@venizia/dev-configs 0.4.7-1 → 0.4.7-3

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.
Files changed (38) hide show
  1. package/dist/checks/purity/probe.d.ts.map +1 -1
  2. package/dist/checks/purity/probe.js +1 -2
  3. package/dist/checks/purity/probe.js.map +1 -1
  4. package/dist/checks/test-mutate.d.ts.map +1 -1
  5. package/dist/checks/test-mutate.js +1 -2
  6. package/dist/checks/test-mutate.js.map +1 -1
  7. package/dist/cli/codemod/async-style.d.ts +1 -1
  8. package/dist/cli/codemod/async-style.d.ts.map +1 -1
  9. package/dist/cli/codemod/async-style.js +13 -0
  10. package/dist/cli/codemod/async-style.js.map +1 -1
  11. package/dist/cli/codemod/const-classes.d.ts +1 -1
  12. package/dist/cli/codemod/const-classes.d.ts.map +1 -1
  13. package/dist/cli/codemod/const-classes.js +13 -0
  14. package/dist/cli/codemod/const-classes.js.map +1 -1
  15. package/dist/cli/codemod/drop-redundant-casts.d.ts +1 -1
  16. package/dist/cli/codemod/drop-redundant-casts.d.ts.map +1 -1
  17. package/dist/cli/codemod/drop-redundant-casts.js +13 -0
  18. package/dist/cli/codemod/drop-redundant-casts.js.map +1 -1
  19. package/dist/cli/codemod/files.d.ts +12 -0
  20. package/dist/cli/codemod/files.d.ts.map +1 -1
  21. package/dist/cli/codemod/files.js +18 -0
  22. package/dist/cli/codemod/files.js.map +1 -1
  23. package/dist/cli/codemod/namespace-functions/index.d.ts +1 -1
  24. package/dist/cli/codemod/namespace-functions/index.d.ts.map +1 -1
  25. package/dist/cli/codemod/namespace-functions/index.js +7 -5
  26. package/dist/cli/codemod/namespace-functions/index.js.map +1 -1
  27. package/dist/cli/codemod/namespace-functions/logger-scope.d.ts +31 -10
  28. package/dist/cli/codemod/namespace-functions/logger-scope.d.ts.map +1 -1
  29. package/dist/cli/codemod/namespace-functions/logger-scope.js +290 -43
  30. package/dist/cli/codemod/namespace-functions/logger-scope.js.map +1 -1
  31. package/dist/cli/codemod/namespace-functions/mappings/core-server.d.ts +4 -2
  32. package/dist/cli/codemod/namespace-functions/mappings/core-server.d.ts.map +1 -1
  33. package/dist/cli/codemod/namespace-functions/mappings/core-server.js +20 -2
  34. package/dist/cli/codemod/namespace-functions/mappings/core-server.js.map +1 -1
  35. package/dist/cli/codemod/namespace-functions/mappings/helpers.d.ts +2 -2
  36. package/dist/cli/codemod/namespace-functions/mappings/helpers.js +2 -2
  37. package/dist/cli/codemod/namespace-functions/mappings/helpers.js.map +1 -1
  38. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"drop-redundant-casts.js","sourceRoot":"","sources":["../../../src/cli/codemod/drop-redundant-casts.ts"],"names":[],"mappings":";;;AAAA,qCAAkE;AAClE,yCAA6D;AAG7D,mCAAuC;AAIvC,uDAAuD;AACvD,MAAa,eAAe;IAC1B,0DAA0D;aAC1C,WAAM,GAAG,QAAQ,CAAC;IAClC,2DAA2D;aAC3C,aAAQ,GAAG,UAAU,CAAC;IACtC,6EAA6E;aAC7D,gBAAW,GAAG,aAAa,CAAC;IAC5C,wCAAwC;aACxB,mBAAc,GAAG,gBAAgB,CAAC;IAClD,yFAAyF;aACzE,mBAAc,GAAG,gBAAgB,CAAC;IAClD,qEAAqE;aACrD,uBAAkB,GAAG,oBAAoB,CAAC;IAC1D,gEAAgE;aAChD,cAAS,GAAG,WAAW,CAAC;IACxC,+EAA+E;aAC/D,mBAAc,GAAG,gBAAgB,CAAC;aAElC,eAAU,GAAG,IAAI,GAAG,CAAS;QAC3C,IAAI,CAAC,MAAM;QACX,IAAI,CAAC,QAAQ;QACb,IAAI,CAAC,WAAW;QAChB,IAAI,CAAC,cAAc;QACnB,IAAI,CAAC,cAAc;QACnB,IAAI,CAAC,kBAAkB;QACvB,IAAI,CAAC,SAAS;QACd,IAAI,CAAC,cAAc;KACpB,CAAC,CAAC;IAEH,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAA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AO,IAAI,YAAY,GAAG,CAAC,EAAE,CAAC;YACjC,OAAO,CAAC,GAAG,CACT,uCAAuC,SAAS,CAAC,KAAK,qCAAqC,CAC5F,CAAC;QACJ,CAAC;QAED,OAAO,OAAO,IAAI,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACxC,CAAC;;AA/KH,8DAgLC","sourcesContent":["import { existsSync, readFileSync, writeFileSync } from 'node:fs';\nimport { dirname, join, relative, resolve } from 'node:path';\nimport type ts from 'typescript';\nimport type { TConstValue } from '../../linters/rules/common';\nimport { CodemodFiles } from './files';\n\ntype TTypeScript = typeof ts;\n\n/** Why a cast is still there after the codemod ran. */\nexport class CastKeepReasons {\n /** Taking it out makes the package fail its typecheck. */\n static readonly NEEDED = 'needed';\n /** `as const` is a narrowing the codemod never touches. */\n static readonly AS_CONST = 'as-const';\n /** `x as unknown as T`: a deliberate escape that only a person can judge. */\n static readonly DOUBLE_CAST = 'double-cast';\n /** `x as unknown` widens on purpose. */\n static readonly UNKNOWN_TARGET = 'unknown-target';\n /** The expression is `any`: the cast is the only type it has, so it is not redundant. */\n static readonly ANY_EXPRESSION = 'any-expression';\n /** The expression is `unknown`: the cast is the only type it has. */\n static readonly UNKNOWN_EXPRESSION = 'unknown-expression';\n /** Test files are skipped unless `--include-tests` is given. */\n static readonly TEST_FILE = 'test-file';\n /** The file is not part of the package's tsconfig, so nothing can check it. */\n static readonly NOT_IN_PROJECT = 'not-in-project';\n\n static readonly SCHEME_SET = new Set<string>([\n this.NEEDED,\n this.AS_CONST,\n this.DOUBLE_CAST,\n this.UNKNOWN_TARGET,\n this.ANY_EXPRESSION,\n this.UNKNOWN_EXPRESSION,\n this.TEST_FILE,\n this.NOT_IN_PROJECT,\n ]);\n\n static isValid(value: string): value is TCastKeepReason {\n return this.SCHEME_SET.has(value);\n }\n}\n\nexport type TCastKeepReason = TConstValue<typeof CastKeepReasons>;\n\nexport interface IKeptCast {\n /** Line and column in the output text (the file after the removals). */\n line: number;\n column: number;\n reason: TCastKeepReason;\n}\n\nexport interface IFileCastResult {\n file: string;\n /** The file text after the removals and the imports they left unused. */\n output: string;\n changed: boolean;\n removed: number;\n importsRemoved: number;\n kept: IKeptCast[];\n}\n\nexport interface IProjectCastResult {\n files: IFileCastResult[];\n /** How many times the package was typechecked (the baseline run included). */\n checks: number;\n /** Errors the package already had before any removal; they are not counted against a removal. */\n baselineErrors: number;\n}\n\n/** One error of a check: its message key (file, code, text) and where it points. */\ninterface IFoundError {\n key: string;\n file: string;\n start: number;\n}\n\ninterface IDiagnosticReport {\n counts: Map<string, number>;\n items: IFoundError[];\n}\n\ninterface ICastCandidate {\n file: string;\n start: number;\n end: number;\n replacement: string;\n /** The cast as written, used to remember a rejected cast across rounds. */\n key: string;\n}\n\nconst MAX_ROUNDS = 50;\n/** How many times the new errors are used to name culprits before the rest is halved. */\nconst MAX_NAMED_ATTEMPTS = 8;\n/** A file that can hold a cast: `as`, or an angle-bracket assertion. */\nconst CAST_TEXT = /\\bas\\b|<[A-Za-z_$][^<>]*>\\s*[A-Za-z_$(]/;\nconst TEST_FILE_PATTERN = /(?:^|\\/)__tests__\\/|\\.(?:test|spec)\\.[cm]?tsx?$/;\n\n/**\n * The compiler's own view of a package, with the text of some files replaced in memory. It uses the\n * compiler's incremental builder: a check after an edit revisits only the files whose exported types\n * changed and the files that import them, and the parsed files are kept between checks.\n */\nclass TypecheckSession {\n private readonly parsed = new Map<string, ts.SourceFile>();\n private readonly disk = new Map<string, string | undefined>();\n private reference: ts.SemanticDiagnosticsBuilderProgram | undefined;\n private program: ts.Program | undefined;\n checks = 0;\n\n constructor(\n private readonly typescript: TTypeScript,\n private readonly options: ts.CompilerOptions,\n private readonly rootNames: string[],\n private readonly root: string,\n ) {}\n\n /**\n * Typechecks the package with `texts` replacing the files on disk and returns the errors as a count\n * per message key. With `asReference`, the result becomes the state later checks are measured from.\n */\n check(texts: Map<string, string>, opts: { asReference?: boolean } = {}): IDiagnosticReport {\n const { typescript, options, rootNames } = this;\n const host = typescript.createCompilerHost(options, true);\n\n host.getSourceFile = (fileName, languageVersionOrOptions) => {\n const key = resolve(fileName);\n let source = texts.get(key);\n if (source === undefined) {\n if (!this.disk.has(key)) {\n this.disk.set(key, typescript.sys.readFile(fileName));\n }\n source = this.disk.get(key);\n }\n\n if (source === undefined) {\n return undefined;\n }\n\n const version = typescript.sys.createHash?.(source) ?? `${source.length}`;\n const cacheKey = `${key}\\0${version}`;\n const cached = this.parsed.get(cacheKey);\n if (cached) {\n return cached;\n }\n\n const sourceFile = typescript.createSourceFile(\n fileName,\n source,\n languageVersionOrOptions,\n true,\n );\n // The builder reads a file's version to tell a changed file from an unchanged one; the type leaves it out.\n Object.assign(sourceFile, { version });\n this.parsed.set(cacheKey, sourceFile);\n return sourceFile;\n };\n\n const builder = typescript.createSemanticDiagnosticsBuilderProgram(\n rootNames,\n options,\n host,\n this.reference,\n );\n this.program = builder.getProgram();\n this.checks += 1;\n\n if (opts.asReference) {\n this.reference = builder;\n }\n\n const counts = new Map<string, number>();\n const items: IFoundError[] = [];\n const diagnostics = [\n ...builder.getOptionsDiagnostics(),\n ...builder.getGlobalDiagnostics(),\n ...builder.getSyntacticDiagnostics(),\n ...builder.getSemanticDiagnostics(),\n ];\n for (const diagnostic of diagnostics) {\n if (diagnostic.category !== typescript.DiagnosticCategory.Error) {\n continue;\n }\n\n const where = diagnostic.file ? relative(this.root, diagnostic.file.fileName) : '';\n const message = typescript.flattenDiagnosticMessageText(diagnostic.messageText, '\\n');\n const key = `${where}|${diagnostic.code}|${message}`;\n counts.set(key, (counts.get(key) ?? 0) + 1);\n items.push({\n key,\n file: diagnostic.file ? resolve(diagnostic.file.fileName) : '',\n start: diagnostic.start ?? 0,\n });\n }\n\n return { counts, items };\n }\n\n getProgram(): ts.Program {\n if (!this.program) {\n // eslint-disable-next-line venizia/no-new-error -- getError would be a dev-configs -> inversion cycle\n throw new Error('[TypecheckSession][getProgram] check() has not run yet');\n }\n\n return this.program;\n }\n}\n\n/**\n * Removes the `as X` casts a package no longer needs. Every removal of a package is tried together\n * in memory and compared with the errors the package had before; when new errors appear, the\n * candidates are halved until the ones that break the typecheck are found, so the cost is a handful\n * of checks, not one per cast.\n */\nexport class RedundantCasts {\n /** The casts of one project: which are removed, which stay and why. */\n static run(opts: {\n typescript: TTypeScript;\n tsconfigPath: string;\n root: string;\n files: string[];\n includeTests?: boolean;\n }): IProjectCastResult {\n const { typescript, tsconfigPath, root, files, includeTests = false } = opts;\n const loaded = RedundantCasts.loadProject({ typescript, tsconfigPath });\n const session = new TypecheckSession(typescript, loaded.options, loaded.fileNames, root);\n const original = new Map<string, string>();\n const current = new Map<string, string>();\n const results = new Map<string, IFileCastResult>();\n const members = new Set(loaded.fileNames.map((name) => resolve(name)));\n\n for (const file of files.map((name) => resolve(name))) {\n if (!members.has(file)) {\n results.set(file, {\n file,\n output: readFileSync(file, 'utf8'),\n changed: false,\n removed: 0,\n importsRemoved: 0,\n kept: [{ line: 0, column: 0, reason: CastKeepReasons.NOT_IN_PROJECT }],\n });\n continue;\n }\n\n const text = readFileSync(file, 'utf8');\n original.set(file, text);\n current.set(file, text);\n }\n\n const baseline = session.check(new Map(), { asReference: true }).counts;\n const baselineErrors = [...baseline.values()].reduce((sum, count) => sum + count, 0);\n const rejected = new Set<string>();\n const removedPerFile = new Map<string, number>();\n\n /** The errors `texts` adds to what the package already had. */\n const newErrors = (texts: Map<string, string>): IFoundError[] => {\n const report = session.check(texts);\n const budget = new Map(baseline);\n const added: IFoundError[] = [];\n\n for (const item of report.items) {\n const left = budget.get(item.key) ?? 0;\n if (left > 0) {\n budget.set(item.key, left - 1);\n continue;\n }\n\n added.push(item);\n }\n\n return added;\n };\n const isBroken = (texts: Map<string, string>): boolean => newErrors(texts).length > 0;\n\n for (let round = 0; round < MAX_ROUNDS; round += 1) {\n session.check(current, { asReference: true });\n const candidates = RedundantCasts.collectCandidates({\n typescript,\n program: session.getProgram(),\n texts: current,\n includeTests,\n rejected,\n });\n\n if (candidates.length === 0) {\n break;\n }\n\n const accepted = RedundantCasts.search({\n candidates,\n base: [],\n newErrors: (chosen) => newErrors(RedundantCasts.apply({ texts: current, chosen })),\n suspectsOf: (chosen, found) =>\n RedundantCasts.suspectsOf({ typescript, program: session.getProgram(), chosen, found }),\n });\n const acceptedKeys = new Set(accepted);\n\n for (const candidate of candidates) {\n if (!acceptedKeys.has(candidate)) {\n rejected.add(`${candidate.file}|${candidate.key}`);\n }\n }\n\n for (const candidate of accepted) {\n removedPerFile.set(candidate.file, (removedPerFile.get(candidate.file) ?? 0) + 1);\n }\n\n const next = RedundantCasts.apply({ texts: current, chosen: accepted });\n for (const [file, text] of next) {\n current.set(file, text);\n }\n }\n\n const cleaned = RedundantCasts.dropUnusedImports({ typescript, original, current });\n const finalTexts = isBroken(cleaned.texts) ? current : cleaned.texts;\n const importsRemoved =\n finalTexts === cleaned.texts ? cleaned.removed : new Map<string, number>();\n\n session.check(finalTexts);\n const program = session.getProgram();\n for (const [file, text] of original) {\n const output = finalTexts.get(file) ?? text;\n const sourceFile = program.getSourceFile(file);\n const kept = sourceFile\n ? RedundantCasts.describeKept({\n typescript,\n sourceFile,\n checker: program.getTypeChecker(),\n includeTests,\n rejected,\n })\n : [];\n\n results.set(file, {\n file,\n output,\n changed: output !== text,\n removed: removedPerFile.get(file) ?? 0,\n importsRemoved: importsRemoved.get(file) ?? 0,\n kept,\n });\n }\n\n return { files: [...results.values()], checks: session.checks, baselineErrors };\n }\n\n private static loadProject(opts: { typescript: TTypeScript; tsconfigPath: string }) {\n const { typescript, tsconfigPath } = opts;\n const read = typescript.readConfigFile(tsconfigPath, typescript.sys.readFile);\n\n if (read.error) {\n // eslint-disable-next-line venizia/no-new-error -- getError would be a dev-configs -> inversion cycle\n throw new Error(\n `[loadProject] cannot read ${tsconfigPath} | ${typescript.flattenDiagnosticMessageText(read.error.messageText, '\\n')}`,\n );\n }\n\n const parsed = typescript.parseJsonConfigFileContent(\n read.config,\n typescript.sys,\n dirname(tsconfigPath),\n undefined,\n tsconfigPath,\n );\n\n return {\n fileNames: parsed.fileNames,\n options: {\n ...parsed.options,\n noEmit: true,\n incremental: false,\n composite: false,\n emitDeclarationOnly: false,\n declaration: false,\n declarationMap: false,\n tsBuildInfoFile: undefined,\n } satisfies ts.CompilerOptions,\n };\n }\n\n /**\n * Finds the casts worth trying: not `as const`, not a double cast, not a cast of `any` or\n * `unknown`, and not one already rejected. A cast inside another candidate waits for the next\n * round, so the edits of one round never overlap.\n */\n private static collectCandidates(opts: {\n typescript: TTypeScript;\n program: ts.Program;\n texts: Map<string, string>;\n includeTests: boolean;\n rejected: Set<string>;\n }): ICastCandidate[] {\n const { typescript, program, texts, includeTests, rejected } = opts;\n const checker = program.getTypeChecker();\n const found: ICastCandidate[] = [];\n\n for (const [file, text] of texts) {\n if (!includeTests && TEST_FILE_PATTERN.test(file)) {\n continue;\n }\n\n const sourceFile = program.getSourceFile(file);\n if (!sourceFile) {\n continue;\n }\n\n RedundantCasts.walkCasts({\n typescript,\n sourceFile,\n visit: (node) => {\n if (RedundantCasts.classify({ typescript, node, checker }) !== undefined) {\n return;\n }\n\n const inner = node.expression;\n const key = text.slice(node.getStart(sourceFile), node.end);\n if (rejected.has(`${file}|${key}`)) {\n return;\n }\n\n found.push({\n file,\n start: node.getStart(sourceFile),\n end: node.end,\n replacement: text.slice(inner.getStart(sourceFile), inner.end),\n key,\n });\n },\n });\n }\n\n found.sort((a, b) => a.file.localeCompare(b.file) || a.start - b.start || b.end - a.end);\n\n const outermost: ICastCandidate[] = [];\n let last: ICastCandidate | undefined;\n for (const candidate of found) {\n const isInside =\n last !== undefined &&\n last.file === candidate.file &&\n candidate.start >= last.start &&\n candidate.end <= last.end;\n if (isInside) {\n continue;\n }\n\n outermost.push(candidate);\n last = candidate;\n }\n\n return outermost;\n }\n\n /** The reason a cast is never tried, or `undefined` when it is worth trying. */\n private static classify(opts: {\n typescript: TTypeScript;\n node: ts.AsExpression | ts.TypeAssertion;\n checker: ts.TypeChecker;\n }): TCastKeepReason | undefined {\n const { typescript, node, checker } = opts;\n const target = node.type;\n\n if (\n typescript.isTypeReferenceNode(target) &&\n typescript.isIdentifier(target.typeName) &&\n target.typeName.text === 'const'\n ) {\n return CastKeepReasons.AS_CONST;\n }\n\n if (target.kind === typescript.SyntaxKind.UnknownKeyword) {\n return CastKeepReasons.UNKNOWN_TARGET;\n }\n\n let inner: ts.Expression = node.expression;\n while (typescript.isParenthesizedExpression(inner)) {\n inner = inner.expression;\n }\n\n if (typescript.isAsExpression(inner) || typescript.isTypeAssertionExpression(inner)) {\n return CastKeepReasons.DOUBLE_CAST;\n }\n\n const flags = checker.getTypeAtLocation(node.expression).flags;\n if (flags & typescript.TypeFlags.Any) {\n return CastKeepReasons.ANY_EXPRESSION;\n }\n\n if (flags & typescript.TypeFlags.Unknown) {\n return CastKeepReasons.UNKNOWN_EXPRESSION;\n }\n\n return undefined;\n }\n\n private static walkCasts(opts: {\n typescript: TTypeScript;\n sourceFile: ts.SourceFile;\n visit: (node: ts.AsExpression | ts.TypeAssertion) => void;\n }): void {\n const { typescript, sourceFile, visit } = opts;\n const walk = (node: ts.Node): void => {\n if (typescript.isAsExpression(node) || typescript.isTypeAssertionExpression(node)) {\n visit(node);\n }\n\n typescript.forEachChild(node, walk);\n };\n\n walk(sourceFile);\n }\n\n /** The casts that remain in a file, each with the reason it stayed. */\n private static describeKept(opts: {\n typescript: TTypeScript;\n sourceFile: ts.SourceFile;\n checker: ts.TypeChecker;\n includeTests: boolean;\n rejected: Set<string>;\n }): IKeptCast[] {\n const { typescript, sourceFile, checker, includeTests, rejected } = opts;\n const kept: IKeptCast[] = [];\n const isTest = TEST_FILE_PATTERN.test(sourceFile.fileName);\n\n RedundantCasts.walkCasts({\n typescript,\n sourceFile,\n visit: (node) => {\n const { line, character } = sourceFile.getLineAndCharacterOfPosition(\n node.getStart(sourceFile),\n );\n const text = sourceFile.text.slice(node.getStart(sourceFile), node.end);\n const reason =\n (isTest && !includeTests ? CastKeepReasons.TEST_FILE : undefined) ??\n RedundantCasts.classify({ typescript, node, checker }) ??\n (rejected.has(`${resolve(sourceFile.fileName)}|${text}`)\n ? CastKeepReasons.NEEDED\n : undefined);\n\n if (reason !== undefined) {\n kept.push({ line: line + 1, column: character + 1, reason });\n }\n },\n });\n\n return kept;\n }\n\n /**\n * The candidates whose removal, together with `base`, adds no error. When a try fails, the places\n * of the new errors name the casts most likely to blame; those are set aside and the rest is tried\n * again. What cannot be named is halved until the breaking casts stand alone. Whatever is accepted\n * was checked together with everything else accepted, so a wrong guess can only keep a cast.\n */\n private static search(opts: {\n candidates: ICastCandidate[];\n base: ICastCandidate[];\n newErrors: (chosen: ICastCandidate[]) => IFoundError[];\n suspectsOf: (chosen: ICastCandidate[], found: IFoundError[]) => ICastCandidate[];\n }): ICastCandidate[] {\n const { base, newErrors, suspectsOf } = opts;\n let remaining = [...opts.candidates];\n\n for (let attempt = 0; attempt < MAX_NAMED_ATTEMPTS && remaining.length > 0; attempt += 1) {\n const chosen = [...base, ...remaining];\n const found = newErrors(chosen);\n if (found.length === 0) {\n return remaining;\n }\n\n const suspects = suspectsOf(chosen, found);\n if (suspects.length === 0) {\n break;\n }\n\n const named = new Set(suspects);\n remaining = remaining.filter((candidate) => !named.has(candidate));\n }\n\n return RedundantCasts.halve({ candidates: remaining, base, newErrors });\n }\n\n private static halve(opts: {\n candidates: ICastCandidate[];\n base: ICastCandidate[];\n newErrors: (chosen: ICastCandidate[]) => IFoundError[];\n }): ICastCandidate[] {\n const { candidates, base, newErrors } = opts;\n\n if (candidates.length === 0) {\n return [];\n }\n\n if (newErrors([...base, ...candidates]).length === 0) {\n return candidates;\n }\n\n if (candidates.length === 1) {\n return [];\n }\n\n const middle = Math.ceil(candidates.length / 2);\n const first = RedundantCasts.halve({\n candidates: candidates.slice(0, middle),\n base,\n newErrors,\n });\n const second = RedundantCasts.halve({\n candidates: candidates.slice(middle),\n base: [...base, ...first],\n newErrors,\n });\n\n return [...first, ...second];\n }\n\n /**\n * The casts a set of new errors most likely comes from: for each error, the chosen cast nearest to\n * it inside the same statement, else the nearest one before it in the same file. An error in a file\n * with no chosen cast (an importer) names nothing; the halving deals with what stays.\n */\n private static suspectsOf(opts: {\n typescript: TTypeScript;\n program: ts.Program;\n chosen: ICastCandidate[];\n found: IFoundError[];\n }): ICastCandidate[] {\n const { typescript, program, chosen, found } = opts;\n const suspects = new Set<ICastCandidate>();\n\n for (const error of found) {\n const inFile = chosen\n .filter((candidate) => candidate.file === error.file)\n .sort((a, b) => a.start - b.start);\n const sourceFile = program.getSourceFile(error.file);\n if (inFile.length === 0 || !sourceFile) {\n continue;\n }\n\n let shift = 0;\n const placed = inFile.map((candidate) => {\n const start = candidate.start - shift;\n shift += candidate.end - candidate.start - candidate.replacement.length;\n return { candidate, start, end: start + candidate.replacement.length };\n });\n const statement = RedundantCasts.enclosingStatement({\n typescript,\n sourceFile,\n position: error.start,\n });\n const distance = (item: { start: number; end: number }) =>\n error.start < item.start\n ? item.start - error.start\n : error.start > item.end\n ? error.start - item.end\n : 0;\n const inside = placed.filter(\n (item) => statement && item.start >= statement.pos && item.end <= statement.end,\n );\n const before = placed.filter((item) => item.start <= error.start);\n const pool = inside.length > 0 ? inside : before;\n const nearest = [...pool].sort((a, b) => distance(a) - distance(b))[0];\n\n if (nearest) {\n suspects.add(nearest.candidate);\n }\n }\n\n return [...suspects];\n }\n\n /** The smallest statement that holds `position`. */\n private static enclosingStatement(opts: {\n typescript: TTypeScript;\n sourceFile: ts.SourceFile;\n position: number;\n }): ts.Node | undefined {\n const { typescript, sourceFile, position } = opts;\n let found: ts.Node | undefined;\n\n const walk = (node: ts.Node): void => {\n if (position < node.pos || position >= node.end) {\n return;\n }\n\n const parent = node.parent;\n const isStatement =\n parent !== undefined &&\n (typescript.isSourceFile(parent) ||\n typescript.isBlock(parent) ||\n typescript.isModuleBlock(parent) ||\n typescript.isCaseClause(parent) ||\n typescript.isDefaultClause(parent));\n if (isStatement) {\n found = node;\n }\n\n typescript.forEachChild(node, walk);\n };\n\n walk(sourceFile);\n return found;\n }\n\n /** The texts with `chosen` removed, each file edited from the end so earlier offsets stay valid. */\n private static apply(opts: {\n texts: Map<string, string>;\n chosen: ICastCandidate[];\n }): Map<string, string> {\n const { texts, chosen } = opts;\n const output = new Map(texts);\n const byFile = new Map<string, ICastCandidate[]>();\n\n for (const candidate of chosen) {\n byFile.set(candidate.file, [...(byFile.get(candidate.file) ?? []), candidate]);\n }\n\n for (const [file, edits] of byFile) {\n let text = output.get(file) ?? '';\n for (const edit of [...edits].sort((a, b) => b.start - a.start)) {\n text = text.slice(0, edit.start) + edit.replacement + text.slice(edit.end);\n }\n\n output.set(file, text);\n }\n\n return output;\n }\n\n /** Removes a named import the removals left unused; an import that was already unused is left alone. */\n private static dropUnusedImports(opts: {\n typescript: TTypeScript;\n original: Map<string, string>;\n current: Map<string, string>;\n }): { texts: Map<string, string>; removed: Map<string, number> } {\n const { typescript, original, current } = opts;\n const texts = new Map(current);\n const removed = new Map<string, number>();\n\n for (const [file, after] of current) {\n const before = original.get(file);\n if (before === undefined || before === after) {\n continue;\n }\n\n const usedBefore = RedundantCasts.identifiersOutsideImports({\n typescript,\n text: before,\n file,\n });\n const usedAfter = RedundantCasts.identifiersOutsideImports({ typescript, text: after, file });\n const sourceFile = typescript.createSourceFile(\n file,\n after,\n typescript.ScriptTarget.Latest,\n true,\n );\n const edits: Array<{ start: number; end: number; text: string }> = [];\n let count = 0;\n\n for (const statement of sourceFile.statements) {\n if (!typescript.isImportDeclaration(statement)) {\n continue;\n }\n\n const clause = statement.importClause;\n const bindings = clause?.namedBindings;\n if (!clause || !bindings || !typescript.isNamedImports(bindings)) {\n continue;\n }\n\n const stale = bindings.elements.filter(\n (element) => usedBefore.has(element.name.text) && !usedAfter.has(element.name.text),\n );\n if (stale.length === 0) {\n continue;\n }\n\n count += stale.length;\n const remaining = bindings.elements.filter((element) => !stale.includes(element));\n const start = statement.getStart(sourceFile);\n\n if (remaining.length === 0 && !clause.name) {\n const lineEnd = after.indexOf('\\n', statement.end);\n edits.push({ start, end: lineEnd === -1 ? statement.end : lineEnd + 1, text: '' });\n continue;\n }\n\n const typeKeyword = clause.isTypeOnly ? 'type ' : '';\n const names = remaining.map((element) =>\n after.slice(element.getStart(sourceFile), element.end),\n );\n const head = clause.name ? `${clause.name.text}${names.length > 0 ? ', ' : ''}` : '';\n const named = names.length > 0 ? `{ ${names.join(', ')} }` : '';\n const from = after.slice(statement.moduleSpecifier.getStart(sourceFile), statement.end);\n edits.push({\n start,\n end: statement.end,\n text: `import ${typeKeyword}${head}${named} from ${from}`,\n });\n }\n\n if (edits.length === 0) {\n continue;\n }\n\n let text = after;\n for (const edit of edits.sort((a, b) => b.start - a.start)) {\n text = text.slice(0, edit.start) + edit.text + text.slice(edit.end);\n }\n\n texts.set(file, text);\n removed.set(file, count);\n }\n\n return { texts, removed };\n }\n\n /** Every identifier text outside the import declarations: a name that appears here is in use. */\n private static identifiersOutsideImports(opts: {\n typescript: TTypeScript;\n text: string;\n file: string;\n }): Set<string> {\n const { typescript, text, file } = opts;\n const sourceFile = typescript.createSourceFile(\n file,\n text,\n typescript.ScriptTarget.Latest,\n true,\n );\n const names = new Set<string>();\n const walk = (node: ts.Node): void => {\n if (typescript.isImportDeclaration(node)) {\n return;\n }\n\n if (typescript.isIdentifier(node)) {\n names.add(node.text);\n }\n\n typescript.forEachChild(node, walk);\n };\n\n walk(sourceFile);\n return names;\n }\n\n /** The nearest `tsconfig.json` at or above `file`, stopping at `root`. */\n static findTsconfig(opts: { file: string; root: string }): string | undefined {\n const { root } = opts;\n let directory = dirname(resolve(opts.file));\n const top = resolve(root);\n\n for (;;) {\n const candidate = join(directory, 'tsconfig.json');\n if (existsSync(candidate)) {\n return candidate;\n }\n\n const parent = dirname(directory);\n if (directory === top || parent === directory) {\n return undefined;\n }\n\n directory = parent;\n }\n }\n}\n\nconst 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.`;\n\n/** A usage error: nothing was read or written. */\nconst USAGE_ERROR_CODE = 2;\n\nclass CastFlags {\n static readonly WRITE = '--write';\n static readonly CHECK = '--check';\n static readonly PROJECT = '--project';\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.PROJECT,\n this.INCLUDE_TESTS,\n this.HELP,\n this.HELP_SHORT,\n ]);\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n}\n\n/** `devz codemod drop-redundant-casts [paths...] [--write | --check]`. */\nexport class DropRedundantCastsCommand {\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(CastFlags.HELP) || args.includes(CastFlags.HELP_SHORT)) {\n console.log(USAGE);\n return 0;\n }\n\n const flags: string[] = [];\n const paths: string[] = [];\n let project: string | undefined;\n\n for (let index = 0; index < args.length; index += 1) {\n const argument = args[index] ?? '';\n\n if (argument === CastFlags.PROJECT) {\n project = args[index + 1];\n index += 1;\n if (!project || project.startsWith('-')) {\n console.error(`devz codemod: ${CastFlags.PROJECT} needs a tsconfig path\\n${USAGE}`);\n return USAGE_ERROR_CODE;\n }\n continue;\n }\n\n if (argument.startsWith(`${CastFlags.PROJECT}=`)) {\n project = argument.slice(CastFlags.PROJECT.length + 1);\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) => !CastFlags.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(CastFlags.WRITE);\n const isCheck = flags.includes(CastFlags.CHECK);\n const includeTests = flags.includes(CastFlags.INCLUDE_TESTS);\n\n if (isWrite && isCheck) {\n console.error(\n `devz codemod: ${CastFlags.WRITE} and ${CastFlags.CHECK} contradict each other\\n${USAGE}`,\n );\n return USAGE_ERROR_CODE;\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 check your sources');\n return 1;\n }\n\n const targets = (paths.length > 0 ? paths : ['.']).map((path) => resolve(root, path));\n const byProject = new Map<string, string[]>();\n\n for (const target of targets) {\n const collected = CodemodFiles.collect({ target });\n\n if (collected.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 collected) {\n if (!CAST_TEXT.test(readFileSync(file, 'utf8'))) {\n continue;\n }\n\n const tsconfig = project\n ? resolve(root, project)\n : RedundantCasts.findTsconfig({ file, root });\n\n if (!tsconfig) {\n console.warn(`${relative(root, file)} no tsconfig.json at or above this file; skipped`);\n continue;\n }\n\n byProject.set(tsconfig, [...(byProject.get(tsconfig) ?? []), file]);\n }\n }\n\n let removed = 0;\n let kept = 0;\n let importsRemoved = 0;\n let changedFiles = 0;\n const reasons = new Map<string, number>();\n const verb = isWrite ? 'removed' : 'would remove';\n\n for (const [tsconfig, files] of byProject) {\n let result: IProjectCastResult;\n try {\n result = RedundantCasts.run({\n typescript,\n tsconfigPath: tsconfig,\n root,\n files,\n includeTests,\n });\n } catch (error) {\n console.error(\n `devz codemod: ${relative(root, tsconfig)}: ${error instanceof Error ? error.message : String(error)}`,\n );\n return 1;\n }\n\n console.log(\n `${relative(root, tsconfig)}: ${files.length} file(s) read, typechecked ${result.checks} time(s)` +\n (result.baselineErrors > 0\n ? `, ${result.baselineErrors} error(s) were there before and are ignored`\n : ''),\n );\n\n for (const file of result.files) {\n removed += file.removed;\n importsRemoved += file.importsRemoved;\n kept += file.kept.length;\n for (const entry of file.kept) {\n reasons.set(entry.reason, (reasons.get(entry.reason) ?? 0) + 1);\n }\n\n if (file.removed === 0 && file.kept.length === 0) {\n continue;\n }\n\n const shown = relative(root, file.file);\n const detail = [...new Set(file.kept.map((entry) => entry.reason))]\n .map(\n (reason) => `${file.kept.filter((entry) => entry.reason === reason).length} ${reason}`,\n )\n .join(', ');\n console.log(\n `${file.removed > 0 ? verb : 'unchanged'} ${shown} (${file.removed} removed, ${file.kept.length} kept${detail ? `: ${detail}` : ''}${file.importsRemoved > 0 ? `, ${file.importsRemoved} import(s) dropped` : ''})`,\n );\n\n if (file.changed) {\n changedFiles += 1;\n if (isWrite) {\n writeFileSync(file.file, file.output);\n }\n }\n }\n }\n\n console.log(\n `devz codemod drop-redundant-casts: ${removed} cast(s) ${isWrite ? 'removed' : 'would be removed'} in ${changedFiles} file(s), ${kept} kept` +\n (reasons.size > 0\n ? ` (${[...reasons].map(([reason, count]) => `${count} ${reason}`).join(', ')})`\n : '') +\n (importsRemoved > 0 ? `, ${importsRemoved} unused import(s) dropped` : ''),\n );\n\n if (!isWrite && changedFiles > 0) {\n console.log(\n `Nothing was written. Run again with ${CastFlags.WRITE} to apply, then run your typecheck.`,\n );\n }\n\n return isCheck && removed > 0 ? 1 : 0;\n }\n}\n"]}
