@@ -13,6 +13,12 @@ var fs = require('fs');
1313module . exports = {
1414 name : 'ember-cli-deploy-sentry' ,
1515
16+ contentFor : function ( type , config ) {
17+ if ( type === 'head-footer' ) {
18+ return '<meta name="sentry:revision"></meta>' ;
19+ }
20+ } ,
21+
1622 createDeployPlugin : function ( options ) {
1723 var DeployPlugin = DeployPluginBase . extend ( {
1824 name : options . name ,
@@ -46,9 +52,19 @@ module.exports = {
4652 this . log ( 'config ok' ) ;
4753 } ,
4854
55+ willUpload : function ( context ) {
56+ var revisionKey = context . revisionKey ;
57+ var indexPath = path . join ( context . distDir , "index.html" ) ;
58+ var index = fs . readFileSync ( indexPath , 'utf8' ) ;
59+ var index = index . replace ( '<meta name="sentry:revision">' ,
60+ '<meta name="sentry:revision" content="' + revisionKey + '">' ) ;
61+
62+ fs . writeFileSync ( indexPath , index ) ;
63+ } ,
64+
4965 _createRelease : function createRelease ( sentrySettings ) {
5066 var url = urljoin ( sentrySettings . url , '/api/0/projects/' , sentrySettings . organizationSlug , sentrySettings . projectSlug , '/releases/' ) ;
51-
67+
5268 return request ( {
5369 uri : url ,
5470 method : 'POST' ,
@@ -64,7 +80,7 @@ module.exports = {
6480 } ,
6581 _deleteRelease : function createRelease ( sentrySettings ) {
6682 var url = urljoin ( sentrySettings . url , '/api/0/projects/' , sentrySettings . organizationSlug , sentrySettings . projectSlug , '/releases/' , sentrySettings . release ) + '/' ;
67-
83+
6884 return request ( {
6985 uri : url ,
7086 method : 'DELETE' ,
@@ -78,7 +94,7 @@ module.exports = {
7894 resolveWithFullResponse : true
7995 } ) ;
8096 } ,
81-
97+
8298 _getUploadFiles : function getUploadFiles ( dir , filePattern ) {
8399 var pattern = path . join ( dir , filePattern ) ;
84100 return new Promise ( function ( resolve , reject ) {
@@ -94,17 +110,17 @@ module.exports = {
94110 return files . map ( function ( file ) {
95111 return path . relative ( dir , file ) ;
96112 } ) ;
97- } ) ;
113+ } ) ;
98114 } ,
99-
115+
100116 _uploadFile : function uploadFile ( sentrySettings , distDir , filePath ) {
101117 var url = urljoin ( sentrySettings . url , '/api/0/projects/' , sentrySettings . organizationSlug , sentrySettings . projectSlug , '/releases/' , sentrySettings . release , '/files/' ) ;
102-
118+
103119 var formData = {
104120 name : urljoin ( sentrySettings . publicUrl , filePath ) ,
105121 file : fs . createReadStream ( path . join ( distDir , filePath ) )
106122 } ;
107-
123+
108124 return request ( {
109125 method : 'POST' ,
110126 uri : url ,
@@ -114,7 +130,7 @@ module.exports = {
114130 formData : formData
115131 } ) ;
116132 } ,
117-
133+
118134 _getReleaseFiles : function getReleaseFiles ( sentrySettings ) {
119135 var url = urljoin ( sentrySettings . url , '/api/0/projects/' , sentrySettings . organizationSlug , sentrySettings . projectSlug , '/releases/' , sentrySettings . release , '/files' ) + '/' ;
120136 return request ( {
@@ -141,15 +157,15 @@ module.exports = {
141157 release : plugin . readConfig ( 'revisionKey' )
142158 } ;
143159 var filePattern = this . readConfig ( 'filePattern' ) ;
144-
160+
145161 if ( ! sentrySettings . release ) {
146162 throw new SilentError ( 'revisionKey setting is not available, either provide it manually or make sure the ember-cli-deploy-revision-data plugin is loaded' ) ;
147163 }
148164 return this . _deleteRelease ( sentrySettings ) . then ( function ( ) { } , function ( ) { } ) . then ( function ( ) {
149165 return plugin . _createRelease ( sentrySettings ) . then ( function ( response ) {
150166 return plugin . _getUploadFiles ( distDir , filePattern ) . then ( function ( files ) {
151167 var uploads = [ ] ;
152- for ( var i = 0 ; i < files . length ; i ++ ) {
168+ for ( var i = 0 ; i < files . length ; i ++ ) {
153169 var file = files [ i ] ;
154170 uploads . push ( plugin . _uploadFile ( sentrySettings , distDir , files [ i ] ) ) ;
155171 }
0 commit comments