rvlib-shipkit 2.18.0 → 2.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/package.json +1 -1
- package/src/asks/asks-queue.ts +63 -10
- package/src/cli/cmd_Asks.ts +3 -1
- package/src/cli/cmd_GlobalProcesses.ts +34 -11
- package/src/cli/cmd_Home.ts +38 -2
- package/src/cli/cmd_Secret.ts +4 -30
- package/src/cli/cmd_Social.ts +40 -1
- package/src/cli/cmd_Trailer.ts +15 -3
- package/src/cli/registry.ts +2 -1
- package/src/collections/actions.ts +29 -1
- package/src/collections/collection-types.ts +2 -0
- package/src/collections/providers.ts +1 -1
- package/src/home/home-paths.ts +5 -1
- package/src/home/home-start.ts +12 -12
- package/src/home/run-daemon.ts +11 -2
- package/src/home/run-pm.ts +9 -1
- package/src/home/supervise.ts +3 -1
- package/src/identities/identities.ts +22 -5
- package/src/review/http.ts +7 -2
- package/src/review/store.ts +81 -19
- package/src/secrets/manager.ts +59 -0
- package/src/secrets/name.ts +2 -0
- package/src/serve/hub-app/col-card.tsx +10 -0
- package/src/serve/hub-app/cols-svc.ts +37 -6
- package/src/serve/hub-app/hub.css +1 -0
- package/src/serve/hub-app/social/identity-pictures.ts +74 -0
- package/src/serve/hub-app/social/social-page.tsx +77 -37
- package/src/serve/hub-app/social.css +8 -3
- package/src/serve/serve-hub.ts +12 -2
- package/src/social/discord-layout.ts +239 -0
- package/src/social/md.ts +14 -6
- package/src/social/publish/discord.ts +3 -2
- package/src/social/routes.ts +3 -3
- package/src/stores/routes.ts +2 -2
- package/src/suite/judge-suites.ts +1 -1
- package/src/suite/suite-cli.ts +5 -5
- package/src/trailer/build.ts +75 -50
- package/src/trailer/draft.ts +28 -0
- package/src/trailer/footage.ts +4 -2
- package/src/trailer/grammar.ts +11 -9
- package/src/trailer/graph.ts +32 -9
- package/src/trailer/profile.ts +35 -0
- package/src/trailer/prune.ts +15 -10
- package/src/trailer/stitch.ts +22 -10
- package/src/trailer/titles.ts +47 -2
|
@@ -13,6 +13,7 @@ import { PANEL, PhoneTop } from '../review/review-page.tsx'
|
|
|
13
13
|
import { brandVar, CopyIcon, CopyRow, ErrorLine, Go, KeptFold, Lightbox, Logo, Md, MdInline, Toast } from './kit.tsx'
|
|
14
14
|
import { PostCard } from './post-card.tsx'
|
|
15
15
|
import { Problems } from './problems.tsx'
|
|
16
|
+
import { bannerGroups, factsOf, hasNote, otherRating, pictureOf, ratingOf, rowPictures, usedBy } from './identity-pictures.ts'
|
|
16
17
|
import { AUTOMATION, fileName, LEGAL, linksText, ME, type DeskAccount, type DeskIdentity, type Picture, type Place, type Row } from './social-model.ts'
|
|
17
18
|
import type { SocialSt } from './social-st.ts'
|
|
18
19
|
|
|
@@ -119,7 +120,7 @@ const Totals = observer(({ so, i }: { so: SocialSt; i: DeskIdentity }) => {
|
|
|
119
120
|
|
|
120
121
|
const avatarOf = (i: DeskIdentity): Picture | null => {
|
|
121
122
|
const file = i.rows.find((r) => r.field === 'avatar')?.files[0]
|
|
122
|
-
return file ? (i
|
|
123
|
+
return file ? pictureOf(i, file) : null
|
|
123
124
|
}
|
|
124
125
|
const firstColour = (i: DeskIdentity): string | null => i.brand.find((r) => /^#[0-9a-f]{6}$/i.test(r.value))?.value ?? null
|
|
125
126
|
|
|
@@ -301,39 +302,47 @@ export const IdentityPage = observer(({ so, i }: { so: SocialSt; i: DeskIdentity
|
|
|
301
302
|
)
|
|
302
303
|
})
|
|
303
304
|
|
|
304
|
-
/** the right of an identity:
|
|
305
|
-
*
|
|
305
|
+
/** the right of an identity: every picture of its folders, the avatars, then the banners by venue, then its other
|
|
306
|
+
* pictures; each tile labelled by its name (rating, variant), with its size, the accounts whose row names it,
|
|
307
|
+
* « copy » (the image on the clipboard), « ⬇ », the Finder and its other formats */
|
|
306
308
|
export const IdentityMedia = observer(({ so, i }: { so: SocialSt; i: DeskIdentity }) => {
|
|
307
|
-
const
|
|
308
|
-
const
|
|
309
|
-
const
|
|
310
|
-
const
|
|
311
|
-
|
|
309
|
+
const kind = (f: Picture): string => factsOf(f.file, i.id).kind
|
|
310
|
+
const nsfw = (f: Picture): number => (factsOf(f.file, i.id).rating === 'nsfw' ? 1 : 0)
|
|
311
|
+
const avatars = i.pictures.filter((f) => kind(f) === 'avatar').sort((a, b) => nsfw(a) - nsfw(b) || a.file.localeCompare(b.file))
|
|
312
|
+
const banners = bannerGroups(i)
|
|
313
|
+
const rest = i.pictures.filter((f) => kind(f) === 'other')
|
|
314
|
+
const nBanners = banners.reduce((n, g) => n + g.pictures.length, 0)
|
|
315
|
+
if (i.pictures.length === 0) return <div className="rv-empty">no picture: a pictures/ folder in {i.id}'s folder</div>
|
|
312
316
|
return (
|
|
313
317
|
<div className="so-colin">
|
|
314
318
|
{avatars.length > 0 ? (
|
|
315
319
|
<KeptFold so={so} card="identity/avatars" title="Avatars" right={<span className="rv-dim rv-small">{avatars.length}</span>}>
|
|
316
320
|
<div className="so-tiles">
|
|
317
321
|
{avatars.map((f) => (
|
|
318
|
-
<PictureTile key={f.file} so={so} i={i} f={f} width={
|
|
322
|
+
<PictureTile key={f.file} so={so} i={i} f={f} width={180} label={factsOf(f.file, i.id).label} used={usedBy(i, f)} />
|
|
319
323
|
))}
|
|
320
324
|
</div>
|
|
321
325
|
</KeptFold>
|
|
322
326
|
) : null}
|
|
323
|
-
{
|
|
324
|
-
<KeptFold so={so} card="identity/banners" title="Banners" right={<span className="rv-dim rv-small">{
|
|
325
|
-
|
|
326
|
-
{
|
|
327
|
-
<
|
|
328
|
-
|
|
329
|
-
|
|
327
|
+
{nBanners > 0 ? (
|
|
328
|
+
<KeptFold so={so} card="identity/banners" title="Banners" right={<span className="rv-dim rv-small">{nBanners}</span>}>
|
|
329
|
+
{banners.map((g) => (
|
|
330
|
+
<div key={g.venue} className="so-picgroup">
|
|
331
|
+
<b className="rv-small so-picgrouptitle">{g.title}</b>
|
|
332
|
+
<div className="so-picgrid">
|
|
333
|
+
{g.pictures.map((f) => (
|
|
334
|
+
<PictureTile key={f.file} so={so} i={i} f={f} label={factsOf(f.file, i.id).label} used={usedBy(i, f)} />
|
|
335
|
+
))}
|
|
336
|
+
</div>
|
|
337
|
+
</div>
|
|
338
|
+
))}
|
|
330
339
|
</KeptFold>
|
|
331
340
|
) : null}
|
|
332
341
|
{rest.length > 0 ? (
|
|
333
342
|
<KeptFold so={so} card="identity/files" title="The brand's pictures" right={<span className="rv-dim rv-small">{rest.length}</span>}>
|
|
334
343
|
<div className="so-tiles">
|
|
335
344
|
{rest.map((f) => (
|
|
336
|
-
<PictureTile key={f.file} so={so} i={i} f={f} width={200} />
|
|
345
|
+
<PictureTile key={f.file} so={so} i={i} f={f} width={200} used={usedBy(i, f)} />
|
|
337
346
|
))}
|
|
338
347
|
</div>
|
|
339
348
|
</KeptFold>
|
|
@@ -348,16 +357,18 @@ const YOUTUBE_AREAS = [
|
|
|
348
357
|
{ w: 1546, label: 'phone', cls: ' phone' },
|
|
349
358
|
]
|
|
350
359
|
|
|
351
|
-
/** one picture: the image (a clip plays muted), its name and size, « copy », « ⬇
|
|
352
|
-
* one, a phone none)
|
|
353
|
-
|
|
360
|
+
/** one picture: the image (a clip plays muted), its name or `label` and size, « copy », « ⬇ », 📂 the Finder (the
|
|
361
|
+
* desktop has one, a phone none) and a download per other format; under it the accounts whose row names it (`used`);
|
|
362
|
+
* `width` a tile, else the width it is given */
|
|
363
|
+
const PictureTile = observer(({ so, i, f, width, label, used }: { so: SocialSt; i: DeskIdentity; f: Picture; width?: number; label?: string; used?: readonly string[] }) => {
|
|
354
364
|
const { url, clip } = so.picture(i, f)
|
|
355
365
|
const size = f.w !== null ? ` · ${f.w}×${f.h}` : ''
|
|
356
366
|
const key = `${i.id}/pic/${f.file}`
|
|
367
|
+
const ext = (file: string): string => file.replace(/^.*\./, '')
|
|
357
368
|
return (
|
|
358
369
|
<div className="so-card so-pic" style={width ? { width } : undefined}>
|
|
359
370
|
<div className="so-picframe">
|
|
360
|
-
{clip ? <video src={url} muted loop autoPlay playsInline /> : <img src={url} alt="" />}
|
|
371
|
+
{clip ? <video src={url} muted loop autoPlay playsInline /> : <img src={url} alt="" loading="lazy" decoding="async" />}
|
|
361
372
|
{f.file.endsWith('-youtube.jpg')
|
|
362
373
|
? YOUTUBE_AREAS.map((a) => (
|
|
363
374
|
<div key={a.label} className={`so-ytarea${a.cls}`} style={{ left: `${((2560 - a.w) / 2 / 2560) * 100}%`, width: `${(a.w / 2560) * 100}%`, top: `${((1440 - 423) / 2 / 1440) * 100}%`, height: `${(423 / 1440) * 100}%` }}>
|
|
@@ -367,9 +378,9 @@ const PictureTile = observer(({ so, i, f, width, tile }: { so: SocialSt; i: Desk
|
|
|
367
378
|
: null}
|
|
368
379
|
</div>
|
|
369
380
|
<div className="so-picrow">
|
|
370
|
-
<b className="rv-small so-ellip so-grow" title={`${
|
|
371
|
-
{fileName(f.file).replace(/^(avatar|banner)-(caid-)?/, '').replace(/\.\w+$/, '').replace(/-round$/, ' round')}
|
|
372
|
-
{
|
|
381
|
+
<b className="rv-small so-ellip so-grow" title={`${[f.file, ...f.also].map(fileName).join(', ')}${size}`}>
|
|
382
|
+
{label ?? fileName(f.file).replace(/^(avatar|banner)-(caid-)?/, '').replace(/\.\w+$/, '').replace(/-round$/, ' round')}
|
|
383
|
+
{label == null && !width ? <span className="rv-dim so-light">{size}</span> : null}
|
|
373
384
|
</b>
|
|
374
385
|
{!clip ? (
|
|
375
386
|
<button className="so-icon" onClick={() => void so.copyImage(url, key)} title="copy the image, to paste in the account's page">
|
|
@@ -385,6 +396,17 @@ const PictureTile = observer(({ so, i, f, width, tile }: { so: SocialSt; i: Desk
|
|
|
385
396
|
</button>
|
|
386
397
|
) : null}
|
|
387
398
|
</div>
|
|
399
|
+
{f.also.length > 0 || (label != null && size !== '') ? (
|
|
400
|
+
<div className="so-picrow so-picmore">
|
|
401
|
+
{label != null && f.w !== null ? <span className="rv-dim rv-small">{f.w}×{f.h}</span> : null}
|
|
402
|
+
{f.also.map((x) => (
|
|
403
|
+
<a key={x} className="so-fmt" href={so.pictureUrl(i.id, x)} download={fileName(x)} title={`download ${fileName(x)}`}>
|
|
404
|
+
⬇ {ext(x)}
|
|
405
|
+
</a>
|
|
406
|
+
))}
|
|
407
|
+
</div>
|
|
408
|
+
) : null}
|
|
409
|
+
{used?.length ? <span className="rv-dim rv-small" title="the accounts whose row names it">→ {used.join(', ')}</span> : null}
|
|
388
410
|
</div>
|
|
389
411
|
)
|
|
390
412
|
})
|
|
@@ -620,25 +642,43 @@ const StepText = observer(({ so, a, index, text }: { so: SocialSt; a: DeskAccoun
|
|
|
620
642
|
)
|
|
621
643
|
})
|
|
622
644
|
|
|
623
|
-
/**
|
|
645
|
+
/** a tile's width on an account's page: a banner wide, an avatar small */
|
|
646
|
+
const tileWidth = (f: Picture): number => (f.w != null && f.h != null && f.w > f.h * 1.6 ? 300 : 180)
|
|
647
|
+
|
|
648
|
+
/** the account: « Upload here », the pictures its rows name for its rating (the identity's rows with its own over
|
|
649
|
+
* them), then its text rows, then its notes */
|
|
624
650
|
export const AccountProfile = observer(({ so, a }: { so: SocialSt; a: DeskAccount }) => {
|
|
625
651
|
const i = so.identityOf(a.identity)
|
|
652
|
+
const rating = ratingOf(a)
|
|
653
|
+
const pics = i == null ? [] : a.rows.filter((r) => r.files.length > 0)
|
|
654
|
+
const mine = pics.filter((r) => !otherRating(r.field, rating))
|
|
655
|
+
const others = pics.filter((r) => otherRating(r.field, rating))
|
|
626
656
|
return (
|
|
627
657
|
<div className="so-colin">
|
|
628
|
-
|
|
629
|
-
{
|
|
630
|
-
r
|
|
631
|
-
<
|
|
632
|
-
<
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
658
|
+
{i != null && mine.length > 0 ? (
|
|
659
|
+
<KeptFold so={so} card="upload" title="Upload here" flush right={rating === '' ? null : <span className={`so-badge solid ${rating === 'sfw' ? 't-ok' : 't-warn'}`} title="its rating row: the pictures it shows">{rating}</span>}>
|
|
660
|
+
{mine.map((r) => (
|
|
661
|
+
<div key={r.field} className="so-row">
|
|
662
|
+
<span className="so-rowfield">{r.field}</span>
|
|
663
|
+
<div className="so-uppics">
|
|
664
|
+
<div className="so-tiles">
|
|
665
|
+
{rowPictures(i, r.files).map((f) => (
|
|
666
|
+
<PictureTile key={f.file} so={so} i={i} f={f} width={tileWidth(f)} label={factsOf(f.file, i.id).label} />
|
|
667
|
+
))}
|
|
668
|
+
</div>
|
|
669
|
+
{hasNote(r) ? <span className="rv-dim rv-small">{r.value}</span> : null}
|
|
636
670
|
</div>
|
|
637
|
-
</
|
|
638
|
-
)
|
|
671
|
+
</div>
|
|
672
|
+
))}
|
|
673
|
+
{others.length > 0 ? <div className="so-row rv-dim rv-small">not for this venue, its rating is {rating}: {others.map((r) => r.field).join(', ')}</div> : null}
|
|
674
|
+
</KeptFold>
|
|
675
|
+
) : null}
|
|
676
|
+
<KeptFold so={so} card="profile" title="The profile" flush>
|
|
677
|
+
{a.rows
|
|
678
|
+
.filter((r) => i == null || r.files.length === 0)
|
|
679
|
+
.map((r) => (
|
|
639
680
|
<CopyRow key={r.field} so={so} k={`${a.identity}/${a.id}/row/${r.field}`} field={r.field} value={r.value} />
|
|
640
|
-
)
|
|
641
|
-
)}
|
|
681
|
+
))}
|
|
642
682
|
</KeptFold>
|
|
643
683
|
{a.notes ? (
|
|
644
684
|
<KeptFold so={so} card="notes" title="Notes" open={false} summary={a.notes}>
|
|
@@ -70,9 +70,7 @@ a.so-icon:visited{color:var(--dim)}
|
|
|
70
70
|
.so-rowfield{flex:none;width:88px;font-size:11.5px;font-weight:700;color:var(--dim);padding-top:var(--s0)}
|
|
71
71
|
.so-rowname{flex:none;width:96px;align-self:center}
|
|
72
72
|
.so-rowvalue{flex:1;min-width:0;overflow-wrap:anywhere}
|
|
73
|
-
.so-
|
|
74
|
-
.so-rowpics.n1{grid-template-columns:minmax(0,200px)}
|
|
75
|
-
.so-rowpics.n2{grid-template-columns:repeat(2,minmax(0,150px))}
|
|
73
|
+
.so-uppics{flex:1;min-width:0;display:flex;flex-direction:column;gap:var(--s1)}
|
|
76
74
|
|
|
77
75
|
/* the list on the left */
|
|
78
76
|
.so-listcol{height:100%;display:flex;flex-direction:column;min-height:0;background:var(--panel)}
|
|
@@ -273,6 +271,13 @@ a.so-go:visited{color:var(--accent)}
|
|
|
273
271
|
.so-picframe{position:relative}
|
|
274
272
|
.so-picframe img,.so-picframe video{display:block;width:100%;border-radius:4px;background:var(--panel2)}
|
|
275
273
|
.so-picrow{display:flex;align-items:center;gap:var(--s1);min-width:0}
|
|
274
|
+
.so-picmore{flex-wrap:wrap}
|
|
275
|
+
.so-fmt{font-size:11px;font-weight:700;padding:0 var(--s1);border:1px solid var(--line);border-radius:3px;line-height:16px;text-decoration:none;color:var(--dim)}
|
|
276
|
+
.so-fmt:hover{color:var(--ink);border-color:var(--dim)}
|
|
277
|
+
.so-picgroup{display:flex;flex-direction:column;gap:var(--s1)}
|
|
278
|
+
.so-picgroup + .so-picgroup{margin-top:var(--s3)}
|
|
279
|
+
.so-picgrouptitle{color:var(--dim)}
|
|
280
|
+
.so-picgrid{display:grid;grid-template-columns:repeat(auto-fill,minmax(260px,1fr));gap:var(--s2)}
|
|
276
281
|
.so-ytarea{position:absolute;border:2px dashed var(--tag);border-radius:4px;pointer-events:none}
|
|
277
282
|
.so-ytarea.phone{border-color:var(--review)}
|
|
278
283
|
.so-ytarea span{position:absolute;top:-15px;left:var(--s0);font-size:10px;font-weight:700;color:var(--tag)}
|
package/src/serve/serve-hub.ts
CHANGED
|
@@ -11,7 +11,8 @@ import { pageOf, searchWiki } from 'rvlib-shipkit/src/wiki/graph-pages.ts'
|
|
|
11
11
|
import { graphRoutes } from 'rvlib-shipkit/src/wiki/serve-graph.ts'
|
|
12
12
|
import type { StudioRoutes } from '../assets/server/studio-server.ts'
|
|
13
13
|
import { comfyBoxUp, type ComfyBox, type ComfyPanelUp } from '../comfy/comfy-panel.ts'
|
|
14
|
-
import { appendAskRemark, appendAssetNote, askDone, askProof } from '../collections/actions.ts'
|
|
14
|
+
import { appendAskRemark, appendAssetNote, askDone, askProof, askSecret } from '../collections/actions.ts'
|
|
15
|
+
import { managerStore, type SecretStore } from '../secrets/manager.ts'
|
|
15
16
|
import { brokenRow, projectResources, type Collection, type Instance, type NeedItem, type Resource } from '../collections/collection-types.ts'
|
|
16
17
|
import type { CheckEvent } from '../core/run-check.ts'
|
|
17
18
|
import { configDirty, readGateBlock, writeGateBlock, type GateEdit } from '../core/when-block.ts'
|
|
@@ -110,6 +111,9 @@ export type HubDeps = {
|
|
|
110
111
|
collections: () => Collection[]
|
|
111
112
|
/** asks dir (repo-root-relative) for the act-in-place ask verbs */
|
|
112
113
|
asksDir: string
|
|
114
|
+
/** where a value pasted under a credential ask goes; absent = the repo's
|
|
115
|
+
* `credsCommand`, as `sk secret set` runs it */
|
|
116
|
+
storeSecret?: SecretStore
|
|
113
117
|
/** the comfy panel; null when the repo declares no workflow module, which
|
|
114
118
|
* is also when the comfy section is absent from the page */
|
|
115
119
|
comfy: ComfyDeps | null
|
|
@@ -276,8 +280,14 @@ export function hubHandler(d: HubDeps, o: { base?: string; projects?: Gutter } =
|
|
|
276
280
|
if (path.startsWith('/api/act/') && req.method === 'POST') {
|
|
277
281
|
// act-in-place verbs — every mutation hits a git-tracked truth
|
|
278
282
|
// file; errors surface as 400 text the card shows verbatim
|
|
283
|
+
// a parse error quotes the body, which can carry a pasted secret
|
|
284
|
+
const b = (await req.json().catch(() => null)) as Record<string, string> | null
|
|
285
|
+
if (b == null || typeof b !== 'object') return new Response('the body is not a json object', { status: 400 })
|
|
279
286
|
try {
|
|
280
|
-
|
|
287
|
+
if (path === '/api/act/ask-secret') {
|
|
288
|
+
const value = typeof b.value === 'string' ? b.value : ''
|
|
289
|
+
return Response.json(await askSecret({ root: d.root, asksDir: d.asksDir, file: b.file ?? '', name: b.name ?? '', value, store: d.storeSecret ?? managerStore(d.root) }))
|
|
290
|
+
}
|
|
281
291
|
if (path === '/api/act/ask-done') askDone(d.root, d.asksDir, b.file ?? '')
|
|
282
292
|
else if (path === '/api/act/ask-proof') askProof(d.root, d.asksDir, b.file ?? '', b.url ?? '')
|
|
283
293
|
else if (path === '/api/act/remark') {
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
// an identity's Discord server as data (wiki tools/shipkit/social-identities.md, The server's layout): `layout.md`
|
|
2
|
+
// beside its discord account.md, made true through the account's bot. Nothing is deleted unless asked, and never a
|
|
3
|
+
// channel that holds a message; a server that already matches gets no call but the reads
|
|
4
|
+
import { existsSync, readFileSync } from 'node:fs'
|
|
5
|
+
import { join } from 'node:path'
|
|
6
|
+
import type { Account } from '../identities/identities.ts'
|
|
7
|
+
import { parseFrontmatter } from './md.ts'
|
|
8
|
+
import { call, channelKey } from './publish/discord.ts'
|
|
9
|
+
|
|
10
|
+
export type ChannelDef = { name: string; emoji: string; topic: string; readOnly: boolean; voice: boolean; ageRestricted: boolean; only: string[] }
|
|
11
|
+
export type CategoryDef = { name: string; was: string[]; channels: ChannelDef[] }
|
|
12
|
+
export type RoleDef = { name: string; color: number; hoist: boolean; mentionable: boolean; owner: boolean }
|
|
13
|
+
/** a member by its Discord username, and the roles the apply gives it */
|
|
14
|
+
export type MemberDef = { name: string; roles: string[] }
|
|
15
|
+
export type DiscordLayout = { file: string; name: string; roles: RoleDef[]; members: MemberDef[]; categories: CategoryDef[] }
|
|
16
|
+
|
|
17
|
+
const ROLE_FLAGS = new Set(['hoist', 'mentionable', 'owner'])
|
|
18
|
+
const CHANNEL_FLAGS = new Set(['read only', 'voice', 'age restricted'])
|
|
19
|
+
|
|
20
|
+
const cells = (chunk: string): string[][] =>
|
|
21
|
+
chunk
|
|
22
|
+
.split('\n')
|
|
23
|
+
.filter((l) => /^\|.*\|$/.test(l.trim()))
|
|
24
|
+
.map((l) => l.trim().slice(1, -1).split('|').map((c) => c.trim()))
|
|
25
|
+
.slice(2)
|
|
26
|
+
|
|
27
|
+
const list = (cell: string | undefined): string[] => (cell ?? '').split(',').map((x) => x.trim()).filter((x) => x !== '')
|
|
28
|
+
|
|
29
|
+
/** a layout page read and checked: every bad row is one error line, thrown together */
|
|
30
|
+
export function parseLayout(raw: string, file: string): DiscordLayout {
|
|
31
|
+
const { meta, body } = parseFrontmatter(raw)
|
|
32
|
+
const errors: string[] = []
|
|
33
|
+
if (!meta.name) errors.push('front matter names no server name (name:)')
|
|
34
|
+
const roles: RoleDef[] = []
|
|
35
|
+
const members: MemberDef[] = []
|
|
36
|
+
const categories: CategoryDef[] = []
|
|
37
|
+
for (const chunk of body.split(/^## /m).slice(1)) {
|
|
38
|
+
const head = chunk.slice(0, chunk.indexOf('\n') === -1 ? chunk.length : chunk.indexOf('\n')).trim()
|
|
39
|
+
if (head === 'Roles') {
|
|
40
|
+
for (const [name = '', colour = '', flags] of cells(chunk)) {
|
|
41
|
+
const f = list(flags)
|
|
42
|
+
for (const x of f) if (!ROLE_FLAGS.has(x)) errors.push(`role ${name}: unknown flag "${x}" (${[...ROLE_FLAGS].join(', ')})`)
|
|
43
|
+
if (!/^#[0-9a-f]{6}$/i.test(colour)) errors.push(`role ${name}: colour "${colour}" is no #rrggbb`)
|
|
44
|
+
roles.push({ name, color: Number.parseInt(colour.slice(1), 16), hoist: f.includes('hoist'), mentionable: f.includes('mentionable'), owner: f.includes('owner') })
|
|
45
|
+
}
|
|
46
|
+
continue
|
|
47
|
+
}
|
|
48
|
+
if (head === 'Members') {
|
|
49
|
+
for (const [name = '', given] of cells(chunk)) {
|
|
50
|
+
if (!/^[a-z0-9_.]{2,32}$/.test(name)) errors.push(`member ${name}: a Discord username is 2 to 32 of a-z, 0-9, _ and .`)
|
|
51
|
+
members.push({ name, roles: list(given) })
|
|
52
|
+
}
|
|
53
|
+
continue
|
|
54
|
+
}
|
|
55
|
+
const m = /^(.+?)(?: \(was (.+)\))?$/.exec(head)!
|
|
56
|
+
const channels: ChannelDef[] = []
|
|
57
|
+
for (const [name = '', emoji = '', topic = '', flags, only] of cells(chunk)) {
|
|
58
|
+
const f = list(flags)
|
|
59
|
+
for (const x of f) if (!CHANNEL_FLAGS.has(x)) errors.push(`#${name}: unknown flag "${x}" (${[...CHANNEL_FLAGS].join(', ')})`)
|
|
60
|
+
if (!/^[\p{L}\p{N}][\p{L}\p{N}_-]*$/u.test(name)) errors.push(`#${name}: a channel name is letters, digits, - and _`)
|
|
61
|
+
channels.push({ name, emoji, topic, readOnly: f.includes('read only'), voice: f.includes('voice'), ageRestricted: f.includes('age restricted'), only: list(only) })
|
|
62
|
+
}
|
|
63
|
+
categories.push({ name: m[1]!, was: list(m[2]), channels })
|
|
64
|
+
}
|
|
65
|
+
// a text and a voice channel may share a name: each is found by its own type
|
|
66
|
+
const names = categories.flatMap((c) => c.channels.map((x) => `${x.voice ? 'voice ' : '#'}${x.name.toLowerCase()}`))
|
|
67
|
+
for (const n of new Set(names)) if (names.filter((x) => x === n).length > 1) errors.push(`${n}: named twice`)
|
|
68
|
+
for (const c of categories) for (const x of c.channels) for (const r of x.only) if (!roles.some((d) => d.name === r)) errors.push(`#${x.name}: only "${r}", no such role under ## Roles`)
|
|
69
|
+
for (const x of members) for (const r of x.roles) if (!roles.some((d) => d.name === r)) errors.push(`member ${x.name}: role "${r}", no such role under ## Roles`)
|
|
70
|
+
if (errors.length > 0) throw new Error(`${file}:\n ${errors.join('\n ')}`)
|
|
71
|
+
return { file, name: meta.name!, roles, members, categories }
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** the layout of a discord account, `layout.md` beside its account.md */
|
|
75
|
+
export function layoutOf(a: Account): DiscordLayout {
|
|
76
|
+
const file = join(a.dir, 'layout.md')
|
|
77
|
+
if (!existsSync(file)) throw new Error(`${a.identity}: no ${file}, the server's layout`)
|
|
78
|
+
return parseLayout(readFileSync(file, 'utf8'), file)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** every channel name of a layout, its key in a draft's place and a `#name` of a text */
|
|
82
|
+
export const layoutChannels = (l: DiscordLayout): string[] => l.categories.flatMap((c) => c.channels.map((x) => x.name))
|
|
83
|
+
|
|
84
|
+
const TEXT = 0
|
|
85
|
+
const VOICE = 2
|
|
86
|
+
const CATEGORY = 4
|
|
87
|
+
/** send messages, create public and private threads, send in threads */
|
|
88
|
+
const WRITE = String((1n << 11n) | (1n << 35n) | (1n << 36n) | (1n << 38n))
|
|
89
|
+
const VIEW = String(1n << 10n)
|
|
90
|
+
|
|
91
|
+
type Overwrite = { id: string; type: number; allow: string; deny: string }
|
|
92
|
+
type Channel = { id: string; type: number; name: string; parent_id: string | null; topic?: string | null; nsfw?: boolean; position: number; permission_overwrites?: Overwrite[] }
|
|
93
|
+
type Role = { id: string; name: string; color: number; hoist: boolean; mentionable: boolean; managed: boolean }
|
|
94
|
+
|
|
95
|
+
const same = (a: string, b: string): boolean => a.toLowerCase() === b.toLowerCase()
|
|
96
|
+
|
|
97
|
+
/** a channel shows as `<emoji>・<name>`; its name alone is its key */
|
|
98
|
+
const shown = (def: ChannelDef): string => (def.emoji === '' ? def.name : `${def.emoji}・${def.name}`)
|
|
99
|
+
|
|
100
|
+
/** the overwrites a channel wants: the everyone role is the guild's own id */
|
|
101
|
+
export function overwritesOf(def: ChannelDef, guild: string, roleIds: ReadonlyMap<string, string>): Overwrite[] {
|
|
102
|
+
return [
|
|
103
|
+
...(def.readOnly ? [{ id: guild, type: 0, allow: '0', deny: WRITE }] : []),
|
|
104
|
+
...(def.only.length === 0 ? [] : [{ id: guild, type: 0, allow: '0', deny: VIEW }]),
|
|
105
|
+
...def.only.flatMap((name) => {
|
|
106
|
+
const id = roleIds.get(name)
|
|
107
|
+
return id == null ? [] : [{ id, type: 0, allow: VIEW, deny: '0' }]
|
|
108
|
+
}),
|
|
109
|
+
]
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const overwriteKey = (o: readonly Overwrite[]): string =>
|
|
113
|
+
o.map((x) => `${x.id}:${x.type}:${x.allow}:${x.deny}`).sort().join(',')
|
|
114
|
+
|
|
115
|
+
/** what differs between a channel and what it wants, by name; empty, it matches */
|
|
116
|
+
export function channelChanges(ch: Channel, want: { name: string; parent_id: string; topic?: string; nsfw: boolean; permission_overwrites: Overwrite[] }): string[] {
|
|
117
|
+
const out: string[] = []
|
|
118
|
+
if (ch.name !== want.name) out.push(`name ${want.name}`)
|
|
119
|
+
if (ch.parent_id !== want.parent_id) out.push('category')
|
|
120
|
+
if (want.topic != null && (ch.topic ?? '') !== want.topic) out.push('topic')
|
|
121
|
+
if ((ch.nsfw ?? false) !== want.nsfw) out.push(want.nsfw ? 'age restricted' : 'not age restricted')
|
|
122
|
+
if (overwriteKey(ch.permission_overwrites ?? []) !== overwriteKey(want.permission_overwrites)) out.push('permissions')
|
|
123
|
+
return out
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export type ApplyReport = { changes: string[]; left: string[] }
|
|
127
|
+
|
|
128
|
+
/** makes the account's server match its layout; what it did (or would do, dry), and what it left alone */
|
|
129
|
+
export async function applyLayout(a: Account, o: { dry: boolean; prune: boolean }): Promise<ApplyReport> {
|
|
130
|
+
const layout = layoutOf(a)
|
|
131
|
+
if (a.guild === '') {
|
|
132
|
+
const guilds = await call<{ id: string; name: string }[]>(a, 'GET', '/users/@me/guilds')
|
|
133
|
+
throw new Error(`${a.file}: no guild, the server's id; the bot is in ${guilds.map((g) => `${g.id} (${g.name})`).join(', ') || 'no server yet'}`)
|
|
134
|
+
}
|
|
135
|
+
const G = a.guild
|
|
136
|
+
const changes: string[] = []
|
|
137
|
+
const left: string[] = []
|
|
138
|
+
const json = (b: unknown): string => JSON.stringify(b)
|
|
139
|
+
const act = async (what: string, run: () => Promise<unknown>): Promise<void> => {
|
|
140
|
+
changes.push(o.dry ? `would ${what}` : what)
|
|
141
|
+
if (!o.dry) await run()
|
|
142
|
+
}
|
|
143
|
+
const guild = await call<{ name: string; owner_id: string }>(a, 'GET', `/guilds/${G}`)
|
|
144
|
+
if (guild.name !== layout.name) await act(`rename the server « ${layout.name} »`, () => call(a, 'PATCH', `/guilds/${G}`, json({ name: layout.name })))
|
|
145
|
+
|
|
146
|
+
const roles = await call<Role[]>(a, 'GET', `/guilds/${G}/roles`)
|
|
147
|
+
const roleIds = new Map<string, string>()
|
|
148
|
+
for (const def of layout.roles) {
|
|
149
|
+
const want = { name: def.name, color: def.color, hoist: def.hoist, mentionable: def.mentionable }
|
|
150
|
+
let role = roles.find((r) => !r.managed && same(r.name, def.name))
|
|
151
|
+
if (role == null) {
|
|
152
|
+
await act(`create the role ${def.name}`, async () => {
|
|
153
|
+
role = await call<Role>(a, 'POST', `/guilds/${G}/roles`, json({ ...want, permissions: '0' }))
|
|
154
|
+
})
|
|
155
|
+
} else if (role.name !== def.name || role.color !== def.color || role.hoist !== def.hoist || role.mentionable !== def.mentionable) {
|
|
156
|
+
const id = role.id
|
|
157
|
+
await act(`update the role ${def.name}`, () => call(a, 'PATCH', `/guilds/${G}/roles/${id}`, json(want)))
|
|
158
|
+
}
|
|
159
|
+
if (role != null) roleIds.set(def.name, role.id)
|
|
160
|
+
if (def.owner && role != null) {
|
|
161
|
+
const member = await call<{ roles: string[] }>(a, 'GET', `/guilds/${G}/members/${guild.owner_id}`)
|
|
162
|
+
const id = role.id
|
|
163
|
+
if (!member.roles.includes(id)) await act(`give the owner the role ${def.name}`, () => call(a, 'PUT', `/guilds/${G}/members/${guild.owner_id}/roles/${id}`))
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
for (const def of layout.members) {
|
|
168
|
+
const found = await call<{ user: { username: string; id: string }; roles: string[] }[]>(a, 'GET', `/guilds/${G}/members/search?query=${encodeURIComponent(def.name)}&limit=10`)
|
|
169
|
+
const member = found.find((x) => x.user.username === def.name)
|
|
170
|
+
if (member == null) {
|
|
171
|
+
left.push(`member ${def.name} (not in the server yet)`)
|
|
172
|
+
continue
|
|
173
|
+
}
|
|
174
|
+
for (const r of def.roles) {
|
|
175
|
+
const id = roleIds.get(r)
|
|
176
|
+
if (id == null) changes.push(`would give ${def.name} the role ${r}`)
|
|
177
|
+
else if (!member.roles.includes(id)) await act(`give ${def.name} the role ${r}`, () => call(a, 'PUT', `/guilds/${G}/members/${member.user.id}/roles/${id}`))
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
const channels = await call<Channel[]>(a, 'GET', `/guilds/${G}/channels`)
|
|
182
|
+
const kept = new Set<string>()
|
|
183
|
+
const moves: { id: string; position: number; label: string }[] = []
|
|
184
|
+
// Discord numbers positions across the whole server, one count per type (categories, text, voice), in the order shown
|
|
185
|
+
const next = new Map<number, number>()
|
|
186
|
+
const slot = (type: number): number => {
|
|
187
|
+
const n = next.get(type) ?? 0
|
|
188
|
+
next.set(type, n + 1)
|
|
189
|
+
return n
|
|
190
|
+
}
|
|
191
|
+
const place = (ch: Channel | undefined, type: number, label: string): void => {
|
|
192
|
+
const position = slot(type)
|
|
193
|
+
if (ch == null) return
|
|
194
|
+
kept.add(ch.id)
|
|
195
|
+
if (ch.position !== position) moves.push({ id: ch.id, position, label })
|
|
196
|
+
}
|
|
197
|
+
for (const cat of layout.categories) {
|
|
198
|
+
let c = channels.find((x) => x.type === CATEGORY && [cat.name, ...cat.was].some((n) => same(n, x.name)))
|
|
199
|
+
if (c == null) {
|
|
200
|
+
await act(`create the category ${cat.name}`, async () => {
|
|
201
|
+
c = await call<Channel>(a, 'POST', `/guilds/${G}/channels`, json({ name: cat.name, type: CATEGORY }))
|
|
202
|
+
})
|
|
203
|
+
} else if (c.name !== cat.name) {
|
|
204
|
+
const id = c.id
|
|
205
|
+
await act(`rename the category ${c.name} → ${cat.name}`, () => call(a, 'PATCH', `/channels/${id}`, json({ name: cat.name })))
|
|
206
|
+
}
|
|
207
|
+
place(c, CATEGORY, `the category ${cat.name}`)
|
|
208
|
+
if (c == null) {
|
|
209
|
+
for (const def of cat.channels) {
|
|
210
|
+
slot(def.voice ? VOICE : TEXT)
|
|
211
|
+
changes.push(`would create #${def.name} in ${cat.name}`)
|
|
212
|
+
}
|
|
213
|
+
continue
|
|
214
|
+
}
|
|
215
|
+
for (const def of cat.channels) {
|
|
216
|
+
const type = def.voice ? VOICE : TEXT
|
|
217
|
+
const want = { name: shown(def), parent_id: c.id, ...(def.voice ? {} : { topic: def.topic }), nsfw: def.ageRestricted, permission_overwrites: overwritesOf(def, G, roleIds) }
|
|
218
|
+
let ch = channels.find((x) => x.type === type && same(channelKey(x.name), def.name))
|
|
219
|
+
if (ch == null) {
|
|
220
|
+
await act(`create #${def.name} in ${cat.name}`, async () => {
|
|
221
|
+
ch = await call<Channel>(a, 'POST', `/guilds/${G}/channels`, json({ ...want, type }))
|
|
222
|
+
})
|
|
223
|
+
} else {
|
|
224
|
+
const diff = channelChanges(ch, want)
|
|
225
|
+
const id = ch.id
|
|
226
|
+
if (diff.length > 0) await act(`set #${def.name} (${cat.name}): ${diff.join(', ')}`, () => call(a, 'PATCH', `/channels/${id}`, json(want)))
|
|
227
|
+
}
|
|
228
|
+
place(ch, type, `#${def.name}`)
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
if (moves.length > 0) await act(`move ${moves.map((m) => m.label).join(', ')}`, () => call(a, 'PATCH', `/guilds/${G}/channels`, json(moves.map(({ id, position }) => ({ id, position })))))
|
|
232
|
+
|
|
233
|
+
for (const x of channels.filter((x) => !kept.has(x.id))) {
|
|
234
|
+
const empty = x.type !== TEXT || (await call<unknown[]>(a, 'GET', `/channels/${x.id}/messages?limit=1`)).length === 0
|
|
235
|
+
if (o.prune && empty && x.type === TEXT) await act(`delete #${x.name} (empty)`, () => call(a, 'DELETE', `/channels/${x.id}`))
|
|
236
|
+
else left.push(`${x.type === CATEGORY ? 'category ' : '#'}${x.name}${x.type === TEXT ? (empty ? ' (empty, --prune deletes it)' : ' (holds messages)') : ''}`)
|
|
237
|
+
}
|
|
238
|
+
return { changes, left }
|
|
239
|
+
}
|
package/src/social/md.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// the markdown shapes every social file is written in: `key: value` front matter, `## <name>` sections, the
|
|
2
2
|
// `| field | value |` tables of a profile
|
|
3
|
-
import {
|
|
3
|
+
import { statSync } from 'node:fs'
|
|
4
4
|
import { isAbsolute, join } from 'node:path'
|
|
5
5
|
|
|
6
6
|
/** `key: value` lines only, no nesting */
|
|
@@ -40,11 +40,21 @@ export function section(body: string, name: string): string | null {
|
|
|
40
40
|
export type ProfileRow = {
|
|
41
41
|
field: string
|
|
42
42
|
value: string
|
|
43
|
-
/** the value
|
|
44
|
-
*
|
|
43
|
+
/** every path of the value that is a file under the identity's `files` folder, the pictures to upload; the rest of
|
|
44
|
+
* the value a note (a size, the other variant); empty, a text */
|
|
45
45
|
files: string[]
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
/** a relative path in a text: no scheme or folder before it, an extension after it */
|
|
49
|
+
const PATH = /(?<![\w/:.~-])[\w~-][\w~./-]*\.\w+/g
|
|
50
|
+
|
|
51
|
+
/** the paths a value names that are files under `root`, in their order, each once */
|
|
52
|
+
export function filesIn(value: string, root: string): string[] {
|
|
53
|
+
const out: string[] = []
|
|
54
|
+
for (const p of value.match(PATH) ?? []) if (!isAbsolute(p) && !p.startsWith('~') && !out.includes(p) && statSync(join(root, p), { throwIfNoEntry: false })?.isFile() === true) out.push(p)
|
|
55
|
+
return out
|
|
56
|
+
}
|
|
57
|
+
|
|
48
58
|
/** the rows of the `| field | value |` table of a `## Profile` (or another) section; `filesRoot` the folder a picture
|
|
49
59
|
* path is relative to, null when the rows name none */
|
|
50
60
|
export function rows(body: string, name = 'Profile', filesRoot: string | null = null): ProfileRow[] {
|
|
@@ -53,9 +63,7 @@ export function rows(body: string, name = 'Profile', filesRoot: string | null =
|
|
|
53
63
|
const m = /^\|\s*(.+?)\s*\|\s*(.*?)\s*\|$/.exec(line.trim())
|
|
54
64
|
if (m == null || m[1] === 'field' || /^-+$/.test(m[1]!)) continue
|
|
55
65
|
const value = m[2]!
|
|
56
|
-
|
|
57
|
-
const files = filesRoot != null && parts.every((x) => /\.\w+$/.test(x) && !isAbsolute(x) && existsSync(join(filesRoot, x))) ? parts : []
|
|
58
|
-
out.push({ field: m[1]!, value, files })
|
|
66
|
+
out.push({ field: m[1]!, value, files: filesRoot == null ? [] : filesIn(value, filesRoot) })
|
|
59
67
|
}
|
|
60
68
|
return out
|
|
61
69
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// a draft's message posted to Discord as the identity's bot (wiki tools/shipkit/social.md, Publishing): to the channel
|
|
2
2
|
// its place names, a `#name` of a channel made its link, its media attached, pinned when it asks; a message already
|
|
3
|
-
// posted is edited at its link. The server's layout
|
|
3
|
+
// posted is edited at its link. The server's layout: ../discord-layout.ts
|
|
4
4
|
import type { Account } from '../../identities/identities.ts'
|
|
5
5
|
import { withoutTags } from '../compose.ts'
|
|
6
6
|
import type { SocialPost } from '../load.ts'
|
|
@@ -11,7 +11,8 @@ const TEXT = 0
|
|
|
11
11
|
|
|
12
12
|
type Channel = { id: string; type: number; name: string }
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
/** one call of Discord's api as the account's bot, waiting out a rate limit */
|
|
15
|
+
export async function call<T>(a: Account, method: string, path: string, body?: BodyInit, json = true): Promise<T> {
|
|
15
16
|
const auth = `Bot ${await secret(a.secret, `${a.file}: secret`)}`
|
|
16
17
|
for (;;) {
|
|
17
18
|
const r = await fetch(API + path, { method, headers: { Authorization: auth, ...(json && body != null ? { 'Content-Type': 'application/json' } : {}) }, body })
|
package/src/social/routes.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { existsSync } from 'node:fs'
|
|
6
6
|
import { homedir } from 'node:os'
|
|
7
7
|
import { isAbsolute, join, relative, resolve } from 'node:path'
|
|
8
|
-
import { bad, NO_STORE, ranged } from '../review/http.ts'
|
|
8
|
+
import { bad, FRESH, NO_STORE, ranged } from '../review/http.ts'
|
|
9
9
|
import { askedPosts, noteOn, notesBy } from '../review/notes.ts'
|
|
10
10
|
import { readAllCached, storeDir } from '../review/store.ts'
|
|
11
11
|
import { DRAFT_NAME, draftsDir, type Desk } from './load.ts'
|
|
@@ -44,7 +44,7 @@ function picture(desk: Desk, identity: string, rel: string): string {
|
|
|
44
44
|
const i = desk.identities.find((x) => x.id === identity)
|
|
45
45
|
if (i?.files == null) throw new Error(`${identity} has no files folder`)
|
|
46
46
|
if (rel.startsWith('~/') || isAbsolute(rel)) {
|
|
47
|
-
if (!i.pictures.some((p) => p.file === rel)) throw new Error(`not a picture of ${identity}: ${rel}`)
|
|
47
|
+
if (!i.pictures.some((p) => p.file === rel || p.also.includes(rel))) throw new Error(`not a picture of ${identity}: ${rel}`)
|
|
48
48
|
return rel.startsWith('~/') ? join(homedir(), rel.slice(2)) : rel
|
|
49
49
|
}
|
|
50
50
|
const abs = resolve(i.files, rel)
|
|
@@ -91,7 +91,7 @@ export async function socialRoutes(root: string, req: Request, path: string): Pr
|
|
|
91
91
|
const pic = /^picture\/([a-z0-9-]+)\/(.+)$/.exec(sub)
|
|
92
92
|
if (pic) {
|
|
93
93
|
const { desk } = await openDesk(root)
|
|
94
|
-
return ranged(req, picture(desk, pic[1]!, decodeURIComponent(pic[2]!)))
|
|
94
|
+
return ranged(req, picture(desk, pic[1]!, decodeURIComponent(pic[2]!)), FRESH)
|
|
95
95
|
}
|
|
96
96
|
const prev = /^preview\/([^/]+)$/.exec(sub)
|
|
97
97
|
if (prev) {
|
package/src/stores/routes.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { readdirSync, readFileSync, statSync, writeFileSync } from 'node:fs'
|
|
5
5
|
import { join } from 'node:path'
|
|
6
6
|
import { machineCommit } from '../core/machine-commit.ts'
|
|
7
|
-
import { bad, NO_STORE, ranged } from '../review/http.ts'
|
|
7
|
+
import { bad, FRESH, NO_STORE, ranged } from '../review/http.ts'
|
|
8
8
|
import { noteOn } from '../review/notes.ts'
|
|
9
9
|
import { openReview } from '../review/project.ts'
|
|
10
10
|
import { FILE_ROUTE, loadStoresUnit, shownFile, storesState, textFiles } from './desk.ts'
|
|
@@ -111,7 +111,7 @@ export async function storesRoutes(root: string, req: Request, path: string): Pr
|
|
|
111
111
|
}
|
|
112
112
|
if (path.startsWith(FILE_ROUTE) && req.method === 'GET') {
|
|
113
113
|
const abs = shownFile(root, decodeURIComponent(path.slice(FILE_ROUTE.length)))
|
|
114
|
-
return abs ? ranged(req, abs) : bad(`${path}?`, 404)
|
|
114
|
+
return abs ? ranged(req, abs, FRESH) : bad(`${path}?`, 404)
|
|
115
115
|
}
|
|
116
116
|
if (req.method !== 'POST') return bad(`stores: no route ${req.method} ${path}`, 404)
|
|
117
117
|
const body = (await req.json().catch(() => ({}))) as Record<string, unknown>
|
|
@@ -47,7 +47,7 @@ export const FULL_TIMEOUT_MS = 120_000
|
|
|
47
47
|
* trigger), so without this a hang lasts until something outside kills it. The quick
|
|
48
48
|
* tier answers in seconds, so two minutes is far from any real run. */
|
|
49
49
|
export const QUICK_CEILING_MS = 120_000
|
|
50
|
-
/** the full tier runs every suite
|
|
50
|
+
/** the full tier's ceiling: it runs every suite, slow ones included */
|
|
51
51
|
export const FULL_CEILING_MS = 1_800_000
|
|
52
52
|
const TESTS_KEYS = ['budgetMs', 'slow', 'serial', 'select']
|
|
53
53
|
const SLOW_KEYS = ['file', 'catches', 'whyNotFast']
|