@fernir2/saas-kit-cli 0.1.0 → 0.1.2
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/bin/create-saas-kit-app.js +81 -81
- package/package.json +2 -5
|
@@ -16,28 +16,28 @@ const __filename = fileURLToPath(import.meta.url);
|
|
|
16
16
|
const __dirname = path.dirname(__filename);
|
|
17
17
|
|
|
18
18
|
function log(message) {
|
|
19
|
-
|
|
19
|
+
console.log(`\x1b[36m[saas-kit-cli]\x1b[0m ${message}`);
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
function logError(message) {
|
|
23
|
-
|
|
23
|
+
console.error(`\x1b[31m[saas-kit-cli ERROR]\x1b[0m ${message}`);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
function runCommand(command, cwd) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
try {
|
|
28
|
+
execSync(command, { stdio: "inherit", cwd: cwd || process.cwd() });
|
|
29
|
+
} catch (error) {
|
|
30
|
+
logError(`Command failed: ${command}`);
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
async function main() {
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
const args = process.argv.slice(2);
|
|
37
|
+
const command = args[0];
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
if (!command || command === "help" || command === "--help" || command === "-h") {
|
|
40
|
+
console.log(`
|
|
41
41
|
╔═══════════════════════════════════════════════════════════╗
|
|
42
42
|
║ SaaS Kit CLI ║
|
|
43
43
|
║ by Fernir.io ║
|
|
@@ -56,90 +56,90 @@ This will:
|
|
|
56
56
|
|
|
57
57
|
More information: https://saaskit.us
|
|
58
58
|
`);
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
process.exit(0);
|
|
60
|
+
}
|
|
61
61
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
62
|
+
if (command !== "create-saas-kit-app") {
|
|
63
|
+
logError(`Unknown command: ${command}`);
|
|
64
|
+
logError(`Run "npx @fernir2/saas-kit-cli help" for usage information`);
|
|
65
|
+
process.exit(1);
|
|
66
|
+
}
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
const projectName = args[1];
|
|
69
69
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
70
|
+
if (!projectName) {
|
|
71
|
+
logError("Project name is required");
|
|
72
|
+
logError("Usage: npx @fernir2/saas-kit-cli create-saas-kit-app <project-name>");
|
|
73
|
+
process.exit(1);
|
|
74
|
+
}
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
const targetDir = path.resolve(process.cwd(), projectName);
|
|
77
77
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
78
|
+
if (existsSync(targetDir)) {
|
|
79
|
+
logError(`Directory "${projectName}" already exists`);
|
|
80
|
+
process.exit(1);
|
|
81
|
+
}
|
|
82
82
|
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
log(`Creating SaaS Kit application: ${projectName}`);
|
|
84
|
+
log("This will take a few minutes...\n");
|
|
85
85
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
86
|
+
// Create temp directory for downloading the package
|
|
87
|
+
const tempDir = path.join(process.cwd(), `.saas-kit-temp-${Date.now()}`);
|
|
88
|
+
mkdirSync(tempDir, { recursive: true });
|
|
89
89
|
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
try {
|
|
91
|
+
log("Step 1/3: Installing @fernir2/saas-kit package...");
|
|
92
92
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
93
|
+
// Install the main package temporarily
|
|
94
|
+
runCommand("npm init -y", tempDir);
|
|
95
|
+
runCommand("npm install @fernir2/saas-kit@latest", tempDir);
|
|
96
96
|
|
|
97
|
-
|
|
97
|
+
log("\nStep 2/3: Creating your application...");
|
|
98
98
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
99
|
+
// Run the create-saas-kit-app binary from the installed package
|
|
100
|
+
const saasKitBinPath = path.join(
|
|
101
|
+
tempDir,
|
|
102
|
+
"node_modules",
|
|
103
|
+
"@fernir2",
|
|
104
|
+
"saas-kit",
|
|
105
|
+
"bin",
|
|
106
|
+
"index.js"
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
if (!existsSync(saasKitBinPath)) {
|
|
110
|
+
logError("Could not find create-saas-kit-app binary in @fernir2/saas-kit package");
|
|
111
|
+
process.exit(1);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
runCommand(`node "${saasKitBinPath}" "${projectName}"`, process.cwd());
|
|
115
|
+
|
|
116
|
+
log("\nStep 3/3: Cleaning up...");
|
|
117
117
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
118
|
+
// Clean up temp directory
|
|
119
|
+
runCommand(`rm -rf "${tempDir}"`, process.cwd());
|
|
120
|
+
|
|
121
|
+
log("\n✨ Success! Your SaaS Kit application is ready!");
|
|
122
|
+
log("\nNext steps:");
|
|
123
|
+
log(` cd ${projectName}`);
|
|
124
|
+
log(` npm install`);
|
|
125
|
+
log(` npm start`);
|
|
126
|
+
log("\n");
|
|
127
|
+
} catch (error) {
|
|
128
|
+
logError("Failed to create application");
|
|
129
129
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
130
|
+
// Clean up on error
|
|
131
|
+
try {
|
|
132
|
+
runCommand(`rm -rf "${tempDir}"`, process.cwd());
|
|
133
|
+
runCommand(`rm -rf "${targetDir}"`, process.cwd());
|
|
134
|
+
} catch (cleanupError) {
|
|
135
|
+
// Ignore cleanup errors
|
|
136
|
+
}
|
|
137
137
|
|
|
138
|
-
|
|
139
|
-
|
|
138
|
+
process.exit(1);
|
|
139
|
+
}
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
main().catch((error) => {
|
|
143
|
-
|
|
144
|
-
|
|
143
|
+
logError(`Unexpected error: ${error.message}`);
|
|
144
|
+
process.exit(1);
|
|
145
145
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fernir2/saas-kit-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "CLI for creating saas-kit apps",
|
|
5
5
|
"bin": {
|
|
6
6
|
"create-saas-kit-app": "bin/create-saas-kit-app.js"
|
|
@@ -9,8 +9,5 @@
|
|
|
9
9
|
"start": "node bin/create-saas-kit-app.js"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {},
|
|
12
|
-
"type": "module"
|
|
13
|
-
"publishConfig": {
|
|
14
|
-
"access": "public"
|
|
15
|
-
}
|
|
12
|
+
"type": "module"
|
|
16
13
|
}
|