@expressots/cli 1.11.1 → 3.0.0-beta.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 (48) hide show
  1. package/bin/cli.d.ts +5 -1
  2. package/bin/cli.js +9 -1
  3. package/bin/commands/project.commands.js +4 -15
  4. package/bin/generate/templates/nonopinionated/module.tpl +1 -2
  5. package/bin/generate/templates/opinionated/controller-service-delete.tpl +6 -14
  6. package/bin/generate/templates/opinionated/controller-service-get.tpl +7 -15
  7. package/bin/generate/templates/opinionated/controller-service-patch.tpl +7 -17
  8. package/bin/generate/templates/opinionated/controller-service-post.tpl +7 -14
  9. package/bin/generate/templates/opinionated/controller-service-put.tpl +7 -17
  10. package/bin/generate/templates/opinionated/controller-service.tpl +1 -2
  11. package/bin/generate/templates/opinionated/module-service.tpl +1 -2
  12. package/bin/generate/templates/opinionated/module.tpl +1 -2
  13. package/bin/generate/utils/command-utils.d.ts +1 -1
  14. package/bin/generate/utils/command-utils.js +12 -12
  15. package/bin/generate/utils/nonopininated-cmd.d.ts +1 -1
  16. package/bin/generate/utils/nonopininated-cmd.js +12 -12
  17. package/bin/generate/utils/opinionated-cmd.d.ts +1 -1
  18. package/bin/generate/utils/opinionated-cmd.js +12 -12
  19. package/bin/generate/utils/string-utils.d.ts +36 -0
  20. package/bin/generate/utils/string-utils.js +71 -0
  21. package/bin/help/form.js +6 -2
  22. package/bin/index.d.ts +0 -1
  23. package/bin/index.js +0 -1
  24. package/bin/info/form.js +3 -13
  25. package/bin/new/form.js +37 -21
  26. package/bin/providers/add/cli.d.ts +1 -0
  27. package/bin/providers/add/cli.js +27 -4
  28. package/bin/providers/add/form.d.ts +2 -1
  29. package/bin/providers/add/form.js +72 -39
  30. package/bin/providers/create/form.js +1 -1
  31. package/bin/scripts/cli.d.ts +3 -0
  32. package/bin/scripts/cli.js +24 -0
  33. package/bin/scripts/form.d.ts +1 -0
  34. package/bin/scripts/form.js +107 -0
  35. package/bin/scripts/index.d.ts +1 -0
  36. package/bin/{@types → scripts}/index.js +1 -1
  37. package/bin/utils/add-module-to-container.js +16 -11
  38. package/bin/utils/compiler.d.ts +1 -1
  39. package/package.json +19 -20
  40. package/bin/@types/config.d.ts +0 -39
  41. package/bin/@types/config.js +0 -2
  42. package/bin/@types/index.d.ts +0 -1
  43. package/bin/app.container.d.ts +0 -1
  44. package/bin/app.container.js +0 -8
  45. package/bin/commands/__tests__/project.commands.spec.d.ts +0 -1
  46. package/bin/commands/__tests__/project.commands.spec.js +0 -8
  47. package/bin/types.d.ts +0 -1
  48. package/bin/types.js +0 -17
@@ -9,11 +9,12 @@ const glob_1 = require("glob");
9
9
  const node_fs_1 = __importDefault(require("node:fs"));
10
10
  const cli_ui_1 = require("./cli-ui");
11
11
  const compiler_1 = __importDefault(require("./compiler"));
