@nu-art/build-and-install 0.204.81 → 0.204.83
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 +1 -8
- package/package.json +1 -1
- package/v2/phase-runner/PhaseRunner.d.ts +1 -5
- package/v2/phase-runner/PhaseRunner.js +4 -30
- package/v2/phase-runner/PhaseRunnerDispatcher.d.ts +1 -2
- package/v2/phase-runner/PhaseRunnerDispatcher.js +2 -1
- package/v2/screens/BAIScreen.d.ts +3 -2
- package/v2/screens/BAIScreen.js +16 -6
- package/v2/screens/BAIScreenManager.d.ts +27 -0
- package/v2/screens/BAIScreenManager.js +83 -0
- package/v2/screens/BAIScreen_Launch.d.ts +2 -0
- package/v2/screens/BAIScreen_Launch.js +8 -8
- package/v2/screens/BAIScreen_UnitList.d.ts +3 -0
- package/v2/screens/BAIScreen_UnitList.js +13 -7
- package/v2/unit/consts.d.ts +6 -0
- package/v2/unit/consts.js +8 -0
- package/v2/unit/core/Unit_TypescriptLib.d.ts +11 -2
- package/v2/unit/core/Unit_TypescriptLib.js +45 -0
- package/v2/unit/core/Unit_TypescriptProject.d.ts +16 -2
- package/v2/unit/core/Unit_TypescriptProject.js +96 -0
- package/v2/unit/firebase-units/Unit_FirebaseFunctionsApp.d.ts +4 -2
- package/v2/unit/firebase-units/Unit_FirebaseFunctionsApp.js +12 -0
- package/v2/unit/firebase-units/Unit_FirebaseHostingApp.js +2 -0
- package/v2/unit/runner-dispatchers.d.ts +11 -0
- package/v2/unit/runner-dispatchers.js +6 -0
- package/v2/unit/types.d.ts +1 -0
package/build-and-install.js
CHANGED
|
@@ -4,15 +4,8 @@ const ts_common_1 = require("@nu-art/ts-common");
|
|
|
4
4
|
const params_1 = require("./core/params/params");
|
|
5
5
|
const PhaseRunner_1 = require("./v2/phase-runner/PhaseRunner");
|
|
6
6
|
const thunderstorm_1 = require("./v2/unit/thunderstorm");
|
|
7
|
-
// @ts-ignore
|
|
8
|
-
const BAIScreen_UnitList_1 = require("./v2/screens/BAIScreen_UnitList");
|
|
9
7
|
ts_common_1.DebugFlag.DefaultLogLevel = params_1.RuntimeParams.debug ? ts_common_1.LogLevel.Debug : ts_common_1.LogLevel.Info;
|
|
10
8
|
const runner = new PhaseRunner_1.PhaseRunner('./.config/project-config-v2.ts');
|
|
11
|
-
const screen = new BAIScreen_UnitList_1.BAIScreen_UnitList();
|
|
12
|
-
// const screen = new BAIScreen_Launch();
|
|
13
|
-
// screen.setWithRunningLogs(true);
|
|
14
|
-
screen.setOnKillCallback(async () => await runner.killRunner());
|
|
15
|
-
runner.setScreen(screen);
|
|
16
9
|
if (params_1.RuntimeParams.runWithThunderstorm)
|
|
17
10
|
runner.registerUnits(thunderstorm_1.allTSUnits);
|
|
18
11
|
runner
|
|
@@ -20,7 +13,7 @@ runner
|
|
|
20
13
|
.then(() => {
|
|
21
14
|
ts_common_1.StaticLogger.logInfo('completed');
|
|
22
15
|
//TODO: make it an array of non exit params
|
|
23
|
-
if (!params_1.RuntimeParams.launch)
|
|
16
|
+
if (!params_1.RuntimeParams.launch && !params_1.RuntimeParams.watch)
|
|
24
17
|
process.exit(0);
|
|
25
18
|
})
|
|
26
19
|
.catch(err => {
|
package/package.json
CHANGED
|
@@ -2,21 +2,17 @@ import { RelativePath } from '@nu-art/ts-common';
|
|
|
2
2
|
import { Phase, Phase_Debug, Phase_Help, Phase_PrintEnv } from '../phase';
|
|
3
3
|
import { UnitPhaseImplementor } from '../unit/types';
|
|
4
4
|
import { BaseUnit } from '../unit/core';
|
|
5
|
-
import { BAIScreen } from '../screens/BAIScreen';
|
|
6
5
|
export declare class PhaseRunner extends BaseUnit implements UnitPhaseImplementor<[Phase_Help, Phase_PrintEnv, Phase_Debug]> {
|
|
7
6
|
private readonly phases;
|
|
8
7
|
private readonly units;
|
|
9
8
|
private unitDependencyTree;
|
|
10
9
|
private readonly project;
|
|
11
10
|
private runningStatus;
|
|
12
|
-
private screen?;
|
|
13
11
|
private phaseFilter;
|
|
14
12
|
constructor(projectPath: RelativePath);
|
|
15
13
|
protected init(): Promise<void>;
|
|
16
14
|
private filterUnits;
|
|
17
15
|
private loadProject;
|
|
18
|
-
private showAllLogs;
|
|
19
|
-
private showScreenLogs;
|
|
20
16
|
private prepareProjectParams;
|
|
21
17
|
private prepareDefaultFileRouts;
|
|
22
18
|
private buildUnitDependencyTree;
|
|
@@ -57,11 +53,11 @@ export declare class PhaseRunner extends BaseUnit implements UnitPhaseImplemento
|
|
|
57
53
|
* @param afterPhase
|
|
58
54
|
*/
|
|
59
55
|
appendPhase(phase: Phase<string>, afterPhase: Phase<string>): void;
|
|
56
|
+
getPhases: () => Phase<string>[];
|
|
60
57
|
private setRunningStatus;
|
|
61
58
|
private loadRunningStatus;
|
|
62
59
|
execute(): Promise<void>;
|
|
63
60
|
killRunner(): Promise<void>;
|
|
64
|
-
setScreen(screen: BAIScreen): void;
|
|
65
61
|
printHelp(): Promise<void>;
|
|
66
62
|
printEnv(): Promise<void>;
|
|
67
63
|
debug(): Promise<void>;
|
|
@@ -38,6 +38,7 @@ const basic_1 = require("@nu-art/commando/cli/basic");
|
|
|
38
38
|
const PhaseRunnerDispatcher_1 = require("./PhaseRunnerDispatcher");
|
|
39
39
|
const consts_2 = require("./consts");
|
|
40
40
|
const types_1 = require("./types");
|
|
41
|
+
const BAIScreenManager_1 = require("../screens/BAIScreenManager");
|
|
41
42
|
class PhaseRunner extends core_1.BaseUnit {
|
|
42
43
|
constructor(projectPath) {
|
|
43
44
|
super({ label: 'Phase Runner', key: 'phase-runner' });
|
|
@@ -63,12 +64,12 @@ class PhaseRunner extends core_1.BaseUnit {
|
|
|
63
64
|
return dependencyKeys.includes(phase.key);
|
|
64
65
|
}
|
|
65
66
|
};
|
|
67
|
+
this.getPhases = () => [...this.phases];
|
|
66
68
|
this.addToClassStack(PhaseRunner);
|
|
67
69
|
this.phases = [];
|
|
68
70
|
this.units = [this];
|
|
69
71
|
this.project = { path: (0, tools_1.convertToFullPath)(projectPath), config: {} };
|
|
70
72
|
this.phaseFilter = this.phaseFilters[types_1.PhaseRunnerMode_Normal];
|
|
71
|
-
this.showAllLogs();
|
|
72
73
|
this.setMinLevel(ts_common_1.LogLevel.Verbose);
|
|
73
74
|
}
|
|
74
75
|
//######################### Initialization #########################
|
|
@@ -76,17 +77,12 @@ class PhaseRunner extends core_1.BaseUnit {
|
|
|
76
77
|
// await super.init(false);
|
|
77
78
|
//Set phase runner to MemKey, so it can be referenced in the runtime
|
|
78
79
|
consts_2.MemKey_PhaseRunner.set(this);
|
|
80
|
+
//Init screen manager
|
|
81
|
+
new BAIScreenManager_1.BAIScreenManager();
|
|
79
82
|
//Load project for use in the phase runner
|
|
80
83
|
await this.loadProject();
|
|
81
84
|
//Filter specific units
|
|
82
85
|
this.filterUnits();
|
|
83
|
-
//Set Logger if one is not already set, or if the allLogs flag is set
|
|
84
|
-
if (!this.screen || params_1.RuntimeParams.allLogs) {
|
|
85
|
-
this.showAllLogs();
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
this.showScreenLogs();
|
|
89
|
-
}
|
|
90
86
|
this.logDebug('Runtime params:', params_1.RuntimeParams);
|
|
91
87
|
//Set runner params
|
|
92
88
|
const runnerParams = {
|
|
@@ -135,25 +131,6 @@ class PhaseRunner extends core_1.BaseUnit {
|
|
|
135
131
|
throw new ts_common_1.BadImplementationException('Config file must be an asynchronous function returning a ProjectConfigV2 object');
|
|
136
132
|
this.project.config = await projectConfigCB();
|
|
137
133
|
}
|
|
138
|
-
showAllLogs() {
|
|
139
|
-
if (this.screen)
|
|
140
|
-
// @ts-ignore
|
|
141
|
-
ts_common_1.BeLogged.removeClient(this.screen.logClient);
|
|
142
|
-
ts_common_1.BeLogged.addClient(ts_common_1.LogClient_Terminal);
|
|
143
|
-
//If no screen is set, PhaseRunner should be responsible to listening to kill command
|
|
144
|
-
//Listen on kill signal
|
|
145
|
-
process.on('SIGINT', async () => {
|
|
146
|
-
this.logInfo('Kill command received, killing units!');
|
|
147
|
-
await this.killRunner();
|
|
148
|
-
this.logInfo('Killed');
|
|
149
|
-
process.exit(0);
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
showScreenLogs() {
|
|
153
|
-
if (!this.screen)
|
|
154
|
-
throw new ts_common_1.ThisShouldNotHappenException('Calling showScreenLogs without a screen set!');
|
|
155
|
-
this.screen.create();
|
|
156
|
-
}
|
|
157
134
|
prepareProjectParams() {
|
|
158
135
|
var _a;
|
|
159
136
|
const params = (_a = this.project.config.params) !== null && _a !== void 0 ? _a : {};
|
|
@@ -398,9 +375,6 @@ class PhaseRunner extends core_1.BaseUnit {
|
|
|
398
375
|
this.logDebug('Units killed');
|
|
399
376
|
await this.setRunningStatus();
|
|
400
377
|
}
|
|
401
|
-
setScreen(screen) {
|
|
402
|
-
this.screen = screen;
|
|
403
|
-
}
|
|
404
378
|
//######################### Phase Implementation #########################
|
|
405
379
|
async printHelp() {
|
|
406
380
|
this.logInfo('Build and install parameters:');
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FunctionKeys, ParamResolver } from '@nu-art/ts-common';
|
|
2
2
|
import { Phase } from '../phase/types';
|
|
3
3
|
import { BaseUnit } from '../unit/core';
|
|
4
|
-
declare class PhaseRunnerDispatcher<T, K extends FunctionKeys<T> = FunctionKeys<T>, P extends ParamResolver<T, K> = ParamResolver<T, K>> {
|
|
4
|
+
export declare class PhaseRunnerDispatcher<T, K extends FunctionKeys<T> = FunctionKeys<T>, P extends ParamResolver<T, K> = ParamResolver<T, K>> {
|
|
5
5
|
private readonly method;
|
|
6
6
|
constructor(method: K);
|
|
7
7
|
private listeners;
|
|
@@ -21,4 +21,3 @@ export interface PhaseRunner_OnUnitsChange {
|
|
|
21
21
|
__onUnitsChange: (data: BaseUnit[]) => void;
|
|
22
22
|
}
|
|
23
23
|
export declare const dispatcher_UnitChange: PhaseRunnerDispatcher<PhaseRunner_OnUnitsChange, "__onUnitsChange", [data: BaseUnit<import("../unit/core").BaseUnit_Config, import("../unit/core").BaseUnit_RuntimeConfig>[]]>;
|
|
24
|
-
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.dispatcher_UnitChange = exports.dispatcher_UnitStatusChange = exports.dispatcher_PhaseChange = void 0;
|
|
3
|
+
exports.dispatcher_UnitChange = exports.dispatcher_UnitStatusChange = exports.dispatcher_PhaseChange = exports.PhaseRunnerDispatcher = void 0;
|
|
4
4
|
const ts_common_1 = require("@nu-art/ts-common");
|
|
5
5
|
class PhaseRunnerDispatcher {
|
|
6
6
|
constructor(method) {
|
|
@@ -24,6 +24,7 @@ class PhaseRunnerDispatcher {
|
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
+
exports.PhaseRunnerDispatcher = PhaseRunnerDispatcher;
|
|
27
28
|
exports.dispatcher_PhaseChange = new PhaseRunnerDispatcher('__onPhaseChange');
|
|
28
29
|
exports.dispatcher_UnitStatusChange = new PhaseRunnerDispatcher('__onUnitStatusChange');
|
|
29
30
|
exports.dispatcher_UnitChange = new PhaseRunnerDispatcher('__onUnitsChange');
|
|
@@ -11,10 +11,11 @@ export declare abstract class BAIScreen<State extends {} = {}> extends ConsoleCo
|
|
|
11
11
|
*/
|
|
12
12
|
constructor(logClientKey: string);
|
|
13
13
|
private createLogClient;
|
|
14
|
-
startLogClient: () => void;
|
|
15
|
-
stopLogClient: () => void;
|
|
16
14
|
protected abstract onLogUpdated: () => void;
|
|
17
15
|
protected getLogs: () => string;
|
|
16
|
+
startScreen: () => void;
|
|
17
|
+
stopScreen: () => void;
|
|
18
|
+
protected abstract destroyContent(): void;
|
|
18
19
|
protected onKill(): Promise<never>;
|
|
19
20
|
setOnKillCallback: (cb: AsyncVoidFunction) => AsyncVoidFunction;
|
|
20
21
|
}
|
package/v2/screens/BAIScreen.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
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
|
+
const PhaseRunnerDispatcher_1 = require("../phase-runner/PhaseRunnerDispatcher");
|
|
6
7
|
class BAIScreen extends ConsoleContainer_1.ConsoleContainer {
|
|
7
8
|
//######################### Initialization #########################
|
|
8
9
|
/**
|
|
@@ -16,17 +17,26 @@ class BAIScreen extends ConsoleContainer_1.ConsoleContainer {
|
|
|
16
17
|
keys: ['escape', 'q', 'C-c'],
|
|
17
18
|
callback: async () => await this.onKill(),
|
|
18
19
|
}]);
|
|
19
|
-
|
|
20
|
-
this.
|
|
21
|
-
//
|
|
22
|
-
|
|
20
|
+
this.getLogs = () => this.logClient.buffers[0];
|
|
21
|
+
this.startScreen = () => {
|
|
22
|
+
//Start listening on dispatchers
|
|
23
|
+
PhaseRunnerDispatcher_1.dispatcher_UnitStatusChange.addListener(this);
|
|
24
|
+
PhaseRunnerDispatcher_1.dispatcher_PhaseChange.addListener(this);
|
|
25
|
+
PhaseRunnerDispatcher_1.dispatcher_UnitChange.addListener(this);
|
|
23
26
|
//Add this log client to BeLogged
|
|
24
27
|
ts_common_1.BeLogged.addClient(this.logClient);
|
|
28
|
+
this.create();
|
|
25
29
|
};
|
|
26
|
-
this.
|
|
30
|
+
this.stopScreen = () => {
|
|
31
|
+
//Stop listening on dispatchers
|
|
32
|
+
PhaseRunnerDispatcher_1.dispatcher_UnitStatusChange.removeListener(this);
|
|
33
|
+
PhaseRunnerDispatcher_1.dispatcher_PhaseChange.removeListener(this);
|
|
34
|
+
PhaseRunnerDispatcher_1.dispatcher_UnitChange.removeListener(this);
|
|
35
|
+
//Remove this log client to BeLogged
|
|
27
36
|
ts_common_1.BeLogged.removeClient(this.logClient);
|
|
37
|
+
this.destroyContent();
|
|
38
|
+
this.container.destroy();
|
|
28
39
|
};
|
|
29
|
-
this.getLogs = () => this.logClient.buffers[0];
|
|
30
40
|
this.setOnKillCallback = (cb) => this.onKillCallback = cb;
|
|
31
41
|
this.createLogClient(logClientKey);
|
|
32
42
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { MemKey } from '@nu-art/ts-common/mem-storage/MemStorage';
|
|
2
|
+
import { BAIScreen } from './BAIScreen';
|
|
3
|
+
import { Phase } from '../phase';
|
|
4
|
+
import { PhaseRunner_OnPhaseChange } from '../phase-runner/PhaseRunnerDispatcher';
|
|
5
|
+
export declare const MemKey_BAIScreenManager: MemKey<BAIScreenManager>;
|
|
6
|
+
type BAIScreenConditions = {
|
|
7
|
+
startOnPhase?: Phase<string>;
|
|
8
|
+
stopOnPhase?: Phase<string>;
|
|
9
|
+
};
|
|
10
|
+
type BAIScreenOption = {
|
|
11
|
+
screen: BAIScreen;
|
|
12
|
+
conditions: BAIScreenConditions;
|
|
13
|
+
};
|
|
14
|
+
export declare class BAIScreenManager implements PhaseRunner_OnPhaseChange {
|
|
15
|
+
readonly screens: BAIScreenOption[];
|
|
16
|
+
private currentPhase?;
|
|
17
|
+
private currentScreen?;
|
|
18
|
+
constructor();
|
|
19
|
+
__onPhaseChange: (phase: Phase<string>) => void;
|
|
20
|
+
addScreen: (screen: BAIScreen, conditions: BAIScreenConditions) => void;
|
|
21
|
+
removeScreen: (screen: BAIScreen) => void;
|
|
22
|
+
private getScreenOption;
|
|
23
|
+
private reAssignScreen;
|
|
24
|
+
private assignTerminal;
|
|
25
|
+
private assignScreenOption;
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BAIScreenManager = exports.MemKey_BAIScreenManager = void 0;
|
|
4
|
+
const MemStorage_1 = require("@nu-art/ts-common/mem-storage/MemStorage");
|
|
5
|
+
const ts_common_1 = require("@nu-art/ts-common");
|
|
6
|
+
const PhaseRunnerDispatcher_1 = require("../phase-runner/PhaseRunnerDispatcher");
|
|
7
|
+
const consts_1 = require("../phase-runner/consts");
|
|
8
|
+
exports.MemKey_BAIScreenManager = new MemStorage_1.MemKey('bai-screen-manager');
|
|
9
|
+
class BAIScreenManager {
|
|
10
|
+
constructor() {
|
|
11
|
+
this.screens = [];
|
|
12
|
+
this.__onPhaseChange = (phase) => {
|
|
13
|
+
this.currentPhase = phase;
|
|
14
|
+
this.reAssignScreen();
|
|
15
|
+
};
|
|
16
|
+
// ######################### Screens #########################
|
|
17
|
+
this.addScreen = (screen, conditions) => {
|
|
18
|
+
if (this.screens.find(op => op.screen === screen))
|
|
19
|
+
return;
|
|
20
|
+
this.screens.push({ screen, conditions });
|
|
21
|
+
};
|
|
22
|
+
this.removeScreen = (screen) => {
|
|
23
|
+
const index = this.screens.findIndex(op => op.screen === screen);
|
|
24
|
+
if (index === -1)
|
|
25
|
+
return;
|
|
26
|
+
(0, ts_common_1.removeFromArrayByIndex)(this.screens, index);
|
|
27
|
+
};
|
|
28
|
+
exports.MemKey_BAIScreenManager.set(this);
|
|
29
|
+
PhaseRunnerDispatcher_1.dispatcher_PhaseChange.addListener(this);
|
|
30
|
+
this.assignTerminal();
|
|
31
|
+
}
|
|
32
|
+
// ######################### Screen Transition Logic #########################
|
|
33
|
+
getScreenOption() {
|
|
34
|
+
const phases = consts_1.MemKey_PhaseRunner.get().getPhases();
|
|
35
|
+
const currentPhaseIndex = this.currentPhase ? phases.indexOf(this.currentPhase) : -1;
|
|
36
|
+
return this.screens.find(screenOption => {
|
|
37
|
+
//Fail fast if current phase is on or past the stopOnPhase
|
|
38
|
+
if (screenOption.conditions.stopOnPhase) {
|
|
39
|
+
const index = phases.indexOf(screenOption.conditions.stopOnPhase);
|
|
40
|
+
if (currentPhaseIndex >= index)
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
//Fail fast if current phase is before the startOnPhase
|
|
44
|
+
if (screenOption.conditions.startOnPhase) {
|
|
45
|
+
const index = phases.indexOf(screenOption.conditions.startOnPhase);
|
|
46
|
+
if (currentPhaseIndex < index)
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
return true;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
reAssignScreen() {
|
|
53
|
+
const screenToAssign = this.getScreenOption();
|
|
54
|
+
//No screen conditions pass
|
|
55
|
+
if (!screenToAssign)
|
|
56
|
+
return this.assignTerminal();
|
|
57
|
+
this.assignScreenOption(screenToAssign);
|
|
58
|
+
}
|
|
59
|
+
assignTerminal() {
|
|
60
|
+
//Un assign current screen
|
|
61
|
+
if (this.currentScreen) {
|
|
62
|
+
this.currentScreen.screen.stopScreen();
|
|
63
|
+
}
|
|
64
|
+
ts_common_1.BeLogged.addClient(ts_common_1.LogClient_Terminal);
|
|
65
|
+
}
|
|
66
|
+
assignScreenOption(screen) {
|
|
67
|
+
//No need to do anything if same screen
|
|
68
|
+
if (this.currentScreen === screen)
|
|
69
|
+
return;
|
|
70
|
+
//Un assign current screen
|
|
71
|
+
if (this.currentScreen) {
|
|
72
|
+
this.currentScreen.screen.stopScreen();
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
//Remove terminal from the BeLogged
|
|
76
|
+
ts_common_1.BeLogged.removeClient(ts_common_1.LogClient_Terminal);
|
|
77
|
+
}
|
|
78
|
+
//Assign given screen
|
|
79
|
+
this.currentScreen = screen;
|
|
80
|
+
this.currentScreen.screen.startScreen();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
exports.BAIScreenManager = BAIScreenManager;
|
|
@@ -14,6 +14,8 @@ export declare class BAIScreen_Launch extends BAIScreen implements PhaseRunner_O
|
|
|
14
14
|
private createGridWidgets;
|
|
15
15
|
private calculateGridDimensions;
|
|
16
16
|
private getGridWidgetLabel;
|
|
17
|
+
protected destroyContent(): void;
|
|
18
|
+
private destroyGridWidgets;
|
|
17
19
|
protected render(): void;
|
|
18
20
|
private getContentForWidget;
|
|
19
21
|
private renderGridWidgets;
|
|
@@ -4,7 +4,6 @@ exports.BAIScreen_Launch = void 0;
|
|
|
4
4
|
const BAIScreen_1 = require("./BAIScreen");
|
|
5
5
|
const consts_1 = require("../phase-runner/consts");
|
|
6
6
|
const firebase_units_1 = require("../unit/firebase-units");
|
|
7
|
-
const PhaseRunnerDispatcher_1 = require("../phase-runner/PhaseRunnerDispatcher");
|
|
8
7
|
class BAIScreen_Launch extends BAIScreen_1.BAIScreen {
|
|
9
8
|
//######################### Lifecycle #########################
|
|
10
9
|
constructor() {
|
|
@@ -31,7 +30,7 @@ class BAIScreen_Launch extends BAIScreen_1.BAIScreen {
|
|
|
31
30
|
});
|
|
32
31
|
};
|
|
33
32
|
this.createGridWidgets = () => {
|
|
34
|
-
this.
|
|
33
|
+
this.destroyGridWidgets();
|
|
35
34
|
this.calculateGridDimensions();
|
|
36
35
|
let xPos = 0;
|
|
37
36
|
let widgetIndex = 0;
|
|
@@ -86,6 +85,9 @@ class BAIScreen_Launch extends BAIScreen_1.BAIScreen {
|
|
|
86
85
|
return this.units[index].config.label;
|
|
87
86
|
return index === this.units.length ? 'Running Logs' : this.units[index].config.label;
|
|
88
87
|
};
|
|
88
|
+
this.destroyGridWidgets = () => {
|
|
89
|
+
this.gridCellWidgets.forEach(widget => widget.destroy());
|
|
90
|
+
};
|
|
89
91
|
this.getContentForWidget = (widgetIndex) => {
|
|
90
92
|
var _a, _b;
|
|
91
93
|
if (!this.withRunningLogs) {
|
|
@@ -113,12 +115,10 @@ class BAIScreen_Launch extends BAIScreen_1.BAIScreen {
|
|
|
113
115
|
createContent() {
|
|
114
116
|
this.updateUnits();
|
|
115
117
|
this.createGridWidgets();
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
//Start the log client
|
|
121
|
-
this.startLogClient();
|
|
118
|
+
}
|
|
119
|
+
//######################### Content Destruction #########################
|
|
120
|
+
destroyContent() {
|
|
121
|
+
this.destroyGridWidgets();
|
|
122
122
|
}
|
|
123
123
|
//######################### Render #########################
|
|
124
124
|
render() {
|
|
@@ -17,7 +17,10 @@ export declare class BAIScreen_UnitList extends BAIScreen<State> implements Phas
|
|
|
17
17
|
__onUnitStatusChange(unit: BaseUnit): void;
|
|
18
18
|
__onUnitsChange(data: BaseUnit[]): void;
|
|
19
19
|
protected onLogUpdated: () => void;
|
|
20
|
+
protected destroyContent(): void;
|
|
21
|
+
private destroyPhaseWidget;
|
|
20
22
|
private destroyUnitListWidget;
|
|
23
|
+
private destroyLogWidget;
|
|
21
24
|
protected createContent(): void;
|
|
22
25
|
private createPhaseWidget;
|
|
23
26
|
private createUnitListWidget;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BAIScreen_UnitList = void 0;
|
|
4
|
-
const PhaseRunnerDispatcher_1 = require("../phase-runner/PhaseRunnerDispatcher");
|
|
5
4
|
const BAIScreen_1 = require("./BAIScreen");
|
|
6
5
|
const consts_1 = require("../phase-runner/consts");
|
|
7
6
|
class BAIScreen_UnitList extends BAIScreen_1.BAIScreen {
|
|
@@ -27,23 +26,30 @@ class BAIScreen_UnitList extends BAIScreen_1.BAIScreen {
|
|
|
27
26
|
this.renderUnitList();
|
|
28
27
|
}
|
|
29
28
|
//######################### Content Destruction #########################
|
|
29
|
+
destroyContent() {
|
|
30
|
+
this.destroyPhaseWidget();
|
|
31
|
+
this.destroyUnitListWidget();
|
|
32
|
+
this.destroyLogWidget();
|
|
33
|
+
}
|
|
34
|
+
destroyPhaseWidget() {
|
|
35
|
+
var _a;
|
|
36
|
+
(_a = this.phaseWidget) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
37
|
+
}
|
|
30
38
|
destroyUnitListWidget() {
|
|
31
39
|
var _a, _b;
|
|
32
40
|
(_a = this.unitWrapperWidget) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
33
41
|
(_b = this.unitWidgets) === null || _b === void 0 ? void 0 : _b.forEach(group => group.forEach(widget => widget.destroy()));
|
|
34
42
|
}
|
|
43
|
+
destroyLogWidget() {
|
|
44
|
+
var _a;
|
|
45
|
+
(_a = this.logWidget) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
46
|
+
}
|
|
35
47
|
//######################### Content Creation #########################
|
|
36
48
|
createContent() {
|
|
37
49
|
//Create widgets
|
|
38
50
|
this.createPhaseWidget();
|
|
39
51
|
this.createUnitListWidget();
|
|
40
52
|
this.createLogWidget();
|
|
41
|
-
//Start listening on dispatchers
|
|
42
|
-
PhaseRunnerDispatcher_1.dispatcher_UnitStatusChange.addListener(this);
|
|
43
|
-
PhaseRunnerDispatcher_1.dispatcher_PhaseChange.addListener(this);
|
|
44
|
-
PhaseRunnerDispatcher_1.dispatcher_UnitChange.addListener(this);
|
|
45
|
-
//Start the log client
|
|
46
|
-
this.startLogClient();
|
|
47
53
|
}
|
|
48
54
|
createPhaseWidget() {
|
|
49
55
|
const props = {
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { WatchEventType } from './types';
|
|
2
|
+
export declare const WatchEvent_Add: WatchEventType;
|
|
3
|
+
export declare const WatchEvent_Update: WatchEventType;
|
|
4
|
+
export declare const WatchEvent_RemoveDir: WatchEventType;
|
|
5
|
+
export declare const WatchEvent_RemoveFile: WatchEventType;
|
|
6
|
+
export declare const WatchEvent_Ready: WatchEventType;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WatchEvent_Ready = exports.WatchEvent_RemoveFile = exports.WatchEvent_RemoveDir = exports.WatchEvent_Update = exports.WatchEvent_Add = void 0;
|
|
4
|
+
exports.WatchEvent_Add = 'add';
|
|
5
|
+
exports.WatchEvent_Update = 'update';
|
|
6
|
+
exports.WatchEvent_RemoveDir = 'remove_dir';
|
|
7
|
+
exports.WatchEvent_RemoveFile = 'remove_file';
|
|
8
|
+
exports.WatchEvent_Ready = 'ready';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Unit_Typescript, Unit_Typescript_Config, Unit_Typescript_RuntimeConfig } from './Unit_Typescript';
|
|
2
|
-
import { UnitPhaseImplementor } from '../types';
|
|
2
|
+
import { UnitPhaseImplementor, WatchEventType } from '../types';
|
|
3
3
|
import { Phase_CheckCyclicImports, Phase_Compile, Phase_Lint, Phase_PreCompile, Phase_PrintDependencyTree, Phase_Purge } from '../../phase';
|
|
4
|
+
import { OnWatchEvent } from '../runner-dispatchers';
|
|
4
5
|
export type Unit_TypescriptLib_Config = Unit_Typescript_Config & {
|
|
5
6
|
customTSConfig?: boolean;
|
|
6
7
|
output: string;
|
|
@@ -18,14 +19,22 @@ export declare class Unit_TypescriptLib<C extends Unit_TypescriptLib_Config = Un
|
|
|
18
19
|
Phase_CheckCyclicImports,
|
|
19
20
|
Phase_Purge,
|
|
20
21
|
Phase_Lint
|
|
21
|
-
]
|
|
22
|
+
]>, OnWatchEvent {
|
|
22
23
|
constructor(config: Unit_TypescriptLib<C, RTC>['config']);
|
|
24
|
+
__onWatchEvent(type: WatchEventType, path?: string): Promise<void>;
|
|
23
25
|
protected init(setInitialized?: boolean): Promise<void>;
|
|
24
26
|
protected resolveTSConfig(): Promise<void>;
|
|
25
27
|
protected clearOutputDir(): Promise<void>;
|
|
26
28
|
protected compileImpl(): Promise<void>;
|
|
27
29
|
protected copyAssetsToOutput(): Promise<void>;
|
|
28
30
|
protected copyPackageJSONToOutput(): Promise<void>;
|
|
31
|
+
protected handleWatchChange(path: string, shouldRemoveDist?: boolean): Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* Remove the deleted file/folder from the dist folder on watch remove file event
|
|
34
|
+
* @param path The path of the currently removed file/folder
|
|
35
|
+
* @private
|
|
36
|
+
*/
|
|
37
|
+
private removeSpecificFileFromDist;
|
|
29
38
|
preCompile(): Promise<void>;
|
|
30
39
|
compile(): Promise<void>;
|
|
31
40
|
purge(): Promise<void>;
|
|
@@ -34,6 +34,8 @@ const RunnerParams_1 = require("../../phase-runner/RunnerParams");
|
|
|
34
34
|
const cli_1 = require("@nu-art/commando/core/cli");
|
|
35
35
|
const consts_1 = require("../../../core/consts");
|
|
36
36
|
const params_1 = require("../../../core/params/params");
|
|
37
|
+
const runner_dispatchers_1 = require("../runner-dispatchers");
|
|
38
|
+
const consts_2 = require("../consts");
|
|
37
39
|
const extensionsToLint = ['.ts', '.tsx'];
|
|
38
40
|
const assetExtensions = [
|
|
39
41
|
'json',
|
|
@@ -49,6 +51,12 @@ class Unit_TypescriptLib extends Unit_Typescript_1.Unit_Typescript {
|
|
|
49
51
|
constructor(config) {
|
|
50
52
|
super(config);
|
|
51
53
|
this.addToClassStack(Unit_TypescriptLib);
|
|
54
|
+
runner_dispatchers_1.dispatcher_WatchEvent.addListener(this);
|
|
55
|
+
}
|
|
56
|
+
async __onWatchEvent(type, path) {
|
|
57
|
+
if (type === consts_2.WatchEvent_Ready)
|
|
58
|
+
return this.setStatus('Watching');
|
|
59
|
+
await this.handleWatchChange(path, [consts_2.WatchEvent_RemoveFile, consts_2.WatchEvent_RemoveDir].includes(type));
|
|
52
60
|
}
|
|
53
61
|
async init(setInitialized = true) {
|
|
54
62
|
await super.init(false);
|
|
@@ -113,6 +121,43 @@ class Unit_TypescriptLib extends Unit_Typescript_1.Unit_Typescript {
|
|
|
113
121
|
const fileContent = JSON.stringify(this.packageJson.dist, null, 2);
|
|
114
122
|
await fs_1.promises.writeFile(targetPath, fileContent, { encoding: 'utf-8' });
|
|
115
123
|
}
|
|
124
|
+
async handleWatchChange(path, shouldRemoveDist = false) {
|
|
125
|
+
// ignore if path doesn't related to unit
|
|
126
|
+
if (!path.startsWith(this.config.pathToPackage))
|
|
127
|
+
return;
|
|
128
|
+
this.setStatus('Compile');
|
|
129
|
+
// check if dist folder must be cleared
|
|
130
|
+
if (shouldRemoveDist)
|
|
131
|
+
await this.removeSpecificFileFromDist(path);
|
|
132
|
+
// perform all watch actions
|
|
133
|
+
await this.compileImpl();
|
|
134
|
+
await this.copyAssetsToOutput();
|
|
135
|
+
this.setStatus('Watching');
|
|
136
|
+
// dispatch unit post compile
|
|
137
|
+
runner_dispatchers_1.dispatcher_UnitWatchCompile.dispatch(this);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Remove the deleted file/folder from the dist folder on watch remove file event
|
|
141
|
+
* @param path The path of the currently removed file/folder
|
|
142
|
+
* @private
|
|
143
|
+
*/
|
|
144
|
+
async removeSpecificFileFromDist(path) {
|
|
145
|
+
const distPathBase = path.replace('src/main', 'dist').replace(/\.ts$/, '');
|
|
146
|
+
const pathsToDelete = [
|
|
147
|
+
`${distPathBase}.js`,
|
|
148
|
+
`${distPathBase}.d.ts`,
|
|
149
|
+
`${distPathBase}.js.map`,
|
|
150
|
+
distPathBase // in case it's a directory
|
|
151
|
+
];
|
|
152
|
+
// try to remove all path options from dist
|
|
153
|
+
for (const path of pathsToDelete) {
|
|
154
|
+
if (!fs.existsSync(path)) {
|
|
155
|
+
this.logDebug(`no file in path ${path}`);
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
await fs_1.promises.rm(path, { recursive: true, force: true });
|
|
159
|
+
}
|
|
160
|
+
}
|
|
116
161
|
//######################### Phase Implementations #########################
|
|
117
162
|
async preCompile() {
|
|
118
163
|
if (!fs.existsSync(`${this.config.pathToPackage}/prebuild.sh`))
|
|
@@ -1,15 +1,29 @@
|
|
|
1
1
|
import { UnitPhaseImplementor } from '../types';
|
|
2
2
|
import { Unit_Typescript, Unit_Typescript_Config, Unit_Typescript_RuntimeConfig } from './Unit_Typescript';
|
|
3
|
-
import { Phase_Install } from '../../phase';
|
|
3
|
+
import { Phase_Install, Phase_Watch } from '../../phase';
|
|
4
4
|
import { StringMap } from '@nu-art/ts-common/utils/types';
|
|
5
5
|
type Unit_TypescriptProject_Config = Unit_Typescript_Config & {
|
|
6
6
|
globalPackages?: StringMap;
|
|
7
7
|
};
|
|
8
8
|
type Unit_TypescriptProject_RuntimeConfig = Unit_Typescript_RuntimeConfig & {};
|
|
9
|
-
export declare class Unit_TypescriptProject<C extends Unit_TypescriptProject_Config = Unit_TypescriptProject_Config, RTC extends Unit_TypescriptProject_RuntimeConfig = Unit_TypescriptProject_RuntimeConfig> extends Unit_Typescript<C, RTC> implements UnitPhaseImplementor<[Phase_Install]> {
|
|
9
|
+
export declare class Unit_TypescriptProject<C extends Unit_TypescriptProject_Config = Unit_TypescriptProject_Config, RTC extends Unit_TypescriptProject_RuntimeConfig = Unit_TypescriptProject_RuntimeConfig> extends Unit_Typescript<C, RTC> implements UnitPhaseImplementor<[Phase_Install, Phase_Watch]> {
|
|
10
|
+
private readonly suffixesToWatch;
|
|
10
11
|
constructor(config: Unit_TypescriptProject<C>['config']);
|
|
11
12
|
private installGlobals;
|
|
12
13
|
private installPackages;
|
|
14
|
+
/**
|
|
15
|
+
* Resolve all paths to watch in all project libs
|
|
16
|
+
* @private
|
|
17
|
+
* @returns string[]
|
|
18
|
+
*/
|
|
19
|
+
private prepareWatchPaths;
|
|
20
|
+
/**
|
|
21
|
+
* Init watch events and attach default watch callback with correct params to each of them
|
|
22
|
+
* @private
|
|
23
|
+
*/
|
|
24
|
+
private initWatch;
|
|
25
|
+
private watchImpl;
|
|
13
26
|
install(): Promise<void>;
|
|
27
|
+
watch(): Promise<void>;
|
|
14
28
|
}
|
|
15
29
|
export {};
|
|
@@ -1,4 +1,27 @@
|
|
|
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
26
|
exports.Unit_TypescriptProject = void 0;
|
|
4
27
|
const Unit_Typescript_1 = require("./Unit_Typescript");
|
|
@@ -7,9 +30,21 @@ const ts_common_1 = require("@nu-art/ts-common");
|
|
|
7
30
|
const nvm_1 = require("@nu-art/commando/cli/nvm");
|
|
8
31
|
const pnpm_1 = require("@nu-art/commando/cli/pnpm");
|
|
9
32
|
const consts_1 = require("../../phase-runner/consts");
|
|
33
|
+
const chokidar = __importStar(require("chokidar"));
|
|
34
|
+
const runner_dispatchers_1 = require("../runner-dispatchers");
|
|
35
|
+
const consts_2 = require("../consts");
|
|
36
|
+
const Unit_TypescriptLib_1 = require("./Unit_TypescriptLib");
|
|
37
|
+
const firebase_units_1 = require("../firebase-units");
|
|
10
38
|
class Unit_TypescriptProject extends Unit_Typescript_1.Unit_Typescript {
|
|
11
39
|
constructor(config) {
|
|
12
40
|
super(config);
|
|
41
|
+
this.suffixesToWatch = [
|
|
42
|
+
'ts',
|
|
43
|
+
'tsx',
|
|
44
|
+
'scss',
|
|
45
|
+
'json',
|
|
46
|
+
'svg'
|
|
47
|
+
];
|
|
13
48
|
this.addToClassStack(Unit_TypescriptProject);
|
|
14
49
|
}
|
|
15
50
|
//######################### Internal Logic #########################
|
|
@@ -33,10 +68,71 @@ class Unit_TypescriptProject extends Unit_Typescript_1.Unit_Typescript {
|
|
|
33
68
|
await pnpm_1.PNPM.createWorkspace(packages);
|
|
34
69
|
await pnpm_1.PNPM.installPackages(nvm_1.NVM.createCommando());
|
|
35
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* Resolve all paths to watch in all project libs
|
|
73
|
+
* @private
|
|
74
|
+
* @returns string[]
|
|
75
|
+
*/
|
|
76
|
+
prepareWatchPaths() {
|
|
77
|
+
// Using phase runner instance to resolve all project libs to watch
|
|
78
|
+
const cantBeInstanceOf = [firebase_units_1.Unit_FirebaseHostingApp, firebase_units_1.Unit_FirebaseFunctionsApp];
|
|
79
|
+
const projectLibs = consts_1.MemKey_PhaseRunner.get()
|
|
80
|
+
.getUnits().filter(unit => unit.isInstanceOf(Unit_TypescriptLib_1.Unit_TypescriptLib) && cantBeInstanceOf.every(_instance => !unit.isInstanceOf(_instance)));
|
|
81
|
+
//return all paths to watch
|
|
82
|
+
return projectLibs.map(lib => {
|
|
83
|
+
const sourceFolder = `${lib.config.pathToPackage}/src/main`;
|
|
84
|
+
return { paths: this.suffixesToWatch.map(suffix => `${sourceFolder}/**/*.${suffix}`), unit: lib };
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Init watch events and attach default watch callback with correct params to each of them
|
|
89
|
+
* @private
|
|
90
|
+
*/
|
|
91
|
+
initWatch() {
|
|
92
|
+
const pathDeclarations = this.prepareWatchPaths();
|
|
93
|
+
const paths = pathDeclarations.flatMap(path => path.paths);
|
|
94
|
+
const watcher = chokidar.watch(paths);
|
|
95
|
+
// set all events to watch and handle them
|
|
96
|
+
return new Promise((resolve, error) => {
|
|
97
|
+
this.logInfo('Starting the watcher...');
|
|
98
|
+
watcher
|
|
99
|
+
.on('error', (error) => {
|
|
100
|
+
this.logError('Error while watching', error);
|
|
101
|
+
})
|
|
102
|
+
.on('ready', () => {
|
|
103
|
+
this.logInfo('Watching...');
|
|
104
|
+
runner_dispatchers_1.dispatcher_WatchEvent.dispatch(consts_2.WatchEvent_Ready);
|
|
105
|
+
watcher
|
|
106
|
+
.on('add', (path) => {
|
|
107
|
+
runner_dispatchers_1.dispatcher_WatchEvent.dispatch(consts_2.WatchEvent_Add, path);
|
|
108
|
+
})
|
|
109
|
+
.on('change', (path) => {
|
|
110
|
+
runner_dispatchers_1.dispatcher_WatchEvent.dispatch(consts_2.WatchEvent_Update, path);
|
|
111
|
+
})
|
|
112
|
+
.on('unlinkDir', (path) => {
|
|
113
|
+
runner_dispatchers_1.dispatcher_WatchEvent.dispatch(consts_2.WatchEvent_RemoveDir, path);
|
|
114
|
+
})
|
|
115
|
+
.on('unlink', (path) => {
|
|
116
|
+
runner_dispatchers_1.dispatcher_WatchEvent.dispatch(consts_2.WatchEvent_RemoveFile, path);
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
process.on('SIGINT', async (status) => {
|
|
120
|
+
await watcher.close();
|
|
121
|
+
process.exit(0);
|
|
122
|
+
resolve();
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
async watchImpl() {
|
|
127
|
+
await this.initWatch();
|
|
128
|
+
}
|
|
36
129
|
//######################### Phase Implementation #########################
|
|
37
130
|
async install() {
|
|
38
131
|
await this.installGlobals();
|
|
39
132
|
await this.installPackages();
|
|
40
133
|
}
|
|
134
|
+
async watch() {
|
|
135
|
+
await this.watchImpl();
|
|
136
|
+
}
|
|
41
137
|
}
|
|
42
138
|
exports.Unit_TypescriptProject = Unit_TypescriptProject;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { Unit_TypescriptLib, Unit_TypescriptLib_Config } from '../core';
|
|
1
|
+
import { BaseUnit, Unit_TypescriptLib, Unit_TypescriptLib_Config } from '../core';
|
|
2
2
|
import { UnitPhaseImplementor } from '../types';
|
|
3
3
|
import { Phase_DeployBackend, Phase_Launch, Phase_ResolveConfigs } from '../../phase';
|
|
4
4
|
import { FirebasePackageConfig } from '../../../core/types';
|
|
5
|
+
import { OnUnitWatchCompiled } from '../runner-dispatchers';
|
|
5
6
|
export type Unit_FirebaseFunctionsApp_Config = Unit_TypescriptLib_Config & {
|
|
6
7
|
firebaseConfig: FirebasePackageConfig;
|
|
7
8
|
sources?: string[];
|
|
8
9
|
};
|
|
9
|
-
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]
|
|
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 {
|
|
10
11
|
static staggerCount: number;
|
|
11
12
|
private readonly PROXY_PID_LOG;
|
|
12
13
|
private readonly PROXY_KILL_LOG;
|
|
@@ -14,6 +15,7 @@ export declare class Unit_FirebaseFunctionsApp<C extends Unit_FirebaseFunctionsA
|
|
|
14
15
|
private readonly EMULATOR_KILL_LOG;
|
|
15
16
|
private launchCommandos;
|
|
16
17
|
private listeners;
|
|
18
|
+
__onUnitWatchCompiled(unit: BaseUnit): Promise<void>;
|
|
17
19
|
constructor(config: Unit_FirebaseFunctionsApp<C>['config']);
|
|
18
20
|
resolveConfigs(): Promise<void>;
|
|
19
21
|
compile(): Promise<void>;
|
|
@@ -12,8 +12,18 @@ const cli_1 = require("@nu-art/commando/core/cli");
|
|
|
12
12
|
const basic_1 = require("@nu-art/commando/cli/basic");
|
|
13
13
|
const nvm_1 = require("@nu-art/commando/cli/nvm");
|
|
14
14
|
const consts_3 = require("../../phase-runner/consts");
|
|
15
|
+
const runner_dispatchers_1 = require("../runner-dispatchers");
|
|
15
16
|
const CONST_VersionApp = 'version-app.json';
|
|
16
17
|
class Unit_FirebaseFunctionsApp extends core_1.Unit_TypescriptLib {
|
|
18
|
+
async __onUnitWatchCompiled(unit) {
|
|
19
|
+
if (this.runtime.unitDependencyNames.includes(unit.runtime.dependencyName)) {
|
|
20
|
+
this.setStatus('Compile');
|
|
21
|
+
await this.compileImpl();
|
|
22
|
+
await this.copyAssetsToOutput();
|
|
23
|
+
await this.createDependenciesDir();
|
|
24
|
+
this.setStatus('Compiled');
|
|
25
|
+
}
|
|
26
|
+
}
|
|
17
27
|
constructor(config) {
|
|
18
28
|
super(config);
|
|
19
29
|
this.PROXY_PID_LOG = '_PROXY_PID_';
|
|
@@ -21,6 +31,8 @@ class Unit_FirebaseFunctionsApp extends core_1.Unit_TypescriptLib {
|
|
|
21
31
|
this.EMULATOR_PID_LOG = '_EMULATOR_PID_';
|
|
22
32
|
this.EMULATOR_KILL_LOG = '_EMULATOR_KILLED_';
|
|
23
33
|
this.addToClassStack(Unit_FirebaseFunctionsApp);
|
|
34
|
+
runner_dispatchers_1.dispatcher_WatchEvent.removeListener(this);
|
|
35
|
+
runner_dispatchers_1.dispatcher_UnitWatchCompile.addListener(this);
|
|
24
36
|
}
|
|
25
37
|
//######################### Phase Implementations #########################
|
|
26
38
|
async resolveConfigs() {
|
|
@@ -11,6 +11,7 @@ const nvm_1 = require("@nu-art/commando/cli/nvm");
|
|
|
11
11
|
const basic_1 = require("@nu-art/commando/cli/basic");
|
|
12
12
|
const RunnerParams_1 = require("../../phase-runner/RunnerParams");
|
|
13
13
|
const cli_1 = require("@nu-art/commando/core/cli");
|
|
14
|
+
const runner_dispatchers_1 = require("../runner-dispatchers");
|
|
14
15
|
const CONST_VersionApp = 'version-app.json';
|
|
15
16
|
class Unit_FirebaseHostingApp extends core_1.Unit_TypescriptLib {
|
|
16
17
|
constructor(config) {
|
|
@@ -18,6 +19,7 @@ class Unit_FirebaseHostingApp extends core_1.Unit_TypescriptLib {
|
|
|
18
19
|
this.APP_PID_LOG = '_APP_PID_';
|
|
19
20
|
this.APP_KILL_LOG = '_APP_KILLED_';
|
|
20
21
|
this.addToClassStack(Unit_FirebaseHostingApp);
|
|
22
|
+
runner_dispatchers_1.dispatcher_WatchEvent.removeListener(this);
|
|
21
23
|
}
|
|
22
24
|
//######################### Phase Implementations #########################
|
|
23
25
|
async resolveConfigs() {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { PhaseRunnerDispatcher } from '../phase-runner/PhaseRunnerDispatcher';
|
|
2
|
+
import { WatchEventType } from './types';
|
|
3
|
+
import { BaseUnit } from './core';
|
|
4
|
+
export interface OnWatchEvent {
|
|
5
|
+
__onWatchEvent: (type: WatchEventType, path?: string) => void;
|
|
6
|
+
}
|
|
7
|
+
export declare const dispatcher_WatchEvent: PhaseRunnerDispatcher<OnWatchEvent, "__onWatchEvent", [type: WatchEventType, path?: string | undefined]>;
|
|
8
|
+
export interface OnUnitWatchCompiled {
|
|
9
|
+
__onUnitWatchCompiled: (init: BaseUnit) => void;
|
|
10
|
+
}
|
|
11
|
+
export declare const dispatcher_UnitWatchCompile: PhaseRunnerDispatcher<OnUnitWatchCompiled, "__onUnitWatchCompiled", [init: BaseUnit<import("./core").BaseUnit_Config, import("./core").BaseUnit_RuntimeConfig>]>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.dispatcher_UnitWatchCompile = exports.dispatcher_WatchEvent = void 0;
|
|
4
|
+
const PhaseRunnerDispatcher_1 = require("../phase-runner/PhaseRunnerDispatcher");
|
|
5
|
+
exports.dispatcher_WatchEvent = new PhaseRunnerDispatcher_1.PhaseRunnerDispatcher('__onWatchEvent');
|
|
6
|
+
exports.dispatcher_UnitWatchCompile = new PhaseRunnerDispatcher_1.PhaseRunnerDispatcher('__onUnitWatchCompiled');
|
package/v2/unit/types.d.ts
CHANGED
|
@@ -5,3 +5,4 @@ export type Unit<P extends Phase<string>[]> = BaseUnit & UnitPhaseImplementor<P>
|
|
|
5
5
|
export type UnitPhaseImplementor<P extends Phase<string>[]> = {
|
|
6
6
|
[K in P[number]['method']]: AsyncVoidFunction;
|
|
7
7
|
};
|
|
8
|
+
export type WatchEventType = 'update' | 'add' | 'remove_file' | 'remove_dir' | 'ready';
|