Checkpoint SHD dashboard design system
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import { spawnSync } from 'node:child_process';
|
||||
import { resolve } from 'node:path';
|
||||
import process from 'node:process';
|
||||
|
||||
const files = ['.env.development', '.env.production'];
|
||||
const action = process.argv[2];
|
||||
const gitCommand = process.platform === 'win32' ? 'git.exe' : 'git';
|
||||
const dotenvxCli = resolve('node_modules/@dotenvx/dotenvx/src/cli/dotenvx.js');
|
||||
|
||||
function run(command, args) {
|
||||
const result = spawnSync(command, args, { cwd: process.cwd(), stdio: 'inherit' });
|
||||
if (result.error) throw result.error;
|
||||
if (result.status !== 0) process.exit(result.status ?? 1);
|
||||
}
|
||||
|
||||
function dotenvx(command, file) {
|
||||
run(process.execPath, [dotenvxCli, command, '-f', file]);
|
||||
}
|
||||
|
||||
if (!['encrypt', 'decrypt', 'stage'].includes(action)) {
|
||||
console.error('Usage: node scripts/env-files.mjs <encrypt|decrypt|stage>');
|
||||
process.exit(2);
|
||||
}
|
||||
|
||||
for (const file of files) {
|
||||
dotenvx(action === 'decrypt' ? 'decrypt' : 'encrypt', file);
|
||||
}
|
||||
|
||||
if (action === 'stage') {
|
||||
run(gitCommand, ['add', '--', ...files]);
|
||||
console.log('Encrypted and staged environment files.');
|
||||
}
|
||||
Reference in New Issue
Block a user