@nu-art/build-and-install 0.400.7 → 0.400.8

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.
@@ -8,7 +8,7 @@ import { ProjectUnit } from './v3/units/ProjectUnit.js';
8
8
  import { PhaseManager } from './v3/PhaseManager.js';
9
9
  import { Unit_NodeProject } from './v3/units/index.js';
10
10
  import { resolve } from 'path';
11
- import { CONST_BaiConfig, CONST_NodeModules } from './core/consts.js';
11
+ import { CONST_BaiConfig, CONST_NodeModules, CONST_VersionApp } from './core/consts.js';
12
12
  import { UnitMapper_FirebaseFunction, UnitMapper_FirebaseHosting, UnitMapper_NodeLib, UnitMapper_NodeProject } from './v3/UnitsMapper/resolvers/index.js';
13
13
  import { CLIParamsResolver } from '@nu-art/commando/cli-params/CLIParamsResolver';
14
14
  import { RunningStatusHandler } from './v3/RunningStatusHandler.js';
@@ -93,8 +93,11 @@ export class BuildAndInstall extends Logger {
93
93
  }));
94
94
  const globalOutputFolder = resolve(this.pathToProject, '.trash/output');
95
95
  this.unitsDependencyMapper = new UnitsDependencyMapper(unitsDependencies, globalOutputFolder);
96
+ const versionFilePath = resolve(this.pathToProject, CONST_VersionApp);
97
+ this.logInfo('loading version from: ', versionFilePath);
98
+ const version = await FileSystemUtils.file.read.json(versionFilePath, { version: '1.0.0' });
96
99
  const runtimeContext = ({
97
- version: '',
100
+ version: version.version,
98
101
  parentUnit: this.nodeProjectUnit,
99
102
  childUnits: allProjectUnits,
100
103
  baiConfig,
package/core/consts.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { MemKey } from '@nu-art/ts-common/mem-storage/index';
2
2
  import { RuntimeProjectConfig } from './types/index.js';
3
+ export declare const CONST_VersionApp = "version-app.json";
3
4
  export declare const CONST_PackageJSONTemplate = "__package.json";
4
5
  export declare const CONST_PackageJSON = "package.json";
5
6
  export declare const CONST_NodeModules = "node_modules";
package/core/consts.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { MemKey } from '@nu-art/ts-common/mem-storage/index';
2
+ export const CONST_VersionApp = 'version-app.json';
2
3
  export const CONST_PackageJSONTemplate = '__package.json';
3
4
  export const CONST_PackageJSON = 'package.json';
4
5
  export const CONST_NodeModules = 'node_modules';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nu-art/build-and-install",
3
- "version": "0.400.7",
3
+ "version": "0.400.8",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -31,8 +31,8 @@
31
31
  },
32
32
  "dependencies": {
33
33
  "chokidar": "^3.6.0",
34
- "@nu-art/ts-common": "0.400.7",
35
- "@nu-art/commando": "0.400.7"
34
+ "@nu-art/ts-common": "0.400.8",
35
+ "@nu-art/commando": "0.400.8"
36
36
  },
37
37
  "unitConfig": {
38
38
  "type": "typescript-lib"
@@ -1,5 +1,4 @@
1
- import { CONST_FirebaseJSON, CONST_FirebaseRC, CONST_NodeModules, CONST_PackageJSON } from '../../../core/consts.js';
2
- import { promises as _fs } from 'fs';
1
+ import { CONST_FirebaseJSON, CONST_FirebaseRC, CONST_NodeModules, CONST_PackageJSON, CONST_VersionApp } from '../../../core/consts.js';
3
2
  import { __stringify, _keys, _logger_logPrefixes, deepClone, ImplementationMissingException, LogLevel, Second, sleep } from '@nu-art/ts-common';
4
3
  import { Const_FirebaseConfigKeys, Const_FirebaseDefaultsKeyToFile } from '../../../defaults/consts.js';
5
4
  import { Commando_NVM } from '@nu-art/commando/shell/plugins/nvm';
@@ -137,8 +136,8 @@ export class Unit_FirebaseFunctionsApp extends Unit_TypescriptLib {
137
136
  }
138
137
  }
139
138
  };
140
- const targetPath = `${this.config.fullPath}/${CONST_FirebaseRC}`;
141
- await _fs.writeFile(targetPath, JSON.stringify(rcConfig, null, 2), { encoding: 'utf-8' });
139
+ const targetPath = resolve(this.config.fullPath, CONST_FirebaseRC);
140
+ await FileSystemUtils.file.write.json(targetPath, rcConfig);
142
141
  }
143
142
  async resolveProxyFile() {
144
143
  const envConfig = this.getEnvConfig();
@@ -230,7 +229,7 @@ export class Unit_FirebaseFunctionsApp extends Unit_TypescriptLib {
230
229
  }
231
230
  };
232
231
  }
233
- await _fs.writeFile(targetPath, JSON.stringify(fileContent, null, 2), { encoding: 'utf-8' });
232
+ await FileSystemUtils.file.write.json(targetPath, fileContent);
234
233
  }
