@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,165 +1,65 @@
|
|
|
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.NpmPackageManagerAdapter = void 0;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
4
|
+
const AbstractPackageManagerAdapter_1 = require("./AbstractPackageManagerAdapter");
|
|
5
|
+
class NpmPackageManagerAdapter extends AbstractPackageManagerAdapter_1.AbstractPackageManagerAdapter {
|
|
6
|
+
async addDevPackage(packageName, dirPath) {
|
|
7
|
+
const isMonorepo = await this.isMonorepo(dirPath);
|
|
8
|
+
const args = ["npm", "install", "--save-dev"];
|
|
9
|
+
if (isMonorepo) {
|
|
10
|
+
args.push("--no-workspaces");
|
|
11
|
+
}
|
|
12
|
+
args.push(packageName);
|
|
13
|
+
await this.execCommand(args, dirPath, true);
|
|
60
14
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
return
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
return [4 /*yield*/, this.execCommand(["npm", "--workspaces", "list", "--json"], dirPath, true)];
|
|
90
|
-
case 1:
|
|
91
|
-
_b.sent();
|
|
92
|
-
return [2 /*return*/, true];
|
|
93
|
-
case 2:
|
|
94
|
-
_a = _b.sent();
|
|
95
|
-
return [2 /*return*/, false];
|
|
96
|
-
case 3: return [2 /*return*/];
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
};
|
|
101
|
-
NpmPackageManagerAdapter.prototype.isPackageInstalled = function (packageName, dirPath) {
|
|
102
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
103
|
-
var args, output, error_1, installedPackages;
|
|
104
|
-
return __generator(this, function (_a) {
|
|
105
|
-
switch (_a.label) {
|
|
106
|
-
case 0:
|
|
107
|
-
args = [
|
|
108
|
-
"npm",
|
|
109
|
-
"list",
|
|
110
|
-
"--depth=1",
|
|
111
|
-
"--json",
|
|
112
|
-
"--no-progress",
|
|
113
|
-
"--non-interactive",
|
|
114
|
-
packageName,
|
|
115
|
-
];
|
|
116
|
-
_a.label = 1;
|
|
117
|
-
case 1:
|
|
118
|
-
_a.trys.push([1, 3, , 4]);
|
|
119
|
-
return [4 /*yield*/, this.execCommand(args, dirPath, true)];
|
|
120
|
-
case 2:
|
|
121
|
-
output = _a.sent();
|
|
122
|
-
return [3 /*break*/, 4];
|
|
123
|
-
case 3:
|
|
124
|
-
error_1 = _a.sent();
|
|
125
|
-
if (typeof error_1 === "string") {
|
|
126
|
-
try {
|
|
127
|
-
JSON.parse(error_1.trim());
|
|
128
|
-
output = error_1;
|
|
129
|
-
}
|
|
130
|
-
catch (_b) {
|
|
131
|
-
return [2 /*return*/, false];
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
else {
|
|
135
|
-
return [2 /*return*/, false];
|
|
136
|
-
}
|
|
137
|
-
return [3 /*break*/, 4];
|
|
138
|
-
case 4:
|
|
139
|
-
installedPackages = JSON.parse(output);
|
|
140
|
-
return [2 /*return*/, installedPackages.dependencies
|
|
141
|
-
? Object.prototype.hasOwnProperty.call(installedPackages.dependencies, packageName)
|
|
142
|
-
: false];
|
|
15
|
+
async isMonorepo(dirPath) {
|
|
16
|
+
try {
|
|
17
|
+
await this.execCommand(["npm", "--workspaces", "list", "--json"], dirPath, true);
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
async isPackageInstalled(packageName, dirPath) {
|
|
25
|
+
const args = [
|
|
26
|
+
"npm",
|
|
27
|
+
"list",
|
|
28
|
+
"--depth=1",
|
|
29
|
+
"--json",
|
|
30
|
+
"--no-progress",
|
|
31
|
+
"--non-interactive",
|
|
32
|
+
packageName,
|
|
33
|
+
];
|
|
34
|
+
let output;
|
|
35
|
+
try {
|
|
36
|
+
output = await this.execCommand(args, dirPath, true);
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
if (typeof error === "string") {
|
|
40
|
+
try {
|
|
41
|
+
JSON.parse(error.trim());
|
|
42
|
+
output = error;
|
|
143
43
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
};
|
|
147
|
-
NpmPackageManagerAdapter.prototype.getNodeModulesPath = function (dirPath) {
|
|
148
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
149
|
-
var nodeModulesPath;
|
|
150
|
-
return __generator(this, function (_a) {
|
|
151
|
-
switch (_a.label) {
|
|
152
|
-
case 0: return [4 /*yield*/, this.execCommand(["npm", "root", "--no-progress", "--non-interactive"], dirPath, true)];
|
|
153
|
-
case 1:
|
|
154
|
-
nodeModulesPath = (_a.sent()).trim();
|
|
155
|
-
if (nodeModulesPath) {
|
|
156
|
-
return [2 /*return*/, nodeModulesPath];
|
|
157
|
-
}
|
|
158
|
-
throw new Error("Node modules path not found for package manager npm");
|
|
44
|
+
catch {
|
|
45
|
+
return false;
|
|
159
46
|
}
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
}
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
const installedPackages = JSON.parse(output);
|
|
53
|
+
return installedPackages.dependencies
|
|
54
|
+
? Object.prototype.hasOwnProperty.call(installedPackages.dependencies, packageName)
|
|
55
|
+
: false;
|
|
56
|
+
}
|
|
57
|
+
async getNodeModulesPath(dirPath) {
|
|
58
|
+
const nodeModulesPath = (await this.execCommand(["npm", "root", "--no-progress", "--non-interactive"], dirPath, true)).trim();
|
|
59
|
+
if (nodeModulesPath) {
|
|
60
|
+
return nodeModulesPath;
|
|
61
|
+
}
|
|
62
|
+
throw new Error("Node modules path not found for package manager npm");
|
|
63
|
+
}
|
|
64
|
+
}
|
|
165
65
|
exports.NpmPackageManagerAdapter = NpmPackageManagerAdapter;
|