FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
sentry-javascript/scripts/bump-version.js at develop · getsentry/sentry-javascript · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
getsentry
/
sentry-javascript
Public
Uh oh!
There was an error while loading.
Please reload this page
.
Notifications
You must be signed in to change notification settings
Fork
1.8k
Star
8.7k
Code
Issues
545
Pull requests
67
Discussions
Actions
Security and quality
5
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
sentry-javascript
/
scripts
/
bump-version.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
118 lines (94 loc) · 4.07 KB
Breadcrumbs
sentry-javascript
/
scripts
/
bump-version.js
Copy path
File metadata and controls
118 lines (94 loc) · 4.07 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
const
fs
=
require
(
'fs'
)
;
const
path
=
require
(
'path'
)
;
function
readJson
(
filePath
)
{
return
JSON
.
parse
(
fs
.
readFileSync
(
filePath
,
'utf-8'
)
)
;
}
function
updateWorkspaceDeps
(
pkgPath
,
workspaceNames
,
newVersion
,
{
bumpVersion
}
=
{
}
)
{
const
pkg
=
JSON
.
parse
(
fs
.
readFileSync
(
pkgPath
,
'utf-8'
)
)
;
if
(
bumpVersion
)
{
pkg
.
version
=
newVersion
;
}
for
(
const
depType
of
[
'dependencies'
,
'devDependencies'
,
'peerDependencies'
]
)
{
if
(
!
pkg
[
depType
]
)
continue
;
for
(
const
[
dep
,
ver
]
of
Object
.
entries
(
pkg
[
depType
]
)
)
{
if
(
workspaceNames
.
has
(
dep
)
&&
!
ver
.
startsWith
(
'workspace:'
)
)
{
pkg
[
depType
]
[
dep
]
=
newVersion
;
}
}
}
if
(
pkg
.
pnpm
?.
overrides
)
{
for
(
const
[
dep
,
value
]
of
Object
.
entries
(
pkg
.
pnpm
.
overrides
)
)
{
if
(
!
workspaceNames
.
has
(
dep
)
)
continue
;
pkg
.
pnpm
.
overrides
[
dep
]
=
value
.
replace
(
/
(?<
=
s
e
n
t
r
y
-
[
\w
-
]
+
-
)
\d
+
\.
\d
+
\.
\d
+
(
-
[
\w
.
]
+
)
?
(?
=
\.
t
g
z
$
)
/
,
newVersion
)
;
}
}
fs
.
writeFileSync
(
pkgPath
,
JSON
.
stringify
(
pkg
,
null
,
2
)
+
'\n'
)
;
return
pkg
;
}
/**
* Bumps the version of all workspace packages and their internal dependencies.
* This replicates the behavior of:
* lerna version --force-publish --exact --no-git-tag-version --no-push --include-merged-tags --yes <newVersion>
*
* Specifically:
* - Updates `version` in every workspace package.json to newVersion
* - Updates all internal workspace dependency references (dependencies, devDependencies, peerDependencies)
* to the new exact version (no ^ or ~ prefix), matching lerna's --exact flag
* - --force-publish: all packages are updated regardless of whether they changed
* - No git tags, commits, or pushes are made
*/
function
bumpVersions
(
rootDir
,
newVersion
)
{
const
rootPkgPath
=
path
.
join
(
rootDir
,
'package.json'
)
;
const
rootPkg
=
JSON
.
parse
(
fs
.
readFileSync
(
rootPkgPath
,
'utf-8'
)
)
;
const
workspaces
=
rootPkg
.
workspaces
;
if
(
!
workspaces
||
!
Array
.
isArray
(
workspaces
)
)
{
throw
new
Error
(
'Could not find workspaces in root package.json'
)
;
}
// Read all workspace package.json files upfront.
// This ensures we fail early if any workspace is unreadable,
// before writing any changes (no partial updates).
const
workspaceNames
=
new
Set
(
)
;
const
workspacePkgPaths
=
[
]
;
for
(
const
workspace
of
workspaces
)
{
const
pkgPath
=
path
.
join
(
rootDir
,
workspace
,
'package.json'
)
;
const
pkg
=
readJson
(
pkgPath
)
;
workspaceNames
.
add
(
pkg
.
name
)
;
workspacePkgPaths
.
push
(
pkgPath
)
;
}
// Apply version bumps
for
(
const
pkgPath
of
workspacePkgPaths
)
{
updateWorkspaceDeps
(
pkgPath
,
workspaceNames
,
newVersion
,
{
bumpVersion
:
true
}
)
;
}
// Update bundler-plugin integration test fixtures.
// These are standalone pnpm projects (not workspaces) that reference local tarballs
// with version-stamped filenames, so they need explicit patching.
const
fixturesDir
=
path
.
join
(
rootDir
,
'dev-packages'
,
'bundler-plugin-integration-tests'
,
'fixtures'
)
;
if
(
fs
.
existsSync
(
fixturesDir
)
)
{
for
(
const
entry
of
fs
.
readdirSync
(
fixturesDir
,
{
withFileTypes
:
true
}
)
)
{
if
(
!
entry
.
isDirectory
(
)
)
continue
;
const
fixturePkgPath
=
path
.
join
(
fixturesDir
,
entry
.
name
,
'package.json'
)
;
if
(
!
fs
.
existsSync
(
fixturePkgPath
)
)
continue
;
updateWorkspaceDeps
(
fixturePkgPath
,
workspaceNames
,
newVersion
)
;
}
}
return
workspacePkgPaths
.
length
;
}
// CLI entry point
if
(
require
.
main
===
module
)
{
const
newVersion
=
process
.
argv
[
2
]
;
if
(
!
newVersion
)
{
console
.
error
(
'Usage: node scripts/bump-version.js <new-version>'
)
;
process
.
exit
(
1
)
;
}
const
rootDir
=
path
.
join
(
__dirname
,
'..'
)
;
const
updatedCount
=
bumpVersions
(
rootDir
,
newVersion
)
;
// Write a .version file used by the gitflow sync workflow to detect version bumps
const
versionFile
=
{
_comment
:
'Auto-generated by scripts/bump-version.js. Used by the gitflow sync workflow to detect version bumps. Do not edit manually.'
,
version
:
newVersion
,
}
;
fs
.
writeFileSync
(
path
.
join
(
rootDir
,
'.version.json'
)
,
JSON
.
stringify
(
versionFile
,
null
,
2
)
+
'\n'
)
;
console
.
log
(
`Updated
${
updatedCount
}
packages to version
${
newVersion
}
`
)
;
}
module
.
exports
=
{
bumpVersions
}
;
Back
|
FazBrowse Home
|
New Git URL