@venizia/dev-configs 0.5.0-8 → 0.5.0-9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -11
- package/dist/checks/purity/manifest.js +11 -3
- package/dist/checks/purity/manifest.js.map +1 -1
- package/dist/checks/purity/probe.js +19 -2
- package/dist/checks/purity/probe.js.map +1 -1
- package/dist/checks/split-report.js +2 -1
- package/dist/checks/split-report.js.map +1 -1
- package/dist/checks/test-controls.d.ts +9 -1
- package/dist/checks/test-controls.js +9 -3
- package/dist/checks/test-controls.js.map +1 -1
- package/dist/checks/test-dead-code.d.ts +9 -1
- package/dist/checks/test-dead-code.js +13 -2
- package/dist/checks/test-dead-code.js.map +1 -1
- package/dist/checks/test-mutate.d.ts +9 -1
- package/dist/checks/test-mutate.js +12 -6
- package/dist/checks/test-mutate.js.map +1 -1
- package/dist/cli/check.d.ts +0 -1
- package/dist/cli/check.js +41 -67
- package/dist/cli/check.js.map +1 -1
- package/dist/cli/clean.js +3 -2
- package/dist/cli/clean.js.map +1 -1
- package/dist/cli/codemod/any-aliases.js +13 -12
- 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 +17 -16
- package/dist/cli/codemod/async-style.js.map +1 -1
- package/dist/cli/codemod/binding-keys.js +14 -13
- 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 +30 -11
- package/dist/cli/codemod/class-renames.js.map +1 -1
- package/dist/cli/codemod/connector-imports.js +12 -11
- package/dist/cli/codemod/connector-imports.js.map +1 -1
- package/dist/cli/codemod/const-classes.d.ts +1 -1
- package/dist/cli/codemod/const-classes.js +21 -20
- package/dist/cli/codemod/const-classes.js.map +1 -1
- package/dist/cli/codemod/drop-redundant-casts.d.ts +6 -1
- package/dist/cli/codemod/drop-redundant-casts.js +27 -19
- package/dist/cli/codemod/drop-redundant-casts.js.map +1 -1
- package/dist/cli/codemod/env-get.d.ts +3 -3
- package/dist/cli/codemod/env-get.js +18 -17
- package/dist/cli/codemod/env-get.js.map +1 -1
- package/dist/cli/codemod/files.js +2 -2
- package/dist/cli/codemod/files.js.map +1 -1
- package/dist/cli/codemod/function-to-arrow.d.ts +76 -0
- package/dist/cli/codemod/function-to-arrow.js +357 -0
- package/dist/cli/codemod/function-to-arrow.js.map +1 -0
- package/dist/cli/codemod/index.js +19 -4
- package/dist/cli/codemod/index.js.map +1 -1
- package/dist/cli/codemod/namespace-functions/index.js +13 -12
- package/dist/cli/codemod/namespace-functions/index.js.map +1 -1
- package/dist/cli/codemod/typed-route-context.d.ts +27 -0
- package/dist/cli/codemod/typed-route-context.js +570 -0
- package/dist/cli/codemod/typed-route-context.js.map +1 -0
- package/dist/cli/index.js +5 -5
- package/dist/cli/index.js.map +1 -1
- package/dist/common/cli-output.d.ts +16 -0
- package/dist/common/cli-output.js +49 -0
- package/dist/common/cli-output.js.map +1 -0
- package/dist/compilers/bun.js +1 -1
- package/dist/compilers/bun.js.map +1 -1
- package/dist/linters/eslint.js +1 -1
- package/dist/linters/eslint.js.map +1 -1
- package/dist/linters/house/browser-api-patterns.d.ts +1 -3
- package/dist/linters/house/browser-api-patterns.js +1 -3
- package/dist/linters/house/browser-api-patterns.js.map +1 -1
- package/dist/linters/house/common.d.ts +8 -2
- package/dist/linters/house/common.js +8 -2
- package/dist/linters/house/common.js.map +1 -1
- package/dist/linters/house/configs.js +8 -6
- package/dist/linters/house/configs.js.map +1 -1
- package/dist/linters/house/const-class-values.rule.d.ts +2 -2
- package/dist/linters/house/const-class-values.rule.js +14 -5
- package/dist/linters/house/const-class-values.rule.js.map +1 -1
- package/dist/linters/house/effect-cleanup-consistency.rule.d.ts +2 -2
- package/dist/linters/house/effect-cleanup-consistency.rule.js +1 -1
- package/dist/linters/house/effect-cleanup-consistency.rule.js.map +1 -1
- package/dist/linters/house/framework-api-patterns.d.ts +54 -0
- package/dist/linters/house/framework-api-patterns.js +62 -0
- package/dist/linters/house/framework-api-patterns.js.map +1 -0
- package/dist/linters/house/framework-exports.js +3 -3
- package/dist/linters/house/framework-exports.js.map +1 -1
- package/dist/linters/house/index.d.ts +3 -4
- package/dist/linters/house/index.js +4 -6
- package/dist/linters/house/index.js.map +1 -1
- package/dist/linters/house/max-params-own.rule.d.ts +2 -2
- package/dist/linters/house/max-params-own.rule.js +1 -1
- package/dist/linters/house/max-params-own.rule.js.map +1 -1
- package/dist/linters/house/no-async-hook-callback.rule.d.ts +2 -2
- package/dist/linters/house/no-async-hook-callback.rule.js +1 -1
- package/dist/linters/house/no-async-hook-callback.rule.js.map +1 -1
- package/dist/linters/house/no-await-new-chain.rule.d.ts +2 -2
- package/dist/linters/house/no-await-new-chain.rule.js +1 -1
- package/dist/linters/house/no-await-new-chain.rule.js.map +1 -1
- package/dist/linters/house/no-await-promise-chain.rule.d.ts +2 -2
- package/dist/linters/house/no-await-promise-chain.rule.js +1 -1
- package/dist/linters/house/no-await-promise-chain.rule.js.map +1 -1
- package/dist/linters/house/no-inline-await.rule.d.ts +2 -2
- package/dist/linters/house/no-inline-await.rule.js +1 -1
- package/dist/linters/house/no-inline-await.rule.js.map +1 -1
- package/dist/linters/house/no-leaked-render.rule.d.ts +2 -2
- package/dist/linters/house/no-leaked-render.rule.js +1 -1
- package/dist/linters/house/no-leaked-render.rule.js.map +1 -1
- package/dist/linters/house/no-new-error.rule.d.ts +2 -2
- package/dist/linters/house/no-new-error.rule.js +2 -2
- package/dist/linters/house/no-new-error.rule.js.map +1 -1
- package/dist/linters/house/no-parent-import.rule.d.ts +5 -2
- package/dist/linters/house/no-parent-import.rule.js +5 -2
- package/dist/linters/house/no-parent-import.rule.js.map +1 -1
- package/dist/linters/house/no-return-await.rule.d.ts +2 -2
- package/dist/linters/house/no-return-await.rule.js +1 -1
- package/dist/linters/house/no-return-await.rule.js.map +1 -1
- package/dist/linters/house/no-shadow-framework-type.rule.d.ts +2 -2
- package/dist/linters/house/no-shadow-framework-type.rule.js +2 -2
- package/dist/linters/house/no-shadow-framework-type.rule.js.map +1 -1
- package/dist/linters/house/no-silent-catch.rule.d.ts +2 -2
- package/dist/linters/house/no-silent-catch.rule.js +3 -3
- package/dist/linters/house/no-silent-catch.rule.js.map +1 -1
- package/dist/linters/house/no-unbraced-case.rule.d.ts +2 -2
- package/dist/linters/house/no-unbraced-case.rule.js +1 -1
- package/dist/linters/house/no-unbraced-case.rule.js.map +1 -1
- package/dist/linters/house/plugin.d.ts +1 -1
- package/dist/linters/house/plugin.js +6 -5
- package/dist/linters/house/plugin.js.map +1 -1
- package/dist/linters/house/prefer-framework-api.rule.d.ts +39 -7
- package/dist/linters/house/prefer-framework-api.rule.js +285 -12
- package/dist/linters/house/prefer-framework-api.rule.js.map +1 -1
- package/dist/linters/house/prefer-promise-sleep.rule.d.ts +2 -2
- package/dist/linters/house/prefer-promise-sleep.rule.js +3 -2
- package/dist/linters/house/prefer-promise-sleep.rule.js.map +1 -1
- package/dist/linters/house/prefer-tnullable.rule.d.ts +2 -2
- package/dist/linters/house/prefer-tnullable.rule.js +2 -2
- package/dist/linters/house/prefer-tnullable.rule.js.map +1 -1
- package/dist/linters/house/typed-route-context.rule.d.ts +19 -0
- package/dist/linters/house/typed-route-context.rule.js +322 -0
- package/dist/linters/house/typed-route-context.rule.js.map +1 -0
- package/dist/linters/house/zod-schema-convention.rule.d.ts +82 -0
- package/dist/linters/house/zod-schema-convention.rule.js +477 -0
- package/dist/linters/house/zod-schema-convention.rule.js.map +1 -0
- package/dist/linters/oxlint.js +11 -1
- package/dist/linters/oxlint.js.map +1 -1
- package/dist/linters/react-eslint.js.map +1 -1
- package/dist/linters/rules/naming-convention.rule.d.ts +4 -1
- package/dist/linters/rules/naming-convention.rule.js +30 -1
- package/dist/linters/rules/naming-convention.rule.js.map +1 -1
- package/dist/linters/rules/no-restricted-properties.rule.js +1 -1
- package/dist/linters/rules/no-restricted-properties.rule.js.map +1 -1
- package/dist/testing/spawn.utility.js +1 -1
- package/dist/testing/spawn.utility.js.map +1 -1
- package/package.json +5 -5
- package/dist/checks/use-when-baseline.d.ts +0 -25
- package/dist/checks/use-when-baseline.js +0 -38
- package/dist/checks/use-when-baseline.js.map +0 -1
- package/dist/linters/house/framework-rule-apis.d.ts +0 -24
- package/dist/linters/house/framework-rule-apis.js +0 -48
- package/dist/linters/house/framework-rule-apis.js.map +0 -1
- package/dist/linters/house/public-surface.d.ts +0 -57
- package/dist/linters/house/public-surface.js +0 -174
- package/dist/linters/house/public-surface.js.map +0 -1
- package/dist/linters/house/published-package-configs.d.ts +0 -23
- package/dist/linters/house/published-package-configs.js +0 -42
- package/dist/linters/house/published-package-configs.js.map +0 -1
- package/dist/linters/house/require-use-when.rule.d.ts +0 -42
- package/dist/linters/house/require-use-when.rule.js +0 -175
- package/dist/linters/house/require-use-when.rule.js.map +0 -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,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,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AC,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 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"]}
|
|
1
|
+
{"version":3,"file":"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AAS,CAAC,GAAG,CACX,GAAG,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,cAAc,KAAK,KAAK,MAAM,MAAM,CAAC,SAAS,WAAW,CACnF,CAAC;gBAEF,IAAI,OAAO,EAAE,CAAC;oBACZ,IAAA,uBAAa,EAAC,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;gBACrC,CAAC;YACH,CAAC;QACH,CAAC;QAED,sBAAS,CAAC,GAAG,CACX,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,sBAAS,CAAC,GAAG,CACX,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';\nimport { CliOutput } from '../../../common/cli-output';\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 CliOutput.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 CliOutput.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 CliOutput.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 CliOutput.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 CliOutput.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 CliOutput.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 CliOutput.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 CliOutput.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 CliOutput.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 CliOutput.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 CliOutput.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 CliOutput.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"]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type TypeScript from 'typescript';
|
|
2
|
+
export interface ITypedRouteContextResult {
|
|
3
|
+
output: string;
|
|
4
|
+
changed: boolean;
|
|
5
|
+
/** How many places were rewritten. */
|
|
6
|
+
rewritten: number;
|
|
7
|
+
}
|
|
8
|
+
/** Types route handlers from their route configs. */
|
|
9
|
+
export declare class TypedRouteContext {
|
|
10
|
+
static rewrite(opts: {
|
|
11
|
+
typescript: typeof TypeScript;
|
|
12
|
+
fileName: string;
|
|
13
|
+
source: string;
|
|
14
|
+
}): ITypedRouteContextResult;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* `devz codemod typed-route-context [paths...] [--write [--all] | --check]`. It is a dry run unless `--write` is
|
|
18
|
+
* given. `--check` is the same dry run, and exits 1 while a file would change.
|
|
19
|
+
*/
|
|
20
|
+
export declare class TypedRouteContextCommand {
|
|
21
|
+
static readonly USAGE = "Usage: devz codemod typed-route-context [paths...] [--write [--all] | --check]\n\nTypes route handlers from their route config (TContextOf). In a file that imports the types from @venizia/ignis or\n@venizia/ignis-kernel:\n\n- a decorated method (@api, @get, @post, @put, @patch, @del) whose configs is a name declared or imported in the\n file: its TRouteContext becomes TContextOf<typeof CONFIG>, and valid<T>() on it loses its type argument;\n- the same for a private method that only the handlers of one route config in its class pass their context to;\n- TRouteContext<Env, Body> drops the body, and TRouteHandler<Response, Env> drops the response.\n\nLeft as they are, for you: a handler of a CRUD override, a method that serves two routes or is also called another\nway, an inline or this.* config, and a context typed through an alias of yours. The typecheck then names each place\nwhere a type you wrote by hand differs from the schema.\n\nA config declared as IAuthRouteConfig, or in a Record of it, carries no schema type: change it to\n\"satisfies\" first (the lint rule @venizia/typed-route-context reports each one). A handler of such a config declared\nin the same file is left as it is; one imported from another file cannot be seen, so change those first.\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 --check dry run that exits 1 while a file would change (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 git\nknows (tracked, or untracked and not ignored), and --write refuses a file with local changes (changed since staged, or untracked): commit, stash or \"git add\" it first, so git can undo the codemod.";
|
|
22
|
+
static run(opts: {
|
|
23
|
+
root: string;
|
|
24
|
+
args: string[];
|
|
25
|
+
}): Promise<number>;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=typed-route-context.d.ts.map
|