@expressots/cli 1.7.1 → 1.8.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.
Files changed (72) hide show
  1. package/README.md +8 -0
  2. package/bin/@types/config.d.ts +39 -39
  3. package/bin/@types/config.js +2 -2
  4. package/bin/@types/index.d.ts +1 -1
  5. package/bin/@types/index.js +17 -17
  6. package/bin/app.container.d.ts +1 -1
  7. package/bin/app.container.js +8 -8
  8. package/bin/cli.d.ts +2 -2
  9. package/bin/cli.js +38 -38
  10. package/bin/commands/__tests__/project.commands.spec.d.ts +1 -0
  11. package/bin/commands/__tests__/project.commands.spec.js +8 -0
  12. package/bin/commands/project.commands.d.ts +8 -8
  13. package/bin/commands/project.commands.js +137 -136
  14. package/bin/generate/cli.d.ts +4 -4
  15. package/bin/generate/cli.js +66 -66
  16. package/bin/generate/form.d.ts +20 -20
  17. package/bin/generate/form.js +30 -30
  18. package/bin/generate/index.d.ts +1 -1
  19. package/bin/generate/index.js +17 -17
  20. package/bin/generate/utils/command-utils.d.ts +123 -123
  21. package/bin/generate/utils/command-utils.js +314 -310
  22. package/bin/generate/utils/nonopininated-cmd.d.ts +9 -9
  23. package/bin/generate/utils/nonopininated-cmd.js +248 -248
  24. package/bin/generate/utils/opinionated-cmd.d.ts +11 -11
  25. package/bin/generate/utils/opinionated-cmd.js +481 -480
  26. package/bin/help/cli.d.ts +4 -4
  27. package/bin/help/cli.js +15 -15
  28. package/bin/help/form.d.ts +2 -2
  29. package/bin/help/form.js +28 -28
  30. package/bin/help/index.d.ts +1 -1
  31. package/bin/help/index.js +17 -2
  32. package/bin/index.d.ts +6 -4
  33. package/bin/index.js +22 -20
  34. package/bin/info/cli.d.ts +4 -4
  35. package/bin/info/cli.js +15 -15
  36. package/bin/info/form.d.ts +2 -2
  37. package/bin/info/form.js +36 -36
  38. package/bin/info/index.d.ts +1 -1
  39. package/bin/info/index.js +17 -17
  40. package/bin/new/cli.d.ts +4 -4
  41. package/bin/new/cli.js +51 -51
  42. package/bin/new/form.d.ts +2 -2
  43. package/bin/new/form.js +235 -213
  44. package/bin/new/index.d.ts +1 -1
  45. package/bin/new/index.js +17 -17
  46. package/bin/providers/cli.d.ts +4 -4
  47. package/bin/providers/cli.js +43 -38
  48. package/bin/providers/external/external.provider.d.ts +2 -0
  49. package/bin/providers/external/external.provider.js +49 -0
  50. package/bin/providers/index.d.ts +1 -1
  51. package/bin/providers/index.js +17 -17
  52. package/bin/providers/prisma/prisma.provider.d.ts +2 -2
  53. package/bin/providers/prisma/prisma.provider.js +272 -270
  54. package/bin/types.d.ts +1 -1
  55. package/bin/types.js +17 -17
  56. package/bin/utils/add-controller-to-module.d.ts +1 -1
  57. package/bin/utils/add-controller-to-module.js +46 -46
  58. package/bin/utils/add-module-to-container.d.ts +3 -3
  59. package/bin/utils/add-module-to-container.js +129 -129
  60. package/bin/utils/center-text.d.ts +2 -2
  61. package/bin/utils/center-text.js +10 -10
  62. package/bin/utils/cli-ui.d.ts +3 -3
  63. package/bin/utils/cli-ui.js +19 -19
  64. package/bin/utils/compiler.d.ts +15 -15
  65. package/bin/utils/compiler.js +93 -93
  66. package/bin/utils/find-folder.d.ts +5 -5
  67. package/bin/utils/find-folder.js +37 -37
  68. package/bin/utils/index.d.ts +1 -1
  69. package/bin/utils/index.js +17 -17
  70. package/bin/utils/verify-file-exists.d.ts +2 -2
  71. package/bin/utils/verify-file-exists.js +30 -30
  72. package/package.json +31 -28