1
+ {"version":3,"file":"drop-redundant-casts.js","sourceRoot":"","sources":["../../../src/cli/codemod/drop-redundant-casts.ts"],"names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T,uCAAuC,SAAS,CAAC,KAAK,qCAAqC,CAC5F,CAAC;QACJ,CAAC;QAED,OAAO,OAAO,IAAI,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACxC,CAAC;;AA1LH,8DA2LC","sourcesContent":["import { existsSync, readFileSync, writeFileSync } from 'node:fs';\nimport { dirname, join, relative, resolve } from 'node:path';\nimport type ts from 'typescript';\nimport type { TConstValue } from '../../linters/rules/common';\nimport { CodemodFiles } from './files';\n\ntype TTypeScript = typeof ts;\n\n/** Why a cast is still there after the codemod ran. */\nexport class CastKeepReasons {\n /** Taking it out makes the package fail its typecheck. */\n static readonly NEEDED = 'needed';\n /** `as const` is a narrowing the codemod never touches. */\n static readonly AS_CONST = 'as-const';\n /** `x as unknown as T`: a deliberate escape that only a person can judge. */\n static readonly DOUBLE_CAST = 'double-cast';\n /** `x as unknown` widens on purpose. */\n static readonly UNKNOWN_TARGET = 'unknown-target';\n /** The expression is `any`: the cast is the only type it has, so it is not redundant. */\n static readonly ANY_EXPRESSION = 'any-expression';\n /** The expression is `unknown`: the cast is the only type it has. */\n static readonly UNKNOWN_EXPRESSION = 'unknown-expression';\n /** Test files are skipped unless `--include-tests` is given. */\n static readonly TEST_FILE = 'test-file';\n /** The file is not part of the package's tsconfig, so nothing can check it. */\n static readonly NOT_IN_PROJECT = 'not-in-project';\n\n static readonly SCHEME_SET = new Set<string>([\n this.NEEDED,\n this.AS_CONST,\n this.DOUBLE_CAST,\n this.UNKNOWN_TARGET,\n this.ANY_EXPRESSION,\n this.UNKNOWN_EXPRESSION,\n this.TEST_FILE,\n this.NOT_IN_PROJECT,\n ]);\n\n static isValid(value: string): value is TCastKeepReason {\n return this.SCHEME_SET.has(value);\n }\n}\n\nexport type TCastKeepReason = TConstValue<typeof CastKeepReasons>;\n\nexport interface IKeptCast {\n /** Line and column in the output text (the file after the removals). */\n line: number;\n column: number;\n reason: TCastKeepReason;\n}\n\nexport interface IFileCastResult {\n file: string;\n /** The file text after the removals and the imports they left unused. */\n output: string;\n changed: boolean;\n removed: number;\n importsRemoved: number;\n kept: IKeptCast[];\n}\n\nexport interface IProjectCastResult {\n files: IFileCastResult[];\n /** How many times the package was typechecked (the baseline run included). */\n checks: number;\n /** Errors the package already had before any removal; they are not counted against a removal. */\n baselineErrors: number;\n}\n\n/** One error of a check: its message key (file, code, text) and where it points. */\ninterface IFoundError {\n key: string;\n file: string;\n start: number;\n}\n\ninterface IDiagnosticReport {\n counts: Map<string, number>;\n items: IFoundError[];\n}\n\ninterface ICastCandidate {\n file: string;\n start: number;\n end: number;\n replacement: string;\n /** The cast as written, used to remember a rejected cast across rounds. */\n key: string;\n}\n\nconst MAX_ROUNDS = 50;\n/** How many times the new errors are used to name culprits before the rest is halved. */\nconst MAX_NAMED_ATTEMPTS = 8;\n/** A file that can hold a cast: `as`, or an angle-bracket assertion. */\nconst CAST_TEXT = /\\bas\\b|<[A-Za-z_$][^<>]*>\\s*[A-Za-z_$(]/;\nconst TEST_FILE_PATTERN = /(?:^|\\/)__tests__\\/|\\.(?:test|spec)\\.[cm]?tsx?$/;\n\n/**\n * The compiler's own view of a package, with the text of some files replaced in memory. It uses the\n * compiler's incremental builder: a check after an edit revisits only the files whose exported types\n * changed and the files that import them, and the parsed files are kept between checks.\n */\nclass TypecheckSession {\n private readonly parsed = new Map<string, ts.SourceFile>();\n private readonly disk = new Map<string, string | undefined>();\n private reference: ts.SemanticDiagnosticsBuilderProgram | undefined;\n private program: ts.Program | undefined;\n checks = 0;\n\n constructor(\n private readonly typescript: TTypeScript,\n private readonly options: ts.CompilerOptions,\n private readonly rootNames: string[],\n private readonly root: string,\n ) {}\n\n /**\n * Typechecks the package with `texts` replacing the files on disk and returns the errors as a count\n * per message key. With `asReference`, the result becomes the state later checks are measured from.\n */\n check(texts: Map<string, string>, opts: { asReference?: boolean } = {}): IDiagnosticReport {\n const { typescript, options, rootNames } = this;\n const host = typescript.createCompilerHost(options, true);\n\n host.getSourceFile = (fileName, languageVersionOrOptions) => {\n const key = resolve(fileName);\n let source = texts.get(key);\n if (source === undefined) {\n if (!this.disk.has(key)) {\n this.disk.set(key, typescript.sys.readFile(fileName));\n }\n source = this.disk.get(key);\n }\n\n if (source === undefined) {\n return undefined;\n }\n\n const version = typescript.sys.createHash?.(source) ?? `${source.length}`;\n const cacheKey = `${key}\\0${version}`;\n const cached = this.parsed.get(cacheKey);\n if (cached) {\n return cached;\n }\n\n const sourceFile = typescript.createSourceFile(\n fileName,\n source,\n languageVersionOrOptions,\n true,\n );\n // The builder reads a file's version to tell a changed file from an unchanged one; the type leaves it out.\n Object.assign(sourceFile, { version });\n this.parsed.set(cacheKey, sourceFile);\n return sourceFile;\n };\n\n const builder = typescript.createSemanticDiagnosticsBuilderProgram(\n rootNames,\n options,\n host,\n this.reference,\n );\n this.program = builder.getProgram();\n this.checks += 1;\n\n if (opts.asReference) {\n this.reference = builder;\n }\n\n const counts = new Map<string, number>();\n const items: IFoundError[] = [];\n const diagnostics = [\n ...builder.getOptionsDiagnostics(),\n ...builder.getGlobalDiagnostics(),\n ...builder.getSyntacticDiagnostics(),\n ...builder.getSemanticDiagnostics(),\n ];\n for (const diagnostic of diagnostics) {\n if (diagnostic.category !== typescript.DiagnosticCategory.Error) {\n continue;\n }\n\n const where = diagnostic.file ? relative(this.root, diagnostic.file.fileName) : '';\n const message = typescript.flattenDiagnosticMessageText(diagnostic.messageText, '\\n');\n const key = `${where}|${diagnostic.code}|${message}`;\n counts.set(key, (counts.get(key) ?? 0) + 1);\n items.push({\n key,\n file: diagnostic.file ? resolve(diagnostic.file.fileName) : '',\n start: diagnostic.start ?? 0,\n });\n }\n\n return { counts, items };\n }\n\n getProgram(): ts.Program {\n if (!this.program) {\n // eslint-disable-next-line venizia/no-new-error -- getError would be a dev-configs -> inversion cycle\n throw new Error('[TypecheckSession][getProgram] check() has not run yet');\n }\n\n return this.program;\n }\n}\n\n/**\n * Removes the `as X` casts a package no longer needs. Every removal of a package is tried together\n * in memory and compared with the errors the package had before; when new errors appear, the\n * candidates are halved until the ones that break the typecheck are found, so the cost is a handful\n * of checks, not one per cast.\n */\nexport class RedundantCasts {\n /** The casts of one project: which are removed, which stay and why. */\n static run(opts: {\n typescript: TTypeScript;\n tsconfigPath: string;\n root: string;\n files: string[];\n includeTests?: boolean;\n }): IProjectCastResult {\n const { typescript, tsconfigPath, root, files, includeTests = false } = opts;\n const loaded = RedundantCasts.loadProject({ typescript, tsconfigPath });\n const session = new TypecheckSession(typescript, loaded.options, loaded.fileNames, root);\n const original = new Map<string, string>();\n const current = new Map<string, string>();\n const results = new Map<string, IFileCastResult>();\n const members = new Set(loaded.fileNames.map((name) => resolve(name)));\n\n for (const file of files.map((name) => resolve(name))) {\n if (!members.has(file)) {\n results.set(file, {\n file,\n output: readFileSync(file, 'utf8'),\n changed: false,\n removed: 0,\n importsRemoved: 0,\n kept: [{ line: 0, column: 0, reason: CastKeepReasons.NOT_IN_PROJECT }],\n });\n continue;\n }\n\n const text = readFileSync(file, 'utf8');\n original.set(file, text);\n current.set(file, text);\n }\n\n const baseline = session.check(new Map(), { asReference: true }).counts;\n const baselineErrors = [...baseline.values()].reduce((sum, count) => sum + count, 0);\n const rejected = new Set<string>();\n const removedPerFile = new Map<string, number>();\n\n /** The errors `texts` adds to what the package already had. */\n const newErrors = (texts: Map<string, string>): IFoundError[] => {\n const report = session.check(texts);\n const budget = new Map(baseline);\n const added: IFoundError[] = [];\n\n for (const item of report.items) {\n const left = budget.get(item.key) ?? 0;\n if (left > 0) {\n budget.set(item.key, left - 1);\n continue;\n }\n\n added.push(item);\n }\n\n return added;\n };\n const isBroken = (texts: Map<string, string>): boolean => newErrors(texts).length > 0;\n\n for (let round = 0; round < MAX_ROUNDS; round += 1) {\n session.check(current, { asReference: true });\n const candidates = RedundantCasts.collectCandidates({\n typescript,\n program: session.getProgram(),\n texts: current,\n includeTests,\n rejected,\n });\n\n if (candidates.length === 0) {\n break;\n }\n\n const accepted = RedundantCasts.search({\n candidates,\n base: [],\n newErrors: (chosen) => newErrors(RedundantCasts.apply({ texts: current, chosen })),\n suspectsOf: (chosen, found) =>\n RedundantCasts.suspectsOf({ typescript, program: session.getProgram(), chosen, found }),\n });\n const acceptedKeys = new Set(accepted);\n\n for (const candidate of candidates) {\n if (!acceptedKeys.has(candidate)) {\n rejected.add(`${candidate.file}|${candidate.key}`);\n }\n }\n\n for (const candidate of accepted) {\n removedPerFile.set(candidate.file, (removedPerFile.get(candidate.file) ?? 0) + 1);\n }\n\n const next = RedundantCasts.apply({ texts: current, chosen: accepted });\n for (const [file, text] of next) {\n current.set(file, text);\n }\n }\n\n const cleaned = RedundantCasts.dropUnusedImports({ typescript, original, current });\n const finalTexts = isBroken(cleaned.texts) ? current : cleaned.texts;\n const importsRemoved =\n finalTexts === cleaned.texts ? cleaned.removed : new Map<string, number>();\n\n session.check(finalTexts);\n const program = session.getProgram();\n for (const [file, text] of original) {\n const output = finalTexts.get(file) ?? text;\n const sourceFile = program.getSourceFile(file);\n const kept = sourceFile\n ? RedundantCasts.describeKept({\n typescript,\n sourceFile,\n checker: program.getTypeChecker(),\n includeTests,\n rejected,\n })\n : [];\n\n results.set(file, {\n file,\n output,\n changed: output !== text,\n removed: removedPerFile.get(file) ?? 0,\n importsRemoved: importsRemoved.get(file) ?? 0,\n kept,\n });\n }\n\n return { files: [...results.values()], checks: session.checks, baselineErrors };\n }\n\n private static loadProject(opts: { typescript: TTypeScript; tsconfigPath: string }) {\n const { typescript, tsconfigPath } = opts;\n const read = typescript.readConfigFile(tsconfigPath, typescript.sys.readFile);\n\n if (read.error) {\n // eslint-disable-next-line venizia/no-new-error -- getError would be a dev-configs -> inversion cycle\n throw new Error(\n `[loadProject] cannot read ${tsconfigPath} | ${typescript.flattenDiagnosticMessageText(read.error.messageText, '\\n')}`,\n );\n }\n\n const parsed = typescript.parseJsonConfigFileContent(\n read.config,\n typescript.sys,\n dirname(tsconfigPath),\n undefined,\n tsconfigPath,\n );\n\n return {\n fileNames: parsed.fileNames,\n options: {\n ...parsed.options,\n noEmit: true,\n incremental: false,\n composite: false,\n emitDeclarationOnly: false,\n declaration: false,\n declarationMap: false,\n tsBuildInfoFile: undefined,\n } satisfies ts.CompilerOptions,\n };\n }\n\n /**\n * Finds the casts worth trying: not `as const`, not a double cast, not a cast of `any` or\n * `unknown`, and not one already rejected. A cast inside another candidate waits for the next\n * round, so the edits of one round never overlap.\n */\n private static collectCandidates(opts: {\n typescript: TTypeScript;\n program: ts.Program;\n texts: Map<string, string>;\n includeTests: boolean;\n rejected: Set<string>;\n }): ICastCandidate[] {\n const { typescript, program, texts, includeTests, rejected } = opts;\n const checker = program.getTypeChecker();\n const found: ICastCandidate[] = [];\n\n for (const [file, text] of texts) {\n if (!includeTests && TEST_FILE_PATTERN.test(file)) {\n continue;\n }\n\n const sourceFile = program.getSourceFile(file);\n if (!sourceFile) {\n continue;\n }\n\n RedundantCasts.walkCasts({\n typescript,\n sourceFile,\n visit: (node) => {\n if (RedundantCasts.classify({ typescript, node, checker }) !== undefined) {\n return;\n }\n\n const inner = node.expression;\n const key = text.slice(node.getStart(sourceFile), node.end);\n if (rejected.has(`${file}|${key}`)) {\n return;\n }\n\n found.push({\n file,\n start: node.getStart(sourceFile),\n end: node.end,\n replacement: text.slice(inner.getStart(sourceFile), inner.end),\n key,\n });\n },\n });\n }\n\n found.sort((a, b) => a.file.localeCompare(b.file) || a.start - b.start || b.end - a.end);\n\n const outermost: ICastCandidate[] = [];\n let last: ICastCandidate | undefined;\n for (const candidate of found) {\n const isInside =\n last !== undefined &&\n last.file === candidate.file &&\n candidate.start >= last.start &&\n candidate.end <= last.end;\n if (isInside) {\n continue;\n }\n\n outermost.push(candidate);\n last = candidate;\n }\n\n return outermost;\n }\n\n /** The reason a cast is never tried, or `undefined` when it is worth trying. */\n private static classify(opts: {\n typescript: TTypeScript;\n node: ts.AsExpression | ts.TypeAssertion;\n checker: ts.TypeChecker;\n }): TCastKeepReason | undefined {\n const { typescript, node, checker } = opts;\n const target = node.type;\n\n if (\n typescript.isTypeReferenceNode(target) &&\n typescript.isIdentifier(target.typeName) &&\n target.typeName.text === 'const'\n ) {\n return CastKeepReasons.AS_CONST;\n }\n\n if (target.kind === typescript.SyntaxKind.UnknownKeyword) {\n return CastKeepReasons.UNKNOWN_TARGET;\n }\n\n let inner: ts.Expression = node.expression;\n while (typescript.isParenthesizedExpression(inner)) {\n inner = inner.expression;\n }\n\n if (typescript.isAsExpression(inner) || typescript.isTypeAssertionExpression(inner)) {\n return CastKeepReasons.DOUBLE_CAST;\n }\n\n const flags = checker.getTypeAtLocation(node.expression).flags;\n if (flags & typescript.TypeFlags.Any) {\n return CastKeepReasons.ANY_EXPRESSION;\n }\n\n if (flags & typescript.TypeFlags.Unknown) {\n return CastKeepReasons.UNKNOWN_EXPRESSION;\n }\n\n return undefined;\n }\n\n private static walkCasts(opts: {\n typescript: TTypeScript;\n sourceFile: ts.SourceFile;\n visit: (node: ts.AsExpression | ts.TypeAssertion) => void;\n }): void {\n const { typescript, sourceFile, visit } = opts;\n const walk = (node: ts.Node): void => {\n if (typescript.isAsExpression(node) || typescript.isTypeAssertionExpression(node)) {\n visit(node);\n }\n\n typescript.forEachChild(node, walk);\n };\n\n walk(sourceFile);\n }\n\n /** The casts that remain in a file, each with the reason it stayed. */\n private static describeKept(opts: {\n typescript: TTypeScript;\n sourceFile: ts.SourceFile;\n checker: ts.TypeChecker;\n includeTests: boolean;\n rejected: Set<string>;\n }): IKeptCast[] {\n const { typescript, sourceFile, checker, includeTests, rejected } = opts;\n const kept: IKeptCast[] = [];\n const isTest = TEST_FILE_PATTERN.test(sourceFile.fileName);\n\n RedundantCasts.walkCasts({\n typescript,\n sourceFile,\n visit: (node) => {\n const { line, character } = sourceFile.getLineAndCharacterOfPosition(\n node.getStart(sourceFile),\n );\n const text = sourceFile.text.slice(node.getStart(sourceFile), node.end);\n const reason =\n (isTest && !includeTests ? CastKeepReasons.TEST_FILE : undefined) ??\n RedundantCasts.classify({ typescript, node, checker }) ??\n (rejected.has(`${resolve(sourceFile.fileName)}|${text}`)\n ? CastKeepReasons.NEEDED\n : undefined);\n\n if (reason !== undefined) {\n kept.push({ line: line + 1, column: character + 1, reason });\n }\n },\n });\n\n return kept;\n }\n\n /**\n * The candidates whose removal, together with `base`, adds no error. When a try fails, the places\n * of the new errors name the casts most likely to blame; those are set aside and the rest is tried\n * again. What cannot be named is halved until the breaking casts stand alone. Whatever is accepted\n * was checked together with everything else accepted, so a wrong guess can only keep a cast.\n */\n private static search(opts: {\n candidates: ICastCandidate[];\n base: ICastCandidate[];\n newErrors: (chosen: ICastCandidate[]) => IFoundError[];\n suspectsOf: (chosen: ICastCandidate[], found: IFoundError[]) => ICastCandidate[];\n }): ICastCandidate[] {\n const { base, newErrors, suspectsOf } = opts;\n let remaining = [...opts.candidates];\n\n for (let attempt = 0; attempt < MAX_NAMED_ATTEMPTS && remaining.length > 0; attempt += 1) {\n const chosen = [...base, ...remaining];\n const found = newErrors(chosen);\n if (found.length === 0) {\n return remaining;\n }\n\n const suspects = suspectsOf(chosen, found);\n if (suspects.length === 0) {\n break;\n }\n\n const named = new Set(suspects);\n remaining = remaining.filter((candidate) => !named.has(candidate));\n }\n\n return RedundantCasts.halve({ candidates: remaining, base, newErrors });\n }\n\n private static halve(opts: {\n candidates: ICastCandidate[];\n base: ICastCandidate[];\n newErrors: (chosen: ICastCandidate[]) => IFoundError[];\n }): ICastCandidate[] {\n const { candidates, base, newErrors } = opts;\n\n if (candidates.length === 0) {\n return [];\n }\n\n if (newErrors([...base, ...candidates]).length === 0) {\n return candidates;\n }\n\n if (candidates.length === 1) {\n return [];\n }\n\n const middle = Math.ceil(candidates.length / 2);\n const first = RedundantCasts.halve({\n candidates: candidates.slice(0, middle),\n base,\n newErrors,\n });\n const second = RedundantCasts.halve({\n candidates: candidates.slice(middle),\n base: [...base, ...first],\n newErrors,\n });\n\n return [...first, ...second];\n }\n\n /**\n * The casts a set of new errors most likely comes from: for each error, the chosen cast nearest to\n * it inside the same statement, else the nearest one before it in the same file. An error in a file\n * with no chosen cast (an importer) names nothing; the halving deals with what stays.\n */\n private static suspectsOf(opts: {\n typescript: TTypeScript;\n program: ts.Program;\n chosen: ICastCandidate[];\n found: IFoundError[];\n }): ICastCandidate[] {\n const { typescript, program, chosen, found } = opts;\n const suspects = new Set<ICastCandidate>();\n\n for (const error of found) {\n const inFile = chosen\n .filter((candidate) => candidate.file === error.file)\n .sort((a, b) => a.start - b.start);\n const sourceFile = program.getSourceFile(error.file);\n if (inFile.length === 0 || !sourceFile) {\n continue;\n }\n\n let shift = 0;\n const placed = inFile.map((candidate) => {\n const start = candidate.start - shift;\n shift += candidate.end - candidate.start - candidate.replacement.length;\n return { candidate, start, end: start + candidate.replacement.length };\n });\n const statement = RedundantCasts.enclosingStatement({\n typescript,\n sourceFile,\n position: error.start,\n });\n const distance = (item: { start: number; end: number }) =>\n error.start < item.start\n ? item.start - error.start\n : error.start > item.end\n ? error.start - item.end\n : 0;\n const inside = placed.filter(\n (item) => statement && item.start >= statement.pos && item.end <= statement.end,\n );\n const before = placed.filter((item) => item.start <= error.start);\n const pool = inside.length > 0 ? inside : before;\n const nearest = [...pool].sort((a, b) => distance(a) - distance(b))[0];\n\n if (nearest) {\n suspects.add(nearest.candidate);\n }\n }\n\n return [...suspects];\n }\n\n /** The smallest statement that holds `position`. */\n private static enclosingStatement(opts: {\n typescript: TTypeScript;\n sourceFile: ts.SourceFile;\n position: number;\n }): ts.Node | undefined {\n const { typescript, sourceFile, position } = opts;\n let found: ts.Node | undefined;\n\n const walk = (node: ts.Node): void => {\n if (position < node.pos || position >= node.end) {\n return;\n }\n\n const parent = node.parent;\n const isStatement =\n parent !== undefined &&\n (typescript.isSourceFile(parent) ||\n typescript.isBlock(parent) ||\n typescript.isModuleBlock(parent) ||\n typescript.isCaseClause(parent) ||\n typescript.isDefaultClause(parent));\n if (isStatement) {\n found = node;\n }\n\n typescript.forEachChild(node, walk);\n };\n\n walk(sourceFile);\n return found;\n }\n\n /** The texts with `chosen` removed, each file edited from the end so earlier offsets stay valid. */\n private static apply(opts: {\n texts: Map<string, string>;\n chosen: ICastCandidate[];\n }): Map<string, string> {\n const { texts, chosen } = opts;\n const output = new Map(texts);\n const byFile = new Map<string, ICastCandidate[]>();\n\n for (const candidate of chosen) {\n byFile.set(candidate.file, [...(byFile.get(candidate.file) ?? []), candidate]);\n }\n\n for (const [file, edits] of byFile) {\n let text = output.get(file) ?? '';\n for (const edit of [...edits].sort((a, b) => b.start - a.start)) {\n text = text.slice(0, edit.start) + edit.replacement + text.slice(edit.end);\n }\n\n output.set(file, text);\n }\n\n return output;\n }\n\n /** Removes a named import the removals left unused; an import that was already unused is left alone. */\n private static dropUnusedImports(opts: {\n typescript: TTypeScript;\n original: Map<string, string>;\n current: Map<string, string>;\n }): { texts: Map<string, string>; removed: Map<string, number> } {\n const { typescript, original, current } = opts;\n const texts = new Map(current);\n const removed = new Map<string, number>();\n\n for (const [file, after] of current) {\n const before = original.get(file);\n if (before === undefined || before === after) {\n continue;\n }\n\n const usedBefore = RedundantCasts.identifiersOutsideImports({\n typescript,\n text: before,\n file,\n });\n const usedAfter = RedundantCasts.identifiersOutsideImports({ typescript, text: after, file });\n const sourceFile = typescript.createSourceFile(\n file,\n after,\n typescript.ScriptTarget.Latest,\n true,\n );\n const edits: Array<{ start: number; end: number; text: string }> = [];\n let count = 0;\n\n for (const statement of sourceFile.statements) {\n if (!typescript.isImportDeclaration(statement)) {\n continue;\n }\n\n const clause = statement.importClause;\n const bindings = clause?.namedBindings;\n if (!clause || !bindings || !typescript.isNamedImports(bindings)) {\n continue;\n }\n\n const stale = bindings.elements.filter(\n (element) => usedBefore.has(element.name.text) && !usedAfter.has(element.name.text),\n );\n if (stale.length === 0) {\n continue;\n }\n\n count += stale.length;\n const remaining = bindings.elements.filter((element) => !stale.includes(element));\n const start = statement.getStart(sourceFile);\n\n if (remaining.length === 0 && !clause.name) {\n const lineEnd = after.indexOf('\\n', statement.end);\n edits.push({ start, end: lineEnd === -1 ? statement.end : lineEnd + 1, text: '' });\n continue;\n }\n\n const typeKeyword = clause.isTypeOnly ? 'type ' : '';\n const names = remaining.map((element) =>\n after.slice(element.getStart(sourceFile), element.end),\n );\n const head = clause.name ? `${clause.name.text}${names.length > 0 ? ', ' : ''}` : '';\n const named = names.length > 0 ? `{ ${names.join(', ')} }` : '';\n const from = after.slice(statement.moduleSpecifier.getStart(sourceFile), statement.end);\n edits.push({\n start,\n end: statement.end,\n text: `import ${typeKeyword}${head}${named} from ${from}`,\n });\n }\n\n if (edits.length === 0) {\n continue;\n }\n\n let text = after;\n for (const edit of edits.sort((a, b) => b.start - a.start)) {\n text = text.slice(0, edit.start) + edit.text + text.slice(edit.end);\n }\n\n texts.set(file, text);\n removed.set(file, count);\n }\n\n return { texts, removed };\n }\n\n /** Every identifier text outside the import declarations: a name that appears here is in use. */\n private static identifiersOutsideImports(opts: {\n typescript: TTypeScript;\n text: string;\n file: string;\n }): Set<string> {\n const { typescript, text, file } = opts;\n const sourceFile = typescript.createSourceFile(\n file,\n text,\n typescript.ScriptTarget.Latest,\n true,\n );\n const names = new Set<string>();\n const walk = (node: ts.Node): void => {\n if (typescript.isImportDeclaration(node)) {\n return;\n }\n\n if (typescript.isIdentifier(node)) {\n names.add(node.text);\n }\n\n typescript.forEachChild(node, walk);\n };\n\n walk(sourceFile);\n return names;\n }\n\n /** The nearest `tsconfig.json` at or above `file`, stopping at `root`. */\n static findTsconfig(opts: { file: string; root: string }): string | undefined {\n const { root } = opts;\n let directory = dirname(resolve(opts.file));\n const top = resolve(root);\n\n for (;;) {\n const candidate = join(directory, 'tsconfig.json');\n if (existsSync(candidate)) {\n return candidate;\n }\n\n const parent = dirname(directory);\n if (directory === top || parent === directory) {\n return undefined;\n }\n\n directory = parent;\n }\n }\n}\n\nconst 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.`;\n\n/** A usage error: nothing was read or written. */\nconst USAGE_ERROR_CODE = 2;\n\nclass CastFlags {\n static readonly WRITE = '--write';\n static readonly CHECK = '--check';\n static readonly ALL = '--all';\n static readonly PROJECT = '--project';\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.PROJECT,\n this.INCLUDE_TESTS,\n this.HELP,\n this.HELP_SHORT,\n ]);\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n}\n\n/** `devz codemod drop-redundant-casts [paths...] [--write | --check]`. */\nexport class DropRedundantCastsCommand {\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(CastFlags.HELP) || args.includes(CastFlags.HELP_SHORT)) {\n console.log(USAGE);\n return 0;\n }\n\n const flags: string[] = [];\n const paths: string[] = [];\n let project: string | undefined;\n\n for (let index = 0; index < args.length; index += 1) {\n const argument = args[index] ?? '';\n\n if (argument === CastFlags.PROJECT) {\n project = args[index + 1];\n index += 1;\n if (!project || project.startsWith('-')) {\n console.error(`devz codemod: ${CastFlags.PROJECT} needs a tsconfig path\\n${USAGE}`);\n return USAGE_ERROR_CODE;\n }\n continue;\n }\n\n if (argument.startsWith(`${CastFlags.PROJECT}=`)) {\n project = argument.slice(CastFlags.PROJECT.length + 1);\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) => !CastFlags.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(CastFlags.WRITE);\n const isCheck = flags.includes(CastFlags.CHECK);\n\n const refusal = CodemodFiles.refusal({\n command: 'drop-redundant-casts',\n isWrite,\n isAll: flags.includes(CastFlags.ALL),\n paths,\n });\n if (refusal) {\n console.error(`${refusal}\\n${USAGE}`);\n return USAGE_ERROR_CODE;\n }\n const includeTests = flags.includes(CastFlags.INCLUDE_TESTS);\n\n if (isWrite && isCheck) {\n console.error(\n `devz codemod: ${CastFlags.WRITE} and ${CastFlags.CHECK} contradict each other\\n${USAGE}`,\n );\n return USAGE_ERROR_CODE;\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 check your sources');\n return 1;\n }\n\n const targets = (paths.length > 0 ? paths : ['.']).map((path) => resolve(root, path));\n const byProject = new Map<string, string[]>();\n\n for (const target of targets) {\n const collected = CodemodFiles.collect({ target });\n\n if (collected.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 collected) {\n if (!CAST_TEXT.test(readFileSync(file, 'utf8'))) {\n continue;\n }\n\n const tsconfig = project\n ? resolve(root, project)\n : RedundantCasts.findTsconfig({ file, root });\n\n if (!tsconfig) {\n console.warn(`${relative(root, file)} no tsconfig.json at or above this file; skipped`);\n continue;\n }\n\n byProject.set(tsconfig, [...(byProject.get(tsconfig) ?? []), file]);\n }\n }\n\n let removed = 0;\n let kept = 0;\n let importsRemoved = 0;\n let changedFiles = 0;\n const reasons = new Map<string, number>();\n const verb = isWrite ? 'removed' : 'would remove';\n\n for (const [tsconfig, files] of byProject) {\n let result: IProjectCastResult;\n try {\n result = RedundantCasts.run({\n typescript,\n tsconfigPath: tsconfig,\n root,\n files,\n includeTests,\n });\n } catch (error) {\n console.error(\n `devz codemod: ${relative(root, tsconfig)}: ${error instanceof Error ? error.message : String(error)}`,\n );\n return 1;\n }\n\n console.log(\n `${relative(root, tsconfig)}: ${files.length} file(s) read, typechecked ${result.checks} time(s)` +\n (result.baselineErrors > 0\n ? `, ${result.baselineErrors} error(s) were there before and are ignored`\n : ''),\n );\n\n for (const file of result.files) {\n removed += file.removed;\n importsRemoved += file.importsRemoved;\n kept += file.kept.length;\n for (const entry of file.kept) {\n reasons.set(entry.reason, (reasons.get(entry.reason) ?? 0) + 1);\n }\n\n if (file.removed === 0 && file.kept.length === 0) {\n continue;\n }\n\n const shown = relative(root, file.file);\n const detail = [...new Set(file.kept.map((entry) => entry.reason))]\n .map(\n (reason) => `${file.kept.filter((entry) => entry.reason === reason).length} ${reason}`,\n )\n .join(', ');\n console.log(\n `${file.removed > 0 ? verb : 'unchanged'} ${shown} (${file.removed} removed, ${file.kept.length} kept${detail ? `: ${detail}` : ''}${file.importsRemoved > 0 ? `, ${file.importsRemoved} import(s) dropped` : ''})`,\n );\n\n if (file.changed) {\n changedFiles += 1;\n if (isWrite) {\n writeFileSync(file.file, file.output);\n }\n }\n }\n }\n\n console.log(\n `devz codemod drop-redundant-casts: ${removed} cast(s) ${isWrite ? 'removed' : 'would be removed'} in ${changedFiles} file(s), ${kept} kept` +\n (reasons.size > 0\n ? ` (${[...reasons].map(([reason, count]) => `${count} ${reason}`).join(', ')})`\n : '') +\n (importsRemoved > 0 ? `, ${importsRemoved} unused import(s) dropped` : ''),\n );\n\n if (!isWrite && changedFiles > 0) {\n console.log(\n `Nothing was written. Run again with ${CastFlags.WRITE} to apply, then run your typecheck.`,\n );\n }\n\n return isCheck && removed > 0 ? 1 : 0;\n }\n}\n"]}
@@ -9,6 +9,18 @@ export declare class CodemodFiles {
9
9
  static collect(opts: {
10
10
  target: string;
11
11
  }): string[];
12
+ /**
13
+ * Why a call must be refused, or `undefined` when it may go on. `--write` with no path rewrote every source
14
+ * file under the working directory, which is how one command typed without a path changed 134 clean files: a
15
+ * codemod that rewrites broadly needs a path or an explicit `--all`. A dry run (and `--check`) with no path still
16
+ * lists the whole tree.
17
+ */
18
+ static refusal(opts: {
19
+ command: string;
20
+ isWrite: boolean;
21
+ isAll: boolean;
22
+ paths: ReadonlyArray<string>;
23
+ }): string | undefined;
12
24
  /** Tracked files plus untracked files git does not ignore; `undefined` outside a repository or without git. */
13
25
  static fromGit(opts: {
14
26
  target: string;
@@ -1 +1 @@
1
- {"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../../src/cli/codemod/files.ts"],"names":[],"mappings":"AAOA;;;;;GAKG;AACH,qBAAa,YAAY;IACvB,wJAAwJ;IACxJ,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,EAAE;IAUlD,+GAA+G;IAC/G,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,EAAE,GAAG,SAAS;IA2B9D;;;OAGG;IACH,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,GAAG,CAAC,MAAM,CAAC,GAAG,SAAS;IAiC/D,wFAAwF;IACxF,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,EAAE;IAoBnD,OAAO,CAAC,MAAM,CAAC,QAAQ;CAGxB"}
1
+ {"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../../src/cli/codemod/files.ts"],"names":[],"mappings":"AAOA;;;;;GAKG;AACH,qBAAa,YAAY;IACvB,wJAAwJ;IACxJ,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,EAAE;IAUlD;;;;;OAKG;IACH,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE;QACnB,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,OAAO,CAAC;QACjB,KAAK,EAAE,OAAO,CAAC;QACf,KAAK,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;KAC9B,GAAG,MAAM,GAAG,SAAS;IActB,+GAA+G;IAC/G,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,EAAE,GAAG,SAAS;IA4B9D;;;OAGG;IACH,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,GAAG,CAAC,MAAM,CAAC,GAAG,SAAS;IAkC/D,wFAAwF;IACxF,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,EAAE;IAoBnD,OAAO,CAAC,MAAM,CAAC,QAAQ;CAGxB"}
@@ -21,6 +21,22 @@ class CodemodFiles {
21
21
  }
22
22
  return CodemodFiles.fromGit({ target }) ?? CodemodFiles.fromWalk({ target });
23
23
  }
