@intra-mart/accel 0.3.1 → 0.4.0-dev.202607140628

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 (67) hide show
  1. package/README.md +55 -12
  2. package/dist/asset/asset-tree.d.ts +5 -0
  3. package/dist/asset/asset-tree.js +7 -0
  4. package/dist/asset/deployer.d.ts +2 -1
  5. package/dist/asset/deployer.js +32 -59
  6. package/dist/asset/file-provider.js +19 -18
  7. package/dist/asset/git-provider.d.ts +14 -0
  8. package/dist/asset/git-provider.js +198 -0
  9. package/dist/asset/installer.d.ts +6 -0
  10. package/dist/asset/installer.js +31 -0
  11. package/dist/asset/renderer.d.ts +2 -0
  12. package/dist/asset/renderer.js +22 -0
  13. package/dist/asset/types.d.ts +1 -1
  14. package/dist/asset/updater.d.ts +52 -0
  15. package/dist/asset/updater.js +301 -0
  16. package/dist/asset/walker.d.ts +3 -2
  17. package/dist/asset/walker.js +67 -45
  18. package/dist/commands/asset-provider.d.ts +7 -0
  19. package/dist/commands/asset-provider.js +9 -0
  20. package/dist/commands/attach.d.ts +0 -4
  21. package/dist/commands/attach.js +11 -20
  22. package/dist/commands/deploy.d.ts +11 -6
  23. package/dist/commands/deploy.js +77 -23
  24. package/dist/commands/init.d.ts +0 -4
  25. package/dist/commands/init.js +11 -20
  26. package/dist/commands/update.d.ts +86 -0
  27. package/dist/commands/update.js +438 -0
  28. package/dist/core/constants.d.ts +3 -3
  29. package/dist/core/constants.js +4 -2
  30. package/dist/core/types.d.ts +11 -0
  31. package/dist/deploy/api-client.d.ts +6 -2
  32. package/dist/deploy/api-client.js +8 -4
  33. package/dist/deploy/deploy-files.d.ts +20 -0
  34. package/dist/deploy/deploy-files.js +37 -0
  35. package/dist/git/errors.d.ts +6 -0
  36. package/dist/git/errors.js +9 -0
  37. package/dist/git/http.d.ts +3 -0
  38. package/dist/git/http.js +58 -0
  39. package/dist/git/object-store.d.ts +13 -0
  40. package/dist/git/object-store.js +79 -0
  41. package/dist/git/pkt-line.d.ts +13 -0
  42. package/dist/git/pkt-line.js +41 -0
  43. package/dist/git/smart-http.d.ts +18 -0
  44. package/dist/git/smart-http.js +109 -0
  45. package/dist/i18n/en.js +49 -6
  46. package/dist/i18n/ja.js +49 -6
  47. package/dist/i18n/zh_CN.js +49 -6
  48. package/dist/index.js +4 -1
  49. package/dist/interactive/progress.js +1 -0
  50. package/dist/interactive/prompts.d.ts +7 -1
  51. package/dist/interactive/prompts.js +63 -64
  52. package/dist/markdown/section-replacement.js +34 -8
  53. package/dist/utils/args.d.ts +1 -0
  54. package/dist/utils/args.js +4 -0
  55. package/dist/utils/fs-list.d.ts +1 -0
  56. package/dist/utils/fs-list.js +11 -0
  57. package/dist/utils/merge-file.d.ts +6 -0
  58. package/dist/utils/merge-file.js +20 -0
  59. package/package.json +6 -8
  60. package/dist/asset/github-provider.d.ts +0 -2
  61. package/dist/asset/github-provider.js +0 -37
  62. package/dist/asset/local-provider.d.ts +0 -2
  63. package/dist/asset/local-provider.js +0 -24
  64. package/dist/utils/archive.d.ts +0 -3
  65. package/dist/utils/archive.js +0 -20
  66. package/dist/utils/https.d.ts +0 -2
  67. package/dist/utils/https.js +0 -44
@@ -1,20 +1,21 @@
1
1
  import type { AccelCredentials, SetupConfigResponse, StagingResponse } from "../core/types.js";
2
2
  import { type ApiClient } from "../deploy/api-client.js";
