@@ -21,6 +21,7 @@ module.exports = class eSimCommands extends CLICommandBase {
21
21
this . lpa = null ;
22
22
this . inputJson = null ;
23
23
this . outputJson = null ;
24
+ this . downloadedProfiles = [ ] ;
24
25
}
25
26
26
27
async provisionCommand ( args ) {
@@ -78,7 +79,14 @@ module.exports = class eSimCommands extends CLICommandBase {
78
79
79
80
// Download each profile and update the JSON output
80
81
await this . _doDownload ( profiles , port , eid ) ;
81
-
82
+
83
+ const profilesOnDevice = await this . _listProfiles ( port ) ;
84
+ const iccids = profilesOnDevice . map ( ( line ) => line . split ( ' ' ) [ 4 ] ) ;
85
+ console . log ( `${ os . EOL } Profiles downloaded:` ) ;
86
+ for ( const iccid of iccids ) {
87
+ const provider = this . downloadedProfiles . find ( ( profile ) => profile . iccid === iccid ) ?. provider ;
88
+ console . log ( `\t${ provider } - ${ iccid } ` ) ;
89
+ }
82
90
console . log ( `${ os . EOL } Provisioning complete` ) ;
83
91
}
84
92
@@ -192,6 +200,17 @@ module.exports = class eSimCommands extends CLICommandBase {
192
200
async _checkForExistingProfiles ( port ) {
193
201
console . log ( `${ os . EOL } Checking for existing profiles...` ) ;
194
202
203
+ const profilesList = await this . _listProfiles ( port ) ;
204
+
205
+ if ( profilesList . length > 0 ) {
206
+ console . error ( `${ os . EOL } Profile(s) already exist:` , profilesList ) ;
207
+ throw new Error ( 'Profile(s) already exist. Troubleshoot manually.' ) ;
208
+ }
209
+
210
+ console . log ( `${ os . EOL } No existing profiles found` ) ;
211
+ }
212
+
213
+ async _listProfiles ( port ) {
195
214
const resProfiles = await execa ( this . lpa , [ 'listProfiles' , `--serial=${ port } ` ] ) ;
196
215
const profilesOutput = resProfiles . stdout ;
197
216
@@ -200,12 +219,7 @@ module.exports = class eSimCommands extends CLICommandBase {
200
219
. split ( '\n' )
201
220
. filter ( ( line ) => line . match ( / ^ \d + : \[ \w + , \s (?: e n a b l e d | d i s a b l e d ) , \s ? \] $ / ) ) ;
202
221
203
- if ( profilesList . length > 0 ) {
204
- console . error ( `${ os . EOL } Profile(s) already exist:` , profilesList ) ;
205
- throw new Error ( 'Profile(s) already exist. Troubleshoot manually.' ) ;
206
- }
207
-
208
- console . log ( `${ os . EOL } No existing profiles found` ) ;
222
+ return profilesList ;
209
223
}
210
224
211
225
_getProfiles ( eid ) {
@@ -254,7 +268,10 @@ module.exports = class eSimCommands extends CLICommandBase {
254
268
success : true ,
255
269
output,
256
270
} ;
257
-
271
+ this . downloadedProfiles . push ( {
272
+ provider : profile . provider ,
273
+ iccid,
274
+ } ) ;
258
275
this . _addToJson ( this . outputJson , outputData ) ;
259
276
} catch ( err ) {
260
277
const outputData = {
0 commit comments