mirror of
https://github.com/github/awesome-copilot.git
synced 2026-08-21 00:16:53 +00:00
chore: publish from main
This commit is contained in:
@@ -2,11 +2,11 @@
|
||||
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import { fileURLToPath } from "url";
|
||||
import { ROOT_FOLDER } from "./constants.mjs";
|
||||
import { readExternalPlugins } from "./external-plugin-validation.mjs";
|
||||
|
||||
const PLUGINS_DIR = path.join(ROOT_FOLDER, "plugins");
|
||||
const EXTENSIONS_DIR = path.join(ROOT_FOLDER, "extensions");
|
||||
const MARKETPLACE_FILE = path.join(ROOT_FOLDER, ".github/plugin", "marketplace.json");
|
||||
|
||||
/**
|
||||
@@ -15,7 +15,7 @@ const MARKETPLACE_FILE = path.join(ROOT_FOLDER, ".github/plugin", "marketplace.j
|
||||
* @returns {object|null} - Plugin metadata or null if not found
|
||||
*/
|
||||
function readPluginMetadata(pluginDir) {
|
||||
const pluginJsonPath = path.join(pluginDir, ".github/plugin", "plugin.json");
|
||||
const pluginJsonPath = path.join(pluginDir, "plugin.json");
|
||||
|
||||
if (!fs.existsSync(pluginJsonPath)) {
|
||||
console.warn(`Warning: No plugin.json found for ${path.basename(pluginDir)}`);
|
||||
@@ -62,35 +62,18 @@ function collectLocalPluginsFromRoot(rootDir, sourcePrefix, includeEntry = () =>
|
||||
return plugins;
|
||||
}
|
||||
|
||||
function hasExtensionEntryPoint(extensionDir, extensionName) {
|
||||
const candidateEntryPoints = [
|
||||
path.join(extensionDir, "extension.mjs"),
|
||||
path.join(extensionDir, "extensions", "extension.mjs"),
|
||||
path.join(extensionDir, "extensions", extensionName, "extension.mjs"),
|
||||
];
|
||||
|
||||
return candidateEntryPoints.some((entryPointPath) => fs.existsSync(entryPointPath));
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate marketplace.json from plugin directories
|
||||
*/
|
||||
function generateMarketplace() {
|
||||
export function generateMarketplace() {
|
||||
console.log("Generating marketplace.json...");
|
||||
|
||||
if (!fs.existsSync(PLUGINS_DIR) && !fs.existsSync(EXTENSIONS_DIR)) {
|
||||
console.error(`Error: Neither plugins directory (${PLUGINS_DIR}) nor extensions directory (${EXTENSIONS_DIR}) was found`);
|
||||
if (!fs.existsSync(PLUGINS_DIR)) {
|
||||
console.error(`Error: Plugins directory (${PLUGINS_DIR}) was not found`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const plugins = [
|
||||
...collectLocalPluginsFromRoot(PLUGINS_DIR, "plugins"),
|
||||
...collectLocalPluginsFromRoot(
|
||||
EXTENSIONS_DIR,
|
||||
"extensions",
|
||||
(entryName) => hasExtensionEntryPoint(path.join(EXTENSIONS_DIR, entryName), entryName)
|
||||
)
|
||||
];
|
||||
const plugins = collectLocalPluginsFromRoot(PLUGINS_DIR, "plugins");
|
||||
|
||||
console.log(`Found ${plugins.length} local plugin manifests`);
|
||||
|
||||
@@ -144,5 +127,6 @@ function generateMarketplace() {
|
||||
console.log(` Location: ${MARKETPLACE_FILE}`);
|
||||
}
|
||||
|
||||
// Run the script
|
||||
generateMarketplace();
|
||||
if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
||||
generateMarketplace();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user