@nu-art/build-and-install 0.400.6 → 0.400.8
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-v3.js +18 -6
- package/core/consts.d.ts +1 -0
- package/core/consts.js +1 -0
- package/core/exceptions/PhaseAggregatedException.d.ts +5 -2
- package/core/exceptions/PhaseAggregatedException.js +18 -2
- package/core/exceptions/UnitPhaseException.d.ts +5 -0
- package/core/exceptions/UnitPhaseException.js +6 -0
- package/core/params/params.d.ts +2 -2
- package/core/params/params.js +19 -11
- package/package.json +3 -3
- package/v3/PhaseManager.js +4 -2
- package/v3/UnitsMapper/resolvers/UnitMapper_FirebaseHosting.js +3 -1
- package/v3/core/Unit_HelpPrinter.d.ts +1 -1
- package/v3/units/Unit_TypescriptLib.d.ts +1 -0
- package/v3/units/Unit_TypescriptLib.js +5 -0
- package/v3/units/firebase/Unit_FirebaseFunctionsApp.js +28 -24
- package/v3/units/firebase/Unit_FirebaseHostingApp.js +14 -9
package/build-and-install-v3.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _keys, arrayToMap, BeLogged, DebugFlag, filterDuplicates, LogClient_Terminal, Logger, LogLevel, merge } from '@nu-art/ts-common';
|
|
1
|
+
import { _keys, arrayToMap, BeLogged, DebugFlag, filterDuplicates, ImplementationMissingException, LogClient_Terminal, Logger, LogLevel, merge } from '@nu-art/ts-common';
|
|
2
2
|
import { AllBaiParams } from './core/params/params.js';
|
|
3
3
|
import { phases_Build, phases_Deploy, phases_Launch, phases_Terminating } from './v3/phase/index.js';
|
|
4
4
|
import { UnitsMapper } from './v3/UnitsMapper/UnitsMapper.js';
|
|
@@ -8,7 +8,7 @@ import { ProjectUnit } from './v3/units/ProjectUnit.js';
|
|
|
8
8
|
import { PhaseManager } from './v3/PhaseManager.js';
|
|
9
9
|
import { Unit_NodeProject } from './v3/units/index.js';
|
|
10
10
|
import { resolve } from 'path';
|
|
11
|
-
import { CONST_BaiConfig, CONST_NodeModules } from './core/consts.js';
|
|
11
|
+
import { CONST_BaiConfig, CONST_NodeModules, CONST_VersionApp } from './core/consts.js';
|
|
12
12
|
import { UnitMapper_FirebaseFunction, UnitMapper_FirebaseHosting, UnitMapper_NodeLib, UnitMapper_NodeProject } from './v3/UnitsMapper/resolvers/index.js';
|
|
13
13
|
import { CLIParamsResolver } from '@nu-art/commando/cli-params/CLIParamsResolver';
|
|
14
14
|
import { RunningStatusHandler } from './v3/RunningStatusHandler.js';
|
|
@@ -76,6 +76,8 @@ export class BuildAndInstall extends Logger {
|
|
|
76
76
|
const nodeProjectUnit = allProjectUnits.find(unit => unit.isInstanceOf(Unit_NodeProject));
|
|
77
77
|
// @ts-ignore
|
|
78
78
|
this['nodeProjectUnit'] = nodeProjectUnit;
|
|
79
|
+
if (!this.nodeProjectUnit)
|
|
80
|
+
throw new ImplementationMissingException('NodeProject unit not found. Make sure you have a Unit_NodeProject in your project.');
|
|
79
81
|
this.nodeProjectUnit.assignUnit(allProjectUnits);
|
|
80
82
|
this.logDebug(`Parent unit: ${this.nodeProjectUnit.config.key}`);
|
|
81
83
|
this.logDebug(`Child units: ${allProjectUnits.map(unit => unit.config.key).join(', ')}`);
|
|
@@ -91,8 +93,11 @@ export class BuildAndInstall extends Logger {
|
|
|
91
93
|
}));
|
|
92
94
|
const globalOutputFolder = resolve(this.pathToProject, '.trash/output');
|
|
93
95
|
this.unitsDependencyMapper = new UnitsDependencyMapper(unitsDependencies, globalOutputFolder);
|
|
96
|
+
const versionFilePath = resolve(this.pathToProject, CONST_VersionApp);
|
|
97
|
+
this.logInfo('loading version from: ', versionFilePath);
|
|
98
|
+
const version = await FileSystemUtils.file.read.json(versionFilePath, { version: '1.0.0' });
|
|
94
99
|
const runtimeContext = ({
|
|
95
|
-
version:
|
|
100
|
+
version: version.version,
|
|
96
101
|
parentUnit: this.nodeProjectUnit,
|
|
97
102
|
childUnits: allProjectUnits,
|
|
98
103
|
baiConfig,
|
|
@@ -129,8 +134,15 @@ export class BuildAndInstall extends Logger {
|
|
|
129
134
|
if (killCounter > 5)
|
|
130
135
|
process.exit(1);
|
|
131
136
|
});
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
137
|
+
try {
|
|
138
|
+
await phaseManager.execute(executionPlan);
|
|
139
|
+
this.logInfo('Completed successfully');
|
|
140
|
+
this.logInfo('---------------------------------- Process Completed successfully ----------------------------------');
|
|
141
|
+
}
|
|
142
|
+
catch (e) {
|
|
143
|
+
this.logInfo('Process Failed');
|
|
144
|
+
this.logInfo('---------------------------------- Process Failed ----------------------------------');
|
|
145
|
+
throw e;
|
|
146
|
+
}
|
|
135
147
|
}
|
|
136
148
|
}
|
package/core/consts.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { MemKey } from '@nu-art/ts-common/mem-storage/index';
|
|
2
2
|
import { RuntimeProjectConfig } from './types/index.js';
|
|
3
|
+
export declare const CONST_VersionApp = "version-app.json";
|
|
3
4
|
export declare const CONST_PackageJSONTemplate = "__package.json";
|
|
4
5
|
export declare const CONST_PackageJSON = "package.json";
|
|
5
6
|
export declare const CONST_NodeModules = "node_modules";
|
package/core/consts.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { MemKey } from '@nu-art/ts-common/mem-storage/index';
|
|
2
|
+
export const CONST_VersionApp = 'version-app.json';
|
|
2
3
|
export const CONST_PackageJSONTemplate = '__package.json';
|
|
3
4
|
export const CONST_PackageJSON = 'package.json';
|
|
4
5
|
export const CONST_NodeModules = 'node_modules';
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import { CustomException } from '@nu-art/ts-common';
|
|
1
|
+
import { CustomException, Logger } from '@nu-art/ts-common';
|
|
2
2
|
import { ScheduledStep } from '../../v3/PhaseManager.js';
|
|
3
|
+
import { UnitPhaseException } from './UnitPhaseException.js';
|
|
3
4
|
export declare class PhaseAggregatedException extends CustomException {
|
|
4
|
-
|
|
5
|
+
errors: UnitPhaseException[];
|
|
6
|
+
constructor(errors: UnitPhaseException[], step: ScheduledStep);
|
|
7
|
+
print(logger: Logger): void;
|
|
5
8
|
}
|
|
@@ -1,8 +1,24 @@
|
|
|
1
|
-
import { CustomException } from '@nu-art/ts-common';
|
|
1
|
+
import { CustomException, isErrorOfType } from '@nu-art/ts-common';
|
|
2
|
+
import { CommandoException } from '@nu-art/commando/shell/core/CliError';
|
|
2
3
|
export class PhaseAggregatedException extends CustomException {
|
|
4
|
+
errors;
|
|
3
5
|
constructor(errors, step) {
|
|
4
6
|
super(PhaseAggregatedException, `One or more errors occurred in step execution: ${JSON.stringify(step)}`);
|
|
5
7
|
// @ts-ignore
|
|
6
|
-
this.
|
|
8
|
+
this.errors = errors;
|
|
9
|
+
}
|
|
10
|
+
print(logger) {
|
|
11
|
+
logger.logError(this.message);
|
|
12
|
+
this.errors.forEach(error => {
|
|
13
|
+
const commandoError = isErrorOfType(error, CommandoException);
|
|
14
|
+
if (commandoError) {
|
|
15
|
+
logger.logWarning(`message: ${commandoError.message}`);
|
|
16
|
+
commandoError.cause && logger.logWarning('caused by: ', commandoError.cause);
|
|
17
|
+
logger.logError('stdout: ', commandoError.stdout);
|
|
18
|
+
logger.logError('stderr', commandoError.stderr);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
logger.logWarning('error: ', error);
|
|
22
|
+
});
|
|
7
23
|
}
|
|
8
24
|
}
|
package/core/params/params.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { BaseCliParam, CliParams } from '@nu-art/commando/cli-params/types';
|
|
2
2
|
export declare const BaiParam_AllUnits: BaseCliParam<'allUnits', boolean>;
|
|
3
3
|
export declare const BaiParam_DependencyTree: BaseCliParam<'dependencyTree', boolean>;
|
|
4
|
-
export declare const BaiParam_continue: BaseCliParam<'continue', boolean>;
|
|
5
4
|
export declare const BaiParam_SetEnv: BaseCliParam<'environment', string>;
|
|
6
5
|
export declare const BaiParam_Install: BaseCliParam<'install', boolean>;
|
|
7
6
|
export declare const BaiParam_Clean: BaseCliParam<'clean', boolean>;
|
|
@@ -14,6 +13,7 @@ export declare const BaiParam_DryRun: BaseCliParam<'dryRun', boolean>;
|
|
|
14
13
|
export declare const BaiParam_Lint: BaseCliParam<'lint', boolean>;
|
|
15
14
|
export declare const BaiParam_Watch: BaseCliParam<'watch', boolean>;
|
|
16
15
|
export declare const BaiParam_WatchBuildTree: BaseCliParam<'watchBuildTree', boolean>;
|
|
16
|
+
export declare const BaiParam_continue: BaseCliParam<'continue', boolean>;
|
|
17
17
|
export declare const BaiParam_Test: BaseCliParam<'test', boolean>;
|
|
18
18
|
export declare const TestTypes: string[];
|
|
19
19
|
export type TestType = typeof TestTypes[number];
|
|
@@ -35,6 +35,6 @@ export declare const BaiParam_includePackage: BaseCliParam<'includePackage', str
|
|
|
35
35
|
export declare const BaiParam_ToESM: BaseCliParam<'toESM', boolean>;
|
|
36
36
|
export declare const BaiParam_Simulate: BaseCliParam<'simulation', boolean>;
|
|
37
37
|
export declare const BaiParam_CheckCyclicImports: BaseCliParam<'checkCyclicImports', boolean>;
|
|
38
|
-
export declare const AllBaiParams: (BaseCliParam<"allUnits", boolean> | BaseCliParam<"dependencyTree", boolean> | BaseCliParam<"
|
|
38
|
+
export declare const AllBaiParams: (BaseCliParam<"allUnits", boolean> | BaseCliParam<"dependencyTree", boolean> | BaseCliParam<"environment", string> | BaseCliParam<"install", boolean> | BaseCliParam<"clean", boolean> | BaseCliParam<"purge", boolean> | BaseCliParam<"generate", boolean> | BaseCliParam<"generateDocs", boolean> | BaseCliParam<"noBuild", boolean> | BaseCliParam<"prepare", boolean> | BaseCliParam<"dryRun", boolean> | BaseCliParam<"lint", boolean> | BaseCliParam<"watch", boolean> | BaseCliParam<"watchBuildTree", boolean> | BaseCliParam<"continue", boolean> | BaseCliParam<"test", boolean> | BaseCliParam<"testType", string[]> | BaseCliParam<"testFiles", string[]> | BaseCliParam<"testCases", string[]> | BaseCliParam<"testDebugPort", number> | BaseCliParam<"launch", boolean> | BaseCliParam<"debugBackend", boolean> | BaseCliParam<"deploy", boolean> | BaseCliParam<"debug", boolean> | BaseCliParam<"debugLifecycle", boolean> | BaseCliParam<"verbose", boolean> | BaseCliParam<"publish", PromoteType> | BaseCliParam<"usePackage", string[]> | BaseCliParam<"includePackage", string[]> | BaseCliParam<"toESM", boolean> | BaseCliParam<"simulation", boolean> | BaseCliParam<"checkCyclicImports", boolean>)[];
|
|
39
39
|
export type BaiParams = CliParams<typeof AllBaiParams>;
|
|
40
40
|
export {};
|
package/core/params/params.js
CHANGED
|
@@ -12,13 +12,6 @@ export const BaiParam_DependencyTree = {
|
|
|
12
12
|
group: 'General',
|
|
13
13
|
description: 'Will print the projects packages dependencies tree into the .trash folder'
|
|
14
14
|
};
|
|
15
|
-
export const BaiParam_continue = {
|
|
16
|
-
keys: ['--continue', '-con'],
|
|
17
|
-
keyName: 'continue',
|
|
18
|
-
type: 'boolean',
|
|
19
|
-
group: 'Build',
|
|
20
|
-
description: 'Will pick up where last build process failed'
|
|
21
|
-
};
|
|
22
15
|
export const BaiParam_SetEnv = {
|
|
23
16
|
keys: ['--set-env', '-se'],
|
|
24
17
|
keyName: 'environment',
|
|
@@ -108,6 +101,14 @@ export const BaiParam_WatchBuildTree = {
|
|
|
108
101
|
description: 'Once watch triggers, will build the entire tree that depends on the libs that changed',
|
|
109
102
|
dependencies: [{ param: BaiParam_Watch, value: true }, { param: BaiParam_NoBuild, value: true }, { param: BaiParam_Prepare, value: false }]
|
|
110
103
|
};
|
|
104
|
+
export const BaiParam_continue = {
|
|
105
|
+
keys: ['--continue', '-con'],
|
|
106
|
+
keyName: 'continue',
|
|
107
|
+
type: 'boolean',
|
|
108
|
+
group: 'Build',
|
|
109
|
+
description: 'Will pick up where last build process failed',
|
|
110
|
+
dependencies: [{ param: BaiParam_Watch, value: false }]
|
|
111
|
+
};
|
|
111
112
|
export const BaiParam_Test = {
|
|
112
113
|
keys: ['--test', '-t'],
|
|
113
114
|
keyName: 'test',
|
|
@@ -158,7 +159,7 @@ export const BaiParam_Launch = {
|
|
|
158
159
|
keyName: 'launch',
|
|
159
160
|
type: 'boolean',
|
|
160
161
|
group: 'Apps',
|
|
161
|
-
description: '
|
|
162
|
+
description: 'Will perform the launch phast on packages that supports it. use the --use-package flag to filter out for specific packages'
|
|
162
163
|
};
|
|
163
164
|
export const BaiParam_DebugBackend = {
|
|
164
165
|
keys: ['--debug-backend', '-lbd'],
|
|
@@ -172,7 +173,7 @@ export const BaiParam_Deploy = {
|
|
|
172
173
|
keyName: 'deploy',
|
|
173
174
|
type: 'boolean',
|
|
174
175
|
group: 'Apps',
|
|
175
|
-
description: 'Will
|
|
176
|
+
description: 'Will perform the deploy phast on packages that supports it. use the --use-package flag to filter out for specific packages',
|
|
176
177
|
dependencies: [
|
|
177
178
|
{ param: BaiParam_Launch, value: false },
|
|
178
179
|
{ param: BaiParam_Watch, value: false },
|
|
@@ -195,7 +196,7 @@ export const BaiParam_DebugLifecycle = {
|
|
|
195
196
|
description: 'Will only print the run config and die'
|
|
196
197
|
};
|
|
197
198
|
export const BaiParam_Verbose = {
|
|
198
|
-
keys: ['--verbose', '-
|
|
199
|
+
keys: ['--verbose', '-v'],
|
|
199
200
|
keyName: 'verbose',
|
|
200
201
|
group: 'Other',
|
|
201
202
|
type: 'boolean',
|
|
@@ -206,7 +207,14 @@ export const BaiParam_QuickDeploy = {
|
|
|
206
207
|
keyName: 'quickDeploy',
|
|
207
208
|
type: 'boolean',
|
|
208
209
|
group: 'Other',
|
|
209
|
-
description: 'Will
|
|
210
|
+
description: 'Will perform the deploy phase without other lifecycle options',
|
|
211
|
+
dependencies: [
|
|
212
|
+
...BaiParam_Deploy.dependencies,
|
|
213
|
+
{ param: BaiParam_Purge, value: false },
|
|
214
|
+
{ param: BaiParam_Lint, value: false },
|
|
215
|
+
{ param: BaiParam_Test, value: false },
|
|
216
|
+
{ param: BaiParam_NoBuild, value: true },
|
|
217
|
+
]
|
|
210
218
|
};
|
|
211
219
|
export const BaiParam_Publish = {
|
|
212
220
|
keys: ['--publish'],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nu-art/build-and-install",
|
|
3
|
-
"version": "0.400.
|
|
3
|
+
"version": "0.400.8",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"chokidar": "^3.6.0",
|
|
34
|
-
"@nu-art/ts-common": "0.400.
|
|
35
|
-
"@nu-art/commando": "0.400.
|
|
34
|
+
"@nu-art/ts-common": "0.400.8",
|
|
35
|
+
"@nu-art/commando": "0.400.8"
|
|
36
36
|
},
|
|
37
37
|
"unitConfig": {
|
|
38
38
|
"type": "typescript-lib"
|
package/v3/PhaseManager.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { addItemToArray, asArray, exists, flatArray, Logger, removeItemFromArray, timeCounter } from '@nu-art/ts-common';
|
|
2
2
|
import { PhaseAggregatedException } from '../core/exceptions/PhaseAggregatedException.js';
|
|
3
|
+
import { UnitPhaseException } from '../core/exceptions/UnitPhaseException.js';
|
|
3
4
|
export class PhaseManager extends Logger {
|
|
4
5
|
phases;
|
|
5
6
|
units;
|
|
@@ -110,7 +111,7 @@ export class PhaseManager extends Logger {
|
|
|
110
111
|
}
|
|
111
112
|
catch (error) {
|
|
112
113
|
this.logError(`Phase(${phase.name}) - Error - ${unit.config.key}`, error);
|
|
113
|
-
errors.push(error);
|
|
114
|
+
errors.push(new UnitPhaseException(error, unit, phase.key));
|
|
114
115
|
failedStep = scheduledStep;
|
|
115
116
|
this.killed = true;
|
|
116
117
|
failed = true;
|
|
@@ -123,8 +124,9 @@ export class PhaseManager extends Logger {
|
|
|
123
124
|
if (!failed)
|
|
124
125
|
await this.runningStatus.onUnitCompleted(unit.config.key);
|
|
125
126
|
}));
|
|
126
|
-
if (failedStep && errors.length)
|
|
127
|
+
if (failedStep && errors.length) {
|
|
127
128
|
throw new PhaseAggregatedException(errors, failedStep);
|
|
129
|
+
}
|
|
128
130
|
await this.runningStatus.onStepEnded();
|
|
129
131
|
}
|
|
130
132
|
this.logInfo('All steps completed.');
|
|
@@ -23,8 +23,10 @@ export class UnitMapper_FirebaseHosting_Class extends UnitMapper_Node {
|
|
|
23
23
|
const outputDir = context.packageJson.publishConfig?.directory;
|
|
24
24
|
const env = this.runtimeParams[BaiParam_SetEnv.keyName];
|
|
25
25
|
const envUnitConfig = context.packageJson.unitConfig.envs[env];
|
|
26
|
-
if (!envUnitConfig)
|
|
26
|
+
if (!envUnitConfig) {
|
|
27
|
+
this.logWarning('Package Json config:', context.packageJson.unitConfig);
|
|
27
28
|
throw new ImplementationMissingException(`Missing configuration for env: ${env}`);
|
|
29
|
+
}
|
|
28
30
|
const envConfig = {
|
|
29
31
|
config: envUnitConfig.config,
|
|
30
32
|
projectId: envUnitConfig.projectId,
|
|
@@ -3,7 +3,7 @@ import { UnitPhaseImplementor } from './types.js';
|
|
|
3
3
|
import { Phase } from '../phase/index.js';
|
|
4
4
|
import { ProjectUnit } from '../units/index.js';
|
|
5
5
|
export declare const BaiParam_Help: BaseCliParam<'help', boolean>;
|
|
6
|
-
declare const AllBaiParams_Help: (BaseCliParam<"allUnits", boolean> | BaseCliParam<"dependencyTree", boolean> | BaseCliParam<"
|
|
6
|
+
declare const AllBaiParams_Help: (BaseCliParam<"allUnits", boolean> | BaseCliParam<"dependencyTree", boolean> | BaseCliParam<"environment", string> | BaseCliParam<"install", boolean> | BaseCliParam<"clean", boolean> | BaseCliParam<"purge", boolean> | BaseCliParam<"generate", boolean> | BaseCliParam<"generateDocs", boolean> | BaseCliParam<"noBuild", boolean> | BaseCliParam<"prepare", boolean> | BaseCliParam<"dryRun", boolean> | BaseCliParam<"lint", boolean> | BaseCliParam<"watch", boolean> | BaseCliParam<"watchBuildTree", boolean> | BaseCliParam<"continue", boolean> | BaseCliParam<"test", boolean> | BaseCliParam<"testType", string[]> | BaseCliParam<"testFiles", string[]> | BaseCliParam<"testCases", string[]> | BaseCliParam<"testDebugPort", number> | BaseCliParam<"launch", boolean> | BaseCliParam<"debugBackend", boolean> | BaseCliParam<"deploy", boolean> | BaseCliParam<"debug", boolean> | BaseCliParam<"debugLifecycle", boolean> | BaseCliParam<"verbose", boolean> | BaseCliParam<"publish", "patch" | "minor" | "major"> | BaseCliParam<"usePackage", string[]> | BaseCliParam<"includePackage", string[]> | BaseCliParam<"toESM", boolean> | BaseCliParam<"simulation", boolean> | BaseCliParam<"checkCyclicImports", boolean> | BaseCliParam<"help", boolean>)[];
|
|
7
7
|
export type Help_BaiParams = CliParams<typeof AllBaiParams_Help>;
|
|
8
8
|
export type Phase_Help = typeof phase_Help;
|
|
9
9
|
export declare const phaseKey_Help = "help";
|
|
@@ -11,6 +11,7 @@ export type Unit_TypescriptLib_Config = Unit_PackageJson_Config & {
|
|
|
11
11
|
export declare class Unit_TypescriptLib<C extends Unit_TypescriptLib_Config = Unit_TypescriptLib_Config> extends Unit_PackageJson<C> implements UnitPhaseImplementor<[Phase_PreCompile, Phase_Compile, Phase_PrintDependencyTree, Phase_CheckCyclicImports, Phase_Lint, Phase_Test, Phase_Publish, Phase_ToESM]> {
|
|
12
12
|
private TestTypeWorkspaceSetup;
|
|
13
13
|
runTests(): Promise<void>;
|
|
14
|
+
protected dependencyUnits: Unit_TypescriptLib[];
|
|
14
15
|
constructor(config: Unit_TypescriptLib<C>['config']);
|
|
15
16
|
protected clearOutputDir(): Promise<void>;
|
|
16
17
|
protected clearOutputDirImpl(): Promise<void>;
|
|
@@ -126,6 +126,7 @@ export class Unit_TypescriptLib extends Unit_PackageJson {
|
|
|
126
126
|
});
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
|
+
dependencyUnits;
|
|
129
130
|
constructor(config) {
|
|
130
131
|
super(config);
|
|
131
132
|
this.addToClassStack(Unit_TypescriptLib);
|
|
@@ -147,6 +148,8 @@ export class Unit_TypescriptLib extends Unit_PackageJson {
|
|
|
147
148
|
// @ts-ignore
|
|
148
149
|
this.publish = undefined;
|
|
149
150
|
}
|
|
151
|
+
const unitKeys = this.runtimeContext.unitsMapper.getTransitiveDependencies([this.config.key]);
|
|
152
|
+
this.dependencyUnits = this.runtimeContext.unitsResolver(unitKeys, Unit_TypescriptLib);
|
|
150
153
|
}
|
|
151
154
|
async compileImpl() {
|
|
152
155
|
const pathToCompile = `${this.config.fullPath}/src/main`;
|
|
@@ -228,6 +231,8 @@ export class Unit_TypescriptLib extends Unit_PackageJson {
|
|
|
228
231
|
.execute();
|
|
229
232
|
}
|
|
230
233
|
async compile() {
|
|
234
|
+
if (!this.dependencyUnits)
|
|
235
|
+
await this.prepare();
|
|
231
236
|
await this.clearOutputDirImpl();
|
|
232
237
|
await this.compileImpl();
|
|
233
238
|
await this.copyAssetsToOutput();
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { CONST_FirebaseJSON, CONST_FirebaseRC, CONST_NodeModules, CONST_PackageJSON } from '../../../core/consts.js';
|
|
2
|
-
import {
|
|
3
|
-
import { __stringify, _logger_logPrefixes, deepClone, ImplementationMissingException, LogLevel, reduceObject, Second, sleep } from '@nu-art/ts-common';
|
|
1
|
+
import { CONST_FirebaseJSON, CONST_FirebaseRC, CONST_NodeModules, CONST_PackageJSON, CONST_VersionApp } from '../../../core/consts.js';
|
|
2
|
+
import { __stringify, _keys, _logger_logPrefixes, deepClone, ImplementationMissingException, LogLevel, Second, sleep } from '@nu-art/ts-common';
|
|
4
3
|
import { Const_FirebaseConfigKeys, Const_FirebaseDefaultsKeyToFile } from '../../../defaults/consts.js';
|
|
5
4
|
import { Commando_NVM } from '@nu-art/commando/shell/plugins/nvm';
|
|
6
5
|
import { resolve } from 'path';
|
|
@@ -48,11 +47,20 @@ export class Unit_FirebaseFunctionsApp extends Unit_TypescriptLib {
|
|
|
48
47
|
const distDependencies = this.deriveDistDependencies();
|
|
49
48
|
packageJson.main = 'index.js';
|
|
50
49
|
packageJson.types = 'index.d.ts';
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
50
|
+
const dependencies = packageJson.dependencies ?? {};
|
|
51
|
+
// First, update existing dependencies (replace workspace:* with file: paths where applicable)
|
|
52
|
+
_keys(dependencies).reduce((dependencies, packageName) => {
|
|
53
|
+
if (distDependencies[packageName])
|
|
54
|
+
dependencies[packageName] = distDependencies[packageName];
|
|
55
|
+
return dependencies;
|
|
56
|
+
}, dependencies);
|
|
57
|
+
// Then, add ALL dependencyUnits to the dependencies (this includes transitive dependencies)
|
|
58
|
+
// This ensures the entire dependency tree is referenced in the main package.json
|
|
59
|
+
this.dependencyUnits.reduce((dependencies, unit) => {
|
|
60
|
+
dependencies[unit.config.key] = distDependencies[unit.config.key];
|
|
61
|
+
return dependencies;
|
|
62
|
+
}, dependencies);
|
|
63
|
+
packageJson.dependencies = dependencies;
|
|
56
64
|
await FileSystemUtils.file.template.write(targetPath, __stringify(packageJson, true), this.deriveDistDependencies(), DEFAULT_OLD_TEMPLATE_PATTERN);
|
|
57
65
|
}
|
|
58
66
|
async prepare() {
|
|
@@ -101,8 +109,9 @@ export class Unit_FirebaseFunctionsApp extends Unit_TypescriptLib {
|
|
|
101
109
|
});
|
|
102
110
|
const debug = this.runtimeContext.runtimeParams.verbose ? ' --debug' : '';
|
|
103
111
|
await this.executeAsyncCommando(commando, `firebase${debug} deploy --only functions --force`, (stdout, stderr, exitCode) => {
|
|
104
|
-
if (exitCode
|
|
105
|
-
|
|
112
|
+
if (exitCode === 0)
|
|
113
|
+
return;
|
|
114
|
+
throw new CommandoException(`Failed to deploy function with exit code ${exitCode}`, stdout, stderr, exitCode);
|
|
106
115
|
});
|
|
107
116
|
this.logInfo(`Functions: `, this.functions);
|
|
108
117
|
}
|
|
@@ -127,8 +136,8 @@ export class Unit_FirebaseFunctionsApp extends Unit_TypescriptLib {
|
|
|
127
136
|
}
|
|
128
137
|
}
|
|
129
138
|
};
|
|
130
|
-
const targetPath =
|
|
131
|
-
await
|
|
139
|
+
const targetPath = resolve(this.config.fullPath, CONST_FirebaseRC);
|
|
140
|
+
await FileSystemUtils.file.write.json(targetPath, rcConfig);
|
|
132
141
|
}
|
|
133
142
|
async resolveProxyFile() {
|
|
134
143
|
const envConfig = this.getEnvConfig();
|
|
@@ -220,7 +229,7 @@ export class Unit_FirebaseFunctionsApp extends Unit_TypescriptLib {
|
|
|
220
229
|
}
|
|
221
230
|
};
|
|
222
231
|
}
|
|
223
|
-
await
|
|
232
|
+
await FileSystemUtils.file.write.json(targetPath, fileContent);
|
|
224
233
|
}
|
|
225
234
|
async resolveFunctionsRuntimeConfig() {
|
|
226
235
|
const envConfig = this.getEnvConfig();
|
|
@@ -233,30 +242,25 @@ export class Unit_FirebaseFunctionsApp extends Unit_TypescriptLib {
|
|
|
233
242
|
};
|
|
234
243
|
const inLocalIgnoreTLS = `${envConfig.isLocal ? '// @ts-ignore\nprocess.env[\'NODE_TLS_REJECT_UNAUTHORIZED\'] = 0;\n\n' : ''}`;
|
|
235
244
|
const fileContent = `${inLocalIgnoreTLS}export const Environment = ${JSON.stringify(beConfig)};`;
|
|
236
|
-
await
|
|
245
|
+
await FileSystemUtils.file.write(targetPath, fileContent);
|
|
237
246
|
}
|
|
238
247
|
//######################### Compile Logic #########################
|
|
239
248
|
async createAppVersionFile() {
|
|
240
249
|
//Writing the file to the package source instead of the output is fine,
|
|
241
250
|
//copyAssetsToOutput will move the file to output
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
// await _fs.writeFile(targetPath, fileContent, {encoding: 'utf-8'});
|
|
251
|
+
const targetPath = `${this.config.fullPath}/src/main/${CONST_VersionApp}`;
|
|
252
|
+
const appVersion = this.runtimeContext.version;
|
|
253
|
+
await FileSystemUtils.file.write.json(targetPath, { version: appVersion });
|
|
246
254
|
}
|
|
247
255
|
deriveDistDependencies() {
|
|
248
|
-
|
|
249
|
-
const dependencyUnits = this.runtimeContext.unitsResolver(unitKeys, Unit_TypescriptLib);
|
|
250
|
-
return dependencyUnits.reduce((dependencies, unit) => {
|
|
256
|
+
return this.dependencyUnits.reduce((dependencies, unit) => {
|
|
251
257
|
dependencies[unit.config.key] = `file:.dependencies/${unit.config.key}`;
|
|
252
258
|
return dependencies;
|
|
253
259
|
}, super.deriveDistDependencies());
|
|
254
260
|
}
|
|
255
261
|
async createDependenciesDir() {
|
|
256
262
|
//Gather units that are dependencies of this unit
|
|
257
|
-
|
|
258
|
-
const dependencyUnits = this.runtimeContext.unitsResolver(unitKeys, Unit_TypescriptLib);
|
|
259
|
-
await Promise.all(dependencyUnits.map(async (unit) => {
|
|
263
|
+
await Promise.all(this.dependencyUnits.map(async (unit) => {
|
|
260
264
|
//Copy dependency unit output into this units output/.dependency dir
|
|
261
265
|
const dependencyOutputPath = `${unit.config.output}/`;
|
|
262
266
|
const targetPath = `${this.config.output}/.dependencies/${unit.config.key}/`;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { ImplementationMissingException, LogLevel } from '@nu-art/ts-common';
|
|
2
|
-
import {
|
|
3
|
-
import { CONST_FirebaseJSON, CONST_FirebaseRC } from '../../../core/consts.js';
|
|
2
|
+
import { CONST_FirebaseJSON, CONST_FirebaseRC, CONST_VersionApp } from '../../../core/consts.js';
|
|
4
3
|
import { Commando_NVM } from '@nu-art/commando/shell/plugins/nvm';
|
|
5
4
|
import { Commando_Basic } from '@nu-art/commando/shell/plugins/basic';
|
|
6
5
|
import { resolve } from 'path';
|
|
7
6
|
import { Unit_TypescriptLib } from '../Unit_TypescriptLib.js';
|
|
8
7
|
import { CommandoException } from '@nu-art/commando/shell/core/CliError';
|
|
9
8
|
import { deployLogFilter } from './common.js';
|
|
10
|
-
|
|
9
|
+
import { FileSystemUtils } from '@nu-art/ts-common/utils/FileSystemUtils';
|
|
11
10
|
export class Unit_FirebaseHostingApp extends Unit_TypescriptLib {
|
|
12
11
|
hosting = {};
|
|
13
12
|
static DefaultConfig_FirebaseHosting = {
|
|
@@ -61,7 +60,7 @@ export class Unit_FirebaseHostingApp extends Unit_TypescriptLib {
|
|
|
61
60
|
const envConfig = this.getEnvConfig();
|
|
62
61
|
const rcConfig = { projects: { default: envConfig.projectId } };
|
|
63
62
|
const targetPath = `${this.config.fullPath}/${CONST_FirebaseRC}`;
|
|
64
|
-
await
|
|
63
|
+
await FileSystemUtils.file.write.json(targetPath, rcConfig);
|
|
65
64
|
}
|
|
66
65
|
async resolveHostingJSON() {
|
|
67
66
|
const envConfig = this.getEnvConfig();
|
|
@@ -70,14 +69,21 @@ export class Unit_FirebaseHostingApp extends Unit_TypescriptLib {
|
|
|
70
69
|
if (envConfig.isLocal)
|
|
71
70
|
fileContent = {};
|
|
72
71
|
else
|
|
73
|
-
fileContent = {
|
|
74
|
-
|
|
72
|
+
fileContent = {
|
|
73
|
+
hosting: this.config.hostingConfig ?? {
|
|
74
|
+
'public': 'dist',
|
|
75
|
+
'rewrites': [
|
|
76
|
+
{ 'source': '**', 'destination': '/index.html' }
|
|
77
|
+
]
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
await FileSystemUtils.file.write.json(targetPath, fileContent);
|
|
75
81
|
}
|
|
76
82
|
async resolveHostingRuntimeConfig() {
|
|
77
83
|
const envConfig = this.getEnvConfig().config;
|
|
78
84
|
const targetPath = resolve(this.config.fullPath, `./src/main/config.ts`);
|
|
79
85
|
const fileContent = `export const config = ${JSON.stringify(envConfig, null, 2)};`;
|
|
80
|
-
await
|
|
86
|
+
await FileSystemUtils.file.write(targetPath, fileContent);
|
|
81
87
|
}
|
|
82
88
|
//######################### Compile Logic #########################
|
|
83
89
|
async compileImpl() {
|
|
@@ -93,8 +99,7 @@ export class Unit_FirebaseHostingApp extends Unit_TypescriptLib {
|
|
|
93
99
|
//Webpack bundles files into the output automatically!
|
|
94
100
|
const targetPath = `${this.config.fullPath}/src/main/${CONST_VersionApp}`;
|
|
95
101
|
const appVersion = this.runtimeContext.version;
|
|
96
|
-
|
|
97
|
-
await _fs.writeFile(targetPath, fileContent, { encoding: 'utf-8' });
|
|
102
|
+
await FileSystemUtils.file.write.json(targetPath, { version: appVersion });
|
|
98
103
|
}
|
|
99
104
|
//######################### Launch Logic #########################
|
|
100
105
|
async runApp() {
|