@elmohq/cli 0.4.2 → 0.4.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/dist/index.js +38 -2
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1094,6 +1094,20 @@ function validatePort(value) {
|
|
|
1094
1094
|
const port = Number(value);
|
|
1095
1095
|
return Number.isInteger(port) && port >= 1 && port <= 65535 ? void 0 : "Must be an integer between 1 and 65535";
|
|
1096
1096
|
}
|
|
1097
|
+
function toPublicUrl(value) {
|
|
1098
|
+
const withScheme = /^https?:\/\//i.test(value) ? value : `https://${value}`;
|
|
1099
|
+
try {
|
|
1100
|
+
return new URL(withScheme);
|
|
1101
|
+
} catch {
|
|
1102
|
+
return;
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
function validatePublicUrl(value) {
|
|
1106
|
+
if (!value) return "Required";
|
|
1107
|
+
const url = toPublicUrl(value.trim());
|
|
1108
|
+
if (!url?.hostname.includes(".")) return "Enter a domain, e.g. elmo.example.com";
|
|
1109
|
+
if (url.pathname !== "/") return "Must not include a path";
|
|
1110
|
+
}
|
|
1097
1111
|
async function configureProvidersInteractive(env) {
|
|
1098
1112
|
p.note([
|
|
1099
1113
|
"Elmo needs two kinds of providers:",
|
|
@@ -1314,15 +1328,37 @@ async function runInit(options, version) {
|
|
|
1314
1328
|
placeholder: "you@example.com"
|
|
1315
1329
|
});
|
|
1316
1330
|
const email = p.isCancel(updatesEmail) ? void 0 : updatesEmail || void 0;
|
|
1331
|
+
const access = await p.select({
|
|
1332
|
+
message: "How will you access Elmo?",
|
|
1333
|
+
options: [{
|
|
1334
|
+
value: "local",
|
|
1335
|
+
label: "On this machine (localhost)"
|
|
1336
|
+
}, {
|
|
1337
|
+
value: "public",
|
|
1338
|
+
label: "From a domain (e.g. behind a reverse proxy)"
|
|
1339
|
+
}],
|
|
1340
|
+
initialValue: "local"
|
|
1341
|
+
});
|
|
1342
|
+
assertNotCancelled(access);
|
|
1343
|
+
let publicUrl;
|
|
1344
|
+
if (access === "public") {
|
|
1345
|
+
const domain = await p.text({
|
|
1346
|
+
message: "Domain",
|
|
1347
|
+
placeholder: "elmo.example.com",
|
|
1348
|
+
validate: validatePublicUrl
|
|
1349
|
+
});
|
|
1350
|
+
assertNotCancelled(domain);
|
|
1351
|
+
publicUrl = toPublicUrl(domain.trim());
|
|
1352
|
+
}
|
|
1317
1353
|
const portInput = await p.text({
|
|
1318
|
-
message: "Web app port",
|
|
1354
|
+
message: access === "public" ? "Port for your reverse proxy to forward to" : "Web app port",
|
|
1319
1355
|
placeholder: String(DEFAULT_APP_PORT),
|
|
1320
1356
|
defaultValue: String(DEFAULT_APP_PORT),
|
|
1321
1357
|
validate: validatePort
|
|
1322
1358
|
});
|
|
1323
1359
|
assertNotCancelled(portInput);
|
|
1324
1360
|
const port = Number(portInput);
|
|
1325
|
-
env.APP_URL = `http://localhost:${port}`;
|
|
1361
|
+
env.APP_URL = publicUrl?.origin ?? `http://localhost:${port}`;
|
|
1326
1362
|
env.VITE_APP_URL = env.APP_URL;
|
|
1327
1363
|
const composeYaml = buildComposeYaml({
|
|
1328
1364
|
dev: Boolean(options.dev),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elmohq/cli",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"marketing",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@types/node": "^26.4.1",
|
|
40
40
|
"@types/semver": "^7.8.0",
|
|
41
|
-
"@workspace/config": "0.4.
|
|
41
|
+
"@workspace/config": "0.4.3",
|
|
42
42
|
"rolldown": "^1.2.7",
|
|
43
43
|
"typescript": "^7.0.2",
|
|
44
44
|
"vitest": "^4.1.11"
|