/build/buildApplication.js

http://story-steward.googlecode.com/ · JavaScript · 92 lines · 76 code · 4 blank · 12 comment · 4 complexity · bf85591ba448633e2d8890bac2b819d5 MD5 · raw file

  1. /*
  2. Copyright 2011 Neil M. Sheldon
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. require("dojo", "fileUtil");
  14. require("my", "fixFileUtil")
  15. require("dojo", "logger");
  16. require("my", "info");
  17. (function() {
  18. var AppInfoText;
  19. var jsonSchema;
  20. if (params.targets.development || params.targets.release) {
  21. AppInfoText = "/* This file is automatically generated */\n" +
  22. "ApplicationInfo = {\n" +
  23. " Title: \"" +
  24. AppInfo.Title +
  25. "\",\n" +
  26. " Name: \"" +
  27. AppInfo.Name +
  28. "\",\n" +
  29. " ID: \"" +
  30. AppInfo.ID +
  31. "\",\n" +
  32. " Version: {\n" +
  33. " Major: \"" +
  34. AppInfo.Version.Major +
  35. "\",\n" +
  36. " Minor: \"" +
  37. AppInfo.Version.Minor +
  38. "\",\n" +
  39. " Revision: \"" +
  40. AppInfo.Version.Revision +
  41. "\"\n" +
  42. " }\n" +
  43. "}\n";
  44. jsonSchema = fileUtil.readFile(params.scriptPath + "../vendor/json-schema/validate.js");
  45. jsonSchema = jsonSchema.replace("module.exports", "JSON = window.JSON || {}; JSON.schema");
  46. }
  47. if (params.targets.development) {
  48. logger.info("Copying test to development");
  49. fileUtil.copyDir(params.scriptPath + "../test/", params.scriptPath + "../development/", /^(?:.*\.(?:html|js|htm|css|txt))|LICENSE|NOTICE$/g, true);
  50. logger.info("Copying source to development");
  51. fileUtil.copyDir(params.scriptPath + "../source/", params.scriptPath + "../development/",{
  52. include: /^(?:.*\.(?:html|js|htm|css|txt))|LICENSE|NOTICE$/g,
  53. exclude: /package-.*\.json$/g
  54. }, true);
  55. logger.info("Creating package file for development");
  56. fileUtil.copyFile(params.scriptPath + "../source/package-development.json", params.scriptPath + "../development/package.json");
  57. logger.info("Copying resources to development");
  58. fileUtil.copyFile(params.scriptPath + "../resources/icons/icons.png", params.scriptPath + "../development/resources/icons.png", true);
  59. fileUtil.copyFile(params.scriptPath + "../resources/icons/readme.txt", params.scriptPath + "../development/resources/readme.txt", true);
  60. fileUtil.copyFile(params.scriptPath + "../resources/quotes.js", params.scriptPath + "../development/resources/quotes.js", true);
  61. fileUtil.copyFile(params.scriptPath + "../resources/main-icon/wing-book-128.png", params.scriptPath + "../development/story-steward.png");
  62. logger.info("Copying non-dojo vendor to development");
  63. fileUtil.copyFile(params.scriptPath + "../vendor/Math.uuid.js", params.scriptPath + "../development/js/Math.uuid.js", true);
  64. fileUtil.saveFile(params.scriptPath + "../development/js/json-validate.js", jsonSchema);
  65. logger.info("Copying version to development");
  66. fileUtil.saveFile(params.scriptPath + "../development/js/appinfo.js", AppInfoText);
  67. }
  68. if (params.targets.release) {
  69. logger.info("Copying source to release");
  70. fileUtil.copyDir(params.scriptPath + "../source/", params.scriptPath + "../release/", {
  71. include: /^(?:.*\.(?:html|js|htm|css|txt))|LICENSE|NOTICE$/g,
  72. exclude: /^.*\/source\/js\/dojo\/my\/.*|package-.*\.json/g
  73. }, true);
  74. logger.info("Creating package file for release");
  75. fileUtil.copyFile(params.scriptPath + "../source/package-release.json", params.scriptPath + "../release/package.json");
  76. logger.info("Copying resources to release");
  77. fileUtil.copyFile(params.scriptPath + "../resources/icons/icons.png", params.scriptPath + "../release/resources/icons.png", true);
  78. fileUtil.copyFile(params.scriptPath + "../resources/icons/readme.txt", params.scriptPath + "../release/resources/readme.txt", true);
  79. fileUtil.copyFile(params.scriptPath + "../resources/quotes.js", params.scriptPath + "../release/resources/quotes.js", true);
  80. fileUtil.copyFile(params.scriptPath + "../resources/main-icon/wing-book-128.png", params.scriptPath + "../release/story-steward.png");
  81. logger.info("Copying non-dojo vendor to release");
  82. fileUtil.copyFile(params.scriptPath + "../vendor/Math.uuid.js", params.scriptPath + "../release/js/Math.uuid.js", true);
  83. fileUtil.saveFile(params.scriptPath + "../release/js/json-validate.js", jsonSchema);
  84. logger.info("Copying version to release");
  85. fileUtil.saveFile(params.scriptPath + "../release/js/appinfo.js", AppInfoText);
  86. }
  87. logger.info("Files copied.")
  88. })();