forked from sourcegraph/sourcegraph-public-snapshot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpublish-npm.ts
More file actions
50 lines (48 loc) · 1.54 KB
/
publish-npm.ts
File metadata and controls
50 lines (48 loc) · 1.54 KB
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
import { writeFile } from 'mz/fs'
import latestVersion from 'latest-version'
import signale from 'signale'
import * as semver from 'semver'
import execa from 'execa'
import * as path from 'path'
// Publish the native integration to npm
async function main(): Promise<void> {
const name = '@sourcegraph/code-host-integration'
// Bump version
let version: string
try {
const currentVersion = await latestVersion(name)
signale.info(`Current version is ${currentVersion}`)
version = semver.inc(currentVersion, 'patch')!
} catch (err) {
if (err && err.name === 'PackageNotFoundError') {
signale.info('Package is not released yet')
version = '0.0.0'
} else {
throw err
}
}
const packageJson = {
name,
version,
license: 'Apache-2.0',
repository: {
type: 'git',
url: 'https://github.com/sourcegraph/sourcegraph',
directory: 'browser',
},
}
signale.info(`New version is ${packageJson.version}`)
// Write package.json
const packagePath = path.resolve(__dirname, '..', 'build', 'integration')
await writeFile(path.join(packagePath, 'package.json'), JSON.stringify(packageJson, null, 2))
if (!process.env.CI) {
signale.warn('Not running in CI, aborting')
return
}
// Publish
await execa('npm', ['publish', '--access', 'public'], { cwd: packagePath, stdio: 'inherit' })
}
main().catch(err => {
process.exitCode = 1
console.error(err)
})