Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/scripts/push-wai.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env zx
import 'zx/globals'
import { config, commitAndPush } from './commons.mjs'

const commitMessage = (await $`git log -1 --pretty=%B`).stdout
await commitAndPush(config, commitMessage)
30 changes: 20 additions & 10 deletions .github/scripts/wai-build.mjs
Original file line number Diff line number Diff line change
@@ -1,25 +1,35 @@
#!/usr/bin/env zx
import 'zx/globals';
import { config, cloneWcagActRules, commitAndPush } from './commons.mjs'
import { config, cloneWcagActRules } from './commons.mjs'

const ACT_TOOLS_PATH = process.env.ACT_TOOLS_PATH || './node_modules/act-tools';
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note (non-blocking): I usually prefer nullish coalescence (??) in order to avoid the occasional blow-up with falsy-but-actually-correct values.

Suggested change
const ACT_TOOLS_PATH = process.env.ACT_TOOLS_PATH || './node_modules/act-tools';
const ACT_TOOLS_PATH = process.env.ACT_TOOLS_PATH ?? './node_modules/act-tools';

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: If act-tools is expected to be in node_modules, wouldn't an import { … } from "act-tools" work fine?

The cli code there seems to only call some other function with parameters read from CLI.
(a bit unrelated to this PR, since it was already how the other commands are run)


await cloneWcagActRules(config);
await generateProposedRulePages(config);
await generateexamples(config);
const commitMessage = (await $`git log -1 --pretty=%B`).stdout;
await commitAndPush(config, commitMessage);
await generateGlossaryPage(config);

async function generateGlossaryPage({ tmpDir, rulesDir, glossaryDir, testAssetsDir }) {
await $`node ${ACT_TOOLS_PATH}/dist/cli/generate-glossary.js \
--rulesDir "${rulesDir}" \
--glossaryDir "${glossaryDir}" \
--testAssetsDir "${testAssetsDir}" \
--outDir "${tmpDir}"
`;
}

async function generateProposedRulePages({ tmpDir, rulesDir, glossaryDir, testAssetsDir }) {
await $`node ./node_modules/act-tools/dist/cli/rule-transform.js \
--rulesDir "${rulesDir}" \
--glossaryDir "${glossaryDir}" \
--testAssetsDir "${testAssetsDir}" \
--outDir "${tmpDir}" \
--proposed
await $`node ${ACT_TOOLS_PATH}/dist/cli/rule-transform.js \
--rulesDir "${rulesDir}" \
--glossaryDir "${glossaryDir}" \
--testAssetsDir "${testAssetsDir}" \
--outDir "${tmpDir}" \
--proposed
`;
}

async function generateexamples({ tmpDir, rulesDir, testAssetsDir }) {
await $`node ./node_modules/act-tools/dist/cli/build-examples.js \
await $`node ${ACT_TOOLS_PATH}/dist/cli/build-examples.js \
--rulesDir "${rulesDir}" \
--testAssetsDir "${testAssetsDir}" \
--outDir "${tmpDir}" \
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/wai-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,7 @@ jobs:
git config --global url."https://${{ secrets.WAI_GIT_NAME }}:${{ secrets.WAI_GIT_ACCESS_TOKEN }}@github.com".insteadOf "https://github.com"
git config --global user.name "${{ secrets.WAI_GIT_NAME }}"
git config --global user.email "${{ secrets.WAI_GIT_EMAIL }}"
- name: Build and deploy WAI update
- name: Build WAI update
run: npm run build:wai
- name: Push WAI update
run: npm run push:wai
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@
"format": "prettier --write *.{json,md,js,html,css,yml} './{__tests__,_rules,.github,pages,test-assets,test-utils,utils}/**/*.{json,md,js,html,css,yml}'",
"test": "jest --coverage",
"build:wai": "zx .github/scripts/wai-build.mjs",
"push:wai": "zx .github/scripts/wai-push.mjs",
"pr:preview": "zx .github/scripts/pr-preview.mjs"
},
"homepage": "https://github.com/act-rules/act-rules.github.io",
Expand Down