-
Notifications
You must be signed in to change notification settings - Fork 53
dx: improve local docs quickstart with bootstrap + smart pipeline runner #67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,21 @@ | ||
| import { Application } from 'typedoc'; | ||
| import webpack from './webpack/package.json' with { type: 'json' }; | ||
| import { major } from 'semver'; | ||
| import { existsSync, readFileSync } from 'node:fs'; | ||
|
|
||
| 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' | ||
| ); | ||
| } | ||
|
Comment on lines
+5
to
+16
|
||
|
|
||
| const webpack = JSON.parse(readFileSync('./webpack/package.json', 'utf8')); | ||
|
|
||
| const app = await Application.bootstrapWithPlugins({ | ||
| entryPoints: ['./webpack/types.d.ts'], | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,83 @@ | ||||||||||||||||||||||||||||
| import { existsSync, readFileSync } from 'node:fs'; | ||||||||||||||||||||||||||||
| import { resolve } from 'node:path'; | ||||||||||||||||||||||||||||
| import { spawnSync } from 'node:child_process'; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| const ROOT = process.cwd(); | ||||||||||||||||||||||||||||
| const WEBPACK_DIR = resolve(ROOT, 'webpack'); | ||||||||||||||||||||||||||||
| const HEAD_COMMIT_FILE = resolve(ROOT, 'HEAD_COMMIT'); | ||||||||||||||||||||||||||||
| const WEBPACK_REPO_URL = 'https://github.com/webpack/webpack.git'; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| const log = message => { | ||||||||||||||||||||||||||||
| console.log(`[bootstrap:webpack] ${message}`); | ||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| const run = (command, args, options = {}) => { | ||||||||||||||||||||||||||||
| const result = spawnSync(command, args, { | ||||||||||||||||||||||||||||
| cwd: ROOT, | ||||||||||||||||||||||||||||
| stdio: 'inherit', | ||||||||||||||||||||||||||||
| ...options, | ||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| if (result.status !== 0) { | ||||||||||||||||||||||||||||
| const fullCommand = [command, ...args].join(' '); | ||||||||||||||||||||||||||||
| throw new Error(`Command failed: ${fullCommand}`); | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| const runCapture = (command, args, options = {}) => { | ||||||||||||||||||||||||||||
| const result = spawnSync(command, args, { | ||||||||||||||||||||||||||||
| cwd: ROOT, | ||||||||||||||||||||||||||||
| encoding: 'utf8', | ||||||||||||||||||||||||||||
| ...options, | ||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| if (result.status !== 0) { | ||||||||||||||||||||||||||||
| const fullCommand = [command, ...args].join(' '); | ||||||||||||||||||||||||||||
| throw new Error(`Command failed: ${fullCommand}`); | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
| 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}`); |
There was a problem hiding this comment.
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 isnpm run docs:quickstart, passing flags requiresnpm run docs:quickstart -- --force --verbose. Consider updating the example (or adding a second example) so contributors don’t trynpm run docs:quickstart --forceand get unexpected npm behavior.