@cms-lab/cli 1.2.2 → 1.2.4

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/README.md CHANGED
@@ -11,9 +11,11 @@ npx @cms-lab/cli scan
11
11
  ```sh
12
12
  cms-lab init
13
13
  cms-lab init --cms strapi --router pages
14
+ cms-lab init --cms directus --router pages
14
15
  cms-lab doctor
15
16
  cms-lab doctor --debug --verbose 2
16
17
  cms-lab scan --report
18
+ cms-lab scan --report --share-report
17
19
  cms-lab scan --markdown
18
20
  cms-lab scan --junit
19
21
  cms-lab scan --slack-webhook "$CMS_LAB_SLACK_WEBHOOK"
@@ -41,6 +43,8 @@ project-specific required fields.
41
43
 
42
44
  `cms-lab init --cms strapi --router pages` writes a Strapi starter config with
43
45
  collections, single types, route examples, and the Strapi relation route helper.
46
+ `cms-lab init --cms directus --router pages` writes a Directus starter config
47
+ with branch, menu item, category, and non-routable pricing collection examples.
44
48
  Use `site.healthPath` or `site.healthUrl` in config when the app root is not the
45
49
  right page for the initial health probe.
46
50
 
@@ -52,10 +56,13 @@ unless `--include-sensitive-output` is passed explicitly.
52
56
  CI strictness can be raised with `--fail-on warning`, `--max-warnings <count>`,
53
57
  `--max-info <count>`, or `--strict`.
54
58
 
55
- Exports include local HTML (`--report`), Markdown (`--markdown`), JUnit XML
56
- (`--junit`), and redacted Slack incoming webhook summaries
57
- (`--slack-webhook <url>`). Slack notifications send counts and diagnostic codes
58
- only, never raw CMS payloads, local paths, or webhook URLs.
59
+ Exports include local HTML (`--report`), share-safe local HTML
60
+ (`--report --share-report`), Markdown (`--markdown`), JUnit XML (`--junit`),
61
+ and redacted Slack incoming webhook summaries (`--slack-webhook <url>`).
62
+ Share-safe HTML redacts CMS source IDs and local project paths while keeping
63
+ diagnostic codes, severity, route paths, and field paths visible. Slack
64
+ notifications send counts and diagnostic codes only, never raw CMS payloads,
65
+ local paths, or webhook URLs.
59
66
 
60
67
  `cms-lab agent-context` writes safe handoff files so coding agents can read the
61
68
  cms-lab docs, package links, route mappings, and safe project facts before
package/dist/bin.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  runCli
4
- } from "./chunk-SVTBRARJ.js";
4
+ } from "./chunk-R7T3O3TT.js";
5
5
 
6
6
  // src/bin.ts
7
7
  var exitCode = await runCli(process.argv.slice(2));
@@ -565,7 +565,7 @@ var noColor = {
565
565
  // src/index.ts
566
566
  async function runCli(argv, dependencies = {}) {
567
567
  let exitCode = 0;
568
- const program = new Command().name("cms-lab").description("Catch CMS bugs before deploy.").version("1.2.2").exitOverride().configureOutput({
568
+ const program = new Command().name("cms-lab").description("Catch CMS bugs before deploy.").version("1.2.4").exitOverride().configureOutput({
569
569
  writeOut: (text) => writeStdout(dependencies, text),
570
570
  writeErr: (text) => writeStderr(dependencies, text)
571
571
  });
@@ -597,6 +597,9 @@ Examples:
597
597
  ).option(
598
598
  "--report [path]",
599
599
  "Write an HTML report. Defaults to .cms-lab/report.html"
600
+ ).option(
601
+ "--share-report",
602
+ "Redact CMS source IDs and local project paths in the HTML report"
600
603
  ).option(
601
604
  "--markdown [path]",
602
605
  "Write a Markdown summary. Defaults to .cms-lab/summary.md"
@@ -666,19 +669,20 @@ Examples:
666
669
  });
667
670
  program.command("init").description("Create a starter cms-lab.config.ts file.").option("--config <path>", "Config file path", "cms-lab.config.ts").option("--force", "Overwrite an existing config file").option(
668
671
  "--cms <provider>",
669
- "Starter CMS provider: prismic or strapi",
672
+ "Starter CMS provider: prismic, strapi, or directus",
670
673
  "prismic"
671
674
  ).option("--router <router>", "Next.js router: app or pages", "app").option("--repository <name>", "Prismic repository name", "my-repo").option("--url <url>", "Site URL", "http://localhost:3000").option(
672
675
  "--strapi-url <url>",
673
676
  "Strapi REST API URL",
674
677
  "http://localhost:1337"
675
- ).option("--strapi-locale <locale>", "Strapi locale query param").addHelpText(
678
+ ).option("--strapi-locale <locale>", "Strapi locale query param").option("--directus-url <url>", "Directus API URL", "http://localhost:8055").addHelpText(
676
679
  "after",
677
680
  `
