@nu-art/build-and-install 0.204.95 → 0.204.96

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.
@@ -11,12 +11,14 @@ if (params_1.RuntimeParams.runWithThunderstorm)
11
11
  runner
12
12
  .execute()
13
13
  .then(() => {
14
- ts_common_1.StaticLogger.logInfo('completed');
15
14
  process.on('SIGINT', () => {
16
- console.log('DEADEDAEDAEDAEDAEDAD');
15
+ console.log('completed');
17
16
  return process.exit(0);
18
17
  });
19
18
  })
20
19
  .catch(err => {
21
- ts_common_1.StaticLogger.logError('Failed with error: ', err);
20
+ process.on('SIGINT', () => {
21
+ console.log('Failed with error: ', err);
22
+ return process.exit(1);
23
+ });
22
24
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nu-art/build-and-install",
3
- "version": "0.204.95",
3
+ "version": "0.204.96",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "TacB0sS",
@@ -6,7 +6,8 @@ export declare class PhaseRunner extends BaseUnit implements UnitPhaseImplemento
6
6
  private readonly phases;
7
7
  private readonly units;
8
8
  private unitDependencyTree;
9
- private readonly project;
9
+ private readonly projectPath;
10
+ private projectConfig;
10
11
  private killed?;
11
12
  private runningStatus;
12
13
  private phaseFilter;
@@ -16,6 +17,9 @@ export declare class PhaseRunner extends BaseUnit implements UnitPhaseImplemento
16
17
  */
17
18
  private killCounter;
18
19
  private static KILL_THRESHOLD;
20
+ static instance: PhaseRunner;
21
+ private readonly screenManager;
22
+ private defaultFileRoutes;
19
23
  constructor(projectPath: RelativePath);
20
24
  protected init(): Promise<void>;
21
25
  private filterUnits;
@@ -73,10 +73,14 @@ class PhaseRunner extends core_1.BaseUnit {
73
73
  }
74
74
  };
75
75
  this.getPhases = () => [...this.phases];
76
+ if ((0, ts_common_1.exists)(PhaseRunner.instance))
77
+ throw new ts_common_1.MUSTNeverHappenException('phase runner instance must be unique');
78
+ Error.stackTraceLimit = 50;
76
79
  this.addToClassStack(PhaseRunner);
80
+ this.screenManager = new BAIScreenManager_1.BAIScreenManager();
77
81
  this.phases = [];
78
82
  this.units = [this];
79
- this.project = { path: (0, tools_1.convertToFullPath)(projectPath), config: {} };
83
+ this.projectPath = (0, tools_1.convertToFullPath)(projectPath);
80
84
  this.phaseFilter = this.phaseFilters[types_1.PhaseRunnerMode_Normal];
81
85
  this.setMinLevel(ts_common_1.LogLevel.Info);
82
86
  console.log('RuntimeParams.debug', params_1.RuntimeParams.debug);
@@ -87,28 +91,36 @@ class PhaseRunner extends core_1.BaseUnit {
87
91
  }
88
92
  //######################### Initialization #########################
89
93
  async init() {
90
- // await super.init(false);
91
- //Set phase runner to MemKey, so it can be referenced in the runtime
94
+ var _a;
92
95
  consts_2.MemKey_PhaseRunner.set(this);
93
- //Init screen manager
94
- new BAIScreenManager_1.BAIScreenManager();
95
- //Load project for use in the phase runner
96
- await this.loadProject();
97
- //Filter specific units
98
- this.filterUnits();
99
- this.logDebug('Runtime params:', params_1.RuntimeParams);
100
- //Set runner params
96
+ BAIScreenManager_1.MemKey_BAIScreenManager.set(this.screenManager);
101
97
  const runnerParams = {
102
98
  rootPath: process.cwd(),
103
99
  configPath: process.cwd() + '/.config',
104
100
  };
105
101
  RunnerParams_1.MemKey_RunnerParams.set(runnerParams);
102
+ if (this.projectConfig) {
103
+ const projectParams = this.prepareProjectParams();
104
+ RunnerParams_1.MemKey_ProjectConfig.set(Object.assign(Object.assign({}, this.projectConfig), { params: projectParams }));
105
+ }
106
+ if (this.defaultFileRoutes)
107
+ consts_1.MemKey_DefaultFiles.set(this.defaultFileRoutes);
108
+ if (PhaseRunner.instance) {
109
+ return;
110
+ }
111
+ PhaseRunner.instance = this;
112
+ //Load project for use in the phase runner
113
+ (_a = this.projectConfig) !== null && _a !== void 0 ? _a : (this.projectConfig = await this.loadProject());
114
+ //Filter specific units
115
+ this.filterUnits();
116
+ this.logDebug('Runtime params:', params_1.RuntimeParams);
117
+ //Set runner params
106
118
  //Set Project Params
107
119
  const projectParams = this.prepareProjectParams();
108
- RunnerParams_1.MemKey_ProjectConfig.set(Object.assign(Object.assign({}, this.project.config), { params: projectParams }));
120
+ RunnerParams_1.MemKey_ProjectConfig.set(Object.assign(Object.assign({}, this.projectConfig), { params: projectParams }));
109
121
  //Set Default File Routes
110
- const defaultFileRoutes = this.prepareDefaultFileRouts();
111
- consts_1.MemKey_DefaultFiles.set(defaultFileRoutes);
122
+ this.defaultFileRoutes = this.prepareDefaultFileRouts();
123
+ consts_1.MemKey_DefaultFiles.set(this.defaultFileRoutes);
112
124
  //Load running status
113
125
  await this.loadRunningStatus();
114
126
  //Print init results
@@ -136,20 +148,20 @@ class PhaseRunner extends core_1.BaseUnit {
136
148
  PhaseRunnerDispatcher_1.dispatcher_UnitChange.dispatch(this.units);
137
149
  }
138
150
  async loadProject() {
139
- if (!fs_1.default.existsSync(this.project.path))
140
- throw new ts_common_1.ImplementationMissingException(`Missing project config file, could not find in path: ${this.project.path}`);
141
- const projectConfigCB = require(this.project.path).default;
151
+ if (!fs_1.default.existsSync(this.projectPath))
152
+ throw new ts_common_1.ImplementationMissingException(`Missing project config file, could not find in path: ${this.projectPath}`);
153
+ const projectConfigCB = require(this.projectPath).default;
142
154
  if (typeof projectConfigCB !== 'function')
143
155
  throw new ts_common_1.BadImplementationException('Config file must be an asynchronous function returning a ProjectConfigV2 object');
144
- this.project.config = await projectConfigCB();
156
+ return projectConfigCB();
145
157
  }
146
158
  prepareProjectParams() {
147
159
  var _a;
148
- const params = (_a = this.project.config.params) !== null && _a !== void 0 ? _a : {};
149
- params[CONST_ThunderstormVersionKey] = this.project.config.thunderstormVersion;
150
- params[CONST_ThunderstormDependencyKey] = this.project.config.thunderstormVersion;
151
- params[CONST_ProjectVersionKey] = this.project.config.projectVersion;
152
- params[CONST_ProjectDependencyKey] = this.project.config.projectVersion;
160
+ const params = (_a = this.projectConfig.params) !== null && _a !== void 0 ? _a : {};
161
+ params[CONST_ThunderstormVersionKey] = this.projectConfig.thunderstormVersion;
162
+ params[CONST_ThunderstormDependencyKey] = this.projectConfig.thunderstormVersion;
163
+ params[CONST_ProjectVersionKey] = this.projectConfig.projectVersion;
164
+ params[CONST_ProjectDependencyKey] = this.projectConfig.projectVersion;
153
165
  return params;
154
166
  }
155
167
  prepareDefaultFileRouts() {
@@ -376,13 +388,23 @@ class PhaseRunner extends core_1.BaseUnit {
376
388
  //######################### Public Functions #########################
377
389
  async execute() {
378
390
  return new MemStorage_1.MemStorage().init(async () => {
379
- process.on('SIGINT', () => {
380
- this.killRunner();
381
- });
382
- await this.init();
383
- await this.buildUnitDependencyTree();
384
- await this.executeImpl();
385
- this.killed = true;
391
+ try {
392
+ process.on('SIGINT', () => {
393
+ this.killRunner();
394
+ });
395
+ await this.init();
396
+ await this.buildUnitDependencyTree();
397
+ await this.executeImpl();
398
+ this.killed = true;
399
+ this.logInfo('Completed successfully');
400
+ if (params_1.RuntimeParams.closeOnExit)
401
+ process.exit(0);
402
+ }
403
+ catch (error) {
404
+ this.logError('Finished with Errors: ', error);
405
+ if (params_1.RuntimeParams.closeOnExit)
406
+ process.exit(1);
407
+ }
386
408
  });
387
409
  }
388
410
  async killRunner() {
@@ -25,7 +25,6 @@ class BAIScreenManager {
25
25
  return;
26
26
  (0, ts_common_1.removeFromArrayByIndex)(this.screens, index);
27
27
  };
28
- exports.MemKey_BAIScreenManager.set(this);
29
28
  PhaseRunnerDispatcher_1.dispatcher_PhaseChange.addListener(this);
30
29
  this.assignTerminal();
31
30
  }
@@ -3,6 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BAIScreen_UnitList = void 0;
4
4
  const BAIScreen_1 = require("./BAIScreen");
5
5
  const consts_1 = require("../phase-runner/consts");
6
+ const PhaseRunner_1 = require("../phase-runner/PhaseRunner");
7
+ const params_1 = require("../../core/params/params");
6
8
  class BAIScreen_UnitList extends BAIScreen_1.BAIScreen {
7
9
  //######################### Lifecycle #########################
8
10
  constructor() {
@@ -22,6 +24,7 @@ class BAIScreen_UnitList extends BAIScreen_1.BAIScreen {
22
24
  this.container.screen.render();
23
25
  }
24
26
  __onUnitsChange(data) {
27
+ this.destroyUnitListWidget();
25
28
  this.createUnitListWidget();
26
29
  this.renderUnitList();
27
30
  }
@@ -65,8 +68,18 @@ class BAIScreen_UnitList extends BAIScreen_1.BAIScreen {
65
68
  fg: 'blue',
66
69
  },
67
70
  align: 'center',
71
+ label: 'phase',
72
+ mouse: true
68
73
  };
69
74
  this.phaseWidget = this.createWidget('text', props);
75
+ this.phaseWidget.on('mouse', (event) => {
76
+ if (event.button === 'left' && event.action === 'mousedown') {
77
+ params_1.RuntimeParams.continue = true;
78
+ PhaseRunner_1.PhaseRunner.instance.execute().then(() => this.logInfo('Completed')).catch((e) => {
79
+ this.logError('Error: ', e);
80
+ });
81
+ }
82
+ });
70
83
  }
71
84
  createUnitListWidget() {
72
85
  this.units = consts_1.MemKey_PhaseRunner.get().getUnits();
@@ -29,6 +29,7 @@ export declare class BaseUnit<C extends BaseUnit_Config = BaseUnit_Config, RTC e
29
29
  protected init(setInitialized?: boolean): Promise<void>;
30
30
  protected getRunnerParam(key: RunnerParamKey): string | undefined;
31
31
  private initLogClient;
32
+ protected setErrorStatus(status: string, error: Error): void;
32
33
  protected setStatus(status: string, type?: 'start' | 'end'): void;
33
34
  protected addToClassStack: (cls: Function) => void;
34
35
  isInstanceOf: (cls: Function) => boolean;
@@ -63,6 +63,7 @@ class BaseUnit extends ts_common_1.Logger {
63
63
  }
64
64
  initLogClient() {
65
65
  this.logger = new ts_common_1.LogClient_MemBuffer(this.tag);
66
+ this.logger.keepLogsNaturalColors();
66
67
  this.logger.setComposer((tag, level) => {
67
68
  ts_common_1._logger_finalDate.setTime(Date.now() - ts_common_1._logger_timezoneOffset);
68
69
  const date = ts_common_1._logger_finalDate.toISOString().replace(/T/, '_').replace(/Z/, '').substring(0, 23).split('_')[1];
@@ -73,6 +74,10 @@ class BaseUnit extends ts_common_1.Logger {
73
74
  });
74
75
  ts_common_1.BeLogged.addClient(this.logger);
75
76
  }
77
+ setErrorStatus(status, error) {
78
+ this.setStatus(status, 'end');
79
+ this.logError(error);
80
+ }
76
81
  setStatus(status, type) {
77
82
  let operationDuration = '';
78
83
  if (type === 'start')
@@ -20,7 +20,6 @@ export declare class Unit_TypescriptLib<C extends Unit_TypescriptLib_Config = Un
20
20
  Phase_Purge,
21
21
  Phase_Lint
22
22
  ]>, OnWatchEvent {
23
- private compilationError;
24
23
  private debounceWatch?;
25
24
  constructor(config: Unit_TypescriptLib<C, RTC>['config']);
26
25
  __onWatchEvent(type: WatchEventType, path?: string): Promise<void>;
@@ -36,7 +36,7 @@ const consts_2 = require("../consts");
36
36
  const CliError_1 = require("@nu-art/commando/shell/core/CliError");
37
37
  const nvm_1 = require("@nu-art/commando/shell/plugins/nvm");
38
38
  const basic_1 = require("@nu-art/commando/shell/plugins/basic");
39
- const extensionsToLint = ['.ts', '.tsx'];
39
+ const extensionsToLint = ['ts', 'tsx'];
40
40
  const assetExtensions = [
41
41
  'json',
42
42
  'scss',
@@ -50,7 +50,6 @@ const assetExtensions = [
50
50
  class Unit_TypescriptLib extends Unit_Typescript_1.Unit_Typescript {
51
51
  constructor(config) {
52
52
  super(config);
53
- this.compilationError = false;
54
53
  this.addToClassStack(Unit_TypescriptLib);
55
54
  runner_dispatchers_1.dispatcher_WatchEvent.addListener(this);
56
55
  }
@@ -59,7 +58,7 @@ class Unit_TypescriptLib extends Unit_Typescript_1.Unit_Typescript {
59
58
  return this.setStatus('Watching');
60
59
  if (this.debounceWatch)
61
60
  delete this.debounceWatch;
62
- this.debounceWatch = (0, ts_common_1.debounce)(() => this.handleWatchChange(path, [consts_2.WatchEvent_RemoveFile, consts_2.WatchEvent_RemoveDir].includes(type)), ts_common_1.Second * 4, ts_common_1.Second * 10);
61
+ this.debounceWatch = (0, ts_common_1.debounce)(() => this.handleWatchChange(path, [consts_2.WatchEvent_RemoveFile, consts_2.WatchEvent_RemoveDir].includes(type)), ts_common_1.Second * 2, ts_common_1.Second * 10);
63
62
  this.debounceWatch();
64
63
  }
65
64
  async init(setInitialized = true) {
@@ -102,27 +101,16 @@ class Unit_TypescriptLib extends Unit_Typescript_1.Unit_Typescript {
102
101
  async compileImpl() {
103
102
  const pathToCompile = `${this.runtime.pathTo.pkg}/src/main`;
104
103
  const pathToTSConfig = `${pathToCompile}/tsconfig.json`;
105
- try {
106
- const commando = this.allocateCommando(nvm_1.Commando_NVM, basic_1.Commando_Basic)
107
- .cd(this.runtime.pathTo.pkg)
108
- .append(`tsc -p "${pathToTSConfig}" --rootDir "${pathToCompile}" --outDir "${this.runtime.pathTo.output}"`)
109
- .addLogProcessor((log) => !log.includes('Now using node') && !log.includes('.nvmrc\' with version'));
110
- await this.executeAsyncCommando(commando, (stdout, stderr, exitCode) => {
111
- if (exitCode > 0)
112
- throw new CliError_1.CommandoException(`Error compiling`, stdout, stderr, exitCode);
113
- });
114
- // set compilation error status on success
115
- this.compilationError = false;
116
- }
117
- catch (e) {
118
- //In order to finish compile when running watch we just log the error instead of throwing it
119
- if (params_1.RuntimeParams.watch) {
120
- // set compilation error status on error
121
- this.compilationError = true;
122
- return this.logError(e);
123
- }
124
- throw e;
125
- }
104
+ const commando = this.allocateCommando(nvm_1.Commando_NVM, basic_1.Commando_Basic)
105
+ .cd(this.runtime.pathTo.pkg)
106
+ .append(`tsc -p "${pathToTSConfig}" --rootDir "${pathToCompile}" --outDir "${this.runtime.pathTo.output}"`)
107
+ .addLogProcessor((log) => !log.includes('Now using node') && !log.includes('.nvmrc\' with version'));
108
+ await this.executeAsyncCommando(commando, (stdout, stderr, exitCode) => {
109
+ if (stderr.length)
110
+ this.logError(stderr);
111
+ if (exitCode > 0)
112
+ throw new CliError_1.CommandoException(`Error compiling`, stdout, stderr, exitCode);
113
+ });
126
114
  }
127
115
  async copyAssetsToOutput() {
128
116
  const command = `find . \\( -name ${assetExtensions.map(suffix => `'*.${suffix}'`)
@@ -144,14 +132,19 @@ class Unit_TypescriptLib extends Unit_Typescript_1.Unit_Typescript {
144
132
  // ignore if path doesn't related to unit
145
133
  if (!path.startsWith(this.config.pathToPackage))
146
134
  return;
147
- this.setStatus('Compiling');
148
- // check if dist folder must be cleared
149
- if (shouldRemoveDist)
150
- await this.removeSpecificFileFromDist(path);
151
- // perform all watch actions
152
- await this.compileImpl();
153
- await this.copyAssetsToOutput();
154
- this.setStatus(`Watching${this.compilationError ? ' with error' : ''}`);
135
+ try {
136
+ this.setStatus('Compiling', 'start');
137
+ // check if dist folder must be cleared
138
+ if (shouldRemoveDist)
139
+ await this.removeSpecificFileFromDist(path);
140
+ // perform all watch actions
141
+ await this.compileImpl();
142
+ await this.copyAssetsToOutput();
143
+ this.setStatus(`Compiled and Watching`, 'end');
144
+ }
145
+ catch (e) {
146
+ this.setStatus(`Watching with error`, e);
147
+ }
155
148
  // dispatch unit post compile
156
149
  runner_dispatchers_1.dispatcher_UnitWatchCompile.dispatch(this);
157
150
  }
@@ -188,13 +181,19 @@ class Unit_TypescriptLib extends Unit_Typescript_1.Unit_Typescript {
188
181
  .execute();
189
182
  }
190
183
  async compile() {
191
- this.setStatus('Compile', 'start');
192
- await this.resolveTSConfig();
193
- await this.clearOutputDir();
194
- await this.compileImpl();
195
- await this.copyAssetsToOutput();
196
- await this.copyPackageJSONToOutput();
197
- this.setStatus(`Compiled${this.compilationError ? ' with error' : ''}`, 'end');
184
+ try {
185
+ this.setStatus('Compiling', 'start');
186
+ await this.resolveTSConfig();
187
+ await this.clearOutputDir();
188
+ await this.compileImpl();
189
+ await this.copyAssetsToOutput();
190
+ await this.copyPackageJSONToOutput();
191
+ this.setStatus(`Compiled`, 'end');
192
+ }
193
+ catch (e) {
194
+ this.setErrorStatus('Compilation Error', e);
195
+ throw e;
196
+ }
198
197
  }
199
198
  async purge() {
200
199
  await fs_1.promises.rm(this.runtime.pathTo.output, { recursive: true, force: true });
@@ -220,8 +219,8 @@ class Unit_TypescriptLib extends Unit_Typescript_1.Unit_Typescript {
220
219
  .execute();
221
220
  }
222
221
  async lint() {
223
- const pathToProjectESLint = RunnerParams_1.MemKey_RunnerParams.get()[RunnerParams_1.RunnerParamKey_ConfigPath] + '/.eslintrc.js';
224
- const pathToLint = this.runtime.pathTo.pkg + 'src/main';
222
+ const pathToProjectESLint = `${RunnerParams_1.MemKey_RunnerParams.get()[RunnerParams_1.RunnerParamKey_ConfigPath]}/eslint.config.cjs`;
223
+ const pathToLint = `${this.runtime.pathTo.pkg}src/main`;
225
224
  const extensions = extensionsToLint.map(ext => `--ext ${ext}`).join(' ');
226
225
  await this.allocateCommando(nvm_1.Commando_NVM)
227
226
  .append(`eslint --config ${pathToProjectESLint} ${extensions} ${pathToLint}`)
@@ -16,10 +16,17 @@ class Unit_FirebaseFunctionsApp extends core_1.Unit_TypescriptLib {
16
16
  async __onUnitWatchCompiled(unit) {
17
17
  if (this.runtime.unitDependencyNames.includes(unit.runtime.dependencyName)) {
18
18
  this.setStatus('Compiling', 'start');
19
- await this.compileImpl();
20
- await this.copyAssetsToOutput();
21
- await this.createDependenciesDir();
22
- this.setStatus('Compiled', 'end');
19
+ try {
20
+ await this.compileImpl();
21
+ await this.copyAssetsToOutput();
22
+ await this.createDependenciesDir();
23
+ this.setStatus('Compiled', 'end');
24
+ }
25
+ catch (e) {
26
+ this.setErrorStatus('Compilation Error', e);
27
+ this.logError(e);
28
+ // throw e;
29
+ }
23
30
  }
24
31
  }
25
32
  constructor(config) {
@@ -37,14 +44,20 @@ class Unit_FirebaseFunctionsApp extends core_1.Unit_TypescriptLib {
37
44
  }
38
45
  async compile() {
39
46
  this.setStatus('Compiling', 'start');
40
- await this.resolveTSConfig();
41
- await this.clearOutputDir();
42
- await this.createAppVersionFile();
43
- await this.compileImpl();
44
- await this.copyAssetsToOutput();
45
- await this.createDependenciesDir();
46
- await this.copyPackageJSONToOutput();
47
- this.setStatus('Compiled', 'end');
47
+ try {
48
+ await this.resolveTSConfig();
49
+ await this.clearOutputDir();
50
+ await this.createAppVersionFile();
51
+ await this.compileImpl();
52
+ await this.copyAssetsToOutput();
53
+ await this.createDependenciesDir();
54
+ await this.copyPackageJSONToOutput();
55
+ this.setStatus('Compiled', 'end');
56
+ }
57
+ catch (e) {
58
+ this.setErrorStatus('Compilation Error', e);
59
+ throw e;
60
+ }
48
61
  }
49
62
  async launch() {
50
63
  this.setStatus('Launching');
@@ -31,11 +31,17 @@ class Unit_FirebaseHostingApp extends core_1.Unit_TypescriptLib {
31
31
  }
32
32
  async compile() {
33
33
  this.setStatus('Compiling', 'start');
34
- await this.resolveTSConfig();
35
- await this.clearOutputDir();
36
- await this.createAppVersionFile();
37
- await this.compileImpl();
38
- this.setStatus('Compiled', 'end');
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
+ }
39
45
  }
40
46
  async launch() {
41
47
  this.setStatus('Launching');