@ts-dev-tools/core 1.10.0 → 1.11.0

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.
@@ -43,6 +43,7 @@ var constants_1 = require("../constants");
43
43
  var DuplicateDependenciesService_1 = require("../services/DuplicateDependenciesService");
44
44
  var MigrationsService_1 = require("../services/MigrationsService");
45
45
  var PackageJson_1 = require("../services/PackageJson");
46
+ var PeerDependenciesService_1 = require("../services/PeerDependenciesService");
46
47
  var SymlinkDependenciesService_1 = require("../services/SymlinkDependenciesService");
47
48
  function install(_a) {
48
49
  return __awaiter(this, arguments, void 0, function (_b) {
@@ -70,6 +71,9 @@ function install(_a) {
70
71
  _d.sent();
71
72
  return [4 /*yield*/, SymlinkDependenciesService_1.SymlinkDependenciesService.executeSymlinking(absoluteProjectDir)];
72
73
  case 2:
74
+ _d.sent();
75
+ return [4 /*yield*/, PeerDependenciesService_1.PeerDependenciesService.executeResolution(absoluteProjectDir)];
76
+ case 3:
73
77
  _d.sent();
74
78
  DuplicateDependenciesService_1.DuplicateDependenciesService.executeDeduplication(absoluteProjectDir);
75
79
  console.info("Installation done!");
@@ -0,0 +1,14 @@
1
+ export declare class PeerDependenciesService {
2
+ static DEPENDENCIES_FOLDER: string;
3
+ static executeResolution(absoluteProjectDir: string): Promise<void>;
4
+ private static getPackagePeerDependencies;
5
+ private static getPackagesToInspect;
6
+ private static resolveDependencyPath;
7
+ private static resolvePeerSourcePath;
8
+ private static resolveFromNestedNodeModules;
9
+ private static getTopLevelPackageDirs;
10
+ private static resolvePackagePathFrom;
11
+ private static canResolveFromConsumerRoot;
12
+ private static symlinkMissingPeers;
13
+ private static symlinkPeer;
14
+ }
@@ -0,0 +1,234 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
+ return new (P || (P = Promise))(function (resolve, reject) {
16
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
20
+ });
21
+ };
22
+ var __generator = (this && this.__generator) || function (thisArg, body) {
23
+ 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);
24
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
+ function verb(n) { return function (v) { return step([n, v]); }; }
26
+ function step(op) {
27
+ if (f) throw new TypeError("Generator is already executing.");
28
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
+ 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;
30
+ if (y = 0, t) op = [op[0] & 2, t.value];
31
+ switch (op[0]) {
32
+ case 0: case 1: t = op; break;
33
+ case 4: _.label++; return { value: op[1], done: false };
34
+ case 5: _.label++; y = op[1]; op = [0]; continue;
35
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
+ default:
37
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
+ if (t[2]) _.ops.pop();
42
+ _.trys.pop(); continue;
43
+ }
44
+ op = body.call(thisArg, _);
45
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
+ }
48
+ };
49
+ Object.defineProperty(exports, "__esModule", { value: true });
50
+ exports.PeerDependenciesService = void 0;
51
+ var fs_1 = require("fs");
52
+ var path_1 = require("path");
53
+ var PackageJson_1 = require("./PackageJson");
54
+ var PluginService_1 = require("./PluginService");
55
+ var PeerDependenciesService = /** @class */ (function () {
56
+ function PeerDependenciesService() {
57
+ }
58
+ PeerDependenciesService.executeResolution = function (absoluteProjectDir) {
59
+ return __awaiter(this, void 0, void 0, function () {
60
+ var installedPlugins, missingPeers, packagesToInspect, _i, packagesToInspect_1, packageToInspect, peers, _a, peers_1, peer, isResolvable, sourcePath;
61
+ return __generator(this, function (_b) {
62
+ console.info("Resolving peer dependencies...");
63
+ installedPlugins = PluginService_1.PluginService.getInstalledPlugins(absoluteProjectDir);
64
+ missingPeers = [];
65
+ packagesToInspect = PeerDependenciesService.getPackagesToInspect(absoluteProjectDir, installedPlugins);
66
+ for (_i = 0, packagesToInspect_1 = packagesToInspect; _i < packagesToInspect_1.length; _i++) {
67
+ packageToInspect = packagesToInspect_1[_i];
68
+ peers = PeerDependenciesService.getPackagePeerDependencies(packageToInspect.path);
69
+ for (_a = 0, peers_1 = peers; _a < peers_1.length; _a++) {
70
+ peer = peers_1[_a];
71
+ isResolvable = PeerDependenciesService.canResolveFromConsumerRoot(absoluteProjectDir, peer.name);
72
+ if (!isResolvable) {
73
+ sourcePath = PeerDependenciesService.resolvePeerSourcePath(absoluteProjectDir, packageToInspect.path, peer.name);
74
+ if (peer.optional && !(0, fs_1.existsSync)(sourcePath)) {
75
+ continue;
76
+ }
77
+ missingPeers.push(__assign(__assign({}, peer), { requiredBy: packageToInspect.name, sourcePath: sourcePath }));
78
+ }
79
+ }
80
+ }
81
+ if (missingPeers.length > 0) {
82
+ PeerDependenciesService.symlinkMissingPeers(absoluteProjectDir, missingPeers);
83
+ }
84
+ console.info("Resolving peer dependencies done!");
85
+ return [2 /*return*/];
86
+ });
87
+ });
88
+ };
89
+ PeerDependenciesService.getPackagePeerDependencies = function (packageDirPath) {
90
+ var packageJson = PackageJson_1.PackageJson.fromDirPath(packageDirPath);
91
+ var content = packageJson.getContent();
92
+ var peerDependencies = content.peerDependencies || {};
93
+ var peerDependenciesMeta = content.peerDependenciesMeta || {};
94
+ return Object.keys(peerDependencies).map(function (name) {
95
+ var _a;
96
+ return ({
97
+ name: name,
98
+ optional: ((_a = peerDependenciesMeta[name]) === null || _a === void 0 ? void 0 : _a.optional) || false,
99
+ });
100
+ });
101
+ };
102
+ PeerDependenciesService.getPackagesToInspect = function (absoluteProjectDir, installedPlugins) {
103
+ var packages = new Map();
104
+ for (var _i = 0, installedPlugins_1 = installedPlugins; _i < installedPlugins_1.length; _i++) {
105
+ var plugin = installedPlugins_1[_i];
106
+ packages.set(plugin.fullname, {
107
+ name: plugin.fullname,
108
+ path: plugin.path,
109
+ });
110
+ var pluginDependencies = PackageJson_1.PackageJson.fromDirPath(plugin.path).getDependenciesPackageNames();
111
+ for (var _a = 0, pluginDependencies_1 = pluginDependencies; _a < pluginDependencies_1.length; _a++) {
112
+ var dependencyName = pluginDependencies_1[_a];
113
+ var dependencyPath = PeerDependenciesService.resolveDependencyPath(absoluteProjectDir, plugin.path, dependencyName);
114
+ if (!dependencyPath) {
115
+ continue;
116
+ }
117
+ if (!packages.has(dependencyName)) {
118
+ packages.set(dependencyName, {
119
+ name: dependencyName,
120
+ path: dependencyPath,
121
+ });
122
+ }
123
+ }
124
+ }
125
+ return Array.from(packages.values());
126
+ };
127
+ PeerDependenciesService.resolveDependencyPath = function (absoluteProjectDir, pluginPath, dependencyName) {
128
+ var candidatePaths = [
129
+ (0, path_1.join)(absoluteProjectDir, PeerDependenciesService.DEPENDENCIES_FOLDER, dependencyName),
130
+ (0, path_1.join)(pluginPath, PeerDependenciesService.DEPENDENCIES_FOLDER, dependencyName),
131
+ ];
132
+ for (var _i = 0, candidatePaths_1 = candidatePaths; _i < candidatePaths_1.length; _i++) {
133
+ var candidatePath = candidatePaths_1[_i];
134
+ if ((0, fs_1.existsSync)((0, path_1.join)(candidatePath, "package.json"))) {
135
+ return candidatePath;
136
+ }
137
+ }
138
+ return undefined;
139
+ };
140
+ PeerDependenciesService.resolvePeerSourcePath = function (absoluteProjectDir, requiredByPath, peerName) {
141
+ var projectNodeModulesPath = (0, path_1.join)(absoluteProjectDir, PeerDependenciesService.DEPENDENCIES_FOLDER);
142
+ var directResolution = PeerDependenciesService.resolvePackagePathFrom(requiredByPath, peerName);
143
+ if (directResolution) {
144
+ return directResolution;
145
+ }
146
+ var projectResolution = PeerDependenciesService.resolvePackagePathFrom(projectNodeModulesPath, peerName);
147
+ if (projectResolution) {
148
+ return projectResolution;
149
+ }
150
+ var nestedResolution = PeerDependenciesService.resolveFromNestedNodeModules(projectNodeModulesPath, peerName);
151
+ if (nestedResolution) {
152
+ return nestedResolution;
153
+ }
154
+ return (0, path_1.join)(projectNodeModulesPath, peerName);
155
+ };
156
+ PeerDependenciesService.resolveFromNestedNodeModules = function (projectNodeModulesPath, peerName) {
157
+ var packageDirs = PeerDependenciesService.getTopLevelPackageDirs(projectNodeModulesPath);
158
+ for (var _i = 0, packageDirs_1 = packageDirs; _i < packageDirs_1.length; _i++) {
159
+ var packageDir = packageDirs_1[_i];
160
+ var resolvedPath = PeerDependenciesService.resolvePackagePathFrom(packageDir, peerName);
161
+ if (resolvedPath) {
162
+ return resolvedPath;
163
+ }
164
+ }
165
+ return undefined;
166
+ };
167
+ PeerDependenciesService.getTopLevelPackageDirs = function (nodeModulesPath) {
168
+ if (!(0, fs_1.existsSync)(nodeModulesPath)) {
169
+ return [];
170
+ }
171
+ var packageDirs = [];
172
+ var entries = (0, fs_1.readdirSync)(nodeModulesPath);
173
+ for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
174
+ var entry = entries_1[_i];
175
+ var entryPath = (0, path_1.join)(nodeModulesPath, entry);
176
+ if (!entry.startsWith("@")) {
177
+ packageDirs.push(entryPath);
178
+ continue;
179
+ }
180
+ var scopedEntries = (0, fs_1.readdirSync)(entryPath);
181
+ for (var _a = 0, scopedEntries_1 = scopedEntries; _a < scopedEntries_1.length; _a++) {
182
+ var scopedEntry = scopedEntries_1[_a];
183
+ packageDirs.push((0, path_1.join)(entryPath, scopedEntry));
184
+ }
185
+ }
186
+ return packageDirs;
187
+ };
188
+ PeerDependenciesService.resolvePackagePathFrom = function (fromPath, packageName) {
189
+ try {
190
+ var packageJsonPath = require.resolve((0, path_1.join)(packageName, "package.json"), {
191
+ paths: [fromPath],
192
+ });
193
+ return (0, path_1.dirname)(packageJsonPath);
194
+ }
195
+ catch (_a) {
196
+ return undefined;
197
+ }
198
+ };
199
+ PeerDependenciesService.canResolveFromConsumerRoot = function (absoluteProjectDir, packageName) {
200
+ var packagePath = (0, path_1.join)(absoluteProjectDir, PeerDependenciesService.DEPENDENCIES_FOLDER, packageName);
201
+ return (0, fs_1.existsSync)(packagePath);
202
+ };
203
+ PeerDependenciesService.symlinkMissingPeers = function (absoluteProjectDir, missingPeers) {
204
+ var projectDependencyPath = (0, path_1.join)(absoluteProjectDir, PeerDependenciesService.DEPENDENCIES_FOLDER);
205
+ var uniqueMissingPeers = new Map();
206
+ for (var _i = 0, missingPeers_1 = missingPeers; _i < missingPeers_1.length; _i++) {
207
+ var peer = missingPeers_1[_i];
208
+ if (!uniqueMissingPeers.has(peer.name)) {
209
+ uniqueMissingPeers.set(peer.name, peer);
210
+ }
211
+ }
212
+ for (var _a = 0, _b = Array.from(uniqueMissingPeers.values()); _a < _b.length; _a++) {
213
+ var peer = _b[_a];
214
+ var peerSourcePath = peer.sourcePath;
215
+ if (!(0, fs_1.existsSync)(peerSourcePath)) {
216
+ console.warn("- Peer dependency \"".concat(peer.name, "\" required by \"").concat(peer.requiredBy, "\" not found in plugin node_modules"));
217
+ continue;
218
+ }
219
+ var peerTargetPath = (0, path_1.join)(projectDependencyPath, peer.name);
220
+ console.info("- Symlinking peer dependency \"".concat(peer.name, "\" required by \"").concat(peer.requiredBy, "\""));
221
+ PeerDependenciesService.symlinkPeer(peerSourcePath, peerTargetPath);
222
+ }
223
+ };
224
+ PeerDependenciesService.symlinkPeer = function (sourcePath, targetPath) {
225
+ var targetParentFolder = (0, path_1.join)(targetPath, "..");
226
+ if (!(0, fs_1.existsSync)(targetParentFolder)) {
227
+ (0, fs_1.mkdirSync)(targetParentFolder, { recursive: true });
228
+ }
229
+ (0, fs_1.symlinkSync)(sourcePath, targetPath);
230
+ };
231
+ PeerDependenciesService.DEPENDENCIES_FOLDER = "node_modules";
232
+ return PeerDependenciesService;
233
+ }());
234
+ exports.PeerDependenciesService = PeerDependenciesService;
@@ -80,7 +80,7 @@ var SymlinkDependenciesService = /** @class */ (function () {
80
80
  case 0:
81
81
  pluginDependencies = SymlinkDependenciesService.getPluginDependencies(plugin);
82
82
  projectDependencyPath = (0, path_1.join)(absoluteProjectDir, SymlinkDependenciesService.DEPENDENCIES_FOLDER);
83
- return [4 /*yield*/, SymlinkDependenciesService.getPluginDependenciesPath(absoluteProjectDir, plugin)];
83
+ return [4 /*yield*/, SymlinkDependenciesService.getPluginDependenciesPath(absoluteProjectDir, plugin, pluginDependencies)];
84
84
  case 1:
85
85
  pluginDependenciesPath = _a.sent();
86
86
  if (projectDependencyPath === pluginDependenciesPath) {
@@ -109,15 +109,20 @@ var SymlinkDependenciesService = /** @class */ (function () {
109
109
  var pluginPackageJson = PackageJson_1.PackageJson.fromDirPath(plugin.path);
110
110
  return pluginPackageJson.getDependenciesPackageNames();
111
111
  };
112
- SymlinkDependenciesService.getPluginDependenciesPath = function (absoluteProjectDir, plugin) {
112
+ SymlinkDependenciesService.getPluginDependenciesPath = function (absoluteProjectDir, plugin, pluginDependencies) {
113
113
  return __awaiter(this, void 0, void 0, function () {
114
- var pluginDependenciesPath;
114
+ var pluginDependenciesPath, hasAnyPluginDependency;
115
115
  return __generator(this, function (_a) {
116
116
  switch (_a.label) {
117
117
  case 0:
118
118
  pluginDependenciesPath = (0, path_1.join)(plugin.path, SymlinkDependenciesService.DEPENDENCIES_FOLDER);
119
119
  if ((0, fs_1.existsSync)(pluginDependenciesPath)) {
120
- return [2 /*return*/, pluginDependenciesPath];
120
+ hasAnyPluginDependency = pluginDependencies.some(function (pluginDependency) {
121
+ return (0, fs_1.existsSync)((0, path_1.join)(pluginDependenciesPath, pluginDependency));
122
+ });
123
+ if (hasAnyPluginDependency) {
124
+ return [2 /*return*/, pluginDependenciesPath];
125
+ }
121
126
  }
122
127
  return [4 /*yield*/, PackageManagerService_1.PackageManagerService.getNodeModulesPath(absoluteProjectDir)];
123
128
  case 1: return [2 /*return*/, _a.sent()];
@@ -4,10 +4,11 @@ export declare class YarnPackageManagerAdapter extends AbstractPackageManagerAda
4
4
  isMonorepo(dirPath: string): Promise<boolean>;
5
5
  isPackageInstalled(packageName: string, dirPath: string): Promise<boolean>;
6
6
  getNodeModulesPath(dirPath: string): Promise<string>;
7
- private yarnWorkspacesOutputHasEntries;
7
+ private analyzeYarnWorkspacesOutput;
8
8
  private parseMaybeJsonString;
9
+ private extractJsonBlock;
9
10
  private hasWorkspaceMap;
10
- private parseJsonObjectFromOutput;
11
11
  private isWorkspaceListEntry;
12
+ private isWorkspaceInfoMap;
12
13
  private yarnListOutputHasPackage;
13
14
  }
@@ -101,7 +101,7 @@ var YarnPackageManagerAdapter = /** @class */ (function (_super) {
101
101
  };
102
102
  YarnPackageManagerAdapter.prototype.isMonorepo = function (dirPath) {
103
103
  return __awaiter(this, void 0, void 0, function () {
104
- var major, primary, fallback, yarnCommands, _i, yarnCommands_1, args, output, _a;
104
+ var major, primary, fallback, yarnCommands, lastOutput, hasRecognizedOutput, hasSuccessfulCommand, _i, yarnCommands_1, args, output, analysis, _a;
105
105
  return __generator(this, function (_b) {
106
106
  switch (_b.label) {
107
107
  case 0: return [4 /*yield*/, this.getVersion(PackageManagerType_1.PackageManagerType.yarn, dirPath)];
@@ -113,6 +113,8 @@ var YarnPackageManagerAdapter = /** @class */ (function (_super) {
113
113
  ["yarn", "workspaces", primary, "--json"],
114
114
  ["yarn", "workspaces", fallback, "--json"],
115
115
  ];
116
+ hasRecognizedOutput = false;
117
+ hasSuccessfulCommand = false;
116
118
  _i = 0, yarnCommands_1 = yarnCommands;
117
119
  _b.label = 2;
118
120
  case 2:
@@ -124,9 +126,15 @@ var YarnPackageManagerAdapter = /** @class */ (function (_super) {
124
126
  return [4 /*yield*/, this.execCommand(args, dirPath, true)];
125
127
  case 4:
126
128
  output = _b.sent();
127
- if (this.yarnWorkspacesOutputHasEntries(output)) {
129
+ hasSuccessfulCommand = true;
130
+ lastOutput = output;
131
+ analysis = this.analyzeYarnWorkspacesOutput(output);
132
+ if (analysis.hasEntries) {
128
133
  return [2 /*return*/, true];
129
134
  }
135
+ if (analysis.hasRecognizedData) {
136
+ hasRecognizedOutput = true;
137
+ }
130
138
  return [3 /*break*/, 6];
131
139
  case 5:
132
140
  _a = _b.sent();
@@ -134,7 +142,11 @@ var YarnPackageManagerAdapter = /** @class */ (function (_super) {
134
142
  case 6:
135
143
  _i++;
136
144
  return [3 /*break*/, 2];
137
- case 7: return [2 /*return*/, false];
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];
138
150
  }
139
151
  });
140
152
  });
@@ -177,20 +189,38 @@ var YarnPackageManagerAdapter = /** @class */ (function (_super) {
177
189
  });
178
190
  });
179
191
  };
180
- YarnPackageManagerAdapter.prototype.yarnWorkspacesOutputHasEntries = function (output) {
192
+ YarnPackageManagerAdapter.prototype.analyzeYarnWorkspacesOutput = function (output) {
181
193
  var _a;
182
194
  var entries = this.parseJsonLines(output);
195
+ if (entries.length === 0) {
196
+ var jsonBlock = this.extractJsonBlock(output);
197
+ if (jsonBlock && typeof jsonBlock === "object") {
198
+ entries = [jsonBlock];
199
+ }
200
+ }
201
+ if (entries.length === 0) {
202
+ return { hasEntries: false, hasRecognizedData: false };
203
+ }
183
204
  var workspaceListCount = 0;
205
+ var hasRecognizedData = false;
184
206
  for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
185
207
  var entry = entries_1[_i];
186
208
  if (!entry || typeof entry !== "object") {
187
209
  continue;
188
210
  }
211
+ var type = entry.type;
212
+ if (type === "error" || type === "warning") {
213
+ continue;
214
+ }
189
215
  var data = (_a = entry.data) !== null && _a !== void 0 ? _a : entry;
190
216
  var parsedData = this.parseMaybeJsonString(data);
191
217
  if (parsedData && typeof parsedData === "object") {
218
+ hasRecognizedData = true;
192
219
  if (this.hasWorkspaceMap(parsedData)) {
193
- return true;
220
+ return { hasEntries: true, hasRecognizedData: hasRecognizedData };
221
+ }
222
+ if (this.isWorkspaceInfoMap(parsedData)) {
223
+ return { hasEntries: true, hasRecognizedData: hasRecognizedData };
194
224
  }
195
225
  if (this.isWorkspaceListEntry(parsedData)) {
196
226
  workspaceListCount += 1;
@@ -198,13 +228,9 @@ var YarnPackageManagerAdapter = /** @class */ (function (_super) {
198
228
  }
199
229
  }
200
230
  if (workspaceListCount > 0) {
201
- return true;
202
- }
203
- var parsedOutput = this.parseJsonObjectFromOutput(output);
204
- if (parsedOutput && typeof parsedOutput === "object") {
205
- return Object.keys(parsedOutput).length > 0;
231
+ return { hasEntries: true, hasRecognizedData: hasRecognizedData };
206
232
  }
207
- return false;
233
+ return { hasEntries: false, hasRecognizedData: hasRecognizedData };
208
234
  };
209
235
  YarnPackageManagerAdapter.prototype.parseMaybeJsonString = function (value) {
210
236
  if (typeof value !== "string") {
@@ -217,27 +243,30 @@ var YarnPackageManagerAdapter = /** @class */ (function (_super) {
217
243
  return undefined;
218
244
  }
219
245
  };
220
- YarnPackageManagerAdapter.prototype.hasWorkspaceMap = function (value) {
221
- if (!value || typeof value !== "object") {
222
- return false;
223
- }
224
- var workspaces = value.workspaces;
225
- return !!workspaces && Object.keys(workspaces).length > 0;
226
- };
227
- YarnPackageManagerAdapter.prototype.parseJsonObjectFromOutput = function (output) {
246
+ YarnPackageManagerAdapter.prototype.extractJsonBlock = function (output) {
228
247
  var start = output.indexOf("{");
229
248
  var end = output.lastIndexOf("}");
230
- if (start < 0 || end <= start) {
249
+ if (start === -1 || end === -1 || end <= start) {
250
+ return undefined;
251
+ }
252
+ var candidate = output.slice(start, end + 1).trim();
253
+ if (candidate.length === 0) {
231
254
  return undefined;
232
255
  }
233
- var slice = output.slice(start, end + 1).trim();
234
256
  try {
235
- return JSON.parse(slice);
257
+ return JSON.parse(candidate);
236
258
  }
237
259
  catch (_a) {
238
260
  return undefined;
239
261
  }
240
262
  };
263
+ YarnPackageManagerAdapter.prototype.hasWorkspaceMap = function (value) {
264
+ if (!value || typeof value !== "object") {
265
+ return false;
266
+ }
267
+ var workspaces = value.workspaces;
268
+ return !!workspaces && Object.keys(workspaces).length > 0;
269
+ };
241
270
  YarnPackageManagerAdapter.prototype.isWorkspaceListEntry = function (value) {
242
271
  if (!value || typeof value !== "object") {
243
272
  return false;
@@ -245,6 +274,22 @@ var YarnPackageManagerAdapter = /** @class */ (function (_super) {
245
274
  var entry = value;
246
275
  return typeof entry.name === "string" && typeof entry.location === "string" && entry.location !== ".";
247
276
  };
277
+ YarnPackageManagerAdapter.prototype.isWorkspaceInfoMap = function (value) {
278
+ if (!value || typeof value !== "object") {
279
+ return false;
280
+ }
281
+ var entries = Object.values(value);
282
+ if (entries.length === 0) {
283
+ return false;
284
+ }
285
+ return entries.some(function (entry) {
286
+ if (!entry || typeof entry !== "object") {
287
+ return false;
288
+ }
289
+ var location = entry.location;
290
+ return typeof location === "string" && location.length > 0 && location !== ".";
291
+ });
292
+ };
248
293
  YarnPackageManagerAdapter.prototype.yarnListOutputHasPackage = function (output, packageName) {
249
294
  var _a;
250
295
  var entries = this.parseJsonLines(output);
@@ -256,6 +301,13 @@ var YarnPackageManagerAdapter = /** @class */ (function (_super) {
256
301
  var data = entry.data;
257
302
  var trees = (_a = data === null || data === void 0 ? void 0 : data.trees) !== null && _a !== void 0 ? _a : entry.trees;
258
303
  if (!trees) {
304
+ var children = entry.children;
305
+ if (children) {
306
+ var childKeys = Object.keys(children);
307
+ if (childKeys.some(function (key) { return key.startsWith(packageName + "@"); })) {
308
+ return true;
309
+ }
310
+ }
259
311
  continue;
260
312
  }
261
313
  if (trees.some(function (tree) { return tree.name.startsWith(packageName + "@"); })) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ts-dev-tools/core",
3
- "version": "1.10.0",
3
+ "version": "1.11.0",
4
4
  "description": "TS dev tools Core",
5
5
  "keywords": [
6
6
  "linter",
@@ -93,5 +93,5 @@
93
93
  "github-actions"
94
94
  ]
95
95
  },
96
- "gitHead": "e45076a10f72cd59f296dc30abdbe692aa8684b1"
96
+ "gitHead": "9181a105b83523716cb8579991fd77f21a0e9ef6"
97
97
  }