From 40d9e3704288c9c2f55aef48a5b5e19ab413bb37 Mon Sep 17 00:00:00 2001 From: VictorPaiu Date: Thu, 2 Oct 2025 09:44:53 +0200 Subject: [PATCH 1/2] Added ignored errors patching for the build artifacts --- scripts/build-artifacts.sh | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/scripts/build-artifacts.sh b/scripts/build-artifacts.sh index 3810ba3..d924d71 100755 --- a/scripts/build-artifacts.sh +++ b/scripts/build-artifacts.sh @@ -6,6 +6,40 @@ get_mem_available_kb() { grep MemAvailable /proc/meminfo | awk '{print $2}' } +copy_ignored_errors() { + local build_target_base="$1" + local target="$2" + + local present_working_dir="$(pwd)" + local config_file="$present_working_dir/configuration/$target.json" + if [ -f "$config_file" ]; then + local ignored_errors_path=$(jq -r '.ignoredErrors.path' "$config_file") + local ignored_errors_file="$present_working_dir/$ignored_errors_path/common-ignored-errors.json" + + if [ -f "$ignored_errors_file" ]; then + local build_dir="$(pwd)/$build_target_base/out/vs/editor/common/errors" + + echo "Copying ignored errors to $build_dir" + + # Strip comments and parse JSON + local clean_json=$(sed 's|//.*$||g' "$ignored_errors_file" | sed '/\/\*/,/\*\//d') + local string_count=$(echo "$clean_json" | jq '.stringPatterns | length') + local regex_count=$(echo "$clean_json" | jq '.regexPatterns | length') + + echo "Number of string ignored errors: $string_count" + echo "Number of regex ignored errors: $regex_count" + echo "Writing ignored errors to $build_dir" + + mkdir -p "$build_dir" + echo "$clean_json" | jq '.' > "$build_dir/ignored-errors.json" + else + echo "Ignored errors file not found: $ignored_errors_file" + fi + else + echo "Config file not found: $config_file" + fi +} + build() { local code_oss_build_target_base="$1" @@ -29,6 +63,7 @@ build() { env \ NODE_OPTIONS="--max-old-space-size=${max_space_size_mb}" \ npm run gulp "$build_target" + cd .. } main() { @@ -37,6 +72,7 @@ main() { local build_target_base=$("$(dirname "$0")/determine-build-target.sh" "$target") echo "Building for target: $build_target_base" build "$build_target_base" + copy_ignored_errors "$build_target_base" "$target" } -main "$@" +main "$@" \ No newline at end of file From b40b74539682da581ef4dabc58855ffbe5bb8609 Mon Sep 17 00:00:00 2001 From: VictorPaiu Date: Thu, 2 Oct 2025 11:12:06 +0200 Subject: [PATCH 2/2] Added more flexible ignored errors patching --- .../common-ignored-errors.json | 0 .../code-editor-sagemaker-server.json | 2 +- configuration/code-editor-server.json | 2 +- ...ode-editor-web-embedded-with-terminal.json | 2 +- configuration/code-editor-web-embedded.json | 2 +- scripts/build-artifacts.sh | 89 +++++++++++++++---- 6 files changed, 74 insertions(+), 23 deletions(-) rename {ignored-errors => common-ignored-errors}/common-ignored-errors.json (100%) diff --git a/ignored-errors/common-ignored-errors.json b/common-ignored-errors/common-ignored-errors.json similarity index 100% rename from ignored-errors/common-ignored-errors.json rename to common-ignored-errors/common-ignored-errors.json diff --git a/configuration/code-editor-sagemaker-server.json b/configuration/code-editor-sagemaker-server.json index 15a547c..ef173e4 100644 --- a/configuration/code-editor-sagemaker-server.json +++ b/configuration/code-editor-sagemaker-server.json @@ -11,6 +11,6 @@ }, "target": "code-editor-sagemaker-server", "ignoredErrors": { - "path": "ignored-errors" + "path": null } } \ No newline at end of file diff --git a/configuration/code-editor-server.json b/configuration/code-editor-server.json index 0cf073a..3e303d4 100644 --- a/configuration/code-editor-server.json +++ b/configuration/code-editor-server.json @@ -11,6 +11,6 @@ }, "target": "code-editor-server", "ignoredErrors": { - "path": "ignored-errors" + "path": null } } \ No newline at end of file diff --git a/configuration/code-editor-web-embedded-with-terminal.json b/configuration/code-editor-web-embedded-with-terminal.json index 1e2e273..34ca1b1 100644 --- a/configuration/code-editor-web-embedded-with-terminal.json +++ b/configuration/code-editor-web-embedded-with-terminal.json @@ -11,6 +11,6 @@ }, "target": "code-editor-web-embedded-with-terminal", "ignoredErrors": { - "path": "ignored-errors" + "path": null } } \ No newline at end of file diff --git a/configuration/code-editor-web-embedded.json b/configuration/code-editor-web-embedded.json index 988ade5..4195bd8 100644 --- a/configuration/code-editor-web-embedded.json +++ b/configuration/code-editor-web-embedded.json @@ -11,6 +11,6 @@ }, "target": "code-editor-web-embedded", "ignoredErrors": { - "path": "ignored-errors" + "path": null } } \ No newline at end of file diff --git a/scripts/build-artifacts.sh b/scripts/build-artifacts.sh index d924d71..fb779a0 100755 --- a/scripts/build-artifacts.sh +++ b/scripts/build-artifacts.sh @@ -12,32 +12,83 @@ copy_ignored_errors() { local present_working_dir="$(pwd)" local config_file="$present_working_dir/configuration/$target.json" + local build_dir="$(pwd)/$build_target_base/out/vs/editor/common/errors" + local output_file="$build_dir/ignored-errors.json" + + echo "Processing ignored errors for target: $target" + mkdir -p "$build_dir" + + # Step 1: Collect all .json files from common-ignored-errors directory + local common_files=() + if [[ -d "${present_working_dir}/common-ignored-errors" ]]; then + echo "Step 1: Looking for common ignored errors files" + while IFS= read -r -d '' file; do + common_files+=("$file") + echo " Found: $(basename "$file")" + done < <(find "${present_working_dir}/common-ignored-errors" -name "*.json" -print0 2>/dev/null || true) + fi + + # Step 2: Collect target-specific .json files if path is not null + local target_files=() if [ -f "$config_file" ]; then local ignored_errors_path=$(jq -r '.ignoredErrors.path' "$config_file") - local ignored_errors_file="$present_working_dir/$ignored_errors_path/common-ignored-errors.json" - - if [ -f "$ignored_errors_file" ]; then - local build_dir="$(pwd)/$build_target_base/out/vs/editor/common/errors" - - echo "Copying ignored errors to $build_dir" - - # Strip comments and parse JSON - local clean_json=$(sed 's|//.*$||g' "$ignored_errors_file" | sed '/\/\*/,/\*\//d') - local string_count=$(echo "$clean_json" | jq '.stringPatterns | length') - local regex_count=$(echo "$clean_json" | jq '.regexPatterns | length') - - echo "Number of string ignored errors: $string_count" - echo "Number of regex ignored errors: $regex_count" - echo "Writing ignored errors to $build_dir" - - mkdir -p "$build_dir" - echo "$clean_json" | jq '.' > "$build_dir/ignored-errors.json" + if [[ "$ignored_errors_path" != "null" && -n "$ignored_errors_path" && -d "${present_working_dir}/$ignored_errors_path" ]]; then + echo "Step 2: Looking for target-specific ignored errors files in: $ignored_errors_path" + while IFS= read -r -d '' file; do + target_files+=("$file") + echo " Found: $(basename "$file")" + done < <(find "${present_working_dir}/$ignored_errors_path" -name "*.json" -print0 2>/dev/null || true) else - echo "Ignored errors file not found: $ignored_errors_file" + echo "Step 2: Skipping target-specific files (path is null or doesn't exist)" fi else echo "Config file not found: $config_file" fi + + # Step 3: Merge all JSON files + echo "Step 3: Merging all ignored errors files" + local temp_file=$(mktemp) + echo '{"stringPatterns": [], "regexPatterns": []}' > "$temp_file" + + # Function to clean JSON (remove comments) + clean_and_merge() { + local file="$1" + local temp_clean=$(mktemp) + # Remove single-line comments and multi-line comments + sed 's|//.*$||g' "$file" | sed '/\/\*/,/\*\//d' > "$temp_clean" + jq -s '.[0] as $base | .[1] as $new | $base + {stringPatterns: ($base.stringPatterns + ($new.stringPatterns // [])), regexPatterns: ($base.regexPatterns + ($new.regexPatterns // []))}' "$temp_file" "$temp_clean" > "${temp_file}.tmp" && mv "${temp_file}.tmp" "$temp_file" + rm "$temp_clean" + } + + # Merge common files + if [[ ${#common_files[@]} -gt 0 ]]; then + for file in "${common_files[@]}"; do + if [[ -f "$file" ]]; then + echo " Merging: $(basename "$file")" + clean_and_merge "$file" + fi + done + fi + + # Merge target-specific files + if [[ ${#target_files[@]} -gt 0 ]]; then + for file in "${target_files[@]}"; do + if [[ -f "$file" ]]; then + echo " Merging: $(basename "$file")" + clean_and_merge "$file" + fi + done + fi + + # Copy merged result to output location + cp "$temp_file" "$output_file" + rm "$temp_file" + + # Report final counts + local string_count=$(jq '.stringPatterns | length' "$output_file") + local regex_count=$(jq '.regexPatterns | length' "$output_file") + echo "Created ignored-errors.json with $string_count string patterns and $regex_count regex patterns" + echo "Output written to: $output_file" } build() {