Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/install.conf
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ HEALTH_PATH=/health
DOMAINS=pit.world www.pit.world
TLS=1
TLS_EMAIL=anthony@profullstack.com
MAX_BODY=64k
MAX_BODY=1m
ACCESS_LOG=off
6 changes: 3 additions & 3 deletions src/promotion-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const PROMO_HELP = `pit promo: promotion campaigns (operators; needs PIT_
pit promo campaigns every campaign
pit promo create --source-ref cmp_... --name N --slug S --title T [--intro TEXT]
pit promo show ID overview: members, holds, posts, windows, reports
pit promo configure ID --json '{"spotlightAccounts":[...]}'
pit promo configure ID --config '{"spotlightAccounts":[...]}' (or --config @FILE.json)
pit promo import ID SNAPSHOT.json [--dry-run]
a complete OutreachGraph snapshot
(scripts/outreachgraph-campaign-export.sh)
Expand Down Expand Up @@ -98,8 +98,8 @@ export async function promoMain(args: string[], out: Out, client: PitClient, jso
})
}
case 'configure': {
need(id && f.json, `configure ID --json '{...}'`)
return show(await client.promo('PATCH', `/campaigns/${e(id)}`, { config: JSON.parse(f.json!) }))
need(id && f.config, `configure ID --config '{...}' | --config @FILE.json`)
return show(await client.promo('PATCH', `/campaigns/${e(id)}`, { config: JSON.parse(f.config!.startsWith('@') ? readFileSync(f.config!.slice(1), 'utf8') : f.config!) }))
}
case 'import': {
need(id && rest[1], 'import ID SNAPSHOT.json [--dry-run]')
Expand Down
13 changes: 13 additions & 0 deletions test/promotion.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,19 @@ describe('promotion: the verifier is not a visitor', () => {
})
})

describe('promotion: the CLI', () => {
it('passes configure --config through the top-level argument handling (which takes --json for itself)', async () => {
const { main } = await import('../src/cli.ts')
const h = setup()
process.env.PIT_ADMIN_TOKEN = 'admintoken'
const client = new PitClient('https://pit.world', (async (input: any, init: any) => h.app.request(String(input).replace('https://pit.world', ''), init, { ip: '127.0.0.1' })) as any)
const lines: string[] = []
const out = { log: (t: string) => lines.push(t), error: (t: string) => lines.push(`ERR ${t}`) }
expect(await main(['promo', 'configure', h.campaign, '--config', '{"perAccountPerDay":3}'], out, client)).toBe(0)
expect(h.promo.campaign(h.campaign).config.perAccountPerDay).toBe(3)
})
})

afterAll(() => {
delete process.env.PIT_ADMIN_TOKEN
})
Loading