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

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.
Files changed (104) hide show
  1. package/build-and-install-v3.d.ts +3 -0
  2. package/build-and-install-v3.js +27 -14
  3. package/build-and-install.js +0 -1
  4. package/core/consts.js +0 -1
  5. package/core/exceptions/PhaseAggregatedException.d.ts +5 -2
  6. package/core/exceptions/PhaseAggregatedException.js +18 -3
  7. package/core/exceptions/UnitPhaseException.d.ts +5 -0
  8. package/core/exceptions/UnitPhaseException.js +6 -0
  9. package/core/package/consts.js +0 -1
  10. package/core/params/params.d.ts +5 -5
  11. package/core/params/params.js +57 -29
  12. package/core/types/configs/firebasejson.js +0 -1
  13. package/core/types/configs/firebaserc.js +0 -1
  14. package/core/types/configs/index.js +0 -1
  15. package/core/types/configs/package-json.js +0 -1
  16. package/core/types/core.js +0 -1
  17. package/core/types/index.js +0 -1
  18. package/core/types/package/index.js +0 -1
  19. package/core/types/package/package.js +0 -1
  20. package/core/types/package/runtime-package.js +0 -1
  21. package/core/types/project-config.js +0 -1
  22. package/defaults/consts.js +0 -1
  23. package/old/PhaseRunnerDispatcher.js +0 -1
  24. package/old/runner-dispatchers.js +0 -1
  25. package/package.json +3 -3
  26. package/v3/PhaseManager.js +19 -5
  27. package/v3/RunningStatusHandler.d.ts +7 -5
  28. package/v3/RunningStatusHandler.js +21 -11
  29. package/v3/UnitsDependencyMapper/UnitsDependencyMapper.js +0 -1
  30. package/v3/UnitsMapper/UnitsMapper.js +0 -1
  31. package/v3/UnitsMapper/resolvers/UnitMapper_Base.js +0 -1
  32. package/v3/UnitsMapper/resolvers/UnitMapper_FirebaseFunction.js +0 -1
  33. package/v3/UnitsMapper/resolvers/UnitMapper_FirebaseHosting.js +3 -2
  34. package/v3/UnitsMapper/resolvers/UnitMapper_Node.js +41 -35
  35. package/v3/UnitsMapper/resolvers/UnitMapper_NodeLib.js +0 -1
  36. package/v3/UnitsMapper/resolvers/UnitMapper_NodeProject.js +0 -1
  37. package/v3/UnitsMapper/resolvers/index.js +0 -1
  38. package/v3/UnitsMapper/types.js +0 -1
  39. package/v3/core/FilesCache.js +0 -1
  40. package/v3/core/Unit_HelpPrinter.d.ts +1 -1
  41. package/v3/core/Unit_HelpPrinter.js +0 -1
  42. package/v3/core/types.js +0 -1
  43. package/v3/phase/consts.d.ts +1 -0
  44. package/v3/phase/consts.js +4 -1
  45. package/v3/phase/index.js +0 -1
  46. package/v3/phase/types.js +0 -1
  47. package/v3/units/BaseUnit.js +0 -1
  48. package/v3/units/ProjectUnit.js +0 -1
  49. package/v3/units/Unit_NodeProject.js +0 -1
  50. package/v3/units/Unit_PackageJson.js +0 -1
  51. package/v3/units/Unit_TypescriptLib.d.ts +1 -0
  52. package/v3/units/Unit_TypescriptLib.js +76 -36
  53. package/v3/units/firebase/Unit_FirebaseFunctionsApp.d.ts +5 -2
  54. package/v3/units/firebase/Unit_FirebaseFunctionsApp.js +47 -29
  55. package/v3/units/firebase/Unit_FirebaseHostingApp.d.ts +3 -2
  56. package/v3/units/firebase/Unit_FirebaseHostingApp.js +24 -6
  57. package/v3/units/firebase/common.d.ts +3 -0
  58. package/v3/units/firebase/common.js +13 -0
  59. package/v3/units/index.js +0 -1
  60. package/build-and-install-v3.js.map +0 -1
  61. package/build-and-install.js.map +0 -1
  62. package/core/consts.js.map +0 -1
  63. package/core/exceptions/PhaseAggregatedException.js.map +0 -1
  64. package/core/package/consts.js.map +0 -1
  65. package/core/params/params.js.map +0 -1
  66. package/core/types/configs/firebasejson.js.map +0 -1
  67. package/core/types/configs/firebaserc.js.map +0 -1
  68. package/core/types/configs/index.js.map +0 -1
  69. package/core/types/configs/package-json.js.map +0 -1
  70. package/core/types/core.js.map +0 -1
  71. package/core/types/index.js.map +0 -1
  72. package/core/types/package/index.js.map +0 -1
  73. package/core/types/package/package.js.map +0 -1
  74. package/core/types/package/runtime-package.js.map +0 -1
  75. package/core/types/project-config.js.map +0 -1
  76. package/defaults/consts.js.map +0 -1
  77. package/old/PhaseRunnerDispatcher.js.map +0 -1
  78. package/old/runner-dispatchers.js.map +0 -1
  79. package/v3/PhaseManager.js.map +0 -1
  80. package/v3/RunningStatusHandler.js.map +0 -1
  81. package/v3/UnitsDependencyMapper/UnitsDependencyMapper.js.map +0 -1
  82. package/v3/UnitsMapper/UnitsMapper.js.map +0 -1
  83. package/v3/UnitsMapper/resolvers/UnitMapper_Base.js.map +0 -1
  84. package/v3/UnitsMapper/resolvers/UnitMapper_FirebaseFunction.js.map +0 -1
  85. package/v3/UnitsMapper/resolvers/UnitMapper_FirebaseHosting.js.map +0 -1
  86. package/v3/UnitsMapper/resolvers/UnitMapper_Node.js.map +0 -1
  87. package/v3/UnitsMapper/resolvers/UnitMapper_NodeLib.js.map +0 -1
  88. package/v3/UnitsMapper/resolvers/UnitMapper_NodeProject.js.map +0 -1
  89. package/v3/UnitsMapper/resolvers/index.js.map +0 -1
  90. package/v3/UnitsMapper/types.js.map +0 -1
  91. package/v3/core/FilesCache.js.map +0 -1
  92. package/v3/core/Unit_HelpPrinter.js.map +0 -1
  93. package/v3/core/types.js.map +0 -1
  94. package/v3/phase/consts.js.map +0 -1
  95. package/v3/phase/index.js.map +0 -1
  96. package/v3/phase/types.js.map +0 -1
  97. package/v3/units/BaseUnit.js.map +0 -1
  98. package/v3/units/ProjectUnit.js.map +0 -1
  99. package/v3/units/Unit_NodeProject.js.map +0 -1
  100. package/v3/units/Unit_PackageJson.js.map +0 -1
  101. package/v3/units/Unit_TypescriptLib.js.map +0 -1
  102. package/v3/units/firebase/Unit_FirebaseFunctionsApp.js.map +0 -1
  103. package/v3/units/firebase/Unit_FirebaseHostingApp.js.map +0 -1
  104. package/v3/units/index.js.map +0 -1
