Skip to content

Commit

Permalink
feat: changelog generator (#431)
Browse files Browse the repository at this point in the history
* added release script include auto generate of changelog

* docs(release): releasing 1.15.3

* docs: changelog + readme

* docs(release): releasing 1.15.4

* feat: gulp tasks
  • Loading branch information
bc-zoharmuzafi authored Dec 26, 2018
1 parent d7d98f6 commit 9e6e225
Show file tree
Hide file tree
Showing 16 changed files with 509 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ cache:
directories:
- node_modules
install:
- npm install --production
- npm install
script:
- npm test
30 changes: 30 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<a name="1.15.4"></a>
## <small>1.15.4 (2018-12-17)</small>

* fix(cp): STRF-5614 Add enhanced_ecommerce to theme config schema. ([58c6fb9](https://github.com/bigcommerce/stencil-cli/commit/58c6fb9))



<a name="1.15.3"></a>
## <small>1.15.3 (2018-12-11)</small>

* upgrade paper package to 2.0.10 ([b4ec832](https://github.com/bigcommerce/stencil-cli/commit/b4ec832))
* Proper error handling for bundle task ([a4dc6c9](https://github.com/bigcommerce/stencil-cli/commit/a4dc6c9))
* PROJECT-1897: Card Management - List, Delete, Edit, Add Cards ([44022a0](https://github.com/bigcommerce/stencil-cli/commit/44022a0))
* Increase timeout for build worker process to be ready ([794e796](https://github.com/bigcommerce/stencil-cli/commit/794e796))
* log push errors to the console ([a9aca72](https://github.com/bigcommerce/stencil-cli/commit/a9aca72))
* update paper npm version ([d5f78a4](https://github.com/bigcommerce/stencil-cli/commit/d5f78a4))
* Point to http instead of https for stencil editor sdk. ([0a9acf6](https://github.com/bigcommerce/stencil-cli/commit/0a9acf6))
* Update README ([298beaa](https://github.com/bigcommerce/stencil-cli/commit/298beaa))
* Deprecate support for node 4.x ([e5c3e96](https://github.com/bigcommerce/stencil-cli/commit/e5c3e96))
* Deprecate support for node 4.x ([1ead058](https://github.com/bigcommerce/stencil-cli/commit/1ead058))
* Bundle all webpack files + release 1.15.0 ([537bb93](https://github.com/bigcommerce/stencil-cli/commit/537bb93))
* STRF-4889: Fix error message for upload limit ([95ba66b](https://github.com/bigcommerce/stencil-cli/commit/95ba66b))
* Update paper & bump version ([9217d6f](https://github.com/bigcommerce/stencil-cli/commit/9217d6f))
* adding -a and --activate flags to stencil push ([5f2ceb8](https://github.com/bigcommerce/stencil-cli/commit/5f2ceb8))
* Update README.md to include min versions of Node ([cf9798c](https://github.com/bigcommerce/stencil-cli/commit/cf9798c))
* trailing comma on output ([0d77cd6](https://github.com/bigcommerce/stencil-cli/commit/0d77cd6))
* ability to locally save bundled theme after push ([f9610d0](https://github.com/bigcommerce/stencil-cli/commit/f9610d0))



1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Unsure where to begin contributing to Stencil CLI? Check our [forums](https://fo

### Git Commit Messages

* Commit message should follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0-beta.2/) structure
* Use the present tense ("Add feature" not "Added feature")
* Use the imperative mood ("Move cursor to..." not "Moves cursor to...")
* Limit the first line to 72 characters or less
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ Stencil CLI comes packaged with [Autoprefixer](https://github.com/postcss/autopr

If you need any help or experience any bugs, please create a GitHub issue in this repository.

## Release stencil-cli
In order to release stencil-cli you should first use the `Squash and merge` option on GitHub, This step is important for generating the `CHANGELOG.md` file with the pr link attached (if not using `Squash and merge`, the changes will be logged only with links to the commits). After the changes are merged to master, pull the latest to your local environment, run `gulp release` and follow the prompts. NOTE: It is required that all commit messages follow the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0-beta.2/) structure.

## License

Copyright (c) 2015-present, BigCommerce Inc.
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ platform:
- x64
install:
- ps: Install-Product node $env:nodejs_version
- npm install --production
- npm install
test_script:
- node --version
- npm --version
Expand Down
1 change: 1 addition & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = {extends: ['@commitlint/config-conventional']}
5 changes: 5 additions & 0 deletions constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const path = require('path');
const packagePath = path.join(process.cwd(), 'package.json');
const packageInfo = require(packagePath);

module.exports = { packageInfo }
130 changes: 130 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
'use strict';
require('colors');
require('path');
const bump = require('gulp-bump');
const changelog = require('./tasks/changelog');
const constants = require('./constants');
const currentVersion = constants.packageInfo.version;
const exec = require('gulp-exec');
const git = require('gulp-git-streamed');
const gulp = require('gulp');
const gulpif = require('gulp-if');
const gutil = require('gulp-util');
const prompt = require('gulp-prompt');
const semver = require('semver');

let branch;
let remote;
let responses;
let targetVersion;

function installPrivateDependencies() {
return gulp.src('package.json')
.pipe(exec('npm run install-private-dependencies'), logError)
.on('error', logError);
}

function bumpTask() {
const questions = [{
type: 'list',
name: 'type',
message: 'What type of release would you like to do?',
choices: [{
value: 'patch',
name: 'Patch: '.yellow + semver.inc(currentVersion, 'patch').yellow + ' Backwards-compatible bug fixes.',
}, {
value: 'minor',
name: 'Minor: '.yellow + semver.inc(currentVersion, 'minor').yellow + ' Component release or significant update to existing one.',
}, {
value: 'major',
name: 'Major: '.yellow + semver.inc(currentVersion, 'major').yellow + ' Major UI refresh.',
}, {
value: 'custom',
name: 'Custom: ?.?.?'.yellow + ' Specify version...',
}],
}, {
type: 'input',
name: 'custom-version',
message: 'What specific version would you like',
when: answers => answers['type'] === 'custom',
validate: value => {
const valid = semver.valid(value) && true;

return valid || 'Must be a valid semver, such as 1.2.3';
},
}, {
name: 'confirmPush',
type: 'confirm',
message: 'Do you want to push this new tag?',
}, {
name: 'pushTo',
type: 'input',
message:'Where would you like to push to?',
default: 'origin master',
when: answers => answers['confirmPush'],
validate: pushResponse => pushResponse.split(' ').length === 2,
}];

return gulp.src('package.json')
.pipe(prompt.prompt(questions, res => {
const pushToSplit = res.pushTo.split(' ');

remote = pushToSplit[0];
branch = pushToSplit[1];
targetVersion = (res.type !== 'custom') ? semver.inc(currentVersion, res.type) : res['custom-version'];
responses = res;

return gulp.src('package.json')
// bump the version number in those files
.pipe(bump({ version: targetVersion }))
// save it back to filesystem
.pipe(gulp.dest(process.cwd()))
// change last modified date
.pipe(exec('touch -c package.json'))
// Fetch Remote Tags
.pipe(git.exec({ args: `fetch ${remote} --tags` }, logError));
}))
.on('error', logError);
}

function deployWebpack() {
return gulp.src('package.json')
.pipe(exec('npm run deploy'), logError)
.on('error', logError);
}

function uninstallPrivateDependencies() {
return gulp.src('package.json')
.pipe(exec('npm run uninstall-private-dependencies'), logError)
.pipe(exec('rm package-lock.json'))
.on('error', logError);
}

function pushTask() {
return gulp.src(['package.json', 'CHANGELOG.md', 'server/plugins/stencil-editor/public/dist/app.js', 'server/plugins/stencil-editor/public/dist/ng-stencil-editor/css/ng-stencil-editor.min.css', 'server/plugins/stencil-editor/public/dist/stencil-preview-sdk.js'])
// Add files
.pipe(git.add())
// Commit the changed version number
.pipe(git.commit(`docs(release): releasing ${targetVersion}`))
// Create a Tag
.pipe(git.tag(targetVersion, targetVersion, logError))
// Push Changes
.pipe(gulpif(responses.confirmPush, git.push(remote, branch, logError)))
// Push Tags
.pipe(gulpif(responses.confirmPush, git.push(remote, branch, { args: '--follow-tags' }, logError)))
.on('error', logError);
}

function logError(err) {
if (err) {
gutil.log(err);
}
}

gulp.task('install-private-dependencies', installPrivateDependencies);
gulp.task('bump', bumpTask);
gulp.task('deploy-webpack', deployWebpack);
gulp.task('changelog', (done) => changelog.changelogTask({}, done));
gulp.task('uninstall-private-dependencies', uninstallPrivateDependencies);
gulp.task('push', pushTask);
gulp.task('release', gulp.series('install-private-dependencies', 'bump', 'deploy-webpack', 'changelog', 'uninstall-private-dependencies', 'push'));
36 changes: 28 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@
"scripts": {
"lint": "eslint .",
"test": "npm run lint && npm run run-tests",
"run-tests": "lab bin/ server/ lib/ -t 80 -l -e 'development' -P spec",
"run-tests": "lab bin/ server/ lib/ tasks/ -t 80 -l -e 'development' -P spec",
"test-cov-html": "lab bin/ server/ lib/ -r html -o coverage.html -P spec",
"dev": "webpack",
"deploy": "webpack --deploy"
"deploy": "webpack --deploy",
"install-private-dependencies": "npm install git+ssh://[email protected]:bigcommerce-labs/jschannel.git#master git+ssh://[email protected]:bigcommerce-labs/ng-common.git#master git+ssh://[email protected]:bigcommerce-labs/ng-stencil-editor.git#master git+ssh://[email protected]:bigcommerce-labs/stencil-preview-sdk.git#master git+ssh://[email protected]:bigcommerce-labs/bcapp-pattern-lab.git#master",
"uninstall-private-dependencies": "npm uninstall jschannel ng-common ng-stencil-editor stencil-preview-sdk bcapp-pattern-lab"
},
"bin": {
"stencil": "./bin/stencil",
Expand Down Expand Up @@ -79,7 +81,6 @@
"request": "^2.81.0",
"semver": "^5.3.0",
"simple-git": "^1.65.0",
"sinon": "^2.2.0",
"tarjan-graph": "^0.3.0",
"tmp": "0.0.26",
"upath": "^0.1.7",
Expand All @@ -88,6 +89,8 @@
"wreck": "^12.2.2"
},
"devDependencies": {
"@commitlint/cli": "^7.2.1",
"@commitlint/config-conventional": "^7.1.2",
"angular": "1.5.6",
"angular-animate": "1.5.6",
"angular-cache": "3.2.4",
Expand All @@ -98,20 +101,37 @@
"babel-core": "^6.8.0",
"babel-loader": "^6.2.4",
"babel-preset-es2015": "^6.6.0",
"bcapp-pattern-lab": "[email protected]:bigcommerce-labs/bcapp-pattern-lab.git",
"bower": "^1.8.2",
"clean-webpack-plugin": "^0.1.9",
"compression": "^1.6.1",
"conventional-changelog-cli": "^1.3.2",
"copy-webpack-plugin": "^2.1.3",
"es6-micro-loader": "^0.2.1",
"express": "^4.13.4",
"gulp": "^4.0.0",
"gulp-bump": "2.0.1",
"gulp-eslint": "^4.0.0",
"gulp-exec": "2.1.2",
"gulp-git": "2.5.2",
"gulp-git-streamed": "2.4.0",
"gulp-if": "2.0.0",
"gulp-prompt": "0.1.2",
"gulp-sass": "4.0.1",
"gulp-sass-lint": "1.1.1",
"gulp-util": "3.0.7",
"husky": "^1.2.0",
"jest": "^21.2.1",
"js-cookie": "^2.1.1",
"jschannel": "[email protected]:bigcommerce-labs/jschannel.git",
"ng-common": "[email protected]:bigcommerce-labs/ng-common.git",
"ng-stencil-editor": "[email protected]:bigcommerce-labs/ng-stencil-editor.git",
"npm-which": "^3.0.1",
"object-to-spawn-args": "^1.1.1",
"script-loader": "^0.7.0",
"stencil-preview-sdk": "[email protected]:bigcommerce-labs/stencil-preview-sdk.git",
"sinon": "^7.1.1",
"webpack": "^1.13.0",
"webpack-livereload-plugin": "^0.8.1"
},
"husky": {
"hooks": {
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
}
}
47 changes: 47 additions & 0 deletions tasks/changelog/changelog-generator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
const path = require('path');

/**
* @param {Object} fs
* @param {string} cwd
* @param {Object} commandExecutor
* @constructor
*/
function ChangelogGenerator(fs, cwd, commandExecutor) {
/**
* @param {ChangelogOptions} customOptions
* @param {function(error: Error?): void} done
* @return {void}
*/
function generateChangelog(customOptions, done) {
const options = getOptions(customOptions);
commandExecutor.executeCommand('touch', ['package.json'], {}, () => {
commandExecutor.executeCommand('conventional-changelog', [], options, done);
});
}

/**
* @private
* @param {ChangelogOptions} [customOptions={}]
* @return {ChangelogOptions}
*/
function getOptions(customOptions) {
customOptions = customOptions ? customOptions : {};
const options = Object.assign({
config: customOptions.preset ? undefined : path.join(__dirname, 'default-config.js'),
infile: path.join(cwd, 'CHANGELOG.md'),
sameFile: true,
}, customOptions);

try {
fs.statSync(options.infile);
} catch(error) {
options.releaseCount = 0;
}

return options;
}

this.generateChangelog = generateChangelog;
}

module.exports = ChangelogGenerator;
Loading

0 comments on commit 9e6e225

Please sign in to comment.