@@ -64,24 +64,53 @@ commander
64
64
. option ( '--cloudfront' , 'CloudFront Distribution ID to invalidate.' )
65
65
. option ( '--s3bucket' , 'S3 Bucket to push to.' )
66
66
. action ( function ( entries , options ) {
67
+ const commit = require ( 'this-commit' ) ( )
68
+ const username = require ( 'username' )
69
+ const createLogger = require ( '../lib/logger' )
70
+ const pkg = require ( '../lib/pkg' )
67
71
const pushToS3 = require ( '../lib/push-to-s3' )
72
+
73
+ const url = pkg . repository . url . replace ( '.git' , '' )
74
+ const tag = `<${ url } /commit/${ commit } |${ pkg . name } @${ commit . slice ( 0 , 6 ) } >:`
75
+ const user = username . sync ( )
68
76
const config = loadConfig ( process . cwd ( ) , commander . config , commander . env )
69
77
const get = util . makeGetFn ( [ options , commander , config . settings ] )
78
+
79
+ const env = get ( 'env' )
80
+ const s3bucket = get ( 's3bucket' )
81
+
70
82
const files = util . parseEntries ( [ ...entries , ...( get ( 'entries' ) || [ ] ) ] )
71
83
util . assertEntriesExist ( files )
72
- Promise . all ( files . map ( pushToS3 ( {
73
- cloudfront : get ( 'cloudfront' ) ,
84
+
85
+ const log = createLogger ( { channel : config . env . SLACK_CHANNEL || '#devops' , webhook : config . env . SLACK_WEBHOOK } )
86
+ const minify = get ( 'minify' )
87
+ const cloudfront = get ( 'cloudfront' )
88
+ const push = pushToS3 ( {
89
+ cloudfront,
74
90
config,
75
- env : get ( 'env' ) ,
76
- minify : get ( 'minify' ) ,
77
- s3bucket : get ( 's3bucket' )
78
- } ) ) ) . then ( ( ) => {
79
- console . log ( 'Finished deploying!' )
80
- process . exit ( 0 )
81
- } ) . catch ( ( err ) => {
82
- console . error ( 'Error while deploying!' )
83
- console . error ( err . stack )
84
- process . exit ( 1 )
91
+ env,
92
+ log,
93
+ minify,
94
+ s3bucket,
95
+ tag
96
+ } )
97
+
98
+ log (
99
+ `:construction: *${ tag } deploy started by <@${ user } >*
100
+ :cloud: *cloudfront:* ${ cloudfront }
101
+ :hash: *commit:* ${ commit }
102
+ :seedling: *env:* ${ env }
103
+ :compression: *minify:* ${ minify }
104
+ :package: *s3bucket:* ${ s3bucket } `
105
+ ) . then ( ( ) => {
106
+ Promise
107
+ . all ( files . map ( push ) )
108
+ . then ( ( ) =>
109
+ log ( `:rocket: ${ tag } deploy finished!! :tada: :confetti_ball: :tada:` )
110
+ . then ( ( ) => process . exit ( 0 ) ) )
111
+ . catch ( ( err ) =>
112
+ log ( `:rotating_light: *error deploying ${ tag } ${ err . message || err } *` )
113
+ . then ( ( ) => process . exit ( 1 ) ) )
85
114
} )
86
115
} )
87
116
@@ -90,15 +119,24 @@ commander
90
119
. allowUnknownOption ( )
91
120
. description ( 'Lint JavaScript [& CSS coming soon!]' )
92
121
. action ( function ( ) {
122
+ const eslint = require ( 'eslint' )
93
123
const engine = require ( 'standard-engine' )
94
- const standardOptions = require ( 'standard/options' )
95
124
// get lint out of there
96
125
process . argv = process . argv . filter ( ( arg ) => arg !== 'lint' )
97
126
// Force verbose
98
127
process . argv . push ( '--verbose' )
99
- // add babel-eslint parser
100
- standardOptions . parser = 'babel-eslint'
101
- engine . cli ( standardOptions )
128
+
129
+ engine . cli ( {
130
+ bugs : 'github.com/conveyal/mastarm/issues' ,
131
+ cmd : 'mastarm lint' ,
132
+ eslint,
133
+ eslintConfig : {
134
+ configFile : path . join ( __dirname , '../lib/eslintrc.json' )
135
+ } ,
136
+ homepage : 'github.com/conveyal/mastarm' ,
137
+ tagline : 'never forget to floss...or lint!' ,
138
+ version : require ( '../package.json' ) . version
139
+ } )
102
140
} )
103
141
104
142
commander
0 commit comments