@venizia/dev-configs 0.4.7-2 → 0.4.7-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.
@@ -1 +1 @@
1
- {"version":3,"file":"const-classes.js","sourceRoot":"","sources":["../../../src/cli/codemod/const-classes.ts"],"names":[],"mappings":";;;AAAA,qCAAsD;AACtD,yCAA8C;AAE9C,mCAAuC;AAIvC,MAAM,mBAAmB,GAAG,+BAA+B,CAAC;AAC5D,MAAM,iBAAiB,GAAG,iDAAiD,CAAC;AAC5E,mFAAmF;AACnF,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC;AAChF,yEAAyE;AACzE,MAAM,UAAU,GAAG,qBAAqB,CAAC;AACzC,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC;AA+C9C,4EAA4E;AAC5E,MAAM,SAAS,GAAG,CAAC,IAAY,EAAU,EAAE;IACzC,MAAM,aAAa,GAAG,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAClE,IAAI,aAAa,EAAE,CAAC;QAClB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAChC,OAAO,GAAG,IAAI,IAAI,CAAC;IACrB,CAAC;IAED,IAAI,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAC5B,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;IACnC,CAAC;IAED,OAAO,GAAG,IAAI,GAAG,CAAC;AACpB,CAAC,CAAC;AAEF,mIAAmI;AACnI,MAAM,KAAK,GAAG,CAAC,KAAa,EAAsB,EAAE;IAClD,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YACjC,OAAO,CAAC,GAAG,CACT,uCAAuC,eAAe,CAAC,KAAK,oEAAoE,CACjI,CAAC;QACJ,CAAC;QAED,OAAO,OAAO,IAAI,CAAC,SAAS,GAAG,CAAC,IAAI,cAAc,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAClE,CAAC;;AA9KH,kDA+KC","sourcesContent":["import { readFileSync, writeFileSync } from 'node:fs';\nimport { relative, resolve } from 'node:path';\nimport type ts from 'typescript';\nimport { CodemodFiles } from './files';\n\ntype TTypeScript = typeof ts;\n\nconst DEFAULT_IMPORT_FROM = '@venizia/ignis-helpers/common';\nconst TEST_FILE_PATTERN = /(?:^|\\/)__tests__\\/|\\.(?:test|spec)\\.[cm]?tsx?$/;\n/** Utility types whose type argument is a set of keys, not an enumerable value. */\nconst KEY_SET_TYPES = new Set(['Pick', 'Omit', 'Extract', 'Exclude', 'Record']);\n/** A file that can hold a string-literal union: a quote beside a `|`. */\nconst UNION_TEXT = /\\|\\s*['\"]|['\"]\\s*\\|/;\nconst RESERVED_KEYS = new Set(['SCHEME_SET']);\n\n/** What the user may change for one declaration, from the mapping file. */\nexport interface IConstClassOverride {\n /** The class name. */\n class?: string;\n /** The type name; only a property of an interface or object type gets a new one. */\n type?: string;\n /** A member key per literal value: `{ \"read-only\": \"READ_ONLY\" }`. */\n members?: Record<string, string>;\n /** Leave this declaration alone. */\n skip?: boolean;\n}\n\nexport type TConstClassMap = Record<string, IConstClassOverride>;\n\nexport interface IConstClassProposal {\n /** The key of the mapping file: `path/to/file.ts#TName` or `path/to/file.ts#IContainer.property`. */\n id: string;\n line: number;\n className: string;\n typeName: string;\n /** The literal values and the member key each one gets, in order. */\n members: Array<{ value: string; key: string }>;\n /** What the union also held: `null` or `undefined`. */\n nullish: string[];\n}\n\nexport interface IConstClassUntouched {\n line: number;\n column: number;\n reason: string;\n}\n\nexport interface IConstClassResult {\n output: string;\n changed: boolean;\n proposals: IConstClassProposal[];\n untouched: IConstClassUntouched[];\n}\n\ninterface IEdit {\n start: number;\n end: number;\n text: string;\n}\n\n/** The plural of a PascalCase word, for the class that holds its values. */\nconst pluralize = (word: string): string => {\n const alreadyPlural = /[^uis]s$/.test(word) || /ings$/.test(word);\n if (alreadyPlural) {\n return word;\n }\n\n if (/(s|x|z|ch|sh)$/.test(word)) {\n return `${word}es`;\n }\n\n if (/[^aeiou]y$/.test(word)) {\n return `${word.slice(0, -1)}ies`;\n }\n\n return `${word}s`;\n};\n\n/** `read-only`, `readOnly` and `string[]` become `READ_ONLY`, `READ_ONLY` and `STRING_ARRAY`; `undefined` when nothing is left. */\nconst toKey = (value: string): string | undefined => {\n const key = value\n .replace(/\\[\\]/g, '_ARRAY_')\n .replace(/([a-z0-9])([A-Z])/g, '$1_$2')\n .replace(/[^A-Za-z0-9]+/g, '_')\n .replace(/^_+|_+$/g, '')\n .toUpperCase();\n\n if (key === '') {\n return undefined;\n }\n\n return /^[0-9]/.test(key) ? `_${key}` : key;\n};\n\nconst pascal = (word: string): string => `${word.charAt(0).toUpperCase()}${word.slice(1)}`;\n\n/**\n * Turns the string-literal unions of exported declarations into const classes: an exported type\n * alias, and a property of an exported interface or object type. The values stay the same, so every\n * existing literal still type-checks and no call site changes. A union it cannot name is reported.\n */\nexport class ConstClasses {\n static convert(opts: {\n typescript: TTypeScript;\n fileName: string;\n source: string;\n /** The id prefix of the mapping file: the path of the file relative to the project root. */\n relativePath?: string;\n overrides?: TConstClassMap;\n importFrom?: string;\n }): IConstClassResult {\n const { typescript, fileName, source, overrides = {}, importFrom = DEFAULT_IMPORT_FROM } = opts;\n const relativePath = opts.relativePath ?? fileName;\n const sourceFile = typescript.createSourceFile(\n fileName,\n source,\n typescript.ScriptTarget.Latest,\n true,\n );\n const taken = ConstClasses.declaredNames({ typescript, sourceFile });\n const proposals: IConstClassProposal[] = [];\n const untouched: IConstClassUntouched[] = [];\n const edits: IEdit[] = [];\n const insertions = new Map<number, string[]>();\n const handled = new Set<ts.Node>();\n\n const report = (node: ts.Node, reason: string) => {\n const { line, character } = sourceFile.getLineAndCharacterOfPosition(\n node.getStart(sourceFile),\n );\n untouched.push({ line: line + 1, column: character + 1, reason });\n };\n\n const lineOf = (node: ts.Node) =>\n sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile)).line + 1;\n\n /** Plans one conversion; `undefined` and a report when the names or the members do not work. */\n const plan = (planOpts: {\n node: ts.UnionTypeNode;\n id: string;\n className: string;\n typeName: string;\n anchor: ts.Node;\n mayRenameType: boolean;\n }): void => {\n const { node, id, anchor } = planOpts;\n const override = overrides[id] ?? {};\n const union = ConstClasses.readUnion({ typescript, node });\n\n if (override.skip) {\n handled.add(node);\n return;\n }\n\n const className = override.class ?? planOpts.className;\n const typeName = planOpts.mayRenameType\n ? (override.type ?? planOpts.typeName)\n : planOpts.typeName;\n const members = union.values.map((value) => ({\n value,\n key: override.members?.[value] ?? toKey(value) ?? '',\n }));\n\n const problem = ConstClasses.checkPlan({\n className,\n typeName,\n members,\n taken,\n mayRenameType: planOpts.mayRenameType,\n });\n if (problem) {\n report(node, `${problem}; left untouched (name it in the mapping file: ${id})`);\n handled.add(node);\n return;\n }\n\n taken.add(className);\n if (planOpts.mayRenameType) {\n taken.add(typeName);\n }\n\n handled.add(node);\n proposals.push({\n id,\n line: lineOf(node),\n className,\n typeName,\n members,\n nullish: union.nullish,\n });\n\n const classText = ConstClasses.renderClass({ className, typeName, members });\n const reference = `TConstValue<typeof ${className}>`;\n const nullishText = union.nullish.map((member) => ` | ${member}`).join('');\n\n if (planOpts.mayRenameType) {\n const aliasText = `export type ${typeName} = ${reference};\\n\\n`;\n const at = anchor.getStart(sourceFile, true);\n insertions.set(at, [...(insertions.get(at) ?? []), `${classText}\\n\\n${aliasText}`]);\n edits.push({\n start: node.getStart(sourceFile),\n end: node.end,\n text: `${typeName}${nullishText}`,\n });\n return;\n }\n\n const at = anchor.getStart(sourceFile, true);\n insertions.set(at, [...(insertions.get(at) ?? []), `${classText}\\n\\n`]);\n edits.push({\n start: node.getStart(sourceFile),\n end: node.end,\n text: `${reference}${nullishText}`,\n });\n };\n\n for (const statement of sourceFile.statements) {\n if (!ConstClasses.isExported({ typescript, node: statement })) {\n continue;\n }\n\n if (typescript.isTypeAliasDeclaration(statement)) {\n const union = typescript.isUnionTypeNode(statement.type) ? statement.type : undefined;\n if (union && ConstClasses.isEnumerable({ typescript, node: union })) {\n const base = statement.name.text.replace(/^T(?=[A-Z])/, '');\n plan({\n node: union,\n id: `${relativePath}#${statement.name.text}`,\n className: pluralize(base),\n typeName: statement.name.text,\n anchor: statement,\n mayRenameType: false,\n });\n continue;\n }\n\n if (typescript.isTypeLiteralNode(statement.type)) {\n ConstClasses.planMembers({\n typescript,\n container: statement,\n members: statement.type.members,\n relativePath,\n plan,\n });\n }\n }\n\n if (typescript.isInterfaceDeclaration(statement)) {\n ConstClasses.planMembers({\n typescript,\n container: statement,\n members: statement.members,\n relativePath,\n plan,\n });\n }\n\n ConstClasses.findStrays({ typescript, statement, handled, report });\n }\n\n if (proposals.length === 0) {\n return { output: source, changed: false, proposals, untouched };\n }\n\n for (const [at, texts] of insertions) {\n edits.push({ start: at, end: at, text: texts.join('') });\n }\n\n // Last, so that at the top of a file the import lands above the class inserted at the same place.\n const importEdit = ConstClasses.planImport({ typescript, sourceFile, importFrom });\n if (importEdit) {\n edits.push(importEdit);\n }\n\n let output = source;\n for (const edit of edits.sort((a, b) => b.start - a.start || b.end - a.end)) {\n output = output.slice(0, edit.start) + edit.text + output.slice(edit.end);\n }\n\n return { output, changed: output !== source, proposals, untouched };\n }\n\n private static planMembers(opts: {\n typescript: TTypeScript;\n container: ts.InterfaceDeclaration | ts.TypeAliasDeclaration;\n members: ts.NodeArray<ts.TypeElement>;\n relativePath: string;\n plan: (planOpts: {\n node: ts.UnionTypeNode;\n id: string;\n className: string;\n typeName: string;\n anchor: ts.Node;\n mayRenameType: boolean;\n }) => void;\n }): void {\n const { typescript, container, members, relativePath, plan } = opts;\n const containerName = container.name.text;\n const base = containerName.replace(/^[IT](?=[A-Z])/, '');\n\n for (const member of members) {\n if (!typescript.isPropertySignature(member) || !member.type) {\n continue;\n }\n\n if (\n !typescript.isUnionTypeNode(member.type) ||\n !ConstClasses.isEnumerable({ typescript, node: member.type })\n ) {\n continue;\n }\n\n const property = typescript.isIdentifier(member.name) ? member.name.text : undefined;\n if (!property) {\n continue;\n }\n\n plan({\n node: member.type,\n id: `${relativePath}#${containerName}.${property}`,\n className: pluralize(`${base}${pascal(property)}`),\n typeName: `T${base}${pascal(property)}`,\n anchor: container,\n mayRenameType: true,\n });\n }\n }\n\n /** Every top-level name the file declares or imports. */\n private static declaredNames(opts: {\n typescript: TTypeScript;\n sourceFile: ts.SourceFile;\n }): Set<string> {\n const { typescript, sourceFile } = opts;\n const names = new Set<string>();\n\n for (const statement of sourceFile.statements) {\n if (typescript.isImportDeclaration(statement) && statement.importClause) {\n const { name, namedBindings } = statement.importClause;\n if (name) {\n names.add(name.text);\n }\n\n if (namedBindings && typescript.isNamespaceImport(namedBindings)) {\n names.add(namedBindings.name.text);\n }\n\n if (namedBindings && typescript.isNamedImports(namedBindings)) {\n for (const element of namedBindings.elements) {\n names.add(element.name.text);\n }\n }\n continue;\n }\n\n if (typescript.isVariableStatement(statement)) {\n for (const declaration of statement.declarationList.declarations) {\n if (typescript.isIdentifier(declaration.name)) {\n names.add(declaration.name.text);\n }\n }\n continue;\n }\n\n if (\n (typescript.isClassDeclaration(statement) ||\n typescript.isFunctionDeclaration(statement) ||\n typescript.isInterfaceDeclaration(statement) ||\n typescript.isTypeAliasDeclaration(statement) ||\n typescript.isEnumDeclaration(statement) ||\n typescript.isModuleDeclaration(statement)) &&\n statement.name &&\n typescript.isIdentifier(statement.name)\n ) {\n names.add(statement.name.text);\n }\n }\n\n return names;\n }\n\n private static isExported(opts: { typescript: TTypeScript; node: ts.Node }): boolean {\n const { typescript, node } = opts;\n const modifiers = typescript.canHaveModifiers(node) ? typescript.getModifiers(node) : undefined;\n return (\n modifiers?.some((modifier) => modifier.kind === typescript.SyntaxKind.ExportKeyword) === true\n );\n }\n\n /** The string values of a union, and its `null` or `undefined` members; the union must be string literals (and nullish) only. */\n private static readUnion(opts: { typescript: TTypeScript; node: ts.UnionTypeNode }): {\n values: string[];\n nullish: string[];\n } {\n const { typescript, node } = opts;\n const values: string[] = [];\n const nullish: string[] = [];\n\n for (const member of node.types) {\n if (typescript.isLiteralTypeNode(member) && typescript.isStringLiteral(member.literal)) {\n if (!values.includes(member.literal.text)) {\n values.push(member.literal.text);\n }\n continue;\n }\n\n if (member.kind === typescript.SyntaxKind.NullKeyword) {\n nullish.push('null');\n } else if (member.kind === typescript.SyntaxKind.UndefinedKeyword) {\n nullish.push('undefined');\n } else if (\n typescript.isLiteralTypeNode(member) &&\n member.literal.kind === typescript.SyntaxKind.NullKeyword\n ) {\n nullish.push('null');\n }\n }\n\n return { values, nullish };\n }\n\n /** At least two string literals, and nothing else but `null` or `undefined`. */\n private static isEnumerable(opts: { typescript: TTypeScript; node: ts.UnionTypeNode }): boolean {\n const { typescript, node } = opts;\n let literals = 0;\n\n for (const member of node.types) {\n if (typescript.isLiteralTypeNode(member) && typescript.isStringLiteral(member.literal)) {\n literals += 1;\n continue;\n }\n\n const isNullish =\n member.kind === typescript.SyntaxKind.UndefinedKeyword ||\n member.kind === typescript.SyntaxKind.NullKeyword ||\n (typescript.isLiteralTypeNode(member) &&\n member.literal.kind === typescript.SyntaxKind.NullKeyword);\n if (!isNullish) {\n return false;\n }\n }\n\n return literals >= 2;\n }\n\n private static checkPlan(opts: {\n className: string;\n typeName: string;\n members: Array<{ value: string; key: string }>;\n taken: Set<string>;\n mayRenameType: boolean;\n }): string | undefined {\n const { className, typeName, members, taken, mayRenameType } = opts;\n\n if (taken.has(className)) {\n return `the name ${className} is already used in this file`;\n }\n\n if (mayRenameType && taken.has(typeName)) {\n return `the name ${typeName} is already used in this file`;\n }\n\n const keys = new Set<string>();\n for (const { value, key } of members) {\n if (key === '') {\n return `no member name can be made from ${JSON.stringify(value)}`;\n }\n\n if (RESERVED_KEYS.has(key)) {\n return `${JSON.stringify(value)} would become the reserved member ${key}`;\n }\n\n if (keys.has(key)) {\n return `two values give the member ${key}`;\n }\n\n keys.add(key);\n }\n\n return undefined;\n }\n\n private static renderClass(opts: {\n className: string;\n typeName: string;\n members: Array<{ value: string; key: string }>;\n }): string {\n const { className, typeName, members } = opts;\n const quote = (value: string) => `'${value.replace(/\\\\/g, '\\\\\\\\').replace(/'/g, \"\\\\'\")}'`;\n const lines = [\n `/** The values of \\`${typeName}\\`. */`,\n `export class ${className} {`,\n ...members.map(({ value, key }) => ` static readonly ${key} = ${quote(value)};`),\n '',\n ` static readonly SCHEME_SET = new Set<string>([${members.map(({ key }) => `this.${key}`).join(', ')}]);`,\n '',\n ` static isValid(value: string): value is ${typeName} {`,\n ' return this.SCHEME_SET.has(value);',\n ' }',\n '}',\n ];\n\n return lines.join('\\n');\n }\n\n /** Reports every string-literal union of an exported declaration the codemod did not handle: it cannot name those. */\n private static findStrays(opts: {\n typescript: TTypeScript;\n statement: ts.Statement;\n handled: Set<ts.Node>;\n report: (node: ts.Node, reason: string) => void;\n }): void {\n const { typescript, statement, handled, report } = opts;\n\n const walk = (node: ts.Node): void => {\n if (typescript.isVariableDeclaration(node) && node.type) {\n // The annotation of an exported constant is not what the lint rule asks to name.\n if (node.initializer) {\n walk(node.initializer);\n }\n return;\n }\n\n if (typescript.isUnionTypeNode(node) && ConstClasses.isEnumerable({ typescript, node })) {\n if (!handled.has(node) && !ConstClasses.isKeySet({ typescript, node })) {\n report(\n node,\n 'a string-literal union in this position (a parameter, a return type, a generic or a nested type) has no name to give it; write the const class by hand',\n );\n }\n\n return;\n }\n\n typescript.forEachChild(node, walk);\n };\n\n walk(statement);\n }\n\n private static isKeySet(opts: { typescript: TTypeScript; node: ts.Node }): boolean {\n const { typescript, node } = opts;\n const parent = node.parent;\n\n if (typescript.isMappedTypeNode(parent) || typescript.isTypeOperatorNode(parent)) {\n return true;\n }\n\n if (\n typescript.isTypeParameterDeclaration(parent) &&\n typescript.isMappedTypeNode(parent.parent)\n ) {\n return true;\n }\n\n if (\n parent &&\n typescript.isTypeReferenceNode(parent) &&\n typescript.isIdentifier(parent.typeName) &&\n KEY_SET_TYPES.has(parent.typeName.text)\n ) {\n return true;\n }\n\n return false;\n }\n\n /** The edit that makes `TConstValue` available: nothing when the file has it, a specifier on an import from the same module, else a new import line. */\n private static planImport(opts: {\n typescript: TTypeScript;\n sourceFile: ts.SourceFile;\n importFrom: string;\n }): IEdit | undefined {\n const { typescript, sourceFile, importFrom } = opts;\n let lastImportEnd = 0;\n let sameModule: ts.ImportDeclaration | undefined;\n\n for (const statement of sourceFile.statements) {\n if (!typescript.isImportDeclaration(statement)) {\n continue;\n }\n\n lastImportEnd = statement.end;\n const bindings = statement.importClause?.namedBindings;\n if (bindings && typescript.isNamedImports(bindings)) {\n if (bindings.elements.some((element) => element.name.text === 'TConstValue')) {\n return undefined;\n }\n\n if (\n typescript.isStringLiteral(statement.moduleSpecifier) &&\n statement.moduleSpecifier.text === importFrom\n ) {\n sameModule = statement;\n }\n }\n }\n\n const bindings = sameModule?.importClause?.namedBindings;\n if (\n sameModule &&\n bindings &&\n typescript.isNamedImports(bindings) &&\n bindings.elements.length > 0\n ) {\n const last = bindings.elements[bindings.elements.length - 1];\n const typeOnly = sameModule.importClause?.isTypeOnly === true;\n return {\n start: last?.end ?? bindings.end,\n end: last?.end ?? bindings.end,\n text: typeOnly ? ', TConstValue' : ', type TConstValue',\n };\n }\n\n const line = `import type { TConstValue } from '${importFrom}';`;\n if (lastImportEnd > 0) {\n return { start: lastImportEnd, end: lastImportEnd, text: `\\n${line}` };\n }\n\n return { start: 0, end: 0, text: `${line}\\n\\n` };\n }\n}\n\nconst USAGE = `Usage: devz codemod const-classes [paths...] [--write | --check] [--map <file>] [--emit-map <file>] [--import-from <module>] [--include-tests]\n\nTurns a string-literal union in an exported declaration into a const class (SCHEME_SET, isValid) plus\n\\`TConstValue<typeof X>\\`, the shape the venizia/const-class-values lint rule asks for. It handles an\nexported type alias and a property of an exported interface or object type. The values stay the same,\nso every existing literal still type-checks and no call site changes.\n\nIt has to choose names: the class is the type name without its leading T, in the plural; a member is\nthe value in upper snake case. The dry run prints every proposal.\n\n --write write the changed files (without it, nothing is written)\n --check dry run that exits 1 while a union can be converted or is left untouched (for CI)\n --map <file> a JSON file of overrides, keyed by the id the dry run prints\n --emit-map <file> write the proposals as a mapping file to edit, then pass it with --map\n --import-from <m> where TConstValue is imported from (default ${DEFAULT_IMPORT_FROM})\n --include-tests also convert test files (skipped by default)\n --help print this text and exit\n\nA mapping entry: { \"src/a.ts#TMode\": { \"class\": \"Modes\", \"members\": { \"read-only\": \"READ_ONLY\" } } },\nor { \"skip\": true }. A union in a parameter, a return type, a generic or a nested type is reported as\nleft untouched: it has no name, so write that class by hand. Key sets (Pick, Omit, Extract, Exclude,\nRecord, mapped types) are not enumerable values and are never touched.`;\n\n/** A usage error: nothing was read or written. */\nconst USAGE_ERROR_CODE = 2;\n\nclass ConstClassFlags {\n static readonly WRITE = '--write';\n static readonly CHECK = '--check';\n static readonly MAP = '--map';\n static readonly EMIT_MAP = '--emit-map';\n static readonly IMPORT_FROM = '--import-from';\n static readonly INCLUDE_TESTS = '--include-tests';\n static readonly HELP = '--help';\n static readonly HELP_SHORT = '-h';\n\n static readonly SCHEME_SET = new Set<string>([\n this.WRITE,\n this.CHECK,\n this.MAP,\n this.EMIT_MAP,\n this.IMPORT_FROM,\n this.INCLUDE_TESTS,\n this.HELP,\n this.HELP_SHORT,\n ]);\n\n /** The flags that take a value. */\n static readonly WITH_VALUE = new Set<string>([this.MAP, this.EMIT_MAP, this.IMPORT_FROM]);\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n}\n\n/** `devz codemod const-classes [paths...] [--write | --check]`. */\nexport class ConstClassesCommand {\n static readonly USAGE = USAGE;\n\n static async run(opts: { root: string; args: string[] }): Promise<number> {\n const { root, args } = opts;\n\n if (args.includes(ConstClassFlags.HELP) || args.includes(ConstClassFlags.HELP_SHORT)) {\n console.log(USAGE);\n return 0;\n }\n\n const flags: string[] = [];\n const paths: string[] = [];\n const values = new Map<string, string>();\n\n for (let index = 0; index < args.length; index += 1) {\n const argument = args[index] ?? '';\n const [name, inline] = argument.startsWith('--') ? argument.split(/=(.*)/s) : [argument];\n\n if (name !== undefined && ConstClassFlags.WITH_VALUE.has(name)) {\n const value = inline ?? args[index + 1];\n if (inline === undefined) {\n index += 1;\n }\n\n if (!value || value.startsWith('-')) {\n console.error(`devz codemod: ${name} needs a value\\n${USAGE}`);\n return USAGE_ERROR_CODE;\n }\n\n values.set(name, value);\n continue;\n }\n\n if (argument.startsWith('-')) {\n flags.push(argument);\n } else {\n paths.push(argument);\n }\n }\n\n const unknown = flags.filter((flag) => !ConstClassFlags.isValid(flag));\n if (unknown.length > 0) {\n console.error(\n `devz codemod: unknown option ${unknown.map((flag) => `\"${flag}\"`).join(', ')}\\n${USAGE}`,\n );\n return USAGE_ERROR_CODE;\n }\n\n const isWrite = flags.includes(ConstClassFlags.WRITE);\n const isCheck = flags.includes(ConstClassFlags.CHECK);\n const includeTests = flags.includes(ConstClassFlags.INCLUDE_TESTS);\n\n if (isWrite && isCheck) {\n console.error(\n `devz codemod: ${ConstClassFlags.WRITE} and ${ConstClassFlags.CHECK} contradict each other\\n${USAGE}`,\n );\n return USAGE_ERROR_CODE;\n }\n\n let overrides: TConstClassMap = {};\n const mapPath = values.get(ConstClassFlags.MAP);\n if (mapPath) {\n let parsed: unknown;\n try {\n parsed = JSON.parse(readFileSync(resolve(root, mapPath), 'utf8'));\n } catch (error) {\n console.error(\n `devz codemod: cannot read the mapping file ${mapPath}: ${error instanceof Error ? error.message : String(error)}`,\n );\n return USAGE_ERROR_CODE;\n }\n\n if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {\n console.error(\n `devz codemod: cannot read the mapping file ${mapPath}: the file must hold one JSON object`,\n );\n return USAGE_ERROR_CODE;\n }\n\n overrides = Object.fromEntries(Object.entries(parsed));\n }\n\n let typescript: TTypeScript;\n try {\n const result2 = await import('typescript');\n typescript = result2.default;\n } catch {\n console.error('devz codemod: the \"typescript\" package is required to read your sources');\n return 1;\n }\n\n const targets = (paths.length > 0 ? paths : ['.']).map((path) => resolve(root, path));\n const importFrom = values.get(ConstClassFlags.IMPORT_FROM);\n const emitted: TConstClassMap = {};\n let changedFiles = 0;\n let converted = 0;\n let untouchedCount = 0;\n\n for (const target of targets) {\n const files = CodemodFiles.collect({ target });\n\n if (files.length === 0 && paths.length > 0) {\n console.warn(\n `devz codemod: no source files under \"${relative(root, target) || target}\" (git ignores the path, or it holds none): nothing was read`,\n );\n }\n\n for (const file of files) {\n const relativePath = relative(root, file).split('\\\\').join('/');\n if (!includeTests && TEST_FILE_PATTERN.test(relativePath)) {\n continue;\n }\n\n const source = readFileSync(file, 'utf8');\n if (!UNION_TEXT.test(source)) {\n continue;\n }\n\n const result = ConstClasses.convert({\n typescript,\n fileName: file,\n source,\n relativePath,\n overrides,\n importFrom,\n });\n\n for (const item of result.untouched) {\n untouchedCount += 1;\n console.warn(`${relativePath}:${item.line}:${item.column} ${item.reason}`);\n }\n\n for (const proposal of result.proposals) {\n converted += 1;\n emitted[proposal.id] = {\n class: proposal.className,\n ...(proposal.id.split('#')[1]?.includes('.') ? { type: proposal.typeName } : {}),\n members: Object.fromEntries(proposal.members.map(({ value, key }) => [value, key])),\n };\n console.log(\n `${isWrite ? 'converted' : 'would convert'} ${relativePath}:${proposal.line} ${proposal.typeName} -> class ${proposal.className} { ${proposal.members.map(({ key, value }) => `${key} = '${value}'`).join(', ')} }` +\n ` [${proposal.id}]`,\n );\n }\n\n if (result.changed) {\n changedFiles += 1;\n if (isWrite) {\n writeFileSync(file, result.output);\n }\n }\n }\n }\n\n const emitPath = values.get(ConstClassFlags.EMIT_MAP);\n if (emitPath) {\n writeFileSync(resolve(root, emitPath), `${JSON.stringify(emitted, null, 2)}\\n`);\n console.log(\n `Wrote ${Object.keys(emitted).length} proposal(s) to ${emitPath}; edit it, then pass --map ${emitPath}.`,\n );\n }\n\n console.log(\n `devz codemod const-classes: ${converted} union(s) ${isWrite ? 'converted' : 'would be converted'} in ${changedFiles} file(s), ${untouchedCount} left untouched`,\n );\n\n if (!isWrite && changedFiles > 0) {\n console.log(\n `Nothing was written. Run again with ${ConstClassFlags.WRITE} to apply (add --map to rename), then run your typecheck and lint.`,\n );\n }\n\n return isCheck && (converted > 0 || untouchedCount > 0) ? 1 : 0;\n }\n}\n"]}
1
+ {"version":3,"file":"const-classes.js","sourceRoot":"","sources":["../../../src/cli/codemod/const-classes.ts"],"names":[],"mappings":";;;AAAA,qCAAsD;AACtD,yCAA8C;AAE9C,mCAAuC;AAIvC,MAAM,mBAAmB,GAAG,+BAA+B,CAAC;AAC5D,MAAM,iBAAiB,GAAG,iDAAiD,CAAC;AAC5E,mFAAmF;AACnF,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC;AAChF,yEAAyE;AACzE,MAAM,UAAU,GAAG,qBAAqB,CAAC;AACzC,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC;AA+C9C,4EAA4E;AAC5E,MAAM,SAAS,GAAG,CAAC,IAAY,EAAU,EAAE;IACzC,MAAM,aAAa,GAAG,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAClE,IAAI,aAAa,EAAE,CAAC;QAClB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAChC,OAAO,GAAG,IAAI,IAAI,CAAC;IACrB,CAAC;IAED,IAAI,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,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,GAAG,MAAM,CAAC,GAAG,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;QACtD,IAAI,QAAQ,EAAE,CAAC;YACb,IAAA,uBAAa,EAAC,IAAA,mBAAO,EAAC,IAAI,EAAE,QAAQ,CAAC,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;YAChF,OAAO,CAAC,GAAG,CACT,SAAS,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,mBAAmB,QAAQ,8BAA8B,QAAQ,GAAG,CACzG,CAAC;QACJ,CAAC;QAED,OAAO,CAAC,GAAG,CACT,+BAA+B,SAAS,aAAa,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,oBAAoB,OAAO,YAAY,aAAa,cAAc,iBAAiB,CACjK,CAAC;QAEF,IAAI,CAAC,OAAO,IAAI,YAAY,GAAG,CAAC,EAAE,CAAC;YACjC,OAAO,CAAC,GAAG,CACT,uCAAuC,eAAe,CAAC,KAAK,oEAAoE,CACjI,CAAC;QACJ,CAAC;QAED,OAAO,OAAO,IAAI,CAAC,SAAS,GAAG,CAAC,IAAI,cAAc,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAClE,CAAC;;AAzLH,kDA0LC","sourcesContent":["import { readFileSync, writeFileSync } from 'node:fs';\nimport { relative, resolve } from 'node:path';\nimport type ts from 'typescript';\nimport { CodemodFiles } from './files';\n\ntype TTypeScript = typeof ts;\n\nconst DEFAULT_IMPORT_FROM = '@venizia/ignis-helpers/common';\nconst TEST_FILE_PATTERN = /(?:^|\\/)__tests__\\/|\\.(?:test|spec)\\.[cm]?tsx?$/;\n/** Utility types whose type argument is a set of keys, not an enumerable value. */\nconst KEY_SET_TYPES = new Set(['Pick', 'Omit', 'Extract', 'Exclude', 'Record']);\n/** A file that can hold a string-literal union: a quote beside a `|`. */\nconst UNION_TEXT = /\\|\\s*['\"]|['\"]\\s*\\|/;\nconst RESERVED_KEYS = new Set(['SCHEME_SET']);\n\n/** What the user may change for one declaration, from the mapping file. */\nexport interface IConstClassOverride {\n /** The class name. */\n class?: string;\n /** The type name; only a property of an interface or object type gets a new one. */\n type?: string;\n /** A member key per literal value: `{ \"read-only\": \"READ_ONLY\" }`. */\n members?: Record<string, string>;\n /** Leave this declaration alone. */\n skip?: boolean;\n}\n\nexport type TConstClassMap = Record<string, IConstClassOverride>;\n\nexport interface IConstClassProposal {\n /** The key of the mapping file: `path/to/file.ts#TName` or `path/to/file.ts#IContainer.property`. */\n id: string;\n line: number;\n className: string;\n typeName: string;\n /** The literal values and the member key each one gets, in order. */\n members: Array<{ value: string; key: string }>;\n /** What the union also held: `null` or `undefined`. */\n nullish: string[];\n}\n\nexport interface IConstClassUntouched {\n line: number;\n column: number;\n reason: string;\n}\n\nexport interface IConstClassResult {\n output: string;\n changed: boolean;\n proposals: IConstClassProposal[];\n untouched: IConstClassUntouched[];\n}\n\ninterface IEdit {\n start: number;\n end: number;\n text: string;\n}\n\n/** The plural of a PascalCase word, for the class that holds its values. */\nconst pluralize = (word: string): string => {\n const alreadyPlural = /[^uis]s$/.test(word) || /ings$/.test(word);\n if (alreadyPlural) {\n return word;\n }\n\n if (/(s|x|z|ch|sh)$/.test(word)) {\n return `${word}es`;\n }\n\n if (/[^aeiou]y$/.test(word)) {\n return `${word.slice(0, -1)}ies`;\n }\n\n return `${word}s`;\n};\n\n/** `read-only`, `readOnly` and `string[]` become `READ_ONLY`, `READ_ONLY` and `STRING_ARRAY`; `undefined` when nothing is left. */\nconst toKey = (value: string): string | undefined => {\n const key = value\n .replace(/\\[\\]/g, '_ARRAY_')\n .replace(/([a-z0-9])([A-Z])/g, '$1_$2')\n .replace(/[^A-Za-z0-9]+/g, '_')\n .replace(/^_+|_+$/g, '')\n .toUpperCase();\n\n if (key === '') {\n return undefined;\n }\n\n return /^[0-9]/.test(key) ? `_${key}` : key;\n};\n\nconst pascal = (word: string): string => `${word.charAt(0).toUpperCase()}${word.slice(1)}`;\n\n/**\n * Turns the string-literal unions of exported declarations into const classes: an exported type\n * alias, and a property of an exported interface or object type. The values stay the same, so every\n * existing literal still type-checks and no call site changes. A union it cannot name is reported.\n */\nexport class ConstClasses {\n static convert(opts: {\n typescript: TTypeScript;\n fileName: string;\n source: string;\n /** The id prefix of the mapping file: the path of the file relative to the project root. */\n relativePath?: string;\n overrides?: TConstClassMap;\n importFrom?: string;\n }): IConstClassResult {\n const { typescript, fileName, source, overrides = {}, importFrom = DEFAULT_IMPORT_FROM } = opts;\n const relativePath = opts.relativePath ?? fileName;\n const sourceFile = typescript.createSourceFile(\n fileName,\n source,\n typescript.ScriptTarget.Latest,\n true,\n );\n const taken = ConstClasses.declaredNames({ typescript, sourceFile });\n const proposals: IConstClassProposal[] = [];\n const untouched: IConstClassUntouched[] = [];\n const edits: IEdit[] = [];\n const insertions = new Map<number, string[]>();\n const handled = new Set<ts.Node>();\n\n const report = (node: ts.Node, reason: string) => {\n const { line, character } = sourceFile.getLineAndCharacterOfPosition(\n node.getStart(sourceFile),\n );\n untouched.push({ line: line + 1, column: character + 1, reason });\n };\n\n const lineOf = (node: ts.Node) =>\n sourceFile.getLineAndCharacterOfPosition(node.getStart(sourceFile)).line + 1;\n\n /** Plans one conversion; `undefined` and a report when the names or the members do not work. */\n const plan = (planOpts: {\n node: ts.UnionTypeNode;\n id: string;\n className: string;\n typeName: string;\n anchor: ts.Node;\n mayRenameType: boolean;\n }): void => {\n const { node, id, anchor } = planOpts;\n const override = overrides[id] ?? {};\n const union = ConstClasses.readUnion({ typescript, node });\n\n if (override.skip) {\n handled.add(node);\n return;\n }\n\n const className = override.class ?? planOpts.className;\n const typeName = planOpts.mayRenameType\n ? (override.type ?? planOpts.typeName)\n : planOpts.typeName;\n const members = union.values.map((value) => ({\n value,\n key: override.members?.[value] ?? toKey(value) ?? '',\n }));\n\n const problem = ConstClasses.checkPlan({\n className,\n typeName,\n members,\n taken,\n mayRenameType: planOpts.mayRenameType,\n });\n if (problem) {\n report(node, `${problem}; left untouched (name it in the mapping file: ${id})`);\n handled.add(node);\n return;\n }\n\n taken.add(className);\n if (planOpts.mayRenameType) {\n taken.add(typeName);\n }\n\n handled.add(node);\n proposals.push({\n id,\n line: lineOf(node),\n className,\n typeName,\n members,\n nullish: union.nullish,\n });\n\n const classText = ConstClasses.renderClass({ className, typeName, members });\n const reference = `TConstValue<typeof ${className}>`;\n const nullishText = union.nullish.map((member) => ` | ${member}`).join('');\n\n if (planOpts.mayRenameType) {\n const aliasText = `export type ${typeName} = ${reference};\\n\\n`;\n const at = anchor.getStart(sourceFile, true);\n insertions.set(at, [...(insertions.get(at) ?? []), `${classText}\\n\\n${aliasText}`]);\n edits.push({\n start: node.getStart(sourceFile),\n end: node.end,\n text: `${typeName}${nullishText}`,\n });\n return;\n }\n\n const at = anchor.getStart(sourceFile, true);\n insertions.set(at, [...(insertions.get(at) ?? []), `${classText}\\n\\n`]);\n edits.push({\n start: node.getStart(sourceFile),\n end: node.end,\n text: `${reference}${nullishText}`,\n });\n };\n\n for (const statement of sourceFile.statements) {\n if (!ConstClasses.isExported({ typescript, node: statement })) {\n continue;\n }\n\n if (typescript.isTypeAliasDeclaration(statement)) {\n const union = typescript.isUnionTypeNode(statement.type) ? statement.type : undefined;\n if (union && ConstClasses.isEnumerable({ typescript, node: union })) {\n const base = statement.name.text.replace(/^T(?=[A-Z])/, '');\n plan({\n node: union,\n id: `${relativePath}#${statement.name.text}`,\n className: pluralize(base),\n typeName: statement.name.text,\n anchor: statement,\n mayRenameType: false,\n });\n continue;\n }\n\n if (typescript.isTypeLiteralNode(statement.type)) {\n ConstClasses.planMembers({\n typescript,\n container: statement,\n members: statement.type.members,\n relativePath,\n plan,\n });\n }\n }\n\n if (typescript.isInterfaceDeclaration(statement)) {\n ConstClasses.planMembers({\n typescript,\n container: statement,\n members: statement.members,\n relativePath,\n plan,\n });\n }\n\n ConstClasses.findStrays({ typescript, statement, handled, report });\n }\n\n if (proposals.length === 0) {\n return { output: source, changed: false, proposals, untouched };\n }\n\n for (const [at, texts] of insertions) {\n edits.push({ start: at, end: at, text: texts.join('') });\n }\n\n // Last, so that at the top of a file the import lands above the class inserted at the same place.\n const importEdit = ConstClasses.planImport({ typescript, sourceFile, importFrom });\n if (importEdit) {\n edits.push(importEdit);\n }\n\n let output = source;\n for (const edit of edits.sort((a, b) => b.start - a.start || b.end - a.end)) {\n output = output.slice(0, edit.start) + edit.text + output.slice(edit.end);\n }\n\n return { output, changed: output !== source, proposals, untouched };\n }\n\n private static planMembers(opts: {\n typescript: TTypeScript;\n container: ts.InterfaceDeclaration | ts.TypeAliasDeclaration;\n members: ts.NodeArray<ts.TypeElement>;\n relativePath: string;\n plan: (planOpts: {\n node: ts.UnionTypeNode;\n id: string;\n className: string;\n typeName: string;\n anchor: ts.Node;\n mayRenameType: boolean;\n }) => void;\n }): void {\n const { typescript, container, members, relativePath, plan } = opts;\n const containerName = container.name.text;\n const base = containerName.replace(/^[IT](?=[A-Z])/, '');\n\n for (const member of members) {\n if (!typescript.isPropertySignature(member) || !member.type) {\n continue;\n }\n\n if (\n !typescript.isUnionTypeNode(member.type) ||\n !ConstClasses.isEnumerable({ typescript, node: member.type })\n ) {\n continue;\n }\n\n const property = typescript.isIdentifier(member.name) ? member.name.text : undefined;\n if (!property) {\n continue;\n }\n\n plan({\n node: member.type,\n id: `${relativePath}#${containerName}.${property}`,\n className: pluralize(`${base}${pascal(property)}`),\n typeName: `T${base}${pascal(property)}`,\n anchor: container,\n mayRenameType: true,\n });\n }\n }\n\n /** Every top-level name the file declares or imports. */\n private static declaredNames(opts: {\n typescript: TTypeScript;\n sourceFile: ts.SourceFile;\n }): Set<string> {\n const { typescript, sourceFile } = opts;\n const names = new Set<string>();\n\n for (const statement of sourceFile.statements) {\n if (typescript.isImportDeclaration(statement) && statement.importClause) {\n const { name, namedBindings } = statement.importClause;\n if (name) {\n names.add(name.text);\n }\n\n if (namedBindings && typescript.isNamespaceImport(namedBindings)) {\n names.add(namedBindings.name.text);\n }\n\n if (namedBindings && typescript.isNamedImports(namedBindings)) {\n for (const element of namedBindings.elements) {\n names.add(element.name.text);\n }\n }\n continue;\n }\n\n if (typescript.isVariableStatement(statement)) {\n for (const declaration of statement.declarationList.declarations) {\n if (typescript.isIdentifier(declaration.name)) {\n names.add(declaration.name.text);\n }\n }\n continue;\n }\n\n if (\n (typescript.isClassDeclaration(statement) ||\n typescript.isFunctionDeclaration(statement) ||\n typescript.isInterfaceDeclaration(statement) ||\n typescript.isTypeAliasDeclaration(statement) ||\n typescript.isEnumDeclaration(statement) ||\n typescript.isModuleDeclaration(statement)) &&\n statement.name &&\n typescript.isIdentifier(statement.name)\n ) {\n names.add(statement.name.text);\n }\n }\n\n return names;\n }\n\n private static isExported(opts: { typescript: TTypeScript; node: ts.Node }): boolean {\n const { typescript, node } = opts;\n const modifiers = typescript.canHaveModifiers(node) ? typescript.getModifiers(node) : undefined;\n return (\n modifiers?.some((modifier) => modifier.kind === typescript.SyntaxKind.ExportKeyword) === true\n );\n }\n\n /** The string values of a union, and its `null` or `undefined` members; the union must be string literals (and nullish) only. */\n private static readUnion(opts: { typescript: TTypeScript; node: ts.UnionTypeNode }): {\n values: string[];\n nullish: string[];\n } {\n const { typescript, node } = opts;\n const values: string[] = [];\n const nullish: string[] = [];\n\n for (const member of node.types) {\n if (typescript.isLiteralTypeNode(member) && typescript.isStringLiteral(member.literal)) {\n if (!values.includes(member.literal.text)) {\n values.push(member.literal.text);\n }\n continue;\n }\n\n if (member.kind === typescript.SyntaxKind.NullKeyword) {\n nullish.push('null');\n } else if (member.kind === typescript.SyntaxKind.UndefinedKeyword) {\n nullish.push('undefined');\n } else if (\n typescript.isLiteralTypeNode(member) &&\n member.literal.kind === typescript.SyntaxKind.NullKeyword\n ) {\n nullish.push('null');\n }\n }\n\n return { values, nullish };\n }\n\n /** At least two string literals, and nothing else but `null` or `undefined`. */\n private static isEnumerable(opts: { typescript: TTypeScript; node: ts.UnionTypeNode }): boolean {\n const { typescript, node } = opts;\n let literals = 0;\n\n for (const member of node.types) {\n if (typescript.isLiteralTypeNode(member) && typescript.isStringLiteral(member.literal)) {\n literals += 1;\n continue;\n }\n\n const isNullish =\n member.kind === typescript.SyntaxKind.UndefinedKeyword ||\n member.kind === typescript.SyntaxKind.NullKeyword ||\n (typescript.isLiteralTypeNode(member) &&\n member.literal.kind === typescript.SyntaxKind.NullKeyword);\n if (!isNullish) {\n return false;\n }\n }\n\n return literals >= 2;\n }\n\n private static checkPlan(opts: {\n className: string;\n typeName: string;\n members: Array<{ value: string; key: string }>;\n taken: Set<string>;\n mayRenameType: boolean;\n }): string | undefined {\n const { className, typeName, members, taken, mayRenameType } = opts;\n\n if (taken.has(className)) {\n return `the name ${className} is already used in this file`;\n }\n\n if (mayRenameType && taken.has(typeName)) {\n return `the name ${typeName} is already used in this file`;\n }\n\n const keys = new Set<string>();\n for (const { value, key } of members) {\n if (key === '') {\n return `no member name can be made from ${JSON.stringify(value)}`;\n }\n\n if (RESERVED_KEYS.has(key)) {\n return `${JSON.stringify(value)} would become the reserved member ${key}`;\n }\n\n if (keys.has(key)) {\n return `two values give the member ${key}`;\n }\n\n keys.add(key);\n }\n\n return undefined;\n }\n\n private static renderClass(opts: {\n className: string;\n typeName: string;\n members: Array<{ value: string; key: string }>;\n }): string {\n const { className, typeName, members } = opts;\n const quote = (value: string) => `'${value.replace(/\\\\/g, '\\\\\\\\').replace(/'/g, \"\\\\'\")}'`;\n const lines = [\n `/** The values of \\`${typeName}\\`. */`,\n `export class ${className} {`,\n ...members.map(({ value, key }) => ` static readonly ${key} = ${quote(value)};`),\n '',\n ` static readonly SCHEME_SET = new Set<string>([${members.map(({ key }) => `this.${key}`).join(', ')}]);`,\n '',\n ` static isValid(value: string): value is ${typeName} {`,\n ' return this.SCHEME_SET.has(value);',\n ' }',\n '}',\n ];\n\n return lines.join('\\n');\n }\n\n /** Reports every string-literal union of an exported declaration the codemod did not handle: it cannot name those. */\n private static findStrays(opts: {\n typescript: TTypeScript;\n statement: ts.Statement;\n handled: Set<ts.Node>;\n report: (node: ts.Node, reason: string) => void;\n }): void {\n const { typescript, statement, handled, report } = opts;\n\n const walk = (node: ts.Node): void => {\n if (typescript.isVariableDeclaration(node) && node.type) {\n // The annotation of an exported constant is not what the lint rule asks to name.\n if (node.initializer) {\n walk(node.initializer);\n }\n return;\n }\n\n if (typescript.isUnionTypeNode(node) && ConstClasses.isEnumerable({ typescript, node })) {\n if (!handled.has(node) && !ConstClasses.isKeySet({ typescript, node })) {\n report(\n node,\n 'a string-literal union in this position (a parameter, a return type, a generic or a nested type) has no name to give it; write the const class by hand',\n );\n }\n\n return;\n }\n\n typescript.forEachChild(node, walk);\n };\n\n walk(statement);\n }\n\n private static isKeySet(opts: { typescript: TTypeScript; node: ts.Node }): boolean {\n const { typescript, node } = opts;\n const parent = node.parent;\n\n if (typescript.isMappedTypeNode(parent) || typescript.isTypeOperatorNode(parent)) {\n return true;\n }\n\n if (\n typescript.isTypeParameterDeclaration(parent) &&\n typescript.isMappedTypeNode(parent.parent)\n ) {\n return true;\n }\n\n if (\n parent &&\n typescript.isTypeReferenceNode(parent) &&\n typescript.isIdentifier(parent.typeName) &&\n KEY_SET_TYPES.has(parent.typeName.text)\n ) {\n return true;\n }\n\n return false;\n }\n\n /** The edit that makes `TConstValue` available: nothing when the file has it, a specifier on an import from the same module, else a new import line. */\n private static planImport(opts: {\n typescript: TTypeScript;\n sourceFile: ts.SourceFile;\n importFrom: string;\n }): IEdit | undefined {\n const { typescript, sourceFile, importFrom } = opts;\n let lastImportEnd = 0;\n let sameModule: ts.ImportDeclaration | undefined;\n\n for (const statement of sourceFile.statements) {\n if (!typescript.isImportDeclaration(statement)) {\n continue;\n }\n\n lastImportEnd = statement.end;\n const bindings = statement.importClause?.namedBindings;\n if (bindings && typescript.isNamedImports(bindings)) {\n if (bindings.elements.some((element) => element.name.text === 'TConstValue')) {\n return undefined;\n }\n\n if (\n typescript.isStringLiteral(statement.moduleSpecifier) &&\n statement.moduleSpecifier.text === importFrom\n ) {\n sameModule = statement;\n }\n }\n }\n\n const bindings = sameModule?.importClause?.namedBindings;\n if (\n sameModule &&\n bindings &&\n typescript.isNamedImports(bindings) &&\n bindings.elements.length > 0\n ) {\n const last = bindings.elements[bindings.elements.length - 1];\n const typeOnly = sameModule.importClause?.isTypeOnly === true;\n return {\n start: last?.end ?? bindings.end,\n end: last?.end ?? bindings.end,\n text: typeOnly ? ', TConstValue' : ', type TConstValue',\n };\n }\n\n const line = `import type { TConstValue } from '${importFrom}';`;\n if (lastImportEnd > 0) {\n return { start: lastImportEnd, end: lastImportEnd, text: `\\n${line}` };\n }\n\n return { start: 0, end: 0, text: `${line}\\n\\n` };\n }\n}\n\nconst USAGE = `Usage: devz codemod const-classes [paths...] [--write | --check] [--map <file>] [--emit-map <file>] [--import-from <module>] [--include-tests]\n\nTurns a string-literal union in an exported declaration into a const class (SCHEME_SET, isValid) plus\n\\`TConstValue<typeof X>\\`, the shape the venizia/const-class-values lint rule asks for. It handles an\nexported type alias and a property of an exported interface or object type. The values stay the same,\nso every existing literal still type-checks and no call site changes.\n\nIt has to choose names: the class is the type name without its leading T, in the plural; a member is\nthe value in upper snake case. The dry run prints every proposal.\n\n --write write the changed files (without it, nothing is written)\n --check dry run that exits 1 while a union can be converted or is left untouched (for CI)\n --all with --write and no path: rewrite every source file under the working directory (--write needs a path or --all)\n --map <file> a JSON file of overrides, keyed by the id the dry run prints\n --emit-map <file> write the proposals as a mapping file to edit, then pass it with --map\n --import-from <m> where TConstValue is imported from (default ${DEFAULT_IMPORT_FROM})\n --include-tests also convert test files (skipped by default)\n --help print this text and exit\n\nA mapping entry: { \"src/a.ts#TMode\": { \"class\": \"Modes\", \"members\": { \"read-only\": \"READ_ONLY\" } } },\nor { \"skip\": true }. A union in a parameter, a return type, a generic or a nested type is reported as\nleft untouched: it has no name, so write that class by hand. Key sets (Pick, Omit, Extract, Exclude,\nRecord, mapped types) are not enumerable values and are never touched.`;\n\n/** A usage error: nothing was read or written. */\nconst USAGE_ERROR_CODE = 2;\n\nclass ConstClassFlags {\n static readonly WRITE = '--write';\n static readonly CHECK = '--check';\n static readonly ALL = '--all';\n static readonly MAP = '--map';\n static readonly EMIT_MAP = '--emit-map';\n static readonly IMPORT_FROM = '--import-from';\n static readonly INCLUDE_TESTS = '--include-tests';\n static readonly HELP = '--help';\n static readonly HELP_SHORT = '-h';\n\n static readonly SCHEME_SET = new Set<string>([\n this.WRITE,\n this.CHECK,\n this.ALL,\n this.MAP,\n this.EMIT_MAP,\n this.IMPORT_FROM,\n this.INCLUDE_TESTS,\n this.HELP,\n this.HELP_SHORT,\n ]);\n\n /** The flags that take a value. */\n static readonly WITH_VALUE = new Set<string>([this.MAP, this.EMIT_MAP, this.IMPORT_FROM]);\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n}\n\n/** `devz codemod const-classes [paths...] [--write | --check]`. */\nexport class ConstClassesCommand {\n static readonly USAGE = USAGE;\n\n static async run(opts: { root: string; args: string[] }): Promise<number> {\n const { root, args } = opts;\n\n if (args.includes(ConstClassFlags.HELP) || args.includes(ConstClassFlags.HELP_SHORT)) {\n console.log(USAGE);\n return 0;\n }\n\n const flags: string[] = [];\n const paths: string[] = [];\n const values = new Map<string, string>();\n\n for (let index = 0; index < args.length; index += 1) {\n const argument = args[index] ?? '';\n const [name, inline] = argument.startsWith('--') ? argument.split(/=(.*)/s) : [argument];\n\n if (name !== undefined && ConstClassFlags.WITH_VALUE.has(name)) {\n const value = inline ?? args[index + 1];\n if (inline === undefined) {\n index += 1;\n }\n\n if (!value || value.startsWith('-')) {\n console.error(`devz codemod: ${name} needs a value\\n${USAGE}`);\n return USAGE_ERROR_CODE;\n }\n\n values.set(name, value);\n continue;\n }\n\n if (argument.startsWith('-')) {\n flags.push(argument);\n } else {\n paths.push(argument);\n }\n }\n\n const unknown = flags.filter((flag) => !ConstClassFlags.isValid(flag));\n if (unknown.length > 0) {\n console.error(\n `devz codemod: unknown option ${unknown.map((flag) => `\"${flag}\"`).join(', ')}\\n${USAGE}`,\n );\n return USAGE_ERROR_CODE;\n }\n\n const isWrite = flags.includes(ConstClassFlags.WRITE);\n const isCheck = flags.includes(ConstClassFlags.CHECK);\n\n const refusal = CodemodFiles.refusal({\n command: 'const-classes',\n isWrite,\n isAll: flags.includes(ConstClassFlags.ALL),\n paths,\n });\n if (refusal) {\n console.error(`${refusal}\\n${USAGE}`);\n return USAGE_ERROR_CODE;\n }\n const includeTests = flags.includes(ConstClassFlags.INCLUDE_TESTS);\n\n if (isWrite && isCheck) {\n console.error(\n `devz codemod: ${ConstClassFlags.WRITE} and ${ConstClassFlags.CHECK} contradict each other\\n${USAGE}`,\n );\n return USAGE_ERROR_CODE;\n }\n\n let overrides: TConstClassMap = {};\n const mapPath = values.get(ConstClassFlags.MAP);\n if (mapPath) {\n let parsed: unknown;\n try {\n parsed = JSON.parse(readFileSync(resolve(root, mapPath), 'utf8'));\n } catch (error) {\n console.error(\n `devz codemod: cannot read the mapping file ${mapPath}: ${error instanceof Error ? error.message : String(error)}`,\n );\n return USAGE_ERROR_CODE;\n }\n\n if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {\n console.error(\n `devz codemod: cannot read the mapping file ${mapPath}: the file must hold one JSON object`,\n );\n return USAGE_ERROR_CODE;\n }\n\n overrides = Object.fromEntries(Object.entries(parsed));\n }\n\n let typescript: TTypeScript;\n try {\n const result2 = await import('typescript');\n typescript = result2.default;\n } catch {\n console.error('devz codemod: the \"typescript\" package is required to read your sources');\n return 1;\n }\n\n const targets = (paths.length > 0 ? paths : ['.']).map((path) => resolve(root, path));\n const importFrom = values.get(ConstClassFlags.IMPORT_FROM);\n const emitted: TConstClassMap = {};\n let changedFiles = 0;\n let converted = 0;\n let untouchedCount = 0;\n\n for (const target of targets) {\n const files = CodemodFiles.collect({ target });\n\n if (files.length === 0 && paths.length > 0) {\n console.warn(\n `devz codemod: no source files under \"${relative(root, target) || target}\" (git ignores the path, or it holds none): nothing was read`,\n );\n }\n\n for (const file of files) {\n const relativePath = relative(root, file).split('\\\\').join('/');\n if (!includeTests && TEST_FILE_PATTERN.test(relativePath)) {\n continue;\n }\n\n const source = readFileSync(file, 'utf8');\n if (!UNION_TEXT.test(source)) {\n continue;\n }\n\n const result = ConstClasses.convert({\n typescript,\n fileName: file,\n source,\n relativePath,\n overrides,\n importFrom,\n });\n\n for (const item of result.untouched) {\n untouchedCount += 1;\n console.warn(`${relativePath}:${item.line}:${item.column} ${item.reason}`);\n }\n\n for (const proposal of result.proposals) {\n converted += 1;\n emitted[proposal.id] = {\n class: proposal.className,\n ...(proposal.id.split('#')[1]?.includes('.') ? { type: proposal.typeName } : {}),\n members: Object.fromEntries(proposal.members.map(({ value, key }) => [value, key])),\n };\n console.log(\n `${isWrite ? 'converted' : 'would convert'} ${relativePath}:${proposal.line} ${proposal.typeName} -> class ${proposal.className} { ${proposal.members.map(({ key, value }) => `${key} = '${value}'`).join(', ')} }` +\n ` [${proposal.id}]`,\n );\n }\n\n if (result.changed) {\n changedFiles += 1;\n if (isWrite) {\n writeFileSync(file, result.output);\n }\n }\n }\n }\n\n const emitPath = values.get(ConstClassFlags.EMIT_MAP);\n if (emitPath) {\n writeFileSync(resolve(root, emitPath), `${JSON.stringify(emitted, null, 2)}\\n`);\n console.log(\n `Wrote ${Object.keys(emitted).length} proposal(s) to ${emitPath}; edit it, then pass --map ${emitPath}.`,\n );\n }\n\n console.log(\n `devz codemod const-classes: ${converted} union(s) ${isWrite ? 'converted' : 'would be converted'} in ${changedFiles} file(s), ${untouchedCount} left untouched`,\n );\n\n if (!isWrite && changedFiles > 0) {\n console.log(\n `Nothing was written. Run again with ${ConstClassFlags.WRITE} to apply (add --map to rename), then run your typecheck and lint.`,\n );\n }\n\n return isCheck && (converted > 0 || untouchedCount > 0) ? 1 : 0;\n }\n}\n"]}
@@ -102,7 +102,7 @@ export declare class RedundantCasts {
102
102
  }
