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

Commit

Permalink
fix(build): Add semantic-release and more...
Browse files Browse the repository at this point in the history
Update eslint support, add commitizen, add publish-latest (going to get rid of dist in master)
  • Loading branch information
Kent C. Dodds committed Sep 26, 2015
1 parent 7e8cb7d commit 37ed4b8
Show file tree
Hide file tree
Showing 17 changed files with 236 additions and 174 deletions.
6 changes: 5 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
{
"extends": "./node_modules/kcd-common-tools/shared/.eslintrc"
// this exists solely for editors. The test and app eslints are slightly different
// and the app validates the app code via the other/app.eslintrc and validates the
// test code via the other/test.eslintrc
// we simply use the test.eslintrc so our editors don't get mad at us.
"extends": "./other/test.eslintrc"
}
23 changes: 23 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
sudo: false
language: node_js
cache:
directories:
- node_modules
branches:
only:
- master
notifications:
email: false
node_js:
- iojs
before_install:
- npm i -g npm@^2.0.0
before_script:
- npm prune
script:
- npm run code-checks
- npm t
- npm run check-coverage
after_success:
- npm run report-coverage
- npm run semantic-release
35 changes: 19 additions & 16 deletions dist/api-check.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! api-check version 7.5.0 built with ♥ by Kent C. Dodds <[email protected]> (http://kent.doddsfamily.us) (ó ì_í)=óò=(ì_í ò)
//! api-check version 0.0.0-semantically-released.0 built with ♥ by Kent C. Dodds <[email protected]> (http://kent.doddsfamily.us) (ó ì_í)=óò=(ì_í ò)

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

module.exports = getApiCheckInstance;
module.exports.VERSION = ("7.5.0");
module.exports.VERSION = ("0.0.0-semantically-released.0");
module.exports.utils = apiCheckUtil;
module.exports.globalConfig = {
verbose: false,
Expand Down Expand Up @@ -151,9 +151,9 @@ return /******/ (function(modules) { // webpackBootstrap

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

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

/**
* This is where the magic happens for actually checking the arguments with the api.
* @param api {Array} - checkers
* @param args {Array} - and arguments object
* @returns {Array}
* @param {Array} api - checkers
* @param {Array} args - and arguments object
* @returns {Array} - the error messages
*/
function checkApiWithArgs(api, args) {
/* eslint complexity:[2, 7] */
Expand Down Expand Up @@ -641,15 +641,16 @@ return /******/ (function(modules) { // webpackBootstrap

function each(obj, iterator, context) {
if (Array.isArray(obj)) {
return eachArry.apply(undefined, arguments);
return eachArry(obj, iterator, context);
} else {
return eachObj.apply(undefined, arguments);
return eachObj(obj, iterator, context);
}
}

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

function eachArry(obj, iterator, context) {
var ret;
var ret = undefined;
var length = obj.length;
for (var i = 0; i < length; i++) {
ret = iterator.call(context, obj[i], i, obj);
Expand Down Expand Up @@ -712,9 +713,11 @@ return /******/ (function(modules) { // webpackBootstrap
/**
* This will set up the checker with all of the defaults that most checkers want like required by default and an
* optional version
* @param checker
* @param properties properties to add to the checker
* @param disabled - when set to true, this will set the checker to a no-op function
*
* @param {Function} checker - the checker to setup with properties
* @param {Object} properties - properties to add to the checker
* @param {boolean} disabled - when set to true, this will set the checker to a no-op function
* @returns {Function} checker - the setup checker
*/
function setupChecker(checker, properties, disabled) {
/* eslint complexity:[2, 9] */
Expand Down
4 changes: 2 additions & 2 deletions dist/api-check.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/api-check.min.js.map

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions other/common.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"rules": {
"func-names": 0, // I wish, but doing this right now would be a royal pain
"new-cap": [
2,
{
"newIsCap": true,
"capIsNew": true
}
],
"max-params": [2, 10],
"max-statements": [2, 30], // TODO bring this down
},
"globals": {
"VERSION": false
}
}
3 changes: 3 additions & 0 deletions other/src.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": ["kentcdodds", "./common.eslintrc"]
}
3 changes: 3 additions & 0 deletions other/test.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": ["kentcdodds/test", "./common.eslintrc"],
}
40 changes: 23 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "api-check",
"version": "7.5.0",
"version": "0.0.0-semantically-released.0",
"description": "Validate the api to your functions to help people use them correctly. This is pretty much React's propTypes without React.",
"main": "dist/api-check.js",
"dependencies": {},
Expand All @@ -9,11 +9,15 @@
"babel-core": "5.5.8",
"babel-eslint": "3.1.17",
"babel-loader": "5.1.4",
"bootstrap": "3.3.5",
"chai": "2.1.0",
"codecov.io": "0.1.4",
"eslint": "0.23.0",
"eslint-loader": "0.14.0",
"ghooks": "0.2.4",
"commitizen": "1.0.4",
"cz-conventional-changelog": "1.1.0",
"eslint": "1.5.1",
"eslint-config-kentcdodds": "4.0.0",
"eslint-loader": "1.0.0",
"ghooks": "0.3.2",
"isparta": "3.0.3",
"isparta-loader": "0.2.0",
"istanbul": "0.3.5",
Expand All @@ -29,32 +33,31 @@
"lodash": "3.9.3",
"mocha": "2.1.0",
"node-libs-browser": "^0.5.2",
"publish-latest": "1.1.0",
"semantic-release": "^4.3.5",
"surge": "0.14.2",
"uglify-loader": "1.2.0",
"webpack": "1.9.11",
"with-package": "0.2.0"
"validate-commit-msg": "1.0.0",
"webpack": "1.9.11"
},
"scripts": {
"start": "npm run test",
"test": "COVERAGE=true NODE_ENV=test karma start",
"test:single": "COVERAGE=true NODE_ENV=test karma start --single-run",
"commit": "git-cz",
"start": "COVERAGE=true NODE_ENV=test karma start",
"test": "COVERAGE=true NODE_ENV=test karma start --single-run",
"test:debug": "echo 'WARNING: This is currently not working quite right...' && NODE_ENV=test karma start --browsers Chrome",
"build:dist": "NODE_ENV=development webpack --config node_modules/kcd-common-tools/shared/webpack.config.js --progress --colors",
"build:prod": "NODE_ENV=production webpack --config node_modules/kcd-common-tools/shared/webpack.config.js --progress --colors",
"build": "npm run build:dist & npm run build:prod",
"ci": "npm run code-checks && npm run test:single && npm run check-coverage && npm run build",
"check-coverage": "./node_modules/istanbul/lib/cli.js check-coverage --statements 100 --functions 100 --lines 100 --branches 100",
"report-coverage": "cat ./coverage/lcov.info | codecov",
"deploy": "npm run deployClean && npm run deployCopy && npm run deploySurge",
"deploySurge": "surge -p deploy.ignored -d api-check.surge.sh",
"deployCopy": "cp index.html deploy.ignored/ && cp dist/api-check.js deploy.ignored/dist/",
"deployClean": "rm -rf deploy.ignored/ && mkdir deploy.ignored/ && mkdir deploy.ignored/dist/",
"only-check": "node node_modules/kcd-common-tools/shared/scripts/only-check.js",
"console-check": "node node_modules/kcd-common-tools/shared/scripts/console-check.js",
"code-checks": "npm run only-check && npm run console-check",
"release": "npm run build && with-package git commit -am pkg.version && with-package git tag pkg.version && git push && npm publish && git push --tags",
"release:beta": "npm run release && npm run tag:beta",
"tag:beta": "with-package npm dist-tag add [email protected] beta"
"code-checks": "eslint src/",
"prepublish": "npm run build",
"postpublish": "publish-latest",
"semantic-release": "semantic-release pre && npm publish && semantic-release post"
},
"repository": {
"type": "git",
Expand All @@ -75,9 +78,12 @@
"homepage": "https://github.com/kentcdodds/api-check",
"config": {
"ghooks": {
"pre-commit": "npm run ci"
"pre-commit": "./node_modules/.bin/validate-commit-msg && npm run code-checks && npm t && npm run check-coverage"
}
},
"czConfig": {
"path": "node_modules/cz-conventional-changelog"
},
"kcdCommon": {
"webpack": {
"output": {
Expand Down
43 changes: 23 additions & 20 deletions src/api-check-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = {
};

function copy(obj) {
let type = typeOf(obj);
const type = typeOf(obj);
let daCopy;
if (type === 'array') {
daCopy = [];
Expand Down Expand Up @@ -39,7 +39,7 @@ function typeOf(obj) {
function getCheckerDisplay(checker, options) {
/* eslint complexity:[2, 7] */
let display;
let short = options && options.short;
const short = options && options.short;
if (short && checker.shortType) {
display = checker.shortType;
} else if (!short && typeof checker.type === 'object' || checker.type === 'function') {
Expand All @@ -52,8 +52,8 @@ function getCheckerDisplay(checker, options) {

function getCheckerType({type}, options) {
if (typeof type === 'function') {
let __apiCheckData = type.__apiCheckData;
let typeTypes = type(options);
const __apiCheckData = type.__apiCheckData;
const typeTypes = type(options);
type = {
__apiCheckData,
[__apiCheckData.type]: typeTypes
Expand All @@ -75,16 +75,17 @@ function arrayify(obj) {

function each(obj, iterator, context) {
if (Array.isArray(obj)) {
return eachArry(...arguments);
return eachArry(obj, iterator, context);
} else {
return eachObj(...arguments);
return eachObj(obj, iterator, context);
}
}

function eachObj(obj, iterator, context) {
var ret;
var hasOwn = Object.prototype.hasOwnProperty;
for (var key in obj) {
let ret;
const hasOwn = Object.prototype.hasOwnProperty;
/* eslint prefer-const:0 */ // some weird eslint bug?
for (let key in obj) {
if (hasOwn.call(obj, key)) {
ret = iterator.call(context, obj[key], key, obj);
if (ret === false) {
Expand All @@ -96,9 +97,9 @@ function eachObj(obj, iterator, context) {
}

function eachArry(obj, iterator, context) {
var ret;
var length = obj.length;
for (var i = 0; i < length; i++) {
let ret;
const length = obj.length;
for (let i = 0; i < length; i++) {
ret = iterator.call(context, obj[i], i, obj);
if (ret === false) {
return ret;
Expand All @@ -113,8 +114,8 @@ function isError(obj) {

function list(arry, join, finalJoin) {
arry = arrayify(arry);
let copy = arry.slice();
let last = copy.pop();
const copy = arry.slice();
const last = copy.pop();
if (copy.length === 1) {
join = ' ';
}
Expand Down Expand Up @@ -148,9 +149,11 @@ function undef(thing) {
/**
* This will set up the checker with all of the defaults that most checkers want like required by default and an
* optional version
* @param checker
* @param properties properties to add to the checker
* @param disabled - when set to true, this will set the checker to a no-op function
*
* @param {Function} checker - the checker to setup with properties
* @param {Object} properties - properties to add to the checker
* @param {boolean} disabled - when set to true, this will set the checker to a no-op function
* @returns {Function} checker - the setup checker
*/
function setupChecker(checker, properties, disabled) {
/* eslint complexity:[2, 9] */
Expand Down Expand Up @@ -187,7 +190,7 @@ function setupChecker(checker, properties, disabled) {
}

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

function addOptional(checker, disabled) {
var optionalCheck = disabled ? getNoop() : function optionalCheck(val, name, location, obj) {
const optionalCheck = disabled ? getNoop() : function optionalCheck(val, name, location, obj) {
if (!undef(val)) {
return checker(val, name, location, obj);
}
Expand All @@ -223,7 +226,7 @@ function addOptional(checker, disabled) {
}

function addNullable(checker, disabled) {
var nullableCheck = disabled ? getNoop() : function nullableCheck(val, name, location, obj) {
const nullableCheck = disabled ? getNoop() : function nullableCheck(val, name, location, obj) {
if (val !== null) {
return checker(val, name, location, obj);
}
Expand Down
Loading

0 comments on commit 37ed4b8

Please sign in to comment.