diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 441975c..346585c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,10 +10,11 @@ jobs: fail-fast: false matrix: node-version: - - 16 + - 20 + - 18 steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} - run: npm install diff --git a/index.js b/index.js index 8d435cf..218ac6a 100644 --- a/index.js +++ b/index.js @@ -2,9 +2,9 @@ import process from 'node:process'; import path from 'node:path'; import fs from 'node:fs'; import minimist from 'minimist'; -import {readPackageUpSync} from 'read-pkg-up'; -import {writePackageSync} from 'write-pkg'; -import execa from 'execa'; +import {readPackageUpSync} from 'read-package-up'; +import {writePackageSync} from 'write-package'; +import {execa} from 'execa'; import hasYarn from 'has-yarn'; const DEFAULT_TEST_SCRIPT = 'echo "Error: no test specified" && exit 1'; diff --git a/package.json b/package.json index b845c8d..f3b95e6 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "bin": "./cli.js", "exports": "./index.js", "engines": { - "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + "node": ">=18" }, "scripts": { "test": "xo && ava" @@ -35,16 +35,19 @@ "xo" ], "dependencies": { - "execa": "^5.1.1", + "execa": "^8.0.1", "has-yarn": "^3.0.0", - "minimist": "^1.2.5", - "read-pkg-up": "^9.0.0", - "write-pkg": "^5.0.0" + "minimist": "^1.2.8", + "read-package-up": "^11.0.0", + "write-package": "^7.0.0" }, "devDependencies": { - "ava": "^3.15.0", - "dot-prop": "^6.0.1", + "ava": "^5.3.1", + "dot-prop": "^8.0.2", "temp-write": "^5.0.0", - "xo": "^0.45.0" + "xo": "^0.56.0" + }, + "ava": { + "timeout": "10m" } } diff --git a/test.js b/test.js index 6095159..580a31f 100644 --- a/test.js +++ b/test.js @@ -2,12 +2,11 @@ import path from 'node:path'; import fs from 'node:fs'; import process from 'node:process'; import tempWrite from 'temp-write'; -import dotProp from 'dot-prop'; +import {getProperty} from 'dot-prop'; import test from 'ava'; import createXo from './index.js'; const originalArgv = [...process.argv]; -const {get} = dotProp; async function run(pkg) { const filepath = tempWrite.sync(JSON.stringify(pkg), 'package.json'); @@ -22,8 +21,8 @@ async function run(pkg) { test('empty package.json', async t => { const pkg = await run({}); - t.is(get(pkg, 'scripts.test'), 'xo'); - t.is(get(pkg, 'xo'), undefined); + t.is(getProperty(pkg, 'scripts.test'), 'xo'); + t.is(getProperty(pkg, 'xo'), undefined); }); test('has scripts', async t => { @@ -33,8 +32,8 @@ test('has scripts', async t => { }, }); - t.is(get(pkg, 'scripts.test'), 'xo'); - t.is(get(pkg, 'xo'), undefined); + t.is(getProperty(pkg, 'scripts.test'), 'xo'); + t.is(getProperty(pkg, 'xo'), undefined); }); test('has default test', async t => { @@ -44,8 +43,8 @@ test('has default test', async t => { }, }); - t.is(get(pkg, 'scripts.test'), 'xo'); - t.is(get(pkg, 'xo'), undefined); + t.is(getProperty(pkg, 'scripts.test'), 'xo'); + t.is(getProperty(pkg, 'xo'), undefined); }); test('has only xo', async t => { @@ -55,8 +54,8 @@ test('has only xo', async t => { }, }); - t.is(get(pkg, 'scripts.test'), 'xo'); - t.is(get(pkg, 'xo'), undefined); + t.is(getProperty(pkg, 'scripts.test'), 'xo'); + t.is(getProperty(pkg, 'xo'), undefined); }); test('has test', async t => { @@ -66,8 +65,8 @@ test('has test', async t => { }, }); - t.is(get(pkg, 'scripts.test'), 'xo && ava'); - t.is(get(pkg, 'xo'), undefined); + t.is(getProperty(pkg, 'scripts.test'), 'xo && ava'); + t.is(getProperty(pkg, 'xo'), undefined); }); test('has cli args', async t => { @@ -80,8 +79,8 @@ test('has cli args', async t => { }); process.argv = originalArgv; - t.is(get(pkg, 'scripts.test'), 'xo'); - t.is(get(pkg, 'xo.space'), true); + t.is(getProperty(pkg, 'scripts.test'), 'xo'); + t.is(getProperty(pkg, 'xo.space'), true); }); test('has cli args and test', async t => { @@ -94,9 +93,9 @@ test('has cli args and test', async t => { }); process.argv = originalArgv; - t.is(get(pkg, 'scripts.test'), 'xo && ava'); - t.is(get(pkg, 'xo.envs.0'), 'node'); - t.is(get(pkg, 'xo.envs.1'), 'browser'); + t.is(getProperty(pkg, 'scripts.test'), 'xo && ava'); + t.is(getProperty(pkg, 'xo.envs[0]'), 'node'); + t.is(getProperty(pkg, 'xo.envs[1]'), 'browser'); }); test('has cli args and existing config', async t => { @@ -109,9 +108,9 @@ test('has cli args and existing config', async t => { }); process.argv = originalArgv; - t.is(get(pkg, 'scripts.test'), 'xo'); - t.is(get(pkg, 'xo.space'), true); - t.is(get(pkg, 'xo.esnext'), true); + t.is(getProperty(pkg, 'scripts.test'), 'xo'); + t.is(getProperty(pkg, 'xo.space'), true); + t.is(getProperty(pkg, 'xo.esnext'), true); }); test('has existing config without cli args', async t => { @@ -124,12 +123,13 @@ test('has existing config without cli args', async t => { }); process.argv = originalArgv; - t.is(get(pkg, 'scripts.test'), 'xo'); - t.deepEqual(get(pkg, 'xo'), {esnext: true}); + t.is(getProperty(pkg, 'scripts.test'), 'xo'); + t.deepEqual(getProperty(pkg, 'xo'), {esnext: true}); }); test('has everything covered when it comes to config', async t => { - process.argv = [...originalArgv, + process.argv = [ + ...originalArgv, '--space', '--esnext', '--no-semicolon', @@ -138,27 +138,28 @@ test('has everything covered when it comes to config', async t => { '--global=foo', '--global=bar', '--ignore=foo', - '--ignore=bar']; + '--ignore=bar', + ]; const pkg = await run({}); process.argv = originalArgv; - t.is(get(pkg, 'scripts.test'), 'xo'); - t.is(get(pkg, 'xo.space'), true); - t.is(get(pkg, 'xo.esnext'), true); - t.is(get(pkg, 'xo.semicolon'), false); - t.is(get(pkg, 'xo.envs.0'), 'foo'); - t.is(get(pkg, 'xo.envs.1'), 'bar'); - t.is(get(pkg, 'xo.globals.0'), 'foo'); - t.is(get(pkg, 'xo.globals.1'), 'bar'); - t.is(get(pkg, 'xo.ignores.0'), 'foo'); - t.is(get(pkg, 'xo.ignores.1'), 'bar'); + t.is(getProperty(pkg, 'scripts.test'), 'xo'); + t.is(getProperty(pkg, 'xo.space'), true); + t.is(getProperty(pkg, 'xo.esnext'), true); + t.is(getProperty(pkg, 'xo.semicolon'), false); + t.is(getProperty(pkg, 'xo.envs[0]'), 'foo'); + t.is(getProperty(pkg, 'xo.envs[1]'), 'bar'); + t.is(getProperty(pkg, 'xo.globals[0]'), 'foo'); + t.is(getProperty(pkg, 'xo.globals[1]'), 'bar'); + t.is(getProperty(pkg, 'xo.ignores[0]'), 'foo'); + t.is(getProperty(pkg, 'xo.ignores[1]'), 'bar'); }); test('installs the XO dependency', async t => { const filepath = tempWrite.sync(JSON.stringify({}), 'package.json'); await createXo({cwd: path.dirname(filepath)}); - t.truthy(get(JSON.parse(fs.readFileSync(filepath, 'utf8')), 'devDependencies.xo')); + t.truthy(getProperty(JSON.parse(fs.readFileSync(filepath, 'utf8')), 'devDependencies.xo')); }); test('installs via yarn if there\'s a lockfile', async t => {