wishforge-ide/apps/ide/policy/plugin-install-policy.cjs
eust-w 0ef99b1e6d style: add Prettier and EditorConfig, format the codebase
Adds prettier 3.9.8 (exact) with a shared config (single quotes,
120 columns, trailing commas), .prettierignore, .editorconfig and the
`format` / `format:check` scripts, then formats all TypeScript,
JavaScript, CSS, JSON and YAML sources.

Purely mechanical: no behaviour change. Typecheck passes, the vitest
suite and the 74 IDE node tests produce the same results as before
(socket-binding tests still cannot run inside this sandbox).
Previously the longest source line was ~3000 characters; reviewing the
following semantic changes now produces readable diffs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 13:32:43 +08:00

73 lines
2.4 KiB
JavaScript

'use strict';
const path = require('node:path');
const { injectable } = require('@theia/core/shared/inversify');
const { PluginServer, PluginDeployer, PluginType } = require('@theia/plugin-ext/lib/common/plugin-protocol');
const { PluginServerImpl } = require('@theia/plugin-ext/lib/main/node/plugin-server-impl');
const { PluginDeployerImpl } = require('@theia/plugin-ext/lib/main/node/plugin-deployer-impl');
const { validateManagedPlugins, managedError } = require('./managed-plugins.cjs');
class ManagedPluginServer extends PluginServerImpl {
async install() {
throw managedError();
}
async doInstall() {
throw managedError();
}
async uninstall() {
throw managedError();
}
async enablePlugin() {
throw managedError();
}
async disablePlugin() {
throw managedError();
}
}
injectable()(ManagedPluginServer);
class ManagedPluginDeployer extends PluginDeployerImpl {
async doStart() {
if (!process.env.WF_IDE_MANAGED_PLUGINS_DIR) throw new Error('MANAGED_EXTENSIONS_UNCONFIGURED');
const root = path.resolve(process.env.WF_IDE_MANAGED_PLUGINS_DIR);
const allowed = validateManagedPlugins(root);
await this.initResolvers();
// Do not consult THEIA_PLUGINS, user directories, extension recommendations
// or resolver participants. All system content was verified before resolution.
const entries = await this.resolveAndHandle(`local-dir:${root}`, PluginType.System);
const paths = new Set(allowed.map(extension => path.join(root, extension.directory)));
if (
entries.length !== paths.size ||
entries.some(entry => !paths.has(entry.originalPath()) || entry.type !== PluginType.System)
) {
throw new Error('EXTENSION_DEPLOYMENT_SCOPE_REJECTED');
}
return super.deployPlugins(entries);
}
async deploy() {
throw managedError();
}
async deployMultipleEntries() {
throw managedError();
}
async deployPlugins() {
throw managedError();
}
async uninstall() {
throw managedError();
}
async undeploy() {
throw managedError();
}
async enablePlugin() {
throw managedError();
}
async disablePlugin() {
throw managedError();
}
}
injectable()(ManagedPluginDeployer);
function bindManagedPlugins(rebind) {
rebind(PluginServer).to(ManagedPluginServer).inSingletonScope();
rebind(PluginDeployer).to(ManagedPluginDeployer).inSingletonScope();
}
module.exports = { ManagedPluginServer, ManagedPluginDeployer, bindManagedPlugins };