├── .babelrc ├── .eslintrc.yaml ├── .flowconfig ├── .gitignore ├── .npmignore ├── .prettierignore ├── .prettierrc ├── .travis.yml ├── CHANGELOG.md ├── LICENSE ├── README.md ├── ROADMAP.md ├── __mocks__ └── rimraf.js ├── docs ├── parallel.gif └── status.png ├── package.json ├── src ├── __tests__ │ ├── __snapshots__ │ │ ├── addRemoveUpgrade.test.js.snap │ │ ├── all.test.js.snap │ │ ├── bootstrap.test.js.snap │ │ ├── bump.test.js.snap │ │ ├── clean.test.js.snap │ │ ├── outdated.test.js.snap │ │ ├── prepublish.test.js.snap │ │ ├── publish.test.js.snap │ │ ├── removeAll.test.js.snap │ │ └── runScript.test.js.snap │ ├── addRemoveUpgrade.test.js │ ├── all.test.js │ ├── bootstrap.test.js │ ├── bump.test.js │ ├── clean.test.js │ ├── outdated.test.js │ ├── prepublish.test.js │ ├── publish.test.js │ ├── removeAll.test.js │ ├── resetAllVersions.test.js │ └── runScript.test.js ├── addRemoveUpgrade.js ├── all.js ├── bootstrap.js ├── bump.js ├── clean.js ├── index.js ├── outdated.js ├── prepublish.js ├── publish.js ├── removeAll.js ├── resetAllVersions.js ├── runScript.js ├── status.js └── utils │ ├── __mocks__ │ └── git.js │ ├── __tests__ │ ├── __snapshots__ │ │ ├── calcGraph.test.js.snap │ │ └── readSpecs.test.js.snap │ ├── calcGraph.test.js │ ├── readSpecs.test.js │ └── shell.test.js │ ├── calcGraph.js │ ├── changelog.js │ ├── constants.js │ ├── git.js │ ├── helpers.js │ ├── initConsole.js │ ├── listPaths.js │ ├── multiRun.js │ ├── promises.js │ ├── readSpecs.js │ ├── removeInternalLinks.js │ ├── shell.js │ ├── types.js │ └── writeSpecs.js ├── test └── fixtures │ ├── CHANGELOG.md │ ├── packages │ ├── dummy.txt │ ├── no-package │ │ └── dummy.txt │ ├── oao-b │ │ └── package.json │ ├── oao-c │ │ └── package.json │ ├── oao-d │ │ └── package.json │ ├── oao-priv │ │ └── package.json │ └── oao │ │ └── package.json │ ├── packages2 │ ├── oao-b │ │ └── package.json │ ├── oao-c │ │ └── package.json │ └── oao │ │ └── package.json │ ├── packages3 │ ├── dummy.txt │ ├── no-package │ │ └── dummy.txt │ ├── oao-b │ │ └── package.json │ ├── oao-c │ │ └── package.json │ ├── oao-d │ │ └── package.json │ ├── oao-priv │ │ └── package.json │ └── oao │ │ └── package.json │ ├── packagesCustomLinks │ ├── oao-b │ │ └── package.json │ ├── oao-c │ │ └── package.json │ └── oao │ │ └── package.json │ ├── packagesScoped │ ├── example-package-b │ │ └── package.json │ └── example-package │ │ └── package.json │ ├── packagesWrongName │ └── wrong-name │ │ └── package.json │ ├── packagesWrongVersion │ └── oao │ │ └── package.json │ ├── packagesWrongVersion2 │ └── oao │ │ └── package.json │ └── yarnInception │ ├── a │ └── package.json │ └── b │ └── package.json └── yarn.lock /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | ["@babel/preset-env", { "targets": { "node": "6" } }], 4 | "@babel/preset-flow" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /.eslintrc.yaml: -------------------------------------------------------------------------------- 1 | parser: babel-eslint 2 | extends: 3 | - airbnb 4 | - prettier 5 | plugins: 6 | - flowtype 7 | rules: 8 | eqeqeq: ['error', 'allow-null'] 9 | prefer-object-spread: off 10 | no-unused-expressions: 11 | - error 12 | - allowShortCircuit: true 13 | no-use-before-define: off 14 | no-multi-spaces: off 15 | no-nested-ternary: off 16 | no-cond-assign: ['error', 'except-parens'] 17 | no-underscore-dangle: off 18 | no-confusing-arrow: off 19 | comma-dangle: 20 | - error 21 | - arrays: always-multiline 22 | objects: always-multiline 23 | imports: always-multiline 24 | exports: always-multiline 25 | functions: ignore 26 | no-plusplus: 27 | - error 28 | - allowForLoopAfterthoughts: true 29 | no-continue: off 30 | no-await-in-loop: off 31 | key-spacing: 32 | - warn 33 | - beforeColon: false 34 | afterColon: true 35 | mode: 'minimum' 36 | object-property-newline: off 37 | class-methods-use-this: off 38 | arrow-parens: off 39 | react/sort-comp: off 40 | react/jsx-first-prop-new-line: off 41 | react/jsx-indent: off 42 | react/jsx-indent-props: off 43 | react/jsx-closing-bracket-location: off 44 | react/jsx-filename-extension: off 45 | react/forbid-prop-types: off 46 | react/prop-types: off 47 | react/require-extension: off 48 | react/require-default-props: off 49 | import/no-extraneous-dependencies: 50 | - error 51 | - devDependencies: true 52 | peerDependencies: true 53 | optionalDependencies: false 54 | import/prefer-default-export: off 55 | jsx-a11y/no-static-element-interactions: off 56 | globals: 57 | chrome: false 58 | -------------------------------------------------------------------------------- /.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | .*/__tests__/.* 3 | .*/__mocks__/.* 4 | /lib/.* 5 | /node_modules/fbjs 6 | /node_modules/jest/.* 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # GIT-NPM common 2 | # -------------- 3 | # All projects 4 | logs 5 | *.log 6 | npm-debug.log* 7 | pids 8 | *.pid 9 | *.seed 10 | node_modules 11 | /coverage 12 | /.nyc_output 13 | /.nyc_tmp 14 | *.sublime-project 15 | *.sublime-workspace 16 | 17 | # Project-specific 18 | 19 | 20 | # GIT-specific 21 | # ------------ 22 | # All projects 23 | lib 24 | 25 | # Project-specific 26 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | # GIT-NPM common 2 | # -------------- 3 | # All projects 4 | logs 5 | *.log 6 | npm-debug.log* 7 | pids 8 | *.pid 9 | *.seed 10 | node_modules 11 | /coverage 12 | /.nyc_output 13 | /.nyc_tmp 14 | *.sublime-project 15 | *.sublime-workspace 16 | 17 | # Project-specific 18 | 19 | 20 | # NPM-specific 21 | # ------------ 22 | # All projects 23 | /src 24 | /tools 25 | /test 26 | /package.coffee 27 | /ROADMAP.md 28 | /.travis.yml 29 | /.npmignore 30 | 31 | # Project-specific 32 | /docs 33 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | package.json 2 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | singleQuote: true 2 | trailingComma: es5 -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - 'stable' 4 | - '10' 5 | before_script: 6 | - export TZ=Europe/Madrid 7 | script: npm run travis 8 | after_success: 9 | - 'cat ./coverage/lcov.info | ./node_modules/.bin/coveralls' 10 | cache: 11 | yarn: true 12 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 2.0.2 (2021-4-18) 2 | 3 | - Bump shelljs (avoids lots of warnings when running various OAO commands). 4 | 5 | ## 2.0.1 (2021-2-7) 6 | 7 | - Bump storyboard. 8 | 9 | ## 2.0.0 (2020-7-25) 10 | 11 | - **Breaking**: Always publishes _all_ (non-private) sub-packages, irrespective of whether they have been updated. 12 | - **Breaking** (but can opt-out with `--bump-dependent-reqs no`): `oao publish` now bumps inner dependency requirements (i.e. cross-links inside the monorepo). (jeroenptrs, onigoetz, guigrpa, #100). 13 | - `oao publish` now always publishes in reverse-dependency order (jeroenptrs, #102). 14 | 15 | ## 1.10.0 (2020-6-26) 16 | 17 | - Allow 2-factor auth when publishing (jeroenptrs, #99). 18 | - Allow publishing scoped packages publicly (jeroenptrs, #99). 19 | 20 | ## 1.9.0 (2020-6-24) 21 | 22 | - Allow publishing from the `main` branch by default, in addition to `master` (jeroenptrs, #98). 23 | 24 | ## 1.8.0 (2020-1-28) 25 | 26 | - Limit `parallelLimit` by number of cpus by default (SimenB, #92). 27 | 28 | ## 1.7.0 (2019-8-13) 29 | 30 | - Add `--no-bump` for `oao publish`, useful in CI/CD environments (#83). 31 | 32 | ## 1.6.1 (2019-8-11) 33 | 34 | - Bump dependencies. Remove @babel/polyfill since it's not needed in Node 6+. 35 | 36 | ## 1.6.0 (2019-2-20) 37 | 38 | - Add `oao remove-all` (removes a dependency throughout the monorepo) (#80). 39 | 40 | ## 1.5.1 (2018-3-21) 41 | 42 | - Fix bug in `oao all` and `oao run-script` which caused incorrect serial execution (#72). 43 | 44 | ## 1.5.0 (2018-3-19) 45 | 46 | - Add `oao bump` (upgrades a dependency across all sub-packages) (#28). 47 | 48 | ## 1.5.0-beta.0 (2018-3-14) 49 | 50 | - Add `--parallel-limit <#processes>` to `oao all` and `oao run-script`, to limit concurrency when running things in parallel (#69). 51 | - Allow simultaneous usage of `--parallel` and `--tree` for `oao all` and `oao run-script`. In this case, jobs may block if other jobs associated to dependent subpackages are still pending (#68). 52 | - `oao run-script`: add the possibility to generate more than one job per subpackage (e.g. `oao run-script test:*`) (#70). 53 | 54 | ## 1.4.1 (2018-3-12) 55 | 56 | - Fix issues caused by new yarn `workspaces` semantics (#71, #67). 57 | 58 | ## 1.4.0 (2018-2-16) 59 | 60 | - Add `--relative-time` to all commands, shortening the date column in logs by 61 | 14 characters (#64). 62 | 63 | ## 1.3.1 (2018-2-13) 64 | 65 | - Add `--no-checks` for `oao publish` (removes all prepublish checks), useful in 66 | some cases (#62). 67 | 68 | ## 1.3.0 (2018-2-13) 69 | 70 | - Add support for extra arguments in `oao all`, e.g. `oao all ls -- -al` is now 71 | equivalent to `oao all 'ls -al'` (#61). 72 | 73 | ## 1.2.1 (2017-11-24) 74 | 75 | - Remove subpackage prefix in logs generated with `oao all` and `oao run-script` 76 | when not running in parallel. 77 | 78 | ## 1.2.0 (2017-11-24) 79 | 80 | - Improve error logging with `oao all` and `oao run-script` in parallel mode -- 81 | re-print the whole stderr contents at the end (#57). 82 | - Add subpackage prefix to all logs in `oao all` and `oao run-script` (related 83 | to #57). 84 | 85 | ## 1.1.0 (2017-11-24) 86 | 87 | - Add `--tree` to `oao all` and `oao run-script` (follows dependency tree, 88 | starting with the tree leaves and going upwards) (closes issue #58). 89 | 90 | ## 1.0.0 (2017-11-11) 91 | 92 | - Bump to 1.0.0. No breaking changes expected (at least not so often). 93 | 94 | ## 0.10.5 (2017-11-11) 95 | 96 | - Add **`oao run-script`** (#55, @kevroadrunner). 97 | 98 | ## 0.10.4 (2017-10-10) 99 | 100 | - Log error code when external command fails and prevent some log redundancy 101 | (#52). 102 | 103 | ## 0.10.3 (2017-10-6) 104 | 105 | - Improve error detail when running `oao status` and some package has an invalid 106 | `name` in its `package.json` (#40). 107 | 108 | ## 0.10.2 (2017-10-6) 109 | 110 | - Set `process.env.YARN_SILENT` to 0, so that yarn's output is not removed in 111 | some cases (#50, see also https://github.com/yarnpkg/yarn/pull/3536, 112 | https://github.com/yarnpkg/yarn/issues/4615). 113 | - Ignore `yarn outdated`'s non-zero error code when it finds outdated packages 114 | (#50). 115 | 116 | ## 0.10.1 (2017-9-13) 117 | 118 | - Bugfix: in `oao add|remove|upgrade`, fix handling of scoped packages (#45). 119 | 120 | ## 0.10.0 (2017-8-23) 121 | 122 | ## 0.10.0-beta.3 (2017-8-18) 123 | 124 | - Add support for **non-monorepo publishing** Use the `oao publish --single` to 125 | indicate that your root package is _not_ a monorepo, and you can benefit from 126 | oao's features even in normal packages: publishing checks, automatic tagging, 127 | interactive version selection, etc. 128 | 129 | ## 0.10.0-beta.2 (2017-8-17) 130 | 131 | ## 0.10.0-beta.1 (2017-8-16) 132 | 133 | - Add support for **yarn workspaces**. This mode is enabled automatically when 134 | the root package.json has a `workspaces` field, which overrides any other 135 | `src` option. 136 | 137 | ## 0.9.0 (Jul. 15, 2017) 138 | 139 | - Experimentally add the possibility to specify some config options in 140 | package.json (#47). 141 | 142 | ## 0.8.5 (Jun. 16, 2017) 143 | 144 | - Add **`--increment-version-by` option for `oao publish`**. This allows setting 145 | the next version automatically, e.g. in a continuous deployment scheme (#41). 146 | - Add prettier. 147 | 148 | ## 0.8.4 (Jun. 16, 2017) 149 | 150 | - Bugfix: in parallel `oao bootstrap`, recover original subpackage 151 | `package.json` files always, even if one of the subpackages fails to install 152 | (#42). 153 | 154 | ## 0.8.3 (Jun. 15, 2017) 155 | 156 | - Parallelize `oao bootstrap` -- **substantially improved performance** (#42). 157 | - Add support for `--frozen-lockfile`, `--pure-lockfile` and `--no-lockfile` 158 | flags in `oao bootstrap` (see Yarn documentation) (#43). 159 | 160 | ## 0.8.2 (Apr. 14, 2017) 161 | 162 | - Bump deps 163 | 164 | ## 0.8.1 (Apr. 3, 2017) 165 | 166 | - Add `--ignore-src ` option to all commands to exclude sub-packages 167 | (#38). 168 | - Add warning to `oao oudated` for internal deps that do not meet the specified 169 | version range (#34). 170 | 171 | ## 0.8.0 (Mar. 8, 2017) 172 | 173 | - Rename `--version` option (incompatible with `commander`'s default option') to 174 | `--new-version` (#35). 175 | - During `oao publish`, automatically **update the changelog** with the new 176 | version and release date. 177 | - Add **`--no-npm-publish` option to `oao publish`** to prevent accidental 178 | publishing on npm of parts of an all-private monorepo. 179 | - During `oao publish`, also **update the versions of _private_ sub-packages** 180 | that have changed. 181 | 182 | ## 0.7.3 (Mar. 4, 2017) 183 | 184 | - Add more granular configuration options for `oao publish`: 185 | `--no-check-uncommitted`, `--no-check-unpulled`, `--no-git-commit` (#29). 186 | - Add `--version ` option to `oao publish` (overrides manual 187 | version specification) (#30). 188 | 189 | ## 0.7.2 (Mar. 1, 2017) 190 | 191 | - When executing a command, inhibit `stdin` access on Windows (see 192 | [this](https://github.com/nodejs/node/issues/10836) and 193 | [this](https://github.com/yarnpkg/yarn/issues/2462)). 194 | 195 | ## 0.7.1 (Feb. 28, 2017) 196 | 197 | - Add **`oao clean`** to remove all `node_modules` directories in sub-packages. 198 | - Provide **more explicit errors when unhandled rejections occur**. 199 | - Add `--no-confirm` option to `oao reset-all-versions` (#26). 200 | - Extract Parallel Console (now published as 201 | `storyboard-listener-console-parallel` under the Storyboard monorepo). 202 | 203 | ## 0.7.0 (Feb. 27, 2017) 204 | 205 | - Add support for **internal links in `oao add|remove|upgrade`** (#17). 206 | - Add support for `oao add|remove|upgrade` on the root package (use either `.` 207 | or `ROOT` as package name). 208 | 209 | ## 0.6.1 (Feb. 26, 2017) 210 | 211 | - Remove extra blank lines (above the fold) caused when clearing the terminal in 212 | parallel logs (#18). 213 | - Show help when user enters no valid command. 214 | 215 | ## 0.6.0 (Feb. 25, 2017) 216 | 217 | - Also process the monorepo root during `oao bootstrap`, including links to 218 | sub-packages (if any) (#24). 219 | - Modify `oao status` so that it provides more accurate information (e.g. in git 220 | repos with no tags, no upstream, etc.) (#23). 221 | - Warn during `oao bootstrap` when linked package version does not satisfy the 222 | required range (#25). 223 | 224 | ## 0.5.7 (Feb. 24, 2017) 225 | 226 | - Add **`oao outdated`**: runs `yarn outdated` on all sub-packages and the root 227 | package, taking care that internal and custom links are omitted. 228 | - Add **`--production` option** to `oao bootstrap`: skip external and internal 229 | development-only dependencies (also available by setting the `NODE_ENV` 230 | environment variable to `production`) (#19). See also discussion in #16. 231 | - Filter sub-package paths, keeping only those that contain a `package.json` 232 | file (#20). 233 | 234 | ## 0.5.6 (Feb. 23, 2017) 235 | 236 | - Allow `--src` pattern to have a trailing slash (optional). 237 | - Other minor tweaks. 238 | 239 | ## 0.5.5 (Feb. 22, 2017) 240 | 241 | - Add **parallel logging in `oao all`** (can be disabled using the 242 | `--no-parallel-logs` option) (#10). 243 | 244 | ## 0.5.4 (Feb. 21, 2017) 245 | 246 | - Add **parallel support to `oao all`**, using the `--parallel` and 247 | `--ignore-errors` options (#10, #13). 248 | - Bugfix: filter out non-directory paths from globby results (#11). 249 | 250 | ## 0.5.3 (Feb. 20, 2017) 251 | 252 | - Add **`oao status`**: provides lots of information on the monorepo. 253 | - Add **`--link ` option** to force some packages to be linked, not 254 | installed (useful in some development environments). Used in `oao bootstrap` 255 | and `oao add|remove|upgrade`. 256 | - Add **`--ignore-engines` option** to `oao upgrade` (passed through to Yarn). 257 | - Add **`--copy-attrs` option** to `oao prepublish` (attributes that are copied 258 | to the sub-package's `package.json` file). 259 | 260 | ## 0.5.2 (Feb. 16, 2017) 261 | 262 | - Add **tentative support for scoped packages** (#7). 263 | - Internal: 264 | - Add unit tests. 265 | - Add static types (Flow). 266 | 267 | ## 0.5.1 (Feb. 15, 2017) 268 | 269 | - Add **`oao upgrade [deps...]`**. 270 | - Add unit tests, Travis, Coveralls. 271 | 272 | ## 0.5.0 (Feb. 14, 2017) 273 | 274 | - Add **`oao add `**. 275 | - Add **`oao remove `**. 276 | - Bump `storyboard` yet again (some warnings remained). 277 | - Fix missing newlines at the end of `package.json` files (#3). 278 | 279 | ## 0.4.1 (Feb. 13, 2017) 280 | 281 | - Bump `storyboard` (prevents "unmet peer dependency" during installation). 282 | 283 | ## 0.4.0 (Feb. 12, 2017) 284 | 285 | - Greatly reduce the number of oao dependencies by bumping `storyboard` to v3 286 | (prerelease). 287 | - Add **`--publish-tag ` option** to `oao publish`: (publishes with a 288 | custom tag, instead of `latest`). 289 | 290 | ## 0.3.3 (Feb. 12, 2017) 291 | 292 | - Fix bad repo links in `package.json`. 293 | 294 | ## 0.3.2 (Feb. 12, 2017) 295 | 296 | - Bugfixes: 297 | - Fix prerelease version updates. 298 | - Move `babel-polyfill` to `dependencies` (#2). 299 | - Prevent normal `git push` output from being shown as errors. 300 | 301 | ## 0.3.0, 0.3.1 (Feb. 12, 2017) 302 | 303 | - Add options to `oao publish`: 304 | - `--no-master` (allow publishing from non-`master` branches). 305 | - `--no-confirm` (skip confirmation steps). 306 | 307 | ## 0.2.0 (Feb. 10, 2017) 308 | 309 | - Automatically detect updated packages, allow user selection of 310 | major/minor/patch/prerelease increment, commit, tag, push and publish. 311 | - Allow custom package directories. 312 | - Improve docs. 313 | 314 | ## 0.1.0 (Feb. 9, 2017) 315 | 316 | - First public release. 317 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2017- Guillermo Grau Panea 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # oao :package: [![Build Status](https://travis-ci.org/guigrpa/oao.svg?branch=master)](https://travis-ci.org/guigrpa/oao) [![Coverage Status](https://coveralls.io/repos/github/guigrpa/oao/badge.svg?branch=master)](https://coveralls.io/github/guigrpa/oao?branch=master) [![npm version](https://img.shields.io/npm/v/oao.svg)](https://www.npmjs.com/package/oao) 2 | 3 | ![oao all --parallel](https://raw.githubusercontent.com/guigrpa/oao/master/docs/parallel.gif) 4 | 5 | A Yarn-based, opinionated monorepo management tool. 6 | 7 | ## Why? :sparkles: 8 | 9 | - Works with **yarn**, hence (relatively) **fast!**. 10 | - **Simple to use** and extend (hope so!). 11 | - Provides a number of monorepo **workflow enhancers**: installing all dependencies, adding/removing/upgrading sub-package dependencies, validating version numbers, determining updated sub-packages, publishing everything at once, updating the changelog, etc. 12 | - Supports **yarn workspaces**, optimising the monorepo dependency tree as a whole and simplifying bootstrap as well as dependency add/upgrade/remove. 13 | - **Prevents some typical publish errors** (using a non-master branch, uncommitted/non-pulled changes). 14 | - Runs a command or `package.json` script on all sub-packages, **serially or in parallel**, optionally following the inverse dependency tree. 15 | - Provides an easy-to-read, **detailed status overview**. 16 | - Support for **non-monorepo publishing**: benefit from _oao_'s pre-publish checks, tagging, version selection, changelog updates, etc. also in your single-package, non-monorepos. 17 | 18 | ## Assumptions :thought_balloon: 19 | 20 | As stated in the tagline, _oao_ is somewhat opinionated and makes the following assumptions on your monorepo: 21 | 22 | - It uses a **synchronized versioning scheme**. In other words: a _master version_ is configured in the root-level `package.json`, and sub-packages will be in sync with that version (whenever they are updated). Some sub-packages can be _left behind_ version-wise if they're not updated, but they'll jump to the master version when they get some love. 23 | - You use **git** for version control and have already initialised your repo. 24 | - **Git tags** are used for releases (and _only_ for releases), and follow semver: `v0.1.3`, `v2.3.5`, `v3.1.0-rc.1` and so on. 25 | - Some sub-packages may be public, others private (flagged `"private": true` in `package.json`). OK, _no assumption here_: rest assured that no private sub-packages will be published by mistake. 26 | 27 | ## Installation 28 | 29 | If _yarn_ is not installed in your system, please [install it first](https://yarnpkg.com/en/docs/install). If you want to use [**yarn workspaces**](https://yarnpkg.com/blog/2017/08/02/introducing-workspaces/) (available since yarn 0.28), enable them by running `yarn config set workspaces-experimental true` and configure the following in your monorepo package.json (replace the glob patterns for your subpackages/workspaces as needed): 30 | 31 | ``` 32 | "workspaces": [ 33 | "packages/*" 34 | ] 35 | ``` 36 | 37 | Add **oao** to your development dependencies (use the `-W` flag to avoid Yarn's warning when installing dependencies on the monorepo root): 38 | 39 | ```sh 40 | $ yarn add oao --dev -W 41 | ``` 42 | 43 | ## Usage 44 | 45 | To see all CLI options, run `oao --help`: 46 | 47 | ``` 48 | Usage: oao [options] [command] 49 | 50 | Options: 51 | 52 | -V, --version output the version number 53 | -h, --help output usage information 54 | 55 | Commands: 56 | 57 | status [options] Show an overview of the monorepo status 58 | bootstrap [options] Install external dependencies and create internal links 59 | clean [options] Delete all node_modules directories from sub-packages and the root package 60 | add [options] Add dependencies to a sub-package 61 | remove [options] Remove dependencies from a sub-package 62 | upgrade [options] [packages...] Upgrade some/all dependencies of a package 63 | outdated [options] Check for outdated dependencies 64 | prepublish [options] Prepare for a release: validate versions, copy READMEs and package.json attrs 65 | publish [options] Publish updated sub-packages 66 | reset-all-versions [options] Reset all versions (incl. monorepo package) to the specified one 67 | all [options] Run a given command on all sub-packages 68 | run-script [options] Run a given script on all sub-packages 69 | ``` 70 | 71 | You can also get help from particular commands, which may have additional options, e.g. `oao publish --help`: 72 | 73 | ``` 74 | Usage: publish [options] 75 | 76 | Publish all (non-private) sub-packages 77 | 78 | Options: 79 | 80 | -s --src glob pattern for sub-package paths [packages/*] (default: "packages/*") 81 | -i --ignore-src glob pattern for sub-package paths that should be ignored 82 | -l --link regex pattern for dependencies that should be linked, not installed 83 | --single no subpackages, just the root one 84 | --relative-time shorten log dates 85 | --no-master allow publishing from a non-master or non-main branch 86 | --no-check-uncommitted skip uncommitted check 87 | --no-check-unpulled skip unpulled check 88 | --no-checks skip all pre-publish checks 89 | --no-bump do not increment version numbers (also disables git commit) 90 | --no-confirm do not ask for confirmation before publishing 91 | --no-git-commit skip the commit-tag-push step before publishing 92 | --no-npm-publish skip the npm publish step 93 | --new-version use this version for publishing, instead of asking 94 | --increment-version-by increment version by this, instead of asking 95 | --publish-tag publish with a custom tag (instead of `latest`) 96 | --changelog-path changelog path [CHANGELOG.md] (default: "CHANGELOG.md") 97 | --no-changelog skip changelog updates 98 | --otp use 2-factor authentication to publish your package 99 | --access publish public or restricted packages 100 | -h, --help output usage information 101 | ``` 102 | 103 | ## Main commands 104 | 105 | In recent versions of npm, remember that you can run oao commands conveniently with the `npx` tool: 106 | 107 | ```sh 108 | $ npx oao bootstrap 109 | $ npx oao add my-subpackage my-new-dependency --dev 110 | $ npx oao publish 111 | ``` 112 | 113 | This uses the local oao package inside your monorepo. 114 | 115 | ### `oao status` 116 | 117 | Provides lots of information on the git repo (current branch, last tag, uncommitted/unpulled changes) and subpackage status (version, private flag, changes since last tag, dependencies). 118 | 119 | ![oao status](https://raw.githubusercontent.com/guigrpa/oao/master/docs/status.png) 120 | 121 | ### `oao bootstrap` 122 | 123 | Installs all sub-package dependencies using **yarn**. External dependencies are installed normally, whereas those belonging to the monorepo itself (and custom links specified with the `--link` option) are `yarn link`ed. Note that dependencies may end up in different places depending on whether you use [yarn workspaces](https://yarnpkg.com/blog/2017/08/02/introducing-workspaces/) or not (see above). 124 | 125 | Development-only dependencies can be skipped by enabling the `--production` option, or setting the `NODE_ENV` environment variable to `production`. Other flags that are passed through to `yarn install` include `--frozen-lockfile`, `--pure-lockfile` and `--no-lockfile`. 126 | 127 | ### `oao clean` 128 | 129 | Removes `node_modules` directories from all sub-packages, as well as from the root package. 130 | 131 | ### `oao add ` 132 | 133 | Adds one or several dependencies to a sub-package. For external dependencies, it passes through [`yarn add`'s flags](https://yarnpkg.com/en/docs/cli/add). Internal dependencies are linked. Examples: 134 | 135 | ```sh 136 | $ oao add subpackage-1 jest --dev 137 | $ oao add subpackage-2 react subpackage-1 --exact 138 | ``` 139 | 140 | ### `oao remove ` 141 | 142 | Removes one or several dependencies from a sub-package. Examples: 143 | 144 | ```sh 145 | $ oao remove subpackage-1 jest 146 | $ oao remove subpackage-2 react subpackage-1 147 | ``` 148 | 149 | ### `oao remove-all ` 150 | 151 | Remove one or deveral dependencies from the monorepo (root and subpackages). It automatically runs `oao bootstrap` after upgrading the `package.json` files as needed. Examples: 152 | 153 | ```sh 154 | $ oao remove-all leftpad 155 | $ oao remove-all leftpad rightpad centerpad 156 | ``` 157 | 158 | ### `oao upgrade [deps...]` 159 | 160 | Upgrade one/several/all dependencies of a sub-package. For external dependencies, it will download the upgraded dependency using yarn. For internal dependencies, it will just update the sub-package's `package.json` file. Examples: 161 | 162 | ```sh 163 | $ oao upgrade subpackage-1 jest@18.0.1 164 | $ oao upgrade subpackage-2 react subpackage-1@3.1.2 165 | $ oao upgrade subpackage-3 166 | ``` 167 | 168 | ### `oao bump ` 169 | 170 | Upgrade one or several dependencies to either their latest version or to a specific version range. In case of internal dependencies, if no version range is given the current version will be used. It automatically runs `oao bootstrap` after upgrading the `package.json` files as needed. Examples: 171 | 172 | ```sh 173 | $ oao bump moment 174 | $ oao bump react@^16 react-dom@^16 175 | $ oao bump subpackage-2 176 | ``` 177 | 178 | ### `oao outdated` 179 | 180 | Runs `yarn outdated` on all sub-packages, as well as the root package. 181 | 182 | ### `oao prepublish` 183 | 184 | Carries out a number of chores that are needed before publishing: 185 | 186 | - Checks that all version numbers are valid and <= the master version. 187 | - Copies `/README.md` to the _main_ sub-package (the one having the same name as the monorepo). 188 | - Copies `/README-LINK.md` to all other sub-packages. 189 | - Copies several fields from the root `package.json` to all other `package.json` files: `description`, `keywords`, `author`, `license`, `homepage`, `bugs`, `repository`. 190 | 191 | ### `oao publish` 192 | 193 | Carries out a number of steps: 194 | 195 | - Asks the user for confirmation that it has _built_ all sub-packages for publishing (using something like `yarn build`). 196 | - Performs a number of checks: 197 | - The current branch should be `master` or `main`. 198 | - No uncommitted changes should remain in the working directory. 199 | - No unpulled changes should remain. 200 | - Determines which sub-packages need publishing (those which have changed with respect to the last tagged version). 201 | - Asks the user for an incremented master version (major, minor, patch or pre-release major), that will be used for the root package as well as all updated sub-packages. 202 | - Asks the user for final confirmation before publishing. 203 | - Updates versions in `package.json` files, commits the updates, adds a tag and pushes all the changes. 204 | - Publishes updated sub-packages. 205 | 206 | There are lots of custom options for `oao publish`. Chances are, you can disable each one of the previous steps by means of one of those options. Check them all with `oao publish --help`. 207 | 208 | **Note: There is a problem when running `oao publish` as a script run with `yarn`. As a workaround, either run `oao publish` manually from the command line, or put it in a script and run it with `npm`, not `yarn`.** 209 | 210 | ### `oao all ` 211 | 212 | Executes the specified command on all sub-packages (private ones included), with the sub-package's root as _current working directory_. Examples: 213 | 214 | ```sh 215 | $ oao all ls 216 | $ oao all "ls -al" 217 | $ oao all "yarn run compile" 218 | $ oao all --tree "yarn run compile" 219 | ``` 220 | 221 | By default, `oao all` runs sequentially. Sometimes you must run commands in parallel, for example when you want to compile all sub-packages with a _watch_ option: 222 | 223 | ```sh 224 | $ oao all "yarn run compileWatch" --parallel 225 | ``` 226 | 227 | **Note: some terminals may have problems with parallel logs (based on [terminal-kit](https://github.com/cronvel/terminal-kit)). If you experience issues, use the `--no-parallel-logs` flag. If you're using the default terminal or Hyper on OS X or Windows, you should be fine.** 228 | 229 | Use `--tree` if you want to follow the inverse dependency tree (starting from the tree leaves). 230 | 231 | You can also pass extra arguments to the command separating them with a `--`: `oao all ls -- -al` is equivalent to `oao all 'ls -al'`. This can be useful for adding extra commands to scripts in `package.json`. 232 | 233 | ### `oao run-script