@khalisoft/nexcl 1.0.1 → 1.0.3

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.
@@ -1,37 +1,85 @@
1
1
  import { execa } from "execa";
2
- import ora from "ora";
3
2
  import path from "path";
4
3
  import injectCtrl from "./injectCtrl.js";
4
+ // export default async function createProject({
5
+ // projectName,
6
+ // addAdmin,
7
+ // }: Options) {
8
+ // const spinner = ora("Creating Next.js app...").start();
9
+ // try {
10
+ // // ✅ Create Next.js with TypeScript
11
+ // await execa(
12
+ // "npx",
13
+ // [
14
+ // "create-next-app@latest",
15
+ // projectName,
16
+ // "--ts",
17
+ // "--app",
18
+ // "--eslint",
19
+ // "--src-dir",
20
+ // "--import-alias=@/*",
21
+ // "--yes",
22
+ // ],
23
+ // { stdio: "inherit" },
24
+ // );
25
+ // spinner.succeed("Next.js app created");
26
+ // const target = path.join(process.cwd(), projectName);
27
+ // if (addAdmin) {
28
+ // await injectCtrl(target);
29
+ // }
30
+ // const installSpinner = ora("Installing extra dependencies...").start();
31
+ // await execa("npm", ["install", "axios", "zustand"], {
32
+ // cwd: target,
33
+ // stdio: "inherit",
34
+ // });
35
+ // installSpinner.succeed("Dependencies installed");
36
+ // console.log("\n✅ Done!");
37
+ // console.log(`cd ${projectName} && npm run dev`);
38
+ // } catch (error) {
39
+ // spinner.fail("Failed");
40
+ // console.error(error);
41
+ // }
42
+ // }
5
43
  export default async function createProject({ projectName, addAdmin, }) {
6
- const spinner = ora("Creating Next.js app...").start();
7
44
  try {
8
- // Create Next.js with TypeScript
9
- await execa("npx", [
10
- "create-next-app@latest",
45
+ console.log("🚀 Creating Next.js app...");
46
+ await execa("npm", [
47
+ "create",
48
+ "next-app@latest",
11
49
  projectName,
50
+ "--",
12
51
  "--ts",
13
52
  "--app",
14
53
  "--eslint",
15
54
  "--src-dir",
16
55
  "--import-alias=@/*",
17
56
  "--yes",
18
- ], { stdio: "inherit" });
19
- spinner.succeed("Next.js app created");
57
+ "--no-install",
58
+ ], {
59
+ stdio: "inherit",
60
+ shell: true,
61
+ });
20
62
  const target = path.join(process.cwd(), projectName);
63
+ console.log("\n📦 Installing dependencies...");
64
+ await execa("npm", ["install"], {
65
+ cwd: target,
66
+ stdio: "inherit",
67
+ shell: true,
68
+ });
21
69
  if (addAdmin) {
70
+ console.log("\n⚙️ Setting up /ctrl...");
22
71
  await injectCtrl(target);
23
72
  }
24
- const installSpinner = ora("Installing extra dependencies...").start();
73
+ console.log("\n📦 Installing extras...");
25
74
  await execa("npm", ["install", "axios", "zustand"], {
26
75
  cwd: target,
27
76
  stdio: "inherit",
77
+ shell: true,
28
78
  });
29
- installSpinner.succeed("Dependencies installed");
30
79
  console.log("\n✅ Done!");
31
80
  console.log(`cd ${projectName} && npm run dev`);
32
81
  }
33
82
  catch (error) {
34
- spinner.fail("Failed");
35
- console.error(error);
83
+ console.error("Failed:", error);
36
84
  }
37
85
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@khalisoft/nexcl",
3
3
  "type": "module",
4
- "version": "1.0.1",
4
+ "version": "1.0.3",
5
5
  "description": "Next.js CLI with built-in admin (/ctrl)",
6
6
  "bin": {
7
7
  "nexcl": "./dist/bin/cli.js"
@@ -8,50 +8,106 @@ interface Options {
8
8
  addAdmin: boolean;
9
9
  }
10
10
 
11
+ // export default async function createProject({
12
+ // projectName,
13
+ // addAdmin,
14
+ // }: Options) {
15
+ // const spinner = ora("Creating Next.js app...").start();
16
+
17
+ // try {
18
+ // // ✅ Create Next.js with TypeScript
19
+ // await execa(
20
+ // "npx",
21
+ // [
22
+ // "create-next-app@latest",
23
+ // projectName,
24
+ // "--ts",
25
+ // "--app",
26
+ // "--eslint",
27
+ // "--src-dir",
28
+ // "--import-alias=@/*",
29
+ // "--yes",
30
+ // ],
31
+ // { stdio: "inherit" },
32
+ // );
33
+
34
+ // spinner.succeed("Next.js app created");
35
+
36
+ // const target = path.join(process.cwd(), projectName);
37
+
38
+ // if (addAdmin) {
39
+ // await injectCtrl(target);
40
+ // }
41
+
42
+ // const installSpinner = ora("Installing extra dependencies...").start();
43
+
44
+ // await execa("npm", ["install", "axios", "zustand"], {
45
+ // cwd: target,
46
+ // stdio: "inherit",
47
+ // });
48
+
49
+ // installSpinner.succeed("Dependencies installed");
50
+
51
+ // console.log("\n✅ Done!");
52
+ // console.log(`cd ${projectName} && npm run dev`);
53
+ // } catch (error) {
54
+ // spinner.fail("Failed");
55
+ // console.error(error);
56
+ // }
57
+ // }
58
+
11
59
  export default async function createProject({
12
60
  projectName,
13
61
  addAdmin,
14
62
  }: Options) {
15
- const spinner = ora("Creating Next.js app...").start();
16
-
17
63
  try {
18
- // Create Next.js with TypeScript
64
+ console.log("🚀 Creating Next.js app...");
65
+
19
66
  await execa(
20
- "npx",
67
+ "npm",
21
68
  [
22
- "create-next-app@latest",
69
+ "create",
70
+ "next-app@latest",
23
71
  projectName,
72
+ "--",
24
73
  "--ts",
25
74
  "--app",
26
75
  "--eslint",
27
76
  "--src-dir",
28
77
  "--import-alias=@/*",
29
78
  "--yes",
79
+ "--no-install",
30
80
  ],
31
- { stdio: "inherit" },
81
+ {
82
+ stdio: "inherit",
83
+ shell: true,
84
+ },
32
85
  );
33
86
 
34
- spinner.succeed("Next.js app created");
35
-
36
87
  const target = path.join(process.cwd(), projectName);
37
88
 
89
+ console.log("\n📦 Installing dependencies...");
90
+ await execa("npm", ["install"], {
91
+ cwd: target,
92
+ stdio: "inherit",
93
+ shell: true,
94
+ });
95
+
38
96
  if (addAdmin) {
97
+ console.log("\n⚙️ Setting up /ctrl...");
39
98
  await injectCtrl(target);
40
99
  }
41
100
 
42
- const installSpinner = ora("Installing extra dependencies...").start();
43
-
101
+ console.log("\n📦 Installing extras...");
44
102
  await execa("npm", ["install", "axios", "zustand"], {
45
103
  cwd: target,
46
104
  stdio: "inherit",
105
+ shell: true,
47
106
  });
48
107
 
49
- installSpinner.succeed("Dependencies installed");
50
-
51
108
  console.log("\n✅ Done!");
52
109
  console.log(`cd ${projectName} && npm run dev`);
53
110
  } catch (error) {
54
- spinner.fail("Failed");
55
- console.error(error);
111
+ console.error("Failed:", error);
56
112
  }
57
113
  }