From 9e2b9adff93c7c1d8bf85cbb04163f84b30fe889 Mon Sep 17 00:00:00 2001 From: Matthew Scharley Date: Tue, 11 Jun 2024 11:42:54 +1000 Subject: [PATCH 1/4] chore: migrate to asdf --- .nvmrc | 1 - .tool-versions | 1 + .vscode/settings.default.json | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) delete mode 100644 .nvmrc create mode 100644 .tool-versions diff --git a/.nvmrc b/.nvmrc deleted file mode 100644 index 48b14e6..0000000 --- a/.nvmrc +++ /dev/null @@ -1 +0,0 @@ -20.14.0 diff --git a/.tool-versions b/.tool-versions new file mode 100644 index 0000000..02fda06 --- /dev/null +++ b/.tool-versions @@ -0,0 +1 @@ +nodejs 20.14.0 diff --git a/.vscode/settings.default.json b/.vscode/settings.default.json index 424c4b4..14dd9b4 100644 --- a/.vscode/settings.default.json +++ b/.vscode/settings.default.json @@ -1,5 +1,5 @@ { - "jest.jestCommandLine": "${NVM_DIR:-~/.nvm}/nvm-exec npx jest", + "jest.jestCommandLine": "${ASDF_DATA_DIR:-~/.asdf}/shims/npx jest", "eslint.options": { "useEslintrc": false, "overrideConfig": { "extends": ["./.github/linters/.eslintrc.yml"] } From 84024502b4b30070c82203841f1947b057383713 Mon Sep 17 00:00:00 2001 From: Matthew Scharley Date: Tue, 11 Jun 2024 11:56:49 +1000 Subject: [PATCH 2/4] chore: add more debug logging --- badges/coverage.svg | 2 +- dist/index.js | 2 ++ src/__tests__/generateChangeset.test.ts | 17 +++++++++++++++++ src/main.ts | 2 ++ 4 files changed, 22 insertions(+), 1 deletion(-) diff --git a/badges/coverage.svg b/badges/coverage.svg index 3db10bc..c5d8e28 100644 --- a/badges/coverage.svg +++ b/badges/coverage.svg @@ -1 +1 @@ -Coverage: 67.87%Coverage67.87% \ No newline at end of file +Coverage: 67.69%Coverage67.69% \ No newline at end of file diff --git a/dist/index.js b/dist/index.js index f74c7e3..95b09b6 100644 --- a/dist/index.js +++ b/dist/index.js @@ -31647,6 +31647,7 @@ exports.parseInput = parseInput; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.run = void 0; const core_1 = __nccwpck_require__(2186); +const debugJson_1 = __nccwpck_require__(3562); const getCommitLog_1 = __nccwpck_require__(553); const getEvent_1 = __nccwpck_require__(9362); const getFile_1 = __nccwpck_require__(9103); @@ -31675,6 +31676,7 @@ async function run() { const getFromGithub = (0, getFile_1.getFile)(octokit, owner, repo, ref); const commits = await (0, getCommitLog_1.getCommitLog)(octokit, owner, repo, pr); const changesetsConfig = await getFromGithub(ChangesetsConfiguration_1.isChangesetsConfiguration)(`${input.changesetFolder}/config.json`); + (0, debugJson_1.debugJson)('Changesets configuration', changesetsConfig); const patchString = await (0, getPrPatch_1.getPrPatch)(octokit, owner, repo, pr.number); const changeset = await (0, processPullRequest_1.processPullRequest)(input, owner, repo, pr, patchString, changesetsConfig, commits, getFromGithub); if (changeset == null) { diff --git a/src/__tests__/generateChangeset.test.ts b/src/__tests__/generateChangeset.test.ts index 0b8c3a3..d414c52 100644 --- a/src/__tests__/generateChangeset.test.ts +++ b/src/__tests__/generateChangeset.test.ts @@ -82,6 +82,23 @@ describe('generateChangeset', () => { }); it('will exclude a package if it is listed as an ignored package for changesets', () => { + expect( + generateChangeset( + pr({}), + commit({ commit: { message: 'fix: hello, world' } }), + input({ useConventionalCommits: true }), + changesets({ ignore: ['@mscharley/test'] }), + { foundChangeset: false }, + [['package.json', { name: '@mscharley/test' }], ['package.json', { name: '@mscharley/test2' }]], + ), + ).toMatchObject({ + affectedPackages: ['@mscharley/test2'], + message: 'fix: hello, world', + updateType: 'patch', + }); + }); + + it('will exclude the changeset if only ignored packages are included', () => { expect( generateChangeset( pr({}), diff --git a/src/main.ts b/src/main.ts index 99ed7b1..ef8a1bb 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,4 +1,5 @@ import { debug, setOutput } from '@actions/core'; +import { debugJson } from './io/debugJson'; import { getCommitLog } from './io/github/getCommitLog'; import { getEvent } from './io/getEvent'; import { getFile } from './io/github/getFile'; @@ -30,6 +31,7 @@ export async function run(): Promise { const getFromGithub = getFile(octokit, owner, repo, ref); const commits = await getCommitLog(octokit, owner, repo, pr); const changesetsConfig = await getFromGithub(isChangesetsConfiguration)(`${input.changesetFolder}/config.json`); + debugJson('Changesets configuration', changesetsConfig); const patchString = await getPrPatch(octokit, owner, repo, pr.number); const changeset = await processPullRequest( From 36901e0094e808935a902cde9e858ace5ec21b51 Mon Sep 17 00:00:00 2001 From: Matthew Scharley Date: Tue, 11 Jun 2024 12:13:45 +1000 Subject: [PATCH 3/4] fix: unwrap the contents of the changesets config file --- dist/index.js | 2 +- src/main.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/index.js b/dist/index.js index 95b09b6..64b1ee8 100644 --- a/dist/index.js +++ b/dist/index.js @@ -31675,7 +31675,7 @@ async function run() { } const getFromGithub = (0, getFile_1.getFile)(octokit, owner, repo, ref); const commits = await (0, getCommitLog_1.getCommitLog)(octokit, owner, repo, pr); - const changesetsConfig = await getFromGithub(ChangesetsConfiguration_1.isChangesetsConfiguration)(`${input.changesetFolder}/config.json`); + const [, changesetsConfig] = await getFromGithub(ChangesetsConfiguration_1.isChangesetsConfiguration)(`${input.changesetFolder}/config.json`); (0, debugJson_1.debugJson)('Changesets configuration', changesetsConfig); const patchString = await (0, getPrPatch_1.getPrPatch)(octokit, owner, repo, pr.number); const changeset = await (0, processPullRequest_1.processPullRequest)(input, owner, repo, pr, patchString, changesetsConfig, commits, getFromGithub); diff --git a/src/main.ts b/src/main.ts index ef8a1bb..2debca9 100644 --- a/src/main.ts +++ b/src/main.ts @@ -30,7 +30,7 @@ export async function run(): Promise { const getFromGithub = getFile(octokit, owner, repo, ref); const commits = await getCommitLog(octokit, owner, repo, pr); - const changesetsConfig = await getFromGithub(isChangesetsConfiguration)(`${input.changesetFolder}/config.json`); + const [, changesetsConfig] = await getFromGithub(isChangesetsConfiguration)(`${input.changesetFolder}/config.json`); debugJson('Changesets configuration', changesetsConfig); const patchString = await getPrPatch(octokit, owner, repo, pr.number); From e1afc6774ef5a1987d734f5447486393309fa40d Mon Sep 17 00:00:00 2001 From: Matthew Scharley Date: Tue, 11 Jun 2024 12:16:58 +1000 Subject: [PATCH 4/4] ci: update actions to use tool-versions --- .github/workflows/check-dist.yml | 2 +- .github/workflows/ci.yml | 2 +- .github/workflows/linter.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/check-dist.yml b/.github/workflows/check-dist.yml index 8fe8e9b..120baad 100644 --- a/.github/workflows/check-dist.yml +++ b/.github/workflows/check-dist.yml @@ -38,7 +38,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 with: - node-version-file: .nvmrc + node-version-file: .tool-versions cache: npm - name: Install Dependencies diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7e45614..8f83cf3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,7 +23,7 @@ jobs: id: setup-node uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 with: - node-version-file: .nvmrc + node-version-file: .tool-versions cache: npm - name: Install Dependencies diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index 12ef47c..5a6381e 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -33,7 +33,7 @@ jobs: id: setup-node uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 with: - node-version-file: .nvmrc + node-version-file: .tool-versions cache: npm - name: Install Dependencies