From f5431c0af8536d7da69fdc1755eaeb6c27940952 Mon Sep 17 00:00:00 2001 From: Alexandre CUER Date: Sun, 22 Nov 2026 11:45:55 +0100 Subject: [PATCH 1/6] Make CodeMirror build versions configurable --- .github/workflows/build-codemirror.yml | 45 ++++++++++++++++++++------ 1 file changed, 36 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build-codemirror.yml b/.github/workflows/build-codemirror.yml index b6486a1..1a658a0 100644 --- a/.github/workflows/build-codemirror.yml +++ b/.github/workflows/build-codemirror.yml @@ -2,6 +2,22 @@ name: Build CodeMirror bundle on: workflow_dispatch: + inputs: + codemirror_version: + description: "Version of codemirror" + required: true + type: string + default: "6.0.2" + lang_yaml_version: + description: "Version of @codemirror/lang-yaml" + required: true + type: string + default: "6.1.3" + esbuild_version: + description: "Version of esbuild (build tool)" + required: true + type: string + default: "0.25.11" permissions: contents: read @@ -16,6 +32,11 @@ jobs: run: working-directory: build/codemirror + env: + CODEMIRROR_VERSION: ${{ inputs.codemirror_version }} + LANG_YAML_VERSION: ${{ inputs.lang_yaml_version }} + ESBUILD_VERSION: ${{ inputs.esbuild_version }} + steps: - name: Checkout uses: actions/checkout@v6 @@ -25,31 +46,37 @@ jobs: with: node-version: 22 - - name: Install pinned dependencies - run: npm install --no-audit --no-fund + - name: Install selected dependencies + run: | + npm install --no-save --no-package-lock --no-audit --no-fund \ + "codemirror@${CODEMIRROR_VERSION}" \ + "@codemirror/lang-yaml@${LANG_YAML_VERSION}" \ + "esbuild@${ESBUILD_VERSION}" - name: Build ES module bundle run: | + OUTPUT="dist/codemirror-${CODEMIRROR_VERSION}-yaml-${LANG_YAML_VERSION}.js" mkdir -p dist - npx esbuild src/index.js \ + ./node_modules/.bin/esbuild src/index.js \ --bundle \ --format=esm \ --target=es2022 \ - --outfile=dist/codemirror.js + --outfile="${OUTPUT}" + echo "BUNDLE_FILE=${OUTPUT}" >> "$GITHUB_ENV" - name: Check bundle run: | - test -s dist/codemirror.js - if grep -Eq 'from ["'\''/](@codemirror|codemirror)|import\(["'\''/](@codemirror|codemirror)' dist/codemirror.js; then + test -s "${BUNDLE_FILE}" + if grep -Eq 'from ["'\''/](@codemirror|codemirror)|import\(["'\''/](@codemirror|codemirror)' "${BUNDLE_FILE}"; then echo "::error::The bundle still contains an external CodeMirror import." exit 1 fi - echo "Bundle size: $(wc -c < dist/codemirror.js) bytes" + echo "Bundle size: $(wc -c < "${BUNDLE_FILE}") bytes" - name: Upload CodeMirror bundle uses: actions/upload-artifact@v4 with: - name: codemirror-6.0.2-yaml-6.1.3 - path: build/codemirror/dist/codemirror.js + name: codemirror-${{ inputs.codemirror_version }}-yaml-${{ inputs.lang_yaml_version }}-esbuild-${{ inputs.esbuild_version }} + path: build/codemirror/dist/codemirror-${{ inputs.codemirror_version }}-yaml-${{ inputs.lang_yaml_version }}.js if-no-files-found: error retention-days: 30 From 0f6f4ff4d47ae19c85c11b5ffca548ed9b2a2e3d Mon Sep 17 00:00:00 2001 From: Alexandre CUER Date: Sun, 22 Nov 2026 11:45:57 +0100 Subject: [PATCH 2/6] Move CodeMirror build versions to workflow inputs --- build/codemirror/package.json | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/build/codemirror/package.json b/build/codemirror/package.json index c06cfbb..38ec57e 100644 --- a/build/codemirror/package.json +++ b/build/codemirror/package.json @@ -2,13 +2,8 @@ "name": "obm-codemirror-bundle", "private": true, "type": "module", - "description": "Build-time dependencies for the OBM CodeMirror browser bundle.", + "description": "Build-time configuration for the OBM CodeMirror browser bundle.", "scripts": { "build": "esbuild src/index.js --bundle --format=esm --target=es2022 --outfile=dist/codemirror.js" - }, - "dependencies": { - "@codemirror/lang-yaml": "6.1.3", - "codemirror": "6.0.2", - "esbuild": "0.25.11" } } From 907fe69b6374af4fc9683f1806b776a485425b17 Mon Sep 17 00:00:00 2001 From: Alexandre CUER Date: Sun, 22 Nov 2026 11:45:59 +0100 Subject: [PATCH 3/6] Document configurable CodeMirror build versions --- build/codemirror/README.md | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/build/codemirror/README.md b/build/codemirror/README.md index 100b5e1..61d6bc3 100644 --- a/build/codemirror/README.md +++ b/build/codemirror/README.md @@ -1,23 +1,25 @@ # CodeMirror browser bundle -This directory contains the build-time configuration for the OBM CodeMirror +This directory contains the build-time entry point for the OBM CodeMirror bundle. It is deliberately separate from the static site runtime. ## Build Run the **Build CodeMirror bundle** workflow manually from GitHub Actions. -It installs the pinned direct dependencies, bundles their dependencies into -one browser ES module, and publishes the result as the -`codemirror-6.0.2-yaml-6.1.3` workflow artifact. +The workflow exposes three version inputs: -The artifact contains: +- `codemirror_version`: version of `codemirror` (default: `6.0.2`) +- `lang_yaml_version`: version of `@codemirror/lang-yaml` (default: `6.1.3`) +- `esbuild_version`: version of `esbuild` (default: `0.25.11`) -```text -codemirror.js -``` +The selected packages are installed for that workflow run only. The output +filename and artifact name include the selected versions. The artifact also +records the esbuild version in its name, although esbuild is only a build tool +and is not included in the browser bundle. -Download and extract that artifact into the site's `vendor/codemirror/` -directory. No npm, Node.js, or CDN access is required by the deployed site. +Download and extract the JavaScript file into the site's +`vendor/codemirror/` directory. No npm, Node.js, or CDN access is required +by the deployed site. ## Browser usage @@ -25,17 +27,14 @@ The bundle exposes the same three named exports as the current esm.sh imports: ```js import { EditorView, basicSetup, yaml } from - "/vendor/codemirror/codemirror.js"; + "/vendor/codemirror/codemirror-6.0.2-yaml-6.1.3.js"; ``` +Replace the versioned filename with the one produced by the workflow run. + CodeMirror injects its editor styles through its JavaScript modules, so this bundle does not require a separate stylesheet. -## Versions - -- `codemirror`: 6.0.2 -- `@codemirror/lang-yaml`: 6.1.3 -- `esbuild`: 0.25.11 (build tool only) +## Entry point -The CodeMirror packages are bundled into the output; esbuild is not included -in the browser bundle. +`src/index.js` defines the public exports included in the browser bundle. From 0bdc762db1b9797cb55bbc26198b12ab3880b68b Mon Sep 17 00:00:00 2001 From: Alexandre CUER Date: Sun, 22 Nov 2026 13:28:55 +0100 Subject: [PATCH 4/6] ci: upgrade CodeMirror workflow actions to Node.js 24 --- .github/workflows/build-codemirror.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-codemirror.yml b/.github/workflows/build-codemirror.yml index 1a658a0..15427cd 100644 --- a/.github/workflows/build-codemirror.yml +++ b/.github/workflows/build-codemirror.yml @@ -42,7 +42,7 @@ jobs: uses: actions/checkout@v6 - name: Set up Node.js - uses: actions/setup-node@v4 + uses: actions/setup-node@v7 with: node-version: 22 @@ -74,7 +74,7 @@ jobs: echo "Bundle size: $(wc -c < "${BUNDLE_FILE}") bytes" - name: Upload CodeMirror bundle - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v7 with: name: codemirror-${{ inputs.codemirror_version }}-yaml-${{ inputs.lang_yaml_version }}-esbuild-${{ inputs.esbuild_version }} path: build/codemirror/dist/codemirror-${{ inputs.codemirror_version }}-yaml-${{ inputs.lang_yaml_version }}.js From 64c5a76efe597a2ce78dfb6a1814546c81e6104c Mon Sep 17 00:00:00 2001 From: Alexandre CUER Date: Sun, 22 Nov 2026 18:34:35 +0100 Subject: [PATCH 5/6] add autocompletion to the bundle --- .github/workflows/build-codemirror.yml | 23 +++++++++++++++++++---- build/codemirror/README.md | 8 ++------ build/codemirror/src/index.js | 1 + 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build-codemirror.yml b/.github/workflows/build-codemirror.yml index 15427cd..11b8416 100644 --- a/.github/workflows/build-codemirror.yml +++ b/.github/workflows/build-codemirror.yml @@ -8,6 +8,11 @@ on: required: true type: string default: "6.0.2" + autocompletion_version: + description: "Version of autocompletion" + required: true + type: string + default: "6.0.0" lang_yaml_version: description: "Version of @codemirror/lang-yaml" required: true @@ -24,7 +29,7 @@ permissions: jobs: build: - name: Bundle CodeMirror and YAML language support + name: Bundle CodeMirror and utilities (such as YAML language support) runs-on: ubuntu-latest timeout-minutes: 10 @@ -36,6 +41,7 @@ jobs: CODEMIRROR_VERSION: ${{ inputs.codemirror_version }} LANG_YAML_VERSION: ${{ inputs.lang_yaml_version }} ESBUILD_VERSION: ${{ inputs.esbuild_version }} + AUTOCOMPLETION_VERSION: ${{ inputs.autocompletion_version}} steps: - name: Checkout @@ -50,12 +56,21 @@ jobs: run: | npm install --no-save --no-package-lock --no-audit --no-fund \ "codemirror@${CODEMIRROR_VERSION}" \ + "@codemirror/autocomplete@{AUTOCOMPLETION_VERSION}" \ "@codemirror/lang-yaml@${LANG_YAML_VERSION}" \ "esbuild@${ESBUILD_VERSION}" + - id: js + name: Set js name + run: | + t0="cm-${CODEMIRROR_VERSION}" + t1="-yaml-${LANG_YAML_VERSION}" + t2="-autocmp-${AUTOCOMPLETION_VERSION}" + echo "name=$t0$t1$t2" >> "$GITHUB_OUTPUT" + - name: Build ES module bundle run: | - OUTPUT="dist/codemirror-${CODEMIRROR_VERSION}-yaml-${LANG_YAML_VERSION}.js" + OUTPUT="dist/${{ steps.js.outputs.name }}.js" mkdir -p dist ./node_modules/.bin/esbuild src/index.js \ --bundle \ @@ -76,7 +91,7 @@ jobs: - name: Upload CodeMirror bundle uses: actions/upload-artifact@v7 with: - name: codemirror-${{ inputs.codemirror_version }}-yaml-${{ inputs.lang_yaml_version }}-esbuild-${{ inputs.esbuild_version }} - path: build/codemirror/dist/codemirror-${{ inputs.codemirror_version }}-yaml-${{ inputs.lang_yaml_version }}.js + name: codemirror-${{ steps.js.outputs.name }}-${{ inputs.esbuild_version }} + path: build/codemirror/dist/${{ steps.js.outputs.name }}.js if-no-files-found: error retention-days: 30 diff --git a/build/codemirror/README.md b/build/codemirror/README.md index 61d6bc3..762b5d5 100644 --- a/build/codemirror/README.md +++ b/build/codemirror/README.md @@ -6,11 +6,7 @@ bundle. It is deliberately separate from the static site runtime. ## Build Run the **Build CodeMirror bundle** workflow manually from GitHub Actions. -The workflow exposes three version inputs: - -- `codemirror_version`: version of `codemirror` (default: `6.0.2`) -- `lang_yaml_version`: version of `@codemirror/lang-yaml` (default: `6.1.3`) -- `esbuild_version`: version of `esbuild` (default: `0.25.11`) +The workflow exposes some version inputs of components to bundle The selected packages are installed for that workflow run only. The output filename and artifact name include the selected versions. The artifact also @@ -27,7 +23,7 @@ The bundle exposes the same three named exports as the current esm.sh imports: ```js import { EditorView, basicSetup, yaml } from - "/vendor/codemirror/codemirror-6.0.2-yaml-6.1.3.js"; + "/vendor/codemirror/xxxxxxxxx.js"; ``` Replace the versioned filename with the one produced by the workflow run. diff --git a/build/codemirror/src/index.js b/build/codemirror/src/index.js index 64cca03..e857ac2 100644 --- a/build/codemirror/src/index.js +++ b/build/codemirror/src/index.js @@ -1,3 +1,4 @@ // Public API exposed by the local OBM CodeMirror bundle. export { EditorView, basicSetup } from "codemirror"; export { yaml } from "@codemirror/lang-yaml"; +export { autocompletion } from '@codemirror/autocomplete'; From 597b2423ff87e54856429610b209e081b9317f9f Mon Sep 17 00:00:00 2001 From: Alexandre CUER Date: Sun, 22 Nov 2026 18:41:52 +0100 Subject: [PATCH 6/6] correctifs --- .github/workflows/build-codemirror.yml | 4 ++-- build/codemirror/README.md | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-codemirror.yml b/.github/workflows/build-codemirror.yml index 11b8416..c42fcc5 100644 --- a/.github/workflows/build-codemirror.yml +++ b/.github/workflows/build-codemirror.yml @@ -9,7 +9,7 @@ on: type: string default: "6.0.2" autocompletion_version: - description: "Version of autocompletion" + description: "Version of @codemirror/autocomplete" required: true type: string default: "6.0.0" @@ -56,7 +56,7 @@ jobs: run: | npm install --no-save --no-package-lock --no-audit --no-fund \ "codemirror@${CODEMIRROR_VERSION}" \ - "@codemirror/autocomplete@{AUTOCOMPLETION_VERSION}" \ + "@codemirror/autocomplete@${AUTOCOMPLETION_VERSION}" \ "@codemirror/lang-yaml@${LANG_YAML_VERSION}" \ "esbuild@${ESBUILD_VERSION}" diff --git a/build/codemirror/README.md b/build/codemirror/README.md index 762b5d5..36facca 100644 --- a/build/codemirror/README.md +++ b/build/codemirror/README.md @@ -19,10 +19,8 @@ by the deployed site. ## Browser usage -The bundle exposes the same three named exports as the current esm.sh imports: - ```js -import { EditorView, basicSetup, yaml } from +import { EditorView, basicSetup, autocompletion, yaml } from "/vendor/codemirror/xxxxxxxxx.js"; ```