@gadgetinc/ggt 0.1.11 → 0.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -6
- package/lib/commands/help.d.ts +2 -4
- package/lib/commands/help.js +6 -1
- package/lib/commands/help.js.map +1 -1
- package/lib/commands/login.d.ts +1 -1
- package/lib/commands/login.js.map +1 -1
- package/lib/commands/logout.d.ts +1 -1
- package/lib/commands/logout.js.map +1 -1
- package/lib/commands/sync.d.ts +9 -10
- package/lib/commands/sync.js +33 -27
- package/lib/commands/sync.js.map +1 -1
- package/lib/commands/whoami.d.ts +1 -1
- package/lib/commands/whoami.js.map +1 -1
- package/lib/utils/base-command.d.ts +14 -4
- package/lib/utils/base-command.js +33 -10
- package/lib/utils/base-command.js.map +1 -1
- package/lib/utils/client.js +1 -2
- package/lib/utils/client.js.map +1 -1
- package/lib/utils/context.d.ts +6 -2
- package/lib/utils/context.js +15 -5
- package/lib/utils/context.js.map +1 -1
- package/lib/utils/errors.d.ts +1 -1
- package/lib/utils/errors.js +3 -3
- package/lib/utils/errors.js.map +1 -1
- package/lib/utils/flags.d.ts +1 -1
- package/lib/utils/help.d.ts +2 -2
- package/lib/utils/help.js.map +1 -1
- package/npm-shrinkwrap.json +3606 -2844
- package/oclif.manifest.json +135 -1
- package/package.json +35 -35
package/README.md
CHANGED
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
Run the following to sync a `my-app.gadget.app` application to the `~/gadget/my-app` on your local machine:
|
|
32
32
|
|
|
33
33
|
```sh
|
|
34
|
-
npx @gadgetinc/ggt sync --app my-app ~/gadget/my-app
|
|
34
|
+
npx @gadgetinc/ggt@latest sync --app my-app ~/gadget/my-app
|
|
35
35
|
```
|
|
36
36
|
|
|
37
37
|
With this running in the background, your local `~/gadget/my-app` folder will become two-way synced with your application's filesystem in Gadget's cloud. Changes you make locally will be immediately reflected by your application's API and actions if you re-run them.
|
|
@@ -128,7 +128,7 @@ EXAMPLES
|
|
|
128
128
|
Goodbye!
|
|
129
129
|
```
|
|
130
130
|
|
|
131
|
-
_See code: [src/commands/sync.ts](https://github.com/gadget-inc/ggt/blob/v0.1.
|
|
131
|
+
_See code: [src/commands/sync.ts](https://github.com/gadget-inc/ggt/blob/v0.1.13/src/commands/sync.ts)_
|
|
132
132
|
|
|
133
133
|
### `ggt help [COMMAND]`
|
|
134
134
|
|
|
@@ -142,7 +142,7 @@ ARGUMENTS
|
|
|
142
142
|
COMMAND The command to show help for.
|
|
143
143
|
```
|
|
144
144
|
|
|
145
|
-
_See code: [src/commands/help.ts](https://github.com/gadget-inc/ggt/blob/v0.1.
|
|
145
|
+
_See code: [src/commands/help.ts](https://github.com/gadget-inc/ggt/blob/v0.1.13/src/commands/help.ts)_
|
|
146
146
|
|
|
147
147
|
### `ggt login`
|
|
148
148
|
|
|
@@ -161,7 +161,7 @@ EXAMPLES
|
|
|
161
161
|
Hello, Jane Doe (jane@example.com)
|
|
162
162
|
```
|
|
163
163
|
|
|
164
|
-
_See code: [src/commands/login.ts](https://github.com/gadget-inc/ggt/blob/v0.1.
|
|
164
|
+
_See code: [src/commands/login.ts](https://github.com/gadget-inc/ggt/blob/v0.1.13/src/commands/login.ts)_
|
|
165
165
|
|
|
166
166
|
### `ggt logout`
|
|
167
167
|
|
|
@@ -176,7 +176,7 @@ EXAMPLES
|
|
|
176
176
|
Goodbye
|
|
177
177
|
```
|
|
178
178
|
|
|
179
|
-
_See code: [src/commands/logout.ts](https://github.com/gadget-inc/ggt/blob/v0.1.
|
|
179
|
+
_See code: [src/commands/logout.ts](https://github.com/gadget-inc/ggt/blob/v0.1.13/src/commands/logout.ts)_
|
|
180
180
|
|
|
181
181
|
### `ggt whoami`
|
|
182
182
|
|
|
@@ -191,7 +191,7 @@ EXAMPLES
|
|
|
191
191
|
You are logged in as Jane Doe (jane@example.com)
|
|
192
192
|
```
|
|
193
193
|
|
|
194
|
-
_See code: [src/commands/whoami.ts](https://github.com/gadget-inc/ggt/blob/v0.1.
|
|
194
|
+
_See code: [src/commands/whoami.ts](https://github.com/gadget-inc/ggt/blob/v0.1.13/src/commands/whoami.ts)_
|
|
195
195
|
|
|
196
196
|
<!-- commandsstop -->
|
|
197
197
|
|
package/lib/commands/help.d.ts
CHANGED
|
@@ -8,9 +8,7 @@ export default class HelpCommand extends Command {
|
|
|
8
8
|
static strict: boolean;
|
|
9
9
|
static summary: string;
|
|
10
10
|
static args: {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
description: string;
|
|
14
|
-
}[];
|
|
11
|
+
command: import("@oclif/core/lib/interfaces/parser").Arg<string | undefined, Record<string, unknown>>;
|
|
12
|
+
};
|
|
15
13
|
run(): Promise<void>;
|
|
16
14
|
}
|
package/lib/commands/help.js
CHANGED
|
@@ -32,6 +32,11 @@ Object.defineProperty(HelpCommand, "args", {
|
|
|
32
32
|
enumerable: true,
|
|
33
33
|
configurable: true,
|
|
34
34
|
writable: true,
|
|
35
|
-
value:
|
|
35
|
+
value: {
|
|
36
|
+
command: core_1.Args.string({
|
|
37
|
+
required: false,
|
|
38
|
+
description: "The command to show help for.",
|
|
39
|
+
}),
|
|
40
|
+
}
|
|
36
41
|
});
|
|
37
42
|
//# sourceMappingURL=help.js.map
|
package/lib/commands/help.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"help.js","sourceRoot":"","sources":["../../src/commands/help.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"help.js","sourceRoot":"","sources":["../../src/commands/help.ts"],"names":[],"mappings":";;;AAAA,sCAA4C;AAC5C,iEAAiC;AAEjC;;;;GAIG;AACH,MAAqB,WAAY,SAAQ,cAAO;IAY9C,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,IAAgB,CAAC,CAAC;IACxC,CAAC;;AAhBH,8BAiBC;AAhBQ;;;;WAAkB,KAAK;GAAC;AAExB;;;;WAAmB,uBAAuB;GAAC;AAE3C;;;;WAAgB;QACrB,OAAO,EAAE,WAAI,CAAC,MAAM,CAAC;YACnB,QAAQ,EAAE,KAAK;YACf,WAAW,EAAE,+BAA+B;SAC7C,CAAC;KACH;GAAC","sourcesContent":["import { Args, Command } from \"@oclif/core\";\nimport Help from \"../utils/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 = {\n command: Args.string({\n required: false,\n description: \"The command to show help for.\",\n }),\n };\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 as string[]);\n }\n}\n"]}
|
package/lib/commands/login.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":";;;AAAA,kEAA+B;AAC/B,wDAAoD;AACpD,0DAA0B;AAE1B,MAAqB,KAAM,SAAQ,
|
|
1
|
+
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":";;;AAAA,kEAA+B;AAC/B,wDAAoD;AACpD,0DAA0B;AAE1B,MAAqB,KAAM,SAAQ,0BAAyB;IAgB1D,KAAK,CAAC,GAAG;QACP,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;;AAlBH,wBAmBC;AAlBQ;;;;WAAmB,yBAAyB;GAAC;AAE7C;;;;WAAiB,OAAO;GAAC;AAEzB;;;;WAAoB;QACzB,IAAA,mBAAM,EAAC,IAAA,eAAK,EAAA;;;;;;;KAOX,CAAC;KACH;GAAC","sourcesContent":["import dedent from \"ts-dedent\";\nimport { BaseCommand } from \"../utils/base-command\";\nimport chalk from \"chalk\";\n\nexport default class Login extends BaseCommand<typeof Login> {\n static override summary = \"Log in to your account.\";\n\n static override usage = \"login\";\n\n static override examples = [\n dedent(chalk`\n {gray $ ggt login}\n We've opened Gadget's login page using your default browser.\n\n Please log in and then return to this terminal.\n\n Hello, Jane Doe {gray (jane@example.com)}\n `),\n ];\n\n async run(): Promise<void> {\n await this.login();\n }\n}\n"]}
|
package/lib/commands/logout.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logout.js","sourceRoot":"","sources":["../../src/commands/logout.ts"],"names":[],"mappings":";;;AAAA,0DAA0B;AAC1B,kEAA+B;AAC/B,wDAAoD;AACpD,8CAA2C;AAE3C,MAAqB,MAAO,SAAQ,
|
|
1
|
+
{"version":3,"file":"logout.js","sourceRoot":"","sources":["../../src/commands/logout.ts"],"names":[],"mappings":";;;AAAA,0DAA0B;AAC1B,kEAA+B;AAC/B,wDAAoD;AACpD,8CAA2C;AAE3C,MAAqB,MAAO,SAAQ,0BAA0B;IAY5D,4DAA4D;IAC5D,KAAK,CAAC,GAAG;QACP,IAAI,iBAAO,CAAC,OAAO,EAAE;YACnB,iBAAO,CAAC,OAAO,GAAG,SAAS,CAAC;YAC5B,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;SACrB;aAAM;YACL,IAAI,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;SACnC;IACH,CAAC;;AApBH,yBAqBC;AApBQ;;;;WAAmB,0BAA0B;GAAC;AAE9C;;;;WAAiB,QAAQ;GAAC;AAE1B;;;;WAAoB;QACzB,IAAA,mBAAM,EAAC,IAAA,eAAK,EAAA;;;KAGX,CAAC;KACH;GAAC","sourcesContent":["import chalk from \"chalk\";\nimport dedent from \"ts-dedent\";\nimport { BaseCommand } from \"../utils/base-command\";\nimport { context } from \"../utils/context\";\n\nexport default class Logout extends BaseCommand<typeof Logout> {\n static override summary = \"Log out of your account.\";\n\n static override usage = \"logout\";\n\n static override examples = [\n dedent(chalk`\n {gray $ ggt logout}\n Goodbye\n `),\n ];\n\n // eslint-disable-next-line @typescript-eslint/require-await\n async run(): Promise<void> {\n if (context.session) {\n context.session = undefined;\n this.log(\"Goodbye\");\n } else {\n this.log(\"You are not logged in\");\n }\n }\n}\n"]}
|
package/lib/commands/sync.d.ts
CHANGED
|
@@ -6,29 +6,26 @@ import type { Query } from "../utils/client";
|
|
|
6
6
|
import { Client } from "../utils/client";
|
|
7
7
|
import { Ignorer } from "../utils/fs-utils";
|
|
8
8
|
import type { PublishFileSyncEventsMutation, PublishFileSyncEventsMutationVariables, RemoteFilesVersionQuery, RemoteFilesVersionQueryVariables, RemoteFileSyncEventsSubscription, RemoteFileSyncEventsSubscriptionVariables } from "../__generated__/graphql";
|
|
9
|
-
export default class Sync extends BaseCommand {
|
|
9
|
+
export default class Sync extends BaseCommand<typeof Sync> {
|
|
10
10
|
static priority: number;
|
|
11
11
|
static summary: string;
|
|
12
12
|
static usage: string;
|
|
13
13
|
static description: string;
|
|
14
14
|
static args: {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
default: string;
|
|
18
|
-
}[];
|
|
15
|
+
directory: import("@oclif/core/lib/interfaces/parser").Arg<string, Record<string, unknown>>;
|
|
16
|
+
};
|
|
19
17
|
static flags: {
|
|
20
|
-
app: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined>;
|
|
18
|
+
app: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
21
19
|
force: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
22
|
-
"file-push-delay": import("@oclif/core/lib/interfaces").OptionFlag<number>;
|
|
23
|
-
"file-stability-threshold": import("@oclif/core/lib/interfaces").OptionFlag<number>;
|
|
24
|
-
"file-poll-interval": import("@oclif/core/lib/interfaces").OptionFlag<number>;
|
|
20
|
+
"file-push-delay": import("@oclif/core/lib/interfaces").OptionFlag<number, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
21
|
+
"file-stability-threshold": import("@oclif/core/lib/interfaces").OptionFlag<number, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
22
|
+
"file-poll-interval": import("@oclif/core/lib/interfaces").OptionFlag<number, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
25
23
|
};
|
|
26
24
|
static examples: string[];
|
|
27
25
|
requireUser: boolean;
|
|
28
26
|
status: SyncStatus;
|
|
29
27
|
dir: string;
|
|
30
28
|
recentWrites: Set<unknown>;
|
|
31
|
-
filePushDelay: number;
|
|
32
29
|
queue: PQueue<import("p-queue/dist/priority-queue").default, import("p-queue").DefaultAddOptions>;
|
|
33
30
|
client: Client;
|
|
34
31
|
ignorer: Ignorer;
|
|
@@ -40,6 +37,8 @@ export default class Sync extends BaseCommand {
|
|
|
40
37
|
};
|
|
41
38
|
publish: DebouncedFunc<() => void>;
|
|
42
39
|
stop: (error?: unknown) => Promise<void>;
|
|
40
|
+
finished: Promise<void>;
|
|
41
|
+
markFinished: () => void;
|
|
43
42
|
relative(to: string): string;
|
|
44
43
|
absolute(...pathSegments: string[]): string;
|
|
45
44
|
normalize(filepath: string): string;
|
package/lib/commands/sync.js
CHANGED
|
@@ -26,7 +26,6 @@ const context_1 = require("../utils/context");
|
|
|
26
26
|
const errors_1 = require("../utils/errors");
|
|
27
27
|
const flags_1 = require("../utils/flags");
|
|
28
28
|
const fs_utils_1 = require("../utils/fs-utils");
|
|
29
|
-
const sleep_1 = require("../utils/sleep");
|
|
30
29
|
const graphql_1 = require("../__generated__/graphql");
|
|
31
30
|
class Sync extends base_command_1.BaseCommand {
|
|
32
31
|
constructor() {
|
|
@@ -55,12 +54,6 @@ class Sync extends base_command_1.BaseCommand {
|
|
|
55
54
|
writable: true,
|
|
56
55
|
value: new Set()
|
|
57
56
|
});
|
|
58
|
-
Object.defineProperty(this, "filePushDelay", {
|
|
59
|
-
enumerable: true,
|
|
60
|
-
configurable: true,
|
|
61
|
-
writable: true,
|
|
62
|
-
value: void 0
|
|
63
|
-
});
|
|
64
57
|
Object.defineProperty(this, "queue", {
|
|
65
58
|
enumerable: true,
|
|
66
59
|
configurable: true,
|
|
@@ -107,6 +100,18 @@ class Sync extends base_command_1.BaseCommand {
|
|
|
107
100
|
writable: true,
|
|
108
101
|
value: void 0
|
|
109
102
|
});
|
|
103
|
+
Object.defineProperty(this, "finished", {
|
|
104
|
+
enumerable: true,
|
|
105
|
+
configurable: true,
|
|
106
|
+
writable: true,
|
|
107
|
+
value: void 0
|
|
108
|
+
});
|
|
109
|
+
Object.defineProperty(this, "markFinished", {
|
|
110
|
+
enumerable: true,
|
|
111
|
+
configurable: true,
|
|
112
|
+
writable: true,
|
|
113
|
+
value: void 0
|
|
114
|
+
});
|
|
110
115
|
}
|
|
111
116
|
relative(to) {
|
|
112
117
|
return path_1.default.relative(this.dir, to);
|
|
@@ -136,15 +141,14 @@ class Sync extends base_command_1.BaseCommand {
|
|
|
136
141
|
}
|
|
137
142
|
async init() {
|
|
138
143
|
await super.init();
|
|
139
|
-
|
|
140
|
-
(0, assert_1.default)((0, lodash_2.isString)(args["directory"]));
|
|
144
|
+
(0, assert_1.default)((0, lodash_2.isString)(this.args["directory"]));
|
|
141
145
|
this.dir =
|
|
142
|
-
this.config.windows && args["directory"].startsWith("~/")
|
|
143
|
-
? path_1.default.join(this.config.home, args["directory"].slice(2))
|
|
144
|
-
: path_1.default.resolve(args["directory"]);
|
|
146
|
+
this.config.windows && this.args["directory"].startsWith("~/")
|
|
147
|
+
? path_1.default.join(this.config.home, this.args["directory"].slice(2))
|
|
148
|
+
: path_1.default.resolve(this.args["directory"]);
|
|
145
149
|
const getApp = async () => {
|
|
146
|
-
if (flags.app)
|
|
147
|
-
return flags.app;
|
|
150
|
+
if (this.flags.app)
|
|
151
|
+
return this.flags.app;
|
|
148
152
|
if (this.metadata.app)
|
|
149
153
|
return this.metadata.app;
|
|
150
154
|
const selected = await (0, inquirer_1.prompt)({
|
|
@@ -166,18 +170,17 @@ class Sync extends base_command_1.BaseCommand {
|
|
|
166
170
|
}
|
|
167
171
|
}
|
|
168
172
|
catch (error) {
|
|
169
|
-
if (!flags.force) {
|
|
170
|
-
throw new errors_1.InvalidSyncFileError(error, this, flags.app);
|
|
173
|
+
if (!this.flags.force) {
|
|
174
|
+
throw new errors_1.InvalidSyncFileError(error, this, this.flags.app);
|
|
171
175
|
}
|
|
172
176
|
this.metadata.app = await getApp();
|
|
173
177
|
}
|
|
174
178
|
}
|
|
175
|
-
if (flags.app && flags.app !== this.metadata.app && !flags.force) {
|
|
176
|
-
throw new errors_1.InvalidSyncAppFlagError(this
|
|
179
|
+
if (this.flags.app && this.flags.app !== this.metadata.app && !this.flags.force) {
|
|
180
|
+
throw new errors_1.InvalidSyncAppFlagError(this);
|
|
177
181
|
}
|
|
178
182
|
await context_1.context.setApp(this.metadata.app);
|
|
179
183
|
this.client = new client_1.Client();
|
|
180
|
-
this.filePushDelay = flags["file-push-delay"];
|
|
181
184
|
// local files/folders that should never be published
|
|
182
185
|
this.ignorer = new fs_utils_1.Ignorer(this.dir, ["node_modules", ".gadget", ".git"]);
|
|
183
186
|
this.watcher = new chokidar_1.FSWatcher({
|
|
@@ -187,7 +190,7 @@ class Sync extends base_command_1.BaseCommand {
|
|
|
187
190
|
// make sure stats are always present on add/change events
|
|
188
191
|
alwaysStat: true,
|
|
189
192
|
// wait for the entire file to be written before emitting add/change events
|
|
190
|
-
awaitWriteFinish: { pollInterval: flags["file-poll-interval"], stabilityThreshold: flags["file-stability-threshold"] },
|
|
193
|
+
awaitWriteFinish: { pollInterval: this.flags["file-poll-interval"], stabilityThreshold: this.flags["file-stability-threshold"] },
|
|
191
194
|
});
|
|
192
195
|
this.debug("starting");
|
|
193
196
|
if (!which_1.default.sync("yarn", { nothrow: true })) {
|
|
@@ -263,6 +266,9 @@ class Sync extends base_command_1.BaseCommand {
|
|
|
263
266
|
}
|
|
264
267
|
async run() {
|
|
265
268
|
let error;
|
|
269
|
+
this.finished = new Promise((resolve) => {
|
|
270
|
+
this.markFinished = resolve;
|
|
271
|
+
});
|
|
266
272
|
this.stop = async (e) => {
|
|
267
273
|
if (this.status != SyncStatus.RUNNING)
|
|
268
274
|
return;
|
|
@@ -280,6 +286,7 @@ class Sync extends base_command_1.BaseCommand {
|
|
|
280
286
|
await Promise.allSettled([this.watcher.close(), this.client.dispose()]);
|
|
281
287
|
this.debug("stopped");
|
|
282
288
|
this.status = SyncStatus.STOPPED;
|
|
289
|
+
this.markFinished();
|
|
283
290
|
}
|
|
284
291
|
};
|
|
285
292
|
for (const signal of ["SIGINT", "SIGTERM"]) {
|
|
@@ -391,7 +398,7 @@ class Sync extends base_command_1.BaseCommand {
|
|
|
391
398
|
}
|
|
392
399
|
})
|
|
393
400
|
.catch(this.stop);
|
|
394
|
-
}, this.
|
|
401
|
+
}, this.flags["file-push-delay"]);
|
|
395
402
|
this.watcher
|
|
396
403
|
.add(`${this.dir}/**/*`)
|
|
397
404
|
.on("error", (error) => void this.stop(error))
|
|
@@ -456,7 +463,7 @@ class Sync extends base_command_1.BaseCommand {
|
|
|
456
463
|
Watching for file changes... {gray Press Ctrl+C to stop}
|
|
457
464
|
`));
|
|
458
465
|
this.log();
|
|
459
|
-
await
|
|
466
|
+
await this.finished;
|
|
460
467
|
if (error) {
|
|
461
468
|
this.notify({ subtitle: "Uh oh!", message: "An error occurred while syncing files" });
|
|
462
469
|
throw error;
|
|
@@ -519,13 +526,12 @@ Object.defineProperty(Sync, "args", {
|
|
|
519
526
|
enumerable: true,
|
|
520
527
|
configurable: true,
|
|
521
528
|
writable: true,
|
|
522
|
-
value:
|
|
523
|
-
{
|
|
524
|
-
name: "directory",
|
|
529
|
+
value: {
|
|
530
|
+
directory: core_1.Args.string({
|
|
525
531
|
description: "The directory to sync files to. If the directory doesn't exist, it will be created.",
|
|
526
532
|
default: ".",
|
|
527
|
-
},
|
|
528
|
-
|
|
533
|
+
}),
|
|
534
|
+
}
|
|
529
535
|
});
|
|
530
536
|
Object.defineProperty(Sync, "flags", {
|
|
531
537
|
enumerable: true,
|
package/lib/commands/sync.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync.js","sourceRoot":"","sources":["../../src/commands/sync.ts"],"names":[],"mappings":";;;;AAAA,sCAAoC;AACpC,0DAA0B;AAC1B,4DAA4B;AAC5B,uCAAqC;AACrC,qEAAqC;AACrC,0DAA0B;AAE1B,gEAA0B;AAC1B,uCAAkC;AAElC,mCAAgC;AAChC,mCAAkC;AAClC,mCAAkC;AAClC,4EAA2C;AAC3C,0DAAyB;AACzB,8DAA6B;AAC7B,wDAAwB;AACxB,kEAAkC;AAClC,kEAA+B;AAC/B,0DAA0B;AAC1B,wDAAoD;AAEpD,4CAAyC;AACzC,8CAA2C;AAC3C,4CAAmG;AACnG,0CAAqC;AACrC,gDAA+E;AAC/E,0CAA4C;AAW5C,sDAA4D;AAE5D,MAAqB,IAAK,SAAQ,0BAAW;IAA7C;;QAuGE;;;;mBAAuB,IAAI;WAAC;QAE5B;;;;mBAAS,UAAU,CAAC,QAAQ;WAAC;QAE7B;;;;;WAAa;QAEb;;;;mBAAe,IAAI,GAAG,EAAE;WAAC;QAEzB;;;;;WAAuB;QAEvB;;;;mBAAQ,IAAI,iBAAM,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,CAAC;WAAC;QAEvC;;;;;WAAgB;QAEhB;;;;;WAAkB;QAElB;;;;;WAAoB;QAEpB;;;;mBAAW;gBACT,GAAG,EAAE,EAAE;gBACP,YAAY,EAAE,GAAG;gBACjB,KAAK,EAAE,CAAC;aACT;WAAC;QAEF;;;;;WAAoC;QAEpC;;;;;WAA0C;IAwb5C,CAAC;IAtbC,QAAQ,CAAC,EAAU;QACjB,OAAO,cAAI,CAAC,QAAQ,CA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,EAAE,IAAI;SACb,CAAC;QACF,oBAAoB,EAAE,YAAK,CAAC,OAAO,CAAC;YAClC,IAAI,EAAE,oBAAoB;YAC1B,WAAW,EAAE,yDAAyD;YACtE,SAAS,EAAE,MAAM;YACjB,SAAS,EAAE,IAAI;YACf,OAAO,EAAE,GAAG;YACZ,MAAM,EAAE,IAAI;SACb,CAAC;KACH;GAAC;AAEK;;;;WAAoB;QACzB,IAAA,mBAAM,EAAC,IAAA,eAAK,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;KAyBX,CAAC;KACH;GAAC;AAsdJ,IAAY,UAKX;AALD,WAAY,UAAU;IACpB,mDAAQ,CAAA;IACR,iDAAO,CAAA;IACP,mDAAQ,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;;;;;;;;;;;;;;;CAejB,CAAC;AAEW,QAAA,0BAA0B,GAAmF;;;;CAIzH,CAAC;AAEW,QAAA,iCAAiC,GAG5B;;;;;;CAMjB,CAAC","sourcesContent":["import { Flags } from \"@oclif/core\";\nimport chalk from \"chalk\";\nimport assert from \"assert\";\nimport { FSWatcher } from \"chokidar\";\nimport format from \"date-fns/format\";\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 { sortBy } from \"lodash\";\nimport { isString } 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 pluralize from \"pluralize\";\nimport dedent from \"ts-dedent\";\nimport which from \"which\";\nimport { BaseCommand } from \"../utils/base-command\";\nimport type { Query } from \"../utils/client\";\nimport { Client } from \"../utils/client\";\nimport { context } from \"../utils/context\";\nimport { InvalidSyncAppFlagError, InvalidSyncFileError, YarnNotFoundError } from \"../utils/errors\";\nimport { app } from \"../utils/flags\";\nimport { ignoreEnoent, Ignorer, isEmptyDir, walkDir } from \"../utils/fs-utils\";\nimport { sleepUntil } from \"../utils/sleep\";\nimport type {\n FileSyncChangedEventInput,\n FileSyncDeletedEventInput,\n PublishFileSyncEventsMutation,\n PublishFileSyncEventsMutationVariables,\n RemoteFilesVersionQuery,\n RemoteFilesVersionQueryVariables,\n RemoteFileSyncEventsSubscription,\n RemoteFileSyncEventsSubscriptionVariables,\n} from \"../__generated__/graphql\";\nimport { FileSyncEncoding } 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 [DIRECTORY] [--app <name>]\";\n\n static override description = dedent(chalk`\n Sync provides the ability to sync your Gadget application's source code to and from your local\n filesystem. While {gray 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 {gray (https://code.visualstudio.com/)}\n - Storing your source code in a Git repository like GitHub {gray (https://github.com/)}\n\n Sync includes the concept of a {gray .ignore} file. This file may contain a list of files and\n directories that won't be received or sent to Gadget when syncing. The format of this file is\n identical to the one used by Git {gray (https://git-scm.com/docs/gitignore)}.\n\n The following files and directories are always ignored:\n - .gadget\n - .git\n - node_modules\n\n Note:\n - If you have separate development and production environments, {gray ggt sync} will only sync with your development environment\n - Gadget applications only support installing dependencies with Yarn 1 {gray (https://classic.yarnpkg.com/lang/en/)}\n - Since file changes are immediately reflected in Gadget, avoid the following while {gray 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(chalk`\n {gray $ ggt sync --app my-app ~/gadget/my-app}\n\n App my-app\n Editor https://my-app.gadget.app/edit\n Playground https://my-app.gadget.app/api/graphql/playground\n Docs https://docs.gadget.dev/api/my-app\n\n {underline Endpoints}\n - https://my-app.gadget.app\n - https://my-app--development.gadget.app\n\n Watching for file changes... {gray Press Ctrl+C to stop}\n\n Received {gray 12:00:00 PM}\n {green ←} routes/GET.js {gray (changed)}\n {green ←} user/signUp/signIn.js {gray (changed)}\n {gray 2 files in total. 2 changed, 0 deleted.}\n\n Sent {gray 12:00:03 PM}\n {green →} routes/GET.ts {gray (changed)}\n {gray 1 file in total. 1 changed, 0 deleted.}\n\n ^C Stopping... {gray (press Ctrl+C again to force)}\n Goodbye!\n `),\n ];\n\n override requireUser = true;\n\n status = SyncStatus.STARTING;\n\n dir!: string;\n\n recentWrites = new Set();\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(prefix: string, changed: string[], deleted: string[], { limit = 10 } = {}): void {\n const lines = sortBy(\n [\n ...changed.map((filepath) => chalk`{green ${prefix}} ${this.normalize(filepath)} {gray (changed)}`),\n ...deleted.map((filepath) => chalk`{red ${prefix}} ${this.normalize(filepath)} {gray (deleted)}`),\n ],\n (line) => line.slice(line.indexOf(\" \") + 1)\n );\n\n let logged = 0;\n for (const line of lines) {\n this.log(line);\n if (++logged == limit && !this.debugEnabled) break;\n }\n\n if (lines.length > logged) {\n this.log(chalk`{gray … ${lines.length - logged} more}`);\n }\n\n this.log(chalk`{gray ${pluralize(\"file\", lines.length, true)} in total. ${changed.length} changed, ${deleted.length} deleted.}`);\n this.log();\n }\n\n override async init(): Promise<void> {\n await super.init();\n const { args, flags } = await this.parse(Sync);\n\n assert(isString(args[\"directory\"]));\n\n this.dir =\n this.config.windows && args[\"directory\"].startsWith(\"~/\")\n ? path.join(this.config.home, args[\"directory\"].slice(2))\n : path.resolve(args[\"directory\"]);\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 context.getAvailableApps().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 InvalidSyncAppFlagError(this, flags.app);\n }\n\n await context.setApp(this.metadata.app);\n\n this.client = new Client();\n\n this.filePushDelay = flags[\"file-push-delay\"];\n\n // local files/folders that should never be published\n this.ignorer = new Ignorer(this.dir, [\"node_modules\", \".gadget\", \".git\"]);\n\n this.watcher = new FSWatcher({\n ignored: (filepath) => this.ignorer.ignores(filepath),\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 you last synced\");\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: await fs.readFile(filepath, \"base64\"),\n encoding: FileSyncEncoding.Base64,\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(chalk` Stopping... {gray (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(\n [...deleted, ...changed]\n .filter((event) => event.path.startsWith(\".gadget/\") || !this.ignorer.ignores(event.path))\n .map((e) => [e.path, e])\n );\n\n void this.queue\n .add(async () => {\n if (!remoteFiles.size) {\n if (BigInt(remoteFilesVersion) > BigInt(this.metadata.filesVersion)) {\n // we still need to update filesVersion, otherwise our expectedFilesVersion will be behind the next time we publish\n this.debug(\"updated local files version from %s to %s\", this.metadata.filesVersion, remoteFilesVersion);\n this.metadata.filesVersion = remoteFilesVersion;\n }\n return;\n }\n\n this.log(chalk`Received {gray ${format(new Date(), \"pp\")}}`);\n this.logPaths(\n \"←\",\n changed.map((x) => x.path).filter((x) => remoteFiles.has(x)),\n deleted.map((x) => x.path).filter((x) => remoteFiles.has(x))\n );\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, Buffer.from(file.content, file.encoding ?? FileSyncEncoding.Utf8), { 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.debug(\"updated local files version from %s to %s\", this.metadata.filesVersion, remoteFilesVersion);\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: await fs.readFile(filepath, \"base64\"),\n encoding: FileSyncEncoding.Base64,\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 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 this.log(chalk`Sent {gray ${format(new Date(), \"pp\")}}`);\n this.logPaths(\n \"→\",\n changed.map((x) => x.path),\n deleted.map((x) => x.path)\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.debug(\"updated local files version from %s to %s\", this.metadata.filesVersion, remoteFilesVersion);\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\" || event === \"unlinkDir\") {\n this.debug(\"skipping event caused by 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 localFilesBuffer.set(filepath, false);\n break;\n }\n\n this.publish();\n });\n\n this.status = SyncStatus.RUNNING;\n\n // app should be defined at this point\n assert(context.app);\n\n this.log();\n this.log(\n dedent(chalk`\n {bold ggt v${this.config.version}}\n\n App ${context.app.name}\n Editor https://${context.app.slug}.gadget.app/edit\n Playground https://${context.app.slug}.gadget.app/api/graphql/playground\n Docs https://docs.gadget.dev/api/${context.app.slug}\n\n {underline Endpoints} ${\n context.app.hasSplitEnvironments\n ? `\n - https://${context.app.slug}.gadget.app\n - https://${context.app.slug}--development.gadget.app`\n : `\n - https://${context.app.slug}.gadget.app`\n }\n\n Watching for file changes... {gray Press Ctrl+C to stop}\n `)\n );\n this.log();\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(\"Goodbye!\");\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, encoding: base64) {\n remoteFilesVersion\n changed {\n path\n mode\n content\n encoding\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,sCAA0C;AAC1C,0DAA0B;AAC1B,4DAA4B;AAC5B,uCAAqC;AACrC,qEAAqC;AACrC,0DAA0B;AAE1B,gEAA0B;AAC1B,uCAAkC;AAElC,mCAAgC;AAChC,mCAAkC;AAClC,mCAAkC;AAClC,4EAA2C;AAC3C,0DAAyB;AACzB,8DAA6B;AAC7B,wDAAwB;AACxB,kEAAkC;AAClC,kEAA+B;AAC/B,0DAA0B;AAC1B,wDAAoD;AAEpD,4CAAyC;AACzC,8CAA2C;AAC3C,4CAAmG;AACnG,0CAAqC;AACrC,gDAA+E;AAW/E,sDAA4D;AAE5D,MAAqB,IAAK,SAAQ,0BAAwB;IAA1D;;QAsGE;;;;mBAAuB,IAAI;WAAC;QAE5B;;;;mBAAS,UAAU,CAAC,QAAQ;WAAC;QAE7B;;;;;WAAa;QAEb;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;CAejB,CAAC;AAEW,QAAA,0BAA0B,GAAmF;;;;CAIzH,CAAC;AAEW,QAAA,iCAAiC,GAG5B;;;;;;CAMjB,CAAC","sourcesContent":["import { Args, Flags } from \"@oclif/core\";\nimport chalk from \"chalk\";\nimport assert from \"assert\";\nimport { FSWatcher } from \"chokidar\";\nimport format from \"date-fns/format\";\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 { sortBy } from \"lodash\";\nimport { isString } 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 pluralize from \"pluralize\";\nimport dedent from \"ts-dedent\";\nimport which from \"which\";\nimport { BaseCommand } from \"../utils/base-command\";\nimport type { Query } from \"../utils/client\";\nimport { Client } from \"../utils/client\";\nimport { context } from \"../utils/context\";\nimport { InvalidSyncAppFlagError, InvalidSyncFileError, YarnNotFoundError } from \"../utils/errors\";\nimport { app } from \"../utils/flags\";\nimport { ignoreEnoent, Ignorer, isEmptyDir, walkDir } from \"../utils/fs-utils\";\nimport type {\n FileSyncChangedEventInput,\n FileSyncDeletedEventInput,\n PublishFileSyncEventsMutation,\n PublishFileSyncEventsMutationVariables,\n RemoteFilesVersionQuery,\n RemoteFilesVersionQueryVariables,\n RemoteFileSyncEventsSubscription,\n RemoteFileSyncEventsSubscriptionVariables,\n} from \"../__generated__/graphql\";\nimport { FileSyncEncoding } from \"../__generated__/graphql\";\n\nexport default class Sync extends BaseCommand<typeof Sync> {\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 [DIRECTORY] [--app <name>]\";\n\n static override description = dedent(chalk`\n Sync provides the ability to sync your Gadget application's source code to and from your local\n filesystem. While {gray 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 {gray (https://code.visualstudio.com/)}\n - Storing your source code in a Git repository like GitHub {gray (https://github.com/)}\n\n Sync includes the concept of a {gray .ignore} file. This file may contain a list of files and\n directories that won't be received or sent to Gadget when syncing. The format of this file is\n identical to the one used by Git {gray (https://git-scm.com/docs/gitignore)}.\n\n The following files and directories are always ignored:\n - .gadget\n - .git\n - node_modules\n\n Note:\n - If you have separate development and production environments, {gray ggt sync} will only sync with your development environment\n - Gadget applications only support installing dependencies with Yarn 1 {gray (https://classic.yarnpkg.com/lang/en/)}\n - Since file changes are immediately reflected in Gadget, avoid the following while {gray 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 directory: Args.string({\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(chalk`\n {gray $ ggt sync --app my-app ~/gadget/my-app}\n\n App my-app\n Editor https://my-app.gadget.app/edit\n Playground https://my-app.gadget.app/api/graphql/playground\n Docs https://docs.gadget.dev/api/my-app\n\n {underline Endpoints}\n - https://my-app.gadget.app\n - https://my-app--development.gadget.app\n\n Watching for file changes... {gray Press Ctrl+C to stop}\n\n Received {gray 12:00:00 PM}\n {green ←} routes/GET.js {gray (changed)}\n {green ←} user/signUp/signIn.js {gray (changed)}\n {gray 2 files in total. 2 changed, 0 deleted.}\n\n Sent {gray 12:00:03 PM}\n {green →} routes/GET.ts {gray (changed)}\n {gray 1 file in total. 1 changed, 0 deleted.}\n\n ^C Stopping... {gray (press Ctrl+C again to force)}\n Goodbye!\n `),\n ];\n\n override requireUser = true;\n\n status = SyncStatus.STARTING;\n\n dir!: string;\n\n recentWrites = new Set();\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 finished!: Promise<void>;\n markFinished!: () => 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(prefix: string, changed: string[], deleted: string[], { limit = 10 } = {}): void {\n const lines = sortBy(\n [\n ...changed.map((filepath) => chalk`{green ${prefix}} ${this.normalize(filepath)} {gray (changed)}`),\n ...deleted.map((filepath) => chalk`{red ${prefix}} ${this.normalize(filepath)} {gray (deleted)}`),\n ],\n (line) => line.slice(line.indexOf(\" \") + 1)\n );\n\n let logged = 0;\n for (const line of lines) {\n this.log(line);\n if (++logged == limit && !this.debugEnabled) break;\n }\n\n if (lines.length > logged) {\n this.log(chalk`{gray … ${lines.length - logged} more}`);\n }\n\n this.log(chalk`{gray ${pluralize(\"file\", lines.length, true)} in total. ${changed.length} changed, ${deleted.length} deleted.}`);\n this.log();\n }\n\n override async init(): Promise<void> {\n await super.init();\n\n assert(isString(this.args[\"directory\"]));\n\n this.dir =\n this.config.windows && this.args[\"directory\"].startsWith(\"~/\")\n ? path.join(this.config.home, this.args[\"directory\"].slice(2))\n : path.resolve(this.args[\"directory\"]);\n\n const getApp = async (): Promise<string> => {\n if (this.flags.app) return this.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 context.getAvailableApps().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 (!this.flags.force) {\n throw new InvalidSyncFileError(error, this, this.flags.app);\n }\n this.metadata.app = await getApp();\n }\n }\n\n if (this.flags.app && this.flags.app !== this.metadata.app && !this.flags.force) {\n throw new InvalidSyncAppFlagError(this);\n }\n\n await context.setApp(this.metadata.app);\n\n this.client = new Client();\n\n // local files/folders that should never be published\n this.ignorer = new Ignorer(this.dir, [\"node_modules\", \".gadget\", \".git\"]);\n\n this.watcher = new FSWatcher({\n ignored: (filepath) => this.ignorer.ignores(filepath),\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: this.flags[\"file-poll-interval\"], stabilityThreshold: this.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 you last synced\");\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: await fs.readFile(filepath, \"base64\"),\n encoding: FileSyncEncoding.Base64,\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 this.finished = new Promise((resolve) => {\n this.markFinished = resolve;\n });\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 this.markFinished();\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(chalk` Stopping... {gray (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(\n [...deleted, ...changed]\n .filter((event) => event.path.startsWith(\".gadget/\") || !this.ignorer.ignores(event.path))\n .map((e) => [e.path, e])\n );\n\n void this.queue\n .add(async () => {\n if (!remoteFiles.size) {\n if (BigInt(remoteFilesVersion) > BigInt(this.metadata.filesVersion)) {\n // we still need to update filesVersion, otherwise our expectedFilesVersion will be behind the next time we publish\n this.debug(\"updated local files version from %s to %s\", this.metadata.filesVersion, remoteFilesVersion);\n this.metadata.filesVersion = remoteFilesVersion;\n }\n return;\n }\n\n this.log(chalk`Received {gray ${format(new Date(), \"pp\")}}`);\n this.logPaths(\n \"←\",\n changed.map((x) => x.path).filter((x) => remoteFiles.has(x)),\n deleted.map((x) => x.path).filter((x) => remoteFiles.has(x))\n );\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, Buffer.from(file.content, file.encoding ?? FileSyncEncoding.Utf8), { 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.debug(\"updated local files version from %s to %s\", this.metadata.filesVersion, remoteFilesVersion);\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: await fs.readFile(filepath, \"base64\"),\n encoding: FileSyncEncoding.Base64,\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 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 this.log(chalk`Sent {gray ${format(new Date(), \"pp\")}}`);\n this.logPaths(\n \"→\",\n changed.map((x) => x.path),\n deleted.map((x) => x.path)\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.debug(\"updated local files version from %s to %s\", this.metadata.filesVersion, remoteFilesVersion);\n this.metadata.filesVersion = remoteFilesVersion;\n }\n }\n })\n .catch(this.stop);\n }, this.flags[\"file-push-delay\"]);\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\" || event === \"unlinkDir\") {\n this.debug(\"skipping event caused by 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 localFilesBuffer.set(filepath, false);\n break;\n }\n\n this.publish();\n });\n\n this.status = SyncStatus.RUNNING;\n\n // app should be defined at this point\n assert(context.app);\n\n this.log();\n this.log(\n dedent(chalk`\n {bold ggt v${this.config.version}}\n\n App ${context.app.name}\n Editor https://${context.app.slug}.gadget.app/edit\n Playground https://${context.app.slug}.gadget.app/api/graphql/playground\n Docs https://docs.gadget.dev/api/${context.app.slug}\n\n {underline Endpoints} ${\n context.app.hasSplitEnvironments\n ? `\n - https://${context.app.slug}.gadget.app\n - https://${context.app.slug}--development.gadget.app`\n : `\n - https://${context.app.slug}.gadget.app`\n }\n\n Watching for file changes... {gray Press Ctrl+C to stop}\n `)\n );\n this.log();\n\n await this.finished;\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(\"Goodbye!\");\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, encoding: base64) {\n remoteFilesVersion\n changed {\n path\n mode\n content\n encoding\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"]}
|
package/lib/commands/whoami.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"whoami.js","sourceRoot":"","sources":["../../src/commands/whoami.ts"],"names":[],"mappings":";;;AAAA,0DAA0B;AAC1B,kEAA+B;AAC/B,wDAAoD;AACpD,8CAA2C;AAE3C,MAAqB,MAAO,SAAQ,
|
|
1
|
+
{"version":3,"file":"whoami.js","sourceRoot":"","sources":["../../src/commands/whoami.ts"],"names":[],"mappings":";;;AAAA,0DAA0B;AAC1B,kEAA+B;AAC/B,wDAAoD;AACpD,8CAA2C;AAE3C,MAAqB,MAAO,SAAQ,0BAA0B;IAY5D,KAAK,CAAC,GAAG;QACP,MAAM,IAAI,GAAG,MAAM,iBAAO,CAAC,OAAO,EAAE,CAAC;QACrC,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,IAAA,eAAK,EAAA,wBAAwB,IAAI,CAAC,IAAI,WAAW,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC;SAC3E;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,EAAC,IAAA,eAAK,EAAA;;;KAGX,CAAC;KACH;GAAC","sourcesContent":["import chalk from \"chalk\";\nimport dedent from \"ts-dedent\";\nimport { BaseCommand } from \"../utils/base-command\";\nimport { context } from \"../utils/context\";\n\nexport default class Whoami extends BaseCommand<typeof Whoami> {\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(chalk`\n {gray $ ggt whoami}\n You are logged in as Jane Doe {gray (jane@example.com)}\n `),\n ];\n\n async run(): Promise<void> {\n const user = await context.getUser();\n if (!user) {\n this.log(\"You are not logged in\");\n return;\n }\n\n if (user.name) {\n this.log(chalk`You are logged in as ${user.name} {gray (${user.email})}`);\n } else {\n this.log(`You are logged in as ${user.email}`);\n }\n }\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Config } from "@oclif/core";
|
|
1
|
+
import type { Config, Interfaces } from "@oclif/core";
|
|
2
2
|
import { Command } from "@oclif/core";
|
|
3
3
|
import type { Notification } from "node-notifier";
|
|
4
4
|
import type WindowsBalloon from "node-notifier/notifiers/balloon";
|
|
@@ -6,20 +6,30 @@ import type Growl from "node-notifier/notifiers/growl";
|
|
|
6
6
|
import type NotificationCenter from "node-notifier/notifiers/notificationcenter";
|
|
7
7
|
import type NotifySend from "node-notifier/notifiers/notifysend";
|
|
8
8
|
import type WindowsToaster from "node-notifier/notifiers/toaster";
|
|
9
|
-
export
|
|
9
|
+
export type Flags<T extends typeof Command> = Interfaces.InferredFlags<(typeof BaseCommand)["baseFlags"] & T["flags"]>;
|
|
10
|
+
export type Args<T extends typeof Command> = Interfaces.InferredArgs<T["args"]>;
|
|
11
|
+
export declare abstract class BaseCommand<T extends typeof Command> extends Command {
|
|
10
12
|
/**
|
|
11
13
|
* Determines how high the command is listed in the README. The lower the number, the higher the command is listed. Equal numbers are
|
|
12
14
|
* sorted alphabetically.
|
|
13
15
|
*/
|
|
14
16
|
static priority: number;
|
|
15
|
-
static
|
|
16
|
-
debug:
|
|
17
|
+
static baseFlags: {
|
|
18
|
+
debug: Interfaces.BooleanFlag<boolean>;
|
|
17
19
|
};
|
|
18
20
|
/**
|
|
19
21
|
* Determines whether the command requires the user to be logged in or not.
|
|
20
22
|
* If true and the user is not logged in, the user will be prompted to login before the command is run.
|
|
21
23
|
*/
|
|
22
24
|
readonly requireUser: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* The parsed flags for the command.
|
|
27
|
+
*/
|
|
28
|
+
flags: Flags<T>;
|
|
29
|
+
/**
|
|
30
|
+
* The parsed arguments for the command.
|
|
31
|
+
*/
|
|
32
|
+
args: Args<T>;
|
|
23
33
|
constructor(argv: string[], config: Config);
|
|
24
34
|
/**
|
|
25
35
|
* Indicates whether the command is being run with the `-D/--debug` flag.
|