@aifabrix/builder 2.44.5 → 2.45.0

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 (249) hide show
  1. package/.cursor/rules/cli-layout.mdc +8 -4
  2. package/.cursor/rules/project-rules.mdc +1 -1
  3. package/README.md +15 -23
  4. package/integration/hubspot-test/README.md +2 -0
  5. package/integration/hubspot-test/test.js +5 -3
  6. package/jest.projects.js +104 -2
  7. package/lib/api/controller-health.api.js +49 -0
  8. package/lib/api/dimension-values.api.js +82 -0
  9. package/lib/api/dimensions.api.js +114 -0
  10. package/lib/api/external-systems.api.js +1 -0
  11. package/lib/api/integration-clients.api.js +168 -0
  12. package/lib/api/types/dimension-values.types.js +28 -0
  13. package/lib/api/types/dimensions.types.js +31 -0
  14. package/lib/api/types/integration-clients.types.js +45 -0
  15. package/lib/api/validation-runner.js +46 -25
  16. package/lib/app/deploy-config.js +11 -1
  17. package/lib/app/deploy-status-display.js +3 -3
  18. package/lib/app/deploy.js +36 -14
  19. package/lib/app/display.js +15 -11
  20. package/lib/app/helpers.js +3 -3
  21. package/lib/app/index.js +3 -3
  22. package/lib/app/push.js +46 -23
  23. package/lib/app/register.js +7 -6
  24. package/lib/app/restart-display.js +126 -0
  25. package/lib/app/rotate-secret.js +7 -6
  26. package/lib/app/run-container-start.js +12 -6
  27. package/lib/app/run-env-compose.js +30 -1
  28. package/lib/app/run-helpers.js +58 -19
  29. package/lib/app/run-reload-sync.js +148 -0
  30. package/lib/app/run-resolve-image.js +51 -1
  31. package/lib/app/run.js +148 -74
  32. package/lib/app/show-display.js +7 -0
  33. package/lib/app/show.js +87 -5
  34. package/lib/build/index.js +83 -49
  35. package/lib/cli/doctor-check.js +117 -0
  36. package/lib/cli/index.js +8 -2
  37. package/lib/cli/infra-guided.js +460 -0
  38. package/lib/cli/installation-log-command.js +73 -0
  39. package/lib/cli/setup-app.js +31 -3
  40. package/lib/cli/setup-auth.js +98 -27
  41. package/lib/cli/setup-dev-path-commands.js +50 -3
  42. package/lib/cli/setup-infra-up-dataplane-action.js +111 -0
  43. package/lib/cli/setup-infra-up-platform-action.js +131 -0
  44. package/lib/cli/setup-infra.js +132 -118
  45. package/lib/cli/setup-integration-client.js +182 -0
  46. package/lib/cli/setup-parameters.js +21 -2
  47. package/lib/cli/setup-platform.js +102 -0
  48. package/lib/cli/setup-secrets.js +18 -6
  49. package/lib/cli/setup-utility-resolve.js +132 -0
  50. package/lib/cli/setup-utility.js +143 -84
  51. package/lib/commands/app-logs.js +81 -33
  52. package/lib/commands/auth-config.js +116 -18
  53. package/lib/commands/datasource-capability-dimension-cli.js +128 -0
  54. package/lib/commands/datasource-capability-output.js +29 -0
  55. package/lib/commands/datasource-capability-relate-cli.js +140 -0
  56. package/lib/commands/datasource-capability.js +411 -0
  57. package/lib/commands/datasource-unified-test-cli.options.js +1 -1
  58. package/lib/commands/datasource.js +53 -13
  59. package/lib/commands/dev-down.js +3 -3
  60. package/lib/commands/dev-infra-gate.js +32 -0
  61. package/lib/commands/dev-init.js +13 -7
  62. package/lib/commands/dimension-value.js +179 -0
  63. package/lib/commands/dimension.js +330 -0
  64. package/lib/commands/integration-client.js +430 -0
  65. package/lib/commands/login-device.js +65 -30
  66. package/lib/commands/login.js +21 -10
  67. package/lib/commands/parameters-validate.js +78 -13
  68. package/lib/commands/repair-datasource-auto-rbac.js +166 -0
  69. package/lib/commands/repair-datasource-keys.js +10 -5
  70. package/lib/commands/repair-datasource.js +19 -7
  71. package/lib/commands/repair-env-template.js +4 -1
  72. package/lib/commands/repair-openapi-sync.js +172 -0
  73. package/lib/commands/repair-persist.js +102 -0
  74. package/lib/commands/repair-rbac-extract.js +27 -0
  75. package/lib/commands/repair-rbac-migrate.js +186 -0
  76. package/lib/commands/repair-rbac.js +214 -31
  77. package/lib/commands/repair-system-alignment.js +246 -0
  78. package/lib/commands/repair-system-permissions.js +168 -0
  79. package/lib/commands/repair.js +120 -338
  80. package/lib/commands/secure.js +1 -1
  81. package/lib/commands/setup-modes.js +468 -0
  82. package/lib/commands/setup-prompts.js +421 -0
  83. package/lib/commands/setup.js +254 -0
  84. package/lib/commands/teardown.js +277 -0
  85. package/lib/commands/up-common.js +113 -19
  86. package/lib/commands/up-dataplane.js +44 -19
  87. package/lib/commands/up-miso.js +18 -18
  88. package/lib/commands/upload.js +111 -23
  89. package/lib/commands/wizard-core-helpers.js +14 -11
  90. package/lib/commands/wizard-core.js +6 -5
  91. package/lib/commands/wizard-dataplane.js +2 -2
  92. package/lib/commands/wizard-entity-selection.js +4 -3
  93. package/lib/commands/wizard-headless.js +2 -1
  94. package/lib/commands/wizard.js +2 -1
  95. package/lib/constants/infra-compose-service-names.js +40 -0
  96. package/lib/core/audit-logger.js +1 -34
  97. package/lib/core/config-admin-email.js +56 -0
  98. package/lib/core/config-normalize.js +60 -0
  99. package/lib/core/config-registered-controller-urls.js +54 -0
  100. package/lib/core/config.js +33 -50
  101. package/lib/core/env-reader.js +16 -3
  102. package/lib/core/secrets-admin-env.js +101 -0
  103. package/lib/core/secrets-ensure-infra.js +34 -1
  104. package/lib/core/secrets-ensure.js +88 -66
  105. package/lib/core/secrets-env-content.js +428 -0
  106. package/lib/core/secrets-env-declarative-expand.js +170 -0
  107. package/lib/core/secrets-env-write.js +29 -1
  108. package/lib/core/secrets-load.js +252 -0
  109. package/lib/core/secrets-names.js +32 -0
  110. package/lib/core/secrets.js +17 -757
  111. package/lib/datasource/capability/basic-exposure.js +76 -0
  112. package/lib/datasource/capability/capability-diff-slice.js +41 -0
  113. package/lib/datasource/capability/capability-key.js +34 -0
  114. package/lib/datasource/capability/capability-resolve.js +172 -0
  115. package/lib/datasource/capability/capability-storage-keys.js +22 -0
  116. package/lib/datasource/capability/copy-operations.js +348 -0
  117. package/lib/datasource/capability/copy-test-payload.js +139 -0
  118. package/lib/datasource/capability/create-operations.js +235 -0
  119. package/lib/datasource/capability/dimension-operations.js +151 -0
  120. package/lib/datasource/capability/dimension-validate.js +219 -0
  121. package/lib/datasource/capability/json-pointer.js +31 -0
  122. package/lib/datasource/capability/reference-rewrite.js +51 -0
  123. package/lib/datasource/capability/relate-operations.js +325 -0
  124. package/lib/datasource/capability/relate-validate.js +219 -0
  125. package/lib/datasource/capability/remove-operations.js +275 -0
  126. package/lib/datasource/capability/run-capability-copy.js +152 -0
  127. package/lib/datasource/capability/run-capability-diff.js +135 -0
  128. package/lib/datasource/capability/run-capability-dimension.js +291 -0
  129. package/lib/datasource/capability/run-capability-edit.js +377 -0
  130. package/lib/datasource/capability/run-capability-relate.js +193 -0
  131. package/lib/datasource/capability/run-capability-remove.js +105 -0
  132. package/lib/datasource/capability/templates/minimal-fetch.json +18 -0
  133. package/lib/datasource/capability/validate-capability-slice.js +35 -0
  134. package/lib/datasource/list.js +136 -23
  135. package/lib/datasource/log-viewer.js +2 -4
  136. package/lib/datasource/unified-validation-run.js +51 -16
  137. package/lib/datasource/validate.js +53 -1
  138. package/lib/deployment/deploy-poll-ui.js +60 -0
  139. package/lib/deployment/deployer-status.js +29 -3
  140. package/lib/deployment/deployer.js +48 -30
  141. package/lib/deployment/environment.js +7 -2
  142. package/lib/deployment/poll-interval.js +72 -0
  143. package/lib/deployment/push.js +11 -9
  144. package/lib/external-system/deploy.js +9 -2
  145. package/lib/external-system/download.js +61 -32
  146. package/lib/external-system/sync-deploy-manifest.js +33 -0
  147. package/lib/infrastructure/index.js +49 -19
  148. package/lib/infrastructure/orphan-infra-docker-teardown.js +177 -0
  149. package/lib/internal/node-fs.js +2 -0
  150. package/lib/parameters/infra-kv-discovery.js +29 -4
  151. package/lib/parameters/infra-parameter-catalog.js +6 -3
  152. package/lib/parameters/infra-parameter-validate.js +67 -19
  153. package/lib/resolvers/datasource-resolver.js +53 -0
  154. package/lib/resolvers/dimension-file.js +52 -0
  155. package/lib/resolvers/manifest-resolver.js +133 -0
  156. package/lib/schema/application-schema.json +4 -0
  157. package/lib/schema/external-datasource.schema.json +183 -53
  158. package/lib/schema/external-system.schema.json +23 -10
  159. package/lib/schema/infra.parameter.yaml +26 -1
  160. package/lib/schema/wizard-config.schema.json +1 -1
  161. package/lib/utils/aifabrix-config-dir-walk.js +40 -0
  162. package/lib/utils/aifabrix-runtime-config-dir.js +26 -3
  163. package/lib/utils/app-config-resolver.js +24 -1
  164. package/lib/utils/app-run-containers.js +2 -2
  165. package/lib/utils/applications-config-defaults.js +206 -0
  166. package/lib/utils/auth-config-validator.js +2 -12
  167. package/lib/utils/bash-secret-env.js +59 -0
  168. package/lib/utils/cli-secrets-error-format.js +78 -0
  169. package/lib/utils/cli-test-layout-chalk.js +31 -9
  170. package/lib/utils/cli-utils.js +4 -36
  171. package/lib/utils/compose-generate-docker-compose.js +111 -6
  172. package/lib/utils/compose-generator.js +17 -8
  173. package/lib/utils/controller-url.js +50 -7
  174. package/lib/utils/datasource-test-run-display.js +8 -0
  175. package/lib/utils/dev-hosts-helper.js +3 -2
  176. package/lib/utils/dev-init-ssh-merge.js +2 -1
  177. package/lib/utils/docker-build.js +17 -9
  178. package/lib/utils/docker-reload-mount.js +127 -0
  179. package/lib/utils/env-copy.js +99 -14
  180. package/lib/utils/env-template.js +5 -1
  181. package/lib/utils/external-readme.js +71 -2
  182. package/lib/utils/external-system-local-test-tty.js +3 -2
  183. package/lib/utils/external-system-readiness-core.js +45 -12
  184. package/lib/utils/external-system-readiness-deploy-display.js +3 -3
  185. package/lib/utils/external-system-readiness-display-internals.js +33 -3
  186. package/lib/utils/external-system-readiness-display.js +10 -1
  187. package/lib/utils/file-upload.js +40 -3
  188. package/lib/utils/health-check-db-init.js +107 -0
  189. package/lib/utils/health-check-public-warn.js +69 -0
  190. package/lib/utils/health-check-url.js +28 -10
  191. package/lib/utils/health-check.js +139 -107
  192. package/lib/utils/help-builder.js +5 -1
  193. package/lib/utils/image-name.js +34 -7
  194. package/lib/utils/infra-optional-service-flags.js +69 -0
  195. package/lib/utils/installation-log-core.js +282 -0
  196. package/lib/utils/installation-log-record.js +237 -0
  197. package/lib/utils/installation-log.js +123 -0
  198. package/lib/utils/integration-file-backup.js +74 -0
  199. package/lib/utils/log-redaction.js +105 -0
  200. package/lib/utils/manifest-location.js +164 -0
  201. package/lib/utils/manifest-source-emit.js +162 -0
  202. package/lib/utils/mutagen-install.js +30 -3
  203. package/lib/utils/paths.js +308 -76
  204. package/lib/utils/postgres-wipe.js +212 -0
  205. package/lib/utils/register-aifabrix-shell-env.js +15 -0
  206. package/lib/utils/remote-dev-auth.js +21 -5
  207. package/lib/utils/remote-docker-env.js +9 -1
  208. package/lib/utils/remote-secrets-loader.js +49 -4
  209. package/lib/utils/resolve-docker-image-ref.js +9 -3
  210. package/lib/utils/run-cli-flags.js +29 -0
  211. package/lib/utils/secrets-ancestor-paths.js +47 -0
  212. package/lib/utils/secrets-canonical.js +10 -3
  213. package/lib/utils/secrets-helpers.js +17 -10
  214. package/lib/utils/secrets-kv-refs.js +42 -0
  215. package/lib/utils/secrets-kv-scope.js +19 -2
  216. package/lib/utils/secrets-materialize-local.js +134 -0
  217. package/lib/utils/secrets-path.js +26 -13
  218. package/lib/utils/secrets-utils.js +20 -10
  219. package/lib/utils/system-builder-root.js +42 -0
  220. package/lib/utils/url-declarative-public-base.js +80 -12
  221. package/lib/utils/url-declarative-resolve-build-urls.js +238 -0
  222. package/lib/utils/url-declarative-resolve-build.js +24 -388
  223. package/lib/utils/url-declarative-resolve-expand-token.js +189 -0
  224. package/lib/utils/url-declarative-resolve-load-doc.js +12 -3
  225. package/lib/utils/url-declarative-resolve-surface-state.js +102 -0
  226. package/lib/utils/url-declarative-resolve.js +47 -7
  227. package/lib/utils/url-declarative-runtime-base-path.js +52 -0
  228. package/lib/utils/url-declarative-vdir-inactive-env.js +2 -1
  229. package/lib/utils/urls-local-registry-scan.js +103 -0
  230. package/lib/utils/urls-local-registry.js +158 -76
  231. package/lib/utils/validation-poll-ui.js +81 -0
  232. package/lib/utils/validation-run-poll.js +29 -5
  233. package/lib/utils/with-muted-logger.js +53 -0
  234. package/package.json +3 -1
  235. package/templates/applications/dataplane/application.yaml +5 -1
  236. package/templates/applications/dataplane/rbac.yaml +10 -10
  237. package/templates/applications/keycloak/env.template +8 -6
  238. package/templates/applications/miso-controller/application.yaml +9 -0
  239. package/templates/applications/miso-controller/env.template +27 -29
  240. package/templates/applications/miso-controller/rbac.yaml +9 -9
  241. package/templates/external-system/README.md.hbs +83 -123
  242. package/.npmrc.token +0 -1
  243. package/.nyc_output/55e9d034-ddab-4579-a706-e02a91d75c91.json +0 -1
  244. package/.nyc_output/processinfo/55e9d034-ddab-4579-a706-e02a91d75c91.json +0 -1
  245. package/.nyc_output/processinfo/index.json +0 -1
  246. package/lib/api/service-users.api.js +0 -150
  247. package/lib/api/types/service-users.types.js +0 -65
  248. package/lib/cli/setup-service-user.js +0 -187
  249. package/lib/commands/service-user.js +0 -429
