diff --git a/docs/eve-migration-roadmap.md b/docs/eve-migration-roadmap.md index 3053433..93a7da8 100644 --- a/docs/eve-migration-roadmap.md +++ b/docs/eve-migration-roadmap.md @@ -568,10 +568,12 @@ Recently cut: `gamecult.eve.runtime_release_request.v1` request from the runtime capability manifest and UPM package manifest, deriving the `eveunity-uitoolkit-v{version}` tag, package dependency set, required package dependency owners, and UPM - artifact path. The lifecycle smoke validates that contract against the package - manifest, parity compares it against the ledger, and the runtime-owner - consumer smoke asserts the exported release fields without pretending the - tagged EveUnity release already exists. + artifact path. `tools/eveunity/eveunity-release-artifact.mjs` consumes that + request and runs `npm pack` against the declared package root, producing the + declared UPM `.tgz` artifact as local smoke evidence. The lifecycle smoke + validates that contract against the package manifest, parity compares it + against the ledger, and the runtime-owner consumer smoke asserts the exported + release fields without pretending the tagged EveUnity release already exists. - EveUnity capture lifecycle now carries a structured pending capture contract. `captureContract` names the Unity UI Toolkit runtime, capture kind, PNG artifact pattern, conformance attachment point, required Aetheria provider diff --git a/docs/parity-testing-harness.md b/docs/parity-testing-harness.md index 10c6716..b856e4b 100644 --- a/docs/parity-testing-harness.md +++ b/docs/parity-testing-harness.md @@ -436,7 +436,9 @@ exist. The current lifecycle proof is deliberately split: - release: `tools/eveunity/eveunity-release-contract.mjs` builds a typed `gamecult.eve.runtime_release_request.v1` request from the runtime capability manifest and UPM package manifest, including required package dependency - owners; the tagged EveUnity release remains a split blocker; + owners. `tools/eveunity/eveunity-release-artifact.mjs` then packs the + declared package root into the declared UPM `.tgz` artifact. The tagged + EveUnity release remains a split blocker; - test: package-owned EditMode tests run through Aetheria in Unity batchmode, and Aetheria can build the package through Unity's generated project. The test contract names CultLib-owned NuGet/precompiled assembly inputs without diff --git a/packages/org.gamecult.eve.unity-uitoolkit/README.md b/packages/org.gamecult.eve.unity-uitoolkit/README.md index bf89f2d..f61b026 100644 --- a/packages/org.gamecult.eve.unity-uitoolkit/README.md +++ b/packages/org.gamecult.eve.unity-uitoolkit/README.md @@ -38,7 +38,8 @@ The runtime capability manifest is `eve-runtime-capability.json`. Its lifecycle section records the current split evidence: -- release: typed UPM release request contract and incubating package identity; +- release: typed UPM release request contract, UPM `.tgz` artifact smoke, and + incubating package identity; - test: package-owned EditMode tests run through Aetheria in Unity batchmode, plus Aetheria consumer-build smoke through Unity's generated project; - capture: typed capture request contract and pending Unity editor or @@ -54,6 +55,10 @@ manifest and UPM package manifest. The request names the package version, tag, artifact path, dependency set, required package dependency owners, and target `GameCult/EveUnity` repository without pretending Eve has published the tagged release. +`tools/eveunity/eveunity-release-artifact.mjs` consumes that request and runs +`npm pack` against the declared package root, producing the declared +`org.gamecult.eve.unity-uitoolkit-{version}.tgz` artifact as local smoke +evidence. The tagged release still belongs in the EveUnity repo. The test stage declares the Unity EditMode runner contract: the current runner is `scripts/run-aetheria-unity-editmode-tests.ps1`, runs @@ -103,11 +108,12 @@ powershell -ExecutionPolicy Bypass -File .\scripts\run-eveunity-lifecycle-smoke. ``` That smoke validates `eve-runtime-capability.json`, checks lifecycle evidence -paths, runs the Aetheria Unity package consumer-build smoke, and verifies the -split handoff manifest. Pass `-RunUnityEditMode` when the local Unity editor -should also execute the incubating batchmode EditMode test runner. The final -tagged UPM release, batchmode runner ownership, and capture artifact still -graduate to `EveUnity`. The capture contract smoke is: +paths, builds the UPM artifact smoke, runs the Aetheria Unity package +consumer-build smoke, and verifies the split handoff manifest. Pass +`-RunUnityEditMode` when the local Unity editor should also execute the +incubating batchmode EditMode test runner. The final tagged UPM release, +batchmode runner ownership, and capture artifact still graduate to `EveUnity`. +The capture contract smoke is: ```powershell powershell -ExecutionPolicy Bypass -File .\scripts\run-eveunity-capture-contract-smoke.ps1 @@ -125,6 +131,12 @@ The release contract smoke is: powershell -ExecutionPolicy Bypass -File .\scripts\run-eveunity-release-contract-smoke.ps1 ``` +The release artifact smoke is: + +```powershell +powershell -ExecutionPolicy Bypass -File .\scripts\run-eveunity-release-artifact-smoke.ps1 +``` + For Aetheria, the Unity evidence path is: - `powershell -ExecutionPolicy Bypass -File ..\..\scripts\run-aetheria-unity-package-smoke.ps1` diff --git a/packages/org.gamecult.eve.unity-uitoolkit/eve-runtime-capability.json b/packages/org.gamecult.eve.unity-uitoolkit/eve-runtime-capability.json index b419a6c..e1a9061 100644 --- a/packages/org.gamecult.eve.unity-uitoolkit/eve-runtime-capability.json +++ b/packages/org.gamecult.eve.unity-uitoolkit/eve-runtime-capability.json @@ -69,7 +69,7 @@ "lifecycle": { "release": { "ownerRepo": "EveUnity", - "status": "incubating-upm-package", + "status": "upm-package-artifact-smoke", "packageName": "org.gamecult.eve.unity-uitoolkit", "packageManifest": "packages/org.gamecult.eve.unity-uitoolkit/package.json", "releaseContract": { @@ -81,6 +81,7 @@ "artifactKind": "upm-package", "requestSchema": "gamecult.eve.runtime_release_request.v1", "requestBuilder": "tools/eveunity/eveunity-release-contract.mjs", + "artifactBuilder": "tools/eveunity/eveunity-release-artifact.mjs", "artifactPattern": "artifacts/eveunity-uitoolkit-release/{version}/org.gamecult.eve.unity-uitoolkit-{version}.tgz", "publishProof": "Tagged UPM release is created from the EveUnity repo and references this package root.", "requiredPackageDependencies": [ @@ -98,7 +99,10 @@ "packages/org.gamecult.eve.unity-uitoolkit/README.md", "tools/eveunity/eveunity-release-contract.mjs", "tools/eveunity/eveunity-release-contract.test.mjs", + "tools/eveunity/eveunity-release-artifact.mjs", + "tools/eveunity/eveunity-release-artifact.test.mjs", "scripts/run-eveunity-release-contract-smoke.ps1", + "scripts/run-eveunity-release-artifact-smoke.ps1", "scripts/run-aetheria-unity-package-smoke.ps1" ], "pendingProofs": [ diff --git a/packages/org.gamecult.eve.unity-uitoolkit/eveunity-split-handoff.json b/packages/org.gamecult.eve.unity-uitoolkit/eveunity-split-handoff.json index a38a4ae..ec97556 100644 --- a/packages/org.gamecult.eve.unity-uitoolkit/eveunity-split-handoff.json +++ b/packages/org.gamecult.eve.unity-uitoolkit/eveunity-split-handoff.json @@ -19,7 +19,10 @@ "packages/org.gamecult.eve.unity-uitoolkit/Tests", "tools/eveunity/eveunity-release-contract.mjs", "tools/eveunity/eveunity-release-contract.test.mjs", - "scripts/run-eveunity-release-contract-smoke.ps1" + "tools/eveunity/eveunity-release-artifact.mjs", + "tools/eveunity/eveunity-release-artifact.test.mjs", + "scripts/run-eveunity-release-contract-smoke.ps1", + "scripts/run-eveunity-release-artifact-smoke.ps1" ], "destinationOwner": "EveUnity", "replacementProof": "Tagged UPM release cut from EveUnity rather than Eve incubation." diff --git a/schemas/gamecult.eve.runtime_capability.v1.schema.json b/schemas/gamecult.eve.runtime_capability.v1.schema.json index da06631..2ad1a23 100644 --- a/schemas/gamecult.eve.runtime_capability.v1.schema.json +++ b/schemas/gamecult.eve.runtime_capability.v1.schema.json @@ -247,6 +247,10 @@ "type": "string", "minLength": 1 }, + "artifactBuilder": { + "type": "string", + "minLength": 1 + }, "artifactPattern": { "type": "string", "minLength": 1 diff --git a/scripts/run-eveunity-lifecycle-smoke.ps1 b/scripts/run-eveunity-lifecycle-smoke.ps1 index 32b2da7..2989d5f 100644 --- a/scripts/run-eveunity-lifecycle-smoke.ps1 +++ b/scripts/run-eveunity-lifecycle-smoke.ps1 @@ -110,7 +110,7 @@ if (-not ($releaseContract.tagPattern -match "\{version\}")) { if (-not ($releaseContract.artifactPattern -match "\{version\}")) { throw "EveUnity release contract artifact pattern must include {version}: $($releaseContract.artifactPattern)" } -foreach ($pathProperty in @("packageRoot", "versionSource", "requestBuilder")) { +foreach ($pathProperty in @("packageRoot", "versionSource", "requestBuilder", "artifactBuilder")) { $relativePath = $releaseContract.$pathProperty if (-not $relativePath) { throw "EveUnity release contract missing $pathProperty" @@ -146,6 +146,11 @@ if ($LASTEXITCODE -ne 0) { throw "EveUnity release contract smoke failed with exit code $LASTEXITCODE" } +& (Join-Path $projectRoot "scripts\run-eveunity-release-artifact-smoke.ps1") +if ($LASTEXITCODE -ne 0) { + throw "EveUnity release artifact smoke failed with exit code $LASTEXITCODE" +} + $testContract = $manifest.lifecycle.test.testContract if ($null -eq $testContract) { throw "EveUnity test lifecycle missing testContract" diff --git a/scripts/run-eveunity-release-artifact-smoke.ps1 b/scripts/run-eveunity-release-artifact-smoke.ps1 new file mode 100644 index 0000000..18a1123 --- /dev/null +++ b/scripts/run-eveunity-release-artifact-smoke.ps1 @@ -0,0 +1,98 @@ +param( + [string] $CapabilityManifestPath = "packages\org.gamecult.eve.unity-uitoolkit\eve-runtime-capability.json", + [string] $RequestOutputPath = "artifacts\eveunity-uitoolkit-release-contract\latest\release-request.json", + [string] $ProofOutputPath = "artifacts\eveunity-uitoolkit-release\latest\release-artifact.json" +) + +$ErrorActionPreference = "Stop" + +$projectRoot = Split-Path -Parent $PSScriptRoot +$absoluteCapabilityPath = if ([System.IO.Path]::IsPathRooted($CapabilityManifestPath)) { + $CapabilityManifestPath +} else { + Join-Path $projectRoot $CapabilityManifestPath +} +$absoluteRequestOutputPath = if ([System.IO.Path]::IsPathRooted($RequestOutputPath)) { + $RequestOutputPath +} else { + Join-Path $projectRoot $RequestOutputPath +} +$absoluteProofOutputPath = if ([System.IO.Path]::IsPathRooted($ProofOutputPath)) { + $ProofOutputPath +} else { + Join-Path $projectRoot $ProofOutputPath +} + +if (-not (Test-Path -LiteralPath $absoluteCapabilityPath)) { + throw "EveUnity release artifact input not found: $absoluteCapabilityPath" +} + +$manifest = Get-Content -LiteralPath $absoluteCapabilityPath -Raw | ConvertFrom-Json +$releaseContract = $manifest.lifecycle.release.releaseContract +if ($null -eq $releaseContract) { + throw "EveUnity release artifact smoke missing lifecycle.release.releaseContract" +} +if ($releaseContract.ownerRepo -ne "EveUnity") { + throw "Unexpected EveUnity release artifact owner: $($releaseContract.ownerRepo)" +} +if ($releaseContract.artifactKind -ne "upm-package") { + throw "Unexpected EveUnity release artifact kind: $($releaseContract.artifactKind)" +} +if (-not $releaseContract.artifactBuilder) { + throw "EveUnity release contract missing artifactBuilder" +} +$artifactBuilderPath = Join-Path $projectRoot $releaseContract.artifactBuilder +if (-not (Test-Path -LiteralPath $artifactBuilderPath)) { + throw "EveUnity release artifact builder not found: $($releaseContract.artifactBuilder)" +} + +node --test (Join-Path $projectRoot "tools\eveunity\eveunity-release-artifact.test.mjs") +if ($LASTEXITCODE -ne 0) { + throw "EveUnity release artifact tests failed with exit code $LASTEXITCODE" +} + +& (Join-Path $projectRoot "scripts\run-eveunity-release-contract-smoke.ps1") ` + -CapabilityManifestPath $CapabilityManifestPath ` + -OutputPath $RequestOutputPath +if ($LASTEXITCODE -ne 0) { + throw "EveUnity release contract smoke failed with exit code $LASTEXITCODE" +} + +node $artifactBuilderPath ` + --project-root $projectRoot ` + --request $RequestOutputPath ` + --proof-output $ProofOutputPath +if ($LASTEXITCODE -ne 0) { + throw "EveUnity release artifact builder failed with exit code $LASTEXITCODE" +} + +if (-not (Test-Path -LiteralPath $absoluteProofOutputPath)) { + throw "EveUnity release artifact proof was not written: $absoluteProofOutputPath" +} + +$proof = Get-Content -LiteralPath $absoluteProofOutputPath -Raw | ConvertFrom-Json +foreach ($expectation in @( + @{ field = "schema"; value = "gamecult.eve.runtime_release_artifact.v1" }, + @{ field = "ownerRepo"; value = "EveUnity" }, + @{ field = "repository"; value = "GameCult/EveUnity" }, + @{ field = "packageName"; value = $releaseContract.packageName }, + @{ field = "artifactKind"; value = "upm-package" } +)) { + if ($proof.($expectation.field) -ne $expectation.value) { + throw "EveUnity release artifact proof $($expectation.field) expected $($expectation.value) got $($proof.($expectation.field))" + } +} +if ($proof.artifactSizeBytes -le 0) { + throw "EveUnity release artifact proof has invalid size: $($proof.artifactSizeBytes)" +} + +$artifactPath = if ([System.IO.Path]::IsPathRooted($proof.artifactPath)) { + $proof.artifactPath +} else { + Join-Path $projectRoot $proof.artifactPath +} +if (-not (Test-Path -LiteralPath $artifactPath)) { + throw "EveUnity release artifact was not written: $artifactPath" +} + +Write-Host "EveUnity release artifact smoke passed: $artifactPath" diff --git a/scripts/run-eveunity-release-contract-smoke.ps1 b/scripts/run-eveunity-release-contract-smoke.ps1 index 9d7fd43..78f7a09 100644 --- a/scripts/run-eveunity-release-contract-smoke.ps1 +++ b/scripts/run-eveunity-release-contract-smoke.ps1 @@ -26,7 +26,7 @@ $releaseContract = $manifest.lifecycle.release.releaseContract if ($null -eq $releaseContract) { throw "EveUnity release contract missing lifecycle.release.releaseContract" } -foreach ($field in @("ownerRepo", "packageName", "packageRoot", "versionSource", "tagPattern", "artifactKind", "requestSchema", "requestBuilder", "artifactPattern", "publishProof")) { +foreach ($field in @("ownerRepo", "packageName", "packageRoot", "versionSource", "tagPattern", "artifactKind", "requestSchema", "requestBuilder", "artifactBuilder", "artifactPattern", "publishProof")) { if (-not $releaseContract.$field) { throw "EveUnity release contract missing $field" } @@ -42,9 +42,10 @@ if ($releaseContract.artifactKind -ne "upm-package") { } $builderPath = Join-Path $projectRoot $releaseContract.requestBuilder +$artifactBuilderPath = Join-Path $projectRoot $releaseContract.artifactBuilder $packagePath = Join-Path $projectRoot $releaseContract.versionSource $packageRoot = Join-Path $projectRoot $releaseContract.packageRoot -foreach ($path in @($builderPath, $packagePath, $packageRoot)) { +foreach ($path in @($builderPath, $artifactBuilderPath, $packagePath, $packageRoot)) { if (-not (Test-Path -LiteralPath $path)) { throw "EveUnity release contract path not found: $path" } diff --git a/scripts/run-parity-harness.ps1 b/scripts/run-parity-harness.ps1 index cb43d68..38ec27b 100644 --- a/scripts/run-parity-harness.ps1 +++ b/scripts/run-parity-harness.ps1 @@ -69,6 +69,7 @@ try { & (Join-Path $PSScriptRoot "run-plugin-handoff-smoke.ps1") & (Join-Path $PSScriptRoot "run-aetheria-provider-handoff-smoke.ps1") & (Join-Path $PSScriptRoot "run-eveunity-split-handoff-smoke.ps1") + & (Join-Path $PSScriptRoot "run-eveunity-release-artifact-smoke.ps1") & (Join-Path $PSScriptRoot "run-eveunity-scene-split-handoff-smoke.ps1") & (Join-Path $PSScriptRoot "run-eveunity-scene-lifecycle-smoke.ps1") & (Join-Path $PSScriptRoot "run-eveelectron-split-handoff-smoke.ps1") diff --git a/scripts/run-runtime-owner-conformance-consumer-smoke.ps1 b/scripts/run-runtime-owner-conformance-consumer-smoke.ps1 index e4cf688..a361025 100644 --- a/scripts/run-runtime-owner-conformance-consumer-smoke.ps1 +++ b/scripts/run-runtime-owner-conformance-consumer-smoke.ps1 @@ -174,7 +174,7 @@ node $consumerScript $consumerExport ` --expect-screenshot-metric unity-scene:aetheria-world:bounding-boxes:pending-capture ` --expect-screenshot-metric electron-shell:aetheria-world:bounding-boxes:pending-capture ` --expect-screenshot-metric tui:aetheria-world:bounding-boxes:terminal-grid-capture ` - --expect-runtime-lifecycle-status unity-uitoolkit:release:incubating-upm-package ` + --expect-runtime-lifecycle-status unity-uitoolkit:release:upm-package-artifact-smoke ` --expect-runtime-lifecycle-status unity-uitoolkit:test:batchmode-editmode-tests-and-consumer-build-smoke ` --expect-runtime-lifecycle-status unity-uitoolkit:capture:pending-editor-capture ` --expect-runtime-lifecycle-pending "unity-uitoolkit:release:Tagged UPM release" ` @@ -184,6 +184,7 @@ node $consumerScript $consumerExport ` --expect-runtime-lifecycle-field "unity-uitoolkit:release:releaseContract.artifactKind:upm-package" ` --expect-runtime-lifecycle-field "unity-uitoolkit:release:releaseContract.requestSchema:gamecult.eve.runtime_release_request.v1" ` --expect-runtime-lifecycle-field "unity-uitoolkit:release:releaseContract.requestBuilder:tools/eveunity/eveunity-release-contract.mjs" ` + --expect-runtime-lifecycle-field "unity-uitoolkit:release:releaseContract.artifactBuilder:tools/eveunity/eveunity-release-artifact.mjs" ` --expect-runtime-lifecycle-field "unity-uitoolkit:release:releaseContract.artifactPattern:artifacts/eveunity-uitoolkit-release/{version}/org.gamecult.eve.unity-uitoolkit-{version}.tgz" ` --expect-runtime-lifecycle-field "unity-uitoolkit:release:releaseContract.tagPattern:eveunity-uitoolkit-v{version}" ` --expect-runtime-lifecycle-field "unity-uitoolkit:release:releaseContract.packageRoot:packages/org.gamecult.eve.unity-uitoolkit" ` diff --git a/tools/eveunity/eveunity-release-artifact.mjs b/tools/eveunity/eveunity-release-artifact.mjs new file mode 100644 index 0000000..0dbecc9 --- /dev/null +++ b/tools/eveunity/eveunity-release-artifact.mjs @@ -0,0 +1,164 @@ +import { spawnSync } from "node:child_process"; +import { existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from "node:fs"; +import path from "node:path"; +import { fileURLToPath } from "node:url"; + +export function buildUnityReleaseArtifactPlan({ request, packageManifest } = {}) { + if (!request || typeof request !== "object") { + throw new Error("release request is required"); + } + if (!packageManifest || typeof packageManifest !== "object") { + throw new Error("package manifest is required"); + } + if (request.artifactKind !== "upm-package") { + throw new Error(`release artifact kind must be upm-package: ${request.artifactKind || "missing"}`); + } + if (packageManifest.name !== request.packageName) { + throw new Error(`package name mismatch: expected ${request.packageName || "missing"} got ${packageManifest.name || "missing"}`); + } + if (packageManifest.version !== request.version) { + throw new Error(`package version mismatch: expected ${request.version || "missing"} got ${packageManifest.version || "missing"}`); + } + if (!request.packageRoot) { + throw new Error("release request missing packageRoot"); + } + if (!request.artifactPath || !request.artifactPath.endsWith(".tgz")) { + throw new Error(`release artifact path must be a .tgz file: ${request.artifactPath || "missing"}`); + } + + const artifactDirectory = path.dirname(request.artifactPath); + const expectedFileName = path.basename(request.artifactPath); + return { + packageRoot: request.packageRoot, + artifactPath: request.artifactPath, + artifactDirectory, + expectedFileName, + npmPackArguments: ["pack", request.packageRoot, "--pack-destination", artifactDirectory], + }; +} + +export function packUnityReleaseArtifact({ + request, + projectRoot = process.cwd(), + npmCommand = "", +} = {}) { + const packageRoot = resolveProjectPath(projectRoot, request?.packageRoot || ""); + const packageManifestPath = path.join(packageRoot, "package.json"); + if (!existsSync(packageManifestPath)) { + throw new Error(`release package manifest not found: ${packageManifestPath}`); + } + + const packageManifest = loadJsonFile(packageManifestPath); + const plan = buildUnityReleaseArtifactPlan({ request, packageManifest }); + const artifactDirectory = resolveProjectPath(projectRoot, plan.artifactDirectory); + const artifactPath = resolveProjectPath(projectRoot, plan.artifactPath); + mkdirSync(artifactDirectory, { recursive: true }); + + const npmInvocation = resolveNpmInvocation(npmCommand); + const packArguments = ["pack", packageRoot, "--pack-destination", artifactDirectory]; + const result = spawnSync(npmInvocation.command, [...npmInvocation.prefixArguments, ...packArguments], { + cwd: projectRoot, + encoding: "utf8", + shell: npmInvocation.shell, + }); + if (result.status !== 0) { + throw new Error(`npm pack failed with exit code ${result.status ?? "spawn-error"}: ${result.error?.message || result.stderr || result.stdout || "no output"}`); + } + + const packedFileName = result.stdout.trim().split(/\r?\n/).filter(Boolean).pop() || plan.expectedFileName; + const packedPath = path.join(artifactDirectory, packedFileName); + if (!existsSync(packedPath)) { + throw new Error(`npm pack did not produce expected output: ${packedPath}`); + } + if (path.resolve(packedPath) !== path.resolve(artifactPath)) { + throw new Error(`npm pack output mismatch: expected ${artifactPath} got ${packedPath}`); + } + + const stats = statSync(artifactPath); + if (stats.size <= 0) { + throw new Error(`release artifact is empty: ${artifactPath}`); + } + + return { + schema: "gamecult.eve.runtime_release_artifact.v1", + ownerRepo: request.ownerRepo, + repository: request.repository, + packageName: request.packageName, + version: request.version, + artifactKind: request.artifactKind, + artifactPath: request.artifactPath, + artifactSizeBytes: stats.size, + packageRoot: request.packageRoot, + sourceRequestPath: request.sourceRequestPath || "", + }; +} + +export function loadJsonFile(filePath) { + return JSON.parse(readFileSync(filePath, "utf8")); +} + +export function writeJsonFile(document, outputPath) { + mkdirSync(path.dirname(outputPath), { recursive: true }); + writeFileSync(outputPath, `${JSON.stringify(document, null, 2)}\n`, "utf8"); +} + +function resolveProjectPath(projectRoot, filePath) { + if (!filePath) return projectRoot; + return path.isAbsolute(filePath) ? filePath : path.resolve(projectRoot, filePath); +} + +function resolveNpmInvocation(npmCommand) { + if (npmCommand) { + return { command: npmCommand, prefixArguments: [], shell: false }; + } + + const npmCliPath = path.join(path.dirname(process.execPath), "node_modules", "npm", "bin", "npm-cli.js"); + if (existsSync(npmCliPath)) { + return { command: process.execPath, prefixArguments: [npmCliPath], shell: false }; + } + + return { command: "npm", prefixArguments: [], shell: true }; +} + +function parseArgs(argv) { + const args = {}; + for (let index = 0; index < argv.length; index += 1) { + const value = argv[index]; + if (!value.startsWith("--")) continue; + const key = value.slice(2); + const next = argv[index + 1]; + if (!next || next.startsWith("--")) { + args[key] = true; + } else { + args[key] = next; + index += 1; + } + } + return args; +} + +function runCli() { + const args = parseArgs(process.argv.slice(2)); + for (const required of ["request", "proof-output"]) { + if (!args[required]) { + throw new Error(`missing required --${required}`); + } + } + + const projectRoot = args["project-root"] ? path.resolve(args["project-root"]) : process.cwd(); + const requestPath = resolveProjectPath(projectRoot, args.request); + const request = { + ...loadJsonFile(requestPath), + sourceRequestPath: args.request, + }; + const proof = packUnityReleaseArtifact({ request, projectRoot }); + const proofOutputPath = resolveProjectPath(projectRoot, args["proof-output"]); + writeJsonFile(proof, proofOutputPath); + process.stdout.write(`${proof.artifactPath}\n`); +} + +const invokedPath = process.argv[1] ? path.resolve(process.argv[1]) : ""; +const modulePath = fileURLToPath(import.meta.url); +if (invokedPath === modulePath) { + runCli(); +} diff --git a/tools/eveunity/eveunity-release-artifact.test.mjs b/tools/eveunity/eveunity-release-artifact.test.mjs new file mode 100644 index 0000000..eb0ccd5 --- /dev/null +++ b/tools/eveunity/eveunity-release-artifact.test.mjs @@ -0,0 +1,41 @@ +import assert from "node:assert/strict"; +import { readFileSync } from "node:fs"; +import test from "node:test"; +import { buildUnityReleaseRequest } from "./eveunity-release-contract.mjs"; +import { buildUnityReleaseArtifactPlan } from "./eveunity-release-artifact.mjs"; + +const capabilityManifest = JSON.parse(readFileSync(new URL("../../packages/org.gamecult.eve.unity-uitoolkit/eve-runtime-capability.json", import.meta.url), "utf8")); +const packageManifest = JSON.parse(readFileSync(new URL("../../packages/org.gamecult.eve.unity-uitoolkit/package.json", import.meta.url), "utf8")); + +test("plans npm pack for the EveUnity UI Toolkit UPM artifact", () => { + const request = buildUnityReleaseRequest({ + capabilityManifest, + packageManifest, + capabilityManifestPath: "packages/org.gamecult.eve.unity-uitoolkit/eve-runtime-capability.json", + packageManifestPath: "packages/org.gamecult.eve.unity-uitoolkit/package.json", + }); + const plan = buildUnityReleaseArtifactPlan({ request, packageManifest }); + + assert.equal(plan.packageRoot, "packages/org.gamecult.eve.unity-uitoolkit"); + assert.equal(plan.artifactPath, "artifacts/eveunity-uitoolkit-release/0.1.0/org.gamecult.eve.unity-uitoolkit-0.1.0.tgz"); + assert.equal(plan.artifactDirectory, "artifacts/eveunity-uitoolkit-release/0.1.0"); + assert.equal(plan.expectedFileName, "org.gamecult.eve.unity-uitoolkit-0.1.0.tgz"); + assert.deepEqual(plan.npmPackArguments, [ + "pack", + "packages/org.gamecult.eve.unity-uitoolkit", + "--pack-destination", + "artifacts/eveunity-uitoolkit-release/0.1.0", + ]); +}); + +test("rejects release artifact plans for mismatched package identity", () => { + const request = buildUnityReleaseRequest({ capabilityManifest, packageManifest }); + + assert.throws( + () => buildUnityReleaseArtifactPlan({ + request, + packageManifest: { ...packageManifest, name: "org.gamecult.eve.wrong" }, + }), + /package name mismatch/, + ); +}); diff --git a/tools/parity/parity-manifest.json b/tools/parity/parity-manifest.json index f7c702a..88a8bbf 100644 --- a/tools/parity/parity-manifest.json +++ b/tools/parity/parity-manifest.json @@ -1655,7 +1655,7 @@ "lifecycle": { "release": { "ownerRepo": "EveUnity", - "status": "incubating-upm-package", + "status": "upm-package-artifact-smoke", "releaseContract": { "ownerRepo": "EveUnity", "packageName": "org.gamecult.eve.unity-uitoolkit", @@ -1665,6 +1665,7 @@ "artifactKind": "upm-package", "requestSchema": "gamecult.eve.runtime_release_request.v1", "requestBuilder": "tools/eveunity/eveunity-release-contract.mjs", + "artifactBuilder": "tools/eveunity/eveunity-release-artifact.mjs", "artifactPattern": "artifacts/eveunity-uitoolkit-release/{version}/org.gamecult.eve.unity-uitoolkit-{version}.tgz", "publishProof": "Tagged UPM release is created from the EveUnity repo and references this package root.", "requiredPackageDependencies": [ @@ -1682,7 +1683,10 @@ "packages/org.gamecult.eve.unity-uitoolkit/README.md", "tools/eveunity/eveunity-release-contract.mjs", "tools/eveunity/eveunity-release-contract.test.mjs", + "tools/eveunity/eveunity-release-artifact.mjs", + "tools/eveunity/eveunity-release-artifact.test.mjs", "scripts/run-eveunity-release-contract-smoke.ps1", + "scripts/run-eveunity-release-artifact-smoke.ps1", "scripts/run-aetheria-unity-package-smoke.ps1" ], "pendingProofs": [ diff --git a/tools/parity/run-parity.mjs b/tools/parity/run-parity.mjs index a6a5a2a..1877811 100644 --- a/tools/parity/run-parity.mjs +++ b/tools/parity/run-parity.mjs @@ -1606,7 +1606,7 @@ function compareReleaseContract(expected, actual, label) { const errors = []; if (!expected) return errors; if (!actual) return [`${label}:missing`]; - for (const key of ["ownerRepo", "packageName", "packageRoot", "versionSource", "tagPattern", "artifactKind", "requestSchema", "requestBuilder", "artifactPattern", "publishProof"]) { + for (const key of ["ownerRepo", "packageName", "packageRoot", "versionSource", "tagPattern", "artifactKind", "requestSchema", "requestBuilder", "artifactBuilder", "artifactPattern", "publishProof"]) { if ((expected[key] || "") !== (actual[key] || "")) { errors.push(`${label}.${key}:expected ${expected[key] || ""} got ${actual[key] || ""}`); } @@ -1614,7 +1614,7 @@ function compareReleaseContract(expected, actual, label) { if (actual.requestSchema && !manifest.schemas?.[actual.requestSchema]) { errors.push(`${label}.requestSchema:${actual.requestSchema}:missing-schema-catalog-entry`); } - for (const key of ["packageRoot", "versionSource", "requestBuilder"]) { + for (const key of ["packageRoot", "versionSource", "requestBuilder", "artifactBuilder"]) { if (actual[key] && !existsSync(path.join(repoRoot, actual[key]))) { errors.push(`${label}.${key}:${actual[key]}:missing`); }