@prenta/cli 1.0.1 β†’ 1.1.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.
@@ -1,4 +1,4 @@
1
1
 
2
- > @prenta/cli@1.0.1 build /home/runner/work/prenta/prenta/packages/cli
2
+ > @prenta/cli@1.1.1 build /home/runner/work/prenta/prenta/packages/cli
3
3
  > tsc
4
4
 
@@ -1,21 +1,33 @@
1
1
 
2
- > @prenta/cli@1.0.1 test /home/runner/work/prenta/prenta/packages/cli
2
+ > @prenta/cli@1.1.1 test /home/runner/work/prenta/prenta/packages/cli
3
3
  > vitest run "--no-file-parallelism"
4
4
 
5
5
 
6
-  RUN  v4.1.8 /home/runner/work/prenta/prenta/packages/cli
7
-
8
- βœ“ src/__tests__/db-restore.test.ts (34 tests) 3161ms
9
- βœ“ src/__tests__/db-backup.test.ts (27 tests) 1691ms
10
- βœ“ src/__tests__/deployment-diagnostics.test.ts (23 tests) 170ms
11
- βœ“ src/__tests__/backup-blob-store.test.ts (18 tests) 432ms
12
- βœ“ src/__tests__/backup-pg-tools.test.ts (26 tests) 231ms
13
- βœ“ src/__tests__/db-sync.test.ts (13 tests) 577ms
6
+  RUN  v4.1.12 /home/runner/work/prenta/prenta/packages/cli
7
+
8
+ βœ“ src/__tests__/db-restore.test.ts (34 tests) 6597ms
9
+ βœ“ requires --target and never defaults to the env database  439ms
10
+ βœ“ warns when --target carries a password on argv and recommends PGPASSWORD instead  491ms
11
+ βœ“ OIDC mode (VERCEL_OIDC_TOKEN + BLOB_STORE_ID) lists and restores without passing a token  608ms
12
+ βœ“ "latest" selects the newest stamp under the prefix  306ms
13
+ βœ“ src/__tests__/db-backup.test.ts (27 tests) 4198ms
14
+ βœ“ writes the workflow YAML verbatim and exits 0 without touching the database  409ms
15
+ βœ“ refuses localhost / 127.0.0.1 unless --allow-local  414ms
16
+ βœ“ src/__tests__/deployment-diagnostics.test.ts (23 tests) 309ms
17
+ βœ“ src/__tests__/backup-blob-store.test.ts (18 tests) 955ms
18
+ βœ“ src/__tests__/backup-pg-tools.test.ts (26 tests) 578ms
19
+ βœ“ src/__tests__/db-sync.test.ts (13 tests) 987ms
20
+ βœ“ src/__tests__/chrome.test.ts (11 tests) 23100ms
14
21
  ↓ src/__tests__/integration/backup-roundtrip.int.test.ts (1 test | 1 skipped)
15
- βœ“ src/__tests__/backup-manifest.test.ts (17 tests) 195ms
16
- βœ“ src/__tests__/backup-crypto.test.ts (13 tests) 429ms
17
- βœ“ src/__tests__/seed.test.ts (10 tests) 105ms
18
- βœ“ src/__tests__/backup-common.test.ts (14 tests) 54ms
22
+ βœ“ src/__tests__/backup-manifest.test.ts (17 tests) 134ms
23
+ - Resolving target versions…
24
+ βœ” Target version: 9.0.0
25
+ βœ“ src/__tests__/upgrade-workspaces.test.ts (12 tests) 3199ms
26
+ βœ“ passes `upgrade --version <ver>` to upgrade instead of printing the CLI version  2065ms
27
+ βœ“ prints its own package version for `prenta --version`  986ms
28
+ βœ“ src/__tests__/backup-crypto.test.ts (13 tests) 317ms
29
+ βœ“ src/__tests__/seed.test.ts (10 tests) 90ms
30
+ βœ“ src/__tests__/backup-common.test.ts (14 tests) 43ms
19
31
  - Reading canonical Prenta schema...
20
32
  βœ” Prenta CMS models added to schema.
21
33
  - Running prisma generate...
@@ -24,10 +36,10 @@
24
36
  β„Ή Run `npx prisma migrate dev --name prenta-cms` to create the migration.
25
37
 
26
38
  - Reading canonical Prenta schema...
39
+ βœ– Could not locate @prenta/core.
27
40
  stdout | src/__tests__/db-init.test.ts > db:init (WS-D D5 β€” canonical schema, no stale fragment) > command > fails clearly when cms-core cannot be located
