PageRenderTime 12ms CodeModel.GetById 2ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

/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 */
13require("dojo", "fileUtil");
14require("my", "fixFileUtil")
15require("dojo", "logger");
16require("my", "info");
17
18(function() {
19    var AppInfoText;
20    var jsonSchema;
21    
22    if (params.targets.development || params.targets.release) {
23        AppInfoText = "/* This file is automatically generated */\n" +
24        "ApplicationInfo = {\n" +
25        "	Title: \"" +
26        AppInfo.Title +
27        "\",\n" +
28        "	Name: \"" +
29        AppInfo.Name +
30        "\",\n" +
31        "	ID: \"" +
32        AppInfo.ID +
33        "\",\n" +
34        "	Version: {\n" +
35        "		Major: \"" +
36        AppInfo.Version.Major +
37        "\",\n" +
38        "		Minor: \"" +
39        AppInfo.Version.Minor +
40        "\",\n" +
41        "		Revision: \"" +
42        AppInfo.Version.Revision +
43        "\"\n" +
44        "	}\n" +
45        "}\n";
46        jsonSchema = fileUtil.readFile(params.scriptPath + "../vendor/json-schema/validate.js");
47        jsonSchema = jsonSchema.replace("module.exports", "JSON = window.JSON || {}; JSON.schema");
48    }
49    
50    if (params.targets.development) {
51    
52        logger.info("Copying test to development");
53        fileUtil.copyDir(params.scriptPath + "../test/", params.scriptPath + "../development/", /^(?:.*\.(?:html|js|htm|css|txt))|LICENSE|NOTICE$/g, true);
54        logger.info("Copying source to development");
55        fileUtil.copyDir(params.scriptPath + "../source/", params.scriptPath + "../development/",{ 
56            include: /^(?:.*\.(?:html|js|htm|css|txt))|LICENSE|NOTICE$/g, 
57            exclude: /package-.*\.json$/g 
58        }, true);
59        logger.info("Creating package file for development");
60        fileUtil.copyFile(params.scriptPath + "../source/package-development.json", params.scriptPath + "../development/package.json");
61        logger.info("Copying resources to development");
62        fileUtil.copyFile(params.scriptPath + "../resources/icons/icons.png", params.scriptPath + "../development/resources/icons.png", true);
63        fileUtil.copyFile(params.scriptPath + "../resources/icons/readme.txt", params.scriptPath + "../development/resources/readme.txt", true);
64        fileUtil.copyFile(params.scriptPath + "../resources/quotes.js", params.scriptPath + "../development/resources/quotes.js", true);
65        fileUtil.copyFile(params.scriptPath + "../resources/main-icon/wing-book-128.png", params.scriptPath + "../development/story-steward.png");
66        logger.info("Copying non-dojo vendor to development");
67        fileUtil.copyFile(params.scriptPath + "../vendor/Math.uuid.js", params.scriptPath + "../development/js/Math.uuid.js", true);
68        fileUtil.saveFile(params.scriptPath + "../development/js/json-validate.js", jsonSchema);
69        logger.info("Copying version to development");
70        fileUtil.saveFile(params.scriptPath + "../development/js/appinfo.js", AppInfoText);
71    }
72    if (params.targets.release) {
73        logger.info("Copying source to release");
74        fileUtil.copyDir(params.scriptPath + "../source/", params.scriptPath + "../release/", {
75            include: /^(?:.*\.(?:html|js|htm|css|txt))|LICENSE|NOTICE$/g,
76            exclude: /^.*\/source\/js\/dojo\/my\/.*|package-.*\.json/g
77        }, true);
78        logger.info("Creating package file for release");
79        fileUtil.copyFile(params.scriptPath + "../source/package-release.json", params.scriptPath + "../release/package.json");
80        logger.info("Copying resources to release");
81        fileUtil.copyFile(params.scriptPath + "../resources/icons/icons.png", params.scriptPath + "../release/resources/icons.png", true);
82        fileUtil.copyFile(params.scriptPath + "../resources/icons/readme.txt", params.scriptPath + "../release/resources/readme.txt", true);
83        fileUtil.copyFile(params.scriptPath + "../resources/quotes.js", params.scriptPath + "../release/resources/quotes.js", true);
84        fileUtil.copyFile(params.scriptPath + "../resources/main-icon/wing-book-128.png", params.scriptPath + "../release/story-steward.png");
85        logger.info("Copying non-dojo vendor to release");
86        fileUtil.copyFile(params.scriptPath + "../vendor/Math.uuid.js", params.scriptPath + "../release/js/Math.uuid.js", true);
87        fileUtil.saveFile(params.scriptPath + "../release/js/json-validate.js", jsonSchema);
88        logger.info("Copying version to release");
89        fileUtil.saveFile(params.scriptPath + "../release/js/appinfo.js", AppInfoText);
90    }
91    logger.info("Files copied.")
92})();