climaybe 2.2.3 → 2.2.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/README.md CHANGED
@@ -209,7 +209,7 @@ Direct pushes to `staging-<store>` or `live-<store>` are automatically synced ba
209
209
 
210
210
  | Workflow | Trigger | What it does |
211
211
  |----------|---------|-------------|
212
- | `main-to-staging-stores.yml` (main-to-staging-&lt;store&gt;) | Push to `main` | Merges main into each `staging-<alias>`; root JSONs ignored. For hotfix-backport, skips the store that sent the hotfix; other stores get the merge. Skips only on pure store-sync. |
212
+ | `main-to-staging-stores.yml` (main-to-staging-&lt;store&gt;) | Push to `main` | Merges main into each `staging-<alias>`; root JSONs ignored. For hotfix-backport: if source is `staging-<alias>`, that same staging branch is skipped; if source is `live-<alias>`, `staging-<alias>` is also synced. Skips only on pure store-sync. |
213
213
  | `stores-to-root.yml` | Push to `staging-*` | From main merge: stores→root. From elsewhere (e.g. Shopify): root→stores |
214
214
  | `pr-to-live.yml` | After stores-to-root | Opens PR from `staging-<alias>` to `live-<alias>` |
215
215
  | `root-to-stores.yml` | Push to `live-*` | From main merge: stores→root. From elsewhere: root→stores (same as stores-to-root on staging-*) |
@@ -268,7 +268,7 @@ You can install/update this later with:
268
268
  - **No tags yet?** The system uses `theme_version` from `config/settings_schema.json` (`theme_info`), creates that tag on main (e.g. `v1.0.0`), and continues from there.
269
269
  - **Staging → main**: On PR, a pre-release patch tag (e.g. v3.1.13) locks the current minor line; on merge, **minor** bump (e.g. v3.1.13 → v3.2.0).
270
270
  - **Non-staging to main** (hotfix backports, direct commits): **Patch** bump only, via **nightly workflow** at 02:00 US Eastern (not at commit time).
271
- - **Version bump runs only on main** (post-merge-tag and nightly-hotfix). Main-to-staging-stores merges main into each `staging-<alias>` on every push (version bumps and hotfixes). When the push is a hotfix from one store (e.g. live-norway), that store’s staging branch is skipped; other stores’ staging branches still get the merge.
271
+ - **Version bump runs only on main** (post-merge-tag and nightly-hotfix). Main-to-staging-stores merges main into each `staging-<alias>` on every push (version bumps and hotfixes). For hotfix-backport, only a `staging-<alias> -> main` source skips syncing back to the same staging branch; a `live-<alias> -> main` source still syncs into `staging-<alias>`.
272
272
  - Version bumps update `config/settings_schema.json` and, when present, `package.json` `version`.
273
273
  - **Safety**: The version-bump workflow fails if the new tag would not be **strictly higher** than the latest merged release tag (semver), so the release line cannot step backward.
274
274
 
package/bin/cli.js CHANGED
@@ -1,25 +1,22 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { readFileSync, existsSync } from 'node:fs';
4
3
  import { createRequire } from 'node:module';
5
4
  import { dirname, join } from 'node:path';
6
5
  import { fileURLToPath } from 'node:url';
7
6
  import { run } from '../src/index.js';
7
+ import { resolveCliVersion } from '../src/lib/cli-version.js';
8
8
  import { maybeOfferCliUpdate } from '../src/lib/update-notifier.js';
9
9
 
10
10
  const require = createRequire(import.meta.url);
11
11
  const binDir = dirname(fileURLToPath(import.meta.url));
12
12
  const packageDir = join(binDir, '..');
13
13
 
14
- // Prefer version baked at publish (bin/version.txt) so the running binary always reports its own version
15
- const versionFile = join(binDir, 'version.txt');
16
- let version;
17
- if (existsSync(versionFile)) {
18
- version = readFileSync(versionFile, 'utf8').trim();
19
- } else {
20
- version = require(join(packageDir, 'package.json')).version;
21
- }
22
-
23
- const packageName = require(join(packageDir, 'package.json')).name || 'climaybe';
14
+ const pkg = require(join(packageDir, 'package.json'));
15
+ const version = resolveCliVersion({
16
+ packageDir,
17
+ binDir,
18
+ packageVersion: pkg.version,
19
+ });
20
+ const packageName = pkg.name || 'climaybe';
24
21
  await maybeOfferCliUpdate({ packageName, currentVersion: version, packageDir });
25
22
  run(process.argv, version, packageDir);
package/bin/version.txt CHANGED
@@ -1 +1 @@
1
- 2.2.3
1
+ 2.2.5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "climaybe",
3
- "version": "2.2.3",
3
+ "version": "2.2.5",
4
4
  "description": "Shopify CLI — theme CI/CD (workflows, branches, stores) and app repo helpers; also: commitlint and Cursor rules/skills",
5
5
  "type": "module",
6
6
  "bin": {
@@ -0,0 +1,20 @@
1
+ import { existsSync, readFileSync } from 'node:fs';
2
+ import { join } from 'node:path';
3
+
4
+ /**
5
+ * Resolve the version shown by the CLI.
6
+ * - In dev checkouts (e.g. npm link), prefer package.json.
7
+ * - In packaged installs, prefer bin/version.txt and fallback to package.json.
8
+ */
9
+ export function resolveCliVersion({ packageDir, binDir, packageVersion }) {
10
+ const devCheckout = existsSync(join(packageDir, '.git'));
11
+ if (devCheckout) return packageVersion;
12
+
13
+ const versionFile = join(binDir, 'version.txt');
14
+ if (existsSync(versionFile)) {
15
+ const baked = readFileSync(versionFile, 'utf8').trim();
16
+ if (baked) return baked;
17
+ }
18
+
19
+ return packageVersion;
20
+ }
@@ -3,12 +3,16 @@ const path = require('path');
3
3
  const ROOT_DIR = process.cwd();
4
4
 
5
5
  function extractImports(content) {
6
- const importRegex = /^\s*import\s+(?:[^'"\n;]+?\s+from\s+)?['"]([^'"]+)['"]\s*;?\s*$/gm;
7
6
  const imports = [];
7
+ const fromImportRegex = /(^|\n)\s*import\s+[\s\S]*?\s+from\s+['"]([^'"]+)['"]\s*;?/g;
8
+ const sideEffectImportRegex = /(^|\n)\s*import\s+['"]([^'"]+)['"]\s*;?/g;
8
9
  let match;
9
10
 
10
- while ((match = importRegex.exec(content)) !== null) {
11
- imports.push(match[1]);
11
+ while ((match = fromImportRegex.exec(content)) !== null) {
12
+ imports.push(match[2]);
13
+ }
14
+ while ((match = sideEffectImportRegex.exec(content)) !== null) {
15
+ imports.push(match[2]);
12
16
  }
13
17
 
14
18
  return imports;
@@ -36,7 +40,12 @@ function processScriptFile(filePath, processedFiles = new Set()) {
36
40
  importedContent += processScriptFile(importPath, processedFiles);
37
41
  }
38
42
 
39
- content = content.replace(/^\s*import\s+(?:[^'"\n;]+?\s+from\s+)?['"][^'"]+['"]\s*;?\s*$/gm, '');
43
+ // Remove import statements (including multiline "import { ... } from '...'" forms).
44
+ content = content.replace(/(^|\n)\s*import\s+[\s\S]*?\s+from\s+['"][^'"]+['"]\s*;?/g, '$1');
45
+ content = content.replace(/(^|\n)\s*import\s+['"][^'"]+['"]\s*;?/g, '$1');
46
+ content = content.replace(/^\s*export\s+default\s+/gm, '');
47
+ content = content.replace(/^\s*export\s+\{[^}]*\}\s*;?\s*$/gm, '');
48
+ content = content.replace(/^\s*export\s+(?=(const|let|var|function|class)\b)/gm, '');
40
49
 
41
50
  if (process.env.NODE_ENV === 'production') {
42
51
  content = content.replace(/\/\*\*[\s\S]*?\*\//g, '');
@@ -4,7 +4,9 @@
4
4
  # merge brings main in but we immediately restore root from stores/<alias>/ so store-specific data is kept.
5
5
  # Runs on every push to main except pure store-sync commits ([stores-to-root], [root-to-stores]), so that:
6
6
  # - Version-bump commits: staging-<alias> get the new version.
7
- # - Hotfix backports (live or staging-<alias> → main): other staging-<alias> get those changes; the store that sent the hotfix is skipped (no need to merge back to the same branch).
7
+ # - Hotfix backports:
8
+ # - staging-<alias> → main: skip syncing back into the same staging-<alias> (already has the change).
9
+ # - live-<alias> → main: sync into staging-<alias> too (so staging gets the live hotfix).
8
10
  #
9
11
  # Also runs when Post-Merge Tag or Nightly Hotfix Tag complete: version-bump pushes with GITHUB_TOKEN,
10
12
  # which does not trigger push-based workflows, so we explicitly run sync after those workflows finish.
@@ -25,7 +27,7 @@ concurrency:
25
27
  cancel-in-progress: false
26
28
 
27
29
  jobs:
28
- # Gate: skip only pure store-sync commits. When hotfix-backport, extract source branch alias so we skip merging back into that same store.
30
+ # Gate: skip only pure store-sync commits. For hotfix-backport, skip syncing back only when source was staging-<alias>.
29
31
  # When triggered by workflow_run (version-bump finished), run sync if the workflow succeeded.
30
32
  gate:
31
33
  runs-on: ubuntu-latest
@@ -33,7 +35,7 @@ jobs:
33
35
  if: github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success'
34
36
  outputs:
35
37
  should_run: ${{ steps.check.outputs.should_run }}
36
- hotfix_source_alias: ${{ steps.check.outputs.hotfix_source_alias }}
38
+ hotfix_skip_alias: ${{ steps.check.outputs.hotfix_skip_alias }}
37
39
  steps:
38
40
  - name: Check commit message and hotfix source
39
41
  id: check
@@ -41,7 +43,7 @@ jobs:
41
43
  if [ "${{ github.event_name }}" = "workflow_run" ]; then
42
44
  echo "Triggered by workflow_run (version-bump finished); syncing main to staging."
43
45
  echo "should_run=true" >> $GITHUB_OUTPUT
44
- echo "hotfix_source_alias=" >> $GITHUB_OUTPUT
46
+ echo "hotfix_skip_alias=" >> $GITHUB_OUTPUT
45
47
  exit 0
46
48
  fi
47
49
 
@@ -50,22 +52,21 @@ jobs:
50
52
  if echo "$COMMIT_MSG" | grep -qE "\[skip-store-sync\]|\[stores-to-root\]|\[root-to-stores\]"; then
51
53
  echo "Skipping — store sync commit (avoid loop)"
52
54
  echo "should_run=false" >> $GITHUB_OUTPUT
53
- echo "hotfix_source_alias=" >> $GITHUB_OUTPUT
55
+ echo "hotfix_skip_alias=" >> $GITHUB_OUTPUT
54
56
  exit 0
55
57
  fi
56
58
 
57
59
  echo "should_run=true" >> $GITHUB_OUTPUT
58
60
 
59
- # If hotfix-backport, extract source branch alias (e.g. staging-norway or live-norway → norway) so we skip that store in sync
60
- HOTFIX_SOURCE_ALIAS=""
61
+ # If hotfix-backport came from staging-<alias>, skip syncing back to that same staging branch.
62
+ HOTFIX_SKIP_ALIAS=""
61
63
  if echo "$COMMIT_MSG" | grep -q "\[hotfix-backport\]"; then
62
64
  SOURCE_BRANCH=$(echo "$COMMIT_MSG" | sed -n 's/.*Merge \([^ ]*\) into main.*/\1/p' | head -1)
63
- if [ -n "$SOURCE_BRANCH" ]; then
64
- HOTFIX_SOURCE_ALIAS="${SOURCE_BRANCH#staging-}"
65
- HOTFIX_SOURCE_ALIAS="${HOTFIX_SOURCE_ALIAS#live-}"
65
+ if [[ -n "$SOURCE_BRANCH" && "$SOURCE_BRANCH" == staging-* ]]; then
66
+ HOTFIX_SKIP_ALIAS="${SOURCE_BRANCH#staging-}"
66
67
  fi
67
68
  fi
68
- echo "hotfix_source_alias=$HOTFIX_SOURCE_ALIAS" >> $GITHUB_OUTPUT
69
+ echo "hotfix_skip_alias=$HOTFIX_SKIP_ALIAS" >> $GITHUB_OUTPUT
69
70
 
70
71
  # Read store list from package.json
71
72
  config:
@@ -88,7 +89,8 @@ jobs:
88
89
  echo "stores=$STORES" >> $GITHUB_OUTPUT
89
90
  echo "Store aliases: $STORES"
90
91
 
91
- # Merge main into each staging-<alias>; root JSONs ignored (restored from stores/<alias>/). Skip the store that sent the hotfix (no need to merge back).
92
+ # Merge main into each staging-<alias>; root JSONs ignored (restored from stores/<alias>/).
93
+ # Skip only staging-origin hotfix source branch (no need to merge back to same staging branch).
92
94
  sync:
93
95
  needs: [gate, config]
94
96
  if: needs.gate.outputs.should_run == 'true'
@@ -103,7 +105,7 @@ jobs:
103
105
  actions: write
104
106
  env:
105
107
  GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
106
- HOTFIX_SOURCE_ALIAS: ${{ needs.gate.outputs.hotfix_source_alias }}
108
+ HOTFIX_SKIP_ALIAS: ${{ needs.gate.outputs.hotfix_skip_alias }}
107
109
  steps:
108
110
  - uses: actions/checkout@v4
109
111
  with:
@@ -116,8 +118,8 @@ jobs:
116
118
  ALIAS="${{ matrix.store }}"
117
119
  STORE_DIR="stores/${ALIAS}"
118
120
 
119
- if [ -n "$HOTFIX_SOURCE_ALIAS" ] && [ "$HOTFIX_SOURCE_ALIAS" = "$ALIAS" ]; then
120
- echo "Hotfix came from staging-$ALIAS or live-$ALIAS, skipping (no need to merge back to same store)."
121
+ if [ -n "$HOTFIX_SKIP_ALIAS" ] && [ "$HOTFIX_SKIP_ALIAS" = "$ALIAS" ]; then
122
+ echo "Hotfix came from staging-$ALIAS, skipping (no need to merge back to same staging branch)."
121
123
  exit 0
122
124
  fi
123
125