@figma/code-connect 1.4.2 → 1.4.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 +2 -22
- package/dist/commands/connect.d.ts +5 -2
- package/dist/commands/connect.d.ts.map +1 -1
- package/dist/commands/connect.js +93 -29
- package/dist/commands/connect.js.map +1 -1
- package/dist/commands/connect_template.d.ts +36 -0
- package/dist/commands/connect_template.d.ts.map +1 -0
- package/dist/commands/connect_template.js +324 -0
- package/dist/commands/connect_template.js.map +1 -0
- package/dist/commands/filter_project_info.d.ts +7 -0
- package/dist/commands/filter_project_info.d.ts.map +1 -0
- package/dist/commands/filter_project_info.js +32 -0
- package/dist/commands/filter_project_info.js.map +1 -0
- package/dist/commands/preview_utils.d.ts +49 -0
- package/dist/commands/preview_utils.d.ts.map +1 -0
- package/dist/commands/preview_utils.js +390 -0
- package/dist/commands/preview_utils.js.map +1 -0
- package/dist/connect/batch_templates.d.ts +11 -0
- package/dist/connect/batch_templates.d.ts.map +1 -0
- package/dist/connect/batch_templates.js +70 -0
- package/dist/connect/batch_templates.js.map +1 -0
- package/dist/connect/create.d.ts.map +1 -1
- package/dist/connect/create.js +13 -0
- package/dist/connect/create.js.map +1 -1
- package/dist/connect/create_template.d.ts +22 -0
- package/dist/connect/create_template.d.ts.map +1 -0
- package/dist/connect/create_template.js +195 -0
- package/dist/connect/create_template.js.map +1 -0
- package/dist/connect/delete_docs.d.ts +2 -1
- package/dist/connect/delete_docs.d.ts.map +1 -1
- package/dist/connect/delete_docs.js +2 -2
- package/dist/connect/delete_docs.js.map +1 -1
- package/dist/connect/figma_rest_api.d.ts +1 -5
- package/dist/connect/figma_rest_api.d.ts.map +1 -1
- package/dist/connect/figma_rest_api.js +9 -3
- package/dist/connect/figma_rest_api.js.map +1 -1
- package/dist/connect/intrinsics.d.ts +3 -3
- package/dist/connect/intrinsics.d.ts.map +1 -1
- package/dist/connect/intrinsics.js +21 -10
- package/dist/connect/intrinsics.js.map +1 -1
- package/dist/connect/migration_helpers.d.ts +10 -3
- package/dist/connect/migration_helpers.d.ts.map +1 -1
- package/dist/connect/migration_helpers.js +43 -22
- package/dist/connect/migration_helpers.js.map +1 -1
- package/dist/connect/parser_common.d.ts +3 -2
- package/dist/connect/parser_common.d.ts.map +1 -1
- package/dist/connect/parser_common.js +2 -2
- package/dist/connect/parser_common.js.map +1 -1
- package/dist/connect/project.d.ts +9 -7
- package/dist/connect/project.d.ts.map +1 -1
- package/dist/connect/project.js +39 -25
- package/dist/connect/project.js.map +1 -1
- package/dist/connect/raw_templates.d.ts +8 -1
- package/dist/connect/raw_templates.d.ts.map +1 -1
- package/dist/connect/raw_templates.js +20 -7
- package/dist/connect/raw_templates.js.map +1 -1
- package/dist/connect/upload.d.ts +3 -1
- package/dist/connect/upload.d.ts.map +1 -1
- package/dist/connect/upload.js +23 -8
- package/dist/connect/upload.js.map +1 -1
- package/dist/connect/validation.d.ts +2 -2
- package/dist/connect/validation.d.ts.map +1 -1
- package/dist/connect/validation.js +4 -4
- package/dist/connect/validation.js.map +1 -1
- package/dist/connect/wizard/helpers.js.map +1 -1
- package/dist/html/parser.d.ts +2 -2
- package/dist/html/parser.d.ts.map +1 -1
- package/dist/html/parser.js +7 -5
- package/dist/html/parser.js.map +1 -1
- package/dist/react/parser.d.ts +3 -3
- package/dist/react/parser.d.ts.map +1 -1
- package/dist/react/parser.js +9 -7
- package/dist/react/parser.js.map +1 -1
- package/dist/storybook/convert.d.ts +7 -1
- package/dist/storybook/convert.d.ts.map +1 -1
- package/dist/storybook/convert.js +11 -4
- package/dist/storybook/convert.js.map +1 -1
- package/{figma-module.d.ts → figma-types.d.ts} +13 -3
- package/package.json +8 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser_common.js","sourceRoot":"","sources":["../../src/connect/parser_common.ts"],"names":[],"mappings":";;;;;;AAmBA,0DAEC;AAqDD,8DA2DC;AAgBD,4DAsEC;AAUD,sEAmCC;AAKD,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AAK,EAAG,CAAA;QAC3B,IAAI,kBAAkB,CAAC,IAAI,EAAE,aAAa,CAAC,UAAU,CAAC,EAAE,CAAC;YACvD,MAAM,GAAG,GAAG,MAAM,OAAO,CAAC,IAAI,EAAE,aAAa,EAAE,YAAY,CAAC,CAAA;YAC5D,IAAI,GAAG,EAAE,CAAC;gBACR,GAAG,CAAC,oBAAoB,GAAG,IAAI,CAAA;gBAC/B,kBAAkB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;YAC9B,CAAC;QACH,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC,CAAA;IAC3D,CAAC;IAED,IAAI,kBAAkB,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACpC,MAAM,IAAI,WAAW,CAAC,0CAA0C,EAAE;YAChE,UAAU,EAAE,aAAa,CAAC,UAAU;YACpC,IAAI,EAAE,aAAa,CAAC,UAAU;SAC/B,CAAC,CAAA;IACJ,CAAC;IAED,OAAO,kBAAkB,CAAA;AAC3B,CAAC","sourcesContent":["import ts, { JsxExpression } from 'typescript'\nimport { FIGMA_CONNECT_CALL, PropMappings, valueToString } from './intrinsics'\nimport { highlight, reset } from '../common/logging'\nimport { error } from 'console'\nimport {\n assertIsObjectLiteralExpression,\n assertIsStringLiteral,\n convertObjectLiteralToJs,\n parsePropertyOfType,\n stripQuotesFromNode,\n} from '../typescript/compiler'\nimport { BaseCodeConnectConfig } from './project'\nimport { CodeConnectJSON } from './figma_connect'\n\ninterface ParserErrorContext {\n sourceFile: ts.SourceFile\n node: ts.Node | undefined\n}\n\nexport function getPositionInSourceFile(node: ts.Node, sourceFile: ts.SourceFile) {\n return sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile))\n}\n\nexport class ParserError extends Error {\n sourceFilePosition: ts.LineAndCharacter | null\n sourceFileName: string\n\n constructor(message: string, context?: ParserErrorContext) {\n super(message)\n this.name = 'ParserError'\n this.sourceFileName = context?.sourceFile.fileName || ''\n this.sourceFilePosition =\n context && context.node\n ? getPositionInSourceFile(context.node, context.sourceFile) || null\n : null\n }\n\n toString() {\n let msg = `${highlight(error(this.name))}: ${this.message}\\n`\n if (this.sourceFileName && this.sourceFilePosition) {\n msg += ` -> ${reset(this.sourceFileName)}:${this.sourceFilePosition.line}:${\n this.sourceFilePosition.character\n }\\n`\n }\n return msg\n }\n\n toDebugString() {\n return this.toString() + `\\n ${this.stack}`\n }\n}\n\nexport class InternalError extends ParserError {\n constructor(message: string) {\n super(message)\n this.name = 'InternalError'\n }\n}\n\nexport interface ParserContext {\n checker: ts.TypeChecker\n sourceFile: ts.SourceFile\n resolvedImports: Record<string, string>\n config: any\n absPath: string\n}\n\n/**\n * Factory to create a function that is used to create `__PROP__(propName)`\n * function nodes, which are used to replace prop references and ultimately\n * replaced.\n *\n * @returns Function to create `__PROP__(propName)` function nodes\n */\nexport function makeCreatePropPlaceholder({\n propMappings,\n referencedProps,\n sourceFile,\n}: {\n /** The prop mappings object */\n propMappings?: PropMappings | undefined\n /** The set of referenced props in the current example */\n referencedProps: Set<string>\n /** The source file */\n sourceFile: ts.SourceFile\n}) {\n return function ({\n name,\n node,\n wrapInJsxExpression = false,\n }: {\n /** The prop name */\n name: string\n /** The props node, used for error reporting */\n node: ts.Node\n /** Whether to wrap the placeholder in a JSX expression node */\n wrapInJsxExpression?: boolean\n }) {\n let propReferenceName = name\n // for nested prop references like `nested.prop`, we only want to look for\n // the prop mapping of `nested`, but include the full `nested.prop` in the\n // __PROP__ call\n if (name.includes('.')) {\n propReferenceName = name.split('.')[0]\n }\n\n // if prop mappings exist, check that the prop reference is in the mappings\n if (propMappings) {\n const mappedProp = propMappings[propReferenceName]\n if (!mappedProp) {\n throw new ParserError(\n `Could not find prop mapping for ${propReferenceName} in the props object`,\n {\n sourceFile,\n node,\n },\n )\n }\n }\n\n referencedProps.add(propReferenceName)\n const callExpression = ts.factory.createCallExpression(\n ts.factory.createIdentifier('__PROP__'),\n undefined,\n [ts.factory.createStringLiteral(name)],\n )\n\n if (wrapInJsxExpression) {\n return ts.factory.createJsxExpression(undefined, callExpression)\n } else {\n return callExpression\n }\n }\n}\n\n/**\n * TS AST visitor function for use with example functions, which replaces\n * references to the `props` argument in various forms in the example code with\n * `__PROP__(propName)` placeholders (created with a createPropPlaceholder\n * function).\n *\n * This is called when transforming the TS AST, and allows us to normalise the\n * different forms of supported prop references into a single representation,\n * which we can then handle consistently (currently we replace the placeholders,\n * using a regex).\n *\n * @returns Placeholder node, or undefined if the node is not a supported prop\n * reference (which results in no transformation)\n */\nexport function visitPropReferencingNode({\n propsParameter,\n node,\n createPropPlaceholder,\n useJsx,\n}: {\n /** The props function parameter node */\n propsParameter: ts.ParameterDeclaration\n /** The node to visit */\n node: ts.Node\n /**\n * The function to create `__PROP__(propName)` function nodes, created by\n * `baseCreatePropPlaceholder`\n * */\n createPropPlaceholder: ReturnType<typeof makeCreatePropPlaceholder>\n /** Whether to support JSX syntax or not */\n useJsx?: boolean\n}): ts.Expression | undefined {\n // `props.` notation\n if (\n ts.isIdentifier(propsParameter.name) &&\n ts.isPropertyAccessExpression(node) &&\n node.expression.getText().startsWith(propsParameter.name.getText())\n ) {\n // nested notation e.g `props.nested.prop`\n if (ts.isPropertyAccessExpression(node.expression)) {\n let current: ts.Node = node\n const parts: string[] = []\n\n // Build the property name by traversing up the chain\n while (ts.isPropertyAccessExpression(current)) {\n parts.unshift(current.name.getText())\n current = current.expression\n }\n\n // Join the parts together to form the full property name\n const name = parts.join('.')\n return createPropPlaceholder({ name, node })\n }\n const name = node.name.getText()\n return createPropPlaceholder({ name, node })\n }\n // `props[\"\"]` notation\n if (\n ts.isIdentifier(propsParameter.name) &&\n ts.isElementAccessExpression(node) &&\n node.expression.getText().startsWith(propsParameter.name.getText()) &&\n ts.isStringLiteral(node.argumentExpression)\n ) {\n const name = stripQuotesFromNode(node.argumentExpression)\n return createPropPlaceholder({ name, node })\n }\n // object destructuring references\n if (ts.isObjectBindingPattern(propsParameter.name)) {\n const isValidNode = useJsx\n ? ts.isJsxExpression(node)\n : ts.isPropertyAccessExpression(node) || ts.isIdentifier(node)\n const target = useJsx ? (node as JsxExpression).expression : node\n\n if (\n isValidNode &&\n target &&\n propsParameter.name.elements.find((el) => target?.getText().startsWith(el.name.getText()))\n ) {\n const name = target.getText()\n return createPropPlaceholder({ name, node, wrapInJsxExpression: useJsx })\n }\n }\n\n return undefined\n}\n\n/**\n * Get template code to create variables referencing the props in the prop\n * mappings. This converts the prop mappings into JS calls like `const propName\n * = figma.properties.string('Prop Name')`, which can then be prepended to the\n * template code.\n *\n * @returns Template code string\n */\nexport function getReferencedPropsForTemplate({\n propMappings = {},\n}: {\n /** The prop mappings object */\n propMappings: PropMappings | undefined\n /** The top level node, used for error reporting */\n exp: ts.Node\n /** The source file */\n sourceFile: ts.SourceFile\n}) {\n let templateCode = ''\n\n if (Object.keys(propMappings).length > 0) {\n for (const prop in propMappings) {\n const propMapping = propMappings[prop]\n templateCode += `const ${prop} = ${valueToString(propMapping)}\\n`\n }\n templateCode += `const __props = {}\\n`\n Object.keys(propMappings).forEach((prop) => {\n // If trying to render prop resulted in an error (e.g. layer was not found\n // because it was invisible), don't include it in the __props object as\n // this will result in a runtime error.\n //\n // TODO Note that this can also happen if there is a typo in the prop name\n // of a nested prop, because we don't validate these at publish time,\n // which would be confusing. Perhaps we should have a way to show a\n // warning but not an error to the user.\n templateCode += `if (${prop} && ${prop}.type !== 'ERROR') {\n __props[\"${prop}\"] = ${prop}\n}\\n`\n })\n templateCode += `\\n`\n }\n\n return templateCode\n}\n\n/**\n * Checks if a file contains Code Connect by looking for the `figma.connect()` function call\n */\nexport function isFigmaConnectFile(\n program: ts.Program,\n file: string,\n extension: string | string[],\n) {\n const allowedExtensions = Array.isArray(extension) ? extension : [extension]\n const fileExtension = file.split('.').pop()\n\n // If the file has no extension, we can't determine if it's a Code Connect file\n if (!fileExtension) {\n return false\n }\n\n // If the file extension is not in the list of supported extensions, it's not a Code Connect file\n if (!allowedExtensions.includes(fileExtension)) {\n return false\n }\n\n const sourceFile = program.getSourceFile(file)\n if (!sourceFile) {\n throw new InternalError(`Could not find source file for ${file}`)\n }\n\n return (\n findDescendants(sourceFile, (node: ts.Node) => {\n if (isFigmaConnectCall(node, sourceFile)) {\n return true\n }\n return false\n }).length > 0\n )\n}\n\n/**\n * Checks if an AST node is a `figma.connect()` call\n *\n * @param node AST node\n * @param sourceFile Source file\n * @returns True if the node is a `figma.connect()` call\n */\nexport function isFigmaConnectCall(\n node: ts.Node,\n sourceFile: ts.SourceFile,\n): node is ts.CallExpression {\n return (\n ts.isCallExpression(node) && node.expression.getText(sourceFile).includes(FIGMA_CONNECT_CALL)\n )\n}\n\nexport function findDescendants(node: ts.Node, cb: (node: ts.Node) => boolean): ts.Node[] {\n const matches: ts.Node[] = []\n function visit(node: ts.Node) {\n if (cb(node)) {\n matches.push(node)\n }\n ts.forEachChild(node, visit)\n }\n visit(node)\n return matches\n}\n\n/**\n * Parses the `links` field of a `figma.connect()` call\n *\n * @param linksArray an ArrayLiteralExpression\n * @param parserContext Parser context\n * @returns An array of link objects\n */\nexport function parseLinks(linksArray: ts.ArrayLiteralExpression, parserContext: ParserContext) {\n const { sourceFile } = parserContext\n const links: { name: string; url: string }[] = []\n for (const element of linksArray.elements) {\n assertIsObjectLiteralExpression(\n element,\n sourceFile,\n `'links' must be an array literal with objects of the format { name: string, url: string }`,\n )\n const name = parsePropertyOfType({\n objectLiteralNode: element,\n propertyName: 'name',\n predicate: ts.isStringLiteral,\n parserContext,\n required: true,\n errorMessage: \"The 'name' property must be a string literal\",\n })\n const url = parsePropertyOfType({\n objectLiteralNode: element,\n propertyName: 'url',\n predicate: ts.isStringLiteral,\n parserContext,\n required: true,\n errorMessage: \"The 'url' property must be a string literal\",\n })\n\n if (name && url) {\n links.push({ name: stripQuotesFromNode(name), url: stripQuotesFromNode(url) })\n }\n }\n\n return links\n}\n\nexport function parseVariant(\n variantMap: ts.ObjectLiteralExpression,\n sourceFile: ts.SourceFile,\n checker: ts.TypeChecker,\n) {\n return convertObjectLiteralToJs(variantMap, sourceFile, checker, (valueNode) => {\n if (\n !ts.isObjectLiteralElement(valueNode) &&\n !ts.isStringLiteral(valueNode) &&\n !ts.isNumericLiteral(valueNode) &&\n valueNode.kind !== ts.SyntaxKind.TrueKeyword &&\n valueNode.kind !== ts.SyntaxKind.FalseKeyword\n ) {\n throw new ParserError(`Invalid value for variant, got: ${valueNode.getText()}`, {\n node: valueNode,\n sourceFile,\n })\n }\n })\n}\n\n/**\n * Parses the `imports` field of a `figma.connect()` call\n *\n * @param importsArray an ArrayLiteralExpression\n * @param parserContext Parser context\n * @returns An array of link objects\n */\nexport function parseImports(\n importsArray: ts.ArrayLiteralExpression,\n parserContext: ParserContext,\n) {\n const { sourceFile } = parserContext\n const imports: string[] = []\n for (const element of importsArray.elements) {\n assertIsStringLiteral(element, sourceFile, `'imports' must be an array literal with strings`)\n imports.push(stripQuotesFromNode(element))\n }\n\n return imports\n}\n\nexport type ParseOptions = {\n repoUrl?: string\n debug?: boolean\n silent?: boolean\n skipTemplateHelpers?: boolean\n}\n\nexport type ParseFn = (\n node: ts.CallExpression,\n parserContext: ParserContext,\n { repoUrl, silent }: ParseOptions,\n) => Promise<CodeConnectJSON>\n\nexport type ResolveImportsFn = (\n program: ts.Program,\n sourceFile: ts.SourceFile,\n) => Record<string, string>\n\nexport async function parseCodeConnect<T extends BaseCodeConnectConfig>({\n program,\n file,\n config,\n absPath,\n parseFn,\n resolveImportsFn,\n parseOptions = {},\n}: {\n program: ts.Program\n file: string\n config: T\n absPath: string\n parseFn: ParseFn\n resolveImportsFn?: ResolveImportsFn\n parseOptions?: ParseOptions\n}): Promise<any[]> {\n const sourceFile = program.getSourceFile(file)\n if (!sourceFile) {\n throw new InternalError(`Could not find source file for ${file}`)\n }\n\n const parserContext = {\n checker: program.getTypeChecker(),\n sourceFile,\n resolvedImports: resolveImportsFn ? resolveImportsFn(program, sourceFile) : {},\n config,\n absPath,\n }\n const codeConnectObjects: CodeConnectJSON[] = []\n\n const nodes: ts.Node[] = [parserContext.sourceFile]\n while (nodes.length > 0) {\n const node = nodes.shift()!\n if (isFigmaConnectCall(node, parserContext.sourceFile)) {\n const doc = await parseFn(node, parserContext, parseOptions)\n if (doc) {\n doc._codeConnectFilePath = file\n codeConnectObjects.push(doc)\n }\n }\n nodes.push(...node.getChildren(parserContext.sourceFile))\n }\n\n if (codeConnectObjects.length === 0) {\n throw new ParserError(`Didn't find any calls to figma.connect()`, {\n sourceFile: parserContext.sourceFile,\n node: parserContext.sourceFile,\n })\n }\n\n return codeConnectObjects\n}\n"]}
|
|
1
|
+
{"version":3,"file":"parser_common.js","sourceRoot":"","sources":["../../src/connect/parser_common.ts"],"names":[],"mappings":";;;;;;AAmBA,0DAEC;AAqDD,8DA2DC;AAgBD,4DAsEC;AAUD,sEAqCC;AAKD,gDA+BC;AASD,gDAOC;AAED,0CAUC;AASD,gCAgCC;AAED,oCAmBC;AASD,oCAYC;AAoBD,4CAoDC;AAreD,4DAA8C;AAC9C,6CAA8E;AAC9E,+CAAoD;AACpD,qCAA+B;AAC/B,qDAM+B;AAS/B,SAAgB,uBAAuB,CAAC,IAAa,EAAE,UAAyB;IAC9E,OAAO,UAAU,CAAC,6BAA6B,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAA;AAC5E,CAAC;AAED,MAAa,WAAY,SAAQ,KAAK;IAIpC,YAAY,OAAe,EAAE,OAA4B;QACvD,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,aAAa,CAAA;QACzB,IAAI,CAAC,cAAc,GAAG,OAAO,EAAE,UAAU,CAAC,QAAQ,IAAI,EAAE,CAAA;QACxD,IAAI,CAAC,kBAAkB;YACrB,OAAO,IAAI,OAAO,CAAC,IAAI;gBACrB,CAAC,CAAC,uBAAuB,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,U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ACJ,CAAC;IAED,OAAO,kBAAkB,CAAA;AAC3B,CAAC","sourcesContent":["import ts, { JsxExpression } from 'typescript'\nimport { FIGMA_CONNECT_CALL, PropMappings, valueToString } from './intrinsics'\nimport { highlight, reset } from '../common/logging'\nimport { error } from 'console'\nimport {\n assertIsObjectLiteralExpression,\n assertIsStringLiteral,\n convertObjectLiteralToJs,\n parsePropertyOfType,\n stripQuotesFromNode,\n} from '../typescript/compiler'\nimport { BaseCodeConnectConfig } from './project'\nimport { CodeConnectJSON } from './figma_connect'\n\ninterface ParserErrorContext {\n sourceFile: ts.SourceFile\n node: ts.Node | undefined\n}\n\nexport function getPositionInSourceFile(node: ts.Node, sourceFile: ts.SourceFile) {\n return sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile))\n}\n\nexport class ParserError extends Error {\n sourceFilePosition: ts.LineAndCharacter | null\n sourceFileName: string\n\n constructor(message: string, context?: ParserErrorContext) {\n super(message)\n this.name = 'ParserError'\n this.sourceFileName = context?.sourceFile.fileName || ''\n this.sourceFilePosition =\n context && context.node\n ? getPositionInSourceFile(context.node, context.sourceFile) || null\n : null\n }\n\n toString() {\n let msg = `${highlight(error(this.name))}: ${this.message}\\n`\n if (this.sourceFileName && this.sourceFilePosition) {\n msg += ` -> ${reset(this.sourceFileName)}:${this.sourceFilePosition.line}:${\n this.sourceFilePosition.character\n }\\n`\n }\n return msg\n }\n\n toDebugString() {\n return this.toString() + `\\n ${this.stack}`\n }\n}\n\nexport class InternalError extends ParserError {\n constructor(message: string) {\n super(message)\n this.name = 'InternalError'\n }\n}\n\nexport interface ParserContext {\n checker: ts.TypeChecker\n sourceFile: ts.SourceFile\n resolvedImports: Record<string, string>\n config: any\n absPath: string\n}\n\n/**\n * Factory to create a function that is used to create `__PROP__(propName)`\n * function nodes, which are used to replace prop references and ultimately\n * replaced.\n *\n * @returns Function to create `__PROP__(propName)` function nodes\n */\nexport function makeCreatePropPlaceholder({\n propMappings,\n referencedProps,\n sourceFile,\n}: {\n /** The prop mappings object */\n propMappings?: PropMappings | undefined\n /** The set of referenced props in the current example */\n referencedProps: Set<string>\n /** The source file */\n sourceFile: ts.SourceFile\n}) {\n return function ({\n name,\n node,\n wrapInJsxExpression = false,\n }: {\n /** The prop name */\n name: string\n /** The props node, used for error reporting */\n node: ts.Node\n /** Whether to wrap the placeholder in a JSX expression node */\n wrapInJsxExpression?: boolean\n }) {\n let propReferenceName = name\n // for nested prop references like `nested.prop`, we only want to look for\n // the prop mapping of `nested`, but include the full `nested.prop` in the\n // __PROP__ call\n if (name.includes('.')) {\n propReferenceName = name.split('.')[0]\n }\n\n // if prop mappings exist, check that the prop reference is in the mappings\n if (propMappings) {\n const mappedProp = propMappings[propReferenceName]\n if (!mappedProp) {\n throw new ParserError(\n `Could not find prop mapping for ${propReferenceName} in the props object`,\n {\n sourceFile,\n node,\n },\n )\n }\n }\n\n referencedProps.add(propReferenceName)\n const callExpression = ts.factory.createCallExpression(\n ts.factory.createIdentifier('__PROP__'),\n undefined,\n [ts.factory.createStringLiteral(name)],\n )\n\n if (wrapInJsxExpression) {\n return ts.factory.createJsxExpression(undefined, callExpression)\n } else {\n return callExpression\n }\n }\n}\n\n/**\n * TS AST visitor function for use with example functions, which replaces\n * references to the `props` argument in various forms in the example code with\n * `__PROP__(propName)` placeholders (created with a createPropPlaceholder\n * function).\n *\n * This is called when transforming the TS AST, and allows us to normalise the\n * different forms of supported prop references into a single representation,\n * which we can then handle consistently (currently we replace the placeholders,\n * using a regex).\n *\n * @returns Placeholder node, or undefined if the node is not a supported prop\n * reference (which results in no transformation)\n */\nexport function visitPropReferencingNode({\n propsParameter,\n node,\n createPropPlaceholder,\n useJsx,\n}: {\n /** The props function parameter node */\n propsParameter: ts.ParameterDeclaration\n /** The node to visit */\n node: ts.Node\n /**\n * The function to create `__PROP__(propName)` function nodes, created by\n * `baseCreatePropPlaceholder`\n * */\n createPropPlaceholder: ReturnType<typeof makeCreatePropPlaceholder>\n /** Whether to support JSX syntax or not */\n useJsx?: boolean\n}): ts.Expression | undefined {\n // `props.` notation\n if (\n ts.isIdentifier(propsParameter.name) &&\n ts.isPropertyAccessExpression(node) &&\n node.expression.getText().startsWith(propsParameter.name.getText())\n ) {\n // nested notation e.g `props.nested.prop`\n if (ts.isPropertyAccessExpression(node.expression)) {\n let current: ts.Node = node\n const parts: string[] = []\n\n // Build the property name by traversing up the chain\n while (ts.isPropertyAccessExpression(current)) {\n parts.unshift(current.name.getText())\n current = current.expression\n }\n\n // Join the parts together to form the full property name\n const name = parts.join('.')\n return createPropPlaceholder({ name, node })\n }\n const name = node.name.getText()\n return createPropPlaceholder({ name, node })\n }\n // `props[\"\"]` notation\n if (\n ts.isIdentifier(propsParameter.name) &&\n ts.isElementAccessExpression(node) &&\n node.expression.getText().startsWith(propsParameter.name.getText()) &&\n ts.isStringLiteral(node.argumentExpression)\n ) {\n const name = stripQuotesFromNode(node.argumentExpression)\n return createPropPlaceholder({ name, node })\n }\n // object destructuring references\n if (ts.isObjectBindingPattern(propsParameter.name)) {\n const isValidNode = useJsx\n ? ts.isJsxExpression(node)\n : ts.isPropertyAccessExpression(node) || ts.isIdentifier(node)\n const target = useJsx ? (node as JsxExpression).expression : node\n\n if (\n isValidNode &&\n target &&\n propsParameter.name.elements.find((el) => target?.getText().startsWith(el.name.getText()))\n ) {\n const name = target.getText()\n return createPropPlaceholder({ name, node, wrapInJsxExpression: useJsx })\n }\n }\n\n return undefined\n}\n\n/**\n * Get template code to create variables referencing the props in the prop\n * mappings. This converts the prop mappings into JS calls like `const propName\n * = figma.properties.string('Prop Name')`, which can then be prepended to the\n * template code.\n *\n * @returns Template code string\n */\nexport function getReferencedPropsForTemplate({\n propMappings = {},\n isForMigration,\n}: {\n /** The prop mappings object */\n propMappings: PropMappings | undefined\n /** The top level node, used for error reporting */\n exp: ts.Node\n /** The source file */\n sourceFile: ts.SourceFile\n isForMigration?: boolean\n}) {\n let templateCode = ''\n\n if (Object.keys(propMappings).length > 0) {\n for (const prop in propMappings) {\n const propMapping = propMappings[prop]\n templateCode += `const ${prop} = ${valueToString(propMapping, undefined, isForMigration)}\\n`\n }\n templateCode += `const __props = {}\\n`\n Object.keys(propMappings).forEach((prop) => {\n // If trying to render prop resulted in an error (e.g. layer was not found\n // because it was invisible), don't include it in the __props object as\n // this will result in a runtime error.\n //\n // TODO Note that this can also happen if there is a typo in the prop name\n // of a nested prop, because we don't validate these at publish time,\n // which would be confusing. Perhaps we should have a way to show a\n // warning but not an error to the user.\n templateCode += `if (${prop} && ${prop}.type !== 'ERROR') {\n __props[\"${prop}\"] = ${prop}\n}\\n`\n })\n templateCode += `\\n`\n }\n\n return templateCode\n}\n\n/**\n * Checks if a file contains Code Connect by looking for the `figma.connect()` function call\n */\nexport function isFigmaConnectFile(\n program: ts.Program,\n file: string,\n extension: string | string[],\n) {\n const allowedExtensions = Array.isArray(extension) ? extension : [extension]\n const fileExtension = file.split('.').pop()\n\n // If the file has no extension, we can't determine if it's a Code Connect file\n if (!fileExtension) {\n return false\n }\n\n // If the file extension is not in the list of supported extensions, it's not a Code Connect file\n if (!allowedExtensions.includes(fileExtension)) {\n return false\n }\n\n const sourceFile = program.getSourceFile(file)\n if (!sourceFile) {\n throw new InternalError(`Could not find source file for ${file}`)\n }\n\n return (\n findDescendants(sourceFile, (node: ts.Node) => {\n if (isFigmaConnectCall(node, sourceFile)) {\n return true\n }\n return false\n }).length > 0\n )\n}\n\n/**\n * Checks if an AST node is a `figma.connect()` call\n *\n * @param node AST node\n * @param sourceFile Source file\n * @returns True if the node is a `figma.connect()` call\n */\nexport function isFigmaConnectCall(\n node: ts.Node,\n sourceFile: ts.SourceFile,\n): node is ts.CallExpression {\n return (\n ts.isCallExpression(node) && node.expression.getText(sourceFile).includes(FIGMA_CONNECT_CALL)\n )\n}\n\nexport function findDescendants(node: ts.Node, cb: (node: ts.Node) => boolean): ts.Node[] {\n const matches: ts.Node[] = []\n function visit(node: ts.Node) {\n if (cb(node)) {\n matches.push(node)\n }\n ts.forEachChild(node, visit)\n }\n visit(node)\n return matches\n}\n\n/**\n * Parses the `links` field of a `figma.connect()` call\n *\n * @param linksArray an ArrayLiteralExpression\n * @param parserContext Parser context\n * @returns An array of link objects\n */\nexport function parseLinks(linksArray: ts.ArrayLiteralExpression, parserContext: ParserContext) {\n const { sourceFile } = parserContext\n const links: { name: string; url: string }[] = []\n for (const element of linksArray.elements) {\n assertIsObjectLiteralExpression(\n element,\n sourceFile,\n `'links' must be an array literal with objects of the format { name: string, url: string }`,\n )\n const name = parsePropertyOfType({\n objectLiteralNode: element,\n propertyName: 'name',\n predicate: ts.isStringLiteral,\n parserContext,\n required: true,\n errorMessage: \"The 'name' property must be a string literal\",\n })\n const url = parsePropertyOfType({\n objectLiteralNode: element,\n propertyName: 'url',\n predicate: ts.isStringLiteral,\n parserContext,\n required: true,\n errorMessage: \"The 'url' property must be a string literal\",\n })\n\n if (name && url) {\n links.push({ name: stripQuotesFromNode(name), url: stripQuotesFromNode(url) })\n }\n }\n\n return links\n}\n\nexport function parseVariant(\n variantMap: ts.ObjectLiteralExpression,\n sourceFile: ts.SourceFile,\n checker: ts.TypeChecker,\n) {\n return convertObjectLiteralToJs(variantMap, sourceFile, checker, (valueNode) => {\n if (\n !ts.isObjectLiteralElement(valueNode) &&\n !ts.isStringLiteral(valueNode) &&\n !ts.isNumericLiteral(valueNode) &&\n valueNode.kind !== ts.SyntaxKind.TrueKeyword &&\n valueNode.kind !== ts.SyntaxKind.FalseKeyword\n ) {\n throw new ParserError(`Invalid value for variant, got: ${valueNode.getText()}`, {\n node: valueNode,\n sourceFile,\n })\n }\n })\n}\n\n/**\n * Parses the `imports` field of a `figma.connect()` call\n *\n * @param importsArray an ArrayLiteralExpression\n * @param parserContext Parser context\n * @returns An array of link objects\n */\nexport function parseImports(\n importsArray: ts.ArrayLiteralExpression,\n parserContext: ParserContext,\n) {\n const { sourceFile } = parserContext\n const imports: string[] = []\n for (const element of importsArray.elements) {\n assertIsStringLiteral(element, sourceFile, `'imports' must be an array literal with strings`)\n imports.push(stripQuotesFromNode(element))\n }\n\n return imports\n}\n\nexport type ParseOptions = {\n repoUrl?: string\n debug?: boolean\n silent?: boolean\n isForMigration?: boolean\n}\n\nexport type ParseFn = (\n node: ts.CallExpression,\n parserContext: ParserContext,\n { repoUrl, silent }: ParseOptions,\n) => Promise<CodeConnectJSON>\n\nexport type ResolveImportsFn = (\n program: ts.Program,\n sourceFile: ts.SourceFile,\n) => Record<string, string>\n\nexport async function parseCodeConnect<T extends BaseCodeConnectConfig>({\n program,\n file,\n config,\n absPath,\n parseFn,\n resolveImportsFn,\n parseOptions = {},\n}: {\n program: ts.Program\n file: string\n config: T\n absPath: string\n parseFn: ParseFn\n resolveImportsFn?: ResolveImportsFn\n parseOptions?: ParseOptions\n}): Promise<any[]> {\n const sourceFile = program.getSourceFile(file)\n if (!sourceFile) {\n throw new InternalError(`Could not find source file for ${file}`)\n }\n\n const parserContext = {\n checker: program.getTypeChecker(),\n sourceFile,\n resolvedImports: resolveImportsFn ? resolveImportsFn(program, sourceFile) : {},\n config,\n absPath,\n }\n const codeConnectObjects: CodeConnectJSON[] = []\n\n const nodes: ts.Node[] = [parserContext.sourceFile]\n while (nodes.length > 0) {\n const node = nodes.shift()!\n if (isFigmaConnectCall(node, parserContext.sourceFile)) {\n const doc = await parseFn(node, parserContext, parseOptions)\n if (doc) {\n doc._codeConnectFilePath = file\n codeConnectObjects.push(doc)\n }\n }\n nodes.push(...node.getChildren(parserContext.sourceFile))\n }\n\n if (codeConnectObjects.length === 0) {\n throw new ParserError(`Didn't find any calls to figma.connect()`, {\n sourceFile: parserContext.sourceFile,\n node: parserContext.sourceFile,\n })\n }\n\n return codeConnectObjects\n}\n"]}
|
|
@@ -33,7 +33,7 @@ export type BaseCodeConnectConfig = {
|
|
|
33
33
|
/**
|
|
34
34
|
* The parser name, if using an internal parser.
|
|
35
35
|
*/
|
|
36
|
-
parser
|
|
36
|
+
parser?: CodeConnectParser;
|
|
37
37
|
/**
|
|
38
38
|
* Label to use for the uploaded code examples
|
|
39
39
|
*/
|
|
@@ -98,12 +98,14 @@ export type CodeConnectReactConfig = BaseCodeConnectConfig & {
|
|
|
98
98
|
};
|
|
99
99
|
};
|
|
100
100
|
export type CodeConnectHtmlConfig = BaseCodeConnectConfig & {};
|
|
101
|
-
export type CodeConnectParserlessConfig =
|
|
102
|
-
|
|
101
|
+
export type CodeConnectParserlessConfig = BaseCodeConnectConfig & {
|
|
102
|
+
parser: undefined;
|
|
103
|
+
};
|
|
104
|
+
export type CodeConnectConfig = CodeConnectReactConfig | CodeConnectExecutableParserConfig | CodeConnectCustomExecutableParserConfig | CodeConnectHtmlConfig | BaseCodeConnectConfig | CodeConnectParserlessConfig;
|
|
103
105
|
interface FigmaConfig {
|
|
104
106
|
codeConnect?: CodeConnectConfig;
|
|
105
107
|
}
|
|
106
|
-
export declare function determineConfigFromProject(dir: string, exitOnError?: boolean): FigmaConfig | undefined;
|
|
108
|
+
export declare function determineConfigFromProject(dir: string, exitOnError?: boolean, isTemplatesOnlyCLI?: boolean): FigmaConfig | undefined;
|
|
107
109
|
export declare function determineLabelFromProject(dir: string): string | undefined;
|
|
108
110
|
export declare function getGitRemoteURL(repoPath: string): string;
|
|
109
111
|
/**
|
|
@@ -148,7 +150,7 @@ export type ReactProjectInfo = ProjectInfo<CodeConnectReactConfig> & {
|
|
|
148
150
|
};
|
|
149
151
|
export declare function getDefaultConfigPath(dir: string): string;
|
|
150
152
|
export declare function getEnvPath(dir: string): string;
|
|
151
|
-
export declare function parseOrDetermineConfig(dir: string, configPath: string): Promise<{
|
|
153
|
+
export declare function parseOrDetermineConfig(dir: string, configPath: string, isTemplatesOnlyCLI?: boolean): Promise<{
|
|
152
154
|
config: CodeConnectConfig;
|
|
153
155
|
hasConfigFile: boolean;
|
|
154
156
|
}>;
|
|
@@ -166,7 +168,7 @@ export declare function checkForEnvAndToken(dir: string): Promise<{
|
|
|
166
168
|
* @param config Code Connect config
|
|
167
169
|
* @returns Object containing information about the project
|
|
168
170
|
*/
|
|
169
|
-
export declare function getProjectInfoFromConfig(dir: string, config: CodeConnectConfig): Promise<ProjectInfo>;
|
|
171
|
+
export declare function getProjectInfoFromConfig(dir: string, config: CodeConnectConfig, isTemplatesOnlyCLI?: boolean): Promise<ProjectInfo>;
|
|
170
172
|
/**
|
|
171
173
|
* Gets information about a project from a directory.
|
|
172
174
|
*
|
|
@@ -174,7 +176,7 @@ export declare function getProjectInfoFromConfig(dir: string, config: CodeConnec
|
|
|
174
176
|
* @param configPath Optional path to Code Connect config file
|
|
175
177
|
* @returns Object containing information about the project
|
|
176
178
|
*/
|
|
177
|
-
export declare function getProjectInfo(dir: string, configPath: string): Promise<ProjectInfo>;
|
|
179
|
+
export declare function getProjectInfo(dir: string, configPath: string, isTemplatesOnlyCLI?: boolean): Promise<ProjectInfo>;
|
|
178
180
|
export declare function getReactProjectInfo(projectInfo: ProjectInfo<CodeConnectReactConfig>): ReactProjectInfo;
|
|
179
181
|
export declare function getTsProgram(projectInfo: ProjectInfo<CodeConnectConfig>): ts.Program;
|
|
180
182
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../src/connect/project.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,YAAY,CAAA;AAO3B,OAAO,EAAoB,uBAAuB,EAAE,MAAM,0BAA0B,CAAA;AAKpF,eAAO,MAAM,+BAA+B;;;;;;;CAQ3C,CAAA;AAED,eAAO,MAAM,wBAAwB,EAAE,OAAO,CAAC,MAAM,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAG/E,CAAA;AAGD,MAAM,MAAM,2BAA2B,GAAG,OAAO,GAAG,SAAS,GAAG,QAAQ,GAAG,eAAe,CAAA;AAK1F,MAAM,MAAM,iBAAiB,GAAG,OAAO,GAAG,MAAM,GAAG,2BAA2B,CAAA;AAE9E,MAAM,MAAM,qBAAqB,GAAG;IAClC;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,EAAE,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AW,EAAE,WAAW,CAAC,sBAAsB,CAAC,GAC/C,gBAAgB,CAOlB;AAED,wBAAgB,YAAY,CAAC,WAAW,EAAE,WAAW,CAAC,iBAAiB,CAAC,GAAG,EAAE,CAAC,OAAO,CAcpF;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,sBAAsB,GAAG,MAAM,GAAG,IAAI,CAoD7F;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,sBAAsB,GAC7B,MAAM,GAAG,IAAI,CAoBf"}
|
package/dist/connect/project.js
CHANGED
|
@@ -48,7 +48,11 @@ exports.DEFAULT_LABEL_PER_PARSER = {
|
|
|
48
48
|
react: label_language_mapping_1.CodeConnectLabel.React,
|
|
49
49
|
html: label_language_mapping_1.CodeConnectLabel.WebComponents,
|
|
50
50
|
};
|
|
51
|
-
function determineConfigFromProject(dir, exitOnError = true) {
|
|
51
|
+
function determineConfigFromProject(dir, exitOnError = true, isTemplatesOnlyCLI = false) {
|
|
52
|
+
if (isTemplatesOnlyCLI) {
|
|
53
|
+
const label = determineLabelFromProject(dir);
|
|
54
|
+
return { codeConnect: label ? { label } : {} };
|
|
55
|
+
}
|
|
52
56
|
const parser = determineParserFromProject(dir);
|
|
53
57
|
if (parser) {
|
|
54
58
|
const label = determineLabelFromProject(dir);
|
|
@@ -215,12 +219,12 @@ Please raise an issue at https://github.com/figma/code-connect/issues if you hav
|
|
|
215
219
|
}
|
|
216
220
|
return config;
|
|
217
221
|
}
|
|
218
|
-
async function parseConfig(configFilePath, dir) {
|
|
222
|
+
async function parseConfig(configFilePath, dir, isTemplatesOnlyCLI = false) {
|
|
219
223
|
try {
|
|
220
224
|
const rawData = fs_1.default.readFileSync(configFilePath, 'utf-8');
|
|
221
225
|
const rawConfig = JSON.parse(rawData);
|
|
222
226
|
const config = await checkForLegacyConfig(rawConfig, configFilePath);
|
|
223
|
-
if (!config.codeConnect?.parser) {
|
|
227
|
+
if (!isTemplatesOnlyCLI && !config.codeConnect?.parser) {
|
|
224
228
|
const parser = determineParserFromProject(dir);
|
|
225
229
|
if (!parser) {
|
|
226
230
|
logging_1.logger.error(`Code Connect was not able to determine your project type, and no \`parser\` was specified. Please ensure you are running Code Connect from your project root. You may need to add a \`parser\` key to your config file, specifying which parser to use. See https://github.com/figma/code-connect/ for instructions.`);
|
|
@@ -235,7 +239,7 @@ async function parseConfig(configFilePath, dir) {
|
|
|
235
239
|
if (!config.codeConnect?.label) {
|
|
236
240
|
const label = determineLabelFromProject(dir);
|
|
237
241
|
if (label) {
|
|
238
|
-
config.codeConnect
|
|
242
|
+
config.codeConnect = { ...config.codeConnect, label };
|
|
239
243
|
}
|
|
240
244
|
}
|
|
241
245
|
return config;
|
|
@@ -410,7 +414,7 @@ function getDefaultConfigPath(dir) {
|
|
|
410
414
|
function getEnvPath(dir) {
|
|
411
415
|
return path_1.default.resolve(path_1.default.join(dir, ENV_FILE_NAME));
|
|
412
416
|
}
|
|
413
|
-
async function parseOrDetermineConfig(dir, configPath) {
|
|
417
|
+
async function parseOrDetermineConfig(dir, configPath, isTemplatesOnlyCLI = false) {
|
|
414
418
|
const configFilePath = configPath ? path_1.default.resolve(configPath) : getDefaultConfigPath(dir);
|
|
415
419
|
const hasConfigFile = fs_1.default.existsSync(configFilePath);
|
|
416
420
|
if (!hasConfigFile) {
|
|
@@ -422,8 +426,8 @@ async function parseOrDetermineConfig(dir, configPath) {
|
|
|
422
426
|
}
|
|
423
427
|
}
|
|
424
428
|
const globalConfig = hasConfigFile
|
|
425
|
-
? await parseConfig(configFilePath, dir)
|
|
426
|
-
: determineConfigFromProject(dir);
|
|
429
|
+
? await parseConfig(configFilePath, dir, isTemplatesOnlyCLI)
|
|
430
|
+
: determineConfigFromProject(dir, true, isTemplatesOnlyCLI);
|
|
427
431
|
if (!globalConfig) {
|
|
428
432
|
throw new Error(`Error parsing config file: ${configFilePath}`);
|
|
429
433
|
}
|
|
@@ -481,23 +485,33 @@ async function checkForEnvAndToken(dir) {
|
|
|
481
485
|
* @param config Code Connect config
|
|
482
486
|
* @returns Object containing information about the project
|
|
483
487
|
*/
|
|
484
|
-
async function getProjectInfoFromConfig(dir, config) {
|
|
488
|
+
async function getProjectInfoFromConfig(dir, config, isTemplatesOnlyCLI = false) {
|
|
485
489
|
const absPath = path_1.default.resolve(dir);
|
|
486
490
|
const remoteUrl = getGitRemoteURL(absPath);
|
|
487
|
-
const defaultIncludeGlobs =
|
|
488
|
-
?
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
491
|
+
const defaultIncludeGlobs = isTemplatesOnlyCLI
|
|
492
|
+
? [
|
|
493
|
+
'**/*.figma.ts',
|
|
494
|
+
'**/*.figma.js',
|
|
495
|
+
'**/*.figma.template.ts',
|
|
496
|
+
'**/*.figma.template.js',
|
|
497
|
+
'**/*.figma.batch.json',
|
|
498
|
+
]
|
|
499
|
+
: config.parser
|
|
500
|
+
? exports.DEFAULT_INCLUDE_GLOBS_BY_PARSER[config.parser]
|
|
501
|
+
: undefined;
|
|
502
|
+
// always ignore node_modules; for parsers, apply parser-specific exclusions
|
|
503
|
+
const defaultExcludeGlobs = isTemplatesOnlyCLI
|
|
504
|
+
? ['node_modules/**']
|
|
505
|
+
: config.parser
|
|
506
|
+
? ({
|
|
507
|
+
react: ['node_modules/**'],
|
|
508
|
+
html: ['node_modules/**'],
|
|
509
|
+
swift: ['**/__test__/**'],
|
|
510
|
+
compose: [],
|
|
511
|
+
custom: [],
|
|
512
|
+
__unit_test__: [],
|
|
513
|
+
}[config.parser] ?? [])
|
|
514
|
+
: [];
|
|
501
515
|
const includeGlobs = config.include || defaultIncludeGlobs;
|
|
502
516
|
const excludeGlobs = config.exclude
|
|
503
517
|
? [...config.exclude, ...defaultExcludeGlobs]
|
|
@@ -546,11 +560,11 @@ function validateLanguage(language) {
|
|
|
546
560
|
* @param configPath Optional path to Code Connect config file
|
|
547
561
|
* @returns Object containing information about the project
|
|
548
562
|
*/
|
|
549
|
-
async function getProjectInfo(dir, configPath) {
|
|
550
|
-
const { config } = await parseOrDetermineConfig(dir, configPath);
|
|
563
|
+
async function getProjectInfo(dir, configPath, isTemplatesOnlyCLI = false) {
|
|
564
|
+
const { config } = await parseOrDetermineConfig(dir, configPath, isTemplatesOnlyCLI);
|
|
551
565
|
// Validate language field if present
|
|
552
566
|
validateLanguage(config.language);
|
|
553
|
-
return getProjectInfoFromConfig(dir, config);
|
|
567
|
+
return getProjectInfoFromConfig(dir, config, isTemplatesOnlyCLI);
|
|
554
568
|
}
|
|
555
569
|
function getReactProjectInfo(projectInfo) {
|
|
556
570
|
const tsProgram = getTsProgram(projectInfo);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project.js","sourceRoot":"","sources":["../../src/connect/project.ts"],"names":[],"mappings":";;;;;;AAqJA,gEAmBC;AAgFD,8DAuCC;AAsID,0CAWC;AAKD,wDAkBC;AAKD,kEA8CC;AAQD,4CAmDC;AAED,0CAoBC;AAiCD,oDAEC;AAED,gCAEC;AAED,wDAyCC;AAKD,kDAoCC;AASD,4DAuDC;AA2BD,wCAOC;AAED,kDASC;AAED,oCAcC;AAUD,sCAoDC;AAYD,gDAuBC;AAp6BD,iDAAyC;AACzC,+BAA+B;AAC/B,gDAAuB;AACvB,4CAAmB;AACnB,4DAA2B;AAC3B,+CAAyD;AACzD,kDAAyB;AACzB,wDAA+B;AAC/B,yEAAyE;AACzE,sDAA4B;AAC5B,uCAAmD;AACnD,qEAAoF;AAEpF,MAAM,wBAAwB,GAAG,mBAAmB,CAAA;AACpD,MAAM,aAAa,GAAG,MAAM,CAAA;AAEf,QAAA,+BAA+B,GAAG;IAC7C,KAAK,EAAE,CAAC,gBAAgB,CAAC;IACzB,IAA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Sync } from 'glob'\nimport path from 'path'\nimport fs from 'fs'\nimport ts from 'typescript'\nimport { exitWithError, logger } from '../common/logging'\nimport chalk from 'chalk'\nimport readline from 'readline'\n// We use an old version of this dep as I couldn't get ES modules working\nimport findUp from 'find-up'\nimport { exitWithFeedbackMessage } from './helpers'\nimport { CodeConnectLabel, SyntaxHighlightLanguage } from './label_language_mapping'\n\nconst DEFAULT_CONFIG_FILE_NAME = 'figma.config.json'\nconst ENV_FILE_NAME = '.env'\n\nexport const DEFAULT_INCLUDE_GLOBS_BY_PARSER = {\n react: [`**/*.{tsx,jsx}`],\n html: [`**/*.{ts,js}`],\n swift: ['**/*.swift'],\n compose: ['**/*.kt'],\n // include globs should be included in configs for custom parsers\n custom: undefined,\n __unit_test__: [''],\n}\n\nexport const DEFAULT_LABEL_PER_PARSER: Partial<Record<CodeConnectParser, string>> = {\n react: CodeConnectLabel.React,\n html: CodeConnectLabel.WebComponents,\n}\n\n// First party parsers which call into parser executables\nexport type CodeConnectExecutableParser = 'swift' | 'compose' | 'custom' | '__unit_test__'\n\n// React is a special case for now as we call it directly from the CLI rather\n// than via an executable for legacy reasons. We will migrate it to the\n// parser executable model.\nexport type CodeConnectParser = 'react' | 'html' | CodeConnectExecutableParser\n\nexport type BaseCodeConnectConfig = {\n /**\n * Specify glob patterns for files (relative to the project root) to be\n * included when looking for source files. If not specified, all files\n * (except any specified in `exclude`) will be included.\n */\n include?: string[]\n /**\n * Specify glob patterns for files (relative to the project root) to be\n * excluded when looking for source files. If not specified, only\n * `node_modules` will be excluded.\n */\n exclude?: string[]\n /**\n * Optional object of substitutions applied to document URLs (in the format {\n * fromString, toString }) for testing (e.g. remapping a production URL to a\n * staging URL). Not publicly documented.\n */\n documentUrlSubstitutions?: Record<string, string>\n /**\n * The parser name, if using an internal parser.\n */\n parser: CodeConnectParser\n\n /**\n * Label to use for the uploaded code examples\n */\n label?: string\n\n /**\n * Language to use for syntax highlighting in the uploaded code examples.\n * If not specified, language is inferred from the label or parser type.\n */\n language?: SyntaxHighlightLanguage\n\n /**\n * The URL of the Figma file to use during the interactive setup wizard for connecting code components to Figma components.\n */\n interactiveSetupFigmaFileUrl?: string\n\n /**\n * Custom Figma API URL to use instead of https://api.figma.com/v1\n */\n apiUrl?: string\n\n /**\n * The default branch name for your repository. Code Connect uses this when generating source code\n * links in Figma. If not specified, Code Connect will attempt to determine this automatically.\n */\n defaultBranch?: string\n}\n\nexport type CodeConnectExecutableParserConfig = BaseCodeConnectConfig & {\n parser: CodeConnectExecutableParser\n}\n\nexport type CodeConnectCustomExecutableParserConfig = BaseCodeConnectConfig & {\n parser: 'custom'\n parserCommand: string\n}\n\n/**\n * React specific configuration\n */\nexport type CodeConnectReactConfig = BaseCodeConnectConfig & {\n parser: 'react'\n /**\n * Maps imports from their path on disk to the specified path.\n * This will rewrite the imports in generated code examples, so it works with\n * relative imports such as `import { Button } from \"./\"`.\n *\n * Example: { \"src/components/*\": \"@ui/components\" }\n * Would rewrite imports for components located in `src/components` to `@ui/components` in\n * generated code examples.\n * `import { Button } from \"./\"` -> `import { Button } from \"@ui/components/Button\"`\n */\n importPaths?: Record<string, string>\n /**\n * For import resolution - this is a temporary solution to support projects that use\n * pnpm workspaces, as the compiler doesn't seem to be able to resolve imports when\n * the package in node_modules is a symlink. Need to look into this more and find a\n * better solution.\n */\n paths?: Record<string, string[]>\n /**\n * Storybook specific configuration\n */\n storybook?: {\n /**\n * The URL of the Storybook instance for the project\n */\n url: string\n }\n}\n\nexport type CodeConnectHtmlConfig = BaseCodeConnectConfig & {}\n\nexport type CodeConnectParserlessConfig = Omit<BaseCodeConnectConfig, 'parser'>\n\nexport type CodeConnectConfig =\n | CodeConnectReactConfig\n | CodeConnectExecutableParserConfig\n | CodeConnectCustomExecutableParserConfig\n | CodeConnectHtmlConfig\n | BaseCodeConnectConfig\n\ninterface FigmaConfig {\n codeConnect?: CodeConnectConfig\n}\n\nexport function determineConfigFromProject(\n dir: string,\n exitOnError = true,\n): FigmaConfig | undefined {\n const parser = determineParserFromProject(dir)\n if (parser) {\n const label = determineLabelFromProject(dir)\n if (label) {\n return { codeConnect: { parser, label } }\n }\n\n return { codeConnect: { parser } }\n }\n\n if (exitOnError) {\n exitWithError(\n `Code Connect was not able to determine your project type, and no config file was found. Please ensure you are running Code Connect from your project root. You may need to create a config file specifying which parser to use. See https://github.com/figma/code-connect/ for instructions.`,\n )\n }\n}\n\nfunction showParserMessage(message: string) {\n logger.info(\n message +\n '. If this is incorrect, please check you are running Code Connect from your project root, or add a `parser` key to your config file. See https://github.com/figma/code-connect for more information.',\n )\n}\n\nfunction packageJsonContains(packageJson: any, dependency: string) {\n return (\n (packageJson.dependencies && packageJson.dependencies[dependency]) ||\n (packageJson.peerDependencies && packageJson.peerDependencies[dependency]) ||\n (packageJson.devDependencies && packageJson.devDependencies[dependency])\n )\n}\n\n// Walk up from the given directory looking for the first directory which\n// matches heuristics for the platforms we support. This means that e.g. if you\n// have a Swift project inside a React project, we'll detect Swift. This enables\n// users to run commands from anywhere inside their project, rather than having\n// to run from the root (the same way npm works).\nfunction determineParserFromProject(dir: string): CodeConnectParser | undefined {\n let parser: CodeConnectParser | undefined\n\n findUp.sync(\n (currentDir) => {\n const packageJsonPath = path.join(currentDir, 'package.json')\n\n if (fs.existsSync(packageJsonPath)) {\n const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'))\n if (packageJsonContains(packageJson, 'react')) {\n showParserMessage(\n `Using \"react\" parser as package.json containing a \"react\" ${\n packageJson.dependencies && packageJson.dependencies['react']\n ? 'dependency'\n : 'peer dependency'\n } was found in ${currentDir}`,\n )\n parser = 'react'\n return findUp.stop\n } else {\n showParserMessage(\n `Using \"html\" parser as package.json containing no other supported web frameworks was found in ${currentDir}`,\n )\n parser = 'html'\n return findUp.stop\n }\n } else {\n if (globSync([`${currentDir}/*.xcodeproj`, `${currentDir}/Package.swift`]).length > 0) {\n showParserMessage(\n `Using \"swift\" parser as a file matching *.xcodeproj or Package.swift was found in ${currentDir}`,\n )\n parser = 'swift'\n return findUp.stop\n } else if (globSync([`${currentDir}/build.gradle.kts`]).length > 0) {\n showParserMessage(\n `Using \"compose\" parser as a file matching build.gradle.kts was found in ${currentDir}`,\n )\n parser = 'compose'\n return findUp.stop\n } else if (globSync([`${currentDir}/build.gradle`]).length > 0) {\n showParserMessage(\n `Using \"compose\" parser as a file matching build.gradle was found in ${currentDir}`,\n )\n parser = 'compose'\n return findUp.stop\n }\n }\n },\n { cwd: dir },\n )\n\n return parser\n}\n\n// Similarly to determineParserFromProject, this walks up looking for a\n// package.json containing a library which we support and we set a specific\n// label for. An example is Angular, which is detected as 'html' parser, but we\n// set a different label for it.\nexport function determineLabelFromProject(dir: string): string | undefined {\n function showMessage(\n libraryName: string,\n moduleName: string,\n packageJson: any,\n currentDir: string,\n ) {\n showParserMessage(\n `Using \"${libraryName}\" label as package.json containing a \"${moduleName}\" ${\n packageJson.dependencies && packageJson.dependencies[moduleName]\n ? 'dependency'\n : 'peer dependency'\n } was found in ${currentDir}`,\n )\n }\n\n let label: string | undefined\n\n findUp.sync(\n (currentDir) => {\n const packageJsonPath = path.join(currentDir, 'package.json')\n\n if (fs.existsSync(packageJsonPath)) {\n const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'))\n if (packageJsonContains(packageJson, 'angular')) {\n showMessage('Angular', 'angular', packageJson, currentDir)\n label = CodeConnectLabel.Angular\n return findUp.stop\n } else if (packageJsonContains(packageJson, 'vue')) {\n showMessage('Vue', 'vue', packageJson, currentDir)\n label = CodeConnectLabel.Vue\n return findUp.stop\n }\n }\n },\n { cwd: dir },\n )\n\n return label\n}\n\nasync function checkForLegacyConfig(\n config: FigmaConfig & { codeConnect: { swift?: any; react?: any } },\n configFilePath: string,\n): Promise<FigmaConfig> | never {\n const { codeConnect } = config\n\n const newConfigBase = {\n ...(codeConnect.include ? { include: codeConnect.include } : {}),\n ...(codeConnect.exclude ? { exclude: codeConnect.exclude } : {}),\n ...(codeConnect.documentUrlSubstitutions\n ? { documentUrlSubstitutions: codeConnect.documentUrlSubstitutions }\n : {}),\n }\n const maybeNewReactConfig = {\n codeConnect: { parser: 'react', ...codeConnect.react, ...newConfigBase },\n }\n const maybeNewSwiftConfig = {\n codeConnect: { parser: 'swift', ...codeConnect.swift, ...newConfigBase },\n }\n\n if (codeConnect.react && codeConnect.swift) {\n logger.error(`${chalk.bold('⚠️ Your Code Connect configuration needs to be updated\\n')}`)\n\n logger.infoForce(`Code Connect is migrating from a single configuration file for all supported languages, to individual configuration files for each language.\n\nAs part of this change, your Code Connect configuration file needs to be split into two configuration files, one for React and one for Swift.\n\nThe React ${chalk.bold(\n 'figma.config.json',\n )} should be located in your React project root and contain:\n\n${JSON.stringify(maybeNewReactConfig, null, 2)}\n\nThe Swift ${chalk.bold(\n 'figma.config.json',\n )} should be located in your Swift project root and contain:\n\n${JSON.stringify(maybeNewSwiftConfig, null, 2)}\n\nYou will need to check any include/exclude paths are correct relative to the new locations.`)\n exitWithFeedbackMessage(1)\n }\n\n if (codeConnect.react || codeConnect.swift) {\n const platform = codeConnect.react ? 'React' : 'Swift'\n const newConfig = codeConnect.react ? maybeNewReactConfig : maybeNewSwiftConfig\n\n logger.infoForce(\n `${chalk.bold('⚠️ Your Code Connect configuration needs to be updated')}\n\nCode Connect is migrating from a single configuration file for all supported languages, to individual configuration files for each language.\n\nAs part of this change, your Code Connect configuration file needs to be updated to remove the ${chalk.bold(\n platform.toLowerCase(),\n )} key and add ${chalk.bold(`{ parser: \"${platform.toLowerCase()}\" }`)}:\n\n${JSON.stringify(newConfig, null, 2)}\n\nCode Connect can make this change for you automatically, or you can do it manually.\n\nPlease also ensure your configuration file is located in your ${platform} project root. If you move the configuration file, you will need to check any include/exclude paths are correct relative to the new location.\n\nPlease raise an issue at https://github.com/figma/code-connect/issues if you have any problems.\n\n---\n`,\n )\n\n const rl = readline.createInterface({\n input: process.stdin,\n output: process.stderr,\n })\n\n const updateConfig = await new Promise<string>((resolve) => {\n rl.question(\n 'Would you like Code Connect to update your configuration file for you? (y/n) ',\n (answer) => {\n resolve(answer)\n },\n )\n })\n rl.close()\n\n if (updateConfig.toLowerCase() === 'y') {\n fs.writeFileSync(configFilePath, JSON.stringify(newConfig, null, 2))\n logger.infoForce(`\\nConfiguration file updated`)\n return newConfig\n } else {\n exitWithError(`\\nPlease update your configuration file manually`)\n }\n }\n\n return config\n}\n\nasync function parseConfig(configFilePath: string, dir: string): Promise<FigmaConfig | undefined> {\n try {\n const rawData = fs.readFileSync(configFilePath, 'utf-8')\n const rawConfig = JSON.parse(rawData)\n const config = await checkForLegacyConfig(rawConfig, configFilePath)\n\n if (!config.codeConnect?.parser) {\n const parser = determineParserFromProject(dir)\n\n if (!parser) {\n logger.error(\n `Code Connect was not able to determine your project type, and no \\`parser\\` was specified. Please ensure you are running Code Connect from your project root. You may need to add a \\`parser\\` key to your config file, specifying which parser to use. See https://github.com/figma/code-connect/ for instructions.`,\n )\n exitWithFeedbackMessage(1)\n }\n\n if (!config.codeConnect) {\n config.codeConnect = { parser }\n }\n // TS errors if this is in an else\n config.codeConnect.parser = parser\n }\n\n if (!config.codeConnect?.label) {\n const label = determineLabelFromProject(dir)\n if (label) {\n config.codeConnect.label = label\n }\n }\n\n return config\n } catch (error) {\n console.error('Error parsing config file:', error)\n return undefined\n }\n}\n\nexport function getGitRemoteURL(repoPath: string) {\n try {\n const spawn = spawnSync('git', ['config', '--get', 'remote.origin.url'], {\n cwd: repoPath,\n })\n const output = spawn.stdout\n return (output || '').toString().trim()\n } catch (error) {\n console.error('Error getting git remote URL:', error)\n return ''\n }\n}\n\n/**\n * Uses `git rev-parse` to find absolute path to the root of the git repository\n */\nexport function getGitRepoAbsolutePath(filePath: string) {\n try {\n const dirPath = fs.statSync(filePath).isDirectory() ? filePath : path.dirname(filePath)\n const spawn = spawnSync('git', ['rev-parse', '--show-toplevel'], {\n cwd: dirPath,\n })\n const output = spawn.stdout\n return (\n (output || '')\n .toString()\n // git always uses /, but other Node API use \\ on Windows\n .replaceAll('/', path.sep)\n .trim()\n )\n } catch (error: any) {\n console.error('Error running `git rev-parse`:', error.toString().split('\\n')[0])\n return ''\n }\n}\n\n/**\n * Find the default branch name for the git repository\n */\nexport function getGitRepoDefaultBranchName(repoPath: string, configDefaultBranch?: string) {\n const DEFAULT_BRANCH_NAME = 'master'\n\n if (configDefaultBranch) {\n return configDefaultBranch\n }\n\n try {\n const symbolicRefResult = spawnSync('git', ['symbolic-ref', 'refs/remotes/origin/HEAD'], {\n cwd: repoPath,\n })\n\n if (symbolicRefResult.status === 0 && symbolicRefResult.stdout) {\n const ref = symbolicRefResult.stdout.toString().trim()\n // Output format: \"refs/remotes/origin/<branch>\" – take the last segment\n const branch = ref.split('/').pop()\n if (branch) {\n return branch\n }\n }\n\n // Fall back to scanning remote branches for known default branch names\n const gitBranchResult = spawnSync('git', ['branch', '-r'], {\n cwd: repoPath,\n })\n\n if (!gitBranchResult.stdout) {\n return DEFAULT_BRANCH_NAME\n }\n\n const branches = gitBranchResult.stdout\n .toString()\n .trim()\n .split('\\n')\n .map((s) => s.trim())\n\n // Check if origin/main exists, otherwise assume master\n if (branches.includes('origin/main')) {\n return 'main'\n } else {\n return DEFAULT_BRANCH_NAME\n }\n } catch (error: any) {\n console.error('Error getting git default branch name:', error.toString().split('\\n')[0])\n return DEFAULT_BRANCH_NAME\n }\n}\n\n/**\n * Finds the URL of a remote file\n * @param filePath absolute file path on disk\n * @param repoURL remote URL, can be a GitHub, GitLab, Bitbucket, etc. URL.\n * @returns\n */\nexport function getRemoteFileUrl(filePath: string, repoURL?: string, defaultBranch?: string) {\n if (!repoURL) {\n return ''\n }\n\n filePath = filePath.replaceAll(path.sep, '/')\n\n let url = repoURL.trim()\n if (url.startsWith('git@')) {\n url = url.replace(':', '/')\n url = url.replace('git@', 'https://')\n }\n url = url.replace(/\\.git$/, '')\n\n // the folder of the git repo on disk could be named differently,\n // so we need to find the relative path of the file to the root of the repo\n // and append that to the remote URL\n const repoAbsPath = getGitRepoAbsolutePath(filePath)\n // Windows uses \\ as the path separator, so replace with /\n .replaceAll(path.sep, '/')\n\n const resolvedDefaultBranch = getGitRepoDefaultBranchName(repoAbsPath, defaultBranch)\n const index = filePath.indexOf(repoAbsPath)\n if (index === -1) {\n return ''\n }\n\n const relativeFilePath = filePath.substring(index + repoAbsPath.length)\n\n if (url.includes('github.com')) {\n return `${url}/blob/${resolvedDefaultBranch}${relativeFilePath}`\n } else if (url.includes('gitlab.com')) {\n return `${url}/-/blob/${resolvedDefaultBranch}${relativeFilePath}`\n } else if (url.includes('bitbucket.org')) {\n return `${url}/src/${resolvedDefaultBranch}${relativeFilePath}`\n } else if (url.includes('dev.azure.com')) {\n // `git config --get remote.origin.url` for azure repos will return different strings depending on if it was\n // cloned with https or ssh. We need to convert this to a valid URL like \"https://dev.azure.com/org/repo/_git/repo?path=/\"\n if (repoURL.startsWith('git@')) {\n // ssh: \"git@ssh.dev.azure.com:v3/org/repo/repo\"\n const [org, project1, project2] = repoURL.split('/').slice(-3)\n return `https://dev.azure.com/${org}/${project1}/_git/${project2}?path=${relativeFilePath}&branch=${resolvedDefaultBranch}`\n } else {\n // https: \"https://org@dev.azure.com/org/repo/_git/repo\"\n const [_, url] = repoURL.split('@')\n return `https://${url}?path=${relativeFilePath}&branch=${resolvedDefaultBranch}`\n }\n } else {\n logger.debug('Unknown remote URL - assuming GitHub Enterprise', url)\n return `${url}/blob/${resolvedDefaultBranch}${relativeFilePath}`\n }\n}\n\nexport function getStorybookUrl(filePath: string, storybookUrl: string) {\n // the folder of the git repo on disk could be named differently,\n // so we need to find the relative path of the file to the root of the repo\n // and append that to the remote URL\n const repoAbsPath = getGitRepoAbsolutePath(filePath).replaceAll(path.sep, '/')\n const index = filePath.indexOf(repoAbsPath)\n if (index === -1) {\n return ''\n }\n\n const relativeFilePath = filePath.substring(index + repoAbsPath.length + 1) // +1 to remove the leading slash\n const storybookComponentPath = relativeFilePath\n .trim()\n .replace(/[\\s|_]/g, '-')\n .replace(/\\.[jt]sx?$/, '')\n .replaceAll('\\\\', '/')\n .split('/')\n .join('-')\n\n return `${storybookUrl}/?path=/docs/${storybookComponentPath}`\n}\n\nexport type ProjectInfo<ConfigT = CodeConnectConfig> = {\n /**\n * Absolute path of the project directory\n */\n absPath: string\n /**\n * An array of all tsx files in the project\n */\n files: string[]\n /**\n * The git remote URL of the project\n */\n remoteUrl: string\n /**\n * The parsed Code Connect config file\n */\n config: ConfigT\n}\n\nexport type ReactProjectInfo = ProjectInfo<CodeConnectReactConfig> & {\n /**\n * TS program containing all tsx files in the project\n */\n tsProgram: ts.Program\n}\n\nfunction mapToAbsolutePaths(globPaths: string[], absPath: string) {\n // glob doesn't like Windows paths so convert to *nix format\n return globPaths.map((globPath) => `${absPath.replaceAll(path.sep, '/')}/${globPath}`)\n}\n\nexport function getDefaultConfigPath(dir: string) {\n return path.resolve(path.join(dir, DEFAULT_CONFIG_FILE_NAME))\n}\n\nexport function getEnvPath(dir: string) {\n return path.resolve(path.join(dir, ENV_FILE_NAME))\n}\n\nexport async function parseOrDetermineConfig(dir: string, configPath: string) {\n const configFilePath = configPath ? path.resolve(configPath) : getDefaultConfigPath(dir)\n\n const hasConfigFile = fs.existsSync(configFilePath)\n\n if (!hasConfigFile) {\n if (configPath) {\n logger.warn(`${configPath} does not exist, proceeding with default options`)\n } else {\n logger.info(`No config file found in ${dir}, proceeding with default options`)\n }\n }\n\n const globalConfig = hasConfigFile\n ? await parseConfig(configFilePath, dir)\n : determineConfigFromProject(dir)\n\n if (!globalConfig) {\n throw new Error(`Error parsing config file: ${configFilePath}`)\n }\n\n if (!globalConfig.codeConnect) {\n throw new Error(`No options specified under 'codeConnect' in config file: ${configFilePath}`)\n }\n\n const config = globalConfig.codeConnect\n\n if (hasConfigFile) {\n if (!config) {\n logger.info(`Config file found, but no options specified under 'codeConnect'. Parsing ${dir}`)\n } else if (config && !config.include) {\n logger.info(`Config file found, but no include globs specified. Parsing ${dir}`)\n } else {\n logger.info(`Config file found, parsing ${dir} using specified include globs`)\n }\n }\n\n return {\n config,\n hasConfigFile,\n }\n}\n\n/**\n * Check if a .env file exists in the provided directory and if it contains a FIGMA_ACCESS_TOKEN.\n */\nexport async function checkForEnvAndToken(dir: string) {\n // Scan the provided directory for a .env file\n const envPath = await findUp('.env', { cwd: dir })\n\n if (!envPath) {\n // No .env file found\n return {\n hasEnvFile: false,\n envHasFigmaToken: false,\n }\n }\n\n // Read the contents of the .env file\n const envContents = fs.readFileSync(envPath, 'utf-8')\n\n // Determine if the .env file contains a FIGMA_ACCESS_TOKEN\n const envVars = envContents.split('\\n').reduce(\n (\n acc: {\n [key: string]: string\n },\n line,\n ) => {\n const [key, value] = line.split('=')\n acc[key] = value\n return acc\n },\n {},\n )\n\n const figmaAccessToken = envVars['FIGMA_ACCESS_TOKEN']\n\n return {\n hasEnvFile: true,\n envHasFigmaToken: !!figmaAccessToken,\n }\n}\n\n/**\n * Gets information about a project from config.\n *\n * @param dir Directory containing the project\n * @param config Code Connect config\n * @returns Object containing information about the project\n */\nexport async function getProjectInfoFromConfig(\n dir: string,\n config: CodeConnectConfig,\n): Promise<ProjectInfo> {\n const absPath = path.resolve(dir)\n const remoteUrl = getGitRemoteURL(absPath)\n\n const defaultIncludeGlobs = config.parser\n ? DEFAULT_INCLUDE_GLOBS_BY_PARSER[config.parser]\n : undefined\n\n // always ignore any `node_modules` folders in react projects\n const defaultExcludeGlobs = config.parser\n ? ({\n react: ['node_modules/**'],\n html: ['node_modules/**'],\n swift: ['**/__test__/**'],\n compose: [],\n custom: [],\n __unit_test__: [],\n }[config.parser] ?? [])\n : []\n\n const includeGlobs = config.include || defaultIncludeGlobs\n const excludeGlobs = config.exclude\n ? [...config.exclude, ...defaultExcludeGlobs]\n : defaultExcludeGlobs\n\n if (config.parser === 'custom' && (!includeGlobs || includeGlobs.length === 0)) {\n exitWithError('Include globs must specified in config file for custom parsers')\n }\n\n if (!includeGlobs) {\n exitWithError('No include globs specified in config file')\n }\n\n const files = globSync(mapToAbsolutePaths(includeGlobs, absPath), {\n nodir: true,\n ignore: mapToAbsolutePaths(excludeGlobs, absPath),\n // Otherwise this is true on *nix and false on Windows\n absolute: true,\n })\n\n if (files.length > 10000) {\n logger.warn(\n `Matching number of files was excessively large (${files.length}) - consider using more specific include/exclude globs in your config file.`,\n )\n }\n\n return {\n absPath,\n remoteUrl,\n config,\n files,\n }\n}\n\n/**\n * Validates the language field in the config.\n * Throws an error if the language is invalid.\n *\n * @param language The language string to validate\n */\nfunction validateLanguage(language: SyntaxHighlightLanguage | undefined): void {\n if (!language) return\n\n const validLanguages = Object.values(SyntaxHighlightLanguage)\n if (!validLanguages.includes(language)) {\n throw new Error(\n `Invalid language \"${language}\" in figma.config.json. ` +\n `Valid values are: ${validLanguages.join(', ')}`,\n )\n }\n}\n\n/**\n * Gets information about a project from a directory.\n *\n * @param dir Directory containing the project\n * @param configPath Optional path to Code Connect config file\n * @returns Object containing information about the project\n */\nexport async function getProjectInfo(dir: string, configPath: string): Promise<ProjectInfo> {\n const { config } = await parseOrDetermineConfig(dir, configPath)\n\n // Validate language field if present\n validateLanguage(config.language)\n\n return getProjectInfoFromConfig(dir, config)\n}\n\nexport function getReactProjectInfo(\n projectInfo: ProjectInfo<CodeConnectReactConfig>,\n): ReactProjectInfo {\n const tsProgram = getTsProgram(projectInfo)\n\n return {\n ...projectInfo,\n tsProgram,\n }\n}\n\nexport function getTsProgram(projectInfo: ProjectInfo<CodeConnectConfig>): ts.Program {\n const compilerOptions: ts.CompilerOptions = {\n // This ensures the compiler can resolve imports such as \"ui/button\" when a\n // baseUrl is configured in the tsconfig of the project. We probably want a more\n // sophisticated way to parse the users tsconfig and pass it to the compiler eventually.\n baseUrl: projectInfo.absPath,\n // TODO: not sure why Node10 is needed her, but otherwise module resolution for\n // pnpm workspaces won't work\n moduleResolution: ts.ModuleResolutionKind.Node10,\n paths: 'paths' in projectInfo.config ? (projectInfo.config.paths ?? {}) : {},\n allowJs: true,\n }\n\n return ts.createProgram(projectInfo.files, compilerOptions)\n}\n\n/**\n * Change an imported path for a component like `./button` to e.g `@ui/button`, based on the config file.\n * Note that `filePath` here is the path to the source file on disk, not the module specifier.\n *\n * @param filePath\n * @param config\n * @returns\n */\nexport function mapImportPath(filePath: string, config: CodeConnectReactConfig): string | null {\n // Takes the reversed path and pattern parts and check if they match\n function isMatch(patternParts: string[], pathParts: string[]) {\n if (patternParts[0] === '*') {\n // if the path is just a wildcard and nothing else, match any import\n if (patternParts.length === 1) {\n return true\n }\n\n // if the _next_ part in the pattern does not exist in the path, it's not\n // a match.\n const index = pathParts.indexOf(patternParts[1])\n if (index === -1) {\n return false\n }\n\n // Skip to the matching part in the path and match the rest of\n // the pattern. E.g if the pattern is `*/ui/src` (reversed) and the path is\n // `button.tsx/components/ui/src`, we skip to `ui` and match the rest of the\n // pattern.\n patternParts = patternParts.slice(1)\n pathParts = pathParts.slice(index)\n }\n\n for (let i = 0; i < patternParts.length; i++) {\n if (patternParts[i] !== pathParts[i]) {\n return false\n }\n }\n return true\n }\n\n for (const [key, value] of Object.entries(config.importPaths || {})) {\n // Do a partial match from the end of the path\n const patternParts = key.split('/').reverse()\n const pathParts = filePath.split('/').reverse()\n if (pathParts.length < patternParts.length) {\n continue\n }\n\n // If the mapped path ends with a wildcard we want to keep the filename in\n // the final path\n if (isMatch(patternParts, pathParts)) {\n if (value.endsWith('*')) {\n const filename = pathParts[0].split('.')[0]\n return `${value.slice(0, -1)}${filename}`\n }\n return value\n }\n }\n\n return null\n}\n\n/**\n * Transform an import specifier (the path in the import statement) using importPaths config.\n * This works directly on the module specifier from the source code, preserving the user's intent.\n *\n * E.g., '@/AlertTitle' with config { \"@/*\": \"@acme/package/*\" } → '@acme/package/AlertTitle'\n *\n * @param specifier The original import specifier from the source file (e.g., '@/AlertTitle', './Button')\n * @param config The Code Connect config containing importPaths\n * @returns The transformed import path, or null if no mapping matched\n */\nexport function mapImportSpecifier(\n specifier: string,\n config: CodeConnectReactConfig,\n): string | null {\n for (const [pattern, replacement] of Object.entries(config.importPaths || {})) {\n // Convert glob pattern to regex: @/* → ^@/(.*)$\n // First escape special regex chars, then convert * to capture group\n const regexPattern = pattern\n .replace(/[.+?^${}()|[\\]\\\\]/g, '\\\\$&') // Escape special chars except *\n .replace(/\\*/g, '(.*)') // Convert * to capture group\n const regex = new RegExp(`^${regexPattern}$`)\n const match = specifier.match(regex)\n\n if (match) {\n // Replace * in replacement with captured group\n let result = replacement\n if (match[1] !== undefined) {\n result = replacement.replace('*', match[1])\n }\n return result\n }\n }\n return null\n}\n"]}
|
|
1
|
+
{"version":3,"file":"project.js","sourceRoot":"","sources":["../../src/connect/project.ts"],"names":[],"mappings":";;;;;;AAwJA,gEAyBC;AAgFD,8DAuCC;AA0ID,0CAWC;AAKD,wDAkBC;AAKD,kEA8CC;AAQD,4CAmDC;AAED,0CAoBC;AAiCD,oDAEC;AAED,gCAEC;AAED,wDA6CC;AAKD,kDAoCC;AASD,4DAkEC;AA2BD,wCAWC;AAED,kDASC;AAED,oCAcC;AAUD,sCAoDC;AAYD,gDAuBC;AAp8BD,iDAAyC;AACzC,+BAA+B;AAC/B,gDAAuB;AACvB,4CAAmB;AACnB,4DAA2B;AAC3B,+CAAyD;AACzD,kDAAyB;AACzB,wDAA+B;AAC/B,yEAAyE;AACzE,sDAA4B;AAC5B,uCAAmD;AACnD,qEAAoF;AAEpF,MAAM,wBAAwB,GAAG,mBAAmB,CAAA;AACpD,MAAM,aAAa,GAAG,MAAM,CAAA;AAEf,QAAA,+BAA+B,GAAG;IAC7C,KAAK,EAAE,CAAC,gBAAgB,CAAC;IACzB,IAAI,EAAE,CAAC,cAAc,CAAC;IACtB,KAAK,EAAE,CAAC,YAAY,CAAC;IACrB,OAAO,EAAE,CAAC,SAAS,CAAC;IACpB,iEAAiE;IACjE,MAAM,EAAE,SAAS;IACjB,aAAa,EAAE,CAAC,EAAE,CAAC;CACpB,CAAA;AAEY,QAAA,wBAAwB,GAA+C;IAClF,KAAK,EAAE,yCAAgB,CAAC,KAAK;I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C,KAAK,CAAC,KAAK,CAAC,CAAA;QAEpC,IAAI,KAAK,EAAE,CAAC;YACV,+CAA+C;YAC/C,IAAI,MAAM,GAAG,WAAW,CAAA;YACxB,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,SAAS,EAAE,CAAC;gBAC3B,MAAM,GAAG,WAAW,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;YAC7C,CAAC;YACD,OAAO,MAAM,CAAA;QACf,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC","sourcesContent":["import { spawnSync } from 'child_process'\nimport { globSync } from 'glob'\nimport path from 'path'\nimport fs from 'fs'\nimport ts from 'typescript'\nimport { exitWithError, logger } from '../common/logging'\nimport chalk from 'chalk'\nimport readline from 'readline'\n// We use an old version of this dep as I couldn't get ES modules working\nimport findUp from 'find-up'\nimport { exitWithFeedbackMessage } from './helpers'\nimport { CodeConnectLabel, SyntaxHighlightLanguage } from './label_language_mapping'\n\nconst DEFAULT_CONFIG_FILE_NAME = 'figma.config.json'\nconst ENV_FILE_NAME = '.env'\n\nexport const DEFAULT_INCLUDE_GLOBS_BY_PARSER = {\n react: [`**/*.{tsx,jsx}`],\n html: [`**/*.{ts,js}`],\n swift: ['**/*.swift'],\n compose: ['**/*.kt'],\n // include globs should be included in configs for custom parsers\n custom: undefined,\n __unit_test__: [''],\n}\n\nexport const DEFAULT_LABEL_PER_PARSER: Partial<Record<CodeConnectParser, string>> = {\n react: CodeConnectLabel.React,\n html: CodeConnectLabel.WebComponents,\n}\n\n// First party parsers which call into parser executables\nexport type CodeConnectExecutableParser = 'swift' | 'compose' | 'custom' | '__unit_test__'\n\n// React is a special case for now as we call it directly from the CLI rather\n// than via an executable for legacy reasons. We will migrate it to the\n// parser executable model.\nexport type CodeConnectParser = 'react' | 'html' | CodeConnectExecutableParser\n\nexport type BaseCodeConnectConfig = {\n /**\n * Specify glob patterns for files (relative to the project root) to be\n * included when looking for source files. If not specified, all files\n * (except any specified in `exclude`) will be included.\n */\n include?: string[]\n /**\n * Specify glob patterns for files (relative to the project root) to be\n * excluded when looking for source files. If not specified, only\n * `node_modules` will be excluded.\n */\n exclude?: string[]\n /**\n * Optional object of substitutions applied to document URLs (in the format {\n * fromString, toString }) for testing (e.g. remapping a production URL to a\n * staging URL). Not publicly documented.\n */\n documentUrlSubstitutions?: Record<string, string>\n /**\n * The parser name, if using an internal parser.\n */\n parser?: CodeConnectParser\n\n /**\n * Label to use for the uploaded code examples\n */\n label?: string\n\n /**\n * Language to use for syntax highlighting in the uploaded code examples.\n * If not specified, language is inferred from the label or parser type.\n */\n language?: SyntaxHighlightLanguage\n\n /**\n * The URL of the Figma file to use during the interactive setup wizard for connecting code components to Figma components.\n */\n interactiveSetupFigmaFileUrl?: string\n\n /**\n * Custom Figma API URL to use instead of https://api.figma.com/v1\n */\n apiUrl?: string\n\n /**\n * The default branch name for your repository. Code Connect uses this when generating source code\n * links in Figma. If not specified, Code Connect will attempt to determine this automatically.\n */\n defaultBranch?: string\n}\n\nexport type CodeConnectExecutableParserConfig = BaseCodeConnectConfig & {\n parser: CodeConnectExecutableParser\n}\n\nexport type CodeConnectCustomExecutableParserConfig = BaseCodeConnectConfig & {\n parser: 'custom'\n parserCommand: string\n}\n\n/**\n * React specific configuration\n */\nexport type CodeConnectReactConfig = BaseCodeConnectConfig & {\n parser: 'react'\n /**\n * Maps imports from their path on disk to the specified path.\n * This will rewrite the imports in generated code examples, so it works with\n * relative imports such as `import { Button } from \"./\"`.\n *\n * Example: { \"src/components/*\": \"@ui/components\" }\n * Would rewrite imports for components located in `src/components` to `@ui/components` in\n * generated code examples.\n * `import { Button } from \"./\"` -> `import { Button } from \"@ui/components/Button\"`\n */\n importPaths?: Record<string, string>\n /**\n * For import resolution - this is a temporary solution to support projects that use\n * pnpm workspaces, as the compiler doesn't seem to be able to resolve imports when\n * the package in node_modules is a symlink. Need to look into this more and find a\n * better solution.\n */\n paths?: Record<string, string[]>\n /**\n * Storybook specific configuration\n */\n storybook?: {\n /**\n * The URL of the Storybook instance for the project\n */\n url: string\n }\n}\n\nexport type CodeConnectHtmlConfig = BaseCodeConnectConfig & {}\n\nexport type CodeConnectParserlessConfig = BaseCodeConnectConfig & {\n parser: undefined\n}\n\nexport type CodeConnectConfig =\n | CodeConnectReactConfig\n | CodeConnectExecutableParserConfig\n | CodeConnectCustomExecutableParserConfig\n | CodeConnectHtmlConfig\n | BaseCodeConnectConfig\n | CodeConnectParserlessConfig\n\ninterface FigmaConfig {\n codeConnect?: CodeConnectConfig\n}\n\nexport function determineConfigFromProject(\n dir: string,\n exitOnError = true,\n isTemplatesOnlyCLI = false,\n): FigmaConfig | undefined {\n if (isTemplatesOnlyCLI) {\n const label = determineLabelFromProject(dir)\n return { codeConnect: label ? { label } : {} }\n }\n\n const parser = determineParserFromProject(dir)\n if (parser) {\n const label = determineLabelFromProject(dir)\n if (label) {\n return { codeConnect: { parser, label } }\n }\n\n return { codeConnect: { parser } }\n }\n\n if (exitOnError) {\n exitWithError(\n `Code Connect was not able to determine your project type, and no config file was found. Please ensure you are running Code Connect from your project root. You may need to create a config file specifying which parser to use. See https://github.com/figma/code-connect/ for instructions.`,\n )\n }\n}\n\nfunction showParserMessage(message: string) {\n logger.info(\n message +\n '. If this is incorrect, please check you are running Code Connect from your project root, or add a `parser` key to your config file. See https://github.com/figma/code-connect for more information.',\n )\n}\n\nfunction packageJsonContains(packageJson: any, dependency: string) {\n return (\n (packageJson.dependencies && packageJson.dependencies[dependency]) ||\n (packageJson.peerDependencies && packageJson.peerDependencies[dependency]) ||\n (packageJson.devDependencies && packageJson.devDependencies[dependency])\n )\n}\n\n// Walk up from the given directory looking for the first directory which\n// matches heuristics for the platforms we support. This means that e.g. if you\n// have a Swift project inside a React project, we'll detect Swift. This enables\n// users to run commands from anywhere inside their project, rather than having\n// to run from the root (the same way npm works).\nfunction determineParserFromProject(dir: string): CodeConnectParser | undefined {\n let parser: CodeConnectParser | undefined\n\n findUp.sync(\n (currentDir) => {\n const packageJsonPath = path.join(currentDir, 'package.json')\n\n if (fs.existsSync(packageJsonPath)) {\n const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'))\n if (packageJsonContains(packageJson, 'react')) {\n showParserMessage(\n `Using \"react\" parser as package.json containing a \"react\" ${\n packageJson.dependencies && packageJson.dependencies['react']\n ? 'dependency'\n : 'peer dependency'\n } was found in ${currentDir}`,\n )\n parser = 'react'\n return findUp.stop\n } else {\n showParserMessage(\n `Using \"html\" parser as package.json containing no other supported web frameworks was found in ${currentDir}`,\n )\n parser = 'html'\n return findUp.stop\n }\n } else {\n if (globSync([`${currentDir}/*.xcodeproj`, `${currentDir}/Package.swift`]).length > 0) {\n showParserMessage(\n `Using \"swift\" parser as a file matching *.xcodeproj or Package.swift was found in ${currentDir}`,\n )\n parser = 'swift'\n return findUp.stop\n } else if (globSync([`${currentDir}/build.gradle.kts`]).length > 0) {\n showParserMessage(\n `Using \"compose\" parser as a file matching build.gradle.kts was found in ${currentDir}`,\n )\n parser = 'compose'\n return findUp.stop\n } else if (globSync([`${currentDir}/build.gradle`]).length > 0) {\n showParserMessage(\n `Using \"compose\" parser as a file matching build.gradle was found in ${currentDir}`,\n )\n parser = 'compose'\n return findUp.stop\n }\n }\n },\n { cwd: dir },\n )\n\n return parser\n}\n\n// Similarly to determineParserFromProject, this walks up looking for a\n// package.json containing a library which we support and we set a specific\n// label for. An example is Angular, which is detected as 'html' parser, but we\n// set a different label for it.\nexport function determineLabelFromProject(dir: string): string | undefined {\n function showMessage(\n libraryName: string,\n moduleName: string,\n packageJson: any,\n currentDir: string,\n ) {\n showParserMessage(\n `Using \"${libraryName}\" label as package.json containing a \"${moduleName}\" ${\n packageJson.dependencies && packageJson.dependencies[moduleName]\n ? 'dependency'\n : 'peer dependency'\n } was found in ${currentDir}`,\n )\n }\n\n let label: string | undefined\n\n findUp.sync(\n (currentDir) => {\n const packageJsonPath = path.join(currentDir, 'package.json')\n\n if (fs.existsSync(packageJsonPath)) {\n const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'))\n if (packageJsonContains(packageJson, 'angular')) {\n showMessage('Angular', 'angular', packageJson, currentDir)\n label = CodeConnectLabel.Angular\n return findUp.stop\n } else if (packageJsonContains(packageJson, 'vue')) {\n showMessage('Vue', 'vue', packageJson, currentDir)\n label = CodeConnectLabel.Vue\n return findUp.stop\n }\n }\n },\n { cwd: dir },\n )\n\n return label\n}\n\nasync function checkForLegacyConfig(\n config: FigmaConfig & { codeConnect: { swift?: any; react?: any } },\n configFilePath: string,\n): Promise<FigmaConfig> | never {\n const { codeConnect } = config\n\n const newConfigBase = {\n ...(codeConnect.include ? { include: codeConnect.include } : {}),\n ...(codeConnect.exclude ? { exclude: codeConnect.exclude } : {}),\n ...(codeConnect.documentUrlSubstitutions\n ? { documentUrlSubstitutions: codeConnect.documentUrlSubstitutions }\n : {}),\n }\n const maybeNewReactConfig = {\n codeConnect: { parser: 'react', ...codeConnect.react, ...newConfigBase },\n }\n const maybeNewSwiftConfig = {\n codeConnect: { parser: 'swift', ...codeConnect.swift, ...newConfigBase },\n }\n\n if (codeConnect.react && codeConnect.swift) {\n logger.error(`${chalk.bold('⚠️ Your Code Connect configuration needs to be updated\\n')}`)\n\n logger.infoForce(`Code Connect is migrating from a single configuration file for all supported languages, to individual configuration files for each language.\n\nAs part of this change, your Code Connect configuration file needs to be split into two configuration files, one for React and one for Swift.\n\nThe React ${chalk.bold(\n 'figma.config.json',\n )} should be located in your React project root and contain:\n\n${JSON.stringify(maybeNewReactConfig, null, 2)}\n\nThe Swift ${chalk.bold(\n 'figma.config.json',\n )} should be located in your Swift project root and contain:\n\n${JSON.stringify(maybeNewSwiftConfig, null, 2)}\n\nYou will need to check any include/exclude paths are correct relative to the new locations.`)\n exitWithFeedbackMessage(1)\n }\n\n if (codeConnect.react || codeConnect.swift) {\n const platform = codeConnect.react ? 'React' : 'Swift'\n const newConfig = codeConnect.react ? maybeNewReactConfig : maybeNewSwiftConfig\n\n logger.infoForce(\n `${chalk.bold('⚠️ Your Code Connect configuration needs to be updated')}\n\nCode Connect is migrating from a single configuration file for all supported languages, to individual configuration files for each language.\n\nAs part of this change, your Code Connect configuration file needs to be updated to remove the ${chalk.bold(\n platform.toLowerCase(),\n )} key and add ${chalk.bold(`{ parser: \"${platform.toLowerCase()}\" }`)}:\n\n${JSON.stringify(newConfig, null, 2)}\n\nCode Connect can make this change for you automatically, or you can do it manually.\n\nPlease also ensure your configuration file is located in your ${platform} project root. If you move the configuration file, you will need to check any include/exclude paths are correct relative to the new location.\n\nPlease raise an issue at https://github.com/figma/code-connect/issues if you have any problems.\n\n---\n`,\n )\n\n const rl = readline.createInterface({\n input: process.stdin,\n output: process.stderr,\n })\n\n const updateConfig = await new Promise<string>((resolve) => {\n rl.question(\n 'Would you like Code Connect to update your configuration file for you? (y/n) ',\n (answer) => {\n resolve(answer)\n },\n )\n })\n rl.close()\n\n if (updateConfig.toLowerCase() === 'y') {\n fs.writeFileSync(configFilePath, JSON.stringify(newConfig, null, 2))\n logger.infoForce(`\\nConfiguration file updated`)\n return newConfig\n } else {\n exitWithError(`\\nPlease update your configuration file manually`)\n }\n }\n\n return config\n}\n\nasync function parseConfig(\n configFilePath: string,\n dir: string,\n isTemplatesOnlyCLI = false,\n): Promise<FigmaConfig | undefined> {\n try {\n const rawData = fs.readFileSync(configFilePath, 'utf-8')\n const rawConfig = JSON.parse(rawData)\n const config = await checkForLegacyConfig(rawConfig, configFilePath)\n\n if (!isTemplatesOnlyCLI && !config.codeConnect?.parser) {\n const parser = determineParserFromProject(dir)\n\n if (!parser) {\n logger.error(\n `Code Connect was not able to determine your project type, and no \\`parser\\` was specified. Please ensure you are running Code Connect from your project root. You may need to add a \\`parser\\` key to your config file, specifying which parser to use. See https://github.com/figma/code-connect/ for instructions.`,\n )\n exitWithFeedbackMessage(1)\n }\n\n if (!config.codeConnect) {\n config.codeConnect = { parser }\n }\n // TS errors if this is in an else\n config.codeConnect.parser = parser\n }\n\n if (!config.codeConnect?.label) {\n const label = determineLabelFromProject(dir)\n if (label) {\n config.codeConnect = { ...config.codeConnect, label }\n }\n }\n\n return config\n } catch (error) {\n console.error('Error parsing config file:', error)\n return undefined\n }\n}\n\nexport function getGitRemoteURL(repoPath: string) {\n try {\n const spawn = spawnSync('git', ['config', '--get', 'remote.origin.url'], {\n cwd: repoPath,\n })\n const output = spawn.stdout\n return (output || '').toString().trim()\n } catch (error) {\n console.error('Error getting git remote URL:', error)\n return ''\n }\n}\n\n/**\n * Uses `git rev-parse` to find absolute path to the root of the git repository\n */\nexport function getGitRepoAbsolutePath(filePath: string) {\n try {\n const dirPath = fs.statSync(filePath).isDirectory() ? filePath : path.dirname(filePath)\n const spawn = spawnSync('git', ['rev-parse', '--show-toplevel'], {\n cwd: dirPath,\n })\n const output = spawn.stdout\n return (\n (output || '')\n .toString()\n // git always uses /, but other Node API use \\ on Windows\n .replaceAll('/', path.sep)\n .trim()\n )\n } catch (error: any) {\n console.error('Error running `git rev-parse`:', error.toString().split('\\n')[0])\n return ''\n }\n}\n\n/**\n * Find the default branch name for the git repository\n */\nexport function getGitRepoDefaultBranchName(repoPath: string, configDefaultBranch?: string) {\n const DEFAULT_BRANCH_NAME = 'master'\n\n if (configDefaultBranch) {\n return configDefaultBranch\n }\n\n try {\n const symbolicRefResult = spawnSync('git', ['symbolic-ref', 'refs/remotes/origin/HEAD'], {\n cwd: repoPath,\n })\n\n if (symbolicRefResult.status === 0 && symbolicRefResult.stdout) {\n const ref = symbolicRefResult.stdout.toString().trim()\n // Output format: \"refs/remotes/origin/<branch>\" – take the last segment\n const branch = ref.split('/').pop()\n if (branch) {\n return branch\n }\n }\n\n // Fall back to scanning remote branches for known default branch names\n const gitBranchResult = spawnSync('git', ['branch', '-r'], {\n cwd: repoPath,\n })\n\n if (!gitBranchResult.stdout) {\n return DEFAULT_BRANCH_NAME\n }\n\n const branches = gitBranchResult.stdout\n .toString()\n .trim()\n .split('\\n')\n .map((s) => s.trim())\n\n // Check if origin/main exists, otherwise assume master\n if (branches.includes('origin/main')) {\n return 'main'\n } else {\n return DEFAULT_BRANCH_NAME\n }\n } catch (error: any) {\n console.error('Error getting git default branch name:', error.toString().split('\\n')[0])\n return DEFAULT_BRANCH_NAME\n }\n}\n\n/**\n * Finds the URL of a remote file\n * @param filePath absolute file path on disk\n * @param repoURL remote URL, can be a GitHub, GitLab, Bitbucket, etc. URL.\n * @returns\n */\nexport function getRemoteFileUrl(filePath: string, repoURL?: string, defaultBranch?: string) {\n if (!repoURL) {\n return ''\n }\n\n filePath = filePath.replaceAll(path.sep, '/')\n\n let url = repoURL.trim()\n if (url.startsWith('git@')) {\n url = url.replace(':', '/')\n url = url.replace('git@', 'https://')\n }\n url = url.replace(/\\.git$/, '')\n\n // the folder of the git repo on disk could be named differently,\n // so we need to find the relative path of the file to the root of the repo\n // and append that to the remote URL\n const repoAbsPath = getGitRepoAbsolutePath(filePath)\n // Windows uses \\ as the path separator, so replace with /\n .replaceAll(path.sep, '/')\n\n const resolvedDefaultBranch = getGitRepoDefaultBranchName(repoAbsPath, defaultBranch)\n const index = filePath.indexOf(repoAbsPath)\n if (index === -1) {\n return ''\n }\n\n const relativeFilePath = filePath.substring(index + repoAbsPath.length)\n\n if (url.includes('github.com')) {\n return `${url}/blob/${resolvedDefaultBranch}${relativeFilePath}`\n } else if (url.includes('gitlab.com')) {\n return `${url}/-/blob/${resolvedDefaultBranch}${relativeFilePath}`\n } else if (url.includes('bitbucket.org')) {\n return `${url}/src/${resolvedDefaultBranch}${relativeFilePath}`\n } else if (url.includes('dev.azure.com')) {\n // `git config --get remote.origin.url` for azure repos will return different strings depending on if it was\n // cloned with https or ssh. We need to convert this to a valid URL like \"https://dev.azure.com/org/repo/_git/repo?path=/\"\n if (repoURL.startsWith('git@')) {\n // ssh: \"git@ssh.dev.azure.com:v3/org/repo/repo\"\n const [org, project1, project2] = repoURL.split('/').slice(-3)\n return `https://dev.azure.com/${org}/${project1}/_git/${project2}?path=${relativeFilePath}&branch=${resolvedDefaultBranch}`\n } else {\n // https: \"https://org@dev.azure.com/org/repo/_git/repo\"\n const [_, url] = repoURL.split('@')\n return `https://${url}?path=${relativeFilePath}&branch=${resolvedDefaultBranch}`\n }\n } else {\n logger.debug('Unknown remote URL - assuming GitHub Enterprise', url)\n return `${url}/blob/${resolvedDefaultBranch}${relativeFilePath}`\n }\n}\n\nexport function getStorybookUrl(filePath: string, storybookUrl: string) {\n // the folder of the git repo on disk could be named differently,\n // so we need to find the relative path of the file to the root of the repo\n // and append that to the remote URL\n const repoAbsPath = getGitRepoAbsolutePath(filePath).replaceAll(path.sep, '/')\n const index = filePath.indexOf(repoAbsPath)\n if (index === -1) {\n return ''\n }\n\n const relativeFilePath = filePath.substring(index + repoAbsPath.length + 1) // +1 to remove the leading slash\n const storybookComponentPath = relativeFilePath\n .trim()\n .replace(/[\\s|_]/g, '-')\n .replace(/\\.[jt]sx?$/, '')\n .replaceAll('\\\\', '/')\n .split('/')\n .join('-')\n\n return `${storybookUrl}/?path=/docs/${storybookComponentPath}`\n}\n\nexport type ProjectInfo<ConfigT = CodeConnectConfig> = {\n /**\n * Absolute path of the project directory\n */\n absPath: string\n /**\n * An array of all tsx files in the project\n */\n files: string[]\n /**\n * The git remote URL of the project\n */\n remoteUrl: string\n /**\n * The parsed Code Connect config file\n */\n config: ConfigT\n}\n\nexport type ReactProjectInfo = ProjectInfo<CodeConnectReactConfig> & {\n /**\n * TS program containing all tsx files in the project\n */\n tsProgram: ts.Program\n}\n\nfunction mapToAbsolutePaths(globPaths: string[], absPath: string) {\n // glob doesn't like Windows paths so convert to *nix format\n return globPaths.map((globPath) => `${absPath.replaceAll(path.sep, '/')}/${globPath}`)\n}\n\nexport function getDefaultConfigPath(dir: string) {\n return path.resolve(path.join(dir, DEFAULT_CONFIG_FILE_NAME))\n}\n\nexport function getEnvPath(dir: string) {\n return path.resolve(path.join(dir, ENV_FILE_NAME))\n}\n\nexport async function parseOrDetermineConfig(\n dir: string,\n configPath: string,\n isTemplatesOnlyCLI = false,\n) {\n const configFilePath = configPath ? path.resolve(configPath) : getDefaultConfigPath(dir)\n\n const hasConfigFile = fs.existsSync(configFilePath)\n\n if (!hasConfigFile) {\n if (configPath) {\n logger.warn(`${configPath} does not exist, proceeding with default options`)\n } else {\n logger.info(`No config file found in ${dir}, proceeding with default options`)\n }\n }\n\n const globalConfig = hasConfigFile\n ? await parseConfig(configFilePath, dir, isTemplatesOnlyCLI)\n : determineConfigFromProject(dir, true, isTemplatesOnlyCLI)\n\n if (!globalConfig) {\n throw new Error(`Error parsing config file: ${configFilePath}`)\n }\n\n if (!globalConfig.codeConnect) {\n throw new Error(`No options specified under 'codeConnect' in config file: ${configFilePath}`)\n }\n\n const config = globalConfig.codeConnect\n\n if (hasConfigFile) {\n if (!config) {\n logger.info(`Config file found, but no options specified under 'codeConnect'. Parsing ${dir}`)\n } else if (config && !config.include) {\n logger.info(`Config file found, but no include globs specified. Parsing ${dir}`)\n } else {\n logger.info(`Config file found, parsing ${dir} using specified include globs`)\n }\n }\n\n return {\n config,\n hasConfigFile,\n }\n}\n\n/**\n * Check if a .env file exists in the provided directory and if it contains a FIGMA_ACCESS_TOKEN.\n */\nexport async function checkForEnvAndToken(dir: string) {\n // Scan the provided directory for a .env file\n const envPath = await findUp('.env', { cwd: dir })\n\n if (!envPath) {\n // No .env file found\n return {\n hasEnvFile: false,\n envHasFigmaToken: false,\n }\n }\n\n // Read the contents of the .env file\n const envContents = fs.readFileSync(envPath, 'utf-8')\n\n // Determine if the .env file contains a FIGMA_ACCESS_TOKEN\n const envVars = envContents.split('\\n').reduce(\n (\n acc: {\n [key: string]: string\n },\n line,\n ) => {\n const [key, value] = line.split('=')\n acc[key] = value\n return acc\n },\n {},\n )\n\n const figmaAccessToken = envVars['FIGMA_ACCESS_TOKEN']\n\n return {\n hasEnvFile: true,\n envHasFigmaToken: !!figmaAccessToken,\n }\n}\n\n/**\n * Gets information about a project from config.\n *\n * @param dir Directory containing the project\n * @param config Code Connect config\n * @returns Object containing information about the project\n */\nexport async function getProjectInfoFromConfig(\n dir: string,\n config: CodeConnectConfig,\n isTemplatesOnlyCLI = false,\n): Promise<ProjectInfo> {\n const absPath = path.resolve(dir)\n const remoteUrl = getGitRemoteURL(absPath)\n\n const defaultIncludeGlobs = isTemplatesOnlyCLI\n ? [\n '**/*.figma.ts',\n '**/*.figma.js',\n '**/*.figma.template.ts',\n '**/*.figma.template.js',\n '**/*.figma.batch.json',\n ]\n : config.parser\n ? DEFAULT_INCLUDE_GLOBS_BY_PARSER[config.parser]\n : undefined\n\n // always ignore node_modules; for parsers, apply parser-specific exclusions\n const defaultExcludeGlobs = isTemplatesOnlyCLI\n ? ['node_modules/**']\n : config.parser\n ? ({\n react: ['node_modules/**'],\n html: ['node_modules/**'],\n swift: ['**/__test__/**'],\n compose: [],\n custom: [],\n __unit_test__: [],\n }[config.parser] ?? [])\n : []\n\n const includeGlobs = config.include || defaultIncludeGlobs\n const excludeGlobs = config.exclude\n ? [...config.exclude, ...defaultExcludeGlobs]\n : defaultExcludeGlobs\n\n if (config.parser === 'custom' && (!includeGlobs || includeGlobs.length === 0)) {\n exitWithError('Include globs must specified in config file for custom parsers')\n }\n\n if (!includeGlobs) {\n exitWithError('No include globs specified in config file')\n }\n\n const files = globSync(mapToAbsolutePaths(includeGlobs, absPath), {\n nodir: true,\n ignore: mapToAbsolutePaths(excludeGlobs, absPath),\n // Otherwise this is true on *nix and false on Windows\n absolute: true,\n })\n\n if (files.length > 10000) {\n logger.warn(\n `Matching number of files was excessively large (${files.length}) - consider using more specific include/exclude globs in your config file.`,\n )\n }\n\n return {\n absPath,\n remoteUrl,\n config,\n files,\n }\n}\n\n/**\n * Validates the language field in the config.\n * Throws an error if the language is invalid.\n *\n * @param language The language string to validate\n */\nfunction validateLanguage(language: SyntaxHighlightLanguage | undefined): void {\n if (!language) return\n\n const validLanguages = Object.values(SyntaxHighlightLanguage)\n if (!validLanguages.includes(language)) {\n throw new Error(\n `Invalid language \"${language}\" in figma.config.json. ` +\n `Valid values are: ${validLanguages.join(', ')}`,\n )\n }\n}\n\n/**\n * Gets information about a project from a directory.\n *\n * @param dir Directory containing the project\n * @param configPath Optional path to Code Connect config file\n * @returns Object containing information about the project\n */\nexport async function getProjectInfo(\n dir: string,\n configPath: string,\n isTemplatesOnlyCLI = false,\n): Promise<ProjectInfo> {\n const { config } = await parseOrDetermineConfig(dir, configPath, isTemplatesOnlyCLI)\n\n // Validate language field if present\n validateLanguage(config.language)\n\n return getProjectInfoFromConfig(dir, config, isTemplatesOnlyCLI)\n}\n\nexport function getReactProjectInfo(\n projectInfo: ProjectInfo<CodeConnectReactConfig>,\n): ReactProjectInfo {\n const tsProgram = getTsProgram(projectInfo)\n\n return {\n ...projectInfo,\n tsProgram,\n }\n}\n\nexport function getTsProgram(projectInfo: ProjectInfo<CodeConnectConfig>): ts.Program {\n const compilerOptions: ts.CompilerOptions = {\n // This ensures the compiler can resolve imports such as \"ui/button\" when a\n // baseUrl is configured in the tsconfig of the project. We probably want a more\n // sophisticated way to parse the users tsconfig and pass it to the compiler eventually.\n baseUrl: projectInfo.absPath,\n // TODO: not sure why Node10 is needed her, but otherwise module resolution for\n // pnpm workspaces won't work\n moduleResolution: ts.ModuleResolutionKind.Node10,\n paths: 'paths' in projectInfo.config ? (projectInfo.config.paths ?? {}) : {},\n allowJs: true,\n }\n\n return ts.createProgram(projectInfo.files, compilerOptions)\n}\n\n/**\n * Change an imported path for a component like `./button` to e.g `@ui/button`, based on the config file.\n * Note that `filePath` here is the path to the source file on disk, not the module specifier.\n *\n * @param filePath\n * @param config\n * @returns\n */\nexport function mapImportPath(filePath: string, config: CodeConnectReactConfig): string | null {\n // Takes the reversed path and pattern parts and check if they match\n function isMatch(patternParts: string[], pathParts: string[]) {\n if (patternParts[0] === '*') {\n // if the path is just a wildcard and nothing else, match any import\n if (patternParts.length === 1) {\n return true\n }\n\n // if the _next_ part in the pattern does not exist in the path, it's not\n // a match.\n const index = pathParts.indexOf(patternParts[1])\n if (index === -1) {\n return false\n }\n\n // Skip to the matching part in the path and match the rest of\n // the pattern. E.g if the pattern is `*/ui/src` (reversed) and the path is\n // `button.tsx/components/ui/src`, we skip to `ui` and match the rest of the\n // pattern.\n patternParts = patternParts.slice(1)\n pathParts = pathParts.slice(index)\n }\n\n for (let i = 0; i < patternParts.length; i++) {\n if (patternParts[i] !== pathParts[i]) {\n return false\n }\n }\n return true\n }\n\n for (const [key, value] of Object.entries(config.importPaths || {})) {\n // Do a partial match from the end of the path\n const patternParts = key.split('/').reverse()\n const pathParts = filePath.split('/').reverse()\n if (pathParts.length < patternParts.length) {\n continue\n }\n\n // If the mapped path ends with a wildcard we want to keep the filename in\n // the final path\n if (isMatch(patternParts, pathParts)) {\n if (value.endsWith('*')) {\n const filename = pathParts[0].split('.')[0]\n return `${value.slice(0, -1)}${filename}`\n }\n return value\n }\n }\n\n return null\n}\n\n/**\n * Transform an import specifier (the path in the import statement) using importPaths config.\n * This works directly on the module specifier from the source code, preserving the user's intent.\n *\n * E.g., '@/AlertTitle' with config { \"@/*\": \"@acme/package/*\" } → '@acme/package/AlertTitle'\n *\n * @param specifier The original import specifier from the source file (e.g., '@/AlertTitle', './Button')\n * @param config The Code Connect config containing importPaths\n * @returns The transformed import path, or null if no mapping matched\n */\nexport function mapImportSpecifier(\n specifier: string,\n config: CodeConnectReactConfig,\n): string | null {\n for (const [pattern, replacement] of Object.entries(config.importPaths || {})) {\n // Convert glob pattern to regex: @/* → ^@/(.*)$\n // First escape special regex chars, then convert * to capture group\n const regexPattern = pattern\n .replace(/[.+?^${}()|[\\]\\\\]/g, '\\\\$&') // Escape special chars except *\n .replace(/\\*/g, '(.*)') // Convert * to capture group\n const regex = new RegExp(`^${regexPattern}$`)\n const match = specifier.match(regex)\n\n if (match) {\n // Replace * in replacement with captured group\n let result = replacement\n if (match[1] !== undefined) {\n result = replacement.replace('*', match[1])\n }\n return result\n }\n }\n return null\n}\n"]}
|
|
@@ -7,5 +7,12 @@ import { CodeConnectConfig } from './project';
|
|
|
7
7
|
* Code Connect files that share the same extension.
|
|
8
8
|
*/
|
|
9
9
|
export declare function isRawTemplate(content: string): boolean;
|
|
10
|
-
export
|
|
10
|
+
export interface BatchOverrides {
|
|
11
|
+
url: string;
|
|
12
|
+
source?: string;
|
|
13
|
+
component?: string;
|
|
14
|
+
batchData: Record<string, any>;
|
|
15
|
+
batchFilePath: string;
|
|
16
|
+
}
|
|
17
|
+
export declare function parseRawFile(filePath: string, label: string | undefined, config?: CodeConnectConfig, dir?: string, batchOverrides?: BatchOverrides): CodeConnectJSON;
|
|
11
18
|
//# sourceMappingURL=raw_templates.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"raw_templates.d.ts","sourceRoot":"","sources":["../../src/connect/raw_templates.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAI7C;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAatD;AA+ED,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,MAAM,CAAC,EAAE,iBAAiB,EAC1B,GAAG,CAAC,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"raw_templates.d.ts","sourceRoot":"","sources":["../../src/connect/raw_templates.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAI7C;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAatD;AA+ED,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAA;IACX,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC9B,aAAa,EAAE,MAAM,CAAA;CACtB;AAED,wBAAgB,YAAY,CAC1B,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,MAAM,CAAC,EAAE,iBAAiB,EAC1B,GAAG,CAAC,EAAE,MAAM,EACZ,cAAc,CAAC,EAAE,cAAc,GAC9B,eAAe,CA8EjB"}
|