pubm 0.4.3 → 0.4.5

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 (3) hide show
  1. package/bin/cli.cjs +141 -5
  2. package/package.json +27 -14
  3. package/postinstall.cjs +22 -1
package/bin/cli.cjs CHANGED
@@ -1,5 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
 
3
+ // Platform resolution adapted from opencode
4
+ // (https://github.com/anomalyco/opencode) — MIT License
5
+
3
6
  const childProcess = require("node:child_process");
4
7
  const fs = require("node:fs");
5
8
  const path = require("node:path");
@@ -25,6 +28,11 @@ if (envPath) {
25
28
  const scriptPath = fs.realpathSync(__filename);
26
29
  const scriptDir = path.dirname(scriptPath);
27
30
 
31
+ const cached = path.join(scriptDir, ".pubm");
32
+ if (fs.existsSync(cached)) {
33
+ run(cached);
34
+ }
35
+
28
36
  const platformMap = {
29
37
  darwin: "darwin",
30
38
  linux: "linux",
@@ -43,18 +51,144 @@ let arch = archMap[os.arch()];
43
51
  if (!arch) {
44
52
  arch = os.arch();
45
53
  }
46
-
47
54
  const base = `@pubm/${platform}-${arch}`;
48
55
  const binary = platform === "windows" ? "pubm.exe" : "pubm";
49
56
 
57
+ function supportsAvx2() {
58
+ if (arch !== "x64") return false;
59
+
60
+ if (platform === "linux") {
61
+ try {
62
+ return /(^|\s)avx2(\s|$)/i.test(fs.readFileSync("/proc/cpuinfo", "utf8"));
63
+ } catch {
64
+ return false;
65
+ }
66
+ }
67
+
68
+ if (platform === "darwin") {
69
+ try {
70
+ const result = childProcess.spawnSync(
71
+ "sysctl",
72
+ ["-n", "hw.optional.avx2_0"],
73
+ {
74
+ encoding: "utf8",
75
+ timeout: 1500,
76
+ },
77
+ );
78
+ if (result.status !== 0) return false;
79
+ return (result.stdout || "").trim() === "1";
80
+ } catch {
81
+ return false;
82
+ }
83
+ }
84
+
85
+ if (platform === "windows") {
86
+ const cmd =
87
+ '(Add-Type -MemberDefinition "[DllImport(""kernel32.dll"")] public static extern bool IsProcessorFeaturePresent(int ProcessorFeature);" -Name Kernel32 -Namespace Win32 -PassThru)::IsProcessorFeaturePresent(40)';
88
+
89
+ for (const exe of ["powershell.exe", "pwsh.exe", "pwsh", "powershell"]) {
90
+ try {
91
+ const result = childProcess.spawnSync(
92
+ exe,
93
+ ["-NoProfile", "-NonInteractive", "-Command", cmd],
94
+ {
95
+ encoding: "utf8",
96
+ timeout: 3000,
97
+ windowsHide: true,
98
+ },
99
+ );
100
+ if (result.status !== 0) continue;
101
+ const out = (result.stdout || "").trim().toLowerCase();
102
+ if (out === "true" || out === "1") return true;
103
+ if (out === "false" || out === "0") return false;
104
+ } catch {}
105
+ }
106
+
107
+ return false;
108
+ }
109
+
110
+ return false;
111
+ }
112
+
113
+ const names = (() => {
114
+ const avx2 = supportsAvx2();
115
+ const baseline = arch === "x64" && !avx2;
116
+
117
+ if (platform === "linux") {
118
+ const musl = (() => {
119
+ try {
120
+ if (fs.existsSync("/etc/alpine-release")) return true;
121
+ } catch {
122
+ // ignore
123
+ }
124
+
125
+ try {
126
+ const result = childProcess.spawnSync("ldd", ["--version"], {
127
+ encoding: "utf8",
128
+ });
129
+ const text = (
130
+ (result.stdout || "") + (result.stderr || "")
131
+ ).toLowerCase();
132
+ if (text.includes("musl")) return true;
133
+ } catch {
134
+ // ignore
135
+ }
136
+
137
+ return false;
138
+ })();
139
+
140
+ if (musl) {
141
+ if (arch === "x64") {
142
+ if (baseline)
143
+ return [
144
+ `${base}-baseline-musl`,
145
+ `${base}-musl`,
146
+ `${base}-baseline`,
147
+ base,
148
+ ];
149
+ return [
150
+ `${base}-musl`,
151
+ `${base}-baseline-musl`,
152
+ base,
153
+ `${base}-baseline`,
154
+ ];
155
+ }
156
+ return [`${base}-musl`, base];
157
+ }
158
+
159
+ if (arch === "x64") {
160
+ if (baseline)
161
+ return [
162
+ `${base}-baseline`,
163
+ base,
164
+ `${base}-baseline-musl`,
165
+ `${base}-musl`,
166
+ ];
167
+ return [
168
+ base,
169
+ `${base}-baseline`,
170
+ `${base}-musl`,
171
+ `${base}-baseline-musl`,
172
+ ];
173
+ }
174
+ return [base, `${base}-musl`];
175
+ }
176
+
177
+ if (arch === "x64") {
178
+ if (baseline) return [`${base}-baseline`, base];
179
+ return [base, `${base}-baseline`];
180
+ }
181
+ return [base];
182
+ })();
183
+
50
184
  function findBinary(startDir) {
51
185
  let current = startDir;
52
186
  for (;;) {
53
187
  const modules = path.join(current, "node_modules");
54
188
  if (fs.existsSync(modules)) {
55
- const candidate = path.join(modules, base, "bin", binary);
56
- if (fs.existsSync(candidate)) {
57
- return candidate;
189
+ for (const name of names) {
190
+ const candidate = path.join(modules, name, "bin", binary);
191
+ if (fs.existsSync(candidate)) return candidate;
58
192
  }
59
193
  }
60
194
  const parent = path.dirname(current);
@@ -68,7 +202,9 @@ function findBinary(startDir) {
68
202
  const resolved = findBinary(scriptDir);
69
203
  if (!resolved) {
70
204
  console.error(
71
- `Failed to find the pubm binary for your platform. You can try manually installing the "${base}" package, or set the PUBM_BIN_PATH environment variable.`,
205
+ "It seems that your package manager failed to install the right version of pubm for your platform. You can try manually installing " +
206
+ names.map((n) => `"${n}"`).join(" or ") +
207
+ " package",
72
208
  );
73
209
  process.exit(1);
74
210
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pubm",
3
- "version": "0.4.3",
3
+ "version": "0.4.5",
4
4
  "type": "module",
5
5
  "description": "publish manager for multiple registry (jsr, npm and private registries)",
6
6
  "types": "./index.d.ts",
@@ -20,7 +20,7 @@
20
20
  "pubm": "./bin/cli.cjs"
21
21
  },
22
22
  "files": [
23
- "bin/",
23
+ "bin/cli.cjs",
24
24
  "index.js",
25
25
  "index.cjs",
26
26
  "index.d.ts",
@@ -35,7 +35,7 @@
35
35
  "coverage": "vitest --run --coverage"
36
36
  },
37
37
  "dependencies": {
38
- "@pubm/core": "0.4.3",
38
+ "@pubm/core": "0.4.5",
39
39
  "commander": "^14.0.3",
40
40
  "enquirer": "^2.4.1",
41
41
  "semver": "^7.6.3",
@@ -46,11 +46,18 @@
46
46
  "@types/semver": "^7.7.1"
47
47
  },
48
48
  "optionalDependencies": {
49
- "@pubm/darwin-arm64": "0.4.3",
50
- "@pubm/darwin-x64": "0.4.3",
51
- "@pubm/linux-arm64": "0.4.3",
52
- "@pubm/linux-x64": "0.4.3",
53
- "@pubm/windows-x64": "0.4.3"
49
+ "@pubm/darwin-arm64": "0.4.5",
50
+ "@pubm/darwin-x64": "0.4.5",
51
+ "@pubm/darwin-x64-baseline": "0.4.5",
52
+ "@pubm/linux-arm64": "0.4.5",
53
+ "@pubm/linux-arm64-musl": "0.4.5",
54
+ "@pubm/linux-x64": "0.4.5",
55
+ "@pubm/linux-x64-baseline": "0.4.5",
56
+ "@pubm/linux-x64-musl": "0.4.5",
57
+ "@pubm/linux-x64-musl-baseline": "0.4.5",
58
+ "@pubm/windows-arm64": "0.4.5",
59
+ "@pubm/windows-x64": "0.4.5",
60
+ "@pubm/windows-x64-baseline": "0.4.5"
54
61
  },
55
62
  "engines": {
56
63
  "node": ">=24",
@@ -66,13 +73,19 @@
66
73
  "directory": "packages/pubm"
67
74
  },
68
75
  "keywords": [
69
- "npm",
76
+ "publish",
77
+ "npm publish",
70
78
  "jsr",
71
79
  "registry",
72
- "publish",
73
- "np",
74
- "publish manager",
75
- "private registry",
76
- "multiple publish"
80
+ "multiple registry",
81
+ "multi registry",
82
+ "release",
83
+ "monorepo release",
84
+ "version bump",
85
+ "changeset",
86
+ "cli",
87
+ "release automation",
88
+ "release cli",
89
+ "open source release"
77
90
  ]
78
91
  }
package/postinstall.cjs CHANGED
@@ -1,5 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
 
3
+ // Platform resolution adapted from opencode
4
+ // (https://github.com/anomalyco/opencode) — MIT License
5
+
3
6
  const fs = require("node:fs");
4
7
  const path = require("node:path");
5
8
  const os = require("node:os");
@@ -28,7 +31,25 @@ function main() {
28
31
  process.exit(0);
29
32
  }
30
33
 
31
- console.log(`pubm: platform binary verified (${packageName})`);
34
+ if (platform !== "windows") {
35
+ const binDir = path.join(__dirname, "bin");
36
+ const target = path.join(binDir, ".pubm");
37
+
38
+ if (!fs.existsSync(binDir)) {
39
+ fs.mkdirSync(binDir, { recursive: true });
40
+ }
41
+ if (fs.existsSync(target)) {
42
+ fs.unlinkSync(target);
43
+ }
44
+ try {
45
+ fs.linkSync(binaryPath, target);
46
+ } catch {
47
+ fs.copyFileSync(binaryPath, target);
48
+ }
49
+ fs.chmodSync(target, 0o755);
50
+ }
51
+
52
+ console.log(`pubm: platform binary cached (${packageName})`);
32
53
  } catch {
33
54
  console.error(
34
55
  `pubm: could not find platform binary package. You may need to install it manually for your platform (${os.platform()}-${os.arch()}).`,