Skip to content
This repository has been archived by the owner on Oct 18, 2023. It is now read-only.

Commit

Permalink
Merge pull request #31 from Financial-Times/matth/support-workspaces
Browse files Browse the repository at this point in the history
Support Yarn style workspaces configuration
  • Loading branch information
i-like-robots authored Feb 18, 2019
2 parents d7f3733 + 2e62d18 commit 9a34528
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 10 deletions.
28 changes: 23 additions & 5 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ Athloi is a tool to assist with the management of multi-package repositories (a.

[monorepos]: https://github.com/babel/babel/blob/master/doc/design/monorepo.md


## Features

- Provides a number of helpers to improve your monorepo workflow such as: installing all dependencies, running npm or custom scripts, publishing public packages, updating version numbers, etc.
- Capable of running tasks serially or in parallel whilst preserving topological sort order between cross-dependent packages.
- Options to filter the packages to target either by name or `package.json` field
- Works well with Yarn workspaces.


## Getting Started

Start by installing Athloi within your project using [npm].
Expand All @@ -14,18 +23,27 @@ npm install --save-dev @financial-times/athloi

[npm]: https://www.npmjs.com/

Configuration can be passed to Athloi by providing a `monorepo.json` file in your repository root. This must include a `packages` property which is a list of [globs] matching the directories containing your packages.
Next you must configure where Athloi should look for the directories containing your packages. To do this you can either create a new `monorepo.json` file in your repository root or add an extra property to your root `package.json` file.

When using a `monorepo.json` file you need to specify a `packages` property which is an array of [globs] matching the your package directories. This is similar to tools like [Lerna].

```json
{
"packages": ["components/*", "tools/*"]
}
```

Alternatively, you can add a `workspaces` property to your existing `package.json` file which is also an array of [globs] matching your package directories. This is compatible with [Yarn].

```json
{
"packages": [
"components/*",
"tools/*"
]
"workspaces": ["components/*", "tools/*"]
}
```

[globs]: https://en.wikipedia.org/wiki/Glob_(programming)
[Lerna]: https://lernajs.io/
[Yarn]: https://yarnpkg.com/en/


## Commands
Expand Down
2 changes: 1 addition & 1 deletion src/cli-task.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module.exports = (task) => {
const config = await loadConfig();

// 2. find all packages by path and create package instances
const packages = await loadPackages(config.packages);
const packages = await loadPackages(config);

// 3. filter packages to run in based on filter option
const filteredPackages = filterPackages(globals.filter, packages);
Expand Down
21 changes: 17 additions & 4 deletions src/load-config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
const findUp = require('find-up');

module.exports = async () => {
const config = await findUp('monorepo.json');
const [ monorepo, manifest ] = await Promise.all([
findUp('monorepo.json'),
findUp('package.json')
]);

if (!config) {
throw Error('Could not find monorepo.json');
// Lerna style configuration file
if (monorepo) {
return require(monorepo).packages;
}

return require(config);
// Yarn workspaces style configuration
if (manifest) {
const pkg = require(manifest);

if (Array.isArray(pkg.workspaces)) {
return pkg.workspaces;
}
}

throw Error('Could not find any Athloi configuration');
};

0 comments on commit 9a34528

Please sign in to comment.