From 78191d96a115f5328bdcaf5446bb20ab564a6eea Mon Sep 17 00:00:00 2001 From: Drex Date: Fri, 29 Dec 2023 11:53:43 +0100 Subject: [PATCH 1/5] fixed the package installation issue --- packages/cli/src/utils/package-manager.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/cli/src/utils/package-manager.ts b/packages/cli/src/utils/package-manager.ts index e380bfe234..44ee10a505 100644 --- a/packages/cli/src/utils/package-manager.ts +++ b/packages/cli/src/utils/package-manager.ts @@ -7,6 +7,7 @@ import chalk from 'chalk'; import { abort, abortIfCancelled } from './utils'; import { npm, pnpm, yarn, bun, packageManagers } from './constants'; import type { PackageManager } from '../types'; +import { isPackageInstalled } from './package-json'; /** * Detect package manager by checking if the lock file exists. @@ -106,7 +107,7 @@ export async function installPackage({ } const packageManager = await getPackageManager(); - + const s = clack.spinner(); s.start( `${alreadyInstalled ? 'Updating' : 'Installing'} ${chalk.bold.cyan( @@ -116,13 +117,20 @@ export async function installPackage({ try { installPackageWithPackageManager(packageManager, packageName); + await sleep(1000); + const installed = await isPackageInstalled() + + if(!installed) throw new Error('Please try again with the "--legacy-peer-deps" flag or refer docs to install manually: https://million.dev/docs/install') + s.stop( `${alreadyInstalled ? 'Updated' : 'Installed'} ${chalk.bold.cyan( packageName, )} with ${chalk.bold(packageManager.label)}.`, ); + + } catch (e) { clack.log.error( `${chalk.red('Error during installation.')}\n\n${chalk.dim( From 9cfd1460b23c9b75889c6740d21f9b4b124e176d Mon Sep 17 00:00:00 2001 From: Drex Date: Fri, 29 Dec 2023 12:17:55 +0100 Subject: [PATCH 2/5] added the legacy-peer-deps flag --- packages/cli/package.json | 5 +++- packages/cli/src/utils/package-manager.ts | 31 ++++++++++++++++++++--- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/packages/cli/package.json b/packages/cli/package.json index dbc1b07f38..3e3193ed20 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -28,10 +28,12 @@ "dependencies": { "@antfu/ni": "^0.21.8", "@clack/prompts": "^0.7.0", + "@material-ui/core": "^4.12.4", "@sentry/integrations": "^7.69.0", "@sentry/node": "^7.69.0", "chalk": "^5.3.0", - "diff": "^5.1.0" + "diff": "^5.1.0", + "million": "^2.6.4" }, "scripts": { "prepare": "node build.mjs", @@ -44,6 +46,7 @@ "@types/diff": "^5.0.3", "@types/gradient-string": "^1.1.2", "@types/node": "^18.14.1", + "@types/react": "^18.0.27", "esbuild": "^0.14.54", "esbuild-plugin-replace": "^1.4.0", "prettier": "^2.8.4", diff --git a/packages/cli/src/utils/package-manager.ts b/packages/cli/src/utils/package-manager.ts index 44ee10a505..6d19f09e24 100644 --- a/packages/cli/src/utils/package-manager.ts +++ b/packages/cli/src/utils/package-manager.ts @@ -29,7 +29,7 @@ export async function detectPackageManger(): Promise { return bun; default: return null; - } + } } /** @@ -38,8 +38,9 @@ export async function detectPackageManger(): Promise { export function installPackageWithPackageManager( packageManager: PackageManager, packageName: string, + flag?:string ): void { - exec(`${packageManager.installCommand} ${packageName}@latest`); + exec(`${packageManager.installCommand} ${packageName}@latest --${flag}`); } /** @@ -122,7 +123,31 @@ export async function installPackage({ const installed = await isPackageInstalled() - if(!installed) throw new Error('Please try again with the "--legacy-peer-deps" flag or refer docs to install manually: https://million.dev/docs/install') + if(!installed) { + + s.stop(); + + const shouldUseLegacyPeerDeps = await clack.confirm({ + message: `The ${chalk.bold.cyan( + packageName, + )} package did not install, would you like to use the "--legacy-peer-deps" flag?`, + }) + + if (!shouldUseLegacyPeerDeps) { + throw new Error('Please try again or refer docs to install manually: https://million.dev/docs/install') + } + + installPackageWithPackageManager(packageManager, packageName, 'legacy-peer-deps'); + + s.start( + `${alreadyInstalled ? 'Updating' : 'Installing'} ${chalk.bold.cyan( + packageName, + )} with ${chalk.bold(packageManager.label)} and the "--legacy-peer-deps" flag.`, + ); + + await sleep(1000); + + } s.stop( `${alreadyInstalled ? 'Updated' : 'Installed'} ${chalk.bold.cyan( From f75bd0fbfdbce4f9ae6aa882921db7922764b118 Mon Sep 17 00:00:00 2001 From: Drex Date: Fri, 29 Dec 2023 12:22:06 +0100 Subject: [PATCH 3/5] removed dependencies --- packages/cli/package.json | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/cli/package.json b/packages/cli/package.json index 3e3193ed20..dbc1b07f38 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -28,12 +28,10 @@ "dependencies": { "@antfu/ni": "^0.21.8", "@clack/prompts": "^0.7.0", - "@material-ui/core": "^4.12.4", "@sentry/integrations": "^7.69.0", "@sentry/node": "^7.69.0", "chalk": "^5.3.0", - "diff": "^5.1.0", - "million": "^2.6.4" + "diff": "^5.1.0" }, "scripts": { "prepare": "node build.mjs", @@ -46,7 +44,6 @@ "@types/diff": "^5.0.3", "@types/gradient-string": "^1.1.2", "@types/node": "^18.14.1", - "@types/react": "^18.0.27", "esbuild": "^0.14.54", "esbuild-plugin-replace": "^1.4.0", "prettier": "^2.8.4", From 6efc1e68f1bb8a2fb3b5a1d0666ca65c42b04325 Mon Sep 17 00:00:00 2001 From: Drex Date: Fri, 29 Dec 2023 12:28:18 +0100 Subject: [PATCH 4/5] fixed linting issues --- packages/cli/src/utils/package-manager.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/cli/src/utils/package-manager.ts b/packages/cli/src/utils/package-manager.ts index 6d19f09e24..677d0fa5a8 100644 --- a/packages/cli/src/utils/package-manager.ts +++ b/packages/cli/src/utils/package-manager.ts @@ -38,9 +38,9 @@ export async function detectPackageManger(): Promise { export function installPackageWithPackageManager( packageManager: PackageManager, packageName: string, - flag?:string + flag:string = '' ): void { - exec(`${packageManager.installCommand} ${packageName}@latest --${flag}`); + exec(`${packageManager.installCommand} ${packageName}@latest ${flag}`); } /** @@ -137,7 +137,7 @@ export async function installPackage({ throw new Error('Please try again or refer docs to install manually: https://million.dev/docs/install') } - installPackageWithPackageManager(packageManager, packageName, 'legacy-peer-deps'); + installPackageWithPackageManager(packageManager, packageName, '--legacy-peer-deps'); s.start( `${alreadyInstalled ? 'Updating' : 'Installing'} ${chalk.bold.cyan( From 49407fa51877cd66a466dccd256c60dbe1fb92b0 Mon Sep 17 00:00:00 2001 From: Drex Date: Fri, 29 Dec 2023 12:31:46 +0100 Subject: [PATCH 5/5] made changes --- packages/cli/src/utils/package-manager.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cli/src/utils/package-manager.ts b/packages/cli/src/utils/package-manager.ts index 677d0fa5a8..846edb6b3b 100644 --- a/packages/cli/src/utils/package-manager.ts +++ b/packages/cli/src/utils/package-manager.ts @@ -38,7 +38,7 @@ export async function detectPackageManger(): Promise { export function installPackageWithPackageManager( packageManager: PackageManager, packageName: string, - flag:string = '' + flag = '' ): void { exec(`${packageManager.installCommand} ${packageName}@latest ${flag}`); }