climaybe 1.4.2 → 1.5.0
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 +21 -6
- package/bin/version.txt +1 -1
- package/package.json +1 -1
- package/src/commands/ensure-branches.js +52 -0
- package/src/commands/init.js +13 -10
- package/src/index.js +6 -0
package/README.md
CHANGED
|
@@ -4,15 +4,21 @@ Shopify CI/CD CLI — scaffolds GitHub Actions workflows, branch strategy, and s
|
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
7
|
+
Install in your theme repo (project-only, no global install):
|
|
8
|
+
|
|
7
9
|
```bash
|
|
8
|
-
|
|
10
|
+
cd your-shopify-theme-repo
|
|
11
|
+
npm install -D climaybe
|
|
9
12
|
```
|
|
10
13
|
|
|
14
|
+
Run commands with `npx climaybe` (or add scripts to your `package.json`).
|
|
15
|
+
|
|
11
16
|
## Quick Start
|
|
12
17
|
|
|
13
18
|
```bash
|
|
14
19
|
cd your-shopify-theme-repo
|
|
15
|
-
climaybe
|
|
20
|
+
npm install -D climaybe
|
|
21
|
+
npx climaybe init
|
|
16
22
|
```
|
|
17
23
|
|
|
18
24
|
The interactive setup will ask for your store URL(s) and configure everything automatically.
|
|
@@ -38,7 +44,7 @@ Interactive setup that configures your repo for CI/CD.
|
|
|
38
44
|
Add a new store to an existing setup.
|
|
39
45
|
|
|
40
46
|
```bash
|
|
41
|
-
climaybe add-store
|
|
47
|
+
npx climaybe add-store
|
|
42
48
|
```
|
|
43
49
|
|
|
44
50
|
- Prompts for new store URL + alias
|
|
@@ -51,7 +57,7 @@ climaybe add-store
|
|
|
51
57
|
Switch your local dev environment to a specific store (multi-store only).
|
|
52
58
|
|
|
53
59
|
```bash
|
|
54
|
-
climaybe switch voldt-norway
|
|
60
|
+
npx climaybe switch voldt-norway
|
|
55
61
|
```
|
|
56
62
|
|
|
57
63
|
Copies `stores/<alias>/` JSON files to the repo root so you can preview that store locally.
|
|
@@ -61,17 +67,26 @@ Copies `stores/<alias>/` JSON files to the repo root so you can preview that sto
|
|
|
61
67
|
Sync root JSON files back to a store directory (multi-store only).
|
|
62
68
|
|
|
63
69
|
```bash
|
|
64
|
-
climaybe sync voldt-norway
|
|
70
|
+
npx climaybe sync voldt-norway
|
|
65
71
|
```
|
|
66
72
|
|
|
67
73
|
If no alias is given, syncs to the default store.
|
|
68
74
|
|
|
75
|
+
### `climaybe ensure-branches`
|
|
76
|
+
|
|
77
|
+
Create missing `staging` and per-store branches (`staging-<alias>`, `live-<alias>`) from your current branch (usually `main`). Use when the repo only has `main` (e.g. after a fresh clone) so the main → staging-<store> sync can run.
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
npx climaybe ensure-branches
|
|
81
|
+
git push origin --all
|
|
82
|
+
```
|
|
83
|
+
|
|
69
84
|
### `climaybe update-workflows`
|
|
70
85
|
|
|
71
86
|
Refresh GitHub Actions workflows from the latest bundled templates.
|
|
72
87
|
|
|
73
88
|
```bash
|
|
74
|
-
climaybe update-workflows
|
|
89
|
+
npx climaybe update-workflows
|
|
75
90
|
```
|
|
76
91
|
|
|
77
92
|
Useful after updating the CLI to get the latest workflow improvements.
|
package/bin/version.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.
|
|
1
|
+
1.5.0
|
package/package.json
CHANGED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import pc from 'picocolors';
|
|
2
|
+
import { readConfig } from '../lib/config.js';
|
|
3
|
+
import {
|
|
4
|
+
isGitRepo,
|
|
5
|
+
currentBranch,
|
|
6
|
+
ensureStagingBranch,
|
|
7
|
+
createStoreBranches,
|
|
8
|
+
} from '../lib/git.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Create missing staging and per-store branches from current HEAD.
|
|
12
|
+
* Use when the repo only has main (e.g. after clone) so the main → staging-<store> sync can run.
|
|
13
|
+
*/
|
|
14
|
+
export async function ensureBranchesCommand() {
|
|
15
|
+
console.log(pc.bold('\n climaybe — Ensure Branches\n'));
|
|
16
|
+
|
|
17
|
+
const config = readConfig();
|
|
18
|
+
if (!config?.stores) {
|
|
19
|
+
console.log(pc.red(' No climaybe config found. Run "climaybe init" first.\n'));
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (!isGitRepo()) {
|
|
24
|
+
console.log(pc.red(' Not a git repository. Run "git init" or clone the repo first.\n'));
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const branch = currentBranch();
|
|
29
|
+
const aliases = Object.keys(config.stores);
|
|
30
|
+
const mode = aliases.length > 1 ? 'multi' : 'single';
|
|
31
|
+
|
|
32
|
+
console.log(pc.dim(` Current branch: ${branch}`));
|
|
33
|
+
console.log(pc.dim(` Mode: ${mode}-store (${aliases.length} store(s))\n`));
|
|
34
|
+
|
|
35
|
+
ensureStagingBranch();
|
|
36
|
+
|
|
37
|
+
if (mode === 'multi') {
|
|
38
|
+
for (const alias of aliases) {
|
|
39
|
+
createStoreBranches(alias);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
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
|
+
if (mode === 'multi') {
|
|
47
|
+
for (const alias of aliases) {
|
|
48
|
+
console.log(pc.dim(` git push origin staging-${alias} live-${alias}`));
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
console.log(pc.dim(' Or push all at once: git push origin --all\n'));
|
|
52
|
+
}
|
package/src/commands/init.js
CHANGED
|
@@ -140,12 +140,12 @@ async function runInitFlow() {
|
|
|
140
140
|
const existingNames =
|
|
141
141
|
ciHost === 'github' ? listGitHubSecrets() : listGitLabVariables();
|
|
142
142
|
const namesWeWillPrompt = new Set(secretsToPrompt.map((s) => s.name));
|
|
143
|
-
const alreadySet = existingNames.filter((n) => namesWeWillPrompt.has(n));
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
143
|
+
const alreadySet = new Set(existingNames.filter((n) => namesWeWillPrompt.has(n)));
|
|
144
|
+
let doUpdateExisting = true;
|
|
145
|
+
if (alreadySet.size > 0) {
|
|
146
|
+
doUpdateExisting = await promptUpdateExistingSecrets([...alreadySet]);
|
|
147
|
+
if (!doUpdateExisting) {
|
|
148
|
+
console.log(pc.dim('\n Skipping only the secret(s) already set; will still prompt for the rest.\n'));
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
151
|
|
|
@@ -159,6 +159,7 @@ async function runInitFlow() {
|
|
|
159
159
|
stores,
|
|
160
160
|
});
|
|
161
161
|
for (const { name, value } of storeUrlSecrets) {
|
|
162
|
+
if (alreadySet.has(name) && !doUpdateExisting) continue;
|
|
162
163
|
try {
|
|
163
164
|
await setter.set(name, value);
|
|
164
165
|
console.log(pc.green(` Set ${name} (from store config).`));
|
|
@@ -168,10 +169,12 @@ async function runInitFlow() {
|
|
|
168
169
|
}
|
|
169
170
|
}
|
|
170
171
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
172
|
+
const toPrompt = secretsToPrompt.filter((s) => !alreadySet.has(s.name) || doUpdateExisting);
|
|
173
|
+
const totalToPrompt = toPrompt.length;
|
|
174
|
+
console.log(pc.cyan(`\n Configure ${totalToPrompt} ${setter.name} secret(s)/variable(s). Leave optional ones blank to skip.\n`));
|
|
175
|
+
for (let i = 0; i < toPrompt.length; i++) {
|
|
176
|
+
const secret = toPrompt[i];
|
|
177
|
+
const value = await promptSecretValue(secret, i, totalToPrompt);
|
|
175
178
|
if (!value) continue;
|
|
176
179
|
|
|
177
180
|
const isThemeToken =
|
package/src/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import { addStoreCommand } from './commands/add-store.js';
|
|
|
4
4
|
import { switchCommand } from './commands/switch.js';
|
|
5
5
|
import { syncCommand } from './commands/sync.js';
|
|
6
6
|
import { updateWorkflowsCommand } from './commands/update-workflows.js';
|
|
7
|
+
import { ensureBranchesCommand } from './commands/ensure-branches.js';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Create the CLI program (for testing and for run).
|
|
@@ -51,6 +52,11 @@ export function createProgram(version = '0.0.0', packageDir = '') {
|
|
|
51
52
|
.description('Refresh GitHub Actions workflows from latest bundled templates')
|
|
52
53
|
.action(updateWorkflowsCommand);
|
|
53
54
|
|
|
55
|
+
program
|
|
56
|
+
.command('ensure-branches')
|
|
57
|
+
.description('Create missing staging and per-store branches from current HEAD (then push)')
|
|
58
|
+
.action(ensureBranchesCommand);
|
|
59
|
+
|
|
54
60
|
return program;
|
|
55
61
|
}
|
|
56
62
|
|