npm-pkg-lint 3.2.3 → 3.3.1
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/README.md +4 -2
- package/dist/index.js +61 -29
- package/dist/index.js.map +3 -3
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -18,9 +18,10 @@ Core principles:
|
|
|
18
18
|
> npx npm-pkg-lint [--tarball my-pkg-1.2.3.tgz} [--pkgfile package.json]
|
|
19
19
|
|
|
20
20
|
```
|
|
21
|
-
usage:
|
|
21
|
+
usage: index.js [-h] [-v] [-t TARBALL] [-p PKGFILE] [--cache CACHE]
|
|
22
|
+
[--allow-types-dependencies] [--ignore-missing-fields]
|
|
22
23
|
|
|
23
|
-
|
|
24
|
+
Opiniated linter for NPM package tarball and package.json metadata
|
|
24
25
|
|
|
25
26
|
optional arguments:
|
|
26
27
|
-h, --help show this help message and exit
|
|
@@ -29,6 +30,7 @@ optional arguments:
|
|
|
29
30
|
specify tarball location
|
|
30
31
|
-p PKGFILE, --pkgfile PKGFILE
|
|
31
32
|
specify package.json location
|
|
33
|
+
--cache CACHE specify cache directory
|
|
32
34
|
--allow-types-dependencies
|
|
33
35
|
allow dependencies to `@types/*`
|
|
34
36
|
--ignore-missing-fields
|
package/dist/index.js
CHANGED
|
@@ -12365,7 +12365,7 @@ var require_merge_stream = __commonJS({
|
|
|
12365
12365
|
var import_argparse = __toESM(require_argparse(), 1);
|
|
12366
12366
|
import { existsSync, createWriteStream as createWriteStream2, readFileSync as readFileSync2, promises as fs4 } from "fs";
|
|
12367
12367
|
import path7 from "path";
|
|
12368
|
-
import { fileURLToPath as
|
|
12368
|
+
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
12369
12369
|
|
|
12370
12370
|
// node_modules/find-up/index.js
|
|
12371
12371
|
import path2 from "path";
|
|
@@ -13327,14 +13327,14 @@ function validateUrl(key, value) {
|
|
|
13327
13327
|
if (value !== value.trim()) {
|
|
13328
13328
|
throw new Error(`"${key}.url" must not have leading or trailing whitespace`);
|
|
13329
13329
|
}
|
|
13330
|
-
const
|
|
13331
|
-
if (
|
|
13330
|
+
const url = new URL(value);
|
|
13331
|
+
if (url.protocol === "git+http:" || url.protocol === "http:") {
|
|
13332
13332
|
throw new Error(`"${key}.url" must use "git+https://" instead of "http://"`);
|
|
13333
13333
|
}
|
|
13334
|
-
if (
|
|
13334
|
+
if (url.protocol !== "git+https:") {
|
|
13335
13335
|
throw new Error(`"${key}.url" must use "git+https://" protocol`);
|
|
13336
13336
|
}
|
|
13337
|
-
if (
|
|
13337
|
+
if (url.host === "") {
|
|
13338
13338
|
throw new Error(`"${key}.url" be a valid url`);
|
|
13339
13339
|
}
|
|
13340
13340
|
}
|
|
@@ -13407,7 +13407,7 @@ function stripFinalNewline(input) {
|
|
|
13407
13407
|
// node_modules/execa/node_modules/npm-run-path/index.js
|
|
13408
13408
|
import process3 from "process";
|
|
13409
13409
|
import path3 from "path";
|
|
13410
|
-
import
|
|
13410
|
+
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
13411
13411
|
|
|
13412
13412
|
// node_modules/execa/node_modules/path-key/index.js
|
|
13413
13413
|
function pathKey(options = {}) {
|
|
@@ -13422,31 +13422,43 @@ function pathKey(options = {}) {
|
|
|
13422
13422
|
}
|
|
13423
13423
|
|
|
13424
13424
|
// node_modules/execa/node_modules/npm-run-path/index.js
|
|
13425
|
-
|
|
13426
|
-
|
|
13427
|
-
|
|
13428
|
-
|
|
13429
|
-
|
|
13430
|
-
|
|
13431
|
-
|
|
13432
|
-
const cwdString = cwd instanceof URL ?
|
|
13433
|
-
|
|
13425
|
+
var npmRunPath = ({
|
|
13426
|
+
cwd = process3.cwd(),
|
|
13427
|
+
path: pathOption = process3.env[pathKey()],
|
|
13428
|
+
preferLocal = true,
|
|
13429
|
+
execPath = process3.execPath,
|
|
13430
|
+
addExecPath = true
|
|
13431
|
+
} = {}) => {
|
|
13432
|
+
const cwdString = cwd instanceof URL ? fileURLToPath3(cwd) : cwd;
|
|
13433
|
+
const cwdPath = path3.resolve(cwdString);
|
|
13434
13434
|
const result = [];
|
|
13435
|
+
if (preferLocal) {
|
|
13436
|
+
applyPreferLocal(result, cwdPath);
|
|
13437
|
+
}
|
|
13438
|
+
if (addExecPath) {
|
|
13439
|
+
applyExecPath(result, execPath, cwdPath);
|
|
13440
|
+
}
|
|
13441
|
+
return [...result, pathOption].join(path3.delimiter);
|
|
13442
|
+
};
|
|
13443
|
+
var applyPreferLocal = (result, cwdPath) => {
|
|
13444
|
+
let previous;
|
|
13435
13445
|
while (previous !== cwdPath) {
|
|
13436
13446
|
result.push(path3.join(cwdPath, "node_modules/.bin"));
|
|
13437
13447
|
previous = cwdPath;
|
|
13438
13448
|
cwdPath = path3.resolve(cwdPath, "..");
|
|
13439
13449
|
}
|
|
13440
|
-
|
|
13441
|
-
|
|
13442
|
-
|
|
13443
|
-
|
|
13450
|
+
};
|
|
13451
|
+
var applyExecPath = (result, execPath, cwdPath) => {
|
|
13452
|
+
const execPathString = execPath instanceof URL ? fileURLToPath3(execPath) : execPath;
|
|
13453
|
+
result.push(path3.resolve(cwdPath, execPathString, ".."));
|
|
13454
|
+
};
|
|
13455
|
+
var npmRunPathEnv = ({ env = process3.env, ...options } = {}) => {
|
|
13444
13456
|
env = { ...env };
|
|
13445
|
-
const
|
|
13446
|
-
options.path = env[
|
|
13447
|
-
env[
|
|
13457
|
+
const pathName = pathKey({ env });
|
|
13458
|
+
options.path = env[pathName];
|
|
13459
|
+
env[pathName] = npmRunPath(options);
|
|
13448
13460
|
return env;
|
|
13449
|
-
}
|
|
13461
|
+
};
|
|
13450
13462
|
|
|
13451
13463
|
// node_modules/execa/node_modules/mimic-fn/index.js
|
|
13452
13464
|
var copyProperty = (to, from, property, ignoreNonConfigurable) => {
|
|
@@ -14986,6 +14998,10 @@ function getFilePath(key) {
|
|
|
14986
14998
|
const filename2 = `${hash.slice(0, 2)}/${hash.slice(2)}.json`;
|
|
14987
14999
|
return path5.join(cacheDir, filename2);
|
|
14988
15000
|
}
|
|
15001
|
+
async function setCacheDirecory(directory2) {
|
|
15002
|
+
await fs3.mkdir(directory2, { recursive: true });
|
|
15003
|
+
cacheDir = directory2;
|
|
15004
|
+
}
|
|
14989
15005
|
async function persistentCacheGet(key) {
|
|
14990
15006
|
if (!enabled) {
|
|
14991
15007
|
return null;
|
|
@@ -15072,7 +15088,12 @@ var ruleId2 = "no-deprecated-dependency";
|
|
|
15072
15088
|
function* getDependencies(pkg) {
|
|
15073
15089
|
const { dependencies = {}, devDependencies = {}, peerDependencies = {} } = pkg;
|
|
15074
15090
|
const allDependencies = { ...dependencies, ...devDependencies, ...peerDependencies };
|
|
15075
|
-
for (
|
|
15091
|
+
for (let [key, version2] of Object.entries(allDependencies)) {
|
|
15092
|
+
if (version2.startsWith("npm:")) {
|
|
15093
|
+
const [newKey, newVersion] = version2.slice("npm:".length).split("@", 2);
|
|
15094
|
+
key = newKey;
|
|
15095
|
+
version2 = newVersion;
|
|
15096
|
+
}
|
|
15076
15097
|
if (key === "@types/node") {
|
|
15077
15098
|
continue;
|
|
15078
15099
|
}
|
|
@@ -15293,8 +15314,8 @@ function* outdatedEngines(pkg) {
|
|
|
15293
15314
|
if (!import_semver2.default.satisfies(expanded, range)) {
|
|
15294
15315
|
continue;
|
|
15295
15316
|
}
|
|
15296
|
-
const nodeRelease = ((parsed == null ? void 0 : parsed.major) ?? 0) || `0.${(parsed == null ? void 0 : parsed.minor) ?? ""}`;
|
|
15297
|
-
const message = `engines.node is satisfied by Node ${nodeRelease} (EOL since ${descriptor.eol})`;
|
|
15317
|
+
const nodeRelease = ((parsed == null ? void 0 : parsed.major) ?? 0) || `0.${String((parsed == null ? void 0 : parsed.minor) ?? "")}`;
|
|
15318
|
+
const message = `engines.node is satisfied by Node ${String(nodeRelease)} (EOL since ${descriptor.eol})`;
|
|
15298
15319
|
yield {
|
|
15299
15320
|
ruleId: ruleId4,
|
|
15300
15321
|
severity: severity2,
|
|
@@ -15314,7 +15335,12 @@ async function* getDeepDependencies(pkg, dependency) {
|
|
|
15314
15335
|
if (!pkgData) {
|
|
15315
15336
|
return;
|
|
15316
15337
|
}
|
|
15317
|
-
for (
|
|
15338
|
+
for (let [key, version2] of Object.entries(pkgData.dependencies ?? {})) {
|
|
15339
|
+
if (version2.startsWith("npm:")) {
|
|
15340
|
+
const [newKey, newVersion] = version2.slice("npm:".length).split("@", 2);
|
|
15341
|
+
key = newKey;
|
|
15342
|
+
version2 = newVersion;
|
|
15343
|
+
}
|
|
15318
15344
|
if (key === "@types/node") {
|
|
15319
15345
|
continue;
|
|
15320
15346
|
}
|
|
@@ -15408,10 +15434,12 @@ function* typesNodeMatchingEngine(pkg) {
|
|
|
15408
15434
|
return;
|
|
15409
15435
|
}
|
|
15410
15436
|
if (typesVersion.major !== nodeVersion.major) {
|
|
15437
|
+
const actualVersion = `v${String(typesVersion.major)}`;
|
|
15438
|
+
const expectedVersion = `v${String(nodeVersion.major)}`;
|
|
15411
15439
|
yield {
|
|
15412
15440
|
ruleId: ruleId6,
|
|
15413
15441
|
severity: severity3,
|
|
15414
|
-
message: `@types/node
|
|
15442
|
+
message: `@types/node ${actualVersion} does not equal engines.node ${expectedVersion}`,
|
|
15415
15443
|
line: 1,
|
|
15416
15444
|
column: 1
|
|
15417
15445
|
};
|
|
@@ -15567,7 +15595,7 @@ function tarballLocation(pkg, pkgPath) {
|
|
|
15567
15595
|
}
|
|
15568
15596
|
|
|
15569
15597
|
// src/index.ts
|
|
15570
|
-
var pkgFilepath =
|
|
15598
|
+
var pkgFilepath = fileURLToPath4(new URL("../package.json", import.meta.url));
|
|
15571
15599
|
var { version } = JSON.parse(readFileSync2(pkgFilepath, "utf-8"));
|
|
15572
15600
|
var PACKAGE_JSON = "package.json";
|
|
15573
15601
|
async function preloadStdin() {
|
|
@@ -15623,6 +15651,7 @@ async function run() {
|
|
|
15623
15651
|
parser.add_argument("-v", "--version", { action: "version", version });
|
|
15624
15652
|
parser.add_argument("-t", "--tarball", { help: "specify tarball location" });
|
|
15625
15653
|
parser.add_argument("-p", "--pkgfile", { help: "specify package.json location" });
|
|
15654
|
+
parser.add_argument("--cache", { help: "specify cache directory" });
|
|
15626
15655
|
parser.add_argument("--allow-types-dependencies", {
|
|
15627
15656
|
action: "store_true",
|
|
15628
15657
|
help: "allow dependencies to `@types/*`"
|
|
@@ -15632,6 +15661,9 @@ async function run() {
|
|
|
15632
15661
|
help: "ignore errors for missing fields (but still checks for empty and valid)"
|
|
15633
15662
|
});
|
|
15634
15663
|
const args = parser.parse_args();
|
|
15664
|
+
if (args.cache) {
|
|
15665
|
+
await setCacheDirecory(args.cache);
|
|
15666
|
+
}
|
|
15635
15667
|
let regenerateReportName = false;
|
|
15636
15668
|
if (args.tarball === "-") {
|
|
15637
15669
|
args.tarball = await preloadStdin();
|