first commit
This commit is contained in:
commit
ff482ebe23
251 files changed
+19126
No files matched your search
@@ -0,0 +1,12 @@
|
||||
import { existsSync, readFileSync, writeFileSync, appendFileSync } from 'node:fs';
|
||||
import { randomBytes } from 'node:crypto';
|
||||
if(existsSync('.env'))console.log('.env already exists; preserved existing configuration.');
|
||||
else {const template=readFileSync('.env.example','utf8');writeFileSync('.env',template.replace('ADMIN_TOKEN=','ADMIN_TOKEN='+randomBytes(32).toString('base64url')),{mode:0o600});console.log('Created .env with a random bootstrap administrator token. Open .env locally to use it; never commit this file.');}
|
||||
let existing=readFileSync('.env','utf8');
|
||||
if(!/^INSPECTOR_URL=/m.test(existing)){appendFileSync('.env','\nINSPECTOR_URL=http://127.0.0.1:4311\n');existing=readFileSync('.env','utf8');}
|
||||
if(!/^INSPECTOR_TOKEN=.+/m.test(existing)){
|
||||
const secret=randomBytes(32).toString('base64url');
|
||||
if(/^INSPECTOR_TOKEN=/m.test(existing))writeFileSync('.env',existing.replace(/^INSPECTOR_TOKEN=.*$/m,'INSPECTOR_TOKEN='+secret),{mode:0o600});
|
||||
else appendFileSync('.env','INSPECTOR_TOKEN='+secret+'\n',{mode:0o600});
|
||||
console.log('Configured a private inspector credential.');
|
||||
}
|
||||
Reference in new issue
Block a user