Skip to content

A plugin marketplace for GitHub Copilot and other AI agents that provides Power Platform development plugins, including reusable skills, agents, and commands for building and deploying solutions.

Fix plugin installation script (#32)

Priyanshu Agrawal2f087fb0b0fc
diff --git a/.github/plugin/marketplace.json b/.github/plugin/marketplace.json
deleted file mode 120000
index 17c96d242..000000000
--- a/.github/plugin/marketplace.json
+++ /dev/null
@@ -1 +0,0 @@
-../../.claude-plugin/marketplace.json
\ No newline at end of file
diff --git a/README.md b/README.md
index 37588e259..30db38bf9 100644
--- a/README.md
+++ b/README.md
@@ -56,12 +56,12 @@ Run the installer to set up all plugins with auto-update enabled:
**Windows (PowerShell)**:
```powershell
-iwr https://raw.githubusercontent.com/microsoft/power-platform-skills/main/install.js -OutFile install.js; node install.js; del install.js
+iwr https://raw.githubusercontent.com/microsoft/power-platform-skills/main/scripts/install.js -OutFile install.js; node install.js; del install.js
```
**Mac OS/Linux**:
```bash
-curl -fsSL https://raw.githubusercontent.com/microsoft/power-platform-skills/main/install.js | node
+curl -fsSL https://raw.githubusercontent.com/microsoft/power-platform-skills/main/scripts/install.js | node
```
diff --git a/install.js b/install.js
deleted file mode 100644
index c55efea98..000000000
--- a/install.js
+++ /dev/null
@@ -1,407 +0,0 @@
-#!/usr/bin/env node
-/**
- * Power Platform Skills — Installation Script
- *
- * Clones the marketplace repository and writes directly to the plugin
- * directories used by Claude Code and GitHub Copilot CLI. No CLI commands
- * are executed — only git, file copies, and JSON config updates.
- *
- * Usage:
- * node install.js (from local clone)
- * curl -fsSL https://raw.githubusercontent.com/microsoft/power-platform-skills/main/install.js | node
- */
-
-const { execSync } = require("child_process");
-const fs = require("fs");
-const path = require("path");
-const os = require("os");
-const https = require("https");
-
-// ── Config ────────────────────────────────────────────────────
-const REPO = "microsoft/power-platform-skills";
-const REPO_URL = `https://github.com/${REPO}.git`;
-const MARKETPLACE_NAME = "power-platform-skills";
-const GITHUB_RAW = `https://raw.githubusercontent.com/${REPO}/main`;
-const HOME = os.homedir();
-
-// ── Colors (disabled when output is piped) ────────────────────
-const tty = process.stdout.isTTY;
-const bold = (s) => (tty ? `\x1b[1m${s}\x1b[0m` : s);
-const green = (s) => (tty ? `\x1b[32m${s}\x1b[0m` : s);
-const yellow = (s) => (tty ? `\x1b[33m${s}\x1b[0m` : s);
-const red = (s) => (tty ? `\x1b[31m${s}\x1b[0m` : s);
-
-const ok = (msg) => console.log(` ${green("✓")} ${msg}`);
-const warn = (msg) => console.log(` ${yellow("!")} ${msg}`);
-const fail = (msg) => console.log(` ${red("✗")} ${msg}`);
-const header = (msg) => console.log(`\n${bold(msg)}`);
-const info = (msg) => console.log(` ${msg}`);
-
-// ── Helpers ───────────────────────────────────────────────────
-function hasCommand(cmd) {
- try {
- const which = process.platform === "win32" ? "where" : "which";
- execSync(`${which} ${cmd}`, { stdio: "pipe" });
- return true;
- } catch {
- return false;
- }
-}
-
-function run(cmd, opts = {}) {
- try {
- const output = execSync(cmd, {
- stdio: "pipe",
- timeout: 120_000,
- cwd: opts.cwd,
- shell: true,
- });
- return { ok: true, output: output.toString().trim() };
- } catch (err) {
- const stderr = err.stderr ? err.stderr.toString().trim() : err.message;
- return { ok: false, output: stderr };
- }
-}
-
-function httpsGet(url) {
- return new Promise((resolve, reject) => {
- const request = (target) => {
- https
- .get(target, { headers: { "User-Agent": "power-platform-skills-installer" } }, (res) => {
- if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
- return request(res.headers.location);
- }
- if (res.statusCode !== 200) {
- return reject(new Error(`HTTP ${res.statusCode} from ${target}`));
- }
- let data = "";
- res.on("data", (chunk) => (data += chunk));
- res.on("end", () => resolve(data));
- })
- .on("error", reject);
- };
- request(url);
- });
-}
-
-function readJSON(filePath) {
- try {
- return JSON.parse(fs.readFileSync(filePath, "utf8"));
- } catch {
- return null;
- }
-}
-
-function writeJSON(filePath, data) {
- fs.mkdirSync(path.dirname(filePath), { recursive: true });
- fs.writeFileSync(filePath, JSON.stringify(data, null, 2) + "\n");
-}
-
-function copyDirSync(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()) {
- copyDirSync(srcPath, destPath);
- } else if (entry.isSymbolicLink()) {
- const target = fs.readlinkSync(srcPath);
- try {
- fs.symlinkSync(target, destPath);
- } catch {
- fs.copyFileSync(fs.realpathSync(srcPath), destPath);
- }
- } else {
- fs.copyFileSync(srcPath, destPath);
- }
- }
-}
-
-// ── Git operations ────────────────────────────────────────────
-function gitCloneOrUpdate(url, dir) {
- const gitDir = path.join(dir, ".git");
-
- if (fs.existsSync(gitDir)) {
- info("Updating existing repository...");
- const fetch = run(`git -C "${dir}" fetch origin main`);
- if (fetch.ok) {
- run(`git -C "${dir}" checkout main`);
- const pull = run(`git -C "${dir}" pull origin main`);
- if (pull.ok) {
- ok("Repository updated");
- return true;
- }
- }
- warn("Update failed — re-cloning...");
- const backup = `${dir}-backup-${Date.now()}`;
- fs.renameSync(dir, backup);
- info(`Backup saved to ${path.basename(backup)}`);
- }
-
- info("Cloning marketplace repository...");
- fs.mkdirSync(path.dirname(dir), { recursive: true });
- const clone = run(`git clone "${url}" "${dir}"`);
- if (clone.ok) {
- ok("Repository cloned");
- return true;
- }
-
- fail(`Failed to clone: ${clone.output}`);
- return false;
-}
-
-function gitCommitSha(dir) {
- const result = run(`git -C "${dir}" rev-parse HEAD`);
- return result.ok ? result.output : "";
-}
-
-// ── Marketplace loader ────────────────────────────────────────
-async function loadMarketplace() {
- const scriptDir = process.argv[1] ? path.dirname(path.resolve(process.argv[1])) : process.cwd();
- const localFile = path.join(scriptDir, ".claude-plugin", "marketplace.json");
-
- if (fs.existsSync(localFile)) {
- return JSON.parse(fs.readFileSync(localFile, "utf8"));
- }
-
- info("Fetching marketplace manifest from GitHub...");
- const raw = await httpsGet(`${GITHUB_RAW}/.claude-plugin/marketplace.json`);
- return JSON.parse(raw);
-}
-
-// ── Claude Code installation ──────────────────────────────────
-//
-// On-disk layout:
-// ~/.claude/plugins/marketplaces/<marketplace>/ — git clone of marketplace repo
-// ~/.claude/plugins/cache/<marketplace>/<plugin>/<ver>/ — plugin files (versioned)
-// ~/.claude/plugins/known_marketplaces.json — marketplace registry
-// ~/.claude/plugins/installed_plugins.json — plugin registry
-//
-function installClaude(plugins) {
- header("Claude Code");
-
- const pluginsRoot = path.join(HOME, ".claude", "plugins");
-
- // 1. Clone marketplace repo
- const marketplacePath = path.join(pluginsRoot, "marketplaces", MARKETPLACE_NAME);
- info("Setting up marketplace repository...");
- if (!gitCloneOrUpdate(REPO_URL, marketplacePath)) {
- fail("Could not set up marketplace — skipping Claude Code");
- return;
- }
-
- const sha = gitCommitSha(marketplacePath);
-
- // 2. Copy each plugin into the versioned cache
- for (const plugin of plugins) {
- const src = path.join(marketplacePath, "plugins", plugin);
- if (!fs.existsSync(src)) {
- warn(`Plugin directory not found in marketplace: plugins/${plugin}`);
- continue;
- }
-
- const pluginMeta = readJSON(path.join(src, ".claude-plugin", "plugin.json"));
- const version = pluginMeta?.version || sha.substring(0, 12);
- const dest = path.join(pluginsRoot, "cache", MARKETPLACE_NAME, plugin, version);
-
- info(`Installing ${plugin} (v${version})...`);
- if (fs.existsSync(dest)) {
- fs.rmSync(dest, { recursive: true, force: true });
- }
- copyDirSync(src, dest);
- ok(`${plugin} installed`);
- }
-
- // 3. Register marketplace in known_marketplaces.json
- const knownPath = path.join(pluginsRoot, "known_marketplaces.json");
- const known = readJSON(knownPath) || {};
- known[MARKETPLACE_NAME] = {
- source: { source: "github", repo: REPO },
- installLocation: marketplacePath,
- lastUpdated: new Date().toISOString(),
- autoUpdate: true,
- };
- writeJSON(knownPath, known);
- ok("Marketplace registered (auto-update enabled)");
-
- // 4. Register plugins in installed_plugins.json
- const installedPath = path.join(pluginsRoot, "installed_plugins.json");
- const installed = readJSON(installedPath) || { version: 2, plugins: {} };
- if (!installed.plugins) installed.plugins = {};
-
- for (const plugin of plugins) {
- const src = path.join(marketplacePath, "plugins", plugin);
- if (!fs.existsSync(src)) continue;
-
- const pluginMeta = readJSON(path.join(src, ".claude-plugin", "plugin.json"));
- const version = pluginMeta?.version || sha.substring(0, 12);
- const cachePath = path.join(pluginsRoot, "cache", MARKETPLACE_NAME, plugin, version);
- const key = `${plugin}@${MARKETPLACE_NAME}`;
-
- const existing = installed.plugins[key]?.[0];
- installed.plugins[key] = [
- {
- scope: "user",
- installPath: cachePath,
- version: version,
- installedAt: existing?.installedAt || new Date().toISOString(),
- lastUpdated: new Date().toISOString(),
- gitCommitSha: sha,
- },
- ];
- }
-
- writeJSON(installedPath, installed);
- ok("Plugin registry updated");
-}
-
-// ── GitHub Copilot installation ───────────────────────────────
-//
-// On-disk layout:
-// ~/.copilot/marketplace-cache/<owner>-<marketplace>/ — git clone of marketplace repo
-// ~/.copilot/installed-plugins/<marketplace>/<plugin>/ — plugin files (flat)
-// ~/.copilot/config.json → { marketplaces: {}, installed_plugins: [] }
-//
-function installCopilot(plugins) {
- header("GitHub Copilot");
-
- const copilotDir = path.join(HOME, ".copilot");
-
- // 1. Clone marketplace repo
- const cacheDir = path.join(copilotDir, "marketplace-cache", `microsoft-${MARKETPLACE_NAME}`);
- info("Setting up marketplace cache...");
- if (!gitCloneOrUpdate(REPO_URL, cacheDir)) {
- fail("Could not set up marketplace cache — skipping Copilot");
- return;
- }
-
- // 2. Copy each plugin to installed-plugins
- for (const plugin of plugins) {
- const src = path.join(cacheDir, "plugins", plugin);
- const dest = path.join(copilotDir, "installed-plugins", MARKETPLACE_NAME, plugin);
-
- if (!fs.existsSync(src)) {
- warn(`Plugin directory not found in marketplace: plugins/${plugin}`);
- continue;
- }
-
- info(`Installing ${plugin}...`);
- if (fs.existsSync(dest)) {
- fs.rmSync(dest, { recursive: true, force: true });
- }
- copyDirSync(src, dest);
- ok(`${plugin} installed`);
- }
-
- // 3. Update config.json — register marketplace + plugins
- const configPath = path.join(copilotDir, "config.json");
- const config = readJSON(configPath) || {};
-
- if (!config.marketplaces) config.marketplaces = {};
- config.marketplaces[MARKETPLACE_NAME] = {
- source: { source: "github", repo: REPO },
- };
-
- if (!config.installed_plugins) config.installed_plugins = [];
-
- for (const plugin of plugins) {
- const pluginPath = path.join(copilotDir, "installed-plugins", MARKETPLACE_NAME, plugin);
- if (!fs.existsSync(pluginPath)) continue;
-
- const idx = config.installed_plugins.findIndex(
- (p) => p.name === plugin && p.marketplace === MARKETPLACE_NAME
- );
-
- const entry = {
- name: plugin,
- marketplace: MARKETPLACE_NAME,
- installed_at: new Date().toISOString(),
- enabled: true,
- cache_path: pluginPath,
- };
-
- if (idx >= 0) {
- entry.installed_at = config.installed_plugins[idx].installed_at;
- config.installed_plugins[idx] = entry;
- } else {
- config.installed_plugins.push(entry);
- }
- }
-
- writeJSON(configPath, config);
- ok("Config updated — marketplace and plugins registered");
-}
-
-// ── Main ──────────────────────────────────────────────────────
-async function main() {
- console.log("");
- console.log(bold("Power Platform Skills — Installer"));
- console.log("──────────────────────────────────");
-
- // ── Prerequisites ──────────────────────────────────────────
- header("Checking prerequisites");
- ok(`Node.js ${process.version}`);
-
- if (!hasCommand("git")) {
- fail("Git is required. Install from https://git-scm.com");
- process.exit(1);
- }
- ok("Git available");
-
- // Detect tools — check CLI in PATH or config directory on disk
- const tools = [];
-
- if (hasCommand("claude") || fs.existsSync(path.join(HOME, ".claude", "plugins"))) {
- tools.push("claude");
- ok("Claude Code detected");
- }
- if (hasCommand("copilot") || fs.existsSync(path.join(HOME, ".copilot", "config.json"))) {
- tools.push("copilot");
- ok("GitHub Copilot CLI detected");
- }
-
- if (tools.length === 0) {
- fail("Neither Claude Code nor GitHub Copilot CLI found.");
- console.log("");
- console.log(" Install at least one:");
- console.log(" Claude Code https://docs.anthropic.com/en/docs/claude-code");
- console.log(" GitHub Copilot https://docs.github.com/en/copilot");
- process.exit(1);
- }
-
- // ── Marketplace ────────────────────────────────────────────
- header("Reading marketplace");
-
- const manifest = await loadMarketplace();
- const plugins = manifest.plugins.map((p) => p.name);
-
- console.log(` Marketplace : ${manifest.name}`);
- console.log(" Plugins :");
- for (const p of plugins) console.log(` - ${p}`);
-
- if (plugins.length === 0) {
- warn("No plugins found in the marketplace.");
- process.exit(0);
- }
-
- // ── Install ────────────────────────────────────────────────
- if (tools.includes("claude")) installClaude(plugins);
- if (tools.includes("copilot")) installCopilot(plugins);
-
- // ── Summary ────────────────────────────────────────────────
- header("Done!");
- console.log("");
- console.log(" Auto-update is enabled. Plugins will stay current automatically.");
- console.log(" Run this script again anytime to update to the latest version.");
- console.log("");
- console.log(" Get started:");
- for (const tool of tools) {
- console.log(` ${tool} session -> /power-pages:create-site`);
- }
- console.log("");
-}
-
-main().catch((err) => {
- fail(`Installation failed: ${err.message}`);
- process.exit(1);
-});
diff --git a/scripts/install.js b/scripts/install.js
new file mode 100644
index 000000000..aa8f6b88b
--- /dev/null
+++ b/scripts/install.js
@@ -0,0 +1,301 @@
+#!/usr/bin/env node
+/**
+ * Power Platform Skills — Installation Script
+ *
+ * Clones the marketplace repository and uses CLI commands to register
+ * the marketplace and install plugins for Claude Code and GitHub Copilot.
+ *
+ * Usage:
+ * node scripts/install.js (from local clone)
+ * curl -fsSL https://raw.githubusercontent.com/microsoft/power-platform-skills/main/scripts/install.js | node
+ */
+
+const { execSync } = require("child_process");
+const fs = require("fs");
+const path = require("path");
+const os = require("os");
+const https = require("https");
+
+// ── Config ────────────────────────────────────────────────────
+const REPO = "microsoft/power-platform-skills";
+const MARKETPLACE_NAME = "power-platform-skills";
+const GITHUB_RAW = `https://raw.githubusercontent.com/${REPO}/main`;
+const HOME = os.homedir();
+
+// ── Colors (disabled when output is piped) ────────────────────
+const tty = process.stdout.isTTY;
+const bold = (s) => (tty ? `\x1b[1m${s}\x1b[0m` : s);
+const green = (s) => (tty ? `\x1b[32m${s}\x1b[0m` : s);
+const yellow = (s) => (tty ? `\x1b[33m${s}\x1b[0m` : s);
+const red = (s) => (tty ? `\x1b[31m${s}\x1b[0m` : s);
+
+const ok = (msg) => console.log(` ${green("✓")} ${msg}`);
+const warn = (msg) => console.log(` ${yellow("!")} ${msg}`);
+const fail = (msg) => console.log(` ${red("✗")} ${msg}`);
+const header = (msg) => console.log(`\n${bold(msg)}`);
+const info = (msg) => console.log(` ${msg}`);
+
+// ── Helpers ───────────────────────────────────────────────────
+function hasCommand(cmd) {
+ try {
+ const which = process.platform === "win32" ? "where" : "which";
+ execSync(`${which} ${cmd}`, { stdio: "pipe" });
+ return true;
+ } catch {
+ return false;
+ }
+}
+
+function run(cmd, opts = {}) {
+ try {
+ const output = execSync(cmd, {
+ stdio: "pipe",
+ timeout: 120_000,
+ cwd: opts.cwd,
+ shell: true,
+ });
+ return { ok: true, output: output.toString().trim() };
+ } catch (err) {
+ const stderr = err.stderr ? err.stderr.toString().trim() : err.message;
+ return { ok: false, output: stderr };
+ }
+}
+
+function httpsGet(url) {
+ return new Promise((resolve, reject) => {
+ const request = (target) => {
+ https
+ .get(target, { headers: { "User-Agent": "power-platform-skills-installer" } }, (res) => {
+ if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
+ return request(res.headers.location);
+ }
+ if (res.statusCode !== 200) {
+ return reject(new Error(`HTTP ${res.statusCode} from ${target}`));
+ }
+ let data = "";
+ res.on("data", (chunk) => (data += chunk));
+ res.on("end", () => resolve(data));
+ })
+ .on("error", reject);
+ };
+ request(url);
+ });
+}
+
+// ── Auto-update ──────────────────────────────────────────────
+// The CLI's `marketplace add` does not set autoUpdate — patch it manually.
+// `getMarketplaces` extracts the marketplaces object from the config root.
+function enableAutoUpdate(configFile, getMarketplaces) {
+ try {
+ const data = JSON.parse(fs.readFileSync(configFile, "utf8"));
+ const marketplaces = getMarketplaces(data);
+ if (marketplaces?.[MARKETPLACE_NAME] && !marketplaces[MARKETPLACE_NAME].autoUpdate) {
+ marketplaces[MARKETPLACE_NAME].autoUpdate = true;
+ fs.writeFileSync(configFile, JSON.stringify(data, null, 2) + "\n");
+ ok("Auto-update enabled");
+ return;
+ }
+ if (marketplaces?.[MARKETPLACE_NAME]?.autoUpdate) {
+ ok("Auto-update already enabled");
+ return;
+ }
+ warn("Marketplace entry not found — auto-update not set");
+ } catch {
+ warn("Could not enable auto-update (config file not found)");
+ }
+}
+
+// ── Marketplace loader ────────────────────────────────────────
+async function loadMarketplace() {
+ const scriptDir = process.argv[1] ? path.dirname(path.resolve(process.argv[1])) : process.cwd();
+ // Script lives in scripts/, so the repo root is one level up
+ const repoRoot = path.resolve(scriptDir, "..");
+ const localFile = path.join(repoRoot, ".claude-plugin", "marketplace.json");
+
+ if (fs.existsSync(localFile)) {
+ return JSON.parse(fs.readFileSync(localFile, "utf8"));
+ }
+
+ // Also check cwd (handles running from repo root or piped download)
+ const cwdFile = path.join(process.cwd(), ".claude-plugin", "marketplace.json");
+ if (fs.existsSync(cwdFile)) {
+ return JSON.parse(fs.readFileSync(cwdFile, "utf8"));
+ }
+
+ info("Fetching marketplace manifest from GitHub...");
+ const raw = await httpsGet(`${GITHUB_RAW}/.claude-plugin/marketplace.json`);
+ return JSON.parse(raw);
+}
+
+// ── Claude Code installation ──────────────────────────────────
+function installClaude(plugins) {
+ header("Claude Code");
+
+ // 1. Register marketplace via CLI (CLI clones the repo automatically)
+ info("Registering marketplace...");
+ const addResult = run(`claude plugin marketplace add "${REPO}"`);
+ if (addResult.ok) {
+ ok("Marketplace registered");
+ } else if (addResult.output.includes("already")) {
+ ok("Marketplace already registered");
+ } else {
+ fail(`Failed to register marketplace: ${addResult.output}`);
+ return;
+ }
+
+ // 2. Update marketplace
+ info("Updating marketplace...");
+ const updateResult = run(`claude plugin marketplace update "${MARKETPLACE_NAME}"`);
+ if (updateResult.ok) {
+ ok("Marketplace updated");
+ } else {
+ warn(`Marketplace update: ${updateResult.output}`);
+ }
+
+ // 3. Enable auto-update (CLI does not set this)
+ const knownPath = path.join(HOME, ".claude", "plugins", "known_marketplaces.json");
+ enableAutoUpdate(knownPath, (data) => data);
+
+ // 4. Install each plugin via CLI
+ for (const plugin of plugins) {
+ info(`Installing ${plugin}...`);
+ const installResult = run(
+ `claude plugin install "${plugin}@${MARKETPLACE_NAME}" --scope user`
+ );
+ if (installResult.ok) {
+ ok(`${plugin} installed`);
+ } else if (installResult.output.includes("already installed")) {
+ ok(`${plugin} already installed`);
+ } else {
+ fail(`Failed to install ${plugin}: ${installResult.output}`);
+ }
+ }
+
+ // 5. Verify installation
+ info("Verifying installation...");
+ const listResult = run("claude plugin list");
+ if (listResult.ok) {
+ const installed = plugins.filter((p) => listResult.output.includes(p));
+ if (installed.length > 0) {
+ ok(`Verified: ${installed.join(", ")}`);
+ } else {
+ warn("Plugins not found in plugin list output");
+ }
+ }
+}
+
+// ── GitHub Copilot installation ───────────────────────────────
+function installCopilot(plugins) {
+ header("GitHub Copilot");
+
+ // 1. Register marketplace via CLI (CLI clones the repo automatically)
+ info("Registering marketplace...");
+ const addResult = run(`copilot plugin marketplace add "${REPO}"`);
+ if (addResult.ok) {
+ ok("Marketplace registered");
+ } else if (addResult.output.includes("already")) {
+ ok("Marketplace already registered");
+ } else {
+ fail(`Failed to register marketplace: ${addResult.output}`);
+ return;
+ }
+
+ // 2. Enable auto-update (CLI does not set this)
+ const configPath = path.join(HOME, ".copilot", "config.json");
+ enableAutoUpdate(configPath, (data) => data.marketplaces);
+
+ // 3. Install each plugin via CLI
+ for (const plugin of plugins) {
+ info(`Installing ${plugin}...`);
+ const installResult = run(`copilot plugin install "${plugin}@${MARKETPLACE_NAME}"`);
+ if (installResult.ok) {
+ ok(`${plugin} installed`);
+ } else if (installResult.output.includes("already installed")) {
+ ok(`${plugin} already installed`);
+ } else {
+ fail(`Failed to install ${plugin}: ${installResult.output}`);
+ }
+ }
+
+ // 4. Verify installation
+ info("Verifying installation...");
+ const listResult = run("copilot plugin list");
+ if (listResult.ok) {
+ const installed = plugins.filter((p) => listResult.output.includes(p));
+ if (installed.length > 0) {
+ ok(`Verified: ${installed.join(", ")}`);
+ } else {
+ warn("Plugins not found in plugin list output");
+ }
+ }
+}
+
+// ── Main ──────────────────────────────────────────────────────
+async function main() {
+ console.log("");
+ console.log(bold("Power Platform Skills — Installer"));
+ console.log("──────────────────────────────────");
+
+ // ── Prerequisites ──────────────────────────────────────────
+ header("Checking prerequisites");
+ ok(`Node.js ${process.version}`);
+
+ // Detect tools — require CLI in PATH (CLI commands need the binary)
+ const tools = [];
+
+ if (hasCommand("claude")) {
+ const ver = run("claude --version");
+ tools.push("claude");
+ ok(`Claude Code ${ver.ok ? ver.output : "(version unknown)"}`);
+ }
+ if (hasCommand("copilot")) {
+ const ver = run("copilot --version");
+ tools.push("copilot");
+ ok(`GitHub Copilot CLI ${ver.ok ? ver.output : "(version unknown)"}`);
+ }
+
+ if (tools.length === 0) {
+ fail("Neither Claude Code nor GitHub Copilot CLI found in PATH.");
+ console.log("");
+ console.log(" Install at least one and ensure it is on your PATH:");
+ console.log(" Claude Code https://docs.anthropic.com/en/docs/claude-code");
+ console.log(" GitHub Copilot https://docs.github.com/en/copilot");
+ process.exit(1);
+ }
+
+ // ── Marketplace ────────────────────────────────────────────
+ header("Reading marketplace");
+
+ const manifest = await loadMarketplace();
+ const plugins = manifest.plugins.map((p) => p.name);
+
+ console.log(` Marketplace : ${manifest.name}`);
+ console.log(" Plugins :");
+ for (const p of plugins) console.log(` - ${p}`);
+
+ if (plugins.length === 0) {
+ warn("No plugins found in the marketplace.");
+ process.exit(0);
+ }
+
+ // ── Install ────────────────────────────────────────────────
+ if (tools.includes("claude")) installClaude(plugins);
+ if (tools.includes("copilot")) installCopilot(plugins);
+
+ // ── Summary ────────────────────────────────────────────────
+ header("Done!");
+ console.log("");
+ console.log(" Plugins will stay current via the marketplace auto-update mechanism.");
+ console.log(" Run this script again anytime to re-install or update.");
+ console.log("");
+ console.log(" Get started:");
+ for (const tool of tools) {
+ console.log(` ${tool} session -> /power-pages:create-site`);
+ }
+ console.log("");
+}
+
+main().catch((err) => {
+ fail(`Installation failed: ${err.message}`);
+ process.exit(1);
+});