@intra-mart/accel 0.2.0-dev.202605271647 → 0.2.0-dev.202606100307
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 +138 -4
- package/dist/asset/deployer.js +2 -3
- package/dist/asset/github-provider.d.ts +2 -0
- package/dist/asset/github-provider.js +37 -0
- package/dist/asset/local-provider.js +1 -22
- package/dist/commands/attach.d.ts +9 -1
- package/dist/commands/attach.js +21 -10
- package/dist/commands/deploy.d.ts +62 -0
- package/dist/commands/deploy.js +293 -0
- package/dist/commands/init.d.ts +9 -1
- package/dist/commands/init.js +21 -10
- package/dist/commands/login.d.ts +31 -0
- package/dist/commands/login.js +75 -0
- package/dist/core/constants.d.ts +2 -0
- package/dist/core/constants.js +3 -1
- package/dist/core/types.d.ts +41 -1
- package/dist/core/version-map.d.ts +2 -1
- package/dist/core/version-map.js +9 -22
- package/dist/deploy/api-client.d.ts +16 -0
- package/dist/deploy/api-client.js +105 -0
- package/dist/deploy/target-scanner.d.ts +5 -0
- package/dist/deploy/target-scanner.js +20 -0
- package/dist/deploy/target-selector.d.ts +11 -0
- package/dist/deploy/target-selector.js +16 -0
- package/dist/i18n/en.js +46 -0
- package/dist/i18n/ja.js +46 -0
- package/dist/i18n/zh_CN.js +46 -0
- package/dist/index.js +4 -0
- package/dist/interactive/credential-auth.d.ts +15 -0
- package/dist/interactive/credential-auth.js +61 -0
- package/dist/interactive/credentials-prompts.d.ts +4 -0
- package/dist/interactive/credentials-prompts.js +85 -0
- package/dist/interactive/prompts.js +56 -6
- package/dist/interactive/summary.js +8 -0
- package/dist/utils/args.d.ts +1 -0
- package/dist/utils/args.js +4 -0
- package/dist/utils/credentials.d.ts +12 -0
- package/dist/utils/credentials.js +46 -0
- package/dist/utils/date-formatter.d.ts +1 -0
- package/dist/utils/date-formatter.js +23 -0
- package/dist/utils/gitignore.d.ts +1 -0
- package/dist/utils/gitignore.js +23 -0
- package/dist/utils/https.d.ts +2 -0
- package/dist/utils/https.js +44 -0
- package/dist/utils/settings-io.d.ts +1 -0
- package/dist/utils/settings-io.js +8 -0
- package/package.json +2 -3
- package/assets/assets.tar.gz +0 -0
- package/dist/asset/default-source.d.ts +0 -1
- package/dist/asset/default-source.js +0 -6
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@ intra-mart Accel Platform (iAP) 開発プロジェクトの作成・管理を行
|
|
|
7
7
|
## 必要環境
|
|
8
8
|
|
|
9
9
|
- 以下のいずれかのパッケージマネージャ(`--package-manager` で選択、デフォルト: Bun)
|
|
10
|
-
- [Bun](https://bun.sh/)
|
|
10
|
+
- [Bun](https://bun.sh/)
|
|
11
11
|
- [npm](https://www.npmjs.com/)
|
|
12
12
|
- [Yarn](https://classic.yarnpkg.com/) (classic v1)
|
|
13
13
|
- [pnpm](https://pnpm.io/)
|
|
@@ -44,6 +44,8 @@ accel init my-project
|
|
|
44
44
|
```bash
|
|
45
45
|
accel init my-project \
|
|
46
46
|
--non-interactive \
|
|
47
|
+
--accelplatform-version 2026-Spring \
|
|
48
|
+
--module workflow \
|
|
47
49
|
--agent claude-code \
|
|
48
50
|
--locale ja
|
|
49
51
|
```
|
|
@@ -53,6 +55,8 @@ accel init my-project \
|
|
|
53
55
|
| オプション | 型 | 説明 | デフォルト |
|
|
54
56
|
|---|---|---|---|
|
|
55
57
|
| `[project-name]` (位置引数) | string | プロジェクト名(ディレクトリ名と一致) | `my-accel-project`(対話で変更可) |
|
|
58
|
+
| `--accelplatform-version` | string | iAPバージョン(例: `2026-Spring`) | 対話で選択 |
|
|
59
|
+
| `--module` | string | 使用モジュール(カンマ区切り) | 対話で選択 |
|
|
56
60
|
| `--agent` | string | エージェント種別(`claude-code`, `github-copilot`、カンマ区切り) | 自動検出 |
|
|
57
61
|
| `--locale` | string | ロケール(`ja`, `en`, `zh_CN`) | OS設定から自動検出 |
|
|
58
62
|
| `--artifact-id` | string | アーティファクトID(pomの `artifactId` に相当) | プロジェクト名と同値 |
|
|
@@ -66,6 +70,10 @@ accel init my-project \
|
|
|
66
70
|
| `--non-interactive` | boolean | 非対話モード(このモードでは `project-name` が必須) | `false` |
|
|
67
71
|
| `--no-git-init` | boolean | git initをスキップ | `false`(git initする) |
|
|
68
72
|
| `--skip-install` | boolean | 依存インストールをスキップ | `false` |
|
|
73
|
+
| `--asset-server-url` | string | 資材を取得するGitHubリポジトリのURL(デフォルトProviderの取得先を上書き) | `https://github.com/accelplatform/skills` |
|
|
74
|
+
| `--asset-ref` | string | GitHubから取得するブランチ/タグ/コミット | `experiment` |
|
|
75
|
+
| `--asset-source` | string | (デバッグ用)ローカル資材のパス(tarアーカイブまたは展開済みディレクトリ)。明示時はGitHubより優先 | - |
|
|
76
|
+
| `--debug-server-url` | string | (デバッグ用)ローカル資材サーバーのURL(`GET /archive`)。明示時はGitHubより優先 | - |
|
|
69
77
|
|
|
70
78
|
### `accel attach`
|
|
71
79
|
|
|
@@ -73,7 +81,7 @@ accel init my-project \
|
|
|
73
81
|
|
|
74
82
|
```bash
|
|
75
83
|
cd my-existing-project
|
|
76
|
-
accel attach --non-interactive
|
|
84
|
+
accel attach --non-interactive --accelplatform-version 2026-Spring --module workflow
|
|
77
85
|
```
|
|
78
86
|
|
|
79
87
|
`init` との違い:
|
|
@@ -89,6 +97,8 @@ accel attach --non-interactive
|
|
|
89
97
|
| オプション | 型 | 説明 | デフォルト |
|
|
90
98
|
|---|---|---|---|
|
|
91
99
|
| `--name` | string | プロジェクト名 | カレントディレクトリ名 |
|
|
100
|
+
| `--accelplatform-version` | string | iAPバージョン(例: `2026-Spring`) | 対話で選択 |
|
|
101
|
+
| `--module` | string | 使用モジュール(カンマ区切り) | 対話で選択 |
|
|
92
102
|
| `--agent` | string | エージェント種別(`claude-code`, `github-copilot`、カンマ区切り) | 自動検出 |
|
|
93
103
|
| `--locale` | string | ロケール(`ja`, `en`, `zh_CN`) | OS設定から自動検出 |
|
|
94
104
|
| `--artifact-id` | string | アーティファクトID(pomの `artifactId` に相当) | プロジェクト名と同値 |
|
|
@@ -102,6 +112,10 @@ accel attach --non-interactive
|
|
|
102
112
|
| `--overwrite` | boolean | 既存ファイルの上書き確認を行わず、全て上書きする | `false`(対話で確認 / 非対話ではスキップ) |
|
|
103
113
|
| `--non-interactive` | boolean | 非対話モード | `false` |
|
|
104
114
|
| `--skip-install` | boolean | 依存インストールをスキップ | `false` |
|
|
115
|
+
| `--asset-server-url` | string | 資材を取得するGitHubリポジトリのURL(デフォルトProviderの取得先を上書き) | `https://github.com/accelplatform/skills` |
|
|
116
|
+
| `--asset-ref` | string | GitHubから取得するブランチ/タグ/コミット | `experiment` |
|
|
117
|
+
| `--asset-source` | string | (デバッグ用)ローカル資材のパス(tarアーカイブまたは展開済みディレクトリ)。明示時はGitHubより優先 | - |
|
|
118
|
+
| `--debug-server-url` | string | (デバッグ用)ローカル資材サーバーのURL(`GET /archive`)。明示時はGitHubより優先 | - |
|
|
105
119
|
|
|
106
120
|
### `accel detach`
|
|
107
121
|
|
|
@@ -116,6 +130,110 @@ accel detach
|
|
|
116
130
|
- ユーザーが編集したファイルはスキップ(警告表示)
|
|
117
131
|
- `.accel/` ディレクトリを削除
|
|
118
132
|
|
|
133
|
+
### `accel login`
|
|
134
|
+
|
|
135
|
+
iAP の接続情報(エンドポイントURL・APIキー)を入力し、`.accel/credentials.json` に保存します。`accel deploy` を実行する前に、コマンドラインから直接接続情報を設定しておけます。
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
cd my-project
|
|
139
|
+
accel login
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
- `endpoint`(テキスト入力)と `apiKey`(マスク入力)を対話で入力します。
|
|
143
|
+
- 入力したトークンの有効性は、トークン検証API(`{endpoint}/oauth/token/verify`)を呼び出して確認します。検証に失敗(401 など)した場合や接続エラーの場合は、その場で再入力を促します。
|
|
144
|
+
- 検証に成功した時点で `.accel/credentials.json` に保存します。**APIキーはシークレットのため、ファイルは自動的に `.gitignore` に追加されます**(コミット対象外)。
|
|
145
|
+
|
|
146
|
+
#### 非対話モード
|
|
147
|
+
|
|
148
|
+
CIでの利用を想定し、プロンプトを出さずに接続情報を検証・保存するモードです。
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
ACCEL_API_KEY=*** accel login \
|
|
152
|
+
--non-interactive \
|
|
153
|
+
--endpoint https://example.com/imart
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
- `endpoint` / `apiKey` は **フラグ > 環境変数 > `.accel/credentials.json`** の優先順位で解決します。
|
|
157
|
+
- `endpoint`: `--endpoint` / `ACCEL_ENDPOINT`
|
|
158
|
+
- `apiKey`: `--api-key` / `ACCEL_API_KEY`
|
|
159
|
+
- **APIキーはシークレット情報のため、CI では `ACCEL_API_KEY` 環境変数での指定を推奨します**(`--api-key` はプロセス一覧やCIログに漏れ得ます)。
|
|
160
|
+
- トークン検証は1回だけ実行します。**失敗時は再入力せず、エラーメッセージを表示して非0終了します**。
|
|
161
|
+
- 検証成功時に `.accel/credentials.json` へ保存します(対話モードと同様、`.gitignore` に自動追記)。
|
|
162
|
+
- `endpoint` / `apiKey` のいずれかが解決できない場合はエラー終了します。
|
|
163
|
+
|
|
164
|
+
#### オプション一覧
|
|
165
|
+
|
|
166
|
+
| オプション | 型 | 説明 | デフォルト |
|
|
167
|
+
|---|---|---|---|
|
|
168
|
+
| `--endpoint` | string | iAPのベースURL(環境変数 `ACCEL_ENDPOINT` でも指定可) | 対話で入力 / 保存値 |
|
|
169
|
+
| `--api-key` | string | OAuth Bearerトークン(**環境変数 `ACCEL_API_KEY` 推奨**) | 対話で入力 / 保存値 |
|
|
170
|
+
| `--non-interactive` | boolean | 非対話モード(プロンプトを出さず、検証失敗時は非0終了) | `false` |
|
|
171
|
+
|
|
172
|
+
### `accel deploy`
|
|
173
|
+
|
|
174
|
+
ビルド成果物(`./target/` 配下の zip)を iAP のステージング環境へデプロイします。対話モードに加え、CIでの利用を想定した非対話モード(`--non-interactive`)に対応します。
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
cd my-project
|
|
178
|
+
accel deploy
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
- プロジェクトのルートで実行します。ビルド成果物は `./target/` 配下に出力されている前提です(`mvn package` で生成される `<artifactId>-<version>.zip`)。
|
|
182
|
+
- 初回実行時に iAP の接続情報(エンドポイントURL・APIキー)の入力を求めます。入力値は `.accel/credentials.json` に保存され、保存値で接続できる限り次回以降は再入力不要です。事前に `accel login`(前述)で設定しておくこともできます。
|
|
183
|
+
- **APIキーはシークレット情報のため、`.accel/credentials.json` は自動的に `.gitignore` に追加されます**(コミット対象外)。
|
|
184
|
+
- デプロイ実行前に、トークン検証API(`/oauth/token/verify`)で接続情報の有効性を確認します。保存済みのエンドポイント/APIキーが誤っていて**接続エラーや認証エラー(401 など)になった場合は、その場で再入力を促し、接続できるまでリトライします**。中断したい場合は ESC / Ctrl+C で抜けられます。
|
|
185
|
+
- 既存のステージング環境を一覧から選択します(ステージングは iAP 側で事前に作成しておく必要があります)。
|
|
186
|
+
- デプロイ対象の zip は、`.accel/settings.json` の `artifactId` と `projectVersion` から `<artifactId>-<projectVersion>.zip` を `./target/` 配下で完全一致で特定し、見つかれば自動選択します。
|
|
187
|
+
- 該当ファイルが見つからない場合、または `.accel/settings.json` が無い場合は、従来通り `./target/` 配下の zip を一覧から選択します(単一なら自動選択)。
|
|
188
|
+
- この選択式の一覧では、`<artifactId>-main-storage.zip` / `<artifactId>-main-public.zip` / `<artifactId>-sample-jssp-internal.zip` のような**バージョンを含まない途中成果物**(`<artifactId>-` の直後が数字で始まらない zip)を除外します。
|
|
189
|
+
- ただし、除外した結果 0 件になった場合(`.accel/settings.json` の `artifactId` と実ファイル名の artifactId が乖離しているケースなど)は、除外せず `./target/` 配下の全 zip を選択候補とします。
|
|
190
|
+
- いずれの場合もデプロイ実行前に最終確認を行います。
|
|
191
|
+
- 送信時、zip は imm 形式としてアップロードされます(送信時のファイル名のみ `.imm` に変更され、ディスク上のファイルはそのままです)。
|
|
192
|
+
|
|
193
|
+
#### 非対話モード
|
|
194
|
+
|
|
195
|
+
CIでの利用を想定し、プロンプトを一切出さずにデプロイを実行するモードです。
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
ACCEL_API_KEY=*** accel deploy \
|
|
199
|
+
--non-interactive \
|
|
200
|
+
--endpoint https://example.com/imart \
|
|
201
|
+
--staging-id my-staging \
|
|
202
|
+
--file ./target/my-app-1.0.0.zip \
|
|
203
|
+
--description "CI deploy"
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
- **接続情報**は login と同じく **フラグ > 環境変数(`ACCEL_ENDPOINT` / `ACCEL_API_KEY`)> `.accel/credentials.json`** の優先順位で解決します(APIキーは `ACCEL_API_KEY` 環境変数での指定を推奨)。
|
|
207
|
+
- デプロイ前にトークン検証を1回だけ実行します。**失敗時は再入力せず、エラーメッセージを表示して非0終了します**。
|
|
208
|
+
- `--staging-id` は**必須**です(一覧選択は行いません。未指定はエラー終了。存在しないステージングはデプロイ時の 404 として表面化します)。
|
|
209
|
+
- デプロイ対象 zip:
|
|
210
|
+
- `--file` を指定した場合はそのパス(`./target/` 配下に限定しません)を使います。ファイルが存在しなければエラー終了します。
|
|
211
|
+
- `--file` 未指定の場合は対話モードと同じ自動特定(`<artifactId>-<projectVersion>.zip` 完全一致)を試みます。**自動特定できない場合**(settings 無し/完全一致無し/複数候補)は `--file` 指定が必要な旨を表示してエラー終了します。`./target/` に zip が 1 件も無い場合は、ビルド未実行の旨(`mvn package` 等の実行を促す)を表示してエラー終了します。
|
|
212
|
+
- `--description` は任意です。最終確認プロンプトは出さず、即デプロイします。
|
|
213
|
+
- フラグ/環境変数で渡した接続情報は **`.accel/credentials.json` に保存しません**(CIランナーにシークレット情報を残さないため)。
|
|
214
|
+
|
|
215
|
+
#### オプション一覧
|
|
216
|
+
|
|
217
|
+
| オプション | 型 | 説明 | デフォルト |
|
|
218
|
+
|---|---|---|---|
|
|
219
|
+
| `--endpoint` | string | iAPのベースURL(環境変数 `ACCEL_ENDPOINT` でも指定可) | 保存値 / 対話で入力 |
|
|
220
|
+
| `--api-key` | string | OAuth Bearerトークン(**環境変数 `ACCEL_API_KEY` 推奨**) | 保存値 / 対話で入力 |
|
|
221
|
+
| `--staging-id` | string | デプロイ先ステージングID(**非対話モードでは必須**) | 対話で一覧選択 |
|
|
222
|
+
| `--file` | string | デプロイする zip のパス(`./target/` 配下に限定しない) | 自動特定 / 対話で選択 |
|
|
223
|
+
| `--description` | string | デプロイメントの説明 | `""` |
|
|
224
|
+
| `--non-interactive` | boolean | 非対話モード(プロンプトを出さず、失敗時は非0終了) | `false` |
|
|
225
|
+
|
|
226
|
+
#### 接続情報ファイル `.accel/credentials.json`
|
|
227
|
+
|
|
228
|
+
```json
|
|
229
|
+
{
|
|
230
|
+
"endpoint": "https://example.com/imart",
|
|
231
|
+
"apiKey": "<OAuth Bearer トークン>"
|
|
232
|
+
}
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
`endpoint` には iAP のベースURL を指定します。API パス(`/api/bearer/development/...`)は CLI が組み立てます。
|
|
236
|
+
|
|
119
237
|
## IM-Juggling連携
|
|
120
238
|
|
|
121
239
|
`--juggling-project` オプションでIM-Jugglingプロジェクトのパスを指定すると、`juggling.im` からiAPバージョンと使用モジュールを自動検出します。
|
|
@@ -144,8 +262,24 @@ my-project/
|
|
|
144
262
|
|
|
145
263
|
- `.accel/settings.json` — プロジェクト設定。git管理対象、手動編集可
|
|
146
264
|
- `.accel/hashsum.txt` — 配備ファイルのSHA-1。`detach` 時の変更検出に使用
|
|
265
|
+
- `.accel/credentials.json` — iAP接続情報(endpoint / APIキー)。`accel deploy` 初回実行時に生成。APIキーを含むため `.gitignore` 対象(git管理対象外)
|
|
147
266
|
|
|
148
267
|
## 対応iAPバージョン
|
|
149
268
|
|
|
150
|
-
|
|
151
|
-
|
|
269
|
+
2025-Spring (8.0.37) 以降の iAP バージョンを選択可能です。
|
|
270
|
+
|
|
271
|
+
## 入力値のバリデーション
|
|
272
|
+
|
|
273
|
+
CLIに渡された値および対話で入力された値は、以下のルールでバリデーションされます。違反する値は対話モードでは再入力を促し、非対話モードではエラーメッセージを表示して終了します。
|
|
274
|
+
|
|
275
|
+
| オプション | ルール |
|
|
276
|
+
|-----------|------|
|
|
277
|
+
| `[project-name]` / `--name` | 空文字不可。ディレクトリ名として不正な文字を含まない(`/ \ : * ? " < > \|`、制御文字、先頭末尾の空白/ドット) |
|
|
278
|
+
| `--artifact-id` | Maven artifactId 規約: `^[A-Za-z0-9][A-Za-z0-9._-]*$` |
|
|
279
|
+
| `--group` | Maven groupId 規約: ドット区切りの識別子 `^[A-Za-z_$][\w$]*(\.[A-Za-z_$][\w$]*)*$` |
|
|
280
|
+
| `--project-version` | Maven version 規約: `^[A-Za-z0-9][A-Za-z0-9._-]*$` |
|
|
281
|
+
| `--accelplatform-version` | 対応iAPバージョン一覧(`2025-Spring` 以降)に含まれる値 |
|
|
282
|
+
| `--module` | `workflow`, `bpm`, `copilot`, `imbox`, `pdfd`, `kaiden` のいずれか(各要素) |
|
|
283
|
+
| `--database` | `postgresql`, `oracle`, `sqlserver` のいずれか |
|
|
284
|
+
| `--agent` | `claude-code`, `github-copilot` のいずれか(各要素) |
|
|
285
|
+
| `--package-manager` | `bun`, `npm`, `yarn`, `pnpm` のいずれか |
|
package/dist/asset/deployer.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { readFile, writeFile, mkdir, stat } from "node:fs/promises";
|
|
2
2
|
import { join, dirname, resolve, sep } from "node:path";
|
|
3
|
-
import { labelToSemver } from "../core/version-map.js";
|
|
4
3
|
import { walkAssetRepo } from "./walker.js";
|
|
5
4
|
import { processMarkdown } from "../markdown/processor.js";
|
|
6
5
|
import { applyRegexReplacements } from "./regex-replacement.js";
|
|
@@ -57,7 +56,7 @@ export const deployAssets = async (options) => {
|
|
|
57
56
|
try {
|
|
58
57
|
progress?.onFetchStart?.();
|
|
59
58
|
const repoDir = await provider.fetch();
|
|
60
|
-
const semver =
|
|
59
|
+
const semver = settings.accelplatformVersion.semver;
|
|
61
60
|
const context = {
|
|
62
61
|
version: semver,
|
|
63
62
|
modules: settings.modules,
|
|
@@ -67,7 +66,7 @@ export const deployAssets = async (options) => {
|
|
|
67
66
|
artifactId: settings.artifactId,
|
|
68
67
|
group: settings.group,
|
|
69
68
|
description: settings.description,
|
|
70
|
-
accelplatformVersion: settings.accelplatformVersion,
|
|
69
|
+
accelplatformVersion: settings.accelplatformVersion.label,
|
|
71
70
|
database: settings.database,
|
|
72
71
|
projectVersion: settings.projectVersion,
|
|
73
72
|
packageManager: settings.packageManager,
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { join } from "node:path";
|
|
2
|
+
import { mkdir, rm, readdir } from "node:fs/promises";
|
|
3
|
+
import { extractTarGz, createTempDir } from "../utils/archive.js";
|
|
4
|
+
import { downloadFile } from "../utils/https.js";
|
|
5
|
+
export const createGitHubAssetProvider = (repoUrl, ref) => {
|
|
6
|
+
let tmpDir = null;
|
|
7
|
+
return {
|
|
8
|
+
fetch: async () => {
|
|
9
|
+
tmpDir = await createTempDir("accel-assets-");
|
|
10
|
+
const archivePath = join(tmpDir, "assets.tar.gz");
|
|
11
|
+
const extractDir = join(tmpDir, "repo");
|
|
12
|
+
await mkdir(extractDir, { recursive: true });
|
|
13
|
+
const base = repoUrl.replace(/\/+$/, "");
|
|
14
|
+
const archiveUrl = `${base}/archive/${ref}.tar.gz`;
|
|
15
|
+
try {
|
|
16
|
+
await downloadFile(archiveUrl, archivePath);
|
|
17
|
+
}
|
|
18
|
+
catch (err) {
|
|
19
|
+
const reason = err instanceof Error ? err.message : String(err);
|
|
20
|
+
throw new Error(`Failed to fetch the asset repository from ${archiveUrl}. Check the URL and ref: ${reason}`);
|
|
21
|
+
}
|
|
22
|
+
await extractTarGz(archivePath, extractDir);
|
|
23
|
+
const entries = await readdir(extractDir, { withFileTypes: true });
|
|
24
|
+
const dirs = entries.filter((e) => e.isDirectory());
|
|
25
|
+
if (dirs.length !== 1) {
|
|
26
|
+
throw new Error(`Unexpected tarball structure (top-level directory count: ${dirs.length}).`);
|
|
27
|
+
}
|
|
28
|
+
return join(extractDir, dirs[0].name);
|
|
29
|
+
},
|
|
30
|
+
cleanup: async () => {
|
|
31
|
+
if (tmpDir) {
|
|
32
|
+
await rm(tmpDir, { recursive: true, force: true }).catch(() => { });
|
|
33
|
+
tmpDir = null;
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
};
|
|
@@ -1,28 +1,7 @@
|
|
|
1
|
-
import { get } from "node:http";
|
|
2
|
-
import { createWriteStream } from "node:fs";
|
|
3
1
|
import { join } from "node:path";
|
|
4
2
|
import { mkdir, rm } from "node:fs/promises";
|
|
5
3
|
import { extractTarGz, createTempDir } from "../utils/archive.js";
|
|
6
|
-
|
|
7
|
-
return new Promise((resolve, reject) => {
|
|
8
|
-
const file = createWriteStream(destPath);
|
|
9
|
-
get(url, (response) => {
|
|
10
|
-
if (response.statusCode !== 200) {
|
|
11
|
-
file.close();
|
|
12
|
-
reject(new Error(`HTTP ${response.statusCode} when downloading from ${url}`));
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
response.pipe(file);
|
|
16
|
-
file.on("finish", () => {
|
|
17
|
-
file.close();
|
|
18
|
-
resolve();
|
|
19
|
-
});
|
|
20
|
-
}).on("error", (err) => {
|
|
21
|
-
file.close();
|
|
22
|
-
reject(err);
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
};
|
|
4
|
+
import { downloadFile } from "../utils/https.js";
|
|
26
5
|
export const createLocalAssetProvider = (serverUrl) => {
|
|
27
6
|
let tmpDir = null;
|
|
28
7
|
return {
|
|
@@ -66,11 +66,19 @@ export declare const attachCommand: import("citty").CommandDef<{
|
|
|
66
66
|
description: string;
|
|
67
67
|
default: false;
|
|
68
68
|
};
|
|
69
|
+
"asset-server-url": {
|
|
70
|
+
type: "string";
|
|
71
|
+
description: string;
|
|
72
|
+
};
|
|
73
|
+
"asset-ref": {
|
|
74
|
+
type: "string";
|
|
75
|
+
description: string;
|
|
76
|
+
};
|
|
69
77
|
"asset-source": {
|
|
70
78
|
type: "string";
|
|
71
79
|
description: string;
|
|
72
80
|
};
|
|
73
|
-
"
|
|
81
|
+
"debug-server-url": {
|
|
74
82
|
type: "string";
|
|
75
83
|
description: string;
|
|
76
84
|
};
|
package/dist/commands/attach.js
CHANGED
|
@@ -2,12 +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 { CLI_VERSION, DEFAULT_ASSET_REPO_URL, DEFAULT_ASSET_REF, } from "../core/constants.js";
|
|
6
6
|
import { runPrompts } from "../interactive/prompts.js";
|
|
7
7
|
import { deployAssets, } from "../asset/deployer.js";
|
|
8
8
|
import { createLocalAssetProvider } from "../asset/local-provider.js";
|
|
9
9
|
import { createFileAssetProvider } from "../asset/file-provider.js";
|
|
10
|
-
import {
|
|
10
|
+
import { createGitHubAssetProvider } from "../asset/github-provider.js";
|
|
11
11
|
import { getMessage } from "../i18n/index.js";
|
|
12
12
|
import { detectLocale } from "../utils/locale-detect.js";
|
|
13
13
|
import { printSummary } from "../interactive/summary.js";
|
|
@@ -86,13 +86,21 @@ export const attachCommand = defineCommand({
|
|
|
86
86
|
description: "Non-interactive mode",
|
|
87
87
|
default: false,
|
|
88
88
|
},
|
|
89
|
+
"asset-server-url": {
|
|
90
|
+
type: "string",
|
|
91
|
+
description: "GitHub repository URL to fetch assets from (overrides the default repository)",
|
|
92
|
+
},
|
|
93
|
+
"asset-ref": {
|
|
94
|
+
type: "string",
|
|
95
|
+
description: "Git ref (branch/tag/commit) to fetch from the GitHub asset repository. Default: master",
|
|
96
|
+
},
|
|
89
97
|
"asset-source": {
|
|
90
98
|
type: "string",
|
|
91
|
-
description: "Local asset source path (tar archive or extracted directory)
|
|
99
|
+
description: "(debug) Local asset source path (tar archive or extracted directory)",
|
|
92
100
|
},
|
|
93
|
-
"
|
|
101
|
+
"debug-server-url": {
|
|
94
102
|
type: "string",
|
|
95
|
-
description: "
|
|
103
|
+
description: "(debug) Local asset server URL serving GET /archive",
|
|
96
104
|
},
|
|
97
105
|
},
|
|
98
106
|
run: async ({ args }) => {
|
|
@@ -155,11 +163,14 @@ export const attachCommand = defineCommand({
|
|
|
155
163
|
jugglingProject: resolved.jugglingProject,
|
|
156
164
|
deployedAssets: {},
|
|
157
165
|
};
|
|
158
|
-
const
|
|
159
|
-
const
|
|
160
|
-
const provider =
|
|
161
|
-
?
|
|
162
|
-
:
|
|
166
|
+
const assetSource = args["asset-source"];
|
|
167
|
+
const debugServerUrl = args["debug-server-url"];
|
|
168
|
+
const provider = assetSource
|
|
169
|
+
? createFileAssetProvider(assetSource)
|
|
170
|
+
: debugServerUrl
|
|
171
|
+
? createLocalAssetProvider(debugServerUrl)
|
|
172
|
+
: createGitHubAssetProvider(args["asset-server-url"] ??
|
|
173
|
+
DEFAULT_ASSET_REPO_URL, args["asset-ref"] ?? DEFAULT_ASSET_REF);
|
|
163
174
|
const isInteractive = !args["non-interactive"];
|
|
164
175
|
const overwriteFlag = args.overwrite;
|
|
165
176
|
if (isInteractive) {
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { AccelCredentials, StagingResponse } from "../core/types.js";
|
|
2
|
+
import { type ApiClient } from "../deploy/api-client.js";
|
|
3
|
+
export declare const toImmFileName: (zipPath: string) => string;
|
|
4
|
+
type ConfirmInfo = {
|
|
5
|
+
endpoint: string;
|
|
6
|
+
stagingId: string;
|
|
7
|
+
sourceFile: string;
|
|
8
|
+
sentAs: string;
|
|
9
|
+
};
|
|
10
|
+
export type DeployPrompts = {
|
|
11
|
+
selectStaging: (stagings: StagingResponse[], locale: string) => Promise<string>;
|
|
12
|
+
selectZip: (zips: string[], locale: string) => Promise<string>;
|
|
13
|
+
description: (locale: string) => Promise<string>;
|
|
14
|
+
confirm: (info: ConfirmInfo, locale: string) => Promise<boolean>;
|
|
15
|
+
};
|
|
16
|
+
export type RunDeployDeps = {
|
|
17
|
+
projectDir: string;
|
|
18
|
+
locale?: string;
|
|
19
|
+
nonInteractive?: boolean;
|
|
20
|
+
endpoint?: string;
|
|
21
|
+
apiKey?: string;
|
|
22
|
+
stagingId?: string;
|
|
23
|
+
file?: string;
|
|
24
|
+
description?: string;
|
|
25
|
+
env?: Record<string, string | undefined>;
|
|
26
|
+
ensureCredentials?: (projectDir: string, locale: string, seed?: Partial<AccelCredentials>) => Promise<AccelCredentials>;
|
|
27
|
+
repromptCredentials?: (current: AccelCredentials, locale: string) => Promise<AccelCredentials>;
|
|
28
|
+
resolveCredentialsOrThrow?: (projectDir: string, locale: string, seed: Partial<AccelCredentials>) => Promise<AccelCredentials>;
|
|
29
|
+
persistCredentials?: (projectDir: string, creds: AccelCredentials) => Promise<void>;
|
|
30
|
+
scanTargets?: (projectDir: string) => Promise<string[]>;
|
|
31
|
+
apiClientFactory?: (endpoint: string, apiKey: string) => ApiClient;
|
|
32
|
+
prompts?: DeployPrompts;
|
|
33
|
+
};
|
|
34
|
+
export declare const runDeploy: (deps: RunDeployDeps) => Promise<void>;
|
|
35
|
+
export declare const deployCommand: import("citty").CommandDef<{
|
|
36
|
+
endpoint: {
|
|
37
|
+
type: "string";
|
|
38
|
+
description: string;
|
|
39
|
+
};
|
|
40
|
+
"api-key": {
|
|
41
|
+
type: "string";
|
|
42
|
+
description: string;
|
|
43
|
+
};
|
|
44
|
+
"staging-id": {
|
|
45
|
+
type: "string";
|
|
46
|
+
description: string;
|
|
47
|
+
};
|
|
48
|
+
file: {
|
|
49
|
+
type: "string";
|
|
50
|
+
description: string;
|
|
51
|
+
};
|
|
52
|
+
description: {
|
|
53
|
+
type: "string";
|
|
54
|
+
description: string;
|
|
55
|
+
};
|
|
56
|
+
"non-interactive": {
|
|
57
|
+
type: "boolean";
|
|
58
|
+
description: string;
|
|
59
|
+
default: false;
|
|
60
|
+
};
|
|
61
|
+
}>;
|
|
62
|
+
export {};
|