3
- export declare const toImmFileName: (zipPath: string) => string;
4
- type ConfirmInfo = {
3
+ import { type DeployFile } from "../deploy/deploy-files.js";
4
+ export type ConfirmInfo = {
5
5
  endpoint: string;
6
6
  stagingId: string;
7
- sourceFile: string;
8
- sentAs: string;
7
+ files: DeployFile[];
9
8
  };
10
9
  export type DeployPrompts = {
11
10
  selectStaging: (stagings: StagingResponse[], locale: string) => Promise<string>;
12
11
  selectZip: (zips: string[], locale: string) => Promise<string>;
13
12
  description: (locale: string) => Promise<string>;
13
+ confirmOrder: (files: DeployFile[], locale: string) => Promise<boolean>;
14
+ selectNextFile: (candidates: DeployFile[], position: number, total: number, locale: string) => Promise<DeployFile>;
14
15
  confirm: (info: ConfirmInfo, locale: string) => Promise<boolean>;
15
16
  confirmSetup: (configs: SetupConfigResponse[], locale: string) => Promise<boolean>;
16
17
  confirmSetupAll: (locale: string) => Promise<boolean>;
17
- selectSetupConfigs: (configs: SetupConfigResponse[], locale: string) => Promise<number[]>;
18
+ selectSetupConfigs: (configs: SetupConfigResponse[], locale: string) => Promise<SetupConfigResponse[]>;
18
19
  };
19
20
  export type RunDeployDeps = {
20
21
  projectDir: string;
@@ -24,6 +25,7 @@ export type RunDeployDeps = {
24
25
  apiKey?: string;
25
26
  stagingId?: string;
26
27
  file?: string;
28
+ additionalFiles?: string[];
27
29
  description?: string;
28
30
  env?: Record<string, string | undefined>;
29
31
  ensureCredentials?: (projectDir: string, locale: string, seed?: Partial<AccelCredentials>) => Promise<AccelCredentials>;
@@ -52,6 +54,10 @@ export declare const deployCommand: import("citty").CommandDef<{
52
54
  type: "string";
53
55
  description: string;
54
56
  };
57
+ "additional-file": {
58
+ type: "string";
59
+ description: string;
60
+ };
55
61
  description: {
56
62
  type: "string";
57
63
  description: string;
@@ -62,4 +68,3 @@ export declare const deployCommand: import("citty").CommandDef<{
62
68
  default: false;
63
69
  };
64
70
  }>;
65
- export {};
@@ -8,16 +8,19 @@ import { readSettings, readSettingsSafe } from "../utils/settings-io.js";
8
8
  import { resolveCredentialInputs } from "../utils/credentials.js";
9
9
  import { persistCredentialsAndSyncMcp as defaultPersistCredentials } from "../utils/mcp-sync.js";
10
10
  import { getMessage } from "../i18n/index.js";
11
- import { lastFlagValue } from "../utils/args.js";
11
+ import { allFlagValues, lastFlagValue } from "../utils/args.js";
12
12
  import { ensureCredentials as defaultEnsureCredentials, repromptCredentials as defaultRepromptCredentials, resolveCredentialsOrThrow as defaultResolveCredentialsOrThrow, } from "../interactive/credentials-prompts.js";
13
13
  import { scanTargets as defaultScanTargets } from "../deploy/target-scanner.js";
14
14
  import { selectDeployTarget } from "../deploy/target-selector.js";
15
15
  import { verifyCredentialsLoop } from "../interactive/credential-auth.js";
16
16
  import { createApiClient as defaultApiClientFactory, isDeployError, } from "../deploy/api-client.js";
17
- export const toImmFileName = (zipPath) => {
18
- const base = basename(zipPath);
19
- return base.replace(/\.zip$/i, "") + ".imm";
17
+ import { buildDeployFiles, validateAdditionalFiles, } from "../deploy/deploy-files.js";
18
+ const ADDITIONAL_FILE_ERROR_KEY = {
19
+ notFound: "deploy.error.additionalFileNotFound",
20
+ invalidExtension: "deploy.error.additionalFileInvalidExtension",
21
+ duplicate: "deploy.error.additionalFileDuplicate",
20
22
  };
23
+ const setupConfigKey = (c) => `${c.moduleId}\u0000${c.configNumber}`;
21
24
  const defaultPrompts = {
22
25
  selectStaging: async (stagings, locale) => {
23
26
  const res = await p.select({
@@ -52,12 +55,34 @@ const defaultPrompts = {
52
55
  process.exit(0);
53
56
  return res;
54
57
  },
58
+ confirmOrder: async (files, locale) => {
59
+ p.note(files.map((f, i) => `${i + 1}. ${f.display}`).join("\n"), getMessage("deploy.order.heading", locale));
60
+ const res = await p.confirm({
61
+ message: getMessage("deploy.order.confirm", locale),
62
+ initialValue: true,
63
+ });
64
+ if (p.isCancel(res))
65
+ process.exit(0);
66
+ return res;
67
+ },
68
+ selectNextFile: async (candidates, position, total, locale) => {
69
+ const res = await p.select({
70
+ message: getMessage("deploy.order.selectNext", locale, {
71
+ position: String(position),
72
+ total: String(total),
73
+ }),
74
+ options: candidates.map((f) => ({ value: f, label: f.display })),
75
+ });
76
+ if (p.isCancel(res))
77
+ process.exit(0);
78
+ return res;
79
+ },
55
80
  confirm: async (info, locale) => {
56
81
  p.note([
57
82
  `${getMessage("deploy.confirm.endpoint", locale)}: ${info.endpoint}`,
58
83
  `${getMessage("deploy.confirm.stagingId", locale)}: ${info.stagingId}`,
59
- `${getMessage("deploy.confirm.sourceFile", locale)}: ${info.sourceFile}`,
60
- `${getMessage("deploy.confirm.sentAs", locale)}: ${info.sentAs}`,
84
+ `${getMessage("deploy.confirm.files", locale)}:`,
85
+ ...info.files.map((f, i) => ` ${i + 1}. ${f.display}`),
61
86
  ].join("\n"));
62
87
  const res = await p.confirm({
63
88
  message: getMessage("deploy.confirm", locale),
@@ -92,14 +117,15 @@ const defaultPrompts = {
92
117
  const res = await p.multiselect({
93
118
  message: getMessage("deploy.setup.selectConfigs", locale),
94
119
  options: configs.map((c) => ({
95
- value: c.configNumber,
120
+ value: setupConfigKey(c),
96
121
  label: `#${c.configNumber} ${c.moduleId} [${c.sections.join(", ")}]`,
97
122
  })),
98
123
  required: true,
99
124
  });
100
125
  if (p.isCancel(res))
101
126
  process.exit(0);
102
- return res;
127
+ const selected = new Set(res);
128
+ return configs.filter((c) => selected.has(setupConfigKey(c)));
103
129
  },
104
130
  };
105
131
  const resolveLocale = async (projectDir) => {
@@ -188,6 +214,9 @@ export const runDeploy = async (deps) => {
188
214
  const seed = resolveCredentialInputs({ endpoint: deps.endpoint, apiKey: deps.apiKey }, env);
189
215
  const fileArg = deps.file?.trim();
190
216
  const stagingArg = deps.stagingId?.trim();
217
+ const additionalArgs = (deps.additionalFiles ?? [])
218
+ .map((s) => s.trim())
219
+ .filter((s) => s.length > 0);
191
220
  p.intro(getMessage("deploy.intro", locale));
192
221
  const spin = p.spinner();
193
222
  const initialCreds = nonInteractive
@@ -231,29 +260,40 @@ export const runDeploy = async (deps) => {
231
260
  scan,
232
261
  selectZip: prompts.selectZip,
233
262
  });
263
+ const validated = await validateAdditionalFiles(projectDir, additionalArgs, zipPath);
264
+ if (!validated.ok) {
265
+ p.log.error(getMessage(ADDITIONAL_FILE_ERROR_KEY[validated.error.kind], locale, {
266
+ path: validated.error.path,
267
+ }));
268
+ throw new Error(`additional file ${validated.error.kind}`);
269
+ }
270
+ let deployFiles = buildDeployFiles(validated.paths, zipPath, projectDir);
271
+ if (additionalArgs.length > 0 && !nonInteractive) {
272
+ const keepDefault = await prompts.confirmOrder(deployFiles, locale);
273
+ if (!keepDefault) {
274
+ deployFiles = await reorderFiles(deployFiles, prompts, locale);
275
+ }
276
+ }
234
277
  const description = (deps.description !== undefined
235
278
  ? deps.description
236
279
  : nonInteractive
237
280
  ? ""
238
281
  : await prompts.description(locale)).trim();
239
- const immName = toImmFileName(zipPath);
240
282
  if (!nonInteractive) {
241
- const confirmed = await prompts.confirm({
242
- endpoint: creds.endpoint,
243
- stagingId,
244
- sourceFile: basename(zipPath),
245
- sentAs: immName,
246
- }, locale);
283
+ const confirmed = await prompts.confirm({ endpoint: creds.endpoint, stagingId, files: deployFiles }, locale);
247
284
  if (!confirmed) {
248
285
  p.log.info(getMessage("deploy.cancelled", locale));
249
286
  return;
250
287
  }
251
288
  }
252
- const bytes = await readFile(zipPath);
289
+ const archives = [];
290
+ for (const file of deployFiles) {
291
+ archives.push({ bytes: await readFile(file.path), fileName: file.sentAs });
292
+ }
253
293
  spin.start(getMessage("deploy.progress.deploying", locale));
254
294
  let result;
255
295
  try {
256
- result = await api.createDeployment(stagingId, bytes, immName, description.length > 0 ? description : undefined);
296
+ result = await api.createDeployment(stagingId, archives, description.length > 0 ? description : undefined);
257
297
  }
258
298
  catch (err) {
259
299
  spin.stop(getMessage("deploy.progress.deploying", locale));
@@ -285,6 +325,16 @@ export const runDeploy = async (deps) => {
285
325
  }
286
326
  p.outro(getMessage("deploy.success", locale));
287
327
  };
328
+ const reorderFiles = async (files, prompts, locale) => {
329
+ const remaining = [...files];
330
+ const ordered = [];
331
+ while (remaining.length > 1) {
332
+ const picked = await prompts.selectNextFile(remaining, ordered.length + 1, files.length, locale);
333
+ ordered.push(picked);
334
+ remaining.splice(remaining.findIndex((f) => f.path === picked.path), 1);
335
+ }
336
+ return [...ordered, ...remaining];
337
+ };
288
338
  const runSetup = async (api, stagingId, configs, locale, prompts, spin) => {
289
339
  const doSetup = await prompts.confirmSetup(configs, locale);
290
340
  if (!doSetup)
@@ -302,17 +352,16 @@ const runSetup = async (api, stagingId, configs, locale, prompts, spin) => {
302
352
  }
303
353
  else {
304
354
  const selected = await prompts.selectSetupConfigs(configs, locale);
355
+ const selectedKeys = new Set(selected.map(setupConfigKey));
356
+ const ordered = configs.filter((c) => selectedKeys.has(setupConfigKey(c)));
305
357
  const allResults = [];
306
358
  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}`;
359
+ for (const config of ordered) {
360
+ const label = `#${config.configNumber} ${config.moduleId}`;
312
361
  spin.start(getMessage("deploy.setup.executing", locale, { config: label }));
313
362
  let partial;
314
363
  try {
315
- partial = await api.executeSetupConfig(stagingId, configNumber);
364
+ partial = await api.executeSetupConfig(stagingId, config.moduleId, config.configNumber);
316
365
  }
317
366
  finally {
318
367
  spin.stop(getMessage("deploy.setup.executing", locale, { config: label }));
@@ -393,6 +442,10 @@ export const deployCommand = defineCommand({
393
442
  type: "string",
394
443
  description: "Path to the zip to deploy (not restricted to ./target/)",
395
444
  },
445
+ "additional-file": {
446
+ type: "string",
447
+ description: "Additional archive (.imm/.zip) deployed before the main artifact (repeatable)",
448
+ },
396
449
  description: {
397
450
  type: "string",
398
451
  description: "Deployment description",
@@ -412,6 +465,7 @@ export const deployCommand = defineCommand({
412
465
  apiKey: lastFlagValue(args["api-key"]),
413
466
  stagingId: lastFlagValue(args["staging-id"]),
414
467
  file: lastFlagValue(args.file),
468
+ additionalFiles: allFlagValues(args["additional-file"]),
415
469
  description: lastFlagValue(args.description),
416
470
  });
417
471
  }
@@ -83,8 +83,4 @@ export declare const initCommand: import("citty").CommandDef<{
83
83
  type: "string";
84
84
  description: string;
85
85
  };
86
- "debug-server-url": {
87
- type: "string";
88
- description: string;
89
- };
90
86
  }>;
@@ -3,12 +3,10 @@ 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, DEFAULT_ASSET_REPO_URL, DEFAULT_ASSET_REF, } from "../core/constants.js";
6
+ import { CLI_VERSION } from "../core/constants.js";
7
7
  import { runPrompts } from "../interactive/prompts.js";
8
8
  import { deployAssets } from "../asset/deployer.js";
9
- import { createLocalAssetProvider } from "../asset/local-provider.js";
10
- import { createFileAssetProvider } from "../asset/file-provider.js";
11
- import { createGitHubAssetProvider } from "../asset/github-provider.js";
9
+ import { selectAssetProvider } from "./asset-provider.js";
12
10
  import { getMessage } from "../i18n/index.js";
13
11
  import { detectLocale } from "../utils/locale-detect.js";
14
12
  import { commandExists } from "../utils/command-exists.js";
@@ -95,19 +93,15 @@ export const initCommand = defineCommand({
95
93
  },
96
94
  "asset-server-url": {
97
95
  type: "string",
98
- description: "GitHub repository URL to fetch assets from (overrides the default repository)",
96
+ description: "Git repository URL to fetch assets from (overrides the default repository)",
99
97
  },
100
98
  "asset-ref": {
101
99
  type: "string",
102
- description: "Git ref (branch/tag/commit) to fetch from the GitHub asset repository. Default: master",
100
+ description: "Git branch/tag to fetch from the asset repository. Default: experiment",
103
101
  },
104
102
  "asset-source": {
105
103
  type: "string",
106
- description: "(debug) Local asset source path (tar archive or extracted directory)",
107
- },
108
- "debug-server-url": {
109
- type: "string",
110
- description: "(debug) Local asset server URL serving GET /archive",
104
+ description: "(debug) Local asset source directory",
111
105
  },
112
106
  },
113
107
  run: async ({ args }) => {
@@ -176,21 +170,18 @@ export const initCommand = defineCommand({
176
170
  javascript: resolved.javascript,
177
171
  locale: resolved.locale,
178
172
  packageManager: resolved.packageManager,
179
- jugglingProject: resolved.jugglingProject,
173
+ jugglingProject: resolved.jugglingProject ?? null,
180
174
  deployedAssets: {},
181
175
  };
182
176
  const isInteractive = !args["non-interactive"];
183
177
  if (isInteractive) {
184
178
  printSummary(settings, projectDir, locale);
185
179
  }
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);
180
+ const provider = await selectAssetProvider({
181
+ assetSource: args["asset-source"],
182
+ assetServerUrl: args["asset-server-url"],
183
+ assetRef: args["asset-ref"],
184
+ }, locale);
194
185
  await deployAssets({
195
186
  projectDir,
196
187
  settings,
@@ -0,0 +1,86 @@
1
+ export declare const updateCommand: import("citty").CommandDef<{
2
+ "juggling-project": {
3
+ type: "string";
4
+ description: string;
5
+ };
6
+ "accelplatform-version": {
7
+ type: "string";
8
+ description: string;
9
+ };
10
+ module: {
11
+ type: "string";
12
+ description: string;
13
+ };
14
+ feature: {
15
+ type: "string";
16
+ description: string;
17
+ };
18
+ name: {
19
+ type: "string";
20
+ description: string;
21
+ };
22
+ group: {
23
+ type: "string";
24
+ description: string;
25
+ };
26
+ "project-version": {
27
+ type: "string";
28
+ description: string;
29
+ };
30
+ description: {
31
+ type: "string";
32
+ description: string;
33
+ };
34
+ database: {
35
+ type: "string";
36
+ description: string;
37
+ };
38
+ javascript: {
39
+ type: "boolean";
40
+ description: string;
41
+ };
42
+ agent: {
43
+ type: "string";
44
+ description: string;
45
+ };
46
+ locale: {
47
+ type: "string";
48
+ description: string;
49
+ };
50
+ "artifact-id": {
51
+ type: "string";
52
+ description: string;
53
+ };
54
+ "package-manager": {
55
+ type: "string";
56
+ description: string;
57
+ };
58
+ "skip-install": {
59
+ type: "boolean";
60
+ description: string;
61
+ default: false;
62
+ };
63
+ "non-interactive": {
64
+ type: "boolean";
65
+ description: string;
66
+ default: false;
67
+ };
68
+ "asset-server-url": {
69
+ type: "string";
70
+ description: string;
71
+ };
72
+ "asset-ref": {
73
+ type: "string";
74
+ description: string;
75
+ };
76
+ "allow-missing-base": {
77
+ type: "boolean";
78
+ description: string;
79
+ default: false;
80
+ };
81
+ "keep-edited": {
82
+ type: "boolean";
83
+ description: string;
84
+ default: false;
85
+ };
86
+ }>;