@blocofy/cli 0.1.7 → 0.1.9

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/blocofy.mjs CHANGED
@@ -15,12 +15,12 @@ import { createInterface } from "node:readline/promises";
15
15
  import { credentialsPath, loadCredentials, saveCredentials } from "../lib/credentials.mjs";
16
16
  import { startDevServer } from "../lib/dev-server.mjs";
17
17
  import { readLocalTemplates } from "../lib/local-theme.mjs";
18
- import { githubNote } from "../lib/messages.mjs";
18
+ import { githubNote, statusLine, syncScopeNote } from "../lib/messages.mjs";
19
19
  import { fetchDevSession, pullTheme, pushTheme } from "../lib/theme-sync.mjs";
20
20
  import { hyperlink, openUrl } from "../lib/term.mjs";
21
21
  import { isValidToken, isValidUrl, normalizeUrl } from "../lib/validate.mjs";
22
22
 
23
- const VERSION = "0.1.7";
23
+ const VERSION = "0.1.9";
24
24
  const args = process.argv.slice(2);
25
25
 
26
26
  /** Parse `--key value` and `--flag` (boolean) arguments. */
@@ -58,8 +58,9 @@ Usage
58
58
  --port <n> local port (default 3030)
59
59
  --no-sync local preview only (skip draft sync + remote views)
60
60
 
61
- blocofy theme pull [dir]
61
+ blocofy theme pull [dir] [--draft]
62
62
  Download the live theme to disk. (dir defaults to cwd)
63
+ --draft pull the draft theme (what 'theme dev' syncs into) instead of live
63
64
 
64
65
  blocofy theme push [dir] [--draft]
65
66
  Write the local theme to the site (create/update; no delete).
@@ -148,11 +149,13 @@ function requireCreds() {
148
149
  }
149
150
 
150
151
  async function themePull(rest) {
152
+ const flags = parseFlags(rest);
151
153
  const positional = rest.filter((a) => !a.startsWith("--"));
152
154
  const dir = resolve(positional[0] ?? process.cwd());
153
155
  const creds = requireCreds();
154
- const { count } = await pullTheme({ dir, url: creds.url, token: creds.token });
155
- console.log(`Downloaded ${count} theme files → ${dir}`);
156
+ const draft = Boolean(flags.draft);
157
+ const { count } = await pullTheme({ dir, url: creds.url, token: creds.token, draft });
158
+ console.log(`Downloaded ${count} ${draft ? "draft" : "live"} theme files → ${dir}`);
156
159
  }
157
160
 
158
161
  async function themePush(rest) {
@@ -212,12 +215,22 @@ async function themeDev(rest) {
212
215
  console.log(` (l) Local ${hyperlink(localUrl)}`);
213
216
  if (previewUrl) console.log(` (p) Preview ${hyperlink(previewUrl)}`);
214
217
  if (editorUrl) console.log(` (e) Editor ${hyperlink(editorUrl)}`);
218
+
219
+ // Kalıcı durum satırı (#119 CLI bulgu #3): yerel hangi taslağa gidiyor + canlı tema.
220
+ const status = statusLine(session);
221
+ if (status) console.log(`\n ${status}`);
222
+
215
223
  const keys = ["l local", previewUrl && "p preview", editorUrl && "e editor", "q quit"]
216
224
  .filter(Boolean)
217
225
  .join(" ");
218
226
  console.log(`\n Press: ${keys}`);
219
227
  console.log(` Edit a theme file and save — every open view reloads automatically.\n`);
220
228
 
229
+ // Senkron kapsamı (#119 CLI bulgu #2): hangi dizinler taşınıyor / taşınmıyor —
230
+ // "config/pages senkronlanıyor sandım" karışıklığını açıkça önler.
231
+ for (const line of syncScopeNote()) console.log(` ${line}`);
232
+ console.log("");
233
+
221
234
  // Düzlem uyarısı: CLI yalnız tema KODUNU taşır; editörde yapılan içerik/ayar
222
235
  // bulutta yaşar (githubNote → lib/messages.mjs, oturum durumuna göre uyarlanır).
223
236
  const note = githubNote(session);
package/lib/messages.mjs CHANGED
@@ -3,6 +3,34 @@
3
3
  * CLI yalnız tema KODUNU taşır; editörde yapılan içerik/ayar bulutta yaşar.
4
4
  */
5
5
 
6
+ import { THEME_DIRS } from "./local-theme.mjs";
7
+
8
+ /**
9
+ * Senkron kapsamı (#119 CLI bulgu #2) — geliştiriciye AÇIKÇA hangi dizinlerin
10
+ * platforma taşındığını (tema kodu) ve hangilerinin taşınMADIĞINI (editör/bulut
11
+ * içeriği) söyler; "config/pages senkronlanıyor sandım" kafa karışıklığını önler.
12
+ * 2 satırlık dizi döner (saf → test edilebilir).
13
+ */
14
+ export function syncScopeNote() {
15
+ const synced = [...THEME_DIRS].sort().map((d) => `${d}/`).join(" ");
16
+ return [
17
+ `Synced (theme code): ${synced}`,
18
+ `Not synced (cloud): config/ pages/ — edit these in the admin editor`,
19
+ ];
20
+ }
21
+
22
+ /**
23
+ * Kalıcı durum satırı (#119 CLI bulgu #3) — yerel dosyaların hangi taslak temaya
24
+ * gittiğini ve canlı temanın hangi instance olduğunu gösterir. Oturum yoksa null
25
+ * (local-only mod). `liveThemeId` yoksa "(none)".
26
+ */
27
+ export function statusLine(session) {
28
+ if (!session) return null;
29
+ const draft = session.draftInstanceId != null ? `#${session.draftInstanceId}` : "—";
30
+ const live = session.liveThemeId != null ? `#${session.liveThemeId}` : "(none)";
31
+ return `Local files → Draft theme ${draft} · Live theme → ${live}`;
32
+ }
33
+
6
34
  /**
7
35
  * Dev oturumuna göre "düzlem" uyarısı döndürür (string), oturum yoksa null.
8
36
  * - GitHub bağlı → repo@branch + `git pull` ipucu.
@@ -18,10 +18,16 @@ async function errorText(res) {
18
18
  }
19
19
  }
20
20
 
21
- /** Download the live theme to disk. `{ path: content }` (stripped) → `.liquid` files. */
22
- export async function pullTheme({ dir, url, token }) {
21
+ /**
22
+ * Download a theme to disk. `{ path: content }` (stripped) → `.liquid` files.
23
+ * With `draft`, pulls the "CLI Draft" instance (what `theme dev` syncs into)
24
+ * instead of the live theme — symmetric with `push --draft`.
25
+ */
26
+ export async function pullTheme({ dir, url, token, draft = false }) {
23
27
  const base = url.replace(/\/+$/, "");
24
- const res = await fetch(`${base}/api/dev/theme`, { headers: { authorization: `Bearer ${token}` } });
28
+ const res = await fetch(`${base}/api/dev/theme${draft ? "?draft=1" : ""}`, {
29
+ headers: { authorization: `Bearer ${token}` },
30
+ });
25
31
  if (!res.ok) throw new Error(await errorText(res));
26
32
  const { files } = await res.json();
27
33
  let count = 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocofy/cli",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "description": "Develop your Blocofy theme locally against live data with instant preview — login, theme dev, pull, push.",
5
5
  "type": "module",
6
6
  "license": "MIT",