create-suryasairus-cms 1.0.0
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/index.js +56 -0
- package/package.json +13 -0
package/index.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const fs = require('fs-extra');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const { execSync } = require('child_process');
|
|
5
|
+
|
|
6
|
+
async function init() {
|
|
7
|
+
const projectName = process.argv[2];
|
|
8
|
+
|
|
9
|
+
if (!projectName) {
|
|
10
|
+
console.error('Please specify the project directory:');
|
|
11
|
+
console.log(' npx create-project-cms <project-directory>');
|
|
12
|
+
process.exit(1);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const targetDir = path.join(process.cwd(), projectName);
|
|
16
|
+
|
|
17
|
+
// 1. Create the directory
|
|
18
|
+
fs.ensureDirSync(targetDir);
|
|
19
|
+
|
|
20
|
+
// 2. Define the package.json
|
|
21
|
+
const templatePkg = {
|
|
22
|
+
name: projectName,
|
|
23
|
+
version: "0.1.0",
|
|
24
|
+
description: "My CMS Project",
|
|
25
|
+
scripts: {
|
|
26
|
+
"dev": "project-cms dev",
|
|
27
|
+
"build": "project-cms build",
|
|
28
|
+
"start": "project-cms start"
|
|
29
|
+
},
|
|
30
|
+
dependencies: {
|
|
31
|
+
// Use the absolute path to your core for local testing
|
|
32
|
+
// "@suryasairus/core": `file:${path.resolve(__dirname, '../core')}`
|
|
33
|
+
"@suryasairus/core": "^1.0.0"
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// 3. Write the file
|
|
38
|
+
console.log(`š Creating ${projectName} in ${targetDir}...`);
|
|
39
|
+
fs.writeJsonSync(path.join(targetDir, 'package.json'), templatePkg, { spaces: 2 });
|
|
40
|
+
|
|
41
|
+
// 4. RUN INSTALL (This is the missing piece!)
|
|
42
|
+
console.log('š¦ Installing core dependencies... This may take a minute.');
|
|
43
|
+
try {
|
|
44
|
+
execSync('npm install', {
|
|
45
|
+
cwd: targetDir,
|
|
46
|
+
stdio: 'inherit' // This shows the progress bar in your terminal
|
|
47
|
+
});
|
|
48
|
+
console.log('\nā
Success! To get started:');
|
|
49
|
+
console.log(` cd ${projectName}`);
|
|
50
|
+
console.log(` npm run dev`);
|
|
51
|
+
} catch (error) {
|
|
52
|
+
console.error('ā Failed to install dependencies:', error.message);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
init();
|