Upgrade to ExtJS 4.0.1 - Released 05/18/2011
[extjs.git] / jsbuilder / src / generators / app / Application.js
1 /**
2  * @class Ext.generator.Application
3  * @extends Ext.generator.Base
4  * Generates a full application
5  */
6 Ext.generator.Application = Ext.extend(Ext.generator.Base, {
7     generate: function() {
8         this.headline('Generating the ' + this.name + ' application');
9         
10         this.createDirectoryStructure();
11         this.copyApplicationFiles();
12         this.copyJasmine();
13         this.copyJSBuilder();
14     },
15     
16     /**
17      * Copies all files required for jasmine to the lib directory
18      */
19     copyJasmine: function() {
20         Logger.log("Copying dependencies...");
21         
22         this.mkdir('lib/jasmine', 'lib/sencha-jasmine', 'lib/sencha-jasmine/matchers');
23         
24         this.file('lib/jasmine/jasmine.css');
25         this.file('lib/jasmine/jasmine-html.js');
26         this.file('lib/jasmine/jasmine.js');
27         this.file('lib/jasmine/MIT.LICENSE');
28         
29         this.file('lib/sencha-jasmine/sencha-jasmine.css');
30         this.file('lib/sencha-jasmine/sencha-jasmine.js');
31         this.file('lib/sencha-jasmine/matchers/Model.js');
32         this.file('lib/sencha-jasmine/matchers/Controller.js');
33     },
34     
35     /**
36      * Copies all static application files to their destination directories
37      */
38     copyApplicationFiles: function() {
39         Logger.log("Copying files...");
40         
41         this.file('index.html');
42         this.file('app/routes.js');
43         this.file('public/resources/css/application.css');
44         this.file('test/unit/index.html');
45         this.file('test/unit/SpecOptions.js');
46         this.file('test/unit/.htaccess');
47         
48         this.template('Application', this, "app/app.js");
49         this.template('Viewport', this, "app/views/Viewport.js");
50     },
51     
52     /**
53      * Creates all of the necessary directories for a new app
54      */
55     createDirectoryStructure: function() {
56         Logger.log("Creating directories...");
57         this.mkdir(
58             'app', 'app/models', 'app/controllers', 'app/views', 'lib', 
59             'public', 'public/resources/images', 'public/resources/css',
60             'test', 'test/acceptance', 'test/fixtures', 'test/unit',
61             'test/unit/models', 'test/unit/controllers', 'test/unit/views'
62         );
63     },
64     
65     /**
66      * Copies all files/folders required for JSBuilder into the lib directory
67      */
68     copyJSBuilder: function() {
69         Logger.log("Copying JSBuilder");
70         this.mkdir("lib/JSBuilder", "lib/JSBuilder/bin");
71         this.file("lib/JSBuilder/bin/Dispatch.js");
72         
73         var builderDirs = ['bin', 'jsdb', 'src', 'tests', 'ycompressor'],
74             length      = builderDirs.length,
75             i;
76         
77         for (i = 0; i < length; i++) {
78             this.copyDir(builderDirs[i], "lib/JSBuilder");
79         }
80         
81         Logger.log("    Copying JSBuilder files");
82         this.file("sencha.sh");
83     },
84     
85     decodeArgs: function(args) {
86         this.name = args[0];
87         this.basePath = args[1] || this.name;
88     }
89 });
90
91 Ext.regGenerator('app', Ext.generator.Application);