templates-mo
Version:
Templates is a scaffolding framework that makes code generation simple, dynamic, and reusable. Generate files, parts of your app, or whole project structures—without the repetitive copy-pasting
41 lines (36 loc) • 1.01 kB
JavaScript
// @ts-check
const { packageManagers, runCommand } = require('../../lib/tools');
/** @type {import('../../lib/types/settings').SettingsFile} */
module.exports = {
prompts: [
{
name: 'packageManager',
aliases: ['pm'],
description: 'Type of package you want to use for package installation',
message: 'What type of package manager would you like to use?',
tpsType: 'data',
type: 'list',
choices: ['npm', 'yarn'],
default: 'npm',
},
{
name: 'typescript',
description: 'Generate typescript files',
aliases: ['t'],
type: 'confirm',
tpsType: 'package',
message: 'Would you like to use typescript?',
default: false,
},
],
events: {
async onRendered(tps, { dest, buildPaths }) {
const answers = tps.getAnswers();
const pm = packageManagers[answers.packageManager];
buildPaths.forEach((path) => {
// TODO: if someone runs with multiple build paths it will display two "Running npm install"
runCommand(pm, dest, [path], tps);
});
},
},
};