Skip to content
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

chore: remove lerna #2526

Open
wants to merge 31 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
590d035
chore: remove precompile and prewatch scripts
david-luna Nov 13, 2024
5d268b5
chore: remove lerna package
david-luna Nov 13, 2024
221fc4f
chore: update peer api check workflow
david-luna Nov 13, 2024
ae4ed34
chore: update release validate workflow
david-luna Nov 13, 2024
f38a38c
chore: update comment
david-luna Nov 13, 2024
4e229dc
chore: update comment in tests
david-luna Nov 13, 2024
fb4df28
chore: update release workflow
david-luna Nov 13, 2024
9f37712
chore: update docs
david-luna Nov 13, 2024
6b8d618
chore: update docs
david-luna Nov 13, 2024
362fb4f
chore: add bump version script
david-luna Nov 13, 2024
6d8aaa1
chore: update version script
david-luna Nov 13, 2024
629f866
chore: update version script
david-luna Nov 14, 2024
174d218
Merge branch 'main' into remove-lerna
david-luna Nov 18, 2024
23b7c71
Merge branch 'main' into remove-lerna
david-luna Nov 19, 2024
60400f0
Merge branch 'main' into remove-lerna
david-luna Nov 22, 2024
67723d6
Merge branch 'main' into remove-lerna
david-luna Nov 27, 2024
8972f4b
Merge branch 'main' into remove-lerna
david-luna Dec 2, 2024
05020c1
Merge branch 'main' into remove-lerna
david-luna Dec 4, 2024
0726e0c
Merge branch 'main' into remove-lerna
david-luna Dec 5, 2024
a60d5f4
chore: merge main
david-luna Jan 21, 2025
3887b70
chore: update package-lock.json
david-luna Jan 21, 2025
eae2663
Merge branch 'main' into remove-lerna
david-luna Jan 21, 2025
6f48e5b
chore: cleanup some scripts
david-luna Jan 21, 2025
1df01ae
chore: fix typo
david-luna Jan 21, 2025
d86b1f2
chore: update version script
david-luna Jan 22, 2025
ddf5b7f
chore: update version script
david-luna Jan 22, 2025
5e90af5
chore: update version script
david-luna Jan 22, 2025
6ee4863
chore: update version script
david-luna Jan 23, 2025
577d584
Merge branch 'main' into remove-lerna
david-luna Feb 3, 2025
c048ccd
Merge branch 'main' into remove-lerna
david-luna Feb 10, 2025
947a253
chore: update package-lock.json
david-luna Feb 10, 2025
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
2 changes: 1 addition & 1 deletion .github/workflows/peer-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ jobs:
run: npm ci

- name: Check API dependency semantics
run: npx lerna exec "node \$LERNA_ROOT_PATH/scripts/peer-api-check.js"
run: node ./scripts/peer-api-check.js
Copy link
Contributor Author

Choose a reason for hiding this comment

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

note for reviewer: this script was used only here so now it's changed to walk over all packages to do the API check.

4 changes: 2 additions & 2 deletions .github/workflows/release-please-validate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Install lerna
run: npm install -g [email protected]
- name: Install glob
run: npm install glob
Copy link
Contributor Author

Choose a reason for hiding this comment

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

note for reviewer: necessary dependency for the next step


- name: Ensure Release Please Config and Manifest are in sync with the repository
run: node scripts/check-release-please.mjs
3 changes: 1 addition & 2 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,10 @@ jobs:

# Release Please has already incremented versions and published tags, so we just
# need to publish all unpublished versions to npm here
# See: https://github.com/lerna/lerna/tree/main/commands/publish#bump-from-package
- name: Publish to npm
# only publish if a release has been created
if: ${{ steps.release.outputs.releases_created }}
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
NPM_CONFIG_PROVENANCE: true
run: npx lerna publish from-package --no-push --no-private --no-git-tag-version --no-verify-access --yes
run: node ./scripts/publish-to-npm.mjs
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ docs

#lerna
.changelog
package.json.lerna_backup

