Skip to content

Commit

Permalink
0.4.4; remove pnpm options that were never applied
Browse files Browse the repository at this point in the history
  • Loading branch information
aruniverse committed Apr 20, 2022
1 parent 7ec3f94 commit d051ca5
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 42 deletions.
53 changes: 23 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,35 @@ Setup a `CoSpace` to link multiple (mono)repos together!

## Getting started

1. Install `cospace`, then run `npx cospace init`
### Initialize

1. Clone all the repos you want to link together under the `repos` directory. You can use [sparse checkouts](https://github.blog/2020-01-17-bring-your-monorepo-down-to-size-with-sparse-checkout/) to only clone the directories you need.
```bash
npx cospace@latest init my-cospace
```

### Link your (mono)repos

```bash
cd my-cospace
```

1. Clone all the repos you want to link together under the `repos` sub directory.

1. Update the `pnpm-workspace.yaml` file with all the packages you want to add to your `CoSpace`. By default all packages under the `repos` sub directory will be added to your `CoSpace`; you will probably want to be more specific and build/link only what you need.

1. Update the `cospace.code-workspace` file with all the repos you want to add to your [vscode multi-root workspace](https://code.visualstudio.com/docs/editor/multi-root-workspaces).

1. Update the [pnpm-workspace.yaml](pnpm-workspace.yaml) file with all the packages you want to add to your CoSpace.
1. Run `pnpm exec cospace override` to automatically update the `pnpm.overrides` section of the `CoSpace`'s `package.json`, to link all the dependencies together with the copy found in the workspace. This will ignore [semver](https://semver.org/) and always use the local package version from the workspace, very useful for when you have pre-release versions of packages in your workspace.

1. Update the [cospace.code-workspace](cospace.code-workspace) file with all the repos you want to add to your VsCode multi root workspace.
1. Run `pnpm install` to install all dependecies in your workspace and link all the packages you've added to your `CoSpace`.

1. (Optional) Run `pnpm setOverrides` to automatically update the `pnpm.overrides` section of the CoSpace's [package.json](package.json), to use the local package version from the workspace, disregarding semver. Useful for when you have pre-release versions of packages in your workspace.
1. Run `pnpm build` to build all the packages you've added to your `CoSpace` using your monorepo task runner. By default we use [lage](https://microsoft.github.io/lage/), but [turborepo](https://turborepo.org/docs) should work as well.

1. Run `pnpm install` to install all the packages you've added to your CoSpace.
For more information visit the <a href="https://aruniverse.github.io/cospace/" target="_blank">docs site</a>.

1. Run `pnpm build` to build all the packages you've added to your CoSpace using your monorepo task runner. I'm using [lage](https://microsoft.github.io/lage/), but [turborepo](https://turborepo.org/docs) should theoretically work.
## example usage

- <a href="https://github.com/aruniverse/itwin-cospace" target="_blank">itwin-cospace</a>, an example of a `CoSpace` to help develop with the iTwin Platform.

## Notes

Expand All @@ -44,26 +60,3 @@ git checkout {branchName}
git sparse-checkout init --cone
git sparse-checkout set [...allSubDirs]
```

### pnpm

#### [link-workspace-packages](https://pnpm.io/workspaces#link-workspace-packages)

- "If you need local packages to also be linked to subdependencies, you can use the `deep` setting"

```json
"pnpm": {
"link-workspace-packages": "deep"
}
```

#### [prefer-workspace-packages](https://pnpm.io/workspaces#prefer-workspace-packages)

- pros: don't have to explicitly list all packages in the `pnpm.overrides` section.
- cons: if you're linking a repo with HEAD pointing to pre-release packages, those won't be used/linked due to semver 😕

```json
"pnpm": {
"prefer-workspace-packages": true
}
```
7 changes: 3 additions & 4 deletions cli/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env node

import { fileURLToPath } from "url";
import * as path from "path";
import path from "path";
import fs from "fs-extra";
import meow from "meow";
import { execSync } from "child_process";
Expand All @@ -10,7 +10,7 @@ const Commands = {
INIT: "init",
OVERRIDE: "override",
PURGE: "purge",
}
};

const help = `
Usage:
Expand Down Expand Up @@ -113,11 +113,10 @@ const overridePnpm = async () => {
if (added.length) {
console.log(
`\nYou added the following packages to your CoSpace:\n- ${added.join(
"\n- "
"\n+ "
)}`
);
}

};

const purge = async () => {
Expand Down
9 changes: 7 additions & 2 deletions cli/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"name": "cospace",
"version": "0.4.3",
"version": "0.4.4",
"description": "Setup a `CoSpace` to link multiple (mono)repos together!",
"author": "https://github.com/aruniverse",
"homepage": "https://aruniverse.github.io/cospace/",
"license": "MIT",
"repository": {
"type": "git",
Expand All @@ -20,7 +21,11 @@
"cospace",
"monorepo",
"pnpm",
"workspaces"
"workspace",
"workspaces",
"link",
"symlinks",
"dependencies"
],
"dependencies": {
"fs-extra": "^10.0.0",
Expand Down
4 changes: 1 addition & 3 deletions cli/template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
"lage": "^1.5.1"
},
"pnpm": {
"overrides": {},
"prefer-workspace-packages": true,
"link-workspace-packages": "deep"
"overrides": {}
}
}
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
"pnpm": {
"overrides": {
"cospace": "workspace:*"
},
"prefer-workspace-packages": true,
"link-workspace-packages": "deep"
}
}
}
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d051ca5

Please sign in to comment.