Skip to content

Commit 54a880e

Browse files
committed
feat(screenshots): export Pen App Store layouts from mobile captures
1 parent d2c9281 commit 54a880e

21 files changed

Lines changed: 10156 additions & 0 deletions

‎.github/workflows/mobile-showcase-screenshots.yml‎

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ on:
3434
- ember
3535
- iris
3636
- all
37+
pen_assets:
38+
description: Export G dark and H light iPhone marketing layouts (requires PEN_CLI_KEY)
39+
type: boolean
40+
default: true
3741

3842
permissions:
3943
contents: read
@@ -102,6 +106,52 @@ jobs:
102106
if-no-files-found: warn
103107
retention-days: 14
104108

109+
pen-assets:
110+
name: Pen App Store layouts
111+
needs: ios
112+
if: inputs.pen_assets
113+
runs-on: ubuntu-latest
114+
timeout-minutes: 30
115+
steps:
116+
- name: Check Pen key
117+
env:
118+
PEN_CLI_KEY: ${{ secrets.PEN_CLI_KEY }}
119+
run: test -n "$PEN_CLI_KEY" || { echo 'Add the PEN_CLI_KEY repository Actions secret to export Pen layouts.'; exit 1; }
120+
121+
- name: Checkout
122+
uses: actions/checkout@v6
123+
124+
- name: Setup Vite+
125+
uses: voidzero-dev/setup-vp@v1
126+
with:
127+
node-version-file: package.json
128+
cache: true
129+
run-install: |
130+
args:
131+
- --filter=@t3tools/scripts...
132+
133+
- name: Install Pen CLI
134+
run: npm install --global @pen.dev/[email protected]
135+
136+
- name: Download iOS captures
137+
uses: actions/download-artifact@v8
138+
with:
139+
name: app-store-connect-screenshots
140+
path: artifacts/app-store/screenshots/apple/
141+
142+
- name: Export and validate Pen layouts
143+
env:
144+
PEN_CLI_KEY: ${{ secrets.PEN_CLI_KEY }}
145+
run: node scripts/mobile-showcase-assets.ts --appearance "${{ inputs.appearance }}" --theme "${{ inputs.theme }}"
146+
147+
- name: Upload Pen layouts
148+
uses: actions/upload-artifact@v7
149+
with:
150+
name: app-store-pen-layouts
151+
path: artifacts/app-store/pen/
152+
if-no-files-found: error
153+
retention-days: 14
154+
105155
android:
106156
name: Android phone, 7-inch tablet, and 10-inch tablet
107157
if: inputs.platform == 'all' || inputs.platform == 'android'

‎docs/operations/mobile-app-store-screenshots.md‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,30 @@ capture fails, the `always()` upload still publishes partial PNGs without re-val
123123
Download `app-store-connect-screenshots` and `google-play-screenshots` from the workflow run's
124124
Artifacts section. Artifacts are retained for 14 days.
125125

