@gadgetinc/ggt 0.1.16 → 0.1.18

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 CHANGED
@@ -129,7 +129,7 @@ EXAMPLES
129
129
  Goodbye!
130
130
  ```
131
131
 
132
- _See code: [src/commands/sync.ts](https://github.com/gadget-inc/ggt/blob/v0.1.16/src/commands/sync.ts)_
132
+ _See code: [src/commands/sync.ts](https://github.com/gadget-inc/ggt/blob/v0.1.18/src/commands/sync.ts)_
133
133
 
134
134
  ### `ggt help [COMMAND]`
135
135
 
@@ -143,7 +143,7 @@ ARGUMENTS
143
143
  COMMAND The command to show help for.
144
144
  ```
145
145
 
146
- _See code: [src/commands/help.ts](https://github.com/gadget-inc/ggt/blob/v0.1.16/src/commands/help.ts)_
146
+ _See code: [src/commands/help.ts](https://github.com/gadget-inc/ggt/blob/v0.1.18/src/commands/help.ts)_
147
147
 
148
148
  ### `ggt list`
149
149
 
@@ -170,7 +170,7 @@ EXAMPLES
170
170
  $ ggt list --sort=slug
171
171
  ```
172
172
 
173
- _See code: [src/commands/list.ts](https://github.com/gadget-inc/ggt/blob/v0.1.16/src/commands/list.ts)_
173
+ _See code: [src/commands/list.ts](https://github.com/gadget-inc/ggt/blob/v0.1.18/src/commands/list.ts)_
174
174
 
175
175
  ### `ggt login`
176
176
 
@@ -189,7 +189,7 @@ EXAMPLES
189
189
  Hello, Jane Doe (jane@example.com)
190
190
  ```
191
191
 
192
- _See code: [src/commands/login.ts](https://github.com/gadget-inc/ggt/blob/v0.1.16/src/commands/login.ts)_
192
+ _See code: [src/commands/login.ts](https://github.com/gadget-inc/ggt/blob/v0.1.18/src/commands/login.ts)_
193
193
 
194
194
  ### `ggt logout`
195
195
 
@@ -204,7 +204,7 @@ EXAMPLES
204
204
  Goodbye
205
205
  ```
206
206
 
207
- _See code: [src/commands/logout.ts](https://github.com/gadget-inc/ggt/blob/v0.1.16/src/commands/logout.ts)_
207
+ _See code: [src/commands/logout.ts](https://github.com/gadget-inc/ggt/blob/v0.1.18/src/commands/logout.ts)_
208
208
 
209
209
  ### `ggt whoami`
210
210
 
@@ -219,7 +219,7 @@ EXAMPLES
219
219
  You are logged in as Jane Doe (jane@example.com)
220
220
  ```
221
221
 
222
- _See code: [src/commands/whoami.ts](https://github.com/gadget-inc/ggt/blob/v0.1.16/src/commands/whoami.ts)_
222
+ _See code: [src/commands/whoami.ts](https://github.com/gadget-inc/ggt/blob/v0.1.18/src/commands/whoami.ts)_
223
223
 
224
224
  <!-- commandsstop -->
225
225
 
@@ -1,10 +1,10 @@
1
- import { Command } from "@oclif/core";
1
+ import { BaseCommand } from "../utils/base-command";
2
2
  /**
3
3
  * Copied from @oclif/plugin-help. Uses our own {@link Help} template class instead of the one from @oclif/core.
4
4
  *
5
5
  * @see https://github.com/oclif/plugin-help/blob/67b580570257b45e92d3a04d50bf2a432c59afe3/src/commands/help.ts
6
6
  */
7
- export default class HelpCommand extends Command {
7
+ export default class HelpCommand extends BaseCommand<typeof HelpCommand> {
8
8
  static strict: boolean;
9
9
  static summary: string;
10
10
  static args: {
@@ -3,12 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const core_1 = require("@oclif/core");
5
5
  const help_1 = tslib_1.__importDefault(require("../utils/help"));
6
+ const base_command_1 = require("../utils/base-command");
6
7
  /**
7
8
  * Copied from @oclif/plugin-help. Uses our own {@link Help} template class instead of the one from @oclif/core.
8
9
  *
9
10
  * @see https://github.com/oclif/plugin-help/blob/67b580570257b45e92d3a04d50bf2a432c59afe3/src/commands/help.ts
10
11
  */
11
- class HelpCommand extends core_1.Command {
12
+ class HelpCommand extends base_command_1.BaseCommand {
12
13
  async run() {
13
14
  const { argv } = await this.parse();
14
15
  const help = new help_1.default(this.config, { all: true });
@@ -1 +1 @@
1
- {"version":3,"file":"help.js","sourceRoot":"/","sources":["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;;AAfe;;;;WAAS,KAAK;GAAC;AAEf;;;;WAAU,uBAAuB;GAAC;AAElC;;;;WAAO;QACrB,OAAO,EAAE,WAAI,CAAC,MAAM,CAAC;YACnB,QAAQ,EAAE,KAAK;YACf,WAAW,EAAE,+BAA+B;SAC7C,CAAC;KACH;GAAC;kBAViB,WAAW","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"]}
1
+ {"version":3,"file":"help.js","sourceRoot":"/","sources":["commands/help.ts"],"names":[],"mappings":";;;AAAA,sCAAmC;AACnC,iEAAiC;AACjC,wDAAoD;AAEpD;;;;GAIG;AACH,MAAqB,WAAY,SAAQ,0BAA+B;IAYtE,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;;AAfe;;;;WAAS,KAAK;GAAC;AAEf;;;;WAAU,uBAAuB;GAAC;AAElC;;;;WAAO;QACrB,OAAO,EAAE,WAAI,CAAC,MAAM,CAAC;YACnB,QAAQ,EAAE,KAAK;YACf,WAAW,EAAE,+BAA+B;SAC7C,CAAC;KACH;GAAC;kBAViB,WAAW","sourcesContent":["import { Args } from \"@oclif/core\";\nimport Help from \"../utils/help\";\nimport { BaseCommand } from \"../utils/base-command\";\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 BaseCommand<typeof HelpCommand> {\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"]}
@@ -13,5 +13,6 @@ export default class List extends BaseCommand<typeof List> {
13
13
  'no-truncate': import("@oclif/core/lib/interfaces").Flag<boolean>;
14
14
  'no-header': import("@oclif/core/lib/interfaces").Flag<boolean>;
15
15
  };
16
+ requireUser: boolean;
16
17
  run(): Promise<void>;
17
18
  }
@@ -7,15 +7,24 @@ const ts_dedent_1 = tslib_1.__importDefault(require("ts-dedent"));
7
7
  const base_command_1 = require("../utils/base-command");
8
8
  const context_1 = require("../utils/context");
9
9
  class List extends base_command_1.BaseCommand {
10
+ constructor() {
11
+ super(...arguments);
12
+ Object.defineProperty(this, "requireUser", {
13
+ enumerable: true,
14
+ configurable: true,
15
+ writable: true,
16
+ value: true
17
+ });
18
+ }
10
19
  async run() {
11
20
  const { flags } = await this.parse(List);
12
- const user = await context_1.context.getUser();
13
- if (!user) {
14
- this.error("You are not logged in -- no apps available", { exit: 1 });
15
- }
16
21
  const apps = await context_1.context.getAvailableApps();
17
- if (apps.length === 0 && !flags.csv) {
18
- this.log("No apps found");
22
+ if (!apps.length) {
23
+ this.log((0, ts_dedent_1.default) `
24
+ It doesn't look like you have any applications.
25
+
26
+ Visit https://gadget.new to create one!
27
+ `);
19
28
  return;
20
29
  }
21
30
  core_1.ux.table(apps, {
@@ -1 +1 @@
1
- {"version":3,"file":"list.js","sourceRoot":"/","sources":["commands/list.ts"],"names":[],"mappings":";;;AAAA,0DAA0B;AAC1B,sCAAiC;AACjC,kEAA+B;AAC/B,wDAAoD;AAEpD,8CAA2C;AAE3C,MAAqB,IAAK,SAAQ,0BAAwB;IAiBxD,KAAK,CAAC,GAAG;QACP,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACzC,MAAM,IAAI,GAAG,MAAM,iBAAO,CAAC,OAAO,EAAE,CAAC;QACrC,IAAI,CAAC,IAAI,EAAE;YACT,IAAI,CAAC,KAAK,CAAC,4CAA4C,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC;SACvE;QACD,MAAM,IAAI,GAAG,MAAM,iBAAO,CAAC,gBAAgB,EAAE,CAAC;QAE9C,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE;YACnC,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;YAC1B,OAAO;SACR;QAED,SAAE,CAAC,KAAK,CACN,IAAkD,EAClD;YACE,EAAE,EAAE;gBACF,MAAM,EAAE,IAAI;gBACZ,QAAQ,EAAE,IAAI;aACf;YACD,IAAI,EAAE;gBACJ,MAAM,EAAE,MAAM;aACf;YACD,aAAa,EAAE;gBACb,MAAM,EAAE,QAAQ;aACjB;SACF,EACD;YACE,SAAS,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC;YAC9B,GAAG,KAAK,EAAE,eAAe;SAC1B,CACF,CAAC;IACJ,CAAC;;AAhDe;;;;WAAU,0DAA0D;GAAC;AAErE;;;;WAAQ,MAAM;GAAC;AAEf;;;;WAAW;QACzB,IAAA,mBAAM,EAAC,IAAA,eAAK,EAAA;;;;KAIX,CAAC;KACH;GAAC;AAEc;;;;WAAQ;QACtB,GAAG,SAAE,CAAC,KAAK,CAAC,KAAK,EAAE;KACpB;GAAC;kBAfiB,IAAI","sourcesContent":["import chalk from \"chalk\";\nimport { ux } from \"@oclif/core\";\nimport dedent from \"ts-dedent\";\nimport { BaseCommand } from \"../utils/base-command\";\nimport type { App } from \"../utils/context\";\nimport { context } from \"../utils/context\";\n\nexport default class List extends BaseCommand<typeof List> {\n static override summary = \"List the apps available to the currently logged in user.\";\n\n static override usage = \"list\";\n\n static override examples = [\n dedent(chalk`\n {gray $ ggt list}\n {gray $ ggt list --extended}\n {gray $ ggt list --sort=slug}\n `),\n ];\n\n static override flags = {\n ...ux.table.flags(),\n };\n\n async run(): Promise<void> {\n const { flags } = await this.parse(List);\n const user = await context.getUser();\n if (!user) {\n this.error(\"You are not logged in -- no apps available\", { exit: 1 });\n }\n const apps = await context.getAvailableApps();\n\n if (apps.length === 0 && !flags.csv) {\n this.log(\"No apps found\");\n return;\n }\n\n ux.table<App & Record<string, never>>(\n apps as unknown as (App & Record<string, never>)[],\n {\n id: {\n header: \"ID\",\n extended: true,\n },\n slug: {\n header: \"Slug\",\n },\n primaryDomain: {\n header: \"Domain\",\n },\n },\n {\n printLine: this.log.bind(this),\n ...flags, // parsed flags\n }\n );\n }\n}\n"]}
1
+ {"version":3,"file":"list.js","sourceRoot":"/","sources":["commands/list.ts"],"names":[],"mappings":";;;AAAA,0DAA0B;AAC1B,sCAAiC;AACjC,kEAA+B;AAC/B,wDAAoD;AAEpD,8CAA2C;AAE3C,MAAqB,IAAK,SAAQ,0BAAwB;IAA1D;;QAiBW;;;;mBAAc,IAAI;WAAC;IAmC9B,CAAC;IAjCC,KAAK,CAAC,GAAG;QACP,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAEzC,MAAM,IAAI,GAAG,MAAM,iBAAO,CAAC,gBAAgB,EAAE,CAAC;QAC9C,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;YAChB,IAAI,CAAC,GAAG,CAAC,IAAA,mBAAM,EAAA;;;;OAId,CAAC,CAAC;YACH,OAAO;SACR;QAED,SAAE,CAAC,KAAK,CACN,IAAkD,EAClD;YACE,EAAE,EAAE;gBACF,MAAM,EAAE,IAAI;gBACZ,QAAQ,EAAE,IAAI;aACf;YACD,IAAI,EAAE;gBACJ,MAAM,EAAE,MAAM;aACf;YACD,aAAa,EAAE;gBACb,MAAM,EAAE,QAAQ;aACjB;SACF,EACD;YACE,SAAS,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC;YAC9B,GAAG,KAAK,EAAE,eAAe;SAC1B,CACF,CAAC;IACJ,CAAC;;AAlDe;;;;WAAU,0DAA0D;EAA7D,CAA8D;AAErE;;;;WAAQ,MAAM;EAAT,CAAU;AAEf;;;;WAAW;QACzB,IAAA,mBAAM,EAAC,IAAA,eAAK,EAAA;;;;KAIX,CAAC;KACH;EANuB,CAMtB;AAEc;;;;WAAQ;QACtB,GAAG,SAAE,CAAC,KAAK,CAAC,KAAK,EAAE;KACpB;EAFoB,CAEnB;kBAfiB,IAAI","sourcesContent":["import chalk from \"chalk\";\nimport { ux } from \"@oclif/core\";\nimport dedent from \"ts-dedent\";\nimport { BaseCommand } from \"../utils/base-command\";\nimport type { App } from \"../utils/context\";\nimport { context } from \"../utils/context\";\n\nexport default class List extends BaseCommand<typeof List> {\n static override summary = \"List the apps available to the currently logged in user.\";\n\n static override usage = \"list\";\n\n static override examples = [\n dedent(chalk`\n {gray $ ggt list}\n {gray $ ggt list --extended}\n {gray $ ggt list --sort=slug}\n `),\n ];\n\n static override flags = {\n ...ux.table.flags(),\n };\n\n override requireUser = true;\n\n async run(): Promise<void> {\n const { flags } = await this.parse(List);\n\n const apps = await context.getAvailableApps();\n if (!apps.length) {\n this.log(dedent`\n It doesn't look like you have any applications.\n\n Visit https://gadget.new to create one!\n `);\n return;\n }\n\n ux.table<App & Record<string, never>>(\n apps as unknown as (App & Record<string, never>)[],\n {\n id: {\n header: \"ID\",\n extended: true,\n },\n slug: {\n header: \"Slug\",\n },\n primaryDomain: {\n header: \"Domain\",\n },\n },\n {\n printLine: this.log.bind(this),\n ...flags, // parsed flags\n }\n );\n }\n}\n"]}
@@ -4,7 +4,7 @@ import PQueue from "p-queue";
4
4
  import { BaseCommand } from "../utils/base-command";
5
5
  import type { Query } from "../utils/client";
6
6
  import { Client } from "../utils/client";
7
- import { Ignorer } from "../utils/fs-utils";
7
+ import { FSIgnorer } from "../utils/fs-utils";
8
8
  import type { PublishFileSyncEventsMutation, PublishFileSyncEventsMutationVariables, RemoteFilesVersionQuery, RemoteFilesVersionQueryVariables, RemoteFileSyncEventsSubscription, RemoteFileSyncEventsSubscriptionVariables } from "../__generated__/graphql";
9
9
  export default class Sync extends BaseCommand<typeof Sync> {
10
10
  static priority: number;
@@ -23,30 +23,112 @@ export default class Sync extends BaseCommand<typeof Sync> {
23
23
  };
24
24
  static examples: string[];
25
25
  requireUser: boolean;
26
+ /**
27
+ * The current status of the sync process.
28
+ */
26
29
  status: SyncStatus;
30
+ /**
31
+ * The absolute path to the directory to sync files to.
32
+ */
27
33
  dir: string;
28
- recentWrites: Set<unknown>;
34
+ /**
35
+ * A list of filepaths that have changed because of a remote file-sync event. This is used to avoid sending files that
36
+ * we recently received from a remote file-sync event.
37
+ */
38
+ recentRemoteChanges: Set<string>;
39
+ /**
40
+ * A FIFO async callback queue that ensures we process file-sync events in the order they occurred.
41
+ */
29
42
  queue: PQueue<import("p-queue/dist/priority-queue").default, import("p-queue").DefaultAddOptions>;
43
+ /**
44
+ * A GraphQL client connected to the app's /edit/api/graphql-ws endpoint
45
+ */
30
46
  client: Client;
31
- ignorer: Ignorer;
47
+ /**
48
+ * Loads the .ignore file and provides methods for checking if a file should be ignored.
49
+ */
50
+ ignorer: FSIgnorer;
51
+ /**
52
+ * Watches the local filesystem for changes.
53
+ */
32
54
  watcher: FSWatcher;
55
+ /**
56
+ * Holds information about the state of the local filesystem. It's persisted to `.gadget/sync.json`.
57
+ */
33
58
  metadata: {
59
+ /**
60
+ * The app this filesystem is synced to.
61
+ */
34
62
  app: string;
63
+ /**
64
+ * The last filesVersion that was successfully written to the filesystem. This is used to determine if the remote
65
+ * filesystem is ahead of the local one.
66
+ */
35
67
  filesVersion: string;
68
+ /**
69
+ * The largest mtime that was seen on the local filesystem before `ggt sync` stopped. This is used to determine if
70
+ * the local filesystem has changed since the last sync.
71
+ *
72
+ * Note: This does not include the mtime of files that are ignored.
73
+ */
36
74
  mtime: number;
37
75
  };
76
+ /**
77
+ * A debounced function that enqueue's local file changes to be sent to Gadget.
78
+ */
38
79
  publish: DebouncedFunc<() => void>;
80
+ /**
81
+ * Gracefully stops the sync.
82
+ */
39
83
  stop: (error?: unknown) => Promise<void>;
40
- finished: Promise<void>;
41
- markFinished: () => void;
84
+ /**
85
+ * Turns an absolute filepath into a relative one from {@linkcode dir}.
86
+ */
42
87
  relative(to: string): string;
88
+ /**
89
+ * Combines path segments into an absolute filepath that starts at {@linkcode dir}.
90
+ */
43
91
  absolute(...pathSegments: string[]): string;
44
- normalize(filepath: string, isDirectory?: boolean): string;
92
+ /**
93
+ * Similar to {@linkcode relative} in that it turns a filepath into a relative one from {@linkcode dir}. However, it
94
+ * also changes any slashes to be posix/unix-like forward slashes, condenses repeated slashes into a single slash, and
95
+ * adds a trailing slash if the filepath is a directory.
96
+ *
97
+ * This is used when sending file-sync events to Gadget to ensure that the paths are consistent across platforms.
98
+ *
99
+ * @see https://www.npmjs.com/package/normalize-path
100
+ */
101
+ normalize(filepath: string, isDirectory: boolean): string;
102
+ /**
103
+ * Pretty-prints changed and deleted filepaths to the console.
104
+ *
105
+ * @param prefix The prefix to print before each line.
106
+ * @param changed The normalized paths that have changed.
107
+ * @param deleted The normalized paths that have been deleted.
108
+ * @param options.limit The maximum number of lines to print. Defaults to 10. If debug is enabled, this is ignored.
109
+ */
45
110
  logPaths(prefix: string, changed: string[], deleted: string[], { limit }?: {
46
111
  limit?: number | undefined;
47
112
  }): void;
113
+ /**
114
+ * Initializes the sync process.
115
+ * - Ensures the directory exists.
116
+ * - Ensures the directory is empty or contains a `.gadget/sync.json` file.
117
+ * - Ensures an app is selected and that it matches the app the directory was previously synced to.
118
+ * - Ensures yarn v1 is installed.
119
+ * - Prompts the user how to resolve conflicts if the local filesystem has changed since the last sync.
120
+ */
48
121
  init(): Promise<void>;
122
+ /**
123
+ * Runs the sync process until it is stopped or an error occurs.
124
+ */
49
125
  run(): Promise<void>;
126
+ /**
127
+ * Enqueues a function that handles file-sync events onto the {@linkcode queue}.
128
+ *
129
+ * @param fn The function to enqueue.
130
+ */
131
+ private _enqueue;
50
132
  }
51
133
  export declare enum SyncStatus {
52
134
  STARTING = 0,