@gadgetinc/ggt 0.1.7 → 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.
Files changed (51) hide show
  1. package/README.md +6 -6
  2. package/lib/__generated__/graphql.d.ts +45 -45
  3. package/lib/commands/help.js +1 -1
  4. package/lib/commands/help.js.map +1 -1
  5. package/lib/commands/login.d.ts +1 -1
  6. package/lib/commands/login.js +1 -1
  7. package/lib/commands/login.js.map +1 -1
  8. package/lib/commands/logout.d.ts +1 -1
  9. package/lib/commands/logout.js +2 -2
  10. package/lib/commands/logout.js.map +1 -1
  11. package/lib/commands/sync.d.ts +4 -4
  12. package/lib/commands/sync.js +13 -23
  13. package/lib/commands/sync.js.map +1 -1
  14. package/lib/commands/whoami.d.ts +1 -1
  15. package/lib/commands/whoami.js +2 -2
  16. package/lib/commands/whoami.js.map +1 -1
  17. package/lib/{lib → utils}/base-command.d.ts +0 -0
  18. package/lib/{lib → utils}/base-command.js +0 -0
  19. package/lib/utils/base-command.js.map +1 -0
  20. package/lib/{lib → utils}/client.d.ts +1 -1
  21. package/lib/{lib → utils}/client.js +3 -3
  22. package/lib/utils/client.js.map +1 -0
  23. package/lib/{lib → utils}/context.d.ts +0 -0
  24. package/lib/{lib → utils}/context.js +0 -0
  25. package/lib/utils/context.js.map +1 -0
  26. package/lib/{lib → utils}/errors.d.ts +6 -0
  27. package/lib/{lib → utils}/errors.js +42 -34
  28. package/lib/utils/errors.js.map +1 -0
  29. package/lib/{lib → utils}/flags.d.ts +0 -0
  30. package/lib/{lib → utils}/flags.js +0 -0
  31. package/lib/utils/flags.js.map +1 -0
  32. package/lib/{lib → utils}/fs-utils.d.ts +0 -0
  33. package/lib/{lib → utils}/fs-utils.js +1 -1
  34. package/lib/utils/fs-utils.js.map +1 -0
  35. package/lib/{lib → utils}/help.d.ts +0 -0
  36. package/lib/{lib → utils}/help.js +0 -0
  37. package/lib/utils/help.js.map +1 -0
  38. package/lib/{lib → utils}/sleep.d.ts +0 -0
  39. package/lib/{lib → utils}/sleep.js +0 -0
  40. package/lib/utils/sleep.js.map +1 -0
  41. package/npm-shrinkwrap.json +679 -493
  42. package/oclif.manifest.json +1 -1
  43. package/package.json +4 -3
  44. package/lib/lib/base-command.js.map +0 -1
  45. package/lib/lib/client.js.map +0 -1
  46. package/lib/lib/context.js.map +0 -1
  47. package/lib/lib/errors.js.map +0 -1
  48. package/lib/lib/flags.js.map +0 -1
  49. package/lib/lib/fs-utils.js.map +0 -1
  50. package/lib/lib/help.js.map +0 -1
  51. package/lib/lib/sleep.js.map +0 -1
@@ -1 +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":[]}}}
1
+ {"version":"0.1.8","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 received or 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.7",
3
+ "version": "0.1.8",
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",
@@ -29,8 +29,9 @@
29
29
  "lint:prettier": "prettier --check .",
30
30
  "lint:typescript": "tsc --project tsconfig.json --project spec/tsconfig.json --noEmit",
31
31
  "publish": "npm run build && changeset publish",
32
+ "readme": "patch-package && oclif readme && prettier --write README.md",
32
33
  "test": "jest",
33
- "version": "patch-package && changeset version && npm install --package-lock-only && npm run build && oclif readme && prettier --write README.md"
34
+ "version": "changeset version && npm install --package-lock-only && npm run build && npm run readme"
34
35
  },
