@nu-art/build-and-install 0.400.12 → 0.400.14
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 +8 -2
- package/core/params/params.d.ts +2 -1
- package/core/params/params.js +18 -4
- package/package.json +3 -3
- package/v3/UnitsMapper/resolvers/UnitMapper_FirebaseFunction.d.ts +2 -0
- package/v3/UnitsMapper/resolvers/UnitMapper_FirebaseFunction.js +15 -4
- package/v3/UnitsMapper/resolvers/UnitMapper_FirebaseHosting.js +8 -4
- package/v3/UnitsMapper/resolvers/UnitMapper_Node.js +1 -1
- package/v3/core/Unit_HelpPrinter.d.ts +1 -1
- package/v3/units/firebase/Unit_FirebaseFunctionsApp.d.ts +1 -1
- package/v3/units/firebase/Unit_FirebaseFunctionsApp.js +19 -12
- package/v3/units/firebase/Unit_FirebaseHostingApp.d.ts +0 -1
- package/v3/units/firebase/Unit_FirebaseHostingApp.js +7 -9
package/build-and-install-v3.js
CHANGED
|
@@ -117,8 +117,14 @@ export class BuildAndInstall extends Logger {
|
|
|
117
117
|
}
|
|
118
118
|
async run() {
|
|
119
119
|
const keyToUnitMap = arrayToMap(this.projectUnits, u => u.config.key);
|
|
120
|
-
|
|
121
|
-
|
|
120
|
+
let topLevelAppKeys = this.projectUnits.filter(unit => unit.config.isTopLevelApp).map(unit => unit.config.key);
|
|
121
|
+
this.logWarning('this.runtimeParams.includeApps', this.runtimeParams.includeApps);
|
|
122
|
+
if (this.runtimeParams.includeApps?.length) {
|
|
123
|
+
this.logWarning('HEREHREHREHRHERHER');
|
|
124
|
+
const regexMatchers = this.runtimeParams.includeApps.map(filter => new RegExp(`.*?${filter}.*?`, 'i'));
|
|
125
|
+
topLevelAppKeys = topLevelAppKeys.filter(unitKey => regexMatchers.some(matcher => matcher.test(unitKey)));
|
|
126
|
+
}
|
|
127
|
+
this.logDebug('topLevelAppKeys: ', topLevelAppKeys);
|
|
122
128
|
const participatingUnitKeys = this.runtimeParams.allUnits
|
|
123
129
|
? undefined
|
|
124
130
|
: [...this.unitsDependencyMapper.getTransitiveDependencies(topLevelAppKeys), ...topLevelAppKeys];
|
package/core/params/params.d.ts
CHANGED
|
@@ -32,9 +32,10 @@ type PromoteType = 'patch' | 'minor' | 'major';
|
|
|
32
32
|
export declare const BaiParam_Publish: BaseCliParam<'publish', PromoteType>;
|
|
33
33
|
export declare const BaiParam_UsePackage: BaseCliParam<'usePackage', string[]>;
|
|
34
34
|
export declare const BaiParam_includePackage: BaseCliParam<'includePackage', string[]>;
|
|
35
|
+
export declare const BaiParam_Apps: BaseCliParam<'includeApps', string[]>;
|
|
35
36
|
export declare const BaiParam_ToESM: BaseCliParam<'toESM', boolean>;
|
|
36
37
|
export declare const BaiParam_Simulate: BaseCliParam<'simulation', boolean>;
|
|
37
38
|
export declare const BaiParam_CheckCyclicImports: BaseCliParam<'checkCyclicImports', boolean>;
|
|
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
|
+
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<"includeApps", string[]> | BaseCliParam<"toESM", boolean> | BaseCliParam<"simulation", boolean> | BaseCliParam<"checkCyclicImports", boolean>)[];
|
|
39
40
|
export type BaiParams = CliParams<typeof AllBaiParams>;
|
|
40
41
|
export {};
|
package/core/params/params.js
CHANGED
|
@@ -91,7 +91,7 @@ export const BaiParam_Watch = {
|
|
|
91
91
|
type: 'boolean',
|
|
92
92
|
group: 'Build',
|
|
93
93
|
description: 'will build and listen for changes in the libraries',
|
|
94
|
-
dependencies: [{ param: BaiParam_NoBuild, value: true }, { param:
|
|
94
|
+
dependencies: [{ param: BaiParam_NoBuild, value: true }, { param: BaiParam_AllUnits, value: true }]
|
|
95
95
|
};
|
|
96
96
|
export const BaiParam_WatchBuildTree = {
|
|
97
97
|
keys: ['--watchBuildTree', '-wbt'],
|
|
@@ -230,7 +230,7 @@ export const BaiParam_UsePackage = {
|
|
|
230
230
|
keys: ['-up', '--use-packages'],
|
|
231
231
|
keyName: 'usePackage',
|
|
232
232
|
type: 'string[]',
|
|
233
|
-
group: '
|
|
233
|
+
group: 'Build',
|
|
234
234
|
description: 'Will specify units to process',
|
|
235
235
|
process: (value) => {
|
|
236
236
|
if (!value)
|
|
@@ -240,10 +240,10 @@ export const BaiParam_UsePackage = {
|
|
|
240
240
|
dependencies: [{ param: BaiParam_AllUnits, value: true }]
|
|
241
241
|
};
|
|
242
242
|
export const BaiParam_includePackage = {
|
|
243
|
-
keys: ['-in', '--include
|
|
243
|
+
keys: ['-in', '--include'],
|
|
244
244
|
keyName: 'includePackage',
|
|
245
245
|
type: 'string[]',
|
|
246
|
-
group: '
|
|
246
|
+
group: 'Build',
|
|
247
247
|
description: 'Will include the units to process',
|
|
248
248
|
process: (value) => {
|
|
249
249
|
if (!value)
|
|
@@ -252,6 +252,19 @@ export const BaiParam_includePackage = {
|
|
|
252
252
|
},
|
|
253
253
|
dependencies: []
|
|
254
254
|
};
|
|
255
|
+
export const BaiParam_Apps = {
|
|
256
|
+
keys: ['-app', '--application'],
|
|
257
|
+
keyName: 'includeApps',
|
|
258
|
+
type: 'string[]',
|
|
259
|
+
group: 'Build',
|
|
260
|
+
description: 'Will include the applications and all their dependency units to the build process',
|
|
261
|
+
process: (value) => {
|
|
262
|
+
if (!value)
|
|
263
|
+
return [];
|
|
264
|
+
return value.split(',').map(str => str.trim());
|
|
265
|
+
},
|
|
266
|
+
dependencies: []
|
|
267
|
+
};
|
|
255
268
|
export const BaiParam_ToESM = {
|
|
256
269
|
keys: ['-tesm', '--to-esm'],
|
|
257
270
|
keyName: 'toESM',
|
|
@@ -297,6 +310,7 @@ export const AllBaiParams = [
|
|
|
297
310
|
BaiParam_Generate, // TODO: to implement
|
|
298
311
|
BaiParam_GenerateDocs, // TODO: to implement
|
|
299
312
|
BaiParam_NoBuild,
|
|
313
|
+
BaiParam_Apps,
|
|
300
314
|
BaiParam_DryRun,
|
|
301
315
|
BaiParam_Lint,
|
|
302
316
|
BaiParam_Watch,
|
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.14",
|
|
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.14",
|
|
35
|
+
"@nu-art/commando": "0.400.14"
|
|
36
36
|
},
|
|
37
37
|
"unitConfig": {
|
|
38
38
|
"type": "typescript-lib"
|
|
@@ -4,6 +4,7 @@ import { Unit_FirebaseFunctionsApp } from '../../units/firebase/Unit_FirebaseFun
|
|
|
4
4
|
type EnvConfig = {
|
|
5
5
|
defaultConfig?: string;
|
|
6
6
|
envConfig?: string;
|
|
7
|
+
identityAccount?: string;
|
|
7
8
|
projectId: string;
|
|
8
9
|
isLocal?: boolean;
|
|
9
10
|
};
|
|
@@ -32,6 +33,7 @@ export declare class UnitMapper_FirebaseFunction_Class extends UnitMapper_Node<U
|
|
|
32
33
|
constructor();
|
|
33
34
|
protected resolveNodeUnit(context: UnitMapper_NodeContext<UnitConfigJSON_FirebaseFunction>): Promise<Unit_FirebaseFunctionsApp<{
|
|
34
35
|
envConfig: {
|
|
36
|
+
identityAccount: string | undefined;
|
|
35
37
|
defaultConfig: string | undefined;
|
|
36
38
|
envConfig: string | undefined;
|
|
37
39
|
projectId: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { tsValidate_OptionalArray, tsValidateAnyString, tsValidateBoolean, tsValidateDynamicObject, tsValidateOptionalAnyNumber, tsValidateOptionalAnyString, tsValidateValue } from '@nu-art/ts-common';
|
|
2
2
|
import { UnitMapper_Node } from './UnitMapper_Node.js';
|
|
3
3
|
import { Unit_FirebaseFunctionsApp } from '../../units/firebase/Unit_FirebaseFunctionsApp.js';
|
|
4
4
|
import { resolve } from 'path';
|
|
@@ -6,6 +6,7 @@ import { BaiParam_SetEnv } from '../../../core/params/params.js';
|
|
|
6
6
|
const valuesValidator = {
|
|
7
7
|
defaultConfig: tsValidateOptionalAnyString,
|
|
8
8
|
envConfig: tsValidateOptionalAnyString,
|
|
9
|
+
identityAccount: tsValidateOptionalAnyString,
|
|
9
10
|
projectId: tsValidateAnyString,
|
|
10
11
|
isLocal: tsValidateBoolean(false),
|
|
11
12
|
};
|
|
@@ -26,10 +27,20 @@ export class UnitMapper_FirebaseFunction_Class extends UnitMapper_Node {
|
|
|
26
27
|
async resolveNodeUnit(context) {
|
|
27
28
|
const outputDir = context.packageJson.publishConfig?.directory;
|
|
28
29
|
const env = this.runtimeParams[BaiParam_SetEnv.keyName];
|
|
29
|
-
|
|
30
|
-
if (!envUnitConfig)
|
|
31
|
-
|
|
30
|
+
let envUnitConfig = context.packageJson.unitConfig.envs[env];
|
|
31
|
+
if (!envUnitConfig) {
|
|
32
|
+
this.logWarning(`Missing EnvConfig in unit ${context.baseConfig.key}`);
|
|
33
|
+
envUnitConfig = {
|
|
34
|
+
identityAccount: '',
|
|
35
|
+
defaultConfig: '',
|
|
36
|
+
envConfig: '',
|
|
37
|
+
projectId: '',
|
|
38
|
+
isLocal: true
|
|
39
|
+
};
|
|
40
|
+
// throw new ImplementationMissingException(`Missing configuration for env: ${env}`);
|
|
41
|
+
}
|
|
32
42
|
const envConfig = {
|
|
43
|
+
identityAccount: envUnitConfig.identityAccount,
|
|
33
44
|
defaultConfig: envUnitConfig.defaultConfig,
|
|
34
45
|
envConfig: envUnitConfig.envConfig,
|
|
35
46
|
projectId: envUnitConfig.projectId,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { tsValidateAnyString, tsValidateBoolean, tsValidateDynamicObject, tsValidateMustExist, tsValidateOptional, tsValidateOptionalAnyNumber, tsValidateValue } from '@nu-art/ts-common';
|
|
2
2
|
import { UnitMapper_Node } from './UnitMapper_Node.js';
|
|
3
3
|
import { Unit_FirebaseHostingApp } from '../../units/firebase/Unit_FirebaseHostingApp.js';
|
|
4
4
|
import { resolve } from 'path';
|
|
@@ -22,10 +22,14 @@ export class UnitMapper_FirebaseHosting_Class extends UnitMapper_Node {
|
|
|
22
22
|
async resolveNodeUnit(context) {
|
|
23
23
|
const outputDir = context.packageJson.publishConfig?.directory;
|
|
24
24
|
const env = this.runtimeParams[BaiParam_SetEnv.keyName];
|
|
25
|
-
|
|
25
|
+
let envUnitConfig = context.packageJson.unitConfig.envs[env];
|
|
26
26
|
if (!envUnitConfig) {
|
|
27
|
-
this.logWarning(
|
|
28
|
-
|
|
27
|
+
this.logWarning(`Missing EnvConfig in unit ${context.baseConfig.key}`);
|
|
28
|
+
envUnitConfig = {
|
|
29
|
+
config: {},
|
|
30
|
+
projectId: '',
|
|
31
|
+
isLocal: true
|
|
32
|
+
};
|
|
29
33
|
}
|
|
30
34
|
const envConfig = {
|
|
31
35
|
config: envUnitConfig.config,
|
|
@@ -32,7 +32,7 @@ export class UnitMapper_Node extends UnitMapper_Base {
|
|
|
32
32
|
if (tsValidateResult(packageJson.unitConfig.type, this.validator.type))
|
|
33
33
|
return; // not the expected type for this mapper
|
|
34
34
|
packageJson = deepClone(packageJson);
|
|
35
|
-
tsValidate(packageJson.unitConfig, this.validator);
|
|
35
|
+
tsValidate(packageJson.unitConfig, this.validator, false);
|
|
36
36
|
const dependencies = packageJson.dependencies;
|
|
37
37
|
if (dependencies)
|
|
38
38
|
packageJson.dependencies = _keys(dependencies).reduce((acc, key) => {
|
|
@@ -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<"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>)[];
|
|
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<"includeApps", 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";
|
|
@@ -10,6 +10,7 @@ type EnvConfig = {
|
|
|
10
10
|
envConfig?: string;
|
|
11
11
|
projectId: string;
|
|
12
12
|
isLocal?: boolean;
|
|
13
|
+
identityAccount?: string;
|
|
13
14
|
};
|
|
14
15
|
export type Unit_FirebaseFunctionsApp_Config = Unit_TypescriptLib_Config & {
|
|
15
16
|
firebaseConfig?: FirebasePackageConfig;
|
|
@@ -48,7 +49,6 @@ export declare class Unit_FirebaseFunctionsApp<C extends Unit_FirebaseFunctionsA
|
|
|
48
49
|
launch(): Promise<void>;
|
|
49
50
|
releaseEmulatorPorts(): Promise<void>;
|
|
50
51
|
deploy(): Promise<void>;
|
|
51
|
-
private getEnvConfig;
|
|
52
52
|
private resolveFunctionsRC;
|
|
53
53
|
private resolveProxyFile;
|
|
54
54
|
private pathToProxy;
|
|
@@ -64,6 +64,10 @@ export class Unit_FirebaseFunctionsApp extends Unit_TypescriptLib {
|
|
|
64
64
|
await FileSystemUtils.file.template.write(targetPath, __stringify(packageJson, true), this.deriveDistDependencies(), DEFAULT_OLD_TEMPLATE_PATTERN);
|
|
65
65
|
}
|
|
66
66
|
async prepare() {
|
|
67
|
+
if (!this.config.envConfig.projectId.length) {
|
|
68
|
+
this.logWarning('envConfig: ', this.config.envConfig);
|
|
69
|
+
throw new ImplementationMissingException(`Missing EnvConfig in unit ${this.config.key}`);
|
|
70
|
+
}
|
|
67
71
|
await super.prepare();
|
|
68
72
|
await FileSystemUtils.folder.list.forEach.folder(this.config.fullPath, async (path) => {
|
|
69
73
|
if (path.replace(`${this.config.fullPath}/`, '').startsWith('firebase-export-'))
|
|
@@ -119,14 +123,8 @@ export class Unit_FirebaseFunctionsApp extends Unit_TypescriptLib {
|
|
|
119
123
|
this.logInfo(`Functions: `, this.functions);
|
|
120
124
|
}
|
|
121
125
|
//######################### ResolveConfig Logic #########################
|
|
122
|
-
getEnvConfig() {
|
|
123
|
-
const envConfig = this.config.envConfig;
|
|
124
|
-
if (!envConfig)
|
|
125
|
-
throw new ImplementationMissingException(`Missing EnvConfig in unit ${this.config.key}`);
|
|
126
|
-
return envConfig;
|
|
127
|
-
}
|
|
128
126
|
async resolveFunctionsRC() {
|
|
129
|
-
const envConfig = this.
|
|
127
|
+
const envConfig = this.config.envConfig;
|
|
130
128
|
const rcConfig = {
|
|
131
129
|
projects: {
|
|
132
130
|
default: envConfig.projectId
|
|
@@ -143,7 +141,7 @@ export class Unit_FirebaseFunctionsApp extends Unit_TypescriptLib {
|
|
|
143
141
|
await FileSystemUtils.file.write.json(targetPath, rcConfig);
|
|
144
142
|
}
|
|
145
143
|
async resolveProxyFile() {
|
|
146
|
-
const envConfig = this.
|
|
144
|
+
const envConfig = this.config.envConfig;
|
|
147
145
|
const targetPath = this.pathToProxy();
|
|
148
146
|
const path = this.runtimeContext.baiConfig.files?.backend?.proxy;
|
|
149
147
|
if (!path)
|
|
@@ -179,7 +177,7 @@ export class Unit_FirebaseFunctionsApp extends Unit_TypescriptLib {
|
|
|
179
177
|
}));
|
|
180
178
|
}
|
|
181
179
|
async resolveFunctionsJSON() {
|
|
182
|
-
const envConfig = this.
|
|
180
|
+
const envConfig = this.config.envConfig;
|
|
183
181
|
const targetPath = `${this.config.fullPath}/${CONST_FirebaseJSON}`;
|
|
184
182
|
let fileContent;
|
|
185
183
|
if (envConfig.isLocal) {
|
|
@@ -235,7 +233,7 @@ export class Unit_FirebaseFunctionsApp extends Unit_TypescriptLib {
|
|
|
235
233
|
await FileSystemUtils.file.write.json(targetPath, fileContent);
|
|
236
234
|
}
|
|
237
235
|
async resolveFunctionsRuntimeConfig() {
|
|
238
|
-
const envConfig = this.
|
|
236
|
+
const envConfig = this.config.envConfig;
|
|
239
237
|
const targetPath = `${this.config.fullPath}/src/main/config.ts`;
|
|
240
238
|
const envKey = this.runtimeContext.runtimeParams.environment;
|
|
241
239
|
const beConfig = {
|
|
@@ -282,10 +280,19 @@ export class Unit_FirebaseFunctionsApp extends Unit_TypescriptLib {
|
|
|
282
280
|
this.logWarning('PROXY TERMINATED');
|
|
283
281
|
}
|
|
284
282
|
async runEmulator() {
|
|
283
|
+
let exportGoogleCredentials;
|
|
284
|
+
if (this.config.envConfig.identityAccount) {
|
|
285
|
+
const pathToIdentityAccount = resolve(this.config.fullPath, this.config.envConfig.identityAccount);
|
|
286
|
+
if (!FileSystemUtils.file.exists(pathToIdentityAccount))
|
|
287
|
+
throw new ImplementationMissingException(`Missing identity file at: ${pathToIdentityAccount}`);
|
|
288
|
+
exportGoogleCredentials = `export GOOGLE_APPLICATION_CREDENTIALS="${pathToIdentityAccount}"`;
|
|
289
|
+
}
|
|
285
290
|
const commando = this.allocateCommando(Commando_NVM).applyNVM()
|
|
286
291
|
.setUID(this.config.key)
|
|
287
|
-
.cd(this.config.fullPath)
|
|
288
|
-
|
|
292
|
+
.cd(this.config.fullPath);
|
|
293
|
+
if (exportGoogleCredentials)
|
|
294
|
+
commando.append(exportGoogleCredentials);
|
|
295
|
+
commando.setLogLevelFilter((log, type) => {
|
|
289
296
|
if (this.emulatorLogStrings.error.some(errStr => log.includes(errStr)))
|
|
290
297
|
return LogLevel.Error;
|
|
291
298
|
if (this.emulatorLogStrings.warning.some(warnStr => log.includes(warnStr)))
|
|
@@ -40,7 +40,6 @@ export declare class Unit_FirebaseHostingApp<C extends Unit_FirebaseHostingApp_C
|
|
|
40
40
|
launch(): Promise<void>;
|
|
41
41
|
releaseWebpackPorts(): Promise<void>;
|
|
42
42
|
deploy(): Promise<void>;
|
|
43
|
-
private getEnvConfig;
|
|
44
43
|
private resolveHostingRC;
|
|
45
44
|
private resolveHostingJSON;
|
|
46
45
|
private resolveHostingRuntimeConfig;
|
|
@@ -19,6 +19,10 @@ export class Unit_FirebaseHostingApp extends Unit_TypescriptLib {
|
|
|
19
19
|
}
|
|
20
20
|
//######################### Phase Implementations #########################
|
|
21
21
|
async prepare() {
|
|
22
|
+
if (!this.config.envConfig.projectId.length) {
|
|
23
|
+
this.logWarning('envConfig: ', this.config.envConfig);
|
|
24
|
+
throw new ImplementationMissingException(`Missing EnvConfig in unit ${this.config.key}`);
|
|
25
|
+
}
|
|
22
26
|
await super.prepare();
|
|
23
27
|
await this.resolveHostingRC();
|
|
24
28
|
await this.resolveHostingJSON();
|
|
@@ -50,20 +54,14 @@ export class Unit_FirebaseHostingApp extends Unit_TypescriptLib {
|
|
|
50
54
|
await this.executeAsyncCommando(commando, `${this.npmCommand('firebase')}${debug} deploy --only hosting`);
|
|
51
55
|
}
|
|
52
56
|
//######################### ResolveConfig Logic #########################
|
|
53
|
-
getEnvConfig() {
|
|
54
|
-
const envConfig = this.config.envConfig;
|
|
55
|
-
if (!envConfig)
|
|
56
|
-
throw new ImplementationMissingException(`Missing EnvConfig in unit ${this.config.label}`);
|
|
57
|
-
return envConfig;
|
|
58
|
-
}
|
|
59
57
|
async resolveHostingRC() {
|
|
60
|
-
const envConfig = this.
|
|
58
|
+
const envConfig = this.config.envConfig;
|
|
61
59
|
const rcConfig = { projects: { default: envConfig.projectId } };
|
|
62
60
|
const targetPath = `${this.config.fullPath}/${CONST_FirebaseRC}`;
|
|
63
61
|
await FileSystemUtils.file.write.json(targetPath, rcConfig);
|
|
64
62
|
}
|
|
65
63
|
async resolveHostingJSON() {
|
|
66
|
-
const envConfig = this.
|
|
64
|
+
const envConfig = this.config.envConfig;
|
|
67
65
|
const targetPath = `${this.config.fullPath}/${CONST_FirebaseJSON}`;
|
|
68
66
|
let fileContent;
|
|
69
67
|
if (envConfig.isLocal)
|
|
@@ -80,7 +78,7 @@ export class Unit_FirebaseHostingApp extends Unit_TypescriptLib {
|
|
|
80
78
|
await FileSystemUtils.file.write.json(targetPath, fileContent);
|
|
81
79
|
}
|
|
82
80
|
async resolveHostingRuntimeConfig() {
|
|
83
|
-
const envConfig = this.
|
|
81
|
+
const envConfig = this.config.envConfig.config;
|
|
84
82
|
const targetPath = resolve(this.config.fullPath, `./src/main/config.ts`);
|
|
85
83
|
const fileContent = `export const config = ${JSON.stringify(envConfig, null, 2)};`;
|
|
86
84
|
await FileSystemUtils.file.write(targetPath, fileContent);
|