create-jinmankn-app 1.0.0 → 1.0.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/index.js +54 -27
- package/package.json +3 -3
package/bin/index.js
CHANGED
|
@@ -3,60 +3,86 @@
|
|
|
3
3
|
const fs = require('fs-extra');
|
|
4
4
|
const path = require('path');
|
|
5
5
|
const { execSync } = require('child_process');
|
|
6
|
-
const inquirer = require('inquirer');
|
|
6
|
+
const inquirer = require('inquirer').default;
|
|
7
7
|
|
|
8
8
|
async function createProject() {
|
|
9
9
|
const projectName = process.argv[2];
|
|
10
10
|
|
|
11
11
|
if (!projectName) {
|
|
12
|
+
console.log('');
|
|
12
13
|
console.log('Please provide a project name.');
|
|
13
|
-
console.log('
|
|
14
|
+
console.log('');
|
|
15
|
+
console.log('Example:');
|
|
16
|
+
console.log('npx create-jinmankn-app my-app');
|
|
14
17
|
process.exit(1);
|
|
15
18
|
}
|
|
16
19
|
|
|
20
|
+
const templatesDir = path.join(__dirname, '../templates');
|
|
21
|
+
|
|
22
|
+
// Automatically read all template folders
|
|
23
|
+
const templates = fs
|
|
24
|
+
.readdirSync(templatesDir)
|
|
25
|
+
.filter((file) =>
|
|
26
|
+
fs.statSync(path.join(templatesDir, file)).isDirectory()
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
if (templates.length === 0) {
|
|
30
|
+
console.log('No templates found.');
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Ask user to choose template
|
|
17
35
|
const answers = await inquirer.prompt([
|
|
18
36
|
{
|
|
19
37
|
type: 'list',
|
|
20
38
|
name: 'template',
|
|
21
|
-
message: 'Select a
|
|
22
|
-
choices:
|
|
23
|
-
|
|
24
|
-
'chom',
|
|
25
|
-
'hospital-faisal'
|
|
26
|
-
]
|
|
27
|
-
}
|
|
39
|
+
message: 'Select a template:',
|
|
40
|
+
choices: templates,
|
|
41
|
+
},
|
|
28
42
|
]);
|
|
29
43
|
|
|
30
44
|
const selectedTemplate = answers.template;
|
|
31
45
|
|
|
32
46
|
const currentDir = process.cwd();
|
|
47
|
+
|
|
33
48
|
const projectPath = path.join(currentDir, projectName);
|
|
34
49
|
|
|
35
50
|
const templatePath = path.join(
|
|
36
|
-
|
|
37
|
-
|
|
51
|
+
templatesDir,
|
|
52
|
+
selectedTemplate
|
|
38
53
|
);
|
|
39
54
|
|
|
40
55
|
console.log('');
|
|
41
56
|
console.log(`Creating ${selectedTemplate} project...`);
|
|
57
|
+
console.log('');
|
|
42
58
|
|
|
59
|
+
// Copy template files
|
|
43
60
|
fs.copySync(templatePath, projectPath);
|
|
44
61
|
|
|
45
|
-
|
|
46
|
-
|
|
62
|
+
// Install frontend dependencies
|
|
63
|
+
const frontendPath = path.join(projectPath, 'frontend');
|
|
47
64
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
stdio: 'inherit',
|
|
51
|
-
});
|
|
65
|
+
if (fs.existsSync(frontendPath)) {
|
|
66
|
+
console.log('Installing frontend dependencies...');
|
|
52
67
|
|
|
53
|
-
|
|
54
|
-
|
|
68
|
+
execSync('npm install', {
|
|
69
|
+
cwd: frontendPath,
|
|
70
|
+
stdio: 'inherit',
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Install backend dependencies
|
|
75
|
+
const backendPath = path.join(projectPath, 'backend');
|
|
55
76
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
77
|
+
if (fs.existsSync(backendPath)) {
|
|
78
|
+
console.log('');
|
|
79
|
+
console.log('Installing backend dependencies...');
|
|
80
|
+
|
|
81
|
+
execSync('npm install', {
|
|
82
|
+
cwd: backendPath,
|
|
83
|
+
stdio: 'inherit',
|
|
84
|
+
});
|
|
85
|
+
}
|
|
60
86
|
|
|
61
87
|
console.log('');
|
|
62
88
|
console.log('Project created successfully!');
|
|
@@ -64,13 +90,14 @@ async function createProject() {
|
|
|
64
90
|
|
|
65
91
|
console.log(`cd ${projectName}`);
|
|
66
92
|
|
|
67
|
-
console.log('');
|
|
68
|
-
console.log('Run backend:');
|
|
69
|
-
console.log('cd backend && npm run dev');
|
|
70
|
-
|
|
71
93
|
console.log('');
|
|
72
94
|
console.log('Run frontend:');
|
|
73
95
|
console.log('cd frontend && npm run dev');
|
|
96
|
+
|
|
97
|
+
console.log('');
|
|
98
|
+
|
|
99
|
+
console.log('Run backend:');
|
|
100
|
+
console.log('cd backend && npm run dev');
|
|
74
101
|
}
|
|
75
102
|
|
|
76
103
|
createProject();
|
package/package.json
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-jinmankn-app",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "",
|
|
5
|
-
|
|
6
|
-
"bin": {
|
|
5
|
+
"bin": {
|
|
7
6
|
"create-jinmankn-app": "./bin/index.js"
|
|
8
7
|
},
|
|
9
8
|
"main": "index.js",
|
|
@@ -15,6 +14,7 @@
|
|
|
15
14
|
"license": "ISC",
|
|
16
15
|
"type": "commonjs",
|
|
17
16
|
"dependencies": {
|
|
17
|
+
"fs-extra": "^11.3.5",
|
|
18
18
|
"inquirer": "^13.4.3"
|
|
19
19
|
}
|
|
20
20
|
}
|