@rudderjs/cli 0.0.6 → 0.0.7
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/README.md +1 -1
- package/dist/commands/command-list.d.ts +3 -0
- package/dist/commands/command-list.d.ts.map +1 -0
- package/dist/commands/command-list.js +57 -0
- package/dist/commands/command-list.js.map +1 -0
- package/dist/commands/make/_shared.d.ts +19 -0
- package/dist/commands/make/_shared.d.ts.map +1 -0
- package/dist/commands/make/_shared.js +27 -0
- package/dist/commands/make/_shared.js.map +1 -0
- package/dist/commands/make/command.d.ts.map +1 -1
- package/dist/commands/make/command.js +11 -18
- package/dist/commands/make/command.js.map +1 -1
- package/dist/commands/make/controller.d.ts.map +1 -1
- package/dist/commands/make/controller.js +8 -21
- package/dist/commands/make/controller.js.map +1 -1
- package/dist/commands/make/event.d.ts.map +1 -1
- package/dist/commands/make/event.js +7 -20
- package/dist/commands/make/event.js.map +1 -1
- package/dist/commands/make/job.d.ts.map +1 -1
- package/dist/commands/make/job.js +7 -20
- package/dist/commands/make/job.js.map +1 -1
- package/dist/commands/make/listener.d.ts.map +1 -1
- package/dist/commands/make/listener.js +7 -20
- package/dist/commands/make/listener.js.map +1 -1
- package/dist/commands/make/mail.d.ts.map +1 -1
- package/dist/commands/make/mail.js +7 -20
- package/dist/commands/make/mail.js.map +1 -1
- package/dist/commands/make/middleware.d.ts.map +1 -1
- package/dist/commands/make/middleware.js +8 -20
- package/dist/commands/make/middleware.js.map +1 -1
- package/dist/commands/make/model.d.ts.map +1 -1
- package/dist/commands/make/model.js +7 -21
- package/dist/commands/make/model.js.map +1 -1
- package/dist/commands/make/provider.d.ts.map +1 -1
- package/dist/commands/make/provider.js +8 -20
- package/dist/commands/make/provider.js.map +1 -1
- package/dist/commands/make/request.d.ts.map +1 -1
- package/dist/commands/make/request.js +8 -20
- package/dist/commands/make/request.js.map +1 -1
- package/dist/commands/make.d.ts.map +1 -1
- package/dist/commands/make.js +19 -10
- package/dist/commands/make.js.map +1 -1
- package/dist/commands/providers-discover.d.ts +8 -0
- package/dist/commands/providers-discover.d.ts.map +1 -0
- package/dist/commands/providers-discover.js +77 -0
- package/dist/commands/providers-discover.js.map +1 -0
- package/dist/commands/vendor-publish.d.ts.map +1 -1
- package/dist/commands/vendor-publish.js +16 -2
- package/dist/commands/vendor-publish.js.map +1 -1
- package/dist/errors.d.ts +10 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +14 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.js +139 -85
- package/dist/index.js.map +1 -1
- package/package.json +12 -3
- package/dist/commands/make/agent.d.ts +0 -4
- package/dist/commands/make/agent.d.ts.map +0 -1
- package/dist/commands/make/agent.js +0 -41
- package/dist/commands/make/agent.js.map +0 -1
- package/dist/commands/make/mcp-prompt.d.ts +0 -4
- package/dist/commands/make/mcp-prompt.d.ts.map +0 -1
- package/dist/commands/make/mcp-prompt.js +0 -45
- package/dist/commands/make/mcp-prompt.js.map +0 -1
- package/dist/commands/make/mcp-resource.d.ts +0 -4
- package/dist/commands/make/mcp-resource.d.ts.map +0 -1
- package/dist/commands/make/mcp-resource.js +0 -44
- package/dist/commands/make/mcp-resource.js.map +0 -1
- package/dist/commands/make/mcp-server.d.ts +0 -4
- package/dist/commands/make/mcp-server.d.ts.map +0 -1
- package/dist/commands/make/mcp-server.js +0 -46
- package/dist/commands/make/mcp-server.js.map +0 -1
- package/dist/commands/make/mcp-tool.d.ts +0 -4
- package/dist/commands/make/mcp-tool.d.ts.map +0 -1
- package/dist/commands/make/mcp-tool.js +0 -43
- package/dist/commands/make/mcp-tool.js.map +0 -1
- package/dist/commands/migrate.d.ts +0 -11
- package/dist/commands/migrate.d.ts.map +0 -1
- package/dist/commands/migrate.js +0 -152
- package/dist/commands/migrate.js.map +0 -1
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ RudderJS CLI — code generators, module scaffolding, and rudder command dispatc
|
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
|
-
The CLI is automatically included when you scaffold a project with `create-
|
|
7
|
+
The CLI is automatically included when you scaffold a project with `create-rudder-app`. For manual setup:
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
10
|
pnpm add -D @rudderjs/cli
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-list.d.ts","sourceRoot":"","sources":["../../src/commands/command-list.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAiE5D,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI,CAOlE"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { rudder, parseSignature } from '@rudderjs/rudder';
|
|
2
|
+
const C = {
|
|
3
|
+
green: (s) => `\x1b[32m${s}\x1b[0m`,
|
|
4
|
+
cyan: (s) => `\x1b[36m${s}\x1b[0m`,
|
|
5
|
+
dim: (s) => `\x1b[2m${s}\x1b[0m`,
|
|
6
|
+
bold: (s) => `\x1b[1m${s}\x1b[0m`,
|
|
7
|
+
};
|
|
8
|
+
function collectUserCommands() {
|
|
9
|
+
const out = [];
|
|
10
|
+
for (const cmd of rudder.getCommands()) {
|
|
11
|
+
out.push({ name: cmd.name, description: cmd.getDescription(), source: 'inline' });
|
|
12
|
+
}
|
|
13
|
+
for (const CommandClass of rudder.getClasses()) {
|
|
14
|
+
const instance = new CommandClass();
|
|
15
|
+
const { name } = parseSignature(instance.signature);
|
|
16
|
+
out.push({ name, description: instance.description, source: 'class' });
|
|
17
|
+
}
|
|
18
|
+
return out.sort((a, b) => a.name.localeCompare(b.name));
|
|
19
|
+
}
|
|
20
|
+
function printCommands(cmds) {
|
|
21
|
+
if (cmds.length === 0) {
|
|
22
|
+
console.log('\n No user-registered commands. Define them in routes/console.ts.\n');
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
// Group by namespace (the part before ':')
|
|
26
|
+
const root = [];
|
|
27
|
+
const groups = {};
|
|
28
|
+
for (const c of cmds) {
|
|
29
|
+
if (!c.name.includes(':')) {
|
|
30
|
+
root.push(c);
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
const ns = c.name.split(':')[0] ?? c.name;
|
|
34
|
+
groups[ns] = [...(groups[ns] ?? []), c];
|
|
35
|
+
}
|
|
36
|
+
const nameWidth = Math.max(...cmds.map(c => c.name.length), 8) + 4;
|
|
37
|
+
console.log(`\n ${C.bold('Registered commands')} ${C.dim(`(${cmds.length})`)}\n`);
|
|
38
|
+
for (const c of root) {
|
|
39
|
+
console.log(` ${C.green(c.name.padEnd(nameWidth))} ${c.description} ${C.dim(`[${c.source}]`)}`);
|
|
40
|
+
}
|
|
41
|
+
for (const [ns, items] of Object.entries(groups).sort()) {
|
|
42
|
+
console.log(`\n ${C.dim(ns)}`);
|
|
43
|
+
for (const c of items) {
|
|
44
|
+
console.log(` ${C.green(c.name.padEnd(nameWidth))} ${c.description} ${C.dim(`[${c.source}]`)}`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
console.log();
|
|
48
|
+
}
|
|
49
|
+
export function commandListCommand(program) {
|
|
50
|
+
program
|
|
51
|
+
.command('command:list')
|
|
52
|
+
.description('List all user-registered Rudder commands grouped by namespace')
|
|
53
|
+
.action(() => {
|
|
54
|
+
printCommands(collectUserCommands());
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=command-list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-list.js","sourceRoot":"","sources":["../../src/commands/command-list.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Command } from 'commander';
|
|
2
|
+
export interface MakeSpec {
|
|
3
|
+
/** Commander command name, e.g. `make:controller` */
|
|
4
|
+
command: string;
|
|
5
|
+
/** Human description shown in help */
|
|
6
|
+
description: string;
|
|
7
|
+
/** Label after the success checkmark, e.g. `Controller created` */
|
|
8
|
+
label: string;
|
|
9
|
+
/** Suffix appended to the class name if not already present */
|
|
10
|
+
suffix?: string;
|
|
11
|
+
/** Destination directory under the app root, e.g. `app/Http/Controllers` */
|
|
12
|
+
directory: string;
|
|
13
|
+
/** Stub generator — receives the normalized class name */
|
|
14
|
+
stub: (className: string) => string;
|
|
15
|
+
/** Optional hook printed after the success line */
|
|
16
|
+
afterCreate?: (className: string, relPath: string) => void;
|
|
17
|
+
}
|
|
18
|
+
export declare function registerMake(program: Command, spec: MakeSpec): void;
|
|
19
|
+
//# sourceMappingURL=_shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_shared.d.ts","sourceRoot":"","sources":["../../../src/commands/make/_shared.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAGxC,MAAM,WAAW,QAAQ;IACvB,qDAAqD;IACrD,OAAO,EAAM,MAAM,CAAA;IACnB,sCAAsC;IACtC,WAAW,EAAE,MAAM,CAAA;IACnB,mEAAmE;IACnE,KAAK,EAAQ,MAAM,CAAA;IACnB,+DAA+D;IAC/D,MAAM,CAAC,EAAM,MAAM,CAAA;IACnB,4EAA4E;IAC5E,SAAS,EAAI,MAAM,CAAA;IACnB,0DAA0D;IAC1D,IAAI,EAAS,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,CAAA;IAC1C,mDAAmD;IACnD,WAAW,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;CAC3D;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,GAAG,IAAI,CAwBnE"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { writeFile, mkdir } from 'node:fs/promises';
|
|
2
|
+
import { existsSync } from 'node:fs';
|
|
3
|
+
import { resolve, dirname } from 'node:path';
|
|
4
|
+
import chalk from 'chalk';
|
|
5
|
+
export function registerMake(program, spec) {
|
|
6
|
+
program
|
|
7
|
+
.command(`${spec.command} <name>`)
|
|
8
|
+
.description(spec.description)
|
|
9
|
+
.option('-f, --force', 'Overwrite if file already exists')
|
|
10
|
+
.action(async (name, opts) => {
|
|
11
|
+
const className = spec.suffix && !name.endsWith(spec.suffix)
|
|
12
|
+
? `${name}${spec.suffix}`
|
|
13
|
+
: name;
|
|
14
|
+
const relPath = `${spec.directory}/${className}.ts`;
|
|
15
|
+
const outPath = resolve(process.cwd(), relPath);
|
|
16
|
+
if (existsSync(outPath) && !opts.force) {
|
|
17
|
+
console.error(chalk.red(` ✗ Already exists: ${relPath}`));
|
|
18
|
+
console.error(chalk.dim(' Use --force to overwrite.'));
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
await mkdir(dirname(outPath), { recursive: true });
|
|
22
|
+
await writeFile(outPath, spec.stub(className));
|
|
23
|
+
console.log(chalk.green(` ✔ ${spec.label}:`), chalk.cyan(relPath));
|
|
24
|
+
spec.afterCreate?.(className, relPath);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=_shared.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_shared.js","sourceRoot":"","sources":["../../../src/commands/make/_shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAE5C,OAAO,KAAK,MAAM,OAAO,CAAA;AAmBzB,MAAM,UAAU,YAAY,CAAC,OAAgB,EAAE,IAAc;IAC3D,OAAO;SACJ,OAAO,CAAC,GAAG,IAAI,CAAC,OAAO,SAAS,CAAC;SACjC,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC;SAC7B,MAAM,CAAC,aAAa,EAAE,kCAAkC,CAAC;SACzD,MAAM,CAAC,KAAK,EAAE,IAAY,EAAE,IAAyB,EAAE,EAAE;QACxD,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC;YAC1D,CAAC,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC,MAAM,EAAE;YACzB,CAAC,CAAC,IAAI,CAAA;QACR,MAAM,OAAO,GAAG,GAAG,IAAI,CAAC,SAAS,IAAI,SAAS,KAAK,CAAA;QACnD,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,OAAO,CAAC,CAAA;QAE/C,IAAI,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;YACvC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,uBAAuB,OAAO,EAAE,CAAC,CAAC,CAAA;YAC1D,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC,CAAA;YACzD,OAAM;QACR,CAAC;QAED,MAAM,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;QAClD,MAAM,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAA;QAE9C,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,IAAI,CAAC,KAAK,GAAG,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAA;QACnE,IAAI,CAAC,WAAW,EAAE,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;IACxC,CAAC,CAAC,CAAA;AACN,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../../src/commands/make/command.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../../src/commands/make/command.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAIxC,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAwBzC;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAWrD"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import { resolve } from 'node:path';
|
|
4
|
-
import { log } from '@clack/prompts';
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
import { registerMake } from './_shared.js';
|
|
5
3
|
export function stub(name) {
|
|
6
4
|
// Convert PascalCase to kebab:case for default signature, e.g. SendEmails → send:emails
|
|
7
5
|
const kebab = name
|
|
@@ -27,20 +25,15 @@ export class ${name} extends Command {
|
|
|
27
25
|
`;
|
|
28
26
|
}
|
|
29
27
|
export function makeCommandCmd(program) {
|
|
30
|
-
program
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
log.
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
await mkdir(resolve(process.cwd(), 'app/Commands'), { recursive: true });
|
|
41
|
-
await writeFile(filePath, stub(name));
|
|
42
|
-
log.success(`Created app/Commands/${name}.ts`);
|
|
43
|
-
log.info(`Register it in routes/console.ts:\n rudder.register(${name})`);
|
|
28
|
+
registerMake(program, {
|
|
29
|
+
command: 'make:command',
|
|
30
|
+
description: 'Create a new rudder command class',
|
|
31
|
+
label: 'Command created',
|
|
32
|
+
directory: 'app/Commands',
|
|
33
|
+
stub,
|
|
34
|
+
afterCreate: (className) => {
|
|
35
|
+
console.log(chalk.dim(` Register it in routes/console.ts: rudder.register(${className})`));
|
|
36
|
+
},
|
|
44
37
|
});
|
|
45
38
|
}
|
|
46
39
|
//# sourceMappingURL=command.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.js","sourceRoot":"","sources":["../../../src/commands/make/command.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"command.js","sourceRoot":"","sources":["../../../src/commands/make/command.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAE3C,MAAM,UAAU,IAAI,CAAC,IAAY;IAC/B,wFAAwF;IACxF,MAAM,KAAK,GAAG,IAAI;SACf,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;SACzD,WAAW,EAAE,CAAA;IAEhB,OAAO;;eAEM,IAAI;4BACS,KAAK;2CACU,IAAI;;;yBAGtB,IAAI;;;;;;;;;;CAU5B,CAAA;AACD,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,OAAgB;IAC7C,YAAY,CAAC,OAAO,EAAE;QACpB,OAAO,EAAM,cAAc;QAC3B,WAAW,EAAE,mCAAmC;QAChD,KAAK,EAAQ,iBAAiB;QAC9B,SAAS,EAAI,cAAc;QAC3B,IAAI;QACJ,WAAW,EAAE,CAAC,SAAS,EAAE,EAAE;YACzB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,0DAA0D,SAAS,GAAG,CAAC,CAAC,CAAA;QAChG,CAAC;KACF,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../../src/commands/make/controller.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../../src/commands/make/controller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAGxC,wBAAgB,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAY9D;AAED,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAOtD;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CASrD"}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { existsSync } from 'node:fs';
|
|
3
|
-
import { resolve, dirname } from 'node:path';
|
|
4
|
-
import chalk from 'chalk';
|
|
1
|
+
import { registerMake } from './_shared.js';
|
|
5
2
|
export function stub(className, prefix) {
|
|
6
3
|
return `import { Controller, Get } from '@rudderjs/router'
|
|
7
4
|
import type { Context } from '@rudderjs/core'
|
|
@@ -24,23 +21,13 @@ export function derivePrefix(className) {
|
|
|
24
21
|
return `/${kebab}s`;
|
|
25
22
|
}
|
|
26
23
|
export function makeController(program) {
|
|
27
|
-
program
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const relPath = `app/Http/Controllers/${className}.ts`;
|
|
35
|
-
const outPath = resolve(process.cwd(), relPath);
|
|
36
|
-
if (existsSync(outPath) && !opts.force) {
|
|
37
|
-
console.error(chalk.red(` ✗ Already exists: ${relPath}`));
|
|
38
|
-
console.error(chalk.dim(' Use --force to overwrite.'));
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
await mkdir(dirname(outPath), { recursive: true });
|
|
42
|
-
await writeFile(outPath, stub(className, prefix));
|
|
43
|
-
console.log(chalk.green(' ✔ Controller created:'), chalk.cyan(relPath));
|
|
24
|
+
registerMake(program, {
|
|
25
|
+
command: 'make:controller',
|
|
26
|
+
description: 'Create a new controller class',
|
|
27
|
+
label: 'Controller created',
|
|
28
|
+
suffix: 'Controller',
|
|
29
|
+
directory: 'app/Http/Controllers',
|
|
30
|
+
stub: (className) => stub(className, derivePrefix(className)),
|
|
44
31
|
});
|
|
45
32
|
}
|
|
46
33
|
//# sourceMappingURL=controller.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller.js","sourceRoot":"","sources":["../../../src/commands/make/controller.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"controller.js","sourceRoot":"","sources":["../../../src/commands/make/controller.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAE3C,MAAM,UAAU,IAAI,CAAC,SAAiB,EAAE,MAAc;IACpD,OAAO;;;eAGM,MAAM;eACN,SAAS;;;;;;CAMvB,CAAA;AACD,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,SAAiB;IAC5C,MAAM,IAAI,GAAG,SAAS,CAAC,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAA;IACjD,0CAA0C;IAC1C,MAAM,KAAK,GAAG,IAAI;SACf,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;SACzD,WAAW,EAAE,CAAA;IAChB,OAAO,IAAI,KAAK,GAAG,CAAA;AACrB,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,OAAgB;IAC7C,YAAY,CAAC,OAAO,EAAE;QACpB,OAAO,EAAM,iBAAiB;QAC9B,WAAW,EAAE,+BAA+B;QAC5C,KAAK,EAAQ,oBAAoB;QACjC,MAAM,EAAO,YAAY;QACzB,SAAS,EAAI,sBAAsB;QACnC,IAAI,EAAS,CAAC,SAAS,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,EAAE,YAAY,CAAC,SAAS,CAAC,CAAC;KACrE,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../../../src/commands/make/event.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../../../src/commands/make/event.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAGxC,wBAAgB,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAO9C;AAED,wBAAgB,SAAS,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAQhD"}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { existsSync } from 'node:fs';
|
|
3
|
-
import { resolve, dirname } from 'node:path';
|
|
4
|
-
import chalk from 'chalk';
|
|
1
|
+
import { registerMake } from './_shared.js';
|
|
5
2
|
export function stub(className) {
|
|
6
3
|
return `export class ${className} {
|
|
7
4
|
constructor(
|
|
@@ -11,22 +8,12 @@ export function stub(className) {
|
|
|
11
8
|
`;
|
|
12
9
|
}
|
|
13
10
|
export function makeEvent(program) {
|
|
14
|
-
program
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const relPath = `app/Events/${className}.ts`;
|
|
21
|
-
const outPath = resolve(process.cwd(), relPath);
|
|
22
|
-
if (existsSync(outPath) && !opts.force) {
|
|
23
|
-
console.error(chalk.red(` ✗ Already exists: ${relPath}`));
|
|
24
|
-
console.error(chalk.dim(' Use --force to overwrite.'));
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
await mkdir(dirname(outPath), { recursive: true });
|
|
28
|
-
await writeFile(outPath, stub(className));
|
|
29
|
-
console.log(chalk.green(' ✔ Event created:'), chalk.cyan(relPath));
|
|
11
|
+
registerMake(program, {
|
|
12
|
+
command: 'make:event',
|
|
13
|
+
description: 'Create a new event class',
|
|
14
|
+
label: 'Event created',
|
|
15
|
+
directory: 'app/Events',
|
|
16
|
+
stub,
|
|
30
17
|
});
|
|
31
18
|
}
|
|
32
19
|
//# sourceMappingURL=event.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event.js","sourceRoot":"","sources":["../../../src/commands/make/event.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"event.js","sourceRoot":"","sources":["../../../src/commands/make/event.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAE3C,MAAM,UAAU,IAAI,CAAC,SAAiB;IACpC,OAAO,gBAAgB,SAAS;;;;;CAKjC,CAAA;AACD,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,OAAgB;IACxC,YAAY,CAAC,OAAO,EAAE;QACpB,OAAO,EAAM,YAAY;QACzB,WAAW,EAAE,0BAA0B;QACvC,KAAK,EAAQ,eAAe;QAC5B,SAAS,EAAI,YAAY;QACzB,IAAI;KACL,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"job.d.ts","sourceRoot":"","sources":["../../../src/commands/make/job.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"job.d.ts","sourceRoot":"","sources":["../../../src/commands/make/job.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAGxC,wBAAgB,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAgB9C;AAED,wBAAgB,OAAO,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAQ9C"}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { existsSync } from 'node:fs';
|
|
3
|
-
import { resolve, dirname } from 'node:path';
|
|
4
|
-
import chalk from 'chalk';
|
|
1
|
+
import { registerMake } from './_shared.js';
|
|
5
2
|
export function stub(className) {
|
|
6
3
|
return `import { Job } from '@rudderjs/queue'
|
|
7
4
|
|
|
@@ -20,22 +17,12 @@ export class ${className} extends Job {
|
|
|
20
17
|
`;
|
|
21
18
|
}
|
|
22
19
|
export function makeJob(program) {
|
|
23
|
-
program
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const relPath = `app/Jobs/${className}.ts`;
|
|
30
|
-
const outPath = resolve(process.cwd(), relPath);
|
|
31
|
-
if (existsSync(outPath) && !opts.force) {
|
|
32
|
-
console.error(chalk.red(` ✗ Already exists: ${relPath}`));
|
|
33
|
-
console.error(chalk.dim(' Use --force to overwrite.'));
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
await mkdir(dirname(outPath), { recursive: true });
|
|
37
|
-
await writeFile(outPath, stub(className));
|
|
38
|
-
console.log(chalk.green(' ✔ Job created:'), chalk.cyan(relPath));
|
|
20
|
+
registerMake(program, {
|
|
21
|
+
command: 'make:job',
|
|
22
|
+
description: 'Create a new queue job class',
|
|
23
|
+
label: 'Job created',
|
|
24
|
+
directory: 'app/Jobs',
|
|
25
|
+
stub,
|
|
39
26
|
});
|
|
40
27
|
}
|
|
41
28
|
//# sourceMappingURL=job.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"job.js","sourceRoot":"","sources":["../../../src/commands/make/job.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"job.js","sourceRoot":"","sources":["../../../src/commands/make/job.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAE3C,MAAM,UAAU,IAAI,CAAC,SAAiB;IACpC,OAAO;;eAEM,SAAS;;;;;;;;;;;;CAYvB,CAAA;AACD,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,OAAgB;IACtC,YAAY,CAAC,OAAO,EAAE;QACpB,OAAO,EAAM,UAAU;QACvB,WAAW,EAAE,8BAA8B;QAC3C,KAAK,EAAQ,aAAa;QAC1B,SAAS,EAAI,UAAU;QACvB,IAAI;KACL,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listener.d.ts","sourceRoot":"","sources":["../../../src/commands/make/listener.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"listener.d.ts","sourceRoot":"","sources":["../../../src/commands/make/listener.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAGxC,wBAAgB,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAS9C;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAQnD"}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { existsSync } from 'node:fs';
|
|
3
|
-
import { resolve, dirname } from 'node:path';
|
|
4
|
-
import chalk from 'chalk';
|
|
1
|
+
import { registerMake } from './_shared.js';
|
|
5
2
|
export function stub(className) {
|
|
6
3
|
return `import type { Listener } from '@rudderjs/core'
|
|
7
4
|
|
|
@@ -13,22 +10,12 @@ export class ${className} implements Listener {
|
|
|
13
10
|
`;
|
|
14
11
|
}
|
|
15
12
|
export function makeListener(program) {
|
|
16
|
-
program
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const relPath = `app/Listeners/${className}.ts`;
|
|
23
|
-
const outPath = resolve(process.cwd(), relPath);
|
|
24
|
-
if (existsSync(outPath) && !opts.force) {
|
|
25
|
-
console.error(chalk.red(` ✗ Already exists: ${relPath}`));
|
|
26
|
-
console.error(chalk.dim(' Use --force to overwrite.'));
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
await mkdir(dirname(outPath), { recursive: true });
|
|
30
|
-
await writeFile(outPath, stub(className));
|
|
31
|
-
console.log(chalk.green(' ✔ Listener created:'), chalk.cyan(relPath));
|
|
13
|
+
registerMake(program, {
|
|
14
|
+
command: 'make:listener',
|
|
15
|
+
description: 'Create a new event listener class',
|
|
16
|
+
label: 'Listener created',
|
|
17
|
+
directory: 'app/Listeners',
|
|
18
|
+
stub,
|
|
32
19
|
});
|
|
33
20
|
}
|
|
34
21
|
//# sourceMappingURL=listener.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listener.js","sourceRoot":"","sources":["../../../src/commands/make/listener.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"listener.js","sourceRoot":"","sources":["../../../src/commands/make/listener.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAE3C,MAAM,UAAU,IAAI,CAAC,SAAiB;IACpC,OAAO;;eAEM,SAAS;;;;;CAKvB,CAAA;AACD,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,OAAgB;IAC3C,YAAY,CAAC,OAAO,EAAE;QACpB,OAAO,EAAM,eAAe;QAC5B,WAAW,EAAE,mCAAmC;QAChD,KAAK,EAAQ,kBAAkB;QAC/B,SAAS,EAAI,eAAe;QAC5B,IAAI;KACL,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mail.d.ts","sourceRoot":"","sources":["../../../src/commands/make/mail.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mail.d.ts","sourceRoot":"","sources":["../../../src/commands/make/mail.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAGxC,wBAAgB,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAgB9C;AAED,wBAAgB,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAQ/C"}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { existsSync } from 'node:fs';
|
|
3
|
-
import { resolve, dirname } from 'node:path';
|
|
4
|
-
import chalk from 'chalk';
|
|
1
|
+
import { registerMake } from './_shared.js';
|
|
5
2
|
export function stub(className) {
|
|
6
3
|
return `import { Mailable } from '@rudderjs/mail'
|
|
7
4
|
|
|
@@ -20,22 +17,12 @@ export class ${className} extends Mailable {
|
|
|
20
17
|
`;
|
|
21
18
|
}
|
|
22
19
|
export function makeMail(program) {
|
|
23
|
-
program
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const relPath = `app/Mail/${className}.ts`;
|
|
30
|
-
const outPath = resolve(process.cwd(), relPath);
|
|
31
|
-
if (existsSync(outPath) && !opts.force) {
|
|
32
|
-
console.error(chalk.red(` ✗ Already exists: ${relPath}`));
|
|
33
|
-
console.error(chalk.dim(' Use --force to overwrite.'));
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
await mkdir(dirname(outPath), { recursive: true });
|
|
37
|
-
await writeFile(outPath, stub(className));
|
|
38
|
-
console.log(chalk.green(' ✔ Mailable created:'), chalk.cyan(relPath));
|
|
20
|
+
registerMake(program, {
|
|
21
|
+
command: 'make:mail',
|
|
22
|
+
description: 'Create a new mailable class',
|
|
23
|
+
label: 'Mailable created',
|
|
24
|
+
directory: 'app/Mail',
|
|
25
|
+
stub,
|
|
39
26
|
});
|
|
40
27
|
}
|
|
41
28
|
//# sourceMappingURL=mail.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mail.js","sourceRoot":"","sources":["../../../src/commands/make/mail.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mail.js","sourceRoot":"","sources":["../../../src/commands/make/mail.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAE3C,MAAM,UAAU,IAAI,CAAC,SAAiB;IACpC,OAAO;;eAEM,SAAS;;;;;;;;;;;;CAYvB,CAAA;AACD,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,OAAgB;IACvC,YAAY,CAAC,OAAO,EAAE;QACpB,OAAO,EAAM,WAAW;QACxB,WAAW,EAAE,6BAA6B;QAC1C,KAAK,EAAQ,kBAAkB;QAC/B,SAAS,EAAI,UAAU;QACvB,IAAI;KACL,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../../src/commands/make/middleware.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../../src/commands/make/middleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAGxC,wBAAgB,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAe9C;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CASrD"}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { existsSync } from 'node:fs';
|
|
3
|
-
import { resolve, dirname } from 'node:path';
|
|
4
|
-
import chalk from 'chalk';
|
|
1
|
+
import { registerMake } from './_shared.js';
|
|
5
2
|
export function stub(className) {
|
|
6
3
|
return `import { Middleware } from '@rudderjs/middleware'
|
|
7
4
|
import type { AppRequest, AppResponse } from '@rudderjs/contracts'
|
|
@@ -19,22 +16,13 @@ export class ${className} extends Middleware {
|
|
|
19
16
|
`;
|
|
20
17
|
}
|
|
21
18
|
export function makeMiddleware(program) {
|
|
22
|
-
program
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const outPath = resolve(process.cwd(), relPath);
|
|
30
|
-
if (existsSync(outPath) && !opts.force) {
|
|
31
|
-
console.error(chalk.red(` ✗ Already exists: ${relPath}`));
|
|
32
|
-
console.error(chalk.dim(' Use --force to overwrite.'));
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
await mkdir(dirname(outPath), { recursive: true });
|
|
36
|
-
await writeFile(outPath, stub(className));
|
|
37
|
-
console.log(chalk.green(' ✔ Middleware created:'), chalk.cyan(relPath));
|
|
19
|
+
registerMake(program, {
|
|
20
|
+
command: 'make:middleware',
|
|
21
|
+
description: 'Create a new middleware class',
|
|
22
|
+
label: 'Middleware created',
|
|
23
|
+
suffix: 'Middleware',
|
|
24
|
+
directory: 'app/Http/Middleware',
|
|
25
|
+
stub,
|
|
38
26
|
});
|
|
39
27
|
}
|
|
40
28
|
//# sourceMappingURL=middleware.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.js","sourceRoot":"","sources":["../../../src/commands/make/middleware.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"middleware.js","sourceRoot":"","sources":["../../../src/commands/make/middleware.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAE3C,MAAM,UAAU,IAAI,CAAC,SAAiB;IACpC,OAAO;;;eAGM,SAAS;;;;;;;;;;CAUvB,CAAA;AACD,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,OAAgB;IAC7C,YAAY,CAAC,OAAO,EAAE;QACpB,OAAO,EAAM,iBAAiB;QAC9B,WAAW,EAAE,+BAA+B;QAC5C,KAAK,EAAQ,oBAAoB;QACjC,MAAM,EAAO,YAAY;QACzB,SAAS,EAAI,qBAAqB;QAClC,IAAI;KACL,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../../src/commands/make/model.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../../src/commands/make/model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAGxC,wBAAgB,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAW7D;AAED,wBAAgB,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAOrD;AAED,wBAAgB,SAAS,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAQhD"}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { existsSync } from 'node:fs';
|
|
3
|
-
import { resolve, dirname } from 'node:path';
|
|
4
|
-
import chalk from 'chalk';
|
|
1
|
+
import { registerMake } from './_shared.js';
|
|
5
2
|
export function stub(className, table) {
|
|
6
3
|
return `import { Model } from '@rudderjs/orm'
|
|
7
4
|
|
|
@@ -21,23 +18,12 @@ export function deriveTable(className) {
|
|
|
21
18
|
.toLowerCase() + 's');
|
|
22
19
|
}
|
|
23
20
|
export function makeModel(program) {
|
|
24
|
-
program
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const table = deriveTable(className);
|
|
31
|
-
const relPath = `app/Models/${className}.ts`;
|
|
32
|
-
const outPath = resolve(process.cwd(), relPath);
|
|
33
|
-
if (existsSync(outPath) && !opts.force) {
|
|
34
|
-
console.error(chalk.red(` ✗ Already exists: ${relPath}`));
|
|
35
|
-
console.error(chalk.dim(' Use --force to overwrite.'));
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
await mkdir(dirname(outPath), { recursive: true });
|
|
39
|
-
await writeFile(outPath, stub(className, table));
|
|
40
|
-
console.log(chalk.green(' ✔ Model created:'), chalk.cyan(relPath));
|
|
21
|
+
registerMake(program, {
|
|
22
|
+
command: 'make:model',
|
|
23
|
+
description: 'Create a new ORM model class',
|
|
24
|
+
label: 'Model created',
|
|
25
|
+
directory: 'app/Models',
|
|
26
|
+
stub: (className) => stub(className, deriveTable(className)),
|
|
41
27
|
});
|
|
42
28
|
}
|
|
43
29
|
//# sourceMappingURL=model.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../../src/commands/make/model.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../../src/commands/make/model.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAE3C,MAAM,UAAU,IAAI,CAAC,SAAiB,EAAE,KAAa;IACnD,OAAO;;eAEM,SAAS;oBACJ,KAAK;;;;;;CAMxB,CAAA;AACD,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,SAAiB;IAC3C,0CAA0C;IAC1C,OAAO,CACL,SAAS;SACN,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;SACzD,WAAW,EAAE,GAAG,GAAG,CACvB,CAAA;AACH,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,OAAgB;IACxC,YAAY,CAAC,OAAO,EAAE;QACpB,OAAO,EAAM,YAAY;QACzB,WAAW,EAAE,8BAA8B;QAC3C,KAAK,EAAQ,eAAe;QAC5B,SAAS,EAAI,YAAY;QACzB,IAAI,EAAS,CAAC,SAAS,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;KACpE,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../src/commands/make/provider.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../src/commands/make/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAGxC,wBAAgB,IAAI,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAc9C;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CASnD"}
|