proteum 1.0.0-1 → 1.0.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.
- package/changelog.md +5 -0
- package/client/components/Dialog/index.less +1 -3
- package/package.json +3 -69
- package/server/app/container/console/index.ts +1 -1
- package/templates/composant.tsx +40 -0
- package/templates/form.ts +30 -0
- package/templates/modal.tsx +47 -0
- package/templates/modele.ts +56 -0
- package/templates/page.tsx +74 -0
- package/templates/route.ts +43 -0
- package/templates/service.ts +75 -0
- package/tsconfig.common.json +1 -2
- package/vscode/copyimportationpath/.eslintrc.json +24 -0
- package/vscode/copyimportationpath/.vscodeignore +12 -0
- package/vscode/copyimportationpath/CHANGELOG.md +9 -0
- package/vscode/copyimportationpath/README.md +3 -0
- package/vscode/copyimportationpath/copyimportationpath-0.0.1.vsix +0 -0
- package/vscode/copyimportationpath/out/extension.js +206 -0
- package/vscode/copyimportationpath/out/extension.js.map +1 -0
- package/vscode/copyimportationpath/package-lock.json +4536 -0
- package/vscode/copyimportationpath/package.json +86 -0
- package/vscode/copyimportationpath/src/extension.ts +300 -0
- package/vscode/copyimportationpath/tsconfig.json +22 -0
- package/vscode/copyimportationpath/vsc-extension-quickstart.md +42 -0
- package/cli/app/config.ts +0 -54
- package/cli/app/index.ts +0 -195
- package/cli/bin.js +0 -11
- package/cli/commands/build.ts +0 -34
- package/cli/commands/deploy/app.ts +0 -29
- package/cli/commands/deploy/web.ts +0 -60
- package/cli/commands/dev.ts +0 -109
- package/cli/commands/init.ts +0 -85
- package/cli/compiler/client/identite.ts +0 -72
- package/cli/compiler/client/index.ts +0 -334
- package/cli/compiler/common/babel/index.ts +0 -170
- package/cli/compiler/common/babel/plugins/index.ts +0 -0
- package/cli/compiler/common/babel/plugins/services.ts +0 -579
- package/cli/compiler/common/babel/routes/imports.ts +0 -127
- package/cli/compiler/common/babel/routes/routes.ts +0 -1130
- package/cli/compiler/common/files/autres.ts +0 -39
- package/cli/compiler/common/files/images.ts +0 -35
- package/cli/compiler/common/files/style.ts +0 -78
- package/cli/compiler/common/index.ts +0 -154
- package/cli/compiler/index.ts +0 -532
- package/cli/compiler/server/index.ts +0 -211
- package/cli/index.ts +0 -189
- package/cli/paths.ts +0 -165
- package/cli/print.ts +0 -12
- package/cli/tsconfig.json +0 -38
- package/cli/utils/index.ts +0 -22
- package/cli/utils/keyboard.ts +0 -78
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "copyimportationpath",
|
|
3
|
+
"displayName": "CopyImportationPath",
|
|
4
|
+
"description": "",
|
|
5
|
+
"version": "0.0.1",
|
|
6
|
+
"engines": {
|
|
7
|
+
"vscode": "^1.57.0"
|
|
8
|
+
},
|
|
9
|
+
"categories": [
|
|
10
|
+
"Other"
|
|
11
|
+
],
|
|
12
|
+
"activationEvents": [
|
|
13
|
+
"onStartupFinished",
|
|
14
|
+
"onCommand:copyimportationpath.copy",
|
|
15
|
+
"onCommand:copyimportationpath.copyStatement"
|
|
16
|
+
],
|
|
17
|
+
"main": "./out/extension.js",
|
|
18
|
+
"contributes": {
|
|
19
|
+
"commands": [
|
|
20
|
+
{
|
|
21
|
+
"command": "copyimportationpath.copy",
|
|
22
|
+
"title": "Copy Importation Path"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"command": "copyimportationpath.copyStatement",
|
|
26
|
+
"title": "Copy Importation Statement"
|
|
27
|
+
}
|
|
28
|
+
],
|
|
29
|
+
"menus": {
|
|
30
|
+
"editor/context": [
|
|
31
|
+
{
|
|
32
|
+
"when": "editorFocus",
|
|
33
|
+
"command": "copyimportationpath.copy"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"when": "editorFocus",
|
|
37
|
+
"command": "copyimportationpath.copyStatement"
|
|
38
|
+
}
|
|
39
|
+
],
|
|
40
|
+
"editor/title/context": [
|
|
41
|
+
{
|
|
42
|
+
"command": "copyimportationpath.copy"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"command": "copyimportationpath.copyStatement"
|
|
46
|
+
}
|
|
47
|
+
],
|
|
48
|
+
"explorer/context": [
|
|
49
|
+
{
|
|
50
|
+
"command": "copyimportationpath.copy"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"command": "copyimportationpath.copyStatement"
|
|
54
|
+
}
|
|
55
|
+
]
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
"scripts": {
|
|
59
|
+
"vscode:prepublish": "npm run compile",
|
|
60
|
+
"compile": "tsc -p ./",
|
|
61
|
+
"watch": "tsc -watch -p ./",
|
|
62
|
+
"pretest": "npm run compile && npm run lint",
|
|
63
|
+
"lint": "eslint src --ext ts",
|
|
64
|
+
"test": "node ./out/test/runTest.js"
|
|
65
|
+
},
|
|
66
|
+
"devDependencies": {
|
|
67
|
+
"@types/glob": "^7.1.3",
|
|
68
|
+
"@types/mocha": "^8.2.2",
|
|
69
|
+
"@types/node": "14.x",
|
|
70
|
+
"@types/vscode": "^1.57.0",
|
|
71
|
+
"@typescript-eslint/eslint-plugin": "^4.26.0",
|
|
72
|
+
"@typescript-eslint/parser": "^4.26.0",
|
|
73
|
+
"eslint": "^7.27.0",
|
|
74
|
+
"glob": "^7.1.7",
|
|
75
|
+
"mocha": "^8.4.0",
|
|
76
|
+
"typescript": "^4.3.2",
|
|
77
|
+
"vscode-test": "^1.5.2"
|
|
78
|
+
},
|
|
79
|
+
"dependencies": {
|
|
80
|
+
"json5": "^2.2.0",
|
|
81
|
+
"minimatch": "^3.0.4"
|
|
82
|
+
},
|
|
83
|
+
"__metadata": {
|
|
84
|
+
"installedTimestamp": 1644001431526
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
import * as vscode from 'vscode';
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const json5 = require('json5')
|
|
4
|
+
const path = require('path');
|
|
5
|
+
var minimatch = require("minimatch")
|
|
6
|
+
|
|
7
|
+
type TAlias = { alias: string, chemin: string, partiel: boolean }
|
|
8
|
+
|
|
9
|
+
export function activate(context: vscode.ExtensionContext) {
|
|
10
|
+
|
|
11
|
+
const regEntete = /^\/\/\s+([a-z]+)\:\s+(.+)/i
|
|
12
|
+
const templates: {[nom: string]: { glob?: string, regex?: RegExp, content: string }} = {}
|
|
13
|
+
|
|
14
|
+
const dossierTemplates = path.join(context.extensionPath, '../..', 'templates');
|
|
15
|
+
if (!fs.existsSync( dossierTemplates )){
|
|
16
|
+
console.log("Template folder not existing:", dossierTemplates);
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
//const dossierTemplates = workspace + '/../node_modules/@dopamyn/framework/templates';
|
|
21
|
+
fs.readdir(dossierTemplates, (err: Error, files: string[]) => {
|
|
22
|
+
|
|
23
|
+
console.log("Lecture de", dossierTemplates, files);
|
|
24
|
+
|
|
25
|
+
if (err) return console.error(err);
|
|
26
|
+
|
|
27
|
+
for (const file of files) {
|
|
28
|
+
|
|
29
|
+
const nom = file.substring(0, file.lastIndexOf('.'));
|
|
30
|
+
|
|
31
|
+
let content = fs.readFileSync(dossierTemplates + '/' + file, { encoding: 'utf-8' });
|
|
32
|
+
const entete = regEntete.exec(content);
|
|
33
|
+
if (!entete) {
|
|
34
|
+
console.error(file + `: Entete manquante ou au mauvais format.`);
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
console.log('Template', file, nom, entete[1], entete[2]);
|
|
39
|
+
|
|
40
|
+
// Retire l'entete de la template
|
|
41
|
+
content = content.substring( entete[0].length ).trim()
|
|
42
|
+
templates[ nom ] = { content }
|
|
43
|
+
|
|
44
|
+
if (entete[1] === 'Glob')
|
|
45
|
+
templates[nom].glob = entete[2]
|
|
46
|
+
else if (entete[1] === 'Regex')
|
|
47
|
+
templates[nom].regex = new RegExp(entete[2])
|
|
48
|
+
else
|
|
49
|
+
console.error(file + `: Entete inconnue: ` + entete[1]);
|
|
50
|
+
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
console.log(templates);
|
|
54
|
+
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
vscode.workspace.onDidCreateFiles(async (e) => {
|
|
58
|
+
for (const file of e.files) {
|
|
59
|
+
|
|
60
|
+
const importPath = await getImportPath(file.path)
|
|
61
|
+
const importName = getImportName(importPath, file.path);
|
|
62
|
+
|
|
63
|
+
console.log("Fichier créé:", file.path, importPath);
|
|
64
|
+
|
|
65
|
+
// Remplacements
|
|
66
|
+
for (const nom in templates) {
|
|
67
|
+
const { glob, regex, content } = templates[nom]
|
|
68
|
+
|
|
69
|
+
let match: RegExpMatchArray | null | undefined;
|
|
70
|
+
|
|
71
|
+
if ((glob && minimatch( file.path, glob )) || (match = regex?.exec( file.path ))) {
|
|
72
|
+
|
|
73
|
+
const remplacements: {[cle: string]: string} = {
|
|
74
|
+
NAMELOWER: importName.toLowerCase(),
|
|
75
|
+
NAME: importName,
|
|
76
|
+
ABSPATH: importPath,
|
|
77
|
+
...(match?.groups || {})
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
console.log("Template:", nom, "Remplacements:", remplacements);
|
|
81
|
+
|
|
82
|
+
fs.writeFileSync(file.path, content.replace(
|
|
83
|
+
new RegExp( Object.keys(remplacements).join('|'), 'g' ),
|
|
84
|
+
(match: string) => remplacements[match]
|
|
85
|
+
));
|
|
86
|
+
break;
|
|
87
|
+
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
const readTsConfig = async (chemin: string, workspace: string): Promise<TAlias[]> => {
|
|
105
|
+
|
|
106
|
+
console.log('Lecture de ' + chemin);
|
|
107
|
+
const rawtsconfig = fs.readFileSync(chemin, { encoding: 'utf-8' })
|
|
108
|
+
const tsconfig = json5.parse(rawtsconfig);
|
|
109
|
+
|
|
110
|
+
const paths = tsconfig.compilerOptions?.paths;
|
|
111
|
+
if (paths !== undefined) {
|
|
112
|
+
|
|
113
|
+
// Les plus specifiques en premiers
|
|
114
|
+
let retour: TAlias[] = []
|
|
115
|
+
for (let alias in paths) {
|
|
116
|
+
|
|
117
|
+
let chemin = path.join(workspace, paths[alias][0])
|
|
118
|
+
const partiel = chemin.endsWith('*');
|
|
119
|
+
if (partiel) {
|
|
120
|
+
|
|
121
|
+
// Retire le * à la fin
|
|
122
|
+
chemin = chemin.substring(0, chemin.length - 1);
|
|
123
|
+
alias = alias.substring(0, alias.length - 1);
|
|
124
|
+
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
retour.push({
|
|
128
|
+
partiel,
|
|
129
|
+
alias,
|
|
130
|
+
chemin
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
retour.sort((a, b) => b.chemin.length - a.chemin.length);
|
|
136
|
+
|
|
137
|
+
return retour;
|
|
138
|
+
|
|
139
|
+
} else if (tsconfig.extends !== undefined)
|
|
140
|
+
return await readTsConfig(path.resolve(path.dirname(chemin), tsconfig.extends), workspace);
|
|
141
|
+
else
|
|
142
|
+
return [];
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const removeExtensions = (fichier: string, extensions: string[]) => {
|
|
146
|
+
|
|
147
|
+
for (const extension of extensions) {
|
|
148
|
+
|
|
149
|
+
console.log(extension, fichier);
|
|
150
|
+
|
|
151
|
+
if (fichier.endsWith('.' + extension)) {
|
|
152
|
+
fichier = fichier.substring(0, fichier.length - extension.length - 1);
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if (fichier.endsWith('/index'))
|
|
158
|
+
fichier = fichier.substring(0, fichier.length - 6);
|
|
159
|
+
|
|
160
|
+
return fichier;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
const getListeAlias = async () => {
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
if (!vscode.workspace.workspaceFolders?.length) {
|
|
167
|
+
console.error(`Impossible de récupérer le dossier du workspace actuel`);
|
|
168
|
+
return []
|
|
169
|
+
}
|
|
170
|
+
const workspace = vscode.workspace.workspaceFolders[0].uri.path;
|
|
171
|
+
|
|
172
|
+
const tsconfigs = await vscode.workspace.findFiles('tsconfig.json');
|
|
173
|
+
if (tsconfigs.length === 0)
|
|
174
|
+
return []
|
|
175
|
+
|
|
176
|
+
return await readTsConfig(tsconfigs[0].path, workspace);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const getImportPath = async (fichier: string) => {
|
|
180
|
+
|
|
181
|
+
const listeAlias = await getListeAlias();
|
|
182
|
+
|
|
183
|
+
console.log('fichier =', fichier);
|
|
184
|
+
|
|
185
|
+
console.log('listeAlias =', listeAlias);
|
|
186
|
+
|
|
187
|
+
for (const alias of listeAlias) {
|
|
188
|
+
|
|
189
|
+
// Remplacement prefixe
|
|
190
|
+
if (alias.partiel) {
|
|
191
|
+
|
|
192
|
+
if (fichier.startsWith(alias.chemin)) {
|
|
193
|
+
fichier = alias.alias + fichier.substring(alias.chemin.length)
|
|
194
|
+
break;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// Remplacement complet
|
|
198
|
+
} else {
|
|
199
|
+
|
|
200
|
+
if (fichier === alias.chemin) {
|
|
201
|
+
fichier = alias.alias
|
|
202
|
+
break;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// Vire l'extension
|
|
210
|
+
fichier = removeExtensions(fichier, ['tsx', 'ts', 'js', 'jsx']);
|
|
211
|
+
|
|
212
|
+
return fichier;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
const findImportPath = async (selectedFile: any) => {
|
|
216
|
+
|
|
217
|
+
let fichier: string;
|
|
218
|
+
if (selectedFile)
|
|
219
|
+
fichier = selectedFile.path;
|
|
220
|
+
else {
|
|
221
|
+
if (!vscode.window.activeTextEditor)
|
|
222
|
+
return console.error(`Aucun editeur actif`);
|
|
223
|
+
fichier = vscode.window.activeTextEditor.document.uri.path;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
return await getImportPath(fichier);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
const getImportName = (importPath: string, originalPath: string) => {
|
|
230
|
+
|
|
231
|
+
const content = fs.readFileSync(originalPath, { encoding: 'utf-8' });
|
|
232
|
+
const exportdefault = /export default\s+(function|class|new)\s+([a-zA-Z]+)/.exec(content);
|
|
233
|
+
|
|
234
|
+
let nomModule: string;
|
|
235
|
+
if (exportdefault) {
|
|
236
|
+
nomModule = exportdefault[2];
|
|
237
|
+
} else {
|
|
238
|
+
const posSlash = importPath.lastIndexOf('/');
|
|
239
|
+
nomModule = importPath.substring(posSlash === -1 ? 0 : posSlash + 1);
|
|
240
|
+
nomModule = nomModule[0].toUpperCase() + nomModule.substring(1);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
return nomModule;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
const copier = (txt: string) => {
|
|
247
|
+
|
|
248
|
+
console.log(txt);
|
|
249
|
+
|
|
250
|
+
vscode.env.clipboard.writeText(txt);
|
|
251
|
+
|
|
252
|
+
//vscode.window.showInformationMessage('Copied ' + txt);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
context.subscriptions.push(
|
|
257
|
+
vscode.commands.registerCommand('copyimportationpath.copy', async (selected) => {
|
|
258
|
+
|
|
259
|
+
try {
|
|
260
|
+
|
|
261
|
+
const fichier = await findImportPath(selected);
|
|
262
|
+
if (fichier)
|
|
263
|
+
copier(fichier);
|
|
264
|
+
|
|
265
|
+
} catch (error) {
|
|
266
|
+
|
|
267
|
+
vscode.window.showErrorMessage( error.toString() );
|
|
268
|
+
|
|
269
|
+
console.error(error);
|
|
270
|
+
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
}),
|
|
274
|
+
|
|
275
|
+
vscode.commands.registerCommand('copyimportationpath.copyStatement', async (selected) => {
|
|
276
|
+
|
|
277
|
+
try {
|
|
278
|
+
|
|
279
|
+
const importPath = await findImportPath(selected);
|
|
280
|
+
if (importPath) {
|
|
281
|
+
|
|
282
|
+
const importName = getImportName(importPath, selected.path);
|
|
283
|
+
|
|
284
|
+
copier(`import ${importName} from '${importPath}';`);
|
|
285
|
+
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
} catch (error) {
|
|
289
|
+
|
|
290
|
+
vscode.window.showErrorMessage(error.toString());
|
|
291
|
+
|
|
292
|
+
console.error(error);
|
|
293
|
+
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
})
|
|
297
|
+
);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
export function deactivate() {}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"module": "commonjs",
|
|
4
|
+
"target": "es6",
|
|
5
|
+
"outDir": "out",
|
|
6
|
+
"lib": [
|
|
7
|
+
"es6"
|
|
8
|
+
],
|
|
9
|
+
"sourceMap": true,
|
|
10
|
+
"rootDir": "src",
|
|
11
|
+
"strict": true /* enable all strict type-checking options */
|
|
12
|
+
/* Additional Checks */
|
|
13
|
+
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
|
|
14
|
+
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
|
|
15
|
+
// "noUnusedParameters": true, /* Report errors on unused parameters. */
|
|
16
|
+
},
|
|
17
|
+
"exclude": [
|
|
18
|
+
"node_modules",
|
|
19
|
+
".vscode-test",
|
|
20
|
+
"templates"
|
|
21
|
+
]
|
|
22
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Welcome to your VS Code Extension
|
|
2
|
+
|
|
3
|
+
## What's in the folder
|
|
4
|
+
|
|
5
|
+
* This folder contains all of the files necessary for your extension.
|
|
6
|
+
* `package.json` - this is the manifest file in which you declare your extension and command.
|
|
7
|
+
* The sample plugin registers a command and defines its title and command name. With this information VS Code can show the command in the command palette. It doesn’t yet need to load the plugin.
|
|
8
|
+
* `src/extension.ts` - this is the main file where you will provide the implementation of your command.
|
|
9
|
+
* The file exports one function, `activate`, which is called the very first time your extension is activated (in this case by executing the command). Inside the `activate` function we call `registerCommand`.
|
|
10
|
+
* We pass the function containing the implementation of the command as the second parameter to `registerCommand`.
|
|
11
|
+
|
|
12
|
+
## Get up and running straight away
|
|
13
|
+
|
|
14
|
+
* Press `F5` to open a new window with your extension loaded.
|
|
15
|
+
* Run your command from the command palette by pressing (`Ctrl+Shift+P` or `Cmd+Shift+P` on Mac) and typing `Hello World`.
|
|
16
|
+
* Set breakpoints in your code inside `src/extension.ts` to debug your extension.
|
|
17
|
+
* Find output from your extension in the debug console.
|
|
18
|
+
|
|
19
|
+
## Make changes
|
|
20
|
+
|
|
21
|
+
* You can relaunch the extension from the debug toolbar after changing code in `src/extension.ts`.
|
|
22
|
+
* You can also reload (`Ctrl+R` or `Cmd+R` on Mac) the VS Code window with your extension to load your changes.
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
## Explore the API
|
|
26
|
+
|
|
27
|
+
* You can open the full set of our API when you open the file `node_modules/@types/vscode/index.d.ts`.
|
|
28
|
+
|
|
29
|
+
## Run tests
|
|
30
|
+
|
|
31
|
+
* Open the debug viewlet (`Ctrl+Shift+D` or `Cmd+Shift+D` on Mac) and from the launch configuration dropdown pick `Extension Tests`.
|
|
32
|
+
* Press `F5` to run the tests in a new window with your extension loaded.
|
|
33
|
+
* See the output of the test result in the debug console.
|
|
34
|
+
* Make changes to `src/test/suite/extension.test.ts` or create new test files inside the `test/suite` folder.
|
|
35
|
+
* The provided test runner will only consider files matching the name pattern `**.test.ts`.
|
|
36
|
+
* You can create folders inside the `test` folder to structure your tests any way you want.
|
|
37
|
+
|
|
38
|
+
## Go further
|
|
39
|
+
|
|
40
|
+
* Reduce the extension size and improve the startup time by [bundling your extension](https://code.visualstudio.com/api/working-with-extensions/bundling-extension).
|
|
41
|
+
* [Publish your extension](https://code.visualstudio.com/api/working-with-extensions/publishing-extension) on the VSCode extension marketplace.
|
|
42
|
+
* Automate builds by setting up [Continuous Integration](https://code.visualstudio.com/api/working-with-extensions/continuous-integration).
|
package/cli/app/config.ts
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/*----------------------------------
|
|
2
|
-
- DEPENDANCES
|
|
3
|
-
----------------------------------*/
|
|
4
|
-
|
|
5
|
-
/*
|
|
6
|
-
NOTE: This is a copy of core/sever/app/config
|
|
7
|
-
We can't import core deps here because it will cause the following error:
|
|
8
|
-
"Can't use import when not a module"
|
|
9
|
-
It will be possible to import core files when the CLI will be compiled as one output file with tsc
|
|
10
|
-
And for that, we need to fix the TS errors for the CLI
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
// Npm
|
|
14
|
-
import fs from 'fs-extra';
|
|
15
|
-
import yaml from 'yaml';
|
|
16
|
-
|
|
17
|
-
// Types
|
|
18
|
-
import type { TEnvConfig } from '../../server/app/container/config';
|
|
19
|
-
|
|
20
|
-
/*----------------------------------
|
|
21
|
-
- LOADE
|
|
22
|
-
----------------------------------*/
|
|
23
|
-
export default class ConfigParser {
|
|
24
|
-
|
|
25
|
-
public constructor(
|
|
26
|
-
public appDir: string,
|
|
27
|
-
public envName?: string
|
|
28
|
-
) {
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
private loadYaml( filepath: string ) {
|
|
33
|
-
console.info(`Loading config ${filepath}`);
|
|
34
|
-
const rawConfig = fs.readFileSync(filepath, 'utf-8');
|
|
35
|
-
return yaml.parse(rawConfig);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
public env(): TEnvConfig {
|
|
39
|
-
// We assume that when we run 5htp dev, we're in local
|
|
40
|
-
// Otherwise, we're in production environment (docker)
|
|
41
|
-
console.log("[app] Using environment:", process.env.NODE_ENV);
|
|
42
|
-
const envFileName = this.appDir + '/env.yaml';
|
|
43
|
-
const envFile = this.loadYaml( envFileName );
|
|
44
|
-
return {
|
|
45
|
-
...envFile,
|
|
46
|
-
version: 'CLI'
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
public identity() {
|
|
51
|
-
const identityFile = this.appDir + '/identity.yaml';
|
|
52
|
-
return this.loadYaml( identityFile );
|
|
53
|
-
}
|
|
54
|
-
}
|
package/cli/app/index.ts
DELETED
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
/*----------------------------------
|
|
2
|
-
- DEPENDANCES
|
|
3
|
-
----------------------------------*/
|
|
4
|
-
|
|
5
|
-
// npm
|
|
6
|
-
import path from 'path';
|
|
7
|
-
import TsAlias from 'ts-alias';
|
|
8
|
-
import fs from 'fs-extra';
|
|
9
|
-
|
|
10
|
-
// Cre
|
|
11
|
-
import cli from '..';
|
|
12
|
-
|
|
13
|
-
// Specific
|
|
14
|
-
import ConfigParser from './config';
|
|
15
|
-
import type { TEnvConfig } from '../../server/app/container/config';
|
|
16
|
-
|
|
17
|
-
/*----------------------------------
|
|
18
|
-
- TYPES
|
|
19
|
-
----------------------------------*/
|
|
20
|
-
|
|
21
|
-
export type TAppSide = 'server' | 'client'
|
|
22
|
-
|
|
23
|
-
type TServiceSetup = {
|
|
24
|
-
id: string,
|
|
25
|
-
name: string,
|
|
26
|
-
config: {},
|
|
27
|
-
subservices: TServiceSubservices,
|
|
28
|
-
type: 'service.setup'
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
type TServiceRef = {
|
|
32
|
-
refTo: string,
|
|
33
|
-
type: 'service.ref'
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
type TServiceSubservices = {
|
|
37
|
-
[key: string]: TServiceSetup | TServiceRef
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/*----------------------------------
|
|
41
|
-
- SERVICE
|
|
42
|
-
----------------------------------*/
|
|
43
|
-
export class App {
|
|
44
|
-
|
|
45
|
-
// config
|
|
46
|
-
// WARNING: High level config files (env and services) shouldn't be loaded from the CLI
|
|
47
|
-
// The CLI will be run on CircleCI, and no env file should be sent to this service
|
|
48
|
-
public identity: Config.Identity;
|
|
49
|
-
|
|
50
|
-
public env: TEnvConfig;
|
|
51
|
-
|
|
52
|
-
public packageJson: {[key: string]: any};
|
|
53
|
-
|
|
54
|
-
public buildId: number = Date.now();
|
|
55
|
-
|
|
56
|
-
public paths = {
|
|
57
|
-
|
|
58
|
-
root: cli.paths.appRoot,
|
|
59
|
-
bin: path.join( cli.paths.appRoot, 'bin'),
|
|
60
|
-
data: path.join( cli.paths.appRoot, 'var', 'data'),
|
|
61
|
-
public: path.join( cli.paths.appRoot, 'public'),
|
|
62
|
-
pages: path.join( cli.paths.appRoot, 'client', 'pages'),
|
|
63
|
-
cache: path.join( cli.paths.appRoot, '.cache'),
|
|
64
|
-
|
|
65
|
-
client: {
|
|
66
|
-
generated: path.join( cli.paths.appRoot, 'client', '.generated')
|
|
67
|
-
},
|
|
68
|
-
server: {
|
|
69
|
-
generated: path.join( cli.paths.appRoot, 'server', '.generated'),
|
|
70
|
-
configs: path.join( cli.paths.appRoot, 'server', 'app')
|
|
71
|
-
},
|
|
72
|
-
common: {
|
|
73
|
-
generated: path.join( cli.paths.appRoot, 'common', '.generated')
|
|
74
|
-
},
|
|
75
|
-
|
|
76
|
-
withAlias: (filename: string, side: TAppSide) =>
|
|
77
|
-
this.aliases[side].apply(filename),
|
|
78
|
-
|
|
79
|
-
withoutAlias: (filename: string, side: TAppSide) =>
|
|
80
|
-
this.aliases[side].realpath(filename),
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
public containerServices = [
|
|
84
|
-
//'Services',
|
|
85
|
-
'Environment',
|
|
86
|
-
'Identity',
|
|
87
|
-
/*'Application',
|
|
88
|
-
'Path',
|
|
89
|
-
'Event'*/
|
|
90
|
-
]
|
|
91
|
-
|
|
92
|
-
public constructor() {
|
|
93
|
-
|
|
94
|
-
cli.debug && console.log(`[cli] Loading app config ...`);
|
|
95
|
-
const configParser = new ConfigParser( cli.paths.appRoot );
|
|
96
|
-
this.identity = configParser.identity();
|
|
97
|
-
this.env = configParser.env();
|
|
98
|
-
this.packageJson = this.loadPkg();
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/*----------------------------------
|
|
103
|
-
- ALIAS
|
|
104
|
-
----------------------------------*/
|
|
105
|
-
|
|
106
|
-
public aliases = {
|
|
107
|
-
client: new TsAlias({
|
|
108
|
-
rootDir: this.paths.root + '/client',
|
|
109
|
-
modulesDir: [
|
|
110
|
-
cli.paths.appRoot + '/node_modules',
|
|
111
|
-
cli.paths.coreRoot + '/node_modules'
|
|
112
|
-
],
|
|
113
|
-
debug: false
|
|
114
|
-
}),
|
|
115
|
-
server: new TsAlias({
|
|
116
|
-
rootDir: this.paths.root + '/server',
|
|
117
|
-
modulesDir: [
|
|
118
|
-
cli.paths.appRoot + '/node_modules',
|
|
119
|
-
cli.paths.coreRoot + '/node_modules'
|
|
120
|
-
],
|
|
121
|
-
debug: false
|
|
122
|
-
}),
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
private loadPkg() {
|
|
126
|
-
return fs.readJSONSync(this.paths.root + '/package.json');
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/*----------------------------------
|
|
130
|
-
- WARMUP (Services awareness)
|
|
131
|
-
----------------------------------*/
|
|
132
|
-
|
|
133
|
-
public registered = {}
|
|
134
|
-
|
|
135
|
-
public use( referenceName: string ): TServiceRef {
|
|
136
|
-
|
|
137
|
-
// We don't check because all service are not regstered when we register subservices
|
|
138
|
-
/*if (this.registered[referenceName] === undefined) {
|
|
139
|
-
throw new Error(`Service ${referenceName} is not registered`);
|
|
140
|
-
}*/
|
|
141
|
-
|
|
142
|
-
return {
|
|
143
|
-
refTo: referenceName,
|
|
144
|
-
type: 'service.ref'
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
public setup(...args: [
|
|
149
|
-
// { user: app.setup('Core/User') }
|
|
150
|
-
servicePath: string,
|
|
151
|
-
serviceConfig?: {},
|
|
152
|
-
] | [
|
|
153
|
-
// app.setup('User', 'Core/User')
|
|
154
|
-
serviceName: string,
|
|
155
|
-
servicePath: string,
|
|
156
|
-
serviceConfig?: {},
|
|
157
|
-
]): TServiceSetup {
|
|
158
|
-
|
|
159
|
-
// Registration to app root
|
|
160
|
-
if (typeof args[1] === 'string') {
|
|
161
|
-
|
|
162
|
-
const [name, id, config] = args;
|
|
163
|
-
|
|
164
|
-
const service = { id, name, config, type: 'service.setup' } as TServiceSetup
|
|
165
|
-
|
|
166
|
-
this.registered[name] = service;
|
|
167
|
-
|
|
168
|
-
return service;
|
|
169
|
-
|
|
170
|
-
// Scoped to a parent service
|
|
171
|
-
} else {
|
|
172
|
-
|
|
173
|
-
const [id, config] = args;
|
|
174
|
-
|
|
175
|
-
const service = { id, config, type: 'service.setup' } as TServiceSetup
|
|
176
|
-
|
|
177
|
-
return service;
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
public async warmup() {
|
|
182
|
-
|
|
183
|
-
// Require all config files in @/server/config
|
|
184
|
-
const configDir = path.resolve(cli.paths.appRoot, 'server', 'config');
|
|
185
|
-
const configFiles = fs.readdirSync(configDir);
|
|
186
|
-
for (const configFile of configFiles) {
|
|
187
|
-
console.log("Loading config file:", configFile);
|
|
188
|
-
require( path.resolve(configDir, configFile) );
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
export const app = new App
|
|
194
|
-
|
|
195
|
-
export default app
|