@intentius/chant 0.124.62 → 0.124.64
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 +26 -0
- package/dist/cli/handlers/approve.d.ts.map +1 -1
- package/dist/cli/handlers/approve.js +167 -18
- 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/pr.d.ts.map +1 -1
- package/dist/cli/handlers/pr.js +2 -1
- package/dist/cli/handlers/release.d.ts +11 -7
- package/dist/cli/handlers/release.d.ts.map +1 -1
- package/dist/cli/handlers/release.js +93 -20
- package/dist/cli/main.d.ts.map +1 -1
- package/dist/cli/main.js +48 -7
- 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 +43 -0
- package/dist/cli/registry.d.ts +18 -2
- package/dist/cli/registry.d.ts.map +1 -1
- package/dist/config.d.ts +50 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -0
- 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 +46 -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 +28 -5
- package/dist/lifecycle/gate-ledger.d.ts.map +1 -1
- package/dist/lifecycle/gate-ledger.js +6 -0
- package/dist/lifecycle/gate-seal.d.ts +59 -7
- package/dist/lifecycle/gate-seal.d.ts.map +1 -1
- package/dist/lifecycle/gate-seal.js +68 -15
- package/dist/lifecycle/gate-statement.d.ts +95 -0
- package/dist/lifecycle/gate-statement.d.ts.map +1 -0
- package/dist/lifecycle/gate-statement.js +110 -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 +120 -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 +107 -0
- package/dist/lifecycle/publish-declaration.d.ts.map +1 -1
- package/dist/lifecycle/publish-declaration.js +110 -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 +13 -4
- package/dist/lifecycle/publish-git-ssh.d.ts +82 -0
- package/dist/lifecycle/publish-git-ssh.d.ts.map +1 -0
- package/dist/lifecycle/publish-git-ssh.js +180 -0
- 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 +77 -0
- package/dist/lifecycle/publish-homebrew.d.ts.map +1 -0
- package/dist/lifecycle/publish-homebrew.js +265 -0
- package/dist/lifecycle/publish-marketplace.d.ts +85 -0
- package/dist/lifecycle/publish-marketplace.d.ts.map +1 -0
- package/dist/lifecycle/publish-marketplace.js +398 -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 +181 -0
- package/dist/lifecycle/release-cut.d.ts +51 -5
- package/dist/lifecycle/release-cut.d.ts.map +1 -1
- package/dist/lifecycle/release-cut.js +165 -16
- package/dist/lifecycle/release-publish.d.ts +18 -2
- package/dist/lifecycle/release-publish.d.ts.map +1 -1
- package/dist/lifecycle/release-publish.js +5 -0
- package/dist/lifecycle/release-revocation.d.ts +4 -3
- package/dist/lifecycle/release-revocation.d.ts.map +1 -1
- package/dist/lifecycle/release-revocation.js +5 -4
- package/dist/lifecycle/release-store.d.ts +32 -0
- package/dist/lifecycle/release-store.d.ts.map +1 -1
- package/dist/lifecycle/release-store.js +11 -0
- 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/gate.d.ts +1 -1
- package/dist/op/gate.d.ts.map +1 -1
- package/dist/op/gate.js +2 -1
- package/dist/pr-forge.d.ts +20 -0
- package/dist/pr-forge.d.ts.map +1 -1
- package/dist/pr-forge.js +87 -8
- package/dist/release-floors.d.ts +1 -1
- package/dist/release-floors.js +1 -1
- package/dist/wave-runtime.mjs +333 -331
- 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.d.ts +45 -2
- package/dist/workspace/ci-green.d.ts.map +1 -1
- package/dist/workspace/ci-green.js +123 -5
- 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 +204 -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 +170 -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 +2 -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 +42 -7
- package/dist/workspace/release-candidates.d.ts.map +1 -1
- package/dist/workspace/release-candidates.js +64 -23
- package/dist/workspace/release-candidates.schema.json +55 -2
- package/dist/workspace/releases.schema.json +47 -0
- 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 +328 -0
- package/src/cli/handlers/approve.ts +206 -18
- package/src/cli/handlers/plan.ts +74 -0
- package/src/cli/handlers/pr.ts +2 -1
- package/src/cli/handlers/release.ts +84 -20
- package/src/cli/main.ts +48 -7
- package/src/cli/mcp/workspace-tools.ts +2 -1
- package/src/cli/parse-args.ts +33 -0
- package/src/cli/registry.ts +18 -2
- package/src/config.ts +8 -0
- package/src/gate-decision-bundle.test.ts +4 -2
- package/src/gate-decision.ts +11 -2
- package/src/gate-statement.schema.json +46 -0
- package/src/lifecycle/__fixtures__/publish-fakes.ts +125 -5
- package/src/lifecycle/gate-ledger.ts +34 -5
- package/src/lifecycle/gate-seal.ts +86 -15
- package/src/lifecycle/gate-statement.ts +144 -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 +149 -0
- package/src/lifecycle/plan-stale.ts +172 -0
- package/src/lifecycle/publish-credentials.ts +2 -0
- package/src/lifecycle/publish-declaration.ts +116 -1
- package/src/lifecycle/publish-forge.ts +14 -4
- package/src/lifecycle/publish-git-ssh.ts +202 -0
- package/src/lifecycle/publish-github.ts +174 -0
- package/src/lifecycle/publish-homebrew.test.ts +358 -0
- package/src/lifecycle/publish-homebrew.ts +283 -0
- package/src/lifecycle/publish-marketplace.test.ts +406 -0
- package/src/lifecycle/publish-marketplace.ts +421 -0
- package/src/lifecycle/publish-resume.test.ts +40 -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 +198 -0
- package/src/lifecycle/release-cut-lane.test.ts +177 -0
- package/src/lifecycle/release-cut-override.test.ts +213 -0
- package/src/lifecycle/release-cut.ts +198 -17
- package/src/lifecycle/release-publish.ts +23 -3
- package/src/lifecycle/release-revocation.ts +5 -4
- package/src/lifecycle/release-store.ts +44 -0
- 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/op/gate.ts +2 -1
- 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 +93 -11
- package/src/pr-requires.test.ts +9 -0
- 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.ts +137 -6
- package/src/workspace/ci-quarantine-report.test.ts +145 -0
- package/src/workspace/ci-quarantine-report.ts +234 -0
- package/src/workspace/ci-quarantine.test.ts +160 -0
- package/src/workspace/ci-quarantine.ts +188 -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 +9 -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 +55 -2
- package/src/workspace/release-candidates.test.ts +77 -4
- package/src/workspace/release-candidates.ts +80 -23
- package/src/workspace/releases.schema.json +47 -0
- package/src/workspace/trust/gate-seal.test.ts +44 -0
- 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,406 @@
|
|
|
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
|
+
/**
|
|
111
|
+
* An Open VSX fake: namespaces, and the versions published to it by
|
|
112
|
+
* `POST /api/-/publish`. `trusted` lists the extensions whose trusted
|
|
113
|
+
* publisher is a GitHub Actions ID token with the registry as its audience
|
|
114
|
+
* (`gha-id-token`) or `ovsx-id-token`; `refuse` is a status every upload gets.
|
|
115
|
+
*/
|
|
116
|
+
function fakeOpenVsx(root: string, namespaces: string[], versions = new Map<string, Uint8Array>(), opts: { trusted?: string[]; refuse?: number } = {}) {
|
|
117
|
+
const calls: Array<{ method: string; url: string; headers?: Record<string, string>; body?: string }> = [];
|
|
118
|
+
let issued = 0;
|
|
119
|
+
const fetch = async (url: string, init: { method: string; headers: Record<string, string>; body?: Uint8Array | string }) => {
|
|
120
|
+
calls.push({ method: init.method, url, headers: init.headers, ...(typeof init.body === "string" ? { body: init.body } : {}) });
|
|
121
|
+
const u = new URL(url);
|
|
122
|
+
if (u.host === "token.actions.test") {
|
|
123
|
+
if (init.headers.authorization !== "Bearer gha-request-token") return reply(401);
|
|
124
|
+
return reply(200, JSON.stringify({ value: u.searchParams.get("audience") === root ? "gha-id-token" : "gha-id-token-for-another-audience" }));
|
|
125
|
+
}
|
|
126
|
+
if (init.method === "POST" && u.pathname === "/api/-/trusted-publishing/token") {
|
|
127
|
+
const req = JSON.parse(init.body as string) as { namespace: string; extension: string; token: string };
|
|
128
|
+
if (!["gha-id-token", "ovsx-id-token"].includes(req.token) || !(opts.trusted ?? []).includes(`${req.namespace}.${req.extension}`)) {
|
|
129
|
+
return reply(400, JSON.stringify({ error: `No trusted publisher matches this token for ${req.namespace}.${req.extension}.` }));
|
|
130
|
+
}
|
|
131
|
+
return reply(201, JSON.stringify({ value: `tp-token-${++issued}`, expiresTimestamp: "2026-11-01T00:10:00Z" }));
|
|
132
|
+
}
|
|
133
|
+
if (init.method === "POST" && u.pathname === "/api/-/publish") {
|
|
134
|
+
if (opts.refuse) return reply(opts.refuse);
|
|
135
|
+
const token = u.searchParams.get("token") ?? "";
|
|
136
|
+
if (token !== "ovsx-token-1" && token !== `tp-token-${issued}`) return reply(403, '{"error":"Invalid access token."}');
|
|
137
|
+
const id = vsixIdentity(Buffer.from(init.body as Uint8Array), "upload");
|
|
138
|
+
const key = `${id.publisher}/${id.name}/${id.version}`;
|
|
139
|
+
if (versions.has(key)) return reply(400, '{"error":"already published"}');
|
|
140
|
+
versions.set(key, init.body as Uint8Array);
|
|
141
|
+
return reply(201, "{}");
|
|
142
|
+
}
|
|
143
|
+
const parts = u.pathname.split("/").filter(Boolean);
|
|
144
|
+
if (parts[0] === "files") return versions.has(parts.slice(1, 4).join("/")) ? reply(200, versions.get(parts.slice(1, 4).join("/"))!) : reply(404);
|
|
145
|
+
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"}');
|
|
146
|
+
if (parts[0] === "api" && parts.length === 4) {
|
|
147
|
+
const key = parts.slice(1).join("/");
|
|
148
|
+
return versions.has(key) ? reply(200, JSON.stringify({ version: parts[3], files: { download: `${root}/files/${key}/x.vsix` } })) : reply(404);
|
|
149
|
+
}
|
|
150
|
+
return reply(404);
|
|
151
|
+
};
|
|
152
|
+
return { fetch, calls, versions, issued: () => issued };
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/** A fake `vsce` that logs each run and its VSCE_PAT, and a gallery fake that lists the versions it published. */
|
|
156
|
+
function fakeVsce(dir: string) {
|
|
157
|
+
const log = join(dir, "vsce.log");
|
|
158
|
+
const bin = join(dir, "vsce");
|
|
159
|
+
writeFileSync(
|
|
160
|
+
bin,
|
|
161
|
+
`#!${process.execPath}
|
|
162
|
+
const fs = require("fs");
|
|
163
|
+
fs.appendFileSync(${JSON.stringify(log)}, JSON.stringify({ args: process.argv.slice(2), pat: process.env.VSCE_PAT || "" }) + "\\n");
|
|
164
|
+
if (process.argv[2] === "verify-pat") {
|
|
165
|
+
if (process.env.FAKE_VSCE_VERIFY_FAIL) { console.error("ERROR Can not acquire a Microsoft Entra ID access token."); process.exit(1); }
|
|
166
|
+
console.log("DONE The Personal Access Token verification succeeded for the publisher '" + process.argv[3] + "'.");
|
|
167
|
+
process.exit(0);
|
|
168
|
+
}
|
|
169
|
+
console.log("Publishing with " + process.env.VSCE_PAT);
|
|
170
|
+
if (process.env.FAKE_VSCE_FAIL) { console.error("ERROR Access Denied"); process.exit(1); }
|
|
171
|
+
console.log("DONE Published arugula.arugula-vscode v1.2.0.");
|
|
172
|
+
`,
|
|
173
|
+
);
|
|
174
|
+
chmodSync(bin, 0o755);
|
|
175
|
+
const runs = () => (existsSync(log) ? readFileSync(log, "utf-8").trim().split("\n").filter(Boolean).map((l) => JSON.parse(l) as { args: string[]; pat: string }) : []);
|
|
176
|
+
const calls: Array<{ method: string; url: string; body?: string }> = [];
|
|
177
|
+
const fetch = async (url: string, init: { method: string; headers: Record<string, string>; body?: Uint8Array | string }) => {
|
|
178
|
+
calls.push({ method: init.method, url, ...(typeof init.body === "string" ? { body: init.body } : {}) });
|
|
179
|
+
if (init.method === "POST" && url === "https://marketplace.test/_apis/public/gallery/extensionquery") {
|
|
180
|
+
const published = runs().some((r) => !process.env.FAKE_VSCE_FAIL && r.args[0] === "publish");
|
|
181
|
+
return reply(200, JSON.stringify({ results: [{ extensions: published ? [{ versions: [{ version: "1.2.0" }, { version: "1.1.0" }] }] : [] }] }));
|
|
182
|
+
}
|
|
183
|
+
return reply(404);
|
|
184
|
+
};
|
|
185
|
+
return { bin, runs, fetch, calls };
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
describe("editor marketplaces (#4676)", () => {
|
|
189
|
+
test("Open VSX: the stage checks the namespace and uploads nothing; the reveal publishes and checks what Open VSX serves against the file", async () => {
|
|
190
|
+
const { dir, bytes, digest } = member();
|
|
191
|
+
const ovsx = fakeOpenVsx("https://open-vsx.test", ["arugula"]);
|
|
192
|
+
const [target] = await createPublishTargets([PublishDeclarationSchema.parse({ type: "marketplace", marketplace: "openvsx", vsix: "dist/arugula.vsix", registry: "https://open-vsx.test" })], { fetch: ovsx.fetch });
|
|
193
|
+
const ctx = context(dir, { OVSX_PAT: "ovsx-token-1" }, [{ component: "editor", kind: "asset", path: "dist/arugula.vsix", digest }]);
|
|
194
|
+
const item = { name: "arugula.arugula-vscode@1.2.0", destination: "https://open-vsx.test/extension/arugula/arugula-vscode/1.2.0", digest };
|
|
195
|
+
expect(await target!.plan(ctx)).toEqual([item]);
|
|
196
|
+
|
|
197
|
+
const staged = await target!.stage(ctx);
|
|
198
|
+
expect(staged).toMatchObject({ items: [item], state: {} });
|
|
199
|
+
expect(ovsx.calls.map((c) => c.method)).toEqual(["GET", "GET"]);
|
|
200
|
+
expect(ovsx.versions.size).toBe(0);
|
|
201
|
+
|
|
202
|
+
expect(await target!.reveal(ctx, staged)).toMatchObject({ items: [item] });
|
|
203
|
+
expect(Buffer.from(ovsx.versions.get("arugula/arugula-vscode/1.2.0")!).equals(bytes)).toBe(true);
|
|
204
|
+
expect(ctx.lines.join("\n")).not.toContain("ovsx-token-1");
|
|
205
|
+
|
|
206
|
+
// Revealed: the version is there with the same bytes, so a stage finds it present and a reveal sends nothing.
|
|
207
|
+
const again = await target!.stage(ctx);
|
|
208
|
+
expect(again.state).toEqual({ present: "true" });
|
|
209
|
+
const n = ovsx.calls.length;
|
|
210
|
+
await target!.reveal(ctx, { ...staged });
|
|
211
|
+
expect(ovsx.calls.slice(n).some((c) => c.method === "POST")).toBe(false);
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
test("Open VSX: refuses a missing namespace and a version already there with other bytes, before anything is uploaded", async () => {
|
|
215
|
+
const { dir } = member();
|
|
216
|
+
const make = async (ovsx: ReturnType<typeof fakeOpenVsx>) =>
|
|
217
|
+
(await createPublishTargets([PublishDeclarationSchema.parse({ type: "marketplace", marketplace: "openvsx", vsix: "dist/arugula.vsix", registry: "https://open-vsx.test" })], { fetch: ovsx.fetch }))[0]!;
|
|
218
|
+
const ctx = context(dir, { OVSX_PAT: "ovsx-token-1" });
|
|
219
|
+
expect((await refused((await make(fakeOpenVsx("https://open-vsx.test", []))).stage(ctx))).code).toBe("publish-marketplace-no-namespace");
|
|
220
|
+
const other = fakeOpenVsx("https://open-vsx.test", ["arugula"], new Map([["arugula/arugula-vscode/1.2.0", new Uint8Array(Buffer.from("other"))]]));
|
|
221
|
+
expect((await refused((await make(other)).stage(ctx))).code).toBe("publish-marketplace-version-exists");
|
|
222
|
+
expect(other.calls.some((c) => c.method === "POST")).toBe(false);
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
test("VS Code Marketplace: the stage asks the gallery and runs nothing; the reveal runs vsce publish with the token in VSCE_PAT", async () => {
|
|
226
|
+
const { dir, digest } = 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", tokenEnv: "MARKETPLACE_PAT" })], {
|
|
229
|
+
fetch: vsce.fetch,
|
|
230
|
+
vsce: vsce.bin,
|
|
231
|
+
});
|
|
232
|
+
const ctx = context(dir, { MARKETPLACE_PAT: "vsce-pat-secret", PATH: process.env.PATH });
|
|
233
|
+
const staged = await target!.stage(ctx);
|
|
234
|
+
expect(staged.items).toEqual([{ name: "arugula.arugula-vscode@1.2.0", destination: "https://marketplace.test/items?itemName=arugula.arugula-vscode", digest }]);
|
|
235
|
+
expect(JSON.parse(vsce.calls[0]!.body!)).toMatchObject({ filters: [{ criteria: [{ filterType: 7, value: "arugula.arugula-vscode" }] }] });
|
|
236
|
+
expect(vsce.runs()).toEqual([]);
|
|
237
|
+
|
|
238
|
+
await target!.reveal(ctx, staged);
|
|
239
|
+
expect(vsce.runs()).toEqual([{ args: ["publish", "--packagePath", join(dir, "dist/arugula.vsix")], pat: "vsce-pat-secret" }]);
|
|
240
|
+
expect(ctx.lines.join("\n")).toContain("vsce: DONE Published arugula.arugula-vscode v1.2.0.");
|
|
241
|
+
expect(ctx.lines.join("\n")).not.toContain("vsce-pat-secret");
|
|
242
|
+
|
|
243
|
+
// Run again: the gallery lists the version, so nothing runs.
|
|
244
|
+
expect((await target!.stage(ctx)).state).toEqual({ present: "true" });
|
|
245
|
+
await target!.reveal(ctx, staged);
|
|
246
|
+
expect(vsce.runs()).toHaveLength(1);
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
test("VS Code Marketplace: a vsce failure is the target's, with vsce's message and no token", async () => {
|
|
250
|
+
const { dir } = member();
|
|
251
|
+
const vsce = fakeVsce(temp());
|
|
252
|
+
const [target] = await createPublishTargets([PublishDeclarationSchema.parse({ type: "marketplace", marketplace: "vscode", vsix: "dist/arugula.vsix", registry: "https://marketplace.test" })], { fetch: vsce.fetch, vsce: vsce.bin });
|
|
253
|
+
const ctx = context(dir, { VSCE_PAT: "vsce-pat-secret", FAKE_VSCE_FAIL: "1", PATH: process.env.PATH });
|
|
254
|
+
const err = await refused(target!.reveal(ctx, await target!.stage(ctx)));
|
|
255
|
+
expect(err.code).toBe("publish-marketplace-failed");
|
|
256
|
+
expect(err.message).toContain("Access Denied");
|
|
257
|
+
expect(err.message).not.toContain("vsce-pat-secret");
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
test("refuses a .vsix that is not the release's, one with no manifest, and a missing token", async () => {
|
|
261
|
+
const make = async () => (await createPublishTargets([PublishDeclarationSchema.parse({ type: "marketplace", marketplace: "openvsx", vsix: "dist/arugula.vsix" })], { fetch: fakeOpenVsx("x", []).fetch }))[0]!;
|
|
262
|
+
const { dir } = member();
|
|
263
|
+
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(
|
|
264
|
+
"publish-artifact-digest-mismatch",
|
|
265
|
+
);
|
|
266
|
+
expect((await refused((await make()).plan(context(member(JSON.stringify({ name: "x" })).dir, { OVSX_PAT: "t0ken" })))).code).toBe("publish-marketplace-vsix-invalid");
|
|
267
|
+
expect((await refused((await make()).plan(context(dir, {})))).code).toBe("publish-credentials-missing");
|
|
268
|
+
expect(() => PublishDeclarationSchema.parse({ type: "marketplace", marketplace: "eclipse", vsix: "x.vsix" })).toThrow();
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
test("reads stored and deflated zip entries", () => {
|
|
272
|
+
const z = zip({ a: "stored", "b/c.json": '{"x":1}' });
|
|
273
|
+
expect(readZipEntry(z, "a")!.toString()).toBe("stored");
|
|
274
|
+
expect(readZipEntry(z, "b/c.json")!.toString()).toBe('{"x":1}');
|
|
275
|
+
expect(readZipEntry(z, "missing")).toBeNull();
|
|
276
|
+
expect(() => readZipEntry(Buffer.from("not a zip at all, long enough to scan"), "a")).toThrow(/not a zip/);
|
|
277
|
+
});
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
describe("marketplaces with the run's identity, and a refusal as a warning (#4698)", () => {
|
|
281
|
+
const GHA = { GITHUB_ACTIONS: "true", ACTIONS_ID_TOKEN_REQUEST_URL: "https://token.actions.test/idtoken?api-version=2.0", ACTIONS_ID_TOKEN_REQUEST_TOKEN: "gha-request-token" };
|
|
282
|
+
|
|
283
|
+
test("VS Code Marketplace, azure-credential: the stage runs vsce verify-pat and the reveal vsce publish, both with --azure-credential and no VSCE_PAT", async () => {
|
|
284
|
+
const { dir } = member();
|
|
285
|
+
const vsce = fakeVsce(temp());
|
|
286
|
+
const [target] = await createPublishTargets([PublishDeclarationSchema.parse({ type: "marketplace", marketplace: "vscode", vsix: "dist/arugula.vsix", registry: "https://marketplace.test", auth: "azure-credential" })], {
|
|
287
|
+
fetch: vsce.fetch,
|
|
288
|
+
vsce: vsce.bin,
|
|
289
|
+
});
|
|
290
|
+
// A PAT left in the environment is not passed on: vsce prefers it to --azure-credential.
|
|
291
|
+
const ctx = context(dir, { VSCE_PAT: "stray-pat", PATH: process.env.PATH });
|
|
292
|
+
expect(target!.credentialEnv).toEqual(["AZURE_CLIENT_SECRET"]);
|
|
293
|
+
await target!.plan(ctx);
|
|
294
|
+
expect(vsce.runs()).toEqual([]);
|
|
295
|
+
|
|
296
|
+
const staged = await target!.stage(ctx);
|
|
297
|
+
expect(vsce.runs()).toEqual([{ args: ["verify-pat", "arugula", "--azure-credential"], pat: "" }]);
|
|
298
|
+
expect(staged.state).toEqual({});
|
|
299
|
+
|
|
300
|
+
await target!.reveal(ctx, staged);
|
|
301
|
+
expect(vsce.runs()[1]).toEqual({ args: ["publish", "--packagePath", join(dir, "dist/arugula.vsix"), "--azure-credential"], pat: "" });
|
|
302
|
+
expect(ctx.lines.join("\n")).not.toContain("using the token");
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
test("VS Code Marketplace, azure-credential: an identity vsce can't sign in with is refused at the stage, before anything reveals", async () => {
|
|
306
|
+
const { dir } = member();
|
|
307
|
+
const vsce = fakeVsce(temp());
|
|
308
|
+
const [target] = await createPublishTargets([PublishDeclarationSchema.parse({ type: "marketplace", marketplace: "vscode", vsix: "dist/arugula.vsix", registry: "https://marketplace.test", auth: "azure-credential" })], {
|
|
309
|
+
fetch: vsce.fetch,
|
|
310
|
+
vsce: vsce.bin,
|
|
311
|
+
});
|
|
312
|
+
const err = await refused(target!.stage(context(dir, { FAKE_VSCE_VERIFY_FAIL: "1", PATH: process.env.PATH })));
|
|
313
|
+
expect(err.code).toBe("publish-marketplace-azure-credential");
|
|
314
|
+
expect(err.message).toContain("Microsoft Entra");
|
|
315
|
+
expect(vsce.runs().map((r) => r.args[0])).toEqual(["verify-pat"]);
|
|
316
|
+
});
|
|
317
|
+
|
|
318
|
+
test("Open VSX, trusted-publishing: the stage exchanges the GitHub Actions ID token to check the registration, and the reveal exchanges again to upload", async () => {
|
|
319
|
+
const { dir, bytes } = member();
|
|
320
|
+
const ovsx = fakeOpenVsx("https://open-vsx.test", ["arugula"], new Map(), { trusted: ["arugula.arugula-vscode"] });
|
|
321
|
+
const [target] = await createPublishTargets([PublishDeclarationSchema.parse({ type: "marketplace", marketplace: "openvsx", vsix: "dist/arugula.vsix", registry: "https://open-vsx.test", auth: "trusted-publishing" })], { fetch: ovsx.fetch });
|
|
322
|
+
const ctx = context(dir, GHA);
|
|
323
|
+
expect(target!.credentialEnv).toEqual(["OVSX_ID_TOKEN"]);
|
|
324
|
+
await target!.plan(ctx);
|
|
325
|
+
expect(ovsx.calls).toEqual([]);
|
|
326
|
+
|
|
327
|
+
const staged = await target!.stage(ctx);
|
|
328
|
+
expect(ovsx.issued()).toBe(1);
|
|
329
|
+
const idRequest = ovsx.calls.find((c) => c.url.startsWith("https://token.actions.test/"))!;
|
|
330
|
+
expect(new URL(idRequest.url).searchParams.get("audience")).toBe("https://open-vsx.test");
|
|
331
|
+
expect(new URL(idRequest.url).searchParams.get("api-version")).toBe("2.0");
|
|
332
|
+
expect(JSON.parse(ovsx.calls.find((c) => c.url.endsWith("/trusted-publishing/token"))!.body!)).toEqual({ namespace: "arugula", extension: "arugula-vscode", token: "gha-id-token" });
|
|
333
|
+
expect(ovsx.versions.size).toBe(0);
|
|
334
|
+
|
|
335
|
+
await target!.reveal(ctx, staged);
|
|
336
|
+
expect(ovsx.issued()).toBe(2);
|
|
337
|
+
expect(Buffer.from(ovsx.versions.get("arugula/arugula-vscode/1.2.0")!).equals(bytes)).toBe(true);
|
|
338
|
+
expect(ovsx.calls.find((c) => c.url.includes("/api/-/publish"))!.url).toContain("token=tp-token-2");
|
|
339
|
+
const out = ctx.lines.join("\n");
|
|
340
|
+
for (const secret of ["gha-id-token", "tp-token-1", "tp-token-2", "gha-request-token"]) expect(out).not.toContain(secret);
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
test("Open VSX, trusted-publishing: reads an ID token from OVSX_ID_TOKEN outside GitHub Actions; refuses a run with none, and an extension with no trusted publisher", async () => {
|
|
344
|
+
const { dir } = member();
|
|
345
|
+
const make = async (ovsx: ReturnType<typeof fakeOpenVsx>) =>
|
|
346
|
+
(await createPublishTargets([PublishDeclarationSchema.parse({ type: "marketplace", marketplace: "openvsx", vsix: "dist/arugula.vsix", registry: "https://open-vsx.test", auth: "trusted-publishing" })], { fetch: ovsx.fetch }))[0]!;
|
|
347
|
+
const trusted = fakeOpenVsx("https://open-vsx.test", ["arugula"], new Map(), { trusted: ["arugula.arugula-vscode"] });
|
|
348
|
+
await (await make(trusted)).stage(context(dir, { OVSX_ID_TOKEN: "ovsx-id-token" }));
|
|
349
|
+
expect(trusted.issued()).toBe(1);
|
|
350
|
+
expect(trusted.calls.some((c) => c.url.startsWith("https://token.actions.test/"))).toBe(false);
|
|
351
|
+
|
|
352
|
+
const none = await refused((await make(trusted)).plan(context(dir, { OVSX_PAT: "a-pat-is-not-read" })));
|
|
353
|
+
expect(none.code).toBe("publish-credentials-missing");
|
|
354
|
+
expect(none.fix).toContain("id-token: write");
|
|
355
|
+
|
|
356
|
+
const unregistered = fakeOpenVsx("https://open-vsx.test", ["arugula"]);
|
|
357
|
+
const err = await refused((await make(unregistered)).stage(context(dir, GHA)));
|
|
358
|
+
expect(err.code).toBe("publish-marketplace-trusted-publishing");
|
|
359
|
+
expect(err.message).toContain("No trusted publisher matches");
|
|
360
|
+
expect(err.fix).toContain("https://open-vsx.test/user-settings/trusted-publishers");
|
|
361
|
+
expect(unregistered.calls.some((c) => c.url.includes("/api/-/publish"))).toBe(false);
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
test("an auth the marketplace does not take, or tokenEnv beside an identity, is refused when the targets are made", async () => {
|
|
365
|
+
const make = (d: Record<string, unknown>) => createPublishTargets([PublishDeclarationSchema.parse({ type: "marketplace", vsix: "x.vsix", ...d })]);
|
|
366
|
+
expect((await refused(make({ marketplace: "openvsx", auth: "azure-credential" }))).code).toBe("publish-marketplace-auth-invalid");
|
|
367
|
+
expect((await refused(make({ marketplace: "vscode", auth: "trusted-publishing" }))).code).toBe("publish-marketplace-auth-invalid");
|
|
368
|
+
expect((await refused(make({ marketplace: "vscode", auth: "azure-credential", tokenEnv: "VSCE_PAT" }))).code).toBe("publish-marketplace-auth-invalid");
|
|
369
|
+
expect(() => PublishDeclarationSchema.parse({ type: "marketplace", marketplace: "openvsx", vsix: "x.vsix", onRefusal: "ignore" })).toThrow();
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
test("onRefusal warn: an upload Open VSX refuses comes back refused with a warning; without it the reveal fails", async () => {
|
|
373
|
+
const { dir } = member();
|
|
374
|
+
const make = async (ovsx: ReturnType<typeof fakeOpenVsx>, onRefusal?: "warn") =>
|
|
375
|
+
(await createPublishTargets([PublishDeclarationSchema.parse({ type: "marketplace", marketplace: "openvsx", vsix: "dist/arugula.vsix", registry: "https://open-vsx.test", ...(onRefusal ? { onRefusal } : {}) })], { fetch: ovsx.fetch }))[0]!;
|
|
376
|
+
const ctx = context(dir, { OVSX_PAT: "ovsx-token-1" });
|
|
377
|
+
|
|
378
|
+
const strict = await make(fakeOpenVsx("https://open-vsx.test", ["arugula"], new Map(), { refuse: 406 }));
|
|
379
|
+
expect((await refused(strict.reveal(ctx, await strict.stage(ctx)))).code).toBe("publish-marketplace-failed");
|
|
380
|
+
|
|
381
|
+
const lenient = await make(fakeOpenVsx("https://open-vsx.test", ["arugula"], new Map(), { refuse: 406 }), "warn");
|
|
382
|
+
const out = await lenient.reveal(ctx, await lenient.stage(ctx));
|
|
383
|
+
expect(out.items).toEqual([expect.objectContaining({ name: "arugula.arugula-vscode@1.2.0", refused: true })]);
|
|
384
|
+
expect(out.warning).toContain("Open VSX refused arugula.arugula-vscode@1.2.0");
|
|
385
|
+
expect(out.warning).toContain("answered 406");
|
|
386
|
+
expect(out.warning).not.toContain("ovsx-token-1");
|
|
387
|
+
|
|
388
|
+
// The stage's checks still refuse under warn.
|
|
389
|
+
expect((await refused((await make(fakeOpenVsx("https://open-vsx.test", []), "warn")).stage(ctx))).code).toBe("publish-marketplace-no-namespace");
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
test("onRefusal warn: a vsce publish that fails comes back refused; vsce missing from PATH still fails", async () => {
|
|
393
|
+
const { dir } = member();
|
|
394
|
+
const vsce = fakeVsce(temp());
|
|
395
|
+
const decl = PublishDeclarationSchema.parse({ type: "marketplace", marketplace: "vscode", vsix: "dist/arugula.vsix", registry: "https://marketplace.test", onRefusal: "warn" });
|
|
396
|
+
const [target] = await createPublishTargets([decl], { fetch: vsce.fetch, vsce: vsce.bin });
|
|
397
|
+
const ctx = context(dir, { VSCE_PAT: "vsce-pat-secret", FAKE_VSCE_FAIL: "1", PATH: process.env.PATH });
|
|
398
|
+
const out = await target!.reveal(ctx, await target!.stage(ctx));
|
|
399
|
+
expect(out.items[0]!.refused).toBe(true);
|
|
400
|
+
expect(out.warning).toContain("Access Denied");
|
|
401
|
+
expect(out.warning).not.toContain("vsce-pat-secret");
|
|
402
|
+
|
|
403
|
+
const [missing] = await createPublishTargets([decl], { fetch: fakeVsce(temp()).fetch, vsce: join(temp(), "no-vsce") });
|
|
404
|
+
expect((await refused(missing!.reveal(ctx, await missing!.stage(ctx)))).code).toBe("publish-marketplace-vsce-missing");
|
|
405
|
+
});
|
|
406
|
+
});
|