28
41
  β„Ή Install it first: `npm install @prenta/core`.
29
42
 
30
- βœ– Could not locate @prenta/core.
31
43
  - Reading canonical Prenta schema...
32
44
  βœ” Prenta CMS models added to schema.
33
45
  stdout | src/__tests__/db-init.test.ts > db:init (WS-D D5 β€” canonical schema, no stale fragment) > command > is idempotent without --force
@@ -37,7 +49,7 @@
37
49
 
38
50
  - Reading canonical Prenta schema...
39
51
  β„Ή Prenta CMS models already present in schema. Use --force to overwrite.
40
- βœ“ src/__tests__/db-init.test.ts (4 tests) 227ms
52
+ βœ“ src/__tests__/db-init.test.ts (4 tests) 210ms
41
53
  stdout | src/__tests__/mcp-init.test.ts > mcp:init > creates both editor configs with placeholder key and git-ignores them
42
54
  βœ” Created .cursor/mcp.json
43
55
 
@@ -108,9 +120,6 @@ Next steps
108
120
  2. Replace act_sk_REPLACE_WITH_YOUR_KEY in both config files with the real key
109
121
  3. Restart Cursor / VS Code so the MCP server is picked up
110
122
 
111
- stderr | src/__tests__/mcp-init.test.ts > mcp:init > fails on invalid JSON without --force, overwrites with --force
112
- βœ– .cursor/mcp.json contains invalid JSON β€” fix it or re-run with --force.
113
-
114
123
  stdout | src/__tests__/mcp-init.test.ts > mcp:init > fails on invalid JSON without --force, overwrites with --force
115
124
  βœ” Created .vscode/mcp.json
116
125
 
@@ -123,6 +132,9 @@ Next steps
123
132
  3. Restart Cursor / VS Code so the MCP server is picked up
124
133
  Tip: pass --url https://your-site.com to target a deployed CMS instead.
125
134
 
135
+ stderr | src/__tests__/mcp-init.test.ts > mcp:init > fails on invalid JSON without --force, overwrites with --force
136
+ βœ– .cursor/mcp.json contains invalid JSON β€” fix it or re-run with --force.
137
+
126
138
  stdout | src/__tests__/mcp-init.test.ts > mcp:init > fails on invalid JSON without --force, overwrites with --force
127
139
  βœ” Updated .cursor/mcp.json
128
140
 
@@ -166,27 +178,28 @@ Next steps
166
178
  3. Restart Cursor / VS Code so the MCP server is picked up
167
179
  Tip: pass --url https://your-site.com to target a deployed CMS instead.
168
180
 
169
- βœ“ src/__tests__/mcp-init.test.ts (6 tests) 271ms
170
- βœ“ src/__tests__/prisma-client-path.test.ts (8 tests) 116ms
171
- βœ“ src/__tests__/form-seed.test.ts (10 tests) 48ms
181
+ βœ“ src/__tests__/mcp-init.test.ts (6 tests) 231ms
182
+ βœ“ src/__tests__/prisma-client-path.test.ts (8 tests) 50ms
183
+ βœ“ src/__tests__/form-seed.test.ts (10 tests) 35ms
172
184
  βœ“ src/__tests__/vercel-env-matrix.test.ts (6 tests) 32ms
173
- βœ“ src/__tests__/upgrade.test.ts (3 tests) 52ms
174
- βœ“ src/__tests__/repo-root.test.ts (4 tests) 101ms
175
- βœ“ src/__tests__/load-dotenv.test.ts (3 tests) 60ms
185
+ βœ“ src/__tests__/upgrade.test.ts (3 tests) 36ms
186
+ βœ“ src/__tests__/repo-root.test.ts (4 tests) 40ms
187
+ βœ“ src/__tests__/load-dotenv.test.ts (3 tests) 27ms
176
188
  - Reading canonical Prenta schema...
177
189
  βœ” Prenta CMS models added to schema.
178
190
  stdout | src/__tests__/schema-fragment.test.ts > db:init schema fragment > injects all deploy-critical Prenta models
191
+ - Running prisma generate...
179
192
  βœ” Prisma client generated.
180
193
  β„Ή Run `npx prisma migrate dev --name prenta-cms` to create the migration.
181
194
 
