plugins 1.2.10-canary.3 → 1.2.10-canary.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +38 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -756,9 +756,20 @@ async function installToPluginCache(plugins, scope, repoPath, source) {
|
|
|
756
756
|
if (knownMarketplaces[marketplaceName]) {
|
|
757
757
|
stepDone(`Marketplace ${c.dim("'" + marketplaceName + "'")} already registered`);
|
|
758
758
|
} else {
|
|
759
|
+
const githubRepo = extractGitHubRepo(source);
|
|
760
|
+
const marketplaceInstallLocation = join3(home, ".claude", "plugins", "marketplaces", marketplaceName);
|
|
761
|
+
let marketplaceSource;
|
|
762
|
+
if (githubRepo) {
|
|
763
|
+
marketplaceSource = { source: "github", repo: githubRepo };
|
|
764
|
+
} else if (isRemoteSource(source)) {
|
|
765
|
+
const gitUrl = normalizeGitUrl(source);
|
|
766
|
+
marketplaceSource = { source: "git", url: gitUrl.endsWith(".git") ? gitUrl : gitUrl + ".git" };
|
|
767
|
+
} else {
|
|
768
|
+
marketplaceSource = { source: "directory", path: repoPath };
|
|
769
|
+
}
|
|
759
770
|
knownMarketplaces[marketplaceName] = {
|
|
760
|
-
source:
|
|
761
|
-
installLocation:
|
|
771
|
+
source: marketplaceSource,
|
|
772
|
+
installLocation: marketplaceInstallLocation,
|
|
762
773
|
lastUpdated: (/* @__PURE__ */ new Date()).toISOString()
|
|
763
774
|
};
|
|
764
775
|
await writeFile(knownPath, JSON.stringify(knownMarketplaces, null, 2));
|
|
@@ -1130,6 +1141,31 @@ function deriveMarketplaceName(source) {
|
|
|
1130
1141
|
const parts = source.replace(/\/$/, "").split("/");
|
|
1131
1142
|
return parts[parts.length - 1] ?? "plugins";
|
|
1132
1143
|
}
|
|
1144
|
+
function extractGitHubRepo(source) {
|
|
1145
|
+
const shorthand = source.match(/^([\w-]+\/[\w.-]+)$/);
|
|
1146
|
+
if (shorthand) return shorthand[1];
|
|
1147
|
+
const httpsMatch = source.match(/^https?:\/\/github\.com\/([\w.-]+\/[\w.-]+?)(?:\.git)?$/);
|
|
1148
|
+
if (httpsMatch) return httpsMatch[1];
|
|
1149
|
+
const sshMatch = source.match(/^git@github\.com:([\w.-]+\/[\w.-]+?)(?:\.git)?$/);
|
|
1150
|
+
if (sshMatch) return sshMatch[1];
|
|
1151
|
+
return null;
|
|
1152
|
+
}
|
|
1153
|
+
function isRemoteSource(source) {
|
|
1154
|
+
if (source.match(/^[\w-]+\/[\w.-]+$/)) return true;
|
|
1155
|
+
if (source.startsWith("git@")) return true;
|
|
1156
|
+
if (source.startsWith("https://") || source.startsWith("http://")) return true;
|
|
1157
|
+
return false;
|
|
1158
|
+
}
|
|
1159
|
+
function normalizeGitUrl(source) {
|
|
1160
|
+
if (source.match(/^[\w-]+\/[\w.-]+$/)) {
|
|
1161
|
+
return `https://github.com/${source}`;
|
|
1162
|
+
}
|
|
1163
|
+
const sshMatch = source.match(/^git@([^:]+):(.+?)(?:\.git)?$/);
|
|
1164
|
+
if (sshMatch) {
|
|
1165
|
+
return `https://${sshMatch[1]}/${sshMatch[2]}`;
|
|
1166
|
+
}
|
|
1167
|
+
return source;
|
|
1168
|
+
}
|
|
1133
1169
|
|
|
1134
1170
|
// lib/telemetry.ts
|
|
1135
1171
|
var TELEMETRY_URL = "https://plugins-telemetry.labs.vercel.dev/t";
|