@openrewrite/rewrite 8.70.2 → 8.70.4
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 +5 -0
- package/dist/javascript/add-import.d.ts.map +1 -1
- package/dist/javascript/add-import.js +22 -9
- package/dist/javascript/add-import.js.map +1 -1
- package/dist/javascript/assertions.d.ts.map +1 -1
- package/dist/javascript/assertions.js +45 -13
- package/dist/javascript/assertions.js.map +1 -1
- package/dist/javascript/dependency-workspace.d.ts +5 -0
- package/dist/javascript/dependency-workspace.d.ts.map +1 -1
- package/dist/javascript/dependency-workspace.js +47 -13
- package/dist/javascript/dependency-workspace.js.map +1 -1
- package/dist/javascript/package-json-parser.d.ts +24 -0
- package/dist/javascript/package-json-parser.d.ts.map +1 -1
- package/dist/javascript/package-json-parser.js +147 -34
- package/dist/javascript/package-json-parser.js.map +1 -1
- package/dist/javascript/package-manager.d.ts +45 -7
- package/dist/javascript/package-manager.d.ts.map +1 -1
- package/dist/javascript/package-manager.js +83 -45
- package/dist/javascript/package-manager.js.map +1 -1
- package/dist/javascript/project-parser.d.ts +7 -0
- package/dist/javascript/project-parser.d.ts.map +1 -1
- package/dist/javascript/project-parser.js +10 -9
- package/dist/javascript/project-parser.js.map +1 -1
- package/dist/javascript/recipes/add-dependency.d.ts +7 -3
- package/dist/javascript/recipes/add-dependency.d.ts.map +1 -1
- package/dist/javascript/recipes/add-dependency.js +71 -13
- package/dist/javascript/recipes/add-dependency.js.map +1 -1
- package/dist/javascript/recipes/upgrade-dependency-version.d.ts +7 -3
- package/dist/javascript/recipes/upgrade-dependency-version.d.ts.map +1 -1
- package/dist/javascript/recipes/upgrade-dependency-version.js +71 -13
- package/dist/javascript/recipes/upgrade-dependency-version.js.map +1 -1
- package/dist/javascript/recipes/upgrade-transitive-dependency-version.d.ts +7 -3
- package/dist/javascript/recipes/upgrade-transitive-dependency-version.d.ts.map +1 -1
- package/dist/javascript/recipes/upgrade-transitive-dependency-version.js +71 -13
- package/dist/javascript/recipes/upgrade-transitive-dependency-version.js.map +1 -1
- package/dist/path-utils.d.ts +45 -0
- package/dist/path-utils.d.ts.map +1 -0
- package/dist/path-utils.js +210 -0
- package/dist/path-utils.js.map +1 -0
- package/dist/rpc/request/parse-project.d.ts +13 -1
- package/dist/rpc/request/parse-project.d.ts.map +1 -1
- package/dist/rpc/request/parse-project.js +18 -9
- package/dist/rpc/request/parse-project.js.map +1 -1
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +4 -0
- package/dist/run.js.map +1 -1
- package/dist/version.txt +1 -1
- package/package.json +1 -1
- package/src/javascript/add-import.ts +28 -7
- package/src/javascript/assertions.ts +48 -6
- package/src/javascript/dependency-workspace.ts +66 -13
- package/src/javascript/package-json-parser.ts +181 -42
- package/src/javascript/package-manager.ts +120 -52
- package/src/javascript/project-parser.ts +18 -9
- package/src/javascript/recipes/add-dependency.ts +89 -17
- package/src/javascript/recipes/upgrade-dependency-version.ts +89 -17
- package/src/javascript/recipes/upgrade-transitive-dependency-version.ts +89 -17
- package/src/path-utils.ts +208 -0
- package/src/rpc/request/parse-project.ts +17 -9
- package/src/run.ts +4 -0
|
@@ -0,0 +1,210 @@
|
|
|
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
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
+
exports.DEFAULT_DIR_EXCLUSIONS = void 0;
|
|
46
|
+
exports.isGitIgnored = isGitIgnored;
|
|
47
|
+
exports.isInGitRepo = isInGitRepo;
|
|
48
|
+
exports.walkDirs = walkDirs;
|
|
49
|
+
exports.getGitTrackedFiles = getGitTrackedFiles;
|
|
50
|
+
/*
|
|
51
|
+
* Copyright 2025 the original author or authors.
|
|
52
|
+
* <p>
|
|
53
|
+
* Licensed under the Moderne Source Available License (the "License");
|
|
54
|
+
* you may not use this file except in compliance with the License.
|
|
55
|
+
* You may obtain a copy of the License at
|
|
56
|
+
* <p>
|
|
57
|
+
* https://docs.moderne.io/licensing/moderne-source-available-license
|
|
58
|
+
* <p>
|
|
59
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
60
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
61
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
62
|
+
* See the License for the specific language governing permissions and
|
|
63
|
+
* limitations under the License.
|
|
64
|
+
*/
|
|
65
|
+
const fs = __importStar(require("fs"));
|
|
66
|
+
const fsp = __importStar(require("fs/promises"));
|
|
67
|
+
const path = __importStar(require("path"));
|
|
68
|
+
const child_process_1 = require("child_process");
|
|
69
|
+
/**
|
|
70
|
+
* Default directory exclusions for file/directory discovery.
|
|
71
|
+
*/
|
|
72
|
+
exports.DEFAULT_DIR_EXCLUSIONS = new Set([
|
|
73
|
+
"node_modules",
|
|
74
|
+
".git",
|
|
75
|
+
".svn",
|
|
76
|
+
".hg",
|
|
77
|
+
"dist",
|
|
78
|
+
"build",
|
|
79
|
+
"out",
|
|
80
|
+
"coverage",
|
|
81
|
+
".next",
|
|
82
|
+
".nuxt",
|
|
83
|
+
".output"
|
|
84
|
+
]);
|
|
85
|
+
/**
|
|
86
|
+
* Checks if a path is ignored by Git.
|
|
87
|
+
* Returns true if the path is ignored, false otherwise.
|
|
88
|
+
* Falls back to false if not in a git repository.
|
|
89
|
+
*/
|
|
90
|
+
function isGitIgnored(filePath, cwd) {
|
|
91
|
+
const result = (0, child_process_1.spawnSync)("git", ["check-ignore", "-q", filePath], {
|
|
92
|
+
cwd: cwd || path.dirname(filePath),
|
|
93
|
+
encoding: "utf8"
|
|
94
|
+
});
|
|
95
|
+
// Exit code 0 means the file IS ignored
|
|
96
|
+
// Exit code 1 means the file is NOT ignored
|
|
97
|
+
// Other exit codes indicate git errors (not a repo, etc.)
|
|
98
|
+
return result.status === 0;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Checks if we're in a git repository.
|
|
102
|
+
*/
|
|
103
|
+
function isInGitRepo(dir) {
|
|
104
|
+
const result = (0, child_process_1.spawnSync)("git", ["rev-parse", "--git-dir"], {
|
|
105
|
+
cwd: dir,
|
|
106
|
+
encoding: "utf8"
|
|
107
|
+
});
|
|
108
|
+
return result.status === 0;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Recursively walks directories starting from a given path.
|
|
112
|
+
* Returns all subdirectory paths (not including the root).
|
|
113
|
+
*/
|
|
114
|
+
function walkDirs(rootDir_1) {
|
|
115
|
+
return __awaiter(this, arguments, void 0, function* (rootDir, options = {}) {
|
|
116
|
+
const { maxDepth, excludeDirs = exports.DEFAULT_DIR_EXCLUSIONS, respectGitIgnore = false, mustContainFile } = options;
|
|
117
|
+
const results = [];
|
|
118
|
+
const inGitRepo = respectGitIgnore && isInGitRepo(rootDir);
|
|
119
|
+
function walk(dir, depth) {
|
|
120
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
121
|
+
if (maxDepth !== undefined && depth > maxDepth) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
let entries;
|
|
125
|
+
try {
|
|
126
|
+
entries = yield fsp.readdir(dir, { withFileTypes: true });
|
|
127
|
+
}
|
|
128
|
+
catch (_a) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
for (const entry of entries) {
|
|
132
|
+
if (!entry.isDirectory()) {
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
|
+
// Skip excluded directories
|
|
136
|
+
if (excludeDirs.has(entry.name)) {
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
// Skip hidden directories
|
|
140
|
+
if (entry.name.startsWith('.')) {
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
const fullPath = path.join(dir, entry.name);
|
|
144
|
+
// Check git ignore if enabled
|
|
145
|
+
if (inGitRepo && isGitIgnored(fullPath, rootDir)) {
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
// Check for required file if specified
|
|
149
|
+
if (mustContainFile) {
|
|
150
|
+
const requiredFile = path.join(fullPath, mustContainFile);
|
|
151
|
+
if (fs.existsSync(requiredFile)) {
|
|
152
|
+
results.push(fullPath);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
results.push(fullPath);
|
|
157
|
+
}
|
|
158
|
+
// Recurse into subdirectory
|
|
159
|
+
yield walk(fullPath, depth + 1);
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
yield walk(rootDir, 0);
|
|
164
|
+
return results;
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Gets files tracked by git (and untracked but not ignored files).
|
|
169
|
+
* Falls back to empty array if not in a git repository.
|
|
170
|
+
*/
|
|
171
|
+
function getGitTrackedFiles(dir) {
|
|
172
|
+
const files = [];
|
|
173
|
+
// Get tracked files
|
|
174
|
+
const tracked = (0, child_process_1.spawnSync)("git", ["ls-files"], {
|
|
175
|
+
cwd: dir,
|
|
176
|
+
encoding: "utf8"
|
|
177
|
+
});
|
|
178
|
+
if (tracked.status !== 0 || tracked.error) {
|
|
179
|
+
return [];
|
|
180
|
+
}
|
|
181
|
+
if (tracked.stdout) {
|
|
182
|
+
for (const line of tracked.stdout.split("\n")) {
|
|
183
|
+
const trimmed = line.trim();
|
|
184
|
+
if (trimmed) {
|
|
185
|
+
const fullPath = path.join(dir, trimmed);
|
|
186
|
+
if (fs.existsSync(fullPath)) {
|
|
187
|
+
files.push(fullPath);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
// Get untracked but not ignored files
|
|
193
|
+
const untracked = (0, child_process_1.spawnSync)("git", ["ls-files", "--others", "--exclude-standard"], {
|
|
194
|
+
cwd: dir,
|
|
195
|
+
encoding: "utf8"
|
|
196
|
+
});
|
|
197
|
+
if (untracked.stdout) {
|
|
198
|
+
for (const line of untracked.stdout.split("\n")) {
|
|
199
|
+
const trimmed = line.trim();
|
|
200
|
+
if (trimmed) {
|
|
201
|
+
const fullPath = path.join(dir, trimmed);
|
|
202
|
+
if (fs.existsSync(fullPath)) {
|
|
203
|
+
files.push(fullPath);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
return files;
|
|
209
|
+
}
|
|
210
|
+
//# sourceMappingURL=path-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path-utils.js","sourceRoot":"","sources":["../src/path-utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,oCASC;AAKD,kCAMC;AA8BD,4BAiEC;AAMD,gDA4CC;AA/MD;;;;;;;;;;;;;;GAcG;AACH,uCAAyB;AACzB,iDAAmC;AACnC,2CAA6B;AAC7B,iDAAwC;AAExC;;GAEG;AACU,QAAA,sBAAsB,GAAG,IAAI,GAAG,CAAC;IAC1C,cAAc;IACd,MAAM;IACN,MAAM;IACN,KAAK;IACL,MAAM;IACN,OAAO;IACP,KAAK;IACL,UAAU;IACV,OAAO;IACP,OAAO;IACP,SAAS;CACZ,CAAC,CAAC;AAEH;;;;GAIG;AACH,SAAgB,YAAY,CAAC,QAAgB,EAAE,GAAY;IACvD,MAAM,MAAM,GAAG,IAAA,yBAAS,EAAC,KAAK,EAAE,CAAC,cAAc,EAAE,IAAI,EAAE,QAAQ,CAAC,EAAE;QAC9D,GAAG,EAAE,GAAG,IAAI,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;QAClC,QAAQ,EAAE,MAAM;KACnB,CAAC,CAAC;IACH,w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20
|
private readonly projectPath;
|
|
21
21
|
private readonly exclusions?;
|
|
22
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Optional path to make source file paths relative to.
|
|
24
|
+
* If not specified, paths are relative to projectPath.
|
|
25
|
+
* Use this when parsing a subdirectory but wanting paths relative to the repository root.
|
|
26
|
+
*/
|
|
27
|
+
private readonly relativeTo?;
|
|
28
|
+
constructor(projectPath: string, exclusions?: string[] | undefined,
|
|
29
|
+
/**
|
|
30
|
+
* Optional path to make source file paths relative to.
|
|
31
|
+
* If not specified, paths are relative to projectPath.
|
|
32
|
+
* Use this when parsing a subdirectory but wanting paths relative to the repository root.
|
|
33
|
+
*/
|
|
34
|
+
relativeTo?: string | undefined);
|
|
23
35
|
static handle(connection: rpc.MessageConnection, localObjects: Map<string, ((input: string) => any) | any>, metricsCsv?: string): void;
|
|
24
36
|
}
|
|
25
37
|
//# sourceMappingURL=parse-project.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-project.d.ts","sourceRoot":"","sources":["../../../src/rpc/request/parse-project.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAG3C,OAAO,EAAW,IAAI,EAAC,MAAM,YAAY,CAAC;AAO1C;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACrC,EAAE,EAAE,IAAI,CAAC;IACT,cAAc,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;;;GAQG;AACH,qBAAa,YAAY;IAEjB,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"parse-project.d.ts","sourceRoot":"","sources":["../../../src/rpc/request/parse-project.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,GAAG,MAAM,qBAAqB,CAAC;AAG3C,OAAO,EAAW,IAAI,EAAC,MAAM,YAAY,CAAC;AAO1C;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACrC,EAAE,EAAE,IAAI,CAAC;IACT,cAAc,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;;;GAQG;AACH,qBAAa,YAAY;IAEjB,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC;IAC5B;;;;OAIG;IACH,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC;gBAPX,WAAW,EAAE,MAAM,EACnB,UAAU,CAAC,EAAE,MAAM,EAAE,YAAA;IACtC;;;;OAIG;IACc,UAAU,CAAC,EAAE,MAAM,YAAA;IAGxC,MAAM,CAAC,MAAM,CACT,UAAU,EAAE,GAAG,CAAC,iBAAiB,EACjC,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,GAAG,CAAC,GAAG,GAAG,CAAC,EACzD,UAAU,CAAC,EAAE,MAAM,GACpB,IAAI;CA4NV"}
|
|
@@ -83,9 +83,16 @@ const markers_1 = require("../../markers");
|
|
|
83
83
|
* Uses ProjectParser for file discovery and Prettier detection.
|
|
84
84
|
*/
|
|
85
85
|
class ParseProject {
|
|
86
|
-
constructor(projectPath, exclusions
|
|
86
|
+
constructor(projectPath, exclusions,
|
|
87
|
+
/**
|
|
88
|
+
* Optional path to make source file paths relative to.
|
|
89
|
+
* If not specified, paths are relative to projectPath.
|
|
90
|
+
* Use this when parsing a subdirectory but wanting paths relative to the repository root.
|
|
91
|
+
*/
|
|
92
|
+
relativeTo) {
|
|
87
93
|
this.projectPath = projectPath;
|
|
88
94
|
this.exclusions = exclusions;
|
|
95
|
+
this.relativeTo = relativeTo;
|
|
89
96
|
}
|
|
90
97
|
static handle(connection, localObjects, metricsCsv) {
|
|
91
98
|
connection.onRequest(new rpc.RequestType("ParseProject"), (0, metrics_1.withMetrics)("ParseProject", metricsCsv, (context) => (request) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -94,6 +101,8 @@ class ParseProject {
|
|
|
94
101
|
context.target = request.projectPath;
|
|
95
102
|
const projectPath = path.resolve(request.projectPath);
|
|
96
103
|
const exclusions = (_d = request.exclusions) !== null && _d !== void 0 ? _d : javascript_1.DEFAULT_EXCLUSIONS;
|
|
104
|
+
// Use relativeTo if specified, otherwise default to projectPath
|
|
105
|
+
const relativeTo = request.relativeTo ? path.resolve(request.relativeTo) : projectPath;
|
|
97
106
|
// Use ProjectParser for file discovery and Prettier detection
|
|
98
107
|
const projectParser = new javascript_1.ProjectParser(projectPath, { exclusions });
|
|
99
108
|
const discovered = yield projectParser.discoverFiles();
|
|
@@ -104,7 +113,7 @@ class ParseProject {
|
|
|
104
113
|
if (discovered.packageJsonFiles.length > 0) {
|
|
105
114
|
const parser = parser_1.Parsers.createParser("packageJson", {
|
|
106
115
|
ctx,
|
|
107
|
-
relativeTo
|
|
116
|
+
relativeTo
|
|
108
117
|
});
|
|
109
118
|
const generator = parser.parse(...discovered.packageJsonFiles);
|
|
110
119
|
for (const _ of discovered.packageJsonFiles) {
|
|
@@ -121,7 +130,7 @@ class ParseProject {
|
|
|
121
130
|
}
|
|
122
131
|
// Parse JSON lock files
|
|
123
132
|
if (discovered.lockFiles.json.length > 0) {
|
|
124
|
-
const parser = parser_1.Parsers.createParser("json", { ctx, relativeTo
|
|
133
|
+
const parser = parser_1.Parsers.createParser("json", { ctx, relativeTo });
|
|
125
134
|
const generator = parser.parse(...discovered.lockFiles.json);
|
|
126
135
|
for (const _ of discovered.lockFiles.json) {
|
|
127
136
|
const id = (0, uuid_1.randomId)();
|
|
@@ -137,7 +146,7 @@ class ParseProject {
|
|
|
137
146
|
}
|
|
138
147
|
// Parse YAML lock files
|
|
139
148
|
if (discovered.lockFiles.yaml.length > 0) {
|
|
140
|
-
const parser = parser_1.Parsers.createParser("yaml", { ctx, relativeTo
|
|
149
|
+
const parser = parser_1.Parsers.createParser("yaml", { ctx, relativeTo });
|
|
141
150
|
const generator = parser.parse(...discovered.lockFiles.yaml);
|
|
142
151
|
for (const _ of discovered.lockFiles.yaml) {
|
|
143
152
|
const id = (0, uuid_1.randomId)();
|
|
@@ -153,7 +162,7 @@ class ParseProject {
|
|
|
153
162
|
}
|
|
154
163
|
// Parse text lock files (yarn.lock Classic)
|
|
155
164
|
if (discovered.lockFiles.text.length > 0) {
|
|
156
|
-
const parser = parser_1.Parsers.createParser("plainText", { ctx, relativeTo
|
|
165
|
+
const parser = parser_1.Parsers.createParser("plainText", { ctx, relativeTo });
|
|
157
166
|
const generator = parser.parse(...discovered.lockFiles.text);
|
|
158
167
|
for (const _ of discovered.lockFiles.text) {
|
|
159
168
|
const id = (0, uuid_1.randomId)();
|
|
@@ -171,7 +180,7 @@ class ParseProject {
|
|
|
171
180
|
if (discovered.jsFiles.length > 0) {
|
|
172
181
|
const parser = parser_1.Parsers.createParser("javascript", {
|
|
173
182
|
ctx,
|
|
174
|
-
relativeTo
|
|
183
|
+
relativeTo
|
|
175
184
|
});
|
|
176
185
|
// Check if Prettier is available
|
|
177
186
|
const detection = yield prettierLoader.detectPrettier();
|
|
@@ -230,7 +239,7 @@ class ParseProject {
|
|
|
230
239
|
}
|
|
231
240
|
// Parse other YAML files
|
|
232
241
|
if (discovered.yamlFiles.length > 0) {
|
|
233
|
-
const parser = parser_1.Parsers.createParser("yaml", { ctx, relativeTo
|
|
242
|
+
const parser = parser_1.Parsers.createParser("yaml", { ctx, relativeTo });
|
|
234
243
|
const generator = parser.parse(...discovered.yamlFiles);
|
|
235
244
|
for (const _ of discovered.yamlFiles) {
|
|
236
245
|
const id = (0, uuid_1.randomId)();
|
|
@@ -246,7 +255,7 @@ class ParseProject {
|
|
|
246
255
|
}
|
|
247
256
|
// Parse other JSON files
|
|
248
257
|
if (discovered.jsonFiles.length > 0) {
|
|
249
|
-
const parser = parser_1.Parsers.createParser("json", { ctx, relativeTo
|
|
258
|
+
const parser = parser_1.Parsers.createParser("json", { ctx, relativeTo });
|
|
250
259
|
const generator = parser.parse(...discovered.jsonFiles);
|
|
251
260
|
for (const _ of discovered.jsonFiles) {
|
|
252
261
|
const id = (0, uuid_1.randomId)();
|
|
@@ -262,7 +271,7 @@ class ParseProject {
|
|
|
262
271
|
}
|
|
263
272
|
// Parse text config files (.prettierignore, .gitignore, etc.)
|
|
264
273
|
if (discovered.textFiles.length > 0) {
|
|
265
|
-
const parser = parser_1.Parsers.createParser("plainText", { ctx, relativeTo
|
|
274
|
+
const parser = parser_1.Parsers.createParser("plainText", { ctx, relativeTo });
|
|
266
275
|
const generator = parser.parse(...discovered.textFiles);
|
|
267
276
|
for (const _ of discovered.textFiles) {
|
|
268
277
|
const id = (0, uuid_1.randomId)();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-project.js","sourceRoot":"","sources":["../../../src/rpc/request/parse-project.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;GAcG;AACH,yDAA2C;AAC3C,2CAA6B;AAC7B,+CAAiD;AACjD,qCAA0C;AAE1C,yCAAqC;AACrC,uCAAsC;AACtC,iDAAmE;AACnE,2CAAkD;AAUlD;;;;;;;;GAQG;AACH,MAAa,YAAY;IACrB,YACqB,WAAmB,EACnB,UAAqB;
|
|
1
|
+
{"version":3,"file":"parse-project.js","sourceRoot":"","sources":["../../../src/rpc/request/parse-project.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;GAcG;AACH,yDAA2C;AAC3C,2CAA6B;AAC7B,+CAAiD;AACjD,qCAA0C;AAE1C,yCAAqC;AACrC,uCAAsC;AACtC,iDAAmE;AACnE,2CAAkD;AAUlD;;;;;;;;GAQG;AACH,MAAa,YAAY;IACrB,YACqB,WAAmB,EACnB,UAAqB;IACtC;;;;OAIG;IACc,UAAmB;QAPnB,gBAAW,GAAX,WAAW,CAAQ;QACnB,eAAU,GAAV,UAAU,CAAW;QAMrB,eAAU,GAAV,UA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,EAAE,UAAU,YAAA,EAAkB,KAAK,CAAC,EAAE,UAAU,YAAA;IAG7E,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC;CAWhC;AA0BD,wBAAsB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,GAAG,EAAE,gBAAgB,GAAG,OAAO,CAAC,SAAS,CAAC,CAMjH;AAED,MAAM,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,SAAS,GAAG,UAAU,GAAG,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;AAE1I;;;;;;;;;;;;GAYG;AACH,wBAAuB,oBAAoB,CACvC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,UAAU,EAAE,GAAG,aAAa,CAAC,UAAU,CAAC,EAChD,GAAG,EAAE,gBAAgB,EACrB,UAAU,CAAC,EAAE,gBAAgB,GAC9B,cAAc,CAAC,MAAM,EAAE,IAAI,EAAE,SAAS,CAAC,CAqEzC"}
|
package/dist/run.js
CHANGED
|
@@ -178,11 +178,15 @@ function scheduleRunStreaming(recipe, before, ctx, onProgress) {
|
|
|
178
178
|
else {
|
|
179
179
|
// For non-scanning recipes, process files immediately as they come in
|
|
180
180
|
const iterable = Array.isArray(before) ? before : before;
|
|
181
|
+
const knownTotal = Array.isArray(before) ? before.length : -1; // -1 = unknown total
|
|
182
|
+
let processCount = 0;
|
|
181
183
|
try {
|
|
182
184
|
for (var _h = true, iterable_2 = __asyncValues(iterable), iterable_2_1; iterable_2_1 = yield __await(iterable_2.next()), _d = iterable_2_1.done, !_d; _h = true) {
|
|
183
185
|
_f = iterable_2_1.value;
|
|
184
186
|
_h = false;
|
|
185
187
|
const b = _f;
|
|
188
|
+
processCount++;
|
|
189
|
+
onProgress === null || onProgress === void 0 ? void 0 : onProgress('processing', processCount, knownTotal, b.sourcePath);
|
|
186
190
|
const editedB = yield __await(recurseRecipeList(recipe, b, (recipe, b2) => __awaiter(this, void 0, void 0, function* () { return (yield recipe.editor()).visit(b2, ctx, cursor); })));
|
|
187
191
|
// Always yield a result so the caller knows when each file is processed
|
|
188
192
|
yield yield __await(new Result(b, editedB !== b ? editedB : b));
|
package/dist/run.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.js","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkEA,kCAMC;AAiBD,
|
|
1
|
+
{"version":3,"file":"run.js","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkEA,kCAMC;AAiBD,oDA0EC;AAnJD,iCAA8C;AAC9C,+BAAyC;AACzC,mCAAqC;AACrC,qCAAgD;AAMhD,MAAa,MAAM;IACf,YAA4B,MAAmB,EAAkB,KAAkB;QAAvD,WAAM,GAAN,MAAM,CAAa;QAAkB,UAAK,GAAL,KAAK,CAAa;IACnF,CAAC;IAEK,IAAI;;;YACN,OAAO,IAAA,0BAAmB,EACtB,MAAA,MAAA,IAAI,CAAC,MAAM,0CAAE,UAAU,mCAAI,EAAE,EAC7B,MAAA,MAAA,IAAI,CAAC,KAAK,0CAAE,UAAU,mCAAI,EAAE,EAC5B,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,oBAAY,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,EACxD,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,oBAAY,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,EACtD,EAAE,EACF,EAAE,EACF,EAAC,OAAO,EAAE,CAAC,EAAC,CACf,CAAC;QACN,CAAC;KAAA;CACJ;AAfD,wBAeC;AAED,SAAe,iBAAiB,CAAC,MAAc;;QAC3C,IAAI,MAAM,YAAY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,MAAM,EAAE,CAAC,EAAE,CAAO,MAAM,EAAE,EAAE,EAAE,EAAE,gDAAC,OAAA,CAAC,MAAM,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,GAAG,EAAE,MAAM,CAAC,CAAA,GAAA,CAAC,CAAA,CAAC;oBACzH,wEAAwE;oBACxE,oBAAM,IAAI,MAAM,CAAC,CAAC,EAAE,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA,CAAC;gBACrD,CAAC;;;;;;;;;QACL,CAAC;QAED,cAAM,mBAAmB,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA,CAAC;IAC3C,CAAC;CAAA"}
|
package/dist/version.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
8.70.
|
|
1
|
+
8.70.4
|
package/package.json
CHANGED
|
@@ -39,6 +39,11 @@ export interface AddImportOptions {
|
|
|
39
39
|
* Cannot be combined with `member`, `alias`, or `onlyIfReferenced`. */
|
|
40
40
|
sideEffectOnly?: boolean;
|
|
41
41
|
|
|
42
|
+
/** If true, adds a type-only import (e.g., `import type { Foo } from 'module'`).
|
|
43
|
+
* Type-only imports are erased at compile time and do not generate runtime code.
|
|
44
|
+
* Cannot be combined with `sideEffectOnly`. */
|
|
45
|
+
typeOnly?: boolean;
|
|
46
|
+
|
|
42
47
|
/** Optional import style to use. If not specified, auto-detects from file and existing imports */
|
|
43
48
|
style?: ImportStyle;
|
|
44
49
|
}
|
|
@@ -77,7 +82,8 @@ export function maybeAddImport(
|
|
|
77
82
|
v.module === options.module &&
|
|
78
83
|
v.member === options.member &&
|
|
79
84
|
v.alias === options.alias &&
|
|
80
|
-
v.sideEffectOnly === (options.sideEffectOnly ?? false)
|
|
85
|
+
v.sideEffectOnly === (options.sideEffectOnly ?? false) &&
|
|
86
|
+
v.typeOnly === (options.typeOnly ?? false)) {
|
|
81
87
|
return;
|
|
82
88
|
}
|
|
83
89
|
}
|
|
@@ -90,6 +96,7 @@ export class AddImport<P> extends JavaScriptVisitor<P> {
|
|
|
90
96
|
readonly alias?: string;
|
|
91
97
|
readonly onlyIfReferenced: boolean;
|
|
92
98
|
readonly sideEffectOnly: boolean;
|
|
99
|
+
readonly typeOnly: boolean;
|
|
93
100
|
readonly style?: ImportStyle;
|
|
94
101
|
|
|
95
102
|
constructor(options: AddImportOptions) {
|
|
@@ -116,6 +123,9 @@ export class AddImport<P> extends JavaScriptVisitor<P> {
|
|
|
116
123
|
if (options.onlyIfReferenced !== undefined) {
|
|
117
124
|
throw new Error("Cannot combine sideEffectOnly with onlyIfReferenced");
|
|
118
125
|
}
|
|
126
|
+
if (options.typeOnly) {
|
|
127
|
+
throw new Error("Cannot combine sideEffectOnly with typeOnly");
|
|
128
|
+
}
|
|
119
129
|
}
|
|
120
130
|
|
|
121
131
|
this.module = options.module;
|
|
@@ -123,6 +133,7 @@ export class AddImport<P> extends JavaScriptVisitor<P> {
|
|
|
123
133
|
this.alias = options.alias;
|
|
124
134
|
this.onlyIfReferenced = options.onlyIfReferenced ?? true;
|
|
125
135
|
this.sideEffectOnly = options.sideEffectOnly ?? false;
|
|
136
|
+
this.typeOnly = options.typeOnly ?? false;
|
|
126
137
|
this.style = options.style;
|
|
127
138
|
}
|
|
128
139
|
|
|
@@ -444,6 +455,11 @@ export class AddImport<P> extends JavaScriptVisitor<P> {
|
|
|
444
455
|
continue;
|
|
445
456
|
}
|
|
446
457
|
|
|
458
|
+
// Only merge into imports with matching typeOnly - don't mix type and value imports
|
|
459
|
+
if (importClause.typeOnly !== this.typeOnly) {
|
|
460
|
+
continue;
|
|
461
|
+
}
|
|
462
|
+
|
|
447
463
|
// Case 1: Existing import has named bindings - merge into them
|
|
448
464
|
if (importClause.namedBindings) {
|
|
449
465
|
// Only merge into NamedImports, not namespace imports
|
|
@@ -631,6 +647,11 @@ export class AddImport<P> extends JavaScriptVisitor<P> {
|
|
|
631
647
|
return false;
|
|
632
648
|
}
|
|
633
649
|
|
|
650
|
+
// Check if the typeOnly flag matches - type-only and value imports are separate
|
|
651
|
+
if (importClause.typeOnly !== this.typeOnly) {
|
|
652
|
+
return false;
|
|
653
|
+
}
|
|
654
|
+
|
|
634
655
|
// Check if the specific member or default import already exists
|
|
635
656
|
if (this.member === '*') {
|
|
636
657
|
// We're adding a namespace import, check if one exists
|
|
@@ -1053,9 +1074,9 @@ export class AddImport<P> extends JavaScriptVisitor<P> {
|
|
|
1053
1074
|
importClause = {
|
|
1054
1075
|
id: randomId(),
|
|
1055
1076
|
kind: JS.Kind.ImportClause,
|
|
1056
|
-
prefix: emptySpace,
|
|
1077
|
+
prefix: this.typeOnly ? singleSpace : emptySpace,
|
|
1057
1078
|
markers: emptyMarkers,
|
|
1058
|
-
typeOnly:
|
|
1079
|
+
typeOnly: this.typeOnly,
|
|
1059
1080
|
name: undefined,
|
|
1060
1081
|
namedBindings: namespaceBinding
|
|
1061
1082
|
};
|
|
@@ -1076,9 +1097,9 @@ export class AddImport<P> extends JavaScriptVisitor<P> {
|
|
|
1076
1097
|
importClause = {
|
|
1077
1098
|
id: randomId(),
|
|
1078
1099
|
kind: JS.Kind.ImportClause,
|
|
1079
|
-
prefix: emptySpace,
|
|
1100
|
+
prefix: this.typeOnly ? singleSpace : emptySpace,
|
|
1080
1101
|
markers: emptyMarkers,
|
|
1081
|
-
typeOnly:
|
|
1102
|
+
typeOnly: this.typeOnly,
|
|
1082
1103
|
name: rightPadded(defaultName, emptySpace),
|
|
1083
1104
|
namedBindings: undefined
|
|
1084
1105
|
};
|
|
@@ -1110,9 +1131,9 @@ export class AddImport<P> extends JavaScriptVisitor<P> {
|
|
|
1110
1131
|
importClause = {
|
|
1111
1132
|
id: randomId(),
|
|
1112
1133
|
kind: JS.Kind.ImportClause,
|
|
1113
|
-
prefix: emptySpace,
|
|
1134
|
+
prefix: this.typeOnly ? singleSpace : emptySpace,
|
|
1114
1135
|
markers: emptyMarkers,
|
|
1115
|
-
typeOnly:
|
|
1136
|
+
typeOnly: this.typeOnly,
|
|
1116
1137
|
name: undefined,
|
|
1117
1138
|
namedBindings: namedImports
|
|
1118
1139
|
};
|
|
@@ -55,9 +55,14 @@ export async function* npm(relativeTo: string, ...sourceSpecs: SourceSpec<any>[]
|
|
|
55
55
|
);
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
// Write non-JS/TS files to disk FIRST so Prettier config detection can find them
|
|
58
|
+
// Write non-JS/TS/JSON files to disk FIRST so Prettier config detection can find them
|
|
59
|
+
// Exclude all package.json files (root and workspace members) - they're handled separately
|
|
59
60
|
for (const spec of sourceSpecs) {
|
|
60
|
-
|
|
61
|
+
const isPackageJson = spec.path?.endsWith('package.json');
|
|
62
|
+
const isPackageLock = spec.path === 'package-lock.json';
|
|
63
|
+
const isJsTs = spec.kind === JS.Kind.CompilationUnit;
|
|
64
|
+
|
|
65
|
+
if (!isPackageJson && !isPackageLock && !isJsTs) {
|
|
61
66
|
if (spec.before && spec.path) {
|
|
62
67
|
const filePath = path.join(relativeTo, spec.path);
|
|
63
68
|
const dir = path.dirname(filePath);
|
|
@@ -69,22 +74,37 @@ export async function* npm(relativeTo: string, ...sourceSpecs: SourceSpec<any>[]
|
|
|
69
74
|
}
|
|
70
75
|
}
|
|
71
76
|
|
|
77
|
+
// Collect all package.json specs (root and workspace members)
|
|
78
|
+
const allPackageJsonSpecs = sourceSpecs.filter(spec => spec.path?.endsWith('package.json'));
|
|
79
|
+
|
|
72
80
|
// Yield package.json FIRST so its PackageJsonParser is used for all JSON specs
|
|
73
81
|
// (The test framework uses the first spec's parser for all specs of the same kind)
|
|
74
82
|
if (packageJsonSpec) {
|
|
75
|
-
// Parse package.json to check if there are dependencies
|
|
83
|
+
// Parse package.json to check if there are dependencies or workspaces
|
|
76
84
|
const packageJsonContent = JSON.parse(packageJsonSpec.before!);
|
|
77
85
|
const hasDependencies = Object.keys({
|
|
78
86
|
...packageJsonContent.dependencies,
|
|
79
87
|
...packageJsonContent.devDependencies
|
|
80
88
|
}).length > 0;
|
|
89
|
+
const hasWorkspaces = Array.isArray(packageJsonContent.workspaces) && packageJsonContent.workspaces.length > 0;
|
|
81
90
|
|
|
82
91
|
// Get or create cached workspace with node_modules
|
|
83
92
|
// If packageLockSpec is provided, use it for deterministic installs with npm ci
|
|
84
|
-
|
|
93
|
+
// For workspaces, include all workspace member package.json files
|
|
94
|
+
if (hasDependencies || hasWorkspaces) {
|
|
95
|
+
// Build workspace packages map for DependencyWorkspace
|
|
96
|
+
const workspacePackages: Record<string, string> | undefined = hasWorkspaces
|
|
97
|
+
? Object.fromEntries(
|
|
98
|
+
allPackageJsonSpecs
|
|
99
|
+
.filter(spec => spec.path !== 'package.json' && spec.before)
|
|
100
|
+
.map(spec => [spec.path!, spec.before!])
|
|
101
|
+
)
|
|
102
|
+
: undefined;
|
|
103
|
+
|
|
85
104
|
const cachedWorkspace = await DependencyWorkspace.getOrCreateWorkspace({
|
|
86
105
|
packageJsonContent: packageJsonSpec.before!,
|
|
87
|
-
packageLockContent: packageLockSpec?.before ?? undefined
|
|
106
|
+
packageLockContent: packageLockSpec?.before ?? undefined,
|
|
107
|
+
workspacePackages
|
|
88
108
|
});
|
|
89
109
|
|
|
90
110
|
// Symlink node_modules from cached workspace to test directory
|
|
@@ -113,6 +133,26 @@ export async function* npm(relativeTo: string, ...sourceSpecs: SourceSpec<any>[]
|
|
|
113
133
|
};
|
|
114
134
|
}
|
|
115
135
|
|
|
136
|
+
// Write and yield workspace member package.json files with PackageJsonParser
|
|
137
|
+
for (const spec of allPackageJsonSpecs) {
|
|
138
|
+
if (spec.path !== 'package.json') {
|
|
139
|
+
// Write workspace member package.json to disk
|
|
140
|
+
if (spec.before && spec.path) {
|
|
141
|
+
const filePath = path.join(relativeTo, spec.path);
|
|
142
|
+
const dir = path.dirname(filePath);
|
|
143
|
+
if (!fs.existsSync(dir)) {
|
|
144
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
145
|
+
}
|
|
146
|
+
fs.writeFileSync(filePath, spec.before);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
yield {
|
|
150
|
+
...spec,
|
|
151
|
+
parser: () => new PackageJsonParser({relativeTo})
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
116
156
|
// Yield package-lock.json after package.json (so PackageJsonParser is used as the group parser)
|
|
117
157
|
if (packageLockSpec) {
|
|
118
158
|
yield packageLockSpec;
|
|
@@ -150,7 +190,9 @@ export async function* npm(relativeTo: string, ...sourceSpecs: SourceSpec<any>[]
|
|
|
150
190
|
}
|
|
151
191
|
|
|
152
192
|
for (const spec of sourceSpecs) {
|
|
153
|
-
|
|
193
|
+
const isPackageJson = spec.path?.endsWith('package.json');
|
|
194
|
+
const isPackageLock = spec.path === 'package-lock.json';
|
|
195
|
+
if (!isPackageJson && !isPackageLock) {
|
|
154
196
|
if (spec.kind === JS.Kind.CompilationUnit) {
|
|
155
197
|
// For JS/TS files, use a parser that adds style marker if available
|
|
156
198
|
// spec.path may be undefined, so generate a reasonable path from the extension
|