Skip to content

Port content inventory command #75

@caugner

Description

@caugner

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));

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs triageTriage needed by staff and/or partners. Automatically applied when an issue is opened.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions