diff --git a/.eslintignore b/.eslintignore index 9d0b71a..394c154 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,2 +1,3 @@ build dist +distribution/generate-readme.js diff --git a/distribution/README.md b/distribution/README.md deleted file mode 100644 index e5cc10b..0000000 --- a/distribution/README.md +++ /dev/null @@ -1,5 +0,0 @@ -The source code can be found here: https://github.com/JetBrains/toolbox-browser-extension/ - -How to build: -1. Run 'yarn install' to install all the dependencies -2. Run 'yarn build' to build the code and copy it to the 'dist' subfolder diff --git a/distribution/generate-readme.js b/distribution/generate-readme.js new file mode 100644 index 0000000..2b80155 --- /dev/null +++ b/distribution/generate-readme.js @@ -0,0 +1,26 @@ +const chidProcess = require('child_process'); +const { writeFileSync } = require('fs'); + +const buffer = [ + 'The source code can be found here: [https://github.com/JetBrains/toolbox-browser-extension/](https://github.com/JetBrains/toolbox-browser-extension/).', + '\nUse the following data as your reference:' +]; + +const branch = chidProcess.execSync('git rev-parse --abbrev-ref HEAD').toString().trim(); +buffer.push(`* Branch: ${branch}`); +const longSHA = chidProcess.execSync("git rev-parse HEAD").toString().trim(); +buffer.push(`* Commit SHA: ${longSHA}`); +const shortSHA = chidProcess.execSync("git rev-parse --short HEAD").toString().trim(); +buffer.push(`* Commit short SHA: ${shortSHA}`); +const authorName = chidProcess.execSync("git log -1 --pretty=format:'%an'").toString().trim(); +buffer.push(`* Commit author: ${authorName}`); +const commitTime = chidProcess.execSync("git log -1 --pretty=format:'%cd'").toString().trim(); +buffer.push(`* Commit time: ${commitTime}`); +const commitMsg = chidProcess.execSync("git log -1 --pretty=%B").toString().trim(); +buffer.push(`* Commit message: ${commitMsg}`); + +buffer.push('\nHow to build:'); +buffer.push('1. Run \`yarn install\` to install all the dependencies'); +buffer.push('2. Run \`yarn build\` to build the code and save it to the \'dist\' subfolder'); + +writeFileSync('dist/README.md', buffer.join('\n')); diff --git a/package.json b/package.json index ff20b7b..14f748c 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "scripts": { "prebuild": "eslint .", "build": "webpack --bail -p", + "postbuild": "node distribution/generate-readme.js", "build:dev": "webpack --bail -p --mode=development --devtool=inline-source-map", "watch": "webpack -w" }, diff --git a/webpack.config.js b/webpack.config.js index ade37da..11a5fc5 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -84,8 +84,7 @@ module.exports = { {from: 'icons/icon-disabled-128.png', to: 'icon-disabled-128.png'}, {from: 'popup/common.css', to: 'jetbrains-toolbox-common.css'}, {from: 'popup/clone.html', to: 'jetbrains-toolbox-clone-popup.html'}, - {from: 'popup/disabled.html', to: 'jetbrains-toolbox-disabled-popup.html'}, - {from: 'distribution/README.md', to: 'README.md'} + {from: 'popup/disabled.html', to: 'jetbrains-toolbox-disabled-popup.html'} ] }), new LicenseChecker({