@imksh/create 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/utils/installPackages.js +30 -20
package/package.json
CHANGED
|
@@ -1,24 +1,34 @@
|
|
|
1
|
-
import { execa } from
|
|
1
|
+
import { execa } from "execa";
|
|
2
|
+
import ora from "ora";
|
|
2
3
|
|
|
3
4
|
export async function installPackages(targetDir) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
const spinner = ora("Installing dependencies...").start();
|
|
6
|
+
|
|
7
|
+
try {
|
|
8
|
+
let packageManager = "npm";
|
|
9
|
+
|
|
10
|
+
const userAgent = process.env.npm_config_user_agent || "";
|
|
11
|
+
|
|
12
|
+
if (userAgent.startsWith("pnpm")) {
|
|
13
|
+
packageManager = "pnpm";
|
|
14
|
+
} else if (userAgent.startsWith("yarn")) {
|
|
15
|
+
packageManager = "yarn";
|
|
13
16
|
}
|
|
14
|
-
}
|
|
15
17
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
18
|
+
await execa(packageManager, ["install"], {
|
|
19
|
+
cwd: targetDir,
|
|
20
|
+
stdio: "inherit",
|
|
21
|
+
env: process.env,
|
|
22
|
+
preferLocal: false,
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
spinner.succeed("Dependencies installed successfully.");
|
|
26
|
+
} catch (error) {
|
|
27
|
+
spinner.fail("Failed to install dependencies.");
|
|
28
|
+
|
|
29
|
+
console.error("\nInstallation Error:");
|
|
30
|
+
console.error(error.shortMessage || error.message);
|
|
31
|
+
|
|
32
|
+
throw error;
|
|
33
|
+
}
|
|
34
|
+
}
|