create-egregore 0.13.0 → 0.14.1
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 +3 -7
- package/lib/local.js +19 -4
- package/package.json +1 -1
package/lib/auth.js
CHANGED
|
@@ -5,8 +5,7 @@
|
|
|
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 CLIENT_ID = "Iv23li2obNsAjakoK2RE"; // GitHub App — clean consent, permissions via installation
|
|
10
9
|
|
|
11
10
|
function post(url, body) {
|
|
12
11
|
return new Promise((resolve, reject) => {
|
|
@@ -73,15 +72,12 @@ function copyToClipboard(text) {
|
|
|
73
72
|
/**
|
|
74
73
|
* Run GitHub Device Flow.
|
|
75
74
|
* Returns the access token string, or throws on failure.
|
|
76
|
-
* @param {object} ui - UI module for output
|
|
77
|
-
* @param {object} [opts] - Options
|
|
78
|
-
* @param {string} [opts.scope] - Override OAuth scope (e.g. "repo" for join flow)
|
|
79
75
|
*/
|
|
80
|
-
async function deviceFlow(ui
|
|
76
|
+
async function deviceFlow(ui) {
|
|
81
77
|
// 1. Request device code
|
|
82
78
|
const codeResp = await post("https://github.com/login/device/code", {
|
|
83
79
|
client_id: CLIENT_ID,
|
|
84
|
-
scope:
|
|
80
|
+
scope: "",
|
|
85
81
|
});
|
|
86
82
|
|
|
87
83
|
if (!codeResp.device_code) {
|
package/lib/local.js
CHANGED
|
@@ -568,11 +568,18 @@ async function localJoinFlow(orgArg, ui) {
|
|
|
568
568
|
explicitRepo = null;
|
|
569
569
|
}
|
|
570
570
|
|
|
571
|
-
// 1. GitHub
|
|
571
|
+
// 1. Install GitHub App — needed for the token to access repository resources
|
|
572
572
|
ui.info(`Joining ${ui.bold(orgLogin)}. First, sign in with GitHub.\n`);
|
|
573
|
+
ui.info("Install the Egregore app on your GitHub account.");
|
|
574
|
+
ui.info("This lets Egregore access the repos you've been invited to.\n");
|
|
575
|
+
openBrowser(APP_INSTALL_URL);
|
|
576
|
+
await ui.prompt("Press Enter when done...");
|
|
577
|
+
|
|
578
|
+
// 2. GitHub auth (auto-approved after App install)
|
|
579
|
+
ui.info("");
|
|
573
580
|
let githubToken;
|
|
574
581
|
try {
|
|
575
|
-
githubToken = await deviceFlow(ui
|
|
582
|
+
githubToken = await deviceFlow(ui);
|
|
576
583
|
ui.success("Authenticated with GitHub");
|
|
577
584
|
} catch (err) {
|
|
578
585
|
ui.error(`GitHub auth failed: ${err.message}`);
|
|
@@ -701,7 +708,7 @@ async function localJoinFlow(orgArg, ui) {
|
|
|
701
708
|
registerInstance(repoName, orgName, egregoreDir);
|
|
702
709
|
const alias = await installShellAlias(egregoreDir, ui);
|
|
703
710
|
|
|
704
|
-
// 11. Clone managed repos
|
|
711
|
+
// 11. Clone managed repos (retry once — git servers may lag behind invitation acceptance)
|
|
705
712
|
for (let i = 0; i < managedRepos.length; i++) {
|
|
706
713
|
const mr = managedRepos[i];
|
|
707
714
|
ui.step(6 + i, totalSteps, `Cloning ${mr}...`);
|
|
@@ -711,7 +718,15 @@ async function localJoinFlow(orgArg, ui) {
|
|
|
711
718
|
cloneRepo(repoUrl, repoDir, githubToken, ui, mr);
|
|
712
719
|
setGitIdentity(repoDir, user);
|
|
713
720
|
} catch {
|
|
714
|
-
|
|
721
|
+
// Retry after a short delay — invitation acceptance may not have propagated
|
|
722
|
+
await new Promise((r) => setTimeout(r, 3000));
|
|
723
|
+
try {
|
|
724
|
+
const repoUrl = `https://github.com/${orgLogin}/${mr}.git`;
|
|
725
|
+
cloneRepo(repoUrl, repoDir, githubToken, ui, mr);
|
|
726
|
+
setGitIdentity(repoDir, user);
|
|
727
|
+
} catch {
|
|
728
|
+
ui.warn(`Could not clone ${mr} — you may not have access yet.`);
|
|
729
|
+
}
|
|
715
730
|
}
|
|
716
731
|
}
|
|
717
732
|
|