UNPKG

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