@dolphjs/cli 1.0.26 → 1.1.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 +48 -16
- package/dist/daemon/watcherConfig.js +5 -1
- package/dist/index.js +1 -1
- package/dist/utils/get_user_config_path.js +2 -2
- package/dist/utils/init_helper_function.js +2 -1
- package/dist/utils/package_description.js +1 -1
- package/dist/utils/package_init.js +1 -1
- package/dist/utils/read_user_config.js +1 -1
- package/dist/utils/read_user_config_path.js +1 -1
- package/dist/utils/write_package_json.js +6 -12
- package/dist/utils/write_user_config.js +1 -1
- package/package.json +2 -2
package/dist/daemon/watcher.js
CHANGED
|
@@ -4,11 +4,6 @@ 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
|
-
*/
|
|
12
7
|
let fileExtension = "";
|
|
13
8
|
let indexFilePath = "";
|
|
14
9
|
export const startApp = () => {
|
|
@@ -25,6 +20,10 @@ export const startApp = () => {
|
|
|
25
20
|
const child = spawn(fileExtension === "ts" ? "ts-node" : "node", spawnArgs, {
|
|
26
21
|
stdio: "inherit",
|
|
27
22
|
});
|
|
23
|
+
child.on("error", (err) => {
|
|
24
|
+
`${chalk.bold(chalk.red("[DOLPH ERROR]: "))} ${chalk.redBright(`${err}`)}`;
|
|
25
|
+
process.exit(1);
|
|
26
|
+
});
|
|
28
27
|
child.on("close", (code) => {
|
|
29
28
|
if (code === 1) {
|
|
30
29
|
`${chalk.bold(chalk.red("[DOLPH ERROR]: "))} ${chalk.redBright("exiting watch mode ...")}`;
|
|
@@ -32,27 +31,60 @@ export const startApp = () => {
|
|
|
32
31
|
}
|
|
33
32
|
});
|
|
34
33
|
};
|
|
35
|
-
export const
|
|
34
|
+
export const buildApp = () => {
|
|
36
35
|
fileExtension = readConfig().language;
|
|
37
36
|
if (fileExtension === "ts") {
|
|
38
37
|
console.log(`${chalk.bold(chalk.yellow("[DOLPH INFO]: "))} ${chalk.yellowBright("compiling to javascript ...")}`);
|
|
38
|
+
indexFilePath = join(getRootDirectory(), "src", "server.ts");
|
|
39
|
+
const spawnArgs = ["src", "-d", "app", "--source-maps", "--copy-files"];
|
|
40
|
+
const child = spawn("swc", spawnArgs, {
|
|
41
|
+
stdio: "inherit",
|
|
42
|
+
});
|
|
43
|
+
console.log(`${chalk.bold(chalk.green("[DOLPH INFO]: "))} ${chalk.greenBright("compilation successful")}`);
|
|
44
|
+
child.on("error", (err) => {
|
|
45
|
+
`${chalk.bold(chalk.red("[DOLPH ERROR]: "))} ${chalk.redBright(`${err}`)}`;
|
|
46
|
+
process.exit(1);
|
|
47
|
+
});
|
|
48
|
+
child.on("close", (code) => {
|
|
49
|
+
if (code === 1) {
|
|
50
|
+
console.log(`${chalk.bold(chalk.red("[DOLPH ERROR]: "))} ${chalk.redBright("exiting compilation ...")}`);
|
|
51
|
+
process.exit(1);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
39
54
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
55
|
+
else {
|
|
56
|
+
console.log(`${chalk.bold(chalk.red("[DOLPH ERROR]: "))} ${chalk.redBright("cannot compile javascript file, exiting compilation ...")}`);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
export const startProdApp = () => {
|
|
60
|
+
fileExtension = readConfig().language;
|
|
61
|
+
if (fileExtension === "ts") {
|
|
62
|
+
console.log(`${chalk.bold(chalk.yellow("[DOLPH INFO]: "))} ${chalk.yellowBright("compiling to javascript ...")}`);
|
|
63
|
+
indexFilePath = join(getRootDirectory(), "src", `server.${fileExtension}`);
|
|
64
|
+
const spawnArgs = ["src", "-d", "app", "--source-maps", "--copy-files"];
|
|
65
|
+
const child = spawn("swc", spawnArgs, {
|
|
66
|
+
stdio: "inherit",
|
|
67
|
+
});
|
|
68
|
+
child.on("error", (err) => {
|
|
69
|
+
`${chalk.bold(chalk.red("[DOLPH ERROR]: "))} ${chalk.redBright(`${err}`)}`;
|
|
48
70
|
process.exit(1);
|
|
49
|
-
}
|
|
50
|
-
|
|
71
|
+
});
|
|
72
|
+
child.on("close", (code) => {
|
|
73
|
+
if (code === 1) {
|
|
74
|
+
console.log(`${chalk.bold(chalk.red("[DOLPH ERROR]: "))} ${chalk.redBright("exiting compilation ...")}`);
|
|
75
|
+
process.exit(1);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
51
79
|
indexFilePath = join(getRootDirectory(), "app", `server.js`);
|
|
52
80
|
console.log(`${chalk.bold(chalk.green("[DOLPH INFO]: "))} ${chalk.greenBright("starting dolph server ...")}`);
|
|
53
81
|
const child2 = spawn("node", [indexFilePath], {
|
|
54
82
|
stdio: "inherit",
|
|
55
83
|
});
|
|
84
|
+
child2.on("error", (err) => {
|
|
85
|
+
`${chalk.bold(chalk.red("[DOLPH ERROR]: "))} ${chalk.redBright(`${err}`)}`;
|
|
86
|
+
process.exit(1);
|
|
87
|
+
});
|
|
56
88
|
child2.on("close", (code) => {
|
|
57
89
|
if (code === 1) {
|
|
58
90
|
`${chalk.bold(chalk.red("[DOLPH ERROR]: "))} ${chalk.redBright("exiting watch mode ...")}`;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { program } from "commander";
|
|
2
|
-
import { startProdApp, watchFile } from "./watcher.js";
|
|
2
|
+
import { buildApp, startProdApp, watchFile } from "./watcher.js";
|
|
3
3
|
export const watcherConfig = () => {
|
|
4
4
|
program
|
|
5
5
|
.command("start")
|
|
@@ -9,4 +9,8 @@ export const watcherConfig = () => {
|
|
|
9
9
|
.command("watch")
|
|
10
10
|
.description("starts the dolph application in watch mode")
|
|
11
11
|
.action(() => watchFile());
|
|
12
|
+
program
|
|
13
|
+
.command("build")
|
|
14
|
+
.description("compile a typescript project to javascript")
|
|
15
|
+
.action(() => buildApp());
|
|
12
16
|
};
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import { configurePackage } from "./utils/read_user_config.js";
|
|
|
7
7
|
import { InitDolphCli } from "./utils/package_init.js";
|
|
8
8
|
import { packageGenerator } from "./utils/package_generator.js";
|
|
9
9
|
import { watcherConfig } from "./daemon/watcherConfig.js";
|
|
10
|
-
figlet.text("
|
|
10
|
+
figlet.text("dolph cli", {
|
|
11
11
|
font: "Big",
|
|
12
12
|
horizontalLayout: "default",
|
|
13
13
|
verticalLayout: "default",
|
|
@@ -2,9 +2,9 @@ import { existsSync } from "fs";
|
|
|
2
2
|
import path from "path";
|
|
3
3
|
export const getUserConfigFilePath = () => {
|
|
4
4
|
const userConfigFolderPath = path.join(process.cwd());
|
|
5
|
-
const userConfigFilePath = path.join(userConfigFolderPath, "
|
|
5
|
+
const userConfigFilePath = path.join(userConfigFolderPath, "dolph_cli.yaml");
|
|
6
6
|
if (existsSync(userConfigFilePath)) {
|
|
7
7
|
return userConfigFilePath;
|
|
8
8
|
}
|
|
9
|
-
return path.join(userConfigFilePath, "../../", "
|
|
9
|
+
return path.join(userConfigFilePath, "../../", "dolph_cli.yaml");
|
|
10
10
|
};
|
|
@@ -23,7 +23,7 @@ export const initDolphCli = (appname) => {
|
|
|
23
23
|
}
|
|
24
24
|
const configFolderPath = path.join(process.cwd());
|
|
25
25
|
const srcPath = path.join(configFolderPath, "src");
|
|
26
|
-
const userConfigFilePath = path.join(configFolderPath, "
|
|
26
|
+
const userConfigFilePath = path.join(configFolderPath, "dolph_cli.yaml");
|
|
27
27
|
if (!existsSync(configFolderPath)) {
|
|
28
28
|
mkdirSync(configFolderPath);
|
|
29
29
|
}
|
|
@@ -82,6 +82,7 @@ export const initDolphCli = (appname) => {
|
|
|
82
82
|
writeGitignore();
|
|
83
83
|
console.log(chalk.green(chalk.bold("dolph cli configurations have been initialized successfully 😎.")));
|
|
84
84
|
console.log(chalk.green(chalk.bold("run yarn install to install dependencies in project directory and start coding 😉.")));
|
|
85
|
+
process.exit(0);
|
|
85
86
|
});
|
|
86
87
|
}
|
|
87
88
|
else {
|
|
@@ -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.0
|
|
5
|
+
.version("1.1.0")
|
|
6
6
|
.description(chalk.cyan("The dolphjs-cli is a tool for efficient intialization and management of a dolphjs project"));
|
|
7
7
|
};
|
|
@@ -61,7 +61,7 @@ export const configurePackage = () => {
|
|
|
61
61
|
return;
|
|
62
62
|
}
|
|
63
63
|
if (Object.keys(options).length === 0) {
|
|
64
|
-
console.log(chalk.yellow(chalk.bold(`No configurations applied, run ${chalk.white("dolph
|
|
64
|
+
console.log(chalk.yellow(chalk.bold(`No configurations applied, run ${chalk.white("dolph config --help")} to see available commands`)));
|
|
65
65
|
}
|
|
66
66
|
});
|
|
67
67
|
};
|
|
@@ -12,7 +12,7 @@ export const readConfig = () => {
|
|
|
12
12
|
}
|
|
13
13
|
catch (e) {
|
|
14
14
|
console.log(e);
|
|
15
|
-
console.log(chalk.bold(chalk.red("Error encountered reading config file, please run 'dolph
|
|
15
|
+
console.log(chalk.bold(chalk.red("Error encountered reading config file, please run 'dolph tr' to initialize config file 🥹")));
|
|
16
16
|
process.exit(1);
|
|
17
17
|
return {};
|
|
18
18
|
}
|
|
@@ -13,14 +13,13 @@ export function writePackageJsonFile(name, extension) {
|
|
|
13
13
|
"node": ">=18.0.0"
|
|
14
14
|
},
|
|
15
15
|
"scripts": {
|
|
16
|
-
"dev:start": "
|
|
16
|
+
"dev:start": "dolph watch",
|
|
17
17
|
"dev:docker:start": "docker-compose -f docker-compose-dev.yml up",
|
|
18
18
|
"dev:docker:stop": "docker-compose -f docker-compose-dev.yml down",
|
|
19
|
-
"build": "
|
|
19
|
+
"build": "dolph build",
|
|
20
20
|
"build:tsc": "tsc && tsc-alias",
|
|
21
|
-
"
|
|
22
|
-
"clean": "rm -r app && rm -r logs"
|
|
23
|
-
"start": "npm run build && npm run prod:start"
|
|
21
|
+
"start": "dolph start",
|
|
22
|
+
"clean": "rm -r app && rm -r logs"
|
|
24
23
|
},
|
|
25
24
|
"dependencies": {
|
|
26
25
|
"@dolphjs/dolph": "^1.1.0"
|
|
@@ -30,7 +29,6 @@ export function writePackageJsonFile(name, extension) {
|
|
|
30
29
|
"@swc/core": "^1.3.91",
|
|
31
30
|
"@types/express": "^4.17.18",
|
|
32
31
|
"@types/node": "^20.8.2",
|
|
33
|
-
"cross-env": "^7.0.3",
|
|
34
32
|
"ts-node": "^10.9.1",
|
|
35
33
|
"tsc-alias": "^1.8.8",
|
|
36
34
|
"tsconfig-paths": "^4.2.0",
|
|
@@ -48,18 +46,14 @@ export function writePackageJsonFile(name, extension) {
|
|
|
48
46
|
"node": ">=18.0.0"
|
|
49
47
|
},
|
|
50
48
|
"scripts": {
|
|
51
|
-
"dev:start": "
|
|
49
|
+
"dev:start": "dolph watch",
|
|
52
50
|
"dev:docker:start": "docker-compose -f docker-compose-dev.yml up",
|
|
53
51
|
"dev:docker:stop": "docker-compose -f docker-compose-dev.yml down",
|
|
54
|
-
"prod:start": "node src/server.js",
|
|
55
52
|
"clean": "rm -r logs",
|
|
56
|
-
"start": "
|
|
53
|
+
"start": "dolph start"
|
|
57
54
|
},
|
|
58
55
|
"dependencies": {
|
|
59
56
|
"@dolphjs/dolph": "^1.1.0"
|
|
60
|
-
},
|
|
61
|
-
"devDependencies": {
|
|
62
|
-
"cross-env": "^7.0.3"
|
|
63
57
|
}
|
|
64
58
|
}
|
|
65
59
|
`;
|
|
@@ -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 tr' 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.0
|
|
3
|
+
"version": "1.1.0",
|
|
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",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"dist/**/*"
|
|
36
36
|
],
|
|
37
37
|
"bin": {
|
|
38
|
-
"dolph
|
|
38
|
+
"dolph": "./dist/index.js",
|
|
39
39
|
"dc": "./dist/index.js"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|