mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2024-12-29 09:22:22 -05:00
Fix build issues on Travis and improve version handling in Gulp.js and Prepro.js
This reverts commit eaceb1bfc3
.
This commit is contained in:
parent
eaceb1bfc3
commit
503fe11e41
6 changed files with 69 additions and 45 deletions
12
README.md
12
README.md
|
@ -45,8 +45,8 @@ Paper.js, in minified and normal variants:
|
||||||
|
|
||||||
### Installing Node.js, NPM and Bower
|
### Installing Node.js, NPM and Bower
|
||||||
|
|
||||||
Node.js is required by Bower, as well as by Gulp, which needs to be installed if
|
Node.js is required by Bower, as well as by Gulp.js, which needs to be installed
|
||||||
you intend to build the library or its documentation by yourself.
|
if you intend to build the library or its documentation by yourself.
|
||||||
|
|
||||||
There are many tutorials explaining the different ways to install Node.js on
|
There are many tutorials explaining the different ways to install Node.js on
|
||||||
different platforms. It is generally not recommended to install Node.js through
|
different platforms. It is generally not recommended to install Node.js through
|
||||||
|
@ -147,7 +147,7 @@ run:
|
||||||
|
|
||||||
### Setting Up For Building
|
### Setting Up For Building
|
||||||
|
|
||||||
As of 2016, Paper.js uses [Gulp](http://gulpjs.com/) for building, and has a
|
As of 2016, Paper.js uses [Gulp.js](http://gulpjs.com/) for building, and has a
|
||||||
couple of dependencies as Bower and NPM modules. Read the chapter [Installing
|
couple of dependencies as Bower and NPM modules. Read the chapter [Installing
|
||||||
Node.js, NPM and Bower](#installing-nodejs-npm-and-bower) if you still need to
|
Node.js, NPM and Bower](#installing-nodejs-npm-and-bower) if you still need to
|
||||||
install these.
|
install these.
|
||||||
|
@ -159,8 +159,8 @@ following commands from the Paper.js directory:
|
||||||
npm install
|
npm install
|
||||||
bower install
|
bower install
|
||||||
|
|
||||||
It is also recommended to install Gulp globally, so you can easier execute the
|
It is also recommended to install Gulp.js globally, so you can easier execute
|
||||||
build commands from anywhere in the command line:
|
the build commands from anywhere in the command line:
|
||||||
|
|
||||||
npm install -g gulp
|
npm install -g gulp
|
||||||
|
|
||||||
|
@ -235,7 +235,7 @@ folder in your web browser. There should be a green bar at the top, meaning all
|
||||||
tests have passed. If the bar is red, some tests have not passed. These will be
|
tests have passed. If the bar is red, some tests have not passed. These will be
|
||||||
highlighted and become visible when scrolling down.
|
highlighted and become visible when scrolling down.
|
||||||
|
|
||||||
You can also run the unit tests through Gulp on the command line:
|
You can also run the unit tests through Gulp.js on the command line:
|
||||||
|
|
||||||
gulp test
|
gulp test
|
||||||
|
|
||||||
|
|
40
gulpfile.js
40
gulpfile.js
|
@ -21,14 +21,19 @@ var gulp = require('gulp'),
|
||||||
whitespace = require('gulp-whitespace'),
|
whitespace = require('gulp-whitespace'),
|
||||||
merge = require('merge-stream'),
|
merge = require('merge-stream'),
|
||||||
del = require('del'),
|
del = require('del'),
|
||||||
zip = require('gulp-zip'),
|
extend = require('extend'),
|
||||||
|
fs = require('fs'),
|
||||||
gitty = require('gitty'),
|
gitty = require('gitty'),
|
||||||
fs = require('fs');
|
zip = require('gulp-zip');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Options
|
* Options
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// Require the __options object before preprocessing, so we have access to the
|
||||||
|
// version number and can make amendments, e.g. the release date.
|
||||||
|
var options = require('./src/options.js');
|
||||||
|
|
||||||
// Options to be used in Prepro.js preprocessing through the global __options
|
// Options to be used in Prepro.js preprocessing through the global __options
|
||||||
// object.
|
// object.
|
||||||
var buildOptions = {
|
var buildOptions = {
|
||||||
|
@ -66,13 +71,12 @@ function git(param) {
|
||||||
return new gitty.Command(gitRepo, operation, args).execSync().trim();
|
return new gitty.Command(gitRepo, operation, args).execSync().trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
var gitDate = git('log -1 --pretty=format:%ad');
|
// Get the date of the last commit from this branch for release date:
|
||||||
var gitVersion = git('describe --abbrev=0 --tags');
|
options.date = git('log -1 --pretty=format:%ad');
|
||||||
var gitBranch = git('rev-parse --abbrev-ref HEAD');
|
// If we're not on the master branch, append the branch name to the version:
|
||||||
if (gitBranch !== 'master')
|
var branch = git('rev-parse --abbrev-ref HEAD');
|
||||||
gitVersion += '-' + gitBranch;
|
if (branch !== 'master')
|
||||||
|
options.version += '-' + branch;
|
||||||
gulp.task('nop');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Task: default
|
* Task: default
|
||||||
|
@ -148,15 +152,17 @@ buildNames.forEach(function(name) {
|
||||||
gulp.task('build:' + name, ['build:start'], function() {
|
gulp.task('build:' + name, ['build:start'], function() {
|
||||||
return gulp.src('src/paper.js')
|
return gulp.src('src/paper.js')
|
||||||
.pipe(prepro({
|
.pipe(prepro({
|
||||||
evaluate: ['src/constants.js', 'src/options.js'],
|
// Evaluate constants.js inside the precompilation scope before
|
||||||
|
// the actual precompilation, so all the constants substitution
|
||||||
|
// statements in the code can work (look for: /*#=*/):
|
||||||
|
evaluate: ['src/constants.js'],
|
||||||
setup: function() {
|
setup: function() {
|
||||||
var options = buildOptions[name];
|
// Return objects to be defined in the preprocess-scope.
|
||||||
options.version = gitVersion;
|
// Note that this would be merge in with already existing
|
||||||
options.date = gitDate;
|
// objects.
|
||||||
// This object will be merged into the Prepro.js VM scope,
|
return {
|
||||||
// which already holds a __options object from the above
|
__options: extend({}, options, buildOptions[name])
|
||||||
// include statement.
|
};
|
||||||
return { __options: options };
|
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
.pipe(uncomment({
|
.pipe(uncomment({
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"del": "^2.2.0",
|
"del": "^2.2.0",
|
||||||
|
"extend": "^3.0.0",
|
||||||
"gitty": "^3.3.3",
|
"gitty": "^3.3.3",
|
||||||
"gulp": "^3.9.0",
|
"gulp": "^3.9.0",
|
||||||
"gulp-prepro": "^2.0.0",
|
"gulp-prepro": "^2.0.0",
|
||||||
|
|
39
src/load.js
39
src/load.js
|
@ -14,6 +14,11 @@
|
||||||
// the browser, avoiding the step of having to manually preprocess it after each
|
// the browser, avoiding the step of having to manually preprocess it after each
|
||||||
// change. This is very useful during development of the library itself.
|
// change. This is very useful during development of the library itself.
|
||||||
if (typeof window === 'object') {
|
if (typeof window === 'object') {
|
||||||
|
/* jshint -W082 */
|
||||||
|
function load(src) {
|
||||||
|
document.write('<script src="' + src + '"></script>');
|
||||||
|
}
|
||||||
|
|
||||||
// Browser based loading through Prepro.js:
|
// Browser based loading through Prepro.js:
|
||||||
if (!window.include) {
|
if (!window.include) {
|
||||||
var scripts = document.getElementsByTagName('script');
|
var scripts = document.getElementsByTagName('script');
|
||||||
|
@ -24,29 +29,29 @@ if (typeof window === 'object') {
|
||||||
var root = src.match(/^(.*\/)\w*\//)[1];
|
var root = src.match(/^(.*\/)\w*\//)[1];
|
||||||
// First load the prepro's browser.js file, which provides the include()
|
// First load the prepro's browser.js file, which provides the include()
|
||||||
// function for the browser.
|
// function for the browser.
|
||||||
document.write('<script type="text/javascript" src="' + root
|
load(root + 'node_modules/prepro/lib/browser.js');
|
||||||
+ 'node_modules/prepro/lib/browser.js"></script>');
|
// Now that we will have window.include() through browser.js, trigger
|
||||||
// Now that we have include(), load this file again, which will execute
|
// the loading of this file again, which will execute the lower part of
|
||||||
// the lower part of the code the 2nd time around.
|
// the code the 2nd time around.
|
||||||
document.write('<script type="text/javascript" src="' + root
|
load(root + 'src/load.js');
|
||||||
+ 'src/load.js"></script>');
|
|
||||||
} else {
|
} else {
|
||||||
include('options.js');
|
include('options.js');
|
||||||
include('paper.js');
|
include('paper.js');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Node based loading through Prepro.js:
|
// Node.js based loading through Prepro.js:
|
||||||
var prepro = require('prepro/lib/node.js');
|
var prepro = require('prepro/lib/node.js'),
|
||||||
// Include deafult browser options.
|
// Load the default browser-based options for further amendments.
|
||||||
// Step out and back into src in case this is loaded from dist/paper-node.js
|
// Step out and back into src, if this is loaded from dist/paper-node.js
|
||||||
prepro.include('../src/options.js');
|
options = require('../src/options.js');
|
||||||
// Override node specific options.
|
// Override Node.js specific options.
|
||||||
|
options.version += '-load';
|
||||||
|
options.environment = 'node';
|
||||||
|
options.load = true;
|
||||||
prepro.setup(function() {
|
prepro.setup(function() {
|
||||||
// This object will be merged into the Prepro.js VM scope, which already
|
// Return objects to be defined in the preprocess-scope.
|
||||||
// holds a __options object from the above include statement.
|
// Note that this would be merge in with already existing objects.
|
||||||
return {
|
return { __options: options };
|
||||||
__options: { environment: 'node' }
|
|
||||||
};
|
|
||||||
});
|
});
|
||||||
// Load Paper.js library files.
|
// Load Paper.js library files.
|
||||||
prepro.include('../src/paper.js');
|
prepro.include('../src/paper.js');
|
||||||
|
|
|
@ -14,12 +14,24 @@
|
||||||
// browser based compile-time preprocessing when loading the separate source
|
// browser based compile-time preprocessing when loading the separate source
|
||||||
// files directly through load.js / Prepro.js during development.
|
// files directly through load.js / Prepro.js during development.
|
||||||
|
|
||||||
|
// The paper.js version.
|
||||||
|
// NOTE: Adjust value here before calling publish.sh, which then updates and
|
||||||
|
// publishes the various JSON package files automatically.
|
||||||
|
var version = '0.9.25';
|
||||||
|
// If this file is loaded in the browser, we're in load.js mode.
|
||||||
|
var load = typeof window === 'object';
|
||||||
|
|
||||||
var __options = {
|
var __options = {
|
||||||
version: 'dev',
|
version: version + (load ? '-load' : ''),
|
||||||
environment: 'browser',
|
environment: 'browser',
|
||||||
|
load: load,
|
||||||
parser: 'acorn',
|
parser: 'acorn',
|
||||||
svg: true,
|
svg: true,
|
||||||
booleanOperations: true,
|
booleanOperations: true,
|
||||||
nativeContains: false,
|
nativeContains: false,
|
||||||
paperScript: true
|
paperScript: true
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Export for use in Gulp.js
|
||||||
|
if (typeof module !== 'undefined')
|
||||||
|
module.exports = __options;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*!
|
/*!
|
||||||
* Paper.js *#=* __options.version - The Swiss Army Knife of Vector Graphics Scripting.
|
* Paper.js v*#=* __options.version - The Swiss Army Knife of Vector Graphics Scripting.
|
||||||
* http://paperjs.org/
|
* http://paperjs.org/
|
||||||
*
|
*
|
||||||
* Copyright (c) 2011 - 2016, Juerg Lehni & Jonathan Puckey
|
* Copyright (c) 2011 - 2016, Juerg Lehni & Jonathan Puckey
|
||||||
|
@ -36,11 +36,11 @@ var paper = new function(undefined) {
|
||||||
// Inline Straps.js core (the Base class) inside the paper scope first:
|
// Inline Straps.js core (the Base class) inside the paper scope first:
|
||||||
/*#*/ include('../bower_components/straps/straps.js', { exports: false });
|
/*#*/ include('../bower_components/straps/straps.js', { exports: false });
|
||||||
|
|
||||||
/*#*/ if (__options.version == 'dev' && __options.environment == 'browser') {
|
/*#*/ if (__options.load && __options.environment == 'browser') {
|
||||||
/*#*/ include('../bower_components/stats.js/build/stats.min.js');
|
/*#*/ include('../bower_components/stats.js/build/stats.min.js');
|
||||||
/*#*/ }
|
/*#*/ }
|
||||||
|
|
||||||
/*#*/ if (__options.version == 'dev') {
|
/*#*/ if (__options.load) {
|
||||||
/*#*/ include('constants.js');
|
/*#*/ include('constants.js');
|
||||||
/*#*/ }
|
/*#*/ }
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ var paper = new function(undefined) {
|
||||||
|
|
||||||
/*#*/ include('canvas/CanvasProvider.js');
|
/*#*/ include('canvas/CanvasProvider.js');
|
||||||
/*#*/ include('canvas/BlendMode.js');
|
/*#*/ include('canvas/BlendMode.js');
|
||||||
/*#*/ if (__options.version == 'dev') {
|
/*#*/ if (__options.load) {
|
||||||
/*#*/ include('canvas/ProxyContext.js');
|
/*#*/ include('canvas/ProxyContext.js');
|
||||||
/*#*/ }
|
/*#*/ }
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue