diff --git a/bin/update-version.js b/bin/update-version.js index 769c01382..c1e0707e0 100755 --- a/bin/update-version.js +++ b/bin/update-version.js @@ -3,55 +3,17 @@ /** Create CSS file to import that prints project version */ const fs = require('fs'); +const path = require('../package.json'); const childProcess = require('child_process'); -const package = require('../package.json'); -const root = __dirname; -const outFile = root + '/../source/_version.css'; +// Get data +const appLicense = path.license; +const appGitRef = childProcess.execSync('git describe --always').toString(); +const filePath = __dirname + '/../source/_version.css'; +const fileContent = `/*! @tacc/core-styles ${appGitRef} | ${appLicense} | github.com/TACC/Core-Styles */` + "\n"; -/** - * Whether a Git revision look like something we can use - * @param {string} rev - The revision to check - * @return {boolean} - */ - function isGitRevOkay(rev) { - const isOkay = /[\da-z]+/.test(rev); +// Tell user +console.log(`Updating CSS version to ${appGitRef}`); - return isOkay; -} - -/** - * Get the Git revision of the current working directory code - * @return {string} - * @see https://stackoverflow.com/a/34518749/11817077 - */ -function getGitRev() { - const rev = childProcess.execSync('git rev-parse HEAD').toString(); - const isRevOkay = isGitRevOkay(rev); - - if ( ! isRevOkay) { - console.warn(`Revision looks odd. Is this okay?` + rev); - } - - return rev; -} - -/** - * Get data and write content to version file - * @return {string} - * @see https://stackoverflow.com/a/34518749/11817077 - */ -(async function writeRevToFile() { - // FP-1544: IF tags are annotated THEN replace version with `git describe` - const ver = package.version; - const rev = await getGitRev().substring(0, 7); - - const cssVersion = `#${rev} (≥ v${ver})`; - const cssLicense = package.license; - - const output = `/*! @tacc/core-styles${cssVersion} | ${cssLicense} | github.com/TACC/Core-Styles */` + "\n"; - - console.log(`Updating CSS version to ${cssVersion}`); - - fs.writeFileSync(outFile, output, 'utf8'); -})(); +// Write version +fs.writeFileSync( filePath, fileContent ); diff --git a/source/_version.css b/source/_version.css index 9d381e0a7..1eca01d80 100644 --- a/source/_version.css +++ b/source/_version.css @@ -1 +1,2 @@ -/*! @tacc/core-styles#bda1e9d (≥ v0.1.0) | MIT | github.com/TACC/Core-Styles */ +/*! @tacc/core-styles v0.1.0-6-ge1c85ae + | MIT | github.com/TACC/Core-Styles */