@intra-mart/accel 0.3.0-next.202605250439 → 0.3.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 (68) hide show
  1. package/README.md +157 -41
  2. package/dist/asset/deployer.js +8 -17
  3. package/dist/asset/foreach-replacement.d.ts +2 -0
  4. package/dist/asset/foreach-replacement.js +20 -0
  5. package/dist/asset/github-provider.d.ts +2 -0
  6. package/dist/asset/github-provider.js +37 -0
  7. package/dist/asset/local-provider.js +1 -22
  8. package/dist/asset/walker.js +4 -15
  9. package/dist/commands/attach.d.ts +13 -1
  10. package/dist/commands/attach.js +33 -12
  11. package/dist/commands/deploy.d.ts +42 -3
  12. package/dist/commands/deploy.js +274 -40
  13. package/dist/commands/init.d.ts +13 -1
  14. package/dist/commands/init.js +33 -12
  15. package/dist/commands/login.d.ts +31 -0
  16. package/dist/commands/login.js +76 -0
  17. package/dist/core/catalog.d.ts +11 -0
  18. package/dist/core/catalog.js +40 -0
  19. package/dist/core/condition-evaluator.js +6 -3
  20. package/dist/core/constants.d.ts +3 -3
  21. package/dist/core/constants.js +6 -11
  22. package/dist/core/eval-context.d.ts +3 -0
  23. package/dist/core/eval-context.js +45 -0
  24. package/dist/core/types.d.ts +61 -12
  25. package/dist/core/types.js +2 -1
  26. package/dist/core/validators.d.ts +7 -2
  27. package/dist/core/validators.js +25 -12
  28. package/dist/core/variable-interpolator.d.ts +1 -1
  29. package/dist/core/variable-interpolator.js +19 -19
  30. package/dist/deploy/api-client.d.ts +5 -2
  31. package/dist/deploy/api-client.js +47 -1
  32. package/dist/deploy/target-selector.d.ts +11 -0
  33. package/dist/deploy/target-selector.js +16 -0
  34. package/dist/i18n/en.js +38 -5
  35. package/dist/i18n/ja.js +38 -5
  36. package/dist/i18n/zh_CN.js +38 -5
  37. package/dist/index.js +2 -0
  38. package/dist/interactive/agent-detect.js +1 -0
  39. package/dist/interactive/credential-auth.d.ts +15 -0
  40. package/dist/interactive/credential-auth.js +61 -0
  41. package/dist/interactive/credentials-prompts.d.ts +3 -1
  42. package/dist/interactive/credentials-prompts.js +50 -7
  43. package/dist/interactive/next-steps.js +3 -0
  44. package/dist/interactive/prompts.d.ts +3 -0
  45. package/dist/interactive/prompts.js +112 -52
  46. package/dist/interactive/summary.js +5 -1
  47. package/dist/juggling/extractor.d.ts +3 -2
  48. package/dist/juggling/extractor.js +9 -9
  49. package/dist/utils/args.d.ts +1 -0
  50. package/dist/utils/args.js +4 -0
  51. package/dist/utils/credentials.d.ts +7 -0
  52. package/dist/utils/credentials.js +21 -0
  53. package/dist/utils/date-formatter.d.ts +1 -0
  54. package/dist/utils/date-formatter.js +23 -0
  55. package/dist/utils/https.d.ts +2 -0
  56. package/dist/utils/https.js +44 -0
  57. package/dist/utils/mcp-sync.d.ts +4 -0
  58. package/dist/utils/mcp-sync.js +97 -0
  59. package/dist/utils/settings-io.d.ts +1 -0
  60. package/dist/utils/settings-io.js +8 -0
  61. package/package.json +6 -5
  62. package/assets/assets.tar.gz +0 -0
  63. package/dist/asset/default-source.d.ts +0 -1
  64. package/dist/asset/default-source.js +0 -6
  65. package/dist/core/module-map.d.ts +0 -3
  66. package/dist/core/module-map.js +0 -7
  67. package/dist/core/version-map.d.ts +0 -7
  68. package/dist/core/version-map.js +0 -45
@@ -1,4 +1,4 @@
1
- import type { AccelCredentials, StagingResponse } from "../core/types.js";
1
+ import type { AccelCredentials, SetupConfigResponse, StagingResponse } from "../core/types.js";
2
2
  import { type ApiClient } from "../deploy/api-client.js";
3
3
  export declare const toImmFileName: (zipPath: string) => string;
