@riverbankcms/sdk 0.5.2 → 0.5.3
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 +9 -8
- package/dist/cli/index.js +57 -37
- package/dist/cli/index.js.map +1 -1
- package/dist/client/client.js +1 -1
- package/dist/client/client.js.map +1 -1
- package/dist/client/client.mjs +1 -1
- package/dist/client/client.mjs.map +1 -1
- package/dist/server/{chunk-XY66HIB4.mjs → chunk-X4STRF2V.mjs} +2 -2
- package/dist/server/{chunk-XY66HIB4.mjs.map → chunk-X4STRF2V.mjs.map} +1 -1
- package/dist/server/{chunk-6PWMOREA.js → chunk-ZSKOHNE7.js} +2 -2
- package/dist/server/{chunk-6PWMOREA.js.map → chunk-ZSKOHNE7.js.map} +1 -1
- package/dist/server/index.js +2 -2
- package/dist/server/index.mjs +1 -1
- package/dist/server/server.js +2 -2
- package/dist/server/server.mjs +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2266,27 +2266,28 @@ The SDK includes a CLI for syncing your local config to the dashboard.
|
|
|
2266
2266
|
Push content types, custom blocks, and block field extensions to your CMS dashboard:
|
|
2267
2267
|
|
|
2268
2268
|
```bash
|
|
2269
|
-
npx riverbankcms push-config --
|
|
2269
|
+
npx riverbankcms push-config --dashboard <url>
|
|
2270
2270
|
```
|
|
2271
2271
|
|
|
2272
2272
|
**Options:**
|
|
2273
2273
|
|
|
2274
2274
|
| Option | Description |
|
|
2275
2275
|
|--------|-------------|
|
|
2276
|
-
| `--api-key <key>` |
|
|
2277
|
-
| `--dashboard <url>` | Dashboard URL
|
|
2276
|
+
| `--api-key <key>` | Management API key (or set `RIVERBANK_*_MGMT_API_KEY`) |
|
|
2277
|
+
| `--dashboard <url>` | Dashboard URL (or set `RIVERBANK_*_DASHBOARD_URL`) |
|
|
2278
2278
|
| `--config <path>` | Path to config file (default: `./riverbank.config.ts`) |
|
|
2279
2279
|
|
|
2280
2280
|
**Example:**
|
|
2281
2281
|
|
|
2282
2282
|
```bash
|
|
2283
|
-
# Using environment variables
|
|
2284
|
-
export
|
|
2285
|
-
|
|
2283
|
+
# Using environment variables (local)
|
|
2284
|
+
export RIVERBANK_LOCAL_DASHBOARD_URL=https://www.riverbankcms.com
|
|
2285
|
+
export RIVERBANK_LOCAL_MGMT_API_KEY=bld_mgmt_sk_...
|
|
2286
|
+
npx riverbankcms push-config
|
|
2286
2287
|
|
|
2287
|
-
# Or inline
|
|
2288
|
+
# Or inline (remote)
|
|
2288
2289
|
npx riverbankcms push-config \
|
|
2289
|
-
--api-key
|
|
2290
|
+
--api-key bld_mgmt_sk_... \
|
|
2290
2291
|
--dashboard https://www.riverbankcms.com
|
|
2291
2292
|
```
|
|
2292
2293
|
|
package/dist/cli/index.js
CHANGED
|
@@ -5400,7 +5400,7 @@ async function pushToDashboard(dashboardUrl, siteId, apiKey, config3) {
|
|
|
5400
5400
|
method: "POST",
|
|
5401
5401
|
headers: {
|
|
5402
5402
|
"Content-Type": "application/json",
|
|
5403
|
-
"
|
|
5403
|
+
"Authorization": `Bearer ${apiKey}`
|
|
5404
5404
|
},
|
|
5405
5405
|
body: JSON.stringify({ config: config3 }),
|
|
5406
5406
|
signal: AbortSignal.timeout(3e4)
|
|
@@ -5445,28 +5445,40 @@ async function pushConfigAction(options) {
|
|
|
5445
5445
|
process.exit(1);
|
|
5446
5446
|
}
|
|
5447
5447
|
const { siteId } = parseResult.data;
|
|
5448
|
-
|
|
5449
|
-
|
|
5450
|
-
siteId,
|
|
5451
|
-
options.apiKey,
|
|
5452
|
-
parseResult.data
|
|
5453
|
-
);
|
|
5448
|
+
const apiKey = resolveManagementApiKey(options.apiKey, options.isRemote);
|
|
5449
|
+
await pushToDashboard(options.dashboard, siteId, apiKey, parseResult.data);
|
|
5454
5450
|
console.log("Config pushed successfully!");
|
|
5455
5451
|
} catch (error) {
|
|
5456
5452
|
console.error("Error:", error instanceof Error ? error.message : error);
|
|
5457
5453
|
process.exit(1);
|
|
5458
5454
|
}
|
|
5459
5455
|
}
|
|
5460
|
-
function resolveDashboardUrl(cliOption) {
|
|
5461
|
-
const
|
|
5456
|
+
function resolveDashboardUrl(cliOption, isRemote) {
|
|
5457
|
+
const envVar = isRemote ? "RIVERBANK_REMOTE_DASHBOARD_URL" : "RIVERBANK_LOCAL_DASHBOARD_URL";
|
|
5458
|
+
const url = cliOption || process.env[envVar];
|
|
5462
5459
|
if (!url) {
|
|
5463
5460
|
console.error("Error: Dashboard URL is required.");
|
|
5464
|
-
console.error(
|
|
5461
|
+
console.error(`Provide --dashboard <url> or set ${envVar} environment variable.`);
|
|
5465
5462
|
process.exit(1);
|
|
5466
5463
|
}
|
|
5467
5464
|
return url;
|
|
5468
5465
|
}
|
|
5469
|
-
|
|
5466
|
+
function resolveManagementApiKey(cliOption, isRemote) {
|
|
5467
|
+
const envVar = isRemote ? "RIVERBANK_REMOTE_MGMT_API_KEY" : "RIVERBANK_LOCAL_MGMT_API_KEY";
|
|
5468
|
+
const apiKey = cliOption || process.env[envVar];
|
|
5469
|
+
if (!apiKey) {
|
|
5470
|
+
console.error("Error: Management API key is required.");
|
|
5471
|
+
console.error(`Provide --api-key <key> or set ${envVar} environment variable.`);
|
|
5472
|
+
process.exit(1);
|
|
5473
|
+
}
|
|
5474
|
+
if (!apiKey.startsWith("bld_mgmt_sk_")) {
|
|
5475
|
+
console.error(`Error: Invalid management API key format for ${envVar}.`);
|
|
5476
|
+
console.error("Expected key starting with bld_mgmt_sk_.");
|
|
5477
|
+
process.exit(1);
|
|
5478
|
+
}
|
|
5479
|
+
return apiKey;
|
|
5480
|
+
}
|
|
5481
|
+
var pushConfigCommand = new commander.Command("push-config").description("Push SDK config to dashboard").option("--api-key <key>", "Management API key (or set RIVERBANK_*_MGMT_API_KEY)").option("--dashboard <url>", "Dashboard URL (or set RIVERBANK_*_DASHBOARD_URL env var)").option("--config <path>", "Path to config file (default: ./riverbank.config.ts)").addHelpText("after", `
|
|
5470
5482
|
Description:
|
|
5471
5483
|
Syncs your local riverbank.config.ts to the CMS dashboard, including:
|
|
5472
5484
|
- Custom blocks
|
|
@@ -5475,12 +5487,14 @@ Description:
|
|
|
5475
5487
|
- Content types, pages, entries, and navigation
|
|
5476
5488
|
|
|
5477
5489
|
Examples:
|
|
5478
|
-
$ npx riverbankcms push-config
|
|
5479
|
-
$ npx riverbankcms push-config --api-key
|
|
5480
|
-
$ npx riverbankcms push-config --
|
|
5481
|
-
`).action((options) => {
|
|
5482
|
-
const
|
|
5483
|
-
|
|
5490
|
+
$ npx riverbankcms push-config
|
|
5491
|
+
$ npx riverbankcms push-config --api-key bld_mgmt_sk_... --dashboard https://www.riverbankcms.com
|
|
5492
|
+
$ npx riverbankcms push-config --config ./src/riverbank.config.ts
|
|
5493
|
+
`).action((options, command) => {
|
|
5494
|
+
const globalOpts = command.optsWithGlobals();
|
|
5495
|
+
const isRemote = globalOpts.remote ?? false;
|
|
5496
|
+
const dashboard = resolveDashboardUrl(options.dashboard, isRemote);
|
|
5497
|
+
return pushConfigAction({ ...options, dashboard, isRemote });
|
|
5484
5498
|
});
|
|
5485
5499
|
|
|
5486
5500
|
// src/client/management/http.ts
|
|
@@ -6247,6 +6261,29 @@ function createListCommand(config3) {
|
|
|
6247
6261
|
);
|
|
6248
6262
|
}
|
|
6249
6263
|
|
|
6264
|
+
// src/cli/sync/mapper.ts
|
|
6265
|
+
function stripNavigationItemIds(items) {
|
|
6266
|
+
return items.map((item) => {
|
|
6267
|
+
const result = {
|
|
6268
|
+
label: item.label,
|
|
6269
|
+
url: item.url
|
|
6270
|
+
};
|
|
6271
|
+
if (item.children && item.children.length > 0) {
|
|
6272
|
+
result.children = stripNavigationItemIds(item.children);
|
|
6273
|
+
}
|
|
6274
|
+
return result;
|
|
6275
|
+
});
|
|
6276
|
+
}
|
|
6277
|
+
function convertPulledNavigationToLocal(remoteMenus) {
|
|
6278
|
+
return {
|
|
6279
|
+
menus: remoteMenus.map((menu) => ({
|
|
6280
|
+
identifier: menu.identifier,
|
|
6281
|
+
name: menu.name,
|
|
6282
|
+
items: stripNavigationItemIds(menu.items)
|
|
6283
|
+
}))
|
|
6284
|
+
};
|
|
6285
|
+
}
|
|
6286
|
+
|
|
6250
6287
|
// src/cli/content/writer.ts
|
|
6251
6288
|
async function ensureDir(dirPath) {
|
|
6252
6289
|
try {
|
|
@@ -6305,9 +6342,8 @@ async function writeNavigation(contentDir, pulledNavigation) {
|
|
|
6305
6342
|
await ensureDir(contentDir);
|
|
6306
6343
|
await ensureDir(metaDir);
|
|
6307
6344
|
const filePath = path9__namespace.join(contentDir, "navigation.json");
|
|
6308
|
-
|
|
6309
|
-
|
|
6310
|
-
});
|
|
6345
|
+
const localNavigation = convertPulledNavigationToLocal(pulledNavigation.menus);
|
|
6346
|
+
await writeJsonFile(filePath, localNavigation);
|
|
6311
6347
|
const menusMeta = {};
|
|
6312
6348
|
for (const menu of pulledNavigation.menus) {
|
|
6313
6349
|
menusMeta[menu.name] = {
|
|
@@ -6708,22 +6744,6 @@ async function loadCliConfig(configPath) {
|
|
|
6708
6744
|
throw error;
|
|
6709
6745
|
}
|
|
6710
6746
|
}
|
|
6711
|
-
|
|
6712
|
-
// src/cli/sync/mapper.ts
|
|
6713
|
-
function stripNavigationItemIds(items) {
|
|
6714
|
-
return items.map((item) => {
|
|
6715
|
-
const result = {
|
|
6716
|
-
label: item.label,
|
|
6717
|
-
url: item.url
|
|
6718
|
-
};
|
|
6719
|
-
if (item.children && item.children.length > 0) {
|
|
6720
|
-
result.children = stripNavigationItemIds(item.children);
|
|
6721
|
-
}
|
|
6722
|
-
return result;
|
|
6723
|
-
});
|
|
6724
|
-
}
|
|
6725
|
-
|
|
6726
|
-
// src/cli/sync/diff.ts
|
|
6727
6747
|
function findChangedFields(local, remote, prefix = "") {
|
|
6728
6748
|
const changes = [];
|
|
6729
6749
|
const allKeys = /* @__PURE__ */ new Set([...Object.keys(local), ...Object.keys(remote)]);
|
|
@@ -8725,7 +8745,7 @@ Environment Variables:
|
|
|
8725
8745
|
RIVERBANK_REMOTE_MGMT_API_KEY Management API key (bld_mgmt_sk_...)
|
|
8726
8746
|
|
|
8727
8747
|
Examples:
|
|
8728
|
-
$ riverbankcms push-config
|
|
8748
|
+
$ riverbankcms push-config
|
|
8729
8749
|
$ riverbankcms pull # Pull all content from local
|
|
8730
8750
|
$ riverbankcms pull --remote # Pull all content from production
|
|
8731
8751
|
$ riverbankcms pull entries blog-post # Pull specific content type
|