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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> = {\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\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\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\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 | 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((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 {\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/\" – 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 = {\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 & {\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 {\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 {\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,\n): ReactProjectInfo {\n const tsProgram = getTsProgram(projectInfo)\n\n return {\n ...projectInfo,\n tsProgram,\n }\n}\n\nexport function getTsProgram(projectInfo: ProjectInfo): 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"]}