-
Notifications
You must be signed in to change notification settings - Fork 309
/
macos.test.ts
52 lines (47 loc) · 1.76 KB
/
macos.test.ts
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
import {test} from '@oclif/test'
import {findDistFileSha, developerSalesforceCom, deleteFolder} from '../helpers/helper'
import * as fs from 'fs-extra'
import * as path from 'path'
import {promisify} from 'node:util'
import {pipeline as pipelineSync} from 'node:stream'
import got from 'got'
const pipeline = promisify(pipelineSync)
const pjson = require('../../package.json')
const pjsonPath = require.resolve('../../package.json')
const originalVersion = pjson.version
const onlyMacos = process.platform === 'darwin' ? test : test.skip()
const testRun = `test-${Math.random().toString().split('.')[1].slice(0, 4)}`
describe('publish:macos', () => {
const cwd = process.cwd()
let pkg: string
let sha: string
let bucket: string
let basePrefix: string
const root = path.join(__dirname, '../tmp/test/publish')
beforeEach(async () => {
pjson.version = `${pjson.version}-${testRun}`
pjson.oclif.update.node.version = process.versions.node
bucket = pjson.oclif.update.s3.bucket
basePrefix = pjson.oclif.update.s3.folder
await deleteFolder(bucket, `${basePrefix}/versions/${pjson.version}/`)
await fs.writeJSON(pjsonPath, pjson, {spaces: 2})
await fs.emptyDir(root)
})
afterEach(async () => {
await deleteFolder(bucket, `${basePrefix}/versions/${pjson.version}/`)
pjson.version = originalVersion
await fs.writeJSON(pjsonPath, pjson, {spaces: 2})
})
onlyMacos
.command(['pack:macos'])
.do(async () => {
[pkg, sha] = await findDistFileSha(cwd, 'macos', f => f.endsWith('pkg'))
})
.command(['upload:macos'])
.it('publishes valid releases', async () => {
await pipeline(
got.stream(`https://${developerSalesforceCom}/${basePrefix}/versions/${pjson.version}/${sha}/${pkg}`),
fs.createWriteStream(pkg),
)
})
})