rvlib-shipkit 2.20.0 → 2.22.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 +35 -0
- package/package.json +1 -1
- package/src/asks/asks-queue.ts +8 -7
- package/src/assets/kits/identity-kit.ts +158 -2
- package/src/checks/SK004-gitignore-policy.check.ts +6 -3
- package/src/cli/cmd_Bump.ts +3 -3
- package/src/cli/cmd_GlobalProcesses.ts +2 -107
- package/src/cli/cmd_Home.ts +1 -1
- package/src/cli/cmd_Overview.ts +2 -1
- package/src/cli/cmd_Rec.ts +349 -0
- package/src/cli/cmd_Releases.ts +42 -3
- package/src/cli/cmd_Review.ts +22 -13
- package/src/cli/cmd_Secret.ts +10 -3
- package/src/cli/cmd_Sign.ts +24 -0
- package/src/cli/cmd_Social.ts +57 -8
- package/src/cli/cmd_Sound.ts +17 -4
- package/src/cli/cmd_Trailer.ts +67 -1
- package/src/cli/family-pages.ts +1 -0
- package/src/cli/registry.ts +6 -1
- package/src/collections/collection-types.ts +1 -1
- package/src/collections/review.ts +23 -4
- package/src/core/agent-spawn.ts +4 -17
- package/src/core/code-lines.ts +49 -0
- package/src/core/discover-checks.ts +27 -3
- package/src/core/hard-reset.ts +34 -0
- package/src/core/layout.ts +6 -0
- package/src/core/raw-access.ts +3 -13
- package/src/core/throwaway-worktree.ts +72 -0
- package/src/home/app-sign.ts +98 -0
- package/src/home/gui-app/ShipkitGui.swift +35 -0
- package/src/home/gui-app.ts +31 -11
- package/src/home/home-routes.ts +6 -0
- package/src/home/pm-switch.ts +112 -0
- package/src/home/serve-web.ts +1 -1
- package/src/identities/identities.ts +17 -6
- package/src/media-kinds.ts +5 -3
- package/src/media-store/forget.ts +54 -0
- package/src/media-store/put.ts +4 -3
- package/src/media-store/space.ts +63 -24
- package/src/messages/brief.ts +3 -3
- package/src/messages/score.ts +2 -0
- package/src/recordings/delete.ts +19 -0
- package/src/recordings/edit.ts +231 -0
- package/src/recordings/load.ts +37 -0
- package/src/recordings/marks-draw.ts +111 -0
- package/src/recordings/marks-png.ts +25 -0
- package/src/recordings/marks.ts +138 -0
- package/src/recordings/media-kind.ts +67 -0
- package/src/recordings/model.ts +170 -0
- package/src/recordings/open.ts +33 -0
- package/src/recordings/place.ts +89 -0
- package/src/recordings/presets.ts +99 -0
- package/src/recordings/recorder-app/Capture.swift +510 -0
- package/src/recordings/recorder-app/Clip.swift +107 -0
- package/src/recordings/recorder-app/Editor.swift +39 -0
- package/src/recordings/recorder-app/Tray.swift +298 -0
- package/src/recordings/recorder-app/main.swift +859 -0
- package/src/recordings/recorder-app.ts +46 -0
- package/src/recordings/recorder.shipkit.ts +11 -0
- package/src/recordings/routes.ts +140 -0
- package/src/recordings/run-recorder.ts +40 -0
- package/src/recordings/share.ts +107 -0
- package/src/recordings/take.ts +146 -0
- package/src/recordings/view.ts +40 -0
- package/src/release/gate-checkout.ts +74 -0
- package/src/release/release-scope.ts +35 -26
- package/src/release/run-bump.ts +79 -37
- package/src/release/run-release.ts +67 -53
- package/src/releases/add.ts +38 -5
- package/src/releases/before.ts +31 -0
- package/src/releases/from-card.ts +105 -20
- package/src/releases/model.ts +100 -18
- package/src/releases/pictures.ts +29 -8
- package/src/repo-config.ts +7 -3
- package/src/review/http.ts +1 -1
- package/src/review/model.ts +12 -2
- package/src/review/stage-card.ts +1 -1
- package/src/review/store.ts +12 -2
- package/src/review/trailer-desk.ts +20 -0
- package/src/review/trailer-model.ts +67 -0
- package/src/review/trailer-routes.ts +98 -1
- package/src/review/trailer-voices.ts +144 -0
- package/src/review/watchers.ts +58 -1
- package/src/secrets/manager.ts +18 -1
- package/src/serve/hub-app/benign-errors.ts +22 -0
- package/src/serve/hub-app/hash-route.ts +27 -15
- package/src/serve/hub-app/home-st.ts +23 -5
- package/src/serve/hub-app/home.html +1 -0
- package/src/serve/hub-app/hub-app.tsx +8 -1
- package/src/serve/hub-app/icons.tsx +2 -0
- package/src/serve/hub-app/palette-st.ts +1 -0
- package/src/serve/hub-app/project-list.css +7 -2
- package/src/serve/hub-app/project-list.tsx +10 -0
- package/src/serve/hub-app/projects-svc.ts +17 -7
- package/src/serve/hub-app/recordings-st.ts +641 -0
- package/src/serve/hub-app/recordings-view.tsx +504 -0
- package/src/serve/hub-app/recordings.css +82 -0
- package/src/serve/hub-app/releases/releases-page.tsx +121 -28
- package/src/serve/hub-app/releases/releases-st.ts +46 -4
- package/src/serve/hub-app/releases.css +30 -3
- package/src/serve/hub-app/repo-sections.ts +1 -1
- package/src/serve/hub-app/repo-st.ts +16 -11
- package/src/serve/hub-app/review/clip-st.ts +3 -1
- package/src/serve/hub-app/review/kit.tsx +3 -3
- package/src/serve/hub-app/review/trailer-page.tsx +32 -6
- package/src/serve/hub-app/review/trailer-st.ts +184 -8
- package/src/serve/hub-app/review/trailer-timeline.tsx +39 -4
- package/src/serve/hub-app/review/trailer-voices-st.ts +370 -0
- package/src/serve/hub-app/review/trailer-voices.tsx +574 -0
- package/src/serve/hub-app/review.css +90 -0
- package/src/serve/hub-app/social/comms-page.tsx +10 -5
- package/src/serve/hub-app/social/next-release.tsx +118 -0
- package/src/serve/hub-app/social/post-card.tsx +31 -3
- package/src/serve/hub-app/social/social-model.ts +6 -0
- package/src/serve/hub-app/social/social-st.ts +50 -1
- package/src/serve/hub-app/social.css +12 -0
- package/src/serve/hub-app/tree-build.ts +2 -0
- package/src/serve/project-gutter-route.ts +8 -0
- package/src/serve/project-gutter.ts +4 -2
- package/src/shipkit.ts +2 -2
- package/src/shot/box.ts +49 -22
- package/src/shot/browser-slot.ts +13 -3
- package/src/shot/client.ts +1 -1
- package/src/shot/film-box.ts +193 -117
- package/src/shot/shooter.ts +20 -8
- package/src/smoke/run-smoke.ts +8 -6
- package/src/social/compose.ts +14 -0
- package/src/social/desk-index.ts +49 -8
- package/src/social/discord-layout.ts +6 -2
- package/src/social/drafts.ts +1 -1
- package/src/social/kinds.ts +3 -2
- package/src/social/load.ts +42 -9
- package/src/social/publish/index.ts +27 -10
- package/src/social/publish/secret.ts +12 -4
- package/src/social/release-card.ts +69 -0
- package/src/social/release-stage.ts +173 -30
- package/src/social/routes.ts +7 -1
- package/src/social/stage.ts +45 -22
- package/src/trailer/bed.ts +111 -0
- package/src/trailer/build.ts +81 -38
- package/src/trailer/ffmpeg.ts +14 -0
- package/src/trailer/grammar.ts +32 -4
- package/src/trailer/graph.ts +12 -1
- package/src/trailer/look.ts +7 -0
- package/src/trailer/shot-plan.ts +75 -0
- package/src/trailer/shot-state.ts +191 -0
- package/src/trailer/sound/audio.ts +28 -0
- package/src/trailer/sound/brand.ts +53 -3
- package/src/trailer/sound/gen.ts +61 -2
- package/src/trailer/sound/index.ts +25 -11
- package/src/trailer/sound/presets.ts +86 -5
- package/src/trailer/sound/run.ts +1 -1
- package/src/trailer/sound/takes.ts +94 -0
- package/src/trailer/titles.ts +36 -0
- package/src/trailer/url.ts +1 -1
- package/src/veille/chrome.ts +6 -3
package/src/shot/shooter.ts
CHANGED
|
@@ -26,7 +26,8 @@ import { dirname } from 'path'
|
|
|
26
26
|
import { loadPlaywright } from '../smoke/run-smoke.ts'
|
|
27
27
|
import { CLIP_INIT, CLIP_QUANTIZER, clipDone, installClip, KEY_EVERY, muxArgs, type PageClipAsk, type PageClipDone, TAKE, takeClip } from './clip-encoder.ts'
|
|
28
28
|
import { type ClipPath, clipPathOf, domEncodeArgs, FrameTimeline, largestCanvas, screencastParams } from './dom-clip.ts'
|
|
29
|
-
import { openBrowser, type PwBrowser } from './box.ts'
|
|
29
|
+
import { CLOSE_MS, openBrowser, type PwBrowser, slotFor } from './box.ts'
|
|
30
|
+
import type { BrowserLease } from './browser-slot.ts'
|
|
30
31
|
import { capMsOf, type ClipAsk, pageMove, readMark, type ShotAsk, slotKey, stillFormat, Turns, waitReady } from './shot-ask.ts'
|
|
31
32
|
|
|
32
33
|
/** the slice of playwright the shots touch, so the lib types nothing it does not ship */
|
|
@@ -82,8 +83,6 @@ export const LIVE_MS = 10_000
|
|
|
82
83
|
export const BROWSER_IDLE_MS = 60_000
|
|
83
84
|
/** the niceness of the process that launches the browser: chromium inherits it */
|
|
84
85
|
export const SHOT_NICE = 10
|
|
85
|
-
/** a browser close that has not answered in this long (a stalled box route) is left behind, so its slot frees */
|
|
86
|
-
export const CLOSE_MS = 5000
|
|
87
86
|
/** a page that paints nothing once the screencast starts is filmed from one still taken after this */
|
|
88
87
|
const FIRST_FRAME_MS = 1000
|
|
89
88
|
|
|
@@ -119,6 +118,8 @@ export class Shooter {
|
|
|
119
118
|
#browser: Browser | null = null
|
|
120
119
|
#launching: Promise<Browser> | null = null
|
|
121
120
|
#held: (() => void) | null = null
|
|
121
|
+
/** a slot taken in the queue and not yet handed to its browser's open */
|
|
122
|
+
#queued: BrowserLease | null = null
|
|
122
123
|
/** before a page goes to a url: the box route forwards this machine's localhost port to the box */
|
|
123
124
|
#reach: (url: string) => Promise<void> = async () => undefined
|
|
124
125
|
#slot: Slot | null = null
|
|
@@ -141,12 +142,20 @@ export class Shooter {
|
|
|
141
142
|
|
|
142
143
|
/** a still of the url, written at `a.out`, encoded by its extension (stillFormat) */
|
|
143
144
|
shot(a: ShotAsk): Promise<ShotDone> {
|
|
144
|
-
return this.#turns.run(() =>
|
|
145
|
+
return this.#turns.run(() => this.#capped(`the shot of ${a.url}`, capMsOf(a), () => this.#shot(a)))
|
|
145
146
|
}
|
|
146
147
|
|
|
147
148
|
/** an mp4 of `a.seconds` of the url, written at `a.out`: its canvas when the canvas is the page, else the page */
|
|
148
149
|
clip(a: ClipAsk): Promise<ShotDone> {
|
|
149
|
-
return this.#turns.run(() =>
|
|
150
|
+
return this.#turns.run(() => this.#capped(`the clip of ${a.url}`, capMsOf(a), () => this.#clip(a)))
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/** the run capped once its browser slot is held: a wait behind the repo's other browsers is its queue, as its turn
|
|
154
|
+
* is, never part of its run (a tab of a sheet waits behind the others' browsers, it never fails at the cap) */
|
|
155
|
+
async #capped(what: string, capMs: number, run: () => Promise<ShotDone>): Promise<ShotDone> {
|
|
156
|
+
const f = this.#for
|
|
157
|
+
if (f != null && this.#held == null && this.#queued == null) this.#queued = await slotFor({ root: f.root, who: f.who, ...(f.say ? { say: f.say } : {}) })
|
|
158
|
+
return withCap(what, capMs, run()).finally(() => this.#touch())
|
|
150
159
|
}
|
|
151
160
|
|
|
152
161
|
async close(): Promise<void> {
|
|
@@ -169,9 +178,10 @@ export class Shooter {
|
|
|
169
178
|
}
|
|
170
179
|
|
|
171
180
|
#free(): void {
|
|
172
|
-
const held = this.#held
|
|
173
|
-
this.#held = null
|
|
181
|
+
const [held, queued] = [this.#held, this.#queued]
|
|
182
|
+
this.#held = this.#queued = null
|
|
174
183
|
held?.()
|
|
184
|
+
queued?.release()
|
|
175
185
|
}
|
|
176
186
|
|
|
177
187
|
#touch(): void {
|
|
@@ -201,7 +211,9 @@ export class Shooter {
|
|
|
201
211
|
let b: Browser
|
|
202
212
|
if (f != null) {
|
|
203
213
|
// the repo's browser: on its box from a Mac (box.ts), else launched here, its slot held until close
|
|
204
|
-
const
|
|
214
|
+
const held = this.#queued
|
|
215
|
+
this.#queued = null
|
|
216
|
+
const o = await openBrowser<Browser>(pw, { root: f.root, who: f.who, args: BROWSER_ARGS, ...(f.say ? { say: f.say } : {}), ...(held ? { held } : {}) })
|
|
205
217
|
b = o.browser
|
|
206
218
|
this.#reach = (url) => o.reach(url)
|
|
207
219
|
this.#held = () => void o.close()
|
package/src/smoke/run-smoke.ts
CHANGED
|
@@ -227,16 +227,18 @@ export function secretArgv(template: string, name: string, field: 'get' | 'accou
|
|
|
227
227
|
}
|
|
228
228
|
|
|
229
229
|
/** a secret read through the repo's declared command, never argv and never
|
|
230
|
-
* env
|
|
231
|
-
* password. */
|
|
232
|
-
export function readSecret(template: string, name: string, field: 'get' | 'account' = 'get'): string {
|
|
230
|
+
* env, as the repo at `cwd` (a scoped name is refused out of its scope). The
|
|
231
|
+
* ACCOUNT field of a secret carries the identity, the value the password. */
|
|
232
|
+
export function readSecret(template: string, name: string, field: 'get' | 'account' = 'get', cwd?: string): string {
|
|
233
233
|
const argv = secretArgv(template, name, field)
|
|
234
234
|
const bin = argv[0] ?? ''
|
|
235
235
|
if (bin === '' || Bun.which(bin) == null) throw new Error(`FAIL credsReadCommand names '${bin}', which is not on PATH`)
|
|
236
|
-
const r = Bun.spawnSync(argv)
|
|
236
|
+
const r = Bun.spawnSync(argv, { ...(cwd != null ? { cwd } : {}), stderr: 'pipe' })
|
|
237
237
|
const v = r.stdout.toString().trim()
|
|
238
|
-
if (r.exitCode
|
|
239
|
-
|
|
238
|
+
if (r.exitCode === 0 && v !== '') return v
|
|
239
|
+
// a refusal is no missing secret: storing it again would not help
|
|
240
|
+
const why = r.stderr.toString().trim().split('\n').at(-1) ?? ''
|
|
241
|
+
throw new Error(why.startsWith('REFUSED') ? `FAIL ${why}` : `FAIL \`${argv.join(' ')}\` answered nothing — store the secret under that name first${why !== '' ? ` (${why})` : ''}`)
|
|
240
242
|
}
|
|
241
243
|
|
|
242
244
|
/** the smallest slice of playwright this module touches, so the package
|
package/src/social/compose.ts
CHANGED
|
@@ -39,6 +39,19 @@ export const TAG = /^#[\p{L}\p{N}_]+$/u
|
|
|
39
39
|
const SATURDAY = '#ScreenshotSaturday'
|
|
40
40
|
/** what each platform takes of a message's tags (wiki tools/shipkit/social.md, The tags); an account with no rule takes none */
|
|
41
41
|
const TAGS: Readonly<Record<string, 'all' | 'one' | 'vertical'>> = { x: 'all', bluesky: 'all', mastodon: 'all', threads: 'one', tiktok: 'vertical', instagram: 'vertical', youtube: 'vertical' }
|
|
42
|
+
/** platforms whose markdown starts a list only after a blank line: a list glued to the line above reads as text */
|
|
43
|
+
const LIST_AFTER_BLANK = new Set(['subscribestar'])
|
|
44
|
+
const LIST_ITEM = /^\s*(?:[-*+]|\d+\.)\s/
|
|
45
|
+
|
|
46
|
+
function blankBeforeLists(text: string): string {
|
|
47
|
+
const out: string[] = []
|
|
48
|
+
for (const line of text.split('\n')) {
|
|
49
|
+
const prev = out.at(-1)
|
|
50
|
+
if (LIST_ITEM.test(line) && prev !== undefined && prev.trim() !== '' && !LIST_ITEM.test(prev)) out.push('')
|
|
51
|
+
out.push(line)
|
|
52
|
+
}
|
|
53
|
+
return out.join('\n')
|
|
54
|
+
}
|
|
42
55
|
|
|
43
56
|
/** a message as one platform posts it: its text with the tags that platform takes (within its `max`), the footer of a
|
|
44
57
|
* vertical; X's links go to `reply`, the first reply under the post */
|
|
@@ -48,6 +61,7 @@ export function compose(
|
|
|
48
61
|
o: { max: number | null; saturday: boolean },
|
|
49
62
|
): { text: string; reply: string } {
|
|
50
63
|
let text = m.text.trim()
|
|
64
|
+
if (LIST_AFTER_BLANK.has(platform)) text = blankBeforeLists(text)
|
|
51
65
|
let reply = ''
|
|
52
66
|
if (platform === 'x') {
|
|
53
67
|
const links = text.match(URL_RE) ?? []
|
package/src/social/desk-index.ts
CHANGED
|
@@ -2,15 +2,18 @@
|
|
|
2
2
|
// stats says it: the social folder, the identities, the repo's config and social unit, the media a draft names outside
|
|
3
3
|
// its folder, and the day; HEAD moves the calendar alone. The desk is built, put on the wire and zipped once a stamp,
|
|
4
4
|
// and a page that holds the answer gets a 304. A stamp misses a media named outside the folder that appears where none
|
|
5
|
-
// stood: its error line clears at the next change
|
|
5
|
+
// stood: its error line clears at the next change. next-release.json is kept the same way, on next.md beside the parts
|
|
6
6
|
import { type Dirent, readdirSync, statSync } from 'node:fs'
|
|
7
7
|
import { join, relative } from 'node:path'
|
|
8
8
|
import { LAYOUT } from '../core/layout.ts'
|
|
9
9
|
import { headCommit } from '../core/git-root.ts'
|
|
10
10
|
import { unitFilesDeclaring } from '../core/unit-files.ts'
|
|
11
11
|
import { identitiesDir, readIdentities, type Identities } from '../identities/identities.ts'
|
|
12
|
+
import { fileOf, NEXT } from '../releases/model.ts'
|
|
13
|
+
import { releasesDir } from '../releases/store.ts'
|
|
12
14
|
import { loadRepoConfig } from '../repo-config.ts'
|
|
13
15
|
import { tagged } from '../review/http.ts'
|
|
16
|
+
import { previewNextRelease, type NextRelease } from './release-stage.ts'
|
|
14
17
|
import { wireOf } from './desk-wire.ts'
|
|
15
18
|
import { loadDesk, type Desk } from './load.ts'
|
|
16
19
|
import { commitMoments, dayOf, postedOf, timelineOf } from './presence.ts'
|
|
@@ -67,24 +70,29 @@ const stat = (abs: string): string => {
|
|
|
67
70
|
const stampOf = (parts: string[]): string => Bun.hash(parts.join('\n')).toString(36)
|
|
68
71
|
|
|
69
72
|
type Part<T> = { stamp: string; value: T }
|
|
73
|
+
type Answer = { stamp: string; tag: string; text: string; zip?: Uint8Array<ArrayBuffer> }
|
|
70
74
|
type Held = {
|
|
71
75
|
idsDir?: string | null
|
|
72
|
-
config?: Part<string | undefined>
|
|
76
|
+
config?: Part<{ speaksAs: string | undefined; releases: boolean }>
|
|
73
77
|
ids?: Part<Identities>
|
|
74
78
|
unit?: Part<SocialUnit | null>
|
|
75
79
|
desk?: Part<Desk> & { outside: string[] }
|
|
76
|
-
answer?:
|
|
80
|
+
answer?: Answer
|
|
81
|
+
next?: Answer
|
|
77
82
|
}
|
|
78
83
|
const held = new Map<string, Held>()
|
|
79
84
|
|
|
80
|
-
/**
|
|
81
|
-
|
|
85
|
+
/** what both answers are built from, the config, the identities and the unit, each read again only when its stamp moved */
|
|
86
|
+
async function partsOf(root: string) {
|
|
82
87
|
const h = held.get(root) ?? {}
|
|
83
88
|
held.set(root, h)
|
|
84
89
|
if (h.idsDir === undefined) h.idsDir = await identitiesDir(root)
|
|
85
90
|
|
|
86
91
|
const configStamp = stat(join(root, 'repo.config.ts'))
|
|
87
|
-
|
|
92
|
+
if (h.config?.stamp !== configStamp) {
|
|
93
|
+
const c = await loadRepoConfig(root, { fresh: true }).catch(() => null)
|
|
94
|
+
h.config = { stamp: configStamp, value: { speaksAs: c?.speaksAs, releases: c?.release?.releases === true } }
|
|
95
|
+
}
|
|
88
96
|
|
|
89
97
|
const idsParts: string[] = []
|
|
90
98
|
if (h.idsDir != null) tree(h.idsDir, idsParts)
|
|
@@ -93,17 +101,22 @@ export async function deskWire(root: string): Promise<{ stamp: string; tag: stri
|
|
|
93
101
|
|
|
94
102
|
const unitStamp = stampOf(unitFilesDeclaring(root, 'social').map(stat))
|
|
95
103
|
const unit = h.unit?.stamp === unitStamp ? h.unit : (h.unit = { stamp: unitStamp, value: await loadSocialUnit(root) })
|
|
104
|
+
return { h, config: h.config, ids, unit, stamps: [configStamp, idsStamp, unitStamp] }
|
|
105
|
+
}
|
|
96
106
|
|
|
107
|
+
/** the answer of `root` as it stands: rebuilt only for the parts whose stamp moved */
|
|
108
|
+
export async function deskWire(root: string): Promise<Answer> {
|
|
109
|
+
const { h, config, ids, unit, stamps } = await partsOf(root)
|
|
97
110
|
const today = dayOf(Date.now())
|
|
98
111
|
const social = join(root, LAYOUT.social)
|
|
99
|
-
const folder: string[] = [today,
|
|
112
|
+
const folder: string[] = [today, ...stamps]
|
|
100
113
|
tree(social, folder)
|
|
101
114
|
folder.push(stat(pushLog(root)))
|
|
102
115
|
for (const p of h.desk?.outside ?? []) folder.push(stat(p))
|
|
103
116
|
const deskStamp = stampOf(folder)
|
|
104
117
|
let desk = h.desk
|
|
105
118
|
if (desk?.stamp !== deskStamp) {
|
|
106
|
-
const value = loadDesk(root, ids.value, { speaksAs: config.value, unit: unit.value })
|
|
119
|
+
const value = loadDesk(root, ids.value, { speaksAs: config.value.speaksAs, unit: unit.value })
|
|
107
120
|
const outside = [...new Set(value.drafts.flatMap((d) => d.media.map((m) => m.path)).filter((p) => relative(social, p).startsWith('..')))]
|
|
108
121
|
desk = h.desk = { stamp: deskStamp, value, outside }
|
|
109
122
|
}
|
|
@@ -121,3 +134,31 @@ export async function deskAnswer(req: Request, root: string): Promise<Response>
|
|
|
121
134
|
const a = await deskWire(root)
|
|
122
135
|
return tagged(req, a.tag, () => a.text, a)
|
|
123
136
|
}
|
|
137
|
+
|
|
138
|
+
/** what Communications shows of the release being filled: `preview` null in a repo with no release files or no
|
|
139
|
+
* next.md, `error` when next.md does not parse */
|
|
140
|
+
export type NextReleaseView = { preview: NextRelease | null; error?: string }
|
|
141
|
+
|
|
142
|
+
/** next.md as the release that cuts it would stage it, kept while next.md, the rhythm and the parts stand */
|
|
143
|
+
export async function nextReleaseWire(root: string): Promise<Answer> {
|
|
144
|
+
const { h, config, unit, stamps } = await partsOf(root)
|
|
145
|
+
const stamp = stampOf([...stamps, stat(join(releasesDir(root), fileOf(NEXT))), stat(join(root, LAYOUT.social, 'rhythm.md'))])
|
|
146
|
+
if (h.next?.stamp === stamp) return h.next
|
|
147
|
+
let view: NextReleaseView = { preview: null }
|
|
148
|
+
if (config.value.releases) {
|
|
149
|
+
try {
|
|
150
|
+
view = { preview: await previewNextRelease(root, unit.value, { ...(config.value.speaksAs ? { speaksAs: config.value.speaksAs } : {}), identitiesDir: h.idsDir ?? null }) }
|
|
151
|
+
} catch (e) {
|
|
152
|
+
view = { preview: null, error: (e as Error).message }
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
const text = JSON.stringify(view)
|
|
156
|
+
h.next = { stamp, tag: `"${Bun.hash(text).toString(36)}"`, text }
|
|
157
|
+
return h.next
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/** `GET api/social/next-release.json`: 304 while the page holds the answer */
|
|
161
|
+
export async function nextReleaseAnswer(req: Request, root: string): Promise<Response> {
|
|
162
|
+
const a = await nextReleaseWire(root)
|
|
163
|
+
return tagged(req, a.tag, () => a.text, a)
|
|
164
|
+
}
|
|
@@ -248,10 +248,14 @@ export async function applyLayout(a: Account, o: { dry: boolean; prune: boolean
|
|
|
248
248
|
await act(`rename the category ${c.name} → ${cat.name}`, () => call(a, 'PATCH', `/channels/${id}`, json({ name: cat.name })))
|
|
249
249
|
}
|
|
250
250
|
place(c, CATEGORY, `the category ${cat.name}`)
|
|
251
|
+
// a dry run before its category exists: a channel the server already holds moves into it, never a new one
|
|
251
252
|
if (c == null) {
|
|
252
253
|
for (const def of cat.channels) {
|
|
253
|
-
|
|
254
|
-
|
|
254
|
+
const type = def.voice ? VOICE : TEXT
|
|
255
|
+
const ch = channels.find((x) => x.type === type && same(channelKey(x.name), def.name))
|
|
256
|
+
if (ch) kept.add(ch.id)
|
|
257
|
+
slot(type)
|
|
258
|
+
changes.push(ch ? `would set #${def.name} (${cat.name}): category` : `would create #${def.name} in ${cat.name}`)
|
|
255
259
|
}
|
|
256
260
|
continue
|
|
257
261
|
}
|
package/src/social/drafts.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { parseFrontmatter } from './md.ts'
|
|
|
8
8
|
|
|
9
9
|
/** the headings a draft holds besides its platforms */
|
|
10
10
|
const OWN = ['Angle', 'Posted'] as const
|
|
11
|
-
const OPTIONS = ['name', 'place', 'title', 'media', 'pin', 'outro', 'mark', 'tags'] as const
|
|
11
|
+
const OPTIONS = ['name', 'place', 'title', 'media', 'rating', 'pin', 'outro', 'mark', 'tags', 'tier'] as const
|
|
12
12
|
type Option = (typeof OPTIONS)[number]
|
|
13
13
|
/** the options whose value is one of a few words: a vertical's end and its watermark's corner, words a project reads */
|
|
14
14
|
const WORDS: Partial<Record<Option, readonly string[]>> = { outro: ['montage', 'short', 'none'], mark: ['left', 'right'] }
|
package/src/social/kinds.ts
CHANGED
|
@@ -21,8 +21,9 @@ export const KIND_FOR: Readonly<Record<PostKind, string>> = {
|
|
|
21
21
|
/** a shared kind's rules page, from the house wiki's root */
|
|
22
22
|
export const kindPage = (k: PostKind): string => `guides/post-kinds/post-kind-${k}.md`
|
|
23
23
|
|
|
24
|
-
/** the kind a staged draft takes from its source:
|
|
25
|
-
|
|
24
|
+
/** the kind a staged draft takes from its source: a card logs a step of the work, a release tells a version. A card is
|
|
25
|
+
* never a `feature` by default: no fact the house keeps says its change reaches users, so that is picked by hand */
|
|
26
|
+
export const sourceKind = (s: { review: string } | { release: string }): PostKind => ('review' in s ? 'iteration' : 'release')
|
|
26
27
|
|
|
27
28
|
/** a kind a project declares in its social unit: its id, what a post of it is for, its rules page from the repo's root */
|
|
28
29
|
export interface OwnKind {
|
package/src/social/load.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// message, each platform's part handed to its speaker's account; the rhythm; the load's errors. Read from the disk as
|
|
3
3
|
// it is on every call: the desks and `sk social` never hold a stale copy
|
|
4
4
|
import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs'
|
|
5
|
-
import { join, relative } from 'node:path'
|
|
5
|
+
import { join, relative, resolve, sep } from 'node:path'
|
|
6
6
|
import { LAYOUT } from '../core/layout.ts'
|
|
7
7
|
import { speakerOf, type Account, type Identities, type Identity } from '../identities/identities.ts'
|
|
8
8
|
import { isPostRating, POST_RATINGS, takes, type PostRating } from '../identities/rating.ts'
|
|
@@ -97,11 +97,15 @@ export type SocialPost = {
|
|
|
97
97
|
/** the heading's own text, as he writes it; `text` is it composed for the account */
|
|
98
98
|
body: string
|
|
99
99
|
tags: string[]
|
|
100
|
+
/** the tier it is posted at, its heading's `tier` else its account's open tier; empty on an account with no tiers */
|
|
101
|
+
tier: string
|
|
102
|
+
/** the heading names its tier; false, `tier` is the account's suggestion */
|
|
103
|
+
tierSet: boolean
|
|
100
104
|
/** X's links, out of its text: the first reply under the post; empty elsewhere */
|
|
101
105
|
reply: string
|
|
102
106
|
/** its write page takes the text (`{text}`); else « Open » copies it first */
|
|
103
107
|
prefilled: boolean
|
|
104
|
-
/** the draft's
|
|
108
|
+
/** its rating, its heading's own else the draft's: what a publisher labels it with */
|
|
105
109
|
rating: PostRating
|
|
106
110
|
/** why it may not go out: the repo's guard on its draft, or a place under its rating; empty, it may */
|
|
107
111
|
refused: string
|
|
@@ -175,10 +179,18 @@ const FORMATS = ['short', VERTICAL] as const
|
|
|
175
179
|
/** the name of a compiled vertical video */
|
|
176
180
|
export const VERTICAL_FILE = /-vertical\.mp4$/
|
|
177
181
|
|
|
178
|
-
/** what one message breaks on its account: a text past the account's max,
|
|
179
|
-
|
|
182
|
+
/** what one message breaks on its account: a text past the account's max, more tags than its `max tags`, a tier its
|
|
183
|
+
* account has not, a `## vertical` message without its video */
|
|
184
|
+
export function messageErrors(
|
|
185
|
+
post: Pick<SocialPost, 'file' | 'from' | 'length' | 'media' | 'tags' | 'tier'>,
|
|
186
|
+
a: Pick<Account, 'name' | 'max' | 'maxTags' | 'tiers'>,
|
|
187
|
+
): string[] {
|
|
180
188
|
const out: string[] = []
|
|
181
189
|
if (a.max !== null && post.length > a.max) out.push(`${post.file}: ## ${post.from} is ${post.length} on ${a.name}, over its ${a.max}`)
|
|
190
|
+
if (a.maxTags !== null && post.tags.length > a.maxTags)
|
|
191
|
+
out.push(`${post.file}: ## ${post.from} has ${post.tags.length} tags on ${a.name}, over its ${a.maxTags}`)
|
|
192
|
+
if (post.tier !== '' && !a.tiers.includes(post.tier))
|
|
193
|
+
out.push(`${post.file}: ## ${post.from} tier "${post.tier}" is none of ${a.name}'s: ${a.tiers.join(', ') || 'it has no tiers'}`)
|
|
182
194
|
if (post.from.split('/')[0] === VERTICAL && !VERTICAL_FILE.test(post.media?.name ?? ''))
|
|
183
195
|
out.push(`${post.file}: ## ${post.from} goes to ${a.name} without its vertical video (media: media/<name>-vertical.mp4)`)
|
|
184
196
|
return out
|
|
@@ -323,12 +335,14 @@ export function loadDesk(root: string, ids: Identities, o: { speaksAs?: string |
|
|
|
323
335
|
}
|
|
324
336
|
for (const { s, a, key, from } of sends) {
|
|
325
337
|
// a place belongs to its account: a group's message lands on the account's own place, or the first that
|
|
326
|
-
// takes the
|
|
338
|
+
// takes the message's rating; an account's own heading names its place, which must take it. A heading's own
|
|
339
|
+
// `rating` is its message's (a release's nsfw picture on the venue that takes it), else the draft's
|
|
340
|
+
const rating = s.options.rating === undefined ? draft.rating : ratingOf(s.options.rating, false, speaker.name, `${file} ## ${s.key}`, errors)
|
|
327
341
|
const places = placesFor(a)
|
|
328
342
|
let place = s.options.place ?? ''
|
|
329
343
|
let refused = ''
|
|
330
344
|
if (from !== key) {
|
|
331
|
-
const l = landing(a, places,
|
|
345
|
+
const l = landing(a, places, rating)
|
|
332
346
|
if ('skip' in l) {
|
|
333
347
|
draft.skipped.push({ account: a.id, why: l.skip })
|
|
334
348
|
continue
|
|
@@ -336,8 +350,8 @@ export function loadDesk(root: string, ids: Identities, o: { speaksAs?: string |
|
|
|
336
350
|
place = l.place
|
|
337
351
|
} else {
|
|
338
352
|
const ceiling = ceilingAt(a, places, place)
|
|
339
|
-
if (ceiling != null && !takes(ceiling,
|
|
340
|
-
refused = `## ${key} goes to ${place || 'its profile'} on ${a.name}, which takes ${ceiling}, and the draft is ${
|
|
353
|
+
if (ceiling != null && !takes(ceiling, rating)) {
|
|
354
|
+
refused = `## ${key} goes to ${place || 'its profile'} on ${a.name}, which takes ${ceiling}, and ${s.options.rating === undefined ? 'the draft' : 'its message'} is ${rating}`
|
|
341
355
|
errors.push(`${file}: ${refused}`)
|
|
342
356
|
}
|
|
343
357
|
}
|
|
@@ -365,6 +379,8 @@ export function loadDesk(root: string, ids: Identities, o: { speaksAs?: string |
|
|
|
365
379
|
text: made.text,
|
|
366
380
|
body: s.text,
|
|
367
381
|
tags,
|
|
382
|
+
tier: s.options.tier ?? a.tiers[0] ?? '',
|
|
383
|
+
tierSet: s.options.tier !== undefined,
|
|
368
384
|
reply: made.reply,
|
|
369
385
|
length: messageLength(a.id, made.text),
|
|
370
386
|
media: (s.options.media == null ? ownMedia : pick(s.options.media))[0] ?? null,
|
|
@@ -375,7 +391,7 @@ export function loadDesk(root: string, ids: Identities, o: { speaksAs?: string |
|
|
|
375
391
|
pin: s.options.pin === 'true',
|
|
376
392
|
from,
|
|
377
393
|
footer,
|
|
378
|
-
rating
|
|
394
|
+
rating,
|
|
379
395
|
refused,
|
|
380
396
|
}
|
|
381
397
|
errors.push(...messageErrors(post, a))
|
|
@@ -420,6 +436,23 @@ export function accountOf(desk: Desk, identity: string, account: string): DeskAc
|
|
|
420
436
|
return a
|
|
421
437
|
}
|
|
422
438
|
|
|
439
|
+
/** a draft by what a command was given: its folder's name, its topic, or its path (relative to `cwd` or absolute, a
|
|
440
|
+
* trailing slash or its `draft.md` alike); a path outside the drafts folder is refused */
|
|
441
|
+
export function findDraft(desk: Desk, ref: string, cwd: string): Draft {
|
|
442
|
+
const where = `${LAYOUT.social}/drafts/`
|
|
443
|
+
let name = ref
|
|
444
|
+
if (ref.includes('/') || ref.endsWith('.md') || ref === '.') {
|
|
445
|
+
const parts = relative(draftsDir(desk.root), resolve(cwd, ref)).split(sep).filter((x) => x !== '')
|
|
446
|
+
if (parts.length === 2 && parts[1]!.endsWith('.md')) parts.pop()
|
|
447
|
+
if (parts.length !== 1 || parts[0] === '..') throw new Error(`${ref} is no draft of ${where}: a draft is a folder right under it`)
|
|
448
|
+
name = parts[0]!
|
|
449
|
+
}
|
|
450
|
+
const hits = desk.drafts.filter((x) => x.slug === name || x.slug.replace(/^\d{8}-\d{6}-/, '') === name)
|
|
451
|
+
if (hits.length > 1) throw new Error(`"${ref}" is the topic of ${hits.length} drafts: ${hits.map((x) => x.slug).join(', ')}; give its folder's name`)
|
|
452
|
+
if (hits[0] == null) throw new Error(`no draft "${ref}" in ${where}: give its folder's name, its topic or its path`)
|
|
453
|
+
return hits[0]
|
|
454
|
+
}
|
|
455
|
+
|
|
423
456
|
/** one message of a draft by its key, `<account>` or `<account>/<name>` */
|
|
424
457
|
export function draftPost(desk: Desk, slug: string, key: string): SocialPost {
|
|
425
458
|
const d = desk.drafts.find((x) => x.slug === slug)
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
// the accounts shipkit posts to itself (`automation: live`): one publisher a platform, the desk's « Publish », and
|
|
2
|
-
// `sk social post --publish`, every waiting message of a draft on its live accounts (`--only` one of them)
|
|
2
|
+
// `sk social post --publish`, every waiting message of a draft on its live accounts (`--only` one of them), `--edit` a
|
|
3
|
+
// posted one sent again at its link where the venue edits in place
|
|
3
4
|
import { accountOf, draftPost, type Desk } from '../load.ts'
|
|
4
5
|
import { setPosted } from '../writes.ts'
|
|
5
6
|
import { postBluesky } from './bluesky.ts'
|
|
6
7
|
import { postDiscord } from './discord.ts'
|
|
8
|
+
import { secretsAs } from './secret.ts'
|
|
7
9
|
import type { Account } from '../../identities/identities.ts'
|
|
8
10
|
import type { SocialPost } from '../load.ts'
|
|
9
11
|
|
|
@@ -14,6 +16,17 @@ const PUBLISHERS: Publishers = {
|
|
|
14
16
|
bluesky: postBluesky,
|
|
15
17
|
}
|
|
16
18
|
|
|
19
|
+
/** the messages `--only` keeps: a message's key (`discord`, `discord/nsfw`) that one alone, else an account's every
|
|
20
|
+
* message. So a release's `--only discord` posts its #announcements message, never the nsfw one beside it */
|
|
21
|
+
export function onlyOf<P extends Pick<SocialPost, 'key' | 'platform'>>(posts: readonly P[], only: string | undefined): P[] {
|
|
22
|
+
if (only == null) return [...posts]
|
|
23
|
+
const one = posts.filter((p) => p.key === only)
|
|
24
|
+
return one.length > 0 ? one : posts.filter((p) => p.platform === only)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** the venues whose publisher edits a posted message at its link; any other refuses a second send */
|
|
28
|
+
const EDITS_IN_PLACE: ReadonlySet<string> = new Set(['discord'])
|
|
29
|
+
|
|
17
30
|
/** posts one message of a draft and records its link; the files written. `publishers` is a test's stub */
|
|
18
31
|
export async function publish(desk: Desk, slug: string, key: string, publishers: Publishers = PUBLISHERS): Promise<{ url: string; files: string[] }> {
|
|
19
32
|
const post = draftPost(desk, slug, key)
|
|
@@ -22,28 +35,32 @@ export async function publish(desk: Desk, slug: string, key: string, publishers:
|
|
|
22
35
|
const run = publishers[post.platform]
|
|
23
36
|
if (run == null) throw new Error(`${post.platform}: nothing posts there by itself`)
|
|
24
37
|
if (a.automation !== 'live') throw new Error(`${a.file}: its automation is not live`)
|
|
25
|
-
if (post.posted !== '' && post.platform
|
|
26
|
-
|
|
38
|
+
if (post.posted !== '' && !EDITS_IN_PLACE.has(post.platform)) throw new Error(`${slug} is already posted on ${a.name}: ${post.posted}`)
|
|
39
|
+
// the hub runs in the house's folder: the token is read as the draft's repo
|
|
40
|
+
const url = await secretsAs(desk.root, () => run(a, post))
|
|
27
41
|
return { url, files: url === post.posted ? [] : setPosted(desk, slug, key, url) }
|
|
28
42
|
}
|
|
29
43
|
|
|
30
44
|
/** each waiting message of a draft on a live account posted, the others named as waiting for his paste; `only` keeps
|
|
31
|
-
* one account's
|
|
45
|
+
* one account's, `edit` sends a posted one again as an edit where its venue edits in place. `before` brings a media
|
|
46
|
+
* the disk let go back first */
|
|
32
47
|
export async function publishDraft(
|
|
33
48
|
desk: Desk,
|
|
34
49
|
slug: string,
|
|
35
|
-
o: { only?: string; publishers?: Publishers; before?: (p: SocialPost) => Promise<void> } = {},
|
|
50
|
+
o: { only?: string; edit?: boolean; publishers?: Publishers; before?: (p: SocialPost) => Promise<void> } = {},
|
|
36
51
|
): Promise<{ key: string; line: string }[]> {
|
|
37
52
|
const d = desk.drafts.find((x) => x.slug === slug)
|
|
38
53
|
if (d == null) throw new Error(`no draft ${slug}`)
|
|
39
54
|
const out: { key: string; line: string }[] = []
|
|
40
|
-
for (const p of d.posts
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
55
|
+
for (const p of onlyOf(d.posts, o.only)) {
|
|
56
|
+
const a = accountOf(desk, p.identity, p.platform)
|
|
57
|
+
const live = a.automation === 'live'
|
|
58
|
+
if (p.posted !== '' && !o.edit) out.push({ key: p.key, line: `already posted, ${p.posted}${live && EDITS_IN_PLACE.has(p.platform) ? ' (--edit sends its text again at its link)' : ''}` })
|
|
59
|
+
else if (p.posted !== '' && !EDITS_IN_PLACE.has(p.platform)) out.push({ key: p.key, line: `already posted, ${p.posted}: ${a.name} cannot edit a post in place, nothing sent` })
|
|
60
|
+
else if (!live) out.push({ key: p.key, line: p.posted !== '' ? `already posted, ${p.posted}: ${a.file} is not automation: live, edit it by hand` : 'waits for his paste' })
|
|
44
61
|
else {
|
|
45
62
|
await o.before?.(p)
|
|
46
|
-
out.push({ key: p.key, line:
|
|
63
|
+
out.push({ key: p.key, line: `${p.posted !== '' ? 'edited at its link' : 'posted'}, ${(await publish(desk, slug, p.key, o.publishers)).url}` })
|
|
47
64
|
}
|
|
48
65
|
}
|
|
49
66
|
return out
|
|
@@ -1,13 +1,21 @@
|
|
|
1
|
-
// an account's token, read through the house config's `credsReadCommand`: a missing one fails loud with where it is named
|
|
1
|
+
// an account's token, read through the house config's `credsReadCommand`: a missing one fails loud with where it is named.
|
|
2
|
+
// It reads as the repo that posts: the hub runs in the house's folder, so `secretsAs` names the draft's repo
|
|
3
|
+
import { AsyncLocalStorage } from 'node:async_hooks'
|
|
2
4
|
import { readSecret } from '../../smoke/run-smoke.ts'
|
|
3
5
|
|
|
6
|
+
const postingRepo = new AsyncLocalStorage<string>()
|
|
7
|
+
|
|
8
|
+
/** `run`, its token reads made as the repo at `root` */
|
|
9
|
+
export const secretsAs = <T>(root: string, run: () => Promise<T>): Promise<T> => postingRepo.run(root, run)
|
|
10
|
+
|
|
4
11
|
export async function secret(name: string, where: string): Promise<string> {
|
|
5
12
|
if (name === '') throw new Error(`no token named: ${where} names no secret`)
|
|
13
|
+
const cwd = postingRepo.getStore() ?? process.cwd()
|
|
6
14
|
const { houseRootOf } = await import('../../home/home-start.ts')
|
|
7
15
|
const { loadRepoConfig } = await import('../../repo-config.ts')
|
|
8
|
-
const house = houseRootOf(
|
|
9
|
-
if (!house) throw new Error(`no house repo seen from ${
|
|
16
|
+
const house = houseRootOf(cwd)
|
|
17
|
+
if (!house) throw new Error(`no house repo seen from ${cwd} to read the token ${name} (${where})`)
|
|
10
18
|
const c = await loadRepoConfig(house)
|
|
11
19
|
if (!c.credsReadCommand) throw new Error(`the house config (${house}) declares no credsReadCommand to read ${name} (${where})`)
|
|
12
|
-
return readSecret(c.credsReadCommand, name)
|
|
20
|
+
return readSecret(c.credsReadCommand, name, 'get', cwd)
|
|
13
21
|
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// the picture of a release post (wiki tools/shipkit/social.md, The release card): the identity kit draws it from the
|
|
2
|
+
// repo's brand (renderReleaseCard), beside the release's first safe still, else as the poster. Only a safe picture is
|
|
3
|
+
// ever its feature: the card goes first in a draft every venue attaches, the safe ones included
|
|
4
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'
|
|
5
|
+
import { join } from 'node:path'
|
|
6
|
+
import { renderReleaseCard } from '../assets/kits/identity-kit.ts'
|
|
7
|
+
import { LAYOUT } from '../core/layout.ts'
|
|
8
|
+
import { localPicture } from '../releases/pictures.ts'
|
|
9
|
+
import { changesOf, isClip, shotFor, type Change, type Release } from '../releases/model.ts'
|
|
10
|
+
|
|
11
|
+
export type CardAsk = {
|
|
12
|
+
version: string
|
|
13
|
+
/** the release's file, when the repo keeps one: its title, changes and safe pictures */
|
|
14
|
+
release: Release | null
|
|
15
|
+
/** the headline when the file gives none: the notes' first line */
|
|
16
|
+
fallback?: string
|
|
17
|
+
/** a SAFE still beside the brand, a file; null, the poster; unset, the file's first safe still */
|
|
18
|
+
feature?: string | null
|
|
19
|
+
headline?: string
|
|
20
|
+
/** where the feature's subject sits across it, 0 to 1 */
|
|
21
|
+
focus?: number
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export type Card = {
|
|
25
|
+
/** the rendered png, in the repo's scratch */
|
|
26
|
+
file: string
|
|
27
|
+
/** its name in a draft, without the extension */
|
|
28
|
+
name: string
|
|
29
|
+
headline: string
|
|
30
|
+
/** the still beside the brand; null, the poster */
|
|
31
|
+
feature: string | null
|
|
32
|
+
alt: string
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** the release's first safe still and the change it shows: a clip never stands in a still picture */
|
|
36
|
+
async function firstSafeStill(root: string, release: Release): Promise<{ file: string; change: Change } | null> {
|
|
37
|
+
for (const change of changesOf(release)) {
|
|
38
|
+
const s = shotFor(change, 'safe')
|
|
39
|
+
if (s && !isClip(s.picture.url)) return { file: await localPicture(root, s.picture.url), change }
|
|
40
|
+
}
|
|
41
|
+
return null
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** the card of a release, rendered into `.shipkit/tmp/release-cards/`; null in a repo with no brand. Its headline: the
|
|
45
|
+
* one asked, else the file's title, else the title of the change its feature shows, else the first change's, else
|
|
46
|
+
* the fallback */
|
|
47
|
+
export async function releaseCard(root: string, ask: CardAsk): Promise<Card | null> {
|
|
48
|
+
const { loadBrand, identityLogo } = await import('../assets/run-assets.ts')
|
|
49
|
+
const brand = await loadBrand(root)
|
|
50
|
+
if (brand == null) return null
|
|
51
|
+
if (typeof brand === 'string') throw new Error(brand)
|
|
52
|
+
if (ask.feature && !existsSync(ask.feature)) throw new Error(`no feature ${ask.feature}`)
|
|
53
|
+
const shown = ask.feature !== undefined ? (ask.feature ? { file: ask.feature, change: null } : null) : ask.release ? await firstSafeStill(root, ask.release) : null
|
|
54
|
+
const first = ask.release ? changesOf(ask.release)[0] : undefined
|
|
55
|
+
const headline = (ask.headline ?? (ask.release?.title || shown?.change?.title || first?.title || ask.fallback || '')).replace(/\s+/g, ' ').trim()
|
|
56
|
+
const logo = await identityLogo(root)
|
|
57
|
+
const png = await renderReleaseCard(
|
|
58
|
+
brand,
|
|
59
|
+
root,
|
|
60
|
+
{ version: ask.version, headline, feature: shown ? readFileSync(shown.file) : null, ...(ask.focus !== undefined ? { focus: ask.focus } : {}) },
|
|
61
|
+
logo ? { markFile: join(root, logo) } : {},
|
|
62
|
+
)
|
|
63
|
+
const dir = join(root, LAYOUT.tmp, 'release-cards')
|
|
64
|
+
mkdirSync(dir, { recursive: true })
|
|
65
|
+
const name = `release-${ask.version}`
|
|
66
|
+
const file = join(dir, `${name}.png`)
|
|
67
|
+
writeFileSync(file, png)
|
|
68
|
+
return { file, name, headline, feature: shown?.file ?? null, alt: `${brand.name} ${ask.version}${headline ? `: ${headline}` : ''}` }
|
|
69
|
+
}
|