jazz-jss 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (215) hide show
  1. data/dist/handlebars/handlebars.js +1493 -0
  2. data/dist/hashchange/{jquery.ba-hashchange.js → hashchange.js} +0 -0
  3. data/dist/jazz/lib/controller.js +1 -1
  4. data/dist/jazz/lib/core.js +3 -0
  5. data/dist/jazz/lib/db.js +1 -1
  6. data/dist/jazz/lib/helper.js +2 -1
  7. data/dist/jazz/lib/model.js +11 -4
  8. data/dist/jazz/lib/view.js +1 -1
  9. data/dist/jazz/module.js +15 -0
  10. data/dist/jquery/jquery.js +0 -0
  11. data/dist/require/require.js +0 -0
  12. data/dist/require/template.js +98 -0
  13. data/dist/underscore/underscore.js +0 -0
  14. data/lib/jazz/app_detector.rb +6 -3
  15. data/lib/jazz/app_generator.rb +12 -8
  16. data/lib/jazz/helper_generator.rb +30 -0
  17. data/lib/jazz/scaffold_generator.rb +4 -0
  18. data/templates/app_root/Rakefile +11 -0
  19. data/templates/app_root/{app → development/app}/assets/javascripts/application.js +0 -0
  20. data/templates/app_root/{app → development/app}/assets/stylesheets/application.css +0 -0
  21. data/templates/app_root/development/app/controllers/application_controller.js +11 -0
  22. data/templates/app_root/development/app/helpers/application_helper.js +7 -0
  23. data/templates/app_root/development/config/glue.js +9 -0
  24. data/templates/app_root/development/config/routes.js +5 -0
  25. data/templates/app_root/scripts/build.js +30 -0
  26. data/templates/app_root/scripts/r.js/LICENSE +58 -0
  27. data/templates/app_root/scripts/r.js/README.md +177 -0
  28. data/templates/app_root/scripts/r.js/build/build.js +26 -0
  29. data/templates/app_root/scripts/r.js/build/buildebug.sh +4 -0
  30. data/templates/app_root/scripts/r.js/build/example.build.js +296 -0
  31. data/templates/app_root/scripts/r.js/build/jslib/blank.js +4 -0
  32. data/templates/app_root/scripts/r.js/build/jslib/build.js +952 -0
  33. data/templates/app_root/scripts/r.js/build/jslib/commandLine.js +23 -0
  34. data/templates/app_root/scripts/r.js/build/jslib/commonJs.js +152 -0
  35. data/templates/app_root/scripts/r.js/build/jslib/env.js +47 -0
  36. data/templates/app_root/scripts/r.js/build/jslib/lang.js +49 -0
  37. data/templates/app_root/scripts/r.js/build/jslib/logger.js +58 -0
  38. data/templates/app_root/scripts/r.js/build/jslib/node.js +106 -0
  39. data/templates/app_root/scripts/r.js/build/jslib/node/args.js +20 -0
  40. data/templates/app_root/scripts/r.js/build/jslib/node/file.js +263 -0
  41. data/templates/app_root/scripts/r.js/build/jslib/node/load.js +17 -0
  42. data/templates/app_root/scripts/r.js/build/jslib/node/optimize.js +10 -0
  43. data/templates/app_root/scripts/r.js/build/jslib/node/print.js +16 -0
  44. data/templates/app_root/scripts/r.js/build/jslib/optimize.js +279 -0
  45. data/templates/app_root/scripts/r.js/build/jslib/opto.build.js +11 -0
  46. data/templates/app_root/scripts/r.js/build/jslib/parse.js +590 -0
  47. data/templates/app_root/scripts/r.js/build/jslib/pragma.js +251 -0
  48. data/templates/app_root/scripts/r.js/build/jslib/requirePatch.js +286 -0
  49. data/templates/app_root/scripts/r.js/build/jslib/rhino.js +22 -0
  50. data/templates/app_root/scripts/r.js/build/jslib/rhino/args.js +21 -0
  51. data/templates/app_root/scripts/r.js/build/jslib/rhino/file.js +244 -0
  52. data/templates/app_root/scripts/r.js/build/jslib/rhino/load.js +12 -0
  53. data/templates/app_root/scripts/r.js/build/jslib/rhino/optimize.js +100 -0
  54. data/templates/app_root/scripts/r.js/build/jslib/rhino/print.js +12 -0
  55. data/templates/app_root/scripts/r.js/build/jslib/uglifyjs/README.md +16 -0
  56. data/templates/app_root/scripts/r.js/build/jslib/uglifyjs/index.js +21 -0
  57. data/templates/app_root/scripts/r.js/build/jslib/uglifyjs/parse-js.js +1342 -0
  58. data/templates/app_root/scripts/r.js/build/jslib/uglifyjs/process.js +2005 -0
  59. data/templates/app_root/scripts/r.js/build/jslib/uglifyjs/squeeze-more.js +55 -0
  60. data/templates/app_root/scripts/r.js/build/jslib/x.js +243 -0
  61. data/templates/app_root/scripts/r.js/build/tests/all.js +47 -0
  62. data/templates/app_root/scripts/r.js/build/tests/allj.sh +3 -0
  63. data/templates/app_root/scripts/r.js/build/tests/alln.sh +18 -0
  64. data/templates/app_root/scripts/r.js/build/tests/anonSimple.build.js +7 -0
  65. data/templates/app_root/scripts/r.js/build/tests/buildUtils.js +19 -0
  66. data/templates/app_root/scripts/r.js/build/tests/builds.js +489 -0
  67. data/templates/app_root/scripts/r.js/build/tests/circular.build.js +18 -0
  68. data/templates/app_root/scripts/r.js/build/tests/convert.js +18 -0
  69. data/templates/app_root/scripts/r.js/build/tests/css.build.js +6 -0
  70. data/templates/app_root/scripts/r.js/build/tests/css/common/common.css +4 -0
  71. data/templates/app_root/scripts/r.js/build/tests/css/master.css +10 -0
  72. data/templates/app_root/scripts/r.js/build/tests/css/sub/sub1.css +7 -0
  73. data/templates/app_root/scripts/r.js/build/tests/cssTestCompare.css +13 -0
  74. data/templates/app_root/scripts/r.js/build/tests/end.frag +3 -0
  75. data/templates/app_root/scripts/r.js/build/tests/expected/unoExcludeShallow.js +23 -0
  76. data/templates/app_root/scripts/r.js/build/tests/exports.build.js +12 -0
  77. data/templates/app_root/scripts/r.js/build/tests/hasTestModule.build.js +10 -0
  78. data/templates/app_root/scripts/r.js/build/tests/hasTestModule.js +30 -0
  79. data/templates/app_root/scripts/r.js/build/tests/http/httpBuild.js +70 -0
  80. data/templates/app_root/scripts/r.js/build/tests/http/main.html +28 -0
  81. data/templates/app_root/scripts/r.js/build/tests/http/scripts/main.js +18 -0
  82. data/templates/app_root/scripts/r.js/build/tests/http/scripts/one.js +3 -0
  83. data/templates/app_root/scripts/r.js/build/tests/http/scripts/three.js +5 -0
  84. data/templates/app_root/scripts/r.js/build/tests/http/scripts/two.js +7 -0
  85. data/templates/app_root/scripts/r.js/build/tests/i18n.build.js +17 -0
  86. data/templates/app_root/scripts/r.js/build/tests/indexBuilder.build.js +8 -0
  87. data/templates/app_root/scripts/r.js/build/tests/lib/amdefine/a.js +17 -0
  88. data/templates/app_root/scripts/r.js/build/tests/lib/amdefine/b.js +8 -0
  89. data/templates/app_root/scripts/r.js/build/tests/lib/amdefine/build.js +6 -0
  90. data/templates/app_root/scripts/r.js/build/tests/lib/amdefine/c.js +7 -0
  91. data/templates/app_root/scripts/r.js/build/tests/lib/amdefine/d.js +5 -0
  92. data/templates/app_root/scripts/r.js/build/tests/lib/amdefine/expected.js +36 -0
  93. data/templates/app_root/scripts/r.js/build/tests/lib/amdefine/node_modules/amdefine/LICENSE +58 -0
  94. data/templates/app_root/scripts/r.js/build/tests/lib/amdefine/node_modules/amdefine/amdefine.js +188 -0
  95. data/templates/app_root/scripts/r.js/build/tests/lib/amdefine/node_modules/amdefine/package.json +21 -0
  96. data/templates/app_root/scripts/r.js/build/tests/lib/comments/bang.js +10 -0
  97. data/templates/app_root/scripts/r.js/build/tests/lib/comments/build.js +6 -0
  98. data/templates/app_root/scripts/r.js/build/tests/lib/comments/expected.js +9 -0
  99. data/templates/app_root/scripts/r.js/build/tests/lib/comments/license.js +13 -0
  100. data/templates/app_root/scripts/r.js/build/tests/lib/dotpackage/scripts/app.build.js +15 -0
  101. data/templates/app_root/scripts/r.js/build/tests/lib/dotpackage/scripts/main-expected.js +13 -0
  102. data/templates/app_root/scripts/r.js/build/tests/lib/dotpackage/scripts/main.js +7 -0
  103. data/templates/app_root/scripts/r.js/build/tests/lib/empty/build.js +13 -0
  104. data/templates/app_root/scripts/r.js/build/tests/lib/empty/expected.js +8 -0
  105. data/templates/app_root/scripts/r.js/build/tests/lib/empty/main.js +1 -0
  106. data/templates/app_root/scripts/r.js/build/tests/lib/empty/sub1.js +1 -0
  107. data/templates/app_root/scripts/r.js/build/tests/lib/empty/sub2.js +1 -0
  108. data/templates/app_root/scripts/r.js/build/tests/lib/nameInsertion/build.js +6 -0
  109. data/templates/app_root/scripts/r.js/build/tests/lib/nameInsertion/expected.js +12 -0
  110. data/templates/app_root/scripts/r.js/build/tests/lib/nameInsertion/main.js +9 -0
  111. data/templates/app_root/scripts/r.js/build/tests/lib/namespace/build.js +8 -0
  112. data/templates/app_root/scripts/r.js/build/tests/lib/namespace/expected.js +47 -0
  113. data/templates/app_root/scripts/r.js/build/tests/lib/namespace/main.js +6 -0
  114. data/templates/app_root/scripts/r.js/build/tests/lib/namespace/modules/four.js +7 -0
  115. data/templates/app_root/scripts/r.js/build/tests/lib/namespace/modules/one.js +9 -0
  116. data/templates/app_root/scripts/r.js/build/tests/lib/namespace/modules/three.js +14 -0
  117. data/templates/app_root/scripts/r.js/build/tests/lib/namespace/modules/two.js +5 -0
  118. data/templates/app_root/scripts/r.js/build/tests/lib/nested/a.js +12 -0
  119. data/templates/app_root/scripts/r.js/build/tests/lib/nested/b.js +3 -0
  120. data/templates/app_root/scripts/r.js/build/tests/lib/nested/build.js +6 -0
  121. data/templates/app_root/scripts/r.js/build/tests/lib/nested/buildWithCE.js +7 -0
  122. data/templates/app_root/scripts/r.js/build/tests/lib/nested/c.js +3 -0
  123. data/templates/app_root/scripts/r.js/build/tests/lib/nested/d.js +3 -0
  124. data/templates/app_root/scripts/r.js/build/tests/lib/nested/e.js +3 -0
  125. data/templates/app_root/scripts/r.js/build/tests/lib/nested/expected-built.js +36 -0
  126. data/templates/app_root/scripts/r.js/build/tests/lib/nested/expected-builtWithCE.js +42 -0
  127. data/templates/app_root/scripts/r.js/build/tests/lib/nested/main.js +3 -0
  128. data/templates/app_root/scripts/r.js/build/tests/lib/nested/top.js +10 -0
  129. data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/a.js +3 -0
  130. data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/b.js +3 -0
  131. data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/build.js +6 -0
  132. data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/buildNeedAll.js +9 -0
  133. data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/buildNeedB.js +11 -0
  134. data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/buildNeedC.js +11 -0
  135. data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/buildNeedD.js +11 -0
  136. data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/buildNested.js +7 -0
  137. data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/c.js +3 -0
  138. data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/d.js +3 -0
  139. data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/expected-built.js +21 -0
  140. data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/expected-builtNeedAll.js +31 -0
  141. data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/expected-builtNeedB.js +24 -0
  142. data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/expected-builtNeedC.js +24 -0
  143. data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/expected-builtNeedD.js +25 -0
  144. data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/expected-builtNested.js +31 -0
  145. data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/main.js +17 -0
  146. data/templates/app_root/scripts/r.js/build/tests/lib/plugins/build.js +6 -0
  147. data/templates/app_root/scripts/r.js/build/tests/lib/plugins/converter.js +11 -0
  148. data/templates/app_root/scripts/r.js/build/tests/lib/plugins/main.js +6 -0
  149. data/templates/app_root/scripts/r.js/build/tests/lib/plugins/plug.js +29 -0
  150. data/templates/app_root/scripts/r.js/build/tests/lib/plugins/util.js +7 -0
  151. data/templates/app_root/scripts/r.js/build/tests/nameOnly.build.js +10 -0
  152. data/templates/app_root/scripts/r.js/build/tests/nodeAll.js +3 -0
  153. data/templates/app_root/scripts/r.js/build/tests/nodeOptimize.js +12 -0
  154. data/templates/app_root/scripts/r.js/build/tests/nodeOptimizeNoCallback.js +10 -0
  155. data/templates/app_root/scripts/r.js/build/tests/order.build.js +16 -0
  156. data/templates/app_root/scripts/r.js/build/tests/override/override.js +36 -0
  157. data/templates/app_root/scripts/r.js/build/tests/packages.build.js +59 -0
  158. data/templates/app_root/scripts/r.js/build/tests/parse.js +103 -0
  159. data/templates/app_root/scripts/r.js/build/tests/simple.build.js +13 -0
  160. data/templates/app_root/scripts/r.js/build/tests/simpleNamespace.build.js +17 -0
  161. data/templates/app_root/scripts/r.js/build/tests/start.frag +4 -0
  162. data/templates/app_root/scripts/r.js/build/tests/text.build.js +16 -0
  163. data/templates/app_root/scripts/r.js/build/tests/textExclude.build.js +16 -0
  164. data/templates/app_root/scripts/r.js/dist.js +95 -0
  165. data/templates/app_root/scripts/r.js/dist/README.md +6 -0
  166. data/templates/app_root/scripts/r.js/dist/r-1.0.0.js +9042 -0
  167. data/templates/app_root/scripts/r.js/dist/r-edge.js +9191 -0
  168. data/templates/app_root/scripts/r.js/dist/r.js +9099 -0
  169. data/templates/app_root/scripts/r.js/lib/closure/COPYING +202 -0
  170. data/templates/app_root/scripts/r.js/lib/closure/README +292 -0
  171. data/templates/app_root/scripts/r.js/lib/closure/compiler.jar +0 -0
  172. data/templates/app_root/scripts/r.js/lib/rhino/LICENSE +4 -0
  173. data/templates/app_root/scripts/r.js/lib/rhino/js.jar +0 -0
  174. data/templates/app_root/scripts/r.js/require.js +1952 -0
  175. data/templates/app_root/scripts/r.js/tasks.txt +2 -0
  176. data/templates/app_root/scripts/r.js/tests/all.js +49 -0
  177. data/templates/app_root/scripts/r.js/tests/allNode.js +3 -0
  178. data/templates/app_root/scripts/r.js/tests/allj.sh +1 -0
  179. data/templates/app_root/scripts/r.js/tests/alln.sh +2 -0
  180. data/templates/app_root/scripts/r.js/tests/alpha.js +3 -0
  181. data/templates/app_root/scripts/r.js/tests/beta.js +6 -0
  182. data/templates/app_root/scripts/r.js/tests/doh/LICENSE +195 -0
  183. data/templates/app_root/scripts/r.js/tests/doh/README +12 -0
  184. data/templates/app_root/scripts/r.js/tests/doh/_browserRunner.js +855 -0
  185. data/templates/app_root/scripts/r.js/tests/doh/_nodeRunner.js +20 -0
  186. data/templates/app_root/scripts/r.js/tests/doh/_rhinoRunner.js +17 -0
  187. data/templates/app_root/scripts/r.js/tests/doh/_sounds/LICENSE +10 -0
  188. data/templates/app_root/scripts/r.js/tests/doh/_sounds/doh.wav +0 -0
  189. data/templates/app_root/scripts/r.js/tests/doh/_sounds/dohaaa.wav +0 -0
  190. data/templates/app_root/scripts/r.js/tests/doh/_sounds/woohoo.wav +0 -0
  191. data/templates/app_root/scripts/r.js/tests/doh/runner.html +316 -0
  192. data/templates/app_root/scripts/r.js/tests/doh/runner.js +1499 -0
  193. data/templates/app_root/scripts/r.js/tests/doh/runner.sh +3 -0
  194. data/templates/app_root/scripts/r.js/tests/doh/small_logo.png +0 -0
  195. data/templates/app_root/scripts/r.js/tests/node/canvasTest.js +39 -0
  196. data/templates/app_root/scripts/r.js/tests/node/embedded/README.md +15 -0
  197. data/templates/app_root/scripts/r.js/tests/node/embedded/coffee/foo.coffee +1 -0
  198. data/templates/app_root/scripts/r.js/tests/node/embedded/main.js +13 -0
  199. data/templates/app_root/scripts/r.js/tests/node/embedded/scripts/bar.js +13 -0
  200. data/templates/app_root/scripts/r.js/tests/node/index.js +11 -0
  201. data/templates/app_root/scripts/r.js/tests/node/tests/alpha/foo.js +6 -0
  202. data/templates/app_root/scripts/r.js/tests/node/tests/alpha/hello.html +9 -0
  203. data/templates/app_root/scripts/r.js/tests/node/tests/foo.js +3 -0
  204. data/templates/app_root/scripts/r.js/tests/node/tests/server.js +11 -0
  205. data/templates/app_root/scripts/r.js/tests/relative.js +10 -0
  206. data/templates/app_root/scripts/r.js/tests/sub/betaSub.js +3 -0
  207. data/templates/application.js +6 -5
  208. data/templates/boot.js +42 -0
  209. data/templates/helper.js +9 -0
  210. data/templates/index.html +1 -1
  211. metadata +201 -11
  212. data/dist/jazz/main.js +0 -65
  213. data/dist/mustache/mustache.js +0 -324
  214. data/templates/app_root/config/routes.js +0 -4
  215. data/templates/glue.js +0 -4
