@xeno-js/cli 0.1.0 → 0.1.1

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.
Files changed (91) hide show
  1. package/dist/index.js +3675 -18
  2. package/dist/index.js.map +1 -0
  3. package/eslint.config.mjs +1 -0
  4. package/package.json +4 -3
  5. package/tsup.config.ts +13 -0
  6. package/dist/domain/contracts/icommand-cli.contracts.js +0 -2
  7. package/dist/domain/contracts/icommand-runner.contracts.js +0 -2
  8. package/dist/domain/contracts/idispatch.contracts.js +0 -2
  9. package/dist/domain/contracts/ifile-service.contracts.js +0 -2
  10. package/dist/domain/contracts/igenerator.contracts.js +0 -2
  11. package/dist/domain/contracts/index.js +0 -2
  12. package/dist/domain/contracts/iscaffold-strategy.contracts.js +0 -2
  13. package/dist/domain/index.js +0 -2
  14. package/dist/generator.contracts.js +0 -13
  15. package/dist/infrastructure/bootstrap/bootstrapper.js +0 -32
  16. package/dist/infrastructure/bootstrap/index.js +0 -17
  17. package/dist/infrastructure/builder/builder.js +0 -16
  18. package/dist/infrastructure/builder/builder.test.js +0 -30
  19. package/dist/infrastructure/builder/index.js +0 -17
  20. package/dist/infrastructure/command_launcher/command.utils.js +0 -30
  21. package/dist/infrastructure/command_launcher/index.js +0 -2
  22. package/dist/infrastructure/commands/command-runner.service.js +0 -36
  23. package/dist/infrastructure/commands/generate.command.js +0 -48
  24. package/dist/infrastructure/commands/help.command.js +0 -44
  25. package/dist/infrastructure/commands/index.js +0 -20
  26. package/dist/infrastructure/commands/new-project.command.js +0 -43
  27. package/dist/infrastructure/dispatcher/dispatcher.js +0 -39
  28. package/dist/infrastructure/dispatcher/index.js +0 -17
  29. package/dist/infrastructure/file/file.service.js +0 -13
  30. package/dist/infrastructure/file/index.js +0 -17
  31. package/dist/infrastructure/generators/bootstrap.generator.js +0 -118
  32. package/dist/infrastructure/generators/core/bootstrap.generator.js +0 -118
  33. package/dist/infrastructure/generators/core/command/cqrs.generator.js +0 -49
  34. package/dist/infrastructure/generators/core/command/generate-command.generator.js +0 -163
  35. package/dist/infrastructure/generators/core/command/generate-query.generator.js +0 -131
  36. package/dist/infrastructure/generators/core/drizzle-sql-lite.generator.js +0 -78
  37. package/dist/infrastructure/generators/core/drizzle.generator.js +0 -85
  38. package/dist/infrastructure/generators/core/env.generator.js +0 -69
  39. package/dist/infrastructure/generators/core/index.js +0 -25
  40. package/dist/infrastructure/generators/core/main.generator.js +0 -45
  41. package/dist/infrastructure/generators/core/packagejson.generator.js +0 -78
  42. package/dist/infrastructure/generators/core/readme.generator.js +0 -431
  43. package/dist/infrastructure/generators/core/registry.generator.js +0 -46
  44. package/dist/infrastructure/generators/core/tsconfig.generator.js +0 -41
  45. package/dist/infrastructure/generators/core-packagejson.generator.js +0 -78
  46. package/dist/infrastructure/generators/drizzle-sql-lite.generator.js +0 -78
  47. package/dist/infrastructure/generators/drizzle.generator.js +0 -85
  48. package/dist/infrastructure/generators/env-vue.generator.js +0 -40
  49. package/dist/infrastructure/generators/env.generator.js +0 -71
  50. package/dist/infrastructure/generators/gitignore.generator.js +0 -62
  51. package/dist/infrastructure/generators/index.js +0 -26
  52. package/dist/infrastructure/generators/main.generator.js +0 -45
  53. package/dist/infrastructure/generators/readme.generator.js +0 -431
  54. package/dist/infrastructure/generators/registry.generator.js +0 -46
  55. package/dist/infrastructure/generators/tsconfig-vue.generator.js +0 -39
  56. package/dist/infrastructure/generators/tsconfig.generator.js +0 -41
  57. package/dist/infrastructure/generators/vite-config.generator.js +0 -39
  58. package/dist/infrastructure/generators/vue/app-vue.generator.js +0 -26
  59. package/dist/infrastructure/generators/vue/bootstrap-ts.generator.js +0 -59
  60. package/dist/infrastructure/generators/vue/command_query/cqrs.generator.js +0 -36
  61. package/dist/infrastructure/generators/vue/command_query/generate-command-vue.generator.js +0 -139
  62. package/dist/infrastructure/generators/vue/command_query/generate-query-vue.generator.js +0 -147
  63. package/dist/infrastructure/generators/vue/env.generator.js +0 -40
  64. package/dist/infrastructure/generators/vue/index-html.generator.js +0 -29
  65. package/dist/infrastructure/generators/vue/index.js +0 -28
  66. package/dist/infrastructure/generators/vue/main.generator.js +0 -45
  67. package/dist/infrastructure/generators/vue/packagejson.generator.js +0 -59
  68. package/dist/infrastructure/generators/vue/readme.generator.js +0 -394
  69. package/dist/infrastructure/generators/vue/registry-ts.generator.js +0 -28
  70. package/dist/infrastructure/generators/vue/router.generator.js +0 -33
  71. package/dist/infrastructure/generators/vue/tailwind.generator.js +0 -19
  72. package/dist/infrastructure/generators/vue/tsconfig.generator.js +0 -39
  73. package/dist/infrastructure/generators/vue/use-app.generator.js +0 -43
  74. package/dist/infrastructure/generators/vue/vite-config.generator.js +0 -39
  75. package/dist/infrastructure/generators/vue-packagejson.generator.js +0 -59
  76. package/dist/infrastructure/generators/vue-readme.generator.js +0 -53
  77. package/dist/infrastructure/generators/vue-source-files.generator.js +0 -136
  78. package/dist/infrastructure/index.js +0 -21
  79. package/dist/infrastructure/strategies/core-scaffold.strategy.js +0 -99
  80. package/dist/infrastructure/strategies/index.js +0 -18
  81. package/dist/infrastructure/strategies/vue-scaffold.strategy.js +0 -79
  82. package/dist/scaffolding.engine.js +0 -60
  83. package/dist/shared/constants/command.constants.js +0 -19
  84. package/dist/shared/constants/core.constants.js +0 -10
  85. package/dist/shared/constants/index.js +0 -18
  86. package/dist/shared/index.js +0 -18
  87. package/dist/shared/types/common.types.js +0 -2
  88. package/dist/shared/types/index.js +0 -2
  89. package/dist/shared/utils/guards.utils.js +0 -310
  90. package/dist/shared/utils/index.js +0 -18
  91. package/dist/shared/utils/string.utils.js +0 -62
