Skip to content
This repository was archived by the owner on Oct 10, 2018. It is now read-only.

Commit 37ed4b8

Browse files
author
Kent C. Dodds
committed
fix(build): Add semantic-release and more...
Update eslint support, add commitizen, add publish-latest (going to get rid of dist in master)
1 parent 7e8cb7d commit 37ed4b8

17 files changed

+236
-174
lines changed

.eslintrc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
{
2-
"extends": "./node_modules/kcd-common-tools/shared/.eslintrc"
2+
// this exists solely for editors. The test and app eslints are slightly different
3+
// and the app validates the app code via the other/app.eslintrc and validates the
4+
// test code via the other/test.eslintrc
5+
// we simply use the test.eslintrc so our editors don't get mad at us.
6+
"extends": "./other/test.eslintrc"
37
}

.travis.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
sudo: false
2+
language: node_js
3+
cache:
4+
directories:
5+
- node_modules
6+
branches:
7+
only:
8+
- master
9+
notifications:
10+
email: false
11+
node_js:
12+
- iojs
13+
before_install:
14+
- npm i -g npm@^2.0.0
15+
before_script:
16+
- npm prune
17+
script:
18+
- npm run code-checks
19+
- npm t
20+
- npm run check-coverage
21+
after_success:
22+
- npm run report-coverage
23+
- npm run semantic-release

