Skip to content

Commit

Permalink
first pass at sneaky hack to fix local mode auto-reload on RFD change
Browse files Browse the repository at this point in the history
  • Loading branch information
david-crespo committed Oct 18, 2024
1 parent 3a0dc87 commit 395c1a1
Show file tree
Hide file tree
Showing 6 changed files with 528 additions and 9 deletions.
Empty file added app/.watch-trigger
Empty file.
15 changes: 11 additions & 4 deletions app/services/rfd.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,25 @@ import type { GetResponseTypeFromEndpointMethod } from '@octokit/types'
import { asciidoctor, type AdocTypes } from '@oxide/react-asciidoc'
import { Octokit } from 'octokit'

// hack to get automatic reload on file writes in local mode
import watchTrigger from '~/.watch-trigger?raw'
import { generateAuthors, type Author } from '~/components/rfd/RfdPreview'
import { isTruthy } from '~/utils/isTruthy'
import { parseRfdNum } from '~/utils/parseRfdNum'
import { can, Permission } from '~/utils/permission'
import { can, type Permission } from '~/utils/permission'
import type { GroupResponse, RfdListResponseItem, RfdResponse } from '~/utils/rfdApi'

import type { Group, User } from './authn.server'
import { apiRequest } from './rfdApi.server'

const localRepo = process.env.LOCAL_RFD_REPO
export const isLocalMode = process.env.NODE_ENV === 'development' && localRepo

// sneaky weird thing
if (isLocalMode) {
console.log(watchTrigger)
}

export type RfdItem = {
number: number
number_string: string
Expand Down Expand Up @@ -52,9 +62,6 @@ export type RfdListItem = {
visibility: 'private' | 'public'
}

const localRepo = process.env.LOCAL_RFD_REPO
export const isLocalMode = process.env.NODE_ENV === 'development' && localRepo

async function canUser(user: User, permission: Permission): Promise<boolean> {
const groups = (await fetchGroups(user)).filter((group) =>
user.groups.includes(group.name),
Expand Down
Loading

0 comments on commit 395c1a1

Please sign in to comment.