+5
-4
@@ -1,10 +1,11 @@
|
|||||||
node_modules/
|
node_modules/
|
||||||
coverage/
|
coverage/
|
||||||
coverage.json
|
dist/
|
||||||
tmp/
|
tmp/
|
||||||
npm-debug.log*
|
|
||||||
.DS_Store
|
|
||||||
.sauce-credentials.json
|
.sauce-credentials.json
|
||||||
*.swp
|
|
||||||
sauce_connect.log
|
sauce_connect.log
|
||||||
|
npm-debug.log*
|
||||||
|
coverage.json
|
||||||
|
.DS_Store
|
||||||
|
*.swp
|
||||||
.zuulrc
|
.zuulrc
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Vanilla example</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<script src="../../dist/choo.min.js"></script>
|
||||||
|
<script>
|
||||||
|
const app = choo()
|
||||||
|
|
||||||
|
app.model({
|
||||||
|
namespace: 'counter',
|
||||||
|
state: {
|
||||||
|
count: 0
|
||||||
|
},
|
||||||
|
reducers: {
|
||||||
|
increment: (action, state) => ({count: state.count + 1}),
|
||||||
|
decrement: (action, state) => ({count: state.count - 1})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const mainView = (params, state, send) => {
|
||||||
|
return choo.view`
|
||||||
|
<main class="app">
|
||||||
|
<h1>Counter example</h1>
|
||||||
|
<div>
|
||||||
|
Count: ${state.counter.count}
|
||||||
|
<button onclick=${(e) => send('counter:increment')}>+</button>
|
||||||
|
<button onclick=${(e) => send('counter:decrement')}>-</button>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
`
|
||||||
|
}
|
||||||
|
|
||||||
|
app.router((route) => [
|
||||||
|
route('/', mainView)
|
||||||
|
])
|
||||||
|
|
||||||
|
const tree = app.start()
|
||||||
|
document.body.appendChild(tree)
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
+19
-7
@@ -4,14 +4,17 @@
|
|||||||
"description": "A 5kb framework for creating sturdy frontend applications",
|
"description": "A 5kb framework for creating sturdy frontend applications",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"deps": "dependency-check . && dependency-check . --extra --no-dev -i xhr",
|
"deps": "./scripts/test deps",
|
||||||
"test:electron": "browserify tests/**/*.js -t es2020 -p proxyquire-universal | tape-run",
|
"test:electron": "./scripts/test electron",
|
||||||
"test:cov": "browserify tests/**/*.js -t es2020 -p proxyquire-universal -p tape-istanbul/plugin | tape-run | tape-istanbul && istanbul report",
|
"test:cov": "./scripts/test cov",
|
||||||
"test:server": "standard && npm run deps && NODE_ENV=test node tests/server/*",
|
"test:server": "./scripts/test server",
|
||||||
"test:browser": "standard && npm run deps && NODE_ENV=test zuul tests/browser/*",
|
"test:browser": "./scripts/test browser",
|
||||||
"test:browser:local": "standard && npm run deps && NODE_ENV=test zuul --local 8080 -- tests/browser/*",
|
"test:browser-local": "./scripts/test browser-local",
|
||||||
"preversion": "if [ ! -z $SKIP_TEST ]; then npm run test:browser; fi",
|
"preversion": "if [ ! -z $SKIP_TEST ]; then npm run test:browser; fi",
|
||||||
"test": "npm run test:electron"
|
"test": "npm run test:electron",
|
||||||
|
"build:dev": "./scripts/build dev",
|
||||||
|
"build:min": "./scripts/build min",
|
||||||
|
"prepublish": "npm run build:dev && npm run build:min"
|
||||||
},
|
},
|
||||||
"repository": "yoshuawuyts/choo",
|
"repository": "yoshuawuyts/choo",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
@@ -22,6 +25,11 @@
|
|||||||
"composable",
|
"composable",
|
||||||
"tiny"
|
"tiny"
|
||||||
],
|
],
|
||||||
|
"files": [
|
||||||
|
"index.js",
|
||||||
|
"http.js",
|
||||||
|
"dist"
|
||||||
|
],
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"barracks": "^8.0.0",
|
"barracks": "^8.0.0",
|
||||||
@@ -40,6 +48,7 @@
|
|||||||
"browserify-istanbul": "^2.0.0",
|
"browserify-istanbul": "^2.0.0",
|
||||||
"bundle-collapser": "^1.2.1",
|
"bundle-collapser": "^1.2.1",
|
||||||
"dependency-check": "^2.5.1",
|
"dependency-check": "^2.5.1",
|
||||||
|
"envify": "^3.4.1",
|
||||||
"es2020": "^1.0.1",
|
"es2020": "^1.0.1",
|
||||||
"geval": "~2.1.1",
|
"geval": "~2.1.1",
|
||||||
"insert-css": "^0.2.0",
|
"insert-css": "^0.2.0",
|
||||||
@@ -56,6 +65,9 @@
|
|||||||
"tape": "^4.5.1",
|
"tape": "^4.5.1",
|
||||||
"tape-istanbul": "~1.0.2",
|
"tape-istanbul": "~1.0.2",
|
||||||
"tape-run": "~2.1.4",
|
"tape-run": "~2.1.4",
|
||||||
|
"uglifyify": "^3.0.2",
|
||||||
|
"uglifyjs": "^2.4.10",
|
||||||
|
"unassertify": "^2.0.3",
|
||||||
"yo-yoify": "^3.1.0",
|
"yo-yoify": "^3.1.0",
|
||||||
"zuul": "toddself/zuul"
|
"zuul": "toddself/zuul"
|
||||||
}
|
}
|
||||||
|
|||||||
Executable
+44
@@ -0,0 +1,44 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
dirname=$(dirname "$(readlink -f "$0")")
|
||||||
|
|
||||||
|
browserify="$dirname/../node_modules/.bin/browserify"
|
||||||
|
uglify="$dirname/../node_modules/.bin/uglifyjs"
|
||||||
|
|
||||||
|
usage () {
|
||||||
|
printf "Usage: build-umd <argument>\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
|
||||||
|
}
|
||||||
|
|
||||||
|
# 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
|
||||||
@@ -48,7 +48,9 @@ run_discify () {
|
|||||||
getopt -T > /dev/null
|
getopt -T > /dev/null
|
||||||
if [ "$?" -eq 4 ]; then
|
if [ "$?" -eq 4 ]; then
|
||||||
args="$(getopt --long help discify minified --options hmdg -- "$*")"
|
args="$(getopt --long help discify minified --options hmdg -- "$*")"
|
||||||
else args="$(getopt h "$*")"; fi
|
else
|
||||||
|
args="$(getopt h "$*")";
|
||||||
|
fi
|
||||||
[ ! $? -eq 0 ] && { usage && exit 2; }
|
[ ! $? -eq 0 ] && { usage && exit 2; }
|
||||||
eval set -- "$args"
|
eval set -- "$args"
|
||||||
|
|
||||||
Executable
+85
@@ -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
|
||||||
Reference in New Issue
Block a user