@@ -23,9 +23,97 @@ Examples:
23
23
  const AUTH_HELP_AFTER = `
24
24
  Without options: show auth status (same as: aifabrix auth status).
25
25
  With --set-controller or --set-environment: write defaults to config.yaml.
26
+ Omit the URL on --set-controller to pick from controllers already stored in config (device logins + default).
27
+ For details on omitting the URL: aifabrix auth set-controller -h
28
+ Aliases:
29
+ aifabrix auth set-controller [url]
30
+ aifabrix auth set-environment <env>
26
31
  Subcommand: auth status [--validate] for CI/scripts.
27
32
  `;
28
33
 
34
+ const AUTH_SET_CONTROLLER_HELP_AFTER = `
35
+ Argument:
36
+ [url] Optional. When omitted, the CLI uses controllers already known in your config file
37
+ (the default controller value plus each device-token key). Requires an interactive TTY.
38
+
39
+ Behavior:
40
+ - No saved controllers: error; run aifabrix login first, or pass a URL.
41
+ - One saved controller: if it is already the default, prints confirmation; otherwise sets it.
42
+ - Several saved controllers: interactive list to choose the default.
43
+ - Non-interactive shell: pass the URL explicitly (piped/CI shells cannot pick without a URL).
44
+
45
+ Examples:
46
+ $ aifabrix auth set-controller
47
+ Pick default controller from config (TTY), or set the only saved one.
48
+
49
+ $ aifabrix auth set-controller http://localhost:3600
50
+ Set default controller to that URL (validated; same rules as aifabrix auth --set-controller).
51
+
52
+ $ aifabrix auth --set-controller
53
+ Same as omitting the URL on this subcommand (parent command flag).
54
+ `;
55
+
56
+ function createAuthStatusAction() {
57
+ return async(options) => {
58
+ try {
59
+ await handleAuthStatus(options);
60
+ } catch (error) {
61
+ handleCommandError(error, 'auth status');
62
+ process.exit(1);
63
+ }
64
+ };
65
+ }
66
+
67
+ function createAuthParentAction() {
68
+ return async(options) => {
69
+ try {
70
+ const setController = options.setController || options['set-controller'];
71
+ const setEnvironment = options.setEnvironment || options['set-environment'];
72
+ if (setController || setEnvironment) {
73
+ await handleAuthConfig({
74
+ setController,
75
+ setEnvironment
76
+ });
77
+ return;
78
+ }
79
+ await handleAuthStatus(options);
80
+ } catch (error) {
81
+ handleCommandError(error, 'auth');
82
+ process.exit(1);
83
+ }
84
+ };
85
+ }
86
+
87
+ function registerAuthSetControllerSubcommand(auth) {
88
+ const setControllerCmd = auth.command('set-controller [url]').description(
89
+ 'Set config.controller to a URL, or omit the URL to pick from controllers already stored in config'
90
+ );
91
+ if (typeof setControllerCmd.summary === 'function') {
92
+ setControllerCmd.summary('Set or pick default controller URL in config');
93
+ }
94
+ setControllerCmd.addHelpText('after', AUTH_SET_CONTROLLER_HELP_AFTER).action(async(url) => {
95
+ try {
96
+ await handleAuthConfig({ setController: url || true });
97
+ } catch (error) {
98
+ handleCommandError(error, 'auth set-controller');
99
+ process.exit(1);
100
+ }
101
+ });
102
+ }
103
+
104
+ function registerAuthSetEnvironmentSubcommand(auth) {
105
+ auth.command('set-environment <env>')
106
+ .description('Set default environment in config (alias for auth --set-environment)')
107
+ .action(async(env) => {
108
+ try {
109
+ await handleAuthConfig({ setEnvironment: env });
110
+ } catch (error) {
111
+ handleCommandError(error, 'auth set-environment');
112
+ process.exit(1);
113
+ }
114
+ });
115
+ }
116
+
29
117
  function setupLoginCommand(program) {
30
118
  program.command('login')
31
119
  .description('Sign in to Miso Controller (device or credentials flow)')
@@ -65,40 +153,23 @@ function setupLogoutCommand(program) {
65
153
  }
66
154
 
67
155
  function setupAuthSubcommands(program) {
68
- const authStatusHandler = async(options) => {
69
- try {
70
- await handleAuthStatus(options);
71
- } catch (error) {
72
- handleCommandError(error, 'auth status');
73
- process.exit(1);
74
- }
75
- };
76
156
  const auth = program.command('auth')
77
157
  .description('Show auth status or set default controller/environment')
78
158
  .addHelpText('after', AUTH_HELP_AFTER)
79
- .option('--set-controller <url>', 'Set default controller URL in config')
159
+ .option(
160
+ '--set-controller [url]',
161
+ 'Set default controller URL in config; omit url to choose from controllers registered in config'
162
+ )
80
163
  .option('--set-environment <env>', 'Set default environment in config')
81
- .action(async(options) => {
82
- try {
83
- const setController = options.setController || options['set-controller'];
84
- const setEnvironment = options.setEnvironment || options['set-environment'];
85
- if (setController || setEnvironment) {
86
- await handleAuthConfig({
87
- setController,
88
- setEnvironment
89
- });
90
- return;
91
- }
92
- await handleAuthStatus(options);
93
- } catch (error) {
94
- handleCommandError(error, 'auth');
95
- process.exit(1);
96
- }
97
- });
164
+ .action(createAuthParentAction());
165
+
166
+ registerAuthSetControllerSubcommand(auth);
167
+ registerAuthSetEnvironmentSubcommand(auth);
168
+
98
169
  auth.command('status')
99
170
  .description('Show tokens/session for current controller and environment')
100
171
  .option('--validate', 'Exit with code 1 when not authenticated (for scripted use, e.g. manual test setup)')
101
- .action(authStatusHandler);
172
+ .action(createAuthStatusAction());
102
173
  }
103
174
 
104
175
  /**
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Dev subcommands: set-home, set-work, print-home, print-work, set-format.
2
+ * Dev subcommands: set-home, set-work, print-home, print-work, shell-env, set-format.
3
3
  *
4
4
  * @fileoverview Path and format CLI registration for `aifabrix dev`
5
5
  * @author AI Fabrix Team
@@ -10,18 +10,35 @@
10
10
  const { formatSuccessLine } = require('../utils/cli-test-layout-chalk');
11
11
 
12
12
  const chalk = require('chalk');
13
+ const path = require('path');
13
14
  const config = require('../core/config');
14
15
  const logger = require('../utils/logger');
15
16
  const paths = require('../utils/paths');
16
- const { registerAifabrixShellEnvFromConfig } = require('../utils/register-aifabrix-shell-env');
17
+ const {
18
+ registerAifabrixShellEnvFromConfig,
19
+ buildShellEnvExportsFromConfig
20
+ } = require('../utils/register-aifabrix-shell-env');
17
21
  const { handleCommandError } = require('../utils/cli-utils');
18
22
 
19
23
  async function runShellEnvRegistration() {
20
24
  try {
21
25
  await registerAifabrixShellEnvFromConfig(config.getConfig);
22
26
  logger.log(
23
- chalk.gray(' User/shell environment updated. Open a new terminal for AIFABRIX_HOME / AIFABRIX_WORK.')
27
+ chalk.gray(' User/shell environment updated. New terminals pick up AIFABRIX_HOME / AIFABRIX_WORK.')
24
28
  );
29
+ if (process.platform !== 'win32') {
30
+ logger.log(
31
+ chalk.gray(' This terminal: ') +
32
+ chalk.cyan('eval "$(aifabrix dev shell-env)"') +
33
+ chalk.gray(' (or source the aifabrix-shell-env.sh next to config.yaml).')
34
+ );
35
+ } else {
36
+ logger.log(
37
+ chalk.gray(' This PowerShell session: ') +
38
+ chalk.cyan('aifabrix dev shell-env') +
39
+ chalk.gray(' then run the printed lines.')
40
+ );
41
+ }
25
42
  } catch (regErr) {
26
43
  throw new Error(`Config saved but environment registration failed: ${regErr.message}`);
27
44
  }
@@ -92,6 +109,36 @@ function addPrintHomeWorkCommands(dev) {
92
109
  process.exit(1);
93
110
  }
94
111
  });
112
+
113
+ dev
114
+ .command('shell-env')
115
+ .description(
116
+ 'Print export lines for AIFABRIX_HOME / AIFABRIX_WORK (stdout only). POSIX: eval "$(aifabrix dev shell-env)"'
117
+ )
118
+ .action(async() => {
119
+ try {
120
+ if (process.platform === 'win32') {
121
+ const cfg = await config.getConfig();
122
+ const home = (cfg['aifabrix-home'] && String(cfg['aifabrix-home']).trim())
123
+ ? paths.resolveAifabrixHomeLikePath(String(cfg['aifabrix-home']).trim())
124
+ : null;
125
+ const work = (cfg['aifabrix-work'] && String(cfg['aifabrix-work']).trim())
126
+ ? path.resolve(String(cfg['aifabrix-work']).trim())
127
+ : null;
128
+ const esc = (s) => String(s).replace(/'/g, '\'\'');
129
+ const lines = ['# Paste into PowerShell for this session only.'];
130
+ if (home) lines.push(`$env:AIFABRIX_HOME = '${esc(home)}'`);
131
+ if (work) lines.push(`$env:AIFABRIX_WORK = '${esc(work)}'`);
132
+ process.stdout.write(`${lines.join('\n')}\n`);
133
+ return;
134
+ }
135
+ const body = await buildShellEnvExportsFromConfig(config.getConfig);
136
+ process.stdout.write(body);
137
+ } catch (error) {
138
+ handleCommandError(error, 'dev shell-env');
139
+ process.exit(1);
140
+ }
141
+ });
95
142
  }
96
143
 
97
144
  function addSetFormatCommand(dev, handleSetFormat) {
@@ -0,0 +1,111 @@
1
+ /**
2
+ * `aifabrix up-dataplane` action body (keeps setup-infra.js under size limits).
3
+ *
4
+ * @fileoverview up-dataplane CLI action
5
+ * @author AI Fabrix Team
6
+ * @version 2.0.0
7
+ */
8
+
9
+ 'use strict';
10
+
11
+ const chalk = require('chalk');
12
+ const logger = require('../utils/logger');
13
+ const { formatProgress } = require('../utils/cli-test-layout-chalk');
14
+ const { handleCommandError, isAuthenticationError } = require('../utils/cli-utils');
15
+ const { resolveControllerUrl } = require('../utils/controller-url');
16
+ const { handleLogin } = require('../commands/login');
17
+ const { handleUpDataplane } = require('../commands/up-dataplane');
18
+ const { cleanBuilderAppDirs } = require('../commands/up-common');
19
+ const { runGuidedUpDataplane } = require('./infra-guided');
20
+ const { recordInfraInstallationCommand } = require('./installation-log-command');
21
+
22
+ /**
23
+ * @param {Object} options
24
+ * @returns {Promise<string[]>}
25
+ */
26
+ async function runUpDataplaneWork(options) {
27
+ let cleanedAppKeys = [];
28
+ if (options.force) {
29
+ const c = await cleanBuilderAppDirs(['dataplane']);
30
+ cleanedAppKeys = Array.isArray(c) ? c : [];
31
+ }
32
+ if (!options.verbose) {
33
+ await runGuidedUpDataplane(options, handleUpDataplane);
34
+ } else {
35
+ await handleUpDataplane(options);
36
+ }
37
+ return cleanedAppKeys;
38
+ }
39
+
40
+ /**
41
+ * @param {Object} params
42
+ * @returns {Promise<void>}
43
+ */
44
+ async function logDataplaneOutcome(params) {
45
+ const { options, startedAt, outcome, error, cleanedAppKeys } = params;
46
+ await recordInfraInstallationCommand({
47
+ command: 'up-dataplane',
48
+ options,
49
+ startedAt,
50
+ outcome,
51
+ error,
52
+ platformAppList: ['dataplane'],
53
+ cleanup: cleanedAppKeys.length > 0 ? { cleanedAppKeys } : undefined
54
+ });
55
+ }
56
+
57
+ /**
58
+ * @param {Object} options
59
+ * @param {Date} startedAt
60
+ * @param {string[]} cleanedAppKeys
61
+ * @param {string} controllerUrl
62
+ * @returns {Promise<void>}
63
+ */
64
+ async function runDataplaneAuthRecovery(options, startedAt, cleanedAppKeys, controllerUrl) {
65
+ if (!options.verbose) {
66
+ logger.log(formatProgress('Authenticating...'));
67
+ } else {
68
+ logger.log(chalk.blue('\nAuthentication required. Running aifabrix login...\n'));
69
+ }
70
+ await handleLogin({ method: 'device', controller: controllerUrl, compact: !options.verbose });
71
+ await handleUpDataplane(options);
72
+ await logDataplaneOutcome({ options, startedAt, outcome: 'success', cleanedAppKeys });
73
+ }
74
+
75
+ /**
76
+ * @param {Object} options
77
+ * @returns {Promise<void>}
78
+ */
79
+ async function handleUpDataplaneCliAction(options) {
80
+ const startedAt = new Date();
81
+ let cleanedAppKeys = [];
82
+ try {
83
+ cleanedAppKeys = await runUpDataplaneWork(options);
84
+ await logDataplaneOutcome({ options, startedAt, outcome: 'success', cleanedAppKeys });
85
+ } catch (error) {
86
+ if (isAuthenticationError(error)) {
87
+ const controllerUrl = error.controllerUrl || await resolveControllerUrl();
88
+ try {
89
+ await runDataplaneAuthRecovery(options, startedAt, cleanedAppKeys, controllerUrl);
90
+ return;
91
+ } catch (loginOrRetryError) {
92
+ await logDataplaneOutcome({
93
+ options,
94
+ startedAt,
95
+ outcome: 'failure',
96
+ error: loginOrRetryError,
97
+ cleanedAppKeys
98
+ });
99
+ handleCommandError(loginOrRetryError, 'up-dataplane');
100
+ process.exit(1);
101
+ }
102
+ }
103
+ await logDataplaneOutcome({ options, startedAt, outcome: 'failure', error, cleanedAppKeys });
104
+ handleCommandError(error, 'up-dataplane');
105
+ process.exit(1);
106
+ }
107
+ }
108
+
109
+ module.exports = {
110
+ handleUpDataplaneCliAction
111
+ };
@@ -0,0 +1,131 @@
1
+ /**
2
+ * `aifabrix up-platform` action body (keeps setup-infra.js under size limits).
3
+ *
4
+ * @fileoverview up-platform CLI action
5
+ * @author AI Fabrix Team
6
+ * @version 2.0.0
7
+ */
8
+
9
+ 'use strict';
10
+
11
+ const chalk = require('chalk');
12
+ const logger = require('../utils/logger');
13
+ const { formatProgress } = require('../utils/cli-test-layout-chalk');
14
+ const { handleCommandError, isAuthenticationError } = require('../utils/cli-utils');
15
+ const { resolveControllerUrl } = require('../utils/controller-url');
16
+ const { handleLogin } = require('../commands/login');
17
+ const { handleUpMiso } = require('../commands/up-miso');
18
+ const { handleUpDataplane } = require('../commands/up-dataplane');
19
+ const {
20
+ applyUpPlatformForceConfig,
21
+ cleanBuilderAppDirs,
22
+ prepareUrlsLocalRegistryForUpPlatform
23
+ } = require('../commands/up-common');
24
+ const { runGuidedUpPlatform } = require('./infra-guided');
25
+ const { recordInfraInstallationCommand } = require('./installation-log-command');
26
+
27
+ const PLATFORM_APPS = ['keycloak', 'miso-controller', 'dataplane'];
28
+
29
+ /**
30
+ * @param {Object} options
31
+ * @returns {Promise<string[]>}
32
+ */
33
+ async function runUpPlatformWork(options) {
34
+ let cleanedAppKeys = [];
35
+ let platformForceCleanSummary = null;
36
+ if (options.force) {
37
+ const forceSummary = await applyUpPlatformForceConfig({ silent: !options.verbose });
38
+ const cleanedApps = await cleanBuilderAppDirs(PLATFORM_APPS, {
39
+ silent: !options.verbose
40
+ });
41
+ cleanedAppKeys = Array.isArray(cleanedApps) ? cleanedApps : [];
42
+ if (!options.verbose) {
43
+ platformForceCleanSummary = { forceSummary, cleanedApps: cleanedAppKeys };
44
+ }
45
+ }
46
+
47
+ if (!options.verbose) {
48
+ await runGuidedUpPlatform(
49
+ options,
50
+ handleUpMiso,
51
+ handleUpDataplane,
52
+ handleLogin,
53
+ platformForceCleanSummary
54
+ );
55
+ } else {
56
+ await prepareUrlsLocalRegistryForUpPlatform();
57
+ await handleUpMiso(options);
58
+ await handleUpDataplane(options);
59
+ }
60
+ return cleanedAppKeys;
61
+ }
62
+
63
+ /**
64
+ * @param {Object} params
65
+ * @returns {Promise<void>}
66
+ */
67
+ async function logUpPlatformOutcome(params) {
68
+ const { options, startedAt, outcome, error, cleanedAppKeys } = params;
69
+ await recordInfraInstallationCommand({
70
+ command: 'up-platform',
71
+ options,
72
+ startedAt,
73
+ outcome,
74
+ error,
75
+ platformAppList: PLATFORM_APPS,
76
+ cleanup: cleanedAppKeys.length > 0 ? { cleanedAppKeys } : undefined,
77
+ upPlatformForce: options.force === true
78
+ });
79
+ }
80
+
81
+ async function maybeHandleUpPlatformAuthRetry(error, options) {
82
+ if (!isAuthenticationError(error)) {
83
+ return false;
84
+ }
85
+ const controllerUrl = error.controllerUrl || await resolveControllerUrl();
86
+ if (!options.verbose) {
87
+ logger.log(formatProgress('Authenticating...'));
88
+ } else {
89
+ logger.log(chalk.blue('\nAuthentication required. Running aifabrix login...\n'));
90
+ }
91
+ await handleLogin({ method: 'device', controller: controllerUrl, compact: !options.verbose });
92
+ await handleUpDataplane(options);
93
+ return true;
94
+ }
95
+
96
+ /**
97
+ * @param {Object} options
98
+ * @returns {Promise<void>}
99
+ */
100
+ async function handleUpPlatformCliAction(options) {
101
+ const startedAt = new Date();
102
+ let cleanedAppKeys = [];
103
+ try {
104
+ cleanedAppKeys = await runUpPlatformWork(options);
105
+ await logUpPlatformOutcome({ options, startedAt, outcome: 'success', cleanedAppKeys });
106
+ } catch (error) {
107
+ try {
108
+ if (await maybeHandleUpPlatformAuthRetry(error, options)) {
109
+ await logUpPlatformOutcome({ options, startedAt, outcome: 'success', cleanedAppKeys });
110
+ return;
111
+ }
112
+ } catch (loginOrRetryError) {
113
+ await logUpPlatformOutcome({
114
+ options,
115
+ startedAt,
116
+ outcome: 'failure',
117
+ error: loginOrRetryError,
118
+ cleanedAppKeys
119
+ });
120
+ handleCommandError(loginOrRetryError, 'up-platform');
121
+ process.exit(1);
122
+ }
123
+ await logUpPlatformOutcome({ options, startedAt, outcome: 'failure', error, cleanedAppKeys });
124
+ handleCommandError(error, 'up-platform');
125
+ process.exit(1);
126
+ }
127
+ }
128
+
129
+ module.exports = {
130
+ handleUpPlatformCliAction
131
+ };