create-egregore 0.13.0 → 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) => {
@@ -75,13 +76,17 @@ function copyToClipboard(text) {
75
76
  * Returns the access token string, or throws on failure.
76
77
  * @param {object} ui - UI module for output
77
78
  * @param {object} [opts] - Options
78
- * @param {string} [opts.scope] - Override OAuth scope (e.g. "repo" for join flow)
79
+ * @param {string} [opts.mode] - "join" uses OAuth App with repo scope; default uses GitHub App
79
80
  */
80
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
+
81
86
  // 1. Request device code
82
87
  const codeResp = await post("https://github.com/login/device/code", {
83
- client_id: CLIENT_ID,
84
- scope: opts.scope ?? SCOPE,
88
+ client_id: clientId,
89
+ scope,
85
90
  });
86
91
 
87
92
  if (!codeResp.device_code) {
@@ -115,7 +120,7 @@ async function deviceFlow(ui, opts = {}) {
115
120
  await sleep(interval);
116
121
 
117
122
  const tokenResp = await post("https://github.com/login/oauth/access_token", {
118
- client_id: CLIENT_ID,
123
+ client_id: clientId,
119
124
  device_code,
120
125
  grant_type: "urn:ietf:params:oauth:grant-type:device_code",
121
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 — repo scope needed to access repos on other accounts
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, { scope: "repo" });
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.13.0",
3
+ "version": "0.14.0",
4
4
  "description": "Set up Egregore for your team in one command",
5
5
  "license": "MIT",
6
6
  "bin": {