678
681
  Examples:
679
682
  cms-lab init
680
683
  cms-lab init --repository my-prismic-repo --url http://localhost:3000
681
684
  cms-lab init --cms strapi --router pages --strapi-url http://localhost:1337
685
+ cms-lab init --cms directus --router pages --directus-url http://localhost:8055
682
686
  cms-lab init --config cms-lab.config.ts --force
683
687
  `
684
688
  ).action(async (options) => {
@@ -809,7 +813,9 @@ async function runScan(options, dependencies) {
809
813
  });
810
814
  const status = exitCode === 0 ? "passed" : "failed";
811
815
  const endReport = debug.time("exports", 2);
812
- await maybeWriteReport(options.report, result, cwd);
816
+ await maybeWriteReport(options.report, result, cwd, {
817
+ share: Boolean(options.shareReport)
818
+ });
813
819
  await maybeWriteMarkdown(options.markdown, result, status, cwd);
814
820
  await maybeWriteJUnit(options.junit, result, cwd);
815
821
  const slackSent = await maybePostSlack({
@@ -1504,13 +1510,17 @@ function exitCodeForResult(result, options) {
1504
1510
  function thresholdExceeded(result, maxWarnings, maxInfo) {
1505
1511
  return maxWarnings !== void 0 && result.summary.warnings > maxWarnings || maxInfo !== void 0 && result.summary.info > maxInfo;
1506
1512
  }
1507
- async function maybeWriteReport(report, result, cwd) {
1513
+ async function maybeWriteReport(report, result, cwd, options = {}) {
1508
1514
  if (!report) {
1509
1515
  return;
1510
1516
  }
1511
1517
  const path = reportPathFromOption(report, cwd);
1512
1518
  await mkdir(dirname(path), { recursive: true });
1513
- await writeFile(path, renderHtmlReport(result), "utf8");
1519
+ await writeFile(
1520
+ path,
1521
+ renderHtmlReport(result, { privacy: options.share ? "share" : "full" }),
1522
+ "utf8"
1523
+ );
1514
1524
  }
1515
1525
  function reportPathFromOption(report, cwd) {
1516
1526
  return resolve(
@@ -1612,8 +1622,10 @@ function plural3(value, singular) {
1612
1622
  }
1613
1623
  function parseInitOptions(options) {
1614
1624
  const cms = options.cms ?? "prismic";
1615
- if (cms !== "prismic" && cms !== "strapi") {
1616
- throw new ConfigLoadError("--cms must be one of: prismic, strapi");
1625
+ if (cms !== "prismic" && cms !== "strapi" && cms !== "directus") {
1626
+ throw new ConfigLoadError(
1627
+ "--cms must be one of: prismic, strapi, directus"
1628
+ );
1617
1629
  }
1618
1630
  const router = options.router ?? "app";
1619
1631
  if (router !== "app" && router !== "pages") {
@@ -1625,13 +1637,17 @@ function parseInitOptions(options) {
1625
1637
  repository: options.repository ?? "my-repo",
1626
1638
  url: options.url ?? "http://localhost:3000",
1627
1639
  strapiUrl: options.strapiUrl ?? "http://localhost:1337",
1628
- strapiLocale: options.strapiLocale
1640
+ strapiLocale: options.strapiLocale,
1641
+ directusUrl: options.directusUrl ?? "http://localhost:8055"
1629
1642
  };
1630
1643
  }
1631
1644
  function starterConfig(options) {
1632
1645
  if (options.cms === "strapi") {
1633
1646
  return strapiStarterConfig(options);
1634
1647
  }
1648
+ if (options.cms === "directus") {
1649
+ return directusStarterConfig(options);
1650
+ }
1635
1651
  return `import { defineConfig } from "@cms-lab/core";
1636
1652
 
