@expressots/cli 1.7.0 → 1.8.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.
Files changed (74) 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/templates/nonopinionated/controller.tpl +2 -8
  21. package/bin/generate/templates/nonopinionated/usecase.tpl +1 -5
  22. package/bin/generate/utils/command-utils.d.ts +123 -123
  23. package/bin/generate/utils/command-utils.js +314 -310
  24. package/bin/generate/utils/nonopininated-cmd.d.ts +9 -9
  25. package/bin/generate/utils/nonopininated-cmd.js +248 -248
  26. package/bin/generate/utils/opinionated-cmd.d.ts +11 -11
  27. package/bin/generate/utils/opinionated-cmd.js +481 -480
  28. package/bin/help/cli.d.ts +4 -4
  29. package/bin/help/cli.js +15 -15
  30. package/bin/help/form.d.ts +2 -2
  31. package/bin/help/form.js +28 -28
  32. package/bin/help/index.d.ts +1 -1
  33. package/bin/help/index.js +17 -2
  34. package/bin/index.d.ts +6 -4
  35. package/bin/index.js +22 -20
  36. package/bin/info/cli.d.ts +4 -4
  37. package/bin/info/cli.js +15 -15
  38. package/bin/info/form.d.ts +2 -2
  39. package/bin/info/form.js +36 -36
  40. package/bin/info/index.d.ts +1 -1
  41. package/bin/info/index.js +17 -17
  42. package/bin/new/cli.d.ts +4 -4
  43. package/bin/new/cli.js +51 -51
  44. package/bin/new/form.d.ts +2 -2
  45. package/bin/new/form.js +235 -213
  46. package/bin/new/index.d.ts +1 -1
  47. package/bin/new/index.js +17 -17
  48. package/bin/providers/cli.d.ts +4 -4
  49. package/bin/providers/cli.js +43 -38
  50. package/bin/providers/external/external.provider.d.ts +2 -0
  51. package/bin/providers/external/external.provider.js +49 -0
  52. package/bin/providers/index.d.ts +1 -1
  53. package/bin/providers/index.js +17 -17
  54. package/bin/providers/prisma/prisma.provider.d.ts +2 -2
  55. package/bin/providers/prisma/prisma.provider.js +272 -270
  56. package/bin/types.d.ts +1 -1
  57. package/bin/types.js +17 -17
  58. package/bin/utils/add-controller-to-module.d.ts +1 -1
  59. package/bin/utils/add-controller-to-module.js +46 -46
  60. package/bin/utils/add-module-to-container.d.ts +3 -3
  61. package/bin/utils/add-module-to-container.js +129 -129
  62. package/bin/utils/center-text.d.ts +2 -2
  63. package/bin/utils/center-text.js +10 -10
  64. package/bin/utils/cli-ui.d.ts +3 -3
  65. package/bin/utils/cli-ui.js +19 -19
  66. package/bin/utils/compiler.d.ts +15 -15
  67. package/bin/utils/compiler.js +93 -93
  68. package/bin/utils/find-folder.d.ts +5 -5
  69. package/bin/utils/find-folder.js +37 -37
  70. package/bin/utils/index.d.ts +1 -1
  71. package/bin/utils/index.js +17 -17
  72. package/bin/utils/verify-file-exists.d.ts +2 -2
  73. package/bin/utils/verify-file-exists.js +30 -30
  74. package/package.json +32 -28
