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