@ts-dev-tools/core 1.12.1 → 1.12.2
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/bin.js +26 -76
- package/dist/constants.js +2 -2
- package/dist/eslint-plugin-ts-dev-tools/index.js +18 -30
- package/dist/install/command.js +30 -80
- package/dist/install/migrations/20201024173398-init.js +89 -141
- package/dist/install/migrations/20220617100200-prettier-cache.js +9 -49
- package/dist/install/migrations/20240329200200-eslint-ignore.js +9 -49
- package/dist/install/migrations/20240412185500-eslint-config.js +16 -53
- package/dist/install/migrations/20240617094000-config-nx-scopes.js +22 -67
- package/dist/install/migrations/20250623095500-add-prettier-oxc.js +9 -49
- package/dist/install/migrations/20250623095600-remove-prettier-oxc.js +15 -55
- package/dist/services/CmdService.js +17 -21
- package/dist/services/CorePackageService.js +8 -11
- package/dist/services/DuplicateDependenciesService.js +28 -33
- package/dist/services/FileService.js +11 -14
- package/dist/services/GitService.js +36 -83
- package/dist/services/MigrationsService.js +52 -121
- package/dist/services/PackageJson.js +47 -57
- package/dist/services/PackageJsonMerge.js +17 -21
- package/dist/services/PackageManagerService.js +25 -80
- package/dist/services/PeerDependenciesService.js +92 -157
- package/dist/services/PluginService.js +32 -39
- package/dist/services/SymlinkDependenciesService.js +52 -133
- package/dist/services/package-manager/AbstractPackageManagerAdapter.js +84 -138
- package/dist/services/package-manager/NpmPackageManagerAdapter.js +58 -158
- package/dist/services/package-manager/YarnPackageManagerAdapter.js +122 -235
- package/dist/tests/cli.js +12 -57
- package/dist/tests/console.js +5 -6
- package/dist/tests/file-system.js +23 -92
- package/dist/tests/test-cache.js +5 -5
- package/dist/tests/test-packages.js +33 -95
- package/dist/tests/test-project-monorepo.js +22 -85
- package/dist/tests/test-project.js +49 -127
- package/package.json +12 -12
|
@@ -1,199 +1,90 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
28
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
-
function step(op) {
|
|
31
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
33
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
34
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
-
switch (op[0]) {
|
|
36
|
-
case 0: case 1: t = op; break;
|
|
37
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
-
default:
|
|
41
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
-
if (t[2]) _.ops.pop();
|
|
46
|
-
_.trys.pop(); continue;
|
|
47
|
-
}
|
|
48
|
-
op = body.call(thisArg, _);
|
|
49
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
3
|
exports.YarnPackageManagerAdapter = void 0;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const AbstractPackageManagerAdapter_1 = require("./AbstractPackageManagerAdapter");
|
|
6
|
+
const PackageManagerType_1 = require("./PackageManagerType");
|
|
7
|
+
class YarnPackageManagerAdapter extends AbstractPackageManagerAdapter_1.AbstractPackageManagerAdapter {
|
|
8
|
+
async addDevPackage(packageName, dirPath) {
|
|
9
|
+
const isMonorepo = await this.isMonorepo(dirPath);
|
|
10
|
+
const { major } = await this.getVersion(PackageManagerType_1.PackageManagerType.yarn, dirPath);
|
|
11
|
+
const args = ["yarn", "add", "--dev"];
|
|
12
|
+
if (isMonorepo) {
|
|
13
|
+
args.push(major >= 2 ? "-W" : "--ignore-workspace-root-check");
|
|
14
|
+
}
|
|
15
|
+
args.push(packageName);
|
|
16
|
+
try {
|
|
17
|
+
await this.execCommand(args, dirPath, true);
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
if (isMonorepo && typeof error === "string" && error.includes("Unsupported option name")) {
|
|
21
|
+
const retryArgs = args
|
|
22
|
+
.filter((arg) => arg !== "--ignore-workspace-root-check" && arg !== "-W")
|
|
23
|
+
.concat(major >= 2 ? "--ignore-workspace-root-check" : "-W");
|
|
24
|
+
await this.execCommand(retryArgs, dirPath, true);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
throw error;
|
|
28
|
+
}
|
|
62
29
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
return [4 /*yield*/, this.execCommand(args, dirPath, true)];
|
|
83
|
-
case 4:
|
|
84
|
-
_a.sent();
|
|
85
|
-
return [3 /*break*/, 8];
|
|
86
|
-
case 5:
|
|
87
|
-
error_1 = _a.sent();
|
|
88
|
-
if (!(isMonorepo && typeof error_1 === "string" && error_1.includes("Unsupported option name"))) return [3 /*break*/, 7];
|
|
89
|
-
retryArgs = args
|
|
90
|
-
.filter(function (arg) { return arg !== "--ignore-workspace-root-check" && arg !== "-W"; })
|
|
91
|
-
.concat(major >= 2 ? "--ignore-workspace-root-check" : "-W");
|
|
92
|
-
return [4 /*yield*/, this.execCommand(retryArgs, dirPath, true)];
|
|
93
|
-
case 6:
|
|
94
|
-
_a.sent();
|
|
95
|
-
return [2 /*return*/];
|
|
96
|
-
case 7: throw error_1;
|
|
97
|
-
case 8: return [2 /*return*/];
|
|
30
|
+
async isMonorepo(dirPath) {
|
|
31
|
+
const { major } = await this.getVersion(PackageManagerType_1.PackageManagerType.yarn, dirPath);
|
|
32
|
+
const primary = major >= 2 ? "list" : "info";
|
|
33
|
+
const fallback = primary === "list" ? "info" : "list";
|
|
34
|
+
const yarnCommands = [
|
|
35
|
+
["yarn", "workspaces", primary, "--json"],
|
|
36
|
+
["yarn", "workspaces", fallback, "--json"],
|
|
37
|
+
];
|
|
38
|
+
let lastOutput;
|
|
39
|
+
let hasRecognizedOutput = false;
|
|
40
|
+
let hasSuccessfulCommand = false;
|
|
41
|
+
for (const args of yarnCommands) {
|
|
42
|
+
try {
|
|
43
|
+
const output = await this.execCommand(args, dirPath, true);
|
|
44
|
+
hasSuccessfulCommand = true;
|
|
45
|
+
lastOutput = output;
|
|
46
|
+
const analysis = this.analyzeYarnWorkspacesOutput(output);
|
|
47
|
+
if (analysis.hasEntries) {
|
|
48
|
+
return true;
|
|
98
49
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
};
|
|
102
|
-
YarnPackageManagerAdapter.prototype.isMonorepo = function (dirPath) {
|
|
103
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
104
|
-
var major, primary, fallback, yarnCommands, lastOutput, hasRecognizedOutput, hasSuccessfulCommand, _i, yarnCommands_1, args, output, analysis, _a;
|
|
105
|
-
return __generator(this, function (_b) {
|
|
106
|
-
switch (_b.label) {
|
|
107
|
-
case 0: return [4 /*yield*/, this.getVersion(PackageManagerType_1.PackageManagerType.yarn, dirPath)];
|
|
108
|
-
case 1:
|
|
109
|
-
major = (_b.sent()).major;
|
|
110
|
-
primary = major >= 2 ? "list" : "info";
|
|
111
|
-
fallback = primary === "list" ? "info" : "list";
|
|
112
|
-
yarnCommands = [
|
|
113
|
-
["yarn", "workspaces", primary, "--json"],
|
|
114
|
-
["yarn", "workspaces", fallback, "--json"],
|
|
115
|
-
];
|
|
116
|
-
hasRecognizedOutput = false;
|
|
117
|
-
hasSuccessfulCommand = false;
|
|
118
|
-
_i = 0, yarnCommands_1 = yarnCommands;
|
|
119
|
-
_b.label = 2;
|
|
120
|
-
case 2:
|
|
121
|
-
if (!(_i < yarnCommands_1.length)) return [3 /*break*/, 7];
|
|
122
|
-
args = yarnCommands_1[_i];
|
|
123
|
-
_b.label = 3;
|
|
124
|
-
case 3:
|
|
125
|
-
_b.trys.push([3, 5, , 6]);
|
|
126
|
-
return [4 /*yield*/, this.execCommand(args, dirPath, true)];
|
|
127
|
-
case 4:
|
|
128
|
-
output = _b.sent();
|
|
129
|
-
hasSuccessfulCommand = true;
|
|
130
|
-
lastOutput = output;
|
|
131
|
-
analysis = this.analyzeYarnWorkspacesOutput(output);
|
|
132
|
-
if (analysis.hasEntries) {
|
|
133
|
-
return [2 /*return*/, true];
|
|
134
|
-
}
|
|
135
|
-
if (analysis.hasRecognizedData) {
|
|
136
|
-
hasRecognizedOutput = true;
|
|
137
|
-
}
|
|
138
|
-
return [3 /*break*/, 6];
|
|
139
|
-
case 5:
|
|
140
|
-
_a = _b.sent();
|
|
141
|
-
return [3 /*break*/, 6];
|
|
142
|
-
case 6:
|
|
143
|
-
_i++;
|
|
144
|
-
return [3 /*break*/, 2];
|
|
145
|
-
case 7:
|
|
146
|
-
if (hasSuccessfulCommand && !hasRecognizedOutput) {
|
|
147
|
-
throw new Error("Unexpected output from \"yarn workspaces\": ".concat(lastOutput !== null && lastOutput !== void 0 ? lastOutput : "<empty>"));
|
|
148
|
-
}
|
|
149
|
-
return [2 /*return*/, false];
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
});
|
|
153
|
-
};
|
|
154
|
-
YarnPackageManagerAdapter.prototype.isPackageInstalled = function (packageName, dirPath) {
|
|
155
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
156
|
-
var output, _a, output, _b;
|
|
157
|
-
return __generator(this, function (_c) {
|
|
158
|
-
switch (_c.label) {
|
|
159
|
-
case 0:
|
|
160
|
-
_c.trys.push([0, 2, , 3]);
|
|
161
|
-
return [4 /*yield*/, this.execCommand(["yarn", "list", "--depth=1", "--json", "--pattern", packageName], dirPath, true)];
|
|
162
|
-
case 1:
|
|
163
|
-
output = _c.sent();
|
|
164
|
-
if (this.yarnListOutputHasPackage(output, packageName)) {
|
|
165
|
-
return [2 /*return*/, true];
|
|
166
|
-
}
|
|
167
|
-
return [3 /*break*/, 3];
|
|
168
|
-
case 2:
|
|
169
|
-
_a = _c.sent();
|
|
170
|
-
return [3 /*break*/, 3];
|
|
171
|
-
case 3:
|
|
172
|
-
_c.trys.push([3, 5, , 6]);
|
|
173
|
-
return [4 /*yield*/, this.execCommand(["yarn", "why", "--json", packageName], dirPath, true)];
|
|
174
|
-
case 4:
|
|
175
|
-
output = _c.sent();
|
|
176
|
-
return [2 /*return*/, this.yarnListOutputHasPackage(output, packageName)];
|
|
177
|
-
case 5:
|
|
178
|
-
_b = _c.sent();
|
|
179
|
-
return [2 /*return*/, false];
|
|
180
|
-
case 6: return [2 /*return*/];
|
|
50
|
+
if (analysis.hasRecognizedData) {
|
|
51
|
+
hasRecognizedOutput = true;
|
|
181
52
|
}
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
// Try next command
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
if (hasSuccessfulCommand && !hasRecognizedOutput) {
|
|
59
|
+
throw new Error(`Unexpected output from "yarn workspaces": ${lastOutput ?? "<empty>"}`);
|
|
60
|
+
}
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
async isPackageInstalled(packageName, dirPath) {
|
|
64
|
+
try {
|
|
65
|
+
const output = await this.execCommand(["yarn", "list", "--depth=1", "--json", "--pattern", packageName], dirPath, true);
|
|
66
|
+
if (this.yarnListOutputHasPackage(output, packageName)) {
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
// Fallback for Yarn versions that don't support `yarn list`
|
|
72
|
+
}
|
|
73
|
+
try {
|
|
74
|
+
const output = await this.execCommand(["yarn", "why", "--json", packageName], dirPath, true);
|
|
75
|
+
return this.yarnListOutputHasPackage(output, packageName);
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
async getNodeModulesPath(dirPath) {
|
|
82
|
+
return (0, path_1.join)(dirPath, "node_modules");
|
|
83
|
+
}
|
|
84
|
+
analyzeYarnWorkspacesOutput(output) {
|
|
85
|
+
let entries = this.parseJsonLines(output);
|
|
195
86
|
if (entries.length === 0) {
|
|
196
|
-
|
|
87
|
+
const jsonBlock = this.extractJsonBlock(output);
|
|
197
88
|
if (jsonBlock && typeof jsonBlock === "object") {
|
|
198
89
|
entries = [jsonBlock];
|
|
199
90
|
}
|
|
@@ -201,26 +92,25 @@ var YarnPackageManagerAdapter = /** @class */ (function (_super) {
|
|
|
201
92
|
if (entries.length === 0) {
|
|
202
93
|
return { hasEntries: false, hasRecognizedData: false };
|
|
203
94
|
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
for (
|
|
207
|
-
var entry = entries_1[_i];
|
|
95
|
+
let workspaceListCount = 0;
|
|
96
|
+
let hasRecognizedData = false;
|
|
97
|
+
for (const entry of entries) {
|
|
208
98
|
if (!entry || typeof entry !== "object") {
|
|
209
99
|
continue;
|
|
210
100
|
}
|
|
211
|
-
|
|
101
|
+
const type = entry.type;
|
|
212
102
|
if (type === "error" || type === "warning") {
|
|
213
103
|
continue;
|
|
214
104
|
}
|
|
215
|
-
|
|
216
|
-
|
|
105
|
+
const data = entry.data ?? entry;
|
|
106
|
+
const parsedData = this.parseMaybeJsonString(data);
|
|
217
107
|
if (parsedData && typeof parsedData === "object") {
|
|
218
108
|
hasRecognizedData = true;
|
|
219
109
|
if (this.hasWorkspaceMap(parsedData)) {
|
|
220
|
-
return { hasEntries: true, hasRecognizedData
|
|
110
|
+
return { hasEntries: true, hasRecognizedData };
|
|
221
111
|
}
|
|
222
112
|
if (this.isWorkspaceInfoMap(parsedData)) {
|
|
223
|
-
return { hasEntries: true, hasRecognizedData
|
|
113
|
+
return { hasEntries: true, hasRecognizedData };
|
|
224
114
|
}
|
|
225
115
|
if (this.isWorkspaceListEntry(parsedData)) {
|
|
226
116
|
workspaceListCount += 1;
|
|
@@ -228,94 +118,91 @@ var YarnPackageManagerAdapter = /** @class */ (function (_super) {
|
|
|
228
118
|
}
|
|
229
119
|
}
|
|
230
120
|
if (workspaceListCount > 0) {
|
|
231
|
-
return { hasEntries: true, hasRecognizedData
|
|
121
|
+
return { hasEntries: true, hasRecognizedData };
|
|
232
122
|
}
|
|
233
|
-
return { hasEntries: false, hasRecognizedData
|
|
234
|
-
}
|
|
235
|
-
|
|
123
|
+
return { hasEntries: false, hasRecognizedData };
|
|
124
|
+
}
|
|
125
|
+
parseMaybeJsonString(value) {
|
|
236
126
|
if (typeof value !== "string") {
|
|
237
127
|
return value;
|
|
238
128
|
}
|
|
239
129
|
try {
|
|
240
130
|
return JSON.parse(value);
|
|
241
131
|
}
|
|
242
|
-
catch
|
|
132
|
+
catch {
|
|
243
133
|
return undefined;
|
|
244
134
|
}
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
135
|
+
}
|
|
136
|
+
extractJsonBlock(output) {
|
|
137
|
+
const start = output.indexOf("{");
|
|
138
|
+
const end = output.lastIndexOf("}");
|
|
249
139
|
if (start === -1 || end === -1 || end <= start) {
|
|
250
140
|
return undefined;
|
|
251
141
|
}
|
|
252
|
-
|
|
142
|
+
const candidate = output.slice(start, end + 1).trim();
|
|
253
143
|
if (candidate.length === 0) {
|
|
254
144
|
return undefined;
|
|
255
145
|
}
|
|
256
146
|
try {
|
|
257
147
|
return JSON.parse(candidate);
|
|
258
148
|
}
|
|
259
|
-
catch
|
|
149
|
+
catch {
|
|
260
150
|
return undefined;
|
|
261
151
|
}
|
|
262
|
-
}
|
|
263
|
-
|
|
152
|
+
}
|
|
153
|
+
hasWorkspaceMap(value) {
|
|
264
154
|
if (!value || typeof value !== "object") {
|
|
265
155
|
return false;
|
|
266
156
|
}
|
|
267
|
-
|
|
157
|
+
const workspaces = value.workspaces;
|
|
268
158
|
return !!workspaces && Object.keys(workspaces).length > 0;
|
|
269
|
-
}
|
|
270
|
-
|
|
159
|
+
}
|
|
160
|
+
isWorkspaceListEntry(value) {
|
|
271
161
|
if (!value || typeof value !== "object") {
|
|
272
162
|
return false;
|
|
273
163
|
}
|
|
274
|
-
|
|
164
|
+
const entry = value;
|
|
275
165
|
return typeof entry.name === "string" && typeof entry.location === "string" && entry.location !== ".";
|
|
276
|
-
}
|
|
277
|
-
|
|
166
|
+
}
|
|
167
|
+
isWorkspaceInfoMap(value) {
|
|
278
168
|
if (!value || typeof value !== "object") {
|
|
279
169
|
return false;
|
|
280
170
|
}
|
|
281
|
-
|
|
171
|
+
const entries = Object.values(value);
|
|
282
172
|
if (entries.length === 0) {
|
|
283
173
|
return false;
|
|
284
174
|
}
|
|
285
|
-
return entries.some(
|
|
175
|
+
return entries.some((entry) => {
|
|
286
176
|
if (!entry || typeof entry !== "object") {
|
|
287
177
|
return false;
|
|
288
178
|
}
|
|
289
|
-
|
|
179
|
+
const location = entry.location;
|
|
290
180
|
return typeof location === "string" && location.length > 0 && location !== ".";
|
|
291
181
|
});
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
for (var _i = 0, entries_2 = entries; _i < entries_2.length; _i++) {
|
|
297
|
-
var entry = entries_2[_i];
|
|
182
|
+
}
|
|
183
|
+
yarnListOutputHasPackage(output, packageName) {
|
|
184
|
+
const entries = this.parseJsonLines(output);
|
|
185
|
+
for (const entry of entries) {
|
|
298
186
|
if (!entry || typeof entry !== "object") {
|
|
299
187
|
continue;
|
|
300
188
|
}
|
|
301
|
-
|
|
302
|
-
|
|
189
|
+
const data = entry.data;
|
|
190
|
+
const trees = data?.trees ?? entry.trees;
|
|
303
191
|
if (!trees) {
|
|
304
|
-
|
|
192
|
+
const children = entry.children;
|
|
305
193
|
if (children) {
|
|
306
|
-
|
|
307
|
-
if (childKeys.some(
|
|
194
|
+
const childKeys = Object.keys(children);
|
|
195
|
+
if (childKeys.some((key) => key.startsWith(packageName + "@"))) {
|
|
308
196
|
return true;
|
|
309
197
|
}
|
|
310
198
|
}
|
|
311
199
|
continue;
|
|
312
200
|
}
|
|
313
|
-
if (trees.some(
|
|
201
|
+
if (trees.some((tree) => tree.name.startsWith(packageName + "@"))) {
|
|
314
202
|
return true;
|
|
315
203
|
}
|
|
316
204
|
}
|
|
317
205
|
return false;
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
}(AbstractPackageManagerAdapter_1.AbstractPackageManagerAdapter));
|
|
206
|
+
}
|
|
207
|
+
}
|
|
321
208
|
exports.YarnPackageManagerAdapter = YarnPackageManagerAdapter;
|
package/dist/tests/cli.js
CHANGED
|
@@ -1,70 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
3
|
exports.exec = exec;
|
|
40
4
|
exports.safeExec = safeExec;
|
|
41
|
-
|
|
5
|
+
const child_process_1 = require("child_process");
|
|
42
6
|
function exec(cwd, cmd) {
|
|
43
|
-
return new Promise(
|
|
44
|
-
(0, child_process_1.exec)(cmd, { cwd
|
|
7
|
+
return new Promise((resolve) => {
|
|
8
|
+
(0, child_process_1.exec)(cmd, { cwd }, (error, stdout, stderr) => {
|
|
45
9
|
resolve({
|
|
46
10
|
code: error && error.code ? error.code : 0,
|
|
47
|
-
error
|
|
11
|
+
error,
|
|
48
12
|
stdout: stdout.trim(),
|
|
49
|
-
stderr
|
|
13
|
+
stderr,
|
|
50
14
|
});
|
|
51
15
|
});
|
|
52
16
|
});
|
|
53
17
|
}
|
|
54
|
-
function safeExec(cwd, cmd) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
_a = _b.sent(), code = _a.code, stderr = _a.stderr, stdout = _a.stdout;
|
|
62
|
-
if (code !== 0) {
|
|
63
|
-
error = [stderr, stdout].filter(function (error) { return !!error; }).join("\n");
|
|
64
|
-
throw new Error("An error occured while executing command \"".concat(cmd, "\": ").concat(error));
|
|
65
|
-
}
|
|
66
|
-
return [2 /*return*/, stdout];
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
});
|
|
18
|
+
async function safeExec(cwd, cmd) {
|
|
19
|
+
const { code, stderr, stdout } = await exec(cwd, cmd);
|
|
20
|
+
if (code !== 0) {
|
|
21
|
+
const error = [stderr, stdout].filter((error) => !!error).join("\n");
|
|
22
|
+
throw new Error(`An error occured while executing command "${cmd}": ${error}`);
|
|
23
|
+
}
|
|
24
|
+
return stdout;
|
|
70
25
|
}
|
package/dist/tests/console.js
CHANGED
|
@@ -4,7 +4,7 @@ exports.mockConsoleInfo = mockConsoleInfo;
|
|
|
4
4
|
exports.resetMockedConsoleInfo = resetMockedConsoleInfo;
|
|
5
5
|
exports.getConsoleInfoContent = getConsoleInfoContent;
|
|
6
6
|
exports.stripAnsi = stripAnsi;
|
|
7
|
-
|
|
7
|
+
const info = console.info;
|
|
8
8
|
function mockConsoleInfo() {
|
|
9
9
|
console.info = jest.fn();
|
|
10
10
|
}
|
|
@@ -12,15 +12,14 @@ function resetMockedConsoleInfo() {
|
|
|
12
12
|
console.info = info;
|
|
13
13
|
}
|
|
14
14
|
function getConsoleInfoContent() {
|
|
15
|
-
|
|
16
|
-
var calls = (_a = console.info) === null || _a === void 0 ? void 0 : _a.mock.calls;
|
|
15
|
+
const calls = console.info?.mock.calls;
|
|
17
16
|
return calls.flat().join("\n");
|
|
18
17
|
}
|
|
19
18
|
function stripAnsi(input) {
|
|
20
19
|
// Valid string terminator sequences are BEL, ESC\, and 0x9c
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
const ST = "(?:\\u0007|\\u001B\\u005C|\\u009C)";
|
|
21
|
+
const pattern = [
|
|
22
|
+
`[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?${ST})`,
|
|
24
23
|
"(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))",
|
|
25
24
|
].join("|");
|
|
26
25
|
return input.replace(new RegExp(pattern, "g"), "");
|