1. #1
    Ext JS Premium Member
    Join Date
    Mar 2009
    Posts
    47
    Vote Rating
    1
    uzver is on a distinguished road

      0  

    Default Get Ext.Loader.history via Node.js

    Get Ext.Loader.history via Node.js


    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 = {
        
    navigatornavigator,
        
    attachEvent: function() {
        }
    }
    top = {
    }

    require(
    appDir '/vendor/extjs/ext-core.js')
    //stub Ext.EventManager
    Ext.EventManager.un = function () {
    }
    //set loader
    Ext.Loader.setConfig({
        
    enabledtrue,
        
    paths: {
            
    'Ext'    'vendor/extjs/src',
            
    'app'    'app'
        
    }
    });
    //override loadScriptFile for Loader
    Ext.Loader.loadScriptFile = function(urlonLoadonErrorscopesynchronous) {
        
    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 == && 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(thisarguments);
    };
    //load main js app file
    require(appDir '/app/app.js'); 
    Usage:
    Code:
    nodejs script.js project_dir/public

  2. #2
    Sencha User
    Join Date
    Jan 2009
    Posts
    2
    Vote Rating
    0
    crisp is on a distinguished road

      0  

    Default


    I'm trying to run this on 4.0.7 on Mac Os Nodejs and I'me getting the following error:

    Code:
    node.js:134
    throw e; // process.nextTick error, or 'error' event on first tick
    ^
    TypeError: Cannot read property 'protocol' of undefined
    at /Users/crisp/Sites/extplay/js/ext/ext-dev.js:9324:50
    at Object.<anonymous> (/Users/crisp/Sites/extplay/js/ext/ext-dev.js:10125:2)
    at Module._compile (module.js:402:26)
    at Object..js (module.js:408:10)
    at Module.load (module.js:334:31)
    at Function._load (module.js:293:12)
    at require (module.js:346:19)
    at Object.<anonymous> (/Users/crisp/Sites/extplay/build.js:28:1)
    at Module._compile (module.js:402:26)
    at Object..js (module.js:408:10)
    What version of ext are you running ?

  3. #3
    Ext JS Premium Member
    Join Date
    Mar 2009
    Posts
    47
    Vote Rating
    1
    uzver is on a distinguished road

      0  

    Default


    Adopted for extjs v4.0.7 and nodejs v0.6.2

    https://gist.github.com/1416405

Thread Participants: 1