dist/api-check.js

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! api-check version 7.5.0 built with ♥ by Kent C. Dodds <kent@doddsfamily.us> (http://kent.doddsfamily.us) (ó ì_í)=óò=(ì_í ò)
1+
//! api-check version 0.0.0-semantically-released.0 built with ♥ by Kent C. Dodds <kent@doddsfamily.us> (http://kent.doddsfamily.us) (ó ì_í)=óò=(ì_í ò)
22

33
(function webpackUniversalModuleDefinition(root, factory) {
44
if(typeof exports === 'object' && typeof module === 'object')
@@ -91,7 +91,7 @@ return /******/ (function(modules) { // webpackBootstrap
9191
var apiCheckApis = getApiCheckApis();
9292

9393
module.exports = getApiCheckInstance;
94-
module.exports.VERSION = ("7.5.0");
94+
module.exports.VERSION = ("0.0.0-semantically-released.0");
9595
module.exports.utils = apiCheckUtil;
9696
module.exports.globalConfig = {
9797
verbose: false,
@@ -151,9 +151,9 @@ return /******/ (function(modules) { // webpackBootstrap
151151

152152
/**
153153
* This is the instance function. Other things are attached to this see additional properties above.
154-
* @param api {Array}
155-
* @param args {arguments}
156-
* @param output {Object}
154+
* @param {Array} api - the checkers to check with
155+
* @param {Array} args - the args to check
156+
* @param {Object} output - output options
157157
* @returns {Object} - if this has a failed = true property, then it failed
158158
*/
159159
function apiCheck(api, args, output) {
@@ -195,7 +195,7 @@ return /******/ (function(modules) { // webpackBootstrap
195195

196196
/**
197197
* checkApiCheckApi, should be read like: check apiCheck api. As in, check the api for apiCheck :-)
198-
* @param checkApiArgs
198+
* @param {Array} checkApiArgs - args provided to apiCheck function
199199
*/
200200
function checkApiCheckApi(checkApiArgs) {
201201
var api = checkApiArgs[0];
@@ -348,9 +348,9 @@ return /******/ (function(modules) { // webpackBootstrap
348348

349349
/**
350350
* This is where the magic happens for actually checking the arguments with the api.
351-
* @param api {Array} - checkers
352-
* @param args {Array} - and arguments object
353-
* @returns {Array}
351+
* @param {Array} api - checkers
352+
* @param {Array} args - and arguments object
353+
* @returns {Array} - the error messages
354354
*/
355355
function checkApiWithArgs(api, args) {
356356
/* eslint complexity:[2, 7] */
@@ -641,15 +641,16 @@ return /******/ (function(modules) { // webpackBootstrap
641641

642642
function each(obj, iterator, context) {
643643
if (Array.isArray(obj)) {
644-
return eachArry.apply(undefined, arguments);
644+
return eachArry(obj, iterator, context);
645645
} else {
646-
return eachObj.apply(undefined, arguments);
646+
return eachObj(obj, iterator, context);
647647
}
648648
}
649649

650650
function eachObj(obj, iterator, context) {
651-
var ret;
651+
var ret = undefined;
652652
var hasOwn = Object.prototype.hasOwnProperty;
653+
/* eslint prefer-const:0 */ // some weird eslint bug?
653654
for (var key in obj) {
654655
if (hasOwn.call(obj, key)) {
655656
ret = iterator.call(context, obj[key], key, obj);
@@ -662,7 +663,7 @@ return /******/ (function(modules) { // webpackBootstrap
662663
}
663664

664665
function eachArry(obj, iterator, context) {
665-
var ret;
666+
var ret = undefined;
666667
var length = obj.length;
667668
for (var i = 0; i < length; i++) {
668669
ret = iterator.call(context, obj[i], i, obj);
@@ -712,9 +713,11 @@ return /******/ (function(modules) { // webpackBootstrap
712713
/**
713714
* This will set up the checker with all of the defaults that most checkers want like required by default and an
714715
* optional version
715-
* @param checker
716-
* @param properties properties to add to the checker
717-
* @param disabled - when set to true, this will set the checker to a no-op function
716+
*
717+
* @param {Function} checker - the checker to setup with properties
718+
* @param {Object} properties - properties to add to the checker
719+
* @param {boolean} disabled - when set to true, this will set the checker to a no-op function
720+
* @returns {Function} checker - the setup checker
718721
*/
719722
function setupChecker(checker, properties, disabled) {
720723
/* eslint complexity:[2, 9] */

dist/api-check.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/api-check.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

other/common.eslintrc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"rules": {
3+
"func-names": 0, // I wish, but doing this right now would be a royal pain
4+
"new-cap": [
5+
2,
6+
{
7+
"newIsCap": true,
8+
"capIsNew": true
9+
}
10+
],
11+
"max-params": [2, 10],
12+
"max-statements": [2, 30], // TODO bring this down
13+
},
14+
"globals": {
15+
"VERSION": false
16+
}
17+
}

other/src.eslintrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": ["kentcdodds", "./common.eslintrc"]
3+
}

other/test.eslintrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": ["kentcdodds/test", "./common.eslintrc"],
3+
}

package.json

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "api-check",
3-
"version": "7.5.0",
3+
"version": "0.0.0-semantically-released.0",
44
"description": "Validate the api to your functions to help people use them correctly. This is pretty much React's propTypes without React.",
55
"main": "dist/api-check.js",
66
"dependencies": {},
@@ -9,11 +9,15 @@
99
"babel-core": "5.5.8",
1010
"babel-eslint": "3.1.17",
1111
"babel-loader": "5.1.4",
12+
"bootstrap": "3.3.5",
1213
"chai": "2.1.0",
1314
"codecov.io": "0.1.4",
14-
"eslint": "0.23.0",
15-
"eslint-loader": "0.14.0",
16-
"ghooks": "0.2.4",
15+
"commitizen": "1.0.4",
16+
"cz-conventional-changelog": "1.1.0",
17+
"eslint": "1.5.1",
18+
"eslint-config-kentcdodds": "4.0.0",
19+
"eslint-loader": "1.0.0",
20+
"ghooks": "0.3.2",
1721
"isparta": "3.0.3",
1822
"isparta-loader": "0.2.0",
1923
"istanbul": "0.3.5",
@@ -29,32 +33,31 @@
2933
"lodash": "3.9.3",
3034
"mocha": "2.1.0",
3135
"node-libs-browser": "^0.5.2",
36+
"publish-latest": "1.1.0",
37+
"semantic-release": "^4.3.5",
3238
"surge": "0.14.2",
3339
"uglify-loader": "1.2.0",
34-
"webpack": "1.9.11",
35-
"with-package": "0.2.0"
40+
"validate-commit-msg": "1.0.0",
41+
"webpack": "1.9.11"
3642
},
3743
"scripts": {
38-
"start": "npm run test",
39-
"test": "COVERAGE=true NODE_ENV=test karma start",
40-
"test:single": "COVERAGE=true NODE_ENV=test karma start --single-run",
44+
"commit": "git-cz",
45+
"start": "COVERAGE=true NODE_ENV=test karma start",
46+
"test": "COVERAGE=true NODE_ENV=test karma start --single-run",
4147
"test:debug": "echo 'WARNING: This is currently not working quite right...' && NODE_ENV=test karma start --browsers Chrome",
4248
"build:dist": "NODE_ENV=development webpack --config node_modules/kcd-common-tools/shared/webpack.config.js --progress --colors",
4349
"build:prod": "NODE_ENV=production webpack --config node_modules/kcd-common-tools/shared/webpack.config.js --progress --colors",
4450
"build": "npm run build:dist & npm run build:prod",
45-
"ci": "npm run code-checks && npm run test:single && npm run check-coverage && npm run build",
4651
"check-coverage": "./node_modules/istanbul/lib/cli.js check-coverage --statements 100 --functions 100 --lines 100 --branches 100",
4752
"report-coverage": "cat ./coverage/lcov.info | codecov",
4853
"deploy": "npm run deployClean && npm run deployCopy && npm run deploySurge",
4954
"deploySurge": "surge -p deploy.ignored -d api-check.surge.sh",
5055
"deployCopy": "cp index.html deploy.ignored/ && cp dist/api-check.js deploy.ignored/dist/",
5156
"deployClean": "rm -rf deploy.ignored/ && mkdir deploy.ignored/ && mkdir deploy.ignored/dist/",
52-
"only-check": "node node_modules/kcd-common-tools/shared/scripts/only-check.js",
53-
"console-check": "node node_modules/kcd-common-tools/shared/scripts/console-check.js",
54-
"code-checks": "npm run only-check && npm run console-check",
55-
"release": "npm run build && with-package git commit -am pkg.version && with-package git tag pkg.version && git push && npm publish && git push --tags",
56-
"release:beta": "npm run release && npm run tag:beta",
57-
"tag:beta": "with-package npm dist-tag add pkg.name@pkg.version beta"
57+
"code-checks": "eslint src/",
58+
"prepublish": "npm run build",
59+
"postpublish": "publish-latest",
60+
"semantic-release": "semantic-release pre && npm publish && semantic-release post"
5861
},
5962
"repository": {
6063
"type": "git",
@@ -75,9 +78,12 @@
7578
"homepage": "https://github.com/kentcdodds/api-check",
7679
"config": {
7780
"ghooks": {
78-
"pre-commit": "npm run ci"
81+
"pre-commit": "./node_modules/.bin/validate-commit-msg && npm run code-checks && npm t && npm run check-coverage"
7982
}
8083
},
84+
"czConfig": {
85+
"path": "node_modules/cz-conventional-changelog"
86+
},
8187
"kcdCommon": {
8288
"webpack": {
8389
"output": {

src/api-check-util.js

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module.exports = {
1010
};
1111

1212
function copy(obj) {
13-
let type = typeOf(obj);
13+
const type = typeOf(obj);
1414
let daCopy;
1515
if (type === 'array') {
1616
daCopy = [];
@@ -39,7 +39,7 @@ function typeOf(obj) {
3939
function getCheckerDisplay(checker, options) {
4040
/* eslint complexity:[2, 7] */
4141
let display;
42-
let short = options && options.short;
42+
const short = options && options.short;
4343
if (short && checker.shortType) {
4444
display = checker.shortType;
4545
} else if (!short && typeof checker.type === 'object' || checker.type === 'function') {
@@ -52,8 +52,8 @@ function getCheckerDisplay(checker, options) {
5252

5353
function getCheckerType({type}, options) {
5454
if (typeof type === 'function') {
55-
let __apiCheckData = type.__apiCheckData;
56-
let typeTypes = type(options);
55+
const __apiCheckData = type.__apiCheckData;
56+
const typeTypes = type(options);
5757
type = {
5858
__apiCheckData,
5959
[__apiCheckData.type]: typeTypes
@@ -75,16 +75,17 @@ function arrayify(obj) {
7575

7676
function each(obj, iterator, context) {
7777
if (Array.isArray(obj)) {
78-
return eachArry(...arguments);
78+
return eachArry(obj, iterator, context);
7979
} else {
80-
return eachObj(...arguments);
80+
return eachObj(obj, iterator, context);
8181
}
8282
}
8383

8484
function eachObj(obj, iterator, context) {
85-
var ret;
86-
var hasOwn = Object.prototype.hasOwnProperty;
87-
for (var key in obj) {
85+
let ret;
86+
const hasOwn = Object.prototype.hasOwnProperty;
87+
/* eslint prefer-const:0 */ // some weird eslint bug?
88+
for (let key in obj) {
8889
if (hasOwn.call(obj, key)) {
8990
ret = iterator.call(context, obj[key], key, obj);
9091
if (ret === false) {
@@ -96,9 +97,9 @@ function eachObj(obj, iterator, context) {
9697
}
9798

9899
function eachArry(obj, iterator, context) {
99-
var ret;
100-
var length = obj.length;
101-
for (var i = 0; i < length; i++) {
100+
let ret;
101+
const length = obj.length;
102+
for (let i = 0; i < length; i++) {
102103
ret = iterator.call(context, obj[i], i, obj);
103104
if (ret === false) {
104105
return ret;
@@ -113,8 +114,8 @@ function isError(obj) {
113114

114115
function list(arry, join, finalJoin) {
115116
arry = arrayify(arry);
116-
let copy = arry.slice();
117-
let last = copy.pop();
117+
const copy = arry.slice();
118+
const last = copy.pop();
118119
if (copy.length === 1) {
119120
join = ' ';
120121
}
@@ -148,9 +149,11 @@ function undef(thing) {
148149
/**
149150
* This will set up the checker with all of the defaults that most checkers want like required by default and an
150151
* optional version
151-
* @param checker
152-
* @param properties properties to add to the checker
153-
* @param disabled - when set to true, this will set the checker to a no-op function
152+
*
153+
* @param {Function} checker - the checker to setup with properties
154+
* @param {Object} properties - properties to add to the checker
155+
* @param {boolean} disabled - when set to true, this will set the checker to a no-op function
156+
* @returns {Function} checker - the setup checker
154157
*/
155158
function setupChecker(checker, properties, disabled) {
156159
/* eslint complexity:[2, 9] */
@@ -187,7 +190,7 @@ function setupChecker(checker, properties, disabled) {
187190
}
188191

189192
function getRequiredVersion(checker, disabled) {
190-
var requiredChecker = disabled ? getNoop() : function requiredChecker(val, name, location, obj) {
193+
const requiredChecker = disabled ? getNoop() : function requiredChecker(val, name, location, obj) {
191194
if (undef(val) && !checker.isOptional) {
192195
let tLocation = location ? ` in ${t(location)}` : '';
193196
const type = getCheckerDisplay(checker, {short: true});
@@ -203,7 +206,7 @@ function getRequiredVersion(checker, disabled) {
203206
}
204207

205208
function addOptional(checker, disabled) {
206-
var optionalCheck = disabled ? getNoop() : function optionalCheck(val, name, location, obj) {
209+
const optionalCheck = disabled ? getNoop() : function optionalCheck(val, name, location, obj) {
207210
if (!undef(val)) {
208211
return checker(val, name, location, obj);
209212
}
@@ -223,7 +226,7 @@ function addOptional(checker, disabled) {
223226
}
224227

225228
function addNullable(checker, disabled) {
226-
var nullableCheck = disabled ? getNoop() : function nullableCheck(val, name, location, obj) {
229+
const nullableCheck = disabled ? getNoop() : function nullableCheck(val, name, location, obj) {
227230
if (val !== null) {
228231
return checker(val, name, location, obj);
229232
}

0 commit comments

Comments
 (0)