@intra-mart/accel 1.0.0-rc.202609290758 → 2.0.0-dev.202610210621
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 +93 -6
- package/dist/asset/deployer.js +1 -2
- package/dist/asset/fetch-once.d.ts +2 -0
- package/dist/asset/fetch-once.js +14 -0
- package/dist/asset/mobile-meta.d.ts +15 -0
- package/dist/asset/mobile-meta.js +86 -0
- package/dist/asset/root-selection.d.ts +12 -0
- package/dist/asset/root-selection.js +78 -0
- package/dist/asset/updater.js +1 -1
- package/dist/asset/walker.d.ts +1 -1
- package/dist/asset/walker.js +3 -26
- package/dist/commands/attach-existing-files.d.ts +12 -0
- package/dist/commands/attach-existing-files.js +76 -0
- package/dist/commands/attach.d.ts +20 -0
- package/dist/commands/attach.js +77 -77
- package/dist/commands/deploy.js +16 -13
- package/dist/commands/detach.js +7 -3
- package/dist/commands/init.d.ts +20 -0
- package/dist/commands/init.js +71 -4
- package/dist/commands/login.js +12 -6
- package/dist/commands/mobile/attach.d.ts +7 -0
- package/dist/commands/mobile/attach.js +60 -0
- package/dist/commands/mobile/init.d.ts +4 -0
- package/dist/commands/mobile/init.js +95 -0
- package/dist/commands/mobile/shared.d.ts +65 -0
- package/dist/commands/mobile/shared.js +254 -0
- package/dist/commands/mobile/update.d.ts +8 -0
- package/dist/commands/mobile/update.js +109 -0
- package/dist/commands/mobile-sdk-options.d.ts +10 -0
- package/dist/commands/mobile-sdk-options.js +19 -0
- package/dist/commands/preset.d.ts +1 -1
- package/dist/commands/preset.js +35 -13
- package/dist/commands/project-type-select.d.ts +17 -0
- package/dist/commands/project-type-select.js +26 -0
- package/dist/commands/switch.d.ts +1 -1
- package/dist/commands/switch.js +118 -48
- package/dist/commands/update.d.ts +22 -0
- package/dist/commands/update.js +179 -106
- package/dist/core/condition-evaluator.js +4 -1
- package/dist/core/constants.d.ts +12 -2
- package/dist/core/constants.js +16 -0
- package/dist/core/eval-context.js +27 -0
- package/dist/core/project-type.d.ts +20 -0
- package/dist/core/project-type.js +49 -0
- package/dist/core/types.d.ts +28 -9
- package/dist/core/types.js +2 -0
- package/dist/core/validation.d.ts +2 -2
- package/dist/core/validators.d.ts +7 -0
- package/dist/core/validators.js +38 -1
- package/dist/core/variable-interpolator.js +2 -0
- package/dist/i18n/en.js +59 -0
- package/dist/i18n/ja.js +59 -0
- package/dist/i18n/zh_CN.js +59 -0
- package/dist/interactive/agent-detect.d.ts +1 -1
- package/dist/interactive/agent-detect.js +6 -6
- package/dist/interactive/mobile-prompts.d.ts +15 -0
- package/dist/interactive/mobile-prompts.js +45 -0
- package/dist/interactive/next-steps.d.ts +4 -0
- package/dist/interactive/next-steps.js +11 -0
- package/dist/interactive/prompts.d.ts +5 -2
- package/dist/interactive/prompts.js +23 -19
- package/dist/interactive/summary.d.ts +5 -3
- package/dist/interactive/summary.js +38 -0
- package/dist/lib.d.ts +11 -5
- package/dist/lib.js +6 -3
- package/dist/utils/args.d.ts +1 -0
- package/dist/utils/args.js +16 -0
- package/dist/utils/expo-project.d.ts +8 -0
- package/dist/utils/expo-project.js +54 -0
- package/dist/utils/external-command.d.ts +68 -0
- package/dist/utils/external-command.js +238 -0
- package/dist/utils/preset-io.d.ts +1 -0
- package/dist/utils/preset-io.js +18 -1
- package/dist/utils/settings-io.d.ts +1 -0
- package/dist/utils/settings-io.js +12 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,6 +4,8 @@ intra-mart Accel Platform (iAP) 開発プロジェクトの作成・管理を行
|
|
|
4
4
|
|
|
5
5
|
プロジェクトの作成から、AIコーディングエージェント(Claude Code / Codex / GitHub Copilot)向け資材(skills・MCP設定)の配備、iAPステージング環境へのデプロイまでをサポートします。
|
|
6
6
|
|
|
7
|
+
iAP と連携するモバイルアプリ(Expo + smartlime)の開発環境も作成できます([モバイルアプリ開発](#モバイルアプリ開発expo--smartlime))。
|
|
8
|
+
|
|
7
9
|
## インストール
|
|
8
10
|
|
|
9
11
|
[Bun](https://bun.sh/) でグローバルインストール:
|
|
@@ -64,6 +66,7 @@ accel init my-project
|
|
|
64
66
|
| オプション | 説明 | デフォルト |
|
|
65
67
|
|---|---|---|
|
|
66
68
|
| `[project-name]` (位置引数) | プロジェクト名(ディレクトリ名と一致) | 対話で入力 |
|
|
69
|
+
| `--project-type` | プロジェクト種別(`iap`, `mobile`。[モバイルアプリ開発](#モバイルアプリ開発expo--smartlime)) | 対話で選択(非対話モードでは `iap`) |
|
|
67
70
|
| `--accelplatform-version` | iAPバージョン。リリースID形式(例: `2026-spring`) | 対話で選択 |
|
|
68
71
|
| `--module` | 使用モジュール。カタログの `artifactId`(カンマ区切り。例: `im_workflow,im_activiti`) | 選択リリースの全モジュール |
|
|
69
72
|
| `--feature` | 使用機能。カタログの機能ID(カンマ区切り。例: `jssp,e2e`) | 選択リリースの全機能 |
|
|
@@ -76,6 +79,8 @@ accel init my-project
|
|
|
76
79
|
| `--database` | データベース種別(`postgresql`, `oracle`, `sqlserver`) | `postgresql` |
|
|
77
80
|
| `--javascript` | TypeScriptの代わりにJavaScriptを使用 | `false` |
|
|
78
81
|
| `--juggling-project` | IM-Jugglingプロジェクトパス([IM-Juggling連携](#im-juggling連携)) | - |
|
|
82
|
+
| `--expo-sdk` | (モバイル)Expo SDK のメジャーバージョン(例: `56`。[モバイルアプリ開発](#モバイルアプリ開発expo--smartlime)) | 選択肢のうち最新の SDK |
|
|
83
|
+
| `--expo-skills` / `--no-expo-skills` | (モバイル)Codex に Expo 公式 skills を導入するか | 対話で確認 |
|
|
79
84
|
| `--package-manager` | パッケージマネージャ(`bun`, `npm`, `yarn`, `pnpm`。CLIオプションでのみ指定可) | `bun` |
|
|
80
85
|
| `--non-interactive` | 非対話モード(このモードでは `project-name` が必須。[CIでの利用](#ciでの利用)) | `false` |
|
|
81
86
|
| `--no-git-init` | git initをスキップ | `false` |
|
|
@@ -100,7 +105,7 @@ accel attach
|
|
|
100
105
|
|
|
101
106
|
#### オプション一覧
|
|
102
107
|
|
|
103
|
-
`init` と同じ設定系オプション(`--accelplatform-version`, `--module`, `--feature`, `--agent`, `--locale`, `--artifact-id`, `--group`, `--project-version`, `--description`, `--database`, `--javascript`, `--juggling-project`, `--package-manager`)と、`--skip-install`, `--asset-server-url`, `--asset-ref` を受け付けます。`attach` 固有のオプションは以下のとおりです。
|
|
108
|
+
`init` と同じ設定系オプション(`--project-type`, `--accelplatform-version`, `--module`, `--feature`, `--agent`, `--locale`, `--artifact-id`, `--group`, `--project-version`, `--description`, `--database`, `--javascript`, `--juggling-project`, `--expo-sdk`, `--expo-skills`, `--package-manager`)と、`--skip-install`, `--asset-server-url`, `--asset-ref` を受け付けます。`attach` 固有のオプションは以下のとおりです。
|
|
104
109
|
|
|
105
110
|
| オプション | 説明 | デフォルト |
|
|
106
111
|
|---|---|---|
|
|
@@ -125,7 +130,7 @@ accel update
|
|
|
125
130
|
|
|
126
131
|
#### オプション一覧
|
|
127
132
|
|
|
128
|
-
`init` と同じ設定系オプション(`--accelplatform-version`, `--module`, `--feature`, `--agent`, `--locale`, `--name`, `--artifact-id`, `--group`, `--project-version`, `--description`, `--database`, `--javascript`, `--juggling-project`, `--package-manager`)を受け付けます。**未指定の項目は現在の設定を維持します。**
|
|
133
|
+
`init` と同じ設定系オプション(`--accelplatform-version`, `--module`, `--feature`, `--agent`, `--locale`, `--name`, `--artifact-id`, `--group`, `--project-version`, `--description`, `--database`, `--javascript`, `--juggling-project`, `--expo-sdk`, `--package-manager`)を受け付けます。**未指定の項目は現在の設定を維持します。**
|
|
129
134
|
|
|
130
135
|
| オプション | 説明 | デフォルト |
|
|
131
136
|
|---|---|---|
|
|
@@ -139,6 +144,8 @@ accel update
|
|
|
139
144
|
|
|
140
145
|
> **Note**: `update` / `switch` は git ソース(既定の GitHub リポジトリ等)から配備されたプロジェクトでのみ利用できます。
|
|
141
146
|
|
|
147
|
+
モバイルプロジェクトで使えるオプションは[モバイルアプリ開発](#モバイルアプリ開発expo--smartlime)を参照してください。
|
|
148
|
+
|
|
142
149
|
### `accel switch`
|
|
143
150
|
|
|
144
151
|
配備済みの資材構成(モジュール・機能・エージェント)を、リポジトリからのダウンロードなしで切り替えます。
|
|
@@ -155,7 +162,7 @@ accel switch --preset server-side
|
|
|
155
162
|
- 配備時点のリポジトリ内容から再構成するため、リポジトリ側の更新には追従しません(更新を取り込みたい場合は `accel update`)。資材はローカルの[資材キャッシュ](#accel-cache)から読み出すため、一度使った構成へはオフラインでも切り替えられます。
|
|
156
163
|
- ユーザーが編集したファイルには一切触れません。切り替えを適用できなかった編集済みファイルは終了時に一覧表示されます。
|
|
157
164
|
- skill の npm 依存も構成に合わせて自動で準備されます([skill の npm 依存の自動インストール](#skill-の-npm-依存の自動インストール))。
|
|
158
|
-
- 切り替えられるのはモジュール・機能・エージェントの3
|
|
165
|
+
- 切り替えられるのはモジュール・機能・エージェントの3項目のみです(モバイルプロジェクトではエージェントのみ)。iAPバージョンなど他の設定の変更は `accel update` で行います。
|
|
159
166
|
|
|
160
167
|
#### オプション一覧
|
|
161
168
|
|
|
@@ -195,8 +202,8 @@ accel preset create
|
|
|
195
202
|
| `[name]`(位置引数) | プリセット名(ID。英数字と `-` `_` のみ。**非対話モードでは必須**) | 対話で入力 |
|
|
196
203
|
| `--label` | 表示名。日本語なども使用可。`preset list` や選択肢に表示される | `""`(プリセット名を表示) |
|
|
197
204
|
| `--description` | プリセットの説明。`preset list` や選択肢に表示される | `""` |
|
|
198
|
-
| `--module` | 使用モジュール。カタログの `artifactId
|
|
199
|
-
| `--feature` | 使用機能。カタログの機能ID(カンマ区切り。**非対話モードでは必須**。`""`
|
|
205
|
+
| `--module` | 使用モジュール。カタログの `artifactId`(カンマ区切り。**非対話モードでは必須**。モバイルプロジェクトでは指定できません) | 対話で選択 |
|
|
206
|
+
| `--feature` | 使用機能。カタログの機能ID(カンマ区切り。**非対話モードでは必須**。`""` で機能なし。モバイルプロジェクトでは指定できません) | 対話で選択 |
|
|
200
207
|
| `--agent` | エージェント種別(`claude-code`, `codex`, `github-copilot`、カンマ区切り。**非対話モードでは必須**) | 対話で選択 |
|
|
201
208
|
| `--force` | 同名プリセットが存在する場合に確認なしで上書きする | `false`(対話で確認 / 非対話ではエラー) |
|
|
202
209
|
| `--locale` | ロケール(`ja`, `en`, `zh_CN`) | `settings.json` の記録値 |
|
|
@@ -224,7 +231,7 @@ accel login
|
|
|
224
231
|
|
|
225
232
|
### `accel deploy`
|
|
226
233
|
|
|
227
|
-
ビルド成果物(`./target/` 配下の zip)を iAP
|
|
234
|
+
ビルド成果物(`./target/` 配下の zip)を iAP のステージング環境へデプロイします。モバイルプロジェクトでは利用できません。
|
|
228
235
|
|
|
229
236
|
```bash
|
|
230
237
|
cd my-project
|
|
@@ -315,6 +322,84 @@ accel init my-project --juggling-project /path/to/juggling-project
|
|
|
315
322
|
|
|
316
323
|
機能(`--feature`)は `juggling.im` から検出できないため自動設定されません。
|
|
317
324
|
|
|
325
|
+
## モバイルアプリ開発(Expo + smartlime)
|
|
326
|
+
|
|
327
|
+
iAP と連携するモバイルアプリの開発環境を作成します。アプリは [Expo](https://expo.dev/) と、iAP 連携ライブラリ smartlime(`@intra-mart/smartlime`)で開発します。
|
|
328
|
+
|
|
329
|
+
> **Note**: モバイルプロジェクトで選べるエージェントは Claude Code と Codex です。GitHub Copilot は選べません(`--agent` やプリセットで `github-copilot` を指定するとエラーになります)。
|
|
330
|
+
|
|
331
|
+
```bash
|
|
332
|
+
accel init my-app --project-type mobile
|
|
333
|
+
cd my-app
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
`accel init` は次の順に処理します。
|
|
337
|
+
|
|
338
|
+
1. Expo 公式の [create-expo](https://docs.expo.dev/more/create-expo/) を実行して、アプリの雛形を作成します(依存のインストールと git の初回コミットも create-expo が行います)。
|
|
339
|
+
2. smartlime 用の skills・AGENTS.md などの資材を配備します。
|
|
340
|
+
3. エージェントに Codex を選んだ場合は、確認のうえで [Expo 公式 skills](https://github.com/expo/skills) を `.agents/skills/` に導入します。Claude Code では、Expo のプラグインを有効にする設定が配備されます。
|
|
341
|
+
|
|
342
|
+
配備した資材は未コミットの変更として残ります。内容を確認してコミットしてください。
|
|
343
|
+
|
|
344
|
+
### 必要な環境
|
|
345
|
+
|
|
346
|
+
- CLI のバージョン 2.0.0 以降。それより前の CLI では、モバイルプロジェクトで `update` などがエラーになります。
|
|
347
|
+
- npm。パッケージマネージャに bun などを選んだ場合も、create-expo の実行に必要です。
|
|
348
|
+
- npm レジストリと GitHub へのネットワーク接続(下記の外部パッケージの取得と実行に使います)。
|
|
349
|
+
- Expo 公式 skills を導入する場合は、導入に使う外部パッケージ(skills)の動作環境(git など)。
|
|
350
|
+
|
|
351
|
+
### 対話で選ぶ項目
|
|
352
|
+
|
|
353
|
+
| 項目 | オプション | 説明 |
|
|
354
|
+
|---|---|---|
|
|
355
|
+
| 連携先 iAP バージョン | `--accelplatform-version` | アプリが連携する iAP のバージョン。呼び出せる API に合わせて資材の内容が変わります |
|
|
356
|
+
| Expo SDK | `--expo-sdk` | 作成するアプリの Expo SDK(例: `56`)。smartlime が対応している SDK から選びます。既定は選択肢のうち最新の SDK |
|
|
357
|
+
| エージェント | `--agent` | `claude-code`, `codex` から選びます |
|
|
358
|
+
| Expo 公式 skills | `--expo-skills` / `--no-expo-skills` | Codex に Expo 公式 skills を導入するか。**非対話モードで Codex を選んだ場合は、どちらかの指定が必須**です |
|
|
359
|
+
|
|
360
|
+
このほか `--locale`, `--package-manager`, `--non-interactive`, `--skip-install`, `--asset-server-url`, `--asset-ref` を iAP プロジェクトと同様に使えます。iAP 専用のオプション(`--module`, `--feature`, `--database`, `--artifact-id`, `--group`, `--javascript`, `--juggling-project`, `--project-version`, `--description`, `--git-init` / `--no-git-init`)を指定するとエラーになります。
|
|
361
|
+
|
|
362
|
+
プロジェクト名(ディレクトリ名)には英小文字・数字・`@` `.` `_` `-` が使え、先頭は英小文字か数字にします(create-expo の制約に合わせたものです)。
|
|
363
|
+
|
|
364
|
+
```bash
|
|
365
|
+
# 非対話モード(CI など)
|
|
366
|
+
accel init my-app \
|
|
367
|
+
--non-interactive \
|
|
368
|
+
--project-type mobile \
|
|
369
|
+
--accelplatform-version 2026-autumn \
|
|
370
|
+
--agent claude-code,codex \
|
|
371
|
+
--expo-skills
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
### 既存の Expo プロジェクトに資材を配備する
|
|
375
|
+
|
|
376
|
+
```bash
|
|
377
|
+
cd my-existing-app
|
|
378
|
+
accel attach --project-type mobile
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
`package.json` の `expo` のバージョン指定から Expo SDK を判定します。対話モードでは、`expo` を使っているプロジェクトなら種別の既定値がモバイルになります。エージェントと Expo 公式 skills の指定は `accel init` と同じです(非対話モードで Codex を選んだ場合は、`--expo-skills` か `--no-expo-skills` が必要です)。
|
|
382
|
+
|
|
383
|
+
### 各コマンドでの扱い
|
|
384
|
+
|
|
385
|
+
| コマンド | モバイルプロジェクトでの扱い |
|
|
386
|
+
|---|---|
|
|
387
|
+
| `update` | 資材を更新します。Expo SDK の更新は行いません(アプリ側で SDK を上げた後に `update` を実行すると、資材を新しい SDK 用に切り替えるか確認します。非対話モードでは `--expo-sdk` で指定します)。設定系のオプションは `--accelplatform-version`, `--expo-sdk`, `--agent`, `--locale`, `--name`, `--package-manager`, `--preset` を使えます |
|
|
388
|
+
| `switch` / `preset` | エージェントのみ切り替えられます。`preset create` の非対話モードで必須なのはプリセット名と `--agent` だけです |
|
|
389
|
+
| `login` | iAP プロジェクトと同じ |
|
|
390
|
+
| `deploy` | 利用できません |
|
|
391
|
+
|
|
392
|
+
Expo 公式 skills は CLI の管理対象ではありません。更新は `npx skills update` で行ってください。後からエージェントに Codex を加えた場合は、表示される導入コマンドを実行してください。
|
|
393
|
+
|
|
394
|
+
### 外部パッケージの利用について
|
|
395
|
+
|
|
396
|
+
モバイルアプリ開発では、CLI が次の外部パッケージを内部で実行します。使用するバージョンは Expo SDK に合わせて自動で決まるため、指定する必要はありません。各パッケージの動作は、それぞれの提供元の仕様に従います。
|
|
397
|
+
|
|
398
|
+
| パッケージ | 用途 |
|
|
399
|
+
|---|---|
|
|
400
|
+
| [create-expo](https://docs.expo.dev/more/create-expo/) | アプリの雛形の作成 |
|
|
401
|
+
| [skills](https://github.com/vercel-labs/skills) | Expo 公式 skills の導入(Codex を選んだ場合のみ) |
|
|
402
|
+
|
|
318
403
|
## MCP 設定の自動生成
|
|
319
404
|
|
|
320
405
|
資材リポジトリが提供するテンプレートから、コーディングエージェント用の MCP 設定ファイルを自動生成します。iAP への接続先 URL と API キーは生成時に埋め込まれるため、手動で設定する必要はありません。
|
|
@@ -374,6 +459,8 @@ my-project/
|
|
|
374
459
|
|
|
375
460
|
このほか、資材リポジトリから取得したデータのキャッシュがホームディレクトリ配下(`~/.accel/cache`)に作られます。プロジェクトディレクトリ内には作られません。
|
|
376
461
|
|
|
462
|
+
モバイルプロジェクトは、create-expo が作成したファイル一式に、`.accel/` と資材(`AGENTS.md`、各エージェントの skills など)が加わります。
|
|
463
|
+
|
|
377
464
|
## 対応iAPバージョン
|
|
378
465
|
|
|
379
466
|
選択可能なiAPバージョン・モジュール・機能は、CLIが内蔵するカタログ(iAPリリースのマスタデータ)に基づきます(2025 Spring / 8.0.37 以降)。バージョンは `2026-spring` のようなリリースID形式で指定します。新しいリリースにはCLIのアップデートで対応します。
|
package/dist/asset/deployer.js
CHANGED
|
@@ -62,10 +62,9 @@ export const deployAssets = async (options) => {
|
|
|
62
62
|
listFiles: (underDirs) => provider.listFiles(underDirs),
|
|
63
63
|
readFile: (relPath) => provider.readFile(relPath),
|
|
64
64
|
};
|
|
65
|
-
const semver = settings.accelplatformVersion.semver;
|
|
66
65
|
const context = buildEvalContext(settings);
|
|
67
66
|
const messageCollector = createMessageCollector();
|
|
68
|
-
const allEntries = await walkAssetRepo(tree,
|
|
67
|
+
const allEntries = await walkAssetRepo(tree, context, messageCollector.collect);
|
|
69
68
|
const entries = allEntries.filter((entry) => {
|
|
70
69
|
if (!isWithinDir(projectDir, join(projectDir, entry.relativePath))) {
|
|
71
70
|
progress?.onPathRejected?.("project", entry.relativePath);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const withFetchOnce = (provider) => {
|
|
2
|
+
let fetched = null;
|
|
3
|
+
return {
|
|
4
|
+
...provider,
|
|
5
|
+
fetch: () => (fetched ??= provider.fetch().catch((err) => {
|
|
6
|
+
fetched = null;
|
|
7
|
+
throw err;
|
|
8
|
+
})),
|
|
9
|
+
cleanup: async () => {
|
|
10
|
+
fetched = null;
|
|
11
|
+
await provider.cleanup();
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Condition } from "../core/types.js";
|
|
2
|
+
export type MobileMeta = {
|
|
3
|
+
expoSdk: string;
|
|
4
|
+
createExpo: {
|
|
5
|
+
package: string;
|
|
6
|
+
template: string;
|
|
7
|
+
};
|
|
8
|
+
expoSkills?: {
|
|
9
|
+
package: string;
|
|
10
|
+
source: string;
|
|
11
|
+
skills: string[];
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export declare const hasMobileGate: (conditions: Condition | undefined) => boolean;
|
|
15
|
+
export declare const validateMobileMeta: (raw: unknown, conditions: Condition | undefined, dir: string, locale: string) => MobileMeta;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import semver from "semver";
|
|
2
|
+
import { getMessage } from "../i18n/index.js";
|
|
3
|
+
import { sanitizeDisplayText } from "../utils/sanitize-text.js";
|
|
4
|
+
const EXPO_SDK_PATTERN = /^[0-9]+$/;
|
|
5
|
+
const NAME = "(?:@[a-z0-9][a-z0-9._~-]*\\/)?[a-z0-9][a-z0-9._~-]*";
|
|
6
|
+
const VERSION = "(?:[0-9]+\\.[0-9]+\\.[0-9]+(?:-[0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*)?|[A-Za-z][A-Za-z0-9-]*)";
|
|
7
|
+
const PACKAGE_SPEC_PATTERN = new RegExp(`^${NAME}@${VERSION}$`);
|
|
8
|
+
const TEMPLATE_SPEC_PATTERN = new RegExp(`^${NAME}(?:@(?:${VERSION}|[0-9]+))?$`);
|
|
9
|
+
const TARBALL_SUFFIX_PATTERN = /\.(?:tgz|tar|tar\.gz)$/i;
|
|
10
|
+
const GITHUB_SOURCE_PATTERN = /^[A-Za-z0-9][A-Za-z0-9-]*\/(?!\.\.?$)[A-Za-z0-9._-]+$/;
|
|
11
|
+
const isRangeLikeTag = (value) => {
|
|
12
|
+
const at = value.lastIndexOf("@");
|
|
13
|
+
const version = at > 0 ? value.slice(at + 1) : "";
|
|
14
|
+
return /^[A-Za-z]/.test(version) && semver.validRange(version, true) !== null;
|
|
15
|
+
};
|
|
16
|
+
const isRegistrySpec = (value, pattern) => typeof value === "string" &&
|
|
17
|
+
pattern.test(value) &&
|
|
18
|
+
!TARBALL_SUFFIX_PATTERN.test(value) &&
|
|
19
|
+
!isRangeLikeTag(value);
|
|
20
|
+
const SKILL_NAME_PATTERN = /^[a-z0-9][a-z0-9-]*$/;
|
|
21
|
+
const isRecord = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
22
|
+
const isMobileGate = (c) => isRecord(c) && Object.keys(c).length === 1 && c.projectType === "mobile";
|
|
23
|
+
export const hasMobileGate = (conditions) => {
|
|
24
|
+
if (isMobileGate(conditions))
|
|
25
|
+
return true;
|
|
26
|
+
if (!isRecord(conditions) || Object.keys(conditions).length !== 1) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
const and = conditions.and;
|
|
30
|
+
return Array.isArray(and) && and.some(isMobileGate);
|
|
31
|
+
};
|
|
32
|
+
const fail = (dir, field, locale) => {
|
|
33
|
+
throw new Error(getMessage("error.mobileMeta.invalid", locale, {
|
|
34
|
+
dir: sanitizeDisplayText(dir),
|
|
35
|
+
field,
|
|
36
|
+
}));
|
|
37
|
+
};
|
|
38
|
+
export const validateMobileMeta = (raw, conditions, dir, locale) => {
|
|
39
|
+
if (!hasMobileGate(conditions))
|
|
40
|
+
fail(dir, "conditions", locale);
|
|
41
|
+
if (!isRecord(raw))
|
|
42
|
+
fail(dir, "mobile", locale);
|
|
43
|
+
const mobile = raw;
|
|
44
|
+
const expoSdk = mobile.expoSdk;
|
|
45
|
+
if (typeof expoSdk !== "string" || !EXPO_SDK_PATTERN.test(expoSdk)) {
|
|
46
|
+
fail(dir, "mobile.expoSdk", locale);
|
|
47
|
+
}
|
|
48
|
+
const createExpo = mobile.createExpo;
|
|
49
|
+
if (!isRecord(createExpo))
|
|
50
|
+
fail(dir, "mobile.createExpo", locale);
|
|
51
|
+
const ce = createExpo;
|
|
52
|
+
if (!isRegistrySpec(ce.package, PACKAGE_SPEC_PATTERN)) {
|
|
53
|
+
fail(dir, "mobile.createExpo.package", locale);
|
|
54
|
+
}
|
|
55
|
+
if (!isRegistrySpec(ce.template, TEMPLATE_SPEC_PATTERN)) {
|
|
56
|
+
fail(dir, "mobile.createExpo.template", locale);
|
|
57
|
+
}
|
|
58
|
+
const result = {
|
|
59
|
+
expoSdk: expoSdk,
|
|
60
|
+
createExpo: { package: ce.package, template: ce.template },
|
|
61
|
+
};
|
|
62
|
+
if (mobile.expoSkills !== undefined) {
|
|
63
|
+
if (!isRecord(mobile.expoSkills))
|
|
64
|
+
fail(dir, "mobile.expoSkills", locale);
|
|
65
|
+
const es = mobile.expoSkills;
|
|
66
|
+
if (!isRegistrySpec(es.package, PACKAGE_SPEC_PATTERN)) {
|
|
67
|
+
fail(dir, "mobile.expoSkills.package", locale);
|
|
68
|
+
}
|
|
69
|
+
if (typeof es.source !== "string" ||
|
|
70
|
+
!GITHUB_SOURCE_PATTERN.test(es.source)) {
|
|
71
|
+
fail(dir, "mobile.expoSkills.source", locale);
|
|
72
|
+
}
|
|
73
|
+
const skills = es.skills;
|
|
74
|
+
if (!Array.isArray(skills) ||
|
|
75
|
+
skills.length === 0 ||
|
|
76
|
+
!skills.every((s) => typeof s === "string" && SKILL_NAME_PATTERN.test(s))) {
|
|
77
|
+
fail(dir, "mobile.expoSkills.skills", locale);
|
|
78
|
+
}
|
|
79
|
+
result.expoSkills = {
|
|
80
|
+
package: es.package,
|
|
81
|
+
source: es.source,
|
|
82
|
+
skills: [...skills],
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
return result;
|
|
86
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { EvalContext } from "../core/types.js";
|
|
2
|
+
import type { AssetTree } from "./asset-tree.js";
|
|
3
|
+
import { type MobileMeta } from "./mobile-meta.js";
|
|
4
|
+
export type MobileRootDir = {
|
|
5
|
+
dir: string;
|
|
6
|
+
mobile: MobileMeta;
|
|
7
|
+
};
|
|
8
|
+
export declare const listMobileRootDirs: (tree: AssetTree, context: EvalContext) => Promise<MobileRootDir[]>;
|
|
9
|
+
export declare const hasMobileRootDirs: (tree: AssetTree) => Promise<boolean>;
|
|
10
|
+
export declare const selectMobileRootDir: (tree: AssetTree, context: EvalContext) => Promise<MobileRootDir>;
|
|
11
|
+
export declare const formatSdkNotAvailable: (sdk: string, candidates: readonly MobileRootDir[], locale: string) => string;
|
|
12
|
+
export declare const selectRootDirs: (tree: AssetTree, context: EvalContext) => Promise<string[]>;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { evaluateCondition } from "../core/condition-evaluator.js";
|
|
2
|
+
import { emptyEvalContext } from "../core/eval-context.js";
|
|
3
|
+
import { getMessage } from "../i18n/index.js";
|
|
4
|
+
import { sanitizeDisplayText } from "../utils/sanitize-text.js";
|
|
5
|
+
import { validateMobileMeta } from "./mobile-meta.js";
|
|
6
|
+
const META_FILE = "_meta.json";
|
|
7
|
+
const readRootMetas = async (tree) => {
|
|
8
|
+
const dirs = (await tree.listRootEntries())
|
|
9
|
+
.map((p) => p.split("/"))
|
|
10
|
+
.filter((parts) => parts.length === 2 && parts[1] === META_FILE)
|
|
11
|
+
.map((parts) => parts[0])
|
|
12
|
+
.sort();
|
|
13
|
+
const metas = [];
|
|
14
|
+
for (const dir of dirs) {
|
|
15
|
+
try {
|
|
16
|
+
const meta = JSON.parse(await tree.readFile(`${dir}/${META_FILE}`));
|
|
17
|
+
if (typeof meta === "object" && meta !== null && !Array.isArray(meta)) {
|
|
18
|
+
metas.push({ dir, meta: meta });
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return metas;
|
|
25
|
+
};
|
|
26
|
+
const rootContext = (context) => emptyEvalContext({
|
|
27
|
+
projectType: context.projectType,
|
|
28
|
+
accelplatformVersion: context.accelplatformVersion,
|
|
29
|
+
});
|
|
30
|
+
const matches = (meta, context) => meta.conditions !== undefined &&
|
|
31
|
+
meta.conditions !== null &&
|
|
32
|
+
evaluateCondition(meta.conditions, rootContext(context));
|
|
33
|
+
const compareSdkDesc = (a, b) => Number(b.mobile.expoSdk) - Number(a.mobile.expoSdk);
|
|
34
|
+
export const listMobileRootDirs = async (tree, context) => {
|
|
35
|
+
const candidates = [];
|
|
36
|
+
for (const { dir, meta } of await readRootMetas(tree)) {
|
|
37
|
+
if (meta.mobile === undefined)
|
|
38
|
+
continue;
|
|
39
|
+
const mobile = validateMobileMeta(meta.mobile, meta.conditions, dir, context.locale);
|
|
40
|
+
if (matches(meta, { ...context, projectType: "mobile" })) {
|
|
41
|
+
candidates.push({ dir, mobile });
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const seen = new Map();
|
|
45
|
+
for (const { dir, mobile } of candidates) {
|
|
46
|
+
const other = seen.get(mobile.expoSdk);
|
|
47
|
+
if (other !== undefined) {
|
|
48
|
+
throw new Error(getMessage("error.mobileMeta.duplicateSdk", context.locale, {
|
|
49
|
+
sdk: mobile.expoSdk,
|
|
50
|
+
dirs: `${sanitizeDisplayText(other)}, ${sanitizeDisplayText(dir)}`,
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
53
|
+
seen.set(mobile.expoSdk, dir);
|
|
54
|
+
}
|
|
55
|
+
return candidates.sort(compareSdkDesc);
|
|
56
|
+
};
|
|
57
|
+
export const hasMobileRootDirs = async (tree) => (await readRootMetas(tree)).some(({ meta }) => meta.mobile !== undefined);
|
|
58
|
+
export const selectMobileRootDir = async (tree, context) => {
|
|
59
|
+
const candidates = await listMobileRootDirs(tree, context);
|
|
60
|
+
const selected = candidates.find((c) => c.mobile.expoSdk === context.expoSdk);
|
|
61
|
+
if (!selected) {
|
|
62
|
+
throw new Error(formatSdkNotAvailable(context.expoSdk, candidates, context.locale));
|
|
63
|
+
}
|
|
64
|
+
return selected;
|
|
65
|
+
};
|
|
66
|
+
export const formatSdkNotAvailable = (sdk, candidates, locale) => getMessage("error.mobileSdkNotAvailable", locale, {
|
|
67
|
+
sdk: sanitizeDisplayText(String(sdk)),
|
|
68
|
+
available: candidates.map((c) => c.mobile.expoSdk).join(", ") ||
|
|
69
|
+
getMessage("summary.empty", locale),
|
|
70
|
+
});
|
|
71
|
+
export const selectRootDirs = async (tree, context) => {
|
|
72
|
+
if (context.projectType === "mobile") {
|
|
73
|
+
return [(await selectMobileRootDir(tree, context)).dir];
|
|
74
|
+
}
|
|
75
|
+
return (await readRootMetas(tree))
|
|
76
|
+
.filter(({ meta }) => meta.mobile === undefined && matches(meta, context))
|
|
77
|
+
.map(({ dir }) => dir);
|
|
78
|
+
};
|
package/dist/asset/updater.js
CHANGED
|
@@ -9,7 +9,7 @@ import { FS_CONCURRENCY, mapWithConcurrency } from "../utils/concurrency.js";
|
|
|
9
9
|
import { isSafeRelPath } from "../utils/safe-rel-path.js";
|
|
10
10
|
export const buildRenderedPlan = async (tree, settings, materialize, collect, onPathRejected) => {
|
|
11
11
|
const context = buildEvalContext(settings);
|
|
12
|
-
const entries = await walkAssetRepo(tree,
|
|
12
|
+
const entries = await walkAssetRepo(tree, context, collect);
|
|
13
13
|
const safeEntries = entries.filter((entry) => {
|
|
14
14
|
if (!isSafeRelPath(entry.relativePath)) {
|
|
15
15
|
onPathRejected?.("project", entry.relativePath);
|
package/dist/asset/walker.d.ts
CHANGED
|
@@ -9,4 +9,4 @@ export type AssetEntry = {
|
|
|
9
9
|
};
|
|
10
10
|
export declare const replacementsFor: (entry: AssetEntry) => Replacement[];
|
|
11
11
|
export declare const walkAssetDir: (tree: AssetTree, context: EvalContext) => Promise<AssetEntry[]>;
|
|
12
|
-
export declare const walkAssetRepo: (tree: AssetTree,
|
|
12
|
+
export declare const walkAssetRepo: (tree: AssetTree, context: EvalContext, collect?: MessageSink) => Promise<AssetEntry[]>;
|
package/dist/asset/walker.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { evaluateCondition } from "../core/condition-evaluator.js";
|
|
2
|
-
import {
|
|
2
|
+
import { selectRootDirs } from "./root-selection.js";
|
|
3
3
|
import { DEPENDENCY_FILE_NAMES, PACKAGE_JSON_NAME, lockfileFor, } from "../core/constants.js";
|
|
4
4
|
import { createAssetDependencyError, } from "../core/errors.js";
|
|
5
5
|
import { getMessage } from "../i18n/index.js";
|
|
@@ -124,27 +124,6 @@ const selectMcpFiles = (rules, context, available) => {
|
|
|
124
124
|
}
|
|
125
125
|
return [...selected].sort();
|
|
126
126
|
};
|
|
127
|
-
const findMatchingVersionDirs = async (tree, vtree, targetSemver) => {
|
|
128
|
-
const root = vtree.get("");
|
|
129
|
-
if (!root)
|
|
130
|
-
return [];
|
|
131
|
-
const matched = [];
|
|
132
|
-
for (const name of [...root.subdirs].sort()) {
|
|
133
|
-
const meta = await readMetaJson(tree, vtree, name);
|
|
134
|
-
if (!meta) {
|
|
135
|
-
continue;
|
|
136
|
-
}
|
|
137
|
-
if (meta.conditions) {
|
|
138
|
-
const context = emptyEvalContext({
|
|
139
|
-
accelplatformVersion: { label: "", semver: targetSemver },
|
|
140
|
-
});
|
|
141
|
-
if (evaluateCondition(meta.conditions, context)) {
|
|
142
|
-
matched.push(name);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
return matched;
|
|
147
|
-
};
|
|
148
127
|
const walkDirectory = async (tree, vtree, dir, baseDir, parentMeta, context, collect) => {
|
|
149
128
|
const entries = [];
|
|
150
129
|
const node = vtree.get(dir);
|
|
@@ -259,10 +238,8 @@ export const walkAssetDir = async (tree, context) => {
|
|
|
259
238
|
const entries = await walkDirectory(tree, vtree, "", "", meta, context);
|
|
260
239
|
return deduplicateByPath(entries);
|
|
261
240
|
};
|
|
262
|
-
export const walkAssetRepo = async (tree,
|
|
263
|
-
const
|
|
264
|
-
const rootVtree = buildVirtualTree(rootFiles);
|
|
265
|
-
const versionDirs = await findMatchingVersionDirs(tree, rootVtree, targetSemver);
|
|
241
|
+
export const walkAssetRepo = async (tree, context, collect) => {
|
|
242
|
+
const versionDirs = await selectRootDirs(tree, context);
|
|
266
243
|
if (versionDirs.length === 0)
|
|
267
244
|
return [];
|
|
268
245
|
const files = await tree.listFiles(versionDirs);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Logger } from "../core/logger.js";
|
|
2
|
+
import type { DeployResult, ExistingFileHandler } from "../asset/deployer.js";
|
|
3
|
+
export declare const resolveExistingFilePolicy: (opts: {
|
|
4
|
+
overwrite?: boolean;
|
|
5
|
+
onExistingFile?: ExistingFileHandler;
|
|
6
|
+
nonInteractive?: boolean;
|
|
7
|
+
locale: string;
|
|
8
|
+
}) => {
|
|
9
|
+
skipExistingFiles?: boolean;
|
|
10
|
+
onExistingFile?: ExistingFileHandler;
|
|
11
|
+
};
|
|
12
|
+
export declare const reportExistingFiles: (result: DeployResult, logger: Logger, locale: string) => void;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import * as p from "@clack/prompts";
|
|
2
|
+
import { createCancelledError } from "../core/errors.js";
|
|
3
|
+
import { getMessage } from "../i18n/index.js";
|
|
4
|
+
import { sanitizeDisplayText } from "../utils/sanitize-text.js";
|
|
5
|
+
const createDefaultExistingFileHandler = (locale) => {
|
|
6
|
+
let sticky;
|
|
7
|
+
return async (path) => {
|
|
8
|
+
if (sticky === "all")
|
|
9
|
+
return "overwrite";
|
|
10
|
+
if (sticky === "skipAll")
|
|
11
|
+
return "skip";
|
|
12
|
+
const choice = await p.select({
|
|
13
|
+
message: getMessage("attach.overwritePrompt", locale, { path }),
|
|
14
|
+
options: [
|
|
15
|
+
{
|
|
16
|
+
value: "yes",
|
|
17
|
+
label: getMessage("attach.overwritePrompt.yes", locale),
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
value: "no",
|
|
21
|
+
label: getMessage("attach.overwritePrompt.no", locale),
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
value: "all",
|
|
25
|
+
label: getMessage("attach.overwritePrompt.all", locale),
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
value: "skipAll",
|
|
29
|
+
label: getMessage("attach.overwritePrompt.skipAll", locale),
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
});
|
|
33
|
+
if (p.isCancel(choice))
|
|
34
|
+
throw createCancelledError();
|
|
35
|
+
if (choice === "all") {
|
|
36
|
+
sticky = "all";
|
|
37
|
+
return "overwrite";
|
|
38
|
+
}
|
|
39
|
+
if (choice === "skipAll") {
|
|
40
|
+
sticky = "skipAll";
|
|
41
|
+
return "skip";
|
|
42
|
+
}
|
|
43
|
+
return choice === "yes" ? "overwrite" : "skip";
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
export const resolveExistingFilePolicy = (opts) => {
|
|
47
|
+
if (opts.overwrite ?? false)
|
|
48
|
+
return {};
|
|
49
|
+
const onExistingFile = opts.onExistingFile ??
|
|
50
|
+
(opts.nonInteractive
|
|
51
|
+
? undefined
|
|
52
|
+
: createDefaultExistingFileHandler(opts.locale));
|
|
53
|
+
return onExistingFile ? { onExistingFile } : { skipExistingFiles: true };
|
|
54
|
+
};
|
|
55
|
+
export const reportExistingFiles = (result, logger, locale) => {
|
|
56
|
+
for (const path of result.overwrittenFiles) {
|
|
57
|
+
logger.info(getMessage("attach.overwritten", locale, {
|
|
58
|
+
path: sanitizeDisplayText(path),
|
|
59
|
+
}));
|
|
60
|
+
}
|
|
61
|
+
for (const path of result.skippedFiles) {
|
|
62
|
+
logger.warn(getMessage("warning.fileExists", locale, {
|
|
63
|
+
path: sanitizeDisplayText(path),
|
|
64
|
+
}));
|
|
65
|
+
}
|
|
66
|
+
if (result.overwrittenFiles.length > 0) {
|
|
67
|
+
logger.info(getMessage("attach.overwriteSummary", locale, {
|
|
68
|
+
count: String(result.overwrittenFiles.length),
|
|
69
|
+
}));
|
|
70
|
+
}
|
|
71
|
+
if (result.skippedFiles.length > 0) {
|
|
72
|
+
logger.info(getMessage("attach.skipSummary", locale, {
|
|
73
|
+
count: String(result.skippedFiles.length),
|
|
74
|
+
}));
|
|
75
|
+
}
|
|
76
|
+
};
|
|
@@ -3,10 +3,13 @@ import type { PromptOptions, ResolvedOptions } from "../core/validation.js";
|
|
|
3
3
|
import { type DeployResult, type ExistingFileHandler, type ProgressCallbacks } from "../asset/deployer.js";
|
|
4
4
|
import { type generateMcpConfigs } from "../utils/mcp-generate.js";
|
|
5
5
|
import { type runEnsure, type syncDependencyArtifacts } from "../utils/runtime-ensure.js";
|
|
6
|
+
import { type MobilePrompts } from "../interactive/mobile-prompts.js";
|
|
7
|
+
import { type RunExternalCommand } from "../utils/external-command.js";
|
|
6
8
|
export type RunAttachDeps = {
|
|
7
9
|
projectDir: string;
|
|
8
10
|
locale?: string;
|
|
9
11
|
nonInteractive?: boolean;
|
|
12
|
+
projectType?: string;
|
|
10
13
|
name?: string;
|
|
11
14
|
artifactId?: string;
|
|
12
15
|
jugglingProject?: string;
|
|
@@ -21,6 +24,8 @@ export type RunAttachDeps = {
|
|
|
21
24
|
agents?: string[];
|
|
22
25
|
packageManager?: string;
|
|
23
26
|
overwrite?: boolean;
|
|
27
|
+
expoSdk?: string;
|
|
28
|
+
expoSkills?: boolean;
|
|
24
29
|
skipInstall?: boolean;
|
|
25
30
|
assetServerUrl?: string;
|
|
26
31
|
assetRef?: string;
|
|
@@ -33,9 +38,24 @@ export type RunAttachDeps = {
|
|
|
33
38
|
generateMcpConfigs?: typeof generateMcpConfigs;
|
|
34
39
|
syncDependencyArtifacts?: typeof syncDependencyArtifacts;
|
|
35
40
|
runEnsure?: typeof runEnsure;
|
|
41
|
+
runExternalCommand?: RunExternalCommand;
|
|
42
|
+
mobilePrompts?: Partial<MobilePrompts>;
|
|
36
43
|
};
|
|
37
44
|
export declare const runAttach: (deps: RunAttachDeps) => Promise<DeployResult>;
|
|
38
45
|
export declare const attachCommand: import("citty").CommandDef<{
|
|
46
|
+
readonly "project-type": {
|
|
47
|
+
readonly type: "string";
|
|
48
|
+
readonly description: "Project type (iap, mobile). Default: iap (interactive: mobile for Expo projects)";
|
|
49
|
+
};
|
|
50
|
+
readonly "expo-sdk": {
|
|
51
|
+
readonly type: "string";
|
|
52
|
+
readonly description: "(mobile) Expo SDK major version (e.g., 56). Default: detected from package.json";
|
|
53
|
+
};
|
|
54
|
+
readonly "expo-skills": {
|
|
55
|
+
readonly type: "boolean";
|
|
56
|
+
readonly description: "(mobile) Install the official Expo skills for Codex";
|
|
57
|
+
readonly negativeDescription: "(mobile) Do not install the official Expo skills";
|
|
58
|
+
};
|
|
39
59
|
readonly "juggling-project": {
|
|
40
60
|
readonly type: "string";
|
|
41
61
|
readonly description: "Path to IM-Juggling project";
|