Skip to content

Commit

Permalink
TBX-4041: Generate dist README.md with git metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
maximmig committed Jun 2, 2020
1 parent db39350 commit 036bc97
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 7 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
build
dist
distribution/generate-readme.js
5 changes: 0 additions & 5 deletions distribution/README.md

This file was deleted.

26 changes: 26 additions & 0 deletions distribution/generate-readme.js
Original file line number Diff line number Diff line change
@@ -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'));
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
3 changes: 1 addition & 2 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down

0 comments on commit 036bc97

Please sign in to comment.