@dolphjs/cli 1.0.24 → 1.0.26
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 +21 -14
- package/dist/daemon/watcherConfig.js +2 -2
- package/package.json +1 -1
package/dist/daemon/watcher.js
CHANGED
|
@@ -4,10 +4,15 @@ import chalk from "chalk";
|
|
|
4
4
|
import { getRootDirectory } from "../utils/get_root_dir_path.js";
|
|
5
5
|
import { readConfig } from "../utils/read_user_config_path.js";
|
|
6
6
|
import { join } from "path";
|
|
7
|
+
/**
|
|
8
|
+
* TODO: add child2.on('error', (err) => {
|
|
9
|
+
console.error('Error spawning child process:', err);
|
|
10
|
+
});
|
|
11
|
+
*/
|
|
7
12
|
let fileExtension = "";
|
|
8
13
|
let indexFilePath = "";
|
|
9
14
|
export const startApp = () => {
|
|
10
|
-
console.log(chalk.bold(
|
|
15
|
+
console.log(`${chalk.bold(chalk.yellow("[DOLPH INFO]: "))} ${chalk.yellowBright("starting dolph server ...")}`);
|
|
11
16
|
fileExtension = readConfig().language;
|
|
12
17
|
indexFilePath = join(getRootDirectory(), "src", `server.${fileExtension}`);
|
|
13
18
|
const additionalOptions = [
|
|
@@ -16,13 +21,13 @@ export const startApp = () => {
|
|
|
16
21
|
"--transpile-only",
|
|
17
22
|
];
|
|
18
23
|
const spawnArgs = [...additionalOptions, indexFilePath];
|
|
19
|
-
console.log(chalk.bold(
|
|
24
|
+
console.log(`${chalk.bold(chalk.green("[DOLPH INFO]: "))} ${chalk.greenBright("starting dolph server ...")}`);
|
|
20
25
|
const child = spawn(fileExtension === "ts" ? "ts-node" : "node", spawnArgs, {
|
|
21
26
|
stdio: "inherit",
|
|
22
27
|
});
|
|
23
28
|
child.on("close", (code) => {
|
|
24
29
|
if (code === 1) {
|
|
25
|
-
|
|
30
|
+
`${chalk.bold(chalk.red("[DOLPH ERROR]: "))} ${chalk.redBright("exiting watch mode ...")}`;
|
|
26
31
|
process.exit(1);
|
|
27
32
|
}
|
|
28
33
|
});
|
|
@@ -30,7 +35,7 @@ export const startApp = () => {
|
|
|
30
35
|
export const startProdApp = () => {
|
|
31
36
|
fileExtension = readConfig().language;
|
|
32
37
|
if (fileExtension === "ts") {
|
|
33
|
-
console.log(chalk.bold(
|
|
38
|
+
console.log(`${chalk.bold(chalk.yellow("[DOLPH INFO]: "))} ${chalk.yellowBright("compiling to javascript ...")}`);
|
|
34
39
|
}
|
|
35
40
|
indexFilePath = join(getRootDirectory(), "src", `server.${fileExtension}`);
|
|
36
41
|
const spawnArgs = ["src", "-d", "app", "--source-maps", "--copy-files"];
|
|
@@ -39,18 +44,18 @@ export const startProdApp = () => {
|
|
|
39
44
|
});
|
|
40
45
|
child.on("close", (code) => {
|
|
41
46
|
if (code === 1) {
|
|
42
|
-
console.log(chalk.bold(
|
|
47
|
+
console.log(`${chalk.bold(chalk.red("[DOLPH ERROR]: "))} ${chalk.redBright("exiting compilation ...")}`);
|
|
43
48
|
process.exit(1);
|
|
44
49
|
}
|
|
45
50
|
});
|
|
46
51
|
indexFilePath = join(getRootDirectory(), "app", `server.js`);
|
|
47
|
-
console.log(chalk.bold(
|
|
48
|
-
const child2 = spawn("node", indexFilePath, {
|
|
52
|
+
console.log(`${chalk.bold(chalk.green("[DOLPH INFO]: "))} ${chalk.greenBright("starting dolph server ...")}`);
|
|
53
|
+
const child2 = spawn("node", [indexFilePath], {
|
|
49
54
|
stdio: "inherit",
|
|
50
55
|
});
|
|
51
56
|
child2.on("close", (code) => {
|
|
52
57
|
if (code === 1) {
|
|
53
|
-
|
|
58
|
+
`${chalk.bold(chalk.red("[DOLPH ERROR]: "))} ${chalk.redBright("exiting watch mode ...")}`;
|
|
54
59
|
process.exit(1);
|
|
55
60
|
}
|
|
56
61
|
});
|
|
@@ -63,12 +68,16 @@ const watcher = chokidar.watch(indexFilePath, {
|
|
|
63
68
|
let isWatcherActive = false;
|
|
64
69
|
export const watchFile = () => {
|
|
65
70
|
if (!isWatcherActive) {
|
|
66
|
-
console.log(chalk.bold(
|
|
71
|
+
console.log(`${chalk.bold(chalk.green("[DOLPH INFO]: "))} ${chalk.greenBright("watching files for changes ...")}`);
|
|
67
72
|
isWatcherActive = true;
|
|
68
73
|
fileExtension = readConfig().language;
|
|
74
|
+
const srcDirectory = join(getRootDirectory(), "src");
|
|
75
|
+
watcher.add(srcDirectory);
|
|
69
76
|
watcher.on("all", (_event, path) => {
|
|
70
|
-
chalk.bold(
|
|
71
|
-
|
|
77
|
+
`${chalk.bold(chalk.green("[DOLPH INFO]: "))} ${chalk.greenBright("file changed" + `[${path}]`)}`;
|
|
78
|
+
if (path.endsWith(".ts") || path.endsWith(".js")) {
|
|
79
|
+
startApp();
|
|
80
|
+
}
|
|
72
81
|
});
|
|
73
82
|
process.on("SIGINT", () => {
|
|
74
83
|
watcher.close();
|
|
@@ -76,8 +85,6 @@ export const watchFile = () => {
|
|
|
76
85
|
});
|
|
77
86
|
}
|
|
78
87
|
else {
|
|
79
|
-
console.log(chalk.bold(
|
|
88
|
+
console.log(`${chalk.bold(chalk.red("[DOLPH ERROR]: "))} ${chalk.redBright("watcher is already active.")}`);
|
|
80
89
|
}
|
|
81
90
|
};
|
|
82
|
-
// startApp();
|
|
83
|
-
// watchFile();
|
|
@@ -3,10 +3,10 @@ import { startProdApp, watchFile } from "./watcher.js";
|
|
|
3
3
|
export const watcherConfig = () => {
|
|
4
4
|
program
|
|
5
5
|
.command("start")
|
|
6
|
-
.description("starts the
|
|
6
|
+
.description("starts the dolph application")
|
|
7
7
|
.action(() => startProdApp());
|
|
8
8
|
program
|
|
9
9
|
.command("watch")
|
|
10
|
-
.description("starts the
|
|
10
|
+
.description("starts the dolph application in watch mode")
|
|
11
11
|
.action(() => watchFile());
|
|
12
12
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dolphjs/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.26",
|
|
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",
|