split-by-codeowners 1.0.3 → 1.0.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.
- package/README.md +52 -29
- package/action.yml +2 -2
- package/dist/index.js +8 -24
- package/dist/index.js.map +1 -1
- package/dist-cli/index.js +11 -31
- package/dist-cli/index.js.map +1 -1
- package/package.json +1 -1
package/dist-cli/index.js
CHANGED
|
@@ -1901,34 +1901,18 @@ async function runSplit(config, logger) {
|
|
|
1901
1901
|
const isGitHubActions = process.env.GITHUB_ACTIONS === "true";
|
|
1902
1902
|
// Auth mode selection:
|
|
1903
1903
|
// - In GitHub Actions: ALWAYS use token-based API (gh may not be installed/auth'd).
|
|
1904
|
-
// - Locally:
|
|
1905
|
-
if (isGitHubActions
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
let useGhCli = !isGitHubActions;
|
|
1909
|
-
let octokit = useGhCli ? null : (0, github_1.getOctokit)(token);
|
|
1910
|
-
let baseBranch;
|
|
1911
|
-
if (useGhCli) {
|
|
1912
|
-
try {
|
|
1913
|
-
const cwd = process.cwd();
|
|
1914
|
-
(0, ghcli_1.assertGhAuthenticated)(cwd);
|
|
1915
|
-
baseBranch = config.baseBranch || (0, ghcli_1.getDefaultBranchViaGh)(cwd);
|
|
1916
|
-
}
|
|
1917
|
-
catch (e) {
|
|
1918
|
-
if (token) {
|
|
1919
|
-
logger.warn("gh is not authenticated; falling back to token auth.");
|
|
1920
|
-
useGhCli = false;
|
|
1921
|
-
octokit = (0, github_1.getOctokit)(token);
|
|
1922
|
-
baseBranch = config.baseBranch || (await (0, github_1.getDefaultBranch)(octokit, repo));
|
|
1923
|
-
}
|
|
1924
|
-
else {
|
|
1925
|
-
throw e;
|
|
1926
|
-
}
|
|
1904
|
+
// - Locally: ALWAYS use gh CLI for best DevX (no token-based local mode).
|
|
1905
|
+
if (isGitHubActions) {
|
|
1906
|
+
if (!token) {
|
|
1907
|
+
throw new Error("Missing GitHub token (set github_token input or GITHUB_TOKEN / GH_TOKEN env var)");
|
|
1927
1908
|
}
|
|
1928
1909
|
}
|
|
1929
1910
|
else {
|
|
1930
|
-
|
|
1911
|
+
(0, ghcli_1.assertGhAuthenticated)(process.cwd());
|
|
1931
1912
|
}
|
|
1913
|
+
const useGhCli = !isGitHubActions;
|
|
1914
|
+
const octokit = useGhCli ? null : (0, github_1.getOctokit)(token);
|
|
1915
|
+
const baseBranch = config.baseBranch || (useGhCli ? (0, ghcli_1.getDefaultBranchViaGh)(process.cwd()) : await (0, github_1.getDefaultBranch)(octokit, repo));
|
|
1932
1916
|
const baseRef = "HEAD";
|
|
1933
1917
|
ensureDirExists((0, git_1.worktreeBaseDir)());
|
|
1934
1918
|
prs = [];
|
|
@@ -13349,8 +13333,7 @@ function printHelp() {
|
|
|
13349
13333
|
" --dry-run Compute buckets, don't write patches",
|
|
13350
13334
|
"",
|
|
13351
13335
|
"PR creation:",
|
|
13352
|
-
" --create-prs Push branches + create/update PRs (
|
|
13353
|
-
" --token <token> GitHub token (or env GITHUB_TOKEN / GH_TOKEN)",
|
|
13336
|
+
" --create-prs Push branches + create/update PRs (uses `gh` auth locally; token in CI)",
|
|
13354
13337
|
" --base-branch <branch> Base branch for PRs (default: repo default)",
|
|
13355
13338
|
" --branch-prefix <prefix> (default: codemods/)",
|
|
13356
13339
|
" --commit-message <msg> (default: chore: automated changes)",
|
|
@@ -13362,7 +13345,7 @@ function printHelp() {
|
|
|
13362
13345
|
"",
|
|
13363
13346
|
"Examples:",
|
|
13364
13347
|
" npx split-by-codeowners --exclude - < excludes.txt",
|
|
13365
|
-
" npx split-by-codeowners --create-prs --
|
|
13348
|
+
" npx split-by-codeowners --create-prs --base-branch main",
|
|
13366
13349
|
""
|
|
13367
13350
|
].join("\n"));
|
|
13368
13351
|
}
|
|
@@ -13400,7 +13383,6 @@ async function main() {
|
|
|
13400
13383
|
let dryRun = false;
|
|
13401
13384
|
let cleanupPatches = true;
|
|
13402
13385
|
let createPrs = false;
|
|
13403
|
-
let githubToken = "";
|
|
13404
13386
|
let baseBranch = "";
|
|
13405
13387
|
let branchPrefix = "codemods/";
|
|
13406
13388
|
let commitMessage = "chore: automated changes";
|
|
@@ -13435,8 +13417,6 @@ async function main() {
|
|
|
13435
13417
|
cleanupPatches = true;
|
|
13436
13418
|
else if (a === "--create-prs")
|
|
13437
13419
|
createPrs = true;
|
|
13438
|
-
else if (a === "--token")
|
|
13439
|
-
githubToken = takeArg(argv, i++, a);
|
|
13440
13420
|
else if (a === "--base-branch")
|
|
13441
13421
|
baseBranch = takeArg(argv, i++, a);
|
|
13442
13422
|
else if (a === "--branch-prefix")
|
|
@@ -13468,7 +13448,7 @@ async function main() {
|
|
|
13468
13448
|
cleanupPatches,
|
|
13469
13449
|
baseRef: "",
|
|
13470
13450
|
createPrs,
|
|
13471
|
-
githubToken,
|
|
13451
|
+
githubToken: "",
|
|
13472
13452
|
baseBranch,
|
|
13473
13453
|
branchPrefix,
|
|
13474
13454
|
commitMessage,
|