Skip to content

Commit

Permalink
package.json: update build system and dependencies; release version 1…
Browse files Browse the repository at this point in the history
….2.0

- don't compile stuff in test/
- minify views
- compile in parallel
  • Loading branch information
michael-brade committed Oct 9, 2016
1 parent c47ec8a commit 14e45fa
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 21 deletions.
21 changes: 17 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.


Expand All @@ -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
Expand All @@ -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`.



Expand Down Expand Up @@ -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
9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -19,6 +19,7 @@
},
"dependencies": {
"lodash": "4.x",
"derby-select2": "0.2.x"
},
"devDependencies": {
"livescript": "1.5.x",
Expand All @@ -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"
Expand Down
24 changes: 12 additions & 12 deletions package.json.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand All @@ -23,6 +23,7 @@ repository:
dependencies:
# utils
'lodash': '4.x'
'derby-select2': '0.2.x'

devDependencies:
# building
Expand All @@ -31,7 +32,7 @@ devDependencies:

# testing
'browserify': '13.x'
"browserify-livescript": "0.2.x"
'browserify-livescript': '0.2.x'

'derby': 'michael-brade/derby'

Expand All @@ -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
Expand All @@ -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'
Expand Down

0 comments on commit 14e45fa

Please sign in to comment.