mirror of
https://github.com/Kaelio/ktx.git
synced 2026-06-19 08:28:06 +02:00
Initial open-source release
This commit is contained in:
commit
1a42152e6f
1199 changed files with 257054 additions and 0 deletions
25
packages/cli/src/setup-secrets.ts
Normal file
25
packages/cli/src/setup-secrets.ts
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import { chmod, mkdir, writeFile } from 'node:fs/promises';
|
||||
import { join, resolve } from 'node:path';
|
||||
|
||||
export function envCredentialReference(envName: string): string {
|
||||
return `env:${envName}`;
|
||||
}
|
||||
|
||||
export interface WriteProjectLocalSecretReferenceOptions {
|
||||
projectDir: string;
|
||||
fileName: string;
|
||||
value: string;
|
||||
}
|
||||
|
||||
export async function writeProjectLocalSecretReference(
|
||||
options: WriteProjectLocalSecretReferenceOptions,
|
||||
): Promise<string> {
|
||||
const secretsDir = resolve(options.projectDir, '.klo/secrets');
|
||||
const secretPath = join(secretsDir, options.fileName);
|
||||
await mkdir(secretsDir, { recursive: true });
|
||||
await writeFile(secretPath, `${options.value.trim()}\n`, { encoding: 'utf-8', mode: 0o600 });
|
||||
if (process.platform !== 'win32') {
|
||||
await chmod(secretPath, 0o600);
|
||||
}
|
||||
return `file:${secretPath}`;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue