From b71cee2f55b943b643f5194e9a1208f9ce2211a8 Mon Sep 17 00:00:00 2001 From: Dominic Date: Mon, 18 May 2020 19:28:04 -0700 Subject: [PATCH] Rename pathSlashModel; remove path flag; update help messages You can still specify a path in the model, but we're no longer calling it pathSlashModel--the functionality will be revealed in the help message instead. We're also taking out the path flag here, so there's only one way to do it --- .../commands/generate/scaffold/scaffold.js | 37 +++++++++---------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/packages/cli/src/commands/generate/scaffold/scaffold.js b/packages/cli/src/commands/generate/scaffold/scaffold.js index 773b8253285c..95ef968fb7a9 100644 --- a/packages/cli/src/commands/generate/scaffold/scaffold.js +++ b/packages/cli/src/commands/generate/scaffold/scaffold.js @@ -313,28 +313,25 @@ const addScaffoldImport = () => { return 'Added scaffold import to index.js' } -export const command = 'scaffold ' -export const desc = 'Generate pages, SDL, and a services object.' -export const builder = { - force: { type: 'boolean', default: false }, - // So the user can specify a path to nest the generated files under. - // E.g. yarn rw g scaffold post --path=admin - path: { type: 'string', default: false }, +export const command = 'scaffold ' +export const desc = + 'Generate Pages, SDL, and Services files based on a given DB schema Model. Also accepts .' +export const builder = (yargs) => { + yargs.positional('model', { + description: + "Model to scaffold. You can also use to nest files by type at the given path directory (or directories). For example, 'rw g scaffold admin/post'.", + }) + yargs.option('force', { + default: false, + type: 'boolean', + }) } -// The user can also specify a path in the argument. -// E.g. yarn rw g scaffold admin/post -export const handler = async ({ pathSlashModel, force, path: pathFlag }) => { - let path - // If path is specified by both pathSlashModel and pathFlag, - // we give pathFlag precedence. - pathFlag - ? (path = pathFlag) - : (path = pathSlashModel.split('/').slice(0, -1).join('/')) - - // This code will work whether or not there's a path in pathSlashModel - // E.g. if pathSlashModel is just 'post', +export const handler = async ({ model: modelArg, force }) => { + let path = modelArg.split('/').slice(0, -1).join('/') + // This code will work whether or not there's a path in model + // E.g. if model is just 'post', // path.split('/') will return ['post']. - const model = pathSlashModel.split('/').pop() + const model = modelArg.split('/').pop() const tasks = new Listr( [