kopia lustrzana https://github.com/cloudflare/wildebeest
Merge pull request #370 from cloudflare/add-prelint-script
add type-check frontend scriptpull/377/head
commit
2bc881e9ca
|
@ -53,6 +53,9 @@ jobs:
|
||||||
- name: Check frontend linting
|
- name: Check frontend linting
|
||||||
run: yarn lint:frontend
|
run: yarn lint:frontend
|
||||||
|
|
||||||
|
- name: Check frontend types
|
||||||
|
run: yarn --cwd types-check
|
||||||
|
|
||||||
test-ui:
|
test-ui:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
|
|
@ -270,7 +270,8 @@ function getContentRewriter() {
|
||||||
contentRewriter.on('*', {
|
contentRewriter.on('*', {
|
||||||
element(el) {
|
element(el) {
|
||||||
if (!['p', 'span', 'br', 'a'].includes(el.tagName)) {
|
if (!['p', 'span', 'br', 'a'].includes(el.tagName)) {
|
||||||
el.tagName = 'p'
|
const element = el as { tagName: string }
|
||||||
|
element.tagName = 'p'
|
||||||
}
|
}
|
||||||
|
|
||||||
if (el.hasAttribute('class')) {
|
if (el.hasAttribute('class')) {
|
||||||
|
|
|
@ -4,7 +4,7 @@ import type { Env } from 'wildebeest/backend/src/types/env'
|
||||||
|
|
||||||
function sqliteToPsql(query: string): string {
|
function sqliteToPsql(query: string): string {
|
||||||
let c = 0
|
let c = 0
|
||||||
return query.replaceAll(/\?([0-9])?/g, (match: string, p1: string) => {
|
return query.replace(/\?([0-9])?/g, (match: string, p1: string) => {
|
||||||
c += 1
|
c += 1
|
||||||
return `$${p1 || c}`
|
return `$${p1 || c}`
|
||||||
})
|
})
|
||||||
|
|
|
@ -281,11 +281,12 @@ export function parseRequest(request: Request, options?: Options): ParsedSignatu
|
||||||
|
|
||||||
if (h === 'request-line') {
|
if (h === 'request-line') {
|
||||||
if (!options.strict) {
|
if (!options.strict) {
|
||||||
|
const cf = (request as { cf?: IncomingRequestCfProperties }).cf
|
||||||
/*
|
/*
|
||||||
* We allow headers from the older spec drafts if strict parsing isn't
|
* We allow headers from the older spec drafts if strict parsing isn't
|
||||||
* specified in options.
|
* specified in options.
|
||||||
*/
|
*/
|
||||||
parsed.signingString += request.method + ' ' + request.url + ' ' + request.cf?.httpProtocol
|
parsed.signingString += request.method + ' ' + request.url + ' ' + cf?.httpProtocol
|
||||||
} else {
|
} else {
|
||||||
/* Strict parsing doesn't allow older draft headers. */
|
/* Strict parsing doesn't allow older draft headers. */
|
||||||
throw new StrictParsingError('request-line is not a valid header ' + 'with strict parsing enabled.')
|
throw new StrictParsingError('request-line is not a valid header ' + 'with strict parsing enabled.')
|
||||||
|
|
|
@ -19,7 +19,8 @@ export function initSentry(request: Request, env: Env, context: any) {
|
||||||
request,
|
request,
|
||||||
transportOptions: { headers },
|
transportOptions: { headers },
|
||||||
})
|
})
|
||||||
const colo = request.cf && request.cf.colo ? request.cf.colo : 'UNKNOWN'
|
const cf = (request as { cf?: IncomingRequestCfProperties }).cf
|
||||||
|
const colo = cf?.colo ? cf.colo : 'UNKNOWN'
|
||||||
sentry.setTag('colo', colo)
|
sentry.setTag('colo', colo)
|
||||||
|
|
||||||
// cf-connecting-ip should always be present, but if not we can fallback to XFF.
|
// cf-connecting-ip should always be present, but if not we can fallback to XFF.
|
||||||
|
|
|
@ -26,12 +26,12 @@ export function arrayBufferToBase64(buffer: ArrayBuffer): string {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function b64ToUrlEncoded(str: string): string {
|
export function b64ToUrlEncoded(str: string): string {
|
||||||
return str.replaceAll(/\+/g, '-').replaceAll(/\//g, '_').replace(/=+/g, '')
|
return str.replace(/\+/g, '-').replace(/\//g, '_').replace(/=+/g, '')
|
||||||
}
|
}
|
||||||
|
|
||||||
export function urlEncodedToB64(str: string): string {
|
export function urlEncodedToB64(str: string): string {
|
||||||
const padding = '='.repeat((4 - (str.length % 4)) % 4)
|
const padding = '='.repeat((4 - (str.length % 4)) % 4)
|
||||||
return str.replaceAll(/-/g, '+').replaceAll(/_/g, '/') + padding
|
return str.replace(/-/g, '+').replace(/_/g, '/') + padding
|
||||||
}
|
}
|
||||||
|
|
||||||
export function stringToU8Array(str: string): Uint8Array {
|
export function stringToU8Array(str: string): Uint8Array {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { cloudflarePagesAdaptor } from '@builder.io/qwik-city/adaptors/cloudflare-pages/vite'
|
import { cloudflarePagesAdapter } from '@builder.io/qwik-city/adapters/cloudflare-pages/vite'
|
||||||
import { extendConfig } from '@builder.io/qwik-city/vite'
|
import { extendConfig } from '@builder.io/qwik-city/vite'
|
||||||
import baseConfig from '../../vite.config'
|
import baseConfig from '../../vite.config'
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ export default extendConfig(baseConfig, () => {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
cloudflarePagesAdaptor({
|
cloudflarePagesAdapter({
|
||||||
// Do not SSG as the D1 database is not available at build time, I think.
|
// Do not SSG as the D1 database is not available at build time, I think.
|
||||||
// staticGenerate: true,
|
// staticGenerate: true,
|
||||||
}),
|
}),
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
},
|
},
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"pretypes-check": "yarn build",
|
||||||
|
"types-check": "tsc",
|
||||||
"lint": "eslint src mock-db adaptors",
|
"lint": "eslint src mock-db adaptors",
|
||||||
"build": "vite build && vite build -c adaptors/cloudflare-pages/vite.config.ts",
|
"build": "vite build && vite build -c adaptors/cloudflare-pages/vite.config.ts",
|
||||||
"dev": "vite --mode ssr",
|
"dev": "vite --mode ssr",
|
||||||
|
|
|
@ -59,12 +59,12 @@ export async function handleRequest(
|
||||||
|
|
||||||
if (formData.has('display_name')) {
|
if (formData.has('display_name')) {
|
||||||
const value = formData.get('display_name')!
|
const value = formData.get('display_name')!
|
||||||
await updateActorProperty(db, connectedActor.id, 'name', value)
|
await updateActorProperty(db, connectedActor.id, 'name', value as string)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (formData.has('note')) {
|
if (formData.has('note')) {
|
||||||
const value = formData.get('note')!
|
const value = formData.get('note')!
|
||||||
await updateActorProperty(db, connectedActor.id, 'summary', value)
|
await updateActorProperty(db, connectedActor.id, 'summary', value as string)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (formData.has('avatar')) {
|
if (formData.has('avatar')) {
|
||||||
|
|
|
@ -42,11 +42,11 @@ export async function handlePostRequest(
|
||||||
const properties: Record<string, string> = {}
|
const properties: Record<string, string> = {}
|
||||||
|
|
||||||
if (formData.has('username')) {
|
if (formData.has('username')) {
|
||||||
properties.preferredUsername = formData.get('username') || ''
|
properties.preferredUsername = (formData.get('username') as string) || ''
|
||||||
}
|
}
|
||||||
|
|
||||||
if (formData.has('name')) {
|
if (formData.has('name')) {
|
||||||
properties.name = formData.get('name') || ''
|
properties.name = (formData.get('name') as string) || ''
|
||||||
}
|
}
|
||||||
|
|
||||||
await createPerson(domain, db, userKEK, email, properties)
|
await createPerson(domain, db, userKEK, email, properties)
|
||||||
|
|
|
@ -50,7 +50,7 @@
|
||||||
"http-message-signatures": "^0.1.2",
|
"http-message-signatures": "^0.1.2",
|
||||||
"toucan-js": "^3.1.0"
|
"toucan-js": "^3.1.0"
|
||||||
},
|
},
|
||||||
"simple-git-hooks": {
|
"simple-git-hooks": {
|
||||||
"pre-commit": "yarn lint"
|
"pre-commit": "yarn lint"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue