Skip to content
This repository was archived by the owner on Oct 23, 2024. It is now read-only.

Fix linting problems in portal code #947

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
134 changes: 67 additions & 67 deletions scripts/release/initauth.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const fs = require('fs');
const cipher = require('./cipher');
const authStore = path.resolve(__dirname, cipher.astore);
const authBase = path.basename(path.dirname(authStore));
const { Writable } = require('stream');
const {Writable} = require('stream');

const mutableStdout = new Writable({
write(chunk, encoding, callback) {
Expand Down Expand Up @@ -61,65 +61,65 @@ const saveAuth = (obj, filename) => new Promise((resolve, reject) => {

const updateRabbit = () => new Promise((resolve, reject) => {
question('Update RabbitMQ account?[yes/no]')
.then((answer) => {
answer = answer.toLowerCase();
if (answer !== 'y' && answer !== 'yes') {
resolve();
return;
}
question(`(${authBase}) Enter username of rabbitmq: `)
.then((username) => {
question(`(${authBase}) Enter password of rabbitmq: `)
.then((password) => {
mutableStdout.muted = false;
saveAuth({ rabbit: { username, password } }, authStore)
.then(resolve)
.catch(reject);
.then((answer) => {
answer = answer.toLowerCase();
if (answer !== 'y' && answer !== 'yes') {
resolve();
return;
}
question(`(${authBase}) Enter username of rabbitmq: `)
.then((username) => {
question(`(${authBase}) Enter password of rabbitmq: `)
.then((password) => {
mutableStdout.muted = false;
saveAuth({rabbit: {username, password}}, authStore)
.then(resolve)
.catch(reject);
});
mutableStdout.muted = true;
});
mutableStdout.muted = true;
});
});
});
});

const updateMongo = () => new Promise((resolve, reject) => {
question('Update MongoDB account?[yes/no]')
.then((answer) => {
answer = answer.toLowerCase();
if (answer !== 'y' && answer !== 'yes') {
resolve();
return;
}
question(`(${authBase}) Enter username of mongodb: `)
.then((username) => {
question(`(${authBase}) Enter password of mongodb: `)
.then((password) => {
mutableStdout.muted = false;
saveAuth({ mongo: { username, password } }, authStore)
.then(resolve)
.catch(reject);
.then((answer) => {
answer = answer.toLowerCase();
if (answer !== 'y' && answer !== 'yes') {
resolve();
return;
}
question(`(${authBase}) Enter username of mongodb: `)
.then((username) => {
question(`(${authBase}) Enter password of mongodb: `)
.then((password) => {
mutableStdout.muted = false;
saveAuth({mongo: {username, password}}, authStore)
.then(resolve)
.catch(reject);
});
mutableStdout.muted = true;
});
mutableStdout.muted = true;
});
});
});
});

const updateInternal = () => new Promise((resolve, reject) => {
question('Update internal passphrase?[yes/no]')
.then((answer) => {
answer = answer.toLowerCase();
if (answer !== 'y' && answer !== 'yes') {
resolve();
return;
}
question(`(${authBase}) Enter internal passphrase: `)
.then((passphrase) => {
mutableStdout.muted = false;
saveAuth({ internalPass: passphrase }, authStore)
.then(resolve)
.catch(reject);
});
mutableStdout.muted = true;
});
.then((answer) => {
answer = answer.toLowerCase();
if (answer !== 'y' && answer !== 'yes') {
resolve();
return;
}
question(`(${authBase}) Enter internal passphrase: `)
.then((passphrase) => {
mutableStdout.muted = false;
saveAuth({internalPass: passphrase}, authStore)
.then(resolve)
.catch(reject);
});
mutableStdout.muted = true;
});
});

const options = {};
Expand All @@ -138,22 +138,22 @@ const parseArgs = () => {
options.mongo = true;
}
return Promise.resolve();
}
};

parseArgs()
.then(() => {
if (options.rabbit) {
return updateRabbit();
}
})
.then(() => {
if (options.mongo) {
return updateMongo();
}
})
.then(() => {
if (options.internal) {
return updateInternal();
}
})
.finally(() => readline.close());
.then(() => {
if (options.rabbit) {
return updateRabbit();
}
})
.then(() => {
if (options.mongo) {
return updateMongo();
}
})
.then(() => {
if (options.internal) {
return updateInternal();
}
})
.finally(() => readline.close());
17 changes: 9 additions & 8 deletions scripts/release/initcert.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@
// SPDX-License-Identifier: Apache-2.0
'use strict';

(function () {
var readline = require('readline').createInterface({
(function() {
const readline = require('readline').createInterface({
input: process.stdin,
output: process.stdout
output: process.stdout,
});
var cipher = require('./cipher');
var dirName = !process.pkg ? __dirname : require('path').dirname(process.execPath);
var keystore = require('path').resolve(dirName, 'cert/' + cipher.kstore);
readline.question('Enter passphrase of certificate: ', function (res) {
const cipher = require('./cipher');
const dirName =
!process.pkg ? __dirname : require('path').dirname(process.execPath);
const keystore = require('path').resolve(dirName, 'cert/' + cipher.kstore);
readline.question('Enter passphrase of certificate: ', function(res) {
readline.close();
cipher.lock(cipher.k, res, keystore, function cb (err) {
cipher.lock(cipher.k, res, keystore, function cb(err) {
console.log(err||'done!');
});
});
Expand Down
Loading