@venizia/dev-configs 0.5.0-11 → 0.5.0-12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/README.md +2 -2
  2. package/dist/cli/codemod/class-renames.d.ts +9 -2
  3. package/dist/cli/codemod/class-renames.js +92 -17
  4. package/dist/cli/codemod/class-renames.js.map +1 -1
  5. package/dist/cli/codemod/index.js +7 -0
  6. package/dist/cli/codemod/index.js.map +1 -1
  7. package/dist/cli/codemod/namespace-functions/mapping.d.ts +6 -0
  8. package/dist/cli/codemod/namespace-functions/mapping.js.map +1 -1
  9. package/dist/cli/codemod/namespace-functions/mappings/connectors.d.ts +2 -0
  10. package/dist/cli/codemod/namespace-functions/mappings/connectors.js +19 -1
  11. package/dist/cli/codemod/namespace-functions/mappings/connectors.js.map +1 -1
  12. package/dist/cli/codemod/namespace-functions/mappings/guards.d.ts +4 -0
  13. package/dist/cli/codemod/namespace-functions/mappings/guards.js +15 -0
  14. package/dist/cli/codemod/namespace-functions/mappings/guards.js.map +1 -0
  15. package/dist/cli/codemod/namespace-functions/mappings/helpers.d.ts +3 -2
  16. package/dist/cli/codemod/namespace-functions/mappings/helpers.js +24 -3
  17. package/dist/cli/codemod/namespace-functions/mappings/helpers.js.map +1 -1
  18. package/dist/cli/codemod/namespace-functions/mappings/inversion.d.ts +6 -2
  19. package/dist/cli/codemod/namespace-functions/mappings/inversion.js +42 -3
  20. package/dist/cli/codemod/namespace-functions/mappings/inversion.js.map +1 -1
  21. package/dist/cli/codemod/namespace-functions/mappings/kernel.d.ts +4 -2
  22. package/dist/cli/codemod/namespace-functions/mappings/kernel.js +16 -3
  23. package/dist/cli/codemod/namespace-functions/mappings/kernel.js.map +1 -1
  24. package/dist/cli/codemod/namespace-functions/rewriter.d.ts +7 -0
  25. package/dist/cli/codemod/namespace-functions/rewriter.js +75 -8
  26. package/dist/cli/codemod/namespace-functions/rewriter.js.map +1 -1
  27. package/dist/cli/codemod/public-names.d.ts +25 -0
  28. package/dist/cli/codemod/public-names.js +134 -0
  29. package/dist/cli/codemod/public-names.js.map +1 -0
  30. package/dist/cli/index.js +1 -0
  31. package/dist/cli/index.js.map +1 -1
  32. package/dist/linters/house/framework-api-patterns.js +1 -1
  33. package/dist/linters/house/framework-api-patterns.js.map +1 -1
  34. package/dist/linters/house/no-shadow-framework-type.rule.d.ts +1 -1
  35. package/dist/linters/house/no-shadow-framework-type.rule.js +1 -1
  36. package/dist/linters/house/no-shadow-framework-type.rule.js.map +1 -1
  37. package/dist/linters/rules/naming-convention.rule.js +1 -1
  38. package/dist/linters/rules/naming-convention.rule.js.map +1 -1
  39. package/package.json +1 -1
package/README.md CHANGED
@@ -173,7 +173,7 @@ and the blank-line padding rules (`paddingConfigs`, below); `reactHouseConfigs`
173
173
  | `MaxParamsOwnRule` | `@venizia/max-params-own` | `build({ max: 5 })` | A function we write takes at most `max` positional parameters. Not counted: an inline callback passed to a call or a JSX prop, a signature a declared type fixes, a constructor whose parameters are all `@inject`. A hook callback counts. |
174
174
  | `NoNewErrorRule` | `@venizia/no-new-error` | `error` | Throw through `getError` (or an `ApplicationError`), never `new Error(...)` / `Error(...)`. Off in tests. |
175
175
  | `PreferFrameworkApiRule` | `@venizia/prefer-framework-api` | `build({ hooks: false })` in `houseConfigs`, `hooks: true` in `reactHouseConfigs` | A form the framework replaces, one row each. Anywhere in a file: `instanceof ApplicationError`, an `APP_ENV_` read of `process.env` and a comparison of `AppEnvs.get(...)` with `'true'` or `'false'` (in a package that depends on `@venizia/ignis*`), a member of `localStorage` / `sessionStorage` (`@venizia/ardor*`), a `localhost` URL used as a fallback. An assignment to a name of `process.env` and a `delete` of it pass. With `hooks`, in a component or a hook: the browser APIs `@venizia/ardor-react` wraps. Options `hooks`, `ignore` (row ids), `extra` (your rows: `{ id, match, message, dependsOn?, owner? }`, match `path`, `member`, `selector`, `literal` or `import`). Message only. Off in tests. An entry that sets options replaces the earlier ones, so state `hooks` again.. `localhost-url` skips `vite.config.*` and `.configs/builders/**`, a dev tool's own configuration |
176
- | `NamingConventionRule` (type names) | `@typescript-eslint/naming-convention` | `error` | Also: a type alias starts with `T` or ends with `Type`, and an interface starts with `I`; `ValueOf`, `ValueOptional`, `ValueOptionalExcept`, `ValueOrPromise` and `PGliteCRUDRepository` (a type that shares its name with a class value) keep their names, and so do the interfaces `declare module` adds to (`ContextRenderer`, `ContextVariableMap`, `ImportMeta`, `ImportMetaEnv`, `Matchers`, `ProcessEnv`, `Register`, `Window`), listed by name because the rule cannot see where an interface is declared. Another name passes through an `extraSelectors` entry with a `filter` and `format: null`. |
176
+ | `NamingConventionRule` (type names) | `@typescript-eslint/naming-convention` | `error` | Also: a type alias starts with `T` or ends with `Type`, and an interface starts with `I`; `ValueOptional`, `ValueOptionalExcept` and `PGliteCRUDRepository` (a type that shares its name with a class value) keep their names, and so do the interfaces `declare module` adds to (`ContextRenderer`, `ContextVariableMap`, `ImportMeta`, `ImportMetaEnv`, `Matchers`, `ProcessEnv`, `Register`, `Window`), listed by name because the rule cannot see where an interface is declared. Another name passes through an `extraSelectors` entry with a `filter` and `format: null`. |
177
177
  | `TypedRouteContextRule` | `@venizia/typed-route-context` | `error` | A route handler left unchecked: a config declared as `IAuthRouteConfig` instead of `satisfies`, `valid<T>()` on a context typed from its route, a `TContextOf` that names another route than the decorator or the handler that forwards to it. Syntax only |
178
178
  | `PreferHttpMethodRule` | `@venizia/prefer-http-method` | `error` | A method written by hand (`'get'`) in a route config, a request or a `method` / `verb` variable is `HTTP.Methods.GET`; autofix for the exact lowercase value; only in a project depending on an IGNIS package; off in tests; option `source` |
179
179
  | `ZodSchemaConventionRule` | `@venizia/zod-schema-convention` | `error` | A zod schema const is PascalCase ending in `Schema`; a type inferred from `XSchema` is `TX` or `XType` (`TXInput` / `TXOutput` for two). In every file, `z.object().strict()` is `z.strictObject()` (fixed when the call has no argument and no comment) and `.passthrough()` is refused. `.passthrough()` is reported only where the file proves the schema is zod's (a chain or a local const that starts at an import of zod), so one on an imported schema passes. In `strictPaths`, an object is `z.strictObject`; in `noAnyPaths`, no `z.any()`; in `noCoercePaths`, no `z.coerce`. Options `schemaName`, `typeName`, `strictCall`, `noPassthrough`, `strictPaths`, `noAnyPaths`, `noCoercePaths` (globs from the working directory), `ignoreTests`, `ignore` (names the two name checks leave alone). Schemas are recognised file by file, without types: an imported schema under a name that does not end in `Schema`, `this.x.extend`, a factory's result and a schema held in an object are not followed. A schema of another library imported under a name ending in `Schema` (yup, mongoose) and derived with a method of the same name (`.pick`, `.omit`, ...) is reported: list it in `ignore`. |
