UNPKG

outsystems-design-tokens

Version:

Store the Design Tokens used on the Ionic Framework and Widgets Library

71 lines (54 loc) 2.21 kB
/* Summary: Script to bump the package version. Workflow: 1. Create new branch 'bump/${version}' 2. Bump version on package.json 3. Commit and push branch to GitHub 4. Create pull request in Github Arguments: releaseType - [major | minor | patch] isPreRelease - [pre] additionalIdentifiers - [pre-release identifier] */ const execSync = require("child_process").execSync; function exec(cmd) { execSync(cmd, { stdio: "inherit", env: process.env }); } function execAndOutput(cmd) { return execSync(cmd, { env: process.env }).toString(); } function makeVersionCommand(releaseType, isPreRelease, additionalIdentifiers) { return `${isPreRelease && releaseType !== "prerelease" ? "pre" : ""}${releaseType} ${ isPreRelease ? `--preid=${additionalIdentifiers}` : "" }`; } const semVerReleaseTypes = ["major", "minor", "patch", "prerelease"]; const releaseType = process.argv[2]; const isPreRelease = releaseType === "prerelease" || process.argv[3] === "pre"; const additionalIdentifiers = process.argv[4] ?? process.argv[3]; if (!semVerReleaseTypes.some((el) => el === releaseType)) { console.log(`Invalid release type! Only ${semVerReleaseTypes.join(", ")} allowed.`); process.exit(); } if (isPreRelease && !additionalIdentifiers) { console.log( `Pre-releases require an additional identifier to be appended to the version number. Ex: 'alpha' or 'beta'.`, ); process.exit(); } exec("git pull"); const versionCommandArgument = makeVersionCommand(releaseType, isPreRelease, additionalIdentifiers); exec(`npm version ${versionCommandArgument} --no-git-tag-version`); const cwd = process.cwd(); const currentBranch = execAndOutput("git branch --no-color --show-current").replace(/[\r\n]+/, ""); const newVersionNumber = require("./../package.json").version; const newBranch = `bump/${releaseType}-${newVersionNumber}`; exec(`git checkout -b ${newBranch}`); exec("git add -u"); exec(`git commit -m "Bump version to ${newVersionNumber}"`); exec(`git push -u origin ${newBranch}`); exec( `gh pr create --title "Bump version to ${newVersionNumber}" --body "Bump package version to ${newVersionNumber}" --base ${currentBranch}`, ); process.chdir(cwd);