@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
@@ -0,0 +1,438 @@
1
+ import fs from "node:fs";
2
+ import { access } from "node:fs/promises";
3
+ import { join } from "node:path";
4
+ import { defineCommand } from "citty";
5
+ import * as p from "@clack/prompts";
6
+ import git from "isomorphic-git";
7
+ import { CLI_VERSION } from "../core/constants.js";
8
+ import { runPrompts, collectSettingsErrors, printIntro, } from "../interactive/prompts.js";
9
+ import { withHint } from "../interactive/format.js";
10
+ import { createGitAssetProvider } from "../asset/git-provider.js";
11
+ import { buildRenderedPlan, collectFileStates, classifyAll, applyUpdateActions, buildUpdatedRecords, } from "../asset/updater.js";
12
+ import { mergeFile } from "../utils/merge-file.js";
13
+ import { runInstallBuild } from "../asset/installer.js";
14
+ import { readSettingsSafe, readHashsum, writeSettings, writeHashsum, } from "../utils/settings-io.js";
15
+ import { getMessage } from "../i18n/index.js";
16
+ import { detectLocale } from "../utils/locale-detect.js";
17
+ import { printSummary } from "../interactive/summary.js";
18
+ import { buildProgressCallbacks } from "../interactive/progress.js";
19
+ const shortSha = (sha) => sha.slice(0, 7);
20
+ const confirmDirtyWorktree = async (projectDir, locale, isInteractive) => {
21
+ try {
22
+ await access(join(projectDir, ".git"));
23
+ const matrix = await git.statusMatrix({ fs, dir: projectDir });
24
+ const isClean = matrix.every(([, head, workdir, stage]) => head === 1 && workdir === 1 && stage === 1);
25
+ if (isClean)
26
+ return true;
27
+ }
28
+ catch {
29
+ return true;
30
+ }
31
+ p.log.warning(getMessage("update.warning.dirty", locale));
32
+ if (!isInteractive)
33
+ return true;
34
+ const cont = await p.confirm({
35
+ message: getMessage("update.confirmDirty", locale),
36
+ });
37
+ return !p.isCancel(cont) && cont === true;
38
+ };
39
+ const resolveFallbackMode = async (opts) => {
40
+ const { baseError, editedCount, commit, locale } = opts;
41
+ const baseFetchMessage = getMessage("update.error.baseFetch", locale, {
42
+ commit,
43
+ message: baseError instanceof Error ? baseError.message : String(baseError),
44
+ });
45
+ if (opts.allowMissingBase) {
46
+ p.log.warning(baseFetchMessage);
47
+ p.log.warning(getMessage("update.fallback.continuing", locale));
48
+ return { keepEdited: opts.keepEditedFlag };
49
+ }
50
+ if (!opts.isInteractive) {
51
+ p.log.error(`${baseFetchMessage}\n${getMessage("update.error.baseFetchHint", locale)}`);
52
+ process.exit(1);
53
+ }
54
+ p.log.warning(baseFetchMessage);
55
+ p.log.warning(getMessage("update.fallback.editedCount", locale, {
56
+ count: String(editedCount),
57
+ }));
58
+ const choice = await p.select({
59
+ message: getMessage("update.fallback.choice", locale),
60
+ options: [
61
+ { value: "abort", label: getMessage("update.fallback.choice.abort", locale) },
62
+ {
63
+ value: "conflict",
64
+ label: getMessage("update.fallback.choice.conflict", locale),
65
+ },
66
+ { value: "keep", label: getMessage("update.fallback.choice.keep", locale) },
67
+ ],
68
+ });
69
+ if (p.isCancel(choice) || choice === "abort") {
70
+ p.log.info(getMessage("update.fallback.aborted", locale));
71
+ process.exit(1);
72
+ }
73
+ return { keepEdited: choice === "keep" };
74
+ };
75
+ const resolveInteractiveSettings = async (promptOpts, cliOnlyOpts, releaseIdFallback) => {
76
+ const locale = promptOpts.locale;
77
+ const cliErrors = collectSettingsErrors(cliOnlyOpts, locale, releaseIdFallback);
78
+ if (cliErrors.length > 0) {
79
+ throw new Error(cliErrors.join("\n"));
80
+ }
81
+ printIntro("update", locale);
82
+ const settingsErrors = collectSettingsErrors(promptOpts, locale);
83
+ if (settingsErrors.length > 0) {
84
+ p.log.warning(getMessage("update.invalidSettings", locale, {
85
+ errors: settingsErrors.map((e) => ` - ${e}`).join("\n"),
86
+ }));
87
+ return runPrompts({ ...promptOpts, skipIntro: true, skipValidation: true });
88
+ }
89
+ const useExisting = await p.confirm({
90
+ message: withHint("prompt.useExistingSettings", locale),
91
+ initialValue: true,
92
+ });
93
+ if (p.isCancel(useExisting))
94
+ process.exit(0);
95
+ return useExisting
96
+ ?
97
+ runPrompts({
98
+ ...promptOpts,
99
+ jugglingProject: cliOnlyOpts.jugglingProject,
100
+ noInteraction: true,
101
+ })
102
+ : runPrompts({ ...promptOpts, skipIntro: true });
103
+ };
104
+ const printResult = (summary, locale) => {
105
+ const lines = [
106
+ [summary.updated, "update.result.updated"],
107
+ [summary.merged, "update.result.merged"],
108
+ [summary.redeployed, "update.result.redeployed"],
109
+ [summary.redeployedWarn, "update.result.redeployedWarn"],
110
+ [summary.added, "update.result.added"],
111
+ [summary.adopted, "update.result.adopted"],
112
+ [summary.keptEdited, "update.result.kept"],
113
+ [summary.keptDeleted, "update.result.keptDeleted"],
114
+ [summary.skippedEdited, "update.result.skippedEdited"],
115
+ [summary.deleted, "update.result.deleted"],
116
+ [summary.warnings, "update.result.keptWarn"],
117
+ [summary.conflicts, "update.result.conflict"],
118
+ ];
119
+ for (const [paths, key] of lines) {
120
+ for (const path of paths) {
121
+ p.log.info(getMessage(key, locale, { path }));
122
+ }
123
+ }
124
+ const updatedCount = summary.updated.length +
125
+ summary.merged.length +
126
+ summary.redeployed.length +
127
+ summary.redeployedWarn.length +
128
+ summary.added.length +
129
+ summary.conflicts.length;
130
+ const keptCount = summary.keptEdited.length +
131
+ summary.keptDeleted.length +
132
+ summary.skippedEdited.length +
133
+ summary.warnings.length;
134
+ const deletedCount = summary.deleted.length;
135
+ if (updatedCount === 0 && deletedCount === 0 && summary.adopted.length === 0) {
136
+ p.log.success(getMessage("update.upToDate", locale));
137
+ }
138
+ else {
139
+ p.log.success(getMessage("update.complete", locale, {
140
+ updated: String(updatedCount),
141
+ kept: String(keptCount),
142
+ deleted: String(deletedCount),
143
+ }));
144
+ }
145
+ if (summary.conflicts.length > 0) {
146
+ const list = summary.conflicts.map((c) => ` - ${c}`).join("\n");
147
+ p.log.warning(`${getMessage("update.conflictSummary", locale, {
148
+ count: String(summary.conflicts.length),
149
+ })}\n${list}`);
150
+ }
151
+ if (summary.skippedEdited.length > 0) {
152
+ const list = summary.skippedEdited.map((c) => ` - ${c}`).join("\n");
153
+ p.log.warning(`${getMessage("update.fallback.skippedSummary", locale, {
154
+ count: String(summary.skippedEdited.length),
155
+ })}\n${list}`);
156
+ }
157
+ };
158
+ export const updateCommand = defineCommand({
159
+ meta: {
160
+ name: "update",
161
+ description: "Update deployed assets to the latest asset repository revision",
162
+ },
163
+ args: {
164
+ "juggling-project": {
165
+ type: "string",
166
+ description: "Path to IM-Juggling project",
167
+ },
168
+ "accelplatform-version": {
169
+ type: "string",
170
+ description: "iAP version (e.g., 2026-spring)",
171
+ },
172
+ module: {
173
+ type: "string",
174
+ description: "Modules to use (comma-separated artifactIds, e.g., im_workflow)",
175
+ },
176
+ feature: {
177
+ type: "string",
178
+ description: "Features to use (comma-separated function ids, e.g., jssp)",
179
+ },
180
+ name: {
181
+ type: "string",
182
+ description: "Project name",
183
+ },
184
+ group: {
185
+ type: "string",
186
+ description: "Group name",
187
+ },
188
+ "project-version": {
189
+ type: "string",
190
+ description: "Project version",
191
+ },
192
+ description: {
193
+ type: "string",
194
+ description: "Project description",
195
+ },
196
+ database: {
197
+ type: "string",
198
+ description: "Database type",
199
+ },
200
+ javascript: {
201
+ type: "boolean",
202
+ description: "Use JavaScript",
203
+ },
204
+ agent: {
205
+ type: "string",
206
+ description: "Agent type",
207
+ },
208
+ locale: {
209
+ type: "string",
210
+ description: "Locale (ja, en, zh_CN)",
211
+ },
212
+ "artifact-id": {
213
+ type: "string",
214
+ description: "Maven artifactId",
215
+ },
216
+ "package-manager": {
217
+ type: "string",
218
+ description: "Package manager (bun, npm, yarn, pnpm)",
219
+ },
220
+ "skip-install": {
221
+ type: "boolean",
222
+ description: "Skip dependency installation after the update",
223
+ default: false,
224
+ },
225
+ "non-interactive": {
226
+ type: "boolean",
227
+ description: "Non-interactive mode",
228
+ default: false,
229
+ },
230
+ "asset-server-url": {
231
+ type: "string",
232
+ description: "Git repository URL to fetch assets from (overrides the recorded assetSource)",
233
+ },
234
+ "asset-ref": {
235
+ type: "string",
236
+ description: "Git branch/tag to fetch from the asset repository (overrides the recorded assetSource)",
237
+ },
238
+ "allow-missing-base": {
239
+ type: "boolean",
240
+ description: "Continue in fallback mode when the recorded base commit cannot be fetched",
241
+ default: false,
242
+ },
243
+ "keep-edited": {
244
+ type: "boolean",
245
+ description: "In fallback mode, keep edited files and skip them instead of inserting conflict markers (requires --allow-missing-base)",
246
+ default: false,
247
+ },
248
+ },
249
+ run: async ({ args }) => {
250
+ const projectDir = process.cwd();
251
+ let locale = args.locale ?? detectLocale();
252
+ const settings = await readSettingsSafe(projectDir);
253
+ if (!settings) {
254
+ p.log.error(getMessage("error.accelNotFound", locale));
255
+ process.exit(1);
256
+ }
257
+ locale = args.locale ?? settings.locale ?? locale;
258
+ const allowMissingBase = args["allow-missing-base"];
259
+ const keepEditedFlag = args["keep-edited"];
260
+ if (keepEditedFlag && !allowMissingBase) {
261
+ p.log.error(getMessage("update.error.keepEditedWithoutAllow", locale));
262
+ process.exit(1);
263
+ }
264
+ const assetSource = settings.assetSource;
265
+ if (!assetSource) {
266
+ p.log.error(getMessage("update.error.legacyProject", locale));
267
+ process.exit(1);
268
+ }
269
+ if (assetSource.type !== "git" || !assetSource.commit || !assetSource.ref) {
270
+ p.log.error(getMessage("update.error.notGitSource", locale));
271
+ process.exit(1);
272
+ }
273
+ const source = {
274
+ ...assetSource,
275
+ commit: assetSource.commit,
276
+ ref: assetSource.ref,
277
+ };
278
+ const targetUrl = args["asset-server-url"] ?? source.url;
279
+ const targetRef = args["asset-ref"] ?? source.ref;
280
+ const isInteractive = !args["non-interactive"];
281
+ if (!(await confirmDirtyWorktree(projectDir, locale, isInteractive))) {
282
+ p.log.info(getMessage("update.cancelled", locale));
283
+ process.exit(0);
284
+ }
285
+ const cliOnlyOpts = {
286
+ name: args.name,
287
+ artifactId: args["artifact-id"],
288
+ jugglingProject: args["juggling-project"],
289
+ accelplatformVersion: args["accelplatform-version"],
290
+ module: args.module
291
+ ?.split(",")
292
+ .map((m) => m.trim()),
293
+ feature: args.feature
294
+ ?.split(",")
295
+ .map((f) => f.trim()),
296
+ group: args.group,
297
+ projectVersion: args["project-version"],
298
+ description: args.description,
299
+ database: args.database,
300
+ javascript: args.javascript,
301
+ agent: args.agent
302
+ ?.split(",")
303
+ .map((a) => a.trim()),
304
+ packageManager: args["package-manager"],
305
+ locale,
306
+ isInit: false,
307
+ };
308
+ const promptOpts = {
309
+ ...cliOnlyOpts,
310
+ name: cliOnlyOpts.name ?? settings.name,
311
+ artifactId: cliOnlyOpts.artifactId ?? settings.artifactId,
312
+ jugglingProject: isInteractive
313
+ ? (cliOnlyOpts.jugglingProject ?? settings.jugglingProject ?? undefined)
314
+ : cliOnlyOpts.jugglingProject,
315
+ accelplatformVersion: cliOnlyOpts.accelplatformVersion ?? settings.accelplatformVersion.label,
316
+ module: cliOnlyOpts.module ?? settings.modules,
317
+ feature: cliOnlyOpts.feature ?? settings.features ?? [],
318
+ group: cliOnlyOpts.group ?? settings.group,
319
+ projectVersion: cliOnlyOpts.projectVersion ?? settings.projectVersion,
320
+ description: cliOnlyOpts.description ?? settings.description,
321
+ database: cliOnlyOpts.database ?? settings.database,
322
+ javascript: cliOnlyOpts.javascript ?? settings.javascript,
323
+ agent: cliOnlyOpts.agent ?? settings.agents,
324
+ packageManager: cliOnlyOpts.packageManager ?? settings.packageManager,
325
+ noInteraction: args["non-interactive"],
326
+ mode: "update",
327
+ };
328
+ let resolved;
329
+ try {
330
+ resolved = isInteractive
331
+ ? await resolveInteractiveSettings(promptOpts, cliOnlyOpts, settings.accelplatformVersion.label)
332
+ : await runPrompts(promptOpts);
333
+ }
334
+ catch (err) {
335
+ p.log.error(err instanceof Error ? err.message : String(err));
336
+ process.exit(1);
337
+ }
338
+ const newSettings = {
339
+ ...settings,
340
+ cliVersion: CLI_VERSION,
341
+ name: resolved.name,
342
+ artifactId: resolved.artifactId,
343
+ group: resolved.group,
344
+ projectVersion: resolved.projectVersion,
345
+ description: resolved.description,
346
+ accelplatformVersion: resolved.accelplatformVersion,
347
+ modules: resolved.modules,
348
+ features: resolved.features,
349
+ database: resolved.database,
350
+ agents: resolved.agents,
351
+ javascript: resolved.javascript,
352
+ locale: resolved.locale,
353
+ packageManager: resolved.packageManager,
354
+ jugglingProject: resolved.jugglingProject === undefined
355
+ ? settings.jugglingProject
356
+ : resolved.jugglingProject,
357
+ };
358
+ if (isInteractive) {
359
+ printSummary(newSettings, projectDir, locale);
360
+ const ok = await p.confirm({
361
+ message: getMessage("update.confirmApply", locale),
362
+ });
363
+ if (p.isCancel(ok) || ok !== true) {
364
+ p.log.info(getMessage("update.cancelled", locale));
365
+ process.exit(0);
366
+ }
367
+ }
368
+ const provider = createGitAssetProvider(targetUrl, targetRef, { locale });
369
+ try {
370
+ p.log.info(getMessage("progress.fetching", locale));
371
+ await provider.fetch();
372
+ const newCommit = provider.sourceInfo().commit;
373
+ if (!newCommit) {
374
+ throw new Error("Failed to resolve the fetched commit");
375
+ }
376
+ p.log.info(getMessage("update.progress.range", locale, {
377
+ from: shortSha(source.commit),
378
+ to: shortSha(newCommit),
379
+ }));
380
+ const theirsPlan = await buildRenderedPlan(provider.asTree(), newSettings, provider.materialize);
381
+ let baseTree = null;
382
+ let baseError = null;
383
+ try {
384
+ baseTree = await provider.openCommit(source.commit);
385
+ }
386
+ catch (err) {
387
+ baseError = err;
388
+ }
389
+ const oldHashsum = await readHashsum(projectDir);
390
+ let actions;
391
+ if (baseTree) {
392
+ const basePlan = await buildRenderedPlan(baseTree, settings, baseTree.materialize);
393
+ const states = await collectFileStates(projectDir, basePlan, theirsPlan, oldHashsum);
394
+ actions = await classifyAll(states, mergeFile);
395
+ }
396
+ else {
397
+ const states = await collectFileStates(projectDir, new Map(), theirsPlan, oldHashsum);
398
+ const preview = await classifyAll(states, mergeFile, {
399
+ keepEdited: true,
400
+ });
401
+ const editedCount = preview.filter((a) => a.outcome === "skipped-edited").length;
402
+ const { keepEdited } = await resolveFallbackMode({
403
+ baseError,
404
+ editedCount,
405
+ commit: source.commit,
406
+ locale,
407
+ isInteractive,
408
+ allowMissingBase,
409
+ keepEditedFlag,
410
+ });
411
+ actions = keepEdited
412
+ ? preview
413
+ : await classifyAll(states, mergeFile, { keepEdited: false });
414
+ }
415
+ const summary = await applyUpdateActions(projectDir, actions);
416
+ const { hashEntries, deployedAssets } = buildUpdatedRecords(oldHashsum, actions);
417
+ const updatedSettings = {
418
+ ...newSettings,
419
+ createdAt: settings.createdAt,
420
+ assetSource: { ...source, url: targetUrl, ref: targetRef, commit: newCommit },
421
+ deployedAssets,
422
+ };
423
+ await writeSettings(projectDir, updatedSettings);
424
+ await writeHashsum(projectDir, hashEntries);
425
+ if (summary.changedFileCount > 0 && !args["skip-install"]) {
426
+ runInstallBuild(projectDir, newSettings.packageManager, buildProgressCallbacks(locale));
427
+ }
428
+ printResult(summary, locale);
429
+ }
430
+ catch (err) {
431
+ p.log.error(err instanceof Error ? err.message : String(err));
432
+ process.exit(1);
433
+ }
434
+ finally {
435
+ await provider.cleanup().catch(() => { });
436
+ }
437
+ },
438
+ });
@@ -1,5 +1,5 @@
1
1
  import type { AccelSettings } from "./types.js";
2
- export declare const CLI_VERSION = "0.1.0";
2
+ export declare const CLI_VERSION: string;
3
3
  export declare const DATABASE_OPTIONS: readonly ["postgresql", "oracle", "sqlserver"];
4
4
  export type DatabaseOption = (typeof DATABASE_OPTIONS)[number];
5
5
  export declare const AGENT_OPTIONS: readonly ["claude-code", "codex", "github-copilot"];
@@ -9,5 +9,5 @@ export type LocaleOption = (typeof LOCALE_OPTIONS)[number];
9
9
  export declare const PACKAGE_MANAGER_OPTIONS: readonly ["bun", "npm", "yarn", "pnpm"];
10
10
  export type PackageManagerOption = (typeof PACKAGE_MANAGER_OPTIONS)[number];
11
11
  export declare const DEFAULT_ASSET_REPO_URL = "https://github.com/accelplatform/skills";
12
- export declare const DEFAULT_ASSET_REF = "2026-07-01-release";
13
- export declare const DEFAULT_SETTINGS: Omit<AccelSettings, "cliVersion" | "createdAt" | "deployedAssets">;
12
+ export declare const DEFAULT_ASSET_REF = "experiment";
13
+ export declare const DEFAULT_SETTINGS: Omit<AccelSettings, "cliVersion" | "createdAt" | "deployedAssets" | "assetSource">;
@@ -1,4 +1,6 @@
1
- export const CLI_VERSION = "0.1.0";
1
+ import { createRequire } from "node:module";
2
+ const pkg = createRequire(import.meta.url)("../../package.json");
3
+ export const CLI_VERSION = pkg.version;
2
4
  export const DATABASE_OPTIONS = ["postgresql", "oracle", "sqlserver"];
