climaybe 3.0.4 → 3.0.5

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/bin/version.txt CHANGED
@@ -1 +1 @@
1
- 3.0.4
1
+ 3.0.5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "climaybe",
3
- "version": "3.0.4",
3
+ "version": "3.0.5",
4
4
  "description": "Shopify CLI by Electric Maybe for theme CI/CD workflows, branch orchestration, app setup, and dev tooling",
5
5
  "type": "module",
6
6
  "bin": {
@@ -6,6 +6,8 @@ import {
6
6
  currentBranch,
7
7
  ensureStagingBranch,
8
8
  createStoreBranches,
9
+ hasOriginRemote,
10
+ pushBranchesToOrigin,
9
11
  } from '../lib/git.js';
10
12
 
11
13
  /**
@@ -36,15 +38,26 @@ export async function ensureBranchesCommand() {
36
38
  console.log(pc.dim(` Mode: ${mode}-store (${aliases.length} store(s))\n`));
37
39
 
38
40
  ensureStagingBranch();
41
+ const branchesToPush = ['staging'];
39
42
  for (const alias of aliases) {
40
43
  createStoreBranches(alias);
44
+ branchesToPush.push(`staging-${alias}`, `live-${alias}`);
41
45
  }
42
46
 
43
47
  console.log(pc.bold(pc.green('\n Branches ensured.\n')));
44
- console.log(pc.dim(' Push them so CI can run:'));
45
- console.log(pc.dim(' git push origin staging'));
46
- for (const alias of aliases) {
47
- console.log(pc.dim(` git push origin staging-${alias} live-${alias}`));
48
+ if (hasOriginRemote()) {
49
+ try {
50
+ pushBranchesToOrigin(branchesToPush);
51
+ console.log(pc.green(' Pushed ensured branches to origin.\n'));
52
+ } catch (err) {
53
+ console.log(pc.yellow(` Could not push branches automatically: ${err.message}`));
54
+ console.log(pc.dim(' Push them manually so CI can run:'));
55
+ console.log(pc.dim(' git push origin --all\n'));
56
+ }
57
+ } else {
58
+ console.log(pc.dim(' No origin remote found.'));
59
+ console.log(pc.dim(' Push them after adding a remote so CI can run:'));
60
+ console.log(pc.dim(' git remote add origin <url>'));
61
+ console.log(pc.dim(' git push origin --all\n'));
48
62
  }
49
- console.log(pc.dim(' Or push all at once: git push origin --all\n'));
50
63
  }
package/src/lib/git.js CHANGED
@@ -107,6 +107,28 @@ export function ensureGitRepo(cwd = process.cwd()) {
107
107
  }
108
108
  }
109
109
 
110
+ /**
111
+ * Check if origin remote exists.
112
+ */
113
+ export function hasOriginRemote(cwd = process.cwd()) {
114
+ try {
115
+ exec('git remote get-url origin', cwd);
116
+ return true;
117
+ } catch {
118
+ return false;
119
+ }
120
+ }
121
+
122
+ /**
123
+ * Push branches to origin if remote exists.
124
+ */
125
+ export function pushBranchesToOrigin(branches = [], cwd = process.cwd()) {
126
+ if (!branches.length) return true;
127
+ const unique = [...new Set(branches)];
128
+ exec(`git push origin ${unique.join(' ')}`, cwd);
129
+ return true;
130
+ }
131
+
110
132
  /**
111
133
  * Get the latest tag version (e.g. "1.2.3") from v* tags, or null if none.
112
134
  * Sorts by version so v2.0.0 > v1.9.9.