@venizia/dev-configs 0.4.8-7 → 0.4.8-9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/codemod/connector-imports.d.ts +5 -1
- package/dist/cli/codemod/connector-imports.js +21 -7
- package/dist/cli/codemod/connector-imports.js.map +1 -1
- package/dist/cli/codemod/index.js +13 -2
- package/dist/cli/codemod/index.js.map +1 -1
- package/dist/cli/codemod/namespace-functions/index.d.ts +2 -1
- package/dist/cli/codemod/namespace-functions/index.js +14 -5
- package/dist/cli/codemod/namespace-functions/index.js.map +1 -1
- package/dist/cli/codemod/namespace-functions/mappings/core-server.js +1 -1
- package/dist/cli/codemod/namespace-functions/mappings/core-server.js.map +1 -1
- package/dist/cli/codemod/namespace-functions/mappings/helpers.d.ts +3 -0
- package/dist/cli/codemod/namespace-functions/mappings/helpers.js +4 -9
- package/dist/cli/codemod/namespace-functions/mappings/helpers.js.map +1 -1
- package/dist/cli/codemod/namespace-functions/reverse.d.ts +40 -0
- package/dist/cli/codemod/namespace-functions/reverse.js +348 -0
- package/dist/cli/codemod/namespace-functions/reverse.js.map +1 -0
- package/dist/cli/codemod/namespace-functions/rewriter.d.ts +21 -2
- package/dist/cli/codemod/namespace-functions/rewriter.js.map +1 -1
- package/package.json +1 -1
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
export declare class ConnectorSpecifiers {
|
|
3
3
|
static readonly SUBPATHS: ReadonlyArray<string>;
|
|
4
4
|
static readonly MOVES: ReadonlyMap<string, string>;
|
|
5
|
+
/** The same table backward, for a downgrade. */
|
|
6
|
+
static readonly REVERSE_MOVES: ReadonlyMap<string, string>;
|
|
5
7
|
}
|
|
6
8
|
export interface IConnectorImportsResult {
|
|
7
9
|
output: string;
|
|
@@ -15,6 +17,8 @@ export declare class ConnectorImports {
|
|
|
15
17
|
typescript: typeof import('typescript');
|
|
16
18
|
fileName: string;
|
|
17
19
|
source: string;
|
|
20
|
+
/** Move `@venizia/ignis-connectors/<sub-path>` back to `@venizia/ignis/<sub-path>`. */
|
|
21
|
+
reverse?: boolean;
|
|
18
22
|
}): IConnectorImportsResult;
|
|
19
23
|
/**
|
|
20
24
|
* The `package.json` nearest to `file` (not above `root`), and whether it lists the connectors package; `undefined` when
|
|
@@ -34,7 +38,7 @@ export declare class ConnectorImports {
|
|
|
34
38
|
* is given. `--check` is the same dry run, and exits 1 while a file would change.
|
|
35
39
|
*/
|
|
36
40
|
export declare class ConnectorImportsCommand {
|
|
37
|
-
static readonly USAGE = "Usage: devz codemod connector-imports [paths...] [--write | --check]\n\nMoves the connector sub-path imports of @venizia/ignis to @venizia/ignis-connectors. The sub-paths\n@venizia/ignis/postgres, /postgres/node-postgres, /postgres/postgres-js, /postgres/pglite,\n/postgres/supabase, /relational, /sqlite, /sqlite/libsql, /search, /search/controllers, /meilisearch,\n/typesense and /typesense/controllers are removed; each one is the same name under\n@venizia/ignis-connectors, so the rewrite changes only the specifier.\n\nIt reads TypeScript files (.ts, .tsx, .mts, .cts): import and export declarations, import(\"...\"),\nrequire(\"...\"), require.resolve(\"...\") and import.meta.resolve(\"...\"), import(\"...\") types, declare module\n\"...\" and the module name of mock.module(\"...\") style calls. A .js, .cjs or .mjs file is not read: edit it by hand. Other sub-paths of @venizia/ignis (mail, static-asset,\ntesting, websocket, ...) and the root are not touched. The app must list @venizia/ignis-connectors as a\ndirect dependency: it reports each package.json that does not.\n\n --write write the changed files (without it, nothing is written)\n --check dry run that exits 1 while a file would change (for CI)\n --help print this text and exit\n\nWith no flag it lists what would change and writes nothing. Inside a git repository it reads the\nfiles git knows (tracked, or untracked and not ignored), and --write refuses a file with local changes\n(changed, staged or untracked): commit or stash it first, so git can undo the codemod.";
|
|
41
|
+
static readonly USAGE = "Usage: devz codemod connector-imports [paths...] [--write | --check] [--reverse]\n\nMoves the connector sub-path imports of @venizia/ignis to @venizia/ignis-connectors. The sub-paths\n@venizia/ignis/postgres, /postgres/node-postgres, /postgres/postgres-js, /postgres/pglite,\n/postgres/supabase, /relational, /sqlite, /sqlite/libsql, /search, /search/controllers, /meilisearch,\n/typesense and /typesense/controllers are removed; each one is the same name under\n@venizia/ignis-connectors, so the rewrite changes only the specifier.\n\nIt reads TypeScript files (.ts, .tsx, .mts, .cts): import and export declarations, import(\"...\"),\nrequire(\"...\"), require.resolve(\"...\") and import.meta.resolve(\"...\"), import(\"...\") types, declare module\n\"...\" and the module name of mock.module(\"...\") style calls. A .js, .cjs or .mjs file is not read: edit it by hand. Other sub-paths of @venizia/ignis (mail, static-asset,\ntesting, websocket, ...) and the root are not touched. The app must list @venizia/ignis-connectors as a\ndirect dependency: it reports each package.json that does not.\n\n --write write the changed files (without it, nothing is written)\n --check dry run that exits 1 while a file would change (for CI)\n --reverse move the specifiers back, for a downgrade: @venizia/ignis-connectors/<sub-path> becomes\n @venizia/ignis/<sub-path>\n --help print this text and exit\n\nWith no flag it lists what would change and writes nothing. Inside a git repository it reads the\nfiles git knows (tracked, or untracked and not ignored), and --write refuses a file with local changes\n(changed, staged or untracked): commit or stash it first, so git can undo the codemod.";
|
|
38
42
|
static run(opts: {
|
|
39
43
|
root: string;
|
|
40
44
|
args: string[];
|
|
@@ -4,7 +4,7 @@ exports.ConnectorImportsCommand = exports.ConnectorImports = exports.ConnectorSp
|
|
|
4
4
|
const node_fs_1 = require("node:fs");
|
|
5
5
|
const node_path_1 = require("node:path");
|
|
6
6
|
const files_1 = require("./files");
|
|
7
|
-
const USAGE = `Usage: devz codemod connector-imports [paths...] [--write | --check]
|
|
7
|
+
const USAGE = `Usage: devz codemod connector-imports [paths...] [--write | --check] [--reverse]
|
|
8
8
|
|
|
9
9
|
Moves the connector sub-path imports of @venizia/ignis to @venizia/ignis-connectors. The sub-paths
|
|
10
10
|
@venizia/ignis/postgres, /postgres/node-postgres, /postgres/postgres-js, /postgres/pglite,
|
|
@@ -20,6 +20,8 @@ direct dependency: it reports each package.json that does not.
|
|
|
20
20
|
|
|
21
21
|
--write write the changed files (without it, nothing is written)
|
|
22
22
|
--check dry run that exits 1 while a file would change (for CI)
|
|
23
|
+
--reverse move the specifiers back, for a downgrade: @venizia/ignis-connectors/<sub-path> becomes
|
|
24
|
+
@venizia/ignis/<sub-path>
|
|
23
25
|
--help print this text and exit
|
|
24
26
|
|
|
25
27
|
With no flag it lists what would change and writes nothing. Inside a git repository it reads the
|
|
@@ -43,11 +45,13 @@ const MODULE_NAME_CALLS = new Set([
|
|
|
43
45
|
class ConnectorImportsFlags {
|
|
44
46
|
static { this.WRITE = '--write'; }
|
|
45
47
|
static { this.CHECK = '--check'; }
|
|
48
|
+
static { this.REVERSE = '--reverse'; }
|
|
46
49
|
static { this.HELP = '--help'; }
|
|
47
50
|
static { this.HELP_SHORT = '-h'; }
|
|
48
51
|
static { this.SCHEME_SET = new Set([
|
|
49
52
|
this.WRITE,
|
|
50
53
|
this.CHECK,
|
|
54
|
+
this.REVERSE,
|
|
51
55
|
this.HELP,
|
|
52
56
|
this.HELP_SHORT,
|
|
53
57
|
]); }
|
|
@@ -76,12 +80,15 @@ class ConnectorSpecifiers {
|
|
|
76
80
|
`${OLD_PREFIX}${subpath}`,
|
|
77
81
|
`${CONNECTORS_PACKAGE}/${subpath}`,
|
|
78
82
|
])); }
|
|
83
|
+
/** The same table backward, for a downgrade. */
|
|
84
|
+
static { this.REVERSE_MOVES = new Map([...ConnectorSpecifiers.MOVES].map(([from, to]) => [to, from])); }
|
|
79
85
|
}
|
|
80
86
|
exports.ConnectorSpecifiers = ConnectorSpecifiers;
|
|
81
87
|
/** Rewrites the module specifiers of the removed connector sub-paths. */
|
|
82
88
|
class ConnectorImports {
|
|
83
89
|
static rewrite(opts) {
|
|
84
|
-
const { typescript: ts, fileName, source } = opts;
|
|
90
|
+
const { typescript: ts, fileName, source, reverse = false } = opts;
|
|
91
|
+
const moves = reverse ? ConnectorSpecifiers.REVERSE_MOVES : ConnectorSpecifiers.MOVES;
|
|
85
92
|
const scriptKind = fileName.endsWith('.tsx') ? ts.ScriptKind.TSX : ts.ScriptKind.TS;
|
|
86
93
|
const file = ts.createSourceFile(fileName, source, ts.ScriptTarget.Latest, true, scriptKind);
|
|
87
94
|
const edits = [];
|
|
@@ -89,7 +96,7 @@ class ConnectorImports {
|
|
|
89
96
|
if (!literal || !ts.isStringLiteralLike(literal)) {
|
|
90
97
|
return;
|
|
91
98
|
}
|
|
92
|
-
const moved =
|
|
99
|
+
const moved = moves.get(literal.text);
|
|
93
100
|
if (moved === undefined) {
|
|
94
101
|
return;
|
|
95
102
|
}
|
|
@@ -205,6 +212,8 @@ class ConnectorImportsCommand {
|
|
|
205
212
|
}
|
|
206
213
|
const isWrite = flags.includes(ConnectorImportsFlags.WRITE);
|
|
207
214
|
const isCheck = flags.includes(ConnectorImportsFlags.CHECK);
|
|
215
|
+
const isReverse = flags.includes(ConnectorImportsFlags.REVERSE);
|
|
216
|
+
const marker = isReverse ? `${CONNECTORS_PACKAGE}/` : OLD_PREFIX;
|
|
208
217
|
if (isWrite && isCheck) {
|
|
209
218
|
console.error(`devz codemod: ${ConnectorImportsFlags.WRITE} and ${ConnectorImportsFlags.CHECK} contradict each other\n${USAGE}`);
|
|
210
219
|
return USAGE_ERROR_CODE;
|
|
@@ -231,10 +240,15 @@ class ConnectorImportsCommand {
|
|
|
231
240
|
}
|
|
232
241
|
for (const file of files) {
|
|
233
242
|
const source = (0, node_fs_1.readFileSync)(file, 'utf8');
|
|
234
|
-
if (!source.includes(
|
|
243
|
+
if (!source.includes(marker)) {
|
|
235
244
|
continue;
|
|
236
245
|
}
|
|
237
|
-
const result = ConnectorImports.rewrite({
|
|
246
|
+
const result = ConnectorImports.rewrite({
|
|
247
|
+
typescript,
|
|
248
|
+
fileName: file,
|
|
249
|
+
source,
|
|
250
|
+
reverse: isReverse,
|
|
251
|
+
});
|
|
238
252
|
if (!result.changed) {
|
|
239
253
|
continue;
|
|
240
254
|
}
|
|
@@ -248,7 +262,7 @@ class ConnectorImportsCommand {
|
|
|
248
262
|
specifierCount += result.rewritten;
|
|
249
263
|
console.log(`${isWrite ? 'changed' : 'would change'} ${shown} (${result.rewritten} specifier(s))`);
|
|
250
264
|
const manifest = ConnectorImports.findManifest({ file, root });
|
|
251
|
-
if (manifest && !manifest.hasConnectors) {
|
|
265
|
+
if (!isReverse && manifest && !manifest.hasConnectors) {
|
|
252
266
|
missing.add((0, node_path_1.relative)(root, manifest.path).split('\\').join('/') || manifest.path);
|
|
253
267
|
}
|
|
254
268
|
if (isWrite) {
|
|
@@ -262,7 +276,7 @@ class ConnectorImportsCommand {
|
|
|
262
276
|
console.warn(`${manifestPath} does not list ${CONNECTORS_PACKAGE}: add it as a dependency, because the imports now come from it`);
|
|
263
277
|
}
|
|
264
278
|
if (!isWrite && changedCount > 0) {
|
|
265
|
-
console.log(`Nothing was written. Run again with ${ConnectorImportsFlags.WRITE} to apply, then add the dependency and run your typecheck.`);
|
|
279
|
+
console.log(`Nothing was written. Run again with ${ConnectorImportsFlags.WRITE} to apply, then ${isReverse ? 'remove the dependency if nothing else uses it and ' : 'add the dependency and '}run your typecheck.`);
|
|
266
280
|
}
|
|
267
281
|
if (isWrite && refusedCount > 0) {
|
|
268
282
|
return 1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connector-imports.js","sourceRoot":"","sources":["../../../src/cli/codemod/connector-imports.ts"],"names":[],"mappings":";;;AAAA,qCAAkE;AAClE,yCAA6D;AAC7D,mCAAuC;AAEvC,MAAM,KAAK,GAAG;;;;;;;;;;;;;;;;;;;;uFAoByE,CAAC;AAExF,kDAAkD;AAClD,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAE3B,MAAM,kBAAkB,GAAG,2BAA2B,CAAC;AACvD,MAAM,UAAU,GAAG,iBAAiB,CAAC;AAErC,uGAAuG;AACvG,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAC;IAChC,QAAQ;IACR,MAAM;IACN,QAAQ;IACR,QAAQ;IACR,cAAc;IACd,eAAe;IACf,YAAY;IACZ,aAAa;CACd,C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I,OAAO,EAAE,CAAC;oBACZ,IAAA,uBAAa,EAAC,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;gBACrC,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,CAAC,GAAG,CACT,mCAAmC,YAAY,YAAY,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,cAAc,KAAK,cAAc,iBAAiB,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,gBAAgB,EAAE;YACvK,CAAC,YAAY,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,YAAY,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,CACxD,CAAC;QAEF,KAAK,MAAM,YAAY,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;YAC/C,OAAO,CAAC,IAAI,CACV,GAAG,YAAY,mBAAmB,kBAAkB,gEAAgE,CACrH,CAAC;QACJ,CAAC;QAED,IAAI,CAAC,OAAO,IAAI,YAAY,GAAG,CAAC,EAAE,CAAC;YACjC,OAAO,CAAC,GAAG,CACT,uCAAuC,qBAAqB,CAAC,KAAK,4DAA4D,CAC/H,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;;AAjIH,0DAkIC","sourcesContent":["import { existsSync, readFileSync, writeFileSync } from 'node:fs';\nimport { dirname, join, relative, resolve } from 'node:path';\nimport { CodemodFiles } from './files';\n\nconst USAGE = `Usage: devz codemod connector-imports [paths...] [--write | --check]\n\nMoves the connector sub-path imports of @venizia/ignis to @venizia/ignis-connectors. The sub-paths\n@venizia/ignis/postgres, /postgres/node-postgres, /postgres/postgres-js, /postgres/pglite,\n/postgres/supabase, /relational, /sqlite, /sqlite/libsql, /search, /search/controllers, /meilisearch,\n/typesense and /typesense/controllers are removed; each one is the same name under\n@venizia/ignis-connectors, so the rewrite changes only the specifier.\n\nIt reads TypeScript files (.ts, .tsx, .mts, .cts): import and export declarations, import(\"...\"),\nrequire(\"...\"), require.resolve(\"...\") and import.meta.resolve(\"...\"), import(\"...\") types, declare module\n\"...\" and the module name of mock.module(\"...\") style calls. A .js, .cjs or .mjs file is not read: edit it by hand. Other sub-paths of @venizia/ignis (mail, static-asset,\ntesting, websocket, ...) and the root are not touched. The app must list @venizia/ignis-connectors as a\ndirect dependency: it reports each package.json that does not.\n\n --write write the changed files (without it, nothing is written)\n --check dry run that exits 1 while a file would change (for CI)\n --help print this text and exit\n\nWith no flag it lists what would change and writes nothing. Inside a git repository it reads the\nfiles git knows (tracked, or untracked and not ignored), and --write refuses a file with local changes\n(changed, staged or untracked): commit or stash it first, so git can undo the codemod.`;\n\n/** A usage error: nothing was read or written. */\nconst USAGE_ERROR_CODE = 2;\n\nconst CONNECTORS_PACKAGE = '@venizia/ignis-connectors';\nconst OLD_PREFIX = '@venizia/ignis/';\n\n/** The call names that take a module name as their first argument besides `require` and `import()`. */\nconst MODULE_NAME_CALLS = new Set([\n 'module',\n 'mock',\n 'doMock',\n 'unmock',\n 'importActual',\n 'requireActual',\n 'importMock',\n 'requireMock',\n]);\n\nclass ConnectorImportsFlags {\n static readonly WRITE = '--write';\n static readonly CHECK = '--check';\n static readonly HELP = '--help';\n static readonly HELP_SHORT = '-h';\n\n static readonly SCHEME_SET = new Set<string>([\n this.WRITE,\n this.CHECK,\n this.HELP,\n this.HELP_SHORT,\n ]);\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n}\n\n/** The removed `@venizia/ignis/<sub-path>` specifiers and the `@venizia/ignis-connectors/<sub-path>` they became. */\nexport class ConnectorSpecifiers {\n static readonly SUBPATHS: ReadonlyArray<string> = [\n 'postgres',\n 'postgres/node-postgres',\n 'postgres/postgres-js',\n 'postgres/pglite',\n 'postgres/supabase',\n 'relational',\n 'sqlite',\n 'sqlite/libsql',\n 'search',\n 'search/controllers',\n 'meilisearch',\n 'typesense',\n 'typesense/controllers',\n ];\n\n static readonly MOVES: ReadonlyMap<string, string> = new Map(\n ConnectorSpecifiers.SUBPATHS.map((subpath) => [\n `${OLD_PREFIX}${subpath}`,\n `${CONNECTORS_PACKAGE}/${subpath}`,\n ]),\n );\n}\n\nexport interface IConnectorImportsResult {\n output: string;\n changed: boolean;\n /** How many specifiers were moved. */\n rewritten: number;\n}\n\n/** Rewrites the module specifiers of the removed connector sub-paths. */\nexport class ConnectorImports {\n static rewrite(opts: {\n typescript: typeof import('typescript');\n fileName: string;\n source: string;\n }): IConnectorImportsResult {\n const { typescript: ts, fileName, source } = opts;\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: Array<{ start: number; end: number; text: string }> = [];\n\n const consider = (literal: import('typescript').Node | undefined) => {\n if (!literal || !ts.isStringLiteralLike(literal)) {\n return;\n }\n\n const moved = ConnectorSpecifiers.MOVES.get(literal.text);\n\n if (moved === undefined) {\n return;\n }\n\n const start = literal.getStart(file);\n const quote = source[start];\n edits.push({ start, end: literal.getEnd(), text: `${quote}${moved}${quote}` });\n };\n\n const isModuleNameCall = (call: import('typescript').CallExpression): boolean => {\n const callee = call.expression;\n\n if (callee.kind === ts.SyntaxKind.ImportKeyword) {\n return true;\n }\n\n if (ts.isIdentifier(callee)) {\n return callee.text === 'require';\n }\n\n if (!ts.isPropertyAccessExpression(callee)) {\n return false;\n }\n\n if (callee.name.text === 'resolve') {\n return (\n (ts.isIdentifier(callee.expression) && callee.expression.text === 'require') ||\n ts.isMetaProperty(callee.expression)\n );\n }\n\n return MODULE_NAME_CALLS.has(callee.name.text);\n };\n\n const visit = (node: import('typescript').Node): void => {\n if (ts.isImportDeclaration(node) || ts.isExportDeclaration(node)) {\n consider(node.moduleSpecifier);\n } else if (ts.isImportEqualsDeclaration(node)) {\n if (ts.isExternalModuleReference(node.moduleReference)) {\n consider(node.moduleReference.expression);\n }\n } else if (ts.isCallExpression(node)) {\n if (isModuleNameCall(node)) {\n consider(node.arguments[0]);\n }\n } else if (ts.isModuleDeclaration(node)) {\n consider(node.name);\n } else if (ts.isImportTypeNode(node)) {\n if (ts.isLiteralTypeNode(node.argument)) {\n consider(node.argument.literal);\n }\n }\n\n ts.forEachChild(node, visit);\n };\n\n visit(file);\n\n if (edits.length === 0) {\n return { output: source, changed: false, rewritten: 0 };\n }\n\n let output = source;\n\n for (const edit of edits.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: true, rewritten: edits.length };\n }\n\n /**\n * The `package.json` nearest to `file` (not above `root`), and whether it lists the connectors package; `undefined` when\n * there is none to read.\n */\n static findManifest(opts: {\n file: string;\n root: string;\n }): { path: string; hasConnectors: boolean } | undefined {\n const { file, root } = opts;\n let directory = dirname(file);\n\n for (;;) {\n const candidate = join(directory, 'package.json');\n\n if (existsSync(candidate)) {\n let manifest: unknown;\n\n try {\n manifest = JSON.parse(readFileSync(candidate, 'utf8'));\n } catch (error) {\n console.warn(\n `${candidate} is not valid JSON, so its dependencies were not checked | ${error instanceof Error ? error.message : String(error)}`,\n );\n\n return undefined;\n }\n\n const listed =\n typeof manifest === 'object' &&\n manifest !== null &&\n ['dependencies', 'devDependencies', 'peerDependencies'].some((field) => {\n const group: unknown = Reflect.get(manifest, field);\n\n return typeof group === 'object' && group !== null && CONNECTORS_PACKAGE in group;\n });\n\n return { path: candidate, hasConnectors: listed };\n }\n\n if (directory === root || dirname(directory) === directory) {\n return undefined;\n }\n\n directory = dirname(directory);\n }\n }\n}\n\n/**\n * `devz codemod connector-imports [paths...] [--write | --check]`: moves the removed\n * `@venizia/ignis/<connector sub-path>` specifiers to `@venizia/ignis-connectors`. It is a dry run unless `--write`\n * is given. `--check` is the same dry run, and exits 1 while a file would change.\n */\nexport class ConnectorImportsCommand {\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 (\n args.includes(ConnectorImportsFlags.HELP) ||\n args.includes(ConnectorImportsFlags.HELP_SHORT)\n ) {\n console.log(USAGE);\n\n return 0;\n }\n\n const flags = args.filter((argument) => argument.startsWith('-'));\n const paths = args.filter((argument) => !argument.startsWith('-'));\n\n const unknown = flags.filter((flag) => !ConnectorImportsFlags.isValid(flag));\n\n if (unknown.length > 0) {\n console.error(\n `devz codemod: unknown option ${unknown.map((flag) => `\"${flag}\"`).join(', ')}\\n${USAGE}`,\n );\n\n return USAGE_ERROR_CODE;\n }\n\n const isWrite = flags.includes(ConnectorImportsFlags.WRITE);\n const isCheck = flags.includes(ConnectorImportsFlags.CHECK);\n\n if (isWrite && isCheck) {\n console.error(\n `devz codemod: ${ConnectorImportsFlags.WRITE} and ${ConnectorImportsFlags.CHECK} contradict each other\\n${USAGE}`,\n );\n\n return USAGE_ERROR_CODE;\n }\n\n let typescript: typeof import('typescript');\n\n try {\n const loaded = await import('typescript');\n typescript = loaded.default;\n } catch {\n console.error('devz codemod: the \"typescript\" package is required to read your sources');\n\n return 1;\n }\n\n const targets = (paths.length > 0 ? paths : ['.']).map((path) => resolve(root, path));\n const missing = new Set<string>();\n let changedCount = 0;\n let specifierCount = 0;\n let refusedCount = 0;\n\n for (const target of targets) {\n const files = CodemodFiles.collect({ target });\n const dirty = isWrite ? CodemodFiles.dirty({ target }) : undefined;\n\n if (files.length === 0 && paths.length > 0) {\n console.warn(\n `devz codemod: no source files under \"${relative(root, target) || target}\" (git ignores the path, or it holds none): nothing was read`,\n );\n }\n\n for (const file of files) {\n const source = readFileSync(file, 'utf8');\n\n if (!source.includes(OLD_PREFIX)) {\n continue;\n }\n\n const result = ConnectorImports.rewrite({ typescript, fileName: file, source });\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 console.warn(\n `refused ${shown} has local changes (commit or stash them, then run again)`,\n );\n continue;\n }\n\n changedCount += 1;\n specifierCount += result.rewritten;\n console.log(\n `${isWrite ? 'changed' : 'would change'} ${shown} (${result.rewritten} specifier(s))`,\n );\n\n const manifest = ConnectorImports.findManifest({ file, root });\n\n if (manifest && !manifest.hasConnectors) {\n missing.add(relative(root, manifest.path).split('\\\\').join('/') || manifest.path);\n }\n\n if (isWrite) {\n writeFileSync(file, result.output);\n }\n }\n }\n\n console.log(\n `devz codemod connector-imports: ${changedCount} file(s) ${isWrite ? 'changed' : 'would change'}, ${specifierCount} specifier(s) ${isWrite ? 'moved' : 'would be moved'}` +\n (refusedCount > 0 ? `, ${refusedCount} refused` : ''),\n );\n\n for (const manifestPath of [...missing].sort()) {\n console.warn(\n `${manifestPath} does not list ${CONNECTORS_PACKAGE}: add it as a dependency, because the imports now come from it`,\n );\n }\n\n if (!isWrite && changedCount > 0) {\n console.log(\n `Nothing was written. Run again with ${ConnectorImportsFlags.WRITE} to apply, then add the dependency and 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":"connector-imports.js","sourceRoot":"","sources":["../../../src/cli/codemod/connector-imports.ts"],"names":[],"mappings":";;;AAAA,qCAAkE;AAClE,yCAA6D;AAC7D,mCAAuC;AAEvC,MAAM,KAAK,GAAG;;;;;;;;;;;;;;;;;;;;;;uFAsByE,CAAC;AAExF,kDAAkD;AAClD,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAE3B,MAAM,kBAAkB,GAAG,2BAA2B,CAAC;AACvD,MAAM,UAAU,GAAG,iBAAiB,CAAC;AAErC,uGAAuG;AACvG,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAC;IAChC,QAAQ;IACR,MAAM;IACN,QAAQ;IACR,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AkB,gEAAgE,CACrH,CAAC;QACJ,CAAC;QAED,IAAI,CAAC,OAAO,IAAI,YAAY,GAAG,CAAC,EAAE,CAAC;YACjC,OAAO,CAAC,GAAG,CACT,uCAAuC,qBAAqB,CAAC,KAAK,mBAAmB,SAAS,CAAC,CAAC,CAAC,oDAAoD,CAAC,CAAC,CAAC,yBAAyB,qBAAqB,CACvM,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;;AAxIH,0DAyIC","sourcesContent":["import { existsSync, readFileSync, writeFileSync } from 'node:fs';\nimport { dirname, join, relative, resolve } from 'node:path';\nimport { CodemodFiles } from './files';\n\nconst USAGE = `Usage: devz codemod connector-imports [paths...] [--write | --check] [--reverse]\n\nMoves the connector sub-path imports of @venizia/ignis to @venizia/ignis-connectors. The sub-paths\n@venizia/ignis/postgres, /postgres/node-postgres, /postgres/postgres-js, /postgres/pglite,\n/postgres/supabase, /relational, /sqlite, /sqlite/libsql, /search, /search/controllers, /meilisearch,\n/typesense and /typesense/controllers are removed; each one is the same name under\n@venizia/ignis-connectors, so the rewrite changes only the specifier.\n\nIt reads TypeScript files (.ts, .tsx, .mts, .cts): import and export declarations, import(\"...\"),\nrequire(\"...\"), require.resolve(\"...\") and import.meta.resolve(\"...\"), import(\"...\") types, declare module\n\"...\" and the module name of mock.module(\"...\") style calls. A .js, .cjs or .mjs file is not read: edit it by hand. Other sub-paths of @venizia/ignis (mail, static-asset,\ntesting, websocket, ...) and the root are not touched. The app must list @venizia/ignis-connectors as a\ndirect dependency: it reports each package.json that does not.\n\n --write write the changed files (without it, nothing is written)\n --check dry run that exits 1 while a file would change (for CI)\n --reverse move the specifiers back, for a downgrade: @venizia/ignis-connectors/<sub-path> becomes\n @venizia/ignis/<sub-path>\n --help print this text and exit\n\nWith no flag it lists what would change and writes nothing. Inside a git repository it reads the\nfiles git knows (tracked, or untracked and not ignored), and --write refuses a file with local changes\n(changed, staged or untracked): commit or stash it first, so git can undo the codemod.`;\n\n/** A usage error: nothing was read or written. */\nconst USAGE_ERROR_CODE = 2;\n\nconst CONNECTORS_PACKAGE = '@venizia/ignis-connectors';\nconst OLD_PREFIX = '@venizia/ignis/';\n\n/** The call names that take a module name as their first argument besides `require` and `import()`. */\nconst MODULE_NAME_CALLS = new Set([\n 'module',\n 'mock',\n 'doMock',\n 'unmock',\n 'importActual',\n 'requireActual',\n 'importMock',\n 'requireMock',\n]);\n\nclass ConnectorImportsFlags {\n static readonly WRITE = '--write';\n static readonly CHECK = '--check';\n static readonly REVERSE = '--reverse';\n static readonly HELP = '--help';\n static readonly HELP_SHORT = '-h';\n\n static readonly SCHEME_SET = new Set<string>([\n this.WRITE,\n this.CHECK,\n this.REVERSE,\n this.HELP,\n this.HELP_SHORT,\n ]);\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n}\n\n/** The removed `@venizia/ignis/<sub-path>` specifiers and the `@venizia/ignis-connectors/<sub-path>` they became. */\nexport class ConnectorSpecifiers {\n static readonly SUBPATHS: ReadonlyArray<string> = [\n 'postgres',\n 'postgres/node-postgres',\n 'postgres/postgres-js',\n 'postgres/pglite',\n 'postgres/supabase',\n 'relational',\n 'sqlite',\n 'sqlite/libsql',\n 'search',\n 'search/controllers',\n 'meilisearch',\n 'typesense',\n 'typesense/controllers',\n ];\n\n static readonly MOVES: ReadonlyMap<string, string> = new Map(\n ConnectorSpecifiers.SUBPATHS.map((subpath) => [\n `${OLD_PREFIX}${subpath}`,\n `${CONNECTORS_PACKAGE}/${subpath}`,\n ]),\n );\n\n /** The same table backward, for a downgrade. */\n static readonly REVERSE_MOVES: ReadonlyMap<string, string> = new Map(\n [...ConnectorSpecifiers.MOVES].map(([from, to]) => [to, from]),\n );\n}\n\nexport interface IConnectorImportsResult {\n output: string;\n changed: boolean;\n /** How many specifiers were moved. */\n rewritten: number;\n}\n\n/** Rewrites the module specifiers of the removed connector sub-paths. */\nexport class ConnectorImports {\n static rewrite(opts: {\n typescript: typeof import('typescript');\n fileName: string;\n source: string;\n /** Move `@venizia/ignis-connectors/<sub-path>` back to `@venizia/ignis/<sub-path>`. */\n reverse?: boolean;\n }): IConnectorImportsResult {\n const { typescript: ts, fileName, source, reverse = false } = opts;\n const moves = reverse ? ConnectorSpecifiers.REVERSE_MOVES : ConnectorSpecifiers.MOVES;\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: Array<{ start: number; end: number; text: string }> = [];\n\n const consider = (literal: import('typescript').Node | undefined) => {\n if (!literal || !ts.isStringLiteralLike(literal)) {\n return;\n }\n\n const moved = moves.get(literal.text);\n\n if (moved === undefined) {\n return;\n }\n\n const start = literal.getStart(file);\n const quote = source[start];\n edits.push({ start, end: literal.getEnd(), text: `${quote}${moved}${quote}` });\n };\n\n const isModuleNameCall = (call: import('typescript').CallExpression): boolean => {\n const callee = call.expression;\n\n if (callee.kind === ts.SyntaxKind.ImportKeyword) {\n return true;\n }\n\n if (ts.isIdentifier(callee)) {\n return callee.text === 'require';\n }\n\n if (!ts.isPropertyAccessExpression(callee)) {\n return false;\n }\n\n if (callee.name.text === 'resolve') {\n return (\n (ts.isIdentifier(callee.expression) && callee.expression.text === 'require') ||\n ts.isMetaProperty(callee.expression)\n );\n }\n\n return MODULE_NAME_CALLS.has(callee.name.text);\n };\n\n const visit = (node: import('typescript').Node): void => {\n if (ts.isImportDeclaration(node) || ts.isExportDeclaration(node)) {\n consider(node.moduleSpecifier);\n } else if (ts.isImportEqualsDeclaration(node)) {\n if (ts.isExternalModuleReference(node.moduleReference)) {\n consider(node.moduleReference.expression);\n }\n } else if (ts.isCallExpression(node)) {\n if (isModuleNameCall(node)) {\n consider(node.arguments[0]);\n }\n } else if (ts.isModuleDeclaration(node)) {\n consider(node.name);\n } else if (ts.isImportTypeNode(node)) {\n if (ts.isLiteralTypeNode(node.argument)) {\n consider(node.argument.literal);\n }\n }\n\n ts.forEachChild(node, visit);\n };\n\n visit(file);\n\n if (edits.length === 0) {\n return { output: source, changed: false, rewritten: 0 };\n }\n\n let output = source;\n\n for (const edit of edits.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: true, rewritten: edits.length };\n }\n\n /**\n * The `package.json` nearest to `file` (not above `root`), and whether it lists the connectors package; `undefined` when\n * there is none to read.\n */\n static findManifest(opts: {\n file: string;\n root: string;\n }): { path: string; hasConnectors: boolean } | undefined {\n const { file, root } = opts;\n let directory = dirname(file);\n\n for (;;) {\n const candidate = join(directory, 'package.json');\n\n if (existsSync(candidate)) {\n let manifest: unknown;\n\n try {\n manifest = JSON.parse(readFileSync(candidate, 'utf8'));\n } catch (error) {\n console.warn(\n `${candidate} is not valid JSON, so its dependencies were not checked | ${error instanceof Error ? error.message : String(error)}`,\n );\n\n return undefined;\n }\n\n const listed =\n typeof manifest === 'object' &&\n manifest !== null &&\n ['dependencies', 'devDependencies', 'peerDependencies'].some((field) => {\n const group: unknown = Reflect.get(manifest, field);\n\n return typeof group === 'object' && group !== null && CONNECTORS_PACKAGE in group;\n });\n\n return { path: candidate, hasConnectors: listed };\n }\n\n if (directory === root || dirname(directory) === directory) {\n return undefined;\n }\n\n directory = dirname(directory);\n }\n }\n}\n\n/**\n * `devz codemod connector-imports [paths...] [--write | --check]`: moves the removed\n * `@venizia/ignis/<connector sub-path>` specifiers to `@venizia/ignis-connectors`. It is a dry run unless `--write`\n * is given. `--check` is the same dry run, and exits 1 while a file would change.\n */\nexport class ConnectorImportsCommand {\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 (\n args.includes(ConnectorImportsFlags.HELP) ||\n args.includes(ConnectorImportsFlags.HELP_SHORT)\n ) {\n console.log(USAGE);\n\n return 0;\n }\n\n const flags = args.filter((argument) => argument.startsWith('-'));\n const paths = args.filter((argument) => !argument.startsWith('-'));\n\n const unknown = flags.filter((flag) => !ConnectorImportsFlags.isValid(flag));\n\n if (unknown.length > 0) {\n console.error(\n `devz codemod: unknown option ${unknown.map((flag) => `\"${flag}\"`).join(', ')}\\n${USAGE}`,\n );\n\n return USAGE_ERROR_CODE;\n }\n\n const isWrite = flags.includes(ConnectorImportsFlags.WRITE);\n const isCheck = flags.includes(ConnectorImportsFlags.CHECK);\n const isReverse = flags.includes(ConnectorImportsFlags.REVERSE);\n const marker = isReverse ? `${CONNECTORS_PACKAGE}/` : OLD_PREFIX;\n\n if (isWrite && isCheck) {\n console.error(\n `devz codemod: ${ConnectorImportsFlags.WRITE} and ${ConnectorImportsFlags.CHECK} contradict each other\\n${USAGE}`,\n );\n\n return USAGE_ERROR_CODE;\n }\n\n let typescript: typeof import('typescript');\n\n try {\n const loaded = await import('typescript');\n typescript = loaded.default;\n } catch {\n console.error('devz codemod: the \"typescript\" package is required to read your sources');\n\n return 1;\n }\n\n const targets = (paths.length > 0 ? paths : ['.']).map((path) => resolve(root, path));\n const missing = new Set<string>();\n let changedCount = 0;\n let specifierCount = 0;\n let refusedCount = 0;\n\n for (const target of targets) {\n const files = CodemodFiles.collect({ target });\n const dirty = isWrite ? CodemodFiles.dirty({ target }) : undefined;\n\n if (files.length === 0 && paths.length > 0) {\n console.warn(\n `devz codemod: no source files under \"${relative(root, target) || target}\" (git ignores the path, or it holds none): nothing was read`,\n );\n }\n\n for (const file of files) {\n const source = readFileSync(file, 'utf8');\n\n if (!source.includes(marker)) {\n continue;\n }\n\n const result = ConnectorImports.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 console.warn(\n `refused ${shown} has local changes (commit or stash them, then run again)`,\n );\n continue;\n }\n\n changedCount += 1;\n specifierCount += result.rewritten;\n console.log(\n `${isWrite ? 'changed' : 'would change'} ${shown} (${result.rewritten} specifier(s))`,\n );\n\n const manifest = ConnectorImports.findManifest({ file, root });\n\n if (!isReverse && manifest && !manifest.hasConnectors) {\n missing.add(relative(root, manifest.path).split('\\\\').join('/') || manifest.path);\n }\n\n if (isWrite) {\n writeFileSync(file, result.output);\n }\n }\n }\n\n console.log(\n `devz codemod connector-imports: ${changedCount} file(s) ${isWrite ? 'changed' : 'would change'}, ${specifierCount} specifier(s) ${isWrite ? 'moved' : 'would be moved'}` +\n (refusedCount > 0 ? `, ${refusedCount} refused` : ''),\n );\n\n for (const manifestPath of [...missing].sort()) {\n console.warn(\n `${manifestPath} does not list ${CONNECTORS_PACKAGE}: add it as a dependency, because the imports now come from it`,\n );\n }\n\n if (!isWrite && changedCount > 0) {\n console.log(\n `Nothing was written. Run again with ${ConnectorImportsFlags.WRITE} to apply, then ${isReverse ? 'remove the dependency if nothing else uses it and ' : 'add the dependency and '}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"]}
|
|
@@ -14,20 +14,31 @@ const USAGE = [
|
|
|
14
14
|
connector_imports_1.ConnectorImportsCommand.USAGE,
|
|
15
15
|
].join('\n\n');
|
|
16
16
|
/** The codemods `devz codemod <name>` runs. */
|
|
17
|
-
const
|
|
17
|
+
const NAME_LIST = [
|
|
18
18
|
'drop-redundant-casts',
|
|
19
19
|
'const-classes',
|
|
20
20
|
'async-style',
|
|
21
21
|
'namespace-functions',
|
|
22
22
|
'connector-imports',
|
|
23
|
-
]
|
|
23
|
+
];
|
|
24
|
+
const NAMES = NAME_LIST.join(', ');
|
|
24
25
|
/** A usage error: nothing was read or written. */
|
|
25
26
|
const USAGE_ERROR_CODE = 2;
|
|
27
|
+
/** The codemods that are style rewrites, not migrations: there is no downgrade of them. */
|
|
28
|
+
const NOT_REVERSIBLE = new Set(['drop-redundant-casts', 'const-classes', 'async-style']);
|
|
26
29
|
/** `devz codemod <name> [args]`: hands the arguments to the codemod called `name`. */
|
|
27
30
|
class CodemodCommand {
|
|
28
31
|
static async run(opts) {
|
|
29
32
|
const { args } = opts;
|
|
30
33
|
const [name, ...rest] = args;
|
|
34
|
+
if (name === '--list') {
|
|
35
|
+
console.log(NAME_LIST.join('\n'));
|
|
36
|
+
return 0;
|
|
37
|
+
}
|
|
38
|
+
if (name !== undefined && NOT_REVERSIBLE.has(name) && rest.includes('--reverse')) {
|
|
39
|
+
console.error(`devz codemod ${name}: not reversible`);
|
|
40
|
+
return USAGE_ERROR_CODE;
|
|
41
|
+
}
|
|
31
42
|
if (name === 'drop-redundant-casts') {
|
|
32
43
|
return drop_redundant_casts_1.DropRedundantCastsCommand.run({ root: opts.root, args: rest });
|
|
33
44
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/cli/codemod/index.ts"],"names":[],"mappings":";;;AAAA,+CAAkD;AAClD,2DAA8D;AAC9D,mDAAsD;AACtD,iEAAmE;AACnE,+DAAkE;AAElE,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;CAC9B,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAEf,+CAA+C;AAC/C,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/cli/codemod/index.ts"],"names":[],"mappings":";;;AAAA,+CAAkD;AAClD,2DAA8D;AAC9D,mDAAsD;AACtD,iEAAmE;AACnE,+DAAkE;AAElE,MAAM,KAAK,GAAG;IACZ,gDAAyB,CAAC,KAAK;IAC/B,mC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C,CAAC;QACxE,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,KAAK,aAAa,EAAE,CAAC;YAC3B,OAAO,+BAAiB,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QAChE,CAAC;QAED,IAAI,IAAI,KAAK,qBAAqB,EAAE,CAAC;YACnC,OAAO,+CAAyB,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QACxE,CAAC;QAED,IAAI,IAAI,KAAK,mBAAmB,EAAE,CAAC;YACjC,OAAO,2CAAuB,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QACtE,CAAC;QAED,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YACnD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YAEnB,OAAO,CAAC,CAAC;QACX,CAAC;QAED,OAAO,CAAC,KAAK,CACX,kCAAkC,IAAI,IAAI,EAAE,yBAAyB,KAAK,OAAO,KAAK,EAAE,CACzF,CAAC;QAEF,OAAO,gBAAgB,CAAC;IAC1B,CAAC;CACF;AAjDD,wCAiDC","sourcesContent":["import { AsyncStyleCommand } from './async-style';\nimport { ConnectorImportsCommand } from './connector-imports';\nimport { ConstClassesCommand } from './const-classes';\nimport { DropRedundantCastsCommand } from './drop-redundant-casts';\nimport { NamespaceFunctionsCommand } from './namespace-functions';\n\nconst USAGE = [\n DropRedundantCastsCommand.USAGE,\n ConstClassesCommand.USAGE,\n AsyncStyleCommand.USAGE,\n NamespaceFunctionsCommand.USAGE,\n ConnectorImportsCommand.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];\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(['drop-redundant-casts', 'const-classes', 'async-style']);\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 console.log(NAME_LIST.join('\\n'));\n\n return 0;\n }\n\n if (name !== undefined && NOT_REVERSIBLE.has(name) && rest.includes('--reverse')) {\n console.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 (args.includes('--help') || args.includes('-h')) {\n console.log(USAGE);\n\n return 0;\n }\n\n console.error(\n `devz codemod: unknown codemod \"${name ?? ''}\" | the codemods are: ${NAMES}\\n\\n${USAGE}`,\n );\n\n return USAGE_ERROR_CODE;\n }\n}\n"]}
|
|
@@ -2,6 +2,7 @@ import { type INamespaceMapping } from './mapping';
|
|
|
2
2
|
export * from './logger-scope';
|
|
3
3
|
export * from './mapping';
|
|
4
4
|
export * from './mappings';
|
|
5
|
+
export * from './reverse';
|
|
5
6
|
export * from './rewriter';
|
|
6
7
|
/**
|
|
7
8
|
* `devz codemod namespace-functions [paths...] [--write | --check]`: rewrites the calls of the
|
|
@@ -9,7 +10,7 @@ export * from './rewriter';
|
|
|
9
10
|
* `--check` is the same dry run, and exits 1 while a call can be rewritten or is left untouched.
|
|
10
11
|
*/
|
|
11
12
|
export declare class NamespaceFunctionsCommand {
|
|
12
|
-
static readonly USAGE = "Usage: devz codemod namespace-functions [paths...] [--write | --check]\n\nMoves calls of an IGNIS function that now lives in a class to the class form, with one options\nobject: `oldName(a, b)` becomes `ClassName.method({ first: a, second: b })`, and an argument named\nlike its key is written short (`{ first }`). The old names are removed from the packages, so run it\nonce after you upgrade. A table in @venizia/dev-configs names each moved function.\n\nIt follows a named import (aliased too) and a namespace import (`ns.oldName(...)`) from a module the\ntable lists, adds the class to that import, and drops the old name once nothing else uses it. It lists\nwith its file and line, and leaves for you: a call with a spread argument or the wrong number of\narguments, the old name used as a value (passed, stored, exported, in typeof), a re-export, a type-only\nimport, and a file that declares a name the rewrite would collide with.\n\nIt also moves the removed `ApplicationLogger`: `ApplicationLogger.get('scope')`, `.get(NAME)` and\n`.get({ scope: NAME })` become `LoggerFactory.getLogger(['scope'])`, `([NAME])`, and the import follows, when\n`ApplicationLogger` comes from `@venizia/ignis-helpers` or `@venizia/ignis`. `Logger.get` and\n`HfLogger.get` are not touched, and a call it cannot decide is listed, as is any other use of\n`ApplicationLogger` (a type, a re-export, a value). An identifier argument is taken for a scope: run your\ntypecheck afterwards.\n\n --write write the changed files (without it, nothing is written)\n --check dry run that exits 1 while a call can be rewritten or is left untouched (for CI)\n --help print this text and exit\n\nWith no flag it lists what would change and writes nothing. Inside a git repository it reads the\nfiles git knows (tracked, or untracked and not ignored), and --write refuses a file with local changes\n(changed, staged or untracked): commit or stash it first, so git can undo the codemod.";
|
|
13
|
+
static readonly USAGE = "Usage: devz codemod namespace-functions [paths...] [--write | --check] [--reverse]\n\nMoves calls of an IGNIS function that now lives in a class to the class form, with one options\nobject: `oldName(a, b)` becomes `ClassName.method({ first: a, second: b })`, and an argument named\nlike its key is written short (`{ first }`). The old names are removed from the packages, so run it\nonce after you upgrade. A table in @venizia/dev-configs names each moved function.\n\nIt follows a named import (aliased too) and a namespace import (`ns.oldName(...)`) from a module the\ntable lists, adds the class to that import, and drops the old name once nothing else uses it. It lists\nwith its file and line, and leaves for you: a call with a spread argument or the wrong number of\narguments, the old name used as a value (passed, stored, exported, in typeof), a re-export, a type-only\nimport, and a file that declares a name the rewrite would collide with.\n\nIt also moves the removed `ApplicationLogger`: `ApplicationLogger.get('scope')`, `.get(NAME)` and\n`.get({ scope: NAME })` become `LoggerFactory.getLogger(['scope'])`, `([NAME])`, and the import follows, when\n`ApplicationLogger` comes from `@venizia/ignis-helpers` or `@venizia/ignis`. `Logger.get` and\n`HfLogger.get` are not touched, and a call it cannot decide is listed, as is any other use of\n`ApplicationLogger` (a type, a re-export, a value). An identifier argument is taken for a scope: run your\ntypecheck afterwards.\n\n --write write the changed files (without it, nothing is written)\n --check dry run that exits 1 while a call can be rewritten or is left untouched (for CI)\n --reverse apply the table backward, for a downgrade: `ClassName.method({ first: a })` becomes\n `oldName(a)` and the import follows. The `ApplicationLogger` rule is not reversed.\n --help print this text and exit\n\nWith no flag it lists what would change and writes nothing. Inside a git repository it reads the\nfiles git knows (tracked, or untracked and not ignored), and --write refuses a file with local changes\n(changed, staged or untracked): commit or stash it first, so git can undo the codemod.";
|
|
13
14
|
static run(opts: {
|
|
14
15
|
root: string;
|
|
15
16
|
args: string[];
|
|
@@ -21,12 +21,14 @@ const files_1 = require("../files");
|
|
|
21
21
|
const mapping_1 = require("./mapping");
|
|
22
22
|
const mappings_1 = require("./mappings");
|
|
23
23
|
const logger_scope_1 = require("./logger-scope");
|
|
24
|
+
const reverse_1 = require("./reverse");
|
|
24
25
|
const rewriter_1 = require("./rewriter");
|
|
25
26
|
__exportStar(require("./logger-scope"), exports);
|
|
26
27
|
__exportStar(require("./mapping"), exports);
|
|
27
28
|
__exportStar(require("./mappings"), exports);
|
|
29
|
+
__exportStar(require("./reverse"), exports);
|
|
28
30
|
__exportStar(require("./rewriter"), exports);
|
|
29
|
-
const USAGE = `Usage: devz codemod namespace-functions [paths...] [--write | --check]
|
|
31
|
+
const USAGE = `Usage: devz codemod namespace-functions [paths...] [--write | --check] [--reverse]
|
|
30
32
|
|
|
31
33
|
Moves calls of an IGNIS function that now lives in a class to the class form, with one options
|
|
32
34
|
object: \`oldName(a, b)\` becomes \`ClassName.method({ first: a, second: b })\`, and an argument named
|
|
@@ -48,6 +50,8 @@ typecheck afterwards.
|
|
|
48
50
|
|
|
49
51
|
--write write the changed files (without it, nothing is written)
|
|
50
52
|
--check dry run that exits 1 while a call can be rewritten or is left untouched (for CI)
|
|
53
|
+
--reverse apply the table backward, for a downgrade: \`ClassName.method({ first: a })\` becomes
|
|
54
|
+
\`oldName(a)\` and the import follows. The \`ApplicationLogger\` rule is not reversed.
|
|
51
55
|
--help print this text and exit
|
|
52
56
|
|
|
53
57
|
With no flag it lists what would change and writes nothing. Inside a git repository it reads the
|
|
@@ -58,11 +62,13 @@ const USAGE_ERROR_CODE = 2;
|
|
|
58
62
|
class NamespaceFunctionsFlags {
|
|
59
63
|
static { this.WRITE = '--write'; }
|
|
60
64
|
static { this.CHECK = '--check'; }
|
|
65
|
+
static { this.REVERSE = '--reverse'; }
|
|
61
66
|
static { this.HELP = '--help'; }
|
|
62
67
|
static { this.HELP_SHORT = '-h'; }
|
|
63
68
|
static { this.SCHEME_SET = new Set([
|
|
64
69
|
this.WRITE,
|
|
65
70
|
this.CHECK,
|
|
71
|
+
this.REVERSE,
|
|
66
72
|
this.HELP,
|
|
67
73
|
this.HELP_SHORT,
|
|
68
74
|
]); }
|
|
@@ -93,6 +99,7 @@ class NamespaceFunctionsCommand {
|
|
|
93
99
|
}
|
|
94
100
|
const isWrite = flags.includes(NamespaceFunctionsFlags.WRITE);
|
|
95
101
|
const isCheck = flags.includes(NamespaceFunctionsFlags.CHECK);
|
|
102
|
+
const isReverse = flags.includes(NamespaceFunctionsFlags.REVERSE);
|
|
96
103
|
if (isWrite && isCheck) {
|
|
97
104
|
console.error(`devz codemod: ${NamespaceFunctionsFlags.WRITE} and ${NamespaceFunctionsFlags.CHECK} contradict each other\n${USAGE}`);
|
|
98
105
|
return USAGE_ERROR_CODE;
|
|
@@ -116,7 +123,7 @@ class NamespaceFunctionsCommand {
|
|
|
116
123
|
return 1;
|
|
117
124
|
}
|
|
118
125
|
// Identifiers only (the table is validated), so the names need no escaping.
|
|
119
|
-
const nameText = new RegExp(`\\b(?:${[...new Set(mappings.map((mapping) => mapping.oldName))].join('|')})\\b`);
|
|
126
|
+
const nameText = new RegExp(`\\b(?:${[...new Set(mappings.map((mapping) => (isReverse ? mapping.className : mapping.oldName)))].join('|')})\\b`);
|
|
120
127
|
const targets = (paths.length > 0 ? paths : ['.']).map((path) => (0, node_path_1.resolve)(root, path));
|
|
121
128
|
let changedCount = 0;
|
|
122
129
|
let callCount = 0;
|
|
@@ -130,14 +137,16 @@ class NamespaceFunctionsCommand {
|
|
|
130
137
|
}
|
|
131
138
|
for (const file of files) {
|
|
132
139
|
const source = (0, node_fs_1.readFileSync)(file, 'utf8');
|
|
133
|
-
if (!nameText.test(source) && !logger_scope_1.LoggerScopeRewriter.mentions({ source })) {
|
|
140
|
+
if (!nameText.test(source) && (isReverse || !logger_scope_1.LoggerScopeRewriter.mentions({ source }))) {
|
|
134
141
|
continue;
|
|
135
142
|
}
|
|
136
143
|
const shown = (0, node_path_1.relative)(root, file).split('\\').join('/') || file;
|
|
137
144
|
// The call-shape rule goes first, and its edits are inside one call, so the lines the table pass reports stay
|
|
138
145
|
// those of the file unless a multi-line `ApplicationLogger.get({ ... })` collapsed onto one line.
|
|
139
|
-
const scoped =
|
|
140
|
-
|
|
146
|
+
const scoped = isReverse
|
|
147
|
+
? { output: source, changed: false, rewritten: 0, reports: [] }
|
|
148
|
+
: logger_scope_1.LoggerScopeRewriter.rewrite({ typescript, fileName: file, source });
|
|
149
|
+
const tabled = (isReverse ? reverse_1.NamespaceFunctionsReverse : rewriter_1.NamespaceFunctions).rewrite({
|
|
141
150
|
typescript,
|
|
142
151
|
fileName: file,
|
|
143
152
|
source: scoped.output,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/cli/codemod/namespace-functions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,qCAAsD;AACtD,yCAA8C;AAC9C,oCAAwC;AACxC,uCAAsE;AACtE,yCAA0C;AAC1C,iDAAqD;AACrD,yCAAgD;AAEhD,iDAA+B;AAC/B,4CAA0B;AAC1B,6CAA2B;AAC3B,6CAA2B;AAE3B,MAAM,KAAK,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;uFA0ByE,CAAC;AAExF,kDAAkD;AAClD,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAE3B,MAAM,uBAAuB;aACX,UAAK,GAAG,SAAS,CAAC;aAClB,UAAK,GAAG,SAAS,CAAC;aAClB,SAAI,GAAG,QAAQ,CAAC;aAChB,eAAU,GAAG,IAAI,CAAC;aAElB,eAAU,GAAG,IAAI,GAAG,CAAS;QAC3C,IAAI,CAAC,KAAK;QACV,IAAI,CAAC,KAAK;QACV,IAAI,CAAC,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;;AAGH;;;;GAIG;AACH,MAAa,yBAAyB;aACpB,UAAK,GAAG,KAAK,CAAC;IAE9B,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,IAKhB;QACC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,GA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MAAM,CAAC,CAAC;gBACrC,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,CAAC,GAAG,CACT,qCAAqC,YAAY,YAAY,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,cAAc,KAAK,SAAS,YAAY,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,oBAAoB,KAAK,WAAW,iBAAiB;YACtM,CAAC,YAAY,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,YAAY,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,CACxD,CAAC;QAEF,IAAI,CAAC,OAAO,IAAI,YAAY,GAAG,CAAC,EAAE,CAAC;YACjC,OAAO,CAAC,GAAG,CACT,uCAAuC,uBAAuB,CAAC,KAAK,mDAAmD,CACxH,CAAC;QACJ,CAAC;QAED,IAAI,OAAO,IAAI,YAAY,GAAG,CAAC,EAAE,CAAC;YAChC,OAAO,CAAC,CAAC;QACX,CAAC;QAED,OAAO,OAAO,IAAI,CAAC,YAAY,GAAG,CAAC,IAAI,WAAW,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAClE,CAAC;;AAlKH,8DAmKC","sourcesContent":["import { readFileSync, writeFileSync } from 'node:fs';\nimport { relative, resolve } from 'node:path';\nimport { CodemodFiles } from '../files';\nimport { type INamespaceMapping, NamespaceMappings } from './mapping';\nimport { ALL_MAPPINGS } from './mappings';\nimport { LoggerScopeRewriter } from './logger-scope';\nimport { NamespaceFunctions } from './rewriter';\n\nexport * from './logger-scope';\nexport * from './mapping';\nexport * from './mappings';\nexport * from './rewriter';\n\nconst USAGE = `Usage: devz codemod namespace-functions [paths...] [--write | --check]\n\nMoves calls of an IGNIS function that now lives in a class to the class form, with one options\nobject: \\`oldName(a, b)\\` becomes \\`ClassName.method({ first: a, second: b })\\`, and an argument named\nlike its key is written short (\\`{ first }\\`). The old names are removed from the packages, so run it\nonce after you upgrade. A table in @venizia/dev-configs names each moved function.\n\nIt follows a named import (aliased too) and a namespace import (\\`ns.oldName(...)\\`) from a module the\ntable lists, adds the class to that import, and drops the old name once nothing else uses it. It lists\nwith its file and line, and leaves for you: a call with a spread argument or the wrong number of\narguments, the old name used as a value (passed, stored, exported, in typeof), a re-export, a type-only\nimport, and a file that declares a name the rewrite would collide with.\n\nIt also moves the removed \\`ApplicationLogger\\`: \\`ApplicationLogger.get('scope')\\`, \\`.get(NAME)\\` and\n\\`.get({ scope: NAME })\\` become \\`LoggerFactory.getLogger(['scope'])\\`, \\`([NAME])\\`, and the import follows, when\n\\`ApplicationLogger\\` comes from \\`@venizia/ignis-helpers\\` or \\`@venizia/ignis\\`. \\`Logger.get\\` and\n\\`HfLogger.get\\` are not touched, and a call it cannot decide is listed, as is any other use of\n\\`ApplicationLogger\\` (a type, a re-export, a value). An identifier argument is taken for a scope: run your\ntypecheck afterwards.\n\n --write write the changed files (without it, nothing is written)\n --check dry run that exits 1 while a call can be rewritten or is left untouched (for CI)\n --help print this text and exit\n\nWith no flag it lists what would change and writes nothing. Inside a git repository it reads the\nfiles git knows (tracked, or untracked and not ignored), and --write refuses a file with local changes\n(changed, staged or untracked): commit or stash it first, so git can undo the codemod.`;\n\n/** A usage error: nothing was read or written. */\nconst USAGE_ERROR_CODE = 2;\n\nclass NamespaceFunctionsFlags {\n static readonly WRITE = '--write';\n static readonly CHECK = '--check';\n static readonly HELP = '--help';\n static readonly HELP_SHORT = '-h';\n\n static readonly SCHEME_SET = new Set<string>([\n this.WRITE,\n this.CHECK,\n this.HELP,\n this.HELP_SHORT,\n ]);\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n}\n\n/**\n * `devz codemod namespace-functions [paths...] [--write | --check]`: rewrites the calls of the\n * functions the mapping table lists to their class form. It is a dry run unless `--write` is given.\n * `--check` is the same dry run, and exits 1 while a call can be rewritten or is left untouched.\n */\nexport class NamespaceFunctionsCommand {\n static readonly USAGE = USAGE;\n\n static async run(opts: {\n root: string;\n args: string[];\n /** The table to apply; the one this package ships by default. */\n mappings?: ReadonlyArray<INamespaceMapping>;\n }): Promise<number> {\n const { root, args, mappings = ALL_MAPPINGS } = opts;\n\n if (\n args.includes(NamespaceFunctionsFlags.HELP) ||\n args.includes(NamespaceFunctionsFlags.HELP_SHORT)\n ) {\n console.log(USAGE);\n\n return 0;\n }\n\n const flags = args.filter((argument) => argument.startsWith('-'));\n const paths = args.filter((argument) => !argument.startsWith('-'));\n\n const unknown = flags.filter((flag) => !NamespaceFunctionsFlags.isValid(flag));\n\n if (unknown.length > 0) {\n console.error(\n `devz codemod: unknown option ${unknown.map((flag) => `\"${flag}\"`).join(', ')}\\n${USAGE}`,\n );\n\n return USAGE_ERROR_CODE;\n }\n\n const isWrite = flags.includes(NamespaceFunctionsFlags.WRITE);\n const isCheck = flags.includes(NamespaceFunctionsFlags.CHECK);\n\n if (isWrite && isCheck) {\n console.error(\n `devz codemod: ${NamespaceFunctionsFlags.WRITE} and ${NamespaceFunctionsFlags.CHECK} contradict each other\\n${USAGE}`,\n );\n\n return USAGE_ERROR_CODE;\n }\n\n const problems = NamespaceMappings.validate({ mappings });\n\n if (problems.length > 0) {\n console.error(\n `devz codemod namespace-functions: the mapping table is broken:\\n${problems.map((problem) => ` ${problem}`).join('\\n')}`,\n );\n\n return 1;\n }\n\n if (mappings.length === 0) {\n console.log(\n 'devz codemod namespace-functions: the mapping table of this version is empty, so there is nothing to rewrite',\n );\n\n return 0;\n }\n\n let typescript: typeof import('typescript');\n\n try {\n const result2 = await import('typescript');\n typescript = result2.default;\n } catch {\n console.error('devz codemod: the \"typescript\" package is required to read your sources');\n\n return 1;\n }\n\n // Identifiers only (the table is validated), so the names need no escaping.\n const nameText = new RegExp(\n `\\\\b(?:${[...new Set(mappings.map((mapping) => mapping.oldName))].join('|')})\\\\b`,\n );\n const targets = (paths.length > 0 ? paths : ['.']).map((path) => resolve(root, path));\n let changedCount = 0;\n let callCount = 0;\n let reportCount = 0;\n let refusedCount = 0;\n\n for (const target of targets) {\n const files = CodemodFiles.collect({ target });\n const dirty = isWrite ? CodemodFiles.dirty({ target }) : undefined;\n\n if (files.length === 0 && paths.length > 0) {\n console.warn(\n `devz codemod: no source files under \"${relative(root, target) || target}\" (git ignores the path, or it holds none): nothing was read`,\n );\n }\n\n for (const file of files) {\n const source = readFileSync(file, 'utf8');\n\n if (!nameText.test(source) && !LoggerScopeRewriter.mentions({ source })) {\n continue;\n }\n\n const shown = relative(root, file).split('\\\\').join('/') || file;\n // The call-shape rule goes first, and its edits are inside one call, so the lines the table pass reports stay\n // those of the file unless a multi-line `ApplicationLogger.get({ ... })` collapsed onto one line.\n const scoped = LoggerScopeRewriter.rewrite({ typescript, fileName: file, source });\n const tabled = NamespaceFunctions.rewrite({\n typescript,\n fileName: file,\n source: scoped.output,\n mappings,\n });\n const result = {\n output: tabled.output,\n changed: scoped.changed || tabled.changed,\n rewritten: scoped.rewritten + tabled.rewritten,\n reports: [...scoped.reports, ...tabled.reports],\n };\n\n for (const report of result.reports) {\n reportCount += 1;\n console.warn(`${shown}:${report.line}:${report.column} ${report.reason}`);\n }\n\n if (!result.changed) {\n continue;\n }\n\n if (dirty?.has(file)) {\n refusedCount += 1;\n console.warn(\n `refused ${shown} has local changes (commit or stash them, then run again)`,\n );\n continue;\n }\n\n changedCount += 1;\n callCount += result.rewritten;\n console.log(\n `${isWrite ? 'changed' : 'would change'} ${shown} (${result.rewritten} call(s))`,\n );\n\n if (isWrite) {\n writeFileSync(file, result.output);\n }\n }\n }\n\n console.log(\n `devz codemod namespace-functions: ${changedCount} file(s) ${isWrite ? 'changed' : 'would change'}, ${callCount} call(s) ${isWrite ? 'rewritten' : 'would be rewritten'}, ${reportCount} left untouched` +\n (refusedCount > 0 ? `, ${refusedCount} refused` : ''),\n );\n\n if (!isWrite && changedCount > 0) {\n console.log(\n `Nothing was written. Run again with ${NamespaceFunctionsFlags.WRITE} to apply, then run your typecheck and formatter.`,\n );\n }\n\n if (isWrite && refusedCount > 0) {\n return 1;\n }\n\n return isCheck && (changedCount > 0 || reportCount > 0) ? 1 : 0;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/cli/codemod/namespace-functions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,qCAAsD;AACtD,yCAA8C;AAC9C,oCAAwC;AACxC,uCAAsE;AACtE,yCAA0C;AAC1C,iDAAqD;AACrD,uCAAsD;AACtD,yCAAgD;AAEhD,iDAA+B;AAC/B,4CAA0B;AAC1B,6CAA2B;AAC3B,4CAA0B;AAC1B,6CAA2B;AAE3B,MAAM,KAAK,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;uFA4ByE,CAAC;AAExF,kDAAkD;AAClD,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAE3B,MAAM,uBAAuB;aACX,UAAK,GAAG,SAAS,CAAC;aAClB,UAAK,GAAG,SAAS,CAAC;aAClB,YAAO,GAAG,WAAW,CAAC;aACtB,SAAI,GAAG,QAAQ,CAAC;aAChB,eAAU,GAAG,IAAI,CAAC;aAElB,eAAU,GAAG,IAAI,GAAG,CAAS;QAC3C,IAAI,CAAC,KAAK;QACV,IAAI,CAAC,KAAK;QACV,IAAI,CAAC,OAAO;QACZ,IAAI,CAAC,IAAI;QACT,IAAI,CAAC,UAAU;KAChB,CAAC,CAAC;IAEH,MAAM,CAAC,OAAO,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;;AAGH;;;;GAIG;AACH,MAAa,yBAAyB;aACpB,UAAK,GAAG,KAAK,CAAC;IAE9B,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,IAKhB;QACC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,GAAG,uBAAY,EAAE,GAAG,IAAI,CAAC;QAErD,IACE,IAAI,CAAC,QAAQ,CAAC,uBAAuB,CAAC,IAAI,CAAC;YAC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AAI,CAAC,CAAC;gBAClB,SAAS,IAAI,MAAM,CAAC,SAAS,CAAC;gBAC9B,OAAO,CAAC,GAAG,CACT,GAAG,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,cAAc,KAAK,KAAK,MAAM,MAAM,CAAC,SAAS,WAAW,CACnF,CAAC;gBAEF,IAAI,OAAO,EAAE,CAAC;oBACZ,IAAA,uBAAa,EAAC,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;gBACrC,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,CAAC,GAAG,CACT,qCAAqC,YAAY,YAAY,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,cAAc,KAAK,SAAS,YAAY,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,oBAAoB,KAAK,WAAW,iBAAiB;YACtM,CAAC,YAAY,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,YAAY,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,CACxD,CAAC;QAEF,IAAI,CAAC,OAAO,IAAI,YAAY,GAAG,CAAC,EAAE,CAAC;YACjC,OAAO,CAAC,GAAG,CACT,uCAAuC,uBAAuB,CAAC,KAAK,mDAAmD,CACxH,CAAC;QACJ,CAAC;QAED,IAAI,OAAO,IAAI,YAAY,GAAG,CAAC,EAAE,CAAC;YAChC,OAAO,CAAC,CAAC;QACX,CAAC;QAED,OAAO,OAAO,IAAI,CAAC,YAAY,GAAG,CAAC,IAAI,WAAW,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAClE,CAAC;;AArKH,8DAsKC","sourcesContent":["import { readFileSync, writeFileSync } from 'node:fs';\nimport { relative, resolve } from 'node:path';\nimport { CodemodFiles } from '../files';\nimport { type INamespaceMapping, NamespaceMappings } from './mapping';\nimport { ALL_MAPPINGS } from './mappings';\nimport { LoggerScopeRewriter } from './logger-scope';\nimport { NamespaceFunctionsReverse } from './reverse';\nimport { NamespaceFunctions } from './rewriter';\n\nexport * from './logger-scope';\nexport * from './mapping';\nexport * from './mappings';\nexport * from './reverse';\nexport * from './rewriter';\n\nconst USAGE = `Usage: devz codemod namespace-functions [paths...] [--write | --check] [--reverse]\n\nMoves calls of an IGNIS function that now lives in a class to the class form, with one options\nobject: \\`oldName(a, b)\\` becomes \\`ClassName.method({ first: a, second: b })\\`, and an argument named\nlike its key is written short (\\`{ first }\\`). The old names are removed from the packages, so run it\nonce after you upgrade. A table in @venizia/dev-configs names each moved function.\n\nIt follows a named import (aliased too) and a namespace import (\\`ns.oldName(...)\\`) from a module the\ntable lists, adds the class to that import, and drops the old name once nothing else uses it. It lists\nwith its file and line, and leaves for you: a call with a spread argument or the wrong number of\narguments, the old name used as a value (passed, stored, exported, in typeof), a re-export, a type-only\nimport, and a file that declares a name the rewrite would collide with.\n\nIt also moves the removed \\`ApplicationLogger\\`: \\`ApplicationLogger.get('scope')\\`, \\`.get(NAME)\\` and\n\\`.get({ scope: NAME })\\` become \\`LoggerFactory.getLogger(['scope'])\\`, \\`([NAME])\\`, and the import follows, when\n\\`ApplicationLogger\\` comes from \\`@venizia/ignis-helpers\\` or \\`@venizia/ignis\\`. \\`Logger.get\\` and\n\\`HfLogger.get\\` are not touched, and a call it cannot decide is listed, as is any other use of\n\\`ApplicationLogger\\` (a type, a re-export, a value). An identifier argument is taken for a scope: run your\ntypecheck afterwards.\n\n --write write the changed files (without it, nothing is written)\n --check dry run that exits 1 while a call can be rewritten or is left untouched (for CI)\n --reverse apply the table backward, for a downgrade: \\`ClassName.method({ first: a })\\` becomes\n \\`oldName(a)\\` and the import follows. The \\`ApplicationLogger\\` rule is not reversed.\n --help print this text and exit\n\nWith no flag it lists what would change and writes nothing. Inside a git repository it reads the\nfiles git knows (tracked, or untracked and not ignored), and --write refuses a file with local changes\n(changed, staged or untracked): commit or stash it first, so git can undo the codemod.`;\n\n/** A usage error: nothing was read or written. */\nconst USAGE_ERROR_CODE = 2;\n\nclass NamespaceFunctionsFlags {\n static readonly WRITE = '--write';\n static readonly CHECK = '--check';\n static readonly REVERSE = '--reverse';\n static readonly HELP = '--help';\n static readonly HELP_SHORT = '-h';\n\n static readonly SCHEME_SET = new Set<string>([\n this.WRITE,\n this.CHECK,\n this.REVERSE,\n this.HELP,\n this.HELP_SHORT,\n ]);\n\n static isValid(value: string): boolean {\n return this.SCHEME_SET.has(value);\n }\n}\n\n/**\n * `devz codemod namespace-functions [paths...] [--write | --check]`: rewrites the calls of the\n * functions the mapping table lists to their class form. It is a dry run unless `--write` is given.\n * `--check` is the same dry run, and exits 1 while a call can be rewritten or is left untouched.\n */\nexport class NamespaceFunctionsCommand {\n static readonly USAGE = USAGE;\n\n static async run(opts: {\n root: string;\n args: string[];\n /** The table to apply; the one this package ships by default. */\n mappings?: ReadonlyArray<INamespaceMapping>;\n }): Promise<number> {\n const { root, args, mappings = ALL_MAPPINGS } = opts;\n\n if (\n args.includes(NamespaceFunctionsFlags.HELP) ||\n args.includes(NamespaceFunctionsFlags.HELP_SHORT)\n ) {\n console.log(USAGE);\n\n return 0;\n }\n\n const flags = args.filter((argument) => argument.startsWith('-'));\n const paths = args.filter((argument) => !argument.startsWith('-'));\n\n const unknown = flags.filter((flag) => !NamespaceFunctionsFlags.isValid(flag));\n\n if (unknown.length > 0) {\n console.error(\n `devz codemod: unknown option ${unknown.map((flag) => `\"${flag}\"`).join(', ')}\\n${USAGE}`,\n );\n\n return USAGE_ERROR_CODE;\n }\n\n const isWrite = flags.includes(NamespaceFunctionsFlags.WRITE);\n const isCheck = flags.includes(NamespaceFunctionsFlags.CHECK);\n const isReverse = flags.includes(NamespaceFunctionsFlags.REVERSE);\n\n if (isWrite && isCheck) {\n console.error(\n `devz codemod: ${NamespaceFunctionsFlags.WRITE} and ${NamespaceFunctionsFlags.CHECK} contradict each other\\n${USAGE}`,\n );\n\n return USAGE_ERROR_CODE;\n }\n\n const problems = NamespaceMappings.validate({ mappings });\n\n if (problems.length > 0) {\n console.error(\n `devz codemod namespace-functions: the mapping table is broken:\\n${problems.map((problem) => ` ${problem}`).join('\\n')}`,\n );\n\n return 1;\n }\n\n if (mappings.length === 0) {\n console.log(\n 'devz codemod namespace-functions: the mapping table of this version is empty, so there is nothing to rewrite',\n );\n\n return 0;\n }\n\n let typescript: typeof import('typescript');\n\n try {\n const result2 = await import('typescript');\n typescript = result2.default;\n } catch {\n console.error('devz codemod: the \"typescript\" package is required to read your sources');\n\n return 1;\n }\n\n // Identifiers only (the table is validated), so the names need no escaping.\n const nameText = new RegExp(\n `\\\\b(?:${[...new Set(mappings.map((mapping) => (isReverse ? mapping.className : mapping.oldName)))].join('|')})\\\\b`,\n );\n const targets = (paths.length > 0 ? paths : ['.']).map((path) => resolve(root, path));\n let changedCount = 0;\n let callCount = 0;\n let reportCount = 0;\n let refusedCount = 0;\n\n for (const target of targets) {\n const files = CodemodFiles.collect({ target });\n const dirty = isWrite ? CodemodFiles.dirty({ target }) : undefined;\n\n if (files.length === 0 && paths.length > 0) {\n console.warn(\n `devz codemod: no source files under \"${relative(root, target) || target}\" (git ignores the path, or it holds none): nothing was read`,\n );\n }\n\n for (const file of files) {\n const source = readFileSync(file, 'utf8');\n\n if (!nameText.test(source) && (isReverse || !LoggerScopeRewriter.mentions({ source }))) {\n continue;\n }\n\n const shown = relative(root, file).split('\\\\').join('/') || file;\n // The call-shape rule goes first, and its edits are inside one call, so the lines the table pass reports stay\n // those of the file unless a multi-line `ApplicationLogger.get({ ... })` collapsed onto one line.\n const scoped = isReverse\n ? { output: source, changed: false, rewritten: 0, reports: [] }\n : LoggerScopeRewriter.rewrite({ typescript, fileName: file, source });\n const tabled = (isReverse ? NamespaceFunctionsReverse : NamespaceFunctions).rewrite({\n typescript,\n fileName: file,\n source: scoped.output,\n mappings,\n });\n const result = {\n output: tabled.output,\n changed: scoped.changed || tabled.changed,\n rewritten: scoped.rewritten + tabled.rewritten,\n reports: [...scoped.reports, ...tabled.reports],\n };\n\n for (const report of result.reports) {\n reportCount += 1;\n console.warn(`${shown}:${report.line}:${report.column} ${report.reason}`);\n }\n\n if (!result.changed) {\n continue;\n }\n\n if (dirty?.has(file)) {\n refusedCount += 1;\n console.warn(\n `refused ${shown} has local changes (commit or stash them, then run again)`,\n );\n continue;\n }\n\n changedCount += 1;\n callCount += result.rewritten;\n console.log(\n `${isWrite ? 'changed' : 'would change'} ${shown} (${result.rewritten} call(s))`,\n );\n\n if (isWrite) {\n writeFileSync(file, result.output);\n }\n }\n }\n\n console.log(\n `devz codemod namespace-functions: ${changedCount} file(s) ${isWrite ? 'changed' : 'would change'}, ${callCount} call(s) ${isWrite ? 'rewritten' : 'would be rewritten'}, ${reportCount} left untouched` +\n (refusedCount > 0 ? `, ${refusedCount} refused` : ''),\n );\n\n if (!isWrite && changedCount > 0) {\n console.log(\n `Nothing was written. Run again with ${NamespaceFunctionsFlags.WRITE} to apply, then run your typecheck and formatter.`,\n );\n }\n\n if (isWrite && refusedCount > 0) {\n return 1;\n }\n\n return isCheck && (changedCount > 0 || reportCount > 0) ? 1 : 0;\n }\n}\n"]}
|
|
@@ -148,7 +148,7 @@ exports.CORE_SERVER_MAPPINGS = [
|
|
|
148
148
|
{
|
|
149
149
|
modules: ['@venizia/ignis/static-asset'],
|
|
150
150
|
oldName: 'resolveServedContentType',
|
|
151
|
-
className: '
|
|
151
|
+
className: 'StaticAssetServe',
|
|
152
152
|
method: 'resolveServedContentType',
|
|
153
153
|
params: [],
|
|
154
154
|
keepsOptions: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core-server.js","sourceRoot":"","sources":["../../../../../src/cli/codemod/namespace-functions/mappings/core-server.ts"],"names":[],"mappings":";;;AAEA;;;;;GAKG;AACU,QAAA,oBAAoB,GAAqC;IACpE;QACE,OAAO,EAAE,CAAC,gBAAgB,CAAC;QAC3B,OAAO,EAAE,qBAAqB;QAC9B,SAAS,EAAE,iBAAiB;QAC5B,MAAM,EAAE,cAAc;QACtB,MAA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C9B,MAAM,EAAE,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC;KAC3B;IACD;QACE,OAAO,EAAE,CAAC,6BAA6B,CAAC;QACxC,OAAO,EAAE,kBAAkB;QAC3B,SAAS,EAAE,+BAA+B;QAC1C,MAAM,EAAE,OAAO;QACf,MAAM,EAAE,EAAE;QACV,YAAY,EAAE,IAAI;KACnB;IACD;QACE,OAAO,EAAE,CAAC,6BAA6B,CAAC;QACxC,OAAO,EAAE,iBAAiB;QAC1B,SAAS,EAAE,+BAA+B;QAC1C,MAAM,EAAE,MAAM;QACd,MAAM,EAAE,EAAE;QACV,YAAY,EAAE,IAAI;KACnB;IACD;QACE,OAAO,EAAE,CAAC,6BAA6B,CAAC;QACxC,OAAO,EAAE,iBAAiB;QAC1B,SAAS,EAAE,8BAA8B;QACzC,MAAM,EAAE,OAAO;QACf,MAAM,EAAE,EAAE;QACV,YAAY,EAAE,IAAI;KACnB;IACD;QACE,OAAO,EAAE,CAAC,6BAA6B,CAAC;QACxC,OAAO,EAAE,0BAA0B;QACnC,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"core-server.js","sourceRoot":"","sources":["../../../../../src/cli/codemod/namespace-functions/mappings/core-server.ts"],"names":[],"mappings":";;;AAEA;;;;;GAKG;AACU,QAAA,oBAAoB,GAAqC;IACpE;QACE,OAAO,EAAE,CAAC,gBAAgB,CAAC;QAC3B,OAAO,EAAE,qBAAqB;QAC9B,SAAS,EAAE,iBAAiB;QAC5B,MAAM,EAAE,cAAc;QACtB,MAAM,EAAE,EAAE;KACX;IACD;QACE,OAAO,EAAE,CAAC,gBAAgB,CAAC;QAC3B,OAAO,EAAE,kBAAkB;QAC3B,SAAS,EAAE,iBAAiB;QAC5B,MAAM,EAAE,QAAQ;QAChB,MAAM,EAAE,EAAE;QACV,YAAY,EAAE,IAAI;KACnB;IACD;QACE,OAAO,EAAE,CAAC,gBAAgB,CAAC;QAC3B,OAAO,EAAE,sBAAsB;QAC/B,SAAS,E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;QACxC,OAAO,EAAE,iBAAiB;QAC1B,SAAS,EAAE,+BAA+B;QAC1C,MAAM,EAAE,MAAM;QACd,MAAM,EAAE,EAAE;QACV,YAAY,EAAE,IAAI;KACnB;IACD;QACE,OAAO,EAAE,CAAC,6BAA6B,CAAC;QACxC,OAAO,EAAE,iBAAiB;QAC1B,SAAS,EAAE,8BAA8B;QACzC,MAAM,EAAE,OAAO;QACf,MAAM,EAAE,EAAE;QACV,YAAY,EAAE,IAAI;KACnB;IACD;QACE,OAAO,EAAE,CAAC,6BAA6B,CAAC;QACxC,OAAO,EAAE,0BAA0B;QACnC,SAAS,EAAE,kBAAkB;QAC7B,MAAM,EAAE,0BAA0B;QAClC,MAAM,EAAE,EAAE;QACV,YAAY,EAAE,IAAI;KACnB;IACD;QACE,OAAO,EAAE,CAAC,wBAAwB,CAAC;QACnC,OAAO,EAAE,wBAAwB;QACjC,SAAS,EAAE,0BAA0B;QACrC,MAAM,EAAE,QAAQ;QAChB,MAAM,EAAE,CAAC,EAAE,GAAG,EAAE,aAAa,EAAE,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;KACrE;IACD;QACE,OAAO,EAAE,CAAC,gBAAgB,CAAC;QAC3B,OAAO,EAAE,gBAAgB;QACzB,SAAS,EAAE,sBAAsB;QACjC,MAAM,EAAE,gBAAgB;QACxB,MAAM,EAAE,EAAE;QACV,YAAY,EAAE,IAAI;KACnB;CACF,CAAC","sourcesContent":["import type { INamespaceMapping } from '../mapping';\n\n/**\n * The functions of `@venizia/ignis` that moved into a class. An entry with `keepsOptions` keeps its\n * arguments and only the callee changes: the function already took ONE options object and its class\n * method takes the same one, or (the two mail type guards) the parameter stays positional because a\n * type predicate narrows its own parameter.\n */\nexport const CORE_SERVER_MAPPINGS: ReadonlyArray<INamespaceMapping> = [\n {\n modules: ['@venizia/ignis'],\n oldName: 'readRuntimeSnapshot',\n className: 'BunRuntimeGuard',\n method: 'readSnapshot',\n params: [],\n },\n {\n modules: ['@venizia/ignis'],\n oldName: 'assertBunRuntime',\n className: 'BunRuntimeGuard',\n method: 'assert',\n params: [],\n keepsOptions: true,\n },\n {\n modules: ['@venizia/ignis'],\n oldName: 'defineAuthController',\n className: 'AuthControllerFactory',\n method: 'build',\n params: [],\n keepsOptions: true,\n },\n {\n modules: ['@venizia/ignis'],\n oldName: 'extraUserColumns',\n className: 'AuthModelColumns',\n method: 'buildUser',\n params: [],\n keepsOptions: true,\n },\n {\n modules: ['@venizia/ignis'],\n oldName: 'extraRoleColumns',\n className: 'AuthModelColumns',\n method: 'buildRole',\n params: [],\n },\n {\n modules: ['@venizia/ignis'],\n oldName: 'extraPermissionColumns',\n className: 'AuthModelColumns',\n method: 'buildPermission',\n params: [],\n keepsOptions: true,\n },\n {\n modules: ['@venizia/ignis'],\n oldName: 'extraPolicyDefinitionColumns',\n className: 'AuthModelColumns',\n method: 'buildPolicyDefinition',\n params: [],\n keepsOptions: true,\n },\n {\n modules: ['@venizia/ignis'],\n oldName: 'policyDefinitionDomainShapeCheck',\n className: 'AuthModelColumns',\n method: 'buildPolicyDefinitionDomainShapeCheck',\n params: [],\n keepsOptions: true,\n },\n {\n modules: ['@venizia/ignis/mail'],\n oldName: 'isMailTransport',\n className: 'MailTypeUtility',\n method: 'isTransport',\n params: [],\n keepsOptions: true,\n },\n {\n modules: ['@venizia/ignis/mail'],\n oldName: 'isValidMailOptions',\n className: 'MailTypeUtility',\n method: 'isValidOptions',\n params: [],\n keepsOptions: true,\n },\n {\n modules: ['@venizia/ignis/mail'],\n oldName: 'splitAddressList',\n className: 'MailAddressUtility',\n method: 'splitList',\n params: [{ key: 'value' }],\n },\n {\n modules: ['@venizia/ignis/mail'],\n oldName: 'formatAddressHeader',\n className: 'MailMimeUtility',\n method: 'formatAddressHeader',\n params: [{ key: 'value' }],\n },\n {\n modules: ['@venizia/ignis/mail'],\n oldName: 'buildRawMimeMessage',\n className: 'MailMimeUtility',\n method: 'buildRawMessage',\n params: [{ key: 'message' }],\n },\n {\n modules: ['@venizia/ignis/mail'],\n oldName: 'getExpiryTime',\n className: 'MailVerificationUtility',\n method: 'getExpiryTime',\n params: [{ key: 'minutes' }],\n },\n {\n modules: ['@venizia/ignis/mail'],\n oldName: 'getExpiryTimeInHours',\n className: 'MailVerificationUtility',\n method: 'getExpiryTimeInHours',\n params: [{ key: 'hours' }],\n },\n {\n modules: ['@venizia/ignis/static-asset'],\n oldName: 'buildCommitToken',\n className: 'StaticAssetCommitTokenUtility',\n method: 'build',\n params: [],\n keepsOptions: true,\n },\n {\n modules: ['@venizia/ignis/static-asset'],\n oldName: 'readCommitToken',\n className: 'StaticAssetCommitTokenUtility',\n method: 'read',\n params: [],\n keepsOptions: true,\n },\n {\n modules: ['@venizia/ignis/static-asset'],\n oldName: 'buildObjectLink',\n className: 'StaticAssetObjectLinkUtility',\n method: 'build',\n params: [],\n keepsOptions: true,\n },\n {\n modules: ['@venizia/ignis/static-asset'],\n oldName: 'resolveServedContentType',\n className: 'StaticAssetServe',\n method: 'resolveServedContentType',\n params: [],\n keepsOptions: true,\n },\n {\n modules: ['@venizia/ignis/testing'],\n oldName: 'assertApplicationBoots',\n className: 'ApplicationBootAssertion',\n method: 'assert',\n params: [{ key: 'application' }, { key: 'options', optional: true }],\n },\n {\n modules: ['@venizia/ignis'],\n oldName: 'readResultRows',\n className: 'DrizzleResultUtility',\n method: 'readResultRows',\n params: [],\n keepsOptions: true,\n },\n];\n"]}
|
|
@@ -8,6 +8,9 @@ import type { INamespaceMapping } from '../mapping';
|
|
|
8
8
|
* The inversion names the package re-exports (`isEmpty`, `omit`, `resolveValue`, ...) are in the
|
|
9
9
|
* inversion table, which lists the helpers entries in its own `modules`.
|
|
10
10
|
*
|
|
11
|
+
* Not here: `createRedisHelper`. It has no one method to move to: `RedisHelperFactory.single`, `.cluster` and `.sentinel` each take
|
|
12
|
+
* the options of one topology, so the call is rewritten by hand.
|
|
13
|
+
*
|
|
11
14
|
* Not here, and still functions: `isPromiseLike`, `isRedisHelper` (type guards), and
|
|
12
15
|
* `applicationLogFormatter` (a value, not a function). `ApplicationLogger` is removed: `logger-scope.ts` moves
|
|
13
16
|
* its calls to `LoggerFactory.getLogger([scope])`, a call on a class that no table entry can carry.
|
|
@@ -17,6 +17,9 @@ const KAFKA = '@venizia/ignis-helpers/kafka';
|
|
|
17
17
|
* The inversion names the package re-exports (`isEmpty`, `omit`, `resolveValue`, ...) are in the
|
|
18
18
|
* inversion table, which lists the helpers entries in its own `modules`.
|
|
19
19
|
*
|
|
20
|
+
* Not here: `createRedisHelper`. It has no one method to move to: `RedisHelperFactory.single`, `.cluster` and `.sentinel` each take
|
|
21
|
+
* the options of one topology, so the call is rewritten by hand.
|
|
22
|
+
*
|
|
20
23
|
* Not here, and still functions: `isPromiseLike`, `isRedisHelper` (type guards), and
|
|
21
24
|
* `applicationLogFormatter` (a value, not a function). `ApplicationLogger` is removed: `logger-scope.ts` moves
|
|
22
25
|
* its calls to `LoggerFactory.getLogger([scope])`, a call on a class that no table entry can carry.
|
|
@@ -318,15 +321,7 @@ exports.HELPERS_MAPPINGS = [
|
|
|
318
321
|
params: [],
|
|
319
322
|
keepsOptions: true,
|
|
320
323
|
},
|
|
321
|
-
// modules/
|
|
322
|
-
{
|
|
323
|
-
modules: [ROOT],
|
|
324
|
-
oldName: 'createRedisHelper',
|
|
325
|
-
className: 'RedisHelperFactory',
|
|
326
|
-
method: 'create',
|
|
327
|
-
params: [],
|
|
328
|
-
keepsOptions: true,
|
|
329
|
-
},
|
|
324
|
+
// modules/secrets
|
|
330
325
|
{
|
|
331
326
|
modules: [ROOT],
|
|
332
327
|
oldName: 'createSecretsHelper',
|