From 816bd3455a5376c261a945f602a0548d831ba840 Mon Sep 17 00:00:00 2001 From: Ben Irvin Date: Mon, 24 Oct 2022 18:06:23 +0200 Subject: [PATCH 01/17] lint typescript files --- .eslintrc.js | 13 +++++++++++-- package.json | 8 ++++---- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index f3b0af1942..642cdf6968 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -7,15 +7,24 @@ const frontPaths = [ 'test/config/front/**/*.js', ]; +const backendRules = require('./.eslintrc.back.js'); + module.exports = { parserOptions: { ecmaVersion: 2020, }, overrides: [ { - files: ['packages/**/*.js', 'test/**/*.js', 'scripts/**/*.js'], + files: [ + 'packages/**/*.js', + 'test/**/*.js', + 'scripts/**/*.js', + 'packages/**/*.ts', + 'test/**/*.ts', + 'scripts/**/*.ts', + ], excludedFiles: frontPaths, - ...require('./.eslintrc.back.js'), + ...backendRules, }, { files: frontPaths, diff --git a/package.json b/package.json index 689f7fbd9c..dd6835b154 100644 --- a/package.json +++ b/package.json @@ -35,13 +35,13 @@ "generate": "plop --plopfile ./packages/generators/admin/plopfile.js", "lint": "npm-run-all -p lint:code lint:css", "lint:code": "eslint .", - "lint:css": "stylelint packages/**/admin/src/**/*.js", + "lint:css": "stylelint packages/**/admin/src/**/*.{js,ts}", "lint:fix": "eslint --fix .", "lint:other": "npm run prettier:other -- --check", "format": "npm-run-all -p format:*", "format:code": "npm run prettier:code -- --write", "format:other": "npm run prettier:other -- --write", - "prettier:code": "prettier \"**/*.js\"", + "prettier:code": "prettier \"**/*.{js,ts}\"", "prettier:other": "prettier \"**/*.{md,css,scss,yaml,yml}\"", "test:clean": "rimraf ./coverage", "test:front": "npm run test:clean && cross-env IS_EE=true jest --config ./jest.config.front.js", @@ -56,10 +56,10 @@ "doc:api": "node scripts/open-api/serve.js" }, "lint-staged": { - "*.{js,md,css,scss,yaml,yml}": [ + "*.{js,ts,md,css,scss,yaml,yml}": [ "prettier --write" ], - "*.js": [ + "*.{js,ts}": [ "eslint --fix" ] }, From 54d5eb9df9fed420d758f478e6b2b5541b19c190 Mon Sep 17 00:00:00 2001 From: Ben Irvin Date: Mon, 24 Oct 2022 18:14:18 +0200 Subject: [PATCH 02/17] don't support ts for front-end yet --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index dd6835b154..d98fb23e6c 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "generate": "plop --plopfile ./packages/generators/admin/plopfile.js", "lint": "npm-run-all -p lint:code lint:css", "lint:code": "eslint .", - "lint:css": "stylelint packages/**/admin/src/**/*.{js,ts}", + "lint:css": "stylelint packages/**/admin/src/**/*.js", "lint:fix": "eslint --fix .", "lint:other": "npm run prettier:other -- --check", "format": "npm-run-all -p format:*", From 972d8a9c929523bf5bd48986e3ea208c56550c01 Mon Sep 17 00:00:00 2001 From: Ben Irvin Date: Mon, 7 Nov 2022 11:46:41 +0100 Subject: [PATCH 03/17] add archive option --- .../lib/providers/local-file-destination-provider.ts | 5 +++++ packages/core/strapi/bin/strapi.js | 9 +++++++-- packages/core/strapi/lib/commands/transfer/export.js | 3 +++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/packages/core/data-transfer/lib/providers/local-file-destination-provider.ts b/packages/core/data-transfer/lib/providers/local-file-destination-provider.ts index f46a558575..482cda65fb 100644 --- a/packages/core/data-transfer/lib/providers/local-file-destination-provider.ts +++ b/packages/core/data-transfer/lib/providers/local-file-destination-provider.ts @@ -20,6 +20,11 @@ export interface ILocalFileDestinationProviderOptions { enabled: boolean; }; + // Archive + archive: { + enabled: boolean; + }; + // File file: { path: string; diff --git a/packages/core/strapi/bin/strapi.js b/packages/core/strapi/bin/strapi.js index 93074ea542..c99bc358b8 100755 --- a/packages/core/strapi/bin/strapi.js +++ b/packages/core/strapi/bin/strapi.js @@ -277,7 +277,12 @@ program .argParser(parseInputBool) ) .addOption( - new Option('--compress [boolean]', 'Compress output file using gz') + new Option('--compress [boolean]', 'Compress output file using gzip compression') + .default(true) + .argParser(parseInputBool) + ) + .addOption( + new Option('--archive [boolean]', 'Archive output files using tar') .default(true) .argParser(parseInputBool) ) @@ -310,7 +315,7 @@ program .addOption( new Option( '--schemaComparison ', - 'exact requires every field to match, strict requires Strapi version and schemas to match, subset requires source schema to exist in destination, bypass skips checks', + 'exact requires every field to match, strict requires Strapi version and content type schema fields do not break, subset requires source schema to exist in destination, bypass skips checks', parseInputList ) .choices(['exact', 'strict', 'subset', 'bypass']) diff --git a/packages/core/strapi/lib/commands/transfer/export.js b/packages/core/strapi/lib/commands/transfer/export.js index ca854dd811..004ad03913 100644 --- a/packages/core/strapi/lib/commands/transfer/export.js +++ b/packages/core/strapi/lib/commands/transfer/export.js @@ -52,6 +52,9 @@ module.exports = async (filename, opts) => { compression: { enabled: opts.compress, }, + archive: { + enabled: opts.archive, + }, }; const destination = createLocalFileDestinationProvider(destinationOptions); From e0c969a0dd7fe7389ffe09763db4cd9276cd0b85 Mon Sep 17 00:00:00 2001 From: Ben Irvin Date: Wed, 9 Nov 2022 09:56:05 +0100 Subject: [PATCH 04/17] use @typescript-eslint/parser for typescript --- .eslintrc.js | 22 ++++++++++++++-------- package.json | 2 ++ yarn.lock | 44 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 8 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 642cdf6968..7e4cdbb07a 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -15,17 +15,23 @@ module.exports = { }, overrides: [ { - files: [ - 'packages/**/*.js', - 'test/**/*.js', - 'scripts/**/*.js', - 'packages/**/*.ts', - 'test/**/*.ts', - 'scripts/**/*.ts', - ], + // Backend javascript + files: ['packages/**/*.js', 'test/**/*.js', 'scripts/**/*.js'], excludedFiles: frontPaths, ...backendRules, }, + + // Backend typescript + { + parser: '@typescript-eslint/parser', + plugins: ['@typescript-eslint'], + extends: ['plugin:@typescript-eslint/recommended'], + files: ['packages/**/*.ts', 'test/**/*.ts', 'scripts/**/*.ts'], + excludedFiles: frontPaths, + //...backendRules, // TODO: write a typescript-friendly version of this + }, + + // Frontend { files: frontPaths, ...require('./.eslintrc.front.js'), diff --git a/package.json b/package.json index d98fb23e6c..71780985a9 100644 --- a/package.json +++ b/package.json @@ -70,6 +70,7 @@ "@strapi/eslint-config": "0.1.2", "@swc/core": "1.2.224", "@swc/jest": "0.2.22", + "@typescript-eslint/parser": "5.42.1", "babel-eslint": "10.1.0", "chalk": "4.1.2", "chokidar": "3.5.3", @@ -105,6 +106,7 @@ "stylelint-processor-styled-components": "1.10.0", "supertest": "6.2.4", "ts-jest": "29.0.3", + "typescript": "4.8.4", "yargs": "13.3.2" }, "engines": { diff --git a/yarn.lock b/yarn.lock index 02d504546c..adadfdc2e0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6444,6 +6444,16 @@ semver "^7.3.7" tsutils "^3.21.0" +"@typescript-eslint/parser@5.42.1": + version "5.42.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-5.42.1.tgz#3e66156f2f74b11690b45950d8f5f28a62751d35" + integrity sha512-kAV+NiNBWVQDY9gDJDToTE/NO8BHi4f6b7zTsVAJoTkmB/zlfOpiEVBzHOKtlgTndCKe8vj9F/PuolemZSh50Q== + dependencies: + "@typescript-eslint/scope-manager" "5.42.1" + "@typescript-eslint/types" "5.42.1" + "@typescript-eslint/typescript-estree" "5.42.1" + debug "^4.3.4" + "@typescript-eslint/parser@^5.14.0": version "5.32.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-5.32.0.tgz#1de243443bc6186fb153b9e395b842e46877ca5d" @@ -6462,6 +6472,14 @@ "@typescript-eslint/types" "5.32.0" "@typescript-eslint/visitor-keys" "5.32.0" +"@typescript-eslint/scope-manager@5.42.1": + version "5.42.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.42.1.tgz#05e5e1351485637d466464237e5259b49f609b18" + integrity sha512-QAZY/CBP1Emx4rzxurgqj3rUinfsh/6mvuKbLNMfJMMKYLRBfweus8brgXF8f64ABkIZ3zdj2/rYYtF8eiuksQ== + dependencies: + "@typescript-eslint/types" "5.42.1" + "@typescript-eslint/visitor-keys" "5.42.1" + "@typescript-eslint/type-utils@5.32.0": version "5.32.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-5.32.0.tgz#45a14506fe3fb908600b4cef2f70778f7b5cdc79" @@ -6476,6 +6494,11 @@ resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.32.0.tgz#484273021eeeae87ddb288f39586ef5efeb6dcd8" integrity sha512-EBUKs68DOcT/EjGfzywp+f8wG9Zw6gj6BjWu7KV/IYllqKJFPlZlLSYw/PTvVyiRw50t6wVbgv4p9uE2h6sZrQ== +"@typescript-eslint/types@5.42.1": + version "5.42.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.42.1.tgz#0d4283c30e9b70d2aa2391c36294413de9106df2" + integrity sha512-Qrco9dsFF5lhalz+lLFtxs3ui1/YfC6NdXu+RAGBa8uSfn01cjO7ssCsjIsUs484vny9Xm699FSKwpkCcqwWwA== + "@typescript-eslint/typescript-estree@5.32.0": version "5.32.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.32.0.tgz#282943f34babf07a4afa7b0ff347a8e7b6030d12" @@ -6489,6 +6512,19 @@ semver "^7.3.7" tsutils "^3.21.0" +"@typescript-eslint/typescript-estree@5.42.1": + version "5.42.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.42.1.tgz#f9a223ecb547a781d37e07a5ac6ba9ff681eaef0" + integrity sha512-qElc0bDOuO0B8wDhhW4mYVgi/LZL+igPwXtV87n69/kYC/7NG3MES0jHxJNCr4EP7kY1XVsRy8C/u3DYeTKQmw== + dependencies: + "@typescript-eslint/types" "5.42.1" + "@typescript-eslint/visitor-keys" "5.42.1" + debug "^4.3.4" + globby "^11.1.0" + is-glob "^4.0.3" + semver "^7.3.7" + tsutils "^3.21.0" + "@typescript-eslint/utils@5.32.0": version "5.32.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.32.0.tgz#eccb6b672b94516f1afc6508d05173c45924840c" @@ -6509,6 +6545,14 @@ "@typescript-eslint/types" "5.32.0" eslint-visitor-keys "^3.3.0" +"@typescript-eslint/visitor-keys@5.42.1": + version "5.42.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.42.1.tgz#df10839adf6605e1cdb79174cf21e46df9be4872" + integrity sha512-LOQtSF4z+hejmpUvitPlc4hA7ERGoj2BVkesOcG91HCn8edLGUXbTrErmutmPbl8Bo9HjAvOO/zBKQHExXNA2A== + dependencies: + "@typescript-eslint/types" "5.42.1" + eslint-visitor-keys "^3.3.0" + "@ucast/core@^1.0.0", "@ucast/core@^1.4.1", "@ucast/core@^1.6.1": version "1.10.1" resolved "https://registry.yarnpkg.com/@ucast/core/-/core-1.10.1.tgz#03a77a7804bcb5002a5cad3681e86cd1897e2e1f" From cdb0e0f456e09b24ca0c42f72a13358b9501f365 Mon Sep 17 00:00:00 2001 From: Ben Irvin Date: Wed, 9 Nov 2022 11:02:35 +0100 Subject: [PATCH 05/17] update --- .eslintrc.back.typescript.js | 43 ++++++++++++++++++++++++++++++++++++ .eslintrc.js | 13 ++++------- 2 files changed, 47 insertions(+), 9 deletions(-) create mode 100644 .eslintrc.back.typescript.js diff --git a/.eslintrc.back.typescript.js b/.eslintrc.back.typescript.js new file mode 100644 index 0000000000..e20ebdb5fe --- /dev/null +++ b/.eslintrc.back.typescript.js @@ -0,0 +1,43 @@ +'use strict'; + +module.exports = { + parser: '@typescript-eslint/parser', + plugins: ['@typescript-eslint'], + /** + * TODO: this should extend @strapi/eslint-config but doing so requires configuring parserOption.project, which requires tsconfig.json configuration + */ + // extends: ['plugin:@typescript-eslint/recommended'], + globals: { + strapi: false, + }, + rules: { + // 'import/no-dynamic-require': 'off', + // 'global-require': 'off', + // 'import/no-extraneous-dependencies': [ + // 'error', + // { + // devDependencies: [ + // 'packages/admin-test-utils/**/*.js', + // 'packages/generators/admin/**/*.js', + // 'scripts/**/*.js', + // '**/test/**/*.js', + // '**/tests/**/*.js', + // '**/__tests__/**/*.js', + // '**/__mocks__/**/*.js', + // ], + // }, + // ], + // 'prefer-destructuring': ['error', { AssignmentExpression: { array: false } }], + // 'no-underscore-dangle': 'off', + // 'no-use-before-define': 'off', + // 'no-continue': 'warn', + // 'no-process-exit': 'off', + // 'no-loop-func': 'off', + // 'no-param-reassign': [ + // 'error', + // { + // props: false, + // }, + // ], + }, +}; diff --git a/.eslintrc.js b/.eslintrc.js index 7e4cdbb07a..501b0a7823 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -7,9 +7,7 @@ const frontPaths = [ 'test/config/front/**/*.js', ]; -const backendRules = require('./.eslintrc.back.js'); - -module.exports = { +const backendRules = (module.exports = { parserOptions: { ecmaVersion: 2020, }, @@ -18,17 +16,14 @@ module.exports = { // Backend javascript files: ['packages/**/*.js', 'test/**/*.js', 'scripts/**/*.js'], excludedFiles: frontPaths, - ...backendRules, + ...require('./.eslintrc.back.js'), }, // Backend typescript { - parser: '@typescript-eslint/parser', - plugins: ['@typescript-eslint'], - extends: ['plugin:@typescript-eslint/recommended'], files: ['packages/**/*.ts', 'test/**/*.ts', 'scripts/**/*.ts'], excludedFiles: frontPaths, - //...backendRules, // TODO: write a typescript-friendly version of this + ...require('./.eslintrc.back.typescript.js'), }, // Frontend @@ -37,4 +32,4 @@ module.exports = { ...require('./.eslintrc.front.js'), }, ], -}; +}); From 5128e333c84713a2e28e8363bb579332d9705a07 Mon Sep 17 00:00:00 2001 From: Ben Irvin Date: Wed, 9 Nov 2022 12:25:02 +0100 Subject: [PATCH 06/17] fix --- .eslintrc.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 501b0a7823..0945f68fbb 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -7,7 +7,7 @@ const frontPaths = [ 'test/config/front/**/*.js', ]; -const backendRules = (module.exports = { +module.exports = { parserOptions: { ecmaVersion: 2020, }, @@ -32,4 +32,4 @@ const backendRules = (module.exports = { ...require('./.eslintrc.front.js'), }, ], -}); +}; From b16d10249b3d549f920b3967c3fd45bd129a1e72 Mon Sep 17 00:00:00 2001 From: Mark Kaylor Date: Wed, 9 Nov 2022 16:22:43 +0100 Subject: [PATCH 07/17] Reduce use of getByRole to improve performance --- .../NpmPackagesFilters/FilterSelect.js | 3 +- .../components/NpmPackagesFilters/index.js | 1 + .../tests/__snapshots__/index.test.js.snap | 1 + .../tests/__snapshots__/plugins.test.js.snap | 1 + .../__snapshots__/providers.test.js.snap | 1 + .../pages/MarketplacePage/tests/index.test.js | 1 - .../MarketplacePage/tests/plugins.test.js | 68 +++++++++---------- .../MarketplacePage/tests/providers.test.js | 38 +++++------ 8 files changed, 54 insertions(+), 60 deletions(-) diff --git a/packages/core/admin/admin/src/pages/MarketplacePage/components/NpmPackagesFilters/FilterSelect.js b/packages/core/admin/admin/src/pages/MarketplacePage/components/NpmPackagesFilters/FilterSelect.js index 7e846a738f..7cef3641da 100644 --- a/packages/core/admin/admin/src/pages/MarketplacePage/components/NpmPackagesFilters/FilterSelect.js +++ b/packages/core/admin/admin/src/pages/MarketplacePage/components/NpmPackagesFilters/FilterSelect.js @@ -9,6 +9,7 @@ const FilterSelect = ({ message, value, onChange, possibleFilters, onClear, cust return (