This repository has been archived by the owner on Jun 15, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build is now working with require -- for html and js files remove html stuff.. it was cool as fuck, but just doesn't make sense for ender tighten up depency copy and sex up codez git local file includes with file analysis working for non --modules flag i believe add is working again, but now with single files + analyzing... hoorays quick asdfasldkfj
- Loading branch information
Showing
8 changed files
with
414 additions
and
160 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/usr/bin/env node | ||
//adapted from node-jitsu's very excellent project require-analyzer | ||
//https://github.com/nodejitsu/require-analyzer | ||
|
||
var Module = require('module').Module | ||
, __load = Module._load | ||
, path = require('path') | ||
, packages = {}; | ||
|
||
// | ||
// Monkey punch `Module._load()` to observe the names | ||
// of packages as they are loaded. | ||
// | ||
Module._load = function (name, parent) { | ||
console.log('__!name::' + name); | ||
console.log('__!path::' + (/^[./]/.test(name) ? Module._resolveFilename(name, parent)[1] : name)); | ||
return __load.apply(Module, arguments); | ||
} | ||
|
||
try { | ||
process.nextTick(function () { | ||
process.exit(0); | ||
}); | ||
|
||
if (process.argv[3] === 'null') { | ||
Module._load(process.argv[2], null, true) | ||
} else { | ||
//simulate module loading with correct paths from content | ||
module = new Module(process.argv[2]); | ||
module.paths = Module._nodeModulePaths(path.dirname(module.filename)); | ||
module._compile(process.argv[3], process.argv[2]); | ||
} | ||
} | ||
catch (ex) { | ||
// | ||
// Log errors and attempt to log as many packages as we can. | ||
// | ||
var eStr = '' + (ex | ||
? (ex.stack ? ex.stack : ex) | ||
: 'falsey error: ' + ex) | ||
|
||
eStr.split('\n').forEach(function (line) { | ||
console.error('__!err::' + line); | ||
}); | ||
} |
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,104 @@ | ||
//adapted from node-jitsu's require-analyzer | ||
//analyzes js files for require statements | ||
//https://github.com/nodejitsu/require-analyzer | ||
|
||
var spawn = require('child_process').spawn | ||
, path = require('path') | ||
, CMD = require('./ender.cmd') | ||
, NPM = require('./ender.npm'); | ||
|
||
var analyzer = module.exports = function (target, content, callback) { | ||
console.log('analyzing ' + target + '...'); | ||
|
||
var packageNames = [] | ||
, packagePaths = [] | ||
, merged = {} | ||
, errs = ['The following error was encountered while trying to parse ' + target.yellow] | ||
, deps = spawn('node', [path.join(__dirname, '..', 'bin', 'find-dependencies'), target, content]); | ||
|
||
function parseLines(data, prefix, fn) { | ||
data = data.toString(); | ||
if (data !== '') { | ||
data.toString().split('\n').filter(function (line) { | ||
return line !== ''; | ||
}).forEach(function (line) { | ||
if (line.indexOf(prefix) !== -1) { | ||
line = line.replace(prefix, ''); | ||
fn(line); | ||
} | ||
}); | ||
} | ||
} | ||
|
||
deps.stdout.on('data', function (data) { | ||
parseLines(data, '__!name::', function (dep) { | ||
packageNames.push(dep); | ||
}); | ||
parseLines(data, '__!path::', function (dep) { | ||
packagePaths.push(dep); | ||
}); | ||
}); | ||
|
||
deps.stderr.on('data', function (data) { | ||
parseLines(data, '__!err::', function (line) { | ||
errs.push(line); | ||
}); | ||
}); | ||
|
||
var timeoutId = setTimeout(function () { | ||
deps.kill(); | ||
}, 5000); | ||
|
||
deps.on('exit', function () { | ||
clearTimeout(timeoutId); | ||
if (errs.length > 1) { | ||
var last = packageNames[packageNames.length - 1]; | ||
if (last && !/^[.\/]/.test(last)) { //is NPM package... | ||
console.log(('Pausing dependency analysis on ' + target).yellow); | ||
console.log('The dependency ' + last.red + ' could not be found...'); | ||
CMD.ask( | ||
'Would you like ender to install it [yes|no]?'.cyan, /(yes|no)/, function (data) { | ||
if (data === 'yes') { | ||
NPM.install([last], function () { | ||
analyzer(target, content, callback); | ||
}); | ||
} else { | ||
console.log('continuing without ' + target + '\'s dependencies...'); | ||
callback(null, [packageNames[0]], [packagePaths[0]]); | ||
} | ||
} | ||
); | ||
} else { | ||
askCallback(packageNames, packagePaths, target, callback); | ||
} | ||
} else { | ||
askCallback(packageNames, packagePaths, target, callback); | ||
} | ||
}); | ||
}; | ||
|
||
function askCallback (packageNames, packagePaths, target, callback) { | ||
|
||
if (packageNames.length > 1) { | ||
console.log(('The following dependencies were found for ' + target + ':').yellow) | ||
|
||
for (var head, i = 0, l = packageNames.length; i < l; i++) { | ||
head = i == (packageNames.length - 1) ? '└' : '├'; | ||
console.log(' - ' + packageNames[i]); | ||
} | ||
|
||
CMD.ask( | ||
'Would you like ender to include these in your ender build [yes|no]?'.cyan, /(yes|no)/, function (data) { | ||
if (data === 'yes') { | ||
callback(null, packageNames, packagePaths); | ||
} else { | ||
callback(null, [packageNames[0]], [packagePaths[0]]); | ||
} | ||
} | ||
); | ||
} else { | ||
callback(null, packageNames, packagePaths); | ||
} | ||
|
||
|
||
} |
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
Oops, something went wrong.