private void Main3(ArgsReader ar) { bool noOpenOutput = ar.ArgIs("/-D"); if (ar.HasArgs(2)) { throw new Exception("不明なコマンド引数"); } if (ar.HasArgs()) { Ground.RootDir = FileTools.MakeFullPath(ar.NextArg()); } else { Ground.RootDir = CommonUtils.GetRiotDir(); } Console.WriteLine("RootDir: " + Ground.RootDir); if (Directory.Exists(Ground.RootDir) == false) { throw new Exception("no RootDir"); } Ground.FileAndDirectoryConfigFile = Path.Combine(Ground.RootDir, "FileAndDirectory.config.txt"); Ground.ResourceDir = Path.Combine(Ground.RootDir, "res"); Ground.OutDir = Path.Combine(Ground.RootDir, "out"); Ground.OutHtmlFile = Path.Combine(Ground.OutDir, "index.html"); Ground.OutHtmlFile_Slimmed = Path.Combine(Ground.OutDir, "slimmed_index.html"); Ground.OutHtmlFile_Slimmed_Wrapped = Path.Combine(Ground.OutDir, "slimmed_wrapped_index.html"); Ground.OutTestMainHtmlFileBase = Path.Combine(Ground.OutDir, "index_"); Console.WriteLine("ComponentAndScriptConfigFile: " + Ground.FileAndDirectoryConfigFile); Console.WriteLine("ResourceDir: " + Ground.ResourceDir); Console.WriteLine("OutDir: " + Ground.OutDir); Console.WriteLine("OutHtmlFile: " + Ground.OutHtmlFile); Console.WriteLine("OutHtmlFile_Slimmed: " + Ground.OutHtmlFile_Slimmed); Console.WriteLine("OutTestMainHtmlFileBase: " + Ground.OutTestMainHtmlFileBase); // ---- check ---- if (File.Exists(Ground.FileAndDirectoryConfigFile) == false) { throw new Exception("no FileAndDirectoryConfigFile"); } if (Directory.Exists(Ground.ResourceDir) == false) { throw new Exception("no ResourceDir"); } if (Directory.Exists(Ground.OutDir) == false) { throw new Exception("no OutDir"); } //Ground.OutHtmlFile //Ground.OutTestMainHtmlFileBase // ---- this.LoadFileAndDirectoryConfig(); Ground.DefineManager = new DefineManager(); // 先に! Ground.ScriptManager = new ScriptManager(); Ground.ComponentManager = new ComponentManager(); Ground.MainHtmlText = File.ReadAllText(Ground.MainHtmlFile, StringTools.ENCODING_SJIS); Ground.GlobalName = Ground.DefineManager.GetPropertyNN("GLOBAL"); FileTools.CleanupDir(Ground.OutDir); FileTools.CopyDir(Ground.ResourceDir, Ground.OutDir); foreach (string dir in Ground.ComponentAndScriptDirs) { this.CopyResources(dir, Ground.OutDir); } { string TESTMAIN_PTN = Guid.NewGuid().ToString("B"); string outHtmlFormat = Ground.MainHtmlText; GlobalIdentifierResolver gir = new GlobalIdentifierResolver(); { string script = Ground.ScriptManager.GetJSCode(); string component = Ground.ComponentManager.GetJSCode(); string css = Ground.ComponentManager.GetCSSCode(); gir.AddJSCode(script); gir.AddJSCode(component); script = gir.ResolveJSCode(script); component = gir.ResolveJSCode(component); css = gir.ResolveCSSCode(css); outHtmlFormat = StringTools.MultiReplace(outHtmlFormat, "riot_script", script, "riot_component", component, "riot_css", css, "riot_testmain", TESTMAIN_PTN ); } { string outHtml = outHtmlFormat; outHtml = StringTools.MultiReplace(outHtml, TESTMAIN_PTN, "" ); outHtml = CommonUtils.ToHTMLNewLine(outHtml); File.WriteAllText(Ground.OutHtmlFile, outHtml, Encoding.UTF8); } foreach (ScriptFile scriptFile in Ground.ScriptManager.GetTestMainScriptFiles()) { string outHtml = outHtmlFormat; { string script = scriptFile.GetJSCode(); gir.AddJSCode(script); script = gir.ResolveJSCode(script); outHtml = StringTools.MultiReplace(outHtml, TESTMAIN_PTN, script ); } outHtml = CommonUtils.ToHTMLNewLine(outHtml); File.WriteAllText(Ground.OutTestMainHtmlFileBase + scriptFile.CoName + Consts.OUT_TEST_MAIN_HTML_SUFFIX, outHtml, Encoding.UTF8); } if (noOpenOutput == false) { OpenOutput(); } HtmlFileOptimizer.Perform( Ground.OutHtmlFile, Ground.OutHtmlFile_Slimmed, ScriptOptimizer.Slim ); HtmlFileOptimizer.Perform( Ground.OutHtmlFile_Slimmed, Ground.OutHtmlFile_Slimmed_Wrapped, ScriptOptimizer.Wrap ); } }