@gadgetinc/ggt 0.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/LICENSE +7 -0
  2. package/README.md +177 -0
  3. package/assets/favicon-128@4x.png +0 -0
  4. package/bin/dev +20 -0
  5. package/bin/dev.cmd +3 -0
  6. package/bin/run +7 -0
  7. package/bin/run.cmd +3 -0
  8. package/dist/commands/help.d.ts +16 -0
  9. package/dist/commands/help.js +37 -0
  10. package/dist/commands/help.js.map +1 -0
  11. package/dist/commands/login.d.ts +7 -0
  12. package/dist/commands/login.js +36 -0
  13. package/dist/commands/login.js.map +1 -0
  14. package/dist/commands/logout.d.ts +7 -0
  15. package/dist/commands/logout.js +41 -0
  16. package/dist/commands/logout.js.map +1 -0
  17. package/dist/commands/sync.d.ts +64 -0
  18. package/dist/commands/sync.js +534 -0
  19. package/dist/commands/sync.js.map +1 -0
  20. package/dist/commands/whoami.d.ts +7 -0
  21. package/dist/commands/whoami.js +45 -0
  22. package/dist/commands/whoami.js.map +1 -0
  23. package/dist/index.d.ts +1 -0
  24. package/dist/index.js +6 -0
  25. package/dist/index.js.map +1 -0
  26. package/dist/lib/base-command.d.ts +87 -0
  27. package/dist/lib/base-command.js +318 -0
  28. package/dist/lib/base-command.js.map +1 -0
  29. package/dist/lib/client.d.ts +39 -0
  30. package/dist/lib/client.js +155 -0
  31. package/dist/lib/client.js.map +1 -0
  32. package/dist/lib/env.d.ts +10 -0
  33. package/dist/lib/env.js +25 -0
  34. package/dist/lib/env.js.map +1 -0
  35. package/dist/lib/errors.d.ts +74 -0
  36. package/dist/lib/errors.js +320 -0
  37. package/dist/lib/errors.js.map +1 -0
  38. package/dist/lib/fs-utils.d.ts +18 -0
  39. package/dist/lib/fs-utils.js +108 -0
  40. package/dist/lib/fs-utils.js.map +1 -0
  41. package/dist/lib/help.d.ts +14 -0
  42. package/dist/lib/help.js +30 -0
  43. package/dist/lib/help.js.map +1 -0
  44. package/dist/lib/sleep.d.ts +5 -0
  45. package/dist/lib/sleep.js +23 -0
  46. package/dist/lib/sleep.js.map +1 -0
  47. package/dist/lib/types.d.ts +9 -0
  48. package/dist/lib/types.js +3 -0
  49. package/dist/lib/types.js.map +1 -0
  50. package/package.json +107 -0
