@expressots/shared 3.0.0 → 4.0.0-preview.3

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 (66) hide show
  1. package/LICENSE.md +21 -21
  2. package/README.md +51 -118
  3. package/lib/CHANGELOG.md +27 -7
  4. package/lib/README.md +51 -118
  5. package/lib/cjs/config/index.js +3 -0
  6. package/lib/cjs/config/project-config.js +17 -0
  7. package/lib/cjs/env/cli-options.js +2 -2
  8. package/lib/cjs/env/environment.js +17 -17
  9. package/lib/cjs/env/index.js +1 -1
  10. package/lib/cjs/index.js +4 -4
  11. package/lib/cjs/interfaces/index.js +3 -5
  12. package/lib/cjs/types/config/index.d.ts +1 -1
  13. package/lib/cjs/types/config/project-config.d.ts +6 -1
  14. package/lib/cjs/types/env/cli-options.d.ts +1 -1
  15. package/lib/cjs/types/env/env-options.d.ts +1 -1
  16. package/lib/cjs/types/env/environment.d.ts +1 -1
  17. package/lib/cjs/types/env/index.d.ts +2 -2
  18. package/lib/cjs/types/index.d.ts +4 -4
  19. package/lib/cjs/types/interfaces/application-express.interface.d.ts +9 -4
  20. package/lib/cjs/types/interfaces/console.interface.d.ts +6 -0
  21. package/lib/cjs/types/interfaces/index.d.ts +5 -5
  22. package/lib/cjs/types/interfaces/render/render.types.d.ts +1 -1
  23. package/lib/cjs/types/utils/compiler.d.ts +1 -1
  24. package/lib/cjs/types/utils/index.d.ts +1 -1
  25. package/lib/cjs/utils/index.js +2 -2
  26. package/lib/esm/config/index.js +1 -0
  27. package/lib/esm/config/project-config.js +16 -0
  28. package/lib/esm/env/cli-options.js +15 -0
  29. package/lib/esm/env/constants.js +10 -0
  30. package/lib/esm/env/env-options.js +19 -0
  31. package/lib/esm/env/environment.js +304 -0
  32. package/lib/esm/env/index.js +1 -0
  33. package/lib/esm/env/interfaces.js +1 -0
  34. package/lib/esm/index.mjs +4 -0
  35. package/lib/esm/interfaces/application-express.interface.js +1 -0
  36. package/lib/esm/interfaces/console.interface.js +1 -0
  37. package/lib/esm/interfaces/environment.interface.js +19 -0
  38. package/lib/esm/interfaces/index.js +1 -0
  39. package/lib/esm/interfaces/middleware.interface.js +1 -0
  40. package/lib/esm/interfaces/render/ejs.types.js +2 -0
  41. package/lib/esm/interfaces/render/render.types.js +20 -0
  42. package/lib/esm/package.json +3 -0
  43. package/lib/esm/types/config/index.d.ts +1 -0
  44. package/lib/esm/types/config/project-config.d.ts +43 -0
  45. package/lib/esm/types/env/cli-options.d.ts +7 -0
  46. package/lib/esm/types/env/constants.d.ts +10 -0
  47. package/lib/esm/types/env/env-options.d.ts +9 -0
  48. package/lib/esm/types/env/environment.d.ts +83 -0
  49. package/lib/esm/types/env/index.d.ts +2 -0
  50. package/lib/esm/types/env/interfaces.d.ts +71 -0
  51. package/lib/esm/types/index.d.ts +4 -0
  52. package/lib/esm/types/interfaces/application-express.interface.d.ts +58 -0
  53. package/lib/esm/types/interfaces/console.interface.d.ts +14 -0
  54. package/lib/esm/types/interfaces/environment.interface.d.ts +37 -0
  55. package/lib/esm/types/interfaces/index.d.ts +5 -0
  56. package/lib/esm/types/interfaces/middleware.interface.d.ts +7 -0
  57. package/lib/esm/types/interfaces/render/ejs.types.d.ts +169 -0
  58. package/lib/esm/types/interfaces/render/render.types.d.ts +71 -0
  59. package/lib/esm/types/utils/compiler.d.ts +17 -0
  60. package/lib/esm/types/utils/index.d.ts +1 -0
  61. package/lib/esm/types/utils/logger.d.ts +19 -0
  62. package/lib/esm/utils/compiler.js +69 -0
  63. package/lib/esm/utils/index.js +1 -0
  64. package/lib/esm/utils/logger.js +60 -0
  65. package/lib/package.json +167 -147
  66. package/package.json +167 -147
