This commit is contained in:
Raven Scott
2026-04-08 22:48:55 -04:00
parent 28323589a8
commit 4ad6c08129
71 changed files with 3940 additions and 122 deletions
+6
View File
@@ -56,6 +56,12 @@ Invoked automatically by:
- Root `npm run os:seeder` / `npm run os:booter`
- Package `start` / `dev` / `pear:dev` scripts where configured
## `vendor-bare-node-shims.mjs`
**Usage:** `node scripts/vendor-bare-node-shims.mjs` (also **`npm run vendor:bare-node-shims -w bare-os-openssh`**)
Copies **`bare-net`** and the **`bare-node-*`** packages **`bare-ssh2`** needs from the root **`node_modules`** into **`packages/bare-os-openssh/vendor/bare-node-shims/`** (no nested **`node_modules`**), rewrites **intra-vendor** deps to **`file:../<pkg>`**, and writes **`README.md`**. **Commit** that directory so clones include **`bare-node-net`** etc. even when the npm registry is unreachable. **`bare-os-booter`** depends on those paths via **`file:`**; run **`npm install`** at the root after changing versions so **`package-lock.json`** stays consistent.
## `sync-kernel-to-seeder.mjs`
**Usage:** `npm run maintainer:sync-kernel-seeder` · `npm run maintainer:sync-kernel-seeder:bundle`
+101
View File
@@ -0,0 +1,101 @@
#!/usr/bin/env node
/**
* Copy Holepunch `bare-node-*` shims and `bare-net` from the repo root `node_modules`
* into `packages/bare-os-openssh/vendor/bare-node-shims/` so clones have these trees
* without relying on npm registry availability. Re-run after `npm install` at the root
* when upgrading versions; commit the vendor directory.
*
* Vendored packages that depend on each other get `file:../<name>` in package.json.
* Other deps stay as published semver/`*` and resolve from the root install.
*/
import fs from 'node:fs'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
const rootNm = path.join(root, 'node_modules')
const destRoot = path.join(
root,
'packages',
'bare-os-openssh',
'vendor',
'bare-node-shims'
)
/** Must match booter `file:` deps and bare-ssh2s Node shim stack. */
const PACKAGES = [
'bare-net',
'bare-node-child-process',
'bare-node-dns',
'bare-node-events',
'bare-node-fs',
'bare-node-http',
'bare-node-https',
'bare-node-net',
'bare-node-path',
'bare-node-stream',
'bare-node-tls',
'bare-node-util',
'bare-node-zlib'
]
const VENDORED = new Set(PACKAGES)
function copyPkg(name) {
const src = path.join(rootNm, name)
const dst = path.join(destRoot, name)
if (!fs.existsSync(src)) {
console.error('vendor-bare-node-shims: missing', src, '— run npm install at repo root')
process.exit(1)
}
fs.rmSync(dst, { recursive: true, force: true })
fs.cpSync(src, dst, {
recursive: true,
dereference: true,
filter: (s) => {
if (path.basename(s) === '.git') return false
const rel = path.relative(src, s)
if (rel.split(path.sep).includes('node_modules')) return false
return true
}
})
}
function patchDeps(pkgPath) {
const pj = path.join(pkgPath, 'package.json')
if (!fs.existsSync(pj)) return
const pkg = JSON.parse(fs.readFileSync(pj, 'utf8'))
for (const section of ['dependencies', 'optionalDependencies', 'peerDependencies']) {
if (!pkg[section]) continue
for (const dep of Object.keys(pkg[section])) {
if (VENDORED.has(dep)) pkg[section][dep] = `file:../${dep}`
}
}
fs.writeFileSync(pj, JSON.stringify(pkg, null, 2) + '\n')
}
fs.mkdirSync(destRoot, { recursive: true })
for (const name of PACKAGES) {
copyPkg(name)
patchDeps(path.join(destRoot, name))
}
const readme = path.join(destRoot, 'README.md')
fs.writeFileSync(
readme,
`# Vendored Bare node shims (Holepunch)
Generated by \`node scripts/vendor-bare-node-shims.mjs\` after \`npm install\` at the repo root.
These packages are normally published on npm; this tree is committed so **git clone** provides the same layout as a full install when registry access is missing or incomplete.
- **bare-net** — Bare TCP stack (\`https://www.npmjs.com/package/bare-net\`).
- **bare-node-*** — Node builtin compatibility shims (e.g. **bare-node-net** wraps **bare-net**).
**bare-os-booter** depends on each via \`file:../bare-os-openssh/vendor/bare-node-shims/<name>\`.
Upgrade: bump versions in **packages/bare-os-booter/package.json**, \`npm install\` at root, re-run this script, commit.
`
)
console.log('vendor-bare-node-shims: synced →', destRoot)