UNPKG

4.17 kBMarkdownView Raw
1![KnitCLI](knit_cli_header.png "Knit CLI")
2
3---
4
5## Install
6
7It is recommended that knit be installed as a local package using npm scripts but it can also work as a global package.
8
9#### Global
10
11```
12yarn global add @knit/knit
13```
14
15#### Local
16
17```
18yarn add @knit/knit
19```
20
21```
22// package.json
23{
24 ...
25 "scripts": {
26 ...
27 "knit": "knit"
28 }
29}
30```
31
32## Commands
33
34#### list [options] [modules...]
35
36This command will list out your modules with their dependency count and show whether you have missing packages you need to install:
37
38```
39yarn knit -- list
40```
41
42![List](list.png "List")
43
44You can pass in module names to limit the scope of the search:
45
46```
47yarn knit -- list @myscope/header-component
48```
49
50![ListModule](list_module.png "List Module")
51
52#### list -d, --dependencies
53
54Passing `--dependencies` will expand the dependencies into a list to show you a more detailed view of your modules:
55
56```
57yarn knit -- list --dependencies
58```
59
60![ListDep](list_dependencies.png "List Dependencies")
61
62#### list -u, --updated
63
64This command shows which modules have been updated since the last release. It considers modules that have updated dependencies to be updated themselves. For example if `page-component` depends on `@myscope/body-component` modifying `@myscope/body-component` will return:
65
66```
67yarn knit -- list --updated
68```
69
70![ListUp](list_updated.png "List Updated")
71
72#### validate
73
74This command is used to make sure the project configuration will work with `knit` and looks to make sure their are no missing or unused dependencies.
75
76```
77yarn knit -- validate
78```
79
80![Validate](validate.png "Validate")
81
82#### server
83
84```
85❯ yarn knit -- server
86Usage: server [options]
87
88start a dev server
89
90Options:
91
92 -h, --help output usage information
93 -p, --port <port> set server port
94 -h, --host <host> set server host
95 -r, --proxy <proxy> set proxy uri
96```
97
98#### relay
99
100```
101❯ yarn knit -- relay
102Usage: relay [options]
103
104update relay schema
105
106Options:
107
108 -h, --help output usage information
109```
110
111This command will call out to a GraphQL server to fetch its schema and save it locally. Useful for running query validation without a live server (tests, travis etc.)
112
113#### version
114
115```
116❯ yarn knit -- version <version>
117Usage: version [options] <version>
118
119version updated modules
120
121Options:
122
123 -h, --help output usage information
124 -f, --force-all version all modules. (will fail if version already released)
125```
126
127This will bump the version of all updated modules and tag and commit to git.
128
129#### build
130
131```
132❯ yarn knit -- build
133Usage: build [options]
134
135build updated modules
136
137Options:
138
139 -h, --help output usage information
140 -f, --force-all build all modules
141```
142
143The updated packages are built against `commonjs`, `es6 modules` and `umd` targets.
144
145#### stitch
146
147```
148❯ yarn knit -- stitch
149Usage: stitch [options]
150
151stitch updated modules
152
153Options:
154
155 -h, --help output usage information
156 -f, --force-all knit all modules. (will fail if version already published)
157```
158
159The updated dependencies are stitched together - all required dependencies and meta data are added to the module `package.json`s.
160
161#### publish
162
163```
164❯ yarn knit -- publish
165Usage: publish [options]
166
167publish updated modules
168
169Options:
170
171 -h, --help output usage information
172 -f, --force-all publish all modules. (will fail if version already published)
173```
174
175This command does not commit anything to git and must be done on a tagged commit. All updated modules are publish to the npm registry and can be used by `require`, `import`, modern tree-shaking bundlers like `webpack` and `rollup` using `jsnext:main` and as script tags thanks to https://unpkg.com.
176
177#### release
178
179```
180❯ yarn knit -- release <version>
181Usage: knit [options]
182
183release updated modules
184
185Options:
186
187 -h, --help output usage information
188 -f, --force-all release all modules. (will fail if version already published)
189```
190
191This command will run all updated modules through the full release process: `version->build->stitch->publish` and then push to git. If you would like to modify this work flow each step has been broken out into its own command for you to mix and match as needed.