Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(chore): add project tools and utilities #270

Merged
merged 6 commits into from
Feb 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed? Shouldn't yarn bundlesize already call the bin file?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another question: are we adding bundlesize so users can use it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's for CI's for now, we could add it to as a feature to webpack, but that needs some work

"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