126+
For iOS runs, `pen_assets` also exports the checked-in G dark and H light designs as
127+
`app-store-pen-layouts`. Add an organization CLI key from pen.dev to the repository's
128+
Actions secrets as `PEN_CLI_KEY`, or turn off `pen_assets` to capture only raw screenshots.
129+
The export runs on a separate Linux runner after iOS validation succeeds; it needs no laptop
130+
or open Pen application. Each selected appearance and palette gets seven 1290×2796 RGB PNGs.
131+
These are iPhone marketing layouts; the iPad and Google Play artifacts remain separate.
132+
133+
The exporter replaces the six phone-screen images with fresh iPhone 6.9-inch captures. It keeps
134+
the original text, phone frame, crop mode, decorative callout cards, and testimonials. The
135+
designed callouts are fixed artwork, not additional live captures. Pen's CLI version is pinned;
136+
exports use scale 1, and missing files, export errors, or incorrect dimensions fail the job.
137+
Rendering can differ slightly from desktop exports around antialiased edges and shadows.
138+
139+
Edit G/H and their shared components in
140+
[`app-store.pen`](../../scripts/mobile-showcase-assets/app-store.pen), keeping its adjacent
141+
asset folder. After changing the design, verify both appearances against the intended exports:
142+
143+
npm install --global @pen.dev/[email protected]
144+
node scripts/mobile-showcase-assets.ts --appearance both --theme t3-code
145+
146+
Set `PEN_CLI_KEY` in the environment before running the exporter. `--input` selects the
147+
`iphone-6.9` capture directory; `--output` selects the designed-image destination. Design changes
148+
must be committed to the repository before the workflow uses them.
149+
126150
The workflow uses the same checked-in device and scene matrix as local capture. Android remains
127151
ARM64 by default for local Apple Silicon development; CI sets `T3_SHOWCASE_ANDROID_ABI=x86_64` so the
128152
debug APK matches its accelerated emulator.
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
// @effect-diagnostics nodeBuiltinImport:off - Tests the host-side image export files.
2+
import * as NodeFSP from "node:fs/promises";
3+
import * as NodeOS from "node:os";
4+
import * as NodePath from "node:path";
5+
import * as NodeURL from "node:url";
6+
import { assert, expect, it } from "@effect/vitest";
7+
import { PNG } from "pngjs";
8+
9+
import {
10+
PEN_LAYOUTS,
11+
PEN_SCENES,
12+
penScreenshotFilename,
13+
preparePenAssets,
14+
} from "./mobile-showcase-assets.ts";
15+
16+
const templateDirectory = NodeURL.fileURLToPath(
17+
new URL("./mobile-showcase-assets/", import.meta.url),
18+
);
19+
const assetsDirectory = "T3 Code AppStore Assets-assets";
20+
21+
it("keeps the G/H layouts and artwork intact while replacing all six matching captures", async () => {
22+
const directory = await NodeFSP.mkdtemp(NodePath.join(NodeOS.tmpdir(), "t3-pen-test-"));
23+
try {
24+
const input = NodePath.join(directory, "input");
25+
await NodeFSP.mkdir(input);
26+
const captures = PEN_SCENES.map(([, scene], index) => ({
27+
scene,
28+
bytes: PNG.sync.write(
29+
Object.assign(new PNG({ width: 1320, height: 2868 }), {
30+
data: Buffer.alloc(1320 * 2868 * 4, 20 + index),
31+
}),
32+
{ colorType: 2, inputColorType: 6 },
33+
),
34+
}));
35+
for (const capture of captures) {
36+
await NodeFSP.writeFile(NodePath.join(input, `${capture.scene}.png`), capture.bytes);
37+
}
38+
const originalDocument = await NodeFSP.readFile(
39+
NodePath.join(templateDirectory, "app-store.pen"),
40+
);
41+
const document = JSON.parse(originalDocument.toString()) as {
42+
children: Array<{ id: string; name: string; width: number; height: number }>;
43+
};
44+
for (const appearance of ["dark", "light"] as const) {
45+
const output = NodePath.join(directory, appearance);
46+
await preparePenAssets(input, output, appearance);
47+
assert.deepStrictEqual(
48+
await NodeFSP.readFile(NodePath.join(output, "app-store.pen")),
49+
originalDocument,
50+
);
51+
for (const [index, id] of PEN_LAYOUTS[appearance].entries()) {
52+
const frame = document.children.find((node) => node.id === id)!;
53+
assert.ok(frame.name.startsWith(`${appearance === "dark" ? "G" : "H"}0${index + 1}`));
54+
assert.equal(frame.width, 1290);
55+
assert.equal(frame.height, 2796);
56+
}
57+
for (const filename of await NodeFSP.readdir(
58+
NodePath.join(templateDirectory, assetsDirectory),
59+
)) {
60+
const scene = PEN_SCENES.find(
61+
([asset]) => penScreenshotFilename(asset, appearance) === filename,
62+
)?.[1];
63+
const expected = scene
64+
? captures.find((capture) => capture.scene === scene)!.bytes
65+
: await NodeFSP.readFile(NodePath.join(templateDirectory, assetsDirectory, filename));
66+
assert.deepStrictEqual(
67+
await NodeFSP.readFile(NodePath.join(output, assetsDirectory, filename)),
68+
expected,
69+
);
70+
}
71+
}
72+
} finally {
73+
await NodeFSP.rm(directory, { recursive: true, force: true });
74+
}
75+
});
76+
77+
it("rejects missing and incorrectly sized captures instead of using the old screenshots", async () => {
78+
const directory = await NodeFSP.mkdtemp(NodePath.join(NodeOS.tmpdir(), "t3-pen-test-"));
79+
try {
80+
const input = NodePath.join(directory, "input");
81+
await NodeFSP.mkdir(input);
82+
await expect(
83+
preparePenAssets(input, NodePath.join(directory, "missing"), "dark"),
84+
).rejects.toThrow(/ENOENT/u);
85+
await NodeFSP.writeFile(
86+
NodePath.join(input, "threads.png"),
87+
PNG.sync.write(new PNG({ width: 1, height: 1 }), { colorType: 2 }),
88+
);
89+
await expect(
90+
preparePenAssets(input, NodePath.join(directory, "wrong-size"), "light"),
91+
).rejects.toThrow(/requires 1320×2868/u);
92+
} finally {
93+
await NodeFSP.rm(directory, { recursive: true, force: true });
94+
}
95+
});

