void BuildConfig(RJSConfig info) { var config = info.Config; if(options.Almond) { options.Log("Configuring for deploy with almond (custom)."); JSON.EnsureProperty(config, "name", "vendor/almond-custom"); JSON.EnsureProperty(config, "mainConfigFile", info.MainPath); JSON.EnsureProperty(config, "wrap", true); var insertRequire = JSON.EnsureArray(config, "insertRequire"); insertRequire.Add("main"); } else { options.Log("Configuring for deploy with require."); JSON.EnsureProperty(config, "name", "main"); } JSON.EnsureProperty(config, "baseUrl", info.BaseUrl); JSON.EnsureProperty(config, "out", info.OutputPath); var include = JSON.EnsureArray(config, "include"); if(include.Count < 1) { foreach(var item in info.Includes) { include.Add(item); } } }
public RJSConfig Build() { var info = new RJSConfig { Config = IO.GetBaseConfiguration(options), BaseUrl = DetermineApplicationPath() }; List<string> excludes = new List<string>(FixupPaths(info.BaseUrl, GetExcludes(info.BaseUrl))); var dirs = options.Excludes.Split(','); foreach (string dir in dirs) { excludes.AddRange(FixupPaths(info.BaseUrl, GetExcludes(info.BaseUrl, dir))); excludes.AddRange(FixupPaths(info.BaseUrl, GetExcludes(info.BaseUrl, "", string.Concat("main-",dir,".js"), SearchOption.TopDirectoryOnly))); } excludes.AddRange(FixupPaths(info.BaseUrl, GetExcludes(info.BaseUrl, "", "*.min.js", SearchOption.TopDirectoryOnly))); info.Excludes = excludes.ToArray(); info.Includes = FixupPaths(info.BaseUrl, GetIncludes(info.BaseUrl)).Except(info.Excludes); info.BuildFilePath = Path.Combine(options.ApplicationSource, amdPath, this.options.Build); info.OptimizerPath = Path.Combine(options.ApplicationSource, amdPath, "r.js"); info.AlmondPath = Path.Combine(options.ApplicationSource, amdPath, almondName + ".js"); info.OutputPath = Path.Combine(options.ApplicationSource, this.options.Target.Replace(".js", ".min.js")); info.MainPath = Path.Combine(options.ApplicationSource, this.options.Target); BuildConfig(info); return info; }
public static void WriteConfiguration(RJSConfig info, Options options) { options.Log(info.Config); using (var file = File.Create(info.BuildFilePath)) using (var writer = new StreamWriter(file)) { writer.Write(info.Config.ToString()); } }
public static void WriteConfiguration(RJSConfig info, Options options) { options.Log(info.Config); using (var file = File.Create(info.BuildFilePath)) { using (var writer = new StreamWriter(file)) { writer.Write(info.Config.ToString()); } } }
public RJSConfig Build() { var info = new RJSConfig { Config = IO.GetBaseConfiguration(options), BaseUrl = DetermineApplicationPath() }; info.Excludes = FixupPaths(info.BaseUrl, GetExcludes(info.BaseUrl)); info.Includes = FixupPaths(info.BaseUrl, GetIncludes(info.BaseUrl)).Except(info.Excludes); info.OutputDirectory = Path.Combine(new DirectoryInfo(info.BaseUrl).Parent.FullName, "app-built"); info.BuildFilePath = Path.Combine(options.ApplicationSource, "vendor/app.build.js"); info.OptimizerPath = Path.Combine(options.ApplicationSource, "vendor/r.js"); BuildConfig(info); return info; }
public RJSConfig Build() { var info = new RJSConfig { Config = IO.GetBaseConfiguration(options), BaseUrl = DetermineApplicationPath() }; info.Excludes = FixupPaths(info.BaseUrl, GetExcludes(info.BaseUrl)); info.Includes = FixupPaths(info.BaseUrl, GetIncludes(info.BaseUrl)).Except(info.Excludes); info.BuildFilePath = Path.Combine(options.ApplicationSource, "vendor/app.build.js"); info.OptimizerPath = Path.Combine(options.ApplicationSource, "vendor/r.js"); info.OutputPath = Path.Combine(options.ApplicationSource, "main-built.js"); info.MainPath = Path.Combine(options.ApplicationSource, "main.js"); BuildConfig(info); return info; }
public RJSConfig Build() { var info = new RJSConfig { Config = IO.GetBaseConfiguration(options), BaseUrl = DetermineApplicationPath() }; info.Excludes = FixupPaths(info.BaseUrl, GetExcludes(info.BaseUrl)); info.Includes = FixupPaths(info.BaseUrl, GetIncludes(info.BaseUrl)).Except(info.Excludes); info.BuildFilePath = Path.Combine(options.ApplicationSource, amdPath, "app.build.js"); info.OptimizerPath = Path.Combine(options.ApplicationSource, amdPath, "r.js"); info.AlmondPath = Path.Combine(options.ApplicationSource, amdPath, almondName + ".js"); info.OutputPath = Path.Combine(options.ApplicationSource, "main-built.js"); info.MainPath = Path.Combine(options.ApplicationSource, "main.js"); BuildConfig(info); return(info); }
public RJSConfig Build() { var info = new RJSConfig { Config = IO.GetBaseConfiguration(options), BaseUrl = DetermineApplicationPath() }; //buildFilePath, OutputPath and MainPath are now configurable //same for moduleName, mainEntry info.Excludes = FixupPaths(info.BaseUrl, GetExcludes(info.BaseUrl)).ToArray(); info.Includes = FixupPaths(info.BaseUrl, GetIncludes(info.BaseUrl)).Except(info.Excludes, StringComparer.OrdinalIgnoreCase).ToArray(); info.BuildFilePath = Path.Combine(options.ApplicationSource, amdPath, options.BuildFile); info.OptimizerPath = Path.Combine(options.ApplicationSource, amdPath, "r.js"); info.AlmondPath = Path.Combine(options.ApplicationSource, amdPath, almondName + ".js"); info.OutputPath = Path.Combine(options.ApplicationSource, options.OutputFileName); info.MainPath = Path.Combine(options.ApplicationSource, options.MainEntry); BuildConfig(info); return info; }
void BuildConfig(RJSConfig info) { var config = info.Config; if (options.Loader == Options.LoaderOptions.Almond) { options.Log("Configuring for deploy with almond (custom)."); JSON.EnsureProperty(config, "name", amdPath + "/" + almondName); JSON.EnsureProperty(config, "mainConfigFile", info.MainPath); JSON.EnsureProperty(config, "wrap", true); } else { options.Log("Configuring for deploy with require."); JSON.EnsureProperty(config, "name", "main"); } var insertRequire = JSON.EnsureArray(config, "insertRequire"); insertRequire.Add("main"); JSON.EnsureProperty(config, "baseUrl", info.BaseUrl); JSON.EnsureProperty(config, "out", info.OutputPath); var include = JSON.EnsureArray(config, "include"); if (include.Count < 1) { foreach (var item in info.Includes) { include.Add(item); } } }
public RJSRunner(RJSConfig config, Options options) { this.config = config; this.options = options; }
void BuildConfig(RJSConfig info) { var config = info.Config; var modulesProperty = config.Property("modules"); var modules = modulesProperty == null ? null : modulesProperty.Value as JArray; var hasModules = modules != null && modules.HasValues; var insertRequire = JSON.EnsureArray(config, "insertRequire"); if (options.InsertRequire == null) options.InsertRequire = new List<string> { "main" }; foreach (var require in options.InsertRequire) { insertRequire.Add(require); } JSON.EnsureProperty(config, "baseUrl", info.BaseUrl); if (options.PreserveLicenseComments.HasValue) JSON.EnsureProperty(config, "preserveLicenseComments", options.PreserveLicenseComments); if (hasModules) { //added support for modules. Used in conjunction with option -c //we load files defined as path/*.js or path/**.js recursively //also we load text!path/*.html or text!path/**.html recursively var baseUrlProp = config.Property("baseUrl"); var baseUrl = (baseUrlProp == null ? null : baseUrlProp.Value as JValue).Value as string ?? ""; foreach (var module in modules.Children()) if (module is JObject) { var includeProp = (module as JObject).Property("include"); var include = includeProp == null ? null : includeProp.Value as JArray; if (include != null) { foreach (var item in include.ToArray()) { if (item is JValue) { var token = item as JValue; var file = token.Value as string; var searchOption = SearchOption.TopDirectoryOnly; token.Value = file; if (file.Contains("**")) { searchOption = SearchOption.AllDirectories; file = file.Replace("**", "*"); } if (file.Contains("*")) { var indexOf = file.IndexOf('!'); var prefix = ""; if (indexOf >= 0) { prefix = file.Substring(0, indexOf + 1); file = file.Substring(indexOf + 1); } var path = Path.GetDirectoryName(file); if (!Path.IsPathRooted(path)) path = Path.Combine(baseUrl, path); var pattern = Path.GetFileName(file); foreach (var f in Directory.GetFiles(path, pattern, searchOption) .Select(f => f.Substring(baseUrl.Length)) .Select(f => ".js".Equals(Path.GetExtension(f)) ? Path.Combine(Path.GetDirectoryName(f), Path.GetFileNameWithoutExtension(f)) : f) .Select(f => f.StartsWith("/") || f.StartsWith("\\") ? f.Substring(1) : f) .Select(f => f.Replace('\\', '/')) ) include.Add(new JValue(prefix + f)); include.Remove(item); } } } } } } else { if (options.Loader == Options.LoaderOptions.Almond) { options.Log("Configuring for deploy with almond (custom)."); JSON.EnsureProperty(config, "name", amdPath + "/" + almondName); JSON.EnsureProperty(config, "mainConfigFile", info.MainPath); JSON.EnsureProperty(config, "wrap", true); } else { options.Log("Configuring for deploy with require."); JSON.EnsureProperty(config, "name", options.ModuleName); } JSON.EnsureProperty(config, "out", info.OutputPath); var include = JSON.EnsureArray(config, "include"); if (include.Count < 1) { foreach (var item in info.Includes) { include.Add(item); } } } var excludes = JSON.EnsureArray(config, "exclude"); if (options.Excludes != null) foreach (var exclude in options.Excludes) { excludes.Add(exclude); } }
void BuildConfig(RJSConfig info) { var config = info.Config; if (options.Loader == Options.LoaderOptions.Almond) { options.Log("Configuring for deploy with almond (custom)."); JSON.EnsureProperty(config, "name", amdPath + "/" + almondName); JSON.EnsureProperty(config, "mainConfigFile", info.MainPath); JSON.EnsureProperty(config, "wrap", true); var insertRequire = JSON.EnsureArray(config, "insertRequire"); var moduleStart = Path.GetFileNameWithoutExtension(info.MainPath); if (insertRequire.Count < 1) { insertRequire.Add(moduleStart); } } else { options.Log("Configuring for deploy with require."); JSON.EnsureProperty(config, "name", "main"); } JSON.EnsureProperty(config, "baseUrl", info.BaseUrl); JSON.EnsureProperty(config, "out", info.OutputPath); var include = JSON.EnsureArray(config, "include"); if (include.Count < 1) { foreach (var item in info.Includes) { include.Add(item); } } }