@dolphjs/cli 1.2.2 → 1.2.4
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
|
@@ -26,8 +26,8 @@ export const startApp = () => {
|
|
|
26
26
|
child = null;
|
|
27
27
|
});
|
|
28
28
|
// If child process is already running, gracefully close it before restarting
|
|
29
|
-
child.kill("SIGTERM");
|
|
30
|
-
|
|
29
|
+
// child.kill("SIGTERM");
|
|
30
|
+
child.kill("SIGKILL");
|
|
31
31
|
}
|
|
32
32
|
child = spawn(fileExtension === "ts" ? "ts-node" : "node", spawnArgs, {
|
|
33
33
|
stdio: "inherit",
|
|
@@ -45,74 +45,97 @@ export const startApp = () => {
|
|
|
45
45
|
});
|
|
46
46
|
};
|
|
47
47
|
export const buildApp = () => {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
48
|
+
return new Promise((resolve, reject) => {
|
|
49
|
+
fileExtension = readConfig().language;
|
|
50
|
+
if (fileExtension === "ts") {
|
|
51
|
+
console.log(`${chalk.bold(chalk.yellow("[DOLPH INFO]: "))} ${chalk.yellowBright("compiling to javascript ...")}`);
|
|
52
|
+
indexFilePath = join(getRootDirectory(), "src", "server.ts");
|
|
53
|
+
const spawnArgs = ["src", "-d", "app", "--source-maps", "--copy-files"];
|
|
54
|
+
const child = spawn("swc", spawnArgs, {
|
|
55
|
+
stdio: "inherit",
|
|
56
|
+
});
|
|
57
|
+
child.on("error", (err) => {
|
|
58
|
+
`${chalk.bold(chalk.red("[DOLPH ERROR]: "))} ${chalk.redBright(`${err}`)}`;
|
|
59
|
+
// process.exit(1);
|
|
60
|
+
reject(err);
|
|
61
|
+
});
|
|
62
|
+
child.on("close", (code) => {
|
|
63
|
+
if (code === 1) {
|
|
64
|
+
console.log(`${chalk.bold(chalk.red("[DOLPH ERROR]: "))} ${chalk.redBright("exiting compilation ...")}`);
|
|
65
|
+
reject(new Error("Compilation failed ..."));
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
console.log(`${chalk.bold(chalk.green("[DOLPH INFO]: "))} ${chalk.greenBright("compilation successful")}`);
|
|
69
|
+
resolve();
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
console.log(`${chalk.bold(chalk.red("[DOLPH ERROR]: "))} ${chalk.redBright("cannot compile javascript file, exiting compilation ...")}`);
|
|
75
|
+
reject(new Error("Cannot compile JavaScript file"));
|
|
76
|
+
}
|
|
77
|
+
});
|
|
71
78
|
};
|
|
72
|
-
export const startProdApp = () => {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
child
|
|
79
|
+
export const startProdApp = async () => {
|
|
80
|
+
try {
|
|
81
|
+
fileExtension = readConfig().language;
|
|
82
|
+
if (fileExtension === "ts") {
|
|
83
|
+
console.log(`${chalk.bold(chalk.yellow("[DOLPH INFO]: "))} ${chalk.yellowBright("compiling to javascript ...")}`);
|
|
84
|
+
indexFilePath = join(getRootDirectory(), "src", `server.ts`);
|
|
85
|
+
const spawnArgs = ["src", "-d", "app", "--source-maps", "--copy-files"];
|
|
86
|
+
if (child) {
|
|
87
|
+
child.on("exit", () => {
|
|
88
|
+
child = null;
|
|
89
|
+
});
|
|
90
|
+
child.kill("SIGTERM");
|
|
91
|
+
}
|
|
92
|
+
child = spawn("swc", spawnArgs, {
|
|
93
|
+
stdio: "inherit",
|
|
94
|
+
});
|
|
95
|
+
child.on("error", (err) => {
|
|
96
|
+
`${chalk.bold(chalk.red("[DOLPH ERROR]: "))} ${chalk.redBright(`${err}`)}`;
|
|
97
|
+
process.exit(1);
|
|
98
|
+
});
|
|
99
|
+
child.on("close", (code) => {
|
|
100
|
+
if (code === 1) {
|
|
101
|
+
console.log(`${chalk.bold(chalk.red("[DOLPH ERROR]: "))} ${chalk.redBright("exiting compilation ...")}`);
|
|
102
|
+
process.exit(1);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
await new Promise((resolve, reject) => {
|
|
106
|
+
child.on("close", (code) => {
|
|
107
|
+
if (code === 0) {
|
|
108
|
+
resolve();
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
reject(new Error("Compilation failed"));
|
|
112
|
+
}
|
|
113
|
+
});
|
|
81
114
|
});
|
|
82
|
-
child.kill("SIGTERM");
|
|
83
115
|
}
|
|
84
|
-
|
|
116
|
+
indexFilePath =
|
|
117
|
+
fileExtension === "ts"
|
|
118
|
+
? join(getRootDirectory(), "app", "src", "server.js")
|
|
119
|
+
: join(getRootDirectory(), "src", "server.js");
|
|
120
|
+
console.log(`${chalk.bold(chalk.green("[DOLPH INFO]: "))} ${chalk.greenBright("starting dolph server ...")}`);
|
|
121
|
+
const child2 = spawn("node", [indexFilePath], {
|
|
85
122
|
stdio: "inherit",
|
|
86
123
|
});
|
|
87
|
-
|
|
124
|
+
child2.on("error", (err) => {
|
|
88
125
|
`${chalk.bold(chalk.red("[DOLPH ERROR]: "))} ${chalk.redBright(`${err}`)}`;
|
|
89
126
|
process.exit(1);
|
|
90
127
|
});
|
|
91
|
-
|
|
128
|
+
child2.on("close", (code) => {
|
|
92
129
|
if (code === 1) {
|
|
93
|
-
|
|
130
|
+
`${chalk.bold(chalk.red("[DOLPH ERROR]: "))} ${chalk.redBright("exiting watch mode ...")}`;
|
|
94
131
|
process.exit(1);
|
|
95
132
|
}
|
|
96
133
|
});
|
|
97
134
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
indexFilePath = join(getRootDirectory(), "src", `server.js`);
|
|
101
|
-
}
|
|
102
|
-
console.log(`${chalk.bold(chalk.green("[DOLPH INFO]: "))} ${chalk.greenBright("starting dolph server ...")}`);
|
|
103
|
-
const child2 = spawn("node", [indexFilePath], {
|
|
104
|
-
stdio: "inherit",
|
|
105
|
-
});
|
|
106
|
-
child2.on("error", (err) => {
|
|
107
|
-
`${chalk.bold(chalk.red("[DOLPH ERROR]: "))} ${chalk.redBright(`${err}`)}`;
|
|
135
|
+
catch (e) {
|
|
136
|
+
console.error(e);
|
|
108
137
|
process.exit(1);
|
|
109
|
-
}
|
|
110
|
-
child2.on("close", (code) => {
|
|
111
|
-
if (code === 1) {
|
|
112
|
-
`${chalk.bold(chalk.red("[DOLPH ERROR]: "))} ${chalk.redBright("exiting watch mode ...")}`;
|
|
113
|
-
process.exit(1);
|
|
114
|
-
}
|
|
115
|
-
});
|
|
138
|
+
}
|
|
116
139
|
};
|
|
117
140
|
const watcher = chokidar.watch([], {
|
|
118
141
|
ignored: "/node_modules",
|
|
@@ -2,6 +2,6 @@ import chalk from "chalk";
|
|
|
2
2
|
import { program } from "commander";
|
|
3
3
|
export const packageDescription = () => {
|
|
4
4
|
program
|
|
5
|
-
.version("1.2.
|
|
5
|
+
.version("1.2.4")
|
|
6
6
|
.description(chalk.cyan("The dolph-cli is a tool for efficient initialization and management of a dolphjs project"));
|
|
7
7
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dolphjs/cli",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.4",
|
|
4
4
|
"description": "The dolphjs-cli is a tool for efficient initialization and management of a dolphjs project",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"repository": "https://github.com/dolphjs/dolph-cli.git",
|