From 88773100537d2478362d53e62b5cc0bce8c3646b Mon Sep 17 00:00:00 2001 From: Aaron Moat <2937187+AaronMoat@users.noreply.github.com> Date: Thu, 25 Apr 2024 16:22:41 +1000 Subject: [PATCH 1/6] Fix package manager detection --- .changeset/slow-moose-smoke.md | 5 + .changeset/ten-pets-hug.md | 8 + .prettierignore | 1 + package.json | 2 +- packages/eslint-config-skuba/.prettierignore | 1 + packages/skuba-dive/.prettierignore | 1 + pnpm-lock.yaml | 149 +++++++++--------- src/cli/__snapshots__/format.int.test.ts.snap | 8 +- src/cli/__snapshots__/lint.int.test.ts.snap | 14 +- .../__snapshots__/project.test.ts.snap | 1 + src/utils/packageManager.test.ts | 63 +++++++- src/utils/packageManager.ts | 26 +-- template/base/_.prettierignore | 1 + 13 files changed, 184 insertions(+), 96 deletions(-) create mode 100644 .changeset/slow-moose-smoke.md create mode 100644 .changeset/ten-pets-hug.md diff --git a/.changeset/slow-moose-smoke.md b/.changeset/slow-moose-smoke.md new file mode 100644 index 000000000..6454a6f8b --- /dev/null +++ b/.changeset/slow-moose-smoke.md @@ -0,0 +1,5 @@ +--- +"skuba": minor +--- + +Add coverage to .prettierignore diff --git a/.changeset/ten-pets-hug.md b/.changeset/ten-pets-hug.md new file mode 100644 index 000000000..f36277cd9 --- /dev/null +++ b/.changeset/ten-pets-hug.md @@ -0,0 +1,8 @@ +--- +'skuba': minor +--- + +Swap out `detect-package-manager` for manual lockfile detection + +`detect-package-manager` has been removed, in lieu of using `find-up` to detect the closest +`pnpm-lock.yaml` or `yarn.lock` to infer the package manager. diff --git a/.prettierignore b/.prettierignore index 1b5cb4b78..7a4b98cdb 100644 --- a/.prettierignore +++ b/.prettierignore @@ -5,6 +5,7 @@ gantry*.yaml gantry*.yml pnpm-lock.yaml +coverage # end managed by skuba /integration/base/ diff --git a/package.json b/package.json index 6e2c244e0..bb5f61e54 100644 --- a/package.json +++ b/package.json @@ -77,7 +77,6 @@ "@types/node": ">=18.12", "chalk": "^4.1.0", "concurrently": "^8.0.0", - "detect-package-manager": "^3.0.1", "dotenv": "^16.0.0", "ejs": "^3.1.6", "enquirer": "^2.3.6", @@ -86,6 +85,7 @@ "eslint-config-skuba": "workspace:*", "execa": "^5.0.0", "fast-glob": "^3.3.2", + "find-up": "^5.0.0", "fs-extra": "^11.0.0", "function-arguments": "^1.0.9", "get-port": "^5.1.1", diff --git a/packages/eslint-config-skuba/.prettierignore b/packages/eslint-config-skuba/.prettierignore index e0ff288a5..80acfad52 100644 --- a/packages/eslint-config-skuba/.prettierignore +++ b/packages/eslint-config-skuba/.prettierignore @@ -5,4 +5,5 @@ gantry*.yaml gantry*.yml pnpm-lock.yaml +coverage # end managed by skuba diff --git a/packages/skuba-dive/.prettierignore b/packages/skuba-dive/.prettierignore index e0ff288a5..80acfad52 100644 --- a/packages/skuba-dive/.prettierignore +++ b/packages/skuba-dive/.prettierignore @@ -5,4 +5,5 @@ gantry*.yaml gantry*.yml pnpm-lock.yaml +coverage # end managed by skuba diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c3de966f2..37977b876 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -38,9 +38,6 @@ importers: concurrently: specifier: ^8.0.0 version: 8.2.2 - detect-package-manager: - specifier: ^3.0.1 - version: 3.0.1 dotenv: specifier: ^16.0.0 version: 16.4.5 @@ -65,6 +62,9 @@ importers: fast-glob: specifier: ^3.3.2 version: 3.3.2 + find-up: + specifier: ^5.0.0 + version: 5.0.0 fs-extra: specifier: ^11.0.0 version: 11.2.0 @@ -88,10 +88,10 @@ importers: version: 1.25.7 jest: specifier: ^29.0.1 - version: 29.7.0(@types/node@20.12.6)(ts-node@10.9.2) + version: 29.7.0(@types/node@20.12.6)(ts-node@10.9.2(@types/node@20.12.6)(typescript@5.4.4)) jest-watch-typeahead: specifier: ^2.1.1 - version: 2.2.2(jest@29.7.0) + version: 2.2.2(jest@29.7.0(@types/node@20.12.6)(ts-node@10.9.2(@types/node@20.12.6)(typescript@5.4.4))) libnpmsearch: specifier: ^7.0.0 version: 7.0.2 @@ -142,7 +142,7 @@ importers: version: 2.2.0 ts-jest: specifier: ^29.1.0 - version: 29.1.2(@babel/core@7.24.4)(@jest/types@29.6.3)(esbuild@0.20.2)(jest@29.7.0)(typescript@5.4.4) + version: 29.1.2(@babel/core@7.24.4)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.24.4))(esbuild@0.20.2)(jest@29.7.0(@types/node@20.12.6)(ts-node@10.9.2(@types/node@20.12.6)(typescript@5.4.4)))(typescript@5.4.4) ts-node: specifier: ^10.9.2 version: 10.9.2(@types/node@20.12.6)(typescript@5.4.4) @@ -170,7 +170,7 @@ importers: version: 2.27.1 '@changesets/get-github-info': specifier: 0.6.0 - version: 0.6.0 + version: 0.6.0(encoding@0.1.13) '@jest/reporters': specifier: 29.7.0 version: 29.7.0 @@ -254,16 +254,16 @@ importers: version: 8.56.7 '@typescript-eslint/eslint-plugin': specifier: ^7.2.0 - version: 7.6.0(@typescript-eslint/parser@7.6.0)(eslint@8.57.0)(typescript@5.3.3) + version: 7.6.0(@typescript-eslint/parser@7.6.0(eslint@8.57.0)(typescript@5.3.3))(eslint@8.57.0)(typescript@5.3.3) '@typescript-eslint/parser': specifier: ^7.2.0 version: 7.6.0(eslint@8.57.0)(typescript@5.3.3) eslint-config-seek: specifier: ^13.0.0 - version: 13.0.0(eslint@8.57.0)(jest@29.7.0)(typescript@5.3.3) + version: 13.0.0(eslint@8.57.0)(jest@29.7.0(@types/node@20.12.6)(ts-node@10.9.2(@types/node@20.12.6)(typescript@5.4.4)))(typescript@5.3.3) eslint-plugin-jest: specifier: ^27.9.0 - version: 27.9.0(@typescript-eslint/eslint-plugin@7.6.0)(eslint@8.57.0)(jest@29.7.0)(typescript@5.3.3) + version: 27.9.0(@typescript-eslint/eslint-plugin@7.6.0(@typescript-eslint/parser@7.6.0(eslint@8.57.0)(typescript@5.3.3))(eslint@8.57.0)(typescript@5.3.3))(eslint@8.57.0)(jest@29.7.0(@types/node@20.12.6)(ts-node@10.9.2(@types/node@20.12.6)(typescript@5.4.4)))(typescript@5.3.3) eslint-plugin-tsdoc: specifier: ^0.2.14 version: 0.2.17 @@ -2059,10 +2059,6 @@ packages: resolution: {integrity: sha512-qE3Veg1YXzGHQhlA6jzebZN2qVf6NX+A7m7qlhCGG30dJixrAQhYOsJjsnBjJkCSmuOPpCk30145fr8FV0bzog==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} - detect-package-manager@3.0.1: - resolution: {integrity: sha512-qoHDH6+lMcpJPAScE7+5CYj91W0mxZNXTwZPrCqi1KMk+x+AoQScQ2V1QyqTln1rHU5Haq5fikvOGHv+leKD8A==} - engines: {node: '>=12'} - devlop@1.1.0: resolution: {integrity: sha512-RWmIqhcFf1lRYBvNmr7qTNuyCt/7/ns2jbpp1+PalgE/rDQcBT0fioSMUpJ93irlUhC5hrg4cYqe6U+0ImW0rA==} @@ -5808,10 +5804,10 @@ snapshots: fs-extra: 7.0.1 semver: 7.6.0 - '@changesets/get-github-info@0.6.0': + '@changesets/get-github-info@0.6.0(encoding@0.1.13)': dependencies: dataloader: 1.4.0 - node-fetch: 2.7.0 + node-fetch: 2.7.0(encoding@0.1.13) transitivePeerDependencies: - encoding @@ -6047,7 +6043,7 @@ snapshots: jest-util: 29.7.0 slash: 3.0.0 - '@jest/core@29.7.0(ts-node@10.9.2)': + '@jest/core@29.7.0(ts-node@10.9.2(@types/node@20.12.6)(typescript@5.4.4))': dependencies: '@jest/console': 29.7.0 '@jest/reporters': 29.7.0 @@ -6061,7 +6057,7 @@ snapshots: exit: 0.1.2 graceful-fs: 4.2.11 jest-changed-files: 29.7.0 - jest-config: 29.7.0(@types/node@20.12.6)(ts-node@10.9.2) + jest-config: 29.7.0(@types/node@20.12.6)(ts-node@10.9.2(@types/node@20.12.6)(typescript@5.4.4)) jest-haste-map: 29.7.0 jest-message-util: 29.7.0 jest-regex-util: 29.6.3 @@ -6433,7 +6429,7 @@ snapshots: '@pnpm/network.ca-file': 1.0.2 config-chain: 1.1.13 - '@semantic-release/commit-analyzer@11.1.0(semantic-release@22.0.12)': + '@semantic-release/commit-analyzer@11.1.0(semantic-release@22.0.12(typescript@5.4.4))': dependencies: conventional-changelog-angular: 7.0.0 conventional-commits-filter: 4.0.0 @@ -6448,7 +6444,7 @@ snapshots: '@semantic-release/error@4.0.0': {} - '@semantic-release/github@9.2.6(semantic-release@22.0.12)': + '@semantic-release/github@9.2.6(semantic-release@22.0.12(typescript@5.4.4))': dependencies: '@octokit/core': 5.2.0 '@octokit/plugin-paginate-rest': 9.2.1(@octokit/core@5.2.0) @@ -6470,7 +6466,7 @@ snapshots: transitivePeerDependencies: - supports-color - '@semantic-release/npm@11.0.3(semantic-release@22.0.12)': + '@semantic-release/npm@11.0.3(semantic-release@22.0.12(typescript@5.4.4))': dependencies: '@semantic-release/error': 4.0.0 aggregate-error: 5.0.0 @@ -6487,7 +6483,7 @@ snapshots: semver: 7.6.0 tempy: 3.1.0 - '@semantic-release/release-notes-generator@12.1.0(semantic-release@22.0.12)': + '@semantic-release/release-notes-generator@12.1.0(semantic-release@22.0.12(typescript@5.4.4))': dependencies: conventional-changelog-angular: 7.0.0 conventional-changelog-writer: 7.0.1 @@ -6780,7 +6776,7 @@ snapshots: dependencies: '@types/yargs-parser': 21.0.3 - '@typescript-eslint/eslint-plugin@7.6.0(@typescript-eslint/parser@7.6.0)(eslint@8.57.0)(typescript@5.3.3)': + '@typescript-eslint/eslint-plugin@7.6.0(@typescript-eslint/parser@7.6.0(eslint@8.57.0)(typescript@5.3.3))(eslint@8.57.0)(typescript@5.3.3)': dependencies: '@eslint-community/regexpp': 4.10.0 '@typescript-eslint/parser': 7.6.0(eslint@8.57.0)(typescript@5.3.3) @@ -6795,6 +6791,7 @@ snapshots: natural-compare: 1.4.0 semver: 7.6.0 ts-api-utils: 1.3.0(typescript@5.3.3) + optionalDependencies: typescript: 5.3.3 transitivePeerDependencies: - supports-color @@ -6807,6 +6804,7 @@ snapshots: '@typescript-eslint/visitor-keys': 7.6.0 debug: 4.3.4 eslint: 8.57.0 + optionalDependencies: typescript: 5.3.3 transitivePeerDependencies: - supports-color @@ -6828,6 +6826,7 @@ snapshots: debug: 4.3.4 eslint: 8.57.0 ts-api-utils: 1.3.0(typescript@5.3.3) + optionalDependencies: typescript: 5.3.3 transitivePeerDependencies: - supports-color @@ -6845,6 +6844,7 @@ snapshots: is-glob: 4.0.3 semver: 7.6.0 tsutils: 3.21.0(typescript@5.3.3) + optionalDependencies: typescript: 5.3.3 transitivePeerDependencies: - supports-color @@ -6859,6 +6859,7 @@ snapshots: minimatch: 9.0.4 semver: 7.6.0 ts-api-utils: 1.3.0(typescript@5.3.3) + optionalDependencies: typescript: 5.3.3 transitivePeerDependencies: - supports-color @@ -6947,11 +6948,11 @@ snapshots: indent-string: 5.0.0 ajv-formats@2.1.1(ajv@8.12.0): - dependencies: + optionalDependencies: ajv: 8.12.0 ajv-formats@3.0.1(ajv@8.12.0): - dependencies: + optionalDependencies: ajv: 8.12.0 ajv@6.12.6: @@ -7468,17 +7469,18 @@ snapshots: js-yaml: 4.1.0 parse-json: 5.2.0 path-type: 4.0.0 + optionalDependencies: typescript: 5.4.4 crc-32@1.2.2: {} - create-jest@29.7.0(@types/node@20.12.6)(ts-node@10.9.2): + create-jest@29.7.0(@types/node@20.12.6)(ts-node@10.9.2(@types/node@20.12.6)(typescript@5.4.4)): dependencies: '@jest/types': 29.6.3 chalk: 4.1.2 exit: 0.1.2 graceful-fs: 4.2.11 - jest-config: 29.7.0(@types/node@20.12.6)(ts-node@10.9.2) + jest-config: 29.7.0(@types/node@20.12.6)(ts-node@10.9.2(@types/node@20.12.6)(typescript@5.4.4)) jest-util: 29.7.0 prompts: 2.4.2 transitivePeerDependencies: @@ -7617,10 +7619,6 @@ snapshots: detect-newline@4.0.1: {} - detect-package-manager@3.0.1: - dependencies: - execa: 5.1.1 - devlop@1.1.0: dependencies: dequal: 2.0.3 @@ -7851,19 +7849,19 @@ snapshots: dependencies: eslint: 8.57.0 - eslint-config-seek@13.0.0(eslint@8.57.0)(jest@29.7.0)(typescript@5.3.3): + eslint-config-seek@13.0.0(eslint@8.57.0)(jest@29.7.0(@types/node@20.12.6)(ts-node@10.9.2(@types/node@20.12.6)(typescript@5.4.4)))(typescript@5.3.3): dependencies: '@babel/core': 7.24.4 '@babel/eslint-parser': 7.24.1(@babel/core@7.24.4)(eslint@8.57.0) '@babel/preset-react': 7.24.1(@babel/core@7.24.4) '@finsit/eslint-plugin-cypress': 3.1.1(eslint@8.57.0) - '@typescript-eslint/eslint-plugin': 7.6.0(@typescript-eslint/parser@7.6.0)(eslint@8.57.0)(typescript@5.3.3) + '@typescript-eslint/eslint-plugin': 7.6.0(@typescript-eslint/parser@7.6.0(eslint@8.57.0)(typescript@5.3.3))(eslint@8.57.0)(typescript@5.3.3) '@typescript-eslint/parser': 7.6.0(eslint@8.57.0)(typescript@5.3.3) eslint: 8.57.0 eslint-config-prettier: 8.10.0(eslint@8.57.0) - eslint-import-resolver-typescript: 3.5.5(@typescript-eslint/parser@7.6.0)(eslint-plugin-import@2.29.1)(eslint@8.57.0) - eslint-plugin-import: 2.29.1(@typescript-eslint/parser@7.6.0)(eslint-import-resolver-typescript@3.5.5)(eslint@8.57.0) - eslint-plugin-jest: 27.9.0(@typescript-eslint/eslint-plugin@7.6.0)(eslint@8.57.0)(jest@29.7.0)(typescript@5.3.3) + eslint-import-resolver-typescript: 3.5.5(@typescript-eslint/parser@7.6.0(eslint@8.57.0)(typescript@5.3.3))(eslint-plugin-import@2.29.1)(eslint@8.57.0) + eslint-plugin-import: 2.29.1(@typescript-eslint/parser@7.6.0(eslint@8.57.0)(typescript@5.3.3))(eslint-import-resolver-typescript@3.5.5)(eslint@8.57.0) + eslint-plugin-jest: 27.9.0(@typescript-eslint/eslint-plugin@7.6.0(@typescript-eslint/parser@7.6.0(eslint@8.57.0)(typescript@5.3.3))(eslint@8.57.0)(typescript@5.3.3))(eslint@8.57.0)(jest@29.7.0(@types/node@20.12.6)(ts-node@10.9.2(@types/node@20.12.6)(typescript@5.4.4)))(typescript@5.3.3) eslint-plugin-react: 7.34.1(eslint@8.57.0) eslint-plugin-react-hooks: 4.6.0(eslint@8.57.0) eslint-plugin-rulesdir: 0.2.2 @@ -7883,13 +7881,13 @@ snapshots: transitivePeerDependencies: - supports-color - eslint-import-resolver-typescript@3.5.5(@typescript-eslint/parser@7.6.0)(eslint-plugin-import@2.29.1)(eslint@8.57.0): + eslint-import-resolver-typescript@3.5.5(@typescript-eslint/parser@7.6.0(eslint@8.57.0)(typescript@5.3.3))(eslint-plugin-import@2.29.1)(eslint@8.57.0): dependencies: debug: 4.3.4 enhanced-resolve: 5.15.0 eslint: 8.57.0 - eslint-module-utils: 2.8.1(@typescript-eslint/parser@7.6.0)(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.5.5)(eslint@8.57.0) - eslint-plugin-import: 2.29.1(@typescript-eslint/parser@7.6.0)(eslint-import-resolver-typescript@3.5.5)(eslint@8.57.0) + eslint-module-utils: 2.8.1(@typescript-eslint/parser@7.6.0(eslint@8.57.0)(typescript@5.3.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.5.5(@typescript-eslint/parser@7.6.0(eslint@8.57.0)(typescript@5.3.3))(eslint-plugin-import@2.29.1)(eslint@8.57.0))(eslint@8.57.0) + eslint-plugin-import: 2.29.1(@typescript-eslint/parser@7.6.0(eslint@8.57.0)(typescript@5.3.3))(eslint-import-resolver-typescript@3.5.5)(eslint@8.57.0) get-tsconfig: 4.7.3 globby: 13.2.2 is-core-module: 2.13.1 @@ -7901,19 +7899,19 @@ snapshots: - eslint-import-resolver-webpack - supports-color - eslint-module-utils@2.8.1(@typescript-eslint/parser@7.6.0)(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.5.5)(eslint@8.57.0): + eslint-module-utils@2.8.1(@typescript-eslint/parser@7.6.0(eslint@8.57.0)(typescript@5.3.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.5.5(@typescript-eslint/parser@7.6.0(eslint@8.57.0)(typescript@5.3.3))(eslint-plugin-import@2.29.1)(eslint@8.57.0))(eslint@8.57.0): dependencies: - '@typescript-eslint/parser': 7.6.0(eslint@8.57.0)(typescript@5.3.3) debug: 3.2.7 + optionalDependencies: + '@typescript-eslint/parser': 7.6.0(eslint@8.57.0)(typescript@5.3.3) eslint: 8.57.0 eslint-import-resolver-node: 0.3.9 - eslint-import-resolver-typescript: 3.5.5(@typescript-eslint/parser@7.6.0)(eslint-plugin-import@2.29.1)(eslint@8.57.0) + eslint-import-resolver-typescript: 3.5.5(@typescript-eslint/parser@7.6.0(eslint@8.57.0)(typescript@5.3.3))(eslint-plugin-import@2.29.1)(eslint@8.57.0) transitivePeerDependencies: - supports-color - eslint-plugin-import@2.29.1(@typescript-eslint/parser@7.6.0)(eslint-import-resolver-typescript@3.5.5)(eslint@8.57.0): + eslint-plugin-import@2.29.1(@typescript-eslint/parser@7.6.0(eslint@8.57.0)(typescript@5.3.3))(eslint-import-resolver-typescript@3.5.5)(eslint@8.57.0): dependencies: - '@typescript-eslint/parser': 7.6.0(eslint@8.57.0)(typescript@5.3.3) array-includes: 3.1.8 array.prototype.findlastindex: 1.2.5 array.prototype.flat: 1.3.2 @@ -7922,7 +7920,7 @@ snapshots: doctrine: 2.1.0 eslint: 8.57.0 eslint-import-resolver-node: 0.3.9 - eslint-module-utils: 2.8.1(@typescript-eslint/parser@7.6.0)(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.5.5)(eslint@8.57.0) + eslint-module-utils: 2.8.1(@typescript-eslint/parser@7.6.0(eslint@8.57.0)(typescript@5.3.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.5.5(@typescript-eslint/parser@7.6.0(eslint@8.57.0)(typescript@5.3.3))(eslint-plugin-import@2.29.1)(eslint@8.57.0))(eslint@8.57.0) hasown: 2.0.2 is-core-module: 2.13.1 is-glob: 4.0.3 @@ -7932,17 +7930,20 @@ snapshots: object.values: 1.2.0 semver: 6.3.1 tsconfig-paths: 3.15.0 + optionalDependencies: + '@typescript-eslint/parser': 7.6.0(eslint@8.57.0)(typescript@5.3.3) transitivePeerDependencies: - eslint-import-resolver-typescript - eslint-import-resolver-webpack - supports-color - eslint-plugin-jest@27.9.0(@typescript-eslint/eslint-plugin@7.6.0)(eslint@8.57.0)(jest@29.7.0)(typescript@5.3.3): + eslint-plugin-jest@27.9.0(@typescript-eslint/eslint-plugin@7.6.0(@typescript-eslint/parser@7.6.0(eslint@8.57.0)(typescript@5.3.3))(eslint@8.57.0)(typescript@5.3.3))(eslint@8.57.0)(jest@29.7.0(@types/node@20.12.6)(ts-node@10.9.2(@types/node@20.12.6)(typescript@5.4.4)))(typescript@5.3.3): dependencies: - '@typescript-eslint/eslint-plugin': 7.6.0(@typescript-eslint/parser@7.6.0)(eslint@8.57.0)(typescript@5.3.3) '@typescript-eslint/utils': 5.62.0(eslint@8.57.0)(typescript@5.3.3) eslint: 8.57.0 - jest: 29.7.0(@types/node@20.12.6)(ts-node@10.9.2) + optionalDependencies: + '@typescript-eslint/eslint-plugin': 7.6.0(@typescript-eslint/parser@7.6.0(eslint@8.57.0)(typescript@5.3.3))(eslint@8.57.0)(typescript@5.3.3) + jest: 29.7.0(@types/node@20.12.6)(ts-node@10.9.2(@types/node@20.12.6)(typescript@5.4.4)) transitivePeerDependencies: - supports-color - typescript @@ -8926,16 +8927,16 @@ snapshots: - babel-plugin-macros - supports-color - jest-cli@29.7.0(@types/node@20.12.6)(ts-node@10.9.2): + jest-cli@29.7.0(@types/node@20.12.6)(ts-node@10.9.2(@types/node@20.12.6)(typescript@5.4.4)): dependencies: - '@jest/core': 29.7.0(ts-node@10.9.2) + '@jest/core': 29.7.0(ts-node@10.9.2(@types/node@20.12.6)(typescript@5.4.4)) '@jest/test-result': 29.7.0 '@jest/types': 29.6.3 chalk: 4.1.2 - create-jest: 29.7.0(@types/node@20.12.6)(ts-node@10.9.2) + create-jest: 29.7.0(@types/node@20.12.6)(ts-node@10.9.2(@types/node@20.12.6)(typescript@5.4.4)) exit: 0.1.2 import-local: 3.1.0 - jest-config: 29.7.0(@types/node@20.12.6)(ts-node@10.9.2) + jest-config: 29.7.0(@types/node@20.12.6)(ts-node@10.9.2(@types/node@20.12.6)(typescript@5.4.4)) jest-util: 29.7.0 jest-validate: 29.7.0 yargs: 17.7.2 @@ -8945,12 +8946,11 @@ snapshots: - supports-color - ts-node - jest-config@29.7.0(@types/node@20.12.6)(ts-node@10.9.2): + jest-config@29.7.0(@types/node@20.12.6)(ts-node@10.9.2(@types/node@20.12.6)(typescript@5.4.4)): dependencies: '@babel/core': 7.24.4 '@jest/test-sequencer': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 20.12.6 babel-jest: 29.7.0(@babel/core@7.24.4) chalk: 4.1.2 ci-info: 3.9.0 @@ -8970,6 +8970,8 @@ snapshots: pretty-format: 29.7.0 slash: 3.0.0 strip-json-comments: 3.1.1 + optionalDependencies: + '@types/node': 20.12.6 ts-node: 10.9.2(@types/node@20.12.6)(typescript@5.4.4) transitivePeerDependencies: - babel-plugin-macros @@ -9052,7 +9054,7 @@ snapshots: jest-util: 29.7.0 jest-pnp-resolver@1.2.3(jest-resolve@29.7.0): - dependencies: + optionalDependencies: jest-resolve: 29.7.0 jest-regex-util@29.6.3: {} @@ -9172,11 +9174,11 @@ snapshots: leven: 3.1.0 pretty-format: 29.7.0 - jest-watch-typeahead@2.2.2(jest@29.7.0): + jest-watch-typeahead@2.2.2(jest@29.7.0(@types/node@20.12.6)(ts-node@10.9.2(@types/node@20.12.6)(typescript@5.4.4))): dependencies: ansi-escapes: 6.2.1 chalk: 5.3.0 - jest: 29.7.0(@types/node@20.12.6)(ts-node@10.9.2) + jest: 29.7.0(@types/node@20.12.6)(ts-node@10.9.2(@types/node@20.12.6)(typescript@5.4.4)) jest-regex-util: 29.6.3 jest-watcher: 29.7.0 slash: 5.1.0 @@ -9201,12 +9203,12 @@ snapshots: merge-stream: 2.0.0 supports-color: 8.1.1 - jest@29.7.0(@types/node@20.12.6)(ts-node@10.9.2): + jest@29.7.0(@types/node@20.12.6)(ts-node@10.9.2(@types/node@20.12.6)(typescript@5.4.4)): dependencies: - '@jest/core': 29.7.0(ts-node@10.9.2) + '@jest/core': 29.7.0(ts-node@10.9.2(@types/node@20.12.6)(typescript@5.4.4)) '@jest/types': 29.6.3 import-local: 3.1.0 - jest-cli: 29.7.0(@types/node@20.12.6)(ts-node@10.9.2) + jest-cli: 29.7.0(@types/node@20.12.6)(ts-node@10.9.2(@types/node@20.12.6)(typescript@5.4.4)) transitivePeerDependencies: - '@types/node' - babel-plugin-macros @@ -9994,9 +9996,11 @@ snapshots: emojilib: 2.4.0 skin-tone: 2.0.0 - node-fetch@2.7.0: + node-fetch@2.7.0(encoding@0.1.13): dependencies: whatwg-url: 5.0.0 + optionalDependencies: + encoding: 0.1.13 node-int64@0.4.0: {} @@ -10307,9 +10311,10 @@ snapshots: prettier-plugin-packagejson@2.4.14(prettier@3.2.5): dependencies: - prettier: 3.2.5 sort-package-json: 2.10.0 synckit: 0.9.0 + optionalDependencies: + prettier: 3.2.5 prettier@2.8.8: {} @@ -10791,11 +10796,11 @@ snapshots: semantic-release@22.0.12(typescript@5.4.4): dependencies: - '@semantic-release/commit-analyzer': 11.1.0(semantic-release@22.0.12) + '@semantic-release/commit-analyzer': 11.1.0(semantic-release@22.0.12(typescript@5.4.4)) '@semantic-release/error': 4.0.0 - '@semantic-release/github': 9.2.6(semantic-release@22.0.12) - '@semantic-release/npm': 11.0.3(semantic-release@22.0.12) - '@semantic-release/release-notes-generator': 12.1.0(semantic-release@22.0.12) + '@semantic-release/github': 9.2.6(semantic-release@22.0.12(typescript@5.4.4)) + '@semantic-release/npm': 11.0.3(semantic-release@22.0.12(typescript@5.4.4)) + '@semantic-release/release-notes-generator': 12.1.0(semantic-release@22.0.12(typescript@5.4.4)) aggregate-error: 5.0.0 cosmiconfig: 8.3.6(typescript@5.4.4) debug: 4.3.4 @@ -11296,14 +11301,11 @@ snapshots: ts-dedent@2.2.0: {} - ts-jest@29.1.2(@babel/core@7.24.4)(@jest/types@29.6.3)(esbuild@0.20.2)(jest@29.7.0)(typescript@5.4.4): + ts-jest@29.1.2(@babel/core@7.24.4)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.24.4))(esbuild@0.20.2)(jest@29.7.0(@types/node@20.12.6)(ts-node@10.9.2(@types/node@20.12.6)(typescript@5.4.4)))(typescript@5.4.4): dependencies: - '@babel/core': 7.24.4 - '@jest/types': 29.6.3 bs-logger: 0.2.6 - esbuild: 0.20.2 fast-json-stable-stringify: 2.1.0 - jest: 29.7.0(@types/node@20.12.6)(ts-node@10.9.2) + jest: 29.7.0(@types/node@20.12.6)(ts-node@10.9.2(@types/node@20.12.6)(typescript@5.4.4)) jest-util: 29.7.0 json5: 2.2.3 lodash.memoize: 4.1.2 @@ -11311,6 +11313,11 @@ snapshots: semver: 7.6.0 typescript: 5.4.4 yargs-parser: 21.1.1 + optionalDependencies: + '@babel/core': 7.24.4 + '@jest/types': 29.6.3 + babel-jest: 29.7.0(@babel/core@7.24.4) + esbuild: 0.20.2 ts-node-dev@2.0.0(@types/node@20.12.6)(typescript@5.4.4): dependencies: diff --git a/src/cli/__snapshots__/format.int.test.ts.snap b/src/cli/__snapshots__/format.int.test.ts.snap index 8d6e6ca3a..24ed6ae8f 100644 --- a/src/cli/__snapshots__/format.int.test.ts.snap +++ b/src/cli/__snapshots__/format.int.test.ts.snap @@ -22,6 +22,7 @@ skuba update complete. Refreshed .eslintignore. refresh-config-files Refreshed .gitignore. refresh-config-files Refreshed .prettierignore. refresh-config-files +Refreshed .npmrc. refresh-config-files Refreshed .dockerignore. refresh-config-files Processed skuba lints in s. @@ -94,6 +95,7 @@ skuba update complete. Refreshed .eslintignore. refresh-config-files Refreshed .gitignore. refresh-config-files Refreshed .prettierignore. refresh-config-files +Refreshed .npmrc. refresh-config-files Refreshed .dockerignore. refresh-config-files Processed skuba lints in s. @@ -108,7 +110,7 @@ Prettier Initialising Prettier... Detected project root: Discovering files... -Discovered 10 files. +Discovered 11 files. Formatting files... .dockerignore parser: - @@ -116,6 +118,8 @@ Formatting files... parser: - .gitignore parser: - +.npmrc + parser: - .prettierignore parser: - b.md @@ -161,6 +165,7 @@ skuba update complete. Refreshed .eslintignore. refresh-config-files Refreshed .gitignore. refresh-config-files Refreshed .prettierignore. refresh-config-files +Refreshed .npmrc. refresh-config-files Refreshed .dockerignore. refresh-config-files Processed skuba lints in s. @@ -199,6 +204,7 @@ skuba update complete. Refreshed .eslintignore. refresh-config-files Refreshed .gitignore. refresh-config-files Refreshed .prettierignore. refresh-config-files +Refreshed .npmrc. refresh-config-files Refreshed .dockerignore. refresh-config-files Processed skuba lints in s. diff --git a/src/cli/__snapshots__/lint.int.test.ts.snap b/src/cli/__snapshots__/lint.int.test.ts.snap index dbd0f70a6..e0bcabae7 100644 --- a/src/cli/__snapshots__/lint.int.test.ts.snap +++ b/src/cli/__snapshots__/lint.int.test.ts.snap @@ -27,7 +27,7 @@ tsc │ tsc --noEmit exited with code 0 skuba │ Processed skuba lints in s. ESLint, Prettier found issues that require triage. -Try running yarn skuba format to fix them. +Try running pnpm exec skuba format to fix them. " `; @@ -72,11 +72,11 @@ ESLint │ Processed 2 files in s. Prettier │ Processed 6 files in s. tsc │ TSFILE: /lib/tsconfig.tsbuildinfo tsc │ tsc --noEmit exited with code 0 -skuba │ skuba has patches to apply. Run yarn skuba format to run them. skuba-patches +skuba │ skuba has patches to apply. Run pnpm exec skuba format to run them. skuba-patches skuba │ Processed skuba lints in s. skuba found issues that require triage. -Try running yarn skuba format to fix them. +Try running pnpm exec skuba format to fix them. " `; @@ -90,7 +90,7 @@ Options: { context: 'skuba-lint', scopeContextToStep: true, style: 'error' } **skuba** \`\`\`term -/package.json skuba has patches to apply. Run yarn skuba format to run them. +/package.json skuba has patches to apply. Run pnpm exec skuba format to run them. \`\`\` ", ] @@ -106,7 +106,7 @@ ESLint │ ○ d.js Prettier │ Initialising Prettier... Prettier │ Detected project root: Prettier │ Discovering files... -Prettier │ Discovered 10 files. +Prettier │ Discovered 11 files. Prettier │ Linting files... Prettier │ .dockerignore Prettier │ parser: - @@ -114,6 +114,8 @@ Prettier │ .eslintignore Prettier │ parser: - Prettier │ .gitignore Prettier │ parser: - +Prettier │ .npmrc +Prettier │ parser: - Prettier │ .prettierignore Prettier │ parser: - Prettier │ b.md @@ -204,7 +206,7 @@ tsc │ tsc --noEmit exited with code 2 skuba │ Processed skuba lints in s. ESLint, Prettier, tsc found issues that require triage. -Try running yarn skuba format to fix them. +Try running pnpm exec skuba format to fix them. " `; diff --git a/src/cli/configure/analysis/__snapshots__/project.test.ts.snap b/src/cli/configure/analysis/__snapshots__/project.test.ts.snap index 0e1fe4e3a..d8d2d395f 100644 --- a/src/cli/configure/analysis/__snapshots__/project.test.ts.snap +++ b/src/cli/configure/analysis/__snapshots__/project.test.ts.snap @@ -91,6 +91,7 @@ yarn-error.log gantry*.yaml gantry*.yml pnpm-lock.yaml +coverage # end managed by skuba ", "operation": "A", diff --git a/src/utils/packageManager.test.ts b/src/utils/packageManager.test.ts index 4ca626b2e..7964de71f 100644 --- a/src/utils/packageManager.test.ts +++ b/src/utils/packageManager.test.ts @@ -1,6 +1,6 @@ -const detect = jest.fn(); +const findUp = jest.fn(); -jest.mock('detect-package-manager', () => ({ detect })); +jest.mock('find-up', () => findUp); import { detectPackageManager } from './packageManager'; @@ -16,7 +16,54 @@ afterEach(stdoutMock.mockReset); describe('detectPackageManager', () => { it('detects pnpm', async () => { - detect.mockResolvedValue('pnpm'); + findUp.mockImplementation((file: string) => + Promise.resolve( + file === 'pnpm-lock.yaml' ? '/root/pnpm-lock.yaml' : undefined, + ), + ); + + await expect(detectPackageManager()).resolves.toMatchInlineSnapshot(` + { + "command": "pnpm", + "exec": "pnpm exec", + "install": "pnpm install", + "runSilent": "pnpm --silent run", + "update": "pnpm update", + } + `); + + expect(stdout()).toBe(''); + }); + + it('preferences yarn on confusing project setups with sibling lockfiles', async () => { + findUp.mockImplementation((file: string) => + Promise.resolve( + file === 'pnpm-lock.yaml' ? '/root/pnpm-lock.yaml' : '/root/yarn.lock', + ), + ); + + await expect(detectPackageManager()).resolves.toMatchInlineSnapshot(` + { + "command": "yarn", + "exec": "yarn", + "install": "yarn install", + "runSilent": "yarn -s", + "update": "yarn upgrade", + } + `); + + expect(stdout()).toBe(''); + }); + + it('preferences the closest lockfile if at different levels', async () => { + findUp.mockImplementation((file: string) => + Promise.resolve( + file === 'pnpm-lock.yaml' + ? '/root/a/b/c/pnpm-lock.yaml' + : '/root/yarn.lock', + ), + ); + await expect(detectPackageManager()).resolves.toMatchInlineSnapshot(` { "command": "pnpm", @@ -31,7 +78,9 @@ describe('detectPackageManager', () => { }); it('detects yarn', async () => { - detect.mockResolvedValue('yarn'); + findUp.mockImplementation((file: string) => + Promise.resolve(file === 'yarn.lock' ? '/root/yarn.lock' : undefined), + ); await expect(detectPackageManager()).resolves.toMatchInlineSnapshot(` { @@ -47,7 +96,7 @@ describe('detectPackageManager', () => { }); it('defaults on unrecognised package manager', async () => { - detect.mockResolvedValue('npm'); + findUp.mockResolvedValue(undefined); await expect(detectPackageManager()).resolves.toMatchInlineSnapshot(` { @@ -62,7 +111,7 @@ describe('detectPackageManager', () => { expect(stdout()).toBe( [ 'Failed to detect package manager; defaulting to yarn.', - 'Expected pnpm|yarn, received npm', + 'No package manager lockfile found.', ].join('\n'), ); }); @@ -70,7 +119,7 @@ describe('detectPackageManager', () => { it('defaults on detection failure', async () => { const message = 'Badness!'; - detect.mockRejectedValue(new Error(message)); + findUp.mockRejectedValue(new Error(message)); await expect(detectPackageManager()).resolves.toMatchInlineSnapshot(` { diff --git a/src/utils/packageManager.ts b/src/utils/packageManager.ts index 7ce8d3cff..991223ccd 100644 --- a/src/utils/packageManager.ts +++ b/src/utils/packageManager.ts @@ -1,6 +1,6 @@ -import { detect } from 'detect-package-manager'; +import findUp from 'find-up'; import isInstalledGlobally from 'is-installed-globally'; -import { ZodError, z } from 'zod'; +import { z } from 'zod'; import { log } from './logging'; @@ -39,11 +39,17 @@ export const detectPackageManager = async ( ): Promise => { let packageManager: PackageManager = DEFAULT_PACKAGE_MANAGER; - let raw: string | undefined; try { - raw = await detect({ cwd, includeGlobalBun: false }); + const [yarnDepth, pnpmDepth] = await Promise.all([ + findDepth('yarn.lock', cwd), + findDepth('pnpm-lock.yaml', cwd), + ]); - packageManager = packageManagerSchema.parse(raw); + if (yarnDepth === undefined && pnpmDepth === undefined) { + throw new Error('No package manager lockfile found.'); + } + + packageManager = (pnpmDepth ?? -1) > (yarnDepth ?? -1) ? 'pnpm' : 'yarn'; } catch (err) { log.warn( `Failed to detect package manager; defaulting to ${log.bold( @@ -53,11 +59,6 @@ export const detectPackageManager = async ( log.subtle( (() => { switch (true) { - case err instanceof ZodError: - return `Expected ${Object.keys(PACKAGE_MANAGERS).join( - '|', - )}, received ${raw}`; - case err instanceof Error: return err.message; @@ -71,6 +72,11 @@ export const detectPackageManager = async ( return configForPackageManager(packageManager); }; +const findDepth = async (filename: string, cwd?: string) => { + const path = await findUp(filename, { cwd }); + return path ? path.split('/').length : undefined; +}; + export type PackageManager = z.infer; export const packageManagerSchema = z diff --git a/template/base/_.prettierignore b/template/base/_.prettierignore index e0ff288a5..80acfad52 100644 --- a/template/base/_.prettierignore +++ b/template/base/_.prettierignore @@ -5,4 +5,5 @@ gantry*.yaml gantry*.yml pnpm-lock.yaml +coverage # end managed by skuba From 02d4e5cb6794ec7f97d1cafba07467459f78cb8b Mon Sep 17 00:00:00 2001 From: skuba <34733141+seek-oss-ci@users.noreply.github.com> Date: Thu, 25 Apr 2024 06:24:42 +0000 Subject: [PATCH 2/6] Run `skuba format` --- .changeset/slow-moose-smoke.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/slow-moose-smoke.md b/.changeset/slow-moose-smoke.md index 6454a6f8b..56863dab0 100644 --- a/.changeset/slow-moose-smoke.md +++ b/.changeset/slow-moose-smoke.md @@ -1,5 +1,5 @@ --- -"skuba": minor +'skuba': minor --- Add coverage to .prettierignore From f40b5eff2424244d53e24d56754262d23598969b Mon Sep 17 00:00:00 2001 From: Aaron Moat <2937187+AaronMoat@users.noreply.github.com> Date: Thu, 25 Apr 2024 16:25:48 +1000 Subject: [PATCH 3/6] pnpmify after bug is fixed --- packages/eslint-config-skuba/.npmrc | 8 ++++++++ packages/skuba-dive/.dockerignore | 6 ------ packages/skuba-dive/.gitignore | 6 ------ packages/skuba-dive/.npmrc | 8 ++++++++ 4 files changed, 16 insertions(+), 12 deletions(-) create mode 100644 packages/eslint-config-skuba/.npmrc create mode 100644 packages/skuba-dive/.npmrc diff --git a/packages/eslint-config-skuba/.npmrc b/packages/eslint-config-skuba/.npmrc new file mode 100644 index 000000000..8db8c5a6c --- /dev/null +++ b/packages/eslint-config-skuba/.npmrc @@ -0,0 +1,8 @@ +# managed by skuba +public-hoist-pattern[]="@types*" +public-hoist-pattern[]="*eslint*" +public-hoist-pattern[]="*prettier*" +public-hoist-pattern[]="esbuild" +public-hoist-pattern[]="jest" +public-hoist-pattern[]="tsconfig-seek" +# end managed by skuba diff --git a/packages/skuba-dive/.dockerignore b/packages/skuba-dive/.dockerignore index 0c55662e6..d428ab05d 100644 --- a/packages/skuba-dive/.dockerignore +++ b/packages/skuba-dive/.dockerignore @@ -15,9 +15,3 @@ node_modules*/ npm-debug.log yarn-error.log # end managed by skuba - -# Ignore .npmrc. This is no longer managed by skuba as pnpm projects use a managed .npmrc. -# IMPORTANT: if migrating to pnpm, remove this line and add an .npmrc IN THE SAME COMMIT. -# You can use `skuba format` to generate the file or otherwise commit an empty file. -# Doing so will conflict with a local .npmrc and make it more difficult to unintentionally commit auth secrets. -.npmrc diff --git a/packages/skuba-dive/.gitignore b/packages/skuba-dive/.gitignore index 36b21a145..b77afb5f3 100644 --- a/packages/skuba-dive/.gitignore +++ b/packages/skuba-dive/.gitignore @@ -21,9 +21,3 @@ npm-debug.log package-lock.json yarn-error.log # end managed by skuba - -# Ignore .npmrc. This is no longer managed by skuba as pnpm projects use a managed .npmrc. -# IMPORTANT: if migrating to pnpm, remove this line and add an .npmrc IN THE SAME COMMIT. -# You can use `skuba format` to generate the file or otherwise commit an empty file. -# Doing so will conflict with a local .npmrc and make it more difficult to unintentionally commit auth secrets. -.npmrc diff --git a/packages/skuba-dive/.npmrc b/packages/skuba-dive/.npmrc new file mode 100644 index 000000000..8db8c5a6c --- /dev/null +++ b/packages/skuba-dive/.npmrc @@ -0,0 +1,8 @@ +# managed by skuba +public-hoist-pattern[]="@types*" +public-hoist-pattern[]="*eslint*" +public-hoist-pattern[]="*prettier*" +public-hoist-pattern[]="esbuild" +public-hoist-pattern[]="jest" +public-hoist-pattern[]="tsconfig-seek" +# end managed by skuba From dfc2ffe345713453d7c28b5a184d5f14f2333b75 Mon Sep 17 00:00:00 2001 From: Aaron Moat <2937187+AaronMoat@users.noreply.github.com> Date: Thu, 25 Apr 2024 16:28:52 +1000 Subject: [PATCH 4/6] changesets --- .changeset/slow-moose-smoke.md | 2 +- .changeset/ten-pets-hug.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.changeset/slow-moose-smoke.md b/.changeset/slow-moose-smoke.md index 56863dab0..f5da14c51 100644 --- a/.changeset/slow-moose-smoke.md +++ b/.changeset/slow-moose-smoke.md @@ -2,4 +2,4 @@ 'skuba': minor --- -Add coverage to .prettierignore +lint: Add coverage to .prettierignore diff --git a/.changeset/ten-pets-hug.md b/.changeset/ten-pets-hug.md index f36277cd9..6c03962f2 100644 --- a/.changeset/ten-pets-hug.md +++ b/.changeset/ten-pets-hug.md @@ -2,7 +2,7 @@ 'skuba': minor --- -Swap out `detect-package-manager` for manual lockfile detection +lint: Swap out `detect-package-manager` for manual lockfile detection `detect-package-manager` has been removed, in lieu of using `find-up` to detect the closest `pnpm-lock.yaml` or `yarn.lock` to infer the package manager. From ce96e625d76490d748f265d8cab341ae4720813e Mon Sep 17 00:00:00 2001 From: Aaron Moat <2937187+AaronMoat@users.noreply.github.com> Date: Tue, 30 Apr 2024 18:55:48 +1000 Subject: [PATCH 5/6] Remove .npmrc --- packages/eslint-config-skuba/.npmrc | 8 -------- packages/skuba-dive/.npmrc | 8 -------- 2 files changed, 16 deletions(-) delete mode 100644 packages/eslint-config-skuba/.npmrc delete mode 100644 packages/skuba-dive/.npmrc diff --git a/packages/eslint-config-skuba/.npmrc b/packages/eslint-config-skuba/.npmrc deleted file mode 100644 index 8db8c5a6c..000000000 --- a/packages/eslint-config-skuba/.npmrc +++ /dev/null @@ -1,8 +0,0 @@ -# managed by skuba -public-hoist-pattern[]="@types*" -public-hoist-pattern[]="*eslint*" -public-hoist-pattern[]="*prettier*" -public-hoist-pattern[]="esbuild" -public-hoist-pattern[]="jest" -public-hoist-pattern[]="tsconfig-seek" -# end managed by skuba diff --git a/packages/skuba-dive/.npmrc b/packages/skuba-dive/.npmrc deleted file mode 100644 index 8db8c5a6c..000000000 --- a/packages/skuba-dive/.npmrc +++ /dev/null @@ -1,8 +0,0 @@ -# managed by skuba -public-hoist-pattern[]="@types*" -public-hoist-pattern[]="*eslint*" -public-hoist-pattern[]="*prettier*" -public-hoist-pattern[]="esbuild" -public-hoist-pattern[]="jest" -public-hoist-pattern[]="tsconfig-seek" -# end managed by skuba From 25b4f80bf365bd444315923ba80ffb09979dd546 Mon Sep 17 00:00:00 2001 From: Aaron Moat <2937187+AaronMoat@users.noreply.github.com> Date: Tue, 30 Apr 2024 18:56:47 +1000 Subject: [PATCH 6/6] Gitignore .npmrc --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 694bdef66..67646fed7 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,6 @@ yarn-error.log /template/**/pnpm-lock.yaml /template/**/yarn.lock /packages/**/*/lib* + +# otherwise changesets break: +/packages/**/.npmrc