@nu-art/build-and-install 0.204.45 → 0.204.47

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.
@@ -9,7 +9,6 @@ export declare class CommandExecutor_FirebaseFunction {
9
9
  private readonly pkg;
10
10
  private readonly commandos;
11
11
  private listeners;
12
- private debugMode?;
13
12
  private onReadyCallbacks;
14
13
  constructor(pkg: Package_FirebaseFunctionsApp);
15
14
  private initListeners;
@@ -20,7 +19,6 @@ export declare class CommandExecutor_FirebaseFunction {
20
19
  private onReady;
21
20
  execute(): Promise<this>;
22
21
  kill(): Promise<void>;
23
- setDebug(debug: boolean): void;
24
22
  addOnReadyCallback(cb: OnReadyCallback): void;
25
23
  }
26
24
  export {};
@@ -5,6 +5,7 @@ const nvm_1 = require("@nu-art/commando/cli/nvm");
5
5
  const basic_1 = require("@nu-art/commando/cli/basic");
6
6
  const cli_1 = require("@nu-art/commando/core/cli");
7
7
  const ts_common_1 = require("@nu-art/ts-common");
8
+ const params_1 = require("../../core/params/params");
8
9
  class CommandExecutor_FirebaseFunction {
9
10
  constructor(pkg) {
10
11
  this.PROXY_PID_LOG = '_PROXY_PID_';
@@ -63,7 +64,7 @@ class CommandExecutor_FirebaseFunction {
63
64
  await this.commandos.emulator
64
65
  .setUID(this.pkg.name)
65
66
  .cd(this.pkg.path)
66
- .append(`firebase emulators:start --export-on-exit --import=.trash/data ${this.debugMode ? `--inspect-functions ${this.pkg.envConfig.ssl}` : ''} &`)
67
+ .append(`firebase emulators:start --export-on-exit --import=.trash/data ${params_1.RuntimeParams.debugBackend ? `--inspect-functions ${this.pkg.envConfig.debugPort}` : ''} &`)
67
68
  .append('pid=$!')
68
69
  .append(`echo "${this.EMULATOR_PID_LOG}=\${pid}"`)
69
70
  .append(`wait \$pid`)
@@ -91,9 +92,6 @@ class CommandExecutor_FirebaseFunction {
91
92
  await this.commandos.emulator.gracefullyKill(emulatorPid);
92
93
  await this.commandos.proxy.gracefullyKill(proxyPid);
93
94
  }
94
- setDebug(debug) {
95
- this.debugMode = debug;
96
- }
97
95
  addOnReadyCallback(cb) {
98
96
  this.onReadyCallbacks.push(cb);
99
97
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nu-art/build-and-install",
3
- "version": "0.204.45",
3
+ "version": "0.204.47",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "TacB0sS",
package/phases/phases.js CHANGED
@@ -740,6 +740,11 @@ exports.Phase_DeployBackend = {
740
740
  const counter = timeCounter();
741
741
  await nvm_1.NVM.createCommando(basic_1.Cli_Basic)
742
742
  .cd(pkg.path)
743
+ .cd('dist')
744
+ .ls()
745
+ .cat('package.json')
746
+ .cat('index.js')
747
+ .cd_()
743
748
  .append(`firebase --debug deploy --only functions --force`)
744
749
  .execute();
745
750
  projectScreen.updateOrCreatePackage(pkg.name, `Deployed (${counter.format('mm:ss.zzz')})`);
@@ -5,9 +5,12 @@ type Unit<P extends Phase<string>[]> = BaseUnit & UnitPhaseImplementor<P>;
5
5
  export declare class PhaseRunner<P extends Phase<string>[]> extends BaseUnit {
6
6
  private readonly phases;
7
7
  private units;
8
+ private runnerParams;
8
9
  constructor(phases: P);
10
+ protected init(): Promise<void>;
9
11
  registerUnits(units: Unit<P> | Unit<P>[]): void;
10
12
  private getUnitsForPhase;
13
+ private _getRunnerParam;
11
14
  private initUnits;
12
15
  private executePhase;
13
16
  execute(): Promise<void>;
@@ -7,8 +7,14 @@ class PhaseRunner extends BaseUnit_1.BaseUnit {
7
7
  constructor(phases) {
8
8
  super({ label: 'Phase Runner', key: 'phase-runner' });
9
9
  this.units = [];
10
+ this.runnerParams = {};
11
+ this._getRunnerParam = (runnerParamKey) => this.runnerParams[runnerParamKey];
10
12
  this.phases = phases;
11
13
  }
14
+ async init() {
15
+ this.runnerParams['rootPath'] = process.cwd();
16
+ this.runnerParams['configPath'] = this.runnerParams['rootPath'] + '/.config';
17
+ }
12
18
  //######################### Unit Logic #########################
13
19
  registerUnits(units) {
14
20
  (0, ts_common_1.asArray)(units).forEach(unit => this.units.push(unit));
@@ -18,6 +24,7 @@ class PhaseRunner extends BaseUnit_1.BaseUnit {
18
24
  }
19
25
  async initUnits() {
20
26
  return Promise.all(this.units.map(unit => {
27
+ unit.setGetRunnerParamCaller(this._getRunnerParam);
21
28
  // @ts-ignore
22
29
  unit.init();
23
30
  }));
@@ -37,6 +44,7 @@ class PhaseRunner extends BaseUnit_1.BaseUnit {
37
44
  }
38
45
  //######################### Public Functions #########################
39
46
  async execute() {
47
+ await this.init();
40
48
  await this.initUnits();
41
49
  await this.executeImpl();
42
50
  }
@@ -10,3 +10,7 @@ export type PhaseImplementor<P extends Phase<string>[]> = {
10
10
  export type PhasesImplementor<Phases extends Phase<string>[]> = {
11
11
  [K in Phases[number]['method']]?: AsyncVoidFunction;
12
12
  };
13
+ export type RunnerParamKeys = 'rootPath' | 'configPath';
14
+ export type RunnerParams = {
15
+ [K in RunnerParamKeys]: string;
16
+ };
@@ -1,12 +1,15 @@
1
1
  import { Logger } from '@nu-art/ts-common';
2
+ import { RunnerParamKeys } from '../../phase-runner/types';
2
3
  type _Config<Config> = {
3
4
  key: string;
4
5
  label: string;
5
6
  } & Config;
6
7
  export declare class BaseUnit<Config extends {} = {}, C extends _Config<Config> = _Config<Config>> extends Logger {
7
8
  readonly config: Readonly<C>;
9
+ protected getRunnerParam: (runnerParamKey: RunnerParamKeys) => string | undefined;
8
10
  constructor(config: C);
9
11
  protected init(): Promise<void>;
10
12
  private initLogClient;
13
+ setGetRunnerParamCaller: (caller: (runnerParamKey: RunnerParamKeys) => string) => void;
11
14
  }
12
15
  export {};
@@ -5,6 +5,9 @@ const ts_common_1 = require("@nu-art/ts-common");
5
5
  class BaseUnit extends ts_common_1.Logger {
6
6
  constructor(config) {
7
7
  super(config.key);
8
+ this.setGetRunnerParamCaller = (caller) => {
9
+ this.getRunnerParam = caller;
10
+ };
8
11
  this.config = Object.freeze(config);
9
12
  this.initLogClient();
10
13
  }
@@ -1,10 +1,26 @@
1
1
  import { BaseUnit } from './BaseUnit';
2
2
  import { Phase_CopyPackageJSON, UnitPhaseImplementor } from './types';
3
- type PackageJSONTargetKey = 'root' | 'dist' | 'dependency';
3
+ import { PackageJson } from '../../../core/types';
4
+ declare const PackageJsonTargetKeys: readonly ["root", "dist", "dependency"];
5
+ type PackageJsonTargetKey = typeof PackageJsonTargetKeys[number];
4
6
  type _Config<Config> = {
5
7
  pathToPackage: string;
6
8
  } & Config;
7
9
  export declare class Unit_Typescript<Config extends {} = {}, C extends _Config<Config> = _Config<Config>> extends BaseUnit<C> implements UnitPhaseImplementor<[Phase_CopyPackageJSON]> {
10
+ readonly packageJson: {
11
+ [k in PackageJsonTargetKey]: PackageJson;
12
+ };
13
+ /**
14
+ * Create a packageJson object for each target key
15
+ * @private
16
+ */
17
+ private populatePackageJson;
18
+ /**
19
+ * Execute template to packageJson object conversion based on target key
20
+ * @param targetKey
21
+ * @param template
22
+ * @private
23
+ */
8
24
  private convertTemplatePackageJSON;
9
25
  /**
10
26
  * Converts a template __package.json file into a usable package.json for the unit root
@@ -25,6 +41,6 @@ export declare class Unit_Typescript<Config extends {} = {}, C extends _Config<C
25
41
  * @private
26
42
  */
27
43
  private convertPJForDependency;
28
- copyPackageJson(targetKey?: PackageJSONTargetKey): Promise<void>;
44
+ copyPackageJson(): Promise<void>;
29
45
  }
30
46
  export {};
@@ -1,4 +1,27 @@
1
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  Object.defineProperty(exports, "__esModule", { value: true });
3
26
  exports.Unit_Typescript = void 0;
4
27
  const BaseUnit_1 = require("./BaseUnit");
@@ -6,21 +29,43 @@ const tools_1 = require("@nu-art/commando/core/tools");
6
29
  const consts_1 = require("../../../core/consts");
7
30
  const ts_common_1 = require("@nu-art/ts-common");
8
31
  const map_project_packages_1 = require("../../../logic/map-project-packages");
32
+ const fs = __importStar(require("fs"));
9
33
  const fs_1 = require("fs");
10
- const targetKeyPathMap = {
11
- 'root': '',
12
- 'dist': '/dist',
13
- 'dependency': '', //TODO: Fill this in
14
- };
34
+ const PackageJsonTargetKey_Root = 'root';
35
+ const PackageJsonTargetKey_Dist = 'dist';
36
+ const PackageJsonTargetKey_Dependency = 'dependency';
37
+ const PackageJsonTargetKeys = [PackageJsonTargetKey_Root, PackageJsonTargetKey_Dist, PackageJsonTargetKey_Dependency];
15
38
  class Unit_Typescript extends BaseUnit_1.BaseUnit {
39
+ constructor() {
40
+ super(...arguments);
41
+ this.packageJson = {};
42
+ }
16
43
  //######################### Internal Logic #########################
44
+ /**
45
+ * Create a packageJson object for each target key
46
+ * @private
47
+ */
48
+ async populatePackageJson() {
49
+ const unitRootPath = (0, tools_1.convertToFullPath)(this.config.pathToPackage);
50
+ const templatePath = `${unitRootPath}/${consts_1.CONST_PackageJSONTemplate}`;
51
+ if (!fs.existsSync(templatePath))
52
+ throw new ts_common_1.BadImplementationException(`Missing __package.json file in root for unit ${this.config.label}`);
53
+ const template = JSON.parse(await fs_1.promises.readFile(templatePath, 'utf-8'));
54
+ PackageJsonTargetKeys.forEach(key => this.packageJson[key] = this.convertTemplatePackageJSON(key, template));
55
+ }
56
+ /**
57
+ * Execute template to packageJson object conversion based on target key
58
+ * @param targetKey
59
+ * @param template
60
+ * @private
61
+ */
17
62
  convertTemplatePackageJSON(targetKey, template) {
18
63
  switch (targetKey) {
19
- case 'root':
64
+ case PackageJsonTargetKey_Root:
20
65
  return this.convertPJForRoot(template);
21
- case 'dist':
66
+ case PackageJsonTargetKey_Dist:
22
67
  return this.convertPJForDist(template);
23
- case 'dependency':
68
+ case PackageJsonTargetKey_Dependency:
24
69
  return this.convertPJForDependency(template);
25
70
  default:
26
71
  throw new ts_common_1.ImplementationMissingException(`No implementation for targetKey ${targetKey}`);
@@ -44,10 +89,10 @@ class Unit_Typescript extends BaseUnit_1.BaseUnit {
44
89
  * @private
45
90
  */
46
91
  convertPJForDist(template) {
47
- var _a, _b;
92
+ var _a, _b, _c;
48
93
  //Get the package params for replacing in the template package json
49
94
  const params = (_b = (_a = consts_1.MemKey_Packages.get()) === null || _a === void 0 ? void 0 : _a.params) !== null && _b !== void 0 ? _b : {};
50
- const converted = this.convertPJForRoot(template);
95
+ const converted = (_c = this.packageJson[PackageJsonTargetKey_Root]) !== null && _c !== void 0 ? _c : this.convertPJForRoot(template);
51
96
  params[converted.name] = converted.version;
52
97
  params[`${converted.name}_path`] = `file:.dependencies/${this.config.key}`; //Not sure about this one
53
98
  //Convert template to actual package.json
@@ -60,27 +105,23 @@ class Unit_Typescript extends BaseUnit_1.BaseUnit {
60
105
  * @private
61
106
  */
62
107
  convertPJForDependency(template) {
63
- var _a, _b;
108
+ var _a, _b, _c;
64
109
  //Get the package params for replacing in the template package json
65
110
  const params = (_b = (_a = consts_1.MemKey_Packages.get()) === null || _a === void 0 ? void 0 : _a.params) !== null && _b !== void 0 ? _b : {};
66
- const converted = this.convertPJForRoot(template);
111
+ const converted = (_c = this.packageJson[PackageJsonTargetKey_Root]) !== null && _c !== void 0 ? _c : this.convertPJForRoot(template);
67
112
  params[converted.name] = converted.version;
68
113
  params[`${converted.name}_path`] = `file:.dependencies/${this.config.key}`; //Not sure about this one
69
114
  //Convert template to actual package.json
70
115
  return (0, map_project_packages_1.convertPackageJSONTemplateToPackJSON_Value)(template, (value, key) => { var _a; return (_a = params[key]) !== null && _a !== void 0 ? _a : params[value]; });
71
116
  }
72
117
  //######################### Phase Implementations #########################
73
- async copyPackageJson(targetKey = 'root') {
74
- //Find paths
118
+ async copyPackageJson() {
119
+ //Populate packageJson objects
120
+ await this.populatePackageJson();
121
+ //Get path
75
122
  const unitRootPath = (0, tools_1.convertToFullPath)(this.config.pathToPackage);
76
- const templatePath = `${unitRootPath}/${consts_1.CONST_PackageJSONTemplate}`;
77
- const targetPath = `${unitRootPath + targetKeyPathMap[targetKey]}/${consts_1.CONST_PackageJSON}`;
78
- //Get the template __package.json file
79
- const template = JSON.parse(await fs_1.promises.readFile(templatePath, 'utf-8'));
80
- //Get converted package.json content
81
- const packageJSON = this.convertTemplatePackageJSON(targetKey, template);
82
123
  //Create the package.json file in target location
83
- await fs_1.promises.writeFile(targetPath, JSON.stringify(packageJSON, null, 2), { encoding: 'utf-8' });
124
+ await fs_1.promises.writeFile(unitRootPath, JSON.stringify(this.packageJson.root, null, 2), { encoding: 'utf-8' });
84
125
  }
85
126
  }
86
127
  exports.Unit_Typescript = Unit_Typescript;
@@ -29,6 +29,7 @@ const Unit_Typescript_1 = require("./Unit_Typescript");
29
29
  const fs = __importStar(require("fs"));
30
30
  const basic_1 = require("@nu-art/commando/cli/basic");
31
31
  const ts_common_1 = require("@nu-art/ts-common");
32
+ const fs_1 = require("fs");
32
33
  class Unit_TypescriptLib extends Unit_Typescript_1.Unit_Typescript {
33
34
  //######################### Internal Logic #########################
34
35
  async resolveTSConfig() {
@@ -38,10 +39,19 @@ class Unit_TypescriptLib extends Unit_Typescript_1.Unit_Typescript {
38
39
  if (this.config.customTSConfig) {
39
40
  //If ts config file does not exist in the main folder
40
41
  if (!fs.existsSync(pathToUnitTSConfig))
41
- throw new ts_common_1.BadImplementationException(`Unit ${this.config.label} missing tsconfig.json file in /src/main`);
42
+ throw new ts_common_1.BadImplementationException(`Unit ${this.config.label} is set to use a custom tsconfig but is missing a tsconfig.json file in /src/main`);
42
43
  return;
43
44
  }
44
45
  //Copy project ts config file into the unit main folder
46
+ const pathToProjectConfig = this.getRunnerParam('configPath');
47
+ if (!pathToProjectConfig)
48
+ throw new ts_common_1.BadImplementationException('Could not get config path from runner params');
49
+ //Make sure a project ts config file exists
50
+ const pathToProjectTSConfig = pathToProjectConfig + '/tsconfig.json';
51
+ if (!fs.existsSync(pathToProjectTSConfig))
52
+ throw new ts_common_1.BadImplementationException(`Project is missing a tsconfig.json file in path ${pathToProjectConfig}`);
53
+ //Copy the file into the unit
54
+ await fs_1.promises.copyFile(pathToProjectTSConfig, pathToUnitTSConfig);
45
55
  }
46
56
  //######################### Phase Implementations #########################
47
57
  async preCompile() {