create-egregore 0.3.9 → 0.3.10
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/setup.js +23 -7
- package/package.json +1 -1
package/lib/setup.js
CHANGED
|
@@ -23,8 +23,9 @@ async function install(data, ui, targetDir) {
|
|
|
23
23
|
const { fork_url, memory_url, github_token, org_name, github_org, slug, api_key, repos = [], telegram_group_link } = data;
|
|
24
24
|
const base = targetDir || process.cwd();
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
const
|
|
26
|
+
// Directory name from fork URL (what git clone would use), e.g. "egregore-core"
|
|
27
|
+
const forkDirName = fork_url.split("/").pop().replace(/\.git$/, "");
|
|
28
|
+
const egregoreDir = path.join(base, forkDirName);
|
|
28
29
|
const memoryDirName = memory_url
|
|
29
30
|
.split("/")
|
|
30
31
|
.pop()
|
|
@@ -36,13 +37,18 @@ async function install(data, ui, targetDir) {
|
|
|
36
37
|
// Configure git credential helper for HTTPS cloning
|
|
37
38
|
configureGitCredentials(github_token);
|
|
38
39
|
|
|
40
|
+
// Embed token in URLs as fallback for private repos (credential helper may not work)
|
|
41
|
+
const authedForkUrl = embedToken(fork_url, github_token);
|
|
42
|
+
const authedMemoryUrl = embedToken(memory_url, github_token);
|
|
43
|
+
|
|
39
44
|
// 1. Clone fork
|
|
40
45
|
ui.step(1, totalSteps, "Cloning egregore...");
|
|
41
46
|
if (fs.existsSync(egregoreDir)) {
|
|
42
47
|
ui.warn("egregore/ already exists — pulling latest");
|
|
43
48
|
run("git pull", { cwd: egregoreDir });
|
|
44
49
|
} else {
|
|
45
|
-
execFileSync("git", ["clone",
|
|
50
|
+
execFileSync("git", ["clone", authedForkUrl, egregoreDir], { stdio: "pipe", encoding: "utf-8", timeout: 60000 });
|
|
51
|
+
try { run(`git remote set-url origin ${fork_url}`, { cwd: egregoreDir }); } catch {}
|
|
46
52
|
}
|
|
47
53
|
ui.success("Cloned egregore");
|
|
48
54
|
|
|
@@ -52,7 +58,8 @@ async function install(data, ui, targetDir) {
|
|
|
52
58
|
ui.warn(`${memoryDirName}/ already exists — pulling latest`);
|
|
53
59
|
run("git pull", { cwd: memoryDir });
|
|
54
60
|
} else {
|
|
55
|
-
execFileSync("git", ["clone",
|
|
61
|
+
execFileSync("git", ["clone", authedMemoryUrl, memoryDir], { stdio: "pipe", encoding: "utf-8", timeout: 60000 });
|
|
62
|
+
try { run(`git remote set-url origin ${memory_url}`, { cwd: memoryDir }); } catch {}
|
|
56
63
|
}
|
|
57
64
|
ui.success("Cloned memory");
|
|
58
65
|
|
|
@@ -82,7 +89,7 @@ async function install(data, ui, targetDir) {
|
|
|
82
89
|
|
|
83
90
|
// 5. Register instance + shell alias
|
|
84
91
|
ui.step(5, totalSteps, "Registering instance...");
|
|
85
|
-
registerInstance(
|
|
92
|
+
registerInstance(forkDirName, org_name, egregoreDir);
|
|
86
93
|
const alias = await installShellAlias(egregoreDir, ui);
|
|
87
94
|
|
|
88
95
|
// 6+. Clone managed repos (if any)
|
|
@@ -96,7 +103,8 @@ async function install(data, ui, targetDir) {
|
|
|
96
103
|
run("git pull", { cwd: repoDir });
|
|
97
104
|
} else {
|
|
98
105
|
const repoUrl = `https://github.com/${github_org}/${repoName}.git`;
|
|
99
|
-
execFileSync("git", ["clone", repoUrl, repoDir], { stdio: "pipe", encoding: "utf-8", timeout: 60000 });
|
|
106
|
+
execFileSync("git", ["clone", embedToken(repoUrl, github_token), repoDir], { stdio: "pipe", encoding: "utf-8", timeout: 60000 });
|
|
107
|
+
try { run(`git remote set-url origin ${repoUrl}`, { cwd: repoDir }); } catch {}
|
|
100
108
|
}
|
|
101
109
|
clonedRepos.push(repoName);
|
|
102
110
|
ui.success(`Cloned ${repoName}`);
|
|
@@ -107,7 +115,7 @@ async function install(data, ui, targetDir) {
|
|
|
107
115
|
ui.success(`Egregore is ready for ${ui.bold(org_name)}`);
|
|
108
116
|
console.log("");
|
|
109
117
|
ui.info(`Your workspace:`);
|
|
110
|
-
ui.info(` ${ui.cyan(
|
|
118
|
+
ui.info(` ${ui.cyan(`./${forkDirName}/`)} — Your Egregore instance`);
|
|
111
119
|
ui.info(` ${ui.cyan(`./${memoryDirName}/`)} — Shared knowledge`);
|
|
112
120
|
for (const repoName of clonedRepos) {
|
|
113
121
|
ui.info(` ${ui.cyan(`./${repoName}/`)} — Managed repo`);
|
|
@@ -122,6 +130,14 @@ async function install(data, ui, targetDir) {
|
|
|
122
130
|
console.log("");
|
|
123
131
|
}
|
|
124
132
|
|
|
133
|
+
function embedToken(url, token) {
|
|
134
|
+
try {
|
|
135
|
+
return url.replace("https://github.com/", `https://x-access-token:${token}@github.com/`);
|
|
136
|
+
} catch {
|
|
137
|
+
return url;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
125
141
|
function configureGitCredentials(token) {
|
|
126
142
|
try {
|
|
127
143
|
run("git config credential.helper store");
|