@soleil-se/run
Version:
Run various utility scripts for creating apps, configs or migration tasks.
42 lines (36 loc) • 1.16 kB
JavaScript
import minimist from 'minimist';
import prompts from 'prompts';
const { _: [script] } = minimist(process.argv.slice(2), {});
const questions = [
{
type: 'select',
name: 'script',
message: 'Script to run?',
choices: [
{ title: 'Create app', value: 'create-app' },
{ title: 'Create build config', value: 'create-build-config' },
{ title: 'Migrate NPM', value: 'migrate-npm' },
{ title: 'Migrate Svelte 5', value: 'migrate-svelte-5' },
{ title: 'Check installed app versions', value: 'install-check' },
{ title: 'Setup or upgrade ESLint and Prettier', value: 'eslint' },
{ title: 'Setup or upgrade Stylelint', value: 'stylelint' },
],
},
];
function onCancel() {
process.exit(0);
}
(async () => {
const response = script ? { script } : await prompts(questions, { onCancel });
try {
const { default: main } = await import(`./scripts/${response.script}.js`);
main();
} catch (error) {
if (error.code === 'ERR_MODULE_NOT_FOUND') {
console.error(`Script "${response.script}" not found.`);
} else {
console.error(error);
}
process.exit(1);
}
})();