From e442ec64a9e853378fa6c7eeef36af5b6917d18e Mon Sep 17 00:00:00 2001 From: Gustavo Perdomo Date: Wed, 22 Oct 2025 00:25:58 -0300 Subject: [PATCH] feat: add support for mise.toml file --- __tests__/main.test.ts | 36 +++++++++++++++++++----------------- dist/cache-save/index.js | 7 +++++-- dist/setup/index.js | 7 +++++-- src/util.ts | 8 ++++++-- 4 files changed, 35 insertions(+), 23 deletions(-) diff --git a/__tests__/main.test.ts b/__tests__/main.test.ts index 10ef15ba..41878fff 100644 --- a/__tests__/main.test.ts +++ b/__tests__/main.test.ts @@ -94,23 +94,25 @@ describe('main tests', () => { describe('getNodeVersionFromFile', () => { each` - contents | expected - ${'12'} | ${'12'} - ${'12.3'} | ${'12.3'} - ${'12.3.4'} | ${'12.3.4'} - ${'v12.3.4'} | ${'12.3.4'} - ${'lts/erbium'} | ${'lts/erbium'} - ${'lts/*'} | ${'lts/*'} - ${'nodejs 12.3.4'} | ${'12.3.4'} - ${'ruby 2.3.4\nnodejs 12.3.4\npython 3.4.5'} | ${'12.3.4'} - ${''} | ${''} - ${'unknown format'} | ${'unknown format'} - ${' 14.1.0 '} | ${'14.1.0'} - ${'{"volta": {"node": ">=14.0.0 <=17.0.0"}}'}| ${'>=14.0.0 <=17.0.0'} - ${'{"volta": {"extends": "./package.json"}}'}| ${'18.0.0'} - ${'{"engines": {"node": "17.0.0"}}'} | ${'17.0.0'} - ${'[tools]\ngo="latest"\nnode = "24.10"'} | ${'24.10'} - ${'{}'} | ${null} + contents | expected + ${'12'} | ${'12'} + ${'12.3'} | ${'12.3'} + ${'12.3.4'} | ${'12.3.4'} + ${'v12.3.4'} | ${'12.3.4'} + ${'lts/erbium'} | ${'lts/erbium'} + ${'lts/*'} | ${'lts/*'} + ${'nodejs 12.3.4'} | ${'12.3.4'} + ${'ruby 2.3.4\nnodejs 12.3.4\npython 3.4.5'} | ${'12.3.4'} + ${''} | ${''} + ${'unknown format'} | ${'unknown format'} + ${' 14.1.0 '} | ${'14.1.0'} + ${'{"volta": {"node": ">=14.0.0 <=17.0.0"}}'} | ${'>=14.0.0 <=17.0.0'} + ${'{"volta": {"extends": "./package.json"}}'} | ${'18.0.0'} + ${'{"engines": {"node": "17.0.0"}}'} | ${'17.0.0'} + ${'[tools]\ngo="latest"\nnode = "24.10"'} | ${'24.10'} + ${'[tools]\nnode = { version = "22.20" }'} | ${'22.20'} + ${'[tools]\nnode = { postinstall = "corepack enable" }'} | ${null} + ${'{}'} | ${null} `.it('parses "$contents"', ({contents, expected}) => { const existsSpy = jest.spyOn(fs, 'existsSync'); existsSpy.mockImplementation(() => true); diff --git a/dist/cache-save/index.js b/dist/cache-save/index.js index acb38778..52040899 100644 --- a/dist/cache-save/index.js +++ b/dist/cache-save/index.js @@ -93258,7 +93258,7 @@ function getNodeVersionFromFile(versionFilePath) { catch (_g) { core.info('Node version file is not JSON file'); } - // Try parsing the file as an MISE `mise.toml` file. + // Try parsing the file as a mise `mise.toml` file. try { const manifest = (0, js_toml_1.load)(contents); if ((_d = manifest === null || manifest === void 0 ? void 0 : manifest.tools) === null || _d === void 0 ? void 0 : _d.node) { @@ -93266,7 +93266,10 @@ function getNodeVersionFromFile(versionFilePath) { if (typeof node === 'object' && (node === null || node === void 0 ? void 0 : node.version)) { return node.version; } - return node; + if (typeof node === 'string') { + return node; + } + return null; } } catch (_h) { diff --git a/dist/setup/index.js b/dist/setup/index.js index f3b9ad16..f58eda2d 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -103773,7 +103773,7 @@ function getNodeVersionFromFile(versionFilePath) { catch (_g) { core.info('Node version file is not JSON file'); } - // Try parsing the file as an MISE `mise.toml` file. + // Try parsing the file as a mise `mise.toml` file. try { const manifest = (0, js_toml_1.load)(contents); if ((_d = manifest === null || manifest === void 0 ? void 0 : manifest.tools) === null || _d === void 0 ? void 0 : _d.node) { @@ -103781,7 +103781,10 @@ function getNodeVersionFromFile(versionFilePath) { if (typeof node === 'object' && (node === null || node === void 0 ? void 0 : node.version)) { return node.version; } - return node; + if (typeof node === 'string') { + return node; + } + return null; } } catch (_h) { diff --git a/src/util.ts b/src/util.ts index 16a590dc..29585478 100644 --- a/src/util.ts +++ b/src/util.ts @@ -57,7 +57,7 @@ export function getNodeVersionFromFile(versionFilePath: string): string | null { core.info('Node version file is not JSON file'); } - // Try parsing the file as an MISE `mise.toml` file. + // Try parsing the file as a mise `mise.toml` file. try { const manifest: Record = load(contents); if (manifest?.tools?.node) { @@ -67,7 +67,11 @@ export function getNodeVersionFromFile(versionFilePath: string): string | null { return node.version; } - return node; + if (typeof node === 'string') { + return node; + } + + return null; } } catch { core.info('Node version file is not TOML file');