Paskelbtas šaltinis
Atsisiųsti šaltinį ZIP
CH-J Server Manager
Naršyti aplankus ir failus konkrečiai programai išleisti.
CH-J / Server Manager
339 failai
core-20261014T184258Z-3fbed0b93fdf
Pridėta: Data neregistruota · Pastatytas:
1
"use strict";3
const test = require("node:test");4
const assert = require("node:assert/strict");5
const fs = require("node:fs");6
const os = require("node:os");7
const path = require("node:path");8
const { PluginRegistry, validateManifest } = require("../src/main/plugins/pluginRegistry");10
function manifest(version, overrides = {}) {11
return {12
schemaVersion: 1,13
id: "chj.system-monitor",14
name: "System Monitor",15
version,16
publisher: "CH-J",17
entry: "ui/index.html",18
pluginApi: "^1.0.0",19
minAppVersion: "0.0.1",20
permissions: ["session.read", "system.metrics.read"],21
...overrides22
};23
}25
test("manifest validator rejects traversal and unknown permissions", () => {26
assert.throws(() => validateManifest(manifest("0.0.1", { entry: "../main.js" })), /entry/);27
assert.throws(() => validateManifest(manifest("0.0.1", { permissions: ["electron.full"] })), /permission/);28
});30
test("all seven first-party tools ship in the app under its shared license; bundled copies win equal-version legacy installs", (t) => {31
const root = fs.mkdtempSync(path.join(os.tmpdir(), "chj-bundled-"));32
t.after(() => fs.rmSync(root, { recursive: true, force: true }));33
const bundledRoot = path.join(__dirname, "..", "src", "main", "firstPartyPlugins");34
const registry = new PluginRegistry(root, null, { bundledRoot });35
const plugins = registry.listInstalled();36
assert.deepEqual(plugins.map((plugin) => plugin.id).sort(), ["chj.file-manager", "chj.hash-checksum", "chj.key-generator", "chj.log-viewer", "chj.nginx-manager", "chj.system-monitor", "chj.users"]);37
for (const plugin of plugins) {38
assert.equal(plugin.bundled, true);39
const resolved = registry.resolveEntry(plugin.id);40
const raw = JSON.parse(fs.readFileSync(path.join(resolved.root, "manifest.json"), "utf8"));41
assert.equal(raw.license, "CH-J Proprietary Software License, Version 1.14 — see application LICENSE");42
assert.equal(fs.existsSync(path.join(resolved.root, "LICENSE")), false);43
assert.ok(fs.statSync(resolved.entryPath).isFile());44
}45
const legacy = path.join(root, "plugins", "chj.system-monitor", "0.0.1");46
fs.mkdirSync(path.join(legacy, "ui"), { recursive: true });47
fs.writeFileSync(path.join(legacy, "manifest.json"), JSON.stringify(manifest("0.0.1")));48
fs.writeFileSync(path.join(legacy, "ui", "index.html"), "legacy");49
assert.equal(registry.getInstalled("chj.system-monitor").bundled, true);50
assert.ok(registry.resolveEntry("chj.system-monitor").root.startsWith(bundledRoot));51
});53
test("registry returns the newest valid installed plugin and can remove all of its versions", (t) => {54
const root = fs.mkdtempSync(path.join(os.tmpdir(), "chj-plugins-"));55
t.after(() => fs.rmSync(root, { recursive: true, force: true }));56
for (const version of ["0.0.1", "0.0.2"]) {57
const versionRoot = path.join(root, "plugins", "chj.system-monitor", version, "ui");58
fs.mkdirSync(versionRoot, { recursive: true });59
fs.writeFileSync(path.join(versionRoot, "index.html"), "<!doctype html>");60
fs.writeFileSync(path.join(versionRoot, "..", "manifest.json"), JSON.stringify(manifest(version)));61
fs.writeFileSync(path.join(versionRoot, "..", ".installation.json"), JSON.stringify({ releaseId: `release-${version}`, sha512: version === "0.0.2" ? "b".repeat(128) : "a".repeat(128), installedAt: "2026-08-07T20:00:00Z" }));62
}63
const registry = new PluginRegistry(root);64
const plugins = registry.listInstalled();65
assert.equal(plugins.length, 1);66
assert.equal(plugins[0].version, "0.0.2");67
assert.equal(plugins[0].installedReleaseId, "release-0.0.2");68
assert.equal(plugins[0].installedSha512, "b".repeat(128));69
assert.deepEqual(registry.removeInstalled("chj.system-monitor"), { removed: true, pluginId: "chj.system-monitor" });70
assert.deepEqual(registry.listInstalled(), []);71
assert.deepEqual(registry.removeInstalled("chj.system-monitor"), { removed: false, pluginId: "chj.system-monitor" });72
});SHA-256
d1bcf15fd47e6e94684aa2a28bcc524d8a4f634c13822302f770fe7dce292526CH-J Proprietary Software License 1.14 · Šaltinis pateiktas pagal CH-J Proprietary Software License 1.14. Jo prieinamumas nekeičia licencijos sąlygų ir nesuteikia papildomų teisių.
Archyvas SHA-256
3df08cf5e899262a6ce92d7ec2caf5c42b683f1f2b57055662b845ff7dde67a8