24
+ /**
25
+ * Why a call must be refused, or `undefined` when it may go on. `--write` with no path rewrote every source
26
+ * file under the working directory, which is how one command typed without a path changed 134 clean files: a
27
+ * codemod that rewrites broadly needs a path or an explicit `--all`. A dry run (and `--check`) with no path still
28
+ * lists the whole tree.
29
+ */
30
+ static refusal(opts) {
31
+ const { command, isWrite, isAll, paths } = opts;
32
+ if (isAll && paths.length > 0) {
33
+ return `devz codemod ${command}: --all and a path contradict each other (--all means the whole working tree)`;
34
+ }
35
+ if (isWrite && !isAll && paths.length === 0) {
36
+ return `devz codemod ${command}: --write needs a path, or --all to rewrite every source file under the working directory (nothing was written)`;
37
+ }
38
+ return undefined;
39
+ }
24
40
  /** Tracked files plus untracked files git does not ignore; `undefined` outside a repository or without git. */
25
41
  static fromGit(opts) {
26
42
  const { target } = opts;
@@ -32,6 +48,7 @@ class CodemodFiles {
32
48
  maxBuffer: 256 * 1024 * 1024,
33
49
  stdio: ['ignore', 'pipe', 'ignore'],
34
50
  });
51
+ // eslint-disable-next-line venizia/no-silent-catch -- not a git repository or no git: the caller falls back to the directory walk; the git error text is lost
35
52
  }
