@nu-art/build-and-install 0.204.90 → 0.204.92
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/package.json +1 -1
- package/v2/phase-runner/PhaseRunner.d.ts +6 -0
- package/v2/phase-runner/PhaseRunner.js +25 -2
- package/v2/screens/BAIScreen.js +0 -3
- package/v2/unit/core/BaseUnit.d.ts +4 -1
- package/v2/unit/core/BaseUnit.js +16 -1
- package/v2/unit/core/Unit_TypescriptLib.d.ts +1 -0
- package/v2/unit/core/Unit_TypescriptLib.js +12 -5
- package/v2/unit/core/Unit_TypescriptProject.js +1 -3
- package/v2/unit/firebase-units/Unit_FirebaseFunctionsApp.d.ts +1 -9
- package/v2/unit/firebase-units/Unit_FirebaseFunctionsApp.js +23 -81
- package/v2/unit/firebase-units/Unit_FirebaseHostingApp.d.ts +1 -5
- package/v2/unit/firebase-units/Unit_FirebaseHostingApp.js +16 -25
package/package.json
CHANGED
|
@@ -10,6 +10,12 @@ export declare class PhaseRunner extends BaseUnit implements UnitPhaseImplemento
|
|
|
10
10
|
private killed?;
|
|
11
11
|
private runningStatus;
|
|
12
12
|
private phaseFilter;
|
|
13
|
+
/**
|
|
14
|
+
* kill counter that will intercept the kill event and if the threshold will be met the main process will be killed as well
|
|
15
|
+
* @private
|
|
16
|
+
*/
|
|
17
|
+
private killCounter;
|
|
18
|
+
private static KILL_THRESHOLD;
|
|
13
19
|
constructor(projectPath: RelativePath);
|
|
14
20
|
protected init(): Promise<void>;
|
|
15
21
|
private filterUnits;
|
|
@@ -46,6 +46,11 @@ const CONST_ProjectDependencyKey = 'APP_VERSION_DEPENDENCY';
|
|
|
46
46
|
class PhaseRunner extends core_1.BaseUnit {
|
|
47
47
|
constructor(projectPath) {
|
|
48
48
|
super({ label: 'Phase Runner', key: 'phase-runner' });
|
|
49
|
+
/**
|
|
50
|
+
* kill counter that will intercept the kill event and if the threshold will be met the main process will be killed as well
|
|
51
|
+
* @private
|
|
52
|
+
*/
|
|
53
|
+
this.killCounter = 0;
|
|
49
54
|
//######################### Internal Logic #########################
|
|
50
55
|
this.phaseFilters = {
|
|
51
56
|
[types_1.PhaseRunnerMode_Normal]: async (phase) => {
|
|
@@ -372,17 +377,34 @@ class PhaseRunner extends core_1.BaseUnit {
|
|
|
372
377
|
//######################### Public Functions #########################
|
|
373
378
|
async execute() {
|
|
374
379
|
return new MemStorage_1.MemStorage().init(async () => {
|
|
380
|
+
process.on('SIGINT', () => {
|
|
381
|
+
this.killRunner();
|
|
382
|
+
});
|
|
375
383
|
await this.init();
|
|
376
384
|
await this.buildUnitDependencyTree();
|
|
377
385
|
await this.executeImpl();
|
|
378
386
|
});
|
|
379
387
|
}
|
|
380
388
|
async killRunner() {
|
|
381
|
-
this.
|
|
389
|
+
this.killCounter++;
|
|
390
|
+
if (this.killCounter === PhaseRunner.KILL_THRESHOLD)
|
|
391
|
+
process.exit(1);
|
|
392
|
+
if (this.killed)
|
|
393
|
+
process.exit(1);
|
|
382
394
|
await this.setRunningStatus();
|
|
383
395
|
this.logDebug('Killing units');
|
|
384
|
-
await Promise.all(this.units.map(unit =>
|
|
396
|
+
await Promise.all(this.units.map(async (unit) => {
|
|
397
|
+
try {
|
|
398
|
+
await unit.kill();
|
|
399
|
+
}
|
|
400
|
+
catch (e) {
|
|
401
|
+
unit.logError(`Error killing unit`, e);
|
|
402
|
+
}
|
|
403
|
+
}));
|
|
385
404
|
this.logDebug('Units killed');
|
|
405
|
+
this.killed = true;
|
|
406
|
+
if (params_1.RuntimeParams.closeOnExit)
|
|
407
|
+
process.exit(1);
|
|
386
408
|
}
|
|
387
409
|
//######################### Phase Implementation #########################
|
|
388
410
|
async printHelp() {
|
|
@@ -421,4 +443,5 @@ class PhaseRunner extends core_1.BaseUnit {
|
|
|
421
443
|
this.logInfo('Unit Dependencies Tree:', dependencyTree);
|
|
422
444
|
}
|
|
423
445
|
}
|
|
446
|
+
PhaseRunner.KILL_THRESHOLD = 5;
|
|
424
447
|
exports.PhaseRunner = PhaseRunner;
|
package/v2/screens/BAIScreen.js
CHANGED
|
@@ -4,7 +4,6 @@ exports.BAIScreen = void 0;
|
|
|
4
4
|
const ConsoleContainer_1 = require("@nu-art/commando/console/ConsoleContainer");
|
|
5
5
|
const ts_common_1 = require("@nu-art/ts-common");
|
|
6
6
|
const PhaseRunnerDispatcher_1 = require("../phase-runner/PhaseRunnerDispatcher");
|
|
7
|
-
const params_1 = require("../../core/params/params");
|
|
8
7
|
class BAIScreen extends ConsoleContainer_1.ConsoleContainer {
|
|
9
8
|
//######################### Initialization #########################
|
|
10
9
|
/**
|
|
@@ -63,8 +62,6 @@ class BAIScreen extends ConsoleContainer_1.ConsoleContainer {
|
|
|
63
62
|
this.logInfo('Kill command received');
|
|
64
63
|
await ((_a = this.onKillCallback) === null || _a === void 0 ? void 0 : _a.call(this));
|
|
65
64
|
this.logInfo('Killed!');
|
|
66
|
-
if (params_1.RuntimeParams.closeOnExit)
|
|
67
|
-
process.exit(1);
|
|
68
65
|
}
|
|
69
66
|
}
|
|
70
67
|
exports.BAIScreen = BAIScreen;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Logger } from '@nu-art/ts-common';
|
|
1
|
+
import { AsyncVoidFunction, Logger } from '@nu-art/ts-common';
|
|
2
2
|
import { RunnerParamKey } from '../../phase-runner/RunnerParams';
|
|
3
3
|
export type BaseUnit_Config = {
|
|
4
4
|
key: string;
|
|
@@ -15,7 +15,10 @@ export declare class BaseUnit<C extends BaseUnit_Config = BaseUnit_Config, RTC e
|
|
|
15
15
|
private unitStatus?;
|
|
16
16
|
private logger;
|
|
17
17
|
private classStack;
|
|
18
|
+
private processTerminator;
|
|
18
19
|
constructor(config: C);
|
|
20
|
+
registerTerminatable(terminatable: AsyncVoidFunction): void;
|
|
21
|
+
unregisterTerminatable(terminatable: AsyncVoidFunction): void;
|
|
19
22
|
protected init(setInitialized?: boolean): Promise<void>;
|
|
20
23
|
protected getRunnerParam(key: RunnerParamKey): string | undefined;
|
|
21
24
|
private initLogClient;
|
package/v2/unit/core/BaseUnit.js
CHANGED
|
@@ -8,6 +8,7 @@ const params_1 = require("../../../core/params/params");
|
|
|
8
8
|
class BaseUnit extends ts_common_1.Logger {
|
|
9
9
|
constructor(config) {
|
|
10
10
|
super(config.key);
|
|
11
|
+
this.processTerminator = [];
|
|
11
12
|
//######################### Class Stack Logic #########################
|
|
12
13
|
this.addToClassStack = (cls) => {
|
|
13
14
|
this.classStack.add(cls.name);
|
|
@@ -24,6 +25,12 @@ class BaseUnit extends ts_common_1.Logger {
|
|
|
24
25
|
this.addToClassStack(BaseUnit);
|
|
25
26
|
this.initLogClient();
|
|
26
27
|
}
|
|
28
|
+
registerTerminatable(terminatable) {
|
|
29
|
+
this.processTerminator.push(terminatable);
|
|
30
|
+
}
|
|
31
|
+
unregisterTerminatable(terminatable) {
|
|
32
|
+
(0, ts_common_1.removeItemFromArray)(this.processTerminator, terminatable);
|
|
33
|
+
}
|
|
27
34
|
async init(setInitialized = true) {
|
|
28
35
|
this.setStatus('Initializing');
|
|
29
36
|
//Register the unit to PhaseRunnerEvent dispatcher
|
|
@@ -59,7 +66,15 @@ class BaseUnit extends ts_common_1.Logger {
|
|
|
59
66
|
return this.unitStatus;
|
|
60
67
|
}
|
|
61
68
|
async kill() {
|
|
62
|
-
|
|
69
|
+
if (!this.processTerminator.length)
|
|
70
|
+
return this.setStatus('Killed');
|
|
71
|
+
this.setStatus('Killing');
|
|
72
|
+
try {
|
|
73
|
+
await Promise.all(this.processTerminator.map(toTerminate => toTerminate()));
|
|
74
|
+
}
|
|
75
|
+
finally {
|
|
76
|
+
this.setStatus('Killed');
|
|
77
|
+
}
|
|
63
78
|
}
|
|
64
79
|
getLogs() {
|
|
65
80
|
return this.logger.buffers[0];
|
|
@@ -21,6 +21,7 @@ export declare class Unit_TypescriptLib<C extends Unit_TypescriptLib_Config = Un
|
|
|
21
21
|
Phase_Lint
|
|
22
22
|
]>, OnWatchEvent {
|
|
23
23
|
private compilationError;
|
|
24
|
+
private debounceWatch?;
|
|
24
25
|
constructor(config: Unit_TypescriptLib<C, RTC>['config']);
|
|
25
26
|
__onWatchEvent(type: WatchEventType, path?: string): Promise<void>;
|
|
26
27
|
protected init(setInitialized?: boolean): Promise<void>;
|
|
@@ -58,7 +58,10 @@ class Unit_TypescriptLib extends Unit_Typescript_1.Unit_Typescript {
|
|
|
58
58
|
async __onWatchEvent(type, path) {
|
|
59
59
|
if (type === consts_2.WatchEvent_Ready)
|
|
60
60
|
return this.setStatus('Watching');
|
|
61
|
-
|
|
61
|
+
if (this.debounceWatch)
|
|
62
|
+
delete this.debounceWatch;
|
|
63
|
+
this.debounceWatch = (0, ts_common_1.debounce)(() => this.handleWatchChange(path, [consts_2.WatchEvent_RemoveFile, consts_2.WatchEvent_RemoveDir].includes(type)), ts_common_1.Second * 4, ts_common_1.Second * 10);
|
|
64
|
+
this.debounceWatch();
|
|
62
65
|
}
|
|
63
66
|
async init(setInitialized = true) {
|
|
64
67
|
await super.init(false);
|
|
@@ -101,13 +104,17 @@ class Unit_TypescriptLib extends Unit_Typescript_1.Unit_Typescript {
|
|
|
101
104
|
const pathToCompile = `${this.runtime.pathTo.pkg}/src/main`;
|
|
102
105
|
const pathToTSConfig = `${pathToCompile}/tsconfig.json`;
|
|
103
106
|
try {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
+
let pid;
|
|
108
|
+
const commando = nvm_1.NVM.createInteractiveCommando(basic_1.Cli_Basic);
|
|
109
|
+
this.registerTerminatable(async () => {
|
|
110
|
+
console.log(`killing ${pid}`);
|
|
111
|
+
process.kill(pid, 2);
|
|
112
|
+
});
|
|
113
|
+
await commando.setUID(this.config.key)
|
|
107
114
|
.cd(this.runtime.pathTo.pkg)
|
|
108
115
|
.append(`tsc -p "${pathToTSConfig}" --rootDir "${pathToCompile}" --outDir "${this.runtime.pathTo.output}"`)
|
|
109
116
|
.addLogProcessor((log) => !log.includes('Now using node') && !log.includes('.nvmrc\' with version'))
|
|
110
|
-
.
|
|
117
|
+
.executeAsync(_pid => pid = _pid, (stdout, stderr, exitCode) => {
|
|
111
118
|
if (exitCode > 0)
|
|
112
119
|
throw new CliError_1.CommandoException(`Error compiling`, stdout, stderr, exitCode);
|
|
113
120
|
});
|
|
@@ -116,10 +116,8 @@ class Unit_TypescriptProject extends Unit_Typescript_1.Unit_Typescript {
|
|
|
116
116
|
runner_dispatchers_1.dispatcher_WatchEvent.dispatch(consts_2.WatchEvent_RemoveFile, path);
|
|
117
117
|
});
|
|
118
118
|
});
|
|
119
|
-
|
|
119
|
+
this.registerTerminatable(async () => {
|
|
120
120
|
await watcher.close();
|
|
121
|
-
process.exit(0);
|
|
122
|
-
resolve();
|
|
123
121
|
});
|
|
124
122
|
});
|
|
125
123
|
}
|
|
@@ -9,9 +9,6 @@ export type Unit_FirebaseFunctionsApp_Config = Unit_TypescriptLib_Config & {
|
|
|
9
9
|
};
|
|
10
10
|
export declare class Unit_FirebaseFunctionsApp<C extends Unit_FirebaseFunctionsApp_Config = Unit_FirebaseFunctionsApp_Config> extends Unit_TypescriptLib<C> implements UnitPhaseImplementor<[Phase_ResolveConfigs, Phase_Launch, Phase_DeployBackend]>, OnUnitWatchCompiled {
|
|
11
11
|
static staggerCount: number;
|
|
12
|
-
private emulatorPid?;
|
|
13
|
-
private proxyPid?;
|
|
14
|
-
private launchCommandos;
|
|
15
12
|
__onUnitWatchCompiled(unit: BaseUnit): Promise<void>;
|
|
16
13
|
constructor(config: Unit_FirebaseFunctionsApp<C>['config']);
|
|
17
14
|
resolveConfigs(): Promise<void>;
|
|
@@ -26,13 +23,8 @@ export declare class Unit_FirebaseFunctionsApp<C extends Unit_FirebaseFunctionsA
|
|
|
26
23
|
private resolveFunctionsRuntimeConfig;
|
|
27
24
|
private createAppVersionFile;
|
|
28
25
|
private createDependenciesDir;
|
|
29
|
-
private
|
|
30
|
-
private onLaunched;
|
|
31
|
-
private initLaunch;
|
|
32
|
-
private initLaunchListeners;
|
|
26
|
+
private releasePorts;
|
|
33
27
|
private runProxy;
|
|
34
28
|
private runEmulator;
|
|
35
|
-
kill(): Promise<void>;
|
|
36
|
-
private printFiles;
|
|
37
29
|
private deployImpl;
|
|
38
30
|
}
|
|
@@ -52,16 +52,13 @@ class Unit_FirebaseFunctionsApp extends core_1.Unit_TypescriptLib {
|
|
|
52
52
|
async launch() {
|
|
53
53
|
this.setStatus('Launching');
|
|
54
54
|
await (0, ts_common_1.sleep)(2 * ts_common_1.Second * Unit_FirebaseFunctionsApp.staggerCount++);
|
|
55
|
-
await this.
|
|
56
|
-
await this.initLaunchListeners();
|
|
57
|
-
await this.clearPorts();
|
|
55
|
+
await this.releasePorts();
|
|
58
56
|
await Promise.all([
|
|
59
57
|
this.runProxy(),
|
|
60
58
|
this.runEmulator(),
|
|
61
59
|
]);
|
|
62
60
|
}
|
|
63
61
|
async deployBackend() {
|
|
64
|
-
await this.printFiles();
|
|
65
62
|
await this.deployImpl();
|
|
66
63
|
}
|
|
67
64
|
//######################### ResolveConfig Logic #########################
|
|
@@ -237,55 +234,45 @@ class Unit_FirebaseFunctionsApp extends core_1.Unit_TypescriptLib {
|
|
|
237
234
|
this.packageJson.dist = packageJsonConverter(this.packageJson.dist);
|
|
238
235
|
}
|
|
239
236
|
//######################### Launch Logic #########################
|
|
240
|
-
async
|
|
237
|
+
async releasePorts() {
|
|
238
|
+
const commando = nvm_1.NVM.createInteractiveCommando(basic_1.Cli_Basic);
|
|
241
239
|
const allPorts = Array.from({ length: 10 }, (_, i) => `${this.config.firebaseConfig.basePort + i}`);
|
|
242
|
-
await
|
|
240
|
+
await commando.setUID(this.config.key)
|
|
243
241
|
.append(`array=($(lsof -ti:${allPorts.join(',')}))`)
|
|
244
242
|
.append(`((\${#array[@]} > 0)) && kill -9 "\${array[@]}"`)
|
|
245
243
|
.append('echo ')
|
|
246
244
|
.execute();
|
|
247
245
|
}
|
|
248
|
-
onLaunched() {
|
|
249
|
-
this.setStatus('Launch Complete');
|
|
250
|
-
}
|
|
251
|
-
async initLaunch() {
|
|
252
|
-
this.launchCommandos = {
|
|
253
|
-
emulator: nvm_1.NVM.createInteractiveCommando(basic_1.Cli_Basic).setUID(this.config.key).cd(this.runtime.pathTo.pkg),
|
|
254
|
-
proxy: nvm_1.NVM.createInteractiveCommando(basic_1.Cli_Basic).setUID(this.config.key).cd(this.runtime.pathTo.pkg),
|
|
255
|
-
};
|
|
256
|
-
}
|
|
257
|
-
async initLaunchListeners() {
|
|
258
|
-
this.launchCommandos.emulator.onLog(/.*Emulator Hub running.*/, () => this.onLaunched());
|
|
259
|
-
}
|
|
260
246
|
async runProxy() {
|
|
261
|
-
|
|
247
|
+
let pid;
|
|
248
|
+
const commando = nvm_1.NVM.createInteractiveCommando(basic_1.Cli_Basic);
|
|
249
|
+
const terminatable = () => commando.gracefullyKill(pid);
|
|
250
|
+
this.registerTerminatable(terminatable);
|
|
251
|
+
await commando.setUID(this.config.key)
|
|
252
|
+
.cd(this.runtime.pathTo.pkg)
|
|
262
253
|
.append('ts-node src/main/proxy.ts')
|
|
263
|
-
.executeAsync(
|
|
254
|
+
.executeAsync(_pid => pid = _pid);
|
|
255
|
+
this.unregisterTerminatable(terminatable);
|
|
264
256
|
}
|
|
265
257
|
async runEmulator() {
|
|
266
|
-
|
|
258
|
+
let pid;
|
|
259
|
+
const commando = nvm_1.NVM.createInteractiveCommando(basic_1.Cli_Basic);
|
|
260
|
+
const terminatable = () => commando.gracefullyKill(pid);
|
|
261
|
+
this.registerTerminatable(terminatable);
|
|
262
|
+
await commando.setUID(this.config.key)
|
|
263
|
+
.cd(this.runtime.pathTo.pkg)
|
|
264
|
+
.onLog(/.*Emulator Hub running.*/, () => this.setStatus('Launch Complete'))
|
|
267
265
|
.append(`firebase emulators:start --export-on-exit --import=.trash/data ${params_1.RuntimeParams.debugBackend ? `--inspect-functions ${this.config.firebaseConfig.debugPort}` : ''}`)
|
|
268
|
-
.executeAsync(
|
|
269
|
-
|
|
270
|
-
async kill() {
|
|
271
|
-
if (!this.launchCommandos)
|
|
272
|
-
return;
|
|
273
|
-
this.logWarning(`Killing unit - ${this.config.label}`);
|
|
274
|
-
await this.launchCommandos.emulator.gracefullyKill(this.emulatorPid);
|
|
275
|
-
await this.launchCommandos.proxy.gracefullyKill(this.proxyPid);
|
|
276
|
-
this.logWarning(`Unit killed - ${this.config.label}`);
|
|
266
|
+
.executeAsync(_pid => pid = _pid);
|
|
267
|
+
this.unregisterTerminatable(terminatable);
|
|
277
268
|
}
|
|
278
269
|
//######################### Deploy Logic #########################
|
|
279
|
-
async
|
|
280
|
-
await
|
|
270
|
+
async deployImpl() {
|
|
271
|
+
await nvm_1.NVM.createInteractiveCommando(basic_1.Cli_Basic)
|
|
281
272
|
.cd(this.runtime.pathTo.output)
|
|
282
273
|
.ls()
|
|
283
274
|
.cat('package.json')
|
|
284
275
|
.cat('index.js')
|
|
285
|
-
.execute();
|
|
286
|
-
}
|
|
287
|
-
async deployImpl() {
|
|
288
|
-
await nvm_1.NVM.createCommando(basic_1.Cli_Basic)
|
|
289
276
|
.cd(this.runtime.pathTo.pkg)
|
|
290
277
|
.append(`firebase --debug deploy --only functions --force`)
|
|
291
278
|
.execute();
|
|
@@ -293,48 +280,3 @@ class Unit_FirebaseFunctionsApp extends core_1.Unit_TypescriptLib {
|
|
|
293
280
|
}
|
|
294
281
|
Unit_FirebaseFunctionsApp.staggerCount = 0;
|
|
295
282
|
exports.Unit_FirebaseFunctionsApp = Unit_FirebaseFunctionsApp;
|
|
296
|
-
// export class CommandoCLIListener {
|
|
297
|
-
//
|
|
298
|
-
// private cb: CommandoCLIListener_Callback;
|
|
299
|
-
// protected filter?: RegExp;
|
|
300
|
-
//
|
|
301
|
-
// constructor(callback: CommandoCLIListener_Callback, filter?: string | RegExp) {
|
|
302
|
-
// this.cb = callback;
|
|
303
|
-
// if (!filter)
|
|
304
|
-
// return;
|
|
305
|
-
//
|
|
306
|
-
// if (typeof filter === 'string')
|
|
307
|
-
// this.filter = new RegExp(filter);
|
|
308
|
-
// else
|
|
309
|
-
// this.filter = filter as RegExp;
|
|
310
|
-
// }
|
|
311
|
-
//
|
|
312
|
-
// //######################### Inner Logic #########################
|
|
313
|
-
//
|
|
314
|
-
// private _process(stdout: string) {
|
|
315
|
-
// if (!this.stdoutPassesFilter(stdout))
|
|
316
|
-
// return false;
|
|
317
|
-
//
|
|
318
|
-
// this.process(stdout);
|
|
319
|
-
// return true;
|
|
320
|
-
// }
|
|
321
|
-
//
|
|
322
|
-
// private stdoutPassesFilter = (stdout: string): boolean => {
|
|
323
|
-
// if (!this.filter)
|
|
324
|
-
// return true;
|
|
325
|
-
//
|
|
326
|
-
// return this.filter.test(stdout);
|
|
327
|
-
// };
|
|
328
|
-
//
|
|
329
|
-
// //######################### Functions #########################
|
|
330
|
-
//
|
|
331
|
-
// public listen = <T extends Commando | CommandoInteractive>(commando: T): T => {
|
|
332
|
-
// const process = this._process.bind(this);
|
|
333
|
-
// commando.addLogProcessor(process);
|
|
334
|
-
// return commando;
|
|
335
|
-
// };
|
|
336
|
-
//
|
|
337
|
-
// protected process(stdout: string) {
|
|
338
|
-
// this.cb(stdout);
|
|
339
|
-
// }
|
|
340
|
-
// }
|
|
@@ -7,9 +7,8 @@ export type Unit_FirebaseHostingApp_Config = Unit_TypescriptLib_Config & {
|
|
|
7
7
|
sources?: string[];
|
|
8
8
|
};
|
|
9
9
|
export declare class Unit_FirebaseHostingApp<C extends Unit_FirebaseHostingApp_Config = Unit_FirebaseHostingApp_Config> extends Unit_TypescriptLib<C> implements UnitPhaseImplementor<[Phase_ResolveConfigs, Phase_Launch, Phase_DeployFrontend]> {
|
|
10
|
-
private launchCommando;
|
|
11
|
-
private hostingPid;
|
|
12
10
|
constructor(config: Unit_FirebaseHostingApp<C>['config']);
|
|
11
|
+
protected init(setInitialized?: boolean): Promise<void>;
|
|
13
12
|
resolveConfigs(): Promise<void>;
|
|
14
13
|
compile(): Promise<void>;
|
|
15
14
|
launch(): Promise<void>;
|
|
@@ -20,9 +19,6 @@ export declare class Unit_FirebaseHostingApp<C extends Unit_FirebaseHostingApp_C
|
|
|
20
19
|
private resolveHostingRuntimeConfig;
|
|
21
20
|
protected compileImpl(): Promise<void>;
|
|
22
21
|
private createAppVersionFile;
|
|
23
|
-
private initLaunch;
|
|
24
|
-
private clearPorts;
|
|
25
22
|
private runApp;
|
|
26
|
-
kill(): Promise<void>;
|
|
27
23
|
private deployImpl;
|
|
28
24
|
}
|
|
@@ -18,6 +18,11 @@ class Unit_FirebaseHostingApp extends core_1.Unit_TypescriptLib {
|
|
|
18
18
|
this.addToClassStack(Unit_FirebaseHostingApp);
|
|
19
19
|
runner_dispatchers_1.dispatcher_WatchEvent.removeListener(this);
|
|
20
20
|
}
|
|
21
|
+
async init(setInitialized = true) {
|
|
22
|
+
await super.init(setInitialized);
|
|
23
|
+
if (!this.config.firebaseConfig.hostingPort)
|
|
24
|
+
throw new ts_common_1.BadImplementationException(`Unit ${this.config.label} missing hosting port in firebaseConfig`);
|
|
25
|
+
}
|
|
21
26
|
//######################### Phase Implementations #########################
|
|
22
27
|
async resolveConfigs() {
|
|
23
28
|
await this.resolveHostingRC();
|
|
@@ -34,8 +39,6 @@ class Unit_FirebaseHostingApp extends core_1.Unit_TypescriptLib {
|
|
|
34
39
|
}
|
|
35
40
|
async launch() {
|
|
36
41
|
this.setStatus('Launching');
|
|
37
|
-
await this.initLaunch();
|
|
38
|
-
await this.clearPorts();
|
|
39
42
|
await this.runApp();
|
|
40
43
|
}
|
|
41
44
|
async deployFrontend() {
|
|
@@ -94,7 +97,7 @@ class Unit_FirebaseHostingApp extends core_1.Unit_TypescriptLib {
|
|
|
94
97
|
//######################### Compile Logic #########################
|
|
95
98
|
async compileImpl() {
|
|
96
99
|
await nvm_1.NVM
|
|
97
|
-
.
|
|
100
|
+
.createInteractiveCommando(basic_1.Cli_Basic)
|
|
98
101
|
.cd(this.runtime.pathTo.pkg)
|
|
99
102
|
.append(`ENV=${params_1.RuntimeParams.environment} npm run build`)
|
|
100
103
|
.execute();
|
|
@@ -108,36 +111,24 @@ class Unit_FirebaseHostingApp extends core_1.Unit_TypescriptLib {
|
|
|
108
111
|
await fs_1.promises.writeFile(targetPath, fileContent, { encoding: 'utf-8' });
|
|
109
112
|
}
|
|
110
113
|
//######################### Launch Logic #########################
|
|
111
|
-
async
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
114
|
+
async runApp() {
|
|
115
|
+
let pid;
|
|
116
|
+
const commando = nvm_1.NVM.createInteractiveCommando(basic_1.Cli_Basic);
|
|
117
|
+
const terminatable = () => commando.gracefullyKill(pid);
|
|
118
|
+
this.registerTerminatable(terminatable);
|
|
119
|
+
await commando
|
|
115
120
|
.setUID(this.config.key)
|
|
116
|
-
.cd(this.runtime.pathTo.pkg)
|
|
117
|
-
}
|
|
118
|
-
async clearPorts() {
|
|
119
|
-
await this.launchCommando
|
|
121
|
+
.cd(this.runtime.pathTo.pkg)
|
|
120
122
|
.append(`array=($(lsof -ti:${[this.config.firebaseConfig.hostingPort].join(',')}))`)
|
|
121
123
|
.append(`((\${#array[@]} > 0)) && kill -9 "\${array[@]}"`)
|
|
122
124
|
.append('echo ')
|
|
123
|
-
.execute();
|
|
124
|
-
}
|
|
125
|
-
async runApp() {
|
|
126
|
-
await this.launchCommando
|
|
127
125
|
.append('npm run start')
|
|
128
|
-
.executeAsync(
|
|
129
|
-
|
|
130
|
-
async kill() {
|
|
131
|
-
var _a;
|
|
132
|
-
if (!this.launchCommando)
|
|
133
|
-
return;
|
|
134
|
-
this.logWarning(`Killing unit - ${this.config.label}`);
|
|
135
|
-
await ((_a = this.launchCommando) === null || _a === void 0 ? void 0 : _a.gracefullyKill(this.hostingPid));
|
|
136
|
-
this.logWarning(`Unit killed - ${this.config.label}`);
|
|
126
|
+
.executeAsync(_pid => pid = _pid);
|
|
127
|
+
this.unregisterTerminatable(terminatable);
|
|
137
128
|
}
|
|
138
129
|
//######################### Deploy Logic #########################
|
|
139
130
|
async deployImpl() {
|
|
140
|
-
await nvm_1.NVM.
|
|
131
|
+
await nvm_1.NVM.createInteractiveCommando(basic_1.Cli_Basic)
|
|
141
132
|
.cd(this.runtime.pathTo.pkg)
|
|
142
133
|
.append(`firebase --debug deploy --only hosting`)
|
|
143
134
|
.execute();
|