182
- - Running prisma generate...
183
- βœ“ src/__tests__/schema-fragment.test.ts (1 test) 125ms
184
- βœ“ src/__tests__/db-sync-resolver.test.ts (4 tests) 21ms
185
- βœ“ src/__tests__/import-typescript.test.ts (3 tests) 145ms
186
- βœ“ src/__tests__/init.test.ts (2 tests) 30ms
187
-
188
-  Test Files  22 passed | 1 skipped (23)
189
-  Tests  249 passed | 1 skipped (250)
190
-  Start at  15:34:38
191
-  Duration  38.55s (transform 3.78s, setup 0ms, import 8.64s, tests 8.27s, environment 25ms)
195
+ βœ“ src/__tests__/schema-fragment.test.ts (1 test) 137ms
196
+ βœ“ src/__tests__/db-sync-resolver.test.ts (4 tests) 25ms
197
+ βœ“ src/__tests__/import-typescript.test.ts (3 tests) 465ms
198
+ βœ“ loads a TypeScript file that imports a sibling without appending ?namespace=  436ms
199
+ βœ“ src/__tests__/init.test.ts (2 tests) 54ms
200
+
201
+  Test Files  24 passed | 1 skipped (25)
202
+  Tests  272 passed | 1 skipped (273)
203
+  Start at  05:51:01
204
+  Duration  86.88s (transform 25.02s, setup 0ms, import 15.82s, tests 41.85s, environment 27ms)
192
205
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,32 @@
1
1
  # @actuate-media/cli
2
2
 
3
+ ## 1.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 9a5efca: `prenta upgrade` updates every workspace package, not just the root `package.json` (#1096).
8
+ - Reads `workspaces` (npm, yarn, bun) and `pnpm-workspace.yaml`, and upgrades `@prenta/*` ranges in each workspace manifest, so an app and its site no longer end up on two different CMS versions. The table shows which file each upgrade is in.
9
+ - Keeps each manifest's indentation and line endings, and leaves `workspace:`, `file:` and tag specs alone.
10
+ - Warns when run from inside a workspace package instead of the root.
11
+ - Suggests the install command for the lockfile in use (npm, pnpm, yarn or bun) instead of always `pnpm install`.
12
+ - `prenta upgrade --version <ver>` works: it printed the CLI version before. `prenta --version` now reports the real CLI version instead of `0.1.0`.
13
+
14
+ ## 1.1.0
15
+
16
+ ### Minor Changes
17
+
18
+ - 69b9667: Porcelain, Linen, and Graphite replace the purple admin palette. Accent presets are Cobalt, Teal, Actuate coral, Rust, and Slate, each tuned to 4.5:1. Shared page header, count chip, tabs, and unsaved bar are new exports. Legacy accent names still resolve.
19
+
20
+ Jobs can be cancelled. A queued job stops immediately; a running job stops after the current slice. Review decisions, batch estimates, and the admin-only automatic apply rule are enforced in cms-core.
21
+
22
+ Menus keep a location on one menu and stop new indents at depth 2. Chrome is a code-first schema with `defineRegion` and `prenta pull chrome`. Form settings cover attribution windows, spam terms, closed forms, and retention.
23
+
24
+ - 69b9667: Sites declare what editors can change in their header and footer with `defineRegion(name, { component, variants, fields })` and `field.brand`, `menu`, `link`, `text`, `textarea`, `select`, `boolean` and `social`, from `@prenta/core/config`. Saved values are typed per region: `RegionValues<typeof header>` for what the CMS stores, `ChromeFieldsOf<typeof header>` for what the site receives. The earlier array-of-fields `defineRegion` and `DEFAULT_CHROME_SCHEMA` are gone, and the `@prenta/core/chrome/schema` entry with them.
25
+
26
+ `prenta push chrome` sends the regions `prenta.config.ts` exports to the CMS, with the repo, branch and commit; run it on every deploy, with an admin API key. The CMS stores each region's schema and fits the saved values to it. A value whose field was removed is kept as an orphan for 30 days, or until someone removes it. A field with `renamedFrom` keeps the old key's value. `prenta pull chrome` writes the CMS's schema to `.prenta/chrome.json`, and `prenta types` generates `ChromeFields` from it.
27
+
28
+ Migration 0027 adds the `prenta_chrome_regions` table. It ships a `down.sql` for manual rollback.
29
+
3
30
  ## 1.0.1
4
31
 
5
32
  ### Patch Changes
@@ -0,0 +1,74 @@
1
+ import { Command } from 'commander';
2
+ import type { ChromeSchemaReadResult, ChromeSyncStatus, RegionDefinition, RegionSchema } from '@prenta/core';
3
+ export interface CmsConnection {
4
+ url?: string;
5
+ key?: string;
6
+ fetch?: typeof fetch;
7
+ }
8
+ /** What `prenta pull chrome` writes and `prenta types` reads. */
9
+ export interface PulledChrome {
10
+ pulledAt: string;
11
+ cms: string;
12
+ sync: ChromeSyncStatus;
13
+ regions: RegionSchema[];
14
+ }
15
+ /** The CMS API base for `--url` / `PRENTA_CMS_URL`, with or without `/api/cms` on the end. */
16
+ export declare function cmsApiBase(url: string): string;
17
+ /** Fetch the schema the CMS holds and write it to `.prenta/chrome.json`. */
18
+ export declare function pullChrome(options?: CmsConnection & {
19
+ out?: string;
20
+ cwd?: string;
21
+ }): Promise<{
22
+ file: string;
23
+ pulled: PulledChrome;
24
+ }>;
25
+ /** Generate `ChromeFields` from `.prenta/chrome.json`. With `out: '-'` the source is returned, not written. */
26
+ export declare function writeChromeTypes(options?: {
27
+ in?: string;
28
+ out?: string;
29
+ cwd?: string;
30
+ }): Promise<{
31
+ file: string | null;
32
+ source: string;
33
+ }>;
34
+ /** Every `defineRegion` a config module exports, named or default. */
35
+ export declare function collectRegions(mod: unknown): Promise<RegionDefinition[]>;
36
+ export interface SchemaSource {
37
+ repo: string;
38
+ branch: string;
39
+ commit: string;
40
+ }
41
+ type Run = (file: string, args: string[], options: {
42
+ cwd: string;
43
+ }) => string;
44
+ /**
45
+ * `git@github.com:owner/repo.git` or `https://github.com/owner/repo` β†’ `owner/repo`.
46
+ * Credentials in the remote (`https://oauth2:TOKEN@host/site.git`) are
47
+ * dropped: the CMS stores the source and shows it to everyone who signs in.
48
+ */
49
+ export declare function repoFromRemote(remote: string): string;
50
+ /** Where the schema comes from: CI variables first (Vercel, GitHub Actions), then git. */
51
+ export declare function detectSource(env?: NodeJS.ProcessEnv, cwd?: string, run?: Run): SchemaSource;
52
+ export interface PushChromeOptions extends CmsConnection {
53
+ config?: string;
54
+ cwd?: string;
55
+ dryRun?: boolean;
56
+ source?: Partial<SchemaSource>;
57
+ /** Loads the config module. Tests pass their own. */
58
+ load?: (file: string) => Promise<unknown>;
59
+ }
60
+ /**
61
+ * The deploy hook: send the regions a config defines to `PUT /chrome/schema`.
62
+ * Needs an admin-scoped API key. A region the config no longer defines loses
63
+ * its schema, and its values are kept as orphans for 30 days.
64
+ */
65
+ export declare function pushChrome(options?: PushChromeOptions): Promise<{
66
+ payload: {
67
+ regions: unknown[];
68
+ source: SchemaSource;
69
+ };
70
+ result: ChromeSchemaReadResult | null;
71
+ }>;
72
+ export declare function registerChromeCommand(program: Command): void;
73
+ export {};
74
+ //# sourceMappingURL=chrome.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chrome.d.ts","sourceRoot":"","sources":["../../src/commands/chrome.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,KAAK,EACV,sBAAsB,EACtB,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,EACb,MAAM,cAAc,CAAA;AAiBrB,MAAM,WAAW,aAAa;IAC5B,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,OAAO,KAAK,CAAA;CACrB;AAED,iEAAiE;AACjE,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,CAAA;IAChB,GAAG,EAAE,M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,EACnB,GAAG,GAAE,GAAY,GAChB,YAAY,CAkBd;AAED,MAAM,WAAW,iBAAkB,SAAQ,aAAa;IACtD,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,CAAA;IAC9B,qDAAqD;IACrD,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;CAC1C;AAED;;;;GAIG;AACH,wBAAsB,UAAU,CAAC,OAAO,GAAE,iBAAsB,GAAG,OAAO,CAAC;IACzE,OAAO,EAAE;QAAE,OAAO,EAAE,OAAO,EAAE,CAAC;QAAC,MAAM,EAAE,YAAY,CAAA;KAAE,CAAA;IACrD,MAAM,EAAE,sBAAsB,GAAG,IAAI,CAAA;CACtC,CAAC,CAqBD;AAsBD,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAgF5D"}
@@ -0,0 +1,274 @@
1
+ import { execFileSync } from 'node:child_process';
2
+ import { mkdir, readFile, writeFile } from 'node:fs/promises';
3
+ import path from 'node:path';
4
+ import { importProjectTypescript } from '../utils/import-typescript.js';
5
+ import { logger } from '../utils/logger.js';
6
+ const DEFAULT_SCHEMA_FILE = '.prenta/chrome.json';
7
+ const DEFAULT_TYPES_FILE = '.prenta/chrome.d.ts';
8
+ const REQUEST_TIMEOUT_MS = 20_000;
9
+ /** Load core only for the chrome commands, so the rest of the CLI doesn't pay for it. */
10
+ async function chromeCore() {
11
+ const core = await import('@prenta/core');
12
+ if (typeof core.chromeTypesSource !== 'function' || typeof core.serializeRegion !== 'function') {
13
+ throw new Error('The chrome commands need a newer @prenta/core. Update it, then try again.');
14
+ }
15
+ return core;
16
+ }
17
+ /** The CMS API base for `--url` / `PRENTA_CMS_URL`, with or without `/api/cms` on the end. */
18
+ export function cmsApiBase(url) {
19
+ const origin = url.trim().replace(/\/+$/, '');
20
+ return /\/api\/cms(\/v1)?$/.test(origin) ? origin : `${origin}/api/cms`;
21
+ }
22
+ function connection(options) {
23
+ const url = options.url ?? process.env.PRENTA_CMS_URL;
24
+ const key = options.key ?? process.env.PRENTA_API_KEY;
25
+ if (!url)
26
+ throw new Error('Set the CMS URL with --url or PRENTA_CMS_URL.');
27
+ if (!key)
28
+ throw new Error('Set an API key with --key or PRENTA_API_KEY.');
29
+ return { base: cmsApiBase(url), key, fetch: options.fetch ?? fetch };
30
+ }
31
+ async function cmsRequest(conn, method, route, body) {
32
+ const response = await conn.fetch(`${conn.base}${route}`, {
33
+ method,
34
+ headers: {
35
+ authorization: `Bearer ${conn.key}`,
36
+ accept: 'application/json',
37
+ ...(body !== undefined ? { 'content-type': 'application/json' } : {}),
38
+ },
39
+ ...(body !== undefined ? { body: JSON.stringify(body) } : {}),
40
+ signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS),
41
+ });
42
+ const text = await response.text();
43
+ let parsed = null;
44
+ try {
45
+ parsed = text ? JSON.parse(text) : null;
46
+ }
47
+ catch {
48
+ // Not JSON: report the status below.
49
+ }
50
+ if (!response.ok) {
51
+ throw new Error(`${method} ${route} failed (${response.status}): ${parsed?.error ?? text.slice(0, 200)}`);
52
+ }
53
+ if (!parsed || parsed.data === undefined)
54
+ throw new Error(`${method} ${route} returned no data`);
55
+ return parsed.data;
56
+ }
57
+ // ─── pull ───────────────────────────────────────────────────────────────
58
+ /** Fetch the schema the CMS holds and write it to `.prenta/chrome.json`. */
59
+ export async function pullChrome(options = {}) {
60
+ const conn = connection(options);
61
+ const view = await cmsRequest(conn, 'GET', '/chrome/schema');
62
+ const pulled = {
63
+ pulledAt: new Date().toISOString(),
64
+ cms: conn.base,
65
+ sync: view.sync,
66
+ regions: view.regions,
67
+ };
68
+ const file = path.resolve(options.cwd ?? process.cwd(), options.out ?? DEFAULT_SCHEMA_FILE);
69
+ await mkdir(path.dirname(file), { recursive: true });
70
+ await writeFile(file, `${JSON.stringify(pulled, null, 2)}\n`);
71
+ return { file, pulled };
72
+ }
73
+ // ─── types ──────────────────────────────────────────────────────────────
74
+ /** Generate `ChromeFields` from `.prenta/chrome.json`. With `out: '-'` the source is returned, not written. */
75
+ export async function writeChromeTypes(options = {}) {
76
+ const cwd = options.cwd ?? process.cwd();
77
+ const input = path.resolve(cwd, options.in ?? DEFAULT_SCHEMA_FILE);
78
+ let pulled;
79
+ try {
80
+ pulled = JSON.parse(await readFile(input, 'utf8'));
81
+ }
82
+ catch (err) {
83
+ const code = err.code;
84
+ throw new Error(code === 'ENOENT'
85
+ ? `${path.relative(cwd, input) || input} doesn't exist yet. Run \`prenta pull chrome\` first.`
86
+ : `Couldn't read ${input}: ${err instanceof Error ? err.message : String(err)}`);
87
+ }
88
+ if (!Array.isArray(pulled.regions))
89
+ throw new Error(`${input} has no regions`);
90
+ const source = (await chromeCore()).chromeTypesSource(pulled.regions);
91
+ if (options.out === '-')
92
+ return { file: null, source };
93
+ const file = path.resolve(cwd, options.out ?? DEFAULT_TYPES_FILE);
94
+ await mkdir(path.dirname(file), { recursive: true });
95
+ await writeFile(file, source);
96
+ return { file, source };
97
+ }
98
+ // ─── push ───────────────────────────────────────────────────────────────
99
+ /** Every `defineRegion` a config module exports, named or default. */
100
+ export async function collectRegions(mod) {
101
+ if (typeof mod !== 'object' || mod === null)
102
+ return [];
103
+ const { isRegionDefinition } = await chromeCore();
104
+ const found = new Map();
105
+ for (const value of Object.values(mod)) {
106
+ if (isRegionDefinition(value)) {
107
+ if (found.has(value.region)) {
108
+ throw new Error(`The config defines the ${value.region} region twice.`);
109
+ }
110
+ found.set(value.region, value);
111
+ }
112
+ }
113
+ return [...found.values()];
114
+ }
115
+ const runGit = (file, args, options) => execFileSync(file, args, {
116
+ cwd: options.cwd,
117
+ encoding: 'utf8',
118
+ stdio: ['ignore', 'pipe', 'ignore'],
119
+ });
120
+ /**
121
+ * `git@github.com:owner/repo.git` or `https://github.com/owner/repo` β†’ `owner/repo`.
122
+ * Credentials in the remote (`https://oauth2:TOKEN@host/site.git`) are
123
+ * dropped: the CMS stores the source and shows it to everyone who signs in.
124
+ */
125
+ export function repoFromRemote(remote) {
126
+ const trimmed = remote.trim();
127
+ let path;
128
+ if (/^[a-z][a-z0-9+.-]*:\/\//i.test(trimmed)) {
129
+ try {
130
+ path = new URL(trimmed).pathname;
131
+ }
132
+ catch {
133
+ path = trimmed.replace(/^[a-z][a-z0-9+.-]*:\/\/[^/]*/i, '');
134
+ }
135
+ }
136
+ else {
137
+ // scp-like `[user[:password]@]host:owner/repo`.
138
+ path = trimmed.replace(/^[^@/]*@/, '').replace(/^[^:/]+:/, '/');
139
+ }
140
+ const segments = path
141
+ .replace(/\.git\/?$/, '')
142
+ .split('/')
143
+ .filter(Boolean);
144
+ return segments.slice(-2).join('/');
145
+ }
146
+ /** Where the schema comes from: CI variables first (Vercel, GitHub Actions), then git. */
147
+ export function detectSource(env = process.env, cwd = process.cwd(), run = runGit) {
148
+ const git = (args) => {
149
+ try {
150
+ return run('git', args, { cwd }).trim();
151
+ }
152
+ catch {
153
+ return '';
154
+ }
155
+ };
156
+ const vercelRepo = env.VERCEL_GIT_REPO_OWNER && env.VERCEL_GIT_REPO_SLUG
157
+ ? `${env.VERCEL_GIT_REPO_OWNER}/${env.VERCEL_GIT_REPO_SLUG}`
158
+ : '';
159
+ const repo = vercelRepo || env.GITHUB_REPOSITORY || repoFromRemote(git(['remote', 'get-url', 'origin']));
160
+ const branch = env.VERCEL_GIT_COMMIT_REF || env.GITHUB_REF_NAME || git(['rev-parse', '--abbrev-ref', 'HEAD']);
161
+ const commit = env.VERCEL_GIT_COMMIT_SHA || env.GITHUB_SHA || git(['rev-parse', 'HEAD']);
162
+ return { repo, branch, commit };
163
+ }
164
+ /**
165
+ * The deploy hook: send the regions a config defines to `PUT /chrome/schema`.
166
+ * Needs an admin-scoped API key. A region the config no longer defines loses
167
+ * its schema, and its values are kept as orphans for 30 days.
168
+ */
169
+ export async function pushChrome(options = {}) {
170
+ const cwd = options.cwd ?? process.cwd();
171
+ const configPath = path.resolve(cwd, options.config ?? 'prenta.config.ts');
172
+ const mod = await (options.load ?? importProjectTypescript)(configPath);
173
+ const regions = await collectRegions(mod);
174
+ if (regions.length === 0) {
175
+ throw new Error(`${path.relative(cwd, configPath) || configPath} exports no regions. Export each one: export const header = defineRegion('header', { … }).`);
176
+ }
177
+ const source = { ...detectSource(process.env, cwd), ...options.source };
178
+ const { serializeRegion } = await chromeCore();
179
+ const payload = { regions: regions.map((region) => serializeRegion(region)), source };
180
+ if (options.dryRun)
181
+ return { payload, result: null };
182
+ const result = await cmsRequest(connection(options), 'PUT', '/chrome/schema', payload);
183
+ return { payload, result };
184
+ }
185
+ function describeRead(result) {
186
+ return result.regions.map((region) => {
187
+ const parts = [];
188
+ if (region.orphaned.length > 0) {
189
+ parts.push(`kept ${region.orphaned.join(', ')} as orphans for 30 days`);
190
+ }
191
+ for (const { from, to } of region.renamed)
192
+ parts.push(`moved ${from} to ${to}`);
193
+ if (region.restored.length > 0)
194
+ parts.push(`restored ${region.restored.join(', ')}`);
195
+ const what = parts.length > 0 ? parts.join('; ') : region.changed ? 'updated' : 'unchanged';
196
+ return `${region.region}: ${what}`;
197
+ });
198
+ }
199
+ // ─── commands ───────────────────────────────────────────────────────────
200
+ function fail(err) {
201
+ logger.error(err instanceof Error ? err.message : String(err));
202
+ process.exitCode = 1;
203
+ }
204
+ export function registerChromeCommand(program) {
205
+ const pull = program.command('pull').description('Read what the CMS holds into .prenta/');
206
+ pull
207
+ .command('chrome')
208
+ .description('Write the header and footer schema the CMS holds to .prenta/chrome.json')
209
+ .option('--url <url>', 'CMS origin (default: PRENTA_CMS_URL)')
210
+ .option('--key <key>', 'API key with the chrome scope (default: PRENTA_API_KEY)')
211
+ .option('--out <file>', 'Where to write it', DEFAULT_SCHEMA_FILE)
212
+ .action(async (options) => {
213
+ try {
214
+ const { file, pulled } = await pullChrome(options);
215
+ const regions = pulled.regions.map((region) => region.region).join(', ') || 'no regions yet';
216
+ logger.success(`Wrote ${path.relative(process.cwd(), file)} (${regions})`);
217
+ }
218
+ catch (err) {
219
+ fail(err);
220
+ }
221
+ });
222
+ const push = program.command('push').description('Send what the site defines to the CMS');
223
+ push
224
+ .command('chrome')
225
+ .description('Send the defineRegion schemas in prenta.config.ts to the CMS. Run it on every deploy.')
226
+ .option('--config <path>', 'Config that exports the regions', 'prenta.config.ts')
227
+ .option('--url <url>', 'CMS origin (default: PRENTA_CMS_URL)')
228
+ .option('--key <key>', 'Admin API key (default: PRENTA_API_KEY)')
229
+ .option('--repo <repo>', 'Repository shown as the source (default: from CI or git)')
230
+ .option('--branch <branch>', 'Branch shown as the source (default: from CI or git)')
231
+ .option('--commit <sha>', 'Commit shown as the source (default: from CI or git)')
232
+ .option('--dry-run', 'Print what would be sent, and send nothing')
233
+ .action(async (options) => {
234
+ try {
235
+ const source = {};
236
+ if (options.repo)
237
+ source.repo = options.repo;
238
+ if (options.branch)
239
+ source.branch = options.branch;
240
+ if (options.commit)
241
+ source.commit = options.commit;
242
+ const { payload, result } = await pushChrome({ ...options, source });
243
+ if (!result) {
244
+ process.stdout.write(`${JSON.stringify(payload, null, 2)}\n`);
245
+ return;
246
+ }
247
+ logger.success(`Schema read at ${payload.source.repo || 'unknown repo'}@${payload.source.commit || 'unknown'}`);
248
+ for (const line of describeRead(result))
249
+ logger.info(line);
250
+ }
251
+ catch (err) {
252
+ fail(err);
253
+ }
254
+ });
255
+ program
256
+ .command('types')
257
+ .description('Generate ChromeFields types from .prenta/chrome.json (run prenta pull chrome first)')
258
+ .option('--in <file>', 'Pulled schema', DEFAULT_SCHEMA_FILE)
259
+ .option('--out <file>', 'Where to write the types ("-" prints them)', DEFAULT_TYPES_FILE)
260
+ .action(async (options) => {
261
+ try {
262
+ const { file, source } = await writeChromeTypes(options);
263
+ if (!file) {
264
+ process.stdout.write(source);
265
+ return;
266
+ }
267
+ logger.success(`Wrote ${path.relative(process.cwd(), file)}`);
268
+ }
269
+ catch (err) {
270
+ fail(err);
271
+ }
272
+ });
273
+ }
274
+ //# sourceMappingURL=chrome.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chrome.js","sourceRoot":"","sources":["../../src/commands/chrome.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC7D,OAAO,IAAI,MAAM,WAAW,CAAA;AAQ5B,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAA;AACvE,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAE3C,MAAM,mBAAmB,GAAG,qBAAqB,CAAA;AACjD,MAAM,kBAAkB,GAAG,qBAAqB,CAAA;AAChD,MAAM,kBAAkB,GAAG,MAAM,CAAA;AAEjC,yFAAyF;AACzF,KAAK,UAAU,UAAU;IACvB,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,cAAc,CAAC,CAAA;IACzC,IAAI,OAAO,IAAI,CAAC,iBAAiB,KAAK,UAAU,IAAI,OAAO,IAAI,CAAC,eAAe,KAAK,UAAU,EAAE,CAAC;QAC/F,MAAM,IAAI,KAAK,CAAC,2EAA2E,CAAC,CAAA;IAC9F,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC;AAgBD,8FAA8F;AAC9F,MAAM,UAAU,UAAU,CAAC,GAAW;IACpC,MAAM,MAAM,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;IAC7C,OAAO,oBAAoB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,UAAU,CAAA;AACzE,CAAC;AAED,SAAS,UAAU,CAAC,OAAsB;IACxC,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,O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AAG,EAAE,CAAC;YACb,IAAI,CAAC,GAAG,CAAC,CAAA;QACX,CAAC;IACH,CAAC,CAAC,CAAA;AACN,CAAC"}
@@ -1,4 +1,31 @@
1
1
  import { Command } from 'commander';
