UNPKG

2.82 kBMarkdownView Raw
1# midway-bin
2
3[![Package Quality](http://npm.packagequality.com/shield/midway-bin.svg)](http://packagequality.com/#?package=midway-bin)
4[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/midwayjs/midway/pulls)
5
6this is a sub package for midway.
7
8midway developer tool, extends [egg-bin].
9
10---
11
12## Install
13
14```bash
15$ npm i midway-bin --save-dev
16```
17
18## Usage
19
20Add `midway-bin` to `package.json` scripts like [egg-bin], but just replace command by `midway-bin:
21
22```json
23{
24 "scripts": {
25 "dev": "midway-bin dev",
26 "debug": "midway-bin debug",
27 "test-local": "midway-bin test",
28 "test": "npm run lint -- --fix && npm run midway-local",
29 "cov": "midway-bin cov",
30 "lint": "eslint .",
31 "pkgfiles": "midway-bin pkgfiles",
32 "autod": "midway-bin autod",
33 "ci": "npm run lint && npm run autod -- --check && npm run pkgfiles -- --check && npm run cov"
34 }
35}
36```
37
38## Command
39
40`midway-bin` add new command
41
42- build
43- clean
44- doc
45
46### build
47
48build typescript source file to dist directory like `tsc` and copy js/css/html file to same place.
49
50```bash
51$ midway-bin build
52```
53
54#### options
55
56- `--clean -c` clean dist directory before build
57- `--entrypoint <entrypoint-file>` bundle the output with the specified file as entrypoint
58
59#### copy static file
60
61we can copy static file when ts file compiling.
62
63```js
64// in package.json
65 "midway-bin-build": {
66 "include": [
67 "app/public",
68 "app/view"
69 ]
70 }
71```
72
73it will be copy `src/app/public` to `${outDir}/app/public`.
74
75The `outDir` field is configured in the `tsconfig.json` File, see [compiler-options](https://www.typescriptlang.org/docs/handbook/compiler-options.html).
76
77### clean
78
79clean a dist directory by build
80
81```bash
82$ midway-bin clean
83```
84
85### doc
86
87generate application document by typedoc
88
89```bash
90$ midway-bin doc
91```
92
93#### options
94
95like typedoc, see [link](https://typedoc.org/guides/arguments/)
96
97- `--options [typedoc.js]` Specify a js option file that should be loaded.
98- `--out -o [outPath]` Specifies the location the documentation should be written to.
99- `--mode -m` default value is `file`, Specifies the output mode the project is used to be compiled with.
100- `--exclude` Exclude files by the given pattern when a path is provided as source.
101- `--theme` default value is `default` Specify the path to the theme that should be used.
102- `--excludeExternals` default value is `true` Prevent externally resolved TypeScript files from being documented.
103- `--ignoreCompilerErrors` default value is `true` Generates documentation, even if the project does not TypeScript compile.
104- `--hideGenerator` default value is `true` Do not print the TypeDoc link at the end of the page.
105
106> Tips: If the options parameter is supplied, the other default parameters are invalid
107
108## License
109
110[MIT](LICENSE)