|
| 1 | +import { GluegunCommand, GluegunToolbox, strings } from 'gluegun'; |
| 2 | + |
| 3 | +import { |
| 4 | + getComponentName, getComponentPath, printCreated |
| 5 | +} from '../../../../utils/functions.helper'; |
| 6 | + |
| 7 | +const COMMAND: GluegunCommand = { |
| 8 | + name: 'common', |
| 9 | + alias: ['c'], |
| 10 | + description: 'cria um componente Angular de tipo Common', |
| 11 | + run: async (toolbox: GluegunToolbox) => { |
| 12 | + const { parameters, print, prompt, template } = toolbox; |
| 13 | + const { |
| 14 | + options: { path } |
| 15 | + } = parameters; |
| 16 | + |
| 17 | + const componentName = parameters.first ?? (await getComponentName(prompt)); |
| 18 | + const componentPath = getComponentPath(path, componentName); |
| 19 | + |
| 20 | + template.generate({ |
| 21 | + template: 'component.template.html.ejs', |
| 22 | + target: `${componentPath}.component.html`, |
| 23 | + props: { name: componentName, ...strings } |
| 24 | + }); |
| 25 | + |
| 26 | + template.generate({ |
| 27 | + template: 'component.template.scss.ejs', |
| 28 | + target: `${componentPath}.component.scss` |
| 29 | + }); |
| 30 | + |
| 31 | + template.generate({ |
| 32 | + template: 'component.template.ts.ejs', |
| 33 | + target: `${componentPath}.component.ts`, |
| 34 | + props: { |
| 35 | + type: 'component', |
| 36 | + name: componentName, |
| 37 | + ...strings |
| 38 | + } |
| 39 | + }); |
| 40 | + |
| 41 | + printCreated(print, `${componentPath}.component.html`); |
| 42 | + printCreated(print, `${componentPath}.component.scss`); |
| 43 | + printCreated(print, `${componentPath}.component.ts`); |
| 44 | + } |
| 45 | +}; |
| 46 | + |
| 47 | +module.exports = COMMAND; |
0 commit comments