@nu-art/build-and-install 0.401.0 → 0.401.1

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 (155) hide show
  1. package/BuildAndInstall.d.ts +40 -0
  2. package/BuildAndInstall.js +155 -0
  3. package/build-and-install-v3.d.ts +1 -44
  4. package/build-and-install-v3.js +1 -157
  5. package/build-and-install.js +11 -11
  6. package/config/consts.d.ts +43 -0
  7. package/config/consts.js +42 -0
  8. package/{core → config}/package/consts.d.ts +1 -1
  9. package/{core → config}/types/project-config.d.ts +3 -0
  10. package/core/FilesCache.d.ts +50 -0
  11. package/core/FilesCache.js +76 -0
  12. package/core/Unit_HelpPrinter.d.ts +16 -0
  13. package/core/Unit_HelpPrinter.js +47 -0
  14. package/core/params/params.d.ts +1 -41
  15. package/core/params/params.js +1 -332
  16. package/core/params.d.ts +50 -0
  17. package/core/params.js +441 -0
  18. package/{v3/core → core}/types.d.ts +1 -1
  19. package/{v3/UnitsDependencyMapper → dependencies}/UnitsDependencyMapper.d.ts +21 -1
  20. package/{v3/UnitsDependencyMapper → dependencies}/UnitsDependencyMapper.js +26 -3
  21. package/dependencies/types.d.ts +1 -0
  22. package/dependencies/types.js +1 -0
  23. package/exceptions/PhaseAggregatedException.d.ts +34 -0
  24. package/{core/exceptions → exceptions}/PhaseAggregatedException.js +26 -0
  25. package/exceptions/UnitPhaseException.d.ts +20 -0
  26. package/exceptions/UnitPhaseException.js +21 -0
  27. package/exports/ExportIndexCache.d.ts +25 -0
  28. package/exports/ExportIndexCache.js +115 -0
  29. package/exports/ExportMapper.d.ts +43 -0
  30. package/exports/ExportMapper.js +519 -0
  31. package/exports/IndicesMcpServer.d.ts +22 -0
  32. package/exports/IndicesMcpServer.js +220 -0
  33. package/exports/types.js +3 -0
  34. package/package.json +20 -9
  35. package/phases/PhaseManager.d.ts +130 -0
  36. package/{v3 → phases}/PhaseManager.js +99 -2
  37. package/{v3/phase → phases/definitions}/consts.d.ts +36 -0
  38. package/{v3/phase → phases/definitions}/consts.js +44 -2
  39. package/phases/definitions/types.d.ts +40 -0
  40. package/phases/index.d.ts +2 -0
  41. package/phases/index.js +2 -0
  42. package/run.js +10 -0
  43. package/runtime/RunningStatusHandler.d.ts +104 -0
  44. package/runtime/RunningStatusHandler.js +153 -0
  45. package/runtime/types.d.ts +1 -0
  46. package/runtime/types.js +2 -0
  47. package/{defaults → templates}/consts.d.ts +9 -0
  48. package/{defaults → templates}/consts.js +12 -2
  49. package/templates/firebase/functions/cloudbuild.yaml +17 -0
  50. package/templates/firebase/functions/dockerfile +19 -0
  51. package/templates/firebase/functions/service.yaml +49 -0
  52. package/{v3/units → units/base}/BaseUnit.d.ts +34 -4
  53. package/{v3/units → units/base}/BaseUnit.js +22 -2
  54. package/units/base/ProjectUnit.d.ts +32 -0
  55. package/units/base/ProjectUnit.js +25 -0
  56. package/units/base/types.js +1 -0
  57. package/units/discovery/UnitsMapper.d.ts +69 -0
  58. package/{v3/UnitsMapper → units/discovery}/UnitsMapper.js +50 -2
  59. package/units/discovery/resolvers/UnitMapper_Base.d.ts +65 -0
  60. package/units/discovery/resolvers/UnitMapper_Base.js +46 -0
  61. package/{v3/UnitsMapper → units/discovery}/resolvers/UnitMapper_FirebaseFunction.d.ts +5 -3
  62. package/units/discovery/resolvers/UnitMapper_FirebaseFunction.js +105 -0
  63. package/{v3/UnitsMapper → units/discovery}/resolvers/UnitMapper_FirebaseHosting.d.ts +3 -2
  64. package/{v3/UnitsMapper → units/discovery}/resolvers/UnitMapper_FirebaseHosting.js +14 -10
  65. package/{v3/UnitsMapper → units/discovery}/resolvers/UnitMapper_Node.d.ts +1 -1
  66. package/{v3/UnitsMapper → units/discovery}/resolvers/UnitMapper_Node.js +2 -2
  67. package/{v3/UnitsMapper → units/discovery}/resolvers/UnitMapper_NodeLib.d.ts +24 -1
  68. package/{v3/UnitsMapper → units/discovery}/resolvers/UnitMapper_NodeLib.js +24 -1
  69. package/{v3/UnitsMapper → units/discovery}/resolvers/UnitMapper_NodeProject.d.ts +22 -1
  70. package/{v3/UnitsMapper → units/discovery}/resolvers/UnitMapper_NodeProject.js +22 -1
  71. package/units/discovery/types.js +1 -0
  72. package/units/implementations/Unit_NodeProject.d.ts +59 -0
  73. package/{v3/units → units/implementations}/Unit_NodeProject.js +65 -5
  74. package/units/implementations/Unit_PackageJson.d.ts +56 -0
  75. package/{v3/units → units/implementations}/Unit_PackageJson.js +39 -3
  76. package/{v3/units → units/implementations}/Unit_TypescriptLib.d.ts +40 -4
  77. package/{v3/units → units/implementations}/Unit_TypescriptLib.js +167 -17
  78. package/units/implementations/firebase/Unit_FirebaseFunctionsApp.d.ts +233 -0
  79. package/units/implementations/firebase/Unit_FirebaseFunctionsApp.js +804 -0
  80. package/units/implementations/firebase/Unit_FirebaseHostingApp.d.ts +113 -0
  81. package/units/implementations/firebase/Unit_FirebaseHostingApp.js +320 -0
  82. package/units/implementations/firebase/common.d.ts +26 -0
  83. package/units/implementations/firebase/common.js +65 -0
  84. package/units/index.d.ts +6 -0
  85. package/units/index.js +6 -0
  86. package/v3/core/Unit_HelpPrinter.d.ts +1 -16
  87. package/v3/core/Unit_HelpPrinter.js +1 -47
  88. package/{v3 → workspace}/Workspace.d.ts +30 -15
  89. package/{v3 → workspace}/Workspace.js +48 -35
  90. package/core/consts.d.ts +0 -13
  91. package/core/consts.js +0 -12
  92. package/core/exceptions/PhaseAggregatedException.d.ts +0 -8
  93. package/core/exceptions/UnitPhaseException.d.ts +0 -5
  94. package/core/exceptions/UnitPhaseException.js +0 -6
  95. package/old/PhaseRunnerDispatcher.d.ts +0 -24
  96. package/old/PhaseRunnerDispatcher.js +0 -32
  97. package/old/runner-dispatchers.d.ts +0 -10
  98. package/old/runner-dispatchers.js +0 -3
  99. package/v3/PhaseManager.d.ts +0 -27
  100. package/v3/RunningStatusHandler.d.ts +0 -18
  101. package/v3/RunningStatusHandler.js +0 -67
  102. package/v3/UnitsMapper/UnitsMapper.d.ts +0 -21
  103. package/v3/UnitsMapper/resolvers/UnitMapper_Base.d.ts +0 -23
  104. package/v3/UnitsMapper/resolvers/UnitMapper_Base.js +0 -16
  105. package/v3/UnitsMapper/resolvers/UnitMapper_FirebaseFunction.js +0 -66
  106. package/v3/core/FilesCache.d.ts +0 -7
  107. package/v3/core/FilesCache.js +0 -33
  108. package/v3/phase/types.d.ts +0 -10
  109. package/v3/units/ProjectUnit.d.ts +0 -18
  110. package/v3/units/ProjectUnit.js +0 -11
  111. package/v3/units/Unit_NodeProject.d.ts +0 -30
  112. package/v3/units/Unit_PackageJson.d.ts +0 -17
  113. package/v3/units/firebase/Unit_FirebaseFunctionsApp.d.ts +0 -64
  114. package/v3/units/firebase/Unit_FirebaseFunctionsApp.js +0 -306
  115. package/v3/units/firebase/Unit_FirebaseHostingApp.d.ts +0 -49
  116. package/v3/units/firebase/Unit_FirebaseHostingApp.js +0 -118
  117. package/v3/units/firebase/common.d.ts +0 -3
  118. package/v3/units/firebase/common.js +0 -13
  119. package/v3/units/index.d.ts +0 -6
  120. package/v3/units/index.js +0 -6
  121. /package/{core → config}/package/consts.js +0 -0
  122. /package/{core → config}/types/configs/firebasejson.d.ts +0 -0
  123. /package/{core → config}/types/configs/firebasejson.js +0 -0
  124. /package/{core → config}/types/configs/firebaserc.d.ts +0 -0
  125. /package/{core → config}/types/configs/firebaserc.js +0 -0
  126. /package/{core → config}/types/configs/index.d.ts +0 -0
  127. /package/{core → config}/types/configs/index.js +0 -0
  128. /package/{core → config}/types/configs/package-json.d.ts +0 -0
  129. /package/{core → config}/types/configs/package-json.js +0 -0
  130. /package/{core → config}/types/core.d.ts +0 -0
  131. /package/{core → config}/types/core.js +0 -0
  132. /package/{core → config}/types/index.d.ts +0 -0
  133. /package/{core → config}/types/index.js +0 -0
  134. /package/{core → config}/types/package/index.d.ts +0 -0
  135. /package/{core → config}/types/package/index.js +0 -0
  136. /package/{core → config}/types/package/package.d.ts +0 -0
  137. /package/{core → config}/types/package/package.js +0 -0
  138. /package/{core → config}/types/package/runtime-package.d.ts +0 -0
  139. /package/{core → config}/types/package/runtime-package.js +0 -0
  140. /package/{core → config}/types/project-config.js +0 -0
  141. /package/{v3/core → core}/types.js +0 -0
  142. /package/{v3/UnitsMapper/types.js → exports/types.d.ts} +0 -0
  143. /package/{v3/phase → phases/definitions}/index.d.ts +0 -0
  144. /package/{v3/phase → phases/definitions}/index.js +0 -0
  145. /package/{v3/phase → phases/definitions}/types.js +0 -0
  146. /package/{v3/units/types.js → run.d.ts} +0 -0
  147. /package/{defaults/backend-proxy → templates/backend/proxy}/proxy._ts +0 -0
  148. /package/{defaults/.firebase_config → templates/firebase/config}/database.rules.json +0 -0
  149. /package/{defaults/.firebase_config → templates/firebase/config}/firestore.indexes.json +0 -0
  150. /package/{defaults/.firebase_config → templates/firebase/config}/firestore.rules +0 -0
  151. /package/{defaults/.firebase_config → templates/firebase/config}/storage.rules +0 -0
  152. /package/{v3/units → units/base}/types.d.ts +0 -0
  153. /package/{v3/UnitsMapper → units/discovery}/resolvers/index.d.ts +0 -0
  154. /package/{v3/UnitsMapper → units/discovery}/resolvers/index.js +0 -0
  155. /package/{v3/UnitsMapper → units/discovery}/types.d.ts +0 -0
