-
Notifications
You must be signed in to change notification settings - Fork 50
feat(sourcemaps): add SentryFacade and Sentry CLI Boilerplate #23
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
Merged
Changes from all commits
Commits
Show all changes
3 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
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,9 @@ | ||
| { | ||
| "release": "0.0.1", | ||
| "org": "some-org", | ||
| "project": "some-proj", | ||
| "authToken": "some-auth-token", | ||
| "include": "/dist", | ||
| "debugLogging": true, | ||
| "debug": true | ||
| } |
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
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,52 @@ | ||
| import SentryCli from "@sentry/cli"; | ||
| import { Options } from "./types"; | ||
|
|
||
| /** Creates a new Sentry CLI instance. */ | ||
| export function makeSentryCli(options: Options) { | ||
| //TODO: pass config file instead of null | ||
| const cli = new SentryCli(undefined, { | ||
| silent: false, //TODO read from options | ||
| org: options.org, | ||
| project: options.project, | ||
| authToken: options.authToken, | ||
| url: options.url, | ||
| vcsRemote: "origin", //TODO set from options, | ||
| }); | ||
|
|
||
| // Let's not worry about dry run for now | ||
| // if (this.isDryRun()) { | ||
| // this.outputDebug("DRY Run Mode"); | ||
|
|
||
| // return { | ||
| // releases: { | ||
| // proposeVersion: () => | ||
| // cli.releases.proposeVersion().then((version) => { | ||
| // this.outputDebug("Proposed version:\n", version); | ||
| // return version; | ||
| // }), | ||
| // new: (release) => { | ||
| // this.outputDebug("Creating new release:\n", release); | ||
| // return Promise.resolve(release); | ||
| // }, | ||
| // uploadSourceMaps: (release, config) => { | ||
| // this.outputDebug("Calling upload-sourcemaps with:\n", config); | ||
| // return Promise.resolve(release, config); | ||
| // }, | ||
| // finalize: (release) => { | ||
| // this.outputDebug("Finalizing release:\n", release); | ||
| // return Promise.resolve(release); | ||
| // }, | ||
| // setCommits: (release, config) => { | ||
| // this.outputDebug("Calling set-commits with:\n", config); | ||
| // return Promise.resolve(release, config); | ||
| // }, | ||
| // newDeploy: (release, config) => { | ||
| // this.outputDebug("Calling deploy with:\n", config); | ||
| // return Promise.resolve(release, config); | ||
| // }, | ||
| // }, | ||
| // }; | ||
| // } | ||
|
|
||
| return cli; | ||
| } |
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,68 @@ | ||
| /* eslint-disable @typescript-eslint/no-unused-vars */ | ||
| /* eslint-disable no-console */ | ||
| //TODO: remove eslint rules | ||
|
|
||
| // Build a facade that exposes necessary sentry functionality | ||
| // Idea: We start out with Sentry-CLI and replace the cli-commands one by one afterwards. | ||
| // Goal: eventually replace everything sentry-cli does with "native" code here | ||
| // Reason: We don't want to depend on a binary that gets downloaded in a postinstall hook | ||
| // - no fixed version | ||
| // - huge download | ||
| // - unnecessary functionality | ||
|
|
||
| import { makeSentryCli } from "./cli"; | ||
| import { Options } from "./types"; | ||
|
|
||
| export type SentryFacade = { | ||
| createNewRelease: () => any; | ||
| cleanArtifacts: () => any; | ||
| uploadSourceMaps: () => any; | ||
| setCommits: () => any; | ||
| finalizeRelease: () => any; | ||
| addDeploy: () => any; | ||
| }; | ||
|
|
||
| /** | ||
| * Factory function that provides all necessary Sentry functionality for creating | ||
| * a release on Sentry. This includes uploading source maps and finalizing the release | ||
| */ | ||
| export function makeSentryFacade(version: string, options: Options): SentryFacade { | ||
| makeSentryCli(options); | ||
| //TODO: remove | ||
| // void cli.execute(["--version"], true); | ||
|
|
||
| return { | ||
| createNewRelease: () => createNewRelease(version), | ||
| cleanArtifacts: () => cleanArtifacts(), | ||
| uploadSourceMaps: () => uploadSourceMaps(version), | ||
| setCommits: () => setCommits(version), | ||
| finalizeRelease: () => finalizeRelease(version), | ||
| addDeploy: () => addDeploy(version), | ||
| }; | ||
| } | ||
|
|
||
| function createNewRelease(version: string) { | ||
| //TODO(must have): implement release creation logic here | ||
| } | ||
|
|
||
| function uploadSourceMaps(version: string) { | ||
| //TODO(must have): implement source maps upload logic here | ||
| } | ||
|
|
||
| function finalizeRelease(version: string) { | ||
| //TODO(must have): implement release finalization logic here | ||
| } | ||
|
|
||
| // TODO: Stuff we worry about later: | ||
|
|
||
| function cleanArtifacts() { | ||
| // NOOP for now | ||
| } | ||
|
|
||
| function setCommits(version: string) { | ||
| // NOOP for now | ||
| } | ||
|
|
||
| function addDeploy(version: string) { | ||
| // NOOP for now | ||
| } |
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,63 @@ | ||
| //TODO: JsDoc for all properties | ||
| export type Options = { | ||
| debugLogging?: boolean; | ||
|
|
||
| /* --- authentication/identification: */ | ||
| org?: string; | ||
| project?: string; | ||
| authToken?: string; | ||
| url?: string; | ||
| // configFile: string | ||
|
|
||
| /* --- release properties: */ | ||
| release?: string; | ||
| // dist: string, | ||
| // entries: string[] | RegExp | ((key: string) => boolean); | ||
|
|
||
| /* --- source maps properties: */ | ||
| //TODO: make this required | ||
| include?: string; //| string[] | IncludeEntry[]; | ||
| // ignoreFile: string | ||
| // ignore: string | string[] | ||
| // ext: string[] | ||
| // urlPrefix: string, | ||
| // urlSuffix: string, | ||
| // validate: boolean | ||
| // stripPrefix?: boolean, | ||
| // stripCommonPrefix?: boolean, | ||
| // sourceMapReference?: boolean, | ||
| // rewrite?: boolean, | ||
|
|
||
| /* --- other unimportant (for now) stuff- properties: */ | ||
| // vcsRemote: string, | ||
| // customHeader: string, | ||
|
|
||
| // finalize?: boolean, | ||
| // dryRun?: boolean, | ||
| debug?: boolean; | ||
| // silent?: boolean, | ||
| // cleanArtifacts?: boolean, | ||
| // errorHandler?: (err: Error, invokeErr: function(): void, compilation: unknown) => void, | ||
| // setCommits?: { | ||
| // repo?: string, | ||
| // commit?: string, | ||
| // previousCommit?: string, | ||
| // auto?: boolean, | ||
| // ignoreMissing?: boolean | ||
| // }, | ||
| // deploy?: { | ||
| // env: string, | ||
| // started?: number, | ||
| // finished?: number, | ||
| // time?: number, | ||
| // name?: string, | ||
| // url?: string, | ||
| // } | ||
| }; | ||
|
|
||
| /* | ||
| type IncludeEntry = { | ||
| paths: string[]; | ||
| //TODO: what about the other entries?? | ||
| }; | ||
| */ |
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.
Uh oh!
There was an error while loading. Please reload this page.