-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Criação da função capitalize para deixar a primeira letra do parametr…
…o maiuscula e criacao do comando create:page
- Loading branch information
1 parent
c1fcd33
commit 0a5831b
Showing
5 changed files
with
56 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,12 @@ | ||
# zionix CLI | ||
|
||
A CLI for zionix. | ||
|
||
## Customizing your CLI | ||
|
||
Check out the documentation at https://github.com/infinitered/gluegun/tree/master/docs. | ||
|
||
## Publishing to NPM | ||
|
||
To package your CLI up for NPM, do this: | ||
Esta CLI foi criada com o objetivo de facilitar as tarefas repetitivas do dia a a dia durante os processos de desenvolvimento com React | ||
|
||
```shell | ||
$ npm login | ||
$ npm whoami | ||
$ npm lint | ||
$ npm test | ||
(if typescript, run `npm run build` here) | ||
$ npm publish | ||
$ zionix create:component {NAME} (Cria um componente padrão React) | ||
$ zionix create:page {NAME} (Cria uma página padrão React) | ||
``` | ||
|
||
# License | ||
|
||
MIT - see LICENSE | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
const capitalize = require('../utils/capitalize') | ||
|
||
module.exports = { | ||
name: 'create:page', | ||
alias: ['page'], | ||
description: 'Cria uma págnina padrão React', | ||
run: async toolbox => { | ||
const { parameters, template, filesystem, print: { success, error } } = toolbox | ||
const name = capitalize(parameters.first) | ||
|
||
if (!parameters.first) { | ||
error('O nome do componente não foi especificado') | ||
return | ||
} | ||
|
||
const package = await filesystem.read('package.json', 'json') | ||
const isReactNative = !!package.dependencies['react-native'] | ||
const isTypescript = !!package.dependencies['typescript'] | ||
|
||
const styleTemplate = isReactNative ? 'styles-rn.js.ejs' : 'styles-react.js.ejs' | ||
|
||
await template.generate({ | ||
template: 'component.js.ejs', | ||
target: `src/pages/${name}/index.${isTypescript ? 'tsx' : 'js'}`, | ||
props: { name } | ||
}) | ||
|
||
await template.generate({ | ||
template: styleTemplate, | ||
target: `src/pages/${name}/styles.${isTypescript ? 'tsx' : 'js'}` | ||
}) | ||
|
||
toolbox.print.success(`src/pages/${name} gerado com sucesso!`) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const capitalize = str => { | ||
if (typeof str === 'string') { | ||
return str.replace(/^\w/, c => c.toUpperCase()) | ||
} else { | ||
return '' | ||
} | ||
} | ||
|
||
module.exports = capitalize |