@buildinternet/uploads 0.50.0 → 0.50.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/cli-catalog.js +1 -0
- package/dist/commands.js +37 -9
- package/package.json +1 -1
package/dist/cli-catalog.js
CHANGED
package/dist/commands.js
CHANGED
|
@@ -809,6 +809,12 @@ takes effect with zero files and cannot combine with --branch/--issue/
|
|
|
809
809
|
--no-promote. Promotion never applies to issues. Staged files stay findable
|
|
810
810
|
with "uploads find gh.branch=<branch>" either way.
|
|
811
811
|
|
|
812
|
+
If the branch was renamed or deleted before the PR opened, pass
|
|
813
|
+
"--from-branch <old-name>" with "--pr <num>". With no file arguments, this
|
|
814
|
+
promotes the stale branch prefix and refreshes the managed comment. With file
|
|
815
|
+
or existing-key arguments, it promotes the stale prefix before the normal
|
|
816
|
+
attach flow.
|
|
817
|
+
|
|
812
818
|
Options:
|
|
813
819
|
--pr <num> Attach to this pull request
|
|
814
820
|
--issue <num> Attach to this issue
|
|
@@ -817,6 +823,8 @@ Options:
|
|
|
817
823
|
--promote No files: promote branch-staged attachments into the
|
|
818
824
|
resolved PR and refresh the comment; not with
|
|
819
825
|
--branch/--issue/--no-promote
|
|
826
|
+
--from-branch <name> Promote staged attachments from this branch instead of
|
|
827
|
+
the current branch; requires a pull-request target
|
|
820
828
|
--no-promote Skip auto-promoting branch-staged attachments (default path only)
|
|
821
829
|
--move With an already-uploaded key/URL argument: delete the source
|
|
822
830
|
object after a successful server-side copy (default: copy)
|
|
@@ -848,6 +856,7 @@ Examples:
|
|
|
848
856
|
uploads attach ./artifact.zip --issue 45 --no-comment
|
|
849
857
|
uploads attach ./shot.png --meta path=/settings --state after
|
|
850
858
|
uploads attach ./shot.png --branch
|
|
859
|
+
uploads attach --pr 123 --from-branch old/branch
|
|
851
860
|
uploads attach ./shot.png --branch feature/new-settings
|
|
852
861
|
uploads attach --promote
|
|
853
862
|
`;
|
|
@@ -1204,7 +1213,12 @@ export async function runAttach(ctx, args, help = false, run = execRunner) {
|
|
|
1204
1213
|
if (parsed.flags.has("--move") && typeof parsed.flags.get("--move") === "string") {
|
|
1205
1214
|
throw new UsageError("--move takes no value — place it after the file arguments");
|
|
1206
1215
|
}
|
|
1207
|
-
if (parsed.flags.has("--
|
|
1216
|
+
if (parsed.flags.has("--from-branch") && !flagString(parsed.flags, "--from-branch")) {
|
|
1217
|
+
throw new UsageError("--from-branch requires a branch name");
|
|
1218
|
+
}
|
|
1219
|
+
const fromBranch = flagString(parsed.flags, "--from-branch");
|
|
1220
|
+
if (parsed.flags.has("--promote") ||
|
|
1221
|
+
(fromBranch !== undefined && parsed.positionals.length === 0)) {
|
|
1208
1222
|
if (parsed.positionals.length > 0) {
|
|
1209
1223
|
throw new UsageError("--promote takes no file arguments — attaching a file to a PR already auto-promotes " +
|
|
1210
1224
|
"staged files; use `uploads attach <file> --pr <num>` instead");
|
|
@@ -1236,6 +1250,12 @@ export async function runAttach(ctx, args, help = false, run = execRunner) {
|
|
|
1236
1250
|
throw new UsageError("--branch cannot be combined with --comment");
|
|
1237
1251
|
return runAttachBranch(ctx, parsed, branchArg, run);
|
|
1238
1252
|
}
|
|
1253
|
+
if (fromBranch !== undefined && parsed.flags.has("--issue")) {
|
|
1254
|
+
throw new UsageError("--from-branch cannot be combined with --issue");
|
|
1255
|
+
}
|
|
1256
|
+
if (fromBranch !== undefined && parsed.flags.has("--no-promote")) {
|
|
1257
|
+
throw new UsageError("--from-branch cannot be combined with --no-promote");
|
|
1258
|
+
}
|
|
1239
1259
|
const explicitTarget = ghTargetFromFlags(parsed.flags, run);
|
|
1240
1260
|
const target = explicitTarget ??
|
|
1241
1261
|
resolveCurrentPullRequest(resolveRepo(flagString(parsed.flags, "--repo"), run), run);
|
|
@@ -1324,11 +1344,14 @@ export async function runAttach(ctx, args, help = false, run = execRunner) {
|
|
|
1324
1344
|
let promotion;
|
|
1325
1345
|
let promotedBranch;
|
|
1326
1346
|
if (target.kind === "pull" && !parsed.flags.has("--no-promote")) {
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1347
|
+
promotedBranch = fromBranch;
|
|
1348
|
+
if (promotedBranch === undefined) {
|
|
1349
|
+
try {
|
|
1350
|
+
promotedBranch = resolveCurrentBranch(run);
|
|
1351
|
+
}
|
|
1352
|
+
catch {
|
|
1353
|
+
promotedBranch = undefined;
|
|
1354
|
+
}
|
|
1332
1355
|
}
|
|
1333
1356
|
if (promotedBranch !== undefined) {
|
|
1334
1357
|
promotion = await attemptPromoteBranch(ctx.client, target, promotedBranch);
|
|
@@ -1336,8 +1359,10 @@ export async function runAttach(ctx, args, help = false, run = execRunner) {
|
|
|
1336
1359
|
}
|
|
1337
1360
|
let comment;
|
|
1338
1361
|
let commentError;
|
|
1339
|
-
//
|
|
1340
|
-
|
|
1362
|
+
// Existing-key attach syncs server-side, but a stale-branch promotion runs
|
|
1363
|
+
// afterward. Refresh once more so that copy is visible in the same command.
|
|
1364
|
+
const shouldRefreshComment = uploads.length > 0 || (fromBranch !== undefined && attachedExisting.length > 0);
|
|
1365
|
+
if (!parsed.flags.has("--no-comment") && shouldRefreshComment) {
|
|
1341
1366
|
try {
|
|
1342
1367
|
comment = await syncAttachmentsComment(ctx.client, target, run, ctx.config.workspace);
|
|
1343
1368
|
}
|
|
@@ -1539,7 +1564,10 @@ async function runAttachPromoteOnly(ctx, parsed, run) {
|
|
|
1539
1564
|
const explicitTarget = ghTargetFromFlags(parsed.flags, run);
|
|
1540
1565
|
const target = explicitTarget ??
|
|
1541
1566
|
resolveCurrentPullRequest(resolveRepo(flagString(parsed.flags, "--repo"), run), run);
|
|
1542
|
-
|
|
1567
|
+
if (target.kind !== "pull") {
|
|
1568
|
+
throw new UsageError("--from-branch only promotes into a pull request");
|
|
1569
|
+
}
|
|
1570
|
+
const branch = flagString(parsed.flags, "--from-branch") ?? resolveCurrentBranch(run);
|
|
1543
1571
|
const promotion = await attemptPromoteBranch(ctx.client, target, branch);
|
|
1544
1572
|
let comment;
|
|
1545
1573
|
let commentError;
|