File tree Expand file tree Collapse file tree 3 files changed +56
-5
lines changed Expand file tree Collapse file tree 3 files changed +56
-5
lines changed Original file line number Diff line number Diff line change @@ -96,6 +96,10 @@ exports.builder = {
96
96
description : 'Verbose mode; will output more information' ,
97
97
count : true ,
98
98
} ,
99
+ endpoint : {
100
+ alias : 'e' ,
101
+ description : 'Exoframe server endpoint to use (will override config value)' ,
102
+ } ,
99
103
} ;
100
104
exports . handler = async ( args = { } ) => {
101
105
const deployToken = args . token ;
@@ -108,16 +112,14 @@ exports.handler = async (args = {}) => {
108
112
109
113
const folder = args . _ ? args . _ . filter ( arg => arg !== 'deploy' ) . shift ( ) : undefined ;
110
114
const update = args . update ;
115
+ const endpoint = args . endpoint || userConfig . endpoint ;
111
116
112
- console . log (
113
- chalk . bold ( `${ update ? 'Updating' : 'Deploying' } ${ folder || 'current project' } to endpoint:` ) ,
114
- userConfig . endpoint
115
- ) ;
117
+ console . log ( chalk . bold ( `${ update ? 'Updating' : 'Deploying' } ${ folder || 'current project' } to endpoint:` ) , endpoint ) ;
116
118
117
119
// create config vars
118
120
const workdir = folder ? path . join ( process . cwd ( ) , folder ) : process . cwd ( ) ;
119
121
const folderName = path . basename ( workdir ) ;
120
- const remoteUrl = `${ userConfig . endpoint } /${ update ? 'update' : 'deploy' } ` ;
122
+ const remoteUrl = `${ endpoint } /${ update ? 'update' : 'deploy' } ` ;
121
123
122
124
// make sure workdir exists
123
125
if ( ! fs . existsSync ( workdir ) ) {
Original file line number Diff line number Diff line change @@ -47,6 +47,23 @@ Array [
47
47
]
48
48
` ;
49
49
50
+ exports [` Should deploy with endpoint flag 1` ] = `
51
+ Array [
52
+ Array [
53
+ "[1mDeploying test/fixtures/test_html_project to endpoint:[22m",
54
+ "http://localhost:3000",
55
+ ],
56
+ Array [
57
+ "Your project is now deployed as:
58
+ ",
59
+ ],
60
+ Array [
61
+ "[31m ID [39m[90m [39m[31m URL [39m[90m [39m[31m Hostname [39m[90m [39m[31m Type [39m
62
+ test [90m [39m localhost [90m [39m test [90m [39m Container ",
63
+ ],
64
+ ]
65
+ ` ;
66
+
50
67
exports [` Should deploy without auth but with token 1` ] = `
51
68
Array [
52
69
Array [
Original file line number Diff line number Diff line change @@ -92,6 +92,38 @@ test('Should deploy', done => {
92
92
} ) ;
93
93
} ) ;
94
94
95
+ // test
96
+ test ( 'Should deploy with endpoint flag' , done => {
97
+ // spy on console
98
+ const consoleSpy = sinon . spy ( console , 'log' ) ;
99
+
100
+ // handle correct request
101
+ const deployServer = nock ( 'http://localhost:3000' )
102
+ . post ( '/deploy' )
103
+ . reply ( ( uri , requestBody ) => {
104
+ const excgf = fs . readFileSync ( path . join ( testFolder , 'exoframe.json' ) ) ;
105
+ const index = fs . readFileSync ( path . join ( testFolder , 'index.html' ) ) ;
106
+ expect ( requestBody ) . toContain ( excgf ) ;
107
+ expect ( requestBody ) . toContain ( index ) ;
108
+
109
+ return replyWithStream ( [ { message : 'Deployment success!' , deployments, level : 'info' } ] ) ;
110
+ } ) ;
111
+
112
+ // execute login
113
+ deploy ( { _ : [ folderPath ] , endpoint : 'http://localhost:3000' } ) . then ( ( ) => {
114
+ // make sure log in was successful
115
+ // check that server was called
116
+ expect ( deployServer . isDone ( ) ) . toBeTruthy ( ) ;
117
+ // first check console output
118
+ expect ( consoleSpy . args ) . toMatchSnapshot ( ) ;
119
+ // restore console
120
+ console . log . restore ( ) ;
121
+ // tear down nock
122
+ deployServer . done ( ) ;
123
+ done ( ) ;
124
+ } ) ;
125
+ } ) ;
126
+
95
127
// test
96
128
test ( 'Should deploy without path' , done => {
97
129
// spy on console
You can’t perform that action at this time.
0 commit comments