create-op-node 0.11.1 → 0.11.2

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.js CHANGED
@@ -444,6 +444,16 @@ async function createRepoFromTemplate(input) {
444
444
  defaultBranch: res.data.default_branch ?? "main"
445
445
  };
446
446
  }
447
+ async function getRepoDefaultBranch(input) {
448
+ const parsed = parseRepoSlug(input.repo);
449
+ if (!parsed) return null;
450
+ try {
451
+ const res = await client(input.token).repos.get({ owner: parsed.owner, repo: parsed.repo });
452
+ return res.data.default_branch ?? null;
453
+ } catch {
454
+ return null;
455
+ }
456
+ }
447
457
  function parseRepoSlug(repo) {
448
458
  const slash = repo.indexOf("/");
449
459
  if (slash <= 0 || slash === repo.length - 1 || repo.indexOf("/", slash + 1) !== -1) return null;
@@ -915,7 +925,16 @@ async function createRegionRepo(args) {
915
925
  );
916
926
  process.exit(0);
917
927
  }
918
- return { fullName: newRepoFull, defaultBranch: "main" };
928
+ const fetched = await getRepoDefaultBranch({ token: ghToken, repo: newRepoFull });
929
+ if (fetched === null) {
930
+ p3.note(
931
+ pc2.yellow(
932
+ `\u26A0 Couldn't read ${newRepoFull}'s default branch \u2014 assuming "main". If the branch/PR steps fail, check the repo's default branch on GitHub.`
933
+ ),
934
+ "Notice"
935
+ );
936
+ }
937
+ return { fullName: newRepoFull, defaultBranch: fetched ?? "main" };
919
938
  }
920
939
  }
921
940
  async function seedRepoSecrets(args) {
@@ -4978,7 +4997,7 @@ function withDefaultSubcommand(argv, known) {
4978
4997
  }
4979
4998
 
4980
4999
  // src/cli.ts
4981
- var VERSION = "0.11.1";
5000
+ var VERSION = "0.11.2";
4982
5001
  var program = new Command();
4983
5002
  program.name("create-op-node").description(
4984
5003
  "Interactive bootstrap for an Opus Populi federation node.\nCloudflare infrastructure \u2192 Mac Studio \u2192 live public API."