Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port content inventory command #75

Closed
caugner opened this issue Jan 6, 2025 · 0 comments · Fixed by #80 or #79
Closed

Port content inventory command #75

caugner opened this issue Jan 6, 2025 · 0 comments · Fixed by #80 or #79
Labels
needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened.

Comments

@caugner
Copy link
Contributor

caugner commented Jan 6, 2025

The content inventory command is used by https://github.com/ddbeck/mdn-content-inventory to publish https://www.npmjs.com/package/@ddbeck/mdn-content-inventory, see:
https://github.com/ddbeck/mdn-content-inventory/blob/b8578e6e2847e79aa406d7db6d1152f9aa627d31/scripts/generate-inventory.mts#L135

The command is currently implemented in yari as part of tool:
https://github.com/mdn/yari/blob/bbe07c528c6ab7376ca1f80896e83b9819a04bce/tool/cli.ts#L1038-L1069

It is exposed in the content repository via the content script:
https://github.com/mdn/content/blob/c198131b981b9274fcde625e441df7da7b41bec3/package.json#L23

FWIW Here is the full implementation:

      const crawler = new fdir()
        .withFullPaths()
        .withErrors()
        .filter((filePath) => filePath.endsWith(".md"))
        .crawl(CONTENT_ROOT);
      const paths = (await crawler.withPromise()) as PathsOutput;

      const inventory = paths.map((path) => {
        const fileContents = fs.readFileSync(path, "utf-8");
        const parsed = frontmatter(fileContents);

        return {
          path: path.substring(path.indexOf("/files")),
          frontmatter: parsed.attributes,
        };
      });

      process.stdout.write(JSON.stringify(inventory, undefined, 2));
@mdn-bot mdn-bot added the needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. label Jan 6, 2025
fiji-flo added a commit that referenced this issue Jan 8, 2025
This was referenced Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants