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
29 lines (22 loc) • 682 B
text/typescript
import path from 'path';
import fs from 'fs';
import * as TPS from '@tps/utilities/constants';
import { isDir } from '@tps/utilities/fileSystem';
import { CommandModule } from 'yargs';
interface NewPackageArgv {
template: string;
package: string;
}
export default {
command: 'package <template> <package>',
description: 'create a new package in a template',
builder: {},
handler(argv) {
const dest = path.join(process.cwd(), TPS.TPS_FOLDER, argv.template);
if (!isDir(dest)) {
throw new Error('TPS template was not found.');
}
const newPackageDir = path.join(dest, argv.package);
fs.mkdirSync(newPackageDir);
},
} as CommandModule<object, NewPackageArgv>;