@nu-art/build-and-install 0.204.19 → 0.204.21
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/defaults/.firebase_config/database.rules.json +7 -0
- package/defaults/.firebase_config/firestore.indexes.json +4 -0
- package/defaults/.firebase_config/firestore.rules +8 -0
- package/defaults/.firebase_config/storage.rules +8 -0
- package/defaults/backend-proxy/proxy._ts +64 -0
- package/logic/ProjectManager.d.ts +1 -0
- package/logic/ProjectManager.js +6 -4
- package/package.json +1 -1
- package/phases/phases.js +14 -7
- package/screen/RunningProcessLogs.js +49 -22
- package/tsconfig.json +23 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import express from 'express';
|
|
2
|
+
import request from 'request';
|
|
3
|
+
import * as fs from 'fs';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
const _express: express.Express = express();
|
|
7
|
+
let _counter = 0;
|
|
8
|
+
_express.all('*', (req, res) => {
|
|
9
|
+
const counter = ++_counter;
|
|
10
|
+
const qMark = req.originalUrl.indexOf('?');
|
|
11
|
+
const query = qMark > 1 ? req.originalUrl.substring(qMark) : '';
|
|
12
|
+
const path = req.path;
|
|
13
|
+
let url = `http://127.0.0.1:SERVER_PORT/shopify-manager-tool-dev/us-central1/api${path}${query}`;
|
|
14
|
+
if (path.startsWith('/emulatorDownload') || path.startsWith('/emulatorUpload'))
|
|
15
|
+
url = `http://127.0.0.1:SERVER_PORT/shopify-manager-tool-dev/us-central1${path}${query}`;
|
|
16
|
+
|
|
17
|
+
console.log(`PROXY ${counter} - [${req.method}] ${url}`);
|
|
18
|
+
|
|
19
|
+
try {
|
|
20
|
+
let reqContent;
|
|
21
|
+
if (req.method === 'POST') {
|
|
22
|
+
reqContent = request.post({uri: url, body: req.body});
|
|
23
|
+
} else if (req.method === 'PUT') {
|
|
24
|
+
reqContent = request.put({uri: url, body: req.body});
|
|
25
|
+
} else if (req.method === 'GET') {
|
|
26
|
+
reqContent = request.get(url);
|
|
27
|
+
} else if (req.method === 'DELETE') {
|
|
28
|
+
reqContent = request.delete(url);
|
|
29
|
+
} else if (req.method === 'HEAD') {
|
|
30
|
+
reqContent = request.head(url);
|
|
31
|
+
} else {
|
|
32
|
+
reqContent = request(url);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
req.pipe(reqContent).pipe(res, {end: true});
|
|
36
|
+
console.log(`PROXY ${counter} - END`);
|
|
37
|
+
} catch (e) {
|
|
38
|
+
console.log(`ERROR calling: ${url}`, e);
|
|
39
|
+
res.end(500);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const ssl = {
|
|
44
|
+
key: 'PATH_TO_SSL_KEY',
|
|
45
|
+
cert: 'PATH_TO_SSL_CERTIFICATE'
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
let key = ssl.key;
|
|
49
|
+
if (!ssl.key.startsWith('-----BEGIN'))
|
|
50
|
+
key = fs.readFileSync(ssl.key, 'utf8');
|
|
51
|
+
|
|
52
|
+
let cert = ssl.cert;
|
|
53
|
+
if (!ssl.cert.startsWith('-----BEGIN'))
|
|
54
|
+
cert = fs.readFileSync(ssl.cert, 'utf8');
|
|
55
|
+
|
|
56
|
+
const options = {
|
|
57
|
+
key: key,
|
|
58
|
+
cert: cert,
|
|
59
|
+
rejectUnauthorized: false,
|
|
60
|
+
requestCert: false,
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
require('https').createServer(options, _express).listen(8008);
|
|
64
|
+
console.log('SSL proxy started!!!');
|
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,7 +586,7 @@ exports.Phase_CompileWatch = {
|
|
|
585
586
|
});
|
|
586
587
|
}
|
|
587
588
|
};
|
|
588
|
-
|
|
589
|
+
let runningAppsLogs;
|
|
589
590
|
let counter = 0;
|
|
590
591
|
exports.Phase_Launch = {
|
|
591
592
|
type: 'package',
|
|
@@ -594,11 +595,14 @@ exports.Phase_Launch = {
|
|
|
594
595
|
mandatoryPhases: [exports.Phase_ResolveEnv],
|
|
595
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'); },
|
|
596
597
|
action: async (pkg) => {
|
|
598
|
+
const projectManager = project_manager_1.MemKey_ProjectManager.get();
|
|
597
599
|
const projectScreen = ProjectScreen_1.MemKey_ProjectScreen.get();
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
600
|
+
if (!runningAppsLogs) {
|
|
601
|
+
projectScreen.disable();
|
|
602
|
+
projectManager.clearLogger();
|
|
603
|
+
runningAppsLogs = new RunningProcessLogs_1.RunningProcessLogs();
|
|
604
|
+
runningAppsLogs.enable();
|
|
605
|
+
}
|
|
602
606
|
const logClient = new ts_common_1.LogClient_MemBuffer(pkg.name);
|
|
603
607
|
logClient.setForTerminal();
|
|
604
608
|
logClient.setComposer((tag, level) => {
|
|
@@ -609,6 +613,7 @@ exports.Phase_Launch = {
|
|
|
609
613
|
logClient.setFilter((level, tag) => {
|
|
610
614
|
return tag === pkg.name;
|
|
611
615
|
});
|
|
616
|
+
ts_common_1.BeLogged.addClient(logClient);
|
|
612
617
|
projectScreen.updateOrCreatePackage(pkg.name, 'Launching...');
|
|
613
618
|
if (pkg.type === 'firebase-functions-app') {
|
|
614
619
|
await (0, ts_common_1.sleep)(1000 * counter++);
|
|
@@ -620,11 +625,12 @@ exports.Phase_Launch = {
|
|
|
620
625
|
.append(`array=($(lsof -ti:${allPorts.join(',')}))`)
|
|
621
626
|
.append(`((\${#array[@]} > 0)) && kill -9 "\${array[@]}"`);
|
|
622
627
|
command.append(`firebase emulators:start --export-on-exit --import=.trash/data ${runInDebug ? `--inspect-functions ${pkg.envConfig.ssl}` : ''}`);
|
|
623
|
-
|
|
628
|
+
runningAppsLogs.registerApp(pkg.name, logClient);
|
|
624
629
|
return command
|
|
625
630
|
.execute();
|
|
626
631
|
}
|
|
627
|
-
if (pkg.type === 'firebase-hosting-app')
|
|
632
|
+
if (pkg.type === 'firebase-hosting-app') {
|
|
633
|
+
runningAppsLogs.registerApp(pkg.name, logClient);
|
|
628
634
|
return nvm_1.NVM.createInteractiveCommando(basic_1.Cli_Basic)
|
|
629
635
|
.setUID(pkg.name)
|
|
630
636
|
.cd(pkg.path)
|
|
@@ -633,6 +639,7 @@ exports.Phase_Launch = {
|
|
|
633
639
|
.append(`nvm use`)
|
|
634
640
|
.append(`npm run start`)
|
|
635
641
|
.execute();
|
|
642
|
+
}
|
|
636
643
|
projectScreen.updateOrCreatePackage(pkg.name, 'Died');
|
|
637
644
|
}
|
|
638
645
|
};
|
|
@@ -41,30 +41,41 @@ class RunningProcessLogs extends ConsoleScreen_1.ConsoleScreen {
|
|
|
41
41
|
}
|
|
42
42
|
recalculateWidgets(logs) {
|
|
43
43
|
this.clearScreen(false);
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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
|
+
}
|
|
61
73
|
},
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
},
|
|
66
|
-
mouse: true
|
|
74
|
+
mouse: true
|
|
75
|
+
});
|
|
76
|
+
yPos += height; // Assumes all cells in a column have the same height
|
|
67
77
|
});
|
|
78
|
+
xPos += column[0][0] * 100;
|
|
68
79
|
});
|
|
69
80
|
}
|
|
70
81
|
render() {
|
|
@@ -74,3 +85,19 @@ class RunningProcessLogs extends ConsoleScreen_1.ConsoleScreen {
|
|
|
74
85
|
}
|
|
75
86
|
}
|
|
76
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
|
+
];
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "es2017",
|
|
4
|
+
"jsx": "react",
|
|
5
|
+
"lib": [
|
|
6
|
+
"es5",
|
|
7
|
+
"es6",
|
|
8
|
+
"es7",
|
|
9
|
+
"dom"
|
|
10
|
+
],
|
|
11
|
+
"declaration": true,
|
|
12
|
+
"resolveJsonModule": true,
|
|
13
|
+
"esModuleInterop": true,
|
|
14
|
+
"experimentalDecorators": true,
|
|
15
|
+
"moduleResolution": "node",
|
|
16
|
+
"noUnusedLocals": true,
|
|
17
|
+
"module": "commonjs",
|
|
18
|
+
"sourceMap": true,
|
|
19
|
+
"strict": true
|
|
20
|
+
},
|
|
21
|
+
"esModuleInterop": true,
|
|
22
|
+
"module": "ES2020"
|
|
23
|
+
}
|