@hazeljs/cli 0.6.0 → 0.6.5
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/@template-ai-native/package.json +1 -1
- package/README.md +22 -1
- package/cli-manifest.json +940 -0
- package/dist/commands/add.d.ts +9 -0
- package/dist/commands/add.js +9 -0
- package/dist/commands/generate-auth.d.ts +12 -0
- package/dist/commands/generate-auth.js +12 -0
- package/dist/commands/generate-crud.d.ts +12 -0
- package/dist/commands/generate-crud.js +12 -0
- package/dist/commands/generate-dto.d.ts +12 -0
- package/dist/commands/generate-dto.js +12 -0
- package/dist/commands/generate-module.d.ts +12 -0
- package/dist/commands/generate-module.js +12 -0
- package/dist/commands/generate-simple.d.ts +53 -6
- package/dist/commands/generate-simple.js +42 -386
- package/dist/commands/info.d.ts +12 -0
- package/dist/commands/info.js +12 -0
- package/dist/commands/templates.d.ts +34 -0
- package/dist/commands/templates.js +387 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.js +45 -1
- package/dist/utils/generator-registry.d.ts +5 -0
- package/dist/utils/generator-registry.js +5 -0
- package/dist/utils/packages-registry.d.ts +11 -2
- package/dist/utils/packages-registry.js +11 -2
- package/package.json +6 -4
package/dist/commands/add.d.ts
CHANGED
|
@@ -1,2 +1,11 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
+
/**
|
|
3
|
+
* Register the `hazel add [package]` command.
|
|
4
|
+
*
|
|
5
|
+
* Installs a HazelJS package via npm and prints import/usage hints.
|
|
6
|
+
* When called without a package name, shows an interactive selection list.
|
|
7
|
+
* Use `--setup` to also generate a minimal `*.setup.ts` starter file.
|
|
8
|
+
*
|
|
9
|
+
* @param program - The root Commander program instance
|
|
10
|
+
*/
|
|
2
11
|
export declare function addCommand(program: Command): void;
|
package/dist/commands/add.js
CHANGED
|
@@ -11,6 +11,15 @@ const path_1 = __importDefault(require("path"));
|
|
|
11
11
|
const inquirer_1 = __importDefault(require("inquirer"));
|
|
12
12
|
const packages_registry_1 = require("../utils/packages-registry");
|
|
13
13
|
const generator_1 = require("../utils/generator");
|
|
14
|
+
/**
|
|
15
|
+
* Register the `hazel add [package]` command.
|
|
16
|
+
*
|
|
17
|
+
* Installs a HazelJS package via npm and prints import/usage hints.
|
|
18
|
+
* When called without a package name, shows an interactive selection list.
|
|
19
|
+
* Use `--setup` to also generate a minimal `*.setup.ts` starter file.
|
|
20
|
+
*
|
|
21
|
+
* @param program - The root Commander program instance
|
|
22
|
+
*/
|
|
14
23
|
function addCommand(program) {
|
|
15
24
|
program
|
|
16
25
|
.command('add [package]')
|
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import { GenerateResult, GenerateCLIOptions } from '../utils/generator';
|
|
3
|
+
/**
|
|
4
|
+
* Generate a complete auth module (6 files: module, service, controller, JWT guard, 2 DTOs).
|
|
5
|
+
*
|
|
6
|
+
* @param _name - Unused (auth generator doesn't need a custom name)
|
|
7
|
+
* @param options - Standard CLI options (--path, --dry-run, --json)
|
|
8
|
+
* @returns GenerateResult with paths of all created files and setup next-steps
|
|
9
|
+
*/
|
|
3
10
|
export declare function runAuth(_name: string, options: GenerateCLIOptions): Promise<GenerateResult>;
|
|
11
|
+
/**
|
|
12
|
+
* Register `hazel g auth` as a sub-command of the generate command.
|
|
13
|
+
*
|
|
14
|
+
* @param command - The Commander `generate` parent command
|
|
15
|
+
*/
|
|
4
16
|
export declare function generateAuth(command: Command): void;
|
|
@@ -145,6 +145,13 @@ export class LoginDto {
|
|
|
145
145
|
password: string;
|
|
146
146
|
}
|
|
147
147
|
`;
|
|
148
|
+
/**
|
|
149
|
+
* Generate a complete auth module (6 files: module, service, controller, JWT guard, 2 DTOs).
|
|
150
|
+
*
|
|
151
|
+
* @param _name - Unused (auth generator doesn't need a custom name)
|
|
152
|
+
* @param options - Standard CLI options (--path, --dry-run, --json)
|
|
153
|
+
* @returns GenerateResult with paths of all created files and setup next-steps
|
|
154
|
+
*/
|
|
148
155
|
async function runAuth(_name, options) {
|
|
149
156
|
const basePath = path_1.default.join(process.cwd(), options.path || 'src/auth');
|
|
150
157
|
const data = {};
|
|
@@ -179,6 +186,11 @@ async function runAuth(_name, options) {
|
|
|
179
186
|
],
|
|
180
187
|
};
|
|
181
188
|
}
|
|
189
|
+
/**
|
|
190
|
+
* Register `hazel g auth` as a sub-command of the generate command.
|
|
191
|
+
*
|
|
192
|
+
* @param command - The Commander `generate` parent command
|
|
193
|
+
*/
|
|
182
194
|
function generateAuth(command) {
|
|
183
195
|
command
|
|
184
196
|
.command('auth')
|
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import { GenerateResult, GenerateCLIOptions } from '../utils/generator';
|
|
3
|
+
/**
|
|
4
|
+
* Generate a complete CRUD resource (4 files: controller, service, DTOs, module).
|
|
5
|
+
*
|
|
6
|
+
* @param name - Resource name (e.g. 'product') — determines file and class names
|
|
7
|
+
* @param options - Standard CLI options (--path, --dry-run, --json, --route)
|
|
8
|
+
* @returns GenerateResult with paths of all created files
|
|
9
|
+
*/
|
|
3
10
|
export declare function runCrud(name: string, options: GenerateCLIOptions): Promise<GenerateResult>;
|
|
11
|
+
/**
|
|
12
|
+
* Register `hazel g crud <name>` as a sub-command of the generate command.
|
|
13
|
+
*
|
|
14
|
+
* @param command - The Commander `generate` parent command
|
|
15
|
+
*/
|
|
4
16
|
export declare function generateCrud(command: Command): void;
|
|
@@ -127,6 +127,13 @@ import { {{className}}Service } from './{{fileName}}.service';
|
|
|
127
127
|
})
|
|
128
128
|
export class {{className}}Module {}
|
|
129
129
|
`;
|
|
130
|
+
/**
|
|
131
|
+
* Generate a complete CRUD resource (4 files: controller, service, DTOs, module).
|
|
132
|
+
*
|
|
133
|
+
* @param name - Resource name (e.g. 'product') — determines file and class names
|
|
134
|
+
* @param options - Standard CLI options (--path, --dry-run, --json, --route)
|
|
135
|
+
* @returns GenerateResult with paths of all created files
|
|
136
|
+
*/
|
|
130
137
|
async function runCrud(name, options) {
|
|
131
138
|
try {
|
|
132
139
|
const className = (0, generator_1.toPascalCase)(name);
|
|
@@ -171,6 +178,11 @@ async function runCrud(name, options) {
|
|
|
171
178
|
};
|
|
172
179
|
}
|
|
173
180
|
}
|
|
181
|
+
/**
|
|
182
|
+
* Register `hazel g crud <name>` as a sub-command of the generate command.
|
|
183
|
+
*
|
|
184
|
+
* @param command - The Commander `generate` parent command
|
|
185
|
+
*/
|
|
174
186
|
function generateCrud(command) {
|
|
175
187
|
command
|
|
176
188
|
.command('crud <name>')
|
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import { GenerateResult, GenerateCLIOptions } from '../utils/generator';
|
|
3
|
+
/**
|
|
4
|
+
* Generate a pair of DTOs (create + update) for the given name.
|
|
5
|
+
*
|
|
6
|
+
* @param name - Entity name (e.g. 'product') — determines file and class names
|
|
7
|
+
* @param options - Standard CLI options (--path, --dry-run, --json)
|
|
8
|
+
* @returns GenerateResult with paths of both created DTO files
|
|
9
|
+
*/
|
|
3
10
|
export declare function runDto(name: string, options: GenerateCLIOptions): Promise<GenerateResult>;
|
|
11
|
+
/**
|
|
12
|
+
* Register `hazel g dto <name>` as a sub-command of the generate command.
|
|
13
|
+
*
|
|
14
|
+
* @param program - The Commander `generate` parent command
|
|
15
|
+
*/
|
|
4
16
|
export declare function generateDto(program: Command): void;
|
|
@@ -59,10 +59,22 @@ class DtoGenerator extends generator_1.Generator {
|
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* Generate a pair of DTOs (create + update) for the given name.
|
|
64
|
+
*
|
|
65
|
+
* @param name - Entity name (e.g. 'product') — determines file and class names
|
|
66
|
+
* @param options - Standard CLI options (--path, --dry-run, --json)
|
|
67
|
+
* @returns GenerateResult with paths of both created DTO files
|
|
68
|
+
*/
|
|
62
69
|
async function runDto(name, options) {
|
|
63
70
|
const generator = new DtoGenerator();
|
|
64
71
|
return generator.generate({ name, path: options.path, dryRun: options.dryRun });
|
|
65
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* Register `hazel g dto <name>` as a sub-command of the generate command.
|
|
75
|
+
*
|
|
76
|
+
* @param program - The Commander `generate` parent command
|
|
77
|
+
*/
|
|
66
78
|
function generateDto(program) {
|
|
67
79
|
program
|
|
68
80
|
.command('dto <name>')
|
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import { GenerateResult, GenerateCLIOptions } from '../utils/generator';
|
|
3
|
+
/**
|
|
4
|
+
* Generate a complete feature module (5 files: module, controller, service, 2 DTOs).
|
|
5
|
+
*
|
|
6
|
+
* @param name - Feature name (e.g. 'users') — determines file and class names
|
|
7
|
+
* @param options - Standard CLI options (--path, --dry-run, --json)
|
|
8
|
+
* @returns GenerateResult with paths of all created files
|
|
9
|
+
*/
|
|
3
10
|
export declare function runModule(name: string, options: GenerateCLIOptions): Promise<GenerateResult>;
|
|
11
|
+
/**
|
|
12
|
+
* Register `hazel g module <name>` as a sub-command of the generate command.
|
|
13
|
+
*
|
|
14
|
+
* @param program - The Commander `generate` parent command
|
|
15
|
+
*/
|
|
4
16
|
export declare function generateModule(program: Command): void;
|
|
@@ -64,6 +64,13 @@ const UPDATE_DTO_TEMPLATE = `export class Update{{className}}Dto {
|
|
|
64
64
|
name?: string;
|
|
65
65
|
}
|
|
66
66
|
`;
|
|
67
|
+
/**
|
|
68
|
+
* Generate a complete feature module (5 files: module, controller, service, 2 DTOs).
|
|
69
|
+
*
|
|
70
|
+
* @param name - Feature name (e.g. 'users') — determines file and class names
|
|
71
|
+
* @param options - Standard CLI options (--path, --dry-run, --json)
|
|
72
|
+
* @returns GenerateResult with paths of all created files
|
|
73
|
+
*/
|
|
67
74
|
async function runModule(name, options) {
|
|
68
75
|
const className = (0, generator_1.toPascalCase)(name);
|
|
69
76
|
const fileName = (0, generator_1.toKebabCase)(name);
|
|
@@ -95,6 +102,11 @@ async function runModule(name, options) {
|
|
|
95
102
|
nextSteps: [`Import ${className}Module in your app module.`],
|
|
96
103
|
};
|
|
97
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* Register `hazel g module <name>` as a sub-command of the generate command.
|
|
107
|
+
*
|
|
108
|
+
* @param program - The Commander `generate` parent command
|
|
109
|
+
*/
|
|
98
110
|
function generateModule(program) {
|
|
99
111
|
program
|
|
100
112
|
.command('module <name>')
|
|
@@ -1,27 +1,74 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Config-driven generator factory for simple single-file generators.
|
|
3
|
-
*
|
|
3
|
+
*
|
|
4
|
+
* Architecture:
|
|
5
|
+
* 1. Templates live in ./templates.ts (Mustache strings, one per generator type).
|
|
6
|
+
* 2. SIMPLE_GENERATORS is a declarative config array — each entry maps a CLI
|
|
7
|
+
* sub-command to a template, suffix, alias, and optional next-steps.
|
|
8
|
+
* 3. registerSimpleGenerators() loops over the config and registers each one
|
|
9
|
+
* as a Commander sub-command of `hazel generate`.
|
|
10
|
+
* 4. runSimpleGenerator() instantiates a lightweight SimpleGenerator (extends
|
|
11
|
+
* the base Generator class) and renders the template with the user's name.
|
|
12
|
+
*
|
|
13
|
+
* To add a new single-file generator:
|
|
14
|
+
* 1. Add a Mustache template in ./templates.ts
|
|
15
|
+
* 2. Add a SimpleGeneratorConfig entry to SIMPLE_GENERATORS below
|
|
16
|
+
* — that's it; the CLI, --list, --json, and --dry-run support are automatic.
|
|
4
17
|
*/
|
|
5
18
|
import { Command } from 'commander';
|
|
6
19
|
import { GenerateResult, GenerateCLIOptions } from '../utils/generator';
|
|
20
|
+
/**
|
|
21
|
+
* Declarative configuration for a single-file generator.
|
|
22
|
+
*
|
|
23
|
+
* Each entry in SIMPLE_GENERATORS produces one CLI sub-command under
|
|
24
|
+
* `hazel generate` (e.g. `hazel g controller <name>`).
|
|
25
|
+
*/
|
|
7
26
|
export interface SimpleGeneratorConfig {
|
|
27
|
+
/** Generator type used as the sub-command name (e.g. 'controller', 'agent') */
|
|
8
28
|
type: string;
|
|
29
|
+
/** Human-readable description shown in `hazel g --list` and `--help` */
|
|
9
30
|
description: string;
|
|
31
|
+
/** File suffix before .ts — e.g. 'controller' produces `name.controller.ts` */
|
|
10
32
|
suffix: string;
|
|
33
|
+
/** Mustache template string (imported from ./templates.ts) */
|
|
11
34
|
template: string;
|
|
35
|
+
/** Short alias for the sub-command (e.g. 'c' for controller) */
|
|
12
36
|
alias?: string;
|
|
37
|
+
/** Default output directory if --path is not provided (defaults to 'src') */
|
|
13
38
|
defaultPath?: string;
|
|
39
|
+
/** Whether the generator requires a <name> argument (false for config, etc.) */
|
|
14
40
|
nameRequired: boolean;
|
|
15
|
-
/**
|
|
41
|
+
/** Factory function returning extra Mustache data merged into the template context */
|
|
16
42
|
extraData?: (name: string) => Record<string, string>;
|
|
17
|
-
/**
|
|
43
|
+
/** Post-generation instructions printed to the user (e.g. 'npm install ...') */
|
|
18
44
|
nextSteps?: string[];
|
|
19
|
-
/**
|
|
45
|
+
/** Additional CLI options beyond the standard --path, --dry-run, --json */
|
|
20
46
|
extraOptions?: string[];
|
|
21
47
|
}
|
|
22
48
|
export declare const SIMPLE_GENERATORS: SimpleGeneratorConfig[];
|
|
49
|
+
/**
|
|
50
|
+
* Execute a simple generator given its config, a name, and CLI options.
|
|
51
|
+
*
|
|
52
|
+
* @param config - The SimpleGeneratorConfig entry (from SIMPLE_GENERATORS)
|
|
53
|
+
* @param name - User-provided name (e.g. 'users') — used for file and class names
|
|
54
|
+
* @param options - Standard CLI options (--path, --dry-run, --json, --platform)
|
|
55
|
+
* @returns A GenerateResult with created file paths and optional next steps
|
|
56
|
+
*/
|
|
23
57
|
export declare function runSimpleGenerator(config: SimpleGeneratorConfig, name: string, options: GenerateCLIOptions): Promise<GenerateResult>;
|
|
24
|
-
/**
|
|
58
|
+
/**
|
|
59
|
+
* Register all simple generators as sub-commands of the `hazel generate` command.
|
|
60
|
+
*
|
|
61
|
+
* Iterates over SIMPLE_GENERATORS and creates a Commander sub-command for each,
|
|
62
|
+
* wiring up aliases, options (--path, --dry-run, --json, plus any extraOptions),
|
|
63
|
+
* and the action handler that calls runSimpleGenerator.
|
|
64
|
+
*
|
|
65
|
+
* @param generateCommand - The Commander `generate` parent command to attach sub-commands to
|
|
66
|
+
*/
|
|
25
67
|
export declare function registerSimpleGenerators(generateCommand: Command): void;
|
|
26
|
-
/**
|
|
68
|
+
/**
|
|
69
|
+
* Look up a SimpleGeneratorConfig by its type name (e.g. 'controller', 'agent').
|
|
70
|
+
*
|
|
71
|
+
* @param type - The generator type to find
|
|
72
|
+
* @returns The matching config, or undefined if no simple generator matches
|
|
73
|
+
*/
|
|
27
74
|
export declare function findSimpleGenerator(type: string): SimpleGeneratorConfig | undefined;
|