From 8a30b00e06745cebf20b32b5a88b2ac79fbee79b Mon Sep 17 00:00:00 2001 From: Gary hunt Date: Mon, 19 Jun 2023 21:30:33 +0100 Subject: [PATCH 01/13] Add an .editorconfig --- .editorconfig | 161 +++++++++++++++++++++++++++++++++++++++++++++++- WebCompiler.sln | 7 ++- 2 files changed, 163 insertions(+), 5 deletions(-) diff --git a/.editorconfig b/.editorconfig index 642b6cfd..6d461377 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,11 +1,168 @@ -# Top-most EditorConfig file root = true +# Top-most EditorConfig file [*] indent_style = space end_of_line = crlf indent_size = 4 +# Microsoft .NET properties +csharp_new_line_before_members_in_object_initializers = false +csharp_preferred_modifier_order = public, private, protected, internal, file, new, static, abstract, virtual, sealed, readonly, override, extern, unsafe, volatile, async, required:suggestion +csharp_space_between_method_call_parameter_list_parentheses = true +csharp_space_between_method_declaration_parameter_list_parentheses = true +csharp_space_between_parentheses = control_flow_statements,expressions +csharp_style_prefer_utf8_string_literals = true:suggestion +csharp_style_var_elsewhere = false:silent +csharp_style_var_for_built_in_types = false:silent +csharp_style_var_when_type_is_apparent = false:silent +dotnet_naming_rule.constants_rule.import_to_resharper = as_predefined +dotnet_naming_rule.constants_rule.severity = warning +dotnet_naming_rule.constants_rule.style = lower_camel_case_style +dotnet_naming_rule.constants_rule.symbols = constants_symbols +dotnet_naming_rule.private_constants_rule.import_to_resharper = as_predefined +dotnet_naming_rule.private_constants_rule.severity = warning +dotnet_naming_rule.private_constants_rule.style = upper_camel_case_style +dotnet_naming_rule.private_constants_rule.symbols = private_constants_symbols +dotnet_naming_rule.private_static_readonly_rule.import_to_resharper = as_predefined +dotnet_naming_rule.private_static_readonly_rule.severity = warning +dotnet_naming_rule.private_static_readonly_rule.style = lower_camel_case_style_1 +dotnet_naming_rule.private_static_readonly_rule.symbols = private_static_readonly_symbols +dotnet_naming_style.lower_camel_case_style.capitalization = camel_case +dotnet_naming_style.lower_camel_case_style_1.capitalization = camel_case +dotnet_naming_style.lower_camel_case_style_1.required_prefix = _ +dotnet_naming_style.upper_camel_case_style.capitalization = pascal_case +dotnet_naming_symbols.constants_symbols.applicable_accessibilities = public,internal,protected,protected_internal,private_protected +dotnet_naming_symbols.constants_symbols.applicable_kinds = field +dotnet_naming_symbols.constants_symbols.required_modifiers = const +dotnet_naming_symbols.private_constants_symbols.applicable_accessibilities = private +dotnet_naming_symbols.private_constants_symbols.applicable_kinds = field +dotnet_naming_symbols.private_constants_symbols.required_modifiers = const +dotnet_naming_symbols.private_static_readonly_symbols.applicable_accessibilities = private +dotnet_naming_symbols.private_static_readonly_symbols.applicable_kinds = field +dotnet_naming_symbols.private_static_readonly_symbols.required_modifiers = static,readonly +dotnet_style_parentheses_in_arithmetic_binary_operators = never_if_unnecessary:none +dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:none +dotnet_style_parentheses_in_relational_binary_operators = never_if_unnecessary:none +dotnet_style_predefined_type_for_locals_parameters_members = true:error +dotnet_style_predefined_type_for_member_access = true:silent +dotnet_style_qualification_for_event = false:silent +dotnet_style_qualification_for_field = false:silent +dotnet_style_qualification_for_method = false:silent +dotnet_style_qualification_for_property = false:silent +dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent + +# ReSharper properties +resharper_csharp_keep_blank_lines_in_code = 1 +resharper_csharp_keep_blank_lines_in_declarations = 1 +resharper_csharp_max_line_length = 0 +resharper_csharp_wrap_lines = false +resharper_enforce_line_ending_style = true +resharper_keep_existing_attribute_arrangement = true +resharper_max_attribute_length_for_same_line = 0 +resharper_place_accessorholder_attribute_on_same_line = false +resharper_place_accessor_attribute_on_same_line = false +resharper_place_field_attribute_on_same_line = false +resharper_show_autodetect_configure_formatting_tip = false +resharper_space_within_array_access_brackets = true +resharper_space_within_checked_parentheses = true +resharper_space_within_default_parentheses = true +resharper_space_within_nameof_parentheses = true +resharper_space_within_sizeof_parentheses = true +resharper_space_within_typeof_parentheses = true +resharper_use_indent_from_vs = false +resharper_xml_keep_user_linebreaks = false +resharper_xml_wrap_lines = false +resharper_xml_wrap_tags_and_pi = false + +# ReSharper inspection severities +resharper_arguments_style_other_highlighting = error +resharper_arrange_object_creation_when_type_not_evident_highlighting = none +resharper_arrange_redundant_parentheses_highlighting = error +resharper_arrange_static_member_qualifier_highlighting = error +resharper_arrange_this_qualifier_highlighting = error +resharper_comment_typo_highlighting = warning +resharper_compare_of_floats_by_equality_operator_highlighting = none +resharper_convert_if_statement_to_return_statement_highlighting = none +resharper_convert_to_constant_local_highlighting = warning +resharper_html_id_not_resolved_highlighting = none +resharper_html_path_error_highlighting = none +resharper_inline_out_variable_declaration_highlighting = none +resharper_localizable_element_highlighting = none +resharper_member_can_be_private_global_highlighting = none +resharper_not_accessed_field_local_highlighting = none +resharper_parameter_type_can_be_enumerable_local_highlighting = warning +resharper_razor_section_not_resolved_highlighting = none +resharper_redundant_argument_default_value_highlighting = none +resharper_redundant_empty_object_creation_argument_list_highlighting = error +resharper_redundant_using_directive_highlighting = error +resharper_replace_substring_with_range_indexer_highlighting = warning +resharper_switch_statement_handles_some_known_enum_values_with_default_highlighting = none +resharper_use_nameof_expression_highlighting = error +csharp_indent_labels = one_less_than_current +csharp_using_directive_placement = outside_namespace:silent +csharp_prefer_simple_using_statement = true:silent +csharp_prefer_braces = true:silent +csharp_style_namespace_declarations = block_scoped:silent +csharp_style_prefer_method_group_conversion = true:silent +csharp_style_prefer_top_level_statements = true:silent +csharp_style_expression_bodied_methods = false:silent +csharp_style_expression_bodied_constructors = false:silent +csharp_style_expression_bodied_operators = false:silent +csharp_style_expression_bodied_properties = true:silent +csharp_style_expression_bodied_indexers = true:silent +csharp_style_expression_bodied_accessors = true:silent +csharp_style_expression_bodied_lambdas = true:silent +csharp_style_expression_bodied_local_functions = false:silent +csharp_space_around_binary_operators = before_and_after +csharp_style_throw_expression = true:silent +csharp_style_prefer_null_check_over_type_check = true:silent +csharp_style_prefer_index_operator = true:silent +csharp_style_prefer_local_over_anonymous_function = true:silent +csharp_prefer_simple_default_expression = true:silent +csharp_style_prefer_tuple_swap = true:silent +csharp_style_implicit_object_creation_when_type_is_apparent = true:silent +csharp_style_prefer_range_operator = true:silent +csharp_style_inlined_variable_declaration = true:silent +csharp_style_unused_value_assignment_preference = discard_variable:silent +csharp_style_deconstructed_variable_declaration = true:silent +csharp_style_unused_value_expression_statement_preference = discard_variable:silent +csharp_prefer_static_local_function = true:silent +csharp_style_prefer_readonly_struct = true:suggestion +csharp_style_prefer_readonly_struct_member = true:suggestion +csharp_style_allow_embedded_statements_on_same_line_experimental = true:silent +csharp_style_allow_blank_lines_between_consecutive_braces_experimental = true:silent +csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true:silent +csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental = true:silent +csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = true:silent +csharp_style_conditional_delegate_call = true:silent +dotnet_diagnostic.RS0035.severity = silent + [*.json] indent_style = space -indent_size = 2 \ No newline at end of file +indent_size = 2 + +[*.{appxmanifest,asax,ascx,aspx,axaml,axml,build,config,cs,cshtml,csproj,dbml,discomap,dtd,htm,html,jsproj,lsproj,master,njsproj,nuspec,paml,proj,props,razor,resw,resx,skin,StyleCop,targets,tasks,vb,vbproj,xaml,xamlx,xml,xoml,xsd}] +indent_style = space +indent_size = 4 +tab_width = 4 +dotnet_style_operator_placement_when_wrapping = beginning_of_line +dotnet_style_coalesce_expression = true:silent +dotnet_style_null_propagation = true:silent +dotnet_style_prefer_is_null_check_over_reference_equality_method = true:silent +dotnet_style_prefer_auto_properties = true:silent +dotnet_style_object_initializer = true:silent +dotnet_style_collection_initializer = true:silent +dotnet_style_prefer_simplified_boolean_expressions = true:silent +dotnet_style_prefer_conditional_expression_over_assignment = true:silent +dotnet_style_prefer_conditional_expression_over_return = true:silent +dotnet_style_explicit_tuple_names = true:silent +dotnet_style_prefer_inferred_tuple_names = true:silent +dotnet_style_prefer_inferred_anonymous_type_member_names = true:silent +dotnet_style_prefer_compound_assignment = true:silent +dotnet_style_prefer_simplified_interpolation = true:suggestion +dotnet_style_namespace_match_folder = true:silent +dotnet_style_readonly_field = true:silent +dotnet_style_allow_multiple_blank_lines_experimental = true:silent +dotnet_style_allow_statement_immediately_after_block_experimental = true:silent +dotnet_code_quality_unused_parameters = all:silent diff --git a/WebCompiler.sln b/WebCompiler.sln index c3380f98..46ca63d6 100644 --- a/WebCompiler.sln +++ b/WebCompiler.sln @@ -1,16 +1,17 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.24720.0 +# Visual Studio Version 17 +VisualStudioVersion = 17.6.33801.468 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebCompilerVsix", "src\WebCompilerVsix\WebCompilerVsix.csproj", "{49C270BE-9645-40D5-BE08-91ADE243D394}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebCompiler", "src\WebCompiler\WebCompiler.csproj", "{B714B5B9-27C4-443C-9517-FE5C5EF46EA2}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebCompiler", "src\WebCompiler\WebCompiler.csproj", "{B714B5B9-27C4-443C-9517-FE5C5EF46EA2}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebCompilerTest", "src\WebCompilerTest\WebCompilerTest.csproj", "{43AAA3AD-A806-45A0-99A3-F0E7E3B81AEB}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{E9E392DE-6C44-4AD2-858C-D73AD3016E6E}" ProjectSection(SolutionItems) = preProject + .editorconfig = .editorconfig appveyor.yml = appveyor.yml build\build.cmd = build\build.cmd CHANGELOG.md = CHANGELOG.md From bfdb54405df9b5d1a5882786c69be6b830e00af0 Mon Sep 17 00:00:00 2001 From: Gary hunt Date: Mon, 19 Jun 2023 21:31:14 +0100 Subject: [PATCH 02/13] Ignore the generated package.json file --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 80692d44..88ff2ea5 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,4 @@ _NCrunch_WebCompiler#Node src/WebCompiler/Node/node_modules/* /src/WebCompiler/Node/node.exe /src/WebCompiler/Node/package-lock.json +/src/WebCompiler/Node/package.json From 31f5dfe25382f18058beca08f8c8341a962be832 Mon Sep 17 00:00:00 2001 From: Gary hunt Date: Mon, 19 Jun 2023 21:31:25 +0100 Subject: [PATCH 03/13] Tag the files that need attention --- src/WebCompiler/Compile/BabelCompiler.cs | 1 + src/WebCompiler/Compile/CompilerService.cs | 2 ++ src/WebCompiler/Compile/HandlebarsCompiler.cs | 1 + src/WebCompiler/Compile/IcedCoffeeScriptCompiler.cs | 1 + src/WebCompiler/Compile/LessCompiler.cs | 1 + src/WebCompiler/Compile/NodeSassCompiler.cs | 2 ++ src/WebCompiler/Compile/SassCompiler.cs | 1 + src/WebCompiler/Compile/StylusCompiler.cs | 1 + src/WebCompiler/Config/Config.cs | 4 ++-- src/WebCompiler/Config/ConfigFileProcessor.cs | 4 ++-- 10 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/WebCompiler/Compile/BabelCompiler.cs b/src/WebCompiler/Compile/BabelCompiler.cs index 90f8b890..de00e38a 100644 --- a/src/WebCompiler/Compile/BabelCompiler.cs +++ b/src/WebCompiler/Compile/BabelCompiler.cs @@ -79,6 +79,7 @@ private void RunCompilerProcess(Config config, FileInfo info) { string arguments = ConstructArguments(config); + // TODO: GH: replace Win32 exe ProcessStartInfo start = new ProcessStartInfo { WorkingDirectory = info.Directory.FullName, diff --git a/src/WebCompiler/Compile/CompilerService.cs b/src/WebCompiler/Compile/CompilerService.cs index 9b760f9b..e2ed4a64 100644 --- a/src/WebCompiler/Compile/CompilerService.cs +++ b/src/WebCompiler/Compile/CompilerService.cs @@ -78,6 +78,7 @@ internal static ICompiler GetCompiler(Config config) public static void Initialize() { var node_modules = Path.Combine(_path, "node_modules"); + // TODO: GH: replace Win32 exe var node_exe = Path.Combine(_path, "node.exe"); var log_file = Path.Combine(_path, "log.txt"); @@ -90,6 +91,7 @@ public static void Initialize() if (Directory.Exists(_path)) Directory.Delete(_path, true); + // TODO: GH: replace Win32 commands Directory.CreateDirectory(_path); SaveResourceFile(_path, "WebCompiler.Node.node.7z", "node.7z"); SaveResourceFile(_path, "WebCompiler.Node.node_modules.7z", "node_modules.7z"); diff --git a/src/WebCompiler/Compile/HandlebarsCompiler.cs b/src/WebCompiler/Compile/HandlebarsCompiler.cs index 7a0070ef..b2854324 100644 --- a/src/WebCompiler/Compile/HandlebarsCompiler.cs +++ b/src/WebCompiler/Compile/HandlebarsCompiler.cs @@ -125,6 +125,7 @@ private void RunCompilerProcess(Config config, FileInfo info) { string arguments = ConstructArguments(config); + // TODO: GH: replace Win32 exe ProcessStartInfo start = new ProcessStartInfo { WorkingDirectory = info.Directory.FullName, diff --git a/src/WebCompiler/Compile/IcedCoffeeScriptCompiler.cs b/src/WebCompiler/Compile/IcedCoffeeScriptCompiler.cs index 65b1aecb..191b35a0 100644 --- a/src/WebCompiler/Compile/IcedCoffeeScriptCompiler.cs +++ b/src/WebCompiler/Compile/IcedCoffeeScriptCompiler.cs @@ -97,6 +97,7 @@ private void RunCompilerProcess(Config config, FileInfo info) { string arguments = ConstructArguments(config); + // TODO: GH: replace Win32 exe ProcessStartInfo start = new ProcessStartInfo { WorkingDirectory = info.Directory.FullName, diff --git a/src/WebCompiler/Compile/LessCompiler.cs b/src/WebCompiler/Compile/LessCompiler.cs index e0c63405..462d4a6d 100644 --- a/src/WebCompiler/Compile/LessCompiler.cs +++ b/src/WebCompiler/Compile/LessCompiler.cs @@ -79,6 +79,7 @@ private void RunCompilerProcess(Config config, FileInfo info) { string arguments = ConstructArguments(config); + // TODO: GH: replace Win32 exe ProcessStartInfo start = new ProcessStartInfo { WorkingDirectory = info.Directory.FullName, diff --git a/src/WebCompiler/Compile/NodeSassCompiler.cs b/src/WebCompiler/Compile/NodeSassCompiler.cs index 5f0dab16..3097de3e 100644 --- a/src/WebCompiler/Compile/NodeSassCompiler.cs +++ b/src/WebCompiler/Compile/NodeSassCompiler.cs @@ -81,6 +81,7 @@ private void RunCompilerProcess(Config config, FileInfo info) { string arguments = ConstructArguments(config); + // TODO: GH: replace Win32 exe ProcessStartInfo start = new ProcessStartInfo { WorkingDirectory = new FileInfo(config.FileName).DirectoryName, // use config's directory to fix source map relative paths @@ -104,6 +105,7 @@ private void RunCompilerProcess(Config config, FileInfo info) if (!options.SourceMap && !config.SourceMap) postCssArguments += " --no-map"; + // TODO: GH: replace Win32 .cmd file start.Arguments = start.Arguments.TrimEnd('"') + $" | \"{Path.Combine(_path, "node_modules\\.bin\\postcss.cmd")}\" {postCssArguments}\""; start.EnvironmentVariables.Add("BROWSERSLIST", options.AutoPrefix); } diff --git a/src/WebCompiler/Compile/SassCompiler.cs b/src/WebCompiler/Compile/SassCompiler.cs index ee2fa65f..ce376a18 100644 --- a/src/WebCompiler/Compile/SassCompiler.cs +++ b/src/WebCompiler/Compile/SassCompiler.cs @@ -82,6 +82,7 @@ private void RunCompilerProcess(Config config, FileInfo info) { string arguments = ConstructArguments(config); + // TODO: GH: replace Win32 exe ProcessStartInfo start = new ProcessStartInfo { WorkingDirectory = new FileInfo(config.FileName).DirectoryName, // use config's directory to fix source map relative paths diff --git a/src/WebCompiler/Compile/StylusCompiler.cs b/src/WebCompiler/Compile/StylusCompiler.cs index cd3ccd07..07cc1f63 100644 --- a/src/WebCompiler/Compile/StylusCompiler.cs +++ b/src/WebCompiler/Compile/StylusCompiler.cs @@ -80,6 +80,7 @@ private void RunCompilerProcess(Config config, FileInfo info) { string arguments = ConstructArguments(config); + // TODO: GH: replace Win32 exe ProcessStartInfo start = new ProcessStartInfo { WorkingDirectory = info.Directory.FullName, diff --git a/src/WebCompiler/Config/Config.cs b/src/WebCompiler/Config/Config.cs index 95aecee6..8782babb 100644 --- a/src/WebCompiler/Config/Config.cs +++ b/src/WebCompiler/Config/Config.cs @@ -68,7 +68,7 @@ public class Config public FileInfo GetAbsoluteInputFile() { string folder = new FileInfo(FileName).DirectoryName; - return new FileInfo(Path.Combine(folder, InputFile.Replace("/", "\\"))); + return new FileInfo(Path.Combine(folder, InputFile.Replace("/", "\\"))); // TODO: GH: check replacement } /// @@ -77,7 +77,7 @@ public FileInfo GetAbsoluteInputFile() public FileInfo GetAbsoluteOutputFile() { string folder = new FileInfo(FileName).DirectoryName; - return new FileInfo(Path.Combine(folder, OutputFile.Replace("/", "\\"))); + return new FileInfo(Path.Combine(folder, OutputFile.Replace("/", "\\"))); // TODO: GH: check replacement } /// diff --git a/src/WebCompiler/Config/ConfigFileProcessor.cs b/src/WebCompiler/Config/ConfigFileProcessor.cs index aedc8dda..bb5f34be 100644 --- a/src/WebCompiler/Config/ConfigFileProcessor.cs +++ b/src/WebCompiler/Config/ConfigFileProcessor.cs @@ -112,7 +112,7 @@ private IEnumerable SourceFileChanged(string configFile, // Compile if the file if it's referenced directly in compilerconfig.json foreach (Config config in configs) { - string input = Path.Combine(folder, config.InputFile.Replace("/", "\\")); + string input = Path.Combine(folder, config.InputFile.Replace("/", "\\")); // TODO: GH: check replacement if (input.Equals(sourceFile, StringComparison.OrdinalIgnoreCase)) { @@ -171,7 +171,7 @@ public static IEnumerable IsFileConfigured(string configFile, string sou foreach (Config config in configs) { - string input = Path.Combine(folder, config.InputFile.Replace("/", "\\")); + string input = Path.Combine(folder, config.InputFile.Replace("/", "\\")); // TODO: GH: check replacement if (input.Equals(sourceFile, StringComparison.OrdinalIgnoreCase)) list.Add(config); From c16e43a8da0cf974e3e222631b29d9c15bf32cda Mon Sep 17 00:00:00 2001 From: Gary hunt Date: Mon, 19 Jun 2023 21:41:51 +0100 Subject: [PATCH 04/13] The SCSS compile Scss test is failing due to a change of URL... assuming the code produces the right result then this patch fixes the test to include the ../ prefix --- src/WebCompilerTest/Compile/ScssTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/WebCompilerTest/Compile/ScssTest.cs b/src/WebCompilerTest/Compile/ScssTest.cs index b6b5c8cf..add7abe0 100644 --- a/src/WebCompilerTest/Compile/ScssTest.cs +++ b/src/WebCompilerTest/Compile/ScssTest.cs @@ -35,7 +35,7 @@ public void CompileScss() var first = result.First(); Assert.IsTrue(File.Exists("../../artifacts/scss/test.css")); Assert.IsTrue(first.CompiledContent.Contains("/*# sourceMappingURL=data:")); - Assert.IsTrue(result.ElementAt(1).CompiledContent.Contains("url(foo.png)")); + Assert.IsTrue(result.ElementAt(1).CompiledContent.Contains("url(../foo.png)")); Assert.IsTrue(result.ElementAt(1).CompiledContent.Contains("-webkit-animation"), "AutoPrefix"); string sourceMap = DecodeSourceMap(first.CompiledContent); From f606642a47c1af4a72dd4118eab608ee71dafe53 Mon Sep 17 00:00:00 2001 From: Gary Hunt Date: Mon, 19 Jun 2023 22:25:27 +0100 Subject: [PATCH 05/13] Linux version of build.sh --- WebCompiler.sln | 1 + build/build.sh | 81 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 build/build.sh diff --git a/WebCompiler.sln b/WebCompiler.sln index 46ca63d6..a0080ef4 100644 --- a/WebCompiler.sln +++ b/WebCompiler.sln @@ -16,6 +16,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution build\build.cmd = build\build.cmd CHANGELOG.md = CHANGELOG.md README.md = README.md + build\build.sh = build\build.sh EndProjectSection EndProject Global diff --git a/build/build.sh b/build/build.sh new file mode 100644 index 00000000..699e0793 --- /dev/null +++ b/build/build.sh @@ -0,0 +1,81 @@ +#!/bin/bash + +#:: IMPORTANT!! npm 3.x is required to avoid long path exceptions + +#// TODO: GH: replace this with linux version +#if exist "../src/WebCompiler/node/node_modules.7z" goto:EOF + +mkdir ../src/WebCompiler/node + +pushd ../src/WebCompiler/node + +# node-sass \ // TODO: GH: is this really needed? it fails to install on OS X +echo Installing packages... +npm install --quiet \ + babel@5.8.34 \ + iced-coffee-script \ + less \ + less-plugin-autoprefix \ + less-plugin-csscomb \ + sass \ + postcss@latest \ + postcss-cli \ + autoprefixer \ + stylus \ + handlebars \ + > /dev/null +npm install --quiet > /dev/null + +#if not exist "node_modules/node-sass/vendor/win32-ia32-48" ( +# echo Copying node binding... +# md "node_modules/node-sass/vendor/win32-ia32-48" +# copy binding.node "node_modules/node-sass/vendor/win32-ia32-48" +#) + +echo Deleting unneeded files and folders... +rm -rf *.html > /dev/null +rm -rf *.markdown > /dev/null +rm -rf *.md > /dev/null +rm -rf *.npmignore > /dev/null +rm -rf *.patch > /dev/null +rm -rf *.txt > /dev/null +rm -rf *.yml > /dev/null +rm -rf .editorconfig > /dev/null +rm -rf .eslintrc > /dev/null +rm -rf .gitattributes > /dev/null +rm -rf .jscsrc > /dev/null +rm -rf .jshintrc > /dev/null +rm -rf CHANGELOG > /dev/null +rm -rf CNAME > /dev/null +rm -rf example.js > /dev/null +rm -rf generate-* > /dev/null +rm -rf gruntfile.js > /dev/null +rm -rf gulpfile.* > /dev/null +rm -rf makefile.* > /dev/null +rm -rf README > /dev/null + +# TODO: limux version of the below +#for /d /r . %%d in (benchmark) do @if exist "%%d" rd /s /q "%%d" > /dev/null +#for /d /r . %%d in (bench) do @if exist "%%d" rd /s /q "%%d" > /dev/null +#for /d /r . %%d in (doc) do @if exist "%%d" rd /s /q "%%d" > /dev/null +#for /d /r . %%d in (docs) do @if exist "%%d" rd /s /q "%%d" > /dev/null +#for /d /r . %%d in (example) do @if exist "%%d" rd /s /q "%%d" > /dev/null +#for /d /r . %%d in (examples) do @if exist "%%d" rd /s /q "%%d" > /dev/null +#for /d /r . %%d in (images) do @if exist "%%d" rd /s /q "%%d" > /dev/null +#for /d /r . %%d in (man) do @if exist "%%d" rd /s /q "%%d" > /dev/null +#for /d /r . %%d in (media) do @if exist "%%d" rd /s /q "%%d" > /dev/null +#for /d /r . %%d in (scripts) do @if exist "%%d" rd /s /q "%%d" > /dev/null +#for /d /r . %%d in (test) do @if exist "%%d" rd /s /q "%%d" > /dev/null +#for /d /r . %%d in (tests) do @if exist "%%d" rd /s /q "%%d" > /dev/null +#for /d /r . %%d in (testing) do @if exist "%%d" rd /s /q "%%d" > /dev/null +#for /d /r . %%d in (tst) do @if exist "%%d" rd /s /q "%%d" > /dev/null + +echo Compressing artifacts and cleans up... +rm node_modules.7z +7z a -r -mx9 node_modules.7z node_modules > /dev/null +rm -rf node_modules > /dev/null +rm package.json > /dev/null + +#:done +echo Done +popd \ No newline at end of file From 8a99e32b36761bed5017fd075436770983a5fa91 Mon Sep 17 00:00:00 2001 From: Gary Hunt Date: Mon, 19 Jun 2023 22:41:22 +0100 Subject: [PATCH 06/13] linux version of prepare.cmd --- src/WebCompiler/Node/prepare.cmd | 1 + src/WebCompiler/Node/prepare.sh | 12 ++++++++++++ 2 files changed, 13 insertions(+) create mode 100644 src/WebCompiler/Node/prepare.sh diff --git a/src/WebCompiler/Node/prepare.cmd b/src/WebCompiler/Node/prepare.cmd index 5cc9ee48..230aeb39 100644 --- a/src/WebCompiler/Node/prepare.cmd +++ b/src/WebCompiler/Node/prepare.cmd @@ -7,3 +7,4 @@ del /q node_modules.7z del /q 7z.exe del /q 7z.dll del /q prepare.cmd +del /q prepare.sh \ No newline at end of file diff --git a/src/WebCompiler/Node/prepare.sh b/src/WebCompiler/Node/prepare.sh new file mode 100644 index 00000000..3c5e8d5d --- /dev/null +++ b/src/WebCompiler/Node/prepare.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +7z x -y node.7z node +rm node.7z + +7z x -y node_modules.7z +rm node_modules.7z + +rm 7z.exe +rm 7z.dll +rm prepare.cmd +rm prepare.sh From 31fb5cafa248fae76b27c86f65f965b1b9a55f0b Mon Sep 17 00:00:00 2001 From: Gary Hunt Date: Mon, 19 Jun 2023 23:09:34 +0100 Subject: [PATCH 07/13] Extract the files in *nix --- src/WebCompiler/Compile/CompilerService.cs | 28 ++++++++++++++++++---- src/WebCompiler/Node/prepare.cmd | 3 +-- src/WebCompiler/Node/prepare.sh | 6 ----- src/WebCompiler/WebCompiler.csproj | 6 ++++- 4 files changed, 29 insertions(+), 14 deletions(-) diff --git a/src/WebCompiler/Compile/CompilerService.cs b/src/WebCompiler/Compile/CompilerService.cs index e2ed4a64..c0972df9 100644 --- a/src/WebCompiler/Compile/CompilerService.cs +++ b/src/WebCompiler/Compile/CompilerService.cs @@ -95,17 +95,35 @@ public static void Initialize() Directory.CreateDirectory(_path); SaveResourceFile(_path, "WebCompiler.Node.node.7z", "node.7z"); SaveResourceFile(_path, "WebCompiler.Node.node_modules.7z", "node_modules.7z"); - SaveResourceFile(_path, "WebCompiler.Node.7z.exe", "7z.exe"); - SaveResourceFile(_path, "WebCompiler.Node.7z.dll", "7z.dll"); - SaveResourceFile(_path, "WebCompiler.Node.prepare.cmd", "prepare.cmd"); + + string processFileName; + string processArguments; + switch ( System.Environment.OSVersion.Platform ) + { + case PlatformID.Unix: + case PlatformID.MacOSX: + SaveResourceFile(_path, "WebCompiler.Node.prepare.sh", "prepare.sh"); + processFileName = "/bin/bash"; + processArguments = "prepare.sh"; + break; + + default: + SaveResourceFile(_path, "WebCompiler.Node.7z.exe", "7z.exe"); + SaveResourceFile(_path, "WebCompiler.Node.7z.dll", "7z.dll"); + SaveResourceFile(_path, "WebCompiler.Node.prepare.cmd", "prepare.cmd"); + processFileName = "cmd.exe"; + processArguments = "/c prepare.cmd"; + break; + } + ProcessStartInfo start = new ProcessStartInfo { WorkingDirectory = _path, CreateNoWindow = true, WindowStyle = ProcessWindowStyle.Hidden, - FileName = "cmd.exe", - Arguments = "/c prepare.cmd" + FileName = processFileName, + Arguments = processArguments }; Process p = Process.Start(start); diff --git a/src/WebCompiler/Node/prepare.cmd b/src/WebCompiler/Node/prepare.cmd index 230aeb39..d70e645e 100644 --- a/src/WebCompiler/Node/prepare.cmd +++ b/src/WebCompiler/Node/prepare.cmd @@ -6,5 +6,4 @@ del /q node_modules.7z del /q 7z.exe del /q 7z.dll -del /q prepare.cmd -del /q prepare.sh \ No newline at end of file +del /q prepare.cmd \ No newline at end of file diff --git a/src/WebCompiler/Node/prepare.sh b/src/WebCompiler/Node/prepare.sh index 3c5e8d5d..c517a12b 100644 --- a/src/WebCompiler/Node/prepare.sh +++ b/src/WebCompiler/Node/prepare.sh @@ -1,12 +1,6 @@ #!/bin/bash -7z x -y node.7z node -rm node.7z - 7z x -y node_modules.7z rm node_modules.7z -rm 7z.exe -rm 7z.dll -rm prepare.cmd rm prepare.sh diff --git a/src/WebCompiler/WebCompiler.csproj b/src/WebCompiler/WebCompiler.csproj index d9f67426..0fe7d676 100644 --- a/src/WebCompiler/WebCompiler.csproj +++ b/src/WebCompiler/WebCompiler.csproj @@ -2,7 +2,7 @@ Exe - net4.8;netstandard2.1;netcoreapp3.1 + netcoreapp3.1;net4.8;netstandard2.1 latest Web Compiler BuildWebCompiler2022 @@ -23,6 +23,7 @@ + @@ -33,6 +34,9 @@ + + + From 6c18542289f16ac588b57b5c95d0900608ed3f65 Mon Sep 17 00:00:00 2001 From: Gary hunt Date: Mon, 19 Jun 2023 23:10:08 +0100 Subject: [PATCH 08/13] Introduce variables --- src/WebCompiler/Compile/BabelCompiler.cs | 8 ++++++-- src/WebCompiler/Compile/HandlebarsCompiler.cs | 8 ++++++-- src/WebCompiler/Compile/IcedCoffeeScriptCompiler.cs | 8 ++++++-- src/WebCompiler/Compile/LessCompiler.cs | 8 ++++++-- src/WebCompiler/Compile/NodeSassCompiler.cs | 8 ++++++-- src/WebCompiler/Compile/SassCompiler.cs | 8 ++++++-- src/WebCompiler/Compile/StylusCompiler.cs | 8 ++++++-- src/WebCompiler/Config/Config.cs | 7 ++++--- 8 files changed, 46 insertions(+), 17 deletions(-) diff --git a/src/WebCompiler/Compile/BabelCompiler.cs b/src/WebCompiler/Compile/BabelCompiler.cs index de00e38a..28418cf7 100644 --- a/src/WebCompiler/Compile/BabelCompiler.cs +++ b/src/WebCompiler/Compile/BabelCompiler.cs @@ -80,20 +80,24 @@ private void RunCompilerProcess(Config config, FileInfo info) string arguments = ConstructArguments(config); // TODO: GH: replace Win32 exe + string processFileName = "cmd.exe"; + string processArguments = $"/c \"\"{Path.Combine(_path, "node_modules\\.bin\\babel.cmd")}\" {arguments} \"{info.FullName}\"\""; + ProcessStartInfo start = new ProcessStartInfo { WorkingDirectory = info.Directory.FullName, UseShellExecute = false, WindowStyle = ProcessWindowStyle.Hidden, CreateNoWindow = true, - FileName = "cmd.exe", - Arguments = $"/c \"\"{Path.Combine(_path, "node_modules\\.bin\\babel.cmd")}\" {arguments} \"{info.FullName}\"\"", + FileName = processFileName, + Arguments = processArguments, StandardOutputEncoding = Encoding.UTF8, StandardErrorEncoding = Encoding.UTF8, RedirectStandardOutput = true, RedirectStandardError = true, }; + // TODO: GH: replace Win32 exe start.EnvironmentVariables["PATH"] = _path + ";" + start.EnvironmentVariables["PATH"]; using (Process p = Process.Start(start)) diff --git a/src/WebCompiler/Compile/HandlebarsCompiler.cs b/src/WebCompiler/Compile/HandlebarsCompiler.cs index b2854324..abb364bc 100644 --- a/src/WebCompiler/Compile/HandlebarsCompiler.cs +++ b/src/WebCompiler/Compile/HandlebarsCompiler.cs @@ -126,20 +126,24 @@ private void RunCompilerProcess(Config config, FileInfo info) string arguments = ConstructArguments(config); // TODO: GH: replace Win32 exe + string processFileName = "cmd.exe"; + string processArguments = $"/c \"\"{Path.Combine(_path, "node_modules\\.bin\\handlebars.cmd")}\" \"{info.FullName}\" {arguments}\""; + ProcessStartInfo start = new ProcessStartInfo { WorkingDirectory = info.Directory.FullName, UseShellExecute = false, WindowStyle = ProcessWindowStyle.Hidden, CreateNoWindow = true, - FileName = "cmd.exe", - Arguments = $"/c \"\"{Path.Combine(_path, "node_modules\\.bin\\handlebars.cmd")}\" \"{info.FullName}\" {arguments}\"", + FileName = processFileName, + Arguments = processArguments, StandardOutputEncoding = Encoding.UTF8, StandardErrorEncoding = Encoding.UTF8, RedirectStandardOutput = true, RedirectStandardError = true, }; + // TODO: GH: replace Win32 exe start.EnvironmentVariables["PATH"] = _path + ";" + start.EnvironmentVariables["PATH"]; using (Process p = Process.Start(start)) diff --git a/src/WebCompiler/Compile/IcedCoffeeScriptCompiler.cs b/src/WebCompiler/Compile/IcedCoffeeScriptCompiler.cs index 191b35a0..11bca204 100644 --- a/src/WebCompiler/Compile/IcedCoffeeScriptCompiler.cs +++ b/src/WebCompiler/Compile/IcedCoffeeScriptCompiler.cs @@ -98,18 +98,22 @@ private void RunCompilerProcess(Config config, FileInfo info) string arguments = ConstructArguments(config); // TODO: GH: replace Win32 exe + string processFileName = "cmd.exe"; + string processArguments = $"/c \"\"{Path.Combine(_path, "node_modules\\.bin\\iced.cmd")}\" {arguments} \"{info.FullName}\"\""; + ProcessStartInfo start = new ProcessStartInfo { WorkingDirectory = info.Directory.FullName, UseShellExecute = false, WindowStyle = ProcessWindowStyle.Hidden, CreateNoWindow = true, - FileName = "cmd.exe", - Arguments = $"/c \"\"{Path.Combine(_path, "node_modules\\.bin\\iced.cmd")}\" {arguments} \"{info.FullName}\"\"", + FileName = processFileName, + Arguments = processArguments, StandardErrorEncoding = Encoding.UTF8, RedirectStandardError = true, }; + // TODO: GH replace with nix variables start.EnvironmentVariables["PATH"] = _path + ";" + start.EnvironmentVariables["PATH"]; using (Process p = Process.Start(start)) diff --git a/src/WebCompiler/Compile/LessCompiler.cs b/src/WebCompiler/Compile/LessCompiler.cs index 462d4a6d..f1f86060 100644 --- a/src/WebCompiler/Compile/LessCompiler.cs +++ b/src/WebCompiler/Compile/LessCompiler.cs @@ -80,20 +80,24 @@ private void RunCompilerProcess(Config config, FileInfo info) string arguments = ConstructArguments(config); // TODO: GH: replace Win32 exe + string processFileName = "cmd.exe"; + string processArguments = $"/c \"\"{Path.Combine(_path, "node_modules\\.bin\\lessc.cmd")}\" {arguments} \"{info.FullName}\"\""; + ProcessStartInfo start = new ProcessStartInfo { WorkingDirectory = info.Directory.FullName, UseShellExecute = false, WindowStyle = ProcessWindowStyle.Hidden, CreateNoWindow = true, - FileName = "cmd.exe", - Arguments = $"/c \"\"{Path.Combine(_path, "node_modules\\.bin\\lessc.cmd")}\" {arguments} \"{info.FullName}\"\"", + FileName = processFileName, + Arguments = processArguments, StandardOutputEncoding = Encoding.UTF8, StandardErrorEncoding = Encoding.UTF8, RedirectStandardOutput = true, RedirectStandardError = true, }; + // TODO: GH: replace Win32 exe start.EnvironmentVariables["PATH"] = _path + ";" + start.EnvironmentVariables["PATH"]; using (Process p = Process.Start(start)) diff --git a/src/WebCompiler/Compile/NodeSassCompiler.cs b/src/WebCompiler/Compile/NodeSassCompiler.cs index 3097de3e..4bf36e21 100644 --- a/src/WebCompiler/Compile/NodeSassCompiler.cs +++ b/src/WebCompiler/Compile/NodeSassCompiler.cs @@ -82,14 +82,17 @@ private void RunCompilerProcess(Config config, FileInfo info) string arguments = ConstructArguments(config); // TODO: GH: replace Win32 exe + string processFileName = "cmd.exe"; + string processArguments = $"/c \"\"{Path.Combine(_path, "node_modules\\.bin\\node-sass.cmd")}\" {arguments} \"{info.FullName}\" \""; + ProcessStartInfo start = new ProcessStartInfo { WorkingDirectory = new FileInfo(config.FileName).DirectoryName, // use config's directory to fix source map relative paths UseShellExecute = false, WindowStyle = ProcessWindowStyle.Hidden, CreateNoWindow = true, - FileName = "cmd.exe", - Arguments = $"/c \"\"{Path.Combine(_path, "node_modules\\.bin\\node-sass.cmd")}\" {arguments} \"{info.FullName}\" \"", + FileName = processFileName, + Arguments = processArguments, StandardOutputEncoding = Encoding.UTF8, StandardErrorEncoding = Encoding.UTF8, RedirectStandardOutput = true, @@ -110,6 +113,7 @@ private void RunCompilerProcess(Config config, FileInfo info) start.EnvironmentVariables.Add("BROWSERSLIST", options.AutoPrefix); } + // TODO: GH: replace Win32 exe start.EnvironmentVariables["PATH"] = _path + ";" + start.EnvironmentVariables["PATH"]; using (Process p = Process.Start(start)) diff --git a/src/WebCompiler/Compile/SassCompiler.cs b/src/WebCompiler/Compile/SassCompiler.cs index ce376a18..742f7900 100644 --- a/src/WebCompiler/Compile/SassCompiler.cs +++ b/src/WebCompiler/Compile/SassCompiler.cs @@ -83,14 +83,17 @@ private void RunCompilerProcess(Config config, FileInfo info) string arguments = ConstructArguments(config); // TODO: GH: replace Win32 exe + string processFileName = "cmd.exe"; + string processArguments = $"/c \"\"{Path.Combine(_path, "node_modules\\.bin\\sass.cmd")}\" {arguments} \"{info.FullName}\" \""; + ProcessStartInfo start = new ProcessStartInfo { WorkingDirectory = new FileInfo(config.FileName).DirectoryName, // use config's directory to fix source map relative paths UseShellExecute = false, WindowStyle = ProcessWindowStyle.Hidden, CreateNoWindow = true, - FileName = "cmd.exe", - Arguments = $"/c \"\"{Path.Combine(_path, "node_modules\\.bin\\sass.cmd")}\" {arguments} \"{info.FullName}\" \"", + FileName = processFileName, + Arguments = processArguments, StandardOutputEncoding = Encoding.UTF8, StandardErrorEncoding = Encoding.UTF8, RedirectStandardOutput = true, @@ -108,6 +111,7 @@ private void RunCompilerProcess(Config config, FileInfo info) postCssArguments += " --no-map"; } + // TODO: GH: replace Win32 exe start.Arguments = start.Arguments.TrimEnd('"') + $" | \"{Path.Combine(_path, "node_modules\\.bin\\postcss.cmd")}\" {postCssArguments}\""; start.EnvironmentVariables.Add("BROWSERSLIST", options.AutoPrefix); } diff --git a/src/WebCompiler/Compile/StylusCompiler.cs b/src/WebCompiler/Compile/StylusCompiler.cs index 07cc1f63..d0de7c6e 100644 --- a/src/WebCompiler/Compile/StylusCompiler.cs +++ b/src/WebCompiler/Compile/StylusCompiler.cs @@ -81,20 +81,24 @@ private void RunCompilerProcess(Config config, FileInfo info) string arguments = ConstructArguments(config); // TODO: GH: replace Win32 exe + string processFileName = "cmd.exe"; + string processArguments = $"/c \"\"{Path.Combine(_path, "node_modules\\.bin\\stylus.cmd")}\" {arguments} \"{info.FullName}\"\""; + ProcessStartInfo start = new ProcessStartInfo { WorkingDirectory = info.Directory.FullName, UseShellExecute = false, WindowStyle = ProcessWindowStyle.Hidden, CreateNoWindow = true, - FileName = "cmd.exe", - Arguments = $"/c \"\"{Path.Combine(_path, "node_modules\\.bin\\stylus.cmd")}\" {arguments} \"{info.FullName}\"\"", + FileName = processFileName, + Arguments = processArguments, StandardOutputEncoding = Encoding.UTF8, StandardErrorEncoding = Encoding.UTF8, RedirectStandardOutput = true, RedirectStandardError = true, }; + // TODO: GH: replace Win32 exe start.EnvironmentVariables["PATH"] = _path + ";" + start.EnvironmentVariables["PATH"]; using (Process p = Process.Start(start)) diff --git a/src/WebCompiler/Config/Config.cs b/src/WebCompiler/Config/Config.cs index 8782babb..45c68fcf 100644 --- a/src/WebCompiler/Config/Config.cs +++ b/src/WebCompiler/Config/Config.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.ComponentModel; using System.IO; using System.Linq; @@ -68,7 +69,7 @@ public class Config public FileInfo GetAbsoluteInputFile() { string folder = new FileInfo(FileName).DirectoryName; - return new FileInfo(Path.Combine(folder, InputFile.Replace("/", "\\"))); // TODO: GH: check replacement + return new FileInfo(Path.Combine(folder, InputFile.Replace('/', Path.DirectorySeparatorChar))); } /// @@ -77,7 +78,7 @@ public FileInfo GetAbsoluteInputFile() public FileInfo GetAbsoluteOutputFile() { string folder = new FileInfo(FileName).DirectoryName; - return new FileInfo(Path.Combine(folder, OutputFile.Replace("/", "\\"))); // TODO: GH: check replacement + return new FileInfo(Path.Combine(folder, OutputFile.Replace('/', Path.DirectorySeparatorChar))); } /// From ed1d01e1588fa51881369ca143544e0052e06fa0 Mon Sep 17 00:00:00 2001 From: Gary Hunt Date: Mon, 19 Jun 2023 23:37:35 +0100 Subject: [PATCH 09/13] *nix versions of the various commands --- src/WebCompiler/Compile/BabelCompiler.cs | 31 +++++++++++-- src/WebCompiler/Compile/CompilerService.cs | 17 +++++-- src/WebCompiler/Compile/HandlebarsCompiler.cs | 31 +++++++++++-- .../Compile/IcedCoffeeScriptCompiler.cs | 31 +++++++++++-- src/WebCompiler/Compile/LessCompiler.cs | 31 +++++++++++-- src/WebCompiler/Compile/NodeSassCompiler.cs | 46 ++++++++++++++++--- src/WebCompiler/Compile/SassCompiler.cs | 45 +++++++++++++++--- src/WebCompiler/Compile/StylusCompiler.cs | 31 +++++++++++-- src/WebCompiler/Config/ConfigFileProcessor.cs | 4 +- src/WebCompiler/WebCompiler.csproj | 6 +-- 10 files changed, 226 insertions(+), 47 deletions(-) diff --git a/src/WebCompiler/Compile/BabelCompiler.cs b/src/WebCompiler/Compile/BabelCompiler.cs index 28418cf7..c1e87cbd 100644 --- a/src/WebCompiler/Compile/BabelCompiler.cs +++ b/src/WebCompiler/Compile/BabelCompiler.cs @@ -79,9 +79,21 @@ private void RunCompilerProcess(Config config, FileInfo info) { string arguments = ConstructArguments(config); - // TODO: GH: replace Win32 exe - string processFileName = "cmd.exe"; - string processArguments = $"/c \"\"{Path.Combine(_path, "node_modules\\.bin\\babel.cmd")}\" {arguments} \"{info.FullName}\"\""; + string processFileName; + string processArguments; + switch ( Environment.OSVersion.Platform ) + { + case PlatformID.Unix: + case PlatformID.MacOSX: + processFileName = "/bin/bash"; + processArguments = $"\"{Path.Combine(_path, "node_modules/.bin/babel")}\" {arguments} \"{info.FullName}\""; + break; + + default: + processFileName = "cmd.exe"; + processArguments = $"/c \"\"{Path.Combine(_path, "node_modules\\.bin\\babel.cmd")}\" {arguments} \"{info.FullName}\" \""; + break; + } ProcessStartInfo start = new ProcessStartInfo { @@ -97,8 +109,17 @@ private void RunCompilerProcess(Config config, FileInfo info) RedirectStandardError = true, }; - // TODO: GH: replace Win32 exe - start.EnvironmentVariables["PATH"] = _path + ";" + start.EnvironmentVariables["PATH"]; + switch ( Environment.OSVersion.Platform ) + { + case PlatformID.Unix: + case PlatformID.MacOSX: + start.EnvironmentVariables["PATH"] = _path + ":" + start.EnvironmentVariables["PATH"]; + break; + + default: + start.EnvironmentVariables["PATH"] = _path + ";" + start.EnvironmentVariables["PATH"]; + break; + } using (Process p = Process.Start(start)) { diff --git a/src/WebCompiler/Compile/CompilerService.cs b/src/WebCompiler/Compile/CompilerService.cs index c0972df9..5d504846 100644 --- a/src/WebCompiler/Compile/CompilerService.cs +++ b/src/WebCompiler/Compile/CompilerService.cs @@ -78,8 +78,20 @@ internal static ICompiler GetCompiler(Config config) public static void Initialize() { var node_modules = Path.Combine(_path, "node_modules"); - // TODO: GH: replace Win32 exe - var node_exe = Path.Combine(_path, "node.exe"); + + string node_exe; + switch ( Environment.OSVersion.Platform ) + { + case PlatformID.Unix: + case PlatformID.MacOSX: + node_exe = "node"; + break; + + default: + node_exe = "node.exe"; + break; + } + var log_file = Path.Combine(_path, "log.txt"); lock (_syncRoot) @@ -91,7 +103,6 @@ public static void Initialize() if (Directory.Exists(_path)) Directory.Delete(_path, true); - // TODO: GH: replace Win32 commands Directory.CreateDirectory(_path); SaveResourceFile(_path, "WebCompiler.Node.node.7z", "node.7z"); SaveResourceFile(_path, "WebCompiler.Node.node_modules.7z", "node_modules.7z"); diff --git a/src/WebCompiler/Compile/HandlebarsCompiler.cs b/src/WebCompiler/Compile/HandlebarsCompiler.cs index abb364bc..370ab45c 100644 --- a/src/WebCompiler/Compile/HandlebarsCompiler.cs +++ b/src/WebCompiler/Compile/HandlebarsCompiler.cs @@ -125,9 +125,21 @@ private void RunCompilerProcess(Config config, FileInfo info) { string arguments = ConstructArguments(config); - // TODO: GH: replace Win32 exe - string processFileName = "cmd.exe"; - string processArguments = $"/c \"\"{Path.Combine(_path, "node_modules\\.bin\\handlebars.cmd")}\" \"{info.FullName}\" {arguments}\""; + string processFileName; + string processArguments; + switch ( Environment.OSVersion.Platform ) + { + case PlatformID.Unix: + case PlatformID.MacOSX: + processFileName = "/bin/bash"; + processArguments = $"\"{Path.Combine(_path, "node_modules/.bin/handlebars")}\" {arguments} \"{info.FullName}\""; + break; + + default: + processFileName = "cmd.exe"; + processArguments = $"/c \"\"{Path.Combine(_path, "node_modules\\.bin\\handlebars.cmd")}\" {arguments} \"{info.FullName}\" \""; + break; + } ProcessStartInfo start = new ProcessStartInfo { @@ -143,8 +155,17 @@ private void RunCompilerProcess(Config config, FileInfo info) RedirectStandardError = true, }; - // TODO: GH: replace Win32 exe - start.EnvironmentVariables["PATH"] = _path + ";" + start.EnvironmentVariables["PATH"]; + switch ( Environment.OSVersion.Platform ) + { + case PlatformID.Unix: + case PlatformID.MacOSX: + start.EnvironmentVariables["PATH"] = _path + ":" + start.EnvironmentVariables["PATH"]; + break; + + default: + start.EnvironmentVariables["PATH"] = _path + ";" + start.EnvironmentVariables["PATH"]; + break; + } using (Process p = Process.Start(start)) { diff --git a/src/WebCompiler/Compile/IcedCoffeeScriptCompiler.cs b/src/WebCompiler/Compile/IcedCoffeeScriptCompiler.cs index 11bca204..83f30516 100644 --- a/src/WebCompiler/Compile/IcedCoffeeScriptCompiler.cs +++ b/src/WebCompiler/Compile/IcedCoffeeScriptCompiler.cs @@ -97,9 +97,21 @@ private void RunCompilerProcess(Config config, FileInfo info) { string arguments = ConstructArguments(config); - // TODO: GH: replace Win32 exe - string processFileName = "cmd.exe"; - string processArguments = $"/c \"\"{Path.Combine(_path, "node_modules\\.bin\\iced.cmd")}\" {arguments} \"{info.FullName}\"\""; + string processFileName; + string processArguments; + switch ( Environment.OSVersion.Platform ) + { + case PlatformID.Unix: + case PlatformID.MacOSX: + processFileName = "/bin/bash"; + processArguments = $"\"{Path.Combine(_path, "node_modules/.bin/iced")}\" {arguments} \"{info.FullName}\""; + break; + + default: + processFileName = "cmd.exe"; + processArguments = $"/c \"\"{Path.Combine(_path, "node_modules\\.bin\\iced.cmd")}\" {arguments} \"{info.FullName}\" \""; + break; + } ProcessStartInfo start = new ProcessStartInfo { @@ -113,8 +125,17 @@ private void RunCompilerProcess(Config config, FileInfo info) RedirectStandardError = true, }; - // TODO: GH replace with nix variables - start.EnvironmentVariables["PATH"] = _path + ";" + start.EnvironmentVariables["PATH"]; + switch ( Environment.OSVersion.Platform ) + { + case PlatformID.Unix: + case PlatformID.MacOSX: + start.EnvironmentVariables["PATH"] = _path + ":" + start.EnvironmentVariables["PATH"]; + break; + + default: + start.EnvironmentVariables["PATH"] = _path + ";" + start.EnvironmentVariables["PATH"]; + break; + } using (Process p = Process.Start(start)) { diff --git a/src/WebCompiler/Compile/LessCompiler.cs b/src/WebCompiler/Compile/LessCompiler.cs index f1f86060..e2e4b28b 100644 --- a/src/WebCompiler/Compile/LessCompiler.cs +++ b/src/WebCompiler/Compile/LessCompiler.cs @@ -79,9 +79,21 @@ private void RunCompilerProcess(Config config, FileInfo info) { string arguments = ConstructArguments(config); - // TODO: GH: replace Win32 exe - string processFileName = "cmd.exe"; - string processArguments = $"/c \"\"{Path.Combine(_path, "node_modules\\.bin\\lessc.cmd")}\" {arguments} \"{info.FullName}\"\""; + string processFileName; + string processArguments; + switch ( Environment.OSVersion.Platform ) + { + case PlatformID.Unix: + case PlatformID.MacOSX: + processFileName = "/bin/bash"; + processArguments = $"\"{Path.Combine(_path, "node_modules/.bin/lessc")}\" {arguments} \"{info.FullName}\""; + break; + + default: + processFileName = "cmd.exe"; + processArguments = $"/c \"\"{Path.Combine(_path, "node_modules\\.bin\\lessc.cmd")}\" {arguments} \"{info.FullName}\" \""; + break; + } ProcessStartInfo start = new ProcessStartInfo { @@ -97,8 +109,17 @@ private void RunCompilerProcess(Config config, FileInfo info) RedirectStandardError = true, }; - // TODO: GH: replace Win32 exe - start.EnvironmentVariables["PATH"] = _path + ";" + start.EnvironmentVariables["PATH"]; + switch ( Environment.OSVersion.Platform ) + { + case PlatformID.Unix: + case PlatformID.MacOSX: + start.EnvironmentVariables["PATH"] = _path + ":" + start.EnvironmentVariables["PATH"]; + break; + + default: + start.EnvironmentVariables["PATH"] = _path + ";" + start.EnvironmentVariables["PATH"]; + break; + } using (Process p = Process.Start(start)) { diff --git a/src/WebCompiler/Compile/NodeSassCompiler.cs b/src/WebCompiler/Compile/NodeSassCompiler.cs index 4bf36e21..c7f90ad0 100644 --- a/src/WebCompiler/Compile/NodeSassCompiler.cs +++ b/src/WebCompiler/Compile/NodeSassCompiler.cs @@ -81,9 +81,21 @@ private void RunCompilerProcess(Config config, FileInfo info) { string arguments = ConstructArguments(config); - // TODO: GH: replace Win32 exe - string processFileName = "cmd.exe"; - string processArguments = $"/c \"\"{Path.Combine(_path, "node_modules\\.bin\\node-sass.cmd")}\" {arguments} \"{info.FullName}\" \""; + string processFileName; + string processArguments; + switch ( Environment.OSVersion.Platform ) + { + case PlatformID.Unix: + case PlatformID.MacOSX: + processFileName = "/bin/bash"; + processArguments = $"\"{Path.Combine(_path, "node_modules/.bin/node-sass")}\" {arguments} \"{info.FullName}\""; + break; + + default: + processFileName = "cmd.exe"; + processArguments = $"/c \"\"{Path.Combine(_path, "node_modules\\.bin\\node-sass.cmd")}\" {arguments} \"{info.FullName}\" \""; + break; + } ProcessStartInfo start = new ProcessStartInfo { @@ -108,13 +120,33 @@ private void RunCompilerProcess(Config config, FileInfo info) if (!options.SourceMap && !config.SourceMap) postCssArguments += " --no-map"; - // TODO: GH: replace Win32 .cmd file - start.Arguments = start.Arguments.TrimEnd('"') + $" | \"{Path.Combine(_path, "node_modules\\.bin\\postcss.cmd")}\" {postCssArguments}\""; + switch ( Environment.OSVersion.Platform ) + { + case PlatformID.Unix: + case PlatformID.MacOSX: + start.Arguments = start.Arguments + $" | \"{Path.Combine(_path, "node_modules/.bin/postcss")}\" {postCssArguments}\""; + break; + + default: + start.Arguments = start.Arguments.TrimEnd('"') + $" | \"{Path.Combine(_path, "node_modules\\.bin\\postcss.cmd")}\" {postCssArguments}\""; + break; + } + + start.EnvironmentVariables.Add("BROWSERSLIST", options.AutoPrefix); } - // TODO: GH: replace Win32 exe - start.EnvironmentVariables["PATH"] = _path + ";" + start.EnvironmentVariables["PATH"]; + switch ( Environment.OSVersion.Platform ) + { + case PlatformID.Unix: + case PlatformID.MacOSX: + start.EnvironmentVariables["PATH"] = _path + ":" + start.EnvironmentVariables["PATH"]; + break; + + default: + start.EnvironmentVariables["PATH"] = _path + ";" + start.EnvironmentVariables["PATH"]; + break; + } using (Process p = Process.Start(start)) { diff --git a/src/WebCompiler/Compile/SassCompiler.cs b/src/WebCompiler/Compile/SassCompiler.cs index 742f7900..ff78e14b 100644 --- a/src/WebCompiler/Compile/SassCompiler.cs +++ b/src/WebCompiler/Compile/SassCompiler.cs @@ -82,9 +82,21 @@ private void RunCompilerProcess(Config config, FileInfo info) { string arguments = ConstructArguments(config); - // TODO: GH: replace Win32 exe - string processFileName = "cmd.exe"; - string processArguments = $"/c \"\"{Path.Combine(_path, "node_modules\\.bin\\sass.cmd")}\" {arguments} \"{info.FullName}\" \""; + string processFileName; + string processArguments; + switch ( Environment.OSVersion.Platform ) + { + case PlatformID.Unix: + case PlatformID.MacOSX: + processFileName = "/bin/bash"; + processArguments = $"\"{Path.Combine(_path, "node_modules/.bin/sass")}\" {arguments} \"{info.FullName}\""; + break; + + default: + processFileName = "cmd.exe"; + processArguments = $"/c \"\"{Path.Combine(_path, "node_modules\\.bin\\sass.cmd")}\" {arguments} \"{info.FullName}\" \""; + break; + } ProcessStartInfo start = new ProcessStartInfo { @@ -111,13 +123,32 @@ private void RunCompilerProcess(Config config, FileInfo info) postCssArguments += " --no-map"; } - // TODO: GH: replace Win32 exe - start.Arguments = start.Arguments.TrimEnd('"') + $" | \"{Path.Combine(_path, "node_modules\\.bin\\postcss.cmd")}\" {postCssArguments}\""; + switch ( Environment.OSVersion.Platform ) + { + case PlatformID.Unix: + case PlatformID.MacOSX: + start.Arguments = start.Arguments + $" | \"{Path.Combine(_path, "node_modules/.bin/postcss")}\" {postCssArguments}\""; + break; + + default: + start.Arguments = start.Arguments.TrimEnd('"') + $" | \"{Path.Combine(_path, "node_modules\\.bin\\postcss.cmd")}\" {postCssArguments}\""; + break; + } start.EnvironmentVariables.Add("BROWSERSLIST", options.AutoPrefix); } - start.EnvironmentVariables["PATH"] = _path + ";" + start.EnvironmentVariables["PATH"]; - + switch ( Environment.OSVersion.Platform ) + { + case PlatformID.Unix: + case PlatformID.MacOSX: + start.EnvironmentVariables["PATH"] = _path + ":" + start.EnvironmentVariables["PATH"]; + break; + + default: + start.EnvironmentVariables["PATH"] = _path + ";" + start.EnvironmentVariables["PATH"]; + break; + } + using (Process p = Process.Start(start)) { var stdout = p.StandardOutput.ReadToEndAsync(); diff --git a/src/WebCompiler/Compile/StylusCompiler.cs b/src/WebCompiler/Compile/StylusCompiler.cs index d0de7c6e..b4c80686 100644 --- a/src/WebCompiler/Compile/StylusCompiler.cs +++ b/src/WebCompiler/Compile/StylusCompiler.cs @@ -80,9 +80,21 @@ private void RunCompilerProcess(Config config, FileInfo info) { string arguments = ConstructArguments(config); - // TODO: GH: replace Win32 exe - string processFileName = "cmd.exe"; - string processArguments = $"/c \"\"{Path.Combine(_path, "node_modules\\.bin\\stylus.cmd")}\" {arguments} \"{info.FullName}\"\""; + string processFileName; + string processArguments; + switch ( Environment.OSVersion.Platform ) + { + case PlatformID.Unix: + case PlatformID.MacOSX: + processFileName = "/bin/bash"; + processArguments = $"\"{Path.Combine(_path, "node_modules/.bin/stylus")}\" {arguments} \"{info.FullName}\""; + break; + + default: + processFileName = "cmd.exe"; + processArguments = $"/c \"\"{Path.Combine(_path, "node_modules\\.bin\\stylus.cmd")}\" {arguments} \"{info.FullName}\" \""; + break; + } ProcessStartInfo start = new ProcessStartInfo { @@ -98,8 +110,17 @@ private void RunCompilerProcess(Config config, FileInfo info) RedirectStandardError = true, }; - // TODO: GH: replace Win32 exe - start.EnvironmentVariables["PATH"] = _path + ";" + start.EnvironmentVariables["PATH"]; + switch ( Environment.OSVersion.Platform ) + { + case PlatformID.Unix: + case PlatformID.MacOSX: + start.EnvironmentVariables["PATH"] = _path + ":" + start.EnvironmentVariables["PATH"]; + break; + + default: + start.EnvironmentVariables["PATH"] = _path + ";" + start.EnvironmentVariables["PATH"]; + break; + } using (Process p = Process.Start(start)) { diff --git a/src/WebCompiler/Config/ConfigFileProcessor.cs b/src/WebCompiler/Config/ConfigFileProcessor.cs index bb5f34be..eeda8411 100644 --- a/src/WebCompiler/Config/ConfigFileProcessor.cs +++ b/src/WebCompiler/Config/ConfigFileProcessor.cs @@ -112,7 +112,7 @@ private IEnumerable SourceFileChanged(string configFile, // Compile if the file if it's referenced directly in compilerconfig.json foreach (Config config in configs) { - string input = Path.Combine(folder, config.InputFile.Replace("/", "\\")); // TODO: GH: check replacement + string input = Path.Combine(folder, config.InputFile.Replace('/', Path.DirectorySeparatorChar)); if (input.Equals(sourceFile, StringComparison.OrdinalIgnoreCase)) { @@ -171,7 +171,7 @@ public static IEnumerable IsFileConfigured(string configFile, string sou foreach (Config config in configs) { - string input = Path.Combine(folder, config.InputFile.Replace("/", "\\")); // TODO: GH: check replacement + string input = Path.Combine(folder, config.InputFile.Replace('/', Path.DirectorySeparatorChar)); if (input.Equals(sourceFile, StringComparison.OrdinalIgnoreCase)) list.Add(config); diff --git a/src/WebCompiler/WebCompiler.csproj b/src/WebCompiler/WebCompiler.csproj index 0fe7d676..b773055d 100644 --- a/src/WebCompiler/WebCompiler.csproj +++ b/src/WebCompiler/WebCompiler.csproj @@ -34,12 +34,12 @@ - - - + + +