CLI workspace for many apps and studios, credential profiles, release trains (release status / plan)
- storebound.workspace.json: app folders (globs), studios with accounts by credential profile, ignore list, the desktop's pairing overrides; ws init | list | status | check | validate | run | apps import | desktop export/import - credential profiles in ~/.storebound/credentials/<profile>.json or env, --account <profile> on any command - release status / release plan <version>, table or --json; MCP workspace_list, workspace_status, release_status, release_plan (read-only) - pairing rules (cli/lib/identity.ts), release lanes (cli/lib/train.ts) and the per-app status read (cli/lib/app-status.ts) shared with the desktop instead of copied - tests with sanitized fixtures, README, skills, CHANGELOG
This commit is contained in:
parent
02d90de77a
commit
7d70e58d76
26 changed files with 2220 additions and 292 deletions
|
|
@ -7,9 +7,13 @@
|
|||
// "reviewDemoAccount": { "username": "", "password": "" } }
|
||||
// The demo account for App Review can also come from env: REVIEW_DEMO_USER, REVIEW_DEMO_PASSWORD.
|
||||
// 3. ASC_P8 only: ~/.appstoreconnect/private_keys/AuthKey_<ASC_KEY_ID>.p8 (where Xcode / altool keep it)
|
||||
// With a credential profile (`--profile <name>` or STOREBOUND_PROFILE), the profile comes before all of these:
|
||||
// ~/.storebound/credentials/<name>.json (same four names; relative paths are relative to that file; folder:
|
||||
// STOREBOUND_CREDENTIALS_DIR) or env STOREBOUND_PROFILE_<NAME>_<KEY> (NAME upper case, other characters as _).
|
||||
// Many studios / store accounts from one machine: one profile per account; storebound.workspace.json names them.
|
||||
import { existsSync, readFileSync } from 'node:fs';
|
||||
import { homedir } from 'node:os';
|
||||
import { join } from 'node:path';
|
||||
import { isAbsolute, join, resolve } from 'node:path';
|
||||
|
||||
export interface ServiceAccount { client_email: string; private_key: string; token_uri?: string }
|
||||
export interface AscKey { keyId: string; issuerId: string; pem: string }
|
||||
|
|
@ -23,7 +27,51 @@ function fileStore(root: string): Store {
|
|||
try { return JSON.parse(readFileSync(p, 'utf8')) as Store; } catch (e) { throw new Error(`${p}: ${(e as Error).message}`); }
|
||||
}
|
||||
|
||||
/** The store credential names a profile holds (the same as the env names). */
|
||||
export const PROFILE_KEYS = ['PLAY_SERVICE_ACCOUNT', 'ASC_KEY_ID', 'ASC_ISSUER_ID', 'ASC_P8'] as const;
|
||||
export const PROFILE_RE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
|
||||
|
||||
export const profileDir = (): string => process.env.STOREBOUND_CREDENTIALS_DIR || join(homedir(), '.storebound', 'credentials');
|
||||
const profileEnvName = (profile: string, key: string): string => `STOREBOUND_PROFILE_${profile.toUpperCase().replace(/[^A-Z0-9]/g, '_')}_${key}`;
|
||||
|
||||
/**
|
||||
* The credentials of one profile as env values (never printed). Env STOREBOUND_PROFILE_<NAME>_<KEY> wins over the
|
||||
* profile file; a relative key path in the file is relative to the file. Throws on a bad name or an unreadable file.
|
||||
*/
|
||||
export function profileEnv(profile: string): Record<string, string> {
|
||||
if (!PROFILE_RE.test(profile)) throw new Error(`credential profile "${profile}": letters, digits, . _ - (max 64)`);
|
||||
const file = join(profileDir(), `${profile}.json`);
|
||||
let stored: Store = {};
|
||||
if (existsSync(file)) {
|
||||
try { stored = JSON.parse(readFileSync(file, 'utf8')) as Store; } catch (e) { throw new Error(`credential profile ${profile}: ${file}: ${(e as Error).message}`); }
|
||||
}
|
||||
const out: Record<string, string> = {};
|
||||
for (const k of PROFILE_KEYS) {
|
||||
const env = process.env[profileEnvName(profile, k)];
|
||||
const v = env || (typeof stored[k] === 'string' ? stored[k] as string : '');
|
||||
if (!v) continue;
|
||||
// a path in the file: relative to the profile folder (inline JSON / PEM stays as it is)
|
||||
const isPath = !env && !/^\s*\{/.test(v) && !/BEGIN PRIVATE KEY/.test(v) && (k === 'PLAY_SERVICE_ACCOUNT' || k === 'ASC_P8');
|
||||
out[k] = isPath && !isAbsolute(v) && !v.startsWith('~') ? resolve(profileDir(), v) : v;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/** Which stores a profile can reach, and where it comes from. No values. */
|
||||
export function profileStatus(profile: string): { profile: string; source: 'file' | 'env' | 'missing' | 'invalid'; apple: boolean; play: boolean; error?: string } {
|
||||
try {
|
||||
const env = profileEnv(profile);
|
||||
const fromEnv = PROFILE_KEYS.some(k => !!process.env[profileEnvName(profile, k)]);
|
||||
const source = fromEnv ? 'env' : existsSync(join(profileDir(), `${profile}.json`)) ? 'file' : 'missing';
|
||||
return { profile, source, apple: !!(env.ASC_KEY_ID && env.ASC_ISSUER_ID), play: !!env.PLAY_SERVICE_ACCOUNT };
|
||||
} catch (e) {
|
||||
return { profile, source: 'invalid', apple: false, play: false, error: (e as Error).message };
|
||||
}
|
||||
}
|
||||
|
||||
function value(root: string, name: string): string | undefined {
|
||||
const profile = process.env.STOREBOUND_PROFILE;
|
||||
if (profile) { const v = profileEnv(profile)[name]; if (v) return v; }
|
||||
const env = process.env[name];
|
||||
if (env) return env;
|
||||
const v = fileStore(root)[name];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue