create-egregore 0.12.6 → 0.14.0

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/lib/auth.js CHANGED
@@ -5,8 +5,9 @@
5
5
 
6
6
  const https = require("node:https");
7
7
 
8
- const CLIENT_ID = "Iv23li2obNsAjakoK2RE";
9
- const SCOPE = ""; // GitHub App — permissions managed via installation, not OAuth scope
8
+ const GITHUB_APP_CLIENT_ID = "Iv23li2obNsAjakoK2RE"; // GitHub App — for founder flow
9
+ const OAUTH_APP_CLIENT_ID = "Ov23liYZjJbbbNgnJ9vH"; // OAuth App — for join flow
10
+ const OAUTH_JOIN_SCOPE = "repo"; // Minimal scope for cross-account access
10
11
 
11
12
  function post(url, body) {
12
13
  return new Promise((resolve, reject) => {
@@ -73,12 +74,19 @@ function copyToClipboard(text) {
73
74
  /**
74
75
  * Run GitHub Device Flow.
75
76
  * Returns the access token string, or throws on failure.
77
+ * @param {object} ui - UI module for output
78
+ * @param {object} [opts] - Options
79
+ * @param {string} [opts.mode] - "join" uses OAuth App with repo scope; default uses GitHub App
76
80
  */
77
- async function deviceFlow(ui) {
81
+ async function deviceFlow(ui, opts = {}) {
82
+ const isJoin = opts.mode === "join";
83
+ const clientId = isJoin ? OAUTH_APP_CLIENT_ID : GITHUB_APP_CLIENT_ID;
84
+ const scope = isJoin ? OAUTH_JOIN_SCOPE : "";
85
+
78
86
  // 1. Request device code
79
87
  const codeResp = await post("https://github.com/login/device/code", {
80
- client_id: CLIENT_ID,
81
- scope: SCOPE,
88
+ client_id: clientId,
89
+ scope,
82
90
  });
83
91
 
84
92
  if (!codeResp.device_code) {
@@ -112,7 +120,7 @@ async function deviceFlow(ui) {
112
120
  await sleep(interval);
113
121
 
114
122
  const tokenResp = await post("https://github.com/login/oauth/access_token", {
115
- client_id: CLIENT_ID,
123
+ client_id: clientId,
116
124
  device_code,
117
125
  grant_type: "urn:ietf:params:oauth:grant-type:device_code",
118
126
  });
package/lib/local.js CHANGED
@@ -568,11 +568,11 @@ async function localJoinFlow(orgArg, ui) {
568
568
  explicitRepo = null;
569
569
  }
570
570
 
571
- // 1. GitHub auth
571
+ // 1. GitHub auth — OAuth App with repo scope for cross-account access
572
572
  ui.info(`Joining ${ui.bold(orgLogin)}. First, sign in with GitHub.\n`);
573
573
  let githubToken;
574
574
  try {
575
- githubToken = await deviceFlow(ui);
575
+ githubToken = await deviceFlow(ui, { mode: "join" });
576
576
  ui.success("Authenticated with GitHub");
577
577
  } catch (err) {
578
578
  ui.error(`GitHub auth failed: ${err.message}`);
@@ -701,7 +701,7 @@ async function localJoinFlow(orgArg, ui) {
701
701
  registerInstance(repoName, orgName, egregoreDir);
702
702
  const alias = await installShellAlias(egregoreDir, ui);
703
703
 
704
- // 11. Clone managed repos
704
+ // 11. Clone managed repos (retry once — git servers may lag behind invitation acceptance)
705
705
  for (let i = 0; i < managedRepos.length; i++) {
706
706
  const mr = managedRepos[i];
707
707
  ui.step(6 + i, totalSteps, `Cloning ${mr}...`);
@@ -711,7 +711,15 @@ async function localJoinFlow(orgArg, ui) {
711
711
  cloneRepo(repoUrl, repoDir, githubToken, ui, mr);
712
712
  setGitIdentity(repoDir, user);
713
713
  } catch {
714
- ui.warn(`Could not clone ${mr} — you may not have access yet.`);
714
+ // Retry after a short delay — invitation acceptance may not have propagated
715
+ await new Promise((r) => setTimeout(r, 3000));
716
+ try {
717
+ const repoUrl = `https://github.com/${orgLogin}/${mr}.git`;
718
+ cloneRepo(repoUrl, repoDir, githubToken, ui, mr);
719
+ setGitIdentity(repoDir, user);
720
+ } catch {
721
+ ui.warn(`Could not clone ${mr} — you may not have access yet.`);
722
+ }
715
723
  }
716
724
  }
717
725
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-egregore",
3
- "version": "0.12.6",
3
+ "version": "0.14.0",
4
4
  "description": "Set up Egregore for your team in one command",
5
5
  "license": "MIT",
6
6
  "bin": {