@@ -1,46 +1,46 @@
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.addControllerToModule = void 0;
7
- const node_fs_1 = __importDefault(require("node:fs"));
8
- async function addControllerToModule(filePath, controllerName, controllerPath) {
9
- const fileContent = await node_fs_1.default.promises.readFile(filePath, "utf8");
10
- const imports = [];
11
- const notImports = [];
12
- fileContent.split("\n").forEach((line) => {
13
- if (line.startsWith("import")) {
14
- imports.push(line);
15
- }
16
- else {
17
- notImports.push(line);
18
- }
19
- });
20
- const newImport = `import { ${controllerName} } from "${controllerPath}";`;
21
- if (imports.includes(newImport)) {
22
- return;
23
- }
24
- imports.push(newImport);
25
- const moduleDeclarationRegex = /CreateModule\(\s*\[([\s\S]*?)]/;
26
- const moduleDeclarationMatch = fileContent.match(moduleDeclarationRegex);
27
- if (!moduleDeclarationMatch) {
28
- return;
29
- }
30
- const controllers = moduleDeclarationMatch[1]
31
- .trim()
32
- .split(",")
33
- .map((c) => c.trim())
34
- .filter((c) => c);
35
- if (controllers.includes(controllerName)) {
36
- return;
37
- }
38
- controllers.push(controllerName);
39
- const newControllers = controllers.join(", ");
40
- const newModuleDeclaration = `CreateModule([${newControllers}]`;
41
- const newFileContent = [...imports, ...notImports]
42
- .join("\n")
43
- .replace(moduleDeclarationRegex, newModuleDeclaration);
44
- await node_fs_1.default.promises.writeFile(filePath, newFileContent, "utf8");
45
- }
46
- exports.addControllerToModule = addControllerToModule;
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.addControllerToModule = void 0;
7
+ const node_fs_1 = __importDefault(require("node:fs"));
8
+ async function addControllerToModule(filePath, controllerName, controllerPath) {
9
+ const fileContent = await node_fs_1.default.promises.readFile(filePath, "utf8");
10
+ const imports = [];
11
+ const notImports = [];
12
+ fileContent.split("\n").forEach((line) => {
13
+ if (line.startsWith("import")) {
14
+ imports.push(line);
15
+ }
16
+ else {
17
+ notImports.push(line);
18
+ }
19
+ });
20
+ const newImport = `import { ${controllerName} } from "${controllerPath}";`;
21
+ if (imports.includes(newImport)) {
22
+ return;
23
+ }
24
+ imports.push(newImport);
25
+ const moduleDeclarationRegex = /CreateModule\(\s*\[([\s\S]*?)]/;
26
+ const moduleDeclarationMatch = fileContent.match(moduleDeclarationRegex);
27
+ if (!moduleDeclarationMatch) {
28
+ return;
29
+ }
30
+ const controllers = moduleDeclarationMatch[1]
31
+ .trim()
32
+ .split(",")
33
+ .map((c) => c.trim())
34
+ .filter((c) => c);
35
+ if (controllers.includes(controllerName)) {
36
+ return;
37
+ }
38
+ controllers.push(controllerName);
39
+ const newControllers = controllers.join(", ");
40
+ const newModuleDeclaration = `CreateModule([${newControllers}]`;
41
+ const newFileContent = [...imports, ...notImports]
42
+ .join("\n")
43
+ .replace(moduleDeclarationRegex, newModuleDeclaration);
44
+ await node_fs_1.default.promises.writeFile(filePath, newFileContent, "utf8");
45
+ }
46
+ exports.addControllerToModule = addControllerToModule;
@@ -1,3 +1,3 @@
1
- declare function addModuleToContainer(name: string, modulePath?: string, path?: string): Promise<void>;
2
- declare function addModuleToContainerNestedPath(name: string, path?: string): Promise<void>;
3
- export { addModuleToContainer, addModuleToContainerNestedPath };
1
+ declare function addModuleToContainer(name: string, modulePath?: string, path?: string): Promise<void>;
2
+ declare function addModuleToContainerNestedPath(name: string, path?: string): Promise<void>;
3
+ export { addModuleToContainer, addModuleToContainerNestedPath };
@@ -1,129 +1,129 @@
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.addModuleToContainerNestedPath = exports.addModuleToContainer = void 0;
7
- const chalk_1 = __importDefault(require("chalk"));
8
- const glob_1 = require("glob");
9
- const node_fs_1 = __importDefault(require("node:fs"));
10
- const cli_ui_1 = require("./cli-ui");
11
- const compiler_1 = __importDefault(require("./compiler"));
12
- const APP_CONTAINER = "app.container.ts";
13
- async function validateAppContainer() {
14
- const { sourceRoot } = await compiler_1.default.loadConfig();
15
- const imports = [];
16
- const notImports = [];
17
- const path = (0, glob_1.globSync)(`./${sourceRoot}/${APP_CONTAINER}`, {
18
- absolute: true,
19
- ignore: "**/node_modules/**",
20
- });
21
- if (!path.length) {
22
- (0, cli_ui_1.printError)("Module not added to Container. Container file not found!", APP_CONTAINER);
23
- process.exit(1);
24
- }
25
- const fileContent = await node_fs_1.default.promises.readFile(path[0], "utf8");
26
- fileContent.split("\n").forEach((line) => {
27
- if (line.startsWith("import")) {
28
- imports.push(line);
29
- }
30
- else {
31
- notImports.push(line);
32
- }
33
- });
34
- // Validate the file content
35
- const moduleDeclarationRegex = /.create\(\s*\[([\s\S]*?)]/;
36
- const moduleDeclarationMatch = fileContent.match(moduleDeclarationRegex);
37
- if (!moduleDeclarationMatch) {
38
- (0, cli_ui_1.printError)("Container format incorrect!", APP_CONTAINER);
39
- process.exit(1);
40
- }
41
- const modules = moduleDeclarationMatch[1]
42
- .trim()
43
- .split(",")
44
- .filter((m) => m.trim() !== "")
45
- .map((m) => m.trim());
46
- return {
47
- regex: moduleDeclarationRegex,
48
- path: path[0],
49
- content: moduleDeclarationMatch,
50
- modules,
51
- imports,
52
- notImports,
53
- };
54
- }
55
- async function addModuleToContainer(name, modulePath, path) {
56
- const containerData = await validateAppContainer();
57
- const moduleName = (name[0].toUpperCase() + name.slice(1)).trimStart();
58
- const { opinionated } = await compiler_1.default.loadConfig();
59
- let usecaseDir;
60
- if (opinionated) {
61
- usecaseDir = `@useCases/`;
62
- }
63
- else {
64
- usecaseDir = `./`;
65
- }
66
- let newImport = "";
67
- const modulePathRegex = /^[^/]=$/;
68
- if (!modulePathRegex.test(modulePath)) {
69
- if (path.split("/").length > 1) {
70
- newImport = `import { ${moduleName}Module } from "${usecaseDir}${name.toLowerCase()}/${name.toLowerCase()}.module";`;
71
- }
72
- else {
73
- newImport = `import { ${moduleName}Module } from "${usecaseDir}${name.toLowerCase()}.module";`;
74
- }
75
- }
76
- else {
77
- newImport = `import { ${moduleName}Module } from "${usecaseDir}${name}/${name.toLowerCase()}.module";`;
78
- }
79
- if (containerData.imports.includes(newImport) &&
80
- containerData.modules.includes(`${moduleName}Module`)) {
81
- return;
82
- }
83
- containerData.imports.push(newImport);
84
- containerData.modules.push(`${moduleName}Module`);
85
- const newModule = containerData.modules.join(", ");
86
- const newModuleDeclaration = `.create([${newModule}]`;
87
- const newFileContent = [
88
- ...containerData.imports,
89
- ...containerData.notImports,
90
- ]
91
- .join("\n")
92
- .replace(containerData.regex, newModuleDeclaration);
93
- console.log(" ", chalk_1.default.greenBright(`[container]`.padEnd(14)), chalk_1.default.bold.white(`${moduleName}Module added to ${APP_CONTAINER}! ✔️`));
94
- await node_fs_1.default.promises.writeFile(containerData.path, newFileContent, "utf8");
95
- }
96
- exports.addModuleToContainer = addModuleToContainer;
97
- async function addModuleToContainerNestedPath(name, path) {
98
- const containerData = await validateAppContainer();
99
- const moduleName = (name[0].toUpperCase() + name.slice(1)).trimStart();
100
- const { opinionated } = await compiler_1.default.loadConfig();
101
- let usecaseDir;
102
- if (opinionated) {
103
- usecaseDir = `@useCases/`;
104
- }
105
- else {
106
- usecaseDir = `./`;
107
- }
108
- if (path.endsWith("/")) {
109
- path = path.slice(0, -1);
110
- }
111
- const newImport = `import { ${moduleName}Module } from "${usecaseDir}${path}.module";`;
112
- if (containerData.imports.includes(newImport) &&
113
- containerData.modules.includes(`${moduleName}Module`)) {
114
- return;
115
- }
116
- containerData.imports.push(newImport);
117
- containerData.modules.push(`${moduleName}Module`);
118
- const newModule = containerData.modules.join(", ");
119
- const newModuleDeclaration = `.create([${newModule}]`;
120
- const newFileContent = [
121
- ...containerData.imports,
122
- ...containerData.notImports,
123
- ]
124
- .join("\n")
125
- .replace(containerData.regex, newModuleDeclaration);
126
- console.log(" ", chalk_1.default.greenBright(`[container]`.padEnd(14)), chalk_1.default.bold.white(`${moduleName}Module added to ${APP_CONTAINER}! ✔️`));
127
- await node_fs_1.default.promises.writeFile(containerData.path, newFileContent, "utf8");
128
- }
129
- exports.addModuleToContainerNestedPath = addModuleToContainerNestedPath;
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.addModuleToContainerNestedPath = exports.addModuleToContainer = void 0;
7
+ const chalk_1 = __importDefault(require("chalk"));
8
+ const glob_1 = require("glob");
9
+ const node_fs_1 = __importDefault(require("node:fs"));
10
+ const cli_ui_1 = require("./cli-ui");
11
+ const compiler_1 = __importDefault(require("./compiler"));
12
+ const APP_CONTAINER = "app.container.ts";
13
+ async function validateAppContainer() {
14
+ const { sourceRoot } = await compiler_1.default.loadConfig();
15
+ const imports = [];
16
+ const notImports = [];
17
+ const path = (0, glob_1.globSync)(`./${sourceRoot}/${APP_CONTAINER}`, {
18
+ absolute: true,
19
+ ignore: "**/node_modules/**",
20
+ });
21
+ if (!path.length) {
22
+ (0, cli_ui_1.printError)("Module not added to Container. Container file not found!", APP_CONTAINER);
23
+ process.exit(1);
24
+ }
25
+ const fileContent = await node_fs_1.default.promises.readFile(path[0], "utf8");
26
+ fileContent.split("\n").forEach((line) => {
27
+ if (line.startsWith("import")) {
28
+ imports.push(line);
29
+ }
30
+ else {
31
+ notImports.push(line);
32
+ }
33
+ });
34
+ // Validate the file content
35
+ const moduleDeclarationRegex = /.create\(\s*\[([\s\S]*?)]/;
36
+ const moduleDeclarationMatch = fileContent.match(moduleDeclarationRegex);
37
+ if (!moduleDeclarationMatch) {
38
+ (0, cli_ui_1.printError)("Container format incorrect!", APP_CONTAINER);
39
+ process.exit(1);
40
+ }
41
+ const modules = moduleDeclarationMatch[1]
42
+ .trim()
43
+ .split(",")
44
+ .filter((m) => m.trim() !== "")
45
+ .map((m) => m.trim());
46
+ return {
47
+ regex: moduleDeclarationRegex,
48
+ path: path[0],
49
+ content: moduleDeclarationMatch,
50
+ modules,
51
+ imports,
52
+ notImports,
53
+ };
54
+ }
55
+ async function addModuleToContainer(name, modulePath, path) {
56
+ const containerData = await validateAppContainer();
57
+ const moduleName = (name[0].toUpperCase() + name.slice(1)).trimStart();
58
+ const { opinionated } = await compiler_1.default.loadConfig();
59
+ let usecaseDir;
60
+ if (opinionated) {
61
+ usecaseDir = `@useCases/`;
62
+ }
63
+ else {
64
+ usecaseDir = `./`;
65
+ }
66
+ let newImport = "";
67
+ const modulePathRegex = /^[^/]=$/;
68
+ if (!modulePathRegex.test(modulePath)) {
69
+ if (path.split("/").length > 1) {
70
+ newImport = `import { ${moduleName}Module } from "${usecaseDir}${name.toLowerCase()}/${name.toLowerCase()}.module";`;
71
+ }
72
+ else {
73
+ newImport = `import { ${moduleName}Module } from "${usecaseDir}${name.toLowerCase()}.module";`;
74
+ }
75
+ }
76
+ else {
77
+ newImport = `import { ${moduleName}Module } from "${usecaseDir}${name}/${name.toLowerCase()}.module";`;
78
+ }
79
+ if (containerData.imports.includes(newImport) &&
80
+ containerData.modules.includes(`${moduleName}Module`)) {
81
+ return;
82
+ }
83
+ containerData.imports.push(newImport);
84
+ containerData.modules.push(`${moduleName}Module`);
85
+ const newModule = containerData.modules.join(", ");
86
+ const newModuleDeclaration = `.create([${newModule}]`;
87
+ const newFileContent = [
88
+ ...containerData.imports,
89
+ ...containerData.notImports,
90
+ ]
91
+ .join("\n")
92
+ .replace(containerData.regex, newModuleDeclaration);
93
+ console.log(" ", chalk_1.default.greenBright(`[container]`.padEnd(14)), chalk_1.default.bold.white(`${moduleName}Module added to ${APP_CONTAINER}! ✔️`));
94
+ await node_fs_1.default.promises.writeFile(containerData.path, newFileContent, "utf8");
95
+ }
96
+ exports.addModuleToContainer = addModuleToContainer;
97
+ async function addModuleToContainerNestedPath(name, path) {
98
+ const containerData = await validateAppContainer();
99
+ const moduleName = (name[0].toUpperCase() + name.slice(1)).trimStart();
100
+ const { opinionated } = await compiler_1.default.loadConfig();
101
+ let usecaseDir;
102
+ if (opinionated) {
103
+ usecaseDir = `@useCases/`;
104
+ }
105
+ else {
106
+ usecaseDir = `./`;
107
+ }
108
+ if (path.endsWith("/")) {
109
+ path = path.slice(0, -1);
110
+ }
111
+ const newImport = `import { ${moduleName}Module } from "${usecaseDir}${path}.module";`;
112
+ if (containerData.imports.includes(newImport) &&
113
+ containerData.modules.includes(`${moduleName}Module`)) {
114
+ return;
115
+ }
116
+ containerData.imports.push(newImport);
117
+ containerData.modules.push(`${moduleName}Module`);
118
+ const newModule = containerData.modules.join(", ");
119
+ const newModuleDeclaration = `.create([${newModule}]`;
120
+ const newFileContent = [
121
+ ...containerData.imports,
122
+ ...containerData.notImports,
123
+ ]
124
+ .join("\n")
125
+ .replace(containerData.regex, newModuleDeclaration);
126
+ console.log(" ", chalk_1.default.greenBright(`[container]`.padEnd(14)), chalk_1.default.bold.white(`${moduleName}Module added to ${APP_CONTAINER}! ✔️`));
127
+ await node_fs_1.default.promises.writeFile(containerData.path, newFileContent, "utf8");
128
+ }
129
+ exports.addModuleToContainerNestedPath = addModuleToContainerNestedPath;
@@ -1,2 +1,2 @@
1
- declare function centerText(text: string): string;
2
- export { centerText };
1
+ declare function centerText(text: string): string;
2
+ export { centerText };
@@ -1,10 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.centerText = void 0;
4
- function centerText(text) {
5
- const terminalWidth = process.stdout.columns;
6
- const padding = Math.floor((terminalWidth - text.length) / 2);
7
- const centeredText = " ".repeat(padding) + text;
8
- return centeredText;
9
- }
10
- exports.centerText = centerText;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.centerText = void 0;
4
+ function centerText(text) {
5
+ const terminalWidth = process.stdout.columns;
6
+ const padding = Math.floor((terminalWidth - text.length) / 2);
7
+ const centeredText = " ".repeat(padding) + text;
8
+ return centeredText;
9
+ }
10
+ exports.centerText = centerText;
@@ -1,3 +1,3 @@
1
- export declare function printError(message: string, component: string): void;
2
- export declare function printGenerateError(schematic: string, file: string): Promise<void>;
3
- export declare function printGenerateSuccess(schematic: string, file: string): Promise<void>;
1
+ export declare function printError(message: string, component: string): void;
2
+ export declare function printGenerateError(schematic: string, file: string): Promise<void>;
3
+ export declare function printGenerateSuccess(schematic: string, file: string): Promise<void>;
@@ -1,19 +1,19 @@
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.printGenerateSuccess = exports.printGenerateError = exports.printError = void 0;
7
- const chalk_1 = __importDefault(require("chalk"));
8
- function printError(message, component) {
9
- console.error(chalk_1.default.red(`${message}:`, chalk_1.default.bold(chalk_1.default.white(`[${component}] ❌`))));
10
- }
11
- exports.printError = printError;
12
- async function printGenerateError(schematic, file) {
13
- console.error(" ", chalk_1.default.redBright(`[${schematic}]`.padEnd(14)), chalk_1.default.bold.white(`${file.split(".")[0]} not created! ❌`));
14
- }
15
- exports.printGenerateError = printGenerateError;
16
- async function printGenerateSuccess(schematic, file) {
17
- console.log(" ", chalk_1.default.greenBright(`[${schematic}]`.padEnd(14)), chalk_1.default.bold.white(`${file.split(".")[0]} created! ✔️`));
18
- }
19
- exports.printGenerateSuccess = printGenerateSuccess;
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.printGenerateSuccess = exports.printGenerateError = exports.printError = void 0;
7
+ const chalk_1 = __importDefault(require("chalk"));
8
+ function printError(message, component) {
9
+ console.error(chalk_1.default.red(`${message}:`, chalk_1.default.bold(chalk_1.default.white(`[${component}] ❌`))));
10
+ }
11
+ exports.printError = printError;
12
+ async function printGenerateError(schematic, file) {
13
+ console.error(" ", chalk_1.default.redBright(`[${schematic}]`.padEnd(14)), chalk_1.default.bold.white(`${file.split(".")[0]} not created! ❌`));
14
+ }
15
+ exports.printGenerateError = printGenerateError;
16
+ async function printGenerateSuccess(schematic, file) {
17
+ console.log(" ", chalk_1.default.greenBright(`[${schematic}]`.padEnd(14)), chalk_1.default.bold.white(`${file.split(".")[0]} created! ✔️`));
18
+ }
19
+ exports.printGenerateSuccess = printGenerateSuccess;
@@ -1,15 +1,15 @@
1
- import { Service } from "ts-node";
2
- import { ExpressoConfig } from "../types";
3
- /**
4
- * Singleton compiler class
5
- */
6
- declare class Compiler {
7
- private static instance;
8
- private constructor();
9
- static get Instance(): Compiler;
10
- getService(): Promise<Service>;
11
- private static interopRequireDefault;
12
- private static findConfig;
13
- static loadConfig(): Promise<ExpressoConfig>;
14
- }
15
- export default Compiler;
1
+ import { Service } from "ts-node";
2
+ import { ExpressoConfig } from "../types";
3
+ /**
4
+ * Singleton compiler class
5
+ */
6
+ declare class Compiler {
7
+ private static instance;
8
+ private constructor();
9
+ static get Instance(): Compiler;
10
+ getService(): Promise<Service>;
11
+ private static interopRequireDefault;
12
+ private static findConfig;
13
+ static loadConfig(): Promise<ExpressoConfig>;
14
+ }
15
+ export default Compiler;
@@ -1,93 +1,93 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- const node_fs_1 = require("node:fs");
30
- const path_1 = __importDefault(require("path"));
31
- const cli_ui_1 = require("./cli-ui");
32
- /**
33
- * The path to the expressots.config.ts file
34
- */
35
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
36
- const EXPRESSOTS_CONFIG = path_1.default.join(process.cwd(), "expressots.config.ts");
37
- /**
38
- * The config object
39
- */
40
- let globalConfigObject = null;
41
- /**
42
- * The ts-node register options
43
- */
44
- const regOpt = {
45
- compilerOptions: {
46
- module: "commonjs",
47
- },
48
- moduleTypes: {
49
- "**": "cjs",
50
- },
51
- };
52
- /**
53
- * Singleton compiler class
54
- */
55
- class Compiler {
56
- constructor() { }
57
- static get Instance() {
58
- if (!Compiler.instance) {
59
- Compiler.instance = new Compiler();
60
- }
61
- return Compiler.instance;
62
- }
63
- async getService() {
64
- const tsnode = await Promise.resolve().then(() => __importStar(require("ts-node")));
65
- const compiler = tsnode.register(regOpt);
66
- return compiler;
67
- }
68
- static interopRequireDefault(obj) {
69
- // eslint-disable-next-line @typescript-eslint/no-var-requires
70
- const module = require(obj);
71
- return module && module.__esModule ? module : { default: module };
72
- }
73
- static async findConfig(dir) {
74
- const configPath = path_1.default.join(dir, "expressots.config.ts");
75
- const exists = (0, node_fs_1.existsSync)(configPath);
76
- if (exists)
77
- return configPath;
78
- const parentDir = path_1.default.join(dir, "..");
79
- if (parentDir === dir) {
80
- (0, cli_ui_1.printError)("No config file found!", "expressots.config.ts");
81
- process.exit(1);
82
- }
83
- return Compiler.findConfig(parentDir);
84
- }
85
- static async loadConfig() {
86
- const compiler = await Compiler.Instance.getService();
87
- compiler.enabled(true);
88
- globalConfigObject = Compiler.interopRequireDefault(await Compiler.findConfig(process.cwd()));
89
- compiler.enabled(false);
90
- return globalConfigObject.default;
91
- }
92
- }
93
- exports.default = Compiler;
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ const node_fs_1 = require("node:fs");
30
+ const path_1 = __importDefault(require("path"));
31
+ const cli_ui_1 = require("./cli-ui");
32
+ /**
33
+ * The path to the expressots.config.ts file
34
+ */
35
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
36
+ const EXPRESSOTS_CONFIG = path_1.default.join(process.cwd(), "expressots.config.ts");
37
+ /**
38
+ * The config object
39
+ */
40
+ let globalConfigObject = null;
41
+ /**
42
+ * The ts-node register options
43
+ */
44
+ const regOpt = {
45
+ compilerOptions: {
46
+ module: "commonjs",
47
+ },
48
+ moduleTypes: {
49
+ "**": "cjs",
50
+ },
51
+ };
52
+ /**
53
+ * Singleton compiler class
54
+ */
55
+ class Compiler {
56
+ constructor() { }
57
+ static get Instance() {
58
+ if (!Compiler.instance) {
59
+ Compiler.instance = new Compiler();
60
+ }
61
+ return Compiler.instance;
62
+ }
63
+ async getService() {
64
+ const tsnode = await Promise.resolve().then(() => __importStar(require("ts-node")));
65
+ const compiler = tsnode.register(regOpt);
66
+ return compiler;
67
+ }
68
+ static interopRequireDefault(obj) {
69
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
70
+ const module = require(obj);
71
+ return module && module.__esModule ? module : { default: module };
72
+ }
73
+ static async findConfig(dir) {
74
+ const configPath = path_1.default.join(dir, "expressots.config.ts");
75
+ const exists = (0, node_fs_1.existsSync)(configPath);
76
+ if (exists)
77
+ return configPath;
78
+ const parentDir = path_1.default.join(dir, "..");
79
+ if (parentDir === dir) {
80
+ (0, cli_ui_1.printError)("No config file found!", "expressots.config.ts");
81
+ process.exit(1);
82
+ }
83
+ return Compiler.findConfig(parentDir);
84
+ }
85
+ static async loadConfig() {
86
+ const compiler = await Compiler.Instance.getService();
87
+ compiler.enabled(true);
88
+ globalConfigObject = Compiler.interopRequireDefault(await Compiler.findConfig(process.cwd()));
89
+ compiler.enabled(false);
90
+ return globalConfigObject.default;
91
+ }
92
+ }
93
+ exports.default = Compiler;