Desktop D3 writes in the window: push listing text, upload graphics, screenshots and previews, render jobs, catalog sync and price export, Play rollout share / halt / resume / complete and iOS phased release controls, TestFlight What to Test, internal groups and testers, reply editor with approve and send; every one a dry run, a native dialog, then the real run

This commit is contained in:
CRTkafa 2026-10-11 04:25:53 +08:00
parent f47c00bed0
commit ba58895d3a
15 changed files with 573 additions and 69 deletions

View file

@ -85,6 +85,33 @@ for (const theme of themes) {
await page.locator('.fchip').first().click(); await page.locator('.fchip').first().click();
await page.getByPlaceholder(/Search apps|Uygulama, bundle/).fill(''); await page.getByPlaceholder(/Search apps|Uygulama, bundle/).fill('');
} }
if (!only.length || only.includes('tf-edit')) {
// TestFlight: What to Test editor of the newest build
await page.goto(`${base}/?start=app:testflight&theme=${theme}&lang=${lang}`);
await settle(page);
await page.getByRole('button', { name: /What to Test|Neyi test etmeli/ }).first().click();
await page.getByRole('textbox').first().fill('New combo meter and the calmer night palette. Please try level 31 at a 20x combo.');
await page.waitForTimeout(200);
await page.evaluate(() => document.getElementById('content')?.scrollBy({ top: 330 }));
await page.waitForTimeout(200);
await shot('tf-edit');
}
if (!only.length || only.includes('reply-edit')) {
// Reviews: the reply editor of the approved draft, edited (not saved yet)
await page.goto(`${base}/?start=app:reviews&theme=${theme}&lang=${lang}`);
await settle(page);
await page.locator('textarea.reply-edit').fill('Sorry about the lost streak! The fix for the crash at high combos is in 2.4.0, in review now. Thank you for the level number.');
await page.waitForTimeout(200);
await shot('reply-edit');
}
if (!only.length || only.includes('write-toast')) {
// a write running: halt the Play rollout (owner action), caught with its progress toast
await page.goto(`${base}/?start=app:releases&theme=${theme}&lang=${lang}`);
await settle(page);
await page.getByRole('button', { name: /^Halt$|^Durdur$/ }).first().click();
await page.waitForTimeout(450);
await shot('write-toast');
}
if (!only.length || only.includes('import')) { if (!only.length || only.includes('import')) {
// Import apps running, with its progress toast // Import apps running, with its progress toast
await page.goto(`${base}/?start=accounts&theme=${theme}&lang=${lang}`); await page.goto(`${base}/?start=accounts&theme=${theme}&lang=${lang}`);

View file

@ -103,8 +103,8 @@ if (import.meta.env.VITE_FIXTURES === 'empty') overrides = { pairs: [], unpairs:
let settings: Settings = { ...DEFAULT_SETTINGS, refresh: { ...DEFAULT_SETTINGS.refresh, autoMinutes: 60 } }; let settings: Settings = { ...DEFAULT_SETTINGS, refresh: { ...DEFAULT_SETTINGS.refresh, autoMinutes: 60 } };
const PLAY_INVITE = (who: string) => `Play Console > Users and permissions > Invite new users: add ${who}. Account permissions: "View app information and download bulk reports (read-only)"; per app, as needed: "Manage store presence", "Manage testing tracks", "Release to production, exclude devices and use Play App Signing" (rollouts), "Reply to reviews", "Manage orders and subscriptions". One service account can be invited to several developer accounts.`; const PLAY_INVITE = (who: string) => `Play Console > Users and permissions > Invite new users: add ${who}. Account permissions: "View app information and download bulk reports (read-only)"; per app, as needed: "Manage store presence", "Manage testing tracks", "Release to production, exclude devices and use Play App Signing" (rollouts), "Reply to reviews", "Manage orders and subscriptions". One service account can be invited to several developer accounts.`;
const CHECKS: Record<string, AccountCheck> = { const CHECKS: Record<string, AccountCheck> = {
[P1]: { store: 'android', status: 'ok', principal: 'storebound@example-games-123.iam.gserviceaccount.com', apps: 8, message: 'The service account can see 8 apps.', fix: null, docs: null }, [P1]: { store: 'android', status: 'ok', principal: 'play-bot@example.com', apps: 8, message: 'The service account can see 8 apps.', fix: null, docs: null },
[P2]: { store: 'android', status: 'permission', principal: 'storebound@sample-labs-456.iam.gserviceaccount.com', apps: 0, message: 'The key works, but no developer account has invited this service account (it sees no apps).', fix: PLAY_INVITE('storebound@sample-labs-456.iam.gserviceaccount.com'), docs: 'https://play.google.com/console/developers/users-and-permissions' }, [P2]: { store: 'android', status: 'permission', principal: 'sample-labs-bot@example.com', apps: 0, message: 'The key works, but no developer account has invited this service account (it sees no apps).', fix: PLAY_INVITE('sample-labs-bot@example.com'), docs: 'https://play.google.com/console/developers/users-and-permissions' },
[A1]: { store: 'ios', status: 'ok', principal: null, apps: 5, message: 'The key works and can read the team\'s apps.', fix: null, docs: null }, [A1]: { store: 'ios', status: 'ok', principal: null, apps: 5, message: 'The key works and can read the team\'s apps.', fix: null, docs: null },
[A2]: { store: 'ios', status: 'ok', principal: null, apps: 3, message: 'The key works and can read the team\'s apps.', fix: null, docs: null }, [A2]: { store: 'ios', status: 'ok', principal: null, apps: 3, message: 'The key works and can read the team\'s apps.', fix: null, docs: null },
[A3]: { store: 'ios', status: 'ok', principal: null, apps: 2, message: 'The key works and can read the team\'s apps.', fix: null, docs: null }, [A3]: { store: 'ios', status: 'ok', principal: null, apps: 2, message: 'The key works and can read the team\'s apps.', fix: null, docs: null },
@ -496,12 +496,13 @@ async function answer(cmd: string, a: Record<string, unknown>): Promise<unknown>
} }
case 'job_cancel': cancelled.add(a.job as string); return true; case 'job_cancel': cancelled.add(a.job as string); return true;
case 'write_with_confirm': { case 'write_with_confirm': {
await sleep(500);
const method = a.method as string, args = (a.args ?? {}) as Record<string, unknown>; const method = a.method as string, args = (a.args ?? {}) as Record<string, unknown>;
if (method === 'reviews.approve') { await progressLines(job, [`[${method}] dry run`, `[${method}] confirmed in the dialog`, `[${method}] applying`]);
if (job && cancelled.has(job)) throw { code: -32800, message: 'Request cancelled' };
const d = DRAFTS[a.projectId as string]?.drafts.find(x => x.file.endsWith(`/${String(args.file)}`)); const d = DRAFTS[a.projectId as string]?.drafts.find(x => x.file.endsWith(`/${String(args.file)}`));
if (d) d.approved = !args.undo; if (method === 'reviews.approve' && d) d.approved = !args.undo;
} if (method === 'reviews.reply' && d) { d.reply = String(args.text); d.approved = false; d.issues = []; }
if (method === 'owner.reply_send' && d) d.sent = iso(0);
const res: ToolResult = { method, ok: true, exitCode: 0, dryRun: false, command: `storebound ${method.replace('.', ' ')}`, output: `[${method}] done (fixture)` }; const res: ToolResult = { method, ok: true, exitCode: 0, dryRun: false, command: `storebound ${method.replace('.', ' ')}`, output: `[${method}] done (fixture)` };
return { confirmed: true, stage: 'done', dryRun: { ...res, dryRun: true }, result: res }; return { confirmed: true, stage: 'done', dryRun: { ...res, dryRun: true }, result: res };
} }

View file

@ -227,7 +227,7 @@ export const en = {
'releases.noVersionsText': 'When the first build is uploaded it shows here.', 'releases.noVersionsText': 'When the first build is uploaded it shows here.',
'releases.history': 'Versions on the stores', 'releases.history': 'Versions on the stores',
'releases.historySub': 'Read {when}', 'releases.historySub': 'Read {when}',
'releases.consoleNote': 'storebound never submits for review, releases or completes a rollout. Do those in the store console.', 'releases.consoleNote': 'storebound never submits for review and never releases an approved version: do those in the store console. Rollout and phased release changes are your decision, each confirmed in a system dialog.',
'cat.products': 'One-time products', 'cat.products': 'One-time products',
'cat.productsSub': 'In the config', 'cat.productsSub': 'In the config',
@ -774,4 +774,96 @@ export const en = {
'portfolio.groupCount_one': '1 app', 'portfolio.groupCount_one': '1 app',
'portfolio.groupAccounts': '{count} accounts', 'portfolio.groupAccounts': '{count} accounts',
'portfolio.groupAccounts_one': '1 account', 'portfolio.groupAccounts_one': '1 account',
'write.dryRunning': 'Dry run first: nothing changes yet',
'write.notApplied': 'Not applied',
'write.notAppliedDetail': 'You chose Cancel in the dialog: nothing changed.',
'act.storeTitle': 'Push to the stores',
'act.storeSub': 'Listing text, screenshots and previews from this folder, and the local renders',
'act.playListing': 'Listing text',
'act.playListingDone': 'Play listing updated',
'act.playImages': 'Graphics and screenshots',
'act.version': 'Version',
'act.appleListing': 'Version {version} and its text',
'act.appleListingDone': 'App Store version and text updated',
'act.appleShots': 'Screenshots',
'act.applePreviews': 'App previews',
'act.uploaded': 'Uploaded',
'act.slowHint': 'Can take minutes: progress shows in the toast, Cancel stops it',
'act.render': 'Render (local)',
'act.renderLang': 'Language to render',
'act.allLangs': 'All languages',
'act.renderShots': 'Render screenshots',
'act.renderVideo': 'Cut app previews',
'act.icons': 'Generate icons',
'act.gallery': 'Review gallery',
'act.galleryDone': 'Gallery written next to the renders',
'act.rendered': 'Done',
'act.localHint': 'Local files only; needs ffmpeg and Chrome (Dependencies)',
'act.note': 'Each action runs a dry run and shows it in a system dialog before anything changes. Nothing here submits for review or publishes: that stays in the consoles.',
'act.catalogTitle': 'Sync the catalog',
'act.catalogSub': 'Create and update products and subscriptions with their regional prices from the config',
'act.playProducts': 'One-time products',
'act.playSubs': 'Subscriptions',
'act.appleIap': 'In-app purchases',
'act.appleSubs': 'Subscriptions',
'act.synced': 'Catalog updated',
'act.prices': 'Prices',
'act.pricesExport': 'Export prices (CSV)',
'act.pricesExported': 'Prices exported into the folder',
'act.pricesImport': 'Changing live prices from a sheet stays a terminal step:',
'act.catalogNote': 'Never submits: new items wait in the consoles until you send them with a version.',
'roll.playNow': 'Rollout {pct} %',
'roll.share': 'New user share',
'roll.toShare': 'Raise to {pct} %',
'roll.halt': 'Halt',
'roll.haltHint': 'Stops new installs of the update; not a rollback',
'roll.halted': 'Rollout halted',
'roll.resume': 'Resume',
'roll.complete': 'Everyone (100 %)',
'roll.completeHint': 'Completes the staged rollout: every user gets the update',
'roll.done': 'Rollout updated',
'roll.iosNow': 'Phased release, day {day} of 7',
'roll.pause': 'Pause',
'roll.pauseHint': 'Holds the automatic updates (up to 30 days); not a rollback',
'roll.paused': 'Phased release paused',
'roll.everyone': 'Release to everyone',
'roll.everyoneHint': 'Ends the phased release: every user with automatic updates gets it now',
'roll.phasedOn': 'Turn on phased release',
'roll.phasedOnHint': 'When this version goes live, it reaches users with automatic updates over 7 days',
'roll.phasedOnDone': 'Phased release is on',
'tf.what': 'What to Test',
'tf.groupsBtn': 'Internal groups',
'tf.whatToTest': 'What to Test for build {build}',
'tf.whatPlaceholder': 'What changed and what to look at (every App Store locale gets this text)',
'tf.whatSave': 'Set this text',
'tf.whatFromFile': 'From the listing file',
'tf.whatFromFileHint': 'Each locale\'s whatToTest (or What\'s New) from the App Store listing file',
'tf.whatSaved': 'What to Test updated',
'tf.toInternal': 'Give build {build} to internal groups',
'tf.noInternal': 'No internal group: create one in App Store Connect or with apple.testflight.groups.',
'tf.distribute': 'Give to these groups',
'tf.distributed': 'Build added to the groups',
'tf.externalNote': 'External groups and Beta App Review stay in App Store Connect.',
'tf.testersTitle': 'Testers',
'tf.testersSub': 'From the testers CSV in this folder (.storebound/testers.csv, never committed)',
'tf.testersGroup': 'Group',
'tf.testersAll': 'Every group in the CSV',
'tf.testersAdd': 'Add new testers',
'tf.testersHint': 'Apple emails each new tester an invitation once the group has a build',
'tf.testersDone': 'Testers added',
'tf.testersNote': 'Emails stay masked in every line and dialog. Removing testers stays a terminal step.',
'reviews.replyEditor': 'Reply',
'reviews.replyPlaceholder': 'Plain text, in the reviewer\'s language. No incentives, no personal data.',
'reviews.unsaved': 'Not saved',
'reviews.save': 'Save draft',
'reviews.saved': 'Draft saved (approve it again)',
'reviews.send': 'Send reply',
'reviews.sendHint': 'Public: the reviewer is notified. A system dialog shows the reply first.',
'reviews.sent': 'Reply sent',
'reviews.incentive': 'Offers something for a rating or asks for stars: not allowed',
'reviews.tooLong': 'Longer than the store allows ({limit} characters)',
'reviews.sendNoteD3': 'Replies are public. Save, approve, then Send: each step shows a system dialog first.',
} as const; } as const;

View file

@ -229,7 +229,7 @@ export const tr: Record<keyof typeof en, string> = {
'releases.noVersionsText': 'İlk derleme yüklendiğinde burada görünür.', 'releases.noVersionsText': 'İlk derleme yüklendiğinde burada görünür.',
'releases.history': 'Mağazalardaki sürümler', 'releases.history': 'Mağazalardaki sürümler',
'releases.historySub': '{when} okundu', 'releases.historySub': '{when} okundu',
'releases.consoleNote': 'storebound hiçbir zaman incelemeye göndermez, yayınlamaz veya dağıtımı tamamlamaz. Bunları mağaza konsolunda yapın.', 'releases.consoleNote': 'storebound hiçbir zaman incelemeye göndermez ve onaylanmış bir sürümü yayınlamaz: bunları mağaza konsolunda yapın. Dağıtım ve aşamalı yayın değişiklikleri sizin kararınızdır, her biri bir sistem penceresinde onaylanır.',
'cat.products': 'Tek seferlik ürünler', 'cat.products': 'Tek seferlik ürünler',
'cat.productsSub': 'Ayar dosyasında', 'cat.productsSub': 'Ayar dosyasında',
@ -776,4 +776,96 @@ export const tr: Record<keyof typeof en, string> = {
'portfolio.groupCount_one': '1 uygulama', 'portfolio.groupCount_one': '1 uygulama',
'portfolio.groupAccounts': '{count} hesap', 'portfolio.groupAccounts': '{count} hesap',
'portfolio.groupAccounts_one': '1 hesap', 'portfolio.groupAccounts_one': '1 hesap',
'write.dryRunning': 'Önce deneme: henüz hiçbir şey değişmiyor',
'write.notApplied': 'Uygulanmadı',
'write.notAppliedDetail': 'Pencerede İptal\'i seçtiniz: hiçbir şey değişmedi.',
'act.storeTitle': 'Mağazalara gönder',
'act.storeSub': 'Bu klasördeki mağaza metni, ekran görüntüleri ve önizlemeler, ve yerel çıktılar',
'act.playListing': 'Mağaza metni',
'act.playListingDone': 'Play mağaza metni güncellendi',
'act.playImages': 'Grafikler ve ekran görüntüleri',
'act.version': 'Sürüm',
'act.appleListing': '{version} sürümü ve metni',
'act.appleListingDone': 'App Store sürümü ve metni güncellendi',
'act.appleShots': 'Ekran görüntüleri',
'act.applePreviews': 'Uygulama önizlemeleri',
'act.uploaded': 'Yüklendi',
'act.slowHint': 'Dakikalar sürebilir: ilerleme bildirimde görünür, İptal durdurur',
'act.render': 'Üret (yerel)',
'act.renderLang': 'Üretilecek dil',
'act.allLangs': 'Tüm diller',
'act.renderShots': 'Ekran görüntülerini üret',
'act.renderVideo': 'Önizlemeleri kes',
'act.icons': 'Simgeleri üret',
'act.gallery': 'İnceleme galerisi',
'act.galleryDone': 'Galeri çıktıların yanına yazıldı',
'act.rendered': 'Bitti',
'act.localHint': 'Yalnızca yerel dosyalar; ffmpeg ve Chrome gerekir (Bağımlılıklar)',
'act.note': 'Her işlem önce bir deneme çalıştırır ve bir şey değişmeden önce sistem penceresinde gösterir. Buradaki hiçbir şey incelemeye göndermez ya da yayımlamaz: o konsollarda kalır.',
'act.catalogTitle': 'Kataloğu eşitle',
'act.catalogSub': 'Ürünleri ve abonelikleri bölgesel fiyatlarıyla yapılandırmadan oluştur ve güncelle',
'act.playProducts': 'Tek seferlik ürünler',
'act.playSubs': 'Abonelikler',
'act.appleIap': 'Uygulama içi satın almalar',
'act.appleSubs': 'Abonelikler',
'act.synced': 'Katalog güncellendi',
'act.prices': 'Fiyatlar',
'act.pricesExport': 'Fiyatları dışa aktar (CSV)',
'act.pricesExported': 'Fiyatlar klasöre aktarıldı',
'act.pricesImport': 'Canlı fiyatları bir tablodan değiştirmek terminal adımı olarak kalır:',
'act.catalogNote': 'Asla göndermez: yeni ürünler siz bir sürümle gönderene kadar konsollarda bekler.',
'roll.playNow': 'Dağıtım %{pct}',
'roll.share': 'Yeni kullanıcı payı',
'roll.toShare': '%{pct} yap',
'roll.halt': 'Durdur',
'roll.haltHint': 'Güncellemenin yeni kurulumlarını durdurur; geri alma değildir',
'roll.halted': 'Dağıtım durduruldu',
'roll.resume': 'Sürdür',
'roll.complete': 'Herkese (%100)',
'roll.completeHint': 'Kademeli dağıtımı tamamlar: her kullanıcı güncellemeyi alır',
'roll.done': 'Dağıtım güncellendi',
'roll.iosNow': 'Aşamalı yayın, 7 günün {day}. günü',
'roll.pause': 'Duraklat',
'roll.pauseHint': 'Otomatik güncellemeleri bekletir (en çok 30 gün); geri alma değildir',
'roll.paused': 'Aşamalı yayın duraklatıldı',
'roll.everyone': 'Herkese yayınla',
'roll.everyoneHint': 'Aşamalı yayını bitirir: otomatik güncellemesi açık her kullanıcı şimdi alır',
'roll.phasedOn': 'Aşamalı yayını aç',
'roll.phasedOnHint': 'Bu sürüm yayına girince otomatik güncellemesi açık kullanıcılara 7 günde ulaşır',
'roll.phasedOnDone': 'Aşamalı yayın açık',
'tf.what': 'Neyi test etmeli',
'tf.groupsBtn': 'İç gruplar',
'tf.whatToTest': '{build} derlemesi için Neyi test etmeli',
'tf.whatPlaceholder': 'Ne değişti, nelere bakılmalı (her App Store dili bu metni alır)',
'tf.whatSave': 'Bu metni ayarla',
'tf.whatFromFile': 'Mağaza dosyasından',
'tf.whatFromFileHint': 'App Store mağaza dosyasındaki her dilin whatToTest (ya da Yenilikler) metni',
'tf.whatSaved': 'Neyi test etmeli güncellendi',
'tf.toInternal': '{build} derlemesini iç gruplara ver',
'tf.noInternal': 'İç grup yok: App Store Connect\'te ya da apple.testflight.groups ile oluşturun.',
'tf.distribute': 'Bu gruplara ver',
'tf.distributed': 'Derleme gruplara eklendi',
'tf.externalNote': 'Dış gruplar ve Beta App Review App Store Connect\'te kalır.',
'tf.testersTitle': 'Test kullanıcıları',
'tf.testersSub': 'Bu klasördeki test kullanıcısı CSV\'sinden (.storebound/testers.csv, asla commit edilmez)',
'tf.testersGroup': 'Grup',
'tf.testersAll': 'CSV\'deki her grup',
'tf.testersAdd': 'Yeni test kullanıcılarını ekle',
'tf.testersHint': 'Grubun bir derlemesi olunca Apple her yeni kullanıcıya davet e-postası gönderir',
'tf.testersDone': 'Test kullanıcıları eklendi',
'tf.testersNote': 'E-postalar her satırda ve pencerede maskeli kalır. Kullanıcı çıkarmak terminal adımı olarak kalır.',
'reviews.replyEditor': 'Yanıt',
'reviews.replyPlaceholder': 'Düz metin, yorumcunun dilinde. Teşvik yok, kişisel veri yok.',
'reviews.unsaved': 'Kaydedilmedi',
'reviews.save': 'Taslağı kaydet',
'reviews.saved': 'Taslak kaydedildi (yeniden onaylayın)',
'reviews.send': 'Yanıtı gönder',
'reviews.sendHint': 'Herkese açık: yorumcu bilgilendirilir. Önce bir sistem penceresi yanıtı gösterir.',
'reviews.sent': 'Yanıt gönderildi',
'reviews.incentive': 'Puan karşılığı bir şey öneriyor ya da yıldız istiyor: izin verilmez',
'reviews.tooLong': 'Mağazanın izin verdiğinden uzun ({limit} karakter)',
'reviews.sendNoteD3': 'Yanıtlar herkese açıktır. Kaydet, onayla, sonra Gönder: her adım önce bir sistem penceresi gösterir.',
}; };

View file

@ -4,8 +4,9 @@ import type { Project } from '../../api';
import { type Key, t } from '../../i18n'; import { type Key, t } from '../../i18n';
import { ago, num } from '../../lib/format'; import { ago, num } from '../../lib/format';
import { type CatalogDiff, type CellState, parityMatrix } from '../../lib/model'; import { type CatalogDiff, type CellState, parityMatrix } from '../../lib/model';
import { useData, useRead } from '../../store'; import { useData, useRead, useWrite } from '../../store';
import { Icon, type IconName } from '../../ui/icons'; import { Icon, type IconName, StoreGlyph } from '../../ui/icons';
import { WriteButton } from '../../ui/WriteButton';
import { Card, Chip, Empty, Kpi, Notice, Skeleton } from '../../ui/kit'; import { Card, Chip, Empty, Kpi, Notice, Skeleton } from '../../ui/kit';
const CELL: Record<CellState, [IconName, Key]> = { ok: ['check', 'cat.ok'], warn: ['alert', 'cat.warn'], error: ['x', 'cat.error'], na: ['dot', 'cat.na'], unknown: ['info', 'cat.unknown'] }; const CELL: Record<CellState, [IconName, Key]> = { ok: ['check', 'cat.ok'], warn: ['alert', 'cat.warn'], error: ['x', 'cat.error'], na: ['dot', 'cat.na'], unknown: ['info', 'cat.unknown'] };
@ -20,6 +21,40 @@ function Cell({ c }: { c: { state: CellState; notes: string[] } }) {
); );
} }
/** Create / update the catalog on both stores from the config (prices included), and export the price sheet. */
function CatalogActions({ project, products, subs, refresh }: { project: Project; products: number; subs: number; refresh: () => void }) {
const d = useData();
const w = useWrite(project.id);
const e = d.statusOf(project);
const ios = !!e?.app?.platforms.ios, android = !!e?.app?.platforms.android;
return (
<Card title={t('act.catalogTitle')} icon="upload" sub={t('act.catalogSub')}>
<div className="act-grid">
{android && (
<div className="act-col">
<div className="act-head"><StoreGlyph store="android" />Google Play</div>
<WriteButton run={w} icon="tag" disabled={!products} w={{ method: 'play.products', args: {}, title: t('act.playProducts'), done: t('act.synced'), after: refresh }}>{t('act.playProducts')}</WriteButton>
<WriteButton run={w} icon="refresh" disabled={!subs} w={{ method: 'play.subscriptions', args: {}, title: t('act.playSubs'), done: t('act.synced'), after: refresh }}>{t('act.playSubs')}</WriteButton>
</div>
)}
{ios && (
<div className="act-col">
<div className="act-head"><StoreGlyph store="ios" />App Store</div>
<WriteButton run={w} icon="tag" disabled={!products} w={{ method: 'apple.iap', args: {}, title: t('act.appleIap'), done: t('act.synced'), after: refresh }}>{t('act.appleIap')}</WriteButton>
<WriteButton run={w} icon="refresh" disabled={!subs} w={{ method: 'apple.subscriptions', args: {}, title: t('act.appleSubs'), done: t('act.synced'), after: refresh }}>{t('act.appleSubs')}</WriteButton>
</div>
)}
<div className="act-col">
<div className="act-head"><Icon name="database" />{t('act.prices')}</div>
<WriteButton run={w} icon="download" w={{ method: 'prices.export', args: {}, title: t('act.pricesExport'), done: t('act.pricesExported') }}>{t('act.pricesExport')}</WriteButton>
<span className="small muted">{t('act.pricesImport')} <code className="selectable">storebound prices import</code></span>
</div>
</div>
<p className="small muted act-note"><Icon name="shield" />{t('act.catalogNote')}</p>
</Card>
);
}
export function CatalogTab({ project }: { project: Project }) { export function CatalogTab({ project }: { project: Project }) {
const d = useData(); const d = useData();
const e = d.statusOf(project); const e = d.statusOf(project);
@ -43,6 +78,7 @@ export function CatalogTab({ project }: { project: Project }) {
<Kpi icon="globe" label={t('cat.gaps')} value={read ? gaps.length : '–'} sub={read ? t('cat.gapsSub') : t('kpi.notRead')} /> <Kpi icon="globe" label={t('cat.gaps')} value={read ? gaps.length : '–'} sub={read ? t('cat.gapsSub') : t('kpi.notRead')} />
</div> </div>
{diff.error && <Notice tone="warn">{t('common.readFailedKeep', { error: diff.error })}</Notice>} {diff.error && <Notice tone="warn">{t('common.readFailedKeep', { error: diff.error })}</Notice>}
<CatalogActions project={project} products={s?.products ?? 0} subs={s?.subscriptions ?? 0} refresh={() => { diff.refresh(); }} />
<Card title={t('cat.matrix')} icon="layers" sub={read ? (diff.fromCache ? t('common.cachedFrom', { when: ago(diff.at) }) : t('common.readWhen', { when: ago(diff.at) })) : t('cat.configOnly')} pad={false} <Card title={t('cat.matrix')} icon="layers" sub={read ? (diff.fromCache ? t('common.cachedFrom', { when: ago(diff.at) }) : t('common.readWhen', { when: ago(diff.at) })) : t('cat.configOnly')} pad={false}
actions={<button className="btn btn-sm" onClick={diff.refresh} disabled={diff.loading}><Icon name="refresh" className={diff.loading ? 'spin' : undefined} />{read ? t('action.refresh') : t('cat.compare')}</button>}> actions={<button className="btn btn-sm" onClick={diff.refresh} disabled={diff.loading}><Icon name="refresh" className={diff.loading ? 'spin' : undefined} />{read ? t('action.refresh') : t('cat.compare')}</button>}>
<div className="table-wrap"> <div className="table-wrap">

View file

@ -1,10 +1,12 @@
// Listings: per language and store, which listing fields are written and within the store limits (from the listing // Listings: per language and store, which listing fields are written and within the store limits (from the listing
// files in the app folder), and how many screenshots are rendered per language. // files in the app folder), and how many screenshots are rendered per language.
import { useState } from 'react';
import type { ListingField, ListingLocale, ListingsResult, Project } from '../../api'; import type { ListingField, ListingLocale, ListingsResult, Project } from '../../api';
import { type Key, t } from '../../i18n'; import { type Key, t } from '../../i18n';
import { ago, num } from '../../lib/format'; import { ago, num } from '../../lib/format';
import { useRead } from '../../store'; import { useData, useRead, useWrite } from '../../store';
import { Icon } from '../../ui/icons'; import { Icon, StoreGlyph } from '../../ui/icons';
import { WriteButton } from '../../ui/WriteButton';
import { Card, Chip, Empty, Kpi, Notice, Skeleton } from '../../ui/kit'; import { Card, Chip, Empty, Kpi, Notice, Skeleton } from '../../ui/kit';
const FIELD_KEY: Record<string, Key> = { const FIELD_KEY: Record<string, Key> = {
@ -56,6 +58,57 @@ function StoreGrid({ store, locales }: { store: 'play' | 'apple'; locales: Listi
); );
} }
/** Push the listing text, upload the art, and render it (each a dry run, a native dialog, then the real run). */
function StoreActions({ project, langs }: { project: Project; langs: string[] }) {
const d = useData();
const w = useWrite(project.id);
const l = d.liveOf(project);
const e = d.statusOf(project);
const suggested = l?.release.next?.ios?.version ?? l?.release.next?.version ?? '';
const [version, setVersion] = useState(suggested);
const [lang, setLang] = useState('');
const ios = !!e?.app?.platforms.ios, android = !!e?.app?.platforms.android;
const okVersion = /^\d+(\.\d+){0,2}$/.test(version);
const only = lang ? { lang } : {};
return (
<Card title={t('act.storeTitle')} icon="upload" sub={t('act.storeSub')}>
<div className="act-grid">
{android && (
<div className="act-col">
<div className="act-head"><StoreGlyph store="android" />Google Play</div>
<WriteButton run={w} icon="text" w={{ method: 'play.listing', args: {}, title: t('act.playListing'), done: t('act.playListingDone') }}>{t('act.playListing')}</WriteButton>
<WriteButton run={w} icon="image" w={{ method: 'play.images', args: {}, title: t('act.playImages'), done: t('act.uploaded') }} hint={t('act.slowHint')}>{t('act.playImages')}</WriteButton>
</div>
)}
{ios && (
<div className="act-col">
<div className="act-head"><StoreGlyph store="ios" />App Store</div>
<div className="row" style={{ gap: 8 }}>
<label className="small muted" htmlFor="act-version">{t('act.version')}</label>
<input id="act-version" className="input input-sm mono" style={{ width: 90 }} value={version} onChange={ev => setVersion(ev.target.value.trim())} placeholder="2.4.0" />
</div>
<WriteButton run={w} icon="text" disabled={!okVersion} w={{ method: 'apple.listing', args: { version }, title: t('act.appleListing', { version }), done: t('act.appleListingDone') }}>{t('act.appleListing', { version: version || '…' })}</WriteButton>
<WriteButton run={w} icon="image" w={{ method: 'apple.screenshots', args: {}, title: t('act.appleShots'), done: t('act.uploaded') }} hint={t('act.slowHint')}>{t('act.appleShots')}</WriteButton>
<WriteButton run={w} icon="play" w={{ method: 'apple.previews', args: {}, title: t('act.applePreviews'), done: t('act.uploaded') }} hint={t('act.slowHint')}>{t('act.applePreviews')}</WriteButton>
</div>
)}
<div className="act-col">
<div className="act-head"><Icon name="wand" />{t('act.render')}</div>
<select className="input input-sm" value={lang} onChange={ev => setLang(ev.target.value)} aria-label={t('act.renderLang')}>
<option value="">{t('act.allLangs')}</option>
{langs.map(x => <option key={x} value={x}>{x}</option>)}
</select>
<WriteButton run={w} icon="image" w={{ method: 'shots.render', args: only, title: t('act.renderShots'), done: t('act.rendered') }} hint={t('act.localHint')}>{t('act.renderShots')}</WriteButton>
<WriteButton run={w} icon="play" w={{ method: 'shots.video', args: only, title: t('act.renderVideo'), done: t('act.rendered') }} hint={t('act.localHint')}>{t('act.renderVideo')}</WriteButton>
<WriteButton run={w} icon="sparkle" w={{ method: 'icons', args: {}, title: t('act.icons'), done: t('act.rendered') }} hint={t('act.localHint')}>{t('act.icons')}</WriteButton>
<WriteButton run={w} icon="layers" w={{ method: 'shots.gallery', args: only, title: t('act.gallery'), done: t('act.galleryDone') }} hint={t('act.localHint')}>{t('act.gallery')}</WriteButton>
</div>
</div>
<p className="small muted act-note"><Icon name="shield" />{t('act.note')}</p>
</Card>
);
}
export function ListingsTab({ project }: { project: Project }) { export function ListingsTab({ project }: { project: Project }) {
const r = useRead<ListingsResult>(project.id, 'project.listings', { network: false }); const r = useRead<ListingsResult>(project.id, 'project.listings', { network: false });
if (!r.data) { if (!r.data) {
@ -76,6 +129,7 @@ export function ListingsTab({ project }: { project: Project }) {
<Kpi icon="image" label={t('lst.screenshots')} value={L.locales.some(l => l.screenshots !== null) ? shots : '–'} sub={L.locales.some(l => l.screenshots !== null) ? t('lst.screenshotsSub') : t('lst.noRenders')} /> <Kpi icon="image" label={t('lst.screenshots')} value={L.locales.some(l => l.screenshots !== null) ? shots : '–'} sub={L.locales.some(l => l.screenshots !== null) ? t('lst.screenshotsSub') : t('lst.noRenders')} />
</div> </div>
{L.problems.map((p, i) => <Notice key={i} tone="warn">{p}</Notice>)} {L.problems.map((p, i) => <Notice key={i} tone="warn">{p}</Notice>)}
{!noFiles && <StoreActions project={project} langs={L.locales.map(l => l.lang)} />}
{noFiles ? ( {noFiles ? (
<Card pad={false}> <Card pad={false}>
<Empty illo="text" title={t('lst.noFilesTitle')}>{t('lst.noFilesText')}</Empty> <Empty illo="text" title={t('lst.noFilesTitle')}>{t('lst.noFilesText')}</Empty>

View file

@ -1,11 +1,13 @@
// Releases: the release timeline (one version on both stores on one track: build -> testing -> review -> live -> // Releases: the release timeline (one version on both stores on one track: build -> testing -> review -> live ->
// rollout %), then every version read from the stores. Submit and release stay in the consoles. // rollout %), then every version read from the stores. Submit and release stay in the consoles.
import { api, type ReleaseTrain } from '../../api'; import { useState } from 'react';
import { api, type ReleaseTrain, type StoreRelease } from '../../api';
import type { UnifiedApp } from '../../lib/identity'; import type { UnifiedApp } from '../../lib/identity';
import { WriteButton } from '../../ui/WriteButton';
import { type Key, t } from '../../i18n'; import { type Key, t } from '../../i18n';
import { ago, date, share } from '../../lib/format'; import { ago, date, share } from '../../lib/format';
import { type Lane, STAGES, type TestFlightStatus, trainLanes, versionHistory } from '../../lib/model'; import { type Lane, STAGES, type TestFlightStatus, trainLanes, versionHistory } from '../../lib/model';
import { useData, useRead } from '../../store'; import { useData, useRead, useWrite } from '../../store';
import { Icon, StoreGlyph } from '../../ui/icons'; import { Icon, StoreGlyph } from '../../ui/icons';
import { Bar, Card, Chip, Empty, Notice, PhaseChip, storeName } from '../../ui/kit'; import { Bar, Card, Chip, Empty, Notice, PhaseChip, storeName } from '../../ui/kit';
import { ascUrl, PLAY_CONSOLE } from '../AppView'; import { ascUrl, PLAY_CONSOLE } from '../AppView';
@ -48,7 +50,54 @@ function LaneRow({ lane, version }: { lane: Lane; version: string }) {
); );
} }
function Train({ title, train, tf, tone }: { title: string; train: ReleaseTrain; tf: TestFlightStatus | null; tone: 'accent' | 'ok' }) { const SHARES = [1, 2, 5, 10, 20, 50];
/** Rollout controls of one store release: Play staged rollout share / halt / resume / complete, iOS phased release
* pause / resume / everyone, or turning the phased release on for an upcoming iOS version. Owner actions: each one is
* a dry run first, then a system dialog that names it. */
function RolloutControls({ app, r }: { app: UnifiedApp; r: StoreRelease }) {
const w = useWrite(app.project?.id ?? null);
const pct = r.fraction !== null ? Math.round(r.fraction * 100) : null;
const [share, setShare] = useState(() => String(SHARES.find(s => pct === null || s > pct) ?? 50));
if (!app.project) return null;
const v = r.version ?? '';
if (r.store === 'android' && (r.phase === 'rollout' || r.phase === 'halted')) {
const track = r.track && ['production', 'beta', 'alpha', 'internal'].includes(r.track) ? r.track : 'production';
const next = SHARES.filter(s => pct === null || s > pct);
return (
<div className="roll-ctl">
<span className="small muted">{t('roll.playNow', { pct: pct ?? 0 })}</span>
{r.phase === 'rollout' && next.length > 0 && <>
<select className="input input-sm" value={share} onChange={e => setShare(e.target.value)} aria-label={t('roll.share')}>{next.map(s => <option key={s} value={s}>{s} %</option>)}</select>
<WriteButton run={w} icon="arrowRight" w={{ method: 'owner.play_rollout', args: { action: 'percent', percent: Number(share), track }, title: t('roll.toShare', { pct: share }), done: t('roll.done') }}>{t('roll.toShare', { pct: share })}</WriteButton>
</>}
{r.phase === 'rollout' && <WriteButton run={w} icon="pause" w={{ method: 'owner.play_rollout', args: { action: 'halt', track }, title: t('roll.halt'), done: t('roll.halted') }} hint={t('roll.haltHint')}>{t('roll.halt')}</WriteButton>}
{r.phase === 'halted' && <WriteButton run={w} icon="play" w={{ method: 'owner.play_rollout', args: { action: 'resume', track }, title: t('roll.resume'), done: t('roll.done') }}>{t('roll.resume')}</WriteButton>}
<WriteButton run={w} icon="users" w={{ method: 'owner.play_rollout', args: { action: 'complete', track }, title: t('roll.complete'), done: t('roll.done') }} hint={t('roll.completeHint')}>{t('roll.complete')}</WriteButton>
</div>
);
}
if (r.store === 'ios' && r.phased && (r.phased.state === 'ACTIVE' || r.phased.state === 'PAUSED')) {
return (
<div className="roll-ctl">
<span className="small muted">{t('roll.iosNow', { day: r.phased.day ?? 0 })}</span>
{r.phased.state === 'ACTIVE' && <WriteButton run={w} icon="pause" w={{ method: 'owner.ios_phased', args: { action: 'pause', version: v }, title: t('roll.pause'), done: t('roll.paused') }} hint={t('roll.pauseHint')}>{t('roll.pause')}</WriteButton>}
{r.phased.state === 'PAUSED' && <WriteButton run={w} icon="play" w={{ method: 'owner.ios_phased', args: { action: 'resume', version: v }, title: t('roll.resume'), done: t('roll.done') }}>{t('roll.resume')}</WriteButton>}
<WriteButton run={w} icon="users" w={{ method: 'owner.ios_phased', args: { action: 'complete', version: v }, title: t('roll.everyone'), done: t('roll.done') }} hint={t('roll.everyoneHint')}>{t('roll.everyone')}</WriteButton>
</div>
);
}
if (r.store === 'ios' && !r.phased && ['draft', 'review', 'approved'].includes(r.phase) && /^\d+(\.\d+){0,2}$/.test(v)) {
return (
<div className="roll-ctl">
<WriteButton run={w} icon="layers" w={{ method: 'owner.ios_phased', args: { action: 'on', version: v }, title: t('roll.phasedOn'), done: t('roll.phasedOnDone') }} hint={t('roll.phasedOnHint')}>{t('roll.phasedOn')}</WriteButton>
</div>
);
}
return null;
}
function Train({ title, train, tf, tone, app }: { title: string; train: ReleaseTrain; tf: TestFlightStatus | null; tone: 'accent' | 'ok'; app: UnifiedApp }) {
const lanes = trainLanes(train, tf); const lanes = trainLanes(train, tf);
return ( return (
<Card pad={false} title={<span className="train-head"><span className="ver">{train.version}</span><Chip tone={tone}>{title}</Chip></span>} <Card pad={false} title={<span className="train-head"><span className="ver">{train.version}</span><Chip tone={tone}>{title}</Chip></span>}
@ -57,6 +106,11 @@ function Train({ title, train, tf, tone }: { title: string; train: ReleaseTrain;
<div className="tl-head"><span>{t('tl.store')}</span>{STAGES.map(s => <span key={s}>{t(STAGE_KEY[s])}</span>)}</div> <div className="tl-head"><span>{t('tl.store')}</span>{STAGES.map(s => <span key={s}>{t(STAGE_KEY[s])}</span>)}</div>
{lanes.map(l => <LaneRow key={l.store} lane={l} version={train.version} />)} {lanes.map(l => <LaneRow key={l.store} lane={l} version={train.version} />)}
</div> </div>
{lanes.some(l => l.release) && app.project && (
<div className="card-foot roll-foot">
{lanes.map(l => l.release && <RolloutControls key={l.store} app={app} r={l.release} />)}
</div>
)}
</Card> </Card>
); );
} }
@ -83,8 +137,8 @@ export function ReleasesTab({ app }: { app: UnifiedApp }) {
return ( return (
<> <>
{errs.map(([s, msg]) => <Notice key={s} tone="warn">{t('releases.storeUnreadable', { store: storeName(s as 'ios'), error: msg })}</Notice>)} {errs.map(([s, msg]) => <Notice key={s} tone="warn">{t('releases.storeUnreadable', { store: storeName(s as 'ios'), error: msg })}</Notice>)}
{l.release.next && <Train title={t('tl.next')} train={l.release.next} tf={tf.data} tone="accent" />} {l.release.next && <Train title={t('tl.next')} train={l.release.next} tf={tf.data} tone="accent" app={app} />}
{l.release.current && <Train title={t('tl.live')} train={l.release.current} tf={tf.data} tone="ok" />} {l.release.current && <Train title={t('tl.live')} train={l.release.current} tf={tf.data} tone="ok" app={app} />}
{!l.release.next && !l.release.current && <Card pad={false}><Empty compact illo="unknown" title={t('releases.noVersions')}>{t('releases.noVersionsText')}</Empty></Card>} {!l.release.next && !l.release.current && <Card pad={false}><Empty compact illo="unknown" title={t('releases.noVersions')}>{t('releases.noVersionsText')}</Empty></Card>}
<Card title={t('releases.history')} icon="layers" sub={t('releases.historySub', { when: ago(d.live?.at ?? d.portfolio?.at) })} pad={false}> <Card title={t('releases.history')} icon="layers" sub={t('releases.historySub', { when: ago(d.live?.at ?? d.portfolio?.at) })} pad={false}>

View file

@ -1,20 +1,31 @@
// Reviews: the inbox of both stores with the star distribution and filters, and per review its local reply draft // Reviews: the inbox of both stores with the star distribution and filters, and per review its local reply draft
// (.storebound/replies) with the send checks. Approving a draft is a local, confirmed write; sending stays in the // (.storebound/replies) with the send checks. Approving a draft is a local, confirmed write; sending stays in the
// terminal (`storebound reviews send`): replies are public. // terminal (`storebound reviews send`): replies are public.
import { useMemo, useState } from 'react'; import { useEffect, useMemo, useState } from 'react';
import { api, type DraftsResult, errorText, newJob, type ReplyDraft } from '../../api'; import type { DraftsResult, ReplyDraft } from '../../api';
import type { UnifiedApp } from '../../lib/identity'; import type { UnifiedApp } from '../../lib/identity';
import { t } from '../../i18n'; import { t } from '../../i18n';
import { ago, date, num } from '../../lib/format'; import { ago, date, num } from '../../lib/format';
import { draftName, filterReviews, type Review, type ReviewFilter, starStats } from '../../lib/model'; import { draftName, filterReviews, type Review, type ReviewFilter, starStats } from '../../lib/model';
import { useData, useRead } from '../../store'; import { useRead, useWrite } from '../../store';
import { WriteButton } from '../../ui/WriteButton';
import { Icon, StoreGlyph } from '../../ui/icons'; import { Icon, StoreGlyph } from '../../ui/icons';
import { Bar, Card, Chip, Empty, Notice, Seg, Skeleton, Stars } from '../../ui/kit'; import { Bar, Card, Chip, Empty, Notice, Seg, Skeleton, Stars } from '../../ui/kit';
const base = (f: string) => f.split(/[\\/]/).pop() ?? f; const base = (f: string) => f.split(/[\\/]/).pop() ?? f;
function Detail({ r, draft, onApprove, busy }: { r: Review; draft: ReplyDraft | undefined; onApprove: (d: ReplyDraft, undo: boolean) => void; busy: boolean }) { /** Same checks as `reviews send` (cli/lib/reviews.ts checkReply), shown while typing; the CLI checks again. */
const INCENTIVE = [/\b(free|bonus|extra|gift|reward)\b[^.!?\n]{0,40}\b(coins?|gems?|credits?|lives|items?)\b/i, /\b(change|update|raise|edit)\s+(your\s+)?(rating|review|stars?)\b/i, /\b(5|five)[ -]?stars?\b/i, /\b(rate|review)\s+us\b/i];
function Detail({ r, draft, w, onChanged }: { r: Review; draft: ReplyDraft | undefined; w: ReturnType<typeof useWrite>; onChanged: () => void }) {
const errors = draft?.issues.filter(i => i.level === 'error') ?? []; const errors = draft?.issues.filter(i => i.level === 'error') ?? [];
const [text, setText] = useState(draft?.reply ?? '');
useEffect(() => { setText(draft?.reply ?? ''); }, [draft?.file, draft?.reply]);
const limit = r.store === 'play' ? 350 : 5970;
const len = [...text.trim()].length;
const dirty = !!draft && text.trim() !== draft.reply.trim();
const live = text && INCENTIVE.some(x => x.test(text)) ? t('reviews.incentive') : len > limit ? t('reviews.tooLong', { limit }) : null;
const file = draft ? base(draft.file) : '';
return ( return (
<Card className="rv-detail" title={<span className="row" style={{ gap: 10 }}><Stars n={r.rating} />{r.title || t('reviews.noTitle')}</span>} <Card className="rv-detail" title={<span className="row" style={{ gap: 10 }}><Stars n={r.rating} />{r.title || t('reviews.noTitle')}</span>}
sub={<span className="row" style={{ gap: 6 }}><StoreGlyph store={r.store === 'apple' ? 'ios' : 'android'} className="ic13" />{r.store === 'apple' ? 'App Store' : 'Google Play'}{r.where ? ` · ${r.where}` : ''} · {date(r.date)}{r.appVersion ? ` · ${t('reviews.version', { v: r.appVersion })}` : ''}</span>}> sub={<span className="row" style={{ gap: 6 }}><StoreGlyph store={r.store === 'apple' ? 'ios' : 'android'} className="ic13" />{r.store === 'apple' ? 'App Store' : 'Google Play'}{r.where ? ` · ${r.where}` : ''} · {date(r.date)}{r.appVersion ? ` · ${t('reviews.version', { v: r.appVersion })}` : ''}</span>}>
@ -32,25 +43,34 @@ function Detail({ r, draft, onApprove, busy }: { r: Review; draft: ReplyDraft |
<span className="label">{t('reviews.draft')}</span> <span className="label">{t('reviews.draft')}</span>
{draft && (draft.sent ? <Chip tone="ok">{t('reviews.sentOn', { date: date(draft.sent) })}</Chip> : draft.approved ? <Chip tone="ok" icon="check">{t('reviews.approved')}</Chip> : <Chip tone="neutral">{t('reviews.notApproved')}</Chip>)} {draft && (draft.sent ? <Chip tone="ok">{t('reviews.sentOn', { date: date(draft.sent) })}</Chip> : draft.approved ? <Chip tone="ok" icon="check">{t('reviews.approved')}</Chip> : <Chip tone="neutral">{t('reviews.notApproved')}</Chip>)}
</div> </div>
{!draft ? <p className="muted small">{t('reviews.noDraft')}</p> : ( {!draft ? <p className="muted small">{t('reviews.noDraft')}</p> : draft.sent ? (
<div className="reply-box selectable">{draft.reply}</div>
) : (
<> <>
{draft.reply ? <div className="reply-box selectable">{draft.reply}</div> : <p className="muted small">{t('reviews.emptyDraft', { file: base(draft.file) })}</p>} <textarea className="input reply-edit" rows={5} value={text} onChange={e => setText(e.target.value)} aria-label={t('reviews.replyEditor')} placeholder={t('reviews.replyPlaceholder')} />
<div className="row small muted" style={{ gap: 10 }}><span className="num">{t('reviews.chars', { n: num([...draft.reply].length), limit: r.store === 'play' ? 350 : 5970 })}</span><span className="mono-id">{base(draft.file)}</span></div> <div className="row small muted" style={{ gap: 10 }}>
{draft.issues.length > 0 && ( <span className={`num${len > limit ? ' tbad' : ''}`}>{t('reviews.chars', { n: num(len), limit })}</span><span className="mono-id">{file}</span>
{dirty && <Chip tone="warn" dot={false}>{t('reviews.unsaved')}</Chip>}
</div>
{live && <ul className="issues"><li className="e"><Icon name="alertCircle" />{live}</li></ul>}
{!dirty && draft.issues.length > 0 && (
<ul className="issues"> <ul className="issues">
{draft.issues.map((i, n) => <li key={n} className={i.level === 'error' ? 'e' : 'w'}><Icon name={i.level === 'error' ? 'alertCircle' : 'alert'} />{i.msg}</li>)} {draft.issues.map((i, n) => <li key={n} className={i.level === 'error' ? 'e' : 'w'}><Icon name={i.level === 'error' ? 'alertCircle' : 'alert'} />{i.msg}</li>)}
</ul> </ul>
)} )}
{!draft.sent && (
<div className="actions"> <div className="actions">
<WriteButton run={w} icon="check" primary={dirty} disabled={!dirty || !text.trim() || text.trim().startsWith('-') || len > 6000}
w={{ method: 'reviews.reply', args: { file, text: text.trim() }, title: t('reviews.save'), done: t('reviews.saved'), after: onChanged }}>{t('reviews.save')}</WriteButton>
{draft.approved {draft.approved
? <button className="btn" onClick={() => onApprove(draft, true)} disabled={busy}>{t('reviews.unapprove')}</button> ? <WriteButton run={w} icon="x" disabled={dirty} w={{ method: 'reviews.approve', args: { file, undo: true }, title: t('reviews.unapprove'), done: t('reviews.unapproved'), after: onChanged }}>{t('reviews.unapprove')}</WriteButton>
: <button className="btn btn-primary" onClick={() => onApprove(draft, false)} disabled={busy || !draft.reply || errors.length > 0} title={errors.length ? t('reviews.fixFirst') : t('reviews.approveHint')}><Icon name="check" />{t('reviews.approve')}</button>} : <WriteButton run={w} icon="check" disabled={dirty || !draft.reply || errors.length > 0} hint={errors.length ? t('reviews.fixFirst') : t('reviews.approveHint')}
w={{ method: 'reviews.approve', args: { file }, title: t('reviews.approve'), done: t('reviews.approvedToast'), after: onChanged }}>{t('reviews.approve')}</WriteButton>}
<WriteButton run={w} icon="send" primary={draft.approved && !dirty} disabled={!draft.approved || dirty || errors.length > 0} hint={t('reviews.sendHint')}
w={{ method: 'owner.reply_send', args: { file }, title: t('reviews.send'), done: t('reviews.sent'), after: onChanged }}>{t('reviews.send')}</WriteButton>
</div> </div>
)}
</> </>
)} )}
<p className="small muted">{t('reviews.sendNote')} <code className="selectable">storebound reviews send</code></p> <p className="small muted">{t('reviews.sendNoteD3')}</p>
</div> </div>
</div> </div>
</Card> </Card>
@ -58,13 +78,12 @@ function Detail({ r, draft, onApprove, busy }: { r: Review; draft: ReplyDraft |
} }
export function ReviewsTab({ app }: { app: UnifiedApp }) { export function ReviewsTab({ app }: { app: UnifiedApp }) {
const d = useData();
const project = app.project; const project = app.project;
const list = useRead<Review[]>(app.target, 'reviews.list', { network: true, args: { days: 30 }, title: t('tab.reviews'), appName: app.name }); const list = useRead<Review[]>(app.target, 'reviews.list', { network: true, args: { days: 30 }, title: t('tab.reviews'), appName: app.name });
const drafts = useRead<DraftsResult>(app.target, 'reviews.drafts', { network: false, skip: !project }); const drafts = useRead<DraftsResult>(app.target, 'reviews.drafts', { network: false, skip: !project });
const [f, setF] = useState<ReviewFilter>({ store: 'all', stars: [], unanswered: false, query: '' }); const [f, setF] = useState<ReviewFilter>({ store: 'all', stars: [], unanswered: false, query: '' });
const [sel, setSel] = useState<string | null>(null); const [sel, setSel] = useState<string | null>(null);
const [busy, setBusy] = useState(false); const w = useWrite(project?.id ?? null);
const all = list.data ?? []; const all = list.data ?? [];
const stats = useMemo(() => starStats(f.store === 'all' ? all : all.filter(r => r.store === f.store)), [all, f.store]); const stats = useMemo(() => starStats(f.store === 'all' ? all : all.filter(r => r.store === f.store)), [all, f.store]);
@ -72,17 +91,7 @@ export function ReviewsTab({ app }: { app: UnifiedApp }) {
const byFile = useMemo(() => new Map((drafts.data?.drafts ?? []).map(x => [base(x.file), x] as const)), [drafts.data]); const byFile = useMemo(() => new Map((drafts.data?.drafts ?? []).map(x => [base(x.file), x] as const)), [drafts.data]);
const cur = shown.find(r => `${r.store}:${r.id}` === sel) ?? shown.find(r => !r.reply && byFile.has(draftName(r))) ?? shown[0]; const cur = shown.find(r => `${r.store}:${r.id}` === sel) ?? shown.find(r => !r.reply && byFile.has(draftName(r))) ?? shown[0];
const write = async (method: string, args: Record<string, unknown>, title: string) => { const changed = () => { drafts.refresh(); };
setBusy(true);
const job = newJob(method);
try {
if (!project) return;
const o = await api.writeWithConfirm(method, project.id, args, job);
if (o.confirmed && o.result?.ok) { d.toast({ kind: 'ok', title, detail: undefined }); await drafts.refresh(); }
else if (o.stage === 'dry-run') d.toast({ kind: 'bad', title: t('write.dryFailed'), detail: o.dryRun.output.split('\n').filter(Boolean).at(-1) });
else if (o.confirmed) d.toast({ kind: 'bad', title: t('write.failed'), detail: o.result?.output.split('\n').filter(Boolean).at(-1) });
} catch (e) { d.toast({ kind: 'bad', title: t('write.failed'), detail: errorText(e) }); } finally { setBusy(false); }
};
if (!list.data) { if (!list.data) {
if (list.loading && !list.error) return <Card><Skeleton lines={5} block /></Card>; if (list.loading && !list.error) return <Card><Skeleton lines={5} block /></Card>;
@ -100,7 +109,7 @@ export function ReviewsTab({ app }: { app: UnifiedApp }) {
<div className="row between"> <div className="row between">
<span className="stamp"><Icon name="clock" />{list.fromCache ? t('common.cachedFrom', { when: ago(list.at) }) : t('common.readWhen', { when: ago(list.at) })}</span> <span className="stamp"><Icon name="clock" />{list.fromCache ? t('common.cachedFrom', { when: ago(list.at) }) : t('common.readWhen', { when: ago(list.at) })}</span>
<div className="actions"> <div className="actions">
<button className="btn btn-sm" onClick={() => write('reviews.draft', { days: 30 }, t('reviews.draftsMade'))} disabled={busy} title={t('reviews.makeDraftsHint')}><Icon name="text" />{t('reviews.makeDrafts')}</button> {project && <WriteButton run={w} icon="text" hint={t('reviews.makeDraftsHint')} w={{ method: 'reviews.draft', args: { days: 30 }, title: t('reviews.makeDrafts'), done: t('reviews.draftsMade'), after: changed }}>{t('reviews.makeDrafts')}</WriteButton>}
<button className="btn btn-sm" onClick={list.refresh} disabled={list.loading}><Icon name="refresh" />{t('action.refresh')}</button> <button className="btn btn-sm" onClick={list.refresh} disabled={list.loading}><Icon name="refresh" />{t('action.refresh')}</button>
</div> </div>
</div> </div>
@ -147,7 +156,7 @@ export function ReviewsTab({ app }: { app: UnifiedApp }) {
</div> </div>
) : <Empty compact illo="reviews" title={t('reviews.noMatch')} />} ) : <Empty compact illo="reviews" title={t('reviews.noMatch')} />}
</Card> </Card>
{cur ? <Detail r={cur} draft={byFile.get(draftName(cur))} busy={busy} onApprove={(dr, undo) => write('reviews.approve', { file: base(dr.file), ...(undo ? { undo: true } : {}) }, undo ? t('reviews.unapproved') : t('reviews.approvedToast'))} /> {cur ? <Detail r={cur} draft={byFile.get(draftName(cur))} w={w} onChanged={changed} />
: <Card className="rv-detail"><Empty compact illo="reviews" title={t('reviews.pick')} /></Card>} : <Card className="rv-detail"><Empty compact illo="reviews" title={t('reviews.pick')} /></Card>}
</div> </div>
</> </>

View file

@ -1,10 +1,12 @@
// TestFlight: beta groups (internal / external, testers, builds, public link) and the recent builds with their // TestFlight: beta groups (internal / external, testers, builds, public link) and the recent builds with their
// processing and beta review states. // processing and beta review states.
import { Fragment, useState } from 'react';
import type { UnifiedApp } from '../../lib/identity'; import type { UnifiedApp } from '../../lib/identity';
import { WriteButton } from '../../ui/WriteButton';
import { t } from '../../i18n'; import { t } from '../../i18n';
import { ago, date, num } from '../../lib/format'; import { ago, date, num } from '../../lib/format';
import type { TestFlightStatus, Tone } from '../../lib/model'; import type { TestFlightStatus, TfBuild, TfGroup, Tone } from '../../lib/model';
import { useData, useRead } from '../../store'; import { useData, useRead, useWrite } from '../../store';
import { Icon } from '../../ui/icons'; import { Icon } from '../../ui/icons';
import { Card, Chip, Empty, Notice, Skeleton } from '../../ui/kit'; import { Card, Chip, Empty, Notice, Skeleton } from '../../ui/kit';
@ -23,10 +25,63 @@ function State({ s }: { s: string | null }) {
return s ? <Chip tone={b.tone}>{b.text}</Chip> : <span className="muted small">–</span>; return s ? <Chip tone={b.tone}>{b.text}</Chip> : <span className="muted small">–</span>;
} }
/** One build's "What to Test" and its internal groups: confirm-gated writes (dry run, dialog, apply). */
function BuildEditor({ b, groups, w, mode, onDone }: { b: TfBuild; groups: TfGroup[]; w: ReturnType<typeof useWrite>; mode: 'what' | 'groups'; onDone: () => void }) {
const [text, setText] = useState('');
const internal = groups.filter(g => g.internal);
const [picked, setPicked] = useState<string[]>(internal.map(g => g.name));
const base = { build: b.build ?? '', ...(b.version ? { version: b.version } : {}) };
if (mode === 'what') {
return (
<div className="build-edit">
<label className="small strong" htmlFor={`wtt-${b.build}`}>{t('tf.whatToTest', { build: b.build ?? '' })}</label>
<textarea id={`wtt-${b.build}`} className="input" rows={3} maxLength={4000} value={text} onChange={e => setText(e.target.value)} placeholder={t('tf.whatPlaceholder')} />
<div className="actions">
<WriteButton run={w} icon="check" primary disabled={!text.trim() || text.trim().startsWith('-')} w={{ method: 'apple.testflight_what_to_test', args: { ...base, text: text.trim() }, title: t('tf.whatSave'), done: t('tf.whatSaved'), after: onDone }}>{t('tf.whatSave')}</WriteButton>
<WriteButton run={w} icon="text" w={{ method: 'apple.testflight_what_to_test', args: base, title: t('tf.whatFromFile'), done: t('tf.whatSaved'), after: onDone }} hint={t('tf.whatFromFileHint')}>{t('tf.whatFromFile')}</WriteButton>
</div>
</div>
);
}
return (
<div className="build-edit">
<span className="small strong">{t('tf.toInternal', { build: b.build ?? '' })}</span>
{internal.length ? (
<div className="row" style={{ gap: 14, flexWrap: 'wrap' }}>
{internal.map(g => <label key={g.id} className="check"><input type="checkbox" checked={picked.includes(g.name)} onChange={e => setPicked(p => (e.target.checked ? [...p, g.name] : p.filter(x => x !== g.name)))} />{g.name}</label>)}
</div>
) : <span className="small muted">{t('tf.noInternal')}</span>}
<div className="actions">
<WriteButton run={w} icon="users" primary disabled={!picked.length} w={{ method: 'apple.testflight_distribute', args: { ...base, groups: picked.join(',') }, title: t('tf.distribute'), done: t('tf.distributed'), after: onDone }}>{t('tf.distribute')}</WriteButton>
<span className="small muted">{t('tf.externalNote')}</span>
</div>
</div>
);
}
function Testers({ groups, w }: { groups: TfGroup[]; w: ReturnType<typeof useWrite> }) {
const [group, setGroup] = useState('');
return (
<Card title={t('tf.testersTitle')} icon="users" sub={t('tf.testersSub')}>
<div className="row" style={{ gap: 10, flexWrap: 'wrap' }}>
<select className="input input-sm" value={group} onChange={e => setGroup(e.target.value)} aria-label={t('tf.testersGroup')}>
<option value="">{t('tf.testersAll')}</option>
{groups.map(g => <option key={g.id} value={g.name}>{g.name}</option>)}
</select>
<WriteButton run={w} icon="users" w={{ method: 'owner.testflight_testers', args: group ? { groups: group } : {}, title: t('tf.testersAdd'), done: t('tf.testersDone') }} hint={t('tf.testersHint')}>{t('tf.testersAdd')}</WriteButton>
</div>
<p className="small muted act-note"><Icon name="shield" />{t('tf.testersNote')}</p>
</Card>
);
}
export function TestFlightTab({ app }: { app: UnifiedApp }) { export function TestFlightTab({ app }: { app: UnifiedApp }) {
const d = useData(); const d = useData();
const e = d.statusFor(app); const e = d.statusFor(app);
const r = useRead<TestFlightStatus>(app.target, 'apple.testflight_status', { network: true, title: 'TestFlight' }); const r = useRead<TestFlightStatus>(app.target, 'apple.testflight_status', { network: true, title: 'TestFlight' });
const w = useWrite(app.project?.id ?? null);
const [open, setOpen] = useState<{ build: string; mode: 'what' | 'groups' } | null>(null);
const writable = !!app.project;
if ((e && !e.app?.platforms.ios) || (!e && !app.project && !app.ios)) return <Card pad={false}><Empty illo="plane" title={t('tf.noIos')}>{t('tf.noIosText')}</Empty></Card>; if ((e && !e.app?.platforms.ios) || (!e && !app.project && !app.ios)) return <Card pad={false}><Empty illo="plane" title={t('tf.noIos')}>{t('tf.noIosText')}</Empty></Card>;
if (!r.data) { if (!r.data) {
if (r.loading && !r.error) return <Card><Skeleton lines={4} block /></Card>; if (r.loading && !r.error) return <Card><Skeleton lines={4} block /></Card>;
@ -62,19 +117,31 @@ export function TestFlightTab({ app }: { app: UnifiedApp }) {
<Card title={t('tf.buildsTitle')} icon="cube" sub={t('tf.buildsSub')} pad={false}> <Card title={t('tf.buildsTitle')} icon="cube" sub={t('tf.buildsSub')} pad={false}>
{s.builds.length ? ( {s.builds.length ? (
<table className="table"> <table className="table">
<thead><tr><th>{t('col.version')}</th><th>{t('col.build')}</th><th>{t('tf.processing')}</th><th>{t('tf.internalTesting')}</th><th>{t('tf.externalTesting')}</th><th className="right">{t('tf.uploaded')}</th></tr></thead> <thead><tr><th>{t('col.version')}</th><th>{t('col.build')}</th><th>{t('tf.processing')}</th><th>{t('tf.internalTesting')}</th><th>{t('tf.externalTesting')}</th><th>{t('tf.uploaded')}</th>{writable && <th className="right"><span className="sr">{t('col.actions')}</span></th>}</tr></thead>
<tbody> <tbody>
{s.builds.map((b, i) => ( {s.builds.map((b, i) => {
<tr key={i}> const usable = !!b.build && b.processing === 'VALID' && !/EXPIRED/.test(`${b.internal ?? ''}`);
const here = open?.build === b.build ? open.mode : null;
return (
<Fragment key={i}>
<tr>
<td className="strong num">{b.version ?? '–'}</td><td className="num">{b.build ?? '–'}</td> <td className="strong num">{b.version ?? '–'}</td><td className="num">{b.build ?? '–'}</td>
<td><State s={b.processing} /></td><td><State s={b.internal} /></td><td><State s={b.external} /></td> <td><State s={b.processing} /></td><td><State s={b.internal} /></td><td><State s={b.external} /></td>
<td className="right muted">{date(b.uploaded)}</td> <td className="muted">{date(b.uploaded)}</td>
{writable && <td className="right nowrap">{usable && <div className="actions" style={{ justifyContent: 'flex-end' }}>
<button className="btn btn-sm btn-ghost" aria-expanded={here === 'what'} onClick={() => setOpen(here === 'what' ? null : { build: b.build!, mode: 'what' })}><Icon name="text" />{t('tf.what')}</button>
<button className="btn btn-sm btn-ghost" aria-expanded={here === 'groups'} onClick={() => setOpen(here === 'groups' ? null : { build: b.build!, mode: 'groups' })}><Icon name="users" />{t('tf.groupsBtn')}</button>
</div>}</td>}
</tr> </tr>
))} {here && <tr className="edit-row"><td colSpan={7}><BuildEditor b={b} groups={s.groups} w={w} mode={here} onDone={() => { setOpen(null); r.refresh(); }} /></td></tr>}
</Fragment>
);
})}
</tbody> </tbody>
</table> </table>
) : <Empty compact illo="plane" title={t('tf.noBuilds')} />} ) : <Empty compact illo="plane" title={t('tf.noBuilds')} />}
</Card> </Card>
{writable && s.groups.length > 0 && <Testers groups={s.groups} w={w} />}
</> </>
); );
} }

View file

@ -304,6 +304,38 @@ export interface ReadState<T> {
refresh: () => Promise<void>; refresh: () => Promise<void>;
} }
export interface WriteRun { method: string; args: Record<string, unknown>; title: string; done: string; after?: () => void }
/**
* Writes of one app folder: dry run, the native dialog that shows it (Apply / Cancel, or the owner action's own
* button), then the real run with a host-minted token. One toast follows it from the dry run to the result, with the
* command's progress lines; Cancel stops it. `busy` is the key of the running write.
*/
export function useWrite(projectId: string | null) {
const d = useData();
const [busy, setBusy] = useState<string | null>(null);
const run = useCallback(async (w: WriteRun) => {
if (!projectId) return null;
const key = `${w.method}:${JSON.stringify(w.args)}`;
const job = newJob(w.method);
setBusy(key);
const tid = d.toast({ id: job, kind: 'job', title: w.title, detail: t('write.dryRunning'), progress: null, job });
try {
const o = await api.writeWithConfirm(w.method, projectId, w.args, job);
if (o.stage === 'dry-run') d.updateToast(tid, { kind: 'bad', title: t('write.dryFailed'), detail: lastLine(o.dryRun.output) || undefined, progress: undefined, job: undefined });
else if (o.stage === 'dialog') d.updateToast(tid, { kind: 'info', title: t('write.notApplied'), detail: t('write.notAppliedDetail'), progress: undefined, job: undefined });
else if (o.result?.ok) { d.updateToast(tid, { kind: 'ok', title: w.done, detail: lastLine(o.result.output) || undefined, progress: undefined, job: undefined }); w.after?.(); }
else d.updateToast(tid, { kind: 'bad', title: t('write.failed'), detail: lastLine(o.result?.output ?? '') || undefined, progress: undefined, job: undefined });
return o;
} catch (e) {
const msg = errorText(e);
d.updateToast(tid, { kind: /cancel/i.test(msg) ? 'info' : 'bad', title: /cancel/i.test(msg) ? t('toast.cancelled') : t('write.failed'), detail: msg, progress: undefined, job: undefined });
return null;
} finally { setBusy(null); }
}, [projectId, d]);
return { busy, run, isBusy: (method: string, args: Record<string, unknown> = {}) => busy === `${method}:${JSON.stringify(args)}` };
}
/** Notifications a fresh read may trigger (Settings > Notifications), compared with the read it replaces. */ /** Notifications a fresh read may trigger (Settings > Notifications), compared with the read it replaces. */
function notifyAfterRead(method: string, prev: unknown, next: unknown, settings: Settings, appName: string | undefined): void { function notifyAfterRead(method: string, prev: unknown, next: unknown, settings: Settings, appName: string | undefined): void {
const name = appName ?? ''; const name = appName ?? '';

View file

@ -748,3 +748,21 @@ h2[tabindex="-1"]:focus, h2[tabindex="-1"]:focus-visible { outline: none; }
.cell-app .s .so-inline { display: inline-flex; align-items: center; gap: 4px; margin-left: 8px; font-family: var(--font); font-size: var(--t-micro); font-weight: 650; color: var(--muted); } .cell-app .s .so-inline { display: inline-flex; align-items: center; gap: 4px; margin-left: 8px; font-family: var(--font); font-size: var(--t-micro); font-weight: 650; color: var(--muted); }
.cell-app .s .so-inline svg { width: 12px; height: 12px; } .cell-app .s .so-inline svg { width: 12px; height: 12px; }
.toolbar .search-input { width: 240px; } .toolbar .search-input { width: 240px; }
/* ---- D3 writes: action cards, rollout controls, TestFlight build editors, reply editor ---- */
.act-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.act-col { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2); }
.act-col .btn { width: 100%; justify-content: flex-start; }
.act-col select.input-sm { width: 100%; max-width: none; }
.act-head { display: flex; align-items: center; gap: 8px; font-weight: 650; font-size: var(--t-meta); color: var(--ink-2); margin-bottom: 2px; }
.act-head svg { width: 15px; height: 15px; }
.act-note { display: flex; align-items: flex-start; gap: 8px; margin-top: 12px; }
.act-note svg { width: 14px; height: 14px; flex: none; margin-top: 2px; color: var(--muted); }
.roll-foot { display: grid; gap: 8px; }
.roll-ctl { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.roll-ctl > .small:first-child { min-width: 150px; }
.table tbody tr.edit-row td { background: var(--surface-2); }
.table tbody tr.edit-row:hover td { background: var(--surface-2); }
.build-edit { display: grid; gap: 10px; padding: 4px 0; max-width: 760px; }
textarea.input { height: auto; padding: 8px 10px; line-height: 1.45; resize: vertical; font-family: var(--font); }
.reply-edit { min-height: 110px; }

View file

@ -0,0 +1,16 @@
// A button that runs one confirm-gated write (dry run -> native dialog -> apply) and spins while it runs.
import type { ReactNode } from 'react';
import type { useWrite, WriteRun } from '../store';
import { Icon, type IconName } from './icons';
export function WriteButton({ w, run, icon, children, primary, danger, disabled, hint, small = true }: {
w: WriteRun; run: ReturnType<typeof useWrite>; icon: IconName; children: ReactNode; primary?: boolean; danger?: boolean; disabled?: boolean; hint?: string; small?: boolean;
}) {
const mine = run.isBusy(w.method, w.args);
return (
<button className={`btn${small ? ' btn-sm' : ''}${primary ? ' btn-primary' : ''}${danger ? ' btn-danger' : ''}`} disabled={disabled || !!run.busy} title={hint} aria-busy={mine || undefined}
onClick={() => { run.run(w); }}>
<Icon name={mine ? 'refresh' : icon} className={mine ? 'spin' : undefined} />{children}
</button>
);
}

View file

@ -90,9 +90,13 @@ export const OWNER_TOOLS: ToolDef[] = [
description: 'Sends one approved, unsent reply draft (.storebound/replies) to its store: public, the reviewer is notified. The draft checks (length, no incentives) apply.', description: 'Sends one approved, unsent reply draft (.storebound/replies) to its store: public, the reviewer is notified. The draft checks (length, no incentives) apply.',
props: { file: { type: 'string', pattern: '^(apple|play)-[A-Za-z0-9._-]{1,120}\\.md$', description: 'Draft file name in .storebound/replies' } }, props: { file: { type: 'string', pattern: '^(apple|play)-[A-Za-z0-9._-]{1,120}\\.md$', description: 'Draft file name in .storebound/replies' } },
required: ['file'], args: i => ['--file', String(i.file)] }, required: ['file'], args: i => ['--file', String(i.file)] },
{ name: 'owner_testflight_testers', title: 'Add TestFlight testers', command: ['apple', 'testflight', 'testers'], write: true, network: true,
description: 'Adds the testers of the project\'s testers CSV (.storebound/testers.csv, gitignored) to their TestFlight groups; Apple emails them an invitation once the group has a build. Emails stay masked in every line. Removing testers stays a terminal command.',
props: { groups: { type: 'string', pattern: '^[^,;]{1,60}(,[^,;]{1,60}){0,19}$', description: 'Comma-separated group names (default: every group in the CSV)' } },
args: i => (i.groups ? ['--group', String(i.groups)] : []) },
]; ];
/** Flags no owner action may ever produce. */ /** Flags no owner action may ever produce. */
export const OWNER_FORBIDDEN_ARGS = ['--yes', '--manual-release', '--cancel-submission', '--submit-review', '--remove', '--invite', '--production', 'submit', 'publish', 'distribute', 'testers']; export const OWNER_FORBIDDEN_ARGS = ['--yes', '--manual-release', '--cancel-submission', '--submit-review', '--remove', '--invite', '--production', '--csv', 'submit', 'publish', 'distribute'];
/** Desktop-only methods whose `project` is a folder without a config yet. */ /** Desktop-only methods whose `project` is a folder without a config yet. */
const NEW_PROJECT = new Set(['project_init']); const NEW_PROJECT = new Set(['project_init']);

View file

@ -39,7 +39,7 @@ const D3_WRITES: [string, J][] = [
['reviews.reply', { file: 'play-r-p1.md', text: 'Thanks! The fix is in 2.4.0.' }], ['reviews.approve', { file: 'play-r-p1.md' }], ['reviews.reply', { file: 'play-r-p1.md', text: 'Thanks! The fix is in 2.4.0.' }], ['reviews.approve', { file: 'play-r-p1.md' }],
['shots.render', {}], ['shots.video', {}], ['shots.gallery', {}], ['icons', {}], ['shots.render', {}], ['shots.video', {}], ['shots.gallery', {}], ['icons', {}],
['owner.play_rollout', { action: 'percent', percent: 50 }], ['owner.play_rollout', { action: 'halt' }], ['owner.ios_phased', { action: 'pause', version: '2.3.0' }], ['owner.play_rollout', { action: 'percent', percent: 50 }], ['owner.play_rollout', { action: 'halt' }], ['owner.ios_phased', { action: 'pause', version: '2.3.0' }],
['owner.ios_phased', { action: 'resume' }], ['owner.reply_send', { file: 'play-r-p1.md' }], ['owner.ios_phased', { action: 'resume' }], ['owner.reply_send', { file: 'play-r-p1.md' }], ['owner.testflight_testers', { groups: 'Friends and family' }],
]; ];
describe('D3 writes: token binding for every method the window offers', () => { describe('D3 writes: token binding for every method the window offers', () => {
@ -82,13 +82,13 @@ describe('D3 writes: token binding for every method the window offers', () => {
describe('owner actions', () => { describe('owner actions', () => {
test('exactly these, desktop only, kind owner, never a submit / release request / cancel / external TestFlight flag', () => { test('exactly these, desktop only, kind owner, never a submit / release request / cancel / external TestFlight flag', () => {
expect(OWNER_TOOLS.map(t => methodName(t.name)).sort()).toEqual(['owner.ios_phased', 'owner.play_rollout', 'owner.reply_send']); expect(OWNER_TOOLS.map(t => methodName(t.name)).sort()).toEqual(['owner.ios_phased', 'owner.play_rollout', 'owner.reply_send', 'owner.testflight_testers']);
for (const t of OWNER_TOOLS) expect(TOOLS.some(x => x.name === t.name)).toBe(false); for (const t of OWNER_TOOLS) expect(TOOLS.some(x => x.name === t.name)).toBe(false);
const ds = describeMethods().filter(m => m.method.startsWith('owner.')); const ds = describeMethods().filter(m => m.method.startsWith('owner.'));
for (const d of ds) expect(d.kind).toBe('owner'); for (const d of ds) expect(d.kind).toBe('owner');
const samples: J[] = [ const samples: J[] = [
{ action: 'percent', percent: 5 }, { action: 'halt' }, { action: 'resume', percent: 10 }, { action: 'complete', track: 'beta' }, { action: 'percent', percent: 5 }, { action: 'halt' }, { action: 'resume', percent: 10 }, { action: 'complete', track: 'beta' },
{ action: 'on' }, { action: 'pause', version: '1.2.3' }, { action: 'resume' }, { action: 'complete' }, { file: 'apple-123.md' }, { action: 'on' }, { action: 'pause', version: '1.2.3' }, { action: 'resume' }, { action: 'complete' }, { file: 'apple-123.md' }, {}, { groups: 'Studio team,Friends' },
]; ];
for (const t of OWNER_TOOLS) for (const s of samples) { for (const t of OWNER_TOOLS) for (const s of samples) {
let argv: string[]; let argv: string[];
@ -104,6 +104,8 @@ describe('owner actions', () => {
expect(toArgv(t('owner_play_rollout'), { action: 'complete', percent: 50, track: 'beta', dry_run: false }).argv).toEqual(['play', 'rollout', '--complete', '--track', 'beta']); expect(toArgv(t('owner_play_rollout'), { action: 'complete', percent: 50, track: 'beta', dry_run: false }).argv).toEqual(['play', 'rollout', '--complete', '--track', 'beta']);
expect(toArgv(t('owner_ios_phased'), { action: 'resume', version: '2.3.0', dry_run: false }).argv).toEqual(['apple', 'release', '--phased', 'resume', '--version', '2.3.0']); expect(toArgv(t('owner_ios_phased'), { action: 'resume', version: '2.3.0', dry_run: false }).argv).toEqual(['apple', 'release', '--phased', 'resume', '--version', '2.3.0']);
expect(toArgv(t('owner_reply_send'), { file: 'play-r1.md', dry_run: false }).argv).toEqual(['reviews', 'send', '--file', 'play-r1.md']); expect(toArgv(t('owner_reply_send'), { file: 'play-r1.md', dry_run: false }).argv).toEqual(['reviews', 'send', '--file', 'play-r1.md']);
expect(toArgv(t('owner_testflight_testers'), { groups: 'Studio team', dry_run: false }).argv).toEqual(['apple', 'testflight', 'testers', '--group', 'Studio team']);
expect(toArgv(t('owner_testflight_testers'), {}).argv).toEqual(['apple', 'testflight', 'testers', '--dry']);
}); });
test('bad arguments never reach a command', async () => { test('bad arguments never reach a command', async () => {
const s = await session(); const s = await session();

View file

@ -104,7 +104,7 @@ describe('account health', () => {
expect(appleCheck({ error: new Error('fetch failed') }).status).toBe('error'); expect(appleCheck({ error: new Error('fetch failed') }).status).toBe('error');
}); });
test('Play: ok, not invited (0 apps), API off, revoked key, missing permission; the hint names the service account', () => { test('Play: ok, not invited (0 apps), API off, revoked key, missing permission; the hint names the service account', () => {
const who = 'storebound@example-project.iam.gserviceaccount.com'; const who = 'play-bot@example.com';
expect(playCheck(who, { apps: 2 })).toMatchObject({ status: 'ok', apps: 2, principal: who }); expect(playCheck(who, { apps: 2 })).toMatchObject({ status: 'ok', apps: 2, principal: who });
const none = playCheck(who, { apps: 0 }); const none = playCheck(who, { apps: 0 });
expect(none.status).toBe('permission'); expect(none.status).toBe('permission');
@ -140,7 +140,7 @@ describe('storebound apps (CLI functions, mocked HTTP)', () => {
test('apple: list with icons, check', async () => { test('apple: list with icons, check', async () => {
const { privateKey } = generateKeyPairSync('ec', { namedCurve: 'P-256' }); const { privateKey } = generateKeyPairSync('ec', { namedCurve: 'P-256' });
process.env.ASC_KEY_ID = 'ABCDE12345'; process.env.ASC_KEY_ID = 'ABCDE12345';
process.env.ASC_ISSUER_ID = '00000000-0000-4000-8000-000000000000'; process.env.ASC_ISSUER_ID = '00000000-0000-0000-0000-000000000000';
process.env.ASC_P8 = privateKey.export({ type: 'pkcs8', format: 'pem' }).toString(); process.env.ASC_P8 = privateKey.export({ type: 'pkcs8', format: 'pem' }).toString();
const get = ascGet([]); const get = ascGet([]);
const seen = mockFetch(url => { const seen = mockFetch(url => {
@ -167,7 +167,7 @@ describe('storebound apps (CLI functions, mocked HTTP)', () => {
}); });
test('play: token exchange, apps:search, check; no apps = not invited', async () => { test('play: token exchange, apps:search, check; no apps = not invited', async () => {
const { privateKey } = generateKeyPairSync('rsa', { modulusLength: 2048 }); const { privateKey } = generateKeyPairSync('rsa', { modulusLength: 2048 });
process.env.PLAY_SERVICE_ACCOUNT = JSON.stringify({ client_email: 'sb@example-project.iam.gserviceaccount.com', private_key: privateKey.export({ type: 'pkcs8', format: 'pem' }).toString(), token_uri: 'https://oauth2.googleapis.com/token' }); process.env.PLAY_SERVICE_ACCOUNT = JSON.stringify({ client_email: 'sb@example.com', private_key: privateKey.export({ type: 'pkcs8', format: 'pem' }).toString(), token_uri: 'https://oauth2.googleapis.com/token' });
let apps: unknown[] = PLAY_SEARCH_2.apps; let apps: unknown[] = PLAY_SEARCH_2.apps;
const seen = mockFetch(url => { const seen = mockFetch(url => {
if (url === 'https://oauth2.googleapis.com/token') return json({ access_token: 'ya29.test', expires_in: 3600 }); if (url === 'https://oauth2.googleapis.com/token') return json({ access_token: 'ya29.test', expires_in: 3600 });
@ -177,7 +177,7 @@ describe('storebound apps (CLI functions, mocked HTTP)', () => {
const r = await listApps('play', root, false); const r = await listApps('play', root, false);
expect(r.apps.map(a => a.id)).toEqual(['com.example.ledger']); expect(r.apps.map(a => a.id)).toEqual(['com.example.ledger']);
expect(seen.some(s => s.startsWith('POST https://oauth2.googleapis.com/token'))).toBe(true); expect(seen.some(s => s.startsWith('POST https://oauth2.googleapis.com/token'))).toBe(true);
expect(await checkAccount('play', root)).toMatchObject({ status: 'ok', principal: 'sb@example-project.iam.gserviceaccount.com' }); expect(await checkAccount('play', root)).toMatchObject({ status: 'ok', principal: 'sb@example.com' });
apps = []; apps = [];
expect((await checkAccount('play', root)).status).toBe('permission'); expect((await checkAccount('play', root)).status).toBe('permission');
}); });
@ -194,8 +194,8 @@ async function session(reply: (argv: string[], o: RunOptions) => { code?: number
await call('session.hello', { secret: SECRET_HEX }); await call('session.hello', { secret: SECRET_HEX });
return { calls, call }; return { calls, call };
} }
const PLAY = { PLAY_SERVICE_ACCOUNT: '{"client_email":"x@example.com","private_key":"-----BEGIN PRIVATE KEY-----"}' }; const PLAY = { PLAY_SERVICE_ACCOUNT: JSON.stringify({ client_email: 'x@example.com', private_key: '-----BEGIN PRIVATE KEY-----' }) };
const APPLE = { ASC_KEY_ID: 'ABCDE12345', ASC_ISSUER_ID: '00000000-0000-4000-8000-000000000000', ASC_P8: '-----BEGIN PRIVATE KEY-----\nx\n-----END PRIVATE KEY-----' }; const APPLE = { ASC_KEY_ID: 'ABCDE12345', ASC_ISSUER_ID: '00000000-0000-0000-0000-000000000000', ASC_P8: '-----BEGIN PRIVATE KEY-----\nx\n-----END PRIVATE KEY-----' };
describe('serve: account methods', () => { describe('serve: account methods', () => {
test('described as kind "account", network reads', () => { test('described as kind "account", network reads', () => {