@dolphjs/cli 1.4.1 → 2.0.1

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.
Files changed (108) hide show
  1. package/README.md +60 -35
  2. package/dist/daemon/watcher.d.ts +4 -0
  3. package/dist/daemon/watcher.js +82 -53
  4. package/dist/daemon/watcherConfig.d.ts +1 -0
  5. package/dist/daemon/watcherConfig.js +13 -9
  6. package/dist/generators/generate_controller.d.ts +2 -0
  7. package/dist/generators/generate_controller.js +38 -30
  8. package/dist/generators/generate_model.d.ts +2 -0
  9. package/dist/generators/generate_model.js +35 -27
  10. package/dist/generators/generate_mysql.d.ts +2 -0
  11. package/dist/generators/generate_mysql.js +33 -25
  12. package/dist/generators/generate_routes.d.ts +2 -0
  13. package/dist/generators/generate_routes.js +33 -25
  14. package/dist/generators/generate_service.d.ts +2 -0
  15. package/dist/generators/generate_service.js +36 -28
  16. package/dist/generators/resolvers/resolve_controller_content.d.ts +1 -0
  17. package/dist/generators/resolvers/resolve_controller_content.js +29 -3
  18. package/dist/generators/resolvers/resolve_model_content.d.ts +2 -0
  19. package/dist/generators/resolvers/resolve_model_content.js +32 -5
  20. package/dist/generators/resolvers/resolve_routes_content.d.ts +1 -0
  21. package/dist/generators/resolvers/resolve_routes_content.js +29 -3
  22. package/dist/generators/resolvers/resolve_service_content.d.ts +1 -0
  23. package/dist/generators/resolvers/resolve_service_content.js +29 -3
  24. package/dist/generators/spring/generate_spring_component.d.ts +2 -0
  25. package/dist/generators/spring/generate_spring_component.js +30 -22
  26. package/dist/generators/spring/generate_spring_controller.d.ts +2 -0
  27. package/dist/generators/spring/generate_spring_controller.js +30 -22
  28. package/dist/generators/spring/generate_spring_model.d.ts +2 -0
  29. package/dist/generators/spring/generate_spring_model.js +30 -22
  30. package/dist/generators/spring/generate_spring_mysql.d.ts +2 -0
  31. package/dist/generators/spring/generate_spring_mysql.js +30 -22
  32. package/dist/generators/spring/generate_spring_service.d.ts +2 -0
  33. package/dist/generators/spring/generate_spring_service.js +30 -22
  34. package/dist/generators/spring/generate_spring_socket_service.d.ts +2 -0
  35. package/dist/generators/spring/generate_spring_socket_service.js +29 -21
  36. package/dist/generators/templates/controller_template.d.ts +5 -0
  37. package/dist/generators/templates/controller_template.js +7 -1
  38. package/dist/generators/templates/model_template.d.ts +5 -0
  39. package/dist/generators/templates/model_template.js +7 -1
  40. package/dist/generators/templates/mysql_config_template.d.ts +5 -0
  41. package/dist/generators/templates/mysql_config_template.js +7 -1
  42. package/dist/generators/templates/routes_template.d.ts +5 -0
  43. package/dist/generators/templates/routes_template.js +7 -1
  44. package/dist/generators/templates/service_template.d.ts +5 -0
  45. package/dist/generators/templates/service_template.js +7 -1
  46. package/dist/generators/templates/socket_service_template.d.ts +1 -0
  47. package/dist/generators/templates/socket_service_template.js +5 -1
  48. package/dist/generators/templates/spring_component_template.d.ts +1 -0
  49. package/dist/generators/templates/spring_component_template.js +5 -1
  50. package/dist/generators/templates/spring_controller_template.d.ts +1 -0
  51. package/dist/generators/templates/spring_controller_template.js +5 -1
  52. package/dist/generators/templates/spring_model_template.d.ts +1 -0
  53. package/dist/generators/templates/spring_model_template.js +5 -1
  54. package/dist/generators/templates/spring_service_template.d.ts +1 -0
  55. package/dist/generators/templates/spring_service_template.js +5 -1
  56. package/dist/get_file_stats.d.ts +1 -0
  57. package/dist/get_file_stats.js +10 -0
  58. package/dist/helpers/messages.d.ts +8 -0
  59. package/dist/helpers/messages.js +14 -8
  60. package/dist/index.d.ts +2 -0
  61. package/dist/index.js +110 -29
  62. package/dist/install.d.ts +1 -0
  63. package/dist/install.js +149 -0
  64. package/dist/registers/register_component.d.ts +1 -0
  65. package/dist/registers/register_component.js +27 -21
  66. package/dist/registers/register_controllers_in_components.d.ts +1 -0
  67. package/dist/registers/register_controllers_in_components.js +22 -17
  68. package/dist/registers/register_routes.d.ts +1 -0
  69. package/dist/registers/register_routes.js +27 -32
  70. package/dist/registers/server_file_express.d.ts +1 -0
  71. package/dist/registers/server_file_express.js +20 -17
  72. package/dist/registers/server_file_spring.d.ts +1 -0
  73. package/dist/registers/server_file_spring.js +18 -13
  74. package/dist/types/config.d.ts +14 -0
  75. package/dist/types/config.js +2 -1
  76. package/dist/utils/get_root_dir_path.d.ts +1 -0
  77. package/dist/utils/get_root_dir_path.js +10 -3
  78. package/dist/utils/get_user_config_path.d.ts +1 -0
  79. package/dist/utils/get_user_config_path.js +14 -7
  80. package/dist/utils/init_helper_function.d.ts +1 -0
  81. package/dist/utils/init_helper_function.js +50 -44
  82. package/dist/utils/package_config.d.ts +1 -0
  83. package/dist/utils/package_config.js +2 -0
  84. package/dist/utils/package_description.d.ts +1 -0
  85. package/dist/utils/package_description.js +12 -5
  86. package/dist/utils/package_generator.d.ts +1 -0
  87. package/dist/utils/package_generator.js +69 -41
  88. package/dist/utils/package_init.d.ts +1 -0
  89. package/dist/utils/package_init.js +9 -5
  90. package/dist/utils/read_package_json.d.ts +4 -0
  91. package/dist/utils/read_package_json.js +17 -0
  92. package/dist/utils/read_user_config.d.ts +1 -0
  93. package/dist/utils/read_user_config.js +29 -22
  94. package/dist/utils/read_user_config_path.d.ts +1 -0
  95. package/dist/utils/read_user_config_path.js +16 -9
  96. package/dist/utils/write_dolph_config.d.ts +1 -0
  97. package/dist/utils/write_dolph_config.js +32 -5
  98. package/dist/utils/write_gitignore.d.ts +1 -0
  99. package/dist/utils/write_gitignore.js +32 -5
  100. package/dist/utils/write_package_json.d.ts +1 -0
  101. package/dist/utils/write_package_json.js +32 -5
  102. package/dist/utils/write_swrcc.d.ts +1 -0
  103. package/dist/utils/write_swrcc.js +32 -5
  104. package/dist/utils/write_tsconfig.d.ts +1 -0
  105. package/dist/utils/write_tsconfig.js +32 -5
  106. package/dist/utils/write_user_config.d.ts +1 -0
  107. package/dist/utils/write_user_config.js +17 -10
  108. package/package.json +22 -12
@@ -1,22 +1,21 @@
1
- import chalk from "chalk";
2
- import { existsSync, readFileSync, writeFileSync } from "fs";
3
- import path from "path";
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.addRoutesIndexFile = void 0;
7
+ const chalk_1 = __importDefault(require("chalk"));
8
+ const fs_1 = require("fs");
9
+ const path_1 = __importDefault(require("path"));
4
10
  const findRoutesDirectory = () => {
5
11
  const rootDir = process.cwd();
6
12
  const possibleDirs = [
7
13
  "/src/routes",
8
- // "/src/Routes",
9
- // "/src/route",
10
- // "/src/Route",
11
- // "/Routes",
12
- // "/Route",
13
- // "/routes",
14
- // "/route",
15
14
  ];
16
- const routesDir = possibleDirs.find((dir) => existsSync(path.join(rootDir, dir)));
17
- return routesDir ? path.join(rootDir, routesDir) : null;
15
+ const routesDir = possibleDirs.find((dir) => (0, fs_1.existsSync)(path_1.default.join(rootDir, dir)));
16
+ return routesDir ? path_1.default.join(rootDir, routesDir) : null;
18
17
  };
19
- export const addRoutesIndexFile = (routesName, readConfig) => {
18
+ const addRoutesIndexFile = (routesName, readConfig) => {
20
19
  let extension;
21
20
  let paradigm;
22
21
  paradigm = readConfig().paradigm;
@@ -32,14 +31,13 @@ export const addRoutesIndexFile = (routesName, readConfig) => {
32
31
  break;
33
32
  }
34
33
  if (!routesName)
35
- chalk.bold(chalk.red("Routes extension or name is required! 🤨"));
34
+ chalk_1.default.bold(chalk_1.default.red("Routes extension or name is required! 🤨"));
36
35
  const routesDir = findRoutesDirectory();
37
36
  if (!routesDir) {
38
- //TODO: create one if it doesn't exist
39
- console.log(chalk.bold(chalk.red("Routes directory doesn't exist 🤨")));
37
+ console.log(chalk_1.default.bold(chalk_1.default.red("Routes directory doesn't exist 🤨")));
40
38
  return;
41
39
  }
42
- const indexPath = path.join(routesDir, `index.${extension}`);
40
+ const indexPath = path_1.default.join(routesDir, `index.${extension}`);
43
41
  let importStatement = ``;
44
42
  const capitalizedString = routesName.charAt(0).toUpperCase() + routesName.slice(1);
45
43
  if (extension === "ts") {
@@ -55,7 +53,7 @@ export const addRoutesIndexFile = (routesName, readConfig) => {
55
53
  }
56
54
  }
57
55
  else {
58
- console.log(chalk.bold(chalk.red("dolphjs only supports '.js' & '.ts' file extensions")));
56
+ console.log(chalk_1.default.bold(chalk_1.default.red("dolphjs only supports '.js' & '.ts' file extensions")));
59
57
  }
60
58
  let routesArray = "";
61
59
  if (extension === "ts") {
@@ -75,22 +73,19 @@ module.exports = { routes };
75
73
  }
76
74
  }
77
75
  try {
78
- // check if file exists
79
- if (!existsSync(indexPath)) {
80
- // if it doesn't exist, create file and add import statement
76
+ if (!(0, fs_1.existsSync)(indexPath)) {
81
77
  const fileContent = `${importStatement}\n\n${routesArray}\n`;
82
- writeFileSync(indexPath, fileContent);
78
+ (0, fs_1.writeFileSync)(indexPath, fileContent);
83
79
  }
84
80
  else {
85
- const fileContent = readFileSync(indexPath, "utf8");
81
+ const fileContent = (0, fs_1.readFileSync)(indexPath, "utf8");
86
82
  const newRouterInstance = `new ${capitalizedString}Router()`;
87
83
  const newRoutesInstance = `${routesName}Routes`;
88
84
  if (!fileContent.includes(importStatement)) {
89
85
  const updatedContent = `${importStatement}\n${fileContent}`;
90
- writeFileSync(indexPath, updatedContent);
86
+ (0, fs_1.writeFileSync)(indexPath, updatedContent);
91
87
  }
92
88
  if (fileContent.includes(`${extension === "ts" ? "export const routes" : "const routes"}`)) {
93
- // add new routes instance to the exisiting routes array
94
89
  if (extension === "ts") {
95
90
  const routesArrayMatch = fileContent.match(/export const routes = \[([\s\S]+?)\];/);
96
91
  if (routesArrayMatch) {
@@ -103,7 +98,7 @@ module.exports = { routes };
103
98
  fileContents = fileContent.replace(`[${existingRoutes}]`, `[${existingRoutes.length > 0 ? existingRoutes + ", " : ""}${newRoutesInstance}]`);
104
99
  }
105
100
  const updatedContents = `${importStatement}\n${fileContents}`;
106
- writeFileSync(indexPath, updatedContents);
101
+ (0, fs_1.writeFileSync)(indexPath, updatedContents);
107
102
  }
108
103
  }
109
104
  else {
@@ -118,27 +113,27 @@ module.exports = { routes };
118
113
  fileContents = fileContent.replace(`[${existingRoutes}]`, `[${existingRoutes.length > 0 ? existingRoutes + ", " : ""}${newRoutesInstance}]`);
119
114
  }
120
115
  const updatedContents = `${importStatement}\n${fileContents}`;
121
- writeFileSync(indexPath, updatedContents);
116
+ (0, fs_1.writeFileSync)(indexPath, updatedContents);
122
117
  }
123
118
  }
124
119
  }
125
120
  else {
126
- // if there is no routes array, add new one
127
121
  if (extension === "ts") {
128
122
  const updatedContents = `${fileContent.trim()}\n\nexport const routes = [${paradigm !== "oop" ? newRouterInstance : newRoutesInstance}];\n`;
129
- writeFileSync(indexPath, updatedContents);
123
+ (0, fs_1.writeFileSync)(indexPath, updatedContents);
130
124
  }
131
125
  else {
132
126
  const updatedContents = `${fileContent.trim()}\n\nconst routes = [${paradigm !== "oop" ? newRouterInstance : newRoutesInstance}];\n\n module.exports = { routes } \n`;
133
- writeFileSync(indexPath, updatedContents);
127
+ (0, fs_1.writeFileSync)(indexPath, updatedContents);
134
128
  }
135
129
  }
136
130
  }
137
- console.log(chalk.bold(chalk.green(`added ${paradigm === "oop"
131
+ console.log(chalk_1.default.bold(chalk_1.default.green(`added ${paradigm === "oop"
138
132
  ? `${capitalizedString}Router`
139
133
  : `${routesName}Routes`} to routes array in index.${extension} file`)));
140
134
  }
141
135
  catch (e) {
142
- console.log(chalk.bold(chalk.red(e)));
136
+ console.log(chalk_1.default.bold(chalk_1.default.red(e)));
143
137
  }
144
138
  };
139
+ exports.addRoutesIndexFile = addRoutesIndexFile;
@@ -0,0 +1 @@
1
+ export declare const addServerFile: (readConfig: any) => void;
@@ -1,23 +1,27 @@
1
- import chalk from "chalk";
2
- import { existsSync, writeFileSync } from "fs";
3
- import path from "path";
4
- // removed other possible dirs to enforce dolphjs style guide
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.addServerFile = void 0;
7
+ const chalk_1 = __importDefault(require("chalk"));
8
+ const fs_1 = require("fs");
9
+ const path_1 = __importDefault(require("path"));
5
10
  const findBaseDirectory = () => {
6
11
  const rootDir = process.cwd();
7
12
  const possibleDirs = [
8
13
  "/src",
9
- // "/"
10
14
  ];
11
- const routesDir = possibleDirs.find((dir) => existsSync(path.join(rootDir, dir)));
12
- return routesDir ? path.join(rootDir, routesDir) : null;
15
+ const routesDir = possibleDirs.find((dir) => (0, fs_1.existsSync)(path_1.default.join(rootDir, dir)));
16
+ return routesDir ? path_1.default.join(rootDir, routesDir) : null;
13
17
  };
14
- export const addServerFile = (readConfig) => {
18
+ const addServerFile = (readConfig) => {
15
19
  let extension;
16
20
  let database;
17
21
  extension = readConfig().language;
18
22
  database = readConfig().database;
19
23
  const baseDirectory = findBaseDirectory();
20
- const indexPath = path.join(baseDirectory, `server.${extension}`);
24
+ const indexPath = path_1.default.join(baseDirectory, `server.${extension}`);
21
25
  let importStatement = ``;
22
26
  let otherFileContent = "";
23
27
  if (extension === "ts" && database === "mysql") {
@@ -43,7 +47,7 @@ const { autoInitMySql } = require("@dolphjs/dolph/packages");
43
47
  const { routes } = require("./routes");`;
44
48
  }
45
49
  else {
46
- console.log(chalk.bold(chalk.red("dolphjs only supports '.js' & '.ts' file extensions ")));
50
+ console.log(chalk_1.default.bold(chalk_1.default.red("dolphjs only supports '.js' & '.ts' file extensions ")));
47
51
  }
48
52
  if (database === "mysql") {
49
53
  otherFileContent = `const dolph = new DolphFactory(routes, []);
@@ -56,19 +60,18 @@ dolph.start();`;
56
60
  dolph.start();`;
57
61
  }
58
62
  try {
59
- // check if file exists
60
- if (!existsSync(indexPath)) {
61
- // if it doesn't exist, create file and add import statement
63
+ if (!(0, fs_1.existsSync)(indexPath)) {
62
64
  const fileContent = `${importStatement}\n\n${otherFileContent}\n`;
63
- writeFileSync(indexPath, fileContent);
65
+ (0, fs_1.writeFileSync)(indexPath, fileContent);
64
66
  }
65
67
  else {
66
68
  const fileContent = `${importStatement}\n\n${otherFileContent}\n`;
67
- writeFileSync(indexPath, fileContent);
69
+ (0, fs_1.writeFileSync)(indexPath, fileContent);
68
70
  }
69
- console.log(chalk.bold(chalk.green(`added server.${extension} file to base directory`)));
71
+ console.log(chalk_1.default.bold(chalk_1.default.green(`added server.${extension} file to base directory`)));
70
72
  }
71
73
  catch (e) {
72
- console.log(chalk.bold(chalk.red(e)));
74
+ console.log(chalk_1.default.bold(chalk_1.default.red(e)));
73
75
  }
74
76
  };
77
+ exports.addServerFile = addServerFile;
@@ -0,0 +1 @@
1
+ export declare const addServerFile: (database: any, name: string) => Promise<void>;
@@ -1,15 +1,21 @@
1
- import chalk from "chalk";
2
- import { existsSync, writeFileSync } from "fs";
3
- import path from "path";
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.addServerFile = void 0;
7
+ const chalk_1 = __importDefault(require("chalk"));
8
+ const fs_1 = require("fs");
9
+ const path_1 = __importDefault(require("path"));
4
10
  const findBaseDirectory = () => {
5
11
  const rootDir = process.cwd();
6
12
  const possibleDirs = ["/src"];
7
- const routesDir = possibleDirs.find((dir) => existsSync(path.join(rootDir, dir)));
8
- return routesDir ? path.join(rootDir, routesDir) : null;
13
+ const routesDir = possibleDirs.find((dir) => (0, fs_1.existsSync)(path_1.default.join(rootDir, dir)));
14
+ return routesDir ? path_1.default.join(rootDir, routesDir) : null;
9
15
  };
10
- export const addServerFile = async (database, name) => {
16
+ const addServerFile = async (database, name) => {
11
17
  const baseDirectory = findBaseDirectory();
12
- const indexPath = path.join(baseDirectory, `server.ts`);
18
+ const indexPath = path_1.default.join(baseDirectory, `server.ts`);
13
19
  let importStatement = ``;
14
20
  let otherFileContent = "";
15
21
  const capitalizedString = name.charAt(0).toUpperCase() + name.slice(1);
@@ -55,18 +61,17 @@ dolph.start();`;
55
61
  dolph.start();`;
56
62
  }
57
63
  try {
58
- // check if file exists
59
- if (!existsSync(indexPath)) {
60
- // if it doesn't exist, create file and add import statement
64
+ if (!(0, fs_1.existsSync)(indexPath)) {
61
65
  const fileContent = `${importStatement}\n\n${otherFileContent}\n`;
62
- writeFileSync(indexPath, fileContent);
66
+ (0, fs_1.writeFileSync)(indexPath, fileContent);
63
67
  }
64
68
  else {
65
69
  const fileContent = `${importStatement}\n\n${otherFileContent}\n`;
66
- writeFileSync(indexPath, fileContent);
70
+ (0, fs_1.writeFileSync)(indexPath, fileContent);
67
71
  }
68
72
  }
69
73
  catch (e) {
70
- console.log(chalk.bold(chalk.red(e)));
74
+ console.log(chalk_1.default.bold(chalk_1.default.red(e)));
71
75
  }
72
76
  };
77
+ exports.addServerFile = addServerFile;
@@ -0,0 +1,14 @@
1
+ export type DefaultConfig = {
2
+ language: language;
3
+ generateFolder: Boolean;
4
+ paradigm: paradigm;
5
+ database: dbs;
6
+ routing: routing;
7
+ api: api;
8
+ };
9
+ type api = "graphql" | "rest";
10
+ type dbs = "mongo" | "mysql" | "postgresql" | "other";
11
+ type paradigm = "oop" | "functional";
12
+ type language = "ts" | "js";
13
+ type routing = "express" | "spring";
14
+ export {};
@@ -1 +1,2 @@
1
- export {};
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export declare const getRootDirectory: () => string;
@@ -1,6 +1,13 @@
1
- import path from "path";
2
- export const getRootDirectory = () => {
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getRootDirectory = void 0;
7
+ const path_1 = __importDefault(require("path"));
8
+ const getRootDirectory = () => {
3
9
  let projectRoot;
4
- projectRoot = path.join(process.cwd());
10
+ projectRoot = path_1.default.join(process.cwd());
5
11
  return projectRoot;
6
12
  };
13
+ exports.getRootDirectory = getRootDirectory;
@@ -0,0 +1 @@
1
+ export declare const getUserConfigFilePath: () => string;
@@ -1,10 +1,17 @@
1
- import { existsSync } from "fs";
2
- import path from "path";
3
- import { getRootDirectory } from "./get_root_dir_path.js";
4
- export const getUserConfigFilePath = () => {
5
- const userConfigFilePath = path.join(getRootDirectory(), "dolph_cli.yaml");
6
- if (existsSync(userConfigFilePath)) {
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getUserConfigFilePath = void 0;
7
+ const fs_1 = require("fs");
8
+ const path_1 = __importDefault(require("path"));
9
+ const get_root_dir_path_js_1 = require("./get_root_dir_path.js");
10
+ const getUserConfigFilePath = () => {
11
+ const userConfigFilePath = path_1.default.join((0, get_root_dir_path_js_1.getRootDirectory)(), "dolph_cli.yaml");
12
+ if ((0, fs_1.existsSync)(userConfigFilePath)) {
7
13
  return userConfigFilePath;
8
14
  }
9
- return path.join(userConfigFilePath, "../../", "dolph_cli.yaml");
15
+ return path_1.default.join(userConfigFilePath, "../../", "dolph_cli.yaml");
10
16
  };
17
+ exports.getUserConfigFilePath = getUserConfigFilePath;
@@ -0,0 +1 @@
1
+ export declare const initDolphCli: (appname: string) => void;
@@ -1,41 +1,47 @@
1
- import { existsSync, mkdirSync, writeFileSync } from "fs";
2
- import inquirer from "inquirer";
3
- import path from "path";
4
- import yaml from "js-yaml";
5
- import { writeSwcrc } from "./write_swrcc.js";
6
- import { writeTsConfigFile } from "./write_tsconfig.js";
7
- import { writeDolphConfig } from "./write_dolph_config.js";
8
- import { writePackageJsonFile } from "./write_package_json.js";
9
- import { writeGitignore } from "./write_gitignore.js";
10
- import { dolphMsg } from "../helpers/messages.js";
11
- import { addServerFile as addSpringServerFile } from "../registers/server_file_spring.js";
12
- export const initDolphCli = (appname) => {
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.initDolphCli = void 0;
7
+ const fs_1 = require("fs");
8
+ const inquirer_1 = __importDefault(require("inquirer"));
9
+ const path_1 = __importDefault(require("path"));
10
+ const js_yaml_1 = __importDefault(require("js-yaml"));
11
+ const write_swrcc_js_1 = require("./write_swrcc.js");
12
+ const write_tsconfig_js_1 = require("./write_tsconfig.js");
13
+ const write_dolph_config_js_1 = require("./write_dolph_config.js");
14
+ const write_package_json_js_1 = require("./write_package_json.js");
15
+ const write_gitignore_js_1 = require("./write_gitignore.js");
16
+ const messages_js_1 = require("../helpers/messages.js");
17
+ const server_file_spring_js_1 = require("../registers/server_file_spring.js");
18
+ const initDolphCli = (appname) => {
13
19
  let projectName = appname;
14
20
  if (appname.length === 0) {
15
- dolphMsg.errorGray("provide a name for you project or indicate with a '.' to use current directory.");
21
+ messages_js_1.dolphMsg.errorGray("provide a name for you project or indicate with a '.' to use current directory.");
16
22
  return;
17
23
  }
18
24
  if (appname !== ".") {
19
- mkdirSync(appname);
25
+ (0, fs_1.mkdirSync)(appname);
20
26
  process.chdir(appname);
21
27
  }
22
28
  else {
23
29
  projectName = process.cwd().split("/").pop();
24
30
  }
25
- const configFolderPath = path.join(process.cwd());
26
- const srcPath = path.join(configFolderPath, "src");
27
- const userConfigFilePath = path.join(configFolderPath, "dolph_cli.yaml");
28
- const testPath = path.join(configFolderPath, "tests");
29
- const sharedDirPath = path.join(srcPath, "shared");
30
- const componentDirPath = path.join(srcPath, "components");
31
- if (!existsSync(configFolderPath)) {
32
- mkdirSync(configFolderPath);
31
+ const configFolderPath = path_1.default.join(process.cwd());
32
+ const srcPath = path_1.default.join(configFolderPath, "src");
33
+ const userConfigFilePath = path_1.default.join(configFolderPath, "dolph_cli.yaml");
34
+ const testPath = path_1.default.join(configFolderPath, "tests");
35
+ const sharedDirPath = path_1.default.join(srcPath, "shared");
36
+ const componentDirPath = path_1.default.join(srcPath, "components");
37
+ if (!(0, fs_1.existsSync)(configFolderPath)) {
38
+ (0, fs_1.mkdirSync)(configFolderPath);
33
39
  }
34
- if (!existsSync(srcPath)) {
35
- mkdirSync(srcPath);
40
+ if (!(0, fs_1.existsSync)(srcPath)) {
41
+ (0, fs_1.mkdirSync)(srcPath);
36
42
  }
37
- if (!existsSync(testPath)) {
38
- mkdirSync(testPath);
43
+ if (!(0, fs_1.existsSync)(testPath)) {
44
+ (0, fs_1.mkdirSync)(testPath);
39
45
  }
40
46
  const defaultConfig = {
41
47
  language: "ts",
@@ -45,8 +51,8 @@ export const initDolphCli = (appname) => {
45
51
  routing: "express",
46
52
  api: "rest",
47
53
  };
48
- if (!existsSync(userConfigFilePath)) {
49
- inquirer
54
+ if (!(0, fs_1.existsSync)(userConfigFilePath)) {
55
+ inquirer_1.default
50
56
  .prompt([
51
57
  {
52
58
  type: "list",
@@ -85,37 +91,37 @@ export const initDolphCli = (appname) => {
85
91
  },
86
92
  ])
87
93
  .then((replies) => {
88
- // TODO: add this to the config file:
89
94
  const comment = "# this is an auto-generated file, please do not edit manually\n";
90
95
  if (replies.routing === "spring") {
91
96
  replies.paradigm = "oop";
92
97
  replies.language = "ts";
93
98
  }
94
99
  const userConfig = { ...defaultConfig, ...replies };
95
- const yamlString = comment + yaml.dump(userConfig);
96
- writeFileSync(userConfigFilePath, yamlString, "utf8");
100
+ const yamlString = comment + js_yaml_1.default.dump(userConfig);
101
+ (0, fs_1.writeFileSync)(userConfigFilePath, yamlString, "utf8");
97
102
  if (userConfig.language === "ts") {
98
- writeSwcrc(userConfig.routing === "spring" ? true : false);
99
- writeTsConfigFile(userConfig.routing === "spring" ? true : false);
103
+ (0, write_swrcc_js_1.writeSwcrc)(userConfig.routing === "spring" ? true : false);
104
+ (0, write_tsconfig_js_1.writeTsConfigFile)(userConfig.routing === "spring" ? true : false);
100
105
  }
101
- writeDolphConfig();
102
- writePackageJsonFile(projectName, userConfig.language);
103
- writeGitignore();
106
+ (0, write_dolph_config_js_1.writeDolphConfig)();
107
+ (0, write_package_json_js_1.writePackageJsonFile)(projectName, userConfig.language);
108
+ (0, write_gitignore_js_1.writeGitignore)();
104
109
  if (userConfig.routing === "spring") {
105
- if (!existsSync(componentDirPath)) {
106
- mkdirSync(componentDirPath);
110
+ if (!(0, fs_1.existsSync)(componentDirPath)) {
111
+ (0, fs_1.mkdirSync)(componentDirPath);
107
112
  }
108
- if (!existsSync(sharedDirPath)) {
109
- mkdirSync(sharedDirPath);
113
+ if (!(0, fs_1.existsSync)(sharedDirPath)) {
114
+ (0, fs_1.mkdirSync)(sharedDirPath);
110
115
  }
111
- addSpringServerFile(userConfig.database, "");
116
+ (0, server_file_spring_js_1.addServerFile)(userConfig.database, "");
112
117
  }
113
- dolphMsg.infoBlue("dolph configurations have been initialized successfully ✨.");
114
- dolphMsg.infoBlue("run `yarn install` to install dependencies in project directory and start building 🚀.");
118
+ messages_js_1.dolphMsg.infoBlue("dolph configurations have been initialized successfully ✨.");
119
+ messages_js_1.dolphMsg.infoBlue("run `yarn install` to install dependencies in project directory and start building 🚀.");
115
120
  process.exit(0);
116
121
  });
117
122
  }
118
123
  else {
119
- dolphMsg.info("I see you already have your dolph configurations present, so I'll abort gently ... 😉.");
124
+ messages_js_1.dolphMsg.info("I see you already have your dolph configurations present, so I'll abort gently ... 😉.");
120
125
  }
121
126
  };
127
+ exports.initDolphCli = initDolphCli;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export declare const packageDescription: () => void;
@@ -1,7 +1,14 @@
1
- import chalk from "chalk";
2
- import { program } from "commander";
3
- export const packageDescription = () => {
4
- program
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.packageDescription = void 0;
7
+ const chalk_1 = __importDefault(require("chalk"));
8
+ const commander_1 = require("commander");
9
+ const packageDescription = () => {
10
+ commander_1.program
5
11
  .version("1.4.0")
6
- .description(chalk.cyan("The dolph-cli is a tool for efficient initialization and management of a dolphjs project"));
12
+ .description(chalk_1.default.cyan("The dolph-cli is a tool for efficient initialization and management of a dolphjs project"));
7
13
  };
14
+ exports.packageDescription = packageDescription;
@@ -0,0 +1 @@
1
+ export declare const packageGenerator: () => void;