1 | ![KnitCLI](knit_cli_header.png "Knit CLI")
|
2 |
|
3 | ---
|
4 |
|
5 | ## Install
|
6 |
|
7 | It 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 | ```
|
12 | yarn global add @knit/knit
|
13 | ```
|
14 |
|
15 | #### Local
|
16 |
|
17 | ```
|
18 | yarn 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 |
|
36 | This command will list out your modules with their dependency count and show whether you have missing packages you need to install:
|
37 |
|
38 | ```
|
39 | yarn knit -- list
|
40 | ```
|
41 |
|
42 | ![List](list.png "List")
|
43 |
|
44 | You can pass in module names to limit the scope of the search:
|
45 |
|
46 | ```
|
47 | yarn knit -- list @myscope/header-component
|
48 | ```
|
49 |
|
50 | ![ListModule](list_module.png "List Module")
|
51 |
|
52 | #### list -d, --dependencies
|
53 |
|
54 | Passing `--dependencies` will expand the dependencies into a list to show you a more detailed view of your modules:
|
55 |
|
56 | ```
|
57 | yarn knit -- list --dependencies
|
58 | ```
|
59 |
|
60 | ![ListDep](list_dependencies.png "List Dependencies")
|
61 |
|
62 | #### list -u, --updated
|
63 |
|
64 | This 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 | ```
|
67 | yarn knit -- list --updated
|
68 | ```
|
69 |
|
70 | ![ListUp](list_updated.png "List Updated")
|
71 |
|
72 | #### validate
|
73 |
|
74 | This 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 | ```
|
77 | yarn knit -- validate
|
78 | ```
|
79 |
|
80 | ![Validate](validate.png "Validate")
|
81 |
|
82 | #### server
|
83 |
|
84 | ```
|
85 | ❯ yarn knit -- server
|
86 | Usage: server [options]
|
87 |
|
88 | start a dev server
|
89 |
|
90 | Options:
|
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
|
102 | Usage: relay [options]
|
103 |
|
104 | update relay schema
|
105 |
|
106 | Options:
|
107 |
|
108 | -h, --help output usage information
|
109 | ```
|
110 |
|
111 | This 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>
|
117 | Usage: version [options] <version>
|
118 |
|
119 | version updated modules
|
120 |
|
121 | Options:
|
122 |
|
123 | -h, --help output usage information
|
124 | -f, --force-all version all modules. (will fail if version already released)
|
125 | ```
|
126 |
|
127 | This will bump the version of all updated modules and tag and commit to git.
|
128 |
|
129 | #### build
|
130 |
|
131 | ```
|
132 | ❯ yarn knit -- build
|
133 | Usage: build [options]
|
134 |
|
135 | build updated modules
|
136 |
|
137 | Options:
|
138 |
|
139 | -h, --help output usage information
|
140 | -f, --force-all build all modules
|
141 | ```
|
142 |
|
143 | The updated packages are built against `commonjs`, `es6 modules` and `umd` targets.
|
144 |
|
145 | #### stitch
|
146 |
|
147 | ```
|
148 | ❯ yarn knit -- stitch
|
149 | Usage: stitch [options]
|
150 |
|
151 | stitch updated modules
|
152 |
|
153 | Options:
|
154 |
|
155 | -h, --help output usage information
|
156 | -f, --force-all knit all modules. (will fail if version already published)
|
157 | ```
|
158 |
|
159 | The 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
|
165 | Usage: publish [options]
|
166 |
|
167 | publish updated modules
|
168 |
|
169 | Options:
|
170 |
|
171 | -h, --help output usage information
|
172 | -f, --force-all publish all modules. (will fail if version already published)
|
173 | ```
|
174 |
|
175 | This 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>
|
181 | Usage: knit [options]
|
182 |
|
183 | release updated modules
|
184 |
|
185 | Options:
|
186 |
|
187 | -h, --help output usage information
|
188 | -f, --force-all release all modules. (will fail if version already published)
|
189 | ```
|
190 |
|
191 | This 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.
|