@gadgetinc/ggt 0.1.6 → 0.1.7
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 +5 -5
- package/lib/lib/base-command.js +1 -1
- package/lib/lib/base-command.js.map +1 -1
- package/lib/lib/errors.d.ts +4 -3
- package/lib/lib/errors.js +19 -88
- package/lib/lib/errors.js.map +1 -1
- package/npm-shrinkwrap.json +2 -16
- package/oclif.manifest.json +1 -1
- package/package.json +2 -3
package/README.md
CHANGED
|
@@ -119,7 +119,7 @@ EXAMPLES
|
|
|
119
119
|
$ ggt sync --app https://my-app.gadget.app/edit
|
|
120
120
|
```
|
|
121
121
|
|
|
122
|
-
_See code: [src/commands/sync.ts](https://github.com/gadget-inc/ggt/blob/v0.1.
|
|
122
|
+
_See code: [src/commands/sync.ts](https://github.com/gadget-inc/ggt/blob/v0.1.7/src/commands/sync.ts)_
|
|
123
123
|
|
|
124
124
|
### `ggt help [COMMAND]`
|
|
125
125
|
|
|
@@ -133,7 +133,7 @@ ARGUMENTS
|
|
|
133
133
|
COMMAND The command to show help for.
|
|
134
134
|
```
|
|
135
135
|
|
|
136
|
-
_See code: [src/commands/help.ts](https://github.com/gadget-inc/ggt/blob/v0.1.
|
|
136
|
+
_See code: [src/commands/help.ts](https://github.com/gadget-inc/ggt/blob/v0.1.7/src/commands/help.ts)_
|
|
137
137
|
|
|
138
138
|
### `ggt login`
|
|
139
139
|
|
|
@@ -149,7 +149,7 @@ EXAMPLES
|
|
|
149
149
|
Hello, Jane Doe (jane@example.com)
|
|
150
150
|
```
|
|
151
151
|
|
|
152
|
-
_See code: [src/commands/login.ts](https://github.com/gadget-inc/ggt/blob/v0.1.
|
|
152
|
+
_See code: [src/commands/login.ts](https://github.com/gadget-inc/ggt/blob/v0.1.7/src/commands/login.ts)_
|
|
153
153
|
|
|
154
154
|
### `ggt logout`
|
|
155
155
|
|
|
@@ -164,7 +164,7 @@ EXAMPLES
|
|
|
164
164
|
Goodbye
|
|
165
165
|
```
|
|
166
166
|
|
|
167
|
-
_See code: [src/commands/logout.ts](https://github.com/gadget-inc/ggt/blob/v0.1.
|
|
167
|
+
_See code: [src/commands/logout.ts](https://github.com/gadget-inc/ggt/blob/v0.1.7/src/commands/logout.ts)_
|
|
168
168
|
|
|
169
169
|
### `ggt whoami`
|
|
170
170
|
|
|
@@ -179,7 +179,7 @@ EXAMPLES
|
|
|
179
179
|
You are logged in as Jane Doe (jane@example.com)
|
|
180
180
|
```
|
|
181
181
|
|
|
182
|
-
_See code: [src/commands/whoami.ts](https://github.com/gadget-inc/ggt/blob/v0.1.
|
|
182
|
+
_See code: [src/commands/whoami.ts](https://github.com/gadget-inc/ggt/blob/v0.1.7/src/commands/whoami.ts)_
|
|
183
183
|
|
|
184
184
|
<!-- commandsstop -->
|
|
185
185
|
|
package/lib/lib/base-command.js
CHANGED
|
@@ -136,8 +136,8 @@ class BaseCommand extends core_1.Command {
|
|
|
136
136
|
*/
|
|
137
137
|
async catch(cause) {
|
|
138
138
|
const error = cause instanceof errors_2.BaseError ? cause : new errors_2.UnexpectedError(cause);
|
|
139
|
-
console.error(error.render());
|
|
140
139
|
await error.capture();
|
|
140
|
+
console.error(error.render());
|
|
141
141
|
// The original implementation of `catch` re-throws the error so that it's caught and printed by oclif's `handle` method. We still want
|
|
142
142
|
// to end up in oclif's `handle` method, but we don't want it to print the error again so we throw an ExitError instead. This will cause
|
|
143
143
|
// `handle` to not print the error, but still exit with the correct exit code.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-command.js","sourceRoot":"","sources":["../../src/lib/base-command.ts"],"names":[],"mappings":";;;;AACA,sCAAuD;AACvD,mDAAmD;AACnD,0DAA0B;AAC1B,gEAA+B;AAE/B,+BAAoC;AACpC,uCAAkC;AAElC,iDAAuC;AAMvC,wDAAwB;AACxB,wDAAwB;AACxB,uCAAqD;AACrD,qCAAsE;AAEtE,MAAsB,WAAY,SAAQ,cAAO;IAsB/C,Y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G,CAAC,QAAQ,EAAE,CAAC,CAAC;YAE3B,IAAI,CAAC,GAAG,CAAC,8DAA8D,CAAC,CAAC;YAEzE,MAAM,cAAc,CAAC;SACtB;gBAAS;YACR,MAAM,EAAE,KAAK,EAAE,CAAC;SACjB;IACH,CAAC;IAED;;;OAGG;IACM,KAAK,CAAC,KAAK,CAAC,KAAoC;QACvD,MAAM,KAAK,GAAG,KAAK,YAAY,kBAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,wBAAY,CAAC,KAAK,CAAC,CAAC;QAC3E,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;QAC9B,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC;QAEtB,uIAAuI;QACvI,wIAAwI;QACxI,8EAA8E;QAC9E,EAAE;QACF,0GAA0G;QAC1G,+GAA+G;QAC/G,MAAM,IAAI,kBAAS,CAAC,OAAO,CAAC,QAAQ,IAAI,KAAK,CAAC,QAAQ,IAAI,CAAC,CAAC,CAAC;IAC/D,CAAC;;AA1KH,kCA2KC;AA1KC;;;GAGG;AACI;;;;WAAW,QAAQ;GAAC;AAEpB;;;;WAAuB;QAC5B,KAAK,EAAE,YAAK,CAAC,OAAO,CAAC;YACnB,IAAI,EAAE,GAAG;YACT,OAAO,EAAE,sCAAsC;YAC/C,SAAS,EAAE,QAAQ;YACnB,OAAO,EAAE,KAAK;SACf,CAAC;KACH;GAAC","sourcesContent":["import type { Config } from \"@oclif/core\";\nimport { Command, Flags, settings } from \"@oclif/core\";\nimport { ExitError } from \"@oclif/core/lib/errors\";\nimport Debug from \"debug\";\nimport getPort from \"get-port\";\nimport type { Server } from \"http\";\nimport { createServer } from \"http\";\nimport { prompt } from \"inquirer\";\nimport type { Notification } from \"node-notifier\";\nimport { notify } from \"node-notifier\";\nimport type WindowsBalloon from \"node-notifier/notifiers/balloon\";\nimport type Growl from \"node-notifier/notifiers/growl\";\nimport type NotificationCenter from \"node-notifier/notifiers/notificationcenter\";\nimport type NotifySend from \"node-notifier/notifiers/notifysend\";\nimport type WindowsToaster from \"node-notifier/notifiers/toaster\";\nimport open from \"open\";\nimport path from \"path\";\nimport { context, GADGET_ENDPOINT } from \"./context\";\nimport { BaseError, UnexpectedError as UnknownError } from \"./errors\";\n\nexport abstract class BaseCommand extends Command {\n /**\n * Determines how high the command is listed in the README. The lower the number, the higher the command is listed. Equal numbers are\n * sorted alphabetically.\n */\n static priority = Infinity;\n\n static override globalFlags = {\n debug: Flags.boolean({\n char: \"D\",\n summary: \"Whether to output debug information.\",\n helpGroup: \"global\",\n default: false,\n }),\n };\n\n /**\n * Determines whether the command requires the user to be logged in or not.\n * If true and the user is not logged in, the user will be prompted to login before the command is run.\n */\n readonly requireUser: boolean = false;\n\n constructor(argv: string[], config: Config) {\n super(argv, config);\n\n // TODO: Remove this once the `@oclif/core` warnIfFlagDeprecated function checks global flags as well.\n // warnIfFlagDeprecated throws a null pointer because it assumes all parsed flags are in the flags object (which is not the case for global flags).\n // https://github.com/oclif/core/blob/11c5752cec838d08bb27cd55f0f1aa2390df3c5e/src/command.ts#L259\n this.ctor.flags = { ...this.ctor.flags, ...BaseCommand.globalFlags };\n }\n\n /**\n * Indicates whether the command is being run with the `-D/--debug` flag.\n */\n get debugEnabled(): boolean {\n return !!settings.debug;\n }\n\n override async init(): Promise<void> {\n await super.init();\n const { flags, argv } = await this.parse({ flags: BaseCommand.globalFlags, strict: false });\n\n // remove global flags from argv so that when the implementation calls parse, it doesn't get confused by them\n this.argv = argv;\n\n if (flags.debug) {\n settings.debug = true;\n Debug.enable(`${this.config.bin}:*`);\n }\n\n context.config = this.config;\n\n if (this.requireUser && !(await context.getUser())) {\n const { login } = await prompt<{ login: boolean }>({\n type: \"confirm\",\n name: \"login\",\n message: \"You must be logged in to use this command. Would you like to log in?\",\n });\n\n if (!login) {\n return this.exit(0);\n }\n\n await this.login();\n }\n }\n\n /**\n * Sends a native OS notification to the user.\n *\n * @see {@link https://www.npmjs.com/package/node-notifier node-notifier}\n */\n notify(\n notification:\n | Notification\n | NotificationCenter.Notification\n | NotifySend.Notification\n | WindowsToaster.Notification\n | WindowsBalloon.Notification\n | Growl.Notification\n ): void {\n notify(\n {\n title: \"Gadget\",\n contentImage: path.join(this.config.root, \"assets\", \"favicon-128@4x.png\"),\n icon: path.join(this.config.root, \"assets\", \"favicon-128@4x.png\"),\n sound: true,\n timeout: false,\n ...notification,\n },\n (error) => {\n if (error) this.warn(error);\n }\n );\n }\n\n /**\n * Opens the Gadget login page in the user's default browser and waits for the user to login.\n */\n async login(): Promise<void> {\n let server: Server | undefined;\n\n try {\n const port = await getPort();\n const receiveSession = new Promise<void>((resolve, reject) => {\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n server = createServer(async (req, res) => {\n const redirectTo = new URL(`${GADGET_ENDPOINT}/auth/cli`);\n\n try {\n if (!req.url) throw new Error(\"missing url\");\n const incomingUrl = new URL(req.url, `http://localhost:${port}`);\n\n const value = incomingUrl.searchParams.get(\"session\");\n if (!value) throw new Error(\"missing session\");\n\n context.session = value;\n\n const user = await context.getUser();\n if (!user) throw new Error(\"missing current user\");\n\n if (user.name) {\n this.log(`Hello, ${user.name} (${user.email})`);\n } else {\n this.log(`Hello, ${user.email}`);\n }\n\n redirectTo.searchParams.set(\"success\", \"true\");\n resolve();\n } catch (error) {\n context.session = undefined;\n redirectTo.searchParams.set(\"success\", \"false\");\n reject(error);\n } finally {\n res.writeHead(303, { Location: redirectTo.toString() });\n res.end();\n }\n });\n\n server.listen(port);\n });\n\n const url = new URL(`${GADGET_ENDPOINT}/auth/login`);\n url.searchParams.set(\"returnTo\", `${GADGET_ENDPOINT}/auth/cli/callback?port=${port}`);\n await open(url.toString());\n\n this.log(\"Your browser has been opened. Please log in to your account.\");\n\n await receiveSession;\n } finally {\n server?.close();\n }\n }\n\n /**\n * Overrides the default `catch` behavior so we can control how errors are printed to the user. This is called automatically by oclif when\n * an error is thrown during the `init` or `run` methods.\n */\n override async catch(cause: Error & { exitCode?: number }): Promise<never> {\n const error = cause instanceof BaseError ? cause : new UnknownError(cause);\n console.error(error.render());\n await error.capture();\n\n // The original implementation of `catch` re-throws the error so that it's caught and printed by oclif's `handle` method. We still want\n // to end up in oclif's `handle` method, but we don't want it to print the error again so we throw an ExitError instead. This will cause\n // `handle` to not print the error, but still exit with the correct exit code.\n //\n // catch: https://github.com/oclif/core/blob/12e31ff2288606e583e03bf774a3244f3136cd10/src/command.ts#L261\n // handle: https://github.com/oclif/core/blob/12e31ff2288606e583e03bf774a3244f3136cd10/src/errors/handle.ts#L15\n throw new ExitError(process.exitCode ?? cause.exitCode ?? 1);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"base-command.js","sourceRoot":"","sources":["../../src/lib/base-command.ts"],"names":[],"mappings":";;;;AACA,sCAAuD;AACvD,mDAAmD;AACnD,0DAA0B;AAC1B,gEAA+B;AAE/B,+BAAoC;AACpC,uCAAkC;AAElC,iDAAuC;AAMvC,wDAAwB;AACxB,wDAAwB;AACxB,uCAAqD;AACrD,qCAAsE;AAEtE,MAAsB,WAAY,SAAQ,cAAO;IAsB/C,YAAY,IAAc,EAAE,MAAc;QACxC,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAPtB;;;WAGG;QACH;;;;mBAAgC,KAAK;WAAC;QAKpC,sGAAsG;QACtG,mJAAmJ;QACnJ,kGAAkG;QAClG,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,WAAW,CAAC,WAAW,EAAE,CAAC;IACvE,CAAC;IAED;;OAEG;IACH,IAAI,YAAY;QACd,OAAO,CAAC,CAAC,eAAQ,CAAC,KAAK,CAAC;IAC1B,CAAC;IAEQ,KAAK,CAAC,IAAI;QACjB,MAAM,KAAK,CAAC,IAAI,EAAE,CAAC;QACnB,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK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AC1G,+GAA+G;QAC/G,MAAM,IAAI,kBAAS,CAAC,OAAO,CAAC,QAAQ,IAAI,KAAK,CAAC,QAAQ,IAAI,CAAC,CAAC,CAAC;IAC/D,CAAC;;AA1KH,kCA2KC;AA1KC;;;GAGG;AACI;;;;WAAW,QAAQ;GAAC;AAEpB;;;;WAAuB;QAC5B,KAAK,EAAE,YAAK,CAAC,OAAO,CAAC;YACnB,IAAI,EAAE,GAAG;YACT,OAAO,EAAE,sCAAsC;YAC/C,SAAS,EAAE,QAAQ;YACnB,OAAO,EAAE,KAAK;SACf,CAAC;KACH;GAAC","sourcesContent":["import type { Config } from \"@oclif/core\";\nimport { Command, Flags, settings } from \"@oclif/core\";\nimport { ExitError } from \"@oclif/core/lib/errors\";\nimport Debug from \"debug\";\nimport getPort from \"get-port\";\nimport type { Server } from \"http\";\nimport { createServer } from \"http\";\nimport { prompt } from \"inquirer\";\nimport type { Notification } from \"node-notifier\";\nimport { notify } from \"node-notifier\";\nimport type WindowsBalloon from \"node-notifier/notifiers/balloon\";\nimport type Growl from \"node-notifier/notifiers/growl\";\nimport type NotificationCenter from \"node-notifier/notifiers/notificationcenter\";\nimport type NotifySend from \"node-notifier/notifiers/notifysend\";\nimport type WindowsToaster from \"node-notifier/notifiers/toaster\";\nimport open from \"open\";\nimport path from \"path\";\nimport { context, GADGET_ENDPOINT } from \"./context\";\nimport { BaseError, UnexpectedError as UnknownError } from \"./errors\";\n\nexport abstract class BaseCommand extends Command {\n /**\n * Determines how high the command is listed in the README. The lower the number, the higher the command is listed. Equal numbers are\n * sorted alphabetically.\n */\n static priority = Infinity;\n\n static override globalFlags = {\n debug: Flags.boolean({\n char: \"D\",\n summary: \"Whether to output debug information.\",\n helpGroup: \"global\",\n default: false,\n }),\n };\n\n /**\n * Determines whether the command requires the user to be logged in or not.\n * If true and the user is not logged in, the user will be prompted to login before the command is run.\n */\n readonly requireUser: boolean = false;\n\n constructor(argv: string[], config: Config) {\n super(argv, config);\n\n // TODO: Remove this once the `@oclif/core` warnIfFlagDeprecated function checks global flags as well.\n // warnIfFlagDeprecated throws a null pointer because it assumes all parsed flags are in the flags object (which is not the case for global flags).\n // https://github.com/oclif/core/blob/11c5752cec838d08bb27cd55f0f1aa2390df3c5e/src/command.ts#L259\n this.ctor.flags = { ...this.ctor.flags, ...BaseCommand.globalFlags };\n }\n\n /**\n * Indicates whether the command is being run with the `-D/--debug` flag.\n */\n get debugEnabled(): boolean {\n return !!settings.debug;\n }\n\n override async init(): Promise<void> {\n await super.init();\n const { flags, argv } = await this.parse({ flags: BaseCommand.globalFlags, strict: false });\n\n // remove global flags from argv so that when the implementation calls parse, it doesn't get confused by them\n this.argv = argv;\n\n if (flags.debug) {\n settings.debug = true;\n Debug.enable(`${this.config.bin}:*`);\n }\n\n context.config = this.config;\n\n if (this.requireUser && !(await context.getUser())) {\n const { login } = await prompt<{ login: boolean }>({\n type: \"confirm\",\n name: \"login\",\n message: \"You must be logged in to use this command. Would you like to log in?\",\n });\n\n if (!login) {\n return this.exit(0);\n }\n\n await this.login();\n }\n }\n\n /**\n * Sends a native OS notification to the user.\n *\n * @see {@link https://www.npmjs.com/package/node-notifier node-notifier}\n */\n notify(\n notification:\n | Notification\n | NotificationCenter.Notification\n | NotifySend.Notification\n | WindowsToaster.Notification\n | WindowsBalloon.Notification\n | Growl.Notification\n ): void {\n notify(\n {\n title: \"Gadget\",\n contentImage: path.join(this.config.root, \"assets\", \"favicon-128@4x.png\"),\n icon: path.join(this.config.root, \"assets\", \"favicon-128@4x.png\"),\n sound: true,\n timeout: false,\n ...notification,\n },\n (error) => {\n if (error) this.warn(error);\n }\n );\n }\n\n /**\n * Opens the Gadget login page in the user's default browser and waits for the user to login.\n */\n async login(): Promise<void> {\n let server: Server | undefined;\n\n try {\n const port = await getPort();\n const receiveSession = new Promise<void>((resolve, reject) => {\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n server = createServer(async (req, res) => {\n const redirectTo = new URL(`${GADGET_ENDPOINT}/auth/cli`);\n\n try {\n if (!req.url) throw new Error(\"missing url\");\n const incomingUrl = new URL(req.url, `http://localhost:${port}`);\n\n const value = incomingUrl.searchParams.get(\"session\");\n if (!value) throw new Error(\"missing session\");\n\n context.session = value;\n\n const user = await context.getUser();\n if (!user) throw new Error(\"missing current user\");\n\n if (user.name) {\n this.log(`Hello, ${user.name} (${user.email})`);\n } else {\n this.log(`Hello, ${user.email}`);\n }\n\n redirectTo.searchParams.set(\"success\", \"true\");\n resolve();\n } catch (error) {\n context.session = undefined;\n redirectTo.searchParams.set(\"success\", \"false\");\n reject(error);\n } finally {\n res.writeHead(303, { Location: redirectTo.toString() });\n res.end();\n }\n });\n\n server.listen(port);\n });\n\n const url = new URL(`${GADGET_ENDPOINT}/auth/login`);\n url.searchParams.set(\"returnTo\", `${GADGET_ENDPOINT}/auth/cli/callback?port=${port}`);\n await open(url.toString());\n\n this.log(\"Your browser has been opened. Please log in to your account.\");\n\n await receiveSession;\n } finally {\n server?.close();\n }\n }\n\n /**\n * Overrides the default `catch` behavior so we can control how errors are printed to the user. This is called automatically by oclif when\n * an error is thrown during the `init` or `run` methods.\n */\n override async catch(cause: Error & { exitCode?: number }): Promise<never> {\n const error = cause instanceof BaseError ? cause : new UnknownError(cause);\n await error.capture();\n console.error(error.render());\n\n // The original implementation of `catch` re-throws the error so that it's caught and printed by oclif's `handle` method. We still want\n // to end up in oclif's `handle` method, but we don't want it to print the error again so we throw an ExitError instead. This will cause\n // `handle` to not print the error, but still exit with the correct exit code.\n //\n // catch: https://github.com/oclif/core/blob/12e31ff2288606e583e03bf774a3244f3136cd10/src/command.ts#L261\n // handle: https://github.com/oclif/core/blob/12e31ff2288606e583e03bf774a3244f3136cd10/src/errors/handle.ts#L15\n throw new ExitError(process.exitCode ?? cause.exitCode ?? 1);\n }\n}\n"]}
|
package/lib/lib/errors.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { GraphQLError } from "graphql";
|
|
2
|
-
import newGithubIssueUrl from "new-github-issue-url";
|
|
3
2
|
import type { CloseEvent, ErrorEvent } from "ws";
|
|
4
3
|
import type Sync from "../commands/sync";
|
|
5
4
|
import type { Payload } from "./client";
|
|
@@ -13,6 +12,10 @@ export declare abstract class BaseError extends Error {
|
|
|
13
12
|
* A GGT_CLI_SOMETHING human/machine readable unique identifier for this error.
|
|
14
13
|
*/
|
|
15
14
|
code: string;
|
|
15
|
+
/**
|
|
16
|
+
* The Sentry event ID for this error.
|
|
17
|
+
*/
|
|
18
|
+
sentryEventId?: string;
|
|
16
19
|
/**
|
|
17
20
|
* The underlying *thing* that caused this error.
|
|
18
21
|
*/
|
|
@@ -34,7 +37,6 @@ export declare abstract class BaseError extends Error {
|
|
|
34
37
|
render(): string;
|
|
35
38
|
protected header(): string;
|
|
36
39
|
protected footer(): string;
|
|
37
|
-
protected issueOptions(): newGithubIssueUrl.Options;
|
|
38
40
|
protected abstract body(): string;
|
|
39
41
|
}
|
|
40
42
|
/**
|
|
@@ -64,7 +66,6 @@ export declare class ClientError extends BaseError {
|
|
|
64
66
|
isBug: IsBug;
|
|
65
67
|
constructor(payload: Payload<any, any>, cause: string | Error | readonly GraphQLError[] | CloseEvent | ErrorEvent);
|
|
66
68
|
body(): string;
|
|
67
|
-
protected issueOptions(): newGithubIssueUrl.Options;
|
|
68
69
|
}
|
|
69
70
|
export declare class YarnNotFoundError extends BaseError {
|
|
70
71
|
isBug: IsBug;
|
package/lib/lib/errors.js
CHANGED
|
@@ -5,7 +5,6 @@ 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,7 +94,7 @@ 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
|
|
@@ -109,67 +117,13 @@ class BaseError extends Error {
|
|
|
109
117
|
return `${this.code}: ${this.message}`;
|
|
110
118
|
}
|
|
111
119
|
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) `
|
|
120
|
+
if (this.isBug == IsBug.NO)
|
|
121
|
+
return "";
|
|
122
|
+
return (0, ts_dedent_1.default) `
|
|
123
|
+
${this.isBug == IsBug.YES ? "This is a bug" : "If you think this is a bug"}, please submit an issue using the link below.
|
|
165
124
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
${JSON.stringify((0, lodash_1.isError)(this.cause) ? serializeError(this.cause) : this.cause, null, 2)}
|
|
169
|
-
\`\`\`
|
|
170
|
-
`;
|
|
171
|
-
}
|
|
172
|
-
return options;
|
|
125
|
+
https://github.com/gadget-inc/ggt/issues/new?template=bug_report.yml${this.sentryEventId ? `&error-id=${this.sentryEventId}` : ""}
|
|
126
|
+
`;
|
|
173
127
|
}
|
|
174
128
|
}
|
|
175
129
|
exports.BaseError = BaseError;
|
|
@@ -296,29 +250,6 @@ class ClientError extends BaseError {
|
|
|
296
250
|
}
|
|
297
251
|
return this.cause;
|
|
298
252
|
}
|
|
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
253
|
}
|
|
323
254
|
exports.ClientError = ClientError;
|
|
324
255
|
class YarnNotFoundError extends BaseError {
|
|
@@ -410,7 +341,7 @@ class InvalidSyncFileError extends BaseError {
|
|
|
410
341
|
|
|
411
342
|
~/gadget/${this.app || "<name of app>"}
|
|
412
343
|
|
|
413
|
-
Otherwise, if you're sure you want to sync the contents of
|
|
344
|
+
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
345
|
|
|
415
346
|
$ ggt sync ${this.sync.argv.join(" ")} --force
|
|
416
347
|
|
package/lib/lib/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/lib/errors.ts"],"names":[],"mappings":";;;;AAAA,sEAAqC;AACrC,6BAAgC;AAEhC,mCAA8F;AAC9F,wFAAqD;AACrD,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;IAqB3C,YAAY,IAAY,EAAE,OAAe;QACvC,KAAK,CAAC,OAAO,CAAC,CAAC;QArBjB;;WAEG;QACH;;;;;WAAa;QAEb;;WAEG;QACH;;;;;WAAqB;QAErB;;WAEG;QACH;;;;;WAAwB;QAStB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IAClD,CAAC;IAED,KAAK,CAAC,OAAO;QACX,IAAI,CAAC,iBAAO,CAAC,GAAG,CAAC,cAAc,IAAI,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,EAAE;YAAE,OAAO;QAElE,MAAM,IAAI,GAAG,MAAM,iBAAO,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,aAAI,CAAC,CAAC;QAEjD,MAAM,CAAC,gBAAgB,CAAC,IAAI,EAAE;YAC5B,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,CAA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AAI,CAAC,IAAI,CAAC,GACZ;;qBAEe,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;;;KAGxC,CAAC;IACJ,CAAC;CACF;AA1BD,oDA0BC;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,IAAA,gBAAO,EAAC,CAAC,CAAC,KAAK,CAAC,CAAC;AAClF,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 newGithubIssueUrl from \"new-github-issue-url\";\nimport { serializeError as baseSerializeError } from \"serialize-error\";\nimport dedent from \"ts-dedent\";\nimport type { SetOptional, Writable } 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 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 (!context.env.productionLike || this.isBug == IsBug.NO) return;\n\n const user = await context.getUser().catch(noop);\n\n 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();\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 header = this.header();\n const body = this.body();\n const footer = this.footer();\n\n let output = \"\";\n if (header) output += header + \"\\n\\n\";\n if (body) output += body + \"\\n\\n\";\n if (footer) output += footer + \"\\n\\n\";\n\n return output;\n }\n\n protected header(): string {\n return `${this.code}: ${this.message}`;\n }\n\n protected footer(): string {\n switch (this.isBug) {\n case IsBug.NO:\n return \"\";\n case IsBug.MAYBE:\n return dedent`\n If you think this is a bug, please submit an issue using the link below.\n\n ${newGithubIssueUrl(this.issueOptions())}\n `;\n case IsBug.YES:\n return dedent`\n This is a bug :(\n\n Visit the link below to see if someone has already reported this issue.\n https://github.com/gadget-inc/ggt/issues?q=is%3Aissue+is%3Aopen+label%3Abug+${this.code}\n\n If nobody has, you can submit one using the link below.\n ---\n ${newGithubIssueUrl(this.issueOptions())}\n `;\n }\n }\n\n protected issueOptions(): newGithubIssueUrl.Options {\n const options = {\n repoUrl: \"https://github.com/gadget-inc/ggt\",\n title: `[BUG ${this.code}]: `,\n labels: [\"bug\"],\n body: dedent`\n ### Description\n [Please describe what you were doing when this error occurred]\n\n ### Command\n \\`\\`\\`sh-session\n ${context.config.bin} ${process.argv.slice(2).join(\" \")}\n \\`\\`\\`\n\n ### Environment\n \\`\\`\\`\n version: ${context.config.version}\n platform: ${context.config.platform}\n arch: ${context.config.arch}\n shell: ${context.config.shell}\n timestamp: ${new Date().toISOString()}\n \\`\\`\\`\n\n ### Stack Trace\n \\`\\`\\`\n ${cleanStack(this.stack)}\n \\`\\`\\`\n `,\n };\n\n if (this.cause) {\n options.body += dedent`\n\n ### Cause\n \\`\\`\\`json\n ${JSON.stringify(isError(this.cause) ? serializeError(this.cause) : this.cause, null, 2)}\n \\`\\`\\`\n `;\n }\n\n return options;\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(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 let output = \"Gadget responded with multiple errors:\";\n for (const error of uniqBy(this.cause, \"message\")) {\n output += `\\n * ${error.message}`;\n }\n return output;\n } else {\n return dedent`\n Gadget responded with an unexpected 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)) {\n return dedent`\n The connection to Gadget received an unexpected error.\n\n ${this.cause.message}\n `;\n }\n\n if (isError(this.cause)) {\n return dedent`\n An unexpected error occurred.\n\n ${this.cause.message}\n `;\n }\n\n return this.cause;\n }\n\n protected override issueOptions(): newGithubIssueUrl.Options {\n const options = super.issueOptions() as Writable<newGithubIssueUrl.Options>;\n options.body += dedent`\n\n ### GraphQL\n\n #### Query\n \\`\\`\\`graphql\n ${this.payload.query}\n \\`\\`\\`\n `;\n\n // mutations can have large/sensitive payloads, so we don't include them by default\n if (!this.payload.query.trimStart().startsWith(\"mutation\")) {\n options.body += dedent`\n\n #### Variables\n \\`\\`\\`json\n ${JSON.stringify(this.payload.variables, null, 2)}\n \\`\\`\\`\n `;\n }\n\n return options;\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 is required to sync your application.\n\n Please install Yarn 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 }> 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 \"${\n this.sync.dir\n }\" 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\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) && isError(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,"file":"errors.js","sourceRoot":"","sources":["../../src/lib/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,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IAClD,CAAC;IAED,KAAK,CAAC,OAAO;QACX,IAAI,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,EAA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AAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;;;KAGxC,CAAC;IACJ,CAAC;CACF;AAxBD,oDAwBC;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,IAAA,gBAAO,EAAC,CAAC,CAAC,KAAK,CAAC,CAAC;AAClF,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 * 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 header = this.header();\n const body = this.body();\n const footer = this.footer();\n\n let output = \"\";\n if (header) output += header + \"\\n\\n\";\n if (body) output += body + \"\\n\\n\";\n if (footer) output += footer + \"\\n\\n\";\n\n return output;\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(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 let output = \"Gadget responded with multiple errors:\";\n for (const error of uniqBy(this.cause, \"message\")) {\n output += `\\n * ${error.message}`;\n }\n return output;\n } else {\n return dedent`\n Gadget responded with an unexpected 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)) {\n return dedent`\n The connection to Gadget received an unexpected error.\n\n ${this.cause.message}\n `;\n }\n\n if (isError(this.cause)) {\n return dedent`\n An unexpected error occurred.\n\n ${this.cause.message}\n `;\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 is required to sync your application.\n\n Please install Yarn 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 }> 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\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) && isError(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"]}
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gadgetinc/ggt",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"lockfileVersion": 2,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@gadgetinc/ggt",
|
|
9
|
-
"version": "0.1.
|
|
9
|
+
"version": "0.1.7",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@oclif/core": "^1.20.4",
|
|
@@ -27,7 +27,6 @@
|
|
|
27
27
|
"ignore": "^5.2.0",
|
|
28
28
|
"inquirer": "^8.2.5",
|
|
29
29
|
"lodash": "^4.17.21",
|
|
30
|
-
"new-github-issue-url": "^0.2.1",
|
|
31
30
|
"node-notifier": "^10.0.1",
|
|
32
31
|
"normalize-path": "^3.0.0",
|
|
33
32
|
"open": "^8.4.0",
|
|
@@ -12457,14 +12456,6 @@
|
|
|
12457
12456
|
"node": ">= 0.6"
|
|
12458
12457
|
}
|
|
12459
12458
|
},
|
|
12460
|
-
"node_modules/new-github-issue-url": {
|
|
12461
|
-
"version": "0.2.1",
|
|
12462
|
-
"resolved": "https://registry.npmjs.org/new-github-issue-url/-/new-github-issue-url-0.2.1.tgz",
|
|
12463
|
-
"integrity": "sha512-md4cGoxuT4T4d/HDOXbrUHkTKrp/vp+m3aOA7XXVYwNsUNMK49g3SQicTSeV5GIz/5QVGAeYRAOlyp9OvlgsYA==",
|
|
12464
|
-
"engines": {
|
|
12465
|
-
"node": ">=10"
|
|
12466
|
-
}
|
|
12467
|
-
},
|
|
12468
12459
|
"node_modules/nice-try": {
|
|
12469
12460
|
"version": "1.0.5",
|
|
12470
12461
|
"license": "MIT"
|
|
@@ -26454,11 +26445,6 @@
|
|
|
26454
26445
|
"version": "0.6.3",
|
|
26455
26446
|
"dev": true
|
|
26456
26447
|
},
|
|
26457
|
-
"new-github-issue-url": {
|
|
26458
|
-
"version": "0.2.1",
|
|
26459
|
-
"resolved": "https://registry.npmjs.org/new-github-issue-url/-/new-github-issue-url-0.2.1.tgz",
|
|
26460
|
-
"integrity": "sha512-md4cGoxuT4T4d/HDOXbrUHkTKrp/vp+m3aOA7XXVYwNsUNMK49g3SQicTSeV5GIz/5QVGAeYRAOlyp9OvlgsYA=="
|
|
26461
|
-
},
|
|
26462
26448
|
"nice-try": {
|
|
26463
26449
|
"version": "1.0.5"
|
|
26464
26450
|
},
|
package/oclif.manifest.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"0.1.
|
|
1
|
+
{"version":"0.1.7","commands":{"help":{"id":"help","summary":"Display help for ggt.","strict":false,"pluginName":"@gadgetinc/ggt","pluginAlias":"@gadgetinc/ggt","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"command","description":"The command to show help for.","required":false}]},"login":{"id":"login","summary":"Log in to your account.","strict":true,"usage":"login","pluginName":"@gadgetinc/ggt","pluginAlias":"@gadgetinc/ggt","pluginType":"core","aliases":[],"examples":["$ ggt login\nYour browser has been opened. Please log in to your account.\nHello, Jane Doe (jane@example.com)"],"flags":{},"args":[]},"logout":{"id":"logout","summary":"Log out of your account.","strict":true,"usage":"logout","pluginName":"@gadgetinc/ggt","pluginAlias":"@gadgetinc/ggt","pluginType":"core","aliases":[],"examples":["$ ggt logout\nGoodbye"],"flags":{},"args":[]},"sync":{"id":"sync","summary":"Sync your Gadget application's source code to and from your local filesystem.","description":"Sync provides the ability to sync your Gadget application's source code to and from your local\nfilesystem. While `ggt sync` is running, local file changes are immediately reflected within\nGadget, while files that are changed remotely are immediately saved to your local filesystem.\n\nUse cases for this include:\n * Developing locally with your own editor like VSCode (https://code.visualstudio.com/)\n * Storing your source code in a Git repository like GitHub (https://github.com/)\n\nSync includes the concept of a `.ignore` file. This file can contain a list of files and\ndirectories that won't be sent to Gadget when syncing.\n\nThe following files and directories are always ignored:\n * .gadget\n * .git\n * node_modules\n\nNote:\n * Gadget applications only support installing dependencies with Yarn 1 (https://classic.yarnpkg.com/lang/en/).\n * Since file changes are immediately reflected in Gadget, avoid the following while `ggt sync` is running:\n * Deleting all your files\n * Moving all your files to a different directory","strict":true,"usage":"sync [--app=<value>] [DIRECTORY]","pluginName":"@gadgetinc/ggt","pluginAlias":"@gadgetinc/ggt","pluginType":"core","aliases":[],"examples":["$ ggt sync --app my-app ~/gadget/my-app\nReady\nReceived\n← routes/GET.js\n← user/signUp/signIn.js\nSent\n→ routes/GET.js\n^C Stopping... (press Ctrl+C again to force)\nDone","# These are equivalent\n$ ggt sync -a my-app\n$ ggt sync --app my-app\n$ ggt sync --app my-app.gadget.app\n$ ggt sync --app https://my-app.gadget.app\n$ ggt sync --app https://my-app.gadget.app/edit"],"flags":{"app":{"name":"app","type":"option","char":"a","summary":"The Gadget application to sync files to.","multiple":false},"force":{"name":"force","type":"boolean","summary":"Whether to sync even if we can't determine the state of your local files relative to your remote ones.","allowNo":false},"file-push-delay":{"name":"file-push-delay","type":"option","summary":"Delay in milliseconds before pushing files to your app.","hidden":true,"helpValue":"ms","helpGroup":"file","multiple":false,"default":100},"file-stability-threshold":{"name":"file-stability-threshold","type":"option","summary":"Time in milliseconds a file's size must remain the same.","hidden":true,"helpValue":"ms","helpGroup":"file","multiple":false,"default":500},"file-poll-interval":{"name":"file-poll-interval","type":"option","description":"Interval in milliseconds between polling a file's size.","hidden":true,"helpValue":"ms","helpGroup":"file","multiple":false,"default":100}},"args":[{"name":"directory","description":"The directory to sync files to. If the directory doesn't exist, it will be created.","default":"."}],"priority":1},"whoami":{"id":"whoami","summary":"Show the name and email address of the currently logged in user.","strict":true,"usage":"whoami","pluginName":"@gadgetinc/ggt","pluginAlias":"@gadgetinc/ggt","pluginType":"core","aliases":[],"examples":["$ ggt whoami\nYou are logged in as Jane Doe (jane@example.com)"],"flags":{},"args":[]}}}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gadgetinc/ggt",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "The command-line interface for Gadget",
|
|
5
5
|
"homepage": "https://github.com/gadget-inc/ggt",
|
|
6
6
|
"bugs": "https://github.com/gadget-inc/ggt/issues",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"lint:typescript": "tsc --project tsconfig.json --project spec/tsconfig.json --noEmit",
|
|
31
31
|
"publish": "npm run build && changeset publish",
|
|
32
32
|
"test": "jest",
|
|
33
|
-
"version": "patch-package && changeset version && npm run build && oclif readme && prettier --write README.md"
|
|
33
|
+
"version": "patch-package && changeset version && npm install --package-lock-only && npm run build && oclif readme && prettier --write README.md"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@oclif/core": "^1.20.4",
|
|
@@ -51,7 +51,6 @@
|
|
|
51
51
|
"ignore": "^5.2.0",
|
|
52
52
|
"inquirer": "^8.2.5",
|
|
53
53
|
"lodash": "^4.17.21",
|
|
54
|
-
"new-github-issue-url": "^0.2.1",
|
|
55
54
|
"node-notifier": "^10.0.1",
|
|
56
55
|
"normalize-path": "^3.0.0",
|
|
57
56
|
"open": "^8.4.0",
|