@pubm/plugin-brew 0.4.5 → 0.4.7
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/brew-core.d.ts +3 -0
- package/dist/brew-tap.d.ts +3 -0
- package/dist/formula.d.ts +65 -0
- package/dist/git-identity.d.ts +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +25 -4
- package/dist/types.d.ts +13 -0
- package/package.json +2 -2
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { ReleaseAsset } from "@pubm/core";
|
|
2
|
+
import type { AssetPlatformMatcher } from "./types.js";
|
|
3
|
+
export interface FormulaAsset {
|
|
4
|
+
platform: "darwin-arm64" | "darwin-x64" | "darwin-x64-baseline" | "linux-arm64" | "linux-arm64-musl" | "linux-x64" | "linux-x64-baseline" | "linux-x64-musl" | "linux-x64-musl-baseline";
|
|
5
|
+
url: string;
|
|
6
|
+
sha256: string;
|
|
7
|
+
}
|
|
8
|
+
export interface GenerateFormulaOptions {
|
|
9
|
+
name: string;
|
|
10
|
+
desc: string;
|
|
11
|
+
homepage: string;
|
|
12
|
+
license: string;
|
|
13
|
+
version: string;
|
|
14
|
+
assets: FormulaAsset[];
|
|
15
|
+
}
|
|
16
|
+
export declare function generateFormula(opts: GenerateFormulaOptions): string;
|
|
17
|
+
export declare function updateFormula(content: string, version: string, assets: FormulaAsset[]): string;
|
|
18
|
+
declare const FORMULA_PLATFORMS: {
|
|
19
|
+
readonly "darwin-arm64": {
|
|
20
|
+
readonly os: "darwin";
|
|
21
|
+
readonly arch: "arm64";
|
|
22
|
+
};
|
|
23
|
+
readonly "darwin-x64": {
|
|
24
|
+
readonly os: "darwin";
|
|
25
|
+
readonly arch: "x64";
|
|
26
|
+
};
|
|
27
|
+
readonly "darwin-x64-baseline": {
|
|
28
|
+
readonly os: "darwin";
|
|
29
|
+
readonly arch: "x64";
|
|
30
|
+
readonly variant: "baseline";
|
|
31
|
+
};
|
|
32
|
+
readonly "linux-arm64": {
|
|
33
|
+
readonly os: "linux";
|
|
34
|
+
readonly arch: "arm64";
|
|
35
|
+
};
|
|
36
|
+
readonly "linux-arm64-musl": {
|
|
37
|
+
readonly os: "linux";
|
|
38
|
+
readonly arch: "arm64";
|
|
39
|
+
readonly abi: "musl";
|
|
40
|
+
};
|
|
41
|
+
readonly "linux-x64": {
|
|
42
|
+
readonly os: "linux";
|
|
43
|
+
readonly arch: "x64";
|
|
44
|
+
};
|
|
45
|
+
readonly "linux-x64-baseline": {
|
|
46
|
+
readonly os: "linux";
|
|
47
|
+
readonly arch: "x64";
|
|
48
|
+
readonly variant: "baseline";
|
|
49
|
+
};
|
|
50
|
+
readonly "linux-x64-musl": {
|
|
51
|
+
readonly os: "linux";
|
|
52
|
+
readonly arch: "x64";
|
|
53
|
+
readonly abi: "musl";
|
|
54
|
+
};
|
|
55
|
+
readonly "linux-x64-musl-baseline": {
|
|
56
|
+
readonly os: "linux";
|
|
57
|
+
readonly arch: "x64";
|
|
58
|
+
readonly abi: "musl";
|
|
59
|
+
readonly variant: "baseline";
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
export type FormulaPlatformKey = keyof typeof FORMULA_PLATFORMS;
|
|
63
|
+
export declare function matchAssetToPlatform(assets: ReleaseAsset[], formulaPlatform: FormulaPlatformKey, customMatcher?: AssetPlatformMatcher): ReleaseAsset | undefined;
|
|
64
|
+
export declare function releaseAssetsToFormulaAssets(assets: ReleaseAsset[], customMatchers?: Record<string, AssetPlatformMatcher>): FormulaAsset[];
|
|
65
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function ensureGitIdentity(cwd?: string): void;
|
package/dist/index.d.ts
ADDED
package/dist/index.js
CHANGED
|
@@ -347,10 +347,19 @@ function brewTap(options) {
|
|
|
347
347
|
const { tmpdir: tmpdir2 } = await import("node:os");
|
|
348
348
|
const { basename, join: join2 } = await import("node:path");
|
|
349
349
|
const { execSync: execSync2 } = await import("node:child_process");
|
|
350
|
+
const { resolveGitHubToken } = await import("@pubm/core");
|
|
350
351
|
const tmpDir = join2(tmpdir2(), `pubm-brew-tap-${Date.now()}`);
|
|
351
352
|
const formulaFile = basename(formulaPath);
|
|
352
|
-
const
|
|
353
|
-
|
|
353
|
+
const isShorthand = /^[^/]+\/[^/]+$/.test(options.repo);
|
|
354
|
+
const repoUrl = isShorthand ? `https://github.com/${options.repo}.git` : options.repo;
|
|
355
|
+
const ownerRepoMatch = repoUrl.match(/github\.com[/:]([^/]+\/[^/.]+?)(?:\.git)?$/);
|
|
356
|
+
const ownerRepo = ownerRepoMatch?.[1] ?? options.repo;
|
|
357
|
+
let cloneUrl = repoUrl;
|
|
358
|
+
const tokenResult = resolveGitHubToken();
|
|
359
|
+
if (tokenResult?.token && repoUrl.startsWith("https://github.com/")) {
|
|
360
|
+
cloneUrl = repoUrl.replace("https://github.com/", `https://x-access-token:${tokenResult.token}@github.com/`);
|
|
361
|
+
}
|
|
362
|
+
execSync2(`git clone --depth 1 ${cloneUrl} ${tmpDir}`, {
|
|
354
363
|
stdio: "inherit"
|
|
355
364
|
});
|
|
356
365
|
ensureGitIdentity(tmpDir);
|
|
@@ -360,9 +369,21 @@ function brewTap(options) {
|
|
|
360
369
|
execSync2([
|
|
361
370
|
`cd ${tmpDir}`,
|
|
362
371
|
`git add Formula/${formulaFile}`,
|
|
363
|
-
`git commit -m "Update ${formulaFile} to ${releaseCtx.version}"
|
|
364
|
-
"git push"
|
|
372
|
+
`git commit -m "Update ${formulaFile} to ${releaseCtx.version}"`
|
|
365
373
|
].join(" && "), { stdio: "inherit" });
|
|
374
|
+
try {
|
|
375
|
+
execSync2(`cd ${tmpDir} && git push`, { stdio: "inherit" });
|
|
376
|
+
} catch {
|
|
377
|
+
const branch = `pubm/brew-formula-v${releaseCtx.version}`;
|
|
378
|
+
execSync2(`cd ${tmpDir} && git checkout -b ${branch}`, {
|
|
379
|
+
stdio: "inherit"
|
|
380
|
+
});
|
|
381
|
+
execSync2(`cd ${tmpDir} && git push origin ${branch}`, {
|
|
382
|
+
stdio: "inherit"
|
|
383
|
+
});
|
|
384
|
+
execSync2(`gh pr create --repo ${ownerRepo} --title "chore(brew): update formula to ${releaseCtx.version}" --body "Automated formula update by pubm"`, { stdio: "inherit" });
|
|
385
|
+
console.log(`Created PR on branch ${branch}`);
|
|
386
|
+
}
|
|
366
387
|
}
|
|
367
388
|
}
|
|
368
389
|
}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ReleaseAsset } from "@pubm/core";
|
|
2
|
+
export type AssetPlatformMatcher = (asset: ReleaseAsset) => boolean;
|
|
3
|
+
export interface BrewTapOptions {
|
|
4
|
+
formula: string;
|
|
5
|
+
repo?: string;
|
|
6
|
+
packageName?: string;
|
|
7
|
+
assetPlatforms?: Record<string, AssetPlatformMatcher>;
|
|
8
|
+
}
|
|
9
|
+
export interface BrewCoreOptions {
|
|
10
|
+
formula: string;
|
|
11
|
+
packageName?: string;
|
|
12
|
+
assetPlatforms?: Record<string, AssetPlatformMatcher>;
|
|
13
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pubm/plugin-brew",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "pubm plugin for Homebrew formula publishing workflows",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"dist/"
|
|
16
16
|
],
|
|
17
17
|
"scripts": {
|
|
18
|
-
"build": "bun build
|
|
18
|
+
"build": "bun run ./build.ts",
|
|
19
19
|
"check": "biome check",
|
|
20
20
|
"typecheck": "tsc --noEmit",
|
|
21
21
|
"test": "vitest --run --passWithNoTests",
|