パッケージの詳細

oao

guigrpa6.3kMIT2.0.2

A Yarn-based, opinionated monorepo management tool

monorepo, lerna, mono-repo, yarn

readme

oao :package: Build Status Coverage Status npm version

oao all --parallel

A Yarn-based, opinionated monorepo management tool.

Why? :sparkles:

  • Works with yarn, hence (relatively) fast!.
  • Simple to use and extend (hope so!).
  • 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.
  • Supports yarn workspaces, optimising the monorepo dependency tree as a whole and simplifying bootstrap as well as dependency add/upgrade/remove.
  • Prevents some typical publish errors (using a non-master branch, uncommitted/non-pulled changes).
  • Runs a command or package.json script on all sub-packages, serially or in parallel, optionally following the inverse dependency tree.
  • Provides an easy-to-read, detailed status overview.
  • 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.

Assumptions :thought_balloon:

As stated in the tagline, oao is somewhat opinionated and makes the following assumptions on your monorepo:

  • 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.
  • You use git for version control and have already initialised your repo.
  • 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.
  • 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.

Installation

If yarn is not installed in your system, please install it first. If you want to use yarn 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):

"workspaces": [
  "packages/*"
]

Add oao to your development dependencies (use the -W flag to avoid Yarn's warning when installing dependencies on the monorepo root):

$ yarn add oao --dev -W

Usage

To see all CLI options, run oao --help:

Usage: oao [options] [command]

Options:

  -V, --version  output the version number
  -h, --help     output usage information

Commands:

  status [options]                               Show an overview of the monorepo status
  bootstrap [options]                            Install external dependencies and create internal links
  clean [options]                                Delete all node_modules directories from sub-packages and the root package
  add [options] <sub-package> <packages...>      Add dependencies to a sub-package
  remove [options] <sub-package> <packages...>   Remove dependencies from a sub-package
  upgrade [options] <sub-package> [packages...]  Upgrade some/all dependencies of a package
  outdated [options]                             Check for outdated dependencies
  prepublish [options]                           Prepare for a release: validate versions, copy READMEs and package.json attrs
  publish [options]                              Publish updated sub-packages
  reset-all-versions [options] <version>         Reset all versions (incl. monorepo package) to the specified one
  all [options] <command>                        Run a given command on all sub-packages
  run-script [options] <command>                 Run a given script on all sub-packages

You can also get help from particular commands, which may have additional options, e.g. oao publish --help:

Usage: publish [options]

Publish all (non-private) sub-packages

Options:

-s --src <glob>                                           glob pattern for sub-package paths [packages/*] (default: "packages/*")
-i --ignore-src <glob>                                    glob pattern for sub-package paths that should be ignored
-l --link <regex>                                         regex pattern for dependencies that should be linked, not installed
--single                                                  no subpackages, just the root one
--relative-time                                           shorten log dates
--no-master                                               allow publishing from a non-master or non-main branch
--no-check-uncommitted                                    skip uncommitted check
--no-check-unpulled                                       skip unpulled check
--no-checks                                               skip all pre-publish checks
--no-bump                                                 do not increment version numbers (also disables git commit)
--no-confirm                                              do not ask for confirmation before publishing
--no-git-commit                                           skip the commit-tag-push step before publishing
--no-npm-publish                                          skip the npm publish step
--new-version <version>                                   use this version for publishing, instead of asking
--increment-version-by <major|minor|patch|rc|beta|alpha>  increment version by this, instead of asking
--publish-tag <tag>                                       publish with a custom tag (instead of `latest`)
--changelog-path <path>                                   changelog path [CHANGELOG.md] (default: "CHANGELOG.md")
--no-changelog                                            skip changelog updates
--otp <code>                                              use 2-factor authentication to publish your package
--access <type>                                           publish public or restricted packages
-h, --help                                                output usage information

Main commands

In recent versions of npm, remember that you can run oao commands conveniently with the npx tool:

$ npx oao bootstrap
$ npx oao add my-subpackage my-new-dependency --dev
$ npx oao publish

This uses the local oao package inside your monorepo.

oao status

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).

oao status

oao bootstrap

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 linked. Note that dependencies may end up in different places depending on whether you use yarn workspaces or not (see above).

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.

oao clean

Removes node_modules directories from all sub-packages, as well as from the root package.

oao add <sub-package> <deps...>

Adds one or several dependencies to a sub-package. For external dependencies, it passes through yarn add's flags. Internal dependencies are linked. Examples:

$ oao add subpackage-1 jest --dev
$ oao add subpackage-2 react subpackage-1 --exact

oao remove <sub-package> <deps...>

Removes one or several dependencies from a sub-package. Examples:

$ oao remove subpackage-1 jest
$ oao remove subpackage-2 react subpackage-1

oao remove-all <deps...>

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:

$ oao remove-all leftpad
$ oao remove-all leftpad rightpad centerpad

oao upgrade <sub-package> [deps...]

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:

$ oao upgrade subpackage-1 jest@18.0.1
$ oao upgrade subpackage-2 react subpackage-1@3.1.2
$ oao upgrade subpackage-3

oao bump <deps...>

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:

$ oao bump moment
$ oao bump react@^16 react-dom@^16
$ oao bump subpackage-2

oao outdated

Runs yarn outdated on all sub-packages, as well as the root package.

oao prepublish

Carries out a number of chores that are needed before publishing:

  • Checks that all version numbers are valid and <= the master version.
  • Copies <root>/README.md to the main sub-package (the one having the same name as the monorepo).
  • Copies <root>/README-LINK.md to all other sub-packages.
  • Copies several fields from the root package.json to all other package.json files: description, keywords, author, license, homepage, bugs, repository.

oao publish

Carries out a number of steps:

  • Asks the user for confirmation that it has built all sub-packages for publishing (using something like yarn build).
  • Performs a number of checks:
    • The current branch should be master or main.
    • No uncommitted changes should remain in the working directory.
    • No unpulled changes should remain.
  • Determines which sub-packages need publishing (those which have changed with respect to the last tagged version).
  • 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.
  • Asks the user for final confirmation before publishing.
  • Updates versions in package.json files, commits the updates, adds a tag and pushes all the changes.
  • Publishes updated sub-packages.

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.

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.

oao all <command>

Executes the specified command on all sub-packages (private ones included), with the sub-package's root as current working directory. Examples:

$ oao all ls
$ oao all "ls -al"
$ oao all "yarn run compile"
$ oao all --tree "yarn run compile"

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:

$ oao all "yarn run compileWatch" --parallel

Note: some terminals may have problems with parallel logs (based on 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.

Use --tree if you want to follow the inverse dependency tree (starting from the tree leaves).

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.

oao run-script <script>

Similar to oao all <command>, it executes the specified (package) script on all sub-packages. Missing scripts will be skipped. Examples:

$ oao run-script start
$ oao run-script start --parallel
$ oao run-script start --tree

By default, oao run-script runs sequentially. Use --parallel to run the scripts in parallel, and --tree if you want to follow the inverse dependency tree (starting from the tree leaves).

You can also run all scripts matching a given glob pattern: oao run-script test:*.

Credits :clap:

  • lerna: for general inspiration.
  • yarn: for a fast, secure and reliable way to do dependency management.
  • np: for the prepublish checks.

Why oao? :sunglasses:

Basically, many other names I could come up with were either too boring (mono-repo), or already taken. oao stands for one and only :grimacing:, which is a reference to the individual nature of monorepos, as well as a beautiful song by Adele. Yes, I agree it's far-fetched, but extremely short and convenient!

Changelog :scroll:

License (MIT) :books:

Copyright (c) Guillermo Grau Panea 2017-now

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

更新履歴

2.0.2 (2021-4-18)

  • Bump shelljs (avoids lots of warnings when running various OAO commands).

2.0.1 (2021-2-7)

  • Bump storyboard.

2.0.0 (2020-7-25)

  • Breaking: Always publishes all (non-private) sub-packages, irrespective of whether they have been updated.
  • 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).
  • oao publish now always publishes in reverse-dependency order (jeroenptrs, #102).

1.10.0 (2020-6-26)

  • Allow 2-factor auth when publishing (jeroenptrs, #99).
  • Allow publishing scoped packages publicly (jeroenptrs, #99).

1.9.0 (2020-6-24)

  • Allow publishing from the main branch by default, in addition to master (jeroenptrs, #98).

1.8.0 (2020-1-28)

  • Limit parallelLimit by number of cpus by default (SimenB, #92).

1.7.0 (2019-8-13)

  • Add --no-bump for oao publish, useful in CI/CD environments (#83).

1.6.1 (2019-8-11)

  • Bump dependencies. Remove @babel/polyfill since it's not needed in Node 6+.

1.6.0 (2019-2-20)

  • Add oao remove-all (removes a dependency throughout the monorepo) (#80).

1.5.1 (2018-3-21)

  • Fix bug in oao all and oao run-script which caused incorrect serial execution (#72).

1.5.0 (2018-3-19)

  • Add oao bump (upgrades a dependency across all sub-packages) (#28).

1.5.0-beta.0 (2018-3-14)

  • Add --parallel-limit <#processes> to oao all and oao run-script, to limit concurrency when running things in parallel (#69).
  • 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).
  • oao run-script: add the possibility to generate more than one job per subpackage (e.g. oao run-script test:*) (#70).

1.4.1 (2018-3-12)

  • Fix issues caused by new yarn workspaces semantics (#71, #67).

1.4.0 (2018-2-16)

  • Add --relative-time to all commands, shortening the date column in logs by 14 characters (#64).

1.3.1 (2018-2-13)

  • Add --no-checks for oao publish (removes all prepublish checks), useful in some cases (#62).

1.3.0 (2018-2-13)

  • Add support for extra arguments in oao all, e.g. oao all ls -- -al is now equivalent to oao all 'ls -al' (#61).

1.2.1 (2017-11-24)

  • Remove subpackage prefix in logs generated with oao all and oao run-script when not running in parallel.

1.2.0 (2017-11-24)

  • Improve error logging with oao all and oao run-script in parallel mode -- re-print the whole stderr contents at the end (#57).
  • Add subpackage prefix to all logs in oao all and oao run-script (related to #57).

1.1.0 (2017-11-24)

  • Add --tree to oao all and oao run-script (follows dependency tree, starting with the tree leaves and going upwards) (closes issue #58).

1.0.0 (2017-11-11)

  • Bump to 1.0.0. No breaking changes expected (at least not so often).

0.10.5 (2017-11-11)

  • Add oao run-script (#55, @kevroadrunner).

0.10.4 (2017-10-10)

  • Log error code when external command fails and prevent some log redundancy (#52).

0.10.3 (2017-10-6)

  • Improve error detail when running oao status and some package has an invalid name in its package.json (#40).

0.10.2 (2017-10-6)

0.10.1 (2017-9-13)

  • Bugfix: in oao add|remove|upgrade, fix handling of scoped packages (#45).

0.10.0 (2017-8-23)

0.10.0-beta.3 (2017-8-18)

  • Add support for non-monorepo publishing Use the oao publish --single to indicate that your root package is not a monorepo, and you can benefit from oao's features even in normal packages: publishing checks, automatic tagging, interactive version selection, etc.

0.10.0-beta.2 (2017-8-17)

0.10.0-beta.1 (2017-8-16)

  • Add support for yarn workspaces. This mode is enabled automatically when the root package.json has a workspaces field, which overrides any other src option.

0.9.0 (Jul. 15, 2017)

  • Experimentally add the possibility to specify some config options in package.json (#47).

0.8.5 (Jun. 16, 2017)

  • Add --increment-version-by option for oao publish. This allows setting the next version automatically, e.g. in a continuous deployment scheme (#41).
  • Add prettier.

0.8.4 (Jun. 16, 2017)

  • Bugfix: in parallel oao bootstrap, recover original subpackage package.json files always, even if one of the subpackages fails to install (#42).

0.8.3 (Jun. 15, 2017)

  • Parallelize oao bootstrap -- substantially improved performance (#42).
  • Add support for --frozen-lockfile, --pure-lockfile and --no-lockfile flags in oao bootstrap (see Yarn documentation) (#43).

0.8.2 (Apr. 14, 2017)

  • Bump deps

0.8.1 (Apr. 3, 2017)

  • Add --ignore-src <glob> option to all commands to exclude sub-packages (#38).
  • Add warning to oao oudated for internal deps that do not meet the specified version range (#34).

0.8.0 (Mar. 8, 2017)

  • Rename --version option (incompatible with commander's default option') to --new-version (#35).
  • During oao publish, automatically update the changelog with the new version and release date.
  • Add --no-npm-publish option to oao publish to prevent accidental publishing on npm of parts of an all-private monorepo.
  • During oao publish, also update the versions of private sub-packages that have changed.

0.7.3 (Mar. 4, 2017)

  • Add more granular configuration options for oao publish: --no-check-uncommitted, --no-check-unpulled, --no-git-commit (#29).
  • Add --version <new-version> option to oao publish (overrides manual version specification) (#30).

0.7.2 (Mar. 1, 2017)

  • When executing a command, inhibit stdin access on Windows (see this and this).

0.7.1 (Feb. 28, 2017)

  • Add oao clean to remove all node_modules directories in sub-packages.
  • Provide more explicit errors when unhandled rejections occur.
  • Add --no-confirm option to oao reset-all-versions (#26).
  • Extract Parallel Console (now published as storyboard-listener-console-parallel under the Storyboard monorepo).

0.7.0 (Feb. 27, 2017)

  • Add support for internal links in oao add|remove|upgrade (#17).
  • Add support for oao add|remove|upgrade on the root package (use either . or ROOT as package name).

0.6.1 (Feb. 26, 2017)

  • Remove extra blank lines (above the fold) caused when clearing the terminal in parallel logs (#18).
  • Show help when user enters no valid command.

0.6.0 (Feb. 25, 2017)

  • Also process the monorepo root during oao bootstrap, including links to sub-packages (if any) (#24).
  • Modify oao status so that it provides more accurate information (e.g. in git repos with no tags, no upstream, etc.) (#23).
  • Warn during oao bootstrap when linked package version does not satisfy the required range (#25).

0.5.7 (Feb. 24, 2017)

  • Add oao outdated: runs yarn outdated on all sub-packages and the root package, taking care that internal and custom links are omitted.
  • Add --production option to oao bootstrap: skip external and internal development-only dependencies (also available by setting the NODE_ENV environment variable to production) (#19). See also discussion in #16.
  • Filter sub-package paths, keeping only those that contain a package.json file (#20).

0.5.6 (Feb. 23, 2017)

  • Allow --src pattern to have a trailing slash (optional).
  • Other minor tweaks.

0.5.5 (Feb. 22, 2017)

  • Add parallel logging in oao all (can be disabled using the --no-parallel-logs option) (#10).

0.5.4 (Feb. 21, 2017)

  • Add parallel support to oao all, using the --parallel and --ignore-errors options (#10, #13).
  • Bugfix: filter out non-directory paths from globby results (#11).

0.5.3 (Feb. 20, 2017)

  • Add oao status: provides lots of information on the monorepo.
  • Add --link <regex> option to force some packages to be linked, not installed (useful in some development environments). Used in oao bootstrap and oao add|remove|upgrade.
  • Add --ignore-engines option to oao upgrade (passed through to Yarn).
  • Add --copy-attrs option to oao prepublish (attributes that are copied to the sub-package's package.json file).

0.5.2 (Feb. 16, 2017)

  • Add tentative support for scoped packages (#7).
  • Internal:
    • Add unit tests.
    • Add static types (Flow).

0.5.1 (Feb. 15, 2017)

  • Add oao upgrade <sub-package> [deps...].
  • Add unit tests, Travis, Coveralls.

0.5.0 (Feb. 14, 2017)

  • Add oao add <sub-package> <deps...>.
  • Add oao remove <sub-package> <deps...>.
  • Bump storyboard yet again (some warnings remained).
  • Fix missing newlines at the end of package.json files (#3).

0.4.1 (Feb. 13, 2017)

  • Bump storyboard (prevents "unmet peer dependency" during installation).

0.4.0 (Feb. 12, 2017)

  • Greatly reduce the number of oao dependencies by bumping storyboard to v3 (prerelease).
  • Add --publish-tag <tag> option to oao publish: (publishes with a custom tag, instead of latest).

0.3.3 (Feb. 12, 2017)

  • Fix bad repo links in package.json.

0.3.2 (Feb. 12, 2017)

  • Bugfixes:
    • Fix prerelease version updates.
    • Move babel-polyfill to dependencies (#2).
    • Prevent normal git push output from being shown as errors.

0.3.0, 0.3.1 (Feb. 12, 2017)

  • Add options to oao publish:
    • --no-master (allow publishing from non-master branches).
    • --no-confirm (skip confirmation steps).

0.2.0 (Feb. 10, 2017)

  • Automatically detect updated packages, allow user selection of major/minor/patch/prerelease increment, commit, tag, push and publish.
  • Allow custom package directories.
  • Improve docs.

0.1.0 (Feb. 9, 2017)

  • First public release.