Skip to content

Commit

Permalink
feat: print app name and version when running scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
hmerritt committed Jan 27, 2024
1 parent b556dc1 commit cfffbd4
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
4 changes: 4 additions & 0 deletions bootstrap.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,9 @@ async function bootstrap() {
const isTest = args.length >= 1 && args[0] === "vitest";
if (isTest) env[0][1] = "test";

// Log app name and version info
console.log(`${core.versionString(appName, appVersion, gitBranch, gitCommitHashShort)}\n`);

// Run bootstrap script
core.bootstrap(env, allowEnvOverride, args, path);
}
33 changes: 32 additions & 1 deletion scripts/bootstrap/core.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,36 @@ function runStream(command, path = __dirname) {
});
}

/**
* Returns version string including app name, version, git branch, and commit hash.
*
* This has been refactored from `/src/lib/global/version.ts`. @TODO make shared function and remove this one.
*
* E.g `App [Version 1.0.0 (development 4122b6...dc7c)]`
*/
const versionString = (appName = undefined, appVersion = undefined, gitBranch = undefined, gitCommitHash = undefined) => {
if (!appVersion) {
return `${appName} [Version unknown]`;
}

let versionString = `${appName} [Version ${appVersion}`;

if (gitCommitHash) {
versionString += ` (`;

// Branch name
versionString += `${gitBranch || "unknown"}/`;

// Commit hash
versionString += `${gitCommitHash})`;
}

versionString += `]`;

return versionString;
};


module.exports = {
bootstrap,
buildENV,
Expand All @@ -189,5 +219,6 @@ module.exports = {
overrideHardcodedENV,
run,
runStream,
shorten
shorten,
versionString
};

0 comments on commit cfffbd4

Please sign in to comment.