chore: publish from main

This commit is contained in:
github-actions[bot]
2026-07-18 00:50:03 +00:00
parent 941c2a4b41
commit 7174a12f1c
514 changed files with 222 additions and 50538 deletions
+76 -3
View File
@@ -28,6 +28,41 @@ const MATERIALIZED_SPECS = {
},
};
function copyDirRecursive(src, dest) {
fs.mkdirSync(dest, { recursive: true });
for (const entry of fs.readdirSync(src, { withFileTypes: true })) {
const srcPath = path.join(src, entry.name);
const destPath = path.join(dest, entry.name);
if (entry.isDirectory()) {
copyDirRecursive(srcPath, destPath);
} else {
fs.copyFileSync(srcPath, destPath);
}
}
}
function moveEntry(srcPath, destPath) {
fs.mkdirSync(path.dirname(destPath), { recursive: true });
try {
fs.renameSync(srcPath, destPath);
return;
} catch (error) {
if (!["EXDEV", "EEXIST", "ENOTEMPTY", "EPERM"].includes(error?.code)) {
throw error;
}
}
const stats = fs.statSync(srcPath);
if (stats.isDirectory()) {
copyDirRecursive(srcPath, destPath);
fs.rmSync(srcPath, { recursive: true, force: true });
return;
}
fs.copyFileSync(srcPath, destPath);
fs.rmSync(srcPath, { force: true });
}
export function restoreManifestFromMaterializedFiles(pluginPath) {
const pluginJsonPath = path.join(pluginPath, ".github/plugin", "plugin.json");
if (!fs.existsSync(pluginJsonPath)) {
@@ -90,15 +125,22 @@ function cleanPlugin(pluginPath) {
return { removed, manifestUpdated };
}
function cleanMaterializedExtensionPlugin(extensionPath) {
export function cleanMaterializedExtensionPlugin(extensionPath) {
const pluginJsonPath = path.join(extensionPath, ".github", "plugin", "plugin.json");
let manifestUpdated = false;
if (fs.existsSync(pluginJsonPath)) {
const plugin = JSON.parse(fs.readFileSync(pluginJsonPath, "utf8"));
const extensionBundlePrefix = `extensions/${path.basename(extensionPath)}/`;
if (plugin.extensions === "extensions") {
plugin.extensions = ".";
fs.writeFileSync(pluginJsonPath, JSON.stringify(plugin, null, 2) + "\n", "utf8");
manifestUpdated = true;
}
if (typeof plugin.logo === "string" && plugin.logo.startsWith(extensionBundlePrefix)) {
plugin.logo = plugin.logo.slice(extensionBundlePrefix.length);
manifestUpdated = true;
}
if (manifestUpdated) {
fs.writeFileSync(pluginJsonPath, JSON.stringify(plugin, null, 2) + "\n", "utf8");
console.log(` Updated ${path.basename(extensionPath)}/.github/plugin/plugin.json`);
}
}
@@ -108,12 +150,43 @@ function cleanMaterializedExtensionPlugin(extensionPath) {
return { removed: 0, manifestUpdated };
}
const bundleRoot = path.join(target, path.basename(extensionPath));
const count = countFiles(target);
if (fs.existsSync(bundleRoot) && fs.statSync(bundleRoot).isDirectory()) {
for (const entry of fs.readdirSync(bundleRoot, { withFileTypes: true })) {
moveEntry(path.join(bundleRoot, entry.name), path.join(extensionPath, entry.name));
}
console.log(` Restored ${path.basename(extensionPath)}/ from materialized extensions bundle`);
}
fs.rmSync(target, { recursive: true, force: true });
console.log(` Removed ${path.basename(extensionPath)}/extensions/ (${count} files)`);
return { removed: count, manifestUpdated };
}
function isExtensionPluginDirectory(extensionPath) {
if (fs.existsSync(path.join(extensionPath, "extension.mjs"))) {
return true;
}
const bundleEntry = path.join(extensionPath, "extensions", path.basename(extensionPath), "extension.mjs");
if (fs.existsSync(bundleEntry)) {
return true;
}
const pluginJsonPath = path.join(extensionPath, ".github", "plugin", "plugin.json");
if (!fs.existsSync(pluginJsonPath)) {
return false;
}
try {
const plugin = JSON.parse(fs.readFileSync(pluginJsonPath, "utf8"));
return plugin.extensions === "extensions";
} catch {
return false;
}
}
function countFiles(dir) {
let count = 0;
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
@@ -204,7 +277,7 @@ function main() {
for (const dirName of extensionDirs) {
const extensionPath = path.join(EXTENSIONS_DIR, dirName);
if (!fs.existsSync(path.join(extensionPath, "extension.mjs"))) {
if (!isExtensionPluginDirectory(extensionPath)) {
continue;
}
const { removed, manifestUpdated } = cleanMaterializedExtensionPlugin(extensionPath);