@intra-mart/accel 0.5.0-dev.202608030656 → 0.5.0-next.202608061256

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 (79) hide show
  1. package/README.md +70 -1
  2. package/dist/asset/deployer.d.ts +1 -0
  3. package/dist/asset/deployer.js +7 -1
  4. package/dist/asset/git-provider.d.ts +1 -0
  5. package/dist/asset/git-provider.js +9 -5
  6. package/dist/asset/updater.d.ts +7 -1
  7. package/dist/asset/updater.js +3 -1
  8. package/dist/commands/asset-provider.d.ts +1 -1
  9. package/dist/commands/asset-provider.js +2 -2
  10. package/dist/commands/attach.js +11 -19
  11. package/dist/commands/cache.js +11 -16
  12. package/dist/commands/deploy.d.ts +3 -0
  13. package/dist/commands/deploy.js +83 -58
  14. package/dist/commands/detach.js +4 -4
  15. package/dist/commands/init.d.ts +32 -0
  16. package/dist/commands/init.js +117 -98
  17. package/dist/commands/login.d.ts +2 -0
  18. package/dist/commands/login.js +16 -9
  19. package/dist/commands/preset.d.ts +31 -0
  20. package/dist/commands/preset.js +389 -0
  21. package/dist/commands/run-wrapper.d.ts +1 -0
  22. package/dist/commands/run-wrapper.js +16 -0
  23. package/dist/commands/switch.d.ts +30 -0
  24. package/dist/commands/switch.js +195 -119
  25. package/dist/commands/update.d.ts +57 -0
  26. package/dist/commands/update.js +351 -248
  27. package/dist/core/constants.d.ts +0 -1
  28. package/dist/core/constants.js +0 -3
  29. package/dist/core/errors.d.ts +6 -0
  30. package/dist/core/errors.js +16 -0
  31. package/dist/core/logger.d.ts +15 -0
  32. package/dist/core/logger.js +1 -0
  33. package/dist/core/paths.d.ts +6 -0
  34. package/dist/core/paths.js +22 -0
  35. package/dist/core/types.d.ts +8 -0
  36. package/dist/core/validation.d.ts +34 -0
  37. package/dist/core/validation.js +87 -0
  38. package/dist/core/validators.d.ts +2 -0
  39. package/dist/core/validators.js +7 -0
  40. package/dist/deploy/api-client.d.ts +1 -0
  41. package/dist/deploy/api-client.js +7 -1
  42. package/dist/git/http.d.ts +2 -2
  43. package/dist/git/http.js +11 -6
  44. package/dist/git/smart-http.d.ts +3 -2
  45. package/dist/git/smart-http.js +5 -5
  46. package/dist/i18n/en.js +35 -0
  47. package/dist/i18n/ja.js +35 -0
  48. package/dist/i18n/zh_CN.js +35 -0
  49. package/dist/index.js +4 -2
  50. package/dist/interactive/asset-messages.d.ts +2 -1
  51. package/dist/interactive/asset-messages.js +4 -4
  52. package/dist/interactive/clack-logger.d.ts +2 -0
  53. package/dist/interactive/clack-logger.js +11 -0
  54. package/dist/interactive/credential-auth.d.ts +2 -0
  55. package/dist/interactive/credential-auth.js +7 -6
  56. package/dist/interactive/credentials-prompts.js +8 -5
  57. package/dist/interactive/next-steps.d.ts +2 -1
  58. package/dist/interactive/next-steps.js +3 -3
  59. package/dist/interactive/progress.d.ts +2 -1
  60. package/dist/interactive/progress.js +8 -8
  61. package/dist/interactive/prompts.d.ts +3 -33
  62. package/dist/interactive/prompts.js +23 -111
  63. package/dist/interactive/summary.d.ts +2 -1
  64. package/dist/interactive/summary.js +3 -3
  65. package/dist/juggling/resolve.d.ts +7 -0
  66. package/dist/juggling/resolve.js +18 -0
  67. package/dist/lib.d.ts +24 -0
  68. package/dist/lib.js +20 -0
  69. package/dist/utils/args.d.ts +1 -0
  70. package/dist/utils/args.js +1 -0
  71. package/dist/utils/githooks-sync.d.ts +3 -1
  72. package/dist/utils/githooks-sync.js +6 -8
  73. package/dist/utils/mcp-sync.d.ts +3 -1
  74. package/dist/utils/mcp-sync.js +2 -2
  75. package/dist/utils/preset-io.d.ts +23 -0
  76. package/dist/utils/preset-io.js +164 -0
  77. package/dist/utils/settings-io.d.ts +1 -0
  78. package/dist/utils/settings-io.js +1 -1
  79. package/package.json +8 -1
