typolar-cli v0.5.1
typolar-cli
CLI for Typolar projects
Install
npm i -g typolar-cliUsage
typolar -hOutput:
Usage: typolar [options] [command]
Options:
-V, --version output the version number
-w, --wrokdir <dir> change work directory
--rc <filepath> set typolarrc filepath
-v, --verbose enable verbose output
-h, --help output usage information
Commands:
new [options] <name> create a new app
show [options] show app info
make:model <name> generate a model file
make:route <name> generate a route file
make:service <name> generate a service file
make:test [options] <name> generate a test file
make:graph <name> generate a graphql type file
make:resolver <name> generate a graphql resolver fileCreate a typolar project:
Usage: typolar new [options] <name>
create a new app
Options:
--registry <taobao|url> set project level npm registry
--no-tslint no tslint integration
--no-prettier no prettier integration
--eslint add eslint integration
--graphql add graphql integration
--docs add documentation generator
--vscode add vscode integration
--conv <camel|pascal|kebab> file name convention (default: "kebab")
--no-install skip npm install
--no-update skip npm update
--no-hide do not hide config files in vscode
--no-init skip git init
--no-hook do not add git hook
--no-commit skip auto initial commit
--clean no example code
-h, --help output usage informatione.g.
typolar new myapp --docs --vscode --eslint --graphql --registry=taobao --cleanProject structure:
myapp/
├── .editorconfig
├── .env
├── .env.template
├── .eslintignore
├── .eslintrc.json
├── .gitattributes
├── .gitignore
├── .npmrc
├── .prettierignore
├── .prettierrc
├── .typolarrc
├── .vscode/
├── config/
│ ├── app.json
│ ├── graphql.json
│ └── logger.json
├── docs/
├── lib/
├── package.json
├── src/
│ ├── app.ts
│ ├── graphql/
│ │ ├── resolvers/
│ │ └── types/
│ ├── index.ts
│ ├── models/
│ ├── routes/
│ └── services/
├── tests/
│ └── tslint.json
├── tsconfig.json
├── tsconfig.prod.json
├── tslint.json
└── views/With example code:
myapp/
├── .editorconfig
├── .env
├── .env.template
├── .eslintignore
├── .eslintrc.json
├── .gitattributes
├── .gitignore
├── .npmrc
├── .prettierignore
├── .prettierrc
├── .typolarrc
├── .vscode/
├── config/
│ ├── app.json
│ ├── graphql.json
│ └── logger.json
├── lib/
│ ├── app.js
│ ├── app.js.map
│ ├── graphql/
│ │ ├── resolvers/
│ │ │ ├── comment.js
│ │ │ ├── comment.js.map
│ │ │ ├── post.js
│ │ │ ├── post.js.map
│ │ │ ├── query.js
│ │ │ ├── query.js.map
│ │ │ ├── user.js
│ │ │ └── user.js.map
│ │ └── types/
│ │ ├── comment.js
│ │ ├── comment.js.map
│ │ ├── post.js
│ │ ├── post.js.map
│ │ ├── query.js
│ │ ├── query.js.map
│ │ ├── schema.js
│ │ ├── schema.js.map
│ │ ├── user.js
│ │ └── user.js.map
│ ├── index.js
│ ├── index.js.map
│ ├── models/
│ │ ├── address.js
│ │ ├── address.js.map
│ │ ├── comment.js
│ │ ├── comment.js.map
│ │ ├── company.js
│ │ ├── company.js.map
│ │ ├── post.js
│ │ ├── post.js.map
│ │ ├── user.js
│ │ └── user.js.map
│ ├── routes/
│ │ ├── home.js
│ │ └── home.js.map
│ └── services/
│ ├── blog.js
│ └── blog.js.map
├── package-lock.json
├── package.json
├── src/
│ ├── app.ts
│ ├── graphql/
│ │ ├── resolvers/
│ │ │ ├── comment.ts
│ │ │ ├── post.ts
│ │ │ ├── query.ts
│ │ │ └── user.ts
│ │ └── types/
│ │ ├── comment.ts
│ │ ├── post.ts
│ │ ├── query.ts
│ │ ├── schema.ts
│ │ └── user.ts
│ ├── index.ts
│ ├── models/
│ │ ├── address.ts
│ │ ├── comment.ts
│ │ ├── company.ts
│ │ ├── post.ts
│ │ └── user.ts
│ ├── routes/
│ │ └── home.ts
│ └── services/
│ └── blog.ts
├── tests/
│ ├── home.spec.ts
│ └── tslint.json
├── tsconfig.json
├── tsconfig.prod.json
├── tslint.json
└── views/
└── home.ejsMinimal structure(no tslint/eslint/prettier/vscode/docs/graphql)
typolar new myapp --no-tslint --no-prettier --no-init --no-install --cleanmyapp/
├── .editorconfig
├── .env
├── .env.template
├── .gitattributes
├── .gitignore
├── .typolarrc
├── config/
│ ├── app.json
│ └── logger.json
├── lib/
├── package.json
├── src/
│ ├── app.ts
│ ├── index.ts
│ ├── models/
│ ├── routes/
│ └── services/
├── tests/
├── tsconfig.json
├── tsconfig.prod.json
└── views/NPM Commands
Start app in dev mode
npm run devStart app in dev mode and watch source files change for restarting
npm run watchStart app in dev mode and watch source files change for restarting
npm run watchRun tests
npm testBuild sources
npm run buildStart app in production mode(requires a successful build)
npm startOptional:
Build docs(requires --docs option set)
npm run docsFormat all soruce files(requires --no-prettier omitted)
npm run formatLint all soruce files(requires --no-tslint omitted)
npm run lintGit hooks
By default a pre-commit git hook is installed. It will lint your staged files before commit. To disable it, pass --no-hook option
If you set
--no-initwhich tells the cli to skip git init for your project, hooks will also be skipped. Same for--no-tslintwhich skips tslint integration
VSCode
Requires --vscode option set
By default, a couple of files are pre-configured to be excluded from vscode's explorer view to make your workspace neat. Set
--no-hideoption if you think it unneccessary
Debug
Three launch configs:
- Launch Program (run in test mode)
- Watch Debug (run in test mode and watch source files change)
- Mocha Tests (debug test cases)
Extensions
Open extensions panel, type in @recommended, see Workspace Recommendations
All extensions are pre-configured in your workspace
Highly recommended
Recommended
Tasks
- run:dev
- run:watch
- build:lib (default build task)
- build:docs
- test:all (default test task)
- test:current
- lint:all
- format:all
- format:dirty
- clean:docs
- clean:build
- view:docs
Config
All config files are in config folder(in your project root directory). You can override almost all files with env vars.
e.g.
APP_PORT=8080 npm run devAlternatively you may set envs in the .env file(in your project root directory). Available vars are listed in .env.template
[global]
# ENV_FILE
# CONFIG_FILE
[app]
# APP_HOST
# APP_PORT
[app.router]
# APP_ROUTER_STYLE
# APP_ROUTER_BASEURL
# APP_ROUTER_MOCK
# APP_ROUTER_PATH
[app.service]
# APP_SERVICE_BASEURL
# APP_SERVICE_REVIVER
# APP_SERVICE_REPLACER
[app.view]
# APP_VIEW_ENGINE
# APP_VIEW_PATH
[logger]
# LOG_HTTP_STYLE
# LOG_APPENDERS
# LOG_LEVEL
# LOG_STACK_PRETTY
[graphql]
# GRAPHQL_UIYou can extend existing configs or add new configs. See kuconfig
Framework
See typolar
License
See License