@gadgetinc/ggt 0.0.0-alpha.7 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/dist/commands/help.js.map +1 -1
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/logout.js.map +1 -1
- package/dist/commands/sync.d.ts +5 -5
- package/dist/commands/sync.js +6 -0
- package/dist/commands/sync.js.map +1 -1
- package/dist/commands/whoami.js.map +1 -1
- package/dist/lib/base-command.js.map +1 -1
- package/dist/lib/errors.d.ts +6 -4
- package/dist/lib/errors.js.map +1 -1
- package/dist/lib/flags.d.ts +1 -1
- package/dist/lib/flags.js +13 -13
- package/dist/lib/flags.js.map +1 -1
- package/npm-shrinkwrap.json +4959 -1649
- package/package.json +21 -22
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.
|
|
122
|
+
_See code: [src/commands/sync.ts](https://github.com/gadget-inc/ggt/blob/v0.1.1/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.
|
|
136
|
+
_See code: [src/commands/help.ts](https://github.com/gadget-inc/ggt/blob/v0.1.1/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.
|
|
152
|
+
_See code: [src/commands/login.ts](https://github.com/gadget-inc/ggt/blob/v0.1.1/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.
|
|
167
|
+
_See code: [src/commands/logout.ts](https://github.com/gadget-inc/ggt/blob/v0.1.1/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.
|
|
182
|
+
_See code: [src/commands/whoami.ts](https://github.com/gadget-inc/ggt/blob/v0.1.1/src/commands/whoami.ts)_
|
|
183
183
|
|
|
184
184
|
<!-- commandsstop -->
|
|
185
185
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"help.js","sourceRoot":"","sources":["../../src/commands/help.ts"],"names":[],"mappings":";;;AAAA,sCAAsC;AACtC,+DAA+B;AAE/B;;;;GAIG;AACH,MAAqB,WAAY,SAAQ,cAAO;IAO9C,KAAK,CAAC,GAAG;QACP,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;QACpC,MAAM,IAAI,GAAG,IAAI,cAAI,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC;QAClD,MAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;;AAXH,8BAYC;
|
|
1
|
+
{"version":3,"file":"help.js","sourceRoot":"","sources":["../../src/commands/help.ts"],"names":[],"mappings":";;;AAAA,sCAAsC;AACtC,+DAA+B;AAE/B;;;;GAIG;AACH,MAAqB,WAAY,SAAQ,cAAO;IAO9C,KAAK,CAAC,GAAG;QACP,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;QACpC,MAAM,IAAI,GAAG,IAAI,cAAI,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC;QAClD,MAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;;AAXH,8BAYC;AAXQ;;;;WAAkB,KAAK;GAAC;AAExB;;;;WAAmB,uBAAuB;GAAC;AAE3C;;;;WAAgB,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,WAAW,EAAE,+BAA+B,EAAE,CAAC;GAAC","sourcesContent":["import { Command } from \"@oclif/core\";\nimport Help from \"../lib/help\";\n\n/**\n * Copied from @oclif/plugin-help. Uses our own {@link Help} template class instead of the one from @oclif/core.\n *\n * @see https://github.com/oclif/plugin-help/blob/67b580570257b45e92d3a04d50bf2a432c59afe3/src/commands/help.ts\n */\nexport default class HelpCommand extends Command {\n static override strict = false;\n\n static override summary = \"Display help for ggt.\";\n\n static override args = [{ name: \"command\", required: false, description: \"The command to show help for.\" }];\n\n async run(): Promise<void> {\n const { argv } = await this.parse();\n const help = new Help(this.config, { all: true });\n await help.showHelp(argv);\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":";;;AAAA,kEAA+B;AAC/B,sDAAkD;AAElD,MAAqB,KAAM,SAAQ,0BAAW;IAa5C,KAAK,CAAC,GAAG;QACP,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;;AAfH,wBAgBC;
|
|
1
|
+
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":";;;AAAA,kEAA+B;AAC/B,sDAAkD;AAElD,MAAqB,KAAM,SAAQ,0BAAW;IAa5C,KAAK,CAAC,GAAG;QACP,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;;AAfH,wBAgBC;AAfQ;;;;WAAmB,yBAAyB;GAAC;AAE7C;;;;WAAiB,OAAO;GAAC;AAEzB;;;;WAAoB;QACzB,IAAA,mBAAM,EAAA;;;;KAIL;KACF;GAAC","sourcesContent":["import dedent from \"ts-dedent\";\nimport { BaseCommand } from \"../lib/base-command\";\n\nexport default class Login extends BaseCommand {\n static override summary = \"Log in to your account.\";\n\n static override usage = \"login\";\n\n static override examples = [\n dedent`\n $ ggt login\n Your browser has been opened. Please log in to your account.\n Hello, Jane Doe (jane@example.com)\n `,\n ];\n\n async run(): Promise<void> {\n await this.login();\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logout.js","sourceRoot":"","sources":["../../src/commands/logout.ts"],"names":[],"mappings":";;;AAAA,kEAA+B;AAC/B,sDAAkD;AAClD,4CAAyC;AAEzC,MAAqB,MAAO,SAAQ,0BAAW;IAY7C,4DAA4D;IAC5D,KAAK,CAAC,GAAG;QACP,IAAI,iBAAO,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE;YAC1B,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;SACrB;aAAM;YACL,IAAI,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;SACnC;IACH,CAAC;;AAnBH,yBAoBC;
|
|
1
|
+
{"version":3,"file":"logout.js","sourceRoot":"","sources":["../../src/commands/logout.ts"],"names":[],"mappings":";;;AAAA,kEAA+B;AAC/B,sDAAkD;AAClD,4CAAyC;AAEzC,MAAqB,MAAO,SAAQ,0BAAW;IAY7C,4DAA4D;IAC5D,KAAK,CAAC,GAAG;QACP,IAAI,iBAAO,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE;YAC1B,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;SACrB;aAAM;YACL,IAAI,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;SACnC;IACH,CAAC;;AAnBH,yBAoBC;AAnBQ;;;;WAAmB,0BAA0B;GAAC;AAE9C;;;;WAAiB,QAAQ;GAAC;AAE1B;;;;WAAoB;QACzB,IAAA,mBAAM,EAAA;;;KAGL;KACF;GAAC","sourcesContent":["import dedent from \"ts-dedent\";\nimport { BaseCommand } from \"../lib/base-command\";\nimport { session } from \"../lib/session\";\n\nexport default class Logout extends BaseCommand {\n static override summary = \"Log out of your account.\";\n\n static override usage = \"logout\";\n\n static override examples = [\n dedent`\n $ ggt logout\n Goodbye\n `,\n ];\n\n // eslint-disable-next-line @typescript-eslint/require-await\n async run(): Promise<void> {\n if (session.set(undefined)) {\n this.log(\"Goodbye\");\n } else {\n this.log(\"You are not logged in\");\n }\n }\n}\n"]}
|
package/dist/commands/sync.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import type { OptionFlag } from "@oclif/core/lib/interfaces";
|
|
3
2
|
import { FSWatcher } from "chokidar";
|
|
4
3
|
import type { DebouncedFunc } from "lodash";
|
|
5
4
|
import PQueue from "p-queue";
|
|
@@ -20,13 +19,14 @@ export default class Sync extends BaseCommand {
|
|
|
20
19
|
default: string;
|
|
21
20
|
}[];
|
|
22
21
|
static flags: {
|
|
23
|
-
app: OptionFlag<string | undefined>;
|
|
22
|
+
app: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
|
|
24
23
|
force: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
25
|
-
"file-push-delay": OptionFlag<number>;
|
|
26
|
-
"file-stability-threshold": OptionFlag<number>;
|
|
27
|
-
"file-poll-interval": OptionFlag<number>;
|
|
24
|
+
"file-push-delay": import("@oclif/core/lib/interfaces").OptionFlag<number>;
|
|
25
|
+
"file-stability-threshold": import("@oclif/core/lib/interfaces").OptionFlag<number>;
|
|
26
|
+
"file-poll-interval": import("@oclif/core/lib/interfaces").OptionFlag<number>;
|
|
28
27
|
};
|
|
29
28
|
static examples: string[];
|
|
29
|
+
requireUser: boolean;
|
|
30
30
|
status: SyncStatus;
|
|
31
31
|
dir: string;
|
|
32
32
|
recentWrites: Set<unknown>;
|
package/dist/commands/sync.js
CHANGED
|
@@ -27,6 +27,12 @@ const sleep_1 = require("../lib/sleep");
|
|
|
27
27
|
class Sync extends base_command_1.BaseCommand {
|
|
28
28
|
constructor() {
|
|
29
29
|
super(...arguments);
|
|
30
|
+
Object.defineProperty(this, "requireUser", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
configurable: true,
|
|
33
|
+
writable: true,
|
|
34
|
+
value: true
|
|
35
|
+
});
|
|
30
36
|
Object.defineProperty(this, "status", {
|
|
31
37
|
enumerable: true,
|
|
32
38
|
configurable: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync.js","sourceRoot":"","sources":["../../src/commands/sync.ts"],"names":[],"mappings":";;;;AAAA,sCAAoC;AAEpC,4DAA4B;AAC5B,uCAAqC;AACrC,0DAA0B;AAE1B,gEAA0B;AAC1B,uCAAkC;AAElC,mCAAkC;AAClC,4EAA2C;AAC3C,0DAAyB;AACzB,8DAA6B;AAC7B,wDAAwB;AACxB,kEAA+B;AAC/B,+BAAgD;AAChD,0DAA0B;AAC1B,oCAAiC;AACjC,sDAAkD;AAElD,0CAAuC;AACvC,0CAAmF;AACnF,wCAAmC;AACnC,8CAA6E;AAC7E,4CAAyC;AACzC,wCAA0C;AAY1C,MAAqB,IAAK,SAAQ,0BAAW;IAA7C;;QA8FE;;;;mBAAS,UAAU,CAAC,QAAQ;WAAC;QAE7B;;;;;WAAa;QAEb;;;;mBAAe,IAAI,GAAG,EAAE;WAAC;QAEzB;;;;mBAAU,IAAI,kBAAW,EAAE;WAAC;QAE5B;;;;mBAAU,IAAI,kBAAW,EAAE;WAAC;QAE5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ib/interfaces\";\nimport assert from \"assert\";\nimport { FSWatcher } from \"chokidar\";\nimport execa from \"execa\";\nimport type { Stats } from \"fs-extra\";\nimport fs from \"fs-extra\";\nimport { prompt } from \"inquirer\";\nimport type { DebouncedFunc } from \"lodash\";\nimport { debounce } from \"lodash\";\nimport normalizePath from \"normalize-path\";\nimport pMap from \"p-map\";\nimport PQueue from \"p-queue\";\nimport path from \"path\";\nimport dedent from \"ts-dedent\";\nimport { TextDecoder, TextEncoder } from \"util\";\nimport which from \"which\";\nimport { api } from \"../lib/api\";\nimport { BaseCommand } from \"../lib/base-command\";\nimport type { Query } from \"../lib/client\";\nimport { Client } from \"../lib/client\";\nimport { FlagError, InvalidSyncFileError, YarnNotFoundError } from \"../lib/errors\";\nimport { app } from \"../lib/flags\";\nimport { ignoreEnoent, Ignorer, isEmptyDir, walkDir } from \"../lib/fs-utils\";\nimport { session } from \"../lib/session\";\nimport { sleepUntil } from \"../lib/sleep\";\nimport type {\n FileSyncChangedEventInput,\n FileSyncDeletedEventInput,\n PublishFileSyncEventsMutation,\n PublishFileSyncEventsMutationVariables,\n RemoteFilesVersionQuery,\n RemoteFilesVersionQueryVariables,\n RemoteFileSyncEventsSubscription,\n RemoteFileSyncEventsSubscriptionVariables,\n} from \"../__generated__/graphql\";\n\nexport default class Sync extends BaseCommand {\n static override priority = 1;\n\n static override summary = \"Sync your Gadget application's source code to and from your local filesystem.\";\n\n static override usage = \"sync [--app=<value>] [DIRECTORY]\";\n\n static override description = dedent`\n Sync provides the ability to sync your Gadget application's source code to and from your local\n filesystem. While \\`ggt sync\\` is running, local file changes are immediately reflected within\n Gadget, while files that are changed remotely are immediately saved to your local filesystem.\n\n Use 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\n Sync includes the concept of a \\`.ignore\\` file. This file can contain a list of files and\n directories that won't be sent to Gadget when syncing.\n\n The following files and directories are always ignored:\n * .gadget\n * .git\n * node_modules\n\n Note:\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\n `;\n\n static override args = [\n {\n name: \"directory\",\n description: \"The directory to sync files to. If the directory doesn't exist, it will be created.\",\n default: \".\",\n },\n ];\n\n static override flags = {\n app: app({\n summary: \"The Gadget application to sync files to.\",\n }),\n force: Flags.boolean({\n summary: \"Whether to sync even if we can't determine the state of your local files relative to your remote ones.\",\n default: false,\n }),\n \"file-push-delay\": Flags.integer({\n summary: \"Delay in milliseconds before pushing files to your app.\",\n helpGroup: \"file\",\n helpValue: \"ms\",\n default: 100,\n hidden: true,\n }) as OptionFlag<number>,\n \"file-stability-threshold\": Flags.integer({\n name: \"file-stability-threshold\",\n summary: \"Time in milliseconds a file's size must remain the same.\",\n helpGroup: \"file\",\n helpValue: \"ms\",\n default: 500,\n hidden: true,\n }) as OptionFlag<number>,\n \"file-poll-interval\": Flags.integer({\n name: \"file-poll-interval\",\n description: \"Interval in milliseconds between polling a file's size.\",\n helpGroup: \"file\",\n helpValue: \"ms\",\n default: 100,\n hidden: true,\n }) as OptionFlag<number>,\n };\n\n static override examples = [\n dedent`\n $ ggt sync --app my-app ~/gadget/my-app\n Ready\n Received\n ← routes/GET.js\n ← user/signUp/signIn.js\n Sent\n → routes/GET.js\n ^C Stopping... (press Ctrl+C again to force)\n Done\n `,\n dedent`\n # 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\n `,\n ];\n\n status = SyncStatus.STARTING;\n\n dir!: string;\n\n recentWrites = new Set();\n\n encoder = new TextEncoder();\n\n decoder = new TextDecoder();\n\n filePushDelay!: number;\n\n queue = new PQueue({ concurrency: 1 });\n\n client!: Client;\n\n ignorer!: Ignorer;\n\n watcher!: FSWatcher;\n\n metadata = {\n app: \"\",\n filesVersion: \"0\",\n mtime: 0,\n };\n\n publish!: DebouncedFunc<() => void>;\n\n stop!: (error?: unknown) => Promise<void>;\n\n relative(to: string): string {\n return path.relative(this.dir, to);\n }\n\n absolute(...pathSegments: string[]): string {\n return path.resolve(this.dir, ...pathSegments);\n }\n\n normalize(filepath: string): string {\n return normalizePath(path.isAbsolute(filepath) ? this.relative(filepath) : filepath);\n }\n\n logPaths(filepaths: string[], { limit = 10, sep = \"-\" } = {}): void {\n let logged = 0;\n for (const filepath of filepaths) {\n this.log(`${sep} ${this.normalize(filepath)}`);\n if (++logged == limit && !this.debugEnabled) break;\n }\n\n if (filepaths.length > logged) {\n this.log(`… ${filepaths.length - logged} more`);\n }\n }\n\n override async init(): Promise<void> {\n await super.init();\n const { args, flags } = await this.parse(Sync);\n\n this.dir = path.resolve(args[\"directory\"] as string);\n\n const getApp = async (): Promise<string> => {\n if (flags.app) return flags.app;\n if (this.metadata.app) return this.metadata.app;\n const selected = await prompt<{ app: string }>({\n type: \"list\",\n name: \"app\",\n message: \"Please select the app to sync to.\",\n choices: await api.getApps().then((apps) => apps.map((app) => app.slug)),\n });\n return selected.app;\n };\n\n if (await isEmptyDir(this.dir)) {\n this.metadata.app = await getApp();\n } else {\n try {\n this.metadata = await fs.readJson(this.absolute(\".gadget\", \"sync.json\"));\n if (!this.metadata.app) {\n this.metadata.app = await getApp();\n }\n } catch (error) {\n if (!flags.force) {\n throw new InvalidSyncFileError(error, this, flags.app);\n }\n this.metadata.app = await getApp();\n }\n }\n\n if (flags.app && flags.app !== this.metadata.app && !flags.force) {\n throw new FlagError(\n { name: \"app\", char: \"a\" },\n dedent`\n You were about to sync the following app to the following directory:\n\n ${flags.app} → ${this.dir}\n\n However, that directory has already been synced with this app:\n\n ${this.metadata.app}\n\n If you're sure that you want to sync \"${flags.app}\" to \"${this.dir}\", run \\`ggt sync\\` again with the \\`--force\\` flag:\n\n $ ggt sync ${this.argv.join(\" \")} --force\n `\n );\n }\n\n this.client = new Client(this.metadata.app, {\n ws: {\n headers: {\n \"user-agent\": this.config.userAgent,\n cookie: `session=${encodeURIComponent(session.get() as string)};`,\n },\n },\n });\n\n this.filePushDelay = flags[\"file-push-delay\"];\n\n // local files that should never be published\n const ignored = [\"node_modules/\", \".gadget/\", \".git/\"];\n\n this.ignorer = new Ignorer(this.dir, ignored);\n\n this.watcher = new FSWatcher({\n ignored,\n // don't emit an event for every watched file on boot\n ignoreInitial: true,\n // make sure stats are always present on add/change events\n alwaysStat: true,\n // wait for the entire file to be written before emitting add/change events\n awaitWriteFinish: { pollInterval: flags[\"file-poll-interval\"], stabilityThreshold: flags[\"file-stability-threshold\"] },\n });\n\n this.debug(\"starting\");\n\n if (!which.sync(\"yarn\", { nothrow: true })) {\n throw new YarnNotFoundError();\n }\n\n await fs.ensureDir(this.dir);\n\n const { remoteFilesVersion } = await this.client.queryUnwrap({ query: REMOTE_FILES_VERSION_QUERY });\n const hasRemoteChanges = BigInt(remoteFilesVersion) > BigInt(this.metadata.filesVersion);\n\n const getChangedFiles = async (): Promise<Map<string, Stats>> => {\n const files = new Map();\n for await (const filepath of walkDir(this.dir, { ignorer: this.ignorer })) {\n const stats = await fs.stat(filepath);\n if (stats.mtime.getTime() > this.metadata.mtime) {\n files.set(this.absolute(filepath), stats);\n }\n }\n return files;\n };\n\n const changedFiles = await getChangedFiles();\n const hasLocalChanges = changedFiles.size > 0;\n if (hasLocalChanges) {\n this.log(\"Local files have changed since the last sync\");\n this.logPaths(Array.from(changedFiles.keys()), { limit: changedFiles.size });\n this.log();\n }\n\n this.debug(\"init %o\", { metadata: this.metadata, remoteFilesVersion, hasRemoteChanges, hasLocalChanges });\n\n let action: Action | undefined;\n if (hasLocalChanges) {\n ({ action } = await prompt({\n type: \"list\",\n name: \"action\",\n choices: [Action.CANCEL, Action.MERGE, Action.RESET],\n message: hasRemoteChanges ? \"Remote files have also changed. How would you like to proceed?\" : \"How would you like to proceed?\",\n }));\n }\n\n switch (action) {\n case Action.MERGE: {\n // get all the changed files again in case more changed\n const files = await getChangedFiles();\n\n // we purposefully don't set the returned remoteFilesVersion here because we haven't processed the in-between versions yet\n await this.client.queryUnwrap({\n query: PUBLISH_FILE_SYNC_EVENTS_MUTATION,\n variables: {\n input: {\n expectedRemoteFilesVersion: remoteFilesVersion,\n changed: await pMap(files, async ([filepath, stats]) => {\n if (stats.mtime.getTime() > this.metadata.mtime) {\n this.metadata.mtime = stats.mtime.getTime();\n }\n\n return {\n path: this.normalize(filepath),\n mode: stats.mode,\n content: this.decoder.decode(await fs.readFile(filepath)),\n };\n }),\n deleted: [],\n },\n },\n });\n break;\n }\n case Action.RESET: {\n await pMap(changedFiles, ([filepath]) => fs.remove(filepath));\n this.metadata.filesVersion = \"0\";\n break;\n }\n case Action.CANCEL: {\n process.exit(0);\n }\n }\n\n this.debug(\"started\");\n }\n\n async run(): Promise<void> {\n let error: unknown;\n\n this.stop = async (e?: unknown) => {\n if (this.status != SyncStatus.RUNNING) return;\n\n error = e;\n this.debug(\"stopping\");\n this.status = SyncStatus.STOPPING;\n\n try {\n unsubscribe();\n this.watcher.removeAllListeners();\n this.publish.flush();\n await this.queue.onIdle();\n } finally {\n await fs.outputJSON(this.absolute(\".gadget\", \"sync.json\"), this.metadata, { spaces: 2 });\n await Promise.allSettled([this.watcher.close(), this.client.dispose()]);\n\n this.debug(\"stopped\");\n this.status = SyncStatus.STOPPED;\n }\n };\n\n for (const signal of [\"SIGINT\", \"SIGTERM\"] as const) {\n process.on(signal, () => {\n if (this.status != SyncStatus.RUNNING) return;\n\n this.log(\" Stopping... (press Ctrl+C again to force)\");\n void this.stop();\n\n // When ggt is run via npx, and the user presses Ctrl+C, npx sends SIGINT twice in quick succession. In order to prevent the second\n // SIGINT from triggering the force exit listener, we wait a bit before registering it. This is a bit of a hack, but it works.\n setTimeout(() => {\n process.once(signal, () => {\n this.log(\" Exiting immediately. Note that files may not have finished syncing.\");\n process.exit(1);\n });\n }, 100).unref();\n });\n }\n\n const unsubscribe = this.client.subscribeUnwrap(\n {\n query: REMOTE_FILE_SYNC_EVENTS_SUBSCRIPTION,\n variables: () => ({ localFilesVersion: this.metadata.filesVersion }),\n },\n {\n error: (error) => void this.stop(error),\n next: ({ remoteFileSyncEvents: { remoteFilesVersion, changed, deleted } }) => {\n const remoteFiles = new Map([...deleted, ...changed].map((e) => [e.path, e]));\n\n void this.queue\n .add(async () => {\n if (!remoteFiles.size) {\n // we still need to update filesVersion, otherwise our expectedFilesVersion will be behind the next time we publish\n this.metadata.filesVersion = remoteFilesVersion;\n return;\n }\n\n this.log(\"Received\");\n this.logPaths(Array.from(remoteFiles.keys()), { sep: \"←\" });\n\n await pMap(\n remoteFiles,\n async ([relativePath, file]) => {\n const filepath = this.absolute(relativePath);\n this.recentWrites.add(filepath);\n\n if (\"content\" in file) {\n await fs.ensureDir(path.dirname(filepath), { mode: 0o755 });\n if (!file.path.endsWith(\"/\")) {\n await fs.writeFile(filepath, this.encoder.encode(file.content), { mode: file.mode });\n }\n if (filepath == this.absolute(\"yarn.lock\")) {\n await execa(\"yarn\", [\"install\"], { cwd: this.dir }).catch((err) => {\n this.debug(\"yarn install failed\");\n this.debug(err.message);\n });\n }\n } else {\n await fs.remove(filepath);\n }\n\n if (filepath == this.ignorer.filepath) {\n this.ignorer.reload();\n }\n },\n { stopOnError: false }\n );\n\n this.metadata.filesVersion = remoteFilesVersion;\n })\n .catch(this.stop);\n },\n }\n );\n\n const localFilesBuffer = new Map<string, { mode: number; mtime: number } | false>();\n\n this.publish = debounce(() => {\n const localFiles = new Map(localFilesBuffer.entries());\n localFilesBuffer.clear();\n\n void this.queue\n .add(async () => {\n const changed: FileSyncChangedEventInput[] = [];\n const deleted: FileSyncDeletedEventInput[] = [];\n\n await pMap(\n localFiles,\n async ([filepath, file]) => {\n if (file) {\n try {\n changed.push({\n path: this.normalize(filepath),\n mode: file.mode,\n content: this.decoder.decode(await fs.readFile(filepath)),\n });\n } catch (error) {\n // A file could have been changed and then deleted before we process the change event, so the readFile above will raise\n // an ENOENT. This is normal operation, so just ignore this event.\n ignoreEnoent(error);\n }\n } else {\n deleted.push({ path: this.normalize(filepath) });\n }\n },\n { stopOnError: false }\n );\n\n if (changed.length > 0 || deleted.length > 0) {\n this.log(\"Sent\");\n this.logPaths(Array.from(localFiles.keys()), { sep: \"→\" });\n\n const data = await this.client.queryUnwrap({\n query: PUBLISH_FILE_SYNC_EVENTS_MUTATION,\n variables: { input: { expectedRemoteFilesVersion: this.metadata.filesVersion, changed, deleted } },\n });\n\n const { remoteFilesVersion } = data.publishFileSyncEvents;\n this.debug(\"remote files version after publishing %s\", remoteFilesVersion);\n\n if (BigInt(remoteFilesVersion) > BigInt(this.metadata.filesVersion)) {\n this.metadata.filesVersion = remoteFilesVersion;\n }\n }\n })\n .catch(this.stop);\n }, this.filePushDelay);\n\n this.watcher\n .add(`${this.dir}/**/*`)\n .on(\"error\", (error) => void this.stop(error))\n .on(\"all\", (event, filepath, stats) => {\n const relativePath = this.relative(filepath);\n\n if (event === \"addDir\") {\n this.debug(\"skipping event caused by added directory %s\", relativePath);\n return;\n }\n\n if (stats?.isSymbolicLink?.()) {\n this.debug(\"skipping event caused by symlink %s\", relativePath);\n return;\n }\n\n if (filepath == this.ignorer.filepath) {\n this.ignorer.reload();\n } else if (this.ignorer.ignores(filepath)) {\n this.debug(\"skipping event caused by ignored file %s\", relativePath);\n return;\n }\n\n // we only update the mtime if the file is not ignored, because if we restart and the mtime is set to an ignored file, then it could\n // be greater than the mtime of all non ignored files and we'll think that local files have changed when only an ignored one has\n if (stats && stats.mtime.getTime() > this.metadata.mtime) {\n this.metadata.mtime = stats.mtime.getTime();\n }\n\n if (this.recentWrites.delete(filepath)) {\n this.debug(\"skipping event caused by recent write %s\", relativePath);\n return;\n }\n\n this.debug(\"file changed %s\", relativePath);\n\n switch (event) {\n case \"add\":\n case \"change\":\n assert(stats, \"missing stats on add/change event\");\n localFilesBuffer.set(filepath, { mode: stats.mode, mtime: stats.mtime.getTime() });\n break;\n case \"unlink\":\n case \"unlinkDir\":\n localFilesBuffer.set(filepath, false);\n break;\n }\n\n this.publish();\n });\n\n this.log(\"Ready\");\n this.status = SyncStatus.RUNNING;\n\n await sleepUntil(() => this.status == SyncStatus.STOPPED, { timeout: Infinity });\n\n if (error) {\n this.notify({ subtitle: \"Uh oh!\", message: \"An error occurred while syncing files\" });\n throw error;\n } else {\n this.log(\"Done\");\n }\n }\n}\n\nexport enum SyncStatus {\n STARTING,\n RUNNING,\n STOPPING,\n STOPPED,\n}\n\nexport enum Action {\n CANCEL = \"Cancel (Ctrl+C)\",\n MERGE = \"Merge local files with remote ones\",\n RESET = \"Reset local files to remote ones\",\n}\n\nexport const REMOTE_FILE_SYNC_EVENTS_SUBSCRIPTION: Query<\n RemoteFileSyncEventsSubscription,\n RemoteFileSyncEventsSubscriptionVariables\n> = /* GraphQL */ `\n subscription RemoteFileSyncEvents($localFilesVersion: String!) {\n remoteFileSyncEvents(localFilesVersion: $localFilesVersion) {\n remoteFilesVersion\n changed {\n path\n mode\n content\n }\n deleted {\n path\n }\n }\n }\n`;\n\nexport const REMOTE_FILES_VERSION_QUERY: Query<RemoteFilesVersionQuery, RemoteFilesVersionQueryVariables> = /* GraphQL */ `\n query RemoteFilesVersion {\n remoteFilesVersion\n }\n`;\n\nexport const PUBLISH_FILE_SYNC_EVENTS_MUTATION: Query<\n PublishFileSyncEventsMutation,\n PublishFileSyncEventsMutationVariables\n> = /* GraphQL */ `\n mutation PublishFileSyncEvents($input: PublishFileSyncEventsInput!) {\n publishFileSyncEvents(input: $input) {\n remoteFilesVersion\n }\n }\n`;\n"]}
|
|
1
|
+
{"version":3,"file":"sync.js","sourceRoot":"","sources":["../../src/commands/sync.ts"],"names":[],"mappings":";;;;AAAA,sCAAoC;AACpC,4DAA4B;AAC5B,uCAAqC;AACrC,0DAA0B;AAE1B,gEAA0B;AAC1B,uCAAkC;AAElC,mCAAkC;AAClC,4EAA2C;AAC3C,0DAAyB;AACzB,8DAA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,CAAA;IACR,iDAAO,CAAA;AACT,CAAC,EALW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAKrB;AAED,IAAY,MAIX;AAJD,WAAY,MAAM;IAChB,oCAA0B,CAAA;IAC1B,sDAA4C,CAAA;IAC5C,oDAA0C,CAAA;AAC5C,CAAC,EAJW,MAAM,GAAN,cAAM,KAAN,cAAM,QAIjB;AAEY,QAAA,oCAAoC,GAG/B;;;;;;;;;;;;;;CAcjB,CAAC;AAEW,QAAA,0BAA0B,GAAmF;;;;CAIzH,CAAC;AAEW,QAAA,iCAAiC,GAG5B;;;;;;CAMjB,CAAC","sourcesContent":["import { Flags } from \"@oclif/core\";\nimport assert from \"assert\";\nimport { FSWatcher } from \"chokidar\";\nimport execa from \"execa\";\nimport type { Stats } from \"fs-extra\";\nimport fs from \"fs-extra\";\nimport { prompt } from \"inquirer\";\nimport type { DebouncedFunc } from \"lodash\";\nimport { debounce } from \"lodash\";\nimport normalizePath from \"normalize-path\";\nimport pMap from \"p-map\";\nimport PQueue from \"p-queue\";\nimport path from \"path\";\nimport dedent from \"ts-dedent\";\nimport { TextDecoder, TextEncoder } from \"util\";\nimport which from \"which\";\nimport { api } from \"../lib/api\";\nimport { BaseCommand } from \"../lib/base-command\";\nimport type { Query } from \"../lib/client\";\nimport { Client } from \"../lib/client\";\nimport { FlagError, InvalidSyncFileError, YarnNotFoundError } from \"../lib/errors\";\nimport { app } from \"../lib/flags\";\nimport { ignoreEnoent, Ignorer, isEmptyDir, walkDir } from \"../lib/fs-utils\";\nimport { session } from \"../lib/session\";\nimport { sleepUntil } from \"../lib/sleep\";\nimport type {\n FileSyncChangedEventInput,\n FileSyncDeletedEventInput,\n PublishFileSyncEventsMutation,\n PublishFileSyncEventsMutationVariables,\n RemoteFilesVersionQuery,\n RemoteFilesVersionQueryVariables,\n RemoteFileSyncEventsSubscription,\n RemoteFileSyncEventsSubscriptionVariables,\n} from \"../__generated__/graphql\";\n\nexport default class Sync extends BaseCommand {\n static override priority = 1;\n\n static override summary = \"Sync your Gadget application's source code to and from your local filesystem.\";\n\n static override usage = \"sync [--app=<value>] [DIRECTORY]\";\n\n static override description = dedent`\n Sync provides the ability to sync your Gadget application's source code to and from your local\n filesystem. While \\`ggt sync\\` is running, local file changes are immediately reflected within\n Gadget, while files that are changed remotely are immediately saved to your local filesystem.\n\n Use 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\n Sync includes the concept of a \\`.ignore\\` file. This file can contain a list of files and\n directories that won't be sent to Gadget when syncing.\n\n The following files and directories are always ignored:\n * .gadget\n * .git\n * node_modules\n\n Note:\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\n `;\n\n static override args = [\n {\n name: \"directory\",\n description: \"The directory to sync files to. If the directory doesn't exist, it will be created.\",\n default: \".\",\n },\n ];\n\n static override flags = {\n app: app({\n summary: \"The Gadget application to sync files to.\",\n }),\n force: Flags.boolean({\n summary: \"Whether to sync even if we can't determine the state of your local files relative to your remote ones.\",\n default: false,\n }),\n \"file-push-delay\": Flags.integer({\n summary: \"Delay in milliseconds before pushing files to your app.\",\n helpGroup: \"file\",\n helpValue: \"ms\",\n default: 100,\n hidden: true,\n }),\n \"file-stability-threshold\": Flags.integer({\n name: \"file-stability-threshold\",\n summary: \"Time in milliseconds a file's size must remain the same.\",\n helpGroup: \"file\",\n helpValue: \"ms\",\n default: 500,\n hidden: true,\n }),\n \"file-poll-interval\": Flags.integer({\n name: \"file-poll-interval\",\n description: \"Interval in milliseconds between polling a file's size.\",\n helpGroup: \"file\",\n helpValue: \"ms\",\n default: 100,\n hidden: true,\n }),\n };\n\n static override examples = [\n dedent`\n $ ggt sync --app my-app ~/gadget/my-app\n Ready\n Received\n ← routes/GET.js\n ← user/signUp/signIn.js\n Sent\n → routes/GET.js\n ^C Stopping... (press Ctrl+C again to force)\n Done\n `,\n dedent`\n # 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\n `,\n ];\n\n override requireUser = true;\n\n status = SyncStatus.STARTING;\n\n dir!: string;\n\n recentWrites = new Set();\n\n encoder = new TextEncoder();\n\n decoder = new TextDecoder();\n\n filePushDelay!: number;\n\n queue = new PQueue({ concurrency: 1 });\n\n client!: Client;\n\n ignorer!: Ignorer;\n\n watcher!: FSWatcher;\n\n metadata = {\n app: \"\",\n filesVersion: \"0\",\n mtime: 0,\n };\n\n publish!: DebouncedFunc<() => void>;\n\n stop!: (error?: unknown) => Promise<void>;\n\n relative(to: string): string {\n return path.relative(this.dir, to);\n }\n\n absolute(...pathSegments: string[]): string {\n return path.resolve(this.dir, ...pathSegments);\n }\n\n normalize(filepath: string): string {\n return normalizePath(path.isAbsolute(filepath) ? this.relative(filepath) : filepath);\n }\n\n logPaths(filepaths: string[], { limit = 10, sep = \"-\" } = {}): void {\n let logged = 0;\n for (const filepath of filepaths) {\n this.log(`${sep} ${this.normalize(filepath)}`);\n if (++logged == limit && !this.debugEnabled) break;\n }\n\n if (filepaths.length > logged) {\n this.log(`… ${filepaths.length - logged} more`);\n }\n }\n\n override async init(): Promise<void> {\n await super.init();\n const { args, flags } = await this.parse(Sync);\n\n this.dir = path.resolve(args[\"directory\"] as string);\n\n const getApp = async (): Promise<string> => {\n if (flags.app) return flags.app;\n if (this.metadata.app) return this.metadata.app;\n const selected = await prompt<{ app: string }>({\n type: \"list\",\n name: \"app\",\n message: \"Please select the app to sync to.\",\n choices: await api.getApps().then((apps) => apps.map((app) => app.slug)),\n });\n return selected.app;\n };\n\n if (await isEmptyDir(this.dir)) {\n this.metadata.app = await getApp();\n } else {\n try {\n this.metadata = await fs.readJson(this.absolute(\".gadget\", \"sync.json\"));\n if (!this.metadata.app) {\n this.metadata.app = await getApp();\n }\n } catch (error) {\n if (!flags.force) {\n throw new InvalidSyncFileError(error, this, flags.app);\n }\n this.metadata.app = await getApp();\n }\n }\n\n if (flags.app && flags.app !== this.metadata.app && !flags.force) {\n throw new FlagError(\n { name: \"app\", char: \"a\" },\n dedent`\n You were about to sync the following app to the following directory:\n\n ${flags.app} → ${this.dir}\n\n However, that directory has already been synced with this app:\n\n ${this.metadata.app}\n\n If you're sure that you want to sync \"${flags.app}\" to \"${this.dir}\", run \\`ggt sync\\` again with the \\`--force\\` flag:\n\n $ ggt sync ${this.argv.join(\" \")} --force\n `\n );\n }\n\n this.client = new Client(this.metadata.app, {\n ws: {\n headers: {\n \"user-agent\": this.config.userAgent,\n cookie: `session=${encodeURIComponent(session.get() as string)};`,\n },\n },\n });\n\n this.filePushDelay = flags[\"file-push-delay\"];\n\n // local files that should never be published\n const ignored = [\"node_modules/\", \".gadget/\", \".git/\"];\n\n this.ignorer = new Ignorer(this.dir, ignored);\n\n this.watcher = new FSWatcher({\n ignored,\n // don't emit an event for every watched file on boot\n ignoreInitial: true,\n // make sure stats are always present on add/change events\n alwaysStat: true,\n // wait for the entire file to be written before emitting add/change events\n awaitWriteFinish: { pollInterval: flags[\"file-poll-interval\"], stabilityThreshold: flags[\"file-stability-threshold\"] },\n });\n\n this.debug(\"starting\");\n\n if (!which.sync(\"yarn\", { nothrow: true })) {\n throw new YarnNotFoundError();\n }\n\n await fs.ensureDir(this.dir);\n\n const { remoteFilesVersion } = await this.client.queryUnwrap({ query: REMOTE_FILES_VERSION_QUERY });\n const hasRemoteChanges = BigInt(remoteFilesVersion) > BigInt(this.metadata.filesVersion);\n\n const getChangedFiles = async (): Promise<Map<string, Stats>> => {\n const files = new Map();\n for await (const filepath of walkDir(this.dir, { ignorer: this.ignorer })) {\n const stats = await fs.stat(filepath);\n if (stats.mtime.getTime() > this.metadata.mtime) {\n files.set(this.absolute(filepath), stats);\n }\n }\n return files;\n };\n\n const changedFiles = await getChangedFiles();\n const hasLocalChanges = changedFiles.size > 0;\n if (hasLocalChanges) {\n this.log(\"Local files have changed since the last sync\");\n this.logPaths(Array.from(changedFiles.keys()), { limit: changedFiles.size });\n this.log();\n }\n\n this.debug(\"init %o\", { metadata: this.metadata, remoteFilesVersion, hasRemoteChanges, hasLocalChanges });\n\n let action: Action | undefined;\n if (hasLocalChanges) {\n ({ action } = await prompt({\n type: \"list\",\n name: \"action\",\n choices: [Action.CANCEL, Action.MERGE, Action.RESET],\n message: hasRemoteChanges ? \"Remote files have also changed. How would you like to proceed?\" : \"How would you like to proceed?\",\n }));\n }\n\n switch (action) {\n case Action.MERGE: {\n // get all the changed files again in case more changed\n const files = await getChangedFiles();\n\n // we purposefully don't set the returned remoteFilesVersion here because we haven't processed the in-between versions yet\n await this.client.queryUnwrap({\n query: PUBLISH_FILE_SYNC_EVENTS_MUTATION,\n variables: {\n input: {\n expectedRemoteFilesVersion: remoteFilesVersion,\n changed: await pMap(files, async ([filepath, stats]) => {\n if (stats.mtime.getTime() > this.metadata.mtime) {\n this.metadata.mtime = stats.mtime.getTime();\n }\n\n return {\n path: this.normalize(filepath),\n mode: stats.mode,\n content: this.decoder.decode(await fs.readFile(filepath)),\n };\n }),\n deleted: [],\n },\n },\n });\n break;\n }\n case Action.RESET: {\n await pMap(changedFiles, ([filepath]) => fs.remove(filepath));\n this.metadata.filesVersion = \"0\";\n break;\n }\n case Action.CANCEL: {\n process.exit(0);\n }\n }\n\n this.debug(\"started\");\n }\n\n async run(): Promise<void> {\n let error: unknown;\n\n this.stop = async (e?: unknown) => {\n if (this.status != SyncStatus.RUNNING) return;\n\n error = e;\n this.debug(\"stopping\");\n this.status = SyncStatus.STOPPING;\n\n try {\n unsubscribe();\n this.watcher.removeAllListeners();\n this.publish.flush();\n await this.queue.onIdle();\n } finally {\n await fs.outputJSON(this.absolute(\".gadget\", \"sync.json\"), this.metadata, { spaces: 2 });\n await Promise.allSettled([this.watcher.close(), this.client.dispose()]);\n\n this.debug(\"stopped\");\n this.status = SyncStatus.STOPPED;\n }\n };\n\n for (const signal of [\"SIGINT\", \"SIGTERM\"] as const) {\n process.on(signal, () => {\n if (this.status != SyncStatus.RUNNING) return;\n\n this.log(\" Stopping... (press Ctrl+C again to force)\");\n void this.stop();\n\n // When ggt is run via npx, and the user presses Ctrl+C, npx sends SIGINT twice in quick succession. In order to prevent the second\n // SIGINT from triggering the force exit listener, we wait a bit before registering it. This is a bit of a hack, but it works.\n setTimeout(() => {\n process.once(signal, () => {\n this.log(\" Exiting immediately. Note that files may not have finished syncing.\");\n process.exit(1);\n });\n }, 100).unref();\n });\n }\n\n const unsubscribe = this.client.subscribeUnwrap(\n {\n query: REMOTE_FILE_SYNC_EVENTS_SUBSCRIPTION,\n variables: () => ({ localFilesVersion: this.metadata.filesVersion }),\n },\n {\n error: (error) => void this.stop(error),\n next: ({ remoteFileSyncEvents: { remoteFilesVersion, changed, deleted } }) => {\n const remoteFiles = new Map([...deleted, ...changed].map((e) => [e.path, e]));\n\n void this.queue\n .add(async () => {\n if (!remoteFiles.size) {\n // we still need to update filesVersion, otherwise our expectedFilesVersion will be behind the next time we publish\n this.metadata.filesVersion = remoteFilesVersion;\n return;\n }\n\n this.log(\"Received\");\n this.logPaths(Array.from(remoteFiles.keys()), { sep: \"←\" });\n\n await pMap(\n remoteFiles,\n async ([relativePath, file]) => {\n const filepath = this.absolute(relativePath);\n this.recentWrites.add(filepath);\n\n if (\"content\" in file) {\n await fs.ensureDir(path.dirname(filepath), { mode: 0o755 });\n if (!file.path.endsWith(\"/\")) {\n await fs.writeFile(filepath, this.encoder.encode(file.content), { mode: file.mode });\n }\n if (filepath == this.absolute(\"yarn.lock\")) {\n await execa(\"yarn\", [\"install\"], { cwd: this.dir }).catch((err) => {\n this.debug(\"yarn install failed\");\n this.debug(err.message);\n });\n }\n } else {\n await fs.remove(filepath);\n }\n\n if (filepath == this.ignorer.filepath) {\n this.ignorer.reload();\n }\n },\n { stopOnError: false }\n );\n\n this.metadata.filesVersion = remoteFilesVersion;\n })\n .catch(this.stop);\n },\n }\n );\n\n const localFilesBuffer = new Map<string, { mode: number; mtime: number } | false>();\n\n this.publish = debounce(() => {\n const localFiles = new Map(localFilesBuffer.entries());\n localFilesBuffer.clear();\n\n void this.queue\n .add(async () => {\n const changed: FileSyncChangedEventInput[] = [];\n const deleted: FileSyncDeletedEventInput[] = [];\n\n await pMap(\n localFiles,\n async ([filepath, file]) => {\n if (file) {\n try {\n changed.push({\n path: this.normalize(filepath),\n mode: file.mode,\n content: this.decoder.decode(await fs.readFile(filepath)),\n });\n } catch (error) {\n // A file could have been changed and then deleted before we process the change event, so the readFile above will raise\n // an ENOENT. This is normal operation, so just ignore this event.\n ignoreEnoent(error);\n }\n } else {\n deleted.push({ path: this.normalize(filepath) });\n }\n },\n { stopOnError: false }\n );\n\n if (changed.length > 0 || deleted.length > 0) {\n this.log(\"Sent\");\n this.logPaths(Array.from(localFiles.keys()), { sep: \"→\" });\n\n const data = await this.client.queryUnwrap({\n query: PUBLISH_FILE_SYNC_EVENTS_MUTATION,\n variables: { input: { expectedRemoteFilesVersion: this.metadata.filesVersion, changed, deleted } },\n });\n\n const { remoteFilesVersion } = data.publishFileSyncEvents;\n this.debug(\"remote files version after publishing %s\", remoteFilesVersion);\n\n if (BigInt(remoteFilesVersion) > BigInt(this.metadata.filesVersion)) {\n this.metadata.filesVersion = remoteFilesVersion;\n }\n }\n })\n .catch(this.stop);\n }, this.filePushDelay);\n\n this.watcher\n .add(`${this.dir}/**/*`)\n .on(\"error\", (error) => void this.stop(error))\n .on(\"all\", (event, filepath, stats) => {\n const relativePath = this.relative(filepath);\n\n if (event === \"addDir\") {\n this.debug(\"skipping event caused by added directory %s\", relativePath);\n return;\n }\n\n if (stats?.isSymbolicLink?.()) {\n this.debug(\"skipping event caused by symlink %s\", relativePath);\n return;\n }\n\n if (filepath == this.ignorer.filepath) {\n this.ignorer.reload();\n } else if (this.ignorer.ignores(filepath)) {\n this.debug(\"skipping event caused by ignored file %s\", relativePath);\n return;\n }\n\n // we only update the mtime if the file is not ignored, because if we restart and the mtime is set to an ignored file, then it could\n // be greater than the mtime of all non ignored files and we'll think that local files have changed when only an ignored one has\n if (stats && stats.mtime.getTime() > this.metadata.mtime) {\n this.metadata.mtime = stats.mtime.getTime();\n }\n\n if (this.recentWrites.delete(filepath)) {\n this.debug(\"skipping event caused by recent write %s\", relativePath);\n return;\n }\n\n this.debug(\"file changed %s\", relativePath);\n\n switch (event) {\n case \"add\":\n case \"change\":\n assert(stats, \"missing stats on add/change event\");\n localFilesBuffer.set(filepath, { mode: stats.mode, mtime: stats.mtime.getTime() });\n break;\n case \"unlink\":\n case \"unlinkDir\":\n localFilesBuffer.set(filepath, false);\n break;\n }\n\n this.publish();\n });\n\n this.log(\"Ready\");\n this.status = SyncStatus.RUNNING;\n\n await sleepUntil(() => this.status == SyncStatus.STOPPED, { timeout: Infinity });\n\n if (error) {\n this.notify({ subtitle: \"Uh oh!\", message: \"An error occurred while syncing files\" });\n throw error;\n } else {\n this.log(\"Done\");\n }\n }\n}\n\nexport enum SyncStatus {\n STARTING,\n RUNNING,\n STOPPING,\n STOPPED,\n}\n\nexport enum Action {\n CANCEL = \"Cancel (Ctrl+C)\",\n MERGE = \"Merge local files with remote ones\",\n RESET = \"Reset local files to remote ones\",\n}\n\nexport const REMOTE_FILE_SYNC_EVENTS_SUBSCRIPTION: Query<\n RemoteFileSyncEventsSubscription,\n RemoteFileSyncEventsSubscriptionVariables\n> = /* GraphQL */ `\n subscription RemoteFileSyncEvents($localFilesVersion: String!) {\n remoteFileSyncEvents(localFilesVersion: $localFilesVersion) {\n remoteFilesVersion\n changed {\n path\n mode\n content\n }\n deleted {\n path\n }\n }\n }\n`;\n\nexport const REMOTE_FILES_VERSION_QUERY: Query<RemoteFilesVersionQuery, RemoteFilesVersionQueryVariables> = /* GraphQL */ `\n query RemoteFilesVersion {\n remoteFilesVersion\n }\n`;\n\nexport const PUBLISH_FILE_SYNC_EVENTS_MUTATION: Query<\n PublishFileSyncEventsMutation,\n PublishFileSyncEventsMutationVariables\n> = /* GraphQL */ `\n mutation PublishFileSyncEvents($input: PublishFileSyncEventsInput!) {\n publishFileSyncEvents(input: $input) {\n remoteFilesVersion\n }\n }\n`;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"whoami.js","sourceRoot":"","sources":["../../src/commands/whoami.ts"],"names":[],"mappings":";;;AAAA,kEAA+B;AAC/B,oCAAiC;AACjC,sDAAkD;AAElD,MAAqB,MAAO,SAAQ,0BAAW;IAY7C,KAAK,CAAC,GAAG;QACP,MAAM,IAAI,GAAG,MAAM,SAAG,CAAC,cAAc,EAAE,CAAC;QACxC,IAAI,CAAC,IAAI,EAAE;YACT,IAAI,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;YAClC,OAAO;SACR;QAED,IAAI,IAAI,CAAC,IAAI,EAAE;YACb,IAAI,CAAC,GAAG,CAAC,wBAAwB,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;SAC/D;aAAM;YACL,IAAI,CAAC,GAAG,CAAC,wBAAwB,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;SAChD;IACH,CAAC;;AAxBH,yBAyBC;
|
|
1
|
+
{"version":3,"file":"whoami.js","sourceRoot":"","sources":["../../src/commands/whoami.ts"],"names":[],"mappings":";;;AAAA,kEAA+B;AAC/B,oCAAiC;AACjC,sDAAkD;AAElD,MAAqB,MAAO,SAAQ,0BAAW;IAY7C,KAAK,CAAC,GAAG;QACP,MAAM,IAAI,GAAG,MAAM,SAAG,CAAC,cAAc,EAAE,CAAC;QACxC,IAAI,CAAC,IAAI,EAAE;YACT,IAAI,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;YAClC,OAAO;SACR;QAED,IAAI,IAAI,CAAC,IAAI,EAAE;YACb,IAAI,CAAC,GAAG,CAAC,wBAAwB,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;SAC/D;aAAM;YACL,IAAI,CAAC,GAAG,CAAC,wBAAwB,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;SAChD;IACH,CAAC;;AAxBH,yBAyBC;AAxBQ;;;;WAAmB,kEAAkE;GAAC;AAEtF;;;;WAAiB,QAAQ;GAAC;AAE1B;;;;WAAoB;QACzB,IAAA,mBAAM,EAAA;;;KAGL;KACF;GAAC","sourcesContent":["import dedent from \"ts-dedent\";\nimport { api } from \"../lib/api\";\nimport { BaseCommand } from \"../lib/base-command\";\n\nexport default class Whoami extends BaseCommand {\n static override summary = \"Show the name and email address of the currently logged in user.\";\n\n static override usage = \"whoami\";\n\n static override examples = [\n dedent`\n $ ggt whoami\n You are logged in as Jane Doe (jane@example.com)\n `,\n ];\n\n async run(): Promise<void> {\n const user = await api.getCurrentUser();\n if (!user) {\n this.log(\"You are not logged in\");\n return;\n }\n\n if (user.name) {\n this.log(`You are logged in as ${user.name} (${user.email})`);\n } else {\n this.log(`You are logged in as ${user.email}`);\n }\n }\n}\n"]}
|
|
@@ -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,+BAA6C;AAC7C,qCAAqC;AACrC,qCAAsE;AACtE,uCAAoC;AAEpC,MAAsB,WAAY,SAAQ,cAAO;IAsB/C,YAAY,IAAc,EAAE,MAAc;QACxC,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAPtB;;;WAGG;QACH;;;;mBAAgC,KAAK;WAAC;IAItC,CAAC;IAED;;OAEG;IACH,IAAI,YAAY;QACd,OAAO,CAAC,CAAC,eAAQ,CAAC,KAAK,CAAC;IAC1B,CAAC;IAEQ,KAAK,CAAC,IAAI;QACj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AAC,CAAC,CAAC;QAEzC,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;;AApKH,kCAqKC;AApKC;;;GAGG;AACI;;;;WAAW,QAAQ;GAAC;AAE3B;;;;WAA8B;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 { api, GADGET_ENDPOINT } from \"./api\";\nimport { setConfig } from \"./config\";\nimport { BaseError, UnexpectedError as UnknownError } from \"./errors\";\nimport { session } from \"./session\";\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\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 setConfig(this.config);\n\n if (this.requireUser && !(await api.getCurrentUser())) {\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 session.set(value);\n\n const user = await api.getCurrentUser();\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 session.set(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 catch(cause: Error & { exitCode?: number }): never {\n const error = cause instanceof BaseError ? cause : new UnknownError(cause);\n console.error(error.render(this.config));\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;AACx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8DAA8D,CAAC,CAAC;YAEzE,MAAM,cAAc,CAAC;SACtB;gBAAS;YACR,MAAM,EAAE,KAAK,EAAE,CAAC;SACjB;IACH,CAAC;IAED;;;OAGG;IACM,KAAK,CAAC,KAAoC;QACjD,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,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;QAEzC,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;;AApKH,kCAqKC;AApKC;;;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 { api, GADGET_ENDPOINT } from \"./api\";\nimport { setConfig } from \"./config\";\nimport { BaseError, UnexpectedError as UnknownError } from \"./errors\";\nimport { session } from \"./session\";\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\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 setConfig(this.config);\n\n if (this.requireUser && !(await api.getCurrentUser())) {\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 session.set(value);\n\n const user = await api.getCurrentUser();\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 session.set(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 catch(cause: Error & { exitCode?: number }): never {\n const error = cause instanceof BaseError ? cause : new UnknownError(cause);\n console.error(error.render(this.config));\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/dist/lib/errors.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { Config } from "@oclif/core";
|
|
2
|
-
import type { OptionFlag } from "@oclif/core/lib/interfaces";
|
|
3
2
|
import type { GraphQLError } from "graphql";
|
|
4
3
|
import newGithubIssueUrl from "new-github-issue-url";
|
|
5
4
|
import type { CloseEvent, ErrorEvent } from "ws";
|
|
@@ -72,11 +71,14 @@ export declare class YarnNotFoundError extends BaseError {
|
|
|
72
71
|
constructor();
|
|
73
72
|
protected body(_: Config): string;
|
|
74
73
|
}
|
|
75
|
-
export declare class FlagError extends
|
|
76
|
-
|
|
74
|
+
export declare class FlagError<T extends {
|
|
75
|
+
name: string;
|
|
76
|
+
char?: string;
|
|
77
|
+
}> extends BaseError {
|
|
78
|
+
readonly flag: T;
|
|
77
79
|
readonly description: string;
|
|
78
80
|
isBug: IsBug;
|
|
79
|
-
constructor(flag:
|
|
81
|
+
constructor(flag: T, description: string);
|
|
80
82
|
protected body(_: Config): string;
|
|
81
83
|
}
|
|
82
84
|
export declare class InvalidSyncFileError extends BaseError {
|
package/dist/lib/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/lib/errors.ts"],"names":[],"mappings":";;;;AAEA,sEAAqC;AACrC,4CAA4C;AAE5C,mCAAwF;AACxF,wFAAqD;AACrD,qDAAuE;AACvE,kEAA+B;AAE/B,+BAA+B;AAK/B;;;;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;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CAAC,IAAI,IAAA,gBAAO,EAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AACnH,CAAC","sourcesContent":["import type { Config } from \"@oclif/core\";\nimport type { OptionFlag } from \"@oclif/core/lib/interfaces\";\nimport cleanStack from \"clean-stack\";\nimport { HTTPError } from \"got/dist/source\";\nimport type { GraphQLError } from \"graphql\";\nimport { isArray, isBoolean, isError, isNil, isNumber, isString, 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\";\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 /**\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(config: Config): string {\n const header = this.header(config);\n const body = this.body(config);\n const footer = this.footer(config);\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(_: Config): string {\n return `${this.code}: ${this.message}`;\n }\n\n protected footer(config: Config): 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(config))}\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(config))}\n `;\n }\n }\n\n protected issueOptions(config: Config): 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 ${config.bin} ${process.argv.slice(2).join(\" \")}\n \\`\\`\\`\n\n ### Environment\n \\`\\`\\`\n version: ${config.version}\n platform: ${config.platform}\n arch: ${config.arch}\n shell: ${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(_: Config): 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 NO,\n MAYBE,\n YES,\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(_: Config): 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(_: Config): 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(config: Config): newGithubIssueUrl.Options {\n const options = super.issueOptions(config) 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(_: Config): 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 extends BaseError {\n isBug = IsBug.NO;\n\n constructor(readonly flag: Partial<OptionFlag<unknown>>, 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(_: Config): 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(_: Config): 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":";;;;AACA,sEAAqC;AACrC,4CAA4C;AAE5C,mCAAwF;AACxF,wFAAqD;AACrD,qDAAuE;AACvE,kEAA+B;AAE/B,+BAA+B;AAK/B;;;;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;;;OAGG;IACH,MAAM,CAAC,MAAc;QACnB,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACnC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC/B,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAEnC,IAAI,MAAM,GAAG,EAAE,CAAC;QAChB,IAAI,MAAM;YAAE,MAAM,IAAI,MAAM,GAAG,MAAM,CAAC;QACtC,IAAI,IAAI;YAAE,MAAM,IAAI,IAAI,GAAG,MAAM,CAAC;QAClC,IAAI,MAAM;YAAE,MAAM,IAAI,MAAM,GAAG,MAAM,CAAC;QAEtC,OAAO,MAAM,CAAC;IAChB,CAAC;IAES,MAAM,CAAC,CAAS;QACxB,OAAO,GAAG,IAAI,CAAC,IAAI,K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AQ,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,CAAC,IAAI,IAAA,gBAAO,EAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AACnH,CAAC","sourcesContent":["import type { Config } from \"@oclif/core\";\nimport cleanStack from \"clean-stack\";\nimport { HTTPError } from \"got/dist/source\";\nimport type { GraphQLError } from \"graphql\";\nimport { isArray, isBoolean, isError, isNil, isNumber, isString, 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\";\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 /**\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(config: Config): string {\n const header = this.header(config);\n const body = this.body(config);\n const footer = this.footer(config);\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(_: Config): string {\n return `${this.code}: ${this.message}`;\n }\n\n protected footer(config: Config): 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(config))}\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(config))}\n `;\n }\n }\n\n protected issueOptions(config: Config): 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 ${config.bin} ${process.argv.slice(2).join(\" \")}\n \\`\\`\\`\n\n ### Environment\n \\`\\`\\`\n version: ${config.version}\n platform: ${config.platform}\n arch: ${config.arch}\n shell: ${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(_: Config): 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 NO,\n MAYBE,\n YES,\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(_: Config): 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(_: Config): 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(config: Config): newGithubIssueUrl.Options {\n const options = super.issueOptions(config) 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(_: Config): 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(_: Config): 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(_: Config): 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"]}
|
package/dist/lib/flags.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const app: import("@oclif/core/lib/interfaces").Definition<string
|
|
1
|
+
export declare const app: import("@oclif/core/lib/interfaces").Definition<string, Record<string, unknown>>;
|
package/dist/lib/flags.js
CHANGED
|
@@ -8,14 +8,14 @@ const lodash_1 = require("lodash");
|
|
|
8
8
|
const ts_dedent_1 = tslib_1.__importDefault(require("ts-dedent"));
|
|
9
9
|
const api_1 = require("./api");
|
|
10
10
|
const errors_1 = require("./errors");
|
|
11
|
-
exports.app = core_1.Flags.
|
|
11
|
+
exports.app = core_1.Flags.custom({
|
|
12
12
|
char: "a",
|
|
13
13
|
name: "app",
|
|
14
14
|
summary: "The Gadget application this command applies to.",
|
|
15
|
-
async
|
|
15
|
+
parse: async (value) => {
|
|
16
16
|
const name = /^(https:\/\/)?(?<name>[\w-]+)(\..*)?/.exec(value)?.groups?.["name"];
|
|
17
17
|
if (!name)
|
|
18
|
-
throw new errors_1.FlagError(
|
|
18
|
+
throw new errors_1.FlagError(exports.app, (0, ts_dedent_1.default) `
|
|
19
19
|
The -a, --app flag must be the application's name, slug, or URL
|
|
20
20
|
|
|
21
21
|
Examples:
|
|
@@ -26,10 +26,12 @@ exports.app = core_1.Flags.build({
|
|
|
26
26
|
--app https://my-app.gadget.app/edit
|
|
27
27
|
`);
|
|
28
28
|
const availableApps = await api_1.api.getApps();
|
|
29
|
-
const
|
|
30
|
-
if (
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
const foundApp = availableApps.find((a) => a.name == name || a.slug == name);
|
|
30
|
+
if (foundApp) {
|
|
31
|
+
return foundApp.slug;
|
|
32
|
+
}
|
|
33
|
+
throw new errors_1.FlagError(exports.app, availableApps.length > 0
|
|
34
|
+
? (0, ts_dedent_1.default) `
|
|
33
35
|
Unknown application:
|
|
34
36
|
|
|
35
37
|
${value}
|
|
@@ -37,11 +39,11 @@ exports.app = core_1.Flags.build({
|
|
|
37
39
|
Did you mean one of these?
|
|
38
40
|
|
|
39
41
|
${(0, lodash_1.sortBy)(availableApps, (app) => fast_levenshtein_1.default.get(app.slug, name))
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
.slice(0, 10)
|
|
43
|
+
.map((app) => `* ${app.slug}`)
|
|
44
|
+
.join("\n")}
|
|
43
45
|
`
|
|
44
|
-
|
|
46
|
+
: (0, ts_dedent_1.default) `
|
|
45
47
|
Unknown application:
|
|
46
48
|
|
|
47
49
|
${value}
|
|
@@ -50,8 +52,6 @@ exports.app = core_1.Flags.build({
|
|
|
50
52
|
|
|
51
53
|
Visit https://gadget.new to create one!
|
|
52
54
|
`);
|
|
53
|
-
}
|
|
54
|
-
return app.slug;
|
|
55
55
|
},
|
|
56
56
|
});
|
|
57
57
|
//# sourceMappingURL=flags.js.map
|
package/dist/lib/flags.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,+BAA4B;AAC5B,qCAAqC;AAExB,QAAA,GAAG,GAAG,YAAK,CAAC,
|
|
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,+BAA4B;AAC5B,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,SAAG,CAAC,OAAO,EAAE,CAAC;QAC1C,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 { api } from \"./api\";\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 api.getApps();\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"]}
|