cws-release 0.1.3 → 0.1.5

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/INSTALL.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # Install
2
2
 
3
- Four options. Pick by **how many extensions you maintain**, not by taste:
3
+ Requires **Node.js 22 or later**. Installing the CLI is only one part of first-time setup: the extension item must already exist, and you must enable the Chrome Web Store API, authorize a service account, and fill in `.cws.json`. Follow the [one-time setup in the README](README.md#one-time-setup) before the first release.
4
+
5
+ For a quick trial or one-off release, use `npx`. For a project you maintain, use a dev dependency. The four options:
4
6
 
5
7
  | | Option | What you run | Version lives in | Best for |
6
8
  | --- | --- | --- | --- | --- |
package/README.md CHANGED
@@ -11,20 +11,133 @@ exact reason it refused.
11
11
 
12
12
  ## Quick start
13
13
 
14
+ Requires **Node.js 22 or later** and an extension item that already exists in the Chrome Web Store. Creating the item and completing its listing and privacy details still require the Developer Dashboard.
15
+
14
16
  ```sh
15
17
  npm i -D cws-release # in your extension repository
16
18
  npx cws-release init # once: writes .cws.json + the agent skill
19
+ # Complete the one-time Google setup below; fill in .cws.json and the key path
20
+ export CWS_SERVICE_ACCOUNT_FILE="$HOME/.config/cws/service-account.json"
21
+ npx cws-release check # also checks store access when both IDs are set
22
+ npx cws-release release --staged # submit for review; deploy manually after approval
23
+ ```
24
+
25
+ First-time path: **confirm the item exists → enable the API and authorize a service account → fill in `publisherId`, `itemId` and the zip path → set the key → run `check` → publish**. See [one-time setup](#one-time-setup); it is done once per publisher account.
26
+
27
+ With only the key configured, `check` verifies authentication. It checks store access only when both `publisherId` and `itemId` are set. Plain `release` uses `DEFAULT_PUBLISH` and goes live automatically after review; use `--staged` for a first release or whenever you want to deploy manually.
28
+
29
+ ## One-time setup
30
+
31
+ Once per **publisher account**, not per extension. Four pieces of state have to
32
+ agree — the API enabled, the key, the dashboard's service-account entry, and
33
+ `.cws.json` — and any mismatch fails with `PUBLISHER_FORBIDDEN` (HTTP 403) even
34
+ when the key itself is perfectly valid. One symptom, four possible causes: work
35
+ through them in this order and the first failure names the piece that is wrong.
36
+
37
+ **1. Enable the Chrome Web Store API** in a Google Cloud project:
38
+
39
+ <https://console.cloud.google.com/apis/library/chromewebstore.googleapis.com>
40
+
41
+ An account that is otherwise fine but runs in a project with this API disabled
42
+ is rejected at the call, not at authentication — it looks like a permissions
43
+ bug and is not one. Select the right project in the console's project picker
44
+ before you click **Enable**.
45
+
46
+ ![The Chrome Web Store API product page in Google Cloud, with the Enable button](docs/assets/enable-api.webp)
47
+
48
+ *The product page carries the **Enable** button. Menu labels follow your console
49
+ language, and Google rearranges these pages from time to time — if the layout
50
+ differs, look for the API name and an enable control.*
51
+
52
+ **2. Create a service account, with no IAM roles:**
53
+
54
+ <https://console.cloud.google.com/iam-admin/serviceaccounts/create>
55
+
56
+ Name it something recognisable (`cws-release`), then **Create and continue** →
57
+ **Continue** → **Done**. Grant no role: access comes from step 4, not from IAM.
58
+
59
+ **3. Create and download a JSON key.** Open the account → **Keys** → **Add key**
60
+ → **Create new key** → **JSON**. Move it out of `~/Downloads` and lock it down
61
+ before you do anything else — see [Key handling](#key-handling):
62
+
63
+ ```sh
64
+ mkdir -p ~/.config/cws
65
+ mv ~/Downloads/<project>-<hex>.json ~/.config/cws/service-account.json
66
+ chmod 700 ~/.config/cws
67
+ chmod 600 ~/.config/cws/service-account.json
68
+ ```
69
+
70
+ **4. Authorize the account in the Developer Dashboard — this is the step that
71
+ actually grants access.** Skipping it returns `PUBLISHER_FORBIDDEN` for every
72
+ item, real or invented:
73
+
74
+ <https://chrome.google.com/webstore/devconsole>
75
+
76
+ Open **Settings** from the sidebar. The service-account field is in the
77
+ **Management** section — *not* under the **Account → Profile** group, which
78
+ holds the display name, contact email, trader declaration and address.
79
+ Paste the `…@….iam.gserviceaccount.com` email shown in the Google Cloud console
80
+ and save; it then appears in the table with today's join date. One publisher
81
+ accepts **one** service account, and the publisher account needs 2-step
82
+ verification enabled.
83
+
84
+ ![The dashboard Settings page, with the Service account table in the Management section](docs/assets/service-account.webp)
85
+
86
+ *The **Service account** table sits in the **Management** block of Settings.
87
+ The one row is the account, keyed by email, with its join date. Google's own
88
+ labels may change; the block name is the anchor, not the row.*
89
+
90
+ **5. Copy the two identifiers into `.cws.json`.** Both are on the **Settings**
91
+ page:
92
+
93
+ - **Publisher ID** — a field under **Profile** in the Account group; it is also
94
+ the `/webstore/devconsole/<publisherId>/settings` segment of the URL.
95
+ - **Item ID** — the 32-character extension id, from the item's own URL in the
96
+ dashboard or from `chrome://extensions`.
17
97
 
98
+ These are per-publisher values: copy yours, never another project's. Identifiers
99
+ are safe to commit; the key is not.
100
+
101
+ ![The Settings page showing the Publisher ID field under Profile](docs/assets/publisher-id.webp)
102
+
103
+ *The **Publisher ID** is the short field under **Profile**, next to the display
104
+ name and contact email — not in the **Management** block above. In this shot
105
+ it is partly redacted; yours is a UUID-like string such as
106
+ `7c6b…-…-…-…-…`.*
107
+
108
+ **6. Point the CLI at the key** — in the shell you will release from, or as a CI
109
+ secret:
110
+
111
+ ```sh
18
112
  export CWS_SERVICE_ACCOUNT_FILE="$HOME/.config/cws/service-account.json"
19
- npx cws-release check # proves the credentials work, in three seconds
20
- npx cws-release release # upload -> submit for review -> print the state
21
113
  ```
22
114
 
23
- Prerequisites (`check` will tell you what is missing): the item already exists
24
- in the store, the publisher has 2FA on, and the service account is added under
25
- **Account** in the [Developer Dashboard](https://chrome.google.com/webstore/devconsole).
26
- The API cannot create a new item — the first upload and the listing tabs are
27
- manual.
115
+ With both identifiers filled in `.cws.json`, run `npx cws-release check`. It exchanges the token and calls `fetchStatus`, so a `PUBLISHER_FORBIDDEN` at this point means step 4 or 5 — not the key. Without the IDs, `check` verifies authentication only.
116
+
117
+ `CWS_ACCESS_TOKEN` skips the key entirely for a one-off run
118
+ (`gcloud auth print-access-token --scopes=https://www.googleapis.com/auth/chromewebstore`);
119
+ it expires in about an hour.
120
+
121
+ ## Key handling
122
+
123
+ The service-account key is a long-lived credential for every item under the
124
+ publisher. Treat it as one secret, not as config:
125
+
126
+ - **Keep it out of the repository.** `~/.config/cws/` or a CI secret variable —
127
+ never `.cws.json`, which is committed, and never pasted into an issue or a
128
+ chat. When a conversation means to *report* a key, report its path and the
129
+ account email instead; neither is a secret.
130
+ - **Directory `700`, file `600`** (the `chmod` in step 3). Move it out of
131
+ `~/Downloads` straight after Google hands it over: download folders are
132
+ synced, indexed and scanned by other tools.
133
+ - **No `set -x` around it**, and no `--verbose` on a script that exports it. The
134
+ CLI never prints the key; your shell should not either.
135
+ - **Lost or exposed?** Delete the key in Google Cloud (**Keys** → delete),
136
+ create a new one, and point `CWS_SERVICE_ACCOUNT_FILE` at it. The dashboard
137
+ entry keys off the account *email*, which does not change, so step 4 stands.
138
+ - Doubling as a backstop, `.gitignore` in every extension repository can carry
139
+ `service-account*.json`. A backstop is not a plan — the file does not belong
140
+ in the working tree in the first place.
28
141
 
29
142
  ## Why this one
30
143
 
@@ -34,18 +147,16 @@ manual.
34
147
  dashboard, covers every item under that publisher and does not expire.
35
148
  - **Honest output.** `publish` returns a review state, not "live"; the CLI prints
36
149
  the store's state instead of inventing one.
37
- - **Built for agents.** Every command accepts `--json` and returns
38
- `{ ok, command, data }`; a failure returns a stable `error.code` and a hint on
39
- what to fix. No log scraping — see [For agents and scripts](#for-agents-and-scripts).
40
- - **Ships as a [skill](SKILL.md)** for coding agents: the procedure, the
41
- guardrails and the CLI live together.
150
+ - **Built for agents.** One command installs the skill
151
+ (`npx skills add XCreativeStudio/cws-release`), and the CLI underneath answers
152
+ in JSON with stable error codes — see [Using it with an AI agent](#using-it-with-an-ai-agent).
42
153
 
43
154
  ## Install
44
155
 
45
156
  | You have… | Use | Pin |
46
157
  | --- | --- | --- |
47
158
  | **Several extensions** | `npm i -D cws-release`, then `npx cws-release <cmd>` | `package.json` + lockfile, per repo |
48
- | One extension, or trying it | `npm i -g cws-release` | your machine |
159
+ | Trying it or a one-off release | `npx cws-release <cmd>` | not pinned; latest each run |
49
160
  | A release pipeline | `uses: XCreativeStudio/cws-release@v1` | the tag |
50
161
 
51
162
  With a dev dependency each repository pins its own version, so upgrading one
@@ -68,8 +179,12 @@ Commit identifiers, never secrets, in `.cws.json` (`init` writes the template):
68
179
  }
69
180
  ```
70
181
 
71
- `itemId` is the 32-character extension id; `zip` may be a single `*`/`?` glob
72
- because build output usually carries the version. Point the CLI at the key:
182
+ `publisherId` and `itemId` come from the dashboard's **Settings** page
183
+ ([step 5](#one-time-setup)); `itemId` is the 32-character extension id. `init`
184
+ defaults `zip` to `.output/*-chrome.zip`; change it to your build output path if
185
+ needed. A `*`/`?` glob is supported when it matches exactly one file.
186
+
187
+ The key is pointed at separately, by environment variable:
73
188
 
74
189
  ```sh
75
190
  export CWS_SERVICE_ACCOUNT_FILE="$HOME/.config/cws/service-account.json" # local
@@ -86,25 +201,37 @@ override the matching keys.
86
201
 
87
202
  | Command | What it does |
88
203
  | --- | --- |
89
- | `cws init` | Write a `.cws.json` template and the agent skill into this repository |
90
- | `cws check` | Exchange the token and call `fetchStatus`; separates "the secret is set" from "the secret works" |
204
+ | `cws init` | Write a `.cws.json` template plus the agent skill into this repository; leaves existing files alone without `--force` |
205
+ | `cws check` | Verify credentials; checks store access when both IDs are configured |
91
206
  | `cws upload [zip]` | Upload the package, then wait for asynchronous processing |
92
207
  | `cws publish` | Submit the uploaded package for review |
93
208
  | `cws release [zip]` | upload → publish → status, in one step |
94
209
  | `cws status` | Published and submitted revision state |
95
210
  | `cws cancel` | Cancel a submission that is under review |
96
211
 
97
- Flags: `--staged` (`STAGED_PUBLISH`), `--live` (`DEFAULT_PUBLISH`),
98
- `--block-on-warnings`, `--json`, `--timeout <ms>`, `--config <path>`,
99
- `--api <url>`, `--force` (with `init`).
212
+ Flags: `--staged` (manual deploy after approval), `--live` (automatic deploy after approval),
213
+ `--block-on-warnings`, `--json`, `--timeout <ms>` (upload polling for `upload`/`release`),
214
+ `--config <path>`, `--api <url>`, `--force` (only with `init`). Extra positional arguments
215
+ and flags that do not apply to the selected command are rejected.
100
216
 
101
217
  `status` is the honest answer to "is it live yet?": `PUBLISHED` in
102
218
  `publishedItemRevisionStatus` means live, anything else is still in review.
103
219
 
104
- ## For agents and scripts
220
+ ## Using it with an AI agent
105
221
 
106
- `--json` turns the CLI into an interface instead of a log to scrape. Success
107
- goes to stdout; progress lines go to stderr.
222
+ Install the skill — the [skills CLI][skills-cli] handles Claude Code, Codex,
223
+ Cursor, Copilot and 70+ other agents:
224
+
225
+ ```sh
226
+ npx skills add XCreativeStudio/cws-release
227
+ ```
228
+
229
+ It lands in `.agents/skills/chrome-web-store-publish/` and brings **both** the
230
+ procedure ([`SKILL.md`](SKILL.md)) and a working copy of the CLI, so the agent can
231
+ run `node .agents/skills/chrome-web-store-publish/cws.mjs check` offline.
232
+
233
+ Then the CLI answers in JSON instead of logs. Success goes to stdout; progress
234
+ lines go to stderr.
108
235
 
109
236
  ```jsonc
110
237
  // cws release --json (stdout)
@@ -117,7 +244,7 @@ found among the progress lines:
117
244
  ```sh
118
245
  cws:json {"ok":false,"error":{"code":"PUBLISHER_FORBIDDEN","status":403,
119
246
  "reason":"PERMISSION_DENIED","message":"HTTP 403: PERMISSION_DENIED: …",
120
- "hint":"Add the service-account email under Account in the Developer Dashboard, and check publisherId in .cws.json."}}
247
+ "hint":"Add the service-account email in the Developer Dashboard under Settings, in the Management section, then check publisherId in .cws.json."}}
121
248
  ```
122
249
 
123
250
  Extract it with `sed -n 's/^cws:json //p'` and branch on `error.code`, which
@@ -126,13 +253,54 @@ never changes meaning. The most common ones:
126
253
  | `code` | Usual fix |
127
254
  | --- | --- |
128
255
  | `NO_CREDENTIALS` | Set `CWS_SERVICE_ACCOUNT_FILE` or `CWS_ACCESS_TOKEN` |
129
- | `PUBLISHER_FORBIDDEN` | Add the service account in the dashboard; check `publisherId` |
256
+ | `CREDENTIALS_UNREADABLE` | The key file is missing or not valid JSON — usually newlines lost when passing `private_key` through a shell or CI variable |
257
+ | `AUTH_FAILED` | Re-exchange the token; tokens last about an hour, and a twice-failed exchange means the key itself is wrong |
258
+ | `PUBLISHER_FORBIDDEN` | The account is not added on the dashboard's **Settings** page — or `publisherId` is wrong. This 403 also masks a disabled API, so work through [steps 1–5](#one-time-setup) in order |
130
259
  | `UPLOAD_REJECTED` | Raise the manifest version above the published one |
131
260
 
132
261
  All 14 codes, with meanings and fixes: [docs/errors.md](docs/errors.md). Exit
133
262
  codes stay coarse for shells — `0` success, `1` failure, `2` usage — and the
134
263
  keys of `data` are the raw API responses, unchanged.
135
264
 
265
+ ### When npm is not reachable
266
+
267
+ Not every environment can install from npm: some agents only read a skill
268
+ directory, and a locked-down CI runner may have no registry access at all.
269
+ Either a `git clone` or `npx cws-release init` drops the same two files into the
270
+ same place, and the CLI runs from there with no install:
271
+
272
+ ```sh
273
+ git clone --depth 1 https://github.com/XCreativeStudio/cws-release.git \
274
+ .agents/skills/chrome-web-store-publish
275
+ ```
276
+
277
+ [INSTALL.md](INSTALL.md) compares every option. The skill is a convenience — the
278
+ CLI and the [one-time setup](#one-time-setup) are the contract, and both work
279
+ from a terminal with no agent in the loop.
280
+
281
+ ### A worked run
282
+
283
+ Publishing an MV3 extension whose build output is
284
+ `.output/<name>-<version>-chrome.zip` to a publisher that already owns the item:
285
+
286
+ ```sh
287
+ cd my-extension
288
+ npx cws-release init # writes .cws.json + the skill
289
+ # paste publisherId and itemId from the dashboard Settings page
290
+ export CWS_SERVICE_ACCOUNT_FILE="$HOME/.config/cws/service-account.json"
291
+
292
+ npx cws-release check # credentials + store access
293
+ npx cws-release upload # glob picks the only zip; waits for processing
294
+ npx cws-release publish --staged # submit for review, deploy manually later
295
+ npx cws-release status # current live version and the one in review
296
+ ```
297
+
298
+ `--staged` (`STAGED_PUBLISH`) is the version for a release you want to watch:
299
+ the review approves it, then deploying is your explicit act. `--live`
300
+ (`DEFAULT_PUBLISH`) goes live as soon as review passes. Use `--staged` for the
301
+ first release of an item and for anything that touches permissions; the CLI
302
+ never claims a version is live — `cws status` reads the store and says so.
303
+
136
304
  ## CI
137
305
 
138
306
  As a GitHub Action — it installs the CLI, checks the Node version, and exposes
@@ -180,6 +348,8 @@ The suite covers JWT signing, config precedence, upload/publish request shapes,
180
348
  asynchronous polling, error mapping, the JSON error contract, and real HTTP
181
349
  round trips against a local server. No credentials needed.
182
350
 
351
+ [skills-cli]: https://github.com/vercel-labs/skills
352
+
183
353
  ## License
184
354
 
185
355
  MIT
package/README.zh-CN.md CHANGED
@@ -10,18 +10,117 @@
10
10
 
11
11
  ## 快速开始
12
12
 
13
+ 需要 **Node.js 22 或更新版本**,并且扩展条目已在 Chrome Web Store 创建。首次创建条目、填写商店信息和隐私问卷仍需在开发者后台手动完成。
14
+
15
+ ```sh
16
+ npm i -D cws-release # 在扩展仓库中安装
17
+ npx cws-release init # 生成 .cws.json 和 agent skill
18
+ # 先完成下方的一次性 Google 授权,并填写 .cws.json 与密钥路径
19
+ export CWS_SERVICE_ACCOUNT_FILE="$HOME/.config/cws/service-account.json"
20
+ npx cws-release check # 有两个 ID 时也会验证商店访问权限
21
+ npx cws-release release --staged # 上传并提交审核;审核通过后再手动上线
22
+ ```
23
+
24
+ 初次配置按这个顺序走:**确认条目已创建 → 启用 API 并授权服务账号 → 填写 `publisherId`、`itemId` 和 zip 路径 → 设置密钥 → 运行 `check` → 发布**。完整步骤见[一次性配置](#一次性配置),通常只需为每个发布者账号做一次。
25
+
26
+ `check` 只设置密钥时会验证认证;补齐 `publisherId` 和 `itemId` 后才会验证商店访问。默认 `release` 使用 `DEFAULT_PUBLISH`,审核通过后会自动上线;首次发布建议显式使用 `--staged`。
27
+
28
+ ## 一次性配置
29
+
30
+ 每个**发布者账号**做一次,不是每个扩展做一次。有四处状态必须一致:API 已启用、
31
+ 密钥、后台里的服务账号条目、`.cws.json`。任一处不一致都会返回
32
+ `PUBLISHER_FORBIDDEN`(HTTP 403),即使密钥本身完全正确。**同一个症状,四种可能的
33
+ 原因**——按下面的顺序走,第一个失败就会告诉你缺的是哪一块。
34
+
35
+ **1. 在 Google Cloud 项目里启用 Chrome Web Store API:**
36
+
37
+ <https://console.cloud.google.com/apis/library/chromewebstore.googleapis.com>
38
+
39
+ 点 **Enable**。项目里没启用这个 API 时,请求是在调用阶段被拒的,而不是在认证阶段
40
+ ——它看起来像权限问题,其实不是。点之前先在控制台顶部的项目选择器里选对项目。
41
+
42
+ ![Google Cloud 里 Chrome Web Store API 的产品页,以及启用按钮](docs/assets/enable-api.webp)
43
+
44
+ *产品页上的**启用**按钮。菜单文字会跟随控制台语言,谷歌也会不时调整页面布局;如果
45
+ 界面和这里不同,就找 API 名字和一个启用控件。*
46
+
47
+ **2. 创建服务账号,不授予任何 IAM 角色:**
48
+
49
+ <https://console.cloud.google.com/iam-admin/serviceaccounts/create>
50
+
51
+ 起个好认的名字(如 `cws-release`),然后 **Create and continue** → **Continue**
52
+ → **Done**。不要授予角色:权限来自第 4 步,不是 IAM。
53
+
54
+ **3. 创建并下载 JSON 密钥。** 打开该账号 → **Keys** → **Add key** →
55
+ **Create new key** → **JSON**。先把它移出 `~/Downloads` 并收紧权限,再干别的
56
+ ——见[密钥保护](#密钥保护):
57
+
13
58
  ```sh
14
- npm i -D cws-release # 在你的扩展仓库里
15
- npx cws-release init # 一次性:生成 .cws.json + agent skill
59
+ mkdir -p ~/.config/cws
60
+ mv ~/Downloads/<project>-<hex>.json ~/.config/cws/service-account.json
61
+ chmod 700 ~/.config/cws
62
+ chmod 600 ~/.config/cws/service-account.json
63
+ ```
64
+
65
+ **4. 在开发者后台授权这个服务账号——真正授予权限的是这一步。** 跳过它,任何条目
66
+ (真的还是编的)都会返回 `PUBLISHER_FORBIDDEN`:
67
+
68
+ <https://chrome.google.com/webstore/devconsole>
69
+
70
+ 从侧边栏进入 **Settings** 页。服务账号的填写框在 **Management** 区块里——**不是**
71
+ 侧边栏 **Account → Profile** 那一组(那里是显示名、联系邮箱、trader 声明和地址)。
72
+ 粘贴 Google Cloud 控制台里显示的 `…@….iam.gserviceaccount.com` 邮箱并保存;随后它
73
+ 会出现在表格中,带当天的加入日期。一个发布者只接受**一个**服务账号,且发布者账号
74
+ 必须已开启两步验证。
75
+
76
+ ![后台 Settings 页,Management 区块里的 Service account 表格](docs/assets/service-account.webp)
77
+
78
+ ***Service account** 表格位于 Settings 页的 **Management** 区块。表中那一行就是该账号,
79
+ 以邮箱为标识,并带加入日期。谷歌的界面文字可能变,认准区块名而不是某一行的样式。*
80
+
81
+ **5. 把两个标识符填进 `.cws.json`。** 两者都在 **Settings** 页:
82
+
83
+ - **Publisher ID** —— Account 组 Profile 区里的一个字段;也出现在该页 URL 的
84
+ `/webstore/devconsole/<publisherId>/settings` 中。
85
+ - **Item ID** —— 32 位扩展 ID,来自后台里该条目的 URL,或 `chrome://extensions`。
86
+
87
+ 这些是按发布者区分的值:填你自己的,不要照抄别人项目里的。标识符可以安全提交,
88
+ 密钥不行。
89
+
90
+ ![Settings 页 Profile 区的 Publisher ID 字段](docs/assets/publisher-id.webp)
16
91
 
92
+ ***Publisher ID** 是 **Profile** 区里的那个短字段,在显示名和联系邮箱旁边——不在上面
93
+ 的 **Management** 区块里。图里它做了部分打码;你自己的是一串形如
94
+ `7c6b…-…-…-…-…` 的 UUID。*
95
+
96
+ **6. 让 CLI 找到密钥** —— 写在你要执行发布的 shell 里,或作为 CI 密钥:
97
+
98
+ ```sh
17
99
  export CWS_SERVICE_ACCOUNT_FILE="$HOME/.config/cws/service-account.json"
18
- npx cws-release check # 三秒内验证凭据可用
19
- npx cws-release release # 上传 → 提交审核 → 打印状态
20
100
  ```
21
101
 
22
- 前置条件(`check` 会告诉你还差什么):条目已在商店中存在、发布者已开启两步验证、
23
- 服务账号已加入[开发者后台](https://chrome.google.com/webstore/devconsole)的
24
- **Account** 页。API 无法创建新条目——首次上传和商店信息页需手动完成。
102
+ 确保 `.cws.json` 已填写两个标识符后运行 `npx cws-release check`。此时它会换取令牌并调用 `fetchStatus`;若仍返回 `PUBLISHER_FORBIDDEN`,问题在第 4 步或第 5 步,不在密钥。若 ID 尚未填写,`check` 只验证认证,不验证商店访问。
103
+
104
+ 一次性运行也可以完全不用密钥,改用 `CWS_ACCESS_TOKEN`
105
+ (`gcloud auth print-access-token --scopes=https://www.googleapis.com/auth/chromewebstore`),
106
+ 它约一小时后过期。
107
+
108
+ ## 密钥保护
109
+
110
+ 服务账号密钥是该发布者下所有条目的长期凭据。把它当**一个秘密**对待,而不是配置:
111
+
112
+ - **不要放进仓库。** 放 `~/.config/cws/` 或 CI 密钥变量——绝不放进会被提交的
113
+ `.cws.json`,也绝不粘贴到 issue 或对话里。对话需要"报"密钥时,报它的**路径**和
114
+ 账号邮箱即可,两者都不是秘密。
115
+ - **目录 `700`、文件 `600`**(即第 3 步的 `chmod`)。谷歌刚把它下载下来就立刻移出
116
+ `~/Downloads`:下载目录会被其他工具同步、索引和扫描。
117
+ - **不要在它周围 `set -x`**,也不要给导出它的脚本加 `--verbose`。CLI 从不打印密钥,
118
+ 你的 shell 也不该。
119
+ - **丢了或泄漏了?** 去 Google Cloud 删掉该密钥(**Keys** → 删除),新建一个,
120
+ 再把 `CWS_SERVICE_ACCOUNT_FILE` 指向新文件。后台的那条记录绑定的是账号**邮箱**,
121
+ 邮箱不变,所以第 4 步不用重做。
122
+ - 作为兜底,每个扩展仓库的 `.gitignore` 可以加一行 `service-account*.json`。兜底不等于
123
+ 方案——这个文件本来就不该出现在工作树里。
25
124
 
26
125
  ## 为什么用它
27
126
 
@@ -31,16 +130,15 @@ npx cws-release release # 上传 → 提交审核 → 打印状态
31
130
  且不会过期。
32
131
  - **诚实的输出。** `publish` 返回的是审核状态而不是"已上线";CLI 打印商店的真实状态,
33
132
  不编造。
34
- - **为 AI 设计。** 所有命令都支持 `--json`,返回 `{ ok, command, data }`;失败返回
35
- 稳定的 `error.code` 和修复提示,不需要爬日志——见[给 AI 和脚本使用](#给-ai-和脚本使用)。
36
- - **附带 [skill](SKILL.md)** 给编码助手:操作流程、护栏和 CLI 放在一起。
133
+ - **为 AI 设计。** 一条命令装好 skill(`npx skills add XCreativeStudio/cws-release`),
134
+ 底层 CLI 用 JSON 作答、错误码稳定——见[配合 AI 助手使用](#配合-ai-助手使用)。
37
135
 
38
136
  ## 安装
39
137
 
40
138
  | 你的情况 | 用 | 版本固定在哪 |
41
139
  | --- | --- | --- |
42
140
  | **维护多个扩展** | `npm i -D cws-release`,然后 `npx cws-release <命令>` | 每个仓库的 `package.json` + lockfile |
43
- | 只有一个扩展,或试用 | `npm i -g cws-release` | 你的机器 |
141
+ | 试用或临时发布 | `npx cws-release <命令>` | 不固定;使用最新版本 |
44
142
  | 发布流水线 | `uses: XCreativeStudio/cws-release@v1` | 标签 |
45
143
 
46
144
  用 dev dependency 时,每个仓库固定自己的版本,升级一个扩展不会影响另一个,CI 装的
@@ -61,8 +159,10 @@ npx cws-release release # 上传 → 提交审核 → 打印状态
61
159
  }
62
160
  ```
63
161
 
64
- `itemId` 是 32 位的扩展 ID;`zip` 可以是单个 `*`/`?` 通配符,因为构建产物通常带版本号。
65
- 让 CLI 找到密钥:
162
+ `publisherId` 和 `itemId` 来自后台的 **Settings** 页([第 5 步](#一次性配置));
163
+ `itemId` 是 32 位扩展 ID。`init` 默认写入 `.output/*-chrome.zip`;如果构建产物路径或名称不同,请改成你的 zip 路径。也可使用只匹配一个文件的 `*`/`?` 通配符。
164
+
165
+ 密钥单独通过环境变量指向:
66
166
 
67
167
  ```sh
68
168
  export CWS_SERVICE_ACCOUNT_FILE="$HOME/.config/cws/service-account.json" # 本地
@@ -78,24 +178,34 @@ export CWS_ACCESS_TOKEN="$(gcloud auth print-access-token \
78
178
 
79
179
  | 命令 | 作用 |
80
180
  | --- | --- |
81
- | `cws init` | 在当前仓库写入 `.cws.json` 模板和 agent skill |
82
- | `cws check` | 换取令牌并调用 `fetchStatus`;区分"密钥已配置"和"密钥可用" |
181
+ | `cws init` | 在当前仓库写入 `.cws.json` 模板和 agent skill;不加 `--force` 时不动已存在的文件 |
182
+ | `cws check` | 验证密钥;配置两个 ID 后再验证商店访问 |
83
183
  | `cws upload [zip]` | 上传包,然后等待异步处理完成 |
84
184
  | `cws publish` | 把已上传的包提交审核 |
85
185
  | `cws release [zip]` | 一步完成 上传 → 提交审核 → 状态 |
86
186
  | `cws status` | 已发布和已提交的版本状态 |
87
187
  | `cws cancel` | 取消正在审核中的提交 |
88
188
 
89
- 参数:`--staged`(`STAGED_PUBLISH`)、`--live`(`DEFAULT_PUBLISH`)、
90
- `--block-on-warnings`、`--json`、`--timeout <ms>`、`--config <path>`、
91
- `--api <url>`、`--force`(配合 `init`)。
189
+ 参数:`--staged`(审核通过后手动上线)、`--live`(审核通过后自动上线)、
190
+ `--block-on-warnings`、`--json`、`--timeout <ms>`(仅用于 `upload`/`release` 的上传等待)、
191
+ `--config <path>`、`--api <url>`、`--force`(仅用于 `init`)。多余的位置参数和不适用于当前命令的选项会报用法错误。
92
192
 
93
193
  "到底上线了吗"——用 `status` 回答:`publishedItemRevisionStatus` 里的
94
194
  `PUBLISHED` 才算已上线,其余都还在审核中。
95
195
 
96
- ## 给 AI 和脚本使用
196
+ ## 配合 AI 助手使用
197
+
198
+ 安装 skill——[skills CLI][skills-cli] 支持 Claude Code、Codex、Cursor、Copilot 等 70+ 种助手:
97
199
 
98
- `--json` 把 CLI 变成可解析的接口,而不是需要爬取的日志。成功写 stdout;进度行写 stderr。
200
+ ```sh
201
+ npx skills add XCreativeStudio/cws-release
202
+ ```
203
+
204
+ 它会把内容装到 `.agents/skills/chrome-web-store-publish/`,同时带上**操作流程**
205
+ ([`SKILL.md`](SKILL.md))和**一份可运行的 CLI**,所以助手可以离线执行
206
+ `node .agents/skills/chrome-web-store-publish/cws.mjs check`。
207
+
208
+ 之后 CLI 用 JSON 而非日志作答。成功写 stdout;进度行写 stderr。
99
209
 
100
210
  ```jsonc
101
211
  // cws release --json (stdout)
@@ -107,7 +217,7 @@ export CWS_ACCESS_TOKEN="$(gcloud auth print-access-token \
107
217
  ```sh
108
218
  cws:json {"ok":false,"error":{"code":"PUBLISHER_FORBIDDEN","status":403,
109
219
  "reason":"PERMISSION_DENIED","message":"HTTP 403: PERMISSION_DENIED: …",
110
- "hint":"Add the service-account email under Account in the Developer Dashboard, and check publisherId in .cws.json."}}
220
+ "hint":"Add the service-account email in the Developer Dashboard under Settings, in the Management section, then check publisherId in .cws.json."}}
111
221
  ```
112
222
 
113
223
  用 `sed -n 's/^cws:json //p'` 提取,然后对 `error.code` 分支——它的含义永不改变。
@@ -116,13 +226,51 @@ cws:json {"ok":false,"error":{"code":"PUBLISHER_FORBIDDEN","status":403,
116
226
  | `code` | 通常的修复方式 |
117
227
  | --- | --- |
118
228
  | `NO_CREDENTIALS` | 设置 `CWS_SERVICE_ACCOUNT_FILE` 或 `CWS_ACCESS_TOKEN` |
119
- | `PUBLISHER_FORBIDDEN` | 在后台加入服务账号;检查 `publisherId` |
229
+ | `CREDENTIALS_UNREADABLE` | 密钥文件不存在或不是合法 JSON——多半是 `private_key` 经 shell 或 CI 变量传递时丢了换行 |
230
+ | `AUTH_FAILED` | 重新换取令牌;令牌约一小时有效期,连续两次失败说明密钥本身有问题 |
231
+ | `PUBLISHER_FORBIDDEN` | 账号没在后台 **Settings** 页加入,或 `publisherId` 不对。这个 403 也会掩盖"API 未启用",所以按[第 1–5 步](#一次性配置)顺序排查 |
120
232
  | `UPLOAD_REJECTED` | 把 manifest 版本号提高到已发布版本之上 |
121
233
 
122
- 全部 14 个错误码的完整含义与修复方式见 [docs/errors.md](docs/errors.md)。退出码对
234
+ 全部 14 个错误码的完整含义与修复方式见[中文错误码说明](docs/zh-CN/errors.md)。退出码对
123
235
  shell 保持粗粒度——`0` 成功、`1` 失败、`2` 用法错误——`data` 里的字段是未经改动的
124
236
  原始 API 响应。
125
237
 
238
+ ### npm 不可达时
239
+
240
+ 不是每个环境都能从 npm 安装:有些助手只读 skill 目录,隔离的 CI 跑者也可能访问不了
241
+ registry。用 `git clone` 或 `npx cws-release init` 都能把同样两个文件放到同一位置,
242
+ 之后无需安装即可运行 CLI:
243
+
244
+ ```sh
245
+ git clone --depth 1 https://github.com/XCreativeStudio/cws-release.git \
246
+ .agents/skills/chrome-web-store-publish
247
+ ```
248
+
249
+ 全部安装方式的对比见 [INSTALL.md](INSTALL.md)。skill 只是便利——真正的契约是 CLI 和
250
+ [一次性配置](#一次性配置),两者在完全没有助手的终端里同样可用。
251
+
252
+ ### 一次完整运行
253
+
254
+ 把一个 MV3 扩展(构建产物为 `.output/<name>-<version>-chrome.zip`)发布到已拥有该条目
255
+ 的发布者:
256
+
257
+ ```sh
258
+ cd my-extension
259
+ npx cws-release init # 生成 .cws.json 和 skill
260
+ # 从后台 Settings 页填入 publisherId 和 itemId
261
+ export CWS_SERVICE_ACCOUNT_FILE="$HOME/.config/cws/service-account.json"
262
+
263
+ npx cws-release check # 验证凭据和商店访问
264
+ npx cws-release upload # 通配符匹配唯一 zip,并等待处理完成
265
+ npx cws-release publish --staged # 提交审核,通过后再手动上线
266
+ npx cws-release status # 当前线上版本与审核中的版本
267
+ ```
268
+
269
+ `--staged`(`STAGED_PUBLISH`)适合需要盯着的发版:审核通过后再"上线"是你的明确动作。
270
+ `--live`(`DEFAULT_PUBLISH`)则在审核通过后立即上线。条目的首次发版、以及任何改动权限
271
+ 的版本,都用 `--staged`。CLI 从不声称某个版本已上线——`cws status` 去读商店,由商店
272
+ 自己说。
273
+
126
274
  ## CI
127
275
 
128
276
  作为 GitHub Action——它会安装 CLI、检查 Node 版本,并把 JSON 信封暴露为 `result`、
@@ -167,6 +315,8 @@ node --test
167
315
  测试覆盖 JWT 签名、配置优先级、上传/发布请求结构、异步轮询、错误映射、JSON 错误契约,
168
316
  以及针对本地服务器的真实 HTTP 往返。无需任何凭据。
169
317
 
318
+ [skills-cli]: https://github.com/vercel-labs/skills
319
+
170
320
  ## 许可证
171
321
 
172
322
  MIT
package/SKILL.md CHANGED
@@ -9,23 +9,31 @@ description: Use when uploading or publishing a Chrome extension to the Chrome W
9
9
  v2. It authenticates with a Google Cloud service account, uploads a zip,
10
10
  submits it for review, and reports status.
11
11
 
12
- ## Getting the CLI into the repository
12
+ ## How this skill was installed
13
13
 
14
- Nothing is installed next to this file: GitHub is the source. Use whichever
15
- form is already available, from the repository root:
14
+ ```sh
15
+ npx skills add XCreativeStudio/cws-release # installs this skill into .agents/skills/
16
+ ```
17
+
18
+ That command copies the whole repository, so `<skill-dir>/cws.mjs` — a working
19
+ CLI — is already next to this file. Prefer it: no network, no version drift.
20
+ The repository also has `npx cws-release init`, which writes the skill for
21
+ projects that would rather not clone the repository.
22
+
23
+ ## Running the CLI
24
+
25
+ From the repository root, use whichever form is available:
16
26
 
17
27
  ```sh
18
- npx cws-release <command> # installed as a dev dependency, or fetched
28
+ node <skill-dir>/cws.mjs <command> # this install: self-contained, no network
29
+ npx cws-release <command> # dev dependency, or fetched from npm
19
30
  npm run cws <command> # if package.json has "scripts": { "cws": "cws" }
20
- node <skill-dir>/cws.mjs <command> # this clone, no network
21
31
  ```
22
32
 
23
33
  The package name comes first and the command second — **no `--` separator**,
24
34
  which the CLI would reject as an unknown option. Both npm forms run with the
25
- repository root as cwd, so `.cws.json` resolves correctly. Run `cws init` once
26
- per repository: it writes the `.cws.json` template and copies this skill into
27
- `.agents/skills/` when missing. Never run `npx cws-publish` — that npm name is
28
- an unrelated project.
35
+ repository root as cwd, so `.cws.json` resolves correctly. Never run
36
+ `npx cws-publish` — that npm name is an unrelated project.
29
37
 
30
38
  A clone whose `cws.mjs --help` shows no `init` line predates `init`; run it with
31
39
  the npx form above.
@@ -37,20 +45,31 @@ the npx form above.
37
45
  [Developer Dashboard](https://chrome.google.com/webstore/devconsole). The API
38
46
  cannot create items.
39
47
  - The publisher account has 2-step verification enabled.
40
- - A service account has been added once under **Account** in the dashboard.
41
- Only one service account can be added per publisher; the same key works for
42
- every item under that publisher.
48
+ - A service account has been added once on the dashboard's **Settings** page,
49
+ which is what actually grants access. Only one service account can be added
50
+ per publisher; the same key works for every item under that publisher.
43
51
  - The manifest version is strictly greater than the published one.
44
52
 
45
53
  ## One-time setup
46
54
 
47
- 1. Google Cloud Console: create/select a project and enable **Chrome Web Store API**.
48
- 2. Create a service account (no IAM roles needed) and download a JSON key.
49
- 3. Developer Dashboard → **Account** → add the service-account email.
50
- 4. Copy the **Publisher ID** (Publisher → Settings) and the **item ID**
51
- (the 32-character extension ID).
52
-
53
- Keep the key outside the repository, for example `~/.config/cws/service-account.json` (mode 600):
55
+ Per publisher account, not per extension. Four pieces of state must agree, and
56
+ any mismatch returns `PUBLISHER_FORBIDDEN` (HTTP 403) even with a valid key.
57
+
58
+ 1. **Enable the API.** In the Google Cloud project:
59
+ <https://console.cloud.google.com/apis/library/chromewebstore.googleapis.com>
60
+ Disabled here, calls fail at the API, not at authentication.
61
+ 2. **Create a service account** with no IAM roles, then **Keys → Add key → JSON**.
62
+ 3. **Authorize it in the dashboard,** under **Settings → Management** — *not*
63
+ under **Account → Profile**, which holds the display name and contact email.
64
+ Paste the `<name>@<project>.iam.gserviceaccount.com` email. This is the step
65
+ that grants access; skip it and every item returns 403.
66
+ 4. **Read both identifiers** on the same **Settings** page: the **Publisher ID**
67
+ (a field under Profile, also in the URL as
68
+ `/webstore/devconsole/<publisherId>/settings`) and the **item ID** (the
69
+ 32-character extension ID). They are per-publisher — never copy another
70
+ project's values.
71
+
72
+ Keep the key outside the repository, for example `~/.config/cws/service-account.json` (mode 600),
54
73
 
55
74
  ```sh
56
75
  export CWS_SERVICE_ACCOUNT_FILE="$HOME/.config/cws/service-account.json"
@@ -58,6 +77,16 @@ export CWS_SERVICE_ACCOUNT_FILE="$HOME/.config/cws/service-account.json"
58
77
 
59
78
  In CI, put the whole JSON in a secret and export it as `CWS_SERVICE_ACCOUNT`.
60
79
 
80
+ **Key handling.** The key is a long-lived credential for every item under the
81
+ publisher. Keep it at `~/.config/cws/` with directory `700` and file `600`, out
82
+ of the repository and out of `.cws.json`. Never print it, never echo it, never
83
+ put it in a command line that lands in shell history, and never add `set -x` to
84
+ a script that exports it. If a task needs to *report* on the key, report its
85
+ path and the account email — neither is a secret. If it may have been exposed:
86
+ delete the key in Google Cloud (**Keys** → delete), create a new one, and point
87
+ `CWS_SERVICE_ACCOUNT_FILE` at it; the dashboard entry is keyed by email and
88
+ needs no change.
89
+
61
90
  ## Repository config
62
91
 
63
92
  Commit identifiers only — never secrets:
@@ -76,7 +105,7 @@ Run from the repository root. `node <skill-dir>/cws.mjs …` and
76
105
 
77
106
  ```sh
78
107
  cws init # write .cws.json + this skill into the current repository
79
- cws check # prove the credentials work, then print the item status
108
+ cws check # verify credentials; checks item status when both IDs are set
80
109
  cws upload # upload .cws.json's zip (or: cws upload path/to.zip)
81
110
  cws publish # submit the uploaded package for review
82
111
  cws release # upload + publish + print the resulting status
@@ -84,8 +113,7 @@ cws status # published / submitted revision state
84
113
  cws cancel # cancel a submission that is under review
85
114
  ```
86
115
 
87
- `cws check` first, every time: it separates "the secret is set" from "the
88
- secret works" in three seconds.
116
+ Run `cws check` before publishing. With only credentials configured it verifies authentication; when both IDs are set it also checks store access and prints the item status.
89
117
 
90
118
  Options: `--staged` (STAGED_PUBLISH: approved but not deployed), `--live`
91
119
  (DEFAULT_PUBLISH), `--block-on-warnings`, `--json`, `--timeout <ms>`,
@@ -106,7 +134,7 @@ Branch on `error.code`, never on the message text:
106
134
  | `NO_CREDENTIALS` | No key or token in the environment | Ask the user for `CWS_SERVICE_ACCOUNT_FILE`; do not retry |
107
135
  | `CREDENTIALS_UNREADABLE` | Key file missing or malformed | Ask for the whole key file; newlines are often lost |
108
136
  | `AUTH_FAILED` | Google rejected the token | Re-run the token exchange once; two failures means the key is wrong |
109
- | `PUBLISHER_FORBIDDEN` | Account not authorized | The user must add the service account in the dashboard |
137
+ | `PUBLISHER_FORBIDDEN` | Account not authorized | The user must add the service account under **Settings → Management**; check `publisherId` |
110
138
  | `ITEM_NOT_FOUND` | Wrong `itemId`/`publisherId` | Fix `.cws.json`; do not retry |
111
139
  | `ITEM_STATE_CONFLICT` | State blocks this | Run `cws status`, report the state |
112
140
  | `RATE_LIMITED` | Throttled | Back off (seconds to minutes), then retry once |
@@ -131,9 +159,9 @@ JSON; everything else on stderr is progress text.
131
159
  again.
132
160
  - Never commit, echo, or log the service-account key. Do not put it in
133
161
  `.cws.json`, and do not include tokens in error output.
134
- - `STAGED_PUBLISH` is the right default when a human should decide when to
135
- deploy; `DEFAULT_PUBLISH` is right for tag-driven releases that are already
136
- reviewed.
162
+ - Use `--staged` for a first release or whenever a human should decide when to
163
+ deploy. Plain `release` defaults to `DEFAULT_PUBLISH`, which goes live after
164
+ approval; use it only when that automatic deployment is intended.
137
165
 
138
166
  ## CI (GitHub Actions)
139
167
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cws-release",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "description": "Zero-dependency CLI for the Chrome Web Store API v2: upload, publish and check extension status with a service account.",
5
5
  "type": "module",
6
6
  "bin": { "cws": "./cws.mjs" },
package/src/api.mjs CHANGED
@@ -40,7 +40,7 @@ function hintFor(code) {
40
40
  case 'AUTH_FAILED':
41
41
  return 'The token expired (about 1 hour) or the key is wrong; re-run the token exchange.';
42
42
  case 'PUBLISHER_FORBIDDEN':
43
- return 'Add the service-account email under Account in the Developer Dashboard, and check publisherId in .cws.json.';
43
+ return 'Add the service-account email in the Developer Dashboard under Settings, in the Management section, then check publisherId in .cws.json.';
44
44
  case 'ITEM_NOT_FOUND':
45
45
  return 'Check itemId (the 32-character extension id) and publisherId; the item must exist in the store.';
46
46
  case 'ITEM_STATE_CONFLICT':
package/src/cli.mjs CHANGED
@@ -11,10 +11,10 @@ const USAGE = `cws — Chrome Web Store API v2 CLI
11
11
 
12
12
  Usage
13
13
  cws init write .cws.json and the skill into the current repository
14
- cws check prove the credentials work, and read the item status
14
+ cws check verify credentials; also checks store access when both IDs are set
15
15
  cws upload [zip] upload a package to an existing item
16
16
  cws publish submit the uploaded package for review
17
- cws release [zip] upload, then publish, then print the status
17
+ cws release [zip] upload, publish (auto-live after approval by default), then print status
18
18
  cws status print the published and submitted revision state
19
19
  cws cancel cancel a submission that is under review
20
20
 
@@ -22,11 +22,11 @@ Options
22
22
  --config <path> .cws.json to use (default: ./.cws.json)
23
23
  --zip <path> package path or a single * / ? glob
24
24
  --staged publish with STAGED_PUBLISH (approve now, deploy later)
25
- --live publish with DEFAULT_PUBLISH (overrides .cws.json)
25
+ --live publish with DEFAULT_PUBLISH (automatic after approval)
26
26
  --block-on-warnings make the publish request fail when validation warns
27
27
  --api <url> override the API base URL (tests, mock store)
28
28
  --json print { ok, command, data } on stdout; progress goes to stderr
29
- --timeout <ms> upload polling timeout (default: 180000)
29
+ --timeout <ms> upload polling timeout for upload/release (default: 180000)
30
30
  --force with init: overwrite existing files
31
31
  -h, --help
32
32
  -v, --version
@@ -152,6 +152,24 @@ export async function runCli({
152
152
  if (!['init', 'check', 'upload', 'publish', 'release', 'status', 'cancel'].includes(command)) {
153
153
  throw new UsageError(`unknown command: ${command}`);
154
154
  }
155
+ const allowedOptions = {
156
+ init: ['json', 'force'],
157
+ check: ['json', 'config', 'api'],
158
+ upload: ['json', 'config', 'zip', 'api', 'timeout'],
159
+ publish: ['json', 'config', 'api', 'staged', 'live', 'blockOnWarnings'],
160
+ release: ['json', 'config', 'zip', 'api', 'timeout', 'staged', 'live', 'blockOnWarnings'],
161
+ status: ['json', 'config', 'api'],
162
+ cancel: ['json', 'config', 'api'],
163
+ }[command];
164
+ const unsupported = Object.keys(options).filter((option) => !['help', 'version'].includes(option) && !allowedOptions.includes(option));
165
+ if (unsupported.length > 0) {
166
+ throw new UsageError(`${unsupported.map((option) => `--${option}`).join(', ')} cannot be used with ${command}`);
167
+ }
168
+ const maxArgs = ['upload', 'release'].includes(command) ? 1 : 0;
169
+ if (args.length > maxArgs) {
170
+ throw new UsageError(`${command} accepts at most ${maxArgs} positional ${maxArgs === 1 ? 'argument' : 'arguments'}`);
171
+ }
172
+ const emit = (data) => stdout.write(`${JSON.stringify(envelope(command, data), null, 2)}\n`);
155
173
  if (command === 'init') {
156
174
  const lines = [];
157
175
  const result = init({ cwd, force: options.force === true, log: (line) => lines.push(line) });
@@ -163,9 +181,10 @@ export async function runCli({
163
181
  const log = options.json
164
182
  ? (line) => stderr.write(`${line}\n`)
165
183
  : (line) => stdout.write(`${line}\n`);
166
- const emit = (data) => stdout.write(`${JSON.stringify(envelope(command, data), null, 2)}\n`);
167
184
 
168
185
  const config = loadConfig({ cwd, configPath: options.config, env });
186
+ if (command !== 'check') requireFields(config, ['publisherId', 'itemId']);
187
+
169
188
  const access = await getAccessToken({ env, fetchImpl });
170
189
  log(`ok authenticated (${access.source})`);
171
190
  const client = createStoreClient({
@@ -182,14 +201,12 @@ export async function runCli({
182
201
  printStatus(log, status, config.itemId);
183
202
  if (options.json) emit(status);
184
203
  } else {
185
- log('hint set publisherId and itemId in .cws.json to verify store access too');
186
- if (options.json) emit({ authenticated: true, source: access.source });
204
+ log('ok authenticated; store access not checked (set publisherId and itemId in .cws.json)');
205
+ if (options.json) emit({ authenticated: true, storeAccessChecked: false, source: access.source });
187
206
  }
188
207
  return 0;
189
208
  }
190
209
 
191
- requireFields(config, ['publisherId', 'itemId']);
192
-
193
210
  if (command === 'status') {
194
211
  const status = await client.fetchStatus(config);
195
212
  printStatus(log, status, config.itemId);
@@ -220,7 +237,7 @@ export async function runCli({
220
237
  const zipPath = resolveZipPath(args[0] ?? options.zip ?? config.zip, cwd);
221
238
  const bytes = readFileSync(zipPath);
222
239
  if (bytes.length < 4 || bytes[0] !== 0x50 || bytes[1] !== 0x4b) {
223
- throw new UsageError(`${zipPath} is not a zip file`);
240
+ throw new ConfigError(`${zipPath} is not a zip file`, { code: 'INVALID_PACKAGE' });
224
241
  }
225
242
  log(`... uploading ${basename(zipPath)} (${bytes.length.toLocaleString('en-US')} bytes)`);
226
243