Skip to content
Browse files

Quick workaround for 2.0.1 final

Will find permanent workaround
  • Loading branch information...
1 parent 60ae49a commit 7453602cba54a066600773cfec63711bae4dc422 @mitchellsimoens mitchellsimoens committed May 22, 2012
Showing with 9,811 additions and 7 deletions.
  1. +4 −3 st/mvc/app/controller/Main.js
  2. +8 −4 st/mvc/app/view/Main.js
  3. +73 −0 st/mvc/sdk-2.0.1-rc-backup/command/sencha.js
  4. +314 −0 st/mvc/sdk-2.0.1-rc-backup/command/src/Cli.js
  5. +179 −0 st/mvc/sdk-2.0.1-rc-backup/command/src/Preprocessor.js
  6. +53 −0 st/mvc/sdk-2.0.1-rc-backup/command/src/log/formatter/Cli.js
  7. +7 −0 st/mvc/sdk-2.0.1-rc-backup/command/src/log/writer/Cli.js
  8. +71 −0 st/mvc/sdk-2.0.1-rc-backup/command/src/module/Abstract.js
  9. +428 −0 st/mvc/sdk-2.0.1-rc-backup/command/src/module/Application.js
  10. +316 −0 st/mvc/sdk-2.0.1-rc-backup/command/src/module/FileSystem.js
  11. +71 −0 st/mvc/sdk-2.0.1-rc-backup/command/src/module/Generate.js
  12. +156 −0 st/mvc/sdk-2.0.1-rc-backup/command/src/module/Manifest.js
  13. +61 −0 st/mvc/sdk-2.0.1-rc-backup/command/src/module/Package.js
  14. +82 −0 st/mvc/sdk-2.0.1-rc-backup/command/src/module/Project.js
  15. +22 −0 st/mvc/sdk-2.0.1-rc-backup/command/src/module/Test.js
  16. +66 −0 st/mvc/sdk-2.0.1-rc-backup/command/src/module/generate/App.js
  17. +1 −0 st/mvc/sdk-2.0.1-rc-backup/command/src/module/generate/App/.senchasdk.tpl
  18. +39 −0 st/mvc/sdk-2.0.1-rc-backup/command/src/module/generate/App/app.js.tpl
  19. +134 −0 st/mvc/sdk-2.0.1-rc-backup/command/src/module/generate/App/app.json.tpl
  20. +49 −0 st/mvc/sdk-2.0.1-rc-backup/command/src/module/generate/App/app/view/Main.js.tpl
  21. +76 −0 st/mvc/sdk-2.0.1-rc-backup/command/src/module/generate/App/index.html.tpl
  22. +126 −0 st/mvc/sdk-2.0.1-rc-backup/command/src/module/generate/App/packager.json.tpl
  23. BIN st/mvc/sdk-2.0.1-rc-backup/command/src/module/generate/App/resources/icons/Icon.png
  24. BIN st/mvc/sdk-2.0.1-rc-backup/command/src/module/generate/App/resources/icons/Icon@2x.png
  25. BIN st/mvc/sdk-2.0.1-rc-backup/command/src/module/generate/App/resources/icons/Icon~ipad.png
  26. BIN st/mvc/sdk-2.0.1-rc-backup/command/src/module/generate/App/resources/icons/Icon~ipad@2x.png
  27. BIN st/mvc/sdk-2.0.1-rc-backup/command/src/module/generate/App/resources/icons/iTunesArtwork.png
  28. BIN st/mvc/sdk-2.0.1-rc-backup/command/src/module/generate/App/resources/icons/icon-spot~ipad.png
  29. BIN ...-2.0.1-rc-backup/command/src/module/generate/App/resources/loading/Default-LandscapeLeft~ipad.png
  30. BIN ...2.0.1-rc-backup/command/src/module/generate/App/resources/loading/Default-LandscapeRight~ipad.png
  31. BIN .../sdk-2.0.1-rc-backup/command/src/module/generate/App/resources/loading/Default-Landscape~ipad.png
  32. BIN ...1-rc-backup/command/src/module/generate/App/resources/loading/Default-PortraitUpsideDown~ipad.png
  33. BIN ...c/sdk-2.0.1-rc-backup/command/src/module/generate/App/resources/loading/Default-Portrait~ipad.png
  34. BIN st/mvc/sdk-2.0.1-rc-backup/command/src/module/generate/App/resources/loading/Default.png
  35. BIN st/mvc/sdk-2.0.1-rc-backup/command/src/module/generate/App/resources/loading/Default@2x.png
  36. BIN st/mvc/sdk-2.0.1-rc-backup/command/src/module/generate/App/resources/loading/Default~ipad.png
  37. 0 st/mvc/{sdk → sdk-2.0.1-rc-backup}/command/src/module/generate/App/resources/loading/Homescreen.jpg
  38. 0 ...{sdk → sdk-2.0.1-rc-backup}/command/src/module/generate/App/resources/loading/Homescreen~ipad.jpg
  39. +19 −0 st/mvc/sdk-2.0.1-rc-backup/command/src/module/generate/App/resources/sass/app.scss.tpl
  40. +14 −0 st/mvc/sdk-2.0.1-rc-backup/command/src/module/generate/App/resources/sass/config.rb.tpl
  41. +21 −0 st/mvc/sdk-2.0.1-rc-backup/command/src/module/generate/Controller.js
  42. +17 −0 st/mvc/sdk-2.0.1-rc-backup/command/src/module/generate/Controller/controller.js.tpl
  43. +36 −0 st/mvc/sdk-2.0.1-rc-backup/command/src/module/generate/Form.js
  44. +21 −0 st/mvc/sdk-2.0.1-rc-backup/command/src/module/generate/Form/form.js.tpl
  45. +106 −0 st/mvc/sdk-2.0.1-rc-backup/command/src/module/generate/Generator.js
  46. +45 −0 st/mvc/sdk-2.0.1-rc-backup/command/src/module/generate/Model.js
  47. +9 −0 st/mvc/sdk-2.0.1-rc-backup/command/src/module/generate/Model/model.js.tpl
  48. +21 −0 st/mvc/sdk-2.0.1-rc-backup/command/src/module/generate/Profile.js
  49. +16 −0 st/mvc/sdk-2.0.1-rc-backup/command/src/module/generate/Profile/profile.js.tpl
  50. +30 −0 st/mvc/sdk-2.0.1-rc-backup/command/src/preprocessor/LineStack.js
  51. +121 −0 st/mvc/sdk-2.0.1-rc-backup/command/src/preprocessor/Statement.js
  52. +38 −0 st/mvc/sdk-2.0.1-rc-backup/command/src/preprocessor/statement/Debug.js
  53. +36 −0 st/mvc/sdk-2.0.1-rc-backup/command/src/preprocessor/statement/Deprecated.js
  54. +18 −0 st/mvc/sdk-2.0.1-rc-backup/command/src/preprocessor/statement/Else.js
  55. +28 −0 st/mvc/sdk-2.0.1-rc-backup/command/src/preprocessor/statement/Elseif.js
  56. +20 −0 st/mvc/sdk-2.0.1-rc-backup/command/src/preprocessor/statement/Feature.js
  57. +69 −0 st/mvc/sdk-2.0.1-rc-backup/command/src/preprocessor/statement/If.js
  58. +20 −0 st/mvc/sdk-2.0.1-rc-backup/command/templates/action.tpl
  59. +19 −0 st/mvc/sdk-2.0.1-rc-backup/command/templates/actions.tpl
  60. +9 −0 st/mvc/sdk-2.0.1-rc-backup/command/templates/cache.manifest.tpl
  61. +24 −0 st/mvc/sdk-2.0.1-rc-backup/command/templates/modules.tpl
  62. +9 −0 st/mvc/sdk-2.0.1-rc-backup/command/test/unit/helpers/preprocessor/after1.js
  63. +2 −0 st/mvc/sdk-2.0.1-rc-backup/command/test/unit/helpers/preprocessor/after2.js
  64. +9 −0 st/mvc/sdk-2.0.1-rc-backup/command/test/unit/helpers/preprocessor/after3.js
  65. +1 −0 st/mvc/sdk-2.0.1-rc-backup/command/test/unit/helpers/preprocessor/after4.js
  66. 0 st/mvc/sdk-2.0.1-rc-backup/command/test/unit/helpers/preprocessor/after5.js
  67. +2 −0 st/mvc/sdk-2.0.1-rc-backup/command/test/unit/helpers/preprocessor/after6.js
  68. +17 −0 st/mvc/sdk-2.0.1-rc-backup/command/test/unit/helpers/preprocessor/before1.js
  69. +9 −0 st/mvc/sdk-2.0.1-rc-backup/command/test/unit/helpers/preprocessor/before2.js
  70. +23 −0 st/mvc/sdk-2.0.1-rc-backup/command/test/unit/helpers/preprocessor/before3.js
  71. +5 −0 st/mvc/sdk-2.0.1-rc-backup/command/test/unit/helpers/preprocessor/before4.js
  72. +3 −0 st/mvc/sdk-2.0.1-rc-backup/command/test/unit/helpers/preprocessor/before5.js
  73. +7 −0 st/mvc/sdk-2.0.1-rc-backup/command/test/unit/helpers/preprocessor/before6.js
  74. +92 −0 st/mvc/sdk-2.0.1-rc-backup/command/test/unit/specs/PreprocessorSpec.js
  75. +9 −0 st/mvc/sdk-2.0.1-rc-backup/command/test/unit/specs/SampleSpec.js
  76. +14 −0 st/mvc/sdk-2.0.1-rc-backup/command/test/unit/specs/preprocessor/statement/IfSpec.js
  77. +7 −0 st/mvc/sdk-2.0.1-rc-backup/command/vendor/nodejs/node_modules/.bin/jasmine-node
  78. +323 −0 st/mvc/sdk-2.0.1-rc-backup/command/vendor/nodejs/node_modules/.bin/uglifyjs
  79. +101 −0 st/mvc/sdk-2.0.1-rc-backup/command/vendor/nodejs/node_modules/findit/README.markdown
  80. +3 −0 st/mvc/sdk-2.0.1-rc-backup/command/vendor/nodejs/node_modules/findit/examples/callback.js
  81. +9 −0 st/mvc/sdk-2.0.1-rc-backup/command/vendor/nodejs/node_modules/findit/examples/emitter.js
  82. +2 −0 st/mvc/sdk-2.0.1-rc-backup/command/vendor/nodejs/node_modules/findit/examples/sync.js
  83. +142 −0 st/mvc/sdk-2.0.1-rc-backup/command/vendor/nodejs/node_modules/findit/index.js
  84. +1 −0 st/mvc/sdk-2.0.1-rc-backup/command/vendor/nodejs/node_modules/findit/node_modules/seq/.npmignore
  85. +442 −0 ...vc/sdk-2.0.1-rc-backup/command/vendor/nodejs/node_modules/findit/node_modules/seq/README.markdown
  86. +18 −0 ...c/sdk-2.0.1-rc-backup/command/vendor/nodejs/node_modules/findit/node_modules/seq/examples/join.js
  87. +12 −0 ...2.0.1-rc-backup/command/vendor/nodejs/node_modules/findit/node_modules/seq/examples/parseq.coffee
  88. +19 −0 ...sdk-2.0.1-rc-backup/command/vendor/nodejs/node_modules/findit/node_modules/seq/examples/parseq.js
  89. +16 −0 ...0.1-rc-backup/command/vendor/nodejs/node_modules/findit/node_modules/seq/examples/stat_all.coffee
  90. +17 −0 ...k-2.0.1-rc-backup/command/vendor/nodejs/node_modules/findit/node_modules/seq/examples/stat_all.js
  91. +520 −0 st/mvc/sdk-2.0.1-rc-backup/command/vendor/nodejs/node_modules/findit/node_modules/seq/index.js
  92. +1 −0 ...ackup/command/vendor/nodejs/node_modules/findit/node_modules/seq/node_modules/chainsaw/.npmignore
  93. +140 −0 .../command/vendor/nodejs/node_modules/findit/node_modules/seq/node_modules/chainsaw/README.markdown
  94. +25 −0 ...mmand/vendor/nodejs/node_modules/findit/node_modules/seq/node_modules/chainsaw/examples/add_do.js
  95. +67 −0 ...mmand/vendor/nodejs/node_modules/findit/node_modules/seq/node_modules/chainsaw/examples/prompt.js
  96. +108 −0 ...-backup/command/vendor/nodejs/node_modules/findit/node_modules/seq/node_modules/chainsaw/index.js
  97. +1 −0 ...odejs/node_modules/findit/node_modules/seq/node_modules/chainsaw/node_modules/traverse/.npmignore
  98. +24 −0 ...r/nodejs/node_modules/findit/node_modules/seq/node_modules/chainsaw/node_modules/traverse/LICENSE
  99. +247 −0 .../node_modules/findit/node_modules/seq/node_modules/chainsaw/node_modules/traverse/README.markdown
  100. +16 −0 ...node_modules/findit/node_modules/seq/node_modules/chainsaw/node_modules/traverse/examples/json.js
  101. +15 −0 ...de_modules/findit/node_modules/seq/node_modules/chainsaw/node_modules/traverse/examples/leaves.js
  102. +8 −0 ..._modules/findit/node_modules/seq/node_modules/chainsaw/node_modules/traverse/examples/negative.js
  103. +38 −0 ...modules/findit/node_modules/seq/node_modules/chainsaw/node_modules/traverse/examples/stringify.js
  104. +322 −0 .../nodejs/node_modules/findit/node_modules/seq/node_modules/chainsaw/node_modules/traverse/index.js
  105. +18 −0 ...ejs/node_modules/findit/node_modules/seq/node_modules/chainsaw/node_modules/traverse/package.json
  106. +114 −0 ...node_modules/findit/node_modules/seq/node_modules/chainsaw/node_modules/traverse/test/circular.js
  107. +35 −0 ...ejs/node_modules/findit/node_modules/seq/node_modules/chainsaw/node_modules/traverse/test/date.js
  108. +219 −0 ...js/node_modules/findit/node_modules/seq/node_modules/chainsaw/node_modules/traverse/test/equal.js
  109. +17 −0 ...node_modules/findit/node_modules/seq/node_modules/chainsaw/node_modules/traverse/test/instance.js
  110. +42 −0 ...ode_modules/findit/node_modules/seq/node_modules/chainsaw/node_modules/traverse/test/interface.js
  111. +47 −0 ...ejs/node_modules/findit/node_modules/seq/node_modules/chainsaw/node_modules/traverse/test/json.js
  112. +21 −0 ...s/node_modules/findit/node_modules/seq/node_modules/chainsaw/node_modules/traverse/test/leaves.js
  113. +203 −0 ...de_modules/findit/node_modules/seq/node_modules/chainsaw/node_modules/traverse/test/mutability.js
  114. +20 −0 ...node_modules/findit/node_modules/seq/node_modules/chainsaw/node_modules/traverse/test/negative.js
  115. +15 −0 ...dejs/node_modules/findit/node_modules/seq/node_modules/chainsaw/node_modules/traverse/test/obj.js
  116. +41 −0 ...ejs/node_modules/findit/node_modules/seq/node_modules/chainsaw/node_modules/traverse/test/stop.js
  117. +36 −0 ...ode_modules/findit/node_modules/seq/node_modules/chainsaw/node_modules/traverse/test/stringify.js
  118. +54 −0 ...de_modules/findit/node_modules/seq/node_modules/chainsaw/node_modules/traverse/test/super_deep.js
  119. +23 −0 ...kup/command/vendor/nodejs/node_modules/findit/node_modules/seq/node_modules/chainsaw/package.json
  120. +418 −0 ...command/vendor/nodejs/node_modules/findit/node_modules/seq/node_modules/chainsaw/test/chainsaw.js
  121. +191 −0 ...p/command/vendor/nodejs/node_modules/findit/node_modules/seq/node_modules/hashish/README.markdown
  122. +9 −0 ...command/vendor/nodejs/node_modules/findit/node_modules/seq/node_modules/hashish/examples/chain.js
  123. +7 −0 ...p/command/vendor/nodejs/node_modules/findit/node_modules/seq/node_modules/hashish/examples/map.js
  124. +253 −0 ...c-backup/command/vendor/nodejs/node_modules/findit/node_modules/seq/node_modules/hashish/index.js
  125. +1 −0 ...nodejs/node_modules/findit/node_modules/seq/node_modules/hashish/node_modules/traverse/.npmignore
  126. +24 −0 ...or/nodejs/node_modules/findit/node_modules/seq/node_modules/hashish/node_modules/traverse/LICENSE
  127. +256 −0 ...s/node_modules/findit/node_modules/seq/node_modules/hashish/node_modules/traverse/README.markdown
  128. +16 −0 .../node_modules/findit/node_modules/seq/node_modules/hashish/node_modules/traverse/examples/json.js
  129. +15 −0 ...ode_modules/findit/node_modules/seq/node_modules/hashish/node_modules/traverse/examples/leaves.js
  130. +8 −0 ...e_modules/findit/node_modules/seq/node_modules/hashish/node_modules/traverse/examples/negative.js
  131. +10 −0 ...node_modules/findit/node_modules/seq/node_modules/hashish/node_modules/traverse/examples/scrub.js
  132. +38 −0 ..._modules/findit/node_modules/seq/node_modules/hashish/node_modules/traverse/examples/stringify.js
  133. +279 −0 ...r/nodejs/node_modules/findit/node_modules/seq/node_modules/hashish/node_modules/traverse/index.js
  134. +18 −0 ...dejs/node_modules/findit/node_modules/seq/node_modules/hashish/node_modules/traverse/package.json
  135. +115 −0 .../node_modules/findit/node_modules/seq/node_modules/hashish/node_modules/traverse/test/circular.js
  136. +35 −0 ...dejs/node_modules/findit/node_modules/seq/node_modules/hashish/node_modules/traverse/test/date.js
  137. +220 −0 ...ejs/node_modules/findit/node_modules/seq/node_modules/hashish/node_modules/traverse/test/equal.js
  138. +13 −0 ...odejs/node_modules/findit/node_modules/seq/node_modules/hashish/node_modules/traverse/test/has.js
  139. +17 −0 .../node_modules/findit/node_modules/seq/node_modules/hashish/node_modules/traverse/test/instance.js
  140. +42 −0 ...node_modules/findit/node_modules/seq/node_modules/hashish/node_modules/traverse/test/interface.js
  141. +47 −0 ...dejs/node_modules/findit/node_modules/seq/node_modules/hashish/node_modules/traverse/test/json.js
  142. +29 −0 ...dejs/node_modules/findit/node_modules/seq/node_modules/hashish/node_modules/traverse/test/keys.js
  143. +21 −0 ...js/node_modules/findit/node_modules/seq/node_modules/hashish/node_modules/traverse/test/leaves.js
  144. +92 −0 ...modules/findit/node_modules/seq/node_modules/hashish/node_modules/traverse/test/lib/deep_equal.js
  145. +252 −0 ...ode_modules/findit/node_modules/seq/node_modules/hashish/node_modules/traverse/test/mutability.js
  146. +20 −0 .../node_modules/findit/node_modules/seq/node_modules/hashish/node_modules/traverse/test/negative.js
  147. +15 −0 ...odejs/node_modules/findit/node_modules/seq/node_modules/hashish/node_modules/traverse/test/obj.js
  148. +35 −0 .../node_modules/findit/node_modules/seq/node_modules/hashish/node_modules/traverse/test/siblings.js
  149. +41 −0 ...dejs/node_modules/findit/node_modules/seq/node_modules/hashish/node_modules/traverse/test/stop.js
  150. +36 −0 ...node_modules/findit/node_modules/seq/node_modules/hashish/node_modules/traverse/test/stringify.js
  151. +34 −0 ...s/node_modules/findit/node_modules/seq/node_modules/hashish/node_modules/traverse/test/subexpr.js
  152. +55 −0 ...ode_modules/findit/node_modules/seq/node_modules/hashish/node_modules/traverse/test/super_deep.js
  153. +22 −0 ...ode_modules/findit/node_modules/seq/node_modules/hashish/node_modules/traverse/testling/leaves.js
  154. +33 −0 ...ckup/command/vendor/nodejs/node_modules/findit/node_modules/seq/node_modules/hashish/package.json
  155. +250 −0 ...ckup/command/vendor/nodejs/node_modules/findit/node_modules/seq/node_modules/hashish/test/hash.js
