pingcode-cli-unofficial 2.1.0 → 2.3.0
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 +47 -10
- package/dist/bin/pingcode.js +321 -64
- package/dist/bin/pingcode.js.map +1 -1
- package/package.json +1 -1
- package/skills/pingcode/SKILL.md +28 -1
- package/skills/pingcode/modules/api.md +11 -8
- package/skills/pingcode/modules/pjm.md +6 -0
- package/skills/pingcode/modules/ship.md +5 -1
package/package.json
CHANGED
package/skills/pingcode/SKILL.md
CHANGED
|
@@ -158,6 +158,21 @@ pingcode auth status --check
|
|
|
158
158
|
served from `<host>/open` there.
|
|
159
159
|
- `pingcode auth logout` removes the token, the stored credentials and the metadata cache.
|
|
160
160
|
|
|
161
|
+
**No app? Use a personal access token.** If you cannot register an OAuth app — a script, a CI job,
|
|
162
|
+
someone else's machine — create a token in PingCode 个人设置 (validity and `scopes` are chosen there,
|
|
163
|
+
shown once) and either paste it or export it. It acts as you, needs no `client_id`/`client_secret`,
|
|
164
|
+
and `PINGCODE_TOKEN` alone is enough to run any command:
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
PINGCODE_TOKEN=<token> pingcode project list # no login, no config file
|
|
168
|
+
pingcode auth login --mode pat --token <token> # store it in the config file
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
A PAT cannot be refreshed: an expired or revoked token fails with exit 3 (`auth:`) and tells you to
|
|
172
|
+
mint a new one. It also carries the same identity-based reach as a user token, so the seven
|
|
173
|
+
user-token-only endpoints (`/v1/myself`, `/v1/permission/my/*`, `/v1/permission/check/*`) work
|
|
174
|
+
whenever the token's scopes cover them.
|
|
175
|
+
|
|
161
176
|
**Security:** a Client Credentials token has organisation-wide system-administrator authority and is
|
|
162
177
|
valid for 30 days. It is not tied to a user. Never print it, never copy it into a file in a
|
|
163
178
|
repository, and treat `~/.pingcode/config.json` as a secret. The CLI redacts the secret and the token
|
|
@@ -180,9 +195,17 @@ from every URL, log line, dry-run plan and error message it emits.
|
|
|
180
195
|
or as an empty string (a blank `description`) is simply missing from the JSON. It does **not**
|
|
181
196
|
distinguish the two, and a missing key is never evidence that the field does not exist. Use
|
|
182
197
|
`x?.y ?? fallback`, not `'y' in x`.
|
|
198
|
+
- **Some fields change shape between endpoints.** A work item's `type` is a bare slug string
|
|
199
|
+
(`"task"`, `"epic"`), never a reference object, and its `state` is an object on most tenants
|
|
200
|
+
but a bare string on a few — the CLI keeps whichever shape the wire sent, so read both with
|
|
201
|
+
`x?.name ?? x`. A work item's `sprint_id` is filled in from its `sprint` object when the API
|
|
202
|
+
sends `sprint_id: null` beside a full object, so it is safe to filter on. `link` and `relation`
|
|
203
|
+
rows name the far end differently (`origin_work_item` / `target_work_item` vs `target`) — see
|
|
204
|
+
`modules/pjm.md`.
|
|
183
205
|
- `--dry-run` on a mutating command prints `{"dry_run":true,"request":{…}}` to stdout and exits 0
|
|
184
206
|
without sending anything. Read requests still run, so ids are really resolved.
|
|
185
|
-
- Errors in `--json` mode go to **stderr** as `{"error":{"kind":…,"message":…,"code":…,"exit":…}}
|
|
207
|
+
- Errors in `--json` mode go to **stderr** as `{"error":{"kind":…,"message":…,"code":…,"exit":…}}`,
|
|
208
|
+
plus an optional `"hint"` when the error carries one.
|
|
186
209
|
- **`pingcode api` is the exception to the shapes above**: stdout is the API's raw JSON, so `--json`
|
|
187
210
|
is a no-op on its five verbs and no key is normalised away. Its own `api list` / `api describe` are
|
|
188
211
|
local catalog views and do honour `--json`.
|
|
@@ -238,6 +261,10 @@ pingcode auth login --client-id <id> --client-secret <secret> --save
|
|
|
238
261
|
pingcode auth status
|
|
239
262
|
pingcode auth status --check # adds one live API call: GET /v1/pjm/projects?page_size=1
|
|
240
263
|
pingcode auth logout
|
|
264
|
+
|
|
265
|
+
# personal access token — no OAuth app needed (scripts, CI, shared machines)
|
|
266
|
+
pingcode auth login --mode pat --token <token>
|
|
267
|
+
PINGCODE_TOKEN=<token> pingcode project list
|
|
241
268
|
```
|
|
242
269
|
|
|
243
270
|
### Settings — 后台设置
|
|
@@ -98,18 +98,21 @@ field that its `PATCH` sibling preserves. Unless you truly mean "replace everyth
|
|
|
98
98
|
| a **user-token-only** endpoint | told this CLI holds an enterprise token |
|
|
99
99
|
|
|
100
100
|
The seven user-token endpoints — `/v1/myself`, `/v1/permission/my/*` (3) and
|
|
101
|
-
`/v1/permission/check/*` (3) —
|
|
102
|
-
|
|
103
|
-
`GET /v1/permission/points` **does**
|
|
104
|
-
|
|
101
|
+
`/v1/permission/check/*` (3) — need a token bound to a human: either the OAuth2
|
|
102
|
+
authorization-code flow (`pingcode auth login --mode user`) or a personal access token whose
|
|
103
|
+
scopes cover them (`--mode pat` / `PINGCODE_TOKEN`). Note that `GET /v1/permission/points` **does**
|
|
104
|
+
work. Everything else, including all 61 enterprise-token-only DevOps endpoints, is reachable with
|
|
105
|
+
the credentials from `pingcode auth login`.
|
|
105
106
|
|
|
106
107
|
## 5. Everything else behaves exactly as it does elsewhere
|
|
107
108
|
|
|
108
109
|
`--dry-run` halts every write (search reads excepted, above) and prints the full request plan
|
|
109
|
-
with the `Authorization` header and any `client_secret` redacted. A `401`
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
110
|
+
with the `Authorization` header and any `client_secret` redacted. A `401` on a **refreshable**
|
|
111
|
+
token (enterprise or user) re-acquires it and replays once; with a **personal access token**
|
|
112
|
+
there is nothing to re-acquire, so it fails immediately with exit `3` and tells you to replace
|
|
113
|
+
the token (expired or revoked). A `429` honours `x-pc-retry-after` once. Any `2xx` is success. The
|
|
114
|
+
exit-code table in [`../SKILL.md`](../SKILL.md) applies unchanged; on a `403` the scope the docs
|
|
115
|
+
declare for that endpoint is printed to stderr (or an honest "the docs declare no scope" when they
|
|
113
116
|
declare none).
|
|
114
117
|
|
|
115
118
|
The rate limit is shared with everything else, so a `--all` sweep over a large collection spends
|
|
@@ -258,6 +258,12 @@ pingcode project work-item link delete SCR-5 <link_id> --yes
|
|
|
258
258
|
the id `link list` printed for the item you are on — passing the other end's id answers
|
|
259
259
|
`工作项或工作项关联不存在` → exit 5.
|
|
260
260
|
- Links may cross projects, and a work item may be linked to itself.
|
|
261
|
+
- The two families expose **different field names for the far end**:
|
|
262
|
+
- `link list` rows expose `origin_work_item` and `target_work_item` (both are parsed as rich
|
|
263
|
+
refs carrying `identifier`, `title`, `type`, `short_id`).
|
|
264
|
+
- `relation list` rows expose `target` (a parsed ref) and `target_type` (the string kind, e.g.
|
|
265
|
+
`idea`). Generic consumer code that walks either family must read **both** spellings
|
|
266
|
+
(`origin_work_item`/`target_work_item` vs `target` + `target_type`).
|
|
261
267
|
|
|
262
268
|
#### `tag` — and the list that does not exist
|
|
263
269
|
|
|
@@ -21,6 +21,8 @@ product DELETE at all, and `PATCH` only edits three cosmetic fields.
|
|
|
21
21
|
|
|
22
22
|
### `product meta` — mandatory before writing an idea or ticket
|
|
23
23
|
|
|
24
|
+
`product meta ticket-states` is listed for completeness, but creating a ticket does **not** need it: `ticket create` has no `--state`, and the server picks the initial state. You only need it for `ticket transition` and `list --state`.
|
|
25
|
+
|
|
24
26
|
```bash
|
|
25
27
|
pingcode product meta idea-states --product SLC --json
|
|
26
28
|
pingcode product meta idea-priorities --product SLC --json
|
|
@@ -119,7 +121,7 @@ pingcode product ticket get SLC-7 --json
|
|
|
119
121
|
|
|
120
122
|
pingcode product ticket create --product SLC --type 故障 --title "Cannot log in" --dry-run --json
|
|
121
123
|
pingcode product ticket create --product SLC --type 故障 --title "Cannot log in" \
|
|
122
|
-
--assignee zhangsan --priority P1 --channel 邮件 --json
|
|
124
|
+
--assignee zhangsan --priority P1 --channel 邮件 --customer 前阳二厂 --json
|
|
123
125
|
|
|
124
126
|
pingcode product ticket update SLC-7 --title "Cannot log in (iOS)" --json
|
|
125
127
|
pingcode product ticket transition SLC-7 --state 处理中 --json
|
|
@@ -128,6 +130,8 @@ pingcode product ticket transition SLC-7 --state 处理中 --json
|
|
|
128
130
|
`--type` is **required** on `product ticket create` — `type_id` is a required body field, which is the one
|
|
129
131
|
place ship demands a lookup (`pingcode product meta ticket-types --product SLC`) before a write can even be
|
|
130
132
|
attempted. `--channel` can only be set at create time; there is no way to change it afterwards.
|
|
133
|
+
`--customer` is scoped to the product; `PATCH /v1/ship/tickets/{id}` also accepts `customer_id`, so you
|
|
134
|
+
can change the customer after creation (the `update` command does not expose it yet).
|
|
131
135
|
|
|
132
136
|
## 4b. Ship rules that will bite you
|
|
133
137
|
|