Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .claude/skills/smt/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ Tagging, promoting, submitting for App Review and pushing the listings reach rea
- A rerun of a tag run uses the workflow file as it was at the tag. A workflow fix needs a new tag.
- Widget and integration tests: put `pumpAndSettle` between `ensureVisible` and `tap`. The scroll pins the End header (a setState), so the control moves one frame later.
- Do not push to a pull request while a merge-on-green job waits for it: it restarts every check. The GraphQL rate limit (and its secondary limit) is shared by every agent and polling loop; poll with REST (`gh api repos/.../commits/<sha>/check-runs`) and merge with `gh api -X PUT repos/comdotlinux/simple-math-tester/pulls/<n>/merge -f merge_method=squash`. In zsh, `for p in $list` does not split on spaces; use an array or literal words.
- App Store screenshots: the required slots are iPhone 6.3" (1206x2622) and iPad 13" (2048x2732); iPhone 6.9" (1290x2796) is optional. Apple copies them to each new version, so a release needs no new shoot. `app-store-listing.yml` takes about 45 minutes with screenshots; if only the upload fails, rerun with `-f screenshots-from-run=<run id>` (artifacts last 7 days), or `-f screenshots=false` for texts only.
- App Store screenshots: the required slots are iPhone 6.3" (1206x2622) and iPad 13" (2048x2732); iPhone 6.9" (1290x2796) is optional. Apple copies them to each new version, so a release needs no new shoot. `app-store-listing.yml` takes about 45 minutes with screenshots; if only the upload fails, rerun with `-f screenshots-from-run=<run id>` (artifacts last 7 days), or `-f screenshots=false` for texts only. With no version in preparation (after a release went live) it stops; add `-f version=X.Y.Z` to create that version first.
- No bundled font has U+25A1 or U+2192. The blank (a line on the baseline) and the arrow are drawn widgets; tests fail if those characters reach a `RichText` or a semantics label.

## 9. Before saying a task is done
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/app-store-listing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ on:
required: false
type: string
default: ''
version:
description: 'Version to create (e.g. 1.5.0) when none is in preparation in App Store Connect'
required: false
type: string
default: ''

permissions:
contents: read
Expand Down Expand Up @@ -186,7 +191,8 @@ jobs:
APPSTORE_KEY_ID: ${{ secrets.APPSTORE_KEY_ID }}
APPSTORE_ISSUER_ID: ${{ secrets.APPSTORE_ISSUER_ID }}
SCREENSHOTS: ${{ inputs.screenshots }}
VERSION: ${{ inputs.version }}
run: |
dir=
if [ "$SCREENSHOTS" = true ]; then dir="$RUNNER_TEMP/app-store-screenshots"; fi
node tool/app_store.mjs listing ${dir:+"$dir"}
node tool/app_store.mjs listing ${dir:+"$dir"} ${VERSION:+--version "$VERSION"}
41 changes: 31 additions & 10 deletions tool/app_store.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -231,20 +231,36 @@
return app;
}

