@getcoherent/cli 0.5.1 → 0.5.2
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/dist/index.js +32 -22
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -6677,7 +6677,7 @@ function formatIssues(issues) {
|
|
|
6677
6677
|
// src/commands/chat/code-generator.ts
|
|
6678
6678
|
import { resolve as resolve6 } from "path";
|
|
6679
6679
|
import { existsSync as existsSync14 } from "fs";
|
|
6680
|
-
import { mkdir as mkdir2 } from "fs/promises";
|
|
6680
|
+
import { mkdir as mkdir2, readFile as readFile5 } from "fs/promises";
|
|
6681
6681
|
import { dirname as dirname5 } from "path";
|
|
6682
6682
|
import {
|
|
6683
6683
|
ComponentGenerator as ComponentGenerator2,
|
|
@@ -6771,15 +6771,25 @@ async function regenerateLayout(config2, projectRoot) {
|
|
|
6771
6771
|
overwrite: true
|
|
6772
6772
|
});
|
|
6773
6773
|
}
|
|
6774
|
-
|
|
6775
|
-
|
|
6776
|
-
|
|
6777
|
-
|
|
6778
|
-
|
|
6779
|
-
|
|
6780
|
-
|
|
6781
|
-
|
|
6782
|
-
|
|
6774
|
+
let shouldOverwriteFooter = false;
|
|
6775
|
+
try {
|
|
6776
|
+
const footerPath = resolve6(projectRoot, "components", "shared", "footer.tsx");
|
|
6777
|
+
const existing = await readFile5(footerPath, "utf-8");
|
|
6778
|
+
shouldOverwriteFooter = existing.includes("Coherent Design Method");
|
|
6779
|
+
} catch {
|
|
6780
|
+
shouldOverwriteFooter = true;
|
|
6781
|
+
}
|
|
6782
|
+
if (shouldOverwriteFooter) {
|
|
6783
|
+
const footerCode = generator.generateSharedFooterCode();
|
|
6784
|
+
await generateSharedComponent2(projectRoot, {
|
|
6785
|
+
name: "Footer",
|
|
6786
|
+
type: "layout",
|
|
6787
|
+
code: footerCode,
|
|
6788
|
+
description: "Site footer",
|
|
6789
|
+
usedIn: ["app/layout.tsx"],
|
|
6790
|
+
overwrite: true
|
|
6791
|
+
});
|
|
6792
|
+
}
|
|
6783
6793
|
if (navType === "sidebar" || navType === "both") {
|
|
6784
6794
|
const sidebarCode = generator.generateSharedSidebarCode();
|
|
6785
6795
|
await generateSharedComponent2(projectRoot, {
|
|
@@ -9606,7 +9616,7 @@ import ora4 from "ora";
|
|
|
9606
9616
|
import { spawn as spawn2 } from "child_process";
|
|
9607
9617
|
import { existsSync as existsSync20, rmSync as rmSync4, readdirSync as readdirSync3 } from "fs";
|
|
9608
9618
|
import { resolve as resolve11, join as join12, dirname as dirname7 } from "path";
|
|
9609
|
-
import { readdir as readdir3, readFile as
|
|
9619
|
+
import { readdir as readdir3, readFile as readFile6, writeFile as writeFile4, mkdir as mkdir4, copyFile as copyFile2 } from "fs/promises";
|
|
9610
9620
|
var COPY_EXCLUDE = /* @__PURE__ */ new Set([
|
|
9611
9621
|
"node_modules",
|
|
9612
9622
|
".next",
|
|
@@ -9650,7 +9660,7 @@ async function patchNextConfigForExport(outRoot) {
|
|
|
9650
9660
|
for (const name of ["next.config.ts", "next.config.mjs", "next.config.js"]) {
|
|
9651
9661
|
const p = join12(outRoot, name);
|
|
9652
9662
|
if (!existsSync20(p)) continue;
|
|
9653
|
-
let content = await
|
|
9663
|
+
let content = await readFile6(p, "utf-8");
|
|
9654
9664
|
if (content.includes("ignoreDuringBuilds")) return;
|
|
9655
9665
|
content = content.replace(
|
|
9656
9666
|
/(const\s+nextConfig\s*(?::\s*\w+)?\s*=\s*\{)/,
|
|
@@ -9693,7 +9703,7 @@ async function ensureReadmeDeploySection(outRoot) {
|
|
|
9693
9703
|
const readmePath = join12(outRoot, "README.md");
|
|
9694
9704
|
if (!existsSync20(readmePath)) return;
|
|
9695
9705
|
try {
|
|
9696
|
-
let content = await
|
|
9706
|
+
let content = await readFile6(readmePath, "utf-8");
|
|
9697
9707
|
if (/##\s+Deploy\b/m.test(content)) return;
|
|
9698
9708
|
content = content.trimEnd() + DEPLOY_SECTION + "\n";
|
|
9699
9709
|
await writeFile4(readmePath, content);
|
|
@@ -9746,7 +9756,7 @@ async function collectImportedPackages2(dir, extensions) {
|
|
|
9746
9756
|
if (!e.isFile()) continue;
|
|
9747
9757
|
const ext = e.name.replace(/^.*\./, "");
|
|
9748
9758
|
if (!extensions.has(ext)) continue;
|
|
9749
|
-
const content = await
|
|
9759
|
+
const content = await readFile6(full, "utf-8").catch(() => "");
|
|
9750
9760
|
let m;
|
|
9751
9761
|
IMPORT_FROM_REGEX2.lastIndex = 0;
|
|
9752
9762
|
while ((m = IMPORT_FROM_REGEX2.exec(content)) !== null) {
|
|
@@ -9765,7 +9775,7 @@ async function findMissingDepsInExport(outRoot) {
|
|
|
9765
9775
|
if (!existsSync20(pkgPath)) return [];
|
|
9766
9776
|
let pkg;
|
|
9767
9777
|
try {
|
|
9768
|
-
pkg = JSON.parse(await
|
|
9778
|
+
pkg = JSON.parse(await readFile6(pkgPath, "utf-8"));
|
|
9769
9779
|
} catch {
|
|
9770
9780
|
return [];
|
|
9771
9781
|
}
|
|
@@ -9795,14 +9805,14 @@ async function stripCoherentArtifacts(outputDir) {
|
|
|
9795
9805
|
}
|
|
9796
9806
|
const layoutPath = join12(outputDir, "app", "layout.tsx");
|
|
9797
9807
|
if (existsSync20(layoutPath)) {
|
|
9798
|
-
let layout = await
|
|
9808
|
+
let layout = await readFile6(layoutPath, "utf-8");
|
|
9799
9809
|
layout = layout.replace(/import\s*\{?\s*AppNav\s*\}?\s*from\s*['"][^'"]+['"]\s*\n?/g, "");
|
|
9800
9810
|
layout = layout.replace(/\s*<AppNav\s*\/?\s*>\s*/g, "\n");
|
|
9801
9811
|
await writeFile4(layoutPath, layout, "utf-8");
|
|
9802
9812
|
}
|
|
9803
9813
|
const sharedHeaderPath = join12(outputDir, "components", "shared", "header.tsx");
|
|
9804
9814
|
if (existsSync20(sharedHeaderPath)) {
|
|
9805
|
-
let header = await
|
|
9815
|
+
let header = await readFile6(sharedHeaderPath, "utf-8");
|
|
9806
9816
|
header = header.replace(/<Link\s[^>]*href="\/design-system"[^>]*>[\s\S]*?<\/Link>/g, "");
|
|
9807
9817
|
header = header.replace(/\n\s*<>\s*\n/, "\n");
|
|
9808
9818
|
header = header.replace(/\n\s*<\/>\s*\n/, "\n");
|
|
@@ -9810,7 +9820,7 @@ async function stripCoherentArtifacts(outputDir) {
|
|
|
9810
9820
|
}
|
|
9811
9821
|
const guardPath = join12(outputDir, "app", "ShowWhenNotAuthRoute.tsx");
|
|
9812
9822
|
if (existsSync20(guardPath)) {
|
|
9813
|
-
let guard = await
|
|
9823
|
+
let guard = await readFile6(guardPath, "utf-8");
|
|
9814
9824
|
guard = guard.replace(/['"],?\s*'\/design-system['"],?\s*/g, "");
|
|
9815
9825
|
const pathsMatch = guard.match(/HIDDEN_PATHS\s*=\s*\[([^\]]*)\]/);
|
|
9816
9826
|
const remaining = pathsMatch ? pathsMatch[1].replace(/['"]/g, "").split(",").map((s) => s.trim()).filter(Boolean) : [];
|
|
@@ -9818,7 +9828,7 @@ async function stripCoherentArtifacts(outputDir) {
|
|
|
9818
9828
|
rmSync4(guardPath, { force: true });
|
|
9819
9829
|
removed.push("app/ShowWhenNotAuthRoute.tsx");
|
|
9820
9830
|
if (existsSync20(layoutPath)) {
|
|
9821
|
-
let layout = await
|
|
9831
|
+
let layout = await readFile6(layoutPath, "utf-8");
|
|
9822
9832
|
layout = layout.replace(/import\s+\w+\s+from\s*['"]\.\/ShowWhenNotAuthRoute['"]\s*\n?/g, "");
|
|
9823
9833
|
layout = layout.replace(/\s*<ShowWhenNotAuthRoute>\s*\n?/g, "\n");
|
|
9824
9834
|
layout = layout.replace(/\s*<\/ShowWhenNotAuthRoute>\s*\n?/g, "\n");
|
|
@@ -11478,7 +11488,7 @@ import chalk30 from "chalk";
|
|
|
11478
11488
|
import ora9 from "ora";
|
|
11479
11489
|
import { existsSync as existsSync26, readFileSync as readFileSync17 } from "fs";
|
|
11480
11490
|
import { join as join17, relative as relative4, dirname as dirname10 } from "path";
|
|
11481
|
-
import { readdir as readdir4, readFile as
|
|
11491
|
+
import { readdir as readdir4, readFile as readFile7 } from "fs/promises";
|
|
11482
11492
|
import { DesignSystemManager as DesignSystemManager16 } from "@getcoherent/core";
|
|
11483
11493
|
import { loadManifest as loadManifest12, saveManifest as saveManifest5, findSharedComponent } from "@getcoherent/core";
|
|
11484
11494
|
function extractTokensFromProject(projectRoot) {
|
|
@@ -11542,7 +11552,7 @@ async function detectCustomComponents(projectRoot, allPageCode) {
|
|
|
11542
11552
|
await walkForTsx(componentsDir, files, ["ui"]);
|
|
11543
11553
|
const fileResults = await Promise.all(
|
|
11544
11554
|
files.map(async (filePath) => {
|
|
11545
|
-
const code = await
|
|
11555
|
+
const code = await readFile7(filePath, "utf-8");
|
|
11546
11556
|
const relFile = relative4(projectRoot, filePath);
|
|
11547
11557
|
const exportedNames = extractExportedComponentNames2(code);
|
|
11548
11558
|
return exportedNames.map((name) => ({
|
|
@@ -11644,7 +11654,7 @@ async function discoverPages(appDir) {
|
|
|
11644
11654
|
if (entry.name.startsWith(".")) continue;
|
|
11645
11655
|
await walk(full);
|
|
11646
11656
|
} else if (entry.name === "page.tsx" || entry.name === "page.jsx") {
|
|
11647
|
-
const code = await
|
|
11657
|
+
const code = await readFile7(full, "utf-8");
|
|
11648
11658
|
const routeDir = dirname10(relative4(appDir, full));
|
|
11649
11659
|
let route = routeDir === "." ? "/" : "/" + routeDir;
|
|
11650
11660
|
route = route.replace(/\/\([^)]+\)/g, "");
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.5.
|
|
6
|
+
"version": "0.5.2",
|
|
7
7
|
"description": "CLI interface for Coherent Design Method",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"main": "./dist/index.js",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"ora": "^7.0.1",
|
|
44
44
|
"prompts": "^2.4.2",
|
|
45
45
|
"zod": "^3.22.4",
|
|
46
|
-
"@getcoherent/core": "0.5.
|
|
46
|
+
"@getcoherent/core": "0.5.2"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@types/node": "^20.11.0",
|