@nu-art/build-and-install 0.204.92 → 0.204.94
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/core/types/package/package.d.ts +3 -0
- 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 +53 -5
- 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.js +13 -21
- package/v2/unit/core/Unit_TypescriptProject.js +16 -8
- package/v2/unit/firebase-units/Unit_FirebaseFunctionsApp.js +17 -28
- package/v2/unit/firebase-units/Unit_FirebaseHostingApp.js +13 -19
- 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 #########################
|
|
@@ -81,3 +108,24 @@ class BaseUnit extends ts_common_1.Logger {
|
|
|
81
108
|
}
|
|
82
109
|
}
|
|
83
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() {
|
|
@@ -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',
|
|
@@ -104,17 +103,11 @@ class Unit_TypescriptLib extends Unit_Typescript_1.Unit_Typescript {
|
|
|
104
103
|
const pathToCompile = `${this.runtime.pathTo.pkg}/src/main`;
|
|
105
104
|
const pathToTSConfig = `${pathToCompile}/tsconfig.json`;
|
|
106
105
|
try {
|
|
107
|
-
|
|
108
|
-
const commando = nvm_1.NVM.createInteractiveCommando(basic_1.Cli_Basic);
|
|
109
|
-
this.registerTerminatable(async () => {
|
|
110
|
-
console.log(`killing ${pid}`);
|
|
111
|
-
process.kill(pid, 2);
|
|
112
|
-
});
|
|
113
|
-
await commando.setUID(this.config.key)
|
|
106
|
+
const commando = this.allocateCommando(nvm_1.Commando_NVM, basic_1.Commando_Basic)
|
|
114
107
|
.cd(this.runtime.pathTo.pkg)
|
|
115
108
|
.append(`tsc -p "${pathToTSConfig}" --rootDir "${pathToCompile}" --outDir "${this.runtime.pathTo.output}"`)
|
|
116
|
-
.addLogProcessor((log) => !log.includes('Now using node') && !log.includes('.nvmrc\' with version'))
|
|
117
|
-
|
|
109
|
+
.addLogProcessor((log) => !log.includes('Now using node') && !log.includes('.nvmrc\' with version'));
|
|
110
|
+
await this.executeAsyncCommando(commando, (stdout, stderr, exitCode) => {
|
|
118
111
|
if (exitCode > 0)
|
|
119
112
|
throw new CliError_1.CommandoException(`Error compiling`, stdout, stderr, exitCode);
|
|
120
113
|
});
|
|
@@ -134,8 +127,7 @@ class Unit_TypescriptLib extends Unit_Typescript_1.Unit_Typescript {
|
|
|
134
127
|
async copyAssetsToOutput() {
|
|
135
128
|
const command = `find . \\( -name ${assetExtensions.map(suffix => `'*.${suffix}'`)
|
|
136
129
|
.join(' -o -name ')} \\) | cpio -pdmuv "${this.runtime.pathTo.output}" > /dev/null 2>&1`;
|
|
137
|
-
await
|
|
138
|
-
.create(basic_1.Cli_Basic)
|
|
130
|
+
await this.allocateCommando(basic_1.Commando_Basic)
|
|
139
131
|
.cd(`${this.runtime.pathTo.pkg}/src/main`)
|
|
140
132
|
// .setStdErrorValidator(stderr => {
|
|
141
133
|
// return !stderr.match(/\d+\sblock/);
|
|
@@ -152,7 +144,7 @@ class Unit_TypescriptLib extends Unit_Typescript_1.Unit_Typescript {
|
|
|
152
144
|
// ignore if path doesn't related to unit
|
|
153
145
|
if (!path.startsWith(this.config.pathToPackage))
|
|
154
146
|
return;
|
|
155
|
-
this.setStatus('
|
|
147
|
+
this.setStatus('Compiling');
|
|
156
148
|
// check if dist folder must be cleared
|
|
157
149
|
if (shouldRemoveDist)
|
|
158
150
|
await this.removeSpecificFileFromDist(path);
|
|
@@ -190,19 +182,19 @@ class Unit_TypescriptLib extends Unit_Typescript_1.Unit_Typescript {
|
|
|
190
182
|
if (!fs.existsSync(`${this.config.pathToPackage}/prebuild.sh`))
|
|
191
183
|
return;
|
|
192
184
|
this.setStatus('Pre-Compile');
|
|
193
|
-
await
|
|
185
|
+
await this.allocateCommando(basic_1.Commando_Basic)
|
|
194
186
|
.cd(this.runtime.pathTo.pkg)
|
|
195
187
|
.append('bash prebuild.sh')
|
|
196
188
|
.execute();
|
|
197
189
|
}
|
|
198
190
|
async compile() {
|
|
199
|
-
this.setStatus('Compile');
|
|
191
|
+
this.setStatus('Compile', 'start');
|
|
200
192
|
await this.resolveTSConfig();
|
|
201
193
|
await this.clearOutputDir();
|
|
202
194
|
await this.compileImpl();
|
|
203
195
|
await this.copyAssetsToOutput();
|
|
204
196
|
await this.copyPackageJSONToOutput();
|
|
205
|
-
this.setStatus(`Compiled${this.compilationError ? ' with error' : ''}
|
|
197
|
+
this.setStatus(`Compiled${this.compilationError ? ' with error' : ''}`, 'end');
|
|
206
198
|
}
|
|
207
199
|
async purge() {
|
|
208
200
|
await fs_1.promises.rm(this.runtime.pathTo.output, { recursive: true, force: true });
|
|
@@ -210,7 +202,7 @@ class Unit_TypescriptLib extends Unit_Typescript_1.Unit_Typescript {
|
|
|
210
202
|
async printDependencyTree() {
|
|
211
203
|
const CONST_RunningRoot = process.cwd();
|
|
212
204
|
this.logDebug(`Generating Dependency Tree - ${this.config.label}`);
|
|
213
|
-
await
|
|
205
|
+
await this.allocateCommando(basic_1.Commando_Basic)
|
|
214
206
|
.cd(this.runtime.pathTo.pkg)
|
|
215
207
|
.append(`mkdir -p ${CONST_RunningRoot}/.trash/dependencies`)
|
|
216
208
|
.append(`pnpm list --depth 1000 > "${CONST_RunningRoot}/.trash/dependencies/${this.config.key}.txt"`)
|
|
@@ -218,7 +210,7 @@ class Unit_TypescriptLib extends Unit_Typescript_1.Unit_Typescript {
|
|
|
218
210
|
}
|
|
219
211
|
async checkCyclicImports() {
|
|
220
212
|
this.logDebug(`Checking Cyclic Imports - ${this.config.label}`);
|
|
221
|
-
await
|
|
213
|
+
await this.allocateCommando(basic_1.Commando_Basic)
|
|
222
214
|
.cd(this.runtime.pathTo.pkg)
|
|
223
215
|
// .setStdErrorValidator(stderr => {
|
|
224
216
|
// return !stderr.includes('Finding files') && !stderr.includes('Image created');
|
|
@@ -231,7 +223,7 @@ class Unit_TypescriptLib extends Unit_Typescript_1.Unit_Typescript {
|
|
|
231
223
|
const pathToProjectESLint = RunnerParams_1.MemKey_RunnerParams.get()[RunnerParams_1.RunnerParamKey_ConfigPath] + '/.eslintrc.js';
|
|
232
224
|
const pathToLint = this.runtime.pathTo.pkg + 'src/main';
|
|
233
225
|
const extensions = extensionsToLint.map(ext => `--ext ${ext}`).join(' ');
|
|
234
|
-
await nvm_1.
|
|
226
|
+
await this.allocateCommando(nvm_1.Commando_NVM)
|
|
235
227
|
.append(`eslint --config ${pathToProjectESLint} ${extensions} ${pathToLint}`)
|
|
236
228
|
.execute();
|
|
237
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,9 +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
|
-
|
|
127
|
+
this.unregisterTerminatable(terminatable);
|
|
128
|
+
};
|
|
129
|
+
this.registerTerminatable(terminatable);
|
|
122
130
|
});
|
|
123
131
|
}
|
|
124
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,38 +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
|
-
const terminatable = () => commando.gracefullyKill(pid);
|
|
250
|
-
this.registerTerminatable(terminatable);
|
|
251
|
-
await commando.setUID(this.config.key)
|
|
245
|
+
const commando = this.allocateCommando(nvm_1.Commando_NVM).applyNVM()
|
|
252
246
|
.cd(this.runtime.pathTo.pkg)
|
|
253
|
-
.append('ts-node src/main/proxy.ts')
|
|
254
|
-
|
|
255
|
-
this.unregisterTerminatable(terminatable);
|
|
247
|
+
.append('ts-node src/main/proxy.ts');
|
|
248
|
+
return this.executeAsyncCommando(commando);
|
|
256
249
|
}
|
|
257
250
|
async runEmulator() {
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
const terminatable = () => commando.gracefullyKill(pid);
|
|
261
|
-
this.registerTerminatable(terminatable);
|
|
262
|
-
await commando.setUID(this.config.key)
|
|
251
|
+
const commando = this.allocateCommando(nvm_1.Commando_NVM).applyNVM()
|
|
252
|
+
.setUID(this.config.key)
|
|
263
253
|
.cd(this.runtime.pathTo.pkg)
|
|
264
254
|
.onLog(/.*Emulator Hub running.*/, () => this.setStatus('Launch Complete'))
|
|
265
|
-
.append(`firebase emulators:start --export-on-exit --import=.trash/data ${params_1.RuntimeParams.debugBackend ? `--inspect-functions ${this.config.firebaseConfig.debugPort}` : ''}`)
|
|
266
|
-
|
|
267
|
-
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);
|
|
268
257
|
}
|
|
269
258
|
//######################### Deploy Logic #########################
|
|
270
259
|
async deployImpl() {
|
|
271
|
-
|
|
260
|
+
const commando = this.allocateCommando(nvm_1.Commando_NVM).applyNVM()
|
|
272
261
|
.cd(this.runtime.pathTo.output)
|
|
273
262
|
.ls()
|
|
274
263
|
.cat('package.json')
|
|
275
264
|
.cat('index.js')
|
|
276
265
|
.cd(this.runtime.pathTo.pkg)
|
|
277
|
-
.append(`firebase --debug deploy --only functions --force`)
|
|
278
|
-
|
|
266
|
+
.append(`firebase --debug deploy --only functions --force`);
|
|
267
|
+
return this.executeAsyncCommando(commando);
|
|
279
268
|
}
|
|
280
269
|
}
|
|
281
270
|
Unit_FirebaseFunctionsApp.staggerCount = 0;
|
|
@@ -6,11 +6,11 @@ const params_1 = require("../../../core/params/params");
|
|
|
6
6
|
const ts_common_1 = require("@nu-art/ts-common");
|
|
7
7
|
const fs_1 = require("fs");
|
|
8
8
|
const consts_1 = require("../../../core/consts");
|
|
9
|
-
const nvm_1 = require("@nu-art/commando/cli/nvm");
|
|
10
|
-
const basic_1 = require("@nu-art/commando/cli/basic");
|
|
11
9
|
const RunnerParams_1 = require("../../phase-runner/RunnerParams");
|
|
12
10
|
const tools_1 = require("@nu-art/commando/shell/tools");
|
|
13
11
|
const runner_dispatchers_1 = require("../runner-dispatchers");
|
|
12
|
+
const nvm_1 = require("@nu-art/commando/shell/plugins/nvm");
|
|
13
|
+
const basic_1 = require("@nu-art/commando/shell/plugins/basic");
|
|
14
14
|
const CONST_VersionApp = 'version-app.json';
|
|
15
15
|
class Unit_FirebaseHostingApp extends core_1.Unit_TypescriptLib {
|
|
16
16
|
constructor(config) {
|
|
@@ -30,12 +30,12 @@ class Unit_FirebaseHostingApp extends core_1.Unit_TypescriptLib {
|
|
|
30
30
|
await this.resolveHostingRuntimeConfig();
|
|
31
31
|
}
|
|
32
32
|
async compile() {
|
|
33
|
-
this.setStatus('
|
|
33
|
+
this.setStatus('Compiling', 'start');
|
|
34
34
|
await this.resolveTSConfig();
|
|
35
35
|
await this.clearOutputDir();
|
|
36
36
|
await this.createAppVersionFile();
|
|
37
37
|
await this.compileImpl();
|
|
38
|
-
this.setStatus('Compiled');
|
|
38
|
+
this.setStatus('Compiled', 'end');
|
|
39
39
|
}
|
|
40
40
|
async launch() {
|
|
41
41
|
this.setStatus('Launching');
|
|
@@ -96,11 +96,10 @@ class Unit_FirebaseHostingApp extends core_1.Unit_TypescriptLib {
|
|
|
96
96
|
}
|
|
97
97
|
//######################### Compile Logic #########################
|
|
98
98
|
async compileImpl() {
|
|
99
|
-
|
|
100
|
-
.createInteractiveCommando(basic_1.Cli_Basic)
|
|
99
|
+
const commando = this.allocateCommando(nvm_1.Commando_NVM, basic_1.Commando_Basic).applyNVM()
|
|
101
100
|
.cd(this.runtime.pathTo.pkg)
|
|
102
|
-
.append(`ENV=${params_1.RuntimeParams.environment} npm run build`)
|
|
103
|
-
|
|
101
|
+
.append(`ENV=${params_1.RuntimeParams.environment} npm run build`);
|
|
102
|
+
await this.executeAsyncCommando(commando);
|
|
104
103
|
}
|
|
105
104
|
async createAppVersionFile() {
|
|
106
105
|
//Writing the file to the package source instead of the output is fine,
|
|
@@ -112,26 +111,21 @@ class Unit_FirebaseHostingApp extends core_1.Unit_TypescriptLib {
|
|
|
112
111
|
}
|
|
113
112
|
//######################### Launch Logic #########################
|
|
114
113
|
async runApp() {
|
|
115
|
-
|
|
116
|
-
const commando = nvm_1.NVM.createInteractiveCommando(basic_1.Cli_Basic);
|
|
117
|
-
const terminatable = () => commando.gracefullyKill(pid);
|
|
118
|
-
this.registerTerminatable(terminatable);
|
|
119
|
-
await commando
|
|
114
|
+
const commando = this.allocateCommando(nvm_1.Commando_NVM).applyNVM()
|
|
120
115
|
.setUID(this.config.key)
|
|
121
116
|
.cd(this.runtime.pathTo.pkg)
|
|
122
117
|
.append(`array=($(lsof -ti:${[this.config.firebaseConfig.hostingPort].join(',')}))`)
|
|
123
118
|
.append(`((\${#array[@]} > 0)) && kill -9 "\${array[@]}"`)
|
|
124
119
|
.append('echo ')
|
|
125
|
-
.append('npm run start')
|
|
126
|
-
|
|
127
|
-
this.unregisterTerminatable(terminatable);
|
|
120
|
+
.append('npm run start');
|
|
121
|
+
return this.executeAsyncCommando(commando);
|
|
128
122
|
}
|
|
129
123
|
//######################### Deploy Logic #########################
|
|
130
124
|
async deployImpl() {
|
|
131
|
-
|
|
125
|
+
const commando = this.allocateCommando(nvm_1.Commando_NVM).applyNVM()
|
|
132
126
|
.cd(this.runtime.pathTo.pkg)
|
|
133
|
-
.append(`firebase --debug deploy --only hosting`)
|
|
134
|
-
|
|
127
|
+
.append(`firebase --debug deploy --only hosting`);
|
|
128
|
+
return this.executeAsyncCommando(commando);
|
|
135
129
|
}
|
|
136
130
|
}
|
|
137
131
|
exports.Unit_FirebaseHostingApp = Unit_FirebaseHostingApp;
|