@mawesome/npm-vm 0.0.0-stage → 0.1.0

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 (44) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +51 -2
  3. package/dist/cli.js +4157 -0
  4. package/dist/cli.js.map +1 -0
  5. package/dist/index-B071ZJDk.d.cts +164 -0
  6. package/dist/index-B071ZJDk.d.ts +164 -0
  7. package/dist/index.cjs +7 -0
  8. package/dist/index.d.cts +2 -0
  9. package/dist/index.d.ts +2 -0
  10. package/dist/index.js +2 -0
  11. package/dist/internal.cjs +2709 -0
  12. package/dist/internal.cjs.map +1 -0
  13. package/dist/internal.d.cts +139 -0
  14. package/dist/internal.d.ts +139 -0
  15. package/dist/internal.js +2706 -0
  16. package/dist/internal.js.map +1 -0
  17. package/dist/provenance--sOYCeF2.js +322 -0
  18. package/dist/provenance--sOYCeF2.js.map +1 -0
  19. package/dist/provenance-DDegWCyS.js +2 -0
  20. package/dist/runtime/atomic-C3shKdH9.cjs +88 -0
  21. package/dist/runtime/bootstrap.cjs +271 -0
  22. package/dist/runtime/commonjs-AANzyd21.cjs +7393 -0
  23. package/dist/runtime/dispatch-B9OSfqsn.cjs +25156 -0
  24. package/dist/runtime/dist-CXwBT6rE.cjs +30766 -0
  25. package/dist/runtime/home-BaoZZSBy.cjs +91 -0
  26. package/dist/runtime/install-C_M5WK98.cjs +13598 -0
  27. package/dist/runtime/journal-_bs-eJRJ.cjs +282 -0
  28. package/dist/runtime/launchers/cmd.tmpl +2 -0
  29. package/dist/runtime/launchers/ps1.tmpl +5 -0
  30. package/dist/runtime/launchers/sh.tmpl +3 -0
  31. package/dist/runtime/lease-HBD4CmBx.cjs +224 -0
  32. package/dist/runtime/lock-DBeYN-Zg.cjs +141 -0
  33. package/dist/runtime/messages-vUDkl1-0.cjs +174 -0
  34. package/dist/runtime/p-map-b8pXdaFZ.cjs +105 -0
  35. package/dist/runtime/proc-hB8N9WjN.cjs +127 -0
  36. package/dist/runtime/provenance-B4bajGXQ.cjs +2 -0
  37. package/dist/runtime/rolldown-runtime-BGT596CS.cjs +64 -0
  38. package/dist/runtime/runtime.cjs +143 -0
  39. package/dist/runtime/src-SpeGbMJx.cjs +314 -0
  40. package/dist/src-Bc9nN1Kl.cjs +2125 -0
  41. package/dist/src-Bc9nN1Kl.cjs.map +1 -0
  42. package/dist/src-NhNG2mnQ.js +1798 -0
  43. package/dist/src-NhNG2mnQ.js.map +1 -0
  44. package/package.json +85 -3
@@ -0,0 +1,91 @@
1
+ const require_rolldown_runtime = require("./rolldown-runtime-BGT596CS.cjs");
2
+ let node_child_process = require("node:child_process");
3
+ let node_path = require("node:path");
4
+ let node_fs = require("node:fs");
5
+ let node_crypto = require("node:crypto");
6
+ let node_os = require("node:os");
7
+ //#region src/setup/home.ts
8
+ var home_exports = /* @__PURE__ */ require_rolldown_runtime.__exportAll({
9
+ cacheBase: () => cacheBase,
10
+ defaultHome: () => defaultHome,
11
+ readMachineId: () => readMachineId,
12
+ resolveDirs: () => resolveDirs
13
+ });
14
+ function localAppData(env) {
15
+ return env["LOCALAPPDATA"] ?? (0, node_path.join)((0, node_os.homedir)(), "AppData", "Local");
16
+ }
17
+ function defaultHome(env, platform = process.platform) {
18
+ if (platform === "win32") return (0, node_path.join)(localAppData(env), "npm-vm");
19
+ return (0, node_path.join)(env["XDG_DATA_HOME"] || (0, node_path.join)((0, node_os.homedir)(), ".local", "share"), "npm-vm");
20
+ }
21
+ function cacheBase(env, platform = process.platform) {
22
+ if (platform === "win32") return (0, node_path.join)(localAppData(env), "npm-vm-cache");
23
+ return (0, node_path.join)(env["XDG_CACHE_HOME"] || (0, node_path.join)((0, node_os.homedir)(), ".cache"), "npm-vm");
24
+ }
25
+ function platformId(platform, env) {
26
+ try {
27
+ if (platform === "linux") {
28
+ for (const file of ["/etc/machine-id", "/var/lib/dbus/machine-id"]) try {
29
+ const id = (0, node_fs.readFileSync)(file, "utf8").trim();
30
+ if (id !== "") return id;
31
+ } catch {}
32
+ return null;
33
+ }
34
+ if (platform === "darwin") {
35
+ const out = (0, node_child_process.execFileSync)("/usr/sbin/ioreg", [
36
+ "-rd1",
37
+ "-c",
38
+ "IOPlatformExpertDevice"
39
+ ], {
40
+ encoding: "utf8",
41
+ env: { PATH: "/usr/bin:/bin:/usr/sbin:/sbin" }
42
+ });
43
+ return /"IOPlatformUUID"\s*=\s*"([^"]+)"/.exec(out)?.[1] ?? null;
44
+ }
45
+ if (platform === "win32") {
46
+ const reg = (0, node_path.join)(env["SystemRoot"] ?? "C:\\Windows", "System32", "reg.exe");
47
+ const out = (0, node_child_process.execFileSync)(reg, [
48
+ "query",
49
+ "HKLM\\SOFTWARE\\Microsoft\\Cryptography",
50
+ "/v",
51
+ "MachineGuid"
52
+ ], { encoding: "utf8" });
53
+ return /MachineGuid\s+REG_SZ\s+(\S+)/.exec(out)?.[1] ?? null;
54
+ }
55
+ } catch {}
56
+ return null;
57
+ }
58
+ /** The hashed machine id, or a hashed hostname when the platform id is unreadable. */
59
+ function readMachineId(env = process.env, platform = process.platform) {
60
+ const raw = platformId(platform, env);
61
+ const source = raw ?? (0, node_os.hostname)();
62
+ return {
63
+ id: (0, node_crypto.createHash)("sha256").update(source).digest("hex").slice(0, 16),
64
+ fallback: raw === null
65
+ };
66
+ }
67
+ function resolveDirs(env = process.env, home = env["NPM_VM_HOME"] || defaultHome(env), platform = process.platform, machine = readMachineId(env, platform)) {
68
+ const absoluteHome = (0, node_path.resolve)(home);
69
+ const state = (0, node_path.join)(absoluteHome, "state");
70
+ return {
71
+ home: absoluteHome,
72
+ cache: (0, node_path.join)(cacheBase(env, platform), machine.id),
73
+ state,
74
+ tmp: (0, node_path.join)(state, "tmp"),
75
+ journal: (0, node_path.join)(state, "journal"),
76
+ machine
77
+ };
78
+ }
79
+ //#endregion
80
+ Object.defineProperty(exports, "home_exports", {
81
+ enumerable: true,
82
+ get: function() {
83
+ return home_exports;
84
+ }
85
+ });
86
+ Object.defineProperty(exports, "resolveDirs", {
87
+ enumerable: true,
88
+ get: function() {
89
+ return resolveDirs;
90
+ }
91
+ });