I made simple nodejs script for getting app dependencies list. It's useful for backend server integration without using Sencha SDK(e.g. rails with jammit gem).
PHP Code:
var appDir = process.argv[2];
//emulate several browser objects for correct loading ext-core
navigator = {
userAgent: 'nodejs',
platform: 'linux'
}
//stub document
document = {
getElementsByTagName: function(tag) {
return [''];
},
attachEvent: function() {
},
documentElement: {
style: {
}
}
}
//stub window
window = {
navigator: navigator,
attachEvent: function() {
}
}
top = {
}
require(appDir + '/vendor/extjs/ext-core.js')
//stub Ext.EventManager
Ext.EventManager.un = function () {
}
//set loader
Ext.Loader.setConfig({
enabled: true,
paths: {
'Ext' : 'vendor/extjs/src',
'app' : 'app'
}
});
//override loadScriptFile for Loader
Ext.Loader.loadScriptFile = function(url, onLoad, onError, scope, synchronous) {
this.isLoading = true;
require(appDir + "/" + url.replace(/^\//, ""));
onLoad.call(scope);
}
//ovride triggerReady for exiting when loading process is completed
var tmp = Ext.Loader.triggerReady;
Ext.Loader.triggerReady = function() {
if(!this.completed && this.queue.length == 0 && this.optionalRequires.length == 0) {
var files = [];
this.history.forEach(function(val) {
files.push(Ext.Loader.getPath(val));
});
this.completed = true;
//return to console list of dependencies
console.log(files.join("\n"));
while (!process.stdout.flush());
process.exit(0);
}
tmp.apply(this, arguments);
};
//load main js app file
require(appDir + '/app/app.js');
Usage:
Code:
nodejs script.js project_dir/public