@nu-art/build-and-install 0.204.2 → 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 +5 -3
- package/core/params/params.js +26 -7
- 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 +144 -42
- 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,7 +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;
|
|
29
|
-
|
|
54
|
+
const CommandoLibs = ['commando', 'build-and-install', 'ts-common'];
|
|
30
55
|
exports.Phase_PrintHelp = {
|
|
31
56
|
type: 'project',
|
|
32
57
|
name: 'printHelp',
|
|
@@ -57,12 +82,17 @@ exports.Phase_SetWithThunderstorm = {
|
|
|
57
82
|
action: async () => {
|
|
58
83
|
var _a;
|
|
59
84
|
// set value of the running with infra flag
|
|
60
|
-
if (params_1.RuntimeParams.
|
|
61
|
-
return
|
|
85
|
+
if (params_1.RuntimeParams.runWithThunderstorm)
|
|
86
|
+
return;
|
|
62
87
|
// Remove all the infra packages from the runtime project
|
|
63
88
|
const packages = consts_1.MemKey_Packages.get();
|
|
64
|
-
|
|
65
|
-
|
|
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);
|
|
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
|
};
|
|
@@ -280,7 +318,6 @@ exports.Phase_InstallPackages = {
|
|
|
280
318
|
action: async () => {
|
|
281
319
|
const packages = consts_1.MemKey_Packages.get();
|
|
282
320
|
const listOfLibs = packages.packages
|
|
283
|
-
.filter(pkg => runningWithInfra || ['project-lib', 'app', 'sourceless'].includes(pkg.type))
|
|
284
321
|
.map(pkg => pkg.path.replace(`${process.cwd()}/`, '').replace(process.cwd(), '.'));
|
|
285
322
|
await pnpm_1.PNPM.createWorkspace(listOfLibs);
|
|
286
323
|
await pnpm_1.PNPM.installPackages(nvm_1.NVM.createCommando());
|
|
@@ -292,6 +329,8 @@ exports.Phase_Clean = {
|
|
|
292
329
|
mandatoryPhases: [exports.Phase_ResolveEnv],
|
|
293
330
|
filter: async (pkg) => params_1.RuntimeParams.clean,
|
|
294
331
|
action: async (pkg) => {
|
|
332
|
+
const projectScreen = ProjectScreen_1.MemKey_ProjectScreen.get();
|
|
333
|
+
projectScreen.updateOrCreatePackage(pkg.name, 'Cleaning');
|
|
295
334
|
if (!fs.existsSync(pkg.output))
|
|
296
335
|
return;
|
|
297
336
|
await fs_1.promises.rm(pkg.output, { recursive: true, force: true });
|
|
@@ -303,6 +342,8 @@ exports.Phase_Lint = {
|
|
|
303
342
|
mandatoryPhases: [exports.Phase_ResolveEnv],
|
|
304
343
|
filter: async (pkg) => params_1.RuntimeParams.lint && pkg.type !== 'sourceless',
|
|
305
344
|
action: async (pkg) => {
|
|
345
|
+
const projectScreen = ProjectScreen_1.MemKey_ProjectScreen.get();
|
|
346
|
+
projectScreen.updateOrCreatePackage(pkg.name, 'Linting');
|
|
306
347
|
const folder = 'main';
|
|
307
348
|
const sourceFolder = `${pkg.path}/src/${folder}`;
|
|
308
349
|
return nvm_1.NVM.createCommando().append(`eslint --config ${pathToProjectEslint} --ext .ts --ext .tsx "${sourceFolder}"`).execute();
|
|
@@ -315,7 +356,7 @@ exports.Phase_Debug = {
|
|
|
315
356
|
filter: async () => params_1.RuntimeParams.debug,
|
|
316
357
|
action: async () => {
|
|
317
358
|
const packages = consts_1.MemKey_Packages.get();
|
|
318
|
-
|
|
359
|
+
ts_common_1.StaticLogger.logInfo(JSON.stringify(packages, null, 2));
|
|
319
360
|
}
|
|
320
361
|
};
|
|
321
362
|
const sourcesPaths = [];
|
|
@@ -327,7 +368,7 @@ const suffixes = [
|
|
|
327
368
|
'svg',
|
|
328
369
|
];
|
|
329
370
|
const compileActions = {};
|
|
330
|
-
exports.
|
|
371
|
+
exports.Phase_PrepareCompile = {
|
|
331
372
|
type: 'package',
|
|
332
373
|
name: 'prepare-compile',
|
|
333
374
|
isMandatory: true,
|
|
@@ -338,33 +379,72 @@ exports.Phase_PrepareWatch = {
|
|
|
338
379
|
return;
|
|
339
380
|
const folder = 'main';
|
|
340
381
|
const sourceFolder = `${pkg.path}/src/${folder}`;
|
|
382
|
+
const projectScreen = ProjectScreen_1.MemKey_ProjectScreen.get();
|
|
341
383
|
suffixes.forEach(suffix => {
|
|
342
384
|
sourcesPaths.push(`${sourceFolder}/**/*.${suffix}`);
|
|
343
385
|
});
|
|
344
386
|
// --- HERE ---
|
|
345
387
|
compileActions[sourceFolder] = async () => {
|
|
346
388
|
const pathToLocalTsConfig = `${sourceFolder}/${CONST_TS_Config}`;
|
|
389
|
+
projectScreen.updateOrCreatePackage(pkg.name, 'Compiling');
|
|
347
390
|
const commando = nvm_1.NVM.createCommando();
|
|
348
391
|
await commando
|
|
349
392
|
.append(`tsc -p "${pathToLocalTsConfig}" --rootDir "${sourceFolder}" --outDir "${pkg.output}"`)
|
|
350
393
|
.execute();
|
|
394
|
+
projectScreen.updateOrCreatePackage(pkg.name, 'Compiled');
|
|
351
395
|
};
|
|
352
396
|
}
|
|
353
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
|
+
};
|
|
354
416
|
exports.Phase_Compile = {
|
|
355
417
|
type: 'package',
|
|
356
418
|
name: 'compile',
|
|
357
|
-
mandatoryPhases: [exports.
|
|
419
|
+
mandatoryPhases: [exports.Phase_PrepareCompile],
|
|
358
420
|
filter: async (pkg) => pkg.type !== 'sourceless' && !params_1.RuntimeParams.noBuild,
|
|
359
421
|
action: async (pkg) => {
|
|
360
422
|
var _a;
|
|
361
423
|
const packages = consts_1.MemKey_Packages.get();
|
|
362
424
|
if (pkg.type === 'sourceless')
|
|
363
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
|
+
}
|
|
364
444
|
const folder = 'main';
|
|
365
445
|
const sourceFolder = `${pkg.path}/src/${folder}`;
|
|
366
446
|
const pathToLocalTsConfig = `${sourceFolder}/${CONST_TS_Config}`;
|
|
367
|
-
const inPackageTsConfig = await fs_1.promises.readFile(
|
|
447
|
+
const inPackageTsConfig = await fs_1.promises.readFile(pathToLocalTsConfig, { encoding: 'utf-8' });
|
|
368
448
|
const defaultPackageTsConfig = await fs_1.promises.readFile(pathToProjectTS_Config, { encoding: 'utf-8' });
|
|
369
449
|
if (!pkg.customTsConfig && inPackageTsConfig !== defaultPackageTsConfig) {
|
|
370
450
|
await fs_1.promises.copyFile(pathToProjectTS_Config, pathToLocalTsConfig);
|
|
@@ -403,16 +483,19 @@ exports.Phase_CompileWatch = {
|
|
|
403
483
|
type: 'project',
|
|
404
484
|
name: 'compile-watch',
|
|
405
485
|
terminatingPhase: true,
|
|
406
|
-
mandatoryPhases: [exports.
|
|
486
|
+
mandatoryPhases: [exports.Phase_PrepareCompile],
|
|
407
487
|
filter: async () => params_1.RuntimeParams.watch,
|
|
408
488
|
action: async () => {
|
|
409
489
|
const watcher = chokidar.watch(sourcesPaths);
|
|
410
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();
|
|
411
493
|
await project_manager_1.MemKey_ProjectManager.get().updateRunningStatus({
|
|
412
494
|
'phaseKey': 'compile-watch',
|
|
413
495
|
'packageDependencyIndex': 0
|
|
414
496
|
});
|
|
415
497
|
let controller;
|
|
498
|
+
let prevController;
|
|
416
499
|
const watchListener = async (path, deleteDist) => {
|
|
417
500
|
const libPath = (0, ts_common_1._keys)(compileActions).find(libPath => path.startsWith(libPath));
|
|
418
501
|
if (!libPath)
|
|
@@ -429,35 +512,45 @@ exports.Phase_CompileWatch = {
|
|
|
429
512
|
try {
|
|
430
513
|
if (controller)
|
|
431
514
|
controller.abort();
|
|
515
|
+
prevController = controller;
|
|
432
516
|
controller = new AbortController();
|
|
433
|
-
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
|
+
}
|
|
434
526
|
}
|
|
435
527
|
catch (e) {
|
|
436
|
-
|
|
528
|
+
ts_common_1.StaticLogger.logError(e);
|
|
437
529
|
}
|
|
438
530
|
};
|
|
439
531
|
return new Promise((resolve, error) => {
|
|
440
532
|
watcher
|
|
441
533
|
.on('error', (error) => {
|
|
442
|
-
|
|
534
|
+
ts_common_1.StaticLogger.logError('Error while watching', error);
|
|
443
535
|
})
|
|
444
536
|
.on('ready', () => {
|
|
445
|
-
|
|
537
|
+
ts_common_1.StaticLogger.logInfo('Watching: ', sourcesPaths);
|
|
538
|
+
packages.packages.map(pkg => projectScreen.updateOrCreatePackage(pkg.name, 'Watching'));
|
|
446
539
|
watcher
|
|
447
540
|
.on('add', (path) => {
|
|
448
|
-
|
|
541
|
+
ts_common_1.StaticLogger.logInfo(`New File added: ${path}`);
|
|
449
542
|
watchListener(path);
|
|
450
543
|
})
|
|
451
544
|
.on('change', (path) => {
|
|
452
|
-
|
|
545
|
+
ts_common_1.StaticLogger.logInfo(`Detected changes in file: ${path}`);
|
|
453
546
|
watchListener(path);
|
|
454
547
|
})
|
|
455
548
|
.on('unlinkDir', (path) => {
|
|
456
|
-
|
|
549
|
+
ts_common_1.StaticLogger.logInfo(`Deleted Directory: ${path}`);
|
|
457
550
|
watchListener(path, true);
|
|
458
551
|
})
|
|
459
552
|
.on('unlink', (path) => {
|
|
460
|
-
|
|
553
|
+
ts_common_1.StaticLogger.logInfo(`File Deleted: ${path}`);
|
|
461
554
|
watchListener(path, true);
|
|
462
555
|
});
|
|
463
556
|
});
|
|
@@ -481,6 +574,8 @@ exports.Phase_Launch = {
|
|
|
481
574
|
mandatoryPhases: [exports.Phase_ResolveEnv],
|
|
482
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'); },
|
|
483
576
|
action: async (pkg) => {
|
|
577
|
+
const projectScreen = ProjectScreen_1.MemKey_ProjectScreen.get();
|
|
578
|
+
projectScreen.updateOrCreatePackage(pkg.name, 'Deploying Application');
|
|
484
579
|
if (pkg.type === 'firebase-functions-app') {
|
|
485
580
|
await (0, ts_common_1.sleep)(1000 * counter++);
|
|
486
581
|
const allPorts = Array.from({ length: 10 }, (_, i) => `${pkg.envConfig.basePort + i}`);
|
|
@@ -502,6 +597,7 @@ exports.Phase_Launch = {
|
|
|
502
597
|
.append(`pwd`)
|
|
503
598
|
.append(`npm run start`)
|
|
504
599
|
.execute();
|
|
600
|
+
projectScreen.updateOrCreatePackage(pkg.name, 'Application Deployed');
|
|
505
601
|
}
|
|
506
602
|
};
|
|
507
603
|
exports.Phase_DeployFrontend = {
|
|
@@ -514,12 +610,15 @@ exports.Phase_DeployFrontend = {
|
|
|
514
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';
|
|
515
611
|
},
|
|
516
612
|
action: async (pkg) => {
|
|
613
|
+
const projectScreen = ProjectScreen_1.MemKey_ProjectScreen.get();
|
|
517
614
|
if (pkg.type !== 'firebase-hosting-app')
|
|
518
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');
|
|
519
617
|
await nvm_1.NVM.createCommando(basic_1.Cli_Basic)
|
|
520
618
|
.cd(pkg.path)
|
|
521
619
|
.append(`firebase deploy --only hosting`)
|
|
522
620
|
.execute();
|
|
621
|
+
projectScreen.updateOrCreatePackage(pkg.name, 'Hosting Deployed');
|
|
523
622
|
}
|
|
524
623
|
};
|
|
525
624
|
exports.Phase_DeployBackend = {
|
|
@@ -529,11 +628,14 @@ exports.Phase_DeployBackend = {
|
|
|
529
628
|
mandatoryPhases: [exports.Phase_ResolveEnv],
|
|
530
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'; },
|
|
531
630
|
action: async (pkg) => {
|
|
631
|
+
const projectScreen = ProjectScreen_1.MemKey_ProjectScreen.get();
|
|
532
632
|
if (pkg.type !== 'firebase-functions-app')
|
|
533
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');
|
|
534
635
|
await nvm_1.NVM.createCommando(basic_1.Cli_Basic)
|
|
535
636
|
.cd(pkg.path)
|
|
536
637
|
.append(`firebase --debug deploy --only functions --force`)
|
|
537
638
|
.execute();
|
|
639
|
+
projectScreen.updateOrCreatePackage(pkg.name, 'Functions Deployed');
|
|
538
640
|
}
|
|
539
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');
|