@nu-art/build-and-install 0.300.7 → 0.400.0
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.d.ts +29 -0
- package/build-and-install-v3.js +132 -0
- package/build-and-install-v3.js.map +1 -0
- package/build-and-install.js +18 -24
- package/build-and-install.js.map +1 -0
- package/core/consts.d.ts +7 -2
- package/core/consts.js +12 -9
- package/core/consts.js.map +1 -0
- package/core/exceptions/PhaseAggregatedException.d.ts +5 -0
- package/core/exceptions/PhaseAggregatedException.js +9 -0
- package/core/exceptions/PhaseAggregatedException.js.map +1 -0
- package/core/package/consts.d.ts +1 -1
- package/core/package/consts.js +7 -9
- package/core/package/consts.js.map +1 -0
- package/core/params/params.d.ts +18 -19
- package/core/params/params.js +142 -178
- package/core/params/params.js.map +1 -0
- package/core/types/configs/firebasejson.js +2 -2
- package/core/types/configs/firebasejson.js.map +1 -0
- package/core/types/configs/firebaserc.js +2 -2
- package/core/types/configs/firebaserc.js.map +1 -0
- package/core/types/configs/index.d.ts +3 -3
- package/core/types/configs/index.js +4 -19
- package/core/types/configs/index.js.map +1 -0
- package/core/types/configs/package-json.d.ts +2 -1
- package/core/types/configs/package-json.js +2 -2
- package/core/types/configs/package-json.js.map +1 -0
- package/core/types/core.js +2 -2
- package/core/types/core.js.map +1 -0
- package/core/types/index.d.ts +4 -4
- package/core/types/index.js +5 -20
- package/core/types/index.js.map +1 -0
- package/core/types/package/index.d.ts +2 -2
- package/core/types/package/index.js +3 -18
- package/core/types/package/index.js.map +1 -0
- package/core/types/package/package.d.ts +10 -14
- package/core/types/package/package.js +15 -12
- package/core/types/package/package.js.map +1 -0
- package/core/types/package/runtime-package.d.ts +2 -2
- package/core/types/package/runtime-package.js +2 -2
- package/core/types/package/runtime-package.js.map +1 -0
- package/core/types/project-config.d.ts +31 -2
- package/core/types/project-config.js +2 -2
- package/core/types/project-config.js.map +1 -0
- package/defaults/backend-proxy/proxy._ts +3 -1
- package/defaults/consts.d.ts +0 -7
- package/defaults/consts.js +10 -10
- package/defaults/consts.js.map +1 -0
- package/{v2/phase-runner → old}/PhaseRunnerDispatcher.d.ts +4 -4
- package/old/PhaseRunnerDispatcher.js +33 -0
- package/old/PhaseRunnerDispatcher.js.map +1 -0
- package/{v2/unit → old}/runner-dispatchers.d.ts +3 -3
- package/old/runner-dispatchers.js +4 -0
- package/old/runner-dispatchers.js.map +1 -0
- package/package.json +20 -15
- package/v3/PhaseManager.d.ts +26 -0
- package/v3/PhaseManager.js +144 -0
- package/v3/PhaseManager.js.map +1 -0
- package/v3/RunningStatusHandler.d.ts +16 -0
- package/v3/RunningStatusHandler.js +57 -0
- package/v3/RunningStatusHandler.js.map +1 -0
- package/v3/UnitsDependencyMapper/UnitsDependencyMapper.d.ts +52 -0
- package/v3/UnitsDependencyMapper/UnitsDependencyMapper.js +287 -0
- package/v3/UnitsDependencyMapper/UnitsDependencyMapper.js.map +1 -0
- package/v3/UnitsMapper/UnitsMapper.d.ts +21 -0
- package/v3/UnitsMapper/UnitsMapper.js +60 -0
- package/v3/UnitsMapper/UnitsMapper.js.map +1 -0
- package/v3/UnitsMapper/resolvers/UnitMapper_Base.d.ts +23 -0
- package/v3/UnitsMapper/resolvers/UnitMapper_Base.js +17 -0
- package/v3/UnitsMapper/resolvers/UnitMapper_Base.js.map +1 -0
- package/v3/UnitsMapper/resolvers/UnitMapper_FirebaseFunction.d.ts +62 -0
- package/v3/UnitsMapper/resolvers/UnitMapper_FirebaseFunction.js +56 -0
- package/v3/UnitsMapper/resolvers/UnitMapper_FirebaseFunction.js.map +1 -0
- package/v3/UnitsMapper/resolvers/UnitMapper_FirebaseHosting.d.ts +38 -0
- package/v3/UnitsMapper/resolvers/UnitMapper_FirebaseHosting.js +49 -0
- package/v3/UnitsMapper/resolvers/UnitMapper_FirebaseHosting.js.map +1 -0
- package/v3/UnitsMapper/resolvers/UnitMapper_Node.d.ts +30 -0
- package/v3/UnitsMapper/resolvers/UnitMapper_Node.js +59 -0
- package/v3/UnitsMapper/resolvers/UnitMapper_Node.js.map +1 -0
- package/v3/UnitsMapper/resolvers/UnitMapper_NodeLib.d.ts +25 -0
- package/v3/UnitsMapper/resolvers/UnitMapper_NodeLib.js +29 -0
- package/v3/UnitsMapper/resolvers/UnitMapper_NodeLib.js.map +1 -0
- package/v3/UnitsMapper/resolvers/UnitMapper_NodeProject.d.ts +24 -0
- package/v3/UnitsMapper/resolvers/UnitMapper_NodeProject.js +23 -0
- package/v3/UnitsMapper/resolvers/UnitMapper_NodeProject.js.map +1 -0
- package/v3/UnitsMapper/resolvers/index.d.ts +4 -0
- package/v3/UnitsMapper/resolvers/index.js +5 -0
- package/v3/UnitsMapper/resolvers/index.js.map +1 -0
- package/v3/UnitsMapper/types.d.ts +24 -0
- package/v3/UnitsMapper/types.js +2 -0
- package/v3/UnitsMapper/types.js.map +1 -0
- package/v3/core/FileSystemUtils.d.ts +34 -0
- package/v3/core/FileSystemUtils.js +152 -0
- package/v3/core/FileSystemUtils.js.map +1 -0
- package/v3/core/FilesCache.d.ts +7 -0
- package/v3/core/FilesCache.js +34 -0
- package/v3/core/FilesCache.js.map +1 -0
- package/v3/core/Unit_HelpPrinter.d.ts +16 -0
- package/v3/core/Unit_HelpPrinter.js +48 -0
- package/v3/core/Unit_HelpPrinter.js.map +1 -0
- package/v3/core/types.d.ts +17 -0
- package/v3/core/types.js +6 -0
- package/v3/core/types.js.map +1 -0
- package/v3/phase/consts.d.ts +52 -0
- package/v3/phase/consts.js +127 -0
- package/v3/phase/consts.js.map +1 -0
- package/v3/phase/index.d.ts +2 -0
- package/v3/phase/index.js +3 -0
- package/v3/phase/index.js.map +1 -0
- package/v3/phase/types.d.ts +9 -0
- package/v3/phase/types.js +2 -0
- package/v3/phase/types.js.map +1 -0
- package/v3/units/BaseUnit.d.ts +46 -0
- package/v3/units/BaseUnit.js +120 -0
- package/v3/units/BaseUnit.js.map +1 -0
- package/v3/units/ProjectUnit.d.ts +18 -0
- package/v3/units/ProjectUnit.js +12 -0
- package/v3/units/ProjectUnit.js.map +1 -0
- package/v3/units/Unit_NodeProject.d.ts +32 -0
- package/v3/units/Unit_NodeProject.js +244 -0
- package/v3/units/Unit_NodeProject.js.map +1 -0
- package/v3/units/Unit_PackageJson.d.ts +19 -0
- package/v3/units/Unit_PackageJson.js +42 -0
- package/v3/units/Unit_PackageJson.js.map +1 -0
- package/v3/units/Unit_TypescriptLib.d.ts +45 -0
- package/v3/units/Unit_TypescriptLib.js +373 -0
- package/v3/units/Unit_TypescriptLib.js.map +1 -0
- package/v3/units/firebase/Unit_FirebaseFunctionsApp.d.ts +62 -0
- package/v3/units/firebase/Unit_FirebaseFunctionsApp.js +281 -0
- package/v3/units/firebase/Unit_FirebaseFunctionsApp.js.map +1 -0
- package/v3/units/firebase/Unit_FirebaseHostingApp.d.ts +49 -0
- package/v3/units/firebase/Unit_FirebaseHostingApp.js +100 -0
- package/v3/units/firebase/Unit_FirebaseHostingApp.js.map +1 -0
- package/v3/units/index.d.ts +5 -0
- package/v3/units/index.js +6 -0
- package/v3/units/index.js.map +1 -0
- package/core/params/types.d.ts +0 -51
- package/core/params/types.js +0 -2
- package/tsconfig.json +0 -23
- package/v2/phase/consts.d.ts +0 -53
- package/v2/phase/consts.js +0 -149
- package/v2/phase/index.d.ts +0 -2
- package/v2/phase/index.js +0 -18
- package/v2/phase/types.d.ts +0 -12
- package/v2/phase/types.js +0 -2
- package/v2/phase-runner/PhaseRunner.d.ts +0 -69
- package/v2/phase-runner/PhaseRunner.js +0 -472
- package/v2/phase-runner/PhaseRunnerDispatcher.js +0 -37
- package/v2/phase-runner/RunnerParams.d.ts +0 -12
- package/v2/phase-runner/RunnerParams.js +0 -9
- package/v2/phase-runner/consts.d.ts +0 -7
- package/v2/phase-runner/consts.js +0 -9
- package/v2/phase-runner/kaki.d.ts +0 -0
- package/v2/phase-runner/kaki.js +0 -1
- package/v2/phase-runner/types.d.ts +0 -13
- package/v2/phase-runner/types.js +0 -6
- package/v2/project/types.d.ts +0 -8
- package/v2/project/types.js +0 -2
- package/v2/screens/BAIScreen.d.ts +0 -22
- package/v2/screens/BAIScreen.js +0 -82
- package/v2/screens/BAIScreenManager.d.ts +0 -28
- package/v2/screens/BAIScreenManager.js +0 -77
- package/v2/screens/BAIScreen_Launch.d.ts +0 -28
- package/v2/screens/BAIScreen_Launch.js +0 -173
- package/v2/screens/BAIScreen_UnitList.d.ts +0 -36
- package/v2/screens/BAIScreen_UnitList.js +0 -203
- package/v2/unit/consts.d.ts +0 -6
- package/v2/unit/consts.js +0 -8
- package/v2/unit/core/BaseUnit.d.ts +0 -39
- package/v2/unit/core/BaseUnit.js +0 -138
- package/v2/unit/core/Unit_Python.d.ts +0 -16
- package/v2/unit/core/Unit_Python.js +0 -26
- package/v2/unit/core/Unit_Typescript.d.ts +0 -49
- package/v2/unit/core/Unit_Typescript.js +0 -143
- package/v2/unit/core/Unit_TypescriptLib.d.ts +0 -48
- package/v2/unit/core/Unit_TypescriptLib.js +0 -226
- package/v2/unit/core/Unit_TypescriptProject.d.ts +0 -31
- package/v2/unit/core/Unit_TypescriptProject.js +0 -194
- package/v2/unit/core/index.d.ts +0 -5
- package/v2/unit/core/index.js +0 -21
- package/v2/unit/firebase-units/Unit_FirebaseFunctionsApp.d.ts +0 -35
- package/v2/unit/firebase-units/Unit_FirebaseFunctionsApp.js +0 -309
- package/v2/unit/firebase-units/Unit_FirebaseHostingApp.d.ts +0 -24
- package/v2/unit/firebase-units/Unit_FirebaseHostingApp.js +0 -138
- package/v2/unit/firebase-units/consts.d.ts +0 -2
- package/v2/unit/firebase-units/consts.js +0 -9
- package/v2/unit/firebase-units/index.d.ts +0 -2
- package/v2/unit/firebase-units/index.js +0 -18
- package/v2/unit/runner-dispatchers.js +0 -6
- package/v2/unit/thunderstorm.d.ts +0 -171
- package/v2/unit/thunderstorm.js +0 -199
- package/v2/unit/tools/tools.d.ts +0 -2
- package/v2/unit/tools/tools.js +0 -15
- package/v2/unit/types.d.ts +0 -8
- package/v2/unit/types.js +0 -2
|
@@ -1,309 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Unit_FirebaseFunctionsApp = void 0;
|
|
4
|
-
const core_1 = require("../core");
|
|
5
|
-
const consts_1 = require("../../../core/consts");
|
|
6
|
-
const fs_1 = require("fs");
|
|
7
|
-
const params_1 = require("../../../core/params/params");
|
|
8
|
-
const ts_common_1 = require("@nu-art/ts-common");
|
|
9
|
-
const consts_2 = require("../../../defaults/consts");
|
|
10
|
-
const RunnerParams_1 = require("../../phase-runner/RunnerParams");
|
|
11
|
-
const consts_3 = require("../../phase-runner/consts");
|
|
12
|
-
const runner_dispatchers_1 = require("../runner-dispatchers");
|
|
13
|
-
const nvm_1 = require("@nu-art/commando/shell/plugins/nvm");
|
|
14
|
-
const consts_4 = require("./consts");
|
|
15
|
-
const CONST_VersionApp = 'version-app.json';
|
|
16
|
-
class Unit_FirebaseFunctionsApp extends core_1.Unit_TypescriptLib {
|
|
17
|
-
async __onUnitWatchCompiled(units) {
|
|
18
|
-
if (units.some(unit => this.runtime.unitDependencyNames.includes(unit.runtime.dependencyName))) {
|
|
19
|
-
this.setStatus('Compiling', 'start');
|
|
20
|
-
try {
|
|
21
|
-
await this.compileImpl();
|
|
22
|
-
await this.copyAssetsToOutput();
|
|
23
|
-
await this.createDependenciesDir();
|
|
24
|
-
this.setStatus('Compiled', 'end');
|
|
25
|
-
}
|
|
26
|
-
catch (e) {
|
|
27
|
-
this.setErrorStatus('Compilation Error', e);
|
|
28
|
-
this.logError(e);
|
|
29
|
-
// throw e;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
constructor(config) {
|
|
34
|
-
super(config);
|
|
35
|
-
this.emulatorLogStrings = {
|
|
36
|
-
error: consts_4.firebaseFunctionEmulator_ErrorStrings,
|
|
37
|
-
warning: consts_4.firebaseFunctionEmulator_WarningStrings,
|
|
38
|
-
};
|
|
39
|
-
this.addToClassStack(Unit_FirebaseFunctionsApp);
|
|
40
|
-
this.logger.setLogTransformer(log => {
|
|
41
|
-
const prefix = ts_common_1._logger_logPrefixes.find(prefix => log.includes(prefix));
|
|
42
|
-
if (!prefix)
|
|
43
|
-
return log;
|
|
44
|
-
return log.substring(log.indexOf(prefix) + prefix.length);
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
async init(setInitialized = true) {
|
|
48
|
-
await super.init(false);
|
|
49
|
-
// only sign on listeners when the unit is being initialized
|
|
50
|
-
runner_dispatchers_1.dispatcher_WatchReady.removeListener(this);
|
|
51
|
-
runner_dispatchers_1.dispatcher_UnitWatchCompile.addListener(this);
|
|
52
|
-
if (setInitialized)
|
|
53
|
-
this.setStatus('Initialized');
|
|
54
|
-
}
|
|
55
|
-
//######################### Phase Implementations #########################
|
|
56
|
-
async resolveConfigs() {
|
|
57
|
-
await this.resolveFunctionsRC();
|
|
58
|
-
await this.resolveConfigDir();
|
|
59
|
-
await this.resolveFunctionsRuntimeConfig();
|
|
60
|
-
await this.resolveFunctionsJSON();
|
|
61
|
-
}
|
|
62
|
-
async compile() {
|
|
63
|
-
this.setStatus('Compiling', 'start');
|
|
64
|
-
try {
|
|
65
|
-
await this.resolveTSConfig();
|
|
66
|
-
await this.clearOutputDir();
|
|
67
|
-
await this.createAppVersionFile();
|
|
68
|
-
await this.compileImpl();
|
|
69
|
-
await this.copyAssetsToOutput();
|
|
70
|
-
await this.createDependenciesDir();
|
|
71
|
-
await this.copyPackageJSONToOutput();
|
|
72
|
-
this.setStatus('Compiled', 'end');
|
|
73
|
-
}
|
|
74
|
-
catch (e) {
|
|
75
|
-
this.setErrorStatus('Compilation Error', e);
|
|
76
|
-
throw e;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
async launch() {
|
|
80
|
-
this.setStatus('Launching');
|
|
81
|
-
await (0, ts_common_1.sleep)(2 * ts_common_1.Second * Unit_FirebaseFunctionsApp.staggerCount++);
|
|
82
|
-
await this.releasePorts();
|
|
83
|
-
await Promise.all([
|
|
84
|
-
this.runProxy(),
|
|
85
|
-
this.runEmulator(),
|
|
86
|
-
]);
|
|
87
|
-
}
|
|
88
|
-
async deployBackend() {
|
|
89
|
-
await this.deployImpl();
|
|
90
|
-
}
|
|
91
|
-
//######################### ResolveConfig Logic #########################
|
|
92
|
-
getEnvConfig() {
|
|
93
|
-
const env = params_1.RuntimeParams.environment;
|
|
94
|
-
const envConfig = this.config.firebaseConfig.envs.find(_env => _env.env === env);
|
|
95
|
-
if (!envConfig)
|
|
96
|
-
throw new ts_common_1.ImplementationMissingException(`Missing EnvConfig for env ${env} in unit ${this.config.label}`);
|
|
97
|
-
return envConfig;
|
|
98
|
-
}
|
|
99
|
-
async resolveFunctionsRC() {
|
|
100
|
-
const envConfig = this.getEnvConfig();
|
|
101
|
-
const rcConfig = { projects: { default: envConfig.projectId } };
|
|
102
|
-
const targetPath = `${this.runtime.pathTo.pkg}/${consts_1.CONST_FirebaseRC}`;
|
|
103
|
-
await fs_1.promises.writeFile(targetPath, JSON.stringify(rcConfig, null, 2), { encoding: 'utf-8' });
|
|
104
|
-
}
|
|
105
|
-
async resolveProxyFile() {
|
|
106
|
-
var _a, _b, _c;
|
|
107
|
-
const envConfig = this.getEnvConfig();
|
|
108
|
-
const defaultFiles = consts_2.MemKey_DefaultFiles.get();
|
|
109
|
-
const targetPath = `${this.runtime.pathTo.pkg}/src/main/proxy.ts`;
|
|
110
|
-
const path = (_a = defaultFiles === null || defaultFiles === void 0 ? void 0 : defaultFiles.backend) === null || _a === void 0 ? void 0 : _a.proxy;
|
|
111
|
-
if (!path)
|
|
112
|
-
return;
|
|
113
|
-
let fileContent = await fs_1.promises.readFile(path, { encoding: 'utf-8' });
|
|
114
|
-
fileContent = fileContent.replace(/PROJECT_ID/g, `${envConfig.projectId}`);
|
|
115
|
-
fileContent = fileContent.replace(/PROXY_PORT/g, `${this.config.firebaseConfig.basePort}`);
|
|
116
|
-
fileContent = fileContent.replace(/SERVER_PORT/g, `${this.config.firebaseConfig.basePort + 1}`);
|
|
117
|
-
fileContent = fileContent.replace(/PATH_TO_SSL_KEY/g, `${(_b = this.config.firebaseConfig.ssl) === null || _b === void 0 ? void 0 : _b.pathToKey}`);
|
|
118
|
-
fileContent = fileContent.replace(/PATH_TO_SSL_CERTIFICATE/g, `${(_c = this.config.firebaseConfig.ssl) === null || _c === void 0 ? void 0 : _c.pathToCertificate}`);
|
|
119
|
-
await fs_1.promises.writeFile(targetPath, fileContent, { encoding: 'utf-8' });
|
|
120
|
-
}
|
|
121
|
-
async resolveConfigDir() {
|
|
122
|
-
//Create the dir if it doesn't exist
|
|
123
|
-
const pathToFirebaseConfigFolder = `${this.runtime.pathTo.pkg}/${this.config.firebaseConfig.pathToFirebaseConfig}`;
|
|
124
|
-
try {
|
|
125
|
-
await fs_1.promises.access(pathToFirebaseConfigFolder);
|
|
126
|
-
}
|
|
127
|
-
catch (e) {
|
|
128
|
-
await fs_1.promises.mkdir(pathToFirebaseConfigFolder, { recursive: true });
|
|
129
|
-
}
|
|
130
|
-
//Fill config dir with relevant files for each file that doesn't exist
|
|
131
|
-
const defaultFiles = RunnerParams_1.MemKey_ProjectConfig.get().defaultFileRoutes;
|
|
132
|
-
if (!defaultFiles) {
|
|
133
|
-
this.logError('No defaultFileRoutes in project config');
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
await Promise.all(consts_2.Const_FirebaseConfigKeys.map(async (firebaseConfigKey) => {
|
|
137
|
-
var _a;
|
|
138
|
-
const pathToConfigFile = `${pathToFirebaseConfigFolder}/${consts_2.Const_FirebaseDefaultsKeyToFile[firebaseConfigKey]}`;
|
|
139
|
-
try {
|
|
140
|
-
await fs_1.promises.access(pathToConfigFile);
|
|
141
|
-
}
|
|
142
|
-
catch (e) {
|
|
143
|
-
const path = (_a = defaultFiles.firebaseConfig) === null || _a === void 0 ? void 0 : _a[firebaseConfigKey];
|
|
144
|
-
if (!path)
|
|
145
|
-
return;
|
|
146
|
-
const defaultFileContent = await fs_1.promises.readFile(path, { encoding: 'utf-8' });
|
|
147
|
-
await fs_1.promises.writeFile(pathToConfigFile, defaultFileContent, { encoding: 'utf-8' });
|
|
148
|
-
}
|
|
149
|
-
}));
|
|
150
|
-
}
|
|
151
|
-
async resolveFunctionsJSON() {
|
|
152
|
-
var _a, _b;
|
|
153
|
-
const envConfig = this.getEnvConfig();
|
|
154
|
-
const targetPath = `${this.runtime.pathTo.pkg}/${consts_1.CONST_FirebaseJSON}`;
|
|
155
|
-
let fileContent;
|
|
156
|
-
if (envConfig.isLocal) {
|
|
157
|
-
const port = this.config.firebaseConfig.basePort;
|
|
158
|
-
fileContent = {
|
|
159
|
-
database: {
|
|
160
|
-
rules: `${this.config.firebaseConfig.pathToFirebaseConfig}/database.rules.json`
|
|
161
|
-
},
|
|
162
|
-
firestore: {
|
|
163
|
-
rules: `${this.config.firebaseConfig.pathToFirebaseConfig}/firestore.rules`,
|
|
164
|
-
indexes: `${this.config.firebaseConfig.pathToFirebaseConfig}/firestore.indexes.json`
|
|
165
|
-
},
|
|
166
|
-
storage: {
|
|
167
|
-
rules: `${this.config.firebaseConfig.pathToFirebaseConfig}/storage.rules`
|
|
168
|
-
},
|
|
169
|
-
remoteconfig: {
|
|
170
|
-
template: `${this.config.firebaseConfig.pathToFirebaseConfig}/remoteconfig.template.json`
|
|
171
|
-
},
|
|
172
|
-
functions: {
|
|
173
|
-
ignore: (_a = this.config.firebaseConfig.functions) === null || _a === void 0 ? void 0 : _a.ignore,
|
|
174
|
-
source: '.',
|
|
175
|
-
predeploy: [
|
|
176
|
-
'echo "Thunderstorm - Local environment is not deployable... Aborting..." && exit 2'
|
|
177
|
-
]
|
|
178
|
-
},
|
|
179
|
-
emulators: {
|
|
180
|
-
functions: { port: port + 1 },
|
|
181
|
-
database: { port: port + 2 },
|
|
182
|
-
firestore: {
|
|
183
|
-
port: port + 3,
|
|
184
|
-
websocketPort: port + 4
|
|
185
|
-
},
|
|
186
|
-
pubsub: { port: port + 5 },
|
|
187
|
-
storage: { port: port + 6 },
|
|
188
|
-
auth: { port: port + 7 },
|
|
189
|
-
ui: { port: port + 8, enabled: true },
|
|
190
|
-
hub: { port: port + 9 },
|
|
191
|
-
logging: { port: port + 10 }
|
|
192
|
-
}
|
|
193
|
-
};
|
|
194
|
-
}
|
|
195
|
-
else {
|
|
196
|
-
fileContent = {
|
|
197
|
-
functions: {
|
|
198
|
-
source: this.config.output.replace(`${this.config.pathToPackage}/`, ''),
|
|
199
|
-
ignore: (_b = this.config.firebaseConfig.functions) === null || _b === void 0 ? void 0 : _b.ignore
|
|
200
|
-
}
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
|
-
await fs_1.promises.writeFile(targetPath, JSON.stringify(fileContent, null, 2), { encoding: 'utf-8' });
|
|
204
|
-
}
|
|
205
|
-
async resolveFunctionsRuntimeConfig() {
|
|
206
|
-
const envConfig = this.getEnvConfig();
|
|
207
|
-
const targetPath = `${this.runtime.pathTo.pkg}/src/main/config.ts`;
|
|
208
|
-
const beConfig = { name: envConfig.env };
|
|
209
|
-
const fileContent = `${envConfig.isLocal ? '// @ts-ignore\nprocess.env[\'NODE_TLS_REJECT_UNAUTHORIZED\'] = 0;\n' : ''}
|
|
210
|
-
export const Environment = ${JSON.stringify(beConfig)};`;
|
|
211
|
-
await fs_1.promises.writeFile(targetPath, fileContent, { encoding: 'utf-8' });
|
|
212
|
-
}
|
|
213
|
-
//######################### Compile Logic #########################
|
|
214
|
-
async createAppVersionFile() {
|
|
215
|
-
//Writing the file to the package source instead of the output is fine,
|
|
216
|
-
//copyAssetsToOutput will move the file to output
|
|
217
|
-
const targetPath = `${this.runtime.pathTo.pkg}/src/main/${CONST_VersionApp}`;
|
|
218
|
-
const appVersion = RunnerParams_1.MemKey_ProjectConfig.get().projectVersion;
|
|
219
|
-
const fileContent = JSON.stringify({ version: appVersion }, null, 2);
|
|
220
|
-
await fs_1.promises.writeFile(targetPath, fileContent, { encoding: 'utf-8' });
|
|
221
|
-
}
|
|
222
|
-
async createDependenciesDir() {
|
|
223
|
-
var _a;
|
|
224
|
-
//Gather units that are dependencies of this unit
|
|
225
|
-
const dependencies = (0, ts_common_1._keys)((_a = this.packageJson.root.dependencies) !== null && _a !== void 0 ? _a : {});
|
|
226
|
-
const runner = consts_3.MemKey_PhaseRunner.get();
|
|
227
|
-
const tsLibUnits = runner.getUnits().filter(unit => unit instanceof core_1.Unit_TypescriptLib);
|
|
228
|
-
const dependencyUnits = tsLibUnits.filter(unit => {
|
|
229
|
-
const unitPJName = unit.packageJson.template.name;
|
|
230
|
-
return dependencies.includes(unitPJName);
|
|
231
|
-
});
|
|
232
|
-
if (!dependencyUnits.length)
|
|
233
|
-
return;
|
|
234
|
-
const packageJsonConverter = (pj) => {
|
|
235
|
-
var _a;
|
|
236
|
-
const finalPJ = (0, ts_common_1.deepClone)(pj);
|
|
237
|
-
(_a = finalPJ.dependencies) !== null && _a !== void 0 ? _a : (finalPJ.dependencies = {});
|
|
238
|
-
(0, ts_common_1._keys)(finalPJ.dependencies).reduce((acc, packageName) => {
|
|
239
|
-
const unit = dependencyUnits.find(unit => unit.packageJson.template.name === packageName);
|
|
240
|
-
if (!unit)
|
|
241
|
-
return acc;
|
|
242
|
-
acc[packageName] = `file:.dependencies/${unit.config.key}`;
|
|
243
|
-
return acc;
|
|
244
|
-
}, finalPJ.dependencies);
|
|
245
|
-
return finalPJ;
|
|
246
|
-
};
|
|
247
|
-
await Promise.all(dependencyUnits.map(async (unit) => {
|
|
248
|
-
//Copy dependency unit output into this units output/.dependency dir
|
|
249
|
-
const dependencyOutputPath = `${unit.runtime.pathTo.output}/`;
|
|
250
|
-
const targetPath = `${this.runtime.pathTo.output}/.dependencies/${unit.config.key}/`;
|
|
251
|
-
const pjTargetPath = `${targetPath}/${consts_1.CONST_PackageJSON}`;
|
|
252
|
-
await this.allocateCommando()
|
|
253
|
-
.append(`mkdir -p ${targetPath}`)
|
|
254
|
-
.append(`rsync -a --delete ${dependencyOutputPath} ${targetPath}`)
|
|
255
|
-
.execute();
|
|
256
|
-
//Copy units dependency package into newly created dir
|
|
257
|
-
const dependencyPJ = packageJsonConverter(unit.packageJson.dist);
|
|
258
|
-
const fileContent = JSON.stringify(dependencyPJ, null, 2);
|
|
259
|
-
await fs_1.promises.writeFile(pjTargetPath, fileContent, { encoding: 'utf-8' });
|
|
260
|
-
}));
|
|
261
|
-
this.packageJson.dist = packageJsonConverter(this.packageJson.dist);
|
|
262
|
-
}
|
|
263
|
-
//######################### Launch Logic #########################
|
|
264
|
-
async releasePorts() {
|
|
265
|
-
const commando = this.allocateCommando(nvm_1.Commando_NVM).applyNVM();
|
|
266
|
-
const allPorts = Array.from({ length: 10 }, (_, i) => `${this.config.firebaseConfig.basePort + i}`);
|
|
267
|
-
await commando.setUID(this.config.key)
|
|
268
|
-
.append(`array=($(lsof -ti:${allPorts.join(',')}))`)
|
|
269
|
-
.append(`((\${#array[@]} > 0)) && kill -9 "\${array[@]}"`)
|
|
270
|
-
.append('echo ')
|
|
271
|
-
.execute();
|
|
272
|
-
}
|
|
273
|
-
async runProxy() {
|
|
274
|
-
await this.resolveProxyFile();
|
|
275
|
-
const commando = this.allocateCommando(nvm_1.Commando_NVM).applyNVM()
|
|
276
|
-
.cd(this.runtime.pathTo.pkg)
|
|
277
|
-
.append('ts-node src/main/proxy.ts');
|
|
278
|
-
await this.executeAsyncCommando(commando);
|
|
279
|
-
this.logWarning('PROXY TERMINATED');
|
|
280
|
-
}
|
|
281
|
-
async runEmulator() {
|
|
282
|
-
const commando = this.allocateCommando(nvm_1.Commando_NVM).applyNVM()
|
|
283
|
-
.setUID(this.config.key)
|
|
284
|
-
.cd(this.runtime.pathTo.pkg)
|
|
285
|
-
.setLogLevelFilter((log, type) => {
|
|
286
|
-
if (this.emulatorLogStrings.error.some(errStr => log.includes(errStr)))
|
|
287
|
-
return ts_common_1.LogLevel.Error;
|
|
288
|
-
if (this.emulatorLogStrings.warning.some(warnStr => log.includes(warnStr)))
|
|
289
|
-
return ts_common_1.LogLevel.Warning;
|
|
290
|
-
})
|
|
291
|
-
.onLog(/.*Emulator Hub running.*/, () => this.setStatus('Launch Complete'))
|
|
292
|
-
.append(`firebase emulators:start --export-on-exit --import=.trash/data ${params_1.RuntimeParams.debugBackend ? `--inspect-functions ${this.config.firebaseConfig.debugPort}` : ''}`);
|
|
293
|
-
await this.executeAsyncCommando(commando);
|
|
294
|
-
this.logWarning('EMULATORS TERMINATED');
|
|
295
|
-
}
|
|
296
|
-
//######################### Deploy Logic #########################
|
|
297
|
-
async deployImpl() {
|
|
298
|
-
const commando = this.allocateCommando(nvm_1.Commando_NVM).applyNVM()
|
|
299
|
-
.cd(this.runtime.pathTo.output)
|
|
300
|
-
.ls()
|
|
301
|
-
.cat('package.json')
|
|
302
|
-
.cat('index.js')
|
|
303
|
-
.cd(this.runtime.pathTo.pkg)
|
|
304
|
-
.append(`firebase --debug deploy --only functions --force`);
|
|
305
|
-
return this.executeAsyncCommando(commando);
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
exports.Unit_FirebaseFunctionsApp = Unit_FirebaseFunctionsApp;
|
|
309
|
-
Unit_FirebaseFunctionsApp.staggerCount = 0;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { Unit_TypescriptLib, Unit_TypescriptLib_Config } from '../core';
|
|
2
|
-
import { FirebasePackageConfig } from '../../../core/types';
|
|
3
|
-
import { UnitPhaseImplementor } from '../types';
|
|
4
|
-
import { Phase_DeployFrontend, Phase_Launch, Phase_ResolveConfigs } from '../../phase';
|
|
5
|
-
export type Unit_FirebaseHostingApp_Config = Unit_TypescriptLib_Config & {
|
|
6
|
-
firebaseConfig: FirebasePackageConfig;
|
|
7
|
-
sources?: string[];
|
|
8
|
-
};
|
|
9
|
-
export declare class Unit_FirebaseHostingApp<C extends Unit_FirebaseHostingApp_Config = Unit_FirebaseHostingApp_Config> extends Unit_TypescriptLib<C> implements UnitPhaseImplementor<[Phase_ResolveConfigs, Phase_Launch, Phase_DeployFrontend]> {
|
|
10
|
-
constructor(config: Unit_FirebaseHostingApp<C>['config']);
|
|
11
|
-
protected init(setInitialized?: boolean): Promise<void>;
|
|
12
|
-
resolveConfigs(): Promise<void>;
|
|
13
|
-
compile(): Promise<void>;
|
|
14
|
-
launch(): Promise<void>;
|
|
15
|
-
deployFrontend(): Promise<void>;
|
|
16
|
-
private getEnvConfig;
|
|
17
|
-
private resolveHostingRC;
|
|
18
|
-
private resolveHostingJSON;
|
|
19
|
-
private resolveHostingRuntimeConfig;
|
|
20
|
-
protected compileImpl(): Promise<void>;
|
|
21
|
-
private createAppVersionFile;
|
|
22
|
-
private runApp;
|
|
23
|
-
private deployImpl;
|
|
24
|
-
}
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Unit_FirebaseHostingApp = void 0;
|
|
4
|
-
const core_1 = require("../core");
|
|
5
|
-
const params_1 = require("../../../core/params/params");
|
|
6
|
-
const ts_common_1 = require("@nu-art/ts-common");
|
|
7
|
-
const fs_1 = require("fs");
|
|
8
|
-
const consts_1 = require("../../../core/consts");
|
|
9
|
-
const RunnerParams_1 = require("../../phase-runner/RunnerParams");
|
|
10
|
-
const tools_1 = require("@nu-art/commando/shell/tools");
|
|
11
|
-
const runner_dispatchers_1 = require("../runner-dispatchers");
|
|
12
|
-
const nvm_1 = require("@nu-art/commando/shell/plugins/nvm");
|
|
13
|
-
const basic_1 = require("@nu-art/commando/shell/plugins/basic");
|
|
14
|
-
const CONST_VersionApp = 'version-app.json';
|
|
15
|
-
class Unit_FirebaseHostingApp extends core_1.Unit_TypescriptLib {
|
|
16
|
-
constructor(config) {
|
|
17
|
-
super(config);
|
|
18
|
-
this.addToClassStack(Unit_FirebaseHostingApp);
|
|
19
|
-
}
|
|
20
|
-
async init(setInitialized = true) {
|
|
21
|
-
await super.init(setInitialized);
|
|
22
|
-
runner_dispatchers_1.dispatcher_WatchReady.removeListener(this);
|
|
23
|
-
if (!this.config.firebaseConfig.hostingPort)
|
|
24
|
-
throw new ts_common_1.BadImplementationException(`Unit ${this.config.label} missing hosting port in firebaseConfig`);
|
|
25
|
-
}
|
|
26
|
-
//######################### Phase Implementations #########################
|
|
27
|
-
async resolveConfigs() {
|
|
28
|
-
await this.resolveHostingRC();
|
|
29
|
-
await this.resolveHostingJSON();
|
|
30
|
-
await this.resolveHostingRuntimeConfig();
|
|
31
|
-
}
|
|
32
|
-
async compile() {
|
|
33
|
-
this.setStatus('Compiling', 'start');
|
|
34
|
-
try {
|
|
35
|
-
await this.resolveTSConfig();
|
|
36
|
-
await this.clearOutputDir();
|
|
37
|
-
await this.createAppVersionFile();
|
|
38
|
-
await this.compileImpl();
|
|
39
|
-
this.setStatus('Compiled', 'end');
|
|
40
|
-
}
|
|
41
|
-
catch (e) {
|
|
42
|
-
this.setErrorStatus('Compilation Error', e);
|
|
43
|
-
throw e;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
async launch() {
|
|
47
|
-
this.setStatus('Launching');
|
|
48
|
-
await this.runApp();
|
|
49
|
-
}
|
|
50
|
-
async deployFrontend() {
|
|
51
|
-
await this.deployImpl();
|
|
52
|
-
}
|
|
53
|
-
//######################### ResolveConfig Logic #########################
|
|
54
|
-
getEnvConfig() {
|
|
55
|
-
const env = params_1.RuntimeParams.environment;
|
|
56
|
-
const envConfig = this.config.firebaseConfig.envs.find(_env => _env.env === env);
|
|
57
|
-
if (!envConfig)
|
|
58
|
-
throw new ts_common_1.ImplementationMissingException(`Missing EnvConfig for env ${env} in unit ${this.config.label}`);
|
|
59
|
-
return envConfig;
|
|
60
|
-
}
|
|
61
|
-
async resolveHostingRC() {
|
|
62
|
-
const envConfig = this.getEnvConfig();
|
|
63
|
-
const rcConfig = { projects: { default: envConfig.projectId } };
|
|
64
|
-
const targetPath = `${this.runtime.pathTo.pkg}/${consts_1.CONST_FirebaseRC}`;
|
|
65
|
-
await fs_1.promises.writeFile(targetPath, JSON.stringify(rcConfig, null, 2), { encoding: 'utf-8' });
|
|
66
|
-
}
|
|
67
|
-
async resolveHostingJSON() {
|
|
68
|
-
const envConfig = this.getEnvConfig();
|
|
69
|
-
const targetPath = `${this.runtime.pathTo.pkg}/${consts_1.CONST_FirebaseJSON}`;
|
|
70
|
-
let fileContent;
|
|
71
|
-
if (envConfig.isLocal)
|
|
72
|
-
fileContent = {};
|
|
73
|
-
else
|
|
74
|
-
fileContent = { hosting: this.config.firebaseConfig.hosting };
|
|
75
|
-
await fs_1.promises.writeFile(targetPath, JSON.stringify(fileContent, null, 2), { encoding: 'utf-8' });
|
|
76
|
-
}
|
|
77
|
-
async resolveHostingRuntimeConfig() {
|
|
78
|
-
var _a;
|
|
79
|
-
const envConfig = this.getEnvConfig();
|
|
80
|
-
const emulatorConfig = {
|
|
81
|
-
hostname: 'localhost',
|
|
82
|
-
port: this.config.firebaseConfig.basePort + 2,
|
|
83
|
-
};
|
|
84
|
-
const feConfig = Object.assign({ label: envConfig.env.toLowerCase(), ModuleFE_Thunderstorm: {
|
|
85
|
-
appName: `${this.config.key} - (${envConfig.env})`
|
|
86
|
-
}, ModuleFE_XHR: {
|
|
87
|
-
origin: envConfig.isLocal ? `https://localhost:${this.config.firebaseConfig.basePort}` : envConfig.backend.url,
|
|
88
|
-
timeout: envConfig.backend.timeout || 30000,
|
|
89
|
-
compress: envConfig.backend.compress || false,
|
|
90
|
-
minLogLevel: envConfig.backend.minLogLevel || false,
|
|
91
|
-
}, ModuleFE_FirebaseListener: {
|
|
92
|
-
emulatorConfig: envConfig.isLocal ? emulatorConfig : undefined,
|
|
93
|
-
firebaseConfig: (_a = envConfig.firebase.listener) === null || _a === void 0 ? void 0 : _a.config
|
|
94
|
-
} }, envConfig.otherConfig);
|
|
95
|
-
const targetPath = (0, tools_1.convertToFullPath)(`${this.config.pathToPackage}/src/main/config.ts`);
|
|
96
|
-
const fileContent = `export const config = ${JSON.stringify(feConfig, null, 2)};`;
|
|
97
|
-
await fs_1.promises.writeFile(targetPath, fileContent, { encoding: 'utf-8' });
|
|
98
|
-
}
|
|
99
|
-
//######################### Compile Logic #########################
|
|
100
|
-
async compileImpl() {
|
|
101
|
-
const commando = this.allocateCommando(nvm_1.Commando_NVM, basic_1.Commando_Basic).applyNVM()
|
|
102
|
-
.cd(this.runtime.pathTo.pkg)
|
|
103
|
-
.append(`ENV=${params_1.RuntimeParams.environment} npm run build`);
|
|
104
|
-
await this.executeAsyncCommando(commando);
|
|
105
|
-
}
|
|
106
|
-
async createAppVersionFile() {
|
|
107
|
-
//Writing the file to the package source instead of the output is fine,
|
|
108
|
-
//Webpack bundles files into the output automatically!
|
|
109
|
-
const targetPath = `${this.runtime.pathTo.pkg}/src/main/${CONST_VersionApp}`;
|
|
110
|
-
const appVersion = RunnerParams_1.MemKey_ProjectConfig.get().projectVersion;
|
|
111
|
-
const fileContent = JSON.stringify({ version: appVersion }, null, 2);
|
|
112
|
-
await fs_1.promises.writeFile(targetPath, fileContent, { encoding: 'utf-8' });
|
|
113
|
-
}
|
|
114
|
-
//######################### Launch Logic #########################
|
|
115
|
-
async runApp() {
|
|
116
|
-
const commando = this.allocateCommando(nvm_1.Commando_NVM).applyNVM()
|
|
117
|
-
.setUID(this.config.key)
|
|
118
|
-
.cd(this.runtime.pathTo.pkg)
|
|
119
|
-
.setLogLevelFilter((log, type) => {
|
|
120
|
-
if (log.toLowerCase().includes('<i>'))
|
|
121
|
-
return ts_common_1.LogLevel.Info;
|
|
122
|
-
})
|
|
123
|
-
.append(`array=($(lsof -ti:${[this.config.firebaseConfig.hostingPort].join(',')}))`)
|
|
124
|
-
.append(`((\${#array[@]} > 0)) && kill -9 "\${array[@]}"`)
|
|
125
|
-
.append('echo ')
|
|
126
|
-
.append('npm run start');
|
|
127
|
-
await this.executeAsyncCommando(commando);
|
|
128
|
-
this.logWarning('HOSTING TERMINATED');
|
|
129
|
-
}
|
|
130
|
-
//######################### Deploy Logic #########################
|
|
131
|
-
async deployImpl() {
|
|
132
|
-
const commando = this.allocateCommando(nvm_1.Commando_NVM).applyNVM()
|
|
133
|
-
.cd(this.runtime.pathTo.pkg)
|
|
134
|
-
.append(`firebase --debug deploy --only hosting`);
|
|
135
|
-
return this.executeAsyncCommando(commando);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
exports.Unit_FirebaseHostingApp = Unit_FirebaseHostingApp;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.firebaseFunctionEmulator_WarningStrings = exports.firebaseFunctionEmulator_ErrorStrings = void 0;
|
|
4
|
-
exports.firebaseFunctionEmulator_ErrorStrings = [
|
|
5
|
-
'functions: Failed',
|
|
6
|
-
];
|
|
7
|
-
exports.firebaseFunctionEmulator_WarningStrings = [
|
|
8
|
-
'⚠',
|
|
9
|
-
];
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./Unit_FirebaseHostingApp"), exports);
|
|
18
|
-
__exportStar(require("./Unit_FirebaseFunctionsApp"), exports);
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.dispatcher_UnitWatchCompile = exports.dispatcher_WatchReady = void 0;
|
|
4
|
-
const PhaseRunnerDispatcher_1 = require("../phase-runner/PhaseRunnerDispatcher");
|
|
5
|
-
exports.dispatcher_WatchReady = new PhaseRunnerDispatcher_1.PhaseRunnerDispatcher('__onWatchReady');
|
|
6
|
-
exports.dispatcher_UnitWatchCompile = new PhaseRunnerDispatcher_1.PhaseRunnerDispatcher('__onUnitWatchCompiled');
|