From c03bcd21e5fe3d6d568f705f4efdcae468e68b8b Mon Sep 17 00:00:00 2001 From: Boris Serdiuk Date: Fri, 1 Jul 2016 11:38:53 +0200 Subject: [PATCH 1/3] prepare umd build before publish --- .gitignore | 9 ++++---- examples/vanilla/index.html | 42 +++++++++++++++++++++++++++++++++++++ package.json | 17 ++++++++++++++- 3 files changed, 63 insertions(+), 5 deletions(-) create mode 100644 examples/vanilla/index.html diff --git a/.gitignore b/.gitignore index 7582006..03944d1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,11 @@ node_modules/ coverage/ -coverage.json +dist/ tmp/ -npm-debug.log* -.DS_Store .sauce-credentials.json -*.swp sauce_connect.log +npm-debug.log* +coverage.json +.DS_Store +*.swp .zuulrc diff --git a/examples/vanilla/index.html b/examples/vanilla/index.html new file mode 100644 index 0000000..cd93a66 --- /dev/null +++ b/examples/vanilla/index.html @@ -0,0 +1,42 @@ + + + Vanilla example + + + + + + diff --git a/package.json b/package.json index aaef47a..f6fe061 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,10 @@ "test:browser": "standard && npm run deps && NODE_ENV=test zuul tests/browser/*", "test:browser:local": "standard && npm run deps && NODE_ENV=test zuul --local 8080 -- tests/browser/*", "preversion": "if [ ! -z $SKIP_TEST ]; then npm run test:browser; fi", - "test": "npm run test:electron" + "test": "npm run test:electron", + "build:dev": "NODE_ENV=development browserify index.js --standalone=choo -t envify > dist/choo.js", + "build:min": "NODE_ENV=production browserify index.js --standalone=choo -t envify -g unassertify -g uglifyify | uglifyjs > dist/choo.min.js", + "prepublish": "mkdir -p 'dist/' && npm run build:dev && npm run build:min" }, "repository": "yoshuawuyts/choo", "keywords": [ @@ -22,6 +25,11 @@ "composable", "tiny" ], + "files": [ + "index.js", + "http.js", + "dist" + ], "license": "MIT", "dependencies": { "barracks": "^8.0.0", @@ -40,6 +48,7 @@ "browserify-istanbul": "^2.0.0", "bundle-collapser": "^1.2.1", "dependency-check": "^2.5.1", + "envify": "^3.4.1", "es2020": "^1.0.1", "geval": "~2.1.1", "insert-css": "^0.2.0", @@ -54,9 +63,15 @@ "standard": "^7.1.0", "tachyons": "^4.0.0-beta.19", "tape": "^4.5.1", +<<<<<<< HEAD "tape-istanbul": "~1.0.2", "tape-run": "~2.1.4", "yo-yoify": "^3.1.0", +======= + "uglifyify": "^3.0.2", + "uglifyjs": "^2.4.10", + "unassertify": "^2.0.3", +>>>>>>> 7370fd0... prepare umd build before publish "zuul": "toddself/zuul" } } From 50daf1f481fbb412c4a0b47795cdcb42acc26cdc Mon Sep 17 00:00:00 2001 From: Yoshua Wuyts Date: Tue, 12 Jul 2016 15:24:36 +0200 Subject: [PATCH 2/3] script/build: add --- package.json | 11 +++---- scripts/build | 54 +++++++++++++++++++++++++++++++ scripts/{test-size => instrument} | 4 ++- 3 files changed, 61 insertions(+), 8 deletions(-) create mode 100755 scripts/build rename scripts/{test-size => instrument} (97%) diff --git a/package.json b/package.json index f6fe061..c8a0624 100644 --- a/package.json +++ b/package.json @@ -12,9 +12,9 @@ "test:browser:local": "standard && npm run deps && NODE_ENV=test zuul --local 8080 -- tests/browser/*", "preversion": "if [ ! -z $SKIP_TEST ]; then npm run test:browser; fi", "test": "npm run test:electron", - "build:dev": "NODE_ENV=development browserify index.js --standalone=choo -t envify > dist/choo.js", - "build:min": "NODE_ENV=production browserify index.js --standalone=choo -t envify -g unassertify -g uglifyify | uglifyjs > dist/choo.min.js", - "prepublish": "mkdir -p 'dist/' && npm run build:dev && npm run build:min" + "build:dev": "./scripts/build dev", + "build:min": "./scripts/build min", + "prepublish": "npm run build:dev && npm run build:min" }, "repository": "yoshuawuyts/choo", "keywords": [ @@ -63,15 +63,12 @@ "standard": "^7.1.0", "tachyons": "^4.0.0-beta.19", "tape": "^4.5.1", -<<<<<<< HEAD "tape-istanbul": "~1.0.2", "tape-run": "~2.1.4", - "yo-yoify": "^3.1.0", -======= "uglifyify": "^3.0.2", "uglifyjs": "^2.4.10", "unassertify": "^2.0.3", ->>>>>>> 7370fd0... prepare umd build before publish + "yo-yoify": "^3.1.0", "zuul": "toddself/zuul" } } diff --git a/scripts/build b/scripts/build new file mode 100755 index 0000000..6f743b2 --- /dev/null +++ b/scripts/build @@ -0,0 +1,54 @@ +#!/bin/sh + +dirname=$(dirname "$(readlink -f "$0")") + +browserify="$dirname/../node_modules/.bin/browserify" +uglify="$dirname/../node_modules/.bin/uglifyjs" + +usage () { + printf "Usage: build-umd \n" +} + +build_dev () { + mkdir -p dist/ + NODE_ENV=development "$browserify" index.js \ + --standalone=choo \ + -t envify \ + > dist/choo.js +} + +build_min () { + mkdir -p dist/ + NODE_ENV=production "$browserify" index.js \ + --standalone=choo \ + -t envify \ + -g unassertify \ + -g uglifyify \ + | "$uglify" \ + > dist/choo.min.js +} + +# set CLI flags +getopt -T > /dev/null +if [ "$?" -eq 4 ]; then + args="$(getopt --long help dev min --options hdm -- "$*")" +else + args="$(getopt h "$*")"; +fi +[ ! $? -eq 0 ] && { usage && exit 2; } +eval set -- "$args" + +# parse CLI flags +while true; do + case "$1" in + -h|--help) usage && exit 1 ;; + -- ) shift; break ;; + * ) break ;; + esac +done + +case "$1" in + d|dev) shift; build_dev "$@" ;; + m|min) shift; build_min "$@" ;; + *) shift; build_min "$@" ;; +esac diff --git a/scripts/test-size b/scripts/instrument similarity index 97% rename from scripts/test-size rename to scripts/instrument index 009daf9..123c132 100755 --- a/scripts/test-size +++ b/scripts/instrument @@ -48,7 +48,9 @@ run_discify () { getopt -T > /dev/null if [ "$?" -eq 4 ]; then args="$(getopt --long help discify minified --options hmdg -- "$*")" -else args="$(getopt h "$*")"; fi +else + args="$(getopt h "$*")"; +fi [ ! $? -eq 0 ] && { usage && exit 2; } eval set -- "$args" From 5357ca2614985619ed2497b9ba88632d6209dc1f Mon Sep 17 00:00:00 2001 From: Yoshua Wuyts Date: Tue, 12 Jul 2016 16:11:04 +0200 Subject: [PATCH 3/3] scripts: add test --- package.json | 12 ++++---- scripts/build | 10 ------ scripts/test | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 91 insertions(+), 16 deletions(-) create mode 100755 scripts/test diff --git a/package.json b/package.json index c8a0624..05454e4 100644 --- a/package.json +++ b/package.json @@ -4,12 +4,12 @@ "description": "A 5kb framework for creating sturdy frontend applications", "main": "index.js", "scripts": { - "deps": "dependency-check . && dependency-check . --extra --no-dev -i xhr", - "test:electron": "browserify tests/**/*.js -t es2020 -p proxyquire-universal | tape-run", - "test:cov": "browserify tests/**/*.js -t es2020 -p proxyquire-universal -p tape-istanbul/plugin | tape-run | tape-istanbul && istanbul report", - "test:server": "standard && npm run deps && NODE_ENV=test node tests/server/*", - "test:browser": "standard && npm run deps && NODE_ENV=test zuul tests/browser/*", - "test:browser:local": "standard && npm run deps && NODE_ENV=test zuul --local 8080 -- tests/browser/*", + "deps": "./scripts/test deps", + "test:electron": "./scripts/test electron", + "test:cov": "./scripts/test cov", + "test:server": "./scripts/test server", + "test:browser": "./scripts/test browser", + "test:browser-local": "./scripts/test browser-local", "preversion": "if [ ! -z $SKIP_TEST ]; then npm run test:browser; fi", "test": "npm run test:electron", "build:dev": "./scripts/build dev", diff --git a/scripts/build b/scripts/build index 6f743b2..c99a807 100755 --- a/scripts/build +++ b/scripts/build @@ -28,16 +28,6 @@ build_min () { > dist/choo.min.js } -# set CLI flags -getopt -T > /dev/null -if [ "$?" -eq 4 ]; then - args="$(getopt --long help dev min --options hdm -- "$*")" -else - args="$(getopt h "$*")"; -fi -[ ! $? -eq 0 ] && { usage && exit 2; } -eval set -- "$args" - # parse CLI flags while true; do case "$1" in diff --git a/scripts/test b/scripts/test new file mode 100755 index 0000000..08ddca3 --- /dev/null +++ b/scripts/test @@ -0,0 +1,85 @@ +#!/bin/sh + +# setting exit because we're linting and need to exit on failure +set -e + +dirname=$(dirname "$(readlink -f "$0")") + +dependency_check="$dirname/../node_modules/.bin/dependency-check" +tape_istanbul="$dirname/../node_modules/.bin/tape-istanbul" +browserify="$dirname/../node_modules/.bin/browserify" +standard="$dirname/../node_modules/.bin/standard" +tape_run="$dirname/../node_modules/.bin/tape-run" +istanbul="$dirname/../node_modules/.bin/istanbul" +zuul="$dirname/../node_modules/.bin/zuul" + +usage () { + printf "Usage: test\n" +} + +lint () { + "$standard" +} + +test_electron () { + check_deps + lint + "$browserify" tests/**/*.js \ + -t es2020 \ + -p proxyquire-universal \ + | "$tape_run" +} + +test_cov () { + check_deps + lint + "$browserify" tests/**/*.js \ + -t es2020 \ + -p proxyquire-universal \ + -p tape-istanbul/plugin \ + | "$tape_run" \ + | "$tape_istanbul" \ + && "$istanbul" report +} + +test_server () { + lint + standard + check_deps + NODE_ENV=test node tests/server/* +} + +test_browser () { + NODE_ENV=test "$zuul" tests/browser/* +} + +test_browser_local () { + lint + check_deps + NODE_ENV=test "$zuul" --local 8080 -- tests/browser/* +} + +check_deps () { + "$dependency_check" . --entry 'index.js' + "$dependency_check" . --entry 'index.js' --extra --no-dev \ + -i xhr +} + +# set CLI flags +# parse CLI flags +while true; do + case "$1" in + -h|--help) usage && exit 1 ;; + -- ) shift; break ;; + * ) break ;; + esac +done + +case "$1" in + e|electron) shift; test_electron "$@" && exit ;; + b|browser) shift; test_browser "$@" && exit ;; + l|browser-local) shift; test_browser_local "$@" && exit ;; + s|server) shift; test_server "$@" && exit ;; + c|cov) shift; test_cov "$@" && exit ;; + d|deps) shift; check_deps "$@" && exit ;; +esac