# OS generated files
.DS_Store
Expand Down
25 changes: 24 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ Please also see [GitHub workflow](https://github.com/open-telemetry/community/bl

- [NPM](https://npmjs.com)
- [TypeScript](https://www.typescriptlang.org/)
- [lerna](https://github.com/lerna/lerna) to manage dependencies, compilations, and links between packages. Most lerna commands should be run by calling the provided npm scripts.
- [nx](https://github.com/nrwl/nx) to manage dependencies, compilations, and links between packages. Most nx commands should be run by calling the provided npm scripts.
- [npm workspaces](https://docs.npmjs.com/cli/v10/using-npm/workspaces)
- [MochaJS](https://mochajs.org/) for tests
- [eslint](https://eslint.org/)
Expand All @@ -119,6 +119,29 @@ Some tests depend on other packages to be installed, so these steps are also req

Each of these commands can also be run in individual packages, as long as the initial install and compile are done first in the root directory.

If you're going to work on a single package and want to quickly jump into its development you can make use of the `focus` script. This scritp will run
the necessary tasks to have only that package ready for development saving time. For example, if you want to work with `@opentelemetry/resource-detector-aws`
run the following command in the root folder

```sh
npm run focus @opentelemetry/resource-detector-aws

> [email protected] focus
> nx run-many -t compile -p @opentelemetry/resource-detector-aws


✔ nx run @opentelemetry/instrumentation-fs:version:update (796ms)
✔ nx run @opentelemetry/contrib-test-utils:compile (3s)
✔ nx run @opentelemetry/instrumentation-fs:compile (3s)
✔ nx run @opentelemetry/resource-detector-aws:compile (3s)

———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

> NX Successfully ran target compile for project @opentelemetry/resource-detector-aws and 3 tasks it depends on (7s)
```

Once the command is done you can `cd` into the package and start using the usual commands.

### CHANGELOG

The conventional commit type (in PR title) is very important to automatically bump versions on release. For instance:
Expand Down
20 changes: 7 additions & 13 deletions RELEASING.md
Copy link
Contributor Author

Choose a reason for hiding this comment

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

note to self: although manual release is unlikely to happen we should provide a way to do it. So we need to provide an alternative to the command lerna publish --skip-npm --no-git-tag-version --no-push

Do not merge this PR until this is resolved.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is now implemented in ./scripts/bump-package-versions.mjs

Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,13 @@ Create a new branch called `x.y.z-proposal` from the current commit.
Decide on the next `major.minor.patch` release number based on [semver](http://semver.org/) guidelines.

- Use `npm install` command to initialize all package directories
- Use `lerna publish --skip-npm --no-git-tag-version --no-push` to bump the version in all `package.json`
- Use `npm run bootstrap` to generate latest `version.ts` files
- Use `node ./scripts/bump-pacakge-versions.mjs` to bump the version in all `package.json`

## Use the Changelog to create a GitHub Release

### Generate the changelog with lerna

Since we use `lerna`, we can use [lerna-changelog](https://github.com/lerna/lerna-changelog#lerna-changelog)
We use [lerna-changelog](https://github.com/lerna/lerna-changelog#lerna-changelog)

#### How to use

Expand Down Expand Up @@ -90,19 +89,14 @@ Create a pull request titled `chore: x.y.z release proposal`. The commit body sh

Merge the PR, and pull the changes locally (using the commands in the first step). Ensure that `chore: x.y.z release proposal` is the most recent commit.

## Publish all packages
## Compile all packages
Copy link
Contributor Author

Choose a reason for hiding this comment

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

note to reviewer: IMO this step was missing since npm publish will pack and publish the packages in whatever state it is. With a full compilation everything should be in the right state for publishing


Go into each directory and use `npm publish` (requires permissions) to publish the package. You can use the following script to automate this.
Go into the root folder and run `npm ci && npm run compile` to build all packages with the latest version of the code.

```bash
#!/bin/bash
## Publish all packages

for dir in $(ls packages); do
pushd packages/$dir
npm publish
popd
done
```
Use the dedicated script for publishing by running the command `node ./scripts/publish-to-npm.mjs` in the root folder. The script will
walk over all non private packages and publish the ones that has not been published yet.

Check your e-mail and make sure the number of “you’ve published this module” emails matches the number you expect.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"compile": "tsc --build tsconfig.json tsconfig.esm.json",
"lint": "eslint . --ext .ts",
"lint:fix": "eslint . --ext .ts --fix",
"prewatch": "npm run precompile",
"prepublishOnly": "npm run compile",
"test": "nyc mocha 'test/**/*.test.ts'",
"tdd": "npm run test -- --watch-extensions ts --watch",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"compile": "tsc --build tsconfig.json tsconfig.esm.json",
"lint": "eslint . --ext .ts",
"lint:fix": "eslint . --ext .ts --fix",
"prewatch": "npm run precompile",
"prepublishOnly": "npm run compile",
"test": "nyc mocha 'test/**/*.test.ts'",
"tdd": "npm run test -- --watch-extensions ts --watch",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"compile": "tsc --build tsconfig.json tsconfig.esm.json",
"lint": "eslint . --ext .ts",
"lint:fix": "eslint . --ext .ts --fix",
"prewatch": "npm run precompile",
"prepublishOnly": "npm run compile",
"test": "nyc mocha 'test/**/*.test.ts'",
"tdd": "npm run test -- --watch-extensions ts --watch",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"compile": "tsc --build tsconfig.json tsconfig.esm.json",
"lint": "eslint . --ext .ts",
"lint:fix": "eslint . --ext .ts --fix",
"prewatch": "npm run precompile",
"prepublishOnly": "npm run compile",
"test": "nyc mocha 'test/**/*.test.ts'",
"tdd": "npm run test -- --watch-extensions ts --watch",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"compile": "tsc --build tsconfig.json tsconfig.esm.json",
"lint": "eslint . --ext .ts",
"lint:fix": "eslint . --ext .ts --fix",
"prewatch": "npm run precompile",
"prepublishOnly": "npm run compile",
"test": "nyc mocha 'test/**/*.test.ts'",
"tdd": "npm run test -- --watch-extensions ts --watch",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"compile": "tsc --build tsconfig.json tsconfig.esm.json",
"lint": "eslint . --ext .ts",
"lint:fix": "eslint . --ext .ts --fix",
"prewatch": "npm run precompile",
"prepublishOnly": "npm run compile",
"test": "nyc mocha 'test/**/*.test.ts'",
"tdd": "npm run test -- --watch-extensions ts --watch",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"compile": "tsc --build tsconfig.json tsconfig.esm.json",
"lint": "eslint . --ext .ts",
"lint:fix": "eslint . --ext .ts --fix",
"prewatch": "npm run precompile",
"prepublishOnly": "npm run compile",
"test": "nyc mocha 'test/**/*.test.ts'",
"tdd": "npm run test -- --watch-extensions ts --watch",
Expand Down
2 changes: 0 additions & 2 deletions incubator/opentelemetry-sampler-aws-xray/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
"compile": "tsc -p .",
"lint": "eslint . --ext .ts",
"lint:fix": "eslint . --ext .ts --fix",
"precompile": "tsc --version && lerna run version:update --scope @opentelemetry/sampler-aws-xray --include-dependencies",
"prewatch": "npm run precompile",
"clean": "tsc --build --clean tsconfig.json tsconfig.esm.json",
"prepublishOnly": "npm run compile",
"tdd": "npm run test -- --watch-extensions ts --watch",
Expand Down
1 change: 0 additions & 1 deletion metapackages/auto-configuration-propagators/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"compile": "tsc -p .",
"lint": "eslint . --ext .ts",
"lint:fix": "eslint . --ext .ts --fix",
"prewatch": "npm run precompile",
"prepublishOnly": "npm run compile",
"tdd": "npm run test -- --watch-extensions ts --watch",
"test": "nyc mocha 'test/**/*.ts'",
Expand Down
1 change: 0 additions & 1 deletion metapackages/auto-instrumentations-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"compile": "tsc -p .",
"lint": "eslint . --ext .ts",
"lint:fix": "eslint . --ext .ts --fix",
"prewatch": "npm run precompile",
"prepublishOnly": "npm run compile",
"tdd": "yarn test -- --watch-extensions ts --watch",
"test": "nyc mocha 'test/**/*.ts'",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function runWithRegister(path: string): PromiseWithChild<{
OTEL_NODE_RESOURCE_DETECTORS: 'none',
OTEL_TRACES_EXPORTER: 'console',
OTEL_LOG_LEVEL: 'debug',
// nx (used by lerna run) defaults `FORCE_COLOR=true`, which in
// nx defaults `FORCE_COLOR=true`, which in
// node v18.17.0, v20.3.0 and later results in ANSI color escapes
// in the ConsoleSpanExporter output that is checked below.
FORCE_COLOR: '0',
Expand Down
1 change: 0 additions & 1 deletion metapackages/auto-instrumentations-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"compile": "tsc --build tsconfig.json tsconfig.esm.json tsconfig.esnext.json",
"lint": "eslint . --ext .ts",
"lint:fix": "eslint . --ext .ts --fix",
"prewatch": "npm run precompile",
"prepublishOnly": "npm run compile",
"test:browser": "nyc karma start --single-run",
"watch": "tsc --build --watch tsconfig.json tsconfig.esm.json tsconfig.esnext.json"
Expand Down
13 changes: 9 additions & 4 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,22 @@
"^compile"
],
"inputs": [
"{projectRoot}/src",
"{projectRoot}/test"
"{projectRoot}/src/**/*.ts",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

note to reviewer: although nx documentation says using folder names is okay I found this option to be more sensitive to changes.

"{projectRoot}/test/**/*.ts"
],
"outputs": [
"{projectRoot}/build"
]
},
"watch": {
"dependsOn": [
"compile"
]
},
"lint": {
"inputs": [
"{projectRoot}/src",
"{projectRoot}/test"
"{projectRoot}/src/**/*.ts",
"{projectRoot}/test/**/*.ts"
]
},
"version:update": {
Expand Down
Loading