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 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 8 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
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 ussual commands.

### CHANGELOG

The conventional commit type (in PR title) is very important to automatically bump versions on release. For instance:
Expand Down
15 changes: 5 additions & 10 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 @@ -90,19 +90,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 @@ -10,8 +10,6 @@
"build:mv3": "npx webpack --mode=production --env MV=3",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"precompile": "tsc --version && lerna run version:update --scope @opentelemetry/browser-extension-autoinjection --include-dependencies",
"prewatch": "npm run precompile",
"test": "nyc mocha 'test/**/*.test.ts'",
"tdd": "npm run test -- --watch-extensions ts --watch",
"watch": "npx webpack --mode=development --watch",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"compile": "tsc -p .",
"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 @@ -10,7 +10,6 @@
"compile": "tsc -p .",
"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 @@ -10,7 +10,6 @@
"compile": "tsc -p .",
"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 @@ -10,7 +10,6 @@
"compile": "tsc -p .",
"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 @@ -10,7 +10,6 @@
"compile": "tsc -p .",
"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 @@ -10,7 +10,6 @@
"compile": "tsc -p .",
"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 @@ -10,7 +10,6 @@
"compile": "tsc -p .",
"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
Loading