@@ -1,17 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./bootstrapper"), exports);
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Builder = void 0;
4
- const commands_1 = require("../commands");
5
- const dispatcher_1 = require("../dispatcher");
6
- class Builder {
7
- static getDispatcher() {
8
- const dispatcher = new dispatcher_1.CliDispatcher([
9
- new commands_1.NewProjectCommand(),
10
- new commands_1.GenerateCommandQuery(),
11
- new commands_1.HelpCommand(),
12
- ]);
13
- return dispatcher;
14
- }
15
- }
16
- exports.Builder = Builder;
@@ -1,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const vitest_1 = require("vitest");
4
- const commands_1 = require("../commands");
5
- const dispatcher_1 = require("../dispatcher");
6
- const builder_1 = require("./builder");
7
- (0, vitest_1.describe)('Builder', () => {
8
- (0, vitest_1.it)('should create a dispatcher with the CLI commands registered', () => {
9
- const dispatcher = builder_1.Builder.getDispatcher();
10
- (0, vitest_1.expect)(dispatcher).toBeInstanceOf(dispatcher_1.CliDispatcher);
11
- });
12
- (0, vitest_1.it)('should dispatch the registered commands through the built dispatcher', async () => {
13
- const dispatcher = builder_1.Builder.getDispatcher();
14
- const newSpy = vitest_1.vi.spyOn(commands_1.NewProjectCommand.prototype, 'execute').mockResolvedValue();
15
- const generateSpy = vitest_1.vi.spyOn(commands_1.GenerateCommandQuery.prototype, 'execute').mockResolvedValue();
16
- const helpSpy = vitest_1.vi.spyOn(commands_1.HelpCommand.prototype, 'execute').mockResolvedValue();
17
- await dispatcher.dispatch(['new', 'demo-app']);
18
- await dispatcher.dispatch(['generate', 'command', 'User']);
19
- await dispatcher.dispatch(['--help']);
20
- await dispatcher.dispatch(['-h']);
21
- (0, vitest_1.expect)(newSpy).toHaveBeenCalledWith(['demo-app']);
22
- (0, vitest_1.expect)(generateSpy).toHaveBeenCalledWith(['command', 'User']);
23
- (0, vitest_1.expect)(helpSpy).toHaveBeenCalledTimes(2);
24
- (0, vitest_1.expect)(helpSpy).toHaveBeenNthCalledWith(1, []);
25
- (0, vitest_1.expect)(helpSpy).toHaveBeenNthCalledWith(2, []);
26
- newSpy.mockRestore();
27
- generateSpy.mockRestore();
28
- helpSpy.mockRestore();
29
- });
30
- });
@@ -1,17 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./builder"), exports);
@@ -1,30 +0,0 @@
1
- "use strict";
2
- // import { spawn } from 'node:child_process';
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- // /**
5
- // * @class CommandUtils
6
- // * @description Utility class for executing shell commands in a cross-platform manner.
7
- // *
8
- // * @author Xeno
9
- // * @version 1.0.0
10
- // * @license ISC
11
- // * @since 2025-09-30
12
- // * @link https://github.com/xeno-js/xeno-js
13
- // */
14
- // export const CommandLauncher = {
15
- // runCommand: (command: string, args: string[], cwd: string): Promise<void> => {
16
- // return new Promise((resolve, reject) => {
17
- // const isWin = process.platform === "win32";
18
- // const cmd = isWin ? `${command}.cmd` : command;
19
- // const child = spawn(cmd, args, {
20
- // cwd,
21
- // stdio: 'inherit',
22
- // shell: true
23
- // });
24
- // child.on('close', (code) => {
25
- // if (code === 0) resolve();
26
- // else reject(new Error(`Command ${command} failed with code ${code}`));
27
- // });
28
- // });
29
- // }
30
- // };
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,36 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CommandRunner = void 0;
4
- const node_child_process_1 = require("node:child_process");
5
- /**
6
- * @class CommandUtils
7
- * @description Utility class for executing shell commands in a cross-platform manner.
8
- *
9
- * @author Xeno
10
- * @version 1.0.0
11
- * @license ISC
12
- * @since 2025-09-30
13
- * @link https://github.com/xeno-js/xeno-js
14
- */
15
- class CommandRunner {
16
- async run(command, args, cwd, isWin = false) {
17
- return new Promise((resolve, reject) => {
18
- const cmd = isWin ? `${command}.cmd` : command;
19
- const child = (0, node_child_process_1.spawn)(cmd, args, {
20
- cwd,
21
- stdio: 'inherit',
22
- shell: false,
23
- });
24
- child.on('error', (error) => {
25
- reject(new Error(`Error during execution of the command ${command}: ${error.message}`));
26
- });
27
- child.on('close', (code) => {
28
- if (code === 0)
29
- resolve();
30
- else
31
- reject(new Error(`Command ${command} failed with code ${code}`));
32
- });
33
- });
34
- }
35
- }
36
- exports.CommandRunner = CommandRunner;
@@ -1,48 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.GenerateCommandQuery = void 0;
7
- const picocolors_1 = __importDefault(require("picocolors"));
8
- const shared_1 = require("../../shared");
9
- const command_constants_1 = require("../../shared/constants/command.constants");
10
- const file_1 = require("../file");
11
- class GenerateCommandQuery {
12
- name = 'generate';
13
- aliases = ['g'];
14
- async execute(args) {
15
- const type = args[0]; // "command" o "query"
16
- const componentName = args[1]; // es: "User"
17
- const isCore = args.includes('--core');
18
- const isVue = args.includes('--vue');
19
- if (shared_1.Guards.isNullOrEmpty(type) || shared_1.Guards.isNullOrEmpty(componentName)) {
20
- throw new Error(`Invalid syntax. Usage: xeno-js g [command | query] <Name> [--core | --vue]`);
21
- }
22
- let outputPath = undefined;
23
- const outputIndex = args.findIndex((arg) => arg === '--output' || arg === '-o' || arg === '--o');
24
- if (outputIndex !== -1 && args.length > outputIndex + 1) {
25
- outputPath = args[outputIndex + 1];
26
- }
27
- const targetDir = process.cwd();
28
- const fileService = new file_1.FileUtils();
29
- if (isCore || !isVue) {
30
- const cqrsType = type === command_constants_1.COMMAND_CONSTANTS.COMMAND ? command_constants_1.COMMAND_CONSTANTS.COMMAND : command_constants_1.COMMAND_CONSTANTS.QUERY;
31
- const { CqrsGenerator } = await import('../generators/core/command/cqrs.generator.js');
32
- const generator = new CqrsGenerator(fileService);
33
- await generator.generate(targetDir, componentName, cqrsType, outputPath);
34
- console.info(picocolors_1.default.green(`\n Successfully generated ${type} component '${componentName}'!`));
35
- }
36
- else if (isVue) {
37
- const cqrsType = type === command_constants_1.COMMAND_CONSTANTS.COMMAND ? command_constants_1.COMMAND_CONSTANTS.COMMAND : command_constants_1.COMMAND_CONSTANTS.QUERY;
38
- const { CqrsVueGenerator } = await import('../generators/vue/command_query/cqrs.generator.js');
39
- const generator = new CqrsVueGenerator(fileService);
40
- await generator.generate(targetDir, componentName, cqrsType, outputPath);
41
- console.info(picocolors_1.default.green(`\n✅ Successfully generated Vue ${type} component '${componentName}'!`));
42
- }
43
- else {
44
- throw new Error(`Unsupported generator type: '${type}'. Use 'command' or 'query'.`);
45
- }
46
- }
47
- }
48
- exports.GenerateCommandQuery = GenerateCommandQuery;
@@ -1,44 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.HelpCommand = void 0;
7
- const picocolors_1 = __importDefault(require("picocolors"));
8
- const shared_1 = require("../../shared");
9
- class HelpCommand {
10
- get name() {
11
- return shared_1.COMMAND_CONSTANTS.HELP;
12
- }
13
- get aliases() {
14
- return [shared_1.ARGS_CONSTANTS.HELP, '-h'];
15
- }
16
- async execute() {
17
- console.info(picocolors_1.default.greenBright('\n🚀 Xeno CLI - Usage Guide\n'));
18
- // --- NEW PROJECT ---
19
- console.info(picocolors_1.default.bold(picocolors_1.default.blue('1. Create a new project:')));
20
- console.info(` xeno-js new ${picocolors_1.default.yellow('<name>')} ${picocolors_1.default.cyan('[--vue | --core]')}`);
21
- console.info(` ${picocolors_1.default.gray('•')} ${picocolors_1.default.yellow('<name>')}: The name of your project directory.`);
22
- console.info(` ${picocolors_1.default.gray('•')} ${picocolors_1.default.cyan('[--vue | --core]')}: Project type. ${picocolors_1.default.gray('(Default: --core)')}`);
23
- console.info(` - ${picocolors_1.default.cyan('--core')}: Initializes a Backend project (Node.js/TS).`);
24
- console.info(` - ${picocolors_1.default.cyan('--vue')}: Initializes a Frontend project (Vue.js).\n`);
25
- // --- GENERATE ---
26
- console.info(picocolors_1.default.bold(picocolors_1.default.blue('2. Generate CQRS components:')));
27
- console.info(` xeno-js generate ${picocolors_1.default.magenta('<type>')} ${picocolors_1.default.yellow('<Name>')} ${picocolors_1.default.cyan('[--vue | --core]')} ${picocolors_1.default.green('[--output <path>]')}`);
28
- console.info(` ${picocolors_1.default.gray('•')} ${picocolors_1.default.magenta('<type>')}: Component type to generate (${picocolors_1.default.magenta('command')} | ${picocolors_1.default.magenta('query')}).`);
29
- console.info(` ${picocolors_1.default.gray('•')} ${picocolors_1.default.yellow('<Name>')}: The name of the component (e.g., UserCreate).`);
30
- console.info(` ${picocolors_1.default.gray('•')} ${picocolors_1.default.cyan('[--vue | --core]')}: Target context. ${picocolors_1.default.gray('(Default: --core)')}`);
31
- console.info(` - ${picocolors_1.default.cyan('--core')}: Generates Controller, Handler, Command/Query, Module, and Zod/DB schemas.`);
32
- console.info(` - ${picocolors_1.default.cyan('--vue')}: Generates frontend-specific files (Stores, Services, etc.).`);
33
- console.info(` ${picocolors_1.default.gray('•')} ${picocolors_1.default.green('[--output | -o]')}: Custom destination path inside 'src/'. ${picocolors_1.default.gray('(Default: src/<name-in-lowercase>)')}`);
34
- console.info(` ${picocolors_1.default.gray('Alias:')} ${picocolors_1.default.gray('xeno-js g <type> <Name> [--vue | --core] [-o | --o <path>]')}\n`);
35
- // --- HELP ---
36
- console.info(picocolors_1.default.bold(picocolors_1.default.blue('3. Help:')));
37
- console.info(` xeno-js --help ${picocolors_1.default.gray('Displays this guide.')}`);
38
- console.info(` ${picocolors_1.default.gray('Alias:')} ${picocolors_1.default.gray('xeno-js --h | -h')}\n`);
39
- // --- DOCS ---
40
- console.info(picocolors_1.default.bold(picocolors_1.default.blue('Documentation:')));
41
- console.info(` ${picocolors_1.default.underline('https://www.xeno-js.it')}\n`);
42
- }
43
- }
44
- exports.HelpCommand = HelpCommand;
@@ -1,20 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./command-runner.service"), exports);
18
- __exportStar(require("./generate.command"), exports);
19
- __exportStar(require("./help.command"), exports);
20
- __exportStar(require("./new-project.command"), exports);
@@ -1,43 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.NewProjectCommand = void 0;
7
- const picocolors_1 = __importDefault(require("picocolors"));
8
- const bootstrap_1 = require("../bootstrap");
9
- const file_1 = require("../file");
10
- const command_runner_service_1 = require("./command-runner.service");
11
- class NewProjectCommand {
12
- name = 'new';
13
- aliases = [];
14
- async execute(args) {
15
- const targetDir = args.find((arg) => !arg.startsWith('--')) ?? 'my-xeno-app';
16
- const isVue = args.includes('--vue');
17
- const fileService = new file_1.FileUtils();
18
- let strategy;
19
- if (isVue) {
20
- const { VueScaffoldStrategy } = await import('../strategies/vue-scaffold.strategy.js');
21
- strategy = new VueScaffoldStrategy(fileService);
22
- }
23
- else {
24
- const { CoreScaffoldStrategy } = await import('../strategies/core-scaffold.strategy.js');
25
- strategy = new CoreScaffoldStrategy(fileService);
26
- }
27
- const options = await strategy.promptOptions(targetDir);
28
- const generators = await strategy.getGenerators(options);
29
- const bootstrapper = new bootstrap_1.Bootstrapper(generators);
30
- await bootstrapper.run(targetDir, options);
31
- const commandRunner = new command_runner_service_1.CommandRunner();
32
- if (options.gitInit) {
33
- console.info(picocolors_1.default.greenBright('\n🗂️ Initializing Git repository...'));
34
- await commandRunner.run('git', ['init'], targetDir);
35
- }
36
- console.info(picocolors_1.default.greenBright('\n📦 Installing dependencies...'));
37
- const isWin = process.platform === 'win32';
38
- await commandRunner.run('npm', ['install'], targetDir, isWin);
39
- console.info(picocolors_1.default.green(`\n✅ Project successfully created in ./${targetDir}`));
40
- console.info(picocolors_1.default.white(`\nNext steps:\n cd ${targetDir}\n npm run start\n`));
41
- }
42
- }
43
- exports.NewProjectCommand = NewProjectCommand;
@@ -1,39 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.CliDispatcher = void 0;
7
- const picocolors_1 = __importDefault(require("picocolors"));
8
- const shared_1 = require("../../shared");
9
- class CliDispatcher {
10
- _commands = new Map();
11
- constructor(commands) {
12
- for (const command of commands) {
13
- this._commands.set(command.name, command);
14
- for (const alias of command.aliases) {
15
- this._commands.set(alias, command);
16
- }
17
- }
18
- }
19
- async dispatch(rawArgs) {
20
- const action = rawArgs[0];
21
- if (!shared_1.Guards.isDefined(action) ||
22
- action === shared_1.ARGS_CONSTANTS.HELP ||
23
- action === '-h' ||
24
- action === '--h') {
25
- const helpCommand = this._commands.get(shared_1.COMMAND_CONSTANTS.HELP);
26
- await helpCommand?.execute([]);
27
- return;
28
- }
29
- const command = this._commands.get(action);
30
- if (!shared_1.Guards.isDefined(command)) {
31
- console.error(picocolors_1.default.red(`\n❌ '${action}' is not a command`));
32
- console.info(picocolors_1.default.yellow(`See 'xeno-js --help' for cli usage guide or https://www.xeno-js.it for docs.\n`));
33
- process.exit(1);
34
- }
35
- const commandArgs = rawArgs.slice(1);
36
- await command.execute(commandArgs);
37
- }
38
- }
39
- exports.CliDispatcher = CliDispatcher;
@@ -1,17 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./dispatcher"), exports);
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FileUtils = void 0;
4
- const promises_1 = require("fs/promises");
5
- const path_1 = require("path");
6
- class FileUtils {
7
- async writeFileRecursive(filePath, content) {
8
- const dir = (0, path_1.dirname)(filePath);
9
- await (0, promises_1.mkdir)(dir, { recursive: true });
10
- await (0, promises_1.writeFile)(filePath, content, 'utf8');
11
- }
12
- }
13
- exports.FileUtils = FileUtils;
@@ -1,17 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./file.service"), exports);
@@ -1,118 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.BootstrapGenerator = void 0;
7
- const node_path_1 = __importDefault(require("node:path"));
8
- const shared_1 = require("../../shared");
9
- class BootstrapGenerator {
10
- _fileService;
11
- constructor(_fileService) {
12
- this._fileService = _fileService;
13
- }
14
- async generate(projectPath, options) {
15
- // Costruisce in modo flessibile i nodi di configurazione
16
- let builderNodes = `
17
- const builder = new AppBuilder<MyRegistry>()
18
- .addContext()
19
- .addMiddlewares((opts) => {
20
- // Add your options here
21
- })
22
- .addPipeline((opts) => {
23
- // Add your options here
24
- })`;
25
- if (options.database !== shared_1.CORE_CONSTANTS.NONE) {
26
- if (options.database === shared_1.CORE_CONSTANTS.DRIZZLE) {
27
- builderNodes += `
28
- .addDb((opts, config) => {
29
- opts.enableSqlLite = false
30
- opts.connectionString = config.getOrThrow('DATABASE_URL');
31
- })`;
32
- }
33
- else if (options.database === shared_1.CORE_CONSTANTS.SQL_LITE) {
34
- builderNodes += `
35
- .addDb((opts, config) => {
36
- opts.enableSqlLite = true;
37
- opts.connectionString = config.getOrThrow('SQLITE_DATABASE_URL');
38
- })`;
39
- }
40
- }
41
- if (options.redis) {
42
- builderNodes += `
43
- .addCache((opts, config) => {
44
- const isDev = config.get('NODE_ENV') === 'development';
45
- opts.inMemory = isDev;
46
- opts.redis = !isDev ? {
47
- host: config.getOrThrow('REDIS_HOST'),
48
- port: config.getNumber('REDIS_PORT') ?? 6379,
49
- username: config.get('REDIS_USERNAME') ?? '',
50
- password: config.get('REDIS_PASSWORD') ?? '',
51
- tls: config.getBoolean('REDIS_TLS') ?? false,
52
- maxRetriesPerRequest: 3
53
- } : undefined
54
- })`;
55
- }
56
- else {
57
- // Default in-memory cache if no redis selected but CQRS pipeline exists
58
- builderNodes += `
59
- .addCache((opts) => {
60
- opts.inMemory = true;
61
- })`;
62
- }
63
- if (options.supabase) {
64
- builderNodes += `
65
- .addAuth((opts, config) => {
66
- opts.url = config.getOrThrow('SUPABASE_URL');
67
- opts.key = config.getOrThrow('SUPABASE_KEY');
68
- })`;
69
- }
70
- if (options.pino || options.sentry) {
71
- const pinoConfig = options.pino
72
- ? `opts.pino.config = !isDev ? { env: config.getOrThrow('NODE_ENV'), destination: 'stdout', prettyPrint: false } : undefined;`
73
- : '';
74
- const sentryConfig = options.sentry
75
- ? `opts.sentry.config = !isDev ? { dsn: config.getOrThrow('SENTRY_DSN'), environment: config.getOrThrow('NODE_ENV') } : undefined;`
76
- : '';
77
- builderNodes += `
78
- .addLogger((opts, config) => {
79
- const isDev = config.get('NODE_ENV') === 'development';
80
- opts.level = LOG_LEVEL.INFO;
81
- opts.console = isDev;
82
- ${pinoConfig}
83
- ${sentryConfig}
84
- })`;
85
- }
86
- builderNodes += `
87
- .addServices((opts, config) => {
88
- // Register custom repositories and handlers here
89
- });`;
90
- const content = `import type { IServiceContainer } from '@xeno-js/core';
91
- import { AppBuilder, LOG_LEVEL, Nullable, TOKENS } from '@xeno-js/core';
92
- import type { MyRegistry } from './registry';
93
-
94
- let containerPromise: Nullable<Promise<IServiceContainer<MyRegistry>>> = null;
95
-
96
- export async function bootstrap() {
97
- if (!containerPromise) {
98
- containerPromise = (async () => {
99
- const builder = getContainer();
100
- return await builder.build();
101
- })().catch((err) => {
102
- containerPromise = null;
103
- throw err;
104
- });
105
- }
106
- return containerPromise;
107
- }
108
-
109
- function getContainer() {
110
- ${builderNodes}
111
- return builder;
112
- }
113
- `;
114
- const filePath = node_path_1.default.join(projectPath, 'src', 'bootstrap.ts');
115
- await this._fileService.writeFileRecursive(filePath, content);
116
- }
117
- }
118
- exports.BootstrapGenerator = BootstrapGenerator;
@@ -1,118 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.BootstrapGenerator = void 0;
7
- const node_path_1 = __importDefault(require("node:path"));
8
- const shared_1 = require("../../../shared");
9
- class BootstrapGenerator {
10
- _fileService;
11
- constructor(_fileService) {
12
- this._fileService = _fileService;
13
- }
14
- async generate(projectPath, options) {
15
- // Costruisce in modo flessibile i nodi di configurazione
16
- let builderNodes = `
17
- const builder = new AppBuilder<MyRegistry>()
18
- .addContext()
19
- .addMiddlewares((opts) => {
20
- // Add your options here
21
- })
22
- .addPipeline((opts) => {
23
- // Add your options here
24
- })`;
25
- if (options.database !== shared_1.CORE_CONSTANTS.NONE) {
26
- if (options.database === shared_1.CORE_CONSTANTS.DRIZZLE) {
27
- builderNodes += `
28
- .addDb((opts, config) => {
29
- opts.enableSqlLite = false
30
- opts.connectionString = config.getOrThrow('DATABASE_URL');
31
- })`;
32
- }
33
- else if (options.database === shared_1.CORE_CONSTANTS.SQL_LITE) {
34
- builderNodes += `
35
- .addDb((opts, config) => {
36
- opts.enableSqlLite = true;
37
- opts.connectionString = config.getOrThrow('SQLITE_DATABASE_URL');
38
- })`;
39
- }
40
- }
41
- if (options.redis) {
42
- builderNodes += `
43
- .addCache((opts, config) => {
44
- const isDev = config.get('NODE_ENV') === 'development';
45
- opts.inMemory = isDev;
46
- opts.redis = !isDev ? {
47
- host: config.getOrThrow('REDIS_HOST'),
48
- port: config.getNumber('REDIS_PORT') ?? 6379,
49
- username: config.get('REDIS_USERNAME') ?? '',
50
- password: config.get('REDIS_PASSWORD') ?? '',
51
- tls: config.getBoolean('REDIS_TLS') ?? false,
52
- maxRetriesPerRequest: 3
53
- } : undefined
54
- })`;
55
- }
56
- else {
57
- // Default in-memory cache if no redis selected but CQRS pipeline exists
58
- builderNodes += `
59
- .addCache((opts) => {
60
- opts.inMemory = true;
61
- })`;
62
- }
63
- if (options.supabase) {
64
- builderNodes += `
65
- .addAuth((opts, config) => {
66
- opts.url = config.getOrThrow('SUPABASE_URL');
67
- opts.key = config.getOrThrow('SUPABASE_KEY');
68
- })`;
69
- }
70
- if (options.pino || options.sentry) {
71
- const pinoConfig = options.pino
72
- ? `opts.pino.config = !isDev ? { env: config.getOrThrow('NODE_ENV'), destination: 'stdout', prettyPrint: false } : undefined;`
73
- : '';
74
- const sentryConfig = options.sentry
75
- ? `opts.sentry.config = !isDev ? { dsn: config.getOrThrow('SENTRY_DSN'), environment: config.getOrThrow('NODE_ENV') } : undefined;`
76
- : '';
77
- builderNodes += `
78
- .addLogger((opts, config) => {
79
- const isDev = config.get('NODE_ENV') === 'development';
80
- opts.level = LOG_LEVEL.INFO;
81
- opts.console = isDev;
82
- ${pinoConfig}
83
- ${sentryConfig}
84
- })`;
85
- }
86
- builderNodes += `
87
- .addServices((opts, config) => {
88
- // Register custom repositories and handlers here
89
- });`;
90
- const content = `import type { IServiceContainer } from '@xeno-js/core';
91
- import { AppBuilder, LOG_LEVEL, Nullable, TOKENS } from '@xeno-js/core';
92
- import type { MyRegistry } from './registry';
93
-
94
- let containerPromise: Nullable<Promise<IServiceContainer<MyRegistry>>> = null;
95
-
96
- export async function bootstrap() {
97
- if (!containerPromise) {
98
- containerPromise = (async () => {
99
- const builder = getContainer();
100
- return await builder.build();
101
- })().catch((err) => {
102
- containerPromise = null;
103
- throw err;
104
- });
105
- }
106
- return containerPromise;
107
- }
108
-
109
- function getContainer() {
110
- ${builderNodes}
111
- return builder;
112
- }
113
- `;
114
- const filePath = node_path_1.default.join(projectPath, 'src', 'bootstrap.ts');
115
- await this._fileService.writeFileRecursive(filePath, content);
116
- }
117
- }
118
- exports.BootstrapGenerator = BootstrapGenerator;