Skip to content

dx: improve local docs quickstart with bootstrap + smart pipeline runner#67

Open
isyedrayan1 wants to merge 1 commit intowebpack:mainfrom
isyedrayan1:isyedrayan1/dx-quickstart-bootstrap
Open

dx: improve local docs quickstart with bootstrap + smart pipeline runner#67
isyedrayan1 wants to merge 1 commit intowebpack:mainfrom
isyedrayan1:isyedrayan1/dx-quickstart-bootstrap

Conversation

@isyedrayan1
Copy link
Copy Markdown

Summary

This PR improves local contributor experience for the docs pipeline without changing core generation behavior.

What changed

  • Added to align local checkout with
  • Added as a one-command ordered runner:
    1. bootstrap webpack
    2. generate markdown
    3. build html
  • Added smart skip logic (, , )
  • Added safe preflight checks in with actionable error messages
  • Updated with local quickstart, troubleshooting, and contributor workflow
  • Added npm scripts:

Scope and non-goals

  • No changes to
  • No changes to core TypeDoc/doc-kit pipeline logic
  • No CI workflow behavior changes

Validation

  • Clean state run () then

docs:quickstart
node scripts/docs-pipeline.mjs

[docs:quickstart] Step 1/3: bootstrap webpack source
[bootstrap:webpack] Cloning webpack repository...
[bootstrap:webpack] Checked out b5499e05b0c1c2847545a610cbaea3d352328d3d.
[docs:quickstart] Step 2/3: generate markdown docs

generate-docs
node generate-md.mjs

