Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: workspace can use only latest ci version of root #207

Merged
merged 1 commit into from Sep 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 7 additions & 3 deletions lib/config.js
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
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')
})