npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@bigfootds/unity-semver-updater

v0.0.5

Published

NodeJS tool to update a Unity project's version to a specified format - typically the semver format.

Downloads

7

Readme

@bigfootds/unity-semver-updater

NodeJS tool to update a Unity project's version to a specified format - typically the semver format.

The intention is that this package exists separate from any automation workflow actions that might use it, so we can quickly prototype and iterate on the logic without the hassle of running automated workflows. Looking at you, GitHub Actions, and how painful it is to run things locally.

For example, this GitHub Action will be converted to use this package as the core of its logic soon:

If you wanna use this package in your own actions, or you just wish to modify it or archive it or do whatever with it, you can do so - this package is licensed with MIT license!

Installation

Install this package from the NPM registry into your NodeJS project by running:

npm install @bigfootds/unity-semver-updater

Usage

const { findProjectSettingsPath } = require("../src/utils/autoFindProjectSettings"); // not part of the library - logic to glob files is not part of this package

const {
	ProjectSettingsHelpers
} = require("@bigfootds/unity-semver-updater");

async function app (){

	let targetFiles = await findProjectSettingsPath();
	let targetFile = targetFiles[0];

	let result = await ProjectSettingsHelpers.getExistingBundleVersion(targetFile);

	console.log("String formatter example:");

	// Default, per the semver spec:
	console.log(result.toString());
	console.log(result.toFormattedOutput());

	// Custom formats:
	console.log(result.toFormattedOutput("{major}-banana-{minor}"));

	// Typical version number structures per the Unity docs:
	let valuesToWrite = {
		bundleVersion: result.toFormattedOutput("{major}.{minor}.{patch}-{releaseLabel}+{buildLabel}"),
		buildNumber: {
			Standalone: Number.parseInt(result.toFormattedOutput("{major}{minor}{patch}")),
			iPhone: Number.parseInt(result.toFormattedOutput("{major}{minor}{patch}")),
			tvOS: Number.parseInt(result.toFormattedOutput("{major}{minor}{patch}"))
		},
		switchReleaseVersion: Number.parseInt(result.toFormattedOutput("{major}{minor}{patch}")),
		switchDisplayVersion: result.toFormattedOutput("{major}.{minor}.{patch}"),
		ps4MasterVersion: result.toFormattedOutput("{major}.{minor}"),
		ps4AppVersion: result.toFormattedOutput("{major}.{minor}"),
		metroPackageVersion: result.toFormattedOutput("{major}.{minor}.{patch}.{build}"),
		XboxOneVersion: result.toFormattedOutput("{major}.{minor}.{patch}.{build}"),
		psp2MasterVersion: result.toFormattedOutput("{major}.{minor}"),
		psp2AppVersion: result.toFormattedOutput("{major}.{minor}")
	}

	// Write a PlayerSettingsVersionStrings instance to the ProjectSettings.asset file:
	let writeResult = await ProjectSettingsHelpers.writeToProjectSettings(targetFile, valuesToWrite);

	// Boolean file update result:
	console.log("Write result: " + writeResult);
}

app();

When the above code is run and the ProjectSettings.asset file contains bundleVersion: 0.1.0.0-rc1, this will be the output:

String formatter example:
0.1.0-rc1
0.1.0
0-banana-1
Write result: true