@blocofy/cli 0.15.0 → 0.17.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 CHANGED
@@ -5,9 +5,10 @@ instant preview, and publish. The CLI does **not** build assets — generate the
5
5
  own tools (npm/Vite/Tailwind); the platform serves plain Liquid + static assets.
6
6
 
7
7
  ```bash
8
- npx @blocofy/cli login # site URL + dev token (admin panel: Settings → Theme CLI tokens)
9
- cd path/to/theme
10
- npx @blocofy/cli theme dev # http://localhost:3030 — local theme + live data, livereload
8
+ npx @blocofy/cli login # browser login: pick your site, approve (draft-only)
9
+ npx @blocofy/cli init my-site # a theme work of its own + its files + a preview link; live site unchanged
10
+ cd my-site
11
+ npx @blocofy/cli theme push --draft --work <wk_…>
11
12
  ```
12
13
 
13
14
  `login` saves the site under a named **context** (default: the site's slug) in
@@ -20,18 +21,44 @@ targets the right one — see [Contexts and project binding](#contexts-and-proje
20
21
  ### Login & contexts
21
22
 
22
23
  ```
23
- blocofy login [--context <name>] [--url <url>] [--token <bcf_…>] [--keychain]
24
- ```
25
- Verify a dev token against its site (`GET /api/dev/whoami`) and save it as a named context
26
- (default name: the site's slug). Nothing is saved if verification fails. Get a token from the
27
- admin panel → Settings → Theme CLI tokens.
24
+ blocofy login [--context <name>] [--site <handle|slug>] [--api-url <url>] [--no-browser] [--insecure-storage]
25
+ ```
26
+ **Browser login (default, 0.16.0).** The CLI opens your system browser on the platform
27
+ (Authorization Code + PKCE S256), you pick the site and approve; the browser comes back to a
28
+ one-shot listener on `http://127.0.0.1:<port>/callback` (or `[::1]`; `localhost` is never used).
29
+ The CLI checks `state` and the RFC 9207 `iss` against the platform's discovery metadata before
30
+ it exchanges the code, and says "connected" only after `GET /api/v1/ping` confirms the site, the
31
+ profile and the CLI audience. The login is **draft-only** ("Tema geliştirme", `theme-dev@1`): it
32
+ can start and fill theme works, push to its own work's draft and create preview links, but it can
33
+ never change the live site or publish — publishing is the panel's (or a human approval's) job.
34
+ - Storage: the OS secure store — macOS Keychain, Windows DPAPI-protected file
35
+ (`%APPDATA%\blocofy\secrets.dpapi`), Linux Secret Service (`secret-tool`). With no OS store the
36
+ login is **refused**, never silently written to a plain file; `--insecure-storage` (or
37
+ `BLOCOFY_SECRET_STORE=file`) chooses `~/.blocofy/secrets.json` (0600) explicitly and is announced.
38
+ - The access token lives 10 minutes and renews itself with a single-use refresh token, one
39
+ renewal at a time across every running `blocofy` (lock `~/.blocofy/.refresh-<context>.lock`,
40
+ `/token` timeout 10 s). A refused renewal (revoked, expired, reused) marks the context
41
+ `reauth_required`: run `blocofy login --context <name>` again.
42
+ - `--site` refuses (and revokes) a login for any other site; `--no-browser` prints the URL only;
43
+ `--api-url` names the platform (default `https://app.blocofy.com`).
44
+ - Needs a terminal. CI (`CI` set, no TTY) and SSH sessions never open a browser: use env
45
+ credentials or the advanced options below.
46
+
47
+ ```
48
+ blocofy login --url <url> --token [--context <name>] [--keychain] # advanced: pasted dev token
49
+ ```
50
+ Verify a dev token (`bcf_…`, or a profiled `bcf2_…` — needs CLI 0.16.0+) against its site
51
+ (`GET /api/dev/whoami`) and save it as a named context (default name: the site's slug). Nothing
52
+ is saved if verification fails. `--token` without a value reads it from a hidden prompt;
53
+ `--token <value>` still works but warns (`TOKEN_IN_ARGV`: argv is visible in `ps` and shell
54
+ history). Get a token from the admin panel → Settings → Theme CLI tokens.
28
55
  - `--keychain` — keep the secret in the macOS keychain (or `BLOCOFY_SECRET_STORE=keychain`);
29
- default is `~/.blocofy/secrets.json` (0600).
56
+ default is `~/.blocofy/secrets.json` (0600). The output names the store used.
30
57
 
31
58
  ```
32
59
  blocofy login --api-key [--context <name>] [--api-url <url>]
33
60
  ```
34
- Verify a v1 API key (`blcf_live_…`, `GET /api/v1/ping`) and add it to a context. The key is
61
+ Verify a v1 API key (`blcf_live_…` or a profiled `blcf_k2_…`, `GET /api/v1/ping`) and add it to a context. The key is
35
62
  read from a **hidden prompt** — the flag takes no value, so it never lands in argv or shell
36
63
  history. If the context already has a dev token for another site, nothing is saved
37
64
  (`TARGET_CREDENTIAL_MISMATCH`).
@@ -41,8 +68,43 @@ history. If the context already has a dev token for another site, nothing is sav
41
68
  ```
42
69
  blocofy contexts [--json] # list saved contexts (never prints secrets)
43
70
  blocofy use <name> # default context for status / target / pages check outside a project
44
- blocofy logout --context <name> # remove a context and its secrets
45
- ```
71
+ blocofy logout [--context <name>] # remove a context and its secrets (default: the `use` context)
72
+ ```
73
+ `logout` reports two separate results. **Server** (browser logins only): `revoked` (the platform's
74
+ RFC 7009 `/revoke` answered 200), `unreachable` / `refused` / `unavailable` (NOT revoked — the
75
+ output names the panel page where you cut it: Settings → Connections and keys), or
76
+ `not_applicable` (a pasted token/key: revoke it in the panel). **Local**: `cleared` | `failed`,
77
+ done whatever the server said. Exit 0 only when both are done; otherwise exit 4.
78
+
79
+ ### New project: `blocofy init`
80
+
81
+ ```
82
+ blocofy init [dir] [--site <handle|slug>] [--context <name>] [--api-url <url>] [--no-browser] [--insecure-storage]
83
+ ```
84
+ Sets up a new project directory end to end, without touching the live site:
85
+ 1. Pre-checks, before any request: a missing or empty directory starts; a directory this CLI
86
+ initialised resumes; a non-empty directory that is not a project is refused
87
+ (`INIT_DIR_NOT_EMPTY`, exit 3, nothing written); a directory bound to another site is refused
88
+ (`INIT_SITE_MISMATCH`, exit 3); a project bound by `link`/`pull` is not taken over
89
+ (`INIT_ALREADY_BOUND`).
90
+ 2. The credential: `--context`, env credentials, the directory's saved context, or (on a terminal)
91
+ a browser login. Non-interactive runs never open a browser and need `--site`.
92
+ 3. Reads the live theme, starts a theme work (`POST /api/v1/theme-work`, idempotency key
93
+ `init:<key>` from `.blocofy/init.json` — written before the first request), downloads the
94
+ work's theme files, writes `.blocofy/project.json` (+ the additive `profile`) and
95
+ `.blocofy/local.json` (context + the work), creates a preview link for the work's home page,
96
+ and reads the live theme again.
97
+ 4. Success = the preview link exists **and** the live theme read back is the one read before:
98
+ "Taslak hazır. Canlı siten değişmedi." If the live theme changed meanwhile (not by init),
99
+ nothing is called a success: exit 5.
100
+
101
+ `.blocofy/init.json` (git-ignored, no secret, no link) records the step reached
102
+ (`started → work_created → files_pulled → pinned → previewed`). Run the same command again after a
103
+ timeout, a crash or Ctrl-C: it reads the work back from the platform and continues — the same key
104
+ always returns the same work, never a second one. Two `init`s in one directory at once: one runs,
105
+ the other is refused (`INIT_IN_PROGRESS`). Do not delete `init.json` to "start over": use a new,
106
+ empty directory.
107
+
46
108
 
47
109
  ### Project binding
48
110
 
@@ -544,7 +606,8 @@ untouched.
544
606
  | 1 | Usage / network / HTTP 5xx / a local check that refuses before any request (e.g. a `site migrate` conflict, a `pages migrate-layout` ambiguity). |
545
607
  | 2 | The server refused the request (HTTP 4xx) — its `{error}` JSON is printed. |
546
608
  | 3 | Target/binding refusal — nothing was read or written (see [Contexts and project binding](#contexts-and-project-binding)). |
547
- | 4 | `site apply` only: not finished within its bounded pass count. Every step already applied is safe — re-run the same command to resume. |
609
+ | 4 | `site apply`: not finished within its bounded pass count. Every step already applied is safe — re-run the same command to resume. `logout`: the local login could not be removed, or the platform login was NOT revoked (cut it in the panel). |
610
+ | 5 | `init`: the live theme changed while init ran (init never writes it) — not reported as a success. |
548
611
 
549
612
  `--json`: every failure prints `{"error":{"code","message","details"}}` as the **last** stderr
550
613
  line; the target block (`{"target":…}`) and any warning lines are printed on stderr before it.
@@ -560,6 +623,52 @@ Each retry prints a notice on stderr.
560
623
 
561
624
  ## Changelog
562
625
 
626
+ - **0.17.0** (2026-10-31) — `theme publish` tells you when the live site is not serving the files
627
+ you published.
628
+ - **`theme publish` reports an unrefreshed live site.** When the platform answers
629
+ `live_sealed: false`, the CLI prints the reason and the fix (`blocofy theme push --live --yes`)
630
+ and exits 4 (not complete) instead of reporting success. Platforms that do not send the field
631
+ behave as before.
632
+ - **`blocofy status` shows live file freshness** ("Live files: up to date", or which files are
633
+ stale, missing or extra on the live site).
634
+ - `theme publish` accepts `--yes` / `--confirm` (no prompt to skip; accepted so scripts that pass
635
+ it to every live command do not fail).
636
+ - `theme dev` no longer prints a preview URL containing `undefined&hr=` for a session without one.
637
+ - **0.16.0** (2026-10-06) — Browser login, `blocofy init`, honest `logout` (ADR-0014 wave P4).
638
+ Pairs with the platform release of the credential profiles (draft-only "Tema geliştirme" by
639
+ default). **Minimum platform:** the browser login needs a platform that publishes the CLI client
640
+ (`blocofy-cli`), RFC 9207 `iss`, `/revoke` and the `profile` / `audience` / `dev_endpoint` fields of
641
+ `GET /api/v1/ping`; an older platform is told apart and refused with "use `login --token`".
642
+ - **`blocofy login` opens the browser** (PKCE S256, loopback `127.0.0.1`/`[::1]` only, `state`
643
+ and `iss` checked, `resource=<origin>/api/v1`). Connected = the identity probe, not a config
644
+ write. Unattended (CI / no TTY) and SSH runs never open a browser. The pasted dev token stays as
645
+ the advanced path (`login --url <site> --token`, hidden prompt; a token in argv warns).
646
+ - **Secure storage**: OS store by default (Keychain / DPAPI / Secret Service); no store → refused;
647
+ the 0600 file only with `--insecure-storage` / `BLOCOFY_SECRET_STORE=file`. **Unverified on real
648
+ machines:** the Windows (DPAPI via PowerShell) and Linux (Secret Service via `secret-tool`) stores
649
+ are covered only by tests with a stand-in for those programs; macOS Keychain uses the existing,
650
+ field-tested adapter.
651
+ - **Draft-only logins default to their saved work**: for a browser login (or any draft-only profile)
652
+ `theme push` and `theme dev` write into the theme work saved by `init` / `theme work start`
653
+ (`.blocofy/local.json`, else `.blocofy/init.json`); `--work` / `--instance` still win. Without a
654
+ saved work they stop with a hint (`THEME_WORK_REQUIRED`, exit 3) before any request.
655
+ - **Refresh single-flight** across processes (lock with pid/hostname/acquired_at, ESRCH or 30 s
656
+ staleness, 10 s `/token` timeout, never retried); reuse/revocation → `reauth_required`. The
657
+ platform's explicit `error_description: "refresh_token_reused"` is honoured first; a 503 without
658
+ `Retry-After` is treated as spent only as a fallback for older platforms.
659
+ - **`init` preview**: uses the work-level `POST /api/v1/theme-work/{handle}/preview-links` when the
660
+ platform has it (an older platform's 404/405 falls back to finding the work theme's home page).
661
+ - **`blocofy logout`** reports the platform revocation and the local removal separately (exit 4
662
+ when either is not done); `--context` defaults to the `use` context.
663
+ - **`blocofy init [dir]`** (see above): idempotent theme-work start, secret-free
664
+ `.blocofy/init.json`, refuses dirty / other-site directories, resumes from every step, success
665
+ only with a preview and the live theme read back unchanged (exit 5 otherwise).
666
+ - **New platform refusals in plain Turkish**, printed before the usual `error [code]` line and
667
+ never retried: `live_effect_not_permitted`, `credential_reapproval_required` (due date +
668
+ re-approval link), `profile_unsupported`, `audience_mismatch`, `ai_draft`,
669
+ `work_copy_not_writable`.
670
+ - **Profiled credentials**: `bcf2_` dev tokens and `blcf_k2_` API keys are accepted (0.15 and
671
+ older refuse `bcf2_` tokens: upgrade the CLI before using one).
563
672
  - **0.15.0** (2026-10-05) — Theme space, theme work and human-approved
564
673
  publishing. Pairs with the platform release that replaces the 5-draft limit with a per-site theme
565
674
  space.