Skip to content

Commit

Permalink
fix: workspace can use only latest ci version of root
Browse files Browse the repository at this point in the history
  • Loading branch information
lukekarrys committed Sep 19, 2022
1 parent 4bbb731 commit 5fededb
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,13 @@ const getFullConfig = async ({
}

if (pkgConfig.ciVersions) {
const versions = pkgConfig.ciVersions
const defaultVersions = defaultConfig.ciVersions
const parsed = parseCIVersions(versions === 'latest' ? defaultVersions.slice(-1) : versions)
let versions = pkgConfig.ciVersions
if (versions === 'latest') {
const defaultVersions = [rootPkgConfig, defaultConfig].find(c => Array.isArray(c.ciVersions))
versions = defaultVersions.ciVersions.slice(-1)
}

const parsed = parseCIVersions(versions)
derived.ciVersions = parsed.targets
derived.engines = pkgConfig.engines || parsed.engines
}
Expand Down
34 changes: 34 additions & 0 deletions test/apply/engines.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,37 @@ t.test('latest ci versions', async (t) => {
const pkg = await s.readJson('package.json')
t.equal(pkg.engines.node, '>=18.0.0')
})

t.test('latest ci versions in workspace', async (t) => {
const s = await setup(t, {
package: {
templateOSS: {
content: 'content',
ciVersions: ['12.x', '14.x', '16.x'],
},
},
workspaces: {
a: {
templateOSS: {
ciVersions: 'latest',
},
},
},
testdir: {
content: {
'source.json': '{ "node": {{{ json engines }}} }',
'index.js': `module.exports={
rootRepo:{add:{'target.json':'source.json'}},
workspaceRepo:{add:{'target-{{ pkgNameFs }}.json':'source.json'}}
}`,
},
},
})
await s.apply()

const root = await s.readJson('target.json')
const workspace = await s.readJson('target-a.json')

t.equal(root.node, '^12.0.0 || ^14.0.0 || >=16.0.0')
t.equal(workspace.node, '>=16.0.0')
})

0 comments on commit 5fededb

Please # to comment.