@blocofy/cli 0.1.6 → 0.1.8

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,11 +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
19
  import { fetchDevSession, pullTheme, pushTheme } from "../lib/theme-sync.mjs";
19
20
  import { hyperlink, openUrl } from "../lib/term.mjs";
20
21
  import { isValidToken, isValidUrl, normalizeUrl } from "../lib/validate.mjs";
21
22
 
22
- const VERSION = "0.1.6";
23
+ const VERSION = "0.1.8";
23
24
  const args = process.argv.slice(2);
24
25
 
25
26
  /** Parse `--key value` and `--flag` (boolean) arguments. */
@@ -57,8 +58,9 @@ Usage
57
58
  --port <n> local port (default 3030)
58
59
  --no-sync local preview only (skip draft sync + remote views)
59
60
 
60
- blocofy theme pull [dir]
61
+ blocofy theme pull [dir] [--draft]
61
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
62
64
 
63
65
  blocofy theme push [dir] [--draft]
64
66
  Write the local theme to the site (create/update; no delete).
@@ -147,11 +149,13 @@ function requireCreds() {
147
149
  }
148
150
 
149
151
  async function themePull(rest) {
152
+ const flags = parseFlags(rest);
150
153
  const positional = rest.filter((a) => !a.startsWith("--"));
151
154
  const dir = resolve(positional[0] ?? process.cwd());
152
155
  const creds = requireCreds();
153
- const { count } = await pullTheme({ dir, url: creds.url, token: creds.token });
154
- 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}`);
155
159
  }
156
160
 
157
161
  async function themePush(rest) {
@@ -217,6 +221,13 @@ async function themeDev(rest) {
217
221
  console.log(`\n Press: ${keys}`);
218
222
  console.log(` Edit a theme file and save — every open view reloads automatically.\n`);
219
223
 
224
+ // Düzlem uyarısı: CLI yalnız tema KODUNU taşır; editörde yapılan içerik/ayar
225
+ // bulutta yaşar (githubNote → lib/messages.mjs, oturum durumuna göre uyarlanır).
226
+ const note = githubNote(session);
227
+ if (note) {
228
+ console.log(` ℹ ${note}\n`);
229
+ }
230
+
220
231
  // Tanılama: kaç tema dosyası izleniyor? Boşsa hot-reload mümkün değil — yanlış
221
232
  // dizinde ya da `theme pull` yapılmamış demektir; sebebini açıkça söyle.
222
233
  const localFiles = readLocalTemplates(themeDir);
@@ -0,0 +1,21 @@
1
+ /**
2
+ * `theme dev` kullanıcı-yönelik mesajları (saf → test edilebilir). Düzlem uyarısı:
3
+ * CLI yalnız tema KODUNU taşır; editörde yapılan içerik/ayar bulutta yaşar.
4
+ */
5
+
6
+ /**
7
+ * Dev oturumuna göre "düzlem" uyarısı döndürür (string), oturum yoksa null.
8
+ * - GitHub bağlı → repo@branch + `git pull` ipucu.
9
+ * - Bağlı değil → içerik/ayar bulutta kalır + repo bağla ipucu.
10
+ * - Eski platform (githubConnected undefined) → ipuçsuz nötr uyarı.
11
+ */
12
+ export function githubNote(session) {
13
+ if (!session) return null;
14
+ if (session.githubConnected === true) {
15
+ return `GitHub: ${session.githubRepo}@${session.githubBranch} — editor edits auto-commit there; run 'git pull' to sync them here.`;
16
+ }
17
+ return (
18
+ "Content & settings edited in the admin editor stay server-side — they won't appear in these local files." +
19
+ (session.githubConnected === false ? " Connect a GitHub repo for two-way sync." : "")
20
+ );
21
+ }
@@ -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.6",
3
+ "version": "0.1.8",
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",