@nu-art/build-and-install 0.401.0 → 0.401.1
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/BuildAndInstall.d.ts +40 -0
- package/BuildAndInstall.js +155 -0
- package/build-and-install-v3.d.ts +1 -44
- package/build-and-install-v3.js +1 -157
- package/build-and-install.js +11 -11
- package/config/consts.d.ts +43 -0
- package/config/consts.js +42 -0
- package/{core → config}/package/consts.d.ts +1 -1
- package/{core → config}/types/project-config.d.ts +3 -0
- package/core/FilesCache.d.ts +50 -0
- package/core/FilesCache.js +76 -0
- package/core/Unit_HelpPrinter.d.ts +16 -0
- package/core/Unit_HelpPrinter.js +47 -0
- package/core/params/params.d.ts +1 -41
- package/core/params/params.js +1 -332
- package/core/params.d.ts +50 -0
- package/core/params.js +441 -0
- package/{v3/core → core}/types.d.ts +1 -1
- package/{v3/UnitsDependencyMapper → dependencies}/UnitsDependencyMapper.d.ts +21 -1
- package/{v3/UnitsDependencyMapper → dependencies}/UnitsDependencyMapper.js +26 -3
- package/dependencies/types.d.ts +1 -0
- package/dependencies/types.js +1 -0
- package/exceptions/PhaseAggregatedException.d.ts +34 -0
- package/{core/exceptions → exceptions}/PhaseAggregatedException.js +26 -0
- package/exceptions/UnitPhaseException.d.ts +20 -0
- package/exceptions/UnitPhaseException.js +21 -0
- package/exports/ExportIndexCache.d.ts +25 -0
- package/exports/ExportIndexCache.js +115 -0
- package/exports/ExportMapper.d.ts +43 -0
- package/exports/ExportMapper.js +519 -0
- package/exports/IndicesMcpServer.d.ts +22 -0
- package/exports/IndicesMcpServer.js +220 -0
- package/exports/types.js +3 -0
- package/package.json +20 -9
- package/phases/PhaseManager.d.ts +130 -0
- package/{v3 → phases}/PhaseManager.js +99 -2
- package/{v3/phase → phases/definitions}/consts.d.ts +36 -0
- package/{v3/phase → phases/definitions}/consts.js +44 -2
- package/phases/definitions/types.d.ts +40 -0
- package/phases/index.d.ts +2 -0
- package/phases/index.js +2 -0
- package/run.js +10 -0
- package/runtime/RunningStatusHandler.d.ts +104 -0
- package/runtime/RunningStatusHandler.js +153 -0
- package/runtime/types.d.ts +1 -0
- package/runtime/types.js +2 -0
- package/{defaults → templates}/consts.d.ts +9 -0
- package/{defaults → templates}/consts.js +12 -2
- package/templates/firebase/functions/cloudbuild.yaml +17 -0
- package/templates/firebase/functions/dockerfile +19 -0
- package/templates/firebase/functions/service.yaml +49 -0
- package/{v3/units → units/base}/BaseUnit.d.ts +34 -4
- package/{v3/units → units/base}/BaseUnit.js +22 -2
- package/units/base/ProjectUnit.d.ts +32 -0
- package/units/base/ProjectUnit.js +25 -0
- package/units/base/types.js +1 -0
- package/units/discovery/UnitsMapper.d.ts +69 -0
- package/{v3/UnitsMapper → units/discovery}/UnitsMapper.js +50 -2
- package/units/discovery/resolvers/UnitMapper_Base.d.ts +65 -0
- package/units/discovery/resolvers/UnitMapper_Base.js +46 -0
- package/{v3/UnitsMapper → units/discovery}/resolvers/UnitMapper_FirebaseFunction.d.ts +5 -3
- package/units/discovery/resolvers/UnitMapper_FirebaseFunction.js +105 -0
- package/{v3/UnitsMapper → units/discovery}/resolvers/UnitMapper_FirebaseHosting.d.ts +3 -2
- package/{v3/UnitsMapper → units/discovery}/resolvers/UnitMapper_FirebaseHosting.js +14 -10
- package/{v3/UnitsMapper → units/discovery}/resolvers/UnitMapper_Node.d.ts +1 -1
- package/{v3/UnitsMapper → units/discovery}/resolvers/UnitMapper_Node.js +2 -2
- package/{v3/UnitsMapper → units/discovery}/resolvers/UnitMapper_NodeLib.d.ts +24 -1
- package/{v3/UnitsMapper → units/discovery}/resolvers/UnitMapper_NodeLib.js +24 -1
- package/{v3/UnitsMapper → units/discovery}/resolvers/UnitMapper_NodeProject.d.ts +22 -1
- package/{v3/UnitsMapper → units/discovery}/resolvers/UnitMapper_NodeProject.js +22 -1
- package/units/discovery/types.js +1 -0
- package/units/implementations/Unit_NodeProject.d.ts +59 -0
- package/{v3/units → units/implementations}/Unit_NodeProject.js +65 -5
- package/units/implementations/Unit_PackageJson.d.ts +56 -0
- package/{v3/units → units/implementations}/Unit_PackageJson.js +39 -3
- package/{v3/units → units/implementations}/Unit_TypescriptLib.d.ts +40 -4
- package/{v3/units → units/implementations}/Unit_TypescriptLib.js +167 -17
- package/units/implementations/firebase/Unit_FirebaseFunctionsApp.d.ts +233 -0
- package/units/implementations/firebase/Unit_FirebaseFunctionsApp.js +804 -0
- package/units/implementations/firebase/Unit_FirebaseHostingApp.d.ts +113 -0
- package/units/implementations/firebase/Unit_FirebaseHostingApp.js +320 -0
- package/units/implementations/firebase/common.d.ts +26 -0
- package/units/implementations/firebase/common.js +65 -0
- package/units/index.d.ts +6 -0
- package/units/index.js +6 -0
- package/v3/core/Unit_HelpPrinter.d.ts +1 -16
- package/v3/core/Unit_HelpPrinter.js +1 -47
- package/{v3 → workspace}/Workspace.d.ts +30 -15
- package/{v3 → workspace}/Workspace.js +48 -35
- package/core/consts.d.ts +0 -13
- package/core/consts.js +0 -12
- package/core/exceptions/PhaseAggregatedException.d.ts +0 -8
- package/core/exceptions/UnitPhaseException.d.ts +0 -5
- package/core/exceptions/UnitPhaseException.js +0 -6
- package/old/PhaseRunnerDispatcher.d.ts +0 -24
- package/old/PhaseRunnerDispatcher.js +0 -32
- package/old/runner-dispatchers.d.ts +0 -10
- package/old/runner-dispatchers.js +0 -3
- package/v3/PhaseManager.d.ts +0 -27
- package/v3/RunningStatusHandler.d.ts +0 -18
- package/v3/RunningStatusHandler.js +0 -67
- package/v3/UnitsMapper/UnitsMapper.d.ts +0 -21
- package/v3/UnitsMapper/resolvers/UnitMapper_Base.d.ts +0 -23
- package/v3/UnitsMapper/resolvers/UnitMapper_Base.js +0 -16
- package/v3/UnitsMapper/resolvers/UnitMapper_FirebaseFunction.js +0 -66
- package/v3/core/FilesCache.d.ts +0 -7
- package/v3/core/FilesCache.js +0 -33
- package/v3/phase/types.d.ts +0 -10
- package/v3/units/ProjectUnit.d.ts +0 -18
- package/v3/units/ProjectUnit.js +0 -11
- package/v3/units/Unit_NodeProject.d.ts +0 -30
- package/v3/units/Unit_PackageJson.d.ts +0 -17
- package/v3/units/firebase/Unit_FirebaseFunctionsApp.d.ts +0 -64
- package/v3/units/firebase/Unit_FirebaseFunctionsApp.js +0 -306
- package/v3/units/firebase/Unit_FirebaseHostingApp.d.ts +0 -49
- package/v3/units/firebase/Unit_FirebaseHostingApp.js +0 -118
- package/v3/units/firebase/common.d.ts +0 -3
- package/v3/units/firebase/common.js +0 -13
- package/v3/units/index.d.ts +0 -6
- package/v3/units/index.js +0 -6
- /package/{core → config}/package/consts.js +0 -0
- /package/{core → config}/types/configs/firebasejson.d.ts +0 -0
- /package/{core → config}/types/configs/firebasejson.js +0 -0
- /package/{core → config}/types/configs/firebaserc.d.ts +0 -0
- /package/{core → config}/types/configs/firebaserc.js +0 -0
- /package/{core → config}/types/configs/index.d.ts +0 -0
- /package/{core → config}/types/configs/index.js +0 -0
- /package/{core → config}/types/configs/package-json.d.ts +0 -0
- /package/{core → config}/types/configs/package-json.js +0 -0
- /package/{core → config}/types/core.d.ts +0 -0
- /package/{core → config}/types/core.js +0 -0
- /package/{core → config}/types/index.d.ts +0 -0
- /package/{core → config}/types/index.js +0 -0
- /package/{core → config}/types/package/index.d.ts +0 -0
- /package/{core → config}/types/package/index.js +0 -0
- /package/{core → config}/types/package/package.d.ts +0 -0
- /package/{core → config}/types/package/package.js +0 -0
- /package/{core → config}/types/package/runtime-package.d.ts +0 -0
- /package/{core → config}/types/package/runtime-package.js +0 -0
- /package/{core → config}/types/project-config.js +0 -0
- /package/{v3/core → core}/types.js +0 -0
- /package/{v3/UnitsMapper/types.js → exports/types.d.ts} +0 -0
- /package/{v3/phase → phases/definitions}/index.d.ts +0 -0
- /package/{v3/phase → phases/definitions}/index.js +0 -0
- /package/{v3/phase → phases/definitions}/types.js +0 -0
- /package/{v3/units/types.js → run.d.ts} +0 -0
- /package/{defaults/backend-proxy → templates/backend/proxy}/proxy._ts +0 -0
- /package/{defaults/.firebase_config → templates/firebase/config}/database.rules.json +0 -0
- /package/{defaults/.firebase_config → templates/firebase/config}/firestore.indexes.json +0 -0
- /package/{defaults/.firebase_config → templates/firebase/config}/firestore.rules +0 -0
- /package/{defaults/.firebase_config → templates/firebase/config}/storage.rules +0 -0
- /package/{v3/units → units/base}/types.d.ts +0 -0
- /package/{v3/UnitsMapper → units/discovery}/resolvers/index.d.ts +0 -0
- /package/{v3/UnitsMapper → units/discovery}/resolvers/index.js +0 -0
- /package/{v3/UnitsMapper → units/discovery}/types.d.ts +0 -0
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { StringMap } from '@nu-art/ts-common';
|
|
2
|
-
import { BaseUnit, BaseUnit_Config, UnitRuntimeContext } from './BaseUnit.js';
|
|
3
|
-
export type Config_ProjectUnit = BaseUnit_Config & {
|
|
4
|
-
relativePath: string;
|
|
5
|
-
fullPath: string;
|
|
6
|
-
dependencies: StringMap;
|
|
7
|
-
};
|
|
8
|
-
export type ProjectUnit_RuntimeContext = UnitRuntimeContext & {
|
|
9
|
-
parentUnit: ProjectUnit<any>;
|
|
10
|
-
childUnits: ProjectUnit[];
|
|
11
|
-
};
|
|
12
|
-
/**
|
|
13
|
-
* Abstract class representing a Unit within a Project.
|
|
14
|
-
* Extends the BaseUnit to provide additional project-specific preparation logic.
|
|
15
|
-
*/
|
|
16
|
-
export declare abstract class ProjectUnit<C extends Config_ProjectUnit = Config_ProjectUnit> extends BaseUnit<C, ProjectUnit_RuntimeContext> {
|
|
17
|
-
constructor(config: C);
|
|
18
|
-
}
|
package/v3/units/ProjectUnit.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { BaseUnit } from './BaseUnit.js';
|
|
2
|
-
/**
|
|
3
|
-
* Abstract class representing a Unit within a Project.
|
|
4
|
-
* Extends the BaseUnit to provide additional project-specific preparation logic.
|
|
5
|
-
*/
|
|
6
|
-
export class ProjectUnit extends BaseUnit {
|
|
7
|
-
constructor(config) {
|
|
8
|
-
super(config);
|
|
9
|
-
this.addToClassStack(ProjectUnit);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { UnitPhaseImplementor } from '../core/types.js';
|
|
2
|
-
import { StringMap } from '@nu-art/ts-common/utils/types';
|
|
3
|
-
import { Unit_PackageJson, Unit_PackageJson_Config } from './Unit_PackageJson.js';
|
|
4
|
-
import { ProjectUnit } from './ProjectUnit.js';
|
|
5
|
-
import { Phase_Install, Phase_PostPublish, Phase_Watch } from '../phase/index.js';
|
|
6
|
-
type Unit_TypescriptProject_Config = Unit_PackageJson_Config & {
|
|
7
|
-
globalPackages?: StringMap;
|
|
8
|
-
isRoot: true;
|
|
9
|
-
};
|
|
10
|
-
export declare class Unit_NodeProject<C extends Unit_TypescriptProject_Config = Unit_TypescriptProject_Config> extends Unit_PackageJson<C> implements UnitPhaseImplementor<[Phase_Install, Phase_Watch, Phase_PostPublish]> {
|
|
11
|
-
private watcher?;
|
|
12
|
-
readonly innerUnits: Unit_PackageJson[];
|
|
13
|
-
private readonly suffixesToWatch;
|
|
14
|
-
constructor(config: Unit_NodeProject<C>['config']);
|
|
15
|
-
protected deriveDistDependencies(): StringMap;
|
|
16
|
-
assignUnit(units: ProjectUnit[]): void;
|
|
17
|
-
/**
|
|
18
|
-
* Resolve all paths to watch in all project libs
|
|
19
|
-
* @private
|
|
20
|
-
* @returns string[]
|
|
21
|
-
*/
|
|
22
|
-
private prepareWatchPaths;
|
|
23
|
-
stopWatch(): Promise<void | undefined>;
|
|
24
|
-
private findUnit;
|
|
25
|
-
install(): Promise<void>;
|
|
26
|
-
watch(timeout?: number, maxTimeout?: number): Promise<void>;
|
|
27
|
-
purge(): Promise<void>;
|
|
28
|
-
postPublish(): Promise<void>;
|
|
29
|
-
}
|
|
30
|
-
export {};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { StringMap } from '@nu-art/ts-common';
|
|
2
|
-
import { UnitPhaseImplementor } from '../core/types.js';
|
|
3
|
-
import { Config_ProjectUnit, ProjectUnit } from './ProjectUnit.js';
|
|
4
|
-
import { TS_PackageJSON } from '../UnitsMapper/types.js';
|
|
5
|
-
import { Phase_Prepare, Phase_Purge } from '../phase/index.js';
|
|
6
|
-
export type Unit_PackageJson_Config = Config_ProjectUnit & {
|
|
7
|
-
packageJson: TS_PackageJSON;
|
|
8
|
-
};
|
|
9
|
-
export declare class Unit_PackageJson<C extends Unit_PackageJson_Config = Unit_PackageJson_Config> extends ProjectUnit<C> implements UnitPhaseImplementor<[Phase_Purge, Phase_Prepare]> {
|
|
10
|
-
constructor(config: C);
|
|
11
|
-
protected npmCommand(command: string): string;
|
|
12
|
-
protected deriveDistDependencies(): StringMap;
|
|
13
|
-
protected deriveLibDependencies(): StringMap;
|
|
14
|
-
prepare(): Promise<void>;
|
|
15
|
-
purge(): Promise<void>;
|
|
16
|
-
protected releasePorts(allPorts: string[]): Promise<void>;
|
|
17
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { UnitPhaseImplementor } from '../../core/types.js';
|
|
2
|
-
import { FirebasePackageConfig } from '../../../core/types/index.js';
|
|
3
|
-
import { StringMap } from '@nu-art/ts-common';
|
|
4
|
-
import { Phase_Deploy, Phase_Launch } from '../../phase/index.js';
|
|
5
|
-
import { Unit_TypescriptLib, Unit_TypescriptLib_Config } from '../Unit_TypescriptLib.js';
|
|
6
|
-
export declare const firebaseFunctionEmulator_ErrorStrings: string[];
|
|
7
|
-
export declare const firebaseFunctionEmulator_WarningStrings: string[];
|
|
8
|
-
type EnvConfig = {
|
|
9
|
-
defaultConfig?: string;
|
|
10
|
-
envConfig?: string;
|
|
11
|
-
projectId: string;
|
|
12
|
-
isLocal?: boolean;
|
|
13
|
-
identityAccount?: string;
|
|
14
|
-
};
|
|
15
|
-
export type Unit_FirebaseFunctionsApp_Config = Unit_TypescriptLib_Config & {
|
|
16
|
-
firebaseConfig?: FirebasePackageConfig;
|
|
17
|
-
pathToFirebaseConfig: string;
|
|
18
|
-
envConfig: EnvConfig;
|
|
19
|
-
ignore?: string[];
|
|
20
|
-
debugPort: number;
|
|
21
|
-
basePort: number;
|
|
22
|
-
sslKey: string;
|
|
23
|
-
sslCert: string;
|
|
24
|
-
pathToEmulatorData: string;
|
|
25
|
-
sources?: string[];
|
|
26
|
-
};
|
|
27
|
-
export declare class Unit_FirebaseFunctionsApp<C extends Unit_FirebaseFunctionsApp_Config = Unit_FirebaseFunctionsApp_Config> extends Unit_TypescriptLib<C> implements UnitPhaseImplementor<[Phase_Launch, Phase_Deploy]> {
|
|
28
|
-
functions: StringMap;
|
|
29
|
-
static staggerCount: number;
|
|
30
|
-
static DefaultConfig_FirebaseFunction: {
|
|
31
|
-
pathToFirebaseConfig: string;
|
|
32
|
-
debugPort: number;
|
|
33
|
-
basePort: number;
|
|
34
|
-
sslKey: string;
|
|
35
|
-
sslCert: string;
|
|
36
|
-
output: string;
|
|
37
|
-
pathToEmulatorData: string;
|
|
38
|
-
};
|
|
39
|
-
readonly emulatorLogStrings: {
|
|
40
|
-
error: string[];
|
|
41
|
-
warning: string[];
|
|
42
|
-
};
|
|
43
|
-
constructor(config: Unit_FirebaseFunctionsApp<C>['config']);
|
|
44
|
-
protected copyPackageJSONToOutput(): Promise<void>;
|
|
45
|
-
prepare(): Promise<void>;
|
|
46
|
-
resolveConfigs(): Promise<void>;
|
|
47
|
-
compile(): Promise<void>;
|
|
48
|
-
postCompile(): Promise<void>;
|
|
49
|
-
launch(): Promise<void>;
|
|
50
|
-
releaseEmulatorPorts(): Promise<void>;
|
|
51
|
-
deploy(): Promise<void>;
|
|
52
|
-
private resolveFunctionsRC;
|
|
53
|
-
private resolveProxyFile;
|
|
54
|
-
private pathToProxy;
|
|
55
|
-
private resolveConfigDir;
|
|
56
|
-
private resolveFunctionsJSON;
|
|
57
|
-
private resolveFunctionsRuntimeConfig;
|
|
58
|
-
private createAppVersionFile;
|
|
59
|
-
protected deriveDistDependencies(): StringMap;
|
|
60
|
-
private createDependenciesDir;
|
|
61
|
-
private runProxy;
|
|
62
|
-
private runEmulator;
|
|
63
|
-
}
|
|
64
|
-
export {};
|
|
@@ -1,306 +0,0 @@
|
|
|
1
|
-
import { CONST_FirebaseJSON, CONST_FirebaseRC, CONST_PackageJSON, CONST_VersionApp } from '../../../core/consts.js';
|
|
2
|
-
import { __stringify, _keys, _logger_logPrefixes, deepClone, ImplementationMissingException, LogLevel, Second, sleep } from '@nu-art/ts-common';
|
|
3
|
-
import { Const_FirebaseConfigKeys, Const_FirebaseDefaultsKeyToFile } from '../../../defaults/consts.js';
|
|
4
|
-
import { Commando_NVM } from '@nu-art/commando/shell/plugins/nvm';
|
|
5
|
-
import { resolve } from 'path';
|
|
6
|
-
import { DEFAULT_OLD_TEMPLATE_PATTERN, FileSystemUtils } from '@nu-art/ts-common/utils/FileSystemUtils';
|
|
7
|
-
import { Unit_TypescriptLib } from '../Unit_TypescriptLib.js';
|
|
8
|
-
import { CommandoException } from '@nu-art/commando/shell/core/CliError';
|
|
9
|
-
import { deployLogFilter } from './common.js';
|
|
10
|
-
export const firebaseFunctionEmulator_ErrorStrings = [
|
|
11
|
-
'functions: Failed',
|
|
12
|
-
];
|
|
13
|
-
export const firebaseFunctionEmulator_WarningStrings = [
|
|
14
|
-
'⚠',
|
|
15
|
-
];
|
|
16
|
-
// const CONST_VersionApp = 'version-app.json';
|
|
17
|
-
export class Unit_FirebaseFunctionsApp extends Unit_TypescriptLib {
|
|
18
|
-
functions = {};
|
|
19
|
-
static staggerCount = 0;
|
|
20
|
-
static DefaultConfig_FirebaseFunction = {
|
|
21
|
-
pathToFirebaseConfig: '.firebase_config',
|
|
22
|
-
debugPort: 8100,
|
|
23
|
-
basePort: 8102,
|
|
24
|
-
sslKey: '.ssl/key.pem',
|
|
25
|
-
sslCert: '.ssl/cert.pem',
|
|
26
|
-
output: 'dist',
|
|
27
|
-
pathToEmulatorData: '.trash/data',
|
|
28
|
-
};
|
|
29
|
-
emulatorLogStrings = {
|
|
30
|
-
error: firebaseFunctionEmulator_ErrorStrings,
|
|
31
|
-
warning: firebaseFunctionEmulator_WarningStrings,
|
|
32
|
-
};
|
|
33
|
-
constructor(config) {
|
|
34
|
-
super(config);
|
|
35
|
-
this.addToClassStack(Unit_FirebaseFunctionsApp);
|
|
36
|
-
this.logger.setLogTransformer(log => {
|
|
37
|
-
const prefix = _logger_logPrefixes.find(prefix => log.includes(prefix));
|
|
38
|
-
if (!prefix)
|
|
39
|
-
return log;
|
|
40
|
-
return log.substring(log.indexOf(prefix) + prefix.length);
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
//######################### Phase Implementations #########################
|
|
44
|
-
async copyPackageJSONToOutput() {
|
|
45
|
-
const targetPath = resolve(this.config.output, CONST_PackageJSON);
|
|
46
|
-
const packageJson = deepClone(this.config.packageJson);
|
|
47
|
-
const distDependencies = this.deriveDistDependencies();
|
|
48
|
-
packageJson.main = 'index.js';
|
|
49
|
-
packageJson.types = 'index.d.ts';
|
|
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;
|
|
64
|
-
await FileSystemUtils.file.template.write(targetPath, __stringify(packageJson, true), this.deriveDistDependencies(), DEFAULT_OLD_TEMPLATE_PATTERN);
|
|
65
|
-
}
|
|
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
|
-
}
|
|
71
|
-
await super.prepare();
|
|
72
|
-
await FileSystemUtils.folder.list.forEach.folder(this.config.fullPath, async (path) => {
|
|
73
|
-
if (path.replace(`${this.config.fullPath}/`, '').startsWith('firebase-export-'))
|
|
74
|
-
return await FileSystemUtils.folder.delete(path);
|
|
75
|
-
});
|
|
76
|
-
await FileSystemUtils.folder.create(resolve(this.config.fullPath, this.config.pathToEmulatorData));
|
|
77
|
-
await FileSystemUtils.file.delete(this.pathToProxy());
|
|
78
|
-
await this.resolveConfigs();
|
|
79
|
-
}
|
|
80
|
-
async resolveConfigs() {
|
|
81
|
-
await this.resolveFunctionsRC();
|
|
82
|
-
await this.resolveConfigDir();
|
|
83
|
-
await this.resolveFunctionsRuntimeConfig();
|
|
84
|
-
await this.resolveFunctionsJSON();
|
|
85
|
-
}
|
|
86
|
-
async compile() {
|
|
87
|
-
await this.createAppVersionFile();
|
|
88
|
-
await super.compile();
|
|
89
|
-
}
|
|
90
|
-
async postCompile() {
|
|
91
|
-
await this.createDependenciesDir();
|
|
92
|
-
}
|
|
93
|
-
async launch() {
|
|
94
|
-
await sleep(2 * Second * Unit_FirebaseFunctionsApp.staggerCount++);
|
|
95
|
-
await this.releaseEmulatorPorts();
|
|
96
|
-
await Promise.all([
|
|
97
|
-
this.runProxy(),
|
|
98
|
-
this.runEmulator(),
|
|
99
|
-
]);
|
|
100
|
-
}
|
|
101
|
-
async releaseEmulatorPorts() {
|
|
102
|
-
const allPorts = Array.from({ length: 10 }, (_, i) => `${this.config.basePort + i}`);
|
|
103
|
-
return this.releasePorts(allPorts);
|
|
104
|
-
}
|
|
105
|
-
async deploy() {
|
|
106
|
-
const commando = this.allocateCommando(Commando_NVM).applyNVM()
|
|
107
|
-
.cd(this.config.output)
|
|
108
|
-
.ls()
|
|
109
|
-
.cat('package.json')
|
|
110
|
-
.cat('index.js')
|
|
111
|
-
.cd(this.config.fullPath)
|
|
112
|
-
.setLogLevelFilter(deployLogFilter)
|
|
113
|
-
// example: Function URL (hello(us-central1)): https://hello-kv65k7yylq-uc.a.run.app
|
|
114
|
-
.onLog(/.*Function URL.*?\((.*?)\(.*(https:\/\/.*?)$/, match => {
|
|
115
|
-
this.functions[match[1]] = match[2];
|
|
116
|
-
});
|
|
117
|
-
const debug = this.runtimeContext.runtimeParams.verbose ? ' --debug' : '';
|
|
118
|
-
await this.executeAsyncCommando(commando, `${this.npmCommand('firebase')}${debug} deploy --only functions --force`, (stdout, stderr, exitCode) => {
|
|
119
|
-
if (exitCode === 0)
|
|
120
|
-
return;
|
|
121
|
-
throw new CommandoException(`Failed to deploy function with exit code ${exitCode}`, stdout, stderr, exitCode);
|
|
122
|
-
});
|
|
123
|
-
this.logInfo(`Functions: `, this.functions);
|
|
124
|
-
}
|
|
125
|
-
//######################### ResolveConfig Logic #########################
|
|
126
|
-
async resolveFunctionsRC() {
|
|
127
|
-
const envConfig = this.config.envConfig;
|
|
128
|
-
const rcConfig = {
|
|
129
|
-
projects: {
|
|
130
|
-
default: envConfig.projectId
|
|
131
|
-
},
|
|
132
|
-
targets: {
|
|
133
|
-
[envConfig.projectId]: {
|
|
134
|
-
database: {
|
|
135
|
-
[envConfig.projectId]: [envConfig.projectId]
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
};
|
|
140
|
-
const targetPath = resolve(this.config.fullPath, CONST_FirebaseRC);
|
|
141
|
-
await FileSystemUtils.file.write.json(targetPath, rcConfig);
|
|
142
|
-
}
|
|
143
|
-
async resolveProxyFile() {
|
|
144
|
-
const envConfig = this.config.envConfig;
|
|
145
|
-
const targetPath = this.pathToProxy();
|
|
146
|
-
const path = this.runtimeContext.baiConfig.files?.backend?.proxy;
|
|
147
|
-
if (!path)
|
|
148
|
-
return;
|
|
149
|
-
const params = {
|
|
150
|
-
PROJECT_ID: `${envConfig.projectId}`,
|
|
151
|
-
PROXY_PORT: `${this.config.basePort}`,
|
|
152
|
-
SERVER_PORT: `${this.config.basePort + 1}`,
|
|
153
|
-
PATH_TO_SSL_KEY: `${this.config.sslKey}`,
|
|
154
|
-
PATH_TO_SSL_CERTIFICATE: `${this.config.sslCert}`,
|
|
155
|
-
};
|
|
156
|
-
await FileSystemUtils.file.template.copy(path, targetPath, params);
|
|
157
|
-
}
|
|
158
|
-
pathToProxy() {
|
|
159
|
-
return resolve(this.config.fullPath, 'src/main/proxy.ts');
|
|
160
|
-
}
|
|
161
|
-
async resolveConfigDir() {
|
|
162
|
-
//Create the dir if it doesn't exist
|
|
163
|
-
const pathToFirebaseConfigFolder = `${this.config.fullPath}/${this.config.pathToFirebaseConfig}`;
|
|
164
|
-
await FileSystemUtils.folder.create(pathToFirebaseConfigFolder);
|
|
165
|
-
//Fill config dir with relevant files for each file that doesn't exist
|
|
166
|
-
const defaultFiles = this.runtimeContext.baiConfig.files?.firebase;
|
|
167
|
-
if (!defaultFiles) {
|
|
168
|
-
this.logError('No defaultFileRoutes in project config');
|
|
169
|
-
return;
|
|
170
|
-
}
|
|
171
|
-
await Promise.all(Const_FirebaseConfigKeys.map(async (firebaseConfigKey) => {
|
|
172
|
-
const pathToConfigFile = `${pathToFirebaseConfigFolder}/${Const_FirebaseDefaultsKeyToFile[firebaseConfigKey]}`;
|
|
173
|
-
if (!defaultFiles[firebaseConfigKey])
|
|
174
|
-
return;
|
|
175
|
-
const path = resolve(this.runtimeContext.parentUnit.config.fullPath, defaultFiles[firebaseConfigKey]);
|
|
176
|
-
await FileSystemUtils.file.copy(path, pathToConfigFile);
|
|
177
|
-
}));
|
|
178
|
-
}
|
|
179
|
-
async resolveFunctionsJSON() {
|
|
180
|
-
const envConfig = this.config.envConfig;
|
|
181
|
-
const targetPath = `${this.config.fullPath}/${CONST_FirebaseJSON}`;
|
|
182
|
-
let fileContent;
|
|
183
|
-
if (envConfig.isLocal) {
|
|
184
|
-
const port = this.config.basePort;
|
|
185
|
-
fileContent = {
|
|
186
|
-
database: [{
|
|
187
|
-
target: this.config.envConfig.projectId,
|
|
188
|
-
rules: `${this.config.pathToFirebaseConfig}/database.rules.json`
|
|
189
|
-
}],
|
|
190
|
-
firestore: {
|
|
191
|
-
rules: `${this.config.pathToFirebaseConfig}/firestore.rules`,
|
|
192
|
-
indexes: `${this.config.pathToFirebaseConfig}/firestore.indexes.json`
|
|
193
|
-
},
|
|
194
|
-
storage: {
|
|
195
|
-
rules: `${this.config.pathToFirebaseConfig}/storage.rules`
|
|
196
|
-
},
|
|
197
|
-
remoteconfig: {
|
|
198
|
-
template: `${this.config.pathToFirebaseConfig}/remoteconfig.template.json`
|
|
199
|
-
},
|
|
200
|
-
functions: {
|
|
201
|
-
ignore: this.config.ignore,
|
|
202
|
-
source: '.',
|
|
203
|
-
predeploy: [
|
|
204
|
-
'echo "Thunderstorm - Local environment is not deployable... Aborting..." && exit 2'
|
|
205
|
-
]
|
|
206
|
-
},
|
|
207
|
-
emulators: {
|
|
208
|
-
singleProjectMode: true,
|
|
209
|
-
functions: { port: port + 1 },
|
|
210
|
-
database: { port: port + 2 },
|
|
211
|
-
firestore: {
|
|
212
|
-
port: port + 3,
|
|
213
|
-
websocketPort: port + 4
|
|
214
|
-
},
|
|
215
|
-
pubsub: { port: port + 5 },
|
|
216
|
-
storage: { port: port + 6 },
|
|
217
|
-
auth: { port: port + 7 },
|
|
218
|
-
ui: { port: port + 8, enabled: true },
|
|
219
|
-
hub: { port: port + 9 },
|
|
220
|
-
logging: { port: port + 10 }
|
|
221
|
-
}
|
|
222
|
-
};
|
|
223
|
-
}
|
|
224
|
-
else {
|
|
225
|
-
fileContent = {
|
|
226
|
-
functions: {
|
|
227
|
-
source: this.config.output.replace(`${this.config.fullPath}/`, ''),
|
|
228
|
-
ignore: this.config.ignore,
|
|
229
|
-
runtime: 'nodejs22',
|
|
230
|
-
}
|
|
231
|
-
};
|
|
232
|
-
}
|
|
233
|
-
await FileSystemUtils.file.write.json(targetPath, fileContent);
|
|
234
|
-
}
|
|
235
|
-
async resolveFunctionsRuntimeConfig() {
|
|
236
|
-
const envConfig = this.config.envConfig;
|
|
237
|
-
const targetPath = `${this.config.fullPath}/src/main/config.ts`;
|
|
238
|
-
const envKey = this.runtimeContext.runtimeParams.environment;
|
|
239
|
-
const beConfig = {
|
|
240
|
-
envKey,
|
|
241
|
-
pathToDefaultConfig: envConfig.defaultConfig ?? `/_config/default`,
|
|
242
|
-
pathToEnvOverrideConfig: envConfig.defaultConfig ?? `/_config/${envKey}`,
|
|
243
|
-
};
|
|
244
|
-
const inLocalIgnoreTLS = `${envConfig.isLocal ? '// @ts-ignore\nprocess.env[\'NODE_TLS_REJECT_UNAUTHORIZED\'] = 0;\n\n' : ''}`;
|
|
245
|
-
const fileContent = `${inLocalIgnoreTLS}export const Environment = ${JSON.stringify(beConfig)};`;
|
|
246
|
-
await FileSystemUtils.file.write(targetPath, fileContent);
|
|
247
|
-
}
|
|
248
|
-
//######################### Compile Logic #########################
|
|
249
|
-
async createAppVersionFile() {
|
|
250
|
-
//Writing the file to the package source instead of the output is fine,
|
|
251
|
-
//copyAssetsToOutput will move the file to output
|
|
252
|
-
const targetPath = `${this.config.fullPath}/src/main/${CONST_VersionApp}`;
|
|
253
|
-
const appVersion = this.runtimeContext.version;
|
|
254
|
-
await FileSystemUtils.file.write.json(targetPath, { version: appVersion });
|
|
255
|
-
}
|
|
256
|
-
deriveDistDependencies() {
|
|
257
|
-
return this.dependencyUnits.reduce((dependencies, unit) => {
|
|
258
|
-
dependencies[unit.config.key] = `file:.dependencies/${unit.config.key}`;
|
|
259
|
-
return dependencies;
|
|
260
|
-
}, super.deriveDistDependencies());
|
|
261
|
-
}
|
|
262
|
-
async createDependenciesDir() {
|
|
263
|
-
//Gather units that are dependencies of this unit
|
|
264
|
-
await Promise.all(this.dependencyUnits.map(async (unit) => {
|
|
265
|
-
//Copy dependency unit output into this units output/.dependency dir
|
|
266
|
-
const dependencyOutputPath = `${unit.config.output}/`;
|
|
267
|
-
const targetPath = `${this.config.output}/.dependencies/${unit.config.key}/`;
|
|
268
|
-
await FileSystemUtils.folder.create(targetPath);
|
|
269
|
-
await this.allocateCommando()
|
|
270
|
-
.append(`rsync -a --delete ${dependencyOutputPath} ${targetPath}`)
|
|
271
|
-
.execute();
|
|
272
|
-
}));
|
|
273
|
-
}
|
|
274
|
-
//######################### Launch Logic #########################
|
|
275
|
-
async runProxy() {
|
|
276
|
-
await this.resolveProxyFile();
|
|
277
|
-
const commando = this.allocateCommando(Commando_NVM).applyNVM()
|
|
278
|
-
.cd(this.config.fullPath);
|
|
279
|
-
await this.executeAsyncCommando(commando, `${this.npmCommand('tsx')} src/main/proxy.ts`);
|
|
280
|
-
this.logWarning('PROXY TERMINATED');
|
|
281
|
-
}
|
|
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
|
-
}
|
|
290
|
-
const commando = this.allocateCommando(Commando_NVM).applyNVM()
|
|
291
|
-
.setUID(this.config.key)
|
|
292
|
-
.cd(this.config.fullPath);
|
|
293
|
-
if (exportGoogleCredentials)
|
|
294
|
-
commando.append(exportGoogleCredentials);
|
|
295
|
-
commando.setLogLevelFilter((log, type) => {
|
|
296
|
-
if (this.emulatorLogStrings.error.some(errStr => log.includes(errStr)))
|
|
297
|
-
return LogLevel.Error;
|
|
298
|
-
if (this.emulatorLogStrings.warning.some(warnStr => log.includes(warnStr)))
|
|
299
|
-
return LogLevel.Warning;
|
|
300
|
-
})
|
|
301
|
-
.onLog(/.*Emulator Hub running.*/, () => this.setStatus('Launch Complete'));
|
|
302
|
-
await this.executeAsyncCommando(commando, `${this.npmCommand('firebase')} emulators:start --project ${this.config.envConfig.projectId} --export-on-exit --import=${this.config.pathToEmulatorData} ${this.runtimeContext.runtimeParams.debugBackend
|
|
303
|
-
? `--inspect-functions ${this.config.debugPort}` : ''}`);
|
|
304
|
-
this.logWarning('EMULATORS TERMINATED');
|
|
305
|
-
}
|
|
306
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { FirebasePackageConfig } from '../../../core/types/index.js';
|
|
2
|
-
import { UnitPhaseImplementor } from '../../core/types.js';
|
|
3
|
-
import { StringMap, TS_Object, TypedMap } from '@nu-art/ts-common';
|
|
4
|
-
import { UnitConfigJSON_Node } from '../../UnitsMapper/resolvers/UnitMapper_Node.js';
|
|
5
|
-
import { Phase_Deploy, Phase_Launch } from '../../phase/index.js';
|
|
6
|
-
import { Unit_TypescriptLib, Unit_TypescriptLib_Config } from '../Unit_TypescriptLib.js';
|
|
7
|
-
export type FirebaseHostingConfig = {
|
|
8
|
-
public: string;
|
|
9
|
-
rewrites: {
|
|
10
|
-
source: string;
|
|
11
|
-
destination: string;
|
|
12
|
-
}[];
|
|
13
|
-
};
|
|
14
|
-
export type FirebaseHosting_EnvConfig = {
|
|
15
|
-
config: TS_Object;
|
|
16
|
-
projectId: string;
|
|
17
|
-
isLocal?: boolean;
|
|
18
|
-
};
|
|
19
|
-
export type UnitConfigJSON_FirebaseHosting = UnitConfigJSON_Node & {
|
|
20
|
-
servingPort?: number;
|
|
21
|
-
hostingConfig?: FirebaseHostingConfig;
|
|
22
|
-
envs: TypedMap<FirebaseHosting_EnvConfig>;
|
|
23
|
-
};
|
|
24
|
-
export type Unit_FirebaseHostingApp_Config = Unit_TypescriptLib_Config & {
|
|
25
|
-
firebaseConfig?: FirebasePackageConfig;
|
|
26
|
-
servingPort: number;
|
|
27
|
-
hostingConfig?: FirebaseHostingConfig;
|
|
28
|
-
envConfig: FirebaseHosting_EnvConfig;
|
|
29
|
-
sources?: string[];
|
|
30
|
-
};
|
|
31
|
-
export declare class Unit_FirebaseHostingApp<C extends Unit_FirebaseHostingApp_Config = Unit_FirebaseHostingApp_Config> extends Unit_TypescriptLib<C> implements UnitPhaseImplementor<[Phase_Launch, Phase_Deploy]> {
|
|
32
|
-
hosting: StringMap;
|
|
33
|
-
static DefaultConfig_FirebaseHosting: {
|
|
34
|
-
servingPort: number;
|
|
35
|
-
output: string;
|
|
36
|
-
};
|
|
37
|
-
constructor(config: Unit_FirebaseHostingApp<C>['config']);
|
|
38
|
-
prepare(): Promise<void>;
|
|
39
|
-
compile(): Promise<void>;
|
|
40
|
-
launch(): Promise<void>;
|
|
41
|
-
releaseWebpackPorts(): Promise<void>;
|
|
42
|
-
deploy(): Promise<void>;
|
|
43
|
-
private resolveHostingRC;
|
|
44
|
-
private resolveHostingJSON;
|
|
45
|
-
private resolveHostingRuntimeConfig;
|
|
46
|
-
protected compileImpl(): Promise<void>;
|
|
47
|
-
private createAppVersionFile;
|
|
48
|
-
private runApp;
|
|
49
|
-
}
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import { ImplementationMissingException, LogLevel } from '@nu-art/ts-common';
|
|
2
|
-
import { CONST_FirebaseJSON, CONST_FirebaseRC, CONST_VersionApp } from '../../../core/consts.js';
|
|
3
|
-
import { Commando_NVM } from '@nu-art/commando/shell/plugins/nvm';
|
|
4
|
-
import { Commando_Basic } from '@nu-art/commando/shell/plugins/basic';
|
|
5
|
-
import { resolve } from 'path';
|
|
6
|
-
import { Unit_TypescriptLib } from '../Unit_TypescriptLib.js';
|
|
7
|
-
import { CommandoException } from '@nu-art/commando/shell/core/CliError';
|
|
8
|
-
import { deployLogFilter } from './common.js';
|
|
9
|
-
import { FileSystemUtils } from '@nu-art/ts-common/utils/FileSystemUtils';
|
|
10
|
-
export class Unit_FirebaseHostingApp extends Unit_TypescriptLib {
|
|
11
|
-
hosting = {};
|
|
12
|
-
static DefaultConfig_FirebaseHosting = {
|
|
13
|
-
servingPort: 8100,
|
|
14
|
-
output: 'dist',
|
|
15
|
-
};
|
|
16
|
-
constructor(config) {
|
|
17
|
-
super(config);
|
|
18
|
-
this.addToClassStack(Unit_FirebaseHostingApp);
|
|
19
|
-
}
|
|
20
|
-
//######################### Phase Implementations #########################
|
|
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
|
-
}
|
|
26
|
-
await super.prepare();
|
|
27
|
-
await this.resolveHostingRC();
|
|
28
|
-
await this.resolveHostingJSON();
|
|
29
|
-
await this.resolveHostingRuntimeConfig();
|
|
30
|
-
}
|
|
31
|
-
async compile() {
|
|
32
|
-
await this.resolveTSConfig(resolve(this.config.fullPath, './src'), 'main', { compilerOptions: { declaration: false } });
|
|
33
|
-
await this.clearOutputDir();
|
|
34
|
-
await this.createAppVersionFile();
|
|
35
|
-
await this.compileImpl();
|
|
36
|
-
}
|
|
37
|
-
async launch() {
|
|
38
|
-
this.setStatus('Launching');
|
|
39
|
-
await this.releaseWebpackPorts();
|
|
40
|
-
await this.runApp();
|
|
41
|
-
}
|
|
42
|
-
async releaseWebpackPorts() {
|
|
43
|
-
return this.releasePorts([`${this.config.servingPort}`]);
|
|
44
|
-
}
|
|
45
|
-
async deploy() {
|
|
46
|
-
const commando = this.allocateCommando(Commando_NVM).applyNVM()
|
|
47
|
-
.cd(this.config.fullPath)
|
|
48
|
-
.setLogLevelFilter(deployLogFilter)
|
|
49
|
-
// example: Function URL (hello(us-central1)): https://hello-kv65k7yylq-uc.a.run.app
|
|
50
|
-
.onLog(/.*Hosting URL.*(https:\/\/.*?)$/, match => {
|
|
51
|
-
this.hosting[match[1]] = match[2];
|
|
52
|
-
});
|
|
53
|
-
const debug = this.runtimeContext.runtimeParams.verbose ? ' --debug' : '';
|
|
54
|
-
await this.executeAsyncCommando(commando, `${this.npmCommand('firebase')}${debug} deploy --only hosting`, (stdout, stderr, exitCode) => {
|
|
55
|
-
if (exitCode === 0)
|
|
56
|
-
return;
|
|
57
|
-
throw new CommandoException(`Failed to deploy hosting with exit code ${exitCode}`, stdout, stderr, exitCode);
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
//######################### ResolveConfig Logic #########################
|
|
61
|
-
async resolveHostingRC() {
|
|
62
|
-
const envConfig = this.config.envConfig;
|
|
63
|
-
const rcConfig = { projects: { default: envConfig.projectId } };
|
|
64
|
-
const targetPath = `${this.config.fullPath}/${CONST_FirebaseRC}`;
|
|
65
|
-
await FileSystemUtils.file.write.json(targetPath, rcConfig);
|
|
66
|
-
}
|
|
67
|
-
async resolveHostingJSON() {
|
|
68
|
-
const envConfig = this.config.envConfig;
|
|
69
|
-
const targetPath = `${this.config.fullPath}/${CONST_FirebaseJSON}`;
|
|
70
|
-
let fileContent;
|
|
71
|
-
if (envConfig.isLocal)
|
|
72
|
-
fileContent = {};
|
|
73
|
-
else
|
|
74
|
-
fileContent = {
|
|
75
|
-
hosting: this.config.hostingConfig ?? {
|
|
76
|
-
'public': 'dist',
|
|
77
|
-
'rewrites': [
|
|
78
|
-
{ 'source': '**', 'destination': '/index.html' }
|
|
79
|
-
]
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
await FileSystemUtils.file.write.json(targetPath, fileContent);
|
|
83
|
-
}
|
|
84
|
-
async resolveHostingRuntimeConfig() {
|
|
85
|
-
const envConfig = this.config.envConfig.config;
|
|
86
|
-
const targetPath = resolve(this.config.fullPath, `./src/main/config.ts`);
|
|
87
|
-
const fileContent = `export const config = ${JSON.stringify(envConfig, null, 2)};`;
|
|
88
|
-
await FileSystemUtils.file.write(targetPath, fileContent);
|
|
89
|
-
}
|
|
90
|
-
//######################### Compile Logic #########################
|
|
91
|
-
async compileImpl() {
|
|
92
|
-
const commando = this.allocateCommando(Commando_NVM, Commando_Basic).applyNVM()
|
|
93
|
-
.cd(this.config.fullPath);
|
|
94
|
-
await this.executeAsyncCommando(commando, `ENV=${this.runtimeContext.runtimeParams.environment} npm run build`, (stdout, stderr, exitCode) => {
|
|
95
|
-
if (exitCode > 0)
|
|
96
|
-
throw new CommandoException(`Error compiling`, stdout, stderr, exitCode);
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
async createAppVersionFile() {
|
|
100
|
-
//Writing the file to the package source instead of the output is fine,
|
|
101
|
-
//Webpack bundles files into the output automatically!
|
|
102
|
-
const targetPath = `${this.config.fullPath}/src/main/${CONST_VersionApp}`;
|
|
103
|
-
const appVersion = this.runtimeContext.version;
|
|
104
|
-
await FileSystemUtils.file.write.json(targetPath, { version: appVersion });
|
|
105
|
-
}
|
|
106
|
-
//######################### Launch Logic #########################
|
|
107
|
-
async runApp() {
|
|
108
|
-
const commando = this.allocateCommando(Commando_NVM).applyNVM()
|
|
109
|
-
.setUID(this.config.key)
|
|
110
|
-
.cd(this.config.fullPath)
|
|
111
|
-
.setLogLevelFilter((log, type) => {
|
|
112
|
-
if (log.toLowerCase().includes('<i>'))
|
|
113
|
-
return LogLevel.Info;
|
|
114
|
-
});
|
|
115
|
-
await this.executeAsyncCommando(commando, 'npm run start');
|
|
116
|
-
this.logWarning('HOSTING TERMINATED');
|
|
117
|
-
}
|
|
118
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { LogLevel } from '@nu-art/ts-common';
|
|
2
|
-
const warn = ['missing required API'];
|
|
3
|
-
const info = ['=== Deploying', 'functions: Successfully deployed function'];
|
|
4
|
-
const infoStartsWith = ['✔ ', 'i '];
|
|
5
|
-
export const deployLogFilter = (log, std) => {
|
|
6
|
-
if (log.startsWith('⚠ ') || warn.find(str => log.includes(str)))
|
|
7
|
-
return LogLevel.Warning;
|
|
8
|
-
if (infoStartsWith.find(str => log.startsWith(str)) || info.find(str => log.includes(str)))
|
|
9
|
-
return LogLevel.Info;
|
|
10
|
-
if (log.includes('Error:'))
|
|
11
|
-
return LogLevel.Error;
|
|
12
|
-
return LogLevel.Debug;
|
|
13
|
-
};
|
package/v3/units/index.d.ts
DELETED
package/v3/units/index.js
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|