@@ -1,6 +1,7 @@
1
1
  import { Logger } from '@nu-art/ts-common';
2
2
  import { BaiParams } from './core/params/params.js';
3
3
  import { Phase } from './v3/phase/index.js';
4
+ import { UnitsMapper } from './v3/UnitsMapper/UnitsMapper.js';
4
5
  import { ProjectUnit } from './v3/units/ProjectUnit.js';
5
6
  import { Unit_NodeProject } from './v3/units/index.js';
6
7
  import { BaseCliParam } from '@nu-art/commando/cli-params/types';
@@ -11,6 +12,7 @@ type BAI_Options = {
11
12
  runtimeParams: BaseCliParam<string, any>[];
12
13
  };
13
14
  export declare class BuildAndInstall extends Logger {
15
+ private unitsMapper;
14
16
  private phases;
15
17
  private pathToProject;
16
18
  private allUnits;
@@ -21,6 +23,7 @@ export declare class BuildAndInstall extends Logger {
21
23
  readonly runningStatus: RunningStatusHandler;
22
24
  constructor(config?: Partial<BAI_Options>);
23
25
  init(): Promise<void>;
26
+ prepareUnitsMapper(unitsMapper: UnitsMapper): void;
24
27
  setApplicativeUnits(projectUnits: ProjectUnit[]): void;
25
28
  setPhases(phases: Phase<string>[][]): void;
26
29
  build(): Promise<ProjectUnit<import("./v3/units/ProjectUnit.js").Config_ProjectUnit>[]>;
@@ -1,6 +1,6 @@
1
- import { _keys, arrayToMap, BeLogged, DebugFlag, filterDuplicates, LogClient_Terminal, Logger, LogLevel, merge } from '@nu-art/ts-common';
1
+ import { _keys, arrayToMap, BeLogged, DebugFlag, filterDuplicates, ImplementationMissingException, LogClient_Terminal, Logger, LogLevel, merge } from '@nu-art/ts-common';
2
2
  import { AllBaiParams } from './core/params/params.js';
3
- import { phases_Build, phases_Deploy, phases_Launch } from './v3/phase/index.js';
3
+ import { phases_Build, phases_Deploy, phases_Launch, phases_Terminating } from './v3/phase/index.js';
4
4
  import { UnitsMapper } from './v3/UnitsMapper/UnitsMapper.js';
5
5
  import { UnitsDependencyMapper } from './v3/UnitsDependencyMapper/UnitsDependencyMapper.js';
6
6
  import { FilesCache } from './v3/core/FilesCache.js';
@@ -15,10 +15,12 @@ import { RunningStatusHandler } from './v3/RunningStatusHandler.js';
15
15
  import { FileSystemUtils } from '@nu-art/ts-common/utils/FileSystemUtils';
16
16
  export const DefaultPhases = [
17
17
  ...phases_Build,
18
+ ...phases_Terminating,
18
19
  ...phases_Launch,
19
20
  ...phases_Deploy,
20
21
  ];
21
22
  export class BuildAndInstall extends Logger {
23
+ unitsMapper;
22
24
  phases = DefaultPhases;
23
25
  pathToProject;
24
26
  allUnits = [];
@@ -46,6 +48,16 @@ export class BuildAndInstall extends Logger {
46
48
  DebugFlag.DefaultLogLevel = LogLevel.Verbose;
47
49
  this.setMinLevel(DebugFlag.DefaultLogLevel);
48
50
  this.logDebug('Runtime params:', this.runtimeParams);
51
+ this.unitsMapper = new UnitsMapper();
52
+ this.prepareUnitsMapper(this.unitsMapper);
53
+ }
54
+ prepareUnitsMapper(unitsMapper) {
55
+ unitsMapper
56
+ .addRules(UnitMapper_NodeLib)
57
+ .addRules(UnitMapper_NodeProject)
58
+ .addRules(UnitMapper_FirebaseHosting)
59
+ .addRules(UnitMapper_FirebaseFunction)
60
+ .setRuntimeParams(this.runtimeParams);
49
61
  }
50
62
  setApplicativeUnits(projectUnits) {
51
63
  this.projectUnits.push(...projectUnits);
@@ -56,14 +68,7 @@ export class BuildAndInstall extends Logger {
56
68
  async build() {
57
69
  await this.init();
58
70
  this.logVerbose(`Resolving units from: ${this.pathToProject}`);
59
- const unitsMapper = new UnitsMapper();
60
- this.allUnits = await unitsMapper
61
- .addRules(UnitMapper_NodeLib)
62
- .addRules(UnitMapper_NodeProject)
63
- .addRules(UnitMapper_FirebaseHosting)
64
- .addRules(UnitMapper_FirebaseFunction)
65
- .setRuntimeParams(this.runtimeParams)
66
- .resolveUnits(this.pathToProject);
71
+ this.allUnits = await this.unitsMapper.resolveUnits(this.pathToProject);
67
72
  Object.freeze(this.allUnits);
68
73
  this.logDebug('Units found:', this.allUnits.map(unit => `${unit.constructor?.['name']}: ${unit.config.key}`).join('\n'));
69
74
  const unitKeyToUnitMap = arrayToMap(this.allUnits, unit => unit.config.key);
@@ -71,6 +76,8 @@ export class BuildAndInstall extends Logger {
71
76
  const nodeProjectUnit = allProjectUnits.find(unit => unit.isInstanceOf(Unit_NodeProject));
72
77
  // @ts-ignore
73
78
  this['nodeProjectUnit'] = nodeProjectUnit;
79
+ if (!this.nodeProjectUnit)
80
+ throw new ImplementationMissingException('NodeProject unit not found. Make sure you have a Unit_NodeProject in your project.');
74
81
  this.nodeProjectUnit.assignUnit(allProjectUnits);
75
82
  this.logDebug(`Parent unit: ${this.nodeProjectUnit.config.key}`);
76
83
  this.logDebug(`Child units: ${allProjectUnits.map(unit => unit.config.key).join(', ')}`);
@@ -124,9 +131,15 @@ export class BuildAndInstall extends Logger {
124
131
  if (killCounter > 5)
125
132
  process.exit(1);
126
133
  });
127
- await phaseManager.execute(executionPlan);
128
- this.logInfo('Completed successfully');
129
- this.logInfo('---------------------------------- Process Completed successfully ----------------------------------');
134
+ try {
135
+ await phaseManager.execute(executionPlan);
136
+ this.logInfo('Completed successfully');
137
+ this.logInfo('---------------------------------- Process Completed successfully ----------------------------------');
138
+ }
139
+ catch (e) {
140
+ this.logInfo('Process Failed');
141
+ this.logInfo('---------------------------------- Process Failed ----------------------------------');
142
+ throw e;
143
+ }
130
144
  }
131
145
  }
132
- //# sourceMappingURL=build-and-install-v3.js.map
@@ -15,4 +15,3 @@ import { BuildAndInstall } from './build-and-install-v3.js';
15
15
  // return process.exit(1);
16
16
  // });
17
17
  // });
18
- //# sourceMappingURL=build-and-install.js.map
package/core/consts.js CHANGED
@@ -9,4 +9,3 @@ export const CONST_TS_CONFIG = 'tsconfig.json';
9
9
  export const CONST_PNPM_WORKSPACE = 'pnpm-workspace.yaml';
10
10
  export const CONST_PNPM_LOCK = 'pnpm-lock.yaml';
11
11
  export const MemKey_Packages = new MemKey('bai-packages', true);
12
- //# sourceMappingURL=consts.js.map
@@ -1,5 +1,8 @@
1
- import { CustomException } from '@nu-art/ts-common';
1
+ import { CustomException, Logger } from '@nu-art/ts-common';
2
2
  import { ScheduledStep } from '../../v3/PhaseManager.js';
3
+ import { UnitPhaseException } from './UnitPhaseException.js';
3
4
  export declare class PhaseAggregatedException extends CustomException {
4
- constructor(errors: Error[], step: ScheduledStep);
5
+ errors: UnitPhaseException[];
6
+ constructor(errors: UnitPhaseException[], step: ScheduledStep);
7
+ print(logger: Logger): void;
5
8
  }
@@ -1,9 +1,24 @@
1
- import { CustomException } from '@nu-art/ts-common';
1
+ import { CustomException, isErrorOfType } from '@nu-art/ts-common';
2
+ import { CommandoException } from '@nu-art/commando/shell/core/CliError';
2
3
  export class PhaseAggregatedException extends CustomException {
4
+ errors;
3
5
  constructor(errors, step) {
4
6
  super(PhaseAggregatedException, `One or more errors occurred in step execution: ${JSON.stringify(step)}`);
5
7
  // @ts-ignore
6
- this.cause = errors;
8
+ this.errors = errors;
9
+ }
10
+ print(logger) {
11
+ logger.logError(this.message);
12
+ this.errors.forEach(error => {
13
+ const commandoError = isErrorOfType(error, CommandoException);
14
+ if (commandoError) {
15
+ logger.logWarning(`message: ${commandoError.message}`);
16
+ commandoError.cause && logger.logWarning('caused by: ', commandoError.cause);
17
+ logger.logError('stdout: ', commandoError.stdout);
18
+ logger.logError('stderr', commandoError.stderr);
19
+ return;
20
+ }
21
+ logger.logWarning('error: ', error);
22
+ });
7
23
  }
8
24
  }
9
- //# sourceMappingURL=PhaseAggregatedException.js.map
@@ -0,0 +1,5 @@
1
+ import { CustomException } from '@nu-art/ts-common';
2
+ import { BaseUnit } from '../../v3/units/index.js';
3
+ export declare class UnitPhaseException extends CustomException {
4
+ constructor(cause: Error, unit: BaseUnit, phase: string);
5
+ }
@@ -0,0 +1,6 @@
1
+ import { CustomException } from '@nu-art/ts-common';
2
+ export class UnitPhaseException extends CustomException {
3
+ constructor(cause, unit, phase) {
4
+ super(UnitPhaseException, `Error in ${unit.config.key} (${phase})`, cause);
5
+ }
6
+ }
@@ -38,4 +38,3 @@ export const Default_FirebaseProjectConfig = {
38
38
  },
39
39
  hosting: Default_HostingConfig
40
40
  };
41
- //# sourceMappingURL=consts.js.map
@@ -1,10 +1,7 @@
1
1
  import { BaseCliParam, CliParams } from '@nu-art/commando/cli-params/types';
2
2
  export declare const BaiParam_AllUnits: BaseCliParam<'allUnits', boolean>;
3
3
  export declare const BaiParam_DependencyTree: BaseCliParam<'dependencyTree', boolean>;
4
- export declare const BaiParam_CheckCyclicImports: BaseCliParam<'checkCyclicImports', boolean>;
5
- export declare const BaiParam_continue: BaseCliParam<'continue', boolean>;
6
4
  export declare const BaiParam_SetEnv: BaseCliParam<'environment', string>;
7
- export declare const BaiParam_Setup: BaseCliParam<'setup', boolean>;
8
5
  export declare const BaiParam_Install: BaseCliParam<'install', boolean>;
9
6
  export declare const BaiParam_Clean: BaseCliParam<'clean', boolean>;
10
7
  export declare const BaiParam_Purge: BaseCliParam<'purge', boolean>;
@@ -16,6 +13,7 @@ export declare const BaiParam_DryRun: BaseCliParam<'dryRun', boolean>;
16
13
  export declare const BaiParam_Lint: BaseCliParam<'lint', boolean>;
17
14
  export declare const BaiParam_Watch: BaseCliParam<'watch', boolean>;
18
15
  export declare const BaiParam_WatchBuildTree: BaseCliParam<'watchBuildTree', boolean>;
16
+ export declare const BaiParam_continue: BaseCliParam<'continue', boolean>;
19
17
  export declare const BaiParam_Test: BaseCliParam<'test', boolean>;
20
18
  export declare const TestTypes: string[];
21
19
  export type TestType = typeof TestTypes[number];
@@ -25,7 +23,7 @@ export declare const BaiParam_TestCase: BaseCliParam<'testCases', string[]>;
25
23
  export declare const BaiParam_TestDebugPort: BaseCliParam<'testDebugPort', number>;
26
24
  export declare const BaiParam_Launch: BaseCliParam<'launch', boolean>;
27
25
  export declare const BaiParam_DebugBackend: BaseCliParam<'debugBackend', boolean>;
28
- export declare const BaiParam_Deploy: BaseCliParam<'deploy', string>;
26
+ export declare const BaiParam_Deploy: BaseCliParam<'deploy', boolean>;
29
27
  export declare const BaiParam_Debug: BaseCliParam<'debug', boolean>;
30
28
  export declare const BaiParam_DebugLifecycle: BaseCliParam<'debugLifecycle', boolean>;
31
29
  export declare const BaiParam_Verbose: BaseCliParam<'verbose', boolean>;
@@ -33,8 +31,10 @@ export declare const BaiParam_QuickDeploy: BaseCliParam<'quickDeploy', boolean>;
33
31
  type PromoteType = 'patch' | 'minor' | 'major';
34
32
  export declare const BaiParam_Publish: BaseCliParam<'publish', PromoteType>;
35
33
  export declare const BaiParam_UsePackage: BaseCliParam<'usePackage', string[]>;
34
+ export declare const BaiParam_includePackage: BaseCliParam<'includePackage', string[]>;
36
35
  export declare const BaiParam_ToESM: BaseCliParam<'toESM', boolean>;
37
36
  export declare const BaiParam_Simulate: BaseCliParam<'simulation', boolean>;
38
- export declare const AllBaiParams: (BaseCliParam<"allUnits", boolean> | BaseCliParam<"dependencyTree", boolean> | BaseCliParam<"checkCyclicImports", boolean> | BaseCliParam<"continue", boolean> | BaseCliParam<"environment", string> | BaseCliParam<"setup", boolean> | BaseCliParam<"install", boolean> | BaseCliParam<"clean", boolean> | BaseCliParam<"purge", boolean> | BaseCliParam<"generate", boolean> | BaseCliParam<"generateDocs", boolean> | BaseCliParam<"noBuild", boolean> | BaseCliParam<"prepare", boolean> | BaseCliParam<"dryRun", boolean> | BaseCliParam<"lint", boolean> | BaseCliParam<"watch", boolean> | BaseCliParam<"watchBuildTree", boolean> | BaseCliParam<"test", boolean> | BaseCliParam<"testType", string[]> | BaseCliParam<"testFiles", string[]> | BaseCliParam<"testCases", string[]> | BaseCliParam<"testDebugPort", number> | BaseCliParam<"launch", boolean> | BaseCliParam<"debugBackend", boolean> | BaseCliParam<"deploy", string> | BaseCliParam<"debug", boolean> | BaseCliParam<"debugLifecycle", boolean> | BaseCliParam<"verbose", boolean> | BaseCliParam<"publish", PromoteType> | BaseCliParam<"usePackage", string[]> | BaseCliParam<"toESM", boolean> | BaseCliParam<"simulation", boolean>)[];
37
+ export declare const BaiParam_CheckCyclicImports: BaseCliParam<'checkCyclicImports', boolean>;
38
+ export declare const AllBaiParams: (BaseCliParam<"allUnits", boolean> | BaseCliParam<"dependencyTree", boolean> | BaseCliParam<"environment", string> | BaseCliParam<"install", boolean> | BaseCliParam<"clean", boolean> | BaseCliParam<"purge", boolean> | BaseCliParam<"generate", boolean> | BaseCliParam<"generateDocs", boolean> | BaseCliParam<"noBuild", boolean> | BaseCliParam<"prepare", boolean> | BaseCliParam<"dryRun", boolean> | BaseCliParam<"lint", boolean> | BaseCliParam<"watch", boolean> | BaseCliParam<"watchBuildTree", boolean> | BaseCliParam<"continue", boolean> | BaseCliParam<"test", boolean> | BaseCliParam<"testType", string[]> | BaseCliParam<"testFiles", string[]> | BaseCliParam<"testCases", string[]> | BaseCliParam<"testDebugPort", number> | BaseCliParam<"launch", boolean> | BaseCliParam<"debugBackend", boolean> | BaseCliParam<"deploy", boolean> | BaseCliParam<"debug", boolean> | BaseCliParam<"debugLifecycle", boolean> | BaseCliParam<"verbose", boolean> | BaseCliParam<"publish", PromoteType> | BaseCliParam<"usePackage", string[]> | BaseCliParam<"includePackage", string[]> | BaseCliParam<"toESM", boolean> | BaseCliParam<"simulation", boolean> | BaseCliParam<"checkCyclicImports", boolean>)[];
39
39
  export type BaiParams = CliParams<typeof AllBaiParams>;
40
40
  export {};
@@ -12,20 +12,6 @@ export const BaiParam_DependencyTree = {
12
12
  group: 'General',
13
13
  description: 'Will print the projects packages dependencies tree into the .trash folder'
14
14
  };
15
- export const BaiParam_CheckCyclicImports = {
16
- keys: ['--check-cyclic-imports', '-cci'],
17
- keyName: 'checkCyclicImports',
18
- type: 'boolean',
19
- group: 'General',
20
- description: 'will check for cyclic imports and render an svg with the import graph'
21
- };
22
- export const BaiParam_continue = {
23
- keys: ['--continue', '-con'],
24
- keyName: 'continue',
25
- type: 'boolean',
26
- group: 'Build',
27
- description: 'Will pick up where last build process failed'
28
- };
29
15
  export const BaiParam_SetEnv = {
30
16
  keys: ['--set-env', '-se'],
31
17
  keyName: 'environment',
@@ -34,13 +20,6 @@ export const BaiParam_SetEnv = {
34
20
  initialValue: 'local',
35
21
  description: 'Will set the .config-${environment}.json as the current .config.json and prepare it as base 64 for local usage \ninput required: envName(string)'
36
22
  };
37
- export const BaiParam_Setup = {
38
- keys: ['--setup'],
39
- keyName: 'setup',
40
- type: 'boolean',
41
- group: 'Build',
42
- description: 'Setup local project for developer'
43
- };
44
23
  export const BaiParam_Install = {
45
24
  keys: ['--install', '-i'],
46
25
  keyName: 'install',
@@ -122,6 +101,14 @@ export const BaiParam_WatchBuildTree = {
122
101
  description: 'Once watch triggers, will build the entire tree that depends on the libs that changed',
123
102
  dependencies: [{ param: BaiParam_Watch, value: true }, { param: BaiParam_NoBuild, value: true }, { param: BaiParam_Prepare, value: false }]
124
103
  };
104
+ export const BaiParam_continue = {
105
+ keys: ['--continue', '-con'],
106
+ keyName: 'continue',
107
+ type: 'boolean',
108
+ group: 'Build',
109
+ description: 'Will pick up where last build process failed',
110
+ dependencies: [{ param: BaiParam_Watch, value: false }]
111
+ };
125
112
  export const BaiParam_Test = {
126
113
  keys: ['--test', '-t'],
127
114
  keyName: 'test',
@@ -172,7 +159,7 @@ export const BaiParam_Launch = {
172
159
  keyName: 'launch',
173
160
  type: 'boolean',
174
161
  group: 'Apps',
175
- description: 'It will add the provided App to the launch list \nrequired input: path-to-app-to-launch(string)'
162
+ description: 'Will perform the launch phast on packages that supports it. use the --use-package flag to filter out for specific packages'
176
163
  };
177
164
  export const BaiParam_DebugBackend = {
178
165
  keys: ['--debug-backend', '-lbd'],
@@ -184,9 +171,15 @@ export const BaiParam_DebugBackend = {
184
171
  export const BaiParam_Deploy = {
185
172
  keys: ['--deploy', '-dep'],
186
173
  keyName: 'deploy',
187
- type: 'string',
174
+ type: 'boolean',
188
175
  group: 'Apps',
189
- description: 'Will add the provided App to the deploy list or all applications'
176
+ description: 'Will perform the deploy phast on packages that supports it. use the --use-package flag to filter out for specific packages',
177
+ dependencies: [
178
+ { param: BaiParam_Launch, value: false },
179
+ { param: BaiParam_Watch, value: false },
180
+ { param: BaiParam_WatchBuildTree, value: false },
181
+ { param: BaiParam_GenerateDocs, value: false },
182
+ ]
190
183
  };
191
184
  export const BaiParam_Debug = {
192
185
  keys: ['--debug', '-d'],
@@ -203,7 +196,7 @@ export const BaiParam_DebugLifecycle = {
203
196
  description: 'Will only print the run config and die'
204
197
  };
205
198
  export const BaiParam_Verbose = {
206
- keys: ['--verbose', '-d'],
199
+ keys: ['--verbose', '-v'],
207
200
  keyName: 'verbose',
208
201
  group: 'Other',
209
202
  type: 'boolean',
@@ -214,7 +207,14 @@ export const BaiParam_QuickDeploy = {
214
207
  keyName: 'quickDeploy',
215
208
  type: 'boolean',
216
209
  group: 'Other',
217
- description: 'Will deploy both frontend & backend, without any other lifecycle action'
210
+ description: 'Will perform the deploy phase without other lifecycle options',
211
+ dependencies: [
212
+ ...BaiParam_Deploy.dependencies,
213
+ { param: BaiParam_Purge, value: false },
214
+ { param: BaiParam_Lint, value: false },
215
+ { param: BaiParam_Test, value: false },
216
+ { param: BaiParam_NoBuild, value: true },
217
+ ]
218
218
  };
219
219
  export const BaiParam_Publish = {
220
220
  keys: ['--publish'],
@@ -239,6 +239,19 @@ export const BaiParam_UsePackage = {
239
239
  },
240
240
  dependencies: [{ param: BaiParam_AllUnits, value: true }]
241
241
  };
242
+ export const BaiParam_includePackage = {
243
+ keys: ['-in', '--include='],
244
+ keyName: 'includePackage',
245
+ type: 'string[]',
246
+ group: 'Other',
247
+ description: 'Will include the units to process',
248
+ process: (value) => {
249
+ if (!value)
250
+ return [];
251
+ return value.split(',').map(str => str.trim());
252
+ },
253
+ dependencies: []
254
+ };
242
255
  export const BaiParam_ToESM = {
243
256
  keys: ['-tesm', '--to-esm'],
244
257
  keyName: 'toESM',
@@ -248,13 +261,29 @@ export const BaiParam_ToESM = {
248
261
  dependencies: [{ param: BaiParam_AllUnits, value: true }]
249
262
  };
250
263
  export const BaiParam_Simulate = {
251
- keys: ['--simulate', '-sim'],
264
+ keys: ['--simulate', '-sim', '--simulation'],
252
265
  keyName: 'simulation',
253
266
  type: 'boolean',
254
267
  group: 'Other',
255
268
  description: 'In combination with other params, will not perform the outbound operation, but instead simulate it',
256
269
  dependencies: [{ param: BaiParam_AllUnits, value: true }]
257
270
  };
271
+ export const BaiParam_CheckCyclicImports = {
272
+ keys: ['--check-cyclic-imports', '-cci'],
273
+ keyName: 'checkCyclicImports',
274
+ type: 'boolean',
275
+ group: 'General',
276
+ description: 'will check for cyclic imports and render an svg with the import graph',
277
+ dependencies: [
278
+ { param: BaiParam_NoBuild, value: true },
279
+ { param: BaiParam_Launch, value: false },
280
+ { param: BaiParam_Install, value: false },
281
+ { param: BaiParam_Deploy, value: false },
282
+ { param: BaiParam_Publish, value: false },
283
+ { param: BaiParam_Purge, value: false },
284
+ { param: BaiParam_Clean, value: false },
285
+ ]
286
+ };
258
287
  export const AllBaiParams = [
259
288
  BaiParam_AllUnits,
260
289
  BaiParam_DependencyTree,
@@ -264,7 +293,6 @@ export const AllBaiParams = [
264
293
  BaiParam_continue,
265
294
  BaiParam_Prepare,
266
295
  BaiParam_SetEnv,
267
- BaiParam_Setup,
268
296
  BaiParam_Install,
269
297
  BaiParam_Generate, // TODO: to implement
270
298
  BaiParam_GenerateDocs, // TODO: to implement
@@ -284,9 +312,9 @@ export const AllBaiParams = [
284
312
  BaiParam_Debug,
285
313
  BaiParam_Verbose,
286
314
  BaiParam_Publish,
315
+ BaiParam_includePackage,
287
316
  BaiParam_UsePackage,
288
317
  BaiParam_ToESM,
289
318
  BaiParam_Simulate,
290
319
  BaiParam_DebugLifecycle
291
320
  ];
292
- //# sourceMappingURL=params.js.map
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=firebasejson.js.map
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=firebaserc.js.map
@@ -1,4 +1,3 @@
1
1
  export * from './firebasejson.js';
2
2
  export * from './firebaserc.js';
3
3
  export * from './package-json.js';
4
- //# sourceMappingURL=index.js.map
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=package-json.js.map
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=core.js.map
@@ -2,4 +2,3 @@ export * from './core.js';
2
2
  export * from './configs/index.js';
3
3
  export * from './package/index.js';
4
4
  export * from './project-config.js';
5
- //# sourceMappingURL=index.js.map
@@ -1,3 +1,2 @@
1
1
  export * from './package.js';
2
2
  export * from './runtime-package.js';
3
- //# sourceMappingURL=index.js.map
@@ -12,4 +12,3 @@ export const PackageTypes = [PackageType_InfraLib,
12
12
  PackageType_Sourceless,
13
13
  PackageType_Python];
14
14
  export const PackageTypesWithOutput = [PackageType_InfraLib, PackageType_ProjectLib, PackageType_FirebaseHostingApp, PackageType_FirebaseFunctionsApp];
15
- //# sourceMappingURL=package.js.map
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=runtime-package.js.map
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=project-config.js.map
@@ -34,4 +34,3 @@ export const Default_OutputFiles = {
34
34
  outputLogs: `${Default_OutputPath}/logs`,
35
35
  runningStatus: `${Default_OutputPath}/running-status.json`
36
36
  };
37
- //# sourceMappingURL=consts.js.map
@@ -30,4 +30,3 @@ export class PhaseRunnerDispatcher {
30
30
  export const dispatcher_PhaseChange = new PhaseRunnerDispatcher('__onPhaseChange');
31
31
  export const dispatcher_UnitStatusChange = new PhaseRunnerDispatcher('__onUnitStatusChange');
32
32
  export const dispatcher_UnitChange = new PhaseRunnerDispatcher('__onUnitsChange');
33
- //# sourceMappingURL=PhaseRunnerDispatcher.js.map
@@ -1,4 +1,3 @@
1
1
  import { PhaseRunnerDispatcher } from './PhaseRunnerDispatcher.js';
2
2
  export const dispatcher_WatchReady = new PhaseRunnerDispatcher('__onWatchReady');
3
3
  export const dispatcher_UnitWatchCompile = new PhaseRunnerDispatcher('__onUnitWatchCompiled');
4
- //# sourceMappingURL=runner-dispatchers.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nu-art/build-and-install",
3
- "version": "0.400.5",
3
+ "version": "0.400.7",
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.5",
35
- "@nu-art/commando": "0.400.5"
34
+ "@nu-art/ts-common": "0.400.7",
35
+ "@nu-art/commando": "0.400.7"
36
36
  },
37
37
  "unitConfig": {
38
38
  "type": "typescript-lib"
@@ -1,5 +1,6 @@
1
- import { addItemToArray, exists, flatArray, Logger, removeItemFromArray, timeCounter } from '@nu-art/ts-common';
1
+ import { addItemToArray, asArray, exists, flatArray, Logger, removeItemFromArray, timeCounter } from '@nu-art/ts-common';
2
2
  import { PhaseAggregatedException } from '../core/exceptions/PhaseAggregatedException.js';
3
+ import { UnitPhaseException } from '../core/exceptions/UnitPhaseException.js';
3
4
  export class PhaseManager extends Logger {
4
5
  phases;
5
6
  units;
@@ -28,6 +29,12 @@ export class PhaseManager extends Logger {
28
29
  const regexMatchers = usePackageKeys.map(filter => new RegExp(`.*?${filter}.*?`, 'i'));
29
30
  this.activeUnits = allUnits.filter(unit => regexMatchers.some(matcher => matcher.test(unit.config.key))).map(unit => unit.config.key);
30
31
  }
32
+ const packagesToInclude = this.runningStatus.runtimeParams.includePackage;
33
+ if (packagesToInclude?.length) {
34
+ const regexMatchers = asArray(packagesToInclude).map(filter => new RegExp(`.*?${filter}.*?`, 'i'));
35
+ this.activeUnits.push(...allUnits.filter(unit => regexMatchers.some(matcher => matcher.test(unit.config.key))).map(unit => unit.config.key));
36
+ this.activeUnits = [...new Set(this.activeUnits)];
37
+ }
31
38
  this.keyToPhaseMap = flatArray(phases).reduce((acc, phase) => {
32
39
  acc[phase.key] = phase;
33
40
  return acc;
@@ -75,11 +82,15 @@ export class PhaseManager extends Logger {
75
82
  break;
76
83
  const scheduledStep = _steps[i];
77
84
  const step = this.mapStep(scheduledStep);
85
+ await this.runningStatus.onStepStarted(i);
78
86
  this.logDebug(`Executing step #${i + 1}/${_steps.length}`);
79
87
  this.logVerbose(scheduledStep);
80
88
  const errors = [];
81
89
  let failedStep;
82
90
  await Promise.all(step.units.map(async (unit) => {
91
+ if (this.runningStatus.isCompleted(unit.config.key))
92
+ return;
93
+ let failed = false;
83
94
  for (const phase of step.phases) {
84
95
  if (this.killed)
85
96
  break;
@@ -100,19 +111,23 @@ export class PhaseManager extends Logger {
100
111
  }
101
112
  catch (error) {
102
113
  this.logError(`Phase(${phase.name}) - Error - ${unit.config.key}`, error);
103
- errors.push(error);
114
+ errors.push(new UnitPhaseException(error, unit, phase.key));
104
115
  failedStep = scheduledStep;
105
116
  this.killed = true;
117
+ failed = true;
106
118
  break;
107
119
  }
108
120
  finally {
109
121
  removeItemFromArray(this.runningUnits, unit);
110
122
  }
111
123
  }
124
+ if (!failed)
125
+ await this.runningStatus.onUnitCompleted(unit.config.key);
112
126
  }));
113
- await this.runningStatus.update(i);
114
- if (failedStep && errors.length)
127
+ if (failedStep && errors.length) {
115
128
  throw new PhaseAggregatedException(errors, failedStep);
129
+ }
130
+ await this.runningStatus.onStepEnded();
116
131
  }
117
132
  this.logInfo('All steps completed.');
118
133
  }
@@ -141,4 +156,3 @@ export class PhaseManager extends Logger {
141
156
  };
142
157
  }
143
158
  }
144
- //# sourceMappingURL=PhaseManager.js.map
@@ -1,16 +1,18 @@
1
1
  import { Logger } from '@nu-art/ts-common';
2
- import { ScheduledStep } from './PhaseManager.js';
3
2
  import { BaiParams } from '../core/params/params.js';
4
3
  export declare class RunningStatusHandler extends Logger {
5
4
  private isolated;
6
- private steps;
7
- private outputFolder;
5
+ private readonly outputFolder;
6
+ private completedUnits;
8
7
  runtimeParams: BaiParams;
9
8
  startIndex: number;
10
9
  constructor(outputFolder: string, runtimeParams: BaiParams);
11
10
  init(): Promise<void>;
12
- setSteps(steps: ScheduledStep[]): void;
13
11
  isolate(): RunningStatusHandler;
14
- update(index: number): Promise<void>;
12
+ isCompleted(unitKey: string): boolean;
13
+ onUnitCompleted(unitKey: string): Promise<void>;
14
+ onStepEnded(): Promise<void>;
15
+ onStepStarted(index: number): Promise<void>;
16
+ private saveStatus;
15
17
  load(): Promise<any>;
16
18
  }
@@ -2,8 +2,9 @@ import fs, { promises as _fs } from 'fs';
2
2
  import { __stringify, Logger } from '@nu-art/ts-common';
3
3
  export class RunningStatusHandler extends Logger {
4
4
  isolated = false;
5
- steps = [];
6
5
  outputFolder;
6
+ // The completed units in the phase.. when running -con, these can be skipped
7
+ completedUnits = [];
7
8
  runtimeParams;
8
9
  startIndex = 0;
9
10
  constructor(outputFolder, runtimeParams) {
@@ -20,31 +21,41 @@ export class RunningStatusHandler extends Logger {
20
21
  this.runtimeParams = Object.assign(currentParams, this.runtimeParams);
21
22
  }
22
23
  }
23
- setSteps(steps) {
24
- if (this.runtimeParams.continue)
25
- return;
26
- this.steps = steps;
27
- }
28
24
  isolate() {
29
25
  this.isolated = true;
30
26
  return this;
31
27
  }
32
- async update(index) {
28
+ isCompleted(unitKey) {
29
+ return this.completedUnits.includes(unitKey);
30
+ }
31
+ async onUnitCompleted(unitKey) {
32
+ this.logDebug(`On unit completed: ${unitKey}`);
33
+ this.completedUnits.push(unitKey);
34
+ await this.saveStatus();
35
+ }
36
+ async onStepEnded() {
37
+ this.logDebug(`On step ended successfully #${this.startIndex}`);
38
+ this.completedUnits = [];
39
+ }
40
+ async onStepStarted(index) {
33
41
  this.startIndex = index;
42
+ this.logDebug(`Setting execution index to #${this.startIndex}`);
34
43
  if (this.isolated)
35
44
  return;
36
- this.logVerbose(`Setting execution index to #${index}`, this.steps[index]);
45
+ await this.saveStatus();
46
+ }
47
+ async saveStatus() {
37
48
  await _fs.writeFile(`${this.outputFolder}/running-status.json`, __stringify({
38
49
  index: this.startIndex,
39
50
  runtimeParams: this.runtimeParams,
40
- steps: this.steps
51
+ completedUnits: this.completedUnits
41
52
  }, true));
42
53
  }
43
54
  async load() {
44
55
  try {
45
56
  const data = JSON.parse(await _fs.readFile(`${this.outputFolder}/running-status.json`, { encoding: 'utf-8' }));
46
57
  this.startIndex = data.index;
47
- this.steps = data.steps;
58
+ this.completedUnits = data.completedUnits ?? [];
48
59
  this.runtimeParams = data.runtimeParams;
49
60
  return data.index;
50
61
  }
@@ -54,4 +65,3 @@ export class RunningStatusHandler extends Logger {
54
65
  }
55
66
  }
56
67
  }
57
- //# sourceMappingURL=RunningStatusHandler.js.map
@@ -284,4 +284,3 @@ export class UnitsDependencyMapper extends Logger {
284
284
  return _values(this.map).filter(node => node.dependsOn.length === 0).map(node => node.key).sort();
285
285
  }
286
286
  }
287
- //# sourceMappingURL=UnitsDependencyMapper.js.map