Deepen all 16 pear-platform scaffolds to production APIs.
Expands spawn, argv, preflight, trust, OTA, pipes, and headless UI modules; bumps to 0.3.1 with fuller tests and registry tier updates. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
require('bare-process/global')
|
||||
const EventEmitter = require('bare-events')
|
||||
const { platformStats } = require('../../_shared/pear-platform-base.js')
|
||||
const { normalizePlatformId, platformStats } = require('../../_shared/pear-platform-base.js')
|
||||
|
||||
const PROTOCOL = 'bare-target-matrix/v1'
|
||||
|
||||
const DEFAULT_TARGETS = [
|
||||
{ id: 'darwin-arm64', os: 'darwin', arch: 'arm64' },
|
||||
{ id: 'darwin-x64', os: 'darwin', arch: 'x64' },
|
||||
{ id: 'linux-arm64', os: 'linux', arch: 'arm64' },
|
||||
{ id: 'linux-x64', os: 'linux', arch: 'x64' },
|
||||
{ id: 'android-arm64', os: 'android', arch: 'arm64' },
|
||||
{ id: 'ios-arm64', os: 'ios', arch: 'arm64' }
|
||||
{ id: 'darwin-arm64', os: 'darwin', arch: 'arm64', mobile: false },
|
||||
{ id: 'darwin-x64', os: 'darwin', arch: 'x64', mobile: false },
|
||||
{ id: 'linux-arm64', os: 'linux', arch: 'arm64', mobile: false },
|
||||
{ id: 'linux-x64', os: 'linux', arch: 'x64', mobile: false },
|
||||
{ id: 'android-arm64', os: 'android', arch: 'arm64', mobile: true },
|
||||
{ id: 'ios-arm64', os: 'ios', arch: 'arm64', mobile: true }
|
||||
]
|
||||
|
||||
class HyperBareTargetMatrix extends EventEmitter {
|
||||
@@ -18,11 +18,26 @@ class HyperBareTargetMatrix extends EventEmitter {
|
||||
super()
|
||||
this._targets = [...(opts.targets || DEFAULT_TARGETS)]
|
||||
this.host = opts.host || 'darwin-arm64'
|
||||
this._stats = { selects: 0 }
|
||||
this._stats = { selects: 0, added: 0 }
|
||||
}
|
||||
|
||||
list () { return [...this._targets] }
|
||||
|
||||
addTarget (os, arch, extra = {}) {
|
||||
const id = normalizePlatformId(os, arch)
|
||||
if (this._targets.find((x) => x.id === id)) return this.select(id)
|
||||
const t = { id, os, arch, mobile: !!extra.mobile, ...extra }
|
||||
this._targets.push(t)
|
||||
this._stats.added++
|
||||
this.emit('add', t)
|
||||
return t
|
||||
}
|
||||
|
||||
matchHost (os, arch) {
|
||||
const id = normalizePlatformId(os, arch)
|
||||
return this._targets.find((x) => x.id === id) || null
|
||||
}
|
||||
|
||||
select (id) {
|
||||
const t = this._targets.find((x) => x.id === id)
|
||||
if (!t) throw new Error(`unknown target: ${id}`)
|
||||
@@ -36,6 +51,11 @@ class HyperBareTargetMatrix extends EventEmitter {
|
||||
return this._targets.find((x) => x.id === this.host) || null
|
||||
}
|
||||
|
||||
isMobile () {
|
||||
const t = this.current()
|
||||
return t ? !!t.mobile : false
|
||||
}
|
||||
|
||||
artifactName (binary = 'pear-runtime') {
|
||||
const t = this.current()
|
||||
if (!t) return binary
|
||||
@@ -43,12 +63,22 @@ class HyperBareTargetMatrix extends EventEmitter {
|
||||
return `${binary}-${t.id}${ext}`
|
||||
}
|
||||
|
||||
runtimePackageName () {
|
||||
const t = this.current()
|
||||
if (!t) return 'bare-runtime'
|
||||
return `bare-runtime-${t.id}`
|
||||
}
|
||||
|
||||
getStats () {
|
||||
return platformStats(this._stats, PROTOCOL, { host: this.host, count: this._targets.length })
|
||||
return platformStats(this._stats, PROTOCOL, {
|
||||
host: this.host,
|
||||
count: this._targets.length
|
||||
})
|
||||
}
|
||||
|
||||
async ready () { return this }
|
||||
|
||||
async close () { this.emit('closed') }
|
||||
}
|
||||
|
||||
module.exports = { HyperBareTargetMatrix, HyperP2PBareTargetMatrix: HyperBareTargetMatrix, PROTOCOL }
|
||||
module.exports = { HyperBareTargetMatrix, HyperP2PBareTargetMatrix: HyperBareTargetMatrix, PROTOCOL, DEFAULT_TARGETS }
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hyper-bare-target-matrix",
|
||||
"version": "0.0.0-scaffold",
|
||||
"version": "0.3.1",
|
||||
"description": "Cross-platform build target matrix.",
|
||||
"main": "index.js",
|
||||
"type": "commonjs",
|
||||
|
||||
@@ -5,6 +5,15 @@ const { HyperBareTargetMatrix } = require('../index.js')
|
||||
test('select target', async (t) => {
|
||||
const m = new HyperBareTargetMatrix()
|
||||
m.select('linux-arm64')
|
||||
t.ok(m.current())
|
||||
t.ok(m.artifactName().includes('linux-arm64'))
|
||||
await m.close()
|
||||
})
|
||||
|
||||
test('matchHost mobile', async (t) => {
|
||||
const m = new HyperBareTargetMatrix()
|
||||
m.select('ios-arm64')
|
||||
t.ok(m.isMobile())
|
||||
t.ok(m.matchHost('ios', 'arm64'))
|
||||
await m.close()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user