Hybrid View

  1. #1
    Ext JS Premium Member
    Join Date
    Sep 2010
    Posts
    365
    Vote Rating
    6
    stewardsencha is on a distinguished road

      0  

    Default Ordering output. Send licence blurb to the top of the file. How to?

    Ordering output. Send licence blurb to the top of the file. How to?


    RE http://docs.sencha.com/ext-js/4-2/#!...mmand_compiler


    A compiler ultimately is all about writing useful output given some number of inputs. The concat command is designed to concatenate the source for the current set of files in the appropriate dependency order.


    The one required parameter is -out, which indicates the name of the output file. There are other options, however, that effect the generated file. You can pick one of the following options for compression:

    I am trying to achieve the "appropriate dependency order". The docs go on to talk about sets. Not how to order those sets?


    The one required parameters is not present ?!! Is this is a doc error, is the one required parameter is concat ?


    I find nothing else on the page that talks about controlling the order.


    Seems to me in the prior version of Cmd, output followed the same order as the comma delimited list of classpaths. Or it did for me!


    But not now?


    Code:
    $ cat alpha/alpha.js
    alert('alpha');
    
    
    $ cat beta/beta.js
    alert('beta');
    
    
    $ sencha compile -classpath=alpha,beta concat ab.js
    Sencha Cmd v3.1.0.216
    [INF] Scanning for extensions in /Users/steward/bin/Sencha/Cmd/3.1.0.216/extensions
    [INF] Loaded extension sencha-compass
    [INF] Loaded extension sencha-io
    [INF] Loading classpath entry /home/steward/public_html/alpha
    [INF] Loading classpath entry /home/steward/public_html/beta
    [INF] Concatenating output to file ab.js
    
    
    $ cat ab.js
    alert('alpha');
    alert('beta');
    
    
    $ sencha compile -classpath=beta,alpha concat ba.js
    Sencha Cmd v3.1.0.216
    [INF] Scanning for extensions in /Users/steward/bin/Sencha/Cmd/3.1.0.216/extensions
    [INF] Loaded extension sencha-compass
    [INF] Loaded extension sencha-io
    [INF] Loading classpath entry /home/steward/public_html/beta
    [INF] Loading classpath entry /home/steward/public_html/alpha
    [INF] Concatenating output to file ba.js
    
    
    $ cat ba.js
    alert('alpha');
    alert('beta');

    Just out of curiosity, why are both outputs the same? There is nothing to distinguish order except the order in which they were encountered?


    I want my license verbiage at the start of the output. How to?


    I return to http://docs.sencha.com/ext-js/4-2/#!...and_app_single


    "These dependencies are expressed in code using Ext.define and the requires (or uses) directives."

    So I add to my app:
    Code:
    Ext.require('Yap.blurb.License')
    I verify the file loads normally, refresh the project...

    Aw heck. I have the feeling I am wandering into deep space.

    Is this something we are to control in the build/xml/ant part?

    What have I missed? Where in the docs? Have I misinterpeted the statement about "appropriate dependcy order". I just want order!

    As the man on the Titantic shouted before he shot himself, "Order I say!"

    Help. Please. Thank you.

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,347
    Vote Rating
    846
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    The order of files included should be determined by Cmd based on your requires statements.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Ext JS Premium Member
    Join Date
    Sep 2010
    Posts
    365
    Vote Rating
    6
    stewardsencha is on a distinguished road

      0  

    Default


    Aw cmon

    Two js files. Concatenate them in a specific order.

    Without dragging in the rest of the world, cooking supper, organizing a union and and calling china.

    "The one required parameter is out". Which is not shown in the example.

    I had it working in an older version. Here I am guessing again.

    A license blurb is not a component to be required. In fact I generate it:

    Code:
        <!-- dsm 5 apr 13
            Sets the DSTAMP, TSTAMP, and TODAY properties in the current project
            http://ant.apache.org/manual/Tasks/tstamp.html
        -->
        <tstamp >
           <format property="TODAY_BLURB" pattern="EEE, d MMM yyyy HH:mm:ss Z" />
        </tstamp>
    
    
        <!--
            dsm 5 apr 13
            Create a blurb with todays' date/time stamp
        -->
        <target name="blurb" description="Write blurb to startup.js">
    <echo file="${app.dir}/startup/blurb.js">/**
     * (c) Copyright 2013 steward. All Rights Reserved.
     *     Generated for my.site.com on ${TODAY_BLURB}
     */
    </echo>
        </target>
    I guess I should be at the Apache Ant site instead of here.

    But I understand the concepts, I'm just annoyed at constantly playing and guessing the syntax. I am trolling for samples. Simple examples.

    Please!

  4. #4
    Ext JS Premium Member
    Join Date
    Sep 2010
    Posts
    365
    Vote Rating
    6
    stewardsencha is on a distinguished road

      0  

    Default


    Maybe this is a better question.

    Can anybody translate this

    Code:
        <!--
            The order files are listed here is the honest to god order of the concatenated output
        -->
        <target name="final"  description="">
            <concat destfile="test">
                <filelist dir="startup"
                    files="blurb.js"/>
                <filelist dir="${build.dir}"
                    files="${build.classes.name}"/>
            </concat>
        </target>
    into a sencha compile concat out something statement.
    I seem to have a gap in my head that prevents me from getting it right.

    Unless I am confused, I have this notion:

    The classpath contains many files.

    Excluding them by namespace and tags etc is okay but tedious when it would be faster to go the other way around: I only want to deal with two files.

    Perhaps what I want to do it override the classpath for a single compile statement: shrink my universe.

    I think I can do this easily outside the project. But that ultimately won't be useful.

    The docs fail for me at this point. I have read them nineteen times over two months. Why is it they are no good for reference? Because they lack the series of simple examples (cf Apache Ant pages).

  5. #5
    Ext JS Premium Member burnnat's Avatar
    Join Date
    Jun 2011
    Posts
    418
    Vote Rating
    61
    burnnat is a jewel in the rough burnnat is a jewel in the rough burnnat is a jewel in the rough burnnat is a jewel in the rough

      0  

    Default


    If all you want to do is concatenate two files, couldn't you use the "sencha fs concat" command?

    For example:
    Code:
    sencha fs concat -to=output.js input1.js input2.js

  6. #6
    Ext JS Premium Member
    Join Date
    Sep 2010
    Posts
    365
    Vote Rating
    6
    stewardsencha is on a distinguished road

      0  

    Default


    Quote Originally Posted by burnnat View Post
    If all you want to do is concatenate two files, couldn't you use the "sencha fs concat" command?

    For example:
    Code:
    sencha fs concat -to=output.js input1.js input2.js

    Because I didn't spot it, because I had a different notion in my head, and because initial tests got me nothing but error messages.



    The correct command line for 3.1.0.256 is

    sencha fs concat -to c.js -from b.js, a.js

    and it works great. Thank you very much for your reply.

  7. #7
    Sencha - Ext JS Dev Team dongryphon's Avatar
    Join Date
    Jul 2009
    Posts
    1,367
    Vote Rating
    136
    dongryphon is a splendid one to behold dongryphon is a splendid one to behold dongryphon is a splendid one to behold dongryphon is a splendid one to behold dongryphon is a splendid one to behold dongryphon is a splendid one to behold

      0  

    Default


    Quote Originally Posted by stewardsencha View Post
    Unless I am confused, I have this notion:

    The classpath contains many files.

    Excluding them by namespace and tags etc is okay but tedious when it would be faster to go the other way around: I only want to deal with two files.
    The compiler is fundamentally about ordering of files based on dependencies that exist between them but also removing "anomalies" like the order in which the OS lists directories (for example a "*.js" listing or sub-folder order, etc.). These anomalies can cause serious cache and performance problems when "delta-patching" Sencha Touch applications.

    The heart of that algorithm is based on http://en.wikipedia.org/wiki/Topological_sorting which is a fancy way to say that unless the two files have an explicit order specified between them, any order is valid. Stated another way: the classpath is not an ordered sequence in itself - it is an unordered set of files. The final order of the files is determined by the relationships internal to those files (as Mitchell pointed out).

    So, if file B.js must follow file A.js and you are not using Ext.define/requires to specify the relationship, you can do this in B.js

    Code:
       //@require A.js
       alert('beta');
    I am not sure how (or if) this kind of simple example works in a development (non-build) scenario or if you care about that.

    Quote Originally Posted by stewardsencha View Post
    The docs fail for me at this point. I have read them nineteen times over two months. Why is it they are no good for reference? Because they lack the series of simple examples (cf Apache Ant pages).
    Thanks for the feedback there - I will try to factor that in to the next iteration of updates.
    Don Griffin
    Ext JS Development Team Lead

    Check the docs. Learn how to (properly) report a framework issue and a Sencha Cmd issue

    "Use the source, Luke!"

  8. #8
    Ext JS Premium Member
    Join Date
    Sep 2010
    Posts
    365
    Vote Rating
    6
    stewardsencha is on a distinguished road

      0  

    Default


    // require A.js
    That is the answer I was sorta expecting I guess.

    What happened is that I had problems building (still do) and found that I could release by compiling only.

    In some earlier version it so happened that the classpath determined the order of inclusion. Guess I leaned on that.

    I grok your viewpoint. By using requires we get the depencies ordered within a (terminology here page? workspace? temporary snapsot?). But a next step in the build is to string those together.

    I think that was done in the past by ordering script tags in the markup.

    The examples in the docs are sparse and incorrect, and I am getting very old. That's all.

    Thank you both for responding. It helped.

  9. #9
    Ext JS Premium Member cmeans's Avatar
    Join Date
    Jun 2010
    Location
    Chicago, IL USA
    Posts
    112
    Vote Rating
    7
    cmeans is on a distinguished road

      3  

    Post


    We do it by using a modified build.xml, and include the blub there rather than in an external file.

    Here's the pertinent section to add (this works with Cmd v3.0.2.288...and earlier):

    Code:
         <target name="-after-page">
              <move file="${build.classes.file}"
                 tofile="${build.classes.file}.tmp"/>
    
              <concat destfile="${build.classes.file}">
                 <header filtering="no" trimleading="yes">
    /*
    Your blub here will be at the top of the all-classes.js file.
    */
                 </header>
                 <fileset file="${build.classes.file}.tmp"/>
              </concat>
              <delete file="${build.classes.file}.tmp" />
           </target>
    -Chris