@forumulate/cli 0.5.0 → 0.8.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 +116 -5
- package/dist/api/args.d.ts +21 -0
- package/dist/api/args.d.ts.map +1 -0
- package/dist/api/args.js +81 -0
- package/dist/api/args.js.map +1 -0
- package/dist/api/command.d.ts +17 -0
- package/dist/api/command.d.ts.map +1 -0
- package/dist/api/command.js +182 -0
- package/dist/api/command.js.map +1 -0
- package/dist/api/describe.d.ts +5 -0
- package/dist/api/describe.d.ts.map +1 -0
- package/dist/api/describe.js +121 -0
- package/dist/api/describe.js.map +1 -0
- package/dist/api/http.d.ts +81 -0
- package/dist/api/http.d.ts.map +1 -0
- package/dist/api/http.js +183 -0
- package/dist/api/http.js.map +1 -0
- package/dist/api/operations.json +1 -0
- package/dist/api/output.d.ts +35 -0
- package/dist/api/output.d.ts.map +1 -0
- package/dist/api/output.js +176 -0
- package/dist/api/output.js.map +1 -0
- package/dist/api/request.d.ts +37 -0
- package/dist/api/request.d.ts.map +1 -0
- package/dist/api/request.js +230 -0
- package/dist/api/request.js.map +1 -0
- package/dist/api/send.d.ts +35 -0
- package/dist/api/send.d.ts.map +1 -0
- package/dist/api/send.js +85 -0
- package/dist/api/send.js.map +1 -0
- package/dist/api/spec.d.ts +96 -0
- package/dist/api/spec.d.ts.map +1 -0
- package/dist/api/spec.js +126 -0
- package/dist/api/spec.js.map +1 -0
- package/dist/commands/completion.d.ts +12 -0
- package/dist/commands/completion.d.ts.map +1 -0
- package/dist/commands/completion.js +153 -0
- package/dist/commands/completion.js.map +1 -0
- package/dist/commands/config.d.ts +33 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +144 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/context.d.ts +35 -0
- package/dist/commands/context.d.ts.map +1 -0
- package/dist/commands/context.js +59 -0
- package/dist/commands/context.js.map +1 -0
- package/dist/commands/groups-api.d.ts +11 -0
- package/dist/commands/groups-api.d.ts.map +1 -0
- package/dist/commands/groups-api.js +140 -0
- package/dist/commands/groups-api.js.map +1 -0
- package/dist/commands/groups-community.d.ts +15 -0
- package/dist/commands/groups-community.d.ts.map +1 -0
- package/dist/commands/groups-community.js +344 -0
- package/dist/commands/groups-community.js.map +1 -0
- package/dist/commands/groups-content.d.ts +10 -0
- package/dist/commands/groups-content.d.ts.map +1 -0
- package/dist/commands/groups-content.js +331 -0
- package/dist/commands/groups-content.js.map +1 -0
- package/dist/commands/groups-docs.d.ts +12 -0
- package/dist/commands/groups-docs.d.ts.map +1 -0
- package/dist/commands/groups-docs.js +414 -0
- package/dist/commands/groups-docs.js.map +1 -0
- package/dist/commands/groups-org.d.ts +10 -0
- package/dist/commands/groups-org.d.ts.map +1 -0
- package/dist/commands/groups-org.js +405 -0
- package/dist/commands/groups-org.js.map +1 -0
- package/dist/commands/groups-site.d.ts +3 -0
- package/dist/commands/groups-site.d.ts.map +1 -0
- package/dist/commands/groups-site.js +230 -0
- package/dist/commands/groups-site.js.map +1 -0
- package/dist/commands/groups-spaces.d.ts +3 -0
- package/dist/commands/groups-spaces.d.ts.map +1 -0
- package/dist/commands/groups-spaces.js +273 -0
- package/dist/commands/groups-spaces.js.map +1 -0
- package/dist/commands/groups-types.d.ts +3 -0
- package/dist/commands/groups-types.d.ts.map +1 -0
- package/dist/commands/groups-types.js +251 -0
- package/dist/commands/groups-types.js.map +1 -0
- package/dist/commands/groups.d.ts +4 -0
- package/dist/commands/groups.d.ts.map +1 -0
- package/dist/commands/groups.js +71 -0
- package/dist/commands/groups.js.map +1 -0
- package/dist/commands/index.d.ts +25 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +118 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/commands/resource.d.ts +86 -0
- package/dist/commands/resource.d.ts.map +1 -0
- package/dist/commands/resource.js +314 -0
- package/dist/commands/resource.js.map +1 -0
- package/dist/content/library.d.ts +1 -0
- package/dist/content/library.d.ts.map +1 -1
- package/dist/content/library.js +1 -0
- package/dist/content/library.js.map +1 -1
- package/dist/help.d.ts +3 -0
- package/dist/help.d.ts.map +1 -0
- package/dist/help.js +142 -0
- package/dist/help.js.map +1 -0
- package/dist/run.d.ts +16 -1
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +51 -91
- package/dist/run.js.map +1 -1
- package/dist/translations/command.d.ts +36 -0
- package/dist/translations/command.d.ts.map +1 -0
- package/dist/translations/command.js +411 -0
- package/dist/translations/command.js.map +1 -0
- package/dist/translations/extras.d.ts +29 -0
- package/dist/translations/extras.d.ts.map +1 -0
- package/dist/translations/extras.js +123 -0
- package/dist/translations/extras.js.map +1 -0
- package/dist/translations/files.d.ts +22 -0
- package/dist/translations/files.d.ts.map +1 -0
- package/dist/translations/files.js +75 -0
- package/dist/translations/files.js.map +1 -0
- package/dist/translations/sync.d.ts +89 -0
- package/dist/translations/sync.d.ts.map +1 -0
- package/dist/translations/sync.js +215 -0
- package/dist/translations/sync.js.map +1 -0
- package/dist/translations/target.d.ts +33 -0
- package/dist/translations/target.d.ts.map +1 -0
- package/dist/translations/target.js +54 -0
- package/dist/translations/target.js.map +1 -0
- package/dist/translations/xliff.d.ts +29 -0
- package/dist/translations/xliff.d.ts.map +1 -0
- package/dist/translations/xliff.js +62 -0
- package/dist/translations/xliff.js.map +1 -0
- package/package.json +6 -4
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The operation index `forumulate api` runs from.
|
|
3
|
+
*
|
|
4
|
+
* `operations.json` is cut from `packages/sdk/openapi.json` by
|
|
5
|
+
* `scripts/slim-spec.mjs`: every operation's method, path, params and request
|
|
6
|
+
* body shape, nothing else (the full spec is 21 MB; this is under 1). It is read
|
|
7
|
+
* lazily, so `forumulate whoami` does not pay to parse a thousand operations.
|
|
8
|
+
*/
|
|
9
|
+
/** A slimmed JSON Schema node (see `slim-spec.mjs` for the key names). */
|
|
10
|
+
export interface SchemaNode {
|
|
11
|
+
$ref?: string;
|
|
12
|
+
/** type */
|
|
13
|
+
t?: string;
|
|
14
|
+
/** properties */
|
|
15
|
+
p?: Record<string, SchemaNode>;
|
|
16
|
+
/** required */
|
|
17
|
+
r?: string[];
|
|
18
|
+
/** items */
|
|
19
|
+
i?: SchemaNode;
|
|
20
|
+
/** enum */
|
|
21
|
+
e?: unknown[];
|
|
22
|
+
/** const */
|
|
23
|
+
c?: unknown;
|
|
24
|
+
/** description (first sentence) */
|
|
25
|
+
d?: string;
|
|
26
|
+
/** anyOf/oneOf, minus a null variant */
|
|
27
|
+
any?: SchemaNode[];
|
|
28
|
+
all?: SchemaNode[];
|
|
29
|
+
/** nullable */
|
|
30
|
+
n?: 1;
|
|
31
|
+
}
|
|
32
|
+
export interface Param {
|
|
33
|
+
n: string;
|
|
34
|
+
in: 'path' | 'query' | 'header' | 'cookie';
|
|
35
|
+
r?: 1;
|
|
36
|
+
t?: string;
|
|
37
|
+
e?: unknown[];
|
|
38
|
+
d?: string;
|
|
39
|
+
}
|
|
40
|
+
export interface Operation {
|
|
41
|
+
id: string;
|
|
42
|
+
m: string;
|
|
43
|
+
p: string;
|
|
44
|
+
s?: string;
|
|
45
|
+
t?: string[];
|
|
46
|
+
q?: Param[];
|
|
47
|
+
/** Declares `Idempotency-Key`: the CLI sends one, so a retried write is not a second write. */
|
|
48
|
+
ik?: 1;
|
|
49
|
+
b?: SchemaNode;
|
|
50
|
+
/** multipart/form-data body */
|
|
51
|
+
mp?: 1;
|
|
52
|
+
/** body required */
|
|
53
|
+
br?: 1;
|
|
54
|
+
dep?: 1;
|
|
55
|
+
}
|
|
56
|
+
export interface OperationIndex {
|
|
57
|
+
info: {
|
|
58
|
+
title?: string;
|
|
59
|
+
version?: string;
|
|
60
|
+
};
|
|
61
|
+
ops: Operation[];
|
|
62
|
+
schemas: Record<string, SchemaNode>;
|
|
63
|
+
}
|
|
64
|
+
export declare function loadIndex(): OperationIndex;
|
|
65
|
+
/** For tests: run against an index that is not the bundled one. */
|
|
66
|
+
export declare function setIndex(index: OperationIndex | undefined): void;
|
|
67
|
+
export declare function resolveRef(node: SchemaNode | undefined, index?: OperationIndex): SchemaNode | undefined;
|
|
68
|
+
/**
|
|
69
|
+
* The top-level properties a body accepts, across every variant of a `oneOf`
|
|
70
|
+
* (blog/forum/changelog take a block-JSON form OR a markdown form) — the set a
|
|
71
|
+
* `--field` flag may name.
|
|
72
|
+
*/
|
|
73
|
+
export declare function bodyProperties(op: Operation, index?: OperationIndex): Record<string, SchemaNode>;
|
|
74
|
+
export declare function pathParams(op: Operation): string[];
|
|
75
|
+
export declare const isMethod: (s: string | undefined) => boolean;
|
|
76
|
+
/** By operationId — exact first, then case-insensitive, so `space_list` works too. */
|
|
77
|
+
export declare function findById(id: string, index?: OperationIndex): Operation | undefined;
|
|
78
|
+
/**
|
|
79
|
+
* By method and path: a template (`/orgs/{orgId}/spaces`) or a concrete path
|
|
80
|
+
* (`/orgs/acme/spaces`). A concrete path also hands back the values it filled
|
|
81
|
+
* in, so `forumulate api GET /orgs/acme/spaces --paginate` knows `orgId=acme`.
|
|
82
|
+
*
|
|
83
|
+
* A literal segment beats a parameter, the same rule the API's router applies:
|
|
84
|
+
* `/orgs/acme/members/invites` is the invite list, not member `invites`.
|
|
85
|
+
*/
|
|
86
|
+
export declare function findByPath(method: string, rawPath: string, index?: OperationIndex): {
|
|
87
|
+
op: Operation;
|
|
88
|
+
values: Record<string, string>;
|
|
89
|
+
} | undefined;
|
|
90
|
+
export interface ListFilter {
|
|
91
|
+
tag?: string;
|
|
92
|
+
search?: string;
|
|
93
|
+
method?: string;
|
|
94
|
+
}
|
|
95
|
+
export declare function filterOps(filter: ListFilter, index?: OperationIndex): Operation[];
|
|
96
|
+
//# sourceMappingURL=spec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spec.d.ts","sourceRoot":"","sources":["../../src/api/spec.ts"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AAEH,0EAA0E;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MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,SAAS,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,iBAAc,GAAG,SAAS,EAAE,CAY9E"}
|
package/dist/api/spec.js
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isMethod = void 0;
|
|
4
|
+
exports.loadIndex = loadIndex;
|
|
5
|
+
exports.setIndex = setIndex;
|
|
6
|
+
exports.resolveRef = resolveRef;
|
|
7
|
+
exports.bodyProperties = bodyProperties;
|
|
8
|
+
exports.pathParams = pathParams;
|
|
9
|
+
exports.findById = findById;
|
|
10
|
+
exports.findByPath = findByPath;
|
|
11
|
+
exports.filterOps = filterOps;
|
|
12
|
+
const node_fs_1 = require("node:fs");
|
|
13
|
+
const node_path_1 = require("node:path");
|
|
14
|
+
let cached;
|
|
15
|
+
function loadIndex() {
|
|
16
|
+
if (!cached) {
|
|
17
|
+
cached = JSON.parse((0, node_fs_1.readFileSync)((0, node_path_1.join)(__dirname, 'operations.json'), 'utf8'));
|
|
18
|
+
}
|
|
19
|
+
return cached;
|
|
20
|
+
}
|
|
21
|
+
/** For tests: run against an index that is not the bundled one. */
|
|
22
|
+
function setIndex(index) {
|
|
23
|
+
cached = index;
|
|
24
|
+
}
|
|
25
|
+
function resolveRef(node, index = loadIndex()) {
|
|
26
|
+
let n = node;
|
|
27
|
+
for (let i = 0; n?.$ref && i < 20; i++)
|
|
28
|
+
n = index.schemas[n.$ref];
|
|
29
|
+
return n ?? undefined;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The top-level properties a body accepts, across every variant of a `oneOf`
|
|
33
|
+
* (blog/forum/changelog take a block-JSON form OR a markdown form) — the set a
|
|
34
|
+
* `--field` flag may name.
|
|
35
|
+
*/
|
|
36
|
+
function bodyProperties(op, index = loadIndex()) {
|
|
37
|
+
const out = {};
|
|
38
|
+
const visit = (raw, depth) => {
|
|
39
|
+
const node = resolveRef(raw, index);
|
|
40
|
+
if (!node || depth > 4)
|
|
41
|
+
return;
|
|
42
|
+
for (const [k, v] of Object.entries(node.p ?? {}))
|
|
43
|
+
out[k] ??= resolveRef(v, index) ?? {};
|
|
44
|
+
for (const v of node.any ?? [])
|
|
45
|
+
visit(v, depth + 1);
|
|
46
|
+
for (const v of node.all ?? [])
|
|
47
|
+
visit(v, depth + 1);
|
|
48
|
+
};
|
|
49
|
+
visit(op.b, 0);
|
|
50
|
+
return out;
|
|
51
|
+
}
|
|
52
|
+
function pathParams(op) {
|
|
53
|
+
return [...op.p.matchAll(/\{([^}]+)\}/g)].map((m) => m[1]);
|
|
54
|
+
}
|
|
55
|
+
const METHODS = new Set(['GET', 'POST', 'PUT', 'PATCH', 'DELETE']);
|
|
56
|
+
const isMethod = (s) => Boolean(s && METHODS.has(s.toUpperCase()));
|
|
57
|
+
exports.isMethod = isMethod;
|
|
58
|
+
/** By operationId — exact first, then case-insensitive, so `space_list` works too. */
|
|
59
|
+
function findById(id, index = loadIndex()) {
|
|
60
|
+
return (index.ops.find((o) => o.id === id) ??
|
|
61
|
+
index.ops.find((o) => o.id.toLowerCase() === id.toLowerCase()));
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* By method and path: a template (`/orgs/{orgId}/spaces`) or a concrete path
|
|
65
|
+
* (`/orgs/acme/spaces`). A concrete path also hands back the values it filled
|
|
66
|
+
* in, so `forumulate api GET /orgs/acme/spaces --paginate` knows `orgId=acme`.
|
|
67
|
+
*
|
|
68
|
+
* A literal segment beats a parameter, the same rule the API's router applies:
|
|
69
|
+
* `/orgs/acme/members/invites` is the invite list, not member `invites`.
|
|
70
|
+
*/
|
|
71
|
+
function findByPath(method, rawPath, index = loadIndex()) {
|
|
72
|
+
const m = method.toUpperCase();
|
|
73
|
+
const path = rawPath
|
|
74
|
+
.split('?')[0]
|
|
75
|
+
.replace(/^\/api(?=\/)/, '')
|
|
76
|
+
.replace(/\/+$/, '') || '/';
|
|
77
|
+
const want = path.split('/');
|
|
78
|
+
let best;
|
|
79
|
+
for (const op of index.ops) {
|
|
80
|
+
if (op.m !== m)
|
|
81
|
+
continue;
|
|
82
|
+
if (op.p === path)
|
|
83
|
+
return { op, values: {} };
|
|
84
|
+
const have = op.p.split('/');
|
|
85
|
+
if (have.length !== want.length)
|
|
86
|
+
continue;
|
|
87
|
+
const values = {};
|
|
88
|
+
let score = 0;
|
|
89
|
+
let ok = true;
|
|
90
|
+
for (let i = 0; i < have.length; i++) {
|
|
91
|
+
const seg = have[i];
|
|
92
|
+
const param = seg.match(/^\{([^}]+)\}$/);
|
|
93
|
+
if (param) {
|
|
94
|
+
// `{orgId}` typed literally is the template, not a value.
|
|
95
|
+
if (want[i] !== seg)
|
|
96
|
+
values[param[1]] = decodeURIComponent(want[i]);
|
|
97
|
+
}
|
|
98
|
+
else if (seg === want[i])
|
|
99
|
+
score++;
|
|
100
|
+
else {
|
|
101
|
+
ok = false;
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
if (ok && (!best || score > best.score))
|
|
106
|
+
best = { op, values, score };
|
|
107
|
+
}
|
|
108
|
+
return best && { op: best.op, values: best.values };
|
|
109
|
+
}
|
|
110
|
+
function filterOps(filter, index = loadIndex()) {
|
|
111
|
+
const tag = filter.tag?.toLowerCase();
|
|
112
|
+
const words = (filter.search ?? '').toLowerCase().split(/\s+/).filter(Boolean);
|
|
113
|
+
return index.ops.filter((o) => {
|
|
114
|
+
if (filter.method && o.m !== filter.method.toUpperCase())
|
|
115
|
+
return false;
|
|
116
|
+
if (tag && !(o.t ?? []).some((t) => t.toLowerCase() === tag))
|
|
117
|
+
return false;
|
|
118
|
+
if (words.length) {
|
|
119
|
+
const hay = `${o.id} ${o.m} ${o.p} ${o.s ?? ''} ${(o.t ?? []).join(' ')}`.toLowerCase();
|
|
120
|
+
if (!words.every((w) => hay.includes(w)))
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
return true;
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spec.js","sourceRoot":"","sources":["../../src/api/spec.ts"],"names":[],"mappings":";;;AAsEA,8BAKC;AAGD,4BAEC;AAED,gCAOC;AAOD,wCAWC;AAED,gCAEC;AAOD,4BAKC;AAUD,gCAoCC;AAQD,8BAYC;AA7LD,qCAAuC;AACvC,yCAAiC;AAmEjC,IAAI,MAAkC,CAAC;AAEvC,SAAgB,SAAS;IACvB,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAA,sBAAY,EAAC,IAAA,gBAAI,EAAC,SAAS,EAAE,iBAAiB,CAAC,EAAE,MAAM,CAAC,CAAmB,CAAC;IAClG,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,mEAAmE;AACnE,SAAgB,QAAQ,CAAC,KAAiC;IACxD,MAAM,GAAG,KAAK,CAAC;AACjB,CAAC;AAED,SAAgB,UAAU,CACxB,IAA4B,EAC5B,KAAK,GAAG,SAAS,EAAE;IAEnB,IAAI,CAAC,GAAG,IAAI,CAAC;IACb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,IAAI,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE;QAAE,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IAClE,OAAO,CAAC,IAAI,SAAS,CAAC;AACxB,CAAC;AAED;;;;GAIG;AACH,SAAgB,cAAc,CAAC,EAAa,EAAE,KAAK,GAAG,SAAS,EAAE;IAC/D,MAAM,GAAG,GAA+B,EAAE,CAAC;IAC3C,MAAM,KAAK,GAAG,CAAC,GAA2B,EAAE,KAAa,EAAE,EAAE;QAC3D,MAAM,IAAI,GAAG,UAAU,CAA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M,CAAC,MAAM,CAAC,WAAW,EAAE;YAAE,OAAO,KAAK,CAAC;QACvE,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,KAAK,GAAG,CAAC;YAAE,OAAO,KAAK,CAAC;QAC3E,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;YACjB,MAAM,GAAG,GAAG,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,WAAW,EAAE,CAAC;YACxF,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;gBAAE,OAAO,KAAK,CAAC;QACzD,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shell completion: `forumulate completion bash|zsh|fish` prints a script, and
|
|
3
|
+
* the script asks the CLI itself (`forumulate __complete <words…>`) what comes
|
|
4
|
+
* next. One source of candidates for three shells, so a verb added to
|
|
5
|
+
* `groups.ts` or an operation added to the spec completes everywhere with no
|
|
6
|
+
* script to regenerate.
|
|
7
|
+
*/
|
|
8
|
+
export declare const TOP_LEVEL: string[];
|
|
9
|
+
/** Candidates for the word being completed, given the words before it. */
|
|
10
|
+
export declare function complete(words: string[]): string[];
|
|
11
|
+
export declare function completionScript(shell: string): string | undefined;
|
|
12
|
+
//# sourceMappingURL=completion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"completion.d.ts","sourceRoot":"","sources":["../../src/commands/completion.ts"],"names":[],"mappings":"AAIA;;;;;;GAMG;AACH,eAAO,MAAM,SAAS,UAcrB,CAAC;AAIF,0EAA0E;AAC1E,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAmDlD;AAyCD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CA8BlE"}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TOP_LEVEL = void 0;
|
|
4
|
+
exports.complete = complete;
|
|
5
|
+
exports.completionScript = completionScript;
|
|
6
|
+
const spec_1 = require("../api/spec");
|
|
7
|
+
const groups_1 = require("./groups");
|
|
8
|
+
const config_1 = require("./config");
|
|
9
|
+
/**
|
|
10
|
+
* Shell completion: `forumulate completion bash|zsh|fish` prints a script, and
|
|
11
|
+
* the script asks the CLI itself (`forumulate __complete <words…>`) what comes
|
|
12
|
+
* next. One source of candidates for three shells, so a verb added to
|
|
13
|
+
* `groups.ts` or an operation added to the spec completes everywhere with no
|
|
14
|
+
* script to regenerate.
|
|
15
|
+
*/
|
|
16
|
+
exports.TOP_LEVEL = [
|
|
17
|
+
'login',
|
|
18
|
+
'logout',
|
|
19
|
+
'whoami',
|
|
20
|
+
'config',
|
|
21
|
+
'api',
|
|
22
|
+
'publish',
|
|
23
|
+
'snapshot',
|
|
24
|
+
'content',
|
|
25
|
+
'import',
|
|
26
|
+
'conformance',
|
|
27
|
+
'doctor',
|
|
28
|
+
'completion',
|
|
29
|
+
'help',
|
|
30
|
+
];
|
|
31
|
+
const COMMON_FLAGS = ['--json', '--org', '--space', '--paginate', '--dry-run', '--help', '--yes'];
|
|
32
|
+
/** Candidates for the word being completed, given the words before it. */
|
|
33
|
+
function complete(words) {
|
|
34
|
+
const [cmd, ...rest] = words;
|
|
35
|
+
const current = rest.length ? rest[rest.length - 1] : (cmd ?? '');
|
|
36
|
+
const before = rest.slice(0, -1);
|
|
37
|
+
if (rest.length === 0) {
|
|
38
|
+
const all = [...exports.TOP_LEVEL, ...groups_1.GROUPS.flatMap((g) => [g.name, ...(g.aliases ?? [])])];
|
|
39
|
+
return all.filter((w) => w.startsWith(current)).sort();
|
|
40
|
+
}
|
|
41
|
+
if (current.startsWith('-'))
|
|
42
|
+
return flagsFor(cmd, before).filter((f) => f.startsWith(current));
|
|
43
|
+
const positionals = before.filter((w) => !w.startsWith('-'));
|
|
44
|
+
if (cmd === 'api') {
|
|
45
|
+
if (positionals.length === 0) {
|
|
46
|
+
if (current === '' || /^[A-Z]/.test(current)) {
|
|
47
|
+
const ids = (0, spec_1.loadIndex)().ops.map((o) => o.id);
|
|
48
|
+
return ['list', 'describe', 'GET', 'POST', 'PUT', 'PATCH', 'DELETE', ...ids].filter((w) => w.startsWith(current));
|
|
49
|
+
}
|
|
50
|
+
return ['list', 'describe', ...(0, spec_1.loadIndex)().ops.map((o) => o.id)].filter((w) => w.startsWith(current));
|
|
51
|
+
}
|
|
52
|
+
if (positionals[0] === 'describe' && positionals.length === 1)
|
|
53
|
+
return (0, spec_1.loadIndex)()
|
|
54
|
+
.ops.map((o) => o.id)
|
|
55
|
+
.filter((w) => w.startsWith(current));
|
|
56
|
+
if ((0, spec_1.isMethod)(positionals[0]) && positionals.length === 1)
|
|
57
|
+
return (0, spec_1.filterOps)({ method: positionals[0] })
|
|
58
|
+
.map((o) => o.p)
|
|
59
|
+
.filter((p) => p.startsWith(current));
|
|
60
|
+
return [];
|
|
61
|
+
}
|
|
62
|
+
if (cmd === 'config') {
|
|
63
|
+
if (positionals.length === 0)
|
|
64
|
+
return ['set', 'get', 'unset', 'list', 'path'].filter((w) => w.startsWith(current));
|
|
65
|
+
if (positionals.length === 1)
|
|
66
|
+
return Object.keys(config_1.CONFIG_KEYS).filter((w) => w.startsWith(current));
|
|
67
|
+
return [];
|
|
68
|
+
}
|
|
69
|
+
if (cmd === 'completion')
|
|
70
|
+
return ['bash', 'zsh', 'fish'].filter((w) => w.startsWith(current));
|
|
71
|
+
const g = (0, groups_1.findGroup)(cmd);
|
|
72
|
+
if (!g)
|
|
73
|
+
return [];
|
|
74
|
+
const verbs = Object.keys(g.verbs);
|
|
75
|
+
if (positionals.length === 0)
|
|
76
|
+
return [...new Set(verbs.map((v) => v.split(' ')[0]))].filter((w) => w.startsWith(current));
|
|
77
|
+
if (positionals.length === 1)
|
|
78
|
+
return verbs
|
|
79
|
+
.filter((v) => v.startsWith(`${positionals[0]} `))
|
|
80
|
+
.map((v) => v.split(' ')[1])
|
|
81
|
+
.filter((w) => w.startsWith(current));
|
|
82
|
+
return [];
|
|
83
|
+
}
|
|
84
|
+
function flagsFor(cmd, before) {
|
|
85
|
+
const positionals = before.filter((w) => !w.startsWith('-'));
|
|
86
|
+
if (cmd === 'api') {
|
|
87
|
+
const op = (positionals[0] && (0, spec_1.findById)(positionals[0])) ||
|
|
88
|
+
((0, spec_1.isMethod)(positionals[0]) && positionals[1]
|
|
89
|
+
? (0, spec_1.findByPath)(positionals[0], positionals[1])?.op
|
|
90
|
+
: undefined);
|
|
91
|
+
const own = [
|
|
92
|
+
'--data',
|
|
93
|
+
'--field',
|
|
94
|
+
'--param',
|
|
95
|
+
'--header',
|
|
96
|
+
'--paginate',
|
|
97
|
+
'--json',
|
|
98
|
+
'--columns',
|
|
99
|
+
'--dry-run',
|
|
100
|
+
'--api-version',
|
|
101
|
+
'--include-headers',
|
|
102
|
+
];
|
|
103
|
+
return [...(op?.q ?? []).map((p) => `--${p.n}`), ...own];
|
|
104
|
+
}
|
|
105
|
+
const g = (0, groups_1.findGroup)(cmd);
|
|
106
|
+
if (!g)
|
|
107
|
+
return COMMON_FLAGS;
|
|
108
|
+
const verb = g.verbs[`${positionals[0]} ${positionals[1]}`] ?? g.verbs[positionals[0] ?? ''];
|
|
109
|
+
const op = verb && (0, spec_1.findById)(verb.op);
|
|
110
|
+
const params = (op?.q ?? []).filter((p) => p.in === 'query').map((p) => `--${p.n}`);
|
|
111
|
+
return [
|
|
112
|
+
...new Set([
|
|
113
|
+
...COMMON_FLAGS,
|
|
114
|
+
...params,
|
|
115
|
+
...(verb?.markdown ? ['--file'] : []),
|
|
116
|
+
...(verb?.download ? ['--out'] : []),
|
|
117
|
+
'--data',
|
|
118
|
+
'--field',
|
|
119
|
+
]),
|
|
120
|
+
];
|
|
121
|
+
}
|
|
122
|
+
function completionScript(shell) {
|
|
123
|
+
switch (shell) {
|
|
124
|
+
case 'bash':
|
|
125
|
+
return `# forumulate bash completion — add to ~/.bashrc:
|
|
126
|
+
# eval "$(forumulate completion bash)"
|
|
127
|
+
_forumulate() {
|
|
128
|
+
local IFS=$'\\n'
|
|
129
|
+
COMPREPLY=($(forumulate __complete "\${COMP_WORDS[@]:1:COMP_CWORD}" 2>/dev/null))
|
|
130
|
+
}
|
|
131
|
+
complete -o default -F _forumulate forumulate
|
|
132
|
+
`;
|
|
133
|
+
case 'zsh':
|
|
134
|
+
return `#compdef forumulate
|
|
135
|
+
# forumulate zsh completion — add to ~/.zshrc:
|
|
136
|
+
# eval "$(forumulate completion zsh)"
|
|
137
|
+
_forumulate() {
|
|
138
|
+
local -a candidates
|
|
139
|
+
candidates=("\${(@f)$(forumulate __complete "\${(@)words[2,CURRENT]}" 2>/dev/null)}")
|
|
140
|
+
compadd -a candidates
|
|
141
|
+
}
|
|
142
|
+
compdef _forumulate forumulate
|
|
143
|
+
`;
|
|
144
|
+
case 'fish':
|
|
145
|
+
return `# forumulate fish completion — save as ~/.config/fish/completions/forumulate.fish
|
|
146
|
+
# forumulate completion fish > ~/.config/fish/completions/forumulate.fish
|
|
147
|
+
complete -c forumulate -f -a '(forumulate __complete (commandline -opc)[2..-1] (commandline -ct) 2>/dev/null)'
|
|
148
|
+
`;
|
|
149
|
+
default:
|
|
150
|
+
return undefined;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
//# sourceMappingURL=completion.js.map
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AC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IACpF,OAAO;QACL,GAAG,IAAI,GAAG,CAAC;YACT,GAAG,YAAY;YACf,GAAG,MAAM;YACT,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YACrC,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YACpC,QAAQ;YACR,SAAS;SACV,CAAC;KACH,CAAC;AACJ,CAAC;AAED,SAAgB,gBAAgB,CAAC,KAAa;IAC5C,QAAQ,KAAK,EAAE,CAAC;QACd,KAAK,MAAM;YACT,OAAO;;;;;;;CAOZ,CAAC;QACE,KAAK,KAAK;YACR,OAAO;;;;;;;;;CASZ,CAAC;QACE,KAAK,MAAM;YACT,OAAO;;;CAGZ,CAAC;QACE;YACE,OAAO,SAAS,CAAC;IACrB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `forumulate config` — defaults a person would otherwise type on every call.
|
|
3
|
+
*
|
|
4
|
+
* Stored beside the credentials (same directory, `FORUMULATE_CONFIG_DIR`
|
|
5
|
+
* honoured) but in its own file: a config is something you paste into a bug
|
|
6
|
+
* report, and a token must never ride along with it.
|
|
7
|
+
*
|
|
8
|
+
* Precedence for every key is flag → environment → this file, so CI that
|
|
9
|
+
* passes `--org` or `FORUMULATE_ORG` is never overridden by a laptop's file.
|
|
10
|
+
*/
|
|
11
|
+
export declare const CONFIG_KEYS: Record<string, {
|
|
12
|
+
env: string;
|
|
13
|
+
about: string;
|
|
14
|
+
}>;
|
|
15
|
+
export type CliConfig = Partial<Record<string, string>>;
|
|
16
|
+
export declare function configPath(env?: NodeJS.ProcessEnv): string;
|
|
17
|
+
export declare function readConfig(env?: NodeJS.ProcessEnv): CliConfig;
|
|
18
|
+
export declare function writeConfig(cfg: CliConfig, env?: NodeJS.ProcessEnv): string;
|
|
19
|
+
/** flag → env → file. */
|
|
20
|
+
export declare function setting(key: keyof typeof CONFIG_KEYS & string, flagValue: string | undefined, env: NodeJS.ProcessEnv, cfg: CliConfig): string | undefined;
|
|
21
|
+
export declare const CONFIG_HELP: string;
|
|
22
|
+
export declare function runConfig(positionals: string[], json: boolean, io: {
|
|
23
|
+
out: (l: string) => void;
|
|
24
|
+
err: (l: string) => void;
|
|
25
|
+
env: NodeJS.ProcessEnv;
|
|
26
|
+
}): number;
|
|
27
|
+
/**
|
|
28
|
+
* The environment the older commands read (`content`, `import`), with the
|
|
29
|
+
* config file's defaults filled in where the environment says nothing — so
|
|
30
|
+
* `config set org` reaches them too without teaching each one to read a file.
|
|
31
|
+
*/
|
|
32
|
+
export declare function envWithConfig(env?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
|
|
33
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/commands/config.ts"],"names":[],"mappings":"AAIA;;;;;;;;;GASG;AACH,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAQtE,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAExD,wBAAgB,UAAU,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,MAAM,CAEvE;AAED,wBAAgB,UAAU,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,SAAS,CAO1E;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,SAAS,EAAE,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,MAAM,CAMxF;AAED,yBAAyB;AACzB,wBAAgB,OAAO,CACrB,GAAG,EAAE,MAAM,OAAO,WAAW,GAAG,MAAM,EACtC,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,GAAG,EAAE,MAAM,CAAC,UAAU,EACtB,GAAG,EAAE,SAAS,GACb,MAAM,GAAG,SAAS,CAGpB;AAED,eAAO,MAAM,WAAW,QAc2C,CAAC;AAEpE,wBAAgB,SAAS,CACvB,WAAW,EAAE,MAAM,EAAE,EACrB,IAAI,EAAE,OAAO,EACb,EAAE,EAAE;IAAE,GAAG,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAAC,GAAG,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC,UAAU,CAAA;CAAE,GACjF,MAAM,CAwDR;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,MAAM,CAAC,UAAU,CAMrF"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CONFIG_HELP = exports.CONFIG_KEYS = void 0;
|
|
4
|
+
exports.configPath = configPath;
|
|
5
|
+
exports.readConfig = readConfig;
|
|
6
|
+
exports.writeConfig = writeConfig;
|
|
7
|
+
exports.setting = setting;
|
|
8
|
+
exports.runConfig = runConfig;
|
|
9
|
+
exports.envWithConfig = envWithConfig;
|
|
10
|
+
const node_fs_1 = require("node:fs");
|
|
11
|
+
const node_path_1 = require("node:path");
|
|
12
|
+
const credentials_1 = require("../credentials");
|
|
13
|
+
/**
|
|
14
|
+
* `forumulate config` — defaults a person would otherwise type on every call.
|
|
15
|
+
*
|
|
16
|
+
* Stored beside the credentials (same directory, `FORUMULATE_CONFIG_DIR`
|
|
17
|
+
* honoured) but in its own file: a config is something you paste into a bug
|
|
18
|
+
* report, and a token must never ride along with it.
|
|
19
|
+
*
|
|
20
|
+
* Precedence for every key is flag → environment → this file, so CI that
|
|
21
|
+
* passes `--org` or `FORUMULATE_ORG` is never overridden by a laptop's file.
|
|
22
|
+
*/
|
|
23
|
+
exports.CONFIG_KEYS = {
|
|
24
|
+
org: { env: 'FORUMULATE_ORG', about: 'default organization (id or slug) for --org' },
|
|
25
|
+
space: { env: 'FORUMULATE_SPACE', about: 'default space (id or slug) for --space' },
|
|
26
|
+
library: { env: 'FORUMULATE_LIBRARY', about: 'default content library for --library' },
|
|
27
|
+
'api-version': {
|
|
28
|
+
env: 'FORUMULATE_API_VERSION',
|
|
29
|
+
about: 'Forumulate-Version header sent by `api` and the resource commands',
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
function configPath(env = process.env) {
|
|
33
|
+
return (0, node_path_1.join)((0, node_path_1.dirname)((0, credentials_1.credentialsPath)(env)), 'config.json');
|
|
34
|
+
}
|
|
35
|
+
function readConfig(env = process.env) {
|
|
36
|
+
try {
|
|
37
|
+
const parsed = JSON.parse((0, node_fs_1.readFileSync)(configPath(env), 'utf8'));
|
|
38
|
+
return parsed && typeof parsed === 'object' ? parsed : {};
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return {};
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function writeConfig(cfg, env = process.env) {
|
|
45
|
+
const path = configPath(env);
|
|
46
|
+
(0, node_fs_1.mkdirSync)((0, node_path_1.dirname)(path), { recursive: true, mode: 0o700 });
|
|
47
|
+
(0, node_fs_1.writeFileSync)(path, `${JSON.stringify(cfg, null, 2)}\n`, { mode: 0o600 });
|
|
48
|
+
(0, node_fs_1.chmodSync)(path, 0o600);
|
|
49
|
+
return path;
|
|
50
|
+
}
|
|
51
|
+
/** flag → env → file. */
|
|
52
|
+
function setting(key, flagValue, env, cfg) {
|
|
53
|
+
const fromEnv = env[exports.CONFIG_KEYS[key].env]?.trim();
|
|
54
|
+
return flagValue ?? (fromEnv || undefined) ?? cfg[key];
|
|
55
|
+
}
|
|
56
|
+
exports.CONFIG_HELP = `forumulate config — defaults for every command
|
|
57
|
+
|
|
58
|
+
Usage:
|
|
59
|
+
forumulate config set <key> <value>
|
|
60
|
+
forumulate config get <key>
|
|
61
|
+
forumulate config unset <key>
|
|
62
|
+
forumulate config list [--json]
|
|
63
|
+
forumulate config path
|
|
64
|
+
|
|
65
|
+
Keys:
|
|
66
|
+
${Object.entries(exports.CONFIG_KEYS)
|
|
67
|
+
.map(([k, v]) => ` ${k.padEnd(12)} ${v.about} (env ${v.env})`)
|
|
68
|
+
.join('\n')}
|
|
69
|
+
|
|
70
|
+
A flag beats the environment, and the environment beats this file.`;
|
|
71
|
+
function runConfig(positionals, json, io) {
|
|
72
|
+
const [verb, key, ...value] = positionals;
|
|
73
|
+
const cfg = readConfig(io.env);
|
|
74
|
+
const known = (k) => {
|
|
75
|
+
if (k && k in exports.CONFIG_KEYS)
|
|
76
|
+
return true;
|
|
77
|
+
io.err(`Unknown key "${k ?? ''}". Keys: ${Object.keys(exports.CONFIG_KEYS).join(', ')}`);
|
|
78
|
+
return false;
|
|
79
|
+
};
|
|
80
|
+
switch (verb) {
|
|
81
|
+
case 'set': {
|
|
82
|
+
if (!known(key))
|
|
83
|
+
return 1;
|
|
84
|
+
if (value.length === 0) {
|
|
85
|
+
io.err(`Usage: forumulate config set ${key} <value>`);
|
|
86
|
+
return 1;
|
|
87
|
+
}
|
|
88
|
+
cfg[key] = value.join(' ');
|
|
89
|
+
const path = writeConfig(cfg, io.env);
|
|
90
|
+
io.out(`${key} = ${cfg[key]} (${path})`);
|
|
91
|
+
return 0;
|
|
92
|
+
}
|
|
93
|
+
case 'get': {
|
|
94
|
+
if (!known(key))
|
|
95
|
+
return 1;
|
|
96
|
+
const v = setting(key, undefined, io.env, cfg);
|
|
97
|
+
if (v === undefined)
|
|
98
|
+
return 1;
|
|
99
|
+
io.out(v);
|
|
100
|
+
return 0;
|
|
101
|
+
}
|
|
102
|
+
case 'unset': {
|
|
103
|
+
if (!known(key))
|
|
104
|
+
return 1;
|
|
105
|
+
delete cfg[key];
|
|
106
|
+
writeConfig(cfg, io.env);
|
|
107
|
+
io.out(`${key} unset`);
|
|
108
|
+
return 0;
|
|
109
|
+
}
|
|
110
|
+
case 'list':
|
|
111
|
+
case undefined: {
|
|
112
|
+
const rows = Object.keys(exports.CONFIG_KEYS).map((k) => {
|
|
113
|
+
const env = io.env[exports.CONFIG_KEYS[k].env]?.trim();
|
|
114
|
+
return { key: k, value: env || cfg[k] || '', from: env ? 'env' : cfg[k] ? 'file' : '' };
|
|
115
|
+
});
|
|
116
|
+
if (json)
|
|
117
|
+
io.out(JSON.stringify(Object.fromEntries(rows.map((r) => [r.key, r.value || null])), null, 2));
|
|
118
|
+
else
|
|
119
|
+
for (const r of rows)
|
|
120
|
+
io.out(`${r.key.padEnd(12)} ${r.value || '-'}${r.from ? ` (${r.from})` : ''}`);
|
|
121
|
+
return 0;
|
|
122
|
+
}
|
|
123
|
+
case 'path':
|
|
124
|
+
io.out(configPath(io.env));
|
|
125
|
+
return 0;
|
|
126
|
+
default:
|
|
127
|
+
io.out(exports.CONFIG_HELP);
|
|
128
|
+
return verb === 'help' ? 0 : 1;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* The environment the older commands read (`content`, `import`), with the
|
|
133
|
+
* config file's defaults filled in where the environment says nothing — so
|
|
134
|
+
* `config set org` reaches them too without teaching each one to read a file.
|
|
135
|
+
*/
|
|
136
|
+
function envWithConfig(env = process.env) {
|
|
137
|
+
const cfg = readConfig(env);
|
|
138
|
+
const out = { ...env };
|
|
139
|
+
for (const [key, { env: name }] of Object.entries(exports.CONFIG_KEYS))
|
|
140
|
+
if (!out[name]?.trim() && cfg[key])
|
|
141
|
+
out[name] = cfg[key];
|
|
142
|
+
return out;
|
|
143
|
+
}
|
|
144
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"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AI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YACpF,OAAO,CAAC,CAAC;QACX,CAAC;QACD,KAAK,MAAM;YACT,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;YAC3B,OAAO,CAAC,CAAC;QACX;YACE,EAAE,CAAC,GAAG,CAAC,mBAAW,CAAC,CAAC;YACpB,OAAO,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACnC,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,SAAgB,aAAa,CAAC,MAAyB,OAAO,CAAC,GAAG;IAChE,MAAM,GAAG,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC;IAC5B,MAAM,GAAG,GAAG,EAAE,GAAG,GAAG,EAAE,CAAC;IACvB,KAAK,MAAM,CAAC,GAAG,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,mBAAW,CAAC;QAC5D,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,GAAG,CAAC,GAAG,CAAC;YAAE,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;IAC3D,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Http } from '../api/http';
|
|
2
|
+
import type { CliConfig } from './config';
|
|
3
|
+
/**
|
|
4
|
+
* What `forumulate api` and the resource commands need from the outside world,
|
|
5
|
+
* all injected so the tests drive them against a fake server and no disk.
|
|
6
|
+
*/
|
|
7
|
+
export interface CommandDeps {
|
|
8
|
+
http: Http;
|
|
9
|
+
out: (line: string) => void;
|
|
10
|
+
err: (line: string) => void;
|
|
11
|
+
env: NodeJS.ProcessEnv;
|
|
12
|
+
config: CliConfig;
|
|
13
|
+
readFile: (path: string) => string | Buffer;
|
|
14
|
+
/** Where `--out <file>` lands: a downloaded archive, PDF or export. */
|
|
15
|
+
writeFile: (path: string, data: Buffer | string) => void;
|
|
16
|
+
readStdin: () => Promise<string>;
|
|
17
|
+
/** A visible y/N question; absent when nobody can answer (CI, a pipe). */
|
|
18
|
+
ask?: (question: string) => Promise<string>;
|
|
19
|
+
/** `--org` → `FORUMULATE_ORG` → `config set org`, already resolved. */
|
|
20
|
+
defaultOrg?: string;
|
|
21
|
+
}
|
|
22
|
+
export declare const isUuid: (s: string) => boolean;
|
|
23
|
+
/**
|
|
24
|
+
* A space by id or slug. `/orgs/{orgId}` takes a slug; `/spaces/{spaceId}`
|
|
25
|
+
* takes only the id, and "pass the uuid" is not an answer a person typing
|
|
26
|
+
* `--space docs` should get. One list call, only when it is not already an id.
|
|
27
|
+
*/
|
|
28
|
+
export declare function resolveChild(deps: CommandDeps, what: 'space' | 'library', orgId: string, ref: string): Promise<string>;
|
|
29
|
+
/**
|
|
30
|
+
* The y/N before anything irreversible. `--yes` skips it; with no terminal to
|
|
31
|
+
* ask on, `--yes` is required — a delete in CI that silently proceeds because
|
|
32
|
+
* nobody could be asked is the outcome the question exists to prevent.
|
|
33
|
+
*/
|
|
34
|
+
export declare function confirm(deps: CommandDeps, yes: boolean, question: string): Promise<boolean>;
|
|
35
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/commands/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAG1C;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,IAAI,CAAC;IACX,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5B,GAAG,EAAE,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