create-egregore 0.17.2 → 0.17.3

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.
Files changed (2) hide show
  1. package/lib/local.js +28 -12
  2. package/package.json +1 -1
package/lib/local.js CHANGED
@@ -693,14 +693,34 @@ async function localFounderFlow(ui, ctx = {}) {
693
693
 
694
694
  // ── Flow 2: Join (local mode) ──────────────────────────────────────
695
695
 
696
+ // Accepts: "org", "org/repo", "https://github.com/org/repo(.git)",
697
+ // "git@github.com:org/repo(.git)". Returns { orgLogin, explicitRepo }.
698
+ function parseJoinTarget(arg) {
699
+ if (!arg) return { orgLogin: null, explicitRepo: null };
700
+ let raw = String(arg).trim();
701
+
702
+ const ssh = raw.match(/^git@[^:]+:(.+)$/);
703
+ if (ssh) raw = ssh[1];
704
+
705
+ if (/^https?:\/\//i.test(raw)) {
706
+ try {
707
+ raw = new URL(raw).pathname;
708
+ } catch {
709
+ // fall through
710
+ }
711
+ }
712
+
713
+ raw = raw.replace(/\.git$/i, "").replace(/^\/+|\/+$/g, "");
714
+ const parts = raw.split("/").filter(Boolean);
715
+ if (parts.length === 0) return { orgLogin: null, explicitRepo: null };
716
+ return { orgLogin: parts[0], explicitRepo: parts[1] || null };
717
+ }
718
+
696
719
  async function localJoinFlow(orgArg, ui, ctx = {}) {
697
- // Parse org/repo if provided (e.g., "acme-org/ops-team")
698
- let orgLogin, explicitRepo;
699
- if (orgArg.includes("/")) {
700
- [orgLogin, explicitRepo] = orgArg.split("/", 2);
701
- } else {
702
- orgLogin = orgArg;
703
- explicitRepo = null;
720
+ const { orgLogin, explicitRepo } = parseJoinTarget(orgArg);
721
+ if (!orgLogin) {
722
+ ui.error("Usage: npx create-egregore join <org>[/<repo>]");
723
+ process.exit(1);
704
724
  }
705
725
 
706
726
  // 1. GitHub auth — OAuth with repo:invite scope (narrow: just invitation acceptance)
@@ -725,10 +745,6 @@ async function localJoinFlow(orgArg, ui, ctx = {}) {
725
745
 
726
746
  // 4. Determine repo name
727
747
  const repoName = explicitRepo || "egregore";
728
- if (!repoName) {
729
- ui.error("Usage: npx create-egregore join <org>/<repo>");
730
- process.exit(1);
731
- }
732
748
 
733
749
  // 5. Clone repos using git credentials (SSH keys / gh CLI / credential helper)
734
750
  // The OAuth token only has repo:invite scope — cloning uses the joiner's own git setup.
@@ -870,4 +886,4 @@ async function localJoinFlow(orgArg, ui, ctx = {}) {
870
886
  console.log("");
871
887
  }
872
888
 
873
- module.exports = { localFounderFlow, localJoinFlow, addCollaborator, getUser, repoExists, createRepo, waitForRepo };
889
+ module.exports = { localFounderFlow, localJoinFlow, parseJoinTarget, addCollaborator, getUser, repoExists, createRepo, waitForRepo };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-egregore",
3
- "version": "0.17.2",
3
+ "version": "0.17.3",
4
4
  "description": "Set up Egregore for your team in one command",
5
5
  "license": "MIT",
6
6
  "bin": {