@nu-art/build-and-install 0.204.91 → 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/unit/core/BaseUnit.js +8 -4
- package/v2/unit/core/Unit_TypescriptLib.d.ts +1 -0
- package/v2/unit/core/Unit_TypescriptLib.js +4 -1
- package/v2/unit/core/Unit_TypescriptProject.js +1 -3
- package/v2/unit/firebase-units/Unit_FirebaseFunctionsApp.js +3 -1
- package/v2/unit/firebase-units/Unit_FirebaseHostingApp.d.ts +1 -5
- package/v2/unit/firebase-units/Unit_FirebaseHostingApp.js +14 -23
package/package.json
CHANGED
package/v2/unit/core/BaseUnit.js
CHANGED
|
@@ -67,10 +67,14 @@ class BaseUnit extends ts_common_1.Logger {
|
|
|
67
67
|
}
|
|
68
68
|
async kill() {
|
|
69
69
|
if (!this.processTerminator.length)
|
|
70
|
-
return;
|
|
71
|
-
this.
|
|
72
|
-
|
|
73
|
-
|
|
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
|
+
}
|
|
74
78
|
}
|
|
75
79
|
getLogs() {
|
|
76
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);
|
|
@@ -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
|
}
|
|
@@ -246,11 +246,13 @@ class Unit_FirebaseFunctionsApp extends core_1.Unit_TypescriptLib {
|
|
|
246
246
|
async runProxy() {
|
|
247
247
|
let pid;
|
|
248
248
|
const commando = nvm_1.NVM.createInteractiveCommando(basic_1.Cli_Basic);
|
|
249
|
-
|
|
249
|
+
const terminatable = () => commando.gracefullyKill(pid);
|
|
250
|
+
this.registerTerminatable(terminatable);
|
|
250
251
|
await commando.setUID(this.config.key)
|
|
251
252
|
.cd(this.runtime.pathTo.pkg)
|
|
252
253
|
.append('ts-node src/main/proxy.ts')
|
|
253
254
|
.executeAsync(_pid => pid = _pid);
|
|
255
|
+
this.unregisterTerminatable(terminatable);
|
|
254
256
|
}
|
|
255
257
|
async runEmulator() {
|
|
256
258
|
let pid;
|
|
@@ -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() {
|
|
@@ -108,32 +111,20 @@ 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() {
|