servcraft 0.4.6 → 0.4.8
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/ROADMAP.md +3 -1
- package/dist/cli/index.cjs +4383 -4368
- package/dist/cli/index.cjs.map +1 -1
- package/dist/cli/index.js +4386 -4371
- package/dist/cli/index.js.map +1 -1
- package/package.json +1 -1
- package/src/cli/commands/add-module.ts +3 -0
- package/src/cli/commands/init.ts +26 -7
package/package.json
CHANGED
package/src/cli/commands/init.ts
CHANGED
|
@@ -7,6 +7,7 @@ import chalk from 'chalk';
|
|
|
7
7
|
import { execSync } from 'child_process';
|
|
8
8
|
import { ensureDir, writeFile, error, warn } from '../utils/helpers.js';
|
|
9
9
|
import { DryRunManager } from '../utils/dry-run.js';
|
|
10
|
+
import { generateModuleFiles } from './add-module.js';
|
|
10
11
|
|
|
11
12
|
interface InitOptions {
|
|
12
13
|
name: string;
|
|
@@ -54,26 +55,26 @@ export const initCommand = new Command('init')
|
|
|
54
55
|
console.log(chalk.cyan('│') + ' ' + chalk.cyan('│'));
|
|
55
56
|
console.log(
|
|
56
57
|
chalk.cyan('│') +
|
|
57
|
-
'
|
|
58
|
+
' ' +
|
|
58
59
|
chalk.bold.white('🚀 Servcraft') +
|
|
59
60
|
chalk.gray(' - Project Generator') +
|
|
60
|
-
'
|
|
61
|
+
' ' +
|
|
61
62
|
chalk.cyan('│')
|
|
62
63
|
);
|
|
63
64
|
console.log(
|
|
64
65
|
chalk.cyan('│') +
|
|
65
|
-
'
|
|
66
|
+
' ' +
|
|
66
67
|
chalk.gray('by ') +
|
|
67
68
|
chalk.blue('Yao Logan') +
|
|
68
69
|
chalk.gray(' (@Le-Sourcier)') +
|
|
69
|
-
'
|
|
70
|
+
' ' +
|
|
70
71
|
chalk.cyan('│')
|
|
71
72
|
);
|
|
72
73
|
console.log(
|
|
73
74
|
chalk.cyan('│') +
|
|
74
|
-
'
|
|
75
|
+
' ' +
|
|
75
76
|
chalk.bgBlue.white(' in/yao-logan ') +
|
|
76
|
-
'
|
|
77
|
+
' ' +
|
|
77
78
|
chalk.cyan('│')
|
|
78
79
|
);
|
|
79
80
|
console.log(chalk.cyan('│') + ' ' + chalk.cyan('│'));
|
|
@@ -161,7 +162,7 @@ export const initCommand = new Command('init')
|
|
|
161
162
|
{ name: 'Email Service', value: 'email', checked: true },
|
|
162
163
|
{ name: 'Audit Logs', value: 'audit', checked: false },
|
|
163
164
|
{ name: 'File Upload', value: 'upload', checked: false },
|
|
164
|
-
{ name: 'Redis Cache', value: '
|
|
165
|
+
{ name: 'Redis Cache', value: 'cache', checked: false },
|
|
165
166
|
],
|
|
166
167
|
},
|
|
167
168
|
]);
|
|
@@ -305,6 +306,24 @@ export const initCommand = new Command('init')
|
|
|
305
306
|
|
|
306
307
|
spinner.succeed('Project files generated!');
|
|
307
308
|
|
|
309
|
+
// Install selected feature modules
|
|
310
|
+
if (options.features && options.features.length > 0 && !cmdOptions?.dryRun) {
|
|
311
|
+
const moduleSpinner = ora('Installing selected modules...').start();
|
|
312
|
+
|
|
313
|
+
try {
|
|
314
|
+
for (const feature of options.features) {
|
|
315
|
+
moduleSpinner.text = `Installing ${feature} module...`;
|
|
316
|
+
const moduleDir = path.join(projectDir, 'src/modules', feature);
|
|
317
|
+
await ensureDir(moduleDir);
|
|
318
|
+
await generateModuleFiles(feature, moduleDir);
|
|
319
|
+
}
|
|
320
|
+
moduleSpinner.succeed(`${options.features.length} module(s) installed!`);
|
|
321
|
+
} catch (err) {
|
|
322
|
+
moduleSpinner.fail('Failed to install some modules');
|
|
323
|
+
warn(` Error: ${err instanceof Error ? err.message : 'Unknown error'}`);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
|
|
308
327
|
// Install dependencies (skip in dry-run mode)
|
|
309
328
|
if (!cmdOptions?.dryRun) {
|
|
310
329
|
const installSpinner = ora('Installing dependencies...').start();
|