rvlib-shipkit 2.12.0 → 2.13.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 +48 -13
- package/README.md +1 -1
- package/package.json +4 -2
- package/src/agent-time/store.ts +2 -2
- package/src/check.ts +1 -1
- package/src/checks/SK001-package-json-shape.check.ts +4 -0
- package/src/checks/SK003-claude-md-shape.check.ts +1 -1
- package/src/checks/SK004-gitignore-policy.check.ts +27 -2
- package/src/checks/SK005-rvlib-versions.check.ts +1 -1
- package/src/checks/SK008-reviewer-agent.check.ts +2 -2
- package/src/checks/SK012-config-barrel-import.check.ts +1 -1
- package/src/checks/SK015-nested-repo.check.ts +1 -1
- package/src/checks/SK035-public-clean.check.ts +46 -0
- package/src/checks/SK036-draft-media-size.check.ts +28 -0
- package/src/cli/cmd_Backup.ts +152 -0
- package/src/cli/cmd_Ci.ts +8 -11
- package/src/cli/cmd_Drill.ts +145 -0
- package/src/cli/cmd_Home.ts +50 -3
- package/src/cli/cmd_Media.ts +7 -5
- package/src/cli/cmd_Review.ts +4 -2
- package/src/cli/cmd_Shot.ts +5 -2
- package/src/cli/cmd_Smoke.ts +4 -1
- package/src/cli/cmd_Social.ts +226 -0
- package/src/cli/cmd_Start.ts +1 -1
- package/src/cli/cmd_Time.ts +1 -1
- package/src/cli/cmd_Trailer.ts +5 -2
- package/src/cli/cmd_Veille.ts +173 -0
- package/src/cli/family-pages.ts +3 -0
- package/src/cli/registry.ts +13 -2
- package/src/cli.ts +5 -2
- package/src/collections/actions.ts +1 -49
- package/src/collections/checks.ts +2 -1
- package/src/collections/collection-types.ts +11 -2
- package/src/collections/providers.ts +4 -4
- package/src/collections/review.ts +2 -1
- package/src/collections/tests.ts +19 -8
- package/src/contracts/apply-contracts.ts +1 -3
- package/src/contracts/contract-manifests.ts +2 -3
- package/src/contracts/contract-types.ts +0 -1
- package/src/contracts/contracts-engine.ts +0 -3
- package/src/core/app-icon.ts +9 -3
- package/src/core/bun-builtins.ts +2 -2
- package/src/core/discover-checks.ts +37 -5
- package/src/core/fix-scope.ts +4 -2
- package/src/core/floor-resolve.ts +68 -48
- package/src/core/floor.ts +9 -0
- package/src/core/git-root.ts +24 -0
- package/src/core/last-good.ts +3 -1
- package/src/core/layout.ts +8 -0
- package/src/core/log-stamp.ts +36 -0
- package/src/core/loop-watch.ts +93 -0
- package/src/core/machine-link.ts +134 -0
- package/src/core/memory-watch.ts +41 -0
- package/src/core/one-way-in-policy.ts +27 -19
- package/src/core/run-ci.ts +6 -8
- package/src/core/run-fixers.ts +9 -9
- package/src/core/slots.ts +21 -0
- package/src/core/tree-rev.ts +60 -0
- package/src/core/unit-files.ts +42 -0
- package/src/drill/render.ts +140 -0
- package/src/drill/run.ts +269 -0
- package/src/fleet/scan-fleet.ts +6 -5
- package/src/home/daemon-jobs.ts +201 -0
- package/src/home/global-context.ts +34 -1
- package/src/home/home-routes.ts +22 -15
- package/src/home/hubs.ts +10 -3
- package/src/home/inbox-shape.ts +53 -4
- package/src/home/inbox.ts +16 -1
- package/src/home/lib-watch.ts +10 -3
- package/src/home/machine-stores.ts +15 -29
- package/src/home/run-daemon.ts +15 -18
- package/src/home/run-pm.ts +2 -0
- package/src/home/serve-daemon.ts +4 -3
- package/src/home/serve-web.ts +104 -1
- package/src/hooks/commit-message.ts +28 -19
- package/src/hooks/leak-guard.ts +10 -3
- package/src/hooks/run-hooks.ts +2 -6
- package/src/identities/identities.ts +334 -0
- package/src/identities/machine-route.ts +126 -0
- package/src/identities/machine.ts +62 -0
- package/src/init-repo.ts +1 -1
- package/src/ledger/check-stats.ts +10 -9
- package/src/ledger/gate-checks.ts +32 -1
- package/src/ledger/record-kept.ts +112 -0
- package/src/ledger/repo-view.ts +10 -0
- package/src/ledger/run-log.ts +17 -12
- package/src/ledger/run-timeline.ts +8 -4
- package/src/ledger/store.ts +7 -0
- package/src/ledger/suite-log.ts +17 -13
- package/src/media-kinds.ts +2 -1
- package/src/media-store/backup/daemon.ts +73 -0
- package/src/media-store/backup/keys.ts +25 -0
- package/src/media-store/backup/manifest.ts +193 -0
- package/src/media-store/backup/restore.ts +192 -0
- package/src/media-store/backup/run.ts +278 -0
- package/src/media-store/backup/secret.ts +86 -0
- package/src/media-store/backup/snapshot.ts +64 -0
- package/src/media-store/backup/sources.ts +199 -0
- package/src/media-store/daemon.ts +56 -70
- package/src/media-store/put.ts +4 -2
- package/src/media-store/space.ts +23 -4
- package/src/pages/forward.ts +35 -0
- package/src/pages/frame-client.ts +118 -0
- package/src/pages/routes.ts +29 -0
- package/src/pages/unit.ts +92 -0
- package/src/plan/planner.ts +12 -0
- package/src/plan/repo-source.ts +19 -5
- package/src/reflect/transcript.ts +35 -10
- package/src/release/public-clean.ts +301 -0
- package/src/release/published-here.ts +22 -0
- package/src/release/run-bump.ts +2 -1
- package/src/release/run-release.ts +4 -1
- package/src/repo-config.ts +53 -2
- package/src/review/http.ts +16 -2
- package/src/review/model.ts +15 -4
- package/src/review/notes.ts +77 -0
- package/src/review/project.ts +6 -38
- package/src/review/routes.ts +4 -12
- package/src/review/store.ts +41 -1
- package/src/review/trailer-media.ts +7 -4
- package/src/review/trailer-shots.ts +21 -4
- package/src/review/unit.ts +1 -1
- package/src/scaffold/files/agent-handoff.md +3 -0
- package/src/scaffold/files/agent-index.md +4 -12
- package/src/scaffold/project-scaffold.ts +5 -4
- package/src/serve/embed.ts +1 -1
- package/src/serve/hub-app/col-card.tsx +3 -17
- package/src/serve/hub-app/col-tables-view.tsx +2 -1
- package/src/serve/hub-app/cols-svc.ts +0 -13
- package/src/serve/hub-app/dock-st.ts +4 -2
- package/src/serve/hub-app/dock-view.tsx +2 -0
- package/src/serve/hub-app/frames-st.ts +35 -0
- package/src/serve/hub-app/hash-route.ts +64 -1
- package/src/serve/hub-app/home-st.ts +31 -7
- package/src/serve/hub-app/home-strip.css +9 -1
- package/src/serve/hub-app/home-strip.tsx +7 -6
- package/src/serve/hub-app/home.html +5 -0
- package/src/serve/hub-app/hub-app.tsx +49 -5
- package/src/serve/hub-app/hub.css +29 -11
- package/src/serve/hub-app/icons.tsx +16 -1
- package/src/serve/hub-app/identities-st.ts +210 -0
- package/src/serve/hub-app/identities-view.tsx +352 -0
- package/src/serve/hub-app/identities.css +48 -0
- package/src/serve/hub-app/identity-address.ts +52 -0
- package/src/serve/hub-app/inbox-st.ts +59 -6
- package/src/serve/hub-app/inbox-view.tsx +48 -6
- package/src/serve/hub-app/inbox.css +12 -1
- package/src/serve/hub-app/index.html +3 -0
- package/src/serve/hub-app/keys.ts +10 -2
- package/src/serve/hub-app/list-walk.ts +89 -0
- package/src/serve/hub-app/machine-st.ts +12 -0
- package/src/serve/hub-app/media-view.tsx +2 -1
- package/src/serve/hub-app/pages-frames.tsx +134 -0
- package/src/serve/hub-app/pages-svc.ts +111 -0
- package/src/serve/hub-app/palette-st.ts +18 -3
- package/src/serve/hub-app/palette-view.tsx +9 -2
- package/src/serve/hub-app/planned-view.tsx +2 -1
- package/src/serve/hub-app/project-list.css +18 -14
- package/src/serve/hub-app/project-list.tsx +88 -49
- package/src/serve/hub-app/projects-svc.ts +33 -3
- package/src/serve/hub-app/repo-sections.ts +19 -2
- package/src/serve/hub-app/repo-st.ts +75 -19
- package/src/serve/hub-app/review/review-cells.tsx +3 -3
- package/src/serve/hub-app/review/review-kit.ts +30 -7
- package/src/serve/hub-app/review/review-page.tsx +1 -1
- package/src/serve/hub-app/review/review-st.ts +19 -8
- package/src/serve/hub-app/review/review-thread.tsx +11 -9
- package/src/serve/hub-app/review/review-views.tsx +84 -19
- package/src/serve/hub-app/review/thread-st.ts +1 -10
- package/src/serve/hub-app/review/trailer-page.tsx +2 -1
- package/src/serve/hub-app/review.css +17 -8
- package/src/serve/hub-app/site/site-part.tsx +173 -0
- package/src/serve/hub-app/site/site-st.ts +157 -0
- package/src/serve/hub-app/site.css +35 -0
- package/src/serve/hub-app/social/calendar.tsx +182 -0
- package/src/serve/hub-app/social/comms-page.tsx +306 -0
- package/src/serve/hub-app/social/kit.tsx +244 -0
- package/src/serve/hub-app/social/post-card.tsx +456 -0
- package/src/serve/hub-app/social/problems.tsx +60 -0
- package/src/serve/hub-app/social/social-model.ts +154 -0
- package/src/serve/hub-app/social/social-page.tsx +674 -0
- package/src/serve/hub-app/social/social-st.ts +986 -0
- package/src/serve/hub-app/social.css +289 -0
- package/src/serve/hub-app/stores/stores-page.tsx +311 -0
- package/src/serve/hub-app/stores/stores-st.ts +286 -0
- package/src/serve/hub-app/stores.css +54 -0
- package/src/serve/hub-app/timeline-geometry.ts +1 -1
- package/src/serve/hub-app/timeline-view.tsx +3 -2
- package/src/serve/hub-app/tree-build.ts +6 -0
- package/src/serve/hub-app/tree-row.tsx +27 -4
- package/src/serve/hub-app/tree-svc.ts +18 -49
- package/src/serve/hub-app/veille/veille-page.tsx +514 -0
- package/src/serve/hub-app/veille/veille-st.ts +443 -0
- package/src/serve/hub-app/veille.css +84 -0
- package/src/serve/hub-runtime.ts +14 -9
- package/src/serve/project-gutter-route.ts +44 -12
- package/src/serve/run-lanes.ts +7 -4
- package/src/serve/same-origin.ts +1 -1
- package/src/serve/serve-hub.ts +20 -12
- package/src/serve/tracked-watch.ts +24 -3
- package/src/serve/warm-cell.ts +5 -1
- package/src/shipkit-files.ts +15 -4
- package/src/shipkit.ts +0 -1
- package/src/shot/box.ts +162 -0
- package/src/shot/browser-slot.ts +62 -0
- package/src/shot/client.ts +43 -7
- package/src/shot/clip-encoder.ts +93 -12
- package/src/shot/film-box.ts +188 -0
- package/src/shot/shooter.ts +50 -15
- package/src/shot/shot-ask.ts +10 -2
- package/src/shot/stepped-clip.ts +5 -4
- package/src/site/desk.ts +242 -0
- package/src/site/routes.ts +66 -0
- package/src/site/unit.ts +62 -0
- package/src/social/brands.ts +22 -0
- package/src/social/compose.ts +97 -0
- package/src/social/desk-index.ts +123 -0
- package/src/social/desk-wire.ts +64 -0
- package/src/social/drafts.ts +183 -0
- package/src/social/house.ts +24 -0
- package/src/social/load.ts +319 -0
- package/src/social/md.ts +70 -0
- package/src/social/media-facts.ts +53 -0
- package/src/social/media-kind.ts +189 -0
- package/src/social/media-limit.ts +42 -0
- package/src/social/media-of.ts +30 -0
- package/src/social/migrate.ts +123 -0
- package/src/social/open.ts +17 -0
- package/src/social/post-url.ts +158 -0
- package/src/social/presence.ts +332 -0
- package/src/social/public-read.ts +53 -0
- package/src/social/publish/bluesky.ts +168 -0
- package/src/social/publish/discord.ts +76 -0
- package/src/social/publish/index.ts +24 -0
- package/src/social/publish/secret.ts +13 -0
- package/src/social/push.ts +31 -0
- package/src/social/richtext.ts +37 -0
- package/src/social/routes.ts +180 -0
- package/src/social/stats.ts +134 -0
- package/src/social/text.ts +267 -0
- package/src/social/tracker-route.ts +39 -0
- package/src/social/tracker.ts +255 -0
- package/src/social/unit.ts +53 -0
- package/src/social/writes.ts +130 -0
- package/src/start-repo.ts +14 -9
- package/src/stores/collection.ts +27 -0
- package/src/stores/desk.ts +336 -0
- package/src/stores/model.ts +187 -0
- package/src/stores/routes.ts +126 -0
- package/src/stores/unit.ts +57 -0
- package/src/suite/calibrate.ts +127 -0
- package/src/suite/core-counters.ts +91 -0
- package/src/suite/judge-suites.ts +94 -34
- package/src/suite/suite-cli.ts +44 -10
- package/src/suite/suite-cpu-preload.ts +34 -9
- package/src/trailer/adapter.ts +4 -0
- package/src/trailer/build.ts +42 -11
- package/src/trailer/ffmpeg.ts +11 -0
- package/src/trailer/footage.ts +30 -13
- package/src/trailer/grammar.ts +18 -2
- package/src/trailer/graph.ts +28 -6
- package/src/trailer/passage.ts +17 -5
- package/src/trailer/plan.ts +74 -3
- package/src/trailer/stitch.ts +67 -26
- package/src/trailer/url.ts +1 -1
- package/src/trailer/versions.ts +24 -0
- package/src/ts/gate-typecheck.ts +32 -0
- package/src/ts/typecheck-cli.ts +9 -11
- package/src/tui/tui-app.tsx +0 -1
- package/src/veille/asks.ts +155 -0
- package/src/veille/auto.ts +31 -0
- package/src/veille/batch.ts +27 -0
- package/src/veille/chrome.ts +127 -0
- package/src/veille/collection.ts +28 -0
- package/src/veille/desk.ts +242 -0
- package/src/veille/identity.ts +80 -0
- package/src/veille/import.ts +68 -0
- package/src/veille/log.ts +183 -0
- package/src/veille/platforms.ts +118 -0
- package/src/veille/reads.ts +66 -0
- package/src/veille/replied.ts +110 -0
- package/src/veille/routes.ts +185 -0
- package/src/veille/service.ts +81 -0
- package/src/veille/watch.ts +116 -0
- package/src/veille/worth.ts +46 -0
- package/src/wiki/scan-md.ts +18 -0
- package/src/collections/posts.ts +0 -142
- package/src/contracts/manifests/social.contract.ts +0 -20
- package/src/scaffold/files/agent-coding.md +0 -35
- package/src/ts/typecheck-cache.ts +0 -11
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
// the desks' writes (wiki build/shipkit/social.md, The desks in the hub): a heading's text, a post's URL, an account's
|
|
2
|
+
// profile URL, a setup step. Each lands as a commit of its own paths (`git commit -- <paths>`, so no other staged work
|
|
3
|
+
// rides along), and the push goes in the background: a backup, never a wait, its failure an error line of the desk (push.ts). A path git ignores (a public repo's
|
|
4
|
+
// drafts) is saved by its file alone. The post URL's message is the one presence.ts reads the moment of a post from
|
|
5
|
+
import { existsSync, readFileSync, writeFileSync } from 'node:fs'
|
|
6
|
+
import { join } from 'node:path'
|
|
7
|
+
import { gitBin } from '../core/git-bin.ts'
|
|
8
|
+
import { STEP, type Account } from '../identities/identities.ts'
|
|
9
|
+
import { setHeadingText, setPostedLine } from './drafts.ts'
|
|
10
|
+
import { accountOf, draftPost, draftsDir, type Desk } from './load.ts'
|
|
11
|
+
import { setMeta } from './md.ts'
|
|
12
|
+
import { pushInBackground } from './push.ts'
|
|
13
|
+
|
|
14
|
+
const SLUG = /^[a-z0-9-]+$/
|
|
15
|
+
const read = (abs: string): string => readFileSync(abs, 'utf8')
|
|
16
|
+
|
|
17
|
+
/** the hosts a platform also answers on, beside the ones its account.md names */
|
|
18
|
+
const ALIASES: Readonly<Record<string, readonly string[]>> = {
|
|
19
|
+
'x.com': ['twitter.com'],
|
|
20
|
+
'threads.com': ['threads.net'],
|
|
21
|
+
'youtube.com': ['youtu.be'],
|
|
22
|
+
'discord.gg': ['discord.com'],
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const hostOf = (url: string): string => {
|
|
26
|
+
try {
|
|
27
|
+
return new URL(url).hostname.toLowerCase().replace(/^www\./, '')
|
|
28
|
+
} catch {
|
|
29
|
+
return ''
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** the hosts an account's own pages are on (profile, write, inbox, stats) and their aliases; empty when it names none */
|
|
34
|
+
function platformHosts(a: Pick<Account, 'profile' | 'write' | 'inbox' | 'stats'>): string[] {
|
|
35
|
+
const named = [a.profile, a.write, a.inbox, a.stats].map(hostOf).filter((h) => h !== '')
|
|
36
|
+
return [...new Set(named.flatMap((h) => [h, ...(ALIASES[h] ?? [])]))]
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** a pasted URL, refused when it is no URL or its host is not the account's platform (a subdomain counts) */
|
|
40
|
+
export function checkUrl(url: string | null, a: Pick<Account, 'name' | 'profile' | 'write' | 'inbox' | 'stats'>): void {
|
|
41
|
+
if (url == null) return
|
|
42
|
+
if (!/^https?:\/\/\S+$/.test(url) || hostOf(url) === '') throw new Error(`"${url}" is not a URL`)
|
|
43
|
+
const hosts = platformHosts(a)
|
|
44
|
+
const h = hostOf(url)
|
|
45
|
+
if (hosts.length === 0 || hosts.some((k) => h === k || h.endsWith(`.${k}`))) return
|
|
46
|
+
throw new Error(`"${url}" is on ${h}, not ${a.name}: ${a.name} takes a URL on ${hosts.join(' or ')}`)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** the paths committed alone in the repo that holds them, then pushed in the background; the ones git ignores stay
|
|
50
|
+
* local; nothing written, nothing done */
|
|
51
|
+
export function commitPaths(paths: string[], message: string): void {
|
|
52
|
+
if (paths.length === 0 || process.env['SHIPKIT_NO_AUTOCOMMIT'] === '1') return
|
|
53
|
+
const cwd = join(paths[0]!, '..')
|
|
54
|
+
const top = Bun.spawnSync([gitBin(), 'rev-parse', '--show-toplevel'], { cwd })
|
|
55
|
+
if (top.exitCode !== 0) throw new Error(`${paths[0]} is in no git repo`)
|
|
56
|
+
const root = top.stdout.toString().trim()
|
|
57
|
+
const run = (args: string[]): void => {
|
|
58
|
+
const r = Bun.spawnSync([gitBin(), ...args], { cwd: root, stderr: 'pipe', stdout: 'pipe' })
|
|
59
|
+
if (r.exitCode !== 0) throw new Error(`git ${args[0]}: ${r.stderr.toString().trim() || r.stdout.toString().trim()}`)
|
|
60
|
+
}
|
|
61
|
+
// exit 0 names the ignored paths as they were given, 1 none of them: a tracked file is never reported
|
|
62
|
+
const ig = Bun.spawnSync([gitBin(), 'check-ignore', '--', ...paths], { cwd: root, stderr: 'pipe', stdout: 'pipe' })
|
|
63
|
+
if (ig.exitCode > 1) throw new Error(`git check-ignore: ${ig.stderr.toString().trim()}`)
|
|
64
|
+
const ignored = new Set(ig.stdout.toString().split('\n').filter((l) => l !== ''))
|
|
65
|
+
const kept = paths.filter((p) => !ignored.has(p))
|
|
66
|
+
if (kept.length === 0) return
|
|
67
|
+
run(['add', '--', ...kept])
|
|
68
|
+
run(['commit', '-q', '-m', message, '--', ...kept])
|
|
69
|
+
if (process.env['SHIPKIT_SOCIAL_NO_PUSH'] !== '1') pushInBackground(root)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** one heading's text he edited, and its title and tags where given; the heading is the message's `from` */
|
|
73
|
+
export function setText(root: string, slug: string, key: string, text: string, title?: string, tags?: string): string[] {
|
|
74
|
+
if (!SLUG.test(slug)) throw new Error(`draft ${slug}?`)
|
|
75
|
+
const abs = join(draftsDir(root), slug, 'draft.md')
|
|
76
|
+
if (!existsSync(abs)) throw new Error(`no drafts/${slug}/draft.md`)
|
|
77
|
+
if (text.trim() === '') throw new Error(`## ${key}: an empty text`)
|
|
78
|
+
const before = read(abs)
|
|
79
|
+
const after = setHeadingText(before, key, text, title, tags)
|
|
80
|
+
if (after === before) return []
|
|
81
|
+
writeFileSync(abs, after)
|
|
82
|
+
commitPaths([abs], `social: ${slug} ## ${key} text edited in the desk`)
|
|
83
|
+
return [abs]
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** a post's URL he pasted: its line of `## Posted`; none, the line goes and it waits again */
|
|
87
|
+
export function setPosted(desk: Desk, slug: string, key: string, url: string | null): string[] {
|
|
88
|
+
const p = draftPost(desk, slug, key)
|
|
89
|
+
checkUrl(url, accountOf(desk, p.identity, p.platform))
|
|
90
|
+
const abs = join(desk.root, p.file)
|
|
91
|
+
const before = read(abs)
|
|
92
|
+
const after = setPostedLine(before, key, url)
|
|
93
|
+
if (after === before) return []
|
|
94
|
+
writeFileSync(abs, after)
|
|
95
|
+
commitPaths([abs], `social: ${key}/${slug} ${url == null ? 'is a draft again' : `is posted, ${url}`}`)
|
|
96
|
+
return [abs]
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** the profile URL he pasted, or none: the account is still to create */
|
|
100
|
+
export function setLive(desk: Desk, identity: string, account: string, url: string | null): string[] {
|
|
101
|
+
const a = accountOf(desk, identity, account)
|
|
102
|
+
checkUrl(url, a)
|
|
103
|
+
const before = read(a.file)
|
|
104
|
+
const after = setMeta(before, 'live', url ?? '')
|
|
105
|
+
if (after === before) return []
|
|
106
|
+
writeFileSync(a.file, after)
|
|
107
|
+
commitPaths([a.file], `social: ${identity} ${account} ${url == null ? 'is still to create' : `is online, ${url}`}`)
|
|
108
|
+
return [a.file]
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** one step of `## Setup` ticked or not, by its index among the bullets; its message and errors name it from 1, as the
|
|
112
|
+
* page numbers it */
|
|
113
|
+
export function setStep(desk: Desk, identity: string, account: string, index: number, done: boolean): string[] {
|
|
114
|
+
const a = accountOf(desk, identity, account)
|
|
115
|
+
const lines = read(a.file).split('\n')
|
|
116
|
+
const at = lines.findIndex((l) => l.trim() === '## Setup')
|
|
117
|
+
if (at === -1) throw new Error(`${a.file} has no ## Setup`)
|
|
118
|
+
let k = -1
|
|
119
|
+
for (let i = at + 1; i < lines.length && !lines[i]!.startsWith('## '); i++) {
|
|
120
|
+
const m = STEP.exec(lines[i]!)
|
|
121
|
+
if (m == null || ++k !== index) continue
|
|
122
|
+
const line = `- [${done ? 'x' : ' '}] ${m[2]}`
|
|
123
|
+
if (line === lines[i]) return []
|
|
124
|
+
lines[i] = line
|
|
125
|
+
writeFileSync(a.file, lines.join('\n'))
|
|
126
|
+
commitPaths([a.file], `social: ${identity} ${account} step ${index + 1} ${done ? 'done' : 'to do'}`)
|
|
127
|
+
return [a.file]
|
|
128
|
+
}
|
|
129
|
+
throw new Error(`${a.file}: no step ${index + 1}`)
|
|
130
|
+
}
|
package/src/start-repo.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
// for its parent shell).
|
|
10
10
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs'
|
|
11
11
|
import { homedir } from 'os'
|
|
12
|
-
import { join } from 'path'
|
|
12
|
+
import { dirname, join } from 'path'
|
|
13
13
|
import { ensureGitRepo, ensureIgnoreBaseline, firstGhLine, isScratch, publishRepo, runner, type Run } from './git-bootstrap.ts'
|
|
14
14
|
import { initRepo } from './init-repo.ts'
|
|
15
15
|
import { AGENT_LINE } from './checks/SK003-claude-md-shape.check.ts'
|
|
@@ -22,15 +22,20 @@ import { defaultHubPort } from './serve/hub-port.ts'
|
|
|
22
22
|
* Base context first, the repo's own router last, so repo docs override.
|
|
23
23
|
* A public repo swaps line 1 for the gitignored `@./CLAUDE.local.md`,
|
|
24
24
|
* which is why that line satisfies the first include (SK003) */
|
|
25
|
-
// sk-disable-next-line RV003 -- the start template writes the house include line itself
|
|
25
|
+
// sk-disable-next-line RV003, SK035 -- the start template writes the house include line itself
|
|
26
26
|
export const HOUSE_INCLUDE = ['@~/dev/corvion/wiki/index.md', '@./agent/index.md']
|
|
27
27
|
export const HOUSE_ALSO_OK = ['@./CLAUDE.local.md']
|
|
28
|
-
/** the day-job checkout: never wired, never given an include */
|
|
29
|
-
// sk-disable-next-line RV003 -- start refuses the day-job checkout by its name
|
|
30
|
-
export const HOUSE_SKIP = ['monoloco']
|
|
31
|
-
|
|
32
28
|
/** a repo shipkit never touches: no CLAUDE.md, no git, no scaffold, no push */
|
|
33
|
-
export const isSkipped = (name: string, skip: readonly string[]
|
|
29
|
+
export const isSkipped = (name: string, skip: readonly string[]): boolean => skip.includes(name)
|
|
30
|
+
|
|
31
|
+
/** the repo names the house config lists under `start.skip` (a day-job checkout belongs there), [] with no house:
|
|
32
|
+
* the names live on the machine, never in this published lib */
|
|
33
|
+
export async function houseSkip(home: string): Promise<string[]> {
|
|
34
|
+
const root = dirname(dirname(housePath(home)))
|
|
35
|
+
if (!existsSync(join(root, 'repo.config.ts'))) return []
|
|
36
|
+
const { loadRepoConfig } = await import('./repo-config.ts')
|
|
37
|
+
return [...((await loadRepoConfig(root)).start?.skip ?? [])]
|
|
38
|
+
}
|
|
34
39
|
|
|
35
40
|
/** where the first house line points, `~` resolved against `home` */
|
|
36
41
|
export const housePath = (home: string): string => {
|
|
@@ -45,7 +50,7 @@ export type StartOpts = {
|
|
|
45
50
|
include?: string[]
|
|
46
51
|
/** alternative lines that satisfy the FIRST include — never double-add; omitted = HOUSE_ALSO_OK */
|
|
47
52
|
alsoOk?: string[]
|
|
48
|
-
/** repo names shipkit never touches; omitted =
|
|
53
|
+
/** repo names shipkit never touches; omitted = the house config's `start.skip` */
|
|
49
54
|
skip?: string[]
|
|
50
55
|
/** the home dir the first house line resolves against; omitted = os.homedir() */
|
|
51
56
|
home?: string
|
|
@@ -80,7 +85,7 @@ export async function startRepo(name: string, opts: StartOpts = {}): Promise<num
|
|
|
80
85
|
const house = opts.include ?? (houseOnDisk ? HOUSE_INCLUDE : [])
|
|
81
86
|
if (opts.include == null && !houseOnDisk) console.error(`skip: no house wiki at ${housePath(home)} — CLAUDE.md gets the agent route only, and no .claude/ policy files`)
|
|
82
87
|
const alt = opts.alsoOk ?? HOUSE_ALSO_OK
|
|
83
|
-
const skipped = isSkipped(name, opts.skip)
|
|
88
|
+
const skipped = isSkipped(name, opts.skip ?? (houseOnDisk ? await houseSkip(home) : []))
|
|
84
89
|
if (skipped && house.length > 0) console.error(`skip: ${name} is include-exempt — CLAUDE.md untouched`)
|
|
85
90
|
// start is the from-anywhere verb, and a STARTED repo comes out READY:
|
|
86
91
|
// any dir with no commit history gets a minimal package.json, a first
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// the store pages as tree rows (wiki build/shipkit/stores.md, The page): one row a store the repo has a venue folder
|
|
2
|
+
// for, its page's state in the slot. Only the preamble and the itch front matter are read: the tree recomputes often
|
|
3
|
+
import { existsSync, readFileSync } from 'node:fs'
|
|
4
|
+
import { join } from 'node:path'
|
|
5
|
+
import { STORES_COL, type Collection, type Instance } from '../collections/collection-types.ts'
|
|
6
|
+
import { ITCH_DIR, pageState, sectionsOf, STEAM_DIR, STORE_NAME } from './model.ts'
|
|
7
|
+
import { storesOf } from './desk.ts'
|
|
8
|
+
|
|
9
|
+
const MAIN = { steam: `${STEAM_DIR}/store.md`, itch: `${ITCH_DIR}/listing.md` } as const
|
|
10
|
+
|
|
11
|
+
export function storesCollection(root: string): Collection | null {
|
|
12
|
+
if (storesOf(root).length === 0) return null
|
|
13
|
+
return {
|
|
14
|
+
id: STORES_COL,
|
|
15
|
+
title: 'stores',
|
|
16
|
+
kind: 'store',
|
|
17
|
+
media: 'text',
|
|
18
|
+
list: async () =>
|
|
19
|
+
storesOf(root).map((id): Instance => {
|
|
20
|
+
const abs = join(root, MAIN[id])
|
|
21
|
+
const md = existsSync(abs) ? readFileSync(abs, 'utf8') : ''
|
|
22
|
+
const url = id === 'itch' ? (/^itchUrl:[ \t]*(\S+)/m.exec(md)?.[1] ?? null) : null
|
|
23
|
+
const page = pageState(sectionsOf(md).preamble, url)
|
|
24
|
+
return { id: `store:${id}`, text: `${STORE_NAME[id]} store page (${page})`, label: STORE_NAME[id], slot: page, type: 'store', path: MAIN[id], state: page === 'online' ? 'ok' : 'idle' }
|
|
25
|
+
}),
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
// the stores desk on the server (wiki build/shipkit/stores.md): each store page read from its venue folder at every
|
|
2
|
+
// load, the repo's stores unit found and read, the seller named, the contract asked in process, his notes on every
|
|
3
|
+
// thing read once. desk.ts reads; routes.ts writes
|
|
4
|
+
import { closeSync, existsSync, openSync, readdirSync, readFileSync, readSync, statSync } from 'node:fs'
|
|
5
|
+
import { join, normalize } from 'node:path'
|
|
6
|
+
import { importFresh, repoUnitFiles } from '../core/discover-checks.ts'
|
|
7
|
+
import { runContracts } from '../contracts/run-contracts.ts'
|
|
8
|
+
import { loadIdentities, speakerOf } from '../identities/identities.ts'
|
|
9
|
+
import { loadRepoConfig } from '../repo-config.ts'
|
|
10
|
+
import type { Subject } from '../review/model.ts'
|
|
11
|
+
import { notesBy, type SubjectNote } from '../review/notes.ts'
|
|
12
|
+
import { readAllCached } from '../review/store.ts'
|
|
13
|
+
import {
|
|
14
|
+
askSteps,
|
|
15
|
+
capsuleRows,
|
|
16
|
+
contractLines,
|
|
17
|
+
fieldAsset,
|
|
18
|
+
ITCH_DIR,
|
|
19
|
+
pageState,
|
|
20
|
+
pathsIn,
|
|
21
|
+
PICTURE_SECTIONS,
|
|
22
|
+
sectionsOf,
|
|
23
|
+
STEAM_DIR,
|
|
24
|
+
STORE_FILES,
|
|
25
|
+
STORE_IDS,
|
|
26
|
+
STORE_NAME,
|
|
27
|
+
valueOf,
|
|
28
|
+
type ContractLine,
|
|
29
|
+
type FieldSpec,
|
|
30
|
+
type PageState,
|
|
31
|
+
type StoreId,
|
|
32
|
+
type Tone,
|
|
33
|
+
} from './model.ts'
|
|
34
|
+
import { partOf, storesProblem, type RenderFamily, type StoresUnit } from './unit.ts'
|
|
35
|
+
|
|
36
|
+
export const FILE_ROUTE = '/api/stores/file/'
|
|
37
|
+
|
|
38
|
+
export type Family = 'capsules' | 'shots' | 'trailer' | 'cover'
|
|
39
|
+
|
|
40
|
+
export interface Picture {
|
|
41
|
+
path: string
|
|
42
|
+
name: string
|
|
43
|
+
/** the store's slot it fills (a capsule) */
|
|
44
|
+
slot?: string
|
|
45
|
+
/** relative to the hub's base; null while the file does not exist */
|
|
46
|
+
url: string | null
|
|
47
|
+
w: number | null
|
|
48
|
+
h: number | null
|
|
49
|
+
/** the size the store asks */
|
|
50
|
+
want?: { w: number; h: number }
|
|
51
|
+
bytes: number
|
|
52
|
+
clip: boolean
|
|
53
|
+
/** an icon's sizes, `16, 32, 256` */
|
|
54
|
+
ico?: string
|
|
55
|
+
said: SubjectNote[]
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface FieldView {
|
|
59
|
+
file: string
|
|
60
|
+
heading: string
|
|
61
|
+
body: string
|
|
62
|
+
value: string
|
|
63
|
+
aside: string
|
|
64
|
+
max?: number
|
|
65
|
+
names: boolean
|
|
66
|
+
steamMarkup: boolean
|
|
67
|
+
said: SubjectNote[]
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface FamilyView {
|
|
71
|
+
id: Family
|
|
72
|
+
title: string
|
|
73
|
+
caption: string
|
|
74
|
+
/** the unit makes it again: its command's words */
|
|
75
|
+
render?: { family: RenderFamily; cmd: string; about: string }
|
|
76
|
+
pictures: Picture[]
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export interface StoreView {
|
|
80
|
+
id: StoreId
|
|
81
|
+
name: string
|
|
82
|
+
page: PageState
|
|
83
|
+
url: string | null
|
|
84
|
+
facts: { label: string; value: string; tone: Tone }[]
|
|
85
|
+
/** the files to open in the editor: the texts, the ask */
|
|
86
|
+
files: { label: string; abs: string }[]
|
|
87
|
+
contract: ContractLine[]
|
|
88
|
+
preamble: string
|
|
89
|
+
fields: FieldView[]
|
|
90
|
+
families: FamilyView[]
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export interface StoresState {
|
|
94
|
+
/** the identity the repo speaks as, the seller of its pages; null when the repo names none */
|
|
95
|
+
seller: { id: string; name: string } | null
|
|
96
|
+
stores: StoreView[]
|
|
97
|
+
/** what is wrong with the repo's stores unit, shown on the page */
|
|
98
|
+
unitError: string | null
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** the stores a repo has: a venue folder each */
|
|
102
|
+
export const storesOf = (root: string): StoreId[] => STORE_IDS.filter((id) => existsSync(join(root, id === 'steam' ? STEAM_DIR : ITCH_DIR)))
|
|
103
|
+
|
|
104
|
+
/** the repo's stores unit, or null; two of them is an error naming both files. Imported again when its file moves */
|
|
105
|
+
export async function loadStoresUnit(root: string): Promise<StoresUnit | null> {
|
|
106
|
+
const found: { file: string; unit: StoresUnit }[] = []
|
|
107
|
+
for (const f of repoUnitFiles(root)) {
|
|
108
|
+
if (f.endsWith('.check.shipkit.ts') || !/\bstores\s*\(|kind:\s*['"]stores['"]/.test(readFileSync(f, 'utf8'))) continue
|
|
109
|
+
const d = (await importFresh(f)) as { kind?: unknown } | undefined
|
|
110
|
+
if (d?.kind !== 'stores') continue
|
|
111
|
+
const why = storesProblem(d as StoresUnit)
|
|
112
|
+
if (why !== null) throw new Error(`${f}: ${why}`)
|
|
113
|
+
found.push({ file: f, unit: d as StoresUnit })
|
|
114
|
+
}
|
|
115
|
+
if (found.length > 1) throw new Error(`two stores units: ${found.map((x) => x.file).join(' and ')}; keep one`)
|
|
116
|
+
return found[0]?.unit ?? null
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** a png's size from its header, an ico's sizes from its directory */
|
|
120
|
+
function sizeOf(abs: string): { w: number | null; h: number | null; ico?: string } {
|
|
121
|
+
const head = Buffer.alloc(6 + 16 * 16)
|
|
122
|
+
const fd = openSync(abs, 'r')
|
|
123
|
+
const n = readSync(fd, head, 0, head.length, 0)
|
|
124
|
+
closeSync(fd)
|
|
125
|
+
if (n >= 24 && head.toString('latin1', 1, 4) === 'PNG') return { w: head.readUInt32BE(16), h: head.readUInt32BE(20) }
|
|
126
|
+
if (abs.endsWith('.ico') && n >= 6) {
|
|
127
|
+
const count = Math.min(16, head.readUInt16LE(4))
|
|
128
|
+
const sides = [...Array(count).keys()].map((i) => head[6 + 16 * i] || 256).sort((a, b) => a - b)
|
|
129
|
+
const big = sides.at(-1) ?? null
|
|
130
|
+
return { w: big, h: big, ico: sides.join(', ') }
|
|
131
|
+
}
|
|
132
|
+
return { w: null, h: null }
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
type Said = (subject: Subject) => SubjectNote[]
|
|
136
|
+
|
|
137
|
+
/** what the desk reads of one repo once a load */
|
|
138
|
+
interface Ctx {
|
|
139
|
+
root: string
|
|
140
|
+
unit: StoresUnit | null
|
|
141
|
+
said: Said
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const readRel = (root: string, rel: string): string => (existsSync(join(root, rel)) ? readFileSync(join(root, rel), 'utf8') : '')
|
|
145
|
+
|
|
146
|
+
function picture(c: Ctx, store: StoreId, path: string, extra: { slot?: string; want?: { w: number; h: number } } = {}): Picture {
|
|
147
|
+
const abs = join(c.root, path)
|
|
148
|
+
const name = path.split('/').pop() ?? path
|
|
149
|
+
const clip = /\.(mp4|webm)$/i.test(path)
|
|
150
|
+
const said = c.said({ kind: 'store', store, asset: path })
|
|
151
|
+
if (!existsSync(abs)) return { path, name, url: null, w: null, h: null, bytes: 0, clip, said, ...extra }
|
|
152
|
+
const st = statSync(abs)
|
|
153
|
+
const url = `${FILE_ROUTE.slice(1)}${path.split('/').map(encodeURIComponent).join('/')}?v=${Math.round(st.mtimeMs)}`
|
|
154
|
+
return { path, name, url, ...(clip ? { w: null, h: null } : sizeOf(abs)), bytes: st.size, clip, said, ...extra }
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/** the store's text files: its own, then the unit's */
|
|
158
|
+
export function textFiles(unit: StoresUnit | null, store: StoreId): { file: string; fields: readonly FieldSpec[] }[] {
|
|
159
|
+
return [...STORE_FILES[store], ...(partOf(unit, store).texts ?? []).map((file) => ({ file, fields: [] }))]
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** the store's text files as fields, its sections about pictures kept apart for the right column */
|
|
163
|
+
function fieldsOf(c: Ctx, store: StoreId): { preamble: string; fields: FieldView[]; pictures: Map<string, string> } {
|
|
164
|
+
const pictures = new Map<string, string>()
|
|
165
|
+
const fields: FieldView[] = []
|
|
166
|
+
let preamble = ''
|
|
167
|
+
for (const f of textFiles(c.unit, store)) {
|
|
168
|
+
const s = sectionsOf(readRel(c.root, f.file))
|
|
169
|
+
if (!preamble) preamble = s.preamble
|
|
170
|
+
for (const sec of s.sections) {
|
|
171
|
+
if (PICTURE_SECTIONS.has(sec.heading)) {
|
|
172
|
+
pictures.set(sec.heading, sec.body)
|
|
173
|
+
continue
|
|
174
|
+
}
|
|
175
|
+
const spec = f.fields.find((x) => x.heading === sec.heading)
|
|
176
|
+
const pick = spec?.pick ?? 'all'
|
|
177
|
+
const { value, notes } = valueOf(sec.body, pick)
|
|
178
|
+
fields.push({
|
|
179
|
+
file: f.file,
|
|
180
|
+
heading: sec.heading,
|
|
181
|
+
body: sec.body,
|
|
182
|
+
value,
|
|
183
|
+
aside: notes,
|
|
184
|
+
...(spec?.max ? { max: spec.max } : {}),
|
|
185
|
+
names: pick === 'names',
|
|
186
|
+
steamMarkup: spec?.steamMarkup === true,
|
|
187
|
+
said: c.said({ kind: 'store', store, asset: fieldAsset(sec.heading) }),
|
|
188
|
+
})
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
return { preamble, fields, pictures }
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
const pngsIn = (root: string, dir: string): string[] =>
|
|
195
|
+
existsSync(join(root, dir))
|
|
196
|
+
? readdirSync(join(root, dir))
|
|
197
|
+
.filter((f) => f.endsWith('.png'))
|
|
198
|
+
.sort()
|
|
199
|
+
.map((f) => `${dir}/${f}`)
|
|
200
|
+
: []
|
|
201
|
+
|
|
202
|
+
/** `sk contracts --venue <store>`, asked in process: its lines */
|
|
203
|
+
async function contract(root: string, store: StoreId): Promise<ContractLine[]> {
|
|
204
|
+
const out: string[] = []
|
|
205
|
+
try {
|
|
206
|
+
await runContracts(root, { venue: store, print: (l) => out.push(l), printErr: (l) => out.push(l) })
|
|
207
|
+
} catch (e) {
|
|
208
|
+
out.push(`FAIL contracts: ${(e as Error).message}`)
|
|
209
|
+
}
|
|
210
|
+
const text = out.join('\n')
|
|
211
|
+
// the wire is coloured on a terminal
|
|
212
|
+
const lines = contractLines(text.replace(/\x1b\[[0-9;]*m/g, ''))
|
|
213
|
+
return lines.length > 0 ? lines : [{ level: 'fail', text: `sk contracts --venue ${store}: ${text.trim() || 'no answer'}` }]
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/** the account's ask by its file name, open or done */
|
|
217
|
+
export function askFile(root: string, name: string | undefined): string | null {
|
|
218
|
+
if (!name) return null
|
|
219
|
+
for (const rel of [`.shipkit/asks/${name}.md`, `.shipkit/asks/done/${name}.md`]) if (existsSync(join(root, rel))) return rel
|
|
220
|
+
return null
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function renderOf(c: Ctx, family: RenderFamily): FamilyView['render'] {
|
|
224
|
+
const r = c.unit?.render?.[family]
|
|
225
|
+
return r ? { family, cmd: r.cmd.join(' '), about: r.about ?? '' } : undefined
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
async function steam(c: Ctx): Promise<StoreView> {
|
|
229
|
+
const { preamble, fields, pictures } = fieldsOf(c, 'steam')
|
|
230
|
+
const askRel = askFile(c.root, partOf(c.unit, 'steam').ask)
|
|
231
|
+
const ask = askSteps(askRel ? readRel(c.root, askRel) : '')
|
|
232
|
+
const appid = readRel(c.root, `${STEAM_DIR}/steam_appid.txt`).trim() || ask.answer
|
|
233
|
+
const capsules = capsuleRows(pictures.get('Capsules') ?? '').map((x) => picture(c, 'steam', `${STEAM_DIR}/capsules/${x.file}`, { slot: x.slot, ...(x.w && x.h ? { want: { w: x.w, h: x.h } } : {}) }))
|
|
234
|
+
const trailer = pathsIn(pictures.get('Trailer') ?? '', /\.(mp4|webm)$/i)
|
|
235
|
+
const page = pageState(preamble, null)
|
|
236
|
+
const capsulesRender = renderOf(c, 'capsules')
|
|
237
|
+
const shotsRender = renderOf(c, 'shots')
|
|
238
|
+
return {
|
|
239
|
+
id: 'steam',
|
|
240
|
+
name: STORE_NAME.steam,
|
|
241
|
+
page,
|
|
242
|
+
url: null,
|
|
243
|
+
facts: [
|
|
244
|
+
...ask.steps.map((s) => ({ label: s.title, value: s.tone === 'done' ? 'done' : s.tone === 'waiting' ? 'waiting' : 'to do', tone: s.tone })),
|
|
245
|
+
{ label: 'App id', value: appid ?? 'not yet', tone: appid ? 'done' : 'todo' },
|
|
246
|
+
{ label: 'Store page', value: page, tone: page === 'online' ? 'done' : 'waiting' },
|
|
247
|
+
],
|
|
248
|
+
files: [
|
|
249
|
+
...textFiles(c.unit, 'steam').map((f) => ({ label: f.file.split('/').pop() ?? f.file, abs: join(c.root, f.file) })),
|
|
250
|
+
...(askRel ? [{ label: `the Steamworks ask (${ask.status ?? '?'})`, abs: join(c.root, askRel) }] : []),
|
|
251
|
+
],
|
|
252
|
+
contract: await contract(c.root, 'steam'),
|
|
253
|
+
preamble,
|
|
254
|
+
fields,
|
|
255
|
+
families: [
|
|
256
|
+
{ id: 'capsules', title: 'Capsules', caption: pictures.get('Capsules')?.split('\n')[0] ?? '', ...(capsulesRender ? { render: capsulesRender } : {}), pictures: capsules },
|
|
257
|
+
{
|
|
258
|
+
id: 'shots',
|
|
259
|
+
title: 'Screenshots',
|
|
260
|
+
caption: pictures.get('Screenshots') ?? '',
|
|
261
|
+
...(shotsRender ? { render: shotsRender } : {}),
|
|
262
|
+
pictures: pngsIn(c.root, `${STEAM_DIR}/screenshots`).map((p) => picture(c, 'steam', p, { want: { w: 1920, h: 1080 } })),
|
|
263
|
+
},
|
|
264
|
+
{ id: 'trailer', title: 'Trailer', caption: pictures.get('Trailer') ?? '', pictures: trailer.map((p) => picture(c, 'steam', p)) },
|
|
265
|
+
],
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
async function itch(c: Ctx): Promise<StoreView> {
|
|
270
|
+
const { preamble, fields, pictures } = fieldsOf(c, 'itch')
|
|
271
|
+
const listing = readRel(c.root, `${ITCH_DIR}/listing.md`)
|
|
272
|
+
const url = /^itchUrl:[ \t]*(\S+)/m.exec(listing)?.[1] ?? null
|
|
273
|
+
const pasted = /^lastPastedAt:[ \t]*(\S+)/m.exec(listing)?.[1] ?? null
|
|
274
|
+
const cover = pathsIn(pictures.get('Cover image') ?? '', /\.(png|jpe?g)$/i)
|
|
275
|
+
const page = pageState(preamble, url)
|
|
276
|
+
const shotsRender = renderOf(c, 'shots')
|
|
277
|
+
return {
|
|
278
|
+
id: 'itch',
|
|
279
|
+
name: STORE_NAME.itch,
|
|
280
|
+
page,
|
|
281
|
+
url,
|
|
282
|
+
facts: [
|
|
283
|
+
{ label: 'itch page', value: url ?? 'not created', tone: url ? 'done' : 'todo' },
|
|
284
|
+
{ label: 'Last pasted', value: pasted ?? 'never', tone: pasted ? 'done' : 'todo' },
|
|
285
|
+
{ label: 'Store page', value: page, tone: page === 'online' ? 'done' : 'waiting' },
|
|
286
|
+
],
|
|
287
|
+
files: textFiles(c.unit, 'itch').map((f) => ({ label: f.file.split('/').pop() ?? f.file, abs: join(c.root, f.file) })),
|
|
288
|
+
contract: await contract(c.root, 'itch'),
|
|
289
|
+
preamble,
|
|
290
|
+
fields,
|
|
291
|
+
families: [
|
|
292
|
+
{ id: 'cover', title: 'Cover', caption: pictures.get('Cover image') ?? '', pictures: cover.map((p) => picture(c, 'itch', p, { want: { w: 630, h: 500 } })) },
|
|
293
|
+
{
|
|
294
|
+
id: 'shots',
|
|
295
|
+
title: 'Screenshots',
|
|
296
|
+
caption: pictures.get('Screenshots') ?? '',
|
|
297
|
+
...(shotsRender ? { render: shotsRender } : {}),
|
|
298
|
+
pictures: pngsIn(c.root, `${STEAM_DIR}/screenshots`).map((p) => picture(c, 'itch', p, { want: { w: 1920, h: 1080 } })),
|
|
299
|
+
},
|
|
300
|
+
],
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/** the identity the repo speaks as (`speaksAs`, else the default identity), named from the identities */
|
|
305
|
+
async function sellerOf(root: string): Promise<StoresState['seller']> {
|
|
306
|
+
const cfg = await loadRepoConfig(root).catch(() => null)
|
|
307
|
+
const ids = await loadIdentities({ cwd: root }).catch(() => null)
|
|
308
|
+
const who = ids ? speakerOf(cfg?.speaksAs, ids) : null
|
|
309
|
+
if (who) return { id: who.id, name: who.name }
|
|
310
|
+
return cfg?.speaksAs ? { id: cfg.speaksAs, name: cfg.speaksAs } : null
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/** the whole desk of one repo: every store it has, its unit's parts, his notes on each thing */
|
|
314
|
+
export async function storesState(root: string, reviewDir: string): Promise<StoresState> {
|
|
315
|
+
let unit: StoresUnit | null = null
|
|
316
|
+
let unitError: string | null = null
|
|
317
|
+
try {
|
|
318
|
+
unit = await loadStoresUnit(root)
|
|
319
|
+
} catch (e) {
|
|
320
|
+
unitError = (e as Error).message
|
|
321
|
+
}
|
|
322
|
+
const items = existsSync(reviewDir) ? readAllCached(reviewDir).items : []
|
|
323
|
+
const c: Ctx = { root, unit, said: notesBy(reviewDir, items) }
|
|
324
|
+
const ids = storesOf(root)
|
|
325
|
+
const stores = await Promise.all(ids.map((id) => (id === 'steam' ? steam(c) : itch(c))))
|
|
326
|
+
return { seller: await sellerOf(root), stores, unitError }
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/** a file the desk shows: an image under a store folder, or a clip store.md names; any other path is refused */
|
|
330
|
+
export function shownFile(root: string, rel: string): string | null {
|
|
331
|
+
const path = normalize(rel)
|
|
332
|
+
if (path.startsWith('..') || path.startsWith('/')) return null
|
|
333
|
+
const named = pathsIn(sectionsOf(readRel(root, `${STEAM_DIR}/store.md`)).sections.find((s) => s.heading === 'Trailer')?.body ?? '', /\.(mp4|webm)$/i)
|
|
334
|
+
const ok = ((path.startsWith(`${STEAM_DIR}/`) || path.startsWith(`${ITCH_DIR}/`)) && /\.(png|jpe?g|ico)$/i.test(path)) || named.includes(path)
|
|
335
|
+
return ok && existsSync(join(root, path)) ? join(root, path) : null
|
|
336
|
+
}
|