this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

refactor project structure

+122 -91
+2 -2
source/cli.js
··· 2 2 3 3 import {program} from 'commander'; 4 4 import packageJson from '../package.json' with {type: 'json'}; 5 - import {config, update} from './commands/index.js'; 5 + import * as commands from './cli/commands/index.js'; 6 6 7 7 program 8 8 .name(packageJson.name) 9 9 .description(packageJson.description) 10 10 .version(packageJson.version); 11 11 12 - program.addCommand(config).addCommand(update); 12 + program.addCommand(commands.config).addCommand(commands.update); 13 13 14 14 await program.parseAsync();
+3
source/cli/actions/config/index.js
··· 1 + export {default as show} from './show.js'; 2 + export {default as set} from './set.js'; 3 + export {default as setMode} from './set-mode.js';
+19
source/cli/actions/config/set-mode.js
··· 1 + import {consola} from 'consola'; 2 + import {setTerminalProfile} from 'mac-terminal'; 3 + import {getConfig, getCurrentMode} from '../../../library/index.js'; 4 + 5 + /** 6 + * @param {{mode: 'dark' | 'light', profile: string}} parameters 7 + * @returns {Promise<void>} 8 + */ 9 + export default async function setMode({mode, profile}) { 10 + const config = await getConfig(); 11 + 12 + config.set(`profiles.${mode}`, profile); 13 + 14 + consola.success('Saved configuration'); 15 + 16 + if (mode === (await getCurrentMode())) { 17 + await setTerminalProfile({profile, setDefault: true}); 18 + } 19 + }
+21
source/cli/actions/config/show.js
··· 1 + import {styleText} from 'node:util'; 2 + import {upperFirst} from 'es-toolkit/string'; 3 + import {getConfig, modes} from '../../../library/index.js'; 4 + 5 + /** 6 + * @returns {Promise<void>} 7 + */ 8 + export default async function show() { 9 + const config = await getConfig(); 10 + 11 + for (const mode of modes) { 12 + const icon = 13 + mode === 'dark' 14 + ? '\u{263D}' // Moon 15 + : '\u{2600}'; // Sun 16 + 17 + console.log( 18 + `${styleText('yellow', icon)} ${upperFirst(mode)} mode profile: ${config.get(`profiles.${mode}`)}`, 19 + ); 20 + } 21 + }
+2
source/cli/actions/index.js
··· 1 + export {default as update} from './update.js'; 2 + export * as config from './config/index.js';
+15
source/cli/actions/update.js
··· 1 + import {setTerminalProfile} from 'mac-terminal'; 2 + import {getConfig, getCurrentMode} from '../../library/index.js'; 3 + 4 + /** 5 + * @param {{mode?: 'dark' | 'light'}} parameters 6 + * @returns {Promise<void>} 7 + */ 8 + export default async function update({mode}) { 9 + mode ??= await getCurrentMode(); 10 + 11 + const config = await getConfig(); 12 + const profile = config.get(`profiles.${mode}`); 13 + 14 + await setTerminalProfile({profile, setDefault: true}); 15 + }
+19
source/cli/commands/config/set-mode.js
··· 1 + import {Argument, Command} from '@commander-js/extra-typings'; 2 + import {getTerminalProfiles} from 'mac-terminal'; 3 + import * as actions from '../../actions/index.js'; 4 + 5 + /** 6 + * Make set mode command 7 + * 8 + * @param {'dark' | 'light'} mode 9 + */ 10 + export default async function setMode(mode) { 11 + return new Command(mode) 12 + .description(`set terminal profile for ${mode}`) 13 + .addArgument( 14 + new Argument('<profile>', 'terminal profile name').choices( 15 + await getTerminalProfiles(), 16 + ), 17 + ) 18 + .action(async (profile) => actions.config.setMode({mode, profile})); 19 + }
+14
source/cli/commands/config/set.js
··· 1 + import {Command} from '@commander-js/extra-typings'; 2 + import {modes} from '../../../library/index.js'; 3 + import * as actions from '../../actions/index.js'; 4 + import setMode from './set-mode.js'; 5 + 6 + const command = new Command('set').description('update configuration'); 7 + 8 + for (const mode of modes) { 9 + command.addCommand(await setMode(mode)); 10 + } 11 + 12 + command.action(actions.config.set); 13 + 14 + export default command;
+6
source/cli/commands/config/show.js
··· 1 + import {Command} from 'commander'; 2 + import * as actions from '../../actions/index.js'; 3 + 4 + export default new Command('show') 5 + .description('show configuration') 6 + .action(actions.config.show);
+13
source/cli/commands/update.js
··· 1 + import {Argument, Command} from '@commander-js/extra-typings'; 2 + import {modes} from '../../library/index.js'; 3 + import * as actions from '../actions/index.js'; 4 + 5 + export default new Command('update') 6 + .description('update terminal profile based on the mode') 7 + .addArgument( 8 + new Argument( 9 + '[mode]', 10 + 'appearance mode. defaults to current system appearance mode.', 11 + ).choices(modes), 12 + ) 13 + .action(async (mode) => actions.update({mode}));
-2
source/commands/config/commands/index.js
··· 1 - export {default as show} from './show.js'; 2 - export {default as set} from './set/index.js';
-1
source/commands/config/commands/set/commands/index.js
··· 1 - export {default as setMode} from './set-mode.js';
-30
source/commands/config/commands/set/commands/set-mode.js
··· 1 - import {Argument, Command} from '@commander-js/extra-typings'; 2 - import {consola} from 'consola'; 3 - import {getTerminalProfiles, setTerminalProfile} from 'mac-terminal'; 4 - import {getConfig, getCurrentMode} from '../../../../../library/index.js'; 5 - 6 - /** 7 - * Make set mode command 8 - * 9 - * @param {'dark' | 'light'} mode 10 - */ 11 - export default async function setMode(mode) { 12 - return new Command(mode) 13 - .description(`set terminal profile for ${mode}`) 14 - .addArgument( 15 - new Argument('<profile>', 'terminal profile name').choices( 16 - await getTerminalProfiles(), 17 - ), 18 - ) 19 - .action(async (profile) => { 20 - const config = await getConfig(); 21 - 22 - config.set(`profiles.${mode}`, profile); 23 - 24 - consola.success('Saved configuration'); 25 - 26 - if (mode === (await getCurrentMode())) { 27 - await setTerminalProfile({profile, setDefault: true}); 28 - } 29 - }); 30 - }
-1
source/commands/config/commands/set/index.js
··· 1 - export {default} from './set.js';
+6 -13
source/commands/config/commands/set/set.js source/cli/actions/config/set.js
··· 1 - import {Command} from '@commander-js/extra-typings'; 2 1 import {consola} from 'consola'; 3 2 import {getTerminalProfiles, setTerminalProfile} from 'mac-terminal'; 4 - import {getConfig, getCurrentMode, modes} from '../../../../library/index.js'; 5 - import {setMode as setModeCommand} from './commands/index.js'; 3 + import {getConfig, getCurrentMode, modes} from '../../../library/index.js'; 6 4 7 - const command = new Command('set').description('update configuration'); 8 - 9 - for (const mode of modes) { 10 - command.addCommand(await setModeCommand(mode)); 11 - } 12 - 13 - command.action(async () => { 5 + /** 6 + * @returns {Promise<void>} 7 + */ 8 + export default async function set() { 14 9 const config = await getConfig(); 15 10 const profiles = await getTerminalProfiles(); 16 11 const newProfiles = {}; ··· 42 37 profile: newProfiles[currentMode], 43 38 setDefault: true, 44 39 }); 45 - }); 46 - 47 - export default command; 40 + }
-21
source/commands/config/commands/show.js
··· 1 - import {styleText} from 'node:util'; 2 - import {Command} from 'commander'; 3 - import {upperFirst} from 'es-toolkit/string'; 4 - import {getConfig, modes} from '../../../library/index.js'; 5 - 6 - export default new Command('show') 7 - .description('show configuration') 8 - .action(async () => { 9 - const config = await getConfig(); 10 - 11 - for (const mode of modes) { 12 - const icon = 13 - mode === 'dark' 14 - ? '\u{263D}' // Moon 15 - : '\u{2600}'; // Sun 16 - 17 - console.log( 18 - `${styleText('yellow', icon)} ${upperFirst(mode)} mode profile: ${config.get(`profiles.${mode}`)}`, 19 - ); 20 - } 21 - });
+2 -1
source/commands/config/config.js source/cli/commands/config/config.js
··· 1 1 import {Command} from 'commander'; 2 - import {show, set} from './commands/index.js'; 2 + import show from './show.js'; 3 + import set from './set.js'; 3 4 4 5 export default new Command('config') 5 6 .description('manage configuration')
source/commands/config/index.js source/cli/commands/config/index.js
source/commands/index.js source/cli/commands/index.js
-20
source/commands/update.js
··· 1 - import {Argument, Command} from '@commander-js/extra-typings'; 2 - import {setTerminalProfile} from 'mac-terminal'; 3 - import {getConfig, getCurrentMode, modes} from '../library/index.js'; 4 - 5 - export default new Command('update') 6 - .description('update terminal profile based on the mode') 7 - .addArgument( 8 - new Argument( 9 - '[mode]', 10 - 'appearance mode. defaults to current system appearance mode.', 11 - ).choices(modes), 12 - ) 13 - .action(async (mode) => { 14 - mode ??= await getCurrentMode(); 15 - 16 - const config = await getConfig(); 17 - const profile = config.get(`profiles.${mode}`); 18 - 19 - await setTerminalProfile({profile, setDefault: true}); 20 - });