@venizia/dev-configs 0.5.0-10 → 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.
- package/README.md +3 -3
- package/dist/cli/codemod/async-context.d.ts +22 -0
- package/dist/cli/codemod/async-context.js +146 -0
- package/dist/cli/codemod/async-context.js.map +1 -0
- package/dist/cli/codemod/class-renames.d.ts +63 -0
- package/dist/cli/codemod/class-renames.js +208 -17
- package/dist/cli/codemod/class-renames.js.map +1 -1
- package/dist/cli/codemod/execution-class.d.ts +14 -0
- package/dist/cli/codemod/execution-class.js +46 -0
- package/dist/cli/codemod/execution-class.js.map +1 -0
- package/dist/cli/codemod/execution-scope.d.ts +68 -0
- package/dist/cli/codemod/execution-scope.js +727 -0
- package/dist/cli/codemod/execution-scope.js.map +1 -0
- package/dist/cli/codemod/index.js +25 -0
- package/dist/cli/codemod/index.js.map +1 -1
- package/dist/cli/codemod/namespace-functions/mapping.d.ts +6 -0
- package/dist/cli/codemod/namespace-functions/mapping.js.map +1 -1
- package/dist/cli/codemod/namespace-functions/mappings/connectors.d.ts +2 -0
- package/dist/cli/codemod/namespace-functions/mappings/connectors.js +19 -1
- package/dist/cli/codemod/namespace-functions/mappings/connectors.js.map +1 -1
- package/dist/cli/codemod/namespace-functions/mappings/guards.d.ts +4 -0
- package/dist/cli/codemod/namespace-functions/mappings/guards.js +15 -0
- package/dist/cli/codemod/namespace-functions/mappings/guards.js.map +1 -0
- package/dist/cli/codemod/namespace-functions/mappings/helpers.d.ts +3 -2
- package/dist/cli/codemod/namespace-functions/mappings/helpers.js +30 -9
- package/dist/cli/codemod/namespace-functions/mappings/helpers.js.map +1 -1
- package/dist/cli/codemod/namespace-functions/mappings/inversion.d.ts +6 -2
- package/dist/cli/codemod/namespace-functions/mappings/inversion.js +42 -3
- package/dist/cli/codemod/namespace-functions/mappings/inversion.js.map +1 -1
- package/dist/cli/codemod/namespace-functions/mappings/kernel.d.ts +4 -2
- package/dist/cli/codemod/namespace-functions/mappings/kernel.js +16 -3
- package/dist/cli/codemod/namespace-functions/mappings/kernel.js.map +1 -1
- package/dist/cli/codemod/namespace-functions/rewriter.d.ts +7 -0
- package/dist/cli/codemod/namespace-functions/rewriter.js +75 -8
- package/dist/cli/codemod/namespace-functions/rewriter.js.map +1 -1
- package/dist/cli/codemod/public-names.d.ts +25 -0
- package/dist/cli/codemod/public-names.js +134 -0
- package/dist/cli/codemod/public-names.js.map +1 -0
- package/dist/cli/index.js +1 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/compilers/bun.js +8 -1
- package/dist/compilers/bun.js.map +1 -1
- package/dist/linters/eslint.js.map +1 -1
- package/dist/linters/house/configs.js +8 -4
- package/dist/linters/house/configs.js.map +1 -1
- package/dist/linters/house/execution-support.d.ts +66 -0
- package/dist/linters/house/execution-support.js +161 -0
- package/dist/linters/house/execution-support.js.map +1 -0
- package/dist/linters/house/framework-api-patterns.js +1 -1
- package/dist/linters/house/framework-api-patterns.js.map +1 -1
- package/dist/linters/house/index.d.ts +3 -1
- package/dist/linters/house/index.js +3 -1
- package/dist/linters/house/index.js.map +1 -1
- package/dist/linters/house/no-shadow-framework-type.rule.d.ts +1 -1
- package/dist/linters/house/no-shadow-framework-type.rule.js +1 -1
- package/dist/linters/house/no-shadow-framework-type.rule.js.map +1 -1
- package/dist/linters/house/plugin.js +6 -2
- package/dist/linters/house/plugin.js.map +1 -1
- package/dist/linters/house/prefer-execution-sleep.rule.d.ts +31 -0
- package/dist/linters/house/{prefer-promise-sleep.rule.js → prefer-execution-sleep.rule.js} +57 -20
- package/dist/linters/house/prefer-execution-sleep.rule.js.map +1 -0
- package/dist/linters/house/prefer-http-method.rule.d.ts +6 -3
- package/dist/linters/house/prefer-http-method.rule.js +116 -9
- package/dist/linters/house/prefer-http-method.rule.js.map +1 -1
- package/dist/linters/house/restrict-execution-call-sites.rule.d.ts +30 -0
- package/dist/linters/house/restrict-execution-call-sites.rule.js +142 -0
- package/dist/linters/house/restrict-execution-call-sites.rule.js.map +1 -0
- package/dist/linters/house/static-execution-reason.rule.d.ts +27 -0
- package/dist/linters/house/static-execution-reason.rule.js +152 -0
- package/dist/linters/house/static-execution-reason.rule.js.map +1 -0
- package/dist/linters/rules/naming-convention.rule.js +1 -1
- package/dist/linters/rules/naming-convention.rule.js.map +1 -1
- package/dist/linters/rules/no-restricted-imports.rule.d.ts +4 -2
- package/dist/linters/rules/no-restricted-imports.rule.js.map +1 -1
- package/dist/linters/rules/no-unused-vars.rule.d.ts +13 -2
- package/dist/linters/rules/no-unused-vars.rule.js.map +1 -1
- package/package.json +2 -2
- package/dist/linters/house/prefer-promise-sleep.rule.d.ts +0 -26
- package/dist/linters/house/prefer-promise-sleep.rule.js.map +0 -1
|
@@ -79,15 +79,111 @@ class ClassRenameTable {
|
|
|
79
79
|
]; }
|
|
80
80
|
}
|
|
81
81
|
exports.ClassRenameTable = ClassRenameTable;
|
|
82
|
+
/** The prefix of the alias a renamed import gets when the file already declares the new name. */
|
|
83
|
+
const ALIAS_PREFIX = 'Ignis';
|
|
82
84
|
/** Renames the classes of `ClassRenameTable` where a file imports them. */
|
|
83
85
|
class ClassRenames {
|
|
86
|
+
static reversed(opts) {
|
|
87
|
+
const { row } = opts;
|
|
88
|
+
const members = Object.fromEntries(Object.entries(row.members ?? {}).map(([from, to]) => [to, from]));
|
|
89
|
+
return { ...row, oldName: row.newName, newName: row.oldName, members };
|
|
90
|
+
}
|
|
91
|
+
/** The renamed class of `ns.Class`, for the members read through a namespace import. */
|
|
92
|
+
static namespaceOwner(opts) {
|
|
93
|
+
const { typescript: ts, node, namespaces } = opts;
|
|
94
|
+
let scope;
|
|
95
|
+
let member;
|
|
96
|
+
if (ts.isPropertyAccessExpression(node)) {
|
|
97
|
+
[scope, member] = [node.expression, node.name.text];
|
|
98
|
+
}
|
|
99
|
+
else if (ts.isQualifiedName(node)) {
|
|
100
|
+
[scope, member] = [node.left, node.right.text];
|
|
101
|
+
}
|
|
102
|
+
else if (ts.isElementAccessExpression(node) &&
|
|
103
|
+
ts.isStringLiteralLike(node.argumentExpression)) {
|
|
104
|
+
[scope, member] = [node.expression, node.argumentExpression.text];
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
return undefined;
|
|
108
|
+
}
|
|
109
|
+
return ts.isIdentifier(scope)
|
|
110
|
+
? namespaces.get(scope.text)?.find((row) => row.oldName === member)
|
|
111
|
+
: undefined;
|
|
112
|
+
}
|
|
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
|
+
const walk = (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) ||
|
|
124
|
+
ts.isBindingElement(node) ||
|
|
125
|
+
ts.isParameter(node) ||
|
|
126
|
+
ts.isFunctionDeclaration(node) ||
|
|
127
|
+
ts.isImportClause(node) ||
|
|
128
|
+
ts.isImportSpecifier(node) ||
|
|
129
|
+
ts.isNamespaceImport(node) ||
|
|
130
|
+
ts.isImportEqualsDeclaration(node);
|
|
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;
|
|
138
|
+
}
|
|
139
|
+
ts.forEachChild(node, walk);
|
|
140
|
+
};
|
|
141
|
+
walk(file);
|
|
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: '' };
|
|
178
|
+
}
|
|
84
179
|
static rewrite(opts) {
|
|
85
180
|
const { typescript: ts, fileName, source, reverse = false } = opts;
|
|
86
|
-
const rows = ClassRenameTable.ROWS.map((row) => reverse ? {
|
|
181
|
+
const rows = (opts.rows ?? ClassRenameTable.ROWS).map((row) => reverse ? ClassRenames.reversed({ row }) : row);
|
|
87
182
|
const scriptKind = fileName.endsWith('.tsx') ? ts.ScriptKind.TSX : ts.ScriptKind.TS;
|
|
88
183
|
const file = ts.createSourceFile(fileName, source, ts.ScriptTarget.Latest, true, scriptKind);
|
|
89
184
|
const edits = new Map();
|
|
90
|
-
const rowsOf = (specifier) => rows.filter((row) =>
|
|
185
|
+
const rowsOf = (specifier) => rows.filter((row) => ClassRenames.owns({ row, specifier }));
|
|
186
|
+
const manual = [];
|
|
91
187
|
const rename = (node, row, text = row.newName) => {
|
|
92
188
|
const start = node.getStart(file);
|
|
93
189
|
edits.set(start, { start, end: node.getEnd(), text });
|
|
@@ -95,6 +191,8 @@ class ClassRenames {
|
|
|
95
191
|
/** The local names to rename everywhere in the file, and the namespace imports whose members are renamed. */
|
|
96
192
|
const locals = new Map();
|
|
97
193
|
const namespaces = new Map();
|
|
194
|
+
/** Every local name of a renamed class, aliases included: its members are renamed through it. */
|
|
195
|
+
const owners = new Map();
|
|
98
196
|
for (const statement of file.statements) {
|
|
99
197
|
if ((ts.isImportDeclaration(statement) || ts.isExportDeclaration(statement)) &&
|
|
100
198
|
statement.moduleSpecifier &&
|
|
@@ -112,16 +210,54 @@ class ClassRenames {
|
|
|
112
210
|
if (!bindings || !ts.isNamedImports(bindings)) {
|
|
113
211
|
continue;
|
|
114
212
|
}
|
|
213
|
+
/** The specifiers dropped because the new name is imported already. */
|
|
214
|
+
const removed = new Set();
|
|
115
215
|
for (const element of bindings.elements) {
|
|
116
216
|
const imported = element.propertyName ?? element.name;
|
|
117
217
|
const row = owned.find((entry) => entry.oldName === imported.text);
|
|
118
218
|
if (!row) {
|
|
119
219
|
continue;
|
|
120
220
|
}
|
|
121
|
-
|
|
122
|
-
if (
|
|
221
|
+
owners.set(element.name.text, row);
|
|
222
|
+
if (element.propertyName) {
|
|
223
|
+
rename(imported, row);
|
|
224
|
+
continue;
|
|
225
|
+
}
|
|
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);
|
|
123
243
|
locals.set(element.name.text, row);
|
|
244
|
+
continue;
|
|
124
245
|
}
|
|
246
|
+
const isTaken = ClassRenames.findDeclaration({ typescript: ts, file, name: row.newName }) !==
|
|
247
|
+
undefined;
|
|
248
|
+
const local = isTaken ? `${ALIAS_PREFIX}${row.newName}` : row.newName;
|
|
249
|
+
rename(imported, row, isTaken ? `${row.newName} as ${local}` : row.newName);
|
|
250
|
+
locals.set(element.name.text, { ...row, newName: local });
|
|
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);
|
|
125
261
|
}
|
|
126
262
|
}
|
|
127
263
|
else if (statement.exportClause && ts.isNamedExports(statement.exportClause)) {
|
|
@@ -136,7 +272,7 @@ class ClassRenames {
|
|
|
136
272
|
}
|
|
137
273
|
}
|
|
138
274
|
if (locals.size === 0 && namespaces.size === 0 && edits.size === 0) {
|
|
139
|
-
return { output: source, changed: false, rewritten: 0 };
|
|
275
|
+
return { output: source, changed: false, rewritten: 0, manual };
|
|
140
276
|
}
|
|
141
277
|
/** An identifier that names a property, member or attribute, not the class. */
|
|
142
278
|
const isMemberName = (node) => {
|
|
@@ -176,6 +312,20 @@ class ClassRenames {
|
|
|
176
312
|
rename(node, row, isShorthand ? `${node.text}: ${row.newName}` : row.newName);
|
|
177
313
|
}
|
|
178
314
|
}
|
|
315
|
+
if (ts.isElementAccessExpression(node) && ts.isStringLiteralLike(node.argumentExpression)) {
|
|
316
|
+
const { expression, argumentExpression } = node;
|
|
317
|
+
const name = argumentExpression.text;
|
|
318
|
+
const owned = ts.isIdentifier(expression) ? namespaces.get(expression.text) : undefined;
|
|
319
|
+
const holder = ts.isIdentifier(expression)
|
|
320
|
+
? owners.get(expression.text)
|
|
321
|
+
: ClassRenames.namespaceOwner({ typescript: ts, node: expression, namespaces });
|
|
322
|
+
const row = owned?.find((entry) => entry.oldName === name) ?? holder;
|
|
323
|
+
const renamed = owned ? row?.newName : holder?.members?.[name];
|
|
324
|
+
if (row && renamed) {
|
|
325
|
+
const quote = argumentExpression.getText(file).charAt(0);
|
|
326
|
+
rename(argumentExpression, row, `${quote}${renamed}${quote}`);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
179
329
|
if (ts.isPropertyAccessExpression(node) || ts.isQualifiedName(node)) {
|
|
180
330
|
const [scope, member] = ts.isPropertyAccessExpression(node)
|
|
181
331
|
? [node.expression, node.name]
|
|
@@ -185,6 +335,14 @@ class ClassRenames {
|
|
|
185
335
|
if (row) {
|
|
186
336
|
rename(member, row);
|
|
187
337
|
}
|
|
338
|
+
// A static member of the class: through its local name, or through a namespace import.
|
|
339
|
+
const holder = ts.isIdentifier(scope)
|
|
340
|
+
? owners.get(scope.text)
|
|
341
|
+
: ClassRenames.namespaceOwner({ typescript: ts, node: scope, namespaces });
|
|
342
|
+
const renamed = holder?.members?.[member.text];
|
|
343
|
+
if (holder && renamed) {
|
|
344
|
+
rename(member, holder, renamed);
|
|
345
|
+
}
|
|
188
346
|
}
|
|
189
347
|
ts.forEachChild(node, visit);
|
|
190
348
|
};
|
|
@@ -193,7 +351,7 @@ class ClassRenames {
|
|
|
193
351
|
for (const edit of [...edits.values()].sort((a, b) => b.start - a.start)) {
|
|
194
352
|
output = output.slice(0, edit.start) + edit.text + output.slice(edit.end);
|
|
195
353
|
}
|
|
196
|
-
return { output, changed: output !== source, rewritten: edits.size };
|
|
354
|
+
return { output, changed: output !== source, rewritten: edits.size, manual };
|
|
197
355
|
}
|
|
198
356
|
}
|
|
199
357
|
exports.ClassRenames = ClassRenames;
|
|
@@ -204,34 +362,55 @@ exports.ClassRenames = ClassRenames;
|
|
|
204
362
|
*/
|
|
205
363
|
class ClassRenamesCommand {
|
|
206
364
|
static { this.USAGE = USAGE; }
|
|
365
|
+
/** A table of renames as a codemod under its own command name. */
|
|
366
|
+
static ofRows(opts) {
|
|
367
|
+
const { name, usage, rows } = opts;
|
|
368
|
+
return {
|
|
369
|
+
name,
|
|
370
|
+
usage,
|
|
371
|
+
isReversible: true,
|
|
372
|
+
marks: ({ reverse }) => rows.map((row) => (reverse ? row.newName : row.oldName)),
|
|
373
|
+
rewrite: (input) => ClassRenames.rewrite({ ...input, rows }),
|
|
374
|
+
};
|
|
375
|
+
}
|
|
207
376
|
static async run(opts) {
|
|
208
377
|
const { root, args } = opts;
|
|
378
|
+
const codemod = opts.codemod ??
|
|
379
|
+
ClassRenamesCommand.ofRows({
|
|
380
|
+
name: 'class-renames',
|
|
381
|
+
usage: USAGE,
|
|
382
|
+
rows: ClassRenameTable.ROWS,
|
|
383
|
+
});
|
|
209
384
|
if (args.includes(ClassRenameFlags.HELP) || args.includes(ClassRenameFlags.HELP_SHORT)) {
|
|
210
|
-
cli_output_1.CliOutput.log(
|
|
385
|
+
cli_output_1.CliOutput.log(codemod.usage);
|
|
211
386
|
return 0;
|
|
212
387
|
}
|
|
213
388
|
const flags = args.filter((argument) => argument.startsWith('-'));
|
|
214
389
|
const paths = args.filter((argument) => !argument.startsWith('-'));
|
|
215
390
|
const unknown = flags.filter((flag) => !ClassRenameFlags.isValid(flag));
|
|
216
391
|
if (unknown.length > 0) {
|
|
217
|
-
cli_output_1.CliOutput.error(`devz codemod: unknown option ${unknown.map((flag) => `"${flag}"`).join(', ')}\n${
|
|
392
|
+
cli_output_1.CliOutput.error(`devz codemod: unknown option ${unknown.map((flag) => `"${flag}"`).join(', ')}\n${codemod.usage}`);
|
|
218
393
|
return USAGE_ERROR_CODE;
|
|
219
394
|
}
|
|
220
395
|
const isWrite = flags.includes(ClassRenameFlags.WRITE);
|
|
221
396
|
const isCheck = flags.includes(ClassRenameFlags.CHECK);
|
|
222
397
|
const isReverse = flags.includes(ClassRenameFlags.REVERSE);
|
|
398
|
+
if (isReverse && !codemod.isReversible) {
|
|
399
|
+
cli_output_1.CliOutput.error(`devz codemod: ${codemod.name} has no ${ClassRenameFlags.REVERSE}\n${codemod.usage}`);
|
|
400
|
+
return USAGE_ERROR_CODE;
|
|
401
|
+
}
|
|
223
402
|
if (isWrite && isCheck) {
|
|
224
|
-
cli_output_1.CliOutput.error(`devz codemod: ${ClassRenameFlags.WRITE} and ${ClassRenameFlags.CHECK} contradict each other\n${
|
|
403
|
+
cli_output_1.CliOutput.error(`devz codemod: ${ClassRenameFlags.WRITE} and ${ClassRenameFlags.CHECK} contradict each other\n${codemod.usage}`);
|
|
225
404
|
return USAGE_ERROR_CODE;
|
|
226
405
|
}
|
|
227
406
|
const refusal = files_1.CodemodFiles.refusal({
|
|
228
|
-
command:
|
|
407
|
+
command: codemod.name,
|
|
229
408
|
isWrite,
|
|
230
409
|
isAll: flags.includes(ClassRenameFlags.ALL),
|
|
231
410
|
paths,
|
|
232
411
|
});
|
|
233
412
|
if (refusal) {
|
|
234
|
-
cli_output_1.CliOutput.error(`${refusal}\n${
|
|
413
|
+
cli_output_1.CliOutput.error(`${refusal}\n${codemod.usage}`);
|
|
235
414
|
return USAGE_ERROR_CODE;
|
|
236
415
|
}
|
|
237
416
|
let typescript;
|
|
@@ -243,11 +422,16 @@ class ClassRenamesCommand {
|
|
|
243
422
|
cli_output_1.CliOutput.error('devz codemod: the "typescript" package is required to read your sources');
|
|
244
423
|
return 1;
|
|
245
424
|
}
|
|
246
|
-
const names =
|
|
425
|
+
const names = codemod.marks({ reverse: isReverse });
|
|
247
426
|
const targets = (paths.length > 0 ? paths : ['.']).map((path) => (0, node_path_1.resolve)(root, path));
|
|
248
427
|
let changedCount = 0;
|
|
249
428
|
let renamedCount = 0;
|
|
250
429
|
let refusedCount = 0;
|
|
430
|
+
let manualCount = 0;
|
|
431
|
+
const { noun, verb } = codemod.unit ?? {
|
|
432
|
+
noun: 'name(s)',
|
|
433
|
+
verb: codemod.isRemoval ? 'removed' : 'renamed',
|
|
434
|
+
};
|
|
251
435
|
for (const target of targets) {
|
|
252
436
|
const files = files_1.CodemodFiles.collect({ target });
|
|
253
437
|
const dirty = isWrite ? files_1.CodemodFiles.dirty({ target }) : undefined;
|
|
@@ -259,16 +443,23 @@ class ClassRenamesCommand {
|
|
|
259
443
|
if (!names.some((name) => source.includes(name))) {
|
|
260
444
|
continue;
|
|
261
445
|
}
|
|
262
|
-
const result =
|
|
446
|
+
const result = codemod.rewrite({
|
|
263
447
|
typescript,
|
|
264
448
|
fileName: file,
|
|
265
449
|
source,
|
|
266
450
|
reverse: isReverse,
|
|
267
451
|
});
|
|
452
|
+
const shown = (0, node_path_1.relative)(root, file).split('\\').join('/') || file;
|
|
453
|
+
manualCount += result.manual.length;
|
|
454
|
+
for (const entry of result.manual) {
|
|
455
|
+
cli_output_1.CliOutput.log(`manual ${shown}:${entry.line} ${entry.note}`);
|
|
456
|
+
}
|
|
457
|
+
for (const entry of result.info ?? []) {
|
|
458
|
+
cli_output_1.CliOutput.log(`review ${shown}:${entry.line} ${entry.note}`);
|
|
459
|
+
}
|
|
268
460
|
if (!result.changed) {
|
|
269
461
|
continue;
|
|
270
462
|
}
|
|
271
|
-
const shown = (0, node_path_1.relative)(root, file).split('\\').join('/') || file;
|
|
272
463
|
if (dirty?.has(file)) {
|
|
273
464
|
refusedCount += 1;
|
|
274
465
|
cli_output_1.CliOutput.warn(`refused ${shown} has local changes (commit, stash or "git add" them, then run again)`);
|
|
@@ -276,13 +467,13 @@ class ClassRenamesCommand {
|
|
|
276
467
|
}
|
|
277
468
|
changedCount += 1;
|
|
278
469
|
renamedCount += result.rewritten;
|
|
279
|
-
cli_output_1.CliOutput.log(`${isWrite ? 'changed' : 'would change'} ${shown} (${result.rewritten}
|
|
470
|
+
cli_output_1.CliOutput.log(`${isWrite ? 'changed' : 'would change'} ${shown} (${result.rewritten} ${noun})`);
|
|
280
471
|
if (isWrite) {
|
|
281
472
|
(0, node_fs_1.writeFileSync)(file, result.output);
|
|
282
473
|
}
|
|
283
474
|
}
|
|
284
475
|
}
|
|
285
|
-
cli_output_1.CliOutput.log(`devz codemod
|
|
476
|
+
cli_output_1.CliOutput.log(`devz codemod ${codemod.name}: ${changedCount} file(s) ${isWrite ? 'changed' : 'would change'}, ${renamedCount} ${noun} ${isWrite ? verb : `would be ${verb}`}` +
|
|
286
477
|
(refusedCount > 0 ? `, ${refusedCount} refused` : ''));
|
|
287
478
|
if (!isWrite && changedCount > 0) {
|
|
288
479
|
cli_output_1.CliOutput.log(`Nothing was written. Run again with ${ClassRenameFlags.WRITE} to apply, then run your typecheck.`);
|
|
@@ -290,7 +481,7 @@ class ClassRenamesCommand {
|
|
|
290
481
|
if (isWrite && refusedCount > 0) {
|
|
291
482
|
return 1;
|
|
292
483
|
}
|
|
293
|
-
return isCheck && changedCount > 0 ? 1 : 0;
|
|
484
|
+
return isCheck && changedCount + manualCount > 0 ? 1 : 0;
|
|
294
485
|
}
|
|
295
486
|
}
|
|
296
487
|
exports.ClassRenamesCommand = ClassRenamesCommand;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"class-renames.js","sourceRoot":"","sources":["../../../src/cli/codemod/class-renames.ts"],"names":[],"mappings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OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,kBAAkB,EAAE;YAChK,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,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7C,CAAC;;AApIH,kDAqIC","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}\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/** Renames the classes of `ClassRenameTable` where a file imports them. */\nexport class ClassRenames {\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 }): IClassRenamesResult {\n const { typescript: ts, fileName, source, reverse = false } = opts;\n const rows = ClassRenameTable.ROWS.map((row) =>\n reverse ? { ...row, oldName: row.newName, newName: row.oldName } : 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\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 rename(imported, row);\n\n if (!element.propertyName) {\n locals.set(element.name.text, row);\n }\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.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\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 static async run(opts: { root: string; args: string[] }): Promise<number> {\n const { root, args } = opts;\n\n if (args.includes(ClassRenameFlags.HELP) || args.includes(ClassRenameFlags.HELP_SHORT)) {\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 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${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 (isWrite && isCheck) {\n CliOutput.error(\n `devz codemod: ${ClassRenameFlags.WRITE} and ${ClassRenameFlags.CHECK} contradict each other\\n${USAGE}`,\n );\n\n return USAGE_ERROR_CODE;\n }\n\n const refusal = CodemodFiles.refusal({\n command: 'class-renames',\n isWrite,\n isAll: flags.includes(ClassRenameFlags.ALL),\n paths,\n });\n\n if (refusal) {\n CliOutput.error(`${refusal}\\n${USAGE}`);\n\n return USAGE_ERROR_CODE;\n }\n\n let typescript: typeof import('typescript');\n\n try {\n const loaded = await import('typescript');\n typescript = loaded.default;\n } catch {\n CliOutput.error('devz codemod: the \"typescript\" package is required to read your sources');\n\n return 1;\n }\n\n const names = ClassRenameTable.ROWS.map((row) => (isReverse ? row.newName : row.oldName));\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\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 = ClassRenames.rewrite({\n typescript,\n fileName: file,\n source,\n reverse: isReverse,\n });\n\n if (!result.changed) {\n continue;\n }\n\n const shown = relative(root, file).split('\\\\').join('/') || file;\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} name(s))`,\n );\n\n if (isWrite) {\n writeFileSync(file, result.output);\n }\n }\n }\n\n CliOutput.log(\n `devz codemod class-renames: ${changedCount} file(s) ${isWrite ? 'changed' : 'would change'}, ${renamedCount} name(s) ${isWrite ? 'renamed' : 'would be renamed'}` +\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 > 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,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,CA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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"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type IClassRename } from './class-renames';
|
|
2
|
+
/** The rename of the promise utilities into `Execution`. */
|
|
3
|
+
export declare class ExecutionClassTable {
|
|
4
|
+
static readonly ROWS: ReadonlyArray<IClassRename>;
|
|
5
|
+
}
|
|
6
|
+
/** `devz codemod execution-class`: `PromiseUtility` to `Execution`. */
|
|
7
|
+
export declare class ExecutionClassCommand {
|
|
8
|
+
static readonly USAGE = "Usage: devz codemod execution-class [paths...] [--write [--all] | --check] [--reverse]\n\nPromiseUtility (@venizia/ignis-helpers, @venizia/ignis) becomes Execution, and two of its methods are renamed:\nexecuteWithLimit is withLimit, voidExecution is fireAndForget. sleep and withTimeout keep their names.\n\nIt reads TypeScript files as \"devz codemod class-renames\" does: named, aliased, type and namespace imports, and\nre-exports. A file that already declares a name \"Execution\" gets the import aliased to \"IgnisExecution\". A method\ntaken apart (\"const { voidExecution } = PromiseUtility\") is not renamed: your typecheck reports it.\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";
|
|
9
|
+
static run(opts: {
|
|
10
|
+
root: string;
|
|
11
|
+
args: string[];
|
|
12
|
+
}): Promise<number>;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=execution-class.d.ts.map
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExecutionClassCommand = exports.ExecutionClassTable = void 0;
|
|
4
|
+
const class_renames_1 = require("./class-renames");
|
|
5
|
+
const USAGE = `Usage: devz codemod execution-class [paths...] [--write [--all] | --check] [--reverse]
|
|
6
|
+
|
|
7
|
+
PromiseUtility (@venizia/ignis-helpers, @venizia/ignis) becomes Execution, and two of its methods are renamed:
|
|
8
|
+
executeWithLimit is withLimit, voidExecution is fireAndForget. sleep and withTimeout keep their names.
|
|
9
|
+
|
|
10
|
+
It reads TypeScript files as "devz codemod class-renames" does: named, aliased, type and namespace imports, and
|
|
11
|
+
re-exports. A file that already declares a name "Execution" gets the import aliased to "IgnisExecution". A method
|
|
12
|
+
taken apart ("const { voidExecution } = PromiseUtility") is not renamed: your typecheck reports it.
|
|
13
|
+
|
|
14
|
+
--write write the changed files (without it, nothing is written); it needs a path, or --all
|
|
15
|
+
--all with --write and no path: rewrite every source file under the working directory
|
|
16
|
+
--check dry run that exits 1 while a file would change (for CI)
|
|
17
|
+
--reverse rename back, for a downgrade
|
|
18
|
+
--help print this text and exit`;
|
|
19
|
+
/** The rename of the promise utilities into `Execution`. */
|
|
20
|
+
class ExecutionClassTable {
|
|
21
|
+
static { this.ROWS = [
|
|
22
|
+
{
|
|
23
|
+
oldName: 'PromiseUtility',
|
|
24
|
+
newName: 'Execution',
|
|
25
|
+
packages: ['@venizia/ignis-helpers', '@venizia/ignis'],
|
|
26
|
+
members: { executeWithLimit: 'withLimit', voidExecution: 'fireAndForget' },
|
|
27
|
+
},
|
|
28
|
+
]; }
|
|
29
|
+
}
|
|
30
|
+
exports.ExecutionClassTable = ExecutionClassTable;
|
|
31
|
+
/** `devz codemod execution-class`: `PromiseUtility` to `Execution`. */
|
|
32
|
+
class ExecutionClassCommand {
|
|
33
|
+
static { this.USAGE = USAGE; }
|
|
34
|
+
static run(opts) {
|
|
35
|
+
return class_renames_1.ClassRenamesCommand.run({
|
|
36
|
+
...opts,
|
|
37
|
+
codemod: class_renames_1.ClassRenamesCommand.ofRows({
|
|
38
|
+
name: 'execution-class',
|
|
39
|
+
usage: USAGE,
|
|
40
|
+
rows: ExecutionClassTable.ROWS,
|
|
41
|
+
}),
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.ExecutionClassCommand = ExecutionClassCommand;
|
|
46
|
+
//# sourceMappingURL=execution-class.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execution-class.js","sourceRoot":"","sources":["../../../src/cli/codemod/execution-class.ts"],"names":[],"mappings":";;;AAAA,mDAAyE;AAEzE,MAAM,KAAK,GAAG;;;;;;;;;;;;;sCAawB,CAAC;AAEvC,4DAA4D;AAC5D,MAAa,mBAAmB;aACd,SAAI,GAAgC;QAClD;YACE,OAAO,EAAE,gBAAgB;YACzB,OAAO,EAAE,WAAW;YACpB,QAAQ,EAAE,CAAC,wBAAwB,EAAE,gBAAgB,CAAC;YACtD,OAAO,EAAE,EAAE,gBAAgB,EAAE,WAAW,EAAE,aAAa,EAAE,eAAe,EAAE;SAC3E;KACF,CAAC;;AARJ,kDASC;AAED,uEAAuE;AACvE,MAAa,qBAAqB;aAChB,UAAK,GAAG,KAAK,CAAC;IAE9B,MAAM,CAAC,GAAG,CAAC,IAAsC;QAC/C,OAAO,mCAAmB,CAAC,GAAG,CAAC;YAC7B,GAAG,IAAI;YACP,OAAO,EAAE,mCAAmB,CAAC,MAAM,CAAC;gBAClC,IAAI,EAAE,iBAAiB;gBACvB,KAAK,EAAE,KAAK;gBACZ,IAAI,EAAE,mBAAmB,CAAC,IAAI;aAC/B,CAAC;SACH,CAAC,CAAC;IACL,CAAC;;AAZH,sDAaC","sourcesContent":["import { ClassRenamesCommand, type IClassRename } from './class-renames';\n\nconst USAGE = `Usage: devz codemod execution-class [paths...] [--write [--all] | --check] [--reverse]\n\nPromiseUtility (@venizia/ignis-helpers, @venizia/ignis) becomes Execution, and two of its methods are renamed:\nexecuteWithLimit is withLimit, voidExecution is fireAndForget. sleep and withTimeout keep their names.\n\nIt reads TypeScript files as \"devz codemod class-renames\" does: named, aliased, type and namespace imports, and\nre-exports. A file that already declares a name \"Execution\" gets the import aliased to \"IgnisExecution\". A method\ntaken apart (\"const { voidExecution } = PromiseUtility\") is not renamed: your typecheck reports it.\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\n/** The rename of the promise utilities into `Execution`. */\nexport class ExecutionClassTable {\n static readonly ROWS: ReadonlyArray<IClassRename> = [\n {\n oldName: 'PromiseUtility',\n newName: 'Execution',\n packages: ['@venizia/ignis-helpers', '@venizia/ignis'],\n members: { executeWithLimit: 'withLimit', voidExecution: 'fireAndForget' },\n },\n ];\n}\n\n/** `devz codemod execution-class`: `PromiseUtility` to `Execution`. */\nexport class ExecutionClassCommand {\n static readonly USAGE = USAGE;\n\n static run(opts: { root: string; args: string[] }): Promise<number> {\n return ClassRenamesCommand.run({\n ...opts,\n codemod: ClassRenamesCommand.ofRows({\n name: 'execution-class',\n usage: USAGE,\n rows: ExecutionClassTable.ROWS,\n }),\n });\n }\n}\n"]}
|