@wise/wds-codemods 0.0.1-experimental-cd881b3 → 0.0.1-experimental-aaa0fc3
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/index.js +130 -279
- package/dist/index.js.map +1 -1
- package/dist/{reportManualReview-CQm-npxR.js → reportManualReview-DXT7jYE1.js} +2 -2
- package/dist/reportManualReview-DXT7jYE1.js.map +1 -0
- package/dist/transforms/button.js +6 -5
- package/dist/transforms/button.js.map +1 -1
- package/package.json +1 -1
- package/dist/reportManualReview-CQm-npxR.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,167 +1,77 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const require_reportManualReview = require('./reportManualReview-
|
|
2
|
+
const require_reportManualReview = require('./reportManualReview-DXT7jYE1.js');
|
|
3
3
|
const node_child_process = require_reportManualReview.__toESM(require("node:child_process"));
|
|
4
4
|
const node_fs_promises = require_reportManualReview.__toESM(require("node:fs/promises"));
|
|
5
5
|
const node_path = require_reportManualReview.__toESM(require("node:path"));
|
|
6
6
|
const node_url = require_reportManualReview.__toESM(require("node:url"));
|
|
7
|
-
const node_fs = require_reportManualReview.__toESM(require("node:fs"));
|
|
8
7
|
const __inquirer_prompts = require_reportManualReview.__toESM(require("@inquirer/prompts"));
|
|
8
|
+
const node_fs = require_reportManualReview.__toESM(require("node:fs"));
|
|
9
9
|
require("jscodeshift/src/testUtils");
|
|
10
10
|
|
|
11
|
-
//#region src/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
message: "Select packages to transform:",
|
|
35
|
-
choices: nonRootPackages.map((file) => ({
|
|
36
|
-
name: file,
|
|
37
|
-
value: file,
|
|
38
|
-
checked: true
|
|
39
|
-
}))
|
|
40
|
-
});
|
|
41
|
-
};
|
|
42
|
-
/**
|
|
43
|
-
* Determine user choice between CLI arg and Inquirer prompt: codemod
|
|
44
|
-
*/
|
|
45
|
-
const determineTransformer = async ({ candidate, transformFiles }) => {
|
|
46
|
-
const codemodMessage = "Select codemod to run:";
|
|
47
|
-
if (candidate && transformFiles.includes(candidate)) {
|
|
48
|
-
logToInquirer(codemodMessage, candidate);
|
|
49
|
-
return candidate;
|
|
11
|
+
//#region src/controller/helpers/getOptions.ts
|
|
12
|
+
async function getOptions(transformFiles) {
|
|
13
|
+
const args = process.argv.slice(2);
|
|
14
|
+
if (args.length > 0) {
|
|
15
|
+
const [transformFile$1, targetPath$1] = args;
|
|
16
|
+
const dry$1 = args.includes("--dry") || args.includes("--dry-run");
|
|
17
|
+
const print$1 = args.includes("--print");
|
|
18
|
+
const ignorePatternIndex = args.findIndex((arg) => arg === "--ignore-pattern");
|
|
19
|
+
let ignorePattern$1;
|
|
20
|
+
if (ignorePatternIndex !== -1 && args.length > ignorePatternIndex + 1) ignorePattern$1 = args[ignorePatternIndex + 1];
|
|
21
|
+
const gitignore$1 = args.includes("--gitignore");
|
|
22
|
+
const noGitignore = args.includes("--no-gitignore");
|
|
23
|
+
if (!transformFile$1 || !transformFiles.includes(transformFile$1)) throw new Error("Invalid transform file specified.");
|
|
24
|
+
if (!targetPath$1) throw new Error("Target path cannot be empty.");
|
|
25
|
+
const useGitignore = !!(gitignore$1 || !gitignore$1 && !noGitignore);
|
|
26
|
+
return {
|
|
27
|
+
transformFile: transformFile$1,
|
|
28
|
+
targetPath: targetPath$1,
|
|
29
|
+
dry: dry$1,
|
|
30
|
+
print: print$1,
|
|
31
|
+
ignorePattern: ignorePattern$1,
|
|
32
|
+
gitignore: useGitignore
|
|
33
|
+
};
|
|
50
34
|
}
|
|
51
|
-
|
|
52
|
-
message:
|
|
35
|
+
const transformFile = await (0, __inquirer_prompts.select)({
|
|
36
|
+
message: "Select a codemod transform to run:",
|
|
53
37
|
choices: transformFiles.map((file) => ({
|
|
54
38
|
name: file,
|
|
55
39
|
value: file
|
|
56
40
|
}))
|
|
57
41
|
});
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
*/
|
|
62
|
-
const determinePaths = async ({ candidate, root, packages }) => {
|
|
63
|
-
const targetPaths = [];
|
|
64
|
-
if (candidate && (0, node_fs.existsSync)((0, node_path.join)(root, candidate))) {
|
|
65
|
-
logToInquirer("Path to run codemod on", candidate);
|
|
66
|
-
targetPaths.push(candidate);
|
|
67
|
-
}
|
|
68
|
-
if (!targetPaths.length) {
|
|
69
|
-
const packagesToProcess = await queryPackages(packages);
|
|
70
|
-
targetPaths.push(...packagesToProcess ?? []);
|
|
71
|
-
}
|
|
72
|
-
return targetPaths;
|
|
73
|
-
};
|
|
74
|
-
/**
|
|
75
|
-
* Determine user choice between CLI arg and Inquirer prompt: dry mode
|
|
76
|
-
*/
|
|
77
|
-
const determineIsDryMode = async (args) => {
|
|
78
|
-
const message = "Run in dry mode (no changes written to files)?";
|
|
79
|
-
if (args.includes("--dry") || args.includes("--dry-run")) {
|
|
80
|
-
logToInquirer(message, "Yes");
|
|
81
|
-
return true;
|
|
82
|
-
}
|
|
83
|
-
return (0, __inquirer_prompts.confirm)({
|
|
84
|
-
message,
|
|
85
|
-
default: false
|
|
42
|
+
const targetPath = await (0, __inquirer_prompts.input)({
|
|
43
|
+
message: "Enter the target directory or file path to run codemod on:",
|
|
44
|
+
validate: (value) => value.trim() !== "" || "Target path cannot be empty"
|
|
86
45
|
});
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
if (args.includes("--print")) {
|
|
94
|
-
logToInquirer(message, "Yes");
|
|
95
|
-
return true;
|
|
96
|
-
}
|
|
97
|
-
return (0, __inquirer_prompts.confirm)({
|
|
98
|
-
message,
|
|
46
|
+
const dry = await (0, __inquirer_prompts.confirm)({
|
|
47
|
+
message: "Run in dry mode (no changes written to files)?",
|
|
48
|
+
default: true
|
|
49
|
+
});
|
|
50
|
+
const print = await (0, __inquirer_prompts.confirm)({
|
|
51
|
+
message: "Print transformed source to console?",
|
|
99
52
|
default: false
|
|
100
53
|
});
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
*/
|
|
105
|
-
const determineIgnorePatterns = async (args) => {
|
|
106
|
-
const message = "Enter ignore pattern(s) (comma separated) or leave empty:";
|
|
107
|
-
const ignorePatternIndex = args.findIndex((arg) => arg === "--ignore-pattern");
|
|
108
|
-
let ignorePattern;
|
|
109
|
-
if (ignorePatternIndex !== -1 && args.length > ignorePatternIndex + 1) ignorePattern = args[ignorePatternIndex + 1];
|
|
110
|
-
if (ignorePattern) {
|
|
111
|
-
logToInquirer(message, ignorePattern);
|
|
112
|
-
return ignorePattern;
|
|
113
|
-
}
|
|
114
|
-
return (0, __inquirer_prompts.input)({
|
|
115
|
-
message,
|
|
116
|
-
validate: () => true
|
|
54
|
+
const ignorePattern = await (0, __inquirer_prompts.input)({
|
|
55
|
+
message: "Enter ignore pattern(s) (comma separated) or leave empty:",
|
|
56
|
+
validate: (value) => true
|
|
117
57
|
});
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
* Determine user choice between CLI arg and Inquirer prompt: gitignore
|
|
121
|
-
*/
|
|
122
|
-
const determineGitIgnore = async (args) => {
|
|
123
|
-
const message = "Respect .gitignore files?";
|
|
124
|
-
if (args.includes("--gitignore")) {
|
|
125
|
-
logToInquirer(message, "Yes");
|
|
126
|
-
return true;
|
|
127
|
-
}
|
|
128
|
-
if (args.includes("--no-gitignore")) {
|
|
129
|
-
logToInquirer(message, "No");
|
|
130
|
-
return false;
|
|
131
|
-
}
|
|
132
|
-
return (0, __inquirer_prompts.confirm)({
|
|
133
|
-
message,
|
|
58
|
+
const gitignore = await (0, __inquirer_prompts.confirm)({
|
|
59
|
+
message: "Respect .gitignore files?",
|
|
134
60
|
default: true
|
|
135
61
|
});
|
|
136
|
-
};
|
|
137
|
-
async function getOptions({ transformFiles, packages, root }) {
|
|
138
|
-
const args = process.argv.slice(2);
|
|
139
|
-
const transformFile = await determineTransformer({
|
|
140
|
-
candidate: args[0],
|
|
141
|
-
transformFiles
|
|
142
|
-
});
|
|
143
|
-
const targetPaths = await determinePaths({
|
|
144
|
-
candidate: args[1],
|
|
145
|
-
packages,
|
|
146
|
-
root
|
|
147
|
-
});
|
|
148
|
-
const isDry = await determineIsDryMode(args);
|
|
149
|
-
const isPrint = await determineIsPrint(args);
|
|
150
|
-
const ignorePatterns = await determineIgnorePatterns(args);
|
|
151
|
-
const useGitIgnore = await determineGitIgnore(args);
|
|
152
62
|
return {
|
|
153
63
|
transformFile,
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
64
|
+
targetPath,
|
|
65
|
+
dry,
|
|
66
|
+
print,
|
|
67
|
+
ignorePattern,
|
|
68
|
+
gitignore
|
|
159
69
|
};
|
|
160
70
|
}
|
|
161
71
|
var getOptions_default = getOptions;
|
|
162
72
|
|
|
163
73
|
//#endregion
|
|
164
|
-
//#region src/
|
|
74
|
+
//#region src/controller/helpers/loadTransformModules.ts
|
|
165
75
|
async function loadTransformModules(transformsDir) {
|
|
166
76
|
let transformModules = {};
|
|
167
77
|
const files = await node_fs.promises.readdir(transformsDir);
|
|
@@ -181,52 +91,6 @@ async function loadTransformModules(transformsDir) {
|
|
|
181
91
|
}
|
|
182
92
|
var loadTransformModules_default = loadTransformModules;
|
|
183
93
|
|
|
184
|
-
//#endregion
|
|
185
|
-
//#region src/utils/repository.ts
|
|
186
|
-
/**
|
|
187
|
-
* Finds the root of the project by looking for the `.git` directory.
|
|
188
|
-
*/
|
|
189
|
-
function findProjectRoot() {
|
|
190
|
-
try {
|
|
191
|
-
const gitRoot = (0, node_child_process.execSync)("git rev-parse --show-toplevel", {
|
|
192
|
-
cwd: process.cwd(),
|
|
193
|
-
encoding: "utf8",
|
|
194
|
-
stdio: [
|
|
195
|
-
"ignore",
|
|
196
|
-
"pipe",
|
|
197
|
-
"ignore"
|
|
198
|
-
]
|
|
199
|
-
}).trim();
|
|
200
|
-
return gitRoot && (0, node_fs.existsSync)(gitRoot) ? gitRoot : "";
|
|
201
|
-
} catch {
|
|
202
|
-
return "";
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
/**
|
|
206
|
-
* Quick and dirty way of determining package roots based on
|
|
207
|
-
* the presence of `package.json` files and them optimistically
|
|
208
|
-
* containing a `@transferwise/components` string.
|
|
209
|
-
* */
|
|
210
|
-
function findPackages() {
|
|
211
|
-
try {
|
|
212
|
-
const packages = (0, node_child_process.execSync)([
|
|
213
|
-
"find ./",
|
|
214
|
-
"-type f",
|
|
215
|
-
"-name \"package.json\"",
|
|
216
|
-
"-not -path \"*/node_modules/*\"",
|
|
217
|
-
"|",
|
|
218
|
-
"xargs grep -l \"@transferwise/components\""
|
|
219
|
-
].join(" "), {
|
|
220
|
-
cwd: findProjectRoot(),
|
|
221
|
-
encoding: "utf8"
|
|
222
|
-
}).trim().split("\n").map(node_path.default.dirname);
|
|
223
|
-
if (packages.length === 0) throw new Error();
|
|
224
|
-
return packages;
|
|
225
|
-
} catch {
|
|
226
|
-
throw new Error("No suitable package roots found in the repository.");
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
|
|
230
94
|
//#endregion
|
|
231
95
|
//#region node_modules/.pnpm/color-name@1.1.4/node_modules/color-name/index.js
|
|
232
96
|
var require_color_name = /* @__PURE__ */ require_reportManualReview.__commonJS({ "node_modules/.pnpm/color-name@1.1.4/node_modules/color-name/index.js": ((exports, module) => {
|
|
@@ -1828,15 +1692,15 @@ var require_route = /* @__PURE__ */ require_reportManualReview.__commonJS({ "nod
|
|
|
1828
1692
|
};
|
|
1829
1693
|
}
|
|
1830
1694
|
function wrapConversion(toModel, graph) {
|
|
1831
|
-
const path$
|
|
1695
|
+
const path$4 = [graph[toModel].parent, toModel];
|
|
1832
1696
|
let fn = conversions$1[graph[toModel].parent][toModel];
|
|
1833
1697
|
let cur = graph[toModel].parent;
|
|
1834
1698
|
while (graph[cur].parent) {
|
|
1835
|
-
path$
|
|
1699
|
+
path$4.unshift(graph[cur].parent);
|
|
1836
1700
|
fn = link(conversions$1[graph[cur].parent][cur], fn);
|
|
1837
1701
|
cur = graph[cur].parent;
|
|
1838
1702
|
}
|
|
1839
|
-
fn.conversion = path$
|
|
1703
|
+
fn.conversion = path$4;
|
|
1840
1704
|
return fn;
|
|
1841
1705
|
}
|
|
1842
1706
|
module.exports = function(fromModel) {
|
|
@@ -4967,11 +4831,11 @@ var require_opts_arg = /* @__PURE__ */ require_reportManualReview.__commonJS({ "
|
|
|
4967
4831
|
const resolved = opts;
|
|
4968
4832
|
const optsFs = opts.fs || {};
|
|
4969
4833
|
opts.mkdir = opts.mkdir || optsFs.mkdir || fs_1$1.mkdir;
|
|
4970
|
-
opts.mkdirAsync = opts.mkdirAsync ? opts.mkdirAsync : async (path$
|
|
4971
|
-
return new Promise((res, rej) => resolved.mkdir(path$
|
|
4834
|
+
opts.mkdirAsync = opts.mkdirAsync ? opts.mkdirAsync : async (path$4, options) => {
|
|
4835
|
+
return new Promise((res, rej) => resolved.mkdir(path$4, options, (er, made) => er ? rej(er) : res(made)));
|
|
4972
4836
|
};
|
|
4973
4837
|
opts.stat = opts.stat || optsFs.stat || fs_1$1.stat;
|
|
4974
|
-
opts.statAsync = opts.statAsync ? opts.statAsync : async (path$
|
|
4838
|
+
opts.statAsync = opts.statAsync ? opts.statAsync : async (path$4) => new Promise((res, rej) => resolved.stat(path$4, (err, stats) => err ? rej(err) : res(stats)));
|
|
4975
4839
|
opts.statSync = opts.statSync || optsFs.statSync || fs_1$1.statSync;
|
|
4976
4840
|
opts.mkdirSync = opts.mkdirSync || optsFs.mkdirSync || fs_1$1.mkdirSync;
|
|
4977
4841
|
return resolved;
|
|
@@ -4986,47 +4850,47 @@ var require_mkdirp_manual = /* @__PURE__ */ require_reportManualReview.__commonJ
|
|
|
4986
4850
|
exports.mkdirpManual = exports.mkdirpManualSync = void 0;
|
|
4987
4851
|
const path_1$3 = require("node:path");
|
|
4988
4852
|
const opts_arg_js_1$3 = require_opts_arg();
|
|
4989
|
-
const mkdirpManualSync = (path$
|
|
4990
|
-
const parent = (0, path_1$3.dirname)(path$
|
|
4853
|
+
const mkdirpManualSync = (path$4, options, made) => {
|
|
4854
|
+
const parent = (0, path_1$3.dirname)(path$4);
|
|
4991
4855
|
const opts = {
|
|
4992
4856
|
...(0, opts_arg_js_1$3.optsArg)(options),
|
|
4993
4857
|
recursive: false
|
|
4994
4858
|
};
|
|
4995
|
-
if (parent === path$
|
|
4996
|
-
return opts.mkdirSync(path$
|
|
4859
|
+
if (parent === path$4) try {
|
|
4860
|
+
return opts.mkdirSync(path$4, opts);
|
|
4997
4861
|
} catch (er) {
|
|
4998
4862
|
const fer = er;
|
|
4999
4863
|
if (fer && fer.code !== "EISDIR") throw er;
|
|
5000
4864
|
return;
|
|
5001
4865
|
}
|
|
5002
4866
|
try {
|
|
5003
|
-
opts.mkdirSync(path$
|
|
5004
|
-
return made || path$
|
|
4867
|
+
opts.mkdirSync(path$4, opts);
|
|
4868
|
+
return made || path$4;
|
|
5005
4869
|
} catch (er) {
|
|
5006
4870
|
const fer = er;
|
|
5007
|
-
if (fer && fer.code === "ENOENT") return (0, exports.mkdirpManualSync)(path$
|
|
4871
|
+
if (fer && fer.code === "ENOENT") return (0, exports.mkdirpManualSync)(path$4, opts, (0, exports.mkdirpManualSync)(parent, opts, made));
|
|
5008
4872
|
if (fer && fer.code !== "EEXIST" && fer && fer.code !== "EROFS") throw er;
|
|
5009
4873
|
try {
|
|
5010
|
-
if (!opts.statSync(path$
|
|
4874
|
+
if (!opts.statSync(path$4).isDirectory()) throw er;
|
|
5011
4875
|
} catch (_) {
|
|
5012
4876
|
throw er;
|
|
5013
4877
|
}
|
|
5014
4878
|
}
|
|
5015
4879
|
};
|
|
5016
4880
|
exports.mkdirpManualSync = mkdirpManualSync;
|
|
5017
|
-
exports.mkdirpManual = Object.assign(async (path$
|
|
4881
|
+
exports.mkdirpManual = Object.assign(async (path$4, options, made) => {
|
|
5018
4882
|
const opts = (0, opts_arg_js_1$3.optsArg)(options);
|
|
5019
4883
|
opts.recursive = false;
|
|
5020
|
-
const parent = (0, path_1$3.dirname)(path$
|
|
5021
|
-
if (parent === path$
|
|
4884
|
+
const parent = (0, path_1$3.dirname)(path$4);
|
|
4885
|
+
if (parent === path$4) return opts.mkdirAsync(path$4, opts).catch((er) => {
|
|
5022
4886
|
const fer = er;
|
|
5023
4887
|
if (fer && fer.code !== "EISDIR") throw er;
|
|
5024
4888
|
});
|
|
5025
|
-
return opts.mkdirAsync(path$
|
|
4889
|
+
return opts.mkdirAsync(path$4, opts).then(() => made || path$4, async (er) => {
|
|
5026
4890
|
const fer = er;
|
|
5027
|
-
if (fer && fer.code === "ENOENT") return (0, exports.mkdirpManual)(parent, opts).then((made$1) => (0, exports.mkdirpManual)(path$
|
|
4891
|
+
if (fer && fer.code === "ENOENT") return (0, exports.mkdirpManual)(parent, opts).then((made$1) => (0, exports.mkdirpManual)(path$4, opts, made$1));
|
|
5028
4892
|
if (fer && fer.code !== "EEXIST" && fer.code !== "EROFS") throw er;
|
|
5029
|
-
return opts.statAsync(path$
|
|
4893
|
+
return opts.statAsync(path$4).then((st) => {
|
|
5030
4894
|
if (st.isDirectory()) return made;
|
|
5031
4895
|
else throw er;
|
|
5032
4896
|
}, () => {
|
|
@@ -5042,18 +4906,18 @@ var require_find_made = /* @__PURE__ */ require_reportManualReview.__commonJS({
|
|
|
5042
4906
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5043
4907
|
exports.findMadeSync = exports.findMade = void 0;
|
|
5044
4908
|
const path_1$2 = require("node:path");
|
|
5045
|
-
const findMade = async (opts, parent, path$
|
|
5046
|
-
if (path$
|
|
5047
|
-
return opts.statAsync(parent).then((st) => st.isDirectory() ? path$
|
|
4909
|
+
const findMade = async (opts, parent, path$4) => {
|
|
4910
|
+
if (path$4 === parent) return;
|
|
4911
|
+
return opts.statAsync(parent).then((st) => st.isDirectory() ? path$4 : void 0, (er) => {
|
|
5048
4912
|
const fer = er;
|
|
5049
4913
|
return fer && fer.code === "ENOENT" ? (0, exports.findMade)(opts, (0, path_1$2.dirname)(parent), parent) : void 0;
|
|
5050
4914
|
});
|
|
5051
4915
|
};
|
|
5052
4916
|
exports.findMade = findMade;
|
|
5053
|
-
const findMadeSync = (opts, parent, path$
|
|
5054
|
-
if (path$
|
|
4917
|
+
const findMadeSync = (opts, parent, path$4) => {
|
|
4918
|
+
if (path$4 === parent) return void 0;
|
|
5055
4919
|
try {
|
|
5056
|
-
return opts.statSync(parent).isDirectory() ? path$
|
|
4920
|
+
return opts.statSync(parent).isDirectory() ? path$4 : void 0;
|
|
5057
4921
|
} catch (er) {
|
|
5058
4922
|
const fer = er;
|
|
5059
4923
|
return fer && fer.code === "ENOENT" ? (0, exports.findMadeSync)(opts, (0, path_1$2.dirname)(parent), parent) : void 0;
|
|
@@ -5071,32 +4935,32 @@ var require_mkdirp_native = /* @__PURE__ */ require_reportManualReview.__commonJ
|
|
|
5071
4935
|
const find_made_js_1 = require_find_made();
|
|
5072
4936
|
const mkdirp_manual_js_1$1 = require_mkdirp_manual();
|
|
5073
4937
|
const opts_arg_js_1$2 = require_opts_arg();
|
|
5074
|
-
const mkdirpNativeSync = (path$
|
|
4938
|
+
const mkdirpNativeSync = (path$4, options) => {
|
|
5075
4939
|
const opts = (0, opts_arg_js_1$2.optsArg)(options);
|
|
5076
4940
|
opts.recursive = true;
|
|
5077
|
-
const parent = (0, path_1$1.dirname)(path$
|
|
5078
|
-
if (parent === path$
|
|
5079
|
-
const made = (0, find_made_js_1.findMadeSync)(opts, path$
|
|
4941
|
+
const parent = (0, path_1$1.dirname)(path$4);
|
|
4942
|
+
if (parent === path$4) return opts.mkdirSync(path$4, opts);
|
|
4943
|
+
const made = (0, find_made_js_1.findMadeSync)(opts, path$4);
|
|
5080
4944
|
try {
|
|
5081
|
-
opts.mkdirSync(path$
|
|
4945
|
+
opts.mkdirSync(path$4, opts);
|
|
5082
4946
|
return made;
|
|
5083
4947
|
} catch (er) {
|
|
5084
4948
|
const fer = er;
|
|
5085
|
-
if (fer && fer.code === "ENOENT") return (0, mkdirp_manual_js_1$1.mkdirpManualSync)(path$
|
|
4949
|
+
if (fer && fer.code === "ENOENT") return (0, mkdirp_manual_js_1$1.mkdirpManualSync)(path$4, opts);
|
|
5086
4950
|
else throw er;
|
|
5087
4951
|
}
|
|
5088
4952
|
};
|
|
5089
4953
|
exports.mkdirpNativeSync = mkdirpNativeSync;
|
|
5090
|
-
exports.mkdirpNative = Object.assign(async (path$
|
|
4954
|
+
exports.mkdirpNative = Object.assign(async (path$4, options) => {
|
|
5091
4955
|
const opts = {
|
|
5092
4956
|
...(0, opts_arg_js_1$2.optsArg)(options),
|
|
5093
4957
|
recursive: true
|
|
5094
4958
|
};
|
|
5095
|
-
const parent = (0, path_1$1.dirname)(path$
|
|
5096
|
-
if (parent === path$
|
|
5097
|
-
return (0, find_made_js_1.findMade)(opts, path$
|
|
4959
|
+
const parent = (0, path_1$1.dirname)(path$4);
|
|
4960
|
+
if (parent === path$4) return await opts.mkdirAsync(path$4, opts);
|
|
4961
|
+
return (0, find_made_js_1.findMade)(opts, path$4).then((made) => opts.mkdirAsync(path$4, opts).then((m$1) => made || m$1).catch((er) => {
|
|
5098
4962
|
const fer = er;
|
|
5099
|
-
if (fer && fer.code === "ENOENT") return (0, mkdirp_manual_js_1$1.mkdirpManual)(path$
|
|
4963
|
+
if (fer && fer.code === "ENOENT") return (0, mkdirp_manual_js_1$1.mkdirpManual)(path$4, opts);
|
|
5100
4964
|
else throw er;
|
|
5101
4965
|
}));
|
|
5102
4966
|
}, { sync: exports.mkdirpNativeSync });
|
|
@@ -5109,21 +4973,21 @@ var require_path_arg = /* @__PURE__ */ require_reportManualReview.__commonJS({ "
|
|
|
5109
4973
|
exports.pathArg = void 0;
|
|
5110
4974
|
const platform = process.env.__TESTING_MKDIRP_PLATFORM__ || process.platform;
|
|
5111
4975
|
const path_1 = require("node:path");
|
|
5112
|
-
const pathArg = (path$
|
|
5113
|
-
if (/\0/.test(path$
|
|
5114
|
-
path: path$
|
|
4976
|
+
const pathArg = (path$4) => {
|
|
4977
|
+
if (/\0/.test(path$4)) throw Object.assign(/* @__PURE__ */ new TypeError("path must be a string without null bytes"), {
|
|
4978
|
+
path: path$4,
|
|
5115
4979
|
code: "ERR_INVALID_ARG_VALUE"
|
|
5116
4980
|
});
|
|
5117
|
-
path$
|
|
4981
|
+
path$4 = (0, path_1.resolve)(path$4);
|
|
5118
4982
|
if (platform === "win32") {
|
|
5119
4983
|
const badWinChars = /[*|"<>?:]/;
|
|
5120
|
-
const { root } = (0, path_1.parse)(path$
|
|
5121
|
-
if (badWinChars.test(path$
|
|
5122
|
-
path: path$
|
|
4984
|
+
const { root } = (0, path_1.parse)(path$4);
|
|
4985
|
+
if (badWinChars.test(path$4.substring(root.length))) throw Object.assign(/* @__PURE__ */ new Error("Illegal characters in path."), {
|
|
4986
|
+
path: path$4,
|
|
5123
4987
|
code: "EINVAL"
|
|
5124
4988
|
});
|
|
5125
4989
|
}
|
|
5126
|
-
return path$
|
|
4990
|
+
return path$4;
|
|
5127
4991
|
};
|
|
5128
4992
|
exports.pathArg = pathArg;
|
|
5129
4993
|
}) });
|
|
@@ -5193,10 +5057,10 @@ var require_src = /* @__PURE__ */ require_reportManualReview.__commonJS({ "node_
|
|
|
5193
5057
|
}
|
|
5194
5058
|
});
|
|
5195
5059
|
/* c8 ignore stop */
|
|
5196
|
-
const mkdirpSync = (path$
|
|
5197
|
-
path$
|
|
5060
|
+
const mkdirpSync = (path$4, opts) => {
|
|
5061
|
+
path$4 = (0, path_arg_js_1.pathArg)(path$4);
|
|
5198
5062
|
const resolved = (0, opts_arg_js_1.optsArg)(opts);
|
|
5199
|
-
return (0, use_native_js_1.useNativeSync)(resolved) ? (0, mkdirp_native_js_1.mkdirpNativeSync)(path$
|
|
5063
|
+
return (0, use_native_js_1.useNativeSync)(resolved) ? (0, mkdirp_native_js_1.mkdirpNativeSync)(path$4, resolved) : (0, mkdirp_manual_js_1.mkdirpManualSync)(path$4, resolved);
|
|
5200
5064
|
};
|
|
5201
5065
|
exports.mkdirpSync = mkdirpSync;
|
|
5202
5066
|
exports.sync = exports.mkdirpSync;
|
|
@@ -5204,10 +5068,10 @@ var require_src = /* @__PURE__ */ require_reportManualReview.__commonJS({ "node_
|
|
|
5204
5068
|
exports.manualSync = mkdirp_manual_js_1.mkdirpManualSync;
|
|
5205
5069
|
exports.native = mkdirp_native_js_1.mkdirpNative;
|
|
5206
5070
|
exports.nativeSync = mkdirp_native_js_1.mkdirpNativeSync;
|
|
5207
|
-
exports.mkdirp = Object.assign(async (path$
|
|
5208
|
-
path$
|
|
5071
|
+
exports.mkdirp = Object.assign(async (path$4, opts) => {
|
|
5072
|
+
path$4 = (0, path_arg_js_1.pathArg)(path$4);
|
|
5209
5073
|
const resolved = (0, opts_arg_js_1.optsArg)(opts);
|
|
5210
|
-
return (0, use_native_js_1.useNative)(resolved) ? (0, mkdirp_native_js_1.mkdirpNative)(path$
|
|
5074
|
+
return (0, use_native_js_1.useNative)(resolved) ? (0, mkdirp_native_js_1.mkdirpNative)(path$4, resolved) : (0, mkdirp_manual_js_1.mkdirpManual)(path$4, resolved);
|
|
5211
5075
|
}, {
|
|
5212
5076
|
mkdirpSync: exports.mkdirpSync,
|
|
5213
5077
|
mkdirpNative: mkdirp_native_js_1.mkdirpNative,
|
|
@@ -5414,65 +5278,52 @@ This is likely because this test is run in a ${chalk.blue("continuous integratio
|
|
|
5414
5278
|
}) });
|
|
5415
5279
|
|
|
5416
5280
|
//#endregion
|
|
5417
|
-
//#region src/
|
|
5281
|
+
//#region src/controller/helpers/snapshotOrchestrator.ts
|
|
5418
5282
|
var import_jest_file_snapshot = /* @__PURE__ */ require_reportManualReview.__toESM(require_jest_file_snapshot());
|
|
5419
5283
|
expect.extend({ toMatchFile: import_jest_file_snapshot.toMatchFile });
|
|
5420
5284
|
|
|
5421
5285
|
//#endregion
|
|
5422
|
-
//#region src/
|
|
5286
|
+
//#region src/controller/index.ts
|
|
5423
5287
|
const currentFilePath = (0, node_url.fileURLToPath)(require("url").pathToFileURL(__filename).href);
|
|
5424
5288
|
const currentDirPath = node_path.default.dirname(currentFilePath);
|
|
5425
|
-
const resetReportFile = async (reportPath) => {
|
|
5426
|
-
try {
|
|
5427
|
-
await node_fs_promises.default.access(reportPath);
|
|
5428
|
-
await node_fs_promises.default.rm(reportPath);
|
|
5429
|
-
console.debug(`Removed existing report file: ${reportPath}`);
|
|
5430
|
-
} catch {
|
|
5431
|
-
console.debug(`No existing report file to remove: ${reportPath}`);
|
|
5432
|
-
}
|
|
5433
|
-
};
|
|
5434
|
-
const summariseReportFile = async (reportPath) => {
|
|
5435
|
-
try {
|
|
5436
|
-
const reportContent = await node_fs_promises.default.readFile(reportPath, "utf8");
|
|
5437
|
-
const lines = reportContent.split("\n").filter(Boolean);
|
|
5438
|
-
if (lines.length) console.log(`\n⚠️ ${lines.length} manual review${lines.length > 1 ? "s are" : " is"} required. See ${reportPath} for details.`);
|
|
5439
|
-
else console.debug(`Report file exists but is empty: ${reportPath}`);
|
|
5440
|
-
} catch {
|
|
5441
|
-
console.debug(`No report file generated - no manual reviews needed`);
|
|
5442
|
-
}
|
|
5443
|
-
};
|
|
5444
5289
|
async function runCodemod(transformsDir) {
|
|
5445
5290
|
try {
|
|
5446
|
-
const packages = findPackages();
|
|
5447
|
-
const reportPath = node_path.default.resolve(process.cwd(), "codemod-report.txt");
|
|
5448
5291
|
const resolvedTransformsDir = transformsDir ?? node_path.default.resolve(currentDirPath, "../dist/transforms");
|
|
5449
5292
|
console.debug(`Resolved transforms directory: ${resolvedTransformsDir}`);
|
|
5450
|
-
await resetReportFile(reportPath);
|
|
5451
5293
|
const { transformFiles } = await loadTransformModules_default(resolvedTransformsDir);
|
|
5452
5294
|
if (transformFiles.length === 0) throw new Error(`No transform scripts found in directory: ${resolvedTransformsDir}`);
|
|
5453
|
-
const
|
|
5454
|
-
|
|
5455
|
-
root: findProjectRoot(),
|
|
5456
|
-
transformFiles: await Promise.all(transformFiles)
|
|
5457
|
-
});
|
|
5295
|
+
const resolvedTransformFiles = await Promise.all(transformFiles);
|
|
5296
|
+
const options = await getOptions_default(resolvedTransformFiles);
|
|
5458
5297
|
const codemodPath = node_path.default.resolve(resolvedTransformsDir, `${options.transformFile}.js`);
|
|
5459
5298
|
console.debug(`Resolved codemod path: ${codemodPath}`);
|
|
5460
|
-
|
|
5461
|
-
|
|
5462
|
-
|
|
5463
|
-
|
|
5464
|
-
|
|
5465
|
-
|
|
5466
|
-
|
|
5467
|
-
|
|
5468
|
-
|
|
5469
|
-
|
|
5470
|
-
|
|
5471
|
-
|
|
5472
|
-
|
|
5473
|
-
|
|
5474
|
-
|
|
5475
|
-
|
|
5299
|
+
const args = [
|
|
5300
|
+
"-t",
|
|
5301
|
+
codemodPath,
|
|
5302
|
+
options.targetPath,
|
|
5303
|
+
options.dry ? "--dry" : "",
|
|
5304
|
+
options.print ? "--print" : "",
|
|
5305
|
+
options.ignorePattern ? options.ignorePattern.split(",").map((pattern) => `--ignore-pattern=${pattern.trim()}`).join(" ") : "",
|
|
5306
|
+
options.gitignore ? "--gitignore" : ""
|
|
5307
|
+
].filter(Boolean);
|
|
5308
|
+
const command = `npx jscodeshift ${args.join(" ")}`;
|
|
5309
|
+
console.debug(`Running: ${command}`);
|
|
5310
|
+
const reportPath = node_path.default.resolve(process.cwd(), "codemod-report.txt");
|
|
5311
|
+
try {
|
|
5312
|
+
await node_fs_promises.default.access(reportPath);
|
|
5313
|
+
await node_fs_promises.default.rm(reportPath);
|
|
5314
|
+
console.debug(`Removed existing report file: ${reportPath}`);
|
|
5315
|
+
} catch {
|
|
5316
|
+
console.debug(`No existing report file to remove: ${reportPath}`);
|
|
5317
|
+
}
|
|
5318
|
+
(0, node_child_process.execSync)(command, { stdio: "inherit" });
|
|
5319
|
+
try {
|
|
5320
|
+
const reportContent = await node_fs_promises.default.readFile(reportPath, "utf8");
|
|
5321
|
+
const lines = reportContent.split("\n").filter(Boolean);
|
|
5322
|
+
if (lines.length) console.log(`\n⚠️ ${lines.length} manual review${lines.length > 1 ? "s are" : " is"} required. See ${reportPath} for details.`);
|
|
5323
|
+
else console.debug(`Report file exists but is empty: ${reportPath}`);
|
|
5324
|
+
} catch {
|
|
5325
|
+
console.debug(`No report file generated - no manual reviews needed`);
|
|
5326
|
+
}
|
|
5476
5327
|
} catch (error) {
|
|
5477
5328
|
if (error instanceof Error) console.error("Error running codemod:", error.message);
|
|
5478
5329
|
else console.error("Error running codemod:", error);
|