chore: no need for 'packages' in "lerna.json" (#4264)
This commit is contained in:
parent
f665499096
commit
c478c11975
|
@ -15,6 +15,8 @@ For experimental package changes, see the [experimental CHANGELOG](experimental/
|
||||||
|
|
||||||
### :house: (Internal)
|
### :house: (Internal)
|
||||||
|
|
||||||
|
* chore: no need for 'packages' in lerna.json [#4264](https://github.com/open-telemetry/opentelemetry-js/pull/4264) @trentm
|
||||||
|
|
||||||
## 1.18.1
|
## 1.18.1
|
||||||
|
|
||||||
### :bug: (Bug Fix)
|
### :bug: (Bug Fix)
|
||||||
|
|
17
lerna.json
17
lerna.json
|
@ -1,20 +1,5 @@
|
||||||
{
|
{
|
||||||
"version": "independent",
|
"version": "independent",
|
||||||
"npmClient": "npm",
|
"npmClient": "npm",
|
||||||
"useWorkspaces": true,
|
"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"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,7 +102,6 @@
|
||||||
},
|
},
|
||||||
"cacheDir": ".changelog"
|
"cacheDir": ".changelog"
|
||||||
},
|
},
|
||||||
"// workspaces": "Please sync with lerna.json#packages",
|
|
||||||
"workspaces": [
|
"workspaces": [
|
||||||
"api",
|
"api",
|
||||||
"packages/*",
|
"packages/*",
|
||||||
|
|
|
@ -71,23 +71,23 @@ main();
|
||||||
function main() {
|
function main() {
|
||||||
const pkgRoot = process.cwd();
|
const pkgRoot = process.cwd();
|
||||||
const projectRoot = findProjectRoot(pkgRoot);
|
const projectRoot = findProjectRoot(pkgRoot);
|
||||||
const lernaPackages = resolveLernaPackages(projectRoot);
|
const workspacePackages = resolveWorkspacePackages(projectRoot);
|
||||||
|
|
||||||
generateTsConfig(projectRoot, lernaPackages, pkgRoot, true);
|
generateTsConfig(projectRoot, workspacePackages, pkgRoot, true);
|
||||||
for (const packageMeta of lernaPackages.values()) {
|
for (const packageMeta of workspacePackages.values()) {
|
||||||
generateTsConfig(projectRoot, lernaPackages, path.join(projectRoot, packageMeta.dir), false, packageMeta);
|
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
|
// Root tsconfig.json
|
||||||
if (isLernaRoot) {
|
if (isLernaRoot) {
|
||||||
writeRootTsConfigJson(pkgRoot, projectRoot, lernaProjects);
|
writeRootTsConfigJson(pkgRoot, projectRoot, workspacePackages);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const otelDependencies = getOtelDependencies(packageMeta.pkgJson);
|
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();
|
const references = dependenciesDir.map(it => path.relative(pkgRoot, path.join(projectRoot, it))).sort();
|
||||||
|
|
||||||
if (packageMeta.hasMultiTarget) {
|
if (packageMeta.hasMultiTarget) {
|
||||||
|
@ -97,16 +97,16 @@ function generateTsConfig(projectRoot, lernaProjects, pkgRoot, isLernaRoot, pack
|
||||||
writeSingleTargetTsConfig(pkgRoot, projectRoot, references);
|
writeSingleTargetTsConfig(pkgRoot, projectRoot, references);
|
||||||
}
|
}
|
||||||
|
|
||||||
function writeRootTsConfigJson(pkgRoot, projectRoot, lernaProjects) {
|
function writeRootTsConfigJson(pkgRoot, projectRoot, workspacePackages) {
|
||||||
const tsconfigPath = path.join(pkgRoot, 'tsconfig.json');
|
const tsconfigPath = path.join(pkgRoot, 'tsconfig.json');
|
||||||
const tsconfig = readJSON(tsconfigPath);
|
const tsconfig = readJSON(tsconfigPath);
|
||||||
const references = Array.from(lernaProjects.values())
|
const references = Array.from(workspacePackages.values())
|
||||||
.filter(it => it.isTsProject)
|
.filter(it => it.isTsProject)
|
||||||
.map(it => toPosix(path.relative(pkgRoot, path.join(projectRoot, it.dir)))).sort();
|
.map(it => toPosix(path.relative(pkgRoot, path.join(projectRoot, it.dir)))).sort();
|
||||||
tsconfig.references = references.map(path => {
|
tsconfig.references = references.map(path => {
|
||||||
return { path: toPosix(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)
|
.filter(it => !it.private && it.isTsProject)
|
||||||
.map(it => toPosix(path.relative(pkgRoot, path.join(projectRoot, it.dir)))).sort();
|
.map(it => toPosix(path.relative(pkgRoot, path.join(projectRoot, it.dir)))).sort();
|
||||||
writeJSON(tsconfigPath, tsconfig, dryRun);
|
writeJSON(tsconfigPath, tsconfig, dryRun);
|
||||||
|
@ -114,7 +114,7 @@ function writeRootTsConfigJson(pkgRoot, projectRoot, lernaProjects) {
|
||||||
for (const tsconfigName of ['tsconfig.esm.json', 'tsconfig.esnext.json']) {
|
for (const tsconfigName of ['tsconfig.esm.json', 'tsconfig.esnext.json']) {
|
||||||
const tsconfigPath = path.join(pkgRoot, tsconfigName);
|
const tsconfigPath = path.join(pkgRoot, tsconfigName);
|
||||||
const tsconfig = readJSON(tsconfigPath);
|
const tsconfig = readJSON(tsconfigPath);
|
||||||
const references = Array.from(lernaProjects.values())
|
const references = Array.from(workspacePackages.values())
|
||||||
.filter(it => it.isTsProject && it.hasMultiTarget)
|
.filter(it => it.isTsProject && it.hasMultiTarget)
|
||||||
.map(it => toPosix(path.relative(pkgRoot, path.join(projectRoot, it.dir)))).sort();
|
.map(it => toPosix(path.relative(pkgRoot, path.join(projectRoot, it.dir)))).sort();
|
||||||
tsconfig.references = references.map(pkgPath => {
|
tsconfig.references = references.map(pkgPath => {
|
||||||
|
@ -182,10 +182,10 @@ function getOtelDependencies(packageJson) {
|
||||||
return Array.from(deps.values());
|
return Array.from(deps.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
function resolveLernaPackages(projectRoot) {
|
function resolveWorkspacePackages(projectRoot) {
|
||||||
const map = new Map();
|
const map = new Map();
|
||||||
const lernaJson = readJSON(`${projectRoot}/lerna.json`);
|
const packageJson = readJSON(`${projectRoot}/package.json`);
|
||||||
for (const pkgDefinition of lernaJson.packages) {
|
for (const pkgDefinition of packageJson.workspaces) {
|
||||||
if (ignoredLernaProjects.includes(pkgDefinition)) {
|
if (ignoredLernaProjects.includes(pkgDefinition)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue