64 lines
2.1 KiB
JavaScript
64 lines
2.1 KiB
JavaScript
// Enables CEP debug mode and links dist/ into the Adobe extensions folder.
|
|
// Run once per machine: npm run cep:setup
|
|
|
|
const { execFileSync } = require("child_process");
|
|
const fs = require("fs");
|
|
const os = require("os");
|
|
const path = require("path");
|
|
|
|
const CSXS_VERSIONS = [9, 10, 11, 12];
|
|
const EXTENSION_NAME = "com.aiedit.panel";
|
|
const dist = path.resolve(__dirname, "..", "dist");
|
|
|
|
function enableDebugMode() {
|
|
if (process.platform === "win32") {
|
|
for (const version of CSXS_VERSIONS) {
|
|
execFileSync("reg", [
|
|
"add", `HKCU\\Software\\Adobe\\CSXS.${version}`,
|
|
"/v", "PlayerDebugMode", "/t", "REG_SZ", "/d", "1", "/f"
|
|
], { stdio: "ignore" });
|
|
}
|
|
} else {
|
|
for (const version of CSXS_VERSIONS) {
|
|
execFileSync("defaults", [
|
|
"write", `com.adobe.CSXS.${version}`, "PlayerDebugMode", "1"
|
|
], { stdio: "ignore" });
|
|
}
|
|
}
|
|
console.log(`PlayerDebugMode enabled for CSXS ${CSXS_VERSIONS.join(", ")}`);
|
|
}
|
|
|
|
function extensionsFolder() {
|
|
return process.platform === "win32"
|
|
? path.join(process.env.APPDATA, "Adobe", "CEP", "extensions")
|
|
: path.join(os.homedir(), "Library", "Application Support", "Adobe", "CEP", "extensions");
|
|
}
|
|
|
|
function linkExtension() {
|
|
const root = extensionsFolder();
|
|
fs.mkdirSync(root, { recursive: true });
|
|
|
|
const target = path.join(root, EXTENSION_NAME);
|
|
const existing = fs.lstatSync(target, { throwIfNoEntry: false });
|
|
if (existing) {
|
|
if (!existing.isSymbolicLink()) {
|
|
console.error(`${target} exists and is not a link. Remove it manually, then rerun.`);
|
|
process.exit(1);
|
|
}
|
|
fs.unlinkSync(target);
|
|
}
|
|
|
|
// Junctions avoid needing administrator rights on Windows.
|
|
fs.symlinkSync(dist, target, process.platform === "win32" ? "junction" : "dir");
|
|
console.log(`Linked ${target} -> ${dist}`);
|
|
}
|
|
|
|
if (!fs.existsSync(dist)) {
|
|
console.error("dist/ not found. Run `npm run build` first.");
|
|
process.exit(1);
|
|
}
|
|
|
|
enableDebugMode();
|
|
linkExtension();
|
|
console.log("Restart Photoshop, then open Plugins > AI Edit.");
|