@intentius/chant 0.124.61 → 0.124.63
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/handlers/approve.d.ts +18 -0
- package/dist/cli/handlers/approve.d.ts.map +1 -1
- package/dist/cli/handlers/approve.js +142 -16
- package/dist/cli/handlers/plan.d.ts +10 -0
- package/dist/cli/handlers/plan.d.ts.map +1 -0
- package/dist/cli/handlers/plan.js +71 -0
- package/dist/cli/handlers/release.d.ts +6 -4
- package/dist/cli/handlers/release.d.ts.map +1 -1
- package/dist/cli/handlers/release.js +13 -7
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +34 -5
- package/dist/cli/mcp/workspace-tools.d.ts.map +1 -1
- package/dist/cli/mcp/workspace-tools.js +2 -1
- package/dist/cli/parse-args.d.ts.map +1 -1
- package/dist/cli/parse-args.js +31 -0
- package/dist/cli/registry.d.ts +13 -1
- package/dist/cli/registry.d.ts.map +1 -1
- package/dist/config.d.ts +32 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/gate-decision.d.ts +1 -1
- package/dist/gate-decision.d.ts.map +1 -1
- package/dist/gate-decision.js +4 -2
- package/dist/gate-statement.schema.json +44 -0
- package/dist/lifecycle/__fixtures__/publish-fakes.d.ts +20 -0
- package/dist/lifecycle/__fixtures__/publish-fakes.d.ts.map +1 -1
- package/dist/lifecycle/__fixtures__/publish-fakes.js +119 -3
- package/dist/lifecycle/gate-ledger.d.ts +17 -3
- package/dist/lifecycle/gate-ledger.d.ts.map +1 -1
- package/dist/lifecycle/gate-seal.d.ts +39 -3
- package/dist/lifecycle/gate-seal.d.ts.map +1 -1
- package/dist/lifecycle/gate-seal.js +50 -10
- package/dist/lifecycle/gate-statement.d.ts +70 -0
- package/dist/lifecycle/gate-statement.d.ts.map +1 -0
- package/dist/lifecycle/gate-statement.js +74 -0
- package/dist/lifecycle/gate-webauthn.d.ts +79 -0
- package/dist/lifecycle/gate-webauthn.d.ts.map +1 -0
- package/dist/lifecycle/gate-webauthn.js +105 -0
- package/dist/lifecycle/git.d.ts +1 -1
- package/dist/lifecycle/git.d.ts.map +1 -1
- package/dist/lifecycle/git.js +24 -19
- package/dist/lifecycle/ledger-remote.d.ts +37 -0
- package/dist/lifecycle/ledger-remote.d.ts.map +1 -0
- package/dist/lifecycle/ledger-remote.js +42 -0
- package/dist/lifecycle/plan-stale.d.ts +76 -0
- package/dist/lifecycle/plan-stale.d.ts.map +1 -0
- package/dist/lifecycle/plan-stale.js +121 -0
- package/dist/lifecycle/publish-credentials.d.ts +1 -1
- package/dist/lifecycle/publish-credentials.d.ts.map +1 -1
- package/dist/lifecycle/publish-credentials.js +2 -0
- package/dist/lifecycle/publish-declaration.d.ts +87 -0
- package/dist/lifecycle/publish-declaration.d.ts.map +1 -1
- package/dist/lifecycle/publish-declaration.js +87 -1
- package/dist/lifecycle/publish-forge.d.ts +5 -1
- package/dist/lifecycle/publish-forge.d.ts.map +1 -1
- package/dist/lifecycle/publish-forge.js +14 -4
- package/dist/lifecycle/publish-github.d.ts +69 -0
- package/dist/lifecycle/publish-github.d.ts.map +1 -0
- package/dist/lifecycle/publish-github.js +153 -0
- package/dist/lifecycle/publish-homebrew.d.ts +66 -0
- package/dist/lifecycle/publish-homebrew.d.ts.map +1 -0
- package/dist/lifecycle/publish-homebrew.js +173 -0
- package/dist/lifecycle/publish-marketplace.d.ts +51 -0
- package/dist/lifecycle/publish-marketplace.d.ts.map +1 -0
- package/dist/lifecycle/publish-marketplace.js +254 -0
- package/dist/lifecycle/publish-targets.d.ts +6 -0
- package/dist/lifecycle/publish-targets.d.ts.map +1 -1
- package/dist/lifecycle/publish-targets.js +15 -0
- package/dist/lifecycle/publish-tauri.d.ts +61 -0
- package/dist/lifecycle/publish-tauri.d.ts.map +1 -0
- package/dist/lifecycle/publish-tauri.js +182 -0
- package/dist/lifecycle/release-publish.d.ts +5 -2
- package/dist/lifecycle/release-publish.d.ts.map +1 -1
- package/dist/lifecycle/snapshot-store.d.ts.map +1 -1
- package/dist/lifecycle/snapshot-store.js +17 -9
- package/dist/lifecycle/test-passkey.d.ts +25 -0
- package/dist/lifecycle/test-passkey.d.ts.map +1 -0
- package/dist/lifecycle/test-passkey.js +39 -0
- package/dist/notify.d.ts +23 -3
- package/dist/notify.d.ts.map +1 -1
- package/dist/notify.js +8 -2
- package/dist/notify.schema.json +12 -3
- package/dist/op/activities/activity-contracts.d.ts +4 -4
- package/dist/pr-forge.d.ts +20 -0
- package/dist/pr-forge.d.ts.map +1 -1
- package/dist/pr-forge.js +61 -2
- package/dist/release-floors.d.ts +1 -1
- package/dist/release-floors.js +1 -1
- package/dist/wave-runtime.mjs +331 -330
- package/dist/workspace/ci-builds.d.ts +21 -0
- package/dist/workspace/ci-builds.d.ts.map +1 -1
- package/dist/workspace/ci-builds.js +14 -0
- package/dist/workspace/ci-green-workflow.d.ts +2 -0
- package/dist/workspace/ci-green-workflow.d.ts.map +1 -1
- package/dist/workspace/ci-green-workflow.js +9 -0
- package/dist/workspace/ci-green.d.ts +45 -2
- package/dist/workspace/ci-green.d.ts.map +1 -1
- package/dist/workspace/ci-green.js +127 -9
- package/dist/workspace/ci-quarantine-report.d.ts +80 -0
- package/dist/workspace/ci-quarantine-report.d.ts.map +1 -0
- package/dist/workspace/ci-quarantine-report.js +205 -0
- package/dist/workspace/ci-quarantine.d.ts +73 -0
- package/dist/workspace/ci-quarantine.d.ts.map +1 -0
- package/dist/workspace/ci-quarantine.js +171 -0
- package/dist/workspace/ci-serve.d.ts.map +1 -1
- package/dist/workspace/ci-serve.js +7 -4
- package/dist/workspace/class-data.d.ts +3 -1
- package/dist/workspace/class-data.d.ts.map +1 -1
- package/dist/workspace/class-data.js +4 -1
- package/dist/workspace/declaration.d.ts +45 -2
- package/dist/workspace/declaration.d.ts.map +1 -1
- package/dist/workspace/declaration.js +45 -2
- package/dist/workspace/declaration.schema.json +51 -3
- package/dist/workspace/forge-work.d.ts +76 -0
- package/dist/workspace/forge-work.d.ts.map +1 -0
- package/dist/workspace/forge-work.js +160 -0
- package/dist/workspace/identity-gate-rule.d.ts +3 -2
- package/dist/workspace/identity-gate-rule.d.ts.map +1 -1
- package/dist/workspace/identity-gate-rule.js +5 -7
- package/dist/workspace/identity.d.ts +3 -2
- package/dist/workspace/identity.d.ts.map +1 -1
- package/dist/workspace/identity.js +6 -3
- package/dist/workspace/intent-cli.d.ts +3 -2
- package/dist/workspace/intent-cli.d.ts.map +1 -1
- package/dist/workspace/intent-cli.js +26 -5
- package/dist/workspace/intent-record.d.ts +3 -0
- package/dist/workspace/intent-record.d.ts.map +1 -1
- package/dist/workspace/intent-record.schema.json +32 -0
- package/dist/workspace/intent.d.ts +9 -0
- package/dist/workspace/intent.d.ts.map +1 -1
- package/dist/workspace/intent.js +3 -0
- package/dist/workspace/intent.schema.json +32 -0
- package/dist/workspace/kind-readers.d.ts.map +1 -1
- package/dist/workspace/kind-readers.js +2 -1
- package/dist/workspace/kinds.d.ts +6 -1
- package/dist/workspace/kinds.d.ts.map +1 -1
- package/dist/workspace/kinds.js +8 -3
- package/dist/workspace/plan-stale.schema.json +286 -0
- package/dist/workspace/release-candidates.d.ts +33 -6
- package/dist/workspace/release-candidates.d.ts.map +1 -1
- package/dist/workspace/release-candidates.js +49 -20
- package/dist/workspace/release-candidates.schema.json +48 -2
- package/dist/workspace/trust/policy.d.ts +10 -0
- package/dist/workspace/trust/policy.d.ts.map +1 -1
- package/dist/workspace/trust/policy.js +19 -1
- package/dist/workspace/trust/run-commits.d.ts.map +1 -1
- package/dist/workspace/trust/run-commits.js +2 -1
- package/dist/workspace/trust/seal.d.ts.map +1 -1
- package/dist/workspace/trust/seal.js +34 -3
- package/dist/workspace/trust/trust-files.d.ts.map +1 -1
- package/dist/workspace/trust/trust-files.js +6 -1
- package/package.json +2 -1
- package/src/cli/handlers/approve-external-signature.test.ts +226 -0
- package/src/cli/handlers/approve.ts +174 -16
- package/src/cli/handlers/plan.ts +74 -0
- package/src/cli/handlers/release.ts +12 -7
- package/src/cli/main.ts +34 -5
- package/src/cli/mcp/workspace-tools.ts +2 -1
- package/src/cli/parse-args.ts +24 -0
- package/src/cli/registry.ts +13 -1
- package/src/gate-decision-bundle.test.ts +4 -2
- package/src/gate-decision.ts +11 -2
- package/src/gate-statement.schema.json +44 -0
- package/src/lifecycle/__fixtures__/publish-fakes.ts +125 -5
- package/src/lifecycle/gate-ledger.ts +17 -3
- package/src/lifecycle/gate-seal.ts +62 -9
- package/src/lifecycle/gate-statement.ts +107 -0
- package/src/lifecycle/gate-webauthn.test.ts +77 -0
- package/src/lifecycle/gate-webauthn.ts +133 -0
- package/src/lifecycle/git.ts +23 -19
- package/src/lifecycle/ledger-remote.test.ts +183 -0
- package/src/lifecycle/ledger-remote.ts +46 -0
- package/src/lifecycle/plan-stale.test.ts +150 -0
- package/src/lifecycle/plan-stale.ts +173 -0
- package/src/lifecycle/publish-credentials.ts +2 -0
- package/src/lifecycle/publish-declaration.ts +93 -1
- package/src/lifecycle/publish-forge.ts +15 -4
- package/src/lifecycle/publish-github.ts +174 -0
- package/src/lifecycle/publish-homebrew.test.ts +179 -0
- package/src/lifecycle/publish-homebrew.ts +187 -0
- package/src/lifecycle/publish-marketplace.test.ts +254 -0
- package/src/lifecycle/publish-marketplace.ts +259 -0
- package/src/lifecycle/publish-target-context.test.ts +2 -2
- package/src/lifecycle/publish-targets.test.ts +23 -0
- package/src/lifecycle/publish-targets.ts +15 -0
- package/src/lifecycle/publish-tauri.test.ts +163 -0
- package/src/lifecycle/publish-tauri.ts +199 -0
- package/src/lifecycle/release-publish.ts +5 -3
- package/src/lifecycle/snapshot-store.ts +16 -9
- package/src/lifecycle/test-passkey.ts +55 -0
- package/src/notify-bundle.test.ts +3 -1
- package/src/notify.schema.json +12 -3
- package/src/notify.ts +20 -3
- package/src/override-gate-bundle.test.ts +2 -0
- package/src/pr-forge-bundle.test.ts +2 -2
- package/src/pr-forge.test.ts +38 -0
- package/src/pr-forge.ts +68 -5
- package/src/release-floors.ts +1 -1
- package/src/stage-hooks-bundle.test.ts +2 -0
- package/src/wave-runtime-bundle.test.ts +3 -2
- package/src/workspace/ci-builds.ts +27 -0
- package/src/workspace/ci-green-stale.test.ts +193 -0
- package/src/workspace/ci-green-workflow.test.ts +9 -0
- package/src/workspace/ci-green-workflow.ts +9 -0
- package/src/workspace/ci-green.ts +141 -10
- package/src/workspace/ci-quarantine-report.test.ts +146 -0
- package/src/workspace/ci-quarantine-report.ts +235 -0
- package/src/workspace/ci-quarantine.test.ts +161 -0
- package/src/workspace/ci-quarantine.ts +189 -0
- package/src/workspace/ci-serve.ts +7 -4
- package/src/workspace/class-data.ts +5 -1
- package/src/workspace/declaration.schema.json +51 -3
- package/src/workspace/declaration.test.ts +1 -0
- package/src/workspace/declaration.ts +88 -5
- package/src/workspace/forge-work.test.ts +143 -0
- package/src/workspace/forge-work.ts +195 -0
- package/src/workspace/identity-gate-rule.ts +6 -8
- package/src/workspace/identity.ts +6 -3
- package/src/workspace/intent-cli.ts +24 -5
- package/src/workspace/intent-record.schema.json +32 -0
- package/src/workspace/intent-record.ts +3 -0
- package/src/workspace/intent.schema.json +32 -0
- package/src/workspace/intent.ts +10 -0
- package/src/workspace/kind-readers.ts +2 -1
- package/src/workspace/kinds.test.ts +13 -0
- package/src/workspace/kinds.ts +12 -3
- package/src/workspace/plan-stale.schema.json +286 -0
- package/src/workspace/release-candidates.schema.json +48 -2
- package/src/workspace/release-candidates.test.ts +77 -4
- package/src/workspace/release-candidates.ts +62 -20
- package/src/workspace/trust/policy.ts +24 -1
- package/src/workspace/trust/run-commits.ts +2 -1
- package/src/workspace/trust/seal.ts +35 -3
- package/src/workspace/trust/trust-files.test.ts +5 -0
- package/src/workspace/trust/trust-files.ts +15 -1
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Homebrew tap target (#4676): a formula in a tap repository on GitHub,
|
|
3
|
+
* rendered from a template in the member with the release's version and each
|
|
4
|
+
* asset's URL and SHA-256, and committed through GitHub's REST API with the
|
|
5
|
+
* token from `tokenEnv` (default `HOMEBREW_TAP_TOKEN`).
|
|
6
|
+
*
|
|
7
|
+
* The template is the formula as the tap holds it, with placeholders where a
|
|
8
|
+
* release changes it:
|
|
9
|
+
*
|
|
10
|
+
* - `{{version}}`: the release's version, its label from the first digit on
|
|
11
|
+
* (`v1.4.0` and `app-v1.4.0` are both `1.4.0`);
|
|
12
|
+
* - `{{url:<name>}}` and `{{sha256:<name>}}`: the URL and the SHA-256 in hex
|
|
13
|
+
* of the declared asset whose file name is `<name>`;
|
|
14
|
+
* - `{{label}}` and `{{tag}}`: the release's label and the tag the cut made.
|
|
15
|
+
*
|
|
16
|
+
* A placeholder chant does not know, or an asset name no declared asset has,
|
|
17
|
+
* is refused (`publish-homebrew-template`). Everything else is copied as it
|
|
18
|
+
* is, so `on_macos`, `on_linux`, `on_arm` and `on_intel` blocks each name
|
|
19
|
+
* their own asset and the formula's Ruby stays the member's. Each SHA-256 is
|
|
20
|
+
* of the file in the checkout, which must match the digest the release
|
|
21
|
+
* records for it.
|
|
22
|
+
*
|
|
23
|
+
* A tap is a branch people install from, with no draft, so the two steps are
|
|
24
|
+
* a branch and a fast-forward (#4048):
|
|
25
|
+
*
|
|
26
|
+
* - The stage commits the rendered formula to `chant-publish/<formula>-<version>`,
|
|
27
|
+
* a branch it makes at the tap branch's head (or moves there, when an
|
|
28
|
+
* earlier stage left it elsewhere). `brew` reads only the tap branch, so
|
|
29
|
+
* nothing is visible. A tap branch that already holds the formula as
|
|
30
|
+
* rendered stages nothing, and a staging branch that already holds it is
|
|
31
|
+
* not committed to again.
|
|
32
|
+
* - The reveal fast-forwards the tap branch to the staged commit, then
|
|
33
|
+
* deletes the staging branch. When the tap branch moved since the stage,
|
|
34
|
+
* the reveal commits the formula onto it instead, one commit either way,
|
|
35
|
+
* unless it already holds the formula as rendered.
|
|
36
|
+
*
|
|
37
|
+
* The asset URLs are the declaration's `url` pattern, so the files must be
|
|
38
|
+
* downloadable there by the time the formula is: declare the `forge` target
|
|
39
|
+
* that attaches them before this one, and its reveal runs first.
|
|
40
|
+
*/
|
|
41
|
+
|
|
42
|
+
import { readFileSync } from "node:fs";
|
|
43
|
+
import { basename } from "node:path";
|
|
44
|
+
import { readCredential } from "./publish-credentials";
|
|
45
|
+
import type { HomebrewPublishDeclaration } from "./publish-declaration";
|
|
46
|
+
import { GitHubRepo, githubApi } from "./publish-github";
|
|
47
|
+
import { bytesDigest, checkReleaseDigest, memberFile, publishTargetKey } from "./publish-targets";
|
|
48
|
+
import { PublishTargetError, type PublishContext, type PublishDeps, type PublishFetch, type PublishItem, type PublishTarget } from "./release-publish";
|
|
49
|
+
import { NEXT_RELEASE } from "../release-floors";
|
|
50
|
+
|
|
51
|
+
/** The first chant that publishes a `homebrew` target (#4676). */
|
|
52
|
+
export const PUBLISH_HOMEBREW_FLOOR = NEXT_RELEASE;
|
|
53
|
+
|
|
54
|
+
/** The variable the tap token is read from when the declaration names none. */
|
|
55
|
+
export const HOMEBREW_TOKEN_ENV = "HOMEBREW_TAP_TOKEN";
|
|
56
|
+
|
|
57
|
+
/** A release's version for a package manager: its label from the first digit on, or null when the label has no digit. */
|
|
58
|
+
export function releaseVersion(label: string | null): string | null {
|
|
59
|
+
const at = label?.search(/\d/) ?? -1;
|
|
60
|
+
return label && at >= 0 ? label.slice(at) : null;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** `pattern` with `{tag}`, `{label}`, `{version}` and `{name}` filled in, each URL-encoded except the tag's slashes. */
|
|
64
|
+
export function fillUrl(pattern: string, values: { tag: string; label: string; version: string; name: string }): string {
|
|
65
|
+
return pattern.replace(/\{(tag|label|version|name)\}/g, (_, k: keyof typeof values) =>
|
|
66
|
+
k === "tag" ? values.tag.split("/").map(encodeURIComponent).join("/") : encodeURIComponent(values[k]),
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** Render a formula template, or name what it can't fill. */
|
|
71
|
+
export function renderFormula(
|
|
72
|
+
template: string,
|
|
73
|
+
values: { version: string; label: string; tag: string },
|
|
74
|
+
assets: ReadonlyMap<string, { url: string; sha256: string }>,
|
|
75
|
+
): string {
|
|
76
|
+
return template.replace(/\{\{\s*([^}]*?)\s*\}\}/g, (whole, inner: string) => {
|
|
77
|
+
if (inner === "version" || inner === "label" || inner === "tag") return values[inner];
|
|
78
|
+
const m = /^(url|sha256):(.+)$/.exec(inner);
|
|
79
|
+
const asset = m ? assets.get(m[2]!.trim()) : undefined;
|
|
80
|
+
if (m && asset) return m[1] === "url" ? asset.url : asset.sha256;
|
|
81
|
+
throw new PublishTargetError(
|
|
82
|
+
"publish-homebrew-template",
|
|
83
|
+
m ? `the formula template names ${whole}, and no declared asset is named ${m[2]!.trim()}` : `the formula template has ${whole}, which chant does not fill`,
|
|
84
|
+
`The placeholders are {{version}}, {{label}}, {{tag}}, and {{url:<name>}} and {{sha256:<name>}} for an asset in assets: ${[...assets.keys()].join(", ")}.`,
|
|
85
|
+
);
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export function homebrewTarget(decl: HomebrewPublishDeclaration, deps: PublishDeps): PublishTarget {
|
|
90
|
+
const fetchImpl: PublishFetch = deps.fetch ?? ((url, init) => fetch(url, init as RequestInit));
|
|
91
|
+
const tokenNames = [decl.tokenEnv ?? HOMEBREW_TOKEN_ENV];
|
|
92
|
+
const formulaName = basename(decl.formula).replace(/\.rb$/, "");
|
|
93
|
+
const setup = (ctx: PublishContext) => {
|
|
94
|
+
const version = releaseVersion(ctx.label);
|
|
95
|
+
if (!version || !ctx.label || !ctx.releaseTag) {
|
|
96
|
+
throw new PublishTargetError(
|
|
97
|
+
"publish-homebrew-no-version",
|
|
98
|
+
`a formula's version is the release's label from its first digit, and release ${ctx.release.releaseDigest} has ${ctx.label ? `the label ${ctx.label}, which has no digit` : "no label"}`,
|
|
99
|
+
"Cut the release with a label such as v1.4.0.",
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
const token = readCredential(ctx.env, tokenNames, ctx.redactor);
|
|
103
|
+
if (!token) {
|
|
104
|
+
throw new PublishTargetError("publish-credentials-missing", `the homebrew target reads its token from ${tokenNames[0]}, and it is not set`, `Set ${tokenNames[0]} to a token that may push to ${decl.tap}.`);
|
|
105
|
+
}
|
|
106
|
+
const assets = new Map<string, { url: string; sha256: string }>();
|
|
107
|
+
for (const p of decl.assets) {
|
|
108
|
+
const abs = memberFile(ctx.cwd, p);
|
|
109
|
+
const digest = bytesDigest(new Uint8Array(readFileSync(abs)));
|
|
110
|
+
checkReleaseDigest(ctx.release, "asset", ctx.cwd, p, [digest]);
|
|
111
|
+
const name = basename(p);
|
|
112
|
+
if (assets.has(name)) throw new PublishTargetError("publish-homebrew-asset-name-taken", `two assets are named ${name}, and the template names an asset by its file name`);
|
|
113
|
+
const url = fillUrl(decl.url, { tag: ctx.releaseTag, label: ctx.label, version, name });
|
|
114
|
+
assets.set(name, { url, sha256: digest.slice("sha256:".length) });
|
|
115
|
+
}
|
|
116
|
+
const template = readFileSync(memberFile(ctx.cwd, decl.template), "utf-8");
|
|
117
|
+
const bytes = new Uint8Array(Buffer.from(renderFormula(template, { version, label: ctx.label, tag: ctx.releaseTag }, assets), "utf-8"));
|
|
118
|
+
return { version, token, assets, bytes, digest: bytesDigest(bytes) };
|
|
119
|
+
};
|
|
120
|
+
const where = (branch: string) => `${decl.tap}@${branch}:${decl.formula}`;
|
|
121
|
+
const target: PublishTarget = {
|
|
122
|
+
kind: "homebrew",
|
|
123
|
+
name: `homebrew formula ${formulaName} in ${decl.tap}`,
|
|
124
|
+
destination: `github ${decl.tap}`,
|
|
125
|
+
credentialEnv: tokenNames,
|
|
126
|
+
key: publishTargetKey(decl),
|
|
127
|
+
async plan(ctx) {
|
|
128
|
+
const { digest } = setup(ctx);
|
|
129
|
+
return [{ name: decl.formula, destination: where(decl.branch ?? "the default branch"), digest }];
|
|
130
|
+
},
|
|
131
|
+
async stage(ctx) {
|
|
132
|
+
const { version, token, assets, bytes, digest } = setup(ctx);
|
|
133
|
+
ctx.log(`using the token from ${token.from}`);
|
|
134
|
+
for (const [name, a] of assets) ctx.log(`${name}: ${a.url} sha256 ${a.sha256}`);
|
|
135
|
+
const tap = new GitHubRepo(githubApi(decl.api, ctx.env), decl.tap, token, fetchImpl, ctx, "publish-homebrew-failed");
|
|
136
|
+
const branch = decl.branch ?? (await tap.defaultBranch());
|
|
137
|
+
const head = await tap.branchHead(branch);
|
|
138
|
+
if (!head) throw new PublishTargetError("publish-homebrew-failed", `${decl.tap} has no branch ${branch}`, "Set branch to the branch brew installs from.");
|
|
139
|
+
const item: PublishItem = { name: decl.formula, destination: where(branch), digest };
|
|
140
|
+
const done = (state: Record<string, string>, present: boolean) => ({ target: target.name, destination: target.destination, items: [{ ...item, ...(present ? { present: true } : {}) }], state: { branch, ...state } });
|
|
141
|
+
|
|
142
|
+
const onTap = await tap.file(decl.formula, branch);
|
|
143
|
+
if (onTap && onTap.bytes.equals(Buffer.from(bytes))) {
|
|
144
|
+
ctx.log(`${branch} already has ${decl.formula} for ${version}`);
|
|
145
|
+
return done({ present: "true" }, true);
|
|
146
|
+
}
|
|
147
|
+
const staging = `chant-publish/${formulaName}-${version}`;
|
|
148
|
+
const stagingHead = await tap.branchHead(staging);
|
|
149
|
+
if (stagingHead) {
|
|
150
|
+
const onStaging = await tap.file(decl.formula, staging);
|
|
151
|
+
if (onStaging && onStaging.bytes.equals(Buffer.from(bytes))) {
|
|
152
|
+
ctx.log(`${staging} already has ${decl.formula} for ${version}`);
|
|
153
|
+
return done({ staging, commit: stagingHead }, true);
|
|
154
|
+
}
|
|
155
|
+
await tap.moveRef(`heads/${staging}`, head, true);
|
|
156
|
+
} else {
|
|
157
|
+
await tap.createBranch(staging, head);
|
|
158
|
+
}
|
|
159
|
+
ctx.log(`committing ${decl.formula} for ${version} to ${staging}, at ${branch}'s head ${head.slice(0, 12)}`);
|
|
160
|
+
const commit = await tap.putFile(decl.formula, staging, bytes, `${formulaName} ${version}`, onTap?.sha ?? null);
|
|
161
|
+
return done({ staging, commit }, false);
|
|
162
|
+
},
|
|
163
|
+
async reveal(ctx, staged) {
|
|
164
|
+
const items = staged.items.map((i) => ({ name: i.name, destination: i.destination, ...(i.digest ? { digest: i.digest } : {}) }));
|
|
165
|
+
const published = { target: target.name, destination: target.destination, items };
|
|
166
|
+
if (staged.state.present === "true") return { ...published, items: items.map((i) => ({ ...i, present: true })) };
|
|
167
|
+
const { version, token, bytes } = setup(ctx);
|
|
168
|
+
const { branch, staging, commit } = staged.state;
|
|
169
|
+
if (!branch || !staging || !commit) throw new PublishTargetError("publish-homebrew-failed", `the staged formula for ${decl.tap} has no staging commit to reveal`);
|
|
170
|
+
const tap = new GitHubRepo(githubApi(decl.api, ctx.env), decl.tap, token, fetchImpl, ctx, "publish-homebrew-failed");
|
|
171
|
+
ctx.log(`fast-forwarding ${branch} to ${commit.slice(0, 12)}`);
|
|
172
|
+
if (!(await tap.moveRef(`heads/${branch}`, commit, false))) {
|
|
173
|
+
// The tap moved since the stage: one commit of the formula onto it, unless it already holds it.
|
|
174
|
+
const onTap = await tap.file(decl.formula, branch);
|
|
175
|
+
if (onTap && onTap.bytes.equals(Buffer.from(bytes))) {
|
|
176
|
+
ctx.log(`${branch} moved since the stage and already has ${decl.formula} for ${version}`);
|
|
177
|
+
} else {
|
|
178
|
+
ctx.log(`${branch} moved since the stage; committing ${decl.formula} for ${version} onto it`);
|
|
179
|
+
await tap.putFile(decl.formula, branch, bytes, `${formulaName} ${version}`, onTap?.sha ?? null);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
await tap.deleteRef(`heads/${staging}`);
|
|
183
|
+
return published;
|
|
184
|
+
},
|
|
185
|
+
};
|
|
186
|
+
return target;
|
|
187
|
+
}
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* #4676: the editor marketplace target. Open VSX against a fake of its REST
|
|
3
|
+
* API, the VS Code Marketplace against a fake `vsce` binary and a fake of the
|
|
4
|
+
* gallery's query API. The stage uploads nothing, since a marketplace has no
|
|
5
|
+
* draft; the reveal uploads. Nothing reaches a network.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { afterAll, describe, expect, test } from "vitest";
|
|
9
|
+
import { createHash } from "node:crypto";
|
|
10
|
+
import { chmodSync, existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
11
|
+
import { tmpdir } from "node:os";
|
|
12
|
+
import { join } from "node:path";
|
|
13
|
+
import { crc32, deflateRawSync } from "node:zlib";
|
|
14
|
+
import { createRedactor } from "./publish-credentials";
|
|
15
|
+
import { PublishDeclarationSchema } from "./publish-declaration";
|
|
16
|
+
import { readZipEntry, vsixIdentity } from "./publish-marketplace";
|
|
17
|
+
import { createPublishTargets } from "./publish-targets";
|
|
18
|
+
import { PublishTargetError, type PublishContext } from "./release-publish";
|
|
19
|
+
import { makeRelease, type ReleaseArtifact } from "./release-store";
|
|
20
|
+
|
|
21
|
+
const dirs: string[] = [];
|
|
22
|
+
afterAll(() => {
|
|
23
|
+
for (const d of dirs) rmSync(d, { recursive: true, force: true });
|
|
24
|
+
});
|
|
25
|
+
const temp = () => {
|
|
26
|
+
const d = mkdtempSync(join(tmpdir(), "chant-publish-marketplace-"));
|
|
27
|
+
dirs.push(d);
|
|
28
|
+
return d;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
function context(cwd: string, env: NodeJS.ProcessEnv, artifacts: ReleaseArtifact[] = []): PublishContext & { lines: string[] } {
|
|
32
|
+
const redactor = createRedactor(env);
|
|
33
|
+
const lines: string[] = [];
|
|
34
|
+
const release = makeRelease({ member: null, commit: "c0ffee".padEnd(40, "0"), artifactDigests: artifacts, targets: [{ env: "dev", params: [], templates: [] }] });
|
|
35
|
+
return { release, label: "v1.2.0", releaseTag: "release/v1.2.0", provenance: { oidc: false, ci: null, reason: "" }, cwd, tag: null, env, redactor, log: (l) => lines.push(redactor.redact(l)), lines };
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async function refused(p: Promise<unknown>): Promise<PublishTargetError> {
|
|
39
|
+
try {
|
|
40
|
+
await p;
|
|
41
|
+
} catch (err) {
|
|
42
|
+
if (err instanceof PublishTargetError) return err;
|
|
43
|
+
throw err;
|
|
44
|
+
}
|
|
45
|
+
throw new Error("expected a PublishTargetError");
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** A zip of `files`, the first stored and the rest deflated, as `vsce package` writes a .vsix. */
|
|
49
|
+
function zip(files: Record<string, string>): Buffer {
|
|
50
|
+
const locals: Buffer[] = [];
|
|
51
|
+
const central: Buffer[] = [];
|
|
52
|
+
let offset = 0;
|
|
53
|
+
Object.entries(files).forEach(([name, text], i) => {
|
|
54
|
+
const raw = Buffer.from(text);
|
|
55
|
+
const method = i === 0 ? 0 : 8;
|
|
56
|
+
const data = method === 0 ? raw : deflateRawSync(raw);
|
|
57
|
+
const n = Buffer.from(name);
|
|
58
|
+
const local = Buffer.alloc(30);
|
|
59
|
+
local.writeUInt32LE(0x04034b50, 0);
|
|
60
|
+
local.writeUInt16LE(20, 4);
|
|
61
|
+
local.writeUInt16LE(method, 8);
|
|
62
|
+
local.writeUInt32LE(crc32(raw), 14);
|
|
63
|
+
local.writeUInt32LE(data.length, 18);
|
|
64
|
+
local.writeUInt32LE(raw.length, 22);
|
|
65
|
+
local.writeUInt16LE(n.length, 26);
|
|
66
|
+
const cd = Buffer.alloc(46);
|
|
67
|
+
cd.writeUInt32LE(0x02014b50, 0);
|
|
68
|
+
cd.writeUInt16LE(20, 4);
|
|
69
|
+
cd.writeUInt16LE(20, 6);
|
|
70
|
+
cd.writeUInt16LE(method, 10);
|
|
71
|
+
cd.writeUInt32LE(crc32(raw), 16);
|
|
72
|
+
cd.writeUInt32LE(data.length, 20);
|
|
73
|
+
cd.writeUInt32LE(raw.length, 24);
|
|
74
|
+
cd.writeUInt16LE(n.length, 28);
|
|
75
|
+
cd.writeUInt32LE(offset, 42);
|
|
76
|
+
locals.push(local, n, data);
|
|
77
|
+
central.push(cd, n);
|
|
78
|
+
offset += 30 + n.length + data.length;
|
|
79
|
+
});
|
|
80
|
+
const dir = Buffer.concat(central);
|
|
81
|
+
const end = Buffer.alloc(22);
|
|
82
|
+
end.writeUInt32LE(0x06054b50, 0);
|
|
83
|
+
end.writeUInt16LE(Object.keys(files).length, 8);
|
|
84
|
+
end.writeUInt16LE(Object.keys(files).length, 10);
|
|
85
|
+
end.writeUInt32LE(dir.length, 12);
|
|
86
|
+
end.writeUInt32LE(offset, 16);
|
|
87
|
+
return Buffer.concat([...locals, dir, end]);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const MANIFEST = JSON.stringify({ publisher: "arugula", name: "arugula-vscode", version: "1.2.0", engines: { vscode: "^1.90.0" } });
|
|
91
|
+
function member(manifest = MANIFEST): { dir: string; bytes: Buffer; digest: string } {
|
|
92
|
+
const dir = temp();
|
|
93
|
+
mkdirSync(join(dir, "dist"));
|
|
94
|
+
const bytes = zip({ "[Content_Types].xml": "<Types/>", "extension.vsixmanifest": "<PackageManifest/>", "extension/package.json": manifest, "extension/out/main.js": "exports.activate = () => {};\n".repeat(50) });
|
|
95
|
+
writeFileSync(join(dir, "dist", "arugula.vsix"), bytes);
|
|
96
|
+
return { dir, bytes, digest: `sha256:${createHash("sha256").update(bytes).digest("hex")}` };
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const reply = (status: number, body: string | Uint8Array = "") => ({
|
|
100
|
+
ok: status < 300,
|
|
101
|
+
status,
|
|
102
|
+
headers: { get: () => null },
|
|
103
|
+
text: async () => (typeof body === "string" ? body : Buffer.from(body).toString("utf-8")),
|
|
104
|
+
arrayBuffer: async () => {
|
|
105
|
+
const b = typeof body === "string" ? Buffer.from(body) : Buffer.from(body);
|
|
106
|
+
return b.buffer.slice(b.byteOffset, b.byteOffset + b.byteLength) as ArrayBuffer;
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
/** An Open VSX fake: namespaces, and the versions published to it by `POST /api/-/publish`. */
|
|
111
|
+
function fakeOpenVsx(root: string, namespaces: string[], versions = new Map<string, Uint8Array>()) {
|
|
112
|
+
const calls: Array<{ method: string; url: string }> = [];
|
|
113
|
+
const fetch = async (url: string, init: { method: string; headers: Record<string, string>; body?: Uint8Array | string }) => {
|
|
114
|
+
calls.push({ method: init.method, url });
|
|
115
|
+
const u = new URL(url);
|
|
116
|
+
if (init.method === "POST" && u.pathname === "/api/-/publish") {
|
|
117
|
+
if (u.searchParams.get("token") !== "ovsx-token-1") return reply(403, '{"error":"Invalid access token."}');
|
|
118
|
+
const id = vsixIdentity(Buffer.from(init.body as Uint8Array), "upload");
|
|
119
|
+
const key = `${id.publisher}/${id.name}/${id.version}`;
|
|
120
|
+
if (versions.has(key)) return reply(400, '{"error":"already published"}');
|
|
121
|
+
versions.set(key, init.body as Uint8Array);
|
|
122
|
+
return reply(201, "{}");
|
|
123
|
+
}
|
|
124
|
+
const parts = u.pathname.split("/").filter(Boolean);
|
|
125
|
+
if (parts[0] === "files") return versions.has(parts.slice(1, 4).join("/")) ? reply(200, versions.get(parts.slice(1, 4).join("/"))!) : reply(404);
|
|
126
|
+
if (parts[0] === "api" && parts.length === 2) return namespaces.includes(parts[1]!) ? reply(200, JSON.stringify({ name: parts[1] })) : reply(404, '{"error":"Namespace not found"}');
|
|
127
|
+
if (parts[0] === "api" && parts.length === 4) {
|
|
128
|
+
const key = parts.slice(1).join("/");
|
|
129
|
+
return versions.has(key) ? reply(200, JSON.stringify({ version: parts[3], files: { download: `${root}/files/${key}/x.vsix` } })) : reply(404);
|
|
130
|
+
}
|
|
131
|
+
return reply(404);
|
|
132
|
+
};
|
|
133
|
+
return { fetch, calls, versions };
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** A fake `vsce` that logs each run and its VSCE_PAT, and a gallery fake that lists the versions it published. */
|
|
137
|
+
function fakeVsce(dir: string) {
|
|
138
|
+
const log = join(dir, "vsce.log");
|
|
139
|
+
const bin = join(dir, "vsce");
|
|
140
|
+
writeFileSync(
|
|
141
|
+
bin,
|
|
142
|
+
`#!${process.execPath}
|
|
143
|
+
const fs = require("fs");
|
|
144
|
+
fs.appendFileSync(${JSON.stringify(log)}, JSON.stringify({ args: process.argv.slice(2), pat: process.env.VSCE_PAT || "" }) + "\\n");
|
|
145
|
+
console.log("Publishing with " + process.env.VSCE_PAT);
|
|
146
|
+
if (process.env.FAKE_VSCE_FAIL) { console.error("ERROR Access Denied"); process.exit(1); }
|
|
147
|
+
console.log("DONE Published arugula.arugula-vscode v1.2.0.");
|
|
148
|
+
`,
|
|
149
|
+
);
|
|
150
|
+
chmodSync(bin, 0o755);
|
|
151
|
+
const runs = () => (existsSync(log) ? readFileSync(log, "utf-8").trim().split("\n").filter(Boolean).map((l) => JSON.parse(l) as { args: string[]; pat: string }) : []);
|
|
152
|
+
const calls: Array<{ method: string; url: string; body?: string }> = [];
|
|
153
|
+
const fetch = async (url: string, init: { method: string; headers: Record<string, string>; body?: Uint8Array | string }) => {
|
|
154
|
+
calls.push({ method: init.method, url, ...(typeof init.body === "string" ? { body: init.body } : {}) });
|
|
155
|
+
if (init.method === "POST" && url === "https://marketplace.test/_apis/public/gallery/extensionquery") {
|
|
156
|
+
const published = runs().some((r) => !process.env.FAKE_VSCE_FAIL && r.args[0] === "publish");
|
|
157
|
+
return reply(200, JSON.stringify({ results: [{ extensions: published ? [{ versions: [{ version: "1.2.0" }, { version: "1.1.0" }] }] : [] }] }));
|
|
158
|
+
}
|
|
159
|
+
return reply(404);
|
|
160
|
+
};
|
|
161
|
+
return { bin, runs, fetch, calls };
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
describe("editor marketplaces (#4676)", () => {
|
|
165
|
+
test("Open VSX: the stage checks the namespace and uploads nothing; the reveal publishes and checks what Open VSX serves against the file", async () => {
|
|
166
|
+
const { dir, bytes, digest } = member();
|
|
167
|
+
const ovsx = fakeOpenVsx("https://open-vsx.test", ["arugula"]);
|
|
168
|
+
const [target] = await createPublishTargets([PublishDeclarationSchema.parse({ type: "marketplace", marketplace: "openvsx", vsix: "dist/arugula.vsix", registry: "https://open-vsx.test" })], { fetch: ovsx.fetch });
|
|
169
|
+
const ctx = context(dir, { OVSX_PAT: "ovsx-token-1" }, [{ component: "editor", kind: "asset", path: "dist/arugula.vsix", digest }]);
|
|
170
|
+
const item = { name: "arugula.arugula-vscode@1.2.0", destination: "https://open-vsx.test/extension/arugula/arugula-vscode/1.2.0", digest };
|
|
171
|
+
expect(await target!.plan(ctx)).toEqual([item]);
|
|
172
|
+
|
|
173
|
+
const staged = await target!.stage(ctx);
|
|
174
|
+
expect(staged).toMatchObject({ items: [item], state: {} });
|
|
175
|
+
expect(ovsx.calls.map((c) => c.method)).toEqual(["GET", "GET"]);
|
|
176
|
+
expect(ovsx.versions.size).toBe(0);
|
|
177
|
+
|
|
178
|
+
expect(await target!.reveal(ctx, staged)).toMatchObject({ items: [item] });
|
|
179
|
+
expect(Buffer.from(ovsx.versions.get("arugula/arugula-vscode/1.2.0")!).equals(bytes)).toBe(true);
|
|
180
|
+
expect(ctx.lines.join("\n")).not.toContain("ovsx-token-1");
|
|
181
|
+
|
|
182
|
+
// Revealed: the version is there with the same bytes, so a stage finds it present and a reveal sends nothing.
|
|
183
|
+
const again = await target!.stage(ctx);
|
|
184
|
+
expect(again.state).toEqual({ present: "true" });
|
|
185
|
+
const n = ovsx.calls.length;
|
|
186
|
+
await target!.reveal(ctx, { ...staged });
|
|
187
|
+
expect(ovsx.calls.slice(n).some((c) => c.method === "POST")).toBe(false);
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
test("Open VSX: refuses a missing namespace and a version already there with other bytes, before anything is uploaded", async () => {
|
|
191
|
+
const { dir } = member();
|
|
192
|
+
const make = async (ovsx: ReturnType<typeof fakeOpenVsx>) =>
|
|
193
|
+
(await createPublishTargets([PublishDeclarationSchema.parse({ type: "marketplace", marketplace: "openvsx", vsix: "dist/arugula.vsix", registry: "https://open-vsx.test" })], { fetch: ovsx.fetch }))[0]!;
|
|
194
|
+
const ctx = context(dir, { OVSX_PAT: "ovsx-token-1" });
|
|
195
|
+
expect((await refused((await make(fakeOpenVsx("https://open-vsx.test", []))).stage(ctx))).code).toBe("publish-marketplace-no-namespace");
|
|
196
|
+
const other = fakeOpenVsx("https://open-vsx.test", ["arugula"], new Map([["arugula/arugula-vscode/1.2.0", new Uint8Array(Buffer.from("other"))]]));
|
|
197
|
+
expect((await refused((await make(other)).stage(ctx))).code).toBe("publish-marketplace-version-exists");
|
|
198
|
+
expect(other.calls.some((c) => c.method === "POST")).toBe(false);
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
test("VS Code Marketplace: the stage asks the gallery and runs nothing; the reveal runs vsce publish with the token in VSCE_PAT", async () => {
|
|
202
|
+
const { dir, digest } = member();
|
|
203
|
+
const vsce = fakeVsce(temp());
|
|
204
|
+
const [target] = await createPublishTargets([PublishDeclarationSchema.parse({ type: "marketplace", marketplace: "vscode", vsix: "dist/arugula.vsix", registry: "https://marketplace.test", tokenEnv: "MARKETPLACE_PAT" })], {
|
|
205
|
+
fetch: vsce.fetch,
|
|
206
|
+
vsce: vsce.bin,
|
|
207
|
+
});
|
|
208
|
+
const ctx = context(dir, { MARKETPLACE_PAT: "vsce-pat-secret", PATH: process.env.PATH });
|
|
209
|
+
const staged = await target!.stage(ctx);
|
|
210
|
+
expect(staged.items).toEqual([{ name: "arugula.arugula-vscode@1.2.0", destination: "https://marketplace.test/items?itemName=arugula.arugula-vscode", digest }]);
|
|
211
|
+
expect(JSON.parse(vsce.calls[0]!.body!)).toMatchObject({ filters: [{ criteria: [{ filterType: 7, value: "arugula.arugula-vscode" }] }] });
|
|
212
|
+
expect(vsce.runs()).toEqual([]);
|
|
213
|
+
|
|
214
|
+
await target!.reveal(ctx, staged);
|
|
215
|
+
expect(vsce.runs()).toEqual([{ args: ["publish", "--packagePath", join(dir, "dist/arugula.vsix")], pat: "vsce-pat-secret" }]);
|
|
216
|
+
expect(ctx.lines.join("\n")).toContain("vsce: DONE Published arugula.arugula-vscode v1.2.0.");
|
|
217
|
+
expect(ctx.lines.join("\n")).not.toContain("vsce-pat-secret");
|
|
218
|
+
|
|
219
|
+
// Run again: the gallery lists the version, so nothing runs.
|
|
220
|
+
expect((await target!.stage(ctx)).state).toEqual({ present: "true" });
|
|
221
|
+
await target!.reveal(ctx, staged);
|
|
222
|
+
expect(vsce.runs()).toHaveLength(1);
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
test("VS Code Marketplace: a vsce failure is the target's, with vsce's message and no token", async () => {
|
|
226
|
+
const { dir } = member();
|
|
227
|
+
const vsce = fakeVsce(temp());
|
|
228
|
+
const [target] = await createPublishTargets([PublishDeclarationSchema.parse({ type: "marketplace", marketplace: "vscode", vsix: "dist/arugula.vsix", registry: "https://marketplace.test" })], { fetch: vsce.fetch, vsce: vsce.bin });
|
|
229
|
+
const ctx = context(dir, { VSCE_PAT: "vsce-pat-secret", FAKE_VSCE_FAIL: "1", PATH: process.env.PATH });
|
|
230
|
+
const err = await refused(target!.reveal(ctx, await target!.stage(ctx)));
|
|
231
|
+
expect(err.code).toBe("publish-marketplace-failed");
|
|
232
|
+
expect(err.message).toContain("Access Denied");
|
|
233
|
+
expect(err.message).not.toContain("vsce-pat-secret");
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
test("refuses a .vsix that is not the release's, one with no manifest, and a missing token", async () => {
|
|
237
|
+
const make = async () => (await createPublishTargets([PublishDeclarationSchema.parse({ type: "marketplace", marketplace: "openvsx", vsix: "dist/arugula.vsix" })], { fetch: fakeOpenVsx("x", []).fetch }))[0]!;
|
|
238
|
+
const { dir } = member();
|
|
239
|
+
expect((await refused((await make()).plan(context(dir, { OVSX_PAT: "t0ken" }, [{ component: "e", kind: "asset", path: "dist/arugula.vsix", digest: `sha256:${"0".repeat(64)}` }])))).code).toBe(
|
|
240
|
+
"publish-artifact-digest-mismatch",
|
|
241
|
+
);
|
|
242
|
+
expect((await refused((await make()).plan(context(member(JSON.stringify({ name: "x" })).dir, { OVSX_PAT: "t0ken" })))).code).toBe("publish-marketplace-vsix-invalid");
|
|
243
|
+
expect((await refused((await make()).plan(context(dir, {})))).code).toBe("publish-credentials-missing");
|
|
244
|
+
expect(() => PublishDeclarationSchema.parse({ type: "marketplace", marketplace: "eclipse", vsix: "x.vsix" })).toThrow();
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
test("reads stored and deflated zip entries", () => {
|
|
248
|
+
const z = zip({ a: "stored", "b/c.json": '{"x":1}' });
|
|
249
|
+
expect(readZipEntry(z, "a")!.toString()).toBe("stored");
|
|
250
|
+
expect(readZipEntry(z, "b/c.json")!.toString()).toBe('{"x":1}');
|
|
251
|
+
expect(readZipEntry(z, "missing")).toBeNull();
|
|
252
|
+
expect(() => readZipEntry(Buffer.from("not a zip at all, long enough to scan"), "a")).toThrow(/not a zip/);
|
|
253
|
+
});
|
|
254
|
+
});
|