rvlib-shipkit 2.19.0 → 2.21.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 +32 -0
- package/package.json +1 -1
- package/src/annex/annex.ts +227 -0
- package/src/annex/offload.ts +279 -0
- package/src/checks/SK004-gitignore-policy.check.ts +6 -3
- package/src/checks/SK040-release-words.check.ts +43 -0
- package/src/checks/SK041-annex-links.check.ts +28 -0
- package/src/checks/SK042-post-kinds.check.ts +73 -0
- package/src/cli/cmd_Annex.ts +179 -0
- package/src/cli/cmd_Commands.ts +4 -1
- package/src/cli/cmd_GlobalProcesses.ts +2 -107
- package/src/cli/cmd_Home.ts +4 -3
- package/src/cli/cmd_Messages.ts +155 -0
- package/src/cli/cmd_Overview.ts +2 -1
- package/src/cli/cmd_Releases.ts +84 -0
- package/src/cli/cmd_Review.ts +176 -12
- package/src/cli/cmd_Shot.ts +4 -4
- package/src/cli/cmd_Social.ts +151 -8
- package/src/cli/cmd_Sound.ts +17 -4
- package/src/cli/cmd_Trailer.ts +67 -1
- package/src/cli/family-pages.ts +2 -0
- package/src/cli/kit/index.ts +1 -1
- package/src/cli/kit/verb.ts +11 -3
- package/src/cli/registry.ts +7 -1
- package/src/collections/collection-types.ts +8 -1
- package/src/collections/providers.ts +4 -1
- package/src/collections/review.ts +23 -4
- package/src/commands/model.ts +36 -0
- package/src/commands/registry.ts +49 -0
- package/src/commands/routes.ts +59 -0
- package/src/commands/runner.ts +35 -0
- package/src/commands/runs.ts +112 -0
- package/src/core/app-icon.ts +4 -3
- package/src/core/icon-type.ts +8 -0
- package/src/core/jobs.ts +4 -3
- package/src/core/layout.ts +11 -2
- package/src/core/squircle.ts +95 -0
- package/src/home/daemon-jobs.ts +26 -2
- package/src/home/global-units.ts +3 -0
- package/src/home/gui-app/ShipkitGui.swift +337 -5
- package/src/home/gui-app.ts +64 -33
- package/src/home/hmr-keep.ts +134 -0
- package/src/home/home-start.ts +2 -2
- package/src/home/lib-watch.ts +21 -11
- package/src/home/pm-switch.ts +112 -0
- package/src/home/pm.ts +1 -1
- package/src/home/process-apps.ts +181 -0
- package/src/home/resources.ts +3 -3
- package/src/home/run-web.ts +7 -4
- package/src/home/serve-web.ts +64 -14
- package/src/identities/collection.ts +49 -0
- package/src/identities/identities.ts +121 -14
- package/src/identities/machine.ts +4 -3
- package/src/identities/rating.ts +33 -0
- package/src/identities/shown.ts +170 -0
- package/src/identities/steps.ts +5 -0
- package/src/media-store/purge.ts +15 -1
- package/src/media-store/remote.ts +22 -6
- package/src/messages/brief.ts +117 -0
- package/src/messages/collection.ts +40 -0
- package/src/messages/model.ts +171 -0
- package/src/messages/routes.ts +15 -0
- package/src/messages/score.ts +182 -0
- package/src/messages/tabs.ts +13 -0
- package/src/release/notes.ts +130 -0
- package/src/release/run-bump.ts +41 -18
- package/src/release/run-release.ts +22 -4
- package/src/release/run-releases.ts +17 -15
- package/src/release/unit-resolve.ts +9 -0
- package/src/releases/add.ts +94 -0
- package/src/releases/before.ts +31 -0
- package/src/releases/collection.ts +36 -0
- package/src/releases/from-card.ts +151 -0
- package/src/releases/model.ts +327 -0
- package/src/releases/pictures.ts +110 -0
- package/src/releases/routes.ts +36 -0
- package/src/releases/store.ts +71 -0
- package/src/repo-config.ts +5 -0
- package/src/review/cells.ts +0 -11
- package/src/review/format.ts +10 -6
- package/src/review/http.ts +1 -1
- package/src/review/model.ts +102 -3
- package/src/review/notes.ts +2 -48
- package/src/review/routes.ts +28 -10
- package/src/review/stage-card.ts +197 -0
- package/src/review/stage-routes.ts +123 -0
- package/src/review/store.ts +47 -1
- package/src/review/trailer-card.ts +99 -0
- package/src/review/trailer-desk.ts +76 -4
- package/src/review/trailer-model.ts +106 -7
- package/src/review/trailer-notes.ts +45 -0
- package/src/review/trailer-routes.ts +119 -13
- package/src/review/trailer-voices.ts +144 -0
- package/src/review/watchers.ts +58 -1
- package/src/serve/hub-app/app-bridge.ts +71 -0
- package/src/serve/hub-app/benign-errors.ts +22 -0
- package/src/serve/hub-app/commands/commands-page.tsx +122 -0
- package/src/serve/hub-app/commands/commands-st.ts +177 -0
- package/src/serve/hub-app/commands.css +24 -0
- package/src/serve/hub-app/hash-route.ts +59 -8
- package/src/serve/hub-app/home-st.ts +19 -2
- package/src/serve/hub-app/home.html +3 -0
- package/src/serve/hub-app/hub-app.tsx +8 -0
- package/src/serve/hub-app/icons.tsx +5 -0
- package/src/serve/hub-app/identities-view.tsx +4 -1
- package/src/serve/hub-app/identities.css +1 -0
- package/src/serve/hub-app/index.html +3 -0
- package/src/serve/hub-app/keys.ts +2 -2
- package/src/serve/hub-app/machine-st.ts +41 -10
- package/src/serve/hub-app/messages/messages-page.tsx +354 -0
- package/src/serve/hub-app/messages/messages-st.ts +74 -0
- package/src/serve/hub-app/messages.css +35 -0
- package/src/serve/hub-app/project-list.css +7 -2
- package/src/serve/hub-app/project-list.tsx +9 -0
- package/src/serve/hub-app/projects-svc.ts +16 -6
- package/src/serve/hub-app/releases/releases-page.tsx +187 -0
- package/src/serve/hub-app/releases/releases-st.ts +111 -0
- package/src/serve/hub-app/releases.css +52 -0
- package/src/serve/hub-app/repo-sections.ts +16 -2
- package/src/serve/hub-app/repo-st.ts +66 -10
- package/src/serve/hub-app/review/clip-st.ts +34 -4
- package/src/serve/hub-app/review/kit.tsx +3 -3
- package/src/serve/hub-app/review/note-place.ts +31 -0
- package/src/serve/hub-app/review/review-cells.tsx +27 -3
- package/src/serve/hub-app/review/review-st.ts +77 -2
- package/src/serve/hub-app/review/review-thread.tsx +9 -31
- package/src/serve/hub-app/review/review-views.tsx +164 -58
- package/src/serve/hub-app/review/thread-st.ts +108 -41
- package/src/serve/hub-app/review/trailer-card.tsx +187 -0
- package/src/serve/hub-app/review/trailer-page.tsx +92 -36
- package/src/serve/hub-app/review/trailer-st.ts +306 -34
- package/src/serve/hub-app/review/trailer-timeline.tsx +68 -23
- 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 +137 -6
- package/src/serve/hub-app/social/comms-page.tsx +65 -28
- package/src/serve/hub-app/social/identity-pictures.ts +46 -8
- package/src/serve/hub-app/social/kit.tsx +9 -6
- package/src/serve/hub-app/social/next-release.tsx +118 -0
- package/src/serve/hub-app/social/post-card.tsx +10 -2
- package/src/serve/hub-app/social/social-model.ts +39 -3
- package/src/serve/hub-app/social/social-page.tsx +179 -65
- package/src/serve/hub-app/social/social-st.ts +117 -27
- package/src/serve/hub-app/social/stage-popup.tsx +268 -0
- package/src/serve/hub-app/social/stage-st.ts +310 -0
- package/src/serve/hub-app/social/step-layout.ts +42 -0
- package/src/serve/hub-app/social.css +68 -1
- package/src/serve/hub-app/tree-build.ts +40 -1
- package/src/serve/hub-app/tree-svc.ts +10 -3
- package/src/serve/project-gutter-route.ts +12 -2
- package/src/serve/project-gutter.ts +4 -2
- package/src/serve/same-origin.ts +24 -1
- package/src/serve/serve-hub.ts +15 -1
- package/src/shipkit-files.ts +9 -7
- package/src/shot/box.ts +33 -12
- package/src/shot/client.ts +1 -1
- package/src/shot/shooter.ts +22 -12
- package/src/shot/shot-ask.ts +14 -3
- package/src/shot/shot.shipkit.ts +1 -1
- package/src/social/desk-index.ts +49 -8
- package/src/social/discord-layout.ts +54 -7
- package/src/social/drafts.ts +1 -1
- package/src/social/fit.ts +84 -0
- package/src/social/identity-words.ts +74 -0
- package/src/social/kind-pages.ts +41 -0
- package/src/social/kinds.ts +93 -0
- package/src/social/load.ts +125 -10
- package/src/social/media-limit.ts +63 -2
- package/src/social/presence.ts +1 -1
- package/src/social/publish/bluesky.ts +58 -19
- package/src/social/publish/index.ts +47 -6
- package/src/social/reach.ts +49 -0
- package/src/social/release-stage.ts +277 -0
- package/src/social/routes.ts +44 -8
- package/src/social/stage.ts +246 -0
- package/src/social/strip.ts +85 -0
- package/src/social/text.ts +6 -2
- package/src/social/unit.ts +57 -1
- package/src/social/writes.ts +11 -0
- package/src/trailer/bed.ts +111 -0
- package/src/trailer/build.ts +72 -40
- package/src/trailer/ffmpeg.ts +6 -0
- package/src/trailer/grammar.ts +37 -6
- package/src/trailer/graph.ts +12 -1
- package/src/trailer/public-words.ts +41 -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
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// check context, so a check reading units stays keyed on what it read.
|
|
4
4
|
import { basename, isAbsolute, join, relative } from 'path'
|
|
5
5
|
import type { CheckCtx } from '../core/check-ctx.ts'
|
|
6
|
+
import { LAYOUT } from '../core/layout.ts'
|
|
6
7
|
import type { RepoConfig } from '../repo-config.ts'
|
|
7
8
|
import type { TestsConfig } from '../suite/judge-suites.ts'
|
|
8
9
|
|
|
@@ -90,6 +91,9 @@ export type ReleaseUnit = {
|
|
|
90
91
|
version: string
|
|
91
92
|
/** absolute path to the versioned changelog */
|
|
92
93
|
changelog: string
|
|
94
|
+
/** the root unit's release files (`.shipkit/releases/`), absolute, when the folder exists: then its notes are those
|
|
95
|
+
* files and CHANGELOG.md is made from them (releases/model.ts); null for a sub-unit and for a repo without one */
|
|
96
|
+
releases: string | null
|
|
93
97
|
/** tag template, `{name}` and `{version}` unsubstituted — bump renders the NEXT tag from it */
|
|
94
98
|
tagTemplate: string
|
|
95
99
|
/** rendered tag for the current version */
|
|
@@ -168,6 +172,7 @@ export function resolveUnits(root: string, config: RepoConfig, io: UnitReader):
|
|
|
168
172
|
undeclaredFix: 'add `release: { npm: true }` to repo.config.ts to publish it',
|
|
169
173
|
githubRelease: rc.githubRelease ?? true,
|
|
170
174
|
tsconfigRel: rc.tsconfig,
|
|
175
|
+
releases: rc.releases === true,
|
|
171
176
|
checkFolderName: false,
|
|
172
177
|
io,
|
|
173
178
|
})
|
|
@@ -205,6 +210,7 @@ export function resolveUnits(root: string, config: RepoConfig, io: UnitReader):
|
|
|
205
210
|
undeclaredFix: 'add `npm: true` to this units[] entry to publish it',
|
|
206
211
|
githubRelease: decl.githubRelease ?? false,
|
|
207
212
|
tsconfigRel: decl.tsconfig,
|
|
213
|
+
releases: false,
|
|
208
214
|
// only the DEFAULT tag renders the package name into a git tag, so
|
|
209
215
|
// only there does the folder have to agree with it
|
|
210
216
|
checkFolderName: decl.tag == null,
|
|
@@ -229,6 +235,8 @@ function build(p: {
|
|
|
229
235
|
undeclaredFix: string
|
|
230
236
|
githubRelease: boolean
|
|
231
237
|
tsconfigRel: string | undefined
|
|
238
|
+
/** the root's notes are the release files (`release.releases`) */
|
|
239
|
+
releases: boolean
|
|
232
240
|
checkFolderName: boolean
|
|
233
241
|
io: UnitReader
|
|
234
242
|
}): { unit: ReleaseUnit } | { error: UnitError[] } {
|
|
@@ -265,6 +273,7 @@ function build(p: {
|
|
|
265
273
|
name,
|
|
266
274
|
version,
|
|
267
275
|
changelog: join(p.root, p.changelogRel),
|
|
276
|
+
releases: p.releases ? join(p.root, LAYOUT.releases) : null,
|
|
268
277
|
tagTemplate: p.tagTemplate,
|
|
269
278
|
tag: render(p.tagTemplate, { name, version }),
|
|
270
279
|
tagGlob: render(p.tagTemplate, { name, version: '*' }),
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
// `sk releases add`: one change of next.md written by hand, or a card's change written again (wiki tools/shipkit/units.md,
|
|
2
|
+
// The release files). What a hand does not give is kept from the change it replaces; the repo's guard reads every word
|
|
3
|
+
// before the file holds it, and the write is committed by pathspec
|
|
4
|
+
import { itemOfRef, storeDir } from '../review/store.ts'
|
|
5
|
+
import { publicProblems } from '../social/unit.ts'
|
|
6
|
+
import { commitPaths } from '../social/writes.ts'
|
|
7
|
+
import { isPostRating, POST_RATINGS, type PostRating } from '../identities/rating.ts'
|
|
8
|
+
import { cardParts, versionsOf, withShot } from './from-card.ts'
|
|
9
|
+
import { changesOf, emptyRelease, isClip, NEXT, type Change, type ReleaseKind, type Shot } from './model.ts'
|
|
10
|
+
import { keepPicture } from './pictures.ts'
|
|
11
|
+
import { addChange, readRelease, undeclaredReleases, writeRelease } from './store.ts'
|
|
12
|
+
|
|
13
|
+
export interface AddAsk {
|
|
14
|
+
category?: string
|
|
15
|
+
title?: string
|
|
16
|
+
text?: string
|
|
17
|
+
bullets?: string[]
|
|
18
|
+
image?: string
|
|
19
|
+
/** a still of what it looked like before, the tab beside its picture */
|
|
20
|
+
before?: string
|
|
21
|
+
/** the rating of the shot it writes; with no new picture, of the change's one unrated shot */
|
|
22
|
+
rating?: string
|
|
23
|
+
card?: string
|
|
24
|
+
commit?: string
|
|
25
|
+
kind?: string
|
|
26
|
+
heading?: string
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const KINDS: readonly string[] = ['major', 'minor', 'patch']
|
|
30
|
+
|
|
31
|
+
async function guarded(root: string, what: string, texts: string[]): Promise<void> {
|
|
32
|
+
const problems = await publicProblems(root, { texts: texts.filter((t) => t.trim() !== '') })
|
|
33
|
+
if (problems.length > 0) throw new Error(`${what}: the repo's guard refuses it: ${problems.join('; ')}`)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** next.md written with the ask: its kind and title, and one change; the file written */
|
|
37
|
+
export async function addByHand(root: string, a: AddAsk): Promise<string> {
|
|
38
|
+
if (a.kind !== undefined && !KINDS.includes(a.kind)) throw new Error(`--kind ${a.kind}: major, minor or patch`)
|
|
39
|
+
if (a.rating !== undefined && !isPostRating(a.rating)) throw new Error(`--rating ${a.rating}: one of ${POST_RATINGS.join(', ')}`)
|
|
40
|
+
const rating = (a.rating as PostRating | undefined) ?? null
|
|
41
|
+
const change = a.category !== undefined || a.title !== undefined || a.card !== undefined
|
|
42
|
+
if (!change && a.kind === undefined && a.heading === undefined) throw new Error('nothing to write: a change (a category and a title, or --card), or --kind, or --release-title')
|
|
43
|
+
const why = await undeclaredReleases(root)
|
|
44
|
+
if (why) throw new Error(why)
|
|
45
|
+
let file: string | null = null
|
|
46
|
+
if (a.kind !== undefined || a.heading !== undefined) {
|
|
47
|
+
if (a.heading) await guarded(root, '--release-title', [a.heading])
|
|
48
|
+
const next = readRelease(root, NEXT) ?? emptyRelease()
|
|
49
|
+
file = writeRelease(root, { ...next, ...(a.kind ? { kind: a.kind as ReleaseKind } : {}), ...(a.heading !== undefined ? { title: a.heading.trim() } : {}) })
|
|
50
|
+
}
|
|
51
|
+
if (change) {
|
|
52
|
+
const x = a.card !== undefined ? itemOfRef(storeDir(root), a.card) : null
|
|
53
|
+
if (a.card !== undefined && !x) throw new Error(`--card ${a.card}: no such card`)
|
|
54
|
+
// the card's own line, when it has one, unless the hand names its own
|
|
55
|
+
const line = x ? versionsOf(storeDir(root), x).find((v) => v.changelog)?.changelog : undefined
|
|
56
|
+
const category = a.category ?? line?.category
|
|
57
|
+
const title = a.title ?? line?.line
|
|
58
|
+
if (category === undefined || title === undefined) throw new Error(x ? `--card ${a.card}: the card has no changelog line; name the category and the title` : 'a change by hand names its category and its title')
|
|
59
|
+
const next = readRelease(root, NEXT)
|
|
60
|
+
const given = x ? versionsOf(storeDir(root), x).at(-1)!.id : null
|
|
61
|
+
// the change of the same card, else of the same title: what the hand does not give, the card included, is kept
|
|
62
|
+
const all = next ? changesOf(next) : []
|
|
63
|
+
const had = (given != null ? all.find((ch) => ch.card === given) : undefined) ?? all.find((ch) => ch.title === title)
|
|
64
|
+
const c: Change = { title, text: a.text ?? had?.text ?? '', bullets: a.bullets ?? had?.bullets ?? [], shots: had?.shots ?? [], card: given ?? had?.card ?? null, commit: a.commit ?? x?.item.commit ?? had?.commit ?? null }
|
|
65
|
+
if (a.before !== undefined && isClip(a.before)) throw new Error(`--before ${a.before}: a before is a still (png, jpg, webp), not a clip`)
|
|
66
|
+
// the shot a --before or a --rating alone lands on: the change's one unrated shot, else its one shot
|
|
67
|
+
const unrated = c.shots.filter((s) => s.picture.rating == null)
|
|
68
|
+
const target = (): Shot => {
|
|
69
|
+
const s = unrated.length === 1 ? unrated[0] : c.shots.length === 1 ? c.shots[0] : undefined
|
|
70
|
+
if (!s) throw new Error(`"${c.title}" has ${c.shots.length === 0 ? 'no picture' : `${c.shots.length} shots`}: give --image with it`)
|
|
71
|
+
return s
|
|
72
|
+
}
|
|
73
|
+
// the words first: a refused change uploads no picture
|
|
74
|
+
await guarded(root, `"${c.title}"`, [category, c.title, c.text, ...c.bullets])
|
|
75
|
+
// a new picture takes the place of the shot of its rating, its old before gone unless the hand gives its own
|
|
76
|
+
let wrote: Shot | null = null
|
|
77
|
+
if (a.image !== undefined) wrote = { picture: { url: await keepPicture(root, a.image), alt: c.title, rating }, before: null }
|
|
78
|
+
else if (x) wrote = (await cardParts(root, x, c.title, rating)).shot
|
|
79
|
+
if (wrote) c.shots = withShot(c.shots, wrote)
|
|
80
|
+
else if (rating != null) {
|
|
81
|
+
const s = target()
|
|
82
|
+
wrote = { picture: { ...s.picture, rating }, before: s.before && { ...s.before, rating } }
|
|
83
|
+
c.shots = c.shots.map((t) => (t === s ? wrote! : t))
|
|
84
|
+
}
|
|
85
|
+
if (a.before !== undefined) {
|
|
86
|
+
const s = wrote ?? target()
|
|
87
|
+
const next: Shot = { picture: s.picture, before: { url: await keepPicture(root, a.before), alt: c.title, rating: rating ?? s.picture.rating } }
|
|
88
|
+
c.shots = c.shots.map((t) => (t.picture.url === s.picture.url ? next : t))
|
|
89
|
+
}
|
|
90
|
+
file = addChange(root, category, c).file
|
|
91
|
+
}
|
|
92
|
+
commitPaths([file!], `releases: next.md takes ${a.title ?? a.card ?? 'its heading'}`)
|
|
93
|
+
return file!
|
|
94
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// whether a pair's before earns its tab (wiki tools/shipkit/units.md, The release files): both stills read at a
|
|
2
|
+
// card's width in grey. The thresholds were measured on 21 real card pairs: an all black before spreads 0, the
|
|
3
|
+
// pairs that look the same differ 0.4 to 9.5 on average, the real changes 28 to 72
|
|
4
|
+
import sharp from 'sharp'
|
|
5
|
+
|
|
6
|
+
/** the width both stills are read at: a release card's, where a small change disappears */
|
|
7
|
+
const WIDTH = 320
|
|
8
|
+
/** under this spread of its grey values (of 255) a before is one flat colour: an all black frame */
|
|
9
|
+
export const BLANK_SPREAD = 4
|
|
10
|
+
/** under this mean difference from the after (of 255) a before shows nothing the after does not */
|
|
11
|
+
export const SAME_DIFF = 16
|
|
12
|
+
|
|
13
|
+
const grey = async (file: string, w: number, h: number): Promise<Buffer> => sharp(file).removeAlpha().resize(w, h, { fit: 'fill' }).greyscale().raw().toBuffer()
|
|
14
|
+
|
|
15
|
+
/** why a before stays out of the release: `blank`, `same`, or null when its tab shows a real difference */
|
|
16
|
+
export async function idleBefore(before: string, after: string): Promise<'blank' | 'same' | null> {
|
|
17
|
+
const m = await sharp(after).metadata()
|
|
18
|
+
const h = Math.max(1, Math.round((WIDTH * (m.height ?? WIDTH)) / Math.max(1, m.width ?? WIDTH)))
|
|
19
|
+
const [b, a] = await Promise.all([grey(before, WIDTH, h), grey(after, WIDTH, h)])
|
|
20
|
+
let sum = 0
|
|
21
|
+
for (const v of b) sum += v
|
|
22
|
+
const mean = sum / b.length
|
|
23
|
+
let spread = 0
|
|
24
|
+
let diff = 0
|
|
25
|
+
for (let i = 0; i < b.length; i++) {
|
|
26
|
+
spread += (b[i]! - mean) ** 2
|
|
27
|
+
diff += Math.abs(b[i]! - a[i]!)
|
|
28
|
+
}
|
|
29
|
+
if (Math.sqrt(spread / b.length) < BLANK_SPREAD) return 'blank'
|
|
30
|
+
return diff / b.length < SAME_DIFF ? 'same' : null
|
|
31
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// the release files as tree rows (wiki tools/shipkit/units.md, The release files): one row a version under the
|
|
2
|
+
// Releases section, next first, then newest first, its count of changes in the slot. A file that does not parse is a
|
|
3
|
+
// red row: SK040 says why. Read on every tree build: a few small md files
|
|
4
|
+
import { RELEASES_COL, type Collection, type Instance } from '../collections/collection-types.ts'
|
|
5
|
+
import { LAYOUT } from '../core/layout.ts'
|
|
6
|
+
import { changesOf, fileOf, NEXT } from './model.ts'
|
|
7
|
+
import { hasReleases, readRelease, releaseVersions } from './store.ts'
|
|
8
|
+
|
|
9
|
+
export function releasesCollection(root: string): Collection | null {
|
|
10
|
+
if (!hasReleases(root)) return null
|
|
11
|
+
return {
|
|
12
|
+
id: RELEASES_COL,
|
|
13
|
+
title: 'releases',
|
|
14
|
+
kind: 'release',
|
|
15
|
+
media: 'text',
|
|
16
|
+
list: async () =>
|
|
17
|
+
releaseVersions(root).map((v, i): Instance => {
|
|
18
|
+
let n: number | null = null
|
|
19
|
+
try {
|
|
20
|
+
n = changesOf(readRelease(root, v)!).length
|
|
21
|
+
} catch {
|
|
22
|
+
n = null
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
id: `release:${v}`,
|
|
26
|
+
text: v === NEXT ? 'the next release, being filled' : `release ${v}`,
|
|
27
|
+
label: v,
|
|
28
|
+
order: i,
|
|
29
|
+
slot: n == null ? 'unreadable' : `${n} change${n === 1 ? '' : 's'}`,
|
|
30
|
+
type: 'release',
|
|
31
|
+
path: `${LAYOUT.releases}/${fileOf(v)}`,
|
|
32
|
+
state: n == null ? 'red' : 'idle',
|
|
33
|
+
}
|
|
34
|
+
}),
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
// a change written from a review card (wiki tools/shipkit/review.md, A change for the release): the card carries its
|
|
2
|
+
// public line (`--changelog "<category>: <line>"`), and the owner's approval adds it to next.md with the card's media
|
|
3
|
+
// (a pair of images as its after and its before, two stills, never a video; a clip as it is, else its image), kept
|
|
4
|
+
// private in the Space. The card named is the thread's first version, so a later version approved again replaces its
|
|
5
|
+
// change instead of adding a second
|
|
6
|
+
import { ensureLocal } from '../review/media-read.ts'
|
|
7
|
+
import { isApproved, verdictOf, type Item, type ReviewItem } from '../review/model.ts'
|
|
8
|
+
import { stageablesOf } from '../review/stage-card.ts'
|
|
9
|
+
import { readAll, readItem, storeDir } from '../review/store.ts'
|
|
10
|
+
import { threadOfItem, threadsOf } from '../review/threads.ts'
|
|
11
|
+
import { commitPaths } from '../social/writes.ts'
|
|
12
|
+
import { idleBefore } from './before.ts'
|
|
13
|
+
import type { PostRating } from '../identities/rating.ts'
|
|
14
|
+
import { changesOf, isClip, NEXT, ratingOf, type Change, type Picture, type Shot } from './model.ts'
|
|
15
|
+
import { keepPicture } from './pictures.ts'
|
|
16
|
+
import { addChange, readRelease, undeclaredReleases, writeRelease } from './store.ts'
|
|
17
|
+
|
|
18
|
+
/** the versions of a card, newest first, following `supersedes` */
|
|
19
|
+
export function versionsOf(dir: string, x: ReviewItem): Item[] {
|
|
20
|
+
const out = [x.item]
|
|
21
|
+
for (let s = x.item.supersedes; s && out.length < 100; ) {
|
|
22
|
+
const prev = readItem(dir, s)
|
|
23
|
+
if (!prev) break
|
|
24
|
+
out.push(prev.item)
|
|
25
|
+
s = prev.item.supersedes
|
|
26
|
+
}
|
|
27
|
+
return out
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** a card's first media is a pair of images, the one shape that lends a change a before */
|
|
31
|
+
const isImagePair = (i: Item): boolean => stageablesOf(i, 1).some((s) => s.side === 'before' && s.kind === 'image')
|
|
32
|
+
|
|
33
|
+
/** the files that stand for the change: a pair of images as its after and its before (null when blank or the same as
|
|
34
|
+
* the after, `idle` says which), a clip or a pair of clips' after as it is, else the first image */
|
|
35
|
+
async function mediaOf(dir: string, i: Item): Promise<{ after: string; before: string | null; idle: 'blank' | 'same' | null } | null> {
|
|
36
|
+
const all = stageablesOf(i, 1)
|
|
37
|
+
const pick = all.find((s) => s.side !== 'before' && s.side !== 'wipe')
|
|
38
|
+
if (!pick) return null
|
|
39
|
+
const after = await ensureLocal(dir, i.id, pick.file)
|
|
40
|
+
if (!after) return null
|
|
41
|
+
const b = pick.side === 'after' && pick.kind === 'image' ? all.find((s) => s.side === 'before' && s.view === pick.view) : undefined
|
|
42
|
+
const before = b ? await ensureLocal(dir, i.id, b.file) : null
|
|
43
|
+
if (!before) return { after, before: null, idle: null }
|
|
44
|
+
const idle = await idleBefore(before, after)
|
|
45
|
+
return { after, before: idle ? null : before, idle }
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** a card's media kept private in the Space, as one shot of a change rated `rating` (null: unrated) */
|
|
49
|
+
async function keptMedia(root: string, i: Item, alt: string, rating: PostRating | null): Promise<{ shot: Shot | null; idle: 'blank' | 'same' | null }> {
|
|
50
|
+
const m = await mediaOf(storeDir(root), i)
|
|
51
|
+
if (!m) return { shot: null, idle: null }
|
|
52
|
+
const picture: Picture = { url: await keepPicture(root, m.after), alt, rating }
|
|
53
|
+
return { shot: { picture, before: m.before ? { url: await keepPicture(root, m.before), alt, rating } : null }, idle: m.idle }
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** the rating a card's media lands with: its changelog line's `--rating`, else unrated */
|
|
57
|
+
const cardRating = (root: string, x: ReviewItem): PostRating | null => versionsOf(storeDir(root), x).find((v) => v.changelog)?.changelog?.rating ?? null
|
|
58
|
+
|
|
59
|
+
/** what a card lends a change whatever its line: its newest version's shot kept private, rated `rating` when a hand
|
|
60
|
+
* gives one, else as the card says, the thread's first id, its commit */
|
|
61
|
+
export async function cardParts(root: string, x: ReviewItem, alt: string, rating: PostRating | null = null): Promise<{ shot: Shot | null; card: string; commit: string | null }> {
|
|
62
|
+
const { shot } = await keptMedia(root, x.item, alt, rating ?? cardRating(root, x))
|
|
63
|
+
return { shot, card: versionsOf(storeDir(root), x).at(-1)!.id, commit: x.item.commit ?? null }
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** a change's shots once a card's shot comes in: it takes the place of the shot it reads the same rating as, the others
|
|
67
|
+
* stay (a safe retake beside an nsfw card, by hand); an unrated card picture whose file did not change keeps the
|
|
68
|
+
* rating it had */
|
|
69
|
+
export function withShot(had: readonly Shot[], shot: Shot | null): Shot[] {
|
|
70
|
+
if (!shot) return [...had]
|
|
71
|
+
const same = had.find((s) => s.picture.url === shot.picture.url)
|
|
72
|
+
const rated: Shot =
|
|
73
|
+
shot.picture.rating == null && same?.picture.rating != null
|
|
74
|
+
? { picture: { ...shot.picture, rating: same.picture.rating }, before: shot.before && { ...shot.before, rating: shot.before.rating ?? (shot.before.url === same.before?.url ? same.before.rating : null) } }
|
|
75
|
+
: shot
|
|
76
|
+
return [rated, ...had.filter((s) => s.picture.url !== rated.picture.url && ratingOf(s.picture) !== ratingOf(rated.picture))]
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** the change a card adds to next: its line and its parts; null for a card with no changelog line */
|
|
80
|
+
export async function changeOfCard(root: string, x: ReviewItem): Promise<{ category: string; change: Change } | null> {
|
|
81
|
+
const line = versionsOf(storeDir(root), x).find((v) => v.changelog)?.changelog
|
|
82
|
+
if (!line) return null
|
|
83
|
+
const { shot, card, commit } = await cardParts(root, x, line.line)
|
|
84
|
+
return { category: line.category, change: { title: line.line, text: '', bullets: [], shots: shot ? [shot] : [], card, commit } }
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** after the owner's verdict: an approved card with a changelog line goes into next.md, committed; the next.md path,
|
|
88
|
+
* or null when the verdict adds nothing. The description and bullets a hand wrote for that change stay. A repo that
|
|
89
|
+
* declares no release files throws, so the card's thread says why its line went nowhere */
|
|
90
|
+
export async function onVerdict(root: string, id: string): Promise<string | null> {
|
|
91
|
+
const x = readItem(storeDir(root), id)
|
|
92
|
+
if (!x || !isApproved(verdictOf(x)?.status ?? 'rejected')) return null
|
|
93
|
+
if (!versionsOf(storeDir(root), x).some((v) => v.changelog)) return null
|
|
94
|
+
const why = await undeclaredReleases(root)
|
|
95
|
+
if (why) throw new Error(why)
|
|
96
|
+
const c = await changeOfCard(root, x)
|
|
97
|
+
if (!c) return null
|
|
98
|
+
const had = readRelease(root, NEXT)
|
|
99
|
+
?.categories.flatMap((k) => k.changes)
|
|
100
|
+
.find((ch) => ch.card === c.change.card)
|
|
101
|
+
const change = had ? { ...c.change, text: had.text, bullets: had.bullets, shots: withShot(had.shots, c.change.shots[0] ?? null) } : c.change
|
|
102
|
+
const { file } = addChange(root, c.category, change)
|
|
103
|
+
commitPaths([file], `releases: next takes the change of the card ${c.change.card}`)
|
|
104
|
+
return file
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** the version of a card's thread a change stands for: its newest approved one, else its newest */
|
|
108
|
+
function approvedOf(dir: string, id: string): ReviewItem | null {
|
|
109
|
+
const t = threadOfItem(id, threadsOf(readAll(dir).items))
|
|
110
|
+
if (!t) return readItem(dir, id)
|
|
111
|
+
return t.versions.find((v) => isApproved(verdictOf(v)?.status ?? 'rejected')) ?? t.head
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** what a refresh did to one change: its stills, and its before dropped as blank or the same as the after */
|
|
115
|
+
export interface Refreshed {
|
|
116
|
+
title: string
|
|
117
|
+
before: 'kept' | 'blank' | 'same' | 'none'
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** every change of next.md still showing a pair's wipe (a clip, from a card whose media is two images) takes that
|
|
121
|
+
* card's stills, its after and its before; any other picture stays, a retake by hand included. The changes moved, and
|
|
122
|
+
* the file written and committed unless `dry` (null when nothing moved) */
|
|
123
|
+
export async function refreshFromCards(root: string, o: { dry?: boolean } = {}): Promise<{ file: string | null; moved: Refreshed[] }> {
|
|
124
|
+
const why = await undeclaredReleases(root)
|
|
125
|
+
if (why) throw new Error(why)
|
|
126
|
+
const next = readRelease(root, NEXT)
|
|
127
|
+
if (!next) return { file: null, moved: [] }
|
|
128
|
+
const dir = storeDir(root)
|
|
129
|
+
const done = new Map<Change, Change>()
|
|
130
|
+
const moved: Refreshed[] = []
|
|
131
|
+
for (const ch of changesOf(next)) {
|
|
132
|
+
const wipe = ch.shots.find((s) => isClip(s.picture.url))
|
|
133
|
+
if (ch.card == null || !wipe) continue
|
|
134
|
+
const x = approvedOf(dir, ch.card)
|
|
135
|
+
if (!x) throw new Error(`"${ch.title}": its card ${ch.card} is not in the store`)
|
|
136
|
+
if (!isImagePair(x.item)) continue
|
|
137
|
+
if (o.dry) {
|
|
138
|
+
moved.push({ title: ch.title, before: 'none' })
|
|
139
|
+
continue
|
|
140
|
+
}
|
|
141
|
+
// the stills show what the wipe showed: its rating stays
|
|
142
|
+
const m = await keptMedia(root, x.item, wipe.picture.alt, wipe.picture.rating)
|
|
143
|
+
done.set(ch, { ...ch, shots: ch.shots.flatMap((s) => (s !== wipe ? [s] : m.shot ? [m.shot] : [])) })
|
|
144
|
+
moved.push({ title: ch.title, before: m.shot?.before ? 'kept' : (m.idle ?? 'none') })
|
|
145
|
+
}
|
|
146
|
+
if (o.dry || moved.length === 0) return { file: null, moved }
|
|
147
|
+
const release = { ...next, categories: next.categories.map((c) => ({ ...c, changes: c.changes.map((ch) => done.get(ch) ?? ch) })) }
|
|
148
|
+
const file = writeRelease(root, release)
|
|
149
|
+
commitPaths([file], `releases: next shows its cards' stills, not their wipes (${moved.length} changes)`)
|
|
150
|
+
return { file, moved }
|
|
151
|
+
}
|