-
Notifications
You must be signed in to change notification settings - Fork 50
ref(core): Add Sentry CLI #86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| import SentryCli, { SentryCliReleases } from "@sentry/cli"; | ||
| import { InternalOptions } from "../options-mapping"; | ||
| import { Logger } from "./logger"; | ||
|
|
||
| type SentryDryRunCLI = { releases: Omit<SentryCliReleases, "listDeploys" | "execute"> }; | ||
| type SentryCLILike = SentryCli | SentryDryRunCLI; | ||
|
|
||
| /** | ||
| * Creates a new Sentry CLI instance. | ||
| * | ||
| * In case, users selected the `dryRun` options, this returns a stub | ||
| * that makes no-ops out of most CLI operations | ||
| */ | ||
| export function getSentryCli(internalOptions: InternalOptions, logger: Logger): SentryCLILike { | ||
| const cli = new SentryCli(internalOptions.configFile, { | ||
| silent: internalOptions.silent, | ||
| org: internalOptions.org, | ||
| project: internalOptions.project, | ||
| authToken: internalOptions.authToken, | ||
| url: internalOptions.url, | ||
| vcsRemote: internalOptions.vcsRemote, | ||
| }); | ||
|
|
||
| if (internalOptions.dryRun) { | ||
Lms24 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return getDryRunCLI(cli, logger); | ||
| } | ||
|
|
||
| return cli; | ||
| } | ||
|
|
||
| function getDryRunCLI(cli: SentryCli, logger: Logger): SentryDryRunCLI { | ||
| return { | ||
| releases: { | ||
| proposeVersion: () => | ||
| cli.releases.proposeVersion().then((version) => { | ||
| logger.info("Proposed version:\n", version); | ||
| return version; | ||
| }), | ||
| new: (release: string) => { | ||
| logger.info("Creating new release:\n", release); | ||
| return Promise.resolve(release); | ||
| }, | ||
| uploadSourceMaps: (release: string, config: unknown) => { | ||
| logger.info("Calling upload-sourcemaps with:\n", config); | ||
| return Promise.resolve(release); | ||
| }, | ||
| finalize: (release: string) => { | ||
| logger.info("Finalizing release:\n", release); | ||
| return Promise.resolve(release); | ||
| }, | ||
| setCommits: (release: string, config: unknown) => { | ||
| logger.info("Calling set-commits with:\n", config); | ||
| return Promise.resolve(release); | ||
| }, | ||
| newDeploy: (release: string, config: unknown) => { | ||
| logger.info("Calling deploy with:\n", config); | ||
| return Promise.resolve(release); | ||
| }, | ||
| }, | ||
| }; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import SentryCli from "@sentry/cli"; | ||
| import { getSentryCli } from "../src/sentry/cli"; | ||
|
|
||
| describe("getSentryCLI", () => { | ||
| it("returns a valid CLI instance if dryRun is not specified", () => { | ||
| // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-explicit-any | ||
| const cli = getSentryCli({} as any, {} as any); | ||
| expect(cli).toBeInstanceOf(SentryCli); | ||
| }); | ||
|
|
||
| it("returns a valid CLI instance if dryRun is set to true", () => { | ||
| // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-explicit-any | ||
| const cli = getSentryCli({ dryRun: true } as any, {} as any); | ||
| expect(cli).not.toBeInstanceOf(SentryCli); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, we'll still have to go with v1 as long as we don't drop Node 8 and 10 support