@veloxts/cli 0.4.12 → 0.4.13
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/dist/cli.js +2 -2
- package/dist/cli.js.map +1 -1
- package/dist/commands/dev.d.ts +4 -1
- package/dist/commands/dev.d.ts.map +1 -1
- package/dist/commands/dev.js +29 -15
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/make.d.ts +17 -0
- package/dist/commands/make.d.ts.map +1 -0
- package/dist/commands/make.js +219 -0
- package/dist/commands/make.js.map +1 -0
- package/dist/dev/error-parser.d.ts +67 -0
- package/dist/dev/error-parser.d.ts.map +1 -0
- package/dist/dev/error-parser.js +384 -0
- package/dist/dev/error-parser.js.map +1 -0
- package/dist/dev/hmr-runner.d.ts +67 -9
- package/dist/dev/hmr-runner.d.ts.map +1 -1
- package/dist/dev/hmr-runner.js +305 -57
- package/dist/dev/hmr-runner.js.map +1 -1
- package/dist/dev/index.d.ts +6 -0
- package/dist/dev/index.d.ts.map +1 -1
- package/dist/dev/index.js +8 -0
- package/dist/dev/index.js.map +1 -1
- package/dist/dev/reload-reporter.d.ts +197 -0
- package/dist/dev/reload-reporter.d.ts.map +1 -0
- package/dist/dev/reload-reporter.js +370 -0
- package/dist/dev/reload-reporter.js.map +1 -0
- package/dist/dev/timing-tracker.d.ts +130 -0
- package/dist/dev/timing-tracker.d.ts.map +1 -0
- package/dist/dev/timing-tracker.js +175 -0
- package/dist/dev/timing-tracker.js.map +1 -0
- package/dist/generators/generators/factory.d.ts +5 -5
- package/dist/generators/generators/factory.js +8 -8
- package/dist/generators/generators/migration.d.ts +7 -7
- package/dist/generators/generators/migration.js +12 -12
- package/dist/generators/generators/model.d.ts +7 -7
- package/dist/generators/generators/model.js +12 -12
- package/dist/generators/generators/procedure.d.ts +6 -6
- package/dist/generators/generators/procedure.js +12 -12
- package/dist/generators/generators/seeder.d.ts +5 -5
- package/dist/generators/generators/seeder.js +9 -9
- package/dist/generators/generators/seeder.js.map +1 -1
- package/dist/generators/types.d.ts +1 -1
- package/dist/generators/types.d.ts.map +1 -1
- package/dist/migrations/commands/run.js +1 -1
- package/dist/migrations/commands/run.js.map +1 -1
- package/dist/migrations/commands/status.js +1 -1
- package/dist/migrations/commands/status.js.map +1 -1
- package/dist/migrations/errors.js +1 -1
- package/dist/migrations/errors.js.map +1 -1
- package/dist/seeding/commands/seed.js +2 -2
- package/dist/seeding/commands/seed.js.map +1 -1
- package/dist/seeding/errors.js +1 -1
- package/dist/seeding/errors.js.map +1 -1
- package/package.json +6 -6
package/dist/cli.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import { Command } from 'commander';
|
|
8
8
|
import { createDbCommand } from './commands/db.js';
|
|
9
9
|
import { createDevCommand } from './commands/dev.js';
|
|
10
|
-
import {
|
|
10
|
+
import { createMakeCommand } from './commands/make.js';
|
|
11
11
|
import { createMigrateCommand } from './commands/migrate.js';
|
|
12
12
|
import { createProceduresCommand } from './commands/procedures.js';
|
|
13
13
|
import { CLI_VERSION } from './index.js';
|
|
@@ -24,7 +24,7 @@ function createCLI() {
|
|
|
24
24
|
// Register commands
|
|
25
25
|
program.addCommand(createDbCommand());
|
|
26
26
|
program.addCommand(createDevCommand(CLI_VERSION));
|
|
27
|
-
program.addCommand(
|
|
27
|
+
program.addCommand(createMakeCommand());
|
|
28
28
|
program.addCommand(createMigrateCommand());
|
|
29
29
|
program.addCommand(createProceduresCommand());
|
|
30
30
|
return program;
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,
|
|
1
|
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AK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;YAC3B,OAAO,CAAC,KAAK,CAAC,UAAU,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QAC3C,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,KAAK,CAAC,2BAA2B,CAAC,CAAC;QAC7C,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,cAAc;AACd,IAAI,EAAE,CAAC"}
|
package/dist/commands/dev.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Dev command - Start development server with hot reload
|
|
3
3
|
*
|
|
4
|
-
* Inspired by Laravel's `php artisan serve` and Vite's dev server
|
|
4
|
+
* Inspired by Laravel's `php artisan serve` and Vite's dev server.
|
|
5
|
+
*
|
|
6
|
+
* By default, uses Hot Module Replacement (HMR) for fast reloads.
|
|
7
|
+
* Use --no-hmr for legacy tsx watch mode with full process restarts.
|
|
5
8
|
*/
|
|
6
9
|
import { Command } from 'commander';
|
|
7
10
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../src/commands/dev.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../src/commands/dev.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAwBpC;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAezD"}
|
package/dist/commands/dev.js
CHANGED
|
@@ -1,27 +1,33 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Dev command - Start development server with hot reload
|
|
3
3
|
*
|
|
4
|
-
* Inspired by Laravel's `php artisan serve` and Vite's dev server
|
|
4
|
+
* Inspired by Laravel's `php artisan serve` and Vite's dev server.
|
|
5
|
+
*
|
|
6
|
+
* By default, uses Hot Module Replacement (HMR) for fast reloads.
|
|
7
|
+
* Use --no-hmr for legacy tsx watch mode with full process restarts.
|
|
5
8
|
*/
|
|
6
9
|
import { spawn } from 'node:child_process';
|
|
7
10
|
import * as p from '@clack/prompts';
|
|
8
11
|
import { Command } from 'commander';
|
|
9
12
|
import pc from 'picocolors';
|
|
10
13
|
import { buildWatchArgs, runHMRServer } from '../dev/index.js';
|
|
11
|
-
import { error, formatCommand, formatPath, info, instruction, printBanner,
|
|
14
|
+
import { error, formatCommand, formatPath, info, instruction, printBanner, } from '../utils/output.js';
|
|
12
15
|
import { findEntryPoint, isVeloxProject, validateEntryPath } from '../utils/paths.js';
|
|
13
16
|
/**
|
|
14
17
|
* Create the dev command
|
|
15
18
|
*/
|
|
16
19
|
export function createDevCommand(version) {
|
|
17
20
|
return new Command('dev')
|
|
18
|
-
.description('Start the development server with hot
|
|
21
|
+
.description('Start the development server with hot module replacement')
|
|
19
22
|
.option('-p, --port <port>', 'Port to listen on', '3210')
|
|
20
23
|
.option('-H, --host <host>', 'Host to bind to', 'localhost')
|
|
21
24
|
.option('-e, --entry <file>', 'Entry point file (auto-detected if not specified)')
|
|
22
25
|
.option('--clear', 'Clear console on restart (default: true)', true)
|
|
23
26
|
.option('--no-clear', 'Disable console clearing on restart')
|
|
24
|
-
.option('--hmr', 'Enable
|
|
27
|
+
.option('--hmr', 'Enable hot module replacement (default: true)', true)
|
|
28
|
+
.option('--no-hmr', 'Disable HMR and use legacy tsx watch mode')
|
|
29
|
+
.option('-v, --verbose', 'Show detailed timing and reload information', false)
|
|
30
|
+
.option('-d, --debug', 'Enable debug logging and request tracing', false)
|
|
25
31
|
.action(async (options) => {
|
|
26
32
|
await runDevServer(options, version);
|
|
27
33
|
});
|
|
@@ -88,33 +94,41 @@ async function runDevServer(options, version) {
|
|
|
88
94
|
}
|
|
89
95
|
// Print startup banner
|
|
90
96
|
printBanner(version);
|
|
91
|
-
// Show HMR warning if enabled
|
|
92
|
-
if (options.hmr) {
|
|
93
|
-
warning('HMR mode is experimental. Some changes may require a full restart.');
|
|
94
|
-
console.log('');
|
|
95
|
-
}
|
|
96
|
-
info('Starting development server...');
|
|
97
|
-
console.log('');
|
|
98
97
|
// Set environment variables for the app
|
|
98
|
+
const debug = options.debug ?? false;
|
|
99
99
|
const env = {
|
|
100
100
|
...process.env,
|
|
101
101
|
PORT: port,
|
|
102
102
|
HOST: host,
|
|
103
103
|
NODE_ENV: 'development',
|
|
104
|
+
...(debug && {
|
|
105
|
+
LOG_LEVEL: 'debug',
|
|
106
|
+
VELOX_REQUEST_LOGGING: 'true',
|
|
107
|
+
}),
|
|
104
108
|
};
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
109
|
+
const clearScreen = options.clear !== false;
|
|
110
|
+
const verbose = options.verbose ?? false;
|
|
111
|
+
// HMR is the default mode
|
|
112
|
+
// Use --no-hmr for legacy tsx watch mode
|
|
113
|
+
if (options.hmr !== false) {
|
|
114
|
+
// Run with HMR (default)
|
|
108
115
|
await runHMRServer({
|
|
109
116
|
entry: entryPoint,
|
|
110
117
|
port,
|
|
111
118
|
host,
|
|
112
119
|
env,
|
|
120
|
+
verbose,
|
|
121
|
+
debug,
|
|
122
|
+
clearOnRestart: clearScreen,
|
|
113
123
|
});
|
|
114
124
|
return; // HMR runner handles its own lifecycle
|
|
115
125
|
}
|
|
126
|
+
// Legacy mode: tsx watch with full process restarts
|
|
127
|
+
info('Starting development server in legacy mode...');
|
|
128
|
+
console.log(` ${pc.dim('Using tsx watch - every change triggers full restart.')}`);
|
|
129
|
+
console.log(` ${pc.dim('Remove --no-hmr for faster reloads with HMR.')}`);
|
|
130
|
+
console.log('');
|
|
116
131
|
// Build watch arguments with smart ignore patterns
|
|
117
|
-
const clearScreen = options.clear !== false;
|
|
118
132
|
const watchArgs = buildWatchArgs({
|
|
119
133
|
entry: entryPoint,
|
|
120
134
|
clearScreen,
|
package/dist/commands/dev.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev.js","sourceRoot":"","sources":["../../src/commands/dev.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"dev.js","sourceRoot":"","sources":["../../src/commands/dev.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C,OAAO,KAAK,CAAC,MAAM,gBAAgB,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EACL,KAAK,EACL,aAAa,EACb,UAAU,EACV,IAAI,EACJ,WAAW,EACX,WAAW,GACZ,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAYtF;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAe;IAC9C,OAAO,IAAI,OAAO,CAAC,KAAK,CAAC;SACtB,WAAW,CAAC,0DAA0D,CAAC;SACvE,MAAM,CAAC,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,CAAC;SACxD,MAAM,CAAC,mBAAmB,EAAE,iBAAiB,EAAE,WAAW,CAAC;SAC3D,MAAM,CAAC,oBAAoB,EAAE,mDAAmD,CAAC;SACjF,MAAM,CAAC,SAAS,EAAE,0CAA0C,EAAE,IAAI,CAAC;SACnE,MAAM,CAAC,YAAY,EAAE,qCAAqC,CAAC;SAC3D,MAAM,CAAC,OAAO,EAAE,+CAA+C,EAAE,IAAI,CAAC;SACtE,MAAM,CAAC,UAAU,EAAE,2CAA2C,CAAC;SAC/D,MAAM,CAAC,eAAe,EAAE,6CAA6C,EAAE,KAAK,CAAC;SAC7E,MAAM,CAAC,aAAa,EAAE,0CAA0C,EAAE,KAAK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rC,CAAC;QAED,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Make command - Code scaffolding for VeloxTS projects
|
|
3
|
+
*
|
|
4
|
+
* Usage:
|
|
5
|
+
* velox make <type> <name> [options]
|
|
6
|
+
* velox m <type> <name> [options]
|
|
7
|
+
*
|
|
8
|
+
* Examples:
|
|
9
|
+
* velox make procedure users --crud
|
|
10
|
+
* velox m p User
|
|
11
|
+
*/
|
|
12
|
+
import { Command } from 'commander';
|
|
13
|
+
/**
|
|
14
|
+
* Create the make command
|
|
15
|
+
*/
|
|
16
|
+
export declare function createMakeCommand(): Command;
|
|
17
|
+
//# sourceMappingURL=make.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"make.d.ts","sourceRoot":"","sources":["../../src/commands/make.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAqCpC;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,CAmD3C"}
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Make command - Code scaffolding for VeloxTS projects
|
|
3
|
+
*
|
|
4
|
+
* Usage:
|
|
5
|
+
* velox make <type> <name> [options]
|
|
6
|
+
* velox m <type> <name> [options]
|
|
7
|
+
*
|
|
8
|
+
* Examples:
|
|
9
|
+
* velox make procedure users --crud
|
|
10
|
+
* velox m p User
|
|
11
|
+
*/
|
|
12
|
+
import * as p from '@clack/prompts';
|
|
13
|
+
import { Command } from 'commander';
|
|
14
|
+
import pc from 'picocolors';
|
|
15
|
+
import { applyCliFlags, detectProjectContext, ensureVeloxProject, findSimilarGenerators, formatGeneratorList, formatWriteResults, formatWriteResultsJson, GeneratorError, GeneratorErrorCode, getAllGenerators, getGenerator, registerBuiltinGenerators, writeFiles, } from '../generators/index.js';
|
|
16
|
+
import { error, formatCommand, info, success } from '../utils/output.js';
|
|
17
|
+
// ============================================================================
|
|
18
|
+
// Command Creation
|
|
19
|
+
// ============================================================================
|
|
20
|
+
/**
|
|
21
|
+
* Create the make command
|
|
22
|
+
*/
|
|
23
|
+
export function createMakeCommand() {
|
|
24
|
+
// Register built-in generators
|
|
25
|
+
registerBuiltinGenerators();
|
|
26
|
+
const cmd = new Command('make')
|
|
27
|
+
.alias('m')
|
|
28
|
+
.description('Scaffold code for your VeloxTS project')
|
|
29
|
+
.argument('[type]', 'Generator type (procedure, schema, model, etc.)')
|
|
30
|
+
.argument('[name]', 'Name for the generated entity')
|
|
31
|
+
.option('-d, --dry-run', 'Preview changes without writing files', false)
|
|
32
|
+
.option('-f, --force', 'Overwrite existing files without prompting', false)
|
|
33
|
+
.option('--json', 'Output results as JSON', false)
|
|
34
|
+
// Generator-specific options (passed through to generators)
|
|
35
|
+
.option('-c, --crud', 'Generate full CRUD operations', false)
|
|
36
|
+
.option('-P, --paginated', 'Include pagination for list operation', false)
|
|
37
|
+
.option('-s, --soft-delete', 'Add soft delete support (model generator)', false)
|
|
38
|
+
.option('-t, --timestamps', 'Include timestamps (model generator)', true)
|
|
39
|
+
.option('-D, --database <type>', 'Database type: sqlite, postgresql, mysql', 'sqlite')
|
|
40
|
+
// Test generator options
|
|
41
|
+
.option('-T, --type <type>', 'Test type: unit, integration, e2e', 'unit')
|
|
42
|
+
.option('-G, --target <target>', 'Test target: procedure, schema, model, service, generic', 'generic')
|
|
43
|
+
// Resource generator options
|
|
44
|
+
.option('-W, --with-tests', 'Include test files (resource generator)', true)
|
|
45
|
+
.option('--skip-model', 'Skip Prisma model generation', false)
|
|
46
|
+
.option('--skip-schema', 'Skip Zod schema generation', false)
|
|
47
|
+
.option('--skip-procedure', 'Skip procedure generation', false)
|
|
48
|
+
.action(async (type, name, options) => {
|
|
49
|
+
await runMake(type, name, options);
|
|
50
|
+
});
|
|
51
|
+
// Add help showing available generators
|
|
52
|
+
cmd.addHelpText('after', `
|
|
53
|
+
Available generators:${formatGeneratorList()}
|
|
54
|
+
|
|
55
|
+
Examples:
|
|
56
|
+
${formatCommand('velox make resource Post')} Scaffold complete Post resource
|
|
57
|
+
${formatCommand('velox m r User --soft-delete')} Resource with soft delete support
|
|
58
|
+
${formatCommand('velox m p User --crud')} Scaffold CRUD procedures only
|
|
59
|
+
${formatCommand('velox m s User --crud')} Scaffold Zod schemas only
|
|
60
|
+
${formatCommand('velox m t User -G procedure')} Scaffold procedure unit tests
|
|
61
|
+
${formatCommand('velox make --dry-run r Post')} Preview resource scaffolding
|
|
62
|
+
`);
|
|
63
|
+
return cmd;
|
|
64
|
+
}
|
|
65
|
+
// ============================================================================
|
|
66
|
+
// Command Execution
|
|
67
|
+
// ============================================================================
|
|
68
|
+
/**
|
|
69
|
+
* Run the make command
|
|
70
|
+
*/
|
|
71
|
+
async function runMake(type, name, options) {
|
|
72
|
+
const { json, dryRun, force } = options;
|
|
73
|
+
// JSON mode: suppress interactive output
|
|
74
|
+
const isInteractive = !json;
|
|
75
|
+
try {
|
|
76
|
+
// List generators if no type specified
|
|
77
|
+
if (!type) {
|
|
78
|
+
if (json) {
|
|
79
|
+
const generators = getAllGenerators().map((g) => ({
|
|
80
|
+
name: g.name,
|
|
81
|
+
aliases: g.generator.metadata.aliases ?? [],
|
|
82
|
+
description: g.generator.metadata.description,
|
|
83
|
+
category: g.generator.metadata.category,
|
|
84
|
+
}));
|
|
85
|
+
console.log(JSON.stringify({ generators }, null, 2));
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
p.intro(pc.bgCyan(pc.black(' VeloxTS Make ')));
|
|
89
|
+
console.log(formatGeneratorList());
|
|
90
|
+
console.log('');
|
|
91
|
+
info(`Run ${formatCommand('velox make <type> <name>')} to scaffold code.`);
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
// Find the generator
|
|
95
|
+
const generator = getGenerator(type);
|
|
96
|
+
if (!generator) {
|
|
97
|
+
const similar = findSimilarGenerators(type);
|
|
98
|
+
const suggestion = similar.length > 0
|
|
99
|
+
? `Did you mean: ${similar.map((s) => pc.cyan(s)).join(', ')}?`
|
|
100
|
+
: `Run ${formatCommand('velox make')} to see available generators.`;
|
|
101
|
+
throw new GeneratorError(GeneratorErrorCode.INVALID_OPTION, `Unknown generator: ${type}`, suggestion);
|
|
102
|
+
}
|
|
103
|
+
// Check for entity name
|
|
104
|
+
if (!name) {
|
|
105
|
+
throw new GeneratorError(GeneratorErrorCode.INVALID_ENTITY_NAME, 'Entity name is required', `Usage: ${formatCommand(`velox make ${type} <name>`)}`);
|
|
106
|
+
}
|
|
107
|
+
// Validate entity name
|
|
108
|
+
const nameError = generator.validateEntityName(name);
|
|
109
|
+
if (nameError) {
|
|
110
|
+
throw new GeneratorError(GeneratorErrorCode.INVALID_ENTITY_NAME, nameError, 'Entity names must start with a letter and contain only letters, numbers, hyphens, or underscores.');
|
|
111
|
+
}
|
|
112
|
+
// Ensure we're in a VeloxTS project
|
|
113
|
+
const cwd = process.cwd();
|
|
114
|
+
await ensureVeloxProject(cwd);
|
|
115
|
+
// Detect project context
|
|
116
|
+
const project = await detectProjectContext(cwd);
|
|
117
|
+
// Extract generator-specific options (remove global flags)
|
|
118
|
+
const { dryRun: _d, force: _f, json: _j, ...generatorOptions } = options;
|
|
119
|
+
// Validate generator options
|
|
120
|
+
const validatedOptions = generator.validateOptions(generatorOptions);
|
|
121
|
+
// Build generator config
|
|
122
|
+
const config = applyCliFlags({
|
|
123
|
+
entityName: name,
|
|
124
|
+
options: validatedOptions,
|
|
125
|
+
conflictStrategy: 'prompt',
|
|
126
|
+
dryRun: false,
|
|
127
|
+
force: false,
|
|
128
|
+
cwd,
|
|
129
|
+
project,
|
|
130
|
+
}, { dryRun, force, json });
|
|
131
|
+
// Show spinner for generation
|
|
132
|
+
let output;
|
|
133
|
+
if (isInteractive) {
|
|
134
|
+
const s = p.spinner();
|
|
135
|
+
s.start(`Scaffolding ${generator.metadata.name}...`);
|
|
136
|
+
try {
|
|
137
|
+
output = await generator.generate(config);
|
|
138
|
+
s.stop(`Scaffolded ${output.files.length} file(s)`);
|
|
139
|
+
}
|
|
140
|
+
catch (err) {
|
|
141
|
+
s.stop('Scaffolding failed');
|
|
142
|
+
throw err;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
output = await generator.generate(config);
|
|
147
|
+
}
|
|
148
|
+
// Write files
|
|
149
|
+
const writeResults = await writeFiles(output.files, {
|
|
150
|
+
conflictStrategy: config.conflictStrategy,
|
|
151
|
+
dryRun: config.dryRun,
|
|
152
|
+
force: config.force,
|
|
153
|
+
cwd,
|
|
154
|
+
silent: json,
|
|
155
|
+
});
|
|
156
|
+
// Output results
|
|
157
|
+
if (json) {
|
|
158
|
+
console.log(formatWriteResultsJson(writeResults));
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
console.log('');
|
|
162
|
+
console.log(formatWriteResults(writeResults, dryRun));
|
|
163
|
+
// Show post-generation instructions
|
|
164
|
+
if (output.postInstructions && !dryRun) {
|
|
165
|
+
console.log('');
|
|
166
|
+
info('Next steps:');
|
|
167
|
+
console.log(output.postInstructions);
|
|
168
|
+
}
|
|
169
|
+
console.log('');
|
|
170
|
+
success(dryRun ? 'Dry run complete.' : 'Scaffolding complete!');
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
catch (err) {
|
|
174
|
+
handleError(err, json);
|
|
175
|
+
process.exit(1);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
// ============================================================================
|
|
179
|
+
// Error Handling
|
|
180
|
+
// ============================================================================
|
|
181
|
+
/**
|
|
182
|
+
* Handle errors with appropriate formatting
|
|
183
|
+
*/
|
|
184
|
+
function handleError(err, json) {
|
|
185
|
+
if (err instanceof GeneratorError) {
|
|
186
|
+
if (json) {
|
|
187
|
+
console.log(JSON.stringify(err.toJSON(), null, 2));
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
error(err.message);
|
|
191
|
+
if (err.fix) {
|
|
192
|
+
info(`Fix: ${err.fix}`);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
if (err instanceof Error) {
|
|
198
|
+
if (json) {
|
|
199
|
+
console.log(JSON.stringify({
|
|
200
|
+
code: 'E2005',
|
|
201
|
+
message: err.message,
|
|
202
|
+
}, null, 2));
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
error(err.message);
|
|
206
|
+
}
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
if (json) {
|
|
210
|
+
console.log(JSON.stringify({
|
|
211
|
+
code: 'E2005',
|
|
212
|
+
message: 'An unknown error occurred',
|
|
213
|
+
}, null, 2));
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
error('An unknown error occurred');
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
//# sourceMappingURL=make.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"make.js","sourceRoot":"","sources":["../../src/commands/make.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,CAAC,MAAM,gBAAgB,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,YAAY,CAAC;AAG5B,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,kBAAkB,EAClB,qBAAqB,EACrB,mBAAmB,EACnB,kBAAkB,EAClB,sBAAsB,EACtB,cAAc,EACd,kBAAkB,EAClB,gBAAgB,EAChB,YAAY,EACZ,yBAAyB,EACzB,UAAU,GACX,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAczE,+EAA+E;AAC/E,mBAAmB;AACnB,+EAA+E;AAE/E;;GAEG;AACH,MAAM,UAA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,SAAS,WAAW,CAAC,GAAY,EAAE,IAAa;IAC9C,IAAI,GAAG,YAAY,cAAc,EAAE,CAAC;QAClC,IAAI,IAAI,EAAE,CAAC;YACT,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QACrD,CAAC;aAAM,CAAC;YACN,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YACnB,IAAI,GAAG,CAAC,GAAG,EAAE,CAAC;gBACZ,IAAI,CAAC,QAAQ,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC;YAC1B,CAAC;QACH,CAAC;QACD,OAAO;IACT,CAAC;IAED,IAAI,GAAG,YAAY,KAAK,EAAE,CAAC;QACzB,IAAI,IAAI,EAAE,CAAC;YACT,OAAO,CAAC,GAAG,CACT,IAAI,CAAC,SAAS,CACZ;gBACE,IAAI,EAAE,OAAO;gBACb,OAAO,EAAE,GAAG,CAAC,OAAO;aACrB,EACD,IAAI,EACJ,CAAC,CACF,CACF,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACrB,CAAC;QACD,OAAO;IACT,CAAC;IAED,IAAI,IAAI,EAAE,CAAC;QACT,OAAO,CAAC,GAAG,CACT,IAAI,CAAC,SAAS,CACZ;YACE,IAAI,EAAE,OAAO;YACb,OAAO,EAAE,2BAA2B;SACrC,EACD,IAAI,EACJ,CAAC,CACF,CACF,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,KAAK,CAAC,2BAA2B,CAAC,CAAC;IACrC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error Parser - Analyzes development errors and provides actionable feedback
|
|
3
|
+
*
|
|
4
|
+
* Parses error messages and stack traces to identify error types, extract
|
|
5
|
+
* file locations, and generate helpful suggestions for resolution.
|
|
6
|
+
*
|
|
7
|
+
* Inspired by Vite's error overlay and Next.js's error page patterns.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* const parsed = parseDevError(error);
|
|
12
|
+
*
|
|
13
|
+
* console.log(parsed.type); // 'syntax-error'
|
|
14
|
+
* console.log(parsed.filePath); // 'src/procedures/users.ts'
|
|
15
|
+
* console.log(parsed.line); // 42
|
|
16
|
+
* console.log(parsed.suggestion); // 'Check for missing closing bracket...'
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* Categories of development errors for targeted handling
|
|
21
|
+
*/
|
|
22
|
+
export type DevErrorType = 'syntax-error' | 'module-not-found' | 'type-error' | 'runtime-error' | 'hmr-failure' | 'database-error' | 'port-in-use' | 'permission-denied' | 'unknown';
|
|
23
|
+
/**
|
|
24
|
+
* Parsed error with extracted metadata and suggestions
|
|
25
|
+
*/
|
|
26
|
+
export interface ParsedDevError {
|
|
27
|
+
/** Original error object */
|
|
28
|
+
readonly originalError: Error;
|
|
29
|
+
/** Classified error type */
|
|
30
|
+
readonly type: DevErrorType;
|
|
31
|
+
/** Clean, user-friendly error message */
|
|
32
|
+
readonly message: string;
|
|
33
|
+
/** File path where error originated (if extractable) */
|
|
34
|
+
readonly filePath?: string;
|
|
35
|
+
/** Line number (if extractable) */
|
|
36
|
+
readonly line?: number;
|
|
37
|
+
/** Column number (if extractable) */
|
|
38
|
+
readonly column?: number;
|
|
39
|
+
/** Actionable suggestion for fixing the error */
|
|
40
|
+
readonly suggestion?: string;
|
|
41
|
+
/** Related documentation or help link */
|
|
42
|
+
readonly helpUrl?: string;
|
|
43
|
+
/** Whether this error is likely recoverable via file edit */
|
|
44
|
+
readonly isRecoverable: boolean;
|
|
45
|
+
/** Code frame snippet around the error (if available) */
|
|
46
|
+
readonly codeFrame?: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Parse a development error into structured, actionable information.
|
|
50
|
+
*
|
|
51
|
+
* @param error - The error to parse
|
|
52
|
+
* @returns Parsed error with type, location, and suggestions
|
|
53
|
+
*/
|
|
54
|
+
export declare function parseDevError(error: Error): ParsedDevError;
|
|
55
|
+
/**
|
|
56
|
+
* Check if an error is a development-time error vs a fatal/configuration error
|
|
57
|
+
*/
|
|
58
|
+
export declare function isDevelopmentError(error: Error): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Get a short, displayable error type label
|
|
61
|
+
*/
|
|
62
|
+
export declare function getErrorTypeLabel(type: DevErrorType): string;
|
|
63
|
+
/**
|
|
64
|
+
* Format parsed error for console output
|
|
65
|
+
*/
|
|
66
|
+
export declare function formatParsedError(parsed: ParsedDevError): string;
|
|
67
|
+
//# sourceMappingURL=error-parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-parser.d.ts","sourceRoot":"","sources":["../../src/dev/error-parser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAMH;;GAEG;AACH,MAAM,MAAM,YAAY,GACpB,cAAc,GACd,kBAAkB,GAClB,YAAY,GACZ,eAAe,GACf,aAAa,GACb,gBAAgB,GAChB,aAAa,GACb,mBAAmB,GACnB,SAAS,CAAC;AAEd;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,4BAA4B;IAC5B,QAAQ,CAAC,aAAa,EAAE,KAAK,CAAC;IAC9B,4BAA4B;IAC5B,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B,yCAAyC;IACzC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,wDAAwD;IACxD,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,mCAAmC;IACnC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,qCAAqC;IACrC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,iDAAiD;IACjD,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAA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