�[96m[info]�[0m Loaded plugin typedoc-plugin-markdown
�[96m[info]�[0m Loaded plugin /workspaces/webpack-doc-kit/plugins/processor.mjs
�[96m[info]�[0m Loaded plugin /workspaces/webpack-doc-kit/plugins/theme/index.mjs
�[96m[info]�[0m markdown generated at ./pages/v5.x
[docs:quickstart] Step 3/3: build html docs

build-html
doc-kit generate -t web --config-file ./doc-kit.config.mjs

  • webpack cloned and checked out to
  • markdown generated
  • html built
  • Re-run

docs:quickstart
node scripts/docs-pipeline.mjs

[docs:quickstart] Step 1/3: bootstrap webpack source (skipped; already at target commit)
[docs:quickstart] Step 2/3: generate markdown docs (skipped; no relevant changes)
[docs:quickstart] Step 3/3: build html docs (skipped; output is up to date)

  • bootstrap skipped
  • generate skipped
  • build skipped
  • Failure check:

generate-docs
node generate-md.mjs

  • clear error shown:

Why

CI already checks out webpack automatically, but local contributors were missing this setup path. This PR makes local setup explicit, reproducible, and fast for repeat runs.

Copilot AI review requested due to automatic review settings March 29, 2026 20:34
@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla bot commented Mar 29, 2026

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: isyedrayan1 / name: Syed Rayan (6cabbbb)

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Improves the local contributor workflow for generating the webpack API docs by adding a bootstrap step for checking out the upstream webpack source at the pinned HEAD_COMMIT, plus a single-command pipeline runner with skip logic.

Changes:

  • Added scripts/bootstrap-webpack.mjs to clone/update ./webpack at the commit pinned in HEAD_COMMIT.
  • Added scripts/docs-pipeline.mjs to run bootstrap → markdown generation → HTML build with --force/--verbose/--no-html support and stateful skipping.
  • Updated generate-md.mjs, package.json scripts, and README.md to support and document the new local quickstart flow.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
scripts/docs-pipeline.mjs New ordered pipeline runner with preflight checks and skip/state logic.
scripts/bootstrap-webpack.mjs New helper to clone/fetch/checkout upstream webpack at HEAD_COMMIT.
generate-md.mjs Adds local preflight checks for presence of required webpack/ inputs.
package.json Adds bootstrap:webpack, docs:quickstart, and docs:doctor scripts.
package-lock.json Lockfile updates from dependency resolution/install.
README.md Adds local quickstart, troubleshooting, and contributor workflow docs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +83 to +93
Useful flags for the quickstart runner:

- `--force` reruns every step
- `--verbose` prints detailed diagnostics
- `--no-html` skips the HTML build

Example:

```bash
node scripts/docs-pipeline.mjs --force --verbose
```
Copy link

Copilot AI Mar 29, 2026

Choose a reason for hiding this comment

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

The README describes flags for the quickstart runner but the example uses node scripts/docs-pipeline.mjs .... If the intended entrypoint is npm run docs:quickstart, passing flags requires npm run docs:quickstart -- --force --verbose. Consider updating the example (or adding a second example) so contributors don’t try npm run docs:quickstart --force and get unexpected npm behavior.

Copilot uses AI. Check for mistakes.
Comment on lines +170 to +178
if (force || currentWebpackCommit !== targetCommit) {
log('Step 1/3: bootstrap webpack source');
run('node', ['scripts/bootstrap-webpack.mjs']);
} else {
log('Step 1/3: bootstrap webpack source (skipped; already at target commit)');
}

const webpackMajor = readWebpackMajorVersion();
const docsDir = resolve(ROOT, `pages/v${webpackMajor}.x`);
Copy link

Copilot AI Mar 29, 2026

Choose a reason for hiding this comment

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

Step 1 can be reported as "skipped" even when the local webpack checkout is incomplete (e.g., webpack/package.json or webpack/types.d.ts missing). In that case the pipeline will fail later with a confusing error even though bootstrap was skipped. Consider extending the skip condition to also verify the required webpack files exist (and/or reuse the same checks as generate-md.mjs) before deciding to skip bootstrap.

Copilot uses AI. Check for mistakes.
resolve(ROOT, 'generate-md.mjs'),
resolve(ROOT, 'tsconfig.json'),
resolve(ROOT, 'plugins'),
resolve(ROOT, 'HEAD_COMMIT'),
Copy link

Copilot AI Mar 29, 2026

Choose a reason for hiding this comment

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

sourceFingerprint() currently tracks repo files (generate-md.mjs/tsconfig/plugins/HEAD_COMMIT) but not the local webpack inputs used for generation (webpack/types.d.ts, webpack/package.json). This means Step 2 can be skipped even if a contributor edits webpack types locally (without changing commits), leaving stale markdown. Include the relevant webpack/ files in the fingerprint (or in needsGenerate) so local edits force regeneration.

Suggested change
resolve(ROOT, 'HEAD_COMMIT'),
resolve(ROOT, 'HEAD_COMMIT'),
resolve(WEBPACK_DIR, 'types.d.ts'),
WEBPACK_PKG,

Copilot uses AI. Check for mistakes.
Comment on lines +53 to +63
const result = spawnSync(command, commandArgs, {
cwd: ROOT,
encoding: 'utf8',
});

if (result.status !== 0) {
const fullCommand = [command, ...commandArgs].join(' ');
fail(`Command failed: ${fullCommand}`);
}

return result.stdout.trim();
Copy link

Copilot AI Mar 29, 2026

Choose a reason for hiding this comment

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

runCapture() discards stderr and only reports "Command failed: ..." on non-zero exit. For failures like a corrupt git repo or missing git, this can hide the underlying error message and make troubleshooting harder. Consider including result.stderr (and result.error for ENOENT) in the failure output so errors are actionable.

Suggested change
const result = spawnSync(command, commandArgs, {
cwd: ROOT,
encoding: 'utf8',
});
if (result.status !== 0) {
const fullCommand = [command, ...commandArgs].join(' ');
fail(`Command failed: ${fullCommand}`);
}
return result.stdout.trim();
const fullCommand = [command, ...commandArgs].join(' ');
const result = spawnSync(command, commandArgs, {
cwd: ROOT,
encoding: 'utf8',
});
// Handle spawn errors (for example, command not found).
if (result.error) {
if (result.error.code === 'ENOENT') {
fail(`Command not found: ${command} (while running: ${fullCommand})`);
}
fail(`Failed to run command: ${fullCommand}\n${result.error.message}`);
}
if (result.status !== 0) {
let errorDetail = '';
if (result.stderr) {
const stderrString =
typeof result.stderr === 'string'
? result.stderr
: result.stderr.toString('utf8');
const trimmedStderr = stderrString.trim();
if (trimmedStderr) {
errorDetail = '\n' + trimmedStderr;
}
}
fail(
`Command failed with exit code ${result.status}: ${fullCommand}${errorDetail}`,
);
}
const stdoutString =
typeof result.stdout === 'string'
? result.stdout
: (result.stdout || '').toString('utf8');
return stdoutString.trim();

Copilot uses AI. Check for mistakes.

if (result.status !== 0) {
const fullCommand = [command, ...args].join(' ');
throw new Error(`Command failed: ${fullCommand}`);
Copy link

Copilot AI Mar 29, 2026

Choose a reason for hiding this comment

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

In runCapture(), failures throw Error("Command failed: ...") without surfacing the command’s stderr (and without checking result.error when the executable is missing). This can make bootstrap failures hard to diagnose. Consider appending result.stderr / result.error?.message to the thrown error to keep the message actionable.

Suggested change
throw new Error(`Command failed: ${fullCommand}`);
const details = [];
if (result.error && result.error.message) {
details.push(`Error: ${result.error.message}`);
}
if (typeof result.stderr === 'string' && result.stderr.trim() !== '') {
details.push(`stderr:\n${result.stderr.trim()}`);
}
const detailSuffix = details.length > 0 ? `\n${details.join('\n')}` : '';
throw new Error(`Command failed: ${fullCommand}${detailSuffix}`);

Copilot uses AI. Check for mistakes.
Comment on lines +5 to +16
if (!existsSync('./webpack')) {
throw new Error('Webpack source not found. Run: npm run bootstrap:webpack');
}

if (
!existsSync('./webpack/package.json') ||
!existsSync('./webpack/types.d.ts')
) {
throw new Error(
'Webpack source is incomplete. Run: npm run bootstrap:webpack'
);
}
Copy link

Copilot AI Mar 29, 2026

Choose a reason for hiding this comment

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

generate-md.mjs now checks that webpack/ exists, but it can still generate docs from a webpack checkout that’s not the HEAD_COMMIT pinned commit (e.g., if a contributor has webpack/ at a different SHA). That can produce pages that don’t match CI’s docs-check behavior and will fail in PRs. Consider validating git -C ./webpack rev-parse HEAD against HEAD_COMMIT and erroring with an actionable message when they differ.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member

@avivkeller avivkeller left a comment

Choose a reason for hiding this comment

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

I'm sorry, but I really have no idea what it is this PR is trying to accomplish.

@avivkeller
Copy link
Copy Markdown
Member

Most of what this PR adds can simply be:

git clone https://github.com/webpack/webpack
git checkout $(cat HEAD_COMMIT)

@isyedrayan1
Copy link
Copy Markdown
Author

isyedrayan1 commented Mar 29, 2026

@avivkeller This PR is simply making the project setup easier for every contributors. With custom scripts. To run the project repo locally.without getting confused with the commands and pre-requisites as I've faced few issues while running the project.

@isyedrayan1
Copy link
Copy Markdown
Author

Thanks for the feedback, that makes sense.

I see that the PR added unnecessary complexity and wasn’t aligned with the core goals of the project.

I’ll refocus on smaller, more relevant contributions directly related to the pipeline and theme output.

Appreciate the clarification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants