@theholocron/cli 2.0.0-alpha.13 → 2.0.0-alpha.14

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.
Files changed (2) hide show
  1. package/dist/cli.mjs +23 -10
  2. package/package.json +1 -1
package/dist/cli.mjs CHANGED
@@ -1361,8 +1361,10 @@ name: Sync GitHub Templates
1361
1361
  # template source files change on main or alpha.
1362
1362
  #
1363
1363
  # Secrets required:
1364
- # SYNC_TOKEN — fine-grained PAT or GitHub App token with Contents write
1365
- # access to the primary and secondary repos.
1364
+ # SYNC_TOKEN — fine-grained PAT (resource owner: org) with:
1365
+ # Contents: Read and write (git trees, blobs, refs)
1366
+ # Pull requests: Read and write (open sync PR)
1367
+ # Workflows: Read and write (write .github/workflows/*.yml)
1366
1368
 
1367
1369
  on: # yamllint disable-line rule:truthy
1368
1370
  workflow_call:
@@ -1982,14 +1984,25 @@ async function runSyncGithub(input) {
1982
1984
  };
1983
1985
  }
1984
1986
  const { sha: newCommitSha } = await newCommitRes.json();
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}`, {
1987
+ let refUpdateRes;
1988
+ if (createPr && branch) {
1989
+ refUpdateRes = await fetchFn(`${API_BASE}/repos/${owner}/${repoName}/git/refs`, {
1990
+ method: "POST",
1991
+ headers,
1992
+ body: JSON.stringify({
1993
+ ref: `refs/heads/${branch}`,
1994
+ sha: newCommitSha
1995
+ })
1996
+ });
1997
+ if (refUpdateRes.status === 422) refUpdateRes = await fetchFn(`${API_BASE}/repos/${owner}/${repoName}/git/refs/heads/${branch}`, {
1998
+ method: "PATCH",
1999
+ headers,
2000
+ body: JSON.stringify({
2001
+ sha: newCommitSha,
2002
+ force: true
2003
+ })
2004
+ });
2005
+ } else refUpdateRes = await fetchFn(`${API_BASE}/repos/${owner}/${repoName}/git/refs/heads/${targetBranch}`, {
1993
2006
  method: "PATCH",
1994
2007
  headers,
1995
2008
  body: JSON.stringify({ sha: newCommitSha })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theholocron/cli",
3
- "version": "2.0.0-alpha.13",
3
+ "version": "2.0.0-alpha.14",
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",