36
53
  catch {
37
54
  return undefined;
@@ -64,6 +81,7 @@ class CodemodFiles {
64
81
  maxBuffer: 256 * 1024 * 1024,
65
82
  stdio: ['ignore', 'pipe', 'ignore'],
66
83
  });
84
+ // eslint-disable-next-line venizia/no-silent-catch -- not a git repository or no git: nothing to check, so no dirty set; the git error text is lost
67
85
  }
68
86
  catch {
69
87
  return undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"files.js","sourceRoot":"","sources":["../../../src/cli/codemod/files.ts"],"names":[],"mappings":";;;AAAA,2DAAkD;AAClD,qCAA4D;AAC5D,yCAA0C;AAE1C,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;AAC/E,MAAM,cAAc,GAAG,uBAAuB,CAAC;AAE/C;;;;;GAKG;AACH,MAAa,YAAY;IACvB,wJAAwJ;IACxJ,MAAM,CAAC,OAAO,CAAC,IAAwB;QACrC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;QAExB,IAAI,IAAA,kBAAQ,EAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC;YAC9B,OAAO,CAAC,MAAM,CAAC,CAAC;QAClB,CAAC;QAED,OAAO,YAAY,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC,IAAI,YAAY,CAAC,QAAQ,CAAC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CAAC;QAE3B,KAAK,MAAM,KAAK,IAAI,IAAA,qBAAW,EAAC,MAAM,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;YACjE,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;gBACxB,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;oBACxE,KAAK,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,IAAA,gBAAI,EAAC,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;gBAC7E,CAAC;gBACD,SAAS;YACX,CAAC;YAED,IAAI,YAAY,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC;gBAChD,KAAK,CAAC,IAAI,CAAC,IAAA,gBAAI,EAAC,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;YACvC,CAAC;QACH,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAEO,MAAM,CAAC,QAAQ,CAAC,IAAsB;QAC5C,OAAO,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IACxE,CAAC;CACF;AArGD,oCAqGC","sourcesContent":["import { execFileSync } from 'node:child_process';\nimport { existsSync, readdirSync, statSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\n\nconst SKIPPED_DIRECTORIES = new Set(['node_modules', 'dist', 'build', '.git']);\nconst SOURCE_PATTERN = /\\.(?:ts|tsx|mts|cts)$/;\n\n/**\n * The source files a codemod may touch. Inside a git repository the list comes from git, so a\n * `.gitignore`d folder (a worktree, a clone, a build output) is never entered. Outside git there is\n * no ignore file to read, so the walk skips every dot-directory as well as `node_modules`, `dist`,\n * `build` and `.git`.\n */\nexport class CodemodFiles {\n /** Every `.ts`, `.tsx`, `.mts` or `.cts` file (declaration files excluded) the codemod may touch under `target`; a file target is returned as it is. */\n static collect(opts: { target: string }): string[] {\n const { target } = opts;\n\n if (statSync(target).isFile()) {\n return [target];\n }\n\n return CodemodFiles.fromGit({ target }) ?? CodemodFiles.fromWalk({ target });\n }\n\n /** Tracked files plus untracked files git does not ignore; `undefined` outside a repository or without git. */\n static fromGit(opts: { target: string }): string[] | undefined {\n const { target } = opts;\n let output: string;\n\n try {\n output = execFileSync(\n 'git',\n ['ls-files', '--cached', '--others', '--exclude-standard', '-z'],\n {\n cwd: target,\n encoding: 'utf8',\n maxBuffer: 256 * 1024 * 1024,\n stdio: ['ignore', 'pipe', 'ignore'],\n },\n );\n } catch {\n return undefined;\n }\n\n return output\n .split('\\0')\n .filter((path) => path !== '' && CodemodFiles.isSource({ name: path }))\n .filter((path) => !path.split('/').some((segment) => SKIPPED_DIRECTORIES.has(segment)))\n .map((path) => join(target, path))\n .filter((path) => existsSync(path) && statSync(path).isFile());\n }\n\n /**\n * The files under `target` that a write could not be undone with git: changed in the working tree,\n * staged, or untracked. `undefined` outside a repository or without git, where there is nothing to check.\n */\n static dirty(opts: { target: string }): Set<string> | undefined {\n const { target } = opts;\n const cwd = statSync(target).isFile() ? dirname(target) : target;\n const queries = [\n ['ls-files', '--modified', '--others', '--exclude-standard', '-z'],\n ['diff', '--cached', '--name-only', '--relative', '-z'],\n ];\n const paths = new Set<string>();\n\n for (const query of queries) {\n let output: string;\n\n try {\n output = execFileSync('git', query, {\n cwd,\n encoding: 'utf8',\n maxBuffer: 256 * 1024 * 1024,\n stdio: ['ignore', 'pipe', 'ignore'],\n });\n } catch {\n return undefined;\n }\n\n for (const path of output.split('\\0')) {\n if (path !== '') {\n paths.add(join(cwd, path));\n }\n }\n }\n\n return paths;\n }\n\n /** The directory walk used outside git: skips dot-directories and the build folders. */\n static fromWalk(opts: { target: string }): string[] {\n const { target } = opts;\n const files: string[] = [];\n\n for (const entry of readdirSync(target, { withFileTypes: true })) {\n if (entry.isDirectory()) {\n if (!SKIPPED_DIRECTORIES.has(entry.name) && !entry.name.startsWith('.')) {\n files.push(...CodemodFiles.fromWalk({ target: join(target, entry.name) }));\n }\n continue;\n }\n\n if (CodemodFiles.isSource({ name: entry.name })) {\n files.push(join(target, entry.name));\n }\n }\n\n return files;\n }\n\n private static isSource(opts: { name: string }): boolean {\n return SOURCE_PATTERN.test(opts.name) && !opts.name.endsWith('.d.ts');\n }\n}\n"]}
