@fragments-sdk/cli 0.11.1 → 0.13.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.
- package/dist/ai-client-I6MDWNYA.js +21 -0
- package/dist/bin.js +419 -410
- package/dist/bin.js.map +1 -1
- package/dist/{chunk-HRFUSSZI.js → chunk-3SOAPJDX.js} +2 -2
- package/dist/{chunk-D5PYOXEI.js → chunk-4K7EAQ5L.js} +148 -13
- package/dist/{chunk-D5PYOXEI.js.map → chunk-4K7EAQ5L.js.map} +1 -1
- package/dist/chunk-DXX6HADE.js +443 -0
- package/dist/chunk-DXX6HADE.js.map +1 -0
- package/dist/chunk-EYXVAMEX.js +626 -0
- package/dist/chunk-EYXVAMEX.js.map +1 -0
- package/dist/{chunk-ZM4ZQZWZ.js → chunk-FO6EBJWP.js} +39 -37
- package/dist/chunk-FO6EBJWP.js.map +1 -0
- package/dist/{chunk-OQO55NKV.js → chunk-QM7SVOGF.js} +120 -12
- package/dist/chunk-QM7SVOGF.js.map +1 -0
- package/dist/{chunk-5G3VZH43.js → chunk-RF3C6LGA.js} +281 -351
- package/dist/chunk-RF3C6LGA.js.map +1 -0
- package/dist/{chunk-WXSR2II7.js → chunk-SM674YAS.js} +58 -6
- package/dist/chunk-SM674YAS.js.map +1 -0
- package/dist/chunk-SXTKFDCR.js +104 -0
- package/dist/chunk-SXTKFDCR.js.map +1 -0
- package/dist/{chunk-PW7QTQA6.js → chunk-UV5JQV3R.js} +2 -2
- package/dist/core/index.js +13 -1
- package/dist/{discovery-NEOY4MPN.js → discovery-VSGC76JN.js} +3 -3
- package/dist/{generate-FBHSXR3D.js → generate-QZXOXYFW.js} +4 -4
- package/dist/index.js +7 -6
- package/dist/index.js.map +1 -1
- package/dist/init-XK6PRUE5.js +636 -0
- package/dist/init-XK6PRUE5.js.map +1 -0
- package/dist/mcp-bin.js +2 -2
- package/dist/{scan-CJF2DOQW.js → scan-CHQHXWVD.js} +6 -6
- package/dist/scan-generate-U3RFVDTX.js +1115 -0
- package/dist/scan-generate-U3RFVDTX.js.map +1 -0
- package/dist/{service-TQYWY65E.js → service-MMEKG4MZ.js} +3 -3
- package/dist/{snapshot-SV2JOFZH.js → snapshot-53TUR3HW.js} +2 -2
- package/dist/{static-viewer-NUBFPKWH.js → static-viewer-KKCR4KXR.js} +3 -3
- package/dist/static-viewer-KKCR4KXR.js.map +1 -0
- package/dist/{test-Z5LVO724.js → test-5UCKXYSC.js} +4 -4
- package/dist/{tokens-CE46OTMD.js → tokens-L46MK5AW.js} +5 -5
- package/dist/{viewer-DLLJIMCK.js → viewer-M2EQQSGE.js} +14 -14
- package/dist/viewer-M2EQQSGE.js.map +1 -0
- package/package.json +11 -9
- package/src/ai-client.ts +156 -0
- package/src/bin.ts +99 -2
- package/src/build.ts +95 -33
- package/src/commands/__tests__/drift-sync.test.ts +252 -0
- package/src/commands/__tests__/scan-generate.test.ts +497 -45
- package/src/commands/enhance.ts +11 -35
- package/src/commands/govern.ts +122 -0
- package/src/commands/init.ts +288 -260
- package/src/commands/scan-generate.ts +740 -139
- package/src/commands/scan.ts +37 -32
- package/src/commands/setup.ts +143 -52
- package/src/commands/sync.ts +357 -0
- package/src/commands/validate.ts +43 -1
- package/src/core/component-extractor.test.ts +282 -0
- package/src/core/component-extractor.ts +1030 -0
- package/src/core/discovery.ts +93 -7
- package/src/service/enhance/props-extractor.ts +235 -13
- package/src/validators.ts +236 -0
- package/src/viewer/vite-plugin.ts +1 -1
- package/dist/chunk-5G3VZH43.js.map +0 -1
- package/dist/chunk-OQO55NKV.js.map +0 -1
- package/dist/chunk-WXSR2II7.js.map +0 -1
- package/dist/chunk-ZM4ZQZWZ.js.map +0 -1
- package/dist/init-UFGK5TCN.js +0 -867
- package/dist/init-UFGK5TCN.js.map +0 -1
- package/dist/scan-generate-SJAN5MVI.js +0 -691
- package/dist/scan-generate-SJAN5MVI.js.map +0 -1
- package/dist/viewer-DLLJIMCK.js.map +0 -1
- package/src/ai.ts +0 -266
- package/src/commands/init-framework.ts +0 -414
- package/src/mcp/bin.ts +0 -36
- package/src/migrate/bin.ts +0 -114
- package/src/theme/index.ts +0 -77
- package/src/viewer/bin.ts +0 -86
- package/src/viewer/cli/health.ts +0 -256
- package/src/viewer/cli/index.ts +0 -33
- package/src/viewer/cli/scan.ts +0 -124
- package/src/viewer/cli/utils.ts +0 -174
- /package/dist/{discovery-NEOY4MPN.js.map → ai-client-I6MDWNYA.js.map} +0 -0
- /package/dist/{chunk-HRFUSSZI.js.map → chunk-3SOAPJDX.js.map} +0 -0
- /package/dist/{chunk-PW7QTQA6.js.map → chunk-UV5JQV3R.js.map} +0 -0
- /package/dist/{scan-CJF2DOQW.js.map → discovery-VSGC76JN.js.map} +0 -0
- /package/dist/{generate-FBHSXR3D.js.map → generate-QZXOXYFW.js.map} +0 -0
- /package/dist/{service-TQYWY65E.js.map → scan-CHQHXWVD.js.map} +0 -0
- /package/dist/{static-viewer-NUBFPKWH.js.map → service-MMEKG4MZ.js.map} +0 -0
- /package/dist/{snapshot-SV2JOFZH.js.map → snapshot-53TUR3HW.js.map} +0 -0
- /package/dist/{test-Z5LVO724.js.map → test-5UCKXYSC.js.map} +0 -0
- /package/dist/{tokens-CE46OTMD.js.map → tokens-L46MK5AW.js.map} +0 -0
|
@@ -2,7 +2,7 @@ import { createRequire as __banner_createRequire } from 'module'; const require
|
|
|
2
2
|
import {
|
|
3
3
|
BRAND,
|
|
4
4
|
fragmentsConfigSchema
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-QM7SVOGF.js";
|
|
6
6
|
|
|
7
7
|
// src/core/config.ts
|
|
8
8
|
import { existsSync } from "fs";
|
|
@@ -1409,4 +1409,4 @@ export {
|
|
|
1409
1409
|
generateRegistry,
|
|
1410
1410
|
generateContextMd
|
|
1411
1411
|
};
|
|
1412
|
-
//# sourceMappingURL=chunk-
|
|
1412
|
+
//# sourceMappingURL=chunk-3SOAPJDX.js.map
|
|
@@ -2,7 +2,7 @@ import { createRequire as __banner_createRequire } from 'module'; const require
|
|
|
2
2
|
import {
|
|
3
3
|
BRAND,
|
|
4
4
|
DEFAULTS
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-QM7SVOGF.js";
|
|
6
6
|
|
|
7
7
|
// src/service/browser-pool.ts
|
|
8
8
|
import { chromium } from "playwright";
|
|
@@ -5937,7 +5937,7 @@ async function extractPropsFromFile(filePath, options = {}) {
|
|
|
5937
5937
|
}
|
|
5938
5938
|
function extractPropsFromSource(source, filePath, options = {}) {
|
|
5939
5939
|
const { propsTypeName } = options;
|
|
5940
|
-
const componentName = inferComponentName2(filePath);
|
|
5940
|
+
const componentName = options.componentName || inferComponentName2(filePath);
|
|
5941
5941
|
const result = {
|
|
5942
5942
|
filePath,
|
|
5943
5943
|
componentName,
|
|
@@ -5975,19 +5975,26 @@ function extractPropsFromSource(source, filePath, options = {}) {
|
|
|
5975
5975
|
(d) => d.name.endsWith("Props") || d.name.endsWith("Properties")
|
|
5976
5976
|
);
|
|
5977
5977
|
}
|
|
5978
|
-
if (
|
|
5979
|
-
result.
|
|
5980
|
-
|
|
5981
|
-
|
|
5978
|
+
if (propsDecl) {
|
|
5979
|
+
result.propsTypeName = propsDecl.name;
|
|
5980
|
+
if (ts.isInterfaceDeclaration(propsDecl.node)) {
|
|
5981
|
+
extractPropsFromInterface2(propsDecl.node, sourceFile, result);
|
|
5982
|
+
} else if (ts.isTypeAliasDeclaration(propsDecl.node)) {
|
|
5983
|
+
extractPropsFromTypeAlias2(propsDecl.node, sourceFile, result);
|
|
5984
|
+
}
|
|
5985
|
+
result.success = result.props.length > 0;
|
|
5982
5986
|
return result;
|
|
5983
5987
|
}
|
|
5984
|
-
|
|
5985
|
-
if (
|
|
5986
|
-
|
|
5987
|
-
|
|
5988
|
-
|
|
5988
|
+
const inlineProps = extractPropsFromInlineParams(componentName, sourceFile);
|
|
5989
|
+
if (inlineProps.length > 0) {
|
|
5990
|
+
result.props = inlineProps;
|
|
5991
|
+
result.propsTypeName = `${componentName}(inline)`;
|
|
5992
|
+
result.success = true;
|
|
5993
|
+
return result;
|
|
5989
5994
|
}
|
|
5990
|
-
result.
|
|
5995
|
+
result.warnings.push(
|
|
5996
|
+
`No props type found for ${componentName}. Looked for: ${targetName}`
|
|
5997
|
+
);
|
|
5991
5998
|
return result;
|
|
5992
5999
|
}
|
|
5993
6000
|
function extractPropsFromInterface2(node, sourceFile, result) {
|
|
@@ -6204,6 +6211,134 @@ function parseTypeNode(node, sourceFile) {
|
|
|
6204
6211
|
propType: { type: "custom", typescript: node.getText(sourceFile) }
|
|
6205
6212
|
};
|
|
6206
6213
|
}
|
|
6214
|
+
function extractPropsFromInlineParams(componentName, sourceFile) {
|
|
6215
|
+
const props = [];
|
|
6216
|
+
const seen = /* @__PURE__ */ new Set();
|
|
6217
|
+
let targetFunc;
|
|
6218
|
+
ts.forEachChild(sourceFile, (node) => {
|
|
6219
|
+
if (ts.isFunctionDeclaration(node) && node.name?.text === componentName) {
|
|
6220
|
+
targetFunc = node;
|
|
6221
|
+
}
|
|
6222
|
+
if (ts.isVariableStatement(node)) {
|
|
6223
|
+
for (const decl of node.declarationList.declarations) {
|
|
6224
|
+
if (ts.isIdentifier(decl.name) && decl.name.text === componentName && decl.initializer && (ts.isArrowFunction(decl.initializer) || ts.isFunctionExpression(decl.initializer))) {
|
|
6225
|
+
targetFunc = decl.initializer;
|
|
6226
|
+
}
|
|
6227
|
+
}
|
|
6228
|
+
}
|
|
6229
|
+
});
|
|
6230
|
+
if (!targetFunc || targetFunc.parameters.length === 0) return props;
|
|
6231
|
+
const firstParam = targetFunc.parameters[0];
|
|
6232
|
+
if (ts.isObjectBindingPattern(firstParam.name)) {
|
|
6233
|
+
for (const element of firstParam.name.elements) {
|
|
6234
|
+
if (ts.isBindingElement(element) && ts.isIdentifier(element.name)) {
|
|
6235
|
+
const name = element.name.text;
|
|
6236
|
+
if (name === "props" || name === "rest" || name.startsWith("_")) continue;
|
|
6237
|
+
if (name === "className" || name === "children" || name === "ref") continue;
|
|
6238
|
+
if (seen.has(name)) continue;
|
|
6239
|
+
seen.add(name);
|
|
6240
|
+
const hasDefault = element.initializer !== void 0;
|
|
6241
|
+
let defaultValue = void 0;
|
|
6242
|
+
let enumValues;
|
|
6243
|
+
let propType = { type: "string" };
|
|
6244
|
+
if (element.initializer) {
|
|
6245
|
+
if (ts.isStringLiteral(element.initializer)) {
|
|
6246
|
+
defaultValue = element.initializer.text;
|
|
6247
|
+
} else if (element.initializer.kind === ts.SyntaxKind.TrueKeyword) {
|
|
6248
|
+
defaultValue = true;
|
|
6249
|
+
propType = { type: "boolean" };
|
|
6250
|
+
} else if (element.initializer.kind === ts.SyntaxKind.FalseKeyword) {
|
|
6251
|
+
defaultValue = false;
|
|
6252
|
+
propType = { type: "boolean" };
|
|
6253
|
+
} else if (ts.isNumericLiteral(element.initializer)) {
|
|
6254
|
+
defaultValue = Number(element.initializer.text);
|
|
6255
|
+
propType = { type: "number" };
|
|
6256
|
+
}
|
|
6257
|
+
}
|
|
6258
|
+
const prop = {
|
|
6259
|
+
name,
|
|
6260
|
+
type: propType.type,
|
|
6261
|
+
propType,
|
|
6262
|
+
description: "",
|
|
6263
|
+
required: !hasDefault && !element.dotDotDotToken
|
|
6264
|
+
};
|
|
6265
|
+
if (defaultValue !== void 0) prop.defaultValue = defaultValue;
|
|
6266
|
+
if (enumValues) prop.enumValues = enumValues;
|
|
6267
|
+
props.push(prop);
|
|
6268
|
+
}
|
|
6269
|
+
}
|
|
6270
|
+
}
|
|
6271
|
+
if (firstParam.type) {
|
|
6272
|
+
extractFromInlineType(firstParam.type, sourceFile, props, seen);
|
|
6273
|
+
}
|
|
6274
|
+
extractCvaVariants(sourceFile, props);
|
|
6275
|
+
return props;
|
|
6276
|
+
}
|
|
6277
|
+
function extractFromInlineType(typeNode, sourceFile, props, seen) {
|
|
6278
|
+
if (ts.isIntersectionTypeNode(typeNode)) {
|
|
6279
|
+
for (const type of typeNode.types) {
|
|
6280
|
+
extractFromInlineType(type, sourceFile, props, seen);
|
|
6281
|
+
}
|
|
6282
|
+
} else if (ts.isTypeLiteralNode(typeNode)) {
|
|
6283
|
+
for (const member of typeNode.members) {
|
|
6284
|
+
if (ts.isPropertySignature(member) && ts.isIdentifier(member.name)) {
|
|
6285
|
+
const name = member.name.text;
|
|
6286
|
+
if (seen.has(name) || name === "className" || name === "children") continue;
|
|
6287
|
+
seen.add(name);
|
|
6288
|
+
const prop = extractPropFromSignature(member, sourceFile);
|
|
6289
|
+
if (prop) props.push(prop);
|
|
6290
|
+
}
|
|
6291
|
+
}
|
|
6292
|
+
}
|
|
6293
|
+
}
|
|
6294
|
+
function extractCvaVariants(sourceFile, props) {
|
|
6295
|
+
const cvaVariants = /* @__PURE__ */ new Map();
|
|
6296
|
+
function visitCva(node) {
|
|
6297
|
+
if (ts.isCallExpression(node) && ts.isIdentifier(node.expression) && node.expression.text === "cva" && node.arguments.length >= 2) {
|
|
6298
|
+
const configArg = node.arguments[1];
|
|
6299
|
+
if (ts.isObjectLiteralExpression(configArg)) {
|
|
6300
|
+
for (const prop of configArg.properties) {
|
|
6301
|
+
if (ts.isPropertyAssignment(prop) && ts.isIdentifier(prop.name) && prop.name.text === "variants" && ts.isObjectLiteralExpression(prop.initializer)) {
|
|
6302
|
+
for (const variantProp of prop.initializer.properties) {
|
|
6303
|
+
if (ts.isPropertyAssignment(variantProp) && ts.isIdentifier(variantProp.name) && ts.isObjectLiteralExpression(variantProp.initializer)) {
|
|
6304
|
+
const variantName = variantProp.name.text;
|
|
6305
|
+
const values = [];
|
|
6306
|
+
for (const valueProp of variantProp.initializer.properties) {
|
|
6307
|
+
if (ts.isPropertyAssignment(valueProp)) {
|
|
6308
|
+
const key = valueProp.name;
|
|
6309
|
+
if (ts.isIdentifier(key)) {
|
|
6310
|
+
values.push(key.text);
|
|
6311
|
+
} else if (ts.isStringLiteral(key)) {
|
|
6312
|
+
values.push(key.text);
|
|
6313
|
+
} else if (ts.isComputedPropertyName(key)) {
|
|
6314
|
+
const expr = key.expression;
|
|
6315
|
+
if (ts.isStringLiteral(expr)) {
|
|
6316
|
+
values.push(expr.text);
|
|
6317
|
+
}
|
|
6318
|
+
}
|
|
6319
|
+
}
|
|
6320
|
+
}
|
|
6321
|
+
if (values.length > 0) {
|
|
6322
|
+
cvaVariants.set(variantName, values);
|
|
6323
|
+
}
|
|
6324
|
+
}
|
|
6325
|
+
}
|
|
6326
|
+
}
|
|
6327
|
+
}
|
|
6328
|
+
}
|
|
6329
|
+
}
|
|
6330
|
+
ts.forEachChild(node, visitCva);
|
|
6331
|
+
}
|
|
6332
|
+
ts.forEachChild(sourceFile, visitCva);
|
|
6333
|
+
for (const prop of props) {
|
|
6334
|
+
const values = cvaVariants.get(prop.name);
|
|
6335
|
+
if (values && values.length > 0) {
|
|
6336
|
+
prop.enumValues = values;
|
|
6337
|
+
prop.propType = { type: "enum", values };
|
|
6338
|
+
prop.type = values.map((v) => `"${v}"`).join(" | ");
|
|
6339
|
+
}
|
|
6340
|
+
}
|
|
6341
|
+
}
|
|
6207
6342
|
function inferComponentName2(filePath) {
|
|
6208
6343
|
const fileName = basename4(filePath);
|
|
6209
6344
|
let name = fileName.replace(/\.(tsx?|jsx?)$/, "");
|
|
@@ -6641,4 +6776,4 @@ export {
|
|
|
6641
6776
|
getStorybookStoryIds,
|
|
6642
6777
|
renderAllComponentVariants
|
|
6643
6778
|
};
|
|
6644
|
-
//# sourceMappingURL=chunk-
|
|
6779
|
+
//# sourceMappingURL=chunk-4K7EAQ5L.js.map
|