Skip to content

Commit 2b31c3a

Browse files
committed
Update Prettier to v3.6.2 and improve release script
Upgrades Prettier from v2.1.2 to v3.6.2 in dependencies. Updates the release PR generation script to read dependencies.json asynchronously, use a relative path, and improve formatting and logic for update detection and output. Also fixes the workflow to use the correct commit message output.
1 parent b6d6cfa commit 2b31c3a

File tree

4 files changed

+65
-43
lines changed

4 files changed

+65
-43
lines changed

.github/workflows/update-dependencies.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ jobs:
8181
token: ${{ steps.generate-token.outputs.token }}
8282
branch: update-dependencies-auto-${{ github.run_id }}
8383
delete-branch: true
84-
commit-message: ${{ steps.pr-contents.outputs.commit-message }}
84+
commit-message: ${{ steps.pr-contents.outputs.title }}
8585
title: ${{ steps.pr-contents.outputs.title }}
8686
body-path: ./pr-body.md
8787
draft: false

package-lock.json

Lines changed: 13 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"@types/node": "^22.14.0",
3030
"@types/semver": "^6.0.0",
3131
"@types/yargs": "^13.0.3",
32-
"prettier": "^2.1.2",
32+
"prettier": "^3.6.2",
3333
"semver": "^6.1.1",
3434
"tsx": "^4.20.6",
3535
"typescript": "^5.9.3",

script/generate-release-pr-contents.mjs

Lines changed: 50 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
import { createWriteStream } from 'fs'
2-
import dependencies from '../dependencies.json' with { type: 'json' }
2+
import { readFile } from 'fs/promises'
3+
import { join } from 'path'
34
import { execFile } from 'child_process'
45
import { promisify } from 'util'
56

67
const execFileAsync = promisify(execFile)
78

8-
const { stdout } = await execFileAsync('git', ['show', 'HEAD:dependencies.json'])
9+
const { stdout } = await execFileAsync('git', [
10+
'show',
11+
'HEAD~50:dependencies.json',
12+
])
913
const previousDependencies = JSON.parse(stdout)
10-
const currentDependencies = dependencies
14+
const currentDependencies = JSON.parse(
15+
await readFile(join(import.meta.dirname, '..', 'dependencies.json'), 'utf8')
16+
)
1117

1218
const listFormatter = new Intl.ListFormat('en')
1319

14-
const findG4WVersion = (deps) => {
20+
const findG4WVersion = deps => {
1521
const url = deps.git.packages.find(x => x.platform === 'windows')?.url
1622

1723
if (url) {
@@ -24,37 +30,49 @@ const findG4WVersion = (deps) => {
2430
}
2531

2632
const updates = {
27-
"Git": currentDependencies.git.version !== previousDependencies.git.version ? {
28-
from: previousDependencies.git.version,
29-
to: currentDependencies.git.version
30-
} : undefined,
31-
"G4W": findG4WVersion(currentDependencies) !== findG4WVersion(previousDependencies) ? {
32-
from: findG4WVersion(previousDependencies),
33-
to: findG4WVersion(currentDependencies)
34-
} : undefined,
35-
"LFS": currentDependencies['git-lfs'].version !== previousDependencies['git-lfs'].version ? {
36-
from: previousDependencies['git-lfs'].version,
37-
to: currentDependencies['git-lfs'].version
38-
} : undefined,
39-
"GCM": currentDependencies['git-credential-manager'].version !== previousDependencies['git-credential-manager'].version ? {
40-
from: previousDependencies['git-credential-manager'].version,
41-
to: currentDependencies['git-credential-manager'].version
42-
} : undefined,
33+
Git:
34+
currentDependencies.git.version !== previousDependencies.git.version
35+
? {
36+
from: previousDependencies.git.version,
37+
to: currentDependencies.git.version,
38+
}
39+
: undefined,
40+
G4W:
41+
findG4WVersion(currentDependencies) !== findG4WVersion(previousDependencies)
42+
? {
43+
from: findG4WVersion(previousDependencies),
44+
to: findG4WVersion(currentDependencies),
45+
}
46+
: undefined,
47+
LFS:
48+
currentDependencies['git-lfs'].version !==
49+
previousDependencies['git-lfs'].version
50+
? {
51+
from: previousDependencies['git-lfs'].version,
52+
to: currentDependencies['git-lfs'].version,
53+
}
54+
: undefined,
55+
GCM:
56+
currentDependencies['git-credential-manager'].version !==
57+
previousDependencies['git-credential-manager'].version
58+
? {
59+
from: previousDependencies['git-credential-manager'].version,
60+
to: currentDependencies['git-credential-manager'].version,
61+
}
62+
: undefined,
4363
}
4464

45-
const updatedComponents = Array.from(Object.entries(updates).filter(([_, v]) => v !== undefined).map(([k]) => k))
65+
const updatedComponents = Array.from(
66+
Object.entries(updates).filter(([_, v]) => v !== undefined)
67+
)
4668

4769
if (updatedComponents.length === 0) {
4870
console.log('title=Update dependencies')
4971
} else {
50-
console.log(`title=Update ${listFormatter.format(updatedComponents)}`)
51-
}
52-
53-
if (updatedComponents.length === 0) {
54-
console.log('commit-message=Update dependencies')
55-
} else {
56-
const parts = Object.entries(updates).filter(([_, v]) => v !== undefined).map(([k, v]) => `${k} to ${v.to}`)
57-
console.log(`commit-message=Update ${listFormatter.format(parts)}`)
72+
const parts = Object.entries(updates)
73+
.filter(([_, v]) => v !== undefined)
74+
.map(([k, v]) => `${k} to ${v.to}`)
75+
console.log(`title=Update ${listFormatter.format(parts)}`)
5876
}
5977

6078
const bodyStream = createWriteStream('pr-body.md', 'utf8')
@@ -67,15 +85,15 @@ wl(
6785
wl(``)
6886

6987
if (updates.Git) {
70-
wl(`- Updated Git from ${updates.Git.from} to ${updates.Git.to}`)
88+
wl(`- Updated Git from ${updates.Git.from} to ${updates.Git.to}`)
7189
}
7290

7391
if (updates.G4W) {
74-
wl(`- Updated G4W from ${updates.G4W.from} to ${updates.G4W.to}`)
92+
wl(`- Updated G4W from ${updates.G4W.from} to ${updates.G4W.to}`)
7593
}
7694

7795
if (updates.LFS) {
78-
wl(`- Updated Git LFS from ${updates.LFS.from} to ${updates.LFS.to}`)
96+
wl(`- Updated Git LFS from ${updates.LFS.from} to ${updates.LFS.to}`)
7997
}
8098

8199
if (updates.GCM) {

0 commit comments

Comments
 (0)