103
103
  /** `devz codemod drop-redundant-casts [paths...] [--write | --check]`. */
104
104
  export declare class DropRedundantCastsCommand {
105
- static readonly USAGE = "Usage: devz codemod drop-redundant-casts [paths...] [--write | --check] [--project <tsconfig>] [--include-tests]\n\nRemoves `as X` casts the compiler no longer needs. A removal is kept only if the package still\ntypechecks: all removals of a package are tried together in memory and the failing ones are found\nby halving, so the package is checked a handful of times, not once per cast.\n\n --write write the changed files (without it, nothing is written)\n --check dry run that exits 1 while a removable cast remains (for CI)\n --project <file> the tsconfig to check against (default: the nearest tsconfig.json of each file)\n --include-tests also try casts in test files (skipped by default)\n --help print this text and exit\n\nA cast stays when its removal breaks the typecheck, and always for `as const`, `as unknown`,\n`x as unknown as T` and a cast of an `any` or `unknown` expression: the cast is the only type\nthere. The report lists how many casts stayed and why. Run your own typecheck after --write.";
105
+ static readonly USAGE = "Usage: devz codemod drop-redundant-casts [paths...] [--write | --check] [--project <tsconfig>] [--include-tests]\n\nRemoves `as X` casts the compiler no longer needs. A removal is kept only if the package still\ntypechecks: all removals of a package are tried together in memory and the failing ones are found\nby halving, so the package is checked a handful of times, not once per cast.\n\n --write write the changed files (without it, nothing is written)\n --check dry run that exits 1 while a removable cast remains (for CI)\n --all with --write and no path: rewrite every source file under the working directory (--write needs a path or --all)\n --project <file> the tsconfig to check against (default: the nearest tsconfig.json of each file)\n --include-tests also try casts in test files (skipped by default)\n --help print this text and exit\n\nA cast stays when its removal breaks the typecheck, and always for `as const`, `as unknown`,\n`x as unknown as T` and a cast of an `any` or `unknown` expression: the cast is the only type\nthere. The report lists how many casts stayed and why. Run your own typecheck after --write.";
106
106
  static run(opts: {
107
107
  root: string;
108
108
  args: string[];
@@ -1 +1 @@
1
- {"version":3,"file":"drop-redundant-casts.d.ts","sourceRoot":"","sources":["../../../src/cli/codemod/drop-redundant-casts.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4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,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,GAAG,SAAS;CAmB9E;AA8CD,0EAA0E;AAC1E,qBAAa,yBAAyB;IACpC,MAAM,CAAC,QAAQ,CAAC,KAAK,6qCAAS;WAEjB,GAAG,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,EAAE,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,CAAC;CAwL1E"}
@@ -614,6 +614,7 @@ by halving, so the package is checked a handful of times, not once per cast.
614
614
 
615
615
  --write write the changed files (without it, nothing is written)
616
616
  --check dry run that exits 1 while a removable cast remains (for CI)
617
+ --all with --write and no path: rewrite every source file under the working directory (--write needs a path or --all)
617
618
  --project <file> the tsconfig to check against (default: the nearest tsconfig.json of each file)
618
619
  --include-tests also try casts in test files (skipped by default)
619
620
  --help print this text and exit
@@ -626,6 +627,7 @@ const USAGE_ERROR_CODE = 2;
626
627
  class CastFlags {
627
628
  static { this.WRITE = '--write'; }
628
629
  static { this.CHECK = '--check'; }
630
+ static { this.ALL = '--all'; }
629
631
  static { this.PROJECT = '--project'; }
630
632
  static { this.INCLUDE_TESTS = '--include-tests'; }
631
633
  static { this.HELP = '--help'; }
@@ -633,6 +635,7 @@ class CastFlags {
633
635
  static { this.SCHEME_SET = new Set([
634
636
  this.WRITE,
635
637
  this.CHECK,
638
+ this.ALL,
636
639
  this.PROJECT,
637
640
  this.INCLUDE_TESTS,
638
641
  this.HELP,
@@ -683,6 +686,16 @@ class DropRedundantCastsCommand {
683
686
  }
684
687
  const isWrite = flags.includes(CastFlags.WRITE);
685
688
  const isCheck = flags.includes(CastFlags.CHECK);
689
+ const refusal = files_1.CodemodFiles.refusal({
690
+ command: 'drop-redundant-casts',
691
+ isWrite,
692
+ isAll: flags.includes(CastFlags.ALL),
693
+ paths,
694
+ });
695
+ if (refusal) {
696
+ console.error(`${refusal}\n${USAGE}`);
697
+ return USAGE_ERROR_CODE;
698
+ }
686
699
  const includeTests = flags.includes(CastFlags.INCLUDE_TESTS);
687
700
  if (isWrite && isCheck) {
688
701
  console.error(`devz codemod: ${CastFlags.WRITE} and ${CastFlags.CHECK} contradict each other\n${USAGE}`);