Пример #1
0
        public Commands(IStatusInformer logger, string rootPath, string buildPath)
        {
            compiler = new Compiler(logger);
            Logger = logger;

            var config = new Config.Config();
            MobileNetConfig = config.DeSerialize(Directory.GetCurrentDirectory() + "\\MobileNet.config");
            ChangeRootPath(rootPath, buildPath);
        }
Пример #2
0
        public void Compile(Config.Config config)
        {
            foreach (Platform platform in config.Platforms)
            {
                string AbsoluteAssetsDir = string.Format("{0}\\{1}\\{2}", config.BuildPath, platform.Name, platform.AssetsDir);
                CopyAssets(config, AbsoluteAssetsDir);

                string AbsoluteWWWDir = string.Format("{0}\\{1}\\{2}", config.BuildPath, platform.Name, platform.WWWDir);
                CheckExistenceOrCreateDir(AbsoluteWWWDir);

                Logger.Log("Copying index.html...");
                CopyIndexHTML(config, AbsoluteWWWDir, platform.AssetsDir);

                foreach (OutputFile output in config.Outputs)
                {
                    Logger.Log(string.Format("Compiling {0} file...", output.RelativeFilename));
                    Logger.ResetProgress();
                    Logger.AddProgress(20);

                    string outputFileName = AbsoluteAssetsDir + "\\" + output.RelativeFilename;

                    if (File.Exists(outputFileName))
                        File.Delete(outputFileName);

                    StreamWriter writer = new StreamWriter(outputFileName);

                    AddRequireContent(output, writer);
                    Logger.AddProgress(10);

                    AddContent(config.VendorPath, output.BeforeLibs, writer, platform.AssetsDir);
                    Logger.Log("Adding pre-required vendor Libs/styles...");
                    Logger.AddProgress(20);

                    Logger.Log("compiling Routers/Views/Models/Collections/others...");
                    CompileAppFiles(output, config.AppPath, config.AppPath, writer, platform.AssetsDir);
                    Logger.AddProgress(30);

                    Logger.Log("Adding post-required vendor Libs/styles...");
                    AddContent(config.VendorPath, output.AfterLibs, writer, platform.AssetsDir);
                    Logger.AddProgress(20);

                    writer.Close();
                }
            }
        }
Пример #3
0
        void CopyIndexHTML(Config.Config config, string absoluteWWWDir, string relativeAssetsDir)
        {
            string sourceHtmlFilename = config.AppPath + "\\index.html";
            string destHtmlFilename = absoluteWWWDir + "\\index.html";

            if (File.Exists(destHtmlFilename))
                File.Delete(destHtmlFilename);

            StreamReader sr = new StreamReader(sourceHtmlFilename);
            string indexcontent = sr.ReadToEnd().Replace(ASSETS, string.IsNullOrEmpty(relativeAssetsDir) ? "" : ("./" + relativeAssetsDir) + "/");
            sr.Close();

            StreamWriter sw = new StreamWriter(destHtmlFilename);
            sw.Write(indexcontent);
            sw.Close();
        }
Пример #4
0
        void CopyAssets(Config.Config config, string buildAssetsDir)
        {
            string from = config.AppPath + "\\images";
            string to = buildAssetsDir;

            CopyFolder(from, to);
        }