@bugbug-io/cli 14.21.0 → 14.23.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/AGENTS.md
CHANGED
|
@@ -24,7 +24,7 @@ packages/cli/
|
|
|
24
24
|
└── vitest.config.ts
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
-
Command domains under `src/features/`: `auth`, `init`, `install`, `profiles`,
|
|
27
|
+
Command domains under `src/features/`: `auth`, `files`, `init`, `install`, `profiles`,
|
|
28
28
|
`project`, `shorthands`, `suiteRuns`, `suites`, `tags`, `testRuns`, `tests`, `tui`.
|
|
29
29
|
|
|
30
30
|
## Architecture
|
package/README.md
CHANGED
|
@@ -94,6 +94,19 @@ bugbug project export -o out.zip # Export to a specific file
|
|
|
94
94
|
bugbug project import out.zip # Import a project from a ZIP archive
|
|
95
95
|
```
|
|
96
96
|
|
|
97
|
+
### Files
|
|
98
|
+
|
|
99
|
+
Manage the project Files library (files used by upload steps, max 10 MB each):
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
bugbug files list # List files (-q <text>, --folder <id>, --root, --ext pdf,png, --sort size --desc)
|
|
103
|
+
bugbug files upload ./invoice.pdf # Upload a file (--name <name>, --folder <id>)
|
|
104
|
+
bugbug files rename <fileId> "Invoice.pdf" # Rename a file
|
|
105
|
+
bugbug files move <fileId> --folder <id> # Move a file to a folder (or --root)
|
|
106
|
+
bugbug files download <fileId> -o out.pdf # Download a file
|
|
107
|
+
bugbug files delete <fileId> # Delete a file; upload steps using it lose their file
|
|
108
|
+
```
|
|
109
|
+
|
|
97
110
|
### Tests
|
|
98
111
|
|
|
99
112
|
```bash
|
|
@@ -63,7 +63,7 @@ import {
|
|
|
63
63
|
waitForSuiteRun,
|
|
64
64
|
waitForTestRun,
|
|
65
65
|
writeReportXml
|
|
66
|
-
} from "./chunk-
|
|
66
|
+
} from "./chunk-7A5MMA6E.js";
|
|
67
67
|
import "./chunk-XLIBEETK.js";
|
|
68
68
|
import "./chunk-3PJ4ZE2N.js";
|
|
69
69
|
import {
|
|
@@ -11128,5 +11128,5 @@ react-router/dist/development/index.mjs:
|
|
|
11128
11128
|
* @license MIT
|
|
11129
11129
|
*)
|
|
11130
11130
|
*/
|
|
11131
|
-
//# sourceMappingURL=NavigatorApp-
|
|
11131
|
+
//# sourceMappingURL=NavigatorApp-XA7Y3JQT.js.map
|
|
11132
11132
|
//# debugId=d5dac43b-3da2-532b-8e28-f4983f3e8003
|
|
@@ -12,7 +12,7 @@ var startNavigator = async (opts = {}) => {
|
|
|
12
12
|
const [{ render }, React, { NavigatorApp }] = await Promise.all([
|
|
13
13
|
import("./render-CSMURV5U.js"),
|
|
14
14
|
importReact(),
|
|
15
|
-
import("./NavigatorApp-
|
|
15
|
+
import("./NavigatorApp-XA7Y3JQT.js")
|
|
16
16
|
]);
|
|
17
17
|
const element = React.createElement(
|
|
18
18
|
NavigatorApp,
|
|
@@ -27,5 +27,5 @@ var startNavigator = async (opts = {}) => {
|
|
|
27
27
|
export {
|
|
28
28
|
startNavigator
|
|
29
29
|
};
|
|
30
|
-
//# sourceMappingURL=app-
|
|
30
|
+
//# sourceMappingURL=app-Z53CNV24.js.map
|
|
31
31
|
//# debugId=cecc8c80-302a-54e0-a1fb-74d6bb70c0a1
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="43cabc91-a3ee-589b-bcb7-031836276340")}catch(e){}}();
|
|
3
3
|
import { createRequire as __nodeCreateRequire } from 'node:module';
|
|
4
4
|
const require = __nodeCreateRequire(import.meta.url);
|
|
5
5
|
import {
|
|
@@ -8930,7 +8930,7 @@ var require_main = __commonJS({
|
|
|
8930
8930
|
// ../core/package.json
|
|
8931
8931
|
var package_default = {
|
|
8932
8932
|
name: "@bugbug-io/core",
|
|
8933
|
-
version: "14.
|
|
8933
|
+
version: "14.23.0",
|
|
8934
8934
|
private: true,
|
|
8935
8935
|
type: "module",
|
|
8936
8936
|
main: "dist/index.js",
|
|
@@ -57013,7 +57013,7 @@ var AuthModule = class {
|
|
|
57013
57013
|
}
|
|
57014
57014
|
}
|
|
57015
57015
|
);
|
|
57016
|
-
const authorizeUrl = response instanceof
|
|
57016
|
+
const authorizeUrl = response?.headers instanceof Headers ? response.headers.get("location") : void 0;
|
|
57017
57017
|
if (!authorizeUrl) {
|
|
57018
57018
|
throw new Error("BugBug OAuth authorize response did not include a redirect URL.");
|
|
57019
57019
|
}
|
|
@@ -57089,6 +57089,16 @@ var ComponentsModule = class {
|
|
|
57089
57089
|
pathParams: { id: componentId },
|
|
57090
57090
|
...options
|
|
57091
57091
|
});
|
|
57092
|
+
update = async (componentId, data, options = {}) => this.#client.put("/components/{id}/", {
|
|
57093
|
+
pathParams: { id: componentId },
|
|
57094
|
+
body: data,
|
|
57095
|
+
...options
|
|
57096
|
+
});
|
|
57097
|
+
partialUpdate = async (componentId, data, options = {}) => this.#client.patch("/components/{id}/", {
|
|
57098
|
+
pathParams: { id: componentId },
|
|
57099
|
+
body: data,
|
|
57100
|
+
...options
|
|
57101
|
+
});
|
|
57092
57102
|
};
|
|
57093
57103
|
var hoursAgo = (hours) => new Date(Date.now() - hours * 60 * 60 * 1e3).toISOString();
|
|
57094
57104
|
var now = () => (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -57177,6 +57187,170 @@ var ConfigModule = class {
|
|
|
57177
57187
|
};
|
|
57178
57188
|
};
|
|
57179
57189
|
};
|
|
57190
|
+
var FILES_PATH = "/projects/{project_pk}/files/";
|
|
57191
|
+
var FILE_PATH = "/projects/{project_pk}/files/{id}/";
|
|
57192
|
+
var FilesModule = class {
|
|
57193
|
+
#client;
|
|
57194
|
+
constructor(client) {
|
|
57195
|
+
this.#client = client;
|
|
57196
|
+
}
|
|
57197
|
+
/**
|
|
57198
|
+
* List files of a project. Returns a page of results; pass `page`/`pageSize` to paginate.
|
|
57199
|
+
*/
|
|
57200
|
+
list = async (options) => {
|
|
57201
|
+
const {
|
|
57202
|
+
projectId,
|
|
57203
|
+
query,
|
|
57204
|
+
folderId,
|
|
57205
|
+
recursive: recursive2,
|
|
57206
|
+
extensions,
|
|
57207
|
+
sortBy,
|
|
57208
|
+
descOrder,
|
|
57209
|
+
page,
|
|
57210
|
+
pageSize,
|
|
57211
|
+
...requestOptions
|
|
57212
|
+
} = options;
|
|
57213
|
+
return this.#client.get(FILES_PATH, {
|
|
57214
|
+
pathParams: { project_pk: projectId },
|
|
57215
|
+
queryParams: {
|
|
57216
|
+
query: query || void 0,
|
|
57217
|
+
folderId: folderId ?? void 0,
|
|
57218
|
+
noFolder: folderId === null ? true : void 0,
|
|
57219
|
+
recursive: folderId && recursive2 ? true : void 0,
|
|
57220
|
+
extension: extensions?.length ? extensions.join(",") : void 0,
|
|
57221
|
+
ordering: sortBy ? `${descOrder ? "-" : ""}${sortBy}` : void 0,
|
|
57222
|
+
page,
|
|
57223
|
+
page_size: pageSize
|
|
57224
|
+
},
|
|
57225
|
+
...requestOptions
|
|
57226
|
+
});
|
|
57227
|
+
};
|
|
57228
|
+
/**
|
|
57229
|
+
* Fetch a single file.
|
|
57230
|
+
*
|
|
57231
|
+
* @throws {NotFoundError} When no file matches `fileId`.
|
|
57232
|
+
*/
|
|
57233
|
+
get = async ({ projectId, fileId, ...options }) => this.#client.get(FILE_PATH, {
|
|
57234
|
+
pathParams: { project_pk: projectId, id: fileId },
|
|
57235
|
+
...options
|
|
57236
|
+
});
|
|
57237
|
+
/**
|
|
57238
|
+
* Upload a file to the project's Files library. Use the returned `id` as
|
|
57239
|
+
* `projectArtifactId` of an `uploadFile` step.
|
|
57240
|
+
*
|
|
57241
|
+
* @throws {ValidationError} When the file exceeds 10 MB or the folder is invalid.
|
|
57242
|
+
*/
|
|
57243
|
+
upload = async ({
|
|
57244
|
+
projectId,
|
|
57245
|
+
file: file2,
|
|
57246
|
+
fileName,
|
|
57247
|
+
contentType = "application/octet-stream",
|
|
57248
|
+
name,
|
|
57249
|
+
folderId,
|
|
57250
|
+
...options
|
|
57251
|
+
}) => {
|
|
57252
|
+
const form = new FormData();
|
|
57253
|
+
const blob = file2 instanceof Blob ? file2 : new Blob([file2], { type: contentType });
|
|
57254
|
+
form.append("file", blob, fileName);
|
|
57255
|
+
if (name) {
|
|
57256
|
+
form.append("name", name);
|
|
57257
|
+
}
|
|
57258
|
+
if (folderId) {
|
|
57259
|
+
form.append("folderId", folderId);
|
|
57260
|
+
}
|
|
57261
|
+
return this.#client.postForm(FILES_PATH, form, {
|
|
57262
|
+
...options,
|
|
57263
|
+
pathParams: { project_pk: projectId }
|
|
57264
|
+
});
|
|
57265
|
+
};
|
|
57266
|
+
/**
|
|
57267
|
+
* Rename a file and/or move it to another folder.
|
|
57268
|
+
*/
|
|
57269
|
+
update = async ({
|
|
57270
|
+
projectId,
|
|
57271
|
+
fileId,
|
|
57272
|
+
name,
|
|
57273
|
+
folderId,
|
|
57274
|
+
...options
|
|
57275
|
+
}) => this.#client.patch(FILE_PATH, {
|
|
57276
|
+
pathParams: { project_pk: projectId, id: fileId },
|
|
57277
|
+
body: {
|
|
57278
|
+
...name !== void 0 ? { name } : {},
|
|
57279
|
+
...folderId !== void 0 ? { folderId } : {}
|
|
57280
|
+
},
|
|
57281
|
+
...options
|
|
57282
|
+
});
|
|
57283
|
+
/**
|
|
57284
|
+
* Delete a file. `uploadFile` steps that use it are kept but lose their file.
|
|
57285
|
+
*/
|
|
57286
|
+
delete = async ({ projectId, fileId, ...options }) => {
|
|
57287
|
+
await this.#client.delete(FILE_PATH, {
|
|
57288
|
+
pathParams: { project_pk: projectId, id: fileId },
|
|
57289
|
+
...options
|
|
57290
|
+
});
|
|
57291
|
+
};
|
|
57292
|
+
/** Delete multiple files at once. */
|
|
57293
|
+
bulkDelete = async ({
|
|
57294
|
+
projectId,
|
|
57295
|
+
fileIds,
|
|
57296
|
+
...options
|
|
57297
|
+
}) => this.#client.post(`${FILES_PATH}bulk-delete/`, {
|
|
57298
|
+
pathParams: { project_pk: projectId },
|
|
57299
|
+
body: { fileIds },
|
|
57300
|
+
...options
|
|
57301
|
+
});
|
|
57302
|
+
/** Move multiple files to a folder (`null` moves them to the root). */
|
|
57303
|
+
move = async ({
|
|
57304
|
+
projectId,
|
|
57305
|
+
fileIds,
|
|
57306
|
+
folderId,
|
|
57307
|
+
...options
|
|
57308
|
+
}) => this.#client.post(`${FILES_PATH}bulk-move/`, {
|
|
57309
|
+
pathParams: { project_pk: projectId },
|
|
57310
|
+
body: { fileIds, folderId },
|
|
57311
|
+
...options
|
|
57312
|
+
});
|
|
57313
|
+
/** Return how many steps use the file and which tests contain them. */
|
|
57314
|
+
usage = async ({
|
|
57315
|
+
projectId,
|
|
57316
|
+
fileId,
|
|
57317
|
+
...options
|
|
57318
|
+
}) => this.#client.get(`${FILE_PATH}usage/`, {
|
|
57319
|
+
pathParams: { project_pk: projectId, id: fileId },
|
|
57320
|
+
...options
|
|
57321
|
+
});
|
|
57322
|
+
/** Download file content. */
|
|
57323
|
+
download = async ({
|
|
57324
|
+
projectId,
|
|
57325
|
+
fileId,
|
|
57326
|
+
...options
|
|
57327
|
+
}) => this.#client.getBinary(`${FILE_PATH}download/`, {
|
|
57328
|
+
pathParams: { project_pk: projectId, id: fileId },
|
|
57329
|
+
...options
|
|
57330
|
+
});
|
|
57331
|
+
/** List file extensions used in the project. */
|
|
57332
|
+
extensions = async ({
|
|
57333
|
+
projectId,
|
|
57334
|
+
...options
|
|
57335
|
+
}) => this.#client.get(`${FILES_PATH}extensions/`, {
|
|
57336
|
+
pathParams: { project_pk: projectId },
|
|
57337
|
+
...options
|
|
57338
|
+
});
|
|
57339
|
+
/** Return the nested folder tree of the Files library. */
|
|
57340
|
+
getFolderTree = async (options = {}) => this.#client.get("/folders/tree/", {
|
|
57341
|
+
queryParams: { kind: "file" },
|
|
57342
|
+
...options
|
|
57343
|
+
});
|
|
57344
|
+
/** Create a folder in the Files library. */
|
|
57345
|
+
createFolder = async ({
|
|
57346
|
+
name,
|
|
57347
|
+
parentId = null,
|
|
57348
|
+
...options
|
|
57349
|
+
}) => this.#client.post("/folders/", {
|
|
57350
|
+
body: { name, kind: "file", parentId },
|
|
57351
|
+
...options
|
|
57352
|
+
});
|
|
57353
|
+
};
|
|
57180
57354
|
var FoldersModule = class {
|
|
57181
57355
|
#client;
|
|
57182
57356
|
constructor(client) {
|
|
@@ -78334,8 +78508,8 @@ var TypeStepSchema = StepBaseSchema.extend({
|
|
|
78334
78508
|
value: external_exports.string().describe("Text to type.")
|
|
78335
78509
|
});
|
|
78336
78510
|
var UploadStepSchema = StepBaseSchema.extend({
|
|
78337
|
-
type: external_exports.literal("uploadFile").describe("Upload a project
|
|
78338
|
-
projectArtifactId: UuidSchema.describe("
|
|
78511
|
+
type: external_exports.literal("uploadFile").describe("Upload a file from the project Files library into the targeted file input."),
|
|
78512
|
+
projectArtifactId: UuidSchema.describe("ID of a file from the project Files library (max 10 MB). Reuse an existing file (`bugbug.files.list` in bugbug_execute) before uploading a new one (bugbug_files_upload).")
|
|
78339
78513
|
});
|
|
78340
78514
|
var GoBackStepSchema = StepBaseSchema.extend({
|
|
78341
78515
|
type: external_exports.literal("goBack").describe("Navigate the browser back in history.")
|
|
@@ -78569,6 +78743,8 @@ var TagUpdateSchema = external_exports.object({
|
|
|
78569
78743
|
color: TagColorSchema.optional()
|
|
78570
78744
|
}).refine((data) => data.name !== void 0 || data.color !== void 0, "Provide name, color, or both");
|
|
78571
78745
|
var TagNamesSchema = external_exports.array(TagNameSchema).max(64).describe("Complete desired list of direct tag names. Replaces existing direct assignments; [] clears them. Use up to 64 names. Missing names are created in the target project with the default color; create tags explicitly first to choose a color.");
|
|
78746
|
+
var FileIdSchema = UuidSchema.describe("File UUID (the project artifact ID).");
|
|
78747
|
+
var FileFolderIdSchema = UuidSchema.describe("UUID of a folder of kind `file`.");
|
|
78572
78748
|
var TagsModule = class {
|
|
78573
78749
|
#client;
|
|
78574
78750
|
constructor(client) {
|
|
@@ -78897,10 +79073,34 @@ var TestsModule = class {
|
|
|
78897
79073
|
...options
|
|
78898
79074
|
});
|
|
78899
79075
|
/**
|
|
78900
|
-
*
|
|
79076
|
+
* Remove a component and its steps from a test. The component and other tests are not changed.
|
|
78901
79077
|
*
|
|
78902
|
-
* @param testId - UUID of the test
|
|
78903
|
-
* @param data -
|
|
79078
|
+
* @param testId - UUID of the test.
|
|
79079
|
+
* @param data - `componentId`: the component instance ID in this test, or the component ID.
|
|
79080
|
+
*/
|
|
79081
|
+
removeComponent = async (testId, data, options = {}) => this.#client.post("/tests/{id}/remove-component/", {
|
|
79082
|
+
pathParams: { id: testId },
|
|
79083
|
+
body: data,
|
|
79084
|
+
...options
|
|
79085
|
+
});
|
|
79086
|
+
/**
|
|
79087
|
+
* Replace a component in a test with a plain group holding a copy of its steps.
|
|
79088
|
+
* The component and other tests are not changed.
|
|
79089
|
+
*
|
|
79090
|
+
* @param testId - UUID of the test.
|
|
79091
|
+
* @param data - `componentId`: the component instance ID in this test, or the component ID.
|
|
79092
|
+
*/
|
|
79093
|
+
detachComponent = async (testId, data, options = {}) => this.#client.post("/tests/{id}/detach-component/", {
|
|
79094
|
+
pathParams: { id: testId },
|
|
79095
|
+
body: data,
|
|
79096
|
+
...options
|
|
79097
|
+
});
|
|
79098
|
+
/**
|
|
79099
|
+
* Remove a component and its steps from a test.
|
|
79100
|
+
*
|
|
79101
|
+
* @deprecated Use {@link removeComponent}, or {@link detachComponent} to keep the steps.
|
|
79102
|
+
* @param testId - UUID of the test.
|
|
79103
|
+
* @param data - `groupId`: the component instance ID in this test.
|
|
78904
79104
|
*/
|
|
78905
79105
|
unlinkComponent = async (testId, data, options = {}) => this.#client.post("/tests/{id}/unlink-component/", {
|
|
78906
79106
|
pathParams: { id: testId },
|
|
@@ -79575,7 +79775,7 @@ var readEnvFiles2 = (cwd) => {
|
|
|
79575
79775
|
var buildUserAgent2 = (clientType, version2) => `BugBug ${clientType.toUpperCase()} ${version2}`;
|
|
79576
79776
|
var package_default2 = {
|
|
79577
79777
|
name: "@bugbug-io/core",
|
|
79578
|
-
version: "14.
|
|
79778
|
+
version: "14.23.0",
|
|
79579
79779
|
private: true,
|
|
79580
79780
|
type: "module",
|
|
79581
79781
|
main: "dist/index.js",
|
|
@@ -80856,6 +81056,7 @@ var BugBugSDK = class {
|
|
|
80856
81056
|
stepRuns;
|
|
80857
81057
|
project;
|
|
80858
81058
|
projectArtifacts;
|
|
81059
|
+
files;
|
|
80859
81060
|
projects;
|
|
80860
81061
|
variables;
|
|
80861
81062
|
visualRegression;
|
|
@@ -80877,6 +81078,7 @@ var BugBugSDK = class {
|
|
|
80877
81078
|
this.stepRuns = new StepRunsModule(this.#client);
|
|
80878
81079
|
this.project = new ProjectModule(this.#client);
|
|
80879
81080
|
this.projectArtifacts = new ProjectArtifactsModule(this.#client);
|
|
81081
|
+
this.files = new FilesModule(this.#client);
|
|
80880
81082
|
this.projects = new ProjectsModule(this.#client);
|
|
80881
81083
|
this.variables = new VariablesModule(this.#client);
|
|
80882
81084
|
this.visualRegression = new VisualRegressionModule(this.#client);
|
|
@@ -81782,5 +81984,5 @@ export {
|
|
|
81782
81984
|
formatErrorMessage,
|
|
81783
81985
|
showError
|
|
81784
81986
|
};
|
|
81785
|
-
//# sourceMappingURL=chunk-
|
|
81786
|
-
//# debugId=
|
|
81987
|
+
//# sourceMappingURL=chunk-7A5MMA6E.js.map
|
|
81988
|
+
//# debugId=43cabc91-a3ee-589b-bcb7-031836276340
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
3
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="1e3decec-3b63-5d56-87b7-c4616c30892b")}catch(e){}}();
|
|
4
4
|
import { createRequire as __nodeCreateRequire } from 'node:module';
|
|
5
5
|
const require = __nodeCreateRequire(import.meta.url);
|
|
6
6
|
import {
|
|
@@ -67,11 +67,12 @@ import {
|
|
|
67
67
|
startSentrySpan,
|
|
68
68
|
stopSuiteRun,
|
|
69
69
|
stopTestRun,
|
|
70
|
+
userCwd,
|
|
70
71
|
validateReporterOptions,
|
|
71
72
|
waitForSuiteRun,
|
|
72
73
|
waitForTestRun,
|
|
73
74
|
writeReportXml
|
|
74
|
-
} from "./chunk-
|
|
75
|
+
} from "./chunk-7A5MMA6E.js";
|
|
75
76
|
import "./chunk-XLIBEETK.js";
|
|
76
77
|
import "./chunk-3PJ4ZE2N.js";
|
|
77
78
|
import {
|
|
@@ -3158,6 +3159,241 @@ var registerAuthCommands = (program3) => {
|
|
|
3158
3159
|
registerLogoutCommand(program3);
|
|
3159
3160
|
};
|
|
3160
3161
|
|
|
3162
|
+
// src/utils/render.ts
|
|
3163
|
+
var renderOutput = async (mode, value, formatters) => {
|
|
3164
|
+
if (mode === "json") {
|
|
3165
|
+
printJson(formatters.toJson(value));
|
|
3166
|
+
return;
|
|
3167
|
+
}
|
|
3168
|
+
process.stdout.write(`${formatters.toPlain(value)}
|
|
3169
|
+
`);
|
|
3170
|
+
};
|
|
3171
|
+
|
|
3172
|
+
// src/utils/toolbox.ts
|
|
3173
|
+
var padRight = (value, width) => {
|
|
3174
|
+
if (value.length >= width) return value;
|
|
3175
|
+
return value + " ".repeat(width - value.length);
|
|
3176
|
+
};
|
|
3177
|
+
var capitalize = (value) => value.charAt(0).toUpperCase() + value.slice(1);
|
|
3178
|
+
|
|
3179
|
+
// src/utils/table.ts
|
|
3180
|
+
var renderTable = (rows, columns, options = {}) => {
|
|
3181
|
+
if (rows.length === 0) {
|
|
3182
|
+
return options.emptyMessage ?? "No results.";
|
|
3183
|
+
}
|
|
3184
|
+
const cells = rows.map((row) => columns.map((col) => col.get(row) ?? ""));
|
|
3185
|
+
const widths = columns.map((col, i) => {
|
|
3186
|
+
const dataMax = cells.reduce((max, row) => Math.max(max, row[i]?.length ?? 0), 0);
|
|
3187
|
+
const headerMax = col.header.length;
|
|
3188
|
+
return Math.max(col.width ?? 0, headerMax, dataMax);
|
|
3189
|
+
});
|
|
3190
|
+
const formatRow = (values) => values.map((value, i) => padRight(value, widths[i])).join(" ").trimEnd();
|
|
3191
|
+
const lines = [];
|
|
3192
|
+
lines.push(formatRow(columns.map((c) => c.header.toUpperCase())));
|
|
3193
|
+
lines.push(formatRow(widths.map((w) => "\u2500".repeat(w))));
|
|
3194
|
+
for (const row of cells) {
|
|
3195
|
+
lines.push(formatRow(row));
|
|
3196
|
+
}
|
|
3197
|
+
return lines.join("\n");
|
|
3198
|
+
};
|
|
3199
|
+
|
|
3200
|
+
// src/features/files/files.formatters.tsx
|
|
3201
|
+
var formatFileSize = (size) => {
|
|
3202
|
+
if (size === null || size === void 0) {
|
|
3203
|
+
return "";
|
|
3204
|
+
}
|
|
3205
|
+
if (size < 1024) {
|
|
3206
|
+
return `${size} B`;
|
|
3207
|
+
}
|
|
3208
|
+
if (size < 1024 * 1024) {
|
|
3209
|
+
return `${(size / 1024).toFixed(1)} KB`;
|
|
3210
|
+
}
|
|
3211
|
+
return `${(size / (1024 * 1024)).toFixed(1)} MB`;
|
|
3212
|
+
};
|
|
3213
|
+
var filesListOutputFormatters = {
|
|
3214
|
+
toPlain(response) {
|
|
3215
|
+
const table = renderTable(
|
|
3216
|
+
response.results,
|
|
3217
|
+
[
|
|
3218
|
+
{ header: "Id", get: (file) => file.id },
|
|
3219
|
+
{ header: "Name", get: (file) => file.name },
|
|
3220
|
+
{ header: "Extension", get: (file) => file.extension },
|
|
3221
|
+
{ header: "Size", get: (file) => formatFileSize(file.size) },
|
|
3222
|
+
{ header: "Created", get: (file) => file.created }
|
|
3223
|
+
],
|
|
3224
|
+
{ emptyMessage: "No files found." }
|
|
3225
|
+
);
|
|
3226
|
+
return `${table}
|
|
3227
|
+
Total: ${response.count}`;
|
|
3228
|
+
},
|
|
3229
|
+
toJson(response) {
|
|
3230
|
+
return response;
|
|
3231
|
+
}
|
|
3232
|
+
};
|
|
3233
|
+
|
|
3234
|
+
// src/features/files/files.service.ts
|
|
3235
|
+
import { readFileSync, statSync, writeFileSync } from "fs";
|
|
3236
|
+
import { basename, resolve } from "path";
|
|
3237
|
+
var MAX_FILE_SIZE_BYTES = 10 * 1024 * 1024;
|
|
3238
|
+
var resolveProjectId = async () => {
|
|
3239
|
+
const { projectId } = getCliConfig();
|
|
3240
|
+
if (projectId?.trim()) {
|
|
3241
|
+
return projectId.trim();
|
|
3242
|
+
}
|
|
3243
|
+
const projects = await getSdk().projects.list({ pageSize: 2 });
|
|
3244
|
+
if (projects.results.length === 1 && projects.results[0]) {
|
|
3245
|
+
return projects.results[0].id;
|
|
3246
|
+
}
|
|
3247
|
+
throw new Error("Cannot determine the project. Pass --project-id or use a project API token.");
|
|
3248
|
+
};
|
|
3249
|
+
var listFiles = async (params) => getSdk().files.list({ projectId: await resolveProjectId(), ...params });
|
|
3250
|
+
var uploadFile = async (path, options = {}) => {
|
|
3251
|
+
const filePath = resolve(userCwd(), path);
|
|
3252
|
+
const { size } = statSync(filePath);
|
|
3253
|
+
if (size > MAX_FILE_SIZE_BYTES) {
|
|
3254
|
+
throw new Error(`File is too large (${size} bytes). The maximum file size is 10 MB.`);
|
|
3255
|
+
}
|
|
3256
|
+
return getSdk().files.upload({
|
|
3257
|
+
projectId: await resolveProjectId(),
|
|
3258
|
+
file: new Uint8Array(readFileSync(filePath)),
|
|
3259
|
+
fileName: basename(filePath),
|
|
3260
|
+
name: options.name,
|
|
3261
|
+
folderId: options.folderId
|
|
3262
|
+
});
|
|
3263
|
+
};
|
|
3264
|
+
var updateFile = async (fileId, changes) => getSdk().files.update({ projectId: await resolveProjectId(), fileId, ...changes });
|
|
3265
|
+
var deleteFile = async (fileId) => getSdk().files.delete({ projectId: await resolveProjectId(), fileId });
|
|
3266
|
+
var downloadFile = async (fileId, output) => {
|
|
3267
|
+
const projectId = await resolveProjectId();
|
|
3268
|
+
const sdk = getSdk();
|
|
3269
|
+
const outPath = resolve(
|
|
3270
|
+
userCwd(),
|
|
3271
|
+
output ?? basename((await sdk.files.get({ projectId, fileId })).name)
|
|
3272
|
+
);
|
|
3273
|
+
const bytes = await sdk.files.download({ projectId, fileId });
|
|
3274
|
+
writeFileSync(outPath, bytes);
|
|
3275
|
+
return { outPath, size: bytes.byteLength };
|
|
3276
|
+
};
|
|
3277
|
+
|
|
3278
|
+
// src/features/files/files.command.ts
|
|
3279
|
+
var SORT_FIELDS = ["name", "extension", "size", "created"];
|
|
3280
|
+
var handleError = (mode, err) => {
|
|
3281
|
+
emitError(mode, { error: err instanceof Error ? err.message : String(err) });
|
|
3282
|
+
exitWith(EXIT_GENERAL_ERROR);
|
|
3283
|
+
};
|
|
3284
|
+
var parseSortField = (sort) => {
|
|
3285
|
+
if (!sort) {
|
|
3286
|
+
return void 0;
|
|
3287
|
+
}
|
|
3288
|
+
if (!SORT_FIELDS.includes(sort)) {
|
|
3289
|
+
throw new Error(`Invalid --sort value "${sort}". Use one of: ${SORT_FIELDS.join(", ")}.`);
|
|
3290
|
+
}
|
|
3291
|
+
return sort;
|
|
3292
|
+
};
|
|
3293
|
+
var registerFilesListCommand = (parent, commandName = "list") => parent.command(commandName).description("List files from the project Files library").option("-q, --query <text>", "Filter by file name").option("--folder <folderId>", "Only files in this folder").option("--root", "Only files in the root (without a folder)").option("--recursive", "With --folder, include files from nested folders").option("--ext <extensions>", "Comma-separated extensions, e.g. pdf,png").option("--sort <field>", `Sort by: ${SORT_FIELDS.join(", ")}`).option("--desc", "Sort in descending order").option("--page <number>", "Page number", "1").option("--page-size <number>", "Files per page (max 100)", "50").action(async function(opts) {
|
|
3294
|
+
const mode = resolveOutputMode();
|
|
3295
|
+
try {
|
|
3296
|
+
const data = await listFiles({
|
|
3297
|
+
query: opts.query,
|
|
3298
|
+
folderId: opts.root ? null : opts.folder,
|
|
3299
|
+
recursive: opts.recursive,
|
|
3300
|
+
extensions: opts.ext?.split(",").map((ext) => ext.trim()).filter(Boolean),
|
|
3301
|
+
sortBy: parseSortField(opts.sort),
|
|
3302
|
+
descOrder: opts.desc,
|
|
3303
|
+
page: Number(opts.page),
|
|
3304
|
+
pageSize: Number(opts.pageSize)
|
|
3305
|
+
});
|
|
3306
|
+
await renderOutput(mode, data, filesListOutputFormatters);
|
|
3307
|
+
} catch (err) {
|
|
3308
|
+
handleError(mode, err);
|
|
3309
|
+
}
|
|
3310
|
+
});
|
|
3311
|
+
var registerFilesUploadCommand = (parent, commandName = "upload") => parent.command(`${commandName} <path>`).description("Upload a file (max 10 MB) to the project Files library").option("--name <name>", "Display name (defaults to the file name)").option("--folder <folderId>", "Folder to upload into").action(async function(path, opts) {
|
|
3312
|
+
const mode = resolveOutputMode();
|
|
3313
|
+
try {
|
|
3314
|
+
const file = await uploadFile(path, { name: opts.name, folderId: opts.folder });
|
|
3315
|
+
if (mode === "json") {
|
|
3316
|
+
printJson(file);
|
|
3317
|
+
} else {
|
|
3318
|
+
process.stdout.write(
|
|
3319
|
+
`Uploaded ${file.name} (${formatFileSize(file.size)}). File id: ${file.id}
|
|
3320
|
+
`
|
|
3321
|
+
);
|
|
3322
|
+
}
|
|
3323
|
+
} catch (err) {
|
|
3324
|
+
handleError(mode, err);
|
|
3325
|
+
}
|
|
3326
|
+
});
|
|
3327
|
+
var registerFilesRenameCommand = (parent, commandName = "rename") => parent.command(`${commandName} <fileId> <name>`).description("Rename a file").action(async function(fileId, name) {
|
|
3328
|
+
const mode = resolveOutputMode();
|
|
3329
|
+
try {
|
|
3330
|
+
const file = await updateFile(fileId, { name });
|
|
3331
|
+
if (mode === "json") {
|
|
3332
|
+
printJson(file);
|
|
3333
|
+
} else {
|
|
3334
|
+
process.stdout.write(`Renamed file ${file.id} to ${file.name}
|
|
3335
|
+
`);
|
|
3336
|
+
}
|
|
3337
|
+
} catch (err) {
|
|
3338
|
+
handleError(mode, err);
|
|
3339
|
+
}
|
|
3340
|
+
});
|
|
3341
|
+
var registerFilesMoveCommand = (parent, commandName = "move") => parent.command(`${commandName} <fileId>`).description("Move a file to a folder, or to the root with --root").option("--folder <folderId>", "Target folder").option("--root", "Move the file to the root").action(async function(fileId, opts) {
|
|
3342
|
+
const mode = resolveOutputMode();
|
|
3343
|
+
try {
|
|
3344
|
+
if (!opts.root && !opts.folder) {
|
|
3345
|
+
throw new Error("Pass --folder <folderId> or --root.");
|
|
3346
|
+
}
|
|
3347
|
+
const file = await updateFile(fileId, { folderId: opts.root ? null : opts.folder });
|
|
3348
|
+
if (mode === "json") {
|
|
3349
|
+
printJson(file);
|
|
3350
|
+
} else {
|
|
3351
|
+
process.stdout.write(`Moved file ${file.name} to ${file.folderId ?? "the root"}
|
|
3352
|
+
`);
|
|
3353
|
+
}
|
|
3354
|
+
} catch (err) {
|
|
3355
|
+
handleError(mode, err);
|
|
3356
|
+
}
|
|
3357
|
+
});
|
|
3358
|
+
var registerFilesDeleteCommand = (parent, commandName = "delete") => parent.command(`${commandName} <fileId>`).description("Delete a file. Upload steps that use it will lose their file.").action(async function(fileId) {
|
|
3359
|
+
const mode = resolveOutputMode();
|
|
3360
|
+
try {
|
|
3361
|
+
await deleteFile(fileId);
|
|
3362
|
+
if (mode === "json") {
|
|
3363
|
+
printJson({ id: fileId, deleted: true });
|
|
3364
|
+
} else {
|
|
3365
|
+
process.stdout.write(`Deleted file ${fileId}
|
|
3366
|
+
`);
|
|
3367
|
+
}
|
|
3368
|
+
} catch (err) {
|
|
3369
|
+
handleError(mode, err);
|
|
3370
|
+
}
|
|
3371
|
+
});
|
|
3372
|
+
var registerFilesDownloadCommand = (parent, commandName = "download") => parent.command(`${commandName} <fileId>`).description("Download a file").option("-o, --output <file>", "Output file path (defaults to the file name)").action(async function(fileId, opts) {
|
|
3373
|
+
const mode = resolveOutputMode();
|
|
3374
|
+
try {
|
|
3375
|
+
const result = await downloadFile(fileId, opts.output);
|
|
3376
|
+
if (mode === "json") {
|
|
3377
|
+
printJson(result);
|
|
3378
|
+
} else {
|
|
3379
|
+
process.stdout.write(`Downloaded file to ${result.outPath} (${result.size} bytes)
|
|
3380
|
+
`);
|
|
3381
|
+
}
|
|
3382
|
+
} catch (err) {
|
|
3383
|
+
handleError(mode, err);
|
|
3384
|
+
}
|
|
3385
|
+
});
|
|
3386
|
+
var registerFilesCommand = (program3) => {
|
|
3387
|
+
const files = program3.command("files").description("Project Files library commands");
|
|
3388
|
+
registerFilesListCommand(files, "list");
|
|
3389
|
+
registerFilesUploadCommand(files, "upload");
|
|
3390
|
+
registerFilesRenameCommand(files, "rename");
|
|
3391
|
+
registerFilesMoveCommand(files, "move");
|
|
3392
|
+
registerFilesDeleteCommand(files, "delete");
|
|
3393
|
+
registerFilesDownloadCommand(files, "download");
|
|
3394
|
+
return files;
|
|
3395
|
+
};
|
|
3396
|
+
|
|
3161
3397
|
// src/features/install/install.service.ts
|
|
3162
3398
|
import { homedir } from "os";
|
|
3163
3399
|
|
|
@@ -3165,13 +3401,13 @@ import { homedir } from "os";
|
|
|
3165
3401
|
import { join } from "path";
|
|
3166
3402
|
|
|
3167
3403
|
// ../core/dist/install/jsonConfig.js
|
|
3168
|
-
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
3404
|
+
import { existsSync, mkdirSync, readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "fs";
|
|
3169
3405
|
import { dirname } from "path";
|
|
3170
3406
|
var readJsonObject = (path) => {
|
|
3171
3407
|
if (!existsSync(path))
|
|
3172
3408
|
return {};
|
|
3173
3409
|
try {
|
|
3174
|
-
const parsed = JSON.parse(
|
|
3410
|
+
const parsed = JSON.parse(readFileSync2(path, "utf8"));
|
|
3175
3411
|
return parsed && typeof parsed === "object" ? parsed : {};
|
|
3176
3412
|
} catch {
|
|
3177
3413
|
return {};
|
|
@@ -3493,44 +3729,6 @@ var registerInstallCommands = (program3) => {
|
|
|
3493
3729
|
registerMcpAlias(program3);
|
|
3494
3730
|
};
|
|
3495
3731
|
|
|
3496
|
-
// src/utils/render.ts
|
|
3497
|
-
var renderOutput = async (mode, value, formatters) => {
|
|
3498
|
-
if (mode === "json") {
|
|
3499
|
-
printJson(formatters.toJson(value));
|
|
3500
|
-
return;
|
|
3501
|
-
}
|
|
3502
|
-
process.stdout.write(`${formatters.toPlain(value)}
|
|
3503
|
-
`);
|
|
3504
|
-
};
|
|
3505
|
-
|
|
3506
|
-
// src/utils/toolbox.ts
|
|
3507
|
-
var padRight = (value, width) => {
|
|
3508
|
-
if (value.length >= width) return value;
|
|
3509
|
-
return value + " ".repeat(width - value.length);
|
|
3510
|
-
};
|
|
3511
|
-
var capitalize = (value) => value.charAt(0).toUpperCase() + value.slice(1);
|
|
3512
|
-
|
|
3513
|
-
// src/utils/table.ts
|
|
3514
|
-
var renderTable = (rows, columns, options = {}) => {
|
|
3515
|
-
if (rows.length === 0) {
|
|
3516
|
-
return options.emptyMessage ?? "No results.";
|
|
3517
|
-
}
|
|
3518
|
-
const cells = rows.map((row) => columns.map((col) => col.get(row) ?? ""));
|
|
3519
|
-
const widths = columns.map((col, i) => {
|
|
3520
|
-
const dataMax = cells.reduce((max, row) => Math.max(max, row[i]?.length ?? 0), 0);
|
|
3521
|
-
const headerMax = col.header.length;
|
|
3522
|
-
return Math.max(col.width ?? 0, headerMax, dataMax);
|
|
3523
|
-
});
|
|
3524
|
-
const formatRow = (values) => values.map((value, i) => padRight(value, widths[i])).join(" ").trimEnd();
|
|
3525
|
-
const lines = [];
|
|
3526
|
-
lines.push(formatRow(columns.map((c) => c.header.toUpperCase())));
|
|
3527
|
-
lines.push(formatRow(widths.map((w) => "\u2500".repeat(w))));
|
|
3528
|
-
for (const row of cells) {
|
|
3529
|
-
lines.push(formatRow(row));
|
|
3530
|
-
}
|
|
3531
|
-
return lines.join("\n");
|
|
3532
|
-
};
|
|
3533
|
-
|
|
3534
3732
|
// src/features/profiles/profiles.formatters.tsx
|
|
3535
3733
|
var profilesListOutputFormatters = {
|
|
3536
3734
|
toPlain(profiles) {
|
|
@@ -4572,6 +4770,7 @@ registerSuiteRunsCommand(program2);
|
|
|
4572
4770
|
registerTagsCommand(program2);
|
|
4573
4771
|
registerProfilesCommand(program2);
|
|
4574
4772
|
registerProjectCommand(program2);
|
|
4773
|
+
registerFilesCommand(program2);
|
|
4575
4774
|
registerAuthCommands(program2);
|
|
4576
4775
|
registerInstallCommands(program2);
|
|
4577
4776
|
registerShorthandCommands(program2);
|
|
@@ -4586,7 +4785,7 @@ program2.exitOverride();
|
|
|
4586
4785
|
});
|
|
4587
4786
|
analytics.trackEvent("cli_session_started");
|
|
4588
4787
|
if (startupMode.type === "commandline" && await shouldRedirectUnauthenticatedCommandToInit(process.argv, hasUsableSession)) {
|
|
4589
|
-
const { startNavigator } = await import("./app-
|
|
4788
|
+
const { startNavigator } = await import("./app-Z53CNV24.js");
|
|
4590
4789
|
await startNavigator({
|
|
4591
4790
|
initialRoute: "/init",
|
|
4592
4791
|
initialRouteState: {
|
|
@@ -4598,7 +4797,7 @@ program2.exitOverride();
|
|
|
4598
4797
|
return;
|
|
4599
4798
|
}
|
|
4600
4799
|
if (startupMode.type === "navigator") {
|
|
4601
|
-
const { startNavigator } = await import("./app-
|
|
4800
|
+
const { startNavigator } = await import("./app-Z53CNV24.js");
|
|
4602
4801
|
await startNavigator({
|
|
4603
4802
|
initialRoute: startupMode.route,
|
|
4604
4803
|
token: config.token,
|
|
@@ -4635,4 +4834,4 @@ program2.exitOverride();
|
|
|
4635
4834
|
}
|
|
4636
4835
|
})();
|
|
4637
4836
|
//# sourceMappingURL=index.js.map
|
|
4638
|
-
//# debugId=
|
|
4837
|
+
//# debugId=1e3decec-3b63-5d56-87b7-c4616c30892b
|