@tyravel/cli 0.1.0
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/bin/tyravel.d.ts +3 -0
- package/dist/bin/tyravel.d.ts.map +1 -0
- package/dist/bin/tyravel.js +5 -0
- package/dist/bin/tyravel.js.map +1 -0
- package/dist/command.d.ts +13 -0
- package/dist/command.d.ts.map +1 -0
- package/dist/command.js +11 -0
- package/dist/command.js.map +1 -0
- package/dist/commands/auth-install.d.ts +8 -0
- package/dist/commands/auth-install.d.ts.map +1 -0
- package/dist/commands/auth-install.js +39 -0
- package/dist/commands/auth-install.js.map +1 -0
- package/dist/commands/make-controller.d.ts +8 -0
- package/dist/commands/make-controller.d.ts.map +1 -0
- package/dist/commands/make-controller.js +31 -0
- package/dist/commands/make-controller.js.map +1 -0
- package/dist/commands/make-event.d.ts +8 -0
- package/dist/commands/make-event.d.ts.map +1 -0
- package/dist/commands/make-event.js +31 -0
- package/dist/commands/make-event.js.map +1 -0
- package/dist/commands/make-job.d.ts +8 -0
- package/dist/commands/make-job.d.ts.map +1 -0
- package/dist/commands/make-job.js +32 -0
- package/dist/commands/make-job.js.map +1 -0
- package/dist/commands/make-listener.d.ts +8 -0
- package/dist/commands/make-listener.d.ts.map +1 -0
- package/dist/commands/make-listener.js +32 -0
- package/dist/commands/make-listener.js.map +1 -0
- package/dist/commands/make-migration.d.ts +8 -0
- package/dist/commands/make-migration.d.ts.map +1 -0
- package/dist/commands/make-migration.js +50 -0
- package/dist/commands/make-migration.js.map +1 -0
- package/dist/commands/make-model.d.ts +8 -0
- package/dist/commands/make-model.d.ts.map +1 -0
- package/dist/commands/make-model.js +31 -0
- package/dist/commands/make-model.js.map +1 -0
- package/dist/commands/make-provider.d.ts +8 -0
- package/dist/commands/make-provider.d.ts.map +1 -0
- package/dist/commands/make-provider.js +32 -0
- package/dist/commands/make-provider.js.map +1 -0
- package/dist/commands/make-subscriber.d.ts +8 -0
- package/dist/commands/make-subscriber.d.ts.map +1 -0
- package/dist/commands/make-subscriber.js +30 -0
- package/dist/commands/make-subscriber.js.map +1 -0
- package/dist/commands/make-test.d.ts +8 -0
- package/dist/commands/make-test.d.ts.map +1 -0
- package/dist/commands/make-test.js +24 -0
- package/dist/commands/make-test.js.map +1 -0
- package/dist/commands/make-view.d.ts +8 -0
- package/dist/commands/make-view.d.ts.map +1 -0
- package/dist/commands/make-view.js +36 -0
- package/dist/commands/make-view.js.map +1 -0
- package/dist/commands/migrate.d.ts +8 -0
- package/dist/commands/migrate.d.ts.map +1 -0
- package/dist/commands/migrate.js +32 -0
- package/dist/commands/migrate.js.map +1 -0
- package/dist/commands/new.d.ts +8 -0
- package/dist/commands/new.d.ts.map +1 -0
- package/dist/commands/new.js +57 -0
- package/dist/commands/new.js.map +1 -0
- package/dist/commands/new.test.d.ts +2 -0
- package/dist/commands/new.test.d.ts.map +1 -0
- package/dist/commands/new.test.js +28 -0
- package/dist/commands/new.test.js.map +1 -0
- package/dist/commands/queue-failed.d.ts +20 -0
- package/dist/commands/queue-failed.d.ts.map +1 -0
- package/dist/commands/queue-failed.js +143 -0
- package/dist/commands/queue-failed.js.map +1 -0
- package/dist/commands/queue-table.d.ts +8 -0
- package/dist/commands/queue-table.d.ts.map +1 -0
- package/dist/commands/queue-table.js +38 -0
- package/dist/commands/queue-table.js.map +1 -0
- package/dist/commands/queue-work.d.ts +8 -0
- package/dist/commands/queue-work.d.ts.map +1 -0
- package/dist/commands/queue-work.js +55 -0
- package/dist/commands/queue-work.js.map +1 -0
- package/dist/commands/serve.d.ts +8 -0
- package/dist/commands/serve.d.ts.map +1 -0
- package/dist/commands/serve.js +77 -0
- package/dist/commands/serve.js.map +1 -0
- package/dist/commands/version.d.ts +7 -0
- package/dist/commands/version.d.ts.map +1 -0
- package/dist/commands/version.js +16 -0
- package/dist/commands/version.js.map +1 -0
- package/dist/console.d.ts +17 -0
- package/dist/console.d.ts.map +1 -0
- package/dist/console.js +114 -0
- package/dist/console.js.map +1 -0
- package/dist/console.test.d.ts +2 -0
- package/dist/console.test.d.ts.map +1 -0
- package/dist/console.test.js +42 -0
- package/dist/console.test.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/kernel.d.ts +3 -0
- package/dist/kernel.d.ts.map +1 -0
- package/dist/kernel.js +44 -0
- package/dist/kernel.js.map +1 -0
- package/dist/project.d.ts +12 -0
- package/dist/project.d.ts.map +1 -0
- package/dist/project.js +34 -0
- package/dist/project.js.map +1 -0
- package/dist/project.test.d.ts +2 -0
- package/dist/project.test.d.ts.map +1 -0
- package/dist/project.test.js +24 -0
- package/dist/project.test.js.map +1 -0
- package/dist/stubs-ecosystem.d.ts +5 -0
- package/dist/stubs-ecosystem.d.ts.map +1 -0
- package/dist/stubs-ecosystem.js +79 -0
- package/dist/stubs-ecosystem.js.map +1 -0
- package/dist/stubs-testing.d.ts +3 -0
- package/dist/stubs-testing.d.ts.map +1 -0
- package/dist/stubs-testing.js +33 -0
- package/dist/stubs-testing.js.map +1 -0
- package/dist/stubs.d.ts +35 -0
- package/dist/stubs.d.ts.map +1 -0
- package/dist/stubs.js +753 -0
- package/dist/stubs.js.map +1 -0
- package/dist/utils.d.ts +9 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +70 -0
- package/dist/utils.js.map +1 -0
- package/dist/utils.test.d.ts +2 -0
- package/dist/utils.test.d.ts.map +1 -0
- package/dist/utils.test.js +13 -0
- package/dist/utils.test.js.map +1 -0
- package/package.json +42 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/commands/version.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,qBAAa,cAAe,SAAQ,OAAO;IACzC,SAAkB,IAAI,aAAa;IACnC,SAAkB,WAAW,kCAAkC;IAEzD,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC;CAQhC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { dirname, join } from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { Command } from '../command.js';
|
|
5
|
+
export class VersionCommand extends Command {
|
|
6
|
+
name = 'version';
|
|
7
|
+
description = 'Show the Tyravel CLI version';
|
|
8
|
+
async handle() {
|
|
9
|
+
const currentDir = dirname(fileURLToPath(import.meta.url));
|
|
10
|
+
const packageJsonPath = join(currentDir, '..', '..', 'package.json');
|
|
11
|
+
const pkg = JSON.parse(readFileSync(packageJsonPath, 'utf8'));
|
|
12
|
+
console.log(`Tyravel CLI ${pkg.version}`);
|
|
13
|
+
return 0;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=version.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/commands/version.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,MAAM,OAAO,cAAe,SAAQ,OAAO;IACvB,IAAI,GAAG,SAAS,CAAC;IACjB,WAAW,GAAG,8BAA8B,CAAC;IAE/D,KAAK,CAAC,MAAM;QACV,MAAM,UAAU,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;QAC3D,MAAM,eAAe,GAAG,IAAI,CAAC,UAAU,EAAE,IAAI,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC;QACrE,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,eAAe,EAAE,MAAM,CAAC,CAAwB,CAAC;QAErF,OAAO,CAAC,GAAG,CAAC,eAAe,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;QAC1C,OAAO,CAAC,CAAC;IACX,CAAC;CACF"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Command } from './command.js';
|
|
2
|
+
export interface ParsedArgv {
|
|
3
|
+
command?: string;
|
|
4
|
+
args: string[];
|
|
5
|
+
options: Record<string, string | boolean>;
|
|
6
|
+
}
|
|
7
|
+
export declare function parseArgv(argv: string[]): ParsedArgv;
|
|
8
|
+
export declare class ConsoleKernel {
|
|
9
|
+
private readonly commands;
|
|
10
|
+
constructor(commands: Command[]);
|
|
11
|
+
list(): Command[];
|
|
12
|
+
run(argv: string[]): Promise<number>;
|
|
13
|
+
private find;
|
|
14
|
+
private printHelp;
|
|
15
|
+
private printCommandHelp;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=console.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"console.d.ts","sourceRoot":"","sources":["../src/console.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C,MAAM,WAAW,UAAU;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC;CAC3C;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,UAAU,CAmDpD;AAED,qBAAa,aAAa;IACZ,OAAO,CAAC,QAAQ,CAAC,QAAQ;gBAAR,QAAQ,EAAE,OAAO,EAAE;IAEhD,IAAI,IAAI,OAAO,EAAE;IAIX,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;IAmC1C,OAAO,CAAC,IAAI;IAIZ,OAAO,CAAC,SAAS;IAkBjB,OAAO,CAAC,gBAAgB;CAOzB"}
|
package/dist/console.js
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
export function parseArgv(argv) {
|
|
2
|
+
const options = {};
|
|
3
|
+
const positional = [];
|
|
4
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
5
|
+
const token = argv[index];
|
|
6
|
+
if (!token) {
|
|
7
|
+
continue;
|
|
8
|
+
}
|
|
9
|
+
if (token.startsWith('--')) {
|
|
10
|
+
const body = token.slice(2);
|
|
11
|
+
const equalsIndex = body.indexOf('=');
|
|
12
|
+
if (equalsIndex !== -1) {
|
|
13
|
+
options[body.slice(0, equalsIndex)] = body.slice(equalsIndex + 1);
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
const key = body;
|
|
17
|
+
const next = argv[index + 1];
|
|
18
|
+
if (!next || next.startsWith('--')) {
|
|
19
|
+
options[key] = true;
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
options[key] = next;
|
|
23
|
+
index += 1;
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
if (token.startsWith('-') && token.length > 1) {
|
|
27
|
+
const key = token.slice(1);
|
|
28
|
+
const next = argv[index + 1];
|
|
29
|
+
if (!next || next.startsWith('-')) {
|
|
30
|
+
options[key] = true;
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
options[key] = next;
|
|
34
|
+
index += 1;
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
positional.push(token);
|
|
38
|
+
}
|
|
39
|
+
const [command, ...args] = positional;
|
|
40
|
+
return { command, args, options };
|
|
41
|
+
}
|
|
42
|
+
export class ConsoleKernel {
|
|
43
|
+
commands;
|
|
44
|
+
constructor(commands) {
|
|
45
|
+
this.commands = commands;
|
|
46
|
+
}
|
|
47
|
+
list() {
|
|
48
|
+
return [...this.commands].sort((left, right) => left.name.localeCompare(right.name));
|
|
49
|
+
}
|
|
50
|
+
async run(argv) {
|
|
51
|
+
const parsed = parseArgv(argv);
|
|
52
|
+
if (!parsed.command || parsed.command === 'list') {
|
|
53
|
+
this.printHelp(parsed.command === 'list' ? this.list() : undefined);
|
|
54
|
+
return 0;
|
|
55
|
+
}
|
|
56
|
+
if (parsed.command === 'help') {
|
|
57
|
+
const target = parsed.args[0];
|
|
58
|
+
if (!target) {
|
|
59
|
+
this.printHelp();
|
|
60
|
+
return 0;
|
|
61
|
+
}
|
|
62
|
+
const command = this.find(target);
|
|
63
|
+
if (!command) {
|
|
64
|
+
console.error(`Unknown command: ${target}`);
|
|
65
|
+
return 1;
|
|
66
|
+
}
|
|
67
|
+
this.printCommandHelp(command);
|
|
68
|
+
return 0;
|
|
69
|
+
}
|
|
70
|
+
const command = this.find(parsed.command);
|
|
71
|
+
if (!command) {
|
|
72
|
+
console.error(`Unknown command: ${parsed.command}`);
|
|
73
|
+
console.error('Run `tyravel list` to see available commands.');
|
|
74
|
+
return 1;
|
|
75
|
+
}
|
|
76
|
+
return command.handle([...parsed.args, ...optionsToArgs(parsed.options)]);
|
|
77
|
+
}
|
|
78
|
+
find(name) {
|
|
79
|
+
return this.commands.find((command) => command.name === name);
|
|
80
|
+
}
|
|
81
|
+
printHelp(commands = this.list()) {
|
|
82
|
+
console.log('Tyravel CLI');
|
|
83
|
+
console.log('');
|
|
84
|
+
console.log('Usage:');
|
|
85
|
+
console.log(' tyravel <command> [options] [arguments]');
|
|
86
|
+
console.log('');
|
|
87
|
+
console.log('Available commands:');
|
|
88
|
+
const nameWidth = Math.max(...commands.map((command) => command.name.length), 'list'.length);
|
|
89
|
+
for (const command of commands) {
|
|
90
|
+
console.log(` ${command.name.padEnd(nameWidth)} ${command.description}`);
|
|
91
|
+
}
|
|
92
|
+
console.log(` ${'list'.padEnd(nameWidth)} List all available commands`);
|
|
93
|
+
console.log(` ${'help'.padEnd(nameWidth)} Display help for a command`);
|
|
94
|
+
}
|
|
95
|
+
printCommandHelp(command) {
|
|
96
|
+
console.log(`Command: ${command.name}`);
|
|
97
|
+
console.log(`Description: ${command.description}`);
|
|
98
|
+
if (command.usage) {
|
|
99
|
+
console.log(`Usage: ${command.usage}`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
function optionsToArgs(options) {
|
|
104
|
+
const args = [];
|
|
105
|
+
for (const [key, value] of Object.entries(options)) {
|
|
106
|
+
if (value === true) {
|
|
107
|
+
args.push(`--${key}`);
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
args.push(`--${key}`, String(value));
|
|
111
|
+
}
|
|
112
|
+
return args;
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=console.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"console.js","sourceRoot":"","sources":["../src/console.ts"],"names":[],"mappings":"AAQA,MAAM,UAAU,SAAS,CAAC,IAAc;IACtC,MAAM,OAAO,GAAqC,EAAE,CAAC;IACrD,MAAM,UAAU,GAAa,EAAE,CAAC;IAEhC,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QACpD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;QAC1B,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,SAAS;QACX,CAAC;QAED,IAAI,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YAC3B,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YAC5B,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;YAEtC,IAAI,WAAW,KAAK,CAAC,CAAC,EAAE,CAAC;gBACvB,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,GAAG,CAAC,CAAC,CAAC;gBAClE,SAAS;YACX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,CAAC;IAEO,gBAAgB,CAAC,OAAgB;QACvC,OAAO,CAAC,GAAG,CAAC,YAAY,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;QACxC,OAAO,CAAC,GAAG,CAAC,gBAAgB,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;QACnD,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;YAClB,OAAO,CAAC,GAAG,CAAC,UAAU,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;QACzC,CAAC;IACH,CAAC;CACF;AAED,SAAS,aAAa,CAAC,OAAyC;IAC9D,MAAM,IAAI,GAAa,EAAE,CAAC;IAE1B,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACnD,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YACnB,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC,CAAC;YACtB,SAAS;QACX,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,EAAE,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IACvC,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"console.test.d.ts","sourceRoot":"","sources":["../src/console.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { ConsoleKernel, parseArgv } from './console.js';
|
|
3
|
+
import { VersionCommand } from './commands/version.js';
|
|
4
|
+
describe('parseArgv', () => {
|
|
5
|
+
it('parses command and positional arguments', () => {
|
|
6
|
+
expect(parseArgv(['new', 'blog'])).toEqual({
|
|
7
|
+
command: 'new',
|
|
8
|
+
args: ['blog'],
|
|
9
|
+
options: {},
|
|
10
|
+
});
|
|
11
|
+
});
|
|
12
|
+
it('parses long and short options', () => {
|
|
13
|
+
expect(parseArgv(['serve', '--port', '4000', '-h', '0.0.0.0'])).toEqual({
|
|
14
|
+
command: 'serve',
|
|
15
|
+
args: [],
|
|
16
|
+
options: {
|
|
17
|
+
port: '4000',
|
|
18
|
+
h: '0.0.0.0',
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
it('parses boolean flags', () => {
|
|
23
|
+
expect(parseArgv(['new', 'blog', '--force'])).toEqual({
|
|
24
|
+
command: 'new',
|
|
25
|
+
args: ['blog'],
|
|
26
|
+
options: { force: true },
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
describe('ConsoleKernel', () => {
|
|
31
|
+
it('returns a non-zero exit code for unknown commands', async () => {
|
|
32
|
+
const kernel = new ConsoleKernel([new VersionCommand()]);
|
|
33
|
+
const code = await kernel.run(['missing-command']);
|
|
34
|
+
expect(code).toBe(1);
|
|
35
|
+
});
|
|
36
|
+
it('runs registered commands', async () => {
|
|
37
|
+
const kernel = new ConsoleKernel([new VersionCommand()]);
|
|
38
|
+
const code = await kernel.run(['version']);
|
|
39
|
+
expect(code).toBe(0);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
//# sourceMappingURL=console.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"console.test.js","sourceRoot":"","sources":["../src/console.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;IACzB,EAAE,CAAC,yCAAyC,EAAE,GAAG,EAAE;QACjD,MAAM,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;YACzC,OAA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E,CAAC,CAAC,CAAC;QACzD,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;QAC3C,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACvB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { Command } from './command.js';
|
|
2
|
+
export type { CommandDefinition } from './command.js';
|
|
3
|
+
export { ConsoleKernel, parseArgv } from './console.js';
|
|
4
|
+
export { createKernel } from './kernel.js';
|
|
5
|
+
export { findProjectRoot, loadProjectConfig, requireProjectRoot, } from './project.js';
|
|
6
|
+
export type { TyravelConfig } from './project.js';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,YAAY,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,cAAc,CAAC"}
|
package/dist/kernel.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kernel.d.ts","sourceRoot":"","sources":["../src/kernel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAoB7C,wBAAgB,YAAY,IAAI,aAAa,CAuB5C"}
|
package/dist/kernel.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { ConsoleKernel } from './console.js';
|
|
2
|
+
import { MakeEventCommand } from './commands/make-event.js';
|
|
3
|
+
import { MakeTestCommand } from './commands/make-test.js';
|
|
4
|
+
import { MakeControllerCommand } from './commands/make-controller.js';
|
|
5
|
+
import { MakeJobCommand } from './commands/make-job.js';
|
|
6
|
+
import { MakeSubscriberCommand } from './commands/make-subscriber.js';
|
|
7
|
+
import { MakeListenerCommand } from './commands/make-listener.js';
|
|
8
|
+
import { MakeMigrationCommand } from './commands/make-migration.js';
|
|
9
|
+
import { MakeModelCommand } from './commands/make-model.js';
|
|
10
|
+
import { MakeProviderCommand } from './commands/make-provider.js';
|
|
11
|
+
import { MakeViewCommand } from './commands/make-view.js';
|
|
12
|
+
import { MigrateCommand } from './commands/migrate.js';
|
|
13
|
+
import { AuthInstallCommand } from './commands/auth-install.js';
|
|
14
|
+
import { NewCommand } from './commands/new.js';
|
|
15
|
+
import { QueueFailedCommand, QueueFailedTableCommand, QueueRetryCommand } from './commands/queue-failed.js';
|
|
16
|
+
import { QueueTableCommand } from './commands/queue-table.js';
|
|
17
|
+
import { QueueWorkCommand } from './commands/queue-work.js';
|
|
18
|
+
import { ServeCommand } from './commands/serve.js';
|
|
19
|
+
import { VersionCommand } from './commands/version.js';
|
|
20
|
+
export function createKernel() {
|
|
21
|
+
return new ConsoleKernel([
|
|
22
|
+
new NewCommand(),
|
|
23
|
+
new AuthInstallCommand(),
|
|
24
|
+
new ServeCommand(),
|
|
25
|
+
new MigrateCommand(),
|
|
26
|
+
new MakeControllerCommand(),
|
|
27
|
+
new MakeModelCommand(),
|
|
28
|
+
new MakeMigrationCommand(),
|
|
29
|
+
new MakeProviderCommand(),
|
|
30
|
+
new MakeViewCommand(),
|
|
31
|
+
new MakeJobCommand(),
|
|
32
|
+
new MakeEventCommand(),
|
|
33
|
+
new MakeListenerCommand(),
|
|
34
|
+
new MakeSubscriberCommand(),
|
|
35
|
+
new MakeTestCommand(),
|
|
36
|
+
new QueueTableCommand(),
|
|
37
|
+
new QueueFailedTableCommand(),
|
|
38
|
+
new QueueFailedCommand(),
|
|
39
|
+
new QueueRetryCommand(),
|
|
40
|
+
new QueueWorkCommand(),
|
|
41
|
+
new VersionCommand(),
|
|
42
|
+
]);
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=kernel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kernel.js","sourceRoot":"","sources":["../src/kernel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC5G,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,MAAM,UAAU,YAAY;IAC1B,OAAO,IAAI,aAAa,CAAC;QACvB,IAAI,UAAU,EAAE;QAChB,IAAI,kBAAkB,EAAE;QACxB,IAAI,YAAY,EAAE;QAClB,IAAI,cAAc,EAAE;QACpB,IAAI,qBAAqB,EAAE;QAC3B,IAAI,gBAAgB,EAAE;QACtB,IAAI,oBAAoB,EAAE;QAC1B,IAAI,mBAAmB,EAAE;QACzB,IAAI,eAAe,EAAE;QACrB,IAAI,cAAc,EAAE;QACpB,IAAI,gBAAgB,EAAE;QACtB,IAAI,mBAAmB,EAAE;QACzB,IAAI,qBAAqB,EAAE;QAC3B,IAAI,eAAe,EAAE;QACrB,IAAI,iBAAiB,EAAE;QACvB,IAAI,uBAAuB,EAAE;QAC7B,IAAI,kBAAkB,EAAE;QACxB,IAAI,iBAAiB,EAAE;QACvB,IAAI,gBAAgB,EAAE;QACtB,IAAI,cAAc,EAAE;KACrB,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface TyravelConfig {
|
|
2
|
+
name: string;
|
|
3
|
+
entry: string;
|
|
4
|
+
serve: {
|
|
5
|
+
port: number;
|
|
6
|
+
hostname: string;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
export declare function findProjectRoot(startDir?: string): string | undefined;
|
|
10
|
+
export declare function loadProjectConfig(root: string): TyravelConfig;
|
|
11
|
+
export declare function requireProjectRoot(startDir?: string): string;
|
|
12
|
+
//# sourceMappingURL=project.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../src/project.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE;QACL,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC;CACH;AAID,wBAAgB,eAAe,CAAC,QAAQ,SAAgB,GAAG,MAAM,GAAG,SAAS,CAc5E;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,CAQ7D;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,SAAgB,GAAG,MAAM,CAQnE"}
|
package/dist/project.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { dirname, join, resolve } from 'node:path';
|
|
3
|
+
const PROJECT_MARKERS = ['tyravel.json', 'src/main.ts'];
|
|
4
|
+
export function findProjectRoot(startDir = process.cwd()) {
|
|
5
|
+
let current = resolve(startDir);
|
|
6
|
+
while (true) {
|
|
7
|
+
if (PROJECT_MARKERS.every((marker) => existsSync(join(current, marker)))) {
|
|
8
|
+
return current;
|
|
9
|
+
}
|
|
10
|
+
const parent = dirname(current);
|
|
11
|
+
if (parent === current) {
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
current = parent;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export function loadProjectConfig(root) {
|
|
18
|
+
const configPath = join(root, 'tyravel.json');
|
|
19
|
+
const raw = readFileSync(configPath, 'utf8');
|
|
20
|
+
try {
|
|
21
|
+
return JSON.parse(raw);
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
throw new Error(`Invalid JSON in ${configPath}`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export function requireProjectRoot(startDir = process.cwd()) {
|
|
28
|
+
const root = findProjectRoot(startDir);
|
|
29
|
+
if (!root) {
|
|
30
|
+
throw new Error('Could not find a Tyravel project. Run this command from an app directory or use `tyravel new`.');
|
|
31
|
+
}
|
|
32
|
+
return root;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=project.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project.js","sourceRoot":"","sources":["../src/project.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAWnD,MAAM,eAAe,GAAG,CAAC,cAAc,EAAE,aAAa,CAAU,CAAC;AAEjE,MAAM,UAAU,eAAe,CAAC,QAAQ,GAAG,OAAO,CAAC,GAAG,EAAE;IACtD,IAAI,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAEhC,OAAO,IAAI,EAAE,CAAC;QACZ,IAAI,eAAe,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;YACzE,OAAO,OAAO,CAAC;QACjB,CAAC;QAED,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;QAChC,IAAI,MAAM,KAAK,OAAO,EAAE,CAAC;YACvB,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,OAAO,GAAG,MAAM,CAAC;IACnB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,IAAY;IAC5C,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;IAC9C,MAAM,GAAG,GAAG,YAAY,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;IAC7C,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAkB,CAAC;IAC1C,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,KAAK,CAAC,mBAAmB,UAAU,EAAE,CAAC,CAAC;IACnD,CAAC;AACH,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,QAAQ,GAAG,OAAO,CAAC,GAAG,EAAE;IACzD,MAAM,IAAI,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC;IACvC,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CACb,gGAAgG,CACjG,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project.test.d.ts","sourceRoot":"","sources":["../src/project.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { tmpdir } from 'node:os';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { afterEach, describe, expect, it } from 'vitest';
|
|
5
|
+
import { findProjectRoot } from './project.js';
|
|
6
|
+
describe('findProjectRoot', () => {
|
|
7
|
+
let tempDir = '';
|
|
8
|
+
afterEach(() => {
|
|
9
|
+
if (tempDir) {
|
|
10
|
+
rmSync(tempDir, { recursive: true, force: true });
|
|
11
|
+
tempDir = '';
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
it('finds the nearest directory with Tyravel markers', () => {
|
|
15
|
+
tempDir = mkdtempSync(join(tmpdir(), 'tyravel-root-'));
|
|
16
|
+
writeFileSync(join(tempDir, 'tyravel.json'), '{}');
|
|
17
|
+
mkdirSync(join(tempDir, 'src'), { recursive: true });
|
|
18
|
+
writeFileSync(join(tempDir, 'src/main.ts'), '');
|
|
19
|
+
const nested = join(tempDir, 'app', 'routes');
|
|
20
|
+
mkdirSync(nested, { recursive: true });
|
|
21
|
+
expect(findProjectRoot(nested)).toBe(tempDir);
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
//# sourceMappingURL=project.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project.test.js","sourceRoot":"","sources":["../src/project.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxE,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE/C,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,IAAI,OAAO,GAAG,EAAE,CAAC;IAEjB,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,OAAO,EAAE,CAAC;YACZ,MAAM,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;YAClD,OAAO,GAAG,EAAE,CAAC;QACf,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,kDAAkD,EAAE,GAAG,EAAE;QAC1D,OAAO,GAAG,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,eAAe,CAAC,CAAC,CAAC;QACvD,aAAa,CAAC,IAAI,CAAC,OAAO,EAAE,cAAc,CAAC,EAAE,IAAI,CAAC,CAAC;QACnD,SAAS,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACrD,aAAa,CAAC,IAAI,CAAC,OAAO,EAAE,aAAa,CAAC,EAAE,EAAE,CAAC,CAAC;QAEhD,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;QAC9C,SAAS,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAEvC,MAAM,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAChD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stubs-ecosystem.d.ts","sourceRoot":"","sources":["../src/stubs-ecosystem.ts"],"names":[],"mappings":"AAAA,wBAAgB,WAAW,IAAI,MAAM,CAepC;AAED,wBAAgB,UAAU,IAAI,MAAM,CAyBnC;AAED,wBAAgB,mBAAmB,IAAI,MAAM,CAU5C;AAED,wBAAgB,2BAA2B,IAAI,MAAM,CAwBpD"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
export function cacheConfig() {
|
|
2
|
+
return `import type { CacheConfig } from '@tyravel/cache';
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
default: 'file',
|
|
6
|
+
prefix: 'tyravel',
|
|
7
|
+
connections: {
|
|
8
|
+
file: {
|
|
9
|
+
driver: 'file',
|
|
10
|
+
path: 'storage/framework/cache',
|
|
11
|
+
},
|
|
12
|
+
array: { driver: 'array' },
|
|
13
|
+
},
|
|
14
|
+
} satisfies CacheConfig;
|
|
15
|
+
`;
|
|
16
|
+
}
|
|
17
|
+
export function mailConfig() {
|
|
18
|
+
return `import type { MailConfig } from '@tyravel/mail';
|
|
19
|
+
|
|
20
|
+
export default {
|
|
21
|
+
default: 'log',
|
|
22
|
+
from: {
|
|
23
|
+
address: 'hello@example.com',
|
|
24
|
+
name: 'Tyravel',
|
|
25
|
+
},
|
|
26
|
+
connections: {
|
|
27
|
+
log: { driver: 'log' },
|
|
28
|
+
array: { driver: 'array' },
|
|
29
|
+
smtp: {
|
|
30
|
+
driver: 'smtp',
|
|
31
|
+
host: process.env.MAIL_HOST ?? '127.0.0.1',
|
|
32
|
+
port: Number(process.env.MAIL_PORT ?? 587),
|
|
33
|
+
username: process.env.MAIL_USERNAME,
|
|
34
|
+
password: process.env.MAIL_PASSWORD,
|
|
35
|
+
encryption: 'tls',
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
queue: 'default',
|
|
39
|
+
queueConnection: 'database',
|
|
40
|
+
} satisfies MailConfig;
|
|
41
|
+
`;
|
|
42
|
+
}
|
|
43
|
+
export function notificationsConfig() {
|
|
44
|
+
return `import type { NotificationsConfig } from '@tyravel/notifications';
|
|
45
|
+
|
|
46
|
+
export default {
|
|
47
|
+
table: 'notifications',
|
|
48
|
+
connection: 'sqlite',
|
|
49
|
+
queue: 'default',
|
|
50
|
+
queueConnection: 'database',
|
|
51
|
+
} satisfies NotificationsConfig;
|
|
52
|
+
`;
|
|
53
|
+
}
|
|
54
|
+
export function notificationsTableMigration() {
|
|
55
|
+
return `import { Migration } from '@tyravel/database';
|
|
56
|
+
import type { DatabaseConnection } from '@tyravel/database';
|
|
57
|
+
import type { SchemaBuilder } from '@tyravel/database';
|
|
58
|
+
|
|
59
|
+
export default class CreateNotificationsTable extends Migration {
|
|
60
|
+
override async up(_connection: DatabaseConnection, schema: SchemaBuilder) {
|
|
61
|
+
await schema.create('notifications', (table) => {
|
|
62
|
+
table.string('id', 36);
|
|
63
|
+
table.string('type');
|
|
64
|
+
table.string('notifiable_type');
|
|
65
|
+
table.string('notifiable_id');
|
|
66
|
+
table.text('data');
|
|
67
|
+
table.timestamp('read_at').nullable();
|
|
68
|
+
table.timestamp('created_at');
|
|
69
|
+
table.unique(['id']);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
override async down(_connection: DatabaseConnection, schema: SchemaBuilder) {
|
|
74
|
+
await schema.drop('notifications');
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
`;
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=stubs-ecosystem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stubs-ecosystem.js","sourceRoot":"","sources":["../src/stubs-ecosystem.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,WAAW;IACzB,OAAO;;;;;;;;;;;;;CAaR,CAAC;AACF,CAAC;AAED,MAAM,UAAU,UAAU;IACxB,OAAO;;;;;;;;;;;;;;;;;;;;;;;CAuBR,CAAC;AACF,CAAC;AAED,MAAM,UAAU,mBAAmB;IACjC,OAAO;;;;;;;;CAQR,CAAC;AACF,CAAC;AAED,MAAM,UAAU,2BAA2B;IACzC,OAAO;;;;;;;;;;;;;;;;;;;;;;CAsBR,CAAC;AACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stubs-testing.d.ts","sourceRoot":"","sources":["../src/stubs-testing.ts"],"names":[],"mappings":"AACA,wBAAgB,mBAAmB,IAAI,MAAM,CAS5C;AAED,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAqBzD"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export function projectVitestConfig() {
|
|
2
|
+
return `import { defineConfig } from 'vitest/config';
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
test: {
|
|
6
|
+
include: ['tests/**/*.test.ts'],
|
|
7
|
+
},
|
|
8
|
+
});
|
|
9
|
+
`;
|
|
10
|
+
}
|
|
11
|
+
export function featureTestStub(className) {
|
|
12
|
+
return `import { describe, it } from 'vitest';
|
|
13
|
+
import { Application } from '@tyravel/core';
|
|
14
|
+
import { TestCase, withTyravelTest } from '@tyravel/testing';
|
|
15
|
+
import '../src/routes/web.js';
|
|
16
|
+
|
|
17
|
+
class ${className} extends TestCase {
|
|
18
|
+
protected createApplication() {
|
|
19
|
+
return new Application(import.meta.dir + '/..');
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const t = withTyravelTest(${className});
|
|
24
|
+
|
|
25
|
+
describe('feature / example', () => {
|
|
26
|
+
it('responds on the home route', async () => {
|
|
27
|
+
const response = await t.http.get('http://localhost/');
|
|
28
|
+
await response.assertOk();
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
`;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=stubs-testing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stubs-testing.js","sourceRoot":"","sources":["../src/stubs-testing.ts"],"names":[],"mappings":"AACA,MAAM,UAAU,mBAAmB;IACjC,OAAO;;;;;;;CAOR,CAAC;AACF,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,SAAiB;IAC/C,OAAO;;;;;QAKD,SAAS;;;;;;4BAMW,SAAS;;;;;;;;CAQpC,CAAC;AACF,CAAC"}
|
package/dist/stubs.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export declare function projectPackageJson(name: string): string;
|
|
2
|
+
export declare function projectConfig(name: string): string;
|
|
3
|
+
export declare function mainEntry(): string;
|
|
4
|
+
export declare function appConfig(name: string): string;
|
|
5
|
+
export declare function viewsConfig(): string;
|
|
6
|
+
export declare function databaseConfig(): string;
|
|
7
|
+
export declare function appServiceProvider(): string;
|
|
8
|
+
export declare function webRoutes(): string;
|
|
9
|
+
export declare function controller(name: string): string;
|
|
10
|
+
export declare function model(name: string): string;
|
|
11
|
+
export declare function migration(className: string): string;
|
|
12
|
+
export declare function view(name: string): string;
|
|
13
|
+
export declare function layoutView(): string;
|
|
14
|
+
export declare function provider(name: string): string;
|
|
15
|
+
export declare function job(name: string): string;
|
|
16
|
+
export declare function queueConfig(): string;
|
|
17
|
+
export declare function jobsTableMigration(): string;
|
|
18
|
+
export declare function domainEvent(name: string): string;
|
|
19
|
+
export declare function eventListener(name: string): string;
|
|
20
|
+
export declare function eventsConfig(): string;
|
|
21
|
+
export declare function failedJobsTableMigration(): string;
|
|
22
|
+
export declare function eventSubscriber(name: string): string;
|
|
23
|
+
export declare function authConfig(): string;
|
|
24
|
+
export declare function userModel(): string;
|
|
25
|
+
export declare function usersTableMigration(): string;
|
|
26
|
+
export declare function sessionsTableMigration(): string;
|
|
27
|
+
export declare function passwordResetTokensMigration(): string;
|
|
28
|
+
export declare function personalAccessTokensMigration(): string;
|
|
29
|
+
export declare function oauthAccountsMigration(): string;
|
|
30
|
+
export declare function postPolicyStub(): string;
|
|
31
|
+
export declare function authController(): string;
|
|
32
|
+
export declare function authRoutes(): string;
|
|
33
|
+
export declare function appServiceProviderWithAuth(): string;
|
|
34
|
+
export declare function mainEntryWithAuth(): string;
|
|
35
|
+
//# sourceMappingURL=stubs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stubs.d.ts","sourceRoot":"","sources":["../src/stubs.ts"],"names":[],"mappings":"AAAA,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAkCvD;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAalD;AAED,wBAAgB,SAAS,IAAI,MAAM,CAgDlC;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAM9C;AAED,wBAAgB,WAAW,IAAI,MAAM,CAMpC;AAED,wBAAgB,cAAc,IAAI,MAAM,CA2BvC;AAED,wBAAgB,kBAAkB,IAAI,MAAM,CAS3C;AAED,wBAAgB,SAAS,IAAI,MAAM,CAWlC;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAqB/C;AAED,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAa1C;AAED,wBAAgB,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAenD;AAED,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,MAA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