@cmssy/cli 9.1.0 → 9.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.
- package/dist/index.js +20 -18
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -211,7 +211,6 @@ Edit this site visually:
|
|
|
211
211
|
|
|
212
212
|
// src/link.ts
|
|
213
213
|
var ENV_FILES = [".env.local", ".env"];
|
|
214
|
-
var DEFAULT_PREVIEW_URL = "http://localhost:3000";
|
|
215
214
|
function loadEnvFiles(cwd, env) {
|
|
216
215
|
for (const file of ENV_FILES) {
|
|
217
216
|
const path = join(cwd, file);
|
|
@@ -278,22 +277,25 @@ async function selectWorkspace(workspaces, options, deps) {
|
|
|
278
277
|
}
|
|
279
278
|
return selected;
|
|
280
279
|
}
|
|
281
|
-
|
|
282
|
-
if (options.previewUrl)
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
280
|
+
function resolvePreviewUrl(options) {
|
|
281
|
+
if (!options.previewUrl) return null;
|
|
282
|
+
let origin;
|
|
283
|
+
try {
|
|
284
|
+
origin = new URL(options.previewUrl).origin;
|
|
285
|
+
} catch {
|
|
286
|
+
throw new CliError(
|
|
287
|
+
`"${options.previewUrl}" is not a valid URL`,
|
|
288
|
+
"pass --preview-url with your DEPLOYED site origin, e.g. --preview-url https://example.com"
|
|
289
|
+
);
|
|
291
290
|
}
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
291
|
+
const { hostname } = new URL(origin);
|
|
292
|
+
if (hostname === "localhost" || hostname === "127.0.0.1") {
|
|
293
|
+
throw new CliError(
|
|
294
|
+
"the workspace preview URL is the DEPLOYED site every editor in the workspace previews - not your localhost",
|
|
295
|
+
"for local development, toggle dev mode in the cmssy editor and enter your local host there (per user, nothing shared)"
|
|
296
|
+
);
|
|
297
|
+
}
|
|
298
|
+
return origin;
|
|
297
299
|
}
|
|
298
300
|
function writeEnvLocal(cwd, updates) {
|
|
299
301
|
const path = join(cwd, ".env.local");
|
|
@@ -330,7 +332,7 @@ async function runLink(options, deps) {
|
|
|
330
332
|
workspaceId: workspace.id
|
|
331
333
|
});
|
|
332
334
|
log(formatResult({ status: "ok", message: "fetched the draft secret" }));
|
|
333
|
-
const previewUrl =
|
|
335
|
+
const previewUrl = resolvePreviewUrl(options);
|
|
334
336
|
if (previewUrl) {
|
|
335
337
|
await setPreviewUrl(previewUrl, { ...admin, workspaceId: workspace.id });
|
|
336
338
|
log(
|
|
@@ -343,7 +345,7 @@ async function runLink(options, deps) {
|
|
|
343
345
|
log(
|
|
344
346
|
formatResult({
|
|
345
347
|
status: "unknown",
|
|
346
|
-
message:
|
|
348
|
+
message: "preview URL left unchanged - pass --preview-url <deployed origin> to set it; for localhost use the editor dev-mode switch"
|
|
347
349
|
})
|
|
348
350
|
);
|
|
349
351
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cmssy/cli",
|
|
3
|
-
"version": "9.1.
|
|
3
|
+
"version": "9.1.1",
|
|
4
4
|
"description": "One command to connect an app to a cmssy workspace: `cmssy link` writes .env.local, sets the preview URL and verifies the editor wiring.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cmssy",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"dist"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@cmssy/core": "9.1.
|
|
28
|
+
"@cmssy/core": "9.1.1"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/node": "^20.0.0",
|