@dolphjs/cli 1.1.20 → 1.1.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/daemon/watcher.js
CHANGED
|
@@ -7,6 +7,7 @@ import { join } from "path";
|
|
|
7
7
|
import _ from "lodash";
|
|
8
8
|
let fileExtension = "";
|
|
9
9
|
let indexFilePath = "";
|
|
10
|
+
let child;
|
|
10
11
|
export const startApp = () => {
|
|
11
12
|
console.log(`${chalk.bold(chalk.yellow("[DOLPH INFO]: "))} ${chalk.yellowBright("starting dolph server ...")}`);
|
|
12
13
|
fileExtension = readConfig().language;
|
|
@@ -20,17 +21,20 @@ export const startApp = () => {
|
|
|
20
21
|
if (fileExtension === "js") {
|
|
21
22
|
spawnArgs = [indexFilePath];
|
|
22
23
|
}
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
if (child) {
|
|
25
|
+
// If child process is already running, gracefully close it before restarting
|
|
26
|
+
child.kill("SIGTERM");
|
|
27
|
+
}
|
|
28
|
+
child = spawn(fileExtension === "ts" ? "ts-node" : "node", spawnArgs, {
|
|
25
29
|
stdio: "inherit",
|
|
26
30
|
});
|
|
27
31
|
child.on("error", (err) => {
|
|
28
|
-
`${chalk.bold(chalk.red("[DOLPH ERROR]: "))} ${chalk.redBright(`${err}`)}
|
|
32
|
+
console.error(`${chalk.bold(chalk.red("[DOLPH ERROR]: "))} ${chalk.redBright(`${err}`)}`);
|
|
29
33
|
process.exit(1);
|
|
30
34
|
});
|
|
31
35
|
child.on("close", (code) => {
|
|
32
36
|
if (code === 1) {
|
|
33
|
-
`${chalk.bold(chalk.red("[DOLPH ERROR]: "))} ${chalk.redBright("exiting watch mode ...")}
|
|
37
|
+
console.error(`${chalk.bold(chalk.red("[DOLPH ERROR]: "))} ${chalk.redBright("exiting watch mode ...")}`);
|
|
34
38
|
process.exit(1);
|
|
35
39
|
}
|
|
36
40
|
});
|
|
@@ -66,7 +70,10 @@ export const startProdApp = () => {
|
|
|
66
70
|
console.log(`${chalk.bold(chalk.yellow("[DOLPH INFO]: "))} ${chalk.yellowBright("compiling to javascript ...")}`);
|
|
67
71
|
indexFilePath = join(getRootDirectory(), "src", `server.ts`);
|
|
68
72
|
const spawnArgs = ["src", "-d", "app", "--source-maps", "--copy-files"];
|
|
69
|
-
|
|
73
|
+
if (child) {
|
|
74
|
+
child.kill("SIGTERM");
|
|
75
|
+
}
|
|
76
|
+
child = spawn("swc", spawnArgs, {
|
|
70
77
|
stdio: "inherit",
|
|
71
78
|
});
|
|
72
79
|
child.on("error", (err) => {
|
|
@@ -87,8 +87,8 @@ export const initDolphCli = (appname) => {
|
|
|
87
87
|
const yamlString = comment + yaml.dump(userConfig);
|
|
88
88
|
writeFileSync(userConfigFilePath, yamlString, "utf8");
|
|
89
89
|
if (userConfig.language === "ts") {
|
|
90
|
-
writeSwcrc();
|
|
91
|
-
writeTsConfigFile();
|
|
90
|
+
writeSwcrc(userConfig.routing === "spring" ? true : false);
|
|
91
|
+
writeTsConfigFile(userConfig.routing === "spring" ? true : false);
|
|
92
92
|
}
|
|
93
93
|
writeDolphConfig();
|
|
94
94
|
writePackageJsonFile(projectName, userConfig.language);
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import * as fs from "fs";
|
|
2
2
|
import { getRootDirectory } from "./get_root_dir_path.js";
|
|
3
3
|
import { join } from "path";
|
|
4
|
-
export function writeSwcrc() {
|
|
5
|
-
|
|
4
|
+
export function writeSwcrc(isSpring) {
|
|
5
|
+
let swcrcContent = ``;
|
|
6
|
+
if (!isSpring) {
|
|
7
|
+
swcrcContent = `{
|
|
6
8
|
"jsc": {
|
|
7
9
|
"parser": {
|
|
8
10
|
"syntax": "typescript",
|
|
@@ -43,6 +45,51 @@ export function writeSwcrc() {
|
|
|
43
45
|
}
|
|
44
46
|
}
|
|
45
47
|
`;
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
swcrcContent = `{
|
|
51
|
+
"jsc": {
|
|
52
|
+
"parser": {
|
|
53
|
+
"syntax": "typescript",
|
|
54
|
+
"tsx": false,
|
|
55
|
+
"dynamicImport": true,
|
|
56
|
+
"decorators": true
|
|
57
|
+
},
|
|
58
|
+
"transform": {
|
|
59
|
+
"legacyDecorator": true,
|
|
60
|
+
"decoratorMetadata": true
|
|
61
|
+
},
|
|
62
|
+
"target": "es2022",
|
|
63
|
+
"externalHelpers": false,
|
|
64
|
+
"keepClassNames": true,
|
|
65
|
+
"loose": false,
|
|
66
|
+
"minify": {
|
|
67
|
+
"compress": false,
|
|
68
|
+
"mangle": false
|
|
69
|
+
},
|
|
70
|
+
"baseUrl": "src",
|
|
71
|
+
"paths": {
|
|
72
|
+
"@/*": ["*"],
|
|
73
|
+
"@/configs/*": ["shared/configs/*"],
|
|
74
|
+
"@/components/*": ["components/*"],
|
|
75
|
+
"@utils/*": ["shared/utils/*"],
|
|
76
|
+
"@shields/*": ["shared/shields/*"],
|
|
77
|
+
"@shared/*": ["shared/*"],
|
|
78
|
+
"@/helpers*": ["shared/helpers/*"],
|
|
79
|
+
"@/interfaces/*": ["shared/interfaces/*"],
|
|
80
|
+
"@/middlewares/*": ["shared/middlewares/*"],
|
|
81
|
+
"@/decorators/*": ["shared/decorators/*"],
|
|
82
|
+
"@/services/*": ["shared/services/*"],
|
|
83
|
+
"@/constants/*": ["shared/constants/*"],
|
|
84
|
+
"@/validations/*": ["shared/validations/*"]
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
"module": {
|
|
88
|
+
"type": "commonjs"
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
`;
|
|
92
|
+
}
|
|
46
93
|
const filePath = join(getRootDirectory(), ".swcrc");
|
|
47
94
|
fs.writeFileSync(filePath, swcrcContent, { encoding: "utf-8" });
|
|
48
95
|
}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import * as fs from "fs";
|
|
2
2
|
import { getRootDirectory } from "./get_root_dir_path.js";
|
|
3
3
|
import { join } from "path";
|
|
4
|
-
export function writeTsConfigFile() {
|
|
5
|
-
|
|
4
|
+
export function writeTsConfigFile(isSpring) {
|
|
5
|
+
let tsConfigContent = ``;
|
|
6
|
+
if (!isSpring) {
|
|
7
|
+
tsConfigContent = `
|
|
8
|
+
{
|
|
6
9
|
"exclude": ["node_modules"],
|
|
7
10
|
"compilerOptions": {
|
|
8
11
|
"allowJs": false,
|
|
@@ -39,7 +42,53 @@ export function writeTsConfigFile() {
|
|
|
39
42
|
"module": "CommonJS"
|
|
40
43
|
}
|
|
41
44
|
}
|
|
42
|
-
}
|
|
45
|
+
}
|
|
46
|
+
`;
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
tsConfigContent = `
|
|
50
|
+
{
|
|
51
|
+
"exclude": ["node_modules"],
|
|
52
|
+
"compilerOptions": {
|
|
53
|
+
"allowJs": false,
|
|
54
|
+
"declaration": false,
|
|
55
|
+
"experimentalDecorators": true,
|
|
56
|
+
"sourceMap": false,
|
|
57
|
+
"useUnknownInCatchVariables": false,
|
|
58
|
+
"strictFunctionTypes": false,
|
|
59
|
+
"forceConsistentCasingInFileNames": true,
|
|
60
|
+
"resolveJsonModule": true,
|
|
61
|
+
"esModuleInterop": true,
|
|
62
|
+
"target": "ES2022",
|
|
63
|
+
"baseUrl": "src",
|
|
64
|
+
"outDir": "app",
|
|
65
|
+
"pretty": true,
|
|
66
|
+
"module": "commonjs",
|
|
67
|
+
"paths": {
|
|
68
|
+
"@/*": ["*"],
|
|
69
|
+
"@/configs/*": ["shared/configs/*"],
|
|
70
|
+
"@/components/*": ["components/*"],
|
|
71
|
+
"@utils/*": ["shared/utils/*"],
|
|
72
|
+
"@shields/*": ["shared/shields/*"],
|
|
73
|
+
"@shared/*": ["shared/*"],
|
|
74
|
+
"@/helpers*": ["shared/helpers/*"],
|
|
75
|
+
"@/interfaces/*": ["shared/interfaces/*"],
|
|
76
|
+
"@/middlewares/*": ["shared/middlewares/*"],
|
|
77
|
+
"@/decorators/*": ["shared/decorators/*"],
|
|
78
|
+
"@/services/*": ["shared/services/*"],
|
|
79
|
+
"@/constants/*": ["shared/constants/*"],
|
|
80
|
+
"@/validations/*": ["shared/validations/*"]
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
"include": ["src/", ".env"],
|
|
84
|
+
"ts-node": {
|
|
85
|
+
"compilerOptions": {
|
|
86
|
+
"module": "CommonJS"
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
`;
|
|
91
|
+
}
|
|
43
92
|
const filePath = join(getRootDirectory(), "tsconfig.json");
|
|
44
93
|
fs.writeFileSync(filePath, tsConfigContent, { encoding: "utf-8" });
|
|
45
94
|
}
|
|
@@ -10,7 +10,7 @@ export const writeConfig = (config) => {
|
|
|
10
10
|
console.log(chalk.green("Configurations saved successfully! 😎."));
|
|
11
11
|
}
|
|
12
12
|
catch (e) {
|
|
13
|
-
console.log(chalk.bold(chalk.red("Error encountered reading config file, please run 'dolph
|
|
13
|
+
console.log(chalk.bold(chalk.red("Error encountered reading config file, please run 'dolph cf' to initialize config file 🥹")));
|
|
14
14
|
process.exit(1);
|
|
15
15
|
}
|
|
16
16
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dolphjs/cli",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.22",
|
|
4
4
|
"description": "The dolphjs-cli is a tool for efficient intialization and management of a dolphjs project",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"repository": "https://github.com/dolphjs/dolph-cli.git",
|
|
@@ -38,6 +38,11 @@
|
|
|
38
38
|
"dolph": "./dist/index.js",
|
|
39
39
|
"dc": "./dist/index.js"
|
|
40
40
|
},
|
|
41
|
+
"peerDependencies": {
|
|
42
|
+
"ts-node": "^10.9.2",
|
|
43
|
+
"@swc/cli": "^0.1.62",
|
|
44
|
+
"@swc/core": "^1.3.91"
|
|
45
|
+
},
|
|
41
46
|
"dependencies": {
|
|
42
47
|
"chalk": "^5.3.0",
|
|
43
48
|
"chokidar": "^3.5.3",
|