Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: [#1731] Replace TSC build constant + Simplify version generation #2053

Merged
merged 3 commits into from
Oct 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"start": "npm run core:watch",
"build": "npm run core",
"core": "npm run core:tsc && npm run core:copy && npm run core:bundle",
"core:tsc": "tsc --project src/engine/tsconfig.json --incremental true --tsBuildInfoFile .tsbuildinfo",
"core:tsc": "tsc --project src/engine/tsconfig.json --incremental true --tsBuildInfoFile .tsbuildinfo && node ./scripts/excalibur-version.js",
"core:copy": "copyfiles -u 2 ./src/engine/**/*.png ./src/engine/**/*.css ./src/engine/**/*.glsl ./build/dist/",
"core:bundle": "webpack --progress --config webpack.config.js --mode production",
"core:watch": "npm run core:bundle -- --watch",
Expand Down Expand Up @@ -89,6 +89,7 @@
"karma-jasmine": "4.0.1",
"karma-webpack": "5.0.0",
"puppeteer": "10.4.0",
"replace-in-file": "6.2.0",
eonarheim marked this conversation as resolved.
Show resolved Hide resolved
"react": "^17.0.2",
"react-dom": "^17.0.2",
"rimraf": "3.0.2",
Expand Down
13 changes: 13 additions & 0 deletions scripts/excalibur-version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const replace = require('replace-in-file');
const version = require('../version').getCiVersion();
const options = {
files: 'build/dist/index.js',
from: /process\.env\.__EX_VERSION/g,
to: `'${version}'`
};
eonarheim marked this conversation as resolved.
Show resolved Hide resolved

try {
replace.sync(options);
} catch (e) {
console.error(e);
}
24 changes: 6 additions & 18 deletions version.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const { execSync } = require('child_process');
const semver = require('semver');
const package = require('./package.json');

function getCiOptions() {
return {
Expand All @@ -18,17 +19,8 @@ function getCurrentCommit() {
return commit;
}

function getLatestTag(commit) {
execSync('git fetch --depth=1000');
execSync('git fetch --all --tags');
const tag = execSync(`git describe --tags ${commit} --abbrev=0`).toString().trim();
return tag;
}

function getLatestVersion() {
const commit = getCurrentCommit();
const tag = getLatestTag(commit);
return tag.match(/^v?([0-9\.]+)$/)[1];
function getNextVersion() {
return package.exNextVersion;
}

function isTaggedRelease(options) {
Expand All @@ -52,8 +44,7 @@ function generateLocalVersion() {
try {
execSync('git fetch');
const commit = getCurrentCommit();
version = getLatestVersion();
version = semver.inc(version, 'minor');
version = getNextVersion();
version = version + '-' + commit.substring(0, 7);
} catch (err) {
console.error(err);
Expand All @@ -78,9 +69,7 @@ function generateCommunityVersion(options) {

function generateAlphaVersion(options) {
let commit = getCurrentCommit();
let version = getLatestVersion();
// Alpha builds target next projected release pre 1.0
version = semver.inc(version, 'minor');
let version = getNextVersion();

// Nuget doesn't yet support the + suffix in versions
const appveyVersion = version + '.' + options.appveyorBuild + '-alpha';
Expand Down Expand Up @@ -117,8 +106,7 @@ function getCiVersion(ciOptions, log = true) {

exports.getCiOptions = getCiOptions;
exports.getCurrentCommit = getCurrentCommit;
exports.getLatestTag = getLatestTag;
exports.getLatestVersion = getLatestVersion;
exports.getNextVersion = getNextVersion;
exports.isTaggedRelease = isTaggedRelease;
exports.isLocal = isLocal;
exports.isFork = isFork;
Expand Down