@nu-art/build-and-install 0.204.80 → 0.204.82

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.
@@ -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
@@ -29,7 +29,7 @@ export type FirebaseEnvConfig<Env extends string> = {
29
29
  storageBucket: string;
30
30
  messagingSenderId: string;
31
31
  appId: string;
32
- measurementId: string;
32
+ measurementId?: string;
33
33
  };
34
34
  };
35
35
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nu-art/build-and-install",
3
- "version": "0.204.80",
3
+ "version": "0.204.82",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "TacB0sS",
@@ -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:');
@@ -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
  }
@@ -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
- //######################### Log Client Interaction #########################
20
- this.startLogClient = () => {
21
- //Remove terminal from BeLogged
22
- ts_common_1.BeLogged.removeConsole(ts_common_1.LogClient_Terminal);
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.stopLogClient = () => {
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.gridCellWidgets.forEach(widget => widget.destroy());
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
- //Start listening on dispatchers
117
- PhaseRunnerDispatcher_1.dispatcher_UnitStatusChange.addListener(this);
118
- PhaseRunnerDispatcher_1.dispatcher_PhaseChange.addListener(this);
119
- PhaseRunnerDispatcher_1.dispatcher_UnitChange.addListener(this);
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 = {