validate-npm-package-name-cli 2.0.0 → 2.1.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/.eslintrc +1 -0
- package/.nycrc +1 -0
- package/CHANGELOG.md +9 -0
- package/bin.mjs +11 -0
- package/eslint.config.mjs +11 -0
- package/package.json +10 -9
- package/test/bin.mjs +17 -1
package/.eslintrc
CHANGED
package/.nycrc
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,15 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [v2.1.0](https://github.com/ljharb/validate-npm-package-name-cli/compare/v2.0.0...v2.1.0) - 2025-12-26
|
|
9
|
+
|
|
10
|
+
### Commits
|
|
11
|
+
|
|
12
|
+
- [New] pass for invalid but preexisting packages [`66652e7`](https://github.com/ljharb/validate-npm-package-name-cli/commit/66652e7f4aeabf9a81c66b68569950e220c21d99)
|
|
13
|
+
- [Dev Deps] update `eslint`, `@ljharb/eslint-config` [`d28c6f2`](https://github.com/ljharb/validate-npm-package-name-cli/commit/d28c6f26c94531e8e34e434fff8c6d60b4ea1836)
|
|
14
|
+
- [Deps] update `pargs`, `validate-npm-package-name` [`cea9494`](https://github.com/ljharb/validate-npm-package-name-cli/commit/cea9494dbe6323730d2f46ce144166f18a085094)
|
|
15
|
+
- [Dev Deps] update `npmignore` [`416fbc7`](https://github.com/ljharb/validate-npm-package-name-cli/commit/416fbc7c204d07a74dd778bcba30bf73297bfb71)
|
|
16
|
+
|
|
8
17
|
## [v2.0.0](https://github.com/ljharb/validate-npm-package-name-cli/compare/v1.0.0...v2.0.0) - 2025-10-31
|
|
9
18
|
|
|
10
19
|
### Commits
|
package/bin.mjs
CHANGED
|
@@ -17,12 +17,23 @@ import validate from 'validate-npm-package-name';
|
|
|
17
17
|
|
|
18
18
|
const {
|
|
19
19
|
validForNewPackages,
|
|
20
|
+
validForOldPackages,
|
|
20
21
|
warnings,
|
|
21
22
|
errors: validateErrors,
|
|
22
23
|
} = validate(packageName);
|
|
23
24
|
|
|
25
|
+
/** @type {boolean | null} */
|
|
26
|
+
let existsOnNpm = null;
|
|
27
|
+
if (!validForNewPackages && validForOldPackages) {
|
|
28
|
+
const res = await fetch(`https://registry.npmjs.org/${encodeURIComponent(packageName)}`);
|
|
29
|
+
existsOnNpm = res.ok;
|
|
30
|
+
}
|
|
31
|
+
|
|
24
32
|
if (validForNewPackages) {
|
|
25
33
|
console.log(styleText('green', packageName));
|
|
34
|
+
} else if (validForOldPackages && existsOnNpm) {
|
|
35
|
+
warnings?.forEach((warning) => console.warn(styleText('yellow', warning)));
|
|
36
|
+
console.log(styleText(['dim', 'green'], packageName));
|
|
26
37
|
} else {
|
|
27
38
|
warnings?.forEach((warning) => console.warn(styleText('yellow', warning)));
|
|
28
39
|
validateErrors?.forEach((error) => console.error(styleText('red', error)));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "validate-npm-package-name-cli",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "CLI for npmjs.com/validate-npm-package-name - give me a string and I'll tell you if it's a valid npm package name",
|
|
5
5
|
"bin": "./bin.mjs",
|
|
6
6
|
"main": false,
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
"prepack": "npmignore --auto --commentLines=autogenerated",
|
|
12
12
|
"prepublish": "not-in-publish || npm run prepublishOnly",
|
|
13
13
|
"prepublishOnly": "safe-publish-latest",
|
|
14
|
-
"lint": "eslint
|
|
15
|
-
"postlint": "tsc
|
|
14
|
+
"lint": "eslint .",
|
|
15
|
+
"postlint": "tsc",
|
|
16
16
|
"pretest": "npm run lint",
|
|
17
17
|
"tests-only": "c8 tape 'test/**/*.mjs'",
|
|
18
18
|
"test": "npm run tests-only",
|
|
@@ -40,21 +40,22 @@
|
|
|
40
40
|
},
|
|
41
41
|
"homepage": "https://github.com/ljharb/validate-npm-package-name-cli#readme",
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"pargs": "1.1",
|
|
44
|
-
"validate-npm-package-name": "^
|
|
43
|
+
"pargs": "^1.2.1",
|
|
44
|
+
"validate-npm-package-name": "^7.0.1"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@
|
|
48
|
-
"@ljharb/eslint-config": "^21.2.0",
|
|
47
|
+
"@ljharb/eslint-config": "^22.1.3",
|
|
49
48
|
"@ljharb/tsconfig": "^0.3.2",
|
|
49
|
+
"@types/is-core-module": "^2.2.2",
|
|
50
50
|
"@types/node": "^22.18.13",
|
|
51
51
|
"@types/tape": "^5.8.1",
|
|
52
52
|
"@types/validate-npm-package-name": "^4.0.2",
|
|
53
53
|
"auto-changelog": "^2.5.0",
|
|
54
54
|
"c8": "^10.1.3",
|
|
55
|
-
"eslint": "
|
|
55
|
+
"eslint": "^9.39.2",
|
|
56
56
|
"in-publish": "^2.0.1",
|
|
57
|
-
"
|
|
57
|
+
"is-core-module": "^2.16.1",
|
|
58
|
+
"npmignore": "^0.3.5",
|
|
58
59
|
"safe-publish-latest": "^2.0.0",
|
|
59
60
|
"tape": "^5.9.0",
|
|
60
61
|
"typescript": "next",
|
package/test/bin.mjs
CHANGED
|
@@ -59,15 +59,31 @@ test('cli', async (t) => {
|
|
|
59
59
|
const y = /** @type {const} */ ([
|
|
60
60
|
'es-abstract',
|
|
61
61
|
'jsonstream',
|
|
62
|
+
'json',
|
|
62
63
|
...Object.keys(pkgJSON.dependencies),
|
|
63
64
|
...Object.keys(pkgJSON.devDependencies),
|
|
64
65
|
]);
|
|
65
66
|
|
|
66
67
|
await Promise.all(y.map((pkg) => run(t, pkg, { out: pkg, outC: styleText('green', pkg) })));
|
|
67
68
|
|
|
69
|
+
// packages that exist on npm but are only validForOldPackages (not validForNewPackages)
|
|
70
|
+
const yOld = /** @type {const} */ ([
|
|
71
|
+
['JSONStream', 'name can no longer contain capital letters'],
|
|
72
|
+
['JSON', 'name can no longer contain capital letters'],
|
|
73
|
+
['path', 'path is a core module name'],
|
|
74
|
+
]);
|
|
75
|
+
|
|
76
|
+
await Promise.all(yOld.map(([pkg, warning]) => run(t, pkg, {
|
|
77
|
+
out: pkg,
|
|
78
|
+
outC: styleText(['dim', 'green'], pkg),
|
|
79
|
+
err: warning,
|
|
80
|
+
errC: styleText('yellow', warning),
|
|
81
|
+
})));
|
|
82
|
+
|
|
68
83
|
const n = /** @type {const} */ ([
|
|
69
84
|
['foo bar', 'name can only contain URL-friendly characters'],
|
|
70
|
-
['
|
|
85
|
+
['worker_threads', '', 'worker_threads is a core module name'],
|
|
86
|
+
['ThisPackageDoesNotExistOnNpm', '', 'name can no longer contain capital letters'],
|
|
71
87
|
]);
|
|
72
88
|
|
|
73
89
|
await Promise.all(n.map(([
|