@nu-art/build-and-install 0.204.3 → 0.204.4
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/build-and-install.js +10 -5
- package/console/Console_PackagesView.d.ts +8 -0
- package/console/Console_PackagesView.js +65 -0
- package/core/package/consts.d.ts +10 -1
- package/core/package/consts.js +2 -3
- package/core/package/generate.d.ts +15 -211
- package/core/package/generate.js +110 -27
- package/core/params/params.d.ts +3 -2
- package/core/params/params.js +14 -3
- package/core/types/package/package.d.ts +41 -19
- package/core/types/package/package.js +2 -1
- package/defaults/consts.d.ts +2 -0
- package/defaults/consts.js +4 -1
- package/logic/ProjectManager.d.ts +4 -0
- package/logic/ProjectManager.js +61 -5
- package/package.json +3 -1
- package/phases/phases.d.ts +2 -1
- package/phases/phases.js +140 -37
- package/project-manager.js +1 -1
- package/screen/ProjectScreen.d.ts +27 -0
- package/screen/ProjectScreen.js +178 -0
package/phases/phases.js
CHANGED
|
@@ -1,9 +1,32 @@
|
|
|
1
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Phase_DeployBackend = exports.Phase_DeployFrontend = exports.Phase_Launch = exports.Phase_CompileWatch = exports.Phase_Compile = exports.
|
|
26
|
+
exports.Phase_DeployBackend = exports.Phase_DeployFrontend = exports.Phase_Launch = exports.Phase_CompileWatch = exports.Phase_Compile = exports.Phase_PreCompile = exports.Phase_PrepareCompile = exports.Phase_Debug = exports.Phase_Lint = exports.Phase_Clean = exports.Phase_InstallPackages = exports.Phase_InstallPnpm = exports.Phase_InstallGlobals = exports.Phase_PackagePurge = exports.Phase_PrintEnv = exports.Phase_CheckCyclicImports = exports.Phase_PrintDependencyTree = exports.Phase_InstallNvm = exports.Phase_ResolvePackages = exports.Phase_ResolveEnv = exports.Phase_ResolveTemplate = exports.Phase_PrepareParams = exports.Phase_SetupProject = exports.Phase_SetWithThunderstorm = exports.Phase_PrintHelp = void 0;
|
|
4
27
|
const ProjectManager_1 = require("../logic/ProjectManager");
|
|
5
28
|
const map_project_packages_1 = require("../logic/map-project-packages");
|
|
6
|
-
const fs = require("fs");
|
|
29
|
+
const fs = __importStar(require("fs"));
|
|
7
30
|
const fs_1 = require("fs");
|
|
8
31
|
const consts_1 = require("../core/consts");
|
|
9
32
|
const tools_1 = require("@nu-art/commando/core/tools");
|
|
@@ -14,9 +37,11 @@ const nvm_1 = require("@nu-art/commando/cli/nvm");
|
|
|
14
37
|
const params_1 = require("../core/params/params");
|
|
15
38
|
const basic_1 = require("@nu-art/commando/cli/basic");
|
|
16
39
|
const pnpm_1 = require("@nu-art/commando/cli/pnpm");
|
|
17
|
-
const chokidar = require("chokidar");
|
|
40
|
+
const chokidar = __importStar(require("chokidar"));
|
|
18
41
|
const consts_2 = require("../defaults/consts");
|
|
19
42
|
const project_manager_1 = require("../project-manager");
|
|
43
|
+
const ProjectScreen_1 = require("../screen/ProjectScreen");
|
|
44
|
+
const cli_1 = require("@nu-art/commando/core/cli");
|
|
20
45
|
const CONST_ThunderstormVersionKey = 'THUNDERSTORM_SDK_VERSION';
|
|
21
46
|
const CONST_ThunderstormDependencyKey = 'THUNDERSTORM_DEPENDENCY_VERSION';
|
|
22
47
|
const CONST_ProjectVersionKey = 'APP_VERSION';
|
|
@@ -26,6 +51,7 @@ const CONST_RunningRoot = process.cwd();
|
|
|
26
51
|
const pathToProjectTS_Config = (0, tools_1.convertToFullPath)(`./.config/${CONST_TS_Config}`);
|
|
27
52
|
const pathToProjectEslint = (0, tools_1.convertToFullPath)('./.config/.eslintrc.js');
|
|
28
53
|
const runInDebug = false;
|
|
54
|
+
const CommandoLibs = ['commando', 'build-and-install', 'ts-common'];
|
|
29
55
|
exports.Phase_PrintHelp = {
|
|
30
56
|
type: 'project',
|
|
31
57
|
name: 'printHelp',
|
|
@@ -60,9 +86,13 @@ exports.Phase_SetWithThunderstorm = {
|
|
|
60
86
|
return;
|
|
61
87
|
// Remove all the infra packages from the runtime project
|
|
62
88
|
const packages = consts_1.MemKey_Packages.get();
|
|
63
|
-
const filter = (pkg) => pkg.type !== types_1.PackageType_InfraLib || (params_1.RuntimeParams.withCommando &&
|
|
64
|
-
packages.packages.filter(filter);
|
|
89
|
+
const filter = (pkg) => pkg.type !== types_1.PackageType_InfraLib || (params_1.RuntimeParams.withCommando && CommandoLibs.includes(pkg.name));
|
|
90
|
+
packages.packages = packages.packages.filter(filter);
|
|
65
91
|
packages.packagesDependency = (_a = packages.packagesDependency) === null || _a === void 0 ? void 0 : _a.map(_packageArray => _packageArray.filter(filter));
|
|
92
|
+
const projectScreen = ProjectScreen_1.MemKey_ProjectScreen.get();
|
|
93
|
+
if (!projectScreen.packageData.length) {
|
|
94
|
+
packages.packagesDependency.map(packages => packages.map(pkg => projectScreen.updateOrCreatePackage(pkg.name, 'Initiated')));
|
|
95
|
+
}
|
|
66
96
|
}
|
|
67
97
|
};
|
|
68
98
|
exports.Phase_SetupProject = {
|
|
@@ -87,6 +117,8 @@ exports.Phase_PrepareParams = {
|
|
|
87
117
|
mandatoryPhases: [exports.Phase_SetupProject, exports.Phase_SetWithThunderstorm],
|
|
88
118
|
action: async (pkg) => {
|
|
89
119
|
const packages = consts_1.MemKey_Packages.get();
|
|
120
|
+
const projectScreen = ProjectScreen_1.MemKey_ProjectScreen.get();
|
|
121
|
+
projectScreen.updateOrCreatePackage(pkg.name, 'Preparing Pramas');
|
|
90
122
|
// with workspace: *
|
|
91
123
|
const tempPackageJson = (0, map_project_packages_1.convertPackageJSONTemplateToPackJSON_Value)(pkg.packageJsonTemplate, (value, key) => {
|
|
92
124
|
const toRet = packages.params[key] ? 'workspace:*' : packages.params[value];
|
|
@@ -95,6 +127,7 @@ exports.Phase_PrepareParams = {
|
|
|
95
127
|
// placed package name to version
|
|
96
128
|
packages.params[tempPackageJson.name] = tempPackageJson.version;
|
|
97
129
|
packages.params[`${tempPackageJson.name}_path`] = `file:.dependencies/${pkg.name}`;
|
|
130
|
+
projectScreen.updateOrCreatePackage(pkg.name, 'Pramas Prepared');
|
|
98
131
|
}
|
|
99
132
|
};
|
|
100
133
|
exports.Phase_ResolveTemplate = {
|
|
@@ -104,6 +137,8 @@ exports.Phase_ResolveTemplate = {
|
|
|
104
137
|
mandatoryPhases: [exports.Phase_PrepareParams, exports.Phase_SetupProject, exports.Phase_SetWithThunderstorm],
|
|
105
138
|
action: async (pkg) => {
|
|
106
139
|
const packages = consts_1.MemKey_Packages.get();
|
|
140
|
+
const projectScreen = ProjectScreen_1.MemKey_ProjectScreen.get();
|
|
141
|
+
projectScreen.updateOrCreatePackage(pkg.name, 'Resolving Templates');
|
|
107
142
|
// with workspace: *
|
|
108
143
|
pkg.packageJsonWorkspace = (0, map_project_packages_1.convertPackageJSONTemplateToPackJSON_Value)(pkg.packageJsonTemplate, (value, key) => {
|
|
109
144
|
const toRet = packages.params[key] ? 'workspace:*' : packages.params[value];
|
|
@@ -130,22 +165,25 @@ exports.Phase_ResolveTemplate = {
|
|
|
130
165
|
return;
|
|
131
166
|
if (!fs.existsSync(pkg.output))
|
|
132
167
|
await fs_1.promises.mkdir(pkg.output);
|
|
168
|
+
projectScreen.updateOrCreatePackage(pkg.name, 'Resolved Templates');
|
|
133
169
|
}
|
|
134
170
|
};
|
|
135
171
|
exports.Phase_ResolveEnv = {
|
|
136
172
|
type: 'package',
|
|
137
173
|
name: 'resolve-env',
|
|
138
174
|
isMandatory: true,
|
|
139
|
-
mandatoryPhases: [exports.Phase_ResolveTemplate, exports.Phase_SetupProject, exports.Phase_SetWithThunderstorm],
|
|
175
|
+
mandatoryPhases: [exports.Phase_ResolveTemplate, exports.Phase_PrepareParams, exports.Phase_SetupProject, exports.Phase_SetWithThunderstorm],
|
|
140
176
|
filter: async (pkg) => pkg.type === 'firebase-functions-app' || pkg.type === 'firebase-hosting-app',
|
|
141
177
|
action: async (pkg) => {
|
|
142
|
-
var _a, _b;
|
|
143
178
|
const firebasePkg = pkg;
|
|
144
179
|
await fs_1.promises.writeFile(`${firebasePkg.path}/${consts_1.CONST_FirebaseRC}`, JSON.stringify((0, generate_1.createFirebaseRC)(firebasePkg, params_1.RuntimeParams.setEnv), null, 2), { encoding: 'utf-8' });
|
|
145
180
|
const defaultFiles = consts_2.MemKey_DefaultFiles.get();
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
181
|
+
const projectScreen = ProjectScreen_1.MemKey_ProjectScreen.get();
|
|
182
|
+
projectScreen.updateOrCreatePackage(pkg.name, 'Resolving Env');
|
|
183
|
+
if (pkg.type === 'firebase-hosting-app') {
|
|
184
|
+
await (0, generate_1.writeToFile_HostingFirebaseJSON)(firebasePkg, params_1.RuntimeParams.setEnv);
|
|
185
|
+
await (0, generate_1.writeToFile_HostingFirebaseConfigJSON)(firebasePkg, params_1.RuntimeParams.setEnv);
|
|
186
|
+
}
|
|
149
187
|
if (pkg.type === 'firebase-functions-app') {
|
|
150
188
|
const firebaseFunctionPkg = firebasePkg;
|
|
151
189
|
const pathToFirebaseConfigFolder = `${firebaseFunctionPkg.path}/${firebaseFunctionPkg.envConfig.pathToFirebaseConfig}`;
|
|
@@ -155,19 +193,14 @@ exports.Phase_ResolveEnv = {
|
|
|
155
193
|
catch (e) {
|
|
156
194
|
await fs_1.promises.mkdir(pathToFirebaseConfigFolder, { recursive: true });
|
|
157
195
|
}
|
|
158
|
-
if (firebasePkg.envConfig.ssl) {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
defaultFileContent = defaultFileContent.replace(/PATH_TO_SSL_KEY/g, `${(_a = firebasePkg.envConfig.ssl) === null || _a === void 0 ? void 0 : _a.pathToKey}`);
|
|
167
|
-
defaultFileContent = defaultFileContent.replace(/PATH_TO_SSL_CERTIFICATE/g, `${(_b = firebasePkg.envConfig.ssl) === null || _b === void 0 ? void 0 : _b.pathToCertificate}`);
|
|
168
|
-
await fs_1.promises.writeFile(pathToProxyFile, defaultFileContent, { encoding: 'utf-8' });
|
|
169
|
-
}
|
|
170
|
-
}
|
|
196
|
+
// if (firebasePkg.envConfig.ssl) {
|
|
197
|
+
// const pathToProxyFile = `${firebaseFunctionPkg.path}/src/main/proxy.ts`;
|
|
198
|
+
// let defaultFileContent = await _fs.readFile(defaultFiles.backend.proxy, {encoding: 'utf-8'});
|
|
199
|
+
// defaultFileContent = defaultFileContent.replace(/SERVER_PORT/g, `${firebasePkg.envConfig.basePort}`);
|
|
200
|
+
// defaultFileContent = defaultFileContent.replace(/PATH_TO_SSL_KEY/g, `${firebasePkg.envConfig.ssl?.pathToKey}`);
|
|
201
|
+
// defaultFileContent = defaultFileContent.replace(/PATH_TO_SSL_CERTIFICATE/g, `${firebasePkg.envConfig.ssl?.pathToCertificate}`);
|
|
202
|
+
// await _fs.writeFile(pathToProxyFile, defaultFileContent, {encoding: 'utf-8'});
|
|
203
|
+
// }
|
|
171
204
|
await Promise.all(consts_2.Const_FirebaseConfigKeys.map(async (firebaseConfigKey) => {
|
|
172
205
|
const pathToConfigFile = `${pathToFirebaseConfigFolder}/${consts_2.Const_FirebaseDefaultsKeyToFile[firebaseConfigKey]}`;
|
|
173
206
|
try {
|
|
@@ -178,9 +211,10 @@ exports.Phase_ResolveEnv = {
|
|
|
178
211
|
await fs_1.promises.writeFile(pathToConfigFile, defaultFileContent, { encoding: 'utf-8' });
|
|
179
212
|
}
|
|
180
213
|
}));
|
|
181
|
-
|
|
214
|
+
await (0, generate_1.writeToFile_functionFirebaseConfigJSON)(firebaseFunctionPkg, params_1.RuntimeParams.setEnv);
|
|
215
|
+
await (0, generate_1.writeToFile_FunctionFirebaseJSON)(firebaseFunctionPkg, params_1.RuntimeParams.setEnv);
|
|
182
216
|
}
|
|
183
|
-
|
|
217
|
+
projectScreen.updateOrCreatePackage(pkg.name, 'Env Resolved');
|
|
184
218
|
}
|
|
185
219
|
};
|
|
186
220
|
exports.Phase_ResolvePackages = {
|
|
@@ -251,6 +285,10 @@ exports.Phase_PackagePurge = {
|
|
|
251
285
|
mandatoryPhases: [exports.Phase_ResolveEnv],
|
|
252
286
|
filter: async (pkg) => fs.existsSync(pkg.output) && params_1.RuntimeParams.purge,
|
|
253
287
|
action: async (pkg) => {
|
|
288
|
+
const projectScreen = ProjectScreen_1.MemKey_ProjectScreen.get();
|
|
289
|
+
//Update cli ui
|
|
290
|
+
projectScreen.updateOrCreatePackage(pkg.name, 'Purging');
|
|
291
|
+
//Perform the action
|
|
254
292
|
await fs_1.promises.rm(pkg.output, { recursive: true, force: true });
|
|
255
293
|
}
|
|
256
294
|
};
|
|
@@ -291,6 +329,8 @@ exports.Phase_Clean = {
|
|
|
291
329
|
mandatoryPhases: [exports.Phase_ResolveEnv],
|
|
292
330
|
filter: async (pkg) => params_1.RuntimeParams.clean,
|
|
293
331
|
action: async (pkg) => {
|
|
332
|
+
const projectScreen = ProjectScreen_1.MemKey_ProjectScreen.get();
|
|
333
|
+
projectScreen.updateOrCreatePackage(pkg.name, 'Cleaning');
|
|
294
334
|
if (!fs.existsSync(pkg.output))
|
|
295
335
|
return;
|
|
296
336
|
await fs_1.promises.rm(pkg.output, { recursive: true, force: true });
|
|
@@ -302,6 +342,8 @@ exports.Phase_Lint = {
|
|
|
302
342
|
mandatoryPhases: [exports.Phase_ResolveEnv],
|
|
303
343
|
filter: async (pkg) => params_1.RuntimeParams.lint && pkg.type !== 'sourceless',
|
|
304
344
|
action: async (pkg) => {
|
|
345
|
+
const projectScreen = ProjectScreen_1.MemKey_ProjectScreen.get();
|
|
346
|
+
projectScreen.updateOrCreatePackage(pkg.name, 'Linting');
|
|
305
347
|
const folder = 'main';
|
|
306
348
|
const sourceFolder = `${pkg.path}/src/${folder}`;
|
|
307
349
|
return nvm_1.NVM.createCommando().append(`eslint --config ${pathToProjectEslint} --ext .ts --ext .tsx "${sourceFolder}"`).execute();
|
|
@@ -314,7 +356,7 @@ exports.Phase_Debug = {
|
|
|
314
356
|
filter: async () => params_1.RuntimeParams.debug,
|
|
315
357
|
action: async () => {
|
|
316
358
|
const packages = consts_1.MemKey_Packages.get();
|
|
317
|
-
|
|
359
|
+
ts_common_1.StaticLogger.logInfo(JSON.stringify(packages, null, 2));
|
|
318
360
|
}
|
|
319
361
|
};
|
|
320
362
|
const sourcesPaths = [];
|
|
@@ -326,7 +368,7 @@ const suffixes = [
|
|
|
326
368
|
'svg',
|
|
327
369
|
];
|
|
328
370
|
const compileActions = {};
|
|
329
|
-
exports.
|
|
371
|
+
exports.Phase_PrepareCompile = {
|
|
330
372
|
type: 'package',
|
|
331
373
|
name: 'prepare-compile',
|
|
332
374
|
isMandatory: true,
|
|
@@ -337,29 +379,68 @@ exports.Phase_PrepareWatch = {
|
|
|
337
379
|
return;
|
|
338
380
|
const folder = 'main';
|
|
339
381
|
const sourceFolder = `${pkg.path}/src/${folder}`;
|
|
382
|
+
const projectScreen = ProjectScreen_1.MemKey_ProjectScreen.get();
|
|
340
383
|
suffixes.forEach(suffix => {
|
|
341
384
|
sourcesPaths.push(`${sourceFolder}/**/*.${suffix}`);
|
|
342
385
|
});
|
|
343
386
|
// --- HERE ---
|
|
344
387
|
compileActions[sourceFolder] = async () => {
|
|
345
388
|
const pathToLocalTsConfig = `${sourceFolder}/${CONST_TS_Config}`;
|
|
389
|
+
projectScreen.updateOrCreatePackage(pkg.name, 'Compiling');
|
|
346
390
|
const commando = nvm_1.NVM.createCommando();
|
|
347
391
|
await commando
|
|
348
392
|
.append(`tsc -p "${pathToLocalTsConfig}" --rootDir "${sourceFolder}" --outDir "${pkg.output}"`)
|
|
349
393
|
.execute();
|
|
394
|
+
projectScreen.updateOrCreatePackage(pkg.name, 'Compiled');
|
|
350
395
|
};
|
|
351
396
|
}
|
|
352
397
|
};
|
|
398
|
+
exports.Phase_PreCompile = {
|
|
399
|
+
type: 'package',
|
|
400
|
+
name: 'pre-compile',
|
|
401
|
+
isMandatory: true,
|
|
402
|
+
mandatoryPhases: [exports.Phase_ResolveEnv],
|
|
403
|
+
filter: async (pkg) => {
|
|
404
|
+
if (pkg.type === 'sourceless')
|
|
405
|
+
return false;
|
|
406
|
+
if (params_1.RuntimeParams.noBuild)
|
|
407
|
+
return false;
|
|
408
|
+
return fs.existsSync(`${pkg.path}/prebuild.sh`);
|
|
409
|
+
},
|
|
410
|
+
action: async (pkg) => {
|
|
411
|
+
return nvm_1.NVM.createCommando(basic_1.Cli_Basic)
|
|
412
|
+
.cd(pkg.path)
|
|
413
|
+
.append(`bash ${pkg.path}/prebuild.sh`).execute();
|
|
414
|
+
}
|
|
415
|
+
};
|
|
353
416
|
exports.Phase_Compile = {
|
|
354
417
|
type: 'package',
|
|
355
418
|
name: 'compile',
|
|
356
|
-
mandatoryPhases: [exports.
|
|
419
|
+
mandatoryPhases: [exports.Phase_PrepareCompile],
|
|
357
420
|
filter: async (pkg) => pkg.type !== 'sourceless' && !params_1.RuntimeParams.noBuild,
|
|
358
421
|
action: async (pkg) => {
|
|
359
422
|
var _a;
|
|
360
423
|
const packages = consts_1.MemKey_Packages.get();
|
|
361
424
|
if (pkg.type === 'sourceless')
|
|
362
425
|
return;
|
|
426
|
+
try {
|
|
427
|
+
const otherFiles = [
|
|
428
|
+
'scss',
|
|
429
|
+
'svg',
|
|
430
|
+
'png',
|
|
431
|
+
'jpg',
|
|
432
|
+
'jpeg',
|
|
433
|
+
'rules',
|
|
434
|
+
];
|
|
435
|
+
const command = `find . \\( -name ${otherFiles.map(suffix => `'*.${suffix}'`).join(' -o -name ')} \\) | cpio -pdm "${pkg.output}" > /dev/null`;
|
|
436
|
+
await cli_1.Commando.create(basic_1.Cli_Basic)
|
|
437
|
+
.cd(`${pkg.path}/src/main`)
|
|
438
|
+
.append(command)
|
|
439
|
+
.execute();
|
|
440
|
+
}
|
|
441
|
+
catch (e) {
|
|
442
|
+
//
|
|
443
|
+
}
|
|
363
444
|
const folder = 'main';
|
|
364
445
|
const sourceFolder = `${pkg.path}/src/${folder}`;
|
|
365
446
|
const pathToLocalTsConfig = `${sourceFolder}/${CONST_TS_Config}`;
|
|
@@ -402,16 +483,19 @@ exports.Phase_CompileWatch = {
|
|
|
402
483
|
type: 'project',
|
|
403
484
|
name: 'compile-watch',
|
|
404
485
|
terminatingPhase: true,
|
|
405
|
-
mandatoryPhases: [exports.
|
|
486
|
+
mandatoryPhases: [exports.Phase_PrepareCompile],
|
|
406
487
|
filter: async () => params_1.RuntimeParams.watch,
|
|
407
488
|
action: async () => {
|
|
408
489
|
const watcher = chokidar.watch(sourcesPaths);
|
|
409
490
|
const projectManager = project_manager_1.MemKey_ProjectManager.get();
|
|
491
|
+
const projectScreen = ProjectScreen_1.MemKey_ProjectScreen.get();
|
|
492
|
+
const packages = consts_1.MemKey_Packages.get();
|
|
410
493
|
await project_manager_1.MemKey_ProjectManager.get().updateRunningStatus({
|
|
411
494
|
'phaseKey': 'compile-watch',
|
|
412
495
|
'packageDependencyIndex': 0
|
|
413
496
|
});
|
|
414
497
|
let controller;
|
|
498
|
+
let prevController;
|
|
415
499
|
const watchListener = async (path, deleteDist) => {
|
|
416
500
|
const libPath = (0, ts_common_1._keys)(compileActions).find(libPath => path.startsWith(libPath));
|
|
417
501
|
if (!libPath)
|
|
@@ -428,35 +512,45 @@ exports.Phase_CompileWatch = {
|
|
|
428
512
|
try {
|
|
429
513
|
if (controller)
|
|
430
514
|
controller.abort();
|
|
515
|
+
prevController = controller;
|
|
431
516
|
controller = new AbortController();
|
|
432
|
-
await projectManager.executePhase('compile', {
|
|
517
|
+
await projectManager.executePhase('compile', {
|
|
518
|
+
phaseKey: 'compile',
|
|
519
|
+
packageDependencyIndex: packageIndex
|
|
520
|
+
}, controller.signal);
|
|
521
|
+
if (!(prevController === null || prevController === void 0 ? void 0 : prevController.signal.aborted)) {
|
|
522
|
+
// reset all packages back to watching
|
|
523
|
+
packages.packages.map(pkg => projectScreen.updateOrCreatePackage(pkg.name, 'Watching'));
|
|
524
|
+
projectScreen.updateRunningPhase('compile-watch');
|
|
525
|
+
}
|
|
433
526
|
}
|
|
434
527
|
catch (e) {
|
|
435
|
-
|
|
528
|
+
ts_common_1.StaticLogger.logError(e);
|
|
436
529
|
}
|
|
437
530
|
};
|
|
438
531
|
return new Promise((resolve, error) => {
|
|
439
532
|
watcher
|
|
440
533
|
.on('error', (error) => {
|
|
441
|
-
|
|
534
|
+
ts_common_1.StaticLogger.logError('Error while watching', error);
|
|
442
535
|
})
|
|
443
536
|
.on('ready', () => {
|
|
444
|
-
|
|
537
|
+
ts_common_1.StaticLogger.logInfo('Watching: ', sourcesPaths);
|
|
538
|
+
packages.packages.map(pkg => projectScreen.updateOrCreatePackage(pkg.name, 'Watching'));
|
|
445
539
|
watcher
|
|
446
540
|
.on('add', (path) => {
|
|
447
|
-
|
|
541
|
+
ts_common_1.StaticLogger.logInfo(`New File added: ${path}`);
|
|
448
542
|
watchListener(path);
|
|
449
543
|
})
|
|
450
544
|
.on('change', (path) => {
|
|
451
|
-
|
|
545
|
+
ts_common_1.StaticLogger.logInfo(`Detected changes in file: ${path}`);
|
|
452
546
|
watchListener(path);
|
|
453
547
|
})
|
|
454
548
|
.on('unlinkDir', (path) => {
|
|
455
|
-
|
|
549
|
+
ts_common_1.StaticLogger.logInfo(`Deleted Directory: ${path}`);
|
|
456
550
|
watchListener(path, true);
|
|
457
551
|
})
|
|
458
552
|
.on('unlink', (path) => {
|
|
459
|
-
|
|
553
|
+
ts_common_1.StaticLogger.logInfo(`File Deleted: ${path}`);
|
|
460
554
|
watchListener(path, true);
|
|
461
555
|
});
|
|
462
556
|
});
|
|
@@ -480,6 +574,8 @@ exports.Phase_Launch = {
|
|
|
480
574
|
mandatoryPhases: [exports.Phase_ResolveEnv],
|
|
481
575
|
filter: async (pkg) => { var _a; return !!((_a = pkg.name.match(new RegExp(params_1.RuntimeParams.launch))) === null || _a === void 0 ? void 0 : _a[0]) && (pkg.type === 'firebase-functions-app' || pkg.type === 'firebase-hosting-app'); },
|
|
482
576
|
action: async (pkg) => {
|
|
577
|
+
const projectScreen = ProjectScreen_1.MemKey_ProjectScreen.get();
|
|
578
|
+
projectScreen.updateOrCreatePackage(pkg.name, 'Deploying Application');
|
|
483
579
|
if (pkg.type === 'firebase-functions-app') {
|
|
484
580
|
await (0, ts_common_1.sleep)(1000 * counter++);
|
|
485
581
|
const allPorts = Array.from({ length: 10 }, (_, i) => `${pkg.envConfig.basePort + i}`);
|
|
@@ -501,6 +597,7 @@ exports.Phase_Launch = {
|
|
|
501
597
|
.append(`pwd`)
|
|
502
598
|
.append(`npm run start`)
|
|
503
599
|
.execute();
|
|
600
|
+
projectScreen.updateOrCreatePackage(pkg.name, 'Application Deployed');
|
|
504
601
|
}
|
|
505
602
|
};
|
|
506
603
|
exports.Phase_DeployFrontend = {
|
|
@@ -513,12 +610,15 @@ exports.Phase_DeployFrontend = {
|
|
|
513
610
|
return !!((_a = pkg.name.match(new RegExp(params_1.RuntimeParams.deploy))) === null || _a === void 0 ? void 0 : _a[0]) && pkg.type === 'firebase-hosting-app';
|
|
514
611
|
},
|
|
515
612
|
action: async (pkg) => {
|
|
613
|
+
const projectScreen = ProjectScreen_1.MemKey_ProjectScreen.get();
|
|
516
614
|
if (pkg.type !== 'firebase-hosting-app')
|
|
517
615
|
throw new ts_common_1.BadImplementationException(`Somehow got a non firebase hosting package here: ${(0, ts_common_1.__stringify)(pkg)}`);
|
|
616
|
+
projectScreen.updateOrCreatePackage(pkg.name, 'Deploying Hosting');
|
|
518
617
|
await nvm_1.NVM.createCommando(basic_1.Cli_Basic)
|
|
519
618
|
.cd(pkg.path)
|
|
520
619
|
.append(`firebase deploy --only hosting`)
|
|
521
620
|
.execute();
|
|
621
|
+
projectScreen.updateOrCreatePackage(pkg.name, 'Hosting Deployed');
|
|
522
622
|
}
|
|
523
623
|
};
|
|
524
624
|
exports.Phase_DeployBackend = {
|
|
@@ -528,11 +628,14 @@ exports.Phase_DeployBackend = {
|
|
|
528
628
|
mandatoryPhases: [exports.Phase_ResolveEnv],
|
|
529
629
|
filter: async (pkg) => { var _a; return !!((_a = pkg.name.match(new RegExp(params_1.RuntimeParams.deploy))) === null || _a === void 0 ? void 0 : _a[0]) && pkg.type === 'firebase-functions-app'; },
|
|
530
630
|
action: async (pkg) => {
|
|
631
|
+
const projectScreen = ProjectScreen_1.MemKey_ProjectScreen.get();
|
|
531
632
|
if (pkg.type !== 'firebase-functions-app')
|
|
532
633
|
throw new ts_common_1.BadImplementationException(`Somehow got a non firebase functions package here: ${(0, ts_common_1.__stringify)(pkg)}`);
|
|
634
|
+
projectScreen.updateOrCreatePackage(pkg.name, 'Deploying Functions');
|
|
533
635
|
await nvm_1.NVM.createCommando(basic_1.Cli_Basic)
|
|
534
636
|
.cd(pkg.path)
|
|
535
637
|
.append(`firebase --debug deploy --only functions --force`)
|
|
536
638
|
.execute();
|
|
639
|
+
projectScreen.updateOrCreatePackage(pkg.name, 'Functions Deployed');
|
|
537
640
|
}
|
|
538
641
|
};
|
package/project-manager.js
CHANGED
|
@@ -5,5 +5,5 @@ const MemStorage_1 = require("@nu-art/ts-common/mem-storage/MemStorage");
|
|
|
5
5
|
const ts_common_1 = require("@nu-art/ts-common");
|
|
6
6
|
const params_1 = require("./core/params/params");
|
|
7
7
|
exports.MemKey_ProjectManager = new MemStorage_1.MemKey('ProjectManager', true);
|
|
8
|
-
exports.MemKey_AbortSignal = new MemStorage_1.MemKey('AbortSignal'
|
|
8
|
+
exports.MemKey_AbortSignal = new MemStorage_1.MemKey('AbortSignal');
|
|
9
9
|
ts_common_1.DebugFlag.DefaultLogLevel = params_1.RuntimeParams.debug ? ts_common_1.LogLevel.Debug : ts_common_1.LogLevel.Info;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { MemKey } from '@nu-art/ts-common/mem-storage/MemStorage';
|
|
2
|
+
import { LogClient_MemBuffer } from '@nu-art/ts-common';
|
|
3
|
+
export type PackageStatus = {
|
|
4
|
+
packageName: string;
|
|
5
|
+
status: string;
|
|
6
|
+
error?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare class ProjectScreen {
|
|
9
|
+
readonly packageData: PackageStatus[];
|
|
10
|
+
private currentRunningPhase;
|
|
11
|
+
private screen;
|
|
12
|
+
private phaseBox;
|
|
13
|
+
private packageTable;
|
|
14
|
+
private logger;
|
|
15
|
+
readonly logClient: LogClient_MemBuffer;
|
|
16
|
+
private enabled;
|
|
17
|
+
constructor(initialData: PackageStatus[]);
|
|
18
|
+
enable(): void;
|
|
19
|
+
disable(): void;
|
|
20
|
+
renderScreen: () => void;
|
|
21
|
+
endRun: () => void;
|
|
22
|
+
private renderCurrentRunningPhase;
|
|
23
|
+
private renderPackageTableTable;
|
|
24
|
+
updateOrCreatePackage: (name: string, status: string, error?: string) => void;
|
|
25
|
+
updateRunningPhase: (name: string) => void;
|
|
26
|
+
}
|
|
27
|
+
export declare const MemKey_ProjectScreen: MemKey<ProjectScreen>;
|
|
@@ -0,0 +1,178 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.MemKey_ProjectScreen = exports.ProjectScreen = void 0;
|
|
27
|
+
// @ts-ignore
|
|
28
|
+
const blessed = __importStar(require("neo-blessed"));
|
|
29
|
+
const MemStorage_1 = require("@nu-art/ts-common/mem-storage/MemStorage");
|
|
30
|
+
const ts_common_1 = require("@nu-art/ts-common");
|
|
31
|
+
class ProjectScreen {
|
|
32
|
+
constructor(initialData) {
|
|
33
|
+
this.logClient = new ts_common_1.LogClient_MemBuffer('output.txt');
|
|
34
|
+
this.enabled = false;
|
|
35
|
+
this.renderScreen = () => {
|
|
36
|
+
if (!this.enabled)
|
|
37
|
+
return;
|
|
38
|
+
this.renderCurrentRunningPhase();
|
|
39
|
+
this.renderPackageTableTable();
|
|
40
|
+
this.logger.setContent(this.logClient.buffers[0]);
|
|
41
|
+
this.screen.render();
|
|
42
|
+
};
|
|
43
|
+
this.endRun = () => {
|
|
44
|
+
this.disable();
|
|
45
|
+
console.log(this.logClient.buffers[0]);
|
|
46
|
+
};
|
|
47
|
+
this.renderCurrentRunningPhase = () => {
|
|
48
|
+
var _a, _b;
|
|
49
|
+
const content = `Phase Name: ${(_b = (_a = this.currentRunningPhase) === null || _a === void 0 ? void 0 : _a.phaseName) !== null && _b !== void 0 ? _b : 'No Phase'}\n`;
|
|
50
|
+
this.phaseBox.setContent(content);
|
|
51
|
+
};
|
|
52
|
+
this.renderPackageTableTable = () => {
|
|
53
|
+
const scrollPosition = this.packageTable.getScroll();
|
|
54
|
+
const selectedIndex = this.packageTable.selected;
|
|
55
|
+
const data = [
|
|
56
|
+
['Package Name', 'Status'],
|
|
57
|
+
...this.packageData.map(pkg => [pkg.packageName, pkg.status])
|
|
58
|
+
];
|
|
59
|
+
this.packageTable.setData(data);
|
|
60
|
+
this.packageTable.select(selectedIndex);
|
|
61
|
+
this.packageTable.setScroll(scrollPosition);
|
|
62
|
+
};
|
|
63
|
+
this.updateOrCreatePackage = (name, status, error) => {
|
|
64
|
+
const index = this.packageData.findIndex(pkg => pkg.packageName === name);
|
|
65
|
+
if (index !== -1) {
|
|
66
|
+
this.packageData[index].status = status;
|
|
67
|
+
this.packageData[index].error = error;
|
|
68
|
+
return this.renderScreen();
|
|
69
|
+
}
|
|
70
|
+
this.packageData.push({ packageName: name, status });
|
|
71
|
+
this.renderScreen();
|
|
72
|
+
};
|
|
73
|
+
this.updateRunningPhase = (name) => {
|
|
74
|
+
this.currentRunningPhase = { phaseName: name };
|
|
75
|
+
this.renderScreen();
|
|
76
|
+
};
|
|
77
|
+
this.packageData = initialData;
|
|
78
|
+
this.logClient.setLogAppendedListener(() => {
|
|
79
|
+
this.renderScreen();
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
enable() {
|
|
83
|
+
this.enabled = true;
|
|
84
|
+
this.screen = blessed.screen({
|
|
85
|
+
smartCSR: true,
|
|
86
|
+
title: 'Build and install',
|
|
87
|
+
});
|
|
88
|
+
this.screen.key(['escape', 'q', 'C-c'], () => {
|
|
89
|
+
return process.exit(1); // Quit on q, esc, or ctrl-c
|
|
90
|
+
});
|
|
91
|
+
// Create the UI components
|
|
92
|
+
this.phaseBox = blessed.text({
|
|
93
|
+
parent: this.screen,
|
|
94
|
+
top: 0,
|
|
95
|
+
left: 0,
|
|
96
|
+
height: 3,
|
|
97
|
+
width: '40%',
|
|
98
|
+
content: 'phases',
|
|
99
|
+
border: { type: 'line' },
|
|
100
|
+
tags: true,
|
|
101
|
+
style: {
|
|
102
|
+
border: { fg: 'green' },
|
|
103
|
+
fg: 'black',
|
|
104
|
+
},
|
|
105
|
+
align: 'center'
|
|
106
|
+
});
|
|
107
|
+
this.packageTable = blessed.listtable({
|
|
108
|
+
parent: this.screen,
|
|
109
|
+
top: 3,
|
|
110
|
+
left: 0,
|
|
111
|
+
width: '40%',
|
|
112
|
+
height: '70%',
|
|
113
|
+
keys: true,
|
|
114
|
+
border: { type: 'line' },
|
|
115
|
+
align: 'left',
|
|
116
|
+
tags: true,
|
|
117
|
+
style: {
|
|
118
|
+
border: { fg: 'blue' },
|
|
119
|
+
header: { bold: true },
|
|
120
|
+
cell: { fg: 'white', selected: { bg: 'blue' } }
|
|
121
|
+
},
|
|
122
|
+
mouse: true,
|
|
123
|
+
interactive: true,
|
|
124
|
+
scrollbar: {
|
|
125
|
+
ch: ' ',
|
|
126
|
+
track: {
|
|
127
|
+
bg: 'grey'
|
|
128
|
+
},
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
blessed.text({
|
|
132
|
+
parent: this.screen,
|
|
133
|
+
top: 0,
|
|
134
|
+
right: 0,
|
|
135
|
+
width: '60%',
|
|
136
|
+
height: 3,
|
|
137
|
+
border: { type: 'line' },
|
|
138
|
+
content: 'Log',
|
|
139
|
+
tags: true,
|
|
140
|
+
style: {
|
|
141
|
+
border: { fg: 'green' },
|
|
142
|
+
fg: 'black',
|
|
143
|
+
},
|
|
144
|
+
align: 'center'
|
|
145
|
+
});
|
|
146
|
+
this.logger = blessed.log({
|
|
147
|
+
parent: this.screen,
|
|
148
|
+
top: 3,
|
|
149
|
+
right: 0,
|
|
150
|
+
width: '60%',
|
|
151
|
+
mouse: true,
|
|
152
|
+
interactive: true,
|
|
153
|
+
bottom: '0',
|
|
154
|
+
tags: true,
|
|
155
|
+
border: { type: 'line' },
|
|
156
|
+
style: {
|
|
157
|
+
border: { fg: 'blue' },
|
|
158
|
+
fg: 'white',
|
|
159
|
+
},
|
|
160
|
+
valign: 'top',
|
|
161
|
+
align: 'left'
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
disable() {
|
|
165
|
+
this.enabled = false;
|
|
166
|
+
if (!this.screen)
|
|
167
|
+
return;
|
|
168
|
+
this.screen.detach();
|
|
169
|
+
this.phaseBox.detach();
|
|
170
|
+
this.packageTable.detach();
|
|
171
|
+
this.logger.detach();
|
|
172
|
+
this.screen.clear();
|
|
173
|
+
this.screen.destroy();
|
|
174
|
+
process.stdout.write('\x1bc'); // This sends the terminal reset escape code
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
exports.ProjectScreen = ProjectScreen;
|
|
178
|
+
exports.MemKey_ProjectScreen = new MemStorage_1.MemKey('project-screen');
|