Skip to content

Commit b14c207

Browse files
authored
Modernize generator (#54)
* feat: modernize generator - oclif v4, fast-xml-parser v5, native fetch, vitest tests * fix: address code review and CodeQL findings from validation * Regenerate generator README to remove duplicate commands section * Update npm-publish job: add packages:write, node 24, GitHub Package Registry publish --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
1 parent 3294af9 commit b14c207

19 files changed

Lines changed: 5177 additions & 8518 deletions

.github/workflows/generator.yml

Lines changed: 49 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,89 @@
11
on:
2-
workflow_dispatch:
32
push:
43
branches:
54
- main
6-
- ci-build
75
paths:
86
- '.github/workflows/generator.yml'
97
- 'generator/sonos-docs/src/**/*.ts'
10-
- 'generator/sonos-docs/.releaserc'
8+
- 'generator/sonos-docs/package.json'
119

1210
pull_request:
1311
branches:
1412
- main
1513
paths:
1614
- '.github/workflows/generator.yml'
1715
- 'generator/sonos-docs/src/**/*.ts'
16+
- 'generator/sonos-docs/package.json'
17+
18+
release:
19+
types: [published]
1820

1921
jobs:
2022
test:
21-
name: 'Build and test on Node v${{ matrix.node }}'
23+
name: 'Build and test on Node ${{ matrix.node }}'
2224
runs-on: ubuntu-latest
25+
permissions:
26+
contents: read
2327
strategy:
2428
matrix:
25-
node: [16, 18]
29+
node: [22, 24]
2630
defaults:
2731
run:
2832
working-directory: generator/sonos-docs
2933
steps:
30-
- uses: actions/checkout@v4
31-
- uses: actions/setup-node@v4
34+
- uses: actions/checkout@v7
35+
- uses: actions/setup-node@v6
3236
with:
3337
node-version: ${{ matrix.node }}
34-
- name: Install depencencies
38+
- name: Install dependencies
3539
run: npm ci
3640
- name: Build library
37-
run: npm run prepack
41+
run: npm run build
42+
- name: Run tests
43+
run: npm test
3844

39-
release:
40-
name: 'Release generator'
45+
npm-publish:
46+
name: 'Publish to npm'
4147
needs: [test]
4248
runs-on: ubuntu-latest
43-
if: github.event_name != 'pull_request'
49+
if: github.event_name == 'release'
50+
permissions:
51+
contents: read
52+
id-token: write
53+
packages: write
4454
defaults:
4555
run:
4656
working-directory: generator/sonos-docs
4757
steps:
48-
- uses: actions/checkout@v4
49-
- uses: actions/setup-node@v4
58+
- name: Checkout
59+
uses: actions/checkout@v7
60+
61+
- name: Setup node for npm registry
62+
uses: actions/setup-node@v6
5063
with:
51-
node-version: 16
52-
- name: Install depencencies
64+
node-version: 24
65+
registry-url: 'https://registry.npmjs.org'
66+
67+
- name: Install dependencies
5368
run: npm ci
54-
- name: Semantic Release
55-
uses: cycjimmy/semantic-release-action@v4
56-
id: semantic
57-
with:
58-
working_directory: generator/sonos-docs
59-
env:
60-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
61-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
62-
- name: Setup node for Github Registry
63-
if: steps.semantic.outputs.new_release_published == 'true'
64-
uses: actions/setup-node@v4
69+
70+
- name: Set version from release tag
71+
run: npm version --no-git-tag-version "${{ github.event.release.tag_name }}"
72+
73+
- name: Build library
74+
run: npm run prepack
75+
76+
- name: Publish to npm
77+
run: npm publish --access public --provenance --tag ${{ github.event.release.prerelease && 'beta' || 'latest' }}
78+
79+
- name: Setup node for GitHub Package Registry
80+
uses: actions/setup-node@v6
6581
with:
66-
node-version: 16
82+
node-version: 24
6783
registry-url: 'https://npm.pkg.github.com'
68-
scope: 'svrooij'
69-
- name: Publish To GitHub Package Registry
70-
if: steps.semantic.outputs.new_release_published == 'true'
71-
run: |
72-
npm publish
84+
scope: '@svrooij'
85+
86+
- name: Publish to GitHub Package Registry
87+
run: npm publish --tag ${{ github.event.release.prerelease && 'beta' || 'latest' }}
7388
env:
74-
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
89+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/json-validation.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ jobs:
2121
runs-on: ubuntu-latest
2222
steps:
2323
- name: Checkout Code
24-
uses: actions/checkout@v4
24+
uses: actions/checkout@v7
2525
- name: Use node 16
26-
uses: actions/setup-node@v4
26+
uses: actions/setup-node@v6
2727
with:
2828
node-version: 16
2929
- name: Install ajv-cli

.github/workflows/linter.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
# Checkout the code base #
4040
##########################
4141
- name: Checkout Code
42-
uses: actions/checkout@v4
42+
uses: actions/checkout@v7
4343
with:
4444
# Full git history is needed to get list of changed files
4545
fetch-depth: 0

0 commit comments

Comments
 (0)