Compare commits
4 Commits
a9cf2a1d21
...
a335d5c14f
Author | SHA1 | Date |
---|---|---|
b1ek | a335d5c14f | |
b1ek | e4f08d0778 | |
b1ek | 64e780b7af | |
b1ek | 513b4c9161 |
|
@ -30,5 +30,4 @@ cd to `react/resume` and run `build.sh`.
|
|||
If you are running in debug mode, run `yarn/npm start`
|
||||
|
||||
## Generate the key
|
||||
Install node modules in following directories: `.`, `./scripts`
|
||||
Then, cd to root and run `node scripts/generate_key.js`
|
||||
Cd to root of project and run `scripts/generate_key.py`
|
7
dev.sh
7
dev.sh
|
@ -1,5 +1,12 @@
|
|||
#!/bin/bash
|
||||
|
||||
if [ ! -f .env ]; then
|
||||
echo "No .env; Please create .env and try again"
|
||||
exit
|
||||
fi
|
||||
|
||||
. '.env'
|
||||
|
||||
cp docker-compose.dev docker-compose.yml
|
||||
cp Dockerfile.dev Dockerfile
|
||||
|
||||
|
|
|
@ -26,7 +26,8 @@ config = {
|
|||
host: DB_HOSTNAME || config.host,
|
||||
define: {
|
||||
timestamps: false
|
||||
}
|
||||
},
|
||||
logging: false
|
||||
};
|
||||
|
||||
/** @type Sequelize */
|
||||
|
|
7
prod.sh
7
prod.sh
|
@ -1,5 +1,12 @@
|
|||
#!/bin/bash
|
||||
|
||||
if [ ! -f .env ]; then
|
||||
echo "No .env; Please create .env and try again"
|
||||
exit
|
||||
fi
|
||||
|
||||
. '.env'
|
||||
|
||||
cp docker-compose.prod docker-compose.yml
|
||||
cp Dockerfile.prod Dockerfile
|
||||
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
import { Terminal } from 'xterm';
|
||||
import { saveAs } from 'file-saver';
|
||||
const fs = require('../fs');
|
||||
|
||||
/**
|
||||
*
|
||||
* @param { string[] } argv
|
||||
* @param { Terminal } terminal
|
||||
*/
|
||||
module.exports = (argv, terminal) => {
|
||||
|
||||
if (argv.indexOf('--help') != -1) {
|
||||
terminal.write(
|
||||
`Usage: ${argv[0]} [DESTANATION]\n
|
||||
Import files from your system to this filesystem.
|
||||
`
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
let el = document.getElementById('upload_file_btn');
|
||||
if (el == null) {
|
||||
el = document.createElement('input');
|
||||
el.style.display = 'none';
|
||||
el.type = 'file';
|
||||
el.id = 'upload_file_btn';
|
||||
el.setAttribute('multiple', 'multiple');
|
||||
document.body.appendChild(el);
|
||||
}
|
||||
|
||||
const dir = argv[1] || '.';
|
||||
|
||||
el.click();
|
||||
|
||||
let files = el.files;
|
||||
global.f = files
|
||||
}
|
|
@ -8,6 +8,7 @@ let cmds = {
|
|||
'mkdir': require('./mkdir'),
|
||||
'wget': require('./wget'),
|
||||
'export_file': require('./export_file'),
|
||||
'import_file': require('./import_file'),
|
||||
|
||||
// alias l='ls -l'
|
||||
'l': (a,t) => {require('./ls')([...a, '-l'], t)},
|
||||
|
|
|
@ -107,8 +107,9 @@ function reset_cmd() {
|
|||
}
|
||||
|
||||
function cbackspace() {
|
||||
let exploded = cmd.split(' ');
|
||||
if (exploded.length >= 1) {
|
||||
let exploded = cmd.substring(0, cmd.length - 2).split(' ');
|
||||
|
||||
if (exploded.length == 1) {
|
||||
reprint_prompt();
|
||||
cmd = '';
|
||||
return;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
const handler = require('express-async-handler');
|
||||
const Helpers = require('../helpers');
|
||||
|
||||
async function project(req, res) {
|
||||
res.template(
|
||||
|
|
|
@ -1,53 +1,3 @@
|
|||
const crypto = require('crypto');
|
||||
const path = require('path');
|
||||
const args = require('args-parser')(process.argv);
|
||||
const fs = require('fs');
|
||||
const base64 = require('js-base64');
|
||||
const { exec } = require('child_process');
|
||||
|
||||
let key = crypto.randomFillSync(Buffer.alloc(32)).toString('base64');
|
||||
let dotenv = path.resolve('.env');
|
||||
|
||||
if (args['help']) {
|
||||
console.log(path.basename(__filename) + ' [--key-only] [--env|-e] [--set-key] [--dry-run] [--stdout|-s]');
|
||||
console.log('\n' +
|
||||
' --help: Display this help\n' +
|
||||
' --key-only: Generate key only and put it in stdout\n' +
|
||||
' --env -e: Specify an env file\n' +
|
||||
' --set-key: Specify your key\n' +
|
||||
' --dry-run: Don\'t write anything, just do the thing\n' +
|
||||
' --stdout -s: Don\'t write to file, write to stdout instead'
|
||||
);
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
if (args['key-only']) {
|
||||
console.log(key);
|
||||
process.exit(0);
|
||||
}
|
||||
if (args['env'] || args['e']) {
|
||||
dotenv = args['env'] ? args['env'] : args['e'];
|
||||
}
|
||||
if (args['set-key']) {
|
||||
key = args['set-key'];
|
||||
}
|
||||
|
||||
const file = fs.readFileSync(dotenv).toString('utf8');
|
||||
|
||||
let lines = file.split('\n');
|
||||
|
||||
for (let i = 0; i != lines.length; i++) {
|
||||
let line = lines[i];
|
||||
if (line.startsWith('APP_KEY=')) {
|
||||
lines[i] = 'APP_KEY=' + key;
|
||||
}
|
||||
}
|
||||
|
||||
const newfile = lines.join('\n');
|
||||
|
||||
const w_stdout = args['stdout'] || args['s'];
|
||||
|
||||
if (!args['dry-run']) {
|
||||
if (w_stdout) console.log(newfile);
|
||||
else
|
||||
fs.writeFileSync(dotenv, newfile);
|
||||
}
|
||||
exec('generate_key.py');
|
|
@ -0,0 +1,24 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import secrets
|
||||
import base64
|
||||
|
||||
if (not os.path.exists('.env')):
|
||||
print('No .env file found. Please create a dotenv to proceed.');
|
||||
exit(-1);
|
||||
|
||||
key_bytes = secrets.token_bytes(32);
|
||||
dotenv_text = '';
|
||||
|
||||
with open('.env', 'tr', encoding='utf-8') as f:
|
||||
dotenv_text = f.read();
|
||||
|
||||
dotenv_lines = dotenv_text.split('\n');
|
||||
key_line = 0;
|
||||
|
||||
for i, line in enumerate(dotenv_lines):
|
||||
if (line.startswith('APP_KEY=')):
|
||||
dotenv_lines[i] = 'APP_KEY=' + base64.b64encode(key_bytes).decode('utf-8');
|
||||
|
||||
with open('.env', 'tw', encoding='utf-8') as f: print('\n'.join(dotenv_lines), file=f)
|
Loading…
Reference in New Issue