1637
1653
  export default defineConfig({
@@ -1653,6 +1669,71 @@ export default defineConfig({
1653
1669
  });
1654
1670
  `;
1655
1671
  }
1672
+ function directusStarterConfig(options) {
1673
+ return `import { defineConfig, readCmsDataPath } from "@cms-lab/core";
1674
+
1675
+ export default defineConfig({
1676
+ site: {
1677
+ url: ${JSON.stringify(options.url)},
1678
+ // Use healthPath when your app's root redirects or errors but a locale route is healthy.
1679
+ // healthPath: "/en",
1680
+ },
1681
+ framework: { type: "next", router: ${JSON.stringify(options.router)} },
1682
+ cms: {
1683
+ provider: "directus",
1684
+ url: ${JSON.stringify(options.directusUrl)},
1685
+ token: process.env.DIRECTUS_TOKEN,
1686
+ collections: [
1687
+ { type: "branch", collection: "branches", uidField: "slug" },
1688
+ { type: "menu_item", collection: "menu_items", uidField: "slug" },
1689
+ { type: "category", collection: "menu_categories", uidField: "slug" },
1690
+ {
1691
+ type: "pricing",
1692
+ collection: "item_branch_pricing",
1693
+ uidField: "id",
1694
+ routable: false,
1695
+ },
1696
+ ],
1697
+ },
1698
+ routes: [
1699
+ {
1700
+ type: "branch",
1701
+ pattern: "/branches/:slug",
1702
+ getPath: (doc) => \`/branches/\${doc.uid}\`,
1703
+ },
1704
+ {
1705
+ type: "category",
1706
+ pattern: "/categories/:slug",
1707
+ getPath: (doc) => \`/categories/\${doc.uid}\`,
1708
+ },
1709
+ {
1710
+ type: "menu_item",
1711
+ pattern: "/menu/:branch/:slug",
1712
+ getPath: (doc) => {
1713
+ const branch =
1714
+ readCmsDataPath(doc.data, "branch.slug") ??
1715
+ readCmsDataPath(doc.data, "branch_id.slug") ??
1716
+ "branch";
1717
+
1718
+ return \`/menu/\${branch}/\${doc.uid}\`;
1719
+ },
1720
+ },
1721
+ ],
1722
+ checks: {
1723
+ fields: {
1724
+ required: [
1725
+ { type: "branch", path: "name" },
1726
+ { type: "branch", path: "city" },
1727
+ { type: "menu_item", path: "name" },
1728
+ { type: "menu_item", path: "base_price", severity: "warning" },
1729
+ { type: "pricing", path: "price", severity: "warning" },
1730
+ { type: "pricing", path: "is_available", severity: "warning" },
1731
+ ],
1732
+ },
1733
+ },
1734
+ });
1735
+ `;
1736
+ }
1656
1737
  function strapiStarterConfig(options) {
1657
1738
  const localeLine = options.strapiLocale ? `
1658
1739
  locale: ${JSON.stringify(options.strapiLocale)},` : "";
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  runCli
3
- } from "./chunk-SVTBRARJ.js";
3
+ } from "./chunk-R7T3O3TT.js";
4
4
  export {
5
5
  runCli
6
6
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cms-lab/cli",
3
- "version": "1.2.2",
3
+ "version": "1.2.4",
4
4
  "type": "module",
5
5
  "description": "Catch CMS bugs before deploy.",
6
6
  "license": "MIT",
@@ -47,15 +47,15 @@
47
47
  "dependencies": {
48
48
  "commander": "^14.0.2",
49
49
  "picocolors": "^1.1.1",
50
- "@cms-lab/contentful": "1.2.2",
51
- "@cms-lab/directus": "1.2.2",
52
- "@cms-lab/next": "1.2.2",
53
- "@cms-lab/core": "1.2.2",
54
- "@cms-lab/reporter": "1.2.2",
55
- "@cms-lab/prismic": "1.2.2",
56
- "@cms-lab/sanity": "1.2.2",
57
- "@cms-lab/strapi": "1.2.2",
58
- "@cms-lab/wordpress": "1.2.2"
50
+ "@cms-lab/contentful": "1.2.4",
51
+ "@cms-lab/next": "1.2.4",
52
+ "@cms-lab/directus": "1.2.4",
53
+ "@cms-lab/core": "1.2.4",
54
+ "@cms-lab/reporter": "1.2.4",
55
+ "@cms-lab/sanity": "1.2.4",
56
+ "@cms-lab/prismic": "1.2.4",
57
+ "@cms-lab/strapi": "1.2.4",
58
+ "@cms-lab/wordpress": "1.2.4"
59
59
  },
60
60
  "author": "Afaq Rashid",
61
61
  "scripts": {