@gadgetinc/ggt 0.1.7 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/README.md +7 -7
  2. package/lib/__generated__/graphql.d.ts +45 -45
  3. package/lib/commands/help.js +1 -1
  4. package/lib/commands/help.js.map +1 -1
  5. package/lib/commands/login.d.ts +1 -1
  6. package/lib/commands/login.js +1 -1
  7. package/lib/commands/login.js.map +1 -1
  8. package/lib/commands/logout.d.ts +1 -1
  9. package/lib/commands/logout.js +2 -2
  10. package/lib/commands/logout.js.map +1 -1
  11. package/lib/commands/sync.d.ts +4 -4
  12. package/lib/commands/sync.js +20 -25
  13. package/lib/commands/sync.js.map +1 -1
  14. package/lib/commands/whoami.d.ts +1 -1
  15. package/lib/commands/whoami.js +2 -2
  16. package/lib/commands/whoami.js.map +1 -1
  17. package/lib/{lib → utils}/base-command.d.ts +0 -0
  18. package/lib/{lib → utils}/base-command.js +1 -1
  19. package/lib/utils/base-command.js.map +1 -0
  20. package/lib/{lib → utils}/client.d.ts +1 -1
  21. package/lib/{lib → utils}/client.js +3 -3
  22. package/lib/utils/client.js.map +1 -0
  23. package/lib/{lib → utils}/context.d.ts +0 -0
  24. package/lib/{lib → utils}/context.js +0 -0
  25. package/lib/utils/context.js.map +1 -0
  26. package/lib/{lib → utils}/errors.d.ts +7 -1
  27. package/lib/{lib → utils}/errors.js +73 -61
  28. package/lib/utils/errors.js.map +1 -0
  29. package/lib/{lib → utils}/flags.d.ts +0 -0
  30. package/lib/{lib → utils}/flags.js +0 -0
  31. package/lib/utils/flags.js.map +1 -0
  32. package/lib/{lib → utils}/fs-utils.d.ts +0 -0
  33. package/lib/{lib → utils}/fs-utils.js +1 -1
  34. package/lib/utils/fs-utils.js.map +1 -0
  35. package/lib/{lib → utils}/help.d.ts +0 -0
  36. package/lib/{lib → utils}/help.js +0 -0
  37. package/lib/utils/help.js.map +1 -0
  38. package/lib/{lib → utils}/sleep.d.ts +0 -0
  39. package/lib/{lib → utils}/sleep.js +0 -0
  40. package/lib/utils/sleep.js.map +1 -0
  41. package/npm-shrinkwrap.json +2757 -2891
  42. package/oclif.manifest.json +1 -1
  43. package/package.json +35 -34
  44. package/lib/lib/base-command.js.map +0 -1
  45. package/lib/lib/client.js.map +0 -1
  46. package/lib/lib/context.js.map +0 -1
  47. package/lib/lib/errors.js.map +0 -1
  48. package/lib/lib/flags.js.map +0 -1
  49. package/lib/lib/fs-utils.js.map +0 -1
  50. package/lib/lib/help.js.map +0 -1
  51. package/lib/lib/sleep.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":";;;;AAAA,sEAAqC;AACrC,6BAAgC;AAEhC,mCAA8F;AAC9F,qDAAuE;AACvE,kEAA+B;AAE/B,+BAA+B;AAI/B,uCAAoC;AACpC,6DAAuC;AACvC,oDAAoB;AACpB,mCAAoC;AAEpC,IAAI,iBAAO,CAAC,GAAG,CAAC,cAAc,EAAE;IAC9B,MAAM,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,2EAA2E,EAAE,CAAC,CAAC;CACnG;AAED;;;;GAIG;AACH,MAAsB,SAAU,SAAQ,KAAK;IA0B3C,YAAY,IAAY,EAAE,OAAe;QACvC,KAAK,CAAC,OAAO,CAAC,CAAC;QA1BjB;;WAEG;QACH;;;;;WAAa;QAEb;;WAEG;QACH;;;;mBAAgB,iBAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,sCAAsC,CAAC,CAAC,CAAC,IAAA,mBAAU,GAAE;WAAC;QAE7F;;WAEG;QACH;;;;;WAAqB;QAErB;;WAEG;QACH;;;;;WAAwB;QAStB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IAClD,CAAC;IAED,KAAK,CAAC,O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CAAC,IAAI,IAAA,iBAAQ,EAAC,CAAC,CAAC,OAAO,CAAC,IAAI,IAAA,gBAAO,EAAC,CAAC,CAAC,SAAS,IAAI,EAAE,CAAC,IAAI,IAAA,gBAAO,EAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC;AAC/H,CAAC","sourcesContent":["import cleanStack from \"clean-stack\";\nimport { HTTPError } from \"got\";\nimport type { GraphQLError } from \"graphql\";\nimport { isArray, isBoolean, isError, isNil, isNumber, isString, noop, uniqBy } from \"lodash\";\nimport { serializeError as baseSerializeError } from \"serialize-error\";\nimport dedent from \"ts-dedent\";\nimport type { SetOptional } from \"type-fest\";\nimport { inspect } from \"util\";\nimport type { CloseEvent, ErrorEvent } from \"ws\";\nimport type Sync from \"../commands/sync\";\nimport type { Payload } from \"./client\";\nimport { context } from \"./context\";\nimport * as Sentry from \"@sentry/node\";\nimport os from \"os\";\nimport { randomUUID } from \"crypto\";\n\nif (context.env.productionLike) {\n Sentry.init({ dsn: \"https://0c26e0d8afd94e77a88ee1c3aa9e7065@o250689.ingest.sentry.io/6703266\" });\n}\n\n/**\n * Base class for all errors.\n *\n * Inspired by gadget's GadgetError and oclif's PrettyPrintableError.\n */\nexport abstract class BaseError extends Error {\n /**\n * A GGT_CLI_SOMETHING human/machine readable unique identifier for this error.\n */\n code: string;\n\n /**\n * The Sentry event ID for this error.\n */\n sentryEventId = context.env.testLike ? \"00000000-0000-0000-0000-000000000000\" : randomUUID();\n\n /**\n * The underlying *thing* that caused this error.\n */\n override cause?: any;\n\n /**\n * Assume the stack trace exists.\n */\n override stack!: string;\n\n /**\n * Indicates whether this error is considered a bug or not.\n */\n abstract isBug: IsBug;\n\n constructor(code: string, message: string) {\n super(message);\n this.code = code;\n Error.captureStackTrace(this, this.constructor);\n }\n\n async capture(): Promise<void> {\n if (this.isBug == IsBug.NO) return;\n\n const user = await context.getUser().catch(noop);\n\n Sentry.getCurrentHub().captureException(this, {\n event_id: this.sentryEventId,\n captureContext: {\n user: user ? { id: String(user.id), email: user.email, username: user.name } : undefined,\n tags: {\n applicationId: context.app?.id,\n arch: context.config.arch,\n isBug: this.isBug,\n code: this.code,\n environment: context.env.value,\n platform: context.config.platform,\n shell: context.config.shell,\n version: context.config.version,\n },\n contexts: {\n cause: this.cause ? serializeError(this.cause) : undefined,\n app: {\n command: `${context.config.bin} ${process.argv.slice(2).join(\" \")}`,\n argv: process.argv,\n },\n device: {\n name: os.hostname(),\n family: os.type(),\n arch: os.arch(),\n },\n runtime: {\n name: process.release.name,\n version: process.version,\n },\n },\n },\n });\n\n await Sentry.flush(2000);\n }\n\n /**\n * Turns this error into a user-friendly message that explains what went wrong and how to fix it. A good write up of what an error should\n * look like can be found here: {@link https://clig.dev/#errors}\n */\n render(): string {\n const rendered = dedent`\n ${this.header()}\n\n ${this.body()}\n `;\n\n const footer = this.footer();\n if (!footer) return rendered;\n\n return dedent`\n ${rendered}\n\n ${footer}\n `;\n }\n\n protected header(): string {\n return `${this.code}: ${this.message}`;\n }\n\n protected footer(): string {\n if (this.isBug == IsBug.NO) return \"\";\n\n return dedent`\n ${this.isBug == IsBug.YES ? \"This is a bug\" : \"If you think this is a bug\"}, please submit an issue using the link below.\n\n https://github.com/gadget-inc/ggt/issues/new?template=bug_report.yml&error-id=${this.sentryEventId}\n `;\n }\n\n protected abstract body(): string;\n}\n\n/**\n * Universal Error object to json blob serializer.\n * Wraps `serialize-error` with some handy stuff, like special support for Got HTTP errors\n */\nexport function serializeError(error: Error | string | unknown): Record<string, any> {\n let serialized = baseSerializeError(isArray(error) ? new AggregateError(error) : error);\n if (typeof serialized == \"string\") {\n serialized = { message: serialized };\n }\n\n if (error instanceof HTTPError && error.name === \"RequestError\") {\n delete serialized[\"timings\"];\n serialized[\"options\"] = { method: error.options.method, url: error.options.url.toJSON() };\n serialized[\"responseBody\"] = inspect(error.response?.body);\n }\n\n return serialized;\n}\n\nexport enum IsBug {\n YES = \"yes\",\n NO = \"no\",\n MAYBE = \"maybe\",\n}\n\n/**\n * Our \"catch all\" error. If this error is thrown, we almost certainly have a bug.\n *\n * Whenever possible, we should use a more specific error so that we can provide more useful information.\n */\nexport class UnexpectedError extends BaseError {\n isBug = IsBug.YES;\n\n constructor(override cause: Error) {\n super(\"GGT_CLI_UNEXPECTED_ERROR\", \"An unexpected error occurred\");\n }\n\n protected body(): string {\n return cleanStack(this.cause.stack ?? this.stack);\n }\n}\n\nexport class ClientError extends BaseError {\n isBug = IsBug.MAYBE;\n\n constructor(readonly payload: Payload<any, any>, override cause: string | Error | readonly GraphQLError[] | CloseEvent | ErrorEvent) {\n super(\"GGT_CLI_CLIENT_ERROR\", \"An error occurred while communicating with Gadget\");\n\n // ErrorEvent and CloseEvent aren't serializable, so we reconstruct them into an object. We discard the `target` property because it's large and not that useful\n if (isErrorEvent(cause)) {\n this.cause = {\n type: cause.type,\n message: cause.message,\n error: serializeError(cause.error),\n } as any;\n } else if (isCloseEvent(cause)) {\n this.cause = {\n type: cause.type,\n code: cause.code,\n reason: cause.reason,\n wasClean: cause.wasClean,\n } as any;\n }\n }\n\n override body(): string {\n if (isGraphQLErrors(this.cause)) {\n if (this.cause.length > 1) {\n const errors = uniqBy(this.cause, \"message\");\n\n let output = \"Gadget responded with multiple errors:\\n\";\n for (let i = 0; i < errors.length; i++) {\n output += `\\n ${i + 1}. ${errors[i]?.message}`;\n }\n\n return output;\n } else {\n return dedent`\n Gadget responded with the following error:\n\n ${this.cause[0]?.message}\n `;\n }\n }\n\n if (isCloseEvent(this.cause)) {\n return \"The connection to Gadget closed unexpectedly.\";\n }\n\n if (isErrorEvent(this.cause) || isError(this.cause)) {\n return this.cause.message;\n }\n\n return this.cause;\n }\n}\n\nexport class YarnNotFoundError extends BaseError {\n isBug = IsBug.NO;\n\n constructor() {\n super(\"GGT_CLI_YARN_NOT_FOUND\", \"Yarn not found\");\n }\n\n protected body(): string {\n return dedent`\n Yarn must be installed to sync your application. You can install it by running:\n\n $ npm install --global yarn\n\n For more information, see: https://classic.yarnpkg.com/en/docs/install\n `;\n }\n}\n\nexport class FlagError<T extends { name: string; char?: string } = { name: string; char?: string }> extends BaseError {\n isBug = IsBug.NO;\n\n constructor(readonly flag: T, readonly description: string) {\n const name = flag.char ? `-${flag.char}, --${flag.name}` : `--${flag.name}`;\n super(\"GGT_CLI_FLAG_ERROR\", `Invalid value provided for the ${name} flag`);\n }\n\n protected body(): string {\n return this.description;\n }\n}\n\nexport class InvalidSyncFileError extends BaseError {\n isBug = IsBug.MAYBE;\n\n constructor(override readonly cause: unknown, readonly sync: Sync, readonly app: string | undefined) {\n super(\"GGT_CLI_INVALID_SYNC_FILE\", \"The .gadget/sync.json file was invalid or not found\");\n }\n\n protected body(): string {\n return dedent`\n We failed to read the Gadget metadata file in this directory:\n\n ${this.sync.dir}\n\n If you're running \\`ggt sync\\` for the first time, we recommend using an empty directory such as:\n\n ~/gadget/${this.app || \"<name of app>\"}\n\n Otherwise, if you're sure you want to sync the contents of that directory to Gadget, run \\`ggt sync\\` again with the \\`--force\\` flag:\n\n $ ggt sync ${this.sync.argv.join(\" \")} --force\n\n You will be prompted to either merge your local files with your remote ones or reset your local files to your remote ones.\n `;\n }\n}\n\nexport class InvalidSyncAppFlagError extends FlagError {\n constructor(sync: Sync, app: string) {\n super(\n { name: \"app\", char: \"a\" },\n dedent`\n You were about to sync the following app to the following directory:\n\n ${app} → ${sync.dir}\n\n However, that directory has already been synced with this app:\n\n ${sync.metadata.app}\n\n If you're sure that you want to sync \"${app}\" to \"${sync.dir}\", run \\`ggt sync\\` again with the \\`--force\\` flag:\n\n $ ggt sync ${sync.argv.join(\" \")} --force\n `\n );\n }\n}\n\nfunction isCloseEvent(e: any): e is SetOptional<CloseEvent, \"target\"> {\n return !isNil(e) && isString(e.type) && isNumber(e.code) && isString(e.reason) && isBoolean(e.wasClean);\n}\n\nfunction isErrorEvent(e: any): e is SetOptional<ErrorEvent, \"target\"> {\n return !isNil(e) && isString(e.type) && isString(e.message) && !isNil(e.error);\n}\n\nfunction isGraphQLErrors(e: any): e is readonly GraphQLError[] {\n return isArray(e) && e.every((e) => !isNil(e) && isString(e.message) && isArray(e.locations ?? []) && isArray(e.path ?? []));\n}\n"]}
File without changes
File without changes
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flags.js","sourceRoot":"","sources":["../../src/utils/flags.ts"],"names":[],"mappings":";;;;AAAA,sCAAoC;AACpC,gFAA2C;AAC3C,mCAAgC;AAChC,kEAA+B;AAC/B,uCAAoC;AACpC,qCAAqC;AAExB,QAAA,GAAG,GAAG,YAAK,CAAC,MAAM,CAAC;IAC9B,IAAI,EAAE,GAAG;IACT,IAAI,EAAE,KAAK;IACX,OAAO,EAAE,iDAAiD;IAC1D,KAAK,EAAE,KAAK,EAAE,KAAa,EAAE,EAAE;QAC7B,MAAM,IAAI,GAAG,sCAAsC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC,MAAM,CAAC,CAAC;QAClF,IAAI,CAAC,IAAI;YACP,MAAM,IAAI,kBAAS,CACjB,WAAG,EACH,IAAA,mBAAM,EAAA;;;;;;;;;SASL,CACF,CAAC;QAEJ,MAAM,aAAa,GAAG,MAAM,iBAAO,CAAC,gBAAgB,EAAE,CAAC;QACvD,MAAM,QAAQ,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,IAAI,IAAI,CAAC,CAAC,IAAI,IAAI,IAAI,CAAC,CAAC;QAC7E,IAAI,QAAQ,EAAE;YACZ,OAAO,QAAQ,CAAC,IAAI,CAAC;SACtB;QAED,MAAM,IAAI,kBAAS,CACjB,WAAG,EACH,aAAa,CAAC,MAAM,GAAG,CAAC;YACtB,CAAC,CAAC,IAAA,mBAAM,EAAA;;;kBAGE,KAAK;;;;kBAIL,IAAA,eAAM,EAAC,aAAa,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,0BAAW,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;iBAC9D,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC;iBACZ,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,KAAK,GAAG,CAAC,IAAI,EAAE,CAAC;iBAC7B,IAAI,CAAC,IAAI,CAAC;aAChB;YACL,CAAC,CAAC,IAAA,mBAAM,EAAA;;;kBAGE,KAAK;;;;;aAKV,CACR,CAAC;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import { Flags } from \"@oclif/core\";\nimport levenshtein from \"fast-levenshtein\";\nimport { sortBy } from \"lodash\";\nimport dedent from \"ts-dedent\";\nimport { context } from \"./context\";\nimport { FlagError } from \"./errors\";\n\nexport const app = Flags.custom({\n char: \"a\",\n name: \"app\",\n summary: \"The Gadget application this command applies to.\",\n parse: async (value: string) => {\n const name = /^(https:\\/\\/)?(?<name>[\\w-]+)(\\..*)?/.exec(value)?.groups?.[\"name\"];\n if (!name)\n throw new FlagError(\n app,\n dedent`\n The -a, --app flag must be the application's name, slug, or URL\n\n Examples:\n\n --app my-app\n --app my-app.gadget.app\n --app https://my-app.gadget.app\n --app https://my-app.gadget.app/edit\n `\n );\n\n const availableApps = await context.getAvailableApps();\n const foundApp = availableApps.find((a) => a.name == name || a.slug == name);\n if (foundApp) {\n return foundApp.slug;\n }\n\n throw new FlagError(\n app,\n availableApps.length > 0\n ? dedent`\n Unknown application:\n\n ${value}\n\n Did you mean one of these?\n\n ${sortBy(availableApps, (app) => levenshtein.get(app.slug, name))\n .slice(0, 10)\n .map((app) => `* ${app.slug}`)\n .join(\"\\n\")}\n `\n : dedent`\n Unknown application:\n\n ${value}\n\n It doesn't look like you have any applications.\n\n Visit https://gadget.new to create one!\n `\n );\n },\n});\n"]}
File without changes
@@ -36,7 +36,7 @@ class Ignorer {
36
36
  this.reload();
37
37
  }
38
38
  ignores(filepath) {
39
- const relative = path_1.default.relative(this._rootDir, filepath);
39
+ const relative = path_1.default.isAbsolute(filepath) ? path_1.default.relative(this._rootDir, filepath) : filepath;
40
40
  if (relative == "")
41
41
  return false;
42
42
  return this._ignorer.ignores(relative);
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fs-utils.js","sourceRoot":"","sources":["../../src/utils/fs-utils.ts"],"names":[],"mappings":";;;;AAAA,0DAA0B;AAC1B,gEAA0B;AAE1B,4DAA4B;AAC5B,wDAAwB;AAExB,MAAM,KAAK,GAAG,IAAA,eAAK,EAAC,cAAc,CAAC,CAAC;AAEpC,MAAa,OAAO;IAKlB,YAA6B,QAAgB,EAAmB,aAAuB;;;;;mBAA1D;;;;;;mBAAmC;;QAJhE;;;;mBAAoB,cAAI,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC;WAAC;QAExD;;;;;WAA0B;QAGxB,IAAI,CAAC,MAAM,EAAE,CAAC;IAChB,CAAC;IAED,OAAO,CAAC,QAAgB;QACtB,MAAM,QAAQ,GAAG,cAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,cAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;QAC/F,IAAI,QAAQ,IAAI,EAAE;YAAE,OAAO,KAAK,CAAC;QACjC,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACzC,CAAC;IAED,MAAM;QACJ,IAAI,CAAC,QAAQ,GAAG,IAAA,gBAAM,GAAE,CAAC;QACzB,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAEtC,IAAI;YACF,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,kBAAE,CAAC,YAAY,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;YAC3D,KAAK,CAAC,+BAA+B,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;SACvD;QAAC,OAAO,KAAK,EAAE;YAC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ChE,MAAM,QAAQ,CAAC;SAChB;KACF;AACH,CAAC;AAXD,kCAWC;AAEM,KAAK,UAAU,UAAU,CAAC,GAAW,EAAE,IAAI,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE;IACzE,IAAI;QACF,MAAM,KAAK,GAAG,MAAM,kBAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACpC,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC;KAC3B;IAAC,OAAO,KAAK,EAAE;QACd,IAAI,IAAI,CAAC,YAAY,EAAE;YACrB,YAAY,CAAC,KAAK,CAAC,CAAC;YACpB,OAAO,IAAI,CAAC;SACb;QACD,MAAM,KAAK,CAAC;KACb;AACH,CAAC;AAXD,gCAWC;AAED,SAAgB,YAAY,CAAC,KAAU;IACrC,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE;QAC3B,KAAK,CAAC,0BAA0B,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QAC9C,OAAO;KACR;IACD,MAAM,KAAK,CAAC;AACd,CAAC;AAND,oCAMC","sourcesContent":["import Debug from \"debug\";\nimport fs from \"fs-extra\";\nimport type { Ignore } from \"ignore\";\nimport ignore from \"ignore\";\nimport path from \"path\";\n\nconst debug = Debug(\"ggt:fs-utils\");\n\nexport class Ignorer {\n readonly filepath = path.join(this._rootDir, \".ignore\");\n\n private _ignorer!: Ignore;\n\n constructor(private readonly _rootDir: string, private readonly _alwaysIgnore: string[]) {\n this.reload();\n }\n\n ignores(filepath: string): boolean {\n const relative = path.isAbsolute(filepath) ? path.relative(this._rootDir, filepath) : filepath;\n if (relative == \"\") return false;\n return this._ignorer.ignores(relative);\n }\n\n reload(): void {\n this._ignorer = ignore();\n this._ignorer.add(this._alwaysIgnore);\n\n try {\n this._ignorer.add(fs.readFileSync(this.filepath, \"utf-8\"));\n debug(\"reloaded ignore rules from %s\", this.filepath);\n } catch (error) {\n ignoreEnoent(error);\n }\n }\n}\n\nexport interface WalkDirOptions {\n ignorer?: Ignorer;\n maxFiles?: number;\n}\n\nexport async function* walkDir(dir: string, options: WalkDirOptions = {}): AsyncGenerator<string> {\n if (options.ignorer?.ignores(dir)) return;\n\n for await (const entry of await fs.opendir(dir)) {\n const filepath = path.join(dir, entry.name);\n if (entry.isDirectory()) {\n yield* walkDir(filepath, options);\n } else if (entry.isFile() && !options.ignorer?.ignores(filepath)) {\n yield filepath;\n }\n }\n}\n\nexport function* walkDirSync(dir: string, options: WalkDirOptions = {}): Generator<string> {\n if (options.ignorer?.ignores(dir)) return;\n\n for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {\n const filepath = path.join(dir, entry.name);\n if (entry.isDirectory()) {\n yield* walkDirSync(filepath, options);\n } else if (entry.isFile() && !options.ignorer?.ignores(filepath)) {\n yield filepath;\n }\n }\n}\n\nexport async function isEmptyDir(dir: string, opts = { ignoreEnoent: true }): Promise<boolean> {\n try {\n const files = await fs.readdir(dir);\n return files.length === 0;\n } catch (error) {\n if (opts.ignoreEnoent) {\n ignoreEnoent(error);\n return true;\n }\n throw error;\n }\n}\n\nexport function ignoreEnoent(error: any): void {\n if (error.code === \"ENOENT\") {\n debug(\"ignoring ENOENT error %s\", error.path);\n return;\n }\n throw error;\n}\n"]}
File without changes
File without changes
@@ -0,0 +1 @@
1
+ {"version":3,"file":"help.js","sourceRoot":"","sources":["../../src/utils/help.ts"],"names":[],"mappings":";;AAAA,sCAAiF;AAEjF,MAAqB,IAAK,SAAQ,WAAS;IAA3C;;QACE;;;;mBAA4B,WAAW;WAAC;IAC1C,CAAC;CAAA;AAFD,uBAEC;AAED,MAAM,WAAY,SAAQ,kBAAgB;IACxC;;;;;OAKG;IACgB,WAAW;QAC5B,IAAI,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE;YAC5B,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC;SACjC;QACD,OAAO,KAAK,CAAC,WAAW,EAAE,CAAC;IAC7B,CAAC;CACF","sourcesContent":["import { CommandHelp as OclifCommandHelp, Help as OclifHelp } from \"@oclif/core\";\n\nexport default class Help extends OclifHelp {\n override CommandHelpClass = CommandHelp;\n}\n\nclass CommandHelp extends OclifCommandHelp {\n /**\n * By default, oclif tries to format the description so that it fit's within the terminal window. However, if the description is already\n * formatted with `dedent`, then the description gets mangled and the help output is not pretty.\n *\n * This overrides the default behavior to just use the description as-is if it already exists.\n */\n protected override description(): string | undefined {\n if (this.command.description) {\n return this.command.description;\n }\n return super.description();\n }\n}\n"]}
File without changes
File without changes
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sleep.js","sourceRoot":"","sources":["../../src/utils/sleep.ts"],"names":[],"mappings":";;;AAAA,SAAgB,KAAK,CAAC,EAAE,GAAG,CAAC;IAC1B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;AAC/F,CAAC;AAFD,sBAEC;AAEM,KAAK,UAAU,UAAU,CAAC,EAAiB,EAAE,EAAE,QAAQ,GAAG,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE;IACjH,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;IAE9C,iDAAiD;IACjD,OAAO,IAAI,EAAE;QACX,IAAI,EAAE,EAAE;YAAE,OAAO;QACjB,MAAM,KAAK,CAAC,QAAQ,CAAC,CAAC;QAEtB,IAAI,KAAK,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,GAAG,OAAO,EAAE;YACzC,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,mBAAmB,OAAO,eAAe,CAAC,CAAC;YACnE,KAAK,CAAC,iBAAiB,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;YAC3C,MAAM,KAAK,CAAC;SACb;KACF;AACH,CAAC;AAdD,gCAcC","sourcesContent":["export function sleep(ms = 0): Promise<void> {\n return new Promise((resolve) => (ms == 0 ? setImmediate(resolve) : setTimeout(resolve, ms)));\n}\n\nexport async function sleepUntil(fn: () => boolean, { interval = 0, timeout = process.env[\"CI\"] ? 5000 : 500 } = {}): Promise<void> {\n const start = isFinite(timeout) && Date.now();\n\n // eslint-disable-next-line no-constant-condition\n while (true) {\n if (fn()) return;\n await sleep(interval);\n\n if (start && Date.now() - start > timeout) {\n const error = new Error(`Timed out after ${timeout} milliseconds`);\n Error.captureStackTrace(error, sleepUntil);\n throw error;\n }\n }\n}\n"]}