diff --git a/bump-build-version.js b/bump-build-version.js new file mode 100644 index 0000000..0b1196b --- /dev/null +++ b/bump-build-version.js @@ -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); diff --git a/package.json b/package.json index 86b647d..1965b0f 100644 --- a/package.json +++ b/package.json @@ -24,5 +24,6 @@ "jest": "^29.7.0", "typescript": "^5.2.2", "vite": "^5.0.5" - } -} + }, + "buildNumber": "master-C70" +} \ No newline at end of file diff --git a/src/scene/title-scene.ts b/src/scene/title-scene.ts index ef6e7c1..79c71b1 100644 --- a/src/scene/title-scene.ts +++ b/src/scene/title-scene.ts @@ -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 @@ -42,7 +42,7 @@ export default class TitleScene extends BaseScene { 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); diff --git a/tsconfig.json b/tsconfig.json index 935bb72..22a8df1 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -16,6 +16,11 @@ /* Linting */ "strict": true, "noFallthroughCasesInSwitch": true, + "paths": { + "@/*": [ + "./src/*" + ], + } }, "include": ["src"] } diff --git a/vite.config.ts b/vite.config.ts new file mode 100644 index 0000000..629bd62 --- /dev/null +++ b/vite.config.ts @@ -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)) + }, + ], + }, +}; \ No newline at end of file