nodejs

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 9, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PackageJSON

type PackageJSON struct {
	Name    string `json:"name,omitempty"`
	Version string `json:"version"`
}

PackageJSON represents the minimal structure of a package.json file for version management purposes.

type Updater

type Updater struct {
	// contains filtered or unexported fields
}

Updater handles package.json version updates.

func NewUpdater

func NewUpdater(repoDir string, dryRun bool) *Updater

NewUpdater creates a new package.json updater for the given repository directory.

func (*Updater) FindPackageJSON

func (u *Updater) FindPackageJSON(ctx context.Context, path string) (string, error)

FindPackageJSON searches for package.json in the repository. If path is provided, it uses that path (relative to repoDir). Otherwise, it looks for package.json in the repository root.

func (*Updater) ReadVersion

func (u *Updater) ReadVersion(ctx context.Context, packagePath string) (string, error)

ReadVersion reads the current version from package.json.

func (*Updater) Update

func (u *Updater) Update(ctx context.Context, packagePath, newVersion string) (bool, error)

Update finds and updates the version in package.json if it exists. Returns whether the file was updated and any error.

func (*Updater) UpdateVersion

func (u *Updater) UpdateVersion(ctx context.Context, packagePath, newVersion string) (bool, error)

UpdateVersion updates the version in package.json while preserving formatting and comments. It uses regex to replace only the version field value, leaving everything else intact. Returns true if the version was changed, false if it was already the target version.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL