Skip to content

Commit d9ca9d0

Browse files
committed
Require Node.js 18 and npm 9
1 parent c31c2bc commit d9ca9d0

10 files changed

+49
-71
lines changed

.github/workflows/main.yml

+2-4
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,10 @@ jobs:
1010
fail-fast: false
1111
matrix:
1212
node-version:
13-
- 19
1413
- 18
15-
- 16
1614
steps:
17-
- uses: actions/checkout@v3
18-
- uses: actions/setup-node@v3
15+
- uses: actions/checkout@v4
16+
- uses: actions/setup-node@v4
1917
with:
2018
node-version: ${{ matrix.node-version }}
2119
- run: git config --global user.name "Github Actions"

package.json

+15-15
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
"type": "module",
99
"bin": "source/cli.js",
1010
"engines": {
11-
"node": ">=16.6.0",
12-
"npm": ">=7.19.0",
11+
"node": ">=18",
12+
"npm": ">=9",
1313
"git": ">=2.11.0",
1414
"yarn": ">=1.7.0"
1515
},
@@ -33,52 +33,52 @@
3333
"dependencies": {
3434
"chalk": "^5.3.0",
3535
"chalk-template": "^1.1.0",
36-
"cosmiconfig": "^8.1.3",
36+
"cosmiconfig": "^8.3.6",
3737
"del": "^7.1.0",
3838
"escape-goat": "^4.0.0",
3939
"escape-string-regexp": "^5.0.0",
4040
"execa": "^8.0.1",
4141
"exit-hook": "^4.0.0",
4242
"github-url-from-git": "^1.5.0",
4343
"has-yarn": "^3.0.0",
44-
"hosted-git-info": "^7.0.0",
44+
"hosted-git-info": "^7.0.1",
4545
"ignore-walk": "^6.0.3",
4646
"import-local": "^3.1.0",
47-
"inquirer": "^9.2.10",
47+
"inquirer": "^9.2.11",
4848
"is-installed-globally": "^0.4.0",
4949
"is-interactive": "^2.0.0",
5050
"is-scoped": "^3.0.0",
5151
"issue-regex": "^4.1.0",
5252
"listr": "^0.14.3",
5353
"listr-input": "^0.2.1",
54-
"log-symbols": "^5.1.0",
54+
"log-symbols": "^6.0.0",
5555
"meow": "^12.1.1",
5656
"new-github-release-url": "^2.0.0",
57-
"npm-name": "^7.1.0",
57+
"npm-name": "^7.1.1",
5858
"onetime": "^6.0.0",
5959
"open": "^9.1.0",
6060
"ow": "^1.1.1",
6161
"p-memoize": "^7.1.1",
6262
"p-timeout": "^6.1.2",
6363
"path-exists": "^5.0.0",
64-
"pkg-dir": "^7.0.0",
65-
"read-pkg": "^8.1.0",
66-
"read-pkg-up": "^10.1.0",
64+
"pkg-dir": "^8.0.0",
65+
"read-pkg": "^9.0.0",
66+
"read-package-up": "^11.0.0",
6767
"rxjs": "^7.8.1",
6868
"semver": "^7.5.4",
6969
"symbol-observable": "^4.0.0",
7070
"terminal-link": "^3.0.0",
71-
"update-notifier": "^6.0.2"
71+
"update-notifier": "^7.0.0"
7272
},
7373
"devDependencies": {
74-
"@sindresorhus/is": "^6.0.0",
75-
"@types/semver": "^7.5.1",
74+
"@sindresorhus/is": "^6.1.0",
75+
"@types/semver": "^7.5.4",
7676
"ava": "^5.3.1",
7777
"common-tags": "^1.8.2",
78-
"esmock": "^2.3.8",
78+
"esmock": "^2.5.9",
7979
"fs-extra": "^11.1.1",
8080
"map-obj": "^5.0.2",
81-
"sinon": "^15.2.0",
81+
"sinon": "^17.0.1",
8282
"strip-ansi": "^7.1.0",
8383
"tempy": "^3.1.0",
8484
"write-pkg": "^6.0.0",

readme.md

+3-5
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@
5454

5555
## Prerequisite
5656

57-
- Node.js 16 or later
58-
- npm 7.19.0 or later
57+
- Node.js 18 or later
58+
- npm 9 or later
5959
- Git 2.11 or later
6060

6161
## Install
@@ -340,14 +340,12 @@ npm ERR! code E403
340340
npm ERR! 403 Forbidden - GET https://registry.yarnpkg.com/-/package/my-awesome-package/collaborators?format=cli - Forbidden
341341
```
342342

343-
…please check whether the command `npm access ls-collaborators my-awesome-package` succeeds. If it doesn't, Yarn has overwritten your registry URL. To fix this, add the correct registry URL to `package.json`:
343+
…please check whether the command `npm access list collaborators my-awesome-package` succeeds. If it doesn't, Yarn has overwritten your registry URL. To fix this, add the correct registry URL to `package.json`:
344344

345345
```json
346346
"publishConfig": {
347347
"registry": "https://registry.npmjs.org"
348348
}
349-
350-
Note: On `npm` v9+, the command has been changed to `npm access list collaborators my-awesome-package`.
351349
```
352350

353351
## Maintainers

source/config.js

+13-17
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,26 @@ import os from 'node:os';
22
import isInstalledGlobally from 'is-installed-globally';
33
import {cosmiconfig} from 'cosmiconfig';
44

5-
// TODO: Remove when cosmiconfig/cosmiconfig#283 lands
6-
const loadESM = async filepath => {
7-
const module = await import(filepath);
8-
return module.default ?? module;
9-
};
5+
export default async function getConfig(rootDirectory) {
6+
const searchDirectory = isInstalledGlobally ? os.homedir() : rootDirectory;
7+
8+
const searchPlaces = [
9+
'.np-config.json',
10+
'.np-config.js',
11+
'.np-config.cjs',
12+
'.np-config.mjs',
13+
];
1014

11-
const getConfig = async rootDir => {
12-
const searchDir = isInstalledGlobally ? os.homedir() : rootDir;
13-
const searchPlaces = ['.np-config.json', '.np-config.js', '.np-config.cjs', '.np-config.mjs'];
1415
if (!isInstalledGlobally) {
1516
searchPlaces.push('package.json');
1617
}
1718

1819
const explorer = cosmiconfig('np', {
1920
searchPlaces,
20-
stopDir: searchDir,
21-
loaders: {
22-
'.js': loadESM,
23-
'.mjs': loadESM,
24-
},
21+
stopDir: searchDirectory,
2522
});
26-
const {config} = (await explorer.search(searchDir)) || {};
2723

28-
return config;
29-
};
24+
const {config} = (await explorer.search(searchDirectory)) ?? {};
3025

31-
export default getConfig;
26+
return config;
27+
}

source/npm/util.js

+3-8
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import pTimeout from 'p-timeout';
55
import ow from 'ow';
66
import npmName from 'npm-name';
77
import chalk from 'chalk-template';
8-
import Version from '../version.js';
98
import * as util from '../util.js';
109

1110
export const version = async () => {
@@ -51,18 +50,14 @@ export const collaborators = async pkg => {
5150
const packageName = pkg.name;
5251
ow(packageName, ow.string);
5352

54-
const npmVersion = await version();
55-
// TODO: Remove old command when targeting Node.js 18
56-
const args = new Version(npmVersion).satisfies('>=9.0.0')
57-
? ['access', 'list', 'collaborators', packageName, '--json']
58-
: ['access', 'ls-collaborators', packageName];
53+
const arguments_ = ['access', 'list', 'collaborators', packageName, '--json'];
5954

6055
if (isExternalRegistry(pkg)) {
61-
args.push('--registry', pkg.publishConfig.registry);
56+
arguments_.push('--registry', pkg.publishConfig.registry);
6257
}
6358

6459
try {
65-
const {stdout} = await execa('npm', args);
60+
const {stdout} = await execa('npm', arguments_);
6661
return stdout;
6762
} catch (error) {
6863
// Ignore non-existing package error

source/util.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import process from 'node:process';
22
import {fileURLToPath} from 'node:url';
33
import path from 'node:path';
4-
import {readPackageUp} from 'read-pkg-up';
4+
import {readPackageUp} from 'read-package-up';
55
import {parsePackage} from 'read-pkg';
66
import issueRegex from 'issue-regex';
77
import terminalLink from 'terminal-link';

test/npm/util/collaborators.js

+2-7
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ test('pkg.name not a string', async t => {
1414
});
1515

1616
const npmVersionFixtures = [
17-
{version: '8.0.0', accessCommand: 'npm access ls-collaborators np'},
1817
{version: '9.0.0', accessCommand: 'npm access list collaborators np --json'},
1918
];
2019

@@ -66,9 +65,7 @@ for (const {version, accessCommand} of npmVersionFixtures) {
6665
test(`npm v${version} - non-existent`, createFixture, [
6766
npmVersionCommand,
6867
{
69-
command: version === '8.0.0'
70-
? 'npm access ls-collaborators non-existent'
71-
: 'npm access list collaborators non-existent --json',
68+
command: 'npm access list collaborators non-existent --json',
7269
stderr: 'npm ERR! code E404\nnpm ERR! 404 Not Found',
7370
},
7471
], async ({t, testedModule: {collaborators}}) => {
@@ -81,9 +78,7 @@ for (const {version, accessCommand} of npmVersionFixtures) {
8178
test(`npm v${version} - error`, createFixture, [
8279
npmVersionCommand,
8380
{
84-
command: version === '8.0.0'
85-
? 'npm access ls-collaborators @private/pkg'
86-
: 'npm access list collaborators @private/pkg --json',
81+
command: 'npm access list collaborators @private/pkg --json',
8782
stderr: 'npm ERR! code E403\nnpm ERR! 403 403 Forbidden',
8883
},
8984
], async ({t, testedModule: {collaborators}}) => {

test/npm/util/verify-recent-npm-version.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const createFixture = _createFixture('../../../source/npm/util.js', import.meta.
66

77
test('satisfied', createFixture, [{
88
command: 'npm --version',
9-
stdout: '7.20.0', // One higher than minimum
9+
stdout: '99.20.0', // Higher than minimum
1010
}], async ({t, testedModule: npm}) => {
1111
await t.notThrowsAsync(
1212
npm.verifyRecentNpmVersion(),
@@ -15,10 +15,10 @@ test('satisfied', createFixture, [{
1515

1616
test('not satisfied', createFixture, [{
1717
command: 'npm --version',
18-
stdout: '7.18.0', // One lower than minimum
18+
stdout: '5.18.0', // Lower than minimum
1919
}], async ({t, testedModule: npm}) => {
2020
await t.throwsAsync(
2121
npm.verifyRecentNpmVersion(),
22-
{message: '`np` requires npm >=7.19.0'},
22+
{message: /`np` requires npm >=/},
2323
);
2424
});

test/tasks/prerequisite-tasks.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ test.serial('should fail when user is not authenticated at npm registry', create
9696
stdout: 'sindresorhus',
9797
},
9898
{
99-
command: 'npm access ls-collaborators test',
99+
command: 'npm access list collaborators test',
100100
stdout: '{"sindresorhus": "read"}',
101101
},
102102
], async ({t, testedModule: prerequisiteTasks}) => {
@@ -117,10 +117,6 @@ test.serial('should fail when user is not authenticated at external registry', c
117117
command: 'npm whoami --registry http://my.io',
118118
stdout: 'sindresorhus',
119119
},
120-
{
121-
command: 'npm access ls-collaborators test --registry http://my.io',
122-
stdout: '{"sindresorhus": "read"}',
123-
},
124120
{
125121
command: 'npm access list collaborators test --json --registry http://my.io',
126122
stdout: '{"sindresorhus": "read"}',

test/util/validate-engine-version-satisfies.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@ const testEngineRanges = test.macro((t, engine, {above, below}) => {
55
const range = npPkg.engines[engine];
66

77
t.notThrows(
8-
() => validateEngineVersionSatisfies(engine, above), // One above minimum
8+
() => validateEngineVersionSatisfies(engine, above), // Above minimum
99
);
1010

1111
t.throws(
12-
() => validateEngineVersionSatisfies(engine, below), // One below minimum
12+
() => validateEngineVersionSatisfies(engine, below), // Below minimum
1313
{message: `\`np\` requires ${engine} ${range}`},
1414
);
1515
});
1616

17-
test('node', testEngineRanges, 'node', {above: '16.7.0', below: '16.5.0'});
17+
test('node', testEngineRanges, 'node', {above: '99.7.0', below: '16.5.0'});
1818

19-
test('npm', testEngineRanges, 'npm', {above: '7.20.0', below: '7.18.0'});
19+
test('npm', testEngineRanges, 'npm', {above: '99.20.0', below: '7.18.0'});
2020

21-
test('git', testEngineRanges, 'git', {above: '2.12.0', below: '2.10.0'});
21+
test('git', testEngineRanges, 'git', {above: '99.12.0', below: '2.10.0'});
2222

23-
test('yarn', testEngineRanges, 'yarn', {above: '1.8.0', below: '1.6.0'});
23+
test('yarn', testEngineRanges, 'yarn', {above: '99.8.0', below: '1.6.0'});
2424

0 commit comments

Comments
 (0)