Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.
TypeScript accessibilityalternativecloudflarecloudflare-workersdesignfreefrontendopen-sourceradix-uireactremixweb-developmentwebflowwebsite-builderwebsite-developmentwebsiteswebstudio
fix: Show released CLI version in MCP docs (#5990)
Oleg Isonene6a29b5d3658
diff --git a/.github/workflows/release.yml b/.github/workflows/release.ymlindex 476a418404..1d53d8906b 100644--- a/.github/workflows/release.yml+++ b/.github/workflows/release.yml@@ -142,12 +142,33 @@ jobs:publish-docs:needs: [release, publish]runs-on: ubuntu-latest+ concurrency:+ group: publish-docs+ cancel-in-progress: falsepermissions:contents: writesteps:- uses: actions/checkout@v4with:fetch-depth: 0- ref: ${{ github.sha }}+ ref: docs- name: Publish released documentation snapshot- run: git push origin "$GITHUB_SHA:refs/heads/docs"+ env:+ RELEASE_SHA: ${{ github.sha }}+ RELEASE_VERSION: ${{ github.ref_name }}+ run: |+ if git merge-base --is-ancestor "$RELEASE_SHA" HEAD; then+ echo "The docs branch already contains release $RELEASE_VERSION or a newer revision."+ exit 0+ fi++ git config user.name "github-actions[bot]"+ git config user.email "41898282+github-actions[bot]@users.noreply.github.com"+ git merge --no-edit "$RELEASE_SHA"+ git checkout "$RELEASE_SHA" -- docs/university/mcp.md+ sed -i.bak "s/^# Webstudio MCP v0\\.0\\.0-webstudio-version$/# Webstudio MCP v$RELEASE_VERSION/" docs/university/mcp.md+ rm docs/university/mcp.md.bak+ grep -Fqx "# Webstudio MCP v$RELEASE_VERSION" docs/university/mcp.md+ git add docs/university/mcp.md+ git commit -m "docs: publish Webstudio CLI $RELEASE_VERSION"+ git push origin docsdiff --git a/docs/university/mcp.md b/docs/university/mcp.mdindex 66c224caa1..7a1bbe588a 100644--- a/docs/university/mcp.md+++ b/docs/university/mcp.md@@ -7,7 +7,7 @@ icon: robot<!-- Generated from the local Webstudio CLI with `webstudio man mcp --verbose`. Do not edit directly. -->-# Webstudio MCP+# Webstudio MCP v0.0.0-webstudio-version{% hint style="info" %}This reference is generated from the Webstudio CLI source in the same Builderdiff --git a/scripts/docs/generate-mcp-docs.test.ts b/scripts/docs/generate-mcp-docs.test.tsindex 5582d12f79..eb27916083 100644--- a/scripts/docs/generate-mcp-docs.test.ts+++ b/scripts/docs/generate-mcp-docs.test.ts@@ -4,11 +4,12 @@ import { renderMcpDocumentation } from "./generate-mcp-docs.js";test("renders GitBook metadata around the complete CLI manual", () => {const generated = renderMcpDocumentation(- "# Webstudio MCP Manual\n\n## Startup\n\nStart here.\n"+ "# Webstudio MCP Manual\n\n## Startup\n\nStart here.\n",+ "1.2.3");assert.match(generated, /^---\n/);- assert.match(generated, /# Webstudio MCP\n/);+ assert.match(generated, /# Webstudio MCP v1\.2\.3\n/);assert.match(generated,/GitBook publishes it when that revision is successfully released/@@ -24,7 +25,14 @@ test("renders GitBook metadata around the complete CLI manual", () => {test("rejects an unexpected CLI manual", () => {assert.throws(- () => renderMcpDocumentation("# Different manual"),+ () => renderMcpDocumentation("# Different manual", "1.2.3"),/Expected the CLI manual/);});++test("rejects a missing CLI version", () => {+ assert.throws(+ () => renderMcpDocumentation("# Webstudio MCP Manual\n\nBody", ""),+ /Expected a CLI version/+ );+});diff --git a/scripts/docs/generate-mcp-docs.ts b/scripts/docs/generate-mcp-docs.tsindex 200173293a..d4517f0c34 100644--- a/scripts/docs/generate-mcp-docs.ts+++ b/scripts/docs/generate-mcp-docs.ts@@ -5,9 +5,13 @@ import { fileURLToPath } from "node:url";const manualTitle = "# Webstudio MCP Manual";const manualPlaceholder = "{{manual}}";+const versionPlaceholder = "{{version}}";const repositoryRoot = fileURLToPath(new URL("../..", import.meta.url));const outputPath = resolve(repositoryRoot, "docs/university/mcp.md");const template = readFileSync(new URL("mcp-page.md", import.meta.url), "utf8");+const { version: cliVersion } = JSON.parse(+ readFileSync(resolve(repositoryRoot, "packages/cli/package.json"), "utf8")+) as { version: string };const getMcpManual = () =>execFileSync(@@ -31,7 +35,7 @@ const getMcpManual = () =>}).trim();-export const renderMcpDocumentation = (manual: string) => {+export const renderMcpDocumentation = (manual: string, version: string) => {const normalizedManual = manual.replaceAll("\r\n", "\n").trim();if (normalizedManual.startsWith(`${manualTitle}\n`) === false) {throw new Error(@@ -45,11 +49,20 @@ export const renderMcpDocumentation = (manual: string) => {`Expected one ${manualPlaceholder} placeholder, found ${placeholderCount}.`);}- return template.replace(manualPlaceholder, manualBody);+ if (version.trim() === "") {+ throw new Error("Expected a CLI version.");+ }+ return template+ .replace(versionPlaceholder, version)+ .replace(manualPlaceholder, manualBody);};export const generateMcpDocumentation = () => {- writeFileSync(outputPath, renderMcpDocumentation(getMcpManual()), "utf8");+ writeFileSync(+ outputPath,+ renderMcpDocumentation(getMcpManual(), cliVersion),+ "utf8"+ );};if (process.argv[1] === fileURLToPath(import.meta.url)) {diff --git a/scripts/docs/mcp-page.md b/scripts/docs/mcp-page.mdindex eb14f789cd..1848694f07 100644--- a/scripts/docs/mcp-page.md+++ b/scripts/docs/mcp-page.md@@ -7,7 +7,7 @@ icon: robot<!-- Generated from the local Webstudio CLI with `webstudio man mcp --verbose`. Do not edit directly. -->-# Webstudio MCP+# Webstudio MCP v{{version}}{% hint style="info" %}This reference is generated from the Webstudio CLI source in the same Builder