mirror of
https://github.com/waybarrios/opencode-power-pack.git
synced 2026-11-18 18:03:43 +00:00
Rely on the required release CI before uploading to GitHub Packages so the immutable version 0.5.0 tag can be mirrored without inheriting registry configuration inside package tests.
41 lines
1.6 KiB
JavaScript
41 lines
1.6 KiB
JavaScript
import assert from "node:assert/strict";
|
|
import fs from "node:fs";
|
|
import path from "node:path";
|
|
import test from "node:test";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
const WORKFLOW = fs.readFileSync(
|
|
path.join(ROOT, ".github", "workflows", "publish-github-package.yml"),
|
|
"utf8",
|
|
);
|
|
const README = fs.readFileSync(path.join(ROOT, "README.md"), "utf8");
|
|
|
|
test("GitHub Packages workflow publishes an exact release tag with least privilege", () => {
|
|
assert.match(WORKFLOW, /release:\n\s+types: \[published\]/);
|
|
assert.match(WORKFLOW, /workflow_dispatch:/);
|
|
assert.match(WORKFLOW, /contents: read\n\s+packages: write/);
|
|
assert.match(WORKFLOW, /ref: \$\{\{ env\.RELEASE_REF \}\}/);
|
|
assert.match(WORKFLOW, /Release ref .* does not match package version/);
|
|
assert.match(WORKFLOW, /registry-url: "https:\/\/npm\.pkg\.github\.com"/);
|
|
assert.match(WORKFLOW, /scope: "@waybarrios"/);
|
|
assert.match(
|
|
WORKFLOW,
|
|
/npm publish --ignore-scripts --registry=https:\/\/npm\.pkg\.github\.com --access public/,
|
|
);
|
|
assert.match(WORKFLOW, /NODE_AUTH_TOKEN: \$\{\{ secrets\.GITHUB_TOKEN \}\}/);
|
|
});
|
|
|
|
test("README distinguishes npmjs installation from the GitHub Packages mirror", () => {
|
|
assert.match(README, /### GitHub Packages mirror/);
|
|
assert.match(
|
|
README,
|
|
/npm login --scope=@waybarrios --auth-type=legacy --registry=https:\/\/npm\.pkg\.github\.com/,
|
|
);
|
|
assert.match(
|
|
README,
|
|
/npm install --global @waybarrios\/opencode-power-pack --registry=https:\/\/npm\.pkg\.github\.com/,
|
|
);
|
|
assert.match(README, /personal access token \(classic\).*`read:packages`/);
|
|
});
|