@venizia/dev-configs 0.5.0-5 → 0.5.0-6
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/dist/cli/codemod/any-aliases.d.ts +1 -1
- package/dist/cli/codemod/any-aliases.js +2 -2
- package/dist/cli/codemod/any-aliases.js.map +1 -1
- package/dist/cli/codemod/async-style.d.ts +1 -1
- package/dist/cli/codemod/async-style.js +2 -2
- package/dist/cli/codemod/async-style.js.map +1 -1
- package/dist/cli/codemod/binding-keys.d.ts +1 -1
- package/dist/cli/codemod/binding-keys.js +2 -2
- package/dist/cli/codemod/binding-keys.js.map +1 -1
- package/dist/cli/codemod/class-renames.d.ts +1 -1
- package/dist/cli/codemod/class-renames.js +2 -3
- package/dist/cli/codemod/class-renames.js.map +1 -1
- package/dist/cli/codemod/connector-imports.d.ts +1 -1
- package/dist/cli/codemod/connector-imports.js +2 -2
- package/dist/cli/codemod/connector-imports.js.map +1 -1
- package/dist/cli/codemod/const-class-sets.d.ts +55 -0
- package/dist/cli/codemod/const-class-sets.js +219 -0
- package/dist/cli/codemod/const-class-sets.js.map +1 -0
- package/dist/cli/codemod/const-classes.d.ts +21 -3
- package/dist/cli/codemod/const-classes.js +135 -21
- package/dist/cli/codemod/const-classes.js.map +1 -1
- package/dist/cli/codemod/env-get.d.ts +1 -1
- package/dist/cli/codemod/env-get.js +2 -2
- package/dist/cli/codemod/env-get.js.map +1 -1
- package/dist/cli/codemod/files.d.ts +4 -2
- package/dist/cli/codemod/files.js +5 -6
- package/dist/cli/codemod/files.js.map +1 -1
- package/dist/cli/codemod/namespace-functions/index.d.ts +1 -1
- package/dist/cli/codemod/namespace-functions/index.js +2 -2
- package/dist/cli/codemod/namespace-functions/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env-get.js","sourceRoot":"","sources":["../../../src/cli/codemod/env-get.ts"],"names":[],"mappings":";;;AAAA,qCAAsD;AAC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,CAAC;YAChE,CAAC,YAAY,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,YAAY,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,CACxD,CAAC;QAEF,IAAI,YAAY,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;YAC1B,MAAM,MAAM,GAAG,CAAC,GAAG,YAAY,CAAC,OAAO,EAAE,CAAC;iBACvC,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;iBACzC,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,GAAG,QAAQ,KAAK,KAAK,EAAE,CAAC;iBACnD,IAAI,CAAC,IAAI,CAAC,CAAC;YAEd,OAAO,CAAC,GAAG,CAAC,4BAA4B,MAAM,EAAE,CAAC,CAAC;QACpD,CAAC;QAED,IAAI,CAAC,OAAO,IAAI,YAAY,GAAG,CAAC,EAAE,CAAC;YACjC,OAAO,CAAC,GAAG,CACT,uCAAuC,WAAW,CAAC,KAAK,qCAAqC,CAC9F,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;;AAzKH,sCA0KC","sourcesContent":["import { readFileSync, writeFileSync } from 'node:fs';\nimport { relative, resolve } from 'node:path';\nimport { CodemodFiles } from './files';\n\nconst USAGE = `Usage: devz codemod env-get [paths...] [--write [--all] | --check]\n\nRewrites the type arguments of applicationEnvironment.get() (and its alias AppEnvs.get()) for the\n@venizia/ignis-helpers release where get() reads strings:\n\n get<string>(key) becomes get(key)\n get<string | undefined>(key) becomes get(key)\n get<string>(key, { defaultValue }) becomes get(key, { defaultValue })\n get<R, B>(key, { transform }) becomes get<R>(key, { transform })\n\nAny other type argument (get<number>(key), get<boolean>(key)) was a cast the new get() no longer allows:\nthe codemod lists it as \"manual\" and leaves it. Move the conversion into a transform, or read the\nstring and convert it where you use it: get(key, { transform: Number }).\n\nA call already in the new form (one type argument and an options literal with a transform) is left alone\nand not listed, and a second run changes nothing.\n\nIt reads TypeScript files (.ts, .tsx, .mts, .cts) and rewrites only calls whose receiver resolves, from the\nscope of the call, to the store: a name imported as applicationEnvironment or AppEnvs from @venizia/ignis,\n@venizia/ignis-helpers (or a sub-path), under any local name (import { AppEnvs as Envs } ...), or a const\ninitialised from such a name in the same or an enclosing scope. A parameter, a local variable, an import from\nanywhere else (a barrel of your own included) and a name nothing declares are not the store. Every other\nget<...>(key) call (a property, an optional chain, those names) is printed as skipped with its file and line,\nand a call with a type argument it cannot place as manual, so run your typecheck after it. A call with one type argument and options\nthat are not a literal (a variable) is left alone and not listed; one with two type arguments and such options is listed as manual, and so is a number read with such options under --numbers (the codemod cannot see what the options hold). A var declared in a nested block counts as block-scoped (a hoisted one is not followed). A comment between the method name and the parenthesis is dropped. A .js, .cjs or .mjs file\nis not read: edit it by hand.\n\n --write write the changed files (without it, nothing is written); it needs a path, or --all\n --all with --write and no path: rewrite every source file under the working directory\n --numbers also rewrite the number reads: get<number>(key) and get<number>(key, { defaultValue }) become\n get(key, { transform: (raw) => ParseUtility.toNumber({ input: raw }), defaultValue }) and\n ParseUtility joins the import of the store. Every rewrite is listed (\"numbers\"). The old call returned\n the environment STRING typed as a number: after the rewrite the read converts it to a number, an unset\n variable still answers undefined (or the default), and a non-numeric value throws at the read\n instead of flowing on as a string. A boolean (the \"false\" string is truthy) stays manual. So does a number\n read the rewrite would not compile: a defaultValue that is a literal but not a number ('10'), options that\n are a variable, a ParseUtility name the file already declares for something else (an import from another\n module, a type-only import, a local), and a parameter or local named ParseUtility at the call.\n --check dry run that exits 1 while a file would change or a manual call remains (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 files\ngit knows, and --write refuses a file with local changes: commit or stash it first, so git can undo it.\nThere is no --reverse: a downgrade restores the files from git.`;\n\n/** A usage error: nothing was read or written. */\nconst USAGE_ERROR_CODE = 2;\n\n/** The names the environment store is exported under, and so the receivers `get()` is called on. */\nconst RECEIVERS = new Set(['applicationEnvironment', 'AppEnvs']);\n\n/** A module that exports the store: the root package and the helpers package, with or without a subpath. */\nconst STORE_MODULE = /^@venizia\\/ignis(?:-helpers)?(?:\\/.*)?$/;\n\nclass EnvGetFlags {\n static readonly WRITE = '--write';\n static readonly ALL = '--all';\n static readonly NUMBERS = '--numbers';\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.ALL,\n this.NUMBERS,\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\nexport interface IEnvGetResult {\n output: string;\n changed: boolean;\n /** How many calls were rewritten. */\n rewritten: number;\n /** The store calls the codemod cannot rewrite: file line (1-based), the first type argument and, when the cause is not the type argument itself, the reason. */\n manual: Array<{ line: number; type: string; reason?: string }>;\n /** With `--numbers`: the lines of the number reads rewritten to a transform (they are counted in `rewritten` too). */\n numbered: number[];\n /** The `get<...>(key)` calls on a receiver the file does not bind to the store (or through an optional chain), left alone and listed: file line (1-based) and the receiver text. */\n skipped: Array<{ line: number; receiver: string }>;\n}\n\n/** Rewrites the type arguments of `applicationEnvironment.get()` calls. */\nexport class EnvGet {\n /** The names a declaration in `node` binds, for `node` a scope: a block or file, a function, a loop or a catch clause. */\n private static declarationIn(opts: {\n typescript: typeof import('typescript');\n scope: import('typescript').Node;\n name: string;\n }): import('typescript').Node | undefined {\n const { typescript: ts, scope, name } = opts;\n\n const bindingNames = (node: import('typescript').BindingName): string[] => {\n if (ts.isIdentifier(node)) {\n return [node.text];\n }\n\n return node.elements.flatMap((element) =>\n ts.isBindingElement(element) ? bindingNames(element.name) : [],\n );\n };\n\n const inDeclarations = (\n declarations: ReadonlyArray<import('typescript').VariableDeclaration>,\n ): import('typescript').Node | undefined =>\n declarations.find((declaration) => bindingNames(declaration.name).includes(name));\n\n if (\n ts.isSourceFile(scope) ||\n ts.isBlock(scope) ||\n ts.isModuleBlock(scope) ||\n ts.isCaseClause(scope) ||\n ts.isDefaultClause(scope)\n ) {\n for (const statement of scope.statements) {\n if (ts.isVariableStatement(statement)) {\n const found = inDeclarations(statement.declarationList.declarations);\n\n if (found !== undefined) {\n return found;\n }\n } else if (\n (ts.isFunctionDeclaration(statement) ||\n ts.isClassDeclaration(statement) ||\n ts.isEnumDeclaration(statement)) &&\n statement.name?.text === name\n ) {\n return statement;\n } else if (ts.isImportDeclaration(statement) && statement.importClause !== undefined) {\n const clause = statement.importClause;\n\n if (clause.name?.text === name) {\n return clause;\n }\n\n const bindings = clause.namedBindings;\n\n if (\n bindings !== undefined &&\n ts.isNamespaceImport(bindings) &&\n bindings.name.text === name\n ) {\n return bindings;\n }\n\n if (bindings !== undefined && ts.isNamedImports(bindings)) {\n const element = bindings.elements.find((candidate) => candidate.name.text === name);\n\n if (element !== undefined) {\n return element;\n }\n }\n }\n }\n\n return undefined;\n }\n\n if (ts.isFunctionLike(scope)) {\n const parameter = scope.parameters.find((candidate) =>\n bindingNames(candidate.name).includes(name),\n );\n\n if (parameter !== undefined) {\n return parameter;\n }\n\n return ts.isFunctionExpression(scope) && scope.name?.text === name ? scope : undefined;\n }\n\n if (\n (ts.isForStatement(scope) || ts.isForOfStatement(scope) || ts.isForInStatement(scope)) &&\n scope.initializer !== undefined &&\n ts.isVariableDeclarationList(scope.initializer)\n ) {\n return inDeclarations(scope.initializer.declarations);\n }\n\n if (ts.isCatchClause(scope) && scope.variableDeclaration !== undefined) {\n return inDeclarations([scope.variableDeclaration]);\n }\n\n return undefined;\n }\n\n /**\n * Whether `identifier` refers to the environment store: the binding the name resolves to, from the\n * innermost scope outwards, is an import of `applicationEnvironment` or `AppEnvs` from the store module\n * (aliased or not), or a `const` that is initialised from such a name. A parameter, a local, an import\n * from anywhere else and a name nothing declares are not the store.\n */\n static isStore(opts: {\n typescript: typeof import('typescript');\n identifier: import('typescript').Identifier;\n }): boolean {\n return EnvGet.storeImport(opts) !== undefined;\n }\n\n /** The import specifier of the store that `identifier` resolves to (through const aliases), or `undefined` when it is not the store. */\n static storeImport(opts: {\n typescript: typeof import('typescript');\n identifier: import('typescript').Identifier;\n seen?: Set<import('typescript').Node>;\n }): import('typescript').ImportSpecifier | undefined {\n const { typescript: ts, identifier } = opts;\n const seen = opts.seen ?? new Set<import('typescript').Node>();\n\n if (seen.has(identifier)) {\n return undefined;\n }\n\n seen.add(identifier);\n\n for (\n let scope: import('typescript').Node | undefined = identifier.parent;\n scope !== undefined;\n scope = scope.parent\n ) {\n const declaration = EnvGet.declarationIn({ typescript: ts, scope, name: identifier.text });\n\n if (declaration === undefined) {\n continue;\n }\n\n if (ts.isImportSpecifier(declaration)) {\n const importDeclaration = declaration.parent.parent.parent;\n\n return ts.isStringLiteral(importDeclaration.moduleSpecifier) &&\n STORE_MODULE.test(importDeclaration.moduleSpecifier.text) &&\n RECEIVERS.has((declaration.propertyName ?? declaration.name).text)\n ? declaration\n : undefined;\n }\n\n if (\n ts.isVariableDeclaration(declaration) &&\n (ts.getCombinedNodeFlags(declaration) & ts.NodeFlags.Const) !== 0 &&\n ts.isIdentifier(declaration.name) &&\n declaration.initializer !== undefined &&\n ts.isIdentifier(declaration.initializer)\n ) {\n return EnvGet.storeImport({ typescript: ts, identifier: declaration.initializer, seen });\n }\n\n return undefined;\n }\n\n return undefined;\n }\n\n static rewrite(opts: {\n typescript: typeof import('typescript');\n fileName: string;\n source: string;\n /** `--numbers`: rewrite `get<number>(key)` and `get<number>(key, { defaultValue })` to a `ParseUtility.toNumber` transform. */\n numbers?: boolean;\n }): IEnvGetResult {\n const { typescript: ts, fileName, source, numbers = false } = opts;\n const language = fileName.endsWith('.tsx') ? ts.ScriptKind.TSX : ts.ScriptKind.TS;\n const file = ts.createSourceFile(fileName, source, ts.ScriptTarget.Latest, true, language);\n const edits: Array<{ start: number; end: number; text: string }> = [];\n const manual: Array<{ line: number; type: string; reason?: string }> = [];\n const skipped: Array<{ line: number; receiver: string }> = [];\n const numbered: number[] = [];\n let rewrittenCalls = 0;\n let isParseUtilityImported = false;\n const lineOf = (node: import('typescript').Node): number =>\n file.getLineAndCharacterOfPosition(node.getStart(file)).line + 1;\n\n /** `string`, or `string | undefined` (the type `get(key)` already answers): the type argument can go. */\n const isStringType = (node: import('typescript').TypeNode): boolean => {\n if (node.kind === ts.SyntaxKind.StringKeyword) {\n return true;\n }\n\n if (ts.isParenthesizedTypeNode(node)) {\n return isStringType(node.type);\n }\n\n if (ts.isUnionTypeNode(node) && node.types.length === 2) {\n const parts = node.types.map((part) => part.kind);\n\n return (\n parts.includes(ts.SyntaxKind.StringKeyword) &&\n parts.includes(ts.SyntaxKind.UndefinedKeyword)\n );\n }\n\n return false;\n };\n\n /** An options literal that already carries a `transform`: the call is in the new form. */\n const hasTransform = (node: import('typescript').Expression | undefined): boolean =>\n node !== undefined &&\n ts.isObjectLiteralExpression(node) &&\n node.properties.some(\n (property) =>\n property.name !== undefined &&\n ts.isIdentifier(property.name) &&\n property.name.text === 'transform',\n );\n\n /** `number`, or `number | undefined`: the types `--numbers` rewrites. */\n const isNumberType = (node: import('typescript').TypeNode): boolean => {\n if (node.kind === ts.SyntaxKind.NumberKeyword) {\n return true;\n }\n\n if (ts.isParenthesizedTypeNode(node)) {\n return isNumberType(node.type);\n }\n\n if (ts.isUnionTypeNode(node) && node.types.length === 2) {\n const parts = node.types.map((part) => part.kind);\n\n return (\n parts.includes(ts.SyntaxKind.NumberKeyword) &&\n parts.includes(ts.SyntaxKind.UndefinedKeyword)\n );\n }\n\n return false;\n };\n\n /** A literal that is not a number: a `defaultValue` of this kind matches no overload of the rewritten call. */\n const isNonNumericLiteral = (node: import('typescript').Expression): boolean =>\n ts.isStringLiteral(node) ||\n ts.isNoSubstitutionTemplateLiteral(node) ||\n ts.isTemplateExpression(node) ||\n ts.isRegularExpressionLiteral(node) ||\n ts.isArrayLiteralExpression(node) ||\n ts.isObjectLiteralExpression(node) ||\n node.kind === ts.SyntaxKind.TrueKeyword ||\n node.kind === ts.SyntaxKind.FalseKeyword ||\n node.kind === ts.SyntaxKind.NullKeyword;\n\n /** An options literal whose `defaultValue` is a literal that is not a number (`{ defaultValue: '10' }`). */\n const hasNonNumericDefault = (node: import('typescript').Expression | undefined): boolean =>\n node !== undefined &&\n ts.isObjectLiteralExpression(node) &&\n node.properties.some(\n (property) =>\n ts.isPropertyAssignment(property) &&\n (ts.isIdentifier(property.name) || ts.isStringLiteral(property.name)) &&\n property.name.text === 'defaultValue' &&\n isNonNumericLiteral(property.initializer),\n );\n\n /** The import specifier the file already has for `ParseUtility`: a value import from the store module, under any local name. */\n const findParseUtilityImport = (): import('typescript').ImportSpecifier | undefined => {\n for (const statement of file.statements) {\n if (\n ts.isImportDeclaration(statement) &&\n ts.isStringLiteral(statement.moduleSpecifier) &&\n STORE_MODULE.test(statement.moduleSpecifier.text) &&\n statement.importClause?.namedBindings !== undefined &&\n ts.isNamedImports(statement.importClause.namedBindings)\n ) {\n const element = statement.importClause.namedBindings.elements.find(\n (candidate) =>\n (candidate.propertyName ?? candidate.name).text === 'ParseUtility' &&\n !candidate.isTypeOnly &&\n !statement.importClause?.isTypeOnly,\n );\n\n if (element !== undefined) {\n return element;\n }\n }\n }\n\n return undefined;\n };\n\n /**\n * The local name `call` can use for `ParseUtility`, or the reason it cannot. The name resolves from the\n * scope of the call, the way the store receiver does: the file's own import of `ParseUtility` from the store\n * module (under any local name) when it is the binding the call sees, a new `ParseUtility` import when\n * nothing in the file or in a scope around the call declares that name. Another module's `ParseUtility`, a\n * type-only import of it, a local declaration of it and a parameter that shadows it all leave the call manual,\n * because the rewrite would not compile (TS2300, TS2339).\n */\n const resolveParseUtility = (\n call: import('typescript').CallExpression,\n ): { name: string } | { reason: string } => {\n const existing = findParseUtilityImport();\n const name = existing?.name.text ?? 'ParseUtility';\n let found: import('typescript').Node | undefined;\n let isFileLevel = false;\n\n for (\n let scope: import('typescript').Node | undefined = call.parent;\n scope !== undefined && found === undefined;\n scope = scope.parent\n ) {\n found = EnvGet.declarationIn({ typescript: ts, scope, name });\n isFileLevel = ts.isSourceFile(scope);\n }\n\n if (found === existing) {\n return { name };\n }\n\n return {\n reason: isFileLevel\n ? `${name} is already declared in this file by something other than a value import from @venizia/ignis-helpers (an import from another module, a type-only import or a local declaration): the rewrite would not compile, so import ParseUtility from @venizia/ignis-helpers under a free name and write the transform by hand`\n : `a parameter or local declaration named ${name} hides the ParseUtility import at this call: the rewrite would not compile, so write the transform by hand or rename the local`,\n };\n };\n\n /** Adds `ParseUtility` to the import of the store, once per file: on its own line inside a multi-line import, after the last name in a one-line one, in a new import beside a type-only one. */\n const addParseUtilityImport = (storeImport: import('typescript').ImportSpecifier): void => {\n if (isParseUtilityImported || findParseUtilityImport() !== undefined) {\n return;\n }\n\n isParseUtilityImported = true;\n\n const declaration = storeImport.parent.parent.parent;\n const named = storeImport.parent;\n\n if (declaration.importClause?.isTypeOnly) {\n edits.push({\n start: declaration.getEnd(),\n end: declaration.getEnd(),\n text: `\\nimport { ParseUtility } from ${declaration.moduleSpecifier.getText(file)};`,\n });\n\n return;\n }\n\n const last = named.elements[named.elements.length - 1];\n const lastLine = file.getLineAndCharacterOfPosition(last.getStart(file)).line;\n const isMultiLine = file.getLineAndCharacterOfPosition(named.getStart(file)).line < lastLine;\n\n if (!isMultiLine) {\n edits.push({ start: last.getEnd(), end: last.getEnd(), text: ', ParseUtility' });\n\n return;\n }\n\n const lineStart = file.getLineStarts()[lastLine];\n const indent = source.slice(lineStart, last.getStart(file)).match(/^\\s*/)?.[0] ?? '';\n const lineBreak = source.includes('\\r\\n') ? '\\r\\n' : '\\n';\n\n edits.push({\n start: last.getEnd(),\n end: last.getEnd(),\n text: `,${lineBreak}${indent}ParseUtility`,\n });\n };\n\n /** Puts `transform` first in the options literal, keeping its layout: `{}` becomes `{ transform }`, a multi-line literal gets the property on its own line. */\n const insertTransform = (\n options: import('typescript').ObjectLiteralExpression,\n transform: string,\n ): void => {\n const open = options.getStart(file) + 1;\n const [first] = options.properties;\n\n if (first === undefined) {\n const inner = source.slice(open, options.getEnd() - 1);\n\n edits.push(\n inner.trim() === ''\n ? { start: open, end: options.getEnd() - 1, text: ` ${transform} ` }\n : { start: open, end: open, text: ` ${transform}` },\n );\n\n return;\n }\n\n const between = source.slice(open, first.getStart(file));\n\n if (between.includes('\\n')) {\n const firstLineStart =\n file.getLineStarts()[file.getLineAndCharacterOfPosition(first.getStart(file)).line];\n const indent = source.slice(firstLineStart, first.getStart(file)).match(/^\\s*/)?.[0] ?? '';\n const lineBreak = between.includes('\\r\\n') ? '\\r\\n' : '\\n';\n\n edits.push({ start: open, end: open, text: `${lineBreak}${indent}${transform},` });\n\n return;\n }\n\n edits.push({\n start: open,\n end: open,\n text: ` ${transform},${/^\\s/.test(between) ? '' : ' '}`,\n });\n };\n\n const visit = (node: import('typescript').Node): void => {\n if (\n ts.isCallExpression(node) &&\n node.typeArguments !== undefined &&\n ts.isPropertyAccessExpression(node.expression) &&\n node.expression.name.text === 'get'\n ) {\n const callee = node.expression;\n const isOptional =\n node.questionDotToken !== undefined || callee.questionDotToken !== undefined;\n\n const storeImport =\n !isOptional && ts.isIdentifier(callee.expression)\n ? EnvGet.storeImport({ typescript: ts, identifier: callee.expression })\n : undefined;\n\n if (storeImport !== undefined) {\n const [first] = node.typeArguments;\n const start = callee.name.getEnd();\n const end = node.arguments.pos - 1;\n const options = node.arguments[1];\n const isTwo = node.typeArguments.length === 2;\n const isPlainLiteral =\n options !== undefined &&\n ts.isObjectLiteralExpression(options) &&\n !hasTransform(options);\n // `get<number>(key)`, `get<number>(key, { defaultValue })` and `get<number, B>(key, { defaultValue })` are one read.\n const isNumberRead =\n numbers &&\n isNumberType(first) &&\n ((!isTwo &&\n !hasTransform(options) &&\n (options === undefined || ts.isObjectLiteralExpression(options))) ||\n (isTwo && isPlainLiteral));\n // `--numbers`: a number read (one type argument or two) with options the codemod cannot read. It cannot see\n // whether they hold a transform, so the call is listed, not left silently.\n const isNumberReadWithVariableOptions =\n numbers &&\n isNumberType(first) &&\n options !== undefined &&\n !ts.isObjectLiteralExpression(options);\n\n if (isNumberReadWithVariableOptions) {\n manual.push({\n line: lineOf(node),\n type: first.getText(file),\n reason:\n 'the options are not an object literal, so the codemod cannot see whether they hold a transform: put the number transform in them by hand, for example { ...options, transform: (raw) => ParseUtility.toNumber({ input: raw }) }',\n });\n } else if (isNumberRead) {\n const parseUtility = resolveParseUtility(node);\n\n if ('reason' in parseUtility) {\n manual.push({\n line: lineOf(node),\n type: first.getText(file),\n reason: parseUtility.reason,\n });\n } else if (hasNonNumericDefault(options)) {\n manual.push({\n line: lineOf(node),\n type: first.getText(file),\n reason:\n 'the defaultValue is a literal that is not a number: the rewritten call matches no overload (and would return that value as it is), so give it a number or convert it where you use it',\n });\n } else {\n addParseUtilityImport(storeImport);\n\n const transform = `transform: (raw) => ${parseUtility.name}.toNumber({ input: raw })`;\n\n edits.push({ start, end, text: '' });\n\n if (options !== undefined && ts.isObjectLiteralExpression(options)) {\n insertTransform(options, transform);\n } else {\n const insertAt = node.arguments[0].getEnd();\n\n edits.push({ start: insertAt, end: insertAt, text: `, { ${transform} }` });\n }\n\n numbered.push(lineOf(node));\n rewrittenCalls += 1;\n }\n } else if (isTwo && options !== undefined && !ts.isObjectLiteralExpression(options)) {\n // `get<R, B>(key, options)` with options in a variable: the codemod cannot see whether they hold a\n // transform or a default of the right type, and `get<R>(key, options)` may not compile with them.\n manual.push({\n line: lineOf(node),\n type: first.getText(file),\n reason:\n 'two type arguments and options that are not an object literal, so the codemod cannot see what they hold: drop the second type argument by hand once the options carry a transform',\n });\n } else if (isTwo && hasTransform(options)) {\n // `get<R, B>(key, { transform })` keeps R, even when R is `string`: a second run leaves\n // `get<string>(key, { transform })` alone.\n edits.push({ start, end, text: `<${first.getText(file)}>` });\n rewrittenCalls += 1;\n } else if (\n !isTwo &&\n options !== undefined &&\n (hasTransform(options) || !ts.isObjectLiteralExpression(options))\n ) {\n // One type argument and a transform: the new form. One type argument and options that are not a\n // literal (a variable): the codemod cannot see what they hold, and what it just left in\n // `get<R, B>(key, options)` would otherwise be listed on the next run; the typecheck names a bad one.\n // Nothing to do and nothing to list.\n } else if (isStringType(first) && (!isTwo || isPlainLiteral)) {\n // `string` is what get() returns without a transform, so the type arguments carry nothing: a literal\n // without a transform reads the same with one type argument or two.\n edits.push({ start, end, text: '' });\n rewrittenCalls += 1;\n } else {\n manual.push({ line: lineOf(node), type: first.getText(file) });\n }\n } else if (node.arguments.length > 0 && !ts.isObjectLiteralExpression(node.arguments[0])) {\n // Every other `x.get<T>(key)` is listed, never hidden: a name the file does not bind to the store, a\n // property, a parameter or an optional chain. A container lookup shares the shape (its first\n // argument is an object literal, so it is not listed).\n skipped.push({ line: lineOf(node), receiver: callee.expression.getText(file) });\n }\n }\n\n ts.forEachChild(node, visit);\n };\n\n visit(file);\n\n if (edits.length === 0) {\n return { output: source, changed: false, rewritten: 0, manual, numbered, skipped };\n }\n\n let output = source;\n\n for (const edit of [...edits].sort((left, right) => right.start - left.start)) {\n output = output.slice(0, edit.start) + edit.text + output.slice(edit.end);\n }\n\n return {\n output,\n changed: output !== source,\n rewritten: rewrittenCalls,\n manual,\n numbered,\n skipped,\n };\n }\n}\n\n/** `devz codemod env-get [paths...] [--write | --check]`: rewrites the type arguments of `applicationEnvironment.get()`. */\nexport class EnvGetCommand {\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(EnvGetFlags.HELP) || args.includes(EnvGetFlags.HELP_SHORT)) {\n console.log(USAGE);\n\n return 0;\n }\n\n const flags = args.filter((argument) => argument.startsWith('-'));\n const paths = args.filter((argument) => !argument.startsWith('-'));\n const unknown = flags.filter((flag) => !EnvGetFlags.isValid(flag));\n\n if (unknown.length > 0) {\n console.error(\n `devz codemod: unknown option ${unknown.map((flag) => `\"${flag}\"`).join(', ')}\\n${USAGE}`,\n );\n\n return USAGE_ERROR_CODE;\n }\n\n const isWrite = flags.includes(EnvGetFlags.WRITE);\n const isCheck = flags.includes(EnvGetFlags.CHECK);\n const isNumbers = flags.includes(EnvGetFlags.NUMBERS);\n\n if (isWrite && isCheck) {\n console.error(\n `devz codemod: ${EnvGetFlags.WRITE} and ${EnvGetFlags.CHECK} contradict each other\\n${USAGE}`,\n );\n\n return USAGE_ERROR_CODE;\n }\n\n const refusal = CodemodFiles.refusal({\n command: 'env-get',\n isWrite,\n isAll: flags.includes(EnvGetFlags.ALL),\n paths,\n });\n\n if (refusal) {\n console.error(`${refusal}\\n${USAGE}`);\n\n return USAGE_ERROR_CODE;\n }\n\n let typescript: typeof import('typescript');\n\n try {\n const loaded = await import('typescript');\n typescript = loaded.default;\n } catch {\n console.error('devz codemod: the \"typescript\" package is required to read your sources');\n\n return 1;\n }\n\n const targets = (paths.length > 0 ? paths : ['.']).map((path) => resolve(root, path));\n let changedCount = 0;\n let callCount = 0;\n let manualCount = 0;\n let skippedCount = 0;\n let numberedCount = 0;\n const manualByType = new Map<string, number>();\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 (!/\\.\\s*get\\b/.test(source)) {\n continue;\n }\n\n const result = EnvGet.rewrite({\n typescript,\n fileName: file,\n source,\n numbers: isNumbers,\n });\n const shown = relative(root, file).split('\\\\').join('/') || file;\n\n for (const item of result.manual) {\n manualCount += 1;\n manualByType.set(item.type, (manualByType.get(item.type) ?? 0) + 1);\n console.warn(\n `manual ${shown}:${item.line} get<${item.type}>: ${\n item.reason ??\n 'a type argument the rewrite cannot place (not string or string | undefined, or two type arguments without an options argument): a number or other conversion goes in a transform, for example get(key, { transform: Number })'\n }`,\n );\n }\n\n for (const line of result.numbered) {\n numberedCount += 1;\n console.log(\n `numbers ${shown}:${line} get<number> rewritten to a transform: the value is now a real number and a non-numeric value throws at the read`,\n );\n }\n\n for (const call of result.skipped) {\n skippedCount += 1;\n console.warn(\n `skipped ${shown}:${call.line} ${call.receiver}.get<...>(): the receiver is not bound to applicationEnvironment or AppEnvs in this file (a property, a parameter, an optional chain or another object): check it by hand if it is the environment store`,\n );\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 env-get: ${changedCount} file(s) ${isWrite ? 'changed' : 'would change'}, ${callCount} call(s) ${isWrite ? 'rewritten' : 'would be rewritten'}, ${manualCount} manual, ${skippedCount} skipped` +\n (isNumbers ? `, ${numberedCount} number read(s) rewritten` : '') +\n (refusedCount > 0 ? `, ${refusedCount} refused` : ''),\n );\n\n if (manualByType.size > 0) {\n const counts = [...manualByType.entries()]\n .sort((left, right) => right[1] - left[1])\n .map(([typeText, count]) => `${typeText} x${count}`)\n .join(', ');\n\n console.log(`manual by type argument: ${counts}`);\n }\n\n if (!isWrite && changedCount > 0) {\n console.log(\n `Nothing was written. Run again with ${EnvGetFlags.WRITE} to apply, then run your typecheck.`,\n );\n }\n\n if (isWrite && refusedCount > 0) {\n return 1;\n }\n\n return isCheck && (changed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C,WAAW,CAAC,CAAC,CAAC,oBAAoB,KAAK,WAAW,YAAY,YAAY,UAAU;YAC3M,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,aAAa,2BAA2B,CAAC,CAAC,CAAC,EAAE,CAAC;YAChE,CAAC,YAAY,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,YAAY,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,CACxD,CAAC;QAEF,IAAI,YAAY,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;YAC1B,MAAM,MAAM,GAAG,CAAC,GAAG,YAAY,CAAC,OAAO,EAAE,CAAC;iBACvC,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;iBACzC,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,GAAG,QAAQ,KAAK,KAAK,EAAE,CAAC;iBACnD,IAAI,CAAC,IAAI,CAAC,CAAC;YAEd,OAAO,CAAC,GAAG,CAAC,4BAA4B,MAAM,EAAE,CAAC,CAAC;QACpD,CAAC;QAED,IAAI,CAAC,OAAO,IAAI,YAAY,GAAG,CAAC,EAAE,CAAC;YACjC,OAAO,CAAC,GAAG,CACT,uCAAuC,WAAW,CAAC,KAAK,qCAAqC,CAC9F,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;;AAzKH,sCA0KC","sourcesContent":["import { readFileSync, writeFileSync } from 'node:fs';\nimport { relative, resolve } from 'node:path';\nimport { CodemodFiles } from './files';\n\nconst USAGE = `Usage: devz codemod env-get [paths...] [--write [--all] | --check]\n\nRewrites the type arguments of applicationEnvironment.get() (and its alias AppEnvs.get()) for the\n@venizia/ignis-helpers release where get() reads strings:\n\n get<string>(key) becomes get(key)\n get<string | undefined>(key) becomes get(key)\n get<string>(key, { defaultValue }) becomes get(key, { defaultValue })\n get<R, B>(key, { transform }) becomes get<R>(key, { transform })\n\nAny other type argument (get<number>(key), get<boolean>(key)) was a cast the new get() no longer allows:\nthe codemod lists it as \"manual\" and leaves it. Move the conversion into a transform, or read the\nstring and convert it where you use it: get(key, { transform: Number }).\n\nA call already in the new form (one type argument and an options literal with a transform) is left alone\nand not listed, and a second run changes nothing.\n\nIt reads TypeScript files (.ts, .tsx, .mts, .cts) and rewrites only calls whose receiver resolves, from the\nscope of the call, to the store: a name imported as applicationEnvironment or AppEnvs from @venizia/ignis,\n@venizia/ignis-helpers (or a sub-path), under any local name (import { AppEnvs as Envs } ...), or a const\ninitialised from such a name in the same or an enclosing scope. A parameter, a local variable, an import from\nanywhere else (a barrel of your own included) and a name nothing declares are not the store. Every other\nget<...>(key) call (a property, an optional chain, those names) is printed as skipped with its file and line,\nand a call with a type argument it cannot place as manual, so run your typecheck after it. A call with one type argument and options\nthat are not a literal (a variable) is left alone and not listed; one with two type arguments and such options is listed as manual, and so is a number read with such options under --numbers (the codemod cannot see what the options hold). A var declared in a nested block counts as block-scoped (a hoisted one is not followed). A comment between the method name and the parenthesis is dropped. A .js, .cjs or .mjs file\nis not read: edit it by hand.\n\n --write write the changed files (without it, nothing is written); it needs a path, or --all\n --all with --write and no path: rewrite every source file under the working directory\n --numbers also rewrite the number reads: get<number>(key) and get<number>(key, { defaultValue }) become\n get(key, { transform: (raw) => ParseUtility.toNumber({ input: raw }), defaultValue }) and\n ParseUtility joins the import of the store. Every rewrite is listed (\"numbers\"). The old call returned\n the environment STRING typed as a number: after the rewrite the read converts it to a number, an unset\n variable still answers undefined (or the default), and a non-numeric value throws at the read\n instead of flowing on as a string. A boolean (the \"false\" string is truthy) stays manual. So does a number\n read the rewrite would not compile: a defaultValue that is a literal but not a number ('10'), options that\n are a variable, a ParseUtility name the file already declares for something else (an import from another\n module, a type-only import, a local), and a parameter or local named ParseUtility at the call.\n --check dry run that exits 1 while a file would change or a manual call remains (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 files\ngit knows, and --write refuses a file with local changes: commit, stash or \"git add\" it first, so git can undo it.\nThere is no --reverse: a downgrade restores the files from git.`;\n\n/** A usage error: nothing was read or written. */\nconst USAGE_ERROR_CODE = 2;\n\n/** The names the environment store is exported under, and so the receivers `get()` is called on. */\nconst RECEIVERS = new Set(['applicationEnvironment', 'AppEnvs']);\n\n/** A module that exports the store: the root package and the helpers package, with or without a subpath. */\nconst STORE_MODULE = /^@venizia\\/ignis(?:-helpers)?(?:\\/.*)?$/;\n\nclass EnvGetFlags {\n static readonly WRITE = '--write';\n static readonly ALL = '--all';\n static readonly NUMBERS = '--numbers';\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.ALL,\n this.NUMBERS,\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\nexport interface IEnvGetResult {\n output: string;\n changed: boolean;\n /** How many calls were rewritten. */\n rewritten: number;\n /** The store calls the codemod cannot rewrite: file line (1-based), the first type argument and, when the cause is not the type argument itself, the reason. */\n manual: Array<{ line: number; type: string; reason?: string }>;\n /** With `--numbers`: the lines of the number reads rewritten to a transform (they are counted in `rewritten` too). */\n numbered: number[];\n /** The `get<...>(key)` calls on a receiver the file does not bind to the store (or through an optional chain), left alone and listed: file line (1-based) and the receiver text. */\n skipped: Array<{ line: number; receiver: string }>;\n}\n\n/** Rewrites the type arguments of `applicationEnvironment.get()` calls. */\nexport class EnvGet {\n /** The names a declaration in `node` binds, for `node` a scope: a block or file, a function, a loop or a catch clause. */\n private static declarationIn(opts: {\n typescript: typeof import('typescript');\n scope: import('typescript').Node;\n name: string;\n }): import('typescript').Node | undefined {\n const { typescript: ts, scope, name } = opts;\n\n const bindingNames = (node: import('typescript').BindingName): string[] => {\n if (ts.isIdentifier(node)) {\n return [node.text];\n }\n\n return node.elements.flatMap((element) =>\n ts.isBindingElement(element) ? bindingNames(element.name) : [],\n );\n };\n\n const inDeclarations = (\n declarations: ReadonlyArray<import('typescript').VariableDeclaration>,\n ): import('typescript').Node | undefined =>\n declarations.find((declaration) => bindingNames(declaration.name).includes(name));\n\n if (\n ts.isSourceFile(scope) ||\n ts.isBlock(scope) ||\n ts.isModuleBlock(scope) ||\n ts.isCaseClause(scope) ||\n ts.isDefaultClause(scope)\n ) {\n for (const statement of scope.statements) {\n if (ts.isVariableStatement(statement)) {\n const found = inDeclarations(statement.declarationList.declarations);\n\n if (found !== undefined) {\n return found;\n }\n } else if (\n (ts.isFunctionDeclaration(statement) ||\n ts.isClassDeclaration(statement) ||\n ts.isEnumDeclaration(statement)) &&\n statement.name?.text === name\n ) {\n return statement;\n } else if (ts.isImportDeclaration(statement) && statement.importClause !== undefined) {\n const clause = statement.importClause;\n\n if (clause.name?.text === name) {\n return clause;\n }\n\n const bindings = clause.namedBindings;\n\n if (\n bindings !== undefined &&\n ts.isNamespaceImport(bindings) &&\n bindings.name.text === name\n ) {\n return bindings;\n }\n\n if (bindings !== undefined && ts.isNamedImports(bindings)) {\n const element = bindings.elements.find((candidate) => candidate.name.text === name);\n\n if (element !== undefined) {\n return element;\n }\n }\n }\n }\n\n return undefined;\n }\n\n if (ts.isFunctionLike(scope)) {\n const parameter = scope.parameters.find((candidate) =>\n bindingNames(candidate.name).includes(name),\n );\n\n if (parameter !== undefined) {\n return parameter;\n }\n\n return ts.isFunctionExpression(scope) && scope.name?.text === name ? scope : undefined;\n }\n\n if (\n (ts.isForStatement(scope) || ts.isForOfStatement(scope) || ts.isForInStatement(scope)) &&\n scope.initializer !== undefined &&\n ts.isVariableDeclarationList(scope.initializer)\n ) {\n return inDeclarations(scope.initializer.declarations);\n }\n\n if (ts.isCatchClause(scope) && scope.variableDeclaration !== undefined) {\n return inDeclarations([scope.variableDeclaration]);\n }\n\n return undefined;\n }\n\n /**\n * Whether `identifier` refers to the environment store: the binding the name resolves to, from the\n * innermost scope outwards, is an import of `applicationEnvironment` or `AppEnvs` from the store module\n * (aliased or not), or a `const` that is initialised from such a name. A parameter, a local, an import\n * from anywhere else and a name nothing declares are not the store.\n */\n static isStore(opts: {\n typescript: typeof import('typescript');\n identifier: import('typescript').Identifier;\n }): boolean {\n return EnvGet.storeImport(opts) !== undefined;\n }\n\n /** The import specifier of the store that `identifier` resolves to (through const aliases), or `undefined` when it is not the store. */\n static storeImport(opts: {\n typescript: typeof import('typescript');\n identifier: import('typescript').Identifier;\n seen?: Set<import('typescript').Node>;\n }): import('typescript').ImportSpecifier | undefined {\n const { typescript: ts, identifier } = opts;\n const seen = opts.seen ?? new Set<import('typescript').Node>();\n\n if (seen.has(identifier)) {\n return undefined;\n }\n\n seen.add(identifier);\n\n for (\n let scope: import('typescript').Node | undefined = identifier.parent;\n scope !== undefined;\n scope = scope.parent\n ) {\n const declaration = EnvGet.declarationIn({ typescript: ts, scope, name: identifier.text });\n\n if (declaration === undefined) {\n continue;\n }\n\n if (ts.isImportSpecifier(declaration)) {\n const importDeclaration = declaration.parent.parent.parent;\n\n return ts.isStringLiteral(importDeclaration.moduleSpecifier) &&\n STORE_MODULE.test(importDeclaration.moduleSpecifier.text) &&\n RECEIVERS.has((declaration.propertyName ?? declaration.name).text)\n ? declaration\n : undefined;\n }\n\n if (\n ts.isVariableDeclaration(declaration) &&\n (ts.getCombinedNodeFlags(declaration) & ts.NodeFlags.Const) !== 0 &&\n ts.isIdentifier(declaration.name) &&\n declaration.initializer !== undefined &&\n ts.isIdentifier(declaration.initializer)\n ) {\n return EnvGet.storeImport({ typescript: ts, identifier: declaration.initializer, seen });\n }\n\n return undefined;\n }\n\n return undefined;\n }\n\n static rewrite(opts: {\n typescript: typeof import('typescript');\n fileName: string;\n source: string;\n /** `--numbers`: rewrite `get<number>(key)` and `get<number>(key, { defaultValue })` to a `ParseUtility.toNumber` transform. */\n numbers?: boolean;\n }): IEnvGetResult {\n const { typescript: ts, fileName, source, numbers = false } = opts;\n const language = fileName.endsWith('.tsx') ? ts.ScriptKind.TSX : ts.ScriptKind.TS;\n const file = ts.createSourceFile(fileName, source, ts.ScriptTarget.Latest, true, language);\n const edits: Array<{ start: number; end: number; text: string }> = [];\n const manual: Array<{ line: number; type: string; reason?: string }> = [];\n const skipped: Array<{ line: number; receiver: string }> = [];\n const numbered: number[] = [];\n let rewrittenCalls = 0;\n let isParseUtilityImported = false;\n const lineOf = (node: import('typescript').Node): number =>\n file.getLineAndCharacterOfPosition(node.getStart(file)).line + 1;\n\n /** `string`, or `string | undefined` (the type `get(key)` already answers): the type argument can go. */\n const isStringType = (node: import('typescript').TypeNode): boolean => {\n if (node.kind === ts.SyntaxKind.StringKeyword) {\n return true;\n }\n\n if (ts.isParenthesizedTypeNode(node)) {\n return isStringType(node.type);\n }\n\n if (ts.isUnionTypeNode(node) && node.types.length === 2) {\n const parts = node.types.map((part) => part.kind);\n\n return (\n parts.includes(ts.SyntaxKind.StringKeyword) &&\n parts.includes(ts.SyntaxKind.UndefinedKeyword)\n );\n }\n\n return false;\n };\n\n /** An options literal that already carries a `transform`: the call is in the new form. */\n const hasTransform = (node: import('typescript').Expression | undefined): boolean =>\n node !== undefined &&\n ts.isObjectLiteralExpression(node) &&\n node.properties.some(\n (property) =>\n property.name !== undefined &&\n ts.isIdentifier(property.name) &&\n property.name.text === 'transform',\n );\n\n /** `number`, or `number | undefined`: the types `--numbers` rewrites. */\n const isNumberType = (node: import('typescript').TypeNode): boolean => {\n if (node.kind === ts.SyntaxKind.NumberKeyword) {\n return true;\n }\n\n if (ts.isParenthesizedTypeNode(node)) {\n return isNumberType(node.type);\n }\n\n if (ts.isUnionTypeNode(node) && node.types.length === 2) {\n const parts = node.types.map((part) => part.kind);\n\n return (\n parts.includes(ts.SyntaxKind.NumberKeyword) &&\n parts.includes(ts.SyntaxKind.UndefinedKeyword)\n );\n }\n\n return false;\n };\n\n /** A literal that is not a number: a `defaultValue` of this kind matches no overload of the rewritten call. */\n const isNonNumericLiteral = (node: import('typescript').Expression): boolean =>\n ts.isStringLiteral(node) ||\n ts.isNoSubstitutionTemplateLiteral(node) ||\n ts.isTemplateExpression(node) ||\n ts.isRegularExpressionLiteral(node) ||\n ts.isArrayLiteralExpression(node) ||\n ts.isObjectLiteralExpression(node) ||\n node.kind === ts.SyntaxKind.TrueKeyword ||\n node.kind === ts.SyntaxKind.FalseKeyword ||\n node.kind === ts.SyntaxKind.NullKeyword;\n\n /** An options literal whose `defaultValue` is a literal that is not a number (`{ defaultValue: '10' }`). */\n const hasNonNumericDefault = (node: import('typescript').Expression | undefined): boolean =>\n node !== undefined &&\n ts.isObjectLiteralExpression(node) &&\n node.properties.some(\n (property) =>\n ts.isPropertyAssignment(property) &&\n (ts.isIdentifier(property.name) || ts.isStringLiteral(property.name)) &&\n property.name.text === 'defaultValue' &&\n isNonNumericLiteral(property.initializer),\n );\n\n /** The import specifier the file already has for `ParseUtility`: a value import from the store module, under any local name. */\n const findParseUtilityImport = (): import('typescript').ImportSpecifier | undefined => {\n for (const statement of file.statements) {\n if (\n ts.isImportDeclaration(statement) &&\n ts.isStringLiteral(statement.moduleSpecifier) &&\n STORE_MODULE.test(statement.moduleSpecifier.text) &&\n statement.importClause?.namedBindings !== undefined &&\n ts.isNamedImports(statement.importClause.namedBindings)\n ) {\n const element = statement.importClause.namedBindings.elements.find(\n (candidate) =>\n (candidate.propertyName ?? candidate.name).text === 'ParseUtility' &&\n !candidate.isTypeOnly &&\n !statement.importClause?.isTypeOnly,\n );\n\n if (element !== undefined) {\n return element;\n }\n }\n }\n\n return undefined;\n };\n\n /**\n * The local name `call` can use for `ParseUtility`, or the reason it cannot. The name resolves from the\n * scope of the call, the way the store receiver does: the file's own import of `ParseUtility` from the store\n * module (under any local name) when it is the binding the call sees, a new `ParseUtility` import when\n * nothing in the file or in a scope around the call declares that name. Another module's `ParseUtility`, a\n * type-only import of it, a local declaration of it and a parameter that shadows it all leave the call manual,\n * because the rewrite would not compile (TS2300, TS2339).\n */\n const resolveParseUtility = (\n call: import('typescript').CallExpression,\n ): { name: string } | { reason: string } => {\n const existing = findParseUtilityImport();\n const name = existing?.name.text ?? 'ParseUtility';\n let found: import('typescript').Node | undefined;\n let isFileLevel = false;\n\n for (\n let scope: import('typescript').Node | undefined = call.parent;\n scope !== undefined && found === undefined;\n scope = scope.parent\n ) {\n found = EnvGet.declarationIn({ typescript: ts, scope, name });\n isFileLevel = ts.isSourceFile(scope);\n }\n\n if (found === existing) {\n return { name };\n }\n\n return {\n reason: isFileLevel\n ? `${name} is already declared in this file by something other than a value import from @venizia/ignis-helpers (an import from another module, a type-only import or a local declaration): the rewrite would not compile, so import ParseUtility from @venizia/ignis-helpers under a free name and write the transform by hand`\n : `a parameter or local declaration named ${name} hides the ParseUtility import at this call: the rewrite would not compile, so write the transform by hand or rename the local`,\n };\n };\n\n /** Adds `ParseUtility` to the import of the store, once per file: on its own line inside a multi-line import, after the last name in a one-line one, in a new import beside a type-only one. */\n const addParseUtilityImport = (storeImport: import('typescript').ImportSpecifier): void => {\n if (isParseUtilityImported || findParseUtilityImport() !== undefined) {\n return;\n }\n\n isParseUtilityImported = true;\n\n const declaration = storeImport.parent.parent.parent;\n const named = storeImport.parent;\n\n if (declaration.importClause?.isTypeOnly) {\n edits.push({\n start: declaration.getEnd(),\n end: declaration.getEnd(),\n text: `\\nimport { ParseUtility } from ${declaration.moduleSpecifier.getText(file)};`,\n });\n\n return;\n }\n\n const last = named.elements[named.elements.length - 1];\n const lastLine = file.getLineAndCharacterOfPosition(last.getStart(file)).line;\n const isMultiLine = file.getLineAndCharacterOfPosition(named.getStart(file)).line < lastLine;\n\n if (!isMultiLine) {\n edits.push({ start: last.getEnd(), end: last.getEnd(), text: ', ParseUtility' });\n\n return;\n }\n\n const lineStart = file.getLineStarts()[lastLine];\n const indent = source.slice(lineStart, last.getStart(file)).match(/^\\s*/)?.[0] ?? '';\n const lineBreak = source.includes('\\r\\n') ? '\\r\\n' : '\\n';\n\n edits.push({\n start: last.getEnd(),\n end: last.getEnd(),\n text: `,${lineBreak}${indent}ParseUtility`,\n });\n };\n\n /** Puts `transform` first in the options literal, keeping its layout: `{}` becomes `{ transform }`, a multi-line literal gets the property on its own line. */\n const insertTransform = (\n options: import('typescript').ObjectLiteralExpression,\n transform: string,\n ): void => {\n const open = options.getStart(file) + 1;\n const [first] = options.properties;\n\n if (first === undefined) {\n const inner = source.slice(open, options.getEnd() - 1);\n\n edits.push(\n inner.trim() === ''\n ? { start: open, end: options.getEnd() - 1, text: ` ${transform} ` }\n : { start: open, end: open, text: ` ${transform}` },\n );\n\n return;\n }\n\n const between = source.slice(open, first.getStart(file));\n\n if (between.includes('\\n')) {\n const firstLineStart =\n file.getLineStarts()[file.getLineAndCharacterOfPosition(first.getStart(file)).line];\n const indent = source.slice(firstLineStart, first.getStart(file)).match(/^\\s*/)?.[0] ?? '';\n const lineBreak = between.includes('\\r\\n') ? '\\r\\n' : '\\n';\n\n edits.push({ start: open, end: open, text: `${lineBreak}${indent}${transform},` });\n\n return;\n }\n\n edits.push({\n start: open,\n end: open,\n text: ` ${transform},${/^\\s/.test(between) ? '' : ' '}`,\n });\n };\n\n const visit = (node: import('typescript').Node): void => {\n if (\n ts.isCallExpression(node) &&\n node.typeArguments !== undefined &&\n ts.isPropertyAccessExpression(node.expression) &&\n node.expression.name.text === 'get'\n ) {\n const callee = node.expression;\n const isOptional =\n node.questionDotToken !== undefined || callee.questionDotToken !== undefined;\n\n const storeImport =\n !isOptional && ts.isIdentifier(callee.expression)\n ? EnvGet.storeImport({ typescript: ts, identifier: callee.expression })\n : undefined;\n\n if (storeImport !== undefined) {\n const [first] = node.typeArguments;\n const start = callee.name.getEnd();\n const end = node.arguments.pos - 1;\n const options = node.arguments[1];\n const isTwo = node.typeArguments.length === 2;\n const isPlainLiteral =\n options !== undefined &&\n ts.isObjectLiteralExpression(options) &&\n !hasTransform(options);\n // `get<number>(key)`, `get<number>(key, { defaultValue })` and `get<number, B>(key, { defaultValue })` are one read.\n const isNumberRead =\n numbers &&\n isNumberType(first) &&\n ((!isTwo &&\n !hasTransform(options) &&\n (options === undefined || ts.isObjectLiteralExpression(options))) ||\n (isTwo && isPlainLiteral));\n // `--numbers`: a number read (one type argument or two) with options the codemod cannot read. It cannot see\n // whether they hold a transform, so the call is listed, not left silently.\n const isNumberReadWithVariableOptions =\n numbers &&\n isNumberType(first) &&\n options !== undefined &&\n !ts.isObjectLiteralExpression(options);\n\n if (isNumberReadWithVariableOptions) {\n manual.push({\n line: lineOf(node),\n type: first.getText(file),\n reason:\n 'the options are not an object literal, so the codemod cannot see whether they hold a transform: put the number transform in them by hand, for example { ...options, transform: (raw) => ParseUtility.toNumber({ input: raw }) }',\n });\n } else if (isNumberRead) {\n const parseUtility = resolveParseUtility(node);\n\n if ('reason' in parseUtility) {\n manual.push({\n line: lineOf(node),\n type: first.getText(file),\n reason: parseUtility.reason,\n });\n } else if (hasNonNumericDefault(options)) {\n manual.push({\n line: lineOf(node),\n type: first.getText(file),\n reason:\n 'the defaultValue is a literal that is not a number: the rewritten call matches no overload (and would return that value as it is), so give it a number or convert it where you use it',\n });\n } else {\n addParseUtilityImport(storeImport);\n\n const transform = `transform: (raw) => ${parseUtility.name}.toNumber({ input: raw })`;\n\n edits.push({ start, end, text: '' });\n\n if (options !== undefined && ts.isObjectLiteralExpression(options)) {\n insertTransform(options, transform);\n } else {\n const insertAt = node.arguments[0].getEnd();\n\n edits.push({ start: insertAt, end: insertAt, text: `, { ${transform} }` });\n }\n\n numbered.push(lineOf(node));\n rewrittenCalls += 1;\n }\n } else if (isTwo && options !== undefined && !ts.isObjectLiteralExpression(options)) {\n // `get<R, B>(key, options)` with options in a variable: the codemod cannot see whether they hold a\n // transform or a default of the right type, and `get<R>(key, options)` may not compile with them.\n manual.push({\n line: lineOf(node),\n type: first.getText(file),\n reason:\n 'two type arguments and options that are not an object literal, so the codemod cannot see what they hold: drop the second type argument by hand once the options carry a transform',\n });\n } else if (isTwo && hasTransform(options)) {\n // `get<R, B>(key, { transform })` keeps R, even when R is `string`: a second run leaves\n // `get<string>(key, { transform })` alone.\n edits.push({ start, end, text: `<${first.getText(file)}>` });\n rewrittenCalls += 1;\n } else if (\n !isTwo &&\n options !== undefined &&\n (hasTransform(options) || !ts.isObjectLiteralExpression(options))\n ) {\n // One type argument and a transform: the new form. One type argument and options that are not a\n // literal (a variable): the codemod cannot see what they hold, and what it just left in\n // `get<R, B>(key, options)` would otherwise be listed on the next run; the typecheck names a bad one.\n // Nothing to do and nothing to list.\n } else if (isStringType(first) && (!isTwo || isPlainLiteral)) {\n // `string` is what get() returns without a transform, so the type arguments carry nothing: a literal\n // without a transform reads the same with one type argument or two.\n edits.push({ start, end, text: '' });\n rewrittenCalls += 1;\n } else {\n manual.push({ line: lineOf(node), type: first.getText(file) });\n }\n } else if (node.arguments.length > 0 && !ts.isObjectLiteralExpression(node.arguments[0])) {\n // Every other `x.get<T>(key)` is listed, never hidden: a name the file does not bind to the store, a\n // property, a parameter or an optional chain. A container lookup shares the shape (its first\n // argument is an object literal, so it is not listed).\n skipped.push({ line: lineOf(node), receiver: callee.expression.getText(file) });\n }\n }\n\n ts.forEachChild(node, visit);\n };\n\n visit(file);\n\n if (edits.length === 0) {\n return { output: source, changed: false, rewritten: 0, manual, numbered, skipped };\n }\n\n let output = source;\n\n for (const edit of [...edits].sort((left, right) => right.start - left.start)) {\n output = output.slice(0, edit.start) + edit.text + output.slice(edit.end);\n }\n\n return {\n output,\n changed: output !== source,\n rewritten: rewrittenCalls,\n manual,\n numbered,\n skipped,\n };\n }\n}\n\n/** `devz codemod env-get [paths...] [--write | --check]`: rewrites the type arguments of `applicationEnvironment.get()`. */\nexport class EnvGetCommand {\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(EnvGetFlags.HELP) || args.includes(EnvGetFlags.HELP_SHORT)) {\n console.log(USAGE);\n\n return 0;\n }\n\n const flags = args.filter((argument) => argument.startsWith('-'));\n const paths = args.filter((argument) => !argument.startsWith('-'));\n const unknown = flags.filter((flag) => !EnvGetFlags.isValid(flag));\n\n if (unknown.length > 0) {\n console.error(\n `devz codemod: unknown option ${unknown.map((flag) => `\"${flag}\"`).join(', ')}\\n${USAGE}`,\n );\n\n return USAGE_ERROR_CODE;\n }\n\n const isWrite = flags.includes(EnvGetFlags.WRITE);\n const isCheck = flags.includes(EnvGetFlags.CHECK);\n const isNumbers = flags.includes(EnvGetFlags.NUMBERS);\n\n if (isWrite && isCheck) {\n console.error(\n `devz codemod: ${EnvGetFlags.WRITE} and ${EnvGetFlags.CHECK} contradict each other\\n${USAGE}`,\n );\n\n return USAGE_ERROR_CODE;\n }\n\n const refusal = CodemodFiles.refusal({\n command: 'env-get',\n isWrite,\n isAll: flags.includes(EnvGetFlags.ALL),\n paths,\n });\n\n if (refusal) {\n console.error(`${refusal}\\n${USAGE}`);\n\n return USAGE_ERROR_CODE;\n }\n\n let typescript: typeof import('typescript');\n\n try {\n const loaded = await import('typescript');\n typescript = loaded.default;\n } catch {\n console.error('devz codemod: the \"typescript\" package is required to read your sources');\n\n return 1;\n }\n\n const targets = (paths.length > 0 ? paths : ['.']).map((path) => resolve(root, path));\n let changedCount = 0;\n let callCount = 0;\n let manualCount = 0;\n let skippedCount = 0;\n let numberedCount = 0;\n const manualByType = new Map<string, number>();\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 (!/\\.\\s*get\\b/.test(source)) {\n continue;\n }\n\n const result = EnvGet.rewrite({\n typescript,\n fileName: file,\n source,\n numbers: isNumbers,\n });\n const shown = relative(root, file).split('\\\\').join('/') || file;\n\n for (const item of result.manual) {\n manualCount += 1;\n manualByType.set(item.type, (manualByType.get(item.type) ?? 0) + 1);\n console.warn(\n `manual ${shown}:${item.line} get<${item.type}>: ${\n item.reason ??\n 'a type argument the rewrite cannot place (not string or string | undefined, or two type arguments without an options argument): a number or other conversion goes in a transform, for example get(key, { transform: Number })'\n }`,\n );\n }\n\n for (const line of result.numbered) {\n numberedCount += 1;\n console.log(\n `numbers ${shown}:${line} get<number> rewritten to a transform: the value is now a real number and a non-numeric value throws at the read`,\n );\n }\n\n for (const call of result.skipped) {\n skippedCount += 1;\n console.warn(\n `skipped ${shown}:${call.line} ${call.receiver}.get<...>(): the receiver is not bound to applicationEnvironment or AppEnvs in this file (a property, a parameter, an optional chain or another object): check it by hand if it is the environment store`,\n );\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, stash or \"git add\" 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 env-get: ${changedCount} file(s) ${isWrite ? 'changed' : 'would change'}, ${callCount} call(s) ${isWrite ? 'rewritten' : 'would be rewritten'}, ${manualCount} manual, ${skippedCount} skipped` +\n (isNumbers ? `, ${numberedCount} number read(s) rewritten` : '') +\n (refusedCount > 0 ? `, ${refusedCount} refused` : ''),\n );\n\n if (manualByType.size > 0) {\n const counts = [...manualByType.entries()]\n .sort((left, right) => right[1] - left[1])\n .map(([typeText, count]) => `${typeText} x${count}`)\n .join(', ');\n\n console.log(`manual by type argument: ${counts}`);\n }\n\n if (!isWrite && changedCount > 0) {\n console.log(\n `Nothing was written. Run again with ${EnvGetFlags.WRITE} to apply, then run your typecheck.`,\n );\n }\n\n if (isWrite && refusedCount > 0) {\n return 1;\n }\n\n return isCheck && (changedCount > 0 || manualCount > 0) ? 1 : 0;\n }\n}\n"]}
|
|
@@ -26,8 +26,10 @@ export declare class CodemodFiles {
|
|
|
26
26
|
target: string;
|
|
27
27
|
}): string[] | undefined;
|
|
28
28
|
/**
|
|
29
|
-
* The files under `target` that a write could not be undone with git: changed in the working tree
|
|
30
|
-
*
|
|
29
|
+
* The files under `target` that a write could not be undone with git: changed in the working tree since
|
|
30
|
+
* the index (unstaged), or untracked and not ignored. A staged file counts as saved, so one codemod can
|
|
31
|
+
* run on what the one before it wrote once "git add" has staged it. `undefined` outside a repository or
|
|
32
|
+
* without git, where there is nothing to check.
|
|
31
33
|
*/
|
|
32
34
|
static dirty(opts: {
|
|
33
35
|
target: string;
|
|
@@ -61,16 +61,15 @@ class CodemodFiles {
|
|
|
61
61
|
.filter((path) => (0, node_fs_1.existsSync)(path) && (0, node_fs_1.statSync)(path).isFile());
|
|
62
62
|
}
|
|
63
63
|
/**
|
|
64
|
-
* The files under `target` that a write could not be undone with git: changed in the working tree
|
|
65
|
-
*
|
|
64
|
+
* The files under `target` that a write could not be undone with git: changed in the working tree since
|
|
65
|
+
* the index (unstaged), or untracked and not ignored. A staged file counts as saved, so one codemod can
|
|
66
|
+
* run on what the one before it wrote once "git add" has staged it. `undefined` outside a repository or
|
|
67
|
+
* without git, where there is nothing to check.
|
|
66
68
|
*/
|
|
67
69
|
static dirty(opts) {
|
|
68
70
|
const { target } = opts;
|
|
69
71
|
const cwd = (0, node_fs_1.statSync)(target).isFile() ? (0, node_path_1.dirname)(target) : target;
|
|
70
|
-
const queries = [
|
|
71
|
-
['ls-files', '--modified', '--others', '--exclude-standard', '-z'],
|
|
72
|
-
['diff', '--cached', '--name-only', '--relative', '-z'],
|
|
73
|
-
];
|
|
72
|
+
const queries = [['ls-files', '--modified', '--others', '--exclude-standard', '-z']];
|
|
74
73
|
const paths = new Set();
|
|
75
74
|
for (const query of queries) {
|
|
76
75
|
let output;
|
|
@@ -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,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,CAAC,EAAE,CAAC;YAC9B,OAAO,gBAAgB,OAAO,+EAA+E,CAAC;QAChH,CAAC;QAED,IAAI,OAAO,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC5C,OAAO,gBAAgB,OAAO,iHAAiH,CAAC;QAClJ,CAAC;QAED,OAAO,SAAS,CAAC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AAU,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;gBAED,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;AAhID,oCAgIC","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 /**\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 since\n * the index (unstaged), or untracked and not ignored. A staged file counts as saved, so one codemod can\n * run on what the one before it wrote once \"git add\" has staged it. `undefined` outside a repository or\n * 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 = [['ls-files', '--modified', '--others', '--exclude-standard', '-z']];\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\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"]}
|
|
@@ -10,7 +10,7 @@ export * from './rewriter';
|
|
|
10
10
|
* `--check` is the same dry run, and exits 1 while a call can be rewritten or is left untouched.
|
|
11
11
|
*/
|
|
12
12
|
export declare class NamespaceFunctionsCommand {
|
|
13
|
-
static readonly USAGE = "Usage: devz codemod namespace-functions [paths...] [--write | --check] [--reverse]\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 --reverse apply the table backward, for a downgrade: `ClassName.method({ first: a })` becomes\n `oldName(a)` and the import follows. The `ApplicationLogger` rule is not reversed.\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
|
|
13
|
+
static readonly USAGE = "Usage: devz codemod namespace-functions [paths...] [--write | --check] [--reverse]\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 --reverse apply the table backward, for a downgrade: `ClassName.method({ first: a })` becomes\n `oldName(a)` and the import follows. The `ApplicationLogger` rule is not reversed.\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 since staged, or untracked): commit, stash or \"git add\" it first, so git can undo the codemod.";
|
|
14
14
|
static run(opts: {
|
|
15
15
|
root: string;
|
|
16
16
|
args: string[];
|
|
@@ -56,7 +56,7 @@ typecheck afterwards.
|
|
|
56
56
|
|
|
57
57
|
With no flag it lists what would change and writes nothing. Inside a git repository it reads the
|
|
58
58
|
files git knows (tracked, or untracked and not ignored), and --write refuses a file with local changes
|
|
59
|
-
(changed
|
|
59
|
+
(changed since staged, or untracked): commit, stash or "git add" it first, so git can undo the codemod.`;
|
|
60
60
|
/** A usage error: nothing was read or written. */
|
|
61
61
|
const USAGE_ERROR_CODE = 2;
|
|
62
62
|
class NamespaceFunctionsFlags {
|
|
@@ -167,7 +167,7 @@ class NamespaceFunctionsCommand {
|
|
|
167
167
|
}
|
|
168
168
|
if (dirty?.has(file)) {
|
|
169
169
|
refusedCount += 1;
|
|
170
|
-
console.warn(`refused ${shown} has local changes (commit or
|
|
170
|
+
console.warn(`refused ${shown} has local changes (commit, stash or "git add" them, then run again)`);
|
|
171
171
|
continue;
|
|
172
172
|
}
|
|
173
173
|
changedCount += 1;
|
|
@@ -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,uCAAsD;AACtD,yC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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;;AArKH,8DAsKC","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 { NamespaceFunctionsReverse } from './reverse';\nimport { NamespaceFunctions } from './rewriter';\n\nexport * from './logger-scope';\nexport * from './mapping';\nexport * from './mappings';\nexport * from './reverse';\nexport * from './rewriter';\n\nconst USAGE = `Usage: devz codemod namespace-functions [paths...] [--write | --check] [--reverse]\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 --reverse apply the table backward, for a downgrade: \\`ClassName.method({ first: a })\\` becomes\n \\`oldName(a)\\` and the import follows. The \\`ApplicationLogger\\` rule is not reversed.\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 REVERSE = '--reverse';\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.REVERSE,\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\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\n if (unknown.length > 0) {\n console.error(\n `devz codemod: unknown option ${unknown.map((flag) => `\"${flag}\"`).join(', ')}\\n${USAGE}`,\n );\n\n return USAGE_ERROR_CODE;\n }\n\n const isWrite = flags.includes(NamespaceFunctionsFlags.WRITE);\n const isCheck = flags.includes(NamespaceFunctionsFlags.CHECK);\n const isReverse = flags.includes(NamespaceFunctionsFlags.REVERSE);\n\n if (isWrite && isCheck) {\n console.error(\n `devz codemod: ${NamespaceFunctionsFlags.WRITE} and ${NamespaceFunctionsFlags.CHECK} contradict each other\\n${USAGE}`,\n );\n\n return USAGE_ERROR_CODE;\n }\n\n const problems = NamespaceMappings.validate({ mappings });\n\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\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\n return 0;\n }\n\n let typescript: typeof import('typescript');\n\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\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) => (isReverse ? mapping.className : 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) && (isReverse || !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 = isReverse\n ? { output: source, changed: false, rewritten: 0, reports: [] }\n : LoggerScopeRewriter.rewrite({ typescript, fileName: file, source });\n const tabled = (isReverse ? NamespaceFunctionsReverse : 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":";;;;;;;;;;;;;;;;;AAAA,qCAAsD;AACtD,yCAA8C;AAC9C,oCAAwC;AACxC,uCAAsE;AACtE,yCAA0C;AAC1C,iDAAqD;AACrD,uCAAsD;AACtD,yCAAgD;AAEhD,iDAA+B;AAC/B,4CAA0B;AAC1B,6CAA2B;AAC3B,4CAA0B;AAC1B,6CAA2B;AAE3B,MAAM,KAAK,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;wGA4B0F,CAAC;AAEzG,kDAAkD;AAClD,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAE3B,MAAM,uBAAuB;aACX,UAAK,GAAG,SAAS,CAAC;aAClB,UAAK,GAAG,SAAS,CAAC;aAClB,YAAO,GAAG,WAAW,CAAC;aACtB,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,OAAO;QACZ,IAAI,CAAC,IAAI;QACT,IAAI,CAAC,UAAU;KAChB,CAAC,CAAC;IAEH,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAA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AAG,CAAC,IAAI,WAAW,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAClE,CAAC;;AArKH,8DAsKC","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 { NamespaceFunctionsReverse } from './reverse';\nimport { NamespaceFunctions } from './rewriter';\n\nexport * from './logger-scope';\nexport * from './mapping';\nexport * from './mappings';\nexport * from './reverse';\nexport * from './rewriter';\n\nconst USAGE = `Usage: devz codemod namespace-functions [paths...] [--write | --check] [--reverse]\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 --reverse apply the table backward, for a downgrade: \\`ClassName.method({ first: a })\\` becomes\n \\`oldName(a)\\` and the import follows. The \\`ApplicationLogger\\` rule is not reversed.\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 since staged, or untracked): commit, stash or \"git add\" 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 REVERSE = '--reverse';\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.REVERSE,\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\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\n if (unknown.length > 0) {\n console.error(\n `devz codemod: unknown option ${unknown.map((flag) => `\"${flag}\"`).join(', ')}\\n${USAGE}`,\n );\n\n return USAGE_ERROR_CODE;\n }\n\n const isWrite = flags.includes(NamespaceFunctionsFlags.WRITE);\n const isCheck = flags.includes(NamespaceFunctionsFlags.CHECK);\n const isReverse = flags.includes(NamespaceFunctionsFlags.REVERSE);\n\n if (isWrite && isCheck) {\n console.error(\n `devz codemod: ${NamespaceFunctionsFlags.WRITE} and ${NamespaceFunctionsFlags.CHECK} contradict each other\\n${USAGE}`,\n );\n\n return USAGE_ERROR_CODE;\n }\n\n const problems = NamespaceMappings.validate({ mappings });\n\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\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\n return 0;\n }\n\n let typescript: typeof import('typescript');\n\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\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) => (isReverse ? mapping.className : 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) && (isReverse || !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 = isReverse\n ? { output: source, changed: false, rewritten: 0, reports: [] }\n : LoggerScopeRewriter.rewrite({ typescript, fileName: file, source });\n const tabled = (isReverse ? NamespaceFunctionsReverse : 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, stash or \"git add\" 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"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@venizia/dev-configs",
|
|
3
|
-
"version": "0.5.0-
|
|
3
|
+
"version": "0.5.0-6",
|
|
4
4
|
"description": "Shareable development configurations for TypeScript projects: oxlint presets with per-rule builders, the ESLint naming-convention rule, the legacy ESLint flat config, and TypeScript compiler options with critical decorator support (experimentalDecorators, emitDecoratorMetadata, useDefineForClassFields). Single source of truth for consistent code style, type checking, and build settings across monorepo packages.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"build-tools",
|