Fix npm packages to not use legacy repository format (#10576)

* Fix packages script

Signed-off-by: Artem Savchenko <armisav@gmail.com>

* Fix npm packages to not use legacy string repo

Signed-off-by: Artem Savchenko <armisav@gmail.com>

---------

Signed-off-by: Artem Savchenko <armisav@gmail.com>
This commit is contained in:
Artyom Savchenko
2026-03-06 12:25:21 +07:00
committed by GitHub
parent 7a7020292b
commit 5613b4f708
102 changed files with 464 additions and 107 deletions
+57
View File
@@ -0,0 +1,57 @@
#!/usr/bin/env node
/**
* Run npm pkg fix on all @hcengineering packages in the monorepo.
* Usage: node common/scripts/fix-packages.js
*/
const path = require('path')
const execSync = require('child_process').execSync
const repo = '@hcengineering'
const repoRoot = execSync('git rev-parse --show-toplevel', { encoding: 'utf-8' }).trim()
function main () {
const output = execSync('node common/scripts/install-run-rush.js list -p --json', {
encoding: 'utf-8',
cwd: repoRoot
})
const lines = output.split('\n')
let jsonStart = -1
for (let i = 0; i < lines.length; i++) {
if (lines[i].trim().startsWith('{')) {
jsonStart = i
break
}
}
if (jsonStart === -1) {
console.error('Could not find JSON output from rush list')
process.exit(1)
}
const config = JSON.parse(lines.slice(jsonStart).join('\n'))
const packages = []
for (const project of config.projects) {
const packageName = project.name ?? project.packageName
if (typeof packageName !== 'string' || !packageName.startsWith(repo)) continue
const projectPath = project.path ?? project.projectFolder ?? path.relative(repoRoot, project.fullPath ?? '')
if (typeof projectPath !== 'string' || projectPath.length === 0) continue
packages.push({
name: packageName,
path: path.resolve(repoRoot, projectPath)
})
}
console.log('Fixing package.json in all @hcengineering packages...')
for (const pkg of packages) {
try {
console.log('fixing', pkg.name)
execSync('npm pkg fix', { encoding: 'utf-8', cwd: pkg.path, stdio: 'pipe' })
} catch (err) {
console.error('Failed:', pkg.name, err.message)
}
}
console.log('... done')
}
main()