@pubm/plugin-brew 0.4.2 → 0.4.4
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 +68 -16
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -18,7 +18,42 @@ function generateFormula(opts) {
|
|
|
18
18
|
const darwinArm64 = findAsset(opts.assets, "darwin-arm64");
|
|
19
19
|
const darwinX64 = findAsset(opts.assets, "darwin-x64");
|
|
20
20
|
const linuxArm64 = findAsset(opts.assets, "linux-arm64");
|
|
21
|
+
const linuxArm64Musl = findAsset(opts.assets, "linux-arm64-musl");
|
|
21
22
|
const linuxX64 = findAsset(opts.assets, "linux-x64");
|
|
23
|
+
const linuxX64Musl = findAsset(opts.assets, "linux-x64-musl");
|
|
24
|
+
const hasMusl = linuxArm64Musl || linuxX64Musl;
|
|
25
|
+
let linuxBlock;
|
|
26
|
+
if (hasMusl) {
|
|
27
|
+
linuxBlock = ` on_linux do
|
|
28
|
+
if Hardware::CPU.arm?
|
|
29
|
+
if OS::Linux.libc_is_musl?
|
|
30
|
+
url "${linuxArm64Musl?.url ?? "PLACEHOLDER"}"
|
|
31
|
+
sha256 "${linuxArm64Musl?.sha256 ?? "PLACEHOLDER"}"
|
|
32
|
+
else
|
|
33
|
+
url "${linuxArm64?.url ?? "PLACEHOLDER"}"
|
|
34
|
+
sha256 "${linuxArm64?.sha256 ?? "PLACEHOLDER"}"
|
|
35
|
+
end
|
|
36
|
+
elsif Hardware::CPU.intel?
|
|
37
|
+
if OS::Linux.libc_is_musl?
|
|
38
|
+
url "${linuxX64Musl?.url ?? "PLACEHOLDER"}"
|
|
39
|
+
sha256 "${linuxX64Musl?.sha256 ?? "PLACEHOLDER"}"
|
|
40
|
+
else
|
|
41
|
+
url "${linuxX64?.url ?? "PLACEHOLDER"}"
|
|
42
|
+
sha256 "${linuxX64?.sha256 ?? "PLACEHOLDER"}"
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end`;
|
|
46
|
+
} else {
|
|
47
|
+
linuxBlock = ` on_linux do
|
|
48
|
+
if Hardware::CPU.arm?
|
|
49
|
+
url "${linuxArm64?.url ?? "PLACEHOLDER"}"
|
|
50
|
+
sha256 "${linuxArm64?.sha256 ?? "PLACEHOLDER"}"
|
|
51
|
+
elsif Hardware::CPU.intel?
|
|
52
|
+
url "${linuxX64?.url ?? "PLACEHOLDER"}"
|
|
53
|
+
sha256 "${linuxX64?.sha256 ?? "PLACEHOLDER"}"
|
|
54
|
+
end
|
|
55
|
+
end`;
|
|
56
|
+
}
|
|
22
57
|
return `class ${className} < Formula
|
|
23
58
|
desc "${opts.desc}"
|
|
24
59
|
homepage "${opts.homepage}"
|
|
@@ -35,15 +70,7 @@ function generateFormula(opts) {
|
|
|
35
70
|
end
|
|
36
71
|
end
|
|
37
72
|
|
|
38
|
-
|
|
39
|
-
if Hardware::CPU.arm?
|
|
40
|
-
url "${linuxArm64?.url ?? "PLACEHOLDER"}"
|
|
41
|
-
sha256 "${linuxArm64?.sha256 ?? "PLACEHOLDER"}"
|
|
42
|
-
elsif Hardware::CPU.intel?
|
|
43
|
-
url "${linuxX64?.url ?? "PLACEHOLDER"}"
|
|
44
|
-
sha256 "${linuxX64?.sha256 ?? "PLACEHOLDER"}"
|
|
45
|
-
end
|
|
46
|
-
end
|
|
73
|
+
${linuxBlock}
|
|
47
74
|
|
|
48
75
|
def install
|
|
49
76
|
bin.install "${opts.name}"
|
|
@@ -58,16 +85,31 @@ end
|
|
|
58
85
|
function updateFormula(content, version, assets) {
|
|
59
86
|
let updated = content.replace(/version\s+"[^"]+"/, `version "${version}"`);
|
|
60
87
|
for (const asset of assets) {
|
|
88
|
+
const isMusl = asset.platform === "linux-arm64-musl" || asset.platform === "linux-x64-musl";
|
|
61
89
|
const platformPatterns = {
|
|
62
90
|
"darwin-arm64": { os: "on_macos", cpu: "arm" },
|
|
63
91
|
"darwin-x64": { os: "on_macos", cpu: "intel" },
|
|
64
92
|
"linux-arm64": { os: "on_linux", cpu: "arm" },
|
|
65
|
-
"linux-
|
|
93
|
+
"linux-arm64-musl": { os: "on_linux", cpu: "arm", musl: true },
|
|
94
|
+
"linux-x64": { os: "on_linux", cpu: "intel" },
|
|
95
|
+
"linux-x64-musl": { os: "on_linux", cpu: "intel", musl: true }
|
|
66
96
|
};
|
|
67
97
|
const pattern = platformPatterns[asset.platform];
|
|
68
98
|
if (!pattern)
|
|
69
99
|
continue;
|
|
70
|
-
|
|
100
|
+
let osBlockRegex;
|
|
101
|
+
if (isMusl) {
|
|
102
|
+
osBlockRegex = new RegExp(`(${pattern.os}\\s+do[\\s\\S]*?Hardware::CPU\\.${pattern.cpu}\\?\\s*\\n[\\s\\S]*?libc_is_musl\\?\\s*\\n\\s*)url\\s+"[^"]+"(\\s*\\n\\s*)sha256\\s+"[^"]+"`, "m");
|
|
103
|
+
} else if (pattern.os === "on_linux") {
|
|
104
|
+
const muslCheck = new RegExp(`${pattern.os}\\s+do[\\s\\S]*?Hardware::CPU\\.${pattern.cpu}\\?[\\s\\S]*?libc_is_musl\\?`);
|
|
105
|
+
if (muslCheck.test(updated)) {
|
|
106
|
+
osBlockRegex = new RegExp(`(${pattern.os}\\s+do[\\s\\S]*?Hardware::CPU\\.${pattern.cpu}\\?\\s*\\n[\\s\\S]*?libc_is_musl\\?\\s*\\n\\s*url\\s+"[^"]+"\\s*\\n\\s*sha256\\s+"[^"]+"\\s*\\n\\s*else\\s*\\n\\s*)url\\s+"[^"]+"(\\s*\\n\\s*)sha256\\s+"[^"]+"`, "m");
|
|
107
|
+
} else {
|
|
108
|
+
osBlockRegex = new RegExp(`(${pattern.os}\\s+do[\\s\\S]*?Hardware::CPU\\.${pattern.cpu}\\?\\s*\\n\\s*)url\\s+"[^"]+"(\\s*\\n\\s*)sha256\\s+"[^"]+"`, "m");
|
|
109
|
+
}
|
|
110
|
+
} else {
|
|
111
|
+
osBlockRegex = new RegExp(`(${pattern.os}\\s+do[\\s\\S]*?Hardware::CPU\\.${pattern.cpu}\\?\\s*\\n\\s*)url\\s+"[^"]+"(\\s*\\n\\s*)sha256\\s+"[^"]+"`, "m");
|
|
112
|
+
}
|
|
71
113
|
updated = updated.replace(osBlockRegex, `$1url "${asset.url}"$2sha256 "${asset.sha256}"`);
|
|
72
114
|
}
|
|
73
115
|
return updated;
|
|
@@ -75,14 +117,24 @@ function updateFormula(content, version, assets) {
|
|
|
75
117
|
var FORMULA_PLATFORMS = {
|
|
76
118
|
"darwin-arm64": { os: "darwin", arch: "arm64" },
|
|
77
119
|
"darwin-x64": { os: "darwin", arch: "x64" },
|
|
120
|
+
"darwin-x64-baseline": { os: "darwin", arch: "x64", variant: "baseline" },
|
|
78
121
|
"linux-arm64": { os: "linux", arch: "arm64" },
|
|
79
|
-
"linux-
|
|
122
|
+
"linux-arm64-musl": { os: "linux", arch: "arm64", abi: "musl" },
|
|
123
|
+
"linux-x64": { os: "linux", arch: "x64" },
|
|
124
|
+
"linux-x64-baseline": { os: "linux", arch: "x64", variant: "baseline" },
|
|
125
|
+
"linux-x64-musl": { os: "linux", arch: "x64", abi: "musl" },
|
|
126
|
+
"linux-x64-musl-baseline": {
|
|
127
|
+
os: "linux",
|
|
128
|
+
arch: "x64",
|
|
129
|
+
abi: "musl",
|
|
130
|
+
variant: "baseline"
|
|
131
|
+
}
|
|
80
132
|
};
|
|
81
133
|
function matchAssetToPlatform(assets, formulaPlatform, customMatcher) {
|
|
82
134
|
if (customMatcher)
|
|
83
135
|
return assets.find(customMatcher);
|
|
84
|
-
const
|
|
85
|
-
return assets.find((a) => a.platform.os === os && a.platform.arch === arch);
|
|
136
|
+
const spec = FORMULA_PLATFORMS[formulaPlatform];
|
|
137
|
+
return assets.find((a) => a.platform.os === spec.os && a.platform.arch === spec.arch && (a.platform.abi ?? undefined) === ("abi" in spec ? spec.abi : undefined) && (a.platform.variant ?? undefined) === ("variant" in spec ? spec.variant : undefined));
|
|
86
138
|
}
|
|
87
139
|
function releaseAssetsToFormulaAssets(assets, customMatchers) {
|
|
88
140
|
const result = [];
|
|
@@ -154,7 +206,7 @@ function brewCore(options) {
|
|
|
154
206
|
],
|
|
155
207
|
hooks: {
|
|
156
208
|
afterRelease: async (_ctx, releaseCtx) => {
|
|
157
|
-
if (options.packageName && releaseCtx.
|
|
209
|
+
if (options.packageName && releaseCtx.displayLabel !== options.packageName) {
|
|
158
210
|
return;
|
|
159
211
|
}
|
|
160
212
|
const { execSync: execSync2 } = await import("node:child_process");
|
|
@@ -249,7 +301,7 @@ function brewTap(options) {
|
|
|
249
301
|
],
|
|
250
302
|
hooks: {
|
|
251
303
|
afterRelease: async (_ctx, releaseCtx) => {
|
|
252
|
-
if (options.packageName && releaseCtx.
|
|
304
|
+
if (options.packageName && releaseCtx.displayLabel !== options.packageName) {
|
|
253
305
|
return;
|
|
254
306
|
}
|
|
255
307
|
const formulaAssets = releaseAssetsToFormulaAssets(releaseCtx.assets, options.assetPlatforms);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pubm/plugin-brew",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "pubm plugin for Homebrew formula publishing workflows",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"license": "Apache-2.0",
|
|
25
25
|
"peerDependencies": {
|
|
26
|
-
"@pubm/core": ">=0.3
|
|
26
|
+
"@pubm/core": ">=0.4.3"
|
|
27
27
|
},
|
|
28
28
|
"publishConfig": {
|
|
29
29
|
"access": "public"
|