@@ -1,66 +1,66 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateProject = void 0;
4
- const form_1 = require("./form");
5
- const coerceSchematicAliases = (arg) => {
6
- switch (arg) {
7
- case "u":
8
- return "usecase";
9
- case "c":
10
- return "controller";
11
- case "d":
12
- return "dto";
13
- case "s":
14
- return "service";
15
- case "p":
16
- return "provider";
17
- case "e":
18
- return "entity";
19
- case "mo":
20
- return "module";
21
- case "mi":
22
- return "middleware";
23
- default:
24
- return arg;
25
- }
26
- };
27
- const generateProject = () => {
28
- return {
29
- command: "generate [schematic] [path] [method]",
30
- describe: "Scaffold a new resource",
31
- aliases: ["g"],
32
- builder: (yargs) => {
33
- yargs.positional("schematic", {
34
- choices: [
35
- "usecase",
36
- "controller",
37
- "dto",
38
- "service",
39
- "provider",
40
- "entity",
41
- "module",
42
- "middleware",
43
- ],
44
- describe: "The schematic to generate",
45
- type: "string",
46
- coerce: coerceSchematicAliases,
47
- });
48
- yargs.positional("path", {
49
- describe: "The path to generate the schematic",
50
- type: "string",
51
- alias: "d",
52
- });
53
- yargs.positional("method", {
54
- choices: ["get", "post", "put", "patch", "delete"],
55
- describe: "HTTP method",
56
- type: "string",
57
- alias: "m",
58
- });
59
- return yargs;
60
- },
61
- handler: async ({ schematic, path, method }) => {
62
- await (0, form_1.createTemplate)({ schematic, path, method });
63
- },
64
- };
65
- };
66
- exports.generateProject = generateProject;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateProject = void 0;
4
+ const form_1 = require("./form");
5
+ const coerceSchematicAliases = (arg) => {
6
+ switch (arg) {
7
+ case "u":
8
+ return "usecase";
9
+ case "c":
10
+ return "controller";
11
+ case "d":
12
+ return "dto";
13
+ case "s":
14
+ return "service";
15
+ case "p":
16
+ return "provider";
17
+ case "e":
18
+ return "entity";
19
+ case "mo":
20
+ return "module";
21
+ case "mi":
22
+ return "middleware";
23
+ default:
24
+ return arg;
25
+ }
26
+ };
27
+ const generateProject = () => {
28
+ return {
29
+ command: "generate [schematic] [path] [method]",
30
+ describe: "Scaffold a new resource",
31
+ aliases: ["g"],
32
+ builder: (yargs) => {
33
+ yargs.positional("schematic", {
34
+ choices: [
35
+ "usecase",
36
+ "controller",
37
+ "dto",
38
+ "service",
39
+ "provider",
40
+ "entity",
41
+ "module",
42
+ "middleware",
43
+ ],
44
+ describe: "The schematic to generate",
45
+ type: "string",
46
+ coerce: coerceSchematicAliases,
47
+ });
48
+ yargs.positional("path", {
49
+ describe: "The path to generate the schematic",
50
+ type: "string",
51
+ alias: "d",
52
+ });
53
+ yargs.positional("method", {
54
+ choices: ["get", "post", "put", "patch", "delete"],
55
+ describe: "HTTP method",
56
+ type: "string",
57
+ alias: "m",
58
+ });
59
+ return yargs;
60
+ },
61
+ handler: async ({ schematic, path, method }) => {
62
+ await (0, form_1.createTemplate)({ schematic, path, method });
63
+ },
64
+ };
65
+ };
66
+ exports.generateProject = generateProject;
@@ -1,20 +1,20 @@
1
- /**
2
- * Create a template props
3
- * @param schematic
4
- * @param path
5
- * @param method
6
- */
7
- type CreateTemplateProps = {
8
- schematic: string;
9
- path: string;
10
- method: string;
11
- };
12
- /**
13
- * Create a template based on the schematic
14
- * @param schematic - the schematic to create
15
- * @param path - the path to create the schematic
16
- * @param method - the http method
17
- * @returns the file created
18
- */
19
- export declare const createTemplate: ({ schematic, path: target, method, }: CreateTemplateProps) => Promise<string>;
20
- export {};
1
+ /**
2
+ * Create a template props
3
+ * @param schematic
4
+ * @param path
5
+ * @param method
6
+ */
7
+ type CreateTemplateProps = {
8
+ schematic: string;
9
+ path: string;
10
+ method: string;
11
+ };
12
+ /**
13
+ * Create a template based on the schematic
14
+ * @param schematic - the schematic to create
15
+ * @param path - the path to create the schematic
16
+ * @param method - the http method
17
+ * @returns the file created
18
+ */
19
+ export declare const createTemplate: ({ schematic, path: target, method, }: CreateTemplateProps) => Promise<string>;
20
+ export {};
@@ -1,30 +1,30 @@
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.createTemplate = void 0;
7
- const compiler_1 = __importDefault(require("../utils/compiler"));
8
- const command_utils_1 = require("./utils/command-utils");
9
- const nonopininated_cmd_1 = require("./utils/nonopininated-cmd");
10
- const opinionated_cmd_1 = require("./utils/opinionated-cmd");
11
- /**
12
- * Create a template based on the schematic
13
- * @param schematic - the schematic to create
14
- * @param path - the path to create the schematic
15
- * @param method - the http method
16
- * @returns the file created
17
- */
18
- const createTemplate = async ({ schematic, path: target, method, }) => {
19
- const config = await compiler_1.default.loadConfig();
20
- const pathStyle = (0, command_utils_1.checkPathStyle)(target);
21
- let returnFile = "";
22
- if (config.opinionated) {
23
- returnFile = await (0, opinionated_cmd_1.opinionatedProcess)(schematic, target, method, config, pathStyle);
24
- }
25
- else {
26
- returnFile = await (0, nonopininated_cmd_1.nonOpinionatedProcess)(schematic, target, method, config);
27
- }
28
- return returnFile;
29
- };
30
- exports.createTemplate = createTemplate;
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.createTemplate = void 0;
7
+ const compiler_1 = __importDefault(require("../utils/compiler"));
8
+ const command_utils_1 = require("./utils/command-utils");
9
+ const nonopininated_cmd_1 = require("./utils/nonopininated-cmd");
10
+ const opinionated_cmd_1 = require("./utils/opinionated-cmd");
11
+ /**
12
+ * Create a template based on the schematic
13
+ * @param schematic - the schematic to create
14
+ * @param path - the path to create the schematic
15
+ * @param method - the http method
16
+ * @returns the file created
17
+ */
18
+ const createTemplate = async ({ schematic, path: target, method, }) => {
19
+ const config = await compiler_1.default.loadConfig();
20
+ const pathStyle = (0, command_utils_1.checkPathStyle)(target);
21
+ let returnFile = "";
22
+ if (config.opinionated) {
23
+ returnFile = await (0, opinionated_cmd_1.opinionatedProcess)(schematic, target, method, config, pathStyle);
24
+ }
25
+ else {
26
+ returnFile = await (0, nonopininated_cmd_1.nonOpinionatedProcess)(schematic, target, method, config);
27
+ }
28
+ return returnFile;
29
+ };
30
+ exports.createTemplate = createTemplate;
@@ -1 +1 @@
1
- export * from "./cli";
1
+ export * from "./cli";
@@ -1,17 +1,17 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./cli"), exports);
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./cli"), exports);
@@ -1,123 +1,123 @@
1
- import { ExpressoConfig } from "../../types";
2
- export declare const enum PathStyle {
3
- None = "none",
4
- Single = "single",
5
- Nested = "nested",
6
- Sugar = "sugar"
7
- }
8
- /**
9
- * File preparation
10
- * @param schematic
11
- * @param target
12
- * @param method
13
- * @param opinionated
14
- * @param sourceRoot
15
- * @returns the file output
16
- */
17
- export type FilePreparation = {
18
- schematic: string;
19
- target: string;
20
- method: string;
21
- expressoConfig: ExpressoConfig;
22
- };
23
- /**
24
- * File output
25
- * @param path
26
- * @param file
27
- * @param className
28
- * @param moduleName
29
- * @param modulePath
30
- * @param outputPath
31
- * @param folderToScaffold
32
- */
33
- export type FileOutput = {
34
- path: string;
35
- file: string;
36
- className: string;
37
- moduleName: string;
38
- modulePath: string;
39
- outputPath: string;
40
- folderToScaffold: string;
41
- fileName: string;
42
- schematic: string;
43
- };
44
- /**
45
- * Create a template based on the schematic
46
- * @param fp
47
- * @returns the file created
48
- */
49
- export declare function validateAndPrepareFile(fp: FilePreparation): Promise<{
50
- path: string;
51
- file: string;
52
- className: string;
53
- moduleName: string;
54
- modulePath: string;
55
- outputPath: string;
56
- folderToScaffold: string;
57
- fileName: string;
58
- schematic: string;
59
- }>;
60
- /**
61
- * Get the file name without the extension
62
- * @param filePath
63
- * @returns the file name
64
- */
65
- export declare function getFileNameWithoutExtension(filePath: string): string;
66
- /**
67
- * Split the target into path, file, class name, module name and module path
68
- * @param target
69
- * @param schematic
70
- * @returns the split target
71
- */
72
- export declare const splitTarget: ({ target, schematic, }: {
73
- target: string;
74
- schematic: string;
75
- }) => Promise<{
76
- path: string;
77
- file: string;
78
- className: string;
79
- moduleName: string;
80
- modulePath: string;
81
- }>;
82
- /**
83
- * Write the template based on the http method
84
- * @param method - the http method
85
- * @returns decorator - the decorator to be used
86
- */
87
- export declare const getHttpMethod: (method: string) => string;
88
- /**
89
- * Write the template based on the schematics
90
- * @param outputPath - the output path
91
- * @param template - the template to be used
92
- * @returns void
93
- */
94
- export declare const writeTemplate: ({ outputPath, template: { path, data }, }: {
95
- outputPath: string;
96
- template: {
97
- path: string;
98
- data: Record<string, string>;
99
- };
100
- }) => void;
101
- /**
102
- * Returns the folder where the schematic should be placed
103
- * @param schematic
104
- */
105
- export declare const schematicFolder: (schematic: string) => string | undefined;
106
- /**
107
- * Get the name with the scaffold pattern
108
- * @param name
109
- * @returns the name in the scaffold pattern
110
- */
111
- export declare const getNameWithScaffoldPattern: (name: string) => Promise<string>;
112
- /**
113
- * Extract the first word from a file and convert it to the scaffold pattern
114
- * @param file
115
- * @returns the first word in the scaffold pattern
116
- */
117
- export declare function extractFirstWord(file: string): Promise<string>;
118
- /**
119
- * Check if the path is a nested path, a single path or a sugar path
120
- * @param path
121
- * @returns the path style
122
- */
123
- export declare const checkPathStyle: (path: string) => PathStyle;
1
+ import { ExpressoConfig } from "../../types";
2
+ export declare const enum PathStyle {
3
+ None = "none",
4
+ Single = "single",
5
+ Nested = "nested",
6
+ Sugar = "sugar"
7
+ }
8
+ /**
9
+ * File preparation
10
+ * @param schematic
11
+ * @param target
12
+ * @param method
13
+ * @param opinionated
14
+ * @param sourceRoot
15
+ * @returns the file output
16
+ */
17
+ export type FilePreparation = {
18
+ schematic: string;
19
+ target: string;
20
+ method: string;
21
+ expressoConfig: ExpressoConfig;
22
+ };
23
+ /**
24
+ * File output
25
+ * @param path
26
+ * @param file
27
+ * @param className
28
+ * @param moduleName
29
+ * @param modulePath
30
+ * @param outputPath
31
+ * @param folderToScaffold
32
+ */
33
+ export type FileOutput = {
34
+ path: string;
35
+ file: string;
36
+ className: string;
37
+ moduleName: string;
38
+ modulePath: string;
39
+ outputPath: string;
40
+ folderToScaffold: string;
41
+ fileName: string;
42
+ schematic: string;
43
+ };
44
+ /**
45
+ * Create a template based on the schematic
46
+ * @param fp
47
+ * @returns the file created
48
+ */
49
+ export declare function validateAndPrepareFile(fp: FilePreparation): Promise<{
50
+ path: string;
51
+ file: string;
52
+ className: string;
53
+ moduleName: string;
54
+ modulePath: string;
55
+ outputPath: string;
56
+ folderToScaffold: string;
57
+ fileName: string;
58
+ schematic: string;
59
+ }>;
60
+ /**
61
+ * Get the file name without the extension
62
+ * @param filePath
63
+ * @returns the file name
64
+ */
65
+ export declare function getFileNameWithoutExtension(filePath: string): string;
66
+ /**
67
+ * Split the target into path, file, class name, module name and module path
68
+ * @param target
69
+ * @param schematic
70
+ * @returns the split target
71
+ */
72
+ export declare const splitTarget: ({ target, schematic, }: {
73
+ target: string;
74
+ schematic: string;
75
+ }) => Promise<{
76
+ path: string;
77
+ file: string;
78
+ className: string;
79
+ moduleName: string;
80
+ modulePath: string;
81
+ }>;
82
+ /**
83
+ * Write the template based on the http method
84
+ * @param method - the http method
85
+ * @returns decorator - the decorator to be used
86
+ */
87
+ export declare const getHttpMethod: (method: string) => string;
88
+ /**
89
+ * Write the template based on the schematics
90
+ * @param outputPath - the output path
91
+ * @param template - the template to be used
92
+ * @returns void
93
+ */
94
+ export declare const writeTemplate: ({ outputPath, template: { path, data }, }: {
95
+ outputPath: string;
96
+ template: {
97
+ path: string;
98
+ data: Record<string, string>;
99
+ };
100
+ }) => void;
101
+ /**
102
+ * Returns the folder where the schematic should be placed
103
+ * @param schematic
104
+ */
105
+ export declare const schematicFolder: (schematic: string) => string | undefined;
106
+ /**
107
+ * Get the name with the scaffold pattern
108
+ * @param name
109
+ * @returns the name in the scaffold pattern
110
+ */
111
+ export declare const getNameWithScaffoldPattern: (name: string) => Promise<string>;
112
+ /**
113
+ * Extract the first word from a file and convert it to the scaffold pattern
114
+ * @param file
115
+ * @returns the first word in the scaffold pattern
116
+ */
117
+ export declare function extractFirstWord(file: string): Promise<string>;
118
+ /**
119
+ * Check if the path is a nested path, a single path or a sugar path
120
+ * @param path
121
+ * @returns the path style
122
+ */
123
+ export declare const checkPathStyle: (path: string) => PathStyle;