-
-
Notifications
You must be signed in to change notification settings - Fork 395
/
Copy path.postbump.cjs
44 lines (39 loc) · 1.15 KB
/
.postbump.cjs
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
const { execSync } = require('child_process')
const { readFileSync, writeFileSync } = require('fs')
const { version, dependencies } = require('./package.json')
const updates = [
[
'./src/index.ts',
/const VERSION = 'v\d+\.\d+\.\d+'/gm,
`const VERSION = 'v${version}'`,
],
[
'./build/index.js',
/const VERSION = 'v\d+\.\d+\.\d+'/gm,
`const VERSION = 'v${version}'`,
false,
],
]
for (const [path, regex, replace, gitAdd = true] of updates) {
writeFileSync(
path,
readFileSync(path, { encoding: 'utf-8' }).replace(regex, replace),
)
if (gitAdd) execSync(`git add ${path}`, { stdio: 'inherit' })
}
const jsr = require('./jsr.json')
jsr.imports = {}
jsr.version = version
for (const [dependency, semver] of Object.entries(dependencies)) {
switch (dependency) {
case 'jose':
case 'oauth4webapi':
jsr.imports[dependency] = `jsr:@panva/${dependency}@${semver}`
break
default:
throw new Error('unhandled jsr dependency')
}
}
writeFileSync('./jsr.json', JSON.stringify(jsr, null, 4) + '\n')
execSync(`git add ./jsr.json`, { stdio: 'inherit' })
execSync('git add build/* -f', { stdio: 'inherit' })