35
36
  "dependencies": {
36
37
  "@oclif/core": "^1.20.4",
@@ -112,7 +113,7 @@
112
113
  "bin": "ggt",
113
114
  "dirname": "gadget",
114
115
  "commands": "./lib/commands",
115
- "helpClass": "./lib/lib/help",
116
+ "helpClass": "./lib/utils/help",
116
117
  "topicSeparator": " ",
117
118
  "topics": {},
118
119
  "plugins": [
@@ -1 +0,0 @@
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,CAAC,EAAE,KAAK,EAAE,WAAW,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;QAE5F,6GAA6G;QAC7G,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QAEjB,IAAI,KAAK,CAAC,KAAK,EAAE;YACf,eAAQ,CAAC,KAAK,GAAG,IAAI,CAAC;YACtB,e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,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"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/lib/client.ts"],"names":[],"mappings":";;;;AAAA,4DAA4B;AAC5B,0DAA0B;AAG1B,2CAA0C;AAE1C,mCAA0C;AAG1C,oDAA2B;AAC3B,uCAAoC;AACpC,qCAAuC;AAEvC,MAAM,KAAK,GAAG,IAAA,eAAK,EAAC,YAAY,CAAC,CAAC;AAElC,IAAK,gBAIJ;AAJD,WAAK,gBAAgB;IACnB,iEAAS,CAAA;IACT,uEAAY,CAAA;IACZ,uEAAY,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ACjB,WAAW,EAAE,CAAC;oBACd,IAAI,CAAC,KAAK,CAAC,IAAI,oBAAW,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;oBACpD,OAAO;iBACR;gBAED,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE;oBAChB,IAAI,CAAC,KAAK,CAAC,IAAI,oBAAW,CAAC,OAAO,EAAE,qCAAqC,CAAC,CAAC,CAAC;oBAC5E,WAAW,EAAE,CAAC;oBACd,OAAO;iBACR;gBAED,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;YACzB,CAAC;SACF,CAAC,CAAC;QAEH,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,KAAK,CACH,OAAiC;QAEjC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,IAAI,CAAC,SAAS,CAA8B,OAAO,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;QACzF,CAAC,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,WAAW,CAAwD,OAAiC;QACxG,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACzC,IAAI,MAAM,CAAC,MAAM;YAAE,MAAM,IAAI,oBAAW,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;QACjE,IAAI,CAAC,MAAM,CAAC,IAAI;YAAE,MAAM,IAAI,oBAAW,CAAC,OAAO,EAAE,qCAAqC,CAAC,CAAC;QACxF,OAAO,MAAM,CAAC,IAAI,CAAC;IACrB,CAAC;IAED,KAAK,CAAC,OAAO;QACX,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;IAC/B,CAAC;CACF;AAxJD,wBAwJC","sourcesContent":["import assert from \"assert\";\nimport Debug from \"debug\";\nimport type { GraphQLError } from \"graphql\";\nimport type { ExecutionResult, SubscribePayload } from \"graphql-ws\";\nimport { createClient } from \"graphql-ws\";\nimport type { ClientRequestArgs } from \"http\";\nimport { isFunction, noop } from \"lodash\";\nimport type { JsonObject, SetOptional } from \"type-fest\";\nimport type { CloseEvent, ErrorEvent } from \"ws\";\nimport WebSocket from \"ws\";\nimport { context } from \"./context\";\nimport { ClientError } from \"./errors\";\n\nconst debug = Debug(\"ggt:client\");\n\nenum ConnectionStatus {\n CONNECTED,\n DISCONNECTED,\n RECONNECTING,\n}\n\nexport class Client {\n // assume the client is going to connect\n status = ConnectionStatus.CONNECTED;\n\n private _client: ReturnType<typeof createClient>;\n\n constructor() {\n assert(context.app, \"context.app must be set before instantiating the Client\");\n const domain = context.env.productionLike ? \"gadget.app\" : \"ggt.pub:3000\";\n\n this._client = createClient({\n url: `wss://${context.app.slug}.${domain}/edit/api/graphql-ws`,\n shouldRetry: () => true,\n webSocketImpl: class extends WebSocket {\n constructor(address: string | URL, protocols?: string | string[], wsOptions?: WebSocket.ClientOptions | ClientRequestArgs) {\n assert(context.session, \"context.session must be set before instantiating the Client\");\n super(address, protocols, {\n ...wsOptions,\n headers: {\n ...wsOptions?.headers,\n \"user-agent\": context.config.userAgent,\n cookie: `session=${encodeURIComponent(context.session)};`,\n },\n });\n }\n },\n on: {\n connecting: () => {\n switch (this.status) {\n case ConnectionStatus.DISCONNECTED:\n this.status = ConnectionStatus.RECONNECTING;\n debug(\"reconnecting...\");\n break;\n case ConnectionStatus.RECONNECTING:\n debug(\"retrying...\");\n break;\n default:\n debug(\"connecting...\");\n break;\n }\n },\n connected: () => {\n if (this.status === ConnectionStatus.RECONNECTING) {\n debug(\"reconnected\");\n } else {\n debug(\"connected\");\n }\n\n // let the other on connected listeners see what status we're in\n setImmediate(() => (this.status = ConnectionStatus.CONNECTED));\n },\n closed: (e) => {\n const event = e as CloseEvent;\n if (event.wasClean) {\n debug(\"connection closed\");\n return;\n }\n\n if (this.status === ConnectionStatus.CONNECTED) {\n this.status = ConnectionStatus.DISCONNECTED;\n debug(\"disconnected\");\n }\n },\n error: (error) => {\n if (this.status == ConnectionStatus.RECONNECTING) {\n debug(\"failed to reconnect %o\", { error });\n } else {\n debug(\"connection error %o\", { error });\n }\n },\n },\n });\n }\n\n subscribe<Data extends JsonObject, Variables extends JsonObject, Extensions extends JsonObject = JsonObject>(\n payload: Payload<Data, Variables>,\n sink: SetOptional<Sink<Data, Extensions>, \"complete\">\n ): () => void {\n let subscribePayload: SubscribePayload;\n let removeConnectedListener: () => void;\n\n if (isFunction(payload.variables)) {\n // the caller wants us to re-evaluate the variables every time graphql-ws re-subscribes after reconnecting\n subscribePayload = { ...payload, variables: payload.variables() };\n removeConnectedListener = this._client.on(\"connected\", () => {\n if (this.status == ConnectionStatus.RECONNECTING) {\n // subscribePayload.variables is supposed to be readonly (it's not) and payload.variables could been re-assigned (it won't)\n (subscribePayload as any).variables = (payload.variables as any)();\n debug(\"re-sending query %s\", subscribePayload.query);\n }\n });\n } else {\n subscribePayload = payload as SubscribePayload;\n }\n\n debug(\"sending query %s\", subscribePayload.query);\n const unsubscribe = this._client.subscribe(subscribePayload, {\n next: (result: ExecutionResult<Data, Extensions>) => sink.next(result),\n error: (error) => sink.error(new ClientError(subscribePayload, error as Error | GraphQLError[] | CloseEvent | ErrorEvent)),\n complete: () => sink.complete?.() ?? noop,\n });\n\n return () => {\n removeConnectedListener?.();\n unsubscribe();\n };\n }\n\n subscribeUnwrap<Data extends JsonObject, Variables extends JsonObject>(\n payload: Payload<Data, Variables>,\n sink: { next: (data: Data) => void; error: (error: ClientError) => void }\n ): () => void {\n const unsubscribe = this.subscribe(payload, {\n ...sink,\n next: (result) => {\n if (result.errors) {\n unsubscribe();\n sink.error(new ClientError(payload, result.errors));\n return;\n }\n\n if (!result.data) {\n sink.error(new ClientError(payload, \"We received a response without data\"));\n unsubscribe();\n return;\n }\n\n sink.next(result.data);\n },\n });\n\n return unsubscribe;\n }\n\n query<Data extends JsonObject, Variables extends JsonObject, Extensions extends JsonObject = JsonObject>(\n payload: Payload<Data, Variables>\n ): Promise<ExecutionResult<Data, Extensions>> {\n return new Promise((resolve, reject) => {\n this.subscribe<Data, Variables, Extensions>(payload, { next: resolve, error: reject });\n });\n }\n\n async queryUnwrap<Data extends JsonObject, Variables extends JsonObject>(payload: Payload<Data, Variables>): Promise<Data> {\n const result = await this.query(payload);\n if (result.errors) throw new ClientError(payload, result.errors);\n if (!result.data) throw new ClientError(payload, \"We received a response without data\");\n return result.data;\n }\n\n async dispose(): Promise<void> {\n await this._client.dispose();\n }\n}\n\nexport type Query<\n Data extends JsonObject,\n Variables extends JsonObject = JsonObject,\n Extensions extends JsonObject = JsonObject\n> = string & {\n __TData?: Data;\n __TVariables?: Variables;\n __TExtensions?: Extensions;\n};\n\nexport interface Payload<Data extends JsonObject, Variables extends JsonObject> {\n readonly query: Query<Data, Variables>;\n readonly variables?: Variables | (() => Variables) | null;\n}\n\nexport interface Sink<Data extends JsonObject, Extensions extends JsonObject> {\n next(value: ExecutionResult<Data, Extensions>): void;\n error(error: ClientError): void;\n complete(): void;\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/lib/context.ts"],"names":[],"mappings":";;;;AACA,4DAA4B;AAC5B,gEAA0B;AAC1B,mDAAqC;AACrC,mCAAkC;AAClC,wDAAwB;AACxB,yCAA0C;AAE1C,MAAM,OAAO;IAAb;QACE;;;;;WAKG;QACH;;;;;WAAgB;QAEhB;;;;mBAAM,IAAI,GAAG,EAAE;WAAC;QAEhB;;;;;WAAU;QAEV;;;;;WAA0B;QAE1B;;;;;WAAqB;QAErB;;;;mBAAgC,EAAE;WAAC;QAEnC;;;;mBAAmB,aAAG,CAAC,MAAM,CAAC;gBAC5B,KAAK,EAAE;oBACL,aAAa,EAAE;wBACb,CAAC,OAAO,EAAE,EAAE;4BACV,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC;4BACtD,IAAI,OAAO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K,CAAC;SAClB;IACH,CAAC;IAED,KAAK;QACH,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAC;QAC1B,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;QACvB,IAAI,CAAC,GAAG,GAAG,SAAS,CAAC;QACrB,IAAI,CAAC,cAAc,GAAG,EAAE,CAAC;IAC3B,CAAC;CACF;AAED;;GAEG;AACH,MAAM,GAAG;IACP,IAAI,KAAK;QACP,OAAO,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,YAAY,CAAC;IAChD,CAAC;IAED,IAAI,cAAc;QAChB,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;IAC7C,CAAC;IAED,IAAI,eAAe;QACjB,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;IAC9C,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IACvC,CAAC;IAED,IAAI,qBAAqB;QACvB,OAAO,IAAI,CAAC,eAAe,IAAI,IAAI,CAAC,QAAQ,CAAC;IAC/C,CAAC;CACF;AAcY,QAAA,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAExB,QAAA,eAAe,GAAG,eAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC,0BAA0B,CAAC","sourcesContent":["import type { Config } from \"@oclif/core\";\nimport assert from \"assert\";\nimport fs from \"fs-extra\";\nimport got, { HTTPError } from \"got\";\nimport { isString } from \"lodash\";\nimport path from \"path\";\nimport { ignoreEnoent } from \"./fs-utils\";\n\nclass Context {\n /**\n * A reference to oclif's {@linkcode Config}.\n *\n * By default, oclif's {@linkcode Config} is only available as an instance property on a Command, but we want to be able to access it from\n * anywhere. To do this, we created this global variable that references the Config. It is set by the init function in the BaseCommand.\n */\n config!: Config;\n\n env = new Env();\n\n app?: App;\n\n private _session?: string;\n\n private _user?: User;\n\n private _availableApps: App[] = [];\n\n private _request = got.extend({\n hooks: {\n beforeRequest: [\n (options) => {\n options.headers[\"user-agent\"] = this.config.userAgent;\n if (options.url.origin === GADGET_ENDPOINT && this.session) {\n options.headers[\"cookie\"] = `session=${encodeURIComponent(this.session)};`;\n }\n },\n ],\n },\n });\n\n get session(): string | undefined {\n if (this._session) return this._session;\n\n try {\n this._session = fs.readFileSync(path.join(this.config.configDir, \"session.txt\"), \"utf-8\");\n return this._session;\n } catch (error) {\n ignoreEnoent(error);\n return undefined;\n }\n }\n\n set session(value: string | undefined) {\n this.clear();\n this._session = value;\n if (this._session) {\n fs.outputFileSync(path.join(this.config.configDir, \"session.txt\"), this._session);\n } else {\n fs.removeSync(path.join(this.config.configDir, \"session.txt\"));\n }\n }\n\n /**\n * @returns The current user, or undefined if the user is not logged in.\n */\n async getUser(): Promise<User | undefined> {\n if (!this.session) return undefined;\n if (this._user) return this._user;\n\n try {\n this._user = await this._request(`${GADGET_ENDPOINT}/auth/api/current-user`).json<User>();\n return this._user;\n } catch (error) {\n if (error instanceof HTTPError && error.response.statusCode === 401) {\n this.session = undefined;\n return undefined;\n }\n throw error;\n }\n }\n\n /**\n * @returns The list of Gadget applications the current user has access to.\n */\n async getAvailableApps(): Promise<App[]> {\n if (!this.session) return [];\n if (this._availableApps.length > 0) return this._availableApps;\n\n this._availableApps = await this._request(`${GADGET_ENDPOINT}/auth/api/apps`).json<App[]>();\n return this._availableApps;\n }\n\n async setApp(value: App | string | undefined): Promise<void> {\n if (isString(value)) {\n const app = await this.getAvailableApps().then((apps) => apps.find((app) => app.name == value || app.slug == value));\n assert(app, `attempted to set app to \"${value}\" but no app with that name or slug was found`);\n this.app = app;\n } else {\n this.app = value;\n }\n }\n\n clear(): void {\n this._session = undefined;\n this._user = undefined;\n this.app = undefined;\n this._availableApps = [];\n }\n}\n\n/**\n * Captures the name and nature of the environment\n */\nclass Env {\n get value(): string {\n return process.env[\"GGT_ENV\"] || \"production\";\n }\n\n get productionLike(): boolean {\n return this.value.startsWith(\"production\");\n }\n\n get developmentLike(): boolean {\n return this.value.startsWith(\"development\");\n }\n\n get testLike(): boolean {\n return this.value.startsWith(\"test\");\n }\n\n get developmentOrTestLike(): boolean {\n return this.developmentLike || this.testLike;\n }\n}\n\nexport interface User {\n id: string | number;\n email: string;\n name?: string;\n}\n\nexport interface App {\n id: string | number;\n name: string;\n slug: string;\n}\n\nexport const context = new Context();\n\nexport const GADGET_ENDPOINT = context.env.productionLike ? \"https://app.gadget.dev\" : \"https://app.ggt.dev:3000\";\n"]}
@@ -1 +0,0 @@
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,EAAE;YAAE,OAAO;QAEnC,MAAM,IAAI,GAAG,MAAM,iBAAO,CAAC,OAAO,EAAE,C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C;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"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"flags.js","sourceRoot":"","sources":["../../src/lib/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"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"fs-utils.js","sourceRoot":"","sources":["../../src/lib/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,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QACxD,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,OAAO,CAAC,C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C;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.relative(this._rootDir, 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"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"help.js","sourceRoot":"","sources":["../../src/lib/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"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"sleep.js","sourceRoot":"","sources":["../../src/lib/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"]}