index.d.ts 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. import { Compiler, WebpackPluginInstance } from 'webpack';
  2. import {
  3. SentryCliCommitsOptions,
  4. SentryCliNewDeployOptions,
  5. SentryCliOptions,
  6. SentryCliUploadSourceMapsOptions,
  7. SourceMapsPathDescriptor,
  8. } from '@sentry/cli';
  9. declare namespace SentryCliPlugin {
  10. export interface SentryCliPluginOptions
  11. extends Pick<
  12. SentryCliOptions,
  13. | 'url'
  14. | 'authToken'
  15. | 'org'
  16. | 'project'
  17. | 'vcsRemote'
  18. | 'dist'
  19. | 'silent'
  20. | 'customHeader'
  21. >,
  22. Pick<
  23. SentryCliUploadSourceMapsOptions,
  24. | 'ignoreFile'
  25. | 'rewrite'
  26. | 'sourceMapReference'
  27. | 'stripPrefix'
  28. | 'stripCommonPrefix'
  29. | 'validate'
  30. | 'urlPrefix'
  31. | 'urlSuffix'
  32. | 'ext'
  33. > {
  34. /**
  35. * Filepaths to scan recursively for source and source map files
  36. */
  37. include:
  38. | string
  39. | SourceMapsPathDescriptor
  40. | Array<string | SourceMapsPathDescriptor>;
  41. /**
  42. * Filepaths to ignore when scanning for sources and source maps
  43. */
  44. ignore?: string | Array<string>;
  45. /**
  46. * Unique name of a release, must be a string, should uniquely identify your release,
  47. * defaults to sentry-cli releases propose-version command which should always return the correct version
  48. * (requires access to git CLI and root directory to be a valid repository).
  49. */
  50. release?: string;
  51. /**
  52. * A filter for entry points that should be processed.
  53. * By default, the release will be injected into all entry points.
  54. */
  55. entries?: string[] | RegExp | ((key: string) => boolean);
  56. /**
  57. * Path to Sentry CLI config properties, as described in https://docs.sentry.io/learn/cli/configuration/#properties-files.
  58. * By default, the config file is looked for upwards from the current path and defaults from ~/.sentryclirc are always loaded.
  59. */
  60. configFile?: string;
  61. /**
  62. * Determines whether processed release should be automatically finalized after artifacts upload.
  63. * Defaults to `true`.
  64. */
  65. finalize?: boolean;
  66. /**
  67. * Determines whether plugin should be applied not more than once during whole webpack run.
  68. * Useful when the process is performing multiple builds using the same config.
  69. * Defaults to `false`.
  70. */
  71. runOnce?: boolean;
  72. /**
  73. * Attempts a dry run (useful for dev environments).
  74. */
  75. dryRun?: boolean;
  76. /**
  77. * Print some useful debug information.
  78. */
  79. debug?: boolean;
  80. /**
  81. * If true, will remove all previously uploaded artifacts from the configured release.
  82. */
  83. cleanArtifacts?: boolean;
  84. /**
  85. * When a CLI error occurs, the plugin will call this function.
  86. *
  87. * By default, it will call `invokeErr()`, thereby stopping Webpack
  88. * compilation. To allow compilation to continue and log a warning instead,
  89. * set this to
  90. * (err, invokeErr, compilation) => {
  91. * compilation.warnings.push('Sentry CLI Plugin: ' + err.message)
  92. * }
  93. *
  94. * Note: `compilation` is typed as `unknown` in order to preserve
  95. * compatibility with both Webpack 4 and Webpack 5 types, If you need the
  96. * correct type, in Webpack 4 use `compilation.Compilation` and in Webpack 5
  97. * use `Compilation`.
  98. */
  99. errorHandler?: (
  100. err: Error,
  101. invokeErr: () => void,
  102. compilation: unknown
  103. ) => void;
  104. /**
  105. * Adds commits to sentry
  106. */
  107. setCommits?: SentryCliCommitsOptions;
  108. /**
  109. * Creates a new release deployment
  110. */
  111. deploy?: SentryCliNewDeployOptions;
  112. }
  113. export { SourceMapsPathDescriptor };
  114. }
  115. declare class SentryCliPlugin implements WebpackPluginInstance {
  116. options: SentryCliPlugin.SentryCliPluginOptions;
  117. constructor(options: SentryCliPlugin.SentryCliPluginOptions);
  118. static cliBinaryExists(): boolean;
  119. static downloadCliBinary(logger: { log(...args: unknown[]) }): Promise<void>;
  120. apply(compiler: Compiler): void;
  121. }
  122. // We need to use this older format (over `export default SentryCliPlugin`)
  123. // because we don't want people using the plugin in their TS projects to be
  124. // forced to set `esmoduleinterop` to `true`, which the newer syntax requires.
  125. // See
  126. // https://github.com/microsoft/TypeScript-Website/blob/6a36b3137182084c76cdf133c812fe3a5626dbf0/packages/documentation/copy/en/declaration-files/templates/module.d.ts.md#L95-L106
  127. // (linking to the docs in their raw form on GH rather than on the TS docs site
  128. // in case the docs site ever moves things around).
  129. //
  130. // Note that with this older format, no other top-level exports can exist, which
  131. // is why the exported interface above is wrapped in a namespace. See the
  132. // example in the above link and
  133. // https://github.com/microsoft/TypeScript-Website/blob/6a36b3137182084c76cdf133c812fe3a5626dbf0/packages/documentation/copy/en/declaration-files/templates/module.d.ts.md#L195-L214.
  134. export = SentryCliPlugin;