@buildinternet/uploads 0.26.0 → 0.27.0
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/LICENSE +202 -21
- package/README.md +5 -0
- package/dist/cli-catalog.js +1 -0
- package/dist/cli.js +5 -0
- package/dist/client.d.ts +5 -0
- package/dist/commands/config.js +6 -1
- package/dist/commands/login.js +25 -13
- package/dist/commands/screenshot.js +85 -12
- package/dist/commands/session.js +7 -5
- package/dist/commands.d.ts +23 -0
- package/dist/commands.js +112 -16
- package/dist/config-file.d.ts +1 -1
- package/dist/config-file.js +2 -0
- package/dist/config.d.ts +2 -0
- package/dist/config.js +14 -0
- package/dist/format-bytes.d.ts +6 -2
- package/dist/format-bytes.js +19 -5
- package/dist/format-usage.d.ts +9 -0
- package/dist/format-usage.js +34 -5
- package/dist/github.d.ts +6 -0
- package/dist/github.js +12 -0
- package/dist/mcp/tools.js +38 -22
- package/dist/session-cli-version.d.ts +15 -0
- package/dist/session-cli-version.js +85 -0
- package/dist/sidecar.d.ts +31 -0
- package/dist/sidecar.js +111 -0
- package/package.json +2 -2
package/LICENSE
CHANGED
|
@@ -1,21 +1,202 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2026 Build Internet
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -98,6 +98,11 @@ explicit deletes. Promotion (auto or `--promote`) does skip files staged
|
|
|
98
98
|
more than 30 days before the PR opens, though; they're still there, just no
|
|
99
99
|
longer auto-promoted.
|
|
100
100
|
|
|
101
|
+
**Metadata edits re-sync the comment too:** `uploads meta set` on a `gh/…`-keyed
|
|
102
|
+
object refreshes the managed comment automatically when it touches `path` or
|
|
103
|
+
`state` — best-effort, so backfilled metadata shows up without waiting on the
|
|
104
|
+
next `attach`.
|
|
105
|
+
|
|
101
106
|
**Bare `put` stages too, by default (issue #403):** on a non-default git
|
|
102
107
|
branch, a `put` with none of
|
|
103
108
|
`--pr`/`--issue`/`--key`/`--ref`/`--prefix`/`--destination` set
|
package/dist/cli-catalog.js
CHANGED
package/dist/cli.js
CHANGED
|
@@ -19,6 +19,7 @@ import { runReport } from "./commands/report.js";
|
|
|
19
19
|
import { runScreenshot } from "./commands/screenshot.js";
|
|
20
20
|
import { packageVersion } from "./package-version.js";
|
|
21
21
|
import { checkForUpdate, maybeHintUpdate } from "./update-check.js";
|
|
22
|
+
import { maybeSyncSessionCliVersion } from "./session-cli-version.js";
|
|
22
23
|
import { errorCodeFromUnknown, maybeShowFirstRunNotice, recordEvent, telemetryCommandName, } from "./telemetry.js";
|
|
23
24
|
async function writeRootHelp(options = {}) {
|
|
24
25
|
// Best-effort version check so the help header can show a banner when outdated.
|
|
@@ -197,6 +198,10 @@ export async function runCli(argv) {
|
|
|
197
198
|
const json = parsed.globals.json ?? false;
|
|
198
199
|
const quiet = parsed.globals.quiet ?? false;
|
|
199
200
|
apiUrl = resolveApiUrl(parsed.globals);
|
|
201
|
+
// Refresh session.cliVersion when the installed package changes (no-op without a session token).
|
|
202
|
+
if (parsed.command && parsed.command !== "login" && parsed.command !== "logout") {
|
|
203
|
+
maybeSyncSessionCliVersion({ apiUrl, envFile: parsed.globals.envFile });
|
|
204
|
+
}
|
|
200
205
|
if (parsed.globals.version) {
|
|
201
206
|
process.stdout.write(`${packageVersion()}\n`);
|
|
202
207
|
return 0;
|
package/dist/client.d.ts
CHANGED
|
@@ -291,6 +291,11 @@ export interface UsageResult {
|
|
|
291
291
|
uploadsRemaining?: number;
|
|
292
292
|
/** File scopes of the presented token (servers ≥ this field's release). */
|
|
293
293
|
scopes?: Array<TokenScope>;
|
|
294
|
+
/**
|
|
295
|
+
* Workspace plan catalog id (`free` | `pro`). Present on API workers that
|
|
296
|
+
* ship plan-aware usage; omitted on older servers.
|
|
297
|
+
*/
|
|
298
|
+
plan?: string;
|
|
294
299
|
}
|
|
295
300
|
export interface ReconcileResult {
|
|
296
301
|
workspace: string;
|
package/dist/commands/config.js
CHANGED
|
@@ -19,6 +19,7 @@ Keys:
|
|
|
19
19
|
UPLOADS_API_URL API base URL (default: ${DEFAULT_API_URL})
|
|
20
20
|
UPLOADS_WORKSPACE Workspace / bucket tenant (default: ${DEFAULT_WORKSPACE})
|
|
21
21
|
UPLOADS_TOKEN Bearer token for the workspace
|
|
22
|
+
UPLOADS_SESSION_TOKEN Device-flow session (CLI version on account sessions)
|
|
22
23
|
UPLOADS_DEFAULT_PREFIX Default key prefix for put/list
|
|
23
24
|
UPLOADS_DEFAULT_REPO Default repo segment for put
|
|
24
25
|
UPLOADS_DEFAULT_REF Default ref segment for put
|
|
@@ -195,7 +196,11 @@ Examples:
|
|
|
195
196
|
const path = flagString(parsed.flags, "--path") ?? resolveConfigPath({ envFile: opts.envFile });
|
|
196
197
|
const force = flagBool(parsed.flags, "--force");
|
|
197
198
|
const result = writeConfigKeys(path, { [key]: value }, { force });
|
|
198
|
-
const payload = {
|
|
199
|
+
const payload = {
|
|
200
|
+
...result,
|
|
201
|
+
key,
|
|
202
|
+
value: key === "UPLOADS_TOKEN" || key === "UPLOADS_SESSION_TOKEN" ? redactToken(value) : value,
|
|
203
|
+
};
|
|
199
204
|
if (opts.json)
|
|
200
205
|
writeJson(payload);
|
|
201
206
|
else
|
package/dist/commands/login.js
CHANGED
|
@@ -2,12 +2,13 @@ import { hostname } from "node:os";
|
|
|
2
2
|
import { createInterface } from "node:readline/promises";
|
|
3
3
|
import { spawn } from "node:child_process";
|
|
4
4
|
import { stdin, stdout } from "node:process";
|
|
5
|
-
import { loadConfigFile, redactToken, resolveConfigPath, writeConfigKeys, workspaceFromToken, } from "../config.js";
|
|
5
|
+
import { authUrlFromApi, loadConfigFile, redactToken, removeConfigKeys, resolveConfigPath, writeConfigKeys, workspaceFromToken, } from "../config.js";
|
|
6
6
|
import { createUploadsClient, createWorkspaceRequest, exchangeEnrollment, listMintWorkspaces, mintWorkspaceToken, requestDeviceCode, requestDeviceToken, } from "../client.js";
|
|
7
7
|
import { flagBool, flagString, parseCommandArgs, UsageError } from "../cli-args.js";
|
|
8
8
|
import { parseScopes } from "./admin-enrollment.js";
|
|
9
9
|
import { writeCommandHelp } from "../cli-style.js";
|
|
10
10
|
import { UploadsError } from "../errors.js";
|
|
11
|
+
import { syncSessionCliVersion } from "../session-cli-version.js";
|
|
11
12
|
const HELP = `uploads login [options]
|
|
12
13
|
|
|
13
14
|
Sign in and save workspace credentials. With no flags, opens a browser to
|
|
@@ -168,17 +169,7 @@ export function resolveAuthUrl(parsed, apiUrl) {
|
|
|
168
169
|
const explicit = flagString(parsed.flags, "--auth-url") ?? process.env.UPLOADS_AUTH_URL;
|
|
169
170
|
if (explicit)
|
|
170
171
|
return explicit.replace(/\/$/, "");
|
|
171
|
-
|
|
172
|
-
const url = new URL(apiUrl);
|
|
173
|
-
if (url.hostname.startsWith("api.")) {
|
|
174
|
-
url.hostname = `auth.${url.hostname.slice(4)}`;
|
|
175
|
-
return url.origin;
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
catch {
|
|
179
|
-
// fall through to the default
|
|
180
|
-
}
|
|
181
|
-
return "https://auth.uploads.sh";
|
|
172
|
+
return authUrlFromApi(apiUrl);
|
|
182
173
|
}
|
|
183
174
|
/** Best-effort browser open. The URL is always printed too, so failures are silent. */
|
|
184
175
|
function openUrl(url) {
|
|
@@ -288,7 +279,13 @@ async function runDeviceLogin(parsed, opts, io) {
|
|
|
288
279
|
scopes,
|
|
289
280
|
label,
|
|
290
281
|
}).catch((err) => describeMintFailure(opts.apiUrl, session.accessToken, workspace, err));
|
|
291
|
-
return {
|
|
282
|
+
return {
|
|
283
|
+
workspace: minted.workspace,
|
|
284
|
+
token: minted.token,
|
|
285
|
+
apiUrl: opts.apiUrl,
|
|
286
|
+
sessionToken: session.accessToken,
|
|
287
|
+
authUrl: opts.authUrl,
|
|
288
|
+
};
|
|
292
289
|
}
|
|
293
290
|
function safeHostname() {
|
|
294
291
|
try {
|
|
@@ -408,9 +405,24 @@ export async function runLogin(args, opts, help = false, deviceIo = defaultDevic
|
|
|
408
405
|
UPLOADS_API_URL: savedApiUrl,
|
|
409
406
|
UPLOADS_WORKSPACE: result.workspace,
|
|
410
407
|
UPLOADS_TOKEN: result.token,
|
|
408
|
+
// Device login only — enables throttled session.cliVersion refresh.
|
|
409
|
+
...(result.sessionToken ? { UPLOADS_SESSION_TOKEN: result.sessionToken } : {}),
|
|
411
410
|
}, { force });
|
|
412
411
|
if (!["UPLOADS_API_URL", "UPLOADS_WORKSPACE", "UPLOADS_TOKEN"].every((key) => write.updated.includes(key)))
|
|
413
412
|
throw new UsageError("credentials were not fully written; retry with --force");
|
|
413
|
+
// Enrollment path: drop any stale device session so we don't heartbeat a dead token.
|
|
414
|
+
if (!result.sessionToken) {
|
|
415
|
+
removeConfigKeys(path, ["UPLOADS_SESSION_TOKEN"]);
|
|
416
|
+
}
|
|
417
|
+
else {
|
|
418
|
+
// Seed session.cliVersion immediately (don't wait for the next command).
|
|
419
|
+
await syncSessionCliVersion({
|
|
420
|
+
sessionToken: result.sessionToken,
|
|
421
|
+
authUrl: result.authUrl,
|
|
422
|
+
apiUrl: savedApiUrl,
|
|
423
|
+
force: true,
|
|
424
|
+
});
|
|
425
|
+
}
|
|
414
426
|
const checked = !flagBool(parsed.flags, "--no-check");
|
|
415
427
|
let doctor = { ok: true, error: undefined };
|
|
416
428
|
if (checked) {
|
|
@@ -2,15 +2,16 @@ import { readFileSync, writeFileSync } from "node:fs";
|
|
|
2
2
|
import { basename } from "node:path";
|
|
3
3
|
import { flagBool, flagInt, flagString, flagValues, parseCommandArgs, UsageError, } from "../cli-args.js";
|
|
4
4
|
import { writeCommandHelp } from "../cli-style.js";
|
|
5
|
-
import { branchFromFlags, derivedMetaEnabled, frameOptionsFromFlags, ghTargetFromFlags, optimizeOptionsFromFlags, stateAppMetaFromFlags, warnNearMissMeta, syncAttachmentsComment, commentViaSuffix, uploadPreparedImage, } from "../commands.js";
|
|
5
|
+
import { branchFromFlags, derivedMetaEnabled, frameOptionsFromFlags, ghTargetFromFlags, optimizeOptionsFromFlags, stateAppMetaFromFlags, warnNearMissMeta, syncAttachmentsComment, commentViaSuffix, uploadPreparedImage, resolvePutStagingTarget, putStagingNoteText, resolveStageBindingWarning, mergeStagingMeta, } from "../commands.js";
|
|
6
6
|
import { resolvePutDefaults } from "../config.js";
|
|
7
7
|
import { loadDefaultsRaw, resolveScreenshotDefaults } from "../config-file.js";
|
|
8
8
|
import { resolvePutPrefix } from "../destinations.js";
|
|
9
9
|
import { execRunner, ghMetadataFromTargetWithTitle, resolveRepo, } from "../github-gh.js";
|
|
10
|
-
import { ghBranchAttachmentKey
|
|
10
|
+
import { ghBranchAttachmentKey } from "../github.js";
|
|
11
11
|
import { safeCaptureFacts } from "../capture-facts.js";
|
|
12
12
|
import { parseMetaFlags, validateMetaMap } from "../metadata.js";
|
|
13
13
|
import { mergeDerivedMeta } from "../metadata-vocab.js";
|
|
14
|
+
import { writeSidecarMeta } from "../sidecar.js";
|
|
14
15
|
import { writeJson, writeStdout } from "../io.js";
|
|
15
16
|
import { assertHideSelector, captureScreenshot, parseViewport, parseWaitUntil, } from "../screenshot.js";
|
|
16
17
|
const SCREENSHOT_HELP = `uploads screenshot <target> [options]
|
|
@@ -33,6 +34,15 @@ fail fast with a clear error instead of sending a doomed request.
|
|
|
33
34
|
After capture, screenshots share the put upload pipeline: optional --frame,
|
|
34
35
|
optimize-by-default, --pr/--issue attachment + --comment, --gallery, --meta.
|
|
35
36
|
|
|
37
|
+
Branch staging by default (pre-PR): with no --pr/--issue/--branch/--key/--ref/
|
|
38
|
+
--prefix/--destination, a screenshot taken on a non-default git branch stages
|
|
39
|
+
under gh/<owner>/<repo>/branch/<branch>/<name> instead of the dated
|
|
40
|
+
screenshots/<repo>/<date>/... layout — same key/metadata as an explicit
|
|
41
|
+
--branch, carrying every derived fact (path/url/env/viewport, --state) along.
|
|
42
|
+
Staged files auto-attach with full metadata the first time you attach to that
|
|
43
|
+
branch's PR once it opens (or run "uploads attach --promote"). Use --no-git,
|
|
44
|
+
or an explicit --ref/--prefix, to opt back into the dated layout.
|
|
45
|
+
|
|
36
46
|
Options:
|
|
37
47
|
--via auto|local|remote Capture backend (default: auto, or UPLOADS_SCREENSHOT_VIA)
|
|
38
48
|
--browser <path> Explicit local browser executable (or UPLOADS_CHROME_PATH / CHROME_PATH)
|
|
@@ -51,7 +61,12 @@ Options:
|
|
|
51
61
|
on --via remote — neutralizes animations via injected CSS)
|
|
52
62
|
--eval <js> Run JS in the page after settle, before capture (--via local only)
|
|
53
63
|
--init-script <file> Inject a JS file before navigation (--via local only)
|
|
54
|
-
--out <file> Also write the PNG to a local file
|
|
64
|
+
--out <file> Also write the PNG to a local file. Also writes a sidecar manifest,
|
|
65
|
+
<file>.uploads.json, recording this capture's derived metadata
|
|
66
|
+
(path/url/env/viewport, plus --state if given) with a content hash; a
|
|
67
|
+
later \`put\`/\`attach\` of this exact file picks the metadata back up
|
|
68
|
+
automatically (explicit --meta/--state still win). See --no-sidecar.
|
|
69
|
+
--no-sidecar Don't write the <file>.uploads.json sidecar alongside --out
|
|
55
70
|
--no-upload Skip hosting; requires --out (local file only)
|
|
56
71
|
--destination <id> Typed root: screenshots | gh | f
|
|
57
72
|
--prefix <path> Key prefix (default: screenshots, or UPLOADS_DEFAULT_PREFIX)
|
|
@@ -171,6 +186,9 @@ captureImpl = captureScreenshot) {
|
|
|
171
186
|
const noUpload = flagBool(parsed.flags, "--no-upload");
|
|
172
187
|
if (noUpload && !outFile)
|
|
173
188
|
throw new UsageError("--no-upload requires --out");
|
|
189
|
+
const noSidecar = flagBool(parsed.flags, "--no-sidecar");
|
|
190
|
+
if (noSidecar && !outFile)
|
|
191
|
+
throw new UsageError("--no-sidecar requires --out");
|
|
174
192
|
const keyHint = flagString(parsed.flags, "--key");
|
|
175
193
|
const destFlag = flagString(parsed.flags, "--destination");
|
|
176
194
|
const prefixFlag = flagString(parsed.flags, "--prefix");
|
|
@@ -210,14 +228,38 @@ captureImpl = captureScreenshot) {
|
|
|
210
228
|
if (noUpload)
|
|
211
229
|
throw new UsageError("--dry-run cannot be combined with --no-upload");
|
|
212
230
|
}
|
|
231
|
+
const putDefaults = resolvePutDefaults({ envFile: ctx.envFile }, rawDefaults);
|
|
232
|
+
const noGit = flagBool(parsed.flags, "--no-git") || putDefaults.noGit === true;
|
|
213
233
|
const branchRepo = branchArg !== undefined ? resolveRepo(flagString(parsed.flags, "--repo"), run) : undefined;
|
|
234
|
+
// Auto branch staging (issue #469 lever 1): mirrors bare `put`'s auto-staging
|
|
235
|
+
// (issue #403). When no --branch/--pr/--issue/--key/--ref/--prefix/--destination
|
|
236
|
+
// is given and git use isn't disabled, a screenshot taken on a non-default
|
|
237
|
+
// git branch stages the same way explicit `--branch`/bare `put` do — same
|
|
238
|
+
// key shape, same gh.* metadata — instead of landing on the dated
|
|
239
|
+
// `screenshots/<repo>/<date>/...` layout. This is what lets derived
|
|
240
|
+
// metadata (path/url/env/viewport, --state) ride through to PR-open
|
|
241
|
+
// promotion when the capture happens before the PR exists. Skipped
|
|
242
|
+
// entirely when --branch was given explicitly (already handled above).
|
|
243
|
+
const autoStagingTarget = branchArg === undefined
|
|
244
|
+
? resolvePutStagingTarget({
|
|
245
|
+
ghTarget,
|
|
246
|
+
keyHint,
|
|
247
|
+
refArg: flagString(parsed.flags, "--ref"),
|
|
248
|
+
prefixArg: prefixFlag,
|
|
249
|
+
destinationArg: destFlag,
|
|
250
|
+
noGit,
|
|
251
|
+
repoArg: flagString(parsed.flags, "--repo") ?? putDefaults.repo,
|
|
252
|
+
run,
|
|
253
|
+
})
|
|
254
|
+
: undefined;
|
|
255
|
+
const stagingTarget = branchArg !== undefined ? { repo: branchRepo, branch: branchArg } : autoStagingTarget;
|
|
214
256
|
let resolvedPrefix;
|
|
215
257
|
try {
|
|
216
258
|
resolvedPrefix = resolvePutPrefix({
|
|
217
259
|
destination: destFlag,
|
|
218
260
|
prefix: prefixFlag,
|
|
219
261
|
key: keyHint,
|
|
220
|
-
ghAttachment: Boolean(ghTarget) ||
|
|
262
|
+
ghAttachment: Boolean(ghTarget) || stagingTarget !== undefined,
|
|
221
263
|
});
|
|
222
264
|
}
|
|
223
265
|
catch (err) {
|
|
@@ -233,7 +275,6 @@ captureImpl = captureScreenshot) {
|
|
|
233
275
|
return raw;
|
|
234
276
|
throw new UsageError(`invalid --format: ${raw}`);
|
|
235
277
|
})();
|
|
236
|
-
const putDefaults = resolvePutDefaults({ envFile: ctx.envFile }, rawDefaults);
|
|
237
278
|
const optimizeOpts = optimizeOptionsFromFlags(parsed.flags, putDefaults);
|
|
238
279
|
const frameOpts = frameOptionsFromFlags(parsed.flags);
|
|
239
280
|
const altFlag = flagString(parsed.flags, "--alt");
|
|
@@ -248,9 +289,8 @@ captureImpl = captureScreenshot) {
|
|
|
248
289
|
metadata = { ...withFacts, ...ghMetadataFromTargetWithTitle(ghTarget, run) };
|
|
249
290
|
validateMetaMap(metadata);
|
|
250
291
|
}
|
|
251
|
-
else if (
|
|
252
|
-
metadata =
|
|
253
|
-
validateMetaMap(metadata);
|
|
292
|
+
else if (stagingTarget !== undefined) {
|
|
293
|
+
metadata = mergeStagingMeta(withFacts, stagingTarget);
|
|
254
294
|
}
|
|
255
295
|
else if (Object.keys(withFacts).length > 0) {
|
|
256
296
|
validateMetaMap(withFacts);
|
|
@@ -282,6 +322,8 @@ captureImpl = captureScreenshot) {
|
|
|
282
322
|
writeFileSync(outFile, captured.png);
|
|
283
323
|
if (logHuman)
|
|
284
324
|
process.stderr.write(`>> wrote ${outFile}\n`);
|
|
325
|
+
if (!noSidecar)
|
|
326
|
+
writeSidecarMeta(outFile, captured.png, withFacts);
|
|
285
327
|
}
|
|
286
328
|
if (noUpload) {
|
|
287
329
|
if (ctx.json) {
|
|
@@ -294,8 +336,8 @@ captureImpl = captureScreenshot) {
|
|
|
294
336
|
}
|
|
295
337
|
const repo = flagString(parsed.flags, "--repo") ?? putDefaults.repo;
|
|
296
338
|
const ref = flagString(parsed.flags, "--ref") ?? putDefaults.ref;
|
|
297
|
-
const branchKey =
|
|
298
|
-
? ghBranchAttachmentKey(
|
|
339
|
+
const branchKey = stagingTarget !== undefined
|
|
340
|
+
? ghBranchAttachmentKey(stagingTarget.repo, stagingTarget.branch, captured.filename)
|
|
299
341
|
: undefined;
|
|
300
342
|
const alt = altFlag ?? basename(captured.filename);
|
|
301
343
|
const { result, prepared, markdown } = await uploadPreparedImage(ctx.client, captured.png, captured.filename, {
|
|
@@ -306,13 +348,26 @@ captureImpl = captureScreenshot) {
|
|
|
306
348
|
prefix: resolvedPrefix ?? putDefaults.prefix,
|
|
307
349
|
repo,
|
|
308
350
|
ref,
|
|
309
|
-
deriveRepoFromGit: !
|
|
351
|
+
deriveRepoFromGit: !noGit,
|
|
310
352
|
dryRun,
|
|
311
353
|
metadata,
|
|
312
354
|
provenanceClient: "uploads-cli-screenshot",
|
|
313
355
|
alt: () => alt,
|
|
314
356
|
width,
|
|
315
357
|
});
|
|
358
|
+
// Staging note (issue #469 lever 1, mirrors #403's bare-put note): only for
|
|
359
|
+
// the auto-staged case — explicit `--branch` keeps its own "staged: these
|
|
360
|
+
// auto-attach..." wording below. Same suppression as put's note (--quiet,
|
|
361
|
+
// UPLOADS_NO_NUDGE=1).
|
|
362
|
+
const stagingNote = autoStagingTarget && !ctx.quiet && !putDefaults.noNudge
|
|
363
|
+
? putStagingNoteText(autoStagingTarget.branch)
|
|
364
|
+
: undefined;
|
|
365
|
+
// Stage-time binding warning (issue #398), same check bare put/attach
|
|
366
|
+
// --branch run, now also reachable from screenshot's staging paths
|
|
367
|
+
// (explicit --branch and auto-staging alike).
|
|
368
|
+
const bindingWarning = stagingTarget !== undefined
|
|
369
|
+
? await resolveStageBindingWarning({ ctx, defaults: putDefaults, repo: stagingTarget.repo })
|
|
370
|
+
: undefined;
|
|
316
371
|
let gallery;
|
|
317
372
|
if (galleryId) {
|
|
318
373
|
try {
|
|
@@ -347,8 +402,25 @@ captureImpl = captureScreenshot) {
|
|
|
347
402
|
if (prepared.optimized) {
|
|
348
403
|
process.stderr.write(`>> optimized ${prepared.originalBytes} → ${prepared.outputBytes} bytes\n`);
|
|
349
404
|
}
|
|
350
|
-
process.stderr.write(`>> key: ${result.key}${dryRun ? " (dry run — not uploaded)" : ""}\n
|
|
405
|
+
process.stderr.write(`>> key: ${result.key}${dryRun ? " (dry run — not uploaded)" : ""}\n`);
|
|
406
|
+
if (stagingTarget !== undefined) {
|
|
407
|
+
process.stderr.write(`>> find these later: uploads find gh.branch=${stagingTarget.branch.toLowerCase()}\n`);
|
|
408
|
+
if (autoStagingTarget) {
|
|
409
|
+
if (stagingNote)
|
|
410
|
+
process.stderr.write(`${stagingNote}\n`);
|
|
411
|
+
}
|
|
412
|
+
else {
|
|
413
|
+
process.stderr.write(`>> staged: these auto-attach to this branch's PR when it opens ` +
|
|
414
|
+
`(or run \`uploads attach --promote\` after opening)\n`);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
if (bindingWarning)
|
|
418
|
+
process.stderr.write(`${bindingWarning}\n`);
|
|
419
|
+
process.stderr.write("\n");
|
|
351
420
|
}
|
|
421
|
+
// One JSON `hint` slot (mirrors bare put): the binding warning is more
|
|
422
|
+
// actionable than the generic staging note, so it wins when both fire.
|
|
423
|
+
const jsonHint = bindingWarning ?? stagingNote;
|
|
352
424
|
switch (format) {
|
|
353
425
|
case "json":
|
|
354
426
|
await writeJson({
|
|
@@ -363,6 +435,7 @@ captureImpl = captureScreenshot) {
|
|
|
363
435
|
backend: captured.backend,
|
|
364
436
|
gallery,
|
|
365
437
|
...(dryRun ? { dryRun: true } : {}),
|
|
438
|
+
...(jsonHint ? { hint: jsonHint } : {}),
|
|
366
439
|
});
|
|
367
440
|
break;
|
|
368
441
|
case "url":
|
package/dist/commands/session.js
CHANGED
|
@@ -23,8 +23,9 @@ Examples:
|
|
|
23
23
|
`;
|
|
24
24
|
const LOGOUT_HELP = `uploads logout
|
|
25
25
|
|
|
26
|
-
Remove the saved UPLOADS_TOKEN
|
|
27
|
-
no longer signed in for the CLI. Does not
|
|
26
|
+
Remove the saved UPLOADS_TOKEN (and device session token) from the shared
|
|
27
|
+
config file so this machine is no longer signed in for the CLI. Does not
|
|
28
|
+
revoke tokens on the server.
|
|
28
29
|
|
|
29
30
|
Environment variables (UPLOADS_TOKEN) are not unset — export them yourself if set.
|
|
30
31
|
|
|
@@ -112,7 +113,7 @@ export async function runLogout(args, opts, help = false) {
|
|
|
112
113
|
const path = flagString(parsed.flags, "--path") ?? resolveConfigPath({ envFile: opts.envFile });
|
|
113
114
|
const hadFileToken = Boolean(loadConfigFile(path).UPLOADS_TOKEN);
|
|
114
115
|
const envTokenStillSet = Boolean(process.env.UPLOADS_TOKEN);
|
|
115
|
-
const result = removeConfigKeys(path, ["UPLOADS_TOKEN"]);
|
|
116
|
+
const result = removeConfigKeys(path, ["UPLOADS_TOKEN", "UPLOADS_SESSION_TOKEN"]);
|
|
116
117
|
const payload = {
|
|
117
118
|
path: result.path,
|
|
118
119
|
removed: result.removed,
|
|
@@ -124,8 +125,9 @@ export async function runLogout(args, opts, help = false) {
|
|
|
124
125
|
await writeJson(payload);
|
|
125
126
|
return 0;
|
|
126
127
|
}
|
|
127
|
-
if (result.removed.includes("UPLOADS_TOKEN")
|
|
128
|
-
|
|
128
|
+
if (result.removed.includes("UPLOADS_TOKEN") ||
|
|
129
|
+
result.removed.includes("UPLOADS_SESSION_TOKEN")) {
|
|
130
|
+
process.stdout.write(`signed out — removed credentials from ${result.path}\n`);
|
|
129
131
|
}
|
|
130
132
|
else if (!result.existed) {
|
|
131
133
|
process.stdout.write(`no config file at ${result.path} — already signed out\n`);
|
package/dist/commands.d.ts
CHANGED
|
@@ -167,6 +167,21 @@ export declare function commentViaSuffix(via: AttachmentsCommentResult["via"]):
|
|
|
167
167
|
export declare class GithubCommentAuthorizationError extends Error {
|
|
168
168
|
}
|
|
169
169
|
export declare function syncAttachmentsComment(client: UploadsClient, target: GhTarget, run: CommandRunner, workspace?: string): Promise<AttachmentsCommentResult>;
|
|
170
|
+
/**
|
|
171
|
+
* Lever 3 (issue #469): a nudge for when an image lands on a PR/issue with
|
|
172
|
+
* no `path` metadata — `path` is one of the highest-value queryable tags
|
|
173
|
+
* (same tier as `state=`), and unlike `uploads screenshot` (which derives it
|
|
174
|
+
* from the captured URL), a plain `attach`/`put --pr`/`put --issue` of an
|
|
175
|
+
* already-existing image has nothing to derive it from, so it's easy to
|
|
176
|
+
* forget. Fires once per batch (not per file) — checks the metadata the
|
|
177
|
+
* server actually stored (`PutResult.metadata`), not what was requested, so
|
|
178
|
+
* a merge/validation drop still surfaces the gap. Non-image uploads (zips,
|
|
179
|
+
* PDFs, etc.) are exempt — "findable by page" doesn't apply to them.
|
|
180
|
+
*/
|
|
181
|
+
export declare function pathMetaHintFor(uploads: {
|
|
182
|
+
contentType: string;
|
|
183
|
+
metadata?: Record<string, string>;
|
|
184
|
+
}[]): string | undefined;
|
|
170
185
|
export type AttachUploadItem = PutResult & {
|
|
171
186
|
file: string;
|
|
172
187
|
markdown: string;
|
|
@@ -355,6 +370,14 @@ export declare function resolvePutStagingTarget(opts: {
|
|
|
355
370
|
repoArg: string | undefined;
|
|
356
371
|
run: CommandRunner;
|
|
357
372
|
}): BranchTarget | undefined;
|
|
373
|
+
/**
|
|
374
|
+
* Merges a staging target's `gh.*` branch metadata over `base` and validates
|
|
375
|
+
* the result (same builder, same contract as `attach --branch`) — the one
|
|
376
|
+
* merge+validate step shared by every staging call site: `runPut`,
|
|
377
|
+
* `runScreenshot`, and both the local stdio MCP `put` and `screenshot`
|
|
378
|
+
* tools.
|
|
379
|
+
*/
|
|
380
|
+
export declare function mergeStagingMeta(base: Record<string, string> | undefined, target: BranchTarget): Record<string, string>;
|
|
358
381
|
/**
|
|
359
382
|
* The bare-put staging note's wording (issue #403): replaces the #393 nudge
|
|
360
383
|
* for the (now default) case where a bare put on a non-default branch stages
|