Skip to content

Commit 30bba1f

Browse files
authored
chore(repo): Add yarn yalc:publish scripts (#7502)
Add a new yarn script to all SDK packages: `yalc:publish`. This script will publish locally built SDK packages to a local [yalc](https://github.com/wclr/yalc) repository which we can use as an alternative to `yarn link` for using our SDKs locally in test projects.
1 parent 4a6256e commit 30bba1f

File tree

25 files changed

+131
-24
lines changed

25 files changed

+131
-24
lines changed

CONTRIBUTING.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@ Since we are using [`TypeScript`](https://www.typescriptlang.org/), you need to
3333
- `yarn build:dev:filter <name of npm package>`, which runs `yarn build:dev` only in projects relevant to the given package (so, for example, running `yarn build:dev:filter @sentry/react` will build the `react` package, all of its dependencies (`utils`, `core`, `browser`, etc), and all packages which depend on it (currently `gatsby` and `nextjs`))
3434
- `yarn build:dev:watch`, which runs `yarn build:dev` in watch mode (recommended)
3535

36+
37+
## Testing SDK Packages Locally
38+
39+
To test local versions of SDK packages, for instance in test projects, you have a couple of options:
40+
41+
* Use [`yarn link`](https://classic.yarnpkg.com/lang/en/docs/cli/link/) to symlink your package to the test project.
42+
* Use [`yalc` to install SDK packages](./docs/using-yalc.md) as if they were already published.
43+
* Run `build:tarball` in the repo and `yarn add ./path/to/tarball.tgz` in the project.
44+
3645
## Adding Tests
3746

3847
**Any nontrivial fixes/features should include tests.** You'll find a `test` folder in each package.

docs/using-yalc.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Using `yalc` for Local SDK Testing
2+
3+
[Yalc](https://github.com/wclr/yalc) is a simple local dependency repository which we can use to work with local versions of our SDKs.
4+
This is a good alternative to `npm|yarn link` for packages where linking is problematic (e.g. SvelteKit or Angular).
5+
6+
Here's how to set up and use yalc:
7+
8+
## Installing `yalc`
9+
10+
Either install yalc globally,
11+
12+
```sh
13+
npm install -g yalc
14+
15+
yarn global add yalc
16+
```
17+
18+
or add it to your desired test projects (same command without the `-g|global` flags)
19+
20+
## Registering/Updating packages
21+
22+
Whenever you want to make your local changes available to your test projects (e.g. after a local code change), run:
23+
24+
```sh
25+
yarn yalc:publish
26+
```
27+
28+
If you run this command in the root of the repo, this will publish all SDK packages to the local yalc repo. If you run it in a specific SDK package, it will just publish this package. You **don't need to** call `yalc update` in your test project. Already linked test projects will be update automatically.
29+
30+
## Using yalc packages
31+
32+
In your test project, run
33+
34+
```sh
35+
yalc add @sentry/browser #or any other SDK package
36+
```
37+
38+
to add the local SDK package to your project.
39+
40+
**Important:** You need to `yalc add` the dependencies of the SDK package as well (e.g. core, utils, types, etc.).
41+
42+
## Troubleshooting:
43+
44+
### My changes are not applied to the test project
45+
46+
Did you run `yarn build && yarn publish:yalc` after making your changes?
47+
48+
### My test project uses Vite and I still don't see changes
49+
50+
Vite pre-bundles and caches dependencies for dev builds. It [doesn't recognize changes in yalc packages though](https://github.com/wclr/yalc/issues/189) :( To make these changes show up anyway, run `vite dev --force`.
51+

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
"test:unit": "lerna run --ignore @sentry-internal/* test:unit",
2929
"test-ci-browser": "lerna run test --ignore \"@sentry/{node,opentelemetry-node,serverless,nextjs,remix,gatsby}\" --ignore @sentry-internal/*",
3030
"test-ci-node": "ts-node ./scripts/node-unit-tests.ts",
31-
"test:update-snapshots": "lerna run test:update-snapshots"
31+
"test:update-snapshots": "lerna run test:update-snapshots",
32+
"yalc:publish": "lerna run yalc:publish"
3233
},
3334
"volta": {
3435
"node": "16.19.0",
@@ -117,7 +118,8 @@
117118
"tslib": "^2.3.1",
118119
"typedoc": "^0.18.0",
119120
"typescript": "3.8.3",
120-
"vitest": "^0.29.2"
121+
"vitest": "^0.29.2",
122+
"yalc": "^1.0.0-pre.53"
121123
},
122124
"resolutions": {
123125
"**/agent-base": "5"

packages/angular-ivy/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@
5656
"fix:prettier": "prettier --write \"{src,test,scripts}/**/**.ts\"",
5757
"lint": "run-s lint:prettier lint:eslint",
5858
"lint:eslint": "eslint . --format stylish",
59-
"lint:prettier": "prettier --check \"{src,test,scripts}/**/**.ts\""
59+
"lint:prettier": "prettier --check \"{src,test,scripts}/**/**.ts\"",
60+
"yalc:publish": "ts-node ../../scripts/prepack.ts && yalc publish build --push"
6061
},
6162
"volta": {
6263
"extends": "../../package.json"

packages/angular/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@
5959
"lint:prettier": "prettier --check \"{src,test,scripts}/**/**.ts\"",
6060
"test": "yarn test:unit",
6161
"test:unit": "jest",
62-
"test:unit:watch": "jest --watch"
62+
"test:unit:watch": "jest --watch",
63+
"yalc:publish": "ts-node ../../scripts/prepack.ts && yalc publish build --push"
6364
},
6465
"volta": {
6566
"extends": "../../package.json"

packages/browser/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@
7575
"test:integration:checkbrowsers": "node scripts/checkbrowsers.js",
7676
"test:package": "node test/package/npm-build.js && rm test/package/tmp.js",
7777
"test:unit:watch": "jest --watch",
78-
"test:integration:watch": "test/integration/run.js --watch"
78+
"test:integration:watch": "test/integration/run.js --watch",
79+
"yalc:publish": "ts-node ../../scripts/prepack.ts --bundles && yalc publish ./build/npm --push"
7980
},
8081
"volta": {
8182
"extends": "../../package.json"

packages/core/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@
4040
"lint:prettier": "prettier --check \"{src,test,scripts}/**/**.ts\"",
4141
"test": "jest",
4242
"test:watch": "jest --watch",
43-
"version": "node ../../scripts/versionbump.js src/version.ts"
43+
"version": "node ../../scripts/versionbump.js src/version.ts",
44+
"yalc:publish": "ts-node ../../scripts/prepack.ts && yalc publish build --push"
4445
},
4546
"volta": {
4647
"extends": "../../package.json"

packages/gatsby/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@
5656
"lint:eslint": "eslint . --format stylish",
5757
"lint:prettier": "prettier --check \"{src,test,scripts}/**/**.ts\"",
5858
"test": "yarn ts-node scripts/pretest.ts && yarn jest",
59-
"test:watch": "yarn ts-node scripts/pretest.ts && yarn jest --watch"
59+
"test:watch": "yarn ts-node scripts/pretest.ts && yarn jest --watch",
60+
"yalc:publish": "ts-node ../../scripts/prepack.ts && yalc publish build --push"
6061
},
6162
"volta": {
6263
"extends": "../../package.json"

packages/integrations/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@
4545
"lint:eslint": "eslint . --format stylish",
4646
"lint:prettier": "prettier --check \"{src,test,scripts}/**/**.ts\"",
4747
"test": "jest",
48-
"test:watch": "jest --watch"
48+
"test:watch": "jest --watch",
49+
"yalc:publish": "ts-node ../../scripts/prepack.ts --bundles && yalc publish ./build/npm --push"
4950
},
5051
"volta": {
5152
"extends": "../../package.json"

packages/nextjs/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@
7575
"test:types": "cd test/types && yarn test",
7676
"test:watch": "jest --watch",
7777
"vercel:branch": "source vercel/set-up-branch-for-test-app-use.sh",
78-
"vercel:project": "source vercel/make-project-use-current-branch.sh"
78+
"vercel:project": "source vercel/make-project-use-current-branch.sh",
79+
"yalc:publish": "ts-node ../../scripts/prepack.ts && yalc publish build --push"
7980
},
8081
"volta": {
8182
"extends": "../../package.json"

0 commit comments

Comments
 (0)