/** The app, its editable app info and the App Store version being prepared. */
export async function findApp(api) {
/**
* The app, its editable app info and the App Store version being prepared.
* With [newVersion] (e.g. "1.5.0"), creates that version when none is being
* prepared; App Store Connect then opens a new editable app info too.
*/
export async function findApp(api, newVersion) {
const app = await appRecord(api);
const versions = async () =>
(await api('GET', `/v1/apps/${app.id}/appStoreVersions?filter[platform]=IOS&limit=10`)).data;
let version = pickEditable(await versions());
if (!version && newVersion) {
console.log(`Creating App Store version ${newVersion}`);
version = (
await api('POST', '/v1/appStoreVersions', {
type: 'appStoreVersions',
attributes: { platform: 'IOS', versionString: newVersion },
relationships: { app: { data: { type: 'apps', id: app.id } } },
})
).data;
}
const info = pickEditable((await api('GET', `/v1/apps/${app.id}/appInfos`)).data);
const version = pickEditable(
(await api('GET', `/v1/apps/${app.id}/appStoreVersions?filter[platform]=IOS&limit=10`)).data,
);
if (!info || !version) throw new Error('No App Store version in preparation: create one in App Store Connect first');
if (!info || !version) {
throw new Error('No App Store version in preparation: run with a version, or create one in App Store Connect');
}
return { app, info, version };
}

/** Writes every listing (and with [screenshots], the screenshots) to App Store Connect. */
export async function listing(api, screenshots) {
const { info, version } = await findApp(api);
export async function listing(api, screenshots, newVersion) {
const { info, version } = await findApp(api, newVersion);
console.log(`Version ${version.attributes.versionString}`);
const byLocale = (body) => Object.fromEntries(body.data.map((l) => [l.attributes.locale, l]));
const infoLocalizations = byLocale(await api('GET', `/v1/appInfos/${info.id}/appInfoLocalizations?limit=200`));
Expand Down Expand Up @@ -412,7 +428,12 @@

async function main() {
const [command, ...args] = process.argv.slice(2);
if (command === 'listing') return listing(connect(process.env), args[0]);
if (command === 'listing') {
const at = args.indexOf('--version');
const newVersion = at >= 0 ? args[at + 1] : undefined;
const [dir] = args.filter((a, i) => i !== at && i !== at + 1);

Check warning on line 434 in tool/app_store.mjs

View workflow job for this annotation

GitHub Actions / Test the Pages functions

lint/correctness/noUnusedFunctionParameters

This parameter a is unused.
return listing(connect(process.env), dir, newVersion);
}
if (command === 'devices' && devices[args[0]]) {
const { size, ratio, pixels } = devices[args[0]];
return console.log(`SCREENSHOT_SIZE=${size}\nSCREENSHOT_PIXEL_RATIO=${ratio}\nSCREENSHOT_PIXELS=${pixels}`);
Expand All @@ -423,7 +444,7 @@
return review(connect(process.env), args[0], notes, args.includes('--dry-run'));
}
throw new Error(
'Usage: node tool/app_store.mjs listing [screenshots dir] | devices <device> | review <version> [notes.json] [--dry-run]',
'Usage: node tool/app_store.mjs listing [screenshots dir] [--version X.Y.Z] | devices <device> | review <version> [notes.json] [--dry-run]',
);
}

Expand Down
38 changes: 38 additions & 0 deletions tool/app_store.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
appStoreTexts,
connect,
devices,
findApp,
listing,
pickEditable,
replaceScreenshots,
Expand Down Expand Up @@ -234,6 +235,43 @@ test('the listing updates a version localization that appeared after it was read
assert.ok(calls.includes('PATCH /v1/appStoreVersionLocalizations/ver-de'));
});

test('with a version, the listing creates it when none is in preparation', async () => {
const calls = [];
let created = false;
const api = async (method, path, data) => {
calls.push(`${method} ${path}`);
if (path.startsWith('/v1/apps?')) return { data: [{ id: 'app' }] };
if (path.startsWith('/v1/apps/app/appStoreVersions')) {
return {
data: [{ id: 'old', attributes: { versionString: '1.4.2', appVersionState: 'READY_FOR_DISTRIBUTION' } }],
};
}
if (method === 'POST' && path === '/v1/appStoreVersions') {
created = true;
assert.deepEqual(data.attributes, { platform: 'IOS', versionString: '1.5.0' });
return { data: { id: 'new', attributes: { versionString: '1.5.0', appVersionState: 'PREPARE_FOR_SUBMISSION' } } };
}
// The editable app info appears with the new version.
if (path === '/v1/apps/app/appInfos') {
return {
data: [{ id: 'info', attributes: { state: created ? 'PREPARE_FOR_SUBMISSION' : 'READY_FOR_DISTRIBUTION' } }],
};
}
throw new Error(`unexpected ${method} ${path}`);
};
const log = console.log;
console.log = () => {};
try {
await assert.rejects(findApp(api), /No App Store version in preparation/);
assert.ok(!calls.includes('POST /v1/appStoreVersions'));
const { info, version } = await findApp(api, '1.5.0');
assert.equal(version.id, 'new');
assert.equal(info.id, 'info');
} finally {
console.log = log;
}
});

test('the screenshot sets are the required iPhone medium size, iPhone large and iPad 13"', () => {
assert.deepEqual(Object.fromEntries(Object.entries(devices).map(([device, d]) => [device, d.displayType])), {
iphone: 'APP_IPHONE_61',
Expand Down