@nu-art/build-and-install 0.204.18 → 0.204.20
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/logic/ProjectManager.d.ts +1 -0
- package/logic/ProjectManager.js +6 -4
- package/package.json +1 -1
- package/phases/phases.js +26 -1
- package/screen/ProjectScreen.d.ts +1 -0
- package/screen/ProjectScreen.js +32 -6
- package/screen/RunningProcessLogs.d.ts +0 -5
- package/screen/RunningProcessLogs.js +65 -24
package/logic/ProjectManager.js
CHANGED
|
@@ -67,16 +67,18 @@ class ProjectManager extends ts_common_1.Logger {
|
|
|
67
67
|
this.setMinLevel(ts_common_1.LogLevel.Verbose);
|
|
68
68
|
this.logInfo('Runtime params:', params_1.RuntimeParams);
|
|
69
69
|
}
|
|
70
|
-
|
|
71
|
-
var _a;
|
|
70
|
+
clearLogger() {
|
|
72
71
|
if (this.logger)
|
|
73
72
|
ts_common_1.BeLogged.removeConsole(this.logger);
|
|
73
|
+
}
|
|
74
|
+
showAllLogs() {
|
|
75
|
+
var _a;
|
|
76
|
+
this.clearLogger();
|
|
74
77
|
(_a = this.projectScreen) === null || _a === void 0 ? void 0 : _a.disable();
|
|
75
78
|
ts_common_1.BeLogged.addClient(this.logger = ts_common_1.LogClient_Terminal);
|
|
76
79
|
}
|
|
77
80
|
showPrettyLogs() {
|
|
78
|
-
|
|
79
|
-
ts_common_1.BeLogged.removeConsole(this.logger);
|
|
81
|
+
this.clearLogger();
|
|
80
82
|
this.projectScreen.enable();
|
|
81
83
|
ts_common_1.BeLogged.addClient(this.logger = this.projectScreen.logClient);
|
|
82
84
|
}
|
package/package.json
CHANGED
package/phases/phases.js
CHANGED
|
@@ -42,6 +42,7 @@ const consts_2 = require("../defaults/consts");
|
|
|
42
42
|
const project_manager_1 = require("../project-manager");
|
|
43
43
|
const ProjectScreen_1 = require("../screen/ProjectScreen");
|
|
44
44
|
const cli_1 = require("@nu-art/commando/core/cli");
|
|
45
|
+
const RunningProcessLogs_1 = require("../screen/RunningProcessLogs");
|
|
45
46
|
const CONST_ThunderstormVersionKey = 'THUNDERSTORM_SDK_VERSION';
|
|
46
47
|
const CONST_ThunderstormDependencyKey = 'THUNDERSTORM_DEPENDENCY_VERSION';
|
|
47
48
|
const CONST_ProjectVersionKey = 'APP_VERSION';
|
|
@@ -585,6 +586,7 @@ exports.Phase_CompileWatch = {
|
|
|
585
586
|
});
|
|
586
587
|
}
|
|
587
588
|
};
|
|
589
|
+
let runningAppsLogs;
|
|
588
590
|
let counter = 0;
|
|
589
591
|
exports.Phase_Launch = {
|
|
590
592
|
type: 'package',
|
|
@@ -593,28 +595,51 @@ exports.Phase_Launch = {
|
|
|
593
595
|
mandatoryPhases: [exports.Phase_ResolveEnv],
|
|
594
596
|
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'); },
|
|
595
597
|
action: async (pkg) => {
|
|
598
|
+
const projectManager = project_manager_1.MemKey_ProjectManager.get();
|
|
596
599
|
const projectScreen = ProjectScreen_1.MemKey_ProjectScreen.get();
|
|
600
|
+
if (!runningAppsLogs) {
|
|
601
|
+
projectScreen.disable();
|
|
602
|
+
projectManager.clearLogger();
|
|
603
|
+
runningAppsLogs = new RunningProcessLogs_1.RunningProcessLogs();
|
|
604
|
+
runningAppsLogs.enable();
|
|
605
|
+
}
|
|
606
|
+
const logClient = new ts_common_1.LogClient_MemBuffer(pkg.name);
|
|
607
|
+
logClient.setForTerminal();
|
|
608
|
+
logClient.setComposer((tag, level) => {
|
|
609
|
+
ts_common_1._logger_finalDate.setTime(Date.now() - ts_common_1._logger_timezoneOffset);
|
|
610
|
+
const date = ts_common_1._logger_finalDate.toISOString().replace(/T/, '_').replace(/Z/, '').substring(0, 23).split('_')[1];
|
|
611
|
+
return `${date} ${(0, ts_common_1._logger_getPrefix)(level)}: `;
|
|
612
|
+
});
|
|
613
|
+
logClient.setFilter((level, tag) => {
|
|
614
|
+
return tag === pkg.name;
|
|
615
|
+
});
|
|
616
|
+
ts_common_1.BeLogged.addClient(logClient);
|
|
597
617
|
projectScreen.updateOrCreatePackage(pkg.name, 'Launching...');
|
|
598
618
|
if (pkg.type === 'firebase-functions-app') {
|
|
599
619
|
await (0, ts_common_1.sleep)(1000 * counter++);
|
|
600
620
|
const allPorts = Array.from({ length: 10 }, (_, i) => `${pkg.envConfig.basePort + i}`);
|
|
601
621
|
const command = nvm_1.NVM.createInteractiveCommando(basic_1.Cli_Basic)
|
|
622
|
+
.setUID(pkg.name)
|
|
602
623
|
.cd(pkg.path)
|
|
603
624
|
.append(`nvm use`)
|
|
604
625
|
.append(`array=($(lsof -ti:${allPorts.join(',')}))`)
|
|
605
626
|
.append(`((\${#array[@]} > 0)) && kill -9 "\${array[@]}"`);
|
|
606
627
|
command.append(`firebase emulators:start --export-on-exit --import=.trash/data ${runInDebug ? `--inspect-functions ${pkg.envConfig.ssl}` : ''}`);
|
|
628
|
+
runningAppsLogs.registerApp(pkg.name, logClient);
|
|
607
629
|
return command
|
|
608
630
|
.execute();
|
|
609
631
|
}
|
|
610
|
-
if (pkg.type === 'firebase-hosting-app')
|
|
632
|
+
if (pkg.type === 'firebase-hosting-app') {
|
|
633
|
+
runningAppsLogs.registerApp(pkg.name, logClient);
|
|
611
634
|
return nvm_1.NVM.createInteractiveCommando(basic_1.Cli_Basic)
|
|
635
|
+
.setUID(pkg.name)
|
|
612
636
|
.cd(pkg.path)
|
|
613
637
|
.append(`array=($(lsof -ti:${[pkg.envConfig.basePort - 1].join(',')}))`)
|
|
614
638
|
.append(`((\${#array[@]} > 0)) && kill -9 "\${array[@]}"`)
|
|
615
639
|
.append(`nvm use`)
|
|
616
640
|
.append(`npm run start`)
|
|
617
641
|
.execute();
|
|
642
|
+
}
|
|
618
643
|
projectScreen.updateOrCreatePackage(pkg.name, 'Died');
|
|
619
644
|
}
|
|
620
645
|
};
|
package/screen/ProjectScreen.js
CHANGED
|
@@ -1,8 +1,31 @@
|
|
|
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.MemKey_ProjectScreen = exports.ProjectScreen = void 0;
|
|
4
27
|
// @ts-ignore
|
|
5
|
-
const
|
|
28
|
+
const blessed = __importStar(require("neo-blessed"));
|
|
6
29
|
const MemStorage_1 = require("@nu-art/ts-common/mem-storage/MemStorage");
|
|
7
30
|
const ts_common_1 = require("@nu-art/ts-common");
|
|
8
31
|
class ProjectScreen {
|
|
@@ -64,7 +87,7 @@ class ProjectScreen {
|
|
|
64
87
|
}
|
|
65
88
|
enable() {
|
|
66
89
|
this.enabled = true;
|
|
67
|
-
this.screen =
|
|
90
|
+
this.screen = blessed.screen({
|
|
68
91
|
smartCSR: true,
|
|
69
92
|
title: 'Build and install',
|
|
70
93
|
});
|
|
@@ -72,7 +95,7 @@ class ProjectScreen {
|
|
|
72
95
|
return process.exit(1); // Quit on q, esc, or ctrl-c
|
|
73
96
|
});
|
|
74
97
|
// Create the UI components
|
|
75
|
-
this.phaseBox =
|
|
98
|
+
this.phaseBox = blessed.text({
|
|
76
99
|
parent: this.screen,
|
|
77
100
|
top: 0,
|
|
78
101
|
left: 0,
|
|
@@ -87,7 +110,7 @@ class ProjectScreen {
|
|
|
87
110
|
},
|
|
88
111
|
align: 'center'
|
|
89
112
|
});
|
|
90
|
-
this.packageTable =
|
|
113
|
+
this.packageTable = blessed.listtable({
|
|
91
114
|
parent: this.screen,
|
|
92
115
|
top: 3,
|
|
93
116
|
left: 0,
|
|
@@ -111,7 +134,7 @@ class ProjectScreen {
|
|
|
111
134
|
},
|
|
112
135
|
}
|
|
113
136
|
});
|
|
114
|
-
this.titleElement =
|
|
137
|
+
this.titleElement = blessed.text({
|
|
115
138
|
parent: this.screen,
|
|
116
139
|
top: 0,
|
|
117
140
|
right: 0,
|
|
@@ -126,7 +149,7 @@ class ProjectScreen {
|
|
|
126
149
|
},
|
|
127
150
|
align: 'center'
|
|
128
151
|
});
|
|
129
|
-
this.logger =
|
|
152
|
+
this.logger = blessed.log({
|
|
130
153
|
parent: this.screen,
|
|
131
154
|
top: 3,
|
|
132
155
|
right: 0,
|
|
@@ -144,6 +167,9 @@ class ProjectScreen {
|
|
|
144
167
|
align: 'left'
|
|
145
168
|
});
|
|
146
169
|
}
|
|
170
|
+
isEnabled() {
|
|
171
|
+
return this.enabled;
|
|
172
|
+
}
|
|
147
173
|
disable() {
|
|
148
174
|
this.enabled = false;
|
|
149
175
|
if (!this.screen)
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import { LogClient_MemBuffer } from '@nu-art/ts-common';
|
|
2
2
|
import { ConsoleScreen } from '@nu-art/commando/console/ConsoleScreen';
|
|
3
|
-
export type PackageStatus = {
|
|
4
|
-
packageName: string;
|
|
5
|
-
status: string;
|
|
6
|
-
error?: string;
|
|
7
|
-
};
|
|
8
3
|
export declare class RunningProcessLogs extends ConsoleScreen<{
|
|
9
4
|
logs: {
|
|
10
5
|
key: string;
|
|
@@ -5,7 +5,17 @@ const ts_common_1 = require("@nu-art/ts-common");
|
|
|
5
5
|
const ConsoleScreen_1 = require("@nu-art/commando/console/ConsoleScreen");
|
|
6
6
|
class RunningProcessLogs extends ConsoleScreen_1.ConsoleScreen {
|
|
7
7
|
constructor() {
|
|
8
|
-
super(
|
|
8
|
+
super({
|
|
9
|
+
smartCSR: true,
|
|
10
|
+
title: 'Runtime-Logs',
|
|
11
|
+
keyBinding: [
|
|
12
|
+
{
|
|
13
|
+
keys: ['C-c'],
|
|
14
|
+
callback: () => process.exit(0)
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
});
|
|
18
|
+
this.state = { logs: [] };
|
|
9
19
|
}
|
|
10
20
|
registerApp(appKey, logClient) {
|
|
11
21
|
const logs = this.state.logs;
|
|
@@ -14,6 +24,10 @@ class RunningProcessLogs extends ConsoleScreen_1.ConsoleScreen {
|
|
|
14
24
|
throw new ts_common_1.BadImplementationException(`already have log for appkey: ${appKey}`);
|
|
15
25
|
logs.push({ key: appKey, logClient });
|
|
16
26
|
this.recalculateWidgets(logs);
|
|
27
|
+
logClient.setLogAppendedListener(() => {
|
|
28
|
+
this.render();
|
|
29
|
+
// might have a leak.. need to remove the listener at some point
|
|
30
|
+
});
|
|
17
31
|
this.setState({ logs });
|
|
18
32
|
}
|
|
19
33
|
unregisterApp(appKey) {
|
|
@@ -26,31 +40,42 @@ class RunningProcessLogs extends ConsoleScreen_1.ConsoleScreen {
|
|
|
26
40
|
this.setState({ logs });
|
|
27
41
|
}
|
|
28
42
|
recalculateWidgets(logs) {
|
|
29
|
-
this.clearScreen(
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
this.clearScreen(false);
|
|
44
|
+
const fittingGrid = gridPreset[logs.length - 1];
|
|
45
|
+
if (!(0, ts_common_1.exists)(fittingGrid))
|
|
46
|
+
return;
|
|
47
|
+
if (!fittingGrid)
|
|
48
|
+
throw new Error(`No preset available for this number of cells ${logs.length}`);
|
|
49
|
+
let index = 0;
|
|
50
|
+
let xPos = 0;
|
|
51
|
+
fittingGrid.forEach(column => {
|
|
52
|
+
let yPos = 0;
|
|
53
|
+
column.forEach(cell => {
|
|
54
|
+
const [fracWidth, fracHeight] = cell;
|
|
55
|
+
const width = 100 * fracWidth;
|
|
56
|
+
const height = 100 * fracHeight;
|
|
57
|
+
this.createWidget('log', {
|
|
58
|
+
top: `${yPos}%`,
|
|
59
|
+
left: `${xPos}%`,
|
|
60
|
+
width: `${width}%`,
|
|
61
|
+
height: `${height}%`,
|
|
62
|
+
label: ` Log for ${logs[index++].key} `,
|
|
63
|
+
border: { type: 'line' },
|
|
64
|
+
scrollable: true,
|
|
65
|
+
scrollbar: {
|
|
66
|
+
ch: ' ',
|
|
67
|
+
track: {
|
|
68
|
+
bg: 'grey'
|
|
69
|
+
},
|
|
70
|
+
style: {
|
|
71
|
+
inverse: true
|
|
72
|
+
}
|
|
47
73
|
},
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
},
|
|
52
|
-
mouse: true
|
|
74
|
+
mouse: true
|
|
75
|
+
});
|
|
76
|
+
yPos += height; // Assumes all cells in a column have the same height
|
|
53
77
|
});
|
|
78
|
+
xPos += column[0][0] * 100;
|
|
54
79
|
});
|
|
55
80
|
}
|
|
56
81
|
render() {
|
|
@@ -60,3 +85,19 @@ class RunningProcessLogs extends ConsoleScreen_1.ConsoleScreen {
|
|
|
60
85
|
}
|
|
61
86
|
}
|
|
62
87
|
exports.RunningProcessLogs = RunningProcessLogs;
|
|
88
|
+
const columnOf1_halfWidth = [[0.5, 1]];
|
|
89
|
+
const columnOf2_halfWidth = [[0.5, 0.5], [0.5, 0.5]];
|
|
90
|
+
const columnOf3_halfWidth = [[0.5, 1 / 3], [0.5, 1 / 3], [0.5, 1 / 3]];
|
|
91
|
+
const columnOf2_3rdWidth = [[1 / 3, 0.5], [1 / 3, 0.5]];
|
|
92
|
+
const columnOf3_3rdWidth = [[1 / 3, 1 / 3], [1 / 3, 1 / 3], [1 / 3, 1 / 3]];
|
|
93
|
+
const gridPreset = [
|
|
94
|
+
[[[1, 1]]],
|
|
95
|
+
[columnOf1_halfWidth, columnOf1_halfWidth],
|
|
96
|
+
[columnOf2_halfWidth, columnOf1_halfWidth],
|
|
97
|
+
[columnOf2_halfWidth, columnOf2_halfWidth],
|
|
98
|
+
[columnOf3_halfWidth, columnOf2_halfWidth],
|
|
99
|
+
[columnOf3_halfWidth, columnOf3_halfWidth],
|
|
100
|
+
[columnOf3_3rdWidth, columnOf2_3rdWidth, columnOf2_3rdWidth],
|
|
101
|
+
[columnOf3_3rdWidth, columnOf3_3rdWidth, columnOf2_3rdWidth],
|
|
102
|
+
[columnOf3_3rdWidth, columnOf3_3rdWidth, columnOf3_3rdWidth],
|
|
103
|
+
];
|