@khalisoft/nexcl 1.0.2 → 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/README.md +133 -0
- package/dist/bin/cli.js +0 -0
- package/dist/utils/createProject.js +59 -11
- package/package.json +8 -6
- package/utils/createProject.ts +70 -14
package/README.md
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# nexcl
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@khalisoft/nexcl)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
|
|
6
|
+
**Next.js CLI with built-in admin panel** — Scaffold production-ready Next.js apps with an optional `/ctrl` admin system in seconds.
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Features
|
|
11
|
+
|
|
12
|
+
- **Next.js scaffolding** — Creates apps with TypeScript, App Router, ESLint, and `src/` directory
|
|
13
|
+
- **Optional `/ctrl` admin panel** — Dashboard, Pages, Users, and Settings sections out of the box
|
|
14
|
+
- **Route protection** — Middleware for `/ctrl` routes (ready for your auth logic)
|
|
15
|
+
- **Extra dependencies** — Pre-installs `axios` and `zustand` for common use cases
|
|
16
|
+
- **Interactive prompts** — Simple CLI flow to configure your project
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
# npm
|
|
24
|
+
npm install -g @khalisoft/nexcl
|
|
25
|
+
|
|
26
|
+
# pnpm
|
|
27
|
+
pnpm add -g @khalisoft/nexcl
|
|
28
|
+
|
|
29
|
+
# yarn
|
|
30
|
+
yarn global add @khalisoft/nexcl
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Usage
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
nexcl [project-name]
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
If you omit the project name, you'll be prompted to enter one.
|
|
42
|
+
|
|
43
|
+
### Example
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
nexcl my-app
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
You'll be asked:
|
|
50
|
+
|
|
51
|
+
1. **Project name** — Defaults to `my-app` or the name you passed
|
|
52
|
+
2. **Include /ctrl admin panel?** — `yes` (default) or `no`
|
|
53
|
+
|
|
54
|
+
Then run your app:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
cd my-app && npm run dev
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## What Gets Created
|
|
63
|
+
|
|
64
|
+
### Base Next.js app
|
|
65
|
+
|
|
66
|
+
- TypeScript
|
|
67
|
+
- App Router
|
|
68
|
+
- ESLint
|
|
69
|
+
- `src/` directory
|
|
70
|
+
- Import alias `@/*`
|
|
71
|
+
|
|
72
|
+
### With `/ctrl` admin (optional)
|
|
73
|
+
|
|
74
|
+
- **Layout** — Sidebar navigation (Dashboard, Pages, Users, Settings)
|
|
75
|
+
- **Routes** — `/ctrl`, `/ctrl/pages`, `/ctrl/users`, `/ctrl/settings`
|
|
76
|
+
- **Middleware** — Placeholder for admin route protection
|
|
77
|
+
|
|
78
|
+
### Extra packages
|
|
79
|
+
|
|
80
|
+
- `axios` — HTTP client
|
|
81
|
+
- `zustand` — State management
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## Project Structure (with /ctrl)
|
|
86
|
+
|
|
87
|
+
```
|
|
88
|
+
my-app/
|
|
89
|
+
├── app/
|
|
90
|
+
│ ├── ctrl/
|
|
91
|
+
│ │ ├── layout.tsx
|
|
92
|
+
│ │ ├── page.tsx
|
|
93
|
+
│ │ ├── pages/page.tsx
|
|
94
|
+
│ │ ├── users/page.tsx
|
|
95
|
+
│ │ └── settings/page.tsx
|
|
96
|
+
│ └── ...
|
|
97
|
+
├── src/
|
|
98
|
+
│ └── middleware.ts
|
|
99
|
+
└── ...
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## Development
|
|
105
|
+
|
|
106
|
+
For contributors who want to run the CLI from source:
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
# Clone the repo
|
|
110
|
+
git clone https://github.com/khalisoft/nexcl.git
|
|
111
|
+
cd nexcl
|
|
112
|
+
|
|
113
|
+
# Install dependencies
|
|
114
|
+
pnpm install
|
|
115
|
+
|
|
116
|
+
# Run in dev mode (no build)
|
|
117
|
+
pnpm dev
|
|
118
|
+
|
|
119
|
+
# Build for release
|
|
120
|
+
pnpm build
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## Contributing
|
|
126
|
+
|
|
127
|
+
Contributions are welcome. Please open an issue or submit a pull request.
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## License
|
|
132
|
+
|
|
133
|
+
[MIT](LICENSE) © Devkaahl
|
package/dist/bin/cli.js
CHANGED
|
File without changes
|
|
@@ -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
|
-
|
|
9
|
-
await execa("
|
|
10
|
-
"create
|
|
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
|
-
|
|
19
|
-
|
|
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
|
-
|
|
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
|
-
|
|
35
|
-
console.error(error);
|
|
83
|
+
console.error("❌ Failed:", error);
|
|
36
84
|
}
|
|
37
85
|
}
|
package/package.json
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@khalisoft/nexcl",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.4",
|
|
5
5
|
"description": "Next.js CLI with built-in admin (/ctrl)",
|
|
6
6
|
"bin": {
|
|
7
7
|
"nexcl": "./dist/bin/cli.js"
|
|
8
8
|
},
|
|
9
|
-
"scripts": {
|
|
10
|
-
"build": "tsc",
|
|
11
|
-
"dev": "tsx bin/cli.ts"
|
|
12
|
-
},
|
|
13
9
|
"keywords": [
|
|
14
10
|
"nextjs",
|
|
15
11
|
"cli",
|
|
@@ -31,5 +27,11 @@
|
|
|
31
27
|
"@types/prompts": "^2.4.9",
|
|
32
28
|
"tsx": "^4.21.0",
|
|
33
29
|
"typescript": "^5.9.3"
|
|
30
|
+
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "pnpm version patch && tsc",
|
|
33
|
+
"build:minor": "pnpm version minor && tsc",
|
|
34
|
+
"build:major": "pnpm version major && tsc",
|
|
35
|
+
"dev": "tsx bin/cli.ts"
|
|
34
36
|
}
|
|
35
|
-
}
|
|
37
|
+
}
|
package/utils/createProject.ts
CHANGED
|
@@ -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
|
-
|
|
64
|
+
console.log("🚀 Creating Next.js app...");
|
|
65
|
+
|
|
19
66
|
await execa(
|
|
20
|
-
"
|
|
67
|
+
"npm",
|
|
21
68
|
[
|
|
22
|
-
"create
|
|
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
|
-
{
|
|
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
|
-
|
|
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
|
-
|
|
55
|
-
console.error(error);
|
|
111
|
+
console.error("❌ Failed:", error);
|
|
56
112
|
}
|
|
57
113
|
}
|