lism-cli 0.4.2 → 0.5.0

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.
@@ -547,8 +547,8 @@ var logger = {
547
547
  };
548
548
 
549
549
  // src/version.ts
550
- var LISM_CSS_VERSION = "0.20.0" ? "0.20.0" : "unknown";
551
- var CLI_VERSION = "0.4.2" ? "0.4.2" : "unknown";
550
+ var LISM_CSS_VERSION = "0.21.0" ? "0.21.0" : "unknown";
551
+ var CLI_VERSION = "0.5.0" ? "0.5.0" : "unknown";
552
552
 
553
553
  // src/constants.ts
554
554
  var SOURCE_REPO = "lism-css/lism-css";
@@ -593,7 +593,11 @@ var TEMPLATES = [
593
593
  sourcePath: "blog/astro/minimal",
594
594
  title: { ja: "Blog Minimal", en: "Blog Minimal" },
595
595
  description: { ja: "\u8A18\u4E8B\u4E00\u89A7 / \u8A73\u7D30 / Tags \u306E\u307F\u306E\u6700\u5C0F\u69CB\u6210\u306E Astro \u30D6\u30ED\u30B0", en: "Minimal Astro blog with posts and tags only" },
596
- previewUrl: "https://lism-blog-astro-minimal.pages.dev/"
596
+ previewUrl: "https://lism-blog-astro-minimal.pages.dev/",
597
+ features: {
598
+ ja: ["\u30BF\u30B0", "sitemap"],
599
+ en: ["Tags", "sitemap"]
600
+ }
597
601
  },
598
602
  {
599
603
  slug: "blog-astro-personal",
@@ -608,7 +612,11 @@ var TEMPLATES = [
608
612
  ja: "\u500B\u4EBA\u30D6\u30ED\u30B0\u30FB\u30A8\u30C3\u30BB\u30A4\u5411\u3051\u3002\u5E74\u6708\u30A2\u30FC\u30AB\u30A4\u30D6\u3064\u304D\u306E\u843D\u3061\u7740\u3044\u305F Astro \u30D6\u30ED\u30B0",
609
613
  en: "Personal / essay-style Astro blog with monthly archives"
610
614
  },
611
- previewUrl: "https://lism-blog-astro-personal.pages.dev/"
615
+ previewUrl: "https://lism-blog-astro-personal.pages.dev/",
616
+ features: {
617
+ ja: ["\u30BF\u30B0", "\u5E74\u6708\u30A2\u30FC\u30AB\u30A4\u30D6", "\u30B7\u30A7\u30A2\u30DC\u30BF\u30F3", "OGP\u753B\u50CF\u81EA\u52D5\u751F\u6210", "sitemap\uFF08lastmod \u5BFE\u5FDC\uFF09"],
618
+ en: ["Tags", "Monthly archives", "Share buttons", "Auto-generated OG images", "sitemap (with lastmod)"]
619
+ }
612
620
  },
613
621
  {
614
622
  slug: "blog-astro-techlog",
@@ -623,31 +631,55 @@ var TEMPLATES = [
623
631
  ja: "\u6280\u8853\u30D6\u30ED\u30B0\u5411\u3051\u3002\u30B3\u30FC\u30C9\u30CF\u30A4\u30E9\u30A4\u30C8\u30FB\u30AB\u30C6\u30B4\u30EA\u30FB\u30BF\u30B0\u30FBTOC\u30FB\u5E74\u6708\u30A2\u30FC\u30AB\u30A4\u30D6\u30FB\u691C\u7D22\u3092\u88C5\u5099\u3057\u305F Astro \u30D6\u30ED\u30B0",
624
632
  en: "Tech blog with code highlighting, categories, tags, TOC, monthly archives and search"
625
633
  },
626
- previewUrl: "https://lism-blog-astro-techlog.pages.dev/"
634
+ previewUrl: "https://lism-blog-astro-techlog.pages.dev/",
635
+ features: {
636
+ ja: [
637
+ "\u30AB\u30C6\u30B4\u30EA / \u30BF\u30B0",
638
+ "\u5E74\u6708\u30A2\u30FC\u30AB\u30A4\u30D6",
639
+ "\u691C\u7D22\uFF08Pagefind\uFF09",
640
+ "\u76EE\u6B21",
641
+ "\u30B3\u30FC\u30C9\u30CF\u30A4\u30E9\u30A4\u30C8",
642
+ "\u30C0\u30FC\u30AF\u30E2\u30FC\u30C9",
643
+ "\u30B7\u30A7\u30A2\u30DC\u30BF\u30F3",
644
+ "OGP\u753B\u50CF\u81EA\u52D5\u751F\u6210",
645
+ "sitemap\uFF08lastmod \u5BFE\u5FDC\uFF09"
646
+ ],
647
+ en: [
648
+ "Categories / Tags",
649
+ "Monthly archives",
650
+ "Search (Pagefind)",
651
+ "Table of contents",
652
+ "Code highlighting",
653
+ "Dark mode",
654
+ "Share buttons",
655
+ "Auto-generated OG images",
656
+ "sitemap (with lastmod)"
657
+ ]
658
+ }
627
659
  },
