@ts-dev-tools/core 1.5.4 → 1.5.11
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/package.json +19 -19
- package/CHANGELOG.md +0 -264
- package/dist/bin.d.ts +0 -2
- package/dist/bin.js +0 -82
- package/dist/install/command.d.ts +0 -4
- package/dist/install/command.js +0 -74
- package/dist/install/migrations/20201024173398-init.d.ts +0 -2
- package/dist/install/migrations/20201024173398-init.js +0 -133
- package/dist/services/CmdService.d.ts +0 -3
- package/dist/services/CmdService.js +0 -56
- package/dist/services/DuplicateDependenciesService.d.ts +0 -4
- package/dist/services/DuplicateDependenciesService.js +0 -33
- package/dist/services/MigrationsService.d.ts +0 -10
- package/dist/services/MigrationsService.js +0 -132
- package/dist/services/PackageJson.d.ts +0 -28
- package/dist/services/PackageJson.js +0 -95
- package/dist/services/PackageJsonMerge.d.ts +0 -8
- package/dist/services/PackageJsonMerge.js +0 -52
- package/dist/services/PackageManagerService.d.ts +0 -7
- package/dist/services/PackageManagerService.js +0 -22
- package/dist/tests/console.d.ts +0 -3
- package/dist/tests/console.js +0 -18
- package/dist/tests/utils.d.ts +0 -5
- package/dist/tests/utils.js +0 -69
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ts-dev-tools/core",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.11",
|
|
4
4
|
"description": "TS dev tools Core",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"linter",
|
|
@@ -41,26 +41,26 @@
|
|
|
41
41
|
"url": "https://github.com/escemi-tech/ts-dev-tools/issues"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@commitlint/cli": "^
|
|
45
|
-
"@commitlint/config-conventional": "^
|
|
46
|
-
"@types/jest": "^
|
|
47
|
-
"@types/node": "^
|
|
48
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
49
|
-
"@typescript-eslint/parser": "^
|
|
50
|
-
"eslint": "^
|
|
44
|
+
"@commitlint/cli": "^16.0.2",
|
|
45
|
+
"@commitlint/config-conventional": "^16.0.0",
|
|
46
|
+
"@types/jest": "^27.4.0",
|
|
47
|
+
"@types/node": "^17.0.8",
|
|
48
|
+
"@typescript-eslint/eslint-plugin": "^5.9.1",
|
|
49
|
+
"@typescript-eslint/parser": "^5.9.1",
|
|
50
|
+
"eslint": "^8.6.0",
|
|
51
51
|
"eslint-config-prettier": "^8.3.0",
|
|
52
|
-
"eslint-plugin-import": "^2.
|
|
53
|
-
"eslint-plugin-jest": "^
|
|
52
|
+
"eslint-plugin-import": "^2.25.4",
|
|
53
|
+
"eslint-plugin-jest": "^25.3.4",
|
|
54
54
|
"eslint-plugin-node": "^11.1.0",
|
|
55
|
-
"eslint-plugin-promise": "^
|
|
55
|
+
"eslint-plugin-promise": "^6.0.0",
|
|
56
56
|
"import-sort-style-module": "^6.0.0",
|
|
57
|
-
"jest": "^
|
|
58
|
-
"lint-staged": "^
|
|
59
|
-
"prettier": "^2.
|
|
60
|
-
"prettier-plugin-import-sort": "^0.0.
|
|
61
|
-
"pretty-quick": "^3.1.
|
|
62
|
-
"ts-jest": "^
|
|
63
|
-
"typescript": "^4.
|
|
57
|
+
"jest": "^27.4.7",
|
|
58
|
+
"lint-staged": "^12.1.7",
|
|
59
|
+
"prettier": "^2.5.1",
|
|
60
|
+
"prettier-plugin-import-sort": "^0.0.7",
|
|
61
|
+
"pretty-quick": "^3.1.3",
|
|
62
|
+
"ts-jest": "^27.1.2",
|
|
63
|
+
"typescript": "^4.5.4"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
66
66
|
"pinst": "^2.1.6"
|
|
@@ -106,5 +106,5 @@
|
|
|
106
106
|
"**/?(*.)+(spec|test).+(ts|tsx|js)"
|
|
107
107
|
]
|
|
108
108
|
},
|
|
109
|
-
"gitHead": "
|
|
109
|
+
"gitHead": "596e045cd413d1208ff8be9c565355d3c23037b2"
|
|
110
110
|
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,264 +0,0 @@
|
|
|
1
|
-
# Change Log
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file.
|
|
4
|
-
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
-
|
|
6
|
-
## 1.5.4 (2021-04-30)
|
|
7
|
-
|
|
8
|
-
**Note:** Version bump only for package @ts-dev-tools/core
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
## 1.5.3 (2021-04-09)
|
|
15
|
-
|
|
16
|
-
**Note:** Version bump only for package @ts-dev-tools/core
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
## 1.5.2 (2021-03-26)
|
|
23
|
-
|
|
24
|
-
**Note:** Version bump only for package @ts-dev-tools/core
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
## 1.5.1 (2021-03-23)
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
### Bug Fixes
|
|
34
|
-
|
|
35
|
-
* **core:** commit-msg hooks wrongly escaped argument ([4e648a8](https://github.com/escemi-tech/ts-dev-tools/commit/4e648a8aaa858b67130871e10f8db2fda345cdc6))
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
# 1.5.0 (2021-03-23)
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
### Features
|
|
45
|
-
|
|
46
|
-
* **core:** remove husky dependency ([00d47b4](https://github.com/escemi-tech/ts-dev-tools/commit/00d47b461f0a0f4e69ce14c5f08ad8fbaeee8896))
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
## 1.4.10 (2021-03-17)
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
### Bug Fixes
|
|
56
|
-
|
|
57
|
-
* **react:** various issues for first migration ([0d09c44](https://github.com/escemi-tech/ts-dev-tools/commit/0d09c44a8dc144c1ffc2bed7290faf365c34e6a0))
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
## 1.4.9 (2021-03-12)
|
|
64
|
-
|
|
65
|
-
**Note:** Version bump only for package @ts-dev-tools/core
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
## 1.4.8 (2020-12-26)
|
|
72
|
-
|
|
73
|
-
**Note:** Version bump only for package @ts-dev-tools/core
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
## 1.4.7 (2020-12-18)
|
|
80
|
-
|
|
81
|
-
**Note:** Version bump only for package @ts-dev-tools/core
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
## 1.4.6 (2020-12-18)
|
|
88
|
-
|
|
89
|
-
**Note:** Version bump only for package @ts-dev-tools/core
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
## 1.4.5 (2020-12-11)
|
|
96
|
-
|
|
97
|
-
**Note:** Version bump only for package @ts-dev-tools/core
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
## 1.4.4 (2020-12-04)
|
|
104
|
-
|
|
105
|
-
**Note:** Version bump only for package @ts-dev-tools/core
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
## 1.4.3 (2020-11-27)
|
|
112
|
-
|
|
113
|
-
**Note:** Version bump only for package @ts-dev-tools/core
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
## 1.4.2 (2020-11-24)
|
|
120
|
-
|
|
121
|
-
**Note:** Version bump only for package @ts-dev-tools/core
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
## 1.4.1 (2020-11-19)
|
|
128
|
-
|
|
129
|
-
**Note:** Version bump only for package @ts-dev-tools/core
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
# 1.4.0 (2020-11-17)
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
### Features
|
|
139
|
-
|
|
140
|
-
* **desp:** upgrade eslint deps ([8c730f5](https://github.com/escemi-tech/ts-dev-tools/commit/8c730f5baa8944a2eb2c542a3b02253c989cce61))
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
## 1.3.7 (2020-11-13)
|
|
147
|
-
|
|
148
|
-
**Note:** Version bump only for package @ts-dev-tools/core
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
## 1.3.6 (2020-11-13)
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
### Bug Fixes
|
|
158
|
-
|
|
159
|
-
* **react:** add missing dependency for @testing-library/react-hooks ([f94882a](https://github.com/escemi-tech/ts-dev-tools/commit/f94882a34c79f789fcef5ee2ec42c8399c7acd21))
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
## 1.3.5 (2020-11-12)
|
|
166
|
-
|
|
167
|
-
**Note:** Version bump only for package @ts-dev-tools/core
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
## 1.3.4 (2020-11-11)
|
|
174
|
-
|
|
175
|
-
**Note:** Version bump only for package @ts-dev-tools/core
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
## 1.3.3 (2020-11-11)
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
### Bug Fixes
|
|
185
|
-
|
|
186
|
-
* typescript build config ignore dist dir ([993bbb8](https://github.com/escemi-tech/ts-dev-tools/commit/993bbb8b45c8e234d6964aaead5d0ce0eac8901d))
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
## 1.3.2 (2020-11-11)
|
|
193
|
-
|
|
194
|
-
**Note:** Version bump only for package @ts-dev-tools/core
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
## 1.3.1 (2020-11-11)
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
### Bug Fixes
|
|
204
|
-
|
|
205
|
-
* **core:** use itself ([fe9fd79](https://github.com/escemi-tech/ts-dev-tools/commit/fe9fd790270d09500a8197c1ae2204492b46aa68))
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
# 1.3.0 (2020-11-09)
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
### Features
|
|
215
|
-
|
|
216
|
-
* add test tools ([a73a3fb](https://github.com/escemi-tech/ts-dev-tools/commit/a73a3fb1a1e7f1ed982356f8d02984d9a09d1f2b))
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
# 1.2.0 (2020-11-09)
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
### Features
|
|
226
|
-
|
|
227
|
-
* prepare for plugin installation ([ab7d4e6](https://github.com/escemi-tech/ts-dev-tools/commit/ab7d4e6203631907c3a0e86255f6866a8a0c7c2a))
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
## 1.1.3 (2020-11-09)
|
|
234
|
-
|
|
235
|
-
**Note:** Version bump only for package @ts-dev-tools/core
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
## 1.1.2 (2020-11-09)
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
### Bug Fixes
|
|
245
|
-
|
|
246
|
-
* install script ([7bf8a4e](https://github.com/escemi-tech/ts-dev-tools/commit/7bf8a4ed404ba4d18fd9fc75c9753dabe27fdd36))
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
## 1.1.1 (2020-10-29)
|
|
253
|
-
|
|
254
|
-
**Note:** Version bump only for package @ts-dev-tools/core
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
# 1.1.0 (2020-10-29)
|
|
261
|
-
|
|
262
|
-
### Features
|
|
263
|
-
|
|
264
|
-
- initialize project ([47760c4](https://github.com/escemi-tech/ts-dev-tools/commit/47760c49ad7823b019cc2e7ae8c06b8f54639b1c))
|
package/dist/bin.d.ts
DELETED
package/dist/bin.js
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
6
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
7
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
8
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
9
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
10
|
-
});
|
|
11
|
-
};
|
|
12
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
13
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
14
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
15
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
16
|
-
function step(op) {
|
|
17
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
18
|
-
while (_) try {
|
|
19
|
-
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;
|
|
20
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
21
|
-
switch (op[0]) {
|
|
22
|
-
case 0: case 1: t = op; break;
|
|
23
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
24
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
25
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
26
|
-
default:
|
|
27
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
28
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
29
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
30
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
31
|
-
if (t[2]) _.ops.pop();
|
|
32
|
-
_.trys.pop(); continue;
|
|
33
|
-
}
|
|
34
|
-
op = body.call(thisArg, _);
|
|
35
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
36
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
-
var path_1 = require("path");
|
|
41
|
-
var command_1 = require("./install/command");
|
|
42
|
-
var PackageJson_1 = require("./services/PackageJson");
|
|
43
|
-
function bin() {
|
|
44
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
45
|
-
var _a, arg, params, _b;
|
|
46
|
-
return __generator(this, function (_c) {
|
|
47
|
-
switch (_c.label) {
|
|
48
|
-
case 0:
|
|
49
|
-
_a = process.argv, arg = _a[2], params = _a.slice(3);
|
|
50
|
-
_b = true;
|
|
51
|
-
switch (_b) {
|
|
52
|
-
case arg === "install": return [3 /*break*/, 1];
|
|
53
|
-
case ["--version", "-v"].includes(arg): return [3 /*break*/, 3];
|
|
54
|
-
}
|
|
55
|
-
return [3 /*break*/, 4];
|
|
56
|
-
case 1:
|
|
57
|
-
// Check if script is not run by the package himself
|
|
58
|
-
if (process.cwd() === path_1.dirname(__dirname)) {
|
|
59
|
-
console.info("Do not install itself!");
|
|
60
|
-
return [3 /*break*/, 5];
|
|
61
|
-
}
|
|
62
|
-
return [4 /*yield*/, command_1.install({
|
|
63
|
-
cwd: process.cwd(),
|
|
64
|
-
dir: params[0],
|
|
65
|
-
})];
|
|
66
|
-
case 2:
|
|
67
|
-
_c.sent();
|
|
68
|
-
return [3 /*break*/, 5];
|
|
69
|
-
case 3:
|
|
70
|
-
console.info(PackageJson_1.PackageJson.fromDirPath(path_1.join(__dirname, "..")).getPackageVersion());
|
|
71
|
-
return [3 /*break*/, 5];
|
|
72
|
-
case 4:
|
|
73
|
-
console.info("Usage\n ts-dev-tools install [path from project root]\n ");
|
|
74
|
-
_c.label = 5;
|
|
75
|
-
case 5: return [2 /*return*/];
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
bin()
|
|
81
|
-
.then()
|
|
82
|
-
.catch(function (error) { return console.error(error); });
|
package/dist/install/command.js
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
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;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "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 (_) 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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.install = void 0;
|
|
40
|
-
var path_1 = require("path");
|
|
41
|
-
var DuplicateDependenciesService_1 = require("../services/DuplicateDependenciesService");
|
|
42
|
-
var MigrationsService_1 = require("../services/MigrationsService");
|
|
43
|
-
var PackageJson_1 = require("../services/PackageJson");
|
|
44
|
-
function install(_a) {
|
|
45
|
-
var cwd = _a.cwd, _b = _a.dir, dir = _b === void 0 ? "." : _b;
|
|
46
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
47
|
-
var tsDevToolsRootPath, packageName, absoluteProjectDir, currentVersion;
|
|
48
|
-
return __generator(this, function (_c) {
|
|
49
|
-
switch (_c.label) {
|
|
50
|
-
case 0:
|
|
51
|
-
tsDevToolsRootPath = path_1.resolve(__dirname, "../..");
|
|
52
|
-
packageName = PackageJson_1.PackageJson.fromDirPath(tsDevToolsRootPath).getPackageName();
|
|
53
|
-
absoluteProjectDir = path_1.resolve(cwd, dir);
|
|
54
|
-
if (!absoluteProjectDir.startsWith(cwd)) {
|
|
55
|
-
throw new Error(".. not allowed");
|
|
56
|
-
}
|
|
57
|
-
currentVersion = PackageJson_1.PackageJson.fromDirPath(absoluteProjectDir).getTsDevToolsVersion();
|
|
58
|
-
if (currentVersion) {
|
|
59
|
-
console.info("Updating " + packageName + " installation...");
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
console.info("Installing " + packageName + "...");
|
|
63
|
-
}
|
|
64
|
-
return [4 /*yield*/, MigrationsService_1.MigrationsService.executeMigrations(tsDevToolsRootPath, absoluteProjectDir, currentVersion)];
|
|
65
|
-
case 1:
|
|
66
|
-
_c.sent();
|
|
67
|
-
DuplicateDependenciesService_1.DuplicateDependenciesService.duplicateDependencies(tsDevToolsRootPath, absoluteProjectDir);
|
|
68
|
-
console.info("Installation done!");
|
|
69
|
-
return [2 /*return*/];
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
exports.install = install;
|
|
@@ -1,133 +0,0 @@
|
|
|
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;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "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 (_) 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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.up = void 0;
|
|
40
|
-
var fs_1 = require("fs");
|
|
41
|
-
var path_1 = require("path");
|
|
42
|
-
var CmdService_1 = require("../../services/CmdService");
|
|
43
|
-
var PackageJson_1 = require("../../services/PackageJson");
|
|
44
|
-
var PackageManagerService_1 = require("../../services/PackageManagerService");
|
|
45
|
-
var up = function (absoluteProjectDir) { return __awaiter(void 0, void 0, void 0, function () {
|
|
46
|
-
var jest, eslintConfig, prettier, commitlint, lintStaged, importSort, scripts, packageJson, isGitRepository, packageManager, gitHooks, gitHookDirPath, _i, _a, gitHookFileName, gitHookFilePath, gitHookCommand;
|
|
47
|
-
return __generator(this, function (_b) {
|
|
48
|
-
switch (_b.label) {
|
|
49
|
-
case 0:
|
|
50
|
-
jest = {
|
|
51
|
-
preset: "ts-jest",
|
|
52
|
-
testEnvironment: "node",
|
|
53
|
-
testMatch: ["**/__tests__/**/*.[jt]s?(x)", "**/?(*.)+(spec|test).+(ts|tsx|js)"],
|
|
54
|
-
};
|
|
55
|
-
eslintConfig = {
|
|
56
|
-
root: true,
|
|
57
|
-
parser: "@typescript-eslint/parser",
|
|
58
|
-
plugins: ["@typescript-eslint", "jest"],
|
|
59
|
-
extends: [
|
|
60
|
-
"eslint:recommended",
|
|
61
|
-
"plugin:@typescript-eslint/recommended",
|
|
62
|
-
"plugin:jest/recommended",
|
|
63
|
-
"prettier",
|
|
64
|
-
],
|
|
65
|
-
env: {
|
|
66
|
-
es2021: true,
|
|
67
|
-
},
|
|
68
|
-
parserOptions: {
|
|
69
|
-
ecmaFeatures: {
|
|
70
|
-
jsx: true,
|
|
71
|
-
},
|
|
72
|
-
ecmaVersion: 12,
|
|
73
|
-
sourceType: "module",
|
|
74
|
-
},
|
|
75
|
-
};
|
|
76
|
-
prettier = {
|
|
77
|
-
semi: true,
|
|
78
|
-
printWidth: 100,
|
|
79
|
-
trailingComma: "es5",
|
|
80
|
-
};
|
|
81
|
-
commitlint = {
|
|
82
|
-
extends: ["@commitlint/config-conventional"],
|
|
83
|
-
};
|
|
84
|
-
lintStaged = {
|
|
85
|
-
"*.{js,ts,tsx}": ["eslint --fix"],
|
|
86
|
-
};
|
|
87
|
-
importSort = {
|
|
88
|
-
".js, .jsx, .ts, .tsx": {
|
|
89
|
-
style: "module",
|
|
90
|
-
parser: "typescript",
|
|
91
|
-
},
|
|
92
|
-
};
|
|
93
|
-
scripts = {
|
|
94
|
-
build: "tsc --noEmit",
|
|
95
|
-
test: "jest",
|
|
96
|
-
lint: 'eslint "src/**/*.{ts,tsx}"',
|
|
97
|
-
prepare: "ts-dev-tools install",
|
|
98
|
-
};
|
|
99
|
-
packageJson = PackageJson_1.PackageJson.fromDirPath(absoluteProjectDir);
|
|
100
|
-
packageJson.merge({
|
|
101
|
-
eslintConfig: eslintConfig,
|
|
102
|
-
prettier: prettier,
|
|
103
|
-
commitlint: commitlint,
|
|
104
|
-
"lint-staged": lintStaged,
|
|
105
|
-
importSort: importSort,
|
|
106
|
-
scripts: scripts,
|
|
107
|
-
jest: jest,
|
|
108
|
-
});
|
|
109
|
-
return [4 /*yield*/, CmdService_1.CmdService.execCmd("git rev-parse", absoluteProjectDir, true)
|
|
110
|
-
.then(function () { return true; })
|
|
111
|
-
.catch(function () { return false; })];
|
|
112
|
-
case 1:
|
|
113
|
-
isGitRepository = _b.sent();
|
|
114
|
-
if (isGitRepository) {
|
|
115
|
-
packageManager = PackageManagerService_1.PackageManagerService.detectPackageManager(absoluteProjectDir);
|
|
116
|
-
gitHooks = {
|
|
117
|
-
"pre-commit": "npx --no-install lint-staged && npx --no-install pretty-quick --staged",
|
|
118
|
-
"commit-msg": "npx --no-install commitlint --edit $1",
|
|
119
|
-
"pre-push": packageManager + " run lint && " + packageManager + " run build && " + packageManager + " run test\"",
|
|
120
|
-
};
|
|
121
|
-
gitHookDirPath = path_1.join(absoluteProjectDir, ".git/hooks");
|
|
122
|
-
for (_i = 0, _a = Object.keys(gitHooks); _i < _a.length; _i++) {
|
|
123
|
-
gitHookFileName = _a[_i];
|
|
124
|
-
gitHookFilePath = path_1.join(gitHookDirPath, gitHookFileName);
|
|
125
|
-
gitHookCommand = gitHooks[gitHookFileName];
|
|
126
|
-
fs_1.writeFileSync(gitHookFilePath, "#!/bin/sh\n# Created by ts-dev-tools (https://escemi-tech.github.io/ts-dev-tools/)\n" + gitHookCommand);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
return [2 /*return*/];
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
}); };
|
|
133
|
-
exports.up = up;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CmdService = void 0;
|
|
4
|
-
var child_process_1 = require("child_process");
|
|
5
|
-
var fs_1 = require("fs");
|
|
6
|
-
var CmdService = /** @class */ (function () {
|
|
7
|
-
function CmdService() {
|
|
8
|
-
}
|
|
9
|
-
CmdService.execCmd = function (args, cwd, silent) {
|
|
10
|
-
if (silent === void 0) { silent = false; }
|
|
11
|
-
if (!args.length) {
|
|
12
|
-
throw new Error("Command args must not be empty");
|
|
13
|
-
}
|
|
14
|
-
if (cwd) {
|
|
15
|
-
if (!fs_1.existsSync(cwd) || !fs_1.statSync(cwd).isDirectory()) {
|
|
16
|
-
throw new Error("Directory \"" + cwd + "\" does not exist");
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
var cmd;
|
|
20
|
-
if (Array.isArray(args)) {
|
|
21
|
-
cmd = args.shift() || "";
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
cmd = args;
|
|
25
|
-
args = [];
|
|
26
|
-
}
|
|
27
|
-
return new Promise(function (resolve, reject) {
|
|
28
|
-
var child = child_process_1.spawn(cmd, args, {
|
|
29
|
-
stdio: silent ? "pipe" : "inherit",
|
|
30
|
-
shell: true,
|
|
31
|
-
windowsVerbatimArguments: true,
|
|
32
|
-
cwd: cwd,
|
|
33
|
-
});
|
|
34
|
-
var output = "";
|
|
35
|
-
var error = "";
|
|
36
|
-
child.on("exit", function (code) {
|
|
37
|
-
if (code) {
|
|
38
|
-
return reject(error);
|
|
39
|
-
}
|
|
40
|
-
resolve(output);
|
|
41
|
-
});
|
|
42
|
-
if (child.stdout) {
|
|
43
|
-
child.stdout.on("data", function (data) {
|
|
44
|
-
output += "\n" + data;
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
if (child.stderr) {
|
|
48
|
-
child.stderr.on("data", function (data) {
|
|
49
|
-
error += "\n" + data;
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
};
|
|
54
|
-
return CmdService;
|
|
55
|
-
}());
|
|
56
|
-
exports.CmdService = CmdService;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DuplicateDependenciesService = void 0;
|
|
4
|
-
var path_1 = require("path");
|
|
5
|
-
var PackageJson_1 = require("./PackageJson");
|
|
6
|
-
var DuplicateDependenciesService = /** @class */ (function () {
|
|
7
|
-
function DuplicateDependenciesService() {
|
|
8
|
-
}
|
|
9
|
-
DuplicateDependenciesService.duplicateDependencies = function (tsDevToolsRootPath, absoluteProjectDir) {
|
|
10
|
-
var projectPackageJson = PackageJson_1.PackageJson.fromDirPath(absoluteProjectDir);
|
|
11
|
-
var installedPlugins = projectPackageJson.getInstalledPlugins();
|
|
12
|
-
console.info("Checking for duplicate dev dependencies...");
|
|
13
|
-
for (var _i = 0, installedPlugins_1 = installedPlugins; _i < installedPlugins_1.length; _i++) {
|
|
14
|
-
var plugin = installedPlugins_1[_i];
|
|
15
|
-
DuplicateDependenciesService.duplicatePluginDependencies(tsDevToolsRootPath, projectPackageJson, plugin);
|
|
16
|
-
}
|
|
17
|
-
console.info("Check for duplicate dev dependencies done!");
|
|
18
|
-
};
|
|
19
|
-
DuplicateDependenciesService.duplicatePluginDependencies = function (tsDevToolsRootPath, projectPackageJson, plugin) {
|
|
20
|
-
var absolutePluginDir = path_1.resolve(tsDevToolsRootPath, "../../", plugin);
|
|
21
|
-
var pluginPackageJson = PackageJson_1.PackageJson.fromDirPath(absolutePluginDir);
|
|
22
|
-
var projectDevDependencies = projectPackageJson.getDevDependenciesPackageNames();
|
|
23
|
-
var pluginDependencies = pluginPackageJson.getDependenciesPackageNames();
|
|
24
|
-
var duplicateDependencies = projectDevDependencies.filter(function (dependency) {
|
|
25
|
-
return pluginDependencies.includes(dependency);
|
|
26
|
-
});
|
|
27
|
-
if (duplicateDependencies.length) {
|
|
28
|
-
console.info("Some dev dependencies are unnecessarily installed as their are already required by \"" + plugin + "\":\"\n - \"" + duplicateDependencies.join("\n - ") + "\n");
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
return DuplicateDependenciesService;
|
|
32
|
-
}());
|
|
33
|
-
exports.DuplicateDependenciesService = DuplicateDependenciesService;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export declare type Migration = {
|
|
2
|
-
name: string;
|
|
3
|
-
path: string;
|
|
4
|
-
};
|
|
5
|
-
export declare type MigrationUpFunction = (absoluteProjectDir: string) => Promise<void>;
|
|
6
|
-
export declare class MigrationsService {
|
|
7
|
-
static executeMigrations(tsDevToolsRootPath: string, absoluteProjectDir: string, currentVersion: string | undefined): Promise<void>;
|
|
8
|
-
private static getAvailableMigrations;
|
|
9
|
-
private static getPluginMigrations;
|
|
10
|
-
}
|
|
@@ -1,132 +0,0 @@
|
|
|
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;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "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 (_) 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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.MigrationsService = void 0;
|
|
40
|
-
var fs_1 = require("fs");
|
|
41
|
-
var path_1 = require("path");
|
|
42
|
-
var PackageJson_1 = require("../services/PackageJson");
|
|
43
|
-
var MigrationsService = /** @class */ (function () {
|
|
44
|
-
function MigrationsService() {
|
|
45
|
-
}
|
|
46
|
-
MigrationsService.executeMigrations = function (tsDevToolsRootPath, absoluteProjectDir, currentVersion) {
|
|
47
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
48
|
-
var migrations, packageJson, packageJsonBackupPath, _i, migrations_1, migration, up, error_1;
|
|
49
|
-
return __generator(this, function (_a) {
|
|
50
|
-
switch (_a.label) {
|
|
51
|
-
case 0:
|
|
52
|
-
migrations = MigrationsService.getAvailableMigrations(tsDevToolsRootPath, absoluteProjectDir, currentVersion);
|
|
53
|
-
packageJson = PackageJson_1.PackageJson.fromDirPath(absoluteProjectDir);
|
|
54
|
-
packageJsonBackupPath = packageJson.backup();
|
|
55
|
-
_a.label = 1;
|
|
56
|
-
case 1:
|
|
57
|
-
_a.trys.push([1, 6, , 7]);
|
|
58
|
-
_i = 0, migrations_1 = migrations;
|
|
59
|
-
_a.label = 2;
|
|
60
|
-
case 2:
|
|
61
|
-
if (!(_i < migrations_1.length)) return [3 /*break*/, 5];
|
|
62
|
-
migration = migrations_1[_i];
|
|
63
|
-
console.info("Applying migration \"" + migration.name + "\"...");
|
|
64
|
-
up = require(migration.path).up;
|
|
65
|
-
// Apply migration
|
|
66
|
-
return [4 /*yield*/, up(absoluteProjectDir)];
|
|
67
|
-
case 3:
|
|
68
|
-
// Apply migration
|
|
69
|
-
_a.sent();
|
|
70
|
-
// Upgrade current version
|
|
71
|
-
PackageJson_1.PackageJson.fromDirPath(absoluteProjectDir).merge({
|
|
72
|
-
tsDevTools: { version: migration.name },
|
|
73
|
-
});
|
|
74
|
-
console.info("Migration \"" + migration.name + "\" applied!");
|
|
75
|
-
_a.label = 4;
|
|
76
|
-
case 4:
|
|
77
|
-
_i++;
|
|
78
|
-
return [3 /*break*/, 2];
|
|
79
|
-
case 5: return [3 /*break*/, 7];
|
|
80
|
-
case 6:
|
|
81
|
-
error_1 = _a.sent();
|
|
82
|
-
// Rollback package.json
|
|
83
|
-
packageJson.restore(packageJsonBackupPath);
|
|
84
|
-
throw error_1;
|
|
85
|
-
case 7:
|
|
86
|
-
fs_1.unlinkSync(packageJsonBackupPath);
|
|
87
|
-
return [2 /*return*/];
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
};
|
|
92
|
-
MigrationsService.getAvailableMigrations = function (tsDevToolsRootPath, absoluteProjectDir, currentVersion) {
|
|
93
|
-
var packageJson = PackageJson_1.PackageJson.fromDirPath(absoluteProjectDir);
|
|
94
|
-
var installedPlugins = packageJson.getInstalledPlugins();
|
|
95
|
-
var migrationFiles = [];
|
|
96
|
-
for (var _i = 0, installedPlugins_1 = installedPlugins; _i < installedPlugins_1.length; _i++) {
|
|
97
|
-
var installedPlugin = installedPlugins_1[_i];
|
|
98
|
-
migrationFiles.push.apply(migrationFiles, MigrationsService.getPluginMigrations(tsDevToolsRootPath, installedPlugin, currentVersion));
|
|
99
|
-
}
|
|
100
|
-
migrationFiles.sort(function (_a, _b) {
|
|
101
|
-
var nameA = _a.name;
|
|
102
|
-
var nameB = _b.name;
|
|
103
|
-
return nameA.localeCompare(nameB);
|
|
104
|
-
});
|
|
105
|
-
return Array.from(new Set(migrationFiles));
|
|
106
|
-
};
|
|
107
|
-
MigrationsService.getPluginMigrations = function (tsDevToolsRootPath, plugin, currentVersion) {
|
|
108
|
-
var pluginDirPath = path_1.resolve(tsDevToolsRootPath, "../../", plugin);
|
|
109
|
-
// First retrieve migration of inherited plugins
|
|
110
|
-
var migrationFiles = MigrationsService.getAvailableMigrations(tsDevToolsRootPath, pluginDirPath, currentVersion);
|
|
111
|
-
// Then retrieve
|
|
112
|
-
var pluginMigrationsDirPath = path_1.resolve(pluginDirPath, "dist/install/migrations");
|
|
113
|
-
for (var _i = 0, _a = fs_1.readdirSync(pluginMigrationsDirPath); _i < _a.length; _i++) {
|
|
114
|
-
var migrationFile = _a[_i];
|
|
115
|
-
if (!migrationFile.match(/^[0-9]{14}-[a-z]+\.(js|ts)$/)) {
|
|
116
|
-
continue;
|
|
117
|
-
}
|
|
118
|
-
var migrationName = migrationFile.split(".").slice(0, -1).join(".");
|
|
119
|
-
var shouldApplyMigration = !currentVersion || currentVersion.localeCompare(migrationName) < 0;
|
|
120
|
-
if (!shouldApplyMigration) {
|
|
121
|
-
continue;
|
|
122
|
-
}
|
|
123
|
-
migrationFiles.push({
|
|
124
|
-
name: plugin + " - " + migrationName,
|
|
125
|
-
path: path_1.resolve(pluginMigrationsDirPath, migrationFile),
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
return migrationFiles;
|
|
129
|
-
};
|
|
130
|
-
return MigrationsService;
|
|
131
|
-
}());
|
|
132
|
-
exports.MigrationsService = MigrationsService;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { PackageJson as PackageJsonType } from "type-fest";
|
|
2
|
-
export declare type JsonArray = boolean[] | number[] | string[] | JsonFileData[] | Date[];
|
|
3
|
-
export declare type AnyJson = boolean | number | string | JsonFileData | Date | JsonArray | JsonArray[];
|
|
4
|
-
export declare type JsonFileData = {
|
|
5
|
-
[key: string]: AnyJson | undefined;
|
|
6
|
-
};
|
|
7
|
-
export declare type PackageJsonContent = JsonFileData & PackageJsonType;
|
|
8
|
-
export declare class PackageJson {
|
|
9
|
-
private path;
|
|
10
|
-
private content?;
|
|
11
|
-
constructor(path: string);
|
|
12
|
-
getPath(): string;
|
|
13
|
-
getContent(): PackageJsonContent;
|
|
14
|
-
setContent(content: PackageJsonContent): void;
|
|
15
|
-
getPackageName(): string | undefined;
|
|
16
|
-
getPackageVersion(): string | undefined;
|
|
17
|
-
isPrivate(): boolean;
|
|
18
|
-
getTsDevToolsVersion(): string | undefined;
|
|
19
|
-
getInstalledPlugins(): string[];
|
|
20
|
-
getDependenciesPackageNames(): string[];
|
|
21
|
-
getDevDependenciesPackageNames(): string[];
|
|
22
|
-
getAllDependenciesPackageNames(): string[];
|
|
23
|
-
merge(update: PackageJsonContent): void;
|
|
24
|
-
backup(): string;
|
|
25
|
-
restore(backupPath: string): void;
|
|
26
|
-
private write;
|
|
27
|
-
static fromDirPath(dirPath: string): PackageJson;
|
|
28
|
-
}
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
3
|
-
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
|
|
4
|
-
to[j] = from[i];
|
|
5
|
-
return to;
|
|
6
|
-
};
|
|
7
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.PackageJson = void 0;
|
|
9
|
-
var fs_1 = require("fs");
|
|
10
|
-
var path_1 = require("path");
|
|
11
|
-
var PackageJsonMerge_1 = require("./PackageJsonMerge");
|
|
12
|
-
var PackageJson = /** @class */ (function () {
|
|
13
|
-
function PackageJson(path) {
|
|
14
|
-
this.path = path;
|
|
15
|
-
this.content = undefined;
|
|
16
|
-
if (!fs_1.existsSync(this.path)) {
|
|
17
|
-
throw new Error("Package.json \"" + this.path + "\" does not exist");
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
PackageJson.prototype.getPath = function () {
|
|
21
|
-
return this.path;
|
|
22
|
-
};
|
|
23
|
-
PackageJson.prototype.getContent = function () {
|
|
24
|
-
if (this.content) {
|
|
25
|
-
return this.content;
|
|
26
|
-
}
|
|
27
|
-
return (this.content = JSON.parse(fs_1.readFileSync(this.path, "utf-8")));
|
|
28
|
-
};
|
|
29
|
-
PackageJson.prototype.setContent = function (content) {
|
|
30
|
-
this.content = content;
|
|
31
|
-
this.write();
|
|
32
|
-
};
|
|
33
|
-
PackageJson.prototype.getPackageName = function () {
|
|
34
|
-
return this.getContent().name;
|
|
35
|
-
};
|
|
36
|
-
PackageJson.prototype.getPackageVersion = function () {
|
|
37
|
-
return this.getContent().version;
|
|
38
|
-
};
|
|
39
|
-
PackageJson.prototype.isPrivate = function () {
|
|
40
|
-
return this.getContent().private === true;
|
|
41
|
-
};
|
|
42
|
-
PackageJson.prototype.getTsDevToolsVersion = function () {
|
|
43
|
-
var tsDevToolsConfig = this.getContent().tsDevTools;
|
|
44
|
-
var version = tsDevToolsConfig === null || tsDevToolsConfig === void 0 ? void 0 : tsDevToolsConfig.version;
|
|
45
|
-
return version;
|
|
46
|
-
};
|
|
47
|
-
PackageJson.prototype.getInstalledPlugins = function () {
|
|
48
|
-
var allDependenciesPackageNames = this.getAllDependenciesPackageNames();
|
|
49
|
-
if (!allDependenciesPackageNames.length) {
|
|
50
|
-
return [];
|
|
51
|
-
}
|
|
52
|
-
var plugins = allDependenciesPackageNames.filter(function (packageName) {
|
|
53
|
-
return packageName.match(/^@ts-dev-tools\/.*$/);
|
|
54
|
-
});
|
|
55
|
-
var sortPlugins = function (pluginA, pluginB) { return pluginA.localeCompare(pluginB); };
|
|
56
|
-
plugins.sort(sortPlugins);
|
|
57
|
-
return plugins;
|
|
58
|
-
};
|
|
59
|
-
PackageJson.prototype.getDependenciesPackageNames = function () {
|
|
60
|
-
var dependencies = this.getContent().dependencies;
|
|
61
|
-
return dependencies ? Object.keys(dependencies) : [];
|
|
62
|
-
};
|
|
63
|
-
PackageJson.prototype.getDevDependenciesPackageNames = function () {
|
|
64
|
-
var devDependencies = this.getContent().devDependencies;
|
|
65
|
-
return devDependencies ? Object.keys(devDependencies) : [];
|
|
66
|
-
};
|
|
67
|
-
PackageJson.prototype.getAllDependenciesPackageNames = function () {
|
|
68
|
-
return Array.from(new Set(__spreadArray(__spreadArray([], this.getDependenciesPackageNames()), this.getDevDependenciesPackageNames())));
|
|
69
|
-
};
|
|
70
|
-
PackageJson.prototype.merge = function (update) {
|
|
71
|
-
this.content = PackageJsonMerge_1.PackageJsonMerge.merge(this.getContent(), update);
|
|
72
|
-
this.write();
|
|
73
|
-
};
|
|
74
|
-
PackageJson.prototype.backup = function () {
|
|
75
|
-
var backupPath = this.path + ".backup";
|
|
76
|
-
fs_1.copyFileSync(this.path, backupPath);
|
|
77
|
-
return backupPath;
|
|
78
|
-
};
|
|
79
|
-
PackageJson.prototype.restore = function (backupPath) {
|
|
80
|
-
fs_1.copyFileSync(backupPath, this.path);
|
|
81
|
-
this.content = undefined;
|
|
82
|
-
};
|
|
83
|
-
PackageJson.prototype.write = function () {
|
|
84
|
-
fs_1.writeFileSync(this.path, JSON.stringify(this.content, null, 2));
|
|
85
|
-
};
|
|
86
|
-
PackageJson.fromDirPath = function (dirPath) {
|
|
87
|
-
var packageJsonPath = path_1.join(dirPath, "package.json");
|
|
88
|
-
if (!fs_1.existsSync(packageJsonPath)) {
|
|
89
|
-
throw new Error("No package.json found in directory \"" + dirPath + "\"");
|
|
90
|
-
}
|
|
91
|
-
return new PackageJson(packageJsonPath);
|
|
92
|
-
};
|
|
93
|
-
return PackageJson;
|
|
94
|
-
}());
|
|
95
|
-
exports.PackageJson = PackageJson;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { PackageJsonContent } from "./PackageJson";
|
|
2
|
-
export declare class PackageJsonMerge {
|
|
3
|
-
static merge(source: PackageJsonContent, update: PackageJsonContent): PackageJsonContent;
|
|
4
|
-
private static mergeValues;
|
|
5
|
-
private static mergeObjects;
|
|
6
|
-
private static mergeArrays;
|
|
7
|
-
private static typesEqual;
|
|
8
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PackageJsonMerge = void 0;
|
|
4
|
-
var PackageJsonMerge = /** @class */ (function () {
|
|
5
|
-
function PackageJsonMerge() {
|
|
6
|
-
}
|
|
7
|
-
PackageJsonMerge.merge = function (source, update) {
|
|
8
|
-
return PackageJsonMerge.mergeObjects(source, update);
|
|
9
|
-
};
|
|
10
|
-
PackageJsonMerge.mergeValues = function (source, update) {
|
|
11
|
-
if (source === undefined) {
|
|
12
|
-
return update;
|
|
13
|
-
}
|
|
14
|
-
if (!PackageJsonMerge.typesEqual(source, update)) {
|
|
15
|
-
throw new Error("Unable to merge package json value because types are different");
|
|
16
|
-
}
|
|
17
|
-
// Deal with arrays
|
|
18
|
-
if (Array.isArray(update)) {
|
|
19
|
-
return PackageJsonMerge.mergeArrays(source, update);
|
|
20
|
-
}
|
|
21
|
-
// Deal with objects
|
|
22
|
-
if (typeof update === "object") {
|
|
23
|
-
return PackageJsonMerge.mergeObjects(source, update);
|
|
24
|
-
}
|
|
25
|
-
return update;
|
|
26
|
-
};
|
|
27
|
-
PackageJsonMerge.mergeObjects = function (source, update) {
|
|
28
|
-
var updateKeys = Object.keys(update);
|
|
29
|
-
for (var _i = 0, updateKeys_1 = updateKeys; _i < updateKeys_1.length; _i++) {
|
|
30
|
-
var updateKey = updateKeys_1[_i];
|
|
31
|
-
source[updateKey] = PackageJsonMerge.mergeValues(source[updateKey], update[updateKey]);
|
|
32
|
-
}
|
|
33
|
-
return source;
|
|
34
|
-
};
|
|
35
|
-
PackageJsonMerge.mergeArrays = function (source, update) {
|
|
36
|
-
for (var _i = 0, update_1 = update; _i < update_1.length; _i++) {
|
|
37
|
-
var item = update_1[_i];
|
|
38
|
-
if (!source.includes(item)) {
|
|
39
|
-
source.push(item);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return source;
|
|
43
|
-
};
|
|
44
|
-
PackageJsonMerge.typesEqual = function (sourceValue, updateValue) {
|
|
45
|
-
if (Array.isArray(sourceValue) && !Array.isArray(updateValue)) {
|
|
46
|
-
return false;
|
|
47
|
-
}
|
|
48
|
-
return typeof sourceValue === typeof updateValue;
|
|
49
|
-
};
|
|
50
|
-
return PackageJsonMerge;
|
|
51
|
-
}());
|
|
52
|
-
exports.PackageJsonMerge = PackageJsonMerge;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PackageManagerService = exports.PackageManagerType = void 0;
|
|
4
|
-
var fs_1 = require("fs");
|
|
5
|
-
var path_1 = require("path");
|
|
6
|
-
var PackageManagerType;
|
|
7
|
-
(function (PackageManagerType) {
|
|
8
|
-
PackageManagerType["yarn"] = "yarn";
|
|
9
|
-
PackageManagerType["npm"] = "npm";
|
|
10
|
-
})(PackageManagerType = exports.PackageManagerType || (exports.PackageManagerType = {}));
|
|
11
|
-
var PackageManagerService = /** @class */ (function () {
|
|
12
|
-
function PackageManagerService() {
|
|
13
|
-
}
|
|
14
|
-
PackageManagerService.detectPackageManager = function (dirPath) {
|
|
15
|
-
if (fs_1.existsSync(path_1.join(dirPath, "yarn.lock"))) {
|
|
16
|
-
return PackageManagerType.yarn;
|
|
17
|
-
}
|
|
18
|
-
return PackageManagerType.npm;
|
|
19
|
-
};
|
|
20
|
-
return PackageManagerService;
|
|
21
|
-
}());
|
|
22
|
-
exports.PackageManagerService = PackageManagerService;
|
package/dist/tests/console.d.ts
DELETED
package/dist/tests/console.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getConsoleInfoContent = exports.resetMockedConsoleInfo = exports.mockConsoleInfo = void 0;
|
|
4
|
-
var info = console.info;
|
|
5
|
-
function mockConsoleInfo() {
|
|
6
|
-
console.info = jest.fn();
|
|
7
|
-
}
|
|
8
|
-
exports.mockConsoleInfo = mockConsoleInfo;
|
|
9
|
-
function resetMockedConsoleInfo() {
|
|
10
|
-
console.info = info;
|
|
11
|
-
}
|
|
12
|
-
exports.resetMockedConsoleInfo = resetMockedConsoleInfo;
|
|
13
|
-
function getConsoleInfoContent() {
|
|
14
|
-
var _a;
|
|
15
|
-
var calls = (_a = console.info) === null || _a === void 0 ? void 0 : _a.mock.calls;
|
|
16
|
-
return calls.flat().join("\n");
|
|
17
|
-
}
|
|
18
|
-
exports.getConsoleInfoContent = getConsoleInfoContent;
|
package/dist/tests/utils.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export declare const testProjectDir: string;
|
|
2
|
-
export declare function createTestProjectDir(filename: string): string;
|
|
3
|
-
export declare function getTsDevToolsRootPath(filename: string): string;
|
|
4
|
-
export declare function restorePackageJson(filename: string): void;
|
|
5
|
-
export declare function removeTestProjectDir(filename: string): void;
|
package/dist/tests/utils.js
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.removeTestProjectDir = exports.restorePackageJson = exports.getTsDevToolsRootPath = exports.createTestProjectDir = exports.testProjectDir = void 0;
|
|
4
|
-
var fs_1 = require("fs");
|
|
5
|
-
var os_1 = require("os");
|
|
6
|
-
var path_1 = require("path");
|
|
7
|
-
exports.testProjectDir = path_1.resolve("__tests__/test-project");
|
|
8
|
-
var getTestProjectDirPath = function (filename) {
|
|
9
|
-
return path_1.join(os_1.tmpdir(), path_1.basename(filename).split(".")[0]);
|
|
10
|
-
};
|
|
11
|
-
var defaultPackageJsonPath = path_1.join(exports.testProjectDir, "package.json");
|
|
12
|
-
function createTestProjectDir(filename) {
|
|
13
|
-
var testProjectDirPath = getTestProjectDirPath(filename);
|
|
14
|
-
if (fs_1.existsSync(testProjectDirPath)) {
|
|
15
|
-
deleteFolderRecursive(testProjectDirPath);
|
|
16
|
-
}
|
|
17
|
-
fs_1.mkdirSync(testProjectDirPath);
|
|
18
|
-
fs_1.mkdirSync(path_1.join(testProjectDirPath, ".git"));
|
|
19
|
-
// Fake node_modules
|
|
20
|
-
var tsDevToolsRootPath = getTsDevToolsRootPath(filename);
|
|
21
|
-
fs_1.mkdirSync(tsDevToolsRootPath, { recursive: true });
|
|
22
|
-
fs_1.copyFileSync(path_1.resolve(__dirname, "../../package.json"), path_1.join(tsDevToolsRootPath, "package.json"));
|
|
23
|
-
// Fake migrations
|
|
24
|
-
var tsDevToolsDistPath = path_1.join(tsDevToolsRootPath, "dist");
|
|
25
|
-
fs_1.symlinkSync(path_1.resolve(__dirname, ".."), tsDevToolsDistPath);
|
|
26
|
-
restorePackageJson(filename);
|
|
27
|
-
return testProjectDirPath;
|
|
28
|
-
}
|
|
29
|
-
exports.createTestProjectDir = createTestProjectDir;
|
|
30
|
-
function getTsDevToolsRootPath(filename) {
|
|
31
|
-
var testProjectDirPath = getTestProjectDirPath(filename);
|
|
32
|
-
if (!fs_1.existsSync(testProjectDirPath)) {
|
|
33
|
-
throw new Error("Test project dir \"" + testProjectDirPath + "\" does not exist");
|
|
34
|
-
}
|
|
35
|
-
return path_1.join(testProjectDirPath, "node_modules/@ts-dev-tools/core");
|
|
36
|
-
}
|
|
37
|
-
exports.getTsDevToolsRootPath = getTsDevToolsRootPath;
|
|
38
|
-
function restorePackageJson(filename) {
|
|
39
|
-
var testProjectDirPath = getTestProjectDirPath(filename);
|
|
40
|
-
if (!fs_1.existsSync(testProjectDirPath)) {
|
|
41
|
-
throw new Error("Test project dir \"" + testProjectDirPath + "\" does not exist");
|
|
42
|
-
}
|
|
43
|
-
fs_1.copyFileSync(defaultPackageJsonPath, path_1.join(testProjectDirPath, "package.json"));
|
|
44
|
-
}
|
|
45
|
-
exports.restorePackageJson = restorePackageJson;
|
|
46
|
-
function removeTestProjectDir(filename) {
|
|
47
|
-
var testProjectDirPath = getTestProjectDirPath(filename);
|
|
48
|
-
if (!fs_1.existsSync(testProjectDirPath)) {
|
|
49
|
-
throw new Error("Test project dir \"" + testProjectDirPath + "\" does not exist");
|
|
50
|
-
}
|
|
51
|
-
deleteFolderRecursive(testProjectDirPath);
|
|
52
|
-
}
|
|
53
|
-
exports.removeTestProjectDir = removeTestProjectDir;
|
|
54
|
-
function deleteFolderRecursive(path) {
|
|
55
|
-
if (fs_1.existsSync(path)) {
|
|
56
|
-
fs_1.readdirSync(path).forEach(function (file) {
|
|
57
|
-
var curPath = path_1.join(path, file);
|
|
58
|
-
if (fs_1.lstatSync(curPath).isDirectory()) {
|
|
59
|
-
// recurse
|
|
60
|
-
deleteFolderRecursive(curPath);
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
// delete file
|
|
64
|
-
fs_1.unlinkSync(curPath);
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
fs_1.rmdirSync(path);
|
|
68
|
-
}
|
|
69
|
-
}
|