@theholocron/holocron-plugin-fern 5.0.0-alpha.428 → 5.0.0-alpha.429
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/dist/index.d.mts +3 -2
- package/dist/index.mjs +75 -12
- package/package.json +5 -5
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AuthError, DnsRecordRequest, PluginToken, ResolveTokenInput, Wiki, WikiProvisionOpts, WikiProxyConfig } from "@theholocron/cli";
|
|
2
2
|
/** Resolves the Fern token from `--token`, `HOLOCRON_FERN_TOKEN`, `FERN_TOKEN` or the keyring entry for `fern`, and throws `AuthError` when none is set. */
|
|
3
3
|
export declare const resolveToken: import("@theholocron/cli").TokenResolver;
|
|
4
|
-
/** Every token this plugin takes, for `holocron doctor tokens
|
|
4
|
+
/** Every token this plugin takes, for `holocron doctor tokens`, with the layers that hold it. */
|
|
5
5
|
export declare const tokens: PluginToken[];
|
|
6
6
|
/** The Fern CLI version written into `fern/fern.config.json`. */
|
|
7
7
|
export declare const FERN_VERSION = "5.114.1";
|
|
@@ -89,11 +89,12 @@ export declare class FernWiki implements Wiki {
|
|
|
89
89
|
export type FernPluginOptions = FernWikiOptions;
|
|
90
90
|
/** Builds the `wiki` capability from the plugin options. */
|
|
91
91
|
export declare function wiki(opts: FernPluginOptions): Wiki;
|
|
92
|
-
/** Creates the Fern plugin: its `connection`
|
|
92
|
+
/** Creates the Fern plugin: its `connection` and `token` probes and the `wiki` capability. */
|
|
93
93
|
export declare function createPlugin(options?: FernPluginOptions): {
|
|
94
94
|
name: string;
|
|
95
95
|
probes: {
|
|
96
96
|
connection: import("@theholocron/cli").Probe;
|
|
97
|
+
token: import("@theholocron/cli").Probe;
|
|
97
98
|
};
|
|
98
99
|
capabilities: {
|
|
99
100
|
wiki: () => Wiki;
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
|
-
import { AuthError, connectionProbe, createResolveToken } from "@theholocron/cli";
|
|
1
|
+
import { AuthError, connectionProbe, createResolveToken, tokenExpectations } from "@theholocron/cli";
|
|
2
2
|
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
import { stringifyJson } from "@theholocron/json-utils";
|
|
5
|
+
// src/probes/token/expectations.ts
|
|
6
|
+
/**
|
|
7
|
+
* Where the Fern token is held: CI only (the `publish-wiki` workflow), so `ci` is the one layer declared. Fern has no
|
|
8
|
+
* endpoint that reports a token's permissions, so none are declared and the probe says so instead of guessing. This is
|
|
9
|
+
* the plugin's `tokens` declaration, read through `tokenExpectations()`; change it and the Fern note in
|
|
10
|
+
* `docs/src/content/docs/tokens.mdx` together.
|
|
11
|
+
*/
|
|
12
|
+
const EXPECTED = { layers: ["ci"] };
|
|
5
13
|
// src/auth.ts
|
|
6
14
|
/** Resolves the Fern token from `--token`, `HOLOCRON_FERN_TOKEN`, `FERN_TOKEN` or the keyring entry for `fern`, and throws `AuthError` when none is set. */
|
|
7
15
|
const resolveToken = createResolveToken({
|
|
@@ -10,8 +18,11 @@ const resolveToken = createResolveToken({
|
|
|
10
18
|
keyringService: "fern",
|
|
11
19
|
errorMessage: "no Fern token found. Set HOLOCRON_FERN_TOKEN / FERN_TOKEN, or run: holocron new token fern <token>"
|
|
12
20
|
});
|
|
13
|
-
/** Every token this plugin takes, for `holocron doctor tokens
|
|
14
|
-
const tokens = [
|
|
21
|
+
/** Every token this plugin takes, for `holocron doctor tokens`, with the layers that hold it. */
|
|
22
|
+
const tokens = [{
|
|
23
|
+
...resolveToken.token,
|
|
24
|
+
expect: EXPECTED
|
|
25
|
+
}];
|
|
15
26
|
// src/capabilities/wiki.ts
|
|
16
27
|
/** The Fern CLI version written into `fern/fern.config.json`. */
|
|
17
28
|
const FERN_VERSION = "5.114.1";
|
|
@@ -177,23 +188,75 @@ function updateInstancesBlock(content, instanceUrl, customDomain, multiSource, r
|
|
|
177
188
|
if (match[0] === newBlock) return content;
|
|
178
189
|
return content.replace(blockRe, newBlock);
|
|
179
190
|
}
|
|
191
|
+
// src/probes/token/parse-layer.ts
|
|
192
|
+
/** Reads `--layer <word>` (or `--layer=<word>`) from the words after the probe name, which the CLI passes when `--environment` named a layer. */
|
|
193
|
+
function parseLayer(args) {
|
|
194
|
+
for (let i = 0; i < args.length; i++) {
|
|
195
|
+
const arg = args[i];
|
|
196
|
+
if (arg === "--layer") return args[i + 1];
|
|
197
|
+
if (arg.startsWith("--layer=")) return arg.slice(8);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
// src/probes/token/token.ts
|
|
201
|
+
/**
|
|
202
|
+
* The `token` probe for Fern. Fern has no endpoint that reports who a token is or what it may do, so the probe cannot
|
|
203
|
+
* judge permissions: it checks that a token is set, says whether the layer holds it when `--layer` is passed (because
|
|
204
|
+
* `--environment` named one) against the plugin's `tokens` declaration, and states plainly that permissions are not
|
|
205
|
+
* checked. It makes no request and never prints the token.
|
|
206
|
+
*/
|
|
207
|
+
function tokenProbe(ctx) {
|
|
208
|
+
return {
|
|
209
|
+
summary: "Check that a Fern token is set, and for a layer that it is one that should hold it. Fern cannot report a token's permissions, so those are not checked. Read-only, no request.",
|
|
210
|
+
writes: false,
|
|
211
|
+
acceptsToken: true,
|
|
212
|
+
async run(probe) {
|
|
213
|
+
probe.secret(ctx.token());
|
|
214
|
+
probe.say({
|
|
215
|
+
status: "ok",
|
|
216
|
+
label: "token",
|
|
217
|
+
detail: "set"
|
|
218
|
+
});
|
|
219
|
+
const layer = parseLayer(probe.args ?? []);
|
|
220
|
+
if (layer) {
|
|
221
|
+
const declared = tokenExpectations(tokens, { layer }).length > 0;
|
|
222
|
+
probe.say(declared ? {
|
|
223
|
+
status: "ok",
|
|
224
|
+
label: layer,
|
|
225
|
+
detail: "a layer that should hold this token"
|
|
226
|
+
} : {
|
|
227
|
+
status: "info",
|
|
228
|
+
label: layer,
|
|
229
|
+
detail: "not a layer this token is declared for, so it is only described"
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
probe.say({
|
|
233
|
+
status: "info",
|
|
234
|
+
label: "permissions",
|
|
235
|
+
detail: "Fern cannot report a token's permissions, so they are not checked"
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
}
|
|
180
240
|
// src/index.ts
|
|
181
241
|
/** Builds the `wiki` capability from the plugin options. */
|
|
182
242
|
function wiki(opts) {
|
|
183
243
|
return new FernWiki(opts);
|
|
184
244
|
}
|
|
185
|
-
/** Creates the Fern plugin: its `connection`
|
|
245
|
+
/** Creates the Fern plugin: its `connection` and `token` probes and the `wiki` capability. */
|
|
186
246
|
function createPlugin(options = {}) {
|
|
187
247
|
return {
|
|
188
248
|
name: "@theholocron/holocron-plugin-fern",
|
|
189
|
-
probes: {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
249
|
+
probes: {
|
|
250
|
+
connection: connectionProbe({
|
|
251
|
+
provider: "Fern",
|
|
252
|
+
token: () => resolveToken(options),
|
|
253
|
+
verify: async () => ({
|
|
254
|
+
ok: true,
|
|
255
|
+
subject: "a token is set (Fern cannot check it from here)"
|
|
256
|
+
})
|
|
257
|
+
}),
|
|
258
|
+
token: tokenProbe({ token: () => resolveToken(options) })
|
|
259
|
+
},
|
|
197
260
|
capabilities: { wiki: () => wiki(options) }
|
|
198
261
|
};
|
|
199
262
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theholocron/holocron-plugin-fern",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.429",
|
|
4
4
|
"description": "Holocron plugin for Fern. Implements the wiki capability for engineering knowledge publishing.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"fern",
|
|
@@ -43,14 +43,14 @@
|
|
|
43
43
|
"tsx": "4.23.15",
|
|
44
44
|
"typescript": "^5.9.3",
|
|
45
45
|
"vitest": "^5.1.0",
|
|
46
|
-
"@theholocron/cli": "5.0.0-alpha.428",
|
|
47
46
|
"@theholocron/eslint-config": "^8.9.0-alpha.17",
|
|
48
|
-
"@theholocron/
|
|
47
|
+
"@theholocron/tsconfig": "^8.9.0-alpha.17",
|
|
49
48
|
"@theholocron/tsdown-config": "^8.9.0-alpha.17",
|
|
50
|
-
"@theholocron/
|
|
49
|
+
"@theholocron/vitest-config": "^8.9.0-alpha.17",
|
|
50
|
+
"@theholocron/cli": "5.0.0-alpha.429"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
|
-
"@theholocron/cli": "5.0.0-alpha.
|
|
53
|
+
"@theholocron/cli": "5.0.0-alpha.429"
|
|
54
54
|
},
|
|
55
55
|
"engines": {
|
|
56
56
|
"node": ">=22"
|