crt-ship 0.1.0: CLI, Claude Code skills and templates for shipping mobile games to Google Play and the App Store
This commit is contained in:
commit
ecb3dc3dc3
64 changed files with 4509 additions and 0 deletions
36
cli/play/listing.ts
Normal file
36
cli/play/listing.ts
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
// Play store listing text + app details in one edit.
|
||||
// crt-ship play listing [--dry] [--only en-US,de-DE]
|
||||
// App details: default language, contact email, website (must be the domain that serves app-ads.txt).
|
||||
// Listings: title, short and full description of every `<!-- play: ... -->` section of the listing file.
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { parsePlayListing } from '../lib/copy';
|
||||
import type { Ctx } from '../lib/ctx';
|
||||
import { need } from '../lib/ctx';
|
||||
import { done, log, step } from '../lib/log';
|
||||
import { playClient } from './client';
|
||||
|
||||
export function readPlayCopy(ctx: Ctx) {
|
||||
const { config, resolve } = ctx.loaded;
|
||||
const file = resolve(config.play?.listing ?? 'store/listing.md');
|
||||
const only = ctx.args.list('only');
|
||||
return parsePlayListing(readFileSync(file, 'utf8'), config.app.name).filter(c => !only.length || only.includes(c.lang));
|
||||
}
|
||||
|
||||
export async function run(ctx: Ctx): Promise<void> {
|
||||
const { config, root } = ctx.loaded;
|
||||
const pkg = need(config.play?.packageName, 'play.packageName');
|
||||
const copy = readPlayCopy(ctx);
|
||||
const details = { defaultLanguage: config.play?.defaultLanguage ?? 'en-US', contactEmail: config.app.contactEmail, contactWebsite: config.app.website };
|
||||
if (!copy.some(c => c.lang === details.defaultLanguage) && !ctx.args.has('only')) throw new Error(`listing has no section for the default language ${details.defaultLanguage}`);
|
||||
log('play', `${copy.length} listings: ${copy.map(c => c.lang).join(', ')}`);
|
||||
const play = await playClient(root, pkg);
|
||||
await play.edit(async id => {
|
||||
await play.call('PUT', `${play.API}/edits/${id}/details`, details);
|
||||
log('play', `details: ${details.defaultLanguage} · ${details.contactEmail} · ${details.contactWebsite}`);
|
||||
for (const [i, c] of copy.entries()) {
|
||||
await play.call('PUT', `${play.API}/edits/${id}/listings/${c.lang}`, { language: c.lang, title: c.title, shortDescription: c.short, fullDescription: c.full });
|
||||
log('play', step(i + 1, copy.length, c.lang));
|
||||
}
|
||||
}, { dry: ctx.args.has('dry') });
|
||||
done('play', 'listing done');
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue