@expressots/cli 1.11.0 → 1.11.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.
- package/bin/commands/project.commands.js +24 -8
- package/bin/help/form.js +1 -1
- package/package.json +1 -1
|
@@ -34,11 +34,26 @@ const path_1 = __importStar(require("path"));
|
|
|
34
34
|
const cli_ui_1 = require("../utils/cli-ui");
|
|
35
35
|
const compiler_1 = __importDefault(require("../utils/compiler"));
|
|
36
36
|
/**
|
|
37
|
-
*
|
|
37
|
+
* Helper function to load and extract outDir from tsconfig.build.json
|
|
38
38
|
*/
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
|
|
39
|
+
function getOutDir() {
|
|
40
|
+
const tsconfigBuildPath = (0, path_1.join)(process.cwd(), "tsconfig.build.json");
|
|
41
|
+
if (!(0, fs_1.existsSync)(tsconfigBuildPath)) {
|
|
42
|
+
(0, cli_ui_1.printError)("Cannot find tsconfig.build.json. Please create one in the root directory", "tsconfig-build-path");
|
|
43
|
+
process.exit(1);
|
|
44
|
+
}
|
|
45
|
+
const tsconfig = JSON.parse((0, fs_1.readFileSync)(tsconfigBuildPath, "utf-8"));
|
|
46
|
+
const outDir = tsconfig.compilerOptions.outDir;
|
|
47
|
+
if (!outDir) {
|
|
48
|
+
(0, cli_ui_1.printError)("Cannot find outDir in tsconfig.build.json. Please provide an outDir.", "tsconfig-build-path");
|
|
49
|
+
process.exit(1);
|
|
50
|
+
}
|
|
51
|
+
if (!(0, fs_1.existsSync)(outDir)) {
|
|
52
|
+
(0, fs_1.mkdirSync)(outDir, { recursive: true });
|
|
53
|
+
(0, cli_ui_1.printSuccess)(`Created outDir: ${outDir}`, "outdir-creation");
|
|
54
|
+
}
|
|
55
|
+
return outDir;
|
|
56
|
+
}
|
|
42
57
|
/**
|
|
43
58
|
* Load the configuration from the compiler
|
|
44
59
|
* @param compiler The compiler to load the configuration from
|
|
@@ -123,7 +138,7 @@ function execCmd(command, args, cwd = process.cwd()) {
|
|
|
123
138
|
/**
|
|
124
139
|
* Helper function to clean the dist directory
|
|
125
140
|
*/
|
|
126
|
-
const cleanDist = async () => {
|
|
141
|
+
const cleanDist = async (outDir) => {
|
|
127
142
|
await fs_1.promises.rm(outDir, { recursive: true, force: true });
|
|
128
143
|
(0, cli_ui_1.printSuccess)(`Clean ${outDir} directory`, "clean-dist");
|
|
129
144
|
};
|
|
@@ -137,7 +152,7 @@ const compileTypescript = async () => {
|
|
|
137
152
|
/**
|
|
138
153
|
* Helper function to copy files to the dist directory
|
|
139
154
|
*/
|
|
140
|
-
const copyFiles = async () => {
|
|
155
|
+
const copyFiles = async (outDir) => {
|
|
141
156
|
const { opinionated } = await compiler_1.default.loadConfig();
|
|
142
157
|
let filesToCopy = [];
|
|
143
158
|
if (opinionated) {
|
|
@@ -168,6 +183,7 @@ const clearScreen = () => {
|
|
|
168
183
|
*/
|
|
169
184
|
const runCommand = async ({ command, }) => {
|
|
170
185
|
const { opinionated } = await compiler_1.default.loadConfig();
|
|
186
|
+
const outDir = getOutDir();
|
|
171
187
|
try {
|
|
172
188
|
switch (command) {
|
|
173
189
|
case "dev":
|
|
@@ -178,9 +194,9 @@ const runCommand = async ({ command, }) => {
|
|
|
178
194
|
(0, cli_ui_1.printError)("Cannot build project. Please provide an outDir in tsconfig.build.json", "build-command");
|
|
179
195
|
process.exit(1);
|
|
180
196
|
}
|
|
181
|
-
await cleanDist();
|
|
197
|
+
await cleanDist(outDir);
|
|
182
198
|
await compileTypescript();
|
|
183
|
-
await copyFiles();
|
|
199
|
+
await copyFiles(outDir);
|
|
184
200
|
break;
|
|
185
201
|
case "prod": {
|
|
186
202
|
if (!outDir) {
|
package/bin/help/form.js
CHANGED
|
@@ -19,7 +19,7 @@ const helpForm = async () => {
|
|
|
19
19
|
"service",
|
|
20
20
|
"g s",
|
|
21
21
|
"Generate a service [controller, usecase, dto, module]",
|
|
22
|
-
], ["controller", "g c", "Generate a controller"], ["usecase", "g u", "Generate a usecase"], ["dto", "g d", "Generate a dto"], ["entity", "g e", "Generate an entity"], ["provider", "add", "Add provider to the project"], ["provider", "create", "Create
|
|
22
|
+
], ["controller", "g c", "Generate a controller"], ["usecase", "g u", "Generate a usecase"], ["dto", "g d", "Generate a dto"], ["entity", "g e", "Generate an entity"], ["provider", "g p", "Generate internal provider"], ["provider", "add", "Add external provider to the project"], ["provider", "create", "Create external provider"], ["module", "g mo", "Generate a module"], ["middleware", "g mi", "Generate a middleware"]);
|
|
23
23
|
console.log(chalk_1.default.bold.white("ExpressoTS:", `${chalk_1.default.green("Resources List")}`));
|
|
24
24
|
console.log(chalk_1.default.whiteBright(table.toString()));
|
|
25
25
|
console.log(chalk_1.default.bold.white(`📝 More info: ${chalk_1.default.green("https://doc.expresso-ts.com/docs/category/cli")}`));
|