1
+ {"version":3,"file":"files.js","sourceRoot":"","sources":["../../../src/cli/codemod/files.ts"],"names":[],"mappings":";;;AAAA,2DAAkD;AAClD,qCAA4D;AAC5D,yCAA0C;AAE1C,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;AAC/E,MAAM,cAAc,GAAG,uBAAuB,CAAC;AAE/C;;;;;GAKG;AACH,MAAa,YAAY;IACvB,wJAAwJ;IACxJ,MAAM,CAAC,OAAO,CAAC,IAAwB;QACrC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;QAExB,IAAI,IAAA,kBAAQ,EAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC;YAC9B,OAAO,CAAC,MAAM,CAAC,CAAC;QAClB,CAAC;QAED,OAAO,YAAY,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC,IAAI,YAAY,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;IAC/E,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,OAAO,CAAC,IAKd;QACC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;QAEhD,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,GAAG,C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ync, statSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\n\nconst SKIPPED_DIRECTORIES = new Set(['node_modules', 'dist', 'build', '.git']);\nconst SOURCE_PATTERN = /\\.(?:ts|tsx|mts|cts)$/;\n\n/**\n * The source files a codemod may touch. Inside a git repository the list comes from git, so a\n * `.gitignore`d folder (a worktree, a clone, a build output) is never entered. Outside git there is\n * no ignore file to read, so the walk skips every dot-directory as well as `node_modules`, `dist`,\n * `build` and `.git`.\n */\nexport class CodemodFiles {\n /** Every `.ts`, `.tsx`, `.mts` or `.cts` file (declaration files excluded) the codemod may touch under `target`; a file target is returned as it is. */\n static collect(opts: { target: string }): string[] {\n const { target } = opts;\n\n if (statSync(target).isFile()) {\n return [target];\n }\n\n return CodemodFiles.fromGit({ target }) ?? CodemodFiles.fromWalk({ target });\n }\n\n /**\n * Why a call must be refused, or `undefined` when it may go on. `--write` with no path rewrote every source\n * file under the working directory, which is how one command typed without a path changed 134 clean files: a\n * codemod that rewrites broadly needs a path or an explicit `--all`. A dry run (and `--check`) with no path still\n * lists the whole tree.\n */\n static refusal(opts: {\n command: string;\n isWrite: boolean;\n isAll: boolean;\n paths: ReadonlyArray<string>;\n }): string | undefined {\n const { command, isWrite, isAll, paths } = opts;\n\n if (isAll && paths.length > 0) {\n return `devz codemod ${command}: --all and a path contradict each other (--all means the whole working tree)`;\n }\n\n if (isWrite && !isAll && paths.length === 0) {\n return `devz codemod ${command}: --write needs a path, or --all to rewrite every source file under the working directory (nothing was written)`;\n }\n\n return undefined;\n }\n\n /** Tracked files plus untracked files git does not ignore; `undefined` outside a repository or without git. */\n static fromGit(opts: { target: string }): string[] | undefined {\n const { target } = opts;\n let output: string;\n\n try {\n output = execFileSync(\n 'git',\n ['ls-files', '--cached', '--others', '--exclude-standard', '-z'],\n {\n cwd: target,\n encoding: 'utf8',\n maxBuffer: 256 * 1024 * 1024,\n stdio: ['ignore', 'pipe', 'ignore'],\n },\n );\n // eslint-disable-next-line venizia/no-silent-catch -- not a git repository or no git: the caller falls back to the directory walk; the git error text is lost\n } catch {\n return undefined;\n }\n\n return output\n .split('\\0')\n .filter((path) => path !== '' && CodemodFiles.isSource({ name: path }))\n .filter((path) => !path.split('/').some((segment) => SKIPPED_DIRECTORIES.has(segment)))\n .map((path) => join(target, path))\n .filter((path) => existsSync(path) && statSync(path).isFile());\n }\n\n /**\n * The files under `target` that a write could not be undone with git: changed in the working tree,\n * staged, or untracked. `undefined` outside a repository or without git, where there is nothing to check.\n */\n static dirty(opts: { target: string }): Set<string> | undefined {\n const { target } = opts;\n const cwd = statSync(target).isFile() ? dirname(target) : target;\n const queries = [\n ['ls-files', '--modified', '--others', '--exclude-standard', '-z'],\n ['diff', '--cached', '--name-only', '--relative', '-z'],\n ];\n const paths = new Set<string>();\n\n for (const query of queries) {\n let output: string;\n\n try {\n output = execFileSync('git', query, {\n cwd,\n encoding: 'utf8',\n maxBuffer: 256 * 1024 * 1024,\n stdio: ['ignore', 'pipe', 'ignore'],\n });\n // eslint-disable-next-line venizia/no-silent-catch -- not a git repository or no git: nothing to check, so no dirty set; the git error text is lost\n } catch {\n return undefined;\n }\n\n for (const path of output.split('\\0')) {\n if (path !== '') {\n paths.add(join(cwd, path));\n }\n }\n }\n\n return paths;\n }\n\n /** The directory walk used outside git: skips dot-directories and the build folders. */\n static fromWalk(opts: { target: string }): string[] {\n const { target } = opts;\n const files: string[] = [];\n\n for (const entry of readdirSync(target, { withFileTypes: true })) {\n if (entry.isDirectory()) {\n if (!SKIPPED_DIRECTORIES.has(entry.name) && !entry.name.startsWith('.')) {\n files.push(...CodemodFiles.fromWalk({ target: join(target, entry.name) }));\n }\n continue;\n }\n\n if (CodemodFiles.isSource({ name: entry.name })) {\n files.push(join(target, entry.name));\n }\n }\n\n return files;\n }\n\n private static isSource(opts: { name: string }): boolean {\n return SOURCE_PATTERN.test(opts.name) && !opts.name.endsWith('.d.ts');\n }\n}\n"]}
@@ -9,7 +9,7 @@ export * from './rewriter';
9
9
  * `--check` is the same dry run, and exits 1 while a call can be rewritten or is left untouched.
