-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathengines.js
90 lines (78 loc) · 2.04 KB
/
engines.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
const t = require('tap')
const { join } = require('path')
const setup = require('../setup.js')
t.test('can set engines and ci separately', async (t) => {
const s = await setup(t, {
package: {
templateOSS: {
engines: '>=10',
},
},
})
await s.apply()
const pkg = await s.readJson('package.json')
const ci = await s.readFile(join('.github', 'workflows', 'ci.yml'))
t.equal(pkg.engines.node, '>=10')
t.notOk(ci.includes('- 10'))
t.notOk(ci.includes('- 12'))
})
t.test('can set ci to latest plus other versions', async (t) => {
const s = await setup(t, {
package: {
templateOSS: {
ciVersions: ['6', '8', 'latest'],
engines: '*',
},
},
})
await s.apply()
const pkg = await s.readJson('package.json')
const ci = await s.readFile(join('.github', 'workflows', 'ci.yml'))
t.equal(pkg.engines.node, '*')
t.ok(ci.includes('- 6'))
t.ok(ci.includes('- 8'))
t.ok(ci.includes('- 18.x'))
})
t.test('latest ci versions', async (t) => {
const s = await setup(t, {
package: {
templateOSS: {
ciVersions: 'latest',
},
},
})
await s.apply()
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')
})