@pubm/plugin-brew 0.4.0 → 0.4.1
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 +23 -15
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -72,20 +72,28 @@ function updateFormula(content, version, assets) {
|
|
|
72
72
|
}
|
|
73
73
|
return updated;
|
|
74
74
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
75
|
+
var FORMULA_PLATFORMS = {
|
|
76
|
+
"darwin-arm64": { os: "darwin", arch: "arm64" },
|
|
77
|
+
"darwin-x64": { os: "darwin", arch: "x64" },
|
|
78
|
+
"linux-arm64": { os: "linux", arch: "arm64" },
|
|
79
|
+
"linux-x64": { os: "linux", arch: "x64" }
|
|
80
|
+
};
|
|
81
|
+
function matchAssetToPlatform(assets, formulaPlatform, customMatcher) {
|
|
82
|
+
if (customMatcher)
|
|
83
|
+
return assets.find(customMatcher);
|
|
84
|
+
const { os, arch } = FORMULA_PLATFORMS[formulaPlatform];
|
|
85
|
+
return assets.find((a) => a.platform.os === os && a.platform.arch === arch);
|
|
86
|
+
}
|
|
87
|
+
function releaseAssetsToFormulaAssets(assets, customMatchers) {
|
|
82
88
|
const result = [];
|
|
83
|
-
for (const
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
+
for (const key of Object.keys(FORMULA_PLATFORMS)) {
|
|
90
|
+
const matched = matchAssetToPlatform(assets, key, customMatchers?.[key]);
|
|
91
|
+
if (matched) {
|
|
92
|
+
result.push({
|
|
93
|
+
platform: key,
|
|
94
|
+
url: matched.url,
|
|
95
|
+
sha256: matched.sha256
|
|
96
|
+
});
|
|
89
97
|
}
|
|
90
98
|
}
|
|
91
99
|
return result;
|
|
@@ -154,7 +162,7 @@ function brewCore(options) {
|
|
|
154
162
|
const pkgPath = resolve(cwd, "package.json");
|
|
155
163
|
const pkg = existsSync(pkgPath) ? JSON.parse(readFileSync(pkgPath, "utf-8")) : {};
|
|
156
164
|
const name = pkg.name?.replace(/^@[^/]+\//, "") ?? "my-tool";
|
|
157
|
-
const formulaAssets =
|
|
165
|
+
const formulaAssets = releaseAssetsToFormulaAssets(releaseCtx.assets, options.assetPlatforms);
|
|
158
166
|
try {
|
|
159
167
|
execSync2("gh repo fork homebrew/homebrew-core --clone=false", {
|
|
160
168
|
stdio: "pipe"
|
|
@@ -244,7 +252,7 @@ function brewTap(options) {
|
|
|
244
252
|
if (options.packageName && releaseCtx.packageName !== options.packageName) {
|
|
245
253
|
return;
|
|
246
254
|
}
|
|
247
|
-
const formulaAssets =
|
|
255
|
+
const formulaAssets = releaseAssetsToFormulaAssets(releaseCtx.assets, options.assetPlatforms);
|
|
248
256
|
const formulaPath = resolve2(process.cwd(), options.formula);
|
|
249
257
|
let content;
|
|
250
258
|
if (existsSync2(formulaPath)) {
|