UNPKG

8.8 kBMarkdownView Raw
1# clark
2
3[![Dependabot badge](https://img.shields.io/badge/Dependabot-active-brightgreen.svg)](https://dependabot.com/)
4
5<!-- THIS FILE WAS GENERATED BY @ianwremmel/proj. PLEASE DO NOT REMOVE ANY COMMENTS THAT BEGING WITH "PROJ" -->
6
7<!-- (optional) Put banner here -->
8
9<!-- PROJ: Badges Start -->
10
11[![license](https://img.shields.io/github/license/ianwremmel/clark.svg)](https://github.com/ianwremmel/clark/blob/master/LICENSE)
12[![standard-readme compliant](https://img.shields.io/badge/readme%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme)
13[![npm (scoped)](https://img.shields.io/npm/v/@ianwremmel/clark.svg)](https://www.npmjs.com/package/@ianwremmel/clark)
14[![npm](https://img.shields.io/npm/dm/@ianwremmel/clark.svg)](https://www.npmjs.com/package/@ianwremmel/clark)
15
16[![Greenkeeper badge](https://badges.greenkeeper.io/ianwremmel/clark.svg)](https://greenkeeper.io/)
17[![dependencies Status](https://david-dm.org/ianwremmel/clark/status.svg)](https://david-dm.org/ianwremmel/clark)
18[![devDependencies Status](https://david-dm.org/ianwremmel/clark/dev-status.svg)](https://david-dm.org/ianwremmel/clark?type=dev)
19[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
20
21[![CircleCI](https://circleci.com/gh/ianwremmel/clark.svg?style=svg)](https://circleci.com/gh/ianwremmel/clark)
22[![Coverage Status](https://coveralls.io/repos/github/ianwremmel/clark/badge.svg?branch=master)](https://coveralls.io/github/ianwremmel/clark?branch=master)
23
24<!-- PROJ: Badges End -->
25
26> Monorepo tools
27
28Clark is a toolkit for interacting with [alle-inspired](https://github.com/boennemann/alle) monorepos. This is a productization of practices found in [PouchDB](https://github.com/pouchdb/pouchdb), the [Cisco Spark JavaScript SDK](https://github.com/ciscospark/spark-js-sdk), and other monorepo projects.
29
30## Table of Contents
31
32* [Install](#install)
33* [Usage](#usage)
34 * [Alle](#alle)
35 * [Non-Alle](#non-alle)
36 * [Commands](#commands)
37* [Maintainer](#maintainer)
38* [Contribute](#contribute)
39 * [Development](#development)
40* [License](#license)
41
42## Install
43
44```bash
45npm install @ianwremmel/clark
46```
47
48## Usage
49
50Unlike [lerna](https://lernajs.io/) or similar tools, `clark` lets you keep track of your dependencies all in your main `package.json` (key benefits being significantly faster `npm install` times and the ability to use greenkeeper). In order to get this benefit, however, you'll need to follow one of two patterns ([alle](#alle) or [non-alle](#non-alle), described below). Once you pick one of those patterns and configure your repository accordingly, you can use `clark hoist`, to move your deps from you individual subpackages to your repo root.
51
52### Alle
53
54[Alle](https://github.com/boennemann/alle) was originally described as just an example of how things _could_ work, before eventually being enacted by [pouchdb](). In order to follow the Alle pattern, all of your package **must** be kept in `./packages/node_modules` and the name of each `package.json` **should** match the subfolder path (yes, this includes the org/user scope if present).
55
56**Benefits**
57
58* Alle is symlink free. It relies on the behavior of `require()` inside a `node_modules` directory to search both up the tree and in sibling folders, thus letting your packages find each other automatically.
59
60**Caveats**
61
62* Many tools have hardcoded excludes for `node_modules` and some can't be overridden at all. Perhaps most problematically, GitHub PR will collapse most of your diffs assuming that anything in `node_modules` is vendored. GitHub language stats also get confused.
63* If you already have an established project, moving every folder can be problematic.
64
65### Non-Alle
66
67When npm encounters a package version that's simply a file path (e.g. `"my-package": "file:./packages/my-package"`), it will symlink it into `./node_modules`. By putting all of our local node_modules in the top-level `package.json`, we can expose our local packages to each other without making any other repo changes.
68
69> In addition to moving dependencies to the top-level, if `clark` sees your in a non-alle monorepo, it will automatically add the local `file:` entries to the top-level as well. You may want to run hoist whenever you create a new package.
70
71Simply add your package directories the `include` section of `.clarkrc`.
72
73```json
74//.clarkrc
75{
76 "include": ["frontend/*", "backend/*"]
77}
78```
79
80**Benefits**
81
82* No need to move anything in your existing project.
83* Doesn't break GitHub.
84
85**Caveats**
86
87* Not yet tested in the wild.
88* Likely requires a very recent version of npm. (Though, clark requires node 8 or later, so this may not be an issue).
89
90### Commands
91
92<!-- commands -->
93* [`clark exec COMMAND`](#clark-exec-command)
94* [`clark help [COMMAND]`](#clark-help-command)
95* [`clark hoist`](#clark-hoist)
96* [`clark init`](#clark-init)
97* [`clark list`](#clark-list)
98* [`clark run SCRIPT`](#clark-run-script)
99
100## `clark exec COMMAND`
101
102Execute a command in each package directory. Note: commands with spaces and pipes are supported, but must be wrapped in quotes.
103
104```
105USAGE
106 $ clark exec COMMAND
107
108OPTIONS
109 -p, --packageName=packageName The package against which to run this command. May be specified more than once.
110 -s, --silent Indicates nothing should be printed to the stdout
111 --fail-fast Alias of --failFast
112 --failFast Fail as soon as a command fails, rather than running all to completion
113 --package=package alias of --packageName
114 --package-name=package-name alias of --packageName
115```
116
117_See code: [src/commands/exec.ts](https://github.com/ianwremmel/clark/blob/v4.1.2/src/commands/exec.ts)_
118
119## `clark help [COMMAND]`
120
121display help for clark
122
123```
124USAGE
125 $ clark help [COMMAND]
126
127ARGUMENTS
128 COMMAND command to show help for
129
130OPTIONS
131 --all see all commands in CLI
132```
133
134_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v1.2.5/src/commands/help.ts)_
135
136## `clark hoist`
137
138Migrate dependencies and dev dependencies from a sub package to the root package.json
139
140```
141USAGE
142 $ clark hoist
143
144OPTIONS
145 -p, --packageName=packageName The package against which to run this command. May be specified more than once.
146 -s, --silent Indicates nothing should be printed to the stdout
147 --fail-fast Alias of --failFast
148
149 --failFast Fail upon encountering a package that cannot be hoisted, rather than running all to
150 completion
151
152 --package=package alias of --packageName
153
154 --package-name=package-name alias of --packageName
155
156 --risky Indicates if clark should attempt to reconcile semver mismatches.
157```
158
159_See code: [src/commands/hoist.ts](https://github.com/ianwremmel/clark/blob/v4.1.2/src/commands/hoist.ts)_
160
161## `clark init`
162
163Create a .clarkrc file in your project root
164
165```
166USAGE
167 $ clark init
168
169OPTIONS
170 -f, --force Overwrite .clarkrc with new config
171 -s, --script=script Identifies a script to add to the config file
172```
173
174_See code: [src/commands/init.ts](https://github.com/ianwremmel/clark/blob/v4.1.2/src/commands/init.ts)_
175
176## `clark list`
177
178List all packages
179
180```
181USAGE
182 $ clark list
183```
184
185_See code: [src/commands/list.ts](https://github.com/ianwremmel/clark/blob/v4.1.2/src/commands/list.ts)_
186
187## `clark run SCRIPT`
188
189Runs a script in each package directory. This is different from `exec` in that scripts should be defined in .clarkrc and may be overridden on a per-package basis via npm scripts. npm scripts defined only in subpackage package.jsons can be run this way, but only scripts named in .clarkrc will populate the help output.
190
191```
192USAGE
193 $ clark run SCRIPT
194
195OPTIONS
196 -p, --packageName=packageName The package against which to run this command. May be specified more than once.
197 -s, --silent Indicates nothing should be printed to the stdout
198 --fail-fast Alias of --failFast
199 --failFast Fail as soon as a command fails, rather than running all to completion
200 --package=package alias of --packageName
201 --package-name=package-name alias of --packageName
202```
203
204_See code: [src/commands/run.ts](https://github.com/ianwremmel/clark/blob/v4.1.2/src/commands/run.ts)_
205<!-- commandsstop -->
206
207## Maintainer
208
209[Ian Remmel](https://github.com/ianwremmel)
210
211## Contribute
212
213PRs Welcome
214
215### Development
216
217Use `ts-node` to test your changes without rebuilding
218
219```bash
220ts-node ./src/cli.ts --help
221```
222
223## License
224
225[MIT](LICENSE) &copy; [Ian Remmel](https://github.com/ianwremmel) 2018 until at least now