brainjar 0.3.703 → 0.3.705
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/brainjar.js +31 -2
- package/package.json +1 -1
package/brainjar.js
CHANGED
|
@@ -107,7 +107,7 @@ var CLI_VERSION, CACHE, DAY;
|
|
|
107
107
|
var init_version_check = __esm({
|
|
108
108
|
"packages/cli/src/version-check.ts"() {
|
|
109
109
|
"use strict";
|
|
110
|
-
CLI_VERSION = "0.3.
|
|
110
|
+
CLI_VERSION = "0.3.705";
|
|
111
111
|
CACHE = path.join(os.homedir(), ".brainjar", "version-check.json");
|
|
112
112
|
DAY = 864e5;
|
|
113
113
|
}
|
|
@@ -12604,6 +12604,33 @@ async function repoRoot(cwd = process.cwd()) {
|
|
|
12604
12604
|
function repoName(root) {
|
|
12605
12605
|
return path5.basename(root) || "project";
|
|
12606
12606
|
}
|
|
12607
|
+
function parseGitRemote(url) {
|
|
12608
|
+
const s = url.trim();
|
|
12609
|
+
const scp = /^(?:[\w.-]+@)?([\w.-]+):([\w.-]+\/[\w.-]+?)(?:\.git)?\/?$/.exec(
|
|
12610
|
+
s
|
|
12611
|
+
);
|
|
12612
|
+
if (scp) return `${scp[1].toLowerCase()}/${scp[2]}`;
|
|
12613
|
+
try {
|
|
12614
|
+
const u = new URL(s);
|
|
12615
|
+
if (!/^(https?|ssh|git):$/.test(u.protocol) || !u.hostname) return null;
|
|
12616
|
+
const parts = u.pathname.replace(/\.git$/, "").split("/").filter(Boolean);
|
|
12617
|
+
if (parts.length < 2) return null;
|
|
12618
|
+
return `${u.hostname.toLowerCase()}/${parts.slice(-2).join("/")}`;
|
|
12619
|
+
} catch {
|
|
12620
|
+
return null;
|
|
12621
|
+
}
|
|
12622
|
+
}
|
|
12623
|
+
async function repoRemote(root) {
|
|
12624
|
+
try {
|
|
12625
|
+
const { stdout } = await run2("git", ["remote", "get-url", "origin"], {
|
|
12626
|
+
cwd: root,
|
|
12627
|
+
windowsHide: true
|
|
12628
|
+
});
|
|
12629
|
+
return parseGitRemote(stdout);
|
|
12630
|
+
} catch {
|
|
12631
|
+
return null;
|
|
12632
|
+
}
|
|
12633
|
+
}
|
|
12607
12634
|
async function mainRepoRoot(root) {
|
|
12608
12635
|
try {
|
|
12609
12636
|
const { stdout } = await run2(
|
|
@@ -16750,12 +16777,14 @@ async function init(argv) {
|
|
|
16750
16777
|
step(2, "Connecting the project Brain\u2026");
|
|
16751
16778
|
const known = await captureProject(root);
|
|
16752
16779
|
const reuse = known && (!brainFlag || known.brainId === brainFlag) ? known : null;
|
|
16780
|
+
const remote = await repoRemote(root);
|
|
16753
16781
|
const conn = await captureApi("/capture/connect", {
|
|
16754
16782
|
method: "POST",
|
|
16755
16783
|
body: {
|
|
16756
16784
|
name,
|
|
16757
16785
|
...brainFlag ? { brainId: brainFlag } : reuse ? { brainId: reuse.brainId } : {},
|
|
16758
|
-
...reuse ? { sourceId: reuse.sourceId } : {}
|
|
16786
|
+
...reuse ? { sourceId: reuse.sourceId } : {},
|
|
16787
|
+
...remote ? { remote } : {}
|
|
16759
16788
|
}
|
|
16760
16789
|
});
|
|
16761
16790
|
ok(
|