@openrewrite/recipes-nodejs 0.52.0-20261009-102010 → 0.52.1
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.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/migrate/code-style.d.ts +14 -0
- package/dist/migrate/code-style.d.ts.map +1 -0
- package/dist/migrate/code-style.js +70 -0
- package/dist/migrate/code-style.js.map +1 -0
- package/dist/migrate/hpagent/find-hpagent-manual-migrations.d.ts.map +1 -1
- package/dist/migrate/hpagent/find-hpagent-manual-migrations.js +36 -133
- package/dist/migrate/hpagent/find-hpagent-manual-migrations.js.map +1 -1
- package/dist/migrate/hpagent/hpagent-support.d.ts +36 -15
- package/dist/migrate/hpagent/hpagent-support.d.ts.map +1 -1
- package/dist/migrate/hpagent/hpagent-support.js +294 -55
- package/dist/migrate/hpagent/hpagent-support.js.map +1 -1
- package/dist/migrate/hpagent/replace-hpagent.d.ts.map +1 -1
- package/dist/migrate/hpagent/replace-hpagent.js +510 -153
- package/dist/migrate/hpagent/replace-hpagent.js.map +1 -1
- package/dist/migrate/source-map-support/enable-source-maps-at-launch.d.ts.map +1 -1
- package/dist/migrate/source-map-support/enable-source-maps-at-launch.js +8 -16
- package/dist/migrate/source-map-support/enable-source-maps-at-launch.js.map +1 -1
- package/dist/migrate/source-map-support/find-source-map-support-manual-migrations.d.ts.map +1 -1
- package/dist/migrate/source-map-support/find-source-map-support-manual-migrations.js +26 -9
- package/dist/migrate/source-map-support/find-source-map-support-manual-migrations.js.map +1 -1
- package/dist/migrate/source-map-support/migrate-source-map-support-to-native.d.ts.map +1 -1
- package/dist/migrate/source-map-support/migrate-source-map-support-to-native.js +7 -4
- package/dist/migrate/source-map-support/migrate-source-map-support-to-native.js.map +1 -1
- package/dist/migrate/source-map-support/replace-source-map-support-api.d.ts +9 -0
- package/dist/migrate/source-map-support/replace-source-map-support-api.d.ts.map +1 -0
- package/dist/migrate/source-map-support/replace-source-map-support-api.js +275 -0
- package/dist/migrate/source-map-support/replace-source-map-support-api.js.map +1 -0
- package/dist/migrate/source-map-support/replace-source-map-support-install.d.ts.map +1 -1
- package/dist/migrate/source-map-support/replace-source-map-support-install.js +2 -1
- package/dist/migrate/source-map-support/replace-source-map-support-install.js.map +1 -1
- package/dist/migrate/source-map-support/source-map-support-api-source.d.ts +14 -0
- package/dist/migrate/source-map-support/source-map-support-api-source.d.ts.map +1 -0
- package/dist/migrate/source-map-support/source-map-support-api-source.js +426 -0
- package/dist/migrate/source-map-support/source-map-support-api-source.js.map +1 -0
- package/dist/migrate/source-map-support/source-map-support-rewrites.d.ts.map +1 -1
- package/dist/migrate/source-map-support/source-map-support-rewrites.js +2 -0
- package/dist/migrate/source-map-support/source-map-support-rewrites.js.map +1 -1
- package/dist/migrate/source-map-support/source-map-support-support.d.ts +11 -3
- package/dist/migrate/source-map-support/source-map-support-support.d.ts.map +1 -1
- package/dist/migrate/source-map-support/source-map-support-support.js +69 -10
- package/dist/migrate/source-map-support/source-map-support-support.js.map +1 -1
- package/dist/resources/advisories-npm.csv +342 -6
- package/package.json +2 -2
- package/src/index.ts +2 -0
- package/src/migrate/code-style.ts +92 -0
- package/src/migrate/fs-extra/replace-fs-extra-native-methods.ts +2 -2
- package/src/migrate/hpagent/find-hpagent-manual-migrations.ts +45 -142
- package/src/migrate/hpagent/hpagent-support.ts +358 -60
- package/src/migrate/hpagent/replace-hpagent.ts +580 -189
- package/src/migrate/source-map-support/enable-source-maps-at-launch.ts +17 -26
- package/src/migrate/source-map-support/find-source-map-support-manual-migrations.ts +25 -9
- package/src/migrate/source-map-support/migrate-source-map-support-to-native.ts +7 -4
- package/src/migrate/source-map-support/replace-source-map-support-api.ts +281 -0
- package/src/migrate/source-map-support/replace-source-map-support-install.ts +2 -1
- package/src/migrate/source-map-support/source-map-support-api-source.ts +470 -0
- package/src/migrate/source-map-support/source-map-support-rewrites.ts +3 -0
- package/src/migrate/source-map-support/source-map-support-support.ts +79 -10
|
@@ -0,0 +1,426 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TYPE_MEMBERS = exports.VALUE_MEMBERS = void 0;
|
|
4
|
+
exports.declarationsFor = declarationsFor;
|
|
5
|
+
exports.builtinsFor = builtinsFor;
|
|
6
|
+
exports.apiSource = apiSource;
|
|
7
|
+
const code_style_1 = require("../code-style");
|
|
8
|
+
exports.VALUE_MEMBERS = new Map([
|
|
9
|
+
['install', 'installSourceMapSupport'], ['wrapCallSite', 'wrapCallSite'], ['getErrorSource', 'getErrorSource'],
|
|
10
|
+
['mapSourcePosition', 'mapSourcePosition'], ['retrieveSourceMap', 'retrieveSourceMap'],
|
|
11
|
+
['resetRetrieveHandlers', 'resetRetrieveHandlers'],
|
|
12
|
+
]);
|
|
13
|
+
exports.TYPE_MEMBERS = new Map([
|
|
14
|
+
['UrlAndMap', 'UrlAndMap'], ['Position', 'Position'], ['State', 'CallSiteState'],
|
|
15
|
+
['Options', 'SourceMapSupportOptions'], ['Environment', 'SourceMapSupportEnvironment'], ['CallSite', 'CallSite'],
|
|
16
|
+
]);
|
|
17
|
+
const TEMPLATES = {
|
|
18
|
+
UrlAndMap: {
|
|
19
|
+
uses: [], typeOnly: true,
|
|
20
|
+
source: ({ n }) => `
|
|
21
|
+
/** What \`retrieveSourceMap\` finds for a generated file: its source map, and where that was read from. */
|
|
22
|
+
interface ${n('UrlAndMap')} {
|
|
23
|
+
url?: string | undefined;
|
|
24
|
+
map: string | import('module').SourceMapPayload;
|
|
25
|
+
}`
|
|
26
|
+
},
|
|
27
|
+
Position: {
|
|
28
|
+
uses: [], typeOnly: true,
|
|
29
|
+
source: ({ n }) => `
|
|
30
|
+
interface ${n('Position')} {
|
|
31
|
+
source: string;
|
|
32
|
+
line: number;
|
|
33
|
+
column: number;
|
|
34
|
+
name?: string | null | undefined;
|
|
35
|
+
}`
|
|
36
|
+
},
|
|
37
|
+
CallSiteState: {
|
|
38
|
+
uses: ['Position'], typeOnly: true,
|
|
39
|
+
source: ({ n }) => `
|
|
40
|
+
/** The positions \`wrapCallSite\` passes between the frames of one stack, to name each frame's function. */
|
|
41
|
+
interface ${n('CallSiteState')} {
|
|
42
|
+
nextPosition: ${n('Position')} | null;
|
|
43
|
+
curPosition: ${n('Position')} | null;
|
|
44
|
+
}`
|
|
45
|
+
},
|
|
46
|
+
SourceMapSupportEnvironment: {
|
|
47
|
+
uses: [], typeOnly: true,
|
|
48
|
+
source: ({ n }) => `
|
|
49
|
+
type ${n('SourceMapSupportEnvironment')} = 'auto' | 'browser' | 'node';`
|
|
50
|
+
},
|
|
51
|
+
CallSite: {
|
|
52
|
+
uses: [], typeOnly: true,
|
|
53
|
+
source: ({ n }) => `
|
|
54
|
+
type ${n('CallSite')} = NodeJS.CallSite;`
|
|
55
|
+
},
|
|
56
|
+
SourceMapSupportOptions: {
|
|
57
|
+
uses: ['UrlAndMap'], typeOnly: true,
|
|
58
|
+
source: ({ n }) => `
|
|
59
|
+
/** source-map-support's \`install\` options; Node prints uncaught errors and reads inline source maps itself. */
|
|
60
|
+
interface ${n('SourceMapSupportOptions')} {
|
|
61
|
+
handleUncaughtExceptions?: boolean | undefined;
|
|
62
|
+
hookRequire?: boolean | undefined;
|
|
63
|
+
emptyCacheBetweenOperations?: boolean | undefined;
|
|
64
|
+
environment?: 'auto' | 'browser' | 'node' | undefined;
|
|
65
|
+
overrideRetrieveFile?: boolean | undefined;
|
|
66
|
+
overrideRetrieveSourceMap?: boolean | undefined;
|
|
67
|
+
retrieveFile?(path: string): string | null;
|
|
68
|
+
retrieveSourceMap?(source: string): ${n('UrlAndMap')} | null;
|
|
69
|
+
}`
|
|
70
|
+
},
|
|
71
|
+
SourceMapSupportState: {
|
|
72
|
+
uses: ['UrlAndMap'], typeOnly: true,
|
|
73
|
+
builtins: ['module#SourceMap'],
|
|
74
|
+
source: ({ n, b }) => `
|
|
75
|
+
interface ${n('SourceMapSupportState')} {
|
|
76
|
+
fileHandlers: ((path: string) => string | null)[];
|
|
77
|
+
mapHandlers: ((source: string) => ${n('UrlAndMap')} | null)[];
|
|
78
|
+
readFiles: boolean;
|
|
79
|
+
readMaps: boolean;
|
|
80
|
+
emptyCaches: boolean;
|
|
81
|
+
installed: boolean;
|
|
82
|
+
files: Map<string, string>;
|
|
83
|
+
maps: Map<string, {url?: string | undefined; map: ${b('module#SourceMap')}; root: string} | null>;
|
|
84
|
+
}`
|
|
85
|
+
},
|
|
86
|
+
installSourceMapSupport: {
|
|
87
|
+
uses: ['SourceMapSupportOptions', 'sourceMapSupportState', 'prepareSourceMappedStackTrace'],
|
|
88
|
+
source: ({ n, t }) => `
|
|
89
|
+
/**
|
|
90
|
+
* source-map-support's \`install\`, on Node's own source map decoder: stack traces are mapped through the
|
|
91
|
+
* \`retrieveSourceMap\` and \`retrieveFile\` handlers first, then the \`sourceMappingURL\` of each generated file.
|
|
92
|
+
*/
|
|
93
|
+
function ${n('installSourceMapSupport')}(options${t(`: ${n('SourceMapSupportOptions')}`)} = {})${t(': void')} {
|
|
94
|
+
const state = ${n('sourceMapSupportState')}();
|
|
95
|
+
if (options.retrieveFile) {
|
|
96
|
+
if (options.overrideRetrieveFile) {
|
|
97
|
+
state.fileHandlers.length = 0;
|
|
98
|
+
state.readFiles = false;
|
|
99
|
+
}
|
|
100
|
+
state.fileHandlers.unshift(options.retrieveFile);
|
|
101
|
+
}
|
|
102
|
+
if (options.retrieveSourceMap) {
|
|
103
|
+
if (options.overrideRetrieveSourceMap) {
|
|
104
|
+
state.mapHandlers.length = 0;
|
|
105
|
+
state.readMaps = false;
|
|
106
|
+
}
|
|
107
|
+
state.mapHandlers.unshift(options.retrieveSourceMap);
|
|
108
|
+
}
|
|
109
|
+
state.emptyCaches = state.emptyCaches || !!options.emptyCacheBetweenOperations;
|
|
110
|
+
if (!state.installed) {
|
|
111
|
+
state.installed = true;
|
|
112
|
+
// Read reflectively, as older versions of @types/node don't declare it.
|
|
113
|
+
const setSourceMapsEnabled${t(': ((enabled: boolean) => void) | undefined')} = Reflect.get(process, 'setSourceMapsEnabled');
|
|
114
|
+
setSourceMapsEnabled?.call(process, true);
|
|
115
|
+
Error.prepareStackTrace = ${n('prepareSourceMappedStackTrace')};
|
|
116
|
+
}
|
|
117
|
+
}`
|
|
118
|
+
},
|
|
119
|
+
wrapCallSite: {
|
|
120
|
+
uses: ['CallSiteState', 'mapSourcePosition', 'cloneCallSite', 'mapEvalOrigin', 'scriptNameOf'],
|
|
121
|
+
source: ({ n, t }) => `
|
|
122
|
+
/**
|
|
123
|
+
* A call site reporting its original position, and the original name of the function the next frame calls.
|
|
124
|
+
* \`state\` is ignored unless it is an object, as when this is passed to \`Array.prototype.map\`.
|
|
125
|
+
*/
|
|
126
|
+
function ${n('wrapCallSite')}(frame${t(': NodeJS.CallSite')}, state${t('?: unknown')})${t(': NodeJS.CallSite')} {
|
|
127
|
+
const positions${t(`: ${n('CallSiteState')}`)} = typeof state === 'object' && state ? state${t(` as ${n('CallSiteState')}`)} : {nextPosition: null, curPosition: null};
|
|
128
|
+
if (frame.isNative()) {
|
|
129
|
+
positions.curPosition = null;
|
|
130
|
+
return frame;
|
|
131
|
+
}
|
|
132
|
+
const source = frame.getFileName() || ${n('scriptNameOf')}(frame);
|
|
133
|
+
if (source) {
|
|
134
|
+
const position = ${n('mapSourcePosition')}({source, line: frame.getLineNumber()${t('!')}, column: frame.getColumnNumber()${t('!')} - 1});
|
|
135
|
+
positions.curPosition = position;
|
|
136
|
+
const clone = ${n('cloneCallSite')}(frame);
|
|
137
|
+
const functionName = clone.getFunctionName;
|
|
138
|
+
return Object.assign(clone, {
|
|
139
|
+
getFunctionName: () => positions.nextPosition?.name || functionName(),
|
|
140
|
+
getFileName: () => position.source,
|
|
141
|
+
getLineNumber: () => position.line,
|
|
142
|
+
getColumnNumber: () => position.column + 1,
|
|
143
|
+
getScriptNameOrSourceURL: () => position.source
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
const origin = frame.isEval() && frame.getEvalOrigin();
|
|
147
|
+
if (!origin) return frame;
|
|
148
|
+
const clone = ${n('cloneCallSite')}(frame);
|
|
149
|
+
const mapped = ${n('mapEvalOrigin')}(origin);
|
|
150
|
+
clone.getEvalOrigin = () => mapped;
|
|
151
|
+
return clone;
|
|
152
|
+
}`
|
|
153
|
+
},
|
|
154
|
+
getErrorSource: {
|
|
155
|
+
uses: ['sourceMapSupportState'],
|
|
156
|
+
builtins: ['fs#readFileSync'],
|
|
157
|
+
source: ({ n, b, t }) => `
|
|
158
|
+
/** The original source line an error was thrown from, with a caret under its column, as Node prints it. */
|
|
159
|
+
function ${n('getErrorSource')}(error${t(': Error')})${t(': string | null')} {
|
|
160
|
+
const match = /\\n at [^(]+ \\((.*):(\\d+):(\\d+)\\)/.exec(error.stack ?? '');
|
|
161
|
+
if (!match) return null;
|
|
162
|
+
const [, source, line, column] = match;
|
|
163
|
+
let contents = ${n('sourceMapSupportState')}().files.get(source${t('!')});
|
|
164
|
+
if (!contents) {
|
|
165
|
+
try {
|
|
166
|
+
contents = ${b('fs#readFileSync')}(source${t('!')}, 'utf8');
|
|
167
|
+
} catch {
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
const code = contents?.split(/\\r\\n|\\r|\\n/)[+line${t('!')} - 1];
|
|
171
|
+
return code ? \`\${source}:\${line}\\n\${code}\\n\${' '.repeat(+column${t('!')} - 1)}^\` : null;
|
|
172
|
+
}`
|
|
173
|
+
},
|
|
174
|
+
mapSourcePosition: {
|
|
175
|
+
uses: ['Position', 'SourceMapSupportState', 'sourceMapSupportState', 'retrieveSourceMap', 'resolveSourceURL'],
|
|
176
|
+
builtins: ['module#SourceMap'],
|
|
177
|
+
source: ({ n, b, t }) => `
|
|
178
|
+
/** The original position of a generated one, or the position itself where its source map has none. */
|
|
179
|
+
function ${n('mapSourcePosition')}(position${t(`: ${n('Position')}`)})${t(`: ${n('Position')}`)} {
|
|
180
|
+
const state = ${n('sourceMapSupportState')}();
|
|
181
|
+
if (!state.maps.has(position.source)) {
|
|
182
|
+
const urlAndMap = ${n('retrieveSourceMap')}(position.source);
|
|
183
|
+
let loaded${t(`: {url?: string | undefined; map: ${b('module#SourceMap')}; root: string} | null`)} = null;
|
|
184
|
+
if (urlAndMap) {
|
|
185
|
+
const payload = typeof urlAndMap.map === 'string' ? JSON.parse(urlAndMap.map.replace(/^\\)]}\\x27/, '')) : urlAndMap.map;
|
|
186
|
+
const root = payload.sourceRoot ? payload.sourceRoot.replace(/\\/?$/, '/') : '';
|
|
187
|
+
const url = urlAndMap.url;
|
|
188
|
+
loaded = {url, map: new ${b('module#SourceMap')}(payload), root};
|
|
189
|
+
payload.sourcesContent?.forEach((contents${t(': string | null')}, i${t(': number')}) => {
|
|
190
|
+
if (contents) state.files.set(${n('resolveSourceURL')}(url, root + payload.sources[i]), contents);
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
state.maps.set(position.source, loaded);
|
|
194
|
+
}
|
|
195
|
+
const loaded = state.maps.get(position.source);
|
|
196
|
+
// Node falls back to the last mapping of an earlier line, where the generated position says more.
|
|
197
|
+
const entry = loaded?.map.findEntry(position.line - 1, position.column);
|
|
198
|
+
if (!loaded || !entry || !('originalSource' in entry) || entry.generatedLine !== position.line - 1) return position;
|
|
199
|
+
return {
|
|
200
|
+
source: ${n('resolveSourceURL')}(loaded.url, loaded.root + entry.originalSource),
|
|
201
|
+
line: entry.originalLine + 1,
|
|
202
|
+
column: entry.originalColumn,
|
|
203
|
+
name: ${t('(')}entry${t(' as {name?: string})')}.name ?? null
|
|
204
|
+
};
|
|
205
|
+
}`
|
|
206
|
+
},
|
|
207
|
+
retrieveSourceMap: {
|
|
208
|
+
uses: ['UrlAndMap', 'sourceMapSupportState', 'retrieveSourceFile', 'resolveSourceURL'],
|
|
209
|
+
builtins: ['module#findSourceMap'],
|
|
210
|
+
source: ({ n, b, t }) => `
|
|
211
|
+
/** The source map of a generated file: from the handlers, its \`sourceMappingURL\`, or what Node read as it loaded. */
|
|
212
|
+
function ${n('retrieveSourceMap')}(source${t(': string')})${t(`: ${n('UrlAndMap')} | null`)} {
|
|
213
|
+
const state = ${n('sourceMapSupportState')}();
|
|
214
|
+
for (const handler of state.mapHandlers) {
|
|
215
|
+
const urlAndMap = handler(source);
|
|
216
|
+
if (urlAndMap) return urlAndMap;
|
|
217
|
+
}
|
|
218
|
+
if (!state.readMaps) return null;
|
|
219
|
+
const pattern = /(?:\\/\\/[@#][\\s]*sourceMappingURL=([^\\s\\x27\\x22]+)[\\s]*$)|(?:\\/\\*[@#][\\s]*sourceMappingURL=([^\\s*\\x27\\x22]+)[\\s]*(?:\\*\\/)[\\s]*$)/mg;
|
|
220
|
+
const contents = ${n('retrieveSourceFile')}(source) ?? '';
|
|
221
|
+
let url${t(': string | undefined')};
|
|
222
|
+
for (let match = pattern.exec(contents); match; match = pattern.exec(contents)) url = match[1] ?? match[2];
|
|
223
|
+
if (url && /^data:application\\/json[^,]+base64,/.test(url)) {
|
|
224
|
+
return {url: source, map: Buffer.from(url.slice(url.indexOf(',') + 1), 'base64').toString()};
|
|
225
|
+
}
|
|
226
|
+
const map = url && ${n('retrieveSourceFile')}(url = ${n('resolveSourceURL')}(source, url));
|
|
227
|
+
if (map) return {url, map};
|
|
228
|
+
const cached = ${b('module#findSourceMap')}(source);
|
|
229
|
+
return cached ? {url: source, map: cached.payload} : null;
|
|
230
|
+
}`
|
|
231
|
+
},
|
|
232
|
+
resetRetrieveHandlers: {
|
|
233
|
+
uses: ['sourceMapSupportState'],
|
|
234
|
+
source: ({ n, t }) => `
|
|
235
|
+
/** Drops the \`retrieveFile\` and \`retrieveSourceMap\` handlers \`install\` was given. */
|
|
236
|
+
function ${n('resetRetrieveHandlers')}()${t(': void')} {
|
|
237
|
+
const state = ${n('sourceMapSupportState')}();
|
|
238
|
+
state.fileHandlers.length = 0;
|
|
239
|
+
state.mapHandlers.length = 0;
|
|
240
|
+
state.readFiles = true;
|
|
241
|
+
state.readMaps = true;
|
|
242
|
+
}`
|
|
243
|
+
},
|
|
244
|
+
sourceMapSupportState: {
|
|
245
|
+
uses: ['SourceMapSupportState'],
|
|
246
|
+
source: ({ n, t }) => `
|
|
247
|
+
/**
|
|
248
|
+
* What source-map-support kept between calls, which every file with these functions shares. It hangs off
|
|
249
|
+
* \`process\` rather than \`globalThis\`, where test runners such as lab would report it as a leaked global.
|
|
250
|
+
*/
|
|
251
|
+
function ${n('sourceMapSupportState')}()${t(`: ${n('SourceMapSupportState')}`)} {
|
|
252
|
+
const key = Symbol.for('source-map-support');
|
|
253
|
+
let state${t(`: ${n('SourceMapSupportState')} | undefined`)} = Reflect.get(process, key);
|
|
254
|
+
if (!state) {
|
|
255
|
+
state = {
|
|
256
|
+
fileHandlers: [], mapHandlers: [], readFiles: true, readMaps: true, emptyCaches: false, installed: false,
|
|
257
|
+
files: new Map(), maps: new Map()
|
|
258
|
+
};
|
|
259
|
+
Reflect.set(process, key, state);
|
|
260
|
+
}
|
|
261
|
+
return state;
|
|
262
|
+
}`
|
|
263
|
+
},
|
|
264
|
+
retrieveSourceFile: {
|
|
265
|
+
uses: ['sourceMapSupportState'],
|
|
266
|
+
builtins: ['fs#readFileSync', 'url#fileURLToPath'],
|
|
267
|
+
source: ({ n, b, t }) => `
|
|
268
|
+
function ${n('retrieveSourceFile')}(path${t(': string')})${t(': string | null')} {
|
|
269
|
+
const state = ${n('sourceMapSupportState')}();
|
|
270
|
+
for (const handler of state.fileHandlers) {
|
|
271
|
+
const contents = handler(path);
|
|
272
|
+
if (contents) return contents;
|
|
273
|
+
}
|
|
274
|
+
if (!state.readFiles) return null;
|
|
275
|
+
path = path.trim();
|
|
276
|
+
if (path.startsWith('file:')) {
|
|
277
|
+
try {
|
|
278
|
+
path = ${b('url#fileURLToPath')}(path);
|
|
279
|
+
} catch {
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
if (!state.files.has(path)) {
|
|
283
|
+
let contents = '';
|
|
284
|
+
try {
|
|
285
|
+
contents = ${b('fs#readFileSync')}(path, 'utf8');
|
|
286
|
+
} catch {
|
|
287
|
+
}
|
|
288
|
+
state.files.set(path, contents);
|
|
289
|
+
}
|
|
290
|
+
return state.files.get(path)${t('!')};
|
|
291
|
+
}`
|
|
292
|
+
},
|
|
293
|
+
resolveSourceURL: {
|
|
294
|
+
uses: [],
|
|
295
|
+
builtins: ['path#dirname', 'path#resolve'],
|
|
296
|
+
source: ({ n, b, t }) => `
|
|
297
|
+
/** \`url\` resolved against the directory of \`file\`, keeping a protocol such as \`file://\` in front. */
|
|
298
|
+
function ${n('resolveSourceURL')}(file${t(': string | undefined')}, url${t(': string')})${t(': string')} {
|
|
299
|
+
if (!file) return url;
|
|
300
|
+
const dir = ${b('path#dirname')}(file);
|
|
301
|
+
const protocol = /^\\w+:\\/\\/[^/]*/.exec(dir)?.[0] ?? '';
|
|
302
|
+
const start = dir.slice(protocol.length);
|
|
303
|
+
if (protocol && /^\\/\\w:/.test(start)) {
|
|
304
|
+
return protocol + '/' + ${b('path#resolve')}(dir.slice(protocol.length + 1), url).replace(/\\\\/g, '/');
|
|
305
|
+
}
|
|
306
|
+
return protocol + ${b('path#resolve')}(start, url);
|
|
307
|
+
}`
|
|
308
|
+
},
|
|
309
|
+
mapEvalOrigin: {
|
|
310
|
+
uses: ['mapSourcePosition'],
|
|
311
|
+
source: ({ n, t }) => `
|
|
312
|
+
/** An \`eval\` origin as V8 formats it, with the position of each call site mapped. */
|
|
313
|
+
function ${n('mapEvalOrigin')}(origin${t(': string')})${t(': string')} {
|
|
314
|
+
let match = /^eval at ([^(]+) \\((.+):(\\d+):(\\d+)\\)$/.exec(origin);
|
|
315
|
+
if (match) {
|
|
316
|
+
const position = ${n('mapSourcePosition')}({source: match[2]${t('!')}, line: +match[3]${t('!')}, column: +match[4]${t('!')} - 1});
|
|
317
|
+
return \`eval at \${match[1]} (\${position.source}:\${position.line}:\${position.column + 1})\`;
|
|
318
|
+
}
|
|
319
|
+
match = /^eval at ([^(]+) \\((.+)\\)$/.exec(origin);
|
|
320
|
+
return match ? \`eval at \${match[1]} (\${${n('mapEvalOrigin')}(match[2]${t('!')})})\` : origin;
|
|
321
|
+
}`
|
|
322
|
+
},
|
|
323
|
+
scriptNameOf: {
|
|
324
|
+
uses: [],
|
|
325
|
+
source: ({ n, t }) => `
|
|
326
|
+
/** The call site's \`getScriptNameOrSourceURL\`, which older versions of @types/node don't declare. */
|
|
327
|
+
function ${n('scriptNameOf')}(frame${t(': NodeJS.CallSite')})${t(': string | null')} {
|
|
328
|
+
return ${t('(')}frame${t(' as unknown as {getScriptNameOrSourceURL(): string | null})')}.getScriptNameOrSourceURL();
|
|
329
|
+
}`
|
|
330
|
+
},
|
|
331
|
+
formatCallSite: {
|
|
332
|
+
uses: ['scriptNameOf'],
|
|
333
|
+
source: ({ n, t }) => `
|
|
334
|
+
/** V8's \`CallSite.prototype.toString\`, which reads the position through the call site's own methods. */
|
|
335
|
+
function ${n('formatCallSite')}(${t('this: NodeJS.CallSite')})${t(': string')} {
|
|
336
|
+
let location = '';
|
|
337
|
+
if (this.isNative()) {
|
|
338
|
+
location = 'native';
|
|
339
|
+
} else {
|
|
340
|
+
const fileName = ${n('scriptNameOf')}(this);
|
|
341
|
+
if (!fileName && this.isEval()) location = this.getEvalOrigin() + ', ';
|
|
342
|
+
location += fileName || '<anonymous>';
|
|
343
|
+
const line = this.getLineNumber();
|
|
344
|
+
if (line != null) {
|
|
345
|
+
location += ':' + line;
|
|
346
|
+
const column = this.getColumnNumber();
|
|
347
|
+
if (column) location += ':' + column;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
const functionName = this.getFunctionName();
|
|
351
|
+
const isConstructor = this.isConstructor();
|
|
352
|
+
if (!(this.isToplevel() || isConstructor)) {
|
|
353
|
+
let typeName = this.getTypeName();
|
|
354
|
+
if (typeName === '[object Object]') typeName = 'null';
|
|
355
|
+
const methodName = this.getMethodName();
|
|
356
|
+
let call = '';
|
|
357
|
+
if (functionName) {
|
|
358
|
+
if (typeName && functionName.indexOf(typeName) !== 0) call += typeName + '.';
|
|
359
|
+
call += functionName;
|
|
360
|
+
if (methodName && functionName.indexOf('.' + methodName) !== functionName.length - methodName.length - 1) {
|
|
361
|
+
call += \` [as \${methodName}]\`;
|
|
362
|
+
}
|
|
363
|
+
} else {
|
|
364
|
+
call += typeName + '.' + (methodName || '<anonymous>');
|
|
365
|
+
}
|
|
366
|
+
return \`\${call} (\${location})\`;
|
|
367
|
+
}
|
|
368
|
+
if (isConstructor) return \`new \${functionName || '<anonymous>'} (\${location})\`;
|
|
369
|
+
return functionName ? \`\${functionName} (\${location})\` : location;
|
|
370
|
+
}`
|
|
371
|
+
},
|
|
372
|
+
cloneCallSite: {
|
|
373
|
+
uses: ['formatCallSite'],
|
|
374
|
+
source: ({ n, t }) => `
|
|
375
|
+
/** A copy of a V8 call site whose methods can be replaced, which a call site's own can't. */
|
|
376
|
+
function ${n('cloneCallSite')}(frame${t(': NodeJS.CallSite')})${t(': NodeJS.CallSite')} {
|
|
377
|
+
const clone${t(': {[name: string]: unknown}')} = {};
|
|
378
|
+
for (const name of Object.getOwnPropertyNames(Object.getPrototypeOf(frame))) {
|
|
379
|
+
const member = ${t('(')}frame${t(' as unknown as {[name: string]: () => unknown})')}[name]${t('!')};
|
|
380
|
+
clone[name] = /^(?:is|get)/.test(name) ? () => member.call(frame) : member;
|
|
381
|
+
}
|
|
382
|
+
clone.toString = ${n('formatCallSite')};
|
|
383
|
+
return clone${t(' as unknown as NodeJS.CallSite')};
|
|
384
|
+
}`
|
|
385
|
+
},
|
|
386
|
+
prepareSourceMappedStackTrace: {
|
|
387
|
+
uses: ['sourceMapSupportState', 'CallSiteState', 'wrapCallSite'],
|
|
388
|
+
source: ({ n, t }) => `
|
|
389
|
+
/** The \`Error.prepareStackTrace\` source-map-support installs, formatting each frame at its original position. */
|
|
390
|
+
function ${n('prepareSourceMappedStackTrace')}(error${t(': Error')}, stack${t(': NodeJS.CallSite[]')})${t(': string')} {
|
|
391
|
+
const state = ${n('sourceMapSupportState')}();
|
|
392
|
+
if (state.emptyCaches) {
|
|
393
|
+
state.files.clear();
|
|
394
|
+
state.maps.clear();
|
|
395
|
+
}
|
|
396
|
+
const positions${t(`: ${n('CallSiteState')}`)} = {nextPosition: null, curPosition: null};
|
|
397
|
+
const frames${t(': string[]')} = [];
|
|
398
|
+
for (let i = stack.length - 1; i >= 0; i--) {
|
|
399
|
+
frames.push('\\n at ' + ${n('wrapCallSite')}(stack[i]${t('!')}, positions));
|
|
400
|
+
positions.nextPosition = positions.curPosition;
|
|
401
|
+
}
|
|
402
|
+
return \`\${error.name || 'Error'}: \${error.message || ''}\${frames.reverse().join('')}\`;
|
|
403
|
+
}`
|
|
404
|
+
},
|
|
405
|
+
};
|
|
406
|
+
const ORDER = Object.keys(TEMPLATES);
|
|
407
|
+
function declarationsFor(requested, typeScript) {
|
|
408
|
+
const needed = new Set();
|
|
409
|
+
const visit = (declaration) => {
|
|
410
|
+
if (needed.has(declaration))
|
|
411
|
+
return;
|
|
412
|
+
needed.add(declaration);
|
|
413
|
+
TEMPLATES[declaration].uses.forEach(visit);
|
|
414
|
+
};
|
|
415
|
+
[...requested].forEach(visit);
|
|
416
|
+
return ORDER.filter(d => needed.has(d) && (typeScript || !TEMPLATES[d].typeOnly));
|
|
417
|
+
}
|
|
418
|
+
function builtinsFor(declarations) {
|
|
419
|
+
return [...new Set(declarations.flatMap(d => { var _a; return (_a = TEMPLATES[d].builtins) !== null && _a !== void 0 ? _a : []; }))]
|
|
420
|
+
.sort((a, b) => a.localeCompare(b, 'en', { sensitivity: 'base' }));
|
|
421
|
+
}
|
|
422
|
+
function apiSource(declarations, spelling) {
|
|
423
|
+
const s = { n: spelling.names, b: spelling.builtins, t: typed => spelling.typeScript ? typed : '' };
|
|
424
|
+
return (0, code_style_1.restyle)(declarations.map(d => TEMPLATES[d].source(s).replace(/^\n/, '')).join('\n\n'), spelling.style);
|
|
425
|
+
}
|
|
426
|
+
//# sourceMappingURL=source-map-support-api-source.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source-map-support-api-source.js","sourceRoot":"","sources":["../../../src/migrate/source-map-support/source-map-support-api-source.ts"],"names":[],"mappings":";;;AA2bA,0CASC;AAGD,kCAGC;AAGD,8BAQC;AA/cD,8CAAiD;AAepC,QAAA,aAAa,GAAwC,IAAI,GAAG,CAAyB;IAC9F,CAAC,SAAS,EAAE,yBAAyB,CAAC,EAAE,CAAC,cAAc,EAAE,cAAc,CAAC,EAAE,CAAC,gBAAgB,EAAE,gBAAgB,CAAC;IAC9G,CAAC,mBAAmB,EAAE,mBAAmB,CAAC,EAAE,CAAC,mBAAmB,EAAE,mBAAmB,CAAC;IACtF,CAAC,uBAAuB,EAAE,uBAAuB,CAAC;CACrD,CAAC,CAAC;AAGU,QAAA,YAAY,GAAwC,IAAI,GAAG,CAAyB;IAC7F,CAAC,WAAW,EAAE,WAAW,CAAC,EAAE,CAAC,UAAU,EAAE,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,eAAe,CAAC;IAChF,CAAC,SAAS,EAAE,yBAAyB,CAAC,EAAE,CAAC,aAAa,EAAE,6BAA6B,CAAC,EAAE,CAAC,UAAU,EAAE,UAAU,CAAC;CACnH,CAAC,CAAC;AAkBH,MAAM,SAAS,GAAqC;IAChD,SAAS,EAAE;QACP,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI;QACxB,MAAM,EAAE,CAAC,EAAC,CAAC,EAAC,EAAE,EAAE,CAAC;;YAEb,CAAC,CAAC,WAAW,CAAC;;;EAGxB;KACG;IACD,QAAQ,EAAE;QACN,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI;QACxB,MAAM,EAAE,CAAC,EAAC,CAAC,EAAC,EAAE,EAAE,CAAC;YACb,CAAC,CAAC,UAAU,CAAC;;;;;EAKvB;KACG;IACD,aAAa,EAAE;QACX,IAAI,EAAE,CAAC,UAAU,CAAC,EAAE,QAA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K,EAAE,CAAC,EAAE,QAAQ,CAAC,QAAQ,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAC,CAAC;IAC5G,OAAO,IAAA,oBAAO,EAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC;AAClH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"source-map-support-rewrites.d.ts","sourceRoot":"","sources":["../../../src/migrate/source-map-support/source-map-support-rewrites.ts"],"names":[],"mappings":"AAMA,OAAO,EAAC,MAAM,EAAC,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"source-map-support-rewrites.d.ts","sourceRoot":"","sources":["../../../src/migrate/source-map-support/source-map-support-rewrites.ts"],"names":[],"mappings":"AAMA,OAAO,EAAC,MAAM,EAAC,MAAM,sBAAsB,CAAC;AAQ5C,wBAAgB,8BAA8B,IAAI,MAAM,EAAE,CAUzD"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.sourceMapSupportRewriteRecipes = sourceMapSupportRewriteRecipes;
|
|
4
4
|
const enable_source_maps_at_launch_1 = require("./enable-source-maps-at-launch");
|
|
5
|
+
const replace_source_map_support_api_1 = require("./replace-source-map-support-api");
|
|
5
6
|
const replace_source_map_support_install_1 = require("./replace-source-map-support-install");
|
|
6
7
|
const replace_source_map_support_register_in_package_json_1 = require("./replace-source-map-support-register-in-package-json");
|
|
7
8
|
const replace_source_map_support_register_in_mocha_config_1 = require("./replace-source-map-support-register-in-mocha-config");
|
|
@@ -10,6 +11,7 @@ function sourceMapSupportRewriteRecipes() {
|
|
|
10
11
|
new replace_source_map_support_register_in_package_json_1.ReplaceSourceMapSupportRegisterInPackageJson(),
|
|
11
12
|
new replace_source_map_support_register_in_mocha_config_1.ReplaceSourceMapSupportRegisterInMochaConfig(),
|
|
12
13
|
new replace_source_map_support_install_1.ReplaceSourceMapSupportInstall(),
|
|
14
|
+
new replace_source_map_support_api_1.ReplaceSourceMapSupportApi(),
|
|
13
15
|
new enable_source_maps_at_launch_1.EnableSourceMapsAtLaunch(),
|
|
14
16
|
];
|
|
15
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"source-map-support-rewrites.js","sourceRoot":"","sources":["../../../src/migrate/source-map-support/source-map-support-rewrites.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"source-map-support-rewrites.js","sourceRoot":"","sources":["../../../src/migrate/source-map-support/source-map-support-rewrites.ts"],"names":[],"mappings":";;AAcA,wEAUC;AAjBD,iFAAwE;AACxE,qFAA4E;AAC5E,6FAAoF;AACpF,+HAAmH;AACnH,+HAAmH;AAGnH,SAAgB,8BAA8B;IAC1C,OAAO;QACH,IAAI,kGAA4C,EAAE;QAClD,IAAI,kGAA4C,EAAE;QAClD,IAAI,mEAA8B,EAAE;QAEpC,IAAI,2DAA0B,EAAE;QAEhC,IAAI,uDAAwB,EAAE;KACjC,CAAC;AACN,CAAC"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { DataTable } from "@openrewrite/rewrite";
|
|
1
|
+
import { Cursor, DataTable } from "@openrewrite/rewrite";
|
|
2
2
|
import { J } from "@openrewrite/rewrite/java";
|
|
3
|
-
import {
|
|
3
|
+
import { JS } from "@openrewrite/rewrite/javascript";
|
|
4
|
+
import { BuiltinBindingVisitor } from "../builtin-binding-visitor";
|
|
4
5
|
import { ModuleBindings } from "../module-bindings";
|
|
5
6
|
export { bindingsOf, isModuleScoped, sourcePathOf, stringLiteral } from "../module-bindings";
|
|
6
7
|
export type { ModuleBindings } from "../module-bindings";
|
|
7
8
|
export declare const MODULES: Set<string>;
|
|
8
9
|
export declare const NON_INSTALL_MEMBERS: Set<string>;
|
|
10
|
+
export declare const DECLARING_KINDS: Set<string>;
|
|
9
11
|
export declare const REASONS: {
|
|
10
12
|
partialMapping: string;
|
|
11
13
|
nonNativeOption: (option: string) => string;
|
|
@@ -19,6 +21,8 @@ export declare const REASONS: {
|
|
|
19
21
|
reExport: string;
|
|
20
22
|
dynamicImport: string;
|
|
21
23
|
nestedRequire: string;
|
|
24
|
+
assigned: (name: string) => string;
|
|
25
|
+
specifierString: string;
|
|
22
26
|
mock: string;
|
|
23
27
|
};
|
|
24
28
|
export declare function propertyName(prop: JS.PropertyAssignment): string | undefined;
|
|
@@ -30,7 +34,11 @@ export declare function nonNativeOption(arg: J | undefined): {
|
|
|
30
34
|
reason: string;
|
|
31
35
|
} | undefined;
|
|
32
36
|
export declare function hasOnlyNativeOptions(arg: J | undefined): boolean;
|
|
33
|
-
export declare
|
|
37
|
+
export declare function isWriteTarget(cursor: Cursor): boolean;
|
|
38
|
+
export declare function isBrowserInstall(arg: J | undefined): boolean;
|
|
39
|
+
export declare function withoutStatements(statements: J.RightPadded<any>[], remove: (s: J) => boolean): J.RightPadded<any>[];
|
|
40
|
+
export declare abstract class SourceMapSupportVisitor<P> extends BuiltinBindingVisitor<P> {
|
|
41
|
+
protected readonly migratedModules: ReadonlySet<string>;
|
|
34
42
|
protected bindings: ModuleBindings;
|
|
35
43
|
protected visitJsCompilationUnit(cu: JS.CompilationUnit, p: P): Promise<J | undefined>;
|
|
36
44
|
protected mapsEverythingLoaded(): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"source-map-support-support.d.ts","sourceRoot":"","sources":["../../../src/migrate/source-map-support/source-map-support-support.ts"],"names":[],"mappings":"AAMA,OAAO,
|
|
1
|
+
{"version":3,"file":"source-map-support-support.d.ts","sourceRoot":"","sources":["../../../src/migrate/source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