@@ -9,7 +9,7 @@ import * as shell from '../utils/shell';
9
9
import { cantHappen } from '../utils/never' ;
10
10
import { promptBundle , BundleSelection , fileBundleSelection , repoBundleSelection } from '../utils/bundleselection' ;
11
11
import { promptForParameters } from '../utils/parameters' ;
12
- import { withOptionalTempFile } from '../utils/tempfile ' ;
12
+ import { promptForCredentials } from '../utils/credentials ' ;
13
13
14
14
export async function install ( target ?: any ) : Promise < void > {
15
15
if ( ! target ) {
@@ -52,12 +52,17 @@ async function installCore(bundlePick: BundleSelection): Promise<void> {
52
52
return ;
53
53
}
54
54
55
+ const credentialSet = await promptForCredentials ( bundlePick , shell . shell , 'Credential set to install bundle with' ) ;
56
+ if ( credentialSet . cancelled ) {
57
+ return ;
58
+ }
59
+
55
60
const parameterValues = await promptForParameters ( bundlePick , 'Install' , 'Enter installation parameters' ) ;
56
61
if ( parameterValues . cancelled ) {
57
62
return ;
58
63
}
59
64
60
- const installResult = await installToViaTempFile ( bundlePick , name , parameterValues . values ) ;
65
+ const installResult = await installTo ( bundlePick , name , parameterValues . value , credentialSet . value ) ;
61
66
62
67
if ( succeeded ( installResult ) ) {
63
68
await refreshBundleExplorer ( ) ;
@@ -66,22 +71,17 @@ async function installCore(bundlePick: BundleSelection): Promise<void> {
66
71
await showDuffleResult ( 'install' , ( bundleId ) => bundleId , installResult ) ;
67
72
}
68
73
69
- async function installToViaTempFile ( bundlePick : BundleSelection , name : string , parameterValues : any ) : Promise < Errorable < string > > {
70
- const parametersJSON = parameterValues ? JSON . stringify ( parameterValues , undefined , 2 ) : undefined ;
71
- return withOptionalTempFile ( parametersJSON , 'json' , ( paramsFile ) => installTo ( bundlePick , name , paramsFile ) ) ;
72
- }
73
-
74
- async function installTo ( bundlePick : BundleSelection , name : string , paramsFile : string | undefined ) : Promise < Errorable < string > > {
74
+ async function installTo ( bundlePick : BundleSelection , name : string , params : { [ key : string ] : string } , credentialSet : string | undefined ) : Promise < Errorable < string > > {
75
75
if ( bundlePick . kind === 'folder' ) {
76
76
const folderPath = bundlePick . path ;
77
77
const bundlePath = path . join ( folderPath , "cnab" , "bundle.json" ) ;
78
78
const installResult = await longRunning ( `Duffle installing ${ bundlePath } ` ,
79
- ( ) => duffle . installFile ( shell . shell , bundlePath , name , paramsFile )
79
+ ( ) => duffle . installFile ( shell . shell , bundlePath , name , params , credentialSet )
80
80
) ;
81
81
return map ( installResult , ( _ ) => bundlePath ) ;
82
82
} else if ( bundlePick . kind === 'repo' ) {
83
83
const installResult = await longRunning ( `Duffle installing ${ bundlePick . bundle } ` ,
84
- ( ) => duffle . installBundle ( shell . shell , bundlePick . label /* because bundlePick. bundle doesn't work */ , name , paramsFile )
84
+ ( ) => duffle . installBundle ( shell . shell , bundlePick . bundle , name , params , credentialSet )
85
85
) ;
86
86
return map ( installResult , ( _ ) => bundlePick . bundle ) ;
87
87
}
0 commit comments