typesync 0.12.2 → 0.13.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.
- package/lib/cli-util.d.ts +1 -1
- package/lib/cli-util.js +21 -69
- package/lib/cli-util.js.map +1 -1
- package/lib/cli.js +80 -151
- package/lib/cli.js.map +1 -1
- package/lib/config-service.d.ts +10 -1
- package/lib/config-service.js +36 -71
- package/lib/config-service.js.map +1 -1
- package/lib/fs-utils.d.ts +1 -0
- package/lib/fs-utils.js +28 -0
- package/lib/fs-utils.js.map +1 -0
- package/lib/globber.d.ts +4 -4
- package/lib/globber.js +7 -6
- package/lib/globber.js.map +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.js +2 -2
- package/lib/index.js.map +1 -1
- package/lib/package-json-file-service.d.ts +14 -1
- package/lib/package-json-file-service.js +14 -115
- package/lib/package-json-file-service.js.map +1 -1
- package/lib/package-source.d.ts +21 -1
- package/lib/package-source.js +30 -76
- package/lib/package-source.js.map +1 -1
- package/lib/type-syncer.d.ts +7 -3
- package/lib/type-syncer.js +131 -185
- package/lib/type-syncer.js.map +1 -1
- package/lib/types.d.ts +7 -70
- package/lib/types.js.map +1 -1
- package/lib/util.d.ts +4 -16
- package/lib/util.js +33 -163
- package/lib/util.js.map +1 -1
- package/lib/versioning.d.ts +8 -2
- package/lib/versioning.js +5 -5
- package/lib/versioning.js.map +1 -1
- package/lib/workspace-resolver.d.ts +78 -0
- package/lib/workspace-resolver.js +38 -0
- package/lib/workspace-resolver.js.map +1 -0
- package/package.json +6 -3
package/lib/type-syncer.js
CHANGED
|
@@ -1,108 +1,74 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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;
|
|
24
|
-
return g = { next: verb(0), "throw": verb(1), "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 };
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
47
7
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
if (
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
57
24
|
};
|
|
58
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
59
26
|
exports.createTypeSyncer = createTypeSyncer;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
27
|
+
const path = __importStar(require("node:path"));
|
|
28
|
+
const types_1 = require("./types");
|
|
29
|
+
const util_1 = require("./util");
|
|
30
|
+
const versioning_1 = require("./versioning");
|
|
63
31
|
/**
|
|
64
32
|
* Creates a type syncer.
|
|
65
33
|
*
|
|
66
34
|
* @param packageJSONservice
|
|
67
35
|
* @param typeDefinitionSource
|
|
68
36
|
*/
|
|
69
|
-
function createTypeSyncer(packageJSONService, packageSource, configService, globber) {
|
|
70
|
-
|
|
37
|
+
function createTypeSyncer(packageJSONService, workspaceResolverService, packageSource, configService, globber) {
|
|
38
|
+
const fetchPackageInfo = (0, util_1.memoizeAsync)(packageSource.fetch);
|
|
71
39
|
return {
|
|
72
|
-
sync
|
|
40
|
+
sync,
|
|
73
41
|
};
|
|
74
42
|
/**
|
|
75
43
|
* Syncs typings in the specified package.json.
|
|
76
44
|
*/
|
|
77
|
-
function sync(filePath, flags) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
});
|
|
105
|
-
});
|
|
45
|
+
async function sync(filePath, flags) {
|
|
46
|
+
const dryRun = !!flags.dry;
|
|
47
|
+
const [{ file, subPackages }, syncOpts] = await Promise.all([
|
|
48
|
+
getManifests(filePath, globber),
|
|
49
|
+
configService.readConfig(filePath, flags),
|
|
50
|
+
]);
|
|
51
|
+
const syncedFiles = await Promise.all([
|
|
52
|
+
syncFile(filePath, file, syncOpts, dryRun),
|
|
53
|
+
...subPackages.map((p) => syncFile(p, null, syncOpts, dryRun)),
|
|
54
|
+
]);
|
|
55
|
+
return {
|
|
56
|
+
syncedFiles,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Get the `package.json` files and sub-packages.
|
|
61
|
+
*
|
|
62
|
+
* @param filePath
|
|
63
|
+
* @param globber
|
|
64
|
+
*/
|
|
65
|
+
async function getManifests(filePath, globber) {
|
|
66
|
+
const file = await packageJSONService.readPackageFile(filePath);
|
|
67
|
+
const subPackages = await workspaceResolverService.getWorkspaces(file, path.dirname(filePath), globber);
|
|
68
|
+
return {
|
|
69
|
+
file,
|
|
70
|
+
subPackages,
|
|
71
|
+
};
|
|
106
72
|
}
|
|
107
73
|
/**
|
|
108
74
|
* Syncs a single file.
|
|
@@ -112,87 +78,66 @@ function createTypeSyncer(packageJSONService, packageSource, configService, glob
|
|
|
112
78
|
* @param allTypings
|
|
113
79
|
* @param opts
|
|
114
80
|
*/
|
|
115
|
-
function syncFile(filePath, file, opts, dryRun) {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
return [2 /*return*/, {}];
|
|
169
|
-
}
|
|
170
|
-
closestMatchingTypingsVersion = (0, versioning_1.getClosestMatchingVersion)(typePackageInfo.versions, localCodePackage.version);
|
|
171
|
-
version = closestMatchingTypingsVersion.version;
|
|
172
|
-
semverRangeSpecifier = '~';
|
|
173
|
-
used.push(t);
|
|
174
|
-
return [2 /*return*/, (_a = {},
|
|
175
|
-
_a[t.typesPackageName] = semverRangeSpecifier + version,
|
|
176
|
-
_a)];
|
|
177
|
-
}
|
|
178
|
-
});
|
|
179
|
-
}); })).then(util_1.mergeObjects)];
|
|
180
|
-
case 3:
|
|
181
|
-
devDepsToAdd = _b.sent();
|
|
182
|
-
devDeps = packageFile.devDependencies;
|
|
183
|
-
if (!!dryRun) return [3 /*break*/, 5];
|
|
184
|
-
return [4 /*yield*/, packageJSONService.writePackageFile(filePath, __assign(__assign({}, packageFile), { devDependencies: (0, util_1.orderObject)(__assign(__assign({}, devDepsToAdd), devDeps)) }))];
|
|
185
|
-
case 4:
|
|
186
|
-
_b.sent();
|
|
187
|
-
_b.label = 5;
|
|
188
|
-
case 5: return [2 /*return*/, {
|
|
189
|
-
filePath: filePath,
|
|
190
|
-
newTypings: used,
|
|
191
|
-
package: packageFile,
|
|
192
|
-
}];
|
|
193
|
-
}
|
|
81
|
+
async function syncFile(filePath, file, opts, dryRun) {
|
|
82
|
+
const { ignoreDeps, ignorePackages } = opts;
|
|
83
|
+
const packageFile = file ?? (await packageJSONService.readPackageFile(filePath));
|
|
84
|
+
const allLocalPackages = Object.values(types_1.IDependencySection)
|
|
85
|
+
.map((dep) => {
|
|
86
|
+
const section = getDependenciesBySection(packageFile, dep);
|
|
87
|
+
const ignoredSection = ignoreDeps?.includes(dep);
|
|
88
|
+
return getPackagesFromSection(section, ignoredSection, ignorePackages);
|
|
89
|
+
})
|
|
90
|
+
.flat();
|
|
91
|
+
const allPackageNames = (0, util_1.uniq)(allLocalPackages.map((p) => p.name));
|
|
92
|
+
const potentiallyUntypedPackages = getPotentiallyUntypedPackages(allPackageNames);
|
|
93
|
+
// This is pushed to in the inner `map`, because packages that have DT-typings
|
|
94
|
+
// *as well* as internal typings should be excluded.
|
|
95
|
+
const used = [];
|
|
96
|
+
const devDepsToAdd = await Promise.all(potentiallyUntypedPackages.map(async (t) => {
|
|
97
|
+
// Fetch the code package from the source.
|
|
98
|
+
const typePackageInfoPromise = fetchPackageInfo(t.typesPackageName);
|
|
99
|
+
const codePackageInfo = await fetchPackageInfo(t.codePackageName);
|
|
100
|
+
// If the code package was not found, there's nothing else to do.
|
|
101
|
+
if (!codePackageInfo) {
|
|
102
|
+
return {};
|
|
103
|
+
}
|
|
104
|
+
const localCodePackage = allLocalPackages.find((p) => p.name === t.codePackageName);
|
|
105
|
+
// Find the closest matching code package version relative to what's in our package.json
|
|
106
|
+
const closestMatchingCodeVersion = (0, versioning_1.getClosestMatchingVersion)(codePackageInfo.versions, localCodePackage.version);
|
|
107
|
+
// If the closest matching version contains internal typings, don't include it.
|
|
108
|
+
if (closestMatchingCodeVersion.containsInternalTypings) {
|
|
109
|
+
return {};
|
|
110
|
+
}
|
|
111
|
+
// Look for the closest matching typings package.
|
|
112
|
+
const typePackageInfo = await typePackageInfoPromise;
|
|
113
|
+
// If the types package was not found, or if it was deprecated, there's nothing else to do.
|
|
114
|
+
if (!typePackageInfo || typePackageInfo.deprecated) {
|
|
115
|
+
return {};
|
|
116
|
+
}
|
|
117
|
+
// Gets the closest matching typings version, or the newest one.
|
|
118
|
+
const closestMatchingTypingsVersion = (0, versioning_1.getClosestMatchingVersion)(typePackageInfo.versions, localCodePackage.version);
|
|
119
|
+
const version = closestMatchingTypingsVersion.version;
|
|
120
|
+
const semverRangeSpecifier = '~';
|
|
121
|
+
used.push(t);
|
|
122
|
+
return {
|
|
123
|
+
[t.typesPackageName]: semverRangeSpecifier + version,
|
|
124
|
+
};
|
|
125
|
+
})).then(util_1.mergeObjects);
|
|
126
|
+
const devDeps = packageFile.devDependencies;
|
|
127
|
+
if (!dryRun) {
|
|
128
|
+
await packageJSONService.writePackageFile(filePath, {
|
|
129
|
+
...packageFile,
|
|
130
|
+
devDependencies: (0, util_1.orderObject)({
|
|
131
|
+
...devDepsToAdd,
|
|
132
|
+
...devDeps,
|
|
133
|
+
}),
|
|
194
134
|
});
|
|
195
|
-
}
|
|
135
|
+
}
|
|
136
|
+
return {
|
|
137
|
+
filePath,
|
|
138
|
+
newTypings: used,
|
|
139
|
+
package: packageFile,
|
|
140
|
+
};
|
|
196
141
|
}
|
|
197
142
|
}
|
|
198
143
|
/**
|
|
@@ -202,15 +147,15 @@ function createTypeSyncer(packageJSONService, packageSource, configService, glob
|
|
|
202
147
|
* @param allTypings All typings available
|
|
203
148
|
*/
|
|
204
149
|
function getPotentiallyUntypedPackages(allPackageNames) {
|
|
205
|
-
|
|
206
|
-
return (0, util_1.filterMap)(allPackageNames,
|
|
150
|
+
const existingTypings = allPackageNames.filter((x) => x.startsWith('@types/'));
|
|
151
|
+
return (0, util_1.filterMap)(allPackageNames, (p) => {
|
|
207
152
|
// Ignore typings packages themselves.
|
|
208
153
|
if (p.startsWith('@types/')) {
|
|
209
154
|
return false;
|
|
210
155
|
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
156
|
+
const typingsName = getTypingsName(p);
|
|
157
|
+
const fullTypingsPackage = (0, util_1.typed)(p);
|
|
158
|
+
const alreadyHasTyping = existingTypings.some((t) => t === fullTypingsPackage);
|
|
214
159
|
if (alreadyHasTyping) {
|
|
215
160
|
return false;
|
|
216
161
|
}
|
|
@@ -228,10 +173,10 @@ function getPotentiallyUntypedPackages(allPackageNames) {
|
|
|
228
173
|
* @param packageName the package name to generate the typings name for
|
|
229
174
|
*/
|
|
230
175
|
function getTypingsName(packageName) {
|
|
231
|
-
|
|
232
|
-
|
|
176
|
+
const scopeInfo = getPackageScope(packageName);
|
|
177
|
+
let typingsName = packageName;
|
|
233
178
|
if (scopeInfo && scopeInfo[0] !== 'types') {
|
|
234
|
-
typingsName =
|
|
179
|
+
typingsName = `${scopeInfo[0]}__${scopeInfo[1]}`;
|
|
235
180
|
}
|
|
236
181
|
return typingsName;
|
|
237
182
|
}
|
|
@@ -241,8 +186,8 @@ function getTypingsName(packageName) {
|
|
|
241
186
|
* @param packageName Package name to check scope for.
|
|
242
187
|
*/
|
|
243
188
|
function getPackageScope(packageName) {
|
|
244
|
-
|
|
245
|
-
|
|
189
|
+
const EXPR = /^@([^/]+)\/(.*)$/i;
|
|
190
|
+
const matches = EXPR.exec(packageName);
|
|
246
191
|
if (!matches) {
|
|
247
192
|
return null;
|
|
248
193
|
}
|
|
@@ -256,16 +201,17 @@ function getPackageScope(packageName) {
|
|
|
256
201
|
* @param ignorePackages
|
|
257
202
|
*/
|
|
258
203
|
function getPackagesFromSection(section, ignoredSection, ignorePackages) {
|
|
259
|
-
return (0, util_1.filterMap)(Object.keys(section),
|
|
260
|
-
|
|
204
|
+
return (0, util_1.filterMap)(Object.keys(section), (name) => {
|
|
205
|
+
const isTyping = name.startsWith('@types/');
|
|
261
206
|
// Never ignore `@types` packages.
|
|
262
207
|
if (!isTyping) {
|
|
263
208
|
// If it's not a `@types` package, check whether the section or package is ignored.
|
|
264
|
-
|
|
209
|
+
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- We want to check for false as well.
|
|
210
|
+
if (ignoredSection || ignorePackages?.includes(name)) {
|
|
265
211
|
return false;
|
|
266
212
|
}
|
|
267
213
|
}
|
|
268
|
-
return { name
|
|
214
|
+
return { name, version: section[name] };
|
|
269
215
|
});
|
|
270
216
|
}
|
|
271
217
|
/**
|
|
@@ -275,7 +221,7 @@ function getPackagesFromSection(section, ignoredSection, ignorePackages) {
|
|
|
275
221
|
* @param section Package section, eg: dev, peer
|
|
276
222
|
*/
|
|
277
223
|
function getDependenciesBySection(file, section) {
|
|
278
|
-
|
|
224
|
+
const dependenciesSection = (() => {
|
|
279
225
|
switch (section) {
|
|
280
226
|
case types_1.IDependencySection.deps:
|
|
281
227
|
return file.dependencies;
|
|
@@ -287,6 +233,6 @@ function getDependenciesBySection(file, section) {
|
|
|
287
233
|
return file.peerDependencies;
|
|
288
234
|
}
|
|
289
235
|
})();
|
|
290
|
-
return dependenciesSection
|
|
236
|
+
return dependenciesSection ?? {};
|
|
291
237
|
}
|
|
292
238
|
//# sourceMappingURL=type-syncer.js.map
|
package/lib/type-syncer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-syncer.js","sourceRoot":"","sources":["../src/type-syncer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"type-syncer.js","sourceRoot":"","sources":["../src/type-syncer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,4CAyJC;AA3LD,gDAAiC;AAKjC,mCAWgB;AAChB,iCAOe;AACf,6CAAwD;AAGxD;;;;;GAKG;AACH,SAAgB,gBAAgB,CAC9B,kBAAuC,EACvC,wBAAmD,EACnD,aAA6B,EAC7B,aAA6B,EAC7B,OAAiB;IAEjB,MAAM,gBAAgB,GAAG,IAAA,mBAAY,EAAC,aAAa,CAAC,KAAK,CAAC,CAAA;IAE1D,OAAO;QACL,IAAI;KACL,CAAA;IAED;;OAEG;IACH,KAAK,UAAU,IAAI,CACjB,QAAgB,EAChB,KAA6B;QAE7B,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAA;QAC1B,MAAM,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,QAAQ,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;YAC1D,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC;YAC/B,aAAa,CAAC,UAAU,CAAC,QAAQ,EAAE,KAAK,CAAC;SAC1C,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,CAAC,QAAQ,EAAE,CAAC;YACd,mFAAmF;YACnF,+GAA+G;YAC/G,IAAI,cAAc,IAAI,cAAc,EAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;gBACrD,OAAO,KAAK,CAAA;YACd,CAAC;QACH,CAAC;QAED,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,CAAA;IACzC,CAAC,CAAC,CAAA;AACJ,CAAC;AAED;;;;;GAKG;AACH,SAAS,wBAAwB,CAC/B,IAAkB,EAClB,OAA2B;IAE3B,MAAM,mBAAmB,GAAG,CAAC,GAAG,EAAE;QAChC,QAAQ,OAAO,EAAE,CAAC;YAChB,KAAK,0BAAkB,CAAC,IAAI;gBAC1B,OAAO,IAAI,CAAC,YAAY,CAAA;YAC1B,KAAK,0BAAkB,CAAC,GAAG;gBACzB,OAAO,IAAI,CAAC,eAAe,CAAA;YAC7B,KAAK,0BAAkB,CAAC,QAAQ;gBAC9B,OAAO,IAAI,CAAC,oBAAoB,CAAA;YAClC,KAAK,0BAAkB,CAAC,IAAI;gBAC1B,OAAO,IAAI,CAAC,gBAAgB,CAAA;QAChC,CAAC;IACH,CAAC,CAAC,EAAE,CAAA;IACJ,OAAO,mBAAmB,IAAI,EAAE,CAAA;AAClC,CAAC"}
|
package/lib/types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { IWorkspacesSection } from './workspace-resolver';
|
|
1
2
|
/**
|
|
2
3
|
* The guts of the program.
|
|
3
4
|
*/
|
|
@@ -11,60 +12,11 @@ export interface ISyncOptions {
|
|
|
11
12
|
/**
|
|
12
13
|
* Ignore certain deps.
|
|
13
14
|
*/
|
|
14
|
-
ignoreDeps?: IDependencySection
|
|
15
|
+
ignoreDeps?: Array<IDependencySection>;
|
|
15
16
|
/**
|
|
16
17
|
* Ignore certain packages.
|
|
17
18
|
*/
|
|
18
|
-
ignorePackages?: string
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Config Service.
|
|
22
|
-
*/
|
|
23
|
-
export interface IConfigService {
|
|
24
|
-
/**
|
|
25
|
-
* Get typesync config.
|
|
26
|
-
*/
|
|
27
|
-
readConfig(filePath: string, flags: ICLIArguments['flags']): Promise<ISyncOptions>;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Fetches info about a package.
|
|
31
|
-
*/
|
|
32
|
-
export interface IPackageSource {
|
|
33
|
-
/**
|
|
34
|
-
* Fetches package info from an external source.
|
|
35
|
-
*
|
|
36
|
-
* @param packageName
|
|
37
|
-
*/
|
|
38
|
-
fetch(packageName: string): Promise<IPackageInfo | null>;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* File service.
|
|
42
|
-
*/
|
|
43
|
-
export interface IPackageJSONService {
|
|
44
|
-
/**
|
|
45
|
-
* Reads and parses JSON from the specified file. Path is relative to the current working directory.
|
|
46
|
-
*/
|
|
47
|
-
readPackageFile(filePath: string): Promise<IPackageFile>;
|
|
48
|
-
/**
|
|
49
|
-
* Writes the JSON to the specified file.
|
|
50
|
-
*/
|
|
51
|
-
writePackageFile(filePath: string, fileContents: IPackageFile): Promise<void>;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Interface for the Package Info structure.
|
|
55
|
-
*/
|
|
56
|
-
export interface IPackageInfo {
|
|
57
|
-
name: string;
|
|
58
|
-
latestVersion: string;
|
|
59
|
-
deprecated: boolean;
|
|
60
|
-
versions: Array<IPackageVersionInfo>;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Version descriptor for versions returned in remote package info.
|
|
64
|
-
*/
|
|
65
|
-
export interface IPackageVersionInfo {
|
|
66
|
-
version: string;
|
|
67
|
-
containsInternalTypings: boolean;
|
|
19
|
+
ignorePackages?: Array<string>;
|
|
68
20
|
}
|
|
69
21
|
/**
|
|
70
22
|
* Package.json file.
|
|
@@ -75,26 +27,13 @@ export interface IPackageFile {
|
|
|
75
27
|
devDependencies?: IDependenciesSection;
|
|
76
28
|
peerDependencies?: IDependenciesSection;
|
|
77
29
|
optionalDependencies?: IDependenciesSection;
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
[key: string]: any;
|
|
30
|
+
workspaces?: IWorkspacesSection;
|
|
31
|
+
[key: string]: unknown;
|
|
81
32
|
}
|
|
82
33
|
/**
|
|
83
34
|
* Section in package.json representing dependencies.
|
|
84
35
|
*/
|
|
85
|
-
export
|
|
86
|
-
[packageName: string]: string;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Section in package.json representing workspaces (yarn/lerna).
|
|
90
|
-
*/
|
|
91
|
-
export type IWorkspacesSection = Array<string>;
|
|
92
|
-
/**
|
|
93
|
-
* Yarn is a special snowflake.
|
|
94
|
-
*/
|
|
95
|
-
export interface IYarnWorkspacesConfig {
|
|
96
|
-
packages: IWorkspacesSection;
|
|
97
|
-
}
|
|
36
|
+
export type IDependenciesSection = Record<string, string>;
|
|
98
37
|
/**
|
|
99
38
|
* Package + version record, collected from the {"package": "^1.2.3"} sections.
|
|
100
39
|
*/
|
|
@@ -155,8 +94,6 @@ export declare enum IDependencySection {
|
|
|
155
94
|
* CLI arguments.
|
|
156
95
|
*/
|
|
157
96
|
export interface ICLIArguments {
|
|
158
|
-
flags:
|
|
159
|
-
[key: string]: boolean | string | undefined;
|
|
160
|
-
};
|
|
97
|
+
flags: Record<string, boolean | string | undefined>;
|
|
161
98
|
args: Array<string>;
|
|
162
99
|
}
|
package/lib/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AA6FA;;GAEG;AACH,IAAY,kBAKX;AALD,WAAY,kBAAkB;IAC5B,iCAAW,CAAA;IACX,mCAAa,CAAA;IACb,2CAAqB,CAAA;IACrB,mCAAa,CAAA;AACf,CAAC,EALW,kBAAkB,kCAAlB,kBAAkB,QAK7B"}
|
package/lib/util.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { IWorkspacesArray, IWorkspacesSection } from './workspace-resolver';
|
|
2
2
|
/**
|
|
3
3
|
* Returns unique items.
|
|
4
4
|
*
|
|
@@ -38,28 +38,16 @@ export declare function untyped(name: string): string;
|
|
|
38
38
|
* Orders an object.
|
|
39
39
|
* @param source
|
|
40
40
|
*/
|
|
41
|
-
export declare function orderObject<T extends Record<string | number | symbol,
|
|
42
|
-
/**
|
|
43
|
-
* Promisifies the specified function.
|
|
44
|
-
*
|
|
45
|
-
* @param fn
|
|
46
|
-
*/
|
|
47
|
-
export declare function promisify(fn: (...args: any[]) => void): (...args: any[]) => Promise<any>;
|
|
48
|
-
/**
|
|
49
|
-
* Flattens a 2-dimensional array.
|
|
50
|
-
*
|
|
51
|
-
* @param source
|
|
52
|
-
*/
|
|
53
|
-
export declare function flatten<T>(source: Array<Array<T>>): Array<T>;
|
|
41
|
+
export declare function orderObject<T extends Record<string | number | symbol, U>, U>(source: T, comparer?: (a: string, b: string) => number): T;
|
|
54
42
|
/**
|
|
55
43
|
* Async memoize.
|
|
56
44
|
*
|
|
57
45
|
* @param fn
|
|
58
46
|
*/
|
|
59
|
-
export declare function memoizeAsync<U extends
|
|
47
|
+
export declare function memoizeAsync<U extends Array<W>, V, W>(fn: (...args: U) => Promise<V>): (...args: U) => Promise<V>;
|
|
60
48
|
/**
|
|
61
49
|
* Ensures that we have a valid workspaces array.
|
|
62
50
|
*
|
|
63
51
|
* @param data
|
|
64
52
|
*/
|
|
65
|
-
export declare function ensureWorkspacesArray(data?: IWorkspacesSection
|
|
53
|
+
export declare function ensureWorkspacesArray(data?: IWorkspacesSection): IWorkspacesArray;
|