@fragments-sdk/cli 0.9.1 → 0.10.1
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/bin.d.ts +1 -0
- package/dist/bin.js +435 -67
- package/dist/bin.js.map +1 -1
- package/dist/{chunk-D7372LQX.js → chunk-5G3VZH43.js} +8 -12
- package/dist/chunk-5G3VZH43.js.map +1 -0
- package/dist/chunk-D2CDBRNU.js +2 -0
- package/dist/{chunk-YMPGYEWK.js → chunk-D5PYOXEI.js} +2 -2
- package/dist/{chunk-BW3ZATBW.js → chunk-HRFUSSZI.js} +27 -10
- package/dist/chunk-HRFUSSZI.js.map +1 -0
- package/dist/{chunk-GF6OVPIN.js → chunk-OQO55NKV.js} +405 -34
- package/dist/chunk-OQO55NKV.js.map +1 -0
- package/dist/{chunk-TOIE7VXF.js → chunk-PW7QTQA6.js} +2 -2
- package/dist/{chunk-AWYCDRPG.js → chunk-WXSR2II7.js} +2 -2
- package/dist/chunk-WXSR2II7.js.map +1 -0
- package/dist/{chunk-5GT62FCB.js → chunk-ZM4ZQZWZ.js} +5 -5
- package/dist/core/index.d.ts +1 -2194
- package/dist/core/index.js +22 -27
- package/dist/{discovery-Z4RDDFVR.js → discovery-NEOY4MPN.js} +3 -3
- package/dist/{generate-LQA2R7FN.js → generate-FBHSXR3D.js} +5 -7
- package/dist/{generate-LQA2R7FN.js.map → generate-FBHSXR3D.js.map} +1 -1
- package/dist/index.d.ts +3 -5
- package/dist/index.js +7 -9
- package/dist/index.js.map +1 -1
- package/dist/{init-2GEGVIUQ.js → init-NDQXUWDU.js} +58 -6
- package/dist/init-NDQXUWDU.js.map +1 -0
- package/dist/mcp-bin.js +5 -8
- package/dist/mcp-bin.js.map +1 -1
- package/dist/scan-CJF2DOQW.js +14 -0
- package/dist/scan-generate-SJAN5MVI.js +691 -0
- package/dist/scan-generate-SJAN5MVI.js.map +1 -0
- package/dist/{service-XP2EAJXD.js → service-TQYWY65E.js} +4 -6
- package/dist/{static-viewer-XCS7UJTO.js → static-viewer-NUBFPKWH.js} +4 -6
- package/dist/{test-TD6TJNVY.js → test-Z5LVO724.js} +4 -5
- package/dist/{test-TD6TJNVY.js.map → test-Z5LVO724.js.map} +1 -1
- package/dist/{tokens-2EXPCVP3.js → tokens-CE46OTMD.js} +6 -8
- package/dist/{tokens-2EXPCVP3.js.map → tokens-CE46OTMD.js.map} +1 -1
- package/dist/{viewer-RFA2KVBG.js → viewer-DNMNC5VS.js} +16 -19
- package/dist/viewer-DNMNC5VS.js.map +1 -0
- package/package.json +2 -1
- package/src/bin.ts +33 -1
- package/src/build.ts +1 -1
- package/src/commands/__tests__/scan-generate.test.ts +308 -0
- package/src/commands/init.ts +72 -5
- package/src/commands/perf.ts +1 -1
- package/src/commands/scan-generate.ts +1013 -0
- package/src/commands/setup.ts +499 -0
- package/src/core/auto-props.ts +1 -1
- package/src/core/bundle-measurer.ts +2 -2
- package/src/core/config.ts +2 -3
- package/src/core/discovery.ts +2 -2
- package/src/core/generators/context.ts +1 -1
- package/src/core/generators/registry.ts +3 -3
- package/src/core/generators/typescript-extractor.ts +1 -1
- package/src/core/graph-extractor.ts +1 -1
- package/src/core/index.ts +3 -205
- package/src/core/loader.ts +40 -10
- package/src/core/parser.ts +1 -1
- package/src/core/previewLoader.ts +1 -1
- package/src/index.ts +2 -2
- package/src/service/snippet-validation.test.ts +1 -1
- package/src/service/snippet-validation.ts +2 -2
- package/src/viewer/__tests__/viewer-integration.test.ts +3 -9
- package/src/viewer/assets/fragments_logo.png +0 -0
- package/src/viewer/vendor/shared/src/VariantPreviewCard.module.scss +2 -10
- package/src/viewer/vendor/shared/src/VariantPreviewCard.tsx +4 -1
- package/src/viewer/vite-plugin.ts +1 -1
- package/dist/chunk-AWYCDRPG.js.map +0 -1
- package/dist/chunk-BW3ZATBW.js.map +0 -1
- package/dist/chunk-D7372LQX.js.map +0 -1
- package/dist/chunk-EKLMXTWU.js +0 -80
- package/dist/chunk-EKLMXTWU.js.map +0 -1
- package/dist/chunk-EZYXYWNF.js +0 -131
- package/dist/chunk-EZYXYWNF.js.map +0 -1
- package/dist/chunk-GF6OVPIN.js.map +0 -1
- package/dist/chunk-NVSPGSKB.js +0 -203
- package/dist/chunk-NVSPGSKB.js.map +0 -1
- package/dist/defineFragment-CBMS7Bab.d.ts +0 -685
- package/dist/init-2GEGVIUQ.js.map +0 -1
- package/dist/scan-JGS65S7P.js +0 -16
- package/dist/storyFilters-3LUYAFZF.js +0 -15
- package/dist/viewer-RFA2KVBG.js.map +0 -1
- package/src/core/__tests__/preview-runtime.test.tsx +0 -111
- package/src/core/composition.test.ts +0 -262
- package/src/core/composition.ts +0 -318
- package/src/core/constants.ts +0 -114
- package/src/core/context.ts +0 -2
- package/src/core/defineFragment.ts +0 -141
- package/src/core/figma.ts +0 -263
- package/src/core/fragment-types.ts +0 -214
- package/src/core/performance-presets.ts +0 -142
- package/src/core/preview-runtime.tsx +0 -144
- package/src/core/schema.ts +0 -229
- package/src/core/storyAdapter.test.ts +0 -571
- package/src/core/storyAdapter.ts +0 -761
- package/src/core/storyFilters.test.ts +0 -350
- package/src/core/storyFilters.ts +0 -253
- package/src/core/storybook-csf.ts +0 -11
- package/src/core/token-parser.ts +0 -321
- package/src/core/token-types.ts +0 -287
- package/src/core/types.ts +0 -784
- /package/dist/{discovery-Z4RDDFVR.js.map → chunk-D2CDBRNU.js.map} +0 -0
- /package/dist/{chunk-YMPGYEWK.js.map → chunk-D5PYOXEI.js.map} +0 -0
- /package/dist/{chunk-TOIE7VXF.js.map → chunk-PW7QTQA6.js.map} +0 -0
- /package/dist/{chunk-5GT62FCB.js.map → chunk-ZM4ZQZWZ.js.map} +0 -0
- /package/dist/{scan-JGS65S7P.js.map → discovery-NEOY4MPN.js.map} +0 -0
- /package/dist/{service-XP2EAJXD.js.map → scan-CJF2DOQW.js.map} +0 -0
- /package/dist/{static-viewer-XCS7UJTO.js.map → service-TQYWY65E.js.map} +0 -0
- /package/dist/{storyFilters-3LUYAFZF.js.map → static-viewer-NUBFPKWH.js.map} +0 -0
package/dist/bin.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __banner_createRequire } from 'module'; const require = __banner_createRequire(import.meta.url);
|
|
3
|
-
import {
|
|
4
|
-
scan
|
|
5
|
-
} from "./chunk-5GT62FCB.js";
|
|
6
3
|
import {
|
|
7
4
|
buildFragments,
|
|
8
5
|
buildFragmentsDir,
|
|
@@ -15,14 +12,17 @@ import {
|
|
|
15
12
|
validateCoverage,
|
|
16
13
|
validateSchema,
|
|
17
14
|
validateSnippets
|
|
18
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-5G3VZH43.js";
|
|
16
|
+
import {
|
|
17
|
+
scan
|
|
18
|
+
} from "./chunk-ZM4ZQZWZ.js";
|
|
19
19
|
import {
|
|
20
20
|
loadConfig,
|
|
21
21
|
loadFragmentFile
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-HRFUSSZI.js";
|
|
23
23
|
import {
|
|
24
24
|
discoverFragmentFiles
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-WXSR2II7.js";
|
|
26
26
|
import {
|
|
27
27
|
FigmaClient,
|
|
28
28
|
StorageManager,
|
|
@@ -38,26 +38,23 @@ import {
|
|
|
38
38
|
renderAllComponentVariants,
|
|
39
39
|
scanCodebase,
|
|
40
40
|
shutdownSharedPool
|
|
41
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-D5PYOXEI.js";
|
|
42
|
+
import "./chunk-D2CDBRNU.js";
|
|
42
43
|
import {
|
|
44
|
+
BRAND,
|
|
43
45
|
budgetBar,
|
|
44
46
|
formatBytes,
|
|
45
47
|
generateContext,
|
|
46
48
|
resolvePerformanceConfig
|
|
47
|
-
} from "./chunk-
|
|
48
|
-
import "./chunk-NVSPGSKB.js";
|
|
49
|
-
import "./chunk-EZYXYWNF.js";
|
|
50
|
-
import {
|
|
51
|
-
BRAND
|
|
52
|
-
} from "./chunk-EKLMXTWU.js";
|
|
49
|
+
} from "./chunk-OQO55NKV.js";
|
|
53
50
|
import "./chunk-Z7EY4VHE.js";
|
|
54
51
|
|
|
55
52
|
// src/bin.ts
|
|
56
53
|
import { Command } from "commander";
|
|
57
|
-
import
|
|
54
|
+
import pc24 from "picocolors";
|
|
58
55
|
import { readFileSync } from "fs";
|
|
59
56
|
import { fileURLToPath } from "url";
|
|
60
|
-
import { dirname as
|
|
57
|
+
import { dirname as dirname5, join as join12 } from "path";
|
|
61
58
|
|
|
62
59
|
// src/commands/validate.ts
|
|
63
60
|
import pc from "picocolors";
|
|
@@ -1861,7 +1858,7 @@ ${BRAND.name} Dev Server
|
|
|
1861
1858
|
}
|
|
1862
1859
|
}
|
|
1863
1860
|
}
|
|
1864
|
-
const { createDevServer } = await import("./viewer-
|
|
1861
|
+
const { createDevServer } = await import("./viewer-DNMNC5VS.js");
|
|
1865
1862
|
console.log(pc7.dim("\nStarting dev server..."));
|
|
1866
1863
|
const parsedPort = typeof port === "string" ? parseInt(port, 10) : port;
|
|
1867
1864
|
try {
|
|
@@ -5788,9 +5785,362 @@ ${BRAND.name} Doctor
|
|
|
5788
5785
|
return result;
|
|
5789
5786
|
}
|
|
5790
5787
|
|
|
5788
|
+
// src/commands/setup.ts
|
|
5789
|
+
import { readFile as readFile9, writeFile as writeFile9, access as access4, mkdir as mkdir7 } from "fs/promises";
|
|
5790
|
+
import { join as join11, resolve as resolve9, dirname as dirname4 } from "path";
|
|
5791
|
+
import pc23 from "picocolors";
|
|
5792
|
+
async function fileExists(path) {
|
|
5793
|
+
try {
|
|
5794
|
+
await access4(path);
|
|
5795
|
+
return true;
|
|
5796
|
+
} catch {
|
|
5797
|
+
return false;
|
|
5798
|
+
}
|
|
5799
|
+
}
|
|
5800
|
+
async function detectFramework(root) {
|
|
5801
|
+
if (await fileExists(join11(root, "app/layout.tsx")) || await fileExists(join11(root, "src/app/layout.tsx"))) {
|
|
5802
|
+
return "nextjs-app";
|
|
5803
|
+
}
|
|
5804
|
+
if (await fileExists(join11(root, "pages/_app.tsx")) || await fileExists(join11(root, "pages/_app.ts"))) {
|
|
5805
|
+
return "nextjs-pages";
|
|
5806
|
+
}
|
|
5807
|
+
if (await fileExists(join11(root, "next.config.ts")) || await fileExists(join11(root, "next.config.js")) || await fileExists(join11(root, "next.config.mjs"))) {
|
|
5808
|
+
return "nextjs-app";
|
|
5809
|
+
}
|
|
5810
|
+
if (await fileExists(join11(root, "vite.config.ts")) || await fileExists(join11(root, "vite.config.js"))) {
|
|
5811
|
+
return "vite";
|
|
5812
|
+
}
|
|
5813
|
+
return "unknown";
|
|
5814
|
+
}
|
|
5815
|
+
async function findEntryFile(root, framework) {
|
|
5816
|
+
const candidates = [];
|
|
5817
|
+
switch (framework) {
|
|
5818
|
+
case "nextjs-app":
|
|
5819
|
+
candidates.push(
|
|
5820
|
+
"src/app/layout.tsx",
|
|
5821
|
+
"app/layout.tsx",
|
|
5822
|
+
"src/app/layout.ts",
|
|
5823
|
+
"app/layout.ts"
|
|
5824
|
+
);
|
|
5825
|
+
break;
|
|
5826
|
+
case "nextjs-pages":
|
|
5827
|
+
candidates.push("pages/_app.tsx", "pages/_app.ts");
|
|
5828
|
+
break;
|
|
5829
|
+
case "vite":
|
|
5830
|
+
candidates.push(
|
|
5831
|
+
"src/main.tsx",
|
|
5832
|
+
"src/main.ts",
|
|
5833
|
+
"src/index.tsx",
|
|
5834
|
+
"src/index.ts"
|
|
5835
|
+
);
|
|
5836
|
+
break;
|
|
5837
|
+
default:
|
|
5838
|
+
candidates.push(
|
|
5839
|
+
"src/main.tsx",
|
|
5840
|
+
"src/main.ts",
|
|
5841
|
+
"src/index.tsx",
|
|
5842
|
+
"src/index.ts",
|
|
5843
|
+
"src/App.tsx",
|
|
5844
|
+
"src/App.ts"
|
|
5845
|
+
);
|
|
5846
|
+
}
|
|
5847
|
+
for (const candidate of candidates) {
|
|
5848
|
+
if (await fileExists(join11(root, candidate))) {
|
|
5849
|
+
return candidate;
|
|
5850
|
+
}
|
|
5851
|
+
}
|
|
5852
|
+
return null;
|
|
5853
|
+
}
|
|
5854
|
+
async function findNextConfig(root) {
|
|
5855
|
+
const candidates = ["next.config.ts", "next.config.mjs", "next.config.js"];
|
|
5856
|
+
for (const candidate of candidates) {
|
|
5857
|
+
if (await fileExists(join11(root, candidate))) {
|
|
5858
|
+
return candidate;
|
|
5859
|
+
}
|
|
5860
|
+
}
|
|
5861
|
+
return null;
|
|
5862
|
+
}
|
|
5863
|
+
async function addStylesImport(root, entryFile) {
|
|
5864
|
+
const fullPath = join11(root, entryFile);
|
|
5865
|
+
const content = await readFile9(fullPath, "utf-8");
|
|
5866
|
+
if (content.includes("@fragments-sdk/ui/styles")) {
|
|
5867
|
+
return { modified: false, message: `Styles already imported in ${entryFile}` };
|
|
5868
|
+
}
|
|
5869
|
+
const stylesImport = "import '@fragments-sdk/ui/styles';";
|
|
5870
|
+
let newContent;
|
|
5871
|
+
if (content.startsWith("'use client'") || content.startsWith('"use client"')) {
|
|
5872
|
+
const directiveEnd = content.indexOf("\n") + 1;
|
|
5873
|
+
newContent = content.slice(0, directiveEnd) + stylesImport + "\n" + content.slice(directiveEnd);
|
|
5874
|
+
} else {
|
|
5875
|
+
newContent = stylesImport + "\n" + content;
|
|
5876
|
+
}
|
|
5877
|
+
await writeFile9(fullPath, newContent, "utf-8");
|
|
5878
|
+
return { modified: true, message: `Added styles import to ${entryFile}` };
|
|
5879
|
+
}
|
|
5880
|
+
async function addThemeProvider(root, entryFile, framework) {
|
|
5881
|
+
const fullPath = join11(root, entryFile);
|
|
5882
|
+
const content = await readFile9(fullPath, "utf-8");
|
|
5883
|
+
if (content.includes("ThemeProvider")) {
|
|
5884
|
+
return { modified: false, message: `ThemeProvider already present in ${entryFile}` };
|
|
5885
|
+
}
|
|
5886
|
+
if (framework === "nextjs-app") {
|
|
5887
|
+
const providerImport = "import { ThemeProvider, TooltipProvider, ToastProvider } from '@fragments-sdk/ui';";
|
|
5888
|
+
let newContent = content;
|
|
5889
|
+
const importLines = content.split("\n");
|
|
5890
|
+
let lastImportIdx = -1;
|
|
5891
|
+
for (let i = 0; i < importLines.length; i++) {
|
|
5892
|
+
if (importLines[i].startsWith("import ") || importLines[i].startsWith("import '") || importLines[i].startsWith('import "')) {
|
|
5893
|
+
lastImportIdx = i;
|
|
5894
|
+
}
|
|
5895
|
+
}
|
|
5896
|
+
if (lastImportIdx >= 0) {
|
|
5897
|
+
importLines.splice(lastImportIdx + 1, 0, providerImport);
|
|
5898
|
+
newContent = importLines.join("\n");
|
|
5899
|
+
} else {
|
|
5900
|
+
newContent = providerImport + "\n" + content;
|
|
5901
|
+
}
|
|
5902
|
+
if (!content.includes("suppressHydrationWarning")) {
|
|
5903
|
+
await writeFile9(fullPath, newContent, "utf-8");
|
|
5904
|
+
return {
|
|
5905
|
+
modified: true,
|
|
5906
|
+
message: `Added provider imports to ${entryFile}. Wrap your {children} with:
|
|
5907
|
+
<ThemeProvider defaultMode="system"><TooltipProvider><ToastProvider>{children}</ToastProvider></TooltipProvider></ThemeProvider>
|
|
5908
|
+
Add suppressHydrationWarning to your <html> tag`
|
|
5909
|
+
};
|
|
5910
|
+
}
|
|
5911
|
+
await writeFile9(fullPath, newContent, "utf-8");
|
|
5912
|
+
return { modified: true, message: `Added provider imports to ${entryFile}. Wrap {children} with ThemeProvider.` };
|
|
5913
|
+
}
|
|
5914
|
+
return { modified: false, message: "Manual ThemeProvider setup needed \u2014 see https://usefragments.com/getting-started#provider-setup" };
|
|
5915
|
+
}
|
|
5916
|
+
async function addTranspilePackages(root) {
|
|
5917
|
+
const configFile = await findNextConfig(root);
|
|
5918
|
+
if (!configFile) {
|
|
5919
|
+
return { modified: false, message: "No next.config found" };
|
|
5920
|
+
}
|
|
5921
|
+
const fullPath = join11(root, configFile);
|
|
5922
|
+
const content = await readFile9(fullPath, "utf-8");
|
|
5923
|
+
if (content.includes("transpilePackages") && content.includes("@fragments-sdk/ui")) {
|
|
5924
|
+
return { modified: false, message: `transpilePackages already configured in ${configFile}` };
|
|
5925
|
+
}
|
|
5926
|
+
if (content.includes("transpilePackages")) {
|
|
5927
|
+
return {
|
|
5928
|
+
modified: false,
|
|
5929
|
+
message: `transpilePackages found in ${configFile} but missing '@fragments-sdk/ui'. Please add it manually.`
|
|
5930
|
+
};
|
|
5931
|
+
}
|
|
5932
|
+
const patterns = [
|
|
5933
|
+
// const nextConfig = { ... }
|
|
5934
|
+
{ search: /const\s+\w+\s*=\s*\{/, replacement: (match) => `${match}
|
|
5935
|
+
transpilePackages: ['@fragments-sdk/ui'],` },
|
|
5936
|
+
// module.exports = { ... }
|
|
5937
|
+
{ search: /module\.exports\s*=\s*\{/, replacement: (match) => `${match}
|
|
5938
|
+
transpilePackages: ['@fragments-sdk/ui'],` },
|
|
5939
|
+
// export default { ... }
|
|
5940
|
+
{ search: /export\s+default\s*\{/, replacement: (match) => `${match}
|
|
5941
|
+
transpilePackages: ['@fragments-sdk/ui'],` }
|
|
5942
|
+
];
|
|
5943
|
+
for (const pattern of patterns) {
|
|
5944
|
+
if (pattern.search.test(content)) {
|
|
5945
|
+
const newContent = content.replace(pattern.search, pattern.replacement);
|
|
5946
|
+
await writeFile9(fullPath, newContent, "utf-8");
|
|
5947
|
+
return { modified: true, message: `Added transpilePackages to ${configFile}` };
|
|
5948
|
+
}
|
|
5949
|
+
}
|
|
5950
|
+
return {
|
|
5951
|
+
modified: false,
|
|
5952
|
+
message: `Could not auto-modify ${configFile}. Add transpilePackages: ['@fragments-sdk/ui'] manually.`
|
|
5953
|
+
};
|
|
5954
|
+
}
|
|
5955
|
+
async function createScssSeeds(root, brand) {
|
|
5956
|
+
const scssLocations = [
|
|
5957
|
+
"src/app/globals.scss",
|
|
5958
|
+
"app/globals.scss",
|
|
5959
|
+
"src/styles/globals.scss",
|
|
5960
|
+
"src/globals.scss",
|
|
5961
|
+
"styles/globals.scss"
|
|
5962
|
+
];
|
|
5963
|
+
for (const loc of scssLocations) {
|
|
5964
|
+
const fullPath2 = join11(root, loc);
|
|
5965
|
+
if (await fileExists(fullPath2)) {
|
|
5966
|
+
const content = await readFile9(fullPath2, "utf-8");
|
|
5967
|
+
if (content.includes("@fragments-sdk/ui/styles")) {
|
|
5968
|
+
return { modified: false, message: `SCSS seeds already configured in ${loc}` };
|
|
5969
|
+
}
|
|
5970
|
+
const seedContent = generateScssSeedImport(brand);
|
|
5971
|
+
const newContent = seedContent + "\n" + content;
|
|
5972
|
+
await writeFile9(fullPath2, newContent, "utf-8");
|
|
5973
|
+
return { modified: true, message: `Added SCSS seed import to ${loc}` };
|
|
5974
|
+
}
|
|
5975
|
+
}
|
|
5976
|
+
const targetDir = await fileExists(join11(root, "src/app")) ? "src/app" : await fileExists(join11(root, "src")) ? "src/styles" : "styles";
|
|
5977
|
+
const targetPath = join11(targetDir, "globals.scss");
|
|
5978
|
+
const fullPath = join11(root, targetPath);
|
|
5979
|
+
await mkdir7(dirname4(fullPath), { recursive: true });
|
|
5980
|
+
await writeFile9(fullPath, generateScssSeedImport(brand), "utf-8");
|
|
5981
|
+
return { modified: true, message: `Created ${targetPath} with SCSS seed configuration` };
|
|
5982
|
+
}
|
|
5983
|
+
async function setupMcpConfig(root) {
|
|
5984
|
+
const mcpConfigPaths = [
|
|
5985
|
+
".cursor/mcp.json",
|
|
5986
|
+
".vscode/mcp.json"
|
|
5987
|
+
];
|
|
5988
|
+
for (const configPath of mcpConfigPaths) {
|
|
5989
|
+
const fullPath = join11(root, configPath);
|
|
5990
|
+
if (await fileExists(fullPath)) {
|
|
5991
|
+
try {
|
|
5992
|
+
const content = await readFile9(fullPath, "utf-8");
|
|
5993
|
+
const config = JSON.parse(content);
|
|
5994
|
+
const servers = config.mcpServers || {};
|
|
5995
|
+
const hasFragments = Object.values(servers).some((server) => {
|
|
5996
|
+
const s = server;
|
|
5997
|
+
return s.args?.some((arg) => arg.includes("@fragments-sdk/mcp"));
|
|
5998
|
+
});
|
|
5999
|
+
if (hasFragments) {
|
|
6000
|
+
return { modified: false, message: `MCP server already configured in ${configPath}` };
|
|
6001
|
+
}
|
|
6002
|
+
servers.fragments = {
|
|
6003
|
+
command: "npx",
|
|
6004
|
+
args: ["@fragments-sdk/mcp"]
|
|
6005
|
+
};
|
|
6006
|
+
config.mcpServers = servers;
|
|
6007
|
+
await writeFile9(fullPath, JSON.stringify(config, null, 2) + "\n", "utf-8");
|
|
6008
|
+
return { modified: true, message: `Added Fragments MCP server to ${configPath}` };
|
|
6009
|
+
} catch {
|
|
6010
|
+
return { modified: false, message: `Could not parse ${configPath}` };
|
|
6011
|
+
}
|
|
6012
|
+
}
|
|
6013
|
+
}
|
|
6014
|
+
const cursorDir = join11(root, ".cursor");
|
|
6015
|
+
const cursorMcpPath = join11(cursorDir, "mcp.json");
|
|
6016
|
+
await mkdir7(cursorDir, { recursive: true });
|
|
6017
|
+
const mcpConfig = {
|
|
6018
|
+
mcpServers: {
|
|
6019
|
+
fragments: {
|
|
6020
|
+
command: "npx",
|
|
6021
|
+
args: ["@fragments-sdk/mcp"]
|
|
6022
|
+
}
|
|
6023
|
+
}
|
|
6024
|
+
};
|
|
6025
|
+
await writeFile9(cursorMcpPath, JSON.stringify(mcpConfig, null, 2) + "\n", "utf-8");
|
|
6026
|
+
return { modified: true, message: "Created .cursor/mcp.json with Fragments MCP server" };
|
|
6027
|
+
}
|
|
6028
|
+
function generateScssSeedImport(brand) {
|
|
6029
|
+
const brandColor = brand || "#0066ff";
|
|
6030
|
+
return `@use '@fragments-sdk/ui/styles' with (
|
|
6031
|
+
$fui-brand: ${brandColor},
|
|
6032
|
+
$fui-neutral: "stone",
|
|
6033
|
+
$fui-density: "default",
|
|
6034
|
+
$fui-radius-style: "rounded"
|
|
6035
|
+
);
|
|
6036
|
+
`;
|
|
6037
|
+
}
|
|
6038
|
+
async function setup(options = {}) {
|
|
6039
|
+
const root = resolve9(options.root ?? process.cwd());
|
|
6040
|
+
const actions = [];
|
|
6041
|
+
const errors = [];
|
|
6042
|
+
console.log(pc23.cyan(`
|
|
6043
|
+
${BRAND.name} Setup
|
|
6044
|
+
`));
|
|
6045
|
+
const framework = await detectFramework(root);
|
|
6046
|
+
const frameworkLabel = framework === "nextjs-app" ? "Next.js (App Router)" : framework === "nextjs-pages" ? "Next.js (Pages Router)" : framework === "vite" ? "Vite" : "Unknown";
|
|
6047
|
+
console.log(` ${pc23.dim("Framework:")} ${frameworkLabel}`);
|
|
6048
|
+
const entryFile = await findEntryFile(root, framework);
|
|
6049
|
+
if (entryFile) {
|
|
6050
|
+
console.log(` ${pc23.dim("Entry:")} ${entryFile}`);
|
|
6051
|
+
} else {
|
|
6052
|
+
console.log(` ${pc23.yellow("!")} Could not detect entry file`);
|
|
6053
|
+
}
|
|
6054
|
+
console.log();
|
|
6055
|
+
if (entryFile) {
|
|
6056
|
+
try {
|
|
6057
|
+
const result = await addStylesImport(root, entryFile);
|
|
6058
|
+
const icon = result.modified ? pc23.green("+") : pc23.dim("\xB7");
|
|
6059
|
+
console.log(` ${icon} ${result.message}`);
|
|
6060
|
+
if (result.modified) actions.push(result.message);
|
|
6061
|
+
} catch (error) {
|
|
6062
|
+
const msg = `Failed to add styles import: ${error instanceof Error ? error.message : error}`;
|
|
6063
|
+
console.log(` ${pc23.red("\u2717")} ${msg}`);
|
|
6064
|
+
errors.push(msg);
|
|
6065
|
+
}
|
|
6066
|
+
}
|
|
6067
|
+
if (entryFile) {
|
|
6068
|
+
try {
|
|
6069
|
+
const result = await addThemeProvider(root, entryFile, framework);
|
|
6070
|
+
const icon = result.modified ? pc23.green("+") : pc23.dim("\xB7");
|
|
6071
|
+
console.log(` ${icon} ${result.message}`);
|
|
6072
|
+
if (result.modified) actions.push(result.message);
|
|
6073
|
+
} catch (error) {
|
|
6074
|
+
const msg = `Failed to add ThemeProvider: ${error instanceof Error ? error.message : error}`;
|
|
6075
|
+
console.log(` ${pc23.red("\u2717")} ${msg}`);
|
|
6076
|
+
errors.push(msg);
|
|
6077
|
+
}
|
|
6078
|
+
}
|
|
6079
|
+
if (framework === "nextjs-app" || framework === "nextjs-pages") {
|
|
6080
|
+
try {
|
|
6081
|
+
const result = await addTranspilePackages(root);
|
|
6082
|
+
const icon = result.modified ? pc23.green("+") : pc23.dim("\xB7");
|
|
6083
|
+
console.log(` ${icon} ${result.message}`);
|
|
6084
|
+
if (result.modified) actions.push(result.message);
|
|
6085
|
+
} catch (error) {
|
|
6086
|
+
const msg = `Failed to update next.config: ${error instanceof Error ? error.message : error}`;
|
|
6087
|
+
console.log(` ${pc23.red("\u2717")} ${msg}`);
|
|
6088
|
+
errors.push(msg);
|
|
6089
|
+
}
|
|
6090
|
+
}
|
|
6091
|
+
if (options.scss || options.brand) {
|
|
6092
|
+
try {
|
|
6093
|
+
const result = await createScssSeeds(root, options.brand);
|
|
6094
|
+
const icon = result.modified ? pc23.green("+") : pc23.dim("\xB7");
|
|
6095
|
+
console.log(` ${icon} ${result.message}`);
|
|
6096
|
+
if (result.modified) actions.push(result.message);
|
|
6097
|
+
} catch (error) {
|
|
6098
|
+
const msg = `Failed to create SCSS seeds: ${error instanceof Error ? error.message : error}`;
|
|
6099
|
+
console.log(` ${pc23.red("\u2717")} ${msg}`);
|
|
6100
|
+
errors.push(msg);
|
|
6101
|
+
}
|
|
6102
|
+
}
|
|
6103
|
+
if (options.mcp) {
|
|
6104
|
+
try {
|
|
6105
|
+
const result = await setupMcpConfig(root);
|
|
6106
|
+
const icon = result.modified ? pc23.green("+") : pc23.dim("\xB7");
|
|
6107
|
+
console.log(` ${icon} ${result.message}`);
|
|
6108
|
+
if (result.modified) actions.push(result.message);
|
|
6109
|
+
} catch (error) {
|
|
6110
|
+
const msg = `Failed to configure MCP: ${error instanceof Error ? error.message : error}`;
|
|
6111
|
+
console.log(` ${pc23.red("\u2717")} ${msg}`);
|
|
6112
|
+
errors.push(msg);
|
|
6113
|
+
}
|
|
6114
|
+
}
|
|
6115
|
+
console.log();
|
|
6116
|
+
if (errors.length > 0) {
|
|
6117
|
+
console.log(pc23.red(` ${errors.length} error(s) occurred during setup`));
|
|
6118
|
+
} else if (actions.length > 0) {
|
|
6119
|
+
console.log(pc23.green(` \u2713 Setup complete \u2014 ${actions.length} file(s) modified`));
|
|
6120
|
+
} else {
|
|
6121
|
+
console.log(pc23.green(" \u2713 Already configured \u2014 no changes needed"));
|
|
6122
|
+
}
|
|
6123
|
+
console.log();
|
|
6124
|
+
console.log(pc23.dim(" Next steps:"));
|
|
6125
|
+
if (!options.scss && !options.brand) {
|
|
6126
|
+
console.log(pc23.dim(" \u2022 Run with --scss to add build-time theme seeds"));
|
|
6127
|
+
}
|
|
6128
|
+
if (!options.mcp) {
|
|
6129
|
+
console.log(pc23.dim(" \u2022 Run with --mcp to configure AI tooling (MCP server)"));
|
|
6130
|
+
}
|
|
6131
|
+
console.log(pc23.dim(" \u2022 Run `fragments doctor` to verify your setup"));
|
|
6132
|
+
console.log(pc23.dim(" \u2022 Visit https://usefragments.com/getting-started"));
|
|
6133
|
+
console.log();
|
|
6134
|
+
return {
|
|
6135
|
+
success: errors.length === 0,
|
|
6136
|
+
actions,
|
|
6137
|
+
errors
|
|
6138
|
+
};
|
|
6139
|
+
}
|
|
6140
|
+
|
|
5791
6141
|
// src/bin.ts
|
|
5792
|
-
var __dirname =
|
|
5793
|
-
var pkg = JSON.parse(readFileSync(
|
|
6142
|
+
var __dirname = dirname5(fileURLToPath(import.meta.url));
|
|
6143
|
+
var pkg = JSON.parse(readFileSync(join12(__dirname, "../package.json"), "utf-8"));
|
|
5794
6144
|
var program = new Command();
|
|
5795
6145
|
program.name(BRAND.cliCommand).description(`${BRAND.name} - Design system documentation and compliance tool`).version(pkg.version);
|
|
5796
6146
|
program.command("validate").description("Validate fragment files").option("-c, --config <path>", "Path to config file").option("--schema", "Validate fragment schema only").option("--coverage", "Validate coverage only").option("--snippets", "Validate snippet/render policy only").option("--snippet-mode <mode>", "Override snippet policy mode (warn|error)").option("--component-start <name>", "Start component name for alphabetical snippet batch validation").option("--component-limit <n>", "Component count for alphabetical snippet batch validation", (value) => Number.parseInt(value, 10)).action(async (options) => {
|
|
@@ -5800,7 +6150,7 @@ program.command("validate").description("Validate fragment files").option("-c, -
|
|
|
5800
6150
|
process.exit(1);
|
|
5801
6151
|
}
|
|
5802
6152
|
} catch (error) {
|
|
5803
|
-
console.error(
|
|
6153
|
+
console.error(pc24.red("Error:"), error instanceof Error ? error.message : error);
|
|
5804
6154
|
process.exit(1);
|
|
5805
6155
|
}
|
|
5806
6156
|
});
|
|
@@ -5820,7 +6170,7 @@ program.command("build").description(`Build compiled ${BRAND.outFile} and ${BRAN
|
|
|
5820
6170
|
process.exit(1);
|
|
5821
6171
|
}
|
|
5822
6172
|
} catch (error) {
|
|
5823
|
-
console.error(
|
|
6173
|
+
console.error(pc24.red("Error:"), error instanceof Error ? error.message : error);
|
|
5824
6174
|
process.exit(1);
|
|
5825
6175
|
}
|
|
5826
6176
|
});
|
|
@@ -5839,7 +6189,7 @@ program.command("context").description("Generate AI-ready context for your desig
|
|
|
5839
6189
|
process.exit(1);
|
|
5840
6190
|
}
|
|
5841
6191
|
} catch (error) {
|
|
5842
|
-
console.error(
|
|
6192
|
+
console.error(pc24.red("Error:"), error instanceof Error ? error.message : error);
|
|
5843
6193
|
process.exit(1);
|
|
5844
6194
|
}
|
|
5845
6195
|
});
|
|
@@ -5866,7 +6216,7 @@ program.command("ai").description("Generate context optimized for AI assistants
|
|
|
5866
6216
|
}
|
|
5867
6217
|
}
|
|
5868
6218
|
} catch (error) {
|
|
5869
|
-
console.error(
|
|
6219
|
+
console.error(pc24.red("Error:"), error instanceof Error ? error.message : error);
|
|
5870
6220
|
process.exit(1);
|
|
5871
6221
|
}
|
|
5872
6222
|
});
|
|
@@ -5874,7 +6224,7 @@ program.command("list").description("List all discovered fragment files").option
|
|
|
5874
6224
|
try {
|
|
5875
6225
|
await list(options);
|
|
5876
6226
|
} catch (error) {
|
|
5877
|
-
console.error(
|
|
6227
|
+
console.error(pc24.red("Error:"), error instanceof Error ? error.message : error);
|
|
5878
6228
|
process.exit(1);
|
|
5879
6229
|
}
|
|
5880
6230
|
});
|
|
@@ -5882,7 +6232,7 @@ program.command("reset").description("Reset to initial state (delete all generat
|
|
|
5882
6232
|
try {
|
|
5883
6233
|
await reset(options);
|
|
5884
6234
|
} catch (error) {
|
|
5885
|
-
console.error(
|
|
6235
|
+
console.error(pc24.red("Error:"), error instanceof Error ? error.message : error);
|
|
5886
6236
|
process.exit(1);
|
|
5887
6237
|
}
|
|
5888
6238
|
});
|
|
@@ -5896,7 +6246,7 @@ linkCommand.command("figma").argument("[figma-url]", "Figma file URL to link com
|
|
|
5896
6246
|
variants: options.variants
|
|
5897
6247
|
});
|
|
5898
6248
|
} catch (error) {
|
|
5899
|
-
console.error(
|
|
6249
|
+
console.error(pc24.red("Error:"), error instanceof Error ? error.message : error);
|
|
5900
6250
|
process.exit(1);
|
|
5901
6251
|
}
|
|
5902
6252
|
});
|
|
@@ -5911,7 +6261,7 @@ linkCommand.command("storybook").description("Bootstrap fragments from existing
|
|
|
5911
6261
|
exclude: options.exclude
|
|
5912
6262
|
});
|
|
5913
6263
|
} catch (error) {
|
|
5914
|
-
console.error(
|
|
6264
|
+
console.error(pc24.red("Error:"), error instanceof Error ? error.message : error);
|
|
5915
6265
|
process.exit(1);
|
|
5916
6266
|
}
|
|
5917
6267
|
});
|
|
@@ -5926,9 +6276,9 @@ program.command("dev").description("Start the development server with live compo
|
|
|
5926
6276
|
skipBuild: options.skipBuild
|
|
5927
6277
|
});
|
|
5928
6278
|
} catch (error) {
|
|
5929
|
-
console.error(
|
|
6279
|
+
console.error(pc24.red("Error:"), error instanceof Error ? error.message : error);
|
|
5930
6280
|
if (error instanceof Error && error.stack) {
|
|
5931
|
-
console.error(
|
|
6281
|
+
console.error(pc24.dim(error.stack));
|
|
5932
6282
|
}
|
|
5933
6283
|
process.exit(1);
|
|
5934
6284
|
}
|
|
@@ -5949,7 +6299,7 @@ program.command("screenshot").description("Capture screenshots of component vari
|
|
|
5949
6299
|
process.exit(1);
|
|
5950
6300
|
}
|
|
5951
6301
|
} catch (error) {
|
|
5952
|
-
console.error(
|
|
6302
|
+
console.error(pc24.red("Error:"), error instanceof Error ? error.message : error);
|
|
5953
6303
|
process.exit(1);
|
|
5954
6304
|
}
|
|
5955
6305
|
});
|
|
@@ -5968,7 +6318,7 @@ program.command("diff").argument("[component]", "Component name to diff (optiona
|
|
|
5968
6318
|
process.exit(1);
|
|
5969
6319
|
}
|
|
5970
6320
|
} catch (error) {
|
|
5971
|
-
console.error(
|
|
6321
|
+
console.error(pc24.red("Error:"), error instanceof Error ? error.message : error);
|
|
5972
6322
|
process.exit(1);
|
|
5973
6323
|
}
|
|
5974
6324
|
});
|
|
@@ -5987,8 +6337,8 @@ program.command("compare").argument("[component]", "Component name to compare").
|
|
|
5987
6337
|
process.exit(1);
|
|
5988
6338
|
}
|
|
5989
6339
|
} catch (error) {
|
|
5990
|
-
console.error(
|
|
5991
|
-
console.log(
|
|
6340
|
+
console.error(pc24.red("Error:"), error instanceof Error ? error.message : error);
|
|
6341
|
+
console.log(pc24.dim(`
|
|
5992
6342
|
Make sure the dev server is running: ${BRAND.cliCommand} dev`));
|
|
5993
6343
|
process.exit(1);
|
|
5994
6344
|
}
|
|
@@ -6007,7 +6357,7 @@ program.command("analyze").description("Analyze design system and generate repor
|
|
|
6007
6357
|
process.exit(1);
|
|
6008
6358
|
}
|
|
6009
6359
|
} catch (error) {
|
|
6010
|
-
console.error(
|
|
6360
|
+
console.error(pc24.red("Error:"), error instanceof Error ? error.message : error);
|
|
6011
6361
|
process.exit(1);
|
|
6012
6362
|
}
|
|
6013
6363
|
});
|
|
@@ -6026,7 +6376,7 @@ program.command("verify").argument("[component]", "Component name to verify (opt
|
|
|
6026
6376
|
if (options.ci) {
|
|
6027
6377
|
console.log(JSON.stringify({ error: error instanceof Error ? error.message : "Verification failed" }));
|
|
6028
6378
|
} else {
|
|
6029
|
-
console.error(
|
|
6379
|
+
console.error(pc24.red("Error:"), error instanceof Error ? error.message : error);
|
|
6030
6380
|
}
|
|
6031
6381
|
process.exit(1);
|
|
6032
6382
|
}
|
|
@@ -6043,7 +6393,7 @@ program.command("audit").description("Scan all fragments and show compliance met
|
|
|
6043
6393
|
if (options.json) {
|
|
6044
6394
|
console.log(JSON.stringify({ error: error instanceof Error ? error.message : "Audit failed" }));
|
|
6045
6395
|
} else {
|
|
6046
|
-
console.error(
|
|
6396
|
+
console.error(pc24.red("Error:"), error instanceof Error ? error.message : error);
|
|
6047
6397
|
}
|
|
6048
6398
|
process.exit(1);
|
|
6049
6399
|
}
|
|
@@ -6065,7 +6415,7 @@ program.command("a11y").description("Run accessibility checks on all component v
|
|
|
6065
6415
|
if (options.json) {
|
|
6066
6416
|
console.log(JSON.stringify({ error: error instanceof Error ? error.message : "A11y check failed" }));
|
|
6067
6417
|
} else {
|
|
6068
|
-
console.error(
|
|
6418
|
+
console.error(pc24.red("Error:"), error instanceof Error ? error.message : error);
|
|
6069
6419
|
}
|
|
6070
6420
|
process.exit(1);
|
|
6071
6421
|
}
|
|
@@ -6088,7 +6438,7 @@ program.command("enhance").description("AI-powered documentation generation from
|
|
|
6088
6438
|
if (options.format === "json") {
|
|
6089
6439
|
console.log(JSON.stringify({ success: false, error: error instanceof Error ? error.message : "Enhance failed" }));
|
|
6090
6440
|
} else {
|
|
6091
|
-
console.error(
|
|
6441
|
+
console.error(pc24.red("Error:"), error instanceof Error ? error.message : error);
|
|
6092
6442
|
}
|
|
6093
6443
|
process.exit(1);
|
|
6094
6444
|
}
|
|
@@ -6109,7 +6459,7 @@ program.command("scan").description(`Zero-config ${BRAND.outFile} generation fro
|
|
|
6109
6459
|
process.exit(1);
|
|
6110
6460
|
}
|
|
6111
6461
|
} catch (error) {
|
|
6112
|
-
console.error(
|
|
6462
|
+
console.error(pc24.red("Error:"), error instanceof Error ? error.message : error);
|
|
6113
6463
|
process.exit(1);
|
|
6114
6464
|
}
|
|
6115
6465
|
});
|
|
@@ -6122,7 +6472,7 @@ program.command("storygen").description("Generate Storybook stories from fragmen
|
|
|
6122
6472
|
format: options.format
|
|
6123
6473
|
});
|
|
6124
6474
|
} catch (error) {
|
|
6125
|
-
console.error(
|
|
6475
|
+
console.error(pc24.red("Error:"), error instanceof Error ? error.message : error);
|
|
6126
6476
|
process.exit(1);
|
|
6127
6477
|
}
|
|
6128
6478
|
});
|
|
@@ -6134,7 +6484,7 @@ program.command("metrics").argument("[component]", "Component name (optional, sh
|
|
|
6134
6484
|
json: options.json
|
|
6135
6485
|
});
|
|
6136
6486
|
} catch (error) {
|
|
6137
|
-
console.error(
|
|
6487
|
+
console.error(pc24.red("Error:"), error instanceof Error ? error.message : error);
|
|
6138
6488
|
process.exit(1);
|
|
6139
6489
|
}
|
|
6140
6490
|
});
|
|
@@ -6148,9 +6498,9 @@ program.command("baseline").description("Manage visual regression baselines").ar
|
|
|
6148
6498
|
port: options.port
|
|
6149
6499
|
});
|
|
6150
6500
|
} catch (error) {
|
|
6151
|
-
console.error(
|
|
6501
|
+
console.error(pc24.red("Error:"), error instanceof Error ? error.message : error);
|
|
6152
6502
|
if (action === "update") {
|
|
6153
|
-
console.log(
|
|
6503
|
+
console.log(pc24.dim(`
|
|
6154
6504
|
Make sure the dev server is running: ${BRAND.cliCommand} dev`));
|
|
6155
6505
|
}
|
|
6156
6506
|
process.exit(1);
|
|
@@ -6158,27 +6508,27 @@ Make sure the dev server is running: ${BRAND.cliCommand} dev`));
|
|
|
6158
6508
|
});
|
|
6159
6509
|
program.command("view").description(`Generate a static HTML viewer for ${BRAND.outFile}`).option("-i, --input <path>", `Path to ${BRAND.outFile}`, BRAND.outFile).option("-o, --output <path>", "Output HTML file path", BRAND.viewerHtmlFile).option("--open", "Open in browser after generation").action(async (options) => {
|
|
6160
6510
|
try {
|
|
6161
|
-
const { generateViewerFromJson } = await import("./static-viewer-
|
|
6511
|
+
const { generateViewerFromJson } = await import("./static-viewer-NUBFPKWH.js");
|
|
6162
6512
|
const fs2 = await import("fs/promises");
|
|
6163
6513
|
const path = await import("path");
|
|
6164
6514
|
const inputPath = path.resolve(process.cwd(), options.input);
|
|
6165
6515
|
const outputPath = path.resolve(process.cwd(), options.output);
|
|
6166
|
-
console.log(
|
|
6516
|
+
console.log(pc24.cyan(`
|
|
6167
6517
|
${BRAND.name} Viewer Generator
|
|
6168
6518
|
`));
|
|
6169
6519
|
try {
|
|
6170
6520
|
await fs2.access(inputPath);
|
|
6171
6521
|
} catch {
|
|
6172
|
-
console.log(
|
|
6173
|
-
console.log(
|
|
6174
|
-
Run ${
|
|
6522
|
+
console.log(pc24.red(`Error: ${options.input} not found.`));
|
|
6523
|
+
console.log(pc24.dim(`
|
|
6524
|
+
Run ${pc24.cyan(`${BRAND.cliCommand} build`)} first to generate ${BRAND.outFile}
|
|
6175
6525
|
`));
|
|
6176
6526
|
process.exit(1);
|
|
6177
6527
|
}
|
|
6178
|
-
console.log(
|
|
6528
|
+
console.log(pc24.dim(`Reading: ${options.input}`));
|
|
6179
6529
|
const html = await generateViewerFromJson(inputPath);
|
|
6180
6530
|
await fs2.writeFile(outputPath, html);
|
|
6181
|
-
console.log(
|
|
6531
|
+
console.log(pc24.green(`
|
|
6182
6532
|
\u2713 Generated: ${options.output}
|
|
6183
6533
|
`));
|
|
6184
6534
|
if (options.open) {
|
|
@@ -6187,7 +6537,7 @@ Run ${pc23.cyan(`${BRAND.cliCommand} build`)} first to generate ${BRAND.outFile}
|
|
|
6187
6537
|
exec(`${openCmd} "${outputPath}"`);
|
|
6188
6538
|
}
|
|
6189
6539
|
} catch (error) {
|
|
6190
|
-
console.error(
|
|
6540
|
+
console.error(pc24.red("Error:"), error instanceof Error ? error.message : error);
|
|
6191
6541
|
process.exit(1);
|
|
6192
6542
|
}
|
|
6193
6543
|
});
|
|
@@ -6200,33 +6550,51 @@ program.command("add").argument("[name]", 'Component name (e.g., "Button", "Text
|
|
|
6200
6550
|
component: options.component
|
|
6201
6551
|
});
|
|
6202
6552
|
} catch (error) {
|
|
6203
|
-
console.error(
|
|
6553
|
+
console.error(pc24.red("Error:"), error instanceof Error ? error.message : error);
|
|
6554
|
+
process.exit(1);
|
|
6555
|
+
}
|
|
6556
|
+
});
|
|
6557
|
+
program.command("setup").description("Configure @fragments-sdk/ui in a consumer project (styles, providers, Next.js config)").option("--root <dir>", "Project root directory", process.cwd()).option("-y, --yes", "Skip interactive prompts").option("--brand <color>", "Brand color hex (e.g., #6366f1)").option("--scss", "Create SCSS seed file for build-time theming").option("--mcp", "Configure MCP server for AI tooling").action(async (options) => {
|
|
6558
|
+
try {
|
|
6559
|
+
const result = await setup({
|
|
6560
|
+
root: options.root,
|
|
6561
|
+
yes: options.yes,
|
|
6562
|
+
brand: options.brand,
|
|
6563
|
+
scss: options.scss,
|
|
6564
|
+
mcp: options.mcp
|
|
6565
|
+
});
|
|
6566
|
+
if (!result.success) {
|
|
6567
|
+
process.exit(1);
|
|
6568
|
+
}
|
|
6569
|
+
} catch (error) {
|
|
6570
|
+
console.error(pc24.red("Error:"), error instanceof Error ? error.message : error);
|
|
6204
6571
|
process.exit(1);
|
|
6205
6572
|
}
|
|
6206
6573
|
});
|
|
6207
|
-
program.command("init").description("Initialize fragments in a project (interactive by default)").option("--force", "Overwrite existing config").option("-y, --yes", "Non-interactive mode - auto-detect and use defaults").action(async (options) => {
|
|
6574
|
+
program.command("init").description("Initialize fragments in a project (interactive by default)").option("--force", "Overwrite existing config").option("-y, --yes", "Non-interactive mode - auto-detect and use defaults").option("--scan <path>", "Scan a TypeScript component directory and generate fragment files").action(async (options) => {
|
|
6208
6575
|
try {
|
|
6209
|
-
const { init } = await import("./init-
|
|
6576
|
+
const { init } = await import("./init-NDQXUWDU.js");
|
|
6210
6577
|
const result = await init({
|
|
6211
6578
|
projectRoot: process.cwd(),
|
|
6212
6579
|
force: options.force,
|
|
6213
|
-
yes: options.yes
|
|
6580
|
+
yes: options.scan ? true : options.yes,
|
|
6581
|
+
scan: options.scan
|
|
6214
6582
|
});
|
|
6215
6583
|
if (!result.success) {
|
|
6216
|
-
console.error(
|
|
6584
|
+
console.error(pc24.red("\nInit failed with errors:"));
|
|
6217
6585
|
for (const error of result.errors) {
|
|
6218
|
-
console.error(
|
|
6586
|
+
console.error(pc24.red(` - ${error}`));
|
|
6219
6587
|
}
|
|
6220
6588
|
process.exit(1);
|
|
6221
6589
|
}
|
|
6222
6590
|
} catch (error) {
|
|
6223
|
-
console.error(
|
|
6591
|
+
console.error(pc24.red("Error:"), error instanceof Error ? error.message : error);
|
|
6224
6592
|
process.exit(1);
|
|
6225
6593
|
}
|
|
6226
6594
|
});
|
|
6227
6595
|
program.command("tokens").description("Discover and list design tokens from CSS/SCSS files").option("-c, --config <path>", "Path to config file").option("--json", "Output as JSON").option("--categories", "Group tokens by category").option("--theme <theme>", "Filter by theme name").option("--category <category>", "Filter by category (color, spacing, typography, etc.)").option("--verbose", "Show all tokens (no truncation)").action(async (options) => {
|
|
6228
6596
|
try {
|
|
6229
|
-
const { tokens } = await import("./tokens-
|
|
6597
|
+
const { tokens } = await import("./tokens-CE46OTMD.js");
|
|
6230
6598
|
const result = await tokens({
|
|
6231
6599
|
config: options.config,
|
|
6232
6600
|
json: options.json,
|
|
@@ -6239,13 +6607,13 @@ program.command("tokens").description("Discover and list design tokens from CSS/
|
|
|
6239
6607
|
process.exit(1);
|
|
6240
6608
|
}
|
|
6241
6609
|
} catch (error) {
|
|
6242
|
-
console.error(
|
|
6610
|
+
console.error(pc24.red("Error:"), error instanceof Error ? error.message : error);
|
|
6243
6611
|
process.exit(1);
|
|
6244
6612
|
}
|
|
6245
6613
|
});
|
|
6246
6614
|
program.command("generate").description("Generate fragment files from component source code").argument("[component]", "Specific component name to generate (optional)").option("--force", "Overwrite existing fragment files").option("--pattern <glob>", "Pattern for component files", "src/components/**/*.tsx").action(async (component, options) => {
|
|
6247
6615
|
try {
|
|
6248
|
-
const { generate } = await import("./generate-
|
|
6616
|
+
const { generate } = await import("./generate-FBHSXR3D.js");
|
|
6249
6617
|
const result = await generate({
|
|
6250
6618
|
projectRoot: process.cwd(),
|
|
6251
6619
|
component,
|
|
@@ -6253,11 +6621,11 @@ program.command("generate").description("Generate fragment files from component
|
|
|
6253
6621
|
componentPattern: options.pattern
|
|
6254
6622
|
});
|
|
6255
6623
|
if (!result.success) {
|
|
6256
|
-
console.error(
|
|
6624
|
+
console.error(pc24.red("\nGenerate completed with errors"));
|
|
6257
6625
|
process.exit(1);
|
|
6258
6626
|
}
|
|
6259
6627
|
} catch (error) {
|
|
6260
|
-
console.error(
|
|
6628
|
+
console.error(pc24.red("Error:"), error instanceof Error ? error.message : error);
|
|
6261
6629
|
process.exit(1);
|
|
6262
6630
|
}
|
|
6263
6631
|
});
|
|
@@ -6265,7 +6633,7 @@ program.command("graph").description("Query the component relationship graph").a
|
|
|
6265
6633
|
try {
|
|
6266
6634
|
await graph(component, options);
|
|
6267
6635
|
} catch (error) {
|
|
6268
|
-
console.error(
|
|
6636
|
+
console.error(pc24.red("Error:"), error instanceof Error ? error.message : error);
|
|
6269
6637
|
process.exit(1);
|
|
6270
6638
|
}
|
|
6271
6639
|
});
|
|
@@ -6283,14 +6651,14 @@ program.command("perf").description("Profile component bundle sizes and performa
|
|
|
6283
6651
|
process.exit(1);
|
|
6284
6652
|
}
|
|
6285
6653
|
} catch (error) {
|
|
6286
|
-
console.error(
|
|
6654
|
+
console.error(pc24.red("Error:"), error instanceof Error ? error.message : error);
|
|
6287
6655
|
process.exit(1);
|
|
6288
6656
|
}
|
|
6289
6657
|
});
|
|
6290
6658
|
program.command("test").description("Run interaction tests for fragments with play functions").option("-c, --config <path>", "Path to config file").option("--component <name>", "Filter by component name").option("--tags <tags>", "Filter by tags (comma-separated)").option("--grep <pattern>", "Filter by variant name pattern").option("--exclude <pattern>", "Exclude tests matching pattern").option("--parallel <count>", "Number of parallel browser contexts", parseInt, 4).option("--timeout <ms>", "Timeout per test in milliseconds", parseInt, 3e4).option("--retries <count>", "Number of retries for failed tests", parseInt, 0).option("--bail", "Stop on first failure").option("--browser <name>", "Browser to use (chromium, firefox, webkit)", "chromium").option("--headed", "Run in headed mode (show browser)").option("--a11y", "Run accessibility checks with axe-core").option("--visual", "Capture screenshots for visual regression").option("--update-snapshots", "Update visual snapshots").option("--watch", "Watch mode - re-run on file changes").option("--reporters <names>", "Reporters to use (console, junit, json)", "console").option("-o, --output <dir>", "Output directory for results", "./test-results").option("--server-url <url>", "URL of running dev server (skips starting server)").option("-p, --port <port>", "Port for dev server", parseInt, 6006).option("--ci", "CI mode - non-interactive, exit with code 1 on failure").option("--list", "List available tests without running them").action(async (options) => {
|
|
6291
6659
|
try {
|
|
6292
6660
|
const { config, configDir } = await loadConfig(options.config);
|
|
6293
|
-
const { runTestCommand, listTests } = await import("./test-
|
|
6661
|
+
const { runTestCommand, listTests } = await import("./test-Z5LVO724.js");
|
|
6294
6662
|
if (options.list) {
|
|
6295
6663
|
await listTests(config, configDir, {
|
|
6296
6664
|
component: options.component,
|
|
@@ -6323,7 +6691,7 @@ program.command("test").description("Run interaction tests for fragments with pl
|
|
|
6323
6691
|
});
|
|
6324
6692
|
process.exit(exitCode);
|
|
6325
6693
|
} catch (error) {
|
|
6326
|
-
console.error(
|
|
6694
|
+
console.error(pc24.red("Error:"), error instanceof Error ? error.message : error);
|
|
6327
6695
|
process.exit(1);
|
|
6328
6696
|
}
|
|
6329
6697
|
});
|
|
@@ -6338,7 +6706,7 @@ program.command("doctor").description("Diagnose design system configuration issu
|
|
|
6338
6706
|
process.exit(1);
|
|
6339
6707
|
}
|
|
6340
6708
|
} catch (error) {
|
|
6341
|
-
console.error(
|
|
6709
|
+
console.error(pc24.red("Error:"), error instanceof Error ? error.message : error);
|
|
6342
6710
|
process.exit(1);
|
|
6343
6711
|
}
|
|
6344
6712
|
});
|