2
2
  export declare function fetchLatestVersions(packages: string[]): Promise<Record<string, string>>;
3
+ declare const DEPENDENCY_SECTIONS: readonly ["dependencies", "devDependencies", "optionalDependencies"];
4
+ type DependencySection = (typeof DEPENDENCY_SECTIONS)[number];
5
+ export interface Manifest {
6
+ path: string;
7
+ json: Record<string, unknown>;
8
+ indent: string;
9
+ eol: string;
10
+ trailingNewline: boolean;
11
+ }
12
+ export interface PrentaDependency {
13
+ manifest: Manifest;
14
+ section: DependencySection;
15
+ name: string;
16
+ prefix: string;
17
+ current: string;
18
+ }
19
+ export interface PlannedUpgrade extends PrentaDependency {
20
+ to: string;
21
+ }
22
+ export declare function readManifest(path: string): Promise<Manifest>;
23
+ /** The root manifest followed by every workspace package manifest under it. */
24
+ export declare function readProjectManifests(root: string): Promise<Manifest[]>;
25
+ export declare function collectPrentaDependencies(manifests: Manifest[]): PrentaDependency[];
26
+ export declare function planUpgrades(deps: PrentaDependency[], targets: Record<string, string>): PlannedUpgrade[];
27
+ /** Rewrites each touched manifest, keeping its indentation and line endings. */
28
+ export declare function applyUpgrades(upgrades: PlannedUpgrade[]): Promise<Manifest[]>;
3
29
  export declare function registerUpgradeCommand(program: Command): void;
30
+ export {};
4
31
  //# sourceMappingURL=upgrade.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"upgrade.d.ts","sourceRoot":"","sources":["../../src/commands/upgrade.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AA6CnC,wBAAsB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAgC7F;AAoHD,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,GAA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