package/README.md CHANGED
@@ -122,7 +122,9 @@ accel update
122
122
 
123
123
  - ユーザーが編集したファイルの内容は保持されます。編集箇所と資材の更新が重なった場合はコンフリクトマーカー(git と同じ `<<<<<<<` 形式)が挿入されるので、該当ファイルを手動で解決してください。コンフリクトの発生は正常終了扱いで、終了時に対象ファイルの一覧が表示されます。
124
124
  - 対話モードでは、最初に**既存の設定を利用するか**を確認します(デフォルト: Yes)。利用する場合は各設定の再入力をスキップし、現在の設定(CLIオプションの指定があればその値で上書き)のまま更新に進みます。再入力を選んだ場合は、iAPバージョン・モジュール・機能・エージェントなどの設定を**現在値を初期値として**変更できます。
125
+ - プリセット(後述「[`accel preset`](#accel-preset)」)が登録されている場合は、「既存の設定を利用 / プリセット○○を利用 / 設定を再入力」の選択になります。プリセットを選ぶと、モジュール・機能・エージェントがプリセットの内容に切り替わった状態で更新に進みます(`--preset` 指定時は設定確定済みのため、この確認をスキップして事前サマリーと適用確認に直行します)。
125
126
  - 既存の設定に不正な値やカタログとの不整合がある場合は、対象の項目と理由を通知した上で再入力になります(確認はスキップ)。
127
+ - `--preset` でプリセットを指定すると、モジュール・機能・エージェントをプリセットの内容に一括で変更できます。`--module` / `--feature` / `--agent` との同時指定はエラーになります。
126
128
  - 非対話モードでは `init` と同じオプションで変更を指定でき、未指定の項目は現在の設定を維持します。
127
129
  - IM-Juggling プロジェクトとの連携は、設定の再入力時に IM-Juggling プロジェクトのプロンプトを空にして確定するか、`--juggling-project ""`(空文字)を指定すると解除できます。
128
130
  - `--asset-server-url` / `--asset-ref` で取得元のリポジトリ・ブランチを変更できます(リポジトリの移転やブランチ再編への追従)。変更した取得元は記録され、以降の update の既定になります。
@@ -144,6 +146,7 @@ accel update --non-interactive --module im_workflow,im_activiti
144
146
 
145
147
  | オプション | 型 | 説明 | デフォルト |
146
148
  |---|---|---|---|
149
+ | `--preset` | string | 適用するプリセット名(後述「[`accel preset`](#accel-preset)」)。モジュール・機能・エージェントをプリセットの内容に変更する。`--module` / `--feature` / `--agent` とは同時指定不可 | - |
147
150
  | `--non-interactive` | boolean | 非対話モード | `false` |
148
151
  | `--skip-install` | boolean | 更新後の install / build をスキップ | `false` |
149
152
  | `--asset-server-url` | string | 資材を取得するgitリポジトリのURL(HTTP(S) のみ)を変更する。変更は記録され、以降の既定になる | 記録済みのURL |
@@ -168,12 +171,20 @@ accel switch --feature jssp
168
171
  - **ユーザーが編集したファイルには一切触れません**。切り替えで上書き・削除の対象になった編集済みファイルはそのまま保持してスキップし、終了時に「切り替えが適用されていないファイル」として一覧表示します。`update` と異なり、コンフリクトマーカーの挿入は行いません。
169
172
  - 未編集のファイルは新しい構成の内容で上書きされ、新構成で不要になった資材は削除、新たに必要になった資材は追加されます。
170
173
  - install / build は変更されたファイルに `package.json` またはロックファイル(`bun.lock` 等)が含まれる場合のみ実行します。skills などの切り替えだけであれば実行されず、すぐに完了します。スキップされた編集済みファイルがある状態で install / build が失敗した場合は、スキップしたファイルが原因の可能性がある旨をあわせて表示します。
171
- - 対話モードでは、モジュール・機能・エージェントを現在の設定を初期値として選択し直せます。
174
+ - 対話モードでは、モジュール・機能・エージェントを現在の設定を初期値として選択し直せます。プリセット(後述「[`accel preset`](#accel-preset)」)が登録されている場合は、最初にプリセットを利用するかの選択肢が表示され、プリセットを選ぶと3項目の選択をスキップしてプリセットの内容に切り替わります(`--module` / `--feature` / `--agent` / `--preset` のいずれかを指定した場合は、この選択肢は表示されません)。
175
+ - `--preset` でプリセットを指定して切り替えることもできます(`--module` / `--feature` / `--agent` との同時指定はエラー)。対話モードでも 3 項目の選択はスキップされ、適用確認に直行します。
176
+
177
+ ```bash
178
+ accel switch --preset server-side
179
+ ```
172
180
 
173
181
  #### 非対話モード
174
182
 
175
183
  ```bash
176
184
  accel switch --non-interactive --feature jssp --agent claude-code
185
+
186
+ # プリセットを使う場合
187
+ accel switch --non-interactive --preset server-side
177
188
  ```
178
189
 
179
190
  未指定の項目は現在の設定を維持します。
@@ -185,12 +196,69 @@ accel switch --non-interactive --feature jssp --agent claude-code
185
196
  | `--module` | string | 使用モジュール。カタログの `artifactId`(カンマ区切り) | 現在の設定を維持 |
186
197
  | `--feature` | string | 使用機能。カタログの機能ID(カンマ区切り) | 現在の設定を維持 |
187
198
  | `--agent` | string | エージェント種別(`claude-code`, `codex`, `github-copilot`、カンマ区切り) | 現在の設定を維持 |
199
+ | `--preset` | string | 適用するプリセット名(後述「[`accel preset`](#accel-preset)」)。3項目をプリセットの内容に変更する。`--module` / `--feature` / `--agent` とは同時指定不可 | - |
188
200
  | `--non-interactive` | boolean | 非対話モード | `false` |
189
201
  | `--skip-install` | boolean | 依存関係変更時の install / build をスキップ | `false` |
190
202
 
191
203
  - 切り替えられるのは上記の3項目のみです。iAPバージョンやロケールなど他の設定の変更は `accel update` で行います。
192
204
  - `update` と同様、git ソースから配備されたプロジェクトでのみ利用できます。
193
205
 
206
+ ### `accel preset`
207
+
208
+ モジュール・機能・エージェントの組み合わせを**構成プリセット**として登録・管理します。登録したプリセットは `accel update` / `accel switch` で利用できます。
209
+
210
+ ```bash
211
+ cd my-project
212
+ accel preset create
213
+ ```
214
+
215
+ 実際の開発では、「画面開発用」「サーバサイド開発用」「workflow用」のように、開発対象ごとに使用する skills 等の構成が決まっているケースが多いはずです。プロジェクトでよく使う構成をプリセットとして登録しておくと、チームメンバー全員が同じ構成を名前ひとつで切り替えられるようになります。
216
+
217
+ - プリセットは `.accel/presets/<プリセット名>.json` に1プリセット1ファイルで保存されます。**git 管理対象**なので、コミットすればチームメンバーに共有されます。
218
+ - プリセットの内容は module / feature / agent の3項目(+表示名・説明)です。3項目すべてを保存します。
219
+ - `init` / `attach` 済みのプロジェクト内で実行してください(`.accel` が無い場合はエラー)。`accel detach` は `.accel/` ごと削除するため、プリセットも一緒に削除されます。
220
+ - プリセット名(ID)に使える文字は英数字と `-` `_` のみです。ファイル名や `--preset` での指定に使われます。
221
+ - 日本語などの名前を付けたい場合は**表示名**を設定してください。一覧や選択肢では「表示名 (プリセット名)」の形式で表示されます(表示名が未設定なら プリセット名のみ)。
222
+ - 適用時(`update` / `switch`)には、プリセットの内容が適用時点のiAPバージョン(`update` で `--accelplatform-version` を指定した場合は変更後のバージョン)のカタログに対して検証されます。バージョン変更などでプリセット内のモジュール・機能が存在しなくなった場合はエラーになります。
223
+
224
+ #### `accel preset create [name]`
225
+
226
+ プリセットを対話形式で作成します。名前(ID)・表示名・説明を入力し、モジュール・機能・エージェントを選択して保存します。保存後に続けて次のプリセットを作成できるため、プロジェクト作成直後に複数のプリセットをまとめて登録できます。
227
+
228
+ ```bash
229
+ # 非対話モード(3項目すべての指定が必須)
230
+ accel preset create server-side \
231
+ --non-interactive \
232
+ --module im_workflow \
233
+ --feature jssp \
234
+ --agent claude-code \
235
+ --label "サーバサイド開発用"
236
+ ```
237
+
238
+ | オプション | 型 | 説明 | デフォルト |
239
+ |---|---|---|---|
240
+ | `[name]`(位置引数) | string | プリセット名(ID。英数字と `-` `_` のみ。**非対話モードでは必須**) | 対話で入力 |
241
+ | `--label` | string | 表示名。日本語なども使用可。`preset list` や選択肢に表示される | `""`(プリセット名を表示) |
242
+ | `--description` | string | プリセットの説明。`preset list` や選択肢に表示される | `""` |
243
+ | `--module` | string | 使用モジュール。カタログの `artifactId`(カンマ区切り。**非対話モードでは必須**) | 対話で選択 |
244
+ | `--feature` | string | 使用機能。カタログの機能ID(カンマ区切り。**非対話モードでは必須**。`""` で機能なし) | 対話で選択 |
245
+ | `--agent` | string | エージェント種別(`claude-code`, `codex`, `github-copilot`、カンマ区切り。**非対話モードでは必須**) | 対話で選択 |
246
+ | `--force` | boolean | 同名プリセットが存在する場合に確認なしで上書きする | `false`(対話で確認 / 非対話ではエラー) |
247
+ | `--locale` | string | ロケール(`ja`, `en`, `zh_CN`) | `settings.json` の記録値 |
248
+ | `--non-interactive` | boolean | 非対話モード | `false` |
249
+
250
+ #### `accel preset list`
251
+
252
+ 登録済みプリセットの一覧(名前と説明)を表示します。
253
+
254
+ #### `accel preset show <name>`
255
+
256
+ 指定したプリセットの内容(表示名・説明・モジュール・機能・エージェント)を表示します。名前(ID)で指定します。
257
+
258
+ #### `accel preset delete <name>`
259
+
260
+ 指定したプリセットを削除します。名前(ID)で指定します。対話モードでは削除前に確認します。
261
+
194
262
  ### `accel cache`
195
263
 
196
264
  資材キャッシュを管理します。
@@ -444,6 +512,7 @@ my-project/
444
512
  - `.accel/settings.json` — プロジェクト設定。git管理対象、手動編集可。資材リポジトリのURL・ref・配備時のコミットSHA(`assetSource`)を記録し、`accel update` / `accel switch` が参照
445
513
  - `.accel/hashsum.txt` — 配備ファイルのハッシュ。`update` / `switch` / `detach` 時のユーザー編集検出に使用
446
514
  - `.accel/credentials.json` — iAP接続情報(endpoint / APIキー)。`accel deploy` 初回実行時に生成。APIキーを含むため `.gitignore` 対象(git管理対象外)
515
+ - `.accel/presets/` — 構成プリセット(1プリセット1ファイル)。`accel preset create` で生成。チーム共有のため git 管理対象(詳細は「[`accel preset`](#accel-preset)」)
447
516
  - `.githooks/` — APIキーの誤コミットを防ぐ pre-commit フック。`accel login` / `accel deploy` による接続情報の保存時に配置(詳細は「[pre-commit フックの自動配置](#pre-commit-フックの自動配置)」)
448
517
 
449
518
  `credentials.json` の保存/更新時には、エージェント別の MCP 設定ファイル(`.mcp.json` / `.codex/config.toml` / `.vscode/mcp.json` のうち、存在し、かつ `agents` に含まれるエージェントのもの)に対しても API キーが反映されます。詳細は「[MCP 設定の自動同期](#mcp-設定の自動同期)」を参照してください。
@@ -19,6 +19,7 @@ export type DeployOptions = {
19
19
  skipExistingFiles?: boolean;
20
20
  onExistingFile?: ExistingFileHandler;
21
21
  progress?: ProgressCallbacks;
22
+ signal?: AbortSignal;
22
23
  };
23
24
  export type DeployResult = {
24
25
  deployedFiles: string[];
@@ -1,6 +1,7 @@
1
1
  import { writeFile, mkdir, stat } from "node:fs/promises";
2
2
  import { join, dirname, resolve, sep } from "node:path";
3
3
  import { buildEvalContext } from "../core/eval-context.js";
4
+ import { normalizeAbort } from "../core/errors.js";
4
5
  import { walkAssetRepo } from "./walker.js";
5
6
  import { createMessageCollector } from "./messages.js";
6
7
  import { renderAssetContent } from "./renderer.js";
@@ -55,7 +56,7 @@ const groupSections = (entries) => {
55
56
  return [...groups.values()];
56
57
  };
57
58
  export const deployAssets = async (options) => {
58
- const { projectDir, settings, provider, noInstall, skipExistingFiles, onExistingFile, progress, } = options;
59
+ const { projectDir, settings, provider, noInstall, skipExistingFiles, onExistingFile, progress, signal, } = options;
59
60
  try {
60
61
  progress?.onFetchStart?.();
61
62
  const repoDir = await provider.fetch();
@@ -79,6 +80,7 @@ export const deployAssets = async (options) => {
79
80
  }
80
81
  return true;
81
82
  });
83
+ signal?.throwIfAborted();
82
84
  progress?.onDownloadStart?.();
83
85
  await provider.materialize([
84
86
  ...new Set(entries.map((e) => e.sourceRelPath)),
@@ -110,6 +112,7 @@ export const deployAssets = async (options) => {
110
112
  }
111
113
  toDeploy.push(entry);
112
114
  }
115
+ signal?.throwIfAborted();
113
116
  const hashEntries = await mapWithConcurrency(toDeploy, FS_CONCURRENCY, async (entry) => {
114
117
  const targetPath = entry.relativePath;
115
118
  const destPath = join(projectDir, targetPath);
@@ -144,6 +147,9 @@ export const deployAssets = async (options) => {
144
147
  }
145
148
  return { deployedFiles, hashEntries, skippedFiles, overwrittenFiles };
146
149
  }
150
+ catch (err) {
151
+ throw normalizeAbort(err, signal);
152
+ }
147
153
  finally {
148
154
  await provider.cleanup().catch(() => { });
149
155
  }
@@ -11,5 +11,6 @@ export type GitAssetProvider = AssetProvider & {
11
11
  };
12
12
  export type GitAssetProviderOptions = {
13
13
  locale?: string;
14
+ signal?: AbortSignal;
14
15
  };
15
16
  export declare const createGitAssetProvider: (repoUrl: string, ref: string, options?: GitAssetProviderOptions) => GitAssetProvider;
@@ -1,3 +1,4 @@
1
+ import { isAbortError } from "../core/errors.js";
1
2
  import { getMessage } from "../i18n/index.js";
2
3
  import { isGitAuthError, isGitObjectMissingError, isGitServerUnsupportedError, } from "../git/errors.js";
3
4
  import { createObjectStore, } from "../git/object-store.js";
@@ -15,7 +16,7 @@ const isHttpUrl = (url) => {
15
16
  }
16
17
  };
17
18
  export const createGitAssetProvider = (repoUrl, ref, options = {}) => {
18
- const { locale = "en" } = options;
19
+ const { locale = "en", signal } = options;
19
20
  let store = null;
20
21
  let commit = null;
21
22
  const withHint = (message, cause) => {
@@ -62,7 +63,7 @@ export const createGitAssetProvider = (repoUrl, ref, options = {}) => {
62
63
  missing.push(oid);
63
64
  }
64
65
  for (let i = 0; i < missing.length; i += MAX_WANTS_PER_REQUEST) {
65
- const pack = await fetchPack(repoUrl, missing.slice(i, i + MAX_WANTS_PER_REQUEST));
66
+ const pack = await fetchPack(repoUrl, missing.slice(i, i + MAX_WANTS_PER_REQUEST), { signal });
66
67
  await store.writePack(pack, "blobs");
67
68
  }
68
69
  };
@@ -110,15 +111,18 @@ export const createGitAssetProvider = (repoUrl, ref, options = {}) => {
110
111
  const pack = await fetchPack(repoUrl, [oid], {
111
112
  deepenOne: true,
112
113
  filterBlobNone: true,
114
+ signal,
113
115
  });
114
116
  await store.writePack(pack, label);
115
117
  }
116
118
  await listRootFilesAt(oid);
117
119
  };
118
120
  const rethrowWithServerDiagnosis = async (original) => {
119
- if (!isGitAuthError(original)) {
121
+ if (!isGitAuthError(original) &&
122
+ !isAbortError(original) &&
123
+ signal?.aborted !== true) {
120
124
  try {
121
- assertServerSupported(repoUrl, await fetchCapabilities(repoUrl));
125
+ assertServerSupported(repoUrl, await fetchCapabilities(repoUrl, signal));
122
126
  }
123
127
  catch (diagErr) {
124
128
  if (isGitServerUnsupportedError(diagErr))
@@ -150,7 +154,7 @@ export const createGitAssetProvider = (repoUrl, ref, options = {}) => {
150
154
  const opened = await ensureStore();
151
155
  try {
152
156
  try {
153
- const resolved = await resolveRef(repoUrl, ref);
157
+ const resolved = await resolveRef(repoUrl, ref, signal);
154
158
  if (!resolved) {
155
159
  throw new Error(`ref not found on server: ${ref}`);
156
160
  }
@@ -35,6 +35,12 @@ export declare const classifySwitch: (states: FileState[]) => UpdateAction[];
35
35
  export declare const classifyAll: (states: FileState[], merge: MergeFn, fallback?: {
36
36
  keepEdited: boolean;
37
37
  }) => Promise<UpdateAction[]>;
38
+ export type UpdaterProgressCallbacks = {
39
+ onRenderStart?: (side: "theirs" | "base") => void;
40
+ onClassifyStart?: (fileCount: number) => void;
41
+ onApplyStart?: (changeCount: number) => void;
42
+ onFileApplied?: (relativePath: string, outcome: UpdateAction["outcome"]) => void;
43
+ };
38
44
  export type UpdateSummary = {
39
45
  updated: string[];
40
46
  merged: string[];
@@ -51,7 +57,7 @@ export type UpdateSummary = {
51
57
  skippedSwitch: string[];
52
58
  changedFileCount: number;
53
59
  };
54
- export declare const applyUpdateActions: (projectDir: string, actions: UpdateAction[]) => Promise<UpdateSummary>;
60
+ export declare const applyUpdateActions: (projectDir: string, actions: UpdateAction[], progress?: UpdaterProgressCallbacks) => Promise<UpdateSummary>;
55
61
  export declare const buildUpdatedRecords: (oldEntries: HashsumEntry[], actions: UpdateAction[]) => {
56
62
  hashEntries: HashsumEntry[];
57
63
  deployedAssets: Record<string, string>;
@@ -296,7 +296,8 @@ export const classifyAll = async (states, merge, fallback) => {
296
296
  }
297
297
  return actions;
298
298
  };
299
- export const applyUpdateActions = async (projectDir, actions) => {
299
+ export const applyUpdateActions = async (projectDir, actions, progress) => {
300
+ progress?.onApplyStart?.(actions.filter((a) => a.op !== "none").length);
300
301
  const summary = {
301
302
  updated: [],
302
303
  merged: [],
@@ -324,6 +325,7 @@ export const applyUpdateActions = async (projectDir, actions) => {
324
325
  for (const action of actions) {
325
326
  if (action.op !== "none") {
326
327
  summary.changedFileCount++;
328
+ progress?.onFileApplied?.(action.relativePath, action.outcome);
327
329
  }
328
330
  switch (action.outcome) {
329
331
  case "updated":
@@ -4,4 +4,4 @@ export type AssetProviderArgs = {
4
4
  assetServerUrl?: string;
5
5
  assetRef?: string;
6
6
  };
7
- export declare const selectAssetProvider: (args: AssetProviderArgs, locale: string) => Promise<AssetProvider>;
7
+ export declare const selectAssetProvider: (args: AssetProviderArgs, locale: string, signal?: AbortSignal) => Promise<AssetProvider>;
@@ -1,9 +1,9 @@
1
1
  import { DEFAULT_ASSET_REPO_URL, DEFAULT_ASSET_REF, } from "../core/constants.js";
2
2
  import { createFileAssetProvider } from "../asset/file-provider.js";
3
3
  import { createGitAssetProvider } from "../asset/git-provider.js";
4
- export const selectAssetProvider = async (args, locale) => {
4
+ export const selectAssetProvider = async (args, locale, signal) => {
5
5
  if (args.assetSource) {
6
6
  return createFileAssetProvider(args.assetSource);
7
7
  }
8
- return createGitAssetProvider(args.assetServerUrl ?? DEFAULT_ASSET_REPO_URL, args.assetRef ?? DEFAULT_ASSET_REF, { locale });
8
+ return createGitAssetProvider(args.assetServerUrl ?? DEFAULT_ASSET_REPO_URL, args.assetRef ?? DEFAULT_ASSET_REF, { locale, signal });
9
9
  };
@@ -2,10 +2,12 @@ import { defineCommand } from "citty";
2
2
  import * as p from "@clack/prompts";
3
3
  import { stat } from "node:fs/promises";
4
4
  import { basename, join } from "node:path";
5
- import { CLI_VERSION } from "../core/constants.js";
5
+ import { getCliVersion } from "../core/paths.js";
6
6
  import { runPrompts } from "../interactive/prompts.js";
7
7
  import { deployAssets, } from "../asset/deployer.js";
8
8
  import { selectAssetProvider } from "./asset-provider.js";
9
+ import { createCancelledError } from "../core/errors.js";
10
+ import { withExitCode } from "./run-wrapper.js";
9
11
  import { getMessage } from "../i18n/index.js";
10
12
  import { detectLocale } from "../utils/locale-detect.js";
11
13
  import { printSummary } from "../interactive/summary.js";
@@ -101,15 +103,12 @@ export const attachCommand = defineCommand({
101
103
  description: "(debug) Local asset source directory",
102
104
  },
103
105
  },
104
- run: async ({ args }) => {
106
+ run: withExitCode(async ({ args }) => {
105
107
  const locale = args.locale ?? detectLocale();
106
108
  const projectDir = process.cwd();
107
- try {
108
- await stat(join(projectDir, ".accel"));
109
- p.log.error(getMessage("error.accelExists", locale));
110
- process.exit(1);
111
- }
112
- catch {
109
+ const accelExists = await stat(join(projectDir, ".accel")).then(() => true, () => false);
110
+ if (accelExists) {
111
+ throw new Error(getMessage("error.accelExists", locale));
113
112
  }
114
113
  const moduleArg = args.module;
115
114
  const modules = moduleArg
@@ -140,16 +139,9 @@ export const attachCommand = defineCommand({
140
139
  noInteraction: args["non-interactive"],
141
140
  isInit: false,
142
141
  };
143
- let resolved;
144
- try {
145
- resolved = await runPrompts(promptOpts);
146
- }
147
- catch (err) {
148
- p.log.error(err instanceof Error ? err.message : String(err));
149
- process.exit(1);
150
- }
142
+ const resolved = await runPrompts(promptOpts);
151
143
  const settings = {
152
- cliVersion: CLI_VERSION,
144
+ cliVersion: getCliVersion(),
153
145
  createdAt: new Date().toISOString(),
154
146
  name: resolved.name,
155
147
  artifactId: resolved.artifactId,
@@ -212,7 +204,7 @@ export const attachCommand = defineCommand({
212
204
  ],
213
205
  });
214
206
  if (p.isCancel(choice))
215
- process.exit(0);
207
+ throw createCancelledError();
216
208
  if (choice === "all") {
217
209
  sticky = "all";
218
210
  return "overwrite";
@@ -256,5 +248,5 @@ export const attachCommand = defineCommand({
256
248
  isInit: false,
257
249
  locale,
258
250
  });
259
- },
251
+ }),
260
252
  });
@@ -5,6 +5,7 @@ import { cacheReposDir, directorySize, listCacheRepos, resolveCacheRoot, } from
5
5
  import { getMessage } from "../i18n/index.js";
6
6
  import { detectLocale } from "../utils/locale-detect.js";
7
7
  import { sanitizeDisplayText } from "../utils/sanitize-text.js";
8
+ import { withExitCode } from "./run-wrapper.js";
8
9
  const formatBytes = (bytes) => {
9
10
  if (bytes >= 1024 ** 3)
10
11
  return `${(bytes / 1024 ** 3).toFixed(1)} GB`;
@@ -19,7 +20,7 @@ const infoCommand = defineCommand({
19
20
  name: "info",
20
21
  description: "Show the asset cache location and disk usage",
21
22
  },
22
- run: async () => {
23
+ run: withExitCode(async () => {
23
24
  const locale = detectLocale();
24
25
  const root = resolveCacheRoot();
25
26
  let dirLine = getMessage("cache.info.dir", locale, { path: root });
@@ -37,30 +38,24 @@ const infoCommand = defineCommand({
37
38
  for (const repo of repos) {
38
39
  p.log.info(` ${sanitizeDisplayText(repo.url ?? repo.dir)} — ${formatBytes(repo.size)}`);
39
40
  }
40
- },
41
+ }),
41
42
  });
42
43
  const clearCommand = defineCommand({
43
44
  meta: {
44
45
  name: "clear",
45
46
  description: "Delete the asset cache (it will be re-downloaded on demand)",
46
47
  },
47
- run: async () => {
48
+ run: withExitCode(async () => {
48
49
  const locale = detectLocale();
49
50
  const reposDir = cacheReposDir(resolveCacheRoot());
50
- try {
51
- const size = await directorySize(reposDir);
52
- if (size === 0) {
53
- p.log.info(getMessage("cache.clear.empty", locale));
54
- return;
55
- }
56
- await rm(reposDir, { recursive: true, force: true });
57
- p.log.success(getMessage("cache.clear.done", locale, { size: formatBytes(size) }));
58
- }
59
- catch (err) {
60
- p.log.error(err instanceof Error ? err.message : String(err));
61
- process.exit(1);
51
+ const size = await directorySize(reposDir);
52
+ if (size === 0) {
53
+ p.log.info(getMessage("cache.clear.empty", locale));
54
+ return;
62
55
  }
63
- },
56
+ await rm(reposDir, { recursive: true, force: true });
57
+ p.log.success(getMessage("cache.clear.done", locale, { size: formatBytes(size) }));
58
+ }),
64
59
  });
65
60
  export const cacheCommand = defineCommand({
66
61
  meta: {
@@ -1,4 +1,5 @@
1
1
  import type { AccelCredentials, SampleSetupConfigResponse, SetupConfigResponse, StagingResponse } from "../core/types.js";
2
+ import type { Logger } from "../core/logger.js";
2
3
  import { type ApiClient } from "../deploy/api-client.js";
3
4
  import { type DeployFile } from "../deploy/deploy-files.js";
4
5
  export type ConfirmInfo = {
@@ -40,6 +41,8 @@ export type RunDeployDeps = {
40
41
  scanTargets?: (projectDir: string) => Promise<string[]>;
41
42
  apiClientFactory?: (endpoint: string, apiKey: string) => ApiClient;
42
43
  prompts?: DeployPrompts;
44
+ logger?: Logger;
45
+ signal?: AbortSignal;
43
46
  };
44
47
  export declare const runDeploy: (deps: RunDeployDeps) => Promise<void>;
45
48
  export declare const deployCommand: import("citty").CommandDef<{