diff --git a/.gitignore b/.gitignore index 6c3473bdbd0..8bea02a1b00 100644 --- a/.gitignore +++ b/.gitignore @@ -91,3 +91,6 @@ package.json.lerna_backup # non-aggregated benchmark results .benchmark-results.txt + +# release notes for release creation +.tmp/ diff --git a/api/CHANGELOG.md b/api/CHANGELOG.md index 946d39be863..c1c964daabb 100644 --- a/api/CHANGELOG.md +++ b/api/CHANGELOG.md @@ -97,13 +97,13 @@ All notable changes to this project will be documented in this file. * export tracer options ([#154](https://www.github.com/open-telemetry/opentelemetry-js-api/issues/154)) ([b125324](https://www.github.com/open-telemetry/opentelemetry-js-api/commit/b125324438fb2f24eb80c7c6673afc8cfc99575e)) -### [1.0.4](https://www.github.com/open-telemetry/opentelemetry-js-api/compare/v1.0.3...v1.0.4) (2021-12-18) +## [1.0.4](https://www.github.com/open-telemetry/opentelemetry-js-api/compare/v1.0.3...v1.0.4) (2021-12-18) ### Bug Fixes * align globalThis fallbacks with otel-core ([#126](https://www.github.com/open-telemetry/opentelemetry-js-api/issues/126)) ([3507de7](https://www.github.com/open-telemetry/opentelemetry-js-api/commit/3507de7c3b95396696657c021953b0b24a63a029)) -### [1.0.3](https://www.github.com/open-telemetry/opentelemetry-js-api/compare/v1.0.2...v1.0.3) (2021-08-30) +## [1.0.3](https://www.github.com/open-telemetry/opentelemetry-js-api/compare/v1.0.2...v1.0.3) (2021-08-30) ### Bug Fixes diff --git a/examples/esm-http-ts/package.json b/examples/esm-http-ts/package.json index 0ac3521fc30..3b6e7f433eb 100644 --- a/examples/esm-http-ts/package.json +++ b/examples/esm-http-ts/package.json @@ -7,7 +7,8 @@ "type": "module", "scripts": { "build": "tsc --build", - "start": "node --experimental-loader=@opentelemetry/instrumentation/hook.mjs ./build/index.js" + "start": "node --experimental-loader=@opentelemetry/instrumentation/hook.mjs ./build/index.js", + "align-api-deps": "node ../../scripts/align-api-deps.js" }, "repository": { "type": "git", diff --git a/examples/http/package.json b/examples/http/package.json index 08989a421cd..2534002a67d 100644 --- a/examples/http/package.json +++ b/examples/http/package.json @@ -8,7 +8,8 @@ "zipkin:server": "cross-env EXPORTER=zipkin node ./server.js", "zipkin:client": "cross-env EXPORTER=zipkin node ./client.js", "jaeger:server": "cross-env EXPORTER=jaeger node ./server.js", - "jaeger:client": "cross-env EXPORTER=jaeger node ./client.js" + "jaeger:client": "cross-env EXPORTER=jaeger node ./client.js", + "align-api-deps": "node ../../scripts/align-api-deps.js" }, "repository": { "type": "git", diff --git a/examples/https/package.json b/examples/https/package.json index 266800c02b1..f3ffbfe2b06 100644 --- a/examples/https/package.json +++ b/examples/https/package.json @@ -12,7 +12,8 @@ "jaeger:client": "cross-env EXPORTER=jaeger node ./client.js", "docker:start": "cd ./docker && docker-compose down && docker-compose up", "docker:startd": "cd ./docker && docker-compose down && docker-compose up -d", - "docker:stop": "cd ./docker && docker-compose down" + "docker:stop": "cd ./docker && docker-compose down", + "align-api-deps": "node ../../scripts/align-api-deps.js" }, "repository": { "type": "git", diff --git a/examples/opentelemetry-web/package.json b/examples/opentelemetry-web/package.json index a236f6c90ab..861b0bc6426 100644 --- a/examples/opentelemetry-web/package.json +++ b/examples/opentelemetry-web/package.json @@ -11,7 +11,8 @@ "start-prodnc": "webpack serve --progress --color --port 8090 --config webpack.prod.config.js --hot --host 0.0.0.0 --no-compress", "docker:start": "cd ./docker && docker-compose down && docker-compose up", "docker:startd": "cd ./docker && docker-compose down && docker-compose up -d", - "docker:stop": "cd ./docker && docker-compose down" + "docker:stop": "cd ./docker && docker-compose down", + "align-api-deps": "node ../../scripts/align-api-deps.js" }, "repository": { "type": "git", diff --git a/examples/opentracing-shim/package.json b/examples/opentracing-shim/package.json index cf880f2b190..37cc5ab31d9 100644 --- a/examples/opentracing-shim/package.json +++ b/examples/opentracing-shim/package.json @@ -8,7 +8,8 @@ "zipkin:client": "cross-env EXPORTER=zipkin node ./client.js", "zipkin:server": "cross-env EXPORTER=zipkin node ./server.js", "jaeger:client": "cross-env EXPORTER=jaeger node ./client.js", - "jaeger:server": "cross-env EXPORTER=jaeger node ./server.js" + "jaeger:server": "cross-env EXPORTER=jaeger node ./server.js", + "align-api-deps": "node ../../scripts/align-api-deps.js" }, "repository": { "type": "git", diff --git a/examples/otlp-exporter-node/package.json b/examples/otlp-exporter-node/package.json index 12add30e456..b857e74ba1e 100644 --- a/examples/otlp-exporter-node/package.json +++ b/examples/otlp-exporter-node/package.json @@ -9,7 +9,8 @@ "start:metrics": "node metrics.js", "docker:start": "cd ./docker && docker-compose down && docker-compose up", "docker:startd": "cd ./docker && docker-compose down && docker-compose up -d", - "docker:stop": "cd ./docker && docker-compose down" + "docker:stop": "cd ./docker && docker-compose down", + "align-api-deps": "node ../../scripts/align-api-deps.js" }, "repository": { "type": "git", diff --git a/experimental/backwards-compatibility/node14/package.json b/experimental/backwards-compatibility/node14/package.json index a72ce8c3a90..074cd2753b1 100644 --- a/experimental/backwards-compatibility/node14/package.json +++ b/experimental/backwards-compatibility/node14/package.json @@ -6,7 +6,8 @@ "main": "index.js", "scripts": { "test:backcompat": "tsc --noEmit index.ts && tsc --noEmit --esModuleInterop index.ts", - "peer-api-check": "node ../../../scripts/peer-api-check.js" + "peer-api-check": "node ../../../scripts/peer-api-check.js", + "align-api-deps": "node ../../../scripts/align-api-deps.js" }, "dependencies": { "@opentelemetry/sdk-node": "0.51.1", diff --git a/experimental/backwards-compatibility/node16/package.json b/experimental/backwards-compatibility/node16/package.json index 9c28ab79329..a5702331ba1 100644 --- a/experimental/backwards-compatibility/node16/package.json +++ b/experimental/backwards-compatibility/node16/package.json @@ -6,7 +6,8 @@ "main": "index.js", "scripts": { "test:backcompat": "tsc --noEmit index.ts && tsc --noEmit --esModuleInterop index.ts", - "peer-api-check": "node ../../../scripts/peer-api-check.js" + "peer-api-check": "node ../../../scripts/peer-api-check.js", + "align-api-deps": "node ../../../scripts/align-api-deps.js" }, "dependencies": { "@opentelemetry/sdk-node": "0.51.1", diff --git a/experimental/examples/logs/package.json b/experimental/examples/logs/package.json index e5861b33ea1..e116515d91c 100644 --- a/experimental/examples/logs/package.json +++ b/experimental/examples/logs/package.json @@ -3,7 +3,8 @@ "version": "0.51.1", "private": true, "scripts": { - "start": "ts-node index.ts" + "start": "ts-node index.ts", + "align-api-deps": "node ../../../scripts/align-api-deps.js" }, "dependencies": { "@opentelemetry/api": "^1.7.0", diff --git a/experimental/examples/opencensus-shim/package.json b/experimental/examples/opencensus-shim/package.json index c63532f33f7..59754a96fa8 100644 --- a/experimental/examples/opencensus-shim/package.json +++ b/experimental/examples/opencensus-shim/package.json @@ -6,7 +6,8 @@ "main": "index.js", "scripts": { "client": "node -r @opentelemetry/shim-opencensus/register ./client.js", - "server": "node -r @opentelemetry/shim-opencensus/register ./server.js" + "server": "node -r @opentelemetry/shim-opencensus/register ./server.js", + "align-api-deps": "node ../../../scripts/align-api-deps.js" }, "repository": { "type": "git", diff --git a/experimental/examples/prometheus/package.json b/experimental/examples/prometheus/package.json index 9d0a8d4ac59..49358e2f5a5 100644 --- a/experimental/examples/prometheus/package.json +++ b/experimental/examples/prometheus/package.json @@ -5,7 +5,8 @@ "description": "Example of using @opentelemetry/sdk-metrics and @opentelemetry/exporter-prometheus", "main": "index.js", "scripts": { - "start": "node index.js" + "start": "node index.js", + "align-api-deps": "node ../../../scripts/align-api-deps.js" }, "author": "OpenTelemetry Authors", "license": "Apache-2.0", diff --git a/experimental/packages/api-events/package.json b/experimental/packages/api-events/package.json index 26883530075..63fe0056f39 100644 --- a/experimental/packages/api-events/package.json +++ b/experimental/packages/api-events/package.json @@ -27,7 +27,8 @@ "version": "node ../../../scripts/version-update.js", "watch": "tsc --build --watch tsconfig.json tsconfig.esm.json tsconfig.esnext.json", "precompile": "cross-var lerna run version --scope $npm_package_name --include-dependencies", - "prewatch": "node ../../../scripts/version-update.js" + "prewatch": "node ../../../scripts/version-update.js", + "align-api-deps": "node ../../../scripts/align-api-deps.js" }, "keywords": [ "opentelemetry", diff --git a/experimental/packages/api-logs/package.json b/experimental/packages/api-logs/package.json index c02648a5c38..ef9f9567b72 100644 --- a/experimental/packages/api-logs/package.json +++ b/experimental/packages/api-logs/package.json @@ -27,7 +27,8 @@ "version": "node ../../../scripts/version-update.js", "watch": "tsc --build --watch tsconfig.json tsconfig.esm.json tsconfig.esnext.json", "precompile": "cross-var lerna run version --scope $npm_package_name --include-dependencies", - "prewatch": "node ../../../scripts/version-update.js" + "prewatch": "node ../../../scripts/version-update.js", + "align-api-deps": "node ../../../scripts/align-api-deps.js" }, "keywords": [ "opentelemetry", diff --git a/experimental/packages/exporter-logs-otlp-grpc/package.json b/experimental/packages/exporter-logs-otlp-grpc/package.json index 63111eb2565..536dcecd5f3 100644 --- a/experimental/packages/exporter-logs-otlp-grpc/package.json +++ b/experimental/packages/exporter-logs-otlp-grpc/package.json @@ -18,7 +18,8 @@ "precompile": "cross-var lerna run version --scope $npm_package_name --include-dependencies", "prewatch": "npm run precompile", "peer-api-check": "node ../../../scripts/peer-api-check.js", - "codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../../" + "codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../../", + "align-api-deps": "node ../../../scripts/align-api-deps.js" }, "keywords": [ "opentelemetry", diff --git a/experimental/packages/exporter-logs-otlp-http/package.json b/experimental/packages/exporter-logs-otlp-http/package.json index f30a7991b6b..2eac44e2221 100644 --- a/experimental/packages/exporter-logs-otlp-http/package.json +++ b/experimental/packages/exporter-logs-otlp-http/package.json @@ -44,7 +44,8 @@ "precompile": "cross-var lerna run version --scope $npm_package_name --include-dependencies", "prewatch": "npm run precompile", "peer-api-check": "node ../../../scripts/peer-api-check.js", - "codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../../" + "codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../../", + "align-api-deps": "node ../../../scripts/align-api-deps.js" }, "keywords": [ "opentelemetry", diff --git a/experimental/packages/exporter-logs-otlp-proto/package.json b/experimental/packages/exporter-logs-otlp-proto/package.json index a62f2cfc5dd..b10f00ad599 100644 --- a/experimental/packages/exporter-logs-otlp-proto/package.json +++ b/experimental/packages/exporter-logs-otlp-proto/package.json @@ -27,7 +27,8 @@ "precompile": "cross-var lerna run version --scope $npm_package_name --include-dependencies", "prewatch": "npm run precompile", "peer-api-check": "node ../../../scripts/peer-api-check.js", - "codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../../" + "codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../../", + "align-api-deps": "node ../../../scripts/align-api-deps.js" }, "keywords": [ "opentelemetry", diff --git a/experimental/packages/exporter-trace-otlp-grpc/package.json b/experimental/packages/exporter-trace-otlp-grpc/package.json index 330b53a093f..08a72959c69 100644 --- a/experimental/packages/exporter-trace-otlp-grpc/package.json +++ b/experimental/packages/exporter-trace-otlp-grpc/package.json @@ -18,7 +18,8 @@ "precompile": "cross-var lerna run version --scope $npm_package_name --include-dependencies", "prewatch": "npm run precompile", "peer-api-check": "node ../../../scripts/peer-api-check.js", - "codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../../" + "codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../../", + "align-api-deps": "node ../../../scripts/align-api-deps.js" }, "keywords": [ "opentelemetry", diff --git a/experimental/packages/exporter-trace-otlp-http/package.json b/experimental/packages/exporter-trace-otlp-http/package.json index 7b419e2b517..dcc7d9eca3a 100644 --- a/experimental/packages/exporter-trace-otlp-http/package.json +++ b/experimental/packages/exporter-trace-otlp-http/package.json @@ -29,7 +29,8 @@ "precompile": "cross-var lerna run version --scope $npm_package_name --include-dependencies", "prewatch": "npm run precompile", "peer-api-check": "node ../../../scripts/peer-api-check.js", - "codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../../" + "codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../../", + "align-api-deps": "node ../../../scripts/align-api-deps.js" }, "keywords": [ "opentelemetry", diff --git a/experimental/packages/exporter-trace-otlp-proto/package.json b/experimental/packages/exporter-trace-otlp-proto/package.json index 63cb9547b72..420386ef608 100644 --- a/experimental/packages/exporter-trace-otlp-proto/package.json +++ b/experimental/packages/exporter-trace-otlp-proto/package.json @@ -27,7 +27,8 @@ "precompile": "cross-var lerna run version --scope $npm_package_name --include-dependencies", "prewatch": "npm run precompile", "peer-api-check": "node ../../../scripts/peer-api-check.js", - "codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../../" + "codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../../", + "align-api-deps": "node ../../../scripts/align-api-deps.js" }, "keywords": [ "opentelemetry", diff --git a/experimental/packages/opentelemetry-browser-detector/package.json b/experimental/packages/opentelemetry-browser-detector/package.json index 61e367b0fc9..2a0f9809b84 100644 --- a/experimental/packages/opentelemetry-browser-detector/package.json +++ b/experimental/packages/opentelemetry-browser-detector/package.json @@ -22,7 +22,8 @@ "watch": "tsc --build --watch tsconfig.json tsconfig.esm.json tsconfig.esnext.json", "precompile": "cross-var lerna run version --scope $npm_package_name --include-dependencies", "prewatch": "npm run precompile", - "peer-api-check": "node ../../../scripts/peer-api-check.js" + "peer-api-check": "node ../../../scripts/peer-api-check.js", + "align-api-deps": "node ../../../scripts/align-api-deps.js" }, "keywords": [ "opentelemetry", diff --git a/experimental/packages/opentelemetry-exporter-metrics-otlp-grpc/package.json b/experimental/packages/opentelemetry-exporter-metrics-otlp-grpc/package.json index 2dc16c6af3a..500c6dc89b6 100644 --- a/experimental/packages/opentelemetry-exporter-metrics-otlp-grpc/package.json +++ b/experimental/packages/opentelemetry-exporter-metrics-otlp-grpc/package.json @@ -18,7 +18,8 @@ "precompile": "cross-var lerna run version --scope $npm_package_name --include-dependencies", "prewatch": "npm run precompile", "peer-api-check": "node ../../../scripts/peer-api-check.js", - "codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../../" + "codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../../", + "align-api-deps": "node ../../../scripts/align-api-deps.js" }, "keywords": [ "opentelemetry", diff --git a/experimental/packages/opentelemetry-exporter-metrics-otlp-http/package.json b/experimental/packages/opentelemetry-exporter-metrics-otlp-http/package.json index 2366d79004f..097dfbea8ba 100644 --- a/experimental/packages/opentelemetry-exporter-metrics-otlp-http/package.json +++ b/experimental/packages/opentelemetry-exporter-metrics-otlp-http/package.json @@ -29,7 +29,8 @@ "precompile": "cross-var lerna run version --scope $npm_package_name --include-dependencies", "prewatch": "npm run precompile", "peer-api-check": "node ../../../scripts/peer-api-check.js", - "codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../../" + "codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../../", + "align-api-deps": "node ../../../scripts/align-api-deps.js" }, "keywords": [ "opentelemetry", diff --git a/experimental/packages/opentelemetry-exporter-metrics-otlp-proto/package.json b/experimental/packages/opentelemetry-exporter-metrics-otlp-proto/package.json index c731087888c..dcd0d4c7001 100644 --- a/experimental/packages/opentelemetry-exporter-metrics-otlp-proto/package.json +++ b/experimental/packages/opentelemetry-exporter-metrics-otlp-proto/package.json @@ -20,7 +20,8 @@ "precompile": "cross-var lerna run version --scope $npm_package_name --include-dependencies", "prewatch": "npm run precompile", "peer-api-check": "node ../../../scripts/peer-api-check.js", - "codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../../" + "codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../../", + "align-api-deps": "node ../../../scripts/align-api-deps.js" }, "keywords": [ "opentelemetry", diff --git a/experimental/packages/opentelemetry-exporter-prometheus/package.json b/experimental/packages/opentelemetry-exporter-prometheus/package.json index 9580bd2bae5..65445ac7b51 100644 --- a/experimental/packages/opentelemetry-exporter-prometheus/package.json +++ b/experimental/packages/opentelemetry-exporter-prometheus/package.json @@ -18,7 +18,8 @@ "watch": "tsc --build --watch", "precompile": "cross-var lerna run version --scope $npm_package_name --include-dependencies", "prewatch": "npm run precompile", - "peer-api-check": "node ../../../scripts/peer-api-check.js" + "peer-api-check": "node ../../../scripts/peer-api-check.js", + "align-api-deps": "node ../../../scripts/align-api-deps.js" }, "keywords": [ "opentelemetry", diff --git a/experimental/packages/opentelemetry-instrumentation-fetch/package.json b/experimental/packages/opentelemetry-instrumentation-fetch/package.json index 59c5dfec3c9..cc86c857715 100644 --- a/experimental/packages/opentelemetry-instrumentation-fetch/package.json +++ b/experimental/packages/opentelemetry-instrumentation-fetch/package.json @@ -20,7 +20,8 @@ "watch": "tsc --build --watch tsconfig.json tsconfig.esm.json tsconfig.esnext.json", "precompile": "cross-var lerna run version --scope $npm_package_name --include-dependencies", "prewatch": "node ../../../scripts/version-update.js", - "peer-api-check": "node ../../../scripts/peer-api-check.js" + "peer-api-check": "node ../../../scripts/peer-api-check.js", + "align-api-deps": "node ../../../scripts/align-api-deps.js" }, "keywords": [ "fetch", diff --git a/experimental/packages/opentelemetry-instrumentation-grpc/package.json b/experimental/packages/opentelemetry-instrumentation-grpc/package.json index c1ba37b73c1..e5e31c085fe 100644 --- a/experimental/packages/opentelemetry-instrumentation-grpc/package.json +++ b/experimental/packages/opentelemetry-instrumentation-grpc/package.json @@ -19,7 +19,8 @@ "precompile": "cross-var lerna run version --scope $npm_package_name --include-dependencies", "prewatch": "node ../../../scripts/version-update.js", "peer-api-check": "node ../../../scripts/peer-api-check.js", - "protos:generate": "cd test/fixtures && buf generate" + "protos:generate": "cd test/fixtures && buf generate", + "align-api-deps": "node ../../../scripts/align-api-deps.js" }, "keywords": [ "opentelemetry", diff --git a/experimental/packages/opentelemetry-instrumentation-http/package.json b/experimental/packages/opentelemetry-instrumentation-http/package.json index e45f35a5f02..13134c89a3f 100644 --- a/experimental/packages/opentelemetry-instrumentation-http/package.json +++ b/experimental/packages/opentelemetry-instrumentation-http/package.json @@ -18,7 +18,8 @@ "watch": "tsc --build --watch", "precompile": "cross-var lerna run version --scope $npm_package_name --include-dependencies", "prewatch": "node ../../../scripts/version-update.js", - "peer-api-check": "node ../../../scripts/peer-api-check.js" + "peer-api-check": "node ../../../scripts/peer-api-check.js", + "align-api-deps": "node ../../../scripts/align-api-deps.js" }, "keywords": [ "opentelemetry", diff --git a/experimental/packages/opentelemetry-instrumentation-xml-http-request/package.json b/experimental/packages/opentelemetry-instrumentation-xml-http-request/package.json index 3b383728500..9cf73a56282 100644 --- a/experimental/packages/opentelemetry-instrumentation-xml-http-request/package.json +++ b/experimental/packages/opentelemetry-instrumentation-xml-http-request/package.json @@ -20,7 +20,8 @@ "watch": "tsc --build --watch tsconfig.json tsconfig.esm.json tsconfig.esnext.json", "precompile": "cross-var lerna run version --scope $npm_package_name --include-dependencies", "prewatch": "node ../../../scripts/version-update.js", - "peer-api-check": "node ../../../scripts/peer-api-check.js" + "peer-api-check": "node ../../../scripts/peer-api-check.js", + "align-api-deps": "node ../../../scripts/align-api-deps.js" }, "keywords": [ "opentelemetry", diff --git a/experimental/packages/opentelemetry-instrumentation/package.json b/experimental/packages/opentelemetry-instrumentation/package.json index 0ecb7a53fba..5adb816886e 100644 --- a/experimental/packages/opentelemetry-instrumentation/package.json +++ b/experimental/packages/opentelemetry-instrumentation/package.json @@ -56,7 +56,8 @@ "watch": "tsc --build --watch tsconfig.json tsconfig.esm.json tsconfig.esnext.json", "precompile": "cross-var lerna run version --scope $npm_package_name --include-dependencies", "prewatch": "node ../../../scripts/version-update.js", - "peer-api-check": "node ../../../scripts/peer-api-check.js" + "peer-api-check": "node ../../../scripts/peer-api-check.js", + "align-api-deps": "node ../../../scripts/align-api-deps.js" }, "keywords": [ "opentelemetry", diff --git a/experimental/packages/opentelemetry-sdk-node/package.json b/experimental/packages/opentelemetry-sdk-node/package.json index 93047b5cdcf..ecf0124ca7a 100644 --- a/experimental/packages/opentelemetry-sdk-node/package.json +++ b/experimental/packages/opentelemetry-sdk-node/package.json @@ -17,7 +17,8 @@ "watch": "tsc --build --watch", "precompile": "cross-var lerna run version --scope $npm_package_name --include-dependencies", "prewatch": "npm run precompile", - "peer-api-check": "node ../../../scripts/peer-api-check.js" + "peer-api-check": "node ../../../scripts/peer-api-check.js", + "align-api-deps": "node ../../../scripts/align-api-deps.js" }, "keywords": [ "opentelemetry", diff --git a/experimental/packages/otlp-exporter-base/package.json b/experimental/packages/otlp-exporter-base/package.json index dc197314b3c..107d10fe929 100644 --- a/experimental/packages/otlp-exporter-base/package.json +++ b/experimental/packages/otlp-exporter-base/package.json @@ -28,7 +28,8 @@ "version": "node ../../../scripts/version-update.js", "watch": "tsc --build --watch tsconfig.json tsconfig.esm.json tsconfig.esnext.json", "precompile": "cross-var lerna run version --scope $npm_package_name --include-dependencies", - "prewatch": "npm run precompile" + "prewatch": "npm run precompile", + "align-api-deps": "node ../../../scripts/align-api-deps.js" }, "keywords": [ "opentelemetry", diff --git a/experimental/packages/otlp-grpc-exporter-base/package.json b/experimental/packages/otlp-grpc-exporter-base/package.json index 12c6b33dde5..15d74b76be1 100644 --- a/experimental/packages/otlp-grpc-exporter-base/package.json +++ b/experimental/packages/otlp-grpc-exporter-base/package.json @@ -17,7 +17,8 @@ "version": "node ../../../scripts/version-update.js", "watch": "tsc -w", "precompile": "cross-var lerna run version --scope $npm_package_name --include-dependencies", - "prewatch": "npm run precompile" + "prewatch": "npm run precompile", + "align-api-deps": "node ../../../scripts/align-api-deps.js" }, "keywords": [ "opentelemetry", diff --git a/experimental/packages/otlp-transformer/package.json b/experimental/packages/otlp-transformer/package.json index 4683ffc6867..e2cee7d3b96 100644 --- a/experimental/packages/otlp-transformer/package.json +++ b/experimental/packages/otlp-transformer/package.json @@ -28,7 +28,8 @@ "prewatch": "node ../../../scripts/version-update.js", "watch": "npm run protos && tsc -w tsconfig.json tsconfig.esm.json tsconfig.esnext.json", "peer-api-check": "node ../../../scripts/peer-api-check.js", - "codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../../" + "codecov": "nyc report --reporter=json && codecov -f coverage/*.json -p ../../../", + "align-api-deps": "node ../../../scripts/align-api-deps.js" }, "keywords": [ "opentelemetry", diff --git a/experimental/packages/propagator-aws-xray-lambda/package.json b/experimental/packages/propagator-aws-xray-lambda/package.json index e3fa20ec1dc..a0edaba5fe5 100644 --- a/experimental/packages/propagator-aws-xray-lambda/package.json +++ b/experimental/packages/propagator-aws-xray-lambda/package.json @@ -15,7 +15,9 @@ "lint": "eslint . --ext .ts", "lint:fix": "eslint . --ext .ts --fix", "watch": "tsc --build --watch tsconfig.json tsconfig.esm.json", - "prepublishOnly": "npm run compile" + "prepublishOnly": "npm run compile", + "peer-api-check": "node ../../../scripts/peer-api-check.js", + "align-api-deps": "node ../../../scripts/align-api-deps.js" }, "keywords": [ "opentelemetry", diff --git a/experimental/packages/sdk-logs/package.json b/experimental/packages/sdk-logs/package.json index 63a165f7951..d2324840b0f 100644 --- a/experimental/packages/sdk-logs/package.json +++ b/experimental/packages/sdk-logs/package.json @@ -43,7 +43,8 @@ "watch": "tsc --build --watch tsconfig.json tsconfig.esm.json tsconfig.esnext.json", "precompile": "cross-var lerna run version --scope $npm_package_name --include-dependencies", "prewatch": "node ../../../scripts/version-update.js", - "peer-api-check": "node ../../../scripts/peer-api-check.js" + "peer-api-check": "node ../../../scripts/peer-api-check.js", + "align-api-deps": "node ../../../scripts/align-api-deps.js" }, "keywords": [ "opentelemetry", diff --git a/experimental/packages/shim-opencensus/package.json b/experimental/packages/shim-opencensus/package.json index 257e1637b58..c29a0c880df 100644 --- a/experimental/packages/shim-opencensus/package.json +++ b/experimental/packages/shim-opencensus/package.json @@ -22,7 +22,8 @@ "watch": "tsc --build --watch", "precompile": "cross-var lerna run version --scope $npm_package_name --include-dependencies", "prewatch": "npm run precompile", - "peer-api-check": "node ../../../scripts/peer-api-check.js" + "peer-api-check": "node ../../../scripts/peer-api-check.js", + "align-api-deps": "node ../../../scripts/align-api-deps.js" }, "keywords": [ "opentelemetry", diff --git a/package.json b/package.json index 74e4153b0a4..31960b06b8c 100644 --- a/package.json +++ b/package.json @@ -41,6 +41,7 @@ "comment_prepare_3": "echo sdk preparation scripts prepare all stable and experimental packages", "prepare_release:sdk:patch": "npm run _check:no_changes && npm run _backup:package-json && npm run _lerna:remove_api && npm run _lerna:version_patch && npm run _restore:package-json && npm run _changelog:prepare_experimental && npm run _changelog:prepare_stable", "prepare_release:sdk:minor": "npm run _check:no_changes && npm run _backup:package-json && npm run _lerna:remove_api && npm run _lerna:version_minor && npm run _restore:package-json && npm run _changelog:prepare_experimental && npm run _changelog:prepare_stable", + "prepare_release:all:minor": "npm run _check:no_changes && npm run _backup:package-json && npm run _lerna:remove_api && npm run _lerna:version_minor && cd api/ && npm version minor && cd .. && lerna run align-api-deps && npm run _restore:package-json && npm run _changelog:prepare_all", "release:publish": "lerna publish from-package --no-push --no-private --no-git-tag-version --no-verify-access", "comment_internal": "echo scripts below this line are for internal use", "_check:no_changes": "if [ ! -z \"$(git status -uall --porcelain)\" ]; then echo Please ensure all changes are committed; exit 1; fi", @@ -51,7 +52,13 @@ "_lerna:version_patch": "npx lerna version patch --exact --no-git-tag-version --no-push --yes", "_lerna:version_minor": "npx lerna version minor --exact --no-git-tag-version --no-push --yes", "_changelog:prepare_experimental": "node scripts/update-changelog.js ./experimental/CHANGELOG.md ./experimental/packages/", - "_changelog:prepare_stable": "node scripts/update-changelog.js ./CHANGELOG.md ./packages/" + "_changelog:prepare_stable": "node scripts/update-changelog.js ./CHANGELOG.md ./packages/", + "_changelog:prepare_api": "node scripts/update-changelog.js ./api/CHANGELOG.md ./api/package.json", + "_changelog:prepare_all": "npm run _changelog:prepare_api && npm run _changelog:prepare_experimental && npm run _changelog:prepare_stable", + "_github:draft_release:all": "npm run _github:draft_release:api && _github:draft_release:experimental && _github:draft_release:stable", + "_github:draft_release:api": "node scripts/extract-latest-release-notes.js ./api/CHANGELOG.md && VERSION=$(node scripts/get-version.js ./api/package.json | grep -oP '^\\d+\\.\\d+\\.\\d+$') && gh release create --draft --notes-file ./.tmp/release-notes.md --target main --title api/v$VERSION api/v$VERSION", + "_github:draft_release:experimental": "node scripts/extract-latest-release-notes.js ./experimental/CHANGELOG.md && VERSION=$(node scripts/get-version.js ./experimental/packages/ | grep -oP '^\\d+\\.\\d+\\.\\d+$') && gh release create --draft --notes-file ./.tmp/release-notes.md --target main --title experimental/v$VERSION experimental/v$VERSION", + "_github:draft_release:stable": "node scripts/extract-latest-release-notes.js ./CHANGELOG.md && VERSION=$(node scripts/get-version.js ./packages/ | grep -oP '^\\d+\\.\\d+\\.\\d+$') && gh release create --draft --notes-file ./.tmp/release-notes.md --target main --title v$VERSION v$VERSION" }, "repository": "open-telemetry/opentelemetry-js", "keywords": [ diff --git a/packages/opentelemetry-context-async-hooks/package.json b/packages/opentelemetry-context-async-hooks/package.json index dcfde4e94d6..fe3204fbcff 100644 --- a/packages/opentelemetry-context-async-hooks/package.json +++ b/packages/opentelemetry-context-async-hooks/package.json @@ -17,7 +17,8 @@ "version": "node ../../scripts/version-update.js", "precompile": "cross-var lerna run version --scope $npm_package_name --include-dependencies", "prewatch": "npm run precompile", - "peer-api-check": "node ../../scripts/peer-api-check.js" + "peer-api-check": "node ../../scripts/peer-api-check.js", + "align-api-deps": "node ../../scripts/align-api-deps.js" }, "keywords": [ "opentelemetry", diff --git a/packages/opentelemetry-context-zone-peer-dep/package.json b/packages/opentelemetry-context-zone-peer-dep/package.json index 7861c86d47d..f3eea183ca2 100644 --- a/packages/opentelemetry-context-zone-peer-dep/package.json +++ b/packages/opentelemetry-context-zone-peer-dep/package.json @@ -20,7 +20,8 @@ "watch": "tsc --build --watch tsconfig.json tsconfig.esm.json tsconfig.esnext.json", "precompile": "cross-var lerna run version --scope $npm_package_name --include-dependencies", "prewatch": "npm run precompile", - "peer-api-check": "node ../../scripts/peer-api-check.js" + "peer-api-check": "node ../../scripts/peer-api-check.js", + "align-api-deps": "node ../../scripts/align-api-deps.js" }, "keywords": [ "opentelemetry", diff --git a/packages/opentelemetry-context-zone/package.json b/packages/opentelemetry-context-zone/package.json index 3335eca931d..97d69c3dba2 100644 --- a/packages/opentelemetry-context-zone/package.json +++ b/packages/opentelemetry-context-zone/package.json @@ -17,7 +17,8 @@ "watch": "tsc --build --watch tsconfig.json tsconfig.esm.json tsconfig.esnext.json", "precompile": "cross-var lerna run version --scope $npm_package_name --include-dependencies", "prewatch": "npm run precompile", - "peer-api-check": "node ../../scripts/peer-api-check.js" + "peer-api-check": "node ../../scripts/peer-api-check.js", + "align-api-deps": "node ../../scripts/align-api-deps.js" }, "keywords": [ "opentelemetry", diff --git a/packages/opentelemetry-core/package.json b/packages/opentelemetry-core/package.json index 474f3980efb..dd753ccbc76 100644 --- a/packages/opentelemetry-core/package.json +++ b/packages/opentelemetry-core/package.json @@ -30,7 +30,8 @@ "watch": "tsc --build --watch tsconfig.json tsconfig.esm.json tsconfig.esnext.json", "precompile": "cross-var lerna run version --scope $npm_package_name --include-dependencies", "prewatch": "npm run precompile", - "peer-api-check": "node ../../scripts/peer-api-check.js" + "peer-api-check": "node ../../scripts/peer-api-check.js", + "align-api-deps": "node ../../scripts/align-api-deps.js" }, "keywords": [ "opentelemetry", diff --git a/packages/opentelemetry-exporter-jaeger/package.json b/packages/opentelemetry-exporter-jaeger/package.json index 351f1d47508..7bc2b559057 100644 --- a/packages/opentelemetry-exporter-jaeger/package.json +++ b/packages/opentelemetry-exporter-jaeger/package.json @@ -18,7 +18,8 @@ "watch": "tsc --build --watch", "precompile": "cross-var lerna run version --scope $npm_package_name --include-dependencies", "prewatch": "npm run precompile", - "peer-api-check": "node ../../scripts/peer-api-check.js" + "peer-api-check": "node ../../scripts/peer-api-check.js", + "align-api-deps": "node ../../scripts/align-api-deps.js" }, "keywords": [ "opentelemetry", diff --git a/packages/opentelemetry-exporter-zipkin/package.json b/packages/opentelemetry-exporter-zipkin/package.json index 8ab3a2d62a0..b418899bce1 100644 --- a/packages/opentelemetry-exporter-zipkin/package.json +++ b/packages/opentelemetry-exporter-zipkin/package.json @@ -28,7 +28,8 @@ "watch": "tsc --build --watch tsconfig.json tsconfig.esm.json tsconfig.esnext.json", "precompile": "cross-var lerna run version --scope $npm_package_name --include-dependencies", "prewatch": "npm run precompile", - "peer-api-check": "node ../../scripts/peer-api-check.js" + "peer-api-check": "node ../../scripts/peer-api-check.js", + "align-api-deps": "node ../../scripts/align-api-deps.js" }, "keywords": [ "opentelemetry", diff --git a/packages/opentelemetry-propagator-b3/package.json b/packages/opentelemetry-propagator-b3/package.json index 8ce6a0587ec..18aca8fedb8 100644 --- a/packages/opentelemetry-propagator-b3/package.json +++ b/packages/opentelemetry-propagator-b3/package.json @@ -19,7 +19,8 @@ "watch": "tsc --build --watch tsconfig.json tsconfig.esm.json tsconfig.esnext.json", "precompile": "cross-var lerna run version --scope $npm_package_name --include-dependencies", "prewatch": "npm run precompile", - "peer-api-check": "node ../../scripts/peer-api-check.js" + "peer-api-check": "node ../../scripts/peer-api-check.js", + "align-api-deps": "node ../../scripts/align-api-deps.js" }, "keywords": [ "opentelemetry", diff --git a/packages/opentelemetry-propagator-jaeger/package.json b/packages/opentelemetry-propagator-jaeger/package.json index 8364e3d8313..0663f6b62e8 100644 --- a/packages/opentelemetry-propagator-jaeger/package.json +++ b/packages/opentelemetry-propagator-jaeger/package.json @@ -22,7 +22,8 @@ "watch": "tsc --build --watch tsconfig.json tsconfig.esm.json tsconfig.esnext.json", "precompile": "cross-var lerna run version --scope $npm_package_name --include-dependencies", "prewatch": "npm run precompile", - "peer-api-check": "node ../../scripts/peer-api-check.js" + "peer-api-check": "node ../../scripts/peer-api-check.js", + "align-api-deps": "node ../../scripts/align-api-deps.js" }, "keywords": [ "opentelemetry", diff --git a/packages/opentelemetry-resources/package.json b/packages/opentelemetry-resources/package.json index 21d0304ede5..ba5d0993f51 100644 --- a/packages/opentelemetry-resources/package.json +++ b/packages/opentelemetry-resources/package.json @@ -33,7 +33,8 @@ "version": "node ../../scripts/version-update.js", "precompile": "cross-var lerna run version --scope $npm_package_name --include-dependencies", "prewatch": "npm run precompile", - "peer-api-check": "node ../../scripts/peer-api-check.js" + "peer-api-check": "node ../../scripts/peer-api-check.js", + "align-api-deps": "node ../../scripts/align-api-deps.js" }, "keywords": [ "opentelemetry", diff --git a/packages/opentelemetry-sdk-trace-base/package.json b/packages/opentelemetry-sdk-trace-base/package.json index cb42a14c41a..b4c27d1eb6b 100644 --- a/packages/opentelemetry-sdk-trace-base/package.json +++ b/packages/opentelemetry-sdk-trace-base/package.json @@ -32,7 +32,8 @@ "watch": "tsc --build --watch tsconfig.json tsconfig.esm.json tsconfig.esnext.json", "precompile": "cross-var lerna run version --scope $npm_package_name --include-dependencies", "prewatch": "npm run precompile", - "peer-api-check": "node ../../scripts/peer-api-check.js" + "peer-api-check": "node ../../scripts/peer-api-check.js", + "align-api-deps": "node ../../scripts/align-api-deps.js" }, "keywords": [ "opentelemetry", diff --git a/packages/opentelemetry-sdk-trace-node/package.json b/packages/opentelemetry-sdk-trace-node/package.json index c166d440a01..9b96ef3e5fc 100644 --- a/packages/opentelemetry-sdk-trace-node/package.json +++ b/packages/opentelemetry-sdk-trace-node/package.json @@ -18,7 +18,8 @@ "watch": "tsc --build --watch", "precompile": "cross-var lerna run version --scope $npm_package_name --include-dependencies", "prewatch": "npm run precompile", - "peer-api-check": "node ../../scripts/peer-api-check.js" + "peer-api-check": "node ../../scripts/peer-api-check.js", + "align-api-deps": "node ../../scripts/align-api-deps.js" }, "keywords": [ "opentelemetry", diff --git a/packages/opentelemetry-sdk-trace-web/package.json b/packages/opentelemetry-sdk-trace-web/package.json index cac7a7baef1..d83fce5844e 100644 --- a/packages/opentelemetry-sdk-trace-web/package.json +++ b/packages/opentelemetry-sdk-trace-web/package.json @@ -22,7 +22,8 @@ "watch": "tsc --build --watch tsconfig.json tsconfig.esm.json tsconfig.esnext.json", "precompile": "cross-var lerna run version --scope $npm_package_name --include-dependencies", "prewatch": "npm run precompile", - "peer-api-check": "node ../../scripts/peer-api-check.js" + "peer-api-check": "node ../../scripts/peer-api-check.js", + "align-api-deps": "node ../../scripts/align-api-deps.js" }, "keywords": [ "opentelemetry", diff --git a/packages/opentelemetry-semantic-conventions/package.json b/packages/opentelemetry-semantic-conventions/package.json index 148d005cd75..64fe778b159 100644 --- a/packages/opentelemetry-semantic-conventions/package.json +++ b/packages/opentelemetry-semantic-conventions/package.json @@ -18,7 +18,8 @@ "precompile": "cross-var lerna run version --scope $npm_package_name --include-dependencies", "prewatch": "npm run precompile", "peer-api-check": "node ../../scripts/peer-api-check.js", - "size-check": "npm run compile && ts-mocha -p tsconfig.json 'test/**/*.test.ts'" + "size-check": "npm run compile && ts-mocha -p tsconfig.json 'test/**/*.test.ts'", + "align-api-deps": "node ../../scripts/align-api-deps.js" }, "keywords": [ "opentelemetry", diff --git a/packages/opentelemetry-shim-opentracing/package.json b/packages/opentelemetry-shim-opentracing/package.json index 5e9bc2e4770..e25f97bce10 100644 --- a/packages/opentelemetry-shim-opentracing/package.json +++ b/packages/opentelemetry-shim-opentracing/package.json @@ -17,7 +17,8 @@ "version": "node ../../scripts/version-update.js", "precompile": "cross-var lerna run version --scope $npm_package_name --include-dependencies", "prewatch": "npm run precompile", - "peer-api-check": "node ../../scripts/peer-api-check.js" + "peer-api-check": "node ../../scripts/peer-api-check.js", + "align-api-deps": "node ../../scripts/align-api-deps.js" }, "keywords": [ "opentelemetry", diff --git a/packages/propagator-aws-xray/package.json b/packages/propagator-aws-xray/package.json index f8686229978..060d527586d 100644 --- a/packages/propagator-aws-xray/package.json +++ b/packages/propagator-aws-xray/package.json @@ -23,7 +23,8 @@ "watch": "tsc --build --watch tsconfig.json tsconfig.esm.json tsconfig.esnext.json", "precompile": "cross-var lerna run version --scope $npm_package_name --include-dependencies", "prewatch": "npm run precompile", - "peer-api-check": "node ../../scripts/peer-api-check.js" + "peer-api-check": "node ../../scripts/peer-api-check.js", + "align-api-deps": "node ../../scripts/align-api-deps.js" }, "keywords": [ "opentelemetry", diff --git a/packages/sdk-metrics/package.json b/packages/sdk-metrics/package.json index c57c9f08950..a84cbf517ee 100644 --- a/packages/sdk-metrics/package.json +++ b/packages/sdk-metrics/package.json @@ -22,7 +22,8 @@ "watch": "tsc --build --watch tsconfig.json tsconfig.esm.json tsconfig.esnext.json", "precompile": "cross-var lerna run version --scope $npm_package_name --include-dependencies", "prewatch": "node ../../scripts/version-update.js", - "peer-api-check": "node ../../scripts/peer-api-check.js" + "peer-api-check": "node ../../scripts/peer-api-check.js", + "align-api-deps": "node ../../scripts/align-api-deps.js" }, "keywords": [ "opentelemetry", diff --git a/packages/template/package.json b/packages/template/package.json index ab4a9b1d651..d9b065b122a 100644 --- a/packages/template/package.json +++ b/packages/template/package.json @@ -32,7 +32,8 @@ "clean": "tsc --build --clean", "precompile": "cross-var lerna run version --scope $npm_package_name --include-dependencies", "prewatch": "npm run precompile", - "peer-api-check": "node ../../scripts/peer-api-check.js" + "peer-api-check": "node ../../scripts/peer-api-check.js", + "align-api-deps": "node ../../scripts/align-api-deps.js" }, "Add these to scripts": { "compile": "tsc --build", diff --git a/scripts/align-api-deps.js b/scripts/align-api-deps.js new file mode 100644 index 00000000000..59dc968954a --- /dev/null +++ b/scripts/align-api-deps.js @@ -0,0 +1,70 @@ +/** + * This extracts the current version from /api/package.json and aligns the + * dependencies in `./package.json` with that new version. For instance: + * - `"@opentelemetry/api": ">1.0.0 <1.9.0"` when the local `@opentelemetry/api` is at `1.9.0` will become `"@opentelemetry/api": ">1.0.0 <1.10.0"` + * - `"@opentelemetry/api": "^1.1.0"` will be left as-is when the local `@opentelemetry/api` is at `1.9.0` as it's already included in the range + * - `"@opentelemetry/api": "1.8.0" when the local `@opentelemetry/api` is at `1.9.0` will become `"@opentelemetry/api": "1.9.0"` + * + * Usage (from package directory): + * - node /scripts/align-api-deps.js + */ + +const fs = require('fs'); +const semver = require('semver'); +const path = require('path'); +const apiVersion = require(path.resolve(__dirname, '../api/package.json')).version; +const nextMinorApiVersion = semver.parse(apiVersion).inc('minor'); + +function alignIfExact(value) { + const exactVersionRegex = /^\d+\.\d+\.\d+$/; + const result = value.match(exactVersionRegex); + if(result == null){ + return value; + } + + // use current exact API version + return apiVersion; +} + +function alignIfRange(value){ + const limitingVersionRegex = /<(\d+\.\d+\.\d+)$/; + const result = value.match(limitingVersionRegex); + if(result == null){ + console.debug(`${value} is not a range, nothing to do`); + return value; + } + + return value.replace(limitingVersionRegex, `<${nextMinorApiVersion}`); +} + +function alignDeps(dependencies) { + for (const key in dependencies) { + if(key !== '@opentelemetry/api'){ + continue; + } + + if (dependencies.hasOwnProperty(key)) { + const value = dependencies[key]; + dependencies[key] = alignIfRange(alignIfExact(value)); + } + } + + return dependencies; +} + +function alignApiDeps(packageJsonPath){ + const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8')); + const categoriesToUpdate = ['peerDependencies', 'devDependencies', 'dependencies']; + + for(const category of categoriesToUpdate){ + if(packageJson[category] == null){ + console.debug(`${category} in ${packageJsonPath} was null or undefined, nothing to do.`); + continue; + } + alignDeps(packageJson[category]); + } + + fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, undefined, 2) + '\n', {encoding: 'utf-8'}); +} + +alignApiDeps(path.join(process.cwd(), './package.json')); diff --git a/scripts/extract-latest-release-notes.js b/scripts/extract-latest-release-notes.js new file mode 100644 index 00000000000..daa34eda355 --- /dev/null +++ b/scripts/extract-latest-release-notes.js @@ -0,0 +1,23 @@ +/** + * This extracts the latest (non-"Unreleased") notes from a CHANGELOG.md and saves them to `./.tmp/release-notes.md` + * + * Usage (from project root): + * - node scripts/extract-latest-release-notes.js [PATH TO CHANGELOG] + * Examples: + * - node scripts/extract-latest-release-notes.js ./packages/CHANGELOG.md + * - node scripts/extract-latest-release-notes.js ./experimental/CHANGELOG.md + */ + +const fs = require('fs'); + +const changelog = fs.readFileSync(process.argv[2]).toString(); +// Matches everything from the first entry at h2 ('##') followed by a space and a non-prerelease semver version +// until the next entry at h2. +const firstReleaseNoteEntryExp = /^## \d+\.\d+\.\d\n.*?(?=^## )/ms; + +fs.mkdirSync('./.tmp/', { + recursive: true +}); + +const notesFile = './.tmp/release-notes.md' +fs.writeFileSync(notesFile, changelog.match(firstReleaseNoteEntryExp)[0]); diff --git a/scripts/get-version.js b/scripts/get-version.js new file mode 100644 index 00000000000..63865b4ce75 --- /dev/null +++ b/scripts/get-version.js @@ -0,0 +1,55 @@ +/** + * This extracts the first version of a non-private package in a directory if the provided path is a directory + * OR the version inside the `package.json` the provided path is a file. + * + * Usage (from project root): + * - node scripts/get-version.js [PATH TO DIRECTORY | PATH TO FILE] + * Examples: + * - node scripts/get-version.js ./experimental/packages/ + * - node scripts/get-version.js ./api/package.json + */ + +const fs = require('fs'); +const path = require('path'); + +function extractVersionFromPackageJson(packageJsonPath){ + const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8')); + + if(packageJson.private === true || packageJson.private === 'true'){ + console.warn('Skipping version from private package at', packageJsonPath); + return undefined; + } + + if(packageJson.version == null){ + console.warn('Version in', packageJsonPath, 'was null or undefined, skipping'); + return undefined; + } + + return packageJson.version; +} + +function findFirstPackageVersion(basePath){ + const packageDirs = fs.readdirSync(basePath); + for(const packageDir of packageDirs){ + const packageJsonPath = path.join(basePath, packageDir, 'package.json'); + try { + const version = extractVersionFromPackageJson(packageJsonPath) + if(version != null){ + return version; + } + } catch (err) { + console.warn('Could not get package JSON', packageJsonPath, err); + } + } + throw new Error('Unable to extract version from packages in ' + basePath); +} + +function determineVersion(path){ + if(fs.lstatSync(path).isDirectory()) { + return findFirstPackageVersion(path); + } + + return extractVersionFromPackageJson(path); +} + +console.log(determineVersion(process.argv[2])); diff --git a/scripts/peer-api-check.js b/scripts/peer-api-check.js index bb5a1bea071..051bf31f4ba 100644 --- a/scripts/peer-api-check.js +++ b/scripts/peer-api-check.js @@ -34,7 +34,17 @@ function checkPackage(package) { const peerVersion = pjson.peerDependencies && pjson.peerDependencies[package]; const devVersion = pjson.devDependencies && pjson.devDependencies[package]; + + if(devVersion) { + if(devVersion.match(/^((>=\d+\.\d+\.\d+ <\d+\.\d+\.\d+)|(\^?\d+\.\d+\.\d+))$/) == null) { + throw new Error(`Package ${pjson.name} does not match required pattern '>=A.B.C =\d+\.\d+\.\d+ <\d+\.\d+\.\d+)|(\^\d+\.\d+\.\d+))$/) == null) { + throw new Error(`Package ${pjson.name} does not match required pattern '>=A.B.C