@specverse/engines 6.0.7 → 6.0.9
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/analyse-prepass/adapters/index.d.ts +9 -0
- package/dist/analyse-prepass/adapters/index.d.ts.map +1 -0
- package/dist/analyse-prepass/adapters/index.js +9 -0
- package/dist/analyse-prepass/adapters/index.js.map +1 -0
- package/dist/analyse-prepass/adapters/typescript-prisma.d.ts +67 -0
- package/dist/analyse-prepass/adapters/typescript-prisma.d.ts.map +1 -0
- package/dist/analyse-prepass/adapters/typescript-prisma.js +167 -0
- package/dist/analyse-prepass/adapters/typescript-prisma.js.map +1 -0
- package/dist/analyse-prepass/backends/codegraph.d.ts +56 -0
- package/dist/analyse-prepass/backends/codegraph.d.ts.map +1 -0
- package/dist/analyse-prepass/backends/codegraph.js +303 -0
- package/dist/analyse-prepass/backends/codegraph.js.map +1 -0
- package/dist/analyse-prepass/backends/gitnexus.d.ts +71 -0
- package/dist/analyse-prepass/backends/gitnexus.d.ts.map +1 -0
- package/dist/analyse-prepass/backends/gitnexus.js +367 -0
- package/dist/analyse-prepass/backends/gitnexus.js.map +1 -0
- package/dist/analyse-prepass/backends/grep-only.d.ts +33 -0
- package/dist/analyse-prepass/backends/grep-only.d.ts.map +1 -0
- package/dist/analyse-prepass/backends/grep-only.js +377 -0
- package/dist/analyse-prepass/backends/grep-only.js.map +1 -0
- package/dist/analyse-prepass/backends/index.d.ts +28 -0
- package/dist/analyse-prepass/backends/index.d.ts.map +1 -0
- package/dist/analyse-prepass/backends/index.js +36 -0
- package/dist/analyse-prepass/backends/index.js.map +1 -0
- package/dist/analyse-prepass/backends/method-patterns.d.ts +27 -0
- package/dist/analyse-prepass/backends/method-patterns.d.ts.map +1 -0
- package/dist/analyse-prepass/backends/method-patterns.js +177 -0
- package/dist/analyse-prepass/backends/method-patterns.js.map +1 -0
- package/dist/analyse-prepass/backends/walk.d.ts +7 -0
- package/dist/analyse-prepass/backends/walk.d.ts.map +1 -0
- package/dist/analyse-prepass/backends/walk.js +105 -0
- package/dist/analyse-prepass/backends/walk.js.map +1 -0
- package/dist/analyse-prepass/index.d.ts +76 -0
- package/dist/analyse-prepass/index.d.ts.map +1 -0
- package/dist/analyse-prepass/index.js +114 -0
- package/dist/analyse-prepass/index.js.map +1 -0
- package/dist/analyse-prepass/interface.d.ts +222 -0
- package/dist/analyse-prepass/interface.d.ts.map +1 -0
- package/dist/analyse-prepass/interface.js +20 -0
- package/dist/analyse-prepass/interface.js.map +1 -0
- package/dist/libs/instance-factories/cli/templates/commander/command-generator.js +104 -0
- package/dist/libs/instance-factories/orms/templates/prisma/schema-generator.js +25 -4
- package/libs/instance-factories/cli/templates/commander/command-generator.ts +104 -0
- package/libs/instance-factories/orms/templates/prisma/schema-generator.ts +43 -5
- package/package.json +5 -1
- package/libs/instance-factories/cli/templates/commander/command-generator.d.ts +0 -14
- package/libs/instance-factories/cli/templates/commander/command-generator.js +0 -182
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Command Generator
|
|
3
|
-
*
|
|
4
|
-
* Generates individual command files from command specifications.
|
|
5
|
-
* Each command registers itself on a Commander program and wires
|
|
6
|
-
* to its corresponding service for business logic delegation.
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Generate a single command file.
|
|
10
|
-
* Called once per command in the spec.
|
|
11
|
-
*/
|
|
12
|
-
export default function generateCommand(context) {
|
|
13
|
-
const { command } = context;
|
|
14
|
-
if (!command) {
|
|
15
|
-
throw new Error('Command is required in template context');
|
|
16
|
-
}
|
|
17
|
-
const name = command.name;
|
|
18
|
-
const description = command.description || '';
|
|
19
|
-
const args = command.arguments || {};
|
|
20
|
-
const flags = command.flags || {};
|
|
21
|
-
const exitCodes = command.exitCodes || {};
|
|
22
|
-
const subcommands = command.subcommands || {};
|
|
23
|
-
const serviceRef = command.serviceRef;
|
|
24
|
-
// Build positional argument string for Commander
|
|
25
|
-
const positionalArgs = Object.entries(args)
|
|
26
|
-
.filter(([_, arg]) => arg.positional)
|
|
27
|
-
.sort((a, b) => (a[1].position || 0) - (b[1].position || 0))
|
|
28
|
-
.map(([argName, arg]) => {
|
|
29
|
-
const required = arg.required;
|
|
30
|
-
return required ? `<${argName}>` : `[${argName}]`;
|
|
31
|
-
})
|
|
32
|
-
.join(' ');
|
|
33
|
-
const commandStr = positionalArgs ? `${name} ${positionalArgs}` : name;
|
|
34
|
-
// Build options
|
|
35
|
-
const optionDefs = Object.entries(flags).map(([flagName, flag]) => {
|
|
36
|
-
const alias = flag.alias ? `${flag.alias}, ` : '';
|
|
37
|
-
const flagType = flag.type?.toLowerCase();
|
|
38
|
-
const valuePart = flagType === 'boolean' ? '' : ` <${flagName.replace(/^--/, '')}>`;
|
|
39
|
-
const defaultVal = flag.default !== undefined ? `, ${JSON.stringify(flag.default)}` : '';
|
|
40
|
-
const desc = flag.description || `${flagName} option`;
|
|
41
|
-
return ` .option('${alias}${flagName}${valuePart}', '${desc}'${defaultVal})`;
|
|
42
|
-
});
|
|
43
|
-
// Build type interface for options
|
|
44
|
-
const optionTypes = Object.entries(flags).map(([flagName, flag]) => {
|
|
45
|
-
const tsType = mapFlagTypeToTS(flag.type);
|
|
46
|
-
const key = flagName.replace(/^--/, '').replace(/-([a-z])/g, (_, c) => c.toUpperCase());
|
|
47
|
-
return ` ${key}${flag.required ? '' : '?'}: ${tsType};`;
|
|
48
|
-
});
|
|
49
|
-
// Build positional arg types
|
|
50
|
-
const argTypes = Object.entries(args)
|
|
51
|
-
.filter(([_, arg]) => arg.positional)
|
|
52
|
-
.map(([argName, arg]) => {
|
|
53
|
-
const tsType = mapArgTypeToTS(arg.type);
|
|
54
|
-
return `${argName}: ${tsType}`;
|
|
55
|
-
});
|
|
56
|
-
// Generate action handler
|
|
57
|
-
const actionParams = argTypes.length > 0
|
|
58
|
-
? argTypes.join(', ') + ', options: CommandOptions'
|
|
59
|
-
: 'options: CommandOptions';
|
|
60
|
-
// Generate exit code comments
|
|
61
|
-
const exitCodeComments = Object.entries(exitCodes).length > 0
|
|
62
|
-
? Object.entries(exitCodes).map(([code, meaning]) => ` // ${code}: ${meaning}`).join('\n')
|
|
63
|
-
: '';
|
|
64
|
-
// Handle subcommands
|
|
65
|
-
const hasSubcommands = Object.keys(subcommands).length > 0;
|
|
66
|
-
const subcommandRegistrations = hasSubcommands
|
|
67
|
-
? generateSubcommandRegistrations(name, subcommands)
|
|
68
|
-
: '';
|
|
69
|
-
// Service import
|
|
70
|
-
const serviceImport = serviceRef
|
|
71
|
-
? `import { ${serviceRef} } from '../services/${serviceRef}.js';`
|
|
72
|
-
: '';
|
|
73
|
-
return `/**
|
|
74
|
-
* ${name} command
|
|
75
|
-
* ${description}
|
|
76
|
-
* Generated from SpecVerse specification
|
|
77
|
-
*/
|
|
78
|
-
|
|
79
|
-
import { Command } from 'commander';
|
|
80
|
-
${serviceImport}
|
|
81
|
-
|
|
82
|
-
interface CommandOptions {
|
|
83
|
-
${optionTypes.length > 0 ? optionTypes.join('\n') : ' [key: string]: any;'}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
${exitCodeComments ? `/**\n * Exit codes:\n${exitCodeComments}\n */` : ''}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Register the ${name} command on the program.
|
|
90
|
-
*/
|
|
91
|
-
export function register${capitalize(name)}Command(program: Command): void {
|
|
92
|
-
${hasSubcommands ? generateCommandWithSubcommands(name, description, subcommands, optionDefs) : generateLeafCommand(name, description, commandStr, optionDefs, actionParams, serviceRef, exitCodes)}
|
|
93
|
-
}
|
|
94
|
-
${subcommandRegistrations}
|
|
95
|
-
`;
|
|
96
|
-
}
|
|
97
|
-
function generateLeafCommand(name, description, commandStr, optionDefs, actionParams, serviceRef, exitCodes) {
|
|
98
|
-
const handler = serviceRef
|
|
99
|
-
? `const service = new ${serviceRef}();
|
|
100
|
-
const result = await service.execute(${actionParams.includes(':') ? '{ ' + actionParams.split(',').map(p => p.trim().split(':')[0].trim()).join(', ') + ', ...options }' : 'options'});
|
|
101
|
-
console.log(result);`
|
|
102
|
-
: `console.log('Executing ${name}...');
|
|
103
|
-
// TODO: Wire to service`;
|
|
104
|
-
return `const cmd = program
|
|
105
|
-
.command('${commandStr}')
|
|
106
|
-
.description('${description}')
|
|
107
|
-
${optionDefs.join('\n')}
|
|
108
|
-
.action(async (${actionParams}) => {
|
|
109
|
-
try {
|
|
110
|
-
${handler}
|
|
111
|
-
} catch (error: any) {
|
|
112
|
-
console.error('Error:', error.message);
|
|
113
|
-
process.exit(${Object.keys(exitCodes).find(k => k !== '0') || '1'});
|
|
114
|
-
}
|
|
115
|
-
});`;
|
|
116
|
-
}
|
|
117
|
-
function generateCommandWithSubcommands(name, description, subcommands, optionDefs) {
|
|
118
|
-
const subcmdRegistrations = Object.entries(subcommands).map(([subName, subDef]) => {
|
|
119
|
-
const subDesc = subDef.description || '';
|
|
120
|
-
const subArgs = subDef.arguments || {};
|
|
121
|
-
const subFlags = subDef.flags || {};
|
|
122
|
-
const positionalStr = Object.entries(subArgs)
|
|
123
|
-
.filter(([_, a]) => a.positional)
|
|
124
|
-
.map(([n, a]) => a.required ? `<${n}>` : `[${n}]`)
|
|
125
|
-
.join(' ');
|
|
126
|
-
const subCmdStr = positionalStr ? `${subName} ${positionalStr}` : subName;
|
|
127
|
-
const subOptionDefs = Object.entries(subFlags).map(([flagName, flag]) => {
|
|
128
|
-
const alias = flag.alias ? `${flag.alias}, ` : '';
|
|
129
|
-
const flagType = flag.type?.toLowerCase();
|
|
130
|
-
const valuePart = flagType === 'boolean' ? '' : ` <${flagName.replace(/^--/, '')}>`;
|
|
131
|
-
const defaultVal = flag.default !== undefined ? `, ${JSON.stringify(flag.default)}` : '';
|
|
132
|
-
return ` .option('${alias}${flagName}${valuePart}', '${flag.description || flagName}'${defaultVal})`;
|
|
133
|
-
});
|
|
134
|
-
return `
|
|
135
|
-
cmd
|
|
136
|
-
.command('${subCmdStr}')
|
|
137
|
-
.description('${subDesc}')
|
|
138
|
-
${subOptionDefs.join('\n')}
|
|
139
|
-
.action(async (...args: any[]) => {
|
|
140
|
-
try {
|
|
141
|
-
console.log('Executing ${name} ${subName}...');
|
|
142
|
-
// TODO: Wire to service
|
|
143
|
-
} catch (error: any) {
|
|
144
|
-
console.error('Error:', error.message);
|
|
145
|
-
process.exit(1);
|
|
146
|
-
}
|
|
147
|
-
});`;
|
|
148
|
-
});
|
|
149
|
-
return `const cmd = program
|
|
150
|
-
.command('${name}')
|
|
151
|
-
.description('${description}');
|
|
152
|
-
${subcmdRegistrations.join('\n')}`;
|
|
153
|
-
}
|
|
154
|
-
function generateSubcommandRegistrations(_parentName, _subcommands) {
|
|
155
|
-
return ''; // Subcommands are registered inline
|
|
156
|
-
}
|
|
157
|
-
function mapFlagTypeToTS(type) {
|
|
158
|
-
if (!type)
|
|
159
|
-
return 'string';
|
|
160
|
-
const lower = type.toLowerCase();
|
|
161
|
-
if (lower === 'boolean')
|
|
162
|
-
return 'boolean';
|
|
163
|
-
if (lower === 'number' || lower === 'integer')
|
|
164
|
-
return 'number';
|
|
165
|
-
return 'string';
|
|
166
|
-
}
|
|
167
|
-
function mapArgTypeToTS(type) {
|
|
168
|
-
if (!type)
|
|
169
|
-
return 'string';
|
|
170
|
-
const lower = type.toLowerCase();
|
|
171
|
-
if (lower === 'filepath' || lower === 'string')
|
|
172
|
-
return 'string';
|
|
173
|
-
if (lower === 'number' || lower === 'integer')
|
|
174
|
-
return 'number';
|
|
175
|
-
if (lower === 'boolean')
|
|
176
|
-
return 'boolean';
|
|
177
|
-
return 'string';
|
|
178
|
-
}
|
|
179
|
-
function capitalize(str) {
|
|
180
|
-
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
181
|
-
}
|
|
182
|
-
//# sourceMappingURL=command-generator.js.map
|