0.2.1 • Published 3 years ago
new-structure v0.2.1
new-structure
CLI for creating new react file structure (component or hook).
Installation
only use in your workspace:
# npm
npm i new-structure -g
# yarn
yarn global add new-structure
# pnpm
pnpm add new-structure -gtested in node 14+.
Usage
in your project's directory, try creating a new component.
new-structure NewComponentor hook
new-structure useMyHook -t hookThe default language is TypeScript. If your project is a JavaScript project, please try adding the -l or --lang option.
new-structure NewComponent -l jsif you want to add a configuration file to the current project directory, please use:
new-structure initconfiguration file like this:
const config = {
// Which language to use ('ts' or 'js')
lang: 'ts',
// structure type ('comp' or 'hook')
type: 'comp',
// components directory path
componentDir: './src/components',
// hooks directory path
hookDir: './src/hooks'
}
module.exports = configUsing a shorter alias
new-structure might be hard to type, so you may use a shorter alias like ns instead.
Adding a permanent alias on POSIX systems
Just put the following line to your .bashrc, .zshrc, or config.fish:
alias ns=new-structureAdding a permanent alias in Powershell (Windows):
In a Powershell window with admin rights, execute:
notepad $profile.AllUsersAllHostsIn the profile.ps1 file that opens, put:
set-alias -name ns -value new-structure