@absolutejs/absolute 0.19.0-beta.111 → 0.19.0-beta.113

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/cli/index.js CHANGED
@@ -43,7 +43,8 @@ __export(exports_devCert, {
43
43
  hasMkcert: () => hasMkcert,
44
44
  ensureDevCert: () => ensureDevCert
45
45
  });
46
- import { existsSync as existsSync4, mkdirSync as mkdirSync2, readFileSync as readFileSync4 } from "fs";
46
+ import { existsSync as existsSync4, mkdirSync as mkdirSync2, readFileSync as readFileSync4, rmSync } from "fs";
47
+ import { platform as platform2 } from "os";
47
48
  import { join as join3 } from "path";
48
49
  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 = () => existsSync4(CERT_PATH) && existsSync4(KEY_PATH), isCertExpired = () => {
49
50
  try {
@@ -112,10 +113,8 @@ var CERT_DIR, CERT_PATH, KEY_PATH, CERT_VALIDITY_DAYS = 365, devLog = (msg) => c
112
113
  throw new Error(`openssl failed: ${err}`);
113
114
  }
114
115
  devLog("HTTPS enabled with self-signed certificate");
115
- devLog("For a trusted certificate (no browser warning), install mkcert:");
116
- devLog(" brew install mkcert && mkcert -install (macOS)");
117
- devLog(" sudo apt install mkcert && mkcert -install (Linux)");
118
- devLog("Then restart the dev server.");
116
+ devLog("Browser will show a one-time security warning \u2014 click Advanced \u2192 Proceed");
117
+ devLog('Run "absolute mkcert" anytime to switch to a trusted certificate');
119
118
  }, ensureDevCert = () => {
120
119
  mkdirSync2(CERT_DIR, { recursive: true });
121
120
  if (certFilesExist() && !isCertExpired()) {
@@ -152,18 +151,96 @@ var CERT_DIR, CERT_PATH, KEY_PATH, CERT_VALIDITY_DAYS = 365, devLog = (msg) => c
152
151
  } catch {
153
152
  return null;
154
153
  }
154
+ }, commandExists = (cmd) => {
155
+ try {
156
+ const check = platform2() === "win32" ? ["where", cmd] : ["command", "-v", cmd];
157
+ const result = Bun.spawnSync(check, {
158
+ stderr: "pipe",
159
+ stdout: "pipe"
160
+ });
161
+ return result.exitCode === 0;
162
+ } catch {
163
+ return false;
164
+ }
165
+ }, installMkcert = () => {
166
+ const os = platform2();
167
+ if (os === "darwin") {
168
+ if (commandExists("brew")) {
169
+ devLog("Installing mkcert with Homebrew...");
170
+ const r = Bun.spawnSync(["brew", "install", "mkcert"], {
171
+ stderr: "pipe",
172
+ stdout: "pipe"
173
+ });
174
+ if (r.exitCode === 0)
175
+ return true;
176
+ }
177
+ devWarn("Install Homebrew first: https://brew.sh");
178
+ return false;
179
+ }
180
+ if (os === "linux") {
181
+ if (commandExists("apt-get")) {
182
+ devLog("Installing mkcert with apt...");
183
+ const r = Bun.spawnSync(["sudo", "apt-get", "install", "-y", "mkcert"], { stderr: "pipe", stdout: "pipe" });
184
+ if (r.exitCode === 0)
185
+ return true;
186
+ }
187
+ if (commandExists("dnf")) {
188
+ devLog("Installing mkcert with dnf...");
189
+ const r = Bun.spawnSync(["sudo", "dnf", "install", "-y", "mkcert"], { stderr: "pipe", stdout: "pipe" });
190
+ if (r.exitCode === 0)
191
+ return true;
192
+ }
193
+ if (commandExists("pacman")) {
194
+ devLog("Installing mkcert with pacman...");
195
+ const r = Bun.spawnSync(["sudo", "pacman", "-S", "--noconfirm", "mkcert"], { stderr: "pipe", stdout: "pipe" });
196
+ if (r.exitCode === 0)
197
+ return true;
198
+ }
199
+ if (commandExists("go")) {
200
+ devLog("Installing mkcert with go install...");
201
+ const r = Bun.spawnSync([
202
+ "go",
203
+ "install",
204
+ "filippo.io/mkcert@latest"
205
+ ], { stderr: "pipe", stdout: "pipe" });
206
+ if (r.exitCode === 0)
207
+ return true;
208
+ }
209
+ devWarn("Could not install mkcert automatically.");
210
+ console.log(" See: https://github.com/FiloSottile/mkcert#installation");
211
+ return false;
212
+ }
213
+ if (os === "win32") {
214
+ if (commandExists("choco")) {
215
+ devLog("Installing mkcert with Chocolatey...");
216
+ const r = Bun.spawnSync(["choco", "install", "-y", "mkcert"], {
217
+ stderr: "pipe",
218
+ stdout: "pipe"
219
+ });
220
+ if (r.exitCode === 0)
221
+ return true;
222
+ }
223
+ if (commandExists("winget")) {
224
+ devLog("Installing mkcert with winget...");
225
+ const r = Bun.spawnSync(["winget", "install", "--id", "FiloSottile.mkcert", "-e"], { stderr: "pipe", stdout: "pipe" });
226
+ if (r.exitCode === 0)
227
+ return true;
228
+ }
229
+ devWarn("Could not install mkcert automatically.");
230
+ console.log(" See: https://github.com/FiloSottile/mkcert#installation");
231
+ return false;
232
+ }
233
+ return false;
155
234
  }, setupMkcert = () => {
156
235
  devLog("Setting up mkcert for locally-trusted HTTPS...");
157
236
  if (!hasMkcert()) {
158
- devWarn("mkcert is not installed.");
159
- console.log("");
160
- console.log(" Install it first:");
161
- console.log(" macOS: brew install mkcert");
162
- console.log(" Linux: sudo apt install mkcert");
163
- console.log(" Windows: choco install mkcert");
164
- console.log("");
165
- console.log(" Then run: absolute mkcert");
166
- return false;
237
+ devLog("mkcert not found \u2014 installing...");
238
+ if (!installMkcert())
239
+ return false;
240
+ if (!hasMkcert()) {
241
+ devWarn("mkcert installed but not found in PATH. Restart your terminal and try again.");
242
+ return false;
243
+ }
167
244
  }
168
245
  devLog("Installing local certificate authority...");
169
246
  const installResult = Bun.spawnSync(["mkcert", "-install"], {
@@ -174,11 +251,8 @@ var CERT_DIR, CERT_PATH, KEY_PATH, CERT_VALIDITY_DAYS = 365, devLog = (msg) => c
174
251
  devWarn("Failed to install CA: " + new TextDecoder().decode(installResult.stderr));
175
252
  return false;
176
253
  }
177
- try {
178
- const { rmSync } = __require("fs");
179
- rmSync(CERT_PATH, { force: true });
180
- rmSync(KEY_PATH, { force: true });
181
- } catch {}
254
+ rmSync(CERT_PATH, { force: true });
255
+ rmSync(KEY_PATH, { force: true });
182
256
  mkdirSync2(CERT_DIR, { recursive: true });
183
257
  generateWithMkcert();
184
258
  console.log("");
@@ -760,8 +834,27 @@ var dev = async (serverEntry, configPath2) => {
760
834
  const config = await loadConfig2(configPath2);
761
835
  httpsEnabled = config?.dev?.https === true;
762
836
  if (httpsEnabled) {
763
- const { ensureDevCert: ensureDevCert2 } = await Promise.resolve().then(() => (init_devCert(), exports_devCert));
764
- ensureDevCert2();
837
+ const { hasMkcert: hasMkcert2, ensureDevCert: ensureDevCert2, setupMkcert: setupMkcert2 } = await Promise.resolve().then(() => (init_devCert(), exports_devCert));
838
+ if (!hasMkcert2()) {
839
+ const readline = await import("readline");
840
+ const rl = readline.createInterface({
841
+ input: process.stdin,
842
+ output: process.stdout
843
+ });
844
+ const answer = await new Promise((res) => {
845
+ rl.question("\x1B[36m[dev]\x1B[0m Install mkcert for trusted HTTPS (no browser warning)? [Y/n] ", (a) => {
846
+ rl.close();
847
+ res(a.trim().toLowerCase());
848
+ });
849
+ });
850
+ if (answer === "" || answer === "y" || answer === "yes") {
851
+ setupMkcert2();
852
+ } else {
853
+ ensureDevCert2();
854
+ }
855
+ } else {
856
+ ensureDevCert2();
857
+ }
765
858
  }
766
859
  } catch {}
767
860
  const usesDocker = existsSync5(resolve3(COMPOSE_PATH));
@@ -940,14 +1033,14 @@ var dev = async (serverEntry, configPath2) => {
940
1033
  };
941
1034
  const openInBrowser = async () => {
942
1035
  const url = `http://localhost:${port}`;
943
- const { platform: platform2 } = process;
944
- const isWSL = platform2 === "linux" && isWSLEnvironment();
1036
+ const { platform: platform3 } = process;
1037
+ const isWSL = platform3 === "linux" && isWSLEnvironment();
945
1038
  let cmd;
946
1039
  if (isWSL) {
947
1040
  cmd = "cmd.exe";
948
- } else if (platform2 === "darwin") {
1041
+ } else if (platform3 === "darwin") {
949
1042
  cmd = "open";
950
- } else if (platform2 === "win32") {
1043
+ } else if (platform3 === "win32") {
951
1044
  cmd = "start";
952
1045
  } else {
953
1046
  cmd = "xdg-open";
@@ -1034,7 +1127,7 @@ var eslint = async (args) => {
1034
1127
  // src/cli/scripts/info.ts
1035
1128
  import { execSync as execSync2 } from "child_process";
1036
1129
  import { existsSync as existsSync6, readFileSync as readFileSync5 } from "fs";
1037
- import { arch as arch2, cpus, platform as platform2, totalmem, version } from "os";
1130
+ import { arch as arch2, cpus, platform as platform3, totalmem, version } from "os";
1038
1131
  import { resolve as resolve4 } from "path";
1039
1132
  var __dirname = "/home/alexkahn/abs/absolutejs/src/cli/scripts";
1040
1133
  var bold = (str) => `\x1B[1m${str}\x1B[0m`;
@@ -1108,7 +1201,7 @@ var isDockerEnvironment = () => {
1108
1201
  };
1109
1202
  var getMemoryMB = () => Math.round(totalmem() / BYTES_PER_KILOBYTE / BYTES_PER_KILOBYTE);
1110
1203
  var getGlibcVersion = () => {
1111
- if (platform2() !== "linux")
1204
+ if (platform3() !== "linux")
1112
1205
  return null;
1113
1206
  try {
1114
1207
  const output = execSync2("ldd --version 2>&1 || true", {
@@ -1130,7 +1223,7 @@ var info = () => {
1130
1223
  lines.push(` ${key}: ${val}`);
1131
1224
  };
1132
1225
  section("Operating System:");
1133
- field("Platform", platform2());
1226
+ field("Platform", platform3());
1134
1227
  field("Arch", arch2());
1135
1228
  field("Version", version());
1136
1229
  field("Available memory (MB)", String(getMemoryMB()));
package/dist/index.js CHANGED
@@ -205043,7 +205043,8 @@ __export(exports_devCert, {
205043
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
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 {
@@ -205112,10 +205113,8 @@ var CERT_DIR, CERT_PATH, KEY_PATH, CERT_VALIDITY_DAYS = 365, devLog = (msg) => c
205112
205113
  throw new Error(`openssl failed: ${err}`);
205113
205114
  }
205114
205115
  devLog("HTTPS enabled with self-signed certificate");
205115
- devLog("For a trusted certificate (no browser warning), install mkcert:");
205116
- devLog(" brew install mkcert && mkcert -install (macOS)");
205117
- devLog(" sudo apt install mkcert && mkcert -install (Linux)");
205118
- devLog("Then restart the dev server.");
205116
+ devLog("Browser will show a one-time security warning \u2014 click Advanced \u2192 Proceed");
205117
+ devLog('Run "absolute mkcert" anytime to switch to a trusted certificate');
205119
205118
  }, ensureDevCert = () => {
205120
205119
  mkdirSync10(CERT_DIR, { recursive: true });
205121
205120
  if (certFilesExist() && !isCertExpired()) {
@@ -205152,18 +205151,96 @@ var CERT_DIR, CERT_PATH, KEY_PATH, CERT_VALIDITY_DAYS = 365, devLog = (msg) => c
205152
205151
  } catch {
205153
205152
  return null;
205154
205153
  }
205154
+ }, commandExists = (cmd) => {
205155
+ try {
205156
+ const check = platform3() === "win32" ? ["where", cmd] : ["command", "-v", cmd];
205157
+ const result = Bun.spawnSync(check, {
205158
+ stderr: "pipe",
205159
+ stdout: "pipe"
205160
+ });
205161
+ return result.exitCode === 0;
205162
+ } catch {
205163
+ return false;
205164
+ }
205165
+ }, installMkcert = () => {
205166
+ const os2 = platform3();
205167
+ if (os2 === "darwin") {
205168
+ if (commandExists("brew")) {
205169
+ devLog("Installing mkcert with Homebrew...");
205170
+ const r = Bun.spawnSync(["brew", "install", "mkcert"], {
205171
+ stderr: "pipe",
205172
+ stdout: "pipe"
205173
+ });
205174
+ if (r.exitCode === 0)
205175
+ return true;
205176
+ }
205177
+ devWarn("Install Homebrew first: https://brew.sh");
205178
+ return false;
205179
+ }
205180
+ if (os2 === "linux") {
205181
+ if (commandExists("apt-get")) {
205182
+ devLog("Installing mkcert with apt...");
205183
+ const r = Bun.spawnSync(["sudo", "apt-get", "install", "-y", "mkcert"], { stderr: "pipe", stdout: "pipe" });
205184
+ if (r.exitCode === 0)
205185
+ return true;
205186
+ }
205187
+ if (commandExists("dnf")) {
205188
+ devLog("Installing mkcert with dnf...");
205189
+ const r = Bun.spawnSync(["sudo", "dnf", "install", "-y", "mkcert"], { stderr: "pipe", stdout: "pipe" });
205190
+ if (r.exitCode === 0)
205191
+ return true;
205192
+ }
205193
+ if (commandExists("pacman")) {
205194
+ devLog("Installing mkcert with pacman...");
205195
+ const r = Bun.spawnSync(["sudo", "pacman", "-S", "--noconfirm", "mkcert"], { stderr: "pipe", stdout: "pipe" });
205196
+ if (r.exitCode === 0)
205197
+ return true;
205198
+ }
205199
+ if (commandExists("go")) {
205200
+ devLog("Installing mkcert with go install...");
205201
+ const r = Bun.spawnSync([
205202
+ "go",
205203
+ "install",
205204
+ "filippo.io/mkcert@latest"
205205
+ ], { stderr: "pipe", stdout: "pipe" });
205206
+ if (r.exitCode === 0)
205207
+ return true;
205208
+ }
205209
+ devWarn("Could not install mkcert automatically.");
205210
+ console.log(" See: https://github.com/FiloSottile/mkcert#installation");
205211
+ return false;
205212
+ }
205213
+ if (os2 === "win32") {
205214
+ if (commandExists("choco")) {
205215
+ devLog("Installing mkcert with Chocolatey...");
205216
+ const r = Bun.spawnSync(["choco", "install", "-y", "mkcert"], {
205217
+ stderr: "pipe",
205218
+ stdout: "pipe"
205219
+ });
205220
+ if (r.exitCode === 0)
205221
+ return true;
205222
+ }
205223
+ if (commandExists("winget")) {
205224
+ devLog("Installing mkcert with winget...");
205225
+ const r = Bun.spawnSync(["winget", "install", "--id", "FiloSottile.mkcert", "-e"], { stderr: "pipe", stdout: "pipe" });
205226
+ if (r.exitCode === 0)
205227
+ return true;
205228
+ }
205229
+ devWarn("Could not install mkcert automatically.");
205230
+ console.log(" See: https://github.com/FiloSottile/mkcert#installation");
205231
+ return false;
205232
+ }
205233
+ return false;
205155
205234
  }, setupMkcert = () => {
205156
205235
  devLog("Setting up mkcert for locally-trusted HTTPS...");
205157
205236
  if (!hasMkcert()) {
205158
- devWarn("mkcert is not installed.");
205159
- console.log("");
205160
- console.log(" Install it first:");
205161
- console.log(" macOS: brew install mkcert");
205162
- console.log(" Linux: sudo apt install mkcert");
205163
- console.log(" Windows: choco install mkcert");
205164
- console.log("");
205165
- console.log(" Then run: absolute mkcert");
205166
- return false;
205237
+ devLog("mkcert not found \u2014 installing...");
205238
+ if (!installMkcert())
205239
+ return false;
205240
+ if (!hasMkcert()) {
205241
+ devWarn("mkcert installed but not found in PATH. Restart your terminal and try again.");
205242
+ return false;
205243
+ }
205167
205244
  }
205168
205245
  devLog("Installing local certificate authority...");
205169
205246
  const installResult = Bun.spawnSync(["mkcert", "-install"], {
@@ -205174,11 +205251,8 @@ var CERT_DIR, CERT_PATH, KEY_PATH, CERT_VALIDITY_DAYS = 365, devLog = (msg) => c
205174
205251
  devWarn("Failed to install CA: " + new TextDecoder().decode(installResult.stderr));
205175
205252
  return false;
205176
205253
  }
205177
- try {
205178
- const { rmSync: rmSync2 } = __require("fs");
205179
- rmSync2(CERT_PATH, { force: true });
205180
- rmSync2(KEY_PATH, { force: true });
205181
- } catch {}
205254
+ rmSync2(CERT_PATH, { force: true });
205255
+ rmSync2(KEY_PATH, { force: true });
205182
205256
  mkdirSync10(CERT_DIR, { recursive: true });
205183
205257
  generateWithMkcert();
205184
205258
  console.log("");
@@ -205524,5 +205598,5 @@ export {
205524
205598
  ANGULAR_INIT_TIMEOUT_MS
205525
205599
  };
205526
205600
 
205527
- //# debugId=97674176A38B7A0F64756E2164756E21
205601
+ //# debugId=F5DFB6DFD539854B64756E2164756E21
205528
205602
  //# sourceMappingURL=index.js.map