@@ -4,10 +4,14 @@ import ora from 'ora';
44import { bash , renameDockerImage } from '../script/utils' ;
55import { CLIError } from '../script/cli' ;
66import logger from '../script/logger' ;
7+ import { initDefault } from '../config' ;
8+ import pushDocker from '../push-docker' ;
9+
10+ const { Select} = require ( 'enquirer' ) ;
711
812interface IArgs {
9- publicUrl : string
10- dockerfile : string
13+ publicUrl ? : string
14+ dockerfile ? : string
1115}
1216
1317
@@ -73,12 +77,12 @@ function buildDockerImage(imageName: string, version: string, remoteAddress: str
7377
7478
7579
76- async function run ( args : IArgs ) {
77- const imageName = process . env . npm_package_name ?? 'bear-example' ;
78- const imageVersion = process . env . npm_package_version ?? '0.0.0' ;
79- const remoteAddress = process . env . npm_package_dockerRegistry ?? 'docker.bearests.com:8443' ;
80- const publicUrl = typeof args . publicUrl !== 'undefined' ? args . publicUrl : '' ;
81- const dockerfile = typeof args . dockerfile !== 'undefined' ? args . dockerfile : './' ;
80+ async function run ( args ? : IArgs ) {
81+ const imageName = process . env . npm_package_name ?? initDefault . packageName ;
82+ const imageVersion = process . env . npm_package_version ?? initDefault . packageVersion ;
83+ const remoteAddress = process . env . npm_package_dockerRegistry ?? initDefault . dockerRegistry ;
84+ const publicUrl = typeof args ? .publicUrl !== 'undefined' ? args . publicUrl : initDefault . publicUrl ;
85+ const dockerfile = typeof args ? .dockerfile !== 'undefined' ? args . dockerfile : initDefault . dockerfilePath ;
8286
8387 console . log ( `ready release ${ imageName } :${ imageVersion } ...` ) ;
8488
@@ -87,6 +91,19 @@ async function run(args: IArgs) {
8791
8892 // By OSX Notice
8993 bash ( `osascript -e 'display notification "${ targetImageName } done" with title "build done"'` ) ;
94+
95+ const prompt = new Select ( {
96+ name : 'confirmPush' ,
97+ message : 'do you want to push it?' ,
98+ choices : [
99+ { name : 'y' , message : 'Yes' } ,
100+ { name : 'n' , message : 'No' } ,
101+ ] ,
102+ } ) ;
103+ const confirmPush = await prompt . run ( ) ;
104+ if ( confirmPush === 'y' ) {
105+ pushDocker ( ) ;
106+ }
90107}
91108
92109export default run ;
0 commit comments