@cms-lab/cli 1.2.3 → 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,6 +11,7 @@ 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
@@ -42,6 +43,8 @@ project-specific required fields.
42
43
 
43
44
  `cms-lab init --cms strapi --router pages` writes a Strapi starter config with
44
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.
45
48
  Use `site.healthPath` or `site.healthUrl` in config when the app root is not the
46
49
  right page for the initial health probe.
47
50
 
package/dist/bin.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  runCli
4
- } from "./chunk-M5O5QRR3.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.3").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
  });
@@ -669,19 +669,20 @@ Examples:
669
669
  });
670
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(
671
671
  "--cms <provider>",
672
- "Starter CMS provider: prismic or strapi",
672
+ "Starter CMS provider: prismic, strapi, or directus",
673
673
  "prismic"
674
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(
675
675
  "--strapi-url <url>",
676
676
  "Strapi REST API URL",
677
677
  "http://localhost:1337"
678
- ).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(
679
679
  "after",
680
680
  `
681
681
  Examples:
682
682
  cms-lab init
683
683
  cms-lab init --repository my-prismic-repo --url http://localhost:3000
684
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
685
686
  cms-lab init --config cms-lab.config.ts --force
686
687
  `
687
688
  ).action(async (options) => {
@@ -1621,8 +1622,10 @@ function plural3(value, singular) {
1621
1622
  }
1622
1623
  function parseInitOptions(options) {
1623
1624
  const cms = options.cms ?? "prismic";
1624
- if (cms !== "prismic" && cms !== "strapi") {
1625
- 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
+ );
1626
1629
  }
1627
1630
  const router = options.router ?? "app";
1628
1631
  if (router !== "app" && router !== "pages") {
@@ -1634,13 +1637,17 @@ function parseInitOptions(options) {
1634
1637
  repository: options.repository ?? "my-repo",
1635
1638
  url: options.url ?? "http://localhost:3000",
1636
1639
  strapiUrl: options.strapiUrl ?? "http://localhost:1337",
1637
- strapiLocale: options.strapiLocale
1640
+ strapiLocale: options.strapiLocale,
1641
+ directusUrl: options.directusUrl ?? "http://localhost:8055"
1638
1642
  };
1639
1643
  }
1640
1644
  function starterConfig(options) {
1641
1645
  if (options.cms === "strapi") {
1642
1646
  return strapiStarterConfig(options);
1643
1647
  }
1648
+ if (options.cms === "directus") {
1649
+ return directusStarterConfig(options);
1650
+ }
1644
1651
  return `import { defineConfig } from "@cms-lab/core";
1645
1652
 
1646
1653
  export default defineConfig({
@@ -1662,6 +1669,71 @@ export default defineConfig({
1662
1669
  });
1663
1670
  `;
1664
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
+ }
1665
1737
  function strapiStarterConfig(options) {
1666
1738
  const localeLine = options.strapiLocale ? `
1667
1739
  locale: ${JSON.stringify(options.strapiLocale)},` : "";
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  runCli
3
- } from "./chunk-M5O5QRR3.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.3",
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.3",
51
- "@cms-lab/core": "1.2.3",
52
- "@cms-lab/prismic": "1.2.3",
53
- "@cms-lab/reporter": "1.2.3",
54
- "@cms-lab/sanity": "1.2.3",
55
- "@cms-lab/strapi": "1.2.3",
56
- "@cms-lab/next": "1.2.3",
57
- "@cms-lab/wordpress": "1.2.3",
58
- "@cms-lab/directus": "1.2.3"
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": {