66const path = require ( 'path' ) ;
77const { execSync } = require ( 'child_process' ) ;
88const BasePlugin = require ( 'ember-cli-deploy-plugin' ) ;
9+ const packageJson = require ( "./package.json" ) ;
910
1011module . exports = {
11- name : require ( './package' ) . name ,
12+ name : packageJson . name ,
1213
1314 createDeployPlugin ( options ) {
1415 const DeployPlugin = BasePlugin . extend ( {
1516 name : options . name ,
1617
1718 defaultConfig : {
1819 assetsDir ( context ) {
19- return path . join ( context . distDir , ' assets' ) ;
20+ return path . join ( context . distDir , " assets" ) ;
2021 } ,
2122
2223 revisionKey ( context ) {
@@ -27,70 +28,83 @@ module.exports = {
2728 return context . deployTarget ;
2829 } ,
2930
30- url : '' ,
31+ url : "" ,
3132 } ,
3233
33- requiredConfig : [ ' appName' , ' orgName' , ' authToken' ] ,
34+ requiredConfig : [ " appName" , " orgName" , " authToken" ] ,
3435
3536 didPrepare ( ) {
36- const releaseName = `${ this . readConfig ( 'appName' ) } @${ this . readConfig ( 'revisionKey' ) } ` ;
37- const assetsDir = this . readConfig ( 'assetsDir' ) ;
38- const urlPrefix = this . readConfig ( 'urlPrefix' ) ? `--url-prefix ${ this . readConfig ( 'urlPrefix' ) } ` : '' ;
39-
40- this . log ( 'SENTRY: Creating release...' ) ;
41- this . sentryCliExec ( 'releases' , `new ${ releaseName } ` ) ;
42-
43- this . log ( 'SENTRY: Assigning commits...' ) ;
44- this . sentryCliExec ( 'releases' , `set-commits ${ releaseName } --auto --ignore-missing` ) ;
37+ const releaseName = `${ this . readConfig ( "appName" ) } @${ this . readConfig (
38+ "revisionKey"
39+ ) } `;
40+ const assetsDir = this . readConfig ( "assetsDir" ) ;
41+ const urlPrefix = this . readConfig ( "urlPrefix" )
42+ ? `--url-prefix ${ this . readConfig ( "urlPrefix" ) } `
43+ : "" ;
44+
45+ this . log ( "SENTRY: Creating release..." ) ;
46+ this . sentryCliExec ( "releases" , `new ${ releaseName } ` ) ;
47+
48+ this . log ( "SENTRY: Assigning commits..." ) ;
49+ this . sentryCliExec (
50+ "releases" ,
51+ `set-commits ${ releaseName } --auto --ignore-missing`
52+ ) ;
4553
46- this . log ( 'SENTRY: Uploading source maps...' ) ;
47- this . sentryCliExec ( 'releases' , `files ${ releaseName } upload-sourcemaps --rewrite ${ assetsDir } ${ urlPrefix } ` ) ;
54+ this . log ( "SENTRY: Uploading source maps..." ) ;
55+ this . sentryCliExec (
56+ "releases" ,
57+ `files ${ releaseName } upload-sourcemaps --rewrite ${ assetsDir } ${ urlPrefix } `
58+ ) ;
4859
49- this . log ( ' SENTRY: Finalizing release...' ) ;
50- this . sentryCliExec ( ' releases' , `finalize ${ releaseName } ` ) ;
60+ this . log ( " SENTRY: Finalizing release..." ) ;
61+ this . sentryCliExec ( " releases" , `finalize ${ releaseName } ` ) ;
5162
52- this . log ( ' SENTRY: Release published!...' ) ;
63+ this . log ( " SENTRY: Release published!..." ) ;
5364 } ,
5465
5566 didDeploy ( ) {
56- const appName = this . readConfig ( 'appName' ) ;
57- const releaseName = `${ appName } @${ this . readConfig ( 'revisionKey' ) } ` ;
58- const environment = this . readConfig ( 'environment' ) ;
59-
60- this . log ( 'SENTRY: Deploying release...' ) ;
61- this . sentryCliExec ( 'releases' , `deploys ${ releaseName } new -e ${ environment } ` ) ;
62- this . log ( 'SENTRY: Deployed!' ) ;
67+ const appName = this . readConfig ( "appName" ) ;
68+ const releaseName = `${ appName } @${ this . readConfig ( "revisionKey" ) } ` ;
69+ const environment = this . readConfig ( "environment" ) ;
70+
71+ this . log ( "SENTRY: Deploying release..." ) ;
72+ this . sentryCliExec (
73+ "releases" ,
74+ `deploys ${ releaseName } new -e ${ environment } `
75+ ) ;
76+ this . log ( "SENTRY: Deployed!" ) ;
6377 } ,
6478
6579 didFail ( ) {
66- const appName = this . readConfig ( ' appName' ) ;
67- const releaseName = `${ appName } @${ this . readConfig ( ' revisionKey' ) } ` ;
80+ const appName = this . readConfig ( " appName" ) ;
81+ const releaseName = `${ appName } @${ this . readConfig ( " revisionKey" ) } ` ;
6882
69- this . log ( ' SENTRY: Deleting release...' ) ;
70- this . sentryCliExec ( ' releases' , `delete ${ releaseName } ` ) ;
71- this . log ( ' SENTRY: Release deleted!' ) ;
83+ this . log ( " SENTRY: Deleting release..." ) ;
84+ this . sentryCliExec ( " releases" , `delete ${ releaseName } ` ) ;
85+ this . log ( " SENTRY: Release deleted!" ) ;
7286 } ,
7387
7488 sentryCliExec ( command , subCommand ) {
75- const authToken = this . readConfig ( ' authToken' ) ;
76- const orgName = this . readConfig ( ' orgName' ) ;
77- const appName = this . readConfig ( ' appName' ) ;
78- const url = this . readConfig ( ' url' ) ;
89+ const authToken = this . readConfig ( " authToken" ) ;
90+ const orgName = this . readConfig ( " orgName" ) ;
91+ const appName = this . readConfig ( " appName" ) ;
92+ const url = this . readConfig ( " url" ) ;
7993
8094 return this . _exec (
8195 [
82- path . join ( ' node_modules' , ' .bin' , ' sentry-cli' ) ,
83- url ? `--url ${ url } ` : '' ,
96+ path . join ( " node_modules" , " .bin" , " sentry-cli" ) ,
97+ url ? `--url ${ url } ` : "" ,
8498 `--auth-token ${ authToken } ` ,
8599 command ,
86100 `--org ${ orgName } ` ,
87101 `--project ${ appName } ` ,
88102 subCommand ,
89- ] . join ( ' ' )
103+ ] . join ( " " )
90104 ) ;
91105 } ,
92106
93- _exec ( command = '' ) {
107+ _exec ( command = "" ) {
94108 return execSync ( command , { cwd : this . project . root } ) ;
95109 } ,
96110 } ) ;
0 commit comments