@maker-or/opencms 0.1.3 → 0.1.4
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 +2 -0
- package/dist/index.js +9 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -22,3 +22,5 @@ npx @maker-or/opencms deploy
|
|
|
22
22
|
The generated `cms/schema.json` file defines the project's content types and allowed blocks. The CLI syncs it to the development environment when `dev` or `deploy` runs.
|
|
23
23
|
|
|
24
24
|
The CLI stores its local login configuration in `~/.config/opencms/config.json` (or `$XDG_CONFIG_HOME/opencms/config.json` when configured).
|
|
25
|
+
|
|
26
|
+
The CLI defaults to the hosted OpenCMS dashboard and API. Use `OPENCMS_DASHBOARD_URL` and `OPENCMS_API_URL` to target a local or self-hosted instance.
|
package/dist/index.js
CHANGED
|
@@ -65,7 +65,12 @@ class OpenCmsApiError extends Error {
|
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
function createSdk(options = {}) {
|
|
68
|
-
const
|
|
68
|
+
const defaultBaseUrl = typeof window === "undefined" ? undefined : window.location.origin;
|
|
69
|
+
const configuredBaseUrl = options.baseUrl ?? defaultBaseUrl;
|
|
70
|
+
if (!configuredBaseUrl) {
|
|
71
|
+
throw new Error("baseUrl is required when using the OpenCMS SDK outside a browser.");
|
|
72
|
+
}
|
|
73
|
+
const baseUrl = configuredBaseUrl.replace(/\/$/, "");
|
|
69
74
|
const fetcher = options.fetch ?? globalThis.fetch;
|
|
70
75
|
const projectId = options.projectId;
|
|
71
76
|
const environment = options.environment ?? "development";
|
|
@@ -201,8 +206,9 @@ function createSdk(options = {}) {
|
|
|
201
206
|
}
|
|
202
207
|
|
|
203
208
|
// src/index.ts
|
|
204
|
-
var
|
|
205
|
-
var
|
|
209
|
+
var hostedUrl = "https://web-eta-ten-16.vercel.app";
|
|
210
|
+
var dashboardUrl = process.env.OPENCMS_DASHBOARD_URL ?? hostedUrl;
|
|
211
|
+
var apiUrl = process.env.OPENCMS_API_URL ?? hostedUrl;
|
|
206
212
|
var configRoot = process.env.XDG_CONFIG_HOME ?? join(homedir(), ".config");
|
|
207
213
|
var configPath = join(configRoot, "opencms", "config.json");
|
|
208
214
|
async function readConfig() {
|