-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
76 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,5 +24,6 @@ | |
"jest": "^29.7.0", | ||
"typescript": "^5.2.2", | ||
"vite": "^5.0.5" | ||
} | ||
} | ||
}, | ||
"buildNumber": "master-C70" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) | ||
}, | ||
], | ||
}, | ||
}; |