jazz-jss 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +44 -19
- data/bin/jazz +20 -8
- data/lib/jazz/cli.rb +73 -9
- data/lib/jazz/generators/controller/controller.rb +22 -0
- data/lib/jazz/generators/controller/templates/controller.js +38 -0
- data/lib/jazz/generators/helper/helper.rb +22 -0
- data/lib/jazz/generators/helper/templates/helper.js +6 -0
- data/lib/jazz/generators/model/model.rb +50 -0
- data/lib/jazz/generators/model/templates/database.js +14 -0
- data/lib/jazz/generators/model/templates/fixture.js +10 -0
- data/{templates → lib/jazz/generators/model/templates}/model.js +9 -12
- data/lib/jazz/generators/project/project.rb +27 -0
- data/{templates/app_root/development/app/assets/javascripts/application.js → lib/jazz/generators/project/templates/app_root/JEMFILE.js} +0 -0
- data/{templates/app_root/development/app/assets/stylesheets/application.css → lib/jazz/generators/project/templates/app_root/app/assets/javascripts/application.js} +0 -0
- data/{templates/view_create.html → lib/jazz/generators/project/templates/app_root/app/assets/stylesheets/application.sass} +0 -0
- data/lib/jazz/generators/project/templates/app_root/app/controllers/application_controller.js +9 -0
- data/{templates/app_root/development → lib/jazz/generators/project/templates/app_root}/app/helpers/application_helper.js +0 -1
- data/lib/jazz/generators/project/templates/app_root/app/scenarios/application_scenario.js +13 -0
- data/lib/jazz/generators/project/templates/app_root/app/views/layouts/index.handlebars +1 -0
- data/lib/jazz/generators/project/templates/app_root/config/boot.js +23 -0
- data/lib/jazz/generators/project/templates/app_root/config/routes.js +6 -0
- data/{templates/view_index.html → lib/jazz/generators/project/templates/app_root/db/fixtures/touch} +0 -0
- data/lib/jazz/generators/project/templates/app_root/index.html +11 -0
- data/lib/jazz/generators/project/templates/app_root/lib/jazz/_.js +9 -0
- data/lib/jazz/generators/project/templates/app_root/lib/jazz/lib/controller/_.js +1 -0
- data/lib/jazz/generators/project/templates/app_root/lib/jazz/lib/controller/controller.js +22 -0
- data/lib/jazz/generators/project/templates/app_root/lib/jazz/lib/core/_.js +1 -0
- data/{dist/jazz/lib → lib/jazz/generators/project/templates/app_root/lib/jazz/lib/core}/core.js +0 -0
- data/lib/jazz/generators/project/templates/app_root/lib/jazz/lib/database/_.js +3 -0
- data/lib/jazz/generators/project/templates/app_root/lib/jazz/lib/database/database.js +10 -0
- data/lib/jazz/generators/project/templates/app_root/lib/jazz/lib/database/finder.js +41 -0
- data/lib/jazz/generators/project/templates/app_root/lib/jazz/lib/database/modifier.js +10 -0
- data/lib/jazz/generators/project/templates/app_root/lib/jazz/lib/helper/_.js +2 -0
- data/lib/jazz/generators/project/templates/app_root/lib/jazz/lib/helper/helper.js +49 -0
- data/lib/jazz/generators/project/templates/app_root/lib/jazz/lib/helper/underscore.js +13 -0
- data/lib/jazz/generators/project/templates/app_root/lib/jazz/lib/model/_.js +4 -0
- data/lib/jazz/generators/project/templates/app_root/lib/jazz/lib/model/conditional.js +3 -0
- data/lib/jazz/generators/project/templates/app_root/lib/jazz/lib/model/finder.js +21 -0
- data/lib/jazz/generators/project/templates/app_root/lib/jazz/lib/model/model.js +23 -0
- data/lib/jazz/generators/project/templates/app_root/lib/jazz/lib/model/modifier.js +44 -0
- data/lib/jazz/generators/project/templates/app_root/lib/jazz/lib/route/_.js +1 -0
- data/lib/jazz/generators/project/templates/app_root/lib/jazz/lib/route/route.js +115 -0
- data/lib/jazz/generators/project/templates/app_root/lib/jazz/lib/scenario/_.js +2 -0
- data/lib/jazz/generators/project/templates/app_root/lib/jazz/lib/scenario/initialize_scenarios/application.js +3 -0
- data/lib/jazz/generators/project/templates/app_root/lib/jazz/lib/scenario/scenario.js +13 -0
- data/lib/jazz/generators/project/templates/app_root/lib/jazz/lib/view/_.js +1 -0
- data/lib/jazz/generators/project/templates/app_root/lib/jazz/lib/view/view.js +39 -0
- data/{dist/handlebars → lib/jazz/generators/project/templates/app_root/vendor}/handlebars.js +0 -0
- data/{dist/hashchange → lib/jazz/generators/project/templates/app_root/vendor}/hashchange.js +0 -0
- data/{dist/jquery → lib/jazz/generators/project/templates/app_root/vendor}/jquery.js +0 -0
- data/lib/jazz/generators/project/templates/app_root/vendor/simplemodal.js +698 -0
- data/lib/jazz/generators/project/templates/app_root/vendor/tipTip.js +191 -0
- data/{dist/underscore → lib/jazz/generators/project/templates/app_root/vendor}/underscore.js +0 -0
- data/lib/jazz/generators/project/templates/application.js +12 -0
- data/lib/jazz/generators/scaffold/scaffold.rb +73 -0
- data/lib/jazz/generators/scaffold/templates/controller.js +49 -0
- data/lib/jazz/generators/scaffold/templates/database.js +14 -0
- data/lib/jazz/generators/scaffold/templates/fixture.js +10 -0
- data/lib/jazz/generators/scaffold/templates/helper.js +6 -0
- data/lib/jazz/generators/scaffold/templates/model.js +13 -0
- data/lib/jazz/generators/scaffold/templates/scenario.js +7 -0
- data/lib/jazz/generators/scaffold/templates/view_edit.handlebars +6 -0
- data/lib/jazz/generators/scaffold/templates/view_form.handlebars +12 -0
- data/lib/jazz/generators/scaffold/templates/view_index.handlebars +27 -0
- data/lib/jazz/generators/scaffold/templates/view_new.handlebars +5 -0
- data/lib/jazz/generators/scaffold/templates/view_show.handlebars +10 -0
- data/lib/jazz/generators/scenario/scenario.rb +22 -0
- data/lib/jazz/generators/scenario/templates/scenario.js +7 -0
- data/lib/jazz/rack/config.ru +16 -0
- data/lib/jazz/sprockets/templates/handlebars.rb +30 -0
- metadata +120 -234
- data/dist/jazz/lib/controller.js +0 -17
- data/dist/jazz/lib/db.js +0 -41
- data/dist/jazz/lib/helper.js +0 -38
- data/dist/jazz/lib/model.js +0 -95
- data/dist/jazz/lib/route.js +0 -74
- data/dist/jazz/lib/view.js +0 -1
- data/dist/jazz/module.js +0 -15
- data/dist/require/order.js +0 -180
- data/dist/require/require.js +0 -31
- data/dist/require/template.js +0 -98
- data/lib/jazz.rb +0 -12
- data/lib/jazz/app_detector.rb +0 -70
- data/lib/jazz/app_generator.rb +0 -41
- data/lib/jazz/controller_generator.rb +0 -34
- data/lib/jazz/helper_generator.rb +0 -30
- data/lib/jazz/model_generator.rb +0 -27
- data/lib/jazz/scaffold_generator.rb +0 -49
- data/templates/app_root/Rakefile +0 -11
- data/templates/app_root/development/app/controllers/application_controller.js +0 -11
- data/templates/app_root/development/config/glue.js +0 -9
- data/templates/app_root/development/config/routes.js +0 -5
- data/templates/app_root/scripts/build.js +0 -30
- data/templates/app_root/scripts/r.js/LICENSE +0 -58
- data/templates/app_root/scripts/r.js/README.md +0 -177
- data/templates/app_root/scripts/r.js/build/build.js +0 -26
- data/templates/app_root/scripts/r.js/build/buildebug.sh +0 -4
- data/templates/app_root/scripts/r.js/build/example.build.js +0 -296
- data/templates/app_root/scripts/r.js/build/jslib/blank.js +0 -4
- data/templates/app_root/scripts/r.js/build/jslib/build.js +0 -952
- data/templates/app_root/scripts/r.js/build/jslib/commandLine.js +0 -23
- data/templates/app_root/scripts/r.js/build/jslib/commonJs.js +0 -152
- data/templates/app_root/scripts/r.js/build/jslib/env.js +0 -47
- data/templates/app_root/scripts/r.js/build/jslib/lang.js +0 -49
- data/templates/app_root/scripts/r.js/build/jslib/logger.js +0 -58
- data/templates/app_root/scripts/r.js/build/jslib/node.js +0 -106
- data/templates/app_root/scripts/r.js/build/jslib/node/args.js +0 -20
- data/templates/app_root/scripts/r.js/build/jslib/node/file.js +0 -263
- data/templates/app_root/scripts/r.js/build/jslib/node/load.js +0 -17
- data/templates/app_root/scripts/r.js/build/jslib/node/optimize.js +0 -10
- data/templates/app_root/scripts/r.js/build/jslib/node/print.js +0 -16
- data/templates/app_root/scripts/r.js/build/jslib/optimize.js +0 -279
- data/templates/app_root/scripts/r.js/build/jslib/opto.build.js +0 -11
- data/templates/app_root/scripts/r.js/build/jslib/parse.js +0 -590
- data/templates/app_root/scripts/r.js/build/jslib/pragma.js +0 -251
- data/templates/app_root/scripts/r.js/build/jslib/requirePatch.js +0 -286
- data/templates/app_root/scripts/r.js/build/jslib/rhino.js +0 -22
- data/templates/app_root/scripts/r.js/build/jslib/rhino/args.js +0 -21
- data/templates/app_root/scripts/r.js/build/jslib/rhino/file.js +0 -244
- data/templates/app_root/scripts/r.js/build/jslib/rhino/load.js +0 -12
- data/templates/app_root/scripts/r.js/build/jslib/rhino/optimize.js +0 -100
- data/templates/app_root/scripts/r.js/build/jslib/rhino/print.js +0 -12
- data/templates/app_root/scripts/r.js/build/jslib/uglifyjs/README.md +0 -16
- data/templates/app_root/scripts/r.js/build/jslib/uglifyjs/index.js +0 -21
- data/templates/app_root/scripts/r.js/build/jslib/uglifyjs/parse-js.js +0 -1342
- data/templates/app_root/scripts/r.js/build/jslib/uglifyjs/process.js +0 -2005
- data/templates/app_root/scripts/r.js/build/jslib/uglifyjs/squeeze-more.js +0 -55
- data/templates/app_root/scripts/r.js/build/jslib/x.js +0 -243
- data/templates/app_root/scripts/r.js/build/tests/all.js +0 -47
- data/templates/app_root/scripts/r.js/build/tests/allj.sh +0 -3
- data/templates/app_root/scripts/r.js/build/tests/alln.sh +0 -18
- data/templates/app_root/scripts/r.js/build/tests/anonSimple.build.js +0 -7
- data/templates/app_root/scripts/r.js/build/tests/buildUtils.js +0 -19
- data/templates/app_root/scripts/r.js/build/tests/builds.js +0 -489
- data/templates/app_root/scripts/r.js/build/tests/circular.build.js +0 -18
- data/templates/app_root/scripts/r.js/build/tests/convert.js +0 -18
- data/templates/app_root/scripts/r.js/build/tests/css.build.js +0 -6
- data/templates/app_root/scripts/r.js/build/tests/css/common/common.css +0 -4
- data/templates/app_root/scripts/r.js/build/tests/css/master.css +0 -10
- data/templates/app_root/scripts/r.js/build/tests/css/sub/sub1.css +0 -7
- data/templates/app_root/scripts/r.js/build/tests/cssTestCompare.css +0 -13
- data/templates/app_root/scripts/r.js/build/tests/end.frag +0 -3
- data/templates/app_root/scripts/r.js/build/tests/expected/unoExcludeShallow.js +0 -23
- data/templates/app_root/scripts/r.js/build/tests/exports.build.js +0 -12
- data/templates/app_root/scripts/r.js/build/tests/hasTestModule.build.js +0 -10
- data/templates/app_root/scripts/r.js/build/tests/hasTestModule.js +0 -30
- data/templates/app_root/scripts/r.js/build/tests/http/httpBuild.js +0 -70
- data/templates/app_root/scripts/r.js/build/tests/http/main.html +0 -28
- data/templates/app_root/scripts/r.js/build/tests/http/scripts/main.js +0 -18
- data/templates/app_root/scripts/r.js/build/tests/http/scripts/one.js +0 -3
- data/templates/app_root/scripts/r.js/build/tests/http/scripts/three.js +0 -5
- data/templates/app_root/scripts/r.js/build/tests/http/scripts/two.js +0 -7
- data/templates/app_root/scripts/r.js/build/tests/i18n.build.js +0 -17
- data/templates/app_root/scripts/r.js/build/tests/indexBuilder.build.js +0 -8
- data/templates/app_root/scripts/r.js/build/tests/lib/amdefine/a.js +0 -17
- data/templates/app_root/scripts/r.js/build/tests/lib/amdefine/b.js +0 -8
- data/templates/app_root/scripts/r.js/build/tests/lib/amdefine/build.js +0 -6
- data/templates/app_root/scripts/r.js/build/tests/lib/amdefine/c.js +0 -7
- data/templates/app_root/scripts/r.js/build/tests/lib/amdefine/d.js +0 -5
- data/templates/app_root/scripts/r.js/build/tests/lib/amdefine/expected.js +0 -36
- data/templates/app_root/scripts/r.js/build/tests/lib/amdefine/node_modules/amdefine/LICENSE +0 -58
- data/templates/app_root/scripts/r.js/build/tests/lib/amdefine/node_modules/amdefine/amdefine.js +0 -188
- data/templates/app_root/scripts/r.js/build/tests/lib/amdefine/node_modules/amdefine/package.json +0 -21
- data/templates/app_root/scripts/r.js/build/tests/lib/comments/bang.js +0 -10
- data/templates/app_root/scripts/r.js/build/tests/lib/comments/build.js +0 -6
- data/templates/app_root/scripts/r.js/build/tests/lib/comments/expected.js +0 -9
- data/templates/app_root/scripts/r.js/build/tests/lib/comments/license.js +0 -13
- data/templates/app_root/scripts/r.js/build/tests/lib/dotpackage/scripts/app.build.js +0 -15
- data/templates/app_root/scripts/r.js/build/tests/lib/dotpackage/scripts/main-expected.js +0 -13
- data/templates/app_root/scripts/r.js/build/tests/lib/dotpackage/scripts/main.js +0 -7
- data/templates/app_root/scripts/r.js/build/tests/lib/empty/build.js +0 -13
- data/templates/app_root/scripts/r.js/build/tests/lib/empty/expected.js +0 -8
- data/templates/app_root/scripts/r.js/build/tests/lib/empty/main.js +0 -1
- data/templates/app_root/scripts/r.js/build/tests/lib/empty/sub1.js +0 -1
- data/templates/app_root/scripts/r.js/build/tests/lib/empty/sub2.js +0 -1
- data/templates/app_root/scripts/r.js/build/tests/lib/nameInsertion/build.js +0 -6
- data/templates/app_root/scripts/r.js/build/tests/lib/nameInsertion/expected.js +0 -12
- data/templates/app_root/scripts/r.js/build/tests/lib/nameInsertion/main.js +0 -9
- data/templates/app_root/scripts/r.js/build/tests/lib/namespace/build.js +0 -8
- data/templates/app_root/scripts/r.js/build/tests/lib/namespace/expected.js +0 -47
- data/templates/app_root/scripts/r.js/build/tests/lib/namespace/main.js +0 -6
- data/templates/app_root/scripts/r.js/build/tests/lib/namespace/modules/four.js +0 -7
- data/templates/app_root/scripts/r.js/build/tests/lib/namespace/modules/one.js +0 -9
- data/templates/app_root/scripts/r.js/build/tests/lib/namespace/modules/three.js +0 -14
- data/templates/app_root/scripts/r.js/build/tests/lib/namespace/modules/two.js +0 -5
- data/templates/app_root/scripts/r.js/build/tests/lib/nested/a.js +0 -12
- data/templates/app_root/scripts/r.js/build/tests/lib/nested/b.js +0 -3
- data/templates/app_root/scripts/r.js/build/tests/lib/nested/build.js +0 -6
- data/templates/app_root/scripts/r.js/build/tests/lib/nested/buildWithCE.js +0 -7
- data/templates/app_root/scripts/r.js/build/tests/lib/nested/c.js +0 -3
- data/templates/app_root/scripts/r.js/build/tests/lib/nested/d.js +0 -3
- data/templates/app_root/scripts/r.js/build/tests/lib/nested/e.js +0 -3
- data/templates/app_root/scripts/r.js/build/tests/lib/nested/expected-built.js +0 -36
- data/templates/app_root/scripts/r.js/build/tests/lib/nested/expected-builtWithCE.js +0 -42
- data/templates/app_root/scripts/r.js/build/tests/lib/nested/main.js +0 -3
- data/templates/app_root/scripts/r.js/build/tests/lib/nested/top.js +0 -10
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/a.js +0 -3
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/b.js +0 -3
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/build.js +0 -6
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/buildNeedAll.js +0 -9
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/buildNeedB.js +0 -11
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/buildNeedC.js +0 -11
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/buildNeedD.js +0 -11
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/buildNested.js +0 -7
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/c.js +0 -3
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/d.js +0 -3
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/expected-built.js +0 -21
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/expected-builtNeedAll.js +0 -31
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/expected-builtNeedB.js +0 -24
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/expected-builtNeedC.js +0 -24
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/expected-builtNeedD.js +0 -25
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/expected-builtNested.js +0 -31
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/main.js +0 -17
- data/templates/app_root/scripts/r.js/build/tests/lib/plugins/build.js +0 -6
- data/templates/app_root/scripts/r.js/build/tests/lib/plugins/converter.js +0 -11
- data/templates/app_root/scripts/r.js/build/tests/lib/plugins/main.js +0 -6
- data/templates/app_root/scripts/r.js/build/tests/lib/plugins/plug.js +0 -29
- data/templates/app_root/scripts/r.js/build/tests/lib/plugins/util.js +0 -7
- data/templates/app_root/scripts/r.js/build/tests/nameOnly.build.js +0 -10
- data/templates/app_root/scripts/r.js/build/tests/nodeAll.js +0 -3
- data/templates/app_root/scripts/r.js/build/tests/nodeOptimize.js +0 -12
- data/templates/app_root/scripts/r.js/build/tests/nodeOptimizeNoCallback.js +0 -10
- data/templates/app_root/scripts/r.js/build/tests/order.build.js +0 -16
- data/templates/app_root/scripts/r.js/build/tests/override/override.js +0 -36
- data/templates/app_root/scripts/r.js/build/tests/packages.build.js +0 -59
- data/templates/app_root/scripts/r.js/build/tests/parse.js +0 -103
- data/templates/app_root/scripts/r.js/build/tests/simple.build.js +0 -13
- data/templates/app_root/scripts/r.js/build/tests/simpleNamespace.build.js +0 -17
- data/templates/app_root/scripts/r.js/build/tests/start.frag +0 -4
- data/templates/app_root/scripts/r.js/build/tests/text.build.js +0 -16
- data/templates/app_root/scripts/r.js/build/tests/textExclude.build.js +0 -16
- data/templates/app_root/scripts/r.js/dist.js +0 -95
- data/templates/app_root/scripts/r.js/dist/README.md +0 -6
- data/templates/app_root/scripts/r.js/dist/r-1.0.0.js +0 -9042
- data/templates/app_root/scripts/r.js/dist/r-edge.js +0 -9191
- data/templates/app_root/scripts/r.js/dist/r.js +0 -9099
- data/templates/app_root/scripts/r.js/lib/closure/COPYING +0 -202
- data/templates/app_root/scripts/r.js/lib/closure/README +0 -292
- data/templates/app_root/scripts/r.js/lib/closure/compiler.jar +0 -0
- data/templates/app_root/scripts/r.js/lib/rhino/LICENSE +0 -4
- data/templates/app_root/scripts/r.js/lib/rhino/js.jar +0 -0
- data/templates/app_root/scripts/r.js/require.js +0 -1952
- data/templates/app_root/scripts/r.js/tasks.txt +0 -2
- data/templates/app_root/scripts/r.js/tests/all.js +0 -49
- data/templates/app_root/scripts/r.js/tests/allNode.js +0 -3
- data/templates/app_root/scripts/r.js/tests/allj.sh +0 -1
- data/templates/app_root/scripts/r.js/tests/alln.sh +0 -2
- data/templates/app_root/scripts/r.js/tests/alpha.js +0 -3
- data/templates/app_root/scripts/r.js/tests/beta.js +0 -6
- data/templates/app_root/scripts/r.js/tests/doh/LICENSE +0 -195
- data/templates/app_root/scripts/r.js/tests/doh/README +0 -12
- data/templates/app_root/scripts/r.js/tests/doh/_browserRunner.js +0 -855
- data/templates/app_root/scripts/r.js/tests/doh/_nodeRunner.js +0 -20
- data/templates/app_root/scripts/r.js/tests/doh/_rhinoRunner.js +0 -17
- data/templates/app_root/scripts/r.js/tests/doh/_sounds/LICENSE +0 -10
- data/templates/app_root/scripts/r.js/tests/doh/_sounds/doh.wav +0 -0
- data/templates/app_root/scripts/r.js/tests/doh/_sounds/dohaaa.wav +0 -0
- data/templates/app_root/scripts/r.js/tests/doh/_sounds/woohoo.wav +0 -0
- data/templates/app_root/scripts/r.js/tests/doh/runner.html +0 -316
- data/templates/app_root/scripts/r.js/tests/doh/runner.js +0 -1499
- data/templates/app_root/scripts/r.js/tests/doh/runner.sh +0 -3
- data/templates/app_root/scripts/r.js/tests/doh/small_logo.png +0 -0
- data/templates/app_root/scripts/r.js/tests/node/canvasTest.js +0 -39
- data/templates/app_root/scripts/r.js/tests/node/embedded/README.md +0 -15
- data/templates/app_root/scripts/r.js/tests/node/embedded/coffee/foo.coffee +0 -1
- data/templates/app_root/scripts/r.js/tests/node/embedded/main.js +0 -13
- data/templates/app_root/scripts/r.js/tests/node/embedded/scripts/bar.js +0 -13
- data/templates/app_root/scripts/r.js/tests/node/index.js +0 -11
- data/templates/app_root/scripts/r.js/tests/node/tests/alpha/foo.js +0 -6
- data/templates/app_root/scripts/r.js/tests/node/tests/alpha/hello.html +0 -9
- data/templates/app_root/scripts/r.js/tests/node/tests/foo.js +0 -3
- data/templates/app_root/scripts/r.js/tests/node/tests/server.js +0 -11
- data/templates/app_root/scripts/r.js/tests/relative.js +0 -10
- data/templates/app_root/scripts/r.js/tests/sub/betaSub.js +0 -3
- data/templates/application.js +0 -7
- data/templates/boot.js +0 -42
- data/templates/controller.js +0 -19
- data/templates/db.js +0 -14
- data/templates/helper.js +0 -9
- data/templates/index.html +0 -9
- data/templates/scaffold_controller.js +0 -19
- data/templates/view_show.html +0 -0
- data/templates/view_update.html +0 -0
@@ -1,263 +0,0 @@
|
|
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
|
-
});
|
@@ -1,17 +0,0 @@
|
|
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
|
-
});
|
@@ -1,10 +0,0 @@
|
|
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({});
|
@@ -1,16 +0,0 @@
|
|
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
|
-
});
|
@@ -1,279 +0,0 @@
|
|
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
|
-
});
|