@definitelytyped/dts-critic 0.1.2 → 0.1.4
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/CHANGELOG.md +14 -0
- package/README.md +0 -9
- package/dist/index.d.ts +2 -32
- package/dist/index.js +15 -245
- package/dist/index.js.map +1 -1
- package/dist/index.test.js +0 -50
- package/dist/index.test.js.map +1 -1
- package/index.ts +16 -266
- package/package.json +3 -15
- package/develop.ts +0 -446
- package/dist/develop.d.ts +0 -1
- package/dist/develop.js +0 -354
- package/dist/develop.js.map +0 -1
- package/dist/dt.d.ts +0 -1
- package/dist/dt.js +0 -79
- package/dist/dt.js.map +0 -1
- package/dt.ts +0 -76
package/dist/develop.js
DELETED
|
@@ -1,354 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const fs = require("fs");
|
|
7
|
-
const yargs = require("yargs");
|
|
8
|
-
const headerParser = require("@definitelytyped/header-parser");
|
|
9
|
-
const path = require("path");
|
|
10
|
-
const cp = require("child_process");
|
|
11
|
-
const which_1 = __importDefault(require("which"));
|
|
12
|
-
const index_1 = require("./index");
|
|
13
|
-
const sourcesDir = "sources";
|
|
14
|
-
const downloadsPath = path.join(sourcesDir, "dts-critic-internal/downloads.json");
|
|
15
|
-
const isNpmPath = path.join(sourcesDir, "dts-critic-internal/npm.json");
|
|
16
|
-
function getPackageDownloads(dtName) {
|
|
17
|
-
const npmName = (0, index_1.dtToNpmName)(dtName);
|
|
18
|
-
const url = `https://api.npmjs.org/downloads/point/last-month/${npmName}`;
|
|
19
|
-
const result = JSON.parse(cp.execFileSync(which_1.default.sync("curl"), ["--silent", "-L", url], { encoding: "utf8" }));
|
|
20
|
-
return result.downloads || 0;
|
|
21
|
-
}
|
|
22
|
-
function getAllPackageDownloads(dtPath) {
|
|
23
|
-
if (fs.existsSync(downloadsPath)) {
|
|
24
|
-
return JSON.parse(fs.readFileSync(downloadsPath, { encoding: "utf8" }));
|
|
25
|
-
}
|
|
26
|
-
initDir(path.dirname(downloadsPath));
|
|
27
|
-
const downloads = {};
|
|
28
|
-
const dtTypesPath = getDtTypesPath(dtPath);
|
|
29
|
-
for (const item of fs.readdirSync(dtTypesPath)) {
|
|
30
|
-
const d = getPackageDownloads(item);
|
|
31
|
-
downloads[item] = d;
|
|
32
|
-
}
|
|
33
|
-
fs.writeFileSync(downloadsPath, JSON.stringify(downloads), { encoding: "utf8" });
|
|
34
|
-
return downloads;
|
|
35
|
-
}
|
|
36
|
-
function initDir(path) {
|
|
37
|
-
if (!fs.existsSync(path)) {
|
|
38
|
-
fs.mkdirSync(path);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
function getDtTypesPath(dtBasePath) {
|
|
42
|
-
return path.join(dtBasePath, "types");
|
|
43
|
-
}
|
|
44
|
-
function compareDownloads(downloads, package1, package2) {
|
|
45
|
-
const count1 = downloads[package1] || 0;
|
|
46
|
-
const count2 = downloads[package2] || 0;
|
|
47
|
-
return count1 - count2;
|
|
48
|
-
}
|
|
49
|
-
function getAllIsNpm(dtPath) {
|
|
50
|
-
if (fs.existsSync(isNpmPath)) {
|
|
51
|
-
return JSON.parse(fs.readFileSync(isNpmPath, { encoding: "utf8" }));
|
|
52
|
-
}
|
|
53
|
-
initDir(path.dirname(isNpmPath));
|
|
54
|
-
const isNpm = {};
|
|
55
|
-
const dtTypesPath = getDtTypesPath(dtPath);
|
|
56
|
-
for (const item of fs.readdirSync(dtTypesPath)) {
|
|
57
|
-
isNpm[item] = (0, index_1.getNpmInfo)(item).isNpm;
|
|
58
|
-
}
|
|
59
|
-
fs.writeFileSync(isNpmPath, JSON.stringify(isNpm), { encoding: "utf8" });
|
|
60
|
-
return isNpm;
|
|
61
|
-
}
|
|
62
|
-
function getPopularNpmPackages(count, dtPath) {
|
|
63
|
-
const dtPackages = getDtNpmPackages(dtPath);
|
|
64
|
-
const downloads = getAllPackageDownloads(dtPath);
|
|
65
|
-
dtPackages.sort((a, b) => compareDownloads(downloads, a, b));
|
|
66
|
-
return dtPackages.slice(dtPackages.length - count);
|
|
67
|
-
}
|
|
68
|
-
function getUnpopularNpmPackages(count, dtPath) {
|
|
69
|
-
const dtPackages = getDtNpmPackages(dtPath);
|
|
70
|
-
const downloads = getAllPackageDownloads(dtPath);
|
|
71
|
-
dtPackages.sort((a, b) => compareDownloads(downloads, a, b));
|
|
72
|
-
return dtPackages.slice(0, count);
|
|
73
|
-
}
|
|
74
|
-
function getDtNpmPackages(dtPath) {
|
|
75
|
-
const dtPackages = fs.readdirSync(getDtTypesPath(dtPath));
|
|
76
|
-
const isNpmJson = getAllIsNpm(dtPath);
|
|
77
|
-
return dtPackages.filter((pkg) => isNpmPackage(pkg, /* header */ undefined, isNpmJson));
|
|
78
|
-
}
|
|
79
|
-
function getNonNpm(args) {
|
|
80
|
-
const nonNpm = [];
|
|
81
|
-
const dtTypesPath = getDtTypesPath(args.dtPath);
|
|
82
|
-
const isNpmJson = getAllIsNpm(args.dtPath);
|
|
83
|
-
for (const item of fs.readdirSync(dtTypesPath)) {
|
|
84
|
-
const packageJsonPath = path.join(dtTypesPath, item, "package.json");
|
|
85
|
-
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
|
|
86
|
-
const header = headerParser.validatePackageJson(item, packageJson, headerParser.getTypesVersions(path.join(dtTypesPath, item)));
|
|
87
|
-
if (!isNpmPackage(item, Array.isArray(header) ? undefined : header, isNpmJson)) {
|
|
88
|
-
nonNpm.push(item);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
console.log(`List of non-npm packages on DT:\n${nonNpm.map((name) => `DT name: ${name}\n`).join("")}`);
|
|
92
|
-
}
|
|
93
|
-
function checkAll(args) {
|
|
94
|
-
const dtPackages = fs.readdirSync(getDtTypesPath(args.dtPath));
|
|
95
|
-
checkPackages({ packages: dtPackages, ...args });
|
|
96
|
-
}
|
|
97
|
-
function checkPopular(args) {
|
|
98
|
-
checkPackages({ packages: getPopularNpmPackages(args.count, args.dtPath), ...args });
|
|
99
|
-
}
|
|
100
|
-
function checkUnpopular(args) {
|
|
101
|
-
checkPackages({ packages: getUnpopularNpmPackages(args.count, args.dtPath), ...args });
|
|
102
|
-
}
|
|
103
|
-
function checkPackages(args) {
|
|
104
|
-
const results = args.packages.map((pkg) => doCheck({ package: pkg, ...args }));
|
|
105
|
-
printResults(results, args.json);
|
|
106
|
-
}
|
|
107
|
-
function checkPackage(args) {
|
|
108
|
-
printResults([doCheck(args)], args.json);
|
|
109
|
-
}
|
|
110
|
-
function doCheck(args) {
|
|
111
|
-
const dtPackage = args.package;
|
|
112
|
-
const opts = getOptions(args.mode, args.enableError || []);
|
|
113
|
-
try {
|
|
114
|
-
const dtsPath = path.join(getDtTypesPath(args.dtPath), dtPackage, "index.d.ts");
|
|
115
|
-
const errors = (0, index_1.dtsCritic)(dtsPath, /* sourcePath */ undefined, opts, args.debug);
|
|
116
|
-
return { package: args.package, output: errors };
|
|
117
|
-
}
|
|
118
|
-
catch (e) {
|
|
119
|
-
return { package: args.package, output: e.toString() };
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
function getOptions(modeArg, enabledErrors) {
|
|
123
|
-
const mode = (0, index_1.parseMode)(modeArg);
|
|
124
|
-
if (!mode) {
|
|
125
|
-
throw new Error(`Could not find mode named '${modeArg}'.`);
|
|
126
|
-
}
|
|
127
|
-
switch (mode) {
|
|
128
|
-
case index_1.Mode.NameOnly:
|
|
129
|
-
return { mode };
|
|
130
|
-
case index_1.Mode.Code:
|
|
131
|
-
const errors = getEnabledErrors(enabledErrors);
|
|
132
|
-
return { mode, errors };
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
function getEnabledErrors(errorNames) {
|
|
136
|
-
const errors = [];
|
|
137
|
-
for (const name of errorNames) {
|
|
138
|
-
const error = (0, index_1.parseExportErrorKind)(name);
|
|
139
|
-
if (error === undefined) {
|
|
140
|
-
throw new Error(`Could not find error named '${name}'.`);
|
|
141
|
-
}
|
|
142
|
-
errors.push(error);
|
|
143
|
-
}
|
|
144
|
-
return new Map(errors.map((err) => [err, true]));
|
|
145
|
-
}
|
|
146
|
-
function checkFile(args) {
|
|
147
|
-
console.log(`\tChecking JS file ${args.jsFile} and declaration file ${args.dtsFile}`);
|
|
148
|
-
try {
|
|
149
|
-
const errors = (0, index_1.checkSource)((0, index_1.findDtsName)(args.dtsFile), args.dtsFile, args.jsFile, new Map(), args.debug);
|
|
150
|
-
console.log(formatErrors(errors));
|
|
151
|
-
}
|
|
152
|
-
catch (e) {
|
|
153
|
-
console.log(e);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
function printResults(results, json) {
|
|
157
|
-
if (json) {
|
|
158
|
-
console.log(JSON.stringify(results));
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
for (const result of results) {
|
|
162
|
-
console.log(`\tChecking package ${result.package} ...`);
|
|
163
|
-
if (typeof result.output === "string") {
|
|
164
|
-
console.log(`Exception:\n${result.output}`);
|
|
165
|
-
}
|
|
166
|
-
else {
|
|
167
|
-
console.log(formatErrors(result.output));
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
function formatErrors(errors) {
|
|
172
|
-
const lines = [];
|
|
173
|
-
for (const error of errors) {
|
|
174
|
-
lines.push("Error: " + error.message);
|
|
175
|
-
}
|
|
176
|
-
if (errors.length === 0) {
|
|
177
|
-
lines.push("No errors found! :)");
|
|
178
|
-
}
|
|
179
|
-
return lines.join("\n");
|
|
180
|
-
}
|
|
181
|
-
function isNpmPackage(name, header, isNpmJson = {}) {
|
|
182
|
-
if (header && header.nonNpm)
|
|
183
|
-
return false;
|
|
184
|
-
const isNpm = isNpmJson[name];
|
|
185
|
-
if (isNpm !== undefined) {
|
|
186
|
-
return isNpm;
|
|
187
|
-
}
|
|
188
|
-
return (0, index_1.getNpmInfo)(name).isNpm;
|
|
189
|
-
}
|
|
190
|
-
function main() {
|
|
191
|
-
yargs
|
|
192
|
-
.usage("$0 <command>")
|
|
193
|
-
.command("check-all", "Check source and declaration of all DT packages that are on NPM.", {
|
|
194
|
-
dtPath: {
|
|
195
|
-
type: "string",
|
|
196
|
-
default: "../DefinitelyTyped",
|
|
197
|
-
describe: "Path of DT repository cloned locally.",
|
|
198
|
-
},
|
|
199
|
-
mode: {
|
|
200
|
-
type: "string",
|
|
201
|
-
required: true,
|
|
202
|
-
choices: [index_1.Mode.NameOnly, index_1.Mode.Code],
|
|
203
|
-
describe: "Mode that defines which group of checks will be made.",
|
|
204
|
-
},
|
|
205
|
-
enableError: {
|
|
206
|
-
type: "array",
|
|
207
|
-
string: true,
|
|
208
|
-
describe: "Enable checking for a specific export error.",
|
|
209
|
-
},
|
|
210
|
-
debug: {
|
|
211
|
-
type: "boolean",
|
|
212
|
-
default: false,
|
|
213
|
-
describe: "Turn debug logging on.",
|
|
214
|
-
},
|
|
215
|
-
json: {
|
|
216
|
-
type: "boolean",
|
|
217
|
-
default: false,
|
|
218
|
-
describe: "Format output result as json.",
|
|
219
|
-
},
|
|
220
|
-
}, checkAll)
|
|
221
|
-
.command("check-popular", "Check source and declaration of most popular DT packages that are on NPM.", {
|
|
222
|
-
count: {
|
|
223
|
-
alias: "c",
|
|
224
|
-
type: "number",
|
|
225
|
-
required: true,
|
|
226
|
-
describe: "Number of packages to be checked.",
|
|
227
|
-
},
|
|
228
|
-
dtPath: {
|
|
229
|
-
type: "string",
|
|
230
|
-
default: "../DefinitelyTyped",
|
|
231
|
-
describe: "Path of DT repository cloned locally.",
|
|
232
|
-
},
|
|
233
|
-
mode: {
|
|
234
|
-
type: "string",
|
|
235
|
-
required: true,
|
|
236
|
-
choices: [index_1.Mode.NameOnly, index_1.Mode.Code],
|
|
237
|
-
describe: "Mode that defines which group of checks will be made.",
|
|
238
|
-
},
|
|
239
|
-
enableError: {
|
|
240
|
-
type: "array",
|
|
241
|
-
string: true,
|
|
242
|
-
describe: "Enable checking for a specific export error.",
|
|
243
|
-
},
|
|
244
|
-
debug: {
|
|
245
|
-
type: "boolean",
|
|
246
|
-
default: false,
|
|
247
|
-
describe: "Turn debug logging on.",
|
|
248
|
-
},
|
|
249
|
-
json: {
|
|
250
|
-
type: "boolean",
|
|
251
|
-
default: false,
|
|
252
|
-
describe: "Format output result as json.",
|
|
253
|
-
},
|
|
254
|
-
}, checkPopular)
|
|
255
|
-
.command("check-unpopular", "Check source and declaration of least popular DT packages that are on NPM.", {
|
|
256
|
-
count: {
|
|
257
|
-
alias: "c",
|
|
258
|
-
type: "number",
|
|
259
|
-
required: true,
|
|
260
|
-
describe: "Number of packages to be checked.",
|
|
261
|
-
},
|
|
262
|
-
dtPath: {
|
|
263
|
-
type: "string",
|
|
264
|
-
default: "../DefinitelyTyped",
|
|
265
|
-
describe: "Path of DT repository cloned locally.",
|
|
266
|
-
},
|
|
267
|
-
mode: {
|
|
268
|
-
type: "string",
|
|
269
|
-
required: true,
|
|
270
|
-
choices: [index_1.Mode.NameOnly, index_1.Mode.Code],
|
|
271
|
-
describe: "Mode that defines which group of checks will be made.",
|
|
272
|
-
},
|
|
273
|
-
enableError: {
|
|
274
|
-
type: "array",
|
|
275
|
-
string: true,
|
|
276
|
-
describe: "Enable checking for a specific export error.",
|
|
277
|
-
},
|
|
278
|
-
debug: {
|
|
279
|
-
type: "boolean",
|
|
280
|
-
default: false,
|
|
281
|
-
describe: "Turn debug logging on.",
|
|
282
|
-
},
|
|
283
|
-
json: {
|
|
284
|
-
type: "boolean",
|
|
285
|
-
default: false,
|
|
286
|
-
describe: "Format output result as json.",
|
|
287
|
-
},
|
|
288
|
-
}, checkUnpopular)
|
|
289
|
-
.command("check-package", "Check source and declaration of a DT package.", {
|
|
290
|
-
package: {
|
|
291
|
-
alias: "p",
|
|
292
|
-
type: "string",
|
|
293
|
-
required: true,
|
|
294
|
-
describe: "DT name of a package.",
|
|
295
|
-
},
|
|
296
|
-
dtPath: {
|
|
297
|
-
type: "string",
|
|
298
|
-
default: "../DefinitelyTyped",
|
|
299
|
-
describe: "Path of DT repository cloned locally.",
|
|
300
|
-
},
|
|
301
|
-
mode: {
|
|
302
|
-
type: "string",
|
|
303
|
-
required: true,
|
|
304
|
-
choices: [index_1.Mode.NameOnly, index_1.Mode.Code],
|
|
305
|
-
describe: "Mode that defines which group of checks will be made.",
|
|
306
|
-
},
|
|
307
|
-
enableError: {
|
|
308
|
-
type: "array",
|
|
309
|
-
string: true,
|
|
310
|
-
describe: "Enable checking for a specific export error.",
|
|
311
|
-
},
|
|
312
|
-
debug: {
|
|
313
|
-
type: "boolean",
|
|
314
|
-
default: false,
|
|
315
|
-
describe: "Turn debug logging on.",
|
|
316
|
-
},
|
|
317
|
-
json: {
|
|
318
|
-
type: "boolean",
|
|
319
|
-
default: false,
|
|
320
|
-
describe: "Format output result as json.",
|
|
321
|
-
},
|
|
322
|
-
}, checkPackage)
|
|
323
|
-
.command("check-file", "Check a JavaScript file and its matching declaration file.", {
|
|
324
|
-
jsFile: {
|
|
325
|
-
alias: "j",
|
|
326
|
-
type: "string",
|
|
327
|
-
required: true,
|
|
328
|
-
describe: "Path of JavaScript file.",
|
|
329
|
-
},
|
|
330
|
-
dtsFile: {
|
|
331
|
-
alias: "d",
|
|
332
|
-
type: "string",
|
|
333
|
-
required: true,
|
|
334
|
-
describe: "Path of declaration file.",
|
|
335
|
-
},
|
|
336
|
-
debug: {
|
|
337
|
-
type: "boolean",
|
|
338
|
-
default: false,
|
|
339
|
-
describe: "Turn debug logging on.",
|
|
340
|
-
},
|
|
341
|
-
}, checkFile)
|
|
342
|
-
.command("get-non-npm", "Get list of DT packages whose source package is not on NPM", {
|
|
343
|
-
dtPath: {
|
|
344
|
-
type: "string",
|
|
345
|
-
default: "../DefinitelyTyped",
|
|
346
|
-
describe: "Path of DT repository cloned locally.",
|
|
347
|
-
},
|
|
348
|
-
}, getNonNpm)
|
|
349
|
-
.demandCommand(1)
|
|
350
|
-
.help()
|
|
351
|
-
.parseSync();
|
|
352
|
-
}
|
|
353
|
-
main();
|
|
354
|
-
//# sourceMappingURL=develop.js.map
|
package/dist/develop.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"develop.js","sourceRoot":"","sources":["../develop.ts"],"names":[],"mappings":";;;;;AAAA,yBAA0B;AAC1B,+BAAgC;AAChC,+DAAgE;AAChE,6BAA8B;AAC9B,oCAAqC;AACrC,kDAA0B;AAC1B,mCAYiB;AAEjB,MAAM,UAAU,GAAG,SAAS,CAAC;AAC7B,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,oCAAoC,CAAC,CAAC;AAClF,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,8BAA8B,CAAC,CAAC;AAExE,SAAS,mBAAmB,CAAC,MAAc;IACzC,MAAM,OAAO,GAAG,IAAA,mBAAW,EAAC,MAAM,CAAC,CAAC;IACpC,MAAM,GAAG,GAAG,oDAAoD,OAAO,EAAE,CAAC;IAC1E,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,eAAK,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,UAAU,EAAE,IAAI,EAAE,GAAG,CAAC,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAE3G,CAAC;IACF,OAAO,MAAM,CAAC,SAAS,IAAI,CAAC,CAAC;AAC/B,CAAC;AAMD,SAAS,sBAAsB,CAAC,MAAc;IAC5C,IAAI,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE,CAAC;QACjC,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,aAAa,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAkB,CAAC;IAC3F,CAAC;IAED,OAAO,CAAC,I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,EAAE,KAAK;YACd,QAAQ,EAAE,wBAAwB;SACnC;QACD,IAAI,EAAE;YACJ,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,KAAK;YACd,QAAQ,EAAE,+BAA+B;SAC1C;KACF,EACD,YAAY,CACb;SACA,OAAO,CACN,YAAY,EACZ,4DAA4D,EAC5D;QACE,MAAM,EAAE;YACN,KAAK,EAAE,GAAG;YACV,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,QAAQ,EAAE,0BAA0B;SACrC;QACD,OAAO,EAAE;YACP,KAAK,EAAE,GAAG;YACV,IAAI,EAAE,QAAQ;YACd,QAAQ,EAAE,IAAI;YACd,QAAQ,EAAE,2BAA2B;SACtC;QACD,KAAK,EAAE;YACL,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,KAAK;YACd,QAAQ,EAAE,wBAAwB;SACnC;KACF,EACD,SAAS,CACV;SACA,OAAO,CACN,aAAa,EACb,4DAA4D,EAC5D;QACE,MAAM,EAAE;YACN,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,oBAAoB;YAC7B,QAAQ,EAAE,uCAAuC;SAClD;KACF,EACD,SAAS,CACV;SACA,aAAa,CAAC,CAAC,CAAC;SAChB,IAAI,EAAE;SACN,SAAS,EAAE,CAAC;AACjB,CAAC;AACD,IAAI,EAAE,CAAC"}
|
package/dist/dt.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/dt.js
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const index_1 = require("./index");
|
|
4
|
-
const fs = require("fs");
|
|
5
|
-
const stripJsonComments = require("strip-json-comments");
|
|
6
|
-
function hasNpmNamingLintRule(eslintPath) {
|
|
7
|
-
if (fs.existsSync(eslintPath)) {
|
|
8
|
-
const eslint = JSON.parse(stripJsonComments(fs.readFileSync(eslintPath, "utf-8")));
|
|
9
|
-
if (eslint.rules?.["@definitelytyped/npm-naming"] !== undefined) {
|
|
10
|
-
return !!eslint.rules["@definitelytyped/npm-naming"];
|
|
11
|
-
}
|
|
12
|
-
return true;
|
|
13
|
-
}
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
function addNpmNamingLintRule(eslintPath) {
|
|
17
|
-
if (fs.existsSync(eslintPath)) {
|
|
18
|
-
const eslint = JSON.parse(stripJsonComments(fs.readFileSync(eslintPath, "utf-8")));
|
|
19
|
-
if (eslint.rules) {
|
|
20
|
-
eslint.rules["@definitelytyped/npm-naming"] = false;
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
eslint.rules = { "@definitelytyped/npm-naming": false };
|
|
24
|
-
}
|
|
25
|
-
fs.writeFileSync(eslintPath, JSON.stringify(eslint, undefined, 4), "utf-8");
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
function main() {
|
|
29
|
-
for (const item of fs.readdirSync("../DefinitelyTyped/types")) {
|
|
30
|
-
const entry = "../DefinitelyTyped/types/" + item;
|
|
31
|
-
try {
|
|
32
|
-
if (hasNpmNamingLintRule(entry + "/.eslintrc.json")) {
|
|
33
|
-
const errors = (0, index_1.dtsCritic)(entry + "/index.d.ts");
|
|
34
|
-
for (const error of errors) {
|
|
35
|
-
switch (error.kind) {
|
|
36
|
-
case index_1.ErrorKind.NoMatchingNpmPackage:
|
|
37
|
-
console.log(`No matching npm package found for ` + item);
|
|
38
|
-
// const re = /\/\/ Type definitions for/;
|
|
39
|
-
// const s = fs.readFileSync(entry + '/index.d.ts', 'utf-8')
|
|
40
|
-
// fs.writeFileSync(entry + '/index.d.ts', s.replace(re, '// Type definitions for non-npm package'), 'utf-8')
|
|
41
|
-
break;
|
|
42
|
-
case index_1.ErrorKind.NoDefaultExport:
|
|
43
|
-
console.log("converting", item, "to export = ...");
|
|
44
|
-
const named = /export default function\s+(\w+\s*)\(/;
|
|
45
|
-
const anon = /export default function\s*\(/;
|
|
46
|
-
const id = /export default(\s+\w+);/;
|
|
47
|
-
let s = fs.readFileSync(entry + "/index.d.ts", "utf-8");
|
|
48
|
-
s = s.replace(named, "export = $1;\ndeclare function $1(");
|
|
49
|
-
s = s.replace(anon, "export = _default;\ndeclare function _default(");
|
|
50
|
-
s = s.replace(id, "export =$1;");
|
|
51
|
-
fs.writeFileSync(entry + "/index.d.ts", s, "utf-8");
|
|
52
|
-
break;
|
|
53
|
-
case index_1.ErrorKind.NoMatchingNpmVersion:
|
|
54
|
-
const m = error.message.match(/in the header, ([0-9.]+),[\s\S]to match one on npm: ([0-9., ]+)\./);
|
|
55
|
-
if (m) {
|
|
56
|
-
const headerver = parseFloat(m[1]);
|
|
57
|
-
const npmvers = m[2].split(",").map((s) => parseFloat(s.trim()));
|
|
58
|
-
const fixto = npmvers.every((v) => headerver > v) ? -1.0 : Math.max(...npmvers);
|
|
59
|
-
console.log(`npm-version:${item}:${m[1]}:${m[2]}:${fixto}`);
|
|
60
|
-
addNpmNamingLintRule(entry + "/.eslintrc.json");
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
console.log("could not parse error message: ", error.message);
|
|
64
|
-
}
|
|
65
|
-
break;
|
|
66
|
-
default:
|
|
67
|
-
console.log(error.message);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
catch (e) {
|
|
73
|
-
console.log("*** ERROR for " + item + " ***");
|
|
74
|
-
console.log(e);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
main();
|
|
79
|
-
//# sourceMappingURL=dt.js.map
|
package/dist/dt.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dt.js","sourceRoot":"","sources":["../dt.ts"],"names":[],"mappings":";;AAAA,mCAAyD;AACzD,yBAA0B;AAC1B,yDAA0D;AAE1D,SAAS,oBAAoB,CAAC,UAAkB;IAC9C,IAAI,EAAE,CAAC,UAAU,CAAC,UAAU,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,CAAC,GAAG,CAAC,CAAC,CAAS,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;gCACzE,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAS,EAAE,EAAE,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC;gCACxF,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC;gCAC5D,oBAAoB,CAAC,KAAK,GAAG,iBAAiB,CAAC,CAAC;4BAClD,CAAC;iCAAM,CAAC;gCACN,OAAO,CAAC,GAAG,CAAC,iCAAiC,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;4BAChE,CAAC;4BACD,MAAM;wBACR;4BACE,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;oBAC/B,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,OAAO,CAAC,GAAG,CAAC,gBAAgB,GAAG,IAAI,GAAG,MAAM,CAAC,CAAC;YAC9C,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACjB,CAAC;IACH,CAAC;AACH,CAAC;AACD,IAAI,EAAE,CAAC"}
|
package/dt.ts
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { dtsCritic as critic, ErrorKind } from "./index";
|
|
2
|
-
import fs = require("fs");
|
|
3
|
-
import stripJsonComments = require("strip-json-comments");
|
|
4
|
-
|
|
5
|
-
function hasNpmNamingLintRule(eslintPath: string): boolean {
|
|
6
|
-
if (fs.existsSync(eslintPath)) {
|
|
7
|
-
const eslint = JSON.parse(stripJsonComments(fs.readFileSync(eslintPath, "utf-8")));
|
|
8
|
-
if (eslint.rules?.["@definitelytyped/npm-naming"] !== undefined) {
|
|
9
|
-
return !!eslint.rules["@definitelytyped/npm-naming"];
|
|
10
|
-
}
|
|
11
|
-
return true;
|
|
12
|
-
}
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function addNpmNamingLintRule(eslintPath: string): void {
|
|
17
|
-
if (fs.existsSync(eslintPath)) {
|
|
18
|
-
const eslint = JSON.parse(stripJsonComments(fs.readFileSync(eslintPath, "utf-8")));
|
|
19
|
-
if (eslint.rules) {
|
|
20
|
-
eslint.rules["@definitelytyped/npm-naming"] = false;
|
|
21
|
-
} else {
|
|
22
|
-
eslint.rules = { "@definitelytyped/npm-naming": false };
|
|
23
|
-
}
|
|
24
|
-
fs.writeFileSync(eslintPath, JSON.stringify(eslint, undefined, 4), "utf-8");
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function main() {
|
|
29
|
-
for (const item of fs.readdirSync("../DefinitelyTyped/types")) {
|
|
30
|
-
const entry = "../DefinitelyTyped/types/" + item;
|
|
31
|
-
try {
|
|
32
|
-
if (hasNpmNamingLintRule(entry + "/.eslintrc.json")) {
|
|
33
|
-
const errors = critic(entry + "/index.d.ts");
|
|
34
|
-
for (const error of errors) {
|
|
35
|
-
switch (error.kind) {
|
|
36
|
-
case ErrorKind.NoMatchingNpmPackage:
|
|
37
|
-
console.log(`No matching npm package found for ` + item);
|
|
38
|
-
// const re = /\/\/ Type definitions for/;
|
|
39
|
-
// const s = fs.readFileSync(entry + '/index.d.ts', 'utf-8')
|
|
40
|
-
// fs.writeFileSync(entry + '/index.d.ts', s.replace(re, '// Type definitions for non-npm package'), 'utf-8')
|
|
41
|
-
break;
|
|
42
|
-
case ErrorKind.NoDefaultExport:
|
|
43
|
-
console.log("converting", item, "to export = ...");
|
|
44
|
-
const named = /export default function\s+(\w+\s*)\(/;
|
|
45
|
-
const anon = /export default function\s*\(/;
|
|
46
|
-
const id = /export default(\s+\w+);/;
|
|
47
|
-
let s = fs.readFileSync(entry + "/index.d.ts", "utf-8");
|
|
48
|
-
s = s.replace(named, "export = $1;\ndeclare function $1(");
|
|
49
|
-
s = s.replace(anon, "export = _default;\ndeclare function _default(");
|
|
50
|
-
s = s.replace(id, "export =$1;");
|
|
51
|
-
fs.writeFileSync(entry + "/index.d.ts", s, "utf-8");
|
|
52
|
-
break;
|
|
53
|
-
case ErrorKind.NoMatchingNpmVersion:
|
|
54
|
-
const m = error.message.match(/in the header, ([0-9.]+),[\s\S]to match one on npm: ([0-9., ]+)\./);
|
|
55
|
-
if (m) {
|
|
56
|
-
const headerver = parseFloat(m[1]);
|
|
57
|
-
const npmvers = m[2].split(",").map((s: string) => parseFloat(s.trim()));
|
|
58
|
-
const fixto = npmvers.every((v: number) => headerver > v) ? -1.0 : Math.max(...npmvers);
|
|
59
|
-
console.log(`npm-version:${item}:${m[1]}:${m[2]}:${fixto}`);
|
|
60
|
-
addNpmNamingLintRule(entry + "/.eslintrc.json");
|
|
61
|
-
} else {
|
|
62
|
-
console.log("could not parse error message: ", error.message);
|
|
63
|
-
}
|
|
64
|
-
break;
|
|
65
|
-
default:
|
|
66
|
-
console.log(error.message);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
} catch (e) {
|
|
71
|
-
console.log("*** ERROR for " + item + " ***");
|
|
72
|
-
console.log(e);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
main();
|