@mutmutco/installer-launcher 1.2.1 → 1.2.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/launcher.js CHANGED
@@ -896,35 +896,17 @@ var plainText = (text) => String(text).replaceAll("\u2192", "->").replaceAll("\x
896
896
 
897
897
  // ../face/src/spinner.ts
898
898
  import { appendFileSync as appendFileSync2, writeSync as writeSync2 } from "node:fs";
899
+ import { isatty } from "node:tty";
899
900
  import { Worker } from "node:worker_threads";
900
901
 
901
902
  // ../face/src/encoding.ts
902
- import { execFileSync } from "node:child_process";
903
903
  var UNICODE_SPINNER_FRAMES = Object.freeze(["\u25D2", "\u25D0", "\u25D3", "\u25D1"]);
904
904
  var ASCII_SPINNER_FRAMES = Object.freeze(["-", "\\", "|", "/"]);
905
- var cachedCodePage;
906
- function consoleOutputCodePage() {
907
- if (cachedCodePage !== void 0) return cachedCodePage;
908
- cachedCodePage = null;
909
- try {
910
- const out = execFileSync("chcp.com", { windowsHide: true, encoding: "utf8", timeout: 5e3 });
911
- const pages = [...String(out).matchAll(/(\d{3,5})/gu)].map((m) => Number(m[1]));
912
- cachedCodePage = pages.length ? pages[pages.length - 1] : null;
913
- } catch {
914
- cachedCodePage = null;
915
- }
916
- return cachedCodePage;
917
- }
918
- function consoleRendersUnicode(env = process.env, platform = process.platform, codePage = platform === "win32" ? consoleOutputCodePage() : null) {
905
+ function consoleRendersUnicode(env = process.env, _platform = process.platform) {
919
906
  if (env.MM_FACE_ASCII === "1" || env.NO_UNICODE === "1") return false;
920
907
  const locale = env.LC_ALL || env.LC_CTYPE || env.LANG || "";
921
908
  if (locale === "C" || locale === "POSIX" || /^C\./u.test(locale) || /^POSIX\./u.test(locale)) return false;
922
909
  if (/cp437|ibm437|\b437\b/iu.test(locale)) return false;
923
- if (/utf-?8/iu.test(locale)) return true;
924
- if (platform === "win32") {
925
- if (env.WT_SESSION || env.ConEmuANSI === "ON") return true;
926
- return codePage === 65001;
927
- }
928
910
  return true;
929
911
  }
930
912
  function spinnerFramesFor(env = process.env, platform = process.platform) {
@@ -935,6 +917,8 @@ function spinnerFramesFor(env = process.env, platform = process.platform) {
935
917
  var WORKER_SOURCE = `
936
918
  const { parentPort, workerData } = require('node:worker_threads');
937
919
  const { writeSync, appendFileSync } = require('node:fs');
920
+ const wide = workerData.wide ? new (require('node:tty').WriteStream)(2) : null;
921
+ const put = (text) => wide ? wide.write(text) : writeSync(2, text);
938
922
  const control = new Int32Array(workerData.control);
939
923
  let frames = workerData.frames, frame = workerData.frame;
940
924
  function draw() {
@@ -942,7 +926,7 @@ function draw() {
942
926
  try {
943
927
  if (Atomics.load(control, 0) || Atomics.load(control, 2) || !frames.length) return;
944
928
  const text = frames[frame++ % frames.length].replace('__elapsed__', Math.floor((Date.now() - workerData.started) / 1000) + 's');
945
- writeSync(2, text);
929
+ put(text);
946
930
  if (workerData.transcriptPath) appendFileSync(workerData.transcriptPath, JSON.stringify({ channel: 'spinner', text }) + '\\n');
947
931
  } finally {
948
932
  Atomics.store(control, 1, 0);
@@ -967,10 +951,12 @@ function createSpinner(face, { animate, stream, intervalMs = 90, transcriptPath,
967
951
  let frame = 0;
968
952
  let started = 0;
969
953
  let suspended = false;
954
+ const wide = process.platform === "win32" && isatty(2);
970
955
  const write = (text) => {
971
956
  if (stream) stream.write(text);
972
957
  else {
973
- writeSync2(2, text);
958
+ if (wide) process.stderr.write(`\x1B[1G${text}`);
959
+ else writeSync2(2, text);
974
960
  if (transcriptPath) appendFileSync2(transcriptPath, `${JSON.stringify({ channel: "spinner", text })}
975
961
  `);
976
962
  }
@@ -1017,7 +1003,8 @@ function createSpinner(face, { animate, stream, intervalMs = 90, transcriptPath,
1017
1003
  frame,
1018
1004
  intervalMs,
1019
1005
  transcriptPath,
1020
- started
1006
+ started,
1007
+ wide
1021
1008
  } });
1022
1009
  const active = worker;
1023
1010
  worker.on("error", () => {
@@ -1853,7 +1840,8 @@ async function refreshLauncher(target, options = {}) {
1853
1840
  if (compareVersions(record.version, from) <= 0) return arm("ok", from, "");
1854
1841
  if (options.dryRun) return arm("ok", record.version, "");
1855
1842
  let unlock;
1856
- if (!options.lockHeld) {
1843
+ const lockHeld = options.lockHeld ?? process.env.MM_OUTER_CONSOLE === "1";
1844
+ if (!lockHeld) {
1857
1845
  try {
1858
1846
  unlock = lockInstallation(productDir);
1859
1847
  } catch {
@@ -2158,7 +2146,7 @@ function page(title, body) {
2158
2146
  }
2159
2147
 
2160
2148
  // src/index.ts
2161
- var LAUNCHER_VERSION = true ? "1.2.1" : readVersionFromPackage();
2149
+ var LAUNCHER_VERSION = true ? "1.2.3" : readVersionFromPackage();
2162
2150
  function defaultPrint(message) {
2163
2151
  process.stdout.write(`${message}
2164
2152
  `);
@@ -2604,6 +2592,7 @@ async function installOrUpdateRun(config, dir, options, print, update, flags2, m
2604
2592
  fetch: fetchImpl,
2605
2593
  readVersion: async () => LAUNCHER_VERSION
2606
2594
  }) : null;
2595
+ if (arm) process.env.MM_LAUNCHER_REFRESHED = "1";
2607
2596
  if (arm) {
2608
2597
  installer.surface({
2609
2598
  id: LAUNCHER_SURFACE,
@@ -710,7 +710,7 @@ async function installAcquisition(dir, candidate, version, acquisition, options)
710
710
  }
711
711
 
712
712
  // src/index.ts
713
- var import_node_child_process6 = require("node:child_process");
713
+ var import_node_child_process5 = require("node:child_process");
714
714
  var import_node_fs12 = require("node:fs");
715
715
  var import_node_os5 = require("node:os");
716
716
  var import_node_path7 = require("node:path");
@@ -930,35 +930,17 @@ var plainText = (text) => String(text).replaceAll("\u2192", "->").replaceAll("\x
930
930
 
931
931
  // ../face/src/spinner.ts
932
932
  var import_node_fs7 = require("node:fs");
933
+ var import_node_tty = require("node:tty");
933
934
  var import_node_worker_threads = require("node:worker_threads");
934
935
 
935
936
  // ../face/src/encoding.ts
936
- var import_node_child_process2 = require("node:child_process");
937
937
  var UNICODE_SPINNER_FRAMES = Object.freeze(["\u25D2", "\u25D0", "\u25D3", "\u25D1"]);
938
938
  var ASCII_SPINNER_FRAMES = Object.freeze(["-", "\\", "|", "/"]);
939
- var cachedCodePage;
940
- function consoleOutputCodePage() {
941
- if (cachedCodePage !== void 0) return cachedCodePage;
942
- cachedCodePage = null;
943
- try {
944
- const out = (0, import_node_child_process2.execFileSync)("chcp.com", { windowsHide: true, encoding: "utf8", timeout: 5e3 });
945
- const pages = [...String(out).matchAll(/(\d{3,5})/gu)].map((m) => Number(m[1]));
946
- cachedCodePage = pages.length ? pages[pages.length - 1] : null;
947
- } catch {
948
- cachedCodePage = null;
949
- }
950
- return cachedCodePage;
951
- }
952
- function consoleRendersUnicode(env = process.env, platform = process.platform, codePage = platform === "win32" ? consoleOutputCodePage() : null) {
939
+ function consoleRendersUnicode(env = process.env, _platform = process.platform) {
953
940
  if (env.MM_FACE_ASCII === "1" || env.NO_UNICODE === "1") return false;
954
941
  const locale = env.LC_ALL || env.LC_CTYPE || env.LANG || "";
955
942
  if (locale === "C" || locale === "POSIX" || /^C\./u.test(locale) || /^POSIX\./u.test(locale)) return false;
956
943
  if (/cp437|ibm437|\b437\b/iu.test(locale)) return false;
957
- if (/utf-?8/iu.test(locale)) return true;
958
- if (platform === "win32") {
959
- if (env.WT_SESSION || env.ConEmuANSI === "ON") return true;
960
- return codePage === 65001;
961
- }
962
944
  return true;
963
945
  }
964
946
  function spinnerFramesFor(env = process.env, platform = process.platform) {
@@ -969,6 +951,8 @@ function spinnerFramesFor(env = process.env, platform = process.platform) {
969
951
  var WORKER_SOURCE = `
970
952
  const { parentPort, workerData } = require('node:worker_threads');
971
953
  const { writeSync, appendFileSync } = require('node:fs');
954
+ const wide = workerData.wide ? new (require('node:tty').WriteStream)(2) : null;
955
+ const put = (text) => wide ? wide.write(text) : writeSync(2, text);
972
956
  const control = new Int32Array(workerData.control);
973
957
  let frames = workerData.frames, frame = workerData.frame;
974
958
  function draw() {
@@ -976,7 +960,7 @@ function draw() {
976
960
  try {
977
961
  if (Atomics.load(control, 0) || Atomics.load(control, 2) || !frames.length) return;
978
962
  const text = frames[frame++ % frames.length].replace('__elapsed__', Math.floor((Date.now() - workerData.started) / 1000) + 's');
979
- writeSync(2, text);
963
+ put(text);
980
964
  if (workerData.transcriptPath) appendFileSync(workerData.transcriptPath, JSON.stringify({ channel: 'spinner', text }) + '\\n');
981
965
  } finally {
982
966
  Atomics.store(control, 1, 0);
@@ -1001,10 +985,12 @@ function createSpinner(face, { animate, stream, intervalMs = 90, transcriptPath,
1001
985
  let frame = 0;
1002
986
  let started = 0;
1003
987
  let suspended = false;
988
+ const wide = process.platform === "win32" && (0, import_node_tty.isatty)(2);
1004
989
  const write = (text) => {
1005
990
  if (stream) stream.write(text);
1006
991
  else {
1007
- (0, import_node_fs7.writeSync)(2, text);
992
+ if (wide) process.stderr.write(`\x1B[1G${text}`);
993
+ else (0, import_node_fs7.writeSync)(2, text);
1008
994
  if (transcriptPath) (0, import_node_fs7.appendFileSync)(transcriptPath, `${JSON.stringify({ channel: "spinner", text })}
1009
995
  `);
1010
996
  }
@@ -1051,7 +1037,8 @@ function createSpinner(face, { animate, stream, intervalMs = 90, transcriptPath,
1051
1037
  frame,
1052
1038
  intervalMs,
1053
1039
  transcriptPath,
1054
- started
1040
+ started,
1041
+ wide
1055
1042
  } });
1056
1043
  const active = worker;
1057
1044
  worker.on("error", () => {
@@ -1587,7 +1574,7 @@ var plain = (text, lane) => lane.tty ? String(text) : plainText(stripColor(Strin
1587
1574
  var rowTitle = (row) => `${row.surface}${row.aspect ? ` ${row.aspect}` : ""}${row.instance ? ` \xB7 ${row.instance}` : ""} ${row.state}`;
1588
1575
 
1589
1576
  // src/autoupdate.ts
1590
- var import_node_child_process3 = require("node:child_process");
1577
+ var import_node_child_process2 = require("node:child_process");
1591
1578
  var import_node_fs10 = require("node:fs");
1592
1579
  var import_node_os3 = require("node:os");
1593
1580
  var import_node_path5 = require("node:path");
@@ -1597,7 +1584,7 @@ function schedulePlatform(override) {
1597
1584
  return null;
1598
1585
  }
1599
1586
  function defaultExec(command2, args) {
1600
- const result = (0, import_node_child_process3.spawnSync)(command2, args, { encoding: "utf8", windowsHide: true });
1587
+ const result = (0, import_node_child_process2.spawnSync)(command2, args, { encoding: "utf8", windowsHide: true });
1601
1588
  if (result.error) return { code: 1, stdout: "", stderr: result.error.message };
1602
1589
  return {
1603
1590
  code: typeof result.status === "number" ? result.status : 1,
@@ -1777,7 +1764,7 @@ function firstLine(text) {
1777
1764
  }
1778
1765
 
1779
1766
  // src/refresh.ts
1780
- var import_node_child_process4 = require("node:child_process");
1767
+ var import_node_child_process3 = require("node:child_process");
1781
1768
  var import_node_fs11 = require("node:fs");
1782
1769
  var import_node_os4 = require("node:os");
1783
1770
  var import_node_path6 = require("node:path");
@@ -1846,7 +1833,7 @@ function parseLauncherVersion(stdout, bin) {
1846
1833
  }
1847
1834
  function runVersion(path, bin) {
1848
1835
  return new Promise((resolve3) => {
1849
- (0, import_node_child_process4.execFile)(path, ["--version"], { timeout: 3e4, windowsHide: true, encoding: "utf8" }, (error, stdout) => {
1836
+ (0, import_node_child_process3.execFile)(path, ["--version"], { timeout: 3e4, windowsHide: true, encoding: "utf8" }, (error, stdout) => {
1850
1837
  resolve3(error ? null : parseLauncherVersion(stdout, bin));
1851
1838
  });
1852
1839
  });
@@ -1887,7 +1874,8 @@ async function refreshLauncher(target, options = {}) {
1887
1874
  if (compareVersions(record.version, from) <= 0) return arm("ok", from, "");
1888
1875
  if (options.dryRun) return arm("ok", record.version, "");
1889
1876
  let unlock;
1890
- if (!options.lockHeld) {
1877
+ const lockHeld = options.lockHeld ?? process.env.MM_OUTER_CONSOLE === "1";
1878
+ if (!lockHeld) {
1891
1879
  try {
1892
1880
  unlock = lockInstallation(productDir);
1893
1881
  } catch {
@@ -1932,14 +1920,14 @@ async function refreshLauncher(target, options = {}) {
1932
1920
  }
1933
1921
 
1934
1922
  // src/login-github.ts
1935
- var import_node_child_process5 = require("node:child_process");
1923
+ var import_node_child_process4 = require("node:child_process");
1936
1924
  var realSleep = (ms) => new Promise((resolve3) => setTimeout(resolve3, ms));
1937
1925
  function openBrowser(url) {
1938
1926
  if (process.env.LAUNCHER_NO_OPEN === "1") return;
1939
1927
  const opener = process.platform === "darwin" ? "open" : process.platform === "win32" ? "rundll32" : "xdg-open";
1940
1928
  const args = process.platform === "win32" ? ["url.dll,FileProtocolHandler", url] : [url];
1941
1929
  try {
1942
- const child = (0, import_node_child_process5.spawn)(opener, args, { detached: true, stdio: "ignore", windowsHide: true });
1930
+ const child = (0, import_node_child_process4.spawn)(opener, args, { detached: true, stdio: "ignore", windowsHide: true });
1943
1931
  child.on("error", () => {
1944
1932
  });
1945
1933
  child.unref();
@@ -2057,7 +2045,7 @@ async function refreshAccessToken(config, refreshToken, fetchImpl = fetch) {
2057
2045
  }
2058
2046
  function readGhToken() {
2059
2047
  try {
2060
- const result = (0, import_node_child_process5.spawnSync)("gh", ["auth", "token", "--hostname", "github.com"], { encoding: "utf8", timeout: 1e4, windowsHide: true });
2048
+ const result = (0, import_node_child_process4.spawnSync)("gh", ["auth", "token", "--hostname", "github.com"], { encoding: "utf8", timeout: 1e4, windowsHide: true });
2061
2049
  const token = result.status === 0 ? String(result.stdout).trim() : "";
2062
2050
  return token && !/\s/u.test(token) ? token : null;
2063
2051
  } catch {
@@ -2192,7 +2180,7 @@ function page(title, body) {
2192
2180
  }
2193
2181
 
2194
2182
  // src/index.ts
2195
- var LAUNCHER_VERSION = true ? "1.2.1" : readVersionFromPackage();
2183
+ var LAUNCHER_VERSION = true ? "1.2.3" : readVersionFromPackage();
2196
2184
  function defaultPrint(message) {
2197
2185
  process.stdout.write(`${message}
2198
2186
  `);
@@ -2568,7 +2556,7 @@ function defaultRunEntry(entry2, cwd, env) {
2568
2556
  const [command2, ...args] = entry2;
2569
2557
  const shell = needsShell(command2);
2570
2558
  const commandLine = shell ? [command2, ...args].map(quoteForShell).join(" ") : command2;
2571
- const spawnEntry = (progress2) => (0, import_node_child_process6.spawnSync)(commandLine, shell ? [] : args, {
2559
+ const spawnEntry = (progress2) => (0, import_node_child_process5.spawnSync)(commandLine, shell ? [] : args, {
2572
2560
  cwd,
2573
2561
  stdio: progress2 ? ["inherit", "inherit", "inherit", "pipe"] : "inherit",
2574
2562
  shell,
@@ -2638,6 +2626,7 @@ async function installOrUpdateRun(config, dir, options, print, update, flags2, m
2638
2626
  fetch: fetchImpl,
2639
2627
  readVersion: async () => LAUNCHER_VERSION
2640
2628
  }) : null;
2629
+ if (arm) process.env.MM_LAUNCHER_REFRESHED = "1";
2641
2630
  if (arm) {
2642
2631
  installer.surface({
2643
2632
  id: LAUNCHER_SURFACE,
@@ -2859,7 +2848,7 @@ async function runInstallEntry(entry2, cwd, env, installer, tokens = null) {
2859
2848
  const redact = (text) => secrets.reduce((safe, value) => safe.replaceAll(value, "[redacted]"), text);
2860
2849
  try {
2861
2850
  const result = await new Promise((resolve3) => {
2862
- const child = (0, import_node_child_process6.spawn)(shell ? [command2, ...args].map(quoteForShell).join(" ") : command2, shell ? [] : args, {
2851
+ const child = (0, import_node_child_process5.spawn)(shell ? [command2, ...args].map(quoteForShell).join(" ") : command2, shell ? [] : args, {
2863
2852
  cwd,
2864
2853
  shell,
2865
2854
  windowsHide: true,
package/dist/refresh.js CHANGED
@@ -283,7 +283,8 @@ async function refreshLauncher(target, options = {}) {
283
283
  if (compareVersions(record.version, from) <= 0) return arm("ok", from, "");
284
284
  if (options.dryRun) return arm("ok", record.version, "");
285
285
  let unlock;
286
- if (!options.lockHeld) {
286
+ const lockHeld = options.lockHeld ?? process.env.MM_OUTER_CONSOLE === "1";
287
+ if (!lockHeld) {
287
288
  try {
288
289
  unlock = lockInstallation(productDir);
289
290
  } catch {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mutmutco/installer-launcher",
3
- "version": "1.2.1",
3
+ "version": "1.2.3",
4
4
  "description": "Single-executable (SEA) launcher: sign-in, gated payload fetch, self-update. One copy ships per product.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",