@absolutejs/absolute 0.19.0-beta.110 → 0.19.0-beta.112

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 CHANGED
@@ -1239,8 +1239,6 @@ var colors2, frameworkColors, formatPath = (filePath) => {
1239
1239
  console.error(`${timestamp} ${tag} ${fullMessage}`);
1240
1240
  }, logHmrUpdate = (path, framework, duration) => {
1241
1241
  log("hmr update", { duration, framework, path });
1242
- }, logInfo = (message) => {
1243
- log(message);
1244
1242
  }, logScriptUpdate = (path, framework, duration) => {
1245
1243
  log("script update", { duration, framework, path });
1246
1244
  }, logServerReload = () => {
@@ -205040,12 +205038,15 @@ var init_hmr = __esm(() => {
205040
205038
  // src/dev/devCert.ts
205041
205039
  var exports_devCert = {};
205042
205040
  __export(exports_devCert, {
205041
+ setupMkcert: () => setupMkcert,
205043
205042
  loadDevCert: () => loadDevCert,
205043
+ hasMkcert: () => hasMkcert,
205044
205044
  ensureDevCert: () => ensureDevCert
205045
205045
  });
205046
- import { existsSync as existsSync15, mkdirSync as mkdirSync10, readFileSync as readFileSync11 } from "fs";
205046
+ import { existsSync as existsSync15, mkdirSync as mkdirSync10, readFileSync as readFileSync11, rmSync as rmSync2 } from "fs";
205047
+ import { platform as platform3 } from "os";
205047
205048
  import { join as join17 } from "path";
205048
- var CERT_DIR, CERT_PATH, KEY_PATH, CERT_VALIDITY_DAYS = 365, certFilesExist = () => existsSync15(CERT_PATH) && existsSync15(KEY_PATH), isCertExpired = () => {
205049
+ var CERT_DIR, CERT_PATH, KEY_PATH, CERT_VALIDITY_DAYS = 365, devLog = (msg) => console.log(`\x1B[2m${new Date().toLocaleTimeString()}\x1B[0m \x1B[36m[dev]\x1B[0m ${msg}`), devWarn = (msg) => console.log(`\x1B[2m${new Date().toLocaleTimeString()}\x1B[0m \x1B[33m[dev]\x1B[0m \x1B[33m${msg}\x1B[0m`), certFilesExist = () => existsSync15(CERT_PATH) && existsSync15(KEY_PATH), isCertExpired = () => {
205049
205050
  try {
205050
205051
  const certPem = readFileSync11(CERT_PATH, "utf-8");
205051
205052
  const proc = Bun.spawnSync(["openssl", "x509", "-enddate", "-noout"], {
@@ -205069,7 +205070,7 @@ var CERT_DIR, CERT_PATH, KEY_PATH, CERT_VALIDITY_DAYS = 365, certFilesExist = ()
205069
205070
  return false;
205070
205071
  }
205071
205072
  }, generateWithMkcert = () => {
205072
- logInfo("Generating locally-trusted certificate with mkcert...");
205073
+ devLog("Generating locally-trusted certificate with mkcert...");
205073
205074
  const result = Bun.spawnSync([
205074
205075
  "mkcert",
205075
205076
  "-cert-file",
@@ -205084,9 +205085,9 @@ var CERT_DIR, CERT_PATH, KEY_PATH, CERT_VALIDITY_DAYS = 365, certFilesExist = ()
205084
205085
  const err = new TextDecoder().decode(result.stderr);
205085
205086
  throw new Error(`mkcert failed: ${err}`);
205086
205087
  }
205087
- logInfo("Certificate generated with mkcert (locally trusted, no browser warning)");
205088
+ devLog("HTTPS enabled with locally-trusted certificate (mkcert)");
205088
205089
  }, generateSelfSigned = () => {
205089
- logInfo("Generating self-signed certificate for HTTPS dev server...");
205090
+ devLog("Generating self-signed certificate...");
205090
205091
  const proc = Bun.spawnSync([
205091
205092
  "openssl",
205092
205093
  "req",
@@ -205111,14 +205112,23 @@ var CERT_DIR, CERT_PATH, KEY_PATH, CERT_VALIDITY_DAYS = 365, certFilesExist = ()
205111
205112
  const err = new TextDecoder().decode(proc.stderr);
205112
205113
  throw new Error(`openssl failed: ${err}`);
205113
205114
  }
205114
- logInfo("Self-signed certificate generated (one-time browser warning on first visit)");
205115
+ devLog("HTTPS enabled with self-signed certificate");
205116
+ devLog("For a trusted certificate (no browser warning), install mkcert:");
205117
+ devLog(" brew install mkcert && mkcert -install (macOS)");
205118
+ devLog(" sudo apt install mkcert && mkcert -install (Linux)");
205119
+ devLog("Then restart the dev server.");
205115
205120
  }, ensureDevCert = () => {
205116
205121
  mkdirSync10(CERT_DIR, { recursive: true });
205117
205122
  if (certFilesExist() && !isCertExpired()) {
205123
+ if (hasMkcert()) {
205124
+ devLog("HTTPS enabled with locally-trusted certificate (mkcert)");
205125
+ } else {
205126
+ devLog("HTTPS enabled with self-signed certificate");
205127
+ }
205118
205128
  return { cert: CERT_PATH, key: KEY_PATH };
205119
205129
  }
205120
205130
  if (certFilesExist()) {
205121
- logWarn("Dev certificate expired, regenerating...");
205131
+ devWarn("Dev certificate expired, regenerating...");
205122
205132
  }
205123
205133
  try {
205124
205134
  if (hasMkcert()) {
@@ -205127,7 +205137,7 @@ var CERT_DIR, CERT_PATH, KEY_PATH, CERT_VALIDITY_DAYS = 365, certFilesExist = ()
205127
205137
  generateSelfSigned();
205128
205138
  }
205129
205139
  } catch (err) {
205130
- logWarn(`Failed to generate HTTPS certificate: ${err instanceof Error ? err.message : err}`);
205140
+ devWarn(`Failed to generate certificate: ${err instanceof Error ? err.message : err}`);
205131
205141
  return null;
205132
205142
  }
205133
205143
  return { cert: CERT_PATH, key: KEY_PATH };
@@ -205143,9 +205153,115 @@ var CERT_DIR, CERT_PATH, KEY_PATH, CERT_VALIDITY_DAYS = 365, certFilesExist = ()
205143
205153
  } catch {
205144
205154
  return null;
205145
205155
  }
205156
+ }, commandExists = (cmd) => {
205157
+ try {
205158
+ const check = platform3() === "win32" ? ["where", cmd] : ["command", "-v", cmd];
205159
+ const result = Bun.spawnSync(check, {
205160
+ stderr: "pipe",
205161
+ stdout: "pipe"
205162
+ });
205163
+ return result.exitCode === 0;
205164
+ } catch {
205165
+ return false;
205166
+ }
205167
+ }, installMkcert = () => {
205168
+ const os2 = platform3();
205169
+ if (os2 === "darwin") {
205170
+ if (commandExists("brew")) {
205171
+ devLog("Installing mkcert with Homebrew...");
205172
+ const r = Bun.spawnSync(["brew", "install", "mkcert"], {
205173
+ stderr: "pipe",
205174
+ stdout: "pipe"
205175
+ });
205176
+ if (r.exitCode === 0)
205177
+ return true;
205178
+ }
205179
+ devWarn("Install Homebrew first: https://brew.sh");
205180
+ return false;
205181
+ }
205182
+ if (os2 === "linux") {
205183
+ if (commandExists("apt-get")) {
205184
+ devLog("Installing mkcert with apt...");
205185
+ const r = Bun.spawnSync(["sudo", "apt-get", "install", "-y", "mkcert"], { stderr: "pipe", stdout: "pipe" });
205186
+ if (r.exitCode === 0)
205187
+ return true;
205188
+ }
205189
+ if (commandExists("dnf")) {
205190
+ devLog("Installing mkcert with dnf...");
205191
+ const r = Bun.spawnSync(["sudo", "dnf", "install", "-y", "mkcert"], { stderr: "pipe", stdout: "pipe" });
205192
+ if (r.exitCode === 0)
205193
+ return true;
205194
+ }
205195
+ if (commandExists("pacman")) {
205196
+ devLog("Installing mkcert with pacman...");
205197
+ const r = Bun.spawnSync(["sudo", "pacman", "-S", "--noconfirm", "mkcert"], { stderr: "pipe", stdout: "pipe" });
205198
+ if (r.exitCode === 0)
205199
+ return true;
205200
+ }
205201
+ if (commandExists("go")) {
205202
+ devLog("Installing mkcert with go install...");
205203
+ const r = Bun.spawnSync([
205204
+ "go",
205205
+ "install",
205206
+ "filippo.io/mkcert@latest"
205207
+ ], { stderr: "pipe", stdout: "pipe" });
205208
+ if (r.exitCode === 0)
205209
+ return true;
205210
+ }
205211
+ devWarn("Could not install mkcert automatically.");
205212
+ console.log(" See: https://github.com/FiloSottile/mkcert#installation");
205213
+ return false;
205214
+ }
205215
+ if (os2 === "win32") {
205216
+ if (commandExists("choco")) {
205217
+ devLog("Installing mkcert with Chocolatey...");
205218
+ const r = Bun.spawnSync(["choco", "install", "-y", "mkcert"], {
205219
+ stderr: "pipe",
205220
+ stdout: "pipe"
205221
+ });
205222
+ if (r.exitCode === 0)
205223
+ return true;
205224
+ }
205225
+ if (commandExists("winget")) {
205226
+ devLog("Installing mkcert with winget...");
205227
+ const r = Bun.spawnSync(["winget", "install", "--id", "FiloSottile.mkcert", "-e"], { stderr: "pipe", stdout: "pipe" });
205228
+ if (r.exitCode === 0)
205229
+ return true;
205230
+ }
205231
+ devWarn("Could not install mkcert automatically.");
205232
+ console.log(" See: https://github.com/FiloSottile/mkcert#installation");
205233
+ return false;
205234
+ }
205235
+ return false;
205236
+ }, setupMkcert = () => {
205237
+ devLog("Setting up mkcert for locally-trusted HTTPS...");
205238
+ if (!hasMkcert()) {
205239
+ devLog("mkcert not found \u2014 installing...");
205240
+ if (!installMkcert())
205241
+ return false;
205242
+ if (!hasMkcert()) {
205243
+ devWarn("mkcert installed but not found in PATH. Restart your terminal and try again.");
205244
+ return false;
205245
+ }
205246
+ }
205247
+ devLog("Installing local certificate authority...");
205248
+ const installResult = Bun.spawnSync(["mkcert", "-install"], {
205249
+ stderr: "pipe",
205250
+ stdout: "pipe"
205251
+ });
205252
+ if (installResult.exitCode !== 0) {
205253
+ devWarn("Failed to install CA: " + new TextDecoder().decode(installResult.stderr));
205254
+ return false;
205255
+ }
205256
+ rmSync2(CERT_PATH, { force: true });
205257
+ rmSync2(KEY_PATH, { force: true });
205258
+ mkdirSync10(CERT_DIR, { recursive: true });
205259
+ generateWithMkcert();
205260
+ console.log("");
205261
+ devLog("Done! Restart your dev server \u2014 no more browser warnings.");
205262
+ return true;
205146
205263
  };
205147
205264
  var init_devCert = __esm(() => {
205148
- init_logger();
205149
205265
  CERT_DIR = join17(process.cwd(), ".absolutejs");
205150
205266
  CERT_PATH = join17(CERT_DIR, "cert.pem");
205151
205267
  KEY_PATH = join17(CERT_DIR, "key.pem");
@@ -205484,5 +205600,5 @@ export {
205484
205600
  ANGULAR_INIT_TIMEOUT_MS
205485
205601
  };
205486
205602
 
205487
- //# debugId=721F3E062986F6F364756E2164756E21
205603
+ //# debugId=61B35047FE13FE4D64756E2164756E21
205488
205604
  //# sourceMappingURL=index.js.map