Skip to content

Commit 0b6a511

Browse files
committed
Published using @Stream44 Studio
Signed-off-by: Christoph <christoph@christoph.diy>
1 parent 74a7672 commit 0b6a511

2 files changed

Lines changed: 42 additions & 9 deletions

File tree

caps/patterns/semver.org/ProjectPublishing.ts

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,35 @@ export async function capsule({
105105
await writeFile(packageJsonPath, updatedContent, 'utf-8')
106106
console.log(chalk.green(` ✓ Updated workspace dependencies in ${packageJsonPath}\n`))
107107
}
108+
109+
// Follow workspaces declarations to update sub-workspace package.json files
110+
const workspaces: string[] = packageJson.workspaces || []
111+
if (workspaces.length > 0) {
112+
const workspacePatterns = workspaces.map(ws => join(ws, 'package.json'))
113+
const subPackageJsonPaths = await glob(workspacePatterns, {
114+
cwd: repoSourceDir as string,
115+
absolute: true,
116+
onlyFiles: true,
117+
})
118+
119+
for (const subPkgPath of subPackageJsonPaths) {
120+
try {
121+
const subContent = await readFile(subPkgPath, 'utf-8')
122+
const subIndent = detectIndent(subContent)
123+
const subPkg = JSON.parse(subContent)
124+
125+
await updateWorkspaceDependencies(subPkg, workspaceNpmPackageNames, workspacePackageSourceDirs, publicNpmPackageNames)
126+
127+
const subUpdated = JSON.stringify(subPkg, null, subIndent) + '\n'
128+
if (subUpdated !== subContent) {
129+
await writeFile(subPkgPath, subUpdated, 'utf-8')
130+
console.log(chalk.green(` ✓ Updated workspace dependencies in ${subPkgPath}\n`))
131+
}
132+
} catch (e) {
133+
// Skip sub-workspaces with unreadable package.json
134+
}
135+
}
136+
}
108137
}
109138
}
110139
}
@@ -228,13 +257,13 @@ async function buildWorkspacePackageMaps(repositoriesConfig: any, npmRenames: Re
228257
workspaceNpmPackageNames[renamedName] = workspacePackageName
229258
}
230259
} catch (error) {
231-
// Skip repos without a readable package.json
260+
console.log(chalk.gray(` [debug] Could not read ${packageJsonPath}: ${error}`))
232261
}
233262

234263
const providers = (repoConfig as any).providers || ((repoConfig as any).provider ? [(repoConfig as any).provider] : [])
235264

236265
for (const provider of providers) {
237-
if (provider.capsule === 't44/caps/patterns/npmjs.com/ProjectPublishing') {
266+
if (provider.capsule === '@stream44.studio/t44-npmjs.com/caps/ProjectPublishing') {
238267
try {
239268
const packageJsonContent = await readFile(packageJsonPath, 'utf-8')
240269
const packageJson = JSON.parse(packageJsonContent)
@@ -278,10 +307,14 @@ async function updateWorkspaceDependencies(
278307
if (typeof depVersion === 'string' && depVersion.startsWith('workspace:')) {
279308
try {
280309
const workspaceDepName = workspaceNpmPackageNames[depName] || depName
281-
const depSourceDir = workspacePackageSourceDirs[workspaceDepName]
310+
const depSourceDir = workspacePackageSourceDirs[workspaceDepName] || workspacePackageSourceDirs[depName]
282311

283312
if (!depSourceDir) {
284-
throw new Error(`Could not find source directory for workspace dependency ${depName} (${workspaceDepName})`)
313+
throw new Error(
314+
`Could not find source directory for workspace dependency ${depName} (resolved to: ${workspaceDepName})\n` +
315+
` workspaceNpmPackageNames keys: ${Object.keys(workspaceNpmPackageNames).join(', ')}\n` +
316+
` workspacePackageSourceDirs keys: ${Object.keys(workspacePackageSourceDirs).join(', ')}`
317+
)
285318
}
286319

287320
const depPackageJsonPath = join(depSourceDir, 'package.json')

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "t44",
3-
"version": "0.4.0-rc.20",
3+
"version": "0.4.0-rc.21",
44
"license": "LGPL",
55
"repository": {
66
"type": "git",
@@ -71,14 +71,14 @@
7171
"@ucanto/principal": "^9.0.3",
7272
"@ucanto/server": "^11.0.3",
7373
"json-schema-ref-resolver": "^3.0.0",
74+
"@stream44.studio/encapsulate": "^0.4.0-rc.21"
75+
},
76+
"optionalDependencies": {
7477
"@stream44.studio/t44-bunny.net": "^0.1.0-rc.3",
7578
"@stream44.studio/t44-vercel.com": "^0.1.0-rc.3",
7679
"@stream44.studio/t44-github.com": "^0.1.0-rc.3",
7780
"@stream44.studio/t44-dynadot.com": "^0.1.0-rc.3",
78-
"@stream44.studio/t44-npmjs.com": "^0.1.0-rc.3",
79-
"@stream44.studio/encapsulate": "^0.4.0-rc.21",
80-
"@stream44.studio/dco": "^0.3.0-rc.24",
81-
"@stream44.studio/t44-blockchaincommons.com": "^0.1.0-rc.19"
81+
"@stream44.studio/t44-npmjs.com": "^0.1.0-rc.3"
8282
},
8383
"devDependencies": {
8484
"@types/bun": "^1.3.4",

0 commit comments

Comments
 (0)