@tamagui/codemod-flat-values 3.0.0-beta.831.1 → 3.0.0-beta.889.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -2
- package/dist/functionalVariants.mjs +469 -0
- package/dist/functionalVariants.mjs.map +1 -0
- package/dist/index.mjs +24 -2
- package/dist/index.mjs.map +1 -1
- package/dist/report.mjs +36 -6
- package/dist/report.mjs.map +1 -1
- package/package.json +6 -6
- package/src/functionalVariants.ts +642 -0
- package/src/index.ts +43 -2
- package/src/report.ts +70 -5
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["index.js"],"sourcesContent":["#!/usr/bin/env node\nimport { existsSync, mkdirSync, writeFileSync } from \"node:fs\";\nimport { dirname, relative, resolve } from \"node:path\";\nimport { resolveTamaguiHost } from \"@tamagui/language-service/host\";\nimport { stylePropsTextOnly } from \"@tamagui/helpers\";\nimport {\n ModuleKind,\n ModuleResolutionKind,\n Node,\n Project,\n ScriptTarget,\n SyntaxKind,\n ts\n} from \"ts-morph\";\nimport { planContainers } from \"./containers\";\nimport { convertJsxSite, convertStyleObject } from \"./convert\";\nimport { compact, unwrapExpression } from \"./expressions\";\nimport {\n codemodMediaNames,\n createModifierRegistry,\n grammarPlatformNames\n} from \"./grammar\";\nimport { createProvenance } from \"./provenance\";\nimport { renderReport } from \"./report\";\nconst projectRoot = process.cwd();\nconst defaultReportPath = resolve(projectRoot, \"tamagui-flat-values-report.md\");\nconst ignoreMarker = \".tamagui-flat-values-ignore\";\nconst ignoredDirectories = /* @__PURE__ */ new Map();\nfunction isIgnored(filePath) {\n let directory = dirname(filePath);\n const visited = [];\n while (directory === projectRoot || !relative(projectRoot, directory).startsWith(\"..\")) {\n const cached = ignoredDirectories.get(directory);\n if (cached !== void 0) {\n for (const seen of visited) ignoredDirectories.set(seen, cached);\n return cached;\n }\n visited.push(directory);\n if (existsSync(resolve(directory, ignoreMarker))) {\n for (const seen of visited) ignoredDirectories.set(seen, true);\n return true;\n }\n if (directory === projectRoot) break;\n const parent = dirname(directory);\n if (parent === directory) break;\n directory = parent;\n }\n for (const seen of visited) ignoredDirectories.set(seen, false);\n return false;\n}\nfunction collectFiles(inputs2) {\n const tsConfigFilePath = resolve(projectRoot, \"tsconfig.json\");\n if (!existsSync(tsConfigFilePath)) {\n console.error(\n `no tsconfig.json in ${projectRoot}; run the codemod from your project root`\n );\n process.exit(2);\n }\n const project = new Project({\n tsConfigFilePath,\n skipAddingFilesFromTsConfig: true,\n compilerOptions: {\n allowJs: false,\n jsx: 4,\n target: ScriptTarget.ES2020,\n module: ModuleKind.ESNext,\n moduleResolution: ModuleResolutionKind.NodeJs,\n skipLibCheck: true,\n strictNullChecks: true,\n baseUrl: projectRoot\n }\n });\n const files2 = /* @__PURE__ */ new Map();\n const ignored = /* @__PURE__ */ new Set();\n const missing = [];\n for (const input of inputs2) {\n const path = resolve(projectRoot, input);\n if (!existsSync(path)) {\n missing.push(input);\n continue;\n }\n const pattern = /\\.[cm]?[jt]sx?$/.test(path) ? path : `${path}/**/*.{ts,tsx}`;\n const matched = project.addSourceFilesAtPaths(pattern);\n if (!matched.length) missing.push(input);\n for (const file of matched) {\n const filePath = file.getFilePath();\n if (isIgnored(filePath)) ignored.add(filePath);\n else files2.set(filePath, file);\n }\n }\n if (missing.length) {\n console.error(\n `no source file matched ${missing.map((input) => `\"${input}\"`).join(\", \")}`\n );\n process.exit(2);\n }\n if (files2.size === 0 && ignored.size > 0) {\n console.error(\n `all ${ignored.size} matched source ${ignored.size === 1 ? \"file was\" : \"files were\"} skipped by ${ignoreMarker}; no migration report was written`\n );\n process.exit(2);\n }\n return {\n sourceFiles: [...files2.values()].sort(\n (left, right) => left.getFilePath().localeCompare(right.getFilePath())\n ),\n ignoredFiles: ignored.size\n };\n}\nfunction themeNames(sourceFiles2) {\n const names = /* @__PURE__ */ new Set([\"light\", \"dark\"]);\n for (const sourceFile of sourceFiles2) {\n for (const name of conditionNames(sourceFile)) {\n if (name.startsWith(\"$theme-\")) names.add(name.slice(\"$theme-\".length));\n }\n }\n return names;\n}\nfunction mediaNames(sourceFiles2) {\n const names = new Set(codemodMediaNames);\n for (const sourceFile of sourceFiles2) {\n for (const name of conditionNames(sourceFile)) {\n if (!name.startsWith(\"$\")) continue;\n if (name.startsWith(\"$theme-\") || name.startsWith(\"$platform-\") || name.startsWith(\"$group-\") || grammarPlatformNames.has(name.slice(1))) {\n continue;\n }\n names.add(name.slice(1));\n }\n }\n return names;\n}\nfunction conditionNames(sourceFile) {\n const names = [];\n for (const attribute of sourceFile.getDescendantsOfKind(SyntaxKind.JsxAttribute)) {\n const name = attribute.getNameNode();\n if (Node.isIdentifier(name)) names.push(name.getText());\n }\n for (const property of sourceFile.getDescendantsOfKind(SyntaxKind.PropertyAssignment)) {\n const name = property.getNameNode();\n if (Node.isComputedPropertyName(name)) continue;\n names.push(name.getText().replace(/^['\"]|['\"]$/g, \"\"));\n }\n return names;\n}\nfunction variantStyleObjects(value) {\n const current = unwrapExpression(value);\n if (Node.isObjectLiteralExpression(current)) return [current];\n if (Node.isConditionalExpression(current)) {\n return [\n ...variantStyleObjects(current.getWhenTrue()),\n ...variantStyleObjects(current.getWhenFalse())\n ];\n }\n if (Node.isArrowFunction(current) || Node.isFunctionExpression(current)) {\n const body = current.getBody();\n if (Node.isBlock(body)) {\n return body.getDescendantsOfKind(SyntaxKind.ReturnStatement).flatMap((statement) => {\n const returned = statement.getExpression();\n return returned ? variantStyleObjects(returned) : [];\n });\n }\n return variantStyleObjects(body);\n }\n return [];\n}\nfunction variantSites(config, label, registry, containers, targets, host, write2) {\n const sites = [];\n const variants = config.getProperty(\"variants\");\n if (Node.isPropertyAssignment(variants)) {\n const object = unwrapExpression(variants.getInitializerOrThrow());\n if (Node.isObjectLiteralExpression(object)) {\n for (const variant of object.getProperties()) {\n if (!Node.isPropertyAssignment(variant)) continue;\n const variantName = compact(variant.getNameNode().getText());\n const branches = unwrapExpression(variant.getInitializerOrThrow());\n if (!Node.isObjectLiteralExpression(branches)) continue;\n for (const branch of branches.getProperties()) {\n if (!Node.isPropertyAssignment(branch)) continue;\n const branchName = compact(branch.getNameNode().getText());\n for (const style of variantStyleObjects(branch.getInitializerOrThrow())) {\n const site = convertStyleObject(\n style,\n \"styled\",\n `${label} variants.${variantName}.${branchName}`,\n registry,\n containers,\n targets,\n host,\n write2\n );\n if (site) sites.push(site);\n }\n }\n }\n }\n }\n return sites;\n}\nfunction conversionTargets(filePath) {\n if (/\\.web\\.[cm]?[jt]sx?$/.test(filePath)) return \"web\";\n if (/\\.native\\.[cm]?[jt]sx?$/.test(filePath)) return \"native\";\n return \"shared\";\n}\nfunction typeAwareHost(node) {\n const checker = node.getProject().getTypeChecker().compilerObject;\n const host = resolveTamaguiHost(\n checker,\n node.compilerNode\n );\n if (!host || node.getText() !== \"View\") return host;\n return {\n ...host,\n accepts: (property) => !(property in stylePropsTextOnly) && host.accepts(property)\n };\n}\nfunction inspectFile(sourceFile, registry, provenance2, write2) {\n const containers = planContainers(sourceFile, registry);\n const targets = conversionTargets(sourceFile.getFilePath());\n const sites = [];\n const styledCalls = sourceFile.getDescendantsOfKind(SyntaxKind.CallExpression).filter((call) => provenance2.isTamaguiStyledCall(call)).sort((left, right) => right.getStart() - left.getStart());\n const jsxOpenings = [\n ...sourceFile.getDescendantsOfKind(SyntaxKind.JsxOpeningElement),\n ...sourceFile.getDescendantsOfKind(SyntaxKind.JsxSelfClosingElement)\n ].filter((opening) => provenance2.isTamaguiElement(opening)).sort((left, right) => right.getStart() - left.getStart());\n for (const opening of jsxOpenings) {\n const site = convertJsxSite(\n opening,\n registry,\n containers,\n targets,\n typeAwareHost(opening.getTagNameNode()),\n write2\n );\n if (site) sites.push(site);\n }\n for (const call of styledCalls) {\n const component = call.getArguments()[0];\n const host = component ? typeAwareHost(component) : void 0;\n const config = unwrapExpression(\n call.getArguments()[1] ?? call\n );\n if (!Node.isObjectLiteralExpression(config)) continue;\n const label = `styled(${compact(call.getArguments()[0]?.getText() ?? \"unknown\")}, \\u2026)`;\n sites.push(...variantSites(config, label, registry, containers, targets, host, write2));\n const site = convertStyleObject(\n config,\n \"styled\",\n label,\n registry,\n containers,\n targets,\n host,\n write2\n );\n if (site) sites.push(site);\n }\n sites.sort(\n (left, right) => left.line - right.line || left.label.localeCompare(right.label)\n );\n return { file: relative(projectRoot, sourceFile.getFilePath()), sites };\n}\nconst usage = `Converts Tamagui style syntax to V3 flat property values and reports what it cannot convert.\n\n npx @tamagui/codemod-flat-values [options] <files or directories...>\n\n --report <path> where to write the Markdown report (default: ${relative(\n projectRoot,\n defaultReportPath\n)})\n --json <path> also write the machine-readable report\n --write rewrite every statically safe conversion in place\n --help print this\n\nRun it from your project root, which is where paths and the tsconfig resolve from.\nSource files are only written with --write.`;\nfunction parseArguments(argv) {\n const inputs2 = [];\n let reportPath2 = defaultReportPath;\n let jsonPath2 = null;\n let write2 = false;\n for (let index = 0; index < argv.length; index++) {\n const argument = argv[index];\n if (argument === \"--help\" || argument === \"-h\") {\n console.log(usage);\n process.exit(0);\n }\n if (argument === \"--write\") {\n write2 = true;\n continue;\n }\n if (argument === \"--report\" || argument === \"--json\") {\n const next = argv[index + 1];\n if (!next) {\n console.error(`${argument} requires a path\n\n${usage}`);\n process.exit(2);\n }\n if (argument === \"--report\") reportPath2 = resolve(next);\n else jsonPath2 = resolve(next);\n index++;\n continue;\n }\n if (argument.startsWith(\"-\")) {\n console.error(`unknown option \"${argument}\"\n\n${usage}`);\n process.exit(2);\n }\n inputs2.push(argument);\n }\n if (!inputs2.length) {\n console.error(`no files or directories given\n\n${usage}`);\n process.exit(2);\n }\n return { reportPath: reportPath2, jsonPath: jsonPath2, inputs: inputs2, write: write2 };\n}\nconst { reportPath, jsonPath, inputs, write } = parseArguments(process.argv.slice(2));\nconst { sourceFiles, ignoredFiles } = collectFiles(inputs);\nfor (const sourceFile of sourceFiles) {\n const diagnostics = sourceFile.compilerNode.parseDiagnostics;\n if (diagnostics?.length) {\n console.error(\n `${relative(projectRoot, sourceFile.getFilePath())}: source has parse errors; no files were written`\n );\n process.exit(2);\n }\n}\nconst originals = new Map(\n sourceFiles.map((sourceFile) => [sourceFile.getFilePath(), sourceFile.getFullText()])\n);\nconst modifierRegistry = createModifierRegistry({\n mediaNames: mediaNames(sourceFiles),\n themeNames: themeNames(sourceFiles)\n});\nconst provenance = createProvenance();\nconst files = sourceFiles.map(\n (sourceFile) => inspectFile(sourceFile, modifierRegistry.registry, provenance, write)\n);\nif (write) {\n for (const sourceFile of sourceFiles) {\n const filePath = sourceFile.getFilePath();\n const parsed = ts.createSourceFile(\n filePath,\n sourceFile.getFullText(),\n ScriptTarget.Latest,\n true,\n filePath.endsWith(\"x\") ? ts.ScriptKind.TSX : ts.ScriptKind.TS\n );\n if (parsed.parseDiagnostics?.length) {\n const details = parsed.parseDiagnostics.map((diagnostic) => {\n const start = diagnostic.start ?? 0;\n const position = parsed.getLineAndCharacterOfPosition(start);\n const line = parsed.text.split(/\\r?\\n/)[position.line] ?? \"\";\n return `${position.line + 1}:${position.character + 1} ${ts.flattenDiagnosticMessageText(\n diagnostic.messageText,\n \"\\n\"\n )}\n ${line.trim()}`;\n }).join(\"\\n\");\n console.error(\n `${relative(projectRoot, filePath)}: rewrite produced parse errors; no files were written\n${details}`\n );\n process.exit(2);\n }\n }\n}\nconst { text, summary } = renderReport(\n files,\n inputs.map((input) => relative(projectRoot, resolve(projectRoot, input))),\n modifierRegistry.diagnostics,\n ignoredFiles,\n write\n);\nmkdirSync(dirname(reportPath), { recursive: true });\nwriteFileSync(reportPath, text);\nif (jsonPath !== null) {\n mkdirSync(dirname(jsonPath), { recursive: true });\n writeFileSync(jsonPath, `${JSON.stringify({ files, summary }, null, 2)}\n`);\n}\nlet written = 0;\nif (write) {\n for (const sourceFile of sourceFiles) {\n const next = sourceFile.getFullText();\n if (next === originals.get(sourceFile.getFilePath())) continue;\n writeFileSync(sourceFile.getFilePath(), next);\n written++;\n }\n}\nconsole.log(`wrote ${reportPath}`);\nif (write) console.log(`rewrote ${written} source files`);\nconsole.log(\n `${summary.sites} sites: ${summary.clean - summary.waiting} clean, ${summary.needsRelocation} need relocation, ${summary.unknownHost} unknown host, ${summary.ineligible} ineligible, ${summary.waiting} waiting on runtime support, ${summary.flagged} syntax-flagged; ${summary.ignoredFiles} source files ignored`\n);\n//# sourceMappingURL=index.js.map\n"],"mappings":";;;;;;;;;;;;;;AAwBA,MAAM,cAAc,QAAQ,IAAI;AAChC,MAAM,oBAAoB,QAAQ,aAAa,+BAA+B;AAC9E,MAAM,eAAe;AACrB,MAAM,qCAAqC,IAAI,IAAI;AACnD,SAAS,UAAU,UAAU;CAC3B,IAAI,YAAY,QAAQ,QAAQ;CAChC,MAAM,UAAU,CAAC;CACjB,OAAO,cAAc,eAAe,CAAC,SAAS,aAAa,SAAS,CAAC,CAAC,WAAW,IAAI,GAAG;EACtF,MAAM,SAAS,mBAAmB,IAAI,SAAS;EAC/C,IAAI,WAAW,KAAK,GAAG;GACrB,KAAK,MAAM,QAAQ,SAAS,mBAAmB,IAAI,MAAM,MAAM;GAC/D,OAAO;EACT;EACA,QAAQ,KAAK,SAAS;EACtB,IAAI,WAAW,QAAQ,WAAW,YAAY,CAAC,GAAG;GAChD,KAAK,MAAM,QAAQ,SAAS,mBAAmB,IAAI,MAAM,IAAI;GAC7D,OAAO;EACT;EACA,IAAI,cAAc,aAAa;EAC/B,MAAM,SAAS,QAAQ,SAAS;EAChC,IAAI,WAAW,WAAW;EAC1B,YAAY;CACd;CACA,KAAK,MAAM,QAAQ,SAAS,mBAAmB,IAAI,MAAM,KAAK;CAC9D,OAAO;AACT;AACA,SAAS,aAAa,SAAS;CAC7B,MAAM,mBAAmB,QAAQ,aAAa,eAAe;CAC7D,IAAI,CAAC,WAAW,gBAAgB,GAAG;EACjC,QAAQ,MACN,uBAAuB,YAAY,yCACrC;EACA,QAAQ,KAAK,CAAC;CAChB;CACA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AQ,aAAa,sBACjS"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["index.js"],"sourcesContent":["#!/usr/bin/env node\nimport { existsSync, mkdirSync, writeFileSync } from \"node:fs\";\nimport { dirname, relative, resolve } from \"node:path\";\nimport { resolveTamaguiHost } from \"@tamagui/language-service/host\";\nimport { stylePropsTextOnly } from \"@tamagui/helpers\";\nimport {\n ModuleKind,\n ModuleResolutionKind,\n Node,\n Project,\n ScriptTarget,\n SyntaxKind,\n ts\n} from \"ts-morph\";\nimport { planContainers } from \"./containers\";\nimport { convertJsxSite, convertStyleObject } from \"./convert\";\nimport { compact, unwrapExpression } from \"./expressions\";\nimport {\n addFunctionalVariantTypeImports,\n convertFunctionalVariants\n} from \"./functionalVariants\";\nimport {\n codemodMediaNames,\n createModifierRegistry,\n grammarPlatformNames\n} from \"./grammar\";\nimport { createProvenance } from \"./provenance\";\nimport { renderReport } from \"./report\";\nconst projectRoot = process.cwd();\nconst defaultReportPath = resolve(projectRoot, \"tamagui-flat-values-report.md\");\nconst ignoreMarker = \".tamagui-flat-values-ignore\";\nconst ignoredDirectories = /* @__PURE__ */ new Map();\nfunction isIgnored(filePath) {\n let directory = dirname(filePath);\n const visited = [];\n while (directory === projectRoot || !relative(projectRoot, directory).startsWith(\"..\")) {\n const cached = ignoredDirectories.get(directory);\n if (cached !== void 0) {\n for (const seen of visited) ignoredDirectories.set(seen, cached);\n return cached;\n }\n visited.push(directory);\n if (existsSync(resolve(directory, ignoreMarker))) {\n for (const seen of visited) ignoredDirectories.set(seen, true);\n return true;\n }\n if (directory === projectRoot) break;\n const parent = dirname(directory);\n if (parent === directory) break;\n directory = parent;\n }\n for (const seen of visited) ignoredDirectories.set(seen, false);\n return false;\n}\nfunction collectFiles(inputs2) {\n const tsConfigFilePath = resolve(projectRoot, \"tsconfig.json\");\n if (!existsSync(tsConfigFilePath)) {\n console.error(\n `no tsconfig.json in ${projectRoot}; run the codemod from your project root`\n );\n process.exit(2);\n }\n const project = new Project({\n tsConfigFilePath,\n skipAddingFilesFromTsConfig: true,\n compilerOptions: {\n allowJs: false,\n jsx: 4,\n target: ScriptTarget.ES2020,\n module: ModuleKind.ESNext,\n moduleResolution: ModuleResolutionKind.NodeJs,\n skipLibCheck: true,\n strictNullChecks: true,\n baseUrl: projectRoot\n }\n });\n const files2 = /* @__PURE__ */ new Map();\n const ignored = /* @__PURE__ */ new Set();\n const missing = [];\n for (const input of inputs2) {\n const path = resolve(projectRoot, input);\n if (!existsSync(path)) {\n missing.push(input);\n continue;\n }\n const pattern = /\\.[cm]?[jt]sx?$/.test(path) ? path : `${path}/**/*.{ts,tsx}`;\n const matched = project.addSourceFilesAtPaths(pattern);\n if (!matched.length) missing.push(input);\n for (const file of matched) {\n const filePath = file.getFilePath();\n if (isIgnored(filePath)) ignored.add(filePath);\n else files2.set(filePath, file);\n }\n }\n if (missing.length) {\n console.error(\n `no source file matched ${missing.map((input) => `\"${input}\"`).join(\", \")}`\n );\n process.exit(2);\n }\n if (files2.size === 0 && ignored.size > 0) {\n console.error(\n `all ${ignored.size} matched source ${ignored.size === 1 ? \"file was\" : \"files were\"} skipped by ${ignoreMarker}; no migration report was written`\n );\n process.exit(2);\n }\n return {\n sourceFiles: [...files2.values()].sort(\n (left, right) => left.getFilePath().localeCompare(right.getFilePath())\n ),\n ignoredFiles: ignored.size\n };\n}\nfunction themeNames(sourceFiles2) {\n const names = /* @__PURE__ */ new Set([\"light\", \"dark\"]);\n for (const sourceFile of sourceFiles2) {\n for (const name of conditionNames(sourceFile)) {\n if (name.startsWith(\"$theme-\")) names.add(name.slice(\"$theme-\".length));\n }\n }\n return names;\n}\nfunction mediaNames(sourceFiles2) {\n const names = new Set(codemodMediaNames);\n for (const sourceFile of sourceFiles2) {\n for (const name of conditionNames(sourceFile)) {\n if (!name.startsWith(\"$\")) continue;\n if (name.startsWith(\"$theme-\") || name.startsWith(\"$platform-\") || name.startsWith(\"$group-\") || grammarPlatformNames.has(name.slice(1))) {\n continue;\n }\n names.add(name.slice(1));\n }\n }\n return names;\n}\nfunction conditionNames(sourceFile) {\n const names = [];\n for (const attribute of sourceFile.getDescendantsOfKind(SyntaxKind.JsxAttribute)) {\n const name = attribute.getNameNode();\n if (Node.isIdentifier(name)) names.push(name.getText());\n }\n for (const property of sourceFile.getDescendantsOfKind(SyntaxKind.PropertyAssignment)) {\n const name = property.getNameNode();\n if (Node.isComputedPropertyName(name)) continue;\n names.push(name.getText().replace(/^['\"]|['\"]$/g, \"\"));\n }\n return names;\n}\nfunction variantStyleObjects(value) {\n const current = unwrapExpression(value);\n if (Node.isObjectLiteralExpression(current)) return [current];\n if (Node.isConditionalExpression(current)) {\n return [\n ...variantStyleObjects(current.getWhenTrue()),\n ...variantStyleObjects(current.getWhenFalse())\n ];\n }\n if (Node.isArrowFunction(current) || Node.isFunctionExpression(current)) {\n const body = current.getBody();\n if (Node.isBlock(body)) {\n return body.getDescendantsOfKind(SyntaxKind.ReturnStatement).flatMap((statement) => {\n const returned = statement.getExpression();\n return returned ? variantStyleObjects(returned) : [];\n });\n }\n return variantStyleObjects(body);\n }\n return [];\n}\nfunction variantSites(config, label, registry, containers, targets, host, write2) {\n const sites = [];\n const variants = config.getProperty(\"variants\");\n if (Node.isPropertyAssignment(variants)) {\n const object = unwrapExpression(variants.getInitializerOrThrow());\n if (Node.isObjectLiteralExpression(object)) {\n for (const variant of object.getProperties()) {\n if (!Node.isPropertyAssignment(variant)) continue;\n const variantName = compact(variant.getNameNode().getText());\n const branches = unwrapExpression(variant.getInitializerOrThrow());\n if (Node.isCallExpression(branches)) {\n const callee = branches.getExpression();\n if (Node.isPropertyAccessExpression(callee) && callee.getName() === \"dynamic\") {\n const body = branches.getArguments()[0];\n if (body && Node.isExpression(body)) {\n for (const style of variantStyleObjects(body)) {\n const site = convertStyleObject(\n style,\n \"styled\",\n `${label} variants.${variantName}`,\n registry,\n containers,\n targets,\n host,\n write2\n );\n if (site) sites.push(site);\n }\n }\n }\n continue;\n }\n if (!Node.isObjectLiteralExpression(branches)) continue;\n for (const branch of branches.getProperties()) {\n if (!Node.isPropertyAssignment(branch)) continue;\n const branchName = compact(branch.getNameNode().getText());\n for (const style of variantStyleObjects(branch.getInitializerOrThrow())) {\n const site = convertStyleObject(\n style,\n \"styled\",\n `${label} variants.${variantName}.${branchName}`,\n registry,\n containers,\n targets,\n host,\n write2\n );\n if (site) sites.push(site);\n }\n }\n }\n }\n }\n return sites;\n}\nfunction conversionTargets(filePath) {\n if (/\\.web\\.[cm]?[jt]sx?$/.test(filePath)) return \"web\";\n if (/\\.native\\.[cm]?[jt]sx?$/.test(filePath)) return \"native\";\n return \"shared\";\n}\nfunction typeAwareHost(node) {\n const checker = node.getProject().getTypeChecker().compilerObject;\n const host = resolveTamaguiHost(\n checker,\n node.compilerNode\n );\n if (!host || node.getText() !== \"View\") return host;\n return {\n ...host,\n accepts: (property) => !(property in stylePropsTextOnly) && host.accepts(property)\n };\n}\nfunction inspectFile(sourceFile, registry, provenance2, write2) {\n const containers = planContainers(sourceFile, registry);\n const targets = conversionTargets(sourceFile.getFilePath());\n const sites = [];\n const functionalVariants = [];\n const requiredTypeImports = [];\n const styledCalls = sourceFile.getDescendantsOfKind(SyntaxKind.CallExpression).filter((call) => provenance2.isTamaguiStyledCall(call)).sort((left, right) => right.getStart() - left.getStart());\n const jsxOpenings = [\n ...sourceFile.getDescendantsOfKind(SyntaxKind.JsxOpeningElement),\n ...sourceFile.getDescendantsOfKind(SyntaxKind.JsxSelfClosingElement)\n ].filter((opening) => provenance2.isTamaguiElement(opening)).sort((left, right) => right.getStart() - left.getStart());\n for (const opening of jsxOpenings) {\n const site = convertJsxSite(\n opening,\n registry,\n containers,\n targets,\n typeAwareHost(opening.getTagNameNode()),\n write2\n );\n if (site) sites.push(site);\n }\n for (const call of styledCalls) {\n const component = call.getArguments()[0];\n const host = component ? typeAwareHost(component) : void 0;\n const config = unwrapExpression(\n call.getArguments()[1] ?? call\n );\n if (!Node.isObjectLiteralExpression(config)) continue;\n const label = `styled(${compact(call.getArguments()[0]?.getText() ?? \"unknown\")}, \\u2026)`;\n sites.push(...variantSites(config, label, registry, containers, targets, host, write2));\n const functional = convertFunctionalVariants(config, label, write2);\n functionalVariants.push(...functional.sites);\n requiredTypeImports.push(...functional.requiredTypeImports);\n const site = convertStyleObject(\n config,\n \"styled\",\n label,\n registry,\n containers,\n targets,\n host,\n write2\n );\n if (site) sites.push(site);\n }\n sites.sort(\n (left, right) => left.line - right.line || left.label.localeCompare(right.label)\n );\n functionalVariants.sort(\n (left, right) => left.line - right.line || left.label.localeCompare(right.label)\n );\n if (write2) addFunctionalVariantTypeImports(sourceFile, requiredTypeImports);\n return {\n file: relative(projectRoot, sourceFile.getFilePath()),\n sites,\n functionalVariants\n };\n}\nconst usage = `Converts Tamagui style syntax to V3 flat property values and reports what it cannot convert.\n\n npx @tamagui/codemod-flat-values [options] <files or directories...>\n\n --report <path> where to write the Markdown report (default: ${relative(\n projectRoot,\n defaultReportPath\n)})\n --json <path> also write the machine-readable report\n --write rewrite every statically safe conversion in place\n --help print this\n\nRun it from your project root, which is where paths and the tsconfig resolve from.\nSource files are only written with --write.`;\nfunction parseArguments(argv) {\n const inputs2 = [];\n let reportPath2 = defaultReportPath;\n let jsonPath2 = null;\n let write2 = false;\n for (let index = 0; index < argv.length; index++) {\n const argument = argv[index];\n if (argument === \"--help\" || argument === \"-h\") {\n console.log(usage);\n process.exit(0);\n }\n if (argument === \"--write\") {\n write2 = true;\n continue;\n }\n if (argument === \"--report\" || argument === \"--json\") {\n const next = argv[index + 1];\n if (!next) {\n console.error(`${argument} requires a path\n\n${usage}`);\n process.exit(2);\n }\n if (argument === \"--report\") reportPath2 = resolve(next);\n else jsonPath2 = resolve(next);\n index++;\n continue;\n }\n if (argument.startsWith(\"-\")) {\n console.error(`unknown option \"${argument}\"\n\n${usage}`);\n process.exit(2);\n }\n inputs2.push(argument);\n }\n if (!inputs2.length) {\n console.error(`no files or directories given\n\n${usage}`);\n process.exit(2);\n }\n return { reportPath: reportPath2, jsonPath: jsonPath2, inputs: inputs2, write: write2 };\n}\nconst { reportPath, jsonPath, inputs, write } = parseArguments(process.argv.slice(2));\nconst { sourceFiles, ignoredFiles } = collectFiles(inputs);\nfor (const sourceFile of sourceFiles) {\n const diagnostics = sourceFile.compilerNode.parseDiagnostics;\n if (diagnostics?.length) {\n console.error(\n `${relative(projectRoot, sourceFile.getFilePath())}: source has parse errors; no files were written`\n );\n process.exit(2);\n }\n}\nconst originals = new Map(\n sourceFiles.map((sourceFile) => [sourceFile.getFilePath(), sourceFile.getFullText()])\n);\nconst modifierRegistry = createModifierRegistry({\n mediaNames: mediaNames(sourceFiles),\n themeNames: themeNames(sourceFiles)\n});\nconst provenance = createProvenance();\nconst files = sourceFiles.map(\n (sourceFile) => inspectFile(sourceFile, modifierRegistry.registry, provenance, write)\n);\nif (write) {\n for (const sourceFile of sourceFiles) {\n const filePath = sourceFile.getFilePath();\n const parsed = ts.createSourceFile(\n filePath,\n sourceFile.getFullText(),\n ScriptTarget.Latest,\n true,\n filePath.endsWith(\"x\") ? ts.ScriptKind.TSX : ts.ScriptKind.TS\n );\n if (parsed.parseDiagnostics?.length) {\n const details = parsed.parseDiagnostics.map((diagnostic) => {\n const start = diagnostic.start ?? 0;\n const position = parsed.getLineAndCharacterOfPosition(start);\n const line = parsed.text.split(/\\r?\\n/)[position.line] ?? \"\";\n return `${position.line + 1}:${position.character + 1} ${ts.flattenDiagnosticMessageText(\n diagnostic.messageText,\n \"\\n\"\n )}\n ${line.trim()}`;\n }).join(\"\\n\");\n console.error(\n `${relative(projectRoot, filePath)}: rewrite produced parse errors; no files were written\n${details}`\n );\n process.exit(2);\n }\n }\n}\nconst { text, summary } = renderReport(\n files,\n inputs.map((input) => relative(projectRoot, resolve(projectRoot, input))),\n modifierRegistry.diagnostics,\n ignoredFiles,\n write\n);\nmkdirSync(dirname(reportPath), { recursive: true });\nwriteFileSync(reportPath, text);\nif (jsonPath !== null) {\n mkdirSync(dirname(jsonPath), { recursive: true });\n writeFileSync(jsonPath, `${JSON.stringify({ files, summary }, null, 2)}\n`);\n}\nlet written = 0;\nif (write) {\n for (const sourceFile of sourceFiles) {\n const next = sourceFile.getFullText();\n if (next === originals.get(sourceFile.getFilePath())) continue;\n writeFileSync(sourceFile.getFilePath(), next);\n written++;\n }\n}\nconsole.log(`wrote ${reportPath}`);\nif (write) console.log(`rewrote ${written} source files`);\nconsole.log(\n `${summary.sites} style sites: ${summary.clean - summary.waiting} clean, ${summary.needsRelocation} need relocation, ${summary.unknownHost} unknown host, ${summary.ineligible} ineligible, ${summary.waiting} waiting on runtime support, ${summary.flagged} syntax-flagged; ${summary.functionalVariantSites} functional variants: ${summary.functionalVariantConverted} automatic, ${summary.functionalVariantFlagged} flagged; ${summary.ignoredFiles} source files ignored`\n);\n//# sourceMappingURL=index.js.map\n"],"mappings":";;;;;;;;;;;;;;;AA4BA,MAAM,cAAc,QAAQ,IAAI;AAChC,MAAM,oBAAoB,QAAQ,aAAa,+BAA+B;AAC9E,MAAM,eAAe;AACrB,MAAM,qCAAqC,IAAI,IAAI;AACnD,SAAS,UAAU,UAAU;CAC3B,IAAI,YAAY,QAAQ,QAAQ;CAChC,MAAM,UAAU,CAAC;CACjB,OAAO,cAAc,eAAe,CAAC,SAAS,aAAa,SAAS,CAAC,CAAC,WAAW,IAAI,GAAG;EACtF,MAAM,SAAS,mBAAmB,IAAI,SAAS;EAC/C,IAAI,WAAW,KAAK,GAAG;GACrB,KAAK,MAAM,QAAQ,SAAS,mBAAmB,IAAI,MAAM,MAAM;GAC/D,OAAO;EACT;EACA,QAAQ,KAAK,SAAS;EACtB,IAAI,WAAW,QAAQ,WAAW,YAAY,CAAC,GAAG;GAChD,KAAK,MAAM,QAAQ,SAAS,mBAAmB,IAAI,MAAM,IAAI;GAC7D,OAAO;EACT;EACA,IAAI,cAAc,aAAa;EAC/B,MAAM,SAAS,QAAQ,SAAS;EAChC,IAAI,WAAW,WAAW;EAC1B,YAAY;CACd;CACA,KAAK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AAC,KAAK,IAAI;GACZ,QAAQ,MACN,GAAG,SAAS,aAAa,QAAQ,EAAE;EACzC,SACI;GACA,QAAQ,KAAK,CAAC;EAChB;CACF;AACF;AACA,MAAM,EAAE,MAAM,YAAY,aACxB,OACA,OAAO,KAAK,UAAU,SAAS,aAAa,QAAQ,aAAa,KAAK,CAAC,CAAC,GACxE,iBAAiB,aACjB,cACA,KACF;AACA,UAAU,QAAQ,UAAU,GAAG,EAAE,WAAW,KAAK,CAAC;AAClD,cAAc,YAAY,IAAI;AAC9B,IAAI,aAAa,MAAM;CACrB,UAAU,QAAQ,QAAQ,GAAG,EAAE,WAAW,KAAK,CAAC;CAChD,cAAc,UAAU,GAAG,KAAK,UAAU;EAAE;EAAO;CAAQ,GAAG,MAAM,CAAC,EAAE;CACxE;AACD;AACA,IAAI,UAAU;AACd,IAAI,OAAO;CACT,KAAK,MAAM,cAAc,aAAa;EACpC,MAAM,OAAO,WAAW,YAAY;EACpC,IAAI,SAAS,UAAU,IAAI,WAAW,YAAY,CAAC,GAAG;EACtD,cAAc,WAAW,YAAY,GAAG,IAAI;EAC5C;CACF;AACF;AACA,QAAQ,IAAI,SAAS,YAAY;AACjC,IAAI,OAAO,QAAQ,IAAI,WAAW,QAAQ,cAAc;AACxD,QAAQ,IACN,GAAG,QAAQ,MAAM,gBAAgB,QAAQ,QAAQ,QAAQ,QAAQ,UAAU,QAAQ,gBAAgB,oBAAoB,QAAQ,YAAY,iBAAiB,QAAQ,WAAW,eAAe,QAAQ,QAAQ,+BAA+B,QAAQ,QAAQ,mBAAmB,QAAQ,uBAAuB,wBAAwB,QAAQ,2BAA2B,cAAc,QAAQ,yBAAyB,YAAY,QAAQ,aAAa,sBAC5b"}
|
package/dist/report.mjs
CHANGED
|
@@ -5,6 +5,9 @@ function countCodes(flags) {
|
|
|
5
5
|
}
|
|
6
6
|
function renderReport(files, corpus, registryDiagnostics, ignoredFiles = 0, write = false) {
|
|
7
7
|
const sites = files.flatMap((file) => file.sites);
|
|
8
|
+
const functionalVariants = files.flatMap((file) => file.functionalVariants);
|
|
9
|
+
const convertedFunctionalVariants = functionalVariants.filter((site) => site.converted);
|
|
10
|
+
const flaggedFunctionalVariants = functionalVariants.filter((site) => !site.converted);
|
|
8
11
|
const clean = sites.filter((site) => site.flags.length === 0 && site.warnings.length === 0 && site.assessmentVerdict === "clean");
|
|
9
12
|
const flagged = sites.filter((site) => site.flags.length > 0);
|
|
10
13
|
const warnings = sites.filter((site) => site.warnings.length > 0);
|
|
@@ -16,9 +19,10 @@ function renderReport(files, corpus, registryDiagnostics, ignoredFiles = 0, writ
|
|
|
16
19
|
const styled = sites.filter((site) => site.kind === "styled");
|
|
17
20
|
const cleanJsx = jsx.filter((site) => site.flags.length === 0 && site.warnings.length === 0 && site.assessmentVerdict === "clean").length;
|
|
18
21
|
const cleanStyled = styled.filter((site) => site.flags.length === 0 && site.warnings.length === 0 && site.assessmentVerdict === "clean").length;
|
|
19
|
-
const readyFiles = files.filter((file) => file.sites.length > 0 && file.sites.every((site) => site.legacyLeft === 0));
|
|
20
|
-
const filesWithSites = files.filter((file) => file.sites.length > 0).length;
|
|
21
|
-
const blockedFiles = files.filter((file) => file.sites.some((site) => site.legacyLeft > 0)).map((file) => file.file);
|
|
22
|
+
const readyFiles = files.filter((file) => (file.sites.length > 0 || file.functionalVariants.length > 0) && file.sites.every((site) => site.legacyLeft === 0) && file.functionalVariants.every((site) => site.converted));
|
|
23
|
+
const filesWithSites = files.filter((file) => file.sites.length > 0 || file.functionalVariants.length > 0).length;
|
|
24
|
+
const blockedFiles = files.filter((file) => file.sites.some((site) => site.legacyLeft > 0) || file.functionalVariants.some((site) => !site.converted)).map((file) => file.file);
|
|
25
|
+
const functionalFlagCounts = countCodes(flaggedFunctionalVariants.flatMap((site) => [...new Map(site.flags.map((flag) => [flag.code, flag])).values()]));
|
|
22
26
|
const lines = [
|
|
23
27
|
"# Flat-values codemod dry-run",
|
|
24
28
|
"",
|
|
@@ -39,10 +43,17 @@ function renderReport(files, corpus, registryDiagnostics, ignoredFiles = 0, writ
|
|
|
39
43
|
`- ${ignoredFiles} source files skipped by \`.tamagui-flat-values-ignore\` markers`,
|
|
40
44
|
`- ${jsx.length} JSX sites: ${cleanJsx} clean, ${jsx.length - cleanJsx} need review`,
|
|
41
45
|
`- ${styled.length} styled config sites: ${cleanStyled} clean, ${styled.length - cleanStyled} need review`,
|
|
46
|
+
`- ${functionalVariants.length} functional variant sites found`,
|
|
47
|
+
`- ${convertedFunctionalVariants.length} functional variants have automatic styled.dynamic rewrites`,
|
|
48
|
+
`- ${flaggedFunctionalVariants.length} functional variants need manual migration`,
|
|
49
|
+
"",
|
|
50
|
+
"### Functional variant flag reasons",
|
|
51
|
+
"",
|
|
52
|
+
...functionalFlagCounts.length ? functionalFlagCounts.map(([code, count]) => `- ${code}: ${count}`) : ["- none"],
|
|
42
53
|
"",
|
|
43
54
|
"### Remaining manual migration",
|
|
44
55
|
"",
|
|
45
|
-
`${readyFiles.length} of ${filesWithSites} files have no legacy condition object left after`,
|
|
56
|
+
`${readyFiles.length} of ${filesWithSites} files have no legacy condition object or flagged functional variant left after`,
|
|
46
57
|
"conversion. V3 has no compatibility setting; finish the remaining files directly:",
|
|
47
58
|
blockedFiles.length ? blockedFiles.map((file) => `\`${file}\``).join(", ") : "every file in this corpus is fully migrated.",
|
|
48
59
|
"",
|
|
@@ -66,8 +77,23 @@ function renderReport(files, corpus, registryDiagnostics, ignoredFiles = 0, writ
|
|
|
66
77
|
for (const diagnostic of registryDiagnostics) lines.push(`- ${diagnostic}`);
|
|
67
78
|
}
|
|
68
79
|
for (const file of files) {
|
|
69
|
-
if (!file.sites.length) continue;
|
|
80
|
+
if (!file.sites.length && !file.functionalVariants.length) continue;
|
|
70
81
|
lines.push("", `## \`${file.file}\``, "");
|
|
82
|
+
for (const site of file.functionalVariants) {
|
|
83
|
+
lines.push(`### ${site.label} functional variant at line ${site.line} (${site.converted ? "automatic" : "manual"})`, "", "Before:", "", "```tsx", site.before, "```", "", site.converted ? "Automatic rewrite:" : "Left authored:", "", "```tsx", site.after, "```");
|
|
84
|
+
if (site.flags.length) {
|
|
85
|
+
lines.push("", "Flags:", "");
|
|
86
|
+
for (const flag of site.flags) lines.push(`- **${flag.code}**: ${flag.detail}`);
|
|
87
|
+
}
|
|
88
|
+
if (site.draft) {
|
|
89
|
+
lines.push("", "Generated `.resolve` draft:", "", "```tsx", site.draft, "```");
|
|
90
|
+
}
|
|
91
|
+
if (site.notes.length) {
|
|
92
|
+
lines.push("", "Notes:", "");
|
|
93
|
+
for (const note of site.notes) lines.push(`- ${note}`);
|
|
94
|
+
}
|
|
95
|
+
lines.push("");
|
|
96
|
+
}
|
|
71
97
|
for (const site of file.sites) {
|
|
72
98
|
const status = [
|
|
73
99
|
site.assessmentVerdict === "clean" ? null : site.assessmentVerdict,
|
|
@@ -120,7 +146,11 @@ function renderReport(files, corpus, registryDiagnostics, ignoredFiles = 0, writ
|
|
|
120
146
|
flagged: flagged.length,
|
|
121
147
|
warnings: warnings.length,
|
|
122
148
|
waiting: waiting.length,
|
|
123
|
-
ignoredFiles
|
|
149
|
+
ignoredFiles,
|
|
150
|
+
functionalVariantSites: functionalVariants.length,
|
|
151
|
+
functionalVariantConverted: convertedFunctionalVariants.length,
|
|
152
|
+
functionalVariantFlagged: flaggedFunctionalVariants.length,
|
|
153
|
+
functionalVariantFlags: Object.fromEntries(functionalFlagCounts)
|
|
124
154
|
}
|
|
125
155
|
};
|
|
126
156
|
}
|
package/dist/report.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"report.js","names":[],"sources":["report.js"],"sourcesContent":["function countCodes(flags) {\n const counts = /* @__PURE__ */ new Map();\n for (const flag of flags) counts.set(flag.code, (counts.get(flag.code) ?? 0) + 1);\n return [...counts].sort(\n ([leftCode, leftCount], [rightCode, rightCount]) => rightCount - leftCount || leftCode.localeCompare(rightCode)\n );\n}\nfunction renderReport(files, corpus, registryDiagnostics, ignoredFiles = 0, write = false) {\n const sites = files.flatMap((file) => file.sites);\n const clean = sites.filter(\n (site) => site.flags.length === 0 && site.warnings.length === 0 && site.assessmentVerdict === \"clean\"\n );\n const flagged = sites.filter((site) => site.flags.length > 0);\n const warnings = sites.filter((site) => site.warnings.length > 0);\n const needsRelocation = sites.filter(\n (site) => site.assessmentVerdict === \"needs-relocation\"\n );\n const unknownHost = sites.filter((site) => site.assessmentVerdict === \"unknown-host\");\n const ineligible = sites.filter((site) => site.assessmentVerdict === \"ineligible\");\n const waiting = clean.filter((site) => site.programs.length === 0);\n const jsx = sites.filter((site) => site.kind === \"jsx\");\n const styled = sites.filter((site) => site.kind === \"styled\");\n const cleanJsx = jsx.filter(\n (site) => site.flags.length === 0 && site.warnings.length === 0 && site.assessmentVerdict === \"clean\"\n ).length;\n const cleanStyled = styled.filter(\n (site) => site.flags.length === 0 && site.warnings.length === 0 && site.assessmentVerdict === \"clean\"\n ).length;\n const readyFiles = files.filter(\n (file) => file.sites.length > 0 && file.sites.every((site) => site.legacyLeft === 0)\n );\n const filesWithSites = files.filter((file) => file.sites.length > 0).length;\n const blockedFiles = files.filter((file) => file.sites.some((site) => site.legacyLeft > 0)).map((file) => file.file);\n const lines = [\n \"# Flat-values codemod dry-run\",\n \"\",\n `Corpus: ${corpus.map((entry) => `\\`${entry}\\``).join(\", \")}.`,\n \"\",\n write ? \"Statically safe conversions were written in place. Flagged legacy syntax remains for manual migration.\" : \"Dry run only: no source files were written. Pass `--write` to apply statically safe conversions.\",\n \"\",\n \"## Summary\",\n \"\",\n `- ${sites.length} conversion sites found`,\n `- ${clean.length - waiting.length} converted with no open questions`,\n `- ${needsRelocation.length} need relocation because the authored target or host cannot evaluate the conversion`,\n `- ${unknownHost.length} have an unverified host type`,\n `- ${ineligible.length} use properties that cannot carry flat clauses`,\n `- ${waiting.length} have nothing to convert until the runtime catches up (see below)`,\n `- ${flagged.length} have syntax or ordering flags for manual work`,\n `- ${warnings.length} have configuration warnings for manual review`,\n `- ${ignoredFiles} source files skipped by \\`.tamagui-flat-values-ignore\\` markers`,\n `- ${jsx.length} JSX sites: ${cleanJsx} clean, ${jsx.length - cleanJsx} need review`,\n `- ${styled.length} styled config sites: ${cleanStyled} clean, ${styled.length - cleanStyled} need review`,\n \"\",\n \"### Remaining manual migration\",\n \"\",\n `${readyFiles.length} of ${filesWithSites} files have no legacy condition object left after`,\n \"conversion. V3 has no compatibility setting; finish the remaining files directly:\",\n blockedFiles.length ? blockedFiles.map((file) => `\\`${file}\\``).join(\", \") : \"every file in this corpus is fully migrated.\",\n \"\",\n \"### Flag reasons\",\n \"\"\n ];\n const flagCounts = countCodes(flagged.flatMap((site) => site.flags));\n lines.push(\n ...flagCounts.length ? flagCounts.map(([code, count]) => `- ${code}: ${count}`) : [\"- none\"]\n );\n const warningCounts = countCodes(warnings.flatMap((site) => site.warnings));\n lines.push(\n \"\",\n \"### Configuration warning reasons\",\n \"\",\n ...warningCounts.length ? warningCounts.map(([code, count]) => `- ${code}: ${count}`) : [\"- none\"]\n );\n const inventoryCounts = countCodes(sites.flatMap((site) => site.inventory));\n if (inventoryCounts.length) {\n lines.push(\n \"\",\n \"### Values left authored for another migration\",\n \"\",\n \"These are not flat-value migration work. The conversion keeps them exactly as\",\n \"authored and records them so their follow-up migrations have a corpus inventory.\",\n \"\",\n ...inventoryCounts.map(([code, count]) => `- ${code}: ${count}`)\n );\n }\n const pendingCounts = countCodes(sites.flatMap((site) => site.pending));\n if (pendingCounts.length) {\n lines.push(\n \"\",\n \"### Waiting on runtime support\",\n \"\",\n \"The conversion is known but not offered, because the runtime cannot read it yet.\",\n \"Each pending reason below names the exact host or merge contract that must land\",\n \"before the suggested source is safe to apply.\",\n \"\",\n ...pendingCounts.map(([code, count]) => `- ${code}: ${count}`)\n );\n }\n if (registryDiagnostics.length) {\n lines.push(\"\", \"### Modifier registry diagnostics\", \"\");\n for (const diagnostic of registryDiagnostics) lines.push(`- ${diagnostic}`);\n }\n for (const file of files) {\n if (!file.sites.length) continue;\n lines.push(\"\", `## \\`${file.file}\\``, \"\");\n for (const site of file.sites) {\n const status = [\n site.assessmentVerdict === \"clean\" ? null : site.assessmentVerdict,\n site.flags.length ? \"syntax-blocked\" : null,\n site.warnings.length ? \"configuration-warning\" : null\n ].filter(Boolean).join(\", \");\n lines.push(\n `### ${site.label} at line ${site.line} (${status || \"clean\"})`,\n \"\",\n \"Before:\",\n \"\",\n \"```tsx\",\n site.before,\n \"```\",\n \"\",\n \"After:\",\n \"\",\n \"```tsx\",\n site.after,\n \"```\"\n );\n if (site.flags.length) {\n lines.push(\"\", \"Flags:\", \"\");\n for (const flag of site.flags) lines.push(`- **${flag.code}**: ${flag.detail}`);\n }\n if (site.warnings.length) {\n lines.push(\"\", \"Configuration warnings:\", \"\");\n for (const warning of site.warnings) {\n lines.push(`- **${warning.code}**: ${warning.detail}`);\n }\n }\n if (site.assessments.length) {\n lines.push(\"\", \"Conversion assessment:\", \"\");\n for (const assessment of site.assessments) {\n for (const reason of assessment.reasons) {\n lines.push(\n `- **${assessment.verdict}: ${assessment.property}**: ${reason.message}. Remedy: ${reason.remedy}.`\n );\n }\n }\n }\n if (site.inventory.length) {\n lines.push(\"\", \"Left authored:\", \"\");\n for (const flag of site.inventory)\n lines.push(`- **${flag.code}**: ${flag.detail}`);\n }\n if (site.pending.length) {\n lines.push(\"\", \"Waiting on runtime support:\", \"\");\n for (const flag of site.pending) lines.push(`- **${flag.code}**: ${flag.detail}`);\n }\n if (site.notes.length) {\n lines.push(\"\", \"Notes:\", \"\");\n for (const note of site.notes) lines.push(`- ${note}`);\n }\n lines.push(\"\");\n }\n }\n return {\n text: `${lines.join(\"\\n\")}\n`,\n summary: {\n sites: sites.length,\n clean: clean.length,\n needsRelocation: needsRelocation.length,\n unknownHost: unknownHost.length,\n ineligible: ineligible.length,\n flagged: flagged.length,\n warnings: warnings.length,\n waiting: waiting.length,\n ignoredFiles\n }\n };\n}\nexport {\n renderReport\n};\n//# sourceMappingURL=report.js.map\n"],"mappings":";A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3,"file":"report.js","names":[],"sources":["report.js"],"sourcesContent":["function countCodes(flags) {\n const counts = /* @__PURE__ */ new Map();\n for (const flag of flags) counts.set(flag.code, (counts.get(flag.code) ?? 0) + 1);\n return [...counts].sort(\n ([leftCode, leftCount], [rightCode, rightCount]) => rightCount - leftCount || leftCode.localeCompare(rightCode)\n );\n}\nfunction renderReport(files, corpus, registryDiagnostics, ignoredFiles = 0, write = false) {\n const sites = files.flatMap((file) => file.sites);\n const functionalVariants = files.flatMap((file) => file.functionalVariants);\n const convertedFunctionalVariants = functionalVariants.filter((site) => site.converted);\n const flaggedFunctionalVariants = functionalVariants.filter((site) => !site.converted);\n const clean = sites.filter(\n (site) => site.flags.length === 0 && site.warnings.length === 0 && site.assessmentVerdict === \"clean\"\n );\n const flagged = sites.filter((site) => site.flags.length > 0);\n const warnings = sites.filter((site) => site.warnings.length > 0);\n const needsRelocation = sites.filter(\n (site) => site.assessmentVerdict === \"needs-relocation\"\n );\n const unknownHost = sites.filter((site) => site.assessmentVerdict === \"unknown-host\");\n const ineligible = sites.filter((site) => site.assessmentVerdict === \"ineligible\");\n const waiting = clean.filter((site) => site.programs.length === 0);\n const jsx = sites.filter((site) => site.kind === \"jsx\");\n const styled = sites.filter((site) => site.kind === \"styled\");\n const cleanJsx = jsx.filter(\n (site) => site.flags.length === 0 && site.warnings.length === 0 && site.assessmentVerdict === \"clean\"\n ).length;\n const cleanStyled = styled.filter(\n (site) => site.flags.length === 0 && site.warnings.length === 0 && site.assessmentVerdict === \"clean\"\n ).length;\n const readyFiles = files.filter(\n (file) => (file.sites.length > 0 || file.functionalVariants.length > 0) && file.sites.every((site) => site.legacyLeft === 0) && file.functionalVariants.every((site) => site.converted)\n );\n const filesWithSites = files.filter(\n (file) => file.sites.length > 0 || file.functionalVariants.length > 0\n ).length;\n const blockedFiles = files.filter(\n (file) => file.sites.some((site) => site.legacyLeft > 0) || file.functionalVariants.some((site) => !site.converted)\n ).map((file) => file.file);\n const functionalFlagCounts = countCodes(\n flaggedFunctionalVariants.flatMap((site) => [\n ...new Map(site.flags.map((flag) => [flag.code, flag])).values()\n ])\n );\n const lines = [\n \"# Flat-values codemod dry-run\",\n \"\",\n `Corpus: ${corpus.map((entry) => `\\`${entry}\\``).join(\", \")}.`,\n \"\",\n write ? \"Statically safe conversions were written in place. Flagged legacy syntax remains for manual migration.\" : \"Dry run only: no source files were written. Pass `--write` to apply statically safe conversions.\",\n \"\",\n \"## Summary\",\n \"\",\n `- ${sites.length} conversion sites found`,\n `- ${clean.length - waiting.length} converted with no open questions`,\n `- ${needsRelocation.length} need relocation because the authored target or host cannot evaluate the conversion`,\n `- ${unknownHost.length} have an unverified host type`,\n `- ${ineligible.length} use properties that cannot carry flat clauses`,\n `- ${waiting.length} have nothing to convert until the runtime catches up (see below)`,\n `- ${flagged.length} have syntax or ordering flags for manual work`,\n `- ${warnings.length} have configuration warnings for manual review`,\n `- ${ignoredFiles} source files skipped by \\`.tamagui-flat-values-ignore\\` markers`,\n `- ${jsx.length} JSX sites: ${cleanJsx} clean, ${jsx.length - cleanJsx} need review`,\n `- ${styled.length} styled config sites: ${cleanStyled} clean, ${styled.length - cleanStyled} need review`,\n `- ${functionalVariants.length} functional variant sites found`,\n `- ${convertedFunctionalVariants.length} functional variants have automatic styled.dynamic rewrites`,\n `- ${flaggedFunctionalVariants.length} functional variants need manual migration`,\n \"\",\n \"### Functional variant flag reasons\",\n \"\",\n ...functionalFlagCounts.length ? functionalFlagCounts.map(([code, count]) => `- ${code}: ${count}`) : [\"- none\"],\n \"\",\n \"### Remaining manual migration\",\n \"\",\n `${readyFiles.length} of ${filesWithSites} files have no legacy condition object or flagged functional variant left after`,\n \"conversion. V3 has no compatibility setting; finish the remaining files directly:\",\n blockedFiles.length ? blockedFiles.map((file) => `\\`${file}\\``).join(\", \") : \"every file in this corpus is fully migrated.\",\n \"\",\n \"### Flag reasons\",\n \"\"\n ];\n const flagCounts = countCodes(flagged.flatMap((site) => site.flags));\n lines.push(\n ...flagCounts.length ? flagCounts.map(([code, count]) => `- ${code}: ${count}`) : [\"- none\"]\n );\n const warningCounts = countCodes(warnings.flatMap((site) => site.warnings));\n lines.push(\n \"\",\n \"### Configuration warning reasons\",\n \"\",\n ...warningCounts.length ? warningCounts.map(([code, count]) => `- ${code}: ${count}`) : [\"- none\"]\n );\n const inventoryCounts = countCodes(sites.flatMap((site) => site.inventory));\n if (inventoryCounts.length) {\n lines.push(\n \"\",\n \"### Values left authored for another migration\",\n \"\",\n \"These are not flat-value migration work. The conversion keeps them exactly as\",\n \"authored and records them so their follow-up migrations have a corpus inventory.\",\n \"\",\n ...inventoryCounts.map(([code, count]) => `- ${code}: ${count}`)\n );\n }\n const pendingCounts = countCodes(sites.flatMap((site) => site.pending));\n if (pendingCounts.length) {\n lines.push(\n \"\",\n \"### Waiting on runtime support\",\n \"\",\n \"The conversion is known but not offered, because the runtime cannot read it yet.\",\n \"Each pending reason below names the exact host or merge contract that must land\",\n \"before the suggested source is safe to apply.\",\n \"\",\n ...pendingCounts.map(([code, count]) => `- ${code}: ${count}`)\n );\n }\n if (registryDiagnostics.length) {\n lines.push(\"\", \"### Modifier registry diagnostics\", \"\");\n for (const diagnostic of registryDiagnostics) lines.push(`- ${diagnostic}`);\n }\n for (const file of files) {\n if (!file.sites.length && !file.functionalVariants.length) continue;\n lines.push(\"\", `## \\`${file.file}\\``, \"\");\n for (const site of file.functionalVariants) {\n lines.push(\n `### ${site.label} functional variant at line ${site.line} (${site.converted ? \"automatic\" : \"manual\"})`,\n \"\",\n \"Before:\",\n \"\",\n \"```tsx\",\n site.before,\n \"```\",\n \"\",\n site.converted ? \"Automatic rewrite:\" : \"Left authored:\",\n \"\",\n \"```tsx\",\n site.after,\n \"```\"\n );\n if (site.flags.length) {\n lines.push(\"\", \"Flags:\", \"\");\n for (const flag of site.flags) lines.push(`- **${flag.code}**: ${flag.detail}`);\n }\n if (site.draft) {\n lines.push(\"\", \"Generated `.resolve` draft:\", \"\", \"```tsx\", site.draft, \"```\");\n }\n if (site.notes.length) {\n lines.push(\"\", \"Notes:\", \"\");\n for (const note of site.notes) lines.push(`- ${note}`);\n }\n lines.push(\"\");\n }\n for (const site of file.sites) {\n const status = [\n site.assessmentVerdict === \"clean\" ? null : site.assessmentVerdict,\n site.flags.length ? \"syntax-blocked\" : null,\n site.warnings.length ? \"configuration-warning\" : null\n ].filter(Boolean).join(\", \");\n lines.push(\n `### ${site.label} at line ${site.line} (${status || \"clean\"})`,\n \"\",\n \"Before:\",\n \"\",\n \"```tsx\",\n site.before,\n \"```\",\n \"\",\n \"After:\",\n \"\",\n \"```tsx\",\n site.after,\n \"```\"\n );\n if (site.flags.length) {\n lines.push(\"\", \"Flags:\", \"\");\n for (const flag of site.flags) lines.push(`- **${flag.code}**: ${flag.detail}`);\n }\n if (site.warnings.length) {\n lines.push(\"\", \"Configuration warnings:\", \"\");\n for (const warning of site.warnings) {\n lines.push(`- **${warning.code}**: ${warning.detail}`);\n }\n }\n if (site.assessments.length) {\n lines.push(\"\", \"Conversion assessment:\", \"\");\n for (const assessment of site.assessments) {\n for (const reason of assessment.reasons) {\n lines.push(\n `- **${assessment.verdict}: ${assessment.property}**: ${reason.message}. Remedy: ${reason.remedy}.`\n );\n }\n }\n }\n if (site.inventory.length) {\n lines.push(\"\", \"Left authored:\", \"\");\n for (const flag of site.inventory)\n lines.push(`- **${flag.code}**: ${flag.detail}`);\n }\n if (site.pending.length) {\n lines.push(\"\", \"Waiting on runtime support:\", \"\");\n for (const flag of site.pending) lines.push(`- **${flag.code}**: ${flag.detail}`);\n }\n if (site.notes.length) {\n lines.push(\"\", \"Notes:\", \"\");\n for (const note of site.notes) lines.push(`- ${note}`);\n }\n lines.push(\"\");\n }\n }\n return {\n text: `${lines.join(\"\\n\")}\n`,\n summary: {\n sites: sites.length,\n clean: clean.length,\n needsRelocation: needsRelocation.length,\n unknownHost: unknownHost.length,\n ineligible: ineligible.length,\n flagged: flagged.length,\n warnings: warnings.length,\n waiting: waiting.length,\n ignoredFiles,\n functionalVariantSites: functionalVariants.length,\n functionalVariantConverted: convertedFunctionalVariants.length,\n functionalVariantFlagged: flaggedFunctionalVariants.length,\n functionalVariantFlags: Object.fromEntries(functionalFlagCounts)\n }\n };\n}\nexport {\n renderReport\n};\n//# sourceMappingURL=report.js.map\n"],"mappings":";AAAA,SAAS,WAAW,OAAO;CACzB,MAAM,yBAAyB,IAAI,IAAI;CACvC,KAAK,MAAM,QAAQ,OAAO,OAAO,IAAI,KAAK,OAAO,OAAO,IAAI,KAAK,IAAI,KAAK,KAAK,CAAC;CAChF,OAAO,CAAC,GAAG,MAAM,CAAC,CAAC,MAChB,CAAC,UAAU,YAAY,CAAC,WAAW,gBAAgB,aAAa,aAAa,SAAS,cAAc,SAAS,CAChH;AACF;AACA,SAAS,aAAa,OAAO,QAAQ,qBAAqB,eAAe,GAAG,QAAQ,OAAO;CACzF,MAAM,QAAQ,MAAM,SAAS,SAAS,KAAK,KAAK;CAChD,MAAM,qBAAqB,MAAM,SAAS,SAAS,KAAK,kBAAkB;CAC1E,MAAM,8BAA8B,mBAAmB,QAAQ,SAAS,KAAK,SAAS;CACtF,MAAM,4BAA4B,mBAAmB,QAAQ,SAAS,CAAC,KAAK,SAAS;CACrF,MAAM,QAAQ,MAAM,QACjB,SAAS,KAAK,MAAM,WAAW,KAAK,KAAK,SAAS,WAAW,KAAK,KAAK,sBAAsB,OAChG;CACA,MAAM,UAAU,MAAM,QAAQ,SAAS,KAAK,MAAM,SAAS,CAAC;CAC5D,MAAM,WAAW,MAAM,QAAQ,SAAS,KAAK,SAAS,SAAS,CAAC;CAChE,MAAM,kBAAkB,MAAM,QAC3B,SAAS,KAAK,sBAAsB,kBACvC;CACA,MAAM,cAAc,MAAM,QAAQ,SAAS,KAAK,sBAAsB,cAAc;CACpF,MAAM,aAAa,MAAM,QAAQ,SAAS,KAAK,sBAAsB,YAAY;CACjF,MAAM,UAAU,MAAM,QAAQ,SAAS,KAAK,SAAS,WAAW,CAAC;CACjE,MAAM,MAA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AAK,MAAM;GACvD;GACA,MAAM,KAAK,EAAE;EACf;CACF;CACA,OAAO;EACL,MAAM,GAAG,MAAM,KAAK,IAAI,EAAE;;EAE1B,SAAS;GACP,OAAO,MAAM;GACb,OAAO,MAAM;GACb,iBAAiB,gBAAgB;GACjC,aAAa,YAAY;GACzB,YAAY,WAAW;GACvB,SAAS,QAAQ;GACjB,UAAU,SAAS;GACnB,SAAS,QAAQ;GACjB;GACA,wBAAwB,mBAAmB;GAC3C,4BAA4B,4BAA4B;GACxD,0BAA0B,0BAA0B;GACpD,wBAAwB,OAAO,YAAY,oBAAoB;EACjE;CACF;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/codemod-flat-values",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.889.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -26,14 +26,14 @@
|
|
|
26
26
|
"typecheck": "tsc --noEmit"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@tamagui/helpers": "3.0.0-beta.
|
|
30
|
-
"@tamagui/language-service": "3.0.0-beta.
|
|
31
|
-
"@tamagui/shorthands": "3.0.0-beta.
|
|
32
|
-
"@tamagui/style-grammar": "3.0.0-beta.
|
|
29
|
+
"@tamagui/helpers": "3.0.0-beta.889.1",
|
|
30
|
+
"@tamagui/language-service": "3.0.0-beta.889.1",
|
|
31
|
+
"@tamagui/shorthands": "3.0.0-beta.889.1",
|
|
32
|
+
"@tamagui/style-grammar": "3.0.0-beta.889.1",
|
|
33
33
|
"ts-morph": "^28.0.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@tamagui/build": "3.0.0-beta.
|
|
36
|
+
"@tamagui/build": "3.0.0-beta.889.1",
|
|
37
37
|
"typescript": "~6.0.3"
|
|
38
38
|
},
|
|
39
39
|
"repository": {
|