@@ -0,0 +1,263 @@
1
+ /**
2
+ * @license Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
3
+ * Available via the MIT or new BSD license.
4
+ * see: http://github.com/jrburke/requirejs for details
5
+ */
6
+
7
+ /*jslint plusplus: false, octal:false, strict: false */
8
+ /*global define: false, process: false */
9
+
10
+ define(['fs', 'path'], function (fs, path) {
11
+
12
+ var isWindows = process.platform === 'win32',
13
+ file;
14
+
15
+ function frontSlash(path) {
16
+ return path.replace(/\\/g, '/');
17
+ }
18
+
19
+ function exists(path) {
20
+ if (isWindows && path.charAt(path.length - 1) === '/' &&
21
+ path.charAt(path.length - 2) !== ':') {
22
+ path = path.substring(0, path.length - 1);
23
+ }
24
+
25
+ try {
26
+ fs.statSync(path);
27
+ return true;
28
+ } catch (e) {
29
+ return false;
30
+ }
31
+ }
32
+
33
+ function mkDir(dir) {
34
+ if (!exists(dir)) {
35
+ fs.mkdirSync(dir, 0777);
36
+ }
37
+ }
38
+
39
+ function mkFullDir(dir) {
40
+ var parts = dir.split('/'),
41
+ currDir = '',
42
+ first = true;
43
+
44
+ parts.forEach(function (part) {
45
+ //First part may be empty string if path starts with a slash.
46
+ currDir += part + '/';
47
+ first = false;
48
+
49
+ if (part) {
50
+ mkDir(currDir);
51
+ }
52
+ });
53
+ }
54
+
55
+ file = {
56
+ backSlashRegExp: /\\/g,
57
+ exclusionRegExp: /^\./,
58
+ getLineSeparator: function () {
59
+ return '/';
60
+ },
61
+
62
+ exists: function (fileName) {
63
+ return exists(fileName);
64
+ },
65
+
66
+ parent: function (fileName) {
67
+ var parts = fileName.split('/');
68
+ parts.pop();
69
+ return parts.join('/');
70
+ },
71
+
72
+ /**
73
+ * Gets the absolute file path as a string, normalized
74
+ * to using front slashes for path separators.
75
+ * @param {String} fileName
76
+ */
77
+ absPath: function (fileName) {
78
+ return frontSlash(path.normalize(frontSlash(fs.realpathSync(fileName))));
79
+ },
80
+
81
+ normalize: function (fileName) {
82
+ return frontSlash(path.normalize(fileName));
83
+ },
84
+
85
+ isFile: function (path) {
86
+ return fs.statSync(path).isFile();
87
+ },
88
+
89
+ isDirectory: function (path) {
90
+ return fs.statSync(path).isDirectory();
91
+ },
92
+
93
+ getFilteredFileList: function (/*String*/startDir, /*RegExp*/regExpFilters, /*boolean?*/makeUnixPaths) {
94
+ //summary: Recurses startDir and finds matches to the files that match regExpFilters.include
95
+ //and do not match regExpFilters.exclude. Or just one regexp can be passed in for regExpFilters,
96
+ //and it will be treated as the "include" case.
97
+ //Ignores files/directories that start with a period (.) unless exclusionRegExp
98
+ //is set to another value.
99
+ var files = [], topDir, regExpInclude, regExpExclude, dirFileArray,
100
+ i, stat, filePath, ok, dirFiles, fileName;
101
+
102
+ topDir = startDir;
103
+
104
+ regExpInclude = regExpFilters.include || regExpFilters;
105
+ regExpExclude = regExpFilters.exclude || null;
106
+
107
+ if (file.exists(topDir)) {
108
+ dirFileArray = fs.readdirSync(topDir);
109
+ for (i = 0; i < dirFileArray.length; i++) {
110
+ fileName = dirFileArray[i];
111
+ filePath = path.join(topDir, fileName);
112
+ stat = fs.statSync(filePath);
113
+ if (stat.isFile()) {
114
+ if (makeUnixPaths) {
115
+ //Make sure we have a JS string.
116
+ if (filePath.indexOf("/") === -1) {
117
+ filePath = frontSlash(filePath);
118
+ }
119
+ }
120
+
121
+ ok = true;
122
+ if (regExpInclude) {
123
+ ok = filePath.match(regExpInclude);
124
+ }
125
+ if (ok && regExpExclude) {
126
+ ok = !filePath.match(regExpExclude);
127
+ }
128
+
129
+ if (ok && (!file.exclusionRegExp ||
130
+ !file.exclusionRegExp.test(fileName))) {
131
+ files.push(filePath);
132
+ }
133
+ } else if (stat.isDirectory() &&
134
+ (!file.exclusionRegExp || !file.exclusionRegExp.test(fileName))) {
135
+ dirFiles = this.getFilteredFileList(filePath, regExpFilters, makeUnixPaths);
136
+ files.push.apply(files, dirFiles);
137
+ }
138
+ }
139
+ }
140
+
141
+ return files; //Array
142
+ },
143
+
144
+ copyDir: function (/*String*/srcDir, /*String*/destDir, /*RegExp?*/regExpFilter, /*boolean?*/onlyCopyNew) {
145
+ //summary: copies files from srcDir to destDir using the regExpFilter to determine if the
146
+ //file should be copied. Returns a list file name strings of the destinations that were copied.
147
+ regExpFilter = regExpFilter || /\w/;
148
+
149
+ //Normalize th directory names, but keep front slashes.
150
+ //path module on windows now returns backslashed paths.
151
+ srcDir = frontSlash(path.normalize(srcDir));
152
+ destDir = frontSlash(path.normalize(destDir));
153
+
154
+ var fileNames = file.getFilteredFileList(srcDir, regExpFilter, true),
155
+ copiedFiles = [], i, srcFileName, destFileName;
156
+
157
+ for (i = 0; i < fileNames.length; i++) {
158
+ srcFileName = fileNames[i];
159
+ destFileName = srcFileName.replace(srcDir, destDir);
160
+
161
+ if (file.copyFile(srcFileName, destFileName, onlyCopyNew)) {
162
+ copiedFiles.push(destFileName);
163
+ }
164
+ }
165
+
166
+ return copiedFiles.length ? copiedFiles : null; //Array or null
167
+ },
168
+
169
+ copyFile: function (/*String*/srcFileName, /*String*/destFileName, /*boolean?*/onlyCopyNew) {
170
+ //summary: copies srcFileName to destFileName. If onlyCopyNew is set, it only copies the file if
171
+ //srcFileName is newer than destFileName. Returns a boolean indicating if the copy occurred.
172
+ var parentDir;
173
+
174
+ //logger.trace("Src filename: " + srcFileName);
175
+ //logger.trace("Dest filename: " + destFileName);
176
+
177
+ //If onlyCopyNew is true, then compare dates and only copy if the src is newer
178
+ //than dest.
179
+ if (onlyCopyNew) {
180
+ if (file.exists(destFileName) && fs.statSync(destFileName).mtime.getTime() >= fs.statSync(srcFileName).mtime.getTime()) {
181
+ return false; //Boolean
182
+ }
183
+ }
184
+
185
+ //Make sure destination dir exists.
186
+ parentDir = path.dirname(destFileName);
187
+ if (!file.exists(parentDir)) {
188
+ mkFullDir(parentDir);
189
+ }
190
+
191
+ fs.writeFileSync(destFileName, fs.readFileSync(srcFileName, 'binary'), 'binary');
192
+
193
+ return true; //Boolean
194
+ },
195
+
196
+ /**
197
+ * Reads a *text* file.
198
+ */
199
+ readFile: function (/*String*/path, /*String?*/encoding) {
200
+ if (encoding === 'utf-8') {
201
+ encoding = 'utf8';
202
+ }
203
+ if (!encoding) {
204
+ encoding = 'utf8';
205
+ }
206
+
207
+ var text = fs.readFileSync(path, encoding);
208
+
209
+ //Hmm, would not expect to get A BOM, but it seems to happen,
210
+ //remove it just in case.
211
+ if (text.indexOf('\uFEFF') === 0) {
212
+ text = text.substring(1, text.length);
213
+ }
214
+
215
+ return text;
216
+ },
217
+
218
+ saveUtf8File: function (/*String*/fileName, /*String*/fileContents) {
219
+ //summary: saves a *text* file using UTF-8 encoding.
220
+ file.saveFile(fileName, fileContents, "utf8");
221
+ },
222
+
223
+ saveFile: function (/*String*/fileName, /*String*/fileContents, /*String?*/encoding) {
224
+ //summary: saves a *text* file.
225
+ var parentDir;
226
+
227
+ if (encoding === 'utf-8') {
228
+ encoding = 'utf8';
229
+ }
230
+ if (!encoding) {
231
+ encoding = 'utf8';
232
+ }
233
+
234
+ //Make sure destination directories exist.
235
+ parentDir = path.dirname(fileName);
236
+ if (!file.exists(parentDir)) {
237
+ mkFullDir(parentDir);
238
+ }
239
+
240
+ fs.writeFileSync(fileName, fileContents, encoding);
241
+ },
242
+
243
+ deleteFile: function (/*String*/fileName) {
244
+ //summary: deletes a file or directory if it exists.
245
+ var files, i, stat;
246
+ if (file.exists(fileName)) {
247
+ stat = fs.statSync(fileName);
248
+ if (stat.isDirectory()) {
249
+ files = fs.readdirSync(fileName);
250
+ for (i = 0; i < files.length; i++) {
251
+ this.deleteFile(path.join(fileName, files[i]));
252
+ }
253
+ fs.rmdirSync(fileName);
254
+ } else {
255
+ fs.unlinkSync(fileName);
256
+ }
257
+ }
258
+ }
259
+ };
260
+
261
+ return file;
262
+
263
+ });
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @license RequireJS Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
3
+ * Available via the MIT or new BSD license.
4
+ * see: http://github.com/jrburke/requirejs for details
5
+ */
6
+
7
+ /*jslint strict: false */
8
+ /*global define: false, console: false */
9
+
10
+ define(['fs'], function (fs) {
11
+ function load(fileName) {
12
+ var contents = fs.readFileSync(fileName, 'utf8');
13
+ process.compile(contents, fileName);
14
+ }
15
+
16
+ return load;
17
+ });
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @license Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
3
+ * Available via the MIT or new BSD license.
4
+ * see: http://github.com/jrburke/requirejs for details
5
+ */
6
+
7
+ /*jslint strict: false */
8
+ /*global define: false */
9
+
10
+ define({});
@@ -0,0 +1,16 @@
1
+ /**
2
+ * @license RequireJS Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
3
+ * Available via the MIT or new BSD license.
4
+ * see: http://github.com/jrburke/requirejs for details
5
+ */
6
+
7
+ /*jslint strict: false */
8
+ /*global define: false, console: false */
9
+
10
+ define(function () {
11
+ function print(msg) {
12
+ console.log(msg);
13
+ }
14
+
15
+ return print;
16
+ });
@@ -0,0 +1,279 @@
1
+ /**
2
+ * @license Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
3
+ * Available via the MIT or new BSD license.
4
+ * see: http://github.com/jrburke/requirejs for details
5
+ */
6
+
7
+ /*jslint plusplus: false, nomen: false, regexp: false, strict: false */
8
+ /*global define: false */
9
+
10
+ define([ 'lang', 'logger', 'env!env/optimize', 'env!env/file', 'parse',
11
+ 'pragma', 'uglifyjs/index'],
12
+ function (lang, logger, envOptimize, file, parse,
13
+ pragma, uglify) {
14
+
15
+ var optimize,
16
+ cssImportRegExp = /\@import\s+(url\()?\s*([^);]+)\s*(\))?([\w, ]*)(;)?/g,
17
+ cssUrlRegExp = /\url\(\s*([^\)]+)\s*\)?/g;
18
+
19
+ /**
20
+ * If an URL from a CSS url value contains start/end quotes, remove them.
21
+ * This is not done in the regexp, since my regexp fu is not that strong,
22
+ * and the CSS spec allows for ' and " in the URL if they are backslash escaped.
23
+ * @param {String} url
24
+ */
25
+ function cleanCssUrlQuotes(url) {
26
+ //Make sure we are not ending in whitespace.
27
+ //Not very confident of the css regexps above that there will not be ending
28
+ //whitespace.
29
+ url = url.replace(/\s+$/, "");
30
+
31
+ if (url.charAt(0) === "'" || url.charAt(0) === "\"") {
32
+ url = url.substring(1, url.length - 1);
33
+ }
34
+
35
+ return url;
36
+ }
37
+
38
+ /**
39
+ * Inlines nested stylesheets that have @import calls in them.
40
+ * @param {String} fileName
41
+ * @param {String} fileContents
42
+ * @param {String} [cssImportIgnore]
43
+ */
44
+ function flattenCss(fileName, fileContents, cssImportIgnore) {
45
+ //Find the last slash in the name.
46
+ fileName = fileName.replace(lang.backSlashRegExp, "/");
47
+ var endIndex = fileName.lastIndexOf("/"),
48
+ //Make a file path based on the last slash.
49
+ //If no slash, so must be just a file name. Use empty string then.
50
+ filePath = (endIndex !== -1) ? fileName.substring(0, endIndex + 1) : "";
51
+
52
+ //Make sure we have a delimited ignore list to make matching faster
53
+ if (cssImportIgnore && cssImportIgnore.charAt(cssImportIgnore.length - 1) !== ",") {
54
+ cssImportIgnore += ",";
55
+ }
56
+
57
+ return fileContents.replace(cssImportRegExp, function (fullMatch, urlStart, importFileName, urlEnd, mediaTypes) {
58
+ //Only process media type "all" or empty media type rules.
59
+ if (mediaTypes && ((mediaTypes.replace(/^\s\s*/, '').replace(/\s\s*$/, '')) !== "all")) {
60
+ return fullMatch;
61
+ }
62
+
63
+ importFileName = cleanCssUrlQuotes(importFileName);
64
+
65
+ //Ignore the file import if it is part of an ignore list.
66
+ if (cssImportIgnore && cssImportIgnore.indexOf(importFileName + ",") !== -1) {
67
+ return fullMatch;
68
+ }
69
+
70
+ //Make sure we have a unix path for the rest of the operation.
71
+ importFileName = importFileName.replace(lang.backSlashRegExp, "/");
72
+
73
+ try {
74
+ //if a relative path, then tack on the filePath.
75
+ //If it is not a relative path, then the readFile below will fail,
76
+ //and we will just skip that import.
77
+ var fullImportFileName = importFileName.charAt(0) === "/" ? importFileName : filePath + importFileName,
78
+ importContents = file.readFile(fullImportFileName), i,
79
+ importEndIndex, importPath, fixedUrlMatch, colonIndex, parts;
80
+
81
+ //Make sure to flatten any nested imports.
82
+ importContents = flattenCss(fullImportFileName, importContents);
83
+
84
+ //Make the full import path
85
+ importEndIndex = importFileName.lastIndexOf("/");
86
+
87
+ //Make a file path based on the last slash.
88
+ //If no slash, so must be just a file name. Use empty string then.
89
+ importPath = (importEndIndex !== -1) ? importFileName.substring(0, importEndIndex + 1) : "";
90
+
91
+ //Modify URL paths to match the path represented by this file.
92
+ importContents = importContents.replace(cssUrlRegExp, function (fullMatch, urlMatch) {
93
+ fixedUrlMatch = cleanCssUrlQuotes(urlMatch);
94
+ fixedUrlMatch = fixedUrlMatch.replace(lang.backSlashRegExp, "/");
95
+
96
+ //Only do the work for relative URLs. Skip things that start with / or have
97
+ //a protocol.
98
+ colonIndex = fixedUrlMatch.indexOf(":");
99
+ if (fixedUrlMatch.charAt(0) !== "/" && (colonIndex === -1 || colonIndex > fixedUrlMatch.indexOf("/"))) {
100
+ //It is a relative URL, tack on the path prefix
101
+ urlMatch = importPath + fixedUrlMatch;
102
+ } else {
103
+ logger.trace(importFileName + "\n URL not a relative URL, skipping: " + urlMatch);
104
+ }
105
+
106
+ //Collapse .. and .
107
+ parts = urlMatch.split("/");
108
+ for (i = parts.length - 1; i > 0; i--) {
109
+ if (parts[i] === ".") {
110
+ parts.splice(i, 1);
111
+ } else if (parts[i] === "..") {
112
+ if (i !== 0 && parts[i - 1] !== "..") {
113
+ parts.splice(i - 1, 2);
114
+ i -= 1;
115
+ }
116
+ }
117
+ }
118
+
119
+ return "url(" + parts.join("/") + ")";
120
+ });
121
+
122
+ return importContents;
123
+ } catch (e) {
124
+ logger.trace(fileName + "\n Cannot inline css import, skipping: " + importFileName);
125
+ return fullMatch;
126
+ }
127
+ });
128
+ }
129
+
130
+ optimize = {
131
+ licenseCommentRegExp: /\/\*[\s\S]*?\*\//g,
132
+
133
+ /**
134
+ * Optimizes a file that contains JavaScript content. Optionally collects
135
+ * plugin resources mentioned in a file, and then passes the content
136
+ * through an minifier if one is specified via config.optimize.
137
+ *
138
+ * @param {String} fileName the name of the file to optimize
139
+ * @param {String} outFileName the name of the file to use for the
140
+ * saved optimized content.
141
+ * @param {Object} config the build config object.
142
+ * @param {String} [moduleName] the module name to use for the file.
143
+ * Used for plugin resource collection.
144
+ * @param {Array} [pluginCollector] storage for any plugin resources
145
+ * found.
146
+ */
147
+ jsFile: function (fileName, outFileName, config, moduleName, pluginCollector) {
148
+ var parts = (config.optimize + "").split('.'),
149
+ optimizerName = parts[0],
150
+ keepLines = parts[1] === 'keepLines',
151
+ licenseContents = '',
152
+ fileContents, optFunc, match, comment;
153
+
154
+ fileContents = file.readFile(fileName);
155
+
156
+ //Apply pragmas/namespace renaming
157
+ fileContents = pragma.process(fileName, fileContents, config, 'OnSave', pluginCollector);
158
+
159
+ //Optimize the JS files if asked.
160
+ if (optimizerName && optimizerName !== 'none') {
161
+ optFunc = envOptimize[optimizerName] || optimize.optimizers[optimizerName];
162
+ if (!optFunc) {
163
+ throw new Error('optimizer with name of "' +
164
+ optimizerName +
165
+ '" not found for this environment');
166
+ }
167
+
168
+ if (config.preserveLicenseComments) {
169
+ //Pull out any license comments for prepending after optimization.
170
+ optimize.licenseCommentRegExp.lastIndex = 0;
171
+ while ((match = optimize.licenseCommentRegExp.exec(fileContents))) {
172
+ comment = match[0];
173
+ //Only keep the comments if they are license comments.
174
+ if (comment.indexOf('@license') !== -1 ||
175
+ comment.indexOf('/*!') === 0) {
176
+ licenseContents += comment + '\n';
177
+ }
178
+ }
179
+ }
180
+
181
+ fileContents = licenseContents + optFunc(fileName, fileContents, keepLines,
182
+ config[optimizerName]);
183
+ }
184
+
185
+ file.saveUtf8File(outFileName, fileContents);
186
+ },
187
+
188
+ /**
189
+ * Optimizes one CSS file, inlining @import calls, stripping comments, and
190
+ * optionally removes line returns.
191
+ * @param {String} fileName the path to the CSS file to optimize
192
+ * @param {String} outFileName the path to save the optimized file.
193
+ * @param {Object} config the config object with the optimizeCss and
194
+ * cssImportIgnore options.
195
+ */
196
+ cssFile: function (fileName, outFileName, config) {
197
+ //Read in the file. Make sure we have a JS string.
198
+ var originalFileContents = file.readFile(fileName),
199
+ fileContents = flattenCss(fileName, originalFileContents, config.cssImportIgnore),
200
+ startIndex, endIndex;
201
+
202
+ //Do comment removal.
203
+ try {
204
+ startIndex = -1;
205
+ //Get rid of comments.
206
+ while ((startIndex = fileContents.indexOf("/*")) !== -1) {
207
+ endIndex = fileContents.indexOf("*/", startIndex + 2);
208
+ if (endIndex === -1) {
209
+ throw "Improper comment in CSS file: " + fileName;
210
+ }
211
+ fileContents = fileContents.substring(0, startIndex) + fileContents.substring(endIndex + 2, fileContents.length);
212
+ }
213
+ //Get rid of newlines.
214
+ if (config.optimizeCss.indexOf(".keepLines") === -1) {
215
+ fileContents = fileContents.replace(/[\r\n]/g, "");
216
+ fileContents = fileContents.replace(/\s+/g, " ");
217
+ fileContents = fileContents.replace(/\{\s/g, "{");
218
+ fileContents = fileContents.replace(/\s\}/g, "}");
219
+ } else {
220
+ //Remove multiple empty lines.
221
+ fileContents = fileContents.replace(/(\r\n)+/g, "\r\n");
222
+ fileContents = fileContents.replace(/(\n)+/g, "\n");
223
+ }
224
+ } catch (e) {
225
+ fileContents = originalFileContents;
226
+ logger.error("Could not optimized CSS file: " + fileName + ", error: " + e);
227
+ }
228
+
229
+ file.saveUtf8File(outFileName, fileContents);
230
+ },
231
+
232
+ /**
233
+ * Optimizes CSS files, inlining @import calls, stripping comments, and
234
+ * optionally removes line returns.
235
+ * @param {String} startDir the path to the top level directory
236
+ * @param {Object} config the config object with the optimizeCss and
237
+ * cssImportIgnore options.
238
+ */
239
+ css: function (startDir, config) {
240
+ if (config.optimizeCss.indexOf("standard") !== -1) {
241
+ var i, fileName,
242
+ fileList = file.getFilteredFileList(startDir, /\.css$/, true);
243
+ if (fileList) {
244
+ for (i = 0; i < fileList.length; i++) {
245
+ fileName = fileList[i];
246
+ logger.trace("Optimizing (" + config.optimizeCss + ") CSS file: " + fileName);
247
+ optimize.cssFile(fileName, fileName, config);
248
+ }
249
+ }
250
+ }
251
+ },
252
+
253
+ optimizers: {
254
+ uglify: function (fileName, fileContents, keepLines, config) {
255
+ var parser = uglify.parser,
256
+ processor = uglify.uglify,
257
+ ast, genCodeConfig;
258
+
259
+ config = config || {};
260
+ genCodeConfig = config.gen_codeOptions || keepLines;
261
+
262
+ logger.trace("Uglifying file: " + fileName);
263
+
264
+ try {
265
+ ast = parser.parse(fileContents, config.strict_semicolons);
266
+ ast = processor.ast_mangle(ast, config.do_toplevel);
267
+ ast = processor.ast_squeeze(ast, config.ast_squeezeOptions);
268
+
269
+ fileContents = processor.gen_code(ast, genCodeConfig);
270
+ } catch (e) {
271
+ logger.error('Cannot uglify file: ' + fileName + '. Skipping it. Error is:\n' + e.toString());
272
+ }
273
+ return fileContents;
274
+ }
275
+ }
276
+ };
277
+
278
+ return optimize;
279
+ });