235
234
  async resolveFunctionsRuntimeConfig() {
236
235
  const envConfig = this.getEnvConfig();
@@ -243,16 +242,15 @@ export class Unit_FirebaseFunctionsApp extends Unit_TypescriptLib {
243
242
  };
244
243
  const inLocalIgnoreTLS = `${envConfig.isLocal ? '// @ts-ignore\nprocess.env[\'NODE_TLS_REJECT_UNAUTHORIZED\'] = 0;\n\n' : ''}`;
245
244
  const fileContent = `${inLocalIgnoreTLS}export const Environment = ${JSON.stringify(beConfig)};`;
246
- await _fs.writeFile(targetPath, fileContent, { encoding: 'utf-8' });
245
+ await FileSystemUtils.file.write(targetPath, fileContent);
247
246
  }
248
247
  //######################### Compile Logic #########################
249
248
  async createAppVersionFile() {
250
249
  //Writing the file to the package source instead of the output is fine,
251
250
  //copyAssetsToOutput will move the file to output
252
- // const targetPath = `${this.config.fullPath}/src/main/${CONST_VersionApp}`;
253
- // const appVersion = MemKey_ProjectConfig.get().projectVersion;
254
- // const fileContent = JSON.stringify({version: appVersion}, null, 2);
255
- // await _fs.writeFile(targetPath, fileContent, {encoding: 'utf-8'});
251
+ const targetPath = `${this.config.fullPath}/src/main/${CONST_VersionApp}`;
252
+ const appVersion = this.runtimeContext.version;
253
+ await FileSystemUtils.file.write.json(targetPath, { version: appVersion });
256
254
  }
257
255
  deriveDistDependencies() {
258
256
  return this.dependencyUnits.reduce((dependencies, unit) => {
@@ -1,13 +1,12 @@
1
1
  import { ImplementationMissingException, LogLevel } from '@nu-art/ts-common';
2
- import { promises as _fs } from 'fs';
3
- import { CONST_FirebaseJSON, CONST_FirebaseRC } from '../../../core/consts.js';
2
+ import { CONST_FirebaseJSON, CONST_FirebaseRC, CONST_VersionApp } from '../../../core/consts.js';
4
3
  import { Commando_NVM } from '@nu-art/commando/shell/plugins/nvm';
5
4
  import { Commando_Basic } from '@nu-art/commando/shell/plugins/basic';
6
5
  import { resolve } from 'path';
7
6
  import { Unit_TypescriptLib } from '../Unit_TypescriptLib.js';
8
7
  import { CommandoException } from '@nu-art/commando/shell/core/CliError';
9
8
  import { deployLogFilter } from './common.js';
10
- const CONST_VersionApp = 'version-app.json';
9
+ import { FileSystemUtils } from '@nu-art/ts-common/utils/FileSystemUtils';
11
10
  export class Unit_FirebaseHostingApp extends Unit_TypescriptLib {
12
11
  hosting = {};
13
12
  static DefaultConfig_FirebaseHosting = {
@@ -61,7 +60,7 @@ export class Unit_FirebaseHostingApp extends Unit_TypescriptLib {
61
60
  const envConfig = this.getEnvConfig();
62
61
  const rcConfig = { projects: { default: envConfig.projectId } };
63
62
  const targetPath = `${this.config.fullPath}/${CONST_FirebaseRC}`;
64
- await _fs.writeFile(targetPath, JSON.stringify(rcConfig, null, 2), { encoding: 'utf-8' });
63
+ await FileSystemUtils.file.write.json(targetPath, rcConfig);
65
64
  }
66
65
  async resolveHostingJSON() {
67
66
  const envConfig = this.getEnvConfig();
@@ -78,13 +77,13 @@ export class Unit_FirebaseHostingApp extends Unit_TypescriptLib {
78
77
  ]
79
78
  }
80
79
  };
81
- await _fs.writeFile(targetPath, JSON.stringify(fileContent, null, 2), { encoding: 'utf-8' });
80
+ await FileSystemUtils.file.write.json(targetPath, fileContent);
82
81
  }
83
82
  async resolveHostingRuntimeConfig() {
84
83
  const envConfig = this.getEnvConfig().config;
85
84
  const targetPath = resolve(this.config.fullPath, `./src/main/config.ts`);
86
85
  const fileContent = `export const config = ${JSON.stringify(envConfig, null, 2)};`;
87
- await _fs.writeFile(targetPath, fileContent, { encoding: 'utf-8' });
86
+ await FileSystemUtils.file.write(targetPath, fileContent);
88
87
  }
89
88
  //######################### Compile Logic #########################
90
89
  async compileImpl() {
@@ -100,8 +99,7 @@ export class Unit_FirebaseHostingApp extends Unit_TypescriptLib {
100
99
  //Webpack bundles files into the output automatically!
101
100
  const targetPath = `${this.config.fullPath}/src/main/${CONST_VersionApp}`;
102
101
  const appVersion = this.runtimeContext.version;
103
- const fileContent = JSON.stringify({ version: appVersion }, null, 2);
104
- await _fs.writeFile(targetPath, fileContent, { encoding: 'utf-8' });
102
+ await FileSystemUtils.file.write.json(targetPath, { version: appVersion });
105
103
  }
106
104
  //######################### Launch Logic #########################
107
105
  async runApp() {