@nu-art/build-and-install 0.204.91 → 0.204.93
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 +0 -3
- package/package.json +1 -1
- package/v2/phase-runner/PhaseRunner.js +3 -3
- package/v2/unit/core/BaseUnit.d.ts +11 -4
- package/v2/unit/core/BaseUnit.js +61 -9
- package/v2/unit/core/Unit_Python.d.ts +0 -4
- package/v2/unit/core/Unit_Python.js +5 -19
- package/v2/unit/core/Unit_Typescript.js +3 -3
- package/v2/unit/core/Unit_TypescriptLib.d.ts +1 -0
- package/v2/unit/core/Unit_TypescriptLib.js +17 -22
- package/v2/unit/core/Unit_TypescriptProject.js +16 -10
- package/v2/unit/firebase-units/Unit_FirebaseFunctionsApp.js +17 -26
- package/v2/unit/firebase-units/Unit_FirebaseHostingApp.d.ts +1 -5
- package/v2/unit/firebase-units/Unit_FirebaseHostingApp.js +20 -35
- package/v2/unit/tools/tools.d.ts +2 -0
- package/v2/unit/tools/tools.js +16 -0
- package/logic/ProjectManager.d.ts +0 -49
- package/logic/ProjectManager.js +0 -271
- package/logic/command-executors/CommandExecutor_FirebaseFunction.d.ts +0 -21
- package/logic/command-executors/CommandExecutor_FirebaseFunction.js +0 -71
- package/logic/command-executors/CommandExecutor_FirebaseHosting.d.ts +0 -13
- package/logic/command-executors/CommandExecutor_FirebaseHosting.js +0 -48
- package/logic/command-executors/CommandExecutor_Python.d.ts +0 -15
- package/logic/command-executors/CommandExecutor_Python.js +0 -53
- package/logic/command-executors/index.d.ts +0 -2
- package/logic/command-executors/index.js +0 -18
- package/logic/map-project-packages.d.ts +0 -4
- package/logic/map-project-packages.js +0 -128
- package/phases/phases.d.ts +0 -24
- package/phases/phases.js +0 -775
- package/project-manager.d.ts +0 -4
- package/project-manager.js +0 -9
- package/screen/ProjectScreen.d.ts +0 -31
- package/screen/ProjectScreen.js +0 -140
- package/screen/RunningProcessLogs.d.ts +0 -17
- package/screen/RunningProcessLogs.js +0 -137
package/build-and-install.js
CHANGED
|
@@ -16,9 +16,6 @@ runner
|
|
|
16
16
|
console.log('DEADEDAEDAEDAEDAEDAD');
|
|
17
17
|
return process.exit(0);
|
|
18
18
|
});
|
|
19
|
-
//TODO: make it an array of non exit params
|
|
20
|
-
if (!params_1.RuntimeParams.launch && !params_1.RuntimeParams.watch)
|
|
21
|
-
return process.exit(0);
|
|
22
19
|
})
|
|
23
20
|
.catch(err => {
|
|
24
21
|
ts_common_1.StaticLogger.logError('Failed with error: ', err);
|
package/package.json
CHANGED
|
@@ -32,13 +32,12 @@ const MemStorage_1 = require("@nu-art/ts-common/mem-storage/MemStorage");
|
|
|
32
32
|
const fs_1 = __importStar(require("fs"));
|
|
33
33
|
const thunderstorm_1 = require("../unit/thunderstorm");
|
|
34
34
|
const consts_1 = require("../../defaults/consts");
|
|
35
|
-
const nvm_1 = require("@nu-art/commando/cli/nvm");
|
|
36
|
-
const basic_1 = require("@nu-art/commando/cli/basic");
|
|
37
35
|
const PhaseRunnerDispatcher_1 = require("./PhaseRunnerDispatcher");
|
|
38
36
|
const tools_1 = require("@nu-art/commando/shell/tools");
|
|
39
37
|
const types_1 = require("./types");
|
|
40
38
|
const BAIScreenManager_1 = require("../screens/BAIScreenManager");
|
|
41
39
|
const consts_2 = require("./consts");
|
|
40
|
+
const basic_1 = require("@nu-art/commando/shell/plugins/basic");
|
|
42
41
|
const CONST_ThunderstormVersionKey = 'THUNDERSTORM_SDK_VERSION';
|
|
43
42
|
const CONST_ThunderstormDependencyKey = 'THUNDERSTORM_DEPENDENCY_VERSION';
|
|
44
43
|
const CONST_ProjectVersionKey = 'APP_VERSION';
|
|
@@ -383,6 +382,7 @@ class PhaseRunner extends core_1.BaseUnit {
|
|
|
383
382
|
await this.init();
|
|
384
383
|
await this.buildUnitDependencyTree();
|
|
385
384
|
await this.executeImpl();
|
|
385
|
+
this.killed = true;
|
|
386
386
|
});
|
|
387
387
|
}
|
|
388
388
|
async killRunner() {
|
|
@@ -428,7 +428,7 @@ class PhaseRunner extends core_1.BaseUnit {
|
|
|
428
428
|
});
|
|
429
429
|
}
|
|
430
430
|
async printEnv() {
|
|
431
|
-
await
|
|
431
|
+
await this.allocateCommando(basic_1.Commando_Basic)
|
|
432
432
|
.append('npm -g list typescript eslint firebase-tools sort-package-json --depth=0')
|
|
433
433
|
.append('echo "npm version:"; npm -v')
|
|
434
434
|
.append('echo "node version:"; node -v')
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import { AsyncVoidFunction, Logger } from '@nu-art/ts-common';
|
|
1
|
+
import { AsyncVoidFunction, Constructor, Logger } from '@nu-art/ts-common';
|
|
2
2
|
import { RunnerParamKey } from '../../phase-runner/RunnerParams';
|
|
3
|
+
import { CommandoInteractive } from '@nu-art/commando/shell';
|
|
4
|
+
import { BaseCommando } from '@nu-art/commando/shell/core/BaseCommando';
|
|
5
|
+
import { MergeTypes } from '@nu-art/commando/shell/core/class-merger';
|
|
6
|
+
import { Commando_Basic } from '@nu-art/commando/shell/plugins/basic';
|
|
3
7
|
export type BaseUnit_Config = {
|
|
4
8
|
key: string;
|
|
5
9
|
label: string;
|
|
@@ -12,20 +16,23 @@ export type BaseUnit_RuntimeConfig = {
|
|
|
12
16
|
export declare class BaseUnit<C extends BaseUnit_Config = BaseUnit_Config, RTC extends BaseUnit_RuntimeConfig = BaseUnit_RuntimeConfig> extends Logger {
|
|
13
17
|
readonly config: Readonly<C>;
|
|
14
18
|
readonly runtime: RTC;
|
|
15
|
-
private unitStatus
|
|
19
|
+
private unitStatus;
|
|
16
20
|
private logger;
|
|
17
21
|
private classStack;
|
|
18
22
|
private processTerminator;
|
|
23
|
+
private timeCounter?;
|
|
19
24
|
constructor(config: C);
|
|
20
25
|
registerTerminatable(terminatable: AsyncVoidFunction): void;
|
|
21
26
|
unregisterTerminatable(terminatable: AsyncVoidFunction): void;
|
|
27
|
+
allocateCommando<T extends Constructor<any>[]>(...plugins: T): MergeTypes<[...T]> & CommandoInteractive & BaseCommando & Commando_Basic;
|
|
28
|
+
executeAsyncCommando<T>(commando: CommandoInteractive, callback?: (stdout: string, stderr: string, exitCode: number) => T): Promise<T>;
|
|
22
29
|
protected init(setInitialized?: boolean): Promise<void>;
|
|
23
30
|
protected getRunnerParam(key: RunnerParamKey): string | undefined;
|
|
24
31
|
private initLogClient;
|
|
25
|
-
protected setStatus(status?:
|
|
32
|
+
protected setStatus(status: string, type?: 'start' | 'end'): void;
|
|
26
33
|
protected addToClassStack: (cls: Function) => void;
|
|
27
34
|
isInstanceOf: (cls: Function) => boolean;
|
|
28
|
-
getStatus(): string
|
|
35
|
+
getStatus(): string;
|
|
29
36
|
kill(): Promise<void>;
|
|
30
37
|
getLogs(): string;
|
|
31
38
|
}
|
package/v2/unit/core/BaseUnit.js
CHANGED
|
@@ -4,10 +4,12 @@ exports.BaseUnit = void 0;
|
|
|
4
4
|
const ts_common_1 = require("@nu-art/ts-common");
|
|
5
5
|
const RunnerParams_1 = require("../../phase-runner/RunnerParams");
|
|
6
6
|
const PhaseRunnerDispatcher_1 = require("../../phase-runner/PhaseRunnerDispatcher");
|
|
7
|
-
const
|
|
7
|
+
const shell_1 = require("@nu-art/commando/shell");
|
|
8
|
+
const basic_1 = require("@nu-art/commando/shell/plugins/basic");
|
|
8
9
|
class BaseUnit extends ts_common_1.Logger {
|
|
9
10
|
constructor(config) {
|
|
10
11
|
super(config.key);
|
|
12
|
+
this.unitStatus = 'Pending Initialization';
|
|
11
13
|
this.processTerminator = [];
|
|
12
14
|
//######################### Class Stack Logic #########################
|
|
13
15
|
this.addToClassStack = (cls) => {
|
|
@@ -31,6 +33,22 @@ class BaseUnit extends ts_common_1.Logger {
|
|
|
31
33
|
unregisterTerminatable(terminatable) {
|
|
32
34
|
(0, ts_common_1.removeItemFromArray)(this.processTerminator, terminatable);
|
|
33
35
|
}
|
|
36
|
+
allocateCommando(...plugins) {
|
|
37
|
+
const commando = shell_1.CommandoInteractive.create(...plugins, basic_1.Commando_Basic);
|
|
38
|
+
commando.setUID(this.config.key);
|
|
39
|
+
return commando;
|
|
40
|
+
}
|
|
41
|
+
async executeAsyncCommando(commando, callback) {
|
|
42
|
+
let pid;
|
|
43
|
+
const terminatable = () => commando.gracefullyKill(pid);
|
|
44
|
+
try {
|
|
45
|
+
this.registerTerminatable(terminatable);
|
|
46
|
+
return await commando.executeAsync(_pid => pid = _pid, callback);
|
|
47
|
+
}
|
|
48
|
+
finally {
|
|
49
|
+
this.unregisterTerminatable(terminatable);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
34
52
|
async init(setInitialized = true) {
|
|
35
53
|
this.setStatus('Initializing');
|
|
36
54
|
//Register the unit to PhaseRunnerEvent dispatcher
|
|
@@ -55,10 +73,19 @@ class BaseUnit extends ts_common_1.Logger {
|
|
|
55
73
|
});
|
|
56
74
|
ts_common_1.BeLogged.addClient(this.logger);
|
|
57
75
|
}
|
|
58
|
-
setStatus(status) {
|
|
59
|
-
|
|
60
|
-
if (
|
|
61
|
-
this.
|
|
76
|
+
setStatus(status, type) {
|
|
77
|
+
let operationDuration = '';
|
|
78
|
+
if (type === 'start')
|
|
79
|
+
this.timeCounter = timeCounter();
|
|
80
|
+
if (type === 'end')
|
|
81
|
+
if (!(0, ts_common_1.exists)(this.timeCounter))
|
|
82
|
+
this.logError(`Got end status: '${status}' - while current status '${this.unitStatus}' was not a start`);
|
|
83
|
+
else {
|
|
84
|
+
operationDuration = ` (${this.timeCounter.format('mm:ss')})`;
|
|
85
|
+
delete this.timeCounter;
|
|
86
|
+
}
|
|
87
|
+
this.logInfo(`Unit status update: ${this.unitStatus} => ${status}${operationDuration}`);
|
|
88
|
+
this.unitStatus = `${status}${operationDuration}`;
|
|
62
89
|
PhaseRunnerDispatcher_1.dispatcher_UnitStatusChange.dispatch(this);
|
|
63
90
|
}
|
|
64
91
|
//######################### Public Functions #########################
|
|
@@ -67,13 +94,38 @@ class BaseUnit extends ts_common_1.Logger {
|
|
|
67
94
|
}
|
|
68
95
|
async kill() {
|
|
69
96
|
if (!this.processTerminator.length)
|
|
70
|
-
return;
|
|
71
|
-
this.
|
|
72
|
-
|
|
73
|
-
|
|
97
|
+
return this.setStatus('Killed');
|
|
98
|
+
this.setStatus('Killing');
|
|
99
|
+
try {
|
|
100
|
+
await Promise.all(this.processTerminator.map(toTerminate => toTerminate()));
|
|
101
|
+
}
|
|
102
|
+
finally {
|
|
103
|
+
this.setStatus('Killed');
|
|
104
|
+
}
|
|
74
105
|
}
|
|
75
106
|
getLogs() {
|
|
76
107
|
return this.logger.buffers[0];
|
|
77
108
|
}
|
|
78
109
|
}
|
|
79
110
|
exports.BaseUnit = BaseUnit;
|
|
111
|
+
function timeCounter() {
|
|
112
|
+
const started = (0, ts_common_1.currentTimeMillis)();
|
|
113
|
+
return {
|
|
114
|
+
dt: () => (0, ts_common_1.currentTimeMillis)() - started,
|
|
115
|
+
format: (format) => {
|
|
116
|
+
let dt = (0, ts_common_1.currentTimeMillis)() - started;
|
|
117
|
+
const hours = Math.floor(dt / ts_common_1.Hour);
|
|
118
|
+
dt -= hours * ts_common_1.Hour;
|
|
119
|
+
const minutes = Math.floor(dt / ts_common_1.Minute);
|
|
120
|
+
dt -= minutes * ts_common_1.Minute;
|
|
121
|
+
const seconds = Math.floor(dt / ts_common_1.Second);
|
|
122
|
+
dt -= seconds * ts_common_1.Second;
|
|
123
|
+
const millis = dt;
|
|
124
|
+
return format
|
|
125
|
+
.replace('hh', String(hours).padStart(2, '0'))
|
|
126
|
+
.replace('mm', String(minutes).padStart(2, '0'))
|
|
127
|
+
.replace('ss', String(seconds).padStart(2, '0'))
|
|
128
|
+
.replace('zzz', String(millis).padStart(3, '0'));
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { Phase_Install } from '../../phase';
|
|
2
2
|
import { UnitPhaseImplementor } from '../types';
|
|
3
3
|
import { BaseUnit, BaseUnit_Config, BaseUnit_RuntimeConfig } from './BaseUnit';
|
|
4
|
-
import { Cli_Basic } from '@nu-art/commando/cli/basic';
|
|
5
|
-
import { CommandoInteractive } from '@nu-art/commando/shell';
|
|
6
4
|
export type Unit_Python_Config = BaseUnit_Config & {
|
|
7
5
|
pathToPackage: string;
|
|
8
6
|
};
|
|
@@ -12,9 +10,7 @@ export type Unit_Python_RuntimeConfig = BaseUnit_RuntimeConfig & {
|
|
|
12
10
|
};
|
|
13
11
|
};
|
|
14
12
|
export declare class Unit_Python<C extends Unit_Python_Config = Unit_Python_Config, RTC extends Unit_Python_RuntimeConfig = Unit_Python_RuntimeConfig> extends BaseUnit<C, RTC> implements UnitPhaseImplementor<[Phase_Install]> {
|
|
15
|
-
protected commando: CommandoInteractive & Cli_Basic;
|
|
16
13
|
constructor(config: Unit_Python<C, RTC>['config']);
|
|
17
14
|
protected init(): Promise<void>;
|
|
18
|
-
private initCommando;
|
|
19
15
|
install(): Promise<void>;
|
|
20
16
|
}
|
|
@@ -3,38 +3,24 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Unit_Python = void 0;
|
|
4
4
|
const BaseUnit_1 = require("./BaseUnit");
|
|
5
5
|
const tools_1 = require("@nu-art/commando/shell/tools");
|
|
6
|
-
const
|
|
7
|
-
const shell_1 = require("@nu-art/commando/shell");
|
|
6
|
+
const python_1 = require("@nu-art/commando/shell/plugins/python");
|
|
8
7
|
class Unit_Python extends BaseUnit_1.BaseUnit {
|
|
9
8
|
constructor(config) {
|
|
10
9
|
super(config);
|
|
11
10
|
this.addToClassStack(Unit_Python);
|
|
12
|
-
this.commando = shell_1.CommandoInteractive.create(basic_1.Cli_Basic);
|
|
13
11
|
}
|
|
14
12
|
async init() {
|
|
15
13
|
await super.init();
|
|
16
14
|
this.runtime.pathTo = {
|
|
17
15
|
pkg: (0, tools_1.convertToFullPath)(this.config.pathToPackage),
|
|
18
16
|
};
|
|
19
|
-
await this.initCommando();
|
|
20
|
-
}
|
|
21
|
-
//######################### Internal Logic #########################
|
|
22
|
-
async initCommando() {
|
|
23
|
-
this.commando
|
|
24
|
-
.setUID(this.config.key)
|
|
25
|
-
.cd(this.runtime.pathTo.pkg)
|
|
26
|
-
.debug();
|
|
27
|
-
//Install & Enter VENV
|
|
28
|
-
await this.commando
|
|
29
|
-
.append('python3 -m venv venv')
|
|
30
|
-
.append('source venv/bin/activate')
|
|
31
|
-
.execute();
|
|
32
|
-
//Set Python Path
|
|
33
|
-
await this.commando.append('export PYTHONPATH=.').execute();
|
|
34
17
|
}
|
|
35
18
|
//######################### Phase Implementation #########################
|
|
36
19
|
async install() {
|
|
37
|
-
|
|
20
|
+
const commando = await this.allocateCommando(python_1.Commando_Python3)
|
|
21
|
+
.cd(this.runtime.pathTo.pkg)
|
|
22
|
+
.installVenv();
|
|
23
|
+
await commando.sourceVenv().installRequirements();
|
|
38
24
|
}
|
|
39
25
|
}
|
|
40
26
|
exports.Unit_Python = Unit_Python;
|
|
@@ -27,11 +27,11 @@ exports.Unit_Typescript = void 0;
|
|
|
27
27
|
const BaseUnit_1 = require("./BaseUnit");
|
|
28
28
|
const consts_1 = require("../../../core/consts");
|
|
29
29
|
const ts_common_1 = require("@nu-art/ts-common");
|
|
30
|
-
const map_project_packages_1 = require("../../../logic/map-project-packages");
|
|
31
30
|
const fs = __importStar(require("fs"));
|
|
32
31
|
const fs_1 = require("fs");
|
|
33
32
|
const RunnerParams_1 = require("../../phase-runner/RunnerParams");
|
|
34
33
|
const tools_1 = require("@nu-art/commando/shell/tools");
|
|
34
|
+
const tools_2 = require("../tools/tools");
|
|
35
35
|
const PackageJsonTargetKey_Template = 'template';
|
|
36
36
|
const PackageJsonTargetKey_Root = 'root';
|
|
37
37
|
const PackageJsonTargetKey_Dist = 'dist';
|
|
@@ -98,7 +98,7 @@ class Unit_Typescript extends BaseUnit_1.BaseUnit {
|
|
|
98
98
|
//Get the package params for replacing in the template package json
|
|
99
99
|
const projectConfig = RunnerParams_1.MemKey_ProjectConfig.get();
|
|
100
100
|
//Convert template to actual package.json
|
|
101
|
-
const converted = (0,
|
|
101
|
+
const converted = (0, tools_2.convertPackageJSONTemplateToPackJSON_Value)(template, (value, key) => projectConfig.params[key] ? 'workspace:*' : projectConfig.params[value]);
|
|
102
102
|
//Set dynamic params for this pkg
|
|
103
103
|
projectConfig.params[converted.name] = converted.version;
|
|
104
104
|
projectConfig.params[`${converted.name}_path`] = `file:.dependencies/${this.config.key}`; //Not sure about this one
|
|
@@ -120,7 +120,7 @@ class Unit_Typescript extends BaseUnit_1.BaseUnit {
|
|
|
120
120
|
if (template.types)
|
|
121
121
|
template.types = template.types.replace('dist/', '');
|
|
122
122
|
//Convert template to actual package.json
|
|
123
|
-
return (0,
|
|
123
|
+
return (0, tools_2.convertPackageJSONTemplateToPackJSON_Value)(template, (value, key) => { var _a; return (_a = params[key]) !== null && _a !== void 0 ? _a : params[value]; });
|
|
124
124
|
}
|
|
125
125
|
//######################### Phase Implementations #########################
|
|
126
126
|
async copyPackageJson() {
|
|
@@ -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>;
|
|
@@ -24,19 +24,18 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.Unit_TypescriptLib = void 0;
|
|
27
|
-
const nvm_1 = require("@nu-art/commando/cli/nvm");
|
|
28
27
|
const Unit_Typescript_1 = require("./Unit_Typescript");
|
|
29
28
|
const fs = __importStar(require("fs"));
|
|
30
29
|
const fs_1 = require("fs");
|
|
31
|
-
const basic_1 = require("@nu-art/commando/cli/basic");
|
|
32
30
|
const ts_common_1 = require("@nu-art/ts-common");
|
|
33
31
|
const RunnerParams_1 = require("../../phase-runner/RunnerParams");
|
|
34
32
|
const consts_1 = require("../../../core/consts");
|
|
35
33
|
const params_1 = require("../../../core/params/params");
|
|
36
34
|
const runner_dispatchers_1 = require("../runner-dispatchers");
|
|
37
35
|
const consts_2 = require("../consts");
|
|
38
|
-
const shell_1 = require("@nu-art/commando/shell");
|
|
39
36
|
const CliError_1 = require("@nu-art/commando/shell/core/CliError");
|
|
37
|
+
const nvm_1 = require("@nu-art/commando/shell/plugins/nvm");
|
|
38
|
+
const basic_1 = require("@nu-art/commando/shell/plugins/basic");
|
|
40
39
|
const extensionsToLint = ['.ts', '.tsx'];
|
|
41
40
|
const assetExtensions = [
|
|
42
41
|
'json',
|
|
@@ -58,7 +57,10 @@ class Unit_TypescriptLib extends Unit_Typescript_1.Unit_Typescript {
|
|
|
58
57
|
async __onWatchEvent(type, path) {
|
|
59
58
|
if (type === consts_2.WatchEvent_Ready)
|
|
60
59
|
return this.setStatus('Watching');
|
|
61
|
-
|
|
60
|
+
if (this.debounceWatch)
|
|
61
|
+
delete this.debounceWatch;
|
|
62
|
+
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);
|
|
63
|
+
this.debounceWatch();
|
|
62
64
|
}
|
|
63
65
|
async init(setInitialized = true) {
|
|
64
66
|
await super.init(false);
|
|
@@ -101,17 +103,11 @@ class Unit_TypescriptLib extends Unit_Typescript_1.Unit_Typescript {
|
|
|
101
103
|
const pathToCompile = `${this.runtime.pathTo.pkg}/src/main`;
|
|
102
104
|
const pathToTSConfig = `${pathToCompile}/tsconfig.json`;
|
|
103
105
|
try {
|
|
104
|
-
|
|
105
|
-
const commando = nvm_1.NVM.createInteractiveCommando(basic_1.Cli_Basic);
|
|
106
|
-
this.registerTerminatable(async () => {
|
|
107
|
-
console.log(`killing ${pid}`);
|
|
108
|
-
process.kill(pid, 2);
|
|
109
|
-
});
|
|
110
|
-
await commando.setUID(this.config.key)
|
|
106
|
+
const commando = this.allocateCommando(nvm_1.Commando_NVM, basic_1.Commando_Basic)
|
|
111
107
|
.cd(this.runtime.pathTo.pkg)
|
|
112
108
|
.append(`tsc -p "${pathToTSConfig}" --rootDir "${pathToCompile}" --outDir "${this.runtime.pathTo.output}"`)
|
|
113
|
-
.addLogProcessor((log) => !log.includes('Now using node') && !log.includes('.nvmrc\' with version'))
|
|
114
|
-
|
|
109
|
+
.addLogProcessor((log) => !log.includes('Now using node') && !log.includes('.nvmrc\' with version'));
|
|
110
|
+
await this.executeAsyncCommando(commando, (stdout, stderr, exitCode) => {
|
|
115
111
|
if (exitCode > 0)
|
|
116
112
|
throw new CliError_1.CommandoException(`Error compiling`, stdout, stderr, exitCode);
|
|
117
113
|
});
|
|
@@ -131,8 +127,7 @@ class Unit_TypescriptLib extends Unit_Typescript_1.Unit_Typescript {
|
|
|
131
127
|
async copyAssetsToOutput() {
|
|
132
128
|
const command = `find . \\( -name ${assetExtensions.map(suffix => `'*.${suffix}'`)
|
|
133
129
|
.join(' -o -name ')} \\) | cpio -pdmuv "${this.runtime.pathTo.output}" > /dev/null 2>&1`;
|
|
134
|
-
await
|
|
135
|
-
.create(basic_1.Cli_Basic)
|
|
130
|
+
await this.allocateCommando(basic_1.Commando_Basic)
|
|
136
131
|
.cd(`${this.runtime.pathTo.pkg}/src/main`)
|
|
137
132
|
// .setStdErrorValidator(stderr => {
|
|
138
133
|
// return !stderr.match(/\d+\sblock/);
|
|
@@ -149,7 +144,7 @@ class Unit_TypescriptLib extends Unit_Typescript_1.Unit_Typescript {
|
|
|
149
144
|
// ignore if path doesn't related to unit
|
|
150
145
|
if (!path.startsWith(this.config.pathToPackage))
|
|
151
146
|
return;
|
|
152
|
-
this.setStatus('
|
|
147
|
+
this.setStatus('Compiling');
|
|
153
148
|
// check if dist folder must be cleared
|
|
154
149
|
if (shouldRemoveDist)
|
|
155
150
|
await this.removeSpecificFileFromDist(path);
|
|
@@ -187,19 +182,19 @@ class Unit_TypescriptLib extends Unit_Typescript_1.Unit_Typescript {
|
|
|
187
182
|
if (!fs.existsSync(`${this.config.pathToPackage}/prebuild.sh`))
|
|
188
183
|
return;
|
|
189
184
|
this.setStatus('Pre-Compile');
|
|
190
|
-
await
|
|
185
|
+
await this.allocateCommando(basic_1.Commando_Basic)
|
|
191
186
|
.cd(this.runtime.pathTo.pkg)
|
|
192
187
|
.append('bash prebuild.sh')
|
|
193
188
|
.execute();
|
|
194
189
|
}
|
|
195
190
|
async compile() {
|
|
196
|
-
this.setStatus('Compile');
|
|
191
|
+
this.setStatus('Compile', 'start');
|
|
197
192
|
await this.resolveTSConfig();
|
|
198
193
|
await this.clearOutputDir();
|
|
199
194
|
await this.compileImpl();
|
|
200
195
|
await this.copyAssetsToOutput();
|
|
201
196
|
await this.copyPackageJSONToOutput();
|
|
202
|
-
this.setStatus(`Compiled${this.compilationError ? ' with error' : ''}
|
|
197
|
+
this.setStatus(`Compiled${this.compilationError ? ' with error' : ''}`, 'end');
|
|
203
198
|
}
|
|
204
199
|
async purge() {
|
|
205
200
|
await fs_1.promises.rm(this.runtime.pathTo.output, { recursive: true, force: true });
|
|
@@ -207,7 +202,7 @@ class Unit_TypescriptLib extends Unit_Typescript_1.Unit_Typescript {
|
|
|
207
202
|
async printDependencyTree() {
|
|
208
203
|
const CONST_RunningRoot = process.cwd();
|
|
209
204
|
this.logDebug(`Generating Dependency Tree - ${this.config.label}`);
|
|
210
|
-
await
|
|
205
|
+
await this.allocateCommando(basic_1.Commando_Basic)
|
|
211
206
|
.cd(this.runtime.pathTo.pkg)
|
|
212
207
|
.append(`mkdir -p ${CONST_RunningRoot}/.trash/dependencies`)
|
|
213
208
|
.append(`pnpm list --depth 1000 > "${CONST_RunningRoot}/.trash/dependencies/${this.config.key}.txt"`)
|
|
@@ -215,7 +210,7 @@ class Unit_TypescriptLib extends Unit_Typescript_1.Unit_Typescript {
|
|
|
215
210
|
}
|
|
216
211
|
async checkCyclicImports() {
|
|
217
212
|
this.logDebug(`Checking Cyclic Imports - ${this.config.label}`);
|
|
218
|
-
await
|
|
213
|
+
await this.allocateCommando(basic_1.Commando_Basic)
|
|
219
214
|
.cd(this.runtime.pathTo.pkg)
|
|
220
215
|
// .setStdErrorValidator(stderr => {
|
|
221
216
|
// return !stderr.includes('Finding files') && !stderr.includes('Image created');
|
|
@@ -228,7 +223,7 @@ class Unit_TypescriptLib extends Unit_Typescript_1.Unit_Typescript {
|
|
|
228
223
|
const pathToProjectESLint = RunnerParams_1.MemKey_RunnerParams.get()[RunnerParams_1.RunnerParamKey_ConfigPath] + '/.eslintrc.js';
|
|
229
224
|
const pathToLint = this.runtime.pathTo.pkg + 'src/main';
|
|
230
225
|
const extensions = extensionsToLint.map(ext => `--ext ${ext}`).join(' ');
|
|
231
|
-
await nvm_1.
|
|
226
|
+
await this.allocateCommando(nvm_1.Commando_NVM)
|
|
232
227
|
.append(`eslint --config ${pathToProjectESLint} ${extensions} ${pathToLint}`)
|
|
233
228
|
.execute();
|
|
234
229
|
}
|
|
@@ -27,14 +27,15 @@ exports.Unit_TypescriptProject = void 0;
|
|
|
27
27
|
const Unit_Typescript_1 = require("./Unit_Typescript");
|
|
28
28
|
const params_1 = require("../../../core/params/params");
|
|
29
29
|
const ts_common_1 = require("@nu-art/ts-common");
|
|
30
|
-
const nvm_1 = require("@nu-art/commando/cli/nvm");
|
|
31
|
-
const pnpm_1 = require("@nu-art/commando/cli/pnpm");
|
|
32
30
|
const consts_1 = require("../../phase-runner/consts");
|
|
33
31
|
const chokidar = __importStar(require("chokidar"));
|
|
34
32
|
const runner_dispatchers_1 = require("../runner-dispatchers");
|
|
35
33
|
const consts_2 = require("../consts");
|
|
36
34
|
const Unit_TypescriptLib_1 = require("./Unit_TypescriptLib");
|
|
37
35
|
const firebase_units_1 = require("../firebase-units");
|
|
36
|
+
const nvm_1 = require("@nu-art/commando/shell/plugins/nvm");
|
|
37
|
+
const pnpm_1 = require("@nu-art/commando/shell/plugins/pnpm");
|
|
38
|
+
const pnpm_2 = require("@nu-art/commando/shell/services/pnpm");
|
|
38
39
|
class Unit_TypescriptProject extends Unit_Typescript_1.Unit_Typescript {
|
|
39
40
|
constructor(config) {
|
|
40
41
|
super(config);
|
|
@@ -57,16 +58,20 @@ class Unit_TypescriptProject extends Unit_Typescript_1.Unit_Typescript {
|
|
|
57
58
|
return acc;
|
|
58
59
|
}, []);
|
|
59
60
|
this.logInfo(`Installing Global Packages: ${packages.join(' ')}`);
|
|
60
|
-
await
|
|
61
|
+
await this.allocateCommando(nvm_1.Commando_NVM)
|
|
62
|
+
.append(`npm i -g ${packages.join(' ')}`)
|
|
63
|
+
.execute();
|
|
61
64
|
}
|
|
62
65
|
async installPackages() {
|
|
63
66
|
if (!params_1.RuntimeParams.install && !params_1.RuntimeParams.installPackages)
|
|
64
67
|
return;
|
|
68
|
+
this.setStatus('Installing packages', 'start');
|
|
65
69
|
const runner = consts_1.MemKey_PhaseRunner.get();
|
|
66
70
|
const units = runner.getUnits().filter(unit => unit instanceof Unit_Typescript_1.Unit_Typescript);
|
|
67
71
|
const packages = units.map(unit => unit.config.pathToPackage);
|
|
68
|
-
await
|
|
69
|
-
await
|
|
72
|
+
await pnpm_2.PNPM.createWorkspace(packages);
|
|
73
|
+
await pnpm_2.PNPM.installPackages(this.allocateCommando(nvm_1.Commando_NVM, pnpm_1.Commando_PNPM));
|
|
74
|
+
this.setStatus('Installed packages', 'end');
|
|
70
75
|
}
|
|
71
76
|
/**
|
|
72
77
|
* Resolve all paths to watch in all project libs
|
|
@@ -77,7 +82,8 @@ class Unit_TypescriptProject extends Unit_Typescript_1.Unit_Typescript {
|
|
|
77
82
|
// Using phase runner instance to resolve all project libs to watch
|
|
78
83
|
const cantBeInstanceOf = [firebase_units_1.Unit_FirebaseHostingApp, firebase_units_1.Unit_FirebaseFunctionsApp];
|
|
79
84
|
const projectLibs = consts_1.MemKey_PhaseRunner.get()
|
|
80
|
-
.getUnits()
|
|
85
|
+
.getUnits()
|
|
86
|
+
.filter(unit => unit.isInstanceOf(Unit_TypescriptLib_1.Unit_TypescriptLib) && cantBeInstanceOf.every(_instance => !unit.isInstanceOf(_instance)));
|
|
81
87
|
//return all paths to watch
|
|
82
88
|
return projectLibs.map(lib => {
|
|
83
89
|
const sourceFolder = `${lib.config.pathToPackage}/src/main`;
|
|
@@ -116,11 +122,11 @@ class Unit_TypescriptProject extends Unit_Typescript_1.Unit_Typescript {
|
|
|
116
122
|
runner_dispatchers_1.dispatcher_WatchEvent.dispatch(consts_2.WatchEvent_RemoveFile, path);
|
|
117
123
|
});
|
|
118
124
|
});
|
|
119
|
-
|
|
125
|
+
const terminatable = async () => {
|
|
120
126
|
await watcher.close();
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
127
|
+
this.unregisterTerminatable(terminatable);
|
|
128
|
+
};
|
|
129
|
+
this.registerTerminatable(terminatable);
|
|
124
130
|
});
|
|
125
131
|
}
|
|
126
132
|
async watchImpl() {
|
|
@@ -8,20 +8,18 @@ const params_1 = require("../../../core/params/params");
|
|
|
8
8
|
const ts_common_1 = require("@nu-art/ts-common");
|
|
9
9
|
const consts_2 = require("../../../defaults/consts");
|
|
10
10
|
const RunnerParams_1 = require("../../phase-runner/RunnerParams");
|
|
11
|
-
const basic_1 = require("@nu-art/commando/cli/basic");
|
|
12
|
-
const nvm_1 = require("@nu-art/commando/cli/nvm");
|
|
13
|
-
const shell_1 = require("@nu-art/commando/shell");
|
|
14
11
|
const consts_3 = require("../../phase-runner/consts");
|
|
15
12
|
const runner_dispatchers_1 = require("../runner-dispatchers");
|
|
13
|
+
const nvm_1 = require("@nu-art/commando/shell/plugins/nvm");
|
|
16
14
|
const CONST_VersionApp = 'version-app.json';
|
|
17
15
|
class Unit_FirebaseFunctionsApp extends core_1.Unit_TypescriptLib {
|
|
18
16
|
async __onUnitWatchCompiled(unit) {
|
|
19
17
|
if (this.runtime.unitDependencyNames.includes(unit.runtime.dependencyName)) {
|
|
20
|
-
this.setStatus('
|
|
18
|
+
this.setStatus('Compiling', 'start');
|
|
21
19
|
await this.compileImpl();
|
|
22
20
|
await this.copyAssetsToOutput();
|
|
23
21
|
await this.createDependenciesDir();
|
|
24
|
-
this.setStatus('Compiled');
|
|
22
|
+
this.setStatus('Compiled', 'end');
|
|
25
23
|
}
|
|
26
24
|
}
|
|
27
25
|
constructor(config) {
|
|
@@ -39,7 +37,7 @@ class Unit_FirebaseFunctionsApp extends core_1.Unit_TypescriptLib {
|
|
|
39
37
|
await this.resolveFunctionsJSON();
|
|
40
38
|
}
|
|
41
39
|
async compile() {
|
|
42
|
-
this.setStatus('
|
|
40
|
+
this.setStatus('Compiling', 'start');
|
|
43
41
|
await this.resolveTSConfig();
|
|
44
42
|
await this.clearOutputDir();
|
|
45
43
|
await this.createAppVersionFile();
|
|
@@ -47,7 +45,7 @@ class Unit_FirebaseFunctionsApp extends core_1.Unit_TypescriptLib {
|
|
|
47
45
|
await this.copyAssetsToOutput();
|
|
48
46
|
await this.createDependenciesDir();
|
|
49
47
|
await this.copyPackageJSONToOutput();
|
|
50
|
-
this.setStatus('Compiled');
|
|
48
|
+
this.setStatus('Compiled', 'end');
|
|
51
49
|
}
|
|
52
50
|
async launch() {
|
|
53
51
|
this.setStatus('Launching');
|
|
@@ -222,7 +220,7 @@ class Unit_FirebaseFunctionsApp extends core_1.Unit_TypescriptLib {
|
|
|
222
220
|
const dependencyOutputPath = `${unit.runtime.pathTo.output}/`;
|
|
223
221
|
const targetPath = `${this.runtime.pathTo.output}/.dependencies/${unit.config.key}/`;
|
|
224
222
|
const pjTargetPath = `${targetPath}/${consts_1.CONST_PackageJSON}`;
|
|
225
|
-
await
|
|
223
|
+
await this.allocateCommando()
|
|
226
224
|
.append(`mkdir -p ${targetPath}`)
|
|
227
225
|
.append(`rsync -a --delete ${dependencyOutputPath} ${targetPath}`)
|
|
228
226
|
.execute();
|
|
@@ -235,7 +233,7 @@ class Unit_FirebaseFunctionsApp extends core_1.Unit_TypescriptLib {
|
|
|
235
233
|
}
|
|
236
234
|
//######################### Launch Logic #########################
|
|
237
235
|
async releasePorts() {
|
|
238
|
-
const commando = nvm_1.
|
|
236
|
+
const commando = this.allocateCommando(nvm_1.Commando_NVM).applyNVM();
|
|
239
237
|
const allPorts = Array.from({ length: 10 }, (_, i) => `${this.config.firebaseConfig.basePort + i}`);
|
|
240
238
|
await commando.setUID(this.config.key)
|
|
241
239
|
.append(`array=($(lsof -ti:${allPorts.join(',')}))`)
|
|
@@ -244,36 +242,29 @@ class Unit_FirebaseFunctionsApp extends core_1.Unit_TypescriptLib {
|
|
|
244
242
|
.execute();
|
|
245
243
|
}
|
|
246
244
|
async runProxy() {
|
|
247
|
-
|
|
248
|
-
const commando = nvm_1.NVM.createInteractiveCommando(basic_1.Cli_Basic);
|
|
249
|
-
this.registerTerminatable(() => commando.gracefullyKill(pid));
|
|
250
|
-
await commando.setUID(this.config.key)
|
|
245
|
+
const commando = this.allocateCommando(nvm_1.Commando_NVM).applyNVM()
|
|
251
246
|
.cd(this.runtime.pathTo.pkg)
|
|
252
|
-
.append('ts-node src/main/proxy.ts')
|
|
253
|
-
|
|
247
|
+
.append('ts-node src/main/proxy.ts');
|
|
248
|
+
return this.executeAsyncCommando(commando);
|
|
254
249
|
}
|
|
255
250
|
async runEmulator() {
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
const terminatable = () => commando.gracefullyKill(pid);
|
|
259
|
-
this.registerTerminatable(terminatable);
|
|
260
|
-
await commando.setUID(this.config.key)
|
|
251
|
+
const commando = this.allocateCommando(nvm_1.Commando_NVM).applyNVM()
|
|
252
|
+
.setUID(this.config.key)
|
|
261
253
|
.cd(this.runtime.pathTo.pkg)
|
|
262
254
|
.onLog(/.*Emulator Hub running.*/, () => this.setStatus('Launch Complete'))
|
|
263
|
-
.append(`firebase emulators:start --export-on-exit --import=.trash/data ${params_1.RuntimeParams.debugBackend ? `--inspect-functions ${this.config.firebaseConfig.debugPort}` : ''}`)
|
|
264
|
-
|
|
265
|
-
this.unregisterTerminatable(terminatable);
|
|
255
|
+
.append(`firebase emulators:start --export-on-exit --import=.trash/data ${params_1.RuntimeParams.debugBackend ? `--inspect-functions ${this.config.firebaseConfig.debugPort}` : ''}`);
|
|
256
|
+
return this.executeAsyncCommando(commando);
|
|
266
257
|
}
|
|
267
258
|
//######################### Deploy Logic #########################
|
|
268
259
|
async deployImpl() {
|
|
269
|
-
|
|
260
|
+
const commando = this.allocateCommando(nvm_1.Commando_NVM).applyNVM()
|
|
270
261
|
.cd(this.runtime.pathTo.output)
|
|
271
262
|
.ls()
|
|
272
263
|
.cat('package.json')
|
|
273
264
|
.cat('index.js')
|
|
274
265
|
.cd(this.runtime.pathTo.pkg)
|
|
275
|
-
.append(`firebase --debug deploy --only functions --force`)
|
|
276
|
-
|
|
266
|
+
.append(`firebase --debug deploy --only functions --force`);
|
|
267
|
+
return this.executeAsyncCommando(commando);
|
|
277
268
|
}
|
|
278
269
|
}
|
|
279
270
|
Unit_FirebaseFunctionsApp.staggerCount = 0;
|
|
@@ -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
|
}
|