@@ -0,0 +1,60 @@
1
+ import { stdout } from "process";
2
+ import chalk from "chalk";
3
+ /**
4
+ * Logger utility for dotenv
5
+ */
6
+ export var LogLevel;
7
+ (function (LogLevel) {
8
+ LogLevel["Info"] = "info";
9
+ LogLevel["Warn"] = "warn";
10
+ LogLevel["Debug"] = "debug";
11
+ })(LogLevel || (LogLevel = {}));
12
+ /**
13
+ * Log a message
14
+ * @param message - The message to log
15
+ * @param logLevel - The log level. Defaults to LogLevel.Info
16
+ */
17
+ export function log(message, logLevel = LogLevel.Info) {
18
+ switch (logLevel) {
19
+ case LogLevel.Info:
20
+ stdout.write(`[ExpressoTS][INFO] ${message}\n`);
21
+ break;
22
+ case LogLevel.Warn:
23
+ stdout.write(`[ExpressoTS][WARN] ${message}\n`);
24
+ break;
25
+ case LogLevel.Debug:
26
+ stdout.write(`[ExpressoTS][DEBUG] ${message}\n`);
27
+ break;
28
+ }
29
+ }
30
+ export function printError(message, component) {
31
+ const formattedMessage = message ? `${message}: ` : ": ";
32
+ const formattedComponent = component ? `[${component}]` : "[]";
33
+ const output = chalk.red(`${formattedMessage}${chalk.bold(chalk.white(`${formattedComponent} ❌\n`))}`);
34
+ stdout.write(output);
35
+ }
36
+ export function printSuccess(message, component) {
37
+ const formattedMessage = message ? `${message}: ` : ": ";
38
+ const formattedComponent = component ? `[${component}]` : "[]";
39
+ const output = chalk.green(`${formattedMessage}${chalk.bold(chalk.white(`${formattedComponent} ✔️\n`))}`);
40
+ stdout.write(output);
41
+ }
42
+ export function printWarning(message, component) {
43
+ if (component === undefined) {
44
+ stdout.write(chalk.yellow(`${message} ⚠️\n`));
45
+ return;
46
+ }
47
+ stdout.write(chalk.yellow(`${message}:`, chalk.bold(chalk.white(`[${component}] ⚠️\n`))));
48
+ }
49
+ export async function printGenerateError(schematic, file) {
50
+ const schematicFormatted = `[${schematic}]`.padEnd(14);
51
+ const fileNameFormatted = chalk.bold.white(`${file.split(".")[0]} not created! ❌\n`);
52
+ const output = chalk.redBright(schematicFormatted) + fileNameFormatted;
53
+ stdout.write(output);
54
+ }
55
+ export async function printGenerateSuccess(schematic, file) {
56
+ const schematicFormatted = `[${schematic}]`.padEnd(14);
57
+ const fileNameFormatted = chalk.bold.white(`${file.split(".")[0]} created! ✔️\n`);
58
+ const output = chalk.greenBright(schematicFormatted) + fileNameFormatted;
59
+ stdout.write(output);
60
+ }
package/lib/package.json CHANGED
@@ -1,147 +1,167 @@
1
- {
2
- "name": "@expressots/shared",
3
- "version": "3.0.0",
4
- "description": "Shared library for ExpressoTS modules 🐎",
5
- "author": "Richard Zampieri <richard.zampieri@expresso-ts.com>",
6
- "main": "./lib/cjs/index.js",
7
- "types": "./lib/cjs/types/index.d.ts",
8
- "exports": {
9
- ".": {
10
- "import": {
11
- "types": "./lib/esm/types/index.d.ts",
12
- "default": "./lib/esm/index.mjs"
13
- },
14
- "require": {
15
- "types": "./lib/cjs/types/index.d.ts",
16
- "default": "./lib/cjs/index.js"
17
- }
18
- }
19
- },
20
- "files": [
21
- "lib/**/*"
22
- ],
23
- "license": "MIT",
24
- "homepage": "https://expresso-ts.com",
25
- "funding": {
26
- "type": "github",
27
- "url": "https://github.com/sponsors/expressots"
28
- },
29
- "repository": {
30
- "type": "git",
31
- "url": "https://github.com/expressots/shared"
32
- },
33
- "bugs": {
34
- "url": "https://github.com/expressots/shared/issues"
35
- },
36
- "publishConfig": {
37
- "access": "public"
38
- },
39
- "keywords": [
40
- "expressots",
41
- "nodejs",
42
- "typescript",
43
- "clean-architecture",
44
- "typescript-framework",
45
- "framework",
46
- "server-side",
47
- "backend",
48
- "library"
49
- ],
50
- "scripts": {
51
- "prepare": "husky",
52
- "clean": "node scripts/rm.js lib",
53
- "copy": "node scripts/copy.js package.json README.md CHANGELOG.md lib",
54
- "build": "npm run clean && npm run build:cjs && npm run copy",
55
- "build:cjs": "tsc -p tsconfig.cjs.json",
56
- "build:esm": "tsc -p tsconfig.esm.json",
57
- "release": "release-it",
58
- "prepublish": "npm run build && npm pack",
59
- "publish": "npm publish --tag latest",
60
- "test": "jest",
61
- "test:watch": "jest --watch",
62
- "coverage": "jest --coverage",
63
- "format": "prettier --write \"src/**/*.ts\" --cache",
64
- "lint": "eslint \"src/**/*.ts\"",
65
- "lint:fix": "eslint \"src/**/*.ts\" --fix"
66
- },
67
- "dependencies": {
68
- "reflect-metadata": "0.2.2",
69
- "ts-node": "10.9.2"
70
- },
71
- "devDependencies": {
72
- "@commitlint/cli": "19.4.1",
73
- "@commitlint/config-conventional": "19.2.2",
74
- "@release-it/conventional-changelog": "8.0.1",
75
- "@types/express": "4.17.21",
76
- "@types/jest": "29.5.13",
77
- "@types/node": "20.14.10",
78
- "@typescript-eslint/eslint-plugin": "7.16.1",
79
- "@typescript-eslint/parser": "7.16.1",
80
- "chalk": "4.1.2",
81
- "eslint": "8.57.0",
82
- "eslint-config-prettier": "9.1.0",
83
- "husky": "9.1.1",
84
- "jest": "29.7.0",
85
- "prettier": "3.3.3",
86
- "release-it": "17.6.0",
87
- "ts-jest": "29.2.5",
88
- "typescript": "5.5.3"
89
- },
90
- "release-it": {
91
- "git": {
92
- "commitMessage": "chore(release): ${version}"
93
- },
94
- "github": {
95
- "release": true
96
- },
97
- "npm": {
98
- "publish": false
99
- },
100
- "plugins": {
101
- "@release-it/conventional-changelog": {
102
- "infile": "CHANGELOG.md",
103
- "preset": {
104
- "name": "conventionalcommits",
105
- "types": [
106
- {
107
- "type": "feat",
108
- "section": "Features"
109
- },
110
- {
111
- "type": "fix",
112
- "section": "Bug Fixes"
113
- },
114
- {
115
- "type": "perf",
116
- "section": "Performance Improvements"
117
- },
118
- {
119
- "type": "revert",
120
- "section": "Reverts"
121
- },
122
- {
123
- "type": "docs",
124
- "section": "Documentation"
125
- },
126
- {
127
- "type": "refactor",
128
- "section": "Code Refactoring"
129
- },
130
- {
131
- "type": "test",
132
- "section": "Tests"
133
- },
134
- {
135
- "type": "build",
136
- "section": "Build System"
137
- },
138
- {
139
- "type": "ci",
140
- "section": "Continuous Integrations"
141
- }
142
- ]
143
- }
144
- }
145
- }
146
- }
147
- }
1
+ {
2
+ "name": "@expressots/shared",
3
+ "version": "4.0.0-preview.3",
4
+ "description": "Shared library for ExpressoTS modules 🐎",
5
+ "author": "Richard Zampieri <richard.zampieri@expresso-ts.com>",
6
+ "main": "./lib/cjs/index.js",
7
+ "types": "./lib/cjs/types/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": {
11
+ "types": "./lib/esm/types/index.d.ts",
12
+ "default": "./lib/esm/index.mjs"
13
+ },
14
+ "require": {
15
+ "types": "./lib/cjs/types/index.d.ts",
16
+ "default": "./lib/cjs/index.js"
17
+ }
18
+ }
19
+ },
20
+ "files": [
21
+ "lib/**/*"
22
+ ],
23
+ "license": "MIT",
24
+ "homepage": "https://expresso-ts.com",
25
+ "funding": {
26
+ "type": "github",
27
+ "url": "https://github.com/sponsors/expressots"
28
+ },
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "https://github.com/expressots/shared"
32
+ },
33
+ "bugs": {
34
+ "url": "https://github.com/expressots/shared/issues"
35
+ },
36
+ "publishConfig": {
37
+ "access": "public"
38
+ },
39
+ "engines": {
40
+ "node": ">=20.18.0"
41
+ },
42
+ "keywords": [
43
+ "expressots",
44
+ "nodejs",
45
+ "typescript",
46
+ "clean-architecture",
47
+ "typescript-framework",
48
+ "framework",
49
+ "server-side",
50
+ "backend",
51
+ "library"
52
+ ],
53
+ "scripts": {
54
+ "prepare": "husky",
55
+ "clean": "node scripts/rm.js lib",
56
+ "copy": "node scripts/copy.js package.json README.md CHANGELOG.md lib",
57
+ "build": "npm run clean && npm run build:cjs && npm run build:esm && npm run copy",
58
+ "build:cjs": "tsc -p tsconfig.cjs.json",
59
+ "build:esm": "node scripts/build-esm.js",
60
+ "release": "release-it",
61
+ "release:prepare": "node scripts/release/prepare-publish.mjs",
62
+ "release:restore": "node scripts/release/restore-package-json.mjs",
63
+ "release:publish": "npm run build && npm run release:prepare && npm publish --tag next --access public && npm run release:restore",
64
+ "prepublish": "npm run build && npm pack",
65
+ "test": "jest",
66
+ "test:watch": "jest --watch",
67
+ "coverage": "jest --coverage",
68
+ "format": "prettier --write \"src/**/*.ts\" --cache",
69
+ "lint": "eslint \"src/**/*.ts\" --cache --cache-location node_modules/.cache/eslint/",
70
+ "lint:fix": "eslint \"src/**/*.ts\" --fix --cache --cache-location node_modules/.cache/eslint/"
71
+ },
72
+ "dependencies": {
73
+ "chalk": "4.1.2"
74
+ },
75
+ "peerDependencies": {
76
+ "ts-node": ">=10.0.0"
77
+ },
78
+ "peerDependenciesMeta": {
79
+ "ts-node": {
80
+ "optional": true
81
+ }
82
+ },
83
+ "devDependencies": {
84
+ "@commitlint/cli": "19.6.0",
85
+ "@commitlint/config-conventional": "19.6.0",
86
+ "@release-it/conventional-changelog": "^11.0.0",
87
+ "@types/express": "4.17.21",
88
+ "@types/jest": "29.5.13",
89
+ "@types/node": "20.14.10",
90
+ "@typescript-eslint/eslint-plugin": "8.25.0",
91
+ "@typescript-eslint/parser": "8.25.0",
92
+ "eslint": "8.57.0",
93
+ "eslint-config-prettier": "10.0.2",
94
+ "husky": "9.1.1",
95
+ "jest": "29.7.0",
96
+ "lint-staged": "^15.2.10",
97
+ "prettier": "3.5.3",
98
+ "reflect-metadata": "0.2.2",
99
+ "release-it": "^20.0.1",
100
+ "ts-jest": "29.2.5",
101
+ "ts-node": "10.9.2",
102
+ "typescript": "5.5.3"
103
+ },
104
+ "lint-staged": {
105
+ "src/**/*.ts": [
106
+ "eslint --cache --cache-location node_modules/.cache/eslint/ --fix",
107
+ "prettier --write --cache"
108
+ ]
109
+ },
110
+ "release-it": {
111
+ "git": {
112
+ "commitMessage": "chore(release): ${version}"
113
+ },
114
+ "github": {
115
+ "release": true
116
+ },
117
+ "npm": {
118
+ "publish": false
119
+ },
120
+ "plugins": {
121
+ "@release-it/conventional-changelog": {
122
+ "infile": "CHANGELOG.md",
123
+ "preset": {
124
+ "name": "conventionalcommits",
125
+ "types": [
126
+ {
127
+ "type": "feat",
128
+ "section": "Features"
129
+ },
130
+ {
131
+ "type": "fix",
132
+ "section": "Bug Fixes"
133
+ },
134
+ {
135
+ "type": "perf",
136
+ "section": "Performance Improvements"
137
+ },
138
+ {
139
+ "type": "revert",
140
+ "section": "Reverts"
141
+ },
142
+ {
143
+ "type": "docs",
144
+ "section": "Documentation"
145
+ },
146
+ {
147
+ "type": "refactor",
148
+ "section": "Code Refactoring"
149
+ },
150
+ {
151
+ "type": "test",
152
+ "section": "Tests"
153
+ },
154
+ {
155
+ "type": "build",
156
+ "section": "Build System"
157
+ },
158
+ {
159
+ "type": "ci",
160
+ "section": "Continuous Integrations"
161
+ }
162
+ ]
163
+ }
164
+ }
165
+ }
166
+ }
167
+ }