package/core/params.js ADDED
@@ -0,0 +1,441 @@
1
+ import { BadImplementationException, tsValidate, tsValidateRegexp } from '@nu-art/ts-common';
2
+ export const BaiParam_AllUnits = {
3
+ keys: ['--all-units', '-all'],
4
+ keyName: 'allUnits',
5
+ type: 'boolean',
6
+ group: 'Build',
7
+ description: 'By default only top level and their dependencies are included, using this flag will include ALL the units'
8
+ };
9
+ export const BaiParam_DependencyTree = {
10
+ keys: ['--dependency-tree', '-dt'],
11
+ keyName: 'dependencyTree',
12
+ type: 'boolean',
13
+ group: 'General',
14
+ description: 'Will print the projects packages dependencies tree into the .trash folder'
15
+ };
16
+ export const BaiParam_SetEnv = {
17
+ keys: ['--set-env', '-se'],
18
+ keyName: 'environment',
19
+ type: 'string',
20
+ group: 'Build',
21
+ initialValue: 'local',
22
+ 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)'
23
+ };
24
+ export const BaiParam_Install = {
25
+ keys: ['--install', '-i'],
26
+ keyName: 'install',
27
+ type: 'boolean',
28
+ group: 'Build',
29
+ description: 'Will run \'pnpm install\' on entire project and will install global packages'
30
+ };
31
+ export const BaiParam_Clean = {
32
+ keys: ['--clean', '-c'],
33
+ keyName: 'clean',
34
+ type: 'boolean',
35
+ group: 'Clean',
36
+ description: 'Will delete the output(dist) & test output(dist-test) folders in all project packages'
37
+ };
38
+ export const BaiParam_Purge = {
39
+ keys: ['--purge', '-p'],
40
+ dependencies: [{ param: BaiParam_Clean, value: true }, { param: BaiParam_Install, value: true }],
41
+ keyName: 'purge',
42
+ group: 'Clean',
43
+ type: 'boolean',
44
+ description: 'Will delete the node_modules folder in all project packages \nWill perform --clean --install'
45
+ };
46
+ export const BaiParam_Generate = {
47
+ keys: ['--generate', '-g'],
48
+ keyName: 'generate',
49
+ type: 'boolean',
50
+ group: 'Build',
51
+ description: 'Will generate sources in the apps if needed'
52
+ };
53
+ export const BaiParam_GenerateDocs = {
54
+ keys: ['--generate-docs', '-docs'],
55
+ keyName: 'generateDocs',
56
+ type: 'boolean',
57
+ group: 'Build',
58
+ description: 'Would generate ts-docs documentation'
59
+ };
60
+ export const BaiParam_NoBuild = {
61
+ keys: ['--no-build', '-nb'],
62
+ keyName: 'noBuild',
63
+ group: 'Build',
64
+ type: 'boolean',
65
+ description: 'Skip the build and link steps',
66
+ };
67
+ export const BaiParam_Prepare = {
68
+ keys: [],
69
+ keyName: 'prepare',
70
+ group: 'Build',
71
+ type: 'boolean',
72
+ initialValue: true,
73
+ description: '-- internal param --'
74
+ };
75
+ export const BaiParam_DryRun = {
76
+ keys: ['--dry-run', '-dry', '--dryrun'],
77
+ keyName: 'dryRun',
78
+ group: 'Other',
79
+ type: 'boolean',
80
+ description: 'Do not perform any phase impl, only log the process'
81
+ };
82
+ export const BaiParam_Lint = {
83
+ keys: ['--lint'],
84
+ keyName: 'lint',
85
+ type: 'boolean',
86
+ group: 'Build',
87
+ description: 'Run lint on all the project packages'
88
+ };
89
+ export const BaiParam_Watch = {
90
+ keys: ['--watch', '-w'],
91
+ keyName: 'watch',
92
+ type: 'boolean',
93
+ group: 'Build',
94
+ description: 'will build and listen for changes in the libraries',
95
+ dependencies: [{ param: BaiParam_NoBuild, value: true }, { param: BaiParam_Prepare, value: false }, { param: BaiParam_AllUnits, value: true }]
96
+ };
97
+ export const BaiParam_WatchBuildTree = {
98
+ keys: ['--watchBuildTree', '-wbt'],
99
+ keyName: 'watchBuildTree',
100
+ type: 'boolean',
101
+ group: 'Build',
102
+ description: 'Once watch triggers, will build the entire tree that depends on the libs that changed',
103
+ dependencies: [{ param: BaiParam_Watch, value: true }, { param: BaiParam_NoBuild, value: true }, { param: BaiParam_Prepare, value: false }]
104
+ };
105
+ export const BaiParam_continue = {
106
+ keys: ['--continue', '-con'],
107
+ keyName: 'continue',
108
+ type: 'boolean',
109
+ group: 'Build',
110
+ description: 'Will pick up where last build process failed',
111
+ dependencies: [{ param: BaiParam_Watch, value: false }]
112
+ };
113
+ export const BaiParam_Test = {
114
+ keys: ['--test', '-t'],
115
+ keyName: 'test',
116
+ type: 'boolean',
117
+ group: 'Test',
118
+ description: 'Run the tests in all the project packages',
119
+ };
120
+ export const TestTypes = ['pure', 'firebase', 'ui', 'mobile'];
121
+ export const BaiParam_TestType = {
122
+ keys: ['--test-type', '-tt'],
123
+ keyName: 'testType',
124
+ type: 'string[]',
125
+ isArray: true,
126
+ group: 'Test',
127
+ options: TestTypes,
128
+ description: 'Run the tests in all the project packages',
129
+ dependencies: [{ param: BaiParam_Test, value: true }],
130
+ };
131
+ export const BaiParam_TestFile = {
132
+ keys: ['--test-file', '-tf'],
133
+ keyName: 'testFiles',
134
+ type: 'string[]',
135
+ isArray: true,
136
+ group: 'Test',
137
+ description: 'Run the specified test files',
138
+ dependencies: [{ param: BaiParam_Test, value: true }],
139
+ };
140
+ export const BaiParam_TestCase = {
141
+ keys: ['--test-case', '-tc'],
142
+ keyName: 'testCases',
143
+ type: 'string[]',
144
+ isArray: true,
145
+ group: 'Test',
146
+ description: 'Run only the specified test cases',
147
+ dependencies: [{ param: BaiParam_Test, value: true }],
148
+ };
149
+ export const BaiParam_TestDebugPort = {
150
+ keys: ['--test-debug', '-td'],
151
+ keyName: 'testDebugPort',
152
+ type: 'number',
153
+ group: 'Test',
154
+ defaultValue: 8010,
155
+ description: 'If provided will allow a debugger connection on the specified port, and will run the tests in watch mode',
156
+ dependencies: [{ param: BaiParam_Test, value: true }],
157
+ };
158
+ export const BaiParam_Launch = {
159
+ keys: ['--launch', '-l'],
160
+ keyName: 'launch',
161
+ type: 'boolean',
162
+ group: 'Apps',
163
+ description: 'Will perform the launch phast on packages that supports it. use the --use-package flag to filter out for specific packages'
164
+ };
165
+ export const BaiParam_DebugBackend = {
166
+ keys: ['--debug-backend', '-lbd'],
167
+ keyName: 'debugBackend',
168
+ type: 'boolean',
169
+ group: 'Apps',
170
+ description: 'Will add the app backend to the launch list - in debug mode'
171
+ };
172
+ export const BaiParam_Deploy = {
173
+ keys: ['--deploy', '-dep'],
174
+ keyName: 'deploy',
175
+ type: 'boolean',
176
+ group: 'Apps',
177
+ description: 'Will perform the deploy phast on packages that supports it. use the --use-package flag to filter out for specific packages',
178
+ dependencies: [
179
+ { param: BaiParam_Launch, value: false },
180
+ { param: BaiParam_Watch, value: false },
181
+ { param: BaiParam_WatchBuildTree, value: false },
182
+ { param: BaiParam_GenerateDocs, value: false },
183
+ ]
184
+ };
185
+ // Docker image tag validation: alphanumeric with dots, underscores, hyphens
186
+ // Cannot start with period or hyphen, max 128 characters
187
+ // Pattern: starts with alphanumeric, followed by 0-127 more alphanumeric/separator chars
188
+ const imageTagRegex = /^[a-zA-Z0-9][a-zA-Z0-9._-]{0,127}$/;
189
+ export const BaiParam_BuildPushImage = {
190
+ keys: ['--build-push-image', '-bpi'],
191
+ keyName: 'buildPushImage',
192
+ type: 'string',
193
+ group: 'Deployment',
194
+ description: `Build Docker container image and push to Artifact Registry. Usage: --build-push-image=<tag>`,
195
+ process: (value) => {
196
+ if (!value)
197
+ throw new BadImplementationException('Image tag is required. Use --build-push-image=<tag>');
198
+ tsValidate(value, tsValidateRegexp(imageTagRegex, true));
199
+ return value;
200
+ },
201
+ };
202
+ export const BaiParam_DeployImage = {
203
+ keys: ['--deploy-image', '-di'],
204
+ keyName: 'deployImage',
205
+ type: 'string',
206
+ group: 'Deployment',
207
+ description: 'Deploy container image from Artifact Registry to Firebase Functions. Usage: --deploy-image <tag>',
208
+ process: (value) => {
209
+ if (!value)
210
+ throw new BadImplementationException('Image tag is required. Use --deploy-image=<tag>');
211
+ tsValidate(value, tsValidateRegexp(imageTagRegex, true));
212
+ return value;
213
+ }
214
+ };
215
+ export const BaiParam_DeployFunction = {
216
+ keys: ['--deploy-function', '-df'],
217
+ keyName: 'deployFunction',
218
+ type: 'string',
219
+ group: 'Deployment',
220
+ description: 'Deploy a specific function by name. Usage: --deploy-function <functionName>',
221
+ process: (value) => {
222
+ if (!value)
223
+ throw new BadImplementationException('Function name is required. Use --deploy-function=<functionName>');
224
+ // Function name validation - just ensure it's a non-empty string
225
+ if (typeof value !== 'string' || value.trim().length === 0)
226
+ throw new BadImplementationException('Function name must be a non-empty string');
227
+ return value;
228
+ },
229
+ };
230
+ export const BaiParam_DeleteFunctions = {
231
+ keys: ['--delete-functions'],
232
+ keyName: 'deleteFunctions',
233
+ type: 'boolean',
234
+ group: 'Deployment',
235
+ description: 'Delete functions before deployment. Behavior depends on other flags.',
236
+ };
237
+ export const BaiParam_DeleteFunction = {
238
+ keys: ['--delete-function', '-delfn'],
239
+ keyName: 'deleteFunction',
240
+ type: 'string',
241
+ group: 'Deployment',
242
+ description: 'Delete a specific function by name before deployment. Usage: --delete-function=<functionName>',
243
+ process: (value) => {
244
+ if (!value)
245
+ throw new BadImplementationException('Function name is required. Use --delete-function=<functionName>');
246
+ // Function name validation - just ensure it's a non-empty string
247
+ if (typeof value !== 'string' || value.trim().length === 0)
248
+ throw new BadImplementationException('Function name must be a non-empty string');
249
+ return value;
250
+ },
251
+ dependencies: [{ param: BaiParam_DeleteFunctions, value: true }]
252
+ };
253
+ export const BaiParam_Debug = {
254
+ keys: ['--debug', '-d'],
255
+ keyName: 'debug',
256
+ group: 'Other',
257
+ type: 'boolean',
258
+ description: 'Will print the parameters the script is running with'
259
+ };
260
+ export const BaiParam_DebugLifecycle = {
261
+ keys: ['--debug-lifecycle', '-dl'],
262
+ keyName: 'debugLifecycle',
263
+ group: 'Other',
264
+ type: 'boolean',
265
+ description: 'Will only print the run config and die'
266
+ };
267
+ export const BaiParam_Verbose = {
268
+ keys: ['--verbose', '-v'],
269
+ keyName: 'verbose',
270
+ group: 'Other',
271
+ type: 'boolean',
272
+ description: 'Set log level to verbose'
273
+ };
274
+ export const BaiParam_QuickDeploy = {
275
+ keys: ['--quick-deploy', '-qd'],
276
+ keyName: 'quickDeploy',
277
+ type: 'boolean',
278
+ group: 'Other',
279
+ description: 'Will perform the deploy phase without other lifecycle options',
280
+ dependencies: [
281
+ ...BaiParam_Deploy.dependencies,
282
+ { param: BaiParam_Purge, value: false },
283
+ { param: BaiParam_Lint, value: false },
284
+ { param: BaiParam_Test, value: false },
285
+ { param: BaiParam_NoBuild, value: true },
286
+ ]
287
+ };
288
+ export const BaiParam_Publish = {
289
+ keys: ['--publish'],
290
+ keyName: 'publish',
291
+ type: 'string',
292
+ group: 'Other',
293
+ options: ['patch', 'minor', 'major'],
294
+ defaultValue: 'patch',
295
+ description: 'Will publish to NPM any package that is not marked as private in its __package.json \nenum options: patch | minor | major \nDefault Param: patch',
296
+ process: (part) => part ?? 'patch'
297
+ };
298
+ export const BaiParam_UsePackage = {
299
+ keys: ['-up', '--use-packages'],
300
+ keyName: 'usePackage',
301
+ type: 'string[]',
302
+ group: 'Other',
303
+ description: 'Will specify units to process',
304
+ process: (value) => {
305
+ if (!value)
306
+ return [];
307
+ return value.split(',').map(str => str.trim());
308
+ },
309
+ dependencies: [{ param: BaiParam_AllUnits, value: true }]
310
+ };
311
+ export const BaiParam_BuildTree = {
312
+ keys: ['--build-tree', '-bt'],
313
+ keyName: 'buildTree',
314
+ type: 'boolean',
315
+ group: 'Build',
316
+ description: 'When used with -up, makes all transitive dependencies active (compile/test them too)',
317
+ };
318
+ export const BaiParam_Apps = {
319
+ keys: ['-app', '--application'],
320
+ keyName: 'includeApps',
321
+ type: 'string[]',
322
+ group: 'Build',
323
+ description: 'Will include the applications and all their dependency units to the build process',
324
+ process: (value) => {
325
+ if (!value)
326
+ return [];
327
+ return value.split(',').map(str => str.trim());
328
+ },
329
+ isArray: true,
330
+ dependencies: [
331
+ { param: BaiParam_UsePackage, value: (currentValue) => currentValue },
332
+ { param: BaiParam_BuildTree, value: true }
333
+ ]
334
+ };
335
+ export const BaiParam_ToESM = {
336
+ keys: ['-tesm', '--to-esm'],
337
+ keyName: 'toESM',
338
+ type: 'boolean',
339
+ group: 'Other',
340
+ description: 'Will migrate existing CJS code to ESM',
341
+ dependencies: [{ param: BaiParam_AllUnits, value: true }]
342
+ };
343
+ export const BaiParam_Simulate = {
344
+ keys: ['--simulate', '-sim', '--simulation'],
345
+ keyName: 'simulation',
346
+ type: 'boolean',
347
+ group: 'Other',
348
+ description: 'In combination with other params, will not perform the outbound operation, but instead simulate it',
349
+ dependencies: [{ param: BaiParam_AllUnits, value: true }]
350
+ };
351
+ export const BaiParam_CheckCyclicImports = {
352
+ keys: ['--check-cyclic-imports', '-cci'],
353
+ keyName: 'checkCyclicImports',
354
+ type: 'boolean',
355
+ group: 'General',
356
+ description: 'will check for cyclic imports and render an svg with the import graph',
357
+ dependencies: [
358
+ { param: BaiParam_NoBuild, value: true },
359
+ { param: BaiParam_Launch, value: false },
360
+ { param: BaiParam_Install, value: false },
361
+ { param: BaiParam_Deploy, value: false },
362
+ { param: BaiParam_Publish, value: false },
363
+ { param: BaiParam_Purge, value: false },
364
+ { param: BaiParam_Clean, value: false },
365
+ ]
366
+ };
367
+ export const BaiParam_ExtractDynamicDeps = {
368
+ keys: ['--extract-dynamic-deps', '-edd'],
369
+ keyName: 'extractDynamicDeps',
370
+ type: 'boolean',
371
+ group: 'Build',
372
+ description: 'Extract dynamic dependencies from TypeScript files and write to _dynamic-deps.json',
373
+ dependencies: [{ param: BaiParam_AllUnits, value: true }]
374
+ };
375
+ export const BaiParam_MapExports = {
376
+ keys: ['--map-exports', '-me'],
377
+ keyName: 'mapExports',
378
+ type: 'boolean',
379
+ group: 'Build',
380
+ description: 'Map all exported symbols from TypeScript files and write to _export-for-import.json',
381
+ dependencies: [{ param: BaiParam_AllUnits, value: true }]
382
+ };
383
+ export const BaiParam_IndicesMcpServer = {
384
+ keys: ['--indices-mcp-server', '-imcp'],
385
+ keyName: 'indicesMcpServer',
386
+ type: 'boolean',
387
+ group: 'Launch',
388
+ description: 'Start Export Indices MCP server for export index queries'
389
+ };
390
+ export const BaiParam_IndicesMcpPort = {
391
+ keys: ['--indices-mcp-port'],
392
+ keyName: 'indicesMcpPort',
393
+ type: 'number',
394
+ group: 'Launch',
395
+ description: 'Port for Export Indices MCP server (default: 3001)',
396
+ dependencies: [{ param: BaiParam_IndicesMcpServer, value: true }]
397
+ };
398
+ export const AllBaiParams = [
399
+ BaiParam_AllUnits,
400
+ BaiParam_DependencyTree,
401
+ BaiParam_CheckCyclicImports,
402
+ BaiParam_Purge,
403
+ BaiParam_Clean,
404
+ BaiParam_continue,
405
+ BaiParam_Prepare,
406
+ BaiParam_SetEnv,
407
+ BaiParam_Install,
408
+ BaiParam_Generate, // TODO: to implement
409
+ BaiParam_GenerateDocs, // TODO: to implement
410
+ BaiParam_NoBuild,
411
+ BaiParam_Apps,
412
+ BaiParam_DryRun,
413
+ BaiParam_Lint,
414
+ BaiParam_Watch,
415
+ BaiParam_WatchBuildTree,
416
+ BaiParam_Test,
417
+ BaiParam_TestType,
418
+ BaiParam_TestFile,
419
+ BaiParam_TestCase,
420
+ BaiParam_TestDebugPort,
421
+ BaiParam_Launch,
422
+ BaiParam_Deploy,
423
+ BaiParam_BuildPushImage,
424
+ BaiParam_DeployImage,
425
+ BaiParam_DeployFunction,
426
+ BaiParam_DeleteFunctions,
427
+ BaiParam_DeleteFunction,
428
+ BaiParam_DebugBackend,
429
+ BaiParam_Debug,
430
+ BaiParam_Verbose,
431
+ BaiParam_Publish,
432
+ BaiParam_UsePackage,
433
+ BaiParam_ToESM,
434
+ BaiParam_Simulate,
435
+ BaiParam_BuildTree,
436
+ BaiParam_ExtractDynamicDeps,
437
+ BaiParam_MapExports,
438
+ BaiParam_IndicesMcpServer,
439
+ BaiParam_IndicesMcpPort,
440
+ BaiParam_DebugLifecycle
441
+ ];
@@ -1,6 +1,6 @@
1
1
  import { AsyncVoidFunction } from '@nu-art/ts-common';
