@theholocron/cli 5.0.0-alpha.350 → 5.0.0-alpha.351

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/cli.mjs CHANGED
@@ -14838,6 +14838,101 @@ function realDocsPresenceIo(repoRoot) {
14838
14838
  };
14839
14839
  /* v8 ignore stop */
14840
14840
  }
14841
+ // src/commands/probe/docs-tokens/docs-tokens-probe.ts
14842
+ const KEYS = [
14843
+ "envName",
14844
+ "vendorEnvName",
14845
+ "keyringService",
14846
+ "keyringKey"
14847
+ ];
14848
+ /** The plugins that have several credentials, each with its own table, so any row of the page counts. */
14849
+ const OWN_TABLES = /* @__PURE__ */ new Set(["holocron-plugin-discord", "holocron-plugin-github"]);
14850
+ /** Fewer plugin resolvers than this means the search found the wrong place, not that the docs are complete. */
14851
+ const MIN_RESOLVERS = 10;
14852
+ /** Every `key: "value"` string a source declares for one of the given token resolver settings. */
14853
+ function declared(text, keys) {
14854
+ return keys.flatMap((key) => [...text.matchAll(new RegExp(`\\b${key}:\\s*"([^"]+)"`, "g"))].map((match) => match[1]));
14855
+ }
14856
+ /**
14857
+ * `docs tokens`: fails for each token a plugin's resolver reads (`envName`, `vendorEnvName`, `keyringService`,
14858
+ * `keyringKey` in `plugins/<name>/src/auth.ts`) that `docs/src/content/docs/tokens.mdx` does not document. The Discord
14859
+ * and GitHub plugins have their own tables, so any row of the page counts; every other plugin has one row in the
14860
+ * provider table and its names must be in that row. A plugin that resolves nothing (1Password uses the `op` CLI's own
14861
+ * auth) needs no row. The one resolver the setup command builds itself is checked against the whole page. It runs in
14862
+ * the `validate:docs` task, through `docs validate`.
14863
+ */
14864
+ function docsTokensProbe(io) {
14865
+ return {
14866
+ summary: "Fail for each token a plugin resolves that docs/src/content/docs/tokens.mdx does not document.",
14867
+ writes: false,
14868
+ async run(ctx) {
14869
+ const page = io.page();
14870
+ const files = io.authFiles();
14871
+ const rowFor = (plugin) => page.split("\n").find((line) => line.startsWith(`| \`${plugin.replace("holocron-plugin-", "")}\``));
14872
+ ctx.say({
14873
+ status: "heading",
14874
+ label: "Documented tokens"
14875
+ });
14876
+ if (files.length <= MIN_RESOLVERS) ctx.say({
14877
+ status: "fail",
14878
+ label: "plugin resolvers",
14879
+ detail: `found ${files.length}, expected more than ${MIN_RESOLVERS}: is the search looking in the right place?`
14880
+ });
14881
+ for (const { plugin, text } of files) {
14882
+ const names = declared(text, KEYS);
14883
+ const row = OWN_TABLES.has(plugin) ? page : rowFor(plugin);
14884
+ if (names.length > 0 && row === void 0) {
14885
+ ctx.say({
14886
+ status: "fail",
14887
+ label: plugin,
14888
+ detail: "no provider-table row in tokens.mdx"
14889
+ });
14890
+ continue;
14891
+ }
14892
+ const missing = names.filter((name) => !row?.includes(`\`${name}\``));
14893
+ if (missing.length > 0) ctx.say({
14894
+ status: "fail",
14895
+ label: plugin,
14896
+ detail: `not in tokens.mdx: ${missing.join(", ")}`
14897
+ });
14898
+ else ctx.say({
14899
+ status: "ok",
14900
+ label: plugin,
14901
+ detail: `${names.length} documented`
14902
+ });
14903
+ }
14904
+ const setupNames = declared(io.setupSource(), ["envName", "keyringKey"]);
14905
+ const setupMissing = setupNames.filter((name) => !page.includes(`\`${name}\``));
14906
+ if (setupMissing.length > 0) ctx.say({
14907
+ status: "fail",
14908
+ label: "setup",
14909
+ detail: `not in tokens.mdx: ${setupMissing.join(", ")}`
14910
+ });
14911
+ else ctx.say({
14912
+ status: "ok",
14913
+ label: "setup",
14914
+ detail: `${setupNames.length} documented`
14915
+ });
14916
+ }
14917
+ };
14918
+ }
14919
+ // src/commands/probe/docs-tokens/real-docs-tokens-io.ts
14920
+ /** The docs-tokens probe's inputs from the real files of `repoRoot`. */
14921
+ function realDocsTokensIo(repoRoot) {
14922
+ /* v8 ignore start -- reads real files; the probe is tested with an injected io */
14923
+ return {
14924
+ page: () => readFileSync(join(repoRoot, "docs/src/content/docs/tokens.mdx"), "utf8"),
14925
+ authFiles: () => readdirSync(join(repoRoot, "plugins")).map((plugin) => ({
14926
+ plugin,
14927
+ file: join(repoRoot, "plugins", plugin, "src/auth.ts")
14928
+ })).filter(({ file }) => existsSync(file)).map(({ plugin, file }) => ({
14929
+ plugin,
14930
+ text: readFileSync(file, "utf8")
14931
+ })),
14932
+ setupSource: () => readFileSync(join(repoRoot, "cli/cli/src/commands/setup/run-setup.ts"), "utf8")
14933
+ };
14934
+ /* v8 ignore stop */
14935
+ }
14841
14936
  // src/commands/probe/docs-coverage/added-lines.ts
14842
14937
  /**
14843
14938
  * The lines a unified diff (`git diff -U0`) adds or changes, by file: from each hunk header
@@ -15077,12 +15172,16 @@ function summarise$2(ctx, packages) {
15077
15172
  * and `docs patch` also write that report wherever `--lcov <path>` says, from the same measurement.
15078
15173
  *
15079
15174
  * `docs presence` is a different kind of check (does a feature come with docs?), kept in this group with the others: see
15080
- * `docsPresenceProbe`. `presenceIo` is what it reads from git and the filesystem.
15175
+ * `docsPresenceProbe`. `presenceIo` is what it reads from git and the filesystem. `docs tokens` fails for a token a
15176
+ * plugin resolves that the tokens page does not document (`docsTokensProbe`, reading through `tokensIo`), and `docs
15177
+ * validate` runs presence and then tokens: it is the `validate:docs` task, so the warning and the failure share one CI check.
15081
15178
  *
15082
15179
  * `mode` is the repo's `repoValidation.docsCoverage`, and only `docs patch` follows it: `off` skips it (nothing is
15083
15180
  * measured or written), `warn` reports an undocumented export without failing, `required` fails for it.
15084
15181
  */
15085
- function docsCoverageProbes(repoRoot, typedoc = runTypedoc(repoRoot), diff = realDiff(repoRoot), mode = "required", presenceIo = realDocsPresenceIo(repoRoot)) {
15182
+ function docsCoverageProbes(repoRoot, typedoc = runTypedoc(repoRoot), diff = realDiff(repoRoot), mode = "required", presenceIo = realDocsPresenceIo(repoRoot), tokensIo = realDocsTokensIo(repoRoot)) {
15183
+ const presence = docsPresenceProbe(presenceIo);
15184
+ const tokens = docsTokensProbe(tokensIo);
15086
15185
  const measure = () => measureDocsCoverage({
15087
15186
  repoRoot,
15088
15187
  typedoc
@@ -15141,7 +15240,16 @@ function docsCoverageProbes(repoRoot, typedoc = runTypedoc(repoRoot), diff = rea
15141
15240
  });
15142
15241
  }
15143
15242
  },
15144
- presence: docsPresenceProbe(presenceIo),
15243
+ presence,
15244
+ tokens,
15245
+ validate: {
15246
+ summary: "Run docs presence (warns) and docs tokens (fails): the validate:docs task.",
15247
+ writes: false,
15248
+ async run(ctx) {
15249
+ await presence.run(ctx);
15250
+ await tokens.run(ctx);
15251
+ }
15252
+ },
15145
15253
  lcov: {
15146
15254
  summary: "Write coverage/docs.lcov: the doc-comment coverage as an lcov report.",
15147
15255
  writes: true,