@theholocron/cli 2.0.0-alpha.12 → 2.0.0-alpha.13
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/dist/cli.mjs +17 -7
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -1839,7 +1839,8 @@ async function runSyncGithub(input) {
|
|
|
1839
1839
|
};
|
|
1840
1840
|
}
|
|
1841
1841
|
let targetBranch = branch;
|
|
1842
|
-
|
|
1842
|
+
let defaultBranch;
|
|
1843
|
+
if (!targetBranch || createPr) {
|
|
1843
1844
|
const repoRes = await fetchFn(`${API_BASE}/repos/${owner}/${repoName}`, { headers });
|
|
1844
1845
|
if (!repoRes.ok) {
|
|
1845
1846
|
const msg = "failed to fetch repo metadata";
|
|
@@ -1852,11 +1853,13 @@ async function runSyncGithub(input) {
|
|
|
1852
1853
|
message: msg
|
|
1853
1854
|
};
|
|
1854
1855
|
}
|
|
1855
|
-
|
|
1856
|
+
defaultBranch = (await repoRes.json()).default_branch;
|
|
1857
|
+
if (!targetBranch) targetBranch = defaultBranch;
|
|
1856
1858
|
}
|
|
1857
|
-
const
|
|
1859
|
+
const baseBranch = createPr && defaultBranch ? defaultBranch : targetBranch;
|
|
1860
|
+
const refRes = await fetchFn(`${API_BASE}/repos/${owner}/${repoName}/git/ref/heads/${baseBranch}`, { headers });
|
|
1858
1861
|
if (!refRes.ok) {
|
|
1859
|
-
const msg = `Branch ${
|
|
1862
|
+
const msg = `Branch ${baseBranch} not found`;
|
|
1860
1863
|
print(` ✗ ${msg}`);
|
|
1861
1864
|
return {
|
|
1862
1865
|
status: "fail",
|
|
@@ -1979,13 +1982,20 @@ async function runSyncGithub(input) {
|
|
|
1979
1982
|
};
|
|
1980
1983
|
}
|
|
1981
1984
|
const { sha: newCommitSha } = await newCommitRes.json();
|
|
1982
|
-
const
|
|
1985
|
+
const refUpdateRes = createPr && branch ? await fetchFn(`${API_BASE}/repos/${owner}/${repoName}/git/refs`, {
|
|
1986
|
+
method: "POST",
|
|
1987
|
+
headers,
|
|
1988
|
+
body: JSON.stringify({
|
|
1989
|
+
ref: `refs/heads/${branch}`,
|
|
1990
|
+
sha: newCommitSha
|
|
1991
|
+
})
|
|
1992
|
+
}) : await fetchFn(`${API_BASE}/repos/${owner}/${repoName}/git/refs/heads/${targetBranch}`, {
|
|
1983
1993
|
method: "PATCH",
|
|
1984
1994
|
headers,
|
|
1985
1995
|
body: JSON.stringify({ sha: newCommitSha })
|
|
1986
1996
|
});
|
|
1987
|
-
if (!
|
|
1988
|
-
const msg = `failed to update ref: ${(await
|
|
1997
|
+
if (!refUpdateRes.ok) {
|
|
1998
|
+
const msg = `failed to update ref: ${(await refUpdateRes.json()).message ?? refUpdateRes.status}`;
|
|
1989
1999
|
print(` ✗ ${msg}`);
|
|
1990
2000
|
return {
|
|
1991
2001
|
status: "fail",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theholocron/cli",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.13",
|
|
4
4
|
"description": "The Holocron CLI — a pluggable, capability-based orchestrator for spinning up and operating software projects.",
|
|
5
5
|
"homepage": "https://github.com/theholocron/holocron/tree/main/packages/cli#readme",
|
|
6
6
|
"bugs": "https://github.com/theholocron/holocron/issues",
|