rvlib-shipkit 2.19.0 → 2.20.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 +16 -0
- package/package.json +1 -1
- package/src/annex/annex.ts +227 -0
- package/src/annex/offload.ts +279 -0
- 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_Home.ts +3 -2
- package/src/cli/cmd_Messages.ts +155 -0
- package/src/cli/cmd_Releases.ts +48 -0
- package/src/cli/cmd_Review.ts +161 -6
- package/src/cli/cmd_Shot.ts +4 -4
- package/src/cli/cmd_Social.ts +143 -6
- 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 +6 -1
- package/src/collections/collection-types.ts +8 -1
- package/src/collections/providers.ts +4 -1
- 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 +5 -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 +302 -5
- package/src/home/gui-app.ts +63 -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.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 +110 -8
- 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 +180 -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 +66 -0
- package/src/releases/collection.ts +36 -0
- package/src/releases/from-card.ts +66 -0
- package/src/releases/model.ts +267 -0
- package/src/releases/pictures.ts +89 -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/model.ts +92 -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 +36 -0
- package/src/review/trailer-card.ts +99 -0
- package/src/review/trailer-desk.ts +57 -4
- package/src/review/trailer-model.ts +41 -7
- package/src/review/trailer-notes.ts +45 -0
- package/src/review/trailer-routes.ts +22 -13
- package/src/serve/hub-app/app-bridge.ts +71 -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 +40 -1
- package/src/serve/hub-app/home-st.ts +11 -2
- package/src/serve/hub-app/home.html +3 -0
- package/src/serve/hub-app/hub-app.tsx +6 -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/releases/releases-page.tsx +94 -0
- package/src/serve/hub-app/releases/releases-st.ts +69 -0
- package/src/serve/hub-app/releases.css +25 -0
- package/src/serve/hub-app/repo-sections.ts +15 -1
- package/src/serve/hub-app/repo-st.ts +56 -5
- package/src/serve/hub-app/review/clip-st.ts +31 -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 +62 -31
- package/src/serve/hub-app/review/trailer-st.ts +138 -26
- package/src/serve/hub-app/review/trailer-timeline.tsx +39 -26
- package/src/serve/hub-app/review.css +49 -6
- package/src/serve/hub-app/social/comms-page.tsx +55 -23
- 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/post-card.tsx +10 -2
- package/src/serve/hub-app/social/social-model.ts +37 -3
- package/src/serve/hub-app/social/social-page.tsx +179 -65
- package/src/serve/hub-app/social/social-st.ts +79 -26
- 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 +60 -1
- package/src/serve/hub-app/tree-build.ts +38 -1
- package/src/serve/hub-app/tree-svc.ts +10 -3
- package/src/serve/project-gutter-route.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/shooter.ts +3 -3
- package/src/shot/shot-ask.ts +14 -3
- package/src/shot/shot.shipkit.ts +1 -1
- package/src/social/discord-layout.ts +48 -5
- 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 +92 -0
- package/src/social/load.ts +105 -9
- 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 +31 -5
- package/src/social/reach.ts +49 -0
- package/src/social/release-stage.ts +173 -0
- package/src/social/routes.ts +42 -7
- package/src/social/stage.ts +227 -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/build.ts +15 -2
- package/src/trailer/grammar.ts +14 -4
- package/src/trailer/public-words.ts +41 -0
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
// a unit's release notes, in one place, whatever holds them (wiki tools/shipkit/units.md): its CHANGELOG's sections,
|
|
2
|
+
// or, for a root unit with `.shipkit/releases/`, the release files, next.md being the Unreleased notes. Bump, release
|
|
3
|
+
// and `sk releases` read only this, so the two homes never drift into two pipelines
|
|
4
|
+
import { existsSync, readdirSync, readFileSync } from 'fs'
|
|
5
|
+
import { join, relative } from 'path'
|
|
6
|
+
import { NEXT, changelogOf, changesOf, fileOf, notesOf as releaseNotes, parseRelease, promoted, renderRelease, type Release } from '../releases/model.ts'
|
|
7
|
+
import { declaredKind, extractChangelogSection, hasUnreleasedHeading, hasVersionSection, promoteUnreleased, type ReleaseKind } from './changelog.ts'
|
|
8
|
+
import type { ReleaseUnit } from './unit-resolve.ts'
|
|
9
|
+
|
|
10
|
+
/** one file a bump writes: its new text, or null to remove it */
|
|
11
|
+
export type NotesWrite = { path: string; text: string | null }
|
|
12
|
+
|
|
13
|
+
export interface UnitNotes {
|
|
14
|
+
/** where they live, repo relative: a file or the release folder */
|
|
15
|
+
rel: string
|
|
16
|
+
/** the Unreleased heading, or next.md, is there */
|
|
17
|
+
hasUnreleased: boolean
|
|
18
|
+
/** and holds something to say */
|
|
19
|
+
hasUnreleasedNotes: boolean
|
|
20
|
+
/** the kind the Unreleased heading declares, or null */
|
|
21
|
+
kind: ReleaseKind | null
|
|
22
|
+
hasVersion(version: string): boolean
|
|
23
|
+
/** the notes of a released version, markdown; throws when it has none */
|
|
24
|
+
section(version: string): string
|
|
25
|
+
/** the files a bump writes to name the Unreleased notes `version`, or why it cannot */
|
|
26
|
+
promote(version: string, date: string): { writes: NotesWrite[] } | { error: string }
|
|
27
|
+
/** the file and the line pattern the commit that wrote a version's notes is found by */
|
|
28
|
+
anchor(version: string): { rel: string; pattern: string }
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const esc = (v: string): string => v.replace(/\./g, '\\.')
|
|
32
|
+
|
|
33
|
+
function changelogNotes(root: string, u: ReleaseUnit): UnitNotes {
|
|
34
|
+
const rel = relative(root, u.changelog)
|
|
35
|
+
const text = existsSync(u.changelog) ? readFileSync(u.changelog, 'utf8') : null
|
|
36
|
+
const missing = `${rel} not found: a release states what changed`
|
|
37
|
+
return {
|
|
38
|
+
rel,
|
|
39
|
+
hasUnreleased: text != null && hasUnreleasedHeading(text),
|
|
40
|
+
hasUnreleasedNotes: text != null && !('error' in promoteUnreleased(text, '0.0.0')),
|
|
41
|
+
kind: text == null ? null : declaredKind(text),
|
|
42
|
+
hasVersion: (v) => text != null && hasVersionSection(text, v),
|
|
43
|
+
section: (v) => {
|
|
44
|
+
if (text == null) throw new Error(missing)
|
|
45
|
+
return extractChangelogSection({ changelog: text, version: v })
|
|
46
|
+
},
|
|
47
|
+
promote: (v) => {
|
|
48
|
+
if (text == null) return { error: missing }
|
|
49
|
+
const p = promoteUnreleased(text, v)
|
|
50
|
+
return 'error' in p ? p : { writes: [{ path: u.changelog, text: p.text }] }
|
|
51
|
+
},
|
|
52
|
+
anchor: (v) => ({ rel, pattern: `^## ${esc(v)}` }),
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function folderNotes(root: string, u: ReleaseUnit, dir: string): UnitNotes {
|
|
57
|
+
const rel = relative(root, dir)
|
|
58
|
+
const read = (v: string): Release | null => {
|
|
59
|
+
const f = join(dir, fileOf(v))
|
|
60
|
+
return existsSync(f) ? parseRelease(readFileSync(f, 'utf8'), `${rel}/${fileOf(v)}`) : null
|
|
61
|
+
}
|
|
62
|
+
let next: Release | null = null
|
|
63
|
+
let nextError: string | null = null
|
|
64
|
+
try {
|
|
65
|
+
next = read(NEXT)
|
|
66
|
+
} catch (e) {
|
|
67
|
+
nextError = (e as Error).message
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
rel,
|
|
71
|
+
hasUnreleased: next != null,
|
|
72
|
+
hasUnreleasedNotes: next != null && changesOf(next).length > 0,
|
|
73
|
+
kind: next?.kind ?? null,
|
|
74
|
+
hasVersion: (v) => existsSync(join(dir, fileOf(v))),
|
|
75
|
+
section: (v) => {
|
|
76
|
+
const r = read(v)
|
|
77
|
+
if (r == null) throw new Error(`${rel} has no ${fileOf(v)}: write the notes, then release`)
|
|
78
|
+
const notes = releaseNotes(r)
|
|
79
|
+
if (notes === '') throw new Error(`${rel}/${fileOf(v)} holds no change: write the notes, then release`)
|
|
80
|
+
return notes
|
|
81
|
+
},
|
|
82
|
+
promote: (v, date) => {
|
|
83
|
+
if (nextError != null) return { error: nextError }
|
|
84
|
+
if (next == null) return { error: `${rel} has no ${fileOf(NEXT)}: write the changes of this version in it, then bump` }
|
|
85
|
+
if (existsSync(join(dir, fileOf(v)))) return { error: `${rel}/${fileOf(v)} exists already: that version is written` }
|
|
86
|
+
let done: Release
|
|
87
|
+
try {
|
|
88
|
+
done = promoted(next, v, date)
|
|
89
|
+
} catch (e) {
|
|
90
|
+
return { error: (e as Error).message }
|
|
91
|
+
}
|
|
92
|
+
const writes: NotesWrite[] = [
|
|
93
|
+
{ path: join(dir, fileOf(v)), text: renderRelease(done) },
|
|
94
|
+
{ path: join(dir, fileOf(NEXT)), text: null },
|
|
95
|
+
]
|
|
96
|
+
// a unit read on npm keeps a CHANGELOG.md, made from the files, its sections from before them kept: npm and
|
|
97
|
+
// GitHub show it. Notes still waiting under its Unreleased heading would be lost, so they refuse
|
|
98
|
+
if (u.targets.npm) {
|
|
99
|
+
const before = existsSync(u.changelog) ? readFileSync(u.changelog, 'utf8') : ''
|
|
100
|
+
if (!('error' in promoteUnreleased(before, '0.0.0')))
|
|
101
|
+
return { error: `${relative(root, u.changelog)} still holds "## Unreleased" notes: move them into ${rel}/${fileOf(NEXT)}, then bump` }
|
|
102
|
+
writes.push({ path: u.changelog, text: changelogOf([...releasedIn(dir, rel), done], before) })
|
|
103
|
+
}
|
|
104
|
+
return { writes }
|
|
105
|
+
},
|
|
106
|
+
anchor: (v) => ({ rel: `${rel}/${fileOf(v)}`, pattern: `^# ${esc(v)}` }),
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** every released version's file of the folder, parsed */
|
|
111
|
+
function releasedIn(dir: string, rel: string): Release[] {
|
|
112
|
+
return readdirSync(dir)
|
|
113
|
+
.filter((f) => /^\d+\.\d+\.\d+\.md$/.test(f))
|
|
114
|
+
.map((f) => parseRelease(readFileSync(join(dir, f), 'utf8'), `${rel}/${f}`))
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** next.md's private pictures made public, the file written with their URLs: how many went public */
|
|
118
|
+
export async function publishNext(root: string): Promise<number> {
|
|
119
|
+
const { readRelease, writeRelease } = await import('../releases/store.ts')
|
|
120
|
+
const { publishPictures } = await import('../releases/pictures.ts')
|
|
121
|
+
const { loadSocialUnit } = await import('../social/unit.ts')
|
|
122
|
+
const next = readRelease(root, NEXT)
|
|
123
|
+
if (next == null) return 0
|
|
124
|
+
const { release, published } = await publishPictures(root, next, await loadSocialUnit(root))
|
|
125
|
+
if (published > 0) writeRelease(root, release)
|
|
126
|
+
return published
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** the notes of one unit, from where it keeps them */
|
|
130
|
+
export const unitNotes = (root: string, u: ReleaseUnit): UnitNotes => (u.releases != null ? folderNotes(root, u, u.releases) : changelogNotes(root, u))
|
package/src/release/run-bump.ts
CHANGED
|
@@ -26,10 +26,10 @@
|
|
|
26
26
|
// every selected unit's package.json and changelog. The publish part is
|
|
27
27
|
// RESUMABLE instead, because an npm publish cannot be undone and a rollback
|
|
28
28
|
// that cannot roll back is a lie.
|
|
29
|
-
import { existsSync, readFileSync, realpathSync, writeFileSync } from 'fs'
|
|
29
|
+
import { existsSync, readFileSync, realpathSync, rmSync, writeFileSync } from 'fs'
|
|
30
30
|
import { homedir } from 'os'
|
|
31
31
|
import { join, relative } from 'path'
|
|
32
|
-
import {
|
|
32
|
+
import { publishNext, unitNotes } from './notes.ts'
|
|
33
33
|
import { deriveRemote, dirtyPathList, dirtyPaths, git as gitAt, mergeProbe, remoteTags, tagExistsLocally } from './git-facts.ts'
|
|
34
34
|
import { unitBlockers } from './unit-gate.ts'
|
|
35
35
|
import { publicCleanBlockers } from './public-clean.ts'
|
|
@@ -216,7 +216,13 @@ function probeMergeIntoReleaseBranch(
|
|
|
216
216
|
* another worktree cannot stop it */
|
|
217
217
|
const rehearsalOnly = (o: BumpOpts): boolean => o.dryRun === true
|
|
218
218
|
|
|
219
|
-
type Selected = { unit: ReleaseUnit; version: string;
|
|
219
|
+
type Selected = { unit: ReleaseUnit; version: string; notesRel: string; kind: BumpKind }
|
|
220
|
+
|
|
221
|
+
/** the local date a version is written on, YYYY-MM-DD */
|
|
222
|
+
const today = (): string => {
|
|
223
|
+
const d = new Date()
|
|
224
|
+
return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`
|
|
225
|
+
}
|
|
220
226
|
|
|
221
227
|
export async function runBump(root: string, config: RepoConfig, kind: BumpKind | null, o: BumpOpts = {}): Promise<number> {
|
|
222
228
|
const print = o.print ?? ((l: string) => console.log(l))
|
|
@@ -366,9 +372,10 @@ export async function runBump(root: string, config: RepoConfig, kind: BumpKind |
|
|
|
366
372
|
if (o.all === true) {
|
|
367
373
|
picked = []
|
|
368
374
|
for (const u of all) {
|
|
369
|
-
|
|
370
|
-
if (
|
|
371
|
-
|
|
375
|
+
const notes = unitNotes(root, u)
|
|
376
|
+
if (u.releases == null && !existsSync(u.changelog)) { print(`skip: ${u.id}: no changelog at ${notes.rel}`); continue }
|
|
377
|
+
if (notes.hasUnreleasedNotes) picked.push(u)
|
|
378
|
+
else print(`skip: ${u.id}: no Unreleased notes in ${notes.rel}`)
|
|
372
379
|
}
|
|
373
380
|
if (picked.length === 0) return fail('no unit has non-empty Unreleased notes — write what changed, then bump')
|
|
374
381
|
} else {
|
|
@@ -387,22 +394,22 @@ export async function runBump(root: string, config: RepoConfig, kind: BumpKind |
|
|
|
387
394
|
const blockers: string[] = []
|
|
388
395
|
const selected: Selected[] = []
|
|
389
396
|
for (const unit of picked) {
|
|
390
|
-
const
|
|
391
|
-
|
|
392
|
-
const source = readFileSync(unit.changelog, 'utf8')
|
|
397
|
+
const notes = unitNotes(root, unit)
|
|
398
|
+
const notesRel = notes.rel
|
|
393
399
|
// an explicit kind on the command line wins for the whole selection.
|
|
394
400
|
// Without one, each unit answers for itself from its own heading, and
|
|
395
401
|
// a unit that never said is a refusal: guessing a version number
|
|
396
402
|
// publishes it, and a published number cannot be recalled.
|
|
397
|
-
const unitKind = kind ??
|
|
403
|
+
const unitKind = kind ?? notes.kind
|
|
398
404
|
if (unitKind == null) {
|
|
399
|
-
|
|
405
|
+
const write = unit.releases != null ? '"# next (minor)" in next.md' : '"## Unreleased (minor)"'
|
|
406
|
+
blockers.push(`unit '${unit.id}': ${notesRel} does not say what kind of release this is: write ${write}, or pass a kind that applies to every selected unit`)
|
|
400
407
|
continue
|
|
401
408
|
}
|
|
402
409
|
let version: string
|
|
403
410
|
try { version = nextVersion(unit.version, unitKind) }
|
|
404
411
|
catch (e) { blockers.push(`unit '${unit.id}': ${e instanceof Error ? e.message : String(e)}`); continue }
|
|
405
|
-
const promoted =
|
|
412
|
+
const promoted = notes.promote(version, today())
|
|
406
413
|
if ('error' in promoted) { blockers.push(`unit '${unit.id}': ${promoted.error}`); continue }
|
|
407
414
|
const tag = renderTag(unit, version)
|
|
408
415
|
if (tagExistsLocally(root, tag)) {
|
|
@@ -414,7 +421,7 @@ export async function runBump(root: string, config: RepoConfig, kind: BumpKind |
|
|
|
414
421
|
continue
|
|
415
422
|
}
|
|
416
423
|
blockers.push(...unitBlockers(root, config, unit), ...(await publicCleanBlockers(root, config, unit)))
|
|
417
|
-
selected.push({ unit, version,
|
|
424
|
+
selected.push({ unit, version, notesRel, kind: unitKind })
|
|
418
425
|
}
|
|
419
426
|
// everything the release needs that does not depend on the new version.
|
|
420
427
|
// HEAD is the release branch by now, so the branch check applies — except
|
|
@@ -465,6 +472,7 @@ export async function runBump(root: string, config: RepoConfig, kind: BumpKind |
|
|
|
465
472
|
// real bump that aborts mid-merge
|
|
466
473
|
if (mergeUnknown) print(`WARN dry run inconclusive — would write ${what}, but the merge into '${branch}' could not be checked (git 2.38+ answers it)`)
|
|
467
474
|
else print(`ok: dry run clean — would write ${what}, commit, then ${o.noRelease === true ? 'stop' : 'release'}`)
|
|
475
|
+
for (const s of selected.filter((x) => x.unit.releases != null)) print(` it did NOT make the pictures of ${s.notesRel}/next.md public: the real bump does, after the repo's guard reads them`)
|
|
468
476
|
// what the rehearsal did NOT cover, said out loud: a merge that never
|
|
469
477
|
// happened cannot have been gated, and a number computed on the
|
|
470
478
|
// feature branch can differ from the one the real bump writes
|
|
@@ -484,20 +492,35 @@ export async function runBump(root: string, config: RepoConfig, kind: BumpKind |
|
|
|
484
492
|
closeMergeWindow()
|
|
485
493
|
const failKeep = (msg: string, fixLine: string): number => { print(`FAIL: ${msg}`); print(` fix: ${fixLine}`); return 1 }
|
|
486
494
|
const files: string[] = []
|
|
495
|
+
for (const s of selected) {
|
|
496
|
+
// a release file's pictures go public now, never before: the version ships, the guard read their bytes
|
|
497
|
+
if (s.unit.releases != null) {
|
|
498
|
+
try {
|
|
499
|
+
const n = await publishNext(root)
|
|
500
|
+
if (n > 0) print(`ok: ${n} picture${n === 1 ? '' : 's'} of ${s.notesRel}/next.md made public`)
|
|
501
|
+
} catch (e) {
|
|
502
|
+
return failKeep(`${s.unit.id}: ${(e as Error).message}`, `fix the change in ${s.notesRel}/next.md, then run bump again`)
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
}
|
|
487
506
|
for (const s of selected) {
|
|
488
507
|
const pkgRel = s.unit.rel === '' ? 'package.json' : `${s.unit.rel}/package.json`
|
|
489
508
|
// re-read: a merge can have changed both files under us
|
|
490
509
|
const pkgNow = readFileSync(`${root}/${pkgRel}`, 'utf8')
|
|
491
|
-
const promoted =
|
|
492
|
-
if ('error' in promoted) return failKeep(`${s.unit.id}: ${promoted.error}`, `check ${s.
|
|
510
|
+
const promoted = unitNotes(root, s.unit).promote(s.version, today())
|
|
511
|
+
if ('error' in promoted) return failKeep(`${s.unit.id}: ${promoted.error}`, `check ${s.notesRel}, then run bump again`)
|
|
493
512
|
// indentation is preserved by rewriting only the version VALUE, so a bump
|
|
494
513
|
// never reformats a file the repo cares about
|
|
495
514
|
const bumped = pkgNow.replace(/("version"\s*:\s*")[^"]*(")/, `$1${s.version}$2`)
|
|
496
515
|
if (bumped === pkgNow) return failKeep(`${s.unit.id}: could not rewrite the version field in ${pkgRel}`, `git status, then set the version by hand`)
|
|
497
516
|
writeFileSync(`${root}/${pkgRel}`, bumped)
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
517
|
+
for (const w of promoted.writes) {
|
|
518
|
+
if (w.text == null) rmSync(w.path, { force: true })
|
|
519
|
+
else writeFileSync(w.path, w.text)
|
|
520
|
+
files.push(relative(root, w.path))
|
|
521
|
+
}
|
|
522
|
+
files.push(pkgRel)
|
|
523
|
+
print(`ok: ${pkgRel} ${s.version}, ${s.notesRel} notes named ${s.version}`)
|
|
501
524
|
}
|
|
502
525
|
|
|
503
526
|
// every OTHER unit that depends on a bumped one moves its range forward, in
|
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
//
|
|
6
6
|
// every step is idempotent and the pipeline resumes: a run that died after
|
|
7
7
|
// publishing completes only what is missing. preflight touches nothing.
|
|
8
|
-
import {
|
|
8
|
+
import { mkdtempSync, rmSync, writeFileSync } from 'fs'
|
|
9
9
|
import { tmpdir } from 'os'
|
|
10
10
|
import { join } from 'path'
|
|
11
11
|
import { runCi } from '../core/run-ci.ts'
|
|
12
|
-
import {
|
|
12
|
+
import { unitNotes } from './notes.ts'
|
|
13
13
|
import { deriveRemote, dirtyPaths, git, remoteTagState, tagExistsLocally, type RemoteTagState } from './git-facts.ts'
|
|
14
14
|
import { releaseScope } from './release-scope.ts'
|
|
15
15
|
import { publishCommand, unitBlockers, type Publisher } from './unit-gate.ts'
|
|
@@ -29,6 +29,11 @@ export type ReleaseConfig = {
|
|
|
29
29
|
tag?: string
|
|
30
30
|
/** the ROOT unit's versioned changelog (default 'CHANGELOG.md') */
|
|
31
31
|
changelog?: string
|
|
32
|
+
/** the ROOT unit's notes are the release files of `.shipkit/releases/` (next.md, one md a version), filled from
|
|
33
|
+
* approved review cards; an npm root's CHANGELOG.md is then made from them, its older sections kept. Declared,
|
|
34
|
+
* never inferred from the folder: an approval writes next.md only where this is true. Default false.
|
|
35
|
+
* wiki/tools/shipkit/units.md, The release files */
|
|
36
|
+
releases?: boolean
|
|
32
37
|
/** publish the ROOT unit to npm, declared and never inferred: a root whose
|
|
33
38
|
* package.json is not private refuses to release until this says true or
|
|
34
39
|
* false. A private package NEVER publishes, whatever this says. True makes
|
|
@@ -197,8 +202,7 @@ export async function releaseUnit(root: string, config: RepoConfig, unit: Releas
|
|
|
197
202
|
|
|
198
203
|
const blockers: string[] = []
|
|
199
204
|
const notesResult = ((): { notes: string } | { error: string } => {
|
|
200
|
-
|
|
201
|
-
try { return { notes: extractChangelogSection({ changelog: readFileSync(unit.changelog, 'utf8'), version }) } }
|
|
205
|
+
try { return { notes: unitNotes(root, unit).section(version) } }
|
|
202
206
|
catch (e) { return { error: `unit '${unit.id}': ${e instanceof Error ? e.message : String(e)}` } }
|
|
203
207
|
})()
|
|
204
208
|
if ('error' in notesResult) blockers.push(notesResult.error)
|
|
@@ -344,6 +348,20 @@ export async function releaseUnit(root: string, config: RepoConfig, unit: Releas
|
|
|
344
348
|
print(`ok: GitHub release ${tag} live`)
|
|
345
349
|
}
|
|
346
350
|
print(`ok: ${name}@${version} released${wantNpm ? ' (npm + tag' : ' (tag'}${wantGh ? ' + github release)' : ')'}`)
|
|
351
|
+
// the root unit's post, staged where the repo's social unit declares release headings: a draft that waits for
|
|
352
|
+
// his submit, never a post; a failure warns and names the command to run again
|
|
353
|
+
if (unit.rel === '') {
|
|
354
|
+
try {
|
|
355
|
+
const { loadSocialUnit } = await import('../social/unit.ts')
|
|
356
|
+
const { stageRelease } = await import('../social/release-stage.ts')
|
|
357
|
+
const before = git(root, ['describe', '--tags', '--abbrev=0', `${tag}^`])
|
|
358
|
+
const r = await stageRelease(root, await loadSocialUnit(root), { unit: unit.id, version, notes, tag, ...(before.code === 0 && before.out !== '' ? { since: before.out } : {}) }, config.speaksAs ? { speaksAs: config.speaksAs } : {})
|
|
359
|
+
if (r != null) print(`ok: ${r.created ? 'staged its post' : 'its post already staged'}: ${r.slug}, waiting in Communications`)
|
|
360
|
+
} catch (e) {
|
|
361
|
+
print(`WARN the release's post was not staged: ${(e as Error).message}`)
|
|
362
|
+
print(` fix: shipkit social release ${version} --unit ${unit.id} --notes <the ## ${version} section> --tag ${tag}`)
|
|
363
|
+
}
|
|
364
|
+
}
|
|
347
365
|
// LAST, and root-unit only: everything above is already published, so
|
|
348
366
|
// a failed deploy is reported without unwinding any of it
|
|
349
367
|
const after = unit.rel === '' ? config.release?.after : undefined
|
|
@@ -6,9 +6,7 @@
|
|
|
6
6
|
// the table stays one line per unit and carries only facts that fit in a
|
|
7
7
|
// column. Anything that needs a sentence (drift, stale notes, an unreachable
|
|
8
8
|
// remote) prints BELOW the table, so the noise is proportional to the problem.
|
|
9
|
-
import {
|
|
10
|
-
import { relative } from 'path'
|
|
11
|
-
import { hasUnreleasedHeading, hasVersionSection } from './changelog.ts'
|
|
9
|
+
import { unitNotes } from './notes.ts'
|
|
12
10
|
import { deriveRemote, git, remoteTags } from './git-facts.ts'
|
|
13
11
|
import { formatUnitError, resolveUnits, type ReleaseUnit } from './units.ts'
|
|
14
12
|
import type { RepoConfig } from '../repo-config.ts'
|
|
@@ -45,6 +43,8 @@ export type UnitReport = {
|
|
|
45
43
|
* describe none of it */
|
|
46
44
|
commitsAfterNotes: number | null
|
|
47
45
|
hasUnreleased: boolean
|
|
46
|
+
/** where the Unreleased notes are written, as a line says it: `"## Unreleased"`, or the release folder's next.md */
|
|
47
|
+
unreleasedAt: string
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
const pathspec = (u: ReleaseUnit): string[] => (u.rel === '' ? [] : ['--', u.rel])
|
|
@@ -53,8 +53,8 @@ const pathspec = (u: ReleaseUnit): string[] => (u.rel === '' ? [] : ['--', u.rel
|
|
|
53
53
|
* purpose: a substring pickaxe also matches prose that MENTIONS `## 1.2.3`,
|
|
54
54
|
* so a sentence in the Unreleased section moves the anchor to itself and
|
|
55
55
|
* silences the stale-notes warning it was talking about. */
|
|
56
|
-
export function notesAnchor(root: string,
|
|
57
|
-
const h = git(root, ['log', '-1', '--format=%H', '-G',
|
|
56
|
+
export function notesAnchor(root: string, at: { rel: string; pattern: string }): string | null {
|
|
57
|
+
const h = git(root, ['log', '-1', '--format=%H', '-G', at.pattern, '--', at.rel])
|
|
58
58
|
return h.code === 0 && h.out !== '' ? h.out : null
|
|
59
59
|
}
|
|
60
60
|
|
|
@@ -110,15 +110,14 @@ async function surveyUnits(root: string, config: RepoConfig, o: { offline?: bool
|
|
|
110
110
|
// whole run. Order is preserved by mapping rather than pushing.
|
|
111
111
|
const reports: UnitReport[] = await Promise.all(units.map(async (u): Promise<UnitReport> => {
|
|
112
112
|
const tagLocal = git(root, ['rev-parse', '--quiet', '--verify', `refs/tags/${u.tag}`]).code === 0
|
|
113
|
-
const
|
|
114
|
-
const hasSection =
|
|
115
|
-
const changelogRel = relative(root, u.changelog)
|
|
113
|
+
const notes = unitNotes(root, u)
|
|
114
|
+
const hasSection = notes.hasVersion(u.version)
|
|
116
115
|
// the commit that introduced this version's heading, then everything
|
|
117
|
-
// that touched the unit afterwards but is not the
|
|
116
|
+
// that touched the unit afterwards but is not the notes themselves
|
|
118
117
|
let commitsAfterNotes: number | null = null
|
|
119
|
-
const anchor = hasSection ? notesAnchor(root,
|
|
118
|
+
const anchor = hasSection ? notesAnchor(root, notes.anchor(u.version)) : null
|
|
120
119
|
if (anchor != null) {
|
|
121
|
-
const c = git(root, ['rev-list', '--count', `${anchor}..HEAD`, ...(u.rel === '' ? ['--'] : ['--', u.rel]), `:(exclude)${
|
|
120
|
+
const c = git(root, ['rev-list', '--count', `${anchor}..HEAD`, ...(u.rel === '' ? ['--'] : ['--', u.rel]), `:(exclude)${notes.rel}`])
|
|
122
121
|
if (c.code === 0) commitsAfterNotes = Number(c.out)
|
|
123
122
|
}
|
|
124
123
|
const since = tagLocal ? git(root, ['rev-list', '--count', `${u.tag}..HEAD`, ...pathspec(u)]) : null
|
|
@@ -158,7 +157,8 @@ async function surveyUnits(root: string, config: RepoConfig, o: { offline?: bool
|
|
|
158
157
|
contentDiffers: tagTree != null && headTree != null ? tagTree !== headTree : null,
|
|
159
158
|
hasSection,
|
|
160
159
|
commitsAfterNotes,
|
|
161
|
-
hasUnreleased:
|
|
160
|
+
hasUnreleased: notes.hasUnreleased,
|
|
161
|
+
unreleasedAt: u.releases != null ? `${notes.rel}/next.md` : '"## Unreleased"',
|
|
162
162
|
}
|
|
163
163
|
}))
|
|
164
164
|
return { reports, errors: errors.map(formatUnitError), remote, remoteError }
|
|
@@ -198,7 +198,7 @@ export function attentionLines(r: UnitReport): string[] {
|
|
|
198
198
|
const out: string[] = []
|
|
199
199
|
const behindNpm = r.npmTarget && r.npmLatest != null && r.npmLatest !== 'unpublished' && r.npmLatest !== r.version
|
|
200
200
|
const npmClause = behindNpm ? `, and npm still has ${r.npmLatest ?? ''}` : ''
|
|
201
|
-
const notesClause = r.hasUnreleased ? '' :
|
|
201
|
+
const notesClause = r.hasUnreleased ? '' : `write the notes in ${r.unreleasedAt}, then `
|
|
202
202
|
// the tool knows the unit and its state, never whether the change is a fix,
|
|
203
203
|
// a feature or a break — stating a kind it cannot know is a guess in the
|
|
204
204
|
// shape of a command
|
|
@@ -222,7 +222,7 @@ export function attentionLines(r: UnitReport): string[] {
|
|
|
222
222
|
} else if (r.hasUnreleased) {
|
|
223
223
|
// written notes with no release behind them are a DECISION waiting on
|
|
224
224
|
// a human, not a defect: a note, so the row still reads as healthy
|
|
225
|
-
out.push(`note: ${r.id}:
|
|
225
|
+
out.push(`note: ${r.id}: ${r.unreleasedAt} notes are waiting — shipkit bump ${KIND} ${r.id}`)
|
|
226
226
|
}
|
|
227
227
|
|
|
228
228
|
if (r.commitsSinceTag === 0 && r.contentDiffers === true)
|
|
@@ -232,7 +232,9 @@ export function attentionLines(r: UnitReport): string[] {
|
|
|
232
232
|
if (r.tagLocal && r.tagRemote === false)
|
|
233
233
|
out.push(`WARN ${r.id}: ${r.tag} exists here and nowhere else — invisible on GitHub until it is pushed`)
|
|
234
234
|
if (!r.hasSection && !r.hasUnreleased)
|
|
235
|
-
out.push(
|
|
235
|
+
out.push(r.unreleasedAt.endsWith('next.md')
|
|
236
|
+
? `WARN ${r.id}: no ${r.version}.md and no ${r.unreleasedAt}: nothing to release from`
|
|
237
|
+
: `WARN ${r.id}: no "## ${r.version}" section and no "## Unreleased" in ${r.id === 'root' ? 'the root changelog' : 'its changelog'} — nothing to release from`)
|
|
236
238
|
return out
|
|
237
239
|
}
|
|
238
240
|
|
|
@@ -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,66 @@
|
|
|
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 { cardParts, versionsOf } from './from-card.ts'
|
|
8
|
+
import { changesOf, emptyRelease, NEXT, type Change, type ReleaseKind } from './model.ts'
|
|
9
|
+
import { keepPicture } from './pictures.ts'
|
|
10
|
+
import { addChange, readRelease, undeclaredReleases, writeRelease } from './store.ts'
|
|
11
|
+
|
|
12
|
+
export interface AddAsk {
|
|
13
|
+
category?: string
|
|
14
|
+
title?: string
|
|
15
|
+
text?: string
|
|
16
|
+
bullets?: string[]
|
|
17
|
+
image?: string
|
|
18
|
+
card?: string
|
|
19
|
+
commit?: string
|
|
20
|
+
kind?: string
|
|
21
|
+
heading?: string
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const KINDS: readonly string[] = ['major', 'minor', 'patch']
|
|
25
|
+
|
|
26
|
+
async function guarded(root: string, what: string, texts: string[]): Promise<void> {
|
|
27
|
+
const problems = await publicProblems(root, { texts: texts.filter((t) => t.trim() !== '') })
|
|
28
|
+
if (problems.length > 0) throw new Error(`${what}: the repo's guard refuses it: ${problems.join('; ')}`)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** next.md written with the ask: its kind and title, and one change; the file written */
|
|
32
|
+
export async function addByHand(root: string, a: AddAsk): Promise<string> {
|
|
33
|
+
if (a.kind !== undefined && !KINDS.includes(a.kind)) throw new Error(`--kind ${a.kind}: major, minor or patch`)
|
|
34
|
+
const change = a.category !== undefined || a.title !== undefined || a.card !== undefined
|
|
35
|
+
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')
|
|
36
|
+
const why = await undeclaredReleases(root)
|
|
37
|
+
if (why) throw new Error(why)
|
|
38
|
+
let file: string | null = null
|
|
39
|
+
if (a.kind !== undefined || a.heading !== undefined) {
|
|
40
|
+
if (a.heading) await guarded(root, '--release-title', [a.heading])
|
|
41
|
+
const next = readRelease(root, NEXT) ?? emptyRelease()
|
|
42
|
+
file = writeRelease(root, { ...next, ...(a.kind ? { kind: a.kind as ReleaseKind } : {}), ...(a.heading !== undefined ? { title: a.heading.trim() } : {}) })
|
|
43
|
+
}
|
|
44
|
+
if (change) {
|
|
45
|
+
const x = a.card !== undefined ? itemOfRef(storeDir(root), a.card) : null
|
|
46
|
+
if (a.card !== undefined && !x) throw new Error(`--card ${a.card}: no such card`)
|
|
47
|
+
// the card's own line, when it has one, unless the hand names its own
|
|
48
|
+
const line = x ? versionsOf(storeDir(root), x).find((v) => v.changelog)?.changelog : undefined
|
|
49
|
+
const category = a.category ?? line?.category
|
|
50
|
+
const title = a.title ?? line?.line
|
|
51
|
+
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')
|
|
52
|
+
const next = readRelease(root, NEXT)
|
|
53
|
+
const given = x ? versionsOf(storeDir(root), x).at(-1)!.id : null
|
|
54
|
+
// the change of the same card, else of the same title: what the hand does not give, the card included, is kept
|
|
55
|
+
const all = next ? changesOf(next) : []
|
|
56
|
+
const had = (given != null ? all.find((ch) => ch.card === given) : undefined) ?? all.find((ch) => ch.title === title)
|
|
57
|
+
const c: Change = { title, text: a.text ?? had?.text ?? '', bullets: a.bullets ?? had?.bullets ?? [], picture: had?.picture ?? null, card: given ?? had?.card ?? null, commit: a.commit ?? x?.item.commit ?? had?.commit ?? null }
|
|
58
|
+
// the words first: a refused change uploads no picture
|
|
59
|
+
await guarded(root, `"${c.title}"`, [category, c.title, c.text, ...c.bullets])
|
|
60
|
+
if (a.image !== undefined) c.picture = { url: await keepPicture(root, a.image), alt: c.title }
|
|
61
|
+
else if (x) c.picture = (await cardParts(root, x, c.title)).picture ?? c.picture
|
|
62
|
+
file = addChange(root, category, c).file
|
|
63
|
+
}
|
|
64
|
+
commitPaths([file!], `releases: next.md takes ${a.title ?? a.card ?? 'its heading'}`)
|
|
65
|
+
return file!
|
|
66
|
+
}
|
|
@@ -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,66 @@
|
|
|
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 after picture,
|
|
3
|
+
// kept private in the Space. The card named is the thread's first version, so a later version approved again replaces
|
|
4
|
+
// its change instead of adding a second one
|
|
5
|
+
import { ensureLocal } from '../review/media-read.ts'
|
|
6
|
+
import { isApproved, verdictOf, type Item, type ReviewItem } from '../review/model.ts'
|
|
7
|
+
import { stageablesOf } from '../review/stage-card.ts'
|
|
8
|
+
import { readItem, storeDir } from '../review/store.ts'
|
|
9
|
+
import { commitPaths } from '../social/writes.ts'
|
|
10
|
+
import { NEXT, type Change } from './model.ts'
|
|
11
|
+
import { keepPicture } from './pictures.ts'
|
|
12
|
+
import { addChange, readRelease, undeclaredReleases } from './store.ts'
|
|
13
|
+
|
|
14
|
+
/** the versions of a card, newest first, following `supersedes` */
|
|
15
|
+
export function versionsOf(dir: string, x: ReviewItem): Item[] {
|
|
16
|
+
const out = [x.item]
|
|
17
|
+
for (let s = x.item.supersedes; s && out.length < 100; ) {
|
|
18
|
+
const prev = readItem(dir, s)
|
|
19
|
+
if (!prev) break
|
|
20
|
+
out.push(prev.item)
|
|
21
|
+
s = prev.item.supersedes
|
|
22
|
+
}
|
|
23
|
+
return out
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** the file that stands for the change: the after of a pair, else the first image or clip */
|
|
27
|
+
async function pictureOf(dir: string, i: Item): Promise<string | null> {
|
|
28
|
+
const pick = stageablesOf(i, 1).find((s) => s.side !== 'before' && s.side !== 'wipe')
|
|
29
|
+
return pick ? ensureLocal(dir, i.id, pick.file) : null
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** what a card lends a change whatever its line: its newest version's picture kept private, the thread's first id, its
|
|
33
|
+
* commit */
|
|
34
|
+
export async function cardParts(root: string, x: ReviewItem, alt: string): Promise<Pick<Change, 'picture' | 'card' | 'commit'>> {
|
|
35
|
+
const dir = storeDir(root)
|
|
36
|
+
const file = await pictureOf(dir, x.item)
|
|
37
|
+
const url = file ? await keepPicture(root, file) : null
|
|
38
|
+
return { picture: url ? { url, alt } : null, card: versionsOf(dir, x).at(-1)!.id, commit: x.item.commit ?? null }
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** the change a card adds to next: its line and its parts; null for a card with no changelog line */
|
|
42
|
+
export async function changeOfCard(root: string, x: ReviewItem): Promise<{ category: string; change: Change } | null> {
|
|
43
|
+
const line = versionsOf(storeDir(root), x).find((v) => v.changelog)?.changelog
|
|
44
|
+
if (!line) return null
|
|
45
|
+
return { category: line.category, change: { title: line.line, text: '', bullets: [], ...(await cardParts(root, x, line.line)) } }
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** after the owner's verdict: an approved card with a changelog line goes into next.md, committed; the next.md path,
|
|
49
|
+
* or null when the verdict adds nothing. The description and bullets a hand wrote for that change stay. A repo that
|
|
50
|
+
* declares no release files throws, so the card's thread says why its line went nowhere */
|
|
51
|
+
export async function onVerdict(root: string, id: string): Promise<string | null> {
|
|
52
|
+
const x = readItem(storeDir(root), id)
|
|
53
|
+
if (!x || !isApproved(verdictOf(x)?.status ?? 'rejected')) return null
|
|
54
|
+
if (!versionsOf(storeDir(root), x).some((v) => v.changelog)) return null
|
|
55
|
+
const why = await undeclaredReleases(root)
|
|
56
|
+
if (why) throw new Error(why)
|
|
57
|
+
const c = await changeOfCard(root, x)
|
|
58
|
+
if (!c) return null
|
|
59
|
+
const had = readRelease(root, NEXT)
|
|
60
|
+
?.categories.flatMap((k) => k.changes)
|
|
61
|
+
.find((ch) => ch.card === c.change.card)
|
|
62
|
+
const change = had ? { ...c.change, text: had.text, bullets: had.bullets } : c.change
|
|
63
|
+
const { file } = addChange(root, c.category, change)
|
|
64
|
+
commitPaths([file], `releases: next takes the change of the card ${c.change.card}`)
|
|
65
|
+
return file
|
|
66
|
+
}
|