Skip to content

Commit cd5c2a0

Browse files
Remove custom outputDir pathing now that we're fetching the apiIndex at
1 parent fc8173c commit cd5c2a0

File tree

9 files changed

+16
-40
lines changed

9 files changed

+16
-40
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,6 @@ textContent/*.mdx
3535

3636
coverage/
3737

38-
.wrangler/
38+
.wrangler/
39+
40+
temp

cli/cli.ts

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ try {
3434
.replace('file://', '')
3535
} catch (e: any) {
3636
if (e.code === 'ERR_MODULE_NOT_FOUND') {
37+
console.log('@patternfly/patternfly-doc-core not found, using current directory as astroRoot')
3738
astroRoot = process.cwd()
3839
} else {
3940
console.error('Error resolving astroRoot', e)
@@ -87,29 +88,6 @@ async function transformMDContentToMDX() {
8788
}
8889
}
8990

90-
async function updateTsConfigOutputDirPath(program: Command) {
91-
const { verbose } = program.opts()
92-
const tsConfigPath = join(astroRoot, 'tsconfig.json')
93-
94-
try {
95-
const tsConfigFile = await readFile(tsConfigPath, 'utf-8')
96-
const tsConfig = JSON.parse(tsConfigFile)
97-
const formattedOutputDir = join(absoluteOutputDir, '*')
98-
99-
tsConfig.compilerOptions.paths['outputDir/*'] = [formattedOutputDir]
100-
101-
await writeFile(tsConfigPath, JSON.stringify(tsConfig, null, 2))
102-
103-
if (verbose) {
104-
console.log(
105-
`Updated tsconfig.json with outputDir path: ${formattedOutputDir}`,
106-
)
107-
}
108-
} catch (e: any) {
109-
console.error('Error updating tsconfig.json with outputDir path:', e)
110-
}
111-
}
112-
11391
async function initializeApiIndex(program: Command) {
11492
const { verbose } = program.opts()
11593
const templateIndexPath = join(astroRoot, 'cli', 'templates', 'apiIndex.json')
@@ -150,7 +128,6 @@ async function buildProject(program: Command): Promise<DocsConfig | undefined> {
150128
)
151129
return config
152130
}
153-
await updateTsConfigOutputDirPath(program)
154131
await updateContent(program)
155132
await generateProps(program, true)
156133
await initializeApiIndex(program)
@@ -230,7 +207,6 @@ program.command('init').action(async () => {
230207
})
231208

232209
program.command('start').action(async () => {
233-
await updateTsConfigOutputDirPath(program)
234210
await updateContent(program)
235211
await initializeApiIndex(program)
236212

jest.config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ const config: Config = {
1616
testPathIgnorePatterns: ['/node_modules/', '/__tests__/helpers/'],
1717
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
1818
moduleNameMapper: {
19-
'^outputDir/(.*)$': '<rootDir>/dist/$1',
2019
'\\.(css|less)$': '<rootDir>/src/__mocks__/styleMock.ts',
2120
'^astro:content$': '<rootDir>/src/__mocks__/astro-content.ts',
2221
'(.+)\\.js': '$1',

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
"@patternfly/quickstarts": "^6.0.0",
6666
"@types/react": "^18.3.23",
6767
"@types/react-dom": "^18.3.7",
68-
"astro": "5.15.9",
68+
"astro": "^5.15.9",
6969
"change-case": "5.4.4",
7070
"commander": "^13.1.0",
7171
"glob": "^11.0.3",

src/__tests__/pages/api/__tests__/[version].test.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ it('returns 400 error when version parameter is missing', async () => {
137137
jest.restoreAllMocks()
138138
})
139139

140-
it('excludes content entries that have no section field', async () => {
140+
it('returns sections array that matches the API index', async () => {
141141
global.fetch = jest.fn(() =>
142142
Promise.resolve({
143143
ok: true,
@@ -151,8 +151,10 @@ it('excludes content entries that have no section field', async () => {
151151
} as any)
152152
const body = await response.json()
153153

154-
// Should only include sections from entries that have data.section
155-
expect(body.length).toBeGreaterThan(0)
154+
// Verify the returned sections exactly match the indexed sections
155+
// The API index generation process filters out entries without section fields
156+
expect(body).toEqual(mockApiIndex.sections.v6)
157+
expect(body).toEqual(['components', 'layouts', 'utilities'])
156158

157159
jest.restoreAllMocks()
158160
})

src/pages/api/[version]/[section].ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ export const GET: APIRoute = async ({ params, url }) => {
2828

2929
return createJsonResponse(pages)
3030
} catch (error) {
31+
const details = error instanceof Error ? error.message : String(error)
3132
return createJsonResponse(
32-
{ error: 'Failed to load API index', details: error },
33+
{ error: 'Failed to load API index', details },
3334
500
3435
)
3536
}

src/pages/api/openapi.json.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ export const GET: APIRoute = async ({ url }) => {
1010
const index = await fetchApiIndex(url)
1111
versions = index.versions
1212
} catch (error) {
13+
const details = error instanceof Error ? error.message : String(error)
1314
return createJsonResponse(
14-
{ error: 'Failed to load API index', details: error },
15+
{ error: 'Failed to load API index', details },
1516
500
1617
)
1718
}

tsconfig.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,7 @@
77
"module": "ESNext",
88
"moduleResolution": "bundler",
99
"importHelpers": true,
10-
"verbatimModuleSyntax": false,
11-
"paths": {
12-
"outputDir/*": [
13-
"/Users/ausulliv/repos/patternfly-doc-core/dist/*"
14-
]
15-
}
10+
"verbatimModuleSyntax": false
1611
},
1712
"include": [
1813
".astro/types.d.ts",

0 commit comments

Comments
 (0)