2
2
  import { BaseUnit } from '../units/index.js';
3
- import { Phase } from '../phase/index.js';
3
+ import { Phase } from '../phases/definitions/index.js';
4
4
  export type Unit<P extends Phase<string>[]> = BaseUnit & UnitPhaseImplementor<P>;
5
5
  export type UnitPhaseImplementor<P extends Phase<string>[]> = {
6
6
  [K in P[number]['method']]: AsyncVoidFunction;
@@ -4,7 +4,27 @@ export type UnitDependentNode = {
4
4
  dependsOn: string[];
5
5
  };
6
6
  /**
7
- * Maps unit dependencies and provides tools to analyze and operate on the dependency graph.
7
+ * Manages unit dependency graph and provides dependency analysis operations.
8
+ *
9
+ * **Key Operations**:
10
+ * - **buildDependencyTree()**: Builds layers of units ordered by dependencies (dependencies first)
11
+ * - **getTransitiveDependencies()**: Gets all transitive dependencies for given units
12
+ * - **getReverseDependencies()**: Gets all units that depend on given units
13
+ * - **filterDependencies()**: Filters dependency graph to only include specified units
14
+ *
15
+ * **Dependency Graph**:
16
+ * - Units are nodes, dependencies are edges
17
+ * - Validates all dependencies exist (throws if unknown dependency)
18
+ * - Supports pruning (removing non-participating units from graph)
19
+ *
20
+ * **Tree Building Algorithm**:
21
+ * 1. Builds reverse dependency map (who depends on whom)
22
+ * 2. Finds leaf nodes (no dependents)
23
+ * 3. Removes leaves and adds to current layer
24
+ * 4. Repeats until all nodes processed
25
+ * 5. Returns layers from bottom (dependencies) to top (dependents)
26
+ *
27
+ * **Usage**: Used by Workspace to determine execution order and resolve transitive dependencies.
8
28
  */
9
29
  export declare class UnitsDependencyMapper extends Logger {
10
30
  private readonly map;
@@ -2,7 +2,27 @@ import { __stringify, _keys, _values, BadImplementationException, DateTimeFormat
2
2
  import { FileSystemUtils } from '@nu-art/ts-common/utils/FileSystemUtils';
3
3
  import { resolve } from 'path';
4
4
  /**
5
- * Maps unit dependencies and provides tools to analyze and operate on the dependency graph.
5
+ * Manages unit dependency graph and provides dependency analysis operations.
6
+ *
7
+ * **Key Operations**:
8
+ * - **buildDependencyTree()**: Builds layers of units ordered by dependencies (dependencies first)
9
+ * - **getTransitiveDependencies()**: Gets all transitive dependencies for given units
10
+ * - **getReverseDependencies()**: Gets all units that depend on given units
11
+ * - **filterDependencies()**: Filters dependency graph to only include specified units
12
+ *
13
+ * **Dependency Graph**:
14
+ * - Units are nodes, dependencies are edges
15
+ * - Validates all dependencies exist (throws if unknown dependency)
16
+ * - Supports pruning (removing non-participating units from graph)
17
+ *
18
+ * **Tree Building Algorithm**:
19
+ * 1. Builds reverse dependency map (who depends on whom)
20
+ * 2. Finds leaf nodes (no dependents)
21
+ * 3. Removes leaves and adds to current layer
22
+ * 4. Repeats until all nodes processed
23
+ * 5. Returns layers from bottom (dependencies) to top (dependents)
24
+ *
25
+ * **Usage**: Used by Workspace to determine execution order and resolve transitive dependencies.
6
26
  */
7
27
  export class UnitsDependencyMapper extends Logger {
8
28
  map = {};
@@ -68,17 +88,20 @@ export class UnitsDependencyMapper extends Logger {
68
88
  layers.push(sortArray(bottomLayer));
69
89
  while (resolved.size < participatingKeys.length - topLayer.length) {
70
90
  const nextLayer = [];
91
+ let lastNode;
71
92
  for (const key of _keys(map)) {
72
93
  const node = map[key];
73
94
  if (resolved.has(key) || topLayer.includes(key))
74
95
  continue;
75
- if (node.dependsOn.every(dep => resolved.has(dep)))
96
+ if (node.dependsOn.every(dep => resolved.has(dep))) {
97
+ lastNode = node;
76
98
  nextLayer.push(key);
99
+ }
77
100
  }
78
101
  if (nextLayer.length === 0) {
79
102
  this.logWarning(participatingKeys);
80
103
  this.logWarning(map);
81
- this.logWarning(layers);
104
+ this.logWarning(`Cyclic or disconnected dependency detected: ${lastNode?.key ?? '??'} and [${nextLayer.join(', ')}]`);
82
105
  throw new Error('Cyclic or disconnected dependency detected');
83
106
  }
84
107
  nextLayer.sort();
@@ -0,0 +1 @@
1
+ export * from './UnitsDependencyMapper.js';
@@ -0,0 +1 @@
1
+ export * from './UnitsDependencyMapper.js';
@@ -0,0 +1,34 @@
1
+ import { CustomException, Logger } from '@nu-art/ts-common';
2
+ import { ScheduledStep } from '../phases/PhaseManager.js';
3
+ import { UnitPhaseException } from './UnitPhaseException.js';
4
+ /**
5
+ * Exception thrown when one or more phases fail during execution.
6
+ *
7
+ * **Aggregation**: Contains all `UnitPhaseException` errors from a failed step.
8
+ *
9
+ * **Error Formatting**: The `print()` method provides detailed error output:
10
+ * - For `CommandoException`: Shows message, cause, stdout, and stderr
11
+ * - For other errors: Shows error object
12
+ *
13
+ * **Usage**: Thrown by `PhaseManager.execute()` when any phase fails.
14
+ */
15
+ export declare class PhaseAggregatedException extends CustomException {
16
+ errors: UnitPhaseException[];
17
+ /**
18
+ * Creates a new PhaseAggregatedException.
19
+ *
20
+ * @param errors - Array of unit/phase errors that occurred
21
+ * @param step - The step that failed
22
+ */
23
+ constructor(errors: UnitPhaseException[], step: ScheduledStep);
24
+ /**
25
+ * Prints detailed error information to logger.
26
+ *
27
+ * **Formatting**:
28
+ * - CommandoException: Shows message, cause, stdout, stderr
29
+ * - Other errors: Shows error object
30
+ *
31
+ * @param logger - Logger to print errors to
32
+ */
33
+ print(logger: Logger): void;
34
+ }
@@ -1,12 +1,38 @@
1
1
  import { CustomException, isErrorOfType } from '@nu-art/ts-common';
2
2
  import { CommandoException } from '@nu-art/commando/shell/core/CliError';
3
+ /**
4
+ * Exception thrown when one or more phases fail during execution.
5
+ *
6
+ * **Aggregation**: Contains all `UnitPhaseException` errors from a failed step.
7
+ *
8
+ * **Error Formatting**: The `print()` method provides detailed error output:
9
+ * - For `CommandoException`: Shows message, cause, stdout, and stderr
10
+ * - For other errors: Shows error object
11
+ *
12
+ * **Usage**: Thrown by `PhaseManager.execute()` when any phase fails.
13
+ */
3
14
  export class PhaseAggregatedException extends CustomException {
4
15
  errors;
16
+ /**
17
+ * Creates a new PhaseAggregatedException.
18
+ *
19
+ * @param errors - Array of unit/phase errors that occurred
20
+ * @param step - The step that failed
21
+ */
5
22
  constructor(errors, step) {
6
23
  super(PhaseAggregatedException, `One or more errors occurred in step execution: ${JSON.stringify(step)}`);
7
24
  // @ts-ignore
8
25
  this.errors = errors;
9
26
  }
27
+ /**
28
+ * Prints detailed error information to logger.
29
+ *
30
+ * **Formatting**:
31
+ * - CommandoException: Shows message, cause, stdout, stderr
32
+ * - Other errors: Shows error object
33
+ *
34
+ * @param logger - Logger to print errors to
35
+ */
10
36
  print(logger) {
11
37
  logger.logError(this.message);
12
38
  this.errors.forEach(error => {
@@ -0,0 +1,20 @@
1
+ import { CustomException } from '@nu-art/ts-common';
2
+ import { BaseUnit } from '../units/index.js';
3
+ /**
4
+ * Exception thrown when a specific phase fails on a specific unit.
5
+ *
6
+ * **Context**: Contains the unit and phase that failed, along with the underlying error.
7
+ *
8
+ * **Usage**: Created by `PhaseManager.execute()` when a phase method throws an error.
9
+ * Multiple `UnitPhaseException`s are aggregated into `PhaseAggregatedException`.
10
+ */
11
+ export declare class UnitPhaseException extends CustomException {
12
+ /**
13
+ * Creates a new UnitPhaseException.
14
+ *
15
+ * @param cause - The underlying error that occurred
16
+ * @param unit - The unit that failed
17
+ * @param phase - The phase key that failed
18
+ */
19
+ constructor(cause: Error, unit: BaseUnit, phase: string);
20
+ }
@@ -0,0 +1,21 @@
1
+ import { CustomException } from '@nu-art/ts-common';
2
+ /**
3
+ * Exception thrown when a specific phase fails on a specific unit.
4
+ *
5
+ * **Context**: Contains the unit and phase that failed, along with the underlying error.
6
+ *
7
+ * **Usage**: Created by `PhaseManager.execute()` when a phase method throws an error.
8
+ * Multiple `UnitPhaseException`s are aggregated into `PhaseAggregatedException`.
9
+ */
10
+ export class UnitPhaseException extends CustomException {
11
+ /**
12
+ * Creates a new UnitPhaseException.
13
+ *
14
+ * @param cause - The underlying error that occurred
15
+ * @param unit - The unit that failed
16
+ * @param phase - The phase key that failed
17
+ */
18
+ constructor(cause, unit, phase) {
19
+ super(UnitPhaseException, `Error in ${unit.config.key} (${phase})`, cause);
20
+ }
21
+ }
@@ -0,0 +1,25 @@
1
+ import { ExportSymbol } from './ExportMapper.js';
2
+ type CachedExportIndex = {
3
+ exports: ExportSymbol[];
4
+ byName: Map<string, ExportSymbol>;
5
+ byFile: Map<string, ExportSymbol[]>;
6
+ byType: Map<string, ExportSymbol[]>;
7
+ indexMtime: number;
8
+ sourceMtime: number;
9
+ packageRoot: string;
10
+ packageName: string;
11
+ projectRoot: string;
12
+ };
13
+ export declare const ExportIndexCache: {
14
+ getIndexPath(projectRoot: string, packageName: string): string;
15
+ load(projectRoot: string, packageRoot: string, packageName: string): Promise<CachedExportIndex>;
16
+ calculateSourceMtime(packageRoot: string): Promise<number>;
17
+ isStale(projectRoot: string, packageRoot: string, packageName: string): Promise<boolean>;
18
+ getByName(projectRoot: string, packageRoot: string, packageName: string, symbolName: string): Promise<ExportSymbol | null>;
19
+ getByFile(projectRoot: string, packageRoot: string, packageName: string, filePath: string): Promise<ExportSymbol[]>;
20
+ getByType(projectRoot: string, packageRoot: string, packageName: string, symbolType: string): Promise<ExportSymbol[]>;
21
+ getAll(projectRoot: string, packageRoot: string, packageName: string): Promise<ExportSymbol[]>;
22
+ invalidate(projectRoot: string, packageRoot: string, packageName: string): void;
23
+ clear(): void;
24
+ };
25
+ export {};