@dolphjs/cli 1.2.4 → 1.3.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.
package/dist/daemon/watcher.js
CHANGED
|
@@ -8,7 +8,7 @@ import _ from "lodash";
|
|
|
8
8
|
let fileExtension = "";
|
|
9
9
|
let indexFilePath = "";
|
|
10
10
|
let child;
|
|
11
|
-
export const startApp = () => {
|
|
11
|
+
export const startApp = (useBun = false) => {
|
|
12
12
|
console.log(`${chalk.bold(chalk.yellow("[DOLPH INFO]: "))} ${chalk.yellowBright("starting dolph server ...")}`);
|
|
13
13
|
fileExtension = readConfig().language;
|
|
14
14
|
indexFilePath = join(getRootDirectory(), "src", `server.${fileExtension}`);
|
|
@@ -29,9 +29,17 @@ export const startApp = () => {
|
|
|
29
29
|
// child.kill("SIGTERM");
|
|
30
30
|
child.kill("SIGKILL");
|
|
31
31
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
if (useBun) {
|
|
33
|
+
console.log(`${chalk.bold(chalk.green("[DOLPH INFO:] "))} ${chalk.greenBright("using Bun to start the server ...")}`);
|
|
34
|
+
child = spawn("bun", [indexFilePath], {
|
|
35
|
+
stdio: "inherit",
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
child = spawn(fileExtension === "ts" ? "ts-node" : "node", spawnArgs, {
|
|
40
|
+
stdio: "inherit",
|
|
41
|
+
});
|
|
42
|
+
}
|
|
35
43
|
child.on("error", (err) => {
|
|
36
44
|
console.error(`${chalk.bold(chalk.red("[DOLPH ERROR]: "))} ${chalk.redBright(`${err}`)}`);
|
|
37
45
|
process.exit(1);
|
|
@@ -76,7 +84,7 @@ export const buildApp = () => {
|
|
|
76
84
|
}
|
|
77
85
|
});
|
|
78
86
|
};
|
|
79
|
-
export const startProdApp = async () => {
|
|
87
|
+
export const startProdApp = async (useBun = false) => {
|
|
80
88
|
try {
|
|
81
89
|
fileExtension = readConfig().language;
|
|
82
90
|
if (fileExtension === "ts") {
|
|
@@ -118,19 +126,37 @@ export const startProdApp = async () => {
|
|
|
118
126
|
? join(getRootDirectory(), "app", "src", "server.js")
|
|
119
127
|
: join(getRootDirectory(), "src", "server.js");
|
|
120
128
|
console.log(`${chalk.bold(chalk.green("[DOLPH INFO]: "))} ${chalk.greenBright("starting dolph server ...")}`);
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
child2.on("close", (code) => {
|
|
129
|
-
if (code === 1) {
|
|
130
|
-
`${chalk.bold(chalk.red("[DOLPH ERROR]: "))} ${chalk.redBright("exiting watch mode ...")}`;
|
|
129
|
+
if (useBun) {
|
|
130
|
+
console.log(`${chalk.bold(chalk.green("[DOLPH INFO]: "))} ${chalk.greenBright("using Bun to start the server ...")}`);
|
|
131
|
+
const child2 = spawn("bun", [indexFilePath], {
|
|
132
|
+
stdio: "inherit",
|
|
133
|
+
});
|
|
134
|
+
child2.on("error", (err) => {
|
|
135
|
+
`${chalk.bold(chalk.red("[DOLPH ERROR]: "))} ${chalk.redBright(`${err}`)}`;
|
|
131
136
|
process.exit(1);
|
|
132
|
-
}
|
|
133
|
-
|
|
137
|
+
});
|
|
138
|
+
child2.on("close", (code) => {
|
|
139
|
+
if (code === 1) {
|
|
140
|
+
`${chalk.bold(chalk.red("[DOLPH ERROR]: "))} ${chalk.redBright("exiting watch mode ...")}`;
|
|
141
|
+
process.exit(1);
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
const child2 = spawn("node", [indexFilePath], {
|
|
147
|
+
stdio: "inherit",
|
|
148
|
+
});
|
|
149
|
+
child2.on("error", (err) => {
|
|
150
|
+
`${chalk.bold(chalk.red("[DOLPH ERROR]: "))} ${chalk.redBright(`${err}`)}`;
|
|
151
|
+
process.exit(1);
|
|
152
|
+
});
|
|
153
|
+
child2.on("close", (code) => {
|
|
154
|
+
if (code === 1) {
|
|
155
|
+
`${chalk.bold(chalk.red("[DOLPH ERROR]: "))} ${chalk.redBright("exiting watch mode ...")}`;
|
|
156
|
+
process.exit(1);
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
}
|
|
134
160
|
}
|
|
135
161
|
catch (e) {
|
|
136
162
|
console.error(e);
|
|
@@ -143,8 +169,8 @@ const watcher = chokidar.watch([], {
|
|
|
143
169
|
ignoreInitial: false,
|
|
144
170
|
});
|
|
145
171
|
let isWatcherActive = false;
|
|
146
|
-
const debouncedStartApp = _.debounce(startApp, 1000);
|
|
147
|
-
export const watchFile = () => {
|
|
172
|
+
const debouncedStartApp = _.debounce((useBun) => startApp(useBun), 1000);
|
|
173
|
+
export const watchFile = (useBun = false) => {
|
|
148
174
|
if (!isWatcherActive) {
|
|
149
175
|
console.log(`${chalk.bold(chalk.green("[DOLPH INFO]: "))} ${chalk.greenBright("watching files for changes ...")}`);
|
|
150
176
|
isWatcherActive = true;
|
|
@@ -153,8 +179,11 @@ export const watchFile = () => {
|
|
|
153
179
|
watcher.add(srcDirectory);
|
|
154
180
|
watcher.on("all", (_event, path) => {
|
|
155
181
|
`${chalk.bold(chalk.green("[DOLPH INFO]: "))} ${chalk.greenBright("file changed" + `[${path}]`)}`;
|
|
156
|
-
if (path.endsWith(".ts") ||
|
|
157
|
-
|
|
182
|
+
if (path.endsWith(".ts") ||
|
|
183
|
+
path.endsWith(".js")
|
|
184
|
+
// path.startsWith("dolph_config")
|
|
185
|
+
) {
|
|
186
|
+
debouncedStartApp(useBun);
|
|
158
187
|
}
|
|
159
188
|
});
|
|
160
189
|
process.on("SIGINT", () => {
|
|
@@ -4,11 +4,17 @@ export const watcherConfig = () => {
|
|
|
4
4
|
program
|
|
5
5
|
.command("start")
|
|
6
6
|
.description("starts the dolph application")
|
|
7
|
-
.
|
|
7
|
+
.option("--bun", "uses bun instead of node to run the command")
|
|
8
|
+
.action((options) => {
|
|
9
|
+
startProdApp(options.bun);
|
|
10
|
+
});
|
|
8
11
|
program
|
|
9
12
|
.command("watch")
|
|
10
13
|
.description("starts the dolph application in watch mode")
|
|
11
|
-
.
|
|
14
|
+
.option("--bun", "uses bun instead of node to run the command")
|
|
15
|
+
.action((options) => {
|
|
16
|
+
watchFile(options.bun);
|
|
17
|
+
});
|
|
12
18
|
program
|
|
13
19
|
.command("build")
|
|
14
20
|
.description("compile a typescript project to javascript")
|
|
@@ -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.
|
|
5
|
+
.version("1.3.0")
|
|
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.
|
|
3
|
+
"version": "1.3.0",
|
|
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",
|