From 14e45faa9b94b0dcea56e41fd243069dbdb1ecc5 Mon Sep 17 00:00:00 2001 From: Michael Brade Date: Sat, 8 Oct 2016 00:56:17 +0200 Subject: [PATCH] package.json: update build system and dependencies; release version 1.2.0 - don't compile stuff in test/ - minify views - compile in parallel --- README.md | 21 +++++++++++++++++---- package.json | 9 ++++----- package.json.sh | 24 ++++++++++++------------ 3 files changed, 33 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index def6002..a6a45f3 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,18 @@ npm test will then run the tests. +## Usage + +``` +EntitiesApi = require('derby-entities-lib/api'); + +// in the app init() function +EntitiesApi.init(model, entities); // see below for what an entities definition is + +// then get the API instance anywhere in the app: +var instance = EntitiesApi.instance(model); +``` + ## Terminology * entity: in case of Derby: a MongoDB collection @@ -214,7 +226,7 @@ Maybe I will add a `validation` property to an attribute... ### Adding new Attribute Type Definitions -Right now, each attribute type consists of a controller (written in JavaScript/LiveScript/whatever) and a Derby view. +Right now, each attribute type consists of a controller (written in JavaScript/LiveScript/ES6) and a Derby view. It is, in effect, a Derby component. @@ -230,7 +242,8 @@ Each type class has to provide the following methods: This returns the `item`'s attribute `attr` as html in the given `locale`. -If the type extends the class `Type`, then `attribute` is optional, and instead of the whole `item`, just its attribute is provided as `data`. This is just so that some common boilerplate can be avoided. +If the type extends the class `Type`, then `attribute` is optional, and instead of the whole `item`, just its attribute +is provided as `data`. This is just so that some common boilerplate can be avoided. #### View @@ -241,7 +254,7 @@ if the view should output plain text or html, or if the editor for that attribut Consequently, each component should define three subviews: `<-text:>`, `<-html:>`, and `<-edit:>`. There is a leading dash to make sure that views don't get confused with components, like `entity:text` vs `text`. -A type finally has to be registered in `EntitiesApi` (api.ls). +A type finally has to be registered in `EntitiesApi` (`api.ls`) by adding it to `types.ls`. @@ -283,4 +296,4 @@ Testing is done with `mocha`. There are two types of tests that are used in this MIT -Copyright (c) 2015 Michael Brade +Copyright (c) 2015-2016 Michael Brade diff --git a/package.json b/package.json index df116de..279ee44 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "derby-entities-lib", "description": "Base library for derby-entity CRUD component and derby-entities-visualizations", - "version": "1.1.3", + "version": "1.2.0", "main": "api.ls", "author": { "name": "Michael Brade", @@ -19,6 +19,7 @@ }, "dependencies": { "lodash": "4.x", + "derby-select2": "0.2.x" }, "devDependencies": { "livescript": "1.5.x", @@ -34,13 +35,11 @@ }, "scripts": { "prebuild": "npm run clean; touch .create_stash && git stash save --include-untracked \"npm build stash\";", - "build": "export DEST=dist;export ASSETS='.*.css|.*.html|./README.md|./package.json';find -path './node_modules*' -prune -o -name '*.ls' -print0| xargs -n1 -0 sh -c 'echo Compiling and minifying $0...;DEST_PATH=\"$DEST/`dirname $0`\";mkdir -p \"$DEST_PATH\";lsc -cp \"$0\" | uglifyjs - -cm -o \"$DEST_PATH/`basename -s .ls \"$0\"`\".js;';echo \"\u001b[01;32mCopying assets...\u001b[00m\";find \\( -path './node_modules*' -o -path \"./$DEST/*\" \\) -prune -o -regextype posix-egrep -regex $ASSETS -print0| xargs -n1 -0 sh -c 'mkdir -p \"$DEST/`dirname \"$0\"`\";cp -a \"$0\" \"$DEST/$0\"';echo \"\u001b[01;32mDone!\u001b[00m\";", + "build": "export DEST=dist;export ASSETS='.*.css|.*.html|./README.md|./package.json';find \\( -path './node_modules' -o -path \"./$DEST\" -o -path './test' \\) -prune -o -name '*.ls' -print0| xargs -n1 -P8 -0 sh -c 'echo Compiling and minifying $0...;mkdir -p \"$DEST/`dirname $0`\";lsc -cp \"$0\" | uglifyjs - -cm -o \"$DEST/${0%.*}.js\";';echo \"\u001b[01;32mCopying assets...\u001b[00m\";find \\( -path './node_modules' -o -path \"./$DEST\" -o -path './test' \\) -prune -o -regextype posix-egrep -regex $ASSETS -print0| xargs -n1 -0 sh -c 'mkdir -p \"$DEST/`dirname \"$0\"`\";cp -a \"$0\" \"$DEST/$0\"';echo \"\u001b[01;32mMinifying views...\u001b[00m\";find \"$DEST\" -name '*.html' -print0 | xargs -n1 -0 perl -i -p0e 's/\\n//g;s/ +/ /g;s///g';echo \"\u001b[01;32mDone!\u001b[00m\";", "postbuild": "git stash pop --index && rm .create_stash;", "clean": "rm -rf dist;", "test": "mocha test/_*.ls test/nightmare.js;", - "disttest": "npm run build; TODO", - "prepublish": "npm run clean; npm run build;", - "publish": "npm publish dist;" + "disttest": "npm run build; TODO" }, "engines": { "node": "4.x || 5.x" diff --git a/package.json.sh b/package.json.sh index a6e3d88..63b3528 100755 --- a/package.json.sh +++ b/package.json.sh @@ -2,7 +2,7 @@ name: 'derby-entities-lib' description: 'Base library for derby-entity CRUD component and derby-entities-visualizations' -version: '1.1.3' +version: '1.2.0' main: 'api.ls' @@ -23,6 +23,7 @@ repository: dependencies: # utils 'lodash': '4.x' + 'derby-select2': '0.2.x' devDependencies: # building @@ -31,7 +32,7 @@ devDependencies: # testing 'browserify': '13.x' - "browserify-livescript": "0.2.x" + 'browserify-livescript': '0.2.x' 'derby': 'michael-brade/derby' @@ -57,21 +58,23 @@ scripts: export DEST=dist; export ASSETS='.*\.css|.*\.html|./README\.md|./package\.json'; - find -path './node_modules*' -prune -o -name '*.ls' -print0 - | xargs -n1 -0 sh -c ' + find \\( -path './node_modules' -o -path \"./$DEST\" -o -path './test' \\) -prune -o -name '*.ls' -print0 + | xargs -n1 -P8 -0 sh -c ' echo Compiling and minifying $0...; - DEST_PATH=\"$DEST/`dirname $0`\"; - mkdir -p \"$DEST_PATH\"; - lsc -cp \"$0\" | uglifyjs - -cm -o \"$DEST_PATH/`basename -s .ls \"$0\"`\".js; + mkdir -p \"$DEST/`dirname $0`\"; + lsc -cp \"$0\" | uglifyjs - -cm -o \"$DEST/${0%.*}.js\"; '; echo \"\033[01;32mCopying assets...\033[00m\"; - find \\( -path './node_modules*' -o -path \"./$DEST/*\" \\) -prune -o -regextype posix-egrep -regex $ASSETS -print0 + find \\( -path './node_modules' -o -path \"./$DEST\" -o -path './test' \\) -prune -o -regextype posix-egrep -regex $ASSETS -print0 | xargs -n1 -0 sh -c ' mkdir -p \"$DEST/`dirname \"$0\"`\"; cp -a \"$0\" \"$DEST/$0\" '; + echo \"\033[01;32mMinifying views...\033[00m\"; + find \"$DEST\" -name '*.html' -print0 | xargs -n1 -0 perl -i -p0e 's/\\n//g;s/ +/ /g;s///g'; + echo \"\033[01;32mDone!\033[00m\"; " # restore the original situation @@ -85,10 +88,7 @@ scripts: disttest: 'npm run build; TODO' # find out how to run the tests using dist/* - ## publishing - run as "npm run publish" - - prepublish: "npm run clean; npm run build;" - publish: "npm publish dist;" + ## publishing: run "npm run build; cd dist; npm publish" engines: node: '4.x || 5.x'