12
- const APP_CONTAINER = "app.container.ts";
12
+ const APP_CONTAINER = "app.ts";
13
13
  async function validateAppContainer() {
14
14
  const { sourceRoot } = await compiler_1.default.loadConfig();
15
15
  const imports = [];
16
16
  const notImports = [];
17
+ // Locate the container file
17
18
  const path = (0, glob_1.globSync)(`./${sourceRoot}/${APP_CONTAINER}`, {
18
19
  absolute: true,
19
20
  ignore: "**/node_modules/**",
@@ -22,7 +23,9 @@ async function validateAppContainer() {
22
23
  (0, cli_ui_1.printError)("Module not added to Container. Container file not found!", APP_CONTAINER);
23
24
  process.exit(1);
24
25
  }
26
+ // Read the container file
25
27
  const fileContent = await node_fs_1.default.promises.readFile(path[0], "utf8");
28
+ // Collect imports and other lines
26
29
  fileContent.split("\n").forEach((line) => {
27
30
  if (line.startsWith("import")) {
28
31
  imports.push(line);
@@ -31,28 +34,30 @@ async function validateAppContainer() {
31
34
  notImports.push(line);
32
35
  }
33
36
  });
34
- // Validate the file content
35
- const moduleDeclarationRegex = /.create\(\s*\[([\s\S]*?)]/;
36
- const moduleDeclarationMatch = fileContent.match(moduleDeclarationRegex);
37
- if (!moduleDeclarationMatch) {
38
- (0, cli_ui_1.printError)("Container format incorrect!", APP_CONTAINER);
37
+ // Regex to detect and extract modules from configContainer
38
+ const moduleRegex = /this\.configContainer\(\s*\[\s*([\s\S]*?)\s*]\s*\)/;
39
+ const moduleMatch = fileContent.match(moduleRegex);
40
+ if (!moduleMatch) {
41
+ (0, cli_ui_1.printError)("The App class does not contain a valid configContainer([]) declaration!", APP_CONTAINER);
39
42
  process.exit(1);
40
43
  }
41
- const modules = moduleDeclarationMatch[1]
44
+ // Extract modules if present
45
+ const modules = moduleMatch[1]
42
46
  .trim()
43
47
  .split(",")
44
48
  .filter((m) => m.trim() !== "")
45
49
  .map((m) => m.trim());
46
50
  return {
47
- regex: moduleDeclarationRegex,
51
+ regex: moduleRegex,
48
52
  path: path[0],
49
- content: moduleDeclarationMatch,
53
+ content: fileContent,
50
54
  modules,
51
55
  imports,
52
56
  notImports,
53
57
  };
54
58
  }
55
59
  async function addModuleToContainer(name, modulePath, path) {
60
+ console.log("To chamando esse cara");
56
61
  const containerData = await validateAppContainer();
57
62
  const moduleName = (name[0].toUpperCase() + name.slice(1)).trimStart();
58
63
  const { opinionated } = await compiler_1.default.loadConfig();
@@ -83,7 +88,7 @@ async function addModuleToContainer(name, modulePath, path) {
83
88
  containerData.imports.push(newImport);
84
89
  containerData.modules.push(`${moduleName}Module`);
85
90
  const newModule = containerData.modules.join(", ");
86
- const newModuleDeclaration = `.create([${newModule}]`;
91
+ const newModuleDeclaration = `this.configContainer([${newModule}])`;
87
92
  const newFileContent = [
88
93
  ...containerData.imports,
89
94
  ...containerData.notImports,
@@ -116,7 +121,7 @@ async function addModuleToContainerNestedPath(name, path) {
116
121
  containerData.imports.push(newImport);
117
122
  containerData.modules.push(`${moduleName}Module`);
118
123
  const newModule = containerData.modules.join(", ");
119
- const newModuleDeclaration = `.create([${newModule}]`;
124
+ const newModuleDeclaration = `this.configContainer([${newModule}])`;
120
125
  const newFileContent = [
121
126
  ...containerData.imports,
122
127
  ...containerData.notImports,
@@ -1,5 +1,5 @@
1
1
  import { Service } from "ts-node";
2
- import { ExpressoConfig } from "../types";
2
+ import { ExpressoConfig } from "@expressots/shared";
3
3
  /**
4
4
  * Singleton compiler class
5
5
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@expressots/cli",
3
- "version": "1.11.1",
3
+ "version": "3.0.0-beta.1",
4
4
  "description": "Expressots CLI - modern, fast, lightweight nodejs web framework (@cli)",
5
5
  "author": "Richard Zampieri",
6
6
  "license": "MIT",
@@ -8,10 +8,11 @@
8
8
  "url": "https://github.com/expressots/expressots-cli/issues"
9
9
  },
10
10
  "bin": {
11
- "expressots": "bin/cli.js"
11
+ "expressots": "bin/cli.js",
12
+ "ex": "bin/cli.js"
12
13
  },
13
14
  "engines": {
14
- "node": ">=18.0.0"
15
+ "node": ">=20.18.0"
15
16
  },
16
17
  "funding": {
17
18
  "type": "github",
@@ -34,23 +35,22 @@
34
35
  "prepare": "husky",
35
36
  "start:build": "npm run build && npm run start",
36
37
  "start": "node ./bin/cli.js",
37
- "start:dev": "tsnd ./src/cli.ts",
38
- "build": "npm run clean && tsc -p tsconfig.json && yarn cp:templates && chmod +x ./bin/cli.js",
39
- "cp:templates": "cp -r ./src/generate/templates ./bin/generate/templates",
40
- "clean": "rimraf ./bin",
38
+ "start:dev": "tsx ./src/cli.ts",
39
+ "build": "npm run clean && tsc -p tsconfig.json && npm run cp:templates && node scripts/chmod.js ./bin/cli.js",
40
+ "cp:templates": "node scripts/cp.js ./src/generate/templates ./bin/generate/",
41
+ "clean": "node scripts/rm.js bin",
41
42
  "prepublish": "npm run build && npm pack",
42
43
  "publish": "npm publish --tag latest",
43
44
  "format": "prettier --write \"./src/**/*.ts\" --cache",
44
45
  "lint": "eslint \"./src/**/*.ts\"",
45
46
  "lint:fix": "eslint \"./src/**/*.ts\" --fix",
46
47
  "release": "release-it",
47
- "test": "vitest run --reporter default",
48
- "test:watch": "vitest",
49
- "coverage": "vitest run --coverage"
48
+ "test": "jest",
49
+ "coverage": "jest --coverage",
50
+ "test:watch": "jest --watch"
50
51
  },
51
52
  "dependencies": {
52
- "@expressots/boost-ts": "1.3.0",
53
- "axios": "^1.7.3",
53
+ "axios": "1.7.7",
54
54
  "chalk-animation": "2.0.3",
55
55
  "cli-progress": "3.12.0",
56
56
  "cli-table3": "0.6.5",
@@ -58,7 +58,7 @@
58
58
  "glob": "10.4.5",
59
59
  "inquirer": "8.2.6",
60
60
  "mustache": "4.2.0",
61
- "semver": "7.6.2",
61
+ "semver": "7.6.3",
62
62
  "ts-node": "10.9.2",
63
63
  "yargs": "17.7.2"
64
64
  },
@@ -66,31 +66,30 @@
66
66
  "@codecov/vite-plugin": "^0.0.1-beta.9",
67
67
  "@commitlint/cli": "19.2.1",
68
68
  "@commitlint/config-conventional": "19.1.0",
69
+ "@expressots/shared": "0.1.0",
69
70
  "@release-it/conventional-changelog": "7.0.2",
70
71
  "@types/chalk-animation": "1.6.1",
71
72
  "@types/cli-progress": "3.11.0",
72
73
  "@types/degit": "2.8.3",
73
74
  "@types/inquirer": "9.0.3",
75
+ "@types/jest": "^29.5.14",
74
76
  "@types/mustache": "4.2.2",
75
77
  "@types/node": "20.12.7",
76
78
  "@types/yargs": "17.0.22",
77
79
  "@typescript-eslint/eslint-plugin": "7.6.0",
78
80
  "@typescript-eslint/parser": "7.6.0",
79
- "@vitest/coverage-v8": "1.4.0",
80
81
  "chalk": "4.1.2",
81
82
  "eslint": "8.57.0",
82
83
  "eslint-config-prettier": "9.1.0",
83
84
  "husky": "9.0.11",
85
+ "jest": "^29.7.0",
84
86
  "prettier": "3.2.5",
85
87
  "reflect-metadata": "0.2.2",
86
88
  "release-it": "16.3.0",
87
- "rimraf": "5.0.5",
88
89
  "shx": "0.3.4",
89
- "ts-node-dev": "2.0.0",
90
- "typescript": "5.2.2",
91
- "vite": "5.2.8",
92
- "vite-tsconfig-paths": "4.3.2",
93
- "vitest": "1.4.0"
90
+ "ts-jest": "^29.2.5",
91
+ "tsx": "^4.19.2",
92
+ "typescript": "5.2.2"
94
93
  },
95
94
  "release-it": {
96
95
  "git": {
@@ -1,39 +0,0 @@
1
- export declare const enum Pattern {
2
- LOWER_CASE = "lowercase",
3
- KEBAB_CASE = "kebab-case",
4
- PASCAL_CASE = "PascalCase",
5
- CAMEL_CASE = "camelCase"
6
- }
7
- interface IProviders {
8
- prisma?: {
9
- schemaName: string;
10
- schemaPath: string;
11
- entitiesPath: string;
12
- entityNamePattern: string;
13
- };
14
- }
15
- /**
16
- * The configuration object for the Expresso CLI.
17
- *
18
- * @property {Pattern} scaffoldPattern - The pattern to use when scaffolding files.
19
- * @property {string} sourceRoot - The root directory for the source files.
20
- * @property {boolean} opinionated - Whether or not to use the opinionated configuration.
21
- *
22
- * @see [ExpressoConfig](https://expresso-ts.com/docs)
23
- */
24
- export interface ExpressoConfig {
25
- scaffoldPattern: Pattern;
26
- sourceRoot: string;
27
- opinionated: boolean;
28
- providers?: IProviders;
29
- scaffoldSchematics?: {
30
- entity?: string;
31
- controller?: string;
32
- usecase?: string;
33
- dto?: string;
34
- module?: string;
35
- provider?: string;
36
- middleware?: string;
37
- };
38
- }
39
- export {};
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1 +0,0 @@
1
- export * from "./config";
@@ -1 +0,0 @@
1
- export {};
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- /* import { AppContainer } from "@expressots/core";
4
-
5
- export const appContainer = new AppContainer();
6
-
7
- export const container = appContainer.create([]);
8
- */
@@ -1 +0,0 @@
1
- export {};
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const vitest_1 = require("vitest");
4
- (0, vitest_1.describe)("project.commands", () => {
5
- (0, vitest_1.it)("should return a list of commands", () => {
6
- (0, vitest_1.expect)(true).toBe(true);
7
- });
8
- });
package/bin/types.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from "./@types";
package/bin/types.js DELETED
@@ -1,17 +0,0 @@
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("./@types"), exports);