Skip to content

Commit

Permalink
Update package.json
Browse files Browse the repository at this point in the history
  • Loading branch information
NouCake committed Feb 12, 2024
1 parent b19cbd6 commit e063654
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 5 deletions.
49 changes: 49 additions & 0 deletions bump-build-version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { execSync } from 'child_process';
import { readFileSync, writeFileSync } from 'fs';

function getGitBranch() {
try {
// Get the current Git branch
const branch = execSync('git rev-parse --abbrev-ref HEAD').toString().trim();
return branch;
} catch (error) {
console.error('Error getting Git branch:', error.message);
process.exit(1);
}
}

function getCommitCount() {
try {
// Get the number of commits on the current branch
const commitCount = execSync('git rev-list --count HEAD').toString().trim();
return commitCount;
} catch (error) {
console.error('Error getting commit count:', error.message);
process.exit(1);
}
}

function generateBuildNumber(branch, commitCount) {
// Replace special characters in branch name with underscores
const sanitizedBranch = branch.replace(/[^a-zA-Z0-9]/g, '_');

// Combine branch name and commit count to create a unique build number
const buildNumber = `${sanitizedBranch}-C${commitCount}`;

return buildNumber;
}

// Get the current Git branch
const currentBranch = getGitBranch();

// Get the number of commits on the current branch
const commitCount = getCommitCount();

// Generate build number based on the branch name and commit count
const buildNumber = generateBuildNumber(currentBranch, commitCount);

const pjson = JSON.parse(readFileSync('./package.json', 'utf8'));
pjson.buildNumber = buildNumber;
writeFileSync('./package.json', JSON.stringify(pjson, null, 2));

console.log('Build Number:', buildNumber);
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@
"jest": "^29.7.0",
"typescript": "^5.2.2",
"vite": "^5.0.5"
}
}
},
"buildNumber": "master-C70"
}
6 changes: 3 additions & 3 deletions src/scene/title-scene.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import AzNopolyGame from "../game";
import { HEIGHT, WIDTH } from "../main";
import { RoomEvent } from "../room";
import { AzNopolyButton } from "../ui/button";
import {FONT_STYLE_COPYRIGHT_FLAVOUR_TEXT, FONT_STYLE_TITLE_TEXT} from "../style.ts";
import Rectangle = Phaser.GameObjects.Rectangle;
import TitleSceneController from "./title-scene-controller";
import { BaseScene } from "./base/base-scene.ts";
import { BaseScene } from "@/scene/base/base-scene.ts";
import * as pjson from "@/../package.json"

type Audio = Phaser.Sound.WebAudioSound | Phaser.Sound.NoAudioSound | Phaser.Sound.HTML5AudioSound

Expand Down Expand Up @@ -42,7 +42,7 @@ export default class TitleScene extends BaseScene<TitleSceneController> {

create() {
const titleText = " AzNopoly "
const copyrightText = "© 2024 AzNopoly - v.0.0.dev-preAlpha";
const copyrightText = "© 2024 AzNopoly - (build " + ((pjson || {}) as any).buildNumber + ")";
const background = this.add.image(0, 0, 'abstracto');
const targetScale = WIDTH / background.width;
background.setScale(targetScale);
Expand Down
5 changes: 5 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
/* Linting */
"strict": true,
"noFallthroughCasesInSwitch": true,
"paths": {
"@/*": [
"./src/*"
],
}
},
"include": ["src"]
}
16 changes: 16 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { fileURLToPath } from 'node:url';
import path from 'path';

console.log("HAAAAAAAaaaaaaaaaaaaaaaa", path.resolve(__dirname, 'src/'))

export default {

resolve: {
alias: [
{
find: '@',
replacement: fileURLToPath(new URL('./src', import.meta.url))
},
],
},
};

0 comments on commit e063654

Please sign in to comment.