@picked/cli 0.0.101-next.2 → 0.0.101-next.3
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 +29 -11
- package/dist/.tsbuildinfo +1 -1
- package/dist/cjs/cli.js +4 -2
- package/dist/cjs/index.js +1 -1
- package/dist/esm/cli.js +69 -67
- package/dist/esm/index.js +2 -2
- package/dist/types/commands/docs.d.ts +65 -0
- package/dist/types/commands/docs.d.ts.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/lib/docs.d.ts +94 -0
- package/dist/types/lib/docs.d.ts.map +1 -0
- package/dist/{workspace-use-CnR5FkxR.js → workspace-use-CXcLlf_z.js} +423 -254
- package/dist/workspace-use-Df1AcQnn.cjs +53 -0
- package/package.json +5 -5
- package/dist/workspace-use-Cjn8sjJj.cjs +0 -51
package/dist/cjs/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const e=require("../workspace-use-
|
|
2
|
+
const e=require("../workspace-use-Df1AcQnn.cjs");let t=require("@picked/config"),n=require("node:util"),r=require("@picked/telemetry");var i=2e3,a=null,o=0;function s(e){if((0,t.isTelemetryForcedOffByEnvironment)())return;o=Date.now();let n=(0,t.detectHostEnvironment)();a={name:`picked.cli.${e}`,traceId:(0,r.createTraceId)(),spanId:(0,r.createSpanId)(),startTimeUnixNano:(0,r.toUnixNano)(o),endTimeUnixNano:(0,r.toUnixNano)(o),attributes:{"picked.cli.command":e,"picked.env.provider":n.provider,"picked.env.ci":n.ci},status:`unset`}}function c(e){a&&(a.endTimeUnixNano=(0,r.toUnixNano)(Date.now()),a.status=e===0?`ok`:`error`)}async function l(){let e=a;if(a=null,e)try{let n=await(0,t.loadResolvedPickedConfig)();if(!n||!(0,t.isTelemetryEnabled)(n))return;let a=(0,r.createTelemetryEmitter)({resource:{"service.name":`picked-cli`},headers:{"Picked-Telemetry":`cli`}});a.record(e),await Promise.race([a.flush(),new Promise(e=>{setTimeout(e,i).unref()})])}catch{}}var u=`Usage:
|
|
3
3
|
picked login
|
|
4
4
|
picked logout
|
|
5
5
|
picked whoami
|
|
@@ -9,4 +9,6 @@ const e=require("../workspace-use-Cjn8sjJj.cjs");let t=require("@picked/config")
|
|
|
9
9
|
picked use [--project <id>] [--workspace <id>] [--no-generate]
|
|
10
10
|
picked workspace export --project <id> (--workspace <id> | --live) --out <dir>
|
|
11
11
|
picked workspace import --project <id> --in <dir> [--name <name>] [--publish]
|
|
12
|
-
picked generate types [--check]
|
|
12
|
+
picked generate types [--check]
|
|
13
|
+
picked docs list [words] [--type <type>] [--json]
|
|
14
|
+
picked docs read <path>`,d=new Map([[`login`,()=>e.c({})],[`logout`,()=>e.s()],[`whoami`,()=>e.a()],[`status`,()=>e.o({})]]);async function f(){let{positionals:t,values:r}=(0,n.parseArgs)({allowPositionals:!0,options:{check:{type:`boolean`,default:!1},project:{type:`string`},workspace:{type:`string`},json:{type:`boolean`,default:!1},generate:{type:`boolean`,default:!0},"no-generate":{type:`boolean`,default:!1},live:{type:`boolean`,default:!1},out:{type:`string`},in:{type:`string`},name:{type:`string`},publish:{type:`boolean`,default:!1},type:{type:`string`}}}),[i,a]=t,o=r.generate&&!r[`no-generate`],c=i===void 0?void 0:d.get(i);if(i!==void 0&&c){s(i),process.exitCode=await c();return}if(i===`workspace`&&(a===`list`||a===`ls`)){s(`workspace list`),process.exitCode=await e.n({json:r.json});return}if(i===`workspace`&&a===`use`||i===`use`){s(`workspace use`),process.exitCode=await e.t({project:r.project,workspace:r.workspace,generate:o});return}if(i===`workspace`&&a===`export`){s(`workspace export`),process.exitCode=await e.i({project:r.project,workspace:r.workspace,live:r.live,out:r.out});return}if(i===`workspace`&&a===`import`){s(`workspace import`),process.exitCode=await e.r({project:r.project,in:r.in,name:r.name,publish:r.publish});return}if(i===`docs`){s(e.u(a)),process.exitCode=await e.d({args:t.slice(1),type:r.type,json:r.json});return}if(i===`generate`&&a===`types`){s(`generate types`),process.exitCode=await e.l({check:r.check});return}s(`unknown`),console.error(u),process.exitCode=1}function p(e){let t=2,n=()=>{--t,t<=0&&process.exit(e)};setTimeout(()=>{process.exit(e)},2e3).unref(),process.stdout.write(``,n),process.stderr.write(``,n)}f().then(async()=>{let e=typeof process.exitCode==`number`?process.exitCode:0;c(e),await l(),p(e)}).catch(e=>{let t=e instanceof Error?e.message:String(e);console.error(t),c(1),l().finally(()=>{p(1)})});
|
package/dist/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../workspace-use-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../workspace-use-Df1AcQnn.cjs");exports.runDocs=e.d,exports.runDocsList=e.f,exports.runDocsRead=e.p,exports.runGenerateTypes=e.l,exports.runLogin=e.c,exports.runLogout=e.s,exports.runStatus=e.o,exports.runWhoami=e.a,exports.runWorkspaceExport=e.i,exports.runWorkspaceImport=e.r,exports.runWorkspaceList=e.n,exports.runWorkspaceUse=e.t;
|
package/dist/esm/cli.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { a as e, c as t,
|
|
3
|
-
import { detectHostEnvironment as
|
|
4
|
-
import { parseArgs as
|
|
5
|
-
import { createSpanId as
|
|
2
|
+
import { a as e, c as t, d as n, i as r, l as i, n as a, o, r as s, s as c, t as l, u } from "../workspace-use-CXcLlf_z.js";
|
|
3
|
+
import { detectHostEnvironment as d, isTelemetryEnabled as f, isTelemetryForcedOffByEnvironment as p, loadResolvedPickedConfig as m } from "@picked/config";
|
|
4
|
+
import { parseArgs as h } from "node:util";
|
|
5
|
+
import { createSpanId as g, createTelemetryEmitter as _, createTraceId as v, toUnixNano as y } from "@picked/telemetry";
|
|
6
6
|
//#region src/telemetry.ts
|
|
7
|
-
var
|
|
8
|
-
function
|
|
9
|
-
if (
|
|
10
|
-
|
|
11
|
-
let t =
|
|
12
|
-
|
|
7
|
+
var b = 2e3, x = null, S = 0;
|
|
8
|
+
function C(e) {
|
|
9
|
+
if (p()) return;
|
|
10
|
+
S = Date.now();
|
|
11
|
+
let t = d();
|
|
12
|
+
x = {
|
|
13
13
|
name: `picked.cli.${e}`,
|
|
14
|
-
traceId:
|
|
15
|
-
spanId:
|
|
16
|
-
startTimeUnixNano:
|
|
17
|
-
endTimeUnixNano:
|
|
14
|
+
traceId: v(),
|
|
15
|
+
spanId: g(),
|
|
16
|
+
startTimeUnixNano: y(S),
|
|
17
|
+
endTimeUnixNano: y(S),
|
|
18
18
|
attributes: {
|
|
19
19
|
"picked.cli.command": e,
|
|
20
20
|
"picked.env.provider": t.provider,
|
|
@@ -23,28 +23,33 @@ function x(e) {
|
|
|
23
23
|
status: "unset"
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
|
-
function
|
|
27
|
-
|
|
26
|
+
function w(e) {
|
|
27
|
+
x && (x.endTimeUnixNano = y(Date.now()), x.status = e === 0 ? "ok" : "error");
|
|
28
28
|
}
|
|
29
|
-
async function
|
|
30
|
-
let e =
|
|
31
|
-
if (
|
|
32
|
-
let t = await
|
|
33
|
-
if (!t || !
|
|
34
|
-
let n =
|
|
29
|
+
async function T() {
|
|
30
|
+
let e = x;
|
|
31
|
+
if (x = null, e) try {
|
|
32
|
+
let t = await m();
|
|
33
|
+
if (!t || !f(t)) return;
|
|
34
|
+
let n = _({
|
|
35
35
|
resource: { "service.name": "picked-cli" },
|
|
36
36
|
headers: { "Picked-Telemetry": "cli" }
|
|
37
37
|
});
|
|
38
38
|
n.record(e), await Promise.race([n.flush(), new Promise((e) => {
|
|
39
|
-
setTimeout(e,
|
|
39
|
+
setTimeout(e, b).unref();
|
|
40
40
|
})]);
|
|
41
41
|
} catch {}
|
|
42
42
|
}
|
|
43
43
|
//#endregion
|
|
44
44
|
//#region src/cli.ts
|
|
45
|
-
var
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
var E = "Usage:\n picked login\n picked logout\n picked whoami\n picked status\n picked workspace list [--json]\n picked workspace use [--project <id>] [--workspace <id>] [--no-generate]\n picked use [--project <id>] [--workspace <id>] [--no-generate]\n picked workspace export --project <id> (--workspace <id> | --live) --out <dir>\n picked workspace import --project <id> --in <dir> [--name <name>] [--publish]\n picked generate types [--check]\n picked docs list [words] [--type <type>] [--json]\n picked docs read <path>", D = /* @__PURE__ */ new Map([
|
|
46
|
+
["login", () => t({})],
|
|
47
|
+
["logout", () => c()],
|
|
48
|
+
["whoami", () => e()],
|
|
49
|
+
["status", () => o({})]
|
|
50
|
+
]);
|
|
51
|
+
async function O() {
|
|
52
|
+
let { positionals: e, values: t } = h({
|
|
48
53
|
allowPositionals: !0,
|
|
49
54
|
options: {
|
|
50
55
|
check: {
|
|
@@ -75,62 +80,59 @@ async function T() {
|
|
|
75
80
|
publish: {
|
|
76
81
|
type: "boolean",
|
|
77
82
|
default: !1
|
|
78
|
-
}
|
|
83
|
+
},
|
|
84
|
+
type: { type: "string" }
|
|
79
85
|
}
|
|
80
|
-
}), [
|
|
81
|
-
if (
|
|
82
|
-
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
if (d === "logout") {
|
|
86
|
-
x("logout"), process.exitCode = await s();
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
if (d === "whoami") {
|
|
90
|
-
x("whoami"), process.exitCode = await e();
|
|
86
|
+
}), [o, c] = e, d = t.generate && !t["no-generate"], f = o === void 0 ? void 0 : D.get(o);
|
|
87
|
+
if (o !== void 0 && f) {
|
|
88
|
+
C(o), process.exitCode = await f();
|
|
91
89
|
return;
|
|
92
90
|
}
|
|
93
|
-
if (
|
|
94
|
-
|
|
91
|
+
if (o === "workspace" && (c === "list" || c === "ls")) {
|
|
92
|
+
C("workspace list"), process.exitCode = await a({ json: t.json });
|
|
95
93
|
return;
|
|
96
94
|
}
|
|
97
|
-
if (
|
|
98
|
-
|
|
95
|
+
if (o === "workspace" && c === "use" || o === "use") {
|
|
96
|
+
C("workspace use"), process.exitCode = await l({
|
|
97
|
+
project: t.project,
|
|
98
|
+
workspace: t.workspace,
|
|
99
|
+
generate: d
|
|
100
|
+
});
|
|
99
101
|
return;
|
|
100
102
|
}
|
|
101
|
-
if (
|
|
102
|
-
|
|
103
|
-
project:
|
|
104
|
-
workspace:
|
|
105
|
-
|
|
103
|
+
if (o === "workspace" && c === "export") {
|
|
104
|
+
C("workspace export"), process.exitCode = await r({
|
|
105
|
+
project: t.project,
|
|
106
|
+
workspace: t.workspace,
|
|
107
|
+
live: t.live,
|
|
108
|
+
out: t.out
|
|
106
109
|
});
|
|
107
110
|
return;
|
|
108
111
|
}
|
|
109
|
-
if (
|
|
110
|
-
|
|
111
|
-
project:
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
112
|
+
if (o === "workspace" && c === "import") {
|
|
113
|
+
C("workspace import"), process.exitCode = await s({
|
|
114
|
+
project: t.project,
|
|
115
|
+
in: t.in,
|
|
116
|
+
name: t.name,
|
|
117
|
+
publish: t.publish
|
|
115
118
|
});
|
|
116
119
|
return;
|
|
117
120
|
}
|
|
118
|
-
if (
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
publish: u.publish
|
|
121
|
+
if (o === "docs") {
|
|
122
|
+
C(u(c)), process.exitCode = await n({
|
|
123
|
+
args: e.slice(1),
|
|
124
|
+
type: t.type,
|
|
125
|
+
json: t.json
|
|
124
126
|
});
|
|
125
127
|
return;
|
|
126
128
|
}
|
|
127
|
-
if (
|
|
128
|
-
|
|
129
|
+
if (o === "generate" && c === "types") {
|
|
130
|
+
C("generate types"), process.exitCode = await i({ check: t.check });
|
|
129
131
|
return;
|
|
130
132
|
}
|
|
131
|
-
|
|
133
|
+
C("unknown"), console.error(E), process.exitCode = 1;
|
|
132
134
|
}
|
|
133
|
-
function
|
|
135
|
+
function k(e) {
|
|
134
136
|
let t = 2, n = () => {
|
|
135
137
|
--t, t <= 0 && process.exit(e);
|
|
136
138
|
};
|
|
@@ -138,13 +140,13 @@ function E(e) {
|
|
|
138
140
|
process.exit(e);
|
|
139
141
|
}, 2e3).unref(), process.stdout.write("", n), process.stderr.write("", n);
|
|
140
142
|
}
|
|
141
|
-
|
|
143
|
+
O().then(async () => {
|
|
142
144
|
let e = typeof process.exitCode == "number" ? process.exitCode : 0;
|
|
143
|
-
|
|
145
|
+
w(e), await T(), k(e);
|
|
144
146
|
}).catch((e) => {
|
|
145
147
|
let t = e instanceof Error ? e.message : String(e);
|
|
146
|
-
console.error(t),
|
|
147
|
-
|
|
148
|
+
console.error(t), w(1), T().finally(() => {
|
|
149
|
+
k(1);
|
|
148
150
|
});
|
|
149
151
|
});
|
|
150
152
|
//#endregion
|
package/dist/esm/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as e, c as t,
|
|
2
|
-
export { r as runGenerateTypes, t as runLogin,
|
|
1
|
+
import { a as e, c as t, d as n, f as r, i, l as a, n as o, o as s, p as c, r as l, s as u, t as d } from "../workspace-use-CXcLlf_z.js";
|
|
2
|
+
export { n as runDocs, r as runDocsList, c as runDocsRead, a as runGenerateTypes, t as runLogin, u as runLogout, s as runStatus, e as runWhoami, i as runWorkspaceExport, l as runWorkspaceImport, o as runWorkspaceList, d as runWorkspaceUse };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/** @file `picked docs list` and `picked docs read` command implementations. */
|
|
2
|
+
import { type DocsSource } from '../lib/docs';
|
|
3
|
+
/**
|
|
4
|
+
* Runs `picked docs list`: prints the path and title of each documentation page, one per
|
|
5
|
+
* line, or every field as JSON.
|
|
6
|
+
*
|
|
7
|
+
* @param {object} options - Command options.
|
|
8
|
+
* @param {string} [options.query] - Words that each listed page must hold.
|
|
9
|
+
* @param {string} [options.type] - Content type to keep: `tutorial`, `how-to`, `reference` or `explanation`.
|
|
10
|
+
* @param {boolean} [options.json] - Print the pages as a JSON array.
|
|
11
|
+
* @param {DocsSource} [options.source] - Where to read pages; defaults to the installed `picked` docs.
|
|
12
|
+
* @returns {Promise<number>} Process exit code: 1 when no page matches.
|
|
13
|
+
* @example
|
|
14
|
+
* await runDocsList({ query: 'feature flag' })
|
|
15
|
+
*/
|
|
16
|
+
export declare function runDocsList(options: {
|
|
17
|
+
query?: string;
|
|
18
|
+
type?: string;
|
|
19
|
+
json?: boolean;
|
|
20
|
+
source?: DocsSource;
|
|
21
|
+
}): Promise<number>;
|
|
22
|
+
/**
|
|
23
|
+
* Runs `picked docs read <page>`: prints one page as Markdown, under a comment that names its
|
|
24
|
+
* URL. The page can be a site path, a docs URL, or a bundled file path.
|
|
25
|
+
*
|
|
26
|
+
* @param {object} options - Command options.
|
|
27
|
+
* @param {string | undefined} options.page - The page to read.
|
|
28
|
+
* @param {DocsSource} [options.source] - Where to read pages; defaults to the installed `picked` docs.
|
|
29
|
+
* @returns {Promise<number>} Process exit code: 1 when the page does not exist.
|
|
30
|
+
* @example
|
|
31
|
+
* await runDocsRead({ page: '/how-to/install-the-sdk' })
|
|
32
|
+
*/
|
|
33
|
+
export declare function runDocsRead(options: {
|
|
34
|
+
page: string | undefined;
|
|
35
|
+
source?: DocsSource;
|
|
36
|
+
}): Promise<number>;
|
|
37
|
+
/**
|
|
38
|
+
* Names a `picked docs` invocation for telemetry.
|
|
39
|
+
*
|
|
40
|
+
* @param {string | undefined} subcommand - The word after `picked docs`.
|
|
41
|
+
* @returns {string} `docs list` or `docs read`.
|
|
42
|
+
* @example
|
|
43
|
+
* docsCommandName('read') // 'docs read'
|
|
44
|
+
*/
|
|
45
|
+
export declare function docsCommandName(subcommand: string | undefined): string;
|
|
46
|
+
/**
|
|
47
|
+
* Runs `picked docs`. `picked docs`, `picked docs list [words]` and `picked docs ls` list pages;
|
|
48
|
+
* `picked docs read <path>` and `picked docs <path>` read one.
|
|
49
|
+
*
|
|
50
|
+
* @param {object} options - Command options.
|
|
51
|
+
* @param {string[]} options.args - The words after `picked docs`.
|
|
52
|
+
* @param {string} [options.type] - Content type to keep when listing.
|
|
53
|
+
* @param {boolean} [options.json] - Print a listing as JSON.
|
|
54
|
+
* @param {DocsSource} [options.source] - Where to read pages; defaults to the installed `picked` docs.
|
|
55
|
+
* @returns {Promise<number>} Process exit code.
|
|
56
|
+
* @example
|
|
57
|
+
* await runDocs({ args: ['read', '/how-to/install-the-sdk'] })
|
|
58
|
+
*/
|
|
59
|
+
export declare function runDocs(options: {
|
|
60
|
+
args: string[];
|
|
61
|
+
type?: string;
|
|
62
|
+
json?: boolean;
|
|
63
|
+
source?: DocsSource;
|
|
64
|
+
}): Promise<number>;
|
|
65
|
+
//# sourceMappingURL=docs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docs.d.ts","sourceRoot":"","sources":["../../../src/commands/docs.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,OAAO,EAML,KAAK,UAAU,EAChB,MAAM,aAAa,CAAA;AAIpB;;;;;;;;;;;;GAYG;AACH,wBAAsB,WAAW,CAAC,OAAO,EAAE;IACzC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,MAAM,CAAC,EAAE,UAAU,CAAA;CACpB,GAAG,OAAO,CAAC,MAAM,CAAC,CA8BlB;AA6BD;;;;;;;;;;GAUG;AACH,wBAAsB,WAAW,CAAC,OAAO,EAAE;IACzC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAA;IACxB,MAAM,CAAC,EAAE,UAAU,CAAA;CACpB,GAAG,OAAO,CAAC,MAAM,CAAC,CA8BlB;AAcD;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAEtE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,OAAO,CAAC,OAAO,EAAE;IACrC,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,MAAM,CAAC,EAAE,UAAU,CAAA;CACpB,GAAG,OAAO,CAAC,MAAM,CAAC,CAYlB"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/** @file Public exports for `\@picked/cli`. */
|
|
2
|
+
export { runDocs, runDocsList, runDocsRead } from './commands/docs';
|
|
2
3
|
export { runGenerateTypes } from './commands/generate-types';
|
|
3
4
|
export { runLogin } from './commands/login';
|
|
4
5
|
export { runLogout } from './commands/logout';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAA;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAA;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAA;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAA;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/** Origin of the published documentation site. */
|
|
2
|
+
export declare const DOCS_SITE = "https://docs.picked.app";
|
|
3
|
+
/** One documentation page, addressed by its site path. */
|
|
4
|
+
export interface DocPage {
|
|
5
|
+
/** Site path without extension, e.g. `/how-to/build-a-flow`; `/` for the home page. */
|
|
6
|
+
path: string;
|
|
7
|
+
/** Page title, from its first `#` heading. */
|
|
8
|
+
title: string;
|
|
9
|
+
/** Diátaxis content type: `tutorial`, `how-to`, `reference` or `explanation`. */
|
|
10
|
+
type?: string;
|
|
11
|
+
/** The page's first paragraph. */
|
|
12
|
+
description?: string;
|
|
13
|
+
/** Absolute path of the bundled Markdown file; local pages only. */
|
|
14
|
+
file?: string;
|
|
15
|
+
}
|
|
16
|
+
/** Where `picked docs` reads pages from. */
|
|
17
|
+
export interface DocsSource {
|
|
18
|
+
/** Where the pages come from: a directory, or the index URL. */
|
|
19
|
+
location: string;
|
|
20
|
+
/** Lists every page, in path order. */
|
|
21
|
+
list: () => Promise<DocPage[]>;
|
|
22
|
+
/** Reads one page's Markdown without frontmatter; `undefined` when no page has that path. */
|
|
23
|
+
read: (path: string) => Promise<string | undefined>;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Turns any way of naming a page into its site path: a path with or without its leading
|
|
27
|
+
* slash, a docs URL with or without an anchor, or a bundled file path.
|
|
28
|
+
*
|
|
29
|
+
* @param {string} input - The page as the caller named it.
|
|
30
|
+
* @returns {string} The site path, e.g. `/reference/sdk/steps`.
|
|
31
|
+
* @example
|
|
32
|
+
* normalizeDocPath('node_modules/picked/docs/reference/sdk/steps.md') // '/reference/sdk/steps'
|
|
33
|
+
*/
|
|
34
|
+
export declare function normalizeDocPath(input: string): string;
|
|
35
|
+
/**
|
|
36
|
+
* Reads pages from a directory laid out like `docs/public-docs/docs/pages`, which is how
|
|
37
|
+
* `picked` bundles them.
|
|
38
|
+
*
|
|
39
|
+
* @param {string} dir - The docs directory, e.g. `node_modules/picked/docs`.
|
|
40
|
+
* @returns {DocsSource} The source.
|
|
41
|
+
* @example
|
|
42
|
+
* const pages = await createLocalDocsSource('node_modules/picked/docs').list()
|
|
43
|
+
*/
|
|
44
|
+
export declare function createLocalDocsSource(dir: string): DocsSource;
|
|
45
|
+
/**
|
|
46
|
+
* Reads pages from the index the docs site publishes, for a project without `picked`
|
|
47
|
+
* installed.
|
|
48
|
+
*
|
|
49
|
+
* @param {typeof fetch} [fetchImpl] - The fetch to use.
|
|
50
|
+
* @returns {DocsSource} The source. Its methods throw when the index cannot be fetched.
|
|
51
|
+
* @example
|
|
52
|
+
* const body = await createRemoteDocsSource().read('/reference/tools/cli')
|
|
53
|
+
*/
|
|
54
|
+
export declare function createRemoteDocsSource(fetchImpl?: typeof fetch): DocsSource;
|
|
55
|
+
/**
|
|
56
|
+
* Finds the docs bundled in the `picked` package, in order: `PICKED_DOCS_DIR`, the `picked`
|
|
57
|
+
* package whose bin runs this command, then the `picked` package installed in `cwd`.
|
|
58
|
+
*
|
|
59
|
+
* @param {object} options - Where to look.
|
|
60
|
+
* @param {string} options.cwd - The working directory.
|
|
61
|
+
* @param {string | undefined} options.bin - The script that started the process (`process.argv[1]`).
|
|
62
|
+
* @param {Record<string, string | undefined>} options.env - The environment.
|
|
63
|
+
* @returns {string | undefined} The docs directory, or `undefined` when none is installed.
|
|
64
|
+
* @example
|
|
65
|
+
* findLocalDocsDir({ cwd: process.cwd(), bin: process.argv[1], env: process.env })
|
|
66
|
+
*/
|
|
67
|
+
export declare function findLocalDocsDir(options: {
|
|
68
|
+
cwd: string;
|
|
69
|
+
bin: string | undefined;
|
|
70
|
+
env: Record<string, string | undefined>;
|
|
71
|
+
}): string | undefined;
|
|
72
|
+
/**
|
|
73
|
+
* The docs bundled in `picked` when they are installed, otherwise the published index.
|
|
74
|
+
*
|
|
75
|
+
* @param {object} [options] - Where to look; defaults to the running process.
|
|
76
|
+
* @param {string} [options.cwd] - The working directory.
|
|
77
|
+
* @returns {DocsSource} The source to read.
|
|
78
|
+
* @example
|
|
79
|
+
* const source = resolveDocsSource()
|
|
80
|
+
*/
|
|
81
|
+
export declare function resolveDocsSource(options?: {
|
|
82
|
+
cwd?: string;
|
|
83
|
+
}): DocsSource;
|
|
84
|
+
/**
|
|
85
|
+
* Keeps the pages whose path, title or description holds every word of `query`.
|
|
86
|
+
*
|
|
87
|
+
* @param {DocPage[]} pages - The pages to search.
|
|
88
|
+
* @param {string} query - Words to look for, in any case.
|
|
89
|
+
* @returns {DocPage[]} The matching pages, in their original order.
|
|
90
|
+
* @example
|
|
91
|
+
* searchDocPages(pages, 'feature flag')
|
|
92
|
+
*/
|
|
93
|
+
export declare function searchDocPages(pages: DocPage[], query: string): DocPage[];
|
|
94
|
+
//# sourceMappingURL=docs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docs.d.ts","sourceRoot":"","sources":["../../../src/lib/docs.ts"],"names":[],"mappings":"AAKA,kDAAkD;AAClD,eAAO,MAAM,SAAS,4BAA4B,CAAA;AAElD,0DAA0D;AAC1D,MAAM,WAAW,OAAO;IACtB,uFAAuF;IACvF,IAAI,EAAE,MAAM,CAAA;IACZ,8CAA8C;IAC9C,KAAK,EAAE,MAAM,CAAA;IACb,iFAAiF;IACjF,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,kCAAkC;IAClC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,oEAAoE;IACpE,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED,4CAA4C;AAC5C,MAAM,WAAW,UAAU;IACzB,gEAAgE;IAChE,QAAQ,EAAE,MAAM,CAAA;IAChB,uCAAuC;IACvC,IAAI,EAAE,MAAM,OAAO,CAAC,OAAO,EAAE,CAAC,CAAA;IAC9B,6FAA6F;IAC7F,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;CACpD;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAUtD;AAwDD;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CA+B7D;AAmCD;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,SAAS,GAAE,OAAO,KAAa,GAAG,UAAU,CA6BlF;AA2BD;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE;IACxC,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;IACvB,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAA;CACxC,GAAG,MAAM,GAAG,SAAS,CAqBrB;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,CAAC,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,UAAU,CAOxE;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,EAAE,CASzE"}
|