@@ -411,7 +411,7 @@ The codemods are `drop-redundant-casts` (removes `as X` casts the compiler no lo
411
411
  `const-classes` (turns a string-literal union into a const class), `async-style` (applies the async style
412
412
  fixers and lists the rest), `namespace-functions` (moves calls of a function that moved into a class to the
413
413
  class form), `connector-imports` (moves `@venizia/ignis/<connector sub-path>` imports to
414
- `@venizia/ignis-connectors`), `class-renames` (renames the classes IGNIS renamed, such as `RejectionHelper` to `RejectionUtility`, at the import and every use), `typed-route-context` (types a route handler's context from its route config with `TContextOf`, and drops the `valid()` type arguments there) and `env-get` (strips the type arguments of `AppEnvs.get()`
414
+ `@venizia/ignis-connectors`), `class-renames` (renames the classes IGNIS renamed, such as `RejectionHelper` to `RejectionUtility`, at the import and every use), `public-names` (renames `ValueOf` and `ValueOrPromise` to `TValueOf` and `TValueOrPromise`, `TConstructor` to `TClass` and `TAbstractConstructor` to `TAbstractClass`, and moves a call of a type guard function such as `isPromiseLike` to the static method of its class; it lists a guard used as a value for you; no `--reverse`), `typed-route-context` (types a route handler's context from its route config with `TContextOf`, and drops the `valid()` type arguments there) and `env-get` (strips the type arguments of `AppEnvs.get()`
415
415
  for the string-reading `get()`; the receiver is a name the call's scope resolves to an import of `applicationEnvironment` or `AppEnvs` from the store module, or a const initialised from one; every other `get<...>(key)` call is listed as skipped, and a call it cannot place as manual, with its file and line) `function-to-arrow` (writes a `function` declaration as an arrow and lists, with the reason, each one it leaves) and `any-aliases` (replaces the removed `AnyType` and `AnyObject` aliases by what they stood for, `any` and `Record<string | symbol | number, any>`, so no type changes, and drops them from the imports; `--strict` writes `unknown` and `Record<string, unknown>` instead; it reads imports from `@venizia/ignis`, `-helpers`, `-inversion`, and from `@venizia/ardor` and `-kernel`, which re-exported them).
416
416
 
417
417
  ## Where it sits
@@ -15,6 +15,8 @@ export interface IClassRenamesResult {
15
15
  changed: boolean;
16
16
  /** How many identifiers were renamed. */
17
17
  rewritten: number;
18
+ /** The imports left for a person: their name is declared again further down the file. */
19
+ manual: ICodemodRewrite['manual'];
18
20
  }
19
21
  /** What a codemod did to one file. */
20
22
  export interface ICodemodRewrite {
@@ -60,8 +62,13 @@ export declare class ClassRenames {
60
62
  private static reversed;
61
63
  /** The renamed class of `ns.Class`, for the members read through a namespace import. */
62
64
  private static namespaceOwner;
63
- /** Whether the file declares or imports a name that a renamed import would collide with. */
64
- private static declares;
65
+ /** The first declaration of `name` in the file, an import included; `except` is a name that does not count. */
66
+ private static findDeclaration;
67
+ /** Whether an import of one of the row's packages already brings in the new name, under that name. */
68
+ private static importsNewName;
69
+ private static owns;
70
+ /** The edit that drops one name from the braces of an import; a left-empty import goes whole. */
71
+ private static planRemoval;
65
72
  static rewrite(opts: {
66
73
  typescript: typeof import('typescript');
67
74
  fileName: string;
@@ -110,30 +110,71 @@ class ClassRenames {
110
110
  ? namespaces.get(scope.text)?.find((row) => row.oldName === member)
111
111
  : undefined;
112
112
  }
113
- /** Whether the file declares or imports a name that a renamed import would collide with. */
114
- static declares(opts) {
115
- const { typescript: ts, file, name } = opts;
116
- let isDeclared = false;
113
+ /** The first declaration of `name` in the file, an import included; `except` is a name that does not count. */
114
+ static findDeclaration(opts) {
115
+ const { typescript: ts, file, name, except, isTypeOnly = false } = opts;
116
+ let declaration;
117
117
  const walk = (node) => {
118
- const isDeclaration = ts.isVariableDeclaration(node) ||
118
+ const isTypeDeclaration = ts.isClassDeclaration(node) ||
119
+ ts.isInterfaceDeclaration(node) ||
120
+ ts.isTypeAliasDeclaration(node) ||
121
+ ts.isTypeParameterDeclaration(node) ||
122
+ ts.isEnumDeclaration(node);
123
+ const isValueDeclaration = ts.isVariableDeclaration(node) ||
119
124
  ts.isBindingElement(node) ||
120
125
  ts.isParameter(node) ||
121
126
  ts.isFunctionDeclaration(node) ||
122
- ts.isClassDeclaration(node) ||
123
- ts.isInterfaceDeclaration(node) ||
124
- ts.isTypeAliasDeclaration(node) ||
125
- ts.isEnumDeclaration(node) ||
126
127
  ts.isImportClause(node) ||
127
128
  ts.isImportSpecifier(node) ||
128
129
  ts.isNamespaceImport(node) ||
129
130
  ts.isImportEqualsDeclaration(node);
130
- if (isDeclaration && node.name && ts.isIdentifier(node.name) && node.name.text === name) {
131
- isDeclared = true;
131
+ const isDeclaration = isTypeDeclaration || (!isTypeOnly && isValueDeclaration);
132
+ if (isDeclaration &&
133
+ node.name &&
134
+ node.name !== except &&
135
+ ts.isIdentifier(node.name) &&
136
+ node.name.text === name) {
137
+ declaration ??= node;
132
138
  }
133
139
  ts.forEachChild(node, walk);
134
140
  };
135
141
  walk(file);
136
- return isDeclared;
142
+ return declaration;
143
+ }
144
+ /** Whether an import of one of the row's packages already brings in the new name, under that name. */
145
+ static importsNewName(opts) {
146
+ const { typescript: ts, file, row } = opts;
147
+ return file.statements.some((statement) => {
148
+ if (!ts.isImportDeclaration(statement) ||
149
+ !ts.isStringLiteralLike(statement.moduleSpecifier) ||
150
+ !ClassRenames.owns({ row, specifier: statement.moduleSpecifier.text })) {
151
+ return false;
152
+ }
153
+ const bindings = statement.importClause?.namedBindings;
154
+ return (bindings !== undefined &&
155
+ ts.isNamedImports(bindings) &&
156
+ bindings.elements.some((element) => !element.propertyName && element.name.text === row.newName));
157
+ });
158
+ }
159
+ static owns(opts) {
160
+ const { row, specifier } = opts;
161
+ return row.packages.some((name) => specifier === name || specifier.startsWith(`${name}/`));
162
+ }
163
+ /** The edit that drops one name from the braces of an import; a left-empty import goes whole. */
164
+ static planRemoval(opts) {
165
+ const { file, declaration, elements, element, removed } = opts;
166
+ const index = elements.indexOf(element);
167
+ const next = elements[index + 1];
168
+ if (elements.slice(index + 1).some((candidate) => !removed.has(candidate)) && next) {
169
+ return { start: element.getStart(file), end: next.getStart(file), text: '' };
170
+ }
171
+ const kept = elements.slice(0, index).filter((candidate) => !removed.has(candidate));
172
+ const previous = kept[kept.length - 1];
173
+ if (previous) {
174
+ return { start: previous.end, end: element.end, text: '' };
175
+ }
176
+ const newline = /^\r?\n/.exec(file.text.slice(declaration.end))?.[0] ?? '';
177
+ return { start: declaration.getStart(file), end: declaration.end + newline.length, text: '' };
137
178
  }
138
179
  static rewrite(opts) {
139
180
  const { typescript: ts, fileName, source, reverse = false } = opts;
@@ -141,7 +182,8 @@ class ClassRenames {
141
182
  const scriptKind = fileName.endsWith('.tsx') ? ts.ScriptKind.TSX : ts.ScriptKind.TS;
142
183
  const file = ts.createSourceFile(fileName, source, ts.ScriptTarget.Latest, true, scriptKind);
143
184
  const edits = new Map();
144
- const rowsOf = (specifier) => rows.filter((row) => row.packages.some((name) => specifier === name || specifier.startsWith(`${name}/`)));
185
+ const rowsOf = (specifier) => rows.filter((row) => ClassRenames.owns({ row, specifier }));
186
+ const manual = [];
145
187
  const rename = (node, row, text = row.newName) => {
146
188
  const start = node.getStart(file);
147
189
  edits.set(start, { start, end: node.getEnd(), text });
@@ -168,6 +210,8 @@ class ClassRenames {
168
210
  if (!bindings || !ts.isNamedImports(bindings)) {
169
211
  continue;
170
212
  }
213
+ /** The specifiers dropped because the new name is imported already. */
214
+ const removed = new Set();
171
215
  for (const element of bindings.elements) {
172
216
  const imported = element.propertyName ?? element.name;
173
217
  const row = owned.find((entry) => entry.oldName === imported.text);
@@ -179,11 +223,42 @@ class ClassRenames {
179
223
  rename(imported, row);
180
224
  continue;
181
225
  }
182
- const isTaken = ClassRenames.declares({ typescript: ts, file, name: row.newName });
226
+ const shadow = ClassRenames.findDeclaration({
227
+ typescript: ts,
228
+ file,
229
+ name: row.oldName,
230
+ except: element.name,
231
+ isTypeOnly: true,
232
+ });
233
+ if (shadow) {
234
+ const { line } = file.getLineAndCharacterOfPosition(shadow.getStart(file));
235
+ manual.push({
236
+ line: line + 1,
237
+ note: `\`${row.oldName}\` is declared again here, so its uses cannot be told apart from the import: rename the import and its uses to ${row.newName} by hand`,
238
+ });
239
+ continue;
240
+ }
241
+ if (ClassRenames.importsNewName({ typescript: ts, file, row })) {
242
+ removed.add(element);
243
+ locals.set(element.name.text, row);
244
+ continue;
245
+ }
246
+ const isTaken = ClassRenames.findDeclaration({ typescript: ts, file, name: row.newName }) !==
247
+ undefined;
183
248
  const local = isTaken ? `${ALIAS_PREFIX}${row.newName}` : row.newName;
184
249
  rename(imported, row, isTaken ? `${row.newName} as ${local}` : row.newName);
185
250
  locals.set(element.name.text, { ...row, newName: local });
186
251
  }
252
+ for (const element of removed) {
253
+ const edit = ClassRenames.planRemoval({
254
+ file,
255
+ declaration: statement,
256
+ elements: bindings.elements,
257
+ element,
258
+ removed,
259
+ });
260
+ edits.set(edit.start, edit);
261
+ }
187
262
  }
188
263
  else if (statement.exportClause && ts.isNamedExports(statement.exportClause)) {
189
264
  for (const element of statement.exportClause.elements) {
@@ -197,7 +272,7 @@ class ClassRenames {
197
272
  }
198
273
  }
199
274
  if (locals.size === 0 && namespaces.size === 0 && edits.size === 0) {
200
- return { output: source, changed: false, rewritten: 0 };
275
+ return { output: source, changed: false, rewritten: 0, manual };
201
276
  }
202
277
  /** An identifier that names a property, member or attribute, not the class. */
203
278
  const isMemberName = (node) => {
@@ -276,7 +351,7 @@ class ClassRenames {
276
351
  for (const edit of [...edits.values()].sort((a, b) => b.start - a.start)) {
277
352
  output = output.slice(0, edit.start) + edit.text + output.slice(edit.end);
278
353
  }
279
- return { output, changed: output !== source, rewritten: edits.size };
354
+ return { output, changed: output !== source, rewritten: edits.size, manual };
280
355
  }
281
356
  }
282
357
  exports.ClassRenames = ClassRenames;
@@ -295,7 +370,7 @@ class ClassRenamesCommand {
295
370
  usage,
296
371
  isReversible: true,
297
372
  marks: ({ reverse }) => rows.map((row) => (reverse ? row.newName : row.oldName)),
298
- rewrite: (input) => ({ ...ClassRenames.rewrite({ ...input, rows }), manual: [] }),
373
+ rewrite: (input) => ClassRenames.rewrite({ ...input, rows }),
299
374
  };
300
375
  }
301
376
  static async run(opts) {
@@ -1 +1 @@
1
- {"version":3,"file":"class-renames.js","sourceRoot":"","sources":["../../../src/cli/codemod/class-renames.ts"],"names":[],"mappings":";;;AAAA,qCAAsD;AACtD,yCAA8C;AAC9C,mCAAuC;AACvC,wDAAoD;AAEpD,MAAM,KAAK,GAAG;;;;;;;;;;;;;;;;;;;;;qMAqBuL,CAAC;AAEtM,kDAAkD;AAClD,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAE3B,MAAM,gBAAgB;aACJ,UAAK,GAAG,SAAS,CAAC;aAClB,QAAG,GAAG,OAAO,CAAC;aACd,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,GAAG;QACR,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,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;;AAYH,qIAAqI;AACrI,MAAM,OAAO,GAAG,CAAC,wBAAwB,EAAE,gBAAgB,CAAC,CAAC;AAC7D,MAAM,OAAO,GAAG,CAAC,8BAA8B,CAAC,CAAC;AACjD,MAAM,MAAM,GAAG,CAAC,uBAAuB,EAAE,gBAAgB,CAAC,CAAC;AAE3D,0DAA0D;AAC1D,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AAO,CAAC,CAAC;QACX,CAAC;QAED,OAAO,OAAO,IAAI,YAAY,GAAG,WAAW,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3D,CAAC;;AAvLH,kDAwLC","sourcesContent":["import { readFileSync, writeFileSync } from 'node:fs';\nimport { relative, resolve } from 'node:path';\nimport { CodemodFiles } from './files';\nimport { CliOutput } from '../../common/cli-output';\n\nconst USAGE = `Usage: devz codemod class-renames [paths...] [--write [--all] | --check] [--reverse]\n\nRenames the exports IGNIS renamed, at the import and at every use in the file: the zod schemas and types renamed\nwith the naming rules (such as trackableHeaders to TrackableHeadersSchema), and the classes RetryHelper, SlugHelper\nand CredentialHelper (@venizia/ignis-helpers) become RetryUtility, SlugUtility and CredentialUtility,\nRejectionHelper and SpawnHelper (@venizia/dev-configs/testing) become RejectionUtility and SpawnUtility. One\ntable, in this file; a later rename adds a row.\n\nIt reads TypeScript files (.ts, .tsx, .mts, .cts): a named import or re-export from the package that owns\nthe class is renamed, and so is each use of the name it brought in (an aliased import, \"Old as Alias\", keeps\nits alias and changes only the imported name). A namespace import's member (\"ns.Old\") is renamed too. A .js,\n.cjs or .mjs file is not read, and neither is \"import('pkg').Old\": edit those by hand. A property or method that\nhas the same name as a class is left alone.\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 --reverse rename back, for a downgrade\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.`;\n\n/** A usage error: nothing was read or written. */\nconst USAGE_ERROR_CODE = 2;\n\nclass ClassRenameFlags {\n static readonly WRITE = '--write';\n static readonly ALL = '--all';\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.ALL,\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\nexport interface IClassRename {\n oldName: string;\n newName: string;\n /** The packages that export it; a module specifier is theirs when it is the package or a sub-path of it. */\n packages: ReadonlyArray<string>;\n /** Static members renamed with the class: old name to new. */\n members?: Readonly<Record<string, string>>;\n}\n\n/** `@venizia/ignis` re-exports the helpers as types only, so a value import of these classes comes from `@venizia/ignis-helpers`. */\nconst HELPERS = ['@venizia/ignis-helpers', '@venizia/ignis'];\nconst TESTING = ['@venizia/dev-configs/testing'];\nconst KERNEL = ['@venizia/ignis-kernel', '@venizia/ignis'];\n\n/** The renamed classes: add a row for the next rename. */\nexport class ClassRenameTable {\n static readonly ROWS: ReadonlyArray<IClassRename> = [\n { oldName: 'RetryHelper', newName: 'RetryUtility', packages: HELPERS },\n { oldName: 'SlugHelper', newName: 'SlugUtility', packages: HELPERS },\n { oldName: 'CredentialHelper', newName: 'CredentialUtility', packages: HELPERS },\n { oldName: 'RejectionHelper', newName: 'RejectionUtility', packages: TESTING },\n { oldName: 'SpawnHelper', newName: 'SpawnUtility', packages: TESTING },\n { oldName: 'trackableHeaders', newName: 'TrackableHeadersSchema', packages: KERNEL },\n { oldName: 'countableHeaders', newName: 'CountableHeadersSchema', packages: KERNEL },\n { oldName: 'defaultRequestHeaders', newName: 'DefaultRequestHeadersSchema', packages: KERNEL },\n { oldName: 'TErrorResponse', newName: 'TErrorOutput', packages: KERNEL },\n {\n oldName: 'vaultAuthSchema',\n newName: 'VaultAuthSchema',\n packages: ['@venizia/ignis-helpers'],\n },\n { oldName: 'ISecretsRegistration', newName: 'TSecretsRegistration', packages: HELPERS },\n { oldName: 'IWebSocketServerOptions', newName: 'TWebSocketServerOptions', packages: HELPERS },\n {\n oldName: 'IRelationalDataSourceOpening',\n newName: 'TRelationalDataSourceOpening',\n packages: ['@venizia/ignis-connectors'],\n },\n ];\n}\n\nexport interface IClassRenamesResult {\n output: string;\n changed: boolean;\n /** How many identifiers were renamed. */\n rewritten: number;\n}\n\n/** What a codemod did to one file. */\nexport interface ICodemodRewrite {\n output: string;\n changed: boolean;\n rewritten: number;\n /** The lines the codemod leaves to a person. */\n manual: Array<{ line: number; note: string }>;\n /** Lines worth a review that are no work of the codemod: `--check` does not fail on them. */\n info?: Array<{ line: number; note: string }>;\n}\n\n/** A codemod that runs through the command of this file: which files it reads, and what it does to one. */\nexport interface IFileCodemod {\n name: string;\n usage: string;\n isReversible: boolean;\n /** Whether the codemod removes the names it counts, so the summary does not say it renamed them. */\n isRemoval?: boolean;\n /** What the summary counts, and what a write did to it; renamed names by default. */\n unit?: { noun: string; verb: string };\n /** A file holding none of these is not read. */\n marks: (opts: { reverse: boolean }) => ReadonlyArray<string>;\n rewrite: (input: {\n typescript: typeof import('typescript');\n fileName: string;\n source: string;\n reverse: boolean;\n }) => ICodemodRewrite;\n}\n\n/** The prefix of the alias a renamed import gets when the file already declares the new name. */\nconst ALIAS_PREFIX = 'Ignis';\n\n/** Renames the classes of `ClassRenameTable` where a file imports them. */\nexport class ClassRenames {\n private static reversed(opts: { row: IClassRename }): IClassRename {\n const { row } = opts;\n const members = Object.fromEntries(\n Object.entries(row.members ?? {}).map(([from, to]) => [to, from]),\n );\n\n return { ...row, oldName: row.newName, newName: row.oldName, members };\n }\n\n /** The renamed class of `ns.Class`, for the members read through a namespace import. */\n private static namespaceOwner(opts: {\n typescript: typeof import('typescript');\n node: import('typescript').Node;\n namespaces: Map<string, ReadonlyArray<IClassRename>>;\n }): IClassRename | undefined {\n const { typescript: ts, node, namespaces } = opts;\n let scope: import('typescript').Node;\n let member: string;\n\n if (ts.isPropertyAccessExpression(node)) {\n [scope, member] = [node.expression, node.name.text];\n } else if (ts.isQualifiedName(node)) {\n [scope, member] = [node.left, node.right.text];\n } else if (\n ts.isElementAccessExpression(node) &&\n ts.isStringLiteralLike(node.argumentExpression)\n ) {\n [scope, member] = [node.expression, node.argumentExpression.text];\n } else {\n return undefined;\n }\n\n return ts.isIdentifier(scope)\n ? namespaces.get(scope.text)?.find((row) => row.oldName === member)\n : undefined;\n }\n\n /** Whether the file declares or imports a name that a renamed import would collide with. */\n private static declares(opts: {\n typescript: typeof import('typescript');\n file: import('typescript').SourceFile;\n name: string;\n }): boolean {\n const { typescript: ts, file, name } = opts;\n let isDeclared = false;\n\n const walk = (node: import('typescript').Node): void => {\n const isDeclaration =\n ts.isVariableDeclaration(node) ||\n ts.isBindingElement(node) ||\n ts.isParameter(node) ||\n ts.isFunctionDeclaration(node) ||\n ts.isClassDeclaration(node) ||\n ts.isInterfaceDeclaration(node) ||\n ts.isTypeAliasDeclaration(node) ||\n ts.isEnumDeclaration(node) ||\n ts.isImportClause(node) ||\n ts.isImportSpecifier(node) ||\n ts.isNamespaceImport(node) ||\n ts.isImportEqualsDeclaration(node);\n\n if (isDeclaration && node.name && ts.isIdentifier(node.name) && node.name.text === name) {\n isDeclared = true;\n }\n\n ts.forEachChild(node, walk);\n };\n\n walk(file);\n\n return isDeclared;\n }\n\n static rewrite(opts: {\n typescript: typeof import('typescript');\n fileName: string;\n source: string;\n /** Rename the new names back to the old ones. */\n reverse?: boolean;\n /** The renames to apply; the class rename table by default. */\n rows?: ReadonlyArray<IClassRename>;\n }): IClassRenamesResult {\n const { typescript: ts, fileName, source, reverse = false } = opts;\n const rows = (opts.rows ?? ClassRenameTable.ROWS).map((row) =>\n reverse ? ClassRenames.reversed({ row }) : row,\n );\n const scriptKind = fileName.endsWith('.tsx') ? ts.ScriptKind.TSX : ts.ScriptKind.TS;\n const file = ts.createSourceFile(fileName, source, ts.ScriptTarget.Latest, true, scriptKind);\n const edits = new Map<number, { start: number; end: number; text: string }>();\n\n const rowsOf = (specifier: string): ReadonlyArray<IClassRename> =>\n rows.filter((row) =>\n row.packages.some((name) => specifier === name || specifier.startsWith(`${name}/`)),\n );\n\n const rename = (node: import('typescript').Node, row: IClassRename, text = row.newName) => {\n const start = node.getStart(file);\n edits.set(start, { start, end: node.getEnd(), text });\n };\n\n /** The local names to rename everywhere in the file, and the namespace imports whose members are renamed. */\n const locals = new Map<string, IClassRename>();\n const namespaces = new Map<string, ReadonlyArray<IClassRename>>();\n /** Every local name of a renamed class, aliases included: its members are renamed through it. */\n const owners = new Map<string, IClassRename>();\n\n for (const statement of file.statements) {\n if (\n (ts.isImportDeclaration(statement) || ts.isExportDeclaration(statement)) &&\n statement.moduleSpecifier &&\n ts.isStringLiteralLike(statement.moduleSpecifier)\n ) {\n const owned = rowsOf(statement.moduleSpecifier.text);\n\n if (owned.length === 0) {\n continue;\n }\n\n if (ts.isImportDeclaration(statement)) {\n const bindings = statement.importClause?.namedBindings;\n\n if (bindings && ts.isNamespaceImport(bindings)) {\n namespaces.set(bindings.name.text, owned);\n continue;\n }\n\n if (!bindings || !ts.isNamedImports(bindings)) {\n continue;\n }\n\n for (const element of bindings.elements) {\n const imported = element.propertyName ?? element.name;\n const row = owned.find((entry) => entry.oldName === imported.text);\n\n if (!row) {\n continue;\n }\n\n owners.set(element.name.text, row);\n\n if (element.propertyName) {\n rename(imported, row);\n continue;\n }\n\n const isTaken = ClassRenames.declares({ typescript: ts, file, name: row.newName });\n const local = isTaken ? `${ALIAS_PREFIX}${row.newName}` : row.newName;\n rename(imported, row, isTaken ? `${row.newName} as ${local}` : row.newName);\n locals.set(element.name.text, { ...row, newName: local });\n }\n } else if (statement.exportClause && ts.isNamedExports(statement.exportClause)) {\n for (const element of statement.exportClause.elements) {\n const exported = element.propertyName ?? element.name;\n const row = owned.find((entry) => entry.oldName === exported.text);\n\n if (row) {\n rename(exported, row);\n }\n }\n }\n }\n }\n\n if (locals.size === 0 && namespaces.size === 0 && edits.size === 0) {\n return { output: source, changed: false, rewritten: 0 };\n }\n\n /** An identifier that names a property, member or attribute, not the class. */\n const isMemberName = (node: import('typescript').Identifier): boolean => {\n const parent = node.parent;\n\n if (ts.isPropertyAccessExpression(parent)) {\n return parent.name === node;\n }\n\n if (ts.isQualifiedName(parent)) {\n return parent.right === node;\n }\n\n if (ts.isBindingElement(parent)) {\n return parent.propertyName === node;\n }\n\n return (\n (ts.isPropertyAssignment(parent) ||\n ts.isPropertyDeclaration(parent) ||\n ts.isPropertySignature(parent) ||\n ts.isMethodDeclaration(parent) ||\n ts.isMethodSignature(parent) ||\n ts.isGetAccessorDeclaration(parent) ||\n ts.isSetAccessorDeclaration(parent) ||\n ts.isEnumMember(parent) ||\n ts.isJsxAttribute(parent)) &&\n parent.name === node\n );\n };\n\n const visit = (node: import('typescript').Node): void => {\n if (ts.isImportDeclaration(node) || (ts.isExportDeclaration(node) && node.moduleSpecifier)) {\n return;\n }\n\n if (ts.isIdentifier(node)) {\n const row = locals.get(node.text);\n\n if (row && !isMemberName(node)) {\n // `{ Old }` in an object literal or a destructuring keeps its key: `{ Old: New }`.\n const isShorthand =\n (ts.isShorthandPropertyAssignment(node.parent) && node.parent.name === node) ||\n (ts.isBindingElement(node.parent) &&\n !node.parent.propertyName &&\n node.parent.name === node);\n\n rename(node, row, isShorthand ? `${node.text}: ${row.newName}` : row.newName);\n }\n }\n\n if (ts.isElementAccessExpression(node) && ts.isStringLiteralLike(node.argumentExpression)) {\n const { expression, argumentExpression } = node;\n const name = argumentExpression.text;\n const owned = ts.isIdentifier(expression) ? namespaces.get(expression.text) : undefined;\n const holder = ts.isIdentifier(expression)\n ? owners.get(expression.text)\n : ClassRenames.namespaceOwner({ typescript: ts, node: expression, namespaces });\n const row = owned?.find((entry) => entry.oldName === name) ?? holder;\n const renamed = owned ? row?.newName : holder?.members?.[name];\n\n if (row && renamed) {\n const quote = argumentExpression.getText(file).charAt(0);\n rename(argumentExpression, row, `${quote}${renamed}${quote}`);\n }\n }\n\n if (ts.isPropertyAccessExpression(node) || ts.isQualifiedName(node)) {\n const [scope, member] = ts.isPropertyAccessExpression(node)\n ? [node.expression, node.name]\n : [node.left, node.right];\n const owned = ts.isIdentifier(scope) ? namespaces.get(scope.text) : undefined;\n const row = owned?.find((entry) => entry.oldName === member.text);\n\n if (row) {\n rename(member, row);\n }\n\n // A static member of the class: through its local name, or through a namespace import.\n const holder = ts.isIdentifier(scope)\n ? owners.get(scope.text)\n : ClassRenames.namespaceOwner({ typescript: ts, node: scope, namespaces });\n const renamed = holder?.members?.[member.text];\n\n if (holder && renamed) {\n rename(member, holder, renamed);\n }\n }\n\n ts.forEachChild(node, visit);\n };\n\n visit(file);\n\n let output = source;\n\n for (const edit of [...edits.values()].sort((a, b) => b.start - a.start)) {\n output = output.slice(0, edit.start) + edit.text + output.slice(edit.end);\n }\n\n return { output, changed: output !== source, rewritten: edits.size };\n }\n}\n\n/**\n * `devz codemod class-renames [paths...] [--write [--all] | --check] [--reverse]`: renames the classes IGNIS\n * renamed. It is a dry run unless `--write` is given. `--check` is the same dry run, and exits 1 while a file\n * would change.\n */\nexport class ClassRenamesCommand {\n static readonly USAGE = USAGE;\n\n /** A table of renames as a codemod under its own command name. */\n static ofRows(opts: {\n name: string;\n usage: string;\n rows: ReadonlyArray<IClassRename>;\n }): IFileCodemod {\n const { name, usage, rows } = opts;\n\n return {\n name,\n usage,\n isReversible: true,\n marks: ({ reverse }) => rows.map((row) => (reverse ? row.newName : row.oldName)),\n rewrite: (input) => ({ ...ClassRenames.rewrite({ ...input, rows }), manual: [] }),\n };\n }\n\n static async run(opts: {\n root: string;\n args: string[];\n /** Another codemod to run this way; the class renames by default. */\n codemod?: IFileCodemod;\n }): Promise<number> {\n const { root, args } = opts;\n const codemod =\n opts.codemod ??\n ClassRenamesCommand.ofRows({\n name: 'class-renames',\n usage: USAGE,\n rows: ClassRenameTable.ROWS,\n });\n\n if (args.includes(ClassRenameFlags.HELP) || args.includes(ClassRenameFlags.HELP_SHORT)) {\n CliOutput.log(codemod.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) => !ClassRenameFlags.isValid(flag));\n\n if (unknown.length > 0) {\n CliOutput.error(\n `devz codemod: unknown option ${unknown.map((flag) => `\"${flag}\"`).join(', ')}\\n${codemod.usage}`,\n );\n\n return USAGE_ERROR_CODE;\n }\n\n const isWrite = flags.includes(ClassRenameFlags.WRITE);\n const isCheck = flags.includes(ClassRenameFlags.CHECK);\n const isReverse = flags.includes(ClassRenameFlags.REVERSE);\n\n if (isReverse && !codemod.isReversible) {\n CliOutput.error(\n `devz codemod: ${codemod.name} has no ${ClassRenameFlags.REVERSE}\\n${codemod.usage}`,\n );\n\n return USAGE_ERROR_CODE;\n }\n\n if (isWrite && isCheck) {\n CliOutput.error(\n `devz codemod: ${ClassRenameFlags.WRITE} and ${ClassRenameFlags.CHECK} contradict each other\\n${codemod.usage}`,\n );\n\n return USAGE_ERROR_CODE;\n }\n\n const refusal = CodemodFiles.refusal({\n command: codemod.name,\n isWrite,\n isAll: flags.includes(ClassRenameFlags.ALL),\n paths,\n });\n\n if (refusal) {\n CliOutput.error(`${refusal}\\n${codemod.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 CliOutput.error('devz codemod: the \"typescript\" package is required to read your sources');\n\n return 1;\n }\n\n const names = codemod.marks({ reverse: isReverse });\n const targets = (paths.length > 0 ? paths : ['.']).map((path) => resolve(root, path));\n let changedCount = 0;\n let renamedCount = 0;\n let refusedCount = 0;\n let manualCount = 0;\n const { noun, verb } = codemod.unit ?? {\n noun: 'name(s)',\n verb: codemod.isRemoval ? 'removed' : 'renamed',\n };\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 (!names.some((name) => source.includes(name))) {\n continue;\n }\n\n const result = codemod.rewrite({\n typescript,\n fileName: file,\n source,\n reverse: isReverse,\n });\n const shown = relative(root, file).split('\\\\').join('/') || file;\n\n manualCount += result.manual.length;\n\n for (const entry of result.manual) {\n CliOutput.log(`manual ${shown}:${entry.line} ${entry.note}`);\n }\n\n for (const entry of result.info ?? []) {\n CliOutput.log(`review ${shown}:${entry.line} ${entry.note}`);\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 renamedCount += result.rewritten;\n CliOutput.log(\n `${isWrite ? 'changed' : 'would change'} ${shown} (${result.rewritten} ${noun})`,\n );\n\n if (isWrite) {\n writeFileSync(file, result.output);\n }\n }\n }\n\n CliOutput.log(\n `devz codemod ${codemod.name}: ${changedCount} file(s) ${isWrite ? 'changed' : 'would change'}, ${renamedCount} ${noun} ${isWrite ? verb : `would be ${verb}`}` +\n (refusedCount > 0 ? `, ${refusedCount} refused` : ''),\n );\n\n if (!isWrite && changedCount > 0) {\n CliOutput.log(\n `Nothing was written. Run again with ${ClassRenameFlags.WRITE} to apply, then run your typecheck.`,\n );\n }\n\n if (isWrite && refusedCount > 0) {\n return 1;\n }\n\n return isCheck && changedCount + manualCount > 0 ? 1 : 0;\n }\n}\n"]}
1
+ {"version":3,"file":"class-renames.js","sourceRoot":"","sources":["../../../src/cli/codemod/class-renames.ts"],"names":[],"mappings":";;;AAAA,qCAAsD;AACtD,yCAA8C;AAC9C,mCAAuC;AACvC,wDAAoD;AAEpD,MAAM,KAAK,GAAG;;;;;;;;;;;;;;;;;;;;;qMAqBuL,CAAC;AAEtM,kDAAkD;AAClD,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAE3B,MAAM,gBAAgB;aACJ,UAAK,GAAG,SAAS,CAAC;aAClB,QAAG,GAAG,OAAO,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,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,cAAc,KAAK,KAAK,MAAM,MAAM,CAAC,SAAS,IAAI,IAAI,GAAG,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,gBAAgB,OAAO,CAAC,IAAI,KAAK,YAAY,YAAY,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,cAAc,KAAK,YAAY,IAAI,IAAI,IAAI,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,IAAI,EAAE,EAAE;YAC7J,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,gBAAgB,CAAC,KAAK,qCAAqC,CACnG,CAAC;QACJ,CAAC;QAED,IAAI,OAAO,IAAI,YAAY,GAAG,CAAC,EAAE,CAAC;YAChC,OAAO,CAAC,CAAC;QACX,CAAC;QAED,OAAO,OAAO,IAAI,YAAY,GAAG,WAAW,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3D,CAAC;;AAvLH,kDAwLC","sourcesContent":["import { readFileSync, writeFileSync } from 'node:fs';\nimport { relative, resolve } from 'node:path';\nimport { CodemodFiles } from './files';\nimport { CliOutput } from '../../common/cli-output';\n\nconst USAGE = `Usage: devz codemod class-renames [paths...] [--write [--all] | --check] [--reverse]\n\nRenames the exports IGNIS renamed, at the import and at every use in the file: the zod schemas and types renamed\nwith the naming rules (such as trackableHeaders to TrackableHeadersSchema), and the classes RetryHelper, SlugHelper\nand CredentialHelper (@venizia/ignis-helpers) become RetryUtility, SlugUtility and CredentialUtility,\nRejectionHelper and SpawnHelper (@venizia/dev-configs/testing) become RejectionUtility and SpawnUtility. One\ntable, in this file; a later rename adds a row.\n\nIt reads TypeScript files (.ts, .tsx, .mts, .cts): a named import or re-export from the package that owns\nthe class is renamed, and so is each use of the name it brought in (an aliased import, \"Old as Alias\", keeps\nits alias and changes only the imported name). A namespace import's member (\"ns.Old\") is renamed too. A .js,\n.cjs or .mjs file is not read, and neither is \"import('pkg').Old\": edit those by hand. A property or method that\nhas the same name as a class is left alone.\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 --reverse rename back, for a downgrade\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.`;\n\n/** A usage error: nothing was read or written. */\nconst USAGE_ERROR_CODE = 2;\n\nclass ClassRenameFlags {\n static readonly WRITE = '--write';\n static readonly ALL = '--all';\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.ALL,\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\nexport interface IClassRename {\n oldName: string;\n newName: string;\n /** The packages that export it; a module specifier is theirs when it is the package or a sub-path of it. */\n packages: ReadonlyArray<string>;\n /** Static members renamed with the class: old name to new. */\n members?: Readonly<Record<string, string>>;\n}\n\n/** `@venizia/ignis` re-exports the helpers as types only, so a value import of these classes comes from `@venizia/ignis-helpers`. */\nconst HELPERS = ['@venizia/ignis-helpers', '@venizia/ignis'];\nconst TESTING = ['@venizia/dev-configs/testing'];\nconst KERNEL = ['@venizia/ignis-kernel', '@venizia/ignis'];\n\n/** The renamed classes: add a row for the next rename. */\nexport class ClassRenameTable {\n static readonly ROWS: ReadonlyArray<IClassRename> = [\n { oldName: 'RetryHelper', newName: 'RetryUtility', packages: HELPERS },\n { oldName: 'SlugHelper', newName: 'SlugUtility', packages: HELPERS },\n { oldName: 'CredentialHelper', newName: 'CredentialUtility', packages: HELPERS },\n { oldName: 'RejectionHelper', newName: 'RejectionUtility', packages: TESTING },\n { oldName: 'SpawnHelper', newName: 'SpawnUtility', packages: TESTING },\n { oldName: 'trackableHeaders', newName: 'TrackableHeadersSchema', packages: KERNEL },\n { oldName: 'countableHeaders', newName: 'CountableHeadersSchema', packages: KERNEL },\n { oldName: 'defaultRequestHeaders', newName: 'DefaultRequestHeadersSchema', packages: KERNEL },\n { oldName: 'TErrorResponse', newName: 'TErrorOutput', packages: KERNEL },\n {\n oldName: 'vaultAuthSchema',\n newName: 'VaultAuthSchema',\n packages: ['@venizia/ignis-helpers'],\n },\n { oldName: 'ISecretsRegistration', newName: 'TSecretsRegistration', packages: HELPERS },\n { oldName: 'IWebSocketServerOptions', newName: 'TWebSocketServerOptions', packages: HELPERS },\n {\n oldName: 'IRelationalDataSourceOpening',\n newName: 'TRelationalDataSourceOpening',\n packages: ['@venizia/ignis-connectors'],\n },\n ];\n}\n\nexport interface IClassRenamesResult {\n output: string;\n changed: boolean;\n /** How many identifiers were renamed. */\n rewritten: number;\n /** The imports left for a person: their name is declared again further down the file. */\n manual: ICodemodRewrite['manual'];\n}\n\n/** What a codemod did to one file. */\nexport interface ICodemodRewrite {\n output: string;\n changed: boolean;\n rewritten: number;\n /** The lines the codemod leaves to a person. */\n manual: Array<{ line: number; note: string }>;\n /** Lines worth a review that are no work of the codemod: `--check` does not fail on them. */\n info?: Array<{ line: number; note: string }>;\n}\n\n/** A codemod that runs through the command of this file: which files it reads, and what it does to one. */\nexport interface IFileCodemod {\n name: string;\n usage: string;\n isReversible: boolean;\n /** Whether the codemod removes the names it counts, so the summary does not say it renamed them. */\n isRemoval?: boolean;\n /** What the summary counts, and what a write did to it; renamed names by default. */\n unit?: { noun: string; verb: string };\n /** A file holding none of these is not read. */\n marks: (opts: { reverse: boolean }) => ReadonlyArray<string>;\n rewrite: (input: {\n typescript: typeof import('typescript');\n fileName: string;\n source: string;\n reverse: boolean;\n }) => ICodemodRewrite;\n}\n\n/** The prefix of the alias a renamed import gets when the file already declares the new name. */\nconst ALIAS_PREFIX = 'Ignis';\n\n/** Renames the classes of `ClassRenameTable` where a file imports them. */\nexport class ClassRenames {\n private static reversed(opts: { row: IClassRename }): IClassRename {\n const { row } = opts;\n const members = Object.fromEntries(\n Object.entries(row.members ?? {}).map(([from, to]) => [to, from]),\n );\n\n return { ...row, oldName: row.newName, newName: row.oldName, members };\n }\n\n /** The renamed class of `ns.Class`, for the members read through a namespace import. */\n private static namespaceOwner(opts: {\n typescript: typeof import('typescript');\n node: import('typescript').Node;\n namespaces: Map<string, ReadonlyArray<IClassRename>>;\n }): IClassRename | undefined {\n const { typescript: ts, node, namespaces } = opts;\n let scope: import('typescript').Node;\n let member: string;\n\n if (ts.isPropertyAccessExpression(node)) {\n [scope, member] = [node.expression, node.name.text];\n } else if (ts.isQualifiedName(node)) {\n [scope, member] = [node.left, node.right.text];\n } else if (\n ts.isElementAccessExpression(node) &&\n ts.isStringLiteralLike(node.argumentExpression)\n ) {\n [scope, member] = [node.expression, node.argumentExpression.text];\n } else {\n return undefined;\n }\n\n return ts.isIdentifier(scope)\n ? namespaces.get(scope.text)?.find((row) => row.oldName === member)\n : undefined;\n }\n\n /** The first declaration of `name` in the file, an import included; `except` is a name that does not count. */\n private static findDeclaration(opts: {\n typescript: typeof import('typescript');\n file: import('typescript').SourceFile;\n name: string;\n except?: import('typescript').Node;\n /** Only the declarations that name a type: a type alias, an interface, a type parameter, a class, an enum. */\n isTypeOnly?: boolean;\n }): import('typescript').Node | undefined {\n const { typescript: ts, file, name, except, isTypeOnly = false } = opts;\n let declaration: import('typescript').Node | undefined;\n\n const walk = (node: import('typescript').Node): void => {\n const isTypeDeclaration =\n ts.isClassDeclaration(node) ||\n ts.isInterfaceDeclaration(node) ||\n ts.isTypeAliasDeclaration(node) ||\n ts.isTypeParameterDeclaration(node) ||\n ts.isEnumDeclaration(node);\n const isValueDeclaration =\n ts.isVariableDeclaration(node) ||\n ts.isBindingElement(node) ||\n ts.isParameter(node) ||\n ts.isFunctionDeclaration(node) ||\n ts.isImportClause(node) ||\n ts.isImportSpecifier(node) ||\n ts.isNamespaceImport(node) ||\n ts.isImportEqualsDeclaration(node);\n const isDeclaration = isTypeDeclaration || (!isTypeOnly && isValueDeclaration);\n\n if (\n isDeclaration &&\n node.name &&\n node.name !== except &&\n ts.isIdentifier(node.name) &&\n node.name.text === name\n ) {\n declaration ??= node;\n }\n\n ts.forEachChild(node, walk);\n };\n\n walk(file);\n\n return declaration;\n }\n\n /** Whether an import of one of the row's packages already brings in the new name, under that name. */\n private static importsNewName(opts: {\n typescript: typeof import('typescript');\n file: import('typescript').SourceFile;\n row: IClassRename;\n }): boolean {\n const { typescript: ts, file, row } = opts;\n\n return file.statements.some((statement) => {\n if (\n !ts.isImportDeclaration(statement) ||\n !ts.isStringLiteralLike(statement.moduleSpecifier) ||\n !ClassRenames.owns({ row, specifier: statement.moduleSpecifier.text })\n ) {\n return false;\n }\n\n const bindings = statement.importClause?.namedBindings;\n\n return (\n bindings !== undefined &&\n ts.isNamedImports(bindings) &&\n bindings.elements.some(\n (element) => !element.propertyName && element.name.text === row.newName,\n )\n );\n });\n }\n\n private static owns(opts: { row: IClassRename; specifier: string }): boolean {\n const { row, specifier } = opts;\n\n return row.packages.some((name) => specifier === name || specifier.startsWith(`${name}/`));\n }\n\n /** The edit that drops one name from the braces of an import; a left-empty import goes whole. */\n private static planRemoval(opts: {\n file: import('typescript').SourceFile;\n declaration: import('typescript').ImportDeclaration;\n elements: ReadonlyArray<import('typescript').ImportSpecifier>;\n element: import('typescript').ImportSpecifier;\n removed: ReadonlySet<import('typescript').ImportSpecifier>;\n }): { start: number; end: number; text: string } {\n const { file, declaration, elements, element, removed } = opts;\n const index = elements.indexOf(element);\n const next = elements[index + 1];\n\n if (elements.slice(index + 1).some((candidate) => !removed.has(candidate)) && next) {\n return { start: element.getStart(file), end: next.getStart(file), text: '' };\n }\n\n const kept = elements.slice(0, index).filter((candidate) => !removed.has(candidate));\n const previous = kept[kept.length - 1];\n\n if (previous) {\n return { start: previous.end, end: element.end, text: '' };\n }\n\n const newline = /^\\r?\\n/.exec(file.text.slice(declaration.end))?.[0] ?? '';\n\n return { start: declaration.getStart(file), end: declaration.end + newline.length, text: '' };\n }\n\n static rewrite(opts: {\n typescript: typeof import('typescript');\n fileName: string;\n source: string;\n /** Rename the new names back to the old ones. */\n reverse?: boolean;\n /** The renames to apply; the class rename table by default. */\n rows?: ReadonlyArray<IClassRename>;\n }): IClassRenamesResult {\n const { typescript: ts, fileName, source, reverse = false } = opts;\n const rows = (opts.rows ?? ClassRenameTable.ROWS).map((row) =>\n reverse ? ClassRenames.reversed({ row }) : row,\n );\n const scriptKind = fileName.endsWith('.tsx') ? ts.ScriptKind.TSX : ts.ScriptKind.TS;\n const file = ts.createSourceFile(fileName, source, ts.ScriptTarget.Latest, true, scriptKind);\n const edits = new Map<number, { start: number; end: number; text: string }>();\n\n const rowsOf = (specifier: string): ReadonlyArray<IClassRename> =>\n rows.filter((row) => ClassRenames.owns({ row, specifier }));\n const manual: ICodemodRewrite['manual'] = [];\n\n const rename = (node: import('typescript').Node, row: IClassRename, text = row.newName) => {\n const start = node.getStart(file);\n edits.set(start, { start, end: node.getEnd(), text });\n };\n\n /** The local names to rename everywhere in the file, and the namespace imports whose members are renamed. */\n const locals = new Map<string, IClassRename>();\n const namespaces = new Map<string, ReadonlyArray<IClassRename>>();\n /** Every local name of a renamed class, aliases included: its members are renamed through it. */\n const owners = new Map<string, IClassRename>();\n\n for (const statement of file.statements) {\n if (\n (ts.isImportDeclaration(statement) || ts.isExportDeclaration(statement)) &&\n statement.moduleSpecifier &&\n ts.isStringLiteralLike(statement.moduleSpecifier)\n ) {\n const owned = rowsOf(statement.moduleSpecifier.text);\n\n if (owned.length === 0) {\n continue;\n }\n\n if (ts.isImportDeclaration(statement)) {\n const bindings = statement.importClause?.namedBindings;\n\n if (bindings && ts.isNamespaceImport(bindings)) {\n namespaces.set(bindings.name.text, owned);\n continue;\n }\n\n if (!bindings || !ts.isNamedImports(bindings)) {\n continue;\n }\n\n /** The specifiers dropped because the new name is imported already. */\n const removed = new Set<import('typescript').ImportSpecifier>();\n\n for (const element of bindings.elements) {\n const imported = element.propertyName ?? element.name;\n const row = owned.find((entry) => entry.oldName === imported.text);\n\n if (!row) {\n continue;\n }\n\n owners.set(element.name.text, row);\n\n if (element.propertyName) {\n rename(imported, row);\n continue;\n }\n\n const shadow = ClassRenames.findDeclaration({\n typescript: ts,\n file,\n name: row.oldName,\n except: element.name,\n isTypeOnly: true,\n });\n\n if (shadow) {\n const { line } = file.getLineAndCharacterOfPosition(shadow.getStart(file));\n manual.push({\n line: line + 1,\n note: `\\`${row.oldName}\\` is declared again here, so its uses cannot be told apart from the import: rename the import and its uses to ${row.newName} by hand`,\n });\n continue;\n }\n\n if (ClassRenames.importsNewName({ typescript: ts, file, row })) {\n removed.add(element);\n locals.set(element.name.text, row);\n continue;\n }\n\n const isTaken =\n ClassRenames.findDeclaration({ typescript: ts, file, name: row.newName }) !==\n undefined;\n const local = isTaken ? `${ALIAS_PREFIX}${row.newName}` : row.newName;\n rename(imported, row, isTaken ? `${row.newName} as ${local}` : row.newName);\n locals.set(element.name.text, { ...row, newName: local });\n }\n\n for (const element of removed) {\n const edit = ClassRenames.planRemoval({\n file,\n declaration: statement,\n elements: bindings.elements,\n element,\n removed,\n });\n edits.set(edit.start, edit);\n }\n } else if (statement.exportClause && ts.isNamedExports(statement.exportClause)) {\n for (const element of statement.exportClause.elements) {\n const exported = element.propertyName ?? element.name;\n const row = owned.find((entry) => entry.oldName === exported.text);\n\n if (row) {\n rename(exported, row);\n }\n }\n }\n }\n }\n\n if (locals.size === 0 && namespaces.size === 0 && edits.size === 0) {\n return { output: source, changed: false, rewritten: 0, manual };\n }\n\n /** An identifier that names a property, member or attribute, not the class. */\n const isMemberName = (node: import('typescript').Identifier): boolean => {\n const parent = node.parent;\n\n if (ts.isPropertyAccessExpression(parent)) {\n return parent.name === node;\n }\n\n if (ts.isQualifiedName(parent)) {\n return parent.right === node;\n }\n\n if (ts.isBindingElement(parent)) {\n return parent.propertyName === node;\n }\n\n return (\n (ts.isPropertyAssignment(parent) ||\n ts.isPropertyDeclaration(parent) ||\n ts.isPropertySignature(parent) ||\n ts.isMethodDeclaration(parent) ||\n ts.isMethodSignature(parent) ||\n ts.isGetAccessorDeclaration(parent) ||\n ts.isSetAccessorDeclaration(parent) ||\n ts.isEnumMember(parent) ||\n ts.isJsxAttribute(parent)) &&\n parent.name === node\n );\n };\n\n const visit = (node: import('typescript').Node): void => {\n if (ts.isImportDeclaration(node) || (ts.isExportDeclaration(node) && node.moduleSpecifier)) {\n return;\n }\n\n if (ts.isIdentifier(node)) {\n const row = locals.get(node.text);\n\n if (row && !isMemberName(node)) {\n // `{ Old }` in an object literal or a destructuring keeps its key: `{ Old: New }`.\n const isShorthand =\n (ts.isShorthandPropertyAssignment(node.parent) && node.parent.name === node) ||\n (ts.isBindingElement(node.parent) &&\n !node.parent.propertyName &&\n node.parent.name === node);\n\n rename(node, row, isShorthand ? `${node.text}: ${row.newName}` : row.newName);\n }\n }\n\n if (ts.isElementAccessExpression(node) && ts.isStringLiteralLike(node.argumentExpression)) {\n const { expression, argumentExpression } = node;\n const name = argumentExpression.text;\n const owned = ts.isIdentifier(expression) ? namespaces.get(expression.text) : undefined;\n const holder = ts.isIdentifier(expression)\n ? owners.get(expression.text)\n : ClassRenames.namespaceOwner({ typescript: ts, node: expression, namespaces });\n const row = owned?.find((entry) => entry.oldName === name) ?? holder;\n const renamed = owned ? row?.newName : holder?.members?.[name];\n\n if (row && renamed) {\n const quote = argumentExpression.getText(file).charAt(0);\n rename(argumentExpression, row, `${quote}${renamed}${quote}`);\n }\n }\n\n if (ts.isPropertyAccessExpression(node) || ts.isQualifiedName(node)) {\n const [scope, member] = ts.isPropertyAccessExpression(node)\n ? [node.expression, node.name]\n : [node.left, node.right];\n const owned = ts.isIdentifier(scope) ? namespaces.get(scope.text) : undefined;\n const row = owned?.find((entry) => entry.oldName === member.text);\n\n if (row) {\n rename(member, row);\n }\n\n // A static member of the class: through its local name, or through a namespace import.\n const holder = ts.isIdentifier(scope)\n ? owners.get(scope.text)\n : ClassRenames.namespaceOwner({ typescript: ts, node: scope, namespaces });\n const renamed = holder?.members?.[member.text];\n\n if (holder && renamed) {\n rename(member, holder, renamed);\n }\n }\n\n ts.forEachChild(node, visit);\n };\n\n visit(file);\n\n let output = source;\n\n for (const edit of [...edits.values()].sort((a, b) => b.start - a.start)) {\n output = output.slice(0, edit.start) + edit.text + output.slice(edit.end);\n }\n\n return { output, changed: output !== source, rewritten: edits.size, manual };\n }\n}\n\n/**\n * `devz codemod class-renames [paths...] [--write [--all] | --check] [--reverse]`: renames the classes IGNIS\n * renamed. It is a dry run unless `--write` is given. `--check` is the same dry run, and exits 1 while a file\n * would change.\n */\nexport class ClassRenamesCommand {\n static readonly USAGE = USAGE;\n\n /** A table of renames as a codemod under its own command name. */\n static ofRows(opts: {\n name: string;\n usage: string;\n rows: ReadonlyArray<IClassRename>;\n }): IFileCodemod {\n const { name, usage, rows } = opts;\n\n return {\n name,\n usage,\n isReversible: true,\n marks: ({ reverse }) => rows.map((row) => (reverse ? row.newName : row.oldName)),\n rewrite: (input) => ClassRenames.rewrite({ ...input, rows }),\n };\n }\n\n static async run(opts: {\n root: string;\n args: string[];\n /** Another codemod to run this way; the class renames by default. */\n codemod?: IFileCodemod;\n }): Promise<number> {\n const { root, args } = opts;\n const codemod =\n opts.codemod ??\n ClassRenamesCommand.ofRows({\n name: 'class-renames',\n usage: USAGE,\n rows: ClassRenameTable.ROWS,\n });\n\n if (args.includes(ClassRenameFlags.HELP) || args.includes(ClassRenameFlags.HELP_SHORT)) {\n CliOutput.log(codemod.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) => !ClassRenameFlags.isValid(flag));\n\n if (unknown.length > 0) {\n CliOutput.error(\n `devz codemod: unknown option ${unknown.map((flag) => `\"${flag}\"`).join(', ')}\\n${codemod.usage}`,\n );\n\n return USAGE_ERROR_CODE;\n }\n\n const isWrite = flags.includes(ClassRenameFlags.WRITE);\n const isCheck = flags.includes(ClassRenameFlags.CHECK);\n const isReverse = flags.includes(ClassRenameFlags.REVERSE);\n\n if (isReverse && !codemod.isReversible) {\n CliOutput.error(\n `devz codemod: ${codemod.name} has no ${ClassRenameFlags.REVERSE}\\n${codemod.usage}`,\n );\n\n return USAGE_ERROR_CODE;\n }\n\n if (isWrite && isCheck) {\n CliOutput.error(\n `devz codemod: ${ClassRenameFlags.WRITE} and ${ClassRenameFlags.CHECK} contradict each other\\n${codemod.usage}`,\n );\n\n return USAGE_ERROR_CODE;\n }\n\n const refusal = CodemodFiles.refusal({\n command: codemod.name,\n isWrite,\n isAll: flags.includes(ClassRenameFlags.ALL),\n paths,\n });\n\n if (refusal) {\n CliOutput.error(`${refusal}\\n${codemod.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 CliOutput.error('devz codemod: the \"typescript\" package is required to read your sources');\n\n return 1;\n }\n\n const names = codemod.marks({ reverse: isReverse });\n const targets = (paths.length > 0 ? paths : ['.']).map((path) => resolve(root, path));\n let changedCount = 0;\n let renamedCount = 0;\n let refusedCount = 0;\n let manualCount = 0;\n const { noun, verb } = codemod.unit ?? {\n noun: 'name(s)',\n verb: codemod.isRemoval ? 'removed' : 'renamed',\n };\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 (!names.some((name) => source.includes(name))) {\n continue;\n }\n\n const result = codemod.rewrite({\n typescript,\n fileName: file,\n source,\n reverse: isReverse,\n });\n const shown = relative(root, file).split('\\\\').join('/') || file;\n\n manualCount += result.manual.length;\n\n for (const entry of result.manual) {\n CliOutput.log(`manual ${shown}:${entry.line} ${entry.note}`);\n }\n\n for (const entry of result.info ?? []) {\n CliOutput.log(`review ${shown}:${entry.line} ${entry.note}`);\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 renamedCount += result.rewritten;\n CliOutput.log(\n `${isWrite ? 'changed' : 'would change'} ${shown} (${result.rewritten} ${noun})`,\n );\n\n if (isWrite) {\n writeFileSync(file, result.output);\n }\n }\n }\n\n CliOutput.log(\n `devz codemod ${codemod.name}: ${changedCount} file(s) ${isWrite ? 'changed' : 'would change'}, ${renamedCount} ${noun} ${isWrite ? verb : `would be ${verb}`}` +\n (refusedCount > 0 ? `, ${refusedCount} refused` : ''),\n );\n\n if (!isWrite && changedCount > 0) {\n CliOutput.log(\n `Nothing was written. Run again with ${ClassRenameFlags.WRITE} to apply, then run your typecheck.`,\n );\n }\n\n if (isWrite && refusedCount > 0) {\n return 1;\n }\n\n return isCheck && changedCount + manualCount > 0 ? 1 : 0;\n }\n}\n"]}
@@ -14,6 +14,7 @@ const execution_scope_1 = require("./execution-scope");
14
14
  const function_to_arrow_1 = require("./function-to-arrow");
15
15
  const drop_redundant_casts_1 = require("./drop-redundant-casts");
16
16
  const namespace_functions_1 = require("./namespace-functions");
17
+ const public_names_1 = require("./public-names");
17
18
  const typed_route_context_1 = require("./typed-route-context");
18
19
  const cli_output_1 = require("../../common/cli-output");
19
20
  const USAGE = [
@@ -31,6 +32,7 @@ const USAGE = [
31
32
  function_to_arrow_1.FunctionToArrowCommand.USAGE,
32
33
  typed_route_context_1.TypedRouteContextCommand.USAGE,
33
34
  async_context_1.AsyncContextCommand.USAGE,
35
+ public_names_1.PublicNamesCommand.USAGE,
34
36
  ].join('\n\n');
35
37
  /** The codemods `devz codemod <name>` runs. */
36
38
  const NAME_LIST = [
@@ -48,6 +50,7 @@ const NAME_LIST = [
48
50
  'async-context',
49
51
  'function-to-arrow',
50
52
  'typed-route-context',
53
+ 'public-names',
51
54
  ];
52
55
  const NAMES = NAME_LIST.join(', ');
53
56
  /** A usage error: nothing was read or written. */
@@ -62,6 +65,7 @@ const NOT_REVERSIBLE = new Set([
62
65
  'binding-keys',
63
66
  'function-to-arrow',
64
67
  'typed-route-context',
68
+ 'public-names',
65
69
  ]);
66
70
  /** `devz codemod <name> [args]`: hands the arguments to the codemod called `name`. */
67
71
  class CodemodCommand {
@@ -115,6 +119,9 @@ class CodemodCommand {
115
119
  if (name === 'async-context') {
116
120
  return async_context_1.AsyncContextCommand.run({ root: opts.root, args: rest });
117
121
  }
122
+ if (name === 'public-names') {
123
+ return public_names_1.PublicNamesCommand.run({ root: opts.root, args: rest });
124
+ }
118
125
  if (name === 'class-renames') {
119
126
  return class_renames_1.ClassRenamesCommand.run({ root: opts.root, args: rest });
120
127
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/cli/codemod/index.ts"],"names":[],"mappings":";;;AAAA,+CAAkD;AAClD,mDAAsD;AACtD,+CAAkD;AAClD,iDAAoD;AACpD,mDAAsD;AACtD,2DAA8D;AAC9D,mDAAsD;AACtD,uCAA0C;AAC1C,uDAA0D;AAC1D,uDAA0D;AAC1D,2DAA6D;AAC7D,iEAAmE;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CAAC;YAC7B,OAAO,mCAAmB,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QAClE,CAAC;QAED,IAAI,IAAI,KAAK,eAAe,EAAE,CAAC;YAC7B,OAAO,mCAAmB,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QAClE,CAAC;QAED,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YACnD,sBAAS,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YAErB,OAAO,CAAC,CAAC;QACX,CAAC;QAED,sBAAS,CAAC,KAAK,CACb,kCAAkC,IAAI,IAAI,EAAE,yBAAyB,KAAK,OAAO,KAAK,EAAE,CACzF,CAAC;QAEF,OAAO,gBAAgB,CAAC;IAC1B,CAAC;CACF;AArFD,wCAqFC","sourcesContent":["import { AnyAliasesCommand } from './any-aliases';\nimport { AsyncContextCommand } from './async-context';\nimport { AsyncStyleCommand } from './async-style';\nimport { BindingKeysCommand } from './binding-keys';\nimport { ClassRenamesCommand } from './class-renames';\nimport { ConnectorImportsCommand } from './connector-imports';\nimport { ConstClassesCommand } from './const-classes';\nimport { EnvGetCommand } from './env-get';\nimport { ExecutionClassCommand } from './execution-class';\nimport { ExecutionScopeCommand } from './execution-scope';\nimport { FunctionToArrowCommand } from './function-to-arrow';\nimport { DropRedundantCastsCommand } from './drop-redundant-casts';\nimport { NamespaceFunctionsCommand } from './namespace-functions';\nimport { TypedRouteContextCommand } from './typed-route-context';\nimport { CliOutput } from '../../common/cli-output';\n\nconst USAGE = [\n DropRedundantCastsCommand.USAGE,\n ConstClassesCommand.USAGE,\n AsyncStyleCommand.USAGE,\n NamespaceFunctionsCommand.USAGE,\n ConnectorImportsCommand.USAGE,\n EnvGetCommand.USAGE,\n AnyAliasesCommand.USAGE,\n BindingKeysCommand.USAGE,\n ClassRenamesCommand.USAGE,\n ExecutionClassCommand.USAGE,\n ExecutionScopeCommand.USAGE,\n FunctionToArrowCommand.USAGE,\n TypedRouteContextCommand.USAGE,\n AsyncContextCommand.USAGE,\n].join('\\n\\n');\n\n/** The codemods `devz codemod <name>` runs. */\nconst NAME_LIST = [\n 'drop-redundant-casts',\n 'const-classes',\n 'async-style',\n 'namespace-functions',\n 'connector-imports',\n 'env-get',\n 'any-aliases',\n 'binding-keys',\n 'class-renames',\n 'execution-class',\n 'execution-scope',\n 'async-context',\n 'function-to-arrow',\n 'typed-route-context',\n];\nconst NAMES = NAME_LIST.join(', ');\n\n/** A usage error: nothing was read or written. */\nconst USAGE_ERROR_CODE = 2;\n\n/** The codemods that are style rewrites, not migrations: there is no downgrade of them. */\nconst NOT_REVERSIBLE = new Set([\n 'drop-redundant-casts',\n 'const-classes',\n 'async-style',\n 'env-get',\n 'any-aliases',\n 'binding-keys',\n 'function-to-arrow',\n 'typed-route-context',\n]);\n\n/** `devz codemod <name> [args]`: hands the arguments to the codemod called `name`. */\nexport class CodemodCommand {\n static async run(opts: { root: string; args: string[] }): Promise<number> {\n const { args } = opts;\n const [name, ...rest] = args;\n\n if (name === '--list') {\n CliOutput.log(NAME_LIST.join('\\n'));\n\n return 0;\n }\n\n if (name !== undefined && NOT_REVERSIBLE.has(name) && rest.includes('--reverse')) {\n CliOutput.error(`devz codemod ${name}: not reversible`);\n\n return USAGE_ERROR_CODE;\n }\n\n if (name === 'drop-redundant-casts') {\n return DropRedundantCastsCommand.run({ root: opts.root, args: rest });\n }\n\n if (name === 'const-classes') {\n return ConstClassesCommand.run({ root: opts.root, args: rest });\n }\n\n if (name === 'async-style') {\n return AsyncStyleCommand.run({ root: opts.root, args: rest });\n }\n\n if (name === 'namespace-functions') {\n return NamespaceFunctionsCommand.run({ root: opts.root, args: rest });\n }\n\n if (name === 'connector-imports') {\n return ConnectorImportsCommand.run({ root: opts.root, args: rest });\n }\n\n if (name === 'env-get') {\n return EnvGetCommand.run({ root: opts.root, args: rest });\n }\n\n if (name === 'any-aliases') {\n return AnyAliasesCommand.run({ root: opts.root, args: rest });\n }\n\n if (name === 'binding-keys') {\n return BindingKeysCommand.run({ root: opts.root, args: rest });\n }\n\n if (name === 'function-to-arrow') {\n return FunctionToArrowCommand.run({ root: opts.root, args: rest });\n }\n\n if (name === 'typed-route-context') {\n return TypedRouteContextCommand.run({ root: opts.root, args: rest });\n }\n\n if (name === 'execution-class') {\n return ExecutionClassCommand.run({ root: opts.root, args: rest });\n }\n\n if (name === 'execution-scope') {\n return ExecutionScopeCommand.run({ root: opts.root, args: rest });\n }\n\n if (name === 'async-context') {\n return AsyncContextCommand.run({ root: opts.root, args: rest });\n }\n\n if (name === 'class-renames') {\n return ClassRenamesCommand.run({ root: opts.root, args: rest });\n }\n\n if (args.includes('--help') || args.includes('-h')) {\n CliOutput.log(USAGE);\n\n return 0;\n }\n\n CliOutput.error(\n `devz codemod: unknown codemod \"${name ?? ''}\" | the codemods are: ${NAMES}\\n\\n${USAGE}`,\n );\n\n return USAGE_ERROR_CODE;\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/cli/codemod/index.ts"],"names":[],"mappings":";;;AAAA,+CAAkD;AAClD,mDAAsD;AACtD,+CAAkD;AAClD,iDAAoD;AACpD,mDAAsD;AACtD,2DAA8D;AAC9D,mDAAsD;AACtD,uCAA0C;AAC1C,uDAA0D;AAC1D,uDAA0D;AAC1D,2DAA6D;AAC7D,iEAAmE;AACnE,+DAAkE;AAClE,iDAAoD;AACpD,+DAAiE;AACjE,wDAAoD;AAEpD,MAAM,KAAK,GAAG;IACZ,gDAAyB,CAAC,KAAK;IAC/B,mCAAmB,CAAC,KAAK;IACzB,+BAAiB,CAAC,KAAK;IACvB,+CAAyB,CAAC,KAAK;IAC/B,2CAAuB,CAAC,KAAK;IAC7B,uBAAa,CAAC,KAAK;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,OAAO,iCAAkB,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QACjE,CAAC;QAED,IAAI,IAAI,KAAK,eAAe,EAAE,CAAC;YAC7B,OAAO,mCAAmB,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QAClE,CAAC;QAED,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YACnD,sBAAS,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YAErB,OAAO,CAAC,CAAC;QACX,CAAC;QAED,sBAAS,CAAC,KAAK,CACb,kCAAkC,IAAI,IAAI,EAAE,yBAAyB,KAAK,OAAO,KAAK,EAAE,CACzF,CAAC;QAEF,OAAO,gBAAgB,CAAC;IAC1B,CAAC;CACF;AAzFD,wCAyFC","sourcesContent":["import { AnyAliasesCommand } from './any-aliases';\nimport { AsyncContextCommand } from './async-context';\nimport { AsyncStyleCommand } from './async-style';\nimport { BindingKeysCommand } from './binding-keys';\nimport { ClassRenamesCommand } from './class-renames';\nimport { ConnectorImportsCommand } from './connector-imports';\nimport { ConstClassesCommand } from './const-classes';\nimport { EnvGetCommand } from './env-get';\nimport { ExecutionClassCommand } from './execution-class';\nimport { ExecutionScopeCommand } from './execution-scope';\nimport { FunctionToArrowCommand } from './function-to-arrow';\nimport { DropRedundantCastsCommand } from './drop-redundant-casts';\nimport { NamespaceFunctionsCommand } from './namespace-functions';\nimport { PublicNamesCommand } from './public-names';\nimport { TypedRouteContextCommand } from './typed-route-context';\nimport { CliOutput } from '../../common/cli-output';\n\nconst USAGE = [\n DropRedundantCastsCommand.USAGE,\n ConstClassesCommand.USAGE,\n AsyncStyleCommand.USAGE,\n NamespaceFunctionsCommand.USAGE,\n ConnectorImportsCommand.USAGE,\n EnvGetCommand.USAGE,\n AnyAliasesCommand.USAGE,\n BindingKeysCommand.USAGE,\n ClassRenamesCommand.USAGE,\n ExecutionClassCommand.USAGE,\n ExecutionScopeCommand.USAGE,\n FunctionToArrowCommand.USAGE,\n TypedRouteContextCommand.USAGE,\n AsyncContextCommand.USAGE,\n PublicNamesCommand.USAGE,\n].join('\\n\\n');\n\n/** The codemods `devz codemod <name>` runs. */\nconst NAME_LIST = [\n 'drop-redundant-casts',\n 'const-classes',\n 'async-style',\n 'namespace-functions',\n 'connector-imports',\n 'env-get',\n 'any-aliases',\n 'binding-keys',\n 'class-renames',\n 'execution-class',\n 'execution-scope',\n 'async-context',\n 'function-to-arrow',\n 'typed-route-context',\n 'public-names',\n];\nconst NAMES = NAME_LIST.join(', ');\n\n/** A usage error: nothing was read or written. */\nconst USAGE_ERROR_CODE = 2;\n\n/** The codemods that are style rewrites, not migrations: there is no downgrade of them. */\nconst NOT_REVERSIBLE = new Set([\n 'drop-redundant-casts',\n 'const-classes',\n 'async-style',\n 'env-get',\n 'any-aliases',\n 'binding-keys',\n 'function-to-arrow',\n 'typed-route-context',\n 'public-names',\n]);\n\n/** `devz codemod <name> [args]`: hands the arguments to the codemod called `name`. */\nexport class CodemodCommand {\n static async run(opts: { root: string; args: string[] }): Promise<number> {\n const { args } = opts;\n const [name, ...rest] = args;\n\n if (name === '--list') {\n CliOutput.log(NAME_LIST.join('\\n'));\n\n return 0;\n }\n\n if (name !== undefined && NOT_REVERSIBLE.has(name) && rest.includes('--reverse')) {\n CliOutput.error(`devz codemod ${name}: not reversible`);\n\n return USAGE_ERROR_CODE;\n }\n\n if (name === 'drop-redundant-casts') {\n return DropRedundantCastsCommand.run({ root: opts.root, args: rest });\n }\n\n if (name === 'const-classes') {\n return ConstClassesCommand.run({ root: opts.root, args: rest });\n }\n\n if (name === 'async-style') {\n return AsyncStyleCommand.run({ root: opts.root, args: rest });\n }\n\n if (name === 'namespace-functions') {\n return NamespaceFunctionsCommand.run({ root: opts.root, args: rest });\n }\n\n if (name === 'connector-imports') {\n return ConnectorImportsCommand.run({ root: opts.root, args: rest });\n }\n\n if (name === 'env-get') {\n return EnvGetCommand.run({ root: opts.root, args: rest });\n }\n\n if (name === 'any-aliases') {\n return AnyAliasesCommand.run({ root: opts.root, args: rest });\n }\n\n if (name === 'binding-keys') {\n return BindingKeysCommand.run({ root: opts.root, args: rest });\n }\n\n if (name === 'function-to-arrow') {\n return FunctionToArrowCommand.run({ root: opts.root, args: rest });\n }\n\n if (name === 'typed-route-context') {\n return TypedRouteContextCommand.run({ root: opts.root, args: rest });\n }\n\n if (name === 'execution-class') {\n return ExecutionClassCommand.run({ root: opts.root, args: rest });\n }\n\n if (name === 'execution-scope') {\n return ExecutionScopeCommand.run({ root: opts.root, args: rest });\n }\n\n if (name === 'async-context') {\n return AsyncContextCommand.run({ root: opts.root, args: rest });\n }\n\n if (name === 'public-names') {\n return PublicNamesCommand.run({ root: opts.root, args: rest });\n }\n\n if (name === 'class-renames') {\n return ClassRenamesCommand.run({ root: opts.root, args: rest });\n }\n\n if (args.includes('--help') || args.includes('-h')) {\n CliOutput.log(USAGE);\n\n return 0;\n }\n\n CliOutput.error(\n `devz codemod: unknown codemod \"${name ?? ''}\" | the codemods are: ${NAMES}\\n\\n${USAGE}`,\n );\n\n return USAGE_ERROR_CODE;\n }\n}\n"]}
@@ -55,6 +55,12 @@ export interface INamespaceMapping {
55
55
  * `ObjectUtility.isEmpty({ value })`. `params` is empty and `restKey` unset for such an entry.
56
56
  */
57
57
  keepsOptions?: boolean;
58
+ /**
59
+ * A type guard row: every entry in `modules` exports the same class, so an import of the class from any of them
60
+ * serves a rewritten call, and a `type` import of it, as is common for a guard's class, becomes a value import.
61
+ * Without it, such a file is listed and left.
62
+ */
63
+ isTypeGuard?: boolean;
58
64
  }
59
65
  /** Checks a mapping table. */
60
66
  export declare class NamespaceMappings {
@@ -1 +1 @@
1
- {"version":3,"file":"mapping.js","sourceRoot":"","sources":["../../../../src/c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AAC,IAAI,CAAC,GAAG,KAAK,cAAc,OAAO,CAAC,OAAO,2BAA2B,CAAC,CAAC;gBAClF,CAAC;YACH,CAAC;YAED,IAAI,OAAO,CAAC,YAAY,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,OAAO,CAAC,OAAO,KAAK,SAAS,CAAC,EAAE,CAAC;gBACzF,QAAQ,CAAC,IAAI,CAAC,GAAG,KAAK,sDAAsD,CAAC,CAAC;YAChF,CAAC;YAED,KAAK,MAAM,MAAM,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;gBACrC,MAAM,EAAE,GAAG,GAAG,MAAM,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;gBAE1C,IAAI,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;oBACjB,QAAQ,CAAC,IAAI,CAAC,GAAG,KAAK,KAAK,OAAO,CAAC,OAAO,SAAS,MAAM,kBAAkB,CAAC,CAAC;gBAC/E,CAAC;gBAED,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YACf,CAAC;QACH,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AA9ED,8CA8EC","sourcesContent":["/**\n * The table behind `devz codemod namespace-functions`. One entry per public function that moved into\n * a class: the old name is no longer exported, and the codemod moves callers to the class form, so an\n * entry is the only upgrade path for that name.\n *\n * How an entry is written, in the file of the package that exports the old name\n * (`mappings/<package-dir>.ts`):\n *\n * ```ts\n * {\n * // Every module specifier the old name can be imported from: the root, a subpath, a re-export.\n * modules: ['@venizia/ignis-helpers', '@venizia/ignis-helpers/core'],\n * oldName: 'float',\n * className: 'ParseUtility',\n * method: 'toFloat',\n * // Where the class is imported from, when that is not where the old name came from. Optional.\n * newModules: ['@venizia/ignis-helpers'],\n * // The old positional parameters in order; each becomes a key of the options object. A parameter\n * // that has a default value in the old function is `optional`, and an optional one is never\n * // followed by a required one.\n * params: [{ key: 'input' }, { key: 'digit', optional: true }],\n * // The old rest parameter, if any (`float` has none): its arguments go under this key as one\n * // array, `[]` when the call passes none. Optional.\n * // restKey: 'values',\n * }\n * ```\n *\n * So `float(value, 3)` becomes `ParseUtility.toFloat({ input: value, digit: 3 })`, and `float(input)`\n * becomes `ParseUtility.toFloat({ input })`. Add the entry in the pull request that adds the class\n * and removes the old export, never before: the codemod would rewrite callers to a method that does not\n * exist yet. `NamespaceMappings.validate` checks every entry in the test suite.\n */\n\n/** One old positional parameter, and the key it becomes in the options object. */\nexport interface INamespaceMappingParameter {\n key: string;\n /** The old parameter has a default value: a call may leave it out, and then the key is left out. */\n optional?: boolean;\n}\n\n/** One function that moved into a class. */\nexport interface INamespaceMapping {\n /** Every module specifier the old name can be imported from. */\n modules: string[];\n oldName: string;\n className: string;\n method: string;\n /** Where the class is imported from; without it, from the module the old name was imported from. */\n newModules?: string[];\n /** The old positional parameters, in order. */\n params: INamespaceMappingParameter[];\n /** The old rest parameter: its arguments are passed as one array under this key. */\n restKey?: string;\n /**\n * The old function already takes ONE options object and the method takes the same one, so a call\n * keeps its arguments and only the callee changes: `isEmpty({ value })` becomes\n * `ObjectUtility.isEmpty({ value })`. `params` is empty and `restKey` unset for such an entry.\n */\n keepsOptions?: boolean;\n}\n\nconst IDENTIFIER = /^[A-Za-z_$][\\w$]*$/;\n\n/** Checks a mapping table. */\nexport class NamespaceMappings {\n /** What is wrong with the table, one line per problem; empty when every entry is usable. */\n static validate(opts: { mappings: ReadonlyArray<INamespaceMapping> }): string[] {\n const { mappings } = opts;\n const problems: string[] = [];\n const seen = new Set<string>();\n\n for (const mapping of mappings) {\n const label = `${mapping.oldName} -> ${mapping.className}.${mapping.method}`;\n\n for (const [field, value] of [\n ['oldName', mapping.oldName],\n ['className', mapping.className],\n ['method', mapping.method],\n ] as const) {\n if (!IDENTIFIER.test(value)) {\n problems.push(`${label}: ${field} \"${value}\" is not an identifier`);\n }\n }\n\n if (mapping.modules.length === 0 || mapping.modules.some((module) => module.trim() === '')) {\n problems.push(`${label}: modules must list at least one module specifier, none empty`);\n }\n\n if (mapping.newModules?.length === 0) {\n problems.push(`${label}: newModules, when given, lists at least one module specifier`);\n }\n\n const keys = new Set<string>();\n let isOptionalSeen = false;\n\n for (const parameter of mapping.params) {\n if (!IDENTIFIER.test(parameter.key)) {\n problems.push(`${label}: the parameter key \"${parameter.key}\" is not an identifier`);\n }\n\n if (keys.has(parameter.key)) {\n problems.push(`${label}: the parameter key \"${parameter.key}\" is listed twice`);\n }\n\n keys.add(parameter.key);\n\n if (isOptionalSeen && !parameter.optional) {\n problems.push(\n `${label}: the required parameter \"${parameter.key}\" follows an optional one`,\n );\n }\n\n isOptionalSeen = isOptionalSeen || parameter.optional === true;\n }\n\n if (mapping.restKey !== undefined) {\n if (!IDENTIFIER.test(mapping.restKey)) {\n problems.push(`${label}: restKey \"${mapping.restKey}\" is not an identifier`);\n }\n\n if (keys.has(mapping.restKey)) {\n problems.push(`${label}: restKey \"${mapping.restKey}\" is also a parameter key`);\n }\n }\n\n if (mapping.keepsOptions && (mapping.params.length > 0 || mapping.restKey !== undefined)) {\n problems.push(`${label}: keepsOptions leaves params empty and restKey unset`);\n }\n\n for (const module of mapping.modules) {\n const id = `${module}#${mapping.oldName}`;\n\n if (seen.has(id)) {\n problems.push(`${label}: ${mapping.oldName} from ${module} has two entries`);\n }\n\n seen.add(id);\n }\n }\n\n return problems;\n }\n}\n"]}
1
+ {"version":3,"file":"mapping.js","sourceRoot":"","sources":["../../../../src/cli/codemod/namespace-functions/mapping.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;;;AAoCH,MAAM,UAAU,GAAG,oBAAoB,CAAC;AAExC,8BAA8B;AAC9B,MAAa,iBAAiB;IAC5B,4FAA4F;IAC5F,MAAM,CAAC,QAAQ,CAAC,IAAoD;QAClE,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;QAC1B,MAAM,QAAQ,GAAa,EAAE,CAAC;QAC9B,M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AAK,MAAM,MAAM,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;gBACrC,MAAM,EAAE,GAAG,GAAG,MAAM,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;gBAE1C,IAAI,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;oBACjB,QAAQ,CAAC,IAAI,CAAC,GAAG,KAAK,KAAK,OAAO,CAAC,OAAO,SAAS,MAAM,kBAAkB,CAAC,CAAC;gBAC/E,CAAC;gBAED,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YACf,CAAC;QACH,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AA9ED,8CA8EC","sourcesContent":["/**\n * The table behind `devz codemod namespace-functions`. One entry per public function that moved into\n * a class: the old name is no longer exported, and the codemod moves callers to the class form, so an\n * entry is the only upgrade path for that name.\n *\n * How an entry is written, in the file of the package that exports the old name\n * (`mappings/<package-dir>.ts`):\n *\n * ```ts\n * {\n * // Every module specifier the old name can be imported from: the root, a subpath, a re-export.\n * modules: ['@venizia/ignis-helpers', '@venizia/ignis-helpers/core'],\n * oldName: 'float',\n * className: 'ParseUtility',\n * method: 'toFloat',\n * // Where the class is imported from, when that is not where the old name came from. Optional.\n * newModules: ['@venizia/ignis-helpers'],\n * // The old positional parameters in order; each becomes a key of the options object. A parameter\n * // that has a default value in the old function is `optional`, and an optional one is never\n * // followed by a required one.\n * params: [{ key: 'input' }, { key: 'digit', optional: true }],\n * // The old rest parameter, if any (`float` has none): its arguments go under this key as one\n * // array, `[]` when the call passes none. Optional.\n * // restKey: 'values',\n * }\n * ```\n *\n * So `float(value, 3)` becomes `ParseUtility.toFloat({ input: value, digit: 3 })`, and `float(input)`\n * becomes `ParseUtility.toFloat({ input })`. Add the entry in the pull request that adds the class\n * and removes the old export, never before: the codemod would rewrite callers to a method that does not\n * exist yet. `NamespaceMappings.validate` checks every entry in the test suite.\n */\n\n/** One old positional parameter, and the key it becomes in the options object. */\nexport interface INamespaceMappingParameter {\n key: string;\n /** The old parameter has a default value: a call may leave it out, and then the key is left out. */\n optional?: boolean;\n}\n\n/** One function that moved into a class. */\nexport interface INamespaceMapping {\n /** Every module specifier the old name can be imported from. */\n modules: string[];\n oldName: string;\n className: string;\n method: string;\n /** Where the class is imported from; without it, from the module the old name was imported from. */\n newModules?: string[];\n /** The old positional parameters, in order. */\n params: INamespaceMappingParameter[];\n /** The old rest parameter: its arguments are passed as one array under this key. */\n restKey?: string;\n /**\n * The old function already takes ONE options object and the method takes the same one, so a call\n * keeps its arguments and only the callee changes: `isEmpty({ value })` becomes\n * `ObjectUtility.isEmpty({ value })`. `params` is empty and `restKey` unset for such an entry.\n */\n keepsOptions?: boolean;\n /**\n * A type guard row: every entry in `modules` exports the same class, so an import of the class from any of them\n * serves a rewritten call, and a `type` import of it, as is common for a guard's class, becomes a value import.\n * Without it, such a file is listed and left.\n */\n isTypeGuard?: boolean;\n}\n\nconst IDENTIFIER = /^[A-Za-z_$][\\w$]*$/;\n\n/** Checks a mapping table. */\nexport class NamespaceMappings {\n /** What is wrong with the table, one line per problem; empty when every entry is usable. */\n static validate(opts: { mappings: ReadonlyArray<INamespaceMapping> }): string[] {\n const { mappings } = opts;\n const problems: string[] = [];\n const seen = new Set<string>();\n\n for (const mapping of mappings) {\n const label = `${mapping.oldName} -> ${mapping.className}.${mapping.method}`;\n\n for (const [field, value] of [\n ['oldName', mapping.oldName],\n ['className', mapping.className],\n ['method', mapping.method],\n ] as const) {\n if (!IDENTIFIER.test(value)) {\n problems.push(`${label}: ${field} \"${value}\" is not an identifier`);\n }\n }\n\n if (mapping.modules.length === 0 || mapping.modules.some((module) => module.trim() === '')) {\n problems.push(`${label}: modules must list at least one module specifier, none empty`);\n }\n\n if (mapping.newModules?.length === 0) {\n problems.push(`${label}: newModules, when given, lists at least one module specifier`);\n }\n\n const keys = new Set<string>();\n let isOptionalSeen = false;\n\n for (const parameter of mapping.params) {\n if (!IDENTIFIER.test(parameter.key)) {\n problems.push(`${label}: the parameter key \"${parameter.key}\" is not an identifier`);\n }\n\n if (keys.has(parameter.key)) {\n problems.push(`${label}: the parameter key \"${parameter.key}\" is listed twice`);\n }\n\n keys.add(parameter.key);\n\n if (isOptionalSeen && !parameter.optional) {\n problems.push(\n `${label}: the required parameter \"${parameter.key}\" follows an optional one`,\n );\n }\n\n isOptionalSeen = isOptionalSeen || parameter.optional === true;\n }\n\n if (mapping.restKey !== undefined) {\n if (!IDENTIFIER.test(mapping.restKey)) {\n problems.push(`${label}: restKey \"${mapping.restKey}\" is not an identifier`);\n }\n\n if (keys.has(mapping.restKey)) {\n problems.push(`${label}: restKey \"${mapping.restKey}\" is also a parameter key`);\n }\n }\n\n if (mapping.keepsOptions && (mapping.params.length > 0 || mapping.restKey !== undefined)) {\n problems.push(`${label}: keepsOptions leaves params empty and restKey unset`);\n }\n\n for (const module of mapping.modules) {\n const id = `${module}#${mapping.oldName}`;\n\n if (seen.has(id)) {\n problems.push(`${label}: ${mapping.oldName} from ${module} has two entries`);\n }\n\n seen.add(id);\n }\n }\n\n return problems;\n }\n}\n"]}
@@ -1,4 +1,6 @@
1
1
  import type { INamespaceMapping } from '../mapping';
2
+ /** The type guards of `@venizia/ignis-connectors`, which keep their positional argument. */
3
+ export declare const CONNECTORS_GUARD_MAPPINGS: ReadonlyArray<INamespaceMapping>;
2
4
  /** The functions of `@venizia/ignis-connectors` that moved into a class. */
3
5
  export declare const CONNECTORS_MAPPINGS: ReadonlyArray<INamespaceMapping>;
4
6
  //# sourceMappingURL=connectors.d.ts.map