pingcode-cli-unofficial 2.3.0 → 2.3.1
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 +16 -7
- package/dist/bin/pingcode.js +220 -112
- package/dist/bin/pingcode.js.map +1 -1
- package/package.json +3 -1
package/dist/bin/pingcode.js
CHANGED
|
@@ -978,7 +978,7 @@ var require_command = __commonJS({
|
|
|
978
978
|
"use strict";
|
|
979
979
|
var EventEmitter = __require("events").EventEmitter;
|
|
980
980
|
var childProcess = __require("child_process");
|
|
981
|
-
var
|
|
981
|
+
var path12 = __require("path");
|
|
982
982
|
var fs = __require("fs");
|
|
983
983
|
var process2 = __require("process");
|
|
984
984
|
var { Argument: Argument2, humanReadableArgName } = require_argument();
|
|
@@ -1911,9 +1911,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1911
1911
|
let launchWithNode = false;
|
|
1912
1912
|
const sourceExt = [".js", ".ts", ".tsx", ".mjs", ".cjs"];
|
|
1913
1913
|
function findFile(baseDir, baseName) {
|
|
1914
|
-
const localBin =
|
|
1914
|
+
const localBin = path12.resolve(baseDir, baseName);
|
|
1915
1915
|
if (fs.existsSync(localBin)) return localBin;
|
|
1916
|
-
if (sourceExt.includes(
|
|
1916
|
+
if (sourceExt.includes(path12.extname(baseName))) return void 0;
|
|
1917
1917
|
const foundExt = sourceExt.find(
|
|
1918
1918
|
(ext) => fs.existsSync(`${localBin}${ext}`)
|
|
1919
1919
|
);
|
|
@@ -1931,17 +1931,17 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1931
1931
|
} catch (err) {
|
|
1932
1932
|
resolvedScriptPath = this._scriptPath;
|
|
1933
1933
|
}
|
|
1934
|
-
executableDir =
|
|
1935
|
-
|
|
1934
|
+
executableDir = path12.resolve(
|
|
1935
|
+
path12.dirname(resolvedScriptPath),
|
|
1936
1936
|
executableDir
|
|
1937
1937
|
);
|
|
1938
1938
|
}
|
|
1939
1939
|
if (executableDir) {
|
|
1940
1940
|
let localFile = findFile(executableDir, executableFile);
|
|
1941
1941
|
if (!localFile && !subcommand._executableFile && this._scriptPath) {
|
|
1942
|
-
const legacyName =
|
|
1942
|
+
const legacyName = path12.basename(
|
|
1943
1943
|
this._scriptPath,
|
|
1944
|
-
|
|
1944
|
+
path12.extname(this._scriptPath)
|
|
1945
1945
|
);
|
|
1946
1946
|
if (legacyName !== this._name) {
|
|
1947
1947
|
localFile = findFile(
|
|
@@ -1952,7 +1952,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
1952
1952
|
}
|
|
1953
1953
|
executableFile = localFile || executableFile;
|
|
1954
1954
|
}
|
|
1955
|
-
launchWithNode = sourceExt.includes(
|
|
1955
|
+
launchWithNode = sourceExt.includes(path12.extname(executableFile));
|
|
1956
1956
|
let proc;
|
|
1957
1957
|
if (process2.platform !== "win32") {
|
|
1958
1958
|
if (launchWithNode) {
|
|
@@ -2792,7 +2792,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2792
2792
|
* @return {Command}
|
|
2793
2793
|
*/
|
|
2794
2794
|
nameFromFilename(filename) {
|
|
2795
|
-
this._name =
|
|
2795
|
+
this._name = path12.basename(filename, path12.extname(filename));
|
|
2796
2796
|
return this;
|
|
2797
2797
|
}
|
|
2798
2798
|
/**
|
|
@@ -2806,9 +2806,9 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
2806
2806
|
* @param {string} [path]
|
|
2807
2807
|
* @return {(string|null|Command)}
|
|
2808
2808
|
*/
|
|
2809
|
-
executableDir(
|
|
2810
|
-
if (
|
|
2811
|
-
this._executableDir =
|
|
2809
|
+
executableDir(path13) {
|
|
2810
|
+
if (path13 === void 0) return this._executableDir;
|
|
2811
|
+
this._executableDir = path13;
|
|
2812
2812
|
return this;
|
|
2813
2813
|
}
|
|
2814
2814
|
/**
|
|
@@ -3421,12 +3421,41 @@ var init_output = __esm({
|
|
|
3421
3421
|
}
|
|
3422
3422
|
});
|
|
3423
3423
|
|
|
3424
|
+
// src/core/package-version.ts
|
|
3425
|
+
import { readFileSync } from "fs";
|
|
3426
|
+
function readPackageVersion() {
|
|
3427
|
+
try {
|
|
3428
|
+
const raw = readFileSync(new URL("../../package.json", import.meta.url), "utf8");
|
|
3429
|
+
const parsed = JSON.parse(raw);
|
|
3430
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) return void 0;
|
|
3431
|
+
const record = parsed;
|
|
3432
|
+
if (record.name !== PACKAGE_NAME) return void 0;
|
|
3433
|
+
return typeof record.version === "string" ? record.version : void 0;
|
|
3434
|
+
} catch {
|
|
3435
|
+
return void 0;
|
|
3436
|
+
}
|
|
3437
|
+
}
|
|
3438
|
+
function requirePackageVersion() {
|
|
3439
|
+
const version = readPackageVersion();
|
|
3440
|
+
if (version === void 0) {
|
|
3441
|
+
throw new Error("cannot read version from the running package.json");
|
|
3442
|
+
}
|
|
3443
|
+
return version;
|
|
3444
|
+
}
|
|
3445
|
+
var PACKAGE_NAME, VERSION;
|
|
3446
|
+
var init_package_version = __esm({
|
|
3447
|
+
"src/core/package-version.ts"() {
|
|
3448
|
+
"use strict";
|
|
3449
|
+
PACKAGE_NAME = "pingcode-cli-unofficial";
|
|
3450
|
+
VERSION = requirePackageVersion();
|
|
3451
|
+
}
|
|
3452
|
+
});
|
|
3453
|
+
|
|
3424
3454
|
// src/version.ts
|
|
3425
|
-
var VERSION;
|
|
3426
3455
|
var init_version = __esm({
|
|
3427
3456
|
"src/version.ts"() {
|
|
3428
3457
|
"use strict";
|
|
3429
|
-
|
|
3458
|
+
init_package_version();
|
|
3430
3459
|
}
|
|
3431
3460
|
});
|
|
3432
3461
|
|
|
@@ -3464,7 +3493,7 @@ import {
|
|
|
3464
3493
|
chmodSync,
|
|
3465
3494
|
existsSync,
|
|
3466
3495
|
mkdirSync,
|
|
3467
|
-
readFileSync,
|
|
3496
|
+
readFileSync as readFileSync2,
|
|
3468
3497
|
renameSync,
|
|
3469
3498
|
rmSync,
|
|
3470
3499
|
statSync,
|
|
@@ -3519,7 +3548,7 @@ function loadConfig(env = process.env, logger = silentLogger) {
|
|
|
3519
3548
|
const file = configFilePath(env);
|
|
3520
3549
|
let raw;
|
|
3521
3550
|
try {
|
|
3522
|
-
raw =
|
|
3551
|
+
raw = readFileSync2(file, "utf8");
|
|
3523
3552
|
} catch (error) {
|
|
3524
3553
|
if (isNotFound(error)) return {};
|
|
3525
3554
|
throw new UsageError(`cannot read ${file}: ${errorMessage(error)}`, { cause: error });
|
|
@@ -4524,9 +4553,9 @@ var init_catalog = __esm({
|
|
|
4524
4553
|
function isMutating(method) {
|
|
4525
4554
|
return MUTATING.has(method.toUpperCase());
|
|
4526
4555
|
}
|
|
4527
|
-
function buildUrl(apiBase,
|
|
4556
|
+
function buildUrl(apiBase, path12, query) {
|
|
4528
4557
|
const base = apiBase.replace(/\/+$/, "");
|
|
4529
|
-
const relative =
|
|
4558
|
+
const relative = path12.startsWith("/") ? path12 : `/${path12}`;
|
|
4530
4559
|
const url = new URL(`${base}${relative}`);
|
|
4531
4560
|
if (query !== void 0) {
|
|
4532
4561
|
for (const [key, value] of Object.entries(query)) {
|
|
@@ -5386,12 +5415,12 @@ function normalizeEnvelope(raw, requested) {
|
|
|
5386
5415
|
values
|
|
5387
5416
|
};
|
|
5388
5417
|
}
|
|
5389
|
-
async function fetchPage(ctx,
|
|
5418
|
+
async function fetchPage(ctx, path12, query = {}, page = {}) {
|
|
5390
5419
|
const pageIndex = validatePageIndex(page.pageIndex ?? 0);
|
|
5391
5420
|
const pageSize = validatePageSize(page.pageSize ?? DEFAULT_PAGE_SIZE);
|
|
5392
5421
|
const raw = await request(ctx, {
|
|
5393
5422
|
method: "GET",
|
|
5394
|
-
path:
|
|
5423
|
+
path: path12,
|
|
5395
5424
|
query: { ...query, page_index: pageIndex, page_size: pageSize }
|
|
5396
5425
|
});
|
|
5397
5426
|
return normalizeEnvelope(raw, { pageIndex, pageSize });
|
|
@@ -5424,8 +5453,8 @@ async function* walkPages(ctx, fetchOne, options, label) {
|
|
|
5424
5453
|
pageIndex += 1;
|
|
5425
5454
|
}
|
|
5426
5455
|
}
|
|
5427
|
-
async function* paginate(ctx,
|
|
5428
|
-
yield* walkPages(ctx, (page) => fetchPage(ctx,
|
|
5456
|
+
async function* paginate(ctx, path12, query = {}, options = {}) {
|
|
5457
|
+
yield* walkPages(ctx, (page) => fetchPage(ctx, path12, query, page), options, "GET-list");
|
|
5429
5458
|
}
|
|
5430
5459
|
function asReadContext(ctx) {
|
|
5431
5460
|
return ctx.dryRun ? { ...ctx, dryRun: false } : ctx;
|
|
@@ -5441,20 +5470,20 @@ function buildSearchBody(payload, page) {
|
|
|
5441
5470
|
body.page_size = page.pageSize;
|
|
5442
5471
|
return { mode: "query", payload: body };
|
|
5443
5472
|
}
|
|
5444
|
-
async function fetchSearchPage(ctx,
|
|
5473
|
+
async function fetchSearchPage(ctx, path12, payload = {}, page = {}) {
|
|
5445
5474
|
const pageIndex = validatePageIndex(page.pageIndex ?? 0);
|
|
5446
5475
|
const pageSize = validatePageSize(page.pageSize ?? DEFAULT_PAGE_SIZE);
|
|
5447
5476
|
const raw = await request(asReadContext(ctx), {
|
|
5448
5477
|
method: "POST",
|
|
5449
|
-
path:
|
|
5478
|
+
path: path12,
|
|
5450
5479
|
body: buildSearchBody(payload, { pageIndex, pageSize })
|
|
5451
5480
|
});
|
|
5452
5481
|
return normalizeEnvelope(raw, { pageIndex, pageSize });
|
|
5453
5482
|
}
|
|
5454
|
-
async function* searchPaginate(ctx,
|
|
5483
|
+
async function* searchPaginate(ctx, path12, payload = {}, options = {}) {
|
|
5455
5484
|
yield* walkPages(
|
|
5456
5485
|
ctx,
|
|
5457
|
-
(page) => fetchSearchPage(ctx,
|
|
5486
|
+
(page) => fetchSearchPage(ctx, path12, payload, page),
|
|
5458
5487
|
options,
|
|
5459
5488
|
"search"
|
|
5460
5489
|
);
|
|
@@ -7055,7 +7084,7 @@ var init_registry = __esm({
|
|
|
7055
7084
|
|
|
7056
7085
|
// src/core/metadata/resolve.ts
|
|
7057
7086
|
import { createHash } from "crypto";
|
|
7058
|
-
import { mkdirSync as mkdirSync2, readFileSync as
|
|
7087
|
+
import { mkdirSync as mkdirSync2, readFileSync as readFileSync3, rmSync as rmSync2, writeFileSync as writeFileSync2 } from "fs";
|
|
7059
7088
|
import path2 from "path";
|
|
7060
7089
|
function cacheKeyFor(parts) {
|
|
7061
7090
|
const material = JSON.stringify([
|
|
@@ -7084,7 +7113,7 @@ function readCache(ctx, key) {
|
|
|
7084
7113
|
if (!ctx.useCache) return void 0;
|
|
7085
7114
|
let raw;
|
|
7086
7115
|
try {
|
|
7087
|
-
raw =
|
|
7116
|
+
raw = readFileSync3(cacheFilePath(ctx, key), "utf8");
|
|
7088
7117
|
} catch {
|
|
7089
7118
|
return void 0;
|
|
7090
7119
|
}
|
|
@@ -7172,9 +7201,9 @@ async function loadSuiteTree(ctx, path_, query) {
|
|
|
7172
7201
|
}
|
|
7173
7202
|
const candidates = [];
|
|
7174
7203
|
for (const [id, node] of nodes) {
|
|
7175
|
-
const
|
|
7176
|
-
const candidate = { id, name: node.name, path:
|
|
7177
|
-
if (
|
|
7204
|
+
const path12 = suitePath(nodes, id);
|
|
7205
|
+
const candidate = { id, name: node.name, path: path12 };
|
|
7206
|
+
if (path12 !== void 0 && path12 !== node.name) candidate.aliases = [path12];
|
|
7178
7207
|
candidates.push(candidate);
|
|
7179
7208
|
}
|
|
7180
7209
|
return candidates;
|
|
@@ -7946,29 +7975,29 @@ endpoints; a wiki page and a code branch are the two with no recovery path at al
|
|
|
7946
7975
|
}
|
|
7947
7976
|
}
|
|
7948
7977
|
async function runVerb(method, pathArgument, flags, self) {
|
|
7949
|
-
const { candidates, path:
|
|
7978
|
+
const { candidates, path: path12 } = resolveEntry2(method, pathArgument);
|
|
7950
7979
|
const { ctx } = contextFor(self);
|
|
7951
7980
|
refuseUserTokenEndpoint(ctx, candidates);
|
|
7952
7981
|
const query = parseQueryFlags(flags.query);
|
|
7953
|
-
refuseUnconfirmedDelete(method,
|
|
7982
|
+
refuseUnconfirmedDelete(method, path12, query, flags);
|
|
7954
7983
|
const body = await readBodyFlags(flags);
|
|
7955
7984
|
const entry = chooseEntry(candidates, query, body);
|
|
7956
7985
|
const paging = readPagingFor(entry, flags);
|
|
7957
7986
|
try {
|
|
7958
|
-
await send(ctx, entry,
|
|
7987
|
+
await send(ctx, entry, path12, query, body, paging);
|
|
7959
7988
|
} catch (error) {
|
|
7960
7989
|
if (error instanceof PermissionError) errLine(paint.dim(declaredScopeLine(entry)));
|
|
7961
7990
|
throw error;
|
|
7962
7991
|
}
|
|
7963
7992
|
}
|
|
7964
|
-
async function send(ctx, entry,
|
|
7993
|
+
async function send(ctx, entry, path12, query, body, paging) {
|
|
7965
7994
|
if (entry.paged === "search") {
|
|
7966
|
-
await sendSearch(ctx,
|
|
7995
|
+
await sendSearch(ctx, path12, body, paging);
|
|
7967
7996
|
return;
|
|
7968
7997
|
}
|
|
7969
7998
|
if (entry.paged === "query" && paging.all) {
|
|
7970
7999
|
const values = await collect(
|
|
7971
|
-
paginate(ctx,
|
|
8000
|
+
paginate(ctx, path12, query, {
|
|
7972
8001
|
pageSize: paging.pageSize,
|
|
7973
8002
|
startPage: paging.pageIndex,
|
|
7974
8003
|
limit: paging.limit
|
|
@@ -7979,17 +8008,17 @@ async function send(ctx, entry, path11, query, body, paging) {
|
|
|
7979
8008
|
}
|
|
7980
8009
|
const raw = await request(ctx, {
|
|
7981
8010
|
method: entry.method,
|
|
7982
|
-
path:
|
|
8011
|
+
path: path12,
|
|
7983
8012
|
query: paging.requested ? { ...query, page_index: paging.pageIndex, page_size: paging.pageSize } : query,
|
|
7984
8013
|
...body === void 0 ? {} : { body }
|
|
7985
8014
|
});
|
|
7986
8015
|
printResponse(raw);
|
|
7987
8016
|
}
|
|
7988
|
-
async function sendSearch(ctx,
|
|
8017
|
+
async function sendSearch(ctx, path12, body, paging) {
|
|
7989
8018
|
const payload = searchPayloadOf(body);
|
|
7990
8019
|
if (paging.all) {
|
|
7991
8020
|
const values = await collect(
|
|
7992
|
-
searchPaginate(ctx,
|
|
8021
|
+
searchPaginate(ctx, path12, payload, {
|
|
7993
8022
|
pageSize: paging.pageSize,
|
|
7994
8023
|
startPage: paging.pageIndex,
|
|
7995
8024
|
limit: paging.limit
|
|
@@ -7998,7 +8027,7 @@ async function sendSearch(ctx, path11, body, paging) {
|
|
|
7998
8027
|
printJson({ values, count: values.length, all: true });
|
|
7999
8028
|
return;
|
|
8000
8029
|
}
|
|
8001
|
-
const page = await fetchSearchPage(ctx,
|
|
8030
|
+
const page = await fetchSearchPage(ctx, path12, payload, {
|
|
8002
8031
|
pageIndex: paging.pageIndex,
|
|
8003
8032
|
pageSize: paging.pageSize
|
|
8004
8033
|
});
|
|
@@ -8032,8 +8061,8 @@ function resolveEntry2(method, pathArgument) {
|
|
|
8032
8061
|
hint: `drop everything from "?" and pass the parameters as --query key=value (repeatable), so they are serialised the same way every other command does it`
|
|
8033
8062
|
});
|
|
8034
8063
|
}
|
|
8035
|
-
const
|
|
8036
|
-
const unfilled = unfilledPathParams(
|
|
8064
|
+
const path12 = normalizePath(raw);
|
|
8065
|
+
const unfilled = unfilledPathParams(path12);
|
|
8037
8066
|
if (unfilled.length > 0) {
|
|
8038
8067
|
throw new UsageError(
|
|
8039
8068
|
`the path still contains the placeholder${unfilled.length > 1 ? "s" : ""} ${unfilled.map((name) => `{${name}}`).join(", ")}`,
|
|
@@ -8042,32 +8071,32 @@ function resolveEntry2(method, pathArgument) {
|
|
|
8042
8071
|
}
|
|
8043
8072
|
);
|
|
8044
8073
|
}
|
|
8045
|
-
const onPath = matchPath(
|
|
8046
|
-
if (onPath.length === 0) throw unknownPath(
|
|
8074
|
+
const onPath = matchPath(path12);
|
|
8075
|
+
if (onPath.length === 0) throw unknownPath(path12);
|
|
8047
8076
|
const candidates = onPath.filter((candidate) => candidate.method === method);
|
|
8048
8077
|
if (candidates.length === 0) {
|
|
8049
|
-
const supported = methodsFor(
|
|
8050
|
-
throw new UsageError(`${method} ${
|
|
8078
|
+
const supported = methodsFor(path12);
|
|
8079
|
+
throw new UsageError(`${method} ${path12} is not a documented endpoint`, {
|
|
8051
8080
|
hint: `that path supports ${supported.join(", ")} \u2014 this API is missing several symmetric operations on purpose (there is no project delete, no sprint delete, and nothing in \u4EA7\u54C1\u7BA1\u7406 can be deleted at all)`
|
|
8052
8081
|
});
|
|
8053
8082
|
}
|
|
8054
|
-
return { candidates, path:
|
|
8083
|
+
return { candidates, path: path12 };
|
|
8055
8084
|
}
|
|
8056
|
-
function unknownPath(
|
|
8057
|
-
if (segmentsOf2(
|
|
8085
|
+
function unknownPath(path12) {
|
|
8086
|
+
if (segmentsOf2(path12).includes("authorize")) {
|
|
8058
8087
|
return new UsageError(
|
|
8059
|
-
`${
|
|
8088
|
+
`${path12} is the browser authorization page of the OAuth2 authorization-code flow, not a REST endpoint: it renders HTML for a human to click and redirects, it returns no JSON, and it is not under /v1`,
|
|
8060
8089
|
{ hint: AUTHORIZE_HINT }
|
|
8061
8090
|
);
|
|
8062
8091
|
}
|
|
8063
|
-
const suggestions = nearestPaths(
|
|
8064
|
-
const hint = suggestions.length === 0 ? `no documented path has ${segmentsOf2(
|
|
8065
|
-
return new UsageError(`${
|
|
8092
|
+
const suggestions = nearestPaths(path12);
|
|
8093
|
+
const hint = suggestions.length === 0 ? `no documented path has ${segmentsOf2(path12).length} segments like this one \u2014 search the catalog with \`pingcode api list --search <text>\`` : `did you mean ${suggestions.join(" , ")} ? \u2014 or search with \`pingcode api list --search <text>\``;
|
|
8094
|
+
return new UsageError(`${path12} is not in the endpoint catalog (459 documented v1 endpoints)`, {
|
|
8066
8095
|
hint
|
|
8067
8096
|
});
|
|
8068
8097
|
}
|
|
8069
|
-
function nearestPaths(
|
|
8070
|
-
const actual = segmentsOf2(
|
|
8098
|
+
function nearestPaths(path12) {
|
|
8099
|
+
const actual = segmentsOf2(path12);
|
|
8071
8100
|
const scored = /* @__PURE__ */ new Map();
|
|
8072
8101
|
for (const entry of CATALOG2) {
|
|
8073
8102
|
const template = segmentsOf2(entry.path);
|
|
@@ -8096,8 +8125,8 @@ function editDistance(a2, b3) {
|
|
|
8096
8125
|
}
|
|
8097
8126
|
return previous[b3.length] ?? Math.max(a2.length, b3.length);
|
|
8098
8127
|
}
|
|
8099
|
-
function segmentsOf2(
|
|
8100
|
-
return
|
|
8128
|
+
function segmentsOf2(path12) {
|
|
8129
|
+
return path12.split("/").filter((segment) => segment !== "");
|
|
8101
8130
|
}
|
|
8102
8131
|
function isPlaceholder2(segment) {
|
|
8103
8132
|
return segment.startsWith("{") && segment.endsWith("}");
|
|
@@ -8114,9 +8143,9 @@ function refuseUserTokenEndpoint(ctx, candidates) {
|
|
|
8114
8143
|
}
|
|
8115
8144
|
);
|
|
8116
8145
|
}
|
|
8117
|
-
function refuseUnconfirmedDelete(method,
|
|
8146
|
+
function refuseUnconfirmedDelete(method, path12, query, flags) {
|
|
8118
8147
|
if (method !== "DELETE" || flags.yes === true) return;
|
|
8119
|
-
throw new UsageError(`refusing to send DELETE ${
|
|
8148
|
+
throw new UsageError(`refusing to send DELETE ${path12}${displayQuery(query)} without --yes`, {
|
|
8120
8149
|
hint: "re-run with --yes to send it, or with --yes --dry-run to print the full request plan without sending anything"
|
|
8121
8150
|
});
|
|
8122
8151
|
}
|
|
@@ -8278,22 +8307,22 @@ function registerDescribe(api) {
|
|
|
8278
8307
|
"\nAn id is exact; a method + path is matched through the same wildcard rules the\nexecutor uses. GET /v1/auth/token is the one path three entries share (the three\ngrants), so address those by id.\n--json prints the catalog entry verbatim.\n"
|
|
8279
8308
|
);
|
|
8280
8309
|
addGlobalOptions(command, { hidden: true }).action(
|
|
8281
|
-
(idOrMethod,
|
|
8310
|
+
(idOrMethod, path12, _flags, self) => {
|
|
8282
8311
|
const { ctx } = contextFor(self);
|
|
8283
|
-
const entry = lookupForDescribe(idOrMethod,
|
|
8312
|
+
const entry = lookupForDescribe(idOrMethod, path12);
|
|
8284
8313
|
printEntry(entry, modeOf(ctx));
|
|
8285
8314
|
}
|
|
8286
8315
|
);
|
|
8287
8316
|
}
|
|
8288
|
-
function lookupForDescribe(idOrMethod,
|
|
8289
|
-
if (
|
|
8317
|
+
function lookupForDescribe(idOrMethod, path12) {
|
|
8318
|
+
if (path12 !== void 0) {
|
|
8290
8319
|
const method = idOrMethod.trim().toUpperCase();
|
|
8291
8320
|
if (!METHODS.includes(method)) {
|
|
8292
8321
|
throw new UsageError(`"${idOrMethod}" is not an HTTP method`, {
|
|
8293
8322
|
hint: `the methods are ${METHODS.join(", ")} \u2014 or pass a single catalog id instead`
|
|
8294
8323
|
});
|
|
8295
8324
|
}
|
|
8296
|
-
const normalized = normalizePath(
|
|
8325
|
+
const normalized = normalizePath(path12.trim());
|
|
8297
8326
|
const matches = matchPath(normalized).filter((entry2) => entry2.method === method);
|
|
8298
8327
|
const entry = matches[0];
|
|
8299
8328
|
if (entry === void 0) {
|
|
@@ -8470,26 +8499,26 @@ function parseRefList(raw) {
|
|
|
8470
8499
|
function parseProperties(raw) {
|
|
8471
8500
|
return typeof raw === "object" && raw !== null && !Array.isArray(raw) ? raw : void 0;
|
|
8472
8501
|
}
|
|
8473
|
-
async function fetchPageOf(ctx,
|
|
8474
|
-
const raw = await fetchPage(ctx,
|
|
8502
|
+
async function fetchPageOf(ctx, path12, query, page, parse) {
|
|
8503
|
+
const raw = await fetchPage(ctx, path12, query, page);
|
|
8475
8504
|
return { ...raw, values: raw.values.map(parse) };
|
|
8476
8505
|
}
|
|
8477
|
-
async function* iterateOf(ctx,
|
|
8478
|
-
for await (const raw of paginate(ctx,
|
|
8506
|
+
async function* iterateOf(ctx, path12, query, options, parse) {
|
|
8507
|
+
for await (const raw of paginate(ctx, path12, query, options)) {
|
|
8479
8508
|
yield parse(raw);
|
|
8480
8509
|
}
|
|
8481
8510
|
}
|
|
8482
|
-
async function listAllOf(ctx,
|
|
8511
|
+
async function listAllOf(ctx, path12, query, parse, options = {}) {
|
|
8483
8512
|
return await collect(
|
|
8484
|
-
iterateOf(ctx,
|
|
8513
|
+
iterateOf(ctx, path12, query, { pageSize: 100, limit: 1e3, ...options }, parse)
|
|
8485
8514
|
);
|
|
8486
8515
|
}
|
|
8487
|
-
async function fetchSearchPageOf(ctx,
|
|
8488
|
-
const raw = await fetchSearchPage(ctx,
|
|
8516
|
+
async function fetchSearchPageOf(ctx, path12, payload, page, parse) {
|
|
8517
|
+
const raw = await fetchSearchPage(ctx, path12, payload, page);
|
|
8489
8518
|
return { ...raw, values: raw.values.map(parse) };
|
|
8490
8519
|
}
|
|
8491
|
-
async function* iterateSearchOf(ctx,
|
|
8492
|
-
for await (const raw of searchPaginate(ctx,
|
|
8520
|
+
async function* iterateSearchOf(ctx, path12, payload, options, parse) {
|
|
8521
|
+
for await (const raw of searchPaginate(ctx, path12, payload, options)) {
|
|
8493
8522
|
yield parse(raw);
|
|
8494
8523
|
}
|
|
8495
8524
|
}
|
|
@@ -13103,13 +13132,13 @@ var init_projectMember = __esm({
|
|
|
13103
13132
|
|
|
13104
13133
|
// src/cli/commands/_shared/bulkEntries.ts
|
|
13105
13134
|
async function readBulkEntries(source, options) {
|
|
13106
|
-
const
|
|
13107
|
-
if (
|
|
13135
|
+
const path12 = source.file?.trim() ?? "";
|
|
13136
|
+
if (path12 === "") {
|
|
13108
13137
|
throw new UsageError("--file <path|-> is required", {
|
|
13109
13138
|
hint: "pass a JSON array of entries, or - to read it from stdin. Each entry needs name, start and end; project and assignee may be shared with --project / --assignee"
|
|
13110
13139
|
});
|
|
13111
13140
|
}
|
|
13112
|
-
const document =
|
|
13141
|
+
const document = path12 === "-" ? await readJsonStdin() : parseJsonDocument(await readTextFile(path12, "--file"), `--file ${path12}`);
|
|
13113
13142
|
const list = unwrap(document, options.wrapperKey);
|
|
13114
13143
|
if (list.length === 0) {
|
|
13115
13144
|
throw new UsageError("--file contained no entries", {
|
|
@@ -17661,6 +17690,67 @@ function compareSemver(a2, b3) {
|
|
|
17661
17690
|
}
|
|
17662
17691
|
return 0;
|
|
17663
17692
|
}
|
|
17693
|
+
function parseComparableVersion(raw) {
|
|
17694
|
+
let version = raw.startsWith("v") ? raw.slice(1) : raw;
|
|
17695
|
+
const buildIndex = version.indexOf("+");
|
|
17696
|
+
if (buildIndex !== -1) {
|
|
17697
|
+
const build = version.slice(buildIndex + 1);
|
|
17698
|
+
if (build.includes("+") || !build.split(".").every((identifier) => SEMVER_IDENTIFIER.test(identifier))) {
|
|
17699
|
+
return void 0;
|
|
17700
|
+
}
|
|
17701
|
+
version = version.slice(0, buildIndex);
|
|
17702
|
+
}
|
|
17703
|
+
const prereleaseIndex = version.indexOf("-");
|
|
17704
|
+
const coreText = prereleaseIndex === -1 ? version : version.slice(0, prereleaseIndex);
|
|
17705
|
+
const prereleaseText = prereleaseIndex === -1 ? void 0 : version.slice(prereleaseIndex + 1);
|
|
17706
|
+
const parts = coreText.split(".");
|
|
17707
|
+
if (parts.length !== 3 || !SEMVER_COMPONENT.test(parts[0]) || !SEMVER_COMPONENT.test(parts[1]) || !SEMVER_COMPONENT.test(parts[2])) {
|
|
17708
|
+
return void 0;
|
|
17709
|
+
}
|
|
17710
|
+
let prerelease;
|
|
17711
|
+
if (prereleaseText !== void 0) {
|
|
17712
|
+
prerelease = prereleaseText.split(".");
|
|
17713
|
+
const valid = prerelease.every((identifier) => SEMVER_IDENTIFIER.test(identifier) && (!/^\d+$/.test(identifier) || SEMVER_COMPONENT.test(identifier)));
|
|
17714
|
+
if (!valid) return void 0;
|
|
17715
|
+
}
|
|
17716
|
+
return {
|
|
17717
|
+
core: [BigInt(parts[0]), BigInt(parts[1]), BigInt(parts[2])],
|
|
17718
|
+
prerelease
|
|
17719
|
+
};
|
|
17720
|
+
}
|
|
17721
|
+
function comparePrerelease(left, right) {
|
|
17722
|
+
const sharedLength = Math.min(left.length, right.length);
|
|
17723
|
+
for (let index = 0; index < sharedLength; index += 1) {
|
|
17724
|
+
const leftIdentifier = left[index];
|
|
17725
|
+
const rightIdentifier = right[index];
|
|
17726
|
+
if (leftIdentifier === rightIdentifier) continue;
|
|
17727
|
+
const leftNumeric = /^\d+$/.test(leftIdentifier);
|
|
17728
|
+
const rightNumeric = /^\d+$/.test(rightIdentifier);
|
|
17729
|
+
if (leftNumeric && rightNumeric) {
|
|
17730
|
+
return BigInt(leftIdentifier) < BigInt(rightIdentifier) ? -1 : 1;
|
|
17731
|
+
}
|
|
17732
|
+
if (leftNumeric !== rightNumeric) return leftNumeric ? -1 : 1;
|
|
17733
|
+
return leftIdentifier < rightIdentifier ? -1 : 1;
|
|
17734
|
+
}
|
|
17735
|
+
return left.length - right.length;
|
|
17736
|
+
}
|
|
17737
|
+
function compareComparableVersions(left, right) {
|
|
17738
|
+
for (let index = 0; index < left.core.length; index += 1) {
|
|
17739
|
+
const leftPart = left.core[index];
|
|
17740
|
+
const rightPart = right.core[index];
|
|
17741
|
+
if (leftPart !== rightPart) return leftPart < rightPart ? -1 : 1;
|
|
17742
|
+
}
|
|
17743
|
+
if (left.prerelease === void 0 || right.prerelease === void 0) {
|
|
17744
|
+
if (left.prerelease === right.prerelease) return 0;
|
|
17745
|
+
return left.prerelease === void 0 ? 1 : -1;
|
|
17746
|
+
}
|
|
17747
|
+
return comparePrerelease(left.prerelease, right.prerelease);
|
|
17748
|
+
}
|
|
17749
|
+
function isNewerVersion(candidate, current) {
|
|
17750
|
+
const candidateVersion = parseComparableVersion(candidate);
|
|
17751
|
+
const currentVersion = parseComparableVersion(current);
|
|
17752
|
+
return candidateVersion !== void 0 && currentVersion !== void 0 && compareComparableVersions(currentVersion, candidateVersion) < 0;
|
|
17753
|
+
}
|
|
17664
17754
|
function cacheFilePath2() {
|
|
17665
17755
|
return path3.join(configDir(), CACHE_FILENAME);
|
|
17666
17756
|
}
|
|
@@ -17737,29 +17827,25 @@ async function checkForUpdate(env = process.env, opts) {
|
|
|
17737
17827
|
return { status: "unknown" };
|
|
17738
17828
|
}
|
|
17739
17829
|
function compareVersions(remote) {
|
|
17740
|
-
|
|
17741
|
-
const remoteParts = parseSemver(remote);
|
|
17742
|
-
if (localParts === void 0 || remoteParts === void 0) {
|
|
17743
|
-
return { status: "up-to-date" };
|
|
17744
|
-
}
|
|
17745
|
-
if (compareSemver(localParts, remoteParts) < 0) {
|
|
17830
|
+
if (isNewerVersion(remote, VERSION)) {
|
|
17746
17831
|
return { status: "update-available", current: VERSION, latest: remote };
|
|
17747
17832
|
}
|
|
17748
17833
|
return { status: "up-to-date" };
|
|
17749
17834
|
}
|
|
17750
|
-
var
|
|
17835
|
+
var PACKAGE_NAME2, REGISTRY_URL, CHECK_TIMEOUT_MS, CACHE_TTL_MS2, CACHE_FILENAME, ENV_NO_UPDATE_CHECK, SEMVER_COMPONENT, SEMVER_IDENTIFIER;
|
|
17751
17836
|
var init_update_check = __esm({
|
|
17752
17837
|
"src/core/update-check.ts"() {
|
|
17753
17838
|
"use strict";
|
|
17754
17839
|
init_config();
|
|
17755
17840
|
init_version();
|
|
17756
|
-
|
|
17757
|
-
REGISTRY_URL = `https://registry.npmjs.org/${encodeURIComponent(
|
|
17841
|
+
PACKAGE_NAME2 = "pingcode-cli-unofficial";
|
|
17842
|
+
REGISTRY_URL = `https://registry.npmjs.org/${encodeURIComponent(PACKAGE_NAME2)}`;
|
|
17758
17843
|
CHECK_TIMEOUT_MS = 5e3;
|
|
17759
17844
|
CACHE_TTL_MS2 = 24 * 60 * 60 * 1e3;
|
|
17760
17845
|
CACHE_FILENAME = "update-check.json";
|
|
17761
17846
|
ENV_NO_UPDATE_CHECK = "PINGCODE_NO_UPDATE_CHECK";
|
|
17762
17847
|
SEMVER_COMPONENT = /^(0|[1-9]\d*)$/;
|
|
17848
|
+
SEMVER_IDENTIFIER = /^[0-9A-Za-z-]+$/;
|
|
17763
17849
|
}
|
|
17764
17850
|
});
|
|
17765
17851
|
|
|
@@ -17842,7 +17928,7 @@ import {
|
|
|
17842
17928
|
copyFileSync,
|
|
17843
17929
|
existsSync as existsSync2,
|
|
17844
17930
|
mkdirSync as mkdirSync3,
|
|
17845
|
-
readFileSync as
|
|
17931
|
+
readFileSync as readFileSync4,
|
|
17846
17932
|
readdirSync,
|
|
17847
17933
|
rmSync as rmSync3,
|
|
17848
17934
|
statSync as statSync2,
|
|
@@ -17932,7 +18018,7 @@ async function installViaNpm(exec2, version) {
|
|
|
17932
18018
|
{ hint: `install Node.js, then re-run this command` }
|
|
17933
18019
|
);
|
|
17934
18020
|
}
|
|
17935
|
-
const spec = `${
|
|
18021
|
+
const spec = `${PACKAGE_NAME3}@${version}`;
|
|
17936
18022
|
let output;
|
|
17937
18023
|
try {
|
|
17938
18024
|
output = exec2(npm, ["install", "--global", spec]);
|
|
@@ -17955,20 +18041,12 @@ async function installViaNpm(exec2, version) {
|
|
|
17955
18041
|
if (installed !== version) {
|
|
17956
18042
|
throw new TransportError(
|
|
17957
18043
|
`npm install --global ${spec} exited 0 but the installed version is ${installed ?? "unreadable"}, expected ${version}`,
|
|
17958
|
-
{ hint: `verify with: ${npm} list --global --depth=0 ${
|
|
18044
|
+
{ hint: `verify with: ${npm} list --global --depth=0 ${PACKAGE_NAME3}` }
|
|
17959
18045
|
);
|
|
17960
18046
|
}
|
|
17961
18047
|
}
|
|
17962
18048
|
function readInstalledVersion() {
|
|
17963
|
-
|
|
17964
|
-
const raw = readFileSync3(fileURLToPath(new URL("../../package.json", import.meta.url)), "utf8");
|
|
17965
|
-
const parsed = JSON.parse(raw);
|
|
17966
|
-
if (typeof parsed !== "object" || parsed === null) return void 0;
|
|
17967
|
-
const version = parsed.version;
|
|
17968
|
-
return typeof version === "string" ? version : void 0;
|
|
17969
|
-
} catch {
|
|
17970
|
-
return void 0;
|
|
17971
|
-
}
|
|
18049
|
+
return readPackageVersion();
|
|
17972
18050
|
}
|
|
17973
18051
|
function exitStatusOf(error) {
|
|
17974
18052
|
if (typeof error === "object" && error !== null && "status" in error) {
|
|
@@ -18036,7 +18114,7 @@ function acquireLock(dir) {
|
|
|
18036
18114
|
}
|
|
18037
18115
|
let holderDead = false;
|
|
18038
18116
|
try {
|
|
18039
|
-
const pid = parseInt(
|
|
18117
|
+
const pid = parseInt(readFileSync4(lockPath, "utf8").trim(), 10);
|
|
18040
18118
|
process.kill(pid, 0);
|
|
18041
18119
|
} catch {
|
|
18042
18120
|
holderDead = true;
|
|
@@ -18074,7 +18152,7 @@ function touchCooldown(dir) {
|
|
|
18074
18152
|
}
|
|
18075
18153
|
function readHint(dir) {
|
|
18076
18154
|
try {
|
|
18077
|
-
const raw =
|
|
18155
|
+
const raw = readFileSync4(path5.join(dir, HINT_FILENAME), "utf8");
|
|
18078
18156
|
const parsed = JSON.parse(raw);
|
|
18079
18157
|
if (typeof parsed !== "object" || parsed === null) return void 0;
|
|
18080
18158
|
const version = parsed.version;
|
|
@@ -18143,7 +18221,7 @@ async function runAutoUpdate(env = process.env, fetchFn = defaultFetch, exec2 =
|
|
|
18143
18221
|
lock.release();
|
|
18144
18222
|
}
|
|
18145
18223
|
}
|
|
18146
|
-
var
|
|
18224
|
+
var PACKAGE_NAME3, REGISTRY_URL2, NETWORK_TIMEOUT_MS, MODULES_DIR, LOCK_FILENAME, HINT_FILENAME, COOLDOWN_FILENAME, DEFAULT_COOLDOWN_MS;
|
|
18147
18225
|
var init_update = __esm({
|
|
18148
18226
|
"src/core/update.ts"() {
|
|
18149
18227
|
"use strict";
|
|
@@ -18151,9 +18229,10 @@ var init_update = __esm({
|
|
|
18151
18229
|
init_errors();
|
|
18152
18230
|
init_update_check();
|
|
18153
18231
|
init_version();
|
|
18232
|
+
init_package_version();
|
|
18154
18233
|
init_paths();
|
|
18155
|
-
|
|
18156
|
-
REGISTRY_URL2 = `https://registry.npmjs.org/${encodeURIComponent(
|
|
18234
|
+
PACKAGE_NAME3 = "pingcode-cli-unofficial";
|
|
18235
|
+
REGISTRY_URL2 = `https://registry.npmjs.org/${encodeURIComponent(PACKAGE_NAME3)}`;
|
|
18157
18236
|
NETWORK_TIMEOUT_MS = 6e4;
|
|
18158
18237
|
MODULES_DIR = "modules";
|
|
18159
18238
|
LOCK_FILENAME = "update.lock";
|
|
@@ -18412,7 +18491,7 @@ import {
|
|
|
18412
18491
|
existsSync as existsSync3,
|
|
18413
18492
|
mkdirSync as mkdirSync4,
|
|
18414
18493
|
readdirSync as readdirSync2,
|
|
18415
|
-
readFileSync as
|
|
18494
|
+
readFileSync as readFileSync5,
|
|
18416
18495
|
rmSync as rmSync4,
|
|
18417
18496
|
statSync as statSync3
|
|
18418
18497
|
} from "fs";
|
|
@@ -18438,7 +18517,7 @@ function collectSkillPayload(skillDir) {
|
|
|
18438
18517
|
function readSkillVersion(skillDir) {
|
|
18439
18518
|
const mdPath = path7.join(skillDir, SKILL_MD);
|
|
18440
18519
|
try {
|
|
18441
|
-
const content =
|
|
18520
|
+
const content = readFileSync5(mdPath, "utf8");
|
|
18442
18521
|
const match = content.match(/^version:\s*(.+)$/m);
|
|
18443
18522
|
return match?.[1]?.trim();
|
|
18444
18523
|
} catch {
|
|
@@ -22215,11 +22294,11 @@ var init_libraries = __esm({
|
|
|
22215
22294
|
|
|
22216
22295
|
// src/cli/commands/testhub/entries.ts
|
|
22217
22296
|
async function readEntryFile(source, schema, hint) {
|
|
22218
|
-
const
|
|
22219
|
-
if (
|
|
22297
|
+
const path12 = source.file?.trim() ?? "";
|
|
22298
|
+
if (path12 === "") {
|
|
22220
22299
|
throw new UsageError("--file <path|-> is required", { hint });
|
|
22221
22300
|
}
|
|
22222
|
-
const document =
|
|
22301
|
+
const document = path12 === "-" ? await readJsonStdin() : parseJsonDocument(await readTextFile(path12, "--file"), `--file ${path12}`);
|
|
22223
22302
|
const list = unwrap2(document, schema.wrapperKey);
|
|
22224
22303
|
if (list.length === 0) {
|
|
22225
22304
|
throw new UsageError("--file contained no entries", {
|
|
@@ -24331,16 +24410,36 @@ init_errors();
|
|
|
24331
24410
|
init_config();
|
|
24332
24411
|
init_update_check();
|
|
24333
24412
|
init_update();
|
|
24334
|
-
init_version();
|
|
24335
24413
|
import { spawn } from "child_process";
|
|
24414
|
+
|
|
24415
|
+
// src/core/legacy-standalone.ts
|
|
24416
|
+
import { statSync as statSync4 } from "fs";
|
|
24417
|
+
import { homedir } from "os";
|
|
24418
|
+
import path11 from "path";
|
|
24419
|
+
function legacyStandalonePath(home = homedir()) {
|
|
24420
|
+
return path11.join(home, ".local", "share", "pingcode-cli");
|
|
24421
|
+
}
|
|
24422
|
+
function existingLegacyStandalone(home = homedir()) {
|
|
24423
|
+
const candidate = legacyStandalonePath(home);
|
|
24424
|
+
try {
|
|
24425
|
+
return statSync4(candidate).isDirectory() ? candidate : void 0;
|
|
24426
|
+
} catch {
|
|
24427
|
+
return void 0;
|
|
24428
|
+
}
|
|
24429
|
+
}
|
|
24430
|
+
|
|
24431
|
+
// src/bin/pingcode.ts
|
|
24432
|
+
init_version();
|
|
24336
24433
|
function notifyUpdateCheck(jsonMode) {
|
|
24337
24434
|
if (jsonMode) return;
|
|
24338
24435
|
if (process.env[ENV_NO_UPDATE_CHECK] === "1") return;
|
|
24339
24436
|
const dir = configDir();
|
|
24340
24437
|
const hint = readHint(dir);
|
|
24341
24438
|
if (hint !== void 0) {
|
|
24342
|
-
|
|
24343
|
-
|
|
24439
|
+
if (isNewerVersion(hint.version, VERSION)) {
|
|
24440
|
+
errLine(paint.yellow(`Update available: ${VERSION} \u2192 ${hint.version}`));
|
|
24441
|
+
errLine(paint.dim("Run: pingcode self-update"));
|
|
24442
|
+
}
|
|
24344
24443
|
try {
|
|
24345
24444
|
removeHint(dir);
|
|
24346
24445
|
} catch {
|
|
@@ -24362,9 +24461,18 @@ function detectJsonMode(program2, argv) {
|
|
|
24362
24461
|
}
|
|
24363
24462
|
return argv.includes("--json");
|
|
24364
24463
|
}
|
|
24464
|
+
function warnLegacyStandalone() {
|
|
24465
|
+
const legacy = existingLegacyStandalone();
|
|
24466
|
+
if (legacy !== void 0) {
|
|
24467
|
+
errLine(paint.yellow(
|
|
24468
|
+
`Deprecated standalone installation found at ${legacy}; it is ignored and can be deleted.`
|
|
24469
|
+
));
|
|
24470
|
+
}
|
|
24471
|
+
}
|
|
24365
24472
|
async function main(argv) {
|
|
24366
24473
|
const program2 = buildProgram();
|
|
24367
24474
|
const jsonMode = argv.includes("--json");
|
|
24475
|
+
if (argv.slice(2).includes("self-update")) warnLegacyStandalone();
|
|
24368
24476
|
notifyUpdateCheck(jsonMode);
|
|
24369
24477
|
try {
|
|
24370
24478
|
await program2.parseAsync(argv);
|