@gadgetinc/ggt 0.1.6 → 0.1.8
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/lib/__generated__/graphql.d.ts +45 -45
- package/lib/commands/help.js +1 -1
- package/lib/commands/help.js.map +1 -1
- package/lib/commands/login.d.ts +1 -1
- package/lib/commands/login.js +1 -1
- package/lib/commands/login.js.map +1 -1
- package/lib/commands/logout.d.ts +1 -1
- package/lib/commands/logout.js +2 -2
- package/lib/commands/logout.js.map +1 -1
- package/lib/commands/sync.d.ts +4 -4
- package/lib/commands/sync.js +13 -23
- package/lib/commands/sync.js.map +1 -1
- package/lib/commands/whoami.d.ts +1 -1
- package/lib/commands/whoami.js +2 -2
- package/lib/commands/whoami.js.map +1 -1
- package/lib/{lib → utils}/base-command.d.ts +0 -0
- package/lib/{lib → utils}/base-command.js +1 -1
- package/lib/utils/base-command.js.map +1 -0
- package/lib/{lib → utils}/client.d.ts +1 -1
- package/lib/{lib → utils}/client.js +3 -3
- package/lib/utils/client.js.map +1 -0
- package/lib/{lib → utils}/context.d.ts +0 -0
- package/lib/{lib → utils}/context.js +0 -0
- package/lib/utils/context.js.map +1 -0
- package/lib/{lib → utils}/errors.d.ts +10 -3
- package/lib/{lib → utils}/errors.js +61 -122
- package/lib/utils/errors.js.map +1 -0
- package/lib/{lib → utils}/flags.d.ts +0 -0
- package/lib/{lib → utils}/flags.js +0 -0
- package/lib/utils/flags.js.map +1 -0
- package/lib/{lib → utils}/fs-utils.d.ts +0 -0
- package/lib/{lib → utils}/fs-utils.js +1 -1
- package/lib/utils/fs-utils.js.map +1 -0
- package/lib/{lib → utils}/help.d.ts +0 -0
- package/lib/{lib → utils}/help.js +0 -0
- package/lib/utils/help.js.map +1 -0
- package/lib/{lib → utils}/sleep.d.ts +0 -0
- package/lib/{lib → utils}/sleep.js +0 -0
- package/lib/utils/sleep.js.map +1 -0
- package/npm-shrinkwrap.json +679 -507
- package/oclif.manifest.json +1 -1
- package/package.json +4 -4
- package/lib/lib/base-command.js.map +0 -1
- package/lib/lib/client.js.map +0 -1
- package/lib/lib/context.js.map +0 -1
- package/lib/lib/errors.js.map +0 -1
- package/lib/lib/flags.js.map +0 -1
- package/lib/lib/fs-utils.js.map +0 -1
- package/lib/lib/help.js.map +0 -1
- package/lib/lib/sleep.js.map +0 -1
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.InvalidSyncFileError = exports.FlagError = exports.YarnNotFoundError = exports.ClientError = exports.UnexpectedError = exports.IsBug = exports.serializeError = exports.BaseError = void 0;
|
|
3
|
+
exports.InvalidSyncAppFlagError = exports.InvalidSyncFileError = exports.FlagError = exports.YarnNotFoundError = exports.ClientError = exports.UnexpectedError = exports.IsBug = exports.serializeError = exports.BaseError = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const clean_stack_1 = tslib_1.__importDefault(require("clean-stack"));
|
|
6
6
|
const got_1 = require("got");
|
|
7
7
|
const lodash_1 = require("lodash");
|
|
8
|
-
const new_github_issue_url_1 = tslib_1.__importDefault(require("new-github-issue-url"));
|
|
9
8
|
const serialize_error_1 = require("serialize-error");
|
|
10
9
|
const ts_dedent_1 = tslib_1.__importDefault(require("ts-dedent"));
|
|
11
10
|
const util_1 = require("util");
|
|
@@ -32,6 +31,15 @@ class BaseError extends Error {
|
|
|
32
31
|
writable: true,
|
|
33
32
|
value: void 0
|
|
34
33
|
});
|
|
34
|
+
/**
|
|
35
|
+
* The Sentry event ID for this error.
|
|
36
|
+
*/
|
|
37
|
+
Object.defineProperty(this, "sentryEventId", {
|
|
38
|
+
enumerable: true,
|
|
39
|
+
configurable: true,
|
|
40
|
+
writable: true,
|
|
41
|
+
value: void 0
|
|
42
|
+
});
|
|
35
43
|
/**
|
|
36
44
|
* The underlying *thing* that caused this error.
|
|
37
45
|
*/
|
|
@@ -54,10 +62,10 @@ class BaseError extends Error {
|
|
|
54
62
|
Error.captureStackTrace(this, this.constructor);
|
|
55
63
|
}
|
|
56
64
|
async capture() {
|
|
57
|
-
if (
|
|
65
|
+
if (this.isBug == IsBug.NO)
|
|
58
66
|
return;
|
|
59
67
|
const user = await context_1.context.getUser().catch(lodash_1.noop);
|
|
60
|
-
Sentry.captureException(this, {
|
|
68
|
+
this.sentryEventId = Sentry.captureException(this, {
|
|
61
69
|
user: user ? { id: String(user.id), email: user.email, username: user.name } : undefined,
|
|
62
70
|
tags: {
|
|
63
71
|
applicationId: context_1.context.app?.id,
|
|
@@ -86,90 +94,38 @@ class BaseError extends Error {
|
|
|
86
94
|
},
|
|
87
95
|
},
|
|
88
96
|
});
|
|
89
|
-
await Sentry.flush();
|
|
97
|
+
await Sentry.flush(2000);
|
|
90
98
|
}
|
|
91
99
|
/**
|
|
92
100
|
* 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
|
|
93
101
|
* look like can be found here: {@link https://clig.dev/#errors}
|
|
94
102
|
*/
|
|
95
103
|
render() {
|
|
96
|
-
const
|
|
97
|
-
|
|
104
|
+
const rendered = (0, ts_dedent_1.default) `
|
|
105
|
+
${this.header()}
|
|
106
|
+
|
|
107
|
+
${this.body()}
|
|
108
|
+
`;
|
|
98
109
|
const footer = this.footer();
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
return output;
|
|
110
|
+
if (!footer)
|
|
111
|
+
return rendered;
|
|
112
|
+
return (0, ts_dedent_1.default) `
|
|
113
|
+
${rendered}
|
|
114
|
+
|
|
115
|
+
${footer}
|
|
116
|
+
`;
|
|
107
117
|
}
|
|
108
118
|
header() {
|
|
109
119
|
return `${this.code}: ${this.message}`;
|
|
110
120
|
}
|
|
111
121
|
footer() {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
return (0, ts_dedent_1.default) `
|
|
117
|
-
If you think this is a bug, please submit an issue using the link below.
|
|
118
|
-
|
|
119
|
-
${(0, new_github_issue_url_1.default)(this.issueOptions())}
|
|
120
|
-
`;
|
|
121
|
-
case IsBug.YES:
|
|
122
|
-
return (0, ts_dedent_1.default) `
|
|
123
|
-
This is a bug :(
|
|
124
|
-
|
|
125
|
-
Visit the link below to see if someone has already reported this issue.
|
|
126
|
-
https://github.com/gadget-inc/ggt/issues?q=is%3Aissue+is%3Aopen+label%3Abug+${this.code}
|
|
127
|
-
|
|
128
|
-
If nobody has, you can submit one using the link below.
|
|
129
|
-
---
|
|
130
|
-
${(0, new_github_issue_url_1.default)(this.issueOptions())}
|
|
131
|
-
`;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
issueOptions() {
|
|
135
|
-
const options = {
|
|
136
|
-
repoUrl: "https://github.com/gadget-inc/ggt",
|
|
137
|
-
title: `[BUG ${this.code}]: `,
|
|
138
|
-
labels: ["bug"],
|
|
139
|
-
body: (0, ts_dedent_1.default) `
|
|
140
|
-
### Description
|
|
141
|
-
[Please describe what you were doing when this error occurred]
|
|
142
|
-
|
|
143
|
-
### Command
|
|
144
|
-
\`\`\`sh-session
|
|
145
|
-
${context_1.context.config.bin} ${process.argv.slice(2).join(" ")}
|
|
146
|
-
\`\`\`
|
|
147
|
-
|
|
148
|
-
### Environment
|
|
149
|
-
\`\`\`
|
|
150
|
-
version: ${context_1.context.config.version}
|
|
151
|
-
platform: ${context_1.context.config.platform}
|
|
152
|
-
arch: ${context_1.context.config.arch}
|
|
153
|
-
shell: ${context_1.context.config.shell}
|
|
154
|
-
timestamp: ${new Date().toISOString()}
|
|
155
|
-
\`\`\`
|
|
156
|
-
|
|
157
|
-
### Stack Trace
|
|
158
|
-
\`\`\`
|
|
159
|
-
${(0, clean_stack_1.default)(this.stack)}
|
|
160
|
-
\`\`\`
|
|
161
|
-
`,
|
|
162
|
-
};
|
|
163
|
-
if (this.cause) {
|
|
164
|
-
options.body += (0, ts_dedent_1.default) `
|
|
122
|
+
if (this.isBug == IsBug.NO)
|
|
123
|
+
return "";
|
|
124
|
+
return (0, ts_dedent_1.default) `
|
|
125
|
+
${this.isBug == IsBug.YES ? "This is a bug" : "If you think this is a bug"}, please submit an issue using the link below.
|
|
165
126
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
${JSON.stringify((0, lodash_1.isError)(this.cause) ? serializeError(this.cause) : this.cause, null, 2)}
|
|
169
|
-
\`\`\`
|
|
170
|
-
`;
|
|
171
|
-
}
|
|
172
|
-
return options;
|
|
127
|
+
https://github.com/gadget-inc/ggt/issues/new?template=bug_report.yml${this.sentryEventId ? `&error-id=${this.sentryEventId}` : ""}
|
|
128
|
+
`;
|
|
173
129
|
}
|
|
174
130
|
}
|
|
175
131
|
exports.BaseError = BaseError;
|
|
@@ -178,7 +134,7 @@ exports.BaseError = BaseError;
|
|
|
178
134
|
* Wraps `serialize-error` with some handy stuff, like special support for Got HTTP errors
|
|
179
135
|
*/
|
|
180
136
|
function serializeError(error) {
|
|
181
|
-
let serialized = (0, serialize_error_1.serializeError)(error);
|
|
137
|
+
let serialized = (0, serialize_error_1.serializeError)((0, lodash_1.isArray)(error) ? new AggregateError(error) : error);
|
|
182
138
|
if (typeof serialized == "string") {
|
|
183
139
|
serialized = { message: serialized };
|
|
184
140
|
}
|
|
@@ -263,62 +219,29 @@ class ClientError extends BaseError {
|
|
|
263
219
|
body() {
|
|
264
220
|
if (isGraphQLErrors(this.cause)) {
|
|
265
221
|
if (this.cause.length > 1) {
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
222
|
+
const errors = (0, lodash_1.uniqBy)(this.cause, "message");
|
|
223
|
+
let output = "Gadget responded with multiple errors:\n";
|
|
224
|
+
for (let i = 0; i < errors.length; i++) {
|
|
225
|
+
output += `\n ${i + 1}. ${errors[i]?.message}`;
|
|
269
226
|
}
|
|
270
227
|
return output;
|
|
271
228
|
}
|
|
272
229
|
else {
|
|
273
230
|
return (0, ts_dedent_1.default) `
|
|
274
|
-
Gadget responded with
|
|
231
|
+
Gadget responded with the following error:
|
|
275
232
|
|
|
276
|
-
|
|
233
|
+
${this.cause[0]?.message}
|
|
277
234
|
`;
|
|
278
235
|
}
|
|
279
236
|
}
|
|
280
237
|
if (isCloseEvent(this.cause)) {
|
|
281
238
|
return "The connection to Gadget closed unexpectedly.";
|
|
282
239
|
}
|
|
283
|
-
if (isErrorEvent(this.cause)) {
|
|
284
|
-
return
|
|
285
|
-
The connection to Gadget received an unexpected error.
|
|
286
|
-
|
|
287
|
-
${this.cause.message}
|
|
288
|
-
`;
|
|
289
|
-
}
|
|
290
|
-
if ((0, lodash_1.isError)(this.cause)) {
|
|
291
|
-
return (0, ts_dedent_1.default) `
|
|
292
|
-
An unexpected error occurred.
|
|
293
|
-
|
|
294
|
-
${this.cause.message}
|
|
295
|
-
`;
|
|
240
|
+
if (isErrorEvent(this.cause) || (0, lodash_1.isError)(this.cause)) {
|
|
241
|
+
return this.cause.message;
|
|
296
242
|
}
|
|
297
243
|
return this.cause;
|
|
298
244
|
}
|
|
299
|
-
issueOptions() {
|
|
300
|
-
const options = super.issueOptions();
|
|
301
|
-
options.body += (0, ts_dedent_1.default) `
|
|
302
|
-
|
|
303
|
-
### GraphQL
|
|
304
|
-
|
|
305
|
-
#### Query
|
|
306
|
-
\`\`\`graphql
|
|
307
|
-
${this.payload.query}
|
|
308
|
-
\`\`\`
|
|
309
|
-
`;
|
|
310
|
-
// mutations can have large/sensitive payloads, so we don't include them by default
|
|
311
|
-
if (!this.payload.query.trimStart().startsWith("mutation")) {
|
|
312
|
-
options.body += (0, ts_dedent_1.default) `
|
|
313
|
-
|
|
314
|
-
#### Variables
|
|
315
|
-
\`\`\`json
|
|
316
|
-
${JSON.stringify(this.payload.variables, null, 2)}
|
|
317
|
-
\`\`\`
|
|
318
|
-
`;
|
|
319
|
-
}
|
|
320
|
-
return options;
|
|
321
|
-
}
|
|
322
245
|
}
|
|
323
246
|
exports.ClientError = ClientError;
|
|
324
247
|
class YarnNotFoundError extends BaseError {
|
|
@@ -333,9 +256,7 @@ class YarnNotFoundError extends BaseError {
|
|
|
333
256
|
}
|
|
334
257
|
body() {
|
|
335
258
|
return (0, ts_dedent_1.default) `
|
|
336
|
-
Yarn
|
|
337
|
-
|
|
338
|
-
Please install Yarn by running:
|
|
259
|
+
Yarn must be installed to sync your application. You can install it by running:
|
|
339
260
|
|
|
340
261
|
$ npm install --global yarn
|
|
341
262
|
|
|
@@ -410,7 +331,7 @@ class InvalidSyncFileError extends BaseError {
|
|
|
410
331
|
|
|
411
332
|
~/gadget/${this.app || "<name of app>"}
|
|
412
333
|
|
|
413
|
-
Otherwise, if you're sure you want to sync the contents of
|
|
334
|
+
Otherwise, if you're sure you want to sync the contents of that directory to Gadget, run \`ggt sync\` again with the \`--force\` flag:
|
|
414
335
|
|
|
415
336
|
$ ggt sync ${this.sync.argv.join(" ")} --force
|
|
416
337
|
|
|
@@ -419,11 +340,29 @@ class InvalidSyncFileError extends BaseError {
|
|
|
419
340
|
}
|
|
420
341
|
}
|
|
421
342
|
exports.InvalidSyncFileError = InvalidSyncFileError;
|
|
343
|
+
class InvalidSyncAppFlagError extends FlagError {
|
|
344
|
+
constructor(sync, app) {
|
|
345
|
+
super({ name: "app", char: "a" }, (0, ts_dedent_1.default) `
|
|
346
|
+
You were about to sync the following app to the following directory:
|
|
347
|
+
|
|
348
|
+
${app} → ${sync.dir}
|
|
349
|
+
|
|
350
|
+
However, that directory has already been synced with this app:
|
|
351
|
+
|
|
352
|
+
${sync.metadata.app}
|
|
353
|
+
|
|
354
|
+
If you're sure that you want to sync "${app}" to "${sync.dir}", run \`ggt sync\` again with the \`--force\` flag:
|
|
355
|
+
|
|
356
|
+
$ ggt sync ${sync.argv.join(" ")} --force
|
|
357
|
+
`);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
exports.InvalidSyncAppFlagError = InvalidSyncAppFlagError;
|
|
422
361
|
function isCloseEvent(e) {
|
|
423
362
|
return !(0, lodash_1.isNil)(e) && (0, lodash_1.isString)(e.type) && (0, lodash_1.isNumber)(e.code) && (0, lodash_1.isString)(e.reason) && (0, lodash_1.isBoolean)(e.wasClean);
|
|
424
363
|
}
|
|
425
364
|
function isErrorEvent(e) {
|
|
426
|
-
return !(0, lodash_1.isNil)(e) && (0, lodash_1.isString)(e.type) && (0, lodash_1.isString)(e.message) && (0, lodash_1.
|
|
365
|
+
return !(0, lodash_1.isNil)(e) && (0, lodash_1.isString)(e.type) && (0, lodash_1.isString)(e.message) && !(0, lodash_1.isNil)(e.error);
|
|
427
366
|
}
|
|
428
367
|
function isGraphQLErrors(e) {
|
|
429
368
|
return (0, lodash_1.isArray)(e) && e.every((e) => !(0, lodash_1.isNil)(e) && (0, lodash_1.isString)(e.message) && (0, lodash_1.isArray)(e.locations ?? []) && (0, lodash_1.isArray)(e.path ?? []));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":";;;;AAAA,sEAAqC;AACrC,6BAAgC;AAEhC,mCAA8F;AAC9F,qDAAuE;AACvE,kEAA+B;AAE/B,+BAA+B;AAI/B,uCAAoC;AACpC,6DAAuC;AACvC,oDAAoB;AAEpB,IAAI,iBAAO,CAAC,GAAG,CAAC,cAAc,EAAE;IAC9B,MAAM,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,2EAA2E,EAAE,CAAC,CAAC;CACnG;AAED;;;;GAIG;AACH,MAAsB,SAAU,SAAQ,KAAK;IA0B3C,YAAY,IAAY,EAAE,OAAe;QACvC,KAAK,CAAC,OAAO,CAAC,CAAC;QA1BjB;;WAEG;QACH;;;;;WAAa;QAEb;;WAEG;QACH;;;;;WAAuB;QAEvB;;WAEG;QACH;;;;;WAAqB;QAErB;;WAEG;QACH;;;;;WAAwB;QAStB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,KAAK,CAAC,iBAAiB,CAA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I,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 * as Sentry from \"@sentry/node\";\nimport os from \"os\";\n\nif (context.env.productionLike) {\n Sentry.init({ dsn: \"https://0c26e0d8afd94e77a88ee1c3aa9e7065@o250689.ingest.sentry.io/6703266\" });\n}\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?: string;\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 this.sentryEventId = Sentry.captureException(this, {\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 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${this.sentryEventId ? `&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 constructor(readonly flag: T, readonly description: string) {\n const name = flag.char ? `-${flag.char}, --${flag.name}` : `--${flag.name}`;\n super(\"GGT_CLI_FLAG_ERROR\", `Invalid value provided for the ${name} flag`);\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, app: string) {\n super(\n { name: \"app\", char: \"a\" },\n dedent`\n You were about to sync the following app to the following directory:\n\n ${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 \"${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"]}
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flags.js","sourceRoot":"","sources":["../../src/utils/flags.ts"],"names":[],"mappings":";;;;AAAA,sCAAoC;AACpC,gFAA2C;AAC3C,mCAAgC;AAChC,kEAA+B;AAC/B,uCAAoC;AACpC,qCAAqC;AAExB,QAAA,GAAG,GAAG,YAAK,CAAC,MAAM,CAAC;IAC9B,IAAI,EAAE,GAAG;IACT,IAAI,EAAE,KAAK;IACX,OAAO,EAAE,iDAAiD;IAC1D,KAAK,EAAE,KAAK,EAAE,KAAa,EAAE,EAAE;QAC7B,MAAM,IAAI,GAAG,sCAAsC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC,MAAM,CAAC,CAAC;QAClF,IAAI,CAAC,IAAI;YACP,MAAM,IAAI,kBAAS,CACjB,WAAG,EACH,IAAA,mBAAM,EAAA;;;;;;;;;SASL,CACF,CAAC;QAEJ,MAAM,aAAa,GAAG,MAAM,iBAAO,CAAC,gBAAgB,EAAE,CAAC;QACvD,MAAM,QAAQ,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,IAAI,IAAI,CAAC,CAAC,IAAI,IAAI,IAAI,CAAC,CAAC;QAC7E,IAAI,QAAQ,EAAE;YACZ,OAAO,QAAQ,CAAC,IAAI,CAAC;SACtB;QAED,MAAM,IAAI,kBAAS,CACjB,WAAG,EACH,aAAa,CAAC,MAAM,GAAG,CAAC;YACtB,CAAC,CAAC,IAAA,mBAAM,EAAA;;;kBAGE,KAAK;;;;kBAIL,IAAA,eAAM,EAAC,aAAa,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,0BAAW,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;iBAC9D,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC;iBACZ,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,KAAK,GAAG,CAAC,IAAI,EAAE,CAAC;iBAC7B,IAAI,CAAC,IAAI,CAAC;aAChB;YACL,CAAC,CAAC,IAAA,mBAAM,EAAA;;;kBAGE,KAAK;;;;;aAKV,CACR,CAAC;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import { Flags } from \"@oclif/core\";\nimport levenshtein from \"fast-levenshtein\";\nimport { sortBy } from \"lodash\";\nimport dedent from \"ts-dedent\";\nimport { context } from \"./context\";\nimport { FlagError } from \"./errors\";\n\nexport const app = Flags.custom({\n char: \"a\",\n name: \"app\",\n summary: \"The Gadget application this command applies to.\",\n parse: async (value: string) => {\n const name = /^(https:\\/\\/)?(?<name>[\\w-]+)(\\..*)?/.exec(value)?.groups?.[\"name\"];\n if (!name)\n throw new FlagError(\n app,\n dedent`\n The -a, --app flag must be the application's name, slug, or URL\n\n Examples:\n\n --app my-app\n --app my-app.gadget.app\n --app https://my-app.gadget.app\n --app https://my-app.gadget.app/edit\n `\n );\n\n const availableApps = await context.getAvailableApps();\n const foundApp = availableApps.find((a) => a.name == name || a.slug == name);\n if (foundApp) {\n return foundApp.slug;\n }\n\n throw new FlagError(\n app,\n availableApps.length > 0\n ? dedent`\n Unknown application:\n\n ${value}\n\n Did you mean one of these?\n\n ${sortBy(availableApps, (app) => levenshtein.get(app.slug, name))\n .slice(0, 10)\n .map((app) => `* ${app.slug}`)\n .join(\"\\n\")}\n `\n : dedent`\n Unknown application:\n\n ${value}\n\n It doesn't look like you have any applications.\n\n Visit https://gadget.new to create one!\n `\n );\n },\n});\n"]}
|
|
File without changes
|
|
@@ -36,7 +36,7 @@ class Ignorer {
|
|
|
36
36
|
this.reload();
|
|
37
37
|
}
|
|
38
38
|
ignores(filepath) {
|
|
39
|
-
const relative = path_1.default.relative(this._rootDir, filepath);
|
|
39
|
+
const relative = path_1.default.isAbsolute(filepath) ? path_1.default.relative(this._rootDir, filepath) : filepath;
|
|
40
40
|
if (relative == "")
|
|
41
41
|
return false;
|
|
42
42
|
return this._ignorer.ignores(relative);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs-utils.js","sourceRoot":"","sources":["../../src/utils/fs-utils.ts"],"names":[],"mappings":";;;;AAAA,0DAA0B;AAC1B,gEAA0B;AAE1B,4DAA4B;AAC5B,wDAAwB;AAExB,MAAM,KAAK,GAAG,IAAA,eAAK,EAAC,cAAc,CAAC,CAAC;AAEpC,MAAa,OAAO;IAKlB,YAA6B,QAAgB,EAAmB,aAAuB;;;;;mBAA1D;;;;;;mBAAmC;;QAJhE;;;;mBAAoB,cAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC;WAAC;QAExD;;;;;WAA0B;QAGxB,IAAI,CAAC,MAAM,EAAE,CAAC;IAChB,CAAC;IAED,OAAO,CAAC,QAAgB;QACtB,MAAM,QAAQ,GAAG,cAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,cAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;QAC/F,IAAI,QAAQ,IAAI,EAAE;YAAE,OAAO,KAAK,CAAC;QACjC,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACzC,CAAC;IAED,MAAM;QACJ,IAAI,CAAC,QAAQ,GAAG,IAAA,gBAAM,GAAE,CAAC;QACzB,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAEtC,IAAI;YACF,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,kBAAE,CAAC,YAAY,CAAC,IAAI,CAAC,QAAQ,EAAE,OAA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CAAC;SACvC;aAAM,IAAI,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,QAAQ,CAAC,EAAE;YAChE,MAAM,QAAQ,CAAC;SAChB;KACF;AACH,CAAC;AAXD,kCAWC;AAEM,KAAK,UAAU,UAAU,CAAC,GAAW,EAAE,IAAI,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE;IACzE,IAAI;QACF,MAAM,KAAK,GAAG,MAAM,kBAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACpC,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC;KAC3B;IAAC,OAAO,KAAK,EAAE;QACd,IAAI,IAAI,CAAC,YAAY,EAAE;YACrB,YAAY,CAAC,KAAK,CAAC,CAAC;YACpB,OAAO,IAAI,CAAC;SACb;QACD,MAAM,KAAK,CAAC;KACb;AACH,CAAC;AAXD,gCAWC;AAED,SAAgB,YAAY,CAAC,KAAU;IACrC,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE;QAC3B,KAAK,CAAC,0BAA0B,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QAC9C,OAAO;KACR;IACD,MAAM,KAAK,CAAC;AACd,CAAC;AAND,oCAMC","sourcesContent":["import Debug from \"debug\";\nimport fs from \"fs-extra\";\nimport type { Ignore } from \"ignore\";\nimport ignore from \"ignore\";\nimport path from \"path\";\n\nconst debug = Debug(\"ggt:fs-utils\");\n\nexport class Ignorer {\n readonly filepath = path.join(this._rootDir, \".ignore\");\n\n private _ignorer!: Ignore;\n\n constructor(private readonly _rootDir: string, private readonly _alwaysIgnore: string[]) {\n this.reload();\n }\n\n ignores(filepath: string): boolean {\n const relative = path.isAbsolute(filepath) ? path.relative(this._rootDir, filepath) : filepath;\n if (relative == \"\") return false;\n return this._ignorer.ignores(relative);\n }\n\n reload(): void {\n this._ignorer = ignore();\n this._ignorer.add(this._alwaysIgnore);\n\n try {\n this._ignorer.add(fs.readFileSync(this.filepath, \"utf-8\"));\n debug(\"reloaded ignore rules from %s\", this.filepath);\n } catch (error) {\n ignoreEnoent(error);\n }\n }\n}\n\nexport interface WalkDirOptions {\n ignorer?: Ignorer;\n maxFiles?: number;\n}\n\nexport async function* walkDir(dir: string, options: WalkDirOptions = {}): AsyncGenerator<string> {\n if (options.ignorer?.ignores(dir)) return;\n\n for await (const entry of await fs.opendir(dir)) {\n const filepath = path.join(dir, entry.name);\n if (entry.isDirectory()) {\n yield* walkDir(filepath, options);\n } else if (entry.isFile() && !options.ignorer?.ignores(filepath)) {\n yield filepath;\n }\n }\n}\n\nexport function* walkDirSync(dir: string, options: WalkDirOptions = {}): Generator<string> {\n if (options.ignorer?.ignores(dir)) return;\n\n for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {\n const filepath = path.join(dir, entry.name);\n if (entry.isDirectory()) {\n yield* walkDirSync(filepath, options);\n } else if (entry.isFile() && !options.ignorer?.ignores(filepath)) {\n yield filepath;\n }\n }\n}\n\nexport async function isEmptyDir(dir: string, opts = { ignoreEnoent: true }): Promise<boolean> {\n try {\n const files = await fs.readdir(dir);\n return files.length === 0;\n } catch (error) {\n if (opts.ignoreEnoent) {\n ignoreEnoent(error);\n return true;\n }\n throw error;\n }\n}\n\nexport function ignoreEnoent(error: any): void {\n if (error.code === \"ENOENT\") {\n debug(\"ignoring ENOENT error %s\", error.path);\n return;\n }\n throw error;\n}\n"]}
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"help.js","sourceRoot":"","sources":["../../src/utils/help.ts"],"names":[],"mappings":";;AAAA,sCAAiF;AAEjF,MAAqB,IAAK,SAAQ,WAAS;IAA3C;;QACE;;;;mBAA4B,WAAW;WAAC;IAC1C,CAAC;CAAA;AAFD,uBAEC;AAED,MAAM,WAAY,SAAQ,kBAAgB;IACxC;;;;;OAKG;IACgB,WAAW;QAC5B,IAAI,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE;YAC5B,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC;SACjC;QACD,OAAO,KAAK,CAAC,WAAW,EAAE,CAAC;IAC7B,CAAC;CACF","sourcesContent":["import { CommandHelp as OclifCommandHelp, Help as OclifHelp } from \"@oclif/core\";\n\nexport default class Help extends OclifHelp {\n override CommandHelpClass = CommandHelp;\n}\n\nclass CommandHelp extends OclifCommandHelp {\n /**\n * By default, oclif tries to format the description so that it fit's within the terminal window. However, if the description is already\n * formatted with `dedent`, then the description gets mangled and the help output is not pretty.\n *\n * This overrides the default behavior to just use the description as-is if it already exists.\n */\n protected override description(): string | undefined {\n if (this.command.description) {\n return this.command.description;\n }\n return super.description();\n }\n}\n"]}
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sleep.js","sourceRoot":"","sources":["../../src/utils/sleep.ts"],"names":[],"mappings":";;;AAAA,SAAgB,KAAK,CAAC,EAAE,GAAG,CAAC;IAC1B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;AAC/F,CAAC;AAFD,sBAEC;AAEM,KAAK,UAAU,UAAU,CAAC,EAAiB,EAAE,EAAE,QAAQ,GAAG,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE;IACjH,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;IAE9C,iDAAiD;IACjD,OAAO,IAAI,EAAE;QACX,IAAI,EAAE,EAAE;YAAE,OAAO;QACjB,MAAM,KAAK,CAAC,QAAQ,CAAC,CAAC;QAEtB,IAAI,KAAK,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,GAAG,OAAO,EAAE;YACzC,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,mBAAmB,OAAO,eAAe,CAAC,CAAC;YACnE,KAAK,CAAC,iBAAiB,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;YAC3C,MAAM,KAAK,CAAC;SACb;KACF;AACH,CAAC;AAdD,gCAcC","sourcesContent":["export function sleep(ms = 0): Promise<void> {\n return new Promise((resolve) => (ms == 0 ? setImmediate(resolve) : setTimeout(resolve, ms)));\n}\n\nexport async function sleepUntil(fn: () => boolean, { interval = 0, timeout = process.env[\"CI\"] ? 5000 : 500 } = {}): Promise<void> {\n const start = isFinite(timeout) && Date.now();\n\n // eslint-disable-next-line no-constant-condition\n while (true) {\n if (fn()) return;\n await sleep(interval);\n\n if (start && Date.now() - start > timeout) {\n const error = new Error(`Timed out after ${timeout} milliseconds`);\n Error.captureStackTrace(error, sleepUntil);\n throw error;\n }\n }\n}\n"]}
|