@expressots/cli 1.7.1 → 1.8.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 (72) hide show
  1. package/README.md +8 -0
  2. package/bin/@types/config.d.ts +39 -39
  3. package/bin/@types/config.js +2 -2
  4. package/bin/@types/index.d.ts +1 -1
  5. package/bin/@types/index.js +17 -17
  6. package/bin/app.container.d.ts +1 -1
  7. package/bin/app.container.js +8 -8
  8. package/bin/cli.d.ts +2 -2
  9. package/bin/cli.js +38 -38
  10. package/bin/commands/__tests__/project.commands.spec.d.ts +1 -0
  11. package/bin/commands/__tests__/project.commands.spec.js +8 -0
  12. package/bin/commands/project.commands.d.ts +8 -8
  13. package/bin/commands/project.commands.js +137 -136
  14. package/bin/generate/cli.d.ts +4 -4
  15. package/bin/generate/cli.js +66 -66
  16. package/bin/generate/form.d.ts +20 -20
  17. package/bin/generate/form.js +30 -30
  18. package/bin/generate/index.d.ts +1 -1
  19. package/bin/generate/index.js +17 -17
  20. package/bin/generate/utils/command-utils.d.ts +123 -123
  21. package/bin/generate/utils/command-utils.js +314 -310
  22. package/bin/generate/utils/nonopininated-cmd.d.ts +9 -9
  23. package/bin/generate/utils/nonopininated-cmd.js +248 -248
  24. package/bin/generate/utils/opinionated-cmd.d.ts +11 -11
  25. package/bin/generate/utils/opinionated-cmd.js +481 -480
  26. package/bin/help/cli.d.ts +4 -4
  27. package/bin/help/cli.js +15 -15
  28. package/bin/help/form.d.ts +2 -2
  29. package/bin/help/form.js +28 -28
  30. package/bin/help/index.d.ts +1 -1
  31. package/bin/help/index.js +17 -2
  32. package/bin/index.d.ts +6 -4
  33. package/bin/index.js +22 -20
  34. package/bin/info/cli.d.ts +4 -4
  35. package/bin/info/cli.js +15 -15
  36. package/bin/info/form.d.ts +2 -2
  37. package/bin/info/form.js +36 -36
  38. package/bin/info/index.d.ts +1 -1
  39. package/bin/info/index.js +17 -17
  40. package/bin/new/cli.d.ts +4 -4
  41. package/bin/new/cli.js +65 -51
  42. package/bin/new/form.d.ts +2 -2
  43. package/bin/new/form.js +238 -213
  44. package/bin/new/index.d.ts +1 -1
  45. package/bin/new/index.js +17 -17
  46. package/bin/providers/cli.d.ts +4 -4
  47. package/bin/providers/cli.js +43 -38
  48. package/bin/providers/external/external.provider.d.ts +2 -0
  49. package/bin/providers/external/external.provider.js +49 -0
  50. package/bin/providers/index.d.ts +1 -1
  51. package/bin/providers/index.js +17 -17
  52. package/bin/providers/prisma/prisma.provider.d.ts +2 -2
  53. package/bin/providers/prisma/prisma.provider.js +272 -270
  54. package/bin/types.d.ts +1 -1
  55. package/bin/types.js +17 -17
  56. package/bin/utils/add-controller-to-module.d.ts +1 -1
  57. package/bin/utils/add-controller-to-module.js +46 -46
  58. package/bin/utils/add-module-to-container.d.ts +3 -3
  59. package/bin/utils/add-module-to-container.js +129 -129
  60. package/bin/utils/center-text.d.ts +2 -2
  61. package/bin/utils/center-text.js +10 -10
  62. package/bin/utils/cli-ui.d.ts +3 -3
  63. package/bin/utils/cli-ui.js +19 -19
  64. package/bin/utils/compiler.d.ts +15 -15
  65. package/bin/utils/compiler.js +93 -93
  66. package/bin/utils/find-folder.d.ts +5 -5
  67. package/bin/utils/find-folder.js +37 -37
  68. package/bin/utils/index.d.ts +1 -1
  69. package/bin/utils/index.js +17 -17
  70. package/bin/utils/verify-file-exists.d.ts +2 -2
  71. package/bin/utils/verify-file-exists.js +30 -30
  72. package/package.json +35 -31
