Skip to content

Commit

Permalink
feat(chore): add project tools and utilities (#270)
Browse files Browse the repository at this point in the history
* misc(add commitlinting): adds commit linting to the cli

* misc(add eslint ignore items): adds build folder and commit linter to ignore

* chore(add new items to chore): adds chore command

* chore(linting): lint added files

* chore(remove cmd): removes f command

* chore(revise cmd): changelog is now CHANGELOG
  • Loading branch information
evenstensberg committed Feb 20, 2018
1 parent 4333088 commit 7ab69a3
Show file tree
Hide file tree
Showing 13 changed files with 1,653 additions and 71 deletions.
1 change: 1 addition & 0 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ test_script:
- yarn appveyor:prepare
- yarn appveyor:lint
- yarn appveyor:test
- yarn bundlesize

cache:
- node_modules -> appveyor.yml,package.json,yarn.lock
31 changes: 31 additions & 0 deletions .cz-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* @license Copyright 2017 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
* applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
* OF ANY KIND, either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*/
// Based on https://github.com/GoogleChrome/lighthouse/blob/master/.cz-config.js

'use strict';

module.exports = {
allowBreakingChanges: ['ast'],
allowCustomScopes: true,
scopes: [],
types: [
{value: 'new_feature', name: 'new_feature: A new feature'}, {
value: 'ast',
name: 'ast: init, migrate, add, etc'
},
{value: 'tests', name: 'tests: Tests, jest, binTestCases etc'},
{value: 'docs', name: 'docs: Documentation'},
{value: 'deps', name: 'deps: Dependency bumps only'},
{value: 'cli', name: 'cli: core CLI things'},
{value: 'misc', name: 'misc: Other formats like tweaks and such'},
{value: 'chore', name: 'chore: Updating docs, linting etc'},
]
};
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
**/__testfixtures__/*
coverage
test
docs
docs
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ jsdoc.json
.appveyor.yml
.codecov.yml
*.snap
build
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ matrix:
- os: linux
node_js: "6"
env: JOB_PART=integration

sudo: false

notifications:
Expand All @@ -33,3 +32,4 @@ before_script:

script:
- npm run travis:$JOB_PART
- commitlint-travis
51 changes: 50 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,53 @@
# Change Log
<a name="2.0.6"></a>
# 2.0.6 (2018-02-20)
[Full Changelog](https://github.com/webpack/webpack-cli/compare/v2.0.4...v2.0.6)

## Chore

* .gitignore: ignore .vscode ([ab0eacc](https://github.com/webpack/webpack-cli/commit/ab0eacc))
* .gitignore: ignore .vscode ([a322505](https://github.com/webpack/webpack-cli/commit/a322505))
* add new items to chore: adds chore command ([db243b6](https://github.com/webpack/webpack-cli/commit/db243b6))
* linting: lint added files ([6dc12af](https://github.com/webpack/webpack-cli/commit/6dc12af))
* remove cmd: removes f command ([7adfdcf](https://github.com/webpack/webpack-cli/commit/7adfdcf))

## Feat

* show help when no options given ([a7ee15a](https://github.com/webpack/webpack-cli/commit/a7ee15a))

## Fix

* Resolve webpack dependencies ([#251](https://github.com/webpack/webpack-cli/pull/251))
* change help logic ([d67f4b7](https://github.com/webpack/webpack-cli/commit/d67f4b7))

## Improvement

* add an option to watch messaging. Add .idea to .gitignore ([#200](https://github.com/webpack/webpack-cli/pull/200))

## Refactor

* convert-args: remove unused arguments ([#253](https://github.com/webpack/webpack-cli/pull/253))

## Style

* run formatter ([7be0da7](https://github.com/webpack/webpack-cli/commit/7be0da7))

## Tests

* add test for showing help on no options ([cf43939](https://github.com/webpack/webpack-cli/commit/cf43939))

## Misc

* remove yargs major update due security compromise ([9bd7ed4](https://github.com/webpack/webpack-cli/commit/9bd7ed4))
* [feature] configuration validation ([#240](https://github.com/webpack/webpack-cli/pull/240))
* v.2.0.6 ([4333088](https://github.com/webpack/webpack-cli/commit/4333088))
* fix typo.. ([0f1cee6](https://github.com/webpack/webpack-cli/commit/0f1cee6))
* 2.0.5 ([94ac6db](https://github.com/webpack/webpack-cli/commit/94ac6db))
* Change from git:// to https:// ([#259](https://github.com/webpack/webpack-cli/pull/259))
* Issue 249 fixed and other enums refactored ([#264](https://github.com/webpack/webpack-cli/pull/264))
* Refactor bin directory ([#263](https://github.com/webpack/webpack-cli/pull/263))
* Add jsdoc comments for migrate ([#255](https://github.com/webpack/webpack-cli/pull/255))
* add commitlinting: adds commit linting to the cli ([7e4dd3d](https://github.com/webpack/webpack-cli/commit/7e4dd3d))
* add eslint ignore items: adds build folder and commit linter to ignore ([a400809](https://github.com/webpack/webpack-cli/commit/a400809))

<a name="2.0.0"></a>
## 2.0.0 (2017-12-21)
Expand Down
100 changes: 100 additions & 0 deletions build/changelog-generator/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/**
* @license Copyright 2017 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
* Based on: https://github.com/GoogleChrome/lighthouse/blob/master/build/changelog-generator/
*/
"use strict";
const readFileSync = require("fs").readFileSync;
const resolve = require("path").resolve;
const mainTemplate = readFileSync(
resolve(__dirname, "templates/template.hbs")
).toString();
const headerPartial = readFileSync(
resolve(__dirname, "templates/header.hbs")
).toString();
const commitPartial = readFileSync(
resolve(__dirname, "templates/commit.hbs")
).toString();

const pullRequestRegex = /\(#(\d+)\)$/;
const parserOpts = {
headerPattern: /^(\w*)(?:\((.*)\))?: (.*)$/,
headerCorrespondence: ["type", "scope", "message"]
};

process.stderr.write(`
> Be sure to have the latest git tags locally:
git fetch --tags
`);

const writerOpts = {
mainTemplate,
headerPartial,
commitPartial,
transform: commit => {
if (typeof commit.hash === "string") {
commit.hash = commit.hash.substring(0, 7);
}

if (commit.type === "test") {
commit.type = "tests";
} else if (commit.type === "cli") {
commit.type = "CLI";
} else if (commit.type === "new_feature") {
commit.type = "New Features";
}

if (commit.type) {
commit.type = commit.type.replace(/_/g, " ");
commit.type =
commit.type.substring(0, 1).toUpperCase() + commit.type.substring(1);
} else {
commit.type = "Misc";
}

let pullRequestMatch = commit.header.match(pullRequestRegex);
// if header does not provide a PR we try the message
if (!pullRequestMatch && commit.message) {
pullRequestMatch = commit.message.match(pullRequestRegex);
}

if (pullRequestMatch) {
commit.header = commit.header.replace(pullRequestMatch[0], "").trim();
if (commit.message) {
commit.message = commit.message.replace(pullRequestMatch[0], "").trim();
}

commit.PR = pullRequestMatch[1];
}

return commit;
},
groupBy: "type",
commitGroupsSort: (a, b) => {
// put new feature on the top
if (a.title === "New Features") {
return -1;
}
if (b.title === "New Features") {
return 1;
}

// put misc on the bottom
if (a.title === "Misc") {
return 1;
}
if (b.title === "Misc") {
return -1;
}

return a.title.localeCompare(b.title);
},
commitsSort: ["type", "scope"]
};

module.exports = {
writerOpts,
parserOpts
};
28 changes: 28 additions & 0 deletions build/changelog-generator/templates/commit.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{{!--
/**
* @license Copyright 2017 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/
From: https://github.com/GoogleChrome/lighthouse/blob/master/build/changelog-generator/
--}}
* {{#if scope}}{{scope}}: {{/if~}}
{{#if message ~}}
{{~message~}}
{{~else~}}
{{~header~}}
{{~/if ~}}
{{~!-- PR number/commit hash --}}
{{~#if @root.linkReferences~}}
{{~#if PR}} ([#{{PR}}](
{{~#if @root.host}}{{~@root.host}}/{{/if~}}
{{~#if @root.owner ~}}{{@root.owner}}/{{/if~}}
{{~@root.repository}}/pull/{{PR}}))
{{~else}} ([{{hash}}](
{{~#if @root.host}}{{~@root.host}}/{{/if~}}
{{~#if @root.owner ~}}{{@root.owner}}/{{/if~}}
{{~@root.repository}}/{{@root.commit}}/{{hash}}))
{{~/if~}}
{{~else~}}
{{~hash~}}
{{~/if~}}
13 changes: 13 additions & 0 deletions build/changelog-generator/templates/header.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{!--
/**
* @license Copyright 2017 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/
From: https://github.com/GoogleChrome/lighthouse/blob/master/build/changelog-generator/
--}}
<a name="{{version}}"></a>
# {{version}} ({{date}})
{{#if @root.linkCompare~}}
[Full Changelog]({{~@root.repoUrl}}/compare/{{previousTag}}...{{currentTag}})
{{~/if}}
22 changes: 22 additions & 0 deletions build/changelog-generator/templates/template.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{{!--
/**
* @license Copyright 2017 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/
From: https://github.com/GoogleChrome/lighthouse/blob/master/build/changelog-generator/
--}}
{{> header}}

{{#each commitGroups}}

{{#if title~}}
## {{title}}

{{/if}}
{{#each commits}}
{{~> commit root=@root}}

{{/each}}
{{/each}}

29 changes: 29 additions & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* @license Copyright 2017 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/
// Config from https://github.com/GoogleChrome/lighthouse/blob/master/commitlint.config.js
"use strict";

module.exports = {
extends: ["cz"],
rules: {
"body-leading-blank": [1, "always"],
"body-tense": [1, "always", ["present-imperative"]],
"footer-leading-blank": [1, "always"],
"footer-tense": [1, "always", ["present-imperative"]],
"header-max-length": [2, "always", 80],
lang: [0, "always", "eng"],
"scope-case": [2, "always", "lowerCase"],
"scope-empty": [0, "never"],
"subject-case": [1, "always", "lowerCase"],
"subject-empty": [0, "never"],
"subject-full-stop": [2, "never", "."],
"subject-tense": [1, "always", ["present-imperative"]],
"type-case": [2, "always", "lowerCase"],
"type-empty": [2, "never"]
// The scope-enum : defined in the cz-config
// The 'type-enum': defined in the cz-config
}
};
36 changes: 35 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,15 @@
"appveyor:lint": "yarn lint",
"appveyor:test": "nyc jest && yarn reportCoverage",
"travis:integration": "yarn prepare && nyc jest && yarn reportCoverage",
"travis:lint": "yarn lint"
"travis:lint": "yarn lint && yarn bundlesize",
"bundlesize": "bundlesize",
"commitmsg": "commitlint -e $GIT_PARAMS",
"changelog": "conventional-changelog --config ./build/changelog-generator/index.js --infile CHANGELOG.md --same-file"
},
"lint-staged": {
"{lib,bin}/**/!(__testfixtures__)/**.js": [
"eslint --fix",
"npm run commitmsg",
"git add"
]
},
Expand All @@ -57,6 +61,28 @@
],
"all": true
},
"bundlesize": [
{
"path": "./lib/migrate/**.js",
"maxSize": "1 kB"
},
{
"path": "./lib/init/**/**.js",
"maxSize": "1.5 kB"
},
{
"path": "./lib/utils/**.js",
"maxSize": "5 kB"
}
],
"config": {
"commitizen": {
"path": "./node_modules/cz-customizable"
},
"cz-customizable": {
"config": "./.cz-config.js"
}
},
"dependencies": {
"chalk": "^2.0.1",
"codecov": "^3.0.0",
Expand Down Expand Up @@ -88,6 +114,14 @@
"yeoman-generator": "https://github.com/ev1stensberg/generator.git#Feature-getArgument"
},
"devDependencies": {
"@commitlint/cli": "^6.1.0",
"@commitlint/prompt-cli": "^6.1.0",
"@commitlint/travis-cli": "^6.1.0",
"bundlesize": "^0.16.0",
"commitizen": "^2.9.6",
"conventional-changelog-cli": "^1.3.13",
"conventional-changelog-lint-config-cz": "^0.3.0",
"cz-customizable": "^5.2.0",
"eslint": "^4.2.0",
"eslint-plugin-node": "^5.1.0",
"flow-bin": "^0.49.1",
Expand Down
Loading

0 comments on commit 7ab69a3

Please sign in to comment.