create-nextspark-app 0.1.0-beta.1

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 ADDED
@@ -0,0 +1,63 @@
1
+ # create-nextspark-app
2
+
3
+ Create a new NextSpark SaaS project with a single command.
4
+
5
+ ## Usage
6
+
7
+ ```bash
8
+ npx create-nextspark-app my-app
9
+ ```
10
+
11
+ This will:
12
+ 1. Create a new directory `my-app`
13
+ 2. Install `@nextsparkjs/core`
14
+ 3. Run the interactive setup wizard
15
+ 4. Generate your project with all configurations
16
+
17
+ ## Options
18
+
19
+ ```bash
20
+ # Interactive setup (default)
21
+ npx create-nextspark-app my-app
22
+
23
+ # Use a preset to skip some prompts
24
+ npx create-nextspark-app my-app --preset saas
25
+ npx create-nextspark-app my-app --preset blog
26
+ npx create-nextspark-app my-app --preset crm
27
+
28
+ # Skip all prompts (use defaults)
29
+ npx create-nextspark-app my-app -y
30
+ ```
31
+
32
+ ## What's Included
33
+
34
+ - **Next.js 15** with App Router and Turbopack
35
+ - **TypeScript** strict configuration
36
+ - **Tailwind CSS v4** with CSS-based theming
37
+ - **Authentication** ready with Better Auth
38
+ - **Database** setup with PostgreSQL + Drizzle
39
+ - **UI Components** 50+ components based on shadcn/ui
40
+ - **Entity System** with automatic CRUD and APIs
41
+ - **Page Builder** with blocks
42
+ - **Testing** with Jest + Cypress
43
+ - **i18n** with next-intl
44
+
45
+ ## After Creation
46
+
47
+ ```bash
48
+ cd my-app
49
+ pnpm dev
50
+ ```
51
+
52
+ ## Requirements
53
+
54
+ - Node.js 18+
55
+ - pnpm (recommended)
56
+
57
+ ## Documentation
58
+
59
+ Visit [nextspark.dev/docs](https://nextspark.dev/docs) for full documentation.
60
+
61
+ ## License
62
+
63
+ MIT
package/bin/index.js ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import '../dist/index.js'
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node
package/dist/index.js ADDED
@@ -0,0 +1,148 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/index.ts
4
+ import { Command } from "commander";
5
+ import chalk2 from "chalk";
6
+
7
+ // src/create.ts
8
+ import path from "path";
9
+ import fs from "fs-extra";
10
+ import chalk from "chalk";
11
+ import ora from "ora";
12
+ import { execSync } from "child_process";
13
+ async function createProject(options) {
14
+ const { projectName, projectPath, preset } = options;
15
+ if (await fs.pathExists(projectPath)) {
16
+ const files = await fs.readdir(projectPath);
17
+ if (files.length > 0) {
18
+ throw new Error(`Directory "${projectName}" already exists and is not empty`);
19
+ }
20
+ }
21
+ console.log();
22
+ console.log(chalk.bold(` Creating ${chalk.cyan(projectName)}...`));
23
+ console.log();
24
+ const dirSpinner = ora(" Creating project directory...").start();
25
+ await fs.ensureDir(projectPath);
26
+ dirSpinner.succeed(" Project directory created");
27
+ const pkgSpinner = ora(" Initializing package.json...").start();
28
+ const packageJson = {
29
+ name: projectName,
30
+ version: "0.1.0",
31
+ private: true
32
+ };
33
+ await fs.writeJson(path.join(projectPath, "package.json"), packageJson, { spaces: 2 });
34
+ pkgSpinner.succeed(" package.json created");
35
+ const coreSpinner = ora(" Installing @nextsparkjs/core...").start();
36
+ try {
37
+ execSync("pnpm add @nextsparkjs/core", {
38
+ cwd: projectPath,
39
+ stdio: "pipe"
40
+ });
41
+ coreSpinner.succeed(" @nextsparkjs/core installed");
42
+ } catch (error) {
43
+ coreSpinner.fail(" Failed to install @nextsparkjs/core");
44
+ throw error;
45
+ }
46
+ console.log();
47
+ console.log(chalk.blue(" Starting NextSpark wizard..."));
48
+ console.log();
49
+ const presetArg = preset ? ` --preset=${preset}` : "";
50
+ execSync(`npx nextspark init${presetArg}`, {
51
+ cwd: projectPath,
52
+ stdio: "inherit"
53
+ // Interactive mode
54
+ });
55
+ console.log();
56
+ console.log(chalk.bold.green(" Success!"));
57
+ console.log();
58
+ console.log(" Next steps:");
59
+ console.log();
60
+ console.log(chalk.cyan(` cd ${projectName}`));
61
+ console.log(chalk.cyan(" pnpm dev"));
62
+ console.log();
63
+ }
64
+
65
+ // src/utils/prompts.ts
66
+ import path2 from "path";
67
+ import prompts from "prompts";
68
+ async function getProjectOptions(projectName, skipPrompts) {
69
+ if (skipPrompts && projectName) {
70
+ return {
71
+ projectName,
72
+ projectPath: path2.resolve(process.cwd(), projectName)
73
+ };
74
+ }
75
+ if (!projectName) {
76
+ const response = await prompts(
77
+ {
78
+ type: "text",
79
+ name: "projectName",
80
+ message: "What is your project named?",
81
+ initial: "my-nextspark-app",
82
+ validate: (value) => {
83
+ if (!value) return "Project name is required";
84
+ if (!/^[a-z0-9-]+$/.test(value)) {
85
+ return "Project name can only contain lowercase letters, numbers, and hyphens";
86
+ }
87
+ return true;
88
+ }
89
+ },
90
+ {
91
+ onCancel: () => {
92
+ throw new Error("PROMPT_CANCELLED");
93
+ }
94
+ }
95
+ );
96
+ projectName = response.projectName;
97
+ }
98
+ if (!skipPrompts) {
99
+ const confirmResponse = await prompts(
100
+ {
101
+ type: "confirm",
102
+ name: "confirm",
103
+ message: `Create project "${projectName}" in current directory?`,
104
+ initial: true
105
+ },
106
+ {
107
+ onCancel: () => {
108
+ throw new Error("PROMPT_CANCELLED");
109
+ }
110
+ }
111
+ );
112
+ if (!confirmResponse.confirm) {
113
+ throw new Error("PROMPT_CANCELLED");
114
+ }
115
+ }
116
+ return {
117
+ projectName,
118
+ projectPath: path2.resolve(process.cwd(), projectName)
119
+ };
120
+ }
121
+
122
+ // src/index.ts
123
+ var program = new Command();
124
+ program.name("create-nextspark-app").description("Create a new NextSpark SaaS project").version("0.1.0-beta.1").argument("[project-name]", "Name of the project").option("--preset <preset>", "Use a preset (saas, blog, crm)").option("-y, --yes", "Skip prompts and use defaults", false).action(async (projectName, options) => {
125
+ console.log();
126
+ console.log(chalk2.bold.cyan(" NextSpark"));
127
+ console.log(chalk2.dim(" Create a new SaaS project"));
128
+ console.log();
129
+ try {
130
+ const projectOptions = await getProjectOptions(projectName, options.yes);
131
+ await createProject({
132
+ ...projectOptions,
133
+ preset: options.preset
134
+ });
135
+ } catch (error) {
136
+ if (error instanceof Error) {
137
+ if (error.message === "PROMPT_CANCELLED") {
138
+ console.log(chalk2.yellow("\n Setup cancelled.\n"));
139
+ process.exit(0);
140
+ }
141
+ console.error(chalk2.red(` Error: ${error.message}`));
142
+ } else {
143
+ console.error(chalk2.red(" An unexpected error occurred"));
144
+ }
145
+ process.exit(1);
146
+ }
147
+ });
148
+ program.parse();
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "create-nextspark-app",
3
+ "version": "0.1.0-beta.1",
4
+ "description": "Create a new NextSpark SaaS project",
5
+ "type": "module",
6
+ "bin": {
7
+ "create-nextspark-app": "./bin/index.js"
8
+ },
9
+ "main": "./dist/index.js",
10
+ "files": [
11
+ "bin",
12
+ "dist"
13
+ ],
14
+ "scripts": {
15
+ "build": "tsup src/index.ts --format esm --outDir dist",
16
+ "dev": "tsup src/index.ts --format esm --watch --outDir dist"
17
+ },
18
+ "dependencies": {
19
+ "commander": "^12.0.0",
20
+ "chalk": "^5.3.0",
21
+ "ora": "^8.0.0",
22
+ "fs-extra": "^11.0.0",
23
+ "prompts": "^2.4.0"
24
+ },
25
+ "devDependencies": {
26
+ "tsup": "^8.0.0",
27
+ "typescript": "^5.0.0",
28
+ "@types/node": "^20.0.0",
29
+ "@types/fs-extra": "^11.0.0",
30
+ "@types/prompts": "^2.4.0"
31
+ },
32
+ "keywords": [
33
+ "nextspark",
34
+ "create-app",
35
+ "nextjs",
36
+ "saas",
37
+ "cli",
38
+ "boilerplate",
39
+ "starter"
40
+ ],
41
+ "license": "MIT",
42
+ "repository": {
43
+ "type": "git",
44
+ "url": "https://github.com/NextSpark-js/nextspark.git",
45
+ "directory": "packages/create-nextspark-app"
46
+ },
47
+ "engines": {
48
+ "node": ">=18.0.0"
49
+ }
50
+ }