10
10
  */
11
11
  export declare class NamespaceFunctionsCommand {
12
- static readonly USAGE = "Usage: devz codemod namespace-functions [paths...] [--write | --check]\n\nMoves calls of an IGNIS function that now lives in a class to the class form, with one options\nobject: `oldName(a, b)` becomes `ClassName.method({ first: a, second: b })`, and an argument named\nlike its key is written short (`{ first }`). The old names are removed from the packages, so run it\nonce after you upgrade. A table in @venizia/dev-configs names each moved function.\n\nIt follows a named import (aliased too) and a namespace import (`ns.oldName(...)`) from a module the\ntable lists, adds the class to that import, and drops the old name once nothing else uses it. It lists\nwith its file and line, and leaves for you: a call with a spread argument or the wrong number of\narguments, the old name used as a value (passed, stored, exported, in typeof), a re-export, a type-only\nimport, and a file that declares a name the rewrite would collide with.\n\nIt also moves the string form of the logger: `ApplicationLogger.get('scope')` (a string, a template, an\nidentifier or a property access) becomes `ApplicationLogger.get({ scope: 'scope' })`, when\n`ApplicationLogger` comes from `@venizia/ignis-helpers` or `@venizia/ignis`. `Logger.get` and\n`HfLogger.get` are not touched, and a call it cannot decide is listed.\n\n --write write the changed files (without it, nothing is written)\n --check dry run that exits 1 while a call can be rewritten or is left untouched (for CI)\n --help print this text and exit\n\nWith no flag it lists what would change and writes nothing. Inside a git repository it reads the\nfiles git knows (tracked, or untracked and not ignored), and --write refuses a file with local changes\n(changed, staged or untracked): commit or stash it first, so git can undo the codemod.";
12
+ static readonly USAGE = "Usage: devz codemod namespace-functions [paths...] [--write | --check]\n\nMoves calls of an IGNIS function that now lives in a class to the class form, with one options\nobject: `oldName(a, b)` becomes `ClassName.method({ first: a, second: b })`, and an argument named\nlike its key is written short (`{ first }`). The old names are removed from the packages, so run it\nonce after you upgrade. A table in @venizia/dev-configs names each moved function.\n\nIt follows a named import (aliased too) and a namespace import (`ns.oldName(...)`) from a module the\ntable lists, adds the class to that import, and drops the old name once nothing else uses it. It lists\nwith its file and line, and leaves for you: a call with a spread argument or the wrong number of\narguments, the old name used as a value (passed, stored, exported, in typeof), a re-export, a type-only\nimport, and a file that declares a name the rewrite would collide with.\n\nIt also moves the removed `ApplicationLogger`: `ApplicationLogger.get('scope')`, `.get(NAME)` and\n`.get({ scope: NAME })` become `LoggerFactory.getLogger(['scope'])`, `([NAME])`, and the import follows, when\n`ApplicationLogger` comes from `@venizia/ignis-helpers` or `@venizia/ignis`. `Logger.get` and\n`HfLogger.get` are not touched, and a call it cannot decide is listed, as is any other use of\n`ApplicationLogger` (a type, a re-export, a value). An identifier argument is taken for a scope: run your\ntypecheck afterwards.\n\n --write write the changed files (without it, nothing is written)\n --check dry run that exits 1 while a call can be rewritten or is left untouched (for CI)\n --help print this text and exit\n\nWith no flag it lists what would change and writes nothing. Inside a git repository it reads the\nfiles git knows (tracked, or untracked and not ignored), and --write refuses a file with local changes\n(changed, staged or untracked): commit or stash it first, so git can undo the codemod.";
13
13
  static run(opts: {
14
14
  root: string;
15
15
  args: string[];
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/cli/codemod/namespace-functions/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,iBAAiB,EAAqB,MAAM,WAAW,CAAC;AAKtE,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAiD3B;;;;GAIG;AACH,qBAAa,yBAAyB;IACpC,MAAM,CAAC,QAAQ,CAAC,KAAK,gxDAAS;WAEjB,GAAG,CAAC,IAAI,EAAE;QACrB,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,EAAE,CAAC;QACf,iEAAiE;QACjE,QAAQ,CAAC,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAC;KAC7C,GAAG,OAAO,CAAC,MAAM,CAAC;CAkJpB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/cli/codemod/namespace-functions/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,iBAAiB,EAAqB,MAAM,WAAW,CAAC;AAKtE,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAmD3B;;;;GAIG;AACH,qBAAa,yBAAyB;IACpC,MAAM,CAAC,QAAQ,CAAC,KAAK,s7DAAS;WAEjB,GAAG,CAAC,IAAI,EAAE;QACrB,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,EAAE,CAAC;QACf,iEAAiE;QACjE,QAAQ,CAAC,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAC;KAC7C,GAAG,OAAO,CAAC,MAAM,CAAC;CAkJpB"}
@@ -39,10 +39,12 @@ with its file and line, and leaves for you: a call with a spread argument or the
39
39
  arguments, the old name used as a value (passed, stored, exported, in typeof), a re-export, a type-only
40
40
  import, and a file that declares a name the rewrite would collide with.
41
41
 
42
- It also moves the string form of the logger: \`ApplicationLogger.get('scope')\` (a string, a template, an
43
- identifier or a property access) becomes \`ApplicationLogger.get({ scope: 'scope' })\`, when
42
+ It also moves the removed \`ApplicationLogger\`: \`ApplicationLogger.get('scope')\`, \`.get(NAME)\` and
43
+ \`.get({ scope: NAME })\` become \`LoggerFactory.getLogger(['scope'])\`, \`([NAME])\`, and the import follows, when
44
44
  \`ApplicationLogger\` comes from \`@venizia/ignis-helpers\` or \`@venizia/ignis\`. \`Logger.get\` and
45
- \`HfLogger.get\` are not touched, and a call it cannot decide is listed.
45
+ \`HfLogger.get\` are not touched, and a call it cannot decide is listed, as is any other use of
46
+ \`ApplicationLogger\` (a type, a re-export, a value). An identifier argument is taken for a scope: run your
47
+ typecheck afterwards.
46
48
 
47
49
  --write write the changed files (without it, nothing is written)
48
50
  --check dry run that exits 1 while a call can be rewritten or is left untouched (for CI)
@@ -132,8 +134,8 @@ class NamespaceFunctionsCommand {
132
134
  continue;
133
135
  }
134
136
  const shown = (0, node_path_1.relative)(root, file).split('\\').join('/') || file;
135
- // The call-shape rule goes first: it only rewrites the argument of a call, so the lines the table pass reports
136
- // are the lines of the file.
137
+ // The call-shape rule goes first, and its edits are inside one call, so the lines the table pass reports stay
138
+ // those of the file unless a multi-line `ApplicationLogger.get({ ... })` collapsed onto one line.
137
139
  const scoped = logger_scope_1.LoggerScopeRewriter.rewrite({ typescript, fileName: file, source });
138
140
  const tabled = rewriter_1.NamespaceFunctions.rewrite({
139
141
  typescript,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/cli/codemod/namespace-functions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,qCAAsD;AACtD,yCAA8C;AAC9C,oCAAwC;AACxC,uCAAsE;AACtE,yCAA0C;AAC1C,iDAAqD;AACrD,yCAAgD;AAEhD,iDAA+B;AAC/B,4CAA0B;AAC1B,6CAA2B;AAC3B,6CAA2B;AAE3B,MAAM,KAAK,GAAG;;;;;;;;;;;;;;;;;;;;;;;;uFAwByE,CAAC;AAExF,kDAAkD;AAClD,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAE3B,MAAM,uBAAuB;aACX,UAAK,GAAG,SAAS,CAAC;aAClB,UAAK,GAAG,SAAS,CAAC;aAClB,SAAI,GAAG,QAAQ,CAAC;aAChB,eAAU,GAAG,IAAI,CAAC;aAElB,eAAU,GAAG,IAAI,GAAG,CAAS;QAC3C,IAAI,CAAC,KAAK;QACV,IAAI,CAAC,KAAK;QACV,IAAI,CAAC,IAAI;QACT,IAAI,CAAC,UAAU;KAChB,CAAC,CAAC;IAEH,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;;AAGH;;;;GAIG;AACH,MAAa,yBAAyB;aACpB,UAAK,GAAG,KAAK,CAAC;IAE9B,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,IAKhB;QACC,MAAM,EAAE,IAAI,EAAE,IAAI,EAA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CAAC,MAAM,CAAC,CAAC;gBACrC,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,CAAC,GAAG,CACT,qCAAqC,YAAY,YAAY,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,cAAc,KAAK,SAAS,YAAY,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,oBAAoB,KAAK,WAAW,iBAAiB;YACtM,CAAC,YAAY,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,YAAY,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,CACxD,CAAC;QAEF,IAAI,CAAC,OAAO,IAAI,YAAY,GAAG,CAAC,EAAE,CAAC;YACjC,OAAO,CAAC,GAAG,CACT,uCAAuC,uBAAuB,CAAC,KAAK,mDAAmD,CACxH,CAAC;QACJ,CAAC;QAED,IAAI,OAAO,IAAI,YAAY,GAAG,CAAC,EAAE,CAAC;YAChC,OAAO,CAAC,CAAC;QACX,CAAC;QAED,OAAO,OAAO,IAAI,CAAC,YAAY,GAAG,CAAC,IAAI,WAAW,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAClE,CAAC;;AAzJH,8DA0JC","sourcesContent":["import { readFileSync, writeFileSync } from 'node:fs';\nimport { relative, resolve } from 'node:path';\nimport { CodemodFiles } from '../files';\nimport { type INamespaceMapping, NamespaceMappings } from './mapping';\nimport { ALL_MAPPINGS } from './mappings';\nimport { LoggerScopeRewriter } from './logger-scope';\nimport { NamespaceFunctions } from './rewriter';\n\nexport * from './logger-scope';\nexport * from './mapping';\nexport * from './mappings';\nexport * from './rewriter';\n\nconst USAGE = `Usage: devz codemod namespace-functions [paths...] [--write | --check]\n\nMoves calls of an IGNIS function that now lives in a class to the class form, with one options\nobject: \\`oldName(a, b)\\` becomes \\`ClassName.method({ first: a, second: b })\\`, and an argument named\nlike its key is written short (\\`{ first }\\`). The old names are removed from the packages, so run it\nonce after you upgrade. A table in @venizia/dev-configs names each moved function.\n\nIt follows a named import (aliased too) and a namespace import (\\`ns.oldName(...)\\`) from a module the\ntable lists, adds the class to that import, and drops the old name once nothing else uses it. It lists\nwith its file and line, and leaves for you: a call with a spread argument or the wrong number of\narguments, the old name used as a value (passed, stored, exported, in typeof), a re-export, a type-only\nimport, and a file that declares a name the rewrite would collide with.\n\nIt also moves the string form of the logger: \\`ApplicationLogger.get('scope')\\` (a string, a template, an\nidentifier or a property access) becomes \\`ApplicationLogger.get({ scope: 'scope' })\\`, when\n\\`ApplicationLogger\\` comes from \\`@venizia/ignis-helpers\\` or \\`@venizia/ignis\\`. \\`Logger.get\\` and\n\\`HfLogger.get\\` are not touched, and a call it cannot decide is listed.\n\n --write write the changed files (without it, nothing is written)\n --check dry run that exits 1 while a call can be rewritten or is left untouched (for CI)\n --help print this text and exit\n\nWith no flag it lists what would change and writes nothing. Inside a git repository it reads the\nfiles git knows (tracked, or untracked and not ignored), and --write refuses a file with local changes\n(changed, staged or untracked): commit or stash it first, so git can undo the codemod.`;\n\n/** A usage error: nothing was read or written. */\nconst USAGE_ERROR_CODE = 2;\n\nclass NamespaceFunctionsFlags {\n static readonly WRITE = '--write';\n static readonly CHECK = '--check';\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.HELP,\n this.HELP_SHORT,\n ]);\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n}\n\n/**\n * `devz codemod namespace-functions [paths...] [--write | --check]`: rewrites the calls of the\n * functions the mapping table lists to their class form. It is a dry run unless `--write` is given.\n * `--check` is the same dry run, and exits 1 while a call can be rewritten or is left untouched.\n */\nexport class NamespaceFunctionsCommand {\n static readonly USAGE = USAGE;\n\n static async run(opts: {\n root: string;\n args: string[];\n /** The table to apply; the one this package ships by default. */\n mappings?: ReadonlyArray<INamespaceMapping>;\n }): Promise<number> {\n const { root, args, mappings = ALL_MAPPINGS } = opts;\n\n if (\n args.includes(NamespaceFunctionsFlags.HELP) ||\n args.includes(NamespaceFunctionsFlags.HELP_SHORT)\n ) {\n console.log(USAGE);\n return 0;\n }\n\n const flags = args.filter((argument) => argument.startsWith('-'));\n const paths = args.filter((argument) => !argument.startsWith('-'));\n\n const unknown = flags.filter((flag) => !NamespaceFunctionsFlags.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(NamespaceFunctionsFlags.WRITE);\n const isCheck = flags.includes(NamespaceFunctionsFlags.CHECK);\n\n if (isWrite && isCheck) {\n console.error(\n `devz codemod: ${NamespaceFunctionsFlags.WRITE} and ${NamespaceFunctionsFlags.CHECK} contradict each other\\n${USAGE}`,\n );\n return USAGE_ERROR_CODE;\n }\n\n const problems = NamespaceMappings.validate({ mappings });\n if (problems.length > 0) {\n console.error(\n `devz codemod namespace-functions: the mapping table is broken:\\n${problems.map((problem) => ` ${problem}`).join('\\n')}`,\n );\n return 1;\n }\n\n if (mappings.length === 0) {\n console.log(\n 'devz codemod namespace-functions: the mapping table of this version is empty, so there is nothing to rewrite',\n );\n return 0;\n }\n\n let typescript: typeof import('typescript');\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 // Identifiers only (the table is validated), so the names need no escaping.\n const nameText = new RegExp(\n `\\\\b(?:${[...new Set(mappings.map((mapping) => mapping.oldName))].join('|')})\\\\b`,\n );\n const targets = (paths.length > 0 ? paths : ['.']).map((path) => resolve(root, path));\n let changedCount = 0;\n let callCount = 0;\n let reportCount = 0;\n let refusedCount = 0;\n\n for (const target of targets) {\n const files = CodemodFiles.collect({ target });\n const dirty = isWrite ? CodemodFiles.dirty({ target }) : undefined;\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 source = readFileSync(file, 'utf8');\n\n if (!nameText.test(source) && !LoggerScopeRewriter.mentions({ source })) {\n continue;\n }\n\n const shown = relative(root, file).split('\\\\').join('/') || file;\n // The call-shape rule goes first: it only rewrites the argument of a call, so the lines the table pass reports\n // are the lines of the file.\n const scoped = LoggerScopeRewriter.rewrite({ typescript, fileName: file, source });\n const tabled = NamespaceFunctions.rewrite({\n typescript,\n fileName: file,\n source: scoped.output,\n mappings,\n });\n const result = {\n output: tabled.output,\n changed: scoped.changed || tabled.changed,\n rewritten: scoped.rewritten + tabled.rewritten,\n reports: [...scoped.reports, ...tabled.reports],\n };\n\n for (const report of result.reports) {\n reportCount += 1;\n console.warn(`${shown}:${report.line}:${report.column} ${report.reason}`);\n }\n\n if (!result.changed) {\n continue;\n }\n\n if (dirty?.has(file)) {\n refusedCount += 1;\n console.warn(\n `refused ${shown} has local changes (commit or stash them, then run again)`,\n );\n continue;\n }\n\n changedCount += 1;\n callCount += result.rewritten;\n console.log(\n `${isWrite ? 'changed' : 'would change'} ${shown} (${result.rewritten} call(s))`,\n );\n\n if (isWrite) {\n writeFileSync(file, result.output);\n }\n }\n }\n\n console.log(\n `devz codemod namespace-functions: ${changedCount} file(s) ${isWrite ? 'changed' : 'would change'}, ${callCount} call(s) ${isWrite ? 'rewritten' : 'would be rewritten'}, ${reportCount} left untouched` +\n (refusedCount > 0 ? `, ${refusedCount} refused` : ''),\n );\n\n if (!isWrite && changedCount > 0) {\n console.log(\n `Nothing was written. Run again with ${NamespaceFunctionsFlags.WRITE} to apply, then run your typecheck and formatter.`,\n );\n }\n\n if (isWrite && refusedCount > 0) {\n return 1;\n }\n\n return isCheck && (changedCount > 0 || reportCount > 0) ? 1 : 0;\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/cli/codemod/namespace-functions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;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AAC,OAAO,IAAI,YAAY,GAAG,CAAC,EAAE,CAAC;YACjC,OAAO,CAAC,GAAG,CACT,uCAAuC,uBAAuB,CAAC,KAAK,mDAAmD,CACxH,CAAC;QACJ,CAAC;QAED,IAAI,OAAO,IAAI,YAAY,GAAG,CAAC,EAAE,CAAC;YAChC,OAAO,CAAC,CAAC;QACX,CAAC;QAED,OAAO,OAAO,IAAI,CAAC,YAAY,GAAG,CAAC,IAAI,WAAW,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAClE,CAAC;;AAzJH,8DA0JC","sourcesContent":["import { readFileSync, writeFileSync } from 'node:fs';\nimport { relative, resolve } from 'node:path';\nimport { CodemodFiles } from '../files';\nimport { type INamespaceMapping, NamespaceMappings } from './mapping';\nimport { ALL_MAPPINGS } from './mappings';\nimport { LoggerScopeRewriter } from './logger-scope';\nimport { NamespaceFunctions } from './rewriter';\n\nexport * from './logger-scope';\nexport * from './mapping';\nexport * from './mappings';\nexport * from './rewriter';\n\nconst USAGE = `Usage: devz codemod namespace-functions [paths...] [--write | --check]\n\nMoves calls of an IGNIS function that now lives in a class to the class form, with one options\nobject: \\`oldName(a, b)\\` becomes \\`ClassName.method({ first: a, second: b })\\`, and an argument named\nlike its key is written short (\\`{ first }\\`). The old names are removed from the packages, so run it\nonce after you upgrade. A table in @venizia/dev-configs names each moved function.\n\nIt follows a named import (aliased too) and a namespace import (\\`ns.oldName(...)\\`) from a module the\ntable lists, adds the class to that import, and drops the old name once nothing else uses it. It lists\nwith its file and line, and leaves for you: a call with a spread argument or the wrong number of\narguments, the old name used as a value (passed, stored, exported, in typeof), a re-export, a type-only\nimport, and a file that declares a name the rewrite would collide with.\n\nIt also moves the removed \\`ApplicationLogger\\`: \\`ApplicationLogger.get('scope')\\`, \\`.get(NAME)\\` and\n\\`.get({ scope: NAME })\\` become \\`LoggerFactory.getLogger(['scope'])\\`, \\`([NAME])\\`, and the import follows, when\n\\`ApplicationLogger\\` comes from \\`@venizia/ignis-helpers\\` or \\`@venizia/ignis\\`. \\`Logger.get\\` and\n\\`HfLogger.get\\` are not touched, and a call it cannot decide is listed, as is any other use of\n\\`ApplicationLogger\\` (a type, a re-export, a value). An identifier argument is taken for a scope: run your\ntypecheck afterwards.\n\n --write write the changed files (without it, nothing is written)\n --check dry run that exits 1 while a call can be rewritten or is left untouched (for CI)\n --help print this text and exit\n\nWith no flag it lists what would change and writes nothing. Inside a git repository it reads the\nfiles git knows (tracked, or untracked and not ignored), and --write refuses a file with local changes\n(changed, staged or untracked): commit or stash it first, so git can undo the codemod.`;\n\n/** A usage error: nothing was read or written. */\nconst USAGE_ERROR_CODE = 2;\n\nclass NamespaceFunctionsFlags {\n static readonly WRITE = '--write';\n static readonly CHECK = '--check';\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.HELP,\n this.HELP_SHORT,\n ]);\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n}\n\n/**\n * `devz codemod namespace-functions [paths...] [--write | --check]`: rewrites the calls of the\n * functions the mapping table lists to their class form. It is a dry run unless `--write` is given.\n * `--check` is the same dry run, and exits 1 while a call can be rewritten or is left untouched.\n */\nexport class NamespaceFunctionsCommand {\n static readonly USAGE = USAGE;\n\n static async run(opts: {\n root: string;\n args: string[];\n /** The table to apply; the one this package ships by default. */\n mappings?: ReadonlyArray<INamespaceMapping>;\n }): Promise<number> {\n const { root, args, mappings = ALL_MAPPINGS } = opts;\n\n if (\n args.includes(NamespaceFunctionsFlags.HELP) ||\n args.includes(NamespaceFunctionsFlags.HELP_SHORT)\n ) {\n console.log(USAGE);\n return 0;\n }\n\n const flags = args.filter((argument) => argument.startsWith('-'));\n const paths = args.filter((argument) => !argument.startsWith('-'));\n\n const unknown = flags.filter((flag) => !NamespaceFunctionsFlags.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(NamespaceFunctionsFlags.WRITE);\n const isCheck = flags.includes(NamespaceFunctionsFlags.CHECK);\n\n if (isWrite && isCheck) {\n console.error(\n `devz codemod: ${NamespaceFunctionsFlags.WRITE} and ${NamespaceFunctionsFlags.CHECK} contradict each other\\n${USAGE}`,\n );\n return USAGE_ERROR_CODE;\n }\n\n const problems = NamespaceMappings.validate({ mappings });\n if (problems.length > 0) {\n console.error(\n `devz codemod namespace-functions: the mapping table is broken:\\n${problems.map((problem) => ` ${problem}`).join('\\n')}`,\n );\n return 1;\n }\n\n if (mappings.length === 0) {\n console.log(\n 'devz codemod namespace-functions: the mapping table of this version is empty, so there is nothing to rewrite',\n );\n return 0;\n }\n\n let typescript: typeof import('typescript');\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 // Identifiers only (the table is validated), so the names need no escaping.\n const nameText = new RegExp(\n `\\\\b(?:${[...new Set(mappings.map((mapping) => mapping.oldName))].join('|')})\\\\b`,\n );\n const targets = (paths.length > 0 ? paths : ['.']).map((path) => resolve(root, path));\n let changedCount = 0;\n let callCount = 0;\n let reportCount = 0;\n let refusedCount = 0;\n\n for (const target of targets) {\n const files = CodemodFiles.collect({ target });\n const dirty = isWrite ? CodemodFiles.dirty({ target }) : undefined;\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 source = readFileSync(file, 'utf8');\n\n if (!nameText.test(source) && !LoggerScopeRewriter.mentions({ source })) {\n continue;\n }\n\n const shown = relative(root, file).split('\\\\').join('/') || file;\n // The call-shape rule goes first, and its edits are inside one call, so the lines the table pass reports stay\n // those of the file unless a multi-line `ApplicationLogger.get({ ... })` collapsed onto one line.\n const scoped = LoggerScopeRewriter.rewrite({ typescript, fileName: file, source });\n const tabled = NamespaceFunctions.rewrite({\n typescript,\n fileName: file,\n source: scoped.output,\n mappings,\n });\n const result = {\n output: tabled.output,\n changed: scoped.changed || tabled.changed,\n rewritten: scoped.rewritten + tabled.rewritten,\n reports: [...scoped.reports, ...tabled.reports],\n };\n\n for (const report of result.reports) {\n reportCount += 1;\n console.warn(`${shown}:${report.line}:${report.column} ${report.reason}`);\n }\n\n if (!result.changed) {\n continue;\n }\n\n if (dirty?.has(file)) {\n refusedCount += 1;\n console.warn(\n `refused ${shown} has local changes (commit or stash them, then run again)`,\n );\n continue;\n }\n\n changedCount += 1;\n callCount += result.rewritten;\n console.log(\n `${isWrite ? 'changed' : 'would change'} ${shown} (${result.rewritten} call(s))`,\n );\n\n if (isWrite) {\n writeFileSync(file, result.output);\n }\n }\n }\n\n console.log(\n `devz codemod namespace-functions: ${changedCount} file(s) ${isWrite ? 'changed' : 'would change'}, ${callCount} call(s) ${isWrite ? 'rewritten' : 'would be rewritten'}, ${reportCount} left untouched` +\n (refusedCount > 0 ? `, ${refusedCount} refused` : ''),\n );\n\n if (!isWrite && changedCount > 0) {\n console.log(\n `Nothing was written. Run again with ${NamespaceFunctionsFlags.WRITE} to apply, then run your typecheck and formatter.`,\n );\n }\n\n if (isWrite && refusedCount > 0) {\n return 1;\n }\n\n return isCheck && (changedCount > 0 || reportCount > 0) ? 1 : 0;\n }\n}\n"]}