@gadgetinc/ggt 0.1.18 → 0.2.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/README.md +6 -6
- package/bin/dev.js +24 -0
- package/bin/run.js +11 -0
- package/lib/__generated__/graphql.js +6 -9
- package/lib/__generated__/graphql.js.map +1 -1
- package/lib/commands/help.js +21 -36
- package/lib/commands/help.js.map +1 -1
- package/lib/commands/list.js +29 -55
- package/lib/commands/list.js.map +1 -1
- package/lib/commands/login.js +13 -29
- package/lib/commands/login.js.map +1 -1
- package/lib/commands/logout.js +17 -34
- package/lib/commands/logout.js.map +1 -1
- package/lib/commands/sync.js +501 -463
- package/lib/commands/sync.js.map +1 -1
- package/lib/commands/whoami.js +17 -34
- package/lib/commands/whoami.js.map +1 -1
- package/lib/index.js +2 -5
- package/lib/index.js.map +1 -1
- package/lib/utils/base-command.js +105 -146
- package/lib/utils/base-command.js.map +1 -1
- package/lib/utils/client.js +104 -113
- package/lib/utils/client.js.map +1 -1
- package/lib/utils/context.js +63 -119
- package/lib/utils/context.js.map +1 -1
- package/lib/utils/errors.js +161 -242
- package/lib/utils/errors.js.map +1 -1
- package/lib/utils/flags.js +23 -26
- package/lib/utils/flags.js.map +1 -1
- package/lib/utils/fs-utils.js +50 -73
- package/lib/utils/fs-utils.js.map +1 -1
- package/lib/utils/help.js +19 -26
- package/lib/utils/help.js.map +1 -1
- package/lib/utils/promise.js +32 -78
- package/lib/utils/promise.js.map +1 -1
- package/lib/utils/sleep.js +6 -11
- package/lib/utils/sleep.js.map +1 -1
- package/npm-shrinkwrap.json +7848 -7077
- package/oclif.manifest.json +1 -21
- package/package.json +49 -49
- package/bin/dev +0 -20
- package/bin/run +0 -7
- package/lib/__generated__/graphql.d.ts +0 -294
- package/lib/commands/help.d.ts +0 -14
- package/lib/commands/list.d.ts +0 -18
- package/lib/commands/login.d.ts +0 -7
- package/lib/commands/logout.d.ts +0 -7
- package/lib/commands/sync.d.ts +0 -146
- package/lib/commands/whoami.d.ts +0 -7
- package/lib/index.d.ts +0 -1
- package/lib/utils/base-command.d.ts +0 -64
- package/lib/utils/client.d.ts +0 -42
- package/lib/utils/context.d.ts +0 -57
- package/lib/utils/errors.d.ts +0 -100
- package/lib/utils/flags.d.ts +0 -1
- package/lib/utils/fs-utils.d.ts +0 -21
- package/lib/utils/help.d.ts +0 -19
- package/lib/utils/promise.d.ts +0 -35
- package/lib/utils/sleep.d.ts +0 -5
package/lib/utils/errors.js
CHANGED
|
@@ -1,117 +1,75 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const crypto_1 = require("crypto");
|
|
1
|
+
import { _ as _class_private_field_get } from "@swc/helpers/_/_class_private_field_get";
|
|
2
|
+
import { _ as _class_private_field_init } from "@swc/helpers/_/_class_private_field_init";
|
|
3
|
+
import { _ as _class_private_field_set } from "@swc/helpers/_/_class_private_field_set";
|
|
4
|
+
import { _ as _define_property } from "@swc/helpers/_/_define_property";
|
|
5
|
+
import cleanStack from "clean-stack";
|
|
6
|
+
import { HTTPError } from "got";
|
|
7
|
+
import _ from "lodash";
|
|
8
|
+
import { serializeError as baseSerializeError } from "serialize-error";
|
|
9
|
+
import { dedent } from "ts-dedent";
|
|
10
|
+
import { inspect } from "util";
|
|
11
|
+
import { context } from "./context.js";
|
|
12
|
+
import os from "os";
|
|
13
|
+
import * as Sentry from "@sentry/node";
|
|
14
|
+
import { randomUUID } from "crypto";
|
|
16
15
|
/**
|
|
17
16
|
* Base class for all errors.
|
|
18
17
|
*
|
|
19
18
|
* Inspired by gadget's GadgetError and oclif's PrettyPrintableError.
|
|
20
|
-
*/
|
|
21
|
-
class BaseError extends Error {
|
|
22
|
-
constructor(code, message) {
|
|
23
|
-
super(message);
|
|
24
|
-
/**
|
|
25
|
-
* A GGT_CLI_SOMETHING human/machine readable unique identifier for this error.
|
|
26
|
-
*/
|
|
27
|
-
Object.defineProperty(this, "code", {
|
|
28
|
-
enumerable: true,
|
|
29
|
-
configurable: true,
|
|
30
|
-
writable: true,
|
|
31
|
-
value: void 0
|
|
32
|
-
});
|
|
33
|
-
/**
|
|
34
|
-
* The Sentry event ID for this error.
|
|
35
|
-
*/
|
|
36
|
-
Object.defineProperty(this, "sentryEventId", {
|
|
37
|
-
enumerable: true,
|
|
38
|
-
configurable: true,
|
|
39
|
-
writable: true,
|
|
40
|
-
value: context_1.context.env.testLike ? "00000000-0000-0000-0000-000000000000" : (0, crypto_1.randomUUID)()
|
|
41
|
-
});
|
|
42
|
-
/**
|
|
43
|
-
* The underlying *thing* that caused this error.
|
|
44
|
-
*/
|
|
45
|
-
Object.defineProperty(this, "cause", {
|
|
46
|
-
enumerable: true,
|
|
47
|
-
configurable: true,
|
|
48
|
-
writable: true,
|
|
49
|
-
value: void 0
|
|
50
|
-
});
|
|
51
|
-
/**
|
|
52
|
-
* Assume the stack trace exists.
|
|
53
|
-
*/
|
|
54
|
-
Object.defineProperty(this, "stack", {
|
|
55
|
-
enumerable: true,
|
|
56
|
-
configurable: true,
|
|
57
|
-
writable: true,
|
|
58
|
-
value: void 0
|
|
59
|
-
});
|
|
60
|
-
this.code = code;
|
|
61
|
-
Error.captureStackTrace(this, this.constructor);
|
|
62
|
-
}
|
|
19
|
+
*/ export class BaseError extends Error {
|
|
63
20
|
async capture() {
|
|
64
|
-
if (this.isBug == IsBug.NO)
|
|
65
|
-
|
|
66
|
-
const user = await context_1.context.getUser().catch(lodash_1.noop);
|
|
21
|
+
if (this.isBug == IsBug.NO) return;
|
|
22
|
+
const user = await context.getUser().catch(_.noop.bind(_));
|
|
67
23
|
Sentry.getCurrentHub().captureException(this, {
|
|
68
24
|
event_id: this.sentryEventId,
|
|
69
25
|
captureContext: {
|
|
70
|
-
user: user ? {
|
|
26
|
+
user: user ? {
|
|
27
|
+
id: String(user.id),
|
|
28
|
+
email: user.email,
|
|
29
|
+
username: user.name
|
|
30
|
+
} : undefined,
|
|
71
31
|
tags: {
|
|
72
|
-
applicationId:
|
|
73
|
-
arch:
|
|
32
|
+
applicationId: context.app?.id,
|
|
33
|
+
arch: context.config.arch,
|
|
74
34
|
isBug: this.isBug,
|
|
75
35
|
code: this.code,
|
|
76
|
-
environment:
|
|
77
|
-
platform:
|
|
78
|
-
shell:
|
|
79
|
-
version:
|
|
36
|
+
environment: context.env.value,
|
|
37
|
+
platform: context.config.platform,
|
|
38
|
+
shell: context.config.shell,
|
|
39
|
+
version: context.config.version
|
|
80
40
|
},
|
|
81
41
|
contexts: {
|
|
82
42
|
cause: this.cause ? serializeError(this.cause) : undefined,
|
|
83
43
|
app: {
|
|
84
|
-
command: `${
|
|
85
|
-
argv: process.argv
|
|
44
|
+
command: `${context.config.bin} ${process.argv.slice(2).join(" ")}`,
|
|
45
|
+
argv: process.argv
|
|
86
46
|
},
|
|
87
47
|
device: {
|
|
88
|
-
name:
|
|
89
|
-
family:
|
|
90
|
-
arch:
|
|
48
|
+
name: os.hostname(),
|
|
49
|
+
family: os.type(),
|
|
50
|
+
arch: os.arch()
|
|
91
51
|
},
|
|
92
52
|
runtime: {
|
|
93
53
|
name: process.release.name,
|
|
94
|
-
version: process.version
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
54
|
+
version: process.version
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
98
58
|
});
|
|
99
59
|
await Sentry.flush(2000);
|
|
100
60
|
}
|
|
101
61
|
/**
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
const rendered = (0, ts_dedent_1.default) `
|
|
62
|
+
* Turns this error into a user-friendly message that explains what went wrong and how to fix it. A good write up of what an error should
|
|
63
|
+
* look like can be found here: {@link https://clig.dev/#errors}
|
|
64
|
+
*/ render() {
|
|
65
|
+
const rendered = dedent`
|
|
107
66
|
${this.header()}
|
|
108
67
|
|
|
109
68
|
${this.body()}
|
|
110
69
|
`;
|
|
111
70
|
const footer = this.footer();
|
|
112
|
-
if (!footer)
|
|
113
|
-
|
|
114
|
-
return (0, ts_dedent_1.default) `
|
|
71
|
+
if (!footer) return rendered;
|
|
72
|
+
return dedent`
|
|
115
73
|
${rendered}
|
|
116
74
|
|
|
117
75
|
${footer}
|
|
@@ -121,115 +79,85 @@ class BaseError extends Error {
|
|
|
121
79
|
return `${this.code}: ${this.message}`;
|
|
122
80
|
}
|
|
123
81
|
footer() {
|
|
124
|
-
if (this.isBug == IsBug.NO)
|
|
125
|
-
|
|
126
|
-
return (0, ts_dedent_1.default) `
|
|
82
|
+
if (this.isBug == IsBug.NO) return "";
|
|
83
|
+
return dedent`
|
|
127
84
|
${this.isBug == IsBug.YES ? "This is a bug" : "If you think this is a bug"}, please submit an issue using the link below.
|
|
128
85
|
|
|
129
86
|
https://github.com/gadget-inc/ggt/issues/new?template=bug_report.yml&error-id=${this.sentryEventId}
|
|
130
87
|
`;
|
|
131
88
|
}
|
|
89
|
+
constructor(code, message){
|
|
90
|
+
super(message);
|
|
91
|
+
/**
|
|
92
|
+
* A GGT_CLI_SOMETHING human/machine readable unique identifier for this error.
|
|
93
|
+
*/ _define_property(this, "code", void 0);
|
|
94
|
+
/**
|
|
95
|
+
* The Sentry event ID for this error.
|
|
96
|
+
*/ _define_property(this, "sentryEventId", context.env.testLike ? "00000000-0000-0000-0000-000000000000" : randomUUID());
|
|
97
|
+
/**
|
|
98
|
+
* The underlying *thing* that caused this error.
|
|
99
|
+
*/ _define_property(this, "cause", void 0);
|
|
100
|
+
/**
|
|
101
|
+
* Assume the stack trace exists.
|
|
102
|
+
*/ _define_property(this, "stack", void 0);
|
|
103
|
+
this.code = code;
|
|
104
|
+
Error.captureStackTrace(this, this.constructor);
|
|
105
|
+
}
|
|
132
106
|
}
|
|
133
|
-
exports.BaseError = BaseError;
|
|
134
107
|
/**
|
|
135
108
|
* Universal Error object to json blob serializer.
|
|
136
109
|
* Wraps `serialize-error` with some handy stuff, like special support for Got HTTP errors
|
|
137
|
-
*/
|
|
138
|
-
|
|
139
|
-
let serialized = (0, serialize_error_1.serializeError)((0, lodash_1.isArray)(error) ? new AggregateError(error) : error);
|
|
110
|
+
*/ export function serializeError(error) {
|
|
111
|
+
let serialized = baseSerializeError(_.isArray(error) ? new AggregateError(error) : error);
|
|
140
112
|
if (typeof serialized == "string") {
|
|
141
|
-
serialized = {
|
|
113
|
+
serialized = {
|
|
114
|
+
message: serialized
|
|
115
|
+
};
|
|
142
116
|
}
|
|
143
|
-
if (error instanceof
|
|
117
|
+
if (error instanceof HTTPError && error.name === "RequestError") {
|
|
144
118
|
delete serialized["timings"];
|
|
145
|
-
serialized["options"] = {
|
|
146
|
-
|
|
119
|
+
serialized["options"] = {
|
|
120
|
+
method: error.options.method,
|
|
121
|
+
url: error.options.url instanceof URL ? error.options.url.toJSON() : error.options.url
|
|
122
|
+
};
|
|
123
|
+
serialized["responseBody"] = inspect(error.response?.body);
|
|
147
124
|
}
|
|
148
125
|
return serialized;
|
|
149
126
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
(function (IsBug) {
|
|
127
|
+
export var IsBug;
|
|
128
|
+
(function(IsBug) {
|
|
153
129
|
IsBug["YES"] = "yes";
|
|
154
130
|
IsBug["NO"] = "no";
|
|
155
131
|
IsBug["MAYBE"] = "maybe";
|
|
156
|
-
})(IsBug
|
|
132
|
+
})(IsBug || (IsBug = {}));
|
|
157
133
|
/**
|
|
158
134
|
* Our "catch all" error. If this error is thrown, we almost certainly have a bug.
|
|
159
135
|
*
|
|
160
136
|
* Whenever possible, we should use a more specific error so that we can provide more useful information.
|
|
161
|
-
*/
|
|
162
|
-
class UnexpectedError extends BaseError {
|
|
163
|
-
constructor(cause) {
|
|
164
|
-
super("GGT_CLI_UNEXPECTED_ERROR", "An unexpected error occurred");
|
|
165
|
-
Object.defineProperty(this, "cause", {
|
|
166
|
-
enumerable: true,
|
|
167
|
-
configurable: true,
|
|
168
|
-
writable: true,
|
|
169
|
-
value: cause
|
|
170
|
-
});
|
|
171
|
-
Object.defineProperty(this, "isBug", {
|
|
172
|
-
enumerable: true,
|
|
173
|
-
configurable: true,
|
|
174
|
-
writable: true,
|
|
175
|
-
value: IsBug.YES
|
|
176
|
-
});
|
|
177
|
-
}
|
|
137
|
+
*/ export class UnexpectedError extends BaseError {
|
|
178
138
|
body() {
|
|
179
|
-
return (
|
|
139
|
+
return cleanStack(this.cause.stack ?? this.stack);
|
|
180
140
|
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
enumerable: true,
|
|
188
|
-
configurable: true,
|
|
189
|
-
writable: true,
|
|
190
|
-
value: payload
|
|
191
|
-
});
|
|
192
|
-
Object.defineProperty(this, "cause", {
|
|
193
|
-
enumerable: true,
|
|
194
|
-
configurable: true,
|
|
195
|
-
writable: true,
|
|
196
|
-
value: cause
|
|
197
|
-
});
|
|
198
|
-
Object.defineProperty(this, "isBug", {
|
|
199
|
-
enumerable: true,
|
|
200
|
-
configurable: true,
|
|
201
|
-
writable: true,
|
|
202
|
-
value: IsBug.MAYBE
|
|
203
|
-
});
|
|
204
|
-
// ErrorEvent and CloseEvent aren't serializable, so we reconstruct them into an object. We discard the `target` property because it's large and not that useful
|
|
205
|
-
if (isErrorEvent(cause)) {
|
|
206
|
-
this.cause = {
|
|
207
|
-
type: cause.type,
|
|
208
|
-
message: cause.message,
|
|
209
|
-
error: serializeError(cause.error),
|
|
210
|
-
};
|
|
211
|
-
}
|
|
212
|
-
else if (isCloseEvent(cause)) {
|
|
213
|
-
this.cause = {
|
|
214
|
-
type: cause.type,
|
|
215
|
-
code: cause.code,
|
|
216
|
-
reason: cause.reason,
|
|
217
|
-
wasClean: cause.wasClean,
|
|
218
|
-
};
|
|
219
|
-
}
|
|
141
|
+
constructor(cause){
|
|
142
|
+
super("GGT_CLI_UNEXPECTED_ERROR", "An unexpected error occurred");
|
|
143
|
+
_define_property(this, "cause", void 0);
|
|
144
|
+
_define_property(this, "isBug", void 0);
|
|
145
|
+
this.cause = cause;
|
|
146
|
+
this.isBug = IsBug.YES;
|
|
220
147
|
}
|
|
148
|
+
}
|
|
149
|
+
export class ClientError extends BaseError {
|
|
221
150
|
body() {
|
|
222
151
|
if (isGraphQLErrors(this.cause)) {
|
|
223
152
|
if (this.cause.length > 1) {
|
|
224
|
-
const errors =
|
|
153
|
+
const errors = _.uniqBy(this.cause, "message");
|
|
225
154
|
let output = "Gadget responded with multiple errors:\n";
|
|
226
|
-
for
|
|
155
|
+
for(let i = 0; i < errors.length; i++){
|
|
227
156
|
output += `\n ${i + 1}. ${errors[i]?.message}`;
|
|
228
157
|
}
|
|
229
158
|
return output;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
return (0, ts_dedent_1.default) `
|
|
159
|
+
} else {
|
|
160
|
+
return dedent`
|
|
233
161
|
Gadget responded with the following error:
|
|
234
162
|
|
|
235
163
|
${this.cause[0]?.message}
|
|
@@ -239,25 +167,39 @@ class ClientError extends BaseError {
|
|
|
239
167
|
if (isCloseEvent(this.cause)) {
|
|
240
168
|
return "The connection to Gadget closed unexpectedly.";
|
|
241
169
|
}
|
|
242
|
-
if (isErrorEvent(this.cause) ||
|
|
170
|
+
if (isErrorEvent(this.cause) || _.isError(this.cause)) {
|
|
243
171
|
return this.cause.message;
|
|
244
172
|
}
|
|
245
173
|
return this.cause;
|
|
246
174
|
}
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
175
|
+
constructor(payload, cause){
|
|
176
|
+
super("GGT_CLI_CLIENT_ERROR", "An error occurred while communicating with Gadget");
|
|
177
|
+
_define_property(this, "payload", void 0);
|
|
178
|
+
_define_property(this, "cause", void 0);
|
|
179
|
+
_define_property(this, "isBug", void 0);
|
|
180
|
+
this.payload = payload;
|
|
181
|
+
this.cause = cause;
|
|
182
|
+
this.isBug = IsBug.MAYBE;
|
|
183
|
+
// ErrorEvent and CloseEvent aren't serializable, so we reconstruct them into an object. We discard the `target` property because it's large and not that useful
|
|
184
|
+
if (isErrorEvent(cause)) {
|
|
185
|
+
this.cause = {
|
|
186
|
+
type: cause.type,
|
|
187
|
+
message: cause.message,
|
|
188
|
+
error: serializeError(cause.error)
|
|
189
|
+
};
|
|
190
|
+
} else if (isCloseEvent(cause)) {
|
|
191
|
+
this.cause = {
|
|
192
|
+
type: cause.type,
|
|
193
|
+
code: cause.code,
|
|
194
|
+
reason: cause.reason,
|
|
195
|
+
wasClean: cause.wasClean
|
|
196
|
+
};
|
|
197
|
+
}
|
|
258
198
|
}
|
|
199
|
+
}
|
|
200
|
+
export class YarnNotFoundError extends BaseError {
|
|
259
201
|
body() {
|
|
260
|
-
return
|
|
202
|
+
return dedent`
|
|
261
203
|
Yarn must be installed to sync your application. You can install it by running:
|
|
262
204
|
|
|
263
205
|
$ npm install --global yarn
|
|
@@ -265,74 +207,38 @@ class YarnNotFoundError extends BaseError {
|
|
|
265
207
|
For more information, see: https://classic.yarnpkg.com/en/docs/install
|
|
266
208
|
`;
|
|
267
209
|
}
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
constructor(flag, description) {
|
|
272
|
-
const name = flag.char ? `-${flag.char}, --${flag.name}` : `--${flag.name}`;
|
|
273
|
-
super("GGT_CLI_FLAG_ERROR", "");
|
|
274
|
-
Object.defineProperty(this, "flag", {
|
|
275
|
-
enumerable: true,
|
|
276
|
-
configurable: true,
|
|
277
|
-
writable: true,
|
|
278
|
-
value: flag
|
|
279
|
-
});
|
|
280
|
-
Object.defineProperty(this, "description", {
|
|
281
|
-
enumerable: true,
|
|
282
|
-
configurable: true,
|
|
283
|
-
writable: true,
|
|
284
|
-
value: description
|
|
285
|
-
});
|
|
286
|
-
Object.defineProperty(this, "isBug", {
|
|
287
|
-
enumerable: true,
|
|
288
|
-
configurable: true,
|
|
289
|
-
writable: true,
|
|
290
|
-
value: IsBug.NO
|
|
291
|
-
});
|
|
292
|
-
_FlagError_message.set(this, void 0);
|
|
293
|
-
// oclif overwrites the message property, so we have to use different one...
|
|
294
|
-
// https://github.com/oclif/core/blob/413592abca47ebedb2c006634a326bab325c26bd/src/parser/parse.ts#L317
|
|
295
|
-
tslib_1.__classPrivateFieldSet(this, _FlagError_message, `Invalid value provided for the ${name} flag`, "f");
|
|
210
|
+
constructor(){
|
|
211
|
+
super("GGT_CLI_YARN_NOT_FOUND", "Yarn not found");
|
|
212
|
+
_define_property(this, "isBug", IsBug.NO);
|
|
296
213
|
}
|
|
214
|
+
}
|
|
215
|
+
var _message = /*#__PURE__*/ new WeakMap();
|
|
216
|
+
export class FlagError extends BaseError {
|
|
297
217
|
header() {
|
|
298
|
-
return `${this.code}: ${
|
|
218
|
+
return `${this.code}: ${_class_private_field_get(this, _message)}`;
|
|
299
219
|
}
|
|
300
220
|
body() {
|
|
301
221
|
return this.description;
|
|
302
222
|
}
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
enumerable: true,
|
|
311
|
-
configurable: true,
|
|
312
|
-
writable: true,
|
|
313
|
-
value: cause
|
|
314
|
-
});
|
|
315
|
-
Object.defineProperty(this, "sync", {
|
|
316
|
-
enumerable: true,
|
|
317
|
-
configurable: true,
|
|
318
|
-
writable: true,
|
|
319
|
-
value: sync
|
|
320
|
-
});
|
|
321
|
-
Object.defineProperty(this, "app", {
|
|
322
|
-
enumerable: true,
|
|
323
|
-
configurable: true,
|
|
324
|
-
writable: true,
|
|
325
|
-
value: app
|
|
326
|
-
});
|
|
327
|
-
Object.defineProperty(this, "isBug", {
|
|
328
|
-
enumerable: true,
|
|
329
|
-
configurable: true,
|
|
223
|
+
constructor(flag, description){
|
|
224
|
+
const name = flag.char ? `-${flag.char}, --${flag.name}` : `--${flag.name}`;
|
|
225
|
+
super("GGT_CLI_FLAG_ERROR", "");
|
|
226
|
+
_define_property(this, "flag", void 0);
|
|
227
|
+
_define_property(this, "description", void 0);
|
|
228
|
+
_define_property(this, "isBug", void 0);
|
|
229
|
+
_class_private_field_init(this, _message, {
|
|
330
230
|
writable: true,
|
|
331
|
-
value:
|
|
231
|
+
value: void 0
|
|
332
232
|
});
|
|
233
|
+
this.flag = flag;
|
|
234
|
+
this.description = description;
|
|
235
|
+
this.isBug = IsBug.NO;
|
|
236
|
+
_class_private_field_set(this, _message, `Invalid value provided for the ${name} flag`);
|
|
333
237
|
}
|
|
238
|
+
}
|
|
239
|
+
export class InvalidSyncFileError extends BaseError {
|
|
334
240
|
body() {
|
|
335
|
-
return
|
|
241
|
+
return dedent`
|
|
336
242
|
We failed to read the Gadget metadata file in this directory:
|
|
337
243
|
|
|
338
244
|
${this.sync.dir}
|
|
@@ -348,18 +254,31 @@ class InvalidSyncFileError extends BaseError {
|
|
|
348
254
|
You will be prompted to either merge your local files with your remote ones or reset your local files to your remote ones.
|
|
349
255
|
`;
|
|
350
256
|
}
|
|
257
|
+
constructor(cause, sync, app){
|
|
258
|
+
super("GGT_CLI_INVALID_SYNC_FILE", "The .gadget/sync.json file was invalid or not found");
|
|
259
|
+
_define_property(this, "cause", void 0);
|
|
260
|
+
_define_property(this, "sync", void 0);
|
|
261
|
+
_define_property(this, "app", void 0);
|
|
262
|
+
_define_property(this, "isBug", void 0);
|
|
263
|
+
this.cause = cause;
|
|
264
|
+
this.sync = sync;
|
|
265
|
+
this.app = app;
|
|
266
|
+
this.isBug = IsBug.MAYBE;
|
|
267
|
+
}
|
|
351
268
|
}
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
269
|
+
export class InvalidSyncAppFlagError extends FlagError {
|
|
270
|
+
constructor(sync){
|
|
271
|
+
super({
|
|
272
|
+
name: "app",
|
|
273
|
+
char: "a"
|
|
274
|
+
}, dedent`
|
|
356
275
|
You were about to sync the following app to the following directory:
|
|
357
276
|
|
|
358
277
|
${sync.flags.app} → ${sync.dir}
|
|
359
278
|
|
|
360
279
|
However, that directory has already been synced with this app:
|
|
361
280
|
|
|
362
|
-
${sync.
|
|
281
|
+
${sync.state.app}
|
|
363
282
|
|
|
364
283
|
If you're sure that you want to sync "${sync.flags.app}" to "${sync.dir}", run \`ggt sync\` again with the \`--force\` flag:
|
|
365
284
|
|
|
@@ -367,14 +286,14 @@ class InvalidSyncAppFlagError extends FlagError {
|
|
|
367
286
|
`);
|
|
368
287
|
}
|
|
369
288
|
}
|
|
370
|
-
exports.InvalidSyncAppFlagError = InvalidSyncAppFlagError;
|
|
371
289
|
function isCloseEvent(e) {
|
|
372
|
-
return !
|
|
290
|
+
return !_.isNil(e) && _.isString(e.type) && _.isNumber(e.code) && _.isString(e.reason) && _.isBoolean(e.wasClean);
|
|
373
291
|
}
|
|
374
292
|
function isErrorEvent(e) {
|
|
375
|
-
return !
|
|
293
|
+
return !_.isNil(e) && _.isString(e.type) && _.isString(e.message) && !_.isNil(e.error);
|
|
376
294
|
}
|
|
377
295
|
function isGraphQLErrors(e) {
|
|
378
|
-
return
|
|
296
|
+
return _.isArray(e) && e.every((e)=>!_.isNil(e) && _.isString(e.message) && _.isArray(e.locations ?? []) && _.isArray(e.path ?? []));
|
|
379
297
|
}
|
|
298
|
+
|
|
380
299
|
//# sourceMappingURL=errors.js.map
|
package/lib/utils/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"/","sources":["utils/errors.ts"],"names":[],"mappings":";;;;;AAAA,sEAAqC;AACrC,6BAAgC;AAEhC,mCAA8F;AAC9F,qDAAuE;AACvE,kEAA+B;AAE/B,+BAA+B;AAI/B,uCAAoC;AACpC,oDAAoB;AACpB,6DAAuC;AACvC,mCAAoC;AAEpC;;;;GAIG;AACH,MAAsB,SAAU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AAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;OACnC,CACF,CAAC;IACJ,CAAC;CACF;AAnBD,0DAmBC;AAED,SAAS,YAAY,CAAC,CAAM;IAC1B,OAAO,CAAC,IAAA,cAAK,EAAC,CAAC,CAAC,IAAI,IAAA,iBAAQ,EAAC,CAAC,CAAC,IAAI,CAAC,IAAI,IAAA,iBAAQ,EAAC,CAAC,CAAC,IAAI,CAAC,IAAI,IAAA,iBAAQ,EAAC,CAAC,CAAC,MAAM,CAAC,IAAI,IAAA,kBAAS,EAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;AAC1G,CAAC;AAED,SAAS,YAAY,CAAC,CAAM;IAC1B,OAAO,CAAC,IAAA,cAAK,EAAC,CAAC,CAAC,IAAI,IAAA,iBAAQ,EAAC,CAAC,CAAC,IAAI,CAAC,IAAI,IAAA,iBAAQ,EAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,IAAA,cAAK,EAAC,CAAC,CAAC,KAAK,CAAC,CAAC;AACjF,CAAC;AAED,SAAS,eAAe,CAAC,CAAM;IAC7B,OAAO,IAAA,gBAAO,EAAC,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAA,cAAK,EAAC,CAAC,CAAC,IAAI,IAAA,iBAAQ,EAAC,CAAC,CAAC,OAAO,CAAC,IAAI,IAAA,gBAAO,EAAC,CAAC,CAAC,SAAS,IAAI,EAAE,CAAC,IAAI,IAAA,gBAAO,EAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC;AAC/H,CAAC","sourcesContent":["import cleanStack from \"clean-stack\";\nimport { HTTPError } from \"got\";\nimport type { GraphQLError } from \"graphql\";\nimport { isArray, isBoolean, isError, isNil, isNumber, isString, noop, uniqBy } from \"lodash\";\nimport { serializeError as baseSerializeError } from \"serialize-error\";\nimport dedent from \"ts-dedent\";\nimport type { SetOptional } from \"type-fest\";\nimport { inspect } from \"util\";\nimport type { CloseEvent, ErrorEvent } from \"ws\";\nimport type Sync from \"../commands/sync\";\nimport type { Payload } from \"./client\";\nimport { context } from \"./context\";\nimport os from \"os\";\nimport * as Sentry from \"@sentry/node\";\nimport { randomUUID } from \"crypto\";\n\n/**\n * Base class for all errors.\n *\n * Inspired by gadget's GadgetError and oclif's PrettyPrintableError.\n */\nexport abstract class BaseError extends Error {\n /**\n * A GGT_CLI_SOMETHING human/machine readable unique identifier for this error.\n */\n code: string;\n\n /**\n * The Sentry event ID for this error.\n */\n sentryEventId = context.env.testLike ? \"00000000-0000-0000-0000-000000000000\" : randomUUID();\n\n /**\n * The underlying *thing* that caused this error.\n */\n override cause?: any;\n\n /**\n * Assume the stack trace exists.\n */\n override stack!: string;\n\n /**\n * Indicates whether this error is considered a bug or not.\n */\n abstract isBug: IsBug;\n\n constructor(code: string, message: string) {\n super(message);\n this.code = code;\n Error.captureStackTrace(this, this.constructor);\n }\n\n async capture(): Promise<void> {\n if (this.isBug == IsBug.NO) return;\n\n const user = await context.getUser().catch(noop);\n\n Sentry.getCurrentHub().captureException(this, {\n event_id: this.sentryEventId,\n captureContext: {\n user: user ? { id: String(user.id), email: user.email, username: user.name } : undefined,\n tags: {\n applicationId: context.app?.id,\n arch: context.config.arch,\n isBug: this.isBug,\n code: this.code,\n environment: context.env.value,\n platform: context.config.platform,\n shell: context.config.shell,\n version: context.config.version,\n },\n contexts: {\n cause: this.cause ? serializeError(this.cause) : undefined,\n app: {\n command: `${context.config.bin} ${process.argv.slice(2).join(\" \")}`,\n argv: process.argv,\n },\n device: {\n name: os.hostname(),\n family: os.type(),\n arch: os.arch(),\n },\n runtime: {\n name: process.release.name,\n version: process.version,\n },\n },\n },\n });\n\n await Sentry.flush(2000);\n }\n\n /**\n * Turns this error into a user-friendly message that explains what went wrong and how to fix it. A good write up of what an error should\n * look like can be found here: {@link https://clig.dev/#errors}\n */\n render(): string {\n const rendered = dedent`\n ${this.header()}\n\n ${this.body()}\n `;\n\n const footer = this.footer();\n if (!footer) return rendered;\n\n return dedent`\n ${rendered}\n\n ${footer}\n `;\n }\n\n protected header(): string {\n return `${this.code}: ${this.message}`;\n }\n\n protected footer(): string {\n if (this.isBug == IsBug.NO) return \"\";\n\n return dedent`\n ${this.isBug == IsBug.YES ? \"This is a bug\" : \"If you think this is a bug\"}, please submit an issue using the link below.\n\n https://github.com/gadget-inc/ggt/issues/new?template=bug_report.yml&error-id=${this.sentryEventId}\n `;\n }\n\n protected abstract body(): string;\n}\n\n/**\n * Universal Error object to json blob serializer.\n * Wraps `serialize-error` with some handy stuff, like special support for Got HTTP errors\n */\nexport function serializeError(error: Error | string | unknown): Record<string, any> {\n let serialized = baseSerializeError(isArray(error) ? new AggregateError(error) : error);\n if (typeof serialized == \"string\") {\n serialized = { message: serialized };\n }\n\n if (error instanceof HTTPError && error.name === \"RequestError\") {\n delete serialized[\"timings\"];\n serialized[\"options\"] = { method: error.options.method, url: error.options.url.toJSON() };\n serialized[\"responseBody\"] = inspect(error.response?.body);\n }\n\n return serialized;\n}\n\nexport enum IsBug {\n YES = \"yes\",\n NO = \"no\",\n MAYBE = \"maybe\",\n}\n\n/**\n * Our \"catch all\" error. If this error is thrown, we almost certainly have a bug.\n *\n * Whenever possible, we should use a more specific error so that we can provide more useful information.\n */\nexport class UnexpectedError extends BaseError {\n isBug = IsBug.YES;\n\n constructor(override cause: Error) {\n super(\"GGT_CLI_UNEXPECTED_ERROR\", \"An unexpected error occurred\");\n }\n\n protected body(): string {\n return cleanStack(this.cause.stack ?? this.stack);\n }\n}\n\nexport class ClientError extends BaseError {\n isBug = IsBug.MAYBE;\n\n constructor(readonly payload: Payload<any, any>, override cause: string | Error | readonly GraphQLError[] | CloseEvent | ErrorEvent) {\n super(\"GGT_CLI_CLIENT_ERROR\", \"An error occurred while communicating with Gadget\");\n\n // ErrorEvent and CloseEvent aren't serializable, so we reconstruct them into an object. We discard the `target` property because it's large and not that useful\n if (isErrorEvent(cause)) {\n this.cause = {\n type: cause.type,\n message: cause.message,\n error: serializeError(cause.error),\n } as any;\n } else if (isCloseEvent(cause)) {\n this.cause = {\n type: cause.type,\n code: cause.code,\n reason: cause.reason,\n wasClean: cause.wasClean,\n } as any;\n }\n }\n\n override body(): string {\n if (isGraphQLErrors(this.cause)) {\n if (this.cause.length > 1) {\n const errors = uniqBy(this.cause, \"message\");\n\n let output = \"Gadget responded with multiple errors:\\n\";\n for (let i = 0; i < errors.length; i++) {\n output += `\\n ${i + 1}. ${errors[i]?.message}`;\n }\n\n return output;\n } else {\n return dedent`\n Gadget responded with the following error:\n\n ${this.cause[0]?.message}\n `;\n }\n }\n\n if (isCloseEvent(this.cause)) {\n return \"The connection to Gadget closed unexpectedly.\";\n }\n\n if (isErrorEvent(this.cause) || isError(this.cause)) {\n return this.cause.message;\n }\n\n return this.cause;\n }\n}\n\nexport class YarnNotFoundError extends BaseError {\n isBug = IsBug.NO;\n\n constructor() {\n super(\"GGT_CLI_YARN_NOT_FOUND\", \"Yarn not found\");\n }\n\n protected body(): string {\n return dedent`\n Yarn must be installed to sync your application. You can install it by running:\n\n $ npm install --global yarn\n\n For more information, see: https://classic.yarnpkg.com/en/docs/install\n `;\n }\n}\n\nexport class FlagError<T extends { name: string; char?: string } = { name: string; char?: string }> extends BaseError {\n isBug = IsBug.NO;\n\n #message: string;\n\n constructor(readonly flag: T, readonly description: string) {\n const name = flag.char ? `-${flag.char}, --${flag.name}` : `--${flag.name}`;\n super(\"GGT_CLI_FLAG_ERROR\", \"\");\n\n // oclif overwrites the message property, so we have to use different one...\n // https://github.com/oclif/core/blob/413592abca47ebedb2c006634a326bab325c26bd/src/parser/parse.ts#L317\n this.#message = `Invalid value provided for the ${name} flag`;\n }\n\n protected override header(): string {\n return `${this.code}: ${this.#message}`;\n }\n\n protected body(): string {\n return this.description;\n }\n}\n\nexport class InvalidSyncFileError extends BaseError {\n isBug = IsBug.MAYBE;\n\n constructor(override readonly cause: unknown, readonly sync: Sync, readonly app: string | undefined) {\n super(\"GGT_CLI_INVALID_SYNC_FILE\", \"The .gadget/sync.json file was invalid or not found\");\n }\n\n protected body(): string {\n return dedent`\n We failed to read the Gadget metadata file in this directory:\n\n ${this.sync.dir}\n\n If you're running \\`ggt sync\\` for the first time, we recommend using an empty directory such as:\n\n ~/gadget/${this.app || \"<name of app>\"}\n\n Otherwise, if you're sure you want to sync the contents of that directory to Gadget, run \\`ggt sync\\` again with the \\`--force\\` flag:\n\n $ ggt sync ${this.sync.argv.join(\" \")} --force\n\n You will be prompted to either merge your local files with your remote ones or reset your local files to your remote ones.\n `;\n }\n}\n\nexport class InvalidSyncAppFlagError extends FlagError {\n constructor(sync: Sync) {\n super(\n { name: \"app\", char: \"a\" },\n dedent`\n You were about to sync the following app to the following directory:\n\n ${sync.flags.app} → ${sync.dir}\n\n However, that directory has already been synced with this app:\n\n ${sync.metadata.app}\n\n If you're sure that you want to sync \"${sync.flags.app}\" to \"${sync.dir}\", run \\`ggt sync\\` again with the \\`--force\\` flag:\n\n $ ggt sync ${sync.argv.join(\" \")} --force\n `\n );\n }\n}\n\nfunction isCloseEvent(e: any): e is SetOptional<CloseEvent, \"target\"> {\n return !isNil(e) && isString(e.type) && isNumber(e.code) && isString(e.reason) && isBoolean(e.wasClean);\n}\n\nfunction isErrorEvent(e: any): e is SetOptional<ErrorEvent, \"target\"> {\n return !isNil(e) && isString(e.type) && isString(e.message) && !isNil(e.error);\n}\n\nfunction isGraphQLErrors(e: any): e is readonly GraphQLError[] {\n return isArray(e) && e.every((e) => !isNil(e) && isString(e.message) && isArray(e.locations ?? []) && isArray(e.path ?? []));\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../src/utils/errors.ts"],"sourcesContent":["import cleanStack from \"clean-stack\";\nimport { HTTPError } from \"got\";\nimport type { GraphQLError } from \"graphql\";\nimport _ from \"lodash\";\nimport { serializeError as baseSerializeError } from \"serialize-error\";\nimport { dedent } from \"ts-dedent\";\nimport type { SetOptional } from \"type-fest\";\nimport { inspect } from \"util\";\nimport type { CloseEvent, ErrorEvent } from \"ws\";\nimport type Sync from \"../commands/sync.js\";\nimport type { Payload } from \"./client.js\";\nimport { context } from \"./context.js\";\nimport os from \"os\";\nimport * as Sentry from \"@sentry/node\";\nimport { randomUUID } from \"crypto\";\n\n/**\n * Base class for all errors.\n *\n * Inspired by gadget's GadgetError and oclif's PrettyPrintableError.\n */\nexport abstract class BaseError extends Error {\n /**\n * A GGT_CLI_SOMETHING human/machine readable unique identifier for this error.\n */\n code: string;\n\n /**\n * The Sentry event ID for this error.\n */\n sentryEventId = context.env.testLike ? \"00000000-0000-0000-0000-000000000000\" : randomUUID();\n\n /**\n * The underlying *thing* that caused this error.\n */\n cause?: any;\n\n /**\n * Assume the stack trace exists.\n */\n override stack!: string;\n\n /**\n * Indicates whether this error is considered a bug or not.\n */\n abstract isBug: IsBug;\n\n constructor(code: string, message: string) {\n super(message);\n this.code = code;\n Error.captureStackTrace(this, this.constructor);\n }\n\n async capture(): Promise<void> {\n if (this.isBug == IsBug.NO) return;\n\n const user = await context.getUser().catch(_.noop.bind(_));\n\n Sentry.getCurrentHub().captureException(this, {\n event_id: this.sentryEventId,\n captureContext: {\n user: user ? { id: String(user.id), email: user.email, username: user.name } : undefined,\n tags: {\n applicationId: context.app?.id,\n arch: context.config.arch,\n isBug: this.isBug,\n code: this.code,\n environment: context.env.value,\n platform: context.config.platform,\n shell: context.config.shell,\n version: context.config.version,\n },\n contexts: {\n cause: this.cause ? serializeError(this.cause) : undefined,\n app: {\n command: `${context.config.bin} ${process.argv.slice(2).join(\" \")}`,\n argv: process.argv,\n },\n device: {\n name: os.hostname(),\n family: os.type(),\n arch: os.arch(),\n },\n runtime: {\n name: process.release.name,\n version: process.version,\n },\n },\n },\n });\n\n await Sentry.flush(2000);\n }\n\n /**\n * Turns this error into a user-friendly message that explains what went wrong and how to fix it. A good write up of what an error should\n * look like can be found here: {@link https://clig.dev/#errors}\n */\n render(): string {\n const rendered = dedent`\n ${this.header()}\n\n ${this.body()}\n `;\n\n const footer = this.footer();\n if (!footer) return rendered;\n\n return dedent`\n ${rendered}\n\n ${footer}\n `;\n }\n\n protected header(): string {\n return `${this.code}: ${this.message}`;\n }\n\n protected footer(): string {\n if (this.isBug == IsBug.NO) return \"\";\n\n return dedent`\n ${this.isBug == IsBug.YES ? \"This is a bug\" : \"If you think this is a bug\"}, please submit an issue using the link below.\n\n https://github.com/gadget-inc/ggt/issues/new?template=bug_report.yml&error-id=${this.sentryEventId}\n `;\n }\n\n protected abstract body(): string;\n}\n\n/**\n * Universal Error object to json blob serializer.\n * Wraps `serialize-error` with some handy stuff, like special support for Got HTTP errors\n */\nexport function serializeError(error: Error | string | unknown): Record<string, any> {\n let serialized = baseSerializeError(_.isArray(error) ? new AggregateError(error) : error);\n if (typeof serialized == \"string\") {\n serialized = { message: serialized };\n }\n\n if (error instanceof HTTPError && error.name === \"RequestError\") {\n delete serialized[\"timings\"];\n serialized[\"options\"] = {\n method: error.options.method,\n url: error.options.url instanceof URL ? error.options.url.toJSON() : error.options.url,\n };\n serialized[\"responseBody\"] = inspect(error.response?.body);\n }\n\n return serialized;\n}\n\nexport enum IsBug {\n YES = \"yes\",\n NO = \"no\",\n MAYBE = \"maybe\",\n}\n\n/**\n * Our \"catch all\" error. If this error is thrown, we almost certainly have a bug.\n *\n * Whenever possible, we should use a more specific error so that we can provide more useful information.\n */\nexport class UnexpectedError extends BaseError {\n isBug = IsBug.YES;\n\n constructor(override cause: Error) {\n super(\"GGT_CLI_UNEXPECTED_ERROR\", \"An unexpected error occurred\");\n }\n\n protected body(): string {\n return cleanStack(this.cause.stack ?? this.stack);\n }\n}\n\nexport class ClientError extends BaseError {\n isBug = IsBug.MAYBE;\n\n constructor(readonly payload: Payload<any, any>, override cause: string | Error | readonly GraphQLError[] | CloseEvent | ErrorEvent) {\n super(\"GGT_CLI_CLIENT_ERROR\", \"An error occurred while communicating with Gadget\");\n\n // ErrorEvent and CloseEvent aren't serializable, so we reconstruct them into an object. We discard the `target` property because it's large and not that useful\n if (isErrorEvent(cause)) {\n this.cause = {\n type: cause.type,\n message: cause.message,\n error: serializeError(cause.error),\n } as any;\n } else if (isCloseEvent(cause)) {\n this.cause = {\n type: cause.type,\n code: cause.code,\n reason: cause.reason,\n wasClean: cause.wasClean,\n } as any;\n }\n }\n\n override body(): string {\n if (isGraphQLErrors(this.cause)) {\n if (this.cause.length > 1) {\n const errors = _.uniqBy(this.cause, \"message\");\n\n let output = \"Gadget responded with multiple errors:\\n\";\n for (let i = 0; i < errors.length; i++) {\n output += `\\n ${i + 1}. ${errors[i]?.message}`;\n }\n\n return output;\n } else {\n return dedent`\n Gadget responded with the following error:\n\n ${this.cause[0]?.message}\n `;\n }\n }\n\n if (isCloseEvent(this.cause)) {\n return \"The connection to Gadget closed unexpectedly.\";\n }\n\n if (isErrorEvent(this.cause) || _.isError(this.cause)) {\n return this.cause.message;\n }\n\n return this.cause;\n }\n}\n\nexport class YarnNotFoundError extends BaseError {\n isBug = IsBug.NO;\n\n constructor() {\n super(\"GGT_CLI_YARN_NOT_FOUND\", \"Yarn not found\");\n }\n\n protected body(): string {\n return dedent`\n Yarn must be installed to sync your application. You can install it by running:\n\n $ npm install --global yarn\n\n For more information, see: https://classic.yarnpkg.com/en/docs/install\n `;\n }\n}\n\nexport class FlagError<T extends { name: string; char?: string } = { name: string; char?: string }> extends BaseError {\n isBug = IsBug.NO;\n\n #message: string;\n\n constructor(readonly flag: T, readonly description: string) {\n const name = flag.char ? `-${flag.char}, --${flag.name}` : `--${flag.name}`;\n super(\"GGT_CLI_FLAG_ERROR\", \"\");\n\n // oclif overwrites the message property, so we have to use different one...\n // https://github.com/oclif/core/blob/413592abca47ebedb2c006634a326bab325c26bd/src/parser/parse.ts#L317\n this.#message = `Invalid value provided for the ${name} flag`;\n }\n\n protected override header(): string {\n return `${this.code}: ${this.#message}`;\n }\n\n protected body(): string {\n return this.description;\n }\n}\n\nexport class InvalidSyncFileError extends BaseError {\n isBug = IsBug.MAYBE;\n\n constructor(override readonly cause: unknown, readonly sync: Sync, readonly app: string | undefined) {\n super(\"GGT_CLI_INVALID_SYNC_FILE\", \"The .gadget/sync.json file was invalid or not found\");\n }\n\n protected body(): string {\n return dedent`\n We failed to read the Gadget metadata file in this directory:\n\n ${this.sync.dir}\n\n If you're running \\`ggt sync\\` for the first time, we recommend using an empty directory such as:\n\n ~/gadget/${this.app || \"<name of app>\"}\n\n Otherwise, if you're sure you want to sync the contents of that directory to Gadget, run \\`ggt sync\\` again with the \\`--force\\` flag:\n\n $ ggt sync ${this.sync.argv.join(\" \")} --force\n\n You will be prompted to either merge your local files with your remote ones or reset your local files to your remote ones.\n `;\n }\n}\n\nexport class InvalidSyncAppFlagError extends FlagError {\n constructor(sync: Sync) {\n super(\n { name: \"app\", char: \"a\" },\n dedent`\n You were about to sync the following app to the following directory:\n\n ${sync.flags.app} → ${sync.dir}\n\n However, that directory has already been synced with this app:\n\n ${sync.state.app}\n\n If you're sure that you want to sync \"${sync.flags.app}\" to \"${sync.dir}\", run \\`ggt sync\\` again with the \\`--force\\` flag:\n\n $ ggt sync ${sync.argv.join(\" \")} --force\n `\n );\n }\n}\n\nfunction isCloseEvent(e: any): e is SetOptional<CloseEvent, \"target\"> {\n return !_.isNil(e) && _.isString(e.type) && _.isNumber(e.code) && _.isString(e.reason) && _.isBoolean(e.wasClean);\n}\n\nfunction isErrorEvent(e: any): e is SetOptional<ErrorEvent, \"target\"> {\n return !_.isNil(e) && _.isString(e.type) && _.isString(e.message) && !_.isNil(e.error);\n}\n\nfunction isGraphQLErrors(e: any): e is readonly GraphQLError[] {\n return _.isArray(e) && e.every((e) => !_.isNil(e) && _.isString(e.message) && _.isArray(e.locations ?? []) && _.isArray(e.path ?? []));\n}\n"],"names":["cleanStack","HTTPError","_","serializeError","baseSerializeError","dedent","inspect","context","os","Sentry","randomUUID","BaseError","Error","capture","isBug","IsBug","NO","user","getUser","catch","noop","bind","getCurrentHub","captureException","event_id","sentryEventId","captureContext","id","String","email","username","name","undefined","tags","applicationId","app","arch","config","code","environment","env","value","platform","shell","version","contexts","cause","command","bin","process","argv","slice","join","device","hostname","family","type","runtime","release","flush","render","rendered","header","body","footer","message","YES","constructor","testLike","stack","captureStackTrace","error","serialized","isArray","AggregateError","method","options","url","URL","toJSON","response","MAYBE","UnexpectedError","ClientError","isGraphQLErrors","length","errors","uniqBy","output","i","isCloseEvent","isErrorEvent","isError","payload","reason","wasClean","YarnNotFoundError","FlagError","description","flag","char","InvalidSyncFileError","sync","dir","InvalidSyncAppFlagError","flags","state","e","isNil","isString","isNumber","isBoolean","every","locations","path"],"mappings":";;;;AAAA,OAAOA,gBAAgB,cAAc;AACrC,SAASC,SAAS,QAAQ,MAAM;AAEhC,OAAOC,OAAO,SAAS;AACvB,SAASC,kBAAkBC,kBAAkB,QAAQ,kBAAkB;AACvE,SAASC,MAAM,QAAQ,YAAY;AAEnC,SAASC,OAAO,QAAQ,OAAO;AAI/B,SAASC,OAAO,QAAQ,eAAe;AACvC,OAAOC,QAAQ,KAAK;AACpB,YAAYC,YAAY,eAAe;AACvC,SAASC,UAAU,QAAQ,SAAS;AAEpC;;;;CAIC,GACD,OAAO,MAAeC,kBAAkBC;IAgCtC,MAAMC,UAAyB;QAC7B,IAAI,IAAI,CAACC,KAAK,IAAIC,MAAMC,EAAE,EAAE;QAE5B,MAAMC,OAAO,MAAMV,QAAQW,OAAO,GAAGC,KAAK,CAACjB,EAAEkB,IAAI,CAACC,IAAI,CAACnB;QAEvDO,OAAOa,aAAa,GAAGC,gBAAgB,CAAC,IAAI,EAAE;YAC5CC,UAAU,IAAI,CAACC,aAAa;YAC5BC,gBAAgB;gBACdT,MAAMA,OAAO;oBAAEU,IAAIC,OAAOX,KAAKU,EAAE;oBAAGE,OAAOZ,KAAKY,KAAK;oBAAEC,UAAUb,KAAKc,IAAI;gBAAC,IAAIC;gBAC/EC,MAAM;oBACJC,eAAe3B,QAAQ4B,GAAG,EAAER;oBAC5BS,MAAM7B,QAAQ8B,MAAM,CAACD,IAAI;o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