release acceptance matrix: tools/acceptance.ts runs every user-facing command from the packed npm tarball (npx --package=<tgz> on Node 20 / 22, bun x --bun after bun add <tgz>) in fresh temp folders with a fresh HOME, real piped stdin (n, EOF) and per-cell fake stores over HTTP (STOREBOUND_STORE_MOCK, loopback only); a cell passes only with the expected exit code and no crash text; report -> markdown matrix. Prompts go through stdinIsTTY (STOREBOUND_ASSUME_TTY drives them with piped stdin), STOREBOUND_DESKTOP_APP=none for the install prompt on a machine with the app. release.yml: required acceptance job matrix (Linux + Windows x node20/node22/bun) and report, the matrix attached to the release; ci.yml: the quick subset on Linux and Windows. Scan fixtures for React Native and Expo
This commit is contained in:
parent
ae681e3ecd
commit
f58e192001
26 changed files with 926 additions and 15 deletions
|
|
@ -2,6 +2,7 @@ import type { Args } from './args';
|
|||
import type { Language, Loaded } from './config';
|
||||
import { playCodes } from './config';
|
||||
import * as rt from './rt';
|
||||
import { stdinIsTTY } from './tty';
|
||||
|
||||
export interface Ctx { loaded: Loaded; args: Args }
|
||||
|
||||
|
|
@ -38,7 +39,7 @@ export async function confirm(ctx: Ctx, question: string): Promise<boolean> {
|
|||
return declined('confirm-required: terminal only');
|
||||
}
|
||||
if (ctx.args.has('yes')) return true;
|
||||
if (!process.stdin.isTTY) {
|
||||
if (!stdinIsTTY()) {
|
||||
console.log(`${question}\n not a terminal: re-run with --yes to confirm`);
|
||||
return declined('not a terminal and no --yes (re-run with --yes to confirm)');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,6 +98,8 @@ export interface Installed { path: string; how: 'bundle' | 'exe' | 'appimage' |
|
|||
export function findInstalled(platform: NodeJS.Platform, env: Record<string, string | undefined> = process.env,
|
||||
exists: (p: string) => boolean = existsSync, home = homedir(),
|
||||
list: (dir: string) => string[] = d => { try { return readdirSync(d); } catch { return []; } }): Installed | null {
|
||||
// the release acceptance matrix drives the install prompt on a machine that has the app: act as if it had none
|
||||
if (env.STOREBOUND_DESKTOP_APP === 'none') return null;
|
||||
if (platform === 'darwin') {
|
||||
for (const dir of ['/Applications', join(home, 'Applications')]) {
|
||||
const app = join(dir, 'storebound.app');
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
// play subscriptions, apple subscriptions and prices import (apple iap never changes the prices of an existing product).
|
||||
// Imported only by those commands, so --allow-price-changes is a flag of theirs alone (tools/gen-flags.ts).
|
||||
import { confirm, type Ctx, declined } from './ctx';
|
||||
import { stdinIsTTY } from './tty';
|
||||
|
||||
/** The flag that lets a write command change the price of an existing product. `flow run` never adds it and refuses it in steps. */
|
||||
export const ALLOW_PRICE_CHANGES = 'allow-price-changes';
|
||||
|
|
@ -18,7 +19,7 @@ export interface HeldPrice { id: string; changes: { region: string; from: string
|
|||
export async function allowPriceChanges(ctx: Ctx, count: number, question: string): Promise<boolean> {
|
||||
if (!count || ctx.args.has('allow-price-changes')) return true;
|
||||
const yes = ctx.args.has('yes');
|
||||
if (process.env.STOREBOUND_SERVE === '1' || (process.stdin.isTTY && !yes)) return confirm(withoutYes(ctx), question);
|
||||
if (process.env.STOREBOUND_SERVE === '1' || (stdinIsTTY() && !yes)) return confirm(withoutYes(ctx), question);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
32
cli/lib/store-mock-env.ts
Normal file
32
cli/lib/store-mock-env.ts
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
// STOREBOUND_STORE_MOCK=http://127.0.0.1:<port>: every request to a store host (App Store Connect, Google APIs, the
|
||||
// public store pages, the example.com placeholders) goes to that local double instead, as
|
||||
// <mock>/__host/<host>/<path>. The release acceptance matrix (tools/acceptance.ts) runs the packed npm tarball this
|
||||
// way against the fake stores of tests/helpers/fake-stores.ts, on every platform and runtime. Only a loopback address
|
||||
// (with an optional path: the matrix gives every cell its own store) is accepted, so the variable can never send store keys or tokens to another machine. Unset: nothing changes.
|
||||
|
||||
const STORE_HOST = /^(?:[a-z0-9-]+\.)*(?:apple\.com|googleapis\.com|google\.com|example\.com)$/i;
|
||||
const LOOPBACK = /^http:\/\/(?:127\.0\.0\.1|localhost|\[::1\]):\d{1,5}(?:\/[\w.-]+)*$/;
|
||||
|
||||
/** The URL a request goes to under the mock (unchanged for hosts that are not store hosts). */
|
||||
export function mockedUrl(url: string, base: string): string {
|
||||
let u: URL;
|
||||
try { u = new URL(url); } catch { return url; }
|
||||
if (u.protocol !== 'https:' || !STORE_HOST.test(u.hostname)) return url;
|
||||
return `${base}/__host/${u.hostname}${u.pathname}${u.search}`;
|
||||
}
|
||||
|
||||
/** Installs the redirect when STOREBOUND_STORE_MOCK is set; throws on a non-loopback value. */
|
||||
export function installStoreMock(env: Record<string, string | undefined> = process.env): boolean {
|
||||
const base = env.STOREBOUND_STORE_MOCK?.replace(/\/+$/, '');
|
||||
if (!base) return false;
|
||||
if (!LOOPBACK.test(base)) throw new Error(`STOREBOUND_STORE_MOCK must be a loopback address like http://127.0.0.1:8080 (got ${JSON.stringify(base)})`);
|
||||
const real = globalThis.fetch;
|
||||
globalThis.fetch = ((input: string | URL | Request, init?: RequestInit) => {
|
||||
if (input instanceof Request) {
|
||||
const to = mockedUrl(input.url, base);
|
||||
return real(to === input.url ? input : new Request(to, input), init);
|
||||
}
|
||||
return real(mockedUrl(String(input), base), init);
|
||||
}) as typeof fetch;
|
||||
return true;
|
||||
}
|
||||
5
cli/lib/tty.ts
Normal file
5
cli/lib/tty.ts
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
// Whether a prompt can ask on stdin. STOREBOUND_ASSUME_TTY=1 treats piped stdin as the terminal, so the release
|
||||
// acceptance matrix (tools/acceptance.ts) drives the real [y/N] and [Y/n] prompts with piped answers ("n\n", EOF) on
|
||||
// every platform and runtime: the same reading code a person's terminal goes through.
|
||||
export const stdinIsTTY = (env: Record<string, string | undefined> = process.env): boolean =>
|
||||
env.STOREBOUND_ASSUME_TTY === '1' || !!process.stdin.isTTY;
|
||||
Loading…
Add table
Add a link
Reference in a new issue