Skip to content

Commit

Permalink
feat: rfc-index tests and .npmrc save exact
Browse files Browse the repository at this point in the history
  • Loading branch information
holloway committed Jan 23, 2025
1 parent bd28921 commit e244ced
Show file tree
Hide file tree
Showing 8 changed files with 452 additions and 49 deletions.
1 change: 1 addition & 0 deletions client/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
save-exact=true
4 changes: 4 additions & 0 deletions client/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ export default defineNuxtConfig({
},
routeRules: {
// https://nuxt.com/docs/guide/concepts/rendering#hybrid-rendering
'/': {
swr: oneDayInSeconds,
prerender: true
},
'/rfc-index.txt': {
swr: oneDayInSeconds,
prerender: true
Expand Down
82 changes: 60 additions & 22 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
"@nuxtjs/color-mode": "^3.4.4",
"@nuxtjs/tailwindcss": "^6.12.1",
"@pinia/nuxt": "^0.5.4",
"@playwright/test": "^1.40.0",
"@tailwindcss/forms": "^0.5.8",
"apigen-ts": "^1.1.0",
"feed": "^4.2.2",
Expand All @@ -42,7 +41,6 @@
"nuxt": "^3.13.1",
"nuxt-headlessui": "^1.2.0",
"pinia": "^2.2.2",
"playwright": "^1.47.1",
"simple-git": "^3.27.0",
"vue": "^3.5.4"
},
Expand All @@ -51,11 +49,16 @@
"@histoire/plugin-vue": "^0.17.17",
"@nuxt/eslint": "^0.5.3",
"@nuxt/test-utils": "^3.15.1",
"@playwright/test": "^1.49.1",
"@types/deep-diff": "^1.0.5",
"@types/lodash-es": "^4.17.12",
"@types/luxon": "^3.4.2",
"@vue/test-utils": "^2.4.6",
"deep-diff": "^1.0.2",
"fast-xml-parser": "^4.5.1",
"happy-dom": "^15.11.7",
"lost-pixel": "^3.22.0",
"playwright": "^1.49.1",
"playwright-core": "^1.49.1",
"vitest": "^2.1.8",
"vue-tsc": "^2.0.29"
Expand Down
6 changes: 3 additions & 3 deletions client/server/routes/rfc-index.xml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ export default defineEventHandler(async (event) => {
const redApi = new ApiClient({ baseUrl: PRIVATE_API_URL })

// this is a promise but we don't care about waiting for the result
void renderRfcIndexDotXml(
void renderRfcIndexDotXml({
push,
close,
abortController,
redApi,
DELAY_BETWEEN_REQUESTS_MS
)
delayBetweenRequestsMs: DELAY_BETWEEN_REQUESTS_MS
})
},
// cleanup when the connection is terminated
cancel() {
Expand Down
7 changes: 5 additions & 2 deletions client/utilities/rfc-index-txt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,11 @@ export async function renderRfcIndexDotTxt({
.join(' \n\n')
)

// wait between requests so as not to overwhelm the server
await setTimeoutPromise(delayBetweenRequestsMs)
if (delayBetweenRequestsMs > 0) {
// wait between requests so as not to overwhelm the server
await setTimeoutPromise(delayBetweenRequestsMs)
}

if (
// checking again after the await
abortController.signal.aborted
Expand Down
50 changes: 30 additions & 20 deletions client/utilities/rfc-index-xml.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
import { delay, padStart } from 'lodash-es'
import type { ApiClient, RfcMetadata } from '~/generated/red-client'
import { padStart } from 'lodash-es'
import type { ApiClient } from '~/generated/red-client'

type DocListArg = Parameters<ApiClient['red']['docList']>[0]

export async function renderRfcIndexDotXml(
push: (data: string) => void,
close: () => void,
abortController: AbortController,
redApi: ApiClient,
type Props = {
push: (data: string) => void
close: () => void
abortController: AbortController
redApi: ApiClient
delayBetweenRequestsMs: number
) {
}

export async function renderRfcIndexDotXml({
push,
close,
abortController,
redApi,
delayBetweenRequestsMs
}: Props) {
push('<?xml version="1.0" encoding="UTF-8"?>\n')
push(
'<rfc-index xmlns="https://www.rfc-editor.org/rfc-index" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="https://www.rfc-editor.org/rfc-index https://www.rfc-editor.org/rfc-index.xsd">\n'
Expand All @@ -32,46 +40,46 @@ export async function renderRfcIndexDotXml(

response.results.forEach((rfcMetadata) => {
push(
`<bcp-entry><doc-id>BCP${padNumber(rfcMetadata.number, longestRfcNumberLength)}</doc-id>`
`<rfc-entry><doc-id>BCP${padNumber(rfcMetadata.number, longestRfcNumberLength)}</doc-id>`
)

// if (rfcMetadata.formats && rfc.formats.length > 0) {
// rfc.formats.map((format) => format.type).join(', ')}`
// }

//if (rfcMetadata.obsoletes && rfcMetadata.obsoletes.length > 0) {
// if (rfcMetadata.obsoletes && rfcMetadata.obsoletes.length > 0) {
// obsups += ` (Obsoletes ${rfcMetadata.obsoletes
// .map((item) => formatRfcNumber(item.number, layout))
// .join(', ')})`
//}
// }

//if (rfcMetadata.obsoleted_by && rfcMetadata.obsoleted_by.length > 0) {
// if (rfcMetadata.obsoleted_by && rfcMetadata.obsoleted_by.length > 0) {
// obsups += ` (Obsoleted by ${rfc.obsoleted_by
// .map((item) => formatRfcNumber(item.number, layout))
// .join(', ')})`
// }
//if (rfcMetadata.updates && rfcMetadata.updates.length > 0) {
// if (rfcMetadata.updates && rfcMetadata.updates.length > 0) {
// obsups += ` (Updates ${rfc.updates
// .map((item) => formatRfcNumber(item.number, layout))
// .join(', ')})`
//}
//if (rfcMetadata.updated_by && rfcMetadata.updated_by.length > 0) {
// }
// if (rfcMetadata.updated_by && rfcMetadata.updated_by.length > 0) {
// obsups += ` (Updated by ${rfc.updated_by
// .map((item) => formatRfcNumber(item.number, layout))
// .join(', ')})`
//}
// }

//if(rfcMetadata.is_also && rfcMetadata.is_also.length > 0) {
// if(rfcMetadata.is_also && rfcMetadata.is_also.length > 0) {
//
// }

// if (rfcMetadata.see_also && rfcMetadata.see_also.length > 0) {
// rfc.see_also.map((item) => formatRfcNumber(item.number, layout))
// rfc.see_also.map((item) => formatRfcNumber(item.number, layout))
// }

// push(JSON.stringify(rfcMetadata))

push('</bcp-entry>\n')
push('</rfc-entry>\n')
})

offset += response.results.length
Expand All @@ -97,7 +105,9 @@ export async function renderRfcIndexDotXml(
return
}

await setTimeoutPromise(delayBetweenRequestsMs)
if (delayBetweenRequestsMs > 0) {
await setTimeoutPromise(delayBetweenRequestsMs)
}
}
}

Expand Down
Loading

0 comments on commit e244ced

Please sign in to comment.