From 52045a5967efb2b577d6c0a3cc70084b9eb18e4f Mon Sep 17 00:00:00 2001 From: Thomas Reggi Date: Wed, 29 May 2024 13:53:16 -0400 Subject: [PATCH 01/12] fix: adds support for tap 19, updates snaps to use new delimeter, rm nyc-args for over 17, custom top-level nyc excludes --- lib/content/package-json.hbs | 13 +++++++++++- package.json | 20 ++++++++++--------- .../test/apply/files-snapshots.js.test.cjs | 18 ++++++++--------- .../test/apply/source-snapshots.js.test.cjs | 10 +++++----- tap-snapshots/test/bin/check.js.test.cjs | 2 +- .../test/check/diff-snapshots.js.test.cjs | 16 +++++++-------- .../test/check/snapshots.js.test.cjs | 14 ++++++------- ...e-manager-mock-release-manager.js.test.cjs | 2 +- .../release-manager-npm-cli.js.test.cjs | 2 +- .../release-manager-prerelease.js.test.cjs | 2 +- ...e-manager-publish-and-lockfile.js.test.cjs | 2 +- ...release-manager-single-release.js.test.cjs | 2 +- ...elease-manager-workspace-names.js.test.cjs | 2 +- test/apply/tap.js | 9 +++++++-- test/bin/apply.js | 2 +- test/bin/check.js | 2 +- test/fixtures/mock-release.js | 13 +++++++----- test/setup.js | 4 ++-- 18 files changed, 78 insertions(+), 57 deletions(-) diff --git a/lib/content/package-json.hbs b/lib/content/package-json.hbs index d9523151..a4340661 100644 --- a/lib/content/package-json.hbs +++ b/lib/content/package-json.hbs @@ -40,13 +40,23 @@ }, "templateVersion": {{{ del }}}, "standard": {{{ del }}}, + "nyc": {{#if tapOver17}}{ + "exclude": {{{ json workspaceGlobs }}} + }{{else}}{{{ del }}}{{/if}}, "tap": { + {{#if tapOver17}} + {{#if workspaceGlobs}} + "exclude": {{{ json workspaceGlobs }}}, + {{/if}} + "test-ignore": {{{ del }}}, + {{else}} {{#if workspacePaths}} "exclude": {{#if tap18}}[ "{{ join workspaceGlobs "," }}" ]{{else }}{{{ del }}}{{/if}}, "test-ignore": {{#if tap18}}{{{ del }}}{{else}}"^({{ join workspacePaths "|" }})/"{{/if}}, {{/if}} + {{/if}} {{#if typescript}} {{#if tap16}} "coverage": false, @@ -57,7 +67,8 @@ ], {{/if}} {{/if}} - "nyc-arg": {{#if tap18}}{{{ del }}}{{else}}[ + "show-full-coverage": {{#if tapOver17}}true{{else}}{{{ del }}}{{/if}}, + "nyc-arg": {{#if tapOver17}}{{{ del }}}{{else}}[ {{#each workspaceGlobs}} "--exclude", "{{ . }}", diff --git a/package.json b/package.json index bf3462d0..ac31636c 100644 --- a/package.json +++ b/package.json @@ -73,19 +73,16 @@ "eslint-config-prettier": "^9.1.0", "nock": "^13.3.8", "prettier": "^3.2.5", - "tap": "^16.0.0" + "tap": "^19.0.2" }, "tap": { "timeout": 600, - "nyc-arg": [ - "--exclude", - "workspace/test-workspace/**", - "--exclude", - "tap-snapshots/**" - ], - "test-ignore": "^(workspace/test-workspace)/", "node-arg": [ "--no-experimental-fetch" + ], + "show-full-coverage": true, + "exclude": [ + "workspace/test-workspace/**" ] }, "templateOSS": { @@ -98,5 +95,10 @@ }, "workspaces": [ "workspace/test-workspace" - ] + ], + "nyc": { + "exclude": [ + "workspace/test-workspace/**" + ] + } } diff --git a/tap-snapshots/test/apply/files-snapshots.js.test.cjs b/tap-snapshots/test/apply/files-snapshots.js.test.cjs index 79bd2bae..17fa2c3c 100644 --- a/tap-snapshots/test/apply/files-snapshots.js.test.cjs +++ b/tap-snapshots/test/apply/files-snapshots.js.test.cjs @@ -5,7 +5,7 @@ * Make sure to inspect the output below. Do not ignore changes! */ 'use strict' -exports[`test/apply/files-snapshots.js TAP private workspace > expect resolving Promise 1`] = ` +exports[`test/apply/files-snapshots.js > TAP > private workspace > promise must resolve to match snapshot 1`] = ` .commitlintrc.js .eslintrc.js .github/actions/create-check/action.yml @@ -42,7 +42,7 @@ workspaces/b/.gitignore workspaces/b/package.json ` -exports[`test/apply/files-snapshots.js TAP turn off add/rm types > expect resolving Promise 1`] = ` +exports[`test/apply/files-snapshots.js > TAP > turn off add/rm types > promise must resolve to match snapshot 1`] = ` .commitlintrc.js .github/actions/create-check/action.yml .github/actions/install-latest-npm/action.yml @@ -65,7 +65,7 @@ package.json release-please-config.json ` -exports[`test/apply/files-snapshots.js TAP turn off module > expect resolving Promise 1`] = ` +exports[`test/apply/files-snapshots.js > TAP > turn off module > promise must resolve to match snapshot 1`] = ` .commitlintrc.js .github/actions/create-check/action.yml .github/actions/install-latest-npm/action.yml @@ -88,7 +88,7 @@ package.json release-please-config.json ` -exports[`test/apply/files-snapshots.js TAP turn off repo > expect resolving Promise 1`] = ` +exports[`test/apply/files-snapshots.js > TAP > turn off repo > promise must resolve to match snapshot 1`] = ` .eslintrc.js .gitignore .npmrc @@ -98,11 +98,11 @@ package.json SECURITY.md ` -exports[`test/apply/files-snapshots.js TAP turn off root > expect resolving Promise 1`] = ` +exports[`test/apply/files-snapshots.js > TAP > turn off root > promise must resolve to match snapshot 1`] = ` package.json ` -exports[`test/apply/files-snapshots.js TAP turn off specific files > expect resolving Promise 1`] = ` +exports[`test/apply/files-snapshots.js > TAP > turn off specific files > promise must resolve to match snapshot 1`] = ` .eslintrc.yml .github/actions/create-check/action.yml .github/actions/install-latest-npm/action.yml @@ -131,7 +131,7 @@ release-please-config.json SECURITY.md ` -exports[`test/apply/files-snapshots.js TAP workspaces > expect resolving Promise 1`] = ` +exports[`test/apply/files-snapshots.js > TAP > workspaces > promise must resolve to match snapshot 1`] = ` .github/actions/create-check/action.yml .github/actions/install-latest-npm/action.yml .github/dependabot.yml @@ -158,7 +158,7 @@ workspaces/d/.gitignore workspaces/d/package.json ` -exports[`test/apply/files-snapshots.js TAP workspaces only (like npm/cli) > expect resolving Promise 1`] = ` +exports[`test/apply/files-snapshots.js > TAP > workspaces only (like npm/cli) > promise must resolve to match snapshot 1`] = ` .github/actions/create-check/action.yml .github/actions/install-latest-npm/action.yml .github/dependabot.yml @@ -182,7 +182,7 @@ workspaces/b/.gitignore workspaces/b/package.json ` -exports[`test/apply/files-snapshots.js TAP workspaces with relative content path > expect resolving Promise 1`] = ` +exports[`test/apply/files-snapshots.js > TAP > workspaces with relative content path > promise must resolve to match snapshot 1`] = ` content_dir/index.js content_dir2/index.js package.json diff --git a/tap-snapshots/test/apply/source-snapshots.js.test.cjs b/tap-snapshots/test/apply/source-snapshots.js.test.cjs index b64a2c6d..131b7dbc 100644 --- a/tap-snapshots/test/apply/source-snapshots.js.test.cjs +++ b/tap-snapshots/test/apply/source-snapshots.js.test.cjs @@ -5,7 +5,7 @@ * Make sure to inspect the output below. Do not ignore changes! */ 'use strict' -exports[`test/apply/source-snapshots.js TAP root only > expect resolving Promise 1`] = ` +exports[`test/apply/source-snapshots.js > TAP > root only > promise must resolve to match snapshot 1`] = ` .commitlintrc.js ======================================== /* This file is automatically added by @npmcli/template-oss. Do not edit. */ @@ -1426,7 +1426,7 @@ If the vulnerability you have found is [in scope for the GitHub Bug Bounty Progr Thanks for helping make GitHub safe for everyone. ` -exports[`test/apply/source-snapshots.js TAP with content path > expect resolving Promise 1`] = ` +exports[`test/apply/source-snapshots.js > TAP > with content path > promise must resolve to match snapshot 1`] = ` content_dir/index.js ======================================== module.exports={} @@ -1444,7 +1444,7 @@ package.json } ` -exports[`test/apply/source-snapshots.js TAP with workspaces > expect resolving Promise 1`] = ` +exports[`test/apply/source-snapshots.js > TAP > with workspaces > promise must resolve to match snapshot 1`] = ` .commitlintrc.js ======================================== /* This file is automatically added by @npmcli/template-oss. Do not edit. */ @@ -3272,7 +3272,7 @@ workspaces/b/package.json } ` -exports[`test/apply/source-snapshots.js TAP workspaces only > expect resolving Promise 1`] = ` +exports[`test/apply/source-snapshots.js > TAP > workspaces only > promise must resolve to match snapshot 1`] = ` .github/actions/create-check/action.yml ======================================== # This file is automatically added by @npmcli/template-oss. Do not edit. @@ -4636,7 +4636,7 @@ workspaces/b/package.json } ` -exports[`test/apply/source-snapshots.js TAP workspaces with nested content path > expect resolving Promise 1`] = ` +exports[`test/apply/source-snapshots.js > TAP > workspaces with nested content path > promise must resolve to match snapshot 1`] = ` content_dir/index.js ======================================== module.exports={} diff --git a/tap-snapshots/test/bin/check.js.test.cjs b/tap-snapshots/test/bin/check.js.test.cjs index 4983251d..5ca44f65 100644 --- a/tap-snapshots/test/bin/check.js.test.cjs +++ b/tap-snapshots/test/bin/check.js.test.cjs @@ -5,7 +5,7 @@ * Make sure to inspect the output below. Do not ignore changes! */ 'use strict' -exports[`test/bin/check.js TAP problems > must match snapshot 1`] = ` +exports[`test/bin/check.js > TAP > problems > must match snapshot 1`] = ` Some problems were detected: diff --git a/tap-snapshots/test/check/diff-snapshots.js.test.cjs b/tap-snapshots/test/check/diff-snapshots.js.test.cjs index 2913d7bd..8f11fd55 100644 --- a/tap-snapshots/test/check/diff-snapshots.js.test.cjs +++ b/tap-snapshots/test/check/diff-snapshots.js.test.cjs @@ -5,7 +5,7 @@ * Make sure to inspect the output below. Do not ignore changes! */ 'use strict' -exports[`test/check/diff-snapshots.js TAP different headers > expect resolving Promise 1`] = ` +exports[`test/check/diff-snapshots.js > TAP > different headers > promise must resolve to match snapshot 1`] = ` Some problems were detected: ------------------------------------------------------------------- @@ -21,7 +21,7 @@ To correct it: npx template-oss-apply --force ------------------------------------------------------------------- ` -exports[`test/check/diff-snapshots.js TAP json delete > expect resolving Promise 1`] = ` +exports[`test/check/diff-snapshots.js > TAP > json delete > promise must resolve to match snapshot 1`] = ` Some problems were detected: ------------------------------------------------------------------- @@ -39,7 +39,7 @@ To correct it: npx template-oss-apply --force ------------------------------------------------------------------- ` -exports[`test/check/diff-snapshots.js TAP json merge > initial check 1`] = ` +exports[`test/check/diff-snapshots.js > TAP > json merge > initial check 1`] = ` Some problems were detected: ------------------------------------------------------------------- @@ -56,7 +56,7 @@ To correct it: npx template-oss-apply --force ------------------------------------------------------------------- ` -exports[`test/check/diff-snapshots.js TAP json overwrite > expect resolving Promise 1`] = ` +exports[`test/check/diff-snapshots.js > TAP > json overwrite > promise must resolve to match snapshot 1`] = ` Some problems were detected: ------------------------------------------------------------------- @@ -73,7 +73,7 @@ To correct it: npx template-oss-apply --force ------------------------------------------------------------------- ` -exports[`test/check/diff-snapshots.js TAP unknown file type > expect resolving Promise 1`] = ` +exports[`test/check/diff-snapshots.js > TAP > unknown file type > promise must resolve to match snapshot 1`] = ` Some problems were detected: ------------------------------------------------------------------- @@ -87,7 +87,7 @@ To correct it: npx template-oss-apply --force ------------------------------------------------------------------- ` -exports[`test/check/diff-snapshots.js TAP update and remove errors > expect resolving Promise 1`] = ` +exports[`test/check/diff-snapshots.js > TAP > update and remove errors > promise must resolve to match snapshot 1`] = ` Some problems were detected: ------------------------------------------------------------------- @@ -97,7 +97,7 @@ The repo file audit.yml needs to be updated: .github/workflows/audit.yml ======================================== [@npmcli/template-oss ERROR] There was an erroring getting the target file - [@npmcli/template-oss ERROR] Error: {{ROOT}}/test/check/tap-testdir-diff-snapshots-update-and-remove-errors/.github/workflows/audit.yml + [@npmcli/template-oss ERROR] Error: {{ROOT}}/.tap/fixtures/test-check-diff-snapshots.js-update-and-remove-errors/.github/workflows/audit.yml YAMLParseError: Implicit keys need to be on a single line at line 42, column 1: @@ -222,7 +222,7 @@ To correct it: npx template-oss-apply --force ------------------------------------------------------------------- ` -exports[`test/check/diff-snapshots.js TAP will diff json > expect resolving Promise 1`] = ` +exports[`test/check/diff-snapshots.js > TAP > will diff json > promise must resolve to match snapshot 1`] = ` Some problems were detected: ------------------------------------------------------------------- diff --git a/tap-snapshots/test/check/snapshots.js.test.cjs b/tap-snapshots/test/check/snapshots.js.test.cjs index 88039c1b..b3b6e01b 100644 --- a/tap-snapshots/test/check/snapshots.js.test.cjs +++ b/tap-snapshots/test/check/snapshots.js.test.cjs @@ -5,7 +5,7 @@ * Make sure to inspect the output below. Do not ignore changes! */ 'use strict' -exports[`test/check/snapshots.js TAP changelog > expect resolving Promise 1`] = ` +exports[`test/check/snapshots.js > TAP > changelog > promise must resolve to match snapshot 1`] = ` Some problems were detected: ------------------------------------------------------------------- @@ -22,7 +22,7 @@ To correct it: reformat the changelog to have the correct heading ------------------------------------------------------------------- ` -exports[`test/check/snapshots.js TAP check empty dir > expect resolving Promise 1`] = ` +exports[`test/check/snapshots.js > TAP > check empty dir > promise must resolve to match snapshot 1`] = ` Some problems were detected: ------------------------------------------------------------------- @@ -111,7 +111,7 @@ To correct it: npm rm @npmcli/template-oss @npmcli/eslint-config tap && npm i @n ------------------------------------------------------------------- ` -exports[`test/check/snapshots.js TAP gitignore > expect resolving Promise 1`] = ` +exports[`test/check/snapshots.js > TAP > gitignore > promise must resolve to match snapshot 1`] = ` Some problems were detected: ------------------------------------------------------------------- @@ -156,7 +156,7 @@ To correct it: move files to not match one of the following patterns: ------------------------------------------------------------------- ` -exports[`test/check/snapshots.js TAP gitignore with workspaces workspace > expect resolving Promise 1`] = ` +exports[`test/check/snapshots.js > TAP > gitignore with workspaces workspace > promise must resolve to match snapshot 1`] = ` Some problems were detected: ------------------------------------------------------------------- @@ -258,7 +258,7 @@ To correct it: move files to not match one of the following patterns: ------------------------------------------------------------------- ` -exports[`test/check/snapshots.js TAP not ok without required > expect resolving Promise 1`] = ` +exports[`test/check/snapshots.js > TAP > not ok without required > promise must resolve to match snapshot 1`] = ` Some problems were detected: ------------------------------------------------------------------- @@ -274,7 +274,7 @@ To correct it: npm rm @npmcli/template-oss @npmcli/eslint-config tap && npm i @n ------------------------------------------------------------------- ` -exports[`test/check/snapshots.js TAP unwanted > expect resolving Promise 1`] = ` +exports[`test/check/snapshots.js > TAP > unwanted > promise must resolve to match snapshot 1`] = ` Some problems were detected: ------------------------------------------------------------------- @@ -288,7 +288,7 @@ To correct it: npm rm eslint ------------------------------------------------------------------- ` -exports[`test/check/snapshots.js TAP workspaces with empty dir > expect resolving Promise 1`] = ` +exports[`test/check/snapshots.js > TAP > workspaces with empty dir > promise must resolve to match snapshot 1`] = ` Some problems were detected: ------------------------------------------------------------------- diff --git a/tap-snapshots/test/release/release-manager-mock-release-manager.js.test.cjs b/tap-snapshots/test/release/release-manager-mock-release-manager.js.test.cjs index 8da017d7..70a28281 100644 --- a/tap-snapshots/test/release/release-manager-mock-release-manager.js.test.cjs +++ b/tap-snapshots/test/release/release-manager-mock-release-manager.js.test.cjs @@ -5,7 +5,7 @@ * Make sure to inspect the output below. Do not ignore changes! */ 'use strict' -exports[`test/release/release-manager.js TAP mock release manager > must match snapshot 1`] = ` +exports[`test/release/release-manager.js > TAP > mock release manager > must match snapshot 1`] = ` ### Release Checklist for v4.0.5 - [ ] 1. Checkout the release branch and test diff --git a/tap-snapshots/test/release/release-manager-npm-cli.js.test.cjs b/tap-snapshots/test/release/release-manager-npm-cli.js.test.cjs index e918f638..787cd5da 100644 --- a/tap-snapshots/test/release/release-manager-npm-cli.js.test.cjs +++ b/tap-snapshots/test/release/release-manager-npm-cli.js.test.cjs @@ -5,7 +5,7 @@ * Make sure to inspect the output below. Do not ignore changes! */ 'use strict' -exports[`test/release/release-manager.js TAP npm/cli > must match snapshot 1`] = ` +exports[`test/release/release-manager.js > TAP > npm/cli > must match snapshot 1`] = ` ### Release Checklist for v10.2.5 - [ ] 1. Checkout the release branch diff --git a/tap-snapshots/test/release/release-manager-prerelease.js.test.cjs b/tap-snapshots/test/release/release-manager-prerelease.js.test.cjs index 11a1bb84..7c2b5bff 100644 --- a/tap-snapshots/test/release/release-manager-prerelease.js.test.cjs +++ b/tap-snapshots/test/release/release-manager-prerelease.js.test.cjs @@ -5,7 +5,7 @@ * Make sure to inspect the output below. Do not ignore changes! */ 'use strict' -exports[`test/release/release-manager.js TAP prerelease > must match snapshot 1`] = ` +exports[`test/release/release-manager.js > TAP > prerelease > must match snapshot 1`] = ` ### Release Checklist for v10.0.0-pre.0 - [ ] 1. Checkout the release branch diff --git a/tap-snapshots/test/release/release-manager-publish-and-lockfile.js.test.cjs b/tap-snapshots/test/release/release-manager-publish-and-lockfile.js.test.cjs index 244206db..3e0f50cf 100644 --- a/tap-snapshots/test/release/release-manager-publish-and-lockfile.js.test.cjs +++ b/tap-snapshots/test/release/release-manager-publish-and-lockfile.js.test.cjs @@ -5,7 +5,7 @@ * Make sure to inspect the output below. Do not ignore changes! */ 'use strict' -exports[`test/release/release-manager.js TAP publish and lockfile > must match snapshot 1`] = ` +exports[`test/release/release-manager.js > TAP > publish and lockfile > must match snapshot 1`] = ` ### Release Checklist for v7.5.4 - [ ] 1. Approve this PR diff --git a/tap-snapshots/test/release/release-manager-single-release.js.test.cjs b/tap-snapshots/test/release/release-manager-single-release.js.test.cjs index dead1de9..3557255a 100644 --- a/tap-snapshots/test/release/release-manager-single-release.js.test.cjs +++ b/tap-snapshots/test/release/release-manager-single-release.js.test.cjs @@ -5,7 +5,7 @@ * Make sure to inspect the output below. Do not ignore changes! */ 'use strict' -exports[`test/release/release-manager.js TAP single release > must match snapshot 1`] = ` +exports[`test/release/release-manager.js > TAP > single release > must match snapshot 1`] = ` ### Release Checklist for v7.5.4 - [ ] 1. Checkout the release branch and test diff --git a/tap-snapshots/test/release/release-manager-workspace-names.js.test.cjs b/tap-snapshots/test/release/release-manager-workspace-names.js.test.cjs index 982d923c..2196064f 100644 --- a/tap-snapshots/test/release/release-manager-workspace-names.js.test.cjs +++ b/tap-snapshots/test/release/release-manager-workspace-names.js.test.cjs @@ -5,7 +5,7 @@ * Make sure to inspect the output below. Do not ignore changes! */ 'use strict' -exports[`test/release/release-manager.js TAP workspace names > expect resolving Promise 1`] = ` +exports[`test/release/release-manager.js > TAP > workspace names > promise must resolve to match snapshot 1`] = ` ### Release Checklist for v10.2.2 - [ ] 1. Checkout the release branch diff --git a/test/apply/tap.js b/test/apply/tap.js index 7dbf076c..56ad40ed 100644 --- a/test/apply/tap.js +++ b/test/apply/tap.js @@ -13,7 +13,9 @@ t.test('tap@18', async t => { await s.apply() const pkg = await s.readJson('package.json') - t.strictSame(pkg.tap, {}) + t.strictSame(pkg.tap, { + 'show-full-coverage': true, + }) }) t.test('tap@16', async t => { @@ -29,6 +31,9 @@ t.test('tap@16', async t => { await s.apply() const pkg = await s.readJson('package.json') t.strictSame(pkg.tap, { - 'nyc-arg': ['--exclude', 'tap-snapshots/**'], + 'nyc-arg': [ + '--exclude', + 'tap-snapshots/**', + ], }) }) diff --git a/test/bin/apply.js b/test/bin/apply.js index c4a32c39..f2ce0a55 100644 --- a/test/bin/apply.js +++ b/test/bin/apply.js @@ -1,7 +1,7 @@ const t = require('tap') const templateApply = mocks => - t.mock( + t.mockRequire( '../../bin/apply.js', mocks && { '../../lib/apply/index.js': async () => mocks(), diff --git a/test/bin/check.js b/test/bin/check.js index b6a4654b..0affbf7c 100644 --- a/test/bin/check.js +++ b/test/bin/check.js @@ -1,7 +1,7 @@ const t = require('tap') const templateCheck = mocks => - t.mock( + t.mockRequire( '../../bin/check.js', mocks && { '../../lib/check/index.js': async () => mocks(), diff --git a/test/fixtures/mock-release.js b/test/fixtures/mock-release.js index 9df552d8..d9e67100 100644 --- a/test/fixtures/mock-release.js +++ b/test/fixtures/mock-release.js @@ -1,5 +1,5 @@ const nock = require('nock') -const { resolve, relative, dirname, sep, join, basename } = require('path') +const { resolve, relative, dirname, sep, join, basename, extname } = require('path') const fs = require('fs') const DIR = __dirname @@ -12,9 +12,12 @@ const REPO = 'npm/npm-cli-release-please' const BRANCH = 'template-oss-mock-testing-branch-do-not-delete' const getPath = t => { - const fixtureName = relative(CWD, t.testdirName).split(`${sep}tap-testdir-`)[1] + const fullExt = extname(t.testdirName) + const testName = fullExt.replace(/\.js-/, '') + const testFileName = basename(t.testdirName, fullExt).replace(/^test-release-/, '') + const fixtureName = `${testFileName}-${testName}` return { - fixtureName: basename(fixtureName), + fixtureName, fixturePath: resolve(DIR, 'nocks', `${fixtureName}.json`), } } @@ -61,7 +64,7 @@ const setup = t => { } const releasePlease = async (t, { setup: s, ...opts } = {}) => { - const ReleasePlease = t.mock('../../lib/release/release-please.js') + const ReleasePlease = t.mockRequire('../../lib/release/release-please.js') try { return await ReleasePlease.run({ token: s.token, @@ -82,7 +85,7 @@ const releasePlease = async (t, { setup: s, ...opts } = {}) => { const releaseManager = (t, { cwd = t.testdir({ 'package.json': '{"name":"pkg"}' }), ...opts } = {}) => { const s = setup(t) - const ReleaseManager = t.mock('../../lib/release/release-manager.js') + const ReleaseManager = t.mockRequire('../../lib/release/release-manager.js') return ReleaseManager.run({ token: s.token, repo: REPO, diff --git a/test/setup.js b/test/setup.js index dec4bf2d..0b11e302 100644 --- a/test/setup.js +++ b/test/setup.js @@ -88,8 +88,8 @@ const setupRoot = async (t, root, mocks) => { return Object.fromEntries(files.map((f, i) => [f, contents[i]])) } - const apply = t.mock('../lib/apply/index.js', mocks) - const check = t.mock('../lib/check/index.js', mocks) + const apply = t.mockRequire('../lib/apply/index.js', mocks) + const check = t.mockRequire('../lib/check/index.js', mocks) return { root, From 99c0664ed1cd073be2a5d304694e371462145171 Mon Sep 17 00:00:00 2001 From: Thomas Reggi Date: Wed, 29 May 2024 14:01:34 -0400 Subject: [PATCH 02/12] lintfixes --- test/apply/tap.js | 5 +---- test/fixtures/mock-release.js | 3 +-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/test/apply/tap.js b/test/apply/tap.js index 56ad40ed..a18ba660 100644 --- a/test/apply/tap.js +++ b/test/apply/tap.js @@ -31,9 +31,6 @@ t.test('tap@16', async t => { await s.apply() const pkg = await s.readJson('package.json') t.strictSame(pkg.tap, { - 'nyc-arg': [ - '--exclude', - 'tap-snapshots/**', - ], + 'nyc-arg': ['--exclude', 'tap-snapshots/**'], }) }) diff --git a/test/fixtures/mock-release.js b/test/fixtures/mock-release.js index d9e67100..1b1cbb2c 100644 --- a/test/fixtures/mock-release.js +++ b/test/fixtures/mock-release.js @@ -1,9 +1,8 @@ const nock = require('nock') -const { resolve, relative, dirname, sep, join, basename, extname } = require('path') +const { resolve, dirname, join, basename, extname } = require('path') const fs = require('fs') const DIR = __dirname -const CWD = process.cwd() const RECORD = 'NOCK_RECORD' in process.env ? true : undefined // These are the live GitHub repo and branch that are used to From 4b08b175803c3fd617e470856029f6f41b11acdd Mon Sep 17 00:00:00 2001 From: Thomas Reggi Date: Thu, 30 May 2024 13:41:49 -0400 Subject: [PATCH 03/12] fix rm tap.exclude on downgrade, rm line about luke as node collab, istanbul -> c8 --- lib/content/package-json.hbs | 1 + lib/release/node-workspace-format.js | 4 +++- lib/release/release-manager.js | 3 ++- lib/release/release-please.js | 4 +++- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/content/package-json.hbs b/lib/content/package-json.hbs index a4340661..c9a1cedc 100644 --- a/lib/content/package-json.hbs +++ b/lib/content/package-json.hbs @@ -50,6 +50,7 @@ {{/if}} "test-ignore": {{{ del }}}, {{else}} + "exclude": {{{ del }}}, {{#if workspacePaths}} "exclude": {{#if tap18}}[ "{{ join workspaceGlobs "," }}" diff --git a/lib/release/node-workspace-format.js b/lib/release/node-workspace-format.js index 78a86be9..770a72f0 100644 --- a/lib/release/node-workspace-format.js +++ b/lib/release/node-workspace-format.js @@ -5,7 +5,8 @@ const { TagName } = require('release-please/build/src/util/tag-name.js') const { ROOT_PROJECT_PATH } = require('release-please/build/src/manifest.js') const { DEPS, link, wrapSpecs, list } = require('./util.js') -/* istanbul ignore next: TODO fix flaky tests and enable coverage */ +/* TODO fix flaky tests and enable coverage */ +/* c8 ignore start */ module.exports = class extends ManifestPlugin { static WORKSPACE_MESSAGE = (name, version) => `${DEPS}(workspace): ${name}@${version}` @@ -95,3 +96,4 @@ module.exports = class extends ManifestPlugin { } } } +/* c8 ignore end */ diff --git a/lib/release/release-manager.js b/lib/release/release-manager.js index 91b673a9..b930bc12 100644 --- a/lib/release/release-manager.js +++ b/lib/release/release-manager.js @@ -165,13 +165,14 @@ class ReleaseManager { // If the url fails with anything but a 404 we want the process to blow // up because that means something is very wrong. This is a rare edge // case that isn't worth testing. - /* istanbul ignore else */ + if (r.statusCode === 200) { this.#info('Found release process from wiki') return r.body.text() } else if (r.statusCode === 404) { this.#info('No release process found in wiki, falling back to default process') return this.#getReleaseSteps() + /* c8 ignore next 3 */ } else { throw new Error(`Release process fetch failed with status: ${r.statusCode}`) } diff --git a/lib/release/release-please.js b/lib/release/release-please.js index 95a7e270..fedb1c84 100644 --- a/lib/release/release-please.js +++ b/lib/release/release-please.js @@ -9,7 +9,8 @@ const NodeWorkspaceFormat = require('./node-workspace-format.js') const { getPublishTag, noop } = require('./util.js') const { SemverVersioningStrategy } = require('./semver-versioning-strategy.js') -/* istanbul ignore next: TODO fix flaky tests and enable coverage */ +/* TODO fix flaky tests and enable coverage */ +/* c8 ignore start */ class ReleasePlease { #token #owner @@ -163,5 +164,6 @@ class ReleasePlease { return releases.length ? releases : null } } +/* c8 ignore end */ module.exports = ReleasePlease From 997f758d3188c23aa79b318d39129b8016eaf780 Mon Sep 17 00:00:00 2001 From: reggi Date: Mon, 16 Dec 2024 11:35:22 -0500 Subject: [PATCH 04/12] fix: migrate old tap 19 pr with todays code --- lib/content/package-json.hbs | 8 ++++---- package.json | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/content/package-json.hbs b/lib/content/package-json.hbs index c9a1cedc..df5fb1a2 100644 --- a/lib/content/package-json.hbs +++ b/lib/content/package-json.hbs @@ -40,11 +40,11 @@ }, "templateVersion": {{{ del }}}, "standard": {{{ del }}}, - "nyc": {{#if tapOver17}}{ + "nyc": {{#if tap18}}{ "exclude": {{{ json workspaceGlobs }}} }{{else}}{{{ del }}}{{/if}}, "tap": { - {{#if tapOver17}} + {{#if tap18}} {{#if workspaceGlobs}} "exclude": {{{ json workspaceGlobs }}}, {{/if}} @@ -68,8 +68,8 @@ ], {{/if}} {{/if}} - "show-full-coverage": {{#if tapOver17}}true{{else}}{{{ del }}}{{/if}}, - "nyc-arg": {{#if tapOver17}}{{{ del }}}{{else}}[ + "show-full-coverage": {{#if tap18}}true{{else}}{{{ del }}}{{/if}}, + "nyc-arg": {{#if tap18}}{{{ del }}}{{else}}[ {{#each workspaceGlobs}} "--exclude", "{{ . }}", diff --git a/package.json b/package.json index ac31636c..edf77913 100644 --- a/package.json +++ b/package.json @@ -80,10 +80,10 @@ "node-arg": [ "--no-experimental-fetch" ], - "show-full-coverage": true, "exclude": [ "workspace/test-workspace/**" - ] + ], + "show-full-coverage": true }, "templateOSS": { "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", From 5f3025728cac5faf0d71c725785f64ea5a992de9 Mon Sep 17 00:00:00 2001 From: reggi Date: Mon, 16 Dec 2024 11:49:47 -0500 Subject: [PATCH 05/12] chore: bumps tap 19 21 --- lib/release/semver-versioning-strategy.js | 3 ++- package.json | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/release/semver-versioning-strategy.js b/lib/release/semver-versioning-strategy.js index 6844deb3..02bd632e 100644 --- a/lib/release/semver-versioning-strategy.js +++ b/lib/release/semver-versioning-strategy.js @@ -59,10 +59,11 @@ class SemverVersioningStrategy { const releaseType = parseCommits(commits) const addPreIfNeeded = prerelease ? `pre${releaseType}` : releaseType const version = inc(currentVersion.toString(), addPreIfNeeded, tag) - /* istanbul ignore next */ + /* c8 ignore start */ if (!version) { throw new Error('Could not bump version') } + /* c8 ignore stop */ return Version.parse(version) } } diff --git a/package.json b/package.json index edf77913..7442d553 100644 --- a/package.json +++ b/package.json @@ -73,7 +73,7 @@ "eslint-config-prettier": "^9.1.0", "nock": "^13.3.8", "prettier": "^3.2.5", - "tap": "^19.0.2" + "tap": "^21.0.1" }, "tap": { "timeout": 600, From 62edbb62ca4c7de57f9c1711ccad224337e10be9 Mon Sep 17 00:00:00 2001 From: reggi Date: Thu, 23 Jan 2025 17:24:10 -0500 Subject: [PATCH 06/12] fix!: drops 20.0.5 support --- package.json | 2 +- test/apply/esm.js | 2 ++ test/setup.js | 14 ++++++++++++-- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 7442d553..6bcea755 100644 --- a/package.json +++ b/package.json @@ -91,7 +91,7 @@ "prettier": true }, "engines": { - "node": "^18.17.0 || >=20.5.0" + "node": "^20.17.0 || >=22.9.0" }, "workspaces": [ "workspace/test-workspace" diff --git a/test/apply/esm.js b/test/apply/esm.js index aeaa9f18..33a41b5b 100644 --- a/test/apply/esm.js +++ b/test/apply/esm.js @@ -19,5 +19,7 @@ t.test('basic', async t => { await s.apply() const file = await s.readFile('file.js') + + process.exit(0) t.match(file, 'var x = 1;') }) diff --git a/test/setup.js b/test/setup.js index 0b11e302..7c2b5c87 100644 --- a/test/setup.js +++ b/test/setup.js @@ -53,12 +53,20 @@ const setupRoot = async (t, root, mocks) => { const rootFs = Object.fromEntries( Object.entries({ readdir: fs.readdir, - readFile: p => fs.readFile(p, { encoding: 'utf-8' }), + readFile: p => { + console.log(p) + return fs.readFile(p, { encoding: 'utf-8' }) + }, writeFile: (p, d) => fs.writeFile(p, d, { encoding: 'utf-8' }), appendFile: fs.appendFile, stat: fs.stat, unlink: fs.unlink, - }).map(([k, fn]) => [k, (p, ...rest) => fn(rootPath(p), ...rest)]), + }).map(([k, fn]) => [ + k, + (p, ...rest) => { + return fn(rootPath(p), ...rest) + }, + ]), ) // Returns a recurisve list of relative file @@ -137,6 +145,8 @@ const setup = async (t, { package = {}, workspaces = {}, testdir = {}, mocks = { // package.json files for each workspace const root = t.testdir(merge(createPackageJson(pkg), testdir)) + console.log({ root }) + return { ...(await setupRoot(t, root, mocks)), workspaces: wsLookup, From 1b4a2f5877057f7fdb36b88ee6b82c684de47f7a Mon Sep 17 00:00:00 2001 From: reggi Date: Thu, 23 Jan 2025 17:26:53 -0500 Subject: [PATCH 07/12] fix template oss --- .github/workflows/ci-release.yml | 13 +++++-------- .github/workflows/ci.yml | 13 +++++-------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci-release.yml b/.github/workflows/ci-release.yml index 4709ee43..5b2d8c03 100644 --- a/.github/workflows/ci-release.yml +++ b/.github/workflows/ci-release.yml @@ -87,20 +87,17 @@ jobs: os: windows-latest shell: cmd node-version: - - 18.17.0 - - 18.x - - 20.5.0 + - 20.17.0 - 20.x + - 22.9.0 - 22.x exclude: - platform: { name: macOS, os: macos-13, shell: bash } - node-version: 18.17.0 - - platform: { name: macOS, os: macos-13, shell: bash } - node-version: 18.x - - platform: { name: macOS, os: macos-13, shell: bash } - node-version: 20.5.0 + node-version: 20.17.0 - platform: { name: macOS, os: macos-13, shell: bash } node-version: 20.x + - platform: { name: macOS, os: macos-13, shell: bash } + node-version: 22.9.0 - platform: { name: macOS, os: macos-13, shell: bash } node-version: 22.x runs-on: ${{ matrix.platform.os }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b934a8d5..3873d0b9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -68,20 +68,17 @@ jobs: os: windows-latest shell: cmd node-version: - - 18.17.0 - - 18.x - - 20.5.0 + - 20.17.0 - 20.x + - 22.9.0 - 22.x exclude: - platform: { name: macOS, os: macos-13, shell: bash } - node-version: 18.17.0 - - platform: { name: macOS, os: macos-13, shell: bash } - node-version: 18.x - - platform: { name: macOS, os: macos-13, shell: bash } - node-version: 20.5.0 + node-version: 20.17.0 - platform: { name: macOS, os: macos-13, shell: bash } node-version: 20.x + - platform: { name: macOS, os: macos-13, shell: bash } + node-version: 22.9.0 - platform: { name: macOS, os: macos-13, shell: bash } node-version: 22.x runs-on: ${{ matrix.platform.os }} From 98e38d9bf369ea47bd2cc00970081f681f7a08b1 Mon Sep 17 00:00:00 2001 From: reggi Date: Thu, 23 Jan 2025 17:42:15 -0500 Subject: [PATCH 08/12] rm process exit --- test/apply/esm.js | 1 - test/check/snapshots.js | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/test/apply/esm.js b/test/apply/esm.js index 33a41b5b..12ee9bf0 100644 --- a/test/apply/esm.js +++ b/test/apply/esm.js @@ -20,6 +20,5 @@ t.test('basic', async t => { const file = await s.readFile('file.js') - process.exit(0) t.match(file, 'var x = 1;') }) diff --git a/test/check/snapshots.js b/test/check/snapshots.js index fa812e1b..0ae34c14 100644 --- a/test/check/snapshots.js +++ b/test/check/snapshots.js @@ -17,7 +17,7 @@ t.test('workspaces with empty dir', async t => { await t.resolveMatchSnapshot(s.check()) }) -t.test('not ok without required', async t => { +t.test('not good without required', async t => { const s = await setup(t) await s.apply() await t.resolveMatchSnapshot(s.check()) From d459dac92ffeac3ce2fc8b41294491e8f661657b Mon Sep 17 00:00:00 2001 From: reggi Date: Thu, 23 Jan 2025 17:46:42 -0500 Subject: [PATCH 09/12] rm logs, tap --- tap-snapshots/test/check/snapshots.js.test.cjs | 2 +- test/setup.js | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/tap-snapshots/test/check/snapshots.js.test.cjs b/tap-snapshots/test/check/snapshots.js.test.cjs index b3b6e01b..38a9aec8 100644 --- a/tap-snapshots/test/check/snapshots.js.test.cjs +++ b/tap-snapshots/test/check/snapshots.js.test.cjs @@ -258,7 +258,7 @@ To correct it: move files to not match one of the following patterns: ------------------------------------------------------------------- ` -exports[`test/check/snapshots.js > TAP > not ok without required > promise must resolve to match snapshot 1`] = ` +exports[`test/check/snapshots.js > TAP > not good without required > promise must resolve to match snapshot 1`] = ` Some problems were detected: ------------------------------------------------------------------- diff --git a/test/setup.js b/test/setup.js index 7c2b5c87..375ef7d6 100644 --- a/test/setup.js +++ b/test/setup.js @@ -54,7 +54,6 @@ const setupRoot = async (t, root, mocks) => { Object.entries({ readdir: fs.readdir, readFile: p => { - console.log(p) return fs.readFile(p, { encoding: 'utf-8' }) }, writeFile: (p, d) => fs.writeFile(p, d, { encoding: 'utf-8' }), @@ -145,8 +144,6 @@ const setup = async (t, { package = {}, workspaces = {}, testdir = {}, mocks = { // package.json files for each workspace const root = t.testdir(merge(createPackageJson(pkg), testdir)) - console.log({ root }) - return { ...(await setupRoot(t, root, mocks)), workspaces: wsLookup, From bfe791861dd9e0ee326cbfc7625a1d058ada90fc Mon Sep 17 00:00:00 2001 From: reggi Date: Thu, 23 Jan 2025 18:00:13 -0500 Subject: [PATCH 10/12] fix test --- test/apply/esm.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/apply/esm.js b/test/apply/esm.js index 12ee9bf0..7a38ec57 100644 --- a/test/apply/esm.js +++ b/test/apply/esm.js @@ -17,8 +17,7 @@ t.test('basic', async t => { }, }) await s.apply() - - const file = await s.readFile('file.js') + const file = await s.readFile('content_dir/file.js') t.match(file, 'var x = 1;') }) From dce3ba16c00aa4c20d829cd4aae478d55c1b6ca5 Mon Sep 17 00:00:00 2001 From: reggi Date: Thu, 23 Jan 2025 18:05:06 -0500 Subject: [PATCH 11/12] fix ignore --- lib/util/import-or-require.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/util/import-or-require.js b/lib/util/import-or-require.js index 0fb0ef4b..7d415e5e 100644 --- a/lib/util/import-or-require.js +++ b/lib/util/import-or-require.js @@ -17,10 +17,12 @@ const importOrRequire = async path => { } catch { try { content = await import(pathToFileURL(path)).then(r => r.default) + /* c8 ignore start */ } catch { // its ok if this fails since the content dir might only be to provide // other files. the index.js is optional } + /* c8 ignore end */ } importOrRequireCache.set(path, content) return content From c7647f68c5b2473052e872e07e682c97a6f2f55e Mon Sep 17 00:00:00 2001 From: Reggi Date: Thu, 30 Jan 2025 11:47:58 -0500 Subject: [PATCH 12/12] Update lib/util/import-or-require.js --- lib/util/import-or-require.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/util/import-or-require.js b/lib/util/import-or-require.js index ee8a2046..86679a60 100644 --- a/lib/util/import-or-require.js +++ b/lib/util/import-or-require.js @@ -15,7 +15,6 @@ const importOrRequire = async path => { try { content = require(path) // this is for node 22+ - // istanbul ignore next /* c8 ignore start */ if (content.__esModule) { return content.default