diff --git a/.eslintignore b/.eslintignore index b6a5aa342..863c8058e 100644 --- a/.eslintignore +++ b/.eslintignore @@ -4,7 +4,8 @@ node_modules .now public dist +*.generated.ts # Storybook cache /node_modules/.cache -/storybook-static \ No newline at end of file +/storybook-static diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 24b7fd31e..d8ebef074 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -98,7 +98,7 @@ jobs: - uses: actions/setup-node@v3 with: node-version: 18.13.0 - - name: 📦 Install Dependencies + - name: 🔍 Check Yarn Cache run: yarn install --immutable --immutable-cache --check-cache onesky-upload: diff --git a/.gitignore b/.gitignore index c4888f0b4..a08b4a557 100644 --- a/.gitignore +++ b/.gitignore @@ -57,6 +57,3 @@ node_modules # Storybook build-storybook.log - -# GraphQL -graphql-digest.txt diff --git a/.husky/post-checkout b/.husky/post-checkout deleted file mode 100755 index b3574d90d..000000000 --- a/.husky/post-checkout +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -. "$(dirname "$0")/_/husky.sh" -digest_file='src/graphql/graphql-digest.txt' -current_hash=`cat $(find . -type f -name "*.graphql") | openssl dgst -sha256` -if [ ! -e $digest_file ] || [ `cat $digest_file` != "$current_hash" ]; then - # Only update the hash if the gql codegen succeeded - yarn gql && echo $current_hash > $digest_file -fi diff --git a/.pnp.cjs b/.pnp.cjs index 8dc55b749..1c92066cd 100644 --- a/.pnp.cjs +++ b/.pnp.cjs @@ -94,6 +94,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["babel-preset-react-app", "npm:10.0.1"],\ ["chromatic", "npm:6.9.0"],\ ["clsx", "npm:1.2.1"],\ + ["concurrently", "npm:8.2.2"],\ ["cross-env", "npm:7.0.3"],\ ["css-mediaquery", "npm:0.1.2"],\ ["dnd-core", "npm:16.0.1"],\ @@ -7171,6 +7172,14 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["regenerator-runtime", "npm:0.14.1"]\ ],\ "linkType": "HARD"\ + }],\ + ["npm:7.24.5", {\ + "packageLocation": "./.yarn/cache/@babel-runtime-npm-7.24.5-e4447a1e48-755383192f.zip/node_modules/@babel/runtime/",\ + "packageDependencies": [\ + ["@babel/runtime", "npm:7.24.5"],\ + ["regenerator-runtime", "npm:0.14.1"]\ + ],\ + "linkType": "HARD"\ }]\ ]],\ ["@babel/runtime-corejs3", [\ @@ -18117,6 +18126,16 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["wrap-ansi", "npm:7.0.0"]\ ],\ "linkType": "HARD"\ + }],\ + ["npm:8.0.1", {\ + "packageLocation": "./.yarn/cache/cliui-npm-8.0.1-3b029092cf-79648b3b00.zip/node_modules/cliui/",\ + "packageDependencies": [\ + ["cliui", "npm:8.0.1"],\ + ["string-width", "npm:4.2.3"],\ + ["strip-ansi", "npm:6.0.1"],\ + ["wrap-ansi", "npm:7.0.0"]\ + ],\ + "linkType": "HARD"\ }]\ ]],\ ["clone", [\ @@ -18443,6 +18462,24 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { "linkType": "HARD"\ }]\ ]],\ + ["concurrently", [\ + ["npm:8.2.2", {\ + "packageLocation": "./.yarn/cache/concurrently-npm-8.2.2-8ae42f052b-8ac774df06.zip/node_modules/concurrently/",\ + "packageDependencies": [\ + ["concurrently", "npm:8.2.2"],\ + ["chalk", "npm:4.1.2"],\ + ["date-fns", "npm:2.30.0"],\ + ["lodash", "npm:4.17.21"],\ + ["rxjs", "npm:7.8.1"],\ + ["shell-quote", "npm:1.8.1"],\ + ["spawn-command", "npm:0.0.2"],\ + ["supports-color", "npm:8.1.1"],\ + ["tree-kill", "npm:1.2.2"],\ + ["yargs", "npm:17.7.2"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ ["configstore", [\ ["npm:5.0.1", {\ "packageLocation": "./.yarn/cache/configstore-npm-5.0.1-739433cdc5-60ef65d493.zip/node_modules/configstore/",\ @@ -19207,6 +19244,16 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { "linkType": "HARD"\ }]\ ]],\ + ["date-fns", [\ + ["npm:2.30.0", {\ + "packageLocation": "./.yarn/cache/date-fns-npm-2.30.0-895c790e0f-f7be015232.zip/node_modules/date-fns/",\ + "packageDependencies": [\ + ["date-fns", "npm:2.30.0"],\ + ["@babel/runtime", "npm:7.24.5"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ ["de-indent", [\ ["npm:1.0.2", {\ "packageLocation": "./.yarn/cache/de-indent-npm-1.0.2-66cccde30f-8deacc0f4a.zip/node_modules/de-indent/",\ @@ -27218,6 +27265,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["babel-preset-react-app", "npm:10.0.1"],\ ["chromatic", "npm:6.9.0"],\ ["clsx", "npm:1.2.1"],\ + ["concurrently", "npm:8.2.2"],\ ["cross-env", "npm:7.0.3"],\ ["css-mediaquery", "npm:0.1.2"],\ ["dnd-core", "npm:16.0.1"],\ @@ -31485,6 +31533,14 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["tslib", "npm:2.4.0"]\ ],\ "linkType": "HARD"\ + }],\ + ["npm:7.8.1", {\ + "packageLocation": "./.yarn/cache/rxjs-npm-7.8.1-41c443a75b-de4b53db10.zip/node_modules/rxjs/",\ + "packageDependencies": [\ + ["rxjs", "npm:7.8.1"],\ + ["tslib", "npm:2.4.0"]\ + ],\ + "linkType": "HARD"\ }]\ ]],\ ["safe-buffer", [\ @@ -31846,6 +31902,13 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["shell-quote", "npm:1.7.4"]\ ],\ "linkType": "HARD"\ + }],\ + ["npm:1.8.1", {\ + "packageLocation": "./.yarn/cache/shell-quote-npm-1.8.1-fcccf06093-5f01201f4e.zip/node_modules/shell-quote/",\ + "packageDependencies": [\ + ["shell-quote", "npm:1.8.1"]\ + ],\ + "linkType": "HARD"\ }]\ ]],\ ["shelljs", [\ @@ -32167,6 +32230,15 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { "linkType": "HARD"\ }]\ ]],\ + ["spawn-command", [\ + ["npm:0.0.2", {\ + "packageLocation": "./.yarn/cache/spawn-command-npm-0.0.2-014d4d5d9f-e35c5d2817.zip/node_modules/spawn-command/",\ + "packageDependencies": [\ + ["spawn-command", "npm:0.0.2"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ ["spdx-correct", [\ ["npm:3.1.1", {\ "packageLocation": "./.yarn/cache/spdx-correct-npm-3.1.1-47f574c27a-77ce438344.zip/node_modules/spdx-correct/",\ @@ -33564,6 +33636,15 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { "linkType": "HARD"\ }]\ ]],\ + ["tree-kill", [\ + ["npm:1.2.2", {\ + "packageLocation": "./.yarn/cache/tree-kill-npm-1.2.2-3da0e5a759-49117f5f41.zip/node_modules/tree-kill/",\ + "packageDependencies": [\ + ["tree-kill", "npm:1.2.2"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ ["trim", [\ ["npm:0.0.3", {\ "packageLocation": "./.yarn/cache/trim-npm-0.0.3-b61d14256f-9a059ba56d.zip/node_modules/trim/",\ @@ -36018,6 +36099,20 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["yargs-parser", "npm:21.1.1"]\ ],\ "linkType": "HARD"\ + }],\ + ["npm:17.7.2", {\ + "packageLocation": "./.yarn/cache/yargs-npm-17.7.2-80b62638e1-73b572e863.zip/node_modules/yargs/",\ + "packageDependencies": [\ + ["yargs", "npm:17.7.2"],\ + ["cliui", "npm:8.0.1"],\ + ["escalade", "npm:3.1.1"],\ + ["get-caller-file", "npm:2.0.5"],\ + ["require-directory", "npm:2.1.1"],\ + ["string-width", "npm:4.2.3"],\ + ["y18n", "npm:5.0.8"],\ + ["yargs-parser", "npm:21.1.1"]\ + ],\ + "linkType": "HARD"\ }]\ ]],\ ["yargs-parser", [\ diff --git a/.yarn/cache/@babel-runtime-npm-7.24.5-e4447a1e48-755383192f.zip b/.yarn/cache/@babel-runtime-npm-7.24.5-e4447a1e48-755383192f.zip new file mode 100644 index 000000000..ac486819e Binary files /dev/null and b/.yarn/cache/@babel-runtime-npm-7.24.5-e4447a1e48-755383192f.zip differ diff --git a/.yarn/cache/cliui-npm-8.0.1-3b029092cf-79648b3b00.zip b/.yarn/cache/cliui-npm-8.0.1-3b029092cf-79648b3b00.zip new file mode 100644 index 000000000..a90643c5e Binary files /dev/null and b/.yarn/cache/cliui-npm-8.0.1-3b029092cf-79648b3b00.zip differ diff --git a/.yarn/cache/concurrently-npm-8.2.2-8ae42f052b-8ac774df06.zip b/.yarn/cache/concurrently-npm-8.2.2-8ae42f052b-8ac774df06.zip new file mode 100644 index 000000000..44ed3b8a2 Binary files /dev/null and b/.yarn/cache/concurrently-npm-8.2.2-8ae42f052b-8ac774df06.zip differ diff --git a/.yarn/cache/date-fns-npm-2.30.0-895c790e0f-f7be015232.zip b/.yarn/cache/date-fns-npm-2.30.0-895c790e0f-f7be015232.zip new file mode 100644 index 000000000..f51ffd3ec Binary files /dev/null and b/.yarn/cache/date-fns-npm-2.30.0-895c790e0f-f7be015232.zip differ diff --git a/.yarn/cache/rxjs-npm-7.8.1-41c443a75b-de4b53db10.zip b/.yarn/cache/rxjs-npm-7.8.1-41c443a75b-de4b53db10.zip new file mode 100644 index 000000000..0bd98badb Binary files /dev/null and b/.yarn/cache/rxjs-npm-7.8.1-41c443a75b-de4b53db10.zip differ diff --git a/.yarn/cache/shell-quote-npm-1.8.1-fcccf06093-5f01201f4e.zip b/.yarn/cache/shell-quote-npm-1.8.1-fcccf06093-5f01201f4e.zip new file mode 100644 index 000000000..3ed7b53ce Binary files /dev/null and b/.yarn/cache/shell-quote-npm-1.8.1-fcccf06093-5f01201f4e.zip differ diff --git a/.yarn/cache/spawn-command-npm-0.0.2-014d4d5d9f-e35c5d2817.zip b/.yarn/cache/spawn-command-npm-0.0.2-014d4d5d9f-e35c5d2817.zip new file mode 100644 index 000000000..7808b8c23 Binary files /dev/null and b/.yarn/cache/spawn-command-npm-0.0.2-014d4d5d9f-e35c5d2817.zip differ diff --git a/.yarn/cache/tree-kill-npm-1.2.2-3da0e5a759-49117f5f41.zip b/.yarn/cache/tree-kill-npm-1.2.2-3da0e5a759-49117f5f41.zip new file mode 100644 index 000000000..c9ef40137 Binary files /dev/null and b/.yarn/cache/tree-kill-npm-1.2.2-3da0e5a759-49117f5f41.zip differ diff --git a/.yarn/cache/yargs-npm-17.7.2-80b62638e1-73b572e863.zip b/.yarn/cache/yargs-npm-17.7.2-80b62638e1-73b572e863.zip new file mode 100644 index 000000000..54c49dc9c Binary files /dev/null and b/.yarn/cache/yargs-npm-17.7.2-80b62638e1-73b572e863.zip differ diff --git a/README.md b/README.md index aecd22502..ecdb55b9d 100644 --- a/README.md +++ b/README.md @@ -689,11 +689,3 @@ To learn more about Next.js, take a look at the following resources: - [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome! - -## Troubleshooting - -If you run into issues with the Typescript linter saying that `types.generated` cannot be found, try running this command to clear out stale generated files: - -```bash -find . -type f -name "*.generated.ts" -delete && yarn gql -``` diff --git a/codegen.yml b/codegen.yml index 3af28778d..d3dc9bd9e 100644 --- a/codegen.yml +++ b/codegen.yml @@ -4,8 +4,6 @@ generates: - ${API_URL:https://api.stage.mpdx.org/graphql} - ./pages/api/Schema/**/*.graphql plugins: - - add: - content: '/* eslint-disable */' - typescript config: scalars: @@ -20,8 +18,6 @@ generates: presetConfig: baseTypesPath: src/graphql/types.generated.ts plugins: - - add: - content: '/* eslint-disable */' - typescript-operations - typescript-react-apollo config: @@ -43,8 +39,6 @@ generates: - ${API_URL:https://api.stage.mpdx.org/graphql} - ./pages/api/Schema/**/*.graphql plugins: - - add: - content: '/* eslint-disable */' - typescript - typescript-resolvers config: @@ -60,3 +54,4 @@ generates: hooks: afterAllFileWrite: - prettier --write + - node deleteStaleFiles.mjs diff --git a/deleteStaleFiles.mjs b/deleteStaleFiles.mjs new file mode 100644 index 000000000..c296e906b --- /dev/null +++ b/deleteStaleFiles.mjs @@ -0,0 +1,23 @@ +import { execSync } from 'node:child_process'; +import { unlinkSync } from 'node:fs'; +import { relative } from 'node:path'; + +const normalize = (filename) => relative(process.cwd(), filename); + +// This script receives the list of generated files, each in a separate argument. +// Some of them are relative to the project root, and some of them are absolute. +// Skip the first argument (node) and the second argument (the script filename) +// and convert to a newline-separated list of paths relative to the project root. +const filesToKeep = new Set(process.argv.slice(2).map(normalize)); + +const allFiles = execSync('find . -type f -name "*.generated.ts"') + .toString() + .trim() + .split('\n') + .map(normalize); + +allFiles.forEach((filename) => { + if (!filesToKeep.has(filename)) { + unlinkSync(filename); + } +}); diff --git a/package.json b/package.json index 5c29e4886..ed1e9d5ec 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "0.1.0", "private": true, "scripts": { - "start": "next dev", + "start": "concurrently 'next dev' 'yarn gql:w' --kill-others", "build": "next build", "build:analyze": "ANALYZE=true yarn build", "build:amplify": "AMPLIFY_NEXTJS_EXPERIMENTAL_TRACE=true next build", @@ -129,6 +129,7 @@ "babel-loader": "^8.2.2", "babel-preset-react-app": "^10.0.0", "chromatic": "^6.9.0", + "concurrently": "^8.2.2", "cross-env": "^7.0.3", "css-mediaquery": "^0.1.2", "dnd-core": "^16.0.1", diff --git a/yarn.lock b/yarn.lock index c0d40db5b..2cb863cab 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2711,6 +2711,15 @@ __metadata: languageName: node linkType: hard +"@babel/runtime@npm:^7.21.0": + version: 7.24.5 + resolution: "@babel/runtime@npm:7.24.5" + dependencies: + regenerator-runtime: ^0.14.0 + checksum: 755383192f3ac32ba4c62bd4f1ae92aed5b82d2c6665f39eb28fa94546777cf5c63493ea92dd03f1c2e621b17e860f190c056684b7f234270fdc91e29beda063 + languageName: node + linkType: hard + "@babel/runtime@npm:^7.23.9": version: 7.24.0 resolution: "@babel/runtime@npm:7.24.0" @@ -10789,6 +10798,17 @@ __metadata: languageName: node linkType: hard +"cliui@npm:^8.0.1": + version: 8.0.1 + resolution: "cliui@npm:8.0.1" + dependencies: + string-width: ^4.2.0 + strip-ansi: ^6.0.1 + wrap-ansi: ^7.0.0 + checksum: 79648b3b0045f2e285b76fb2e24e207c6db44323581e421c3acbd0e86454cba1b37aea976ab50195a49e7384b871e6dfb2247ad7dec53c02454ac6497394cb56 + languageName: node + linkType: hard + "clone-buffer@npm:^1.0.0": version: 1.0.0 resolution: "clone-buffer@npm:1.0.0" @@ -11073,6 +11093,26 @@ __metadata: languageName: node linkType: hard +"concurrently@npm:^8.2.2": + version: 8.2.2 + resolution: "concurrently@npm:8.2.2" + dependencies: + chalk: ^4.1.2 + date-fns: ^2.30.0 + lodash: ^4.17.21 + rxjs: ^7.8.1 + shell-quote: ^1.8.1 + spawn-command: 0.0.2 + supports-color: ^8.1.1 + tree-kill: ^1.2.2 + yargs: ^17.7.2 + bin: + conc: dist/bin/concurrently.js + concurrently: dist/bin/concurrently.js + checksum: 8ac774df06869773438f1bf91025180c52d5b53139bc86cf47659136c0d97461d0579c515d848d1e945d4e3e0cafe646b2ea18af8d74259b46abddcfe39b2c6c + languageName: node + linkType: hard + "configstore@npm:^5.0.1": version: 5.0.1 resolution: "configstore@npm:5.0.1" @@ -11736,6 +11776,15 @@ __metadata: languageName: node linkType: hard +"date-fns@npm:^2.30.0": + version: 2.30.0 + resolution: "date-fns@npm:2.30.0" + dependencies: + "@babel/runtime": ^7.21.0 + checksum: f7be01523282e9bb06c0cd2693d34f245247a29098527d4420628966a2d9aad154bd0e90a6b1cf66d37adcb769cd108cf8a7bd49d76db0fb119af5cdd13644f4 + languageName: node + linkType: hard + "de-indent@npm:^1.0.2": version: 1.0.2 resolution: "de-indent@npm:1.0.2" @@ -18620,6 +18669,7 @@ __metadata: babel-preset-react-app: ^10.0.0 chromatic: ^6.9.0 clsx: ^1.2.1 + concurrently: ^8.2.2 cross-env: ^7.0.3 css-mediaquery: ^0.1.2 dnd-core: ^16.0.1 @@ -22191,6 +22241,15 @@ __metadata: languageName: node linkType: hard +"rxjs@npm:^7.8.1": + version: 7.8.1 + resolution: "rxjs@npm:7.8.1" + dependencies: + tslib: ^2.1.0 + checksum: de4b53db1063e618ec2eca0f7965d9137cabe98cf6be9272efe6c86b47c17b987383df8574861bcced18ebd590764125a901d5506082be84a8b8e364bf05f119 + languageName: node + linkType: hard + "safe-buffer@npm:5.1.1": version: 5.1.1 resolution: "safe-buffer@npm:5.1.1" @@ -22549,6 +22608,13 @@ __metadata: languageName: node linkType: hard +"shell-quote@npm:^1.8.1": + version: 1.8.1 + resolution: "shell-quote@npm:1.8.1" + checksum: 5f01201f4ef504d4c6a9d0d283fa17075f6770bfbe4c5850b074974c68062f37929ca61700d95ad2ac8822e14e8c4b990ca0e6e9272e64befd74ce5e19f0736b + languageName: node + linkType: hard + "shelljs@npm:^0.8.5": version: 0.8.5 resolution: "shelljs@npm:0.8.5" @@ -22839,6 +22905,13 @@ __metadata: languageName: node linkType: hard +"spawn-command@npm:0.0.2": + version: 0.0.2 + resolution: "spawn-command@npm:0.0.2" + checksum: e35c5d28177b4d461d33c88cc11f6f3a5079e2b132c11e1746453bbb7a0c0b8a634f07541a2a234fa4758239d88203b758def509161b651e81958894c0b4b64b + languageName: node + linkType: hard + "spdx-correct@npm:^3.0.0": version: 3.1.1 resolution: "spdx-correct@npm:3.1.1" @@ -23471,7 +23544,7 @@ __metadata: languageName: node linkType: hard -"supports-color@npm:^8.0.0": +"supports-color@npm:^8.0.0, supports-color@npm:^8.1.1": version: 8.1.1 resolution: "supports-color@npm:8.1.1" dependencies: @@ -23981,6 +24054,15 @@ __metadata: languageName: node linkType: hard +"tree-kill@npm:^1.2.2": + version: 1.2.2 + resolution: "tree-kill@npm:1.2.2" + bin: + tree-kill: cli.js + checksum: 49117f5f410d19c84b0464d29afb9642c863bc5ba40fcb9a245d474c6d5cc64d1b177a6e6713129eb346b40aebb9d4631d967517f9fbe8251c35b21b13cd96c7 + languageName: node + linkType: hard + "trim-newlines@npm:^3.0.1": version: 3.0.1 resolution: "trim-newlines@npm:3.0.1" @@ -25985,7 +26067,7 @@ __metadata: languageName: node linkType: hard -"yargs-parser@npm:^21.0.0": +"yargs-parser@npm:^21.0.0, yargs-parser@npm:^21.1.1": version: 21.1.1 resolution: "yargs-parser@npm:21.1.1" checksum: ed2d96a616a9e3e1cc7d204c62ecc61f7aaab633dcbfab2c6df50f7f87b393993fe6640d017759fe112d0cb1e0119f2b4150a87305cc873fd90831c6a58ccf1c @@ -26041,6 +26123,21 @@ __metadata: languageName: node linkType: hard +"yargs@npm:^17.7.2": + version: 17.7.2 + resolution: "yargs@npm:17.7.2" + dependencies: + cliui: ^8.0.1 + escalade: ^3.1.1 + get-caller-file: ^2.0.5 + require-directory: ^2.1.1 + string-width: ^4.2.3 + y18n: ^5.0.5 + yargs-parser: ^21.1.1 + checksum: 73b572e863aa4a8cbef323dd911d79d193b772defd5a51aab0aca2d446655216f5002c42c5306033968193bdbf892a7a4c110b0d77954a7fdf563e653967b56a + languageName: node + linkType: hard + "yauzl@npm:^2.10.0": version: 2.10.0 resolution: "yauzl@npm:2.10.0"