From 87cc5a695df0b62e642714c94684ae04630b5987 Mon Sep 17 00:00:00 2001 From: Percy Ma Date: Sun, 11 Sep 2022 17:36:51 +0800 Subject: [PATCH 1/6] chore: auto gengerate `.npmrc` and setting for pnpm --- docs/content/1.getting-started/1.quick-start.md | 2 +- packages/nuxi/package.json | 3 ++- packages/nuxi/src/commands/init.ts | 11 ++++++++++- yarn.lock | 8 ++++++++ 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/docs/content/1.getting-started/1.quick-start.md b/docs/content/1.getting-started/1.quick-start.md index 365d1cf5706..2e6c8f4ad46 100644 --- a/docs/content/1.getting-started/1.quick-start.md +++ b/docs/content/1.getting-started/1.quick-start.md @@ -70,7 +70,7 @@ npm install ``` ```bash [pnpm] -pnpm install --shamefully-hoist +pnpm install ``` :: diff --git a/packages/nuxi/package.json b/packages/nuxi/package.json index d47852f9a44..8d19787be50 100644 --- a/packages/nuxi/package.json +++ b/packages/nuxi/package.json @@ -44,7 +44,8 @@ "pkg-types": "^0.3.5", "scule": "^0.3.2", "semver": "^7.3.7", - "unbuild": "latest" + "unbuild": "latest", + "which-pm-runs": "^1.1.0" }, "optionalDependencies": { "fsevents": "~2.3.2" diff --git a/packages/nuxi/src/commands/init.ts b/packages/nuxi/src/commands/init.ts index acc6a98e89d..78bab709d94 100644 --- a/packages/nuxi/src/commands/init.ts +++ b/packages/nuxi/src/commands/init.ts @@ -1,6 +1,8 @@ +import { writeFile } from 'node:fs/promises' import { downloadTemplate, startShell } from 'giget' import { relative } from 'pathe' import consola from 'consola' +import detectPackageManager from 'which-pm-runs' import { defineNuxtCommand } from './index' const rpath = (p: string) => relative(process.cwd(), p) @@ -25,11 +27,18 @@ export default defineNuxtCommand({ registry: process.env.NUXI_INIT_REGISTRY || DEFAULT_REGISTRY }) + const pkgManager = detectPackageManager()?.name || 'npm' + // Show next steps const relativeDist = rpath(t.dir) + + if (pkgManager === 'pnpm') { + await writeFile(`${relativeDist}/.npmrc`, 'shamefully-hoist=true') + } + const nextSteps = [ !args.shell && relativeDist.length > 1 && `\`cd ${relativeDist}\``, - 'Install dependencies with `npm install` or `yarn install` or `pnpm install --shamefully-hoist`', + 'Install dependencies with `npm install` or `yarn install` or `pnpm install`', 'Start development server with `npm run dev` or `yarn dev` or `pnpm run dev`' ].filter(Boolean) diff --git a/yarn.lock b/yarn.lock index db3f23b78d6..1402f5eea8a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10164,6 +10164,7 @@ __metadata: scule: ^0.3.2 semver: ^7.3.7 unbuild: latest + which-pm-runs: ^1.1.0 dependenciesMeta: fsevents: optional: true @@ -13942,6 +13943,13 @@ __metadata: languageName: node linkType: hard +"which-pm-runs@npm:^1.1.0": + version: 1.1.0 + resolution: "which-pm-runs@npm:1.1.0" + checksum: 39a56ee50886fb33ec710e3b36dc9fe3d0096cac44850d9ca0c6186c4cb824d6c8125f013e0562e7c94744e1e8e4a6ab695592cdb12555777c7a4368143d822c + languageName: node + linkType: hard + "which@npm:^2.0.1, which@npm:^2.0.2": version: 2.0.2 resolution: "which@npm:2.0.2" From d6e14808afe30a6251630fb3c65821a87f1a57db Mon Sep 17 00:00:00 2001 From: Percy Ma Date: Sun, 11 Sep 2022 18:35:11 +0800 Subject: [PATCH 2/6] chore: add `@types/which-pm-runs` --- packages/nuxi/package.json | 1 + yarn.lock | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/packages/nuxi/package.json b/packages/nuxi/package.json index 8d19787be50..e12cd562afd 100644 --- a/packages/nuxi/package.json +++ b/packages/nuxi/package.json @@ -24,6 +24,7 @@ "@types/flat": "^5.0.2", "@types/mri": "^1.1.1", "@types/semver": "^7", + "@types/which-pm-runs": "^1.0.0", "c12": "^0.2.11", "chokidar": "^3.5.3", "clear": "^0.1.0", diff --git a/yarn.lock b/yarn.lock index 1402f5eea8a..9589c9e66ab 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2692,6 +2692,13 @@ __metadata: languageName: node linkType: hard +"@types/which-pm-runs@npm:^1.0.0": + version: 1.0.0 + resolution: "@types/which-pm-runs@npm:1.0.0" + checksum: a135d7be3250b6a7aebec035d75a514f02f9d39720b20d903edfd6188cb492be41fe0f3dfd43e7ea6b7a27cb58b2d339c6def393a987ffa5d4eb7464d2ab12ed + languageName: node + linkType: hard + "@typescript-eslint/eslint-plugin@npm:^5.36.1": version: 5.36.1 resolution: "@typescript-eslint/eslint-plugin@npm:5.36.1" @@ -10142,6 +10149,7 @@ __metadata: "@types/flat": ^5.0.2 "@types/mri": ^1.1.1 "@types/semver": ^7 + "@types/which-pm-runs": ^1.0.0 c12: ^0.2.11 chokidar: ^3.5.3 clear: ^0.1.0 From e1a471db5c1974c665dc4c8bd59abb041613b28f Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Thu, 10 Nov 2022 15:57:53 +0100 Subject: [PATCH 3/6] update lock --- pnpm-lock.yaml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9e74ab5a57d..056ccc342b9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -352,6 +352,7 @@ importers: '@types/flat': ^5.0.2 '@types/mri': ^1.1.1 '@types/semver': ^7 + '@types/which-pm-runs': ^1.0.0 c12: ^0.2.13 chokidar: ^3.5.3 clear: ^0.1.0 @@ -375,6 +376,7 @@ importers: scule: ^0.3.2 semver: ^7.3.8 unbuild: ^0.9.4 + which-pm-runs: ^1.1.0 optionalDependencies: fsevents: 2.3.2 devDependencies: @@ -384,6 +386,7 @@ importers: '@types/flat': 5.0.2 '@types/mri': 1.1.1 '@types/semver': 7.3.12 + '@types/which-pm-runs': 1.0.0 c12: 0.2.13 chokidar: 3.5.3 clear: 0.1.0 @@ -406,6 +409,7 @@ importers: scule: 0.3.2 semver: 7.3.8 unbuild: 0.9.4 + which-pm-runs: 1.1.0 packages/nuxt: specifiers: @@ -1947,6 +1951,10 @@ packages: source-map: 0.6.1 dev: true + /@types/which-pm-runs/1.0.0: + resolution: {integrity: sha512-BXfdlYLWvRhngJbih4N57DjO+63Z7AxiFiip8yq3rD46U7V4I2W538gngPvBsZiMehhD8sfGf4xLI6k7TgXvNw==} + dev: true + /@types/yargs-parser/21.0.0: resolution: {integrity: sha512-iO9ZQHkZxHn4mSakYV0vFHAVDyEOIJQrV2uZ06HxEPcx+mt8swXoZHIbaaJ2crJYFfErySgktuTZ3BeLz+XmFA==} dev: false @@ -9123,6 +9131,11 @@ packages: is-symbol: 1.0.4 dev: true + /which-pm-runs/1.1.0: + resolution: {integrity: sha512-n1brCuqClxfFfq/Rb0ICg9giSZqCS+pLtccdag6C2HyufBrh3fBOiy9nb6ggRMvWOVH5GrdJskj5iGTZNxd7SA==} + engines: {node: '>=4'} + dev: true + /which/2.0.2: resolution: {integrity: sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==} engines: {node: '>= 8'} From ac0c479045b62008694b7055cfa10726d452d73c Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Thu, 10 Nov 2022 16:39:28 +0100 Subject: [PATCH 4/6] directly check pnpm --- packages/nuxi/package.json | 4 +--- packages/nuxi/src/commands/init.ts | 7 +++---- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/packages/nuxi/package.json b/packages/nuxi/package.json index 9967d7aa684..8496d1edb13 100644 --- a/packages/nuxi/package.json +++ b/packages/nuxi/package.json @@ -24,7 +24,6 @@ "@types/flat": "^5.0.2", "@types/mri": "^1.1.1", "@types/semver": "^7", - "@types/which-pm-runs": "^1.0.0", "c12": "^0.2.13", "chokidar": "^3.5.3", "clear": "^0.1.0", @@ -46,8 +45,7 @@ "pkg-types": "^0.3.6", "scule": "^0.3.2", "semver": "^7.3.8", - "unbuild": "latest", - "which-pm-runs": "^1.1.0" + "unbuild": "latest" }, "optionalDependencies": { "fsevents": "~2.3.2" diff --git a/packages/nuxi/src/commands/init.ts b/packages/nuxi/src/commands/init.ts index 78bab709d94..fee448cfea4 100644 --- a/packages/nuxi/src/commands/init.ts +++ b/packages/nuxi/src/commands/init.ts @@ -2,7 +2,6 @@ import { writeFile } from 'node:fs/promises' import { downloadTemplate, startShell } from 'giget' import { relative } from 'pathe' import consola from 'consola' -import detectPackageManager from 'which-pm-runs' import { defineNuxtCommand } from './index' const rpath = (p: string) => relative(process.cwd(), p) @@ -27,12 +26,12 @@ export default defineNuxtCommand({ registry: process.env.NUXI_INIT_REGISTRY || DEFAULT_REGISTRY }) - const pkgManager = detectPackageManager()?.name || 'npm' - // Show next steps const relativeDist = rpath(t.dir) - if (pkgManager === 'pnpm') { + // Write .nuxtrc with `shamefully-hoist=true` for pnpm + const usingPnpm = (process.env.npm_config_user_agent || '').includes('pnpm') + if (usingPnpm) { await writeFile(`${relativeDist}/.npmrc`, 'shamefully-hoist=true') } From bd4623b1bf8ee47892f58218fcbd3a2d507f9951 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Thu, 10 Nov 2022 17:26:16 +0100 Subject: [PATCH 5/6] update docs --- docs/content/1.getting-started/2.installation.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/content/1.getting-started/2.installation.md b/docs/content/1.getting-started/2.installation.md index 190ecc8041f..63153014fd2 100644 --- a/docs/content/1.getting-started/2.installation.md +++ b/docs/content/1.getting-started/2.installation.md @@ -79,6 +79,10 @@ pnpm install :: +::alert +**Note:** If using **pnpm**, make sure to have `.npmrc` with `shamefully-hoist=true` inside it before `pnpm install`. +:: + ## Development Server Now you'll be able to start your Nuxt app in development mode: From 6f5bdb14c55a6e822810444a383b2ace07e997f3 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Thu, 10 Nov 2022 17:28:43 +0100 Subject: [PATCH 6/6] update lock --- pnpm-lock.yaml | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 056ccc342b9..9e74ab5a57d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -352,7 +352,6 @@ importers: '@types/flat': ^5.0.2 '@types/mri': ^1.1.1 '@types/semver': ^7 - '@types/which-pm-runs': ^1.0.0 c12: ^0.2.13 chokidar: ^3.5.3 clear: ^0.1.0 @@ -376,7 +375,6 @@ importers: scule: ^0.3.2 semver: ^7.3.8 unbuild: ^0.9.4 - which-pm-runs: ^1.1.0 optionalDependencies: fsevents: 2.3.2 devDependencies: @@ -386,7 +384,6 @@ importers: '@types/flat': 5.0.2 '@types/mri': 1.1.1 '@types/semver': 7.3.12 - '@types/which-pm-runs': 1.0.0 c12: 0.2.13 chokidar: 3.5.3 clear: 0.1.0 @@ -409,7 +406,6 @@ importers: scule: 0.3.2 semver: 7.3.8 unbuild: 0.9.4 - which-pm-runs: 1.1.0 packages/nuxt: specifiers: @@ -1951,10 +1947,6 @@ packages: source-map: 0.6.1 dev: true - /@types/which-pm-runs/1.0.0: - resolution: {integrity: sha512-BXfdlYLWvRhngJbih4N57DjO+63Z7AxiFiip8yq3rD46U7V4I2W538gngPvBsZiMehhD8sfGf4xLI6k7TgXvNw==} - dev: true - /@types/yargs-parser/21.0.0: resolution: {integrity: sha512-iO9ZQHkZxHn4mSakYV0vFHAVDyEOIJQrV2uZ06HxEPcx+mt8swXoZHIbaaJ2crJYFfErySgktuTZ3BeLz+XmFA==} dev: false @@ -9131,11 +9123,6 @@ packages: is-symbol: 1.0.4 dev: true - /which-pm-runs/1.1.0: - resolution: {integrity: sha512-n1brCuqClxfFfq/Rb0ICg9giSZqCS+pLtccdag6C2HyufBrh3fBOiy9nb6ggRMvWOVH5GrdJskj5iGTZNxd7SA==} - engines: {node: '>=4'} - dev: true - /which/2.0.2: resolution: {integrity: sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==} engines: {node: '>= 8'}