@@ -0,0 +1,534 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PUBLISH_FILE_SYNC_EVENTS_MUTATION = exports.REMOTE_FILES_VERSION_QUERY = exports.REMOTE_FILE_SYNC_EVENTS_SUBSCRIPTION = exports.Action = exports.SyncStatus = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const core_1 = require("@oclif/core");
6
+ const assert_1 = tslib_1.__importDefault(require("assert"));
7
+ const chokidar_1 = require("chokidar");
8
+ const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
9
+ const inquirer_1 = require("inquirer");
10
+ const lodash_1 = require("lodash");
11
+ const normalize_path_1 = tslib_1.__importDefault(require("normalize-path"));
12
+ const p_map_1 = tslib_1.__importDefault(require("p-map"));
13
+ const p_queue_1 = tslib_1.__importDefault(require("p-queue"));
14
+ const path_1 = tslib_1.__importDefault(require("path"));
15
+ const ts_dedent_1 = tslib_1.__importDefault(require("ts-dedent"));
16
+ const base_command_1 = require("../lib/base-command");
17
+ const fs_utils_1 = require("../lib/fs-utils");
18
+ const sleep_1 = require("../lib/sleep");
19
+ class Sync extends base_command_1.BaseCommand {
20
+ constructor() {
21
+ super(...arguments);
22
+ Object.defineProperty(this, "requireApp", {
23
+ enumerable: true,
24
+ configurable: true,
25
+ writable: true,
26
+ value: true
27
+ });
28
+ Object.defineProperty(this, "status", {
29
+ enumerable: true,
30
+ configurable: true,
31
+ writable: true,
32
+ value: SyncStatus.STARTING
33
+ });
34
+ Object.defineProperty(this, "dir", {
35
+ enumerable: true,
36
+ configurable: true,
37
+ writable: true,
38
+ value: void 0
39
+ });
40
+ Object.defineProperty(this, "recentWrites", {
41
+ enumerable: true,
42
+ configurable: true,
43
+ writable: true,
44
+ value: new Set()
45
+ });
46
+ Object.defineProperty(this, "filePushDelay", {
47
+ enumerable: true,
48
+ configurable: true,
49
+ writable: true,
50
+ value: void 0
51
+ });
52
+ Object.defineProperty(this, "queue", {
53
+ enumerable: true,
54
+ configurable: true,
55
+ writable: true,
56
+ value: new p_queue_1.default({ concurrency: 1 })
57
+ });
58
+ Object.defineProperty(this, "ignorer", {
59
+ enumerable: true,
60
+ configurable: true,
61
+ writable: true,
62
+ value: void 0
63
+ });
64
+ Object.defineProperty(this, "watcher", {
65
+ enumerable: true,
66
+ configurable: true,
67
+ writable: true,
68
+ value: void 0
69
+ });
70
+ Object.defineProperty(this, "metadata", {
71
+ enumerable: true,
72
+ configurable: true,
73
+ writable: true,
74
+ value: {
75
+ lastWritten: {
76
+ filesVersion: "0",
77
+ mtime: 0,
78
+ },
79
+ }
80
+ });
81
+ Object.defineProperty(this, "publish", {
82
+ enumerable: true,
83
+ configurable: true,
84
+ writable: true,
85
+ value: void 0
86
+ });
87
+ Object.defineProperty(this, "stop", {
88
+ enumerable: true,
89
+ configurable: true,
90
+ writable: true,
91
+ value: void 0
92
+ });
93
+ }
94
+ relative(to) {
95
+ return path_1.default.relative(this.dir, to);
96
+ }
97
+ absolute(...pathSegments) {
98
+ return path_1.default.resolve(this.dir, ...pathSegments);
99
+ }
100
+ normalize(filepath) {
101
+ return (0, normalize_path_1.default)(path_1.default.isAbsolute(filepath) ? this.relative(filepath) : filepath);
102
+ }
103
+ logPaths(filepaths, { limit = 10, sep = "-" } = {}) {
104
+ let logged = 0;
105
+ for (const filepath of filepaths) {
106
+ this.log(`${sep} ${this.normalize(filepath)}`);
107
+ if (++logged == limit && !this.debugEnabled)
108
+ break;
109
+ }
110
+ if (filepaths.length > logged) {
111
+ this.log(`… ${filepaths.length - logged} more`);
112
+ }
113
+ }
114
+ async init() {
115
+ await super.init();
116
+ const { args, flags } = await this.parse(Sync);
117
+ this.dir = path_1.default.resolve(args["directory"]);
118
+ this.filePushDelay = flags["file-push-delay"];
119
+ // local files that should never be published
120
+ const ignored = ["node_modules/", ".gadget/", ".ggt/", ".git/"];
121
+ this.ignorer = new fs_utils_1.Ignorer(this.dir, ignored);
122
+ this.watcher = new chokidar_1.FSWatcher({
123
+ ignored,
124
+ // don't emit an event for every watched file on boot
125
+ ignoreInitial: true,
126
+ // make sure stats are always present on add/change events
127
+ alwaysStat: true,
128
+ // wait for the entire file to be written before emitting add/change events
129
+ awaitWriteFinish: { pollInterval: flags["file-poll-interval"], stabilityThreshold: flags["file-stability-threshold"] },
130
+ });
131
+ this.debug("starting");
132
+ await fs_extra_1.default.ensureDir(this.dir);
133
+ try {
134
+ this.metadata = await fs_extra_1.default.readJson(this.absolute(".ggt", "sync.json"));
135
+ }
136
+ catch (error) {
137
+ // use defaults if the metadata file doesn't exist
138
+ (0, fs_utils_1.ignoreEnoent)(error);
139
+ const d = await fs_extra_1.default.opendir(this.dir);
140
+ if ((await d.read()) != null) {
141
+ this.warn("Could not find .ggt/sync.json in a non empty directory");
142
+ }
143
+ await d.close();
144
+ }
145
+ const { remoteFilesVersion } = await this.client.queryUnwrap({ query: exports.REMOTE_FILES_VERSION_QUERY });
146
+ const hasRemoteChanges = BigInt(remoteFilesVersion) > BigInt(this.metadata.lastWritten.filesVersion);
147
+ const getChangedFiles = async () => {
148
+ const files = new Map();
149
+ for await (const filepath of (0, fs_utils_1.walkDir)(this.dir, { ignorer: this.ignorer, maxFiles: 100 })) {
150
+ const stats = await fs_extra_1.default.stat(filepath);
151
+ if (stats.mtime.getTime() > this.metadata.lastWritten.mtime) {
152
+ files.set(this.absolute(filepath), stats);
153
+ }
154
+ }
155
+ return files;
156
+ };
157
+ const changedFiles = await getChangedFiles();
158
+ const hasLocalChanges = changedFiles.size > 0;
159
+ if (hasLocalChanges) {
160
+ this.log("Local files have changed since the last sync");
161
+ this.logPaths(Array.from(changedFiles.keys()), { limit: changedFiles.size });
162
+ this.log();
163
+ }
164
+ this.debug("init %o", { metadata: this.metadata, remoteFilesVersion, hasRemoteChanges, hasLocalChanges });
165
+ let action;
166
+ if (hasLocalChanges) {
167
+ ({ action } = await (0, inquirer_1.prompt)({
168
+ type: "list",
169
+ name: "action",
170
+ choices: [Action.CANCEL, Action.MERGE, Action.RESET],
171
+ message: hasRemoteChanges ? "Remote files have also changed. How would you like to proceed?" : "How would you like to proceed?",
172
+ }));
173
+ }
174
+ switch (action) {
175
+ case Action.MERGE: {
176
+ // get all the changed files again in case more changed
177
+ const files = await getChangedFiles();
178
+ // we purposefully don't set the returned remoteFilesVersion here because we haven't processed the in-between versions yet
179
+ await this.client.queryUnwrap({
180
+ query: exports.PUBLISH_FILE_SYNC_EVENTS_MUTATION,
181
+ variables: {
182
+ input: {
183
+ expectedRemoteFilesVersion: remoteFilesVersion,
184
+ changed: await (0, p_map_1.default)(files, async ([filepath, stats]) => {
185
+ if (stats.mtime.getTime() > this.metadata.lastWritten.mtime) {
186
+ this.metadata.lastWritten.mtime = stats.mtime.getTime();
187
+ }
188
+ return {
189
+ path: this.normalize(filepath),
190
+ mode: stats.mode,
191
+ content: await fs_extra_1.default.readFile(filepath, "utf-8"),
192
+ };
193
+ }),
194
+ deleted: [],
195
+ },
196
+ },
197
+ });
198
+ break;
199
+ }
200
+ case Action.RESET: {
201
+ await (0, p_map_1.default)(changedFiles, ([filepath]) => fs_extra_1.default.remove(filepath));
202
+ this.metadata.lastWritten.filesVersion = "0";
203
+ break;
204
+ }
205
+ case Action.CANCEL: {
206
+ process.exit(0);
207
+ }
208
+ }
209
+ this.debug("started");
210
+ }
211
+ async run() {
212
+ let error;
213
+ this.stop = async (e) => {
214
+ if (this.status != SyncStatus.RUNNING)
215
+ return;
216
+ error = e;
217
+ this.debug("stopping");
218
+ this.status = SyncStatus.STOPPING;
219
+ try {
220
+ unsubscribe();
221
+ this.watcher.removeAllListeners();
222
+ this.publish.flush();
223
+ await this.queue.onIdle();
224
+ }
225
+ finally {
226
+ await fs_extra_1.default.outputJSON(this.absolute(".ggt", "sync.json"), this.metadata, { spaces: 2 });
227
+ await Promise.allSettled([this.watcher.close(), this.client.dispose()]);
228
+ this.debug("stopped");
229
+ this.status = SyncStatus.STOPPED;
230
+ }
231
+ };
232
+ for (const signal of ["SIGINT", "SIGTERM"]) {
233
+ process.on(signal, () => {
234
+ if (this.status != SyncStatus.RUNNING)
235
+ return;
236
+ this.log(" Stopping... (press Ctrl+C again to force)");
237
+ process.once("SIGINT", () => {
238
+ this.log(` Exiting immediately. Note that files may not have finished syncing.`);
239
+ process.exit(1);
240
+ });
241
+ void this.stop();
242
+ });
243
+ }
244
+ const unsubscribe = this.client.subscribeUnwrap({
245
+ query: exports.REMOTE_FILE_SYNC_EVENTS_SUBSCRIPTION,
246
+ variables: () => ({ localFilesVersion: this.metadata.lastWritten.filesVersion }),
247
+ }, {
248
+ error: (error) => void this.stop(error),
249
+ next: ({ remoteFileSyncEvents }) => {
250
+ if (!remoteFileSyncEvents.changed.length && !remoteFileSyncEvents.deleted.length) {
251
+ return;
252
+ }
253
+ const { remoteFilesVersion, changed, deleted } = remoteFileSyncEvents;
254
+ const remoteFiles = new Map([...deleted, ...changed].map((e) => [e.path, e]));
255
+ void this.queue
256
+ .add(async () => {
257
+ this.log("Received");
258
+ this.logPaths(Array.from(remoteFiles.keys()), { sep: "←" });
259
+ await (0, p_map_1.default)(remoteFiles, async ([relativePath, file]) => {
260
+ const filepath = this.absolute(relativePath);
261
+ this.recentWrites.add(filepath);
262
+ if ("content" in file) {
263
+ await fs_extra_1.default.ensureDir(path_1.default.dirname(filepath), { mode: 0o755 });
264
+ if (!file.path.endsWith("/"))
265
+ await fs_extra_1.default.writeFile(filepath, file.content, { mode: file.mode });
266
+ }
267
+ else {
268
+ await fs_extra_1.default.remove(filepath);
269
+ }
270
+ if (filepath == this.ignorer.filepath) {
271
+ this.ignorer.reload();
272
+ }
273
+ }, { stopOnError: false });
274
+ this.metadata.lastWritten.filesVersion = remoteFilesVersion;
275
+ })
276
+ .catch(this.stop);
277
+ },
278
+ });
279
+ const localFilesBuffer = new Map();
280
+ this.publish = (0, lodash_1.debounce)(() => {
281
+ const localFiles = new Map(localFilesBuffer.entries());
282
+ localFilesBuffer.clear();
283
+ void this.queue
284
+ .add(async () => {
285
+ const changed = [];
286
+ const deleted = [];
287
+ await (0, p_map_1.default)(localFiles, async ([filepath, file]) => {
288
+ if (file) {
289
+ try {
290
+ changed.push({
291
+ path: this.normalize(filepath),
292
+ mode: file.mode,
293
+ content: await fs_extra_1.default.readFile(filepath, "utf-8"),
294
+ });
295
+ }
296
+ catch (error) {
297
+ // A file could have been changed and then deleted before we process the change event, so the readFile above will raise
298
+ // an ENOENT. This is normal operation, so just ignore this event.
299
+ (0, fs_utils_1.ignoreEnoent)(error);
300
+ }
301
+ }
302
+ else {
303
+ deleted.push({ path: this.normalize(filepath) });
304
+ }
305
+ }, { stopOnError: false });
306
+ if (changed.length > 0 || deleted.length > 0) {
307
+ this.log("Sent");
308
+ this.logPaths(Array.from(localFiles.keys()), { sep: "→" });
309
+ const data = await this.client.queryUnwrap({
310
+ query: exports.PUBLISH_FILE_SYNC_EVENTS_MUTATION,
311
+ variables: { input: { expectedRemoteFilesVersion: this.metadata.lastWritten.filesVersion, changed, deleted } },
312
+ });
313
+ const { remoteFilesVersion } = data.publishFileSyncEvents;
314
+ this.debug("remote files version after publishing %s", remoteFilesVersion);
315
+ if (BigInt(remoteFilesVersion) > BigInt(this.metadata.lastWritten.filesVersion)) {
316
+ this.metadata.lastWritten.filesVersion = remoteFilesVersion;
317
+ }
318
+ }
319
+ })
320
+ .catch(this.stop);
321
+ }, this.filePushDelay);
322
+ this.watcher
323
+ .add(`${this.dir}/**/*`)
324
+ .on("error", (error) => void this.stop(error))
325
+ .on("all", (event, filepath, stats) => {
326
+ const relativePath = this.relative(filepath);
327
+ if (event === "addDir") {
328
+ this.debug("skipping event caused by added directory %s", relativePath);
329
+ return;
330
+ }
331
+ if (stats?.isSymbolicLink?.()) {
332
+ this.debug("skipping event caused by symlink %s", relativePath);
333
+ return;
334
+ }
335
+ if (filepath == this.ignorer.filepath) {
336
+ this.ignorer.reload();
337
+ }
338
+ else if (this.ignorer.ignores(filepath)) {
339
+ this.debug("skipping event caused by ignored file %s", relativePath);
340
+ return;
341
+ }
342
+ // we only update the lastWritten.mtime if the file is not ignored, because if we restart and the lastWritten.mtime is set to an
343
+ // ignored file, then it *could* be greater than the mtime of all non ignored files and we'll think that local files have
344
+ // changed when only an ignored one has
345
+ if (stats && stats.mtime.getTime() > this.metadata.lastWritten.mtime) {
346
+ this.metadata.lastWritten.mtime = stats.mtime.getTime();
347
+ }
348
+ if (this.recentWrites.delete(filepath)) {
349
+ this.debug("skipping event caused by recent write %s", relativePath);
350
+ return;
351
+ }
352
+ this.debug("file changed %s", relativePath);
353
+ switch (event) {
354
+ case "add":
355
+ case "change":
356
+ (0, assert_1.default)(stats, "missing stats on add/change event");
357
+ localFilesBuffer.set(filepath, { mode: stats.mode, mtime: stats.mtime.getTime() });
358
+ break;
359
+ case "unlink":
360
+ case "unlinkDir":
361
+ localFilesBuffer.set(filepath, false);
362
+ break;
363
+ }
364
+ this.publish();
365
+ });
366
+ this.log("Ready");
367
+ this.status = SyncStatus.RUNNING;
368
+ await (0, sleep_1.sleepUntil)(() => this.status == SyncStatus.STOPPED, { timeout: Infinity });
369
+ if (error) {
370
+ this.notify({ subtitle: "Uh oh!", message: "An error occurred while syncing files" });
371
+ throw error;
372
+ }
373
+ else {
374
+ this.log("Done");
375
+ }
376
+ }
377
+ }
378
+ exports.default = Sync;
379
+ Object.defineProperty(Sync, "priority", {
380
+ enumerable: true,
381
+ configurable: true,
382
+ writable: true,
383
+ value: 1
384
+ });
385
+ Object.defineProperty(Sync, "summary", {
386
+ enumerable: true,
387
+ configurable: true,
388
+ writable: true,
389
+ value: "Sync your Gadget application's source code to and from your local filesystem."
390
+ });
391
+ Object.defineProperty(Sync, "usage", {
392
+ enumerable: true,
393
+ configurable: true,
394
+ writable: true,
395
+ value: "sync --app <name> [DIRECTORY]"
396
+ });
397
+ Object.defineProperty(Sync, "description", {
398
+ enumerable: true,
399
+ configurable: true,
400
+ writable: true,
401
+ value: (0, ts_dedent_1.default) `
402
+ Sync provides the ability to sync your Gadget application's source code to and from your local
403
+ filesystem. While \`ggt sync\` is running, local file changes are immediately reflected within
404
+ Gadget, while files that are changed remotely are immediately saved to your local filesystem.
405
+
406
+ Use cases for this include:
407
+ * Developing locally with your own editor like VSCode (https://code.visualstudio.com/)
408
+ * Storing your source code in a Git repository like GitHub (https://github.com/)
409
+
410
+ Sync includes the concept of a \`.ignore\` file. This file can contain a list of files and
411
+ directories that won't be sent to Gadget when syncing.
412
+
413
+ The following files and directories are always ignored:
414
+ * .gadget
415
+ * .ggt
416
+ * .git
417
+ * node_modules
418
+
419
+ Note:
420
+ * Sync does not support node_modules, so you will have to run \`npm install\` yourself.
421
+ * Since file changes are immediately reflected in Gadget, avoid the following while \`ggt sync\` is running:
422
+ * Deleting all your files
423
+ * Moving all your files to a different directory
424
+ `
425
+ });
426
+ Object.defineProperty(Sync, "args", {
427
+ enumerable: true,
428
+ configurable: true,
429
+ writable: true,
430
+ value: [
431
+ {
432
+ name: "directory",
433
+ description: "The directory to sync files to. If the directory doesn't exist, it will be created.",
434
+ default: ".",
435
+ },
436
+ ]
437
+ });
438
+ Object.defineProperty(Sync, "flags", {
439
+ enumerable: true,
440
+ configurable: true,
441
+ writable: true,
442
+ value: {
443
+ "file-push-delay": core_1.Flags.integer({
444
+ summary: "Delay in milliseconds before pushing files to your app.",
445
+ helpGroup: "file",
446
+ helpValue: "ms",
447
+ default: 100,
448
+ hidden: true,
449
+ }),
450
+ "file-stability-threshold": core_1.Flags.integer({
451
+ name: "file-stability-threshold",
452
+ summary: "Time in milliseconds a file's size must remain the same.",
453
+ helpGroup: "file",
454
+ helpValue: "ms",
455
+ default: 500,
456
+ hidden: true,
457
+ }),
458
+ "file-poll-interval": core_1.Flags.integer({
459
+ name: "file-poll-interval",
460
+ description: "Interval in milliseconds between polling a file's size.",
461
+ helpGroup: "file",
462
+ helpValue: "ms",
463
+ default: 100,
464
+ hidden: true,
465
+ }),
466
+ }
467
+ });
468
+ Object.defineProperty(Sync, "examples", {
469
+ enumerable: true,
470
+ configurable: true,
471
+ writable: true,
472
+ value: [
473
+ (0, ts_dedent_1.default) `
474
+ $ ggt sync --app my-app ~/gadget/my-app
475
+ Ready
476
+ Received
477
+ ← routes/GET.js
478
+ ← user/signUp/signIn.js
479
+ Sent
480
+ → routes/GET.js
481
+ ^C Stopping... (press Ctrl+C again to force)
482
+ Done
483
+ `,
484
+ (0, ts_dedent_1.default) `
485
+ # These are equivalent
486
+ $ ggt sync -A my-app
487
+ $ ggt sync --app my-app
488
+ $ ggt sync --app my-app.gadget.app
489
+ $ ggt sync --app https://my-app.gadget.app
490
+ $ ggt sync --app https://my-app.gadget.app/edit
491
+ `,
492
+ ]
493
+ });
494
+ var SyncStatus;
495
+ (function (SyncStatus) {
496
+ SyncStatus[SyncStatus["STARTING"] = 0] = "STARTING";
497
+ SyncStatus[SyncStatus["RUNNING"] = 1] = "RUNNING";
498
+ SyncStatus[SyncStatus["STOPPING"] = 2] = "STOPPING";
499
+ SyncStatus[SyncStatus["STOPPED"] = 3] = "STOPPED";
500
+ })(SyncStatus = exports.SyncStatus || (exports.SyncStatus = {}));
501
+ var Action;
502
+ (function (Action) {
503
+ Action["CANCEL"] = "Cancel (Ctrl+C)";
504
+ Action["MERGE"] = "Merge local files with remote ones";
505
+ Action["RESET"] = "Reset local files to remote ones";
506
+ })(Action = exports.Action || (exports.Action = {}));
507
+ exports.REMOTE_FILE_SYNC_EVENTS_SUBSCRIPTION = `
508
+ subscription RemoteFileSyncEvents($localFilesVersion: String!) {
509
+ remoteFileSyncEvents(localFilesVersion: $localFilesVersion) {
510
+ remoteFilesVersion
511
+ changed {
512
+ path
513
+ mode
514
+ content
515
+ }
516
+ deleted {
517
+ path
518
+ }
519
+ }
520
+ }
521
+ `;
522
+ exports.REMOTE_FILES_VERSION_QUERY = `
523
+ query RemoteFilesVersion {
524
+ remoteFilesVersion
525
+ }
526
+ `;
527
+ exports.PUBLISH_FILE_SYNC_EVENTS_MUTATION = `
528
+ mutation PublishFileSyncEvents($input: PublishFileSyncEventsInput!) {
529
+ publishFileSyncEvents(input: $input) {
530
+ remoteFilesVersion
531
+ }
532
+ }
533
+ `;
534
+ //# sourceMappingURL=sync.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync.js","sourceRoot":"","sources":["../../src/commands/sync.ts"],"names":[],"mappings":";;;;AAAA,sCAAoC;AAEpC,4DAA4B;AAC5B,uCAAqC;AAErC,gEAA0B;AAC1B,uCAAkC;AAElC,mCAAkC;AAClC,4EAA2C;AAC3C,0DAAyB;AACzB,8DAA6B;AAC7B,wDAAwB;AACxB,kEAA+B;AAC/B,sDAAkD;AAElD,8CAAiE;AACjE,wCAA0C;AAY1C,MAAqB,IAAK,SAAQ,0BAAW;IAA7C;;QAwFE;;;;mBAA+B,IAAI;WAAC;QAEpC;;;;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;;;;;WAAkB;QAElB;;;;;WAAoB;QAEpB;;;;mBAAW;gBACT,WAAW,EAAE;oBACX,YAAY,EAAE,GAAG;oBACjB,KAAK,EAAE,CAAC;iBACT;aACF;WAAC;QAEF;;;;;WAAoC;QAEpC;;;;;WAA0C;IAsV5C,CAAC;IApVC,QAAQ,CAAC,EAAU;QACjB,OAAO,cAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IACrC,CAAC;IAED,QAAQ,CAAC,GAAG,YAAsB;QAChC,OAAO,cAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,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;YACnE,SAAS,EAAE,MAAM;YACjB,SAAS,EAAE,IAAI;YACf,OAAO,EAAE,GAAG;YACZ,MAAM,EAAE,IAAI;SACb,CAAuB;QACxB,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,CAAuB;KACzB;GAAC;AAEF;;;;WAA2B;QACzB,IAAA,mBAAM,EAAA;;;;;;;;;;KAUL;QACD,IAAA,mBAAM,EAAA;;;;;;;KAOL;KACF;GAAC;AAmXJ,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;;;;;;;;;;;;;;CAcjB,CAAC;AAEW,QAAA,0BAA0B,GAAmF;;;;CAIzH,CAAC;AAEW,QAAA,iCAAiC,GAG5B;;;;;;CAMjB,CAAC","sourcesContent":["import { Flags } from \"@oclif/core\";\nimport type { OptionFlag } from \"@oclif/core/lib/interfaces\";\nimport assert from \"assert\";\nimport { FSWatcher } from \"chokidar\";\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 { BaseCommand } from \"../lib/base-command\";\nimport type { Query } from \"../lib/client\";\nimport { ignoreEnoent, Ignorer, walkDir } from \"../lib/fs-utils\";\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 <name> [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 * .ggt\n * .git\n * node_modules\n\n Note:\n * Sync does not support node_modules, so you will have to run \\`npm install\\` yourself.\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 \"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 override readonly requireApp = 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 ignorer!: Ignorer;\n\n watcher!: FSWatcher;\n\n metadata = {\n lastWritten: {\n filesVersion: \"0\",\n mtime: 0,\n },\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 this.filePushDelay = flags[\"file-push-delay\"];\n\n // local files that should never be published\n const ignored = [\"node_modules/\", \".gadget/\", \".ggt/\", \".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 await fs.ensureDir(this.dir);\n\n try {\n this.metadata = await fs.readJson(this.absolute(\".ggt\", \"sync.json\"));\n } catch (error) {\n // use defaults if the metadata file doesn't exist\n ignoreEnoent(error);\n\n const d = await fs.opendir(this.dir);\n if ((await d.read()) != null) {\n this.warn(\"Could not find .ggt/sync.json in a non empty directory\");\n }\n await d.close();\n }\n\n const { remoteFilesVersion } = await this.client.queryUnwrap({ query: REMOTE_FILES_VERSION_QUERY });\n const hasRemoteChanges = BigInt(remoteFilesVersion) > BigInt(this.metadata.lastWritten.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, maxFiles: 100 })) {\n const stats = await fs.stat(filepath);\n if (stats.mtime.getTime() > this.metadata.lastWritten.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.lastWritten.mtime) {\n this.metadata.lastWritten.mtime = stats.mtime.getTime();\n }\n\n return {\n path: this.normalize(filepath),\n mode: stats.mode,\n content: await fs.readFile(filepath, \"utf-8\"),\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.lastWritten.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(\".ggt\", \"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 process.once(\"SIGINT\", () => {\n this.log(` Exiting immediately. Note that files may not have finished syncing.`);\n process.exit(1);\n });\n\n void this.stop();\n });\n }\n\n const unsubscribe = this.client.subscribeUnwrap(\n {\n query: REMOTE_FILE_SYNC_EVENTS_SUBSCRIPTION,\n variables: () => ({ localFilesVersion: this.metadata.lastWritten.filesVersion }),\n },\n {\n error: (error) => void this.stop(error),\n next: ({ remoteFileSyncEvents }) => {\n if (!remoteFileSyncEvents.changed.length && !remoteFileSyncEvents.deleted.length) {\n return;\n }\n\n const { remoteFilesVersion, changed, deleted } = remoteFileSyncEvents;\n const remoteFiles = new Map([...deleted, ...changed].map((e) => [e.path, e]));\n\n void this.queue\n .add(async () => {\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(\"/\")) await fs.writeFile(filepath, file.content, { mode: file.mode });\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.lastWritten.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, \"utf-8\"),\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.lastWritten.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.lastWritten.filesVersion)) {\n this.metadata.lastWritten.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 lastWritten.mtime if the file is not ignored, because if we restart and the lastWritten.mtime is set to an\n // ignored file, then it *could* be greater than the mtime of all non ignored files and we'll think that local files have\n // changed when only an ignored one has\n if (stats && stats.mtime.getTime() > this.metadata.lastWritten.mtime) {\n this.metadata.lastWritten.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"]}
@@ -0,0 +1,7 @@
1
+ import { BaseCommand } from "../lib/base-command";
2
+ export default class Whoami extends BaseCommand {
3
+ static summary: string;
4
+ static usage: string;
5
+ static examples: string[];
6
+ run(): Promise<void>;
7
+ }
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const ts_dedent_1 = tslib_1.__importDefault(require("ts-dedent"));
5
+ const base_command_1 = require("../lib/base-command");
6
+ class Whoami extends base_command_1.BaseCommand {
7
+ async run() {
8
+ const user = await this.getCurrentUser();
9
+ if (!user) {
10
+ this.log("You are not logged in");
11
+ return;
12
+ }
13
+ if (user.name) {
14
+ this.log(`You are logged in as ${user.name} (${user.email})`);
15
+ }
16
+ else {
17
+ this.log(`You are logged in as ${user.email}`);
18
+ }
19
+ }
20
+ }
21
+ exports.default = Whoami;
22
+ Object.defineProperty(Whoami, "summary", {
23
+ enumerable: true,
24
+ configurable: true,
25
+ writable: true,
26
+ value: "Show the name and email address of the currently logged in user."
27
+ });
28
+ Object.defineProperty(Whoami, "usage", {
29
+ enumerable: true,
30
+ configurable: true,
31
+ writable: true,
32
+ value: "whoami"
33
+ });
34
+ Object.defineProperty(Whoami, "examples", {
35
+ enumerable: true,
36
+ configurable: true,
37
+ writable: true,
38
+ value: [
39
+ (0, ts_dedent_1.default) `
40
+ $ ggt whoami
41
+ You are logged in as Jane Doe (jane@example.com)
42
+ `,
43
+ ]
44
+ });
45
+ //# sourceMappingURL=whoami.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"whoami.js","sourceRoot":"","sources":["../../src/commands/whoami.ts"],"names":[],"mappings":";;;AAAA,kEAA+B;AAC/B,sDAAkD;AAElD,MAAqB,MAAO,SAAQ,0BAAW;IAY7C,KAAK,CAAC,GAAG;QACP,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;QACzC,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;AAxBC;;;;WAA0B,kEAAkE;GAAC;AAE7F;;;;WAAwB,QAAQ;GAAC;AAEjC;;;;WAA2B;QACzB,IAAA,mBAAM,EAAA;;;KAGL;KACF;GAAC","sourcesContent":["import dedent from \"ts-dedent\";\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 this.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"]}
@@ -0,0 +1 @@
1
+ export { run } from "@oclif/core";