Skip to content

Commit 7b6e3b0

Browse files
committed
ci: update version if find deps
1 parent 8603c60 commit 7b6e3b0

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

tools/scripts/prepare-package-json.mjs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,36 @@ try {
4040
function removeDepFromOtherLib(graph, name, json) {
4141
const libsName = Object.values(graph.nodes)
4242
.filter((i) => i.data.tags.includes('type:publish'))
43-
.map((i) => i.data.metadata.js.packageName);
43+
.reduce((acum, i) => {
44+
acum[i.data.metadata.js.packageName] = i.data.root;
45+
return acum;
46+
}, {});
47+
48+
for (const [name] of Object.entries(json.dependencies)) {
49+
if (!Object.keys(libsName).includes(name)) {
50+
continue;
51+
}
52+
try {
53+
const jsonDep = JSON.parse(
54+
readFileSync(
55+
join(workspaceRoot, libsName[name], 'package.json')
56+
).toString()
57+
);
58+
json.dependencies[name] = jsonDep.version;
59+
} catch (e) {
60+
console.warn(
61+
'Can parse:',
62+
join(workspaceRoot, libsName[name], 'package.json')
63+
);
64+
}
4465

66+
console.log(libsName[name]);
67+
}
4568
if (!('peerDependencies' in json)) return;
4669

4770
json['peerDependencies'] = Object.entries(json['peerDependencies']).reduce(
4871
(acum, [name, value]) => {
49-
if (libsName.includes(name)) {
72+
if (Object.keys(libsName).includes(name)) {
5073
acum[name] = `^${value}`;
5174
}
5275
return acum;

0 commit comments

Comments
 (0)