mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-23 08:31:49 +00:00
feat(plugins): add validated data-only host color themes
This commit is contained in:
1 parent
ffabb9e9c7
commit
fdeeaf74bb
76 files changed
+2928
-90
No files matched your search
@@ -297,6 +297,7 @@ async function scanPackageDirectory(
|
||||
manifest.main.browser,
|
||||
manifest.main.node,
|
||||
...(manifest.contributes?.views ?? []).map(({ entry }) => entry),
|
||||
...(manifest.contributes?.themes ?? []).map(({ entry }) => entry),
|
||||
...(manifest.contributes?.commands ?? []).flatMap(({ icon }) => packageIconPaths(icon)),
|
||||
...(manifest.contributes?.menus ?? []).flatMap(({ icon }) => packageIconPaths(icon)),
|
||||
...(manifest.contributes?.views ?? []).flatMap(({ icon }) => packageIconPaths(icon)),
|
||||
@@ -754,6 +755,7 @@ async function inspectPluginPackage(
|
||||
manifest.main.browser,
|
||||
manifest.main.node,
|
||||
...(manifest.contributes?.views ?? []).map(({ entry }) => entry),
|
||||
...(manifest.contributes?.themes ?? []).map(({ entry }) => entry),
|
||||
...(manifest.contributes?.commands ?? []).flatMap(({ icon }) => packageIconPaths(icon)),
|
||||
...(manifest.contributes?.menus ?? []).flatMap(({ icon }) => packageIconPaths(icon)),
|
||||
...(manifest.contributes?.views ?? []).flatMap(({ icon }) => packageIconPaths(icon)),
|
||||
|
||||
@@ -310,6 +310,7 @@ function findDuplicateIds(manifest: PluginManifest): string[] {
|
||||
["settings", manifest.contributes?.settings],
|
||||
["commands", manifest.contributes?.commands],
|
||||
["views", manifest.contributes?.views],
|
||||
["themes", manifest.contributes?.themes],
|
||||
["providers", manifest.contributes?.providers],
|
||||
["companionExecutables", manifest.companionExecutables],
|
||||
] as const;
|
||||
@@ -336,6 +337,7 @@ function validateOwnedContributionIds(manifest: PluginManifest): string[] {
|
||||
["setting", manifest.contributes?.settings],
|
||||
["command", manifest.contributes?.commands],
|
||||
["view", manifest.contributes?.views],
|
||||
["theme", manifest.contributes?.themes],
|
||||
["provider", manifest.contributes?.providers],
|
||||
["companion executable", manifest.companionExecutables],
|
||||
] as const;
|
||||
@@ -367,6 +369,8 @@ function validateSemantics(manifest: PluginManifest): string[] {
|
||||
}
|
||||
|
||||
const requiredFeatures = new Set(manifest.features?.required ?? []);
|
||||
if ((manifest.main.data || manifest.contributes?.themes?.length) && !requiredFeatures.has('appearance.theme-packs')) errors.push('Theme packs require appearance.theme-packs');
|
||||
for (const theme of manifest.contributes?.themes ?? []) if (!theme.entry.endsWith('.json')) errors.push('Theme palette entry must be JSON');
|
||||
if (manifest.contributes?.views?.some((view) => view.location === 'terminal-sidebar')
|
||||
&& !requiredFeatures.has('views.terminal-sidebar')) errors.push('Terminal sidebar pages require views.terminal-sidebar');
|
||||
if (manifest.contributes?.views?.some((view) => view.location === 'vault-page')
|
||||
@@ -691,6 +695,7 @@ function validateSemantics(manifest: PluginManifest): string[] {
|
||||
manifest.main.browser,
|
||||
manifest.main.node,
|
||||
...(manifest.contributes?.views ?? []).map(({ entry }) => entry),
|
||||
...(manifest.contributes?.themes ?? []).map(({ entry }) => entry),
|
||||
...(manifest.contributes?.commands ?? []).flatMap(({ icon }) => packageIconPaths(icon)),
|
||||
...(manifest.contributes?.menus ?? []).flatMap(({ icon }) => packageIconPaths(icon)),
|
||||
...(manifest.contributes?.views ?? []).flatMap(({ icon }) => packageIconPaths(icon)),
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { readFile } from "node:fs/promises";
|
||||
import test from "node:test";
|
||||
import { validateManifestValue } from "./manifest.js";
|
||||
import { checkPluginCompatibility } from "./compatibility.js";
|
||||
const manifest = JSON.parse(
|
||||
await readFile(
|
||||
new URL(
|
||||
"../../../examples/plugins/forest-theme-pack/netcatty.plugin.json",
|
||||
import.meta.url,
|
||||
),
|
||||
"utf8",
|
||||
),
|
||||
);
|
||||
test("static theme admission requires explicit feature, namespaces, JSON entries and no executable or permission mixture", () => {
|
||||
assert.equal(validateManifestValue(manifest).valid, true);
|
||||
assert.equal(
|
||||
checkPluginCompatibility(manifest, {
|
||||
netcattyVersion: "1.0.0",
|
||||
apiVersion: "0.1.0-internal.1",
|
||||
features: [],
|
||||
}).compatible,
|
||||
false,
|
||||
);
|
||||
for (const change of [
|
||||
{ main: { data: "theme", browser: "index.js" } },
|
||||
{ permissions: { required: ["network"] } },
|
||||
{ activationEvents: ["onStartupFinished"] },
|
||||
{
|
||||
contributes: {
|
||||
...manifest.contributes,
|
||||
commands: [{ id: manifest.id + ".run", title: "Run" }],
|
||||
},
|
||||
},
|
||||
{ features: { required: [] } },
|
||||
{
|
||||
contributes: {
|
||||
themes: [
|
||||
{ ...manifest.contributes.themes[0], id: "another.plugin.theme" },
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
contributes: {
|
||||
themes: [{ ...manifest.contributes.themes[0], entry: "theme.css" }],
|
||||
},
|
||||
},
|
||||
])
|
||||
assert.equal(
|
||||
validateManifestValue({ ...manifest, ...change }).valid,
|
||||
false,
|
||||
JSON.stringify(change),
|
||||
);
|
||||
});
|
||||
Reference in new issue
Block a user