3
5
  export const AGENT_OPTIONS = ["claude-code", "codex", "github-copilot"];
4
6
  export const LOCALE_OPTIONS = ["ja", "en", "zh_CN"];
@@ -9,7 +11,7 @@ export const PACKAGE_MANAGER_OPTIONS = [
9
11
  "pnpm",
10
12
  ];
11
13
  export const DEFAULT_ASSET_REPO_URL = "https://github.com/accelplatform/skills";
12
- export const DEFAULT_ASSET_REF = "2026-07-01-release";
14
+ export const DEFAULT_ASSET_REF = "experiment";
13
15
  export const DEFAULT_SETTINGS = {
14
16
  name: "my-accel-project",
15
17
  artifactId: "",
@@ -101,6 +101,7 @@ export type AccelSettings = {
101
101
  locale: string;
102
102
  packageManager: string;
103
103
  jugglingProject: string | null;
104
+ assetSource?: AssetSourceInfo;
104
105
  deployedAssets: Record<string, string>;
105
106
  };
106
107
  export type HashsumEntry = {
@@ -108,9 +109,19 @@ export type HashsumEntry = {
108
109
  version: string;
109
110
  sha1: string;
110
111
  };
112
+ export type AssetSourceInfo = {
113
+ type: "git" | "directory";
114
+ url: string;
115
+ ref: string | null;
116
+ commit: string | null;
117
+ };
111
118
  export type AssetProvider = {
112
119
  fetch: () => Promise<string>;
120
+ listFiles: () => Promise<string[]>;
121
+ materialize: (dirs: string[]) => Promise<void>;
122
+ readFile: (relPath: string) => Promise<string>;
113
123
  cleanup: () => Promise<void>;
124
+ sourceInfo: () => AssetSourceInfo;
114
125
  };
115
126
  export type EvalContext = {
116
127
  accelplatformVersion: AccelplatformVersion;
@@ -5,12 +5,16 @@ export declare const makeDeployError: (kind: DeployError["kind"], extra?: {
5
5
  serverMessage?: string;
6
6
  }) => DeployError;
7
7
  export declare const isDeployError: (e: unknown) => e is DeployError;
8
+ export type DeployArchive = {
9
+ bytes: Uint8Array;
10
+ fileName: string;
11
+ };
8
12
  export type ApiClient = {
9
13
  verifyToken: () => Promise<void>;
10
14
  listStagings: () => Promise<StagingResponse[]>;
11
- createDeployment: (stagingId: string, bytes: Uint8Array, immFileName: string, description?: string) => Promise<DeploymentCreateResponse>;
15
+ createDeployment: (stagingId: string, archives: DeployArchive[], description?: string) => Promise<DeploymentCreateResponse>;
12
16
  executeSetup: (stagingId: string) => Promise<SetupExecuteResponse>;
13
- executeSetupConfig: (stagingId: string, configNumber: number) => Promise<SetupExecuteResponse>;
17
+ executeSetupConfig: (stagingId: string, moduleId: string, configNumber: number) => Promise<SetupExecuteResponse>;
14
18
  };
15
19
  export declare const createApiClient: (endpoint: string, apiKey: string, deps?: {
16
20
  fetch?: FetchFn;
@@ -88,9 +88,13 @@ export const createApiClient = (endpoint, apiKey, deps = {}) => {
88
88
  }
89
89
  return records;
90
90
  };
91
- const createDeployment = async (stagingId, bytes, immFileName, description) => {
91
+ const createDeployment = async (stagingId, archives, description) => {
92
92
  const form = new FormData();
93
- form.append("archiveFile", new File([bytes], immFileName, { type: "application/zip" }));
93
+ for (const archive of archives) {
94
+ form.append("archiveFile", new File([archive.bytes], archive.fileName, {
95
+ type: "application/zip",
96
+ }));
97
+ }
94
98
  if (description && description.length > 0) {
95
99
  form.append("description", description);
96
100
  }
@@ -109,8 +113,8 @@ export const createApiClient = (endpoint, apiKey, deps = {}) => {
109
113
  body: JSON.stringify({}),
110
114
  });
111
115
  };
112
- const executeSetupConfig = async (stagingId, configNumber) => {
113
- const url = `${endpoint}${STAGING_PATH}/${encodeURIComponent(stagingId)}/setup/configs/${configNumber}/execute`;
116
+ const executeSetupConfig = async (stagingId, moduleId, configNumber) => {
117
+ const url = `${endpoint}${STAGING_PATH}/${encodeURIComponent(stagingId)}/setup/configs/${encodeURIComponent(moduleId)}/${configNumber}/execute`;
114
118
  return request(url, {
115
119
  method: "POST",
116
120
  headers: { ...baseHeaders, "Content-Type": "application/json" },
@@ -0,0 +1,20 @@
1
+ export declare const toImmFileName: (zipPath: string) => string;
2
+ export declare const sentAsName: (path: string) => string;
3
+ export type DeployFile = {
4
+ path: string;
5
+ display: string;
6
+ sentAs: string;
7
+ };
8
+ export type AdditionalFileError = {
9
+ kind: "notFound" | "invalidExtension" | "duplicate";
10
+ path: string;
11
+ };
12
+ export type ValidateAdditionalFilesResult = {
13
+ ok: true;
14
+ paths: string[];
15
+ } | {
16
+ ok: false;
17
+ error: AdditionalFileError;
18
+ };
19
+ export declare const validateAdditionalFiles: (projectDir: string, args: string[], mainPath: string) => Promise<ValidateAdditionalFilesResult>;
20
+ export declare const buildDeployFiles: (additionalPaths: string[], mainPath: string, projectDir: string) => DeployFile[];
@@ -0,0 +1,37 @@
1
+ import { stat } from "node:fs/promises";
2
+ import { basename, extname, relative, resolve } from "node:path";
3
+ export const toImmFileName = (zipPath) => {
4
+ const base = basename(zipPath);
5
+ return base.replace(/\.zip$/i, "") + ".imm";
6
+ };
7
+ export const sentAsName = (path) => /\.zip$/i.test(path) ? toImmFileName(path) : basename(path);
8
+ const ALLOWED_EXTENSIONS = new Set([".imm", ".zip"]);
9
+ export const validateAdditionalFiles = async (projectDir, args, mainPath) => {
10
+ const seen = new Set([resolve(projectDir, mainPath)]);
11
+ const paths = [];
12
+ for (const arg of args) {
13
+ const path = resolve(projectDir, arg);
14
+ try {
15
+ const s = await stat(path);
16
+ if (!s.isFile())
17
+ throw new Error("not a file");
18
+ }
19
+ catch {
20
+ return { ok: false, error: { kind: "notFound", path: arg } };
21
+ }
22
+ if (!ALLOWED_EXTENSIONS.has(extname(path).toLowerCase())) {
23
+ return { ok: false, error: { kind: "invalidExtension", path: arg } };
24
+ }
25
+ if (seen.has(path)) {
26
+ return { ok: false, error: { kind: "duplicate", path: arg } };
27
+ }
28
+ seen.add(path);
29
+ paths.push(path);
30
+ }
31
+ return { ok: true, paths };
32
+ };
33
+ export const buildDeployFiles = (additionalPaths, mainPath, projectDir) => [...additionalPaths, mainPath].map((path) => ({
34
+ path,
35
+ display: relative(projectDir, path),
36
+ sentAs: sentAsName(path),
37
+ }));
@@ -0,0 +1,6 @@
1
+ export declare const createGitAuthError: (status: number, url: string) => Error;
2
+ export declare const isGitAuthError: (err: unknown) => err is Error;
3
+ export declare const createGitObjectMissingError: (filepath: string, oid: string) => Error;
4
+ export declare const isGitObjectMissingError: (err: unknown) => err is Error;
5
+ export declare const createGitServerUnsupportedError: (url: string, missing: string) => Error;
6
+ export declare const isGitServerUnsupportedError: (err: unknown) => err is Error;
@@ -0,0 +1,9 @@
1
+ const GIT_AUTH_ERROR = "GitAuthError";
2
+ const GIT_SERVER_UNSUPPORTED_ERROR = "GitServerUnsupportedError";
3
+ export const createGitAuthError = (status, url) => Object.assign(new Error(`Authentication required (HTTP ${status}) for ${url}`), { name: GIT_AUTH_ERROR });
4
+ export const isGitAuthError = (err) => err instanceof Error && err.name === GIT_AUTH_ERROR;
5
+ const GIT_OBJECT_MISSING_ERROR = "GitObjectMissingError";
6
+ export const createGitObjectMissingError = (filepath, oid) => Object.assign(new Error(`Object ${oid} for ${filepath} has not been fetched`), { name: GIT_OBJECT_MISSING_ERROR });
7
+ export const isGitObjectMissingError = (err) => err instanceof Error && err.name === GIT_OBJECT_MISSING_ERROR;
8
+ export const createGitServerUnsupportedError = (url, missing) => Object.assign(new Error(`Server does not support required git feature (${missing}): ${url}`), { name: GIT_SERVER_UNSUPPORTED_ERROR });
9
+ export const isGitServerUnsupportedError = (err) => err instanceof Error && err.name === GIT_SERVER_UNSUPPORTED_ERROR;
@@ -0,0 +1,3 @@
1
+ export declare const normalizeRepoUrl: (url: string) => string;
2
+ export declare const getInfoRefs: (repoUrl: string) => Promise<Buffer>;
3
+ export declare const postUploadPack: (repoUrl: string, body: Buffer) => Promise<Buffer>;