628
660
  {
629
- slug: "lp-astro-minimal",
661
+ slug: "lp-astro-corporate",
630
662
  kind: "single-project-variant",
631
663
  category: "lp",
632
664
  stack: "astro",
633
- variant: "minimal",
634
- variantLabel: { ja: "Minimal", en: "Minimal" },
665
+ variant: "corporate",
666
+ variantLabel: { ja: "Corporate", en: "Corporate" },
635
667
  sourcePath: "lp/astro",
636
- title: { ja: "LP Minimal", en: "LP Minimal" },
637
- description: { ja: "\u30DF\u30CB\u30DE\u30EB\u306A Astro \u30E9\u30F3\u30C7\u30A3\u30F3\u30B0\u30DA\u30FC\u30B8", en: "Minimal Astro landing page" },
638
- draft: true
668
+ title: { ja: "LP Corporate", en: "LP Corporate" },
669
+ description: { ja: "\u30B3\u30FC\u30DD\u30EC\u30FC\u30C8\u30B5\u30A4\u30C8\u5411\u3051\u306E Astro \u30E9\u30F3\u30C7\u30A3\u30F3\u30B0\u30DA\u30FC\u30B8", en: "Astro landing page for corporate sites" },
670
+ previewUrl: "https://lism-lp-astro.pages.dev/corporate/"
639
671
  },
640
672
  {
641
- slug: "lp-astro-natural",
673
+ slug: "lp-astro-interior",
642
674
  kind: "single-project-variant",
643
675
  category: "lp",
644
676
  stack: "astro",
645
- variant: "natural",
646
- variantLabel: { ja: "Natural", en: "Natural" },
677
+ variant: "interior",
678
+ variantLabel: { ja: "Interior", en: "Interior" },
647
679
  sourcePath: "lp/astro",
648
- title: { ja: "LP Natural", en: "LP Natural" },
649
- description: { ja: "\u30CA\u30C1\u30E5\u30E9\u30EB\u306A\u96F0\u56F2\u6C17\u306E Astro \u30E9\u30F3\u30C7\u30A3\u30F3\u30B0\u30DA\u30FC\u30B8", en: "Natural-themed Astro landing page" },
650
- draft: true
680
+ title: { ja: "LP Interior", en: "LP Interior" },
681
+ description: { ja: "\u30A4\u30F3\u30C6\u30EA\u30A2\u30FB\u66AE\u3089\u3057\u7CFB\u30B5\u30FC\u30D3\u30B9\u5411\u3051\u306E Astro \u30E9\u30F3\u30C7\u30A3\u30F3\u30B0\u30DA\u30FC\u30B8", en: "Astro landing page for interior / lifestyle services" },
682
+ previewUrl: "https://lism-lp-astro.pages.dev/interior/"
651
683
  },
652
684
  {
653
685
  slug: "lp-astro-ryokan",
@@ -824,7 +856,7 @@ function postProcessTemplate(projectDir, tpl) {
824
856
  rewritePackageName(projectDir, tpl.slug);
825
857
  }
826
858
  if (tpl.kind === "single-project-variant") {
827
- extractVariantPages(projectDir, tpl);
859
+ extractVariantFiles(projectDir, tpl);
828
860
  rewritePackageName(projectDir, tpl.packageName ?? tpl.slug);
829
861
  }
830
862
  cleanupDevArtifacts(projectDir);
@@ -840,28 +872,84 @@ function cleanupDevArtifacts(projectDir) {
840
872
  fs.rmSync(screenshotsConfig, { force: true });
841
873
  }
842
874
  }
