Skip to content

Commit 134c025

Browse files
authored
[ignore] fix npm bump version (#52)
Signed-off-by: Augustin Husson <augustin.husson@amadeus.com>
1 parent bbf1d00 commit 134c025

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

scripts/npm-bump/npm-bump.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,24 @@ import (
2020
"path/filepath"
2121
"regexp"
2222

23-
"github.com/perses/perses/scripts/pkg/command"
2423
"github.com/perses/perses/scripts/pkg/npm"
2524
"github.com/sirupsen/logrus"
2625
)
2726

2827
var versionPattern = regexp.MustCompile(`^\d+\.\d+\.\d+(?:-[\w\d.]+)?$`)
2928

3029
func updatePackageVersion(workspaces []string, workspacePath string, newVersion string) error {
31-
// Use npm version command with --no-git-tag-version to avoid creating git tags
32-
// and --allow-same-version to allow setting the same version
33-
if err := command.RunInDirectory(workspacePath, "npm", "version", newVersion, "--no-git-tag-version", "--allow-same-version"); err != nil {
34-
return err
35-
}
3630
pkgPath := filepath.Join(workspacePath, "package.json")
3731
data, err := os.ReadFile(pkgPath)
3832
if err != nil {
3933
logrus.WithError(err).Fatalf("unable to read the file %s", pkgPath)
4034
}
35+
36+
// First, update the package version in the package.json
37+
bumpVersion := regexp.MustCompile(`"version":\s*"[0-9]+\.[0-9]+\.[0-9]+(-(alpha|beta|rc)\.[0-9]+)?"`)
38+
data = bumpVersion.ReplaceAll(data, []byte(fmt.Sprintf(`"version": "%s"`, newVersion)))
39+
40+
// Then, update all @perses-dev/* dependencies to the new version
4141
for _, workspace := range workspaces {
4242
bumpNPMDeps := regexp.MustCompile(fmt.Sprintf(`"@perses-dev/%s":\s*"(\^)?[0-9]+\.[0-9]+\.[0-9]+(-(alpha|beta|rc)\.[0-9]+)?"`, workspace))
4343
data = bumpNPMDeps.ReplaceAll(data, []byte(fmt.Sprintf(`"@perses-dev/%s": "%s"`, workspace, newVersion)))
@@ -67,6 +67,7 @@ func main() {
6767
return
6868
}
6969

70+
// First, update the root package.json
7071
if err := updatePackageVersion(workspaces, ".", version); err != nil {
7172
logrus.WithError(err).Fatal("failed to update root package.json")
7273
}

0 commit comments

Comments
 (0)