Init link helper to work on a project outside of the workspace

This commit is contained in:
Alexandre Bodin 2019-06-08 01:32:37 +02:00
parent 649df34583
commit 41b9a72e95
2 changed files with 25 additions and 15 deletions

View File

@ -1,15 +0,0 @@
# The Strapi monorepo
Juggling a multimodule project over multiple repos is pretty difficult for contributing.
Strapi follows a monorepo approach, all officially maintained modules are in the same repository-- this one.
Pros:
- Single lint, build, test and release process.
- Easy to coordinate changes across modules.
- Single place to report issues and track milestones.
- Easier to setup a development environment.
Cons:
- Codebase looks more intimidating.
- Repo is bigger in size.

25
scripts/link.js Normal file
View File

@ -0,0 +1,25 @@
const { join } = require('path');
const execa = require('execa');
const fs = require('fs-extra');
const { promisify } = require('util');
const glob = promisify(require('glob').glob);
async function run() {
const packageDirs = await glob('packages/*');
console.log('Linking all packages');
const packages = packageDirs.map(dir => ({
dir,
pkgJSON: fs.readJSONSync(join(dir, 'package.json')),
}));
await Promise.all(
packages.map(({ dir }) => execa('yarn', ['link'], { cwd: dir }))
);
const packageNames = packages.map(p => p.pkgJSON.name).join(' ');
console.log(`Package names: \n ${packageNames}\n`);
}
run().catch(err => console.error(err));