@dolphjs/cli 1.1.0 → 1.1.2

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.
@@ -92,7 +92,7 @@ export const startProdApp = () => {
92
92
  }
93
93
  });
94
94
  };
95
- const watcher = chokidar.watch(indexFilePath, {
95
+ const watcher = chokidar.watch([], {
96
96
  ignored: "/node_modules",
97
97
  persistent: true,
98
98
  ignoreInitial: false,
@@ -1,8 +1,8 @@
1
1
  import { existsSync } from "fs";
2
2
  import path from "path";
3
+ import { getRootDirectory } from "./get_root_dir_path.js";
3
4
  export const getUserConfigFilePath = () => {
4
- const userConfigFolderPath = path.join(process.cwd());
5
- const userConfigFilePath = path.join(userConfigFolderPath, "dolph_cli.yaml");
5
+ const userConfigFilePath = path.join(getRootDirectory(), "dolph_cli.yaml");
6
6
  if (existsSync(userConfigFilePath)) {
7
7
  return userConfigFilePath;
8
8
  }
@@ -70,6 +70,8 @@ export const initDolphCli = (appname) => {
70
70
  // },
71
71
  ])
72
72
  .then((replies) => {
73
+ // TODO: add this to the config file:
74
+ // # this is an auto generate file, please do not edit manually
73
75
  const userConfig = { ...defaultConfig, ...replies };
74
76
  const yamlString = yaml.dump(userConfig);
75
77
  writeFileSync(userConfigFilePath, yamlString, "utf8");
@@ -8,60 +8,74 @@ export const configurePackage = () => {
8
8
  .command("config")
9
9
  .alias("cf")
10
10
  .description("Set default configurations")
11
- .option("-l, --language" + chalk.bold(chalk.blue("<language>")), "Set the default coding language (ts or js)")
12
- .option("-p, --paradigm" + chalk.bold(chalk.blue("<paradigm>")), "Set the default programming paradigm (oop or functional)")
13
- .option("-d, --database" + chalk.bold(chalk.blue("<database>")), "Set the default project database (mongo, mysql, postresql or other)")
11
+ .option("-lg, --language" + chalk.bold(chalk.blue("<language>")), "Set the default coding language (ts or js)")
12
+ .option("-pd, --paradigm" + chalk.bold(chalk.blue("<paradigm>")), "Set the default programming paradigm (oop or functional)")
13
+ .option("-db, --database" + chalk.bold(chalk.blue("<database>")), "Set the default project database (mongo, mysql, postresql or other)")
14
14
  .option("-gf, --generateFolder" + chalk.bold(chalk.blue("<boolean>")), "Generates a folder file for the Services, Models, Controllers and Routes (true or false)")
15
- .action((options) => {
16
- const config = readConfig();
17
- // validate language choosen
18
- if (options.language) {
19
- if (options.language !== "js" && options.language !== "ts") {
20
- console.log(options.language);
21
- console.log(chalk.red(`Invalid project language, format must be either ${chalk.bold("js")} or ${chalk.bold("ts")}`));
15
+ .action(async (name, options) => {
16
+ let config = readConfig();
17
+ Object.entries(name).forEach(([key, value]) => {
18
+ if (key && key.toLocaleLowerCase().includes("language") && value) {
19
+ console.log(value.toString(), value);
20
+ if (value.toString() !== "js" && value.toString() !== "ts") {
21
+ console.log(chalk.red(`Invalid project language, format must be either ${chalk.bold("js")} or ${chalk.bold("ts")}`));
22
+ return;
23
+ }
24
+ config.language = value;
25
+ writeConfig(config);
26
+ console.log(chalk.cyan(`Default project language is now ${chalk.bold(config.language)}`));
22
27
  return;
23
28
  }
24
- config.language = options.language;
25
- writeConfig(config);
26
- console.log(chalk.cyan(`Default project language is now ${chalk.bold(config.language)}`));
27
- return;
28
- }
29
- // validate paradigm choosen
30
- if (options.paradigm) {
31
- if (options.paradigm !== "oop" && options.paradigm !== "functional") {
32
- console.log(chalk.red(`Invalid programming paradigm, must be either ${chalk.bold("oop")} or ${chalk.bold("functional")}`));
29
+ if (key && key.toLocaleLowerCase().includes("paradigm") && value) {
30
+ if (value.toString() !== "oop" && value.toString() !== "functional") {
31
+ console.log(chalk.red(`Invalid programming paradigm, must be either ${chalk.bold("oop")} or ${chalk.bold("functional")}`));
32
+ return;
33
+ }
34
+ config.paradigm = value;
35
+ writeConfig(config);
36
+ console.log(chalk.cyan(`Default programming paradigm is now ${chalk.bold(config.paradigm)}`));
33
37
  return;
34
38
  }
35
- config.paradigm = options.paradigm;
36
- writeConfig(config);
37
- console.log(chalk.cyan(`Default programming paradigm is now ${chalk.bold(config.paradigm)}`));
38
- return;
39
- }
40
- // validate database choosen
41
- if (options.database) {
42
- if (!dbOptions.includes(options.database)) {
43
- console.log(chalk.red(`Invalid database value, must be either of these: ${dbOptions.join(", ")} `));
39
+ if (key && key.toLocaleLowerCase().includes("database") && value) {
40
+ if (!dbOptions.includes(value.toString())) {
41
+ console.log(chalk.red(`Invalid database value, must be either of these: ${dbOptions.join(", ")} `));
42
+ return;
43
+ }
44
+ config.database = value;
45
+ writeConfig(config);
46
+ console.log(chalk.cyan(`Default project database is now ${chalk.bold(config.database)}`));
44
47
  return;
45
48
  }
46
- config.database = options.database;
47
- writeConfig(config);
48
- console.log(chalk.cyan(`Default project database is now ${chalk.bold(config.database)}`));
49
- return;
50
- }
49
+ });
51
50
  // validate generateFolder
52
- if (options.generateFolder) {
53
- if (options.generateFolder !== "true" &&
54
- options.generateFolder !== "false") {
55
- console.log(chalk.red(`Invalid folder generation value, value must be ${chalk.bold("true")} or ${chalk.bold("false")}`));
56
- return;
57
- }
58
- config.generateFolder = options.generateFolder;
59
- writeConfig(config);
60
- console.log(chalk.cyan(`Generation of folder files for the Services, Models, Controllers and Routes set to ${chalk.bold(config.generateFolder)}`));
61
- return;
62
- }
51
+ // if (options.generateFolder) {
52
+ // if (
53
+ // options.generateFolder !== "true" &&
54
+ // options.generateFolder !== "false"
55
+ // ) {
56
+ // console.log(
57
+ // chalk.red(
58
+ // `Invalid folder generation value, value must be ${chalk.bold(
59
+ // "true"
60
+ // )} or ${chalk.bold("false")}`
61
+ // )
62
+ // );
63
+ // return;
64
+ // }
65
+ // config.generateFolder = options.generateFolder;
66
+ // writeConfig(config);
67
+ // console.log(
68
+ // chalk.cyan(
69
+ // `Generation of folder files for the Services, Models, Controllers and Routes set to ${chalk.bold(
70
+ // config.generateFolder
71
+ // )}`
72
+ // )
73
+ // );
74
+ // return;
75
+ // }
63
76
  if (Object.keys(options).length === 0) {
64
77
  console.log(chalk.yellow(chalk.bold(`No configurations applied, run ${chalk.white("dolph config --help")} to see available commands`)));
65
78
  }
79
+ process.exit(0);
66
80
  });
67
81
  };
@@ -12,8 +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 tr' to initialize config file 🥹")));
15
+ console.log(chalk.bold(chalk.red("Error encountered reading config file, please run 'dolph cf' to initialize config file 🥹")));
16
16
  process.exit(1);
17
- return {};
18
17
  }
19
18
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dolphjs/cli",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
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",