Skip to content

Commit 3af8869

Browse files
priyanshu92Copilot
andcommitted
enforce plugin manifest metadata
- Validate that plugin.json keeps version, description, author, homepage, repository, license, and keywords after marketplace entries were minimized. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent ccb3b87 commit 3af8869

1 file changed

Lines changed: 25 additions & 1 deletion

File tree

scripts/validate-legacy-compatibility.js

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,30 @@ function assertMinimalMarketplace(marketplace) {
6666
assert.ok(marketplace.plugins.length > 0, 'plugins must contain at least one entry');
6767
}
6868

69+
function assertPluginMetadata(pluginName, manifest) {
70+
// Marketplace plugin entries intentionally omit these optional override fields.
71+
// Keep them in each plugin manifest instead so `plugin.json` remains the single
72+
// source of truth for display/update metadata.
73+
assert.equal(manifest.name, pluginName);
74+
assert.match(manifest.version, /^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/, 'version must be semantic');
75+
assert.equal(typeof manifest.description, 'string', 'description must be a string');
76+
assert.notEqual(manifest.description.trim(), '', 'description must not be empty');
77+
assert.equal(typeof manifest.author?.name, 'string', 'author.name must be a string');
78+
assert.notEqual(manifest.author.name.trim(), '', 'author.name must not be empty');
79+
assert.equal(typeof manifest.homepage, 'string', 'homepage must be a string');
80+
assert.notEqual(manifest.homepage.trim(), '', 'homepage must not be empty');
81+
assert.equal(typeof manifest.repository, 'string', 'repository must be a string');
82+
assert.notEqual(manifest.repository.trim(), '', 'repository must not be empty');
83+
assert.equal(typeof manifest.license, 'string', 'license must be a string');
84+
assert.notEqual(manifest.license.trim(), '', 'license must not be empty');
85+
assert.ok(Array.isArray(manifest.keywords), 'keywords must be an array');
86+
assert.ok(manifest.keywords.length > 0, 'keywords must contain at least one entry');
87+
for (const [index, keyword] of manifest.keywords.entries()) {
88+
assert.equal(typeof keyword, 'string', `keywords[${index}] must be a string`);
89+
assert.notEqual(keyword.trim(), '', `keywords[${index}] must not be empty`);
90+
}
91+
}
92+
6993
const errors = [];
7094

7195
function check(label, fn) {
@@ -113,7 +137,7 @@ if (errors.length === 0) {
113137

114138
check(`${plugin.name} plugin manifest`, () => {
115139
const pluginManifest = readJson(openManifestPath);
116-
assert.equal(plugin.name, pluginManifest.name);
140+
assertPluginMetadata(plugin.name, pluginManifest);
117141
});
118142

119143
check(relativeLegacyManifestPath, () => {

0 commit comments

Comments
 (0)