From c29343c87e547bf6cb1a2728cf8673db5fc7dfc6 Mon Sep 17 00:00:00 2001 From: marcincuber <5611060+marcincuber@users.noreply.github.com> Date: Wed, 25 Nov 2026 20:18:55 +0000 Subject: [PATCH] uprgades --- .github/workflows/lighthouse.yml | 5 +- .github/workflows/redirects.yml | 2 +- .github/workflows/terraform-modules.yml | 8 +- README.md | 7 +- argocd-applicationset-studio/app.js | 6 +- argocd-applicationset-studio/index.html | 61 +++---- .../vendor/js-yaml-5.2.2.umd.min.js | 32 ---- .../vendor/js-yaml.LICENSE | 21 --- json-diff/app.js | 2 +- json-diff/diff.js | 8 +- json-diff/index.html | 9 +- json-diff/source-map.js | 154 +++++++++++++----- kubernetes-rbac-explorer/app.js | 7 +- kubernetes-rbac-explorer/index.html | 5 +- .../embed-applicationset-studio-runtime.py | 6 +- scripts/json-diff.test.cjs | 18 ++ scripts/yaml-compatibility.test.cjs | 44 +++++ yaml-formatter/app.js | 8 +- yaml-formatter/index.html | 5 +- yaml-formatter/schema.js | 48 ++++++ yaml-formatter/vendor/js-yaml.min.js | 41 ++++- 21 files changed, 338 insertions(+), 159 deletions(-) delete mode 100644 argocd-applicationset-studio/vendor/js-yaml-5.2.2.umd.min.js delete mode 100644 argocd-applicationset-studio/vendor/js-yaml.LICENSE create mode 100644 scripts/yaml-compatibility.test.cjs create mode 100644 yaml-formatter/schema.js diff --git a/.github/workflows/lighthouse.yml b/.github/workflows/lighthouse.yml index 6c79df1..536b21e 100644 --- a/.github/workflows/lighthouse.yml +++ b/.github/workflows/lighthouse.yml @@ -16,7 +16,7 @@ jobs: steps: - name: Check out repository - uses: actions/checkout@v6 + uses: actions/checkout@v7 - name: Verify embedded ApplicationSet Studio runtime run: python3 scripts/embed-applicationset-studio-runtime.py --check @@ -33,6 +33,9 @@ jobs: - name: Test JSON and YAML comparison run: node --test scripts/json-diff.test.cjs + - name: Test YAML parser compatibility + run: node --test scripts/yaml-compatibility.test.cjs + - name: Test timestamp parsing and comparison run: node --test scripts/timestamp-converter.test.cjs diff --git a/.github/workflows/redirects.yml b/.github/workflows/redirects.yml index 8a44333..18ad9dd 100644 --- a/.github/workflows/redirects.yml +++ b/.github/workflows/redirects.yml @@ -14,7 +14,7 @@ jobs: timeout-minutes: 10 steps: - name: Check out repository - uses: actions/checkout@v6 + uses: actions/checkout@v7 - name: Check deployed redirects and canonical destinations run: python3 scripts/check-redirects.py diff --git a/.github/workflows/terraform-modules.yml b/.github/workflows/terraform-modules.yml index b0ddf30..d02963e 100644 --- a/.github/workflows/terraform-modules.yml +++ b/.github/workflows/terraform-modules.yml @@ -37,10 +37,10 @@ jobs: steps: - name: Check out repository - uses: actions/checkout@v6 + uses: actions/checkout@v7 - name: Install JSON Schema validator - run: python3 -m pip install --disable-pip-version-check check-jsonschema==0.38.0 + run: python3 -m pip install --disable-pip-version-check check-jsonschema==0.39.0 - name: Validate catalogue schema run: check-jsonschema --schemafile terraform-modules/modules.schema.json terraform-modules/modules.json @@ -59,10 +59,10 @@ jobs: steps: - name: Check out repository - uses: actions/checkout@v6 + uses: actions/checkout@v7 - name: Install JSON Schema validator - run: python3 -m pip install --disable-pip-version-check check-jsonschema==0.38.0 + run: python3 -m pip install --disable-pip-version-check check-jsonschema==0.39.0 - name: Refresh Registry and GitHub metadata env: diff --git a/README.md b/README.md index 1b6a8cb..0d71d64 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,8 @@ Git, or an SCM provider, and generated output should be verified with the ApplicationSet controller before production use. The Studio ships one embedded v1 browser runtime so it also works on enterprise -networks that block JavaScript file responses. It includes js-yaml 5.2.2. After +networks that block JavaScript file responses. It embeds the shared js-yaml +5.5.0 browser bundle from `yaml-formatter/vendor/`. After changing `app.js` or upgrading the vendored parser, refresh and verify the page: ```sh @@ -88,7 +89,7 @@ can copy or download the formatted result. The shorter `/json-formatter/` alias redirects to this tool. -YAML parsing and serialization use the vendored `js-yaml` 4.1.0 browser +YAML parsing and serialization use the vendored `js-yaml` 5.5.0 browser bundle, distributed under the MIT license included with the tool. ## JSON & YAML Diff Checker @@ -153,7 +154,7 @@ snapshots, generates narrowly scoped RBAC drafts, and exports a Markdown review. The explorer accepts multi-document YAML, JSON arrays, and Kubernetes `List` objects. Parsing and analysis stay in the browser. Secret objects are rejected, and users should never provide a kubeconfig, token, or other credentials. YAML -input uses the existing vendored `js-yaml` 4.1.0 bundle. +input uses the shared vendored `js-yaml` 5.5.0 bundle. The random sample library demonstrates namespace read-only access, deployment operations, sensitive cluster access, RBAC administration, aggregated diff --git a/argocd-applicationset-studio/app.js b/argocd-applicationset-studio/app.js index c4fb645..85146b4 100644 --- a/argocd-applicationset-studio/app.js +++ b/argocd-applicationset-studio/app.js @@ -799,11 +799,9 @@ spec: if (text.length > MAX_INPUT_LENGTH) { throw new Error(`${label} exceeds the 2 MB local preview limit.`); } - const documents = []; + let documents; try { - window.jsyaml.loadAll(text, (document) => { - if (document !== null && document !== undefined) documents.push(document); - }, YAML_LOAD_OPTIONS); + documents = window.jsyaml.loadAll(text, YAML_LOAD_OPTIONS).filter((document) => document != null); } catch (error) { const location = error.mark ? ` at line ${error.mark.line + 1}, column ${error.mark.column + 1}` diff --git a/argocd-applicationset-studio/index.html b/argocd-applicationset-studio/index.html index a9eac89..179b72a 100644 --- a/argocd-applicationset-studio/index.html +++ b/argocd-applicationset-studio/index.html @@ -632,38 +632,45 @@

Take the review with you

5.2.2 and the Studio runtime in this document makes startup deterministic. --> - - + + + + - + - + + + " opening_index = page.find(opening) diff --git a/scripts/json-diff.test.cjs b/scripts/json-diff.test.cjs index 1abaa91..8fdb1c8 100644 --- a/scripts/json-diff.test.cjs +++ b/scripts/json-diff.test.cjs @@ -177,6 +177,24 @@ test("source locations cover YAML blocks, flow collections, empty values and esc ]); }); +test("YAML source highlights use the same numeric and alias keys as comparison", () => { + const before = "key: &field 0b101\n*field : old\n0x10: [a, b]\n"; + const after = "key: &field 0b101\n*field : new\n0x10: [a, b, c]\n"; + assert.deepEqual(locatedValues(before, after, "yaml", "yaml"), [ + { path: "/16/2", before: null, after: "c" }, + { path: "/5", before: "old", after: "new" }, + ]); +}); + +test("YAML source highlights isolate tags and anchors on empty scalars", () => { + const before = "empty: &empty\ntagged: !!null\n"; + const after = "empty: 12\ntagged: true\n"; + assert.deepEqual(locatedValues(before, after, "yaml", "yaml"), [ + { path: "/empty", before: "&empty", after: "12" }, + { path: "/tagged", before: "!!null", after: "true" }, + ]); +}); + test("source highlights respect keyed arrays and unordered duplicate counts", () => { assert.deepEqual(locatedValues('[{"id":1,"x":2},{"id":2,"x":2}]', '[{"id":2,"x":2},{"id":1,"x":3}]', "json", "json", { arrayMode: "keyed", arrayKey: "id" }), [ { path: "/id=1/x", before: "2", after: "3" }, diff --git a/scripts/yaml-compatibility.test.cjs b/scripts/yaml-compatibility.test.cjs new file mode 100644 index 0000000..7fb9049 --- /dev/null +++ b/scripts/yaml-compatibility.test.cjs @@ -0,0 +1,44 @@ +"use strict"; + +const assert = require("node:assert/strict"); +const fs = require("node:fs"); +const path = require("node:path"); +const test = require("node:test"); +const vm = require("node:vm"); +const yaml = require("../yaml-formatter/vendor/js-yaml.min.js"); +const { configurationSchema } = require("../yaml-formatter/schema.js"); + +const schema = configurationSchema(yaml); + +test("configuration YAML preserves merges, dates, and numeric forms", () => { + const values = yaml.load(`defaults: &defaults {count: 1_000, flags: 0b101} +config: {<<: *defaults, estimate: 1_2.3_4, enabled: yes} +date: 2025-01-01`, { schema }); + assert.deepEqual(values.config, { count: 1000, flags: 5, estimate: 12.34, enabled: "yes" }); + assert.equal(values.date.toISOString(), "2025-01-01T00:00:00.000Z"); + assert.deepEqual(yaml.load(yaml.dump(values, { schema }), { schema }), values); +}); + +test("explicit YAML collection and binary tags remain JSON-convertible", () => { + const documents = yaml.loadAll(`checks: !!set {one: null, two: null} +--- +pairs: !!pairs [weight: 1] +ordered: !!omap [{one: 1}, {two: 2}] +--- +bytes: !!binary AAEC`, { schema }); + assert.deepEqual(documents, [ + { checks: { one: null, two: null } }, + { pairs: [["weight", 1]], ordered: [{ one: 1 }, { two: 2 }] }, + { bytes: new Uint8Array([0, 1, 2]) }, + ]); +}); + +test("the embedded ApplicationSet parser decodes YAML line separators", () => { + const page = fs.readFileSync(path.join(__dirname, "../argocd-applicationset-studio/index.html"), "utf8"); + const [, runtime] = page.match(/ - + + +