@wport/cli 0.9.0 → 0.9.1-dev.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 +23 -0
- package/dist/index.js +29 -5
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -16,6 +16,16 @@ npm install -g @wport/cli
|
|
|
16
16
|
|
|
17
17
|
Requires Node.js >= 18.17.
|
|
18
18
|
|
|
19
|
+
### dev channel(內部測試用)
|
|
20
|
+
|
|
21
|
+
`@wport/cli@dev` 是預設連 dev 後端(`https://developers.wport.me/v2`)的建置,供內部測試未上 prod 的後端改動:
|
|
22
|
+
|
|
23
|
+
npm i -g @wport/cli@dev # wport → dev 後端
|
|
24
|
+
wport login # 直接對 dev 後端做 device flow
|
|
25
|
+
npm i -g @wport/cli@latest # 換回 prod 版
|
|
26
|
+
|
|
27
|
+
dev 版憑證獨立存於 `credentials-dev.json`,與 prod 版的 `credentials.json` 互不干擾;`wport doctor` 會印出目前 channel。base URL 仍可用 `--api` / `WPORT_API_BASE` 覆寫。
|
|
28
|
+
|
|
19
29
|
## Quick start
|
|
20
30
|
|
|
21
31
|
```bash
|
|
@@ -314,6 +324,19 @@ Three codegen variants — pick whichever matches your setup:
|
|
|
314
324
|
|
|
315
325
|
The `:prod` / `:remote` variants go through `scripts/gen-from-remote.cjs`, which filters the upstream spec down to the endpoints this CLI uses (it ignores unrelated `$ref` breakage elsewhere in the spec). When the CLI starts using a new endpoint, add it to `KEEP_PATHS` in that script.
|
|
316
326
|
|
|
327
|
+
#### 發 dev channel 到 npm
|
|
328
|
+
|
|
329
|
+
npm version prerelease --preid=dev --no-git-tag-version # 0.9.0 → 0.9.1-dev.0(prerelease 會先進 patch)
|
|
330
|
+
npm run build:dev # 選用:發布前先在本地確認 dev build 行為正常
|
|
331
|
+
# 發布必須帶 WPORT_BUILD_CHANNEL=dev:否則 npm publish 的 prepublishOnly hook 會跑 `npm run build`(prod),
|
|
332
|
+
# 把 dist 覆寫回 prod 產物,結果 @wport/cli@dev 底下發成 prod build(靜默、不報錯)。
|
|
333
|
+
WPORT_BUILD_CHANNEL=dev npm publish --tag dev --otp <code> # 必須顯式帶 --tag dev
|
|
334
|
+
npm view @wport/cli dist-tags # 斷言 latest 未被動到
|
|
335
|
+
|
|
336
|
+
⚠️ npm 預設 tag 是 `latest`,即使版號是 prerelease;漏掉 `--tag dev` 會把 `latest` 指到 dev 版,污染所有 `npm i @wport/cli`。發布後務必用 `npm view dist-tags` 確認 `latest` 沒變。
|
|
337
|
+
|
|
338
|
+
⚠️ `package.json` 的 `prepublishOnly` 會在 `npm publish` 時自動重跑 `npm run build`(prod build,無 dev channel),覆寫掉上一步 `build:dev` 產出的 dist。真正決定 channel 的是 publish 指令本身的 `WPORT_BUILD_CHANNEL=dev` 前綴 —— 該 env 會被 npm 傳進 prepublishOnly 的子行程,讓重跑的 `npm run build` 也讀到 dev channel。漏掉這個前綴,`@wport/cli@dev` 就會靜默發成連 `api.wport.me` 的 prod build。
|
|
339
|
+
|
|
317
340
|
## Support
|
|
318
341
|
|
|
319
342
|
This CLI is in pre-release. Bug reports and feature requests are best-effort and handled directly by the maintainer.
|
package/dist/index.js
CHANGED
|
@@ -179,7 +179,7 @@ function isTimeoutAbort(err) {
|
|
|
179
179
|
return false;
|
|
180
180
|
}
|
|
181
181
|
function buildUserAgent() {
|
|
182
|
-
return `wport-cli/${"0.9.0"} (node ${process.version}; ${process.platform})`;
|
|
182
|
+
return `wport-cli/${"0.9.1-dev.0"} (node ${process.version}; ${process.platform})`;
|
|
183
183
|
}
|
|
184
184
|
function unwrapDataResponse(body) {
|
|
185
185
|
if (body && typeof body === "object" && "success" in body && "data" in body) {
|
|
@@ -366,8 +366,26 @@ function validateAndCoerce(key, value) {
|
|
|
366
366
|
}
|
|
367
367
|
}
|
|
368
368
|
|
|
369
|
+
// src/lib/channel.ts
|
|
370
|
+
var CHANNEL_BASE_URL = {
|
|
371
|
+
prod: "https://api.wport.me",
|
|
372
|
+
dev: "https://developers.wport.me/v2"
|
|
373
|
+
};
|
|
374
|
+
function currentChannel() {
|
|
375
|
+
return true ? "dev" : "prod";
|
|
376
|
+
}
|
|
377
|
+
function channelBaseUrl(channel) {
|
|
378
|
+
return CHANNEL_BASE_URL[channel] ?? CHANNEL_BASE_URL.prod;
|
|
379
|
+
}
|
|
380
|
+
function channelBanner() {
|
|
381
|
+
const channel = currentChannel();
|
|
382
|
+
if (channel === "prod") return null;
|
|
383
|
+
return `[${channel}] targeting the dev backend
|
|
384
|
+
`;
|
|
385
|
+
}
|
|
386
|
+
|
|
369
387
|
// src/lib/global-opts.ts
|
|
370
|
-
var DEFAULT_BASE_URL =
|
|
388
|
+
var DEFAULT_BASE_URL = channelBaseUrl(currentChannel());
|
|
371
389
|
var API_BASE_ENV_VAR = "WPORT_API_BASE";
|
|
372
390
|
var DEFAULT_LOCALE = "zh-TW";
|
|
373
391
|
var DEFAULT_TIMEOUT_MS = 1e4;
|
|
@@ -981,7 +999,8 @@ var KEY_PREFIX = "wpk_live_";
|
|
|
981
999
|
var KEY_MIN_LENGTH = KEY_PREFIX.length + 32;
|
|
982
1000
|
var paths2 = (0, import_env_paths2.default)("wport", { suffix: "" });
|
|
983
1001
|
function getCredentialsPath() {
|
|
984
|
-
|
|
1002
|
+
const fileName = currentChannel() === "dev" ? "credentials-dev.json" : "credentials.json";
|
|
1003
|
+
return (0, import_node_path2.join)(paths2.config, fileName);
|
|
985
1004
|
}
|
|
986
1005
|
function isValidKeyFormat(key) {
|
|
987
1006
|
return key.startsWith(KEY_PREFIX) && key.length >= KEY_MIN_LENGTH && !/\s/.test(key);
|
|
@@ -1253,11 +1272,12 @@ function registerDoctorCommand(program2) {
|
|
|
1253
1272
|
}
|
|
1254
1273
|
async function runDoctor(ctx) {
|
|
1255
1274
|
const line = (s = "") => process.stdout.write(s + "\n");
|
|
1256
|
-
line(`wport-cli ${"0.9.0"}`);
|
|
1275
|
+
line(`wport-cli ${"0.9.1-dev.0"}`);
|
|
1257
1276
|
line(` bundled schema fingerprint: ${"839e8a891dfb"}`);
|
|
1258
1277
|
line("");
|
|
1259
1278
|
line("Resolved configuration:");
|
|
1260
1279
|
line(` API base URL: ${ctx.baseUrl}`);
|
|
1280
|
+
line(` channel: ${currentChannel()}`);
|
|
1261
1281
|
line(` locale: ${ctx.locale}`);
|
|
1262
1282
|
line(` timeout: ${ctx.timeoutMs}ms`);
|
|
1263
1283
|
const cfgPath = getConfigPath();
|
|
@@ -1427,6 +1447,8 @@ function warnIfRateLimitLow(headers) {
|
|
|
1427
1447
|
|
|
1428
1448
|
// src/commands/enterprise/login.ts
|
|
1429
1449
|
async function performLogin(ctx, key) {
|
|
1450
|
+
const banner = channelBanner();
|
|
1451
|
+
if (banner) process.stderr.write(banner);
|
|
1430
1452
|
if (!isValidKeyFormat(key)) {
|
|
1431
1453
|
throw new CliError(
|
|
1432
1454
|
`That does not look like a valid ${KEY_PREFIX} key. Nothing was saved.`,
|
|
@@ -2744,6 +2766,8 @@ function describeIdentity(displayName, email) {
|
|
|
2744
2766
|
return "this device";
|
|
2745
2767
|
}
|
|
2746
2768
|
async function performLogin2(ctx, flags, deps = {}) {
|
|
2769
|
+
const banner = channelBanner();
|
|
2770
|
+
if (banner) process.stderr.write(banner);
|
|
2747
2771
|
const openBrowser = deps.openBrowser ?? openInBrowser;
|
|
2748
2772
|
const hostnameFn = deps.hostname ?? import_node_os.hostname;
|
|
2749
2773
|
if (!flags.force) {
|
|
@@ -4706,7 +4730,7 @@ function registerPersonalCommand(program2) {
|
|
|
4706
4730
|
|
|
4707
4731
|
// src/index.ts
|
|
4708
4732
|
var program = new import_commander.Command();
|
|
4709
|
-
program.name("wport").description("wport CLI \u2014 terminal interface to the W101 Talent Search Hub public API").version("0.9.0", "-v, --version", "output the CLI version").option("--lang <locale>", "Accept-Language locale: zh-TW | en-US | vi-VN | th-TH | id-ID").option("--api <url>", "override API base URL").option("--output <fmt>", "output format: table | json").option("--no-color", "disable color output").option("--timeout <ms>", "HTTP timeout in milliseconds", (v) => Number(v));
|
|
4733
|
+
program.name("wport").description("wport CLI \u2014 terminal interface to the W101 Talent Search Hub public API").version("0.9.1-dev.0", "-v, --version", "output the CLI version").option("--lang <locale>", "Accept-Language locale: zh-TW | en-US | vi-VN | th-TH | id-ID").option("--api <url>", "override API base URL").option("--output <fmt>", "output format: table | json").option("--no-color", "disable color output").option("--timeout <ms>", "HTTP timeout in milliseconds", (v) => Number(v));
|
|
4710
4734
|
registerJobsCommand(program);
|
|
4711
4735
|
registerConfigCommand(program);
|
|
4712
4736
|
registerDoctorCommand(program);
|