index.d.ts 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. /**
  2. * Typings for @sentry/cli
  3. */
  4. declare module '@sentry/cli' {
  5. export interface SentryCliOptions {
  6. /**
  7. * The URL of the Sentry instance you are connecting to. Defaults to https://sentry.io/.
  8. * This value will update `SENTRY_URL env variable.
  9. */
  10. url?: string;
  11. /**
  12. * Authentication token for API, interchangeable with `apiKey`.
  13. * This value will update `SENTRY_AUTH_TOKEN` env variable.
  14. */
  15. authToken?: string;
  16. /**
  17. * Authentication token for API, interchangeable with `authToken`.
  18. * This value will update `SENTRY_API_KEY` env variable.
  19. */
  20. apiKey?: string;
  21. /**
  22. * Sentry DSN.
  23. * This value will update `SENTRY_DSN` env variable.
  24. */
  25. dsn?: string;
  26. /**
  27. * Organization slug.
  28. * This value will update `SENTRY_ORG` env variable.
  29. */
  30. org?: string;
  31. /**
  32. * Project Project slug.
  33. * This value will update `SENTRY_PROJECT` env variable.
  34. */
  35. project?: string;
  36. /**
  37. * Version control system remote name.
  38. * This value will update `SENTRY_VCS_REMOTE` env variable.
  39. */
  40. vcsRemote?: string;
  41. /**
  42. * Unique identifier for the distribution, used to further segment your release.
  43. * Usually your build number.
  44. */
  45. dist?: string;
  46. /**
  47. * If true, all logs are suppressed.
  48. */
  49. silent?: boolean;
  50. /**
  51. * A header added to every outgoing network request.
  52. * This value will update `CUSTOM_HEADER` env variable.
  53. */
  54. customHeader?: string;
  55. }
  56. /**
  57. * Custom upload-sourcemaps options for a particular `include` path. In this
  58. * case `paths` takes the place of `include` in the options so as to make it
  59. * clear that this is not recursive.
  60. */
  61. export type SourceMapsPathDescriptor = Omit<SentryCliUploadSourceMapsOptions, 'include'> & { paths: string[] }
  62. export interface SentryCliUploadSourceMapsOptions {
  63. /**
  64. * One or more paths that Sentry CLI should scan recursively for sources.
  65. * It will upload all .map files and match associated .js files.
  66. */
  67. include: Array<string | SourceMapsPathDescriptor>;
  68. /**
  69. * One or more paths to ignore during upload. Overrides entries in ignoreFile file.
  70. */
  71. ignore?: string[];
  72. /**
  73. * Path to a file containing list of files/directories to ignore.
  74. * Can point to .gitignore or anything with same format.
  75. */
  76. ignoreFile?: string | null;
  77. /**
  78. * Enables rewriting of matching sourcemaps so that indexed maps are flattened
  79. * and missing sources are inlined if possible. Defaults to `true`.
  80. */
  81. rewrite?: boolean;
  82. /**
  83. * This prevents the automatic detection of sourcemap references.
  84. */
  85. sourceMapReference?: boolean;
  86. /**
  87. * When paired with the rewrite option this will remove a prefix from uploaded files.
  88. * For instance you can use this to remove a path that is build machine specific.
  89. */
  90. stripPrefix?: string[];
  91. /**
  92. * When paired with the rewrite option this will add ~ to the stripPrefix array.
  93. */
  94. stripCommonPrefix?: boolean;
  95. /**
  96. * This attempts sourcemap validation before upload when rewriting is not enabled.
  97. * It will spot a variety of issues with source maps and cancel the upload if any are found.
  98. * This is not enabled by default as this can cause false positives.
  99. */
  100. validate?: boolean;
  101. /**
  102. * This sets an URL prefix at the beginning of all files.
  103. * This defaults to `~/` but you might want to set this to the full URL.
  104. * This is also useful if your files are stored in a sub folder. eg: url-prefix `~/static/js`.
  105. */
  106. urlPrefix?: string;
  107. /**
  108. * This sets an URL suffix at the end of all files.
  109. * Useful for appending query parameters.
  110. */
  111. urlSuffix?: string;
  112. /**
  113. * This sets the file extensions to be considered.
  114. * By default the following file extensions are processed: js, map, jsbundle and bundle.
  115. */
  116. ext?: string[];
  117. }
  118. export interface SentryCliNewDeployOptions {
  119. /**
  120. * Environment for this release. Values that make sense here would be `production` or `staging`.
  121. */
  122. env: string;
  123. /**
  124. * Deployment start time in Unix timestamp (in seconds) or ISO 8601 format.
  125. */
  126. started?: number | string;
  127. /**
  128. * Deployment finish time in Unix timestamp (in seconds) or ISO 8601 format.
  129. */
  130. finished?: number | string;
  131. /**
  132. * Deployment duration (in seconds). Can be used instead of started and finished.
  133. */
  134. time?: number;
  135. /**
  136. * Human readable name for the deployment.
  137. */
  138. name?: string;
  139. /**
  140. * URL that points to the deployment.
  141. */
  142. url?: string;
  143. }
  144. export interface SentryCliCommitsOptions {
  145. /**
  146. * Automatically choose the associated commit (uses the current commit). Overrides other setCommit options.
  147. */
  148. auto?: boolean;
  149. /**
  150. * The full repo name as defined in Sentry. Required if auto option is not true.
  151. */
  152. repo?: string;
  153. /**
  154. * The current (last) commit in the release. Required if auto option is not true.
  155. */
  156. commit?: string;
  157. /**
  158. * The commit before the beginning of this release (in other words, the last commit of the previous release).
  159. * If omitted, this will default to the last commit of the previous release in Sentry.
  160. * If there was no previous release, the last 10 commits will be used.
  161. */
  162. previousCommit?: string;
  163. /**
  164. * When the flag is set and the previous release commit was not found in the repository, will create a release
  165. * with the default commits count(or the one specified with `--initial-depth`) instead of failing the command.
  166. */
  167. ignoreMissing?: boolean;
  168. /**
  169. * When the flag is set, command will not fail and just exit silently if no new commits for a given release have been found.
  170. */
  171. ignoreEmpty?: boolean;
  172. }
  173. export interface SentryCliReleases {
  174. ['new'](
  175. release: string,
  176. options?: { projects: string[] } | string[]
  177. ): Promise<string>;
  178. setCommits(
  179. release: string,
  180. options: SentryCliCommitsOptions
  181. ): Promise<string>;
  182. finalize(release: string): Promise<string>
  183. proposeVersion(): Promise<string>
  184. uploadSourceMaps(
  185. release: string,
  186. options: SentryCliUploadSourceMapsOptions
  187. ): Promise<string>
  188. listDeploys(release: string): Promise<string>;
  189. newDeploy(
  190. release: string,
  191. options: SentryCliNewDeployOptions
  192. ): Promise<string>
  193. execute(args: string[], live: boolean): Promise<string>;
  194. }
  195. export default class SentryCli {
  196. /**
  197. * Creates a new instance of SentryCli class
  198. *
  199. * @param configFile Path to Sentry CLI config properties, as described in https://docs.sentry.io/learn/cli/configuration/#properties-files.
  200. * By default, the config file is looked for upwards from the current path and defaults from ~/.sentryclirc are always loaded.
  201. * This value will update `SENTRY_PROPERTIES` env variable.
  202. * @param options {@link SentryCliOptions}
  203. */
  204. constructor(configFile?: string | null, options?: SentryCliOptions)
  205. public configFile?: string;
  206. public options?: SentryCliOptions;
  207. public releases: SentryCliReleases
  208. public static getVersion(): string
  209. public static getPath(): string
  210. /**
  211. * Downloads the CLI binary.
  212. * @returns {Promise<void>}
  213. */
  214. static downloadBinary(logger: { log(...args: unknown[]): void }): Promise<void>;
  215. public execute(args: string[], live: boolean): Promise<string>
  216. }
  217. }