proteum 1.0.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.
- package/.dockerignore +10 -0
- package/Rte.zip +0 -0
- package/cli/app/config.ts +54 -0
- package/cli/app/index.ts +195 -0
- package/cli/bin.js +11 -0
- package/cli/commands/build.ts +34 -0
- package/cli/commands/deploy/app.ts +29 -0
- package/cli/commands/deploy/web.ts +60 -0
- package/cli/commands/dev.ts +109 -0
- package/cli/commands/init.ts +85 -0
- package/cli/compiler/client/identite.ts +72 -0
- package/cli/compiler/client/index.ts +334 -0
- package/cli/compiler/common/babel/index.ts +170 -0
- package/cli/compiler/common/babel/plugins/index.ts +0 -0
- package/cli/compiler/common/babel/plugins/services.ts +579 -0
- package/cli/compiler/common/babel/routes/imports.ts +127 -0
- package/cli/compiler/common/babel/routes/routes.ts +1130 -0
- package/cli/compiler/common/files/autres.ts +39 -0
- package/cli/compiler/common/files/images.ts +35 -0
- package/cli/compiler/common/files/style.ts +78 -0
- package/cli/compiler/common/index.ts +154 -0
- package/cli/compiler/index.ts +532 -0
- package/cli/compiler/server/index.ts +211 -0
- package/cli/index.ts +189 -0
- package/cli/paths.ts +165 -0
- package/cli/print.ts +12 -0
- package/cli/tsconfig.json +38 -0
- package/cli/utils/index.ts +22 -0
- package/cli/utils/keyboard.ts +78 -0
- package/client/app/component.tsx +54 -0
- package/client/app/index.ts +142 -0
- package/client/app/service.ts +34 -0
- package/client/app.tsconfig.json +28 -0
- package/client/components/Button.tsx +298 -0
- package/client/components/Dialog/Manager.tsx +309 -0
- package/client/components/Dialog/card.tsx +208 -0
- package/client/components/Dialog/index.less +151 -0
- package/client/components/Dialog/status.less +176 -0
- package/client/components/Dialog/status.tsx +48 -0
- package/client/components/index.ts +2 -0
- package/client/components/types.d.ts +3 -0
- package/client/data/input.ts +32 -0
- package/client/global.d.ts +5 -0
- package/client/hooks.ts +22 -0
- package/client/index.ts +6 -0
- package/client/pages/_layout/index.less +6 -0
- package/client/pages/_layout/index.tsx +43 -0
- package/client/pages/bug.tsx.old +60 -0
- package/client/pages/useHeader.tsx +50 -0
- package/client/services/captcha/index.ts +67 -0
- package/client/services/router/components/Link.tsx +46 -0
- package/client/services/router/components/Page.tsx +55 -0
- package/client/services/router/components/router.tsx +218 -0
- package/client/services/router/index.tsx +521 -0
- package/client/services/router/request/api.ts +267 -0
- package/client/services/router/request/history.ts +5 -0
- package/client/services/router/request/index.ts +53 -0
- package/client/services/router/request/multipart.ts +147 -0
- package/client/services/router/response/index.tsx +128 -0
- package/client/services/router/response/page.ts +86 -0
- package/client/services/socket/index.ts +147 -0
- package/client/utils/dom.ts +77 -0
- package/common/app/index.ts +9 -0
- package/common/data/chaines/index.ts +54 -0
- package/common/data/dates.ts +179 -0
- package/common/data/markdown.ts +73 -0
- package/common/data/rte/nodes.ts +83 -0
- package/common/data/stats.ts +90 -0
- package/common/errors/index.tsx +326 -0
- package/common/router/index.ts +213 -0
- package/common/router/layouts.ts +93 -0
- package/common/router/register.ts +55 -0
- package/common/router/request/api.ts +77 -0
- package/common/router/request/index.ts +35 -0
- package/common/router/response/index.ts +45 -0
- package/common/router/response/page.ts +128 -0
- package/common/utils/rte.ts +183 -0
- package/common/utils.ts +7 -0
- package/doc/TODO.md +71 -0
- package/doc/front/router.md +27 -0
- package/doc/workspace/workspace.png +0 -0
- package/doc/workspace/workspace2.png +0 -0
- package/doc/workspace/workspace_26.01.22.png +0 -0
- package/package.json +171 -0
- package/server/app/commands.ts +141 -0
- package/server/app/container/config.ts +203 -0
- package/server/app/container/console/index.ts +550 -0
- package/server/app/container/index.ts +137 -0
- package/server/app/index.ts +273 -0
- package/server/app/service/container.ts +88 -0
- package/server/app/service/index.ts +235 -0
- package/server/app.tsconfig.json +28 -0
- package/server/context.ts +4 -0
- package/server/index.ts +4 -0
- package/server/services/auth/index.ts +250 -0
- package/server/services/auth/old.ts +277 -0
- package/server/services/auth/router/index.ts +95 -0
- package/server/services/auth/router/request.ts +54 -0
- package/server/services/auth/router/service.json +6 -0
- package/server/services/auth/service.json +6 -0
- package/server/services/cache/commands.ts +41 -0
- package/server/services/cache/index.ts +297 -0
- package/server/services/cache/service.json +6 -0
- package/server/services/cron/CronTask.ts +86 -0
- package/server/services/cron/index.ts +112 -0
- package/server/services/cron/service.json +6 -0
- package/server/services/disks/driver.ts +103 -0
- package/server/services/disks/drivers/local/index.ts +188 -0
- package/server/services/disks/drivers/local/service.json +6 -0
- package/server/services/disks/drivers/s3/index.ts +301 -0
- package/server/services/disks/drivers/s3/service.json +6 -0
- package/server/services/disks/index.ts +90 -0
- package/server/services/disks/service.json +6 -0
- package/server/services/email/index.ts +188 -0
- package/server/services/email/utils.ts +53 -0
- package/server/services/fetch/index.ts +201 -0
- package/server/services/fetch/service.json +7 -0
- package/server/services/models.7z +0 -0
- package/server/services/prisma/Facet.ts +142 -0
- package/server/services/prisma/index.ts +201 -0
- package/server/services/prisma/service.json +6 -0
- package/server/services/router/http/index.ts +217 -0
- package/server/services/router/http/multipart.ts +102 -0
- package/server/services/router/http/session.ts.old +40 -0
- package/server/services/router/index.ts +801 -0
- package/server/services/router/request/api.ts +87 -0
- package/server/services/router/request/index.ts +184 -0
- package/server/services/router/request/service.ts +21 -0
- package/server/services/router/request/validation/zod.ts +180 -0
- package/server/services/router/response/index.ts +338 -0
- package/server/services/router/response/mask/Filter.ts +323 -0
- package/server/services/router/response/mask/index.ts +60 -0
- package/server/services/router/response/mask/selecteurs.ts +92 -0
- package/server/services/router/response/page/document.tsx +160 -0
- package/server/services/router/response/page/index.tsx +196 -0
- package/server/services/router/service.json +6 -0
- package/server/services/router/service.ts +36 -0
- package/server/services/schema/index.ts +44 -0
- package/server/services/schema/request.ts +49 -0
- package/server/services/schema/router/index.ts +28 -0
- package/server/services/schema/router/service.json +6 -0
- package/server/services/schema/service.json +6 -0
- package/server/services/security/encrypt/aes/index.ts +85 -0
- package/server/services/security/encrypt/aes/service.json +6 -0
- package/server/services/socket/index.ts +162 -0
- package/server/services/socket/scope.ts +226 -0
- package/server/services/socket/service.json +6 -0
- package/server/services_old/SocketClient.ts +92 -0
- package/server/services_old/Token.old.ts +97 -0
- package/server/utils/slug.ts +79 -0
- package/tsconfig.common.json +45 -0
- package/tsconfig.json +3 -0
- package/types/aliases.d.ts +54 -0
- package/types/global/modules.d.ts +49 -0
- package/types/global/utils.d.ts +103 -0
- package/types/icons.d.ts +1 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Disallowed
|
|
2
|
+
|
|
3
|
+
- To destructure page data objects
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
route.page('/withdraw', { bodyId: 'withdraw' }, ({}, { api }) => ({
|
|
7
|
+
|
|
8
|
+
withdraw: api.get('/withdraw')
|
|
9
|
+
|
|
10
|
+
}), ({ withdraw: { history, balance, minimum, fees } }, { api, modal, page, user }) => {
|
|
11
|
+
|
|
12
|
+
...
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Do instead:
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
route.page('/withdraw', { bodyId: 'withdraw' }, ({}, { api }) => ({
|
|
19
|
+
|
|
20
|
+
withdraw: api.get('/withdraw')
|
|
21
|
+
|
|
22
|
+
}), ({ withdraw }, { api, modal, page, user }) => {
|
|
23
|
+
|
|
24
|
+
const { history, balance, minimum, fees } = withdraw;
|
|
25
|
+
|
|
26
|
+
...
|
|
27
|
+
```
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "proteum",
|
|
3
|
+
"description": "Convenient TypeScript framework designed for Performance and Productivity.",
|
|
4
|
+
"version": "1.0.0-1",
|
|
5
|
+
"author": "Gaetan Le Gac (https://github.com/gaetanlegac)",
|
|
6
|
+
"repository": "git://github.com/gaetanlegac/proteum.git",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"engines": {
|
|
9
|
+
"node": ">=16.1.0",
|
|
10
|
+
"npm": ">=3.10.10"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"framework"
|
|
14
|
+
],
|
|
15
|
+
"bin": {
|
|
16
|
+
"proteum": "cli/bin.js"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@lexical/file": "^0.19.0",
|
|
20
|
+
"@lexical/headless": "^0.18.0",
|
|
21
|
+
"@lexical/html": "^0.18.0",
|
|
22
|
+
"@lexical/react": "^0.18.0",
|
|
23
|
+
"@prisma/client": "^6.5.0",
|
|
24
|
+
"accepts": "^1.3.7",
|
|
25
|
+
"activity-detector": "^3.0.0",
|
|
26
|
+
"ansi-to-html": "^0.7.1",
|
|
27
|
+
"array-move": "^3.0.1",
|
|
28
|
+
"aws-sdk": "^2.1415.0",
|
|
29
|
+
"bowser": "^2.11.0",
|
|
30
|
+
"chart.js": "^3.6.2",
|
|
31
|
+
"cli-highlight": "^2.1.11",
|
|
32
|
+
"compression": "^1.7.4",
|
|
33
|
+
"cookie-parser": "^1.4.5",
|
|
34
|
+
"core-js": "^3.18.1",
|
|
35
|
+
"cors": "^2.8.5",
|
|
36
|
+
"cron-parser": "^4.0.0",
|
|
37
|
+
"dayjs": "^1.11.5",
|
|
38
|
+
"deep-extend": "^0.6.0",
|
|
39
|
+
"dottie": "^2.0.2",
|
|
40
|
+
"escape-regexp": "^0.0.1",
|
|
41
|
+
"express": "^4.17.1",
|
|
42
|
+
"express-csp-header": "^5.0.0",
|
|
43
|
+
"express-fileupload": "^1.2.1",
|
|
44
|
+
"fast-safe-stringify": "^2.1.1",
|
|
45
|
+
"file-type": "^16.5.3",
|
|
46
|
+
"formattor": "^0.0.2",
|
|
47
|
+
"fs-extra": "^10.1.0",
|
|
48
|
+
"got": "^11.8.3",
|
|
49
|
+
"handlebars": "^4.7.7",
|
|
50
|
+
"helmet": "^4.6.0",
|
|
51
|
+
"history": "^5.0.1",
|
|
52
|
+
"hpp": "^0.2.3",
|
|
53
|
+
"human-interval": "^2.0.1",
|
|
54
|
+
"intl": "^1.2.5",
|
|
55
|
+
"iso-639-1": "^2.1.9",
|
|
56
|
+
"js-cookie": "^3.0.1",
|
|
57
|
+
"jsdom": "^25.0.1",
|
|
58
|
+
"jsonwebtoken": "^8.5.1",
|
|
59
|
+
"lexical": "^0.18.0",
|
|
60
|
+
"load-script": "^2.0.0",
|
|
61
|
+
"locale": "^0.1.0",
|
|
62
|
+
"markdown-it": "^13.0.1",
|
|
63
|
+
"md5": "^2.3.0",
|
|
64
|
+
"mime-types": "^2.1.35",
|
|
65
|
+
"module-alias": "^2.2.2",
|
|
66
|
+
"mysql2": "^2.3.0",
|
|
67
|
+
"object-sizeof": "^1.6.3",
|
|
68
|
+
"path-to-regexp": "^6.2.0",
|
|
69
|
+
"picomatch": "^2.3.1",
|
|
70
|
+
"preact": "^10.27.1",
|
|
71
|
+
"preact-render-to-string": "^6.6.1",
|
|
72
|
+
"prettier": "^3.3.3",
|
|
73
|
+
"react-scrollbars-custom": "^4.0.27",
|
|
74
|
+
"react-textarea-autosize": "^8.5.9",
|
|
75
|
+
"regenerator-runtime": "^0.13.9",
|
|
76
|
+
"request": "^2.88.2",
|
|
77
|
+
"slugify": "^1.6.6",
|
|
78
|
+
"source-map-support": "^0.5.21",
|
|
79
|
+
"sql-formatter": "^4.0.2",
|
|
80
|
+
"stopword": "^3.1.1",
|
|
81
|
+
"tslog": "^4.9.1",
|
|
82
|
+
"uuid": "^8.3.2",
|
|
83
|
+
"uuid-by-string": "^3.0.4",
|
|
84
|
+
"validator": "^13.7.0",
|
|
85
|
+
"ws": "^8.2.2",
|
|
86
|
+
"yaml": "^1.10.2",
|
|
87
|
+
"yargs-parser": "^21.1.1",
|
|
88
|
+
"youch": "^3.3.3",
|
|
89
|
+
"youch-terminal": "^2.2.3",
|
|
90
|
+
"zod": "^4.1.5",
|
|
91
|
+
"@babel/cli": "^7.15.4",
|
|
92
|
+
"@babel/plugin-proposal-class-properties": "^7.14.5",
|
|
93
|
+
"@babel/plugin-proposal-decorators": "^7.25.9",
|
|
94
|
+
"@babel/plugin-proposal-private-methods": "^7.14.5",
|
|
95
|
+
"@babel/plugin-proposal-private-property-in-object": "^7.15.4",
|
|
96
|
+
"@babel/plugin-transform-react-constant-elements": "^7.14.5",
|
|
97
|
+
"@babel/preset-env": "^7.15.6",
|
|
98
|
+
"@babel/preset-react": "^7.14.5",
|
|
99
|
+
"@babel/preset-typescript": "^7.15.0",
|
|
100
|
+
"@prefresh/webpack": "^3.3.2",
|
|
101
|
+
"@squoosh/lib": "^0.4.0",
|
|
102
|
+
"@tailwindcss/postcss": "^4.1.17",
|
|
103
|
+
"autoprefixer": "^10.4.21",
|
|
104
|
+
"babel-loader": "^10.0.0",
|
|
105
|
+
"babel-plugin-glob-import": "^0.0.9-1",
|
|
106
|
+
"babel-plugin-transform-imports": "^2.0.0",
|
|
107
|
+
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
|
|
108
|
+
"babel-plugin-transform-remove-console": "^6.9.4",
|
|
109
|
+
"brotli-webpack-plugin": "^1.1.0",
|
|
110
|
+
"browser-sync": "^2.27.5",
|
|
111
|
+
"compression-webpack-plugin": "^8.0.1",
|
|
112
|
+
"console-table-printer": "^2.10.0",
|
|
113
|
+
"css-loader": "^6.2.0",
|
|
114
|
+
"css-minimizer-webpack-plugin": "^7.0.4",
|
|
115
|
+
"favicons": "^7.2.0",
|
|
116
|
+
"filesize": "^8.0.3",
|
|
117
|
+
"image-minimizer-webpack-plugin": "^4.1.4",
|
|
118
|
+
"imagemin": "^9.0.1",
|
|
119
|
+
"imagemin-svgo": "^10.0.0",
|
|
120
|
+
"imagemin-webp": "^6.0.0",
|
|
121
|
+
"json5": "^2.2.0",
|
|
122
|
+
"less-loader": "^10.0.1",
|
|
123
|
+
"less-vars-to-js": "^1.3.0",
|
|
124
|
+
"mini-css-extract-plugin": "^2.2.2",
|
|
125
|
+
"minimatch": "^3.0.4",
|
|
126
|
+
"node-cmd": "^5.0.0",
|
|
127
|
+
"node-notifier": "^10.0.0",
|
|
128
|
+
"null-loader": "^4.0.1",
|
|
129
|
+
"postcss-loader": "^8.2.0",
|
|
130
|
+
"prompts": "^2.4.2",
|
|
131
|
+
"react-dev-utils": "^11.0.4",
|
|
132
|
+
"replace-once": "^1.0.0",
|
|
133
|
+
"responsive-loader": "^3.1.2",
|
|
134
|
+
"serialize-javascript": "^6.0.2",
|
|
135
|
+
"sharp": "^0.34.3",
|
|
136
|
+
"speed-measure-webpack-plugin": "^1.5.0",
|
|
137
|
+
"tailwindcss": "^4.1.17",
|
|
138
|
+
"terser-webpack-plugin": "^5.2.4",
|
|
139
|
+
"ts-alias": "^0.0.7",
|
|
140
|
+
"ts-node": "^10.9.1",
|
|
141
|
+
"webfont": "^11.2.26",
|
|
142
|
+
"webpack": "^5.98.0",
|
|
143
|
+
"webpack-assets-manifest": "^5.0.6",
|
|
144
|
+
"webpack-bundle-analyzer": "^4.4.2",
|
|
145
|
+
"webpack-dev-middleware": "^5.1.0",
|
|
146
|
+
"webpack-hot-middleware": "^2.25.0",
|
|
147
|
+
"webpack-node-externals": "^3.0.0",
|
|
148
|
+
"webpack-virtual-modules": "^0.4.3"
|
|
149
|
+
},
|
|
150
|
+
"devDependencies": {
|
|
151
|
+
"@types/babel__core": "^7.1.16",
|
|
152
|
+
"@types/babel__preset-env": "^7.9.6",
|
|
153
|
+
"@types/cookie": "^0.4.1",
|
|
154
|
+
"@types/express": "^4.17.13",
|
|
155
|
+
"@types/favicons": "^6.2.2",
|
|
156
|
+
"@types/fs-extra": "^9.0.12",
|
|
157
|
+
"@types/markdown-it": "^12.2.3",
|
|
158
|
+
"@types/mime-types": "^2.1.1",
|
|
159
|
+
"@types/node": "^16.9.1",
|
|
160
|
+
"@types/nodemailer": "^6.4.4",
|
|
161
|
+
"@types/pg": "^8.6.1",
|
|
162
|
+
"@types/pg-escape": "^0.2.1",
|
|
163
|
+
"@types/prompts": "^2.0.14",
|
|
164
|
+
"@types/sharp": "^0.31.1",
|
|
165
|
+
"@types/universal-analytics": "^0.4.5",
|
|
166
|
+
"@types/webpack-env": "^1.16.2",
|
|
167
|
+
"@types/ws": "^7.4.7",
|
|
168
|
+
"@types/yargs-parser": "^21.0.0",
|
|
169
|
+
"schema-dts": "^1.1.2"
|
|
170
|
+
}
|
|
171
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/*----------------------------------
|
|
2
|
+
- DEPENDANCES
|
|
3
|
+
----------------------------------*/
|
|
4
|
+
|
|
5
|
+
// Npm
|
|
6
|
+
import yargsParser from 'yargs-parser';
|
|
7
|
+
|
|
8
|
+
// Core
|
|
9
|
+
import type { Application } from '@server/app';
|
|
10
|
+
import Service from '@server/app/service';
|
|
11
|
+
import { NotFound } from '@common/errors';
|
|
12
|
+
|
|
13
|
+
/*----------------------------------
|
|
14
|
+
- TYPES
|
|
15
|
+
----------------------------------*/
|
|
16
|
+
|
|
17
|
+
type CommandCallback<TArgs extends any[]> = (...args: TArgs) => Promise<any>
|
|
18
|
+
|
|
19
|
+
export type CommandsList = {
|
|
20
|
+
[commandName: string]: Command
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export type Command<TArgs extends any[] = any[]> = {
|
|
24
|
+
name: string,
|
|
25
|
+
description: string,
|
|
26
|
+
run?: CommandCallback<TArgs>
|
|
27
|
+
childrens: CommandsList
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/*----------------------------------
|
|
31
|
+
- SERVICE TYPES
|
|
32
|
+
----------------------------------*/
|
|
33
|
+
|
|
34
|
+
const LogPrefix = `[commands]`;
|
|
35
|
+
|
|
36
|
+
export type Config = {
|
|
37
|
+
debug: boolean
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export type Hooks = {
|
|
41
|
+
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export type Services = {
|
|
45
|
+
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/*----------------------------------
|
|
49
|
+
- SERVICE
|
|
50
|
+
----------------------------------*/
|
|
51
|
+
export default class CommandsManager extends Service<Config, Hooks, Application> {
|
|
52
|
+
|
|
53
|
+
public priority = 2 as 2;
|
|
54
|
+
|
|
55
|
+
public commandsIndex: CommandsList = {}
|
|
56
|
+
|
|
57
|
+
public command<TArgs extends any[]>(
|
|
58
|
+
...args: (
|
|
59
|
+
[name: string, description: string, childrens: Command[]]
|
|
60
|
+
|
|
|
61
|
+
[name: string, description: string, run: CommandCallback<TArgs>, childrens?: Command[]]
|
|
62
|
+
)
|
|
63
|
+
): Command {
|
|
64
|
+
|
|
65
|
+
let name: string, description: string;
|
|
66
|
+
let childrens: Command[] | undefined;
|
|
67
|
+
let run: CommandCallback<TArgs> | undefined;
|
|
68
|
+
|
|
69
|
+
if (typeof args[2] === 'object')
|
|
70
|
+
([name, description, childrens] = args)
|
|
71
|
+
else
|
|
72
|
+
([name, description, run, childrens] = args)
|
|
73
|
+
|
|
74
|
+
const command: Command = {
|
|
75
|
+
name,
|
|
76
|
+
description,
|
|
77
|
+
run,
|
|
78
|
+
childrens: childrens ? this.indexFromList(childrens) : {}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return command;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
private indexFromList( list: Command[] ): CommandsList {
|
|
85
|
+
|
|
86
|
+
const index: CommandsList = {}
|
|
87
|
+
for (const command of list)
|
|
88
|
+
index[ command.name ] = command;
|
|
89
|
+
|
|
90
|
+
return index;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/*----------------------------------
|
|
94
|
+
- REGISTER
|
|
95
|
+
----------------------------------*/
|
|
96
|
+
public fromList( list: Command[] ) {
|
|
97
|
+
for (const command of list) {
|
|
98
|
+
|
|
99
|
+
if (this.commandsIndex[ command.name ] !== undefined)
|
|
100
|
+
throw new Error(`Tried to register command "${command.name}", but it already has been defined.`);
|
|
101
|
+
|
|
102
|
+
this.commandsIndex[ command.name ] = command;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/*----------------------------------
|
|
107
|
+
- RUN
|
|
108
|
+
----------------------------------*/
|
|
109
|
+
public async run( commandString: string ) {
|
|
110
|
+
|
|
111
|
+
const { _, ...args } = yargsParser(commandString);
|
|
112
|
+
|
|
113
|
+
this.config.debug && console.log(LogPrefix, `Run command: ${commandString} | Parsed:`, { _, ...args });
|
|
114
|
+
|
|
115
|
+
let command: Command | undefined;
|
|
116
|
+
for (const commandName of _) {
|
|
117
|
+
|
|
118
|
+
const commandsList: CommandsList = command === undefined
|
|
119
|
+
? this.commandsIndex
|
|
120
|
+
: command.childrens;
|
|
121
|
+
|
|
122
|
+
command = commandsList[commandName];
|
|
123
|
+
|
|
124
|
+
if (command === undefined)
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (command === undefined)
|
|
129
|
+
throw new NotFound(`Command not found.`);
|
|
130
|
+
|
|
131
|
+
if (command.run === undefined)
|
|
132
|
+
throw new NotFound(`This command isn't runnable.`);
|
|
133
|
+
|
|
134
|
+
// TODO: order correctly & validate type according to injected typescript typedefs (command.run.params)
|
|
135
|
+
const argsList = Object.values(args);
|
|
136
|
+
|
|
137
|
+
const result = await command.run(argsList);
|
|
138
|
+
|
|
139
|
+
return result;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
/*----------------------------------
|
|
2
|
+
- DEPENDANCES
|
|
3
|
+
----------------------------------*/
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
WARNING: This file SHOULDN'T import deps from the project
|
|
7
|
+
Because it's imported by the CLI, which should be independant of the app escept for loading config
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
// Npm
|
|
11
|
+
import fs from 'fs-extra';
|
|
12
|
+
import yaml from 'yaml';
|
|
13
|
+
|
|
14
|
+
// Types
|
|
15
|
+
import type { TDomainsList } from '@common/router';
|
|
16
|
+
import type { TLogProfile } from './console';
|
|
17
|
+
|
|
18
|
+
/*----------------------------------
|
|
19
|
+
- TYPES
|
|
20
|
+
----------------------------------*/
|
|
21
|
+
|
|
22
|
+
declare global {
|
|
23
|
+
namespace Config {
|
|
24
|
+
|
|
25
|
+
type EnvName = TEnvConfig["name"];
|
|
26
|
+
|
|
27
|
+
type Env = TEnvConfig;
|
|
28
|
+
type Identity = AppIdentityConfig;
|
|
29
|
+
interface Services {}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/*
|
|
34
|
+
name: server
|
|
35
|
+
profile: prod
|
|
36
|
+
|
|
37
|
+
router:
|
|
38
|
+
port: 80
|
|
39
|
+
domains:
|
|
40
|
+
current: 'https://recruiters.becrosspath.com'
|
|
41
|
+
recruiters: 'https://recruiters.becrosspath.com'
|
|
42
|
+
landing: 'https://becrosspath.com'
|
|
43
|
+
employers: 'https://employers.becrosspath.com'
|
|
44
|
+
candidates: 'https://candidates.becrosspath.com'
|
|
45
|
+
csm: 'https://csm.becrosspath.com'
|
|
46
|
+
|
|
47
|
+
database:
|
|
48
|
+
name: 'aws'
|
|
49
|
+
databases: [railway]
|
|
50
|
+
host: 'mysql-z7vp.railway.internal'
|
|
51
|
+
port: 3306
|
|
52
|
+
login: root
|
|
53
|
+
password: "GMnVsczoyYkyzwvVqDkMUOAIjVsumEev"
|
|
54
|
+
|
|
55
|
+
console:
|
|
56
|
+
enable: false
|
|
57
|
+
debug: false
|
|
58
|
+
bufferLimit: 10000
|
|
59
|
+
level: 'log'
|
|
60
|
+
*/
|
|
61
|
+
|
|
62
|
+
export type TEnvName = TEnvConfig["name"];
|
|
63
|
+
export type TEnvConfig = {
|
|
64
|
+
name: 'local' | 'server',
|
|
65
|
+
profile: 'dev' | 'testing' | 'prod',
|
|
66
|
+
|
|
67
|
+
router: {
|
|
68
|
+
port: number,
|
|
69
|
+
domains: TDomainsList
|
|
70
|
+
},
|
|
71
|
+
console: {
|
|
72
|
+
enable: boolean,
|
|
73
|
+
debug: boolean,
|
|
74
|
+
bufferLimit: number,
|
|
75
|
+
level: TLogProfile,
|
|
76
|
+
},
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
type AppIdentityConfig = {
|
|
80
|
+
|
|
81
|
+
name: string,
|
|
82
|
+
identifier: string,
|
|
83
|
+
description: string,
|
|
84
|
+
author: {
|
|
85
|
+
name: string,
|
|
86
|
+
url: string,
|
|
87
|
+
email: string
|
|
88
|
+
},
|
|
89
|
+
|
|
90
|
+
social: {
|
|
91
|
+
|
|
92
|
+
},
|
|
93
|
+
|
|
94
|
+
locale: string
|
|
95
|
+
language: string
|
|
96
|
+
maincolor: string,
|
|
97
|
+
iconsPack?: string,
|
|
98
|
+
|
|
99
|
+
web: {
|
|
100
|
+
title: string,
|
|
101
|
+
titleSuffix: string,
|
|
102
|
+
fullTitle: string,
|
|
103
|
+
description: string,
|
|
104
|
+
version: string,
|
|
105
|
+
metas?: {[name: string]: string},
|
|
106
|
+
jsonld?: {[name: string]: string},
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export type AppConfig = {
|
|
111
|
+
env: Config.Env,
|
|
112
|
+
identity: Config.Identity,
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const debug = false;
|
|
116
|
+
|
|
117
|
+
/*----------------------------------
|
|
118
|
+
- LOADE
|
|
119
|
+
----------------------------------*/
|
|
120
|
+
export default class ConfigParser {
|
|
121
|
+
|
|
122
|
+
public constructor(
|
|
123
|
+
public appDir: string,
|
|
124
|
+
public envName?: string
|
|
125
|
+
) {
|
|
126
|
+
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
private loadYaml( filepath: string ) {
|
|
130
|
+
debug && console.info(`Loading config ${filepath}`);
|
|
131
|
+
const rawConfig = fs.readFileSync(filepath, 'utf-8');
|
|
132
|
+
return yaml.parse(rawConfig);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
public env(): TEnvConfig {
|
|
136
|
+
// We assume that when we run 5htp dev, we're in local
|
|
137
|
+
// Otherwise, we're in production environment (docker)
|
|
138
|
+
console.log("[app] Using environment:", process.env.NODE_ENV);
|
|
139
|
+
const envFileName = this.appDir + '/env.yaml';
|
|
140
|
+
const envFile = this.loadYaml( envFileName );
|
|
141
|
+
return {
|
|
142
|
+
...envFile,
|
|
143
|
+
version: BUILD_DATE
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
public identity() {
|
|
148
|
+
const identityFile = this.appDir + '/identity.yaml';
|
|
149
|
+
debug && console.info(`Loading identity ${identityFile}`);
|
|
150
|
+
return this.loadYaml( identityFile );
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/*const walkYaml = (dir: string, configA: any, envName: string) => {
|
|
155
|
+
|
|
156
|
+
const files = fs.readdirSync(dir);
|
|
157
|
+
for (const file of files) {
|
|
158
|
+
|
|
159
|
+
const fullpath = dir + '/' + file;
|
|
160
|
+
|
|
161
|
+
// extension .yaml
|
|
162
|
+
const isDir = fs.lstatSync(fullpath).isDirectory();
|
|
163
|
+
let key = file;
|
|
164
|
+
if (!isDir) {
|
|
165
|
+
|
|
166
|
+
if (!file.endsWith('.yaml'))
|
|
167
|
+
continue;
|
|
168
|
+
|
|
169
|
+
key = key.substring(0, key.length - 5);
|
|
170
|
+
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
let fileConfig = configA;
|
|
174
|
+
|
|
175
|
+
// Ciblage environnement
|
|
176
|
+
// Before: /config/services/env.<envName>.yaml
|
|
177
|
+
// After: /config/services
|
|
178
|
+
if (key.startsWith('env.')) {
|
|
179
|
+
|
|
180
|
+
// Excluding not mtching env name
|
|
181
|
+
if (key.substring(4) !== envName)
|
|
182
|
+
continue;
|
|
183
|
+
|
|
184
|
+
// Créé l'entrée dans la config, sauf si le nom du fichier est default
|
|
185
|
+
} else if (key !== 'default') {
|
|
186
|
+
|
|
187
|
+
// Init config
|
|
188
|
+
if (!(key in fileConfig))
|
|
189
|
+
fileConfig[key] = {};
|
|
190
|
+
|
|
191
|
+
fileConfig = configA[key];
|
|
192
|
+
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// Recursion
|
|
196
|
+
if (isDir)
|
|
197
|
+
walk(fullpath, fileConfig, envName);
|
|
198
|
+
// Lecture fichier
|
|
199
|
+
else
|
|
200
|
+
deepExtend(fileConfig, loadYaml(fullpath));
|
|
201
|
+
|
|
202
|
+
}
|
|
203
|
+
}*/
|