(assumeYes: boolean)
| 48 | } |
| 49 | |
| 50 | const resolveSecret = async (assumeYes: boolean): Promise<string> => { |
| 51 | if (process.env.SECRET?.trim()) { |
| 52 | return process.env.SECRET.trim() |
| 53 | } |
| 54 | |
| 55 | if (!assumeYes && process.stdin.isTTY) { |
| 56 | const value = await setupPrompts.text({ |
| 57 | message: 'SECRET env var value (hex recommended)', |
| 58 | placeholder: 'openssl rand -hex 128', |
| 59 | validate: (input) => (input.trim() ? undefined : 'SECRET is required'), |
| 60 | }) |
| 61 | |
| 62 | if (setupPrompts.isCancel(value)) { |
| 63 | setupPrompts.cancel('Setup cancelled') |
| 64 | throw new SetupCancelledError() |
| 65 | } |
| 66 | |
| 67 | return value.trim() |
| 68 | } |
| 69 | |
| 70 | return randomBytes(64).toString('hex') |
| 71 | } |
| 72 | |
| 73 | const upsertSecret = (content: string, secret: string): string => { |
| 74 | const normalized = content.length > 0 ? content : '' |
no test coverage detected