climaybe 2.4.2 → 3.0.1
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 +25 -26
- package/bin/version.txt +1 -1
- package/package.json +9 -1
- package/src/commands/add-dev-kit.js +5 -3
- package/src/commands/add-store.js +22 -7
- package/src/commands/app-init.js +1 -1
- package/src/commands/build-scripts.js +27 -0
- package/src/commands/create-entrypoints.js +45 -0
- package/src/commands/ensure-branches.js +4 -9
- package/src/commands/init.js +69 -18
- package/src/commands/migrate-legacy-config.js +217 -0
- package/src/index.js +37 -2
- package/src/lib/build-scripts.js +153 -0
- package/src/lib/build-workflows.js +3 -43
- package/src/lib/config.js +78 -8
- package/src/lib/dev-runtime.js +210 -0
- package/src/lib/prompts.js +29 -6
- package/src/lib/shopify-cli.js +30 -0
- package/src/lib/theme-dev-kit.js +52 -52
- package/src/lib/watch.js +80 -0
- package/src/lib/workflows.js +2 -4
- package/src/workflows/build/create-release.yml +23 -6
- package/src/workflows/build/reusable-build.yml +26 -6
- package/src/workflows/multi/main-to-staging-stores.yml +4 -3
- package/src/workflows/multi/multistore-hotfix-to-main.yml +3 -3
- package/src/workflows/multi/pr-to-live.yml +3 -3
- package/src/workflows/preview/pr-close.yml +4 -4
- package/src/workflows/preview/pr-update.yml +4 -4
package/README.md
CHANGED
|
@@ -13,10 +13,10 @@ Built by [Electric Maybe](https://electricmaybe.com) — a Shopify-focused produ
|
|
|
13
13
|
|
|
14
14
|
- **`climaybe theme <command>`** — canonical commands for theme repos (workflows, stores, branches).
|
|
15
15
|
- **Same commands at the top level** — `climaybe init` is the same as `climaybe theme init` (backward compatible).
|
|
16
|
-
- **`climaybe app init`** — app repos only: writes `project_type: "app"` in `
|
|
16
|
+
- **`climaybe app init`** — app repos only: writes `project_type: "app"` in `climaybe.config.json`, optional commitlint + Cursor bundle. Does **not** install theme GitHub Actions or store/branch setup.
|
|
17
17
|
- **`climaybe setup-commitlint`** and **`climaybe add-cursor`** — always at the top level (stack-agnostic).
|
|
18
18
|
|
|
19
|
-
Theme-only commands refuse to run when `
|
|
19
|
+
Theme-only commands refuse to run when `climaybe.config.json` → `project_type` is **`app`**.
|
|
20
20
|
|
|
21
21
|
## Install
|
|
22
22
|
|
|
@@ -64,7 +64,7 @@ Interactive setup that configures your repo for CI/CD.
|
|
|
64
64
|
6. Asks whether to enable **commitlint + Husky** (enforce [conventional commits](https://www.conventionalcommits.org/) on `git commit`)
|
|
65
65
|
7. Asks whether to install the **Cursor bundle** (`.cursor/rules/`, `.cursor/skills/`, `.cursor/agents/`) — Electric Maybe conventions for themes and AI workflows
|
|
66
66
|
8. Based on store count, sets up **single-store** or **multi-store** mode
|
|
67
|
-
9. Writes `
|
|
67
|
+
9. Writes `climaybe.config.json`
|
|
68
68
|
10. Scaffolds GitHub Actions workflows
|
|
69
69
|
11. Creates git branches and store directories (multi-store)
|
|
70
70
|
12. Optionally installs commitlint, Husky, and the Cursor bundle (rules, skills, agents)
|
|
@@ -145,21 +145,19 @@ The previous command name `add-cursor-skill` still works as an alias. Re-running
|
|
|
145
145
|
|
|
146
146
|
## Configuration
|
|
147
147
|
|
|
148
|
-
The CLI writes config into
|
|
148
|
+
The CLI writes config into `climaybe.config.json`:
|
|
149
149
|
|
|
150
150
|
```json
|
|
151
151
|
{
|
|
152
|
-
"
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
"
|
|
160
|
-
|
|
161
|
-
"voldt-norway": "voldt-norway.myshopify.com"
|
|
162
|
-
}
|
|
152
|
+
"port": 9295,
|
|
153
|
+
"default_store": "voldt-staging.myshopify.com",
|
|
154
|
+
"preview_workflows": true,
|
|
155
|
+
"build_workflows": true,
|
|
156
|
+
"commitlint": true,
|
|
157
|
+
"cursor_skills": true,
|
|
158
|
+
"stores": {
|
|
159
|
+
"voldt-staging": "voldt-staging.myshopify.com",
|
|
160
|
+
"voldt-norway": "voldt-norway.myshopify.com"
|
|
163
161
|
}
|
|
164
162
|
}
|
|
165
163
|
```
|
|
@@ -235,27 +233,28 @@ Enabled via `climaybe init` prompt (`Enable preview + cleanup workflows?`; defau
|
|
|
235
233
|
|
|
236
234
|
Enabled via `climaybe init` prompt (`Enable build + Lighthouse workflows?`; default: yes).
|
|
237
235
|
|
|
238
|
-
When enabled,
|
|
239
|
-
- `_scripts/main.
|
|
240
|
-
- `
|
|
236
|
+
When enabled, builds are **resilient**:
|
|
237
|
+
- If `_scripts/*.js` or `_styles/main.css` are missing, the build workflow **skips** those steps and continues.
|
|
238
|
+
- `init` may offer to create entrypoints; **default answer is No**.
|
|
241
239
|
|
|
242
|
-
`
|
|
243
|
-
- `assets/`
|
|
244
|
-
|
|
245
|
-
`climaybe` auto-installs the shared build script at `.climaybe/build-scripts.js` during workflow scaffolding.
|
|
240
|
+
Build workflows run bundling via `npx -y climaybe@latest build-scripts` and Tailwind via `npx -y climaybe@latest build` (no per-repo build script is installed).
|
|
246
241
|
|
|
247
242
|
| Workflow | Trigger | What it does |
|
|
248
243
|
|----------|---------|-------------|
|
|
249
244
|
| `build-pipeline.yml` | Push to any branch | Runs reusable build and Lighthouse checks (when required secrets exist) |
|
|
250
245
|
| `reusable-build.yml` | workflow_call | Runs Node build + Tailwind compile, then commits compiled assets when changed |
|
|
251
|
-
| `create-release.yml` | Push tag `v*`, or **workflow_run** after Post-Merge Tag / Nightly Hotfix Tag succeed on `main` | Builds release archive and creates GitHub Release notes from commits since the previous tag. If
|
|
246
|
+
| `create-release.yml` | Push tag `v*`, or **workflow_run** after Post-Merge Tag / Nightly Hotfix Tag succeed on `main` | Builds release archive and creates GitHub Release notes from commits since the previous tag. It filters repetitive automation subjects (main→staging syncs, store/root sync chores, bot merge noise) before generating notes. If remaining subjects are low-signal and `GEMINI_API_KEY` exists, it uses Gemini to generate cleaner merchant-facing notes. Also covers tags created by workflows with `GITHUB_TOKEN`, which may not trigger tag-push workflows. |
|
|
252
247
|
|
|
253
248
|
### Optional theme dev kit package
|
|
254
249
|
|
|
255
250
|
During `climaybe init`, you can enable the Electric Maybe theme dev kit (default: yes). This installs local
|
|
256
|
-
dev
|
|
257
|
-
`.lighthouserc.js`),
|
|
258
|
-
|
|
251
|
+
dev config defaults (`.theme-check.yml`, `.shopifyignore`, `.prettierrc`,
|
|
252
|
+
`.lighthouserc.js`), writes `climaybe.config.json`, appends a managed `.gitignore` block, and optionally adds
|
|
253
|
+
`.vscode/tasks.json` (default: yes) wired to run `climaybe` dev commands.
|
|
254
|
+
|
|
255
|
+
You can create optional build entrypoints later with:
|
|
256
|
+
|
|
257
|
+
`climaybe create-entrypoints`
|
|
259
258
|
|
|
260
259
|
If these files already exist, `init` warns that they will be replaced.
|
|
261
260
|
|
package/bin/version.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
3.0.1
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "climaybe",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.1",
|
|
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": {
|
|
@@ -78,6 +78,14 @@
|
|
|
78
78
|
]
|
|
79
79
|
},
|
|
80
80
|
"dependencies": {
|
|
81
|
+
"@shopify/prettier-plugin-liquid": "^1.6.3",
|
|
82
|
+
"@tailwindcss/cli": "^4.1.17",
|
|
83
|
+
"@tailwindcss/typography": "^0.5.16",
|
|
84
|
+
"eslint": "^9.11.0",
|
|
85
|
+
"prettier": "^3.4.2",
|
|
86
|
+
"stylelint": "^16.9.0",
|
|
87
|
+
"stylelint-config-standard": "^36.0.1",
|
|
88
|
+
"tailwindcss": "^4.1.18",
|
|
81
89
|
"commander": "^14.0.3",
|
|
82
90
|
"picocolors": "^1.1.1",
|
|
83
91
|
"prompts": "^2.4.2"
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import prompts from 'prompts';
|
|
2
2
|
import pc from 'picocolors';
|
|
3
|
-
import { readConfig, writeConfig } from '../lib/config.js';
|
|
3
|
+
import { readConfig, readPkg, writeConfig } from '../lib/config.js';
|
|
4
4
|
import { getDevKitExistingFiles, scaffoldThemeDevKit } from '../lib/theme-dev-kit.js';
|
|
5
|
-
import { promptVSCodeDevTasks } from '../lib/prompts.js';
|
|
5
|
+
import { promptProjectName, promptVSCodeDevTasks } from '../lib/prompts.js';
|
|
6
6
|
|
|
7
7
|
export async function addDevKitCommand() {
|
|
8
8
|
console.log(pc.bold('\n climaybe — Add theme dev kit\n'));
|
|
@@ -25,12 +25,14 @@ export async function addDevKitCommand() {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
const config = readConfig() || {};
|
|
28
|
+
const projectName = !readPkg() ? await promptProjectName() : undefined;
|
|
28
29
|
scaffoldThemeDevKit({
|
|
29
30
|
includeVSCodeTasks,
|
|
30
31
|
defaultStoreDomain: config.default_store || '',
|
|
32
|
+
packageName: projectName || undefined,
|
|
31
33
|
});
|
|
32
34
|
writeConfig({ dev_kit: true, vscode_tasks: includeVSCodeTasks });
|
|
33
35
|
|
|
34
36
|
console.log(pc.green(' Theme dev kit installed.'));
|
|
35
|
-
console.log(pc.dim(' Added
|
|
37
|
+
console.log(pc.dim(' Added local dev-kit config files and ignore defaults.\n'));
|
|
36
38
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import pc from 'picocolors';
|
|
2
|
-
import { promptNewStore, promptConfigureCISecrets, promptUpdateExistingSecrets, promptSecretValue
|
|
2
|
+
import { promptNewStore, promptConfigureCISecrets, promptUpdateExistingSecrets, promptSecretValue } from '../lib/prompts.js';
|
|
3
3
|
import {
|
|
4
4
|
readConfig,
|
|
5
5
|
addStoreToConfig,
|
|
@@ -119,23 +119,38 @@ export async function addStoreCommand() {
|
|
|
119
119
|
console.log(pc.cyan(`\n Configure ${total} secret(s) for store "${store.alias}" (theme token required).\n`));
|
|
120
120
|
for (let i = 0; i < secretsToPrompt.length; i++) {
|
|
121
121
|
const secret = secretsToPrompt[i];
|
|
122
|
-
const value = await promptSecretValue(secret, i, total);
|
|
123
|
-
if (!value) continue;
|
|
124
|
-
|
|
125
122
|
const isThemeToken = secret.name === 'SHOPIFY_THEME_ACCESS_TOKEN' || secret.name.startsWith('SHOPIFY_THEME_ACCESS_TOKEN_');
|
|
126
123
|
if (isThemeToken && store.domain) {
|
|
127
|
-
|
|
128
|
-
|
|
124
|
+
// Theme tokens are required and must validate; keep prompting until valid + set.
|
|
125
|
+
while (true) {
|
|
126
|
+
const value = await promptSecretValue(secret, i, total);
|
|
127
|
+
if (!value) {
|
|
128
|
+
console.log(pc.red(' Theme access token is required.'));
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
129
131
|
const result = await validateThemeAccessToken(store.domain, value);
|
|
130
132
|
if (!result.ok) {
|
|
131
133
|
console.log(pc.red(` Token test failed: ${result.error}`));
|
|
132
|
-
console.log(pc.dim('
|
|
134
|
+
console.log(pc.dim(' Please try again with a valid Theme Access token.'));
|
|
133
135
|
continue;
|
|
134
136
|
}
|
|
135
137
|
console.log(pc.green(' Token validated against store.'));
|
|
138
|
+
try {
|
|
139
|
+
await setter.set(secret.name, value);
|
|
140
|
+
console.log(pc.green(` Set ${secret.name}.`));
|
|
141
|
+
setCount++;
|
|
142
|
+
break;
|
|
143
|
+
} catch (err) {
|
|
144
|
+
console.log(pc.red(` Failed to set ${secret.name}: ${err.message}`));
|
|
145
|
+
console.log(pc.dim(' Please try entering the token again.'));
|
|
146
|
+
}
|
|
136
147
|
}
|
|
148
|
+
continue;
|
|
137
149
|
}
|
|
138
150
|
|
|
151
|
+
const value = await promptSecretValue(secret, i, total);
|
|
152
|
+
if (!value) continue;
|
|
153
|
+
|
|
139
154
|
try {
|
|
140
155
|
await setter.set(secret.name, value);
|
|
141
156
|
console.log(pc.green(` Set ${secret.name}.`));
|
package/src/commands/app-init.js
CHANGED
|
@@ -26,7 +26,7 @@ async function runAppInitFlow() {
|
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
writeConfig(config, process.cwd(), { defaultPackageName: 'shopify-app' });
|
|
29
|
-
console.log(pc.green(' Updated
|
|
29
|
+
console.log(pc.green(' Updated climaybe config.'));
|
|
30
30
|
|
|
31
31
|
ensureGitRepo();
|
|
32
32
|
ensureInitialCommit();
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import pc from 'picocolors';
|
|
2
|
+
import { requireThemeProject } from '../lib/theme-guard.js';
|
|
3
|
+
import { buildScripts } from '../lib/build-scripts.js';
|
|
4
|
+
|
|
5
|
+
export async function buildScriptsCommand() {
|
|
6
|
+
console.log(pc.bold('\n climaybe — Build scripts\n'));
|
|
7
|
+
if (!requireThemeProject()) return;
|
|
8
|
+
|
|
9
|
+
try {
|
|
10
|
+
if (global.gc) global.gc();
|
|
11
|
+
const { bundles } = buildScripts({ cwd: process.cwd() });
|
|
12
|
+
if (!bundles || bundles.length === 0) {
|
|
13
|
+
console.log(pc.yellow(' No _scripts/*.js entrypoints found; nothing to build.'));
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const totalFiles = bundles.reduce((sum, b) => sum + (b.fileCount || 0), 0);
|
|
17
|
+
console.log(pc.green(` Scripts built (${bundles.length} bundle(s), ${totalFiles} files total)`));
|
|
18
|
+
for (const b of bundles) {
|
|
19
|
+
console.log(pc.dim(` - ${b.entryFile} → ${b.outputPath}`));
|
|
20
|
+
}
|
|
21
|
+
if (global.gc) global.gc();
|
|
22
|
+
} catch (err) {
|
|
23
|
+
console.log(pc.red(` Build error: ${err.message}`));
|
|
24
|
+
process.exitCode = 1;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import pc from 'picocolors';
|
|
4
|
+
import { requireThemeProject } from '../lib/theme-guard.js';
|
|
5
|
+
|
|
6
|
+
const MAIN_JS = `// climaybe entrypoint: global theme JS
|
|
7
|
+
// Add imports here for code you want on every page.
|
|
8
|
+
// Top-level files in _scripts/ (besides main.js) are treated as separate bundles.
|
|
9
|
+
`;
|
|
10
|
+
|
|
11
|
+
const MAIN_CSS = `@import "tailwindcss";
|
|
12
|
+
`;
|
|
13
|
+
|
|
14
|
+
export async function createEntrypointsCommand() {
|
|
15
|
+
console.log(pc.bold('\n climaybe — Create entrypoints\n'));
|
|
16
|
+
if (!requireThemeProject()) return;
|
|
17
|
+
|
|
18
|
+
const scriptsDir = join(process.cwd(), '_scripts');
|
|
19
|
+
const stylesDir = join(process.cwd(), '_styles');
|
|
20
|
+
const assetsDir = join(process.cwd(), 'assets');
|
|
21
|
+
|
|
22
|
+
mkdirSync(scriptsDir, { recursive: true });
|
|
23
|
+
mkdirSync(stylesDir, { recursive: true });
|
|
24
|
+
mkdirSync(assetsDir, { recursive: true });
|
|
25
|
+
|
|
26
|
+
const mainJsPath = join(scriptsDir, 'main.js');
|
|
27
|
+
const mainCssPath = join(stylesDir, 'main.css');
|
|
28
|
+
|
|
29
|
+
if (!existsSync(mainJsPath)) {
|
|
30
|
+
writeFileSync(mainJsPath, MAIN_JS, 'utf-8');
|
|
31
|
+
console.log(pc.green(' Created _scripts/main.js'));
|
|
32
|
+
} else {
|
|
33
|
+
console.log(pc.dim(' _scripts/main.js already exists (skipped)'));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (!existsSync(mainCssPath)) {
|
|
37
|
+
writeFileSync(mainCssPath, MAIN_CSS, 'utf-8');
|
|
38
|
+
console.log(pc.green(' Created _styles/main.css'));
|
|
39
|
+
} else {
|
|
40
|
+
console.log(pc.dim(' _styles/main.css already exists (skipped)'));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
console.log(pc.dim('\n Next: run `climaybe build` or `climaybe serve`.\n'));
|
|
44
|
+
}
|
|
45
|
+
|
|
@@ -36,20 +36,15 @@ export async function ensureBranchesCommand() {
|
|
|
36
36
|
console.log(pc.dim(` Mode: ${mode}-store (${aliases.length} store(s))\n`));
|
|
37
37
|
|
|
38
38
|
ensureStagingBranch();
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
for (const alias of aliases) {
|
|
42
|
-
createStoreBranches(alias);
|
|
43
|
-
}
|
|
39
|
+
for (const alias of aliases) {
|
|
40
|
+
createStoreBranches(alias);
|
|
44
41
|
}
|
|
45
42
|
|
|
46
43
|
console.log(pc.bold(pc.green('\n Branches ensured.\n')));
|
|
47
44
|
console.log(pc.dim(' Push them so CI can run:'));
|
|
48
45
|
console.log(pc.dim(' git push origin staging'));
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
console.log(pc.dim(` git push origin staging-${alias} live-${alias}`));
|
|
52
|
-
}
|
|
46
|
+
for (const alias of aliases) {
|
|
47
|
+
console.log(pc.dim(` git push origin staging-${alias} live-${alias}`));
|
|
53
48
|
}
|
|
54
49
|
console.log(pc.dim(' Or push all at once: git push origin --all\n'));
|
|
55
50
|
}
|
package/src/commands/init.js
CHANGED
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
import prompts from 'prompts';
|
|
2
2
|
import pc from 'picocolors';
|
|
3
|
+
import { execSync } from 'node:child_process';
|
|
3
4
|
import {
|
|
4
5
|
promptStoreLoop,
|
|
5
6
|
promptPreviewWorkflows,
|
|
6
7
|
promptBuildWorkflows,
|
|
7
8
|
promptDevKit,
|
|
8
9
|
promptVSCodeDevTasks,
|
|
10
|
+
promptProjectName,
|
|
9
11
|
promptCommitlint,
|
|
10
12
|
promptCursorSkills,
|
|
11
13
|
promptConfigureCISecrets,
|
|
12
14
|
promptUpdateExistingSecrets,
|
|
13
15
|
promptSecretValue,
|
|
14
|
-
promptTestThemeToken,
|
|
15
16
|
} from '../lib/prompts.js';
|
|
16
|
-
import { readConfig, writeConfig, getProjectType } from '../lib/config.js';
|
|
17
|
+
import { readConfig, writeConfig, getProjectType, readPkg } from '../lib/config.js';
|
|
17
18
|
import { ensureGitRepo, ensureInitialCommit, ensureStagingBranch, createStoreBranches, getSuggestedTagForRelease } from '../lib/git.js';
|
|
18
19
|
import { scaffoldWorkflows } from '../lib/workflows.js';
|
|
19
20
|
import { createStoreDirectories } from '../lib/store-sync.js';
|
|
20
21
|
import { scaffoldCommitlint } from '../lib/commit-tooling.js';
|
|
21
22
|
import { scaffoldCursorBundle } from '../lib/cursor-bundle.js';
|
|
22
|
-
import { getMissingBuildWorkflowRequirements,
|
|
23
|
+
import { getMissingBuildWorkflowRequirements, ensureBuildWorkflowDefaults } from '../lib/build-workflows.js';
|
|
23
24
|
import { getDevKitExistingFiles, scaffoldThemeDevKit } from '../lib/theme-dev-kit.js';
|
|
24
25
|
import {
|
|
25
26
|
isGhAvailable,
|
|
@@ -36,11 +37,25 @@ import {
|
|
|
36
37
|
setGitLabVariable,
|
|
37
38
|
} from '../lib/github-secrets.js';
|
|
38
39
|
|
|
40
|
+
function installThemeDependencies(cwd = process.cwd()) {
|
|
41
|
+
try {
|
|
42
|
+
execSync('npm install', { cwd, stdio: 'inherit' });
|
|
43
|
+
console.log(pc.green(' Installed theme dependencies (npm install).'));
|
|
44
|
+
return true;
|
|
45
|
+
} catch (err) {
|
|
46
|
+
console.log(pc.yellow(` npm install failed or skipped: ${err.message}`));
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
39
51
|
/**
|
|
40
52
|
* Run the full init flow: prompts, config write, git, branches, workflows.
|
|
41
53
|
* Used by both init (when not already inited or user confirms reinit) and reinit.
|
|
42
54
|
*/
|
|
43
55
|
async function runInitFlow() {
|
|
56
|
+
const hasPackageJson = !!readPkg();
|
|
57
|
+
const projectName = !hasPackageJson ? await promptProjectName() : undefined;
|
|
58
|
+
|
|
44
59
|
// 1. Collect stores from user
|
|
45
60
|
const stores = await promptStoreLoop();
|
|
46
61
|
const mode = stores.length > 1 ? 'multi' : 'single';
|
|
@@ -53,18 +68,30 @@ async function runInitFlow() {
|
|
|
53
68
|
|
|
54
69
|
console.log(pc.dim(`\n Mode: ${mode}-store (${stores.length} store(s))`));
|
|
55
70
|
|
|
71
|
+
let missingBuildFiles = [];
|
|
56
72
|
if (enableBuildWorkflows) {
|
|
57
73
|
ensureBuildWorkflowDefaults();
|
|
58
|
-
|
|
74
|
+
missingBuildFiles = getMissingBuildWorkflowRequirements();
|
|
59
75
|
if (missingBuildFiles.length > 0) {
|
|
60
76
|
console.log(pc.red('\n Build workflows are enabled, but required files are missing:'));
|
|
61
77
|
for (const req of missingBuildFiles) {
|
|
62
78
|
const expected = req.kind === 'dir' ? `${req.path}/` : req.path;
|
|
63
79
|
console.log(pc.red(` - ${expected}`));
|
|
64
80
|
}
|
|
65
|
-
console.log(pc.dim(
|
|
66
|
-
|
|
67
|
-
|
|
81
|
+
console.log(pc.dim('\n Build workflows will be scaffolded, but build steps will be skipped until entrypoints exist.'));
|
|
82
|
+
const { createNow } = await prompts({
|
|
83
|
+
type: 'confirm',
|
|
84
|
+
name: 'createNow',
|
|
85
|
+
message: 'Create _scripts/main.js and _styles/main.css now?',
|
|
86
|
+
initial: false,
|
|
87
|
+
});
|
|
88
|
+
if (createNow) {
|
|
89
|
+
// Lazy import to avoid circular deps and keep init lean.
|
|
90
|
+
const { createEntrypointsCommand } = await import('./create-entrypoints.js');
|
|
91
|
+
await createEntrypointsCommand();
|
|
92
|
+
} else {
|
|
93
|
+
console.log(pc.dim(' Skipping entrypoint creation (default).'));
|
|
94
|
+
}
|
|
68
95
|
}
|
|
69
96
|
}
|
|
70
97
|
|
|
@@ -75,6 +102,7 @@ async function runInitFlow() {
|
|
|
75
102
|
default_store: stores[0].domain,
|
|
76
103
|
preview_workflows: enablePreviewWorkflows,
|
|
77
104
|
build_workflows: enableBuildWorkflows,
|
|
105
|
+
build_entrypoints_ready: enableBuildWorkflows ? missingBuildFiles?.length === 0 : undefined,
|
|
78
106
|
dev_kit: enableDevKit,
|
|
79
107
|
vscode_tasks: enableVSCodeTasks,
|
|
80
108
|
commitlint: enableCommitlint,
|
|
@@ -86,9 +114,9 @@ async function runInitFlow() {
|
|
|
86
114
|
config.stores[s.alias] = s.domain;
|
|
87
115
|
}
|
|
88
116
|
|
|
89
|
-
// 3. Write
|
|
117
|
+
// 3. Write climaybe config
|
|
90
118
|
writeConfig(config);
|
|
91
|
-
console.log(pc.green(' Updated
|
|
119
|
+
console.log(pc.green(' Updated climaybe config.'));
|
|
92
120
|
|
|
93
121
|
// 4. Ensure git repo
|
|
94
122
|
ensureGitRepo();
|
|
@@ -97,6 +125,7 @@ async function runInitFlow() {
|
|
|
97
125
|
// 5. Create branches
|
|
98
126
|
if (mode === 'single') {
|
|
99
127
|
ensureStagingBranch();
|
|
128
|
+
createStoreBranches(stores[0].alias);
|
|
100
129
|
} else {
|
|
101
130
|
// Multi-store: staging branch + per-store branches
|
|
102
131
|
ensureStagingBranch();
|
|
@@ -141,8 +170,10 @@ async function runInitFlow() {
|
|
|
141
170
|
scaffoldThemeDevKit({
|
|
142
171
|
includeVSCodeTasks: enableVSCodeTasks,
|
|
143
172
|
defaultStoreDomain: stores[0]?.domain || '',
|
|
173
|
+
packageName: projectName || undefined,
|
|
144
174
|
});
|
|
145
|
-
console.log(pc.green(' Theme dev kit installed (
|
|
175
|
+
console.log(pc.green(' Theme dev kit installed (local config + ignore defaults).'));
|
|
176
|
+
installThemeDependencies();
|
|
146
177
|
}
|
|
147
178
|
|
|
148
179
|
// Done
|
|
@@ -150,6 +181,7 @@ async function runInitFlow() {
|
|
|
150
181
|
|
|
151
182
|
if (mode === 'single') {
|
|
152
183
|
console.log(pc.dim(' Branches: main, staging'));
|
|
184
|
+
console.log(pc.dim(` staging-${stores[0].alias}, live-${stores[0].alias}`));
|
|
153
185
|
console.log(pc.dim(' Workflow: staging → main with versioning + nightly hotfix tagging'));
|
|
154
186
|
} else {
|
|
155
187
|
console.log(pc.dim(' Branches: main, staging'));
|
|
@@ -245,26 +277,45 @@ async function runInitFlow() {
|
|
|
245
277
|
console.log(pc.cyan(`\n Configure ${totalToPrompt} ${setter.name} secret(s)/variable(s). Leave optional ones blank to skip.\n`));
|
|
246
278
|
for (let i = 0; i < toPrompt.length; i++) {
|
|
247
279
|
const secret = toPrompt[i];
|
|
248
|
-
const value = await promptSecretValue(secret, i, totalToPrompt);
|
|
249
|
-
if (!value) continue;
|
|
250
|
-
|
|
251
280
|
const isThemeToken =
|
|
252
281
|
secret.name === 'SHOPIFY_THEME_ACCESS_TOKEN' || secret.name.startsWith('SHOPIFY_THEME_ACCESS_TOKEN_');
|
|
253
282
|
const storeUrl = isThemeToken ? getStoreUrlForThemeTokenSecret(secret.name, stores) : null;
|
|
254
283
|
|
|
255
|
-
if (
|
|
256
|
-
|
|
257
|
-
|
|
284
|
+
if (isThemeToken) {
|
|
285
|
+
if (!storeUrl) {
|
|
286
|
+
console.log(pc.red(` Could not resolve store URL for required token ${secret.name}.`));
|
|
287
|
+
continue;
|
|
288
|
+
}
|
|
289
|
+
// Theme tokens are required and must validate; keep prompting until valid + set.
|
|
290
|
+
while (true) {
|
|
291
|
+
const value = await promptSecretValue(secret, i, totalToPrompt);
|
|
292
|
+
if (!value) {
|
|
293
|
+
console.log(pc.red(' Theme access token is required.'));
|
|
294
|
+
continue;
|
|
295
|
+
}
|
|
258
296
|
const result = await validateThemeAccessToken(storeUrl, value);
|
|
259
297
|
if (!result.ok) {
|
|
260
298
|
console.log(pc.red(` Token test failed: ${result.error}`));
|
|
261
|
-
console.log(pc.dim('
|
|
299
|
+
console.log(pc.dim(' Please try again with a valid Theme Access token.'));
|
|
262
300
|
continue;
|
|
263
301
|
}
|
|
264
302
|
console.log(pc.green(' Token validated against store.'));
|
|
303
|
+
try {
|
|
304
|
+
await setter.set(secret.name, value);
|
|
305
|
+
console.log(pc.green(` Set ${secret.name}.`));
|
|
306
|
+
setCount++;
|
|
307
|
+
break;
|
|
308
|
+
} catch (err) {
|
|
309
|
+
console.log(pc.red(` Failed to set ${secret.name}: ${err.message}`));
|
|
310
|
+
console.log(pc.dim(' Please try entering the token again.'));
|
|
311
|
+
}
|
|
265
312
|
}
|
|
313
|
+
continue;
|
|
266
314
|
}
|
|
267
315
|
|
|
316
|
+
const value = await promptSecretValue(secret, i, totalToPrompt);
|
|
317
|
+
if (!value) continue;
|
|
318
|
+
|
|
268
319
|
try {
|
|
269
320
|
await setter.set(secret.name, value);
|
|
270
321
|
console.log(pc.green(` Set ${secret.name}.`));
|
|
@@ -284,7 +335,7 @@ export async function initCommand() {
|
|
|
284
335
|
if (getProjectType() === 'app') {
|
|
285
336
|
console.log(pc.red(' This repo is configured as a Shopify app (project_type: app).'));
|
|
286
337
|
console.log(pc.dim(' Use: npx climaybe app init'));
|
|
287
|
-
console.log(pc.dim(' To switch to theme CI/CD, remove or edit
|
|
338
|
+
console.log(pc.dim(' To switch to theme CI/CD, remove or edit climaybe.config.json → project_type first.\n'));
|
|
288
339
|
return;
|
|
289
340
|
}
|
|
290
341
|
|