Skip to content

Commit

Permalink
Add pnpm-sync-dependencies-meta-injected
Browse files Browse the repository at this point in the history
  • Loading branch information
ynotdraw committed Jun 27, 2023
1 parent e9a79ae commit 8d05e67
Show file tree
Hide file tree
Showing 11 changed files with 816 additions and 343 deletions.
6 changes: 6 additions & 0 deletions .changeset/lovely-plums-kneel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@crowdstrike/ember-toucan-form': patch
'@crowdstrike/ember-toucan-core': patch
---

(internal) Updated repo to use [pnpm-sync-dependencies-meta-injected](https://github.com/NullVoxPopuli/pnpm-sync-dependencies-meta-injected) to make local development easier. To develop in the repo, run `pnpm start`.
89 changes: 20 additions & 69 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
- [Clone the repo](#clone-the-repo)
- [Install dependencies](#install-dependencies)
- [Adding components](#adding-components)
- [Running the docs/test-app](#running-the-docstest-app)
- [Viewing changes in the docs/test-app](#viewing-changes-in-the-docstest-app)
- [Developing](#developing)
- [Tests](#tests)
- [Documentation](#documentation)
- [VS Code setup](#vscode-setup)
Expand Down Expand Up @@ -48,83 +47,35 @@ A few things to remember:
2. When adding a new component, it needs to be added to the template registry so Glint picks it up.
To do that, add a line in `packages/ember-toucan-core/src/template-registry.ts`.

## Viewing changes in the docs/test-app
## Developing

For the time being you can use `pnpm link` to create a symlink between the addon and the apps.
This will allow you to make a change in the addon and immediately see the change in the app rather than having to stop the app, rebuild, resync dependencies, etc.
To develop in this monorepo you can simply run:

There are two ways to do this:
- `pnpm start`

### Option 1: run the Bash script
from the root directory.

In the root of the repo, run:
This will:

```bash
./local-setup.bash
```

This will run a Bash script, where you can choose to install and symlink.

You will also have the option of deleting the turbo repo, and/or deleting the `node_modules`, `dist`, and `tsc` cache.
But running these takes longer.
- Build all of the `packages/*` and watch them for changes
- Build the docs app and the tests app and serve them
- Automatically sync changes from the `packages/*` to the served apps so
that they are always up to date.

### Option 2: symlink manually
You can now visit:

```bash
# 1. Create a symlink in the ember-toucan-core addon
cd packages/ember-toucan-core
pnpm build
pnpm link .

# 2. Create a symlink in the forms addon (required even if you aren't using it)
cd ../ember-toucan-form
pnpm link @crowdstrike/ember-toucan-core # need to link this because ember-toucan-forms depends on it
pnpm build
pnpm link .

# 3. Link ember-toucan-core docs-app
cd ../../docs-app
pnpm link @crowdstrike/ember-toucan-core # note @crowdstrike here
pnpm link @crowdstrike/ember-toucan-form # note @crowdstrike here
pnpm i

The test-app also needs to link `ember-toucan-form`.

# 4. Link ember-toucan-core to the test-app
cd ../test-app
pnpm link @crowdstrike/ember-toucan-core # note @crowdstrike here
pnpm link @crowdstrike/ember-toucan-form # note @crowdstrike here
pnpm i
```
- The docs app at http://localhost:4201/
- The tests app at http://localhost:4200/tests

Now the docs-app and addon are linked!
Now you'll want to run the addon in watch mode so that it auto-rebuilds and run the docs-app separately.

```bash
# In one terminal
cd packages/ember-toucan-core
pnpm start
# ember-toucan-core is now in watch mode and will rebuild automatically


# In a second terminal, `cd` to the root of the repo
cd <root-of-repo>
pnpm start:docs # using turbo here

# In a third terminal, `cd` to the test-app
cd <root-of-repo>/test-app
pnpm start # and then `cd` to /tests

# IF you are making changes in ember-toucan-form, start a fourth terminal
cd packages/ember-toucan-form
pnpm start
```
If you don't need to run both apps you can save a little of your local
compute by running:

When making a change in `ember-toucan-core`, the docs-app should now refresh and you should see your changes.
- `start:docs-app` and visiting http://localhost:4201/
- `start:test-app` and visiting http://localhost:4200/tests

⚠️ **NOTE**: Upon linking, you will notice changes in each `package.json` and the `pnpm-lock.yaml` file.
You **do not** want to check these changes in.
Please discard them or ignore them when committing!
These commands will still build and watch the `packages/*` and sync changes
to the running app. Don't run both `only` tasks together as this will cause
issues - if you want to run both apps simply use `pnpm start`.

## Tests

Expand Down
5 changes: 2 additions & 3 deletions docs-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
"lint:hbs:fix": "ember-template-lint . --fix --no-error-on-unmatched-pattern",
"lint:js:fix": "eslint . --fix",
"lint:types": "glint",
"start": "ember serve",
"start": "concurrently 'ember serve' 'pnpm _syncPnpm --watch' --names 'docs-app serve,docs-app sync built package'",
"test:ember": "ember test",
"_syncPnpm": "pnpm sync-pnpm"
"_syncPnpm": "pnpm sync-dependencies-meta-injected"
},
"devDependencies": {
"@babel/core": "^7.19.6",
Expand Down Expand Up @@ -114,7 +114,6 @@
"prettier-plugin-tailwindcss": "^0.3.0",
"qunit": "^2.19.1",
"qunit-dom": "^2.0.0",
"sync-pnpm": "workspace:*",
"tailwindcss": "^3.1.8",
"typescript": "^5.0.0",
"validated-changeset": "^1.3.4",
Expand Down
3 changes: 0 additions & 3 deletions internal/sync-pnpm/bin/sync-pnpm.js

This file was deleted.

52 changes: 0 additions & 52 deletions internal/sync-pnpm/index.js

This file was deleted.

19 changes: 0 additions & 19 deletions internal/sync-pnpm/package.json

This file was deleted.

116 changes: 0 additions & 116 deletions local-setup.bash

This file was deleted.

15 changes: 9 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "[email protected]:CrowdStrike/ember-toucan-core.git",
"directory": "ember-toucan-core"
},
"engines" : {
"engines": {
"node": ">=16",
"pnpm": ">=7.24.2 <7.33.0"
},
Expand All @@ -23,22 +23,25 @@
"scripts": {
"release": "changeset publish",
"build:docs": "pnpm turbo build --filter docs-app",
"start": "pnpm start:tests",
"start:docs": "pnpm turbo --filter docs-app start",
"start:tests": "pnpm turbo --filter test-app start",
"start:addon": "pnpm --filter !test-app start --no-watch.clearScreen",
"start": "pnpm --filter './packages/*' build; concurrently 'npm:_start:*' --names '_start:'",
"start:docs-app": "pnpm --filter './packages/*' build; pnpm --stream --parallel --filter docs-app... start",
"start:test-app": "pnpm --filter './packages/*' build; pnpm --stream --parallel --filter test-app... start",
"build": "pnpm turbo build",
"test": "pnpm turbo --filter test-app test",
"test:docs": "pnpm turbo --filter docs-app test",
"lint": "pnpm turbo lint",
"lint:fix": "pnpm --filter '*' lint:fix",
"format": "pnpm --filter '*' format",
"format:check": "pnpm --filter '*' format:check"
"format:check": "pnpm --filter '*' format:check",
"_start:docs": "pnpm --filter docs-app start",
"_start:tests": "pnpm --filter test-app start",
"_start:packages": "pnpm --stream -parallel --filter './packages/*' start --no-watch.clearScreen"
},
"devDependencies": {
"@changesets/changelog-github": "^0.4.8",
"@changesets/cli": "^2.26.0",
"concurrently": "^8.0.0",
"pnpm-sync-dependencies-meta-injected": "^0.0.8",
"prettier": "^2.8.3",
"turbo": "^1.8.8"
},
Expand Down
3 changes: 1 addition & 2 deletions packages/ember-toucan-form/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"prepack": "rollup --config",
"format:check": "prettier -c .",
"format": "prettier -w .",
"_syncPnpm": "pnpm sync-pnpm"
"_syncPnpm": "pnpm sync-dependencies-meta-injected"
},
"peerDependencies": {
"@crowdstrike/ember-toucan-core": "^0.2.0",
Expand Down Expand Up @@ -105,7 +105,6 @@
"rollup": "^3.12.1",
"rollup-plugin-copy": "^3.4.0",
"rollup-plugin-ts": "^3.0.2",
"sync-pnpm": "workspace:*",
"tailwindcss": "^2.2.15",
"typescript": "^5.0.0"
},
Expand Down
Loading

0 comments on commit 8d05e67

Please sign in to comment.