ydev-mern 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/cli.js +64 -13
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -9,10 +9,23 @@ const __dirname = path.dirname(__filename);
|
|
|
9
9
|
const rootPackageDir = path.resolve(__dirname, '..');
|
|
10
10
|
|
|
11
11
|
const targetArg = process.argv[2];
|
|
12
|
-
const targetDir = targetArg
|
|
12
|
+
const targetDir = targetArg
|
|
13
|
+
? path.resolve(process.cwd(), targetArg)
|
|
14
|
+
: process.cwd();
|
|
13
15
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
const colors = {
|
|
17
|
+
reset: '\x1b[0m',
|
|
18
|
+
bold: '\x1b[1m',
|
|
19
|
+
cyan: '\x1b[36m',
|
|
20
|
+
yellow: '\x1b[33m',
|
|
21
|
+
green: '\x1b[32m',
|
|
22
|
+
red: '\x1b[31m',
|
|
23
|
+
gray: '\x1b[90m',
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
function log(message = '') {
|
|
27
|
+
console.log(message);
|
|
28
|
+
}
|
|
16
29
|
|
|
17
30
|
function copyDirRecursive(src, dest) {
|
|
18
31
|
if (!fs.existsSync(dest)) {
|
|
@@ -25,7 +38,12 @@ function copyDirRecursive(src, dest) {
|
|
|
25
38
|
const srcPath = path.join(src, entry.name);
|
|
26
39
|
const destPath = path.join(dest, entry.name);
|
|
27
40
|
|
|
28
|
-
|
|
41
|
+
// Skip generated or environment-specific directories
|
|
42
|
+
if (
|
|
43
|
+
entry.name === 'node_modules' ||
|
|
44
|
+
entry.name === 'dist' ||
|
|
45
|
+
entry.name === '.git'
|
|
46
|
+
) {
|
|
29
47
|
continue;
|
|
30
48
|
}
|
|
31
49
|
|
|
@@ -38,25 +56,58 @@ function copyDirRecursive(src, dest) {
|
|
|
38
56
|
}
|
|
39
57
|
|
|
40
58
|
try {
|
|
59
|
+
log();
|
|
60
|
+
log(
|
|
61
|
+
`${colors.bold}${colors.cyan}ydev-mern${colors.reset} ${colors.gray}Project Scaffolder${colors.reset}`
|
|
62
|
+
);
|
|
63
|
+
log();
|
|
64
|
+
|
|
65
|
+
log(
|
|
66
|
+
`${colors.gray}Project directory:${colors.reset} ${colors.yellow}${targetDir}${colors.reset}`
|
|
67
|
+
);
|
|
68
|
+
log();
|
|
69
|
+
|
|
41
70
|
const foldersToCopy = ['frontend', 'backend'];
|
|
42
71
|
|
|
72
|
+
log(`${colors.bold}Creating project structure${colors.reset}`);
|
|
73
|
+
log();
|
|
74
|
+
|
|
43
75
|
for (const folder of foldersToCopy) {
|
|
44
76
|
const srcFolder = path.join(rootPackageDir, folder);
|
|
45
77
|
const destFolder = path.join(targetDir, folder);
|
|
46
78
|
|
|
47
79
|
if (fs.existsSync(srcFolder)) {
|
|
48
|
-
|
|
80
|
+
log(` Copying ${folder}/`);
|
|
49
81
|
copyDirRecursive(srcFolder, destFolder);
|
|
50
82
|
}
|
|
51
83
|
}
|
|
52
84
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
85
|
+
log();
|
|
86
|
+
log(`${colors.green}${colors.bold}Project created successfully.${colors.reset}`);
|
|
87
|
+
log();
|
|
88
|
+
|
|
89
|
+
log(`${colors.bold}Next steps${colors.reset}`);
|
|
90
|
+
log();
|
|
91
|
+
|
|
92
|
+
log(` Backend`);
|
|
93
|
+
log(` ${colors.gray}$${colors.reset} cd backend`);
|
|
94
|
+
log(` ${colors.gray}$${colors.reset} npm install`);
|
|
95
|
+
log(` ${colors.gray}$${colors.reset} npm run dev`);
|
|
96
|
+
log();
|
|
97
|
+
|
|
98
|
+
log(` Frontend`);
|
|
99
|
+
log(` ${colors.gray}$${colors.reset} cd frontend`);
|
|
100
|
+
log(` ${colors.gray}$${colors.reset} npm install`);
|
|
101
|
+
log(` ${colors.gray}$${colors.reset} npm run dev`);
|
|
102
|
+
log();
|
|
103
|
+
|
|
104
|
+
log(`${colors.gray}Start both services in separate terminal windows.${colors.reset}`);
|
|
105
|
+
log();
|
|
59
106
|
} catch (error) {
|
|
60
|
-
|
|
107
|
+
log();
|
|
108
|
+
log(`${colors.red}${colors.bold}Project setup failed.${colors.reset}`);
|
|
109
|
+
log();
|
|
110
|
+
log(`${colors.red}${error.message}${colors.reset}`);
|
|
111
|
+
log();
|
|
61
112
|
process.exit(1);
|
|
62
|
-
}
|
|
113
|
+
}
|