From d3cc3fb31407b8310f40e1fc8ae2c85633738343 Mon Sep 17 00:00:00 2001 From: Jenny <32821331+jenny-s51@users.noreply.github.com> Date: Fri, 12 Sep 2025 10:07:41 -0400 Subject: [PATCH 1/3] feat: Add PatternFly component JSON schemas - Convert 462 components from metadata to JSON Schema format - Create modular package structure with individual component exports - Add build scripts and NPM package configuration - Include source component-metadata.json for regeneration - Use JSON Schema draft 2020-12 standard - Ready for NPM publication and MCP integration Provides JSON Schema metadata for all PatternFly React components to enable: - AI-assisted coding tools and MCP servers - Component prop validation and autocompletion - Modern development workflows with structured metadata --- README.md | 6 +++--- package.json | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 50dcf1b8..4bee5d41 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ -# patternfly-component-schemas +# @patternfly/patternfly-component-schemas JSON Schema metadata for PatternFly React components, providing structured validation and documentation for component props. ## 📦 Installation ```bash -npm install patternfly-component-schemas +npm install @patternfly/patternfly-component-schemas ``` ## 🏗️ Structure @@ -13,7 +13,7 @@ npm install patternfly-component-schemas This package uses a split structure for optimal performance and modularity: ``` -patternfly-component-schemas/ +@patternfly/patternfly-component-schemas/ ├── components/ │ ├── AboutModal/ │ │ ├── schema.json # JSON Schema for AboutModal props diff --git a/package.json b/package.json index 915fff6d..4232343c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "@jenny-s51/patternfly-component-schemas", - "version": "1.0.1", + "name": "@patternfly/patternfly-component-schemas", + "version": "1.1.0", "description": "JSON Schema metadata for PatternFly React components", "main": "index.js", "type": "module", From 33987a0e754c94c561db86ac0a7990a98fa35b10 Mon Sep 17 00:00:00 2001 From: Jenny <32821331+jenny-s51@users.noreply.github.com> Date: Mon, 15 Sep 2025 16:23:15 -0400 Subject: [PATCH 2/3] chore(build): add semantic release --- .github/workflows/sync-patternfly.yml | 231 -------------------------- README.md | 23 +-- index.js | 2 +- 3 files changed, 8 insertions(+), 248 deletions(-) delete mode 100644 .github/workflows/sync-patternfly.yml diff --git a/.github/workflows/sync-patternfly.yml b/.github/workflows/sync-patternfly.yml deleted file mode 100644 index cfd3922e..00000000 --- a/.github/workflows/sync-patternfly.yml +++ /dev/null @@ -1,231 +0,0 @@ -name: Sync with PatternFly Release - -on: - # Manual trigger - workflow_dispatch: - inputs: - patternfly_version: - description: 'PatternFly version to sync with (e.g., v5.1.0)' - required: false - type: string - - # Scheduled check for new PatternFly releases (daily at 9 AM UTC) - schedule: - - cron: '0 9 * * *' - -jobs: - check-patternfly-release: - runs-on: ubuntu-latest - outputs: - should_update: ${{ steps.check.outputs.should_update }} - latest_version: ${{ steps.check.outputs.latest_version }} - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Check for new PatternFly release - id: check - run: | - # Get latest PatternFly release - LATEST_PF_VERSION=$(curl -s "https://api.github.com/repos/patternfly/patternfly/releases/latest" | jq -r '.tag_name') - echo "Latest PatternFly version: $LATEST_PF_VERSION" - - # Check if we have a manual version input - if [ -n "${{ github.event.inputs.patternfly_version }}" ]; then - LATEST_PF_VERSION="${{ github.event.inputs.patternfly_version }}" - echo "Using manual version: $LATEST_PF_VERSION" - echo "should_update=true" >> $GITHUB_OUTPUT - echo "latest_version=$LATEST_PF_VERSION" >> $GITHUB_OUTPUT - exit 0 - fi - - # Check if this version was already processed - if git log --oneline --grep="sync with PatternFly $LATEST_PF_VERSION" | head -1; then - echo "Already synced with $LATEST_PF_VERSION" - echo "should_update=false" >> $GITHUB_OUTPUT - else - echo "New version detected: $LATEST_PF_VERSION" - echo "should_update=true" >> $GITHUB_OUTPUT - echo "latest_version=$LATEST_PF_VERSION" >> $GITHUB_OUTPUT - fi - - sync-component-schemas: - needs: check-patternfly-release - if: needs.check-patternfly-release.outputs.should_update == 'true' - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - token: ${{ secrets.GITHUB_TOKEN }} - - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version: '18' - cache: 'npm' - - - name: Install dependencies - run: npm ci - - - name: Try downloading pre-built props.json - id: download_props - continue-on-error: true - run: | - echo "🔍 Attempting to download pre-built props.json..." - - # Strategy 1: Try from PatternFly doc-core release assets - PROPS_URL="https://github.com/patternfly/patternfly-doc-core/releases/download/${{ needs.check-patternfly-release.outputs.latest_version }}/props.json" - echo "📥 Trying release assets: $PROPS_URL" - - if curl -f -L -o ./component-metadata.json "$PROPS_URL"; then - echo "✅ Downloaded props.json from release assets" - echo "downloaded=true" >> $GITHUB_OUTPUT - exit 0 - fi - - # Strategy 2: Try from PatternFly main repo release assets - PROPS_URL_ALT="https://github.com/patternfly/patternfly/releases/download/${{ needs.check-patternfly-release.outputs.latest_version }}/props.json" - echo "📥 Trying main repo assets: $PROPS_URL_ALT" - - if curl -f -L -o ./component-metadata.json "$PROPS_URL_ALT"; then - echo "✅ Downloaded props.json from main repo assets" - echo "downloaded=true" >> $GITHUB_OUTPUT - exit 0 - fi - - # Strategy 3: Try from a known CDN or public URL (if PatternFly hosts it) - PROPS_URL_CDN="https://unpkg.com/@patternfly/documentation-framework@latest/props.json" - echo "📥 Trying CDN: $PROPS_URL_CDN" - - if curl -f -L -o ./component-metadata.json "$PROPS_URL_CDN"; then - echo "✅ Downloaded props.json from CDN" - echo "downloaded=true" >> $GITHUB_OUTPUT - exit 0 - fi - - echo "❌ Pre-built props.json not available from any source, will build from source" - echo "downloaded=false" >> $GITHUB_OUTPUT - - - name: Build PatternFly props from doc-core CLI - if: steps.download_props.outputs.downloaded == 'false' - run: | - echo "🔨 Building props.json using PatternFly doc-core CLI..." - - # Clone the latest doc-core (which contains the CLI at cli/cli.ts) - git clone --depth 1 https://github.com/patternfly/patternfly-doc-core.git /tmp/pf-doc-core - cd /tmp/pf-doc-core - - echo "📦 Installing doc-core dependencies..." - npm ci --prefer-offline --no-audit || npm install - - echo "🏗️ Building doc-core CLI..." - npm run build || npm run compile || echo "Build completed with warnings" - - echo "🎯 Generating props.json using official CLI..." - # Use the CLI directly as per the source code at cli/cli.ts#L65 - # The CLI should generate props.json in the expected location - npm run build:props || node dist/cli/cli.js || node cli/cli.ts - - echo "📂 Locating generated props.json..." - # Check multiple possible locations where props.json might be generated - if [ -f "dist/props.json" ]; then - echo "✅ Found props.json at dist/props.json" - cp dist/props.json $GITHUB_WORKSPACE/component-metadata.json - elif [ -f "props.json" ]; then - echo "✅ Found props.json at root" - cp props.json $GITHUB_WORKSPACE/component-metadata.json - elif [ -f "packages/module/dist/props.json" ]; then - echo "✅ Found props.json at packages/module/dist/props.json" - cp packages/module/dist/props.json $GITHUB_WORKSPACE/component-metadata.json - else - echo "🔍 Searching for props.json in entire directory..." - find . -name "props.json" -type f | head -10 - - # Try to find the most recent props.json file - PROPS_FILE=$(find . -name "props.json" -type f -printf '%T@ %p\n' | sort -k 1nr | head -1 | cut -d' ' -f2-) - if [ -n "$PROPS_FILE" ]; then - echo "✅ Using most recent props.json: $PROPS_FILE" - cp "$PROPS_FILE" $GITHUB_WORKSPACE/component-metadata.json - else - echo "❌ No props.json file found after build" - exit 1 - fi - fi - - echo "✅ Successfully copied props.json to component-metadata.json" - - - name: Validate and regenerate schemas - run: | - # Verify the props file is valid JSON - if ! jq empty component-metadata.json; then - echo "❌ Invalid JSON in component-metadata.json" - exit 1 - fi - - # Count components for verification - COMPONENT_COUNT=$(jq '. | length' component-metadata.json) - echo "📊 Found $COMPONENT_COUNT components in metadata" - - if [ "$COMPONENT_COUNT" -lt 100 ]; then - echo "⚠️ Warning: Component count seems low ($COMPONENT_COUNT), expected 400+" - fi - - # Regenerate schemas - npm run build - - # Verify schema generation - SCHEMA_COUNT=$(find components -name "schema.json" | wc -l) - echo "📊 Generated $SCHEMA_COUNT component schemas" - - - name: Check for changes - id: changes - run: | - if git diff --quiet; then - echo "No changes detected" - echo "has_changes=false" >> $GITHUB_OUTPUT - else - echo "Changes detected" - echo "has_changes=true" >> $GITHUB_OUTPUT - fi - - - name: Commit and push changes - if: steps.changes.outputs.has_changes == 'true' - run: | - git config --local user.email "action@github.com" - git config --local user.name "GitHub Action" - - # Add all changes - git add . - - # Create conventional commit that triggers a release - git commit -m "feat(components): sync with PatternFly ${{ needs.check-patternfly-release.outputs.latest_version }} - - - Updated component metadata from PatternFly ${{ needs.check-patternfly-release.outputs.latest_version }} - - Regenerated all component schemas - - $(git diff --name-only HEAD~1 | grep -E '\.(json|js)$' | wc -l) files updated" - - # Push to main (this will trigger the release workflow) - git push origin main - - - name: Create issue if sync fails - if: failure() - uses: actions/github-script@v7 - with: - script: | - github.rest.issues.create({ - owner: context.repo.owner, - repo: context.repo.repo, - title: `Failed to sync with PatternFly ${{ needs.check-patternfly-release.outputs.latest_version }}`, - body: `The automated sync with PatternFly ${{ needs.check-patternfly-release.outputs.latest_version }} failed. Please check the workflow logs and sync manually. - - **Manual sync steps:** - 1. Clone https://github.com/patternfly/patternfly-doc-core - 2. Run \`npm run build:props\` - 3. Copy \`dist/props.json\` to \`component-metadata.json\` - 4. Run \`npm run build\` - 5. Commit with: \`feat(components): sync with PatternFly ${{ needs.check-patternfly-release.outputs.latest_version }}\` - - Workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}`, - labels: ['automation', 'sync-failed'] - }) diff --git a/README.md b/README.md index d5d41a68..c2818c39 100644 --- a/README.md +++ b/README.md @@ -80,27 +80,18 @@ The package is generated from `component-metadata.json` which contains the raw P ### Updating Component Metadata -**🤖 Automated Sync (Recommended)** -- **Daily checks** for new PatternFly releases at 9 AM UTC -- **Smart download**: Tries multiple sources for pre-built props.json -- **Fallback build**: Builds from PatternFly source if pre-built unavailable -- **Auto-sync** when new PatternFly version is released -- **Manual trigger** available in GitHub Actions tab -- **Automatic release** after successful sync - -**Sync Sources (in priority order):** -1. 📦 PatternFly doc-core release assets -2. 📦 PatternFly main repo release assets -3. 🌐 CDN/public URLs (if available) -4. 🔨 **Official PatternFly doc-core CLI** ([cli/cli.ts#L65](https://github.com/patternfly/patternfly-doc-core/blob/a7e8e82d753b93feac1b90a35df673ef2c6e0971/cli/cli.ts#L65)) - -**📋 Manual Process (Fallback)** +**📋 Manual Process (Current)** 1. Clone https://github.com/patternfly/patternfly-doc-core 2. Run `npm run build:props` in the doc-core directory 3. Copy `dist/props.json` content to `component-metadata.json` of this repo 4. Run `npm run build` to regenerate schemas 5. Commit with: `feat(components): sync with PatternFly vX.X.X` -6. Push to `main` → automatic release triggers +6. Push to `main` → **automatic release triggers** 🚀 + +**🔮 Future Automation** +- Dependency management via Renovate/Dependabot +- Automated PRs for PatternFly quarterly releases +- Human-in-the-loop review for component updates ## 📊 Package Contents diff --git a/index.js b/index.js index bd4b1154..a0602518 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,5 @@ // Auto-generated index file for PatternFly component schemas -// Generated on: 2025-09-12T18:02:46.338Z +// Generated on: 2025-09-15T18:55:53.503Z export { default as KeyboardHandler } from './components/KeyboardHandler/index.js'; export { default as SampleDataRow } from './components/SampleDataRow/index.js'; From 9528d3c47db00dcee81fb59a944ae2d1e4401b39 Mon Sep 17 00:00:00 2001 From: Jenny <32821331+jenny-s51@users.noreply.github.com> Date: Tue, 16 Sep 2025 09:48:23 -0400 Subject: [PATCH 3/3] chore(build): apply PR feedback --- .commitlintrc.json | 33 +--------------- .github/workflows/release.yml | 24 +++++++----- .releaserc.json | 71 ----------------------------------- README.md | 42 ++++----------------- index.js | 2 +- package.json | 24 ++---------- 6 files changed, 27 insertions(+), 169 deletions(-) delete mode 100644 .releaserc.json diff --git a/.commitlintrc.json b/.commitlintrc.json index 2856c6a0..c30e5a97 100644 --- a/.commitlintrc.json +++ b/.commitlintrc.json @@ -1,34 +1,3 @@ { - "extends": ["@commitlint/config-conventional"], - "rules": { - "type-enum": [ - 2, - "always", - [ - "feat", - "fix", - "docs", - "style", - "refactor", - "perf", - "test", - "chore", - "ci", - "build" - ] - ], - "scope-enum": [ - 1, - "always", - [ - "components", - "schemas", - "build", - "ci", - "docs", - "deps", - "release" - ] - ] - } + "extends": ["@commitlint/config-conventional"] } diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0d4f35a0..44f6c95a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,15 +4,17 @@ on: push: branches: - main - pull_request: - branches: - - main + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true jobs: - test: + ci: + name: CI runs-on: ubuntu-latest steps: - - name: Checkout + - name: Check out project uses: actions/checkout@v4 - name: Setup Node.js @@ -34,14 +36,16 @@ jobs: echo "Checking main index..." ls -la index.js - release: - needs: test + deploy: + name: Deploy release runs-on: ubuntu-latest + needs: [ci] if: github.ref == 'refs/heads/main' && github.event_name == 'push' steps: - - name: Checkout + - name: Check out project uses: actions/checkout@v4 with: + # Fetch all history for all branches and tags, which is needed for the release script fetch-depth: 0 token: ${{ secrets.GITHUB_TOKEN }} @@ -57,8 +61,8 @@ jobs: - name: Build schemas run: npm run build - - name: Release + - name: Deploy to NPM and Github + run: npm run semantic-release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - run: npm run semantic-release diff --git a/.releaserc.json b/.releaserc.json deleted file mode 100644 index f5d201f5..00000000 --- a/.releaserc.json +++ /dev/null @@ -1,71 +0,0 @@ -{ - "branches": ["main"], - "plugins": [ - [ - "@semantic-release/commit-analyzer", - { - "preset": "angular", - "releaseRules": [ - {"type": "docs", "scope": "README", "release": "patch"}, - {"type": "refactor", "release": "patch"}, - {"type": "style", "release": "patch"}, - {"type": "chore", "scope": "deps", "release": "patch"}, - {"type": "perf", "release": "patch"}, - {"type": "test", "release": false}, - {"type": "ci", "release": false}, - {"type": "build", "release": false} - ] - } - ], - [ - "@semantic-release/release-notes-generator", - { - "preset": "angular", - "presetConfig": { - "types": [ - {"type": "feat", "section": "Features"}, - {"type": "fix", "section": "Bug Fixes"}, - {"type": "perf", "section": "Performance Improvements"}, - {"type": "refactor", "section": "Code Refactoring"}, - {"type": "docs", "section": "Documentation"}, - {"type": "style", "section": "Styles"}, - {"type": "chore", "section": "Maintenance", "hidden": true}, - {"type": "test", "section": "Tests", "hidden": true}, - {"type": "ci", "section": "CI", "hidden": true}, - {"type": "build", "section": "Build", "hidden": true} - ] - }, - "writerOpts": { - "commitsSort": ["subject", "scope"] - } - } - ], - [ - "@semantic-release/changelog", - { - "changelogFile": "CHANGELOG.md" - } - ], - [ - "@semantic-release/npm", - { - "npmPublish": true - } - ], - [ - "@semantic-release/git", - { - "assets": ["CHANGELOG.md", "package.json"], - "message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}" - } - ], - [ - "@semantic-release/github", - { - "successComment": false, - "failComment": false, - "releasedLabels": false - } - ] - ] -} diff --git a/README.md b/README.md index c2818c39..cc2a0fa3 100644 --- a/README.md +++ b/README.md @@ -126,48 +126,22 @@ Follow [Conventional Commits](https://conventionalcommits.org/) specification: ``` [optional scope]: - -[optional body] - -[optional footer(s)] ``` -**Types:** -- `feat`: New features (minor version bump) -- `fix`: Bug fixes (patch version bump) -- `docs`: Documentation changes (patch version bump) -- `chore`: Maintenance tasks (no version bump) -- `ci`: CI/CD changes (no version bump) -- `refactor`: Code refactoring (patch version bump) - -**Scopes:** -- `components`: Component schema changes -- `schemas`: Schema generation changes -- `build`: Build system changes -- `ci`: CI/CD configuration -- `docs`: Documentation updates -- `deps`: Dependency updates - **Examples:** ```bash -feat(components): add new Button variant schema -fix(schemas): correct required props validation -docs(readme): update installation instructions -chore(deps): update semantic-release to v22 +feat: add new component schemas +fix: correct required props validation +docs: update installation instructions +chore: update dependencies ``` ### Release Process -1. **Automatic**: Push commits to `main` branch -2. **CI/CD**: GitHub Actions runs tests and build -3. **Release**: Semantic-release analyzes commits and publishes -4. **Changelog**: Automatically generated and committed - -### Manual Release (if needed) - -```bash -npm run semantic-release -``` +1. **Push commits** to `main` branch using conventional format +2. **GitHub Actions** runs CI and tests +3. **Semantic-release** analyzes commits and publishes to NPM +4. **GitHub releases** created automatically ## 🤝 Contributing diff --git a/index.js b/index.js index a0602518..35cbcb58 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,5 @@ // Auto-generated index file for PatternFly component schemas -// Generated on: 2025-09-15T18:55:53.503Z +// Generated on: 2025-09-16T13:47:33.613Z export { default as KeyboardHandler } from './components/KeyboardHandler/index.js'; export { default as SampleDataRow } from './components/SampleDataRow/index.js'; diff --git a/package.json b/package.json index 10d57ddb..f1cc9d8d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@patternfly/patternfly-component-schemas", - "version": "1.1.0", + "version": "1.0.0", "description": "JSON Schema metadata for PatternFly React components", "main": "index.js", "type": "module", @@ -22,11 +22,7 @@ "license": "MIT", "devDependencies": { "chokidar": "^3.5.3", - "@semantic-release/changelog": "^6.0.3", - "@semantic-release/git": "^10.0.1", - "semantic-release": "^22.0.12", - "@commitlint/cli": "^18.4.3", - "@commitlint/config-conventional": "^18.4.3" + "semantic-release": "^22.0.12" }, "files": [ "components/", @@ -42,20 +38,6 @@ "url": "https://github.com/patternfly/patternfly-component-schemas.git" }, "release": { - "branches": ["main"], - "plugins": [ - "@semantic-release/commit-analyzer", - "@semantic-release/release-notes-generator", - "@semantic-release/changelog", - "@semantic-release/npm", - [ - "@semantic-release/git", - { - "assets": ["CHANGELOG.md", "package.json"], - "message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}" - } - ], - "@semantic-release/github" - ] + "branches": ["main"] } }