package/README.md CHANGED
@@ -2,6 +2,9 @@
2
2
 
3
3
  <!-- PROJECT SHIELDS -->
4
4
 
5
+ [![Codecov][codecov-shield]][codecov-url]
6
+ [![NPM][npm-shield]][npm-url]
7
+ ![Build][build-shield]
5
8
  [![Contributors][contributors-shield]][contributors-url]
6
9
  [![Forks][forks-shield]][forks-url]
7
10
  [![Stargazers][stars-shield]][stars-url]
@@ -95,6 +98,11 @@ Distributed under the MIT License. See [`LICENSE.txt`](https://github.com/expres
95
98
  <!-- MARKDOWN LINKS & IMAGES -->
96
99
  <!-- https://www.markdownguide.org/basic-syntax/#reference-style-links -->
97
100
 
101
+ [codecov-url]: https://codecov.io/gh/expressots/expressots-cli
102
+ [codecov-shield]: https://img.shields.io/codecov/c/gh/expressots/expressots-cli/main?style=for-the-badge&logo=codecov&labelColor=FB9AD1
103
+ [npm-url]: https://www.npmjs.com/package/@expressots/expressots-cli
104
+ [npm-shield]: https://img.shields.io/npm/v/%40expressots%2Fcli?style=for-the-badge&logo=npm&color=9B3922
105
+ [build-shield]: https://img.shields.io/github/actions/workflow/status/expressots/expressots-cli/build.yml?branch=main&style=for-the-badge&logo=github
98
106
  [contributors-shield]: https://img.shields.io/github/contributors/expressots/expressots-cli?style=for-the-badge
99
107
  [contributors-url]: https://github.com/expressots/expressots-cli/graphs/contributors
100
108
  [forks-shield]: https://img.shields.io/github/forks/expressots/expressots-cli?style=for-the-badge
@@ -1,39 +1,39 @@
1
- export declare const enum Pattern {
2
- LOWER_CASE = "lowercase",
3
- KEBAB_CASE = "kebab-case",
4
- PASCAL_CASE = "PascalCase",
5
- CAMEL_CASE = "camelCase"
6
- }
7
- interface IProviders {
8
- prisma?: {
9
- schemaName: string;
10
- schemaPath: string;
11
- entitiesPath: string;
12
- entityNamePattern: string;
13
- };
14
- }
15
- /**
16
- * The configuration object for the Expresso CLI.
17
- *
18
- * @property {Pattern} scaffoldPattern - The pattern to use when scaffolding files.
19
- * @property {string} sourceRoot - The root directory for the source files.
20
- * @property {boolean} opinionated - Whether or not to use the opinionated configuration.
21
- *
22
- * @see [ExpressoConfig](https://expresso-ts.com/docs)
23
- */
24
- export interface ExpressoConfig {
25
- scaffoldPattern: Pattern;
26
- sourceRoot: string;
27
- opinionated: boolean;
28
- providers?: IProviders;
29
- scaffoldSchematics?: {
30
- entity?: string;
31
- controller?: string;
32
- usecase?: string;
33
- dto?: string;
34
- module?: string;
35
- provider?: string;
36
- middleware?: string;
37
- };
38
- }
39
- export {};
1
+ export declare const enum Pattern {
2
+ LOWER_CASE = "lowercase",
3
+ KEBAB_CASE = "kebab-case",
4
+ PASCAL_CASE = "PascalCase",
5
+ CAMEL_CASE = "camelCase"
6
+ }
7
+ interface IProviders {
8
+ prisma?: {
9
+ schemaName: string;
10
+ schemaPath: string;
11
+ entitiesPath: string;
12
+ entityNamePattern: string;
13
+ };
14
+ }
15
+ /**
16
+ * The configuration object for the Expresso CLI.
17
+ *
18
+ * @property {Pattern} scaffoldPattern - The pattern to use when scaffolding files.
19
+ * @property {string} sourceRoot - The root directory for the source files.
20
+ * @property {boolean} opinionated - Whether or not to use the opinionated configuration.
21
+ *
22
+ * @see [ExpressoConfig](https://expresso-ts.com/docs)
23
+ */
24
+ export interface ExpressoConfig {
25
+ scaffoldPattern: Pattern;
26
+ sourceRoot: string;
27
+ opinionated: boolean;
28
+ providers?: IProviders;
29
+ scaffoldSchematics?: {
30
+ entity?: string;
31
+ controller?: string;
32
+ usecase?: string;
33
+ dto?: string;
34
+ module?: string;
35
+ provider?: string;
36
+ middleware?: string;
37
+ };
38
+ }
39
+ export {};
@@ -1,2 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1 +1 @@
1
- export * from "./config";
1
+ export * from "./config";
@@ -1,17 +1,17 @@
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("./config"), exports);
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("./config"), exports);
@@ -1 +1 @@
1
- export {};
1
+ export {};
@@ -1,8 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- /* import { AppContainer } from "@expressots/core";
4
-
5
- export const appContainer = new AppContainer();
6
-
7
- export const container = appContainer.create([]);
8
- */
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /* import { AppContainer } from "@expressots/core";
4
+
5
+ export const appContainer = new AppContainer();
6
+
7
+ export const container = appContainer.create([]);
8
+ */
package/bin/cli.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- #!/usr/bin/env node
2
- export {};
1
+ #!/usr/bin/env node
2
+ export {};
package/bin/cli.js CHANGED
@@ -1,38 +1,38 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
- var __importDefault = (this && this.__importDefault) || function (mod) {
4
- return (mod && mod.__esModule) ? mod : { "default": mod };
5
- };
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- const yargs_1 = __importDefault(require("yargs"));
8
- const helpers_1 = require("yargs/helpers");
9
- const project_commands_1 = require("./commands/project.commands");
10
- const generate_1 = require("./generate");
11
- const cli_1 = require("./help/cli");
12
- const info_1 = require("./info");
13
- const new_1 = require("./new");
14
- const providers_1 = require("./providers");
15
- console.log(`\n[🐎 Expressots]\n`);
16
- (0, yargs_1.default)((0, helpers_1.hideBin)(process.argv))
17
- .scriptName("expressots")
18
- .command(project_commands_1.runCommandModule)
19
- .command((0, new_1.createProject)())
20
- .command((0, providers_1.generateProviders)())
21
- .command((0, generate_1.generateProject)())
22
- .command((0, info_1.infoProject)())
23
- .command((0, cli_1.helpCommand)())
24
- .example("$0 new expressots-demo", "Create interactively")
25
- .example("$0 new expressots-demo -d ./", "Create interactively with path")
26
- .example("$0 new expressots-demo -p yarn -t opinionated", "Create silently")
27
- .example("$0 new expressots-demo -p yarn -t opinionated -d ./", "Create silently with path")
28
- .example("$0 generate service user-create", "Scaffold a service")
29
- .example("$0 info", "Show CLI details")
30
- .demandCommand(1, "You need at least one command before moving on")
31
- .epilog("For more information: \n" +
32
- "🌐 visit:\t https://expresso-ts.com\n" +
33
- "💖 Sponsor:\t https://github.com/sponsors/expressots")
34
- .help("help", "Show command help")
35
- .alias("h", "help")
36
- .version(false)
37
- .wrap(140)
38
- .parse();
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ const yargs_1 = __importDefault(require("yargs"));
8
+ const helpers_1 = require("yargs/helpers");
9
+ const project_commands_1 = require("./commands/project.commands");
10
+ const generate_1 = require("./generate");
11
+ const cli_1 = require("./help/cli");
12
+ const info_1 = require("./info");
13
+ const new_1 = require("./new");
14
+ const providers_1 = require("./providers");
15
+ console.log(`\n[🐎 Expressots]\n`);
16
+ (0, yargs_1.default)((0, helpers_1.hideBin)(process.argv))
17
+ .scriptName("expressots")
18
+ .command(project_commands_1.runCommandModule)
19
+ .command((0, new_1.createProject)())
20
+ .command((0, providers_1.generateProviders)())
21
+ .command((0, generate_1.generateProject)())
22
+ .command((0, info_1.infoProject)())
23
+ .command((0, cli_1.helpCommand)())
24
+ .example("$0 new expressots-demo", "Create interactively")
25
+ .example("$0 new expressots-demo -d ./", "Create interactively with path")
26
+ .example("$0 new expressots-demo -p yarn -t opinionated", "Create silently")
27
+ .example("$0 new expressots-demo -p yarn -t opinionated -d ./", "Create silently with path")
28
+ .example("$0 generate service user-create", "Scaffold a service")
29
+ .example("$0 info", "Show CLI details")
30
+ .demandCommand(1, "You need at least one command before moving on")
31
+ .epilog("For more information: \n" +
32
+ "🌐 visit:\t https://expresso-ts.com\n" +
33
+ "💖 Sponsor:\t https://github.com/sponsors/expressots")
34
+ .help("help", "Show command help")
35
+ .alias("h", "help")
36
+ .version(false)
37
+ .wrap(140)
38
+ .parse();
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const vitest_1 = require("vitest");
4
+ (0, vitest_1.describe)("project.commands", () => {
5
+ (0, vitest_1.it)("should return a list of commands", () => {
6
+ (0, vitest_1.expect)(true).toBe(true);
7
+ });
8
+ });
@@ -1,8 +1,8 @@
1
- import { CommandModule } from "yargs";
2
- export declare const runCommandModule: CommandModule<{}, {
3
- command: string;
4
- }>;
5
- declare const runCommand: ({ command }: {
6
- command: string;
7
- }) => Promise<void>;
8
- export { runCommand };
1
+ import { CommandModule } from "yargs";
2
+ export declare const runCommandModule: CommandModule<{}, {
3
+ command: string;
4
+ }>;
5
+ declare const runCommand: ({ command }: {
6
+ command: string;
7
+ }) => Promise<void>;
8
+ export { runCommand };
@@ -1,136 +1,137 @@
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.runCommand = exports.runCommandModule = void 0;
7
- const child_process_1 = require("child_process");
8
- const fs_1 = require("fs");
9
- const path_1 = __importDefault(require("path"));
10
- const compiler_1 = __importDefault(require("../utils/compiler"));
11
- /**
12
- * Load the configuration from the compiler
13
- * @param compiler The compiler to load the configuration from
14
- * @returns The configuration
15
- */
16
- const opinionatedConfig = [
17
- "--transpile-only",
18
- "-r",
19
- "dotenv/config",
20
- "-r",
21
- "tsconfig-paths/register",
22
- "./src/main.ts",
23
- ];
24
- const nonOpinionatedConfig = [
25
- "--transpile-only",
26
- "-r",
27
- "dotenv/config",
28
- "./src/main.ts",
29
- ];
30
- /**
31
- * Helper function to execute a command
32
- * @param command The command to execute
33
- * @param args The arguments to pass to the command
34
- * @param cwd The current working directory to execute the command in
35
- * @returns A promise that resolves when the command completes successfully
36
- */
37
- function execCmd(command, args, cwd = process.cwd()) {
38
- return new Promise((resolve, reject) => {
39
- const proc = (0, child_process_1.spawn)(command, args, {
40
- stdio: "inherit",
41
- shell: true,
42
- cwd,
43
- });
44
- proc.on("close", (code) => {
45
- if (code === 0) {
46
- resolve();
47
- }
48
- else {
49
- reject(new Error(`Command failed with code ${code}`));
50
- }
51
- });
52
- });
53
- }
54
- // Helper to delete the dist directory
55
- const cleanDist = async () => {
56
- await fs_1.promises.rm("./dist", { recursive: true, force: true });
57
- };
58
- // Helper to compile TypeScript
59
- const compileTypescript = async () => {
60
- await execCmd("npx", ["tsc", "-p", "tsconfig.build.json"]);
61
- };
62
- // Helper to copy files
63
- const copyFiles = async () => {
64
- const { opinionated } = await compiler_1.default.loadConfig();
65
- let filesToCopy = [];
66
- if (opinionated) {
67
- filesToCopy = [
68
- "./register-path.js",
69
- "tsconfig.build.json",
70
- "package.json",
71
- ];
72
- }
73
- else {
74
- filesToCopy = ["tsconfig.json", "package.json"];
75
- }
76
- filesToCopy.forEach((file) => {
77
- fs_1.promises.copyFile(file, path_1.default.join("./dist", path_1.default.basename(file)));
78
- });
79
- };
80
- // eslint-disable-next-line @typescript-eslint/ban-types
81
- exports.runCommandModule = {
82
- command: "run <command>",
83
- describe: "Runs a specified command (dev, build, prod)",
84
- builder: (yargs) => {
85
- return yargs.positional("command", {
86
- describe: "The command to run",
87
- type: "string",
88
- choices: ["dev", "build", "prod"],
89
- });
90
- },
91
- handler: async (argv) => {
92
- const { command } = argv;
93
- // Now call your original runCommand function with the command
94
- // Ensure runCommand is properly defined to handle these commands
95
- await runCommand({ command });
96
- },
97
- };
98
- const runCommand = async ({ command }) => {
99
- const { opinionated } = await compiler_1.default.loadConfig();
100
- try {
101
- switch (command) {
102
- case "dev":
103
- // Use execSync or spawn to run ts-node-dev programmatically
104
- execCmd("tsnd", opinionated ? opinionatedConfig : nonOpinionatedConfig);
105
- break;
106
- case "build":
107
- await cleanDist();
108
- await compileTypescript();
109
- await copyFiles();
110
- break;
111
- case "prod":
112
- let config = [];
113
- if (opinionated) {
114
- config = [
115
- "-r",
116
- "dotenv/config",
117
- "-r",
118
- "./dist/register-path.js",
119
- "./dist/src/main.js",
120
- ];
121
- }
122
- else {
123
- config = ["-r", "dotenv/config", "./dist/main.js"];
124
- }
125
- // Ensure environment variables are set
126
- execCmd("node", config);
127
- break;
128
- default:
129
- console.log(`Unknown command: ${command}`);
130
- }
131
- }
132
- catch (error) {
133
- console.error("Error executing command:", error);
134
- }
135
- };
136
- exports.runCommand = runCommand;
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.runCommand = exports.runCommandModule = void 0;
7
+ const child_process_1 = require("child_process");
8
+ const fs_1 = require("fs");
9
+ const path_1 = __importDefault(require("path"));
10
+ const compiler_1 = __importDefault(require("../utils/compiler"));
11
+ /**
12
+ * Load the configuration from the compiler
13
+ * @param compiler The compiler to load the configuration from
14
+ * @returns The configuration
15
+ */
16
+ const opinionatedConfig = [
17
+ "--transpile-only",
18
+ "-r",
19
+ "dotenv/config",
20
+ "-r",
21
+ "tsconfig-paths/register",
22
+ "./src/main.ts",
23
+ ];
24
+ const nonOpinionatedConfig = [
25
+ "--transpile-only",
26
+ "-r",
27
+ "dotenv/config",
28
+ "./src/main.ts",
29
+ ];
30
+ /**
31
+ * Helper function to execute a command
32
+ * @param command The command to execute
33
+ * @param args The arguments to pass to the command
34
+ * @param cwd The current working directory to execute the command in
35
+ * @returns A promise that resolves when the command completes successfully
36
+ */
37
+ function execCmd(command, args, cwd = process.cwd()) {
38
+ return new Promise((resolve, reject) => {
39
+ const proc = (0, child_process_1.spawn)(command, args, {
40
+ stdio: "inherit",
41
+ shell: true,
42
+ cwd,
43
+ });
44
+ proc.on("close", (code) => {
45
+ if (code === 0) {
46
+ resolve();
47
+ }
48
+ else {
49
+ reject(new Error(`Command failed with code ${code}`));
50
+ }
51
+ });
52
+ });
53
+ }
54
+ // Helper to delete the dist directory
55
+ const cleanDist = async () => {
56
+ await fs_1.promises.rm("./dist", { recursive: true, force: true });
57
+ };
58
+ // Helper to compile TypeScript
59
+ const compileTypescript = async () => {
60
+ await execCmd("npx", ["tsc", "-p", "tsconfig.build.json"]);
61
+ };
62
+ // Helper to copy files
63
+ const copyFiles = async () => {
64
+ const { opinionated } = await compiler_1.default.loadConfig();
65
+ let filesToCopy = [];
66
+ if (opinionated) {
67
+ filesToCopy = [
68
+ "./register-path.js",
69
+ "tsconfig.build.json",
70
+ "package.json",
71
+ ];
72
+ }
73
+ else {
74
+ filesToCopy = ["tsconfig.json", "package.json"];
75
+ }
76
+ filesToCopy.forEach((file) => {
77
+ fs_1.promises.copyFile(file, path_1.default.join("./dist", path_1.default.basename(file)));
78
+ });
79
+ };
80
+ // eslint-disable-next-line @typescript-eslint/ban-types
81
+ exports.runCommandModule = {
82
+ command: "run <command>",
83
+ describe: "Runs a specified command (dev, build, prod)",
84
+ builder: (yargs) => {
85
+ return yargs.positional("command", {
86
+ describe: "The command to run",
87
+ type: "string",
88
+ choices: ["dev", "build", "prod"],
89
+ });
90
+ },
91
+ handler: async (argv) => {
92
+ const { command } = argv;
93
+ // Now call your original runCommand function with the command
94
+ // Ensure runCommand is properly defined to handle these commands
95
+ await runCommand({ command });
96
+ },
97
+ };
98
+ const runCommand = async ({ command }) => {
99
+ const { opinionated } = await compiler_1.default.loadConfig();
100
+ try {
101
+ switch (command) {
102
+ case "dev":
103
+ // Use execSync or spawn to run ts-node-dev programmatically
104
+ execCmd("tsnd", opinionated ? opinionatedConfig : nonOpinionatedConfig);
105
+ break;
106
+ case "build":
107
+ await cleanDist();
108
+ await compileTypescript();
109
+ await copyFiles();
110
+ break;
111
+ case "prod": {
112
+ let config = [];
113
+ if (opinionated) {
114
+ config = [
115
+ "-r",
116
+ "dotenv/config",
117
+ "-r",
118
+ "./dist/register-path.js",
119
+ "./dist/src/main.js",
120
+ ];
121
+ }
122
+ else {
123
+ config = ["-r", "dotenv/config", "./dist/main.js"];
124
+ }
125
+ // Ensure environment variables are set
126
+ execCmd("node", config);
127
+ break;
128
+ }
129
+ default:
130
+ console.log(`Unknown command: ${command}`);
131
+ }
132
+ }
133
+ catch (error) {
134
+ console.error("Error executing command:", error);
135
+ }
136
+ };
137
+ exports.runCommand = runCommand;
@@ -1,4 +1,4 @@
1
- import { CommandModule } from "yargs";
2
- type CommandModuleArgs = {};
3
- declare const generateProject: () => CommandModule<CommandModuleArgs, any>;
4
- export { generateProject };
1
+ import { CommandModule } from "yargs";
2
+ type CommandModuleArgs = {};
3
+ declare const generateProject: () => CommandModule<CommandModuleArgs, any>;
4
+ export { generateProject };