Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[DDW-697] Adds scripts file to themes for command line use
  • Loading branch information
MarcusHurney committed Jul 12, 2019
1 parent 134fd00 commit b547cde
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
5 changes: 5 additions & 0 deletions source/renderer/app/themes/scripts/check.js
@@ -0,0 +1,5 @@
// @flow
import { checkCreateTheme } from '../utils/checkCreateTheme';
import { CREATE_THEME_OBJ } from '../utils/constants';

checkCreateTheme(CREATE_THEME_OBJ);
55 changes: 55 additions & 0 deletions source/renderer/app/themes/scripts/update.js
@@ -0,0 +1,55 @@
// @flow
import chalk from 'chalk';
import { findUpdates, updateThemes } from '../utils/updateThemes';
import { CREATE_THEME_OBJ } from '../utils/constants';

const logInputOption = (option: string) => chalk.magenta.italic(`'${option}'`);
const YES_OR_NO = `${logInputOption('yes')} / ${logInputOption('no')}`;

const readline = require('readline');

const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
prompt: chalk.cyan(
`\nWould you like to write these updates to the theme files? ( ${YES_OR_NO} )\n`
),
});

const pendingUpdates = findUpdates(CREATE_THEME_OBJ); // Todo: Enter correct params
if (pendingUpdates !== null) {
rl.prompt();
rl.on('line', line => {
switch (line.trim()) {
case 'yes' || 'y':
chalk`\n{bold Upating themes...}\n`;
const updatedThemes = updateThemes(pendingUpdates);
for (const updatedTheme of Object.entries(updatedThemes)) {
const [file, themeObj] = updatedTheme;
// call fs module to write updates
//write the themeObj to the file using the fs module
}
chalk
.hex('#2cbb69')
.bold(
`\nThemes updated! Please check the result and commit the updates if neccessary.\n`
);
break;
case 'no' || 'n':
chalk.cyan('Exiting... See you later!');
process.exit(0);
break;
default:
chalk.cyan(
`Umm... Enter ( ${YES_OR_NO} ) to continue, or ${logInputOption(
'ctrl + c'
)} to exit.`
);
break;
}
rl.prompt();
}).on('close', () => {
chalk.cyan('Exiting... See you later!');
process.exit(0);
});
}

0 comments on commit b547cde

Please sign in to comment.