@intra-mart/accel 0.4.0 → 0.5.0-dev.202608030656
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.
- package/README.md +71 -4
- package/dist/asset/deployer.js +3 -4
- package/dist/asset/git-provider.js +53 -25
- package/dist/asset/installer.d.ts +4 -1
- package/dist/asset/installer.js +13 -0
- package/dist/asset/updater.d.ts +6 -1
- package/dist/asset/updater.js +122 -23
- package/dist/commands/cache.d.ts +1 -0
- package/dist/commands/cache.js +74 -0
- package/dist/commands/switch.d.ts +24 -0
- package/dist/commands/switch.js +203 -0
- package/dist/core/constants.d.ts +1 -1
- package/dist/core/constants.js +1 -1
- package/dist/git/object-cache.d.ts +12 -0
- package/dist/git/object-cache.js +95 -0
- package/dist/git/object-store.d.ts +3 -1
- package/dist/git/object-store.js +49 -9
- package/dist/i18n/en.js +24 -0
- package/dist/i18n/ja.js +24 -0
- package/dist/i18n/zh_CN.js +24 -0
- package/dist/index.js +4 -0
- package/dist/interactive/prompts.d.ts +4 -1
- package/dist/interactive/prompts.js +51 -43
- package/dist/utils/concurrency.d.ts +1 -0
- package/dist/utils/concurrency.js +1 -0
- package/dist/utils/hash.d.ts +1 -0
- package/dist/utils/hash.js +5 -0
- package/dist/utils/safe-rel-path.d.ts +1 -0
- package/dist/utils/safe-rel-path.js +5 -0
- package/dist/utils/settings-io.js +3 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -68,7 +68,7 @@ accel init my-project \
|
|
|
68
68
|
| `--no-git-init` | boolean | git initをスキップ | `false`(git initする) |
|
|
69
69
|
| `--skip-install` | boolean | 依存インストールをスキップ | `false` |
|
|
70
70
|
| `--asset-server-url` | string | 資材を取得するgitリポジトリのURL(HTTP(S) のみ。デフォルトの取得先を上書き) | `https://github.com/accelplatform/skills` |
|
|
71
|
-
| `--asset-ref` | string | 資材リポジトリから取得するブランチ/タグ | `
|
|
71
|
+
| `--asset-ref` | string | 資材リポジトリから取得するブランチ/タグ | `experiment` |
|
|
72
72
|
|
|
73
73
|
### `accel attach`
|
|
74
74
|
|
|
@@ -109,7 +109,7 @@ accel attach --non-interactive --accelplatform-version 2026-spring
|
|
|
109
109
|
| `--non-interactive` | boolean | 非対話モード | `false` |
|
|
110
110
|
| `--skip-install` | boolean | 依存インストールをスキップ | `false` |
|
|
111
111
|
| `--asset-server-url` | string | 資材を取得するgitリポジトリのURL(HTTP(S) のみ。デフォルトの取得先を上書き) | `https://github.com/accelplatform/skills` |
|
|
112
|
-
| `--asset-ref` | string | 資材リポジトリから取得するブランチ/タグ | `
|
|
112
|
+
| `--asset-ref` | string | 資材リポジトリから取得するブランチ/タグ | `experiment` |
|
|
113
113
|
|
|
114
114
|
### `accel update`
|
|
115
115
|
|
|
@@ -153,6 +153,71 @@ accel update --non-interactive --module im_workflow,im_activiti
|
|
|
153
153
|
|
|
154
154
|
> **Note**: `update` は git ソース(既定の GitHub リポジトリ等)から配備されたプロジェクトでのみ利用できます。`--asset-source`(ローカルディレクトリ)から配備したプロジェクトや、旧バージョンのCLIで作成されたプロジェクトでは利用できません。
|
|
155
155
|
|
|
156
|
+
### `accel switch`
|
|
157
|
+
|
|
158
|
+
配備済みの資材構成(モジュール・機能・エージェント)を、リポジトリからのダウンロードなしで切り替えます。
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
cd my-project
|
|
162
|
+
accel switch --feature jssp
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
- git worktree やサブエージェントを使った並列作業など、**作業コンテキストごとに必要な skills だけを配置したい**ケースを想定したコマンドです。
|
|
166
|
+
- 資材は `.accel/settings.json` に記録されたコミット(配備時点のリポジトリ内容)から再構成します。**リポジトリ側の更新には追従しません**(更新を取り込みたい場合は `accel update`)。
|
|
167
|
+
- 資材の内容はローカルの資材キャッシュ(後述「[`accel cache`](#accel-cache)」)から読み出すため、通常ダウンロードは発生しません。キャッシュに記録コミットのデータがない場合のみリポジトリから再取得します(取得できない場合はエラー終了)。切り替え先の構成に必要なデータが全てキャッシュにあれば(例: 一度使ったことのある構成へ戻す場合)、オフラインでも切り替えできます。
|
|
168
|
+
- **ユーザーが編集したファイルには一切触れません**。切り替えで上書き・削除の対象になった編集済みファイルはそのまま保持してスキップし、終了時に「切り替えが適用されていないファイル」として一覧表示します。`update` と異なり、コンフリクトマーカーの挿入は行いません。
|
|
169
|
+
- 未編集のファイルは新しい構成の内容で上書きされ、新構成で不要になった資材は削除、新たに必要になった資材は追加されます。
|
|
170
|
+
- install / build は変更されたファイルに `package.json` またはロックファイル(`bun.lock` 等)が含まれる場合のみ実行します。skills などの切り替えだけであれば実行されず、すぐに完了します。スキップされた編集済みファイルがある状態で install / build が失敗した場合は、スキップしたファイルが原因の可能性がある旨をあわせて表示します。
|
|
171
|
+
- 対話モードでは、モジュール・機能・エージェントを現在の設定を初期値として選択し直せます。
|
|
172
|
+
|
|
173
|
+
#### 非対話モード
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
accel switch --non-interactive --feature jssp --agent claude-code
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
未指定の項目は現在の設定を維持します。
|
|
180
|
+
|
|
181
|
+
#### オプション一覧
|
|
182
|
+
|
|
183
|
+
| オプション | 型 | 説明 | デフォルト |
|
|
184
|
+
|---|---|---|---|
|
|
185
|
+
| `--module` | string | 使用モジュール。カタログの `artifactId`(カンマ区切り) | 現在の設定を維持 |
|
|
186
|
+
| `--feature` | string | 使用機能。カタログの機能ID(カンマ区切り) | 現在の設定を維持 |
|
|
187
|
+
| `--agent` | string | エージェント種別(`claude-code`, `codex`, `github-copilot`、カンマ区切り) | 現在の設定を維持 |
|
|
188
|
+
| `--non-interactive` | boolean | 非対話モード | `false` |
|
|
189
|
+
| `--skip-install` | boolean | 依存関係変更時の install / build をスキップ | `false` |
|
|
190
|
+
|
|
191
|
+
- 切り替えられるのは上記の3項目のみです。iAPバージョンやロケールなど他の設定の変更は `accel update` で行います。
|
|
192
|
+
- `update` と同様、git ソースから配備されたプロジェクトでのみ利用できます。
|
|
193
|
+
|
|
194
|
+
### `accel cache`
|
|
195
|
+
|
|
196
|
+
資材キャッシュを管理します。
|
|
197
|
+
|
|
198
|
+
`accel init` / `attach` / `update` / `switch` は、資材リポジトリから取得したデータをユーザーのホームディレクトリ配下のキャッシュ(`~/.accel/cache`。環境変数 `ACCEL_CACHE_DIR` で変更可能)に保持し、コマンド間・プロジェクト間で共有します。2回目以降の実行では取得済みのデータを再ダウンロードしないため、`update` や別プロジェクト・別 worktree での `init` も高速になります。
|
|
199
|
+
|
|
200
|
+
> **Note**: `ACCEL_CACHE_DIR` に**複数ユーザーが書き込める共有パスを指定しないでください**。キャッシュを改ざんされると、配備される資材の内容が差し替えられる可能性があります。
|
|
201
|
+
|
|
202
|
+
キャッシュは自動では削除されません。不要になった場合は `accel cache clear` で削除してください。
|
|
203
|
+
|
|
204
|
+
#### `accel cache info`
|
|
205
|
+
|
|
206
|
+
キャッシュの場所とディスク使用量を表示します。
|
|
207
|
+
|
|
208
|
+
```
|
|
209
|
+
キャッシュディレクトリ: /home/user/.accel/cache
|
|
210
|
+
合計サイズ: 12.4 MB
|
|
211
|
+
|
|
212
|
+
https://github.com/accelplatform/skills — 12.4 MB
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
#### `accel cache clear`
|
|
216
|
+
|
|
217
|
+
キャッシュを全て削除し、解放したサイズを表示します。削除してもプロジェクトには影響せず、以降のコマンド実行時に必要なデータが再ダウンロードされるだけです。
|
|
218
|
+
|
|
219
|
+
> **Note**: 他の `accel` コマンドの実行中に `cache clear` を行うと、実行中の取得処理が失敗することがあります(データが壊れることはなく、再実行で回復します)。
|
|
220
|
+
|
|
156
221
|
### `accel detach`
|
|
157
222
|
|
|
158
223
|
プロジェクトからAccel CLIの資材を解除します。
|
|
@@ -376,13 +441,15 @@ my-project/
|
|
|
376
441
|
└── .git/
|
|
377
442
|
```
|
|
378
443
|
|
|
379
|
-
- `.accel/settings.json` — プロジェクト設定。git管理対象、手動編集可。資材リポジトリのURL・ref・配備時のコミットSHA(`assetSource`)を記録し、`accel update` が参照
|
|
380
|
-
- `.accel/hashsum.txt` — 配備ファイルのハッシュ。`update` / `detach` 時のユーザー編集検出に使用
|
|
444
|
+
- `.accel/settings.json` — プロジェクト設定。git管理対象、手動編集可。資材リポジトリのURL・ref・配備時のコミットSHA(`assetSource`)を記録し、`accel update` / `accel switch` が参照
|
|
445
|
+
- `.accel/hashsum.txt` — 配備ファイルのハッシュ。`update` / `switch` / `detach` 時のユーザー編集検出に使用
|
|
381
446
|
- `.accel/credentials.json` — iAP接続情報(endpoint / APIキー)。`accel deploy` 初回実行時に生成。APIキーを含むため `.gitignore` 対象(git管理対象外)
|
|
382
447
|
- `.githooks/` — APIキーの誤コミットを防ぐ pre-commit フック。`accel login` / `accel deploy` による接続情報の保存時に配置(詳細は「[pre-commit フックの自動配置](#pre-commit-フックの自動配置)」)
|
|
383
448
|
|
|
384
449
|
`credentials.json` の保存/更新時には、エージェント別の MCP 設定ファイル(`.mcp.json` / `.codex/config.toml` / `.vscode/mcp.json` のうち、存在し、かつ `agents` に含まれるエージェントのもの)に対しても API キーが反映されます。詳細は「[MCP 設定の自動同期](#mcp-設定の自動同期)」を参照してください。
|
|
385
450
|
|
|
451
|
+
このほか、資材リポジトリから取得したデータの資材キャッシュがユーザーのホームディレクトリ配下(`~/.accel/cache`。環境変数 `ACCEL_CACHE_DIR` で変更可能)に作られます。プロジェクトディレクトリ内には作られません。詳細は「[`accel cache`](#accel-cache)」を参照してください。
|
|
452
|
+
|
|
386
453
|
## 対応iAPバージョン
|
|
387
454
|
|
|
388
455
|
選択可能なiAPバージョン・モジュール・機能は、同梱のマスタデータパッケージ `@intra-mart/catalog` のカタログに基づきます(2025 Spring / 8.0.37 以降)。バージョンは `2026-spring` のようなリリースID形式で指定します。新しいリリースへの対応はカタログの更新によって行われます。
|
package/dist/asset/deployer.js
CHANGED
|
@@ -6,7 +6,7 @@ import { createMessageCollector } from "./messages.js";
|
|
|
6
6
|
import { renderAssetContent } from "./renderer.js";
|
|
7
7
|
import { runInstallBuild } from "./installer.js";
|
|
8
8
|
import { computeSha1 } from "../utils/hash.js";
|
|
9
|
-
import { mapWithConcurrency } from "../utils/concurrency.js";
|
|
9
|
+
import { FS_CONCURRENCY, mapWithConcurrency } from "../utils/concurrency.js";
|
|
10
10
|
import { writeSettings, writeHashsum } from "../utils/settings-io.js";
|
|
11
11
|
export { getInstallCmds } from "./installer.js";
|
|
12
12
|
const fileExists = async (path) => {
|
|
@@ -41,7 +41,6 @@ const fileLabelOf = (relativePath, section) => {
|
|
|
41
41
|
return relativePath;
|
|
42
42
|
return relativePath.slice(section.length);
|
|
43
43
|
};
|
|
44
|
-
const DEPLOY_CONCURRENCY = 64;
|
|
45
44
|
const groupSections = (entries) => {
|
|
46
45
|
const groups = new Map();
|
|
47
46
|
for (const entry of entries) {
|
|
@@ -89,7 +88,7 @@ export const deployAssets = async (options) => {
|
|
|
89
88
|
progress.onSectionDeploy(group.section, group.files);
|
|
90
89
|
}
|
|
91
90
|
}
|
|
92
|
-
const existsFlags = await mapWithConcurrency(entries,
|
|
91
|
+
const existsFlags = await mapWithConcurrency(entries, FS_CONCURRENCY, (entry) => fileExists(join(projectDir, entry.relativePath)));
|
|
93
92
|
const skippedFiles = [];
|
|
94
93
|
const overwrittenFiles = [];
|
|
95
94
|
const toDeploy = [];
|
|
@@ -111,7 +110,7 @@ export const deployAssets = async (options) => {
|
|
|
111
110
|
}
|
|
112
111
|
toDeploy.push(entry);
|
|
113
112
|
}
|
|
114
|
-
const hashEntries = await mapWithConcurrency(toDeploy,
|
|
113
|
+
const hashEntries = await mapWithConcurrency(toDeploy, FS_CONCURRENCY, async (entry) => {
|
|
115
114
|
const targetPath = entry.relativePath;
|
|
116
115
|
const destPath = join(projectDir, targetPath);
|
|
117
116
|
const raw = await tree.readFile(entry.sourceRelPath);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { getMessage } from "../i18n/index.js";
|
|
2
2
|
import { isGitAuthError, isGitObjectMissingError, isGitServerUnsupportedError, } from "../git/errors.js";
|
|
3
3
|
import { createObjectStore, } from "../git/object-store.js";
|
|
4
|
+
import { ensureUrlSidecar, repoStoreDir, resolveCacheRoot, } from "../git/object-cache.js";
|
|
4
5
|
import { assertServerSupported, fetchCapabilities, fetchPack, isValidOid, resolveRef, } from "../git/smart-http.js";
|
|
5
6
|
const MAX_WANTS_PER_REQUEST = 1000;
|
|
6
7
|
const META_FILENAME = "_meta.json";
|
|
@@ -17,7 +18,6 @@ export const createGitAssetProvider = (repoUrl, ref, options = {}) => {
|
|
|
17
18
|
const { locale = "en" } = options;
|
|
18
19
|
let store = null;
|
|
19
20
|
let commit = null;
|
|
20
|
-
let packSeq = 0;
|
|
21
21
|
const withHint = (message, cause) => {
|
|
22
22
|
if (isGitAuthError(cause)) {
|
|
23
23
|
return `${message}\n${getMessage("error.gitAuthHint", locale)}`;
|
|
@@ -27,6 +27,23 @@ export const createGitAssetProvider = (repoUrl, ref, options = {}) => {
|
|
|
27
27
|
}
|
|
28
28
|
return message;
|
|
29
29
|
};
|
|
30
|
+
const ensureStore = async () => {
|
|
31
|
+
if (store)
|
|
32
|
+
return store;
|
|
33
|
+
if (!isHttpUrl(repoUrl)) {
|
|
34
|
+
throw new Error(getMessage("error.gitUrlUnsupported", locale, { url: repoUrl }));
|
|
35
|
+
}
|
|
36
|
+
const dir = repoStoreDir(resolveCacheRoot(), repoUrl);
|
|
37
|
+
store = await createObjectStore({ dir });
|
|
38
|
+
await ensureUrlSidecar(dir, repoUrl);
|
|
39
|
+
return store;
|
|
40
|
+
};
|
|
41
|
+
const requireStore = () => {
|
|
42
|
+
if (!store) {
|
|
43
|
+
throw new Error("GitAssetProvider used before fetch()");
|
|
44
|
+
}
|
|
45
|
+
return store;
|
|
46
|
+
};
|
|
30
47
|
const requireRepo = () => {
|
|
31
48
|
if (!store || !commit) {
|
|
32
49
|
throw new Error("GitAssetProvider used before fetch()");
|
|
@@ -34,7 +51,7 @@ export const createGitAssetProvider = (repoUrl, ref, options = {}) => {
|
|
|
34
51
|
return { store, commit };
|
|
35
52
|
};
|
|
36
53
|
const fetchMissingBlobs = async (oids) => {
|
|
37
|
-
const
|
|
54
|
+
const store = requireStore();
|
|
38
55
|
const missing = [];
|
|
39
56
|
const seen = new Set();
|
|
40
57
|
for (const oid of oids) {
|
|
@@ -46,11 +63,11 @@ export const createGitAssetProvider = (repoUrl, ref, options = {}) => {
|
|
|
46
63
|
}
|
|
47
64
|
for (let i = 0; i < missing.length; i += MAX_WANTS_PER_REQUEST) {
|
|
48
65
|
const pack = await fetchPack(repoUrl, missing.slice(i, i + MAX_WANTS_PER_REQUEST));
|
|
49
|
-
await store.writePack(pack,
|
|
66
|
+
await store.writePack(pack, "blobs");
|
|
50
67
|
}
|
|
51
68
|
};
|
|
52
69
|
const readFileAt = async (oid, relPath) => {
|
|
53
|
-
const
|
|
70
|
+
const store = requireStore();
|
|
54
71
|
try {
|
|
55
72
|
return await store.readBlobAtPath(oid, relPath);
|
|
56
73
|
}
|
|
@@ -63,7 +80,7 @@ export const createGitAssetProvider = (repoUrl, ref, options = {}) => {
|
|
|
63
80
|
const materializeAt = async (oid, files) => {
|
|
64
81
|
if (files.length === 0)
|
|
65
82
|
return;
|
|
66
|
-
const
|
|
83
|
+
const store = requireStore();
|
|
67
84
|
const targets = [];
|
|
68
85
|
for (const file of files) {
|
|
69
86
|
const blobOid = await store.getBlobOid(oid, file);
|
|
@@ -76,24 +93,26 @@ export const createGitAssetProvider = (repoUrl, ref, options = {}) => {
|
|
|
76
93
|
.filter((e) => e.path === META_FILENAME || e.path.endsWith(`/${META_FILENAME}`))
|
|
77
94
|
.map((e) => e.oid);
|
|
78
95
|
const listRootFilesAt = async (oid) => {
|
|
79
|
-
const
|
|
96
|
+
const store = requireStore();
|
|
80
97
|
const entries = await store.listRootBlobEntries(oid);
|
|
81
98
|
await fetchMissingBlobs(metaOidsOf(entries));
|
|
82
99
|
return entries.map((e) => e.path);
|
|
83
100
|
};
|
|
84
101
|
const listFilesAt = async (oid, underDirs) => {
|
|
85
|
-
const
|
|
102
|
+
const store = requireStore();
|
|
86
103
|
const entries = await store.listBlobEntries(oid, underDirs);
|
|
87
104
|
await fetchMissingBlobs(metaOidsOf(entries));
|
|
88
105
|
return entries.map((e) => e.path);
|
|
89
106
|
};
|
|
90
107
|
const fetchTreesFor = async (oid, label) => {
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
108
|
+
const store = requireStore();
|
|
109
|
+
if (!store.hasObject(oid)) {
|
|
110
|
+
const pack = await fetchPack(repoUrl, [oid], {
|
|
111
|
+
deepenOne: true,
|
|
112
|
+
filterBlobNone: true,
|
|
113
|
+
});
|
|
114
|
+
await store.writePack(pack, label);
|
|
115
|
+
}
|
|
97
116
|
await listRootFilesAt(oid);
|
|
98
117
|
};
|
|
99
118
|
const rethrowWithServerDiagnosis = async (original) => {
|
|
@@ -108,18 +127,27 @@ export const createGitAssetProvider = (repoUrl, ref, options = {}) => {
|
|
|
108
127
|
}
|
|
109
128
|
throw original;
|
|
110
129
|
};
|
|
111
|
-
const commitTreeOf = (oid) =>
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
130
|
+
const commitTreeOf = (oid) => {
|
|
131
|
+
const blobCache = new Map();
|
|
132
|
+
const readFileCached = (relPath) => {
|
|
133
|
+
let cached = blobCache.get(relPath);
|
|
134
|
+
if (!cached) {
|
|
135
|
+
cached = readFileAt(oid, relPath);
|
|
136
|
+
cached.catch(() => blobCache.delete(relPath));
|
|
137
|
+
blobCache.set(relPath, cached);
|
|
138
|
+
}
|
|
139
|
+
return cached;
|
|
140
|
+
};
|
|
141
|
+
return {
|
|
142
|
+
listRootEntries: () => listRootFilesAt(oid),
|
|
143
|
+
listFiles: (underDirs) => listFilesAt(oid, underDirs),
|
|
144
|
+
readFile: readFileCached,
|
|
145
|
+
materialize: (files) => materializeAt(oid, files),
|
|
146
|
+
};
|
|
147
|
+
};
|
|
117
148
|
const provider = {
|
|
118
149
|
fetch: async () => {
|
|
119
|
-
|
|
120
|
-
throw new Error(getMessage("error.gitUrlUnsupported", locale, { url: repoUrl }));
|
|
121
|
-
}
|
|
122
|
-
store = await createObjectStore();
|
|
150
|
+
const opened = await ensureStore();
|
|
123
151
|
try {
|
|
124
152
|
try {
|
|
125
153
|
const resolved = await resolveRef(repoUrl, ref);
|
|
@@ -137,7 +165,7 @@ export const createGitAssetProvider = (repoUrl, ref, options = {}) => {
|
|
|
137
165
|
const reason = err instanceof Error ? err.message : String(err);
|
|
138
166
|
throw new Error(withHint(`Failed to fetch the asset repository from ${repoUrl} (ref: ${ref}). Check the URL and ref: ${reason}`, err));
|
|
139
167
|
}
|
|
140
|
-
return
|
|
168
|
+
return opened.dir;
|
|
141
169
|
},
|
|
142
170
|
listRootEntries: () => {
|
|
143
171
|
const { commit: oid } = requireRepo();
|
|
@@ -173,10 +201,10 @@ export const createGitAssetProvider = (repoUrl, ref, options = {}) => {
|
|
|
173
201
|
return commitTreeOf(oid);
|
|
174
202
|
},
|
|
175
203
|
openCommit: async (sha) => {
|
|
176
|
-
requireRepo();
|
|
177
204
|
if (!isValidOid(sha)) {
|
|
178
205
|
throw new Error(`Invalid commit SHA recorded in settings: ${JSON.stringify(sha)}`);
|
|
179
206
|
}
|
|
207
|
+
await ensureStore();
|
|
180
208
|
try {
|
|
181
209
|
await fetchTreesFor(sha, `trees-${sha.slice(0, 7)}`);
|
|
182
210
|
}
|
|
@@ -2,5 +2,8 @@ export type InstallProgress = {
|
|
|
2
2
|
onInstallStart?: (command: string) => void;
|
|
3
3
|
onBuildStart?: (command: string) => void;
|
|
4
4
|
};
|
|
5
|
+
export declare const installTriggerChanged: (changedPaths: string[]) => boolean;
|
|
5
6
|
export declare const getInstallCmds: (packageManager: string) => string[];
|
|
6
|
-
export declare const runInstallBuild: (projectDir: string, packageManager: string, progress?: InstallProgress) =>
|
|
7
|
+
export declare const runInstallBuild: (projectDir: string, packageManager: string, progress?: InstallProgress) => {
|
|
8
|
+
success: boolean;
|
|
9
|
+
};
|
package/dist/asset/installer.js
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import { execSync } from "node:child_process";
|
|
2
|
+
import { basename } from "node:path";
|
|
3
|
+
const INSTALL_TRIGGER_BASENAMES = [
|
|
4
|
+
"package.json",
|
|
5
|
+
"bun.lock",
|
|
6
|
+
"package-lock.json",
|
|
7
|
+
"yarn.lock",
|
|
8
|
+
"pnpm-lock.yaml",
|
|
9
|
+
];
|
|
10
|
+
export const installTriggerChanged = (changedPaths) => changedPaths.some((path) => INSTALL_TRIGGER_BASENAMES.includes(basename(path)));
|
|
2
11
|
export const getInstallCmds = (packageManager) => {
|
|
3
12
|
switch (packageManager) {
|
|
4
13
|
case "npm":
|
|
@@ -14,11 +23,13 @@ export const getInstallCmds = (packageManager) => {
|
|
|
14
23
|
};
|
|
15
24
|
export const runInstallBuild = (projectDir, packageManager, progress) => {
|
|
16
25
|
const [installCmd, buildCmd] = getInstallCmds(packageManager);
|
|
26
|
+
let success = true;
|
|
17
27
|
progress?.onInstallStart?.(installCmd);
|
|
18
28
|
try {
|
|
19
29
|
execSync(installCmd, { cwd: projectDir, stdio: "pipe" });
|
|
20
30
|
}
|
|
21
31
|
catch {
|
|
32
|
+
success = false;
|
|
22
33
|
console.warn(`Warning: install command failed: ${installCmd} in ${projectDir}`);
|
|
23
34
|
}
|
|
24
35
|
progress?.onBuildStart?.(buildCmd);
|
|
@@ -26,6 +37,8 @@ export const runInstallBuild = (projectDir, packageManager, progress) => {
|
|
|
26
37
|
execSync(buildCmd, { cwd: projectDir, stdio: "pipe" });
|
|
27
38
|
}
|
|
28
39
|
catch {
|
|
40
|
+
success = false;
|
|
29
41
|
console.warn(`Warning: build command failed: ${buildCmd} in ${projectDir}`);
|
|
30
42
|
}
|
|
43
|
+
return { success };
|
|
31
44
|
};
|
package/dist/asset/updater.d.ts
CHANGED
|
@@ -17,17 +17,21 @@ export type FileState = {
|
|
|
17
17
|
oursContent: string | null;
|
|
18
18
|
recorded: HashsumEntry | null;
|
|
19
19
|
};
|
|
20
|
-
export type UpdateOutcome = "up-to-date" | "updated" | "kept-edited" | "merged" | "conflict" | "kept-deleted" | "redeployed" | "removed" | "kept-warn" | "added" | "adopted" | "redeployed-warn" | "skipped-edited";
|
|
20
|
+
export type UpdateOutcome = "up-to-date" | "updated" | "kept-edited" | "merged" | "conflict" | "kept-deleted" | "redeployed" | "removed" | "kept-warn" | "added" | "adopted" | "redeployed-warn" | "skipped-edited" | "skipped-switch";
|
|
21
|
+
export type SwitchSkipReason = "edited" | "deleted" | "out-of-scope" | "unmanaged";
|
|
21
22
|
export type UpdateAction = {
|
|
22
23
|
relativePath: string;
|
|
23
24
|
op: "none" | "write" | "delete";
|
|
24
25
|
outcome: UpdateOutcome;
|
|
25
26
|
content?: string;
|
|
27
|
+
skipReason?: SwitchSkipReason;
|
|
26
28
|
record: HashsumEntry | "keep" | "remove";
|
|
27
29
|
};
|
|
28
30
|
export declare const collectFileStates: (projectDir: string, basePlan: RenderedPlan, theirsPlan: RenderedPlan, recorded: HashsumEntry[]) => Promise<FileState[]>;
|
|
29
31
|
export declare const classifyFile: (state: FileState, merge: MergeFn) => Promise<UpdateAction>;
|
|
30
32
|
export declare const classifyFileFallback: (state: FileState, merge: MergeFn, keepEdited: boolean) => Promise<UpdateAction>;
|
|
33
|
+
export declare const classifyFileSwitch: (state: FileState) => UpdateAction;
|
|
34
|
+
export declare const classifySwitch: (states: FileState[]) => UpdateAction[];
|
|
31
35
|
export declare const classifyAll: (states: FileState[], merge: MergeFn, fallback?: {
|
|
32
36
|
keepEdited: boolean;
|
|
33
37
|
}) => Promise<UpdateAction[]>;
|
|
@@ -44,6 +48,7 @@ export type UpdateSummary = {
|
|
|
44
48
|
warnings: string[];
|
|
45
49
|
redeployedWarn: string[];
|
|
46
50
|
skippedEdited: string[];
|
|
51
|
+
skippedSwitch: string[];
|
|
47
52
|
changedFileCount: number;
|
|
48
53
|
};
|
|
49
54
|
export declare const applyUpdateActions: (projectDir: string, actions: UpdateAction[]) => Promise<UpdateSummary>;
|
package/dist/asset/updater.js
CHANGED
|
@@ -4,7 +4,8 @@ import { buildEvalContext } from "../core/eval-context.js";
|
|
|
4
4
|
import { walkAssetRepo } from "./walker.js";
|
|
5
5
|
import { renderAssetContent } from "./renderer.js";
|
|
6
6
|
import { computeSha1 } from "../utils/hash.js";
|
|
7
|
-
|
|
7
|
+
import { FS_CONCURRENCY, mapWithConcurrency } from "../utils/concurrency.js";
|
|
8
|
+
import { isSafeRelPath } from "../utils/safe-rel-path.js";
|
|
8
9
|
export const buildRenderedPlan = async (tree, settings, materialize, collect) => {
|
|
9
10
|
const context = buildEvalContext(settings);
|
|
10
11
|
const entries = await walkAssetRepo(tree, settings.accelplatformVersion.semver, context, collect);
|
|
@@ -20,18 +21,17 @@ export const buildRenderedPlan = async (tree, settings, materialize, collect) =>
|
|
|
20
21
|
...new Set(safeEntries.map((e) => e.sourceRelPath)),
|
|
21
22
|
]);
|
|
22
23
|
}
|
|
23
|
-
const
|
|
24
|
-
for (const entry of safeEntries) {
|
|
24
|
+
const rendered = await mapWithConcurrency(safeEntries, FS_CONCURRENCY, async (entry) => {
|
|
25
25
|
const raw = await tree.readFile(entry.sourceRelPath);
|
|
26
26
|
const content = renderAssetContent(raw, entry.relativePath, entry.meta?.replacements ?? [], context);
|
|
27
|
-
|
|
27
|
+
return {
|
|
28
28
|
relativePath: entry.relativePath,
|
|
29
29
|
content,
|
|
30
30
|
version: entry.meta?.version ?? "0.0.0",
|
|
31
31
|
sha1: computeSha1(content),
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
return new Map(rendered.map((asset) => [asset.relativePath, asset]));
|
|
35
35
|
};
|
|
36
36
|
export const collectFileStates = async (projectDir, basePlan, theirsPlan, recorded) => {
|
|
37
37
|
const recordedMap = new Map(recorded.map((e) => [e.filePath, e]));
|
|
@@ -40,12 +40,12 @@ export const collectFileStates = async (projectDir, basePlan, theirsPlan, record
|
|
|
40
40
|
...theirsPlan.keys(),
|
|
41
41
|
...recordedMap.keys(),
|
|
42
42
|
]);
|
|
43
|
-
const
|
|
44
|
-
for (const key of [...keys].sort()) {
|
|
43
|
+
const targets = [...keys].sort().flatMap((key) => {
|
|
45
44
|
const theirs = theirsPlan.get(key) ?? null;
|
|
46
45
|
const rec = recordedMap.get(key) ?? null;
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
return theirs || rec ? [{ key, theirs, rec }] : [];
|
|
47
|
+
});
|
|
48
|
+
return mapWithConcurrency(targets, FS_CONCURRENCY, async ({ key, theirs, rec }) => {
|
|
49
49
|
let oursContent = null;
|
|
50
50
|
try {
|
|
51
51
|
oursContent = await readFile(join(projectDir, key), "utf-8");
|
|
@@ -53,15 +53,14 @@ export const collectFileStates = async (projectDir, basePlan, theirsPlan, record
|
|
|
53
53
|
catch {
|
|
54
54
|
oursContent = null;
|
|
55
55
|
}
|
|
56
|
-
|
|
56
|
+
return {
|
|
57
57
|
relativePath: key,
|
|
58
58
|
base: basePlan.get(key) ?? null,
|
|
59
59
|
theirs,
|
|
60
60
|
oursContent,
|
|
61
61
|
recorded: rec,
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
return states;
|
|
62
|
+
};
|
|
63
|
+
});
|
|
65
64
|
};
|
|
66
65
|
export const classifyFile = async (state, merge) => {
|
|
67
66
|
const { relativePath, base, theirs, oursContent, recorded } = state;
|
|
@@ -195,6 +194,99 @@ export const classifyFileFallback = async (state, merge, keepEdited) => {
|
|
|
195
194
|
record: theirsRecord,
|
|
196
195
|
};
|
|
197
196
|
};
|
|
197
|
+
export const classifyFileSwitch = (state) => {
|
|
198
|
+
const { relativePath, base, theirs, oursContent, recorded } = state;
|
|
199
|
+
if (recorded) {
|
|
200
|
+
if (!theirs) {
|
|
201
|
+
if (oursContent === null) {
|
|
202
|
+
return { relativePath, op: "none", outcome: "removed", record: "remove" };
|
|
203
|
+
}
|
|
204
|
+
const edited = computeSha1(oursContent) !== recorded.sha1;
|
|
205
|
+
if (edited) {
|
|
206
|
+
return {
|
|
207
|
+
relativePath,
|
|
208
|
+
op: "none",
|
|
209
|
+
outcome: "skipped-switch",
|
|
210
|
+
skipReason: "out-of-scope",
|
|
211
|
+
record: "keep",
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
return { relativePath, op: "delete", outcome: "removed", record: "remove" };
|
|
215
|
+
}
|
|
216
|
+
const theirsRecord = {
|
|
217
|
+
filePath: relativePath,
|
|
218
|
+
version: theirs.version,
|
|
219
|
+
sha1: theirs.sha1,
|
|
220
|
+
};
|
|
221
|
+
const changed = base?.content !== theirs.content;
|
|
222
|
+
if (oursContent === null) {
|
|
223
|
+
if (!changed) {
|
|
224
|
+
return { relativePath, op: "none", outcome: "kept-deleted", record: "keep" };
|
|
225
|
+
}
|
|
226
|
+
return {
|
|
227
|
+
relativePath,
|
|
228
|
+
op: "none",
|
|
229
|
+
outcome: "skipped-switch",
|
|
230
|
+
skipReason: "deleted",
|
|
231
|
+
record: "keep",
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
const edited = computeSha1(oursContent) !== recorded.sha1;
|
|
235
|
+
if (!edited) {
|
|
236
|
+
if (!changed) {
|
|
237
|
+
return { relativePath, op: "none", outcome: "up-to-date", record: "keep" };
|
|
238
|
+
}
|
|
239
|
+
return {
|
|
240
|
+
relativePath,
|
|
241
|
+
op: "write",
|
|
242
|
+
outcome: "updated",
|
|
243
|
+
content: theirs.content,
|
|
244
|
+
record: theirsRecord,
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
if (!changed) {
|
|
248
|
+
return { relativePath, op: "none", outcome: "kept-edited", record: "keep" };
|
|
249
|
+
}
|
|
250
|
+
if (oursContent === theirs.content) {
|
|
251
|
+
return { relativePath, op: "none", outcome: "adopted", record: theirsRecord };
|
|
252
|
+
}
|
|
253
|
+
return {
|
|
254
|
+
relativePath,
|
|
255
|
+
op: "none",
|
|
256
|
+
outcome: "skipped-switch",
|
|
257
|
+
skipReason: "edited",
|
|
258
|
+
record: "keep",
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
if (!theirs) {
|
|
262
|
+
return { relativePath, op: "none", outcome: "up-to-date", record: "keep" };
|
|
263
|
+
}
|
|
264
|
+
const theirsRecord = {
|
|
265
|
+
filePath: relativePath,
|
|
266
|
+
version: theirs.version,
|
|
267
|
+
sha1: theirs.sha1,
|
|
268
|
+
};
|
|
269
|
+
if (oursContent === null) {
|
|
270
|
+
return {
|
|
271
|
+
relativePath,
|
|
272
|
+
op: "write",
|
|
273
|
+
outcome: "added",
|
|
274
|
+
content: theirs.content,
|
|
275
|
+
record: theirsRecord,
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
if (oursContent === theirs.content) {
|
|
279
|
+
return { relativePath, op: "none", outcome: "adopted", record: theirsRecord };
|
|
280
|
+
}
|
|
281
|
+
return {
|
|
282
|
+
relativePath,
|
|
283
|
+
op: "none",
|
|
284
|
+
outcome: "skipped-switch",
|
|
285
|
+
skipReason: "unmanaged",
|
|
286
|
+
record: "keep",
|
|
287
|
+
};
|
|
288
|
+
};
|
|
289
|
+
export const classifySwitch = (states) => states.map(classifyFileSwitch);
|
|
198
290
|
export const classifyAll = async (states, merge, fallback) => {
|
|
199
291
|
const actions = [];
|
|
200
292
|
for (const state of states) {
|
|
@@ -218,17 +310,19 @@ export const applyUpdateActions = async (projectDir, actions) => {
|
|
|
218
310
|
warnings: [],
|
|
219
311
|
redeployedWarn: [],
|
|
220
312
|
skippedEdited: [],
|
|
313
|
+
skippedSwitch: [],
|
|
221
314
|
changedFileCount: 0,
|
|
222
315
|
};
|
|
223
|
-
|
|
316
|
+
await mapWithConcurrency(actions.filter((a) => a.op === "delete"), FS_CONCURRENCY, async (action) => {
|
|
317
|
+
await unlink(join(projectDir, action.relativePath)).catch(() => { });
|
|
318
|
+
});
|
|
319
|
+
await mapWithConcurrency(actions.filter((a) => a.op === "write"), FS_CONCURRENCY, async (action) => {
|
|
224
320
|
const destPath = join(projectDir, action.relativePath);
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
else if (action.op === "delete") {
|
|
231
|
-
await unlink(destPath).catch(() => { });
|
|
321
|
+
await mkdir(dirname(destPath), { recursive: true });
|
|
322
|
+
await writeFile(destPath, action.content ?? "", "utf-8");
|
|
323
|
+
});
|
|
324
|
+
for (const action of actions) {
|
|
325
|
+
if (action.op !== "none") {
|
|
232
326
|
summary.changedFileCount++;
|
|
233
327
|
}
|
|
234
328
|
switch (action.outcome) {
|
|
@@ -264,6 +358,9 @@ export const applyUpdateActions = async (projectDir, actions) => {
|
|
|
264
358
|
case "skipped-edited":
|
|
265
359
|
summary.skippedEdited.push(action.relativePath);
|
|
266
360
|
break;
|
|
361
|
+
case "skipped-switch":
|
|
362
|
+
summary.skippedSwitch.push(action.relativePath);
|
|
363
|
+
break;
|
|
267
364
|
case "added":
|
|
268
365
|
summary.added.push(action.relativePath);
|
|
269
366
|
break;
|
|
@@ -272,6 +369,8 @@ export const applyUpdateActions = async (projectDir, actions) => {
|
|
|
272
369
|
break;
|
|
273
370
|
case "up-to-date":
|
|
274
371
|
break;
|
|
372
|
+
default:
|
|
373
|
+
action.outcome;
|
|
275
374
|
}
|
|
276
375
|
}
|
|
277
376
|
return summary;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const cacheCommand: import("citty").CommandDef<import("citty").ArgsDef>;
|