One product per machine: the CLI and the desktop app share one version, the store accounts and the app folder list
- one version: package.json's version is the desktop app's too (desktopVersion removed); tools/desktop-version.ts keeps the plugin manifests and the app's copies equal, desktop-release publish refuses another version, release order app first then npm publish; the unpublished desktop 0.1.0 candidate is noted in the docs and CHANGELOG - storebound desktop installs (per user, no admin: macOS DMG -> /Applications or ~/Applications, Windows NSIS /S, Linux AppImage + .desktop with the storebound:// handler), updates an older app, notes a newer one (downgrade only with --force), asks once ([Y/n], --yes, exit 3 without a terminal), opens on the folder; --dry / --json / --download; the install steps are pure plans (cli/lib/desktop-install.ts); the version's own manifest dl/<version>/latest.json - credentials: one store, the CLI's credential profiles in ~/.storebound/credentials; the desktop writes and reads them (profiles.rs, files 0600), moves old keychain accounts into profiles on first start, shows profiles the CLI made; precedence env > named profile > project file > default profile; config `account`, "account" in the project's credentials.json; storebound accounts list | import (dedup by key id / service account e-mail, key files copied 0600, project file keeps keystore and review contact, backup, --dry, never prints values) | use - app folders: one list ~/.storebound/projects.json shared by the desktop (registry.rs), storebound desktop, apps folders | add | remove, ws init and ws without a workspace file - desktop: notice when a folder pins another storebound version; storebound-desktop --version - tests: version drift, desktop decisions and per-OS plans, credential precedence and import, registry (TS + Rust), keychain migration and profile round trip (Rust), boot check with old keychain state and the new shared state
This commit is contained in:
parent
bba46b5c7f
commit
d2ce185441
60 changed files with 2443 additions and 246 deletions
|
|
@ -3,14 +3,19 @@ import { describe, expect, test } from 'bun:test';
|
|||
import { cpSync, mkdirSync, mkdtempSync, readFileSync, writeFileSync } from 'node:fs';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { join } from 'node:path';
|
||||
import { artifactName, developerIdIdentity, mergeManifest, pathFreeEnv, releaseUrl, remoteSessionReason, sliceProblems, sumsText, uploadable, archProblems, commitProblems } from '../tools/desktop-release';
|
||||
import { artifactName, developerIdIdentity, mergeManifest, pathFreeEnv, releaseUrl, remoteSessionReason, sliceProblems, sumsText, uploadable, archProblems, commitProblems, releaseTogetherProblems } from '../tools/desktop-release';
|
||||
import { COPIES, setVersion, versions } from '../tools/desktop-version';
|
||||
|
||||
describe('desktop version authority', () => {
|
||||
test('the repository has one desktop version', () => {
|
||||
test('the repository has one version: the CLI, the plugin manifests and the desktop app', () => {
|
||||
const { version, drift } = versions();
|
||||
expect(version).toMatch(/^\d+\.\d+\.\d+$/);
|
||||
expect(drift).toEqual([]);
|
||||
const pkg = JSON.parse(readFileSync(join(import.meta.dir, '../package.json'), 'utf8'));
|
||||
expect(version).toBe(pkg.version);
|
||||
expect(pkg.desktopVersion).toBeUndefined();
|
||||
expect(COPIES.map(c => c.file)).toContain('apps/desktop/src-tauri/tauri.conf.json');
|
||||
expect(COPIES[0]!.file).toBe('package.json');
|
||||
});
|
||||
test('drift is found and --set fixes every copy', () => {
|
||||
const root = mkdtempSync(join(tmpdir(), 'sb-ver-'));
|
||||
|
|
@ -20,6 +25,8 @@ describe('desktop version authority', () => {
|
|||
expect(versions(root).drift.map(d => d.file)).toEqual(['apps/desktop/src-tauri/tauri.conf.json']);
|
||||
setVersion('0.2.0-beta.1', root);
|
||||
expect(versions(root)).toEqual({ version: '0.2.0-beta.1', drift: [] });
|
||||
expect(JSON.parse(readFileSync(join(root, 'package.json'), 'utf8')).version).toBe('0.2.0-beta.1');
|
||||
expect(JSON.parse(readFileSync(join(root, '.claude-plugin/marketplace.json'), 'utf8')).plugins[0].version).toBe('0.2.0-beta.1');
|
||||
// only the package's own version line of Cargo.toml / Cargo.lock changes
|
||||
expect(readFileSync(join(root, 'apps/desktop/src-tauri/Cargo.toml'), 'utf8')).toContain('tauri = { version = "2.12"');
|
||||
expect(() => setVersion('latest', root)).toThrow();
|
||||
|
|
@ -27,6 +34,11 @@ describe('desktop version authority', () => {
|
|||
});
|
||||
|
||||
describe('desktop release', () => {
|
||||
test('the app and the npm CLI are published with one version', () => {
|
||||
expect(releaseTogetherProblems('0.8.0', '0.8.0')).toEqual([]);
|
||||
expect(releaseTogetherProblems('0.1.0', '0.8.0')[0]).toMatch(/one version/);
|
||||
expect(releaseTogetherProblems('0.8.0', null)).toHaveLength(1);
|
||||
});
|
||||
test('signing refuses SSH and non-GUI sessions', () => {
|
||||
expect(remoteSessionReason({}, 'Aqua')).toBeNull();
|
||||
expect(remoteSessionReason({ SSH_CONNECTION: '1 2 3 4' }, 'Aqua')).toMatch(/SSH/);
|
||||
|
|
|
|||
|
|
@ -1,10 +1,19 @@
|
|||
// Loaded before every test file (bunfig.toml): no real waiting between the re-checks of cli/lib/upsert.ts or for
|
||||
// the store's list to settle after a create (cli/apple/iap.ts).
|
||||
import { afterEach } from 'bun:test';
|
||||
import { mkdtempSync } from 'node:fs';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { join } from 'node:path';
|
||||
|
||||
process.env.STOREBOUND_UPSERT_WAIT_MS = '0';
|
||||
process.env.STOREBOUND_LIST_SETTLE_MS ??= '0';
|
||||
|
||||
// The machine-wide stores (credential profiles, the app folder list) of the person running the tests are never read
|
||||
// or written: every test process gets empty ones (a test that needs content points these at its own folder).
|
||||
const machine = mkdtempSync(join(tmpdir(), 'storebound-machine-'));
|
||||
process.env.STOREBOUND_CREDENTIALS_DIR = join(machine, 'credentials');
|
||||
process.env.STOREBOUND_REGISTRY = join(machine, 'projects.json');
|
||||
|
||||
// Commands run in-process set process.exitCode on purpose (a check with problems, a declined confirmation:
|
||||
// DECLINED_EXIT in cli/lib/ctx.ts). Tests assert it where it matters; it must not leak into bun test's own exit code.
|
||||
afterEach(() => { process.exitCode = 0; });
|
||||
|
|
|
|||
231
tests/machine.test.ts
Normal file
231
tests/machine.test.ts
Normal file
|
|
@ -0,0 +1,231 @@
|
|||
// One product per machine: credential profiles shared by every project and the desktop app (precedence, `accounts
|
||||
// import` dedup and file modes), the machine's app folder list, and what `storebound desktop` decides and installs.
|
||||
import { describe, expect, test } from 'bun:test';
|
||||
import { existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { join } from 'node:path';
|
||||
import { applyImport, planImport, useProfile } from '../cli/lib/accounts';
|
||||
import { activeProfile, androidSigning, ascKey, defaultProfile, playServiceAccount, reviewContact, setConfigAccount } from '../cli/lib/credentials';
|
||||
import { compareVersions, consent, decide, installPlan, isRunning, question, runningCheck } from '../cli/lib/desktop-install';
|
||||
import { addFolder, folderId, parseRegistry, readRegistry, removeFolder, withFolder, withoutFolder } from '../cli/lib/registry';
|
||||
import { desktopProjectId } from '../cli/lib/workspace';
|
||||
|
||||
const ROOT = join(import.meta.dir, '..');
|
||||
const PEM = (s: string) => ['-----BEGIN PRIVATE KEY-----', s, '-----END PRIVATE KEY-----', ''].join('\n');
|
||||
const SA = (email: string) => JSON.stringify({ type: 'service_account', client_email: email, private_key: PEM('play-secret-sentinel'), token_uri: 'https://oauth2.googleapis.com/token' });
|
||||
|
||||
/** Runs `fn` with an empty credentials folder and registry, and no store env; restores everything after. */
|
||||
function machine(fn: (m: { creds: string; base: string }) => void) {
|
||||
const saved = { ...process.env };
|
||||
const base = mkdtempSync(join(tmpdir(), 'sb-machine-'));
|
||||
try {
|
||||
for (const k of Object.keys(process.env)) if (/^(ASC_|PLAY_SERVICE|STOREBOUND_PROFILE|ANDROID_)/.test(k)) delete process.env[k];
|
||||
process.env.STOREBOUND_CREDENTIALS_DIR = join(base, 'credentials');
|
||||
process.env.STOREBOUND_REGISTRY = join(base, 'projects.json');
|
||||
fn({ creds: join(base, 'credentials'), base });
|
||||
} finally {
|
||||
for (const k of Object.keys(process.env)) if (!(k in saved)) delete process.env[k];
|
||||
Object.assign(process.env, saved);
|
||||
}
|
||||
}
|
||||
|
||||
/** A project whose .storebound/credentials.json holds the shared store keys (as files in the project) and its own keystore. */
|
||||
function project(base: string, name: string, o: { keyId?: string; email?: string } = {}): string {
|
||||
const dir = join(base, name);
|
||||
mkdirSync(join(dir, '.storebound'), { recursive: true });
|
||||
writeFileSync(join(dir, 'storebound.config.json'), '{}');
|
||||
writeFileSync(join(dir, '.storebound', `AuthKey_${o.keyId ?? 'ABCDE12345'}.p8`), PEM('apple-secret-sentinel'));
|
||||
writeFileSync(join(dir, '.storebound', 'play.json'), SA(o.email ?? 'release@example.com'));
|
||||
writeFileSync(join(dir, '.storebound', 'credentials.json'), JSON.stringify({
|
||||
ASC_KEY_ID: o.keyId ?? 'ABCDE12345', ASC_ISSUER_ID: '00000000-0000-0000-0000-000000000000', ASC_P8: join(dir, '.storebound', `AuthKey_${o.keyId ?? 'ABCDE12345'}.p8`),
|
||||
PLAY_SERVICE_ACCOUNT: join(dir, '.storebound', 'play.json'), ASC_VENDOR_NUMBER: '12345678',
|
||||
ANDROID_KEYSTORE: `${name}.jks`, ANDROID_KEYSTORE_PASSWORD: `${name}-pw`, ANDROID_KEY_ALIAS: 'upload',
|
||||
reviewContact: { firstName: 'Ada', lastName: 'Example', phone: '+1 555 0100', email: `review@${name}.example.org` },
|
||||
}, null, 2));
|
||||
return dir;
|
||||
}
|
||||
|
||||
describe('credentials: one machine, many projects', () => {
|
||||
test('project-only values from the project, store keys from the profile, env over everything', () => machine(({ creds, base }) => {
|
||||
const a = project(base, 'Star Dash');
|
||||
// the project's own keys work without any profile
|
||||
expect(ascKey(a).keyId).toBe('ABCDE12345');
|
||||
mkdirSync(creds, { recursive: true });
|
||||
writeFileSync(join(creds, 'other.json'), JSON.stringify({ ASC_KEY_ID: 'OTHER00000', ASC_ISSUER_ID: 'iss', ASC_P8: PEM('x') }));
|
||||
// the default profile (the only one) never beats keys the project holds itself
|
||||
expect(defaultProfile()).toBe('other');
|
||||
expect(activeProfile(a)).toEqual({ name: 'other', from: 'default' });
|
||||
expect(ascKey(a).keyId).toBe('ABCDE12345');
|
||||
// a named profile does ("account" in the project file, then the config, then --account / env)
|
||||
const file = join(a, '.storebound', 'credentials.json');
|
||||
writeFileSync(file, JSON.stringify({ ...JSON.parse(readFileSync(file, 'utf8')), account: 'other' }));
|
||||
expect(activeProfile(a)).toEqual({ name: 'other', from: 'project' });
|
||||
expect(ascKey(a).keyId).toBe('OTHER00000');
|
||||
setConfigAccount(a, 'nope');
|
||||
expect(activeProfile(a)?.from).toBe('config');
|
||||
setConfigAccount(a, undefined);
|
||||
process.env.ASC_KEY_ID = 'ENV0000000';
|
||||
expect(ascKey(a).keyId).toBe('ENV0000000');
|
||||
delete process.env.ASC_KEY_ID;
|
||||
// the app's own things never come from a profile
|
||||
expect(androidSigning(a)?.keyAlias).toBe('upload');
|
||||
expect(reviewContact(a)?.firstName).toBe('Ada');
|
||||
// STOREBOUND_PROFILE set but empty: no profile at all
|
||||
process.env.STOREBOUND_PROFILE = '';
|
||||
expect(activeProfile(a)).toBeNull();
|
||||
}));
|
||||
|
||||
test('accounts import: two projects with the same Apple key and Play account -> one profile, 0600 files, projects stay valid', () => machine(({ creds, base }) => {
|
||||
const a = project(base, 'Star Dash'), b = project(base, 'a game');
|
||||
const dry = planImport(a);
|
||||
expect(dry.profile).toBe('default');
|
||||
expect(dry.reuse).toBe(false);
|
||||
expect(dry.moved.sort()).toEqual(['ASC_ISSUER_ID', 'ASC_KEY_ID', 'ASC_P8', 'ASC_VENDOR_NUMBER', 'PLAY_SERVICE_ACCOUNT']);
|
||||
expect(existsSync(creds)).toBe(false); // planning writes nothing
|
||||
const r = applyImport(dry);
|
||||
expect(r.backup && existsSync(r.backup)).toBeTruthy();
|
||||
const files = readdirSync(join(creds, 'default')).sort();
|
||||
expect(files).toEqual(['app-store-connect.p8', 'play-service-account.json']);
|
||||
if (process.platform !== 'win32') {
|
||||
for (const f of files) expect(statSync(join(creds, 'default', f)).mode & 0o777).toBe(0o600);
|
||||
expect(statSync(join(creds, 'default.json')).mode & 0o777).toBe(0o600);
|
||||
expect(statSync(join(creds, 'default')).mode & 0o777).toBe(0o700);
|
||||
expect(statSync(join(a, '.storebound', 'credentials.json')).mode & 0o777).toBe(0o600);
|
||||
}
|
||||
// the profile refers to its key files by path; the project file keeps the app's own things and names the profile
|
||||
const prof = JSON.parse(readFileSync(join(creds, 'default.json'), 'utf8'));
|
||||
expect(prof.ASC_P8).toBe('default/app-store-connect.p8');
|
||||
expect(JSON.stringify(prof)).not.toContain('sentinel');
|
||||
const projA = JSON.parse(readFileSync(join(a, '.storebound', 'credentials.json'), 'utf8'));
|
||||
expect(projA.account).toBe('default');
|
||||
expect(projA.ASC_KEY_ID).toBeUndefined();
|
||||
expect(projA.ANDROID_KEYSTORE).toBe('Star Dash.jks');
|
||||
expect(ascKey(a).pem).toContain('apple-secret-sentinel');
|
||||
expect(playServiceAccount(a).client_email).toBe('release@example.com');
|
||||
// the second project with the same account: the same profile, its files unchanged
|
||||
const second = planImport(b);
|
||||
expect(second.profile).toBe('default');
|
||||
expect(second.reuse).toBe(true);
|
||||
expect(second.writes.filter(w => w.path.startsWith(creds)).map(w => w.action)).toEqual(['same']);
|
||||
applyImport(second);
|
||||
expect(JSON.parse(readFileSync(join(b, '.storebound', 'credentials.json'), 'utf8')).ANDROID_KEYSTORE_PASSWORD).toBe('a game-pw');
|
||||
expect(ascKey(b).keyId).toBe('ABCDE12345');
|
||||
// running it again changes nothing
|
||||
expect(planImport(b).writes.every(w => w.action === 'same')).toBe(true);
|
||||
expect(planImport(b).notes[0]).toMatch(/already imported/);
|
||||
// another team: a profile of its own; --name may not take over an existing profile's account
|
||||
const c = project(base, 'other-studio', { keyId: 'ZZZZZ99999', email: 'other@example.com' });
|
||||
expect(() => planImport(c, { name: 'default' })).toThrow(/another App Store Connect key/);
|
||||
const third = planImport(c);
|
||||
expect(third.profile).toBe('other-studio');
|
||||
applyImport(third);
|
||||
expect(ascKey(c).keyId).toBe('ZZZZZ99999');
|
||||
expect(ascKey(a).keyId).toBe('ABCDE12345'); // "account": "default" still points Star Dash at its own
|
||||
expect(useProfile(c, 'default')).toContain('credentials.json');
|
||||
expect(() => useProfile(c, 'missing')).toThrow(/no profile/);
|
||||
}));
|
||||
|
||||
test('the import command prints paths and names, never key values', () => machine(({ base }) => {
|
||||
const a = project(base, 'Star Dash');
|
||||
const r = Bun.spawnSync(['bun', join(ROOT, 'cli', 'index.ts'), 'accounts', 'import', '--dry', '--dir', a], { env: { ...process.env, STOREBOUND_NO_NETWORK: '1' } });
|
||||
const out = r.stdout.toString() + r.stderr.toString();
|
||||
expect(r.exitCode).toBe(0);
|
||||
expect(out).toContain('profile "default"');
|
||||
expect(out).not.toContain('sentinel');
|
||||
expect(out).not.toContain('ABCDE12345');
|
||||
const no = Bun.spawnSync(['bun', join(ROOT, 'cli', 'index.ts'), 'accounts', 'import', '--dir', a], { stdin: 'ignore', env: { ...process.env, STOREBOUND_NO_NETWORK: '1' } });
|
||||
expect(no.exitCode).toBe(3); // not a terminal and no --yes
|
||||
expect(existsSync(join(process.env.STOREBOUND_CREDENTIALS_DIR!, 'default.json'))).toBe(false);
|
||||
}));
|
||||
});
|
||||
|
||||
describe('the machine\'s app folder list', () => {
|
||||
test('add, re-add, remove; ids are the desktop export ids; bad entries are dropped', () => machine(({ base }) => {
|
||||
const r0 = { version: 1 as const, projects: [] };
|
||||
const { registry, added } = withFolder(r0, '/w/Star Dash', 'Star Dash', 't');
|
||||
expect(added).toBe(true);
|
||||
expect(registry.projects[0]!.id).toBe(desktopProjectId('/w/Star Dash'));
|
||||
expect(withFolder(registry, '/w/Star Dash/', undefined, 't').added).toBe(false);
|
||||
expect(withoutFolder(registry, folderId('/w/Star Dash')).removed?.name).toBe('Star Dash');
|
||||
expect(parseRegistry('{"projects":[{"path":"relative"},{"path":"/a","id":"zz"},{"path":"/a"}]}').projects.map(p => [p.path, p.id])).toEqual([['/a', folderId('/a')]]);
|
||||
expect(parseRegistry('not json').projects).toEqual([]);
|
||||
const dir = project(base, 'a game');
|
||||
expect(addFolder(dir).added).toBe(true);
|
||||
expect(addFolder(dir).added).toBe(false);
|
||||
expect(readRegistry().projects.map(p => p.path)).toEqual([dir]);
|
||||
// `storebound apps folders` reads the same file the desktop does
|
||||
const out = Bun.spawnSync(['bun', join(ROOT, 'cli', 'index.ts'), 'apps', 'folders', '--json'], { env: { ...process.env, STOREBOUND_NO_NETWORK: '1' } }).stdout.toString();
|
||||
expect(JSON.parse(out).projects[0].path).toBe(dir);
|
||||
expect(removeFolder(dir)?.path).toBe(dir);
|
||||
expect(readRegistry().projects).toEqual([]);
|
||||
}));
|
||||
});
|
||||
|
||||
describe('storebound desktop: one version with the CLI', () => {
|
||||
const app = { path: '/Applications/storebound.app', how: 'bundle' as const };
|
||||
test('versions compare like semver', () => {
|
||||
expect(compareVersions('0.8.0', '0.8.0')).toBe(0);
|
||||
expect(compareVersions('0.7.9', '0.8.0')).toBe(-1);
|
||||
expect(compareVersions('0.10.0', '0.9.1')).toBe(1);
|
||||
expect(compareVersions('0.8.0-beta.1', '0.8.0')).toBe(-1);
|
||||
});
|
||||
test('installed and the same: open; missing: install; older: update; newer: open, downgrade only with --force; nothing published', () => {
|
||||
expect(decide({ installed: app, installedVersion: '0.8.0', cli: '0.8.0', available: null, force: false }).action).toBe('open');
|
||||
expect(decide({ installed: null, installedVersion: null, cli: '0.8.0', available: '0.8.0', force: false })).toEqual({ action: 'install', from: null, to: '0.8.0', notes: [] });
|
||||
const up = decide({ installed: app, installedVersion: '0.7.1', cli: '0.8.0', available: '0.8.0', force: false });
|
||||
expect([up.action, up.from, up.to]).toEqual(['update', '0.7.1', '0.8.0']);
|
||||
const newer = decide({ installed: app, installedVersion: '0.9.0', cli: '0.8.0', available: '0.8.0', force: false });
|
||||
expect(newer.action).toBe('open');
|
||||
expect(newer.notes[0]).toMatch(/newer than this CLI/);
|
||||
expect(decide({ installed: app, installedVersion: '0.9.0', cli: '0.8.0', available: '0.8.0', force: true }).action).toBe('downgrade');
|
||||
// the CLI's own version is not out yet: the newest published one, said so
|
||||
const lag = decide({ installed: null, installedVersion: null, cli: '0.8.1', available: '0.8.0', force: false });
|
||||
expect([lag.action, lag.to]).toEqual(['install', '0.8.0']);
|
||||
expect(lag.notes.join()).toMatch(/0\.8\.0.*0\.8\.1/);
|
||||
expect(decide({ installed: app, installedVersion: '0.7.0', cli: '0.8.0', available: '0.7.0', force: false }).action).toBe('open');
|
||||
expect(decide({ installed: null, installedVersion: null, cli: '0.8.0', available: null, unavailableReason: 'offline', force: false })).toEqual({ action: 'unavailable', from: null, to: null, notes: ['offline'] });
|
||||
});
|
||||
test('no terminal and no --yes: declined (exit 3, the command printed); the question defaults to yes', () => {
|
||||
expect(consent(true, false)).toBe('yes');
|
||||
expect(consent(false, true)).toBe('ask');
|
||||
expect(consent(false, false)).toBe('declined');
|
||||
expect(question({ action: 'install', from: null, to: '0.8.0', notes: [] }, 77_000_000, '~/Applications')).toBe('Install storebound desktop 0.8.0 (77 MB) to ~/Applications? [Y/n] ');
|
||||
});
|
||||
const base = { file: '/tmp/x/storebound_0.8.0_universal.dmg', version: '0.8.0', home: '/Users/you', tmp: '/tmp/x', env: {}, has: () => false, systemAppsWritable: false };
|
||||
test('macOS: from the read-only DMG into ~/Applications (or /Applications), no xattr, an update in place', () => {
|
||||
const p = installPlan({ ...base, platform: 'darwin', kind: 'macos-universal-dmg', existing: null });
|
||||
expect(p.target).toBe('/Users/you/Applications/storebound.app');
|
||||
expect(p.place).toBe('~/Applications');
|
||||
const runs = p.steps.flatMap(s => ('run' in s ? [s.run] : []));
|
||||
expect(runs[0]).toEqual(['hdiutil', 'attach', '-nobrowse', '-readonly', '-noautoopen', '-mountpoint', '/tmp/x/mnt', base.file]);
|
||||
expect(runs.some(r => r[0] === 'hdiutil' && r[1] === 'detach')).toBe(true);
|
||||
expect(JSON.stringify(p.steps)).not.toContain('xattr');
|
||||
expect(p.steps.some(s => 'expectVersion' in s && s.expectVersion.version === '0.8.0')).toBe(true);
|
||||
expect(installPlan({ ...base, platform: 'darwin', kind: 'macos-universal-dmg', existing: null, systemAppsWritable: true }).target).toBe('/Applications/storebound.app');
|
||||
const upd = installPlan({ ...base, platform: 'darwin', kind: 'macos-universal-dmg', existing: app, systemAppsWritable: false });
|
||||
expect(upd.target).toBe('/Applications/storebound.app');
|
||||
expect(upd.steps.map(s => Object.keys(s)[1])).toContain('remove');
|
||||
});
|
||||
test('Windows: the per-user NSIS installer, silent; Linux: AppImage + .desktop with the link handler; .deb only printed', () => {
|
||||
const w = installPlan({ ...base, platform: 'win32', kind: 'windows-x86_64-nsis', file: 'C:\\t\\storebound_0.8.0_x64-setup.exe', existing: null, env: { LOCALAPPDATA: 'C:\\Users\\you\\AppData\\Local' } });
|
||||
expect(w.steps[0]).toMatchObject({ run: ['C:\\t\\storebound_0.8.0_x64-setup.exe', '/S'] });
|
||||
expect(w.target).toBe('C:\\Users\\you\\AppData\\Local\\storebound\\storebound-desktop.exe');
|
||||
const l = installPlan({ ...base, platform: 'linux', kind: 'linux-x86_64-appimage', home: '/home/you', file: '/tmp/x/storebound_0.8.0_amd64.AppImage', existing: null, has: t => t === 'xdg-mime' });
|
||||
expect(l.target).toBe('/home/you/.local/bin/storebound.AppImage');
|
||||
const entry = l.steps.find(s => 'write' in s) as { write: { path: string; content: string } };
|
||||
expect(entry.write.path).toBe('/home/you/.local/share/applications/storebound.desktop');
|
||||
expect(entry.write.content).toContain('MimeType=x-scheme-handler/storebound;');
|
||||
expect(entry.write.content).toContain('Exec="/home/you/.local/bin/storebound.AppImage" %u');
|
||||
expect(l.steps.flatMap(s => ('run' in s ? [s.run[0]] : []))).toEqual(['xdg-mime']);
|
||||
const deb = installPlan({ ...base, platform: 'linux', kind: 'linux-x86_64-deb', home: '/home/you', existing: null });
|
||||
expect(deb.steps).toEqual([]);
|
||||
expect(deb.manual).toMatch(/sudo apt install/);
|
||||
});
|
||||
test('an update never replaces a running app', () => {
|
||||
expect(runningCheck('darwin')).toEqual(['pgrep', '-x', 'storebound-desktop']);
|
||||
expect(isRunning('darwin', 0, '123\n')).toBe(true);
|
||||
expect(isRunning('linux', 1, '')).toBe(false);
|
||||
expect(isRunning('win32', 0, 'INFO: No tasks are running which match the specified criteria.')).toBe(false);
|
||||
expect(isRunning('win32', 0, 'storebound-desktop.exe 4242 Console')).toBe(true);
|
||||
});
|
||||
});
|
||||
|
|
@ -207,7 +207,8 @@ describe('serve: account methods', () => {
|
|||
const r = await s.call('apps.list', { credentials: PLAY, args: { icons: true } });
|
||||
expect(r.result).toEqual({ store: 'android', apps: [], warnings: [], at: 'x' });
|
||||
expect(s.calls[0]!.argv).toEqual(['apps', 'list', '--store', 'play', '--icons', '--json']);
|
||||
expect(s.calls[0]!.o.env).toEqual(PLAY);
|
||||
// exactly this account: no credential profile of the machine mixes in
|
||||
expect(s.calls[0]!.o.env).toEqual({ ...PLAY, STOREBOUND_PROFILE: '' });
|
||||
expect(existsSync(join(s.calls[0]!.o.cwd, '.storebound'))).toBe(false);
|
||||
await s.call('account.check', { credentials: APPLE });
|
||||
expect(s.calls[1]!.argv).toEqual(['apps', 'check', '--store', 'apple', '--json']);
|
||||
|
|
|
|||
|
|
@ -156,13 +156,14 @@ describe('credential profiles', () => {
|
|||
expect(profileStatus('nobody')).toEqual({ profile: 'nobody', source: 'missing', apple: false, play: false });
|
||||
expect(JSON.stringify(profileStatus('acme-apple'))).not.toContain(SENTINEL);
|
||||
expect(() => profileEnv('../x')).toThrow('credential profile');
|
||||
// a profile chosen for the run wins over env and the project file
|
||||
// env wins over everything; then a named profile (--account), then the project file
|
||||
const pem = ['-----BEGIN PRIVATE KEY-----', 'abc', '-----END PRIVATE KEY-----'].join('\n');
|
||||
writeFileSync(join(creds, 'pick.json'), JSON.stringify({ ASC_KEY_ID: 'PICKED', ASC_ISSUER_ID: 'iss', ASC_P8: pem }));
|
||||
process.env.ASC_KEY_ID = 'FROM-ENV';
|
||||
process.env.ASC_ISSUER_ID = 'iss-env';
|
||||
process.env.STOREBOUND_PROFILE = 'pick';
|
||||
expect(ascKey(root).keyId).toBe('PICKED');
|
||||
process.env.ASC_KEY_ID = 'FROM-ENV';
|
||||
process.env.ASC_ISSUER_ID = 'iss-env';
|
||||
expect(ascKey(root).keyId).toBe('FROM-ENV');
|
||||
delete process.env.STOREBOUND_PROFILE;
|
||||
process.env.ASC_P8 = pem;
|
||||
expect(ascKey(root).keyId).toBe('FROM-ENV');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue