Skip to content
Merged
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
14 changes: 3 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,6 @@ jobs:
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Read HEAD_COMMIT
id: webpack-ref
run: echo "ref=$(cat HEAD_COMMIT)" >> "$GITHUB_OUTPUT"

- name: Checkout webpack
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
repository: webpack/webpack
ref: ${{ steps.webpack-ref.outputs.ref }}
path: webpack

- name: Setup Node.js
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
with:
Expand All @@ -54,6 +43,9 @@ jobs:
- name: Install dependencies
run: npm ci

- name: Clone webpack
run: npm run clone-webpack

- name: Regenerate docs
run: npm run generate-docs

Expand Down
12 changes: 4 additions & 8 deletions .github/workflows/sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,6 @@ jobs:
echo "New webpack commit detected, syncing."
fi

- name: Checkout webpack
if: steps.check.outputs.changed == 'true'
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
repository: webpack/webpack
ref: ${{ steps.latest.outputs.latest }}
path: webpack

- name: Setup Node.js
if: steps.check.outputs.changed == 'true'
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
Expand All @@ -61,6 +53,10 @@ jobs:
if: steps.check.outputs.changed == 'true'
run: echo "${{ steps.latest.outputs.latest }}" > HEAD_COMMIT

- name: Clone webpack
if: steps.check.outputs.changed == 'true'
run: npm run clone-webpack

- name: Regenerate docs
if: steps.check.outputs.changed == 'true'
run: npm run generate-docs
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ This ensures documentation stays in sync with upstream webpack without manual in

| Script | Description |
| ----------------------- | ------------------------------------ |
| `npm run clone-webpack` | Clone webpack repo at pinned commit |
| `npm run generate-docs` | Generate Markdown from webpack types |
| `npm run build-html` | Convert Markdown to HTML |
| `npm run build` | Generate docs + build HTML |
Expand Down
23 changes: 23 additions & 0 deletions clone-webpack.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { readFile, access } from 'node:fs/promises';
import { execFileSync } from 'node:child_process';

const WEBPACK_DIR = 'webpack';
const REF = (await readFile('HEAD_COMMIT', 'utf-8')).trim();

try {
await access(WEBPACK_DIR);
execFileSync('git', ['fetch', '--all'], {
cwd: WEBPACK_DIR,
stdio: 'inherit',
});
} catch {
execFileSync(
'git',
['clone', 'https://github.com/webpack/webpack.git', WEBPACK_DIR],
{
stdio: 'inherit',
}
);
}

execFileSync('git', ['checkout', REF], { cwd: WEBPACK_DIR, stdio: 'inherit' });
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"scripts": {
"clone-webpack": "node clone-webpack.mjs",
"generate-docs": "node generate-md.mjs",
"build-html": "doc-kit generate -t web --config-file ./doc-kit.config.mjs",
"build": "npm run generate-docs && npm run build-html",
Expand Down