-
Notifications
You must be signed in to change notification settings - Fork 11
fix(API): address issues with text API in monorepos #185
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 9 commits
9fd87fb
d75e164
7b27a98
9bced60
06a90f4
76e5270
fc8173c
cd5c2a0
062ae90
f41a39e
43c2194
8e9d674
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 |
|---|---|---|
|
|
@@ -34,3 +34,7 @@ src/apiIndex.json | |
| textContent/*.mdx | ||
|
|
||
| coverage/ | ||
|
|
||
| .wrangler/ | ||
|
|
||
| temp | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,6 +34,7 @@ try { | |
| .replace('file://', '') | ||
| } catch (e: any) { | ||
| if (e.code === 'ERR_MODULE_NOT_FOUND') { | ||
| console.log('@patternfly/patternfly-doc-core not found, using current directory as astroRoot') | ||
| astroRoot = process.cwd() | ||
| } else { | ||
| console.error('Error resolving astroRoot', e) | ||
|
|
@@ -87,29 +88,33 @@ async function transformMDContentToMDX() { | |
| } | ||
| } | ||
|
|
||
| async function initializeApiIndex() { | ||
| async function initializeApiIndex(program: Command) { | ||
| const { verbose } = program.opts() | ||
| const templateIndexPath = join(astroRoot, 'cli', 'templates', 'apiIndex.json') | ||
| const targetIndexPath = join(astroRoot, 'src', 'apiIndex.json') | ||
|
|
||
| const targetIndexPath = join(absoluteOutputDir, 'apiIndex.json') | ||
| const indexExists = await fileExists(targetIndexPath) | ||
|
|
||
| // early return if the file exists from a previous build | ||
| if (indexExists) { | ||
| console.log('apiIndex.json already exists, skipping initialization') | ||
| if (verbose) { | ||
| console.log('apiIndex.json already exists, skipping initialization') | ||
| } | ||
| return | ||
| } | ||
|
|
||
| try { | ||
| await copyFile(templateIndexPath, targetIndexPath) | ||
| console.log('Initialized apiIndex.json') | ||
| if (verbose) { | ||
| console.log('Initialized apiIndex.json') | ||
| } | ||
| } catch (e: any) { | ||
| console.error('Error copying apiIndex.json template:', e) | ||
| } | ||
| } | ||
|
|
||
| async function buildProject(): Promise<DocsConfig | undefined> { | ||
| await updateContent(program) | ||
| await generateProps(program, true) | ||
| async function buildProject(program: Command): Promise<DocsConfig | undefined> { | ||
| const { verbose } = program.opts() | ||
|
|
||
| if (!config) { | ||
| console.error( | ||
| 'No config found, please run the `setup` command or manually create a pf-docs.config.mjs file', | ||
|
|
@@ -123,44 +128,52 @@ async function buildProject(): Promise<DocsConfig | undefined> { | |
| ) | ||
| return config | ||
| } | ||
|
|
||
| await initializeApiIndex() | ||
| await updateContent(program) | ||
| await generateProps(program, true) | ||
| await initializeApiIndex(program) | ||
| await transformMDContentToMDX() | ||
|
|
||
| build({ | ||
| const docsOutputDir = join(absoluteOutputDir, 'docs') | ||
|
|
||
| await build({ | ||
| root: astroRoot, | ||
| outDir: join(absoluteOutputDir, 'docs'), | ||
| outDir: docsOutputDir, | ||
| }) | ||
|
|
||
| // copy the apiIndex.json file to the docs directory so it can be served as a static asset | ||
| const apiIndexPath = join(absoluteOutputDir, 'apiIndex.json') | ||
| const docsApiIndexPath = join(absoluteOutputDir, 'docs', 'apiIndex.json') | ||
| await copyFile(apiIndexPath, docsApiIndexPath) | ||
|
|
||
| if (verbose) { | ||
| console.log('Copied apiIndex.json to docs directory') | ||
| } | ||
|
|
||
| return config | ||
| } | ||
|
|
||
| async function deploy() { | ||
| const { verbose } = program.opts() | ||
| async function deploy(program: Command) { | ||
| const { verbose, dryRun } = program.opts() | ||
|
|
||
| if (verbose) { | ||
| console.log('Starting Cloudflare deployment...') | ||
| } | ||
|
|
||
| if (dryRun) { | ||
| console.log('Dry run mode enabled, skipping deployment') | ||
| return | ||
| } | ||
|
|
||
| try { | ||
| // First build the project | ||
| const config = await buildProject() | ||
| if (config) { | ||
| if (verbose) { | ||
| console.log('Build complete, deploying to Cloudflare...') | ||
| } | ||
|
|
||
| // Deploy using Wrangler | ||
| const { execSync } = await import('child_process') | ||
| const outputPath = join(absoluteOutputDir, 'docs') | ||
|
|
||
| execSync(`npx wrangler pages deploy ${outputPath}`, { | ||
| stdio: 'inherit', | ||
| cwd: currentDir, | ||
| }) | ||
|
|
||
| console.log('Successfully deployed to Cloudflare Pages!') | ||
| } | ||
| // Deploy using Wrangler | ||
| const { execSync } = await import('child_process') | ||
|
|
||
| execSync(`wrangler pages deploy`, { | ||
| stdio: 'inherit', | ||
| cwd: currentDir, | ||
| }) | ||
|
Comment on lines
172
to
+179
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # Check for wrangler.toml files and examine the deploy function in detail
echo "=== Finding wrangler.toml files ==="
fd -t f "wrangler.toml"
echo -e "\n=== Checking cli/cli.ts deploy function context ==="
# Read the deploy function in full (lines 155-181 as mentioned in comment)
if [ -f "cli/cli.ts" ]; then
sed -n '155,181p' cli/cli.ts
else
echo "cli/cli.ts not found, searching for it"
fd -t f "cli.ts"
fiRepository: patternfly/patternfly-doc-core Length of output: 761 🏁 Script executed: echo "=== Searching for currentDir definition in cli/cli.ts ==="
rg "currentDir" cli/cli.ts -B 2 -A 2
echo -e "\n=== Checking full deploy function and surrounding context ==="
wc -l cli/cli.ts
echo -e "\n=== Search for where deploy() is called ==="
rg "deploy\(" cli/cli.ts -B 3 -A 3
echo -e "\n=== Check if outputDir is used in deploy or related functions ==="
rg "outputDir" cli/cli.ts -B 1 -A 1Repository: patternfly/patternfly-doc-core Length of output: 1997 🏁 Script executed: echo "=== Search for README or deployment documentation ==="
fd -t f -i "readme" | head -5
echo -e "\n=== Check for any comments/docs around deploy function ==="
sed -n '145,180p' cli/cli.ts
echo -e "\n=== Search for test files related to deploy ==="
fd -t f "test\|spec" | grep -i deploy
echo -e "\n=== Check if there are any example configs or docs ==="
fd -t f "example\|sample\|template" | head -10
echo -e "\n=== Search for wrangler usage in comments or docs ==="
rg "wrangler" --type md --type txtRepository: patternfly/patternfly-doc-core Length of output: 1180 Pass the build output directory explicitly to Wrangler. The deployment command executes Or the 🤖 Prompt for AI Agents
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is intended, we want the deploy dir to come from the wrangler config file. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @wise-king-sullyman, understood! Using the wrangler.toml configuration for the deployment directory is a valid approach and keeps the deployment configuration centralized. Thank you for clarifying the intent. |
||
|
|
||
| console.log('Successfully deployed to Cloudflare Pages!') | ||
| } catch (error) { | ||
| console.error('Deployment failed:', error) | ||
| process.exit(1) | ||
|
|
@@ -172,6 +185,7 @@ program.name('pf-doc-core') | |
|
|
||
| program.option('--verbose', 'verbose mode', false) | ||
| program.option('--props', 'generate props data', false) | ||
| program.option('--dry-run', 'dry run mode', false) | ||
|
|
||
| program.command('setup').action(async () => { | ||
| await Promise.all([ | ||
|
|
@@ -194,7 +208,7 @@ program.command('init').action(async () => { | |
|
|
||
| program.command('start').action(async () => { | ||
| await updateContent(program) | ||
| await initializeApiIndex() | ||
| await initializeApiIndex(program) | ||
|
|
||
| // if a props file hasn't been generated yet, but the consumer has propsData, it will cause a runtime error so to | ||
| // prevent that we're just creating a props file regardless of what they say if one doesn't exist yet | ||
|
|
@@ -204,7 +218,7 @@ program.command('start').action(async () => { | |
| }) | ||
|
|
||
| program.command('build').action(async () => { | ||
| await buildProject() | ||
| await buildProject(program) | ||
| }) | ||
|
|
||
| program.command('generate-props').action(async () => { | ||
|
|
@@ -229,7 +243,7 @@ program | |
| }) | ||
|
|
||
| program.command('deploy').action(async () => { | ||
| await deploy() | ||
| await deploy(program) | ||
| }) | ||
|
|
||
| program.parse(process.argv) | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.