Compare commits

..

No commits in common. "a335d5c14f0b61fa020619fcbe565562736c181e" and "a9cf2a1d210444bc37988b02b4a0dfbf0db9a4b9" have entirely different histories.

10 changed files with 57 additions and 85 deletions

View File

@ -30,4 +30,5 @@ cd to `react/resume` and run `build.sh`.
If you are running in debug mode, run `yarn/npm start` If you are running in debug mode, run `yarn/npm start`
## Generate the key ## Generate the key
Cd to root of project and run `scripts/generate_key.py` Install node modules in following directories: `.`, `./scripts`
Then, cd to root and run `node scripts/generate_key.js`

7
dev.sh
View File

@ -1,12 +1,5 @@
#!/bin/bash #!/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 docker-compose.dev docker-compose.yml
cp Dockerfile.dev Dockerfile cp Dockerfile.dev Dockerfile

View File

@ -26,8 +26,7 @@ config = {
host: DB_HOSTNAME || config.host, host: DB_HOSTNAME || config.host,
define: { define: {
timestamps: false timestamps: false
}, }
logging: false
}; };
/** @type Sequelize */ /** @type Sequelize */

View File

@ -1,12 +1,5 @@
#!/bin/bash #!/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 docker-compose.prod docker-compose.yml
cp Dockerfile.prod Dockerfile cp Dockerfile.prod Dockerfile

View File

@ -1,37 +0,0 @@
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
}

View File

@ -8,7 +8,6 @@ let cmds = {
'mkdir': require('./mkdir'), 'mkdir': require('./mkdir'),
'wget': require('./wget'), 'wget': require('./wget'),
'export_file': require('./export_file'), 'export_file': require('./export_file'),
'import_file': require('./import_file'),
// alias l='ls -l' // alias l='ls -l'
'l': (a,t) => {require('./ls')([...a, '-l'], t)}, 'l': (a,t) => {require('./ls')([...a, '-l'], t)},

View File

@ -107,9 +107,8 @@ function reset_cmd() {
} }
function cbackspace() { function cbackspace() {
let exploded = cmd.substring(0, cmd.length - 2).split(' '); let exploded = cmd.split(' ');
if (exploded.length >= 1) {
if (exploded.length == 1) {
reprint_prompt(); reprint_prompt();
cmd = ''; cmd = '';
return; return;

View File

@ -1,5 +1,4 @@
const handler = require('express-async-handler'); const handler = require('express-async-handler');
const Helpers = require('../helpers');
async function project(req, res) { async function project(req, res) {
res.template( res.template(

View File

@ -1,3 +1,53 @@
const { exec } = require('child_process'); const crypto = require('crypto');
const path = require('path');
const args = require('args-parser')(process.argv);
const fs = require('fs');
const base64 = require('js-base64');
exec('generate_key.py'); 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);
}

View File

@ -1,24 +0,0 @@
#!/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)