|
1 |
| -/* eslint-disable security/detect-non-literal-fs-filename */ |
2 |
| -const { resolve } = require('path'); |
3 |
| -const { readFileSync, writeFileSync } = require('fs'); |
4 |
| -const simpleGit = require('simple-git'); |
5 |
| - |
6 |
| -const options = { |
7 |
| - baseDir: process.cwd(), |
8 |
| - binary: 'git', |
9 |
| - maxConcurrentProcesses: 6, |
10 |
| - trimmed: false, |
11 |
| -}; |
12 |
| - |
13 |
| -// when setting all options in a single object |
14 |
| -const git = simpleGit(options); |
15 |
| - |
16 |
| -// Get the latest commit hash of the current branch |
17 |
| -const getCurrentCommitHash = async () => { |
18 |
| - try { |
19 |
| - const logSummary = await git.log(); |
20 |
| - // get first 7 characters of the hash |
21 |
| - const commitHash = logSummary.latest.hash.slice(0, 7); |
22 |
| - console.log(`Current commit hash: ${commitHash}`); |
23 |
| - return commitHash; |
24 |
| - } catch (error) { |
25 |
| - console.error('Error occurred:', error); |
26 |
| - } |
27 |
| -}; |
28 |
| - |
29 | 1 | module.exports = {
|
30 | 2 | installCommand: () => 'npm i --prefer-offline --no-audit',
|
31 | 3 | buildCommand: () => null,
|
32 |
| - versionUpdated: async ({ version, dir }) => { |
33 |
| - const commitHash = await getCurrentCommitHash(); |
34 |
| - const packageJsonPath = resolve(dir, 'package.json'); |
35 |
| - const packageJson = JSON.parse(readFileSync(packageJsonPath).toString()); |
36 |
| - packageJson.version = `${version}+${commitHash}`; |
37 |
| - writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2)); |
38 |
| - }, |
39 |
| - publishCommand: ({ tag }) => `echo "Releasing ${tag} version of the app"`, |
| 4 | + publishCommand: ({ tag }) => |
| 5 | + `echo "Releasing ${tag} version of frontend webapp"`, |
40 | 6 | };
|
0 commit comments