843
- function extractVariantPages(projectDir, tpl) {
844
- const pagesDir = path.join(projectDir, "src", "pages");
845
- const variantDir = path.join(pagesDir, tpl.variant);
846
- const variantIndex = path.join(variantDir, "index.astro");
847
- const targetIndex = path.join(pagesDir, "index.astro");
848
- if (!fs.existsSync(variantIndex)) {
875
+ function extractVariantFiles(projectDir, tpl) {
876
+ const srcDir = path.join(projectDir, "src");
877
+ const variant = tpl.variant;
878
+ const pagesVariantIndex = path.join(srcDir, "pages", variant, "index.astro");
879
+ if (!fs.existsSync(pagesVariantIndex)) {
849
880
  throw new Error(
850
881
  t("create.variantMissing", {
851
- variant: tpl.variant,
852
- path: `${formatTemplatePath(tpl.sourcePath)}/src/pages/${tpl.variant}/index.astro`
882
+ variant,
883
+ path: `${formatTemplatePath(tpl.sourcePath)}/src/pages/${variant}/index.astro`
853
884
  })
854
885
  );
855
886
  }
856
- if (fs.existsSync(targetIndex)) {
857
- fs.rmSync(targetIndex, { force: true });
858
- }
859
- fs.renameSync(variantIndex, targetIndex);
860
- for (const entry of fs.readdirSync(pagesDir, { withFileTypes: true })) {
887
+ if (!fs.existsSync(srcDir) || !fs.statSync(srcDir).isDirectory()) return;
888
+ for (const entry of fs.readdirSync(srcDir, { withFileTypes: true })) {
861
889
  if (!entry.isDirectory()) continue;
862
- fs.rmSync(path.join(pagesDir, entry.name), { recursive: true, force: true });
890
+ const parentDir = path.join(srcDir, entry.name);
891
+ const variantDirInside = path.join(parentDir, variant);
892
+ if (!fs.existsSync(variantDirInside)) continue;
893
+ if (!fs.statSync(variantDirInside).isDirectory()) continue;
894
+ mergeDirectory(variantDirInside, parentDir);
895
+ for (const child of fs.readdirSync(parentDir, { withFileTypes: true })) {
896
+ if (!child.isDirectory()) continue;
897
+ fs.rmSync(path.join(parentDir, child.name), { recursive: true, force: true });
898
+ }
899
+ }
900
+ rewriteVariantAliasImports(srcDir, variant);
901
+ }
902
+ var ALIAS_REWRITE_EXTENSIONS = /* @__PURE__ */ new Set([
903
+ ".astro",
904
+ ".ts",
905
+ ".tsx",
906
+ ".js",
907
+ ".jsx",
908
+ ".mjs",
909
+ ".cjs",
910
+ ".css",
911
+ ".scss",
912
+ ".sass",
913
+ ".less",
914
+ ".md",
915
+ ".mdx",
916
+ ".vue",
917
+ ".svelte",
918
+ ".html"
919
+ ]);
920
+ function rewriteVariantAliasImports(srcDir, variant) {
921
+ if (!fs.existsSync(srcDir)) return;
922
+ const pattern = new RegExp(`(@/[^/'"\\s\`]+)/${escapeRegExp(variant)}/`, "g");
923
+ walkFiles(srcDir, (filePath) => {
924
+ const ext = path.extname(filePath);
925
+ if (!ALIAS_REWRITE_EXTENSIONS.has(ext)) return;
926
+ let original;
927
+ try {
928
+ original = fs.readFileSync(filePath, "utf-8");
929
+ } catch {
930
+ return;
931
+ }
932
+ if (!original.includes(`/${variant}/`)) return;
933
+ const replaced = original.replace(pattern, "$1/");
934
+ if (replaced !== original) {
935
+ fs.writeFileSync(filePath, replaced);
936
+ }
937
+ });
938
+ }
939
+ function walkFiles(dir, callback) {
940
+ if (!fs.existsSync(dir)) return;
941
+ for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
942
+ const fp = path.join(dir, entry.name);
943
+ if (entry.isDirectory()) {
944
+ walkFiles(fp, callback);
945
+ } else if (entry.isFile()) {
946
+ callback(fp);
947
+ }
863
948
  }
864
949
  }
950
+ function escapeRegExp(s) {
951
+ return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
952
+ }
865
953
  function printNextSteps(projectDir, tpl) {
866
954
  logger.heading(t("create.nextSteps"));
867
955
  const rel = path.relative(process.cwd(), projectDir) || ".";
package/dist/index.js CHANGED
@@ -13,7 +13,7 @@ import {
13
13
  preScanLang,
14
14
  setLang,
15
15
  t
16
- } from "./chunk-J2T5ZPMR.js";
16
+ } from "./chunk-USFIDRTL.js";
17
17
 
18
18
  // src/createProgram.ts
19
19
  import { Command as Command3 } from "commander";
package/dist/lib.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  setLang,
4
4
  t,
5
5
  tOf
6
- } from "./chunk-J2T5ZPMR.js";
6
+ } from "./chunk-USFIDRTL.js";
7
7
  export {
8
8
  runCreate,
9
9
  setLang,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lism-cli",
3
- "version": "0.4.2",
3
+ "version": "0.5.0",
4
4
  "description": "CLI for scaffolding projects and adding UI components for Lism CSS / Lism UI.",
5
5
  "author": {
6
6
  "name": "ddryo",