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: no need for 'packages' in "lerna.json" #4264

Merged
Merged
Show file tree
Hide file tree
Changes from 2 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: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ fix(sdk-metrics): hand-roll MetricAdvice type as older API versions do not inclu

### :house: (Internal)

* chore: no need for 'packages' in lerna.json [#4264](https://github.com/open-telemetry/opentelemetry-js/pull/4264) @trentm

## 1.18.0

### :rocket: (Enhancement)
Expand Down
17 changes: 1 addition & 16 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,5 @@
{
"version": "independent",
"npmClient": "npm",
"useWorkspaces": true,
"// packages": "Please sync with package.json#workspaces",
"packages": [
"api",
"packages/*",
"experimental/packages/*",
"experimental/examples/*",
"experimental/backwards-compatibility/*",
"integration-tests/*",
"selenium-tests",
"examples/otlp-exporter-node",
"examples/opentelemetry-web",
"examples/http",
"examples/https",
"examples/esm-http-ts"
]
"useWorkspaces": true
}
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@
},
"cacheDir": ".changelog"
},
"// workspaces": "Please sync with lerna.json#packages",
"workspaces": [
"api",
"packages/*",
Expand Down
28 changes: 14 additions & 14 deletions scripts/update-ts-configs.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,23 +71,23 @@ main();
function main() {
const pkgRoot = process.cwd();
const projectRoot = findProjectRoot(pkgRoot);
const lernaPackages = resolveLernaPackages(projectRoot);
const workspacePackages = resolveWorkspacePackages(projectRoot);

generateTsConfig(projectRoot, lernaPackages, pkgRoot, true);
for (const packageMeta of lernaPackages.values()) {
generateTsConfig(projectRoot, lernaPackages, path.join(projectRoot, packageMeta.dir), false, packageMeta);
generateTsConfig(projectRoot, workspacePackages, pkgRoot, true);
for (const packageMeta of workspacePackages.values()) {
generateTsConfig(projectRoot, workspacePackages, path.join(projectRoot, packageMeta.dir), false, packageMeta);
}
}

function generateTsConfig(projectRoot, lernaProjects, pkgRoot, isLernaRoot, packageMeta) {
function generateTsConfig(projectRoot, workspacePackages, pkgRoot, isLernaRoot, packageMeta) {
// Root tsconfig.json
if (isLernaRoot) {
writeRootTsConfigJson(pkgRoot, projectRoot, lernaProjects);
writeRootTsConfigJson(pkgRoot, projectRoot, workspacePackages);
return;
}

const otelDependencies = getOtelDependencies(packageMeta.pkgJson);
const dependenciesDir = resolveDependencyDirs(lernaProjects, otelDependencies);
const dependenciesDir = resolveDependencyDirs(workspacePackages, otelDependencies);
const references = dependenciesDir.map(it => path.relative(pkgRoot, path.join(projectRoot, it))).sort();

if (packageMeta.hasMultiTarget) {
Expand All @@ -97,24 +97,24 @@ function generateTsConfig(projectRoot, lernaProjects, pkgRoot, isLernaRoot, pack
writeSingleTargetTsConfig(pkgRoot, projectRoot, references);
}

function writeRootTsConfigJson(pkgRoot, projectRoot, lernaProjects) {
function writeRootTsConfigJson(pkgRoot, projectRoot, workspacePackages) {
const tsconfigPath = path.join(pkgRoot, 'tsconfig.json');
const tsconfig = readJSON(tsconfigPath);
const references = Array.from(lernaProjects.values())
const references = Array.from(workspacePackages.values())
.filter(it => it.isTsProject)
.map(it => toPosix(path.relative(pkgRoot, path.join(projectRoot, it.dir)))).sort();
tsconfig.references = references.map(path => {
return { path: toPosix(path) }
});
tsconfig.typedocOptions.entryPoints = Array.from(lernaProjects.values())
tsconfig.typedocOptions.entryPoints = Array.from(workspacePackages.values())
.filter(it => !it.private && it.isTsProject)
.map(it => toPosix(path.relative(pkgRoot, path.join(projectRoot, it.dir)))).sort();
writeJSON(tsconfigPath, tsconfig, dryRun);

for (const tsconfigName of ['tsconfig.esm.json', 'tsconfig.esnext.json']) {
const tsconfigPath = path.join(pkgRoot, tsconfigName);
const tsconfig = readJSON(tsconfigPath);
const references = Array.from(lernaProjects.values())
const references = Array.from(workspacePackages.values())
.filter(it => it.isTsProject && it.hasMultiTarget)
.map(it => toPosix(path.relative(pkgRoot, path.join(projectRoot, it.dir)))).sort();
tsconfig.references = references.map(pkgPath => {
Expand Down Expand Up @@ -182,10 +182,10 @@ function getOtelDependencies(packageJson) {
return Array.from(deps.values());
}

function resolveLernaPackages(projectRoot) {
function resolveWorkspacePackages(projectRoot) {
const map = new Map();
const lernaJson = readJSON(`${projectRoot}/lerna.json`);
for (const pkgDefinition of lernaJson.packages) {
const packageJson = readJSON(`${projectRoot}/package.json`);
for (const pkgDefinition of packageJson.workspaces) {
if (ignoredLernaProjects.includes(pkgDefinition)) {
continue;
}
Expand Down