Skip to content

Commit ad3230a

Browse files
author
Vitor Silva
committed
Update the distribution file; Remove temporarly the graph connector (using a lot of space);
2 parents dff597d + 23a9ad5 commit ad3230a

23 files changed

+1170
-1109
lines changed

.jscsrc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"esnext": true,
32
"disallowSpacesInNamedFunctionExpression": {
43
"beforeOpeningRoundBrace": true
54
},

dist/Runtime.js

Lines changed: 13 additions & 36 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/Runtime.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/minibus.js

Lines changed: 26 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/minibus.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/sandbox.js

Lines changed: 26 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/sandbox.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gulpfile.js

Lines changed: 111 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ var gulp = require('gulp');
44
var exec = require('child_process').exec;
55
var jsdoc = require('gulp-jsdoc3');
66
var pandoc = require('gulp-pandoc');
7+
var fs = require('fs');
78

89
// Task and dependencies to distribute for all environments;
910
var babel = require('babelify');
1011
var browserify = require('browserify');
1112
var buffer = require('vinyl-buffer');
1213
var source = require('vinyl-source-stream');
14+
var sourcemaps = require('gulp-sourcemaps');
1315
var replace = require('gulp-replace');
1416
var insert = require('gulp-insert');
1517
var uglify = require('gulp-uglify');
@@ -18,6 +20,8 @@ var argv = require('yargs').argv;
1820
var through = require('through2');
1921
var path = require('path');
2022
var gulpif = require('gulp-if');
23+
var gutil = require('gulp-util');
24+
var extensions = ['.js', '.json'];
2125

2226
var git = require('gulp-git');
2327
var prompt = require('gulp-prompt');
@@ -127,107 +131,120 @@ function prependLicense(clean) {
127131

128132
}
129133

130-
gulp.task('runtime', function() {
131-
132-
var compact = true;
133-
134-
return browserify({
135-
entries: ['./src/runtime/RuntimeUA.js'],
136-
standalone: 'Runtime',
137-
debug: false
138-
})
139-
.transform(babel, {
140-
compact: compact,
141-
presets: ['es2015', 'stage-0'],
142-
plugins: ['add-module-exports', 'transform-runtime', 'transform-regenerator']
143-
})
144-
.bundle()
145-
.on('error', function(err) {
146-
console.error(err);
147-
this.emit('end');
148-
})
149-
.pipe(source('Runtime.js'))
150-
.pipe(buffer())
151-
.pipe(gulpif(compact, uglify()))
152-
.pipe(gulpif(compact, insert.prepend(license + '// Runtime User Agent \n\n// version: {{version}}\n\n')))
153-
.pipe(gulpif(compact, replace('{{version}}', pkg.version)))
154-
.pipe(gulp.dest('./dist'));
134+
/**
135+
* Make 3 distriution files
136+
* By default the compact mode is true;
137+
* How to use: gulp dist --compact false | true;
138+
*/
139+
gulp.task('dist', function() {
140+
141+
return gulp.src(['src/sandbox.js', 'src/minibus.js', 'src/runtime/RuntimeUA.js'])
142+
.pipe(dist());
155143

156144
});
157145

158-
gulp.task('minibus', function() {
159-
160-
var compact = true;
161-
162-
var descriptionNote = '/**\n' +
163-
'* Minimal interface and implementation to send and receive messages. It can be reused in many type of components.\n' +
164-
'* Components that need a message system should receive this class as a dependency or extend it.\n' +
165-
'* Extensions should implement the following private methods: _onPostMessage and _registerExternalListener.\n' +
166-
'*/\n';
167-
168-
return browserify({
169-
entries: ['./src/minibus.js'],
170-
standalone: 'MiniBus',
171-
debug: false
172-
})
173-
.transform(babel, {
174-
compact: compact,
175-
presets: ['es2015', 'stage-0'],
176-
plugins: ['add-module-exports', 'transform-runtime', 'transform-regenerator']
177-
})
178-
.bundle()
179-
.on('error', function(err) {
180-
console.error(err);
181-
this.emit('end');
182-
})
183-
.pipe(source('minibus.js'))
184-
.pipe(buffer())
185-
.pipe(gulpif(compact, uglify()))
186-
.pipe(gulpif(compact, insert.prepend(descriptionNote + '// version: {{version}}\n\n')))
187-
.pipe(gulpif(compact, replace('{{version}}', pkg.version)))
188-
.pipe(gulp.dest('./dist'));
146+
function dist(debug) {
189147

190-
});
148+
if (!debug) debug = false;
191149

192-
gulp.task('sandbox', function() {
193-
194-
var descriptionNote = '/**\n' +
195-
'* @author micaelpedrosa@gmail.com\n' +
196-
'* Base class to implement external sandbox component\n' +
197-
'*/\n\n';
198-
199-
var compact = true;
200-
201-
return browserify({
202-
entries: ['./src/sandbox.js'],
203-
standalone: 'sandbox',
204-
debug: false
205-
})
206-
.transform(babel, {
207-
compact: compact,
208-
presets: ['es2015', 'stage-0'],
209-
plugins: ['add-module-exports', 'transform-runtime', 'transform-regenerator']
210-
})
211-
.bundle()
212-
.on('error', function(err) {
213-
console.error(err);
214-
this.emit('end');
215-
})
216-
.pipe(source('sandbox.js'))
217-
.pipe(buffer())
218-
.pipe(gulpif(compact, uglify()))
219-
.pipe(gulpif(compact, insert.prepend(descriptionNote + '// version: {{version}}\n\n')))
220-
.pipe(gulpif(compact, replace('{{version}}', pkg.version)))
221-
.pipe(gulp.dest('./dist'));
150+
return through.obj(function(file, enc, cb) {
222151

223-
});
152+
if (file.isNull()) {
153+
return cb(new Error('Fil is null'));
154+
}
224155

225-
/**
226-
* Make 3 distriution files
227-
* By default the compact mode is true;
228-
* How to use: gulp dist --compact false | true;
229-
*/
230-
gulp.task('dist', ['runtime', 'minibus', 'sandbox']);
156+
if (file.isStream()) {
157+
return cb(new Error('Streaming not supported'));
158+
}
159+
160+
var filename = path.basename(file.path, '.js');
161+
162+
var opts = {
163+
configuration: {},
164+
debug: false,
165+
standalone: filename === 'RuntimeUA' ? 'Runtime' : filename,
166+
destination: __dirname + '/dist'
167+
};
168+
169+
gutil.log(gutil.colors.yellow('Make a distribution file from', filename + '.js'));
170+
171+
gulp.src([file.path])
172+
.pipe(transpile(opts))
173+
.pipe(mark())
174+
.pipe(gulp.dest(__dirname + '/dist'))
175+
.on('error', function(error) {
176+
gutil.log(gutil.colors.red(error));
177+
})
178+
.on('end', function() {
179+
gutil.log('> ' + gutil.colors.green('Distribution ') + gutil.colors.white(filename) + gutil.colors.green(' done!'));
180+
cb();
181+
});
182+
});
183+
184+
}
185+
186+
function mark() {
187+
188+
return through.obj(function(file, enc, cb) {
189+
190+
var fileObject = path.parse(file.path);
191+
192+
gulp.src([file.path])
193+
.pipe(insert.prepend(license + '// Distribution file for {{package}} \n// version: {{version}}\n// Last build: {{date}}\n\n'))
194+
.pipe(replace('{{version}}', pkg.version))
195+
.pipe(replace('{{package}}', fileObject.name + '.js'))
196+
.pipe(replace('{{date}}', new Date()))
197+
.pipe(gulp.dest(__dirname + '/dist'))
198+
.on('end', function() {
199+
cb();
200+
});
201+
202+
});
203+
204+
}
205+
206+
function transpile(opts) {
207+
208+
return through.obj(function(file, enc, cb) {
209+
210+
var fileObject = path.parse(file.path);
211+
var filename = fileObject.base === 'RuntimeUA.js' ? 'Runtime.js' : fileObject.base;
212+
var args = {};
213+
214+
var environment = argv.production || process.env.NODE_ENV;
215+
process.env.environment = environment ? 'production' : 'development';
216+
217+
args.entries = [file.path];
218+
args.extensions = extensions;
219+
if (opts.debug) args.debug = opts.debug;
220+
if (opts.standalone) args.standalone = opts.standalone;
221+
222+
return browserify(args)
223+
.transform(babel, {
224+
compact: true,
225+
presets: ['es2015', 'stage-0'],
226+
plugins: ['add-module-exports', 'babel-polyfill', 'transform-runtime', 'transform-regenerator']
227+
})
228+
.bundle()
229+
.on('error', function(err) {
230+
gutil.log(gutil.colors.red(err));
231+
this.emit('end');
232+
})
233+
.pipe(source(filename))
234+
.pipe(buffer())
235+
.pipe(sourcemaps.init({loadMaps: true}))
236+
.pipe(uglify())
237+
.pipe(sourcemaps.write('./'))
238+
.pipe(gulp.dest(opts.destination))
239+
.on('end', function() {
240+
file.contents = fs.readFileSync(opts.destination + '/' + filename);
241+
file.path = opts.destination + '/' + filename;
242+
cb(null, file);
243+
});
244+
245+
});
246+
247+
}
231248

232249
/**
233250
* Bumping version number and tagging the repository with it.

karma.conf.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ module.exports = function(config) {
2424

2525
// list of files to exclude
2626
exclude: [
27-
'test/PolicyEngine.spec.js',
2827
'test/GraphConnector.spec.js'
2928
],
3029

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@
2929
"url": "https://github.com/reTHINK-project/dev-runtime-core/issues"
3030
},
3131
"homepage": "https://rethink-project.eu/",
32-
"dependencies": {},
32+
"dependencies": {
33+
"gulp-sourcemaps": "^1.6.0",
34+
"gulp-util": "^3.0.7"
35+
},
3336
"devDependencies": {
3437
"array.observe": "0.0.1",
3538
"babel-plugin-add-module-exports": "^0.1.3",

0 commit comments

Comments
 (0)