mirror of
https://github.com/hansjone/netxops.git
synced 2026-10-20 02:43:21 +08:00
Harden public package installation and release validation
This commit is contained in:
parent
9271494b37
commit
9b2166e5b6
41 changed files with 994 additions and 363 deletions
17
scripts/install-preset.mjs
Normal file
17
scripts/install-preset.mjs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
/** Developer fallback: use the same composition and preservation rules as Host activation. */
|
||||
import { existsSync } from 'node:fs'
|
||||
import { homedir } from 'node:os'
|
||||
import { join } from 'node:path'
|
||||
import { composeNetxopsPresetArtifacts, installDirectoryPreset, syncDeclarativeIntoProfilePatch } from '../lib/index.js'
|
||||
|
||||
const index = process.argv.indexOf('--profile')
|
||||
const profile = index < 0 ? 'web' : process.argv[index + 1]
|
||||
if (!profile || !/^[\w-]+$/.test(profile)) throw new Error('Invalid profile name.')
|
||||
const dshHome = process.env.DSH_HOME?.trim() || join(homedir(), '.dsh')
|
||||
if (!existsSync(join(dshHome, 'profiles', profile, 'package.json'))) {
|
||||
throw new Error(`Harness profile is not installed: ${profile}. Start this Host first.`)
|
||||
}
|
||||
const artifacts = composeNetxopsPresetArtifacts(profile)
|
||||
installDirectoryPreset(artifacts, console)
|
||||
syncDeclarativeIntoProfilePatch(profile, artifacts.declarativePatch, console)
|
||||
console.log(`Netx Ops preset prepared for ${profile}. Restart this Host to load its patch.`)
|
||||
Loading…
Add table
Add a link
Reference in a new issue