-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Share build process found in [emberjs/emberjs-build][1] * Easiest approach was to copy paste from [emberjs/ember.js][2] * In the long term, we should move common build tasks / setup to [emberjs/emberjs-build][1] * Vendor `ember-inflector` ES6 package Silence Deprecations * Use `container._registry.has` instead of `container.has` * Use `env.registry` instead of `store.container` [1]: https://github.com/emberjs/emberjs-build [2]: https://github.com/emberjs/ember.js * Resolve JSCS infractions * Move `package-manager-files` for `emberjs-build` * Pass Bower Funnels into emberjs-build * Run appveyor against node `0.10`
- Loading branch information
1 parent
5887afe
commit baef116
Showing
28 changed files
with
344 additions
and
451 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,199 +1,28 @@ | ||
/* jshint node: true */ | ||
|
||
var es6 = require('broccoli-es6-module-transpiler'); | ||
var PackageResolver = require('es6-module-transpiler-package-resolver'); | ||
var concat = require('broccoli-concat'); | ||
var uglify = require('broccoli-uglify-js'); | ||
var es3SafeRecast = require('broccoli-es3-safe-recast'); | ||
var env = process.env.EMBER_ENV; | ||
var amdBuild = require('./lib/amd-build'); | ||
var pickFiles = require('broccoli-static-compiler'); | ||
var merge = require('broccoli-merge-trees'); | ||
var moveFile = require('broccoli-file-mover'); | ||
var wrap = require('broccoli-wrap'); | ||
var jshint = require('broccoli-jshint'); | ||
var defeatureify = require('broccoli-defeatureify'); | ||
var version = require('git-repo-version')(10); | ||
var yuidoc = require('broccoli-yuidoc'); | ||
var replace = require('broccoli-replace'); | ||
var stew = require('broccoli-stew'); | ||
var path = require('path'); | ||
var fs = require('fs'); | ||
var jscsTree = require('broccoli-jscs'); | ||
|
||
function minify(tree, name){ | ||
var config = require('./config/ember-defeatureify'); | ||
tree = defeatureify(tree, { | ||
debugStatements: config.options.debugStatements, | ||
enableStripDebug: config.stripDebug | ||
}); | ||
tree = moveFile(tree, { | ||
srcFile: name + '.js', | ||
destFile: '/' + name + '.prod.js' | ||
}); | ||
tree = removeSourceMappingURL(tree); | ||
var uglified = moveFile(uglify(tree, {mangle: true}),{ | ||
srcFile: name + '.prod.js', | ||
destFile: '/' + name + '.min.js' | ||
}); | ||
return merge([uglified, tree], {overwrite: true}); | ||
} | ||
|
||
function testTree(packageName){ | ||
var test = pickFiles('packages/' + packageName + '/tests', { | ||
srcDir: '/', | ||
files: [ '**/*.js' ], | ||
destDir: '/' + packageName | ||
}); | ||
var jshinted = jshint('packages/' + packageName + '/', { | ||
jshintrcPath: path.join(__dirname, '.jshintrc') | ||
}); | ||
jshinted = wrap(jshinted, { | ||
wrapper: [ "if (!QUnit.urlParams.nojshint) {\n", "\n}"], | ||
}); | ||
jshinted = pickFiles(jshinted, { | ||
files: ['{lib,tests}/**/*.js'], | ||
srcDir: '/', | ||
destDir: '/' + packageName + '-jshint' | ||
}); | ||
return merge([jshinted, test]); | ||
} | ||
|
||
var yuidocTree = yuidoc('packages', { | ||
srcDir: '/', | ||
destDir: 'docs', | ||
yuidoc: { | ||
"name": "The ember-data API", | ||
"description": "The ember-data API: a data persistence library for Ember.js", | ||
"version": version, | ||
"logo": "http://f.cl.ly/items/1A1L432s022u1O1q1V3p/ember%20logo.png", | ||
"url": "https://github.com/emberjs/data", | ||
"options": { | ||
"paths": [ | ||
"packages/ember-data/lib", | ||
"packages/activemodel-adapter/lib", | ||
"packages/ember-inflector/addon" | ||
], | ||
"exclude": "vendor", | ||
"outdir": "docs/build" | ||
} | ||
// To create fast production builds (without ES3 support, minification, derequire, or JSHint) | ||
// run the following: | ||
// | ||
// DISABLE_ES3=true DISABLE_JSCS=true DISABLE_JSHINT=true DISABLE_MIN=true DISABLE_DEREQUIRE=true ember serve --environment=production | ||
|
||
var EmberBuild = require('emberjs-build'); | ||
var packages = require('./lib/packages'); | ||
var vendoredPackage = require('emberjs-build/lib/vendored-package'); | ||
var vendoredES6Package = require('emberjs-build/lib/es6-vendored-package'); | ||
|
||
var emberBuild = new EmberBuild({ | ||
name: 'ember-data', | ||
namespace: 'DS', | ||
packages: packages, | ||
skipTemplates: true, | ||
skipRuntime: true, | ||
vendoredPackages: { | ||
'loader': vendoredPackage('loader'), | ||
'ember-inflector': vendoredES6Package('ember-inflector', { | ||
libPath: 'bower_components/ember-inflector/packages/ember-inflector/lib', | ||
destDir: '/ember-inflector' | ||
}) | ||
} | ||
}); | ||
|
||
// Excludes tests files from package path | ||
function package(packagePath, vendorPath) { | ||
vendorPath = vendorPath || 'packages/'; | ||
return pickFiles(vendorPath + packagePath, { | ||
files: [ 'lib/**/*.js' ], | ||
srcDir: '/', | ||
destDir: '/' + packagePath | ||
}); | ||
} | ||
|
||
function packageAddon(packagePath, vendorPath) { | ||
return stew.rename(pickFiles(vendorPath + packagePath, { | ||
files: [ '**/*.js' ], | ||
srcDir: '/addon', | ||
destDir: '/' + packagePath + '/lib' | ||
}), 'index.js', 'main.js'); | ||
} | ||
|
||
var packages = merge([ | ||
packageAddon('ember-inflector', 'node_modules/'), | ||
package('ember-data'), | ||
package('activemodel-adapter'), | ||
package('ember') | ||
]); | ||
|
||
var globalBuild; | ||
|
||
// Bundle formatter for smaller payload | ||
if (env === 'production') { | ||
globalBuild = es6(packages, { | ||
inputFiles: ['ember-data'], | ||
output: '/ember-data.js', | ||
resolvers: [PackageResolver], | ||
formatter: 'bundle' | ||
}); | ||
} else { | ||
// Use AMD for faster rebuilds in dev | ||
globalBuild = amdBuild(packages); | ||
} | ||
|
||
var testFiles = merge([ | ||
testTree('ember-data'), | ||
testTree('activemodel-adapter') | ||
]); | ||
|
||
if (env === 'production'){ | ||
testFiles = es3SafeRecast(testFiles); | ||
} | ||
|
||
testFiles = concat(testFiles, { | ||
inputFiles: ['**/*.js'], | ||
separator: '\n', | ||
wrapInEval: true, | ||
wrapInFunction: true, | ||
outputFile: '/ember-data-tests.js' | ||
}); | ||
|
||
var testRunner = pickFiles('tests', { | ||
srcDir: '/', | ||
files: [ '**/*' ], | ||
destDir: '/' | ||
}); | ||
|
||
var bower = pickFiles('bower_components', { | ||
srcDir: '/', | ||
destDir: '/bower_components' | ||
}); | ||
|
||
var configurationFiles = pickFiles('config/package-manager-files', { | ||
srcDir: '/', | ||
destDir: '/', | ||
files: [ '**/*.json' ] | ||
}); | ||
|
||
function versionStamp(tree) { | ||
return replace(tree, { | ||
files: ['**/*'], | ||
patterns: [{ | ||
match: /VERSION_STRING_PLACEHOLDER/g, | ||
replacement: version | ||
}] | ||
}); | ||
} | ||
|
||
function removeSourceMappingURL(tree) { | ||
return replace(tree, { | ||
files: ['**/*'], | ||
patterns: [{ | ||
match: /\/\/(.*)sourceMappingURL=(.*)/g, | ||
replacement: '' | ||
}] | ||
}); | ||
} | ||
|
||
configurationFiles = versionStamp(configurationFiles); | ||
|
||
var jscsFiles = jscsTree("packages"); | ||
|
||
var trees = [ | ||
testFiles, | ||
testRunner, | ||
bower, | ||
configurationFiles, | ||
jscsFiles | ||
]; | ||
|
||
if (env === 'production') { | ||
globalBuild = versionStamp(globalBuild); | ||
globalBuild = es3SafeRecast(globalBuild); | ||
var minifiedGlobals = minify(globalBuild, 'ember-data'); | ||
trees.push(yuidocTree); | ||
trees.push(minifiedGlobals); | ||
} | ||
|
||
trees.push(globalBuild); | ||
|
||
module.exports = merge(trees, {overwrite: true}); | ||
module.exports = emberBuild.getDistTrees(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
#!/usr/bin/env node | ||
|
||
var RSVP = require('rsvp'); | ||
var spawn = require('child_process').spawn; | ||
var chalk = require('chalk'); | ||
var packages = require('../lib/packages'); | ||
var runInSequence = require('../lib/run-in-sequence'); | ||
|
||
function shouldPrint(inputString) { | ||
var skipStrings = [ | ||
"*** WARNING: Method userSpaceScaleFactor", | ||
"CoreText performance note:", | ||
]; | ||
|
||
for (var i = 0; i < skipStrings.length; i++) { | ||
if (inputString.indexOf(skipStrings[i])) { | ||
return false; | ||
} | ||
} | ||
|
||
return true; | ||
} | ||
|
||
function run(queryString) { | ||
return new RSVP.Promise(function(resolve, reject) { | ||
var args = [ | ||
'bower_components/qunit-phantom-runner/runner.js', | ||
'./dist/tests/index.html?' + queryString | ||
]; | ||
|
||
console.log('Running: phantomjs ' + args.join(' ')); | ||
|
||
var child = spawn('phantomjs', args); | ||
var result = {output: [], errors: [], code: null}; | ||
|
||
child.stdout.on('data', function (data) { | ||
var string = data.toString(); | ||
var lines = string.split('\n'); | ||
|
||
lines.forEach(function(line) { | ||
if (line.indexOf('0 failed.') > -1) { | ||
console.log(chalk.green(line)); | ||
} else { | ||
console.log(line); | ||
} | ||
}); | ||
result.output.push(string); | ||
}); | ||
|
||
child.stderr.on('data', function (data) { | ||
var string = data.toString(); | ||
|
||
if (shouldPrint(string)) { | ||
result.errors.push(string); | ||
console.error(chalk.red(string)); | ||
} | ||
}); | ||
|
||
child.on('close', function (code) { | ||
result.code = code; | ||
|
||
if (code === 0) { | ||
resolve(result); | ||
} else { | ||
reject(result); | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
var testFunctions = []; | ||
var emberChannel = process.env.EMBER_CHANNEL || 'release'; | ||
var runnningInCI = process.env.CI || false; | ||
|
||
testFunctions.push(function() { | ||
return run('emberchannel=' + emberChannel); | ||
}); | ||
|
||
if (runnningInCI) { | ||
testFunctions.push(function() { | ||
return run('dist=min&emberchannel=' + emberChannel); | ||
}); | ||
testFunctions.push(function() { | ||
return run('dist=prod&emberchannel=' + emberChannel); | ||
}); | ||
} | ||
|
||
runInSequence(testFunctions) | ||
.then(function() { | ||
console.log(chalk.green('Passed!')); | ||
process.exit(0); | ||
}) | ||
.catch(function(e) { | ||
console.error(e); | ||
console.error(chalk.red('Failed!')); | ||
process.exit(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.