4
4
  type ConfirmInfo = {
@@ -12,15 +12,54 @@ export type DeployPrompts = {
12
12
  selectZip: (zips: string[], locale: string) => Promise<string>;
13
13
  description: (locale: string) => Promise<string>;
14
14
  confirm: (info: ConfirmInfo, locale: string) => Promise<boolean>;
15
+ confirmSetup: (configs: SetupConfigResponse[], locale: string) => Promise<boolean>;
16
+ confirmSetupAll: (locale: string) => Promise<boolean>;
17
+ selectSetupConfigs: (configs: SetupConfigResponse[], locale: string) => Promise<number[]>;
15
18
  };
16
19
  export type RunDeployDeps = {
17
20
  projectDir: string;
18
21
  locale?: string;
19
- ensureCredentials?: (projectDir: string, locale: string) => Promise<AccelCredentials>;
22
+ nonInteractive?: boolean;
23
+ endpoint?: string;
24
+ apiKey?: string;
25
+ stagingId?: string;
26
+ file?: string;
27
+ description?: string;
28
+ env?: Record<string, string | undefined>;
29
+ ensureCredentials?: (projectDir: string, locale: string, seed?: Partial<AccelCredentials>) => Promise<AccelCredentials>;
30
+ repromptCredentials?: (current: AccelCredentials, locale: string) => Promise<AccelCredentials>;
31
+ resolveCredentialsOrThrow?: (projectDir: string, locale: string, seed: Partial<AccelCredentials>) => Promise<AccelCredentials>;
32
+ persistCredentials?: (projectDir: string, creds: AccelCredentials) => Promise<void>;
20
33
  scanTargets?: (projectDir: string) => Promise<string[]>;
21
34
  apiClientFactory?: (endpoint: string, apiKey: string) => ApiClient;
22
35
  prompts?: DeployPrompts;
23
36
  };
24
37
  export declare const runDeploy: (deps: RunDeployDeps) => Promise<void>;
25
- export declare const deployCommand: import("citty").CommandDef<{}>;
38
+ export declare const deployCommand: import("citty").CommandDef<{
39
+ endpoint: {
40
+ type: "string";
41
+ description: string;
42
+ };
43
+ "api-key": {
44
+ type: "string";
45
+ description: string;
46
+ };
47
+ "staging-id": {
48
+ type: "string";
49
+ description: string;
50
+ };
51
+ file: {
52
+ type: "string";
53
+ description: string;
54
+ };
55
+ description: {
56
+ type: "string";
57
+ description: string;
58
+ };
59
+ "non-interactive": {
60
+ type: "boolean";
61
+ description: string;
62
+ default: false;
63
+ };
64
+ }>;
26
65
  export {};
@@ -1,12 +1,18 @@
1
1
  import { defineCommand } from "citty";
2
2
  import * as p from "@clack/prompts";
3
- import { readFile } from "node:fs/promises";
4
- import { basename } from "node:path";
3
+ import { readFile, stat } from "node:fs/promises";
4
+ import { basename, resolve } from "node:path";
5
5
  import { detectLocale } from "../utils/locale-detect.js";
6
- import { readSettings } from "../utils/settings-io.js";
6
+ import { formatEpochMillis } from "../utils/date-formatter.js";
7
+ import { readSettings, readSettingsSafe } from "../utils/settings-io.js";
8
+ import { resolveCredentialInputs } from "../utils/credentials.js";
9
+ import { persistCredentialsAndSyncMcp as defaultPersistCredentials } from "../utils/mcp-sync.js";
7
10
  import { getMessage } from "../i18n/index.js";
8
- import { ensureCredentials as defaultEnsureCredentials } from "../interactive/credentials-prompts.js";
11
+ import { lastFlagValue } from "../utils/args.js";
12
+ import { ensureCredentials as defaultEnsureCredentials, repromptCredentials as defaultRepromptCredentials, resolveCredentialsOrThrow as defaultResolveCredentialsOrThrow, } from "../interactive/credentials-prompts.js";
9
13
  import { scanTargets as defaultScanTargets } from "../deploy/target-scanner.js";
14
+ import { selectDeployTarget } from "../deploy/target-selector.js";
15
+ import { verifyCredentialsLoop } from "../interactive/credential-auth.js";
10
16
  import { createApiClient as defaultApiClientFactory, isDeployError, } from "../deploy/api-client.js";
11
17
  export const toImmFileName = (zipPath) => {
12
18
  const base = basename(zipPath);
@@ -61,6 +67,40 @@ const defaultPrompts = {
61
67
  process.exit(0);
62
68
  return res;
63
69
  },
70
+ confirmSetup: async (configs, locale) => {
71
+ p.note(configs
72
+ .map((c) => `#${c.configNumber} ${c.moduleId} [${c.sections.join(", ")}]`)
73
+ .join("\n"), getMessage("deploy.setup.heading", locale));
74
+ const res = await p.confirm({
75
+ message: getMessage("deploy.setup.confirm", locale),
76
+ initialValue: true,
77
+ });
78
+ if (p.isCancel(res))
79
+ process.exit(0);
80
+ return res;
81
+ },
82
+ confirmSetupAll: async (locale) => {
83
+ const res = await p.confirm({
84
+ message: getMessage("deploy.setup.confirmAll", locale),
85
+ initialValue: true,
86
+ });
87
+ if (p.isCancel(res))
88
+ process.exit(0);
89
+ return res;
90
+ },
91
+ selectSetupConfigs: async (configs, locale) => {
92
+ const res = await p.multiselect({
93
+ message: getMessage("deploy.setup.selectConfigs", locale),
94
+ options: configs.map((c) => ({
95
+ value: c.configNumber,
96
+ label: `#${c.configNumber} ${c.moduleId} [${c.sections.join(", ")}]`,
97
+ })),
98
+ required: true,
99
+ });
100
+ if (p.isCancel(res))
101
+ process.exit(0);
102
+ return res;
103
+ },
64
104
  };
65
105
  const resolveLocale = async (projectDir) => {
66
106
  try {
@@ -99,49 +139,115 @@ const formatDeployError = (err, locale) => {
99
139
  });
100
140
  }
101
141
  };
142
+ const resolveZipPath = async (opts) => {
143
+ const { projectDir, locale, nonInteractive, fileArg, scan, selectZip } = opts;
144
+ if (fileArg && fileArg.length > 0) {
145
+ const filePath = resolve(projectDir, fileArg);
146
+ try {
147
+ const s = await stat(filePath);
148
+ if (!s.isFile())
149
+ throw new Error("not a file");
150
+ }
151
+ catch {
152
+ p.log.error(getMessage("deploy.error.fileNotFound", locale, { path: fileArg }));
153
+ throw new Error("file not found");
154
+ }
155
+ return filePath;
156
+ }
157
+ const zips = await scan(projectDir);
158
+ if (zips.length === 0) {
159
+ p.log.error(getMessage("deploy.error.noTargetZip", locale));
160
+ throw new Error("no target zip");
161
+ }
162
+ const settings = await readSettingsSafe(projectDir);
163
+ const selection = selectDeployTarget(zips, settings
164
+ ? { artifactId: settings.artifactId, projectVersion: settings.projectVersion }
165
+ : null);
166
+ if ("auto" in selection)
167
+ return selection.auto;
168
+ if (nonInteractive) {
169
+ p.log.error(getMessage("deploy.error.zipNotResolved", locale));
170
+ throw new Error("zip not resolved");
171
+ }
172
+ return selection.candidates.length === 1
173
+ ? selection.candidates[0]
174
+ : await selectZip(selection.candidates, locale);
175
+ };
102
176
  export const runDeploy = async (deps) => {
103
177
  const { projectDir } = deps;
104
178
  const locale = deps.locale ?? (await resolveLocale(projectDir));
105
179
  const ensureCreds = deps.ensureCredentials ?? defaultEnsureCredentials;
180
+ const reprompt = deps.repromptCredentials ?? defaultRepromptCredentials;
181
+ const resolveOrThrow = deps.resolveCredentialsOrThrow ?? defaultResolveCredentialsOrThrow;
182
+ const persist = deps.persistCredentials ?? defaultPersistCredentials;
106
183
  const scan = deps.scanTargets ?? defaultScanTargets;
107
184
  const apiClientFactory = deps.apiClientFactory ?? defaultApiClientFactory;
108
185
  const prompts = deps.prompts ?? defaultPrompts;
186
+ const env = deps.env ?? process.env;
187
+ const nonInteractive = deps.nonInteractive ?? false;
188
+ const seed = resolveCredentialInputs({ endpoint: deps.endpoint, apiKey: deps.apiKey }, env);
189
+ const fileArg = deps.file?.trim();
190
+ const stagingArg = deps.stagingId?.trim();
109
191
  p.intro(getMessage("deploy.intro", locale));
110
- const creds = await ensureCreds(projectDir, locale);
111
- const api = apiClientFactory(creds.endpoint, creds.apiKey);
112
192
  const spin = p.spinner();
113
- spin.start(getMessage("deploy.progress.fetchingStagings", locale));
114
- let stagings;
115
- try {
116
- stagings = await api.listStagings();
193
+ const initialCreds = nonInteractive
194
+ ? await resolveOrThrow(projectDir, locale, seed)
195
+ : await ensureCreds(projectDir, locale, seed);
196
+ const { creds, api } = await verifyCredentialsLoop(projectDir, locale, initialCreds, { dirty: false, interactive: !nonInteractive }, {
197
+ apiClientFactory,
198
+ repromptCredentials: reprompt,
199
+ persistCredentials: persist,
200
+ });
201
+ let stagingId;
202
+ if (stagingArg && stagingArg.length > 0) {
203
+ stagingId = stagingArg;
117
204
  }
118
- catch (err) {
119
- spin.stop(getMessage("deploy.progress.fetchingStagings", locale));
120
- throw logAndRethrow(err, locale);
205
+ else if (nonInteractive) {
206
+ p.log.error(getMessage("deploy.error.missingStagingId", locale));
207
+ throw new Error("missing staging id");
121
208
  }
122
- spin.stop(getMessage("deploy.progress.fetchingStagings", locale));
123
- if (stagings.length === 0) {
124
- p.log.error(getMessage("deploy.error.noStagings", locale));
125
- throw new Error("no stagings");
126
- }
127
- const stagingId = await prompts.selectStaging(stagings, locale);
128
- const zips = await scan(projectDir);
129
- if (zips.length === 0) {
130
- p.log.error(getMessage("deploy.error.noTargetZip", locale));
131
- throw new Error("no target zip");
209
+ else {
210
+ let stagings;
211
+ spin.start(getMessage("deploy.progress.fetchingStagings", locale));
212
+ try {
213
+ stagings = await api.listStagings();
214
+ spin.stop(getMessage("deploy.progress.fetchingStagings", locale));
215
+ }
216
+ catch (err) {
217
+ spin.stop(getMessage("deploy.progress.fetchingStagings", locale));
218
+ throw logAndRethrow(err, locale);
219
+ }
220
+ if (stagings.length === 0) {
221
+ p.log.error(getMessage("deploy.error.noStagings", locale));
222
+ throw new Error("no stagings");
223
+ }
224
+ stagingId = await prompts.selectStaging(stagings, locale);
132
225
  }
133
- const zipPath = zips.length === 1 ? zips[0] : await prompts.selectZip(zips, locale);
134
- const description = (await prompts.description(locale)).trim();
226
+ const zipPath = await resolveZipPath({
227
+ projectDir,
228
+ locale,
229
+ nonInteractive,
230
+ fileArg,
231
+ scan,
232
+ selectZip: prompts.selectZip,
233
+ });
234
+ const description = (deps.description !== undefined
235
+ ? deps.description
236
+ : nonInteractive
237
+ ? ""
238
+ : await prompts.description(locale)).trim();
135
239
  const immName = toImmFileName(zipPath);
136
- const confirmed = await prompts.confirm({
137
- endpoint: creds.endpoint,
138
- stagingId,
139
- sourceFile: basename(zipPath),
140
- sentAs: immName,
141
- }, locale);
142
- if (!confirmed) {
143
- p.log.info(getMessage("deploy.cancelled", locale));
144
- return;
240
+ if (!nonInteractive) {
241
+ const confirmed = await prompts.confirm({
242
+ endpoint: creds.endpoint,
243
+ stagingId,
244
+ sourceFile: basename(zipPath),
245
+ sentAs: immName,
246
+ }, locale);
247
+ if (!confirmed) {
248
+ p.log.info(getMessage("deploy.cancelled", locale));
249
+ return;
250
+ }
145
251
  }
146
252
  const bytes = await readFile(zipPath);
147
253
  spin.start(getMessage("deploy.progress.deploying", locale));
@@ -154,14 +260,108 @@ export const runDeploy = async (deps) => {
154
260
  throw logAndRethrow(err, locale);
155
261
  }
156
262
  spin.stop(getMessage("deploy.progress.deploying", locale));
157
- p.note([
263
+ const resultLines = [
158
264
  `${getMessage("deploy.result.deployId", locale)}: ${result.deployId}`,
159
265
  `${getMessage("deploy.result.stagingId", locale)}: ${result.stagingId}`,
160
266
  `${getMessage("deploy.result.status", locale)}: ${result.status}`,
161
- `${getMessage("deploy.result.createDate", locale)}: ${result.createDate}`,
162
- ].join("\n"));
267
+ `${getMessage("deploy.result.createDate", locale)}: ${formatEpochMillis(result.createDate, locale)}`,
268
+ ];
269
+ p.note(resultLines.join("\n"));
270
+ if (!nonInteractive && result.setupConfigs && result.setupConfigs.length > 0) {
271
+ try {
272
+ await runSetup(api, stagingId, result.setupConfigs, locale, prompts, spin);
273
+ }
274
+ catch (err) {
275
+ const msg = isDeployError(err)
276
+ ? formatDeployError(err, locale)
277
+ : err instanceof Error
278
+ ? err.message
279
+ : String(err);
280
+ p.log.error(getMessage("deploy.setup.error", locale, { message: msg }));
281
+ }
282
+ }
283
+ if (result.shortcutUrl) {
284
+ p.log.info(`${getMessage("deploy.result.shortcutUrl", locale)}: ${result.shortcutUrl}`);
285
+ }
163
286
  p.outro(getMessage("deploy.success", locale));
164
287
  };
288
+ const runSetup = async (api, stagingId, configs, locale, prompts, spin) => {
289
+ const doSetup = await prompts.confirmSetup(configs, locale);
290
+ if (!doSetup)
291
+ return;
292
+ const doAll = await prompts.confirmSetupAll(locale);
293
+ let setupResult;
294
+ if (doAll) {
295
+ spin.start(getMessage("deploy.setup.executing", locale, { config: "all" }));
296
+ try {
297
+ setupResult = await api.executeSetup(stagingId);
298
+ }
299
+ finally {
300
+ spin.stop(getMessage("deploy.setup.executing", locale, { config: "all" }));
301
+ }
302
+ }
303
+ else {
304
+ const selected = await prompts.selectSetupConfigs(configs, locale);
305
+ const allResults = [];
306
+ let allSuccess = true;
307
+ for (const configNumber of selected.sort((a, b) => a - b)) {
308
+ const config = configs.find((c) => c.configNumber === configNumber);
309
+ const label = config
310
+ ? `#${config.configNumber} ${config.moduleId}`
311
+ : `#${configNumber}`;
312
+ spin.start(getMessage("deploy.setup.executing", locale, { config: label }));
313
+ let partial;
314
+ try {
315
+ partial = await api.executeSetupConfig(stagingId, configNumber);
316
+ }
317
+ finally {
318
+ spin.stop(getMessage("deploy.setup.executing", locale, { config: label }));
319
+ }
320
+ allResults.push(...partial.results);
321
+ if (!partial.success)
322
+ allSuccess = false;
323
+ }
324
+ setupResult = {
325
+ success: allSuccess,
326
+ totalCount: allResults.length,
327
+ results: allResults,
328
+ };
329
+ }
330
+ showSetupResults(setupResult, locale);
331
+ };
332
+ const showSetupResults = (result, locale) => {
333
+ if (result.results.length === 0)
334
+ return;
335
+ const sectionHeader = getMessage("deploy.setup.resultHeader.section", locale);
336
+ const targetHeader = getMessage("deploy.setup.resultHeader.target", locale);
337
+ const resultHeader = getMessage("deploy.setup.resultHeader.result", locale);
338
+ const rows = result.results.map((r) => {
339
+ const status = r.success ? "OK" : "NG";
340
+ const detail = r.message ? ` (${r.message})` : "";
341
+ return [r.label, r.target, `${status}${detail}`];
342
+ });
343
+ const displayWidth = (s) => {
344
+ let w = 0;
345
+ for (const ch of s) {
346
+ const cp = ch.codePointAt(0) ?? 0;
347
+ w += cp > 0x7f ? 2 : 1;
348
+ }
349
+ return w;
350
+ };
351
+ const colWidths = [sectionHeader, targetHeader, resultHeader].map((h, i) => Math.max(displayWidth(h), ...rows.map((r) => displayWidth(r[i]))));
352
+ const pad = (s, w) => s + " ".repeat(Math.max(0, w - displayWidth(s)));
353
+ const formatRow = (cols) => cols.map((c, i) => pad(c, colWidths[i])).join(" | ");
354
+ const header = formatRow([sectionHeader, targetHeader, resultHeader]);
355
+ const separator = colWidths.map((w) => "-".repeat(w)).join("-+-");
356
+ const lines = rows.map((r) => formatRow(r));
357
+ p.note([header, separator, ...lines].join("\n"));
358
+ if (result.success) {
359
+ p.log.success(getMessage("deploy.setup.resultSuccess", locale));
360
+ }
361
+ else {
362
+ p.log.warn(getMessage("deploy.setup.resultPartialFailure", locale));
363
+ }
364
+ };
165
365
  const logAndRethrow = (err, locale) => {
166
366
  if (isDeployError(err)) {
167
367
  p.log.error(formatDeployError(err, locale));
@@ -176,10 +376,44 @@ export const deployCommand = defineCommand({
176
376
  name: "deploy",
177
377
  description: "Deploy build artifacts to an iAP staging environment",
178
378
  },
179
- args: {},
180
- run: async () => {
379
+ args: {
380
+ endpoint: {
381
+ type: "string",
382
+ description: "iAP base URL (or set ACCEL_ENDPOINT)",
383
+ },
384
+ "api-key": {
385
+ type: "string",
386
+ description: "OAuth Bearer token. Prefer the ACCEL_API_KEY env var (argv leaks to process listings / CI logs)",
387
+ },
388
+ "staging-id": {
389
+ type: "string",
390
+ description: "Target staging ID (required in non-interactive mode)",
391
+ },
392
+ file: {
393
+ type: "string",
394
+ description: "Path to the zip to deploy (not restricted to ./target/)",
395
+ },
396
+ description: {
397
+ type: "string",
398
+ description: "Deployment description",
399
+ },
400
+ "non-interactive": {
401
+ type: "boolean",
402
+ description: "Non-interactive mode (no prompts; exits non-zero on failure)",
403
+ default: false,
404
+ },
405
+ },
406
+ run: async ({ args }) => {
181
407
  try {
182
- await runDeploy({ projectDir: process.cwd() });
408
+ await runDeploy({
409
+ projectDir: process.cwd(),
410
+ nonInteractive: args["non-interactive"],
411
+ endpoint: lastFlagValue(args.endpoint),
412
+ apiKey: lastFlagValue(args["api-key"]),
413
+ stagingId: lastFlagValue(args["staging-id"]),
414
+ file: lastFlagValue(args.file),
415
+ description: lastFlagValue(args.description),
416
+ });
183
417
  }
184
418
  catch {
185
419
  process.exit(1);
@@ -16,6 +16,10 @@ export declare const initCommand: import("citty").CommandDef<{
16
16
  type: "string";
17
17
  description: string;
18
18
  };
19
+ feature: {
20
+ type: "string";
21
+ description: string;
22
+ };
19
23
  group: {
20
24
  type: "string";
21
25
  description: string;
@@ -67,11 +71,19 @@ export declare const initCommand: import("citty").CommandDef<{
67
71
  description: string;
68
72
  default: false;
69
73
  };
74
+ "asset-server-url": {
75
+ type: "string";
76
+ description: string;
77
+ };
78
+ "asset-ref": {
79
+ type: "string";
80
+ description: string;
81
+ };
70
82
  "asset-source": {
71
83
  type: "string";
72
84
  description: string;
73
85
  };
74
- "asset-server-url": {
86
+ "debug-server-url": {
75
87
  type: "string";
76
88
  description: string;
77
89
  };
@@ -3,12 +3,12 @@ import * as p from "@clack/prompts";
3
3
  import { mkdir, stat } from "node:fs/promises";
4
4
  import { execSync } from "node:child_process";
5
5
  import { resolve } from "node:path";
6
- import { CLI_VERSION } from "../core/constants.js";
6
+ import { CLI_VERSION, DEFAULT_ASSET_REPO_URL, DEFAULT_ASSET_REF, } from "../core/constants.js";
7
7
  import { runPrompts } from "../interactive/prompts.js";
8
8
  import { deployAssets } from "../asset/deployer.js";
9
9
  import { createLocalAssetProvider } from "../asset/local-provider.js";
10
10
  import { createFileAssetProvider } from "../asset/file-provider.js";
11
- import { defaultAssetSourcePath } from "../asset/default-source.js";
11
+ import { createGitHubAssetProvider } from "../asset/github-provider.js";
12
12
  import { getMessage } from "../i18n/index.js";
13
13
  import { detectLocale } from "../utils/locale-detect.js";
14
14
  import { commandExists } from "../utils/command-exists.js";
@@ -32,11 +32,15 @@ export const initCommand = defineCommand({
32
32
  },
33
33
  "accelplatform-version": {
34
34
  type: "string",
35
- description: "iAP version (e.g., 2026-Spring)",
35
+ description: "iAP version (e.g., 2026-spring)",
36
36
  },
37
37
  module: {
38
38
  type: "string",
39
- description: "Modules to use (comma-separated)",
39
+ description: "Modules to use (comma-separated artifactIds, e.g., im_workflow)",
40
+ },
41
+ feature: {
42
+ type: "string",
43
+ description: "Features to use (comma-separated function ids, e.g., jssp)",
40
44
  },
41
45
  group: {
42
46
  type: "string",
@@ -89,13 +93,21 @@ export const initCommand = defineCommand({
89
93
  description: "Non-interactive mode",
90
94
  default: false,
91
95
  },
96
+ "asset-server-url": {
97
+ type: "string",
98
+ description: "GitHub repository URL to fetch assets from (overrides the default repository)",
99
+ },
100
+ "asset-ref": {
101
+ type: "string",
102
+ description: "Git ref (branch/tag/commit) to fetch from the GitHub asset repository. Default: master",
103
+ },
92
104
  "asset-source": {
93
105
  type: "string",
94
- description: "Local asset source path (tar archive or extracted directory). Defaults to the bundled assets/assets.tar.gz.",
106
+ description: "(debug) Local asset source path (tar archive or extracted directory)",
95
107
  },
96
- "asset-server-url": {
108
+ "debug-server-url": {
97
109
  type: "string",
98
- description: "Asset server URL (takes precedence over --asset-source when explicitly set)",
110
+ description: "(debug) Local asset server URL serving GET /archive",
99
111
  },
100
112
  },
101
113
  run: async ({ args }) => {
@@ -105,6 +117,10 @@ export const initCommand = defineCommand({
105
117
  const modules = moduleArg
106
118
  ? moduleArg.split(",").map((m) => m.trim())
107
119
  : undefined;
120
+ const featureArg = args.feature;
121
+ const features = featureArg
122
+ ? featureArg.split(",").map((f) => f.trim())
123
+ : undefined;
108
124
  const agentArg = args.agent;
109
125
  const promptOpts = {
110
126
  name: projectName,
@@ -112,6 +128,7 @@ export const initCommand = defineCommand({
112
128
  jugglingProject: args["juggling-project"],
113
129
  accelplatformVersion: args["accelplatform-version"],
114
130
  module: modules,
131
+ feature: features,
115
132
  group: args.group,
116
133
  projectVersion: args["project-version"],
117
134
  description: args.description,
@@ -153,6 +170,7 @@ export const initCommand = defineCommand({
153
170
  description: resolved.description,
154
171
  accelplatformVersion: resolved.accelplatformVersion,
155
172
  modules: resolved.modules,
173
+ features: resolved.features,
156
174
  database: resolved.database,
157
175
  agents: resolved.agents,
158
176
  javascript: resolved.javascript,
@@ -165,11 +183,14 @@ export const initCommand = defineCommand({
165
183
  if (isInteractive) {
166
184
  printSummary(settings, projectDir, locale);
167
185
  }
168
- const serverUrl = args["asset-server-url"];
169
- const assetSource = args["asset-source"] ?? defaultAssetSourcePath();
170
- const provider = serverUrl
171
- ? createLocalAssetProvider(serverUrl)
172
- : createFileAssetProvider(assetSource);
186
+ const assetSource = args["asset-source"];
187
+ const debugServerUrl = args["debug-server-url"];
188
+ const provider = assetSource
189
+ ? createFileAssetProvider(assetSource)
190
+ : debugServerUrl
191
+ ? createLocalAssetProvider(debugServerUrl)
192
+ : createGitHubAssetProvider(args["asset-server-url"] ??
193
+ DEFAULT_ASSET_REPO_URL, args["asset-ref"] ?? DEFAULT_ASSET_REF);
173
194
  await deployAssets({
174
195
  projectDir,
175
196
  settings,
@@ -0,0 +1,31 @@
1
+ import type { AccelCredentials } from "../core/types.js";
2
+ import { type ApiClient } from "../deploy/api-client.js";
3
+ export type RunLoginDeps = {
4
+ projectDir: string;
5
+ locale?: string;
6
+ nonInteractive?: boolean;
7
+ endpoint?: string;
8
+ apiKey?: string;
9
+ env?: Record<string, string | undefined>;
10
+ readCredentials?: (projectDir: string) => Promise<Partial<AccelCredentials>>;
11
+ repromptCredentials?: (current: AccelCredentials, locale: string, seed?: Partial<AccelCredentials>) => Promise<AccelCredentials>;
12
+ resolveCredentialsOrThrow?: (projectDir: string, locale: string, seed: Partial<AccelCredentials>) => Promise<AccelCredentials>;
13
+ persistCredentials?: (projectDir: string, creds: AccelCredentials) => Promise<void>;
14
+ apiClientFactory?: (endpoint: string, apiKey: string) => ApiClient;
15
+ };
16
+ export declare const runLogin: (deps: RunLoginDeps) => Promise<void>;
17
+ export declare const loginCommand: import("citty").CommandDef<{
18
+ endpoint: {
19
+ type: "string";
20
+ description: string;
21
+ };
22
+ "api-key": {
23
+ type: "string";
24
+ description: string;
25
+ };
26
+ "non-interactive": {
27
+ type: "boolean";
28
+ description: string;
29
+ default: false;
30
+ };
31
+ }>;
@@ -0,0 +1,76 @@
1
+ import { defineCommand } from "citty";
2
+ import * as p from "@clack/prompts";
3
+ import { detectLocale } from "../utils/locale-detect.js";
4
+ import { readSettingsSafe } from "../utils/settings-io.js";
5
+ import { readCredentials as defaultReadCredentials, resolveCredentialInputs, } from "../utils/credentials.js";
6
+ import { persistCredentialsAndSyncMcp as defaultPersistCredentials } from "../utils/mcp-sync.js";
7
+ import { repromptCredentials as defaultRepromptCredentials, resolveCredentialsOrThrow as defaultResolveCredentialsOrThrow, } from "../interactive/credentials-prompts.js";
8
+ import { verifyCredentialsLoop } from "../interactive/credential-auth.js";
9
+ import { createApiClient as defaultApiClientFactory, } from "../deploy/api-client.js";
10
+ import { getMessage } from "../i18n/index.js";
11
+ import { lastFlagValue } from "../utils/args.js";
12
+ const resolveLocale = async (projectDir) => {
13
+ const settings = await readSettingsSafe(projectDir);
14
+ return settings?.locale ?? detectLocale();
15
+ };
16
+ export const runLogin = async (deps) => {
17
+ const { projectDir } = deps;
18
+ const locale = deps.locale ?? (await resolveLocale(projectDir));
19
+ const read = deps.readCredentials ?? defaultReadCredentials;
20
+ const reprompt = deps.repromptCredentials ?? defaultRepromptCredentials;
21
+ const resolveOrThrow = deps.resolveCredentialsOrThrow ?? defaultResolveCredentialsOrThrow;
22
+ const persist = deps.persistCredentials ?? defaultPersistCredentials;
23
+ const apiClientFactory = deps.apiClientFactory ?? defaultApiClientFactory;
24
+ const env = deps.env ?? process.env;
25
+ const seed = resolveCredentialInputs({ endpoint: deps.endpoint, apiKey: deps.apiKey }, env);
26
+ p.intro(getMessage("login.intro", locale));
27
+ let initial;
28
+ if (deps.nonInteractive) {
29
+ initial = await resolveOrThrow(projectDir, locale, seed);
30
+ }
31
+ else {
32
+ const existing = await read(projectDir);
33
+ initial = await reprompt({ endpoint: existing.endpoint ?? "", apiKey: existing.apiKey ?? "" }, locale, seed);
34
+ }
35
+ const { creds } = await verifyCredentialsLoop(projectDir, locale, initial, { dirty: true, interactive: !deps.nonInteractive }, {
36
+ apiClientFactory,
37
+ repromptCredentials: reprompt,
38
+ persistCredentials: persist,
39
+ });
40
+ p.log.success(`endpoint: ${creds.endpoint}`);
41
+ p.outro(getMessage("login.complete", locale));
42
+ };
43
+ export const loginCommand = defineCommand({
44
+ meta: {
45
+ name: "login",
46
+ description: "Configure and verify iAP connection credentials",
47
+ },
48
+ args: {
49
+ endpoint: {
50
+ type: "string",
51
+ description: "iAP base URL (or set ACCEL_ENDPOINT)",
52
+ },
53
+ "api-key": {
54
+ type: "string",
55
+ description: "OAuth Bearer token. Prefer the ACCEL_API_KEY env var (argv leaks to process listings / CI logs)",
56
+ },
57
+ "non-interactive": {
58
+ type: "boolean",
59
+ description: "Non-interactive mode (no prompts; exits non-zero on failure)",
60
+ default: false,
61
+ },
62
+ },
63
+ run: async ({ args }) => {
64
+ try {
65
+ await runLogin({
66
+ projectDir: process.cwd(),
67
+ nonInteractive: args["non-interactive"],
68
+ endpoint: lastFlagValue(args.endpoint),
69
+ apiKey: lastFlagValue(args["api-key"]),
70
+ });
71
+ }
72
+ catch {
73
+ process.exit(1);
74
+ }
75
+ },
76
+ });