@elmohq/cli 0.4.2 → 0.4.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.
Files changed (2) hide show
  1. package/dist/index.js +41 -6
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -497,7 +497,7 @@ function buildDbMigrateService(options) {
497
497
  }
498
498
  function buildWebService(options) {
499
499
  const lines = ["web:"];
500
- if (options.dev) lines.push(" build:", ` context: ${options.repoRoot}`, ` dockerfile: ${options.dockerfilePath}`, " target: web", " args:", " DEPLOYMENT_MODE: local");
500
+ if (options.dev) lines.push(" build:", ` context: ${options.repoRoot}`, ` dockerfile: ${options.dockerfilePath}`, " target: web");
501
501
  else lines.push(` image: elmohq/elmo-web:${options.version}`);
502
502
  lines.push(" env_file:", " - path: .env", " required: true", " ports:", ` - "${options.port}:3000"`);
503
503
  if (options.dependsOn.length > 0) {
@@ -511,7 +511,7 @@ function buildWebService(options) {
511
511
  }
512
512
  function buildWorkerService(options) {
513
513
  const lines = ["worker:"];
514
- if (options.dev) lines.push(" build:", ` context: ${options.repoRoot}`, ` dockerfile: ${options.dockerfilePath}`, " target: worker", " args:", " DEPLOYMENT_MODE: local");
514
+ if (options.dev) lines.push(" build:", ` context: ${options.repoRoot}`, ` dockerfile: ${options.dockerfilePath}`, " target: worker");
515
515
  else lines.push(` image: elmohq/elmo-worker:${options.version}`);
516
516
  lines.push(" env_file:", " - path: .env", " required: true");
517
517
  lines.push(" stop_grace_period: 35s");
@@ -526,7 +526,7 @@ function buildWorkerService(options) {
526
526
  }
527
527
  //#endregion
528
528
  //#region src/providers.ts
529
- const CLORO_AFFILIATE = "https://affiliate.cloro.dev/elmo?sid=cli";
529
+ const CLORO_AFFILIATE = "https://cloro.dev?fpr=elmo&fp_sid=cli";
530
530
  const BRIGHTDATA_AFFILIATE = "https://get.brightdata.com/elmo?sid=cli";
531
531
  const OXYLABS_AFFILIATE = "https://oxylabs.go2cloud.org/aff_c?offer_id=7&aff_id=2263&url_id=32";
532
532
  const SEARCHAPI_AFFILIATE = "https://www.searchapi.io/?via=elmo";
@@ -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:",
@@ -1264,7 +1278,6 @@ async function runInit(options, version) {
1264
1278
  assertNotCancelled(postgresMode);
1265
1279
  const env = {};
1266
1280
  env.DEPLOYMENT_MODE = "local";
1267
- env.VITE_DEPLOYMENT_MODE = "local";
1268
1281
  env.DEPLOYMENT_ID = preservedDeploymentId ?? crypto.randomUUID();
1269
1282
  env.BETTER_AUTH_SECRET = generateSecret();
1270
1283
  env.ELMO_ENCRYPTION_KEY = generateSecret(32, "base64");
@@ -1314,15 +1327,37 @@ async function runInit(options, version) {
1314
1327
  placeholder: "you@example.com"
1315
1328
  });
1316
1329
  const email = p.isCancel(updatesEmail) ? void 0 : updatesEmail || void 0;
1330
+ const access = await p.select({
1331
+ message: "How will you access Elmo?",
1332
+ options: [{
1333
+ value: "local",
1334
+ label: "On this machine (localhost)"
1335
+ }, {
1336
+ value: "public",
1337
+ label: "From a domain (e.g. behind a reverse proxy)"
1338
+ }],
1339
+ initialValue: "local"
1340
+ });
1341
+ assertNotCancelled(access);
1342
+ let publicUrl;
1343
+ if (access === "public") {
1344
+ const domain = await p.text({
1345
+ message: "Domain",
1346
+ placeholder: "elmo.example.com",
1347
+ validate: validatePublicUrl
1348
+ });
1349
+ assertNotCancelled(domain);
1350
+ publicUrl = toPublicUrl(domain.trim());
1351
+ }
1317
1352
  const portInput = await p.text({
1318
- message: "Web app port",
1353
+ message: access === "public" ? "Port for your reverse proxy to forward to" : "Web app port",
1319
1354
  placeholder: String(DEFAULT_APP_PORT),
1320
1355
  defaultValue: String(DEFAULT_APP_PORT),
1321
1356
  validate: validatePort
1322
1357
  });
1323
1358
  assertNotCancelled(portInput);
1324
1359
  const port = Number(portInput);
1325
- env.APP_URL = `http://localhost:${port}`;
1360
+ env.APP_URL = publicUrl?.origin ?? `http://localhost:${port}`;
1326
1361
  env.VITE_APP_URL = env.APP_URL;
1327
1362
  const composeYaml = buildComposeYaml({
1328
1363
  dev: Boolean(options.dev),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elmohq/cli",
3
- "version": "0.4.2",
3
+ "version": "0.4.4",
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.2",
41
+ "@workspace/config": "0.4.4",
42
42
  "rolldown": "^1.2.7",
43
43
  "typescript": "^7.0.2",
44
44
  "vitest": "^4.1.11"