Skip to content

Commit d9d16c4

Browse files
committed
chore: add bump deno
1 parent 84c19f0 commit d9d16c4

File tree

4 files changed

+52
-4
lines changed

4 files changed

+52
-4
lines changed

bun.lockb

1.19 KB
Binary file not shown.

deno/web.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { parse, serialize } from 'npm:cookie-es'
1+
import { parse, serialize } from 'npm:cookie-es@^1.0.0'
22
import {
33
getExistCookies,
44
getHeaderLanguagesWithGetter,

package.json

+7-3
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
"prepare": "git config --local core.hooksPath .githooks",
7070
"changelog": "gh-changelogen --repo=intlify/utils",
7171
"release": "bumpp --commit \"release: v%s\" --push --tag",
72+
"version": "npx tsx scripts/bump-deno.ts",
7273
"fix": "run-p lint format",
7374
"lint": "deno lint",
7475
"format": "deno fmt",
@@ -103,6 +104,7 @@
103104
"devDependencies": {
104105
"@cloudflare/workers-types": "^4.20231016.0",
105106
"@types/node": "^20.11.24",
107+
"@types/semver": "^7.5.8",
106108
"@types/supertest": "^2.0.12",
107109
"@vitest/coverage-v8": "^1.3.0",
108110
"bumpp": "^9.2.0",
@@ -111,12 +113,14 @@
111113
"gh-changelogen": "^0.2.8",
112114
"h3": "^1.8.1",
113115
"hono": "^3.8.1",
116+
"jsonc-parser": "^3.2.1",
114117
"lint-staged": "^15.0.0",
115-
"npm-run-all2": "^6.0.0",
116118
"miniflare": "^3.20231016.0",
117-
"supertest": "^6.3.3",
118-
"playwright": "^1.38.1",
119+
"npm-run-all2": "^6.0.0",
119120
"pkg-types": "^1.0.2",
121+
"playwright": "^1.38.1",
122+
"semver": "^7.6.0",
123+
"supertest": "^6.3.3",
120124
"typescript": "^5.4.1-rc",
121125
"unbuild": "^2.0.0",
122126
"vitest": "^1.3.0",

scripts/bump-deno.ts

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { applyEdits, modify, parse } from 'jsonc-parser'
2+
import { promises as fs } from 'node:fs'
3+
import { resolve } from 'node:path'
4+
import semver from 'semver'
5+
import { readPackageJSON } from 'pkg-types'
6+
7+
import type { ParseError } from 'jsonc-parser'
8+
9+
async function main() {
10+
const npmPath = resolve(process.cwd(), 'package.json')
11+
const npm = await readPackageJSON(npmPath)
12+
if (npm.version == null) {
13+
throw new Error('Failed to read package.json: version is not found')
14+
}
15+
16+
const denoPath = resolve(process.cwd(), 'deno.jsonc')
17+
const denoConfig = await fs.readFile(denoPath, 'utf-8').catch(() => '{}')
18+
const errors: ParseError[] = []
19+
const deno = parse(denoConfig, errors, { allowTrailingComma: true })
20+
if (errors.length > 0) {
21+
throw new Error(`Failed to parse deno.jsonc: ${errors.map((e) => e.error).join(', ')}`)
22+
}
23+
if (deno.version == null) {
24+
throw new Error('Failed to read deno.jsonc: version is not found')
25+
}
26+
27+
if (!semver.gt(npm.version, deno.version)) {
28+
throw new Error(
29+
`Failed to bump: npm version (${npm.version}) is not greater than deno version (${deno.version})`,
30+
)
31+
}
32+
33+
console.log(`Bump deno version to ${npm.version}`)
34+
const denoConfigEdit = modify(denoConfig, ['version'], npm.version, {
35+
formattingOptions: { tabSize: 2, insertSpaces: true },
36+
})
37+
const denoConfigModified = applyEdits(denoConfig, denoConfigEdit)
38+
await fs.writeFile(denoPath, denoConfigModified)
39+
}
40+
41+
main().catch((err) => {
42+
console.error(err)
43+
process.exit(1)
44+
})

0 commit comments

Comments
 (0)