‎scripts/mobile-showcase-assets.ts‎

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
// @effect-diagnostics nodeBuiltinImport:off - Host-side Pen CLI and image export automation.
2+
import * as NodeChildProcess from "node:child_process";
3+
import * as NodeFSP from "node:fs/promises";
4+
import * as NodeOS from "node:os";
5+
import * as NodePath from "node:path";
6+
import * as NodeProcess from "node:process";
7+
import * as NodeURL from "node:url";
8+
import * as NodeUtil from "node:util";
9+
10+
import showcaseConfig, { type ShowcaseAppearance } from "./mobile-showcase.config.ts";
11+
import {
12+
normalizeStorePng,
13+
parseShowcaseCliArgs,
14+
planShowcaseCaptures,
15+
validateStoreAsset,
16+
} from "./mobile-showcase.ts";
17+
18+
const TEMPLATE_DIRECTORY = NodeURL.fileURLToPath(
19+
new URL("./mobile-showcase-assets/", import.meta.url),
20+
);
21+
const ASSETS_DIRECTORY = "T3 Code AppStore Assets-assets";
22+
export const PEN_LAYOUTS = {
23+
dark: ["VzYVc", "HTuJU", "aJlvZ", "xEv0b", "Fv2DI", "cPgee", "Uv0Se"],
24+
light: ["vLscN", "jvvlj", "E9ELUC", "R4sQ6I", "eYCoY", "E3y7Q", "mivY7"],
25+
} as const;
26+
export const PEN_SCENES = [
27+
["01-sessions", "threads"],
28+
["02-environments", "environments"],
29+
["03-chat", "thread"],
30+
["04-terminal", "terminal"],
31+
["05-diff", "review"],
32+
["06-live-activity", "agent-activity"],
33+
] as const;
34+
35+
export function penScreenshotFilename(asset: string, appearance: ShowcaseAppearance): string {
36+
return `${asset}-${appearance}${asset === "06-live-activity" ? "-v2" : "@hi2"}.png`;
37+
}
38+
39+
export async function preparePenAssets(
40+
inputDirectory: string,
41+
temporaryDirectory: string,
42+
appearance: ShowcaseAppearance,
43+
): Promise<void> {
44+
const device = showcaseConfig.devices.find((candidate) => candidate.id === "iphone-6.9")!;
45+
await NodeFSP.cp(TEMPLATE_DIRECTORY, temporaryDirectory, { recursive: true });
46+
for (const [asset, scene] of PEN_SCENES) {
47+
const bytes = await NodeFSP.readFile(NodePath.join(inputDirectory, `${scene}.png`));
48+
validateStoreAsset(device.storeAsset, bytes, `${appearance}/${scene}`);
49+
await NodeFSP.writeFile(
50+
NodePath.join(temporaryDirectory, ASSETS_DIRECTORY, penScreenshotFilename(asset, appearance)),
51+
bytes,
52+
);
53+
}
54+
}
55+
56+
export async function renderPenAssets(
57+
inputDirectory: string,
58+
outputDirectory: string,
59+
appearance: ShowcaseAppearance,
60+
): Promise<void> {
61+
if (!NodeProcess.env.PEN_CLI_KEY) {
62+
throw new Error("Set PEN_CLI_KEY before exporting the Pen App Store layouts.");
63+
}
64+
const temporaryDirectory = await NodeFSP.mkdtemp(
65+
NodePath.join(NodeOS.tmpdir(), "t3-pen-assets-"),
66+
);
67+
try {
68+
await preparePenAssets(inputDirectory, temporaryDirectory, appearance);
69+
const exportDirectory = NodePath.join(temporaryDirectory, "exports");
70+
const command = `execute(${JSON.stringify({
71+
input: `Export(${JSON.stringify(PEN_LAYOUTS[appearance])}, "png", ${JSON.stringify(exportDirectory)}, {scale: 1})`,
72+
})})\nexit()\n`;
73+
const result = NodeChildProcess.spawnSync(
74+
"pen",
75+
[
76+
"interactive",
77+
"--in",
78+
NodePath.join(temporaryDirectory, "app-store.pen"),
79+
"--out",
80+
NodePath.join(temporaryDirectory, "render.pen"),
81+
],
82+
{ input: command, encoding: "utf8", timeout: 300_000, maxBuffer: 4 * 1024 * 1024 },
83+
);
84+
if (
85+
result.error ||
86+
result.status !== 0 ||
87+
/\b(error|failed)\b/iu.test(result.stdout + result.stderr)
88+
) {
89+
const detail =
90+
`${result.error?.message ?? ""}\n${result.stdout}\n${result.stderr}`.replaceAll(
91+
NodeProcess.env.PEN_CLI_KEY,
92+
"[REDACTED]",
93+
);
94+
throw new Error(`Pen export failed: ${detail}`);
95+
}
96+
const images = await Promise.all(
97+
PEN_LAYOUTS[appearance].map(async (id, index) => {
98+
const bytes = normalizeStorePng(
99+
await NodeFSP.readFile(NodePath.join(exportDirectory, `${id}.png`)),
100+
);
101+
validateStoreAsset(
102+
{
103+
store: "apple",
104+
directory: outputDirectory,
105+
width: 1290,
106+
height: 2796,
107+
minimumUploadCount: 7,
108+
maximumUploadCount: 7,
109+
},
110+
bytes,
111+
id,
112+
);
113+
return { filename: `${PEN_SCENES[index]?.[0] ?? "07-testimonials"}.png`, bytes };
114+
}),
115+
);
116+
await NodeFSP.mkdir(outputDirectory, { recursive: true });
117+
for (const image of images) {
118+
await NodeFSP.writeFile(NodePath.join(outputDirectory, image.filename), image.bytes);
119+
}
120+
NodeProcess.stdout.write(`Exported 7 ${appearance} Pen layouts to ${outputDirectory}\n`);
121+
} finally {
122+
await NodeFSP.rm(temporaryDirectory, { recursive: true, force: true });
123+
}
124+
}
125+
126+
async function main(): Promise<void> {
127+
const { values } = NodeUtil.parseArgs({
128+
options: {
129+
input: { type: "string", default: "artifacts/app-store/screenshots/apple/iphone-6.9" },
130+
output: { type: "string", default: "artifacts/app-store/pen" },
131+
appearance: { type: "string", default: "both" },
132+
theme: { type: "string", default: "t3-code" },
133+
},
134+
});
135+
const options = parseShowcaseCliArgs([
136+
"--device",
137+
"iphone-6.9",
138+
"--appearance",
139+
values.appearance,
140+
"--theme",
141+
values.theme,
142+
]);
143+
for (const capture of planShowcaseCaptures(showcaseConfig, options)) {
144+
await renderPenAssets(
145+
NodePath.resolve(values.input, capture.appearance, capture.theme),
146+
NodePath.resolve(values.output, capture.appearance, capture.theme),
147+
capture.appearance,
148+
);
149+
}
150+
}
151+
152+
if (import.meta.main) {
153+
main().catch((error: unknown) => {
154+
NodeProcess.stderr.write(`${error instanceof Error ? error.message : String(error)}\n`);
155+
NodeProcess.exit(1);
156+
});
157+
}
595 KB
Loading
682 KB
Loading
63 KB
Loading
589 KB
Loading
637 KB
Loading
598 KB
Loading

0 commit comments

Comments
 (0)