Proper compilation phase (fix #50).

This commit is contained in:
Julien Fontanet 2015-03-30 17:58:13 +02:00
parent 4dc89c9082
commit 9f9ab01508
10 changed files with 113 additions and 60 deletions

2
.gitignore vendored
View File

@ -1,3 +1,5 @@
/dist/
/node_modules/
npm-debug.log
.xo-server.*

View File

@ -16,7 +16,21 @@ ___
## Installation
Manual install procedure is [available here](https://github.com/vatesfr/xo/blob/master/doc/installation/README.md#installation)
Manual install procedure is [available here](https://github.com/vatesfr/xo/blob/master/doc/installation/README.md#installation).
## Compilation
Production build:
```
$ npm run build
```
Development build:
```
$ npm run dev
```
## How to report a bug?

65
gulpfile.js Normal file
View File

@ -0,0 +1,65 @@
'use strict';
// ===================================================================
var gulp = require('gulp')
var babel = require('gulp-babel')
var coffee = require('gulp-coffee')
var plumber = require('gulp-plumber')
var sourceMaps = require('gulp-sourcemaps')
var watch = require('gulp-watch')
// ===================================================================
var SRC_DIR = __dirname + '/src';
var DIST_DIR = __dirname + '/dist';
var PRODUCTION = process.argv.indexOf('--production') !== -1
// ===================================================================
function src(patterns) {
return PRODUCTION ?
gulp.src(patterns, {
base: SRC_DIR,
cwd: SRC_DIR,
}) :
watch(patterns, {
base: SRC_DIR,
cwd: SRC_DIR,
ignoreInitial: false,
verbose: true
})
.pipe(plumber())
}
// ===================================================================
gulp.task(function buildCoffee() {
return src('**/*.coffee')
.pipe(sourceMaps.init())
.pipe(coffee({
bare: true
}))
.pipe(sourceMaps.write('.'))
.pipe(gulp.dest(DIST_DIR))
})
gulp.task(function buildEs6() {
return src('**/*.js')
.pipe(sourceMaps.init())
.pipe(babel({
compact: true,
comments: false,
optional: [
'runtime'
]
}))
.pipe(sourceMaps.write('.'))
.pipe(gulp.dest(DIST_DIR))
})
// ===================================================================
gulp.task('build', gulp.parallel('buildCoffee', 'buildEs6'))

View File

@ -1,24 +1,14 @@
'use strict';
'use strict'
//====================================================================
// ===================================================================
// Enable xo logs by default.
if (process.env.DEBUG === undefined) {
process.env.DEBUG = 'xo:*';
process.env.DEBUG = 'xo:*'
}
var debug = require('debug')('xo:runner');
// Enable source maps support for traces.
require('source-map-support').install()
//====================================================================
// Some modules are written in CoffeeScript.
debug('Loading CoffeeScript...');
require('coffee-script/register');
// Some modules are written in ES6.
debug('Loading Babel (ES6 support)...');
require('babel/register')({
ignore: /xo-.*\/node_modules/
});
debug('Loading main module...');
module.exports = require('./src');
// Import the real main module.
module.exports = require('./dist')

View File

@ -15,6 +15,9 @@
},
"author": "Julien Fontanet <julien.fontanet@vates.fr>",
"preferGlobal": true,
"files": [
"dist/"
],
"directories": {
"bin": "bin"
},
@ -24,10 +27,9 @@
},
"dependencies": {
"app-conf": "^0.3.4",
"babel": "^4.7.13",
"babel-runtime": "^4.7.16",
"base64url": "1.0.4",
"bluebird": "^2.9.14",
"coffee-script": "~1.9.1",
"compiled-accessors": "^0.2.0",
"connect": "^3.3.5",
"debug": "^2.1.3",
@ -36,6 +38,7 @@
"fibers": "~1.0.5",
"fs-promise": "^0.3.1",
"graceful-fs": "^3.0.6",
"gulp-sourcemaps": "^1.5.1",
"hashy": "~0.4.2",
"http-server-plus": "^0.5.1",
"human-format": "^0.3.0",
@ -65,6 +68,7 @@
"require-tree": "~1.0.1",
"schema-inspector": "^1.5.1",
"serve-static": "^1.9.2",
"source-map-support": "^0.2.10",
"then-redis": "~1.3.0",
"ws": "~0.7.1",
"xml2js": "~0.4.6",
@ -73,13 +77,21 @@
"devDependencies": {
"chai": "~2.1.2",
"coffeelint-no-implicit-returns": "0.0.4",
"glob": "~5.0.3",
"gulp": "git://github.com/gulpjs/gulp#4.0",
"gulp-babel": "^4.0.1",
"gulp-coffee": "^2.3.1",
"gulp-plumber": "^1.0.0",
"gulp-watch": "^4.2.2",
"in-publish": "^1.1.1",
"mocha": "^2.2.1",
"node-inspector": "^0.9.2",
"sinon": "^1.14.1"
},
"scripts": {
"build": "gulp build --production",
"dev": "gulp build",
"prepublish": "in-publish && npm run build || in-install",
"start": "node bin/xo-server",
"test": "coffee run-tests"
"test": "mocha 'dist/**/*.spec.js'"
}
}

View File

@ -1,32 +0,0 @@
#!/usr/bin/env coffee
# Some modules are written in ES6.
require('babel/register')
# Tests runner.
$mocha = require 'mocha'
# Used to find the specification files.
$glob = require 'glob'
#=====================================================================
do ->
# Instantiates the tests runner.
mocha = new $mocha {
reporter: 'spec'
}
# Processes arguments.
do ->
{argv} = process
i = 2
n = argv.length
mocha.grep argv[i++] while i < n
$glob 'src/**/*.spec.{coffee,js}', (error, files) ->
console.error(error) if error
mocha.addFile file for file in files
mocha.run( -> )

View File

@ -4,7 +4,7 @@ $sinon = require 'sinon'
#---------------------------------------------------------------------
{$MappedCollection} = require './MappedCollection.coffee'
{$MappedCollection} = require './MappedCollection'
#=====================================================================

View File

@ -4,7 +4,7 @@ $sinon = require 'sinon'
#---------------------------------------------------------------------
{$MappedCollection} = require './MappedCollection.coffee'
{$MappedCollection} = require './MappedCollection'
$nonBindedHelpers = require './helpers'

View File

@ -4,7 +4,7 @@ $sinon = require 'sinon'
#---------------------------------------------------------------------
{$MappedCollection} = require './MappedCollection.coffee'
{$MappedCollection} = require './MappedCollection'
# Helpers for dealing with fibers.
{$coroutine} = require './fibers-utils'

View File

@ -29,6 +29,8 @@ $XAPI = require './xapi'
} = require './utils'
{$MappedCollection} = require './MappedCollection'
{default: {Set}} = require 'babel-runtime/core-js'
#=====================================================================
# Models and collections.
@ -45,9 +47,9 @@ class $Acl extends $Model
class $Acls extends $RedisCollection
Model: $Acl
create: (subject, object) ->
@create: (subject, object) ->
return $Acl.create(subject, object).then((acl) => @add acl)
delete: (subject, object) ->
@delete: (subject, object) ->
return $Acl.hash(subject, object).then((hash) => @remove hash)
#---------------------------------------------------------------------