@nu-art/build-and-install 0.204.100 → 0.204.101
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build-and-install.js +1 -1
- package/defaults/.firebase_config/database.rules.json +16 -3
- package/defaults/backend-proxy/proxy._ts +10 -6
- package/package.json +1 -1
- package/v2/unit/core/Unit_TypescriptProject.js +1 -1
- package/v2/unit/firebase-units/Unit_FirebaseHostingApp.js +4 -8
- package/core/package/generate.d.ts +0 -24
- package/core/package/generate.js +0 -180
package/build-and-install.js
CHANGED
|
@@ -5,7 +5,7 @@ const params_1 = require("./core/params/params");
|
|
|
5
5
|
const PhaseRunner_1 = require("./v2/phase-runner/PhaseRunner");
|
|
6
6
|
const thunderstorm_1 = require("./v2/unit/thunderstorm");
|
|
7
7
|
ts_common_1.DebugFlag.DefaultLogLevel = params_1.RuntimeParams.debug ? ts_common_1.LogLevel.Debug : ts_common_1.LogLevel.Info;
|
|
8
|
-
const runner = new PhaseRunner_1.PhaseRunner('./.config/project-config
|
|
8
|
+
const runner = new PhaseRunner_1.PhaseRunner('./.config/project-config.ts');
|
|
9
9
|
if (params_1.RuntimeParams.runWithThunderstorm)
|
|
10
10
|
runner.registerUnits(thunderstorm_1.allTSUnits);
|
|
11
11
|
runner
|
|
@@ -1,7 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"rules": {
|
|
3
3
|
".read": false,
|
|
4
|
-
".write": false
|
|
4
|
+
".write": false,
|
|
5
|
+
"state": {
|
|
6
|
+
"ModuleBE_SyncManager": {
|
|
7
|
+
"syncData": {
|
|
8
|
+
".read": true,
|
|
9
|
+
".write": false
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"ModuleBE_FocusedObject": {
|
|
13
|
+
"focusedData": {
|
|
14
|
+
".read": true,
|
|
15
|
+
".write": false
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
5
19
|
}
|
|
6
|
-
}
|
|
7
|
-
|
|
20
|
+
}
|
|
@@ -16,20 +16,24 @@ _express.all('*', (req, res) => {
|
|
|
16
16
|
|
|
17
17
|
console.log(`PROXY ${counter} - [${req.method}] ${url}`);
|
|
18
18
|
|
|
19
|
+
const handleError = (error: any) => {
|
|
20
|
+
console.log(`ERROR calling: ${url}`, error);
|
|
21
|
+
};
|
|
22
|
+
|
|
19
23
|
try {
|
|
20
24
|
let reqContent;
|
|
21
25
|
if (req.method === 'POST') {
|
|
22
|
-
reqContent = request.post({uri: url, body: req.body});
|
|
26
|
+
reqContent = request.post({uri: url, body: req.body}, handleError);
|
|
23
27
|
} else if (req.method === 'PUT') {
|
|
24
|
-
reqContent = request.put({uri: url, body: req.body});
|
|
28
|
+
reqContent = request.put({uri: url, body: req.body}, handleError);
|
|
25
29
|
} else if (req.method === 'GET') {
|
|
26
|
-
reqContent = request.get(url);
|
|
30
|
+
reqContent = request.get(url, handleError);
|
|
27
31
|
} else if (req.method === 'DELETE') {
|
|
28
|
-
reqContent = request.delete(url);
|
|
32
|
+
reqContent = request.delete(url, handleError);
|
|
29
33
|
} else if (req.method === 'HEAD') {
|
|
30
|
-
reqContent = request.head(url);
|
|
34
|
+
reqContent = request.head(url, handleError);
|
|
31
35
|
} else {
|
|
32
|
-
reqContent = request(url);
|
|
36
|
+
reqContent = request(url, handleError);
|
|
33
37
|
}
|
|
34
38
|
|
|
35
39
|
req.pipe(reqContent).pipe(res, {end: true});
|
package/package.json
CHANGED
|
@@ -116,7 +116,7 @@ class Unit_TypescriptProject extends Unit_Typescript_1.Unit_Typescript {
|
|
|
116
116
|
const onUnitChange = (path) => {
|
|
117
117
|
const unit = this.findUnit(pathDeclarations, path);
|
|
118
118
|
// @ts-ignore - FIXME: should be a better way
|
|
119
|
-
unit.setStatus('
|
|
119
|
+
unit.setStatus('Dirty');
|
|
120
120
|
//add unit to set
|
|
121
121
|
units.add(unit);
|
|
122
122
|
return unit;
|
|
@@ -81,21 +81,17 @@ class Unit_FirebaseHostingApp extends core_1.Unit_TypescriptLib {
|
|
|
81
81
|
hostname: 'localhost',
|
|
82
82
|
port: this.config.firebaseConfig.basePort + 2,
|
|
83
83
|
};
|
|
84
|
-
const feConfig = {
|
|
85
|
-
ModuleFE_Thunderstorm: {
|
|
84
|
+
const feConfig = Object.assign({ ModuleFE_Thunderstorm: {
|
|
86
85
|
appName: `${this.config.key} - (${envConfig.env})`
|
|
87
|
-
},
|
|
88
|
-
ModuleFE_XHR: {
|
|
86
|
+
}, ModuleFE_XHR: {
|
|
89
87
|
origin: envConfig.isLocal ? `https://localhost:${this.config.firebaseConfig.basePort}` : envConfig.backend.url,
|
|
90
88
|
timeout: envConfig.backend.timeout || 30000,
|
|
91
89
|
compress: envConfig.backend.compress || false,
|
|
92
90
|
minLogLevel: envConfig.backend.minLogLevel || false,
|
|
93
|
-
},
|
|
94
|
-
ModuleFE_FirebaseListener: {
|
|
91
|
+
}, ModuleFE_FirebaseListener: {
|
|
95
92
|
emulatorConfig: envConfig.isLocal ? emulatorConfig : undefined,
|
|
96
93
|
firebaseConfig: (_a = envConfig.firebase.listener) === null || _a === void 0 ? void 0 : _a.config
|
|
97
|
-
}
|
|
98
|
-
};
|
|
94
|
+
} }, envConfig.otherConfig);
|
|
99
95
|
const targetPath = (0, tools_1.convertToFullPath)(`${this.config.pathToPackage}/src/main/config.ts`);
|
|
100
96
|
const fileContent = `export const config = ${JSON.stringify(feConfig, null, 2)};`;
|
|
101
97
|
await fs_1.promises.writeFile(targetPath, fileContent, { encoding: 'utf-8' });
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { FirebaseEnvConfig, Package_FirebaseFunctionsApp, Package_FirebaseHostingAndFunctionApp, Package_FirebaseHostingApp } from '../types';
|
|
2
|
-
export declare function createFirebaseHostingConfig<Env extends string>(pkg: Package_FirebaseHostingApp, env: Env): {
|
|
3
|
-
projects: {
|
|
4
|
-
default: string;
|
|
5
|
-
};
|
|
6
|
-
};
|
|
7
|
-
export declare function createFirebaseFunctionConfig<Env extends string>(pkg: Package_FirebaseHostingApp, env: Env): void;
|
|
8
|
-
export declare function createFirebaseRC<Env extends string>(pkg: Package_FirebaseHostingApp | Package_FirebaseFunctionsApp, env: Env): {
|
|
9
|
-
projects: {
|
|
10
|
-
default: string;
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
export declare function writeToFile_HostingFirebaseJSON<Env extends string>(pkg: Package_FirebaseHostingApp | Package_FirebaseHostingAndFunctionApp, env: Env): Promise<void>;
|
|
14
|
-
export declare function writeToFile_HostingFirebaseConfigJSON<Env extends string>(pkg: Package_FirebaseHostingApp | Package_FirebaseHostingAndFunctionApp, env: Env): Promise<void>;
|
|
15
|
-
export declare function writeToFile_functionFirebaseConfigJSON<Env extends string>(pkg: Package_FirebaseFunctionsApp | Package_FirebaseHostingAndFunctionApp, env: Env): Promise<void>;
|
|
16
|
-
export declare function writeToFile_FunctionFirebaseJSON<Env extends string>(pkg: Package_FirebaseFunctionsApp | Package_FirebaseHostingAndFunctionApp, env: Env): Promise<void>;
|
|
17
|
-
export declare function createFirebaseFullJSON<Env extends string>(pkg: Package_FirebaseHostingAndFunctionApp, env: Env): {
|
|
18
|
-
then<TResult1 = void, TResult2 = never>(onfulfilled?: ((value: void) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): Promise<TResult1 | TResult2>;
|
|
19
|
-
catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null | undefined): Promise<void | TResult>;
|
|
20
|
-
finally(onfinally?: (() => void) | null | undefined): Promise<void>;
|
|
21
|
-
[Symbol.toStringTag]: string;
|
|
22
|
-
};
|
|
23
|
-
export declare function getEnvConfig(pkg: Package_FirebaseHostingApp | Package_FirebaseFunctionsApp | Package_FirebaseHostingAndFunctionApp): FirebaseEnvConfig<string>;
|
|
24
|
-
export declare function generateProxyFile(firebasePkg: Package_FirebaseHostingApp | Package_FirebaseFunctionsApp, pathToFile: string): Promise<void>;
|
package/core/package/generate.js
DELETED
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateProxyFile = exports.getEnvConfig = exports.createFirebaseFullJSON = exports.writeToFile_FunctionFirebaseJSON = exports.writeToFile_functionFirebaseConfigJSON = exports.writeToFile_HostingFirebaseConfigJSON = exports.writeToFile_HostingFirebaseJSON = exports.createFirebaseRC = exports.createFirebaseFunctionConfig = exports.createFirebaseHostingConfig = void 0;
|
|
4
|
-
const ts_common_1 = require("@nu-art/ts-common");
|
|
5
|
-
const fs_1 = require("fs");
|
|
6
|
-
const consts_1 = require("../consts");
|
|
7
|
-
const consts_2 = require("../../defaults/consts");
|
|
8
|
-
const params_1 = require("../params/params");
|
|
9
|
-
function createFirebaseHostingConfig(pkg, env) {
|
|
10
|
-
const envConfig = pkg.envConfig.envs.find(_env => _env.env === env);
|
|
11
|
-
if (!envConfig)
|
|
12
|
-
throw new ts_common_1.BadImplementationException(`Could not find env: ${env}`);
|
|
13
|
-
return {
|
|
14
|
-
projects: {
|
|
15
|
-
default: envConfig.projectId,
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
exports.createFirebaseHostingConfig = createFirebaseHostingConfig;
|
|
20
|
-
function createFirebaseFunctionConfig(pkg, env) {
|
|
21
|
-
const envConfig = pkg.envConfig.envs.find(_env => _env.env === env);
|
|
22
|
-
if (!envConfig)
|
|
23
|
-
throw new ts_common_1.BadImplementationException(`Could not find env: ${env}`);
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
exports.createFirebaseFunctionConfig = createFirebaseFunctionConfig;
|
|
27
|
-
function createFirebaseRC(pkg, env) {
|
|
28
|
-
const envConfig = pkg.envConfig.envs.find(_env => _env.env === env);
|
|
29
|
-
if (!envConfig)
|
|
30
|
-
throw new ts_common_1.BadImplementationException(`Could not find env: ${env}`);
|
|
31
|
-
return {
|
|
32
|
-
projects: {
|
|
33
|
-
default: envConfig.projectId,
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
exports.createFirebaseRC = createFirebaseRC;
|
|
38
|
-
function getHostingConfig(pkg, envConfig) {
|
|
39
|
-
if (envConfig.isLocal)
|
|
40
|
-
return {};
|
|
41
|
-
return {
|
|
42
|
-
hosting: pkg.envConfig.hosting
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
async function writeToFile_HostingFirebaseJSON(pkg, env) {
|
|
46
|
-
const envConfig = pkg.envConfig.envs.find(_env => _env.env === env);
|
|
47
|
-
if (!envConfig)
|
|
48
|
-
throw new ts_common_1.BadImplementationException(`Could not find env: ${env}`);
|
|
49
|
-
const fileContent = getHostingConfig(pkg, envConfig);
|
|
50
|
-
await fs_1.promises.writeFile(`${pkg.path}/${consts_1.CONST_FirebaseJSON}`, JSON.stringify(fileContent, null, 2), { encoding: 'utf-8' });
|
|
51
|
-
}
|
|
52
|
-
exports.writeToFile_HostingFirebaseJSON = writeToFile_HostingFirebaseJSON;
|
|
53
|
-
async function writeToFile_HostingFirebaseConfigJSON(pkg, env) {
|
|
54
|
-
var _a;
|
|
55
|
-
const envConfig = pkg.envConfig.envs.find(_env => _env.env === env);
|
|
56
|
-
if (!envConfig)
|
|
57
|
-
throw new ts_common_1.BadImplementationException(`Could not find env: ${env}`);
|
|
58
|
-
const emulatorConfig = {
|
|
59
|
-
hostname: 'localhost',
|
|
60
|
-
port: pkg.envConfig.basePort + 2,
|
|
61
|
-
};
|
|
62
|
-
const feConfig = {
|
|
63
|
-
ModuleFE_Thunderstorm: {
|
|
64
|
-
appName: `${pkg.name} - (${env})`
|
|
65
|
-
},
|
|
66
|
-
ModuleFE_XHR: {
|
|
67
|
-
origin: envConfig.isLocal ? `https://localhost:${pkg.envConfig.basePort}` : envConfig.backend.url,
|
|
68
|
-
timeout: envConfig.backend.timeout || 30000,
|
|
69
|
-
compress: envConfig.backend.compress || false,
|
|
70
|
-
minLogLevel: envConfig.backend.minLogLevel || false,
|
|
71
|
-
},
|
|
72
|
-
ModuleFE_FirebaseListener: {
|
|
73
|
-
emulatorConfig: envConfig.isLocal ? emulatorConfig : undefined,
|
|
74
|
-
firebaseConfig: (_a = envConfig.firebase.listener) === null || _a === void 0 ? void 0 : _a.config
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
const fileContent = `export const config = ${JSON.stringify(feConfig, null, 2)};`;
|
|
78
|
-
await fs_1.promises.writeFile(`${pkg.path}/src/main/config.ts`, fileContent, { encoding: 'utf-8' });
|
|
79
|
-
}
|
|
80
|
-
exports.writeToFile_HostingFirebaseConfigJSON = writeToFile_HostingFirebaseConfigJSON;
|
|
81
|
-
async function writeToFile_functionFirebaseConfigJSON(pkg, env) {
|
|
82
|
-
const envConfig = pkg.envConfig.envs.find(_env => _env.env === env);
|
|
83
|
-
if (!envConfig)
|
|
84
|
-
throw new ts_common_1.BadImplementationException(`Could not find env: ${env}`);
|
|
85
|
-
const beConfig = {
|
|
86
|
-
name: envConfig.env
|
|
87
|
-
};
|
|
88
|
-
const fileContent = `${envConfig.isLocal ? '// @ts-ignore\nprocess.env[\'NODE_TLS_REJECT_UNAUTHORIZED\'] = 0;\n' : ''}
|
|
89
|
-
export const Environment = ${JSON.stringify(beConfig)};`;
|
|
90
|
-
await fs_1.promises.writeFile(`${pkg.path}/src/main/config.ts`, fileContent, { encoding: 'utf-8' });
|
|
91
|
-
}
|
|
92
|
-
exports.writeToFile_functionFirebaseConfigJSON = writeToFile_functionFirebaseConfigJSON;
|
|
93
|
-
function getFunctionConfig(pkg, envConfig) {
|
|
94
|
-
var _a, _b;
|
|
95
|
-
if (envConfig.isLocal) {
|
|
96
|
-
const port = pkg.envConfig.basePort;
|
|
97
|
-
return {
|
|
98
|
-
database: {
|
|
99
|
-
rules: `${pkg.envConfig.pathToFirebaseConfig}/database.rules.json`
|
|
100
|
-
},
|
|
101
|
-
firestore: {
|
|
102
|
-
rules: `${pkg.envConfig.pathToFirebaseConfig}/firestore.rules`,
|
|
103
|
-
indexes: `${pkg.envConfig.pathToFirebaseConfig}/firestore.indexes.json`
|
|
104
|
-
},
|
|
105
|
-
storage: {
|
|
106
|
-
rules: `${pkg.envConfig.pathToFirebaseConfig}/storage.rules`
|
|
107
|
-
},
|
|
108
|
-
remoteconfig: {
|
|
109
|
-
template: `${pkg.envConfig.pathToFirebaseConfig}/remoteconfig.template.json`
|
|
110
|
-
},
|
|
111
|
-
functions: {
|
|
112
|
-
ignore: (_a = pkg.envConfig.functions) === null || _a === void 0 ? void 0 : _a.ignore,
|
|
113
|
-
source: '.',
|
|
114
|
-
predeploy: [
|
|
115
|
-
'echo "Thunderstorm - Local environment is not deployable... Aborting..." && exit 2'
|
|
116
|
-
]
|
|
117
|
-
},
|
|
118
|
-
emulators: {
|
|
119
|
-
functions: { port: port + 1 },
|
|
120
|
-
database: { port: port + 2 },
|
|
121
|
-
firestore: {
|
|
122
|
-
port: port + 3,
|
|
123
|
-
websocketPort: port + 4
|
|
124
|
-
},
|
|
125
|
-
pubsub: { port: port + 5 },
|
|
126
|
-
storage: { port: port + 6 },
|
|
127
|
-
auth: { port: port + 7 },
|
|
128
|
-
ui: { port: port + 8, enabled: true },
|
|
129
|
-
hub: { port: port + 9 },
|
|
130
|
-
logging: { port: port + 10 }
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
else {
|
|
135
|
-
return {
|
|
136
|
-
functions: {
|
|
137
|
-
source: pkg.output.replace(`${pkg.path}/`, ''),
|
|
138
|
-
ignore: (_b = pkg.envConfig.functions) === null || _b === void 0 ? void 0 : _b.ignore
|
|
139
|
-
}
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
async function writeToFile_FunctionFirebaseJSON(pkg, env) {
|
|
144
|
-
const envConfig = getEnvConfig(pkg);
|
|
145
|
-
const fileContent = getFunctionConfig(pkg, envConfig);
|
|
146
|
-
await fs_1.promises.writeFile(`${pkg.path}/${consts_1.CONST_FirebaseJSON}`, JSON.stringify(fileContent, null, 2), { encoding: 'utf-8' });
|
|
147
|
-
}
|
|
148
|
-
exports.writeToFile_FunctionFirebaseJSON = writeToFile_FunctionFirebaseJSON;
|
|
149
|
-
function createFirebaseFullJSON(pkg, env) {
|
|
150
|
-
const envConfig = pkg.envConfig.envs.find(_env => _env.env === env);
|
|
151
|
-
if (!envConfig)
|
|
152
|
-
throw new ts_common_1.BadImplementationException(`Could not find env: ${env}`);
|
|
153
|
-
const hosting = writeToFile_HostingFirebaseJSON(pkg, env);
|
|
154
|
-
const functions = writeToFile_FunctionFirebaseJSON(pkg, env);
|
|
155
|
-
return Object.assign(Object.assign({}, hosting), functions);
|
|
156
|
-
}
|
|
157
|
-
exports.createFirebaseFullJSON = createFirebaseFullJSON;
|
|
158
|
-
function getEnvConfig(pkg) {
|
|
159
|
-
const env = params_1.RuntimeParams.environment;
|
|
160
|
-
const envConfig = pkg.envConfig.envs.find(_env => _env.env === env);
|
|
161
|
-
if (!envConfig)
|
|
162
|
-
throw new ts_common_1.BadImplementationException(`No env config for env ${env} in package ${pkg.name}`);
|
|
163
|
-
return envConfig;
|
|
164
|
-
}
|
|
165
|
-
exports.getEnvConfig = getEnvConfig;
|
|
166
|
-
async function generateProxyFile(firebasePkg, pathToFile) {
|
|
167
|
-
var _a, _b, _c;
|
|
168
|
-
const envConfig = getEnvConfig(firebasePkg);
|
|
169
|
-
const defaultFiles = consts_2.MemKey_DefaultFiles.get();
|
|
170
|
-
if (!((_a = defaultFiles === null || defaultFiles === void 0 ? void 0 : defaultFiles.backend) === null || _a === void 0 ? void 0 : _a.proxy))
|
|
171
|
-
return;
|
|
172
|
-
let fileContent = await fs_1.promises.readFile(defaultFiles.backend.proxy, { encoding: 'utf-8' });
|
|
173
|
-
fileContent = fileContent.replace(/PROJECT_ID/g, `${envConfig.projectId}`);
|
|
174
|
-
fileContent = fileContent.replace(/PROXY_PORT/g, `${firebasePkg.envConfig.basePort}`);
|
|
175
|
-
fileContent = fileContent.replace(/SERVER_PORT/g, `${firebasePkg.envConfig.basePort + 1}`);
|
|
176
|
-
fileContent = fileContent.replace(/PATH_TO_SSL_KEY/g, `${(_b = firebasePkg.envConfig.ssl) === null || _b === void 0 ? void 0 : _b.pathToKey}`);
|
|
177
|
-
fileContent = fileContent.replace(/PATH_TO_SSL_CERTIFICATE/g, `${(_c = firebasePkg.envConfig.ssl) === null || _c === void 0 ? void 0 : _c.pathToCertificate}`);
|
|
178
|
-
await fs_1.promises.writeFile(pathToFile, fileContent, { encoding: 'utf-8' });
|
|
179
|
-
}
|
|
180
|
-
exports.generateProxyFile = generateProxyFile;
|