@venizia/dev-configs 0.4.2 → 0.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +2 -5
- package/README.md +20 -5
- package/dist/checks/catalog.d.ts +39 -0
- package/dist/checks/catalog.d.ts.map +1 -0
- package/dist/checks/catalog.js +94 -0
- package/dist/checks/catalog.js.map +1 -0
- package/dist/checks/index.d.ts +11 -0
- package/dist/checks/index.d.ts.map +1 -0
- package/dist/checks/index.js +27 -0
- package/dist/checks/index.js.map +1 -0
- package/dist/checks/module-cycles.d.ts +22 -0
- package/dist/checks/module-cycles.d.ts.map +1 -0
- package/dist/checks/module-cycles.js +149 -0
- package/dist/checks/module-cycles.js.map +1 -0
- package/dist/checks/purity/manifest.d.ts +94 -0
- package/dist/checks/purity/manifest.d.ts.map +1 -0
- package/dist/checks/purity/manifest.js +177 -0
- package/dist/checks/purity/manifest.js.map +1 -0
- package/dist/checks/purity/probe.d.ts +68 -0
- package/dist/checks/purity/probe.d.ts.map +1 -0
- package/dist/checks/purity/probe.js +295 -0
- package/dist/checks/purity/probe.js.map +1 -0
- package/dist/checks/purity/run.d.ts +47 -0
- package/dist/checks/purity/run.d.ts.map +1 -0
- package/dist/checks/purity/run.js +121 -0
- package/dist/checks/purity/run.js.map +1 -0
- package/dist/checks/split-report.d.ts +19 -0
- package/dist/checks/split-report.d.ts.map +1 -0
- package/dist/checks/split-report.js +123 -0
- package/dist/checks/split-report.js.map +1 -0
- package/dist/cli/check.d.ts +10 -0
- package/dist/cli/check.d.ts.map +1 -0
- package/dist/cli/check.js +206 -0
- package/dist/cli/check.js.map +1 -0
- package/dist/cli/clean.d.ts +2 -1
- package/dist/cli/clean.d.ts.map +1 -1
- package/dist/cli/clean.js +18 -1
- package/dist/cli/clean.js.map +1 -1
- package/dist/cli/codemod/const-classes.d.ts +80 -0
- package/dist/cli/codemod/const-classes.d.ts.map +1 -0
- package/dist/cli/codemod/const-classes.js +603 -0
- package/dist/cli/codemod/const-classes.js.map +1 -0
- package/dist/cli/codemod/drop-redundant-casts.d.ts +112 -0
- package/dist/cli/codemod/drop-redundant-casts.d.ts.map +1 -0
- package/dist/cli/codemod/drop-redundant-casts.js +780 -0
- package/dist/cli/codemod/drop-redundant-casts.js.map +1 -0
- package/dist/cli/codemod/files.d.ts +22 -0
- package/dist/cli/codemod/files.d.ts.map +1 -0
- package/dist/cli/codemod/files.js +68 -0
- package/dist/cli/codemod/files.js.map +1 -0
- package/dist/cli/codemod/index.d.ts +5 -4
- package/dist/cli/codemod/index.d.ts.map +1 -1
- package/dist/cli/codemod/index.js +77 -36
- package/dist/cli/codemod/index.js.map +1 -1
- package/dist/cli/codemod/model-settings.d.ts +2 -1
- package/dist/cli/codemod/model-settings.d.ts.map +1 -1
- package/dist/cli/codemod/model-settings.js +77 -3
- package/dist/cli/codemod/model-settings.js.map +1 -1
- package/dist/cli/index.js +21 -2
- package/dist/cli/index.js.map +1 -1
- package/dist/linters/house/common.d.ts +1 -0
- package/dist/linters/house/common.d.ts.map +1 -1
- package/dist/linters/house/common.js +1 -0
- package/dist/linters/house/common.js.map +1 -1
- package/dist/linters/house/configs.d.ts.map +1 -1
- package/dist/linters/house/configs.js +20 -1
- package/dist/linters/house/configs.js.map +1 -1
- package/dist/linters/house/const-class-values.rule.d.ts +7 -4
- package/dist/linters/house/const-class-values.rule.d.ts.map +1 -1
- package/dist/linters/house/const-class-values.rule.js +73 -21
- package/dist/linters/house/const-class-values.rule.js.map +1 -1
- package/dist/linters/rules/common.d.ts +48 -1
- package/dist/linters/rules/common.d.ts.map +1 -1
- package/dist/linters/rules/common.js +53 -0
- package/dist/linters/rules/common.js.map +1 -1
- package/dist/linters/rules/eqeqeq.rule.d.ts +2 -2
- package/dist/linters/rules/eqeqeq.rule.d.ts.map +1 -1
- package/dist/linters/rules/eqeqeq.rule.js +2 -1
- package/dist/linters/rules/eqeqeq.rule.js.map +1 -1
- package/dist/linters/rules/no-unused-vars.rule.d.ts +3 -3
- package/dist/linters/rules/no-unused-vars.rule.d.ts.map +1 -1
- package/dist/linters/rules/no-unused-vars.rule.js +2 -1
- package/dist/linters/rules/no-unused-vars.rule.js.map +1 -1
- package/dist/linters/rules/switch-case-braces.rule.d.ts +2 -2
- package/dist/linters/rules/switch-case-braces.rule.d.ts.map +1 -1
- package/dist/linters/rules/switch-case-braces.rule.js +2 -1
- package/dist/linters/rules/switch-case-braces.rule.js.map +1 -1
- package/dist/testing/index.d.ts +2 -0
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +2 -0
- package/dist/testing/index.js.map +1 -1
- package/dist/testing/repo-tmp.d.ts +12 -0
- package/dist/testing/repo-tmp.d.ts.map +1 -0
- package/dist/testing/repo-tmp.js +67 -0
- package/dist/testing/repo-tmp.js.map +1 -0
- package/dist/testing/spawn.helper.d.ts +13 -0
- package/dist/testing/spawn.helper.d.ts.map +1 -0
- package/dist/testing/spawn.helper.js +22 -0
- package/dist/testing/spawn.helper.js.map +1 -0
- package/dist/testing/tmpdir-preload.d.ts +2 -0
- package/dist/testing/tmpdir-preload.d.ts.map +1 -0
- package/dist/testing/tmpdir-preload.js +9 -0
- package/dist/testing/tmpdir-preload.js.map +1 -0
- package/package.json +9 -1
- package/src/tsconfig/tsconfig.base.json +5 -2
- package/src/tsconfig/tsconfig.common.json +2 -2
|
@@ -0,0 +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;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CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,kBAAkB,OAAO,YAAY,aAAa,IAAI,OAAO;YAC1I,CAAC,OAAO,CAAC,IAAI,GAAG,CAAC;gBACf,CAAC,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,GAAG,KAAK,IAAI,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG;gBAChF,CAAC,CAAC,EAAE,CAAC;YACP,CAAC,cAAc,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,cAAc,2BAA2B,CAAC,CAAC,CAAC,EAAE,CAAC,CAC7E,CAAC;QAEF,IAAI,CAAC,OAAO,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;;AA9KH,8DA+KC","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 typescript = (await import('typescript')).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"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The source files a codemod may touch. Inside a git repository the list comes from git, so a
|
|
3
|
+
* `.gitignore`d folder (a worktree, a clone, a build output) is never entered. Outside git there is
|
|
4
|
+
* no ignore file to read, so the walk skips every dot-directory as well as `node_modules`, `dist`,
|
|
5
|
+
* `build` and `.git`.
|
|
6
|
+
*/
|
|
7
|
+
export declare class CodemodFiles {
|
|
8
|
+
/** Every `.ts`, `.tsx`, `.mts` or `.cts` file (declaration files excluded) the codemod may touch under `target`; a file target is returned as it is. */
|
|
9
|
+
static collect(opts: {
|
|
10
|
+
target: string;
|
|
11
|
+
}): string[];
|
|
12
|
+
/** Tracked files plus untracked files git does not ignore; `undefined` outside a repository or without git. */
|
|
13
|
+
static fromGit(opts: {
|
|
14
|
+
target: string;
|
|
15
|
+
}): string[] | undefined;
|
|
16
|
+
/** The directory walk used outside git: skips dot-directories and the build folders. */
|
|
17
|
+
static fromWalk(opts: {
|
|
18
|
+
target: string;
|
|
19
|
+
}): string[];
|
|
20
|
+
private static isSource;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=files.d.ts.map
|
|
@@ -0,0 +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,wFAAwF;IACxF,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,EAAE;IAoBnD,OAAO,CAAC,MAAM,CAAC,QAAQ;CAGxB"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CodemodFiles = void 0;
|
|
4
|
+
const node_child_process_1 = require("node:child_process");
|
|
5
|
+
const node_fs_1 = require("node:fs");
|
|
6
|
+
const node_path_1 = require("node:path");
|
|
7
|
+
const SKIPPED_DIRECTORIES = new Set(['node_modules', 'dist', 'build', '.git']);
|
|
8
|
+
const SOURCE_PATTERN = /\.(?:ts|tsx|mts|cts)$/;
|
|
9
|
+
/**
|
|
10
|
+
* The source files a codemod may touch. Inside a git repository the list comes from git, so a
|
|
11
|
+
* `.gitignore`d folder (a worktree, a clone, a build output) is never entered. Outside git there is
|
|
12
|
+
* no ignore file to read, so the walk skips every dot-directory as well as `node_modules`, `dist`,
|
|
13
|
+
* `build` and `.git`.
|
|
14
|
+
*/
|
|
15
|
+
class CodemodFiles {
|
|
16
|
+
/** Every `.ts`, `.tsx`, `.mts` or `.cts` file (declaration files excluded) the codemod may touch under `target`; a file target is returned as it is. */
|
|
17
|
+
static collect(opts) {
|
|
18
|
+
const { target } = opts;
|
|
19
|
+
if ((0, node_fs_1.statSync)(target).isFile()) {
|
|
20
|
+
return [target];
|
|
21
|
+
}
|
|
22
|
+
return CodemodFiles.fromGit({ target }) ?? CodemodFiles.fromWalk({ target });
|
|
23
|
+
}
|
|
24
|
+
/** Tracked files plus untracked files git does not ignore; `undefined` outside a repository or without git. */
|
|
25
|
+
static fromGit(opts) {
|
|
26
|
+
const { target } = opts;
|
|
27
|
+
let output;
|
|
28
|
+
try {
|
|
29
|
+
output = (0, node_child_process_1.execFileSync)('git', ['ls-files', '--cached', '--others', '--exclude-standard', '-z'], {
|
|
30
|
+
cwd: target,
|
|
31
|
+
encoding: 'utf8',
|
|
32
|
+
maxBuffer: 256 * 1024 * 1024,
|
|
33
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
return output
|
|
40
|
+
.split('\0')
|
|
41
|
+
.filter((path) => path !== '' && CodemodFiles.isSource({ name: path }))
|
|
42
|
+
.filter((path) => !path.split('/').some((segment) => SKIPPED_DIRECTORIES.has(segment)))
|
|
43
|
+
.map((path) => (0, node_path_1.join)(target, path))
|
|
44
|
+
.filter((path) => (0, node_fs_1.existsSync)(path) && (0, node_fs_1.statSync)(path).isFile());
|
|
45
|
+
}
|
|
46
|
+
/** The directory walk used outside git: skips dot-directories and the build folders. */
|
|
47
|
+
static fromWalk(opts) {
|
|
48
|
+
const { target } = opts;
|
|
49
|
+
const files = [];
|
|
50
|
+
for (const entry of (0, node_fs_1.readdirSync)(target, { withFileTypes: true })) {
|
|
51
|
+
if (entry.isDirectory()) {
|
|
52
|
+
if (!SKIPPED_DIRECTORIES.has(entry.name) && !entry.name.startsWith('.')) {
|
|
53
|
+
files.push(...CodemodFiles.fromWalk({ target: (0, node_path_1.join)(target, entry.name) }));
|
|
54
|
+
}
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
if (CodemodFiles.isSource({ name: entry.name })) {
|
|
58
|
+
files.push((0, node_path_1.join)(target, entry.name));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return files;
|
|
62
|
+
}
|
|
63
|
+
static isSource(opts) {
|
|
64
|
+
return SOURCE_PATTERN.test(opts.name) && !opts.name.endsWith('.d.ts');
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports.CodemodFiles = CodemodFiles;
|
|
68
|
+
//# sourceMappingURL=files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.js","sourceRoot":"","sources":["../../../src/cli/codemod/files.ts"],"names":[],"mappings":";;;AAAA,2DAAkD;AAClD,qCAA4D;AAC5D,yCAAiC;AAEjC,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,+GAA+G;IAC/G,MAAM,CAAC,OAAO,CAAC,IAAwB;QACrC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;QACxB,IAAI,MAAc,CAAC;QAEnB,IAAI,CAAC;YACH,MAAM,GAAG,IAAA,iCAAY,EACnB,KAAK,EACL,CAAC,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,oBAAoB,EAAE,IAAI,CAAC,EAChE;gBACE,GAAG,EAAE,MAAM;gBACX,QAAQ,EAAE,MAAM;gBAChB,SAAS,EAAE,GA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AE,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;AAhED,oCAgEC","sourcesContent":["import { execFileSync } from 'node:child_process';\nimport { existsSync, readdirSync, statSync } from 'node:fs';\nimport { 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 /** 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,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `devz codemod model-settings [paths...] [--check]`: moves `@model` settings from the
|
|
3
|
-
* (`defaultFilter`, `defaultLimit`, `maxLimit`, `scopeFilter`) to `query` and `access
|
|
4
|
-
*
|
|
5
|
-
* anything would
|
|
2
|
+
* `devz codemod model-settings [paths...] [--write | --check]`: moves `@model` settings from the
|
|
3
|
+
* flat keys (`defaultFilter`, `defaultLimit`, `maxLimit`, `scopeFilter`) to `query` and `access`,
|
|
4
|
+
* and `skipMigrate` to `migration.use`. It is a dry run unless `--write` is given: it lists what
|
|
5
|
+
* would change. `--check` is the same dry run, and exits 1 when anything would change or is
|
|
6
|
+
* left untouched (an untouched model still throws when its decorator runs).
|
|
6
7
|
*/
|
|
7
8
|
export declare class CodemodCommand {
|
|
8
9
|
static run(opts: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cli/codemod/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cli/codemod/index.ts"],"names":[],"mappings":"AA0CA;;;;;;GAMG;AACH,qBAAa,cAAc;WACZ,GAAG,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,EAAE,CAAA;KAAE,GAAG,OAAO,CAAC,MAAM,CAAC;CAgH1E"}
|
|
@@ -3,45 +3,76 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.CodemodCommand = void 0;
|
|
4
4
|
const node_fs_1 = require("node:fs");
|
|
5
5
|
const node_path_1 = require("node:path");
|
|
6
|
+
const const_classes_1 = require("./const-classes");
|
|
7
|
+
const drop_redundant_casts_1 = require("./drop-redundant-casts");
|
|
8
|
+
const files_1 = require("./files");
|
|
6
9
|
const model_settings_1 = require("./model-settings");
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
const USAGE = `Usage: devz codemod model-settings [paths...] [--write | --check]
|
|
11
|
+
|
|
12
|
+
Moves @model settings to the grouped shape and skipMigrate to migration.use.
|
|
13
|
+
|
|
14
|
+
--write write the changed files (without it, nothing is written)
|
|
15
|
+
--check dry run that exits 1 when anything would change or is left untouched (for CI)
|
|
16
|
+
--help print this text and exit
|
|
17
|
+
|
|
18
|
+
With no flag it lists what would change and writes nothing. Inside a git repository it reads the
|
|
19
|
+
files git knows (tracked, or untracked and not ignored), so ignored folders are never touched.`;
|
|
20
|
+
/** A file that can hold a `@model` call: the decorator, an aliased import of it, or `ns.model(`. */
|
|
21
|
+
const MODEL_TEXT = /@model\b|\bmodel\s+as\s+\w+|\.model\(/;
|
|
22
|
+
/** A usage error: nothing was read or written. */
|
|
23
|
+
const USAGE_ERROR_CODE = 2;
|
|
24
|
+
class CodemodFlags {
|
|
25
|
+
static { this.WRITE = '--write'; }
|
|
26
|
+
static { this.CHECK = '--check'; }
|
|
27
|
+
static { this.HELP = '--help'; }
|
|
28
|
+
static { this.HELP_SHORT = '-h'; }
|
|
29
|
+
static { this.SCHEME_SET = new Set([
|
|
30
|
+
this.WRITE,
|
|
31
|
+
this.CHECK,
|
|
32
|
+
this.HELP,
|
|
33
|
+
this.HELP_SHORT,
|
|
34
|
+
]); }
|
|
35
|
+
static isValid(value) {
|
|
36
|
+
return this.SCHEME_SET.has(value);
|
|
15
37
|
}
|
|
16
|
-
|
|
17
|
-
for (const entry of (0, node_fs_1.readdirSync)(target, { withFileTypes: true })) {
|
|
18
|
-
if (entry.isDirectory()) {
|
|
19
|
-
if (!SKIPPED_DIRECTORIES.has(entry.name)) {
|
|
20
|
-
files.push(...collectFiles((0, node_path_1.join)(target, entry.name)));
|
|
21
|
-
}
|
|
22
|
-
continue;
|
|
23
|
-
}
|
|
24
|
-
if (SOURCE_PATTERN.test(entry.name) && !entry.name.endsWith('.d.ts')) {
|
|
25
|
-
files.push((0, node_path_1.join)(target, entry.name));
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
return files;
|
|
29
|
-
};
|
|
38
|
+
}
|
|
30
39
|
/**
|
|
31
|
-
* `devz codemod model-settings [paths...] [--check]`: moves `@model` settings from the
|
|
32
|
-
* (`defaultFilter`, `defaultLimit`, `maxLimit`, `scopeFilter`) to `query` and `access
|
|
33
|
-
*
|
|
34
|
-
* anything would
|
|
40
|
+
* `devz codemod model-settings [paths...] [--write | --check]`: moves `@model` settings from the
|
|
41
|
+
* flat keys (`defaultFilter`, `defaultLimit`, `maxLimit`, `scopeFilter`) to `query` and `access`,
|
|
42
|
+
* and `skipMigrate` to `migration.use`. It is a dry run unless `--write` is given: it lists what
|
|
43
|
+
* would change. `--check` is the same dry run, and exits 1 when anything would change or is
|
|
44
|
+
* left untouched (an untouched model still throws when its decorator runs).
|
|
35
45
|
*/
|
|
36
46
|
class CodemodCommand {
|
|
37
47
|
static async run(opts) {
|
|
38
|
-
const
|
|
48
|
+
const { args } = opts;
|
|
49
|
+
const [name, ...rest] = args;
|
|
50
|
+
if (name === 'drop-redundant-casts') {
|
|
51
|
+
return drop_redundant_casts_1.DropRedundantCastsCommand.run({ root: opts.root, args: rest });
|
|
52
|
+
}
|
|
53
|
+
if (name === 'const-classes') {
|
|
54
|
+
return const_classes_1.ConstClassesCommand.run({ root: opts.root, args: rest });
|
|
55
|
+
}
|
|
56
|
+
if (args.includes(CodemodFlags.HELP) || args.includes(CodemodFlags.HELP_SHORT)) {
|
|
57
|
+
console.log(`${USAGE}\n\n${drop_redundant_casts_1.DropRedundantCastsCommand.USAGE}\n\n${const_classes_1.ConstClassesCommand.USAGE}`);
|
|
58
|
+
return 0;
|
|
59
|
+
}
|
|
39
60
|
if (name !== 'model-settings') {
|
|
40
61
|
console.error(`devz codemod: unknown codemod "${name ?? ''}"\n${USAGE}`);
|
|
41
|
-
return
|
|
62
|
+
return USAGE_ERROR_CODE;
|
|
63
|
+
}
|
|
64
|
+
const unknown = rest.filter((argument) => argument.startsWith('-') && !CodemodFlags.isValid(argument));
|
|
65
|
+
if (unknown.length > 0) {
|
|
66
|
+
console.error(`devz codemod: unknown option ${unknown.map((flag) => `"${flag}"`).join(', ')}\n${USAGE}`);
|
|
67
|
+
return USAGE_ERROR_CODE;
|
|
68
|
+
}
|
|
69
|
+
const isWrite = rest.includes(CodemodFlags.WRITE);
|
|
70
|
+
const isCheck = rest.includes(CodemodFlags.CHECK);
|
|
71
|
+
if (isWrite && isCheck) {
|
|
72
|
+
console.error(`devz codemod: ${CodemodFlags.WRITE} and ${CodemodFlags.CHECK} contradict each other\n${USAGE}`);
|
|
73
|
+
return USAGE_ERROR_CODE;
|
|
42
74
|
}
|
|
43
|
-
const
|
|
44
|
-
const paths = rest.filter((argument) => !argument.startsWith('--'));
|
|
75
|
+
const paths = rest.filter((argument) => !argument.startsWith('-'));
|
|
45
76
|
const targets = (paths.length > 0 ? paths : ['.']).map((path) => (0, node_path_1.resolve)(opts.root, path));
|
|
46
77
|
let typescript;
|
|
47
78
|
try {
|
|
@@ -54,9 +85,13 @@ class CodemodCommand {
|
|
|
54
85
|
let changedCount = 0;
|
|
55
86
|
let reportCount = 0;
|
|
56
87
|
for (const target of targets) {
|
|
57
|
-
|
|
88
|
+
const files = files_1.CodemodFiles.collect({ target });
|
|
89
|
+
if (files.length === 0 && paths.length > 0) {
|
|
90
|
+
console.warn(`devz codemod: no source files under "${(0, node_path_1.relative)(opts.root, target) || target}" (git ignores the path, or it holds none): nothing was read`);
|
|
91
|
+
}
|
|
92
|
+
for (const file of files) {
|
|
58
93
|
const source = (0, node_fs_1.readFileSync)(file, 'utf8');
|
|
59
|
-
if (!
|
|
94
|
+
if (!MODEL_TEXT.test(source)) {
|
|
60
95
|
continue;
|
|
61
96
|
}
|
|
62
97
|
const result = (0, model_settings_1.migrateModelSettings)({ typescript, fileName: file, source });
|
|
@@ -69,14 +104,20 @@ class CodemodCommand {
|
|
|
69
104
|
continue;
|
|
70
105
|
}
|
|
71
106
|
changedCount += 1;
|
|
72
|
-
console.log(`${
|
|
73
|
-
if (
|
|
107
|
+
console.log(`${isWrite ? 'changed' : 'would change'} ${shown} (${result.rewritten} model(s))`);
|
|
108
|
+
if (isWrite) {
|
|
74
109
|
(0, node_fs_1.writeFileSync)(file, result.output);
|
|
75
110
|
}
|
|
76
111
|
}
|
|
77
112
|
}
|
|
78
|
-
console.log(`devz codemod model-settings: ${changedCount} file(s) ${
|
|
79
|
-
|
|
113
|
+
console.log(`devz codemod model-settings: ${changedCount} file(s) ${isWrite ? 'changed' : 'would change'}, ${reportCount} left untouched`);
|
|
114
|
+
if (!isWrite && changedCount > 0) {
|
|
115
|
+
console.log(`Nothing was written. Run again with ${CodemodFlags.WRITE} to apply.`);
|
|
116
|
+
}
|
|
117
|
+
if (isCheck && changedCount === 0 && reportCount > 0) {
|
|
118
|
+
console.log('Nothing to rewrite, but the models above throw when the decorator runs: fix them by hand.');
|
|
119
|
+
}
|
|
120
|
+
return isCheck && (changedCount > 0 || reportCount > 0) ? 1 : 0;
|
|
80
121
|
}
|
|
81
122
|
}
|
|
82
123
|
exports.CodemodCommand = CodemodCommand;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/cli/codemod/index.ts"],"names":[],"mappings":";;;AAAA,qCAA6E;AAC7E,yCAAoD;AACpD,qDAAwD;AAExD,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,MAAM,KAAK,GAAG,yDAAyD,CAAC;AAExE,+FAA+F;AAC/F,MAAM,YAAY,GAAG,CAAC,MAAc,EAAY,EAAE;IAChD,MAAM,KAAK,GAAG,IAAA,kBAAQ,EAAC,MAAM,CAAC,CAAC;IAE/B,IAAI,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC;QACnB,OAAO,CAAC,MAAM,CAAC,CAAC;IAClB,CAAC;IAED,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,MAAM,KAAK,IAAI,IAAA,qBAAW,EAAC,MAAM,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;QACjE,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;YACxB,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;gBACzC,KAAK,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC,IAAA,gBA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EF,IAAI,CAAC,OAAO,EAAE,CAAC;oBACb,IAAA,uBAAa,EAAC,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;gBACrC,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,CAAC,GAAG,CACT,gCAAgC,YAAY,YAAY,OAAO,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS,KAAK,WAAW,iBAAiB,CAC9H,CAAC;QAEF,OAAO,OAAO,IAAI,YAAY,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7C,CAAC;CACF;AA7DD,wCA6DC","sourcesContent":["import { readdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';\nimport { join, relative, resolve } from 'node:path';\nimport { migrateModelSettings } from './model-settings';\n\nconst SKIPPED_DIRECTORIES = new Set(['node_modules', 'dist', 'build', '.git']);\nconst SOURCE_PATTERN = /\\.(?:ts|tsx|mts|cts)$/;\n\nconst USAGE = 'Usage: devz codemod model-settings [paths...] [--check]';\n\n/** Every source file under `target`: the file itself, or the `.ts` files below a directory. */\nconst collectFiles = (target: string): string[] => {\n const stats = statSync(target);\n\n if (stats.isFile()) {\n return [target];\n }\n\n const files: string[] = [];\n for (const entry of readdirSync(target, { withFileTypes: true })) {\n if (entry.isDirectory()) {\n if (!SKIPPED_DIRECTORIES.has(entry.name)) {\n files.push(...collectFiles(join(target, entry.name)));\n }\n continue;\n }\n\n if (SOURCE_PATTERN.test(entry.name) && !entry.name.endsWith('.d.ts')) {\n files.push(join(target, entry.name));\n }\n }\n\n return files;\n};\n\n/**\n * `devz codemod model-settings [paths...] [--check]`: moves `@model` settings from the flat keys\n * (`defaultFilter`, `defaultLimit`, `maxLimit`, `scopeFilter`) to `query` and `access`. Without\n * `--check` it writes the files; with it, it only lists what would change and exits 1 when\n * anything would.\n */\nexport class CodemodCommand {\n static async run(opts: { root: string; args: string[] }): Promise<number> {\n const [name, ...rest] = opts.args;\n\n if (name !== 'model-settings') {\n console.error(`devz codemod: unknown codemod \"${name ?? ''}\"\\n${USAGE}`);\n return 1;\n }\n\n const isCheck = rest.includes('--check');\n const paths = rest.filter((argument) => !argument.startsWith('--'));\n const targets = (paths.length > 0 ? paths : ['.']).map((path) => resolve(opts.root, path));\n\n let typescript: typeof import('typescript');\n try {\n typescript = (await import('typescript')).default;\n } catch {\n console.error('devz codemod: the \"typescript\" package is required to read your sources');\n return 1;\n }\n\n let changedCount = 0;\n let reportCount = 0;\n\n for (const target of targets) {\n for (const file of collectFiles(target)) {\n const source = readFileSync(file, 'utf8');\n\n if (!source.includes('@model')) {\n continue;\n }\n\n const result = migrateModelSettings({ typescript, fileName: file, source });\n const shown = relative(opts.root, file) || file;\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 changedCount += 1;\n console.log(\n `${isCheck ? 'would change' : 'changed'} ${shown} (${result.rewritten} model(s))`,\n );\n\n if (!isCheck) {\n writeFileSync(file, result.output);\n }\n }\n }\n\n console.log(\n `devz codemod model-settings: ${changedCount} file(s) ${isCheck ? 'would change' : 'changed'}, ${reportCount} left untouched`,\n );\n\n return isCheck && changedCount > 0 ? 1 : 0;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/cli/codemod/index.ts"],"names":[],"mappings":";;;AAAA,qCAAsD;AACtD,yCAA8C;AAC9C,mDAAsD;AACtD,iEAAmE;AACnE,mCAAuC;AACvC,qDAAwD;AAExD,MAAM,KAAK,GAAG;;;;;;;;;+FASiF,CAAC;AAEhG,oGAAoG;AACpG,MAAM,UAAU,GAAG,uCAAuC,CAAC;AAE3D,kDAAkD;AAClD,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAE3B,MAAM,YAAY;aACA,UAAK,GAAG,SAAS,CAAC;aAClB,UAAK,GAAG,SAAS,CAAC;aAClB,SAAI,GAAG,QAAQ,C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G,KAAK,IAAI,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;gBAC7E,CAAC;gBAED,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;oBACpB,SAAS;gBACX,CAAC;gBAED,YAAY,IAAI,CAAC,CAAC;gBAClB,OAAO,CAAC,GAAG,CACT,GAAG,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,cAAc,KAAK,KAAK,MAAM,MAAM,CAAC,SAAS,YAAY,CACpF,CAAC;gBAEF,IAAI,OAAO,EAAE,CAAC;oBACZ,IAAA,uBAAa,EAAC,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;gBACrC,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,CAAC,GAAG,CACT,gCAAgC,YAAY,YAAY,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,cAAc,KAAK,WAAW,iBAAiB,CAC9H,CAAC;QAEF,IAAI,CAAC,OAAO,IAAI,YAAY,GAAG,CAAC,EAAE,CAAC;YACjC,OAAO,CAAC,GAAG,CAAC,uCAAuC,YAAY,CAAC,KAAK,YAAY,CAAC,CAAC;QACrF,CAAC;QAED,IAAI,OAAO,IAAI,YAAY,KAAK,CAAC,IAAI,WAAW,GAAG,CAAC,EAAE,CAAC;YACrD,OAAO,CAAC,GAAG,CACT,2FAA2F,CAC5F,CAAC;QACJ,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;CACF;AAjHD,wCAiHC","sourcesContent":["import { readFileSync, writeFileSync } from 'node:fs';\nimport { relative, resolve } from 'node:path';\nimport { ConstClassesCommand } from './const-classes';\nimport { DropRedundantCastsCommand } from './drop-redundant-casts';\nimport { CodemodFiles } from './files';\nimport { migrateModelSettings } from './model-settings';\n\nconst USAGE = `Usage: devz codemod model-settings [paths...] [--write | --check]\n\nMoves @model settings to the grouped shape and skipMigrate to migration.use.\n\n --write write the changed files (without it, nothing is written)\n --check dry run that exits 1 when anything would change 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), so ignored folders are never touched.`;\n\n/** A file that can hold a `@model` call: the decorator, an aliased import of it, or `ns.model(`. */\nconst MODEL_TEXT = /@model\\b|\\bmodel\\s+as\\s+\\w+|\\.model\\(/;\n\n/** A usage error: nothing was read or written. */\nconst USAGE_ERROR_CODE = 2;\n\nclass CodemodFlags {\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 model-settings [paths...] [--write | --check]`: moves `@model` settings from the\n * flat keys (`defaultFilter`, `defaultLimit`, `maxLimit`, `scopeFilter`) to `query` and `access`,\n * and `skipMigrate` to `migration.use`. It is a dry run unless `--write` is given: it lists what\n * would change. `--check` is the same dry run, and exits 1 when anything would change or is\n * left untouched (an untouched model still throws when its decorator runs).\n */\nexport class CodemodCommand {\n static async run(opts: { root: string; args: string[] }): Promise<number> {\n const { args } = opts;\n\n const [name, ...rest] = args;\n\n if (name === 'drop-redundant-casts') {\n return DropRedundantCastsCommand.run({ root: opts.root, args: rest });\n }\n\n if (name === 'const-classes') {\n return ConstClassesCommand.run({ root: opts.root, args: rest });\n }\n\n if (args.includes(CodemodFlags.HELP) || args.includes(CodemodFlags.HELP_SHORT)) {\n console.log(`${USAGE}\\n\\n${DropRedundantCastsCommand.USAGE}\\n\\n${ConstClassesCommand.USAGE}`);\n return 0;\n }\n\n if (name !== 'model-settings') {\n console.error(`devz codemod: unknown codemod \"${name ?? ''}\"\\n${USAGE}`);\n return USAGE_ERROR_CODE;\n }\n\n const unknown = rest.filter(\n (argument) => argument.startsWith('-') && !CodemodFlags.isValid(argument),\n );\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 = rest.includes(CodemodFlags.WRITE);\n const isCheck = rest.includes(CodemodFlags.CHECK);\n\n if (isWrite && isCheck) {\n console.error(\n `devz codemod: ${CodemodFlags.WRITE} and ${CodemodFlags.CHECK} contradict each other\\n${USAGE}`,\n );\n return USAGE_ERROR_CODE;\n }\n\n const paths = rest.filter((argument) => !argument.startsWith('-'));\n const targets = (paths.length > 0 ? paths : ['.']).map((path) => resolve(opts.root, path));\n\n let typescript: typeof import('typescript');\n try {\n typescript = (await import('typescript')).default;\n } catch {\n console.error('devz codemod: the \"typescript\" package is required to read your sources');\n return 1;\n }\n\n let changedCount = 0;\n let reportCount = 0;\n\n for (const target of targets) {\n const files = CodemodFiles.collect({ target });\n\n if (files.length === 0 && paths.length > 0) {\n console.warn(\n `devz codemod: no source files under \"${relative(opts.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 (!MODEL_TEXT.test(source)) {\n continue;\n }\n\n const result = migrateModelSettings({ typescript, fileName: file, source });\n const shown = relative(opts.root, file) || file;\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 changedCount += 1;\n console.log(\n `${isWrite ? 'changed' : 'would change'} ${shown} (${result.rewritten} model(s))`,\n );\n\n if (isWrite) {\n writeFileSync(file, result.output);\n }\n }\n }\n\n console.log(\n `devz codemod model-settings: ${changedCount} file(s) ${isWrite ? 'changed' : 'would change'}, ${reportCount} left untouched`,\n );\n\n if (!isWrite && changedCount > 0) {\n console.log(`Nothing was written. Run again with ${CodemodFlags.WRITE} to apply.`);\n }\n\n if (isCheck && changedCount === 0 && reportCount > 0) {\n console.log(\n 'Nothing to rewrite, but the models above throw when the decorator runs: fix them by hand.',\n );\n }\n\n return isCheck && (changedCount > 0 || reportCount > 0) ? 1 : 0;\n }\n}\n"]}
|
|
@@ -15,7 +15,8 @@ export interface IModelSettingsResult {
|
|
|
15
15
|
reports: IModelSettingsReport[];
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
|
-
* Rewrites
|
|
18
|
+
* Rewrites `@model({ ... })` from the old keys to the grouped ones. `skipMigrate` becomes
|
|
19
|
+
* `migration: { use: false }`. In the `settings` object literal:
|
|
19
20
|
* `defaultFilter` to `query.filter`, `defaultLimit` and `maxLimit` to `query.limit.default` and
|
|
20
21
|
* `query.limit.max`, `scopeFilter` to `access` (`writeGuard` to `write.mode`, `sharedRows` to
|
|
21
22
|
* `write.sharedRows`).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-settings.d.ts","sourceRoot":"","sources":["../../../src/cli/codemod/model-settings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAEjC,KAAK,WAAW,GAAG,OAAO,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"model-settings.d.ts","sourceRoot":"","sources":["../../../src/cli/codemod/model-settings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAEjC,KAAK,WAAW,GAAG,OAAO,EAAE,CAAC;AAK7B,6DAA6D;AAC7D,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,oBAAoB;IACnC,+EAA+E;IAC/E,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,yDAAyD;IACzD,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,oBAAoB,EAAE,CAAC;CACjC;AAWD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,oBAAoB,GAAI,MAAM;IACzC,UAAU,EAAE,WAAW,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB,KAAG,oBAsaH,CAAC"}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.migrateModelSettings = void 0;
|
|
4
|
+
/** The packages that export the `@model` decorator, so an aliased import of it is recognised. */
|
|
5
|
+
const MODEL_MODULES = new Set(['@venizia/ignis', '@venizia/ignis-kernel']);
|
|
4
6
|
const QUERY_KEYS = { defaultFilter: 'filter', defaultLimit: 'default', maxLimit: 'max' };
|
|
5
7
|
const OLD_KEYS = new Set([...Object.keys(QUERY_KEYS), 'scopeFilter']);
|
|
6
8
|
/**
|
|
7
|
-
* Rewrites
|
|
9
|
+
* Rewrites `@model({ ... })` from the old keys to the grouped ones. `skipMigrate` becomes
|
|
10
|
+
* `migration: { use: false }`. In the `settings` object literal:
|
|
8
11
|
* `defaultFilter` to `query.filter`, `defaultLimit` and `maxLimit` to `query.limit.default` and
|
|
9
12
|
* `query.limit.max`, `scopeFilter` to `access` (`writeGuard` to `write.mode`, `sharedRows` to
|
|
10
13
|
* `write.sharedRows`).
|
|
@@ -35,6 +38,39 @@ const migrateModelSettings = (opts) => {
|
|
|
35
38
|
return undefined;
|
|
36
39
|
};
|
|
37
40
|
const text = (node) => source.slice(node.getStart(sourceFile), node.end);
|
|
41
|
+
// Names that mean `@model`: the identifier itself, an alias of a named import from IGNIS, and the
|
|
42
|
+
// namespace of `import * as ignis` (`@ignis.model(...)`).
|
|
43
|
+
const modelNames = new Set(['model']);
|
|
44
|
+
const namespaces = new Set();
|
|
45
|
+
for (const statement of sourceFile.statements) {
|
|
46
|
+
if (!typescript.isImportDeclaration(statement) ||
|
|
47
|
+
!typescript.isStringLiteral(statement.moduleSpecifier) ||
|
|
48
|
+
!MODEL_MODULES.has(statement.moduleSpecifier.text)) {
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
const bindings = statement.importClause?.namedBindings;
|
|
52
|
+
if (!bindings) {
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
if (typescript.isNamespaceImport(bindings)) {
|
|
56
|
+
namespaces.add(bindings.name.text);
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
for (const element of bindings.elements) {
|
|
60
|
+
if ((element.propertyName ?? element.name).text === 'model') {
|
|
61
|
+
modelNames.add(element.name.text);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
const isModelCallee = (callee) => {
|
|
66
|
+
if (typescript.isIdentifier(callee)) {
|
|
67
|
+
return modelNames.has(callee.text);
|
|
68
|
+
}
|
|
69
|
+
return (typescript.isPropertyAccessExpression(callee) &&
|
|
70
|
+
typescript.isIdentifier(callee.expression) &&
|
|
71
|
+
namespaces.has(callee.expression.text) &&
|
|
72
|
+
callee.name.text === 'model');
|
|
73
|
+
};
|
|
38
74
|
/**
|
|
39
75
|
* The leading trivia of `first` (its own comments and indentation) followed by the comments that
|
|
40
76
|
* were above the properties being merged into it, so no comment is dropped.
|
|
@@ -226,11 +262,45 @@ const migrateModelSettings = (opts) => {
|
|
|
226
262
|
edits.push(...localEdits);
|
|
227
263
|
rewritten += 1;
|
|
228
264
|
};
|
|
265
|
+
/**
|
|
266
|
+
* `skipMigrate: true` becomes `migration: { use: false }`; `skipMigrate: false` is the default and
|
|
267
|
+
* is removed. Anything that is not a boolean literal, or a model that already has `migration`, is
|
|
268
|
+
* reported and left alone.
|
|
269
|
+
*/
|
|
270
|
+
const migrateSkipMigrate = (argument) => {
|
|
271
|
+
const property = argument.properties.find((candidate) => nameOf(candidate) === 'skipMigrate');
|
|
272
|
+
if (!property) {
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
if (!typescript.isPropertyAssignment(property)) {
|
|
276
|
+
report(property, 'skipMigrate is a shorthand property; left untouched');
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
if (argument.properties.some((candidate) => nameOf(candidate) === 'migration')) {
|
|
280
|
+
report(property, 'skipMigrate and migration are both set; left untouched');
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
const { initializer } = property;
|
|
284
|
+
if (initializer.kind === typescript.SyntaxKind.TrueKeyword) {
|
|
285
|
+
edits.push({
|
|
286
|
+
start: property.getStart(sourceFile),
|
|
287
|
+
end: property.end,
|
|
288
|
+
text: 'migration: { use: false }',
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
else if (initializer.kind === typescript.SyntaxKind.FalseKeyword) {
|
|
292
|
+
edits.push(removal(property));
|
|
293
|
+
}
|
|
294
|
+
else {
|
|
295
|
+
report(property, 'skipMigrate is not a boolean literal; left untouched');
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
298
|
+
rewritten += 1;
|
|
299
|
+
};
|
|
229
300
|
const visit = (node) => {
|
|
230
301
|
if (typescript.isDecorator(node) &&
|
|
231
302
|
typescript.isCallExpression(node.expression) &&
|
|
232
|
-
|
|
233
|
-
node.expression.expression.text === 'model') {
|
|
303
|
+
isModelCallee(node.expression.expression)) {
|
|
234
304
|
const argument = node.expression.arguments[0];
|
|
235
305
|
if (argument && typescript.isObjectLiteralExpression(argument)) {
|
|
236
306
|
const settingsProperty = argument.properties.find((property) => nameOf(property) === 'settings');
|
|
@@ -243,6 +313,10 @@ const migrateModelSettings = (opts) => {
|
|
|
243
313
|
report(settingsProperty, 'settings is not an object literal (a variable, a call or a shorthand); left untouched');
|
|
244
314
|
}
|
|
245
315
|
}
|
|
316
|
+
migrateSkipMigrate(argument);
|
|
317
|
+
}
|
|
318
|
+
else if (argument) {
|
|
319
|
+
report(argument, '@model argument is not an object literal (a variable or a call); left untouched');
|
|
246
320
|
}
|
|
247
321
|
}
|
|
248
322
|
typescript.forEachChild(node, visit);
|