mirror of
https://github.com/morluto/rea.git
synced 2026-12-03 21:46:01 +00:00
test(vsix): share main manifest fixtures (#16285)
This commit is contained in:
1 parent
bfe2c7cf0c
commit
8375d83dc2
1 file changed
+34
-175
@@ -790,6 +790,15 @@ it("refuses a vsixmanifest with more XML nodes than its tree allowance", async (
|
||||
});
|
||||
});
|
||||
|
||||
const packageJsonWithMain = (main: string): string =>
|
||||
JSON.stringify({
|
||||
name: "hello",
|
||||
publisher: "demo",
|
||||
version: "1.2.3",
|
||||
engines: { vscode: "^1.74.0" },
|
||||
main,
|
||||
});
|
||||
|
||||
/** A package.json whose unused `padding` array alone fills the value allowance. */
|
||||
const manyValuesPackageJson = (main: string): string =>
|
||||
`{"name":"hello","publisher":"demo","version":"1.2.3","engines":{"vscode":"^1.74.0"},"main":${JSON.stringify(main)},"padding":[${"0,".repeat(MAX_INSPECT_VSIX_PACKAGE_MANIFEST_JSON_VALUES)}0]}`;
|
||||
@@ -876,13 +885,7 @@ it("reports a deep vsixmanifest as the XML element-depth ceiling", async () => {
|
||||
|
||||
it("does not parse or use index files when the directory package.json exceeds the value allowance", async () => {
|
||||
const bytes = await vsixPackageFixture({
|
||||
packageJson: JSON.stringify({
|
||||
name: "hello",
|
||||
publisher: "demo",
|
||||
version: "1.2.3",
|
||||
engines: { vscode: "^1.74.0" },
|
||||
main: "./out",
|
||||
}),
|
||||
packageJson: packageJsonWithMain("./out"),
|
||||
extraMembers: {
|
||||
"extension/out/package.json": manyValuesPackageJson("./start.js"),
|
||||
"extension/out/start.js": "exports.activate = () => {};",
|
||||
@@ -1356,13 +1359,7 @@ it("resolves an extension-less CommonJS main the way Node does", async () => {
|
||||
|
||||
it("resolves a directory main through that directory's package.json", async () => {
|
||||
const bytes = await vsixPackageFixture({
|
||||
packageJson: JSON.stringify({
|
||||
name: "hello",
|
||||
publisher: "demo",
|
||||
version: "1.2.3",
|
||||
engines: { vscode: "^1.74.0" },
|
||||
main: "./out",
|
||||
}),
|
||||
packageJson: packageJsonWithMain("./out"),
|
||||
extraMembers: {
|
||||
"extension/out/package.json": JSON.stringify({ main: "./start.js" }),
|
||||
"extension/out/start.js": "exports.activate = () => {};",
|
||||
@@ -1380,13 +1377,7 @@ it("resolves a directory main through that directory's package.json", async () =
|
||||
|
||||
it("falls back to the directory index when its package.json main is missing", async () => {
|
||||
const bytes = await vsixPackageFixture({
|
||||
packageJson: JSON.stringify({
|
||||
name: "hello",
|
||||
publisher: "demo",
|
||||
version: "1.2.3",
|
||||
engines: { vscode: "^1.74.0" },
|
||||
main: "./out",
|
||||
}),
|
||||
packageJson: packageJsonWithMain("./out"),
|
||||
extraMembers: {
|
||||
"extension/out/package.json": JSON.stringify({ main: "./gone.js" }),
|
||||
"extension/out/index.js": "exports.activate = () => {};",
|
||||
@@ -1408,13 +1399,7 @@ it.each([
|
||||
"treats an absolute directory package.json main (%s) as outside the package",
|
||||
async (nestedMain, path, present) => {
|
||||
const bytes = await vsixPackageFixture({
|
||||
packageJson: JSON.stringify({
|
||||
name: "hello",
|
||||
publisher: "demo",
|
||||
version: "1.2.3",
|
||||
engines: { vscode: "^1.74.0" },
|
||||
main: "./out",
|
||||
}),
|
||||
packageJson: packageJsonWithMain("./out"),
|
||||
extraMembers: {
|
||||
"extension/out/package.json": JSON.stringify({ main: nestedMain }),
|
||||
"extension/out/missing/start.js": "exports.activate = () => {};",
|
||||
@@ -1436,13 +1421,7 @@ it.each([
|
||||
"keeps a directory package.json main (%s) inside the extension root",
|
||||
async (nestedMain, path, present) => {
|
||||
const bytes = await vsixPackageFixture({
|
||||
packageJson: JSON.stringify({
|
||||
name: "hello",
|
||||
publisher: "demo",
|
||||
version: "1.2.3",
|
||||
engines: { vscode: "^1.74.0" },
|
||||
main: "./out",
|
||||
}),
|
||||
packageJson: packageJsonWithMain("./out"),
|
||||
extraMembers: {
|
||||
"extension/out/package.json": JSON.stringify({ main: nestedMain }),
|
||||
"outside.js": "exports.activate = () => {};",
|
||||
@@ -1459,13 +1438,7 @@ it.each([
|
||||
|
||||
it("keeps a directory package.json main targeting the extension root from matching archive-root files", async () => {
|
||||
const withIndex = await vsixPackageFixture({
|
||||
packageJson: JSON.stringify({
|
||||
name: "hello",
|
||||
publisher: "demo",
|
||||
version: "1.2.3",
|
||||
engines: { vscode: "^1.74.0" },
|
||||
main: "./out",
|
||||
}),
|
||||
packageJson: packageJsonWithMain("./out"),
|
||||
extraMembers: {
|
||||
"extension/out/package.json": JSON.stringify({ main: ".." }),
|
||||
"extension.js": "exports.activate = () => {};",
|
||||
@@ -1481,13 +1454,7 @@ it("keeps a directory package.json main targeting the extension root from matchi
|
||||
});
|
||||
|
||||
const withoutIndex = await vsixPackageFixture({
|
||||
packageJson: JSON.stringify({
|
||||
name: "hello",
|
||||
publisher: "demo",
|
||||
version: "1.2.3",
|
||||
engines: { vscode: "^1.74.0" },
|
||||
main: "./out",
|
||||
}),
|
||||
packageJson: packageJsonWithMain("./out"),
|
||||
extraMembers: {
|
||||
"extension/out/package.json": JSON.stringify({ main: ".." }),
|
||||
"extension.js": "exports.activate = () => {};",
|
||||
@@ -1504,13 +1471,7 @@ it("keeps a directory package.json main targeting the extension root from matchi
|
||||
|
||||
it("reports an absolute directory package.json main absent without an index", async () => {
|
||||
const bytes = await vsixPackageFixture({
|
||||
packageJson: JSON.stringify({
|
||||
name: "hello",
|
||||
publisher: "demo",
|
||||
version: "1.2.3",
|
||||
engines: { vscode: "^1.74.0" },
|
||||
main: "./out",
|
||||
}),
|
||||
packageJson: packageJsonWithMain("./out"),
|
||||
extraMembers: {
|
||||
"extension/out/package.json": JSON.stringify({
|
||||
main: "/missing/start.js",
|
||||
@@ -1531,13 +1492,7 @@ it.each(["{not json", "[]", "null"])(
|
||||
"reports a malformed directory package.json instead of using its index (%s)",
|
||||
async (manifest) => {
|
||||
const bytes = await vsixPackageFixture({
|
||||
packageJson: JSON.stringify({
|
||||
name: "hello",
|
||||
publisher: "demo",
|
||||
version: "1.2.3",
|
||||
engines: { vscode: "^1.74.0" },
|
||||
main: "./out",
|
||||
}),
|
||||
packageJson: packageJsonWithMain("./out"),
|
||||
extraMembers: {
|
||||
"extension/out/package.json": manifest,
|
||||
"extension/out/index.js": "exports.activate = () => {};",
|
||||
@@ -1586,13 +1541,7 @@ it.each([
|
||||
"reports a %s directory package.json malformed as Node does",
|
||||
async (_encoding, manifest) => {
|
||||
const bytes = await vsixPackageFixture({
|
||||
packageJson: JSON.stringify({
|
||||
name: "hello",
|
||||
publisher: "demo",
|
||||
version: "1.2.3",
|
||||
engines: { vscode: "^1.74.0" },
|
||||
main: "./out",
|
||||
}),
|
||||
packageJson: packageJsonWithMain("./out"),
|
||||
extraMembers: {
|
||||
"extension/out/start.js": "exports.activate = () => {};",
|
||||
"extension/out/index.js": "exports.activate = () => {};",
|
||||
@@ -1616,13 +1565,7 @@ it.each([
|
||||
|
||||
it("reads a UTF-8 BOM directory package.json main as Node does", async () => {
|
||||
const bytes = await vsixPackageFixture({
|
||||
packageJson: JSON.stringify({
|
||||
name: "hello",
|
||||
publisher: "demo",
|
||||
version: "1.2.3",
|
||||
engines: { vscode: "^1.74.0" },
|
||||
main: "./out",
|
||||
}),
|
||||
packageJson: packageJsonWithMain("./out"),
|
||||
extraMembers: {
|
||||
"extension/out/start.js": "exports.activate = () => {};",
|
||||
},
|
||||
@@ -1645,13 +1588,7 @@ it("reads a UTF-8 BOM directory package.json main as Node does", async () => {
|
||||
});
|
||||
|
||||
it("does not use index files when the directory package.json is duplicated", async () => {
|
||||
const packageJson = JSON.stringify({
|
||||
name: "hello",
|
||||
publisher: "demo",
|
||||
version: "1.2.3",
|
||||
engines: { vscode: "^1.74.0" },
|
||||
main: "./out",
|
||||
});
|
||||
const packageJson = packageJsonWithMain("./out");
|
||||
const directoryManifest = JSON.stringify({ main: "./start.js" });
|
||||
const bytes = await vsixPackageFixture({
|
||||
packageJson,
|
||||
@@ -1677,13 +1614,7 @@ it("does not use index files when the directory package.json is duplicated", asy
|
||||
});
|
||||
|
||||
it("does not use index files when the directory package.json exceeds the manifest budget", async () => {
|
||||
const packageJson = JSON.stringify({
|
||||
name: "hello",
|
||||
publisher: "demo",
|
||||
version: "1.2.3",
|
||||
engines: { vscode: "^1.74.0" },
|
||||
main: "./out",
|
||||
});
|
||||
const packageJson = packageJsonWithMain("./out");
|
||||
const directoryManifest = JSON.stringify({
|
||||
main: "./start.js",
|
||||
padding: "x".repeat(packageJson.length + defaultVsixManifest.length),
|
||||
@@ -1722,13 +1653,7 @@ it("does not use index files when the directory package.json exceeds the manifes
|
||||
it("treats a trailing-slash main as directory-only and skips a sibling file", async () => {
|
||||
const bytes = await vsixPackageFixture({
|
||||
includeMain: false,
|
||||
packageJson: JSON.stringify({
|
||||
name: "hello",
|
||||
publisher: "demo",
|
||||
version: "1.2.3",
|
||||
engines: { vscode: "^1.74.0" },
|
||||
main: "./out/",
|
||||
}),
|
||||
packageJson: packageJsonWithMain("./out/"),
|
||||
extraMembers: {
|
||||
"extension/out.js": "exports.activate = () => {};",
|
||||
},
|
||||
@@ -1745,13 +1670,7 @@ it("treats a trailing-slash main as directory-only and skips a sibling file", as
|
||||
it("resolves a trailing-slash main to the directory index over a sibling file", async () => {
|
||||
const bytes = await vsixPackageFixture({
|
||||
includeMain: false,
|
||||
packageJson: JSON.stringify({
|
||||
name: "hello",
|
||||
publisher: "demo",
|
||||
version: "1.2.3",
|
||||
engines: { vscode: "^1.74.0" },
|
||||
main: "./out/",
|
||||
}),
|
||||
packageJson: packageJsonWithMain("./out/"),
|
||||
extraMembers: {
|
||||
"extension/out.js": "exports.activate = () => {};",
|
||||
"extension/out/index.js": "exports.activate = () => {};",
|
||||
@@ -1769,13 +1688,7 @@ it("resolves a trailing-slash main to the directory index over a sibling file",
|
||||
it("resolves a trailing-slash main through the directory package.json", async () => {
|
||||
const bytes = await vsixPackageFixture({
|
||||
includeMain: false,
|
||||
packageJson: JSON.stringify({
|
||||
name: "hello",
|
||||
publisher: "demo",
|
||||
version: "1.2.3",
|
||||
engines: { vscode: "^1.74.0" },
|
||||
main: "./out/",
|
||||
}),
|
||||
packageJson: packageJsonWithMain("./out/"),
|
||||
extraMembers: {
|
||||
"extension/out.js": "exports.activate = () => {};",
|
||||
"extension/out/package.json": JSON.stringify({ main: "./start.js" }),
|
||||
@@ -1795,13 +1708,7 @@ it("resolves a trailing-slash main through the directory package.json", async ()
|
||||
it("looks up a main with trailing whitespace by its literal name", async () => {
|
||||
const bytes = await vsixPackageFixture({
|
||||
includeMain: false,
|
||||
packageJson: JSON.stringify({
|
||||
name: "hello",
|
||||
publisher: "demo",
|
||||
version: "1.2.3",
|
||||
engines: { vscode: "^1.74.0" },
|
||||
main: "./out/start.js ",
|
||||
}),
|
||||
packageJson: packageJsonWithMain("./out/start.js "),
|
||||
extraMembers: {
|
||||
"extension/out/start.js": "exports.activate = () => {};",
|
||||
"extension/out/start.js ": "exports.activate = () => {};",
|
||||
@@ -1819,13 +1726,7 @@ it("looks up a main with trailing whitespace by its literal name", async () => {
|
||||
it("does not trim whitespace from a directory package.json main", async () => {
|
||||
const bytes = await vsixPackageFixture({
|
||||
includeMain: false,
|
||||
packageJson: JSON.stringify({
|
||||
name: "hello",
|
||||
publisher: "demo",
|
||||
version: "1.2.3",
|
||||
engines: { vscode: "^1.74.0" },
|
||||
main: "./out/",
|
||||
}),
|
||||
packageJson: packageJsonWithMain("./out/"),
|
||||
extraMembers: {
|
||||
"extension/out/package.json": JSON.stringify({ main: " start.js" }),
|
||||
"extension/out/start.js": "exports.activate = () => {};",
|
||||
@@ -1844,13 +1745,7 @@ it("does not trim whitespace from a directory package.json main", async () => {
|
||||
it("keeps a main whose trailing separator is followed by whitespace a file path", async () => {
|
||||
const bytes = await vsixPackageFixture({
|
||||
includeMain: false,
|
||||
packageJson: JSON.stringify({
|
||||
name: "hello",
|
||||
publisher: "demo",
|
||||
version: "1.2.3",
|
||||
engines: { vscode: "^1.74.0" },
|
||||
main: "./out/ ",
|
||||
}),
|
||||
packageJson: packageJsonWithMain("./out/ "),
|
||||
extraMembers: {
|
||||
"extension/out/ .js": "exports.activate = () => {};",
|
||||
"extension/out/index.js": "exports.activate = () => {};",
|
||||
@@ -1870,13 +1765,7 @@ it.each(["./out/.", "./out/sub/.."])(
|
||||
async (main) => {
|
||||
const bytes = await vsixPackageFixture({
|
||||
includeMain: false,
|
||||
packageJson: JSON.stringify({
|
||||
name: "hello",
|
||||
publisher: "demo",
|
||||
version: "1.2.3",
|
||||
engines: { vscode: "^1.74.0" },
|
||||
main,
|
||||
}),
|
||||
packageJson: packageJsonWithMain(main),
|
||||
extraMembers: {
|
||||
"extension/out.js": "exports.activate = () => {};",
|
||||
"extension/out/index.js": "exports.activate = () => {};",
|
||||
@@ -1897,13 +1786,7 @@ it.each([".", "./", "./out/.."])(
|
||||
async (main) => {
|
||||
const bytes = await vsixPackageFixture({
|
||||
includeMain: false,
|
||||
packageJson: JSON.stringify({
|
||||
name: "hello",
|
||||
publisher: "demo",
|
||||
version: "1.2.3",
|
||||
engines: { vscode: "^1.74.0" },
|
||||
main,
|
||||
}),
|
||||
packageJson: packageJsonWithMain(main),
|
||||
extraMembers: {
|
||||
"extension/index.js": "exports.activate = () => {};",
|
||||
},
|
||||
@@ -1953,13 +1836,7 @@ it("matches entry points by exact member case, reporting a case-only match", asy
|
||||
|
||||
it("does not blame case when a malformed directory package.json stops main", async () => {
|
||||
const bytes = await vsixPackageFixture({
|
||||
packageJson: JSON.stringify({
|
||||
name: "hello",
|
||||
publisher: "demo",
|
||||
version: "1.2.3",
|
||||
engines: { vscode: "^1.74.0" },
|
||||
main: "./out",
|
||||
}),
|
||||
packageJson: packageJsonWithMain("./out"),
|
||||
includeMain: false,
|
||||
extraMembers: {
|
||||
"extension/out/package.json": "[",
|
||||
@@ -2029,13 +1906,7 @@ it("keeps backslashes literal in package.json entry points instead of matching s
|
||||
it("does not treat a trailing backslash in main as a POSIX directory marker", async () => {
|
||||
const bytes = await vsixPackageFixture({
|
||||
includeMain: false,
|
||||
packageJson: JSON.stringify({
|
||||
name: "hello",
|
||||
publisher: "demo",
|
||||
version: "1.2.3",
|
||||
engines: { vscode: "^1.74.0" },
|
||||
main: "./out\\",
|
||||
}),
|
||||
packageJson: packageJsonWithMain("./out\\"),
|
||||
extraMembers: {
|
||||
"extension/out.js": "exports.activate = () => {};",
|
||||
"extension/out/index.js": "exports.activate = () => {};",
|
||||
@@ -2056,13 +1927,7 @@ it("does not treat a trailing backslash in main as a POSIX directory marker", as
|
||||
it("keeps backslashes literal in a directory main's nested package.json", async () => {
|
||||
const bytes = await vsixPackageFixture({
|
||||
includeMain: false,
|
||||
packageJson: JSON.stringify({
|
||||
name: "hello",
|
||||
publisher: "demo",
|
||||
version: "1.2.3",
|
||||
engines: { vscode: "^1.74.0" },
|
||||
main: "./out",
|
||||
}),
|
||||
packageJson: packageJsonWithMain("./out"),
|
||||
extraMembers: {
|
||||
"extension/out/package.json": JSON.stringify({
|
||||
main: "./sub\\start.js",
|
||||
@@ -2111,13 +1976,7 @@ it("still resolves slash-separated and extensionless entry points, including bac
|
||||
|
||||
const nestedSlash = await vsixPackageFixture({
|
||||
includeMain: false,
|
||||
packageJson: JSON.stringify({
|
||||
name: "hello",
|
||||
publisher: "demo",
|
||||
version: "1.2.3",
|
||||
engines: { vscode: "^1.74.0" },
|
||||
main: "./out",
|
||||
}),
|
||||
packageJson: packageJsonWithMain("./out"),
|
||||
extraMembers: {
|
||||
"extension/out/package.json": JSON.stringify({ main: "./sub/start" }),
|
||||
"extension/out/sub/start.js": "exports.activate = () => {};",
|
||||
|
||||
Reference in new issue
Block a user