@metamask-previews/platform-api-docs 0.2.1-preview-11d253c58 → 0.2.1-preview-0a1dd02ad

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/CHANGELOG.md CHANGED
@@ -7,11 +7,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
- ### Changed
11
-
12
- - Bump `execa` from `^5.0.0` to `^10.0.1` ([#10330](https://github.com/MetaMask/core/pull/10330), [#10332](https://github.com/MetaMask/core/pull/10332))
13
- - Bump `yargs` from `^17.7.2` to `^17.7.3` ([#10446](https://github.com/MetaMask/core/pull/10446))
14
-
15
10
  ## [0.2.1]
16
11
 
17
12
  ### Changed
@@ -35,10 +30,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
35
30
  - Speed up documentation generation by loading source files in bulk instead of one at a time ([#9990](https://github.com/MetaMask/core/pull/9990))
36
31
  - Bump `@metamask/utils` from `^11.11.0` to `^11.12.0` ([#10076](https://github.com/MetaMask/core/pull/10076))
37
32
 
38
- ### Fixed
39
-
40
- - Link a capability to its source rather than to the build output compiled from it, where both are available ([#10085](https://github.com/MetaMask/core/pull/10085))
41
-
42
33
  ## [0.1.0]
43
34
 
44
35
  ### Added
package/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { execa } from 'execa';
2
+ import execa from 'execa';
3
3
  import * as fs from 'node:fs/promises';
4
4
  import * as path from 'node:path';
5
5
  import npmWhich from 'npm-which';
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC9B,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,Q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I,CAAC,UAAU,CAAC,KAAK,QAAQ,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACxE,aAAa,CAAC,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC;QAC5C,CAAC;QACD,IACE,OAAO,IAAI,CAAC,eAAe,CAAC,KAAK,QAAQ;YACzC,IAAI,CAAC,eAAe,CAAC,CAAC,MAAM,GAAG,CAAC,EAChC,CAAC;YACD,aAAa,CAAC,aAAa,GAAG,IAAI,CAAC,eAAe,CAAC,CAAC;QACtD,CAAC;QAED,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;YACb,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAC;YACxC,MAAM,aAAa,CAAC,OAAO,EAAE,iBAAiB,EAAE,aAAa,CAAC,CAAC;QACjE,CAAC;aAAM,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACpC,OAAO,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC;YACzC,MAAM,aAAa,CAAC,OAAO,EAAE,iBAAiB,EAAE,aAAa,CAAC,CAAC;YAE/D,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;gBACf,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAC;gBACxC,MAAM,aAAa,CAAC,OAAO,EAAE,iBAAiB,EAAE,aAAa,CAAC,CAAC;YACjE,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACrB,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC,CAAC,CAAC","sourcesContent":["#!/usr/bin/env node\n\nimport { execa } from 'execa';\nimport * as fs from 'node:fs/promises';\nimport * as path from 'node:path';\nimport npmWhich from 'npm-which';\nimport yargs from 'yargs';\n\nimport { generate, resolveRepoUrl } from './generate.js';\nimport type { RootCapabilitiesTypeReference } from './root-messenger-discovery.js';\nimport { parseRootCapabilitiesTypeReference } from './root-messenger-discovery.js';\n\n/**\n * Arguments shared by both discovery strategies.\n */\ntype CommonArguments = {\n /** Whether to build the generated site. */\n build: boolean;\n /** Whether to serve the production build. */\n serve: boolean;\n /** Whether to serve the development site. */\n dev: boolean;\n /** Path to the project being documented. */\n 'project-path': string;\n /** Directory where generated documentation is written. */\n output?: string;\n /** Label displayed in the generated documentation. */\n 'project-label'?: string;\n /** URL where the generated site is served. */\n 'site-url'?: string;\n /** Base path where the generated site is served. */\n 'site-base-url'?: string;\n};\n\n/**\n * Arguments for the strategy that scans configured source directories.\n */\ntype ScanStrategyArguments = {\n /** The selected strategy. */\n strategy: 'scan';\n /** Directories, relative to the project root, to scan. */\n scanDir: string[];\n};\n\n/**\n * Arguments for the strategy that resolves a root messenger's type unions.\n */\ntype RootMessengerStrategyArguments = {\n /** The selected strategy. */\n strategy: 'root-messenger';\n /** The root messenger actions type reference. */\n rootActions: RootCapabilitiesTypeReference;\n /** The root messenger events type reference. */\n rootEvents: RootCapabilitiesTypeReference;\n};\n\n/**\n * Parsed CLI arguments, discriminated by the selected discovery strategy.\n */\ntype ParsedArguments = CommonArguments &\n (ScanStrategyArguments | RootMessengerStrategyArguments);\n\n/**\n * Locate the Docusaurus binary in this package's `node_modules/.bin`. Using\n * `npm-which` lets the lookup track wherever the installed Docusaurus puts\n * its binary, so a future Docusaurus upgrade can't break this path.\n *\n * @returns Absolute path to the `docusaurus` executable.\n */\nfunction resolveDocusaurus(): string {\n return npmWhich(import.meta.dirname).sync('docusaurus');\n}\n\n/**\n * Run a Docusaurus command.\n *\n * @param command - The docusaurus command (start, build, serve).\n * @param cwd - The site directory.\n * @param extraEnv - Extra environment variables passed through to the\n * Docusaurus process (e.g. `DOCS_PROJECT_LABEL`, `DOCS_COMMIT_SHA`,\n * `DOCS_REPO_URL`).\n */\nasync function runDocusaurus(\n command: string,\n cwd: string,\n extraEnv: Record<string, string> = {},\n): Promise<void> {\n await execa(resolveDocusaurus(), [command], {\n cwd,\n stdio: 'inherit',\n env: { ...process.env, ...extraEnv },\n });\n}\n\n/**\n * Copy site files into the output directory, skipping `node_modules`, `docs`,\n * and `tsconfig.json`. `docs` is owned by the doc generator and shouldn't be\n * carried over from the source `site/` directory. `tsconfig.json` extends the\n * monorepo's `tsconfig.base.json` via a relative path that only resolves from\n * the source location — it's there for IDE / lint inheritance, not for\n * Docusaurus, which uses `jiti` and doesn't consult the tsconfig at runtime.\n *\n * @param outDir - The output directory to set up.\n */\nasync function setupSite(outDir: string): Promise<void> {\n const packageDir = path.resolve(import.meta.dirname, '..');\n const siteDir = path.join(packageDir, 'site');\n const packageNodeModules = path.join(packageDir, 'node_modules');\n const skip = new Set(['node_modules', 'docs', 'tsconfig.json']);\n\n console.log(`\\nSetting up Docusaurus site in ${outDir}...`);\n\n await fs.cp(siteDir, outDir, {\n recursive: true,\n filter: (source) => !skip.has(path.basename(source)),\n });\n\n // Symlink this package's `node_modules` into the output so the copied\n // `docusaurus.config.ts` and the rest of Docusaurus's bundling pipeline can\n // resolve their deps the same way they do in the source tree. Without it,\n // Node's resolver walks up from the output and can't reach our nested deps\n // when the package is installed as a regular dependency by an external\n // consumer (e.g. `metamask-extension`, `metamask-mobile`).\n const linkPath = path.join(outDir, 'node_modules');\n try {\n // `'junction'` works cross-platform (POSIX ignores it; Windows uses it\n // without admin) — `'dir'` would require admin on Windows.\n await fs.symlink(packageNodeModules, linkPath, 'junction');\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== 'EEXIST') {\n throw error;\n }\n }\n\n // Write a minimal package.json so Docusaurus doesn't warn about a missing one\n const pkgJsonPath = path.join(outDir, 'package.json');\n try {\n await fs.access(pkgJsonPath);\n } catch {\n await fs.writeFile(\n pkgJsonPath,\n JSON.stringify(\n { name: 'platform-api-docs-site', private: true },\n null,\n 2,\n ),\n );\n }\n}\n\n/**\n * Resolve the short Git commit SHA the docs are being generated from.\n * Returns null when the project isn't a git repo or git isn't available.\n *\n * @param projectPath - The project root path.\n * @returns The short SHA, or null on failure.\n */\nasync function resolveCommitSha(projectPath: string): Promise<string | null> {\n try {\n const { stdout } = await execa('git', ['rev-parse', '--short', 'HEAD'], {\n cwd: projectPath,\n });\n const trimmed = stdout.trim();\n return trimmed.length > 0 ? trimmed : null;\n } catch {\n return null;\n }\n}\n\n/**\n * Reject flag combinations that don't make sense, so a mistaken invocation\n * fails instead of silently producing docs built the wrong way.\n *\n * Flags belonging to the strategy that wasn't selected are errors rather than\n * ignored. Used as a yargs `.check`, so failures print alongside usage.\n *\n * @param argv - The parsed arguments.\n * @param argv.strategy - The selected discovery strategy.\n * @param argv.rootActions - The parsed root actions type reference.\n * @param argv.rootEvents - The parsed root events type reference.\n * @param argv.scanDir - The additional directories to scan.\n * @returns True when the combination is valid.\n */\nfunction checkStrategyArgs({\n strategy,\n rootActions,\n rootEvents,\n scanDir = [],\n}: {\n strategy?: 'root-messenger' | 'scan';\n rootActions?: RootCapabilitiesTypeReference;\n rootEvents?: RootCapabilitiesTypeReference;\n scanDir?: string[];\n}): ScanStrategyArguments | RootMessengerStrategyArguments {\n if (strategy !== 'root-messenger') {\n if (rootActions !== undefined || rootEvents !== undefined) {\n throw new Error(\n '--root-actions and --root-events only apply to --strategy root-messenger.',\n );\n }\n return { strategy: 'scan', scanDir };\n }\n\n if (rootActions === undefined || rootEvents === undefined) {\n throw new Error(\n '--strategy root-messenger requires both --root-actions and --root-events, ' +\n 'each written as \"<file>#<TypeName>\".',\n );\n }\n if (scanDir.length > 0) {\n throw new Error(\n '--scan-dir only applies to --strategy scan; --strategy root-messenger reads ' +\n 'only the files named by --root-actions and --root-events.',\n );\n }\n\n return { strategy, rootActions, rootEvents };\n}\n\n/**\n * Parse and validate CLI arguments.\n *\n * @param argumentsForParsing - Arguments to parse, excluding the Node and\n * script paths.\n * @returns Parsed arguments, discriminated by discovery strategy.\n */\nasync function parseArguments(\n argumentsForParsing: string[] = process.argv.slice(2),\n): Promise<ParsedArguments> {\n const argv = await yargs(argumentsForParsing)\n .command(\n '$0 [project-path]',\n 'Produces documentation for the platform API, the set of actions and events available in clients through the message bus.',\n (yargsInstance) => {\n yargsInstance.positional('project-path', {\n type: 'string',\n description: 'Path to the project to scan',\n default: '.',\n });\n },\n )\n .option('build', {\n type: 'boolean',\n description:\n 'Generate platform API docs and build a production-ready site',\n default: false,\n })\n .option('serve', {\n type: 'boolean',\n description:\n 'Generate platform API docs and serve a production-ready site',\n default: false,\n })\n .option('dev', {\n type: 'boolean',\n description:\n 'Generate platform API docs and serve a development-only site',\n default: false,\n })\n .option('strategy', {\n type: 'string',\n description:\n 'How to find messenger actions and events. \"scan\" parses every source and declaration file looking for messenger types. \"root-messenger\" instead resolves the two types the project declares for its root messenger',\n default: 'scan',\n })\n .choices('strategy', ['scan', 'root-messenger'] as const)\n .option('root-actions', {\n type: 'string',\n coerce: parseRootCapabilitiesTypeReference,\n description:\n 'Type aliasing the union of every action on the root messenger, written as \"<file>#<TypeName>\" (required with --strategy root-messenger)',\n })\n .option('root-events', {\n type: 'string',\n coerce: parseRootCapabilitiesTypeReference,\n description:\n 'Type aliasing the union of every event on the root messenger, written as \"<file>#<TypeName>\" (required with --strategy root-messenger)',\n })\n .option('scan-dir', {\n type: 'array',\n string: true,\n description:\n 'Additional directories within the project to scan for messenger actions and events (note: may be specified multiple times)',\n default: [],\n })\n .option('output', {\n type: 'string',\n description: 'Output directory',\n })\n .option('project-label', {\n type: 'string',\n description:\n 'Short label identifying the project (e.g. \"Core\", \"Extension\") — stamped on the site title and headings',\n })\n .option('site-url', {\n type: 'string',\n description:\n 'Absolute URL the built site will be served from, e.g. https://metamask.github.io',\n })\n .option('site-base-url', {\n type: 'string',\n description:\n 'Path prefix the built site will be served under, e.g. /core/platform-api/',\n })\n .help()\n .parse();\n\n const strategyArguments = checkStrategyArgs(argv);\n\n const projectPath = argv['project-path'];\n if (typeof projectPath !== 'string') {\n throw new Error('Expected --project-path to be a string.');\n }\n\n return {\n build: argv.build,\n serve: argv.serve,\n dev: argv.dev,\n 'project-path': projectPath,\n output: argv.output,\n 'project-label': argv['project-label'],\n 'site-url': argv['site-url'],\n 'site-base-url': argv['site-base-url'],\n ...strategyArguments,\n };\n}\n\n/**\n * Main CLI entry point.\n */\nasync function main(): Promise<void> {\n const argv = await parseArguments();\n\n const resolvedProjectPath = path.resolve(argv['project-path']);\n const resolvedOutputDir = path.resolve(\n argv.output ?? path.join(resolvedProjectPath, '.platform-api-docs'),\n );\n const projectLabel =\n argv['project-label'] && argv['project-label'].length > 0\n ? argv['project-label']\n : null;\n const commitSha = await resolveCommitSha(resolvedProjectPath);\n const repoUrl = await resolveRepoUrl(resolvedProjectPath);\n\n // Step 1: Generate docs\n if (argv.strategy === 'root-messenger') {\n await generate({\n projectPath: resolvedProjectPath,\n outputDir: resolvedOutputDir,\n projectLabel,\n commitSha,\n strategy: 'root-messenger',\n rootActions: argv.rootActions,\n rootEvents: argv.rootEvents,\n });\n } else {\n const scanDirs = ['src', ...argv.scanDir].filter(\n (dir, index, dirs) => dirs.indexOf(dir) === index,\n );\n\n await generate({\n projectPath: resolvedProjectPath,\n outputDir: resolvedOutputDir,\n projectLabel,\n commitSha,\n strategy: 'scan',\n scanDirs,\n });\n }\n\n // Step 2: If --build, --serve, or --dev, set up and run Docusaurus\n if (argv.build || argv.serve || argv.dev) {\n await setupSite(resolvedOutputDir);\n\n // Translate CLI flags into the environment variables Docusaurus's\n // config reads. Keeping the CLI surface flag-only means consumers\n // (workflow files, package.json scripts) don't have to know how the\n // values are plumbed through to Docusaurus.\n const docusaurusEnv: Record<string, string> = {};\n if (projectLabel) {\n docusaurusEnv.DOCS_PROJECT_LABEL = projectLabel;\n }\n if (commitSha) {\n docusaurusEnv.DOCS_COMMIT_SHA = commitSha;\n }\n if (repoUrl) {\n docusaurusEnv.DOCS_REPO_URL = repoUrl;\n }\n if (typeof argv['site-url'] === 'string' && argv['site-url'].length > 0) {\n docusaurusEnv.DOCS_URL = argv['site-url'];\n }\n if (\n typeof argv['site-base-url'] === 'string' &&\n argv['site-base-url'].length > 0\n ) {\n docusaurusEnv.DOCS_BASE_URL = argv['site-base-url'];\n }\n\n if (argv.dev) {\n console.log('\\nStarting dev server...');\n await runDocusaurus('start', resolvedOutputDir, docusaurusEnv);\n } else if (argv.build || argv.serve) {\n console.log('\\nBuilding static site...');\n await runDocusaurus('build', resolvedOutputDir, docusaurusEnv);\n\n if (argv.serve) {\n console.log('\\nServing static site...');\n await runDocusaurus('serve', resolvedOutputDir, docusaurusEnv);\n }\n }\n }\n}\n\nmain().catch((error) => {\n console.error(error);\n process.exitCode = 1;\n});\n"]}
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,QAAQ,MAAM,WAAW,CAAC;AACjC,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEzD,OAAO,EAAE,kCAAkC,EAAE,MAAM,+BAA+B,CAAC;AAoDnF;;;;;;GAMG;AACH,SAAS,iBAAiB;IACxB,OAAO,QAAQ,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;AAC1D,CAAC;AAED;;;;;;;;GAQG;AACH,KAAK,UAAU,aAAa,CAC1B,OAAe,EACf,GAAW,EACX,QAAQ,GAA2B,EAAE;IAErC,MAAM,KAAK,CAAC,iBAAiB,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE;QAC1C,GAAG;QACH,KAAK,EAAE,SAAS;QAChB,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,GAAG,QAAQ,EAAE;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AAE,CAAC;YACpC,OAAO,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC;YACzC,MAAM,aAAa,CAAC,OAAO,EAAE,iBAAiB,EAAE,aAAa,CAAC,CAAC;YAE/D,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;gBACf,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAC;gBACxC,MAAM,aAAa,CAAC,OAAO,EAAE,iBAAiB,EAAE,aAAa,CAAC,CAAC;YACjE,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACrB,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC,CAAC,CAAC","sourcesContent":["#!/usr/bin/env node\n\nimport execa from 'execa';\nimport * as fs from 'node:fs/promises';\nimport * as path from 'node:path';\nimport npmWhich from 'npm-which';\nimport yargs from 'yargs';\n\nimport { generate, resolveRepoUrl } from './generate.js';\nimport type { RootCapabilitiesTypeReference } from './root-messenger-discovery.js';\nimport { parseRootCapabilitiesTypeReference } from './root-messenger-discovery.js';\n\n/**\n * Arguments shared by both discovery strategies.\n */\ntype CommonArguments = {\n /** Whether to build the generated site. */\n build: boolean;\n /** Whether to serve the production build. */\n serve: boolean;\n /** Whether to serve the development site. */\n dev: boolean;\n /** Path to the project being documented. */\n 'project-path': string;\n /** Directory where generated documentation is written. */\n output?: string;\n /** Label displayed in the generated documentation. */\n 'project-label'?: string;\n /** URL where the generated site is served. */\n 'site-url'?: string;\n /** Base path where the generated site is served. */\n 'site-base-url'?: string;\n};\n\n/**\n * Arguments for the strategy that scans configured source directories.\n */\ntype ScanStrategyArguments = {\n /** The selected strategy. */\n strategy: 'scan';\n /** Directories, relative to the project root, to scan. */\n scanDir: string[];\n};\n\n/**\n * Arguments for the strategy that resolves a root messenger's type unions.\n */\ntype RootMessengerStrategyArguments = {\n /** The selected strategy. */\n strategy: 'root-messenger';\n /** The root messenger actions type reference. */\n rootActions: RootCapabilitiesTypeReference;\n /** The root messenger events type reference. */\n rootEvents: RootCapabilitiesTypeReference;\n};\n\n/**\n * Parsed CLI arguments, discriminated by the selected discovery strategy.\n */\ntype ParsedArguments = CommonArguments &\n (ScanStrategyArguments | RootMessengerStrategyArguments);\n\n/**\n * Locate the Docusaurus binary in this package's `node_modules/.bin`. Using\n * `npm-which` lets the lookup track wherever the installed Docusaurus puts\n * its binary, so a future Docusaurus upgrade can't break this path.\n *\n * @returns Absolute path to the `docusaurus` executable.\n */\nfunction resolveDocusaurus(): string {\n return npmWhich(import.meta.dirname).sync('docusaurus');\n}\n\n/**\n * Run a Docusaurus command.\n *\n * @param command - The docusaurus command (start, build, serve).\n * @param cwd - The site directory.\n * @param extraEnv - Extra environment variables passed through to the\n * Docusaurus process (e.g. `DOCS_PROJECT_LABEL`, `DOCS_COMMIT_SHA`,\n * `DOCS_REPO_URL`).\n */\nasync function runDocusaurus(\n command: string,\n cwd: string,\n extraEnv: Record<string, string> = {},\n): Promise<void> {\n await execa(resolveDocusaurus(), [command], {\n cwd,\n stdio: 'inherit',\n env: { ...process.env, ...extraEnv },\n });\n}\n\n/**\n * Copy site files into the output directory, skipping `node_modules`, `docs`,\n * and `tsconfig.json`. `docs` is owned by the doc generator and shouldn't be\n * carried over from the source `site/` directory. `tsconfig.json` extends the\n * monorepo's `tsconfig.base.json` via a relative path that only resolves from\n * the source location — it's there for IDE / lint inheritance, not for\n * Docusaurus, which uses `jiti` and doesn't consult the tsconfig at runtime.\n *\n * @param outDir - The output directory to set up.\n */\nasync function setupSite(outDir: string): Promise<void> {\n const packageDir = path.resolve(import.meta.dirname, '..');\n const siteDir = path.join(packageDir, 'site');\n const packageNodeModules = path.join(packageDir, 'node_modules');\n const skip = new Set(['node_modules', 'docs', 'tsconfig.json']);\n\n console.log(`\\nSetting up Docusaurus site in ${outDir}...`);\n\n await fs.cp(siteDir, outDir, {\n recursive: true,\n filter: (source) => !skip.has(path.basename(source)),\n });\n\n // Symlink this package's `node_modules` into the output so the copied\n // `docusaurus.config.ts` and the rest of Docusaurus's bundling pipeline can\n // resolve their deps the same way they do in the source tree. Without it,\n // Node's resolver walks up from the output and can't reach our nested deps\n // when the package is installed as a regular dependency by an external\n // consumer (e.g. `metamask-extension`, `metamask-mobile`).\n const linkPath = path.join(outDir, 'node_modules');\n try {\n // `'junction'` works cross-platform (POSIX ignores it; Windows uses it\n // without admin) — `'dir'` would require admin on Windows.\n await fs.symlink(packageNodeModules, linkPath, 'junction');\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== 'EEXIST') {\n throw error;\n }\n }\n\n // Write a minimal package.json so Docusaurus doesn't warn about a missing one\n const pkgJsonPath = path.join(outDir, 'package.json');\n try {\n await fs.access(pkgJsonPath);\n } catch {\n await fs.writeFile(\n pkgJsonPath,\n JSON.stringify(\n { name: 'platform-api-docs-site', private: true },\n null,\n 2,\n ),\n );\n }\n}\n\n/**\n * Resolve the short Git commit SHA the docs are being generated from.\n * Returns null when the project isn't a git repo or git isn't available.\n *\n * @param projectPath - The project root path.\n * @returns The short SHA, or null on failure.\n */\nasync function resolveCommitSha(projectPath: string): Promise<string | null> {\n try {\n const { stdout } = await execa('git', ['rev-parse', '--short', 'HEAD'], {\n cwd: projectPath,\n });\n const trimmed = stdout.trim();\n return trimmed.length > 0 ? trimmed : null;\n } catch {\n return null;\n }\n}\n\n/**\n * Reject flag combinations that don't make sense, so a mistaken invocation\n * fails instead of silently producing docs built the wrong way.\n *\n * Flags belonging to the strategy that wasn't selected are errors rather than\n * ignored. Used as a yargs `.check`, so failures print alongside usage.\n *\n * @param argv - The parsed arguments.\n * @param argv.strategy - The selected discovery strategy.\n * @param argv.rootActions - The parsed root actions type reference.\n * @param argv.rootEvents - The parsed root events type reference.\n * @param argv.scanDir - The additional directories to scan.\n * @returns True when the combination is valid.\n */\nfunction checkStrategyArgs({\n strategy,\n rootActions,\n rootEvents,\n scanDir = [],\n}: {\n strategy?: 'root-messenger' | 'scan';\n rootActions?: RootCapabilitiesTypeReference;\n rootEvents?: RootCapabilitiesTypeReference;\n scanDir?: string[];\n}): ScanStrategyArguments | RootMessengerStrategyArguments {\n if (strategy !== 'root-messenger') {\n if (rootActions !== undefined || rootEvents !== undefined) {\n throw new Error(\n '--root-actions and --root-events only apply to --strategy root-messenger.',\n );\n }\n return { strategy: 'scan', scanDir };\n }\n\n if (rootActions === undefined || rootEvents === undefined) {\n throw new Error(\n '--strategy root-messenger requires both --root-actions and --root-events, ' +\n 'each written as \"<file>#<TypeName>\".',\n );\n }\n if (scanDir.length > 0) {\n throw new Error(\n '--scan-dir only applies to --strategy scan; --strategy root-messenger reads ' +\n 'only the files named by --root-actions and --root-events.',\n );\n }\n\n return { strategy, rootActions, rootEvents };\n}\n\n/**\n * Parse and validate CLI arguments.\n *\n * @param argumentsForParsing - Arguments to parse, excluding the Node and\n * script paths.\n * @returns Parsed arguments, discriminated by discovery strategy.\n */\nasync function parseArguments(\n argumentsForParsing: string[] = process.argv.slice(2),\n): Promise<ParsedArguments> {\n const argv = await yargs(argumentsForParsing)\n .command(\n '$0 [project-path]',\n 'Produces documentation for the platform API, the set of actions and events available in clients through the message bus.',\n (yargsInstance) => {\n yargsInstance.positional('project-path', {\n type: 'string',\n description: 'Path to the project to scan',\n default: '.',\n });\n },\n )\n .option('build', {\n type: 'boolean',\n description:\n 'Generate platform API docs and build a production-ready site',\n default: false,\n })\n .option('serve', {\n type: 'boolean',\n description:\n 'Generate platform API docs and serve a production-ready site',\n default: false,\n })\n .option('dev', {\n type: 'boolean',\n description:\n 'Generate platform API docs and serve a development-only site',\n default: false,\n })\n .option('strategy', {\n type: 'string',\n description:\n 'How to find messenger actions and events. \"scan\" parses every source and declaration file looking for messenger types. \"root-messenger\" instead resolves the two types the project declares for its root messenger',\n default: 'scan',\n })\n .choices('strategy', ['scan', 'root-messenger'] as const)\n .option('root-actions', {\n type: 'string',\n coerce: parseRootCapabilitiesTypeReference,\n description:\n 'Type aliasing the union of every action on the root messenger, written as \"<file>#<TypeName>\" (required with --strategy root-messenger)',\n })\n .option('root-events', {\n type: 'string',\n coerce: parseRootCapabilitiesTypeReference,\n description:\n 'Type aliasing the union of every event on the root messenger, written as \"<file>#<TypeName>\" (required with --strategy root-messenger)',\n })\n .option('scan-dir', {\n type: 'array',\n string: true,\n description:\n 'Additional directories within the project to scan for messenger actions and events (note: may be specified multiple times)',\n default: [],\n })\n .option('output', {\n type: 'string',\n description: 'Output directory',\n })\n .option('project-label', {\n type: 'string',\n description:\n 'Short label identifying the project (e.g. \"Core\", \"Extension\") — stamped on the site title and headings',\n })\n .option('site-url', {\n type: 'string',\n description:\n 'Absolute URL the built site will be served from, e.g. https://metamask.github.io',\n })\n .option('site-base-url', {\n type: 'string',\n description:\n 'Path prefix the built site will be served under, e.g. /core/platform-api/',\n })\n .help()\n .parse();\n\n const strategyArguments = checkStrategyArgs(argv);\n\n const projectPath = argv['project-path'];\n if (typeof projectPath !== 'string') {\n throw new Error('Expected --project-path to be a string.');\n }\n\n return {\n build: argv.build,\n serve: argv.serve,\n dev: argv.dev,\n 'project-path': projectPath,\n output: argv.output,\n 'project-label': argv['project-label'],\n 'site-url': argv['site-url'],\n 'site-base-url': argv['site-base-url'],\n ...strategyArguments,\n };\n}\n\n/**\n * Main CLI entry point.\n */\nasync function main(): Promise<void> {\n const argv = await parseArguments();\n\n const resolvedProjectPath = path.resolve(argv['project-path']);\n const resolvedOutputDir = path.resolve(\n argv.output ?? path.join(resolvedProjectPath, '.platform-api-docs'),\n );\n const projectLabel =\n argv['project-label'] && argv['project-label'].length > 0\n ? argv['project-label']\n : null;\n const commitSha = await resolveCommitSha(resolvedProjectPath);\n const repoUrl = await resolveRepoUrl(resolvedProjectPath);\n\n // Step 1: Generate docs\n if (argv.strategy === 'root-messenger') {\n await generate({\n projectPath: resolvedProjectPath,\n outputDir: resolvedOutputDir,\n projectLabel,\n commitSha,\n strategy: 'root-messenger',\n rootActions: argv.rootActions,\n rootEvents: argv.rootEvents,\n });\n } else {\n const scanDirs = ['src', ...argv.scanDir].filter(\n (dir, index, dirs) => dirs.indexOf(dir) === index,\n );\n\n await generate({\n projectPath: resolvedProjectPath,\n outputDir: resolvedOutputDir,\n projectLabel,\n commitSha,\n strategy: 'scan',\n scanDirs,\n });\n }\n\n // Step 2: If --build, --serve, or --dev, set up and run Docusaurus\n if (argv.build || argv.serve || argv.dev) {\n await setupSite(resolvedOutputDir);\n\n // Translate CLI flags into the environment variables Docusaurus's\n // config reads. Keeping the CLI surface flag-only means consumers\n // (workflow files, package.json scripts) don't have to know how the\n // values are plumbed through to Docusaurus.\n const docusaurusEnv: Record<string, string> = {};\n if (projectLabel) {\n docusaurusEnv.DOCS_PROJECT_LABEL = projectLabel;\n }\n if (commitSha) {\n docusaurusEnv.DOCS_COMMIT_SHA = commitSha;\n }\n if (repoUrl) {\n docusaurusEnv.DOCS_REPO_URL = repoUrl;\n }\n if (typeof argv['site-url'] === 'string' && argv['site-url'].length > 0) {\n docusaurusEnv.DOCS_URL = argv['site-url'];\n }\n if (\n typeof argv['site-base-url'] === 'string' &&\n argv['site-base-url'].length > 0\n ) {\n docusaurusEnv.DOCS_BASE_URL = argv['site-base-url'];\n }\n\n if (argv.dev) {\n console.log('\\nStarting dev server...');\n await runDocusaurus('start', resolvedOutputDir, docusaurusEnv);\n } else if (argv.build || argv.serve) {\n console.log('\\nBuilding static site...');\n await runDocusaurus('build', resolvedOutputDir, docusaurusEnv);\n\n if (argv.serve) {\n console.log('\\nServing static site...');\n await runDocusaurus('serve', resolvedOutputDir, docusaurusEnv);\n }\n }\n }\n}\n\nmain().catch((error) => {\n console.error(error);\n process.exitCode = 1;\n});\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../src/generate.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,+BAA+B,CAAC;AAQnF;;;;GA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;IACjB,0DAA0D;IAC1D,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB,CAAC;AAEF;;;;GAIG;AACH,KAAK,4BAA4B,GAAG;IAClC,6BAA6B;IAC7B,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,iDAAiD;IACjD,WAAW,EAAE,6BAA6B,CAAC;IAC3C,gDAAgD;IAChD,UAAU,EAAE,6BAA6B,CAAC;CAC3C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,4CAA4C;IAC5C,WAAW,EAAE,MAAM,CAAC;IACpB,gEAAgE;IAChE,SAAS,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B,GAAG,CAAC,mBAAmB,GAAG,4BAA4B,CAAC,CAAC;AAEzD;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAmEF;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAClC,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAuBxB;AA+dD;;;;;GAKG;AACH,wBAAsB,QAAQ,CAC5B,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,cAAc,CAAC,CAsCzB"}
package/dist/generate.js CHANGED
@@ -26,14 +26,7 @@ function deduplicationScore(item) {
26
26
  item.sourceFile.toLowerCase().includes(namespacePrefix)
27
27
  ? 1
28
28
  : 0;
29
- // A capability declared in a package's own source is usually also visible in
30
- // the `dist` built from it, and a cross-package import resolves to that
31
- // `dist` rather than to the sibling's source. Prefer the source, which is
32
- // what an engineer can actually read and edit. Projects that only ever see
33
- // published packages score every candidate the same way, so nothing changes
34
- // for them.
35
- const sourceScore = /[\\/]dist[\\/]/u.test(item.sourceFile) ? 0 : 1;
36
- return jsDocScore + homeScore + sourceScore;
29
+ return jsDocScore + homeScore;
37
30
  }
38
31
  const execFileAsync = promisify(execFile);
39
32
  /**
@@ -241,9 +234,6 @@ async function toGlobPath(...segments) {
241
234
  async function scanSources(projectPath, sources) {
242
235
  const project = createProject();
243
236
  const sourceFiles = [];
244
- // NOTE: We are calling `addSourceFiles` for each kind of source instead of
245
- // calling it at the very end so that at each step we can make sure to exclude
246
- // `node_modules` and `dist`.
247
237
  for (const dir of sources.scanDirs) {
248
238
  const root = await toGlobPath(projectPath, dir);
249
239
  sourceFiles.push(...addSourceFiles(project, [
@@ -1 +1 @@
1
- {"version":3,"file":"generate.js","sourceRoot":"","sources":["../src/generate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAGtC,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,0CAA0C,EAAE,MAAM,+BAA+B,CAAC;AAC3F,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGhD,6EAA6E;AAC7E,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAsE7B;;;;;;GAMG;AACH,SAAS,kBAAkB,CAAC,IAA+B;IACzD,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACtC,MAAM,eAAe,GAAG,IAAI,CAAC,UAAU;SACpC,KAAK,CAA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CAAC,CAAC,CAAC,YAAY,GAAG,CACnG,CAAC;IACF,OAAO,CAAC,GAAG,CAAC,cAAc,YAAY,EAAE,CAAC,CAAC;IAC1C,OAAO,CAAC,GAAG,CAAC,aAAa,WAAW,EAAE,CAAC,CAAC;IACxC,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;IAExD,OAAO;QACL,UAAU,EAAE,UAAU,CAAC,MAAM;QAC7B,OAAO,EAAE,YAAY;QACrB,MAAM,EAAE,WAAW;KACpB,CAAC;AACJ,CAAC","sourcesContent":["import { directoryExists } from '@metamask/utils/node';\nimport { execFile } from 'node:child_process';\nimport * as fs from 'node:fs/promises';\nimport * as path from 'node:path';\nimport { promisify } from 'node:util';\nimport type { Project } from 'ts-morph';\n\nimport { extractFromSourceFile } from './extraction.js';\nimport {\n generateIndexPage,\n generateNamespacePage,\n generateSidebars,\n} from './markdown.js';\nimport type { RootCapabilitiesTypeReference } from './root-messenger-discovery.js';\nimport { discoverFromRootMessengerCapabilitiesTypes } from './root-messenger-discovery.js';\nimport { createProject } from './ts-project.js';\nimport type { MessengerCapabilityPacket, NamespaceGroup } from './types.js';\n\n/** How many skipped capability types to name before summarizing the rest. */\nconst MAX_SKIPPED_SHOWN = 10;\n\n/**\n * Options for the `scan` strategy, which reads every `*Messenger` type alias\n * in every file it can find. Used when no single messenger aggregates every\n * capability.\n */\ntype ScanStrategyOptions = {\n /** The selected strategy. */\n strategy: 'scan';\n /** Directories, relative to the project root, to scan. */\n scanDirs: string[];\n};\n\n/**\n * Options for the `root-messenger` strategy, which walks the types a\n * project declares for its root messenger capabilities instead of scanning the\n * entire repo. Used when one messenger carries every action and event.\n */\ntype RootMessengerStrategyOptions = {\n /** The selected strategy. */\n strategy: 'root-messenger';\n /** The root messenger actions type reference. */\n rootActions: RootCapabilitiesTypeReference;\n /** The root messenger events type reference. */\n rootEvents: RootCapabilitiesTypeReference;\n};\n\n/**\n * Options for the generate function.\n */\nexport type GenerateOptions = {\n /** Absolute path to the project to scan. */\n projectPath: string;\n /** Absolute path to the output directory for generated docs. */\n outputDir: string;\n /**\n * Short label identifying the project the docs were generated from (e.g.\n * \"Core\", \"Extension\"). Stamped in the index page title.\n */\n projectLabel?: string | null;\n /**\n * Git commit SHA the docs were generated from. Stamped in the index page\n * intro so engineers know how current the site is.\n */\n commitSha?: string | null;\n} & (ScanStrategyOptions | RootMessengerStrategyOptions);\n\n/**\n * Result returned by the generate function.\n */\nexport type GenerateResult = {\n namespaces: number;\n actions: number;\n events: number;\n};\n\n/**\n * The set of directories available to scan for messenger types, resolved from\n * the project's filesystem layout.\n */\ntype ScanSources = {\n /** User-configured scan dirs that exist on disk (relative to projectPath). */\n scanDirs: string[];\n /** Absolute path to `packages/` if it exists, otherwise null. */\n packagesDir: string | null;\n /** Absolute path to `node_modules/@metamask/` if it exists, otherwise null. */\n nodeModulesDir: string | null;\n};\n\n/**\n * Compute a deduplication score for a messenger item, preferring items with\n * JSDoc and from the \"home\" package whose name matches the namespace.\n *\n * @param item - The messenger item to score.\n * @returns A numeric score (higher is better).\n */\nfunction deduplicationScore(item: MessengerCapabilityPacket): number {\n const jsDocScore = item.jsDoc ? 2 : 0;\n const namespacePrefix = item.typeString\n .split(':')[0]\n .replace(/(?:Controller|Service)$/u, '')\n .toLowerCase();\n const homeScore =\n namespacePrefix.length > 0 &&\n item.sourceFile.toLowerCase().includes(namespacePrefix)\n ? 1\n : 0;\n // A capability declared in a package's own source is usually also visible in\n // the `dist` built from it, and a cross-package import resolves to that\n // `dist` rather than to the sibling's source. Prefer the source, which is\n // what an engineer can actually read and edit. Projects that only ever see\n // published packages score every candidate the same way, so nothing changes\n // for them.\n const sourceScore = /[\\\\/]dist[\\\\/]/u.test(item.sourceFile) ? 0 : 1;\n return jsDocScore + homeScore + sourceScore;\n}\n\nconst execFileAsync = promisify(execFile);\n\n/**\n * Resolve the default branch of a project's `origin` remote by reading the\n * symbolic ref `refs/remotes/origin/HEAD`. Falls back to `main` if the\n * symbolic ref isn't set (e.g. in shallow CI clones).\n *\n * @param projectPath - Absolute path to the project root.\n * @returns The default branch name (e.g. \"main\", \"master\", \"develop\").\n */\nasync function resolveDefaultBranch(projectPath: string): Promise<string> {\n try {\n const { stdout } = await execFileAsync(\n 'git',\n ['symbolic-ref', '--short', 'refs/remotes/origin/HEAD'],\n { cwd: projectPath },\n );\n // stdout looks like \"origin/main\"; strip the leading \"origin/\".\n const trimmed = stdout.trim();\n const slash = trimmed.indexOf('/');\n return slash === -1\n ? // istanbul ignore next: defensive — `symbolic-ref --short` always\n // returns `origin/<branch>` when the symbolic ref is set; this\n // fallback only matters if git's output format ever changes.\n trimmed || 'main'\n : trimmed.slice(slash + 1);\n } catch {\n return 'main';\n }\n}\n\n/**\n * Resolve the bare GitHub repository URL for a project by reading its\n * `origin` remote.\n *\n * @param projectPath - Absolute path to the project root.\n * @returns A URL like \"https://github.com/Owner/Repo\" or null when the remote\n * isn't a GitHub URL or can't be read.\n */\nexport async function resolveRepoUrl(\n projectPath: string,\n): Promise<string | null> {\n try {\n const { stdout: remoteRaw } = await execFileAsync(\n 'git',\n ['remote', 'get-url', 'origin'],\n { cwd: projectPath },\n );\n\n const remote = remoteRaw.trim();\n\n // Parse owner/repo from SSH or HTTPS remote URLs\n // Handles aliases like github.com-Org used in SSH configs\n const match = remote.match(\n /github\\.com[^:/]*[:/]([^/]+\\/[^/]+?)(?:\\.git)?$/u,\n );\n if (!match) {\n return null;\n }\n\n return `https://github.com/${match[1]}`;\n } catch {\n return null;\n }\n}\n\n/**\n * Resolve the GitHub blob base URL used for per-line source links.\n *\n * Prefers the documented commit SHA when one is available so the links point\n * at the exact revision the docs were generated from; falls back to the\n * default branch otherwise.\n *\n * @param projectPath - Absolute path to the project root.\n * @param commitSha - Optional commit SHA to use as the ref. When null, the\n * default branch is used instead.\n * @returns A base URL like \"https://github.com/Owner/Repo/blob/<ref>/\" or null.\n */\nasync function resolveRepoBaseUrl(\n projectPath: string,\n commitSha: string | null,\n): Promise<string | null> {\n const repoUrl = await resolveRepoUrl(projectPath);\n if (!repoUrl) {\n return null;\n }\n const ref = commitSha ?? (await resolveDefaultBranch(projectPath));\n return `${repoUrl}/blob/${ref}/`;\n}\n\n/**\n * Discover which configured source locations actually exist on disk.\n *\n * @param projectPath - The project root path.\n * @param scanDirs - User-configured scan directories relative to projectPath.\n * @returns A ScanSources object describing the locations to scan.\n */\nasync function discoverScanSources(\n projectPath: string,\n scanDirs: string[],\n): Promise<ScanSources> {\n const existingScanDirs: string[] = [];\n for (const dir of scanDirs) {\n if (await directoryExists(path.join(projectPath, dir))) {\n existingScanDirs.push(dir);\n }\n }\n\n const packagesDir = path.join(projectPath, 'packages');\n const nodeModulesDir = path.join(projectPath, 'node_modules', '@metamask');\n\n return {\n scanDirs: existingScanDirs,\n packagesDir: (await directoryExists(packagesDir)) ? packagesDir : null,\n nodeModulesDir: (await directoryExists(nodeModulesDir))\n ? nodeModulesDir\n : null,\n };\n}\n\n/**\n * Log a human-readable description of which source locations will be scanned.\n *\n * @param sources - The resolved scan sources.\n */\nfunction logScanPlan(sources: ScanSources): void {\n const summary: string[] = [];\n for (const dir of sources.scanDirs) {\n summary.push(`${dir}/ (.ts)`);\n }\n if (sources.packagesDir) {\n summary.push('packages/*/src (.ts)');\n }\n if (sources.nodeModulesDir) {\n summary.push('node_modules/@metamask/*/dist (.d.cts)');\n }\n console.log(\n `Scanning ${summary.join(', ')} for Messenger action/event types...`,\n );\n}\n\n/**\n * Patterns excluded when scanning TypeScript sources: build output, tests, and\n * declaration files (which are only read under `node_modules/@metamask`, via\n * the separate set below).\n *\n * Every pattern is anchored to `root` rather than written as a bare\n * `!**‍/*.test.ts`. A matcher resolves an unanchored negation against the\n * process's working directory, not against the pattern it accompanies, so an\n * unanchored exclusion silently stops excluding anything the moment the scanned\n * path falls outside the working directory — which is the normal case, since\n * this runs from wherever the consumer invoked it.\n *\n * `contentRoot` must be the directory the matched *files* live under, not an\n * ancestor of it. Anchoring at `packages/` rather than `packages/*‍/src` would\n * make the first path segment a package name, so a workspace package called\n * `test` or `dist` would match `test/**` and be dropped whole.\n *\n * @param contentRoot - Resolved directory, or directory glob, that the matched\n * files live directly under.\n * @returns The exclusion patterns.\n */\nfunction buildTsSourceExclusions(contentRoot: string): string[] {\n return [\n 'node_modules/**',\n 'dist/**',\n '__tests__/**',\n 'tests/**',\n 'test/**',\n '__mocks__/**',\n '*.test.ts',\n '*.test-d.ts',\n '*.spec.ts',\n '*.d.ts',\n ].map((pattern) => `!${contentRoot}/**/${pattern}`);\n}\n\n/**\n * Add every file matching a set of glob patterns to the project, in a stable\n * order.\n *\n * ts-morph promises nothing about the order it returns matches in, and\n * deduplication downstream keeps the first of two equally-scored items, so an\n * unsorted list would let the filesystem decide which source link a capability\n * gets.\n *\n * Ordering is by code unit rather than `localeCompare`, which collates\n * differently depending on the locale the process happens to run under.\n *\n * @param project - The shared ts-morph project.\n * @param patterns - Glob patterns to match, including `!` exclusions.\n * @returns The added source files, sorted by path.\n */\nfunction addSourceFiles(\n project: Project,\n patterns: string[],\n): ReturnType<Project['addSourceFilesAtPaths']> {\n return project.addSourceFilesAtPaths(patterns).sort(\n (fileA, fileB) =>\n // Subtracting the two comparisons keeps this branchless, so it reads\n // the same whichever order the matcher happened to return.\n Number(fileA.getFilePath() > fileB.getFilePath()) -\n Number(fileA.getFilePath() < fileB.getFilePath()),\n );\n}\n\n/**\n * Build a glob pattern from a directory path.\n *\n * Two things have to be true of the result. Glob syntax is always\n * forward-slashed, including on Windows, where `path.join` would produce\n * backslashes that a matcher reads as escapes. And the path must be fully\n * resolved: the matcher does not follow a symlinked *ancestor* of the pattern,\n * so a project under `/tmp` or `/var` on macOS (both symlinks) would match\n * nothing at all.\n *\n * @param segments - Path segments to join.\n * @returns The joined, resolved path with forward slashes.\n */\nasync function toGlobPath(...segments: string[]): Promise<string> {\n // Safe to resolve without a fallback: `discoverScanSources` has already\n // confirmed every directory reaching this point exists.\n const resolved = await fs.realpath(path.join(...segments));\n return resolved.replace(/\\\\/gu, '/');\n}\n\n/**\n * Scan every source location described by `sources` (scan directories first,\n * then workspace packages, then published declaration files) and return all\n * extracted messenger items.\n *\n * A single ts-morph Project is shared across every file so the type checker can\n * resolve cross-file references (e.g. a `*Messenger` declaration in one file\n * walking through an imported umbrella union into an auto-generated\n * `*-method-action-types.ts` sibling).\n *\n * @param projectPath - The project root path.\n * @param sources - The set of source locations to scan.\n * @returns A flat list of all extracted messenger items.\n */\nasync function scanSources(\n projectPath: string,\n sources: ScanSources,\n): Promise<MessengerCapabilityPacket[]> {\n const project = createProject();\n const sourceFiles = [];\n\n // NOTE: We are calling `addSourceFiles` for each kind of source instead of\n // calling it at the very end so that at each step we can make sure to exclude\n // `node_modules` and `dist`.\n for (const dir of sources.scanDirs) {\n const root = await toGlobPath(projectPath, dir);\n sourceFiles.push(\n ...addSourceFiles(project, [\n `${root}/**/*.ts`,\n ...buildTsSourceExclusions(root),\n ]),\n );\n }\n\n if (sources.packagesDir) {\n const root = await toGlobPath(sources.packagesDir);\n // Anchored at each package's `src`, not at `packages` itself, so a package\n // whose name collides with an exclusion (`test`, `dist`) isn't dropped.\n const contentRoot = `${root}/*/src`;\n sourceFiles.push(\n ...addSourceFiles(project, [\n `${contentRoot}/**/*.ts`,\n ...buildTsSourceExclusions(contentRoot),\n ]),\n );\n }\n\n if (sources.nodeModulesDir) {\n const root = await toGlobPath(sources.nodeModulesDir);\n sourceFiles.push(...addSourceFiles(project, [`${root}/*/dist/**/*.d.cts`]));\n }\n\n // Matched paths are fully resolved, so the root they are made relative to\n // has to be resolved the same way or every source link becomes a `../..`\n // walk out of the project.\n const resolvedProjectPath = await fs.realpath(projectPath);\n\n const allItems: MessengerCapabilityPacket[] = [];\n for (const sourceFile of sourceFiles) {\n allItems.push(...extractFromSourceFile(sourceFile, resolvedProjectPath));\n }\n return allItems;\n}\n\n/**\n * Replace a previously-seen item in its existing namespace group with a\n * higher-scoring duplicate. Handles the case where the duplicate is a\n * different kind (action vs event) by moving it between lists.\n *\n * @param byNamespace - Map of namespace to its group.\n * @param previous - The previously stored item.\n * @param replacement - The new item to replace it with.\n */\nfunction replaceDuplicateInGroup(\n byNamespace: Map<string, NamespaceGroup>,\n previous: MessengerCapabilityPacket,\n replacement: MessengerCapabilityPacket,\n): void {\n const namespace = replacement.typeString.split(':')[0];\n const group = byNamespace.get(namespace);\n // istanbul ignore next: `previous` and `replacement` have the same\n // typeString, so they share a namespace, and we always insert the\n // namespace into `byNamespace` before recording the original entry.\n if (!group) {\n return;\n }\n const previousList =\n previous.kind === 'action' ? group.actions : group.events;\n const index = previousList.indexOf(previous);\n // istanbul ignore next: `previous` was added to its kind's list by\n // `groupByNamespace` before being recorded in `seen`, so it is always\n // present when we look it up here.\n if (index === -1) {\n return;\n }\n if (previous.kind === replacement.kind) {\n previousList[index] = replacement;\n } else {\n previousList.splice(index, 1);\n const newList =\n replacement.kind === 'action' ? group.actions : group.events;\n newList.push(replacement);\n }\n}\n\n/**\n * Group items by namespace, deduplicating duplicate typeStrings using\n * `deduplicationScore`. Returns groups sorted alphabetically by namespace,\n * with each group's items sorted alphabetically by typeString.\n *\n * @param items - The full list of extracted items.\n * @returns The deduplicated and sorted namespace groups.\n */\nfunction groupByNamespace(\n items: MessengerCapabilityPacket[],\n): NamespaceGroup[] {\n const byNamespace = new Map<string, NamespaceGroup>();\n const seen = new Map<string, MessengerCapabilityPacket>();\n\n for (const item of items) {\n const existing = seen.get(item.typeString);\n if (existing) {\n if (deduplicationScore(item) <= deduplicationScore(existing)) {\n continue;\n }\n replaceDuplicateInGroup(byNamespace, existing, item);\n seen.set(item.typeString, item);\n continue;\n }\n\n seen.set(item.typeString, item);\n const namespace = item.typeString.split(':')[0];\n let group = byNamespace.get(namespace);\n if (!group) {\n group = { namespace, actions: [], events: [] };\n byNamespace.set(namespace, group);\n }\n if (item.kind === 'action') {\n group.actions.push(item);\n } else {\n group.events.push(item);\n }\n }\n\n const namespaces = Array.from(byNamespace.values()).sort((a, b) =>\n a.namespace.localeCompare(b.namespace),\n );\n\n for (const ns of namespaces) {\n ns.actions.sort((a, b) => a.typeString.localeCompare(b.typeString));\n ns.events.sort((a, b) => a.typeString.localeCompare(b.typeString));\n }\n\n return namespaces;\n}\n\n/**\n * Write generated docs (namespace pages, index page, sidebars) to disk,\n * replacing any existing `docs/` directory.\n *\n * @param namespaces - The grouped namespaces to render.\n * @param outputDir - The root output directory.\n * @param repoBaseUrl - GitHub blob base URL for source links, or null.\n * @param indexOptions - Options stamped on the index page header.\n * @param indexOptions.projectLabel - Short label identifying the project.\n * @param indexOptions.commitSha - Git commit SHA the docs were generated from.\n * @returns Promise that resolves once all files are written.\n */\nasync function writeOutput(\n namespaces: NamespaceGroup[],\n outputDir: string,\n repoBaseUrl: string | null,\n indexOptions: {\n projectLabel?: string | null;\n commitSha?: string | null;\n },\n): Promise<void> {\n const docsDir = path.join(outputDir, 'docs');\n\n if (await directoryExists(docsDir)) {\n await fs.rm(docsDir, { recursive: true });\n }\n await fs.mkdir(docsDir, { recursive: true });\n\n for (const ns of namespaces) {\n const nsDir = path.join(docsDir, ns.namespace);\n await fs.mkdir(nsDir, { recursive: true });\n\n if (ns.actions.length > 0) {\n await fs.writeFile(\n path.join(nsDir, 'actions.md'),\n generateNamespacePage(ns, 'action', repoBaseUrl),\n );\n }\n\n if (ns.events.length > 0) {\n await fs.writeFile(\n path.join(nsDir, 'events.md'),\n generateNamespacePage(ns, 'event', repoBaseUrl),\n );\n }\n }\n\n await fs.writeFile(\n path.join(docsDir, 'index.md'),\n generateIndexPage(namespaces, indexOptions),\n );\n\n await fs.writeFile(\n path.join(outputDir, 'sidebars.ts'),\n generateSidebars(namespaces),\n );\n}\n\n/**\n * Collect capabilities by scanning the project's files.\n *\n * @param projectPath - The project root path.\n * @param scanDirs - Directories (relative to projectPath) to scan.\n * @returns The extracted capabilities.\n * @throws If the project has no scannable directories at all.\n */\nasync function collectByScanning(\n projectPath: string,\n scanDirs: string[],\n): Promise<MessengerCapabilityPacket[]> {\n const sources = await discoverScanSources(projectPath, scanDirs);\n\n if (\n sources.scanDirs.length === 0 &&\n !sources.packagesDir &&\n !sources.nodeModulesDir\n ) {\n throw new Error(\n `No scannable directories found in ${projectPath}. ` +\n `Looked for: ${scanDirs.join(', ')}, packages/, node_modules/@metamask/`,\n );\n }\n\n logScanPlan(sources);\n\n return await scanSources(projectPath, sources);\n}\n\n/**\n * Using the project's root messenger capability collection types as\n * entrypoints, collect the constituent individual capability types and package\n * them so that they can be displayed within the documentation site.\n *\n * @param projectPath - The project root path.\n * @param options - The root-messenger strategy options.\n * @returns The extracted capabilities.\n */\nfunction collectFromRootMessengerCapabilities(\n projectPath: string,\n options: RootMessengerStrategyOptions,\n): MessengerCapabilityPacket[] {\n const { rootActions, rootEvents } = options;\n\n console.log(\n `Resolving actions from ${rootActions.filePath}#${rootActions.typeName} ` +\n `and events from ${rootEvents.filePath}#${rootEvents.typeName}...`,\n );\n\n const { capabilityPackets, skippedCapabilities } =\n discoverFromRootMessengerCapabilitiesTypes({\n projectPath,\n rootActionsTypeReference: rootActions,\n rootEventsTypeReference: rootEvents,\n });\n\n // Report rather than drop silently: a jump in any of these usually means the\n // project changed how it declares its capabilities.\n warnSkipped(\n 'declared inline, with no name to document',\n skippedCapabilities.unnamedCapabilities,\n );\n warnSkipped(\n 'whose shape could not be read',\n skippedCapabilities.unextractableCapabilities,\n );\n\n // If both capability collection types resolve to nothing, it's always a\n // misconfiguration (a wrong type name, or imports that didn't resolve).\n // Failing here matters because generation would otherwise replace an existing\n // docs directory with an empty one and exit successfully.\n if (capabilityPackets.length === 0) {\n throw new Error(\n `No messenger actions or events found in ` +\n `${rootActions.filePath}#${rootActions.typeName} or ` +\n `${rootEvents.filePath}#${rootEvents.typeName}. ` +\n `Check that these types name the collections carrying every ` +\n `capability, and that their imports resolve.`,\n );\n }\n\n return capabilityPackets;\n}\n\n/**\n * Warn about capability types that couldn't be documented, naming them so the\n * warning is actionable.\n *\n * @param description - Why they were skipped, as a noun phrase.\n * @param labels - Labels identifying each skipped type.\n */\nfunction warnSkipped(description: string, labels: string[]): void {\n if (labels.length === 0) {\n return;\n }\n\n const shown = labels.slice(0, MAX_SKIPPED_SHOWN);\n const remaining = labels.length - shown.length;\n console.warn(\n `Warning: skipped ${labels.length} capability ` +\n `${labels.length === 1 ? 'type' : 'types'} ${description}: ` +\n `${shown.join(', ')}${remaining > 0 ? `, and ${remaining} more` : ''}`,\n );\n}\n\n/**\n * Scan a project for messenger action/event types and generate documentation.\n *\n * @param options - Generation options.\n * @returns A promise resolving to counts of generated namespaces, actions, and events.\n */\nexport async function generate(\n options: GenerateOptions,\n): Promise<GenerateResult> {\n const { projectPath, outputDir, projectLabel, commitSha } = options;\n\n const allItems =\n options.strategy === 'root-messenger'\n ? collectFromRootMessengerCapabilities(projectPath, options)\n : await collectByScanning(projectPath, options.scanDirs);\n\n console.log(\n `Found ${allItems.length} messenger ${allItems.length === 1 ? 'item' : 'items'} total.`,\n );\n\n const namespaces = groupByNamespace(allItems);\n const repoBaseUrl = await resolveRepoBaseUrl(projectPath, commitSha ?? null);\n\n await writeOutput(namespaces, outputDir, repoBaseUrl, {\n projectLabel,\n commitSha,\n });\n\n const totalActions = namespaces.reduce(\n (sum, ns) => sum + ns.actions.length,\n 0,\n );\n const totalEvents = namespaces.reduce((sum, ns) => sum + ns.events.length, 0);\n\n console.log(\n `Generated docs for ${namespaces.length} ${namespaces.length === 1 ? 'namespace' : 'namespaces'}.`,\n );\n console.log(` Actions: ${totalActions}`);\n console.log(` Events: ${totalEvents}`);\n console.log(`Output: ${path.join(outputDir, 'docs')}/`);\n\n return {\n namespaces: namespaces.length,\n actions: totalActions,\n events: totalEvents,\n };\n}\n"]}
1
+ {"version":3,"file":"generate.js","sourceRoot":"","sources":["../src/generate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,QAA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AM,CACpC,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,EACpC,CAAC,CACF,CAAC;IACF,MAAM,WAAW,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IAE9E,OAAO,CAAC,GAAG,CACT,sBAAsB,UAAU,CAAC,MAAM,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,YAAY,GAAG,CACnG,CAAC;IACF,OAAO,CAAC,GAAG,CAAC,cAAc,YAAY,EAAE,CAAC,CAAC;IAC1C,OAAO,CAAC,GAAG,CAAC,aAAa,WAAW,EAAE,CAAC,CAAC;IACxC,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;IAExD,OAAO;QACL,UAAU,EAAE,UAAU,CAAC,MAAM;QAC7B,OAAO,EAAE,YAAY;QACrB,MAAM,EAAE,WAAW;KACpB,CAAC;AACJ,CAAC","sourcesContent":["import { directoryExists } from '@metamask/utils/node';\nimport { execFile } from 'node:child_process';\nimport * as fs from 'node:fs/promises';\nimport * as path from 'node:path';\nimport { promisify } from 'node:util';\nimport type { Project } from 'ts-morph';\n\nimport { extractFromSourceFile } from './extraction.js';\nimport {\n generateIndexPage,\n generateNamespacePage,\n generateSidebars,\n} from './markdown.js';\nimport type { RootCapabilitiesTypeReference } from './root-messenger-discovery.js';\nimport { discoverFromRootMessengerCapabilitiesTypes } from './root-messenger-discovery.js';\nimport { createProject } from './ts-project.js';\nimport type { MessengerCapabilityPacket, NamespaceGroup } from './types.js';\n\n/** How many skipped capability types to name before summarizing the rest. */\nconst MAX_SKIPPED_SHOWN = 10;\n\n/**\n * Options for the `scan` strategy, which reads every `*Messenger` type alias\n * in every file it can find. Used when no single messenger aggregates every\n * capability.\n */\ntype ScanStrategyOptions = {\n /** The selected strategy. */\n strategy: 'scan';\n /** Directories, relative to the project root, to scan. */\n scanDirs: string[];\n};\n\n/**\n * Options for the `root-messenger` strategy, which walks the types a\n * project declares for its root messenger capabilities instead of scanning the\n * entire repo. Used when one messenger carries every action and event.\n */\ntype RootMessengerStrategyOptions = {\n /** The selected strategy. */\n strategy: 'root-messenger';\n /** The root messenger actions type reference. */\n rootActions: RootCapabilitiesTypeReference;\n /** The root messenger events type reference. */\n rootEvents: RootCapabilitiesTypeReference;\n};\n\n/**\n * Options for the generate function.\n */\nexport type GenerateOptions = {\n /** Absolute path to the project to scan. */\n projectPath: string;\n /** Absolute path to the output directory for generated docs. */\n outputDir: string;\n /**\n * Short label identifying the project the docs were generated from (e.g.\n * \"Core\", \"Extension\"). Stamped in the index page title.\n */\n projectLabel?: string | null;\n /**\n * Git commit SHA the docs were generated from. Stamped in the index page\n * intro so engineers know how current the site is.\n */\n commitSha?: string | null;\n} & (ScanStrategyOptions | RootMessengerStrategyOptions);\n\n/**\n * Result returned by the generate function.\n */\nexport type GenerateResult = {\n namespaces: number;\n actions: number;\n events: number;\n};\n\n/**\n * The set of directories available to scan for messenger types, resolved from\n * the project's filesystem layout.\n */\ntype ScanSources = {\n /** User-configured scan dirs that exist on disk (relative to projectPath). */\n scanDirs: string[];\n /** Absolute path to `packages/` if it exists, otherwise null. */\n packagesDir: string | null;\n /** Absolute path to `node_modules/@metamask/` if it exists, otherwise null. */\n nodeModulesDir: string | null;\n};\n\n/**\n * Compute a deduplication score for a messenger item, preferring items with\n * JSDoc and from the \"home\" package whose name matches the namespace.\n *\n * @param item - The messenger item to score.\n * @returns A numeric score (higher is better).\n */\nfunction deduplicationScore(item: MessengerCapabilityPacket): number {\n const jsDocScore = item.jsDoc ? 2 : 0;\n const namespacePrefix = item.typeString\n .split(':')[0]\n .replace(/(?:Controller|Service)$/u, '')\n .toLowerCase();\n const homeScore =\n namespacePrefix.length > 0 &&\n item.sourceFile.toLowerCase().includes(namespacePrefix)\n ? 1\n : 0;\n return jsDocScore + homeScore;\n}\n\nconst execFileAsync = promisify(execFile);\n\n/**\n * Resolve the default branch of a project's `origin` remote by reading the\n * symbolic ref `refs/remotes/origin/HEAD`. Falls back to `main` if the\n * symbolic ref isn't set (e.g. in shallow CI clones).\n *\n * @param projectPath - Absolute path to the project root.\n * @returns The default branch name (e.g. \"main\", \"master\", \"develop\").\n */\nasync function resolveDefaultBranch(projectPath: string): Promise<string> {\n try {\n const { stdout } = await execFileAsync(\n 'git',\n ['symbolic-ref', '--short', 'refs/remotes/origin/HEAD'],\n { cwd: projectPath },\n );\n // stdout looks like \"origin/main\"; strip the leading \"origin/\".\n const trimmed = stdout.trim();\n const slash = trimmed.indexOf('/');\n return slash === -1\n ? // istanbul ignore next: defensive — `symbolic-ref --short` always\n // returns `origin/<branch>` when the symbolic ref is set; this\n // fallback only matters if git's output format ever changes.\n trimmed || 'main'\n : trimmed.slice(slash + 1);\n } catch {\n return 'main';\n }\n}\n\n/**\n * Resolve the bare GitHub repository URL for a project by reading its\n * `origin` remote.\n *\n * @param projectPath - Absolute path to the project root.\n * @returns A URL like \"https://github.com/Owner/Repo\" or null when the remote\n * isn't a GitHub URL or can't be read.\n */\nexport async function resolveRepoUrl(\n projectPath: string,\n): Promise<string | null> {\n try {\n const { stdout: remoteRaw } = await execFileAsync(\n 'git',\n ['remote', 'get-url', 'origin'],\n { cwd: projectPath },\n );\n\n const remote = remoteRaw.trim();\n\n // Parse owner/repo from SSH or HTTPS remote URLs\n // Handles aliases like github.com-Org used in SSH configs\n const match = remote.match(\n /github\\.com[^:/]*[:/]([^/]+\\/[^/]+?)(?:\\.git)?$/u,\n );\n if (!match) {\n return null;\n }\n\n return `https://github.com/${match[1]}`;\n } catch {\n return null;\n }\n}\n\n/**\n * Resolve the GitHub blob base URL used for per-line source links.\n *\n * Prefers the documented commit SHA when one is available so the links point\n * at the exact revision the docs were generated from; falls back to the\n * default branch otherwise.\n *\n * @param projectPath - Absolute path to the project root.\n * @param commitSha - Optional commit SHA to use as the ref. When null, the\n * default branch is used instead.\n * @returns A base URL like \"https://github.com/Owner/Repo/blob/<ref>/\" or null.\n */\nasync function resolveRepoBaseUrl(\n projectPath: string,\n commitSha: string | null,\n): Promise<string | null> {\n const repoUrl = await resolveRepoUrl(projectPath);\n if (!repoUrl) {\n return null;\n }\n const ref = commitSha ?? (await resolveDefaultBranch(projectPath));\n return `${repoUrl}/blob/${ref}/`;\n}\n\n/**\n * Discover which configured source locations actually exist on disk.\n *\n * @param projectPath - The project root path.\n * @param scanDirs - User-configured scan directories relative to projectPath.\n * @returns A ScanSources object describing the locations to scan.\n */\nasync function discoverScanSources(\n projectPath: string,\n scanDirs: string[],\n): Promise<ScanSources> {\n const existingScanDirs: string[] = [];\n for (const dir of scanDirs) {\n if (await directoryExists(path.join(projectPath, dir))) {\n existingScanDirs.push(dir);\n }\n }\n\n const packagesDir = path.join(projectPath, 'packages');\n const nodeModulesDir = path.join(projectPath, 'node_modules', '@metamask');\n\n return {\n scanDirs: existingScanDirs,\n packagesDir: (await directoryExists(packagesDir)) ? packagesDir : null,\n nodeModulesDir: (await directoryExists(nodeModulesDir))\n ? nodeModulesDir\n : null,\n };\n}\n\n/**\n * Log a human-readable description of which source locations will be scanned.\n *\n * @param sources - The resolved scan sources.\n */\nfunction logScanPlan(sources: ScanSources): void {\n const summary: string[] = [];\n for (const dir of sources.scanDirs) {\n summary.push(`${dir}/ (.ts)`);\n }\n if (sources.packagesDir) {\n summary.push('packages/*/src (.ts)');\n }\n if (sources.nodeModulesDir) {\n summary.push('node_modules/@metamask/*/dist (.d.cts)');\n }\n console.log(\n `Scanning ${summary.join(', ')} for Messenger action/event types...`,\n );\n}\n\n/**\n * Patterns excluded when scanning TypeScript sources: build output, tests, and\n * declaration files (which are only read under `node_modules/@metamask`, via\n * the separate set below).\n *\n * Every pattern is anchored to `root` rather than written as a bare\n * `!**‍/*.test.ts`. A matcher resolves an unanchored negation against the\n * process's working directory, not against the pattern it accompanies, so an\n * unanchored exclusion silently stops excluding anything the moment the scanned\n * path falls outside the working directory — which is the normal case, since\n * this runs from wherever the consumer invoked it.\n *\n * `contentRoot` must be the directory the matched *files* live under, not an\n * ancestor of it. Anchoring at `packages/` rather than `packages/*‍/src` would\n * make the first path segment a package name, so a workspace package called\n * `test` or `dist` would match `test/**` and be dropped whole.\n *\n * @param contentRoot - Resolved directory, or directory glob, that the matched\n * files live directly under.\n * @returns The exclusion patterns.\n */\nfunction buildTsSourceExclusions(contentRoot: string): string[] {\n return [\n 'node_modules/**',\n 'dist/**',\n '__tests__/**',\n 'tests/**',\n 'test/**',\n '__mocks__/**',\n '*.test.ts',\n '*.test-d.ts',\n '*.spec.ts',\n '*.d.ts',\n ].map((pattern) => `!${contentRoot}/**/${pattern}`);\n}\n\n/**\n * Add every file matching a set of glob patterns to the project, in a stable\n * order.\n *\n * ts-morph promises nothing about the order it returns matches in, and\n * deduplication downstream keeps the first of two equally-scored items, so an\n * unsorted list would let the filesystem decide which source link a capability\n * gets.\n *\n * Ordering is by code unit rather than `localeCompare`, which collates\n * differently depending on the locale the process happens to run under.\n *\n * @param project - The shared ts-morph project.\n * @param patterns - Glob patterns to match, including `!` exclusions.\n * @returns The added source files, sorted by path.\n */\nfunction addSourceFiles(\n project: Project,\n patterns: string[],\n): ReturnType<Project['addSourceFilesAtPaths']> {\n return project.addSourceFilesAtPaths(patterns).sort(\n (fileA, fileB) =>\n // Subtracting the two comparisons keeps this branchless, so it reads\n // the same whichever order the matcher happened to return.\n Number(fileA.getFilePath() > fileB.getFilePath()) -\n Number(fileA.getFilePath() < fileB.getFilePath()),\n );\n}\n\n/**\n * Build a glob pattern from a directory path.\n *\n * Two things have to be true of the result. Glob syntax is always\n * forward-slashed, including on Windows, where `path.join` would produce\n * backslashes that a matcher reads as escapes. And the path must be fully\n * resolved: the matcher does not follow a symlinked *ancestor* of the pattern,\n * so a project under `/tmp` or `/var` on macOS (both symlinks) would match\n * nothing at all.\n *\n * @param segments - Path segments to join.\n * @returns The joined, resolved path with forward slashes.\n */\nasync function toGlobPath(...segments: string[]): Promise<string> {\n // Safe to resolve without a fallback: `discoverScanSources` has already\n // confirmed every directory reaching this point exists.\n const resolved = await fs.realpath(path.join(...segments));\n return resolved.replace(/\\\\/gu, '/');\n}\n\n/**\n * Scan every source location described by `sources` (scan directories first,\n * then workspace packages, then published declaration files) and return all\n * extracted messenger items.\n *\n * A single ts-morph Project is shared across every file so the type checker can\n * resolve cross-file references (e.g. a `*Messenger` declaration in one file\n * walking through an imported umbrella union into an auto-generated\n * `*-method-action-types.ts` sibling).\n *\n * @param projectPath - The project root path.\n * @param sources - The set of source locations to scan.\n * @returns A flat list of all extracted messenger items.\n */\nasync function scanSources(\n projectPath: string,\n sources: ScanSources,\n): Promise<MessengerCapabilityPacket[]> {\n const project = createProject();\n const sourceFiles = [];\n\n for (const dir of sources.scanDirs) {\n const root = await toGlobPath(projectPath, dir);\n sourceFiles.push(\n ...addSourceFiles(project, [\n `${root}/**/*.ts`,\n ...buildTsSourceExclusions(root),\n ]),\n );\n }\n\n if (sources.packagesDir) {\n const root = await toGlobPath(sources.packagesDir);\n // Anchored at each package's `src`, not at `packages` itself, so a package\n // whose name collides with an exclusion (`test`, `dist`) isn't dropped.\n const contentRoot = `${root}/*/src`;\n sourceFiles.push(\n ...addSourceFiles(project, [\n `${contentRoot}/**/*.ts`,\n ...buildTsSourceExclusions(contentRoot),\n ]),\n );\n }\n\n if (sources.nodeModulesDir) {\n const root = await toGlobPath(sources.nodeModulesDir);\n sourceFiles.push(...addSourceFiles(project, [`${root}/*/dist/**/*.d.cts`]));\n }\n\n // Matched paths are fully resolved, so the root they are made relative to\n // has to be resolved the same way or every source link becomes a `../..`\n // walk out of the project.\n const resolvedProjectPath = await fs.realpath(projectPath);\n\n const allItems: MessengerCapabilityPacket[] = [];\n for (const sourceFile of sourceFiles) {\n allItems.push(...extractFromSourceFile(sourceFile, resolvedProjectPath));\n }\n return allItems;\n}\n\n/**\n * Replace a previously-seen item in its existing namespace group with a\n * higher-scoring duplicate. Handles the case where the duplicate is a\n * different kind (action vs event) by moving it between lists.\n *\n * @param byNamespace - Map of namespace to its group.\n * @param previous - The previously stored item.\n * @param replacement - The new item to replace it with.\n */\nfunction replaceDuplicateInGroup(\n byNamespace: Map<string, NamespaceGroup>,\n previous: MessengerCapabilityPacket,\n replacement: MessengerCapabilityPacket,\n): void {\n const namespace = replacement.typeString.split(':')[0];\n const group = byNamespace.get(namespace);\n // istanbul ignore next: `previous` and `replacement` have the same\n // typeString, so they share a namespace, and we always insert the\n // namespace into `byNamespace` before recording the original entry.\n if (!group) {\n return;\n }\n const previousList =\n previous.kind === 'action' ? group.actions : group.events;\n const index = previousList.indexOf(previous);\n // istanbul ignore next: `previous` was added to its kind's list by\n // `groupByNamespace` before being recorded in `seen`, so it is always\n // present when we look it up here.\n if (index === -1) {\n return;\n }\n if (previous.kind === replacement.kind) {\n previousList[index] = replacement;\n } else {\n previousList.splice(index, 1);\n const newList =\n replacement.kind === 'action' ? group.actions : group.events;\n newList.push(replacement);\n }\n}\n\n/**\n * Group items by namespace, deduplicating duplicate typeStrings using\n * `deduplicationScore`. Returns groups sorted alphabetically by namespace,\n * with each group's items sorted alphabetically by typeString.\n *\n * @param items - The full list of extracted items.\n * @returns The deduplicated and sorted namespace groups.\n */\nfunction groupByNamespace(\n items: MessengerCapabilityPacket[],\n): NamespaceGroup[] {\n const byNamespace = new Map<string, NamespaceGroup>();\n const seen = new Map<string, MessengerCapabilityPacket>();\n\n for (const item of items) {\n const existing = seen.get(item.typeString);\n if (existing) {\n if (deduplicationScore(item) <= deduplicationScore(existing)) {\n continue;\n }\n replaceDuplicateInGroup(byNamespace, existing, item);\n seen.set(item.typeString, item);\n continue;\n }\n\n seen.set(item.typeString, item);\n const namespace = item.typeString.split(':')[0];\n let group = byNamespace.get(namespace);\n if (!group) {\n group = { namespace, actions: [], events: [] };\n byNamespace.set(namespace, group);\n }\n if (item.kind === 'action') {\n group.actions.push(item);\n } else {\n group.events.push(item);\n }\n }\n\n const namespaces = Array.from(byNamespace.values()).sort((a, b) =>\n a.namespace.localeCompare(b.namespace),\n );\n\n for (const ns of namespaces) {\n ns.actions.sort((a, b) => a.typeString.localeCompare(b.typeString));\n ns.events.sort((a, b) => a.typeString.localeCompare(b.typeString));\n }\n\n return namespaces;\n}\n\n/**\n * Write generated docs (namespace pages, index page, sidebars) to disk,\n * replacing any existing `docs/` directory.\n *\n * @param namespaces - The grouped namespaces to render.\n * @param outputDir - The root output directory.\n * @param repoBaseUrl - GitHub blob base URL for source links, or null.\n * @param indexOptions - Options stamped on the index page header.\n * @param indexOptions.projectLabel - Short label identifying the project.\n * @param indexOptions.commitSha - Git commit SHA the docs were generated from.\n * @returns Promise that resolves once all files are written.\n */\nasync function writeOutput(\n namespaces: NamespaceGroup[],\n outputDir: string,\n repoBaseUrl: string | null,\n indexOptions: {\n projectLabel?: string | null;\n commitSha?: string | null;\n },\n): Promise<void> {\n const docsDir = path.join(outputDir, 'docs');\n\n if (await directoryExists(docsDir)) {\n await fs.rm(docsDir, { recursive: true });\n }\n await fs.mkdir(docsDir, { recursive: true });\n\n for (const ns of namespaces) {\n const nsDir = path.join(docsDir, ns.namespace);\n await fs.mkdir(nsDir, { recursive: true });\n\n if (ns.actions.length > 0) {\n await fs.writeFile(\n path.join(nsDir, 'actions.md'),\n generateNamespacePage(ns, 'action', repoBaseUrl),\n );\n }\n\n if (ns.events.length > 0) {\n await fs.writeFile(\n path.join(nsDir, 'events.md'),\n generateNamespacePage(ns, 'event', repoBaseUrl),\n );\n }\n }\n\n await fs.writeFile(\n path.join(docsDir, 'index.md'),\n generateIndexPage(namespaces, indexOptions),\n );\n\n await fs.writeFile(\n path.join(outputDir, 'sidebars.ts'),\n generateSidebars(namespaces),\n );\n}\n\n/**\n * Collect capabilities by scanning the project's files.\n *\n * @param projectPath - The project root path.\n * @param scanDirs - Directories (relative to projectPath) to scan.\n * @returns The extracted capabilities.\n * @throws If the project has no scannable directories at all.\n */\nasync function collectByScanning(\n projectPath: string,\n scanDirs: string[],\n): Promise<MessengerCapabilityPacket[]> {\n const sources = await discoverScanSources(projectPath, scanDirs);\n\n if (\n sources.scanDirs.length === 0 &&\n !sources.packagesDir &&\n !sources.nodeModulesDir\n ) {\n throw new Error(\n `No scannable directories found in ${projectPath}. ` +\n `Looked for: ${scanDirs.join(', ')}, packages/, node_modules/@metamask/`,\n );\n }\n\n logScanPlan(sources);\n\n return await scanSources(projectPath, sources);\n}\n\n/**\n * Using the project's root messenger capability collection types as\n * entrypoints, collect the constituent individual capability types and package\n * them so that they can be displayed within the documentation site.\n *\n * @param projectPath - The project root path.\n * @param options - The root-messenger strategy options.\n * @returns The extracted capabilities.\n */\nfunction collectFromRootMessengerCapabilities(\n projectPath: string,\n options: RootMessengerStrategyOptions,\n): MessengerCapabilityPacket[] {\n const { rootActions, rootEvents } = options;\n\n console.log(\n `Resolving actions from ${rootActions.filePath}#${rootActions.typeName} ` +\n `and events from ${rootEvents.filePath}#${rootEvents.typeName}...`,\n );\n\n const { capabilityPackets, skippedCapabilities } =\n discoverFromRootMessengerCapabilitiesTypes({\n projectPath,\n rootActionsTypeReference: rootActions,\n rootEventsTypeReference: rootEvents,\n });\n\n // Report rather than drop silently: a jump in any of these usually means the\n // project changed how it declares its capabilities.\n warnSkipped(\n 'declared inline, with no name to document',\n skippedCapabilities.unnamedCapabilities,\n );\n warnSkipped(\n 'whose shape could not be read',\n skippedCapabilities.unextractableCapabilities,\n );\n\n // If both capability collection types resolve to nothing, it's always a\n // misconfiguration (a wrong type name, or imports that didn't resolve).\n // Failing here matters because generation would otherwise replace an existing\n // docs directory with an empty one and exit successfully.\n if (capabilityPackets.length === 0) {\n throw new Error(\n `No messenger actions or events found in ` +\n `${rootActions.filePath}#${rootActions.typeName} or ` +\n `${rootEvents.filePath}#${rootEvents.typeName}. ` +\n `Check that these types name the collections carrying every ` +\n `capability, and that their imports resolve.`,\n );\n }\n\n return capabilityPackets;\n}\n\n/**\n * Warn about capability types that couldn't be documented, naming them so the\n * warning is actionable.\n *\n * @param description - Why they were skipped, as a noun phrase.\n * @param labels - Labels identifying each skipped type.\n */\nfunction warnSkipped(description: string, labels: string[]): void {\n if (labels.length === 0) {\n return;\n }\n\n const shown = labels.slice(0, MAX_SKIPPED_SHOWN);\n const remaining = labels.length - shown.length;\n console.warn(\n `Warning: skipped ${labels.length} capability ` +\n `${labels.length === 1 ? 'type' : 'types'} ${description}: ` +\n `${shown.join(', ')}${remaining > 0 ? `, and ${remaining} more` : ''}`,\n );\n}\n\n/**\n * Scan a project for messenger action/event types and generate documentation.\n *\n * @param options - Generation options.\n * @returns A promise resolving to counts of generated namespaces, actions, and events.\n */\nexport async function generate(\n options: GenerateOptions,\n): Promise<GenerateResult> {\n const { projectPath, outputDir, projectLabel, commitSha } = options;\n\n const allItems =\n options.strategy === 'root-messenger'\n ? collectFromRootMessengerCapabilities(projectPath, options)\n : await collectByScanning(projectPath, options.scanDirs);\n\n console.log(\n `Found ${allItems.length} messenger ${allItems.length === 1 ? 'item' : 'items'} total.`,\n );\n\n const namespaces = groupByNamespace(allItems);\n const repoBaseUrl = await resolveRepoBaseUrl(projectPath, commitSha ?? null);\n\n await writeOutput(namespaces, outputDir, repoBaseUrl, {\n projectLabel,\n commitSha,\n });\n\n const totalActions = namespaces.reduce(\n (sum, ns) => sum + ns.actions.length,\n 0,\n );\n const totalEvents = namespaces.reduce((sum, ns) => sum + ns.events.length, 0);\n\n console.log(\n `Generated docs for ${namespaces.length} ${namespaces.length === 1 ? 'namespace' : 'namespaces'}.`,\n );\n console.log(` Actions: ${totalActions}`);\n console.log(` Events: ${totalEvents}`);\n console.log(`Output: ${path.join(outputDir, 'docs')}/`);\n\n return {\n namespaces: namespaces.length,\n actions: totalActions,\n events: totalEvents,\n };\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask-previews/platform-api-docs",
3
- "version": "0.2.1-preview-11d253c58",
3
+ "version": "0.2.1-preview-0a1dd02ad",
4
4
  "description": "Produces documentation for the platform API, the set of actions and events available in the clients through the message bus",
5
5
  "keywords": [
6
6
  "Ethereum",
@@ -51,28 +51,27 @@
51
51
  "@easyops-cn/docusaurus-search-local": "^0.55.1",
52
52
  "@mdx-js/react": "^3.1.1",
53
53
  "@metamask/utils": "^12.0.0",
54
- "execa": "^10.0.1",
54
+ "execa": "^5.0.0",
55
55
  "npm-which": "^3.0.1",
56
56
  "prism-react-renderer": "^2.4.1",
57
57
  "react": "^19.0.0",
58
58
  "react-dom": "^19.0.0",
59
59
  "ts-morph": "^28.0.0",
60
- "yargs": "^17.7.3"
60
+ "yargs": "^17.7.2"
61
61
  },
62
62
  "devDependencies": {
63
- "@jest/globals": "^30.4.1",
64
- "@metamask/auto-changelog": "^6.2.1",
63
+ "@metamask/auto-changelog": "^6.1.0",
65
64
  "@types/jest": "^30.0.0",
66
65
  "@types/node": "^22.13.14",
67
66
  "@types/npm-which": "^3",
68
67
  "@types/react": "^19.0.0",
69
- "@types/yargs": "^17.0.35",
68
+ "@types/yargs": "^17.0.32",
70
69
  "@typescript/native": "npm:typescript@^7.0.2",
71
- "deepmerge": "^4.3.1",
70
+ "deepmerge": "^4.2.2",
72
71
  "jest": "^30.4.2",
73
- "rimraf": "^6.1.3",
74
- "ts-jest": "^29.4.12",
75
- "tsx": "^4.23.15",
72
+ "rimraf": "^5.0.5",
73
+ "ts-jest": "^29.4.11",
74
+ "tsx": "^4.20.5",
76
75
  "typescript": "npm:@typescript/typescript6@^6.0.2"
77
76
  },
78
77
  "engines": {