@openrewrite/rewrite 8.92.14 → 8.92.16
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/javascript/add-import.d.ts.map +1 -1
- package/dist/javascript/add-import.js +127 -52
- package/dist/javascript/add-import.js.map +1 -1
- package/dist/javascript/amd.d.ts.map +1 -1
- package/dist/javascript/amd.js +3 -2
- package/dist/javascript/amd.js.map +1 -1
- package/dist/javascript/binding.js +3 -3
- package/dist/javascript/binding.js.map +1 -1
- package/dist/javascript/index.d.ts +3 -0
- package/dist/javascript/index.d.ts.map +1 -1
- package/dist/javascript/index.js +3 -0
- package/dist/javascript/index.js.map +1 -1
- package/dist/javascript/migrate/es6/modernize-octal-escape-sequences.d.ts.map +1 -1
- package/dist/javascript/migrate/es6/modernize-octal-escape-sequences.js +28 -32
- package/dist/javascript/migrate/es6/modernize-octal-escape-sequences.js.map +1 -1
- package/dist/javascript/preconditions.d.ts +11 -0
- package/dist/javascript/preconditions.d.ts.map +1 -1
- package/dist/javascript/preconditions.js +14 -0
- package/dist/javascript/preconditions.js.map +1 -1
- package/dist/javascript/search/index.d.ts +1 -0
- package/dist/javascript/search/index.d.ts.map +1 -1
- package/dist/javascript/search/index.js +1 -0
- package/dist/javascript/search/index.js.map +1 -1
- package/dist/javascript/search/is-vendored-or-bundled.d.ts +13 -0
- package/dist/javascript/search/is-vendored-or-bundled.d.ts.map +1 -0
- package/dist/javascript/search/is-vendored-or-bundled.js +93 -0
- package/dist/javascript/search/is-vendored-or-bundled.js.map +1 -0
- package/dist/rewrite-javascript-version.txt +1 -1
- package/package.json +1 -1
- package/src/javascript/add-import.ts +135 -53
- package/src/javascript/amd.ts +3 -2
- package/src/javascript/binding.ts +3 -3
- package/src/javascript/index.ts +3 -0
- package/src/javascript/migrate/es6/modernize-octal-escape-sequences.ts +28 -36
- package/src/javascript/preconditions.ts +19 -1
- package/src/javascript/search/index.ts +1 -0
- package/src/javascript/search/is-vendored-or-bundled.ts +59 -0
package/dist/javascript/index.js
CHANGED
|
@@ -97,6 +97,9 @@ __exportStar(require("./remove-import"), exports);
|
|
|
97
97
|
__exportStar(require("./cleanup/index"), exports);
|
|
98
98
|
__exportStar(require("./recipes/index"), exports);
|
|
99
99
|
__exportStar(require("./search/index"), exports);
|
|
100
|
+
__exportStar(require("./migrate/index"), exports);
|
|
101
|
+
__exportStar(require("./migrate/es6/index"), exports);
|
|
102
|
+
__exportStar(require("./migrate/typescript/index"), exports);
|
|
100
103
|
require("./print");
|
|
101
104
|
require("./rpc");
|
|
102
105
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/javascript/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;GAcG;AACH,yCAAuB;AACvB,4CAA0B;AAC1B,+CAA6B;AAC7B,2CAAyB;AACzB,0CAAwB;AACxB,4CAA0B;AAC1B,2DAAyC;AACzC,wDAAsC;AACtC,oDAAkC;AAClC,uDAAqC;AACrC,kDAAgC;AAChC,qDAAmC;AACnC,mDAAiC;AACjC,2CAAyB;AACzB,+CAA6B;AAC7B,+CAA6B;AAC7B,mDAAiC;AAGjC,gGAAgG;AAChG,wFAAwF;AACxF,iCAGiB;AAFb,gGAAA,OAAO,OAAA;AAAE,wGAAA,eAAe,OAAA;AAAE,4GAAA,mBAAmB,OAAA;AAAE,oGAAA,WAAW,OAAA;AAAE,8GAAA,qBAAqB,OAAA;AAAE,qGAAA,YAAY,OAAA;AAAE,mGAAA,UAAU,OAAA;AAC3G,yGAAA,gBAAgB,OAAA;AAAE,uGAAA,cAAc,OAAA;AAAE,0GAAA,iBAAiB,OAAA;AAAE,6FAAA,IAAI,OAAA;AAG7D,2CAAkE;AAA1D,yGAAA,WAAW,OAAA;AAAE,0GAAA,YAAY,OAAA;AAAE,uGAAA,SAAS,OAAA;AAG5C,6BAKe;AAJX,0GAAA,mBA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../../../src/javascript/migrate/es6/modernize-octal-escape-sequences.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAS,MAAM,EAAC,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAC,WAAW,EAAC,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAC,gBAAgB,EAAC,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"modernize-octal-escape-sequences.d.ts","sourceRoot":"","sources":["../../../../src/javascript/migrate/es6/modernize-octal-escape-sequences.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAS,MAAM,EAAC,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAC,WAAW,EAAC,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAC,gBAAgB,EAAC,MAAM,oBAAoB,CAAC;AAMpD,qBAAa,6BAA8B,SAAQ,MAAM;IACrD,IAAI,SAA6E;IACjF,WAAW,SAAsC;IACjD,WAAW,SAA0P;IAQrQ,iBAAiB,EAAE,OAAO,CAAC;gBAEf,OAAO,CAAC,EAAE;QAAE,iBAAiB,CAAC,EAAE,OAAO,CAAA;KAAE;IAK/C,MAAM,IAAI,OAAO,CAAC,WAAW,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;CAwC9D"}
|
|
@@ -24,6 +24,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
24
24
|
exports.ModernizeOctalEscapeSequences = void 0;
|
|
25
25
|
const recipe_1 = require("../../../recipe");
|
|
26
26
|
const visitor_1 = require("../../visitor");
|
|
27
|
+
const tree_1 = require("../../tree");
|
|
27
28
|
const mutative_1 = require("mutative");
|
|
28
29
|
class ModernizeOctalEscapeSequences extends recipe_1.Recipe {
|
|
29
30
|
constructor(options) {
|
|
@@ -31,48 +32,43 @@ class ModernizeOctalEscapeSequences extends recipe_1.Recipe {
|
|
|
31
32
|
super(options);
|
|
32
33
|
this.name = "org.openrewrite.javascript.migrate.es6.modernize-octal-escape-sequences";
|
|
33
34
|
this.displayName = "Modernize octal escape sequences";
|
|
34
|
-
this.description = "Convert
|
|
35
|
+
this.description = "Convert legacy octal escape sequences in string literals (e.g., `\\1`, `\\123`) to hex escape sequences (e.g., `\\x01`, `\\x53`) or Unicode escape sequences (e.g., `\\u0001`, `\\u0053`). The `\\0` escape is left alone unless a digit follows it.";
|
|
35
36
|
(_a = this.useUnicodeEscapes) !== null && _a !== void 0 ? _a : (this.useUnicodeEscapes = false);
|
|
36
37
|
}
|
|
37
38
|
async editor() {
|
|
38
39
|
const useUnicode = this.useUnicodeEscapes;
|
|
40
|
+
const modernize = (source) => source.replace(/\\([0-3][0-7]{0,2}|[4-7][0-7]?|[\s\S])/g, (escape, body, offset) => {
|
|
41
|
+
var _a;
|
|
42
|
+
if (!/^[0-7]/.test(body) || (body === '0' && !/[0-9]/.test((_a = source[offset + 2]) !== null && _a !== void 0 ? _a : ''))) {
|
|
43
|
+
return escape;
|
|
44
|
+
}
|
|
45
|
+
const code = parseInt(body, 8);
|
|
46
|
+
return useUnicode ?
|
|
47
|
+
`\\u${code.toString(16).padStart(4, '0')}` :
|
|
48
|
+
`\\x${code.toString(16).padStart(2, '0')}`;
|
|
49
|
+
});
|
|
39
50
|
return new class extends visitor_1.JavaScriptVisitor {
|
|
40
51
|
async visitLiteral(literal, _ctx) {
|
|
41
|
-
|
|
42
|
-
if (typeof literal.value !== 'string') {
|
|
43
|
-
return literal;
|
|
44
|
-
}
|
|
52
|
+
var _a, _b;
|
|
45
53
|
const valueSource = literal.valueSource;
|
|
46
|
-
if (!valueSource)
|
|
54
|
+
if (!valueSource || (valueSource[0] !== '"' && valueSource[0] !== "'") ||
|
|
55
|
+
((_a = this.cursor.parentTree()) === null || _a === void 0 ? void 0 : _a.value.kind) === tree_1.JS.Kind.JsxAttribute) {
|
|
47
56
|
return literal;
|
|
48
57
|
}
|
|
49
|
-
//
|
|
50
|
-
//
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
// Convert to Unicode escape sequence (4 hex digits, zero-padded)
|
|
63
|
-
return `\\u${decimalValue.toString(16).padStart(4, '0')}`;
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
// Convert to hex escape sequence (2 hex digits, zero-padded)
|
|
67
|
-
return `\\x${decimalValue.toString(16).padStart(2, '0')}`;
|
|
68
|
-
}
|
|
58
|
+
// Surrogate escapes are held outside valueSource, so each run between them is rewritten on its own
|
|
59
|
+
// and the escapes are moved to where their runs now end.
|
|
60
|
+
let modernized = '';
|
|
61
|
+
let cut = 0;
|
|
62
|
+
const unicodeEscapes = (_b = literal.unicodeEscapes) === null || _b === void 0 ? void 0 : _b.map(escape => {
|
|
63
|
+
modernized += modernize(valueSource.slice(cut, escape.valueSourceIndex));
|
|
64
|
+
cut = escape.valueSourceIndex;
|
|
65
|
+
return Object.assign(Object.assign({}, escape), { valueSourceIndex: modernized.length });
|
|
66
|
+
});
|
|
67
|
+
modernized += modernize(valueSource.slice(cut));
|
|
68
|
+
return modernized === valueSource ? literal : (0, mutative_1.create)(literal, draft => {
|
|
69
|
+
draft.valueSource = modernized;
|
|
70
|
+
draft.unicodeEscapes = unicodeEscapes;
|
|
69
71
|
});
|
|
70
|
-
if (hasOctalEscapes) {
|
|
71
|
-
return (0, mutative_1.create)(literal, draft => {
|
|
72
|
-
draft.valueSource = modernized;
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
return literal;
|
|
76
72
|
}
|
|
77
73
|
};
|
|
78
74
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modernize-octal-escape-sequences.js","sourceRoot":"","sources":["../../../../src/javascript/migrate/es6/modernize-octal-escape-sequences.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;AAEH,4CAA+C;AAG/C,2CAAgD;AAEhD,uCAA2C;AAE3C,MAAa,6BAA8B,SAAQ,eAAM;IAarD,YAAY,OAAyC;;QACjD,KAAK,CAAC,OAAO,CAAC,CAAC;QAbnB,SAAI,GAAG,yEAAyE,CAAC;QACjF,gBAAW,GAAG,kCAAkC,CAAC;QACjD,gBAAW,GAAG,
|
|
1
|
+
{"version":3,"file":"modernize-octal-escape-sequences.js","sourceRoot":"","sources":["../../../../src/javascript/migrate/es6/modernize-octal-escape-sequences.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;;;;;;;AAEH,4CAA+C;AAG/C,2CAAgD;AAEhD,qCAA8B;AAC9B,uCAA2C;AAE3C,MAAa,6BAA8B,SAAQ,eAAM;IAarD,YAAY,OAAyC;;QACjD,KAAK,CAAC,OAAO,CAAC,CAAC;QAbnB,SAAI,GAAG,yEAAyE,CAAC;QACjF,gBAAW,GAAG,kCAAkC,CAAC;QACjD,gBAAW,GAAG,sPAAsP,CAAC;QAYjQ,MAAA,IAAI,CAAC,iBAAiB,oCAAtB,IAAI,CAAC,iBAAiB,GAAK,KAAK,EAAC;IACrC,CAAC;IAED,KAAK,CAAC,MAAM;QACR,MAAM,UAAU,GAAG,IAAI,CAAC,iBAAiB,CAAC;QAC1C,MAAM,SAAS,GAAG,CAAC,MAAc,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAChD,yCAAyC,EACzC,CAAC,MAAc,EAAE,IAAY,EAAE,MAAc,EAAE,EAAE;;YAC7C,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAA,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,mCAAI,EAAE,CAAC,CAAC,EAAE,CAAC;gBACpF,OAAO,MAAM,CAAC;YAClB,CAAC;YACD,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;YAC/B,OAAO,UAAU,CAAC,CAAC;gBACf,MAAM,IAAI,CA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,CAAC,IAAA,iBAAO,EAAC,OAAO,EAAE,KAAK,CAAC,EAAE;oBACnE,KAAK,CAAC,WAAW,GAAG,UAAU,CAAC;oBAC/B,KAAK,CAAC,cAAc,GAAG,cAAc,CAAC;gBAC1C,CAAC,CAAC,CAAC;YACP,CAAC;SACJ,CAAA;IACL,CAAC;CACJ;AA1DD,sEA0DC;AA/CG;IANC,IAAA,eAAM,EAAC;QACJ,WAAW,EAAE,qBAAqB;QAClC,WAAW,EAAE,yGAAyG;QACtH,QAAQ,EAAE,KAAK;QACf,OAAO,EAAE,MAAM;KAClB,CAAC;wEACyB"}
|
|
@@ -15,6 +15,17 @@ import { RecipeRef } from "../preconditions";
|
|
|
15
15
|
* Delegates to {@code org.openrewrite.FindSourceFiles}.
|
|
16
16
|
*/
|
|
17
17
|
export declare function hasSourcePath(filePattern: string): RecipeRef;
|
|
18
|
+
/**
|
|
19
|
+
* Match vendored, bundled and build-output JavaScript and TypeScript sources,
|
|
20
|
+
* typically negated with {@link not} so that a recipe leaves them alone.
|
|
21
|
+
*
|
|
22
|
+
* Returns a {@link RecipeRef} placeholder bundled with a native
|
|
23
|
+
* {@link IsVendoredOrBundled} visitor for in-process evaluation; see
|
|
24
|
+
* {@link hasSourcePath} for the introspection / lazy-evaluation pattern.
|
|
25
|
+
*
|
|
26
|
+
* Delegates to {@code org.openrewrite.javascript.search.FindVendoredOrBundled}.
|
|
27
|
+
*/
|
|
28
|
+
export declare function isVendoredOrBundled(): RecipeRef;
|
|
18
29
|
/**
|
|
19
30
|
* Match files using a specific method.
|
|
20
31
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preconditions.d.ts","sourceRoot":"","sources":["../../src/javascript/preconditions.ts"],"names":[],"mappings":"AAeA,OAAO,EAAC,SAAS,EAAC,MAAM,kBAAkB,CAAC;AAI3C;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,CAM5D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,UAAU,CAAC,aAAa,EAAE,MAAM,EAAE,cAAc,GAAE,OAAe,GAAG,SAAS,CAM5F;AAED;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,sBAAsB,EAAE,MAAM,EAAE,kBAAkB,GAAE,OAAe,GAAG,SAAS,CAMvG;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,aAAa,EAAE,MAAM,EAAE,cAAc,GAAE,OAAe,GAAG,SAAS,CAM7F;AAED;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,sBAAsB,EAAE,MAAM,GAAG,SAAS,CAMnE"}
|
|
1
|
+
{"version":3,"file":"preconditions.d.ts","sourceRoot":"","sources":["../../src/javascript/preconditions.ts"],"names":[],"mappings":"AAeA,OAAO,EAAC,SAAS,EAAC,MAAM,kBAAkB,CAAC;AAI3C;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,SAAS,CAM5D;AAED;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,IAAI,SAAS,CAM/C;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,UAAU,CAAC,aAAa,EAAE,MAAM,EAAE,cAAc,GAAE,OAAe,GAAG,SAAS,CAM5F;AAED;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,sBAAsB,EAAE,MAAM,EAAE,kBAAkB,GAAE,OAAe,GAAG,SAAS,CAMvG;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,aAAa,EAAE,MAAM,EAAE,cAAc,GAAE,OAAe,GAAG,SAAS,CAM7F;AAED;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,sBAAsB,EAAE,MAAM,GAAG,SAAS,CAMnE"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.hasSourcePath = hasSourcePath;
|
|
4
|
+
exports.isVendoredOrBundled = isVendoredOrBundled;
|
|
4
5
|
exports.usesMethod = usesMethod;
|
|
5
6
|
exports.usesType = usesType;
|
|
6
7
|
exports.findMethods = findMethods;
|
|
@@ -41,6 +42,19 @@ const search_2 = require("./search");
|
|
|
41
42
|
function hasSourcePath(filePattern) {
|
|
42
43
|
return new preconditions_1.RecipeRef("org.openrewrite.FindSourceFiles", { filePattern }, new search_1.IsSourceFile(filePattern));
|
|
43
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Match vendored, bundled and build-output JavaScript and TypeScript sources,
|
|
47
|
+
* typically negated with {@link not} so that a recipe leaves them alone.
|
|
48
|
+
*
|
|
49
|
+
* Returns a {@link RecipeRef} placeholder bundled with a native
|
|
50
|
+
* {@link IsVendoredOrBundled} visitor for in-process evaluation; see
|
|
51
|
+
* {@link hasSourcePath} for the introspection / lazy-evaluation pattern.
|
|
52
|
+
*
|
|
53
|
+
* Delegates to {@code org.openrewrite.javascript.search.FindVendoredOrBundled}.
|
|
54
|
+
*/
|
|
55
|
+
function isVendoredOrBundled() {
|
|
56
|
+
return new preconditions_1.RecipeRef("org.openrewrite.javascript.search.FindVendoredOrBundled", {}, new search_2.IsVendoredOrBundled());
|
|
57
|
+
}
|
|
44
58
|
/**
|
|
45
59
|
* Match files using a specific method.
|
|
46
60
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preconditions.js","sourceRoot":"","sources":["../../src/javascript/preconditions.ts"],"names":[],"mappings":";;AAkCA,sCAMC;AAeD,gCAMC;AAWD,4BAMC;AAWD,kCAMC;AAWD,8BAMC;
|
|
1
|
+
{"version":3,"file":"preconditions.js","sourceRoot":"","sources":["../../src/javascript/preconditions.ts"],"names":[],"mappings":";;AAkCA,sCAMC;AAYD,kDAMC;AAeD,gCAMC;AAWD,4BAMC;AAWD,kCAMC;AAWD,8BAMC;AAlID;;;;;;;;;;;;;;GAcG;AACH,oDAA2C;AAC3C,sCAAuC;AACvC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../../../src/javascript/search/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAa,MAAM,mBAAmB,CAAC;AAEjE,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAE5B,eAAO,MAAM,MAAM,EAAE,kBAAkB,EAA6C,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/javascript/search/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAa,MAAM,mBAAmB,CAAC;AAEjE,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC;AACzC,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAE5B,eAAO,MAAM,MAAM,EAAE,kBAAkB,EAA6C,CAAA"}
|
|
@@ -17,6 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
exports.Search = void 0;
|
|
18
18
|
const marketplace_1 = require("../../marketplace");
|
|
19
19
|
__exportStar(require("./find-dependency"), exports);
|
|
20
|
+
__exportStar(require("./is-vendored-or-bundled"), exports);
|
|
20
21
|
__exportStar(require("./uses-method"), exports);
|
|
21
22
|
__exportStar(require("./uses-type"), exports);
|
|
22
23
|
exports.Search = [...marketplace_1.JavaScript, { displayName: "Search" }];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/javascript/search/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,mDAAiE;AAEjE,oDAAkC;AAClC,gDAA8B;AAC9B,8CAA4B;AAEf,QAAA,MAAM,GAAyB,CAAC,GAAG,wBAAU,EAAE,EAAC,WAAW,EAAE,QAAQ,EAAC,CAAC,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/javascript/search/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,mDAAiE;AAEjE,oDAAkC;AAClC,2DAAyC;AACzC,gDAA8B;AAC9B,8CAA4B;AAEf,QAAA,MAAM,GAAyB,CAAC,GAAG,wBAAU,EAAE,EAAC,WAAW,EAAE,QAAQ,EAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ExecutionContext } from "../../execution";
|
|
2
|
+
import { TreeVisitor } from "../../visitor";
|
|
3
|
+
/**
|
|
4
|
+
* Marks JavaScript and TypeScript sources that are vendored, bundled or build output.
|
|
5
|
+
* In-process counterpart of {@code org.openrewrite.javascript.search.FindVendoredOrBundled};
|
|
6
|
+
* keep the two in sync.
|
|
7
|
+
*/
|
|
8
|
+
export declare class IsVendoredOrBundled extends TreeVisitor<any, ExecutionContext> {
|
|
9
|
+
private readonly matcher;
|
|
10
|
+
protected preVisit(tree: any, _: ExecutionContext): Promise<any>;
|
|
11
|
+
private isVendoredOrBundled;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=is-vendored-or-bundled.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-vendored-or-bundled.d.ts","sourceRoot":"","sources":["../../../src/javascript/search/is-vendored-or-bundled.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAC,gBAAgB,EAAC,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAgB1C;;;;GAIG;AACH,qBAAa,mBAAoB,SAAQ,WAAW,CAAC,GAAG,EAAE,gBAAgB,CAAC;IACvE,OAAO,CAAC,QAAQ,CAAC,OAAO,CACqE;cAE7E,QAAQ,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,GAAG,CAAC;IAQtE,OAAO,CAAC,mBAAmB;CAQ9B"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.IsVendoredOrBundled = void 0;
|
|
37
|
+
/*
|
|
38
|
+
* Copyright 2026 the original author or authors.
|
|
39
|
+
* <p>
|
|
40
|
+
* Licensed under the Moderne Source Available License (the "License");
|
|
41
|
+
* you may not use this file except in compliance with the License.
|
|
42
|
+
* You may obtain a copy of the License at
|
|
43
|
+
* <p>
|
|
44
|
+
* https://docs.moderne.io/licensing/moderne-source-available-license
|
|
45
|
+
* <p>
|
|
46
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
47
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
48
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
49
|
+
* See the License for the specific language governing permissions and
|
|
50
|
+
* limitations under the License.
|
|
51
|
+
*/
|
|
52
|
+
const picomatch = __importStar(require("picomatch"));
|
|
53
|
+
const visitor_1 = require("../../visitor");
|
|
54
|
+
const markers_1 = require("../../markers");
|
|
55
|
+
const java_1 = require("../../java");
|
|
56
|
+
const tree_1 = require("../tree");
|
|
57
|
+
const PATH_PATTERNS = [
|
|
58
|
+
"**/node_modules/**",
|
|
59
|
+
"**/bower_components/**",
|
|
60
|
+
"**/vendor/**",
|
|
61
|
+
"**/dist/**",
|
|
62
|
+
"**/*.min.*",
|
|
63
|
+
"**/*.bundle.*"
|
|
64
|
+
];
|
|
65
|
+
const SOURCE_MAPPING_URL = /^[#@] sourceMappingURL=/;
|
|
66
|
+
/**
|
|
67
|
+
* Marks JavaScript and TypeScript sources that are vendored, bundled or build output.
|
|
68
|
+
* In-process counterpart of {@code org.openrewrite.javascript.search.FindVendoredOrBundled};
|
|
69
|
+
* keep the two in sync.
|
|
70
|
+
*/
|
|
71
|
+
class IsVendoredOrBundled extends visitor_1.TreeVisitor {
|
|
72
|
+
constructor() {
|
|
73
|
+
super(...arguments);
|
|
74
|
+
this.matcher = picomatch.default ? picomatch.default(PATH_PATTERNS) : picomatch(PATH_PATTERNS);
|
|
75
|
+
}
|
|
76
|
+
async preVisit(tree, _) {
|
|
77
|
+
this.stopAfterPreVisit();
|
|
78
|
+
if (tree.kind === tree_1.JS.Kind.CompilationUnit && this.isVendoredOrBundled(tree)) {
|
|
79
|
+
return (0, markers_1.foundSearchResult)(tree);
|
|
80
|
+
}
|
|
81
|
+
return tree;
|
|
82
|
+
}
|
|
83
|
+
isVendoredOrBundled(cu) {
|
|
84
|
+
if (this.matcher(cu.sourcePath.replace(/\\/g, '/'))) {
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
const comments = cu.eof.comments;
|
|
88
|
+
const last = comments[comments.length - 1];
|
|
89
|
+
return (last === null || last === void 0 ? void 0 : last.kind) === java_1.J.Kind.TextComment && SOURCE_MAPPING_URL.test(last.text.trim());
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
exports.IsVendoredOrBundled = IsVendoredOrBundled;
|
|
93
|
+
//# sourceMappingURL=is-vendored-or-bundled.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-vendored-or-bundled.js","sourceRoot":"","sources":["../../../src/javascript/search/is-vendored-or-bundled.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;GAcG;AACH,qDAAuC;AAEvC,2CAA0C;AAC1C,2CAAgD;AAChD,qCAA0C;AAC1C,kCAA2B;AAE3B,MAAM,aAAa,GAAG;IAClB,oBAAoB;IACpB,wBAAwB;IACxB,cAAc;IACd,YAAY;IACZ,YAAY;IACZ,eAAe;CAClB,CAAC;AAEF,MAAM,kBAAkB,GAAG,yBAAyB,CAAC;AAErD;;;;GAIG;AACH,MAAa,mBAAoB,SAAQ,qBAAkC;IAA3E;;QACqB,YAAO,GACpB,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAE,SAAiB,CAAC,aAAa,CAAC,CAAC;IAkBjG,CAAC;IAhBa,KAAK,CAAC,QAAQ,CAAC,IAAS,EAAE,CAAmB;QACnD,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACzB,IAAI,IAAI,CAAC,IAAI,KAAK,SAAE,CAAC,IAAI,CAAC,eAAe,IAAI,IAAI,CAAC,mBAAmB,CAAC,IAA0B,CAAC,EAAE,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