@dolphjs/cli 1.1.12 โ 1.1.14
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/generators/generate_controller.js +4 -2
- package/dist/generators/generate_model.js +2 -2
- package/dist/generators/generate_mysql.js +17 -11
- package/dist/generators/generate_routes.js +1 -1
- package/dist/generators/generate_service.js +2 -2
- package/dist/generators/spring/generate_spring_component.js +2 -2
- package/dist/generators/spring/generate_spring_controller.js +2 -2
- package/dist/generators/spring/generate_spring_model.js +2 -2
- package/dist/generators/spring/generate_spring_mysql.js +48 -0
- package/dist/generators/spring/generate_spring_service.js +2 -2
- package/dist/registers/register_component.js +6 -4
- package/dist/registers/register_controllers_in_components.js +57 -0
- package/dist/utils/init_helper_function.js +15 -1
- package/dist/utils/package_generator.js +7 -5
- package/package.json +1 -1
|
@@ -5,6 +5,7 @@ import { promisify } from "util";
|
|
|
5
5
|
import { readConfig } from "../utils/read_user_config_path.js";
|
|
6
6
|
import { resolveControllerContent } from "./resolvers/resolve_controller_content.js";
|
|
7
7
|
import { generateController as generateSpringController } from "./spring/generate_spring_controller.js";
|
|
8
|
+
import { addControllerInComponentFIle } from "../registers/register_controllers_in_components.js";
|
|
8
9
|
const writeFileAsync = promisify(writeFile);
|
|
9
10
|
const createControllerDirectory = () => {
|
|
10
11
|
const projectRoot = path.join(process.cwd());
|
|
@@ -30,7 +31,8 @@ export const generateControllerFile = async (name, controllerDir, readConfig) =>
|
|
|
30
31
|
};
|
|
31
32
|
export const generateController = async (name) => {
|
|
32
33
|
if (readConfig().routing === "spring") {
|
|
33
|
-
generateSpringController(name);
|
|
34
|
+
await generateSpringController(name);
|
|
35
|
+
addControllerInComponentFIle(name);
|
|
34
36
|
}
|
|
35
37
|
else {
|
|
36
38
|
if (!name) {
|
|
@@ -48,7 +50,7 @@ export const generateController = async (name) => {
|
|
|
48
50
|
if (readConfig().generateFolder === "true" || true) {
|
|
49
51
|
mkdirSync(controllerDirName);
|
|
50
52
|
}
|
|
51
|
-
generateControllerFile(name, path.join(controllerFilePath), readConfig);
|
|
53
|
+
await generateControllerFile(name, path.join(controllerFilePath), readConfig);
|
|
52
54
|
}
|
|
53
55
|
catch (e) {
|
|
54
56
|
console.log(chalk.bold(chalk.red(e)));
|
|
@@ -30,7 +30,7 @@ export const generateModelFile = async (name, modelDir, readConfig) => {
|
|
|
30
30
|
};
|
|
31
31
|
export const generateModel = async (name) => {
|
|
32
32
|
if (readConfig().routing === "spring") {
|
|
33
|
-
generateSpringModel(name, readConfig().database === "mongo" ? true : false, readConfig().database === "mysql" ? true : false);
|
|
33
|
+
await generateSpringModel(name, readConfig().database === "mongo" ? true : false, readConfig().database === "mysql" ? true : false);
|
|
34
34
|
}
|
|
35
35
|
else {
|
|
36
36
|
if (!name) {
|
|
@@ -46,7 +46,7 @@ export const generateModel = async (name) => {
|
|
|
46
46
|
const modelFilePath = path.join(modelDirName + `/${name}.model.${readConfig().language}`);
|
|
47
47
|
try {
|
|
48
48
|
mkdirSync(modelDirName);
|
|
49
|
-
generateModelFile(name, path.join(modelFilePath), readConfig);
|
|
49
|
+
await generateModelFile(name, path.join(modelFilePath), readConfig);
|
|
50
50
|
}
|
|
51
51
|
catch (e) {
|
|
52
52
|
console.log(chalk.bold(chalk.red(e)));
|
|
@@ -4,6 +4,7 @@ import chalk from "chalk";
|
|
|
4
4
|
import { promisify } from "util";
|
|
5
5
|
import { readConfig } from "../utils/read_user_config_path.js";
|
|
6
6
|
import { resolveMySqlContent } from "./resolvers/resolve_model_content.js";
|
|
7
|
+
import { generateConfig as generateSpringConfig } from "./spring/generate_spring_mysql.js";
|
|
7
8
|
const writeFileAsync = promisify(writeFile);
|
|
8
9
|
const createConfigDirectory = () => {
|
|
9
10
|
const projectRoot = path.join(process.cwd());
|
|
@@ -32,17 +33,22 @@ export const generateConfig = async (name) => {
|
|
|
32
33
|
console.log(chalk.bold(chalk.red("Config extension or name is required! ๐คจ")));
|
|
33
34
|
return;
|
|
34
35
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
createConfigDirectory();
|
|
38
|
-
configDir = findConfigDirectory();
|
|
36
|
+
if (readConfig().routing === "spring") {
|
|
37
|
+
await generateSpringConfig(name);
|
|
39
38
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
39
|
+
else {
|
|
40
|
+
let configDir = findConfigDirectory();
|
|
41
|
+
if (!configDir) {
|
|
42
|
+
createConfigDirectory();
|
|
43
|
+
configDir = findConfigDirectory();
|
|
44
|
+
}
|
|
45
|
+
const configDirName = configDir;
|
|
46
|
+
const configFilePath = path.join(configDirName + `/db.configs.${readConfig().language}`);
|
|
47
|
+
try {
|
|
48
|
+
await generateConfigFile(name, path.join(configFilePath), readConfig);
|
|
49
|
+
}
|
|
50
|
+
catch (e) {
|
|
51
|
+
console.log(chalk.bold(chalk.red(e)));
|
|
52
|
+
}
|
|
47
53
|
}
|
|
48
54
|
};
|
|
@@ -43,7 +43,7 @@ export const generateRouter = async (name) => {
|
|
|
43
43
|
if (readConfig().generateFolder === "true" || true) {
|
|
44
44
|
mkdirSync(routesDirName);
|
|
45
45
|
}
|
|
46
|
-
generateRoutesFile(name, path.join(routesFilePath), readConfig);
|
|
46
|
+
await generateRoutesFile(name, path.join(routesFilePath), readConfig);
|
|
47
47
|
}
|
|
48
48
|
catch (e) {
|
|
49
49
|
console.log(chalk.bold(chalk.red(e)));
|
|
@@ -30,7 +30,7 @@ export const generateServiceFile = async (name, serviceDir, readConfig) => {
|
|
|
30
30
|
};
|
|
31
31
|
export const generateService = async (name) => {
|
|
32
32
|
if (readConfig().routing === "spring") {
|
|
33
|
-
generateSpringService(name, readConfig().database === "mongo" ? true : false, readConfig().database === "mysql" ? true : false);
|
|
33
|
+
await generateSpringService(name, readConfig().database === "mongo" ? true : false, readConfig().database === "mysql" ? true : false);
|
|
34
34
|
}
|
|
35
35
|
else {
|
|
36
36
|
if (!name) {
|
|
@@ -48,7 +48,7 @@ export const generateService = async (name) => {
|
|
|
48
48
|
if (readConfig().generateFolder === "true" || true) {
|
|
49
49
|
mkdirSync(serviceDirName);
|
|
50
50
|
}
|
|
51
|
-
generateServiceFile(name, path.join(serviceFilePath), readConfig);
|
|
51
|
+
await generateServiceFile(name, path.join(serviceFilePath), readConfig);
|
|
52
52
|
}
|
|
53
53
|
catch (e) {
|
|
54
54
|
console.log(chalk.bold(chalk.red(e)));
|
|
@@ -7,14 +7,14 @@ import { promisify } from "util";
|
|
|
7
7
|
const writeFileAsync = promisify(writeFile);
|
|
8
8
|
const createComponentDirectory = (componentName) => {
|
|
9
9
|
const projectRoot = path.join(process.cwd());
|
|
10
|
-
const userComponentPath = path.join(projectRoot, `/src/${componentName}`);
|
|
10
|
+
const userComponentPath = path.join(projectRoot, `/src/components/${componentName}`);
|
|
11
11
|
if (!existsSync(userComponentPath)) {
|
|
12
12
|
mkdirSync(userComponentPath);
|
|
13
13
|
}
|
|
14
14
|
};
|
|
15
15
|
const findComponentDirectory = (componentName) => {
|
|
16
16
|
const rootDir = process.cwd();
|
|
17
|
-
const possibleDirs = [`src/${componentName}`];
|
|
17
|
+
const possibleDirs = [`src/components/${componentName}`];
|
|
18
18
|
const componentDir = possibleDirs.find((dir) => existsSync(path.join(rootDir, dir)));
|
|
19
19
|
return componentDir ? path.join(rootDir, componentDir) : null;
|
|
20
20
|
};
|
|
@@ -7,14 +7,14 @@ import { promisify } from "util";
|
|
|
7
7
|
const writeFileAsync = promisify(writeFile);
|
|
8
8
|
const createControllerDirectory = (componentName) => {
|
|
9
9
|
const projectRoot = path.join(process.cwd());
|
|
10
|
-
const userCompontrollerPath = path.join(projectRoot, `/src/${componentName}`);
|
|
10
|
+
const userCompontrollerPath = path.join(projectRoot, `/src/components/${componentName}`);
|
|
11
11
|
if (!existsSync(userCompontrollerPath)) {
|
|
12
12
|
mkdirSync(userCompontrollerPath);
|
|
13
13
|
}
|
|
14
14
|
};
|
|
15
15
|
const findControllerDirectory = (componentName) => {
|
|
16
16
|
const rootDir = process.cwd();
|
|
17
|
-
const possibleDirs = [`src/${componentName}`];
|
|
17
|
+
const possibleDirs = [`src/components/${componentName}`];
|
|
18
18
|
const controllerDir = possibleDirs.find((dir) => existsSync(path.join(rootDir, dir)));
|
|
19
19
|
return controllerDir ? path.join(rootDir, controllerDir) : null;
|
|
20
20
|
};
|
|
@@ -7,14 +7,14 @@ import { promisify } from "util";
|
|
|
7
7
|
const writeFileAsync = promisify(writeFile);
|
|
8
8
|
const createModelDirectory = (componentName) => {
|
|
9
9
|
const projectRoot = path.join(process.cwd());
|
|
10
|
-
const userModelPath = path.join(projectRoot, `/src/${componentName}`);
|
|
10
|
+
const userModelPath = path.join(projectRoot, `/src/components/${componentName}`);
|
|
11
11
|
if (!existsSync(userModelPath)) {
|
|
12
12
|
mkdirSync(userModelPath);
|
|
13
13
|
}
|
|
14
14
|
};
|
|
15
15
|
const findModelDirectory = (componentName) => {
|
|
16
16
|
const rootDir = process.cwd();
|
|
17
|
-
const possibleDirs = [`src/${componentName}`];
|
|
17
|
+
const possibleDirs = [`src/components/${componentName}`];
|
|
18
18
|
const modelDir = possibleDirs.find((dir) => existsSync(path.join(rootDir, dir)));
|
|
19
19
|
return modelDir ? path.join(rootDir, modelDir) : null;
|
|
20
20
|
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, writeFile } from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import chalk from "chalk";
|
|
4
|
+
import { promisify } from "util";
|
|
5
|
+
import { readConfig } from "../../utils/read_user_config_path.js";
|
|
6
|
+
import { resolveMySqlContent } from "./../resolvers/resolve_model_content.js";
|
|
7
|
+
const writeFileAsync = promisify(writeFile);
|
|
8
|
+
const createConfigDirectory = () => {
|
|
9
|
+
const projectRoot = path.join(process.cwd());
|
|
10
|
+
const userConfigFilePath = path.join(projectRoot, "/src/shared/configs");
|
|
11
|
+
if (!existsSync(userConfigFilePath)) {
|
|
12
|
+
mkdirSync(userConfigFilePath);
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
const findConfigDirectory = () => {
|
|
16
|
+
const rootDir = process.cwd();
|
|
17
|
+
const possibleDirs = ["/src/shared/configs"];
|
|
18
|
+
const configDir = possibleDirs.find((dir) => existsSync(path.join(rootDir, dir)));
|
|
19
|
+
return configDir ? path.join(rootDir, configDir) : null;
|
|
20
|
+
};
|
|
21
|
+
export const generateConfigFile = async (name, configDir, readConfig) => {
|
|
22
|
+
try {
|
|
23
|
+
await writeFileAsync(configDir, resolveMySqlContent(readConfig));
|
|
24
|
+
console.log(`${chalk.bold(chalk.green(`db.config.${readConfig().language} generated successfully! ๐`))}`);
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
console.log(chalk.bold(chalk.red(error.toString())));
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
export const generateConfig = async (name) => {
|
|
31
|
+
if (!name) {
|
|
32
|
+
console.log(chalk.bold(chalk.red("Config extension or name is required! ๐คจ")));
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
let configDir = findConfigDirectory();
|
|
36
|
+
if (!configDir) {
|
|
37
|
+
createConfigDirectory();
|
|
38
|
+
configDir = findConfigDirectory();
|
|
39
|
+
}
|
|
40
|
+
const configDirName = configDir;
|
|
41
|
+
const configFilePath = path.join(configDirName + `/db.configs.${readConfig().language}`);
|
|
42
|
+
try {
|
|
43
|
+
await generateConfigFile(name, path.join(configFilePath), readConfig);
|
|
44
|
+
}
|
|
45
|
+
catch (e) {
|
|
46
|
+
console.log(chalk.bold(chalk.red(e)));
|
|
47
|
+
}
|
|
48
|
+
};
|
|
@@ -7,14 +7,14 @@ import { promisify } from "util";
|
|
|
7
7
|
const writeFileAsync = promisify(writeFile);
|
|
8
8
|
const createServiceDirectory = (componentName) => {
|
|
9
9
|
const projectRoot = path.join(process.cwd());
|
|
10
|
-
const userServicePath = path.join(projectRoot, `/src/${componentName}`);
|
|
10
|
+
const userServicePath = path.join(projectRoot, `/src/components/${componentName}`);
|
|
11
11
|
if (!existsSync(userServicePath)) {
|
|
12
12
|
mkdirSync(userServicePath);
|
|
13
13
|
}
|
|
14
14
|
};
|
|
15
15
|
const findServiceDirectory = (componentName) => {
|
|
16
16
|
const rootDir = process.cwd();
|
|
17
|
-
const possibleDirs = [`src/${componentName}`];
|
|
17
|
+
const possibleDirs = [`src/components/${componentName}`];
|
|
18
18
|
const serviceDir = possibleDirs.find((dir) => existsSync(path.join(rootDir, dir)));
|
|
19
19
|
return serviceDir ? path.join(rootDir, serviceDir) : null;
|
|
20
20
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
2
2
|
import { dolphMsg } from "../helpers/messages.js";
|
|
3
3
|
import path from "path";
|
|
4
|
-
const
|
|
4
|
+
const createComponentDirectory = () => {
|
|
5
5
|
const projectRoot = path.join(process.cwd());
|
|
6
|
-
const userComponentPath = path.join(projectRoot, `/src`);
|
|
6
|
+
const userComponentPath = path.join(projectRoot, `/src/components`);
|
|
7
7
|
if (!existsSync(userComponentPath)) {
|
|
8
8
|
mkdirSync(userComponentPath);
|
|
9
9
|
}
|
|
@@ -25,7 +25,7 @@ export const addComponentToServerFile = (componentName) => {
|
|
|
25
25
|
}
|
|
26
26
|
const serverPath = path.join(serverDir, "server.ts");
|
|
27
27
|
const capitalizedString = componentName.charAt(0).toUpperCase() + componentName.slice(1);
|
|
28
|
-
const importStatement = `import { ${capitalizedString}Component } from "
|
|
28
|
+
const importStatement = `import { ${capitalizedString}Component } from "./components/${componentName}/${componentName}.component";`;
|
|
29
29
|
try {
|
|
30
30
|
if (!existsSync(serverPath)) {
|
|
31
31
|
const fileContent = `import { DolphFactory } from "@dolphjs/dolph";
|
|
@@ -48,7 +48,9 @@ dolph.start();
|
|
|
48
48
|
if (routesArrayMatch) {
|
|
49
49
|
const existingCode = routesArrayMatch[1].trim();
|
|
50
50
|
let fileContents;
|
|
51
|
-
fileContents = fileContent.replace(existingCode, `${existingCode.length > 0
|
|
51
|
+
fileContents = fileContent.replace(existingCode, `${existingCode.length > 0
|
|
52
|
+
? existingCode.slice(0, -1) + `, ${newComponentInstance}]`
|
|
53
|
+
: newComponentInstance}`);
|
|
52
54
|
const updatedContents = `${importStatement}\n${fileContents}`;
|
|
53
55
|
writeFileSync(serverPath, updatedContents);
|
|
54
56
|
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { existsSync, readFileSync, writeFileSync } from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { dolphMsg } from "../helpers/messages.js";
|
|
4
|
+
const findComponentsDirectory = () => {
|
|
5
|
+
const rootDir = process.cwd();
|
|
6
|
+
const possibleDirs = [`src/components`];
|
|
7
|
+
const srcDir = possibleDirs.find((dir) => existsSync(path.join(rootDir, dir)));
|
|
8
|
+
return srcDir ? path.join(rootDir, srcDir) : null;
|
|
9
|
+
};
|
|
10
|
+
export const addControllerInComponentFIle = (componentName) => {
|
|
11
|
+
if (!componentName) {
|
|
12
|
+
dolphMsg.errorRed("component extension or name is required! ๐คจ");
|
|
13
|
+
}
|
|
14
|
+
const componentDir = findComponentsDirectory();
|
|
15
|
+
if (!componentDir) {
|
|
16
|
+
dolphMsg.errorRed("something went wrong, please make sure to use the `new` command when creating a dolph project.");
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const componentPath = path.join(componentDir, `${componentName}.component.ts`);
|
|
20
|
+
const capitalizedString = componentName.charAt(0).toUpperCase() + componentName.slice(1);
|
|
21
|
+
const importStatement = `import { ${capitalizedString}Controller } from "./${componentName}.controller";`;
|
|
22
|
+
try {
|
|
23
|
+
if (!existsSync(componentPath)) {
|
|
24
|
+
const fileContent = `import { Component } from "@dolphjs/dolph/decorators";
|
|
25
|
+
@Component({ controllers: [${capitalizedString}Controller] })
|
|
26
|
+
export class ${capitalizedString}Component {}
|
|
27
|
+
`;
|
|
28
|
+
writeFileSync(componentPath, fileContent);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
const fileContent = readFileSync(componentPath, "utf8");
|
|
32
|
+
const newComponentInstance = `${capitalizedString}Controller`;
|
|
33
|
+
if (!fileContent.includes(importStatement)) {
|
|
34
|
+
const updatedContent = `${importStatement}\n\n${fileContent}`;
|
|
35
|
+
writeFileSync(componentPath, updatedContent);
|
|
36
|
+
}
|
|
37
|
+
if (fileContent.includes(`const dolph`)) {
|
|
38
|
+
// add new controller class to the existing array
|
|
39
|
+
const controllersArrayMatch = fileContent.match(/@Component\(\s*{\s*controllers:\s*\[([^\]]*)\]\s*}\s*\)/);
|
|
40
|
+
if (controllersArrayMatch) {
|
|
41
|
+
const existingCode = controllersArrayMatch[1].trim();
|
|
42
|
+
let fileContents;
|
|
43
|
+
fileContents = fileContent.replace(existingCode, `${existingCode.length > 0
|
|
44
|
+
? existingCode.slice(0, -1) + `, ${newComponentInstance}`
|
|
45
|
+
: newComponentInstance}`);
|
|
46
|
+
const updatedContents = `${importStatement}\n${fileContents}`;
|
|
47
|
+
writeFileSync(componentPath, updatedContents);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
dolphMsg.info(`registerd ${capitalizedString}Controller in ${capitalizedString}Component`);
|
|
52
|
+
process.exit(0);
|
|
53
|
+
}
|
|
54
|
+
catch (e) {
|
|
55
|
+
dolphMsg.errorRed(e.toString());
|
|
56
|
+
}
|
|
57
|
+
};
|
|
@@ -24,12 +24,18 @@ export const initDolphCli = (appname) => {
|
|
|
24
24
|
const configFolderPath = path.join(process.cwd());
|
|
25
25
|
const srcPath = path.join(configFolderPath, "src");
|
|
26
26
|
const userConfigFilePath = path.join(configFolderPath, "dolph_cli.yaml");
|
|
27
|
+
const testPath = path.join(configFolderPath, "tests");
|
|
28
|
+
const sharedDirPath = path.join(srcPath, "shared");
|
|
29
|
+
const componentDirPath = path.join(srcPath, "components");
|
|
27
30
|
if (!existsSync(configFolderPath)) {
|
|
28
31
|
mkdirSync(configFolderPath);
|
|
29
32
|
}
|
|
30
33
|
if (!existsSync(srcPath)) {
|
|
31
34
|
mkdirSync(srcPath);
|
|
32
35
|
}
|
|
36
|
+
if (!existsSync(testPath)) {
|
|
37
|
+
mkdirSync(testPath);
|
|
38
|
+
}
|
|
33
39
|
const defaultConfig = {
|
|
34
40
|
language: "ts",
|
|
35
41
|
paradigm: "oop",
|
|
@@ -72,7 +78,7 @@ export const initDolphCli = (appname) => {
|
|
|
72
78
|
.then((replies) => {
|
|
73
79
|
// TODO: add this to the config file:
|
|
74
80
|
const comment = "# this is an auto-generated file, please do not edit manually\n";
|
|
75
|
-
if (
|
|
81
|
+
if (replies.routing === "spring") {
|
|
76
82
|
replies.paradigm = "oop";
|
|
77
83
|
replies.language = "ts";
|
|
78
84
|
}
|
|
@@ -86,6 +92,14 @@ export const initDolphCli = (appname) => {
|
|
|
86
92
|
writeDolphConfig();
|
|
87
93
|
writePackageJsonFile(projectName, userConfig.language);
|
|
88
94
|
writeGitignore();
|
|
95
|
+
if (userConfig.routing === "spring") {
|
|
96
|
+
if (!existsSync(componentDirPath)) {
|
|
97
|
+
mkdirSync(componentDirPath);
|
|
98
|
+
}
|
|
99
|
+
if (!existsSync(sharedDirPath)) {
|
|
100
|
+
mkdirSync(sharedDirPath);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
89
103
|
dolphMsg.infoBlue("dolph configurations have been initialized successfully โจ.");
|
|
90
104
|
dolphMsg.infoYellow("run `yarn install` to install dependencies in project directory and start building ๐.");
|
|
91
105
|
process.exit(0);
|
|
@@ -11,15 +11,16 @@ import { addServerFile } from "../registers/server_file_routes.js";
|
|
|
11
11
|
import { dolphMsg } from "../helpers/messages.js";
|
|
12
12
|
import { generateComponent } from "../generators/spring/generate_spring_component.js";
|
|
13
13
|
import { addComponentToServerFile } from "../registers/register_component.js";
|
|
14
|
+
import { addControllerInComponentFIle } from "../registers/register_controllers_in_components.js";
|
|
14
15
|
export const packageGenerator = () => {
|
|
15
16
|
program
|
|
16
17
|
.command("generate")
|
|
17
18
|
.alias("g")
|
|
18
|
-
.option("-s, --service" + chalk.bold(chalk.blue("<name>")), "Generates a dolphjs service file.")
|
|
19
|
-
.option("-c, --controller" + chalk.bold(chalk.blue("<name>")), "Generates a dolphjs controller file.")
|
|
20
|
-
.option("-r, --route" + chalk.bold(chalk.blue("<name>")), "Generates a dolphjs routes file.")
|
|
21
|
-
.option("-m, --model" + chalk.bold(chalk.blue("<name>")), "Generates a dolphjs models file.")
|
|
22
|
-
.option("-com, --component" + chalk.bold(chalk.blue("<name>")), "Generates a dolphjs spring component file.")
|
|
19
|
+
.option("-s, --service" + chalk.bold(chalk.blue(" <name>")), "Generates a dolphjs service file.")
|
|
20
|
+
.option("-c, --controller" + chalk.bold(chalk.blue(" <name>")), "Generates a dolphjs controller file.")
|
|
21
|
+
.option("-r, --route" + chalk.bold(chalk.blue(" <name>")), "Generates a dolphjs routes file.")
|
|
22
|
+
.option("-m, --model" + chalk.bold(chalk.blue(" <name>")), "Generates a dolphjs models file.")
|
|
23
|
+
.option("-com, --component" + chalk.bold(chalk.blue(" <name>")), "Generates a dolphjs spring component file.")
|
|
23
24
|
.option("-a, --all" + chalk.bold(chalk.blue(" <name> ")), "Generates dolphjs controllers, routes, models and services files for the name paramter.")
|
|
24
25
|
.action(async (name, _options) => {
|
|
25
26
|
Object.entries(name).forEach(([key, value]) => {
|
|
@@ -66,6 +67,7 @@ export const packageGenerator = () => {
|
|
|
66
67
|
}
|
|
67
68
|
else {
|
|
68
69
|
generateComponent(value.toString());
|
|
70
|
+
addControllerInComponentFIle(value.toString());
|
|
69
71
|
addComponentToServerFile(value.toString());
|
|
70
72
|
}
|
|
71
73
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dolphjs/cli",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.14",
|
|
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",
|