Documentation
¶
Index ¶
- type PackageJSON
- type Updater
- func (u *Updater) FindPackageJSON(ctx context.Context, path string) (string, error)
- func (u *Updater) ReadVersion(ctx context.Context, packagePath string) (string, error)
- func (u *Updater) Update(ctx context.Context, packagePath, newVersion string) (bool, error)
- func (u *Updater) UpdateVersion(ctx context.Context, packagePath, newVersion string) (bool, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PackageJSON ¶
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 ¶
NewUpdater creates a new package.json updater for the given repository directory.
func (*Updater) FindPackageJSON ¶
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 ¶
ReadVersion reads the current version from package.json.
func (*Updater) Update ¶
Update finds and updates the version in package.json if it exists. Returns whether the file was updated and any error.
func (*Updater) UpdateVersion ¶
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.