-
SummaryTo target subpackages of monorepos via github urls I had to write a little script run on Context
My issue
My questions
Other tracks
Ok, this seems enough for now, thanks in advance for your time and thank you very much for sharing your work! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Digging more I found a much better workaround:
Here is the working result: {
"name": "...",
"devDependencies": {
"@directus/extensions-sdk": "github:jclaveau/directus#my_branch&path:packages/extensions-sdk",
},
"dependencies": {
"@directus/errors": "github:jclaveau/directus#my_branch&path:packages/errors",
"@directus/sdk": "github:jclaveau/directus#my_branch&path:packages/sdk",
"//": "..."
}
} In const directusBranch = 'my_branch'
function readPackage(pkg, context) {
if (pkg.name.match(/^@directus\//) || pkg.name.match(/^directus$/)) {
// context.log(JSON.stringify(pkg, null, 2))
for (const depEntry of ['dependencies', 'devDependencies', 'peerDependencies']) {
if (!pkg[depEntry]) {
continue
}
pkg[depEntry] = Object.fromEntries(
Object.entries(pkg[depEntry])
.map(([key, value]) => fixForkedDependencies(key, value, context))
)
}
function fixForkedDependencies(depName, depVersion, context) {
if (depName.match(/^@directus\//) && depVersion.match(/^workspace:\*/)) {
const nameParts = depName.split('/')
const newVersion = ['api', 'directus', 'app'].includes(nameParts[1]) // sdk will be moved here in a later directus version
? 'github:jclaveau/directus#' + directusBranch + '&path:' + nameParts[1]
: 'github:jclaveau/directus#' + directusBranch + '&path:packages/' + nameParts[1]
context.log(`fixForkedDependencies of ${pkg.name}: ${depName}: ${depVersion} => ${newVersion}`)
depVersion = newVersion
}
return [depName, depVersion];
}
}
return pkg
}
module.exports = {
hooks: {
readPackage
}
} Pros:
Remaining issues:
|
Beta Was this translation helpful? Give feedback.
-
I opened a bug to track the support for monorepos btw #8243 |
Beta Was this translation helpful? Give feedback.
Digging more I found a much better workaround:
worspace:*
deps are not handled but this can be handle in.pnpmfile.cjs
Here is the working result:
In a
package.json
In
.pnpmfile.cjs