Skip to content

chore(repo): Add yarn yalc:publish scripts #7502

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ Since we are using [`TypeScript`](https://www.typescriptlang.org/), you need to
- `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`))
- `yarn build:dev:watch`, which runs `yarn build:dev` in watch mode (recommended)


## Testing SDK Packages Locally

To test local versions of SDK packages, for instance in test projects, you have a couple of options:

* Use [`yarn link`](https://classic.yarnpkg.com/lang/en/docs/cli/link/) to symlink your package to the test project.
* Use [`yalc` to install SDK packages](./docs/using-yalc.md) as if they were already published.
* Run `build:tarball` in the repo and `yarn add ./path/to/tarball.tgz` in the project.

## Adding Tests

**Any nontrivial fixes/features should include tests.** You'll find a `test` folder in each package.
Expand Down
51 changes: 51 additions & 0 deletions docs/using-yalc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Using `yalc` for Local SDK Testing
Copy link
Member

@AbhiPrasad AbhiPrasad Mar 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

m: Let's add a link to these doc to the main CONTRIBUTING doc.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point. f6ba80f

(I think at some point we had a sentence about linking packages in there but not anymore. I added it back)


[Yalc](https://github.com/wclr/yalc) is a simple local dependency repository which we can use to work with local versions of our SDKs.
This is a good alternative to `npm|yarn link` for packages where linking is problematic (e.g. SvelteKit or Angular).

Here's how to set up and use yalc:

## Installing `yalc`

Either install yalc globally,

```sh
npm install -g yalc

yarn global add yalc
```

or add it to your desired test projects (same command without the `-g|global` flags)

## Registering/Updating packages

Whenever you want to make your local changes available to your test projects (e.g. after a local code change), run:

```sh
yarn yalc:publish
```

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.

## Using yalc packages

In your test project, run

```sh
yalc add @sentry/browser #or any other SDK package
```

to add the local SDK package to your project.

**Important:** You need to `yalc add` the dependencies of the SDK package as well (e.g. core, utils, types, etc.).

## Troubleshooting:

### My changes are not applied to the test project

Did you run `yarn build && yarn publish:yalc` after making your changes?

### My test project uses Vite and I still don't see changes

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`.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"test:unit": "lerna run --ignore @sentry-internal/* test:unit",
"test-ci-browser": "lerna run test --ignore \"@sentry/{node,opentelemetry-node,serverless,nextjs,remix,gatsby}\" --ignore @sentry-internal/*",
"test-ci-node": "ts-node ./scripts/node-unit-tests.ts",
"test:update-snapshots": "lerna run test:update-snapshots"
"test:update-snapshots": "lerna run test:update-snapshots",
"yalc:publish": "lerna run yalc:publish"
},
"volta": {
"node": "16.19.0",
Expand Down Expand Up @@ -117,7 +118,8 @@
"tslib": "^2.3.1",
"typedoc": "^0.18.0",
"typescript": "3.8.3",
"vitest": "^0.29.2"
"vitest": "^0.29.2",
"yalc": "^1.0.0-pre.53"
},
"resolutions": {
"**/agent-base": "5"
Expand Down
3 changes: 2 additions & 1 deletion packages/angular-ivy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@
"fix:prettier": "prettier --write \"{src,test,scripts}/**/**.ts\"",
"lint": "run-s lint:prettier lint:eslint",
"lint:eslint": "eslint . --format stylish",
"lint:prettier": "prettier --check \"{src,test,scripts}/**/**.ts\""
"lint:prettier": "prettier --check \"{src,test,scripts}/**/**.ts\"",
"yalc:publish": "ts-node ../../scripts/prepack.ts && yalc publish build --push"
},
"volta": {
"extends": "../../package.json"
Expand Down
3 changes: 2 additions & 1 deletion packages/angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@
"lint:prettier": "prettier --check \"{src,test,scripts}/**/**.ts\"",
"test": "yarn test:unit",
"test:unit": "jest",
"test:unit:watch": "jest --watch"
"test:unit:watch": "jest --watch",
"yalc:publish": "ts-node ../../scripts/prepack.ts && yalc publish build --push"
},
"volta": {
"extends": "../../package.json"
Expand Down
3 changes: 2 additions & 1 deletion packages/browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@
"test:integration:checkbrowsers": "node scripts/checkbrowsers.js",
"test:package": "node test/package/npm-build.js && rm test/package/tmp.js",
"test:unit:watch": "jest --watch",
"test:integration:watch": "test/integration/run.js --watch"
"test:integration:watch": "test/integration/run.js --watch",
"yalc:publish": "ts-node ../../scripts/prepack.ts --bundles && yalc publish ./build/npm --push"
},
"volta": {
"extends": "../../package.json"
Expand Down
3 changes: 2 additions & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
"lint:prettier": "prettier --check \"{src,test,scripts}/**/**.ts\"",
"test": "jest",
"test:watch": "jest --watch",
"version": "node ../../scripts/versionbump.js src/version.ts"
"version": "node ../../scripts/versionbump.js src/version.ts",
"yalc:publish": "ts-node ../../scripts/prepack.ts && yalc publish build --push"
},
"volta": {
"extends": "../../package.json"
Expand Down
3 changes: 2 additions & 1 deletion packages/gatsby/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@
"lint:eslint": "eslint . --format stylish",
"lint:prettier": "prettier --check \"{src,test,scripts}/**/**.ts\"",
"test": "yarn ts-node scripts/pretest.ts && yarn jest",
"test:watch": "yarn ts-node scripts/pretest.ts && yarn jest --watch"
"test:watch": "yarn ts-node scripts/pretest.ts && yarn jest --watch",
"yalc:publish": "ts-node ../../scripts/prepack.ts && yalc publish build --push"
},
"volta": {
"extends": "../../package.json"
Expand Down
3 changes: 2 additions & 1 deletion packages/integrations/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@
"lint:eslint": "eslint . --format stylish",
"lint:prettier": "prettier --check \"{src,test,scripts}/**/**.ts\"",
"test": "jest",
"test:watch": "jest --watch"
"test:watch": "jest --watch",
"yalc:publish": "ts-node ../../scripts/prepack.ts --bundles && yalc publish ./build/npm --push"
},
"volta": {
"extends": "../../package.json"
Expand Down
3 changes: 2 additions & 1 deletion packages/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@
"test:types": "cd test/types && yarn test",
"test:watch": "jest --watch",
"vercel:branch": "source vercel/set-up-branch-for-test-app-use.sh",
"vercel:project": "source vercel/make-project-use-current-branch.sh"
"vercel:project": "source vercel/make-project-use-current-branch.sh",
"yalc:publish": "ts-node ../../scripts/prepack.ts && yalc publish build --push"
},
"volta": {
"extends": "../../package.json"
Expand Down
3 changes: 2 additions & 1 deletion packages/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@
"test:jest": "jest",
"test:release-health": "node test/manual/release-health/runner.js",
"test:webpack": "cd test/manual/webpack-domain/ && yarn --silent && node npm-build.js",
"test:watch": "jest --watch"
"test:watch": "jest --watch",
"yalc:publish": "ts-node ../../scripts/prepack.ts && yalc publish build --push"
},
"volta": {
"extends": "../../package.json"
Expand Down
3 changes: 2 additions & 1 deletion packages/opentelemetry-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@
"lint:prettier": "prettier --check \"{src,test,scripts}/**/**.ts\"",
"test": "yarn test:jest",
"test:jest": "jest",
"test:watch": "jest --watch"
"test:watch": "jest --watch",
"yalc:publish": "ts-node ../../scripts/prepack.ts && yalc publish build --push"
},
"volta": {
"extends": "../../package.json"
Expand Down
3 changes: 2 additions & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@
"lint:eslint": "eslint . --format stylish",
"lint:prettier": "prettier --check \"{src,test,scripts}/**/**.ts\"",
"test": "jest",
"test:watch": "jest --watch"
"test:watch": "jest --watch",
"yalc:publish": "ts-node ../../scripts/prepack.ts && yalc publish build --push"
},
"volta": {
"extends": "../../package.json"
Expand Down
3 changes: 2 additions & 1 deletion packages/remix/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@
"test:integration:client:ci": "yarn test:integration:client --browser='all' --reporter='line'",
"test:integration:server": "export NODE_OPTIONS='--stack-trace-limit=25' && jest --config=test/integration/jest.config.js test/integration/test/server/",
"test:unit": "jest",
"test:watch": "jest --watch"
"test:watch": "jest --watch",
"yalc:publish": "ts-node ../../scripts/prepack.ts && yalc publish build --push"
},
"volta": {
"extends": "../../package.json"
Expand Down
3 changes: 2 additions & 1 deletion packages/replay/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
"test": "jest",
"test:watch": "jest --watch",
"bootstrap:demo": "cd demo && yarn",
"start:demo": "yarn build:dev && cd demo && yarn start"
"start:demo": "yarn build:dev && cd demo && yarn start",
"yalc:publish": "ts-node ../../scripts/prepack.ts --bundles && yalc publish ./build/npm --push"
},
"repository": {
"type": "git",
Expand Down
3 changes: 2 additions & 1 deletion packages/serverless/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@
"lint:eslint": "eslint . --format stylish",
"lint:prettier": "prettier --check \"{src,test,scripts}/**/**.ts\"",
"test": "jest",
"test:watch": "jest --watch"
"test:watch": "jest --watch",
"yalc:publish": "ts-node ../../scripts/prepack.ts --bundles && yalc publish ./build/npm --push"
},
"volta": {
"extends": "../../package.json"
Expand Down
3 changes: 2 additions & 1 deletion packages/svelte/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
"lint:eslint": "eslint . --format stylish",
"lint:prettier": "prettier --check \"{src,test,scripts}/**/**.ts\"",
"test": "jest",
"test:watch": "jest --watch"
"test:watch": "jest --watch",
"yalc:publish": "ts-node ../../scripts/prepack.ts && yalc publish build --push"
},
"volta": {
"extends": "../../package.json"
Expand Down
3 changes: 2 additions & 1 deletion packages/sveltekit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@
"lint:prettier": "prettier --check \"{src,test,scripts}/**/**.ts\"",
"test": "yarn test:unit",
"test:unit": "vitest run",
"test:watch": "vitest --watch"
"test:watch": "vitest --watch",
"yalc:publish": "ts-node ../../scripts/prepack.ts && yalc publish build --push"
},
"volta": {
"extends": "../../package.json"
Expand Down
3 changes: 2 additions & 1 deletion packages/tracing-internal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
"lint:prettier": "prettier --check \"{src,test,scripts}/**/**.ts\"",
"test:unit": "jest",
"test": "jest",
"test:watch": "jest --watch"
"test:watch": "jest --watch",
"yalc:publish": "ts-node ../../scripts/prepack.ts && yalc publish build --push"
},
"volta": {
"extends": "../../package.json"
Expand Down
3 changes: 2 additions & 1 deletion packages/tracing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
"lint:prettier": "prettier --check \"{src,test,scripts}/**/**.ts\"",
"test:unit": "jest",
"test": "jest",
"test:watch": "jest --watch"
"test:watch": "jest --watch",
"yalc:publish": "ts-node ../../scripts/prepack.ts --bundles && yalc publish ./build/npm --push"
},
"volta": {
"extends": "../../package.json"
Expand Down
3 changes: 2 additions & 1 deletion packages/types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
"lint:prettier": "prettier --check \"{src,test,scripts}/**/**.ts\"",
"fix": "run-s fix:eslint fix:prettier",
"fix:eslint": "eslint . --format stylish --fix",
"fix:prettier": "prettier --write \"{src,test,scripts}/**/**.ts\""
"fix:prettier": "prettier --write \"{src,test,scripts}/**/**.ts\"",
"yalc:publish": "ts-node ../../scripts/prepack.ts && yalc publish build --push"
},
"volta": {
"extends": "../../package.json"
Expand Down
3 changes: 2 additions & 1 deletion packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@
"lint:prettier": "prettier --check \"{src,test,scripts}/**/**.ts\"",
"test": "jest",
"test:watch": "jest --watch",
"test:package": "node test/types/index.js"
"test:package": "node test/types/index.js",
"yalc:publish": "ts-node ../../scripts/prepack.ts && yalc publish build --push"
},
"volta": {
"extends": "../../package.json"
Expand Down
3 changes: 2 additions & 1 deletion packages/vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
"lint:eslint": "eslint . --format stylish",
"lint:prettier": "prettier --check \"{src,test,scripts}/**/**.ts\"",
"test": "jest",
"test:watch": "jest --watch"
"test:watch": "jest --watch",
"yalc:publish": "ts-node ../../scripts/prepack.ts && yalc publish build --push"
},
"volta": {
"extends": "../../package.json"
Expand Down
3 changes: 2 additions & 1 deletion packages/wasm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
"fix:prettier": "prettier --write \"{src,test,scripts}/**/**.ts\"",
"lint": "run-s lint:prettier lint:eslint",
"lint:eslint": "eslint . --format stylish",
"lint:prettier": "prettier --check \"{src,test,scripts}/**/**.ts\""
"lint:prettier": "prettier --check \"{src,test,scripts}/**/**.ts\"",
"yalc:publish": "ts-node ../../scripts/prepack.ts --bundles && yalc publish ./build/npm --push"
},
"volta": {
"extends": "../../package.json"
Expand Down
26 changes: 25 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -15070,7 +15070,7 @@ [email protected]:
resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.6.tgz#f1c46a2a93a253e7b3905115e74d527cd23061a1"
integrity sha512-IZUoxEjNjubzrmvzZU4lKP7OnYmX72XRl3sqkfJhBKweKi5rnGi5+IUdlj/H1M+Ip5JQ1WzaDMOBRY90Ajc5jg==

[email protected]:
[email protected], ini@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/ini/-/ini-2.0.0.tgz#e5fd556ecdd5726be978fa1001862eacb0a94bc5"
integrity sha512-7PnF4oN3CvZF23ADhA5wRaYEQpJ8qygSkbtTXWBeXWXmEVRXK+1ITciHWwHhsjv1TmW0MgacIv6hEi5pX5NQdA==
Expand Down Expand Up @@ -19456,6 +19456,16 @@ npm-packlist@^2.1.4:
npm-bundled "^1.1.1"
npm-normalize-package-bin "^1.0.1"

npm-packlist@^2.1.5:
version "2.2.2"
resolved "https://registry.yarnpkg.com/npm-packlist/-/npm-packlist-2.2.2.tgz#076b97293fa620f632833186a7a8f65aaa6148c8"
integrity sha512-Jt01acDvJRhJGthnUJVF/w6gumWOZxO7IkpY/lsX9//zqQgnF7OJaxgQXcerd4uQOLu7W5bkb4mChL9mdfm+Zg==
dependencies:
glob "^7.1.6"
ignore-walk "^3.0.3"
npm-bundled "^1.1.1"
npm-normalize-package-bin "^1.0.1"

npm-packlist@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/npm-packlist/-/npm-packlist-3.0.0.tgz#0370df5cfc2fcc8f79b8f42b37798dd9ee32c2a9"
Expand Down Expand Up @@ -27798,6 +27808,20 @@ y18n@^5.0.5:
resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.8.tgz#7f4934d0f7ca8c56f95314939ddcd2dd91ce1d55"
integrity sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==

yalc@^1.0.0-pre.53:
version "1.0.0-pre.53"
resolved "https://registry.yarnpkg.com/yalc/-/yalc-1.0.0-pre.53.tgz#c51db2bb924a6908f4cb7e82af78f7e5606810bc"
integrity sha512-tpNqBCpTXplnduzw5XC+FF8zNJ9L/UXmvQyyQj7NKrDNavbJtHvzmZplL5ES/RCnjX7JR7W9wz5GVDXVP3dHUQ==
dependencies:
chalk "^4.1.0"
detect-indent "^6.0.0"
fs-extra "^8.0.1"
glob "^7.1.4"
ignore "^5.0.4"
ini "^2.0.0"
npm-packlist "^2.1.5"
yargs "^16.1.1"

yallist@^3.0.0, yallist@^3.0.2, yallist@^3.1.1:
version "3.1.1"
resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.1.1.tgz#dbb7daf9bfd8bac9ab45ebf602b8cbad0d5d08fd"
Expand Down