53 lines
2.4 KiB
Text
53 lines
2.4 KiB
Text
#!/usr/bin/env nu
|
|
def main [
|
|
--workspace: string = ""
|
|
--initial-delegate-did: string = ""
|
|
--dry-run
|
|
]: nothing -> nothing {
|
|
let ws = if ($workspace | is-not-empty) { $workspace } else { $env.PLAYBOOK_PARAM_WORKSPACE? | default "libre-wuji" }
|
|
let delegate_did = if ($initial_delegate_did | is-not-empty) { $initial_delegate_did } else { $env.PLAYBOOK_PARAM_INITIAL_DELEGATE_DID? | default "" }
|
|
|
|
if ($delegate_did | is-empty) { error make { msg: "initial-delegate-did is required for Radicle governance bootstrap" } }
|
|
|
|
let repo_pairs = [
|
|
{ name: $"policy-($ws)", purpose: "keeper signing policy" },
|
|
{ name: $"desired-($ws)", purpose: "desired state declarations" },
|
|
{ name: $"state-($ws)", purpose: "applied state ledger" },
|
|
{ name: "policy-libre-daoshi", purpose: "daoshi keeper policy" },
|
|
{ name: "desired-libre-daoshi", purpose: "daoshi desired state" },
|
|
{ name: "state-libre-daoshi", purpose: "daoshi applied state ledger" },
|
|
]
|
|
|
|
if $dry_run {
|
|
print "[dry-run] would create Radicle repos and set initial delegation:"
|
|
for rp in $repo_pairs { print $"[dry-run] rad init --name ($rp.name) # ($rp.purpose)" }
|
|
print $"[dry-run] would set delegate ($delegate_did) as initial signer — threshold=1"
|
|
return
|
|
}
|
|
|
|
for rp in $repo_pairs {
|
|
let check_r = do { ^rad ls --repo $rp.name } | complete
|
|
if $check_r.exit_code == 0 {
|
|
print $" EXISTS: ($rp.name) — skipping init"
|
|
} else {
|
|
let init_r = do { ^rad init --name $rp.name --description $rp.purpose --public } | complete
|
|
if $init_r.exit_code != 0 {
|
|
print $" WARNING: rad init failed for ($rp.name): ($init_r.stderr | str trim)"
|
|
} else {
|
|
print $" created: ($rp.name)"
|
|
}
|
|
}
|
|
}
|
|
|
|
for rp in $repo_pairs {
|
|
let delegate_r = do { ^rad delegate add $delegate_did --repo $rp.name } | complete
|
|
if $delegate_r.exit_code != 0 {
|
|
print $" WARNING: failed to add delegate to ($rp.name): ($delegate_r.stderr | str trim)"
|
|
} else {
|
|
print $" delegate ($delegate_did) added to ($rp.name)"
|
|
}
|
|
}
|
|
|
|
print "Radicle governance repos initialized with initial delegation set (threshold=1)"
|
|
print "Add additional operators via the onboard_operator playbook to increase quorum threshold"
|
|
}
|