Sorry, we could not display the entire diff because too many files (1,411) changed.
View
7 st/mvc/app/controller/Main.js
@@ -12,10 +12,11 @@ Ext.define('Locale.controller.Main', {
onLocalePick : function(field, value) {
if (value.length > 2) {
var store = field.getStore(),
- rec = store.findRecord('text', value),
- abbr = rec.get(field.getValueField());
+ rec = store.findRecord('text', value);
+
+ value = rec.get(field.getValueField());
}
- Ux.locale.Manager.updateLocale(abbr);
+ Ux.locale.Manager.updateLocale(value);
}
});
View
12 st/mvc/app/view/Main.js
@@ -19,14 +19,18 @@ Ext.define('Locale.view.Main', {
},
items : [
{
- ui : 'decline',
- locales : {
+ ui : 'decline',
+ enableLocale : true,
+ locale : Ux.locale.Manager,
+ locales : {
text : 'buttons.cancel'
}
},
{
- ui : 'confirm',
- locales : {
+ ui : 'confirm',
+ enableLocale : true,
+ locale : Ux.locale.Manager,
+ locales : {
text : 'buttons.save'
}
},
View
73 st/mvc/sdk-2.0.1-rc-backup/command/sencha.js
@@ -0,0 +1,73 @@
+/**
+ * Sencha Command
+ * @author Jacky Nguyen <jacky@sencha.com>
+ */
+(function() {
+ var sdkToolsVersion = '2.0.0-beta2',
+ sdkToolsEnvName = 'SENCHA_SDK_TOOLS_' + sdkToolsVersion.replace(/[\.-]/g, '_').toUpperCase(),
+ coreFiles = [
+ "Ext.js",
+ "version/Version.js",
+ "lang/String.js",
+ "lang/Number.js",
+ "lang/Array.js",
+ "lang/Function.js",
+ "lang/Object.js",
+ "lang/Date.js",
+ "lang/JSON.js",
+ "class/Base.js",
+ "class/Class.js",
+ "class/ClassManager.js",
+ "class/Loader.js",
+ "lang/Error.js"
+ ],
+ path = require('path'),
+ currentPath = __dirname,
+ srcPath = path.resolve(currentPath, '../src'),
+ corePath = path.join(srcPath, 'core'),
+ sdkToolsPath = process.env[sdkToolsEnvName],
+ command;
+
+ if (!sdkToolsPath) {
+ console.log('[ERROR] Sencha SDK Tools ' + sdkToolsVersion + ' cannot be found from your system ('+sdkToolsEnvName+
+ ' environment variable is not set). Please download and install version "'+
+ sdkToolsVersion+'" of the tools from http://www.sencha.com/products/sdk-tools . ' +
+ 'Close this terminal and open a new one after the installation is complete.');
+ return;
+ }
+
+ coreFiles.forEach(function(file) {
+ require(path.join(corePath, file));
+ });
+
+ Ext.Loader.setConfig({
+ paths: {
+ Ext: srcPath,
+ Command: path.join(currentPath, 'src')
+ }
+ });
+
+ command = Ext.create('Command.Cli', {
+ version: '2.0.1',
+ currentPath: currentPath,
+ binPath: path.join(sdkToolsPath, 'bin'),
+ modules: {
+ 'app': 'Application',
+ 'fs': 'FileSystem',
+ 'manifest': 'Manifest',
+ 'test': 'Test',
+ 'generate': 'Generate',
+ 'package': 'Package'
+ },
+ logger: Ext.create('Ext.log.Logger', {
+ writers: {
+ cli: Ext.create('Command.log.writer.Cli', {
+ formatter: Ext.create('Command.log.formatter.Cli')
+ })
+ },
+ minPriority: 'verbose'
+ })
+ });
+
+ command.run(Array.prototype.slice.call(process.argv, 2));
+})();
View
314 st/mvc/sdk-2.0.1-rc-backup/command/src/Cli.js
@@ -0,0 +1,314 @@
+/**
+ * @class Command.Cli
+ * @author Jacky Nguyen <jacky@sencha.com>
+ */
+Ext.define('Command.Cli', {
+ config: {
+ version: '',
+ logger: null,
+ currentPath: '',
+ binPath: '',
+ modules: {}
+ },
+
+ modules: {},
+
+ templates: {},
+
+ ArgumentError: new Ext.Class({
+ extend: Error,
+ constructor: function(message){
+ this.message = message;
+ }
+ }),
+
+ constructor: function(config) {
+ var platformName = process.platform;
+
+ if (platformName === 'win32') {
+ platformName = 'win';
+ }
+ else if (platformName === 'darwin') {
+ platformName = 'osx';
+ }
+ else {
+ platformName = 'linux';
+
+ if (/64/.test(process.arch)) {
+ platformName += '64';
+ }
+ }
+
+ this.platformName = platformName;
+
+ this.initConfig(config);
+ },
+
+ applyVersion: function(version) {
+ return new Ext.Version(version);
+ },
+
+ applyModules: function(modules) {
+ var classManager = Ext.ClassManager,
+ alias, name;
+
+ for (alias in modules) {
+ if (modules.hasOwnProperty(alias)) {
+ name = modules[alias];
+ classManager.setAlias('Command.module.' + name, 'module.' + alias);
+ }
+ }
+
+ return modules;
+ },
+
+ run: function(args) {
+ var options = this.parseArguments(args),
+ targets = options.targets,
+ moduleName = targets.shift(),
+ action = targets.shift(),
+ module;
+
+ if (!moduleName || !(module = this.getModule(moduleName))) {
+ return this.printUsage();
+ }
+
+ if (!action || !module.hasAction(action)) {
+ return this.printUsage(moduleName);
+ }
+
+ process.on('uncaughtException', function(e) {
+ this.error(e.message);
+ }.bind(this));
+
+ try {
+ this.execute(module, action, options);
+ }
+ catch (e) {
+ this.error(e.message);
+
+ if (e instanceof this.ArgumentError) {
+ this.printUsage(moduleName, action);
+ }
+ }
+ },
+
+ getModule: function(name) {
+ var modules = this.modules,
+ module = modules[name];
+
+ if (!module) {
+ try {
+ module = Ext.createByAlias('module.' + name, this);
+ }
+ catch (e) {
+ return null;
+ }
+
+ modules[name] = module;
+ }
+
+ return module;
+ },
+
+ execute: function(module, action, options) {
+ var rules = module.getActionRules(action).slice(1),
+ args = [],
+ targets = options.targets,
+ i, ln, arg, value, name, longName, shortName, type, defaultValue;
+
+ for (i = 0,ln = rules.length; i < ln; i++) {
+ arg = rules[i];
+
+ longName = arg[0];
+ shortName = arg[1];
+ type = arg[3];
+ defaultValue = arg[4];
+ name = '--' + longName;
+
+ if (options.hasOwnProperty(longName)) {
+ value = this.formatArgumentValue(options[longName], type, name);
+ }
+ else if (shortName && options.hasOwnProperty(shortName)) {
+ name = '-' + shortName;
+ value = this.formatArgumentValue(options[shortName], type, name);
+ }
+ else {
+ value = targets.shift();
+
+ if (value !== undefined) {
+ value = this.formatArgumentValue(value, type, name);
+ }
+ else if (defaultValue !== undefined && defaultValue !== null) {
+ value = defaultValue;
+ }
+ else {
+ throw new this.ArgumentError("Missing required value for argument: '" + name + "'");
+ }
+ }
+
+ args.push(value);
+ }
+
+ module[action].apply(module, args);
+ },
+
+ formatArgumentValue: function(value, type, name) {
+ var errorMessagePrefix = "Invalid value of: '" + value + "' for argument: '" + name + "', ";
+
+ switch (type) {
+ case "number":
+ if (isNaN(value)) {
+ throw new this.ArgumentError(errorMessagePrefix + "must be a valid number");
+ }
+ return Number(value);
+ break;
+
+ case "array":
+ if (typeof value != 'string') {
+ throw new this.ArgumentError(errorMessagePrefix + "must be a valid comma-separated list of items");
+ }
+ return value.split(',');
+ break;
+
+ case "boolean":
+ if (value === "yes") {
+ value = true;
+ }
+ else if (value === "no") {
+ value = false;
+ }
+ return Boolean(value);
+ break;
+
+ default:
+ return String(value);
+ }
+ },
+
+ getTemplate: function(name) {
+ var templates = this.templates,
+ template = templates[name],
+ filePath;
+
+ if (!template) {
+ filePath = require('path').resolve(this.getCurrentPath(), 'templates/' + name + '.tpl');
+ templates[name] = template = Ext.create('Ext.XTemplate', this.getModule('fs').read(filePath));
+ }
+
+ return template;
+ },
+
+ printUsage: function(moduleName, actionName) {
+ var modules = [],
+ actions = [],
+ module, info;
+
+ if (!moduleName) {
+ Ext.Object.each(this.getModules(), function(alias) {
+ modules.push({
+ name: alias,
+ description: this.getModule(alias).description
+ });
+ }, this);
+
+ console.log(this.getTemplate('modules').apply({
+ version: this.getVersion().toString(),
+ modules: modules
+ }));
+ }
+ else if (!actionName) {
+ module = this.getModule(moduleName);
+
+ Ext.Object.each(module.actions, function(name, args) {
+ actions.push({
+ name: name,
+ description: args[0],
+ args: args.slice(1)
+ });
+ });
+
+ console.log(this.getTemplate('actions').apply({
+ name: moduleName,
+ description: module.description,
+ actions: actions
+ }));
+ }
+ else {
+ module = this.getModule(moduleName);
+ info = module.actions[actionName];
+
+ console.log(this.getTemplate('action').apply({
+ module: moduleName,
+ name: actionName,
+ description: info[0],
+ args: info.slice(1)
+ }));
+ }
+ },
+
+ parseArguments: function(args) {
+ var targets = [],
+ options = {
+ targets: targets
+ },
+ key = null,
+ i, ln, option, match;
+
+ for (i = 0, ln = args.length; i < ln; i++) {
+ option = args[i];
+
+ if (key !== null) {
+ if (!option.match(/^-{1,2}([^-])/i)) {
+ options[key] = option;
+ key = null;
+ continue;
+ }
+
+ options[key] = true;
+ key = null;
+ }
+
+ if (match = option.match(/^--([^=]+)=(.*)$/i)) {
+ options[match[1]] = match[2];
+ }
+ else if ((match = option.match(/^--(.+)$/i)) || (match = option.match(/^-(.)$/i))) {
+ key = match[1];
+ }
+ else if (match = option.match(/^-(.+)$/i)) {
+ match[1].split('').forEach(function(a) {
+ options[a] = true;
+ });
+ }
+ else {
+ targets.push(option);
+ }
+ }
+
+ if (key !== null) {
+ options[key] = true;
+ }
+
+ return options;
+ },
+
+ doLog: function(message, priority, stackLevel) {
+ return this.getLogger().log(message, priority, (stackLevel !== undefined) ? stackLevel : 2);
+ },
+
+ log: function(message) {
+ return this.doLog(message, 'verbose');
+ },
+
+ info: function(message) {
+ return this.doLog(message, 'info');
+ },
+
+ warn: function(message) {
+ return this.doLog(message, 'warn');
+ },
+
+ error: function(message) {
+ return this.doLog(message, 'error');
+ }
+});
View
179 st/mvc/sdk-2.0.1-rc-backup/command/src/Preprocessor.js
@@ -0,0 +1,179 @@
+/**
+ * @class Command.Preprocessor
+ * @author Jacky Nguyen <jacky@sencha.com>
+ */
+Ext.define('Command.Preprocessor', {
+ statics: {
+ getInstance: function() {
+ if (!this.instance) {
+ this.instance = new this();
+ }
+
+ return this.instance;
+ }
+ },
+
+ params: {},
+
+ process: function(filePath) {
+ // This is currently not memory-efficient since it reads the whole file's content at once.
+ // However nodejs doesn't have a proper / easy way to "readLine" synchronously
+ // And it takes a ridiculous amount of effort to do so
+ var lineStack = Ext.create('Command.preprocessor.LineStack', filePath);
+
+ return Ext.create('Command.preprocessor.Statement').process(lineStack);
+ },
+
+ evaluate: function(name, value) {
+ var params = this.params,
+ modifier = null,
+ param = (params.hasOwnProperty(name)) ? params[name] : false,
+ match;
+
+ if (value === undefined) {
+ value = true;
+ }
+
+ if (Ext.isString(value)) {
+ match = value.match(/^(!=*|<=|>=|<|>|=+)/);
+
+ if (match) {
+ modifier = match[0];
+ value = value.slice(modifier.length);
+ }
+
+ // Boolean
+ if (value === 'true') {
+ value = true;
+ }
+ else if (value === 'false') {
+ value = false;
+ }
+ // Numeric
+ else if (!isNaN(value)) {
+ value = parseFloat(value);
+ }
+ }
+
+// Logger.log('[DEBUG][Parser#evaluate] name:"' + name + '", modifier:'+modifier+', param:"' + param + '", value:"' + value + '"');
+
+ switch (modifier) {
+ case '!==':
+ case '!=':
+ case '!':
+ return (param !== value);
+ case '>':
+ return (param > value);
+ case '<':
+ return (param < value);
+ case '<=':
+ return (param <= value);
+ case '>=':
+ return (param >= value);
+ case '==':
+ return (param == value);
+ case '=':
+ case '===':
+ default:
+ return (param === value);
+ }
+ },
+
+ setParams: function(params) {
+ this.params = params || {};
+ },
+
+ isCloseOf: function(string, statement) {
+ if (!statement.type) {
+ return false;
+ }
+
+ return string.trim().match(new RegExp("^\\/\\/(?:\\t|\\s)*<\\/" + ((statement.isInverted) ? "!" : "") +
+ statement.type + ">$")) !== null;
+ },
+
+ isStatement: function(string) {
+ return this.parseStatementParts(string) !== null;
+ },
+
+ parseStatementParts: function(string) {
+ return string.trim().match(/^\/\/(?:\t|\s)*<([^\/]+)>$/);
+ },
+
+ parseStatementProperties: function(string) {
+ var properties = {},
+ expect = function(regexp) {
+ var result = string.match(regexp);
+
+ if (result !== null) {
+ string = string.slice(result[0].length);
+ return result[0];
+ }
+
+ return null;
+ },
+ name, equalSign, valueWrapper, valueCheck, value;
+
+ while (string.length > 0) {
+ expect(/^[^\w]+/i);
+ name = expect(/^[\w\.\-_]+/i);
+
+ if (name === null) {
+ break;
+ }
+
+ equalSign = expect(/^=/);
+
+ if (equalSign === null) {
+ properties[name] = true;
+ continue;
+ }
+
+ valueWrapper = expect(/^('|")/i);
+ valueCheck = valueWrapper || "\\s";
+
+ value = expect(new RegExp('^[^' + valueCheck + ']+'));
+
+ if (valueWrapper !== null) {
+ expect(new RegExp(valueWrapper));
+ }
+
+ properties[name] = value;
+ }
+
+ return properties;
+ },
+
+ parseStatement: function(string) {
+ string = string.trim();
+
+ var parts = this.parseStatementParts(string),
+ typeMatch, statement;
+
+ // Check if it's actually a valid statement
+ if (parts === null) {
+ return false;
+ }
+
+ string = parts[1];
+
+ typeMatch = string.match(/^(!)?([\w]+)/i);
+
+ if (typeMatch === null) {
+ return false;
+ }
+
+ statement = {
+ properties: {}
+ };
+
+ statement.type = typeMatch[2];
+ statement.isInverted = (typeMatch[1] !== undefined);
+
+ string = string.substr(typeMatch[0].length, string.length).trim();
+ statement.properties = this.parseStatementProperties(string);
+
+ return statement;
+ }
+
+});
View
53 st/mvc/sdk-2.0.1-rc-backup/command/src/log/formatter/Cli.js
@@ -0,0 +1,53 @@
+Ext.define('Command.log.formatter.Cli', {
+ extend: 'Ext.log.formatter.Default',
+
+ styles: {
+ 'bold' : [1, 22],
+ 'italic' : [3, 23],
+ 'underline' : [4, 24],
+ 'inverse' : [7, 27],
+ //grayscale
+ 'white' : [37, 39],
+ 'grey' : [90, 39],
+ 'black' : [30, 39],
+ //colors
+ 'blue' : [34, 39],
+ 'cyan' : [36, 39],
+ 'green' : [32, 39],
+ 'magenta' : [35, 39],
+ 'red' : [31, 39],
+ 'yellow' : [33, 39]
+ },
+
+ priorityStyle: {
+ verbose: ['grey', 'bold'],
+ info: ['green', 'bold'],
+ deprecate: ['yellow', 'bold'],
+ warn: ['magenta', 'bold'],
+ error: ['red', 'bold']
+ },
+
+ format: function(event) {
+ var priority = event.priorityName,
+ priorityStyles = this.priorityStyle[priority];
+
+ return require('util').format('%s %s',
+ this.style('['+priority.toUpperCase()+']', priorityStyles),
+// this.style('['+event.callerDisplayName+']', ['grey']),
+ event.message);
+ },
+
+ style: function(text, styles) {
+ var style, i, ln, data;
+
+ styles = Ext.Array.from(styles);
+
+ for (i = 0,ln = styles.length; i < ln; i++) {
+ style = styles[i];
+ data = this.styles[style];
+ text = '\033['+data[0]+'m' + text + '\033['+data[1]+'m';
+ }
+
+ return text;
+ }
+});
View
7 st/mvc/sdk-2.0.1-rc-backup/command/src/log/writer/Cli.js
@@ -0,0 +1,7 @@
+Ext.define('Command.log.writer.Cli', {
+ extend: 'Ext.log.writer.Writer',
+
+ doWrite: function(event) {
+ console.log(event.message);
+ }
+});
View
71 st/mvc/sdk-2.0.1-rc-backup/command/src/module/Abstract.js
@@ -0,0 +1,71 @@
+/**
+ * @class Command.module.Abstract
+ * @author Jacky Nguyen <jacky@sencha.com>
+ */
+Ext.define('Command.module.Abstract', {
+ actions: {},
+
+ constructor: function(cli) {
+ this.cli = cli;
+ },
+
+ getModule: function(name) {
+ return this.cli.getModule(name);
+ },
+
+ getTemplate: function(name) {
+ return this.cli.getTemplate(name);
+ },
+
+ hasAction: function(action) {
+ return this.actions.hasOwnProperty(action);
+ },
+
+ getActionRules: function(action) {
+ return this.actions[action];
+ },
+
+ getBinaryPath: function(binary) {
+ return require('path').join(this.cli.getBinPath(), binary);
+ },
+
+ getVendorPath: function(name) {
+ return require('path').resolve(this.cli.getCurrentPath(), 'vendor/' + name);
+ },
+
+ escapeShell: function(cmd) {
+ if (!cmd) {
+ return '';
+ }
+
+ return '"' + cmd + '"';
+ },
+
+ exec: function(command, args, callback) {
+ var util = require('util');
+
+ if (typeof args == 'function') {
+ callback = args;
+ args = [];
+ }
+
+ args = args.map(function(arg) {
+ return this.escapeShell(arg);
+ }, this);
+ args.unshift(command);
+
+ command = util.format.apply(util, args);
+ callback = callback.bind(this);
+
+ require('child_process').exec(command, callback);
+ }
+
+}, function() {
+ ['log', 'info', 'warn', 'error'].forEach(function(name) {
+ this.addMember(name, function() {
+ var args = Ext.Array.from(arguments);
+ args.push(name);
+ return this.cli.doLog.apply(this.cli, args);
+ });
+ }, this);
+});
View
428 st/mvc/sdk-2.0.1-rc-backup/command/src/module/Application.js
@@ -0,0 +1,428 @@
+/**
+ * @class Command.module.Application
+ * @author Jacky Nguyen <jacky@sencha.com>
+ */
+Ext.define('Command.module.Application', {
+ extend: 'Command.module.Abstract',
+
+ description: 'Resolve application dependencies and build for production',
+
+ actions: {
+ create: [
+ "(Alias to 'sencha generate app') Generate a new project with the recommended structure",
+ ['name', 'n', 'The namespace of the application to create. ' +
+ 'This will be used as the prefix for all your classes', 'string', null, 'MyApp'],
+ ['path', 'p', 'The directory path to generate this application to.', 'string', null, '/path/to/myapp'],
+ ['library', 'l', "The library's build to develop your application with, either 'core' or 'all'. " +
+ "Defaults to 'core'", 'string', 'core', 'all']
+ ],
+ upgrade: [
+ "Upgrade the given application to the SDK at the current working directory",
+ ['path', 'p', 'The directory path to the application to upgrade', 'string', null, '/path/to/myapp']
+ ],
+ resolve: [
+ "Generate a list of dependencies in the exact loading order for the given application. " +
+ "Note that the resolved paths are relative to the given application's HTML document",
+ ['uri', 'u', 'The URI to the application\'s HTML document', 'string', null, 'http://localhost/myapp/index.html'],
+ ['output', 'o', 'The file path to write the results to in JSON format.', 'string', null, 'dependencies.json']
+ ],
+ build: [
+ "Build the application at the current working directory to the given path",
+ ['environment', 'e', "The build environment, either 'testing', 'package', 'production', or 'native'" +
+ "\n " +
+ "+ 'testing' is meant for QA prior to production. All JavaScript and CSS Files are bundled, but not minified" +
+ "\n " +
+ "+ 'package' creates a self-contained, re-distributable production build that " +
+ "\n " +
+ "normally runs from local file system without the need for a web server" +
+ "\n " +
+ "+ 'production' creates a production build that is normally hosted on a web server and " +
+ "\n " +
+ "serve multiple clients (devices). The build is offline-capable and has built-in " +
+ "\n " +
+ "OTA delta updating feature" +
+ "\n " +
+ "+ 'native' first generates a 'package' build, then packages it as a native " +
+ "\n " +
+ "application, ready to be deployed to native platforms",
+ 'string', null, 'production'],
+ ['destination', 'd', "The directory path to build this application to. " +
+ "\n " +
+ "If none given, the default path specified inside 'app.json' is used", 'string', '', '/path/to/deploy/myapp'],
+ ['archive', 'a', "The directory path where all previous builds were stored," +
+ "\n " +
+ "needed to generate deltas between updates (for production only). " +
+ "\n " +
+ "If none given, the default path specified inside 'app.json' is used",
+ 'string', '', '/path/to/myapp/archive']
+ ]
+ },
+
+ isSdkDirectory: function(sdkPath) {
+ var path = require('path'),
+ fs = this.getModule('fs');
+
+ return path.existsSync(sdkPath) && path.existsSync(path.join(sdkPath, '.senchasdk')) &&
+ fs.read(path.join(sdkPath, '.senchasdk')).trim() === '.';
+ },
+
+ isApplicationDirectory: function(appPath) {
+ var path = require('path');
+
+ return path.existsSync(appPath) && path.existsSync(path.join(appPath, '.senchasdk')) &&
+ path.existsSync(path.join(appPath, 'app.json'));
+ },
+
+ create: function() {
+ var module = this.getModule('generate'),
+ sdkPath = process.cwd();
+
+ if (!this.isSdkDirectory(sdkPath)) {
+ throw new Error("The current working directory (" + sdkPath + ") is not a valid SDK directory. " +
+ "Please 'cd' into a SDK directory before executing this command");
+ }
+
+ module.app.apply(module, arguments);
+ },
+
+ upgrade: function(appPath) {
+ var sdkPath = process.cwd(),
+ path = require('path'),
+ fs = this.getModule('fs'),
+ newSdkVersion = fs.read(path.join(sdkPath, 'version.txt')).trim(),
+ appSdkPath, oldSdkVersion, oldSdkPath;
+
+ if (!this.isSdkDirectory(sdkPath)) {
+ throw new Error("The current working directory (" + sdkPath + ") is not a valid SDK directory. " +
+ "Please 'cd' into a SDK directory before executing this command");
+ }
+
+ if (!this.isApplicationDirectory(appPath)) {
+ throw new Error("" + appPath + " is not a valid application directory.");
+ }
+
+ appSdkPath = path.join(appPath, fs.read(path.join(appPath, '.senchasdk')).trim());
+ oldSdkVersion = fs.read(path.join(appSdkPath, 'version.txt')).trim();
+ oldSdkPath = appSdkPath + '-' + oldSdkVersion + '-backup';
+
+ if (oldSdkVersion === newSdkVersion) {
+ this.info("This SDK (version '" + newSdkVersion + "') is identical to the application's SDK, nothing to upgrade.");
+ return;
+ }
+
+ this.info("Upgrading your application from SDK version '" + oldSdkVersion + "' to version '" + newSdkVersion + "'");
+ fs.rename(appSdkPath, oldSdkPath);
+ this.info("Renamed '" + appSdkPath + "' to '" + oldSdkPath + "' for backup");
+
+ fs.copyDirectory(path.join(sdkPath, 'src'), path.join(appSdkPath, 'src'));
+ fs.copyDirectory(path.join(sdkPath, 'resources'), path.join(appSdkPath, 'resources'));
+ fs.copyDirectory(path.join(sdkPath, 'command'), path.join(appSdkPath, 'command'));
+ fs.copyDirectory(path.join(sdkPath, 'microloader'), path.join(appSdkPath, 'microloader'));
+ fs.copyFile(path.join(sdkPath, 'version.txt'), path.join(appSdkPath, 'version.txt'));
+ fs.copyFile(path.join(sdkPath, 'sencha-touch-debug.js'), path.join(appSdkPath, 'sencha-touch.js'));
+ fs.copyFile(path.join(sdkPath, 'sencha-touch-all-debug.js'), path.join(appSdkPath, 'sencha-touch-all.js'));
+
+ this.info("Your application has successfully been upgraded. To revert this operation, simply remove '" + appSdkPath + "' and rename '" + oldSdkPath + "' back to '" + appSdkPath + "'");
+ },
+
+ resolve: function(uri, output, onSuccess, onFailure) {
+ var parsedUri = require('url').parse(uri);
+
+ if (!/^file|http/.test(parsedUri.protocol)) {
+ uri = 'file:///' + require('path').resolve(uri).replace(/\\/g, '/');
+ }
+
+ this.exec('%s %s %s', [
+ this.getBinaryPath('phantomjs'),
+ this.getVendorPath('phantomjs/dependencies.js'),
+ uri
+ ], function(error, stdout, stderr) {
+ if (error) {
+ this.error(stdout || stderr);
+ if (onFailure) {
+ onFailure()
+ }
+ }
+ else {
+ if (output) {
+ this.getModule('fs').write(output, stdout);
+ }
+
+ if (onSuccess) {
+ onSuccess(JSON.parse(stdout));
+ }
+ }
+ });
+ },
+
+ build: function(environment, destination, archive) {
+ var nativePackaging = false,
+ src = process.cwd();
+
+ if (environment == 'native') {
+ environment = 'package';
+ nativePackaging = true;
+ }
+
+ if (!/^testing|package|production$/.test(environment)) {
+ throw new Error("Invalid environment argument of: '"+environment+"'," +
+ " must be either 'testing', 'package', 'production' or 'native'");
+ }
+
+ if (!this.isApplicationDirectory(src)) {
+ throw new Error("The current directory ('" + src + "') is not a valid application directory.");
+ }
+
+ var path = require('path'),
+ fs = this.getModule('fs'),
+ sdk = path.resolve(src, fs.read('.senchasdk').trim()),
+ config = fs.readJson(path.join(src, 'app.json')),
+ jsAssets = config.js || [],
+ cssAssets = config.css || [],
+ extras = config.extras || config.resources,
+ ignore = Ext.Array.from(config.ignore),
+ appCache = config.appCache,
+ indexHtmlPath = config.indexHtmlPath || 'index.html',
+ appUrl = config.url || path.join(src, indexHtmlPath),
+ preprocessor = Ext.require('Command.Preprocessor').getInstance(),
+ nodeFs = require('fs'),
+ temp = Date.now(),
+ indexHtml, assets, file, destinationFile, files,
+ appJs, assetsCount, processedAssetsCount,
+ packagerConfig, packagerJson, processIndex, ignoreFn;
+
+ if (!/^file|http/.test(require('url').parse(appUrl).protocol)) {
+ appUrl = 'file:///' + path.resolve(appUrl).replace(/\\/g, '/');
+ }
+
+ preprocessor.setParams(config.buildOptions || {});
+
+ if (!destination) {
+ destination = config.buildPaths[environment];
+ }
+
+ if (!archive) {
+ archive = config.archivePath;
+ }
+
+ destination = path.resolve(destination);
+ archive = path.resolve(archive);
+
+ this.info("Deploying your application to " + destination);
+
+ fs.mkdir(destination);
+
+ jsAssets = jsAssets.map(function(asset) {
+ if (typeof asset == 'string') {
+ asset = { path: asset };
+ }
+ asset.type = 'js';
+ return asset;
+ });
+
+ jsAssets.forEach(function(jsAsset) {
+ if (jsAsset.bundle) {
+ appJs = jsAsset.path;
+ }
+ });
+
+ if (!appJs) {
+ appJs = 'app.js';
+ }
+
+ appJs = path.join(destination, appJs);
+
+ cssAssets = cssAssets.map(function(asset) {
+ if (typeof asset == 'string') {
+ asset = { path: asset };
+ }
+ asset.type = 'css';
+ return asset;
+ });
+
+ assets = jsAssets.concat(cssAssets).filter(function(asset) {
+ return !asset.shared || (environment != 'production');
+ });
+
+ assets.forEach(function(asset) {
+ file = asset.path;
+ fs.copyFile(path.join(src, file), path.join(destination, file));
+ this.info("Copied " + file);
+ }, this);
+
+ ignore = ignore.map(function(regex){
+ try {
+ return new RegExp(regex);
+ }
+ catch (e) {
+ throw new Error("Invalid ignore value ('" + regex + "'). Reason: " + e);
+ }
+ });
+
+ ignoreFn = function(from, to) {
+ var i, ln;
+ for (i = 0,ln = ignore.length; i < ln; i++) {
+ if (ignore[i].test(from)) {
+ this.info("Ignored " + from);
+ return false;
+ }
+ }
+ }.bind(this);
+
+ extras.forEach(function(extra) {
+ fs.copy(path.join(src, extra), path.join(destination, extra), ignoreFn);
+ this.info("Copied " + extra);
+ }, this);
+
+ processIndex = function(callback) {
+ var appJson = JSON.stringify({
+ id: config.id,
+ js: jsAssets,
+ css: cssAssets
+ });
+
+ fs.write(path.join(destination, 'app.json'), appJson);
+ this.info("Generated app.json");
+
+ indexHtml = fs.read(path.join(src, indexHtmlPath));
+
+ if (environment == 'production' && appCache) {
+ indexHtml = indexHtml.replace('<html manifest=""', '<html manifest="cache.manifest"');
+ }
+
+ fs.minify(path.join(sdk, 'microloader', (environment == 'production' ? 'production' : 'testing')+'.js'), null, 'closurecompiler', function(content) {
+ indexHtml = indexHtml.replace(/<script id="microloader"([^<]+)<\/script>/,
+ '<script type="text/javascript">' +
+ content + ';Ext.blink(' + (environment == 'production' ? JSON.stringify({
+ id: config.id
+ }) : appJson) + ')' +
+ '</script>');
+
+ fs.write(path.join(destination, indexHtmlPath), indexHtml);
+ this.info("Embedded microloader into " + indexHtmlPath);
+
+ if (callback) {
+ callback();
+ }
+ }.bind(this));
+ }.bind(this);
+
+ this.info("Resolving your application dependencies ("+appUrl+")");
+
+ this.resolve(appUrl, null, function(dependencies) {
+ this.info("Found " + dependencies.length + " dependencies. Concatenating all into '" + appJs + "'");
+
+ files = dependencies.map(function(dependency) {
+ return path.join(src, dependency.path);
+ });
+
+ files.push(appJs);
+
+ fs.concat(files, appJs + '.' + temp, "\n");
+
+ nodeFs.unlinkSync(appJs);
+ nodeFs.renameSync(appJs + '.' + temp, appJs);
+
+ processedAssetsCount = 0;
+ assetsCount = assets.length;
+ assets.forEach(function(asset) {
+ file = asset.path;
+ destinationFile = path.join(destination, file);
+
+ if (asset.type == 'js') {
+ fs.write(destinationFile, preprocessor.process(destinationFile));
+ this.info("Processed " + file);
+ }
+
+ if (environment == 'testing') {
+ return;
+ }
+
+ this.info("Minifying " + file);
+
+ fs.minify(destinationFile, destinationFile, null, function(destinationFile, file, asset) {
+ this.info("Minified " + file);
+
+ if (environment == 'production') {
+ var version = fs.checksum(destinationFile);
+ asset.version = version;
+
+ fs.prependFile(destinationFile, '/*' + version + '*/');
+ fs.copyFile(destinationFile, path.join(archive, file, version));
+
+ if (asset.update === 'delta') {
+ nodeFs.readdirSync(path.join(archive, file)).forEach(function(archivedVersion) {
+ if (archivedVersion === version) {
+ return;
+ }
+
+ var deltaFile = path.join(destination, 'deltas', file, archivedVersion + '.json');
+
+ fs.write(deltaFile, '');
+ fs.delta(
+ path.join(archive, file, archivedVersion), destinationFile, deltaFile,
+ function() {
+ this.info("Generated delta for: '" + file + "' from hash: '" +
+ archivedVersion + "' to hash: '" + version + "'");
+ }.bind(this)
+ );
+
+ }, this);
+ }
+ }
+
+ if (++processedAssetsCount == assetsCount) {
+ processIndex(function() {
+ if (environment == 'production' && appCache) {
+ appCache.cache = appCache.cache.map(function(cache) {
+ var checksum = '';
+
+ if (!/^(\/|(.*):\/\/)/.test(cache)) {
+ this.info("Generating checksum for appCache item: " + cache);
+ checksum = fs.checksum(path.join(destination, cache));
+ }
+
+ return {
+ uri: cache,
+ checksum: checksum
+ }
+ }, this);
+
+ fs.write(path.join(destination, 'cache.manifest'), this.getTemplate('cache.manifest').apply(appCache));
+ this.info("Generated cache.manifest");
+ }
+
+ if (nativePackaging) {
+ packagerJson = fs.read(path.join(src, 'packager.json'));
+ packagerConfig = Ext.JSON.decode(packagerJson);
+
+ if (packagerConfig.platform.match(/iOS/)) {
+ fs.copyDirectory(path.join(src, 'resources', 'icons'), destination);
+ fs.copyDirectory(path.join(src, 'resources', 'loading'), destination);
+ }
+
+ packagerConfig.inputPath = destination;
+ packagerConfig.outputPath = path.resolve(config.buildPaths.native);
+ fs.mkdir(packagerConfig.outputPath);
+ fs.writeJson(path.join(src, 'packager.temp.json'), packagerConfig);
+
+ this.info("Packaging your application as a native app...");
+
+ this.getModule('package').run('packager.temp.json', function() {
+ nodeFs.unlinkSync(path.join(src, 'packager.temp.json'));
+ });
+ }
+ }.bind(this));
+ }
+ }.bind(this, destinationFile, file, asset));
+ }, this);
+
+ if (environment == 'testing') {
+ processIndex();
+ }
+
+ }.bind(this), function() {
+ this.error("Failed loading your application from: '"+appUrl+"'. " + (!config.url ? "Try setting the absolute URL to your application for the 'url' item inside 'app.json'" : ""));
+ }.bind(this));
+ }
+});
View
316 st/mvc/sdk-2.0.1-rc-backup/command/src/module/FileSystem.js
@@ -0,0 +1,316 @@
+/**
+ * @class Command.module.FileSystem
+ * @author Jacky Nguyen <jacky@sencha.com>
+ */
+Ext.define('Command.module.FileSystem', {
+ extend: 'Command.module.Abstract',
+
+ description: 'A set of useful utility actions to work with files. ' +
+ 'Most commonly used actions are: concat, minify, delta',
+
+ actions: {
+ concat: [
+ "Concatenate multiple files into one",
+ ['from', 'f', 'List of files to concatenate, comma-separated', 'array', null, 'foo.js,bar.js,baz.js'],
+ ['to', 't', 'The destination file to write concatenated content', 'string', null, 'target.js']
+ ],
+ minify: [
+ "Minify a JavaScript file, currently support YUICompressor (default), Closure Compiler and UglifyJS",
+ ['from', 'f', 'Path to the file to minify', 'string', null, 'app.js'],
+ ['to', 't', 'Path to the destination file to write minified content to.', 'string', null, 'app-minified.js'],
+ ['compressor', 'c',
+ 'The name of the compressor to use, can be either: "yuicompressor", ' +
+ '"uglifyjs" or "closurecompiler". Defaults to "yuicompressor"', 'string', 'yuicompressor', 'uglifyjs']
+ ],
+ delta: [
+ "Generates deltas between two files in JSON format",
+ ['from', 'f', 'Path to the dictionary file', 'string', null, 'version1.js'],
+ ['to', 't', 'Path to the target file to compare to', 'string', null, 'version2.js'],
+ ['delta', 'd', 'Path to a JSON file to write the delta content to', 'string', null, 'delta.json']
+ ]
+ },
+
+ /**
+ * Concatenate multiple files into one
+ * @param fromFiles
+ * @param toFile
+ */
+ concat: function(fromFiles, toFile, separator) {
+ var fs = require('fs'),
+ i, ln, fromFile, fd;
+
+ separator = separator || '';
+
+ fd = fs.openSync(toFile, 'w');
+
+ for (i = 0,ln = fromFiles.length; i < ln; i++) {
+ fromFile = fromFiles[i];
+ fs.writeSync(fd, this.read(fromFile) + separator);
+ }
+
+ fs.closeSync(fd);
+ },
+
+ /**
+ * Minify a JavaScript file, currently support YUICompressor (default), Closure Compiler and UglifyJS
+ * @param fromFiles
+ * @param toFile
+ */
+ minify: function(fromFile, toFile, compressor, callback) {
+ var command, jarPath, toArg, content;
+
+ callback = callback || Ext.emptyFn;
+
+ if (compressor === 'uglifyjs') {
+ var uglifyjs = require('uglify-js'),
+ jsp = uglifyjs.parser,
+ pro = uglifyjs.uglify,
+ ast = jsp.parse(this.read(fromFile));
+
+ ast = pro.ast_mangle(ast); // get a new AST with mangled names
+ ast = pro.ast_squeeze(ast); // get an AST with compression optimizations
+ content = pro.gen_code(ast);
+
+ if (toFile) {
+ this.write(toFile, content);
+ callback();
+ }
+ else {
+ callback(content);
+ }
+ }
+ else {
+ if (compressor === 'closurecompiler') {
+ command = 'java -jar %s ' + (toFile ? '--js_output_file %s' : '%s') + ' --js %s';
+ jarPath = this.getBinaryPath('closurecompiler.jar');
+ }
+ else {
+ command = 'java -jar %s ' + (toFile ? '-o %s' : '%s') + ' %s';
+ jarPath = this.getBinaryPath('yuicompressor.jar');
+ }
+
+ this.exec(command, [jarPath, toFile, fromFile], function(error, stdout, stderr) {
+ if (error) {
+ this.error(error);
+ this.error(stderr);
+ }
+ else {
+ if (!toFile) {
+ callback(stdout);
+ }
+ else {
+ if (stdout) {
+ this.info(stdout);
+ }
+ callback();
+ }
+ }
+ });
+ }
+ },
+
+ /**
+ * Generates deltas between two files in JSON format
+ * @param fromFile
+ * @param toFile
+ * @param delta
+ */
+ delta: function(fromFile, toFile, delta, callback) {
+ this.exec('%s encode -json -dictionary %s -target %s -delta %s --stats', [
+ this.getBinaryPath('vcdiff'),
+ fromFile,
+ toFile,
+ delta
+ ], function(error, stdout, stderr) {
+ if (error) {
+ this.error(stderr);
+ }
+ else {
+ if (stdout) {
+ this.info(stdout);
+ }
+
+ // Fix malformed JSON generated from vcdiff (trailing comma), e.g [1,2,3,] -> [1,2,3]
+ var content = this.read(delta);
+ this.write(delta, content.substring(0, content.length - 2) + ']');
+ callback();
+ }
+ });
+ },
+
+ mkdir: function() {
+ var fs = require('fs'),
+ path = require('path'),
+ names = Array.prototype.slice.call(arguments),
+ ln = names.length,
+ i, j, subLn, name, parentDirName, dirNames;
+
+ for (i = 0; i < ln; i++) {
+ name = names[i];
+ dirNames = [];
+
+ while (!path.existsSync(name)) {
+ dirNames.unshift(name);
+ parentDirName = path.dirname(name);
+
+ if (parentDirName === name) {
+ break;
+ }
+
+ name = parentDirName;
+ }
+
+ for (j = 0, subLn = dirNames.length; j < subLn; j++) {
+ name = dirNames[j];
+ fs.mkdirSync(name);
+ }
+ }
+ },
+
+ read: function(file) {
+ return require('fs').readFileSync(file, 'utf8');
+ },
+
+ readJson: function(file) {
+ return Ext.JSON.decode(this.read(file));
+ },
+
+ write: function(file, content) {
+ var path = require('path');
+
+ if (!path.existsSync(file)) {
+ this.mkdir(path.dirname(file));
+ }
+
+ require('fs').writeFileSync(file, content, 'utf8');
+ },
+
+ rename: function(from, to) {
+ return require('fs').renameSync(from, to);
+ },
+
+ removeFile: function(path) {
+ return require('fs').unlinkSync(path);
+ },
+
+ writeJson: function(file, object, beautify) {
+ return this.write(file, beautify ? JSON.stringify(object, null, 4) : JSON.stringify(object));
+ },
+
+ prependFile: function(file, content) {
+ this.write(file, content + this.read(file));
+ },
+
+ appendFile: function(file, content) {
+ var fs = require('fs'),
+ fd = fs.openSync(file, 'a');
+
+ fs.writeSync(fd, content);
+ fs.closeSync(fd);
+ },
+
+ copyFile: function(src, destination, filterFn) {
+ if (typeof filterFn == 'function' && filterFn(src, destination) === false) {
+ return false;
+ }
+
+ var fs = require('fs'),
+ path = require('path');
+
+ if (!path.existsSync(destination)) {
+ this.mkdir(path.dirname(destination));
+ }
+
+ fs.writeFileSync(destination, fs.readFileSync(src));
+ fs.chmodSync(destination, fs.statSync(src).mode.toString(8).substr(-3));
+
+ return true;
+ },
+
+ removeDirectory: function(directory) {
+ var fs = require('fs'),
+ path = require('path'),
+ files, filePath, fileStats, i, filesLength;
+
+ files = fs.readdirSync(directory);
+ filesLength = files.length;
+
+ if (filesLength) {
+ for (i = 0; i < filesLength; i += 1) {
+ filePath = path.join(directory, files[i]);
+
+ fileStats = fs.statSync(filePath);
+
+ if (fileStats.isFile()) {
+ fs.unlinkSync(filePath);
+ }
+ else if (fileStats.isDirectory()) {
+ this.removeDirectory(filePath);
+ }
+ }
+ }
+
+ fs.rmdirSync(directory);
+ },
+
+ copyDirectory: function(src, destination, filterFn) {
+ if (typeof filterFn == 'function' && filterFn(src, destination) === false) {
+ return false;
+ }
+
+ var fs = require('fs'),
+ path = require('path'),
+ files, file, stats, i, ln, link, srcFile, destinationFile;
+
+ this.mkdir(destination);
+
+ files = fs.readdirSync(src);
+
+ for (i = 0,ln = files.length; i < ln; i++) {
+ file = files[i];
+ srcFile = path.join(src, file);
+ destinationFile = path.join(destination, file);
+
+ stats = fs.lstatSync(srcFile);
+
+ if (stats.isDirectory()) {
+ this.copyDirectory(srcFile, destinationFile, filterFn);
+ }
+ else {
+ if (typeof filterFn == 'function' && filterFn(src, destination) === false) {
+ return false;
+ }
+
+ if (stats.isSymbolicLink()) {
+ try {
+ link = fs.readlinkSync(srcFile);
+ fs.symlinkSync(link, destinationFile);
+ }
+ catch (e) {}
+ }
+ else {
+ this.copyFile(srcFile, destinationFile);
+ }
+ }
+ }
+
+ return true;
+ },
+
+ checksum: function(file) {
+ var hash = require('crypto').createHash('sha1');
+
+ hash.update(this.read(file));
+
+ return hash.digest('hex');
+ },
+
+ copy: function(src, destination, filterFn) {
+ if (require('fs').statSync(src).isDirectory()) {
+ return this.copyDirectory(src, destination, filterFn);
+ }
+ else {
+ return this.copyFile(src, destination, filterFn);
+ }
+ }
+});
View
71 st/mvc/sdk-2.0.1-rc-backup/command/src/module/Generate.js
@@ -0,0 +1,71 @@
+Ext.define('Command.module.Generate', {
+ extend: 'Command.module.Abstract',
+
+ description: 'Automates the generation of projects and files',
+
+ actions: {
+ app: [
+ "Generate a new project with the recommended structure",
+ ['name', 'n', 'The namespace of the application to create. ' +
+ 'This will be used as the prefix for all your classes', 'string', null, 'MyApp'],
+ ['path', 'p', 'The directory path to generate this application to.', 'string', null, '/path/to/myapp'],
+ ['library', 'l', "The library's build to develop your application with, either 'core' or 'all'. " +
+ "Defaults to 'core'." +
+ "\n " +
+ "+ Use 'all' if your application make use of almost every class available in the whole framework" +
+ "\n " +
+ "+ Use 'core' if your application only make use of a portion of the framework. " +
+ "\n " +
+ "When you deploy the application, it only includes exactly what it needs.",
+ 'string', 'core', 'all']
+ ],
+ model: [
+ "Generate a Model for an existing project",
+ ['name', 'n', 'The name of the Model to create', 'string', null, 'User'],
+ ['fields', 'f', 'The set of fields to add to the Model', 'array', null, 'id:int,name,email']
+ ],
+ controller: [
+ "Generate a Controller for an existing project",
+ ['name', 'n', 'The name of the Controller to create', 'string', null, 'User']
+ ],
+ profile: [
+ "Generate a Profile for an existing project",
+ ['name', 'n', 'The name of the Profile to create', 'string', null, 'Phone']
+ ]
+ // form: [
+ // "Generate a Form for an existing project",
+ // ['name', 'n', 'The name of the Form to create', 'string', null, 'User'],
+ // ['fields', 'f', 'The set of fields to add to the Form', 'string', null, 'name:string,email:email,message:string']
+ // ]
+ },
+
+ /**
+ * For each action defined above we automatically create the function that invokes its generator. This just creates
+ * those functions, passing the arguments in as an object instead of an array
+ */
+ constructor: function() {
+ var actions = this.actions,
+ actionName;
+
+ for (actionName in actions) {
+ this[actionName] = function(actionName) {
+ return function() {
+ var params = this.actions[actionName].slice(1),
+ length = params.length,
+ args = [],
+ paramName, i;
+
+ for (i = 0; i < length; i++) {
+ paramName = params[i][0];
+
+ args[paramName] = arguments[i];
+ }
+
+ Ext.create('Command.module.generate.' + Ext.String.capitalize(actionName), args, this.cli);
+ };
+ }(actionName);
+ }
+
+ this.callParent(arguments);
+ }
+});
View
156 st/mvc/sdk-2.0.1-rc-backup/command/src/module/Manifest.js
@@ -0,0 +1,156 @@
+/**
+ * @class Command.module.Manifest
+ * @author Jacky Nguyen <jacky@sencha.com>
+ */
+Ext.define('Command.module.Manifest', {
+ extend: 'Command.module.Abstract',
+
+ description: 'Extract class metadata',
+
+ actions: {
+ create: [
+ "Generate a list of metadata for all classes found in the given directories",
+ ['path', 'p', 'The directory path(s) that contains all classes', 'array', null, '/path/to/src,/path/to/another/src'],
+ ['output', 'o', 'The file path to write the results to in JSON format.', 'string', null, 'metadata.json']
+ ]
+ },
+
+ compareAst: function(branch, matcher) {
+ var i, ln, toBranch, fromBranch;
+
+ for (i = 0,ln = matcher.length; i < ln; i++) {
+ toBranch = matcher[i];
+ fromBranch = branch[i];
+
+ if (Ext.isArray(toBranch)) {
+ if (!this.compareAst(fromBranch, toBranch)) {
+ return false;
+ }
+ }
+ else {
+ if (toBranch !== undefined && toBranch !== fromBranch) {
+ return false;
+ }
+ }
+ }
+
+ return true;
+ },
+
+ walkAst: function(ast, matcher, single, matches) {
+ var i, ln, block;
+
+ if (!single && !matches) {
+ matches = [];
+ }
+
+ for (i = 0, ln = ast.length; i < ln; i++) {
+ block = ast[i];
+
+ if (Ext.isArray(block)) {
+ if (this.compareAst(block, matcher)) {
+ if (!single) {
+ matches.push(block);
+ }
+ else {
+ return block;
+ }
+ }
+
+ if (!single) {
+ this.walkAst(block, matcher, single, matches);
+ }
+ else {
+ return this.walkAst(block, matcher, single, matches);
+ }
+ }
+ }
+
+ return matches || null;
+ },
+
+ create: function(paths, output) {
+ var uglifyjs = require('uglify-js'),
+ findit = require('findit'),
+ fsModule = this.getModule('fs'),
+ fileNameMatcher = /\.js$/,
+ parser = uglifyjs.parser,
+ assembler = uglifyjs.uglify,
+ properties = {
+ extend: true,
+ singleton: true,
+ requires: true,
+ alias: true,
+ mixins: true,
+ alternateClassName: true
+ },
+ defineMatcher = [
+ "stat",
+ [
+ "call",
+ [
+ "dot",
+ [
+ "name",
+ "Ext"
+ ],
+ "define"
+ ],
+ [
+ [
+ "string",
+ undefined
+ ],
+ [
+ "object"
+ ]
+ ]
+ ]
+ ],
+ results = [],
+ ast, files,
+ match, body, metadata;
+
+ paths.forEach(function(path) {
+ files = findit.sync(path);
+
+ files.forEach(function(file) {
+ if (fileNameMatcher.test(file)) {
+ try {
+ ast = parser.parse(fsModule.read(file));
+ }
+ catch (e) {
+ throw new Error(require('util').format(
+ "Failed parsing file: %s\nReason: %s\nLine: %s\nColumn: %s",
+ file, e.message, e.line, e.col
+ ));
+ }
+
+ match = this.walkAst(ast, defineMatcher, true);
+
+ if (match) {
+ metadata = {};
+ metadata.name = match[1][2][0][1];
+
+ body = match[1][2][1][1];
+
+ body.forEach(function(property) {
+ if (properties.hasOwnProperty(property[0])) {
+ metadata[property[0]] = eval("(" + assembler.gen_code(property[1]) + ")");
+ }
+ });
+
+ results.push(metadata);
+ }
+ }
+ }, this);
+
+ }, this);
+
+ if (output) {
+ fsModule.write(output, JSON.stringify(results, null, 4));
+ }
+
+ return output;
+ }
+});
View
61 st/mvc/sdk-2.0.1-rc-backup/command/src/module/Package.js
@@ -0,0 +1,61 @@
+Ext.define('Command.module.Package', {
+ extend: 'Command.module.Abstract',
+ description: "Packages a Sencha Touch 2 application for native app stores",
+
+ actions: {
+ generate: [
+ "Generates a Packager configuration JSON file",
+ ['path', 'p', 'What to call the configuration file', 'string', 'packager.json', 'myconfigfile.json']
+ ],
+
+ build: [
+ "Packages an app with the given configuration JSON file",
+ ['path', 'p', 'What to call the configuration file', 'string', 'packager.json', 'myconfigfile.json']
+ ],
+
+ run: [
+ "Packages and tries to run the application for the given configuration JSON file",
+ ['path', 'p', 'What to call the configuration file', 'string', 'packager.json', 'myconfigfile.json']
+ ]
+ },
+
+ generate: function(fileName) {
+ this.exec('stbuild generate %s', [fileName], function(error, stdout, stderr) {
+ if (stdout) {
+ this.info(stdout);
+ }
+
+ if (stderr) {
+ this.error(stderr);
+ }
+ });
+ },
+
+ build: function(fileName) {
+ this.exec('stbuild package %s', [fileName], function(error, stdout, stderr) {
+ if (stdout) {
+ this.info(stdout);
+ }
+
+ if (stderr) {
+ this.error(stderr);
+ }
+ });
+ },
+
+ run: function(fileName, callback) {
+ this.exec('stbuild run %s', [fileName], function(error, stdout, stderr) {
+ if (callback) {
+ callback();
+ }
+
+ if (stdout) {
+ this.info(stdout);
+ }
+
+ if (stderr) {
+ this.error(stderr);
+ }
+ });
+ }
+});
View
82 st/mvc/sdk-2.0.1-rc-backup/command/src/module/Project.js
@@ -0,0 +1,82 @@
+Ext.define('Command.module.Project', {
+ extend: 'Command.module.Abstract',
+
+ description: 'Utility actions to work a project',
+
+ actions: {
+ create: [
+ "Generate a new project with the recommended structure",
+ ['name', 'p', 'The name of the application to create', 'string', null, 'MyApp']
+ ]
+ },
+
+ constructor: function() {
+ this.templates = {};
+
+ this.callParent(arguments);
+ },
+
+ create: function(name) {
+ this.args = {
+ name: name
+ };
+
+ console.log(this.args);
+
+ this.createDirectories(name);
+ this.copyFiles(name);
+
+ },
+
+ createDirectories: function(name) {
+ var fs = require('fs'),
+ path = require('path');
+
+ fs.mkdirSync(name);
+
+ fs.mkdirSync(path.join(name, 'app'));
+ fs.mkdirSync(path.join(name, 'app', 'model'));
+ fs.mkdirSync(path.join(name, 'app', 'view'));
+ fs.mkdirSync(path.join(name, 'app', 'controller'));
+ fs.mkdirSync(path.join(name, 'app', 'store'));
+ fs.mkdirSync(path.join(name, 'app', 'profile'));
+
+ fs.mkdirSync(path.join(name, 'deploy'));
+ },
+
+ template: function(template, destination) {
+ var fs = require('fs'),
+ path = require('path');
+
+ template = this.getTemplate(template);
+
+ console.log(template.apply(this.args));
+
+ fs.writeFile(path || template, template.apply(this.args));
+ },
+
+ copyFiles: function(name) {
+ var fs = require('fs'),
+ path = require('path');
+
+ this.template('index.html')
+ },
+
+ getTemplate: function(name) {
+ var templates = this.templates,
+ template = templates[name],
+ filePath;
+
+ if (!template) {
+ filePath = require('path').resolve(this.cli.getCurrentPath(), 'src/module/Project/templates/' + name + '.tpl');
+ templates[name] = template = Ext.create('Ext.XTemplate', this.getModule('fs').read(filePath));
+ }
+
+ return template;
+ }
+});
+
+// this.log("Generate application at " + path + " with namespace: " + namespace);
+// this.info("Generate application at " + path + " with namespace: " + namespace);
+// this.warn("Generate application at " + path + " with namespace: " + namespace);
+// this.error("Generate application at " + path + " with namespace: " + namespace);
View
22 st/mvc/sdk-2.0.1-rc-backup/command/src/module/Test.js
@@ -0,0 +1,22 @@
+/**
+ * @class Command.module.Test
+ * @author Jacky Nguyen <jacky@sencha.com>
+ */
+Ext.define('Command.module.Test', {
+ extend: 'Command.module.Abstract',
+
+ description: 'Unit testing using Jasmine',
+
+ actions: {
+ run: [
+ "Run Jasmine's unit tests",
+ ['path', 'p', 'The *absolute* path to the directory that contains all spec files', 'string', null, '/path/to/specs'],
+ ['verbose', 'v', 'Whether to print extra information per each test run', 'boolean', false, 'yes'],
+ ['color', 'c', 'Whether to use color coding for output', 'boolean', true, 'no']
+ ]
+ },
+
+ run: function(path, verbose, color) {
+ require('jasmine-node').executeSpecsInFolder(path, Ext.emptyFn, verbose, color);
+ }
+});
View
66 st/mvc/sdk-2.0.1-rc-backup/command/src/module/generate/App.js
@@ -0,0 +1,66 @@
+Ext.define('Command.module.generate.App', {
+ extend: 'Command.module.generate.Generator',
+
+ description: 'Automates the generation of a new project',
+
+ getUniqueId: function() {
+ return require('node-uuid').v1();
+ },
+
+ execute: function(args) {
+ var path = require('path'),
+ cwd = process.cwd(),
+ sdkVersionFile = path.join(cwd, 'version.txt'),
+ sdkVersion = new Ext.Version(require('fs').readFileSync(sdkVersionFile, 'utf8').trim()),
+ appPath = path.resolve(args.path);
+
+ this.mkdir(
+ appPath,
+ path.join(appPath, 'app'),
+ path.join(appPath, 'app', 'model'),
+ path.join(appPath, 'app', 'view'),
+ path.join(appPath, 'app', 'controller'),
+ path.join(appPath, 'app', 'store'),
+ path.join(appPath, 'app', 'profile'),
+ path.join(appPath, 'sdk'),
+ path.join(appPath, 'sdk', 'src'),
+ path.join(appPath, 'sdk', 'resources'),
+ path.join(appPath, 'resources'),
+ path.join(appPath, 'resources', 'css'),
+ path.join(appPath, 'resources', 'images'),<