@nu-art/build-and-install 0.204.22 → 0.204.24

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.
@@ -1,4 +1,4 @@
1
- import { Package_FirebaseFunctionsApp, Package_FirebaseHostingAndFunctionApp, Package_FirebaseHostingApp } from '../types';
1
+ import { FirebaseEnvConfig, Package_FirebaseFunctionsApp, Package_FirebaseHostingAndFunctionApp, Package_FirebaseHostingApp } from '../types';
2
2
  export declare function createFirebaseHostingConfig<Env extends string>(pkg: Package_FirebaseHostingApp, env: Env): {
3
3
  projects: {
4
4
  default: string;
@@ -20,3 +20,5 @@ export declare function createFirebaseFullJSON<Env extends string>(pkg: Package_
20
20
  finally(onfinally?: (() => void) | null | undefined): Promise<void>;
21
21
  [Symbol.toStringTag]: string;
22
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>;
@@ -1,9 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createFirebaseFullJSON = exports.writeToFile_FunctionFirebaseJSON = exports.writeToFile_functionFirebaseConfigJSON = exports.writeToFile_HostingFirebaseConfigJSON = exports.writeToFile_HostingFirebaseJSON = exports.createFirebaseRC = exports.createFirebaseFunctionConfig = exports.createFirebaseHostingConfig = void 0;
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
4
  const ts_common_1 = require("@nu-art/ts-common");
5
5
  const fs_1 = require("fs");
6
6
  const consts_1 = require("../consts");
7
+ const consts_2 = require("../../defaults/consts");
8
+ const params_1 = require("../params/params");
7
9
  function createFirebaseHostingConfig(pkg, env) {
8
10
  const envConfig = pkg.envConfig.envs.find(_env => _env.env === env);
9
11
  if (!envConfig)
@@ -62,7 +64,7 @@ async function writeToFile_HostingFirebaseConfigJSON(pkg, env) {
62
64
  appName: `${pkg.name} - (${env})`
63
65
  },
64
66
  ModuleFE_XHR: {
65
- origin: envConfig.isLocal ? `https://localhost:${pkg.envConfig.basePort + 1}` : envConfig.backend.url,
67
+ origin: envConfig.isLocal ? `https://localhost:${pkg.envConfig.basePort}` : envConfig.backend.url,
66
68
  timeout: envConfig.backend.timeout || 30000,
67
69
  compress: envConfig.backend.compress || false,
68
70
  minLogLevel: envConfig.backend.minLogLevel || false,
@@ -139,9 +141,7 @@ function getFunctionConfig(pkg, envConfig) {
139
141
  }
140
142
  }
141
143
  async function writeToFile_FunctionFirebaseJSON(pkg, env) {
142
- const envConfig = pkg.envConfig.envs.find(_env => _env.env === env);
143
- if (!envConfig)
144
- throw new ts_common_1.BadImplementationException(`Could not find env: ${env}`);
144
+ const envConfig = getEnvConfig(pkg);
145
145
  const fileContent = getFunctionConfig(pkg, envConfig);
146
146
  await fs_1.promises.writeFile(`${pkg.path}/${consts_1.CONST_FirebaseJSON}`, JSON.stringify(fileContent, null, 2), { encoding: 'utf-8' });
147
147
  }
@@ -155,3 +155,24 @@ function createFirebaseFullJSON(pkg, env) {
155
155
  return Object.assign(Object.assign({}, hosting), functions);
156
156
  }
157
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;
168
+ const envConfig = getEnvConfig(firebasePkg);
169
+ const defaultFiles = consts_2.MemKey_DefaultFiles.get();
170
+ let fileContent = await fs_1.promises.readFile(defaultFiles.backend.proxy, { encoding: 'utf-8' });
171
+ fileContent = fileContent.replace(/PROJECT_ID/g, `${envConfig.projectId}`);
172
+ fileContent = fileContent.replace(/PROXY_PORT/g, `${firebasePkg.envConfig.basePort}`);
173
+ fileContent = fileContent.replace(/SERVER_PORT/g, `${firebasePkg.envConfig.basePort + 1}`);
174
+ fileContent = fileContent.replace(/PATH_TO_SSL_KEY/g, `${(_a = firebasePkg.envConfig.ssl) === null || _a === void 0 ? void 0 : _a.pathToKey}`);
175
+ fileContent = fileContent.replace(/PATH_TO_SSL_CERTIFICATE/g, `${(_b = firebasePkg.envConfig.ssl) === null || _b === void 0 ? void 0 : _b.pathToCertificate}`);
176
+ await fs_1.promises.writeFile(pathToFile, fileContent, { encoding: 'utf-8' });
177
+ }
178
+ exports.generateProxyFile = generateProxyFile;
@@ -38,6 +38,7 @@ export type FirebasePackageConfig<Env extends string = string> = {
38
38
  name: string;
39
39
  debugPort: number;
40
40
  basePort: number;
41
+ hostingPort?: number;
41
42
  pathToFirebaseConfig: string;
42
43
  ssl?: {
43
44
  pathToKey: string;
@@ -10,9 +10,9 @@ _express.all('*', (req, res) => {
10
10
  const qMark = req.originalUrl.indexOf('?');
11
11
  const query = qMark > 1 ? req.originalUrl.substring(qMark) : '';
12
12
  const path = req.path;
13
- let url = `http://127.0.0.1:SERVER_PORT/shopify-manager-tool-dev/us-central1/api${path}${query}`;
13
+ let url = `http://127.0.0.1:SERVER_PORT/PROJECT_ID/us-central1/api${path}${query}`;
14
14
  if (path.startsWith('/emulatorDownload') || path.startsWith('/emulatorUpload'))
15
- url = `http://127.0.0.1:SERVER_PORT/shopify-manager-tool-dev/us-central1${path}${query}`;
15
+ url = `http://127.0.0.1:SERVER_PORT/PROJECT_ID/us-central1${path}${query}`;
16
16
 
17
17
  console.log(`PROXY ${counter} - [${req.method}] ${url}`);
18
18
 
@@ -60,5 +60,5 @@ const options = {
60
60
  requestCert: false,
61
61
  };
62
62
 
63
- require('https').createServer(options, _express).listen(8008);
63
+ require('https').createServer(options, _express).listen(PROXY_PORT);
64
64
  console.log('SSL proxy started!!!');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nu-art/build-and-install",
3
- "version": "0.204.22",
3
+ "version": "0.204.24",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "TacB0sS",
package/phases/phases.js CHANGED
@@ -177,7 +177,6 @@ exports.Phase_ResolveEnv = {
177
177
  mandatoryPhases: [exports.Phase_ResolveTemplate, exports.Phase_PrepareParams, exports.Phase_SetupProject, exports.Phase_SetWithThunderstorm],
178
178
  filter: async (pkg) => pkg.type === 'firebase-functions-app' || pkg.type === 'firebase-hosting-app',
179
179
  action: async (pkg) => {
180
- var _a, _b;
181
180
  const firebasePkg = pkg;
182
181
  await fs_1.promises.writeFile(`${firebasePkg.path}/${consts_1.CONST_FirebaseRC}`, JSON.stringify((0, generate_1.createFirebaseRC)(firebasePkg, params_1.RuntimeParams.environment), null, 2), { encoding: 'utf-8' });
183
182
  const defaultFiles = consts_2.MemKey_DefaultFiles.get();
@@ -196,14 +195,8 @@ exports.Phase_ResolveEnv = {
196
195
  catch (e) {
197
196
  await fs_1.promises.mkdir(pathToFirebaseConfigFolder, { recursive: true });
198
197
  }
199
- if (firebasePkg.envConfig.ssl) {
200
- const pathToProxyFile = `${firebaseFunctionPkg.path}/src/main/proxy.ts`;
201
- let defaultFileContent = await fs_1.promises.readFile(defaultFiles.backend.proxy, { encoding: 'utf-8' });
202
- defaultFileContent = defaultFileContent.replace(/SERVER_PORT/g, `${firebasePkg.envConfig.basePort}`);
203
- defaultFileContent = defaultFileContent.replace(/PATH_TO_SSL_KEY/g, `${(_a = firebasePkg.envConfig.ssl) === null || _a === void 0 ? void 0 : _a.pathToKey}`);
204
- defaultFileContent = defaultFileContent.replace(/PATH_TO_SSL_CERTIFICATE/g, `${(_b = firebasePkg.envConfig.ssl) === null || _b === void 0 ? void 0 : _b.pathToCertificate}`);
205
- await fs_1.promises.writeFile(pathToProxyFile, defaultFileContent, { encoding: 'utf-8' });
206
- }
198
+ if (firebasePkg.envConfig.ssl)
199
+ await (0, generate_1.generateProxyFile)(firebasePkg, `${firebaseFunctionPkg.path}/src/main/proxy.ts`);
207
200
  await Promise.all(consts_2.Const_FirebaseConfigKeys.map(async (firebaseConfigKey) => {
208
201
  const pathToConfigFile = `${pathToFirebaseConfigFolder}/${consts_2.Const_FirebaseDefaultsKeyToFile[firebaseConfigKey]}`;
209
202
  try {
@@ -407,6 +400,7 @@ exports.Phase_PrepareCompile = {
407
400
  'jpg',
408
401
  'jpeg',
409
402
  'rules',
403
+ '_ts',
410
404
  ];
411
405
  const command = `find . \\( -name ${otherFiles.map(suffix => `'*.${suffix}'`).join(' -o -name ')} \\) | cpio -pdm "${pkg.output}" > /dev/null`;
412
406
  await cli_1.Commando.create(basic_1.Cli_Basic)
@@ -632,10 +626,12 @@ exports.Phase_Launch = {
632
626
  }
633
627
  if (pkg.type === 'firebase-hosting-app') {
634
628
  runningAppsLogs.registerApp(pkg.name, logClient);
629
+ if (!pkg.envConfig.hostingPort)
630
+ throw new ts_common_1.BadImplementationException('Missing hosting port in envConfig');
635
631
  return nvm_1.NVM.createInteractiveCommando(basic_1.Cli_Basic)
636
632
  .setUID(pkg.name)
637
633
  .cd(pkg.path)
638
- .append(`array=($(lsof -ti:${[pkg.envConfig.basePort - 1].join(',')}))`)
634
+ .append(`array=($(lsof -ti:${[pkg.envConfig.hostingPort].join(',')}))`)
639
635
  .append(`((\${#array[@]} > 0)) && kill -9 "\${array[@]}"`)
640
636
  .append(`nvm use`)
641
637
  .append(`npm run start`)