@imksh/create 1.0.1 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@imksh/create",
3
- "version": "1.0.1",
3
+ "version": "1.0.4",
4
4
  "description": "A production-ready create for scaffolding modern applications.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,25 +1,34 @@
1
- import { execa } from 'execa';
1
+ import { execa } from "execa";
2
+ import ora from "ora";
2
3
 
3
4
  export async function installPackages(targetDir) {
4
- // Detect package manager based on process.env.npm_config_user_agent
5
- let pm = 'npm';
6
- const userAgent = process.env.npm_config_user_agent;
7
-
8
- if (userAgent) {
9
- if (userAgent.startsWith('yarn')) {
10
- pm = 'yarn';
11
- } else if (userAgent.startsWith('pnpm')) {
12
- pm = 'pnpm';
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
- // Handle mern template differently (it might need install in root, or client/server separately)
17
- // Our mern template will be designed such that 'npm install' at root installs everything
18
- // using workspaces or postinstall scripts.
19
-
20
- await execa(`${pm} install`, {
21
- cwd: targetDir,
22
- stdio: 'ignore',
23
- shell: true
24
- });
25
- }
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
+ }
@@ -2,10 +2,11 @@ import { execa } from 'execa';
2
2
 
3
3
  export async function runGit(targetDir) {
4
4
  try {
5
- await execa('git init', { cwd: targetDir, stdio: 'ignore', shell: true });
6
- await execa('git add .', { cwd: targetDir, stdio: 'ignore', shell: true });
7
- await execa('git commit -m "Initial commit from @imksh/cli"', { cwd: targetDir, stdio: 'ignore', shell: true });
5
+ await execa('git', ['init'], { cwd: targetDir, stdio: 'ignore' });
6
+ await execa('git', ['add', '.'], { cwd: targetDir, stdio: 'ignore' });
7
+ await execa('git', ['commit', '-m', 'Initial commit from @imksh/cli'], { cwd: targetDir, stdio: 'ignore' });
8
8
  } catch (err) {
9
9
  throw new Error('Git initialization failed');
10
10
  }
11
11
  }
12
+