@@ -54,7 +54,7 @@ module.exports = class eSimCommands extends CLICommandBase {
54
54
55
55
const profiles = eidBlock ?. profiles ;
56
56
57
- console . log ( `${ os . EOL } Provisioning the following profiles: ` ) ;
57
+ console . log ( `${ os . EOL } Provisioning the following profiles to EID ${ eid } : ` ) ;
58
58
profiles . forEach ( ( profile , index ) => {
59
59
const rspUrl = `1\$${ profile . smdp } \$${ profile . matching_id } ` ;
60
60
console . log ( `\t${ index + 1 } . ${ profile . provider } (${ rspUrl } )` ) ;
@@ -66,11 +66,12 @@ module.exports = class eSimCommands extends CLICommandBase {
66
66
console . log ( `${ os . EOL } ${ index + 1 } . Downloading ${ profile . provider } profile from ${ rspUrl } ` ) ;
67
67
68
68
const start = Date . now ( ) ;
69
+ let timeTaken = 0 ;
69
70
let iccid = null ;
70
71
71
72
try {
72
73
const res = await execa ( this . lpa , [ 'download' , rspUrl , `--serial=${ port } ` ] ) ;
73
- const timeTaken = ( ( Date . now ( ) - start ) / 1000 ) . toFixed ( 2 ) ;
74
+ timeTaken = ( ( Date . now ( ) - start ) / 1000 ) . toFixed ( 2 ) ;
74
75
75
76
const output = res . stdout ;
76
77
if ( output . includes ( 'Profile successfully downloaded' ) ) {
@@ -93,8 +94,17 @@ module.exports = class eSimCommands extends CLICommandBase {
93
94
94
95
this . _addToJson ( this . outputJson , outputData ) ;
95
96
} catch ( err ) {
96
- console . error ( `${ os . EOL } \tFailed to download profile: ${ err . message } ` ) ;
97
+ const outputData = {
98
+ EID : eid ,
99
+ provider : profile . provider ,
100
+ iccid,
101
+ time : timeTaken ,
102
+ output : err . message ,
103
+ } ;
104
+ this . _addToJson ( this . outputJson , outputData ) ;
105
+ throw new Error ( 'Failed to download profile' ) ;
97
106
}
107
+
98
108
}
99
109
100
110
console . log ( `${ os . EOL } Provisioning complete` ) ;
@@ -239,7 +249,6 @@ module.exports = class eSimCommands extends CLICommandBase {
239
249
240
250
// Write updated JSON back to the file with indentation
241
251
fs . writeFileSync ( jsonFile , JSON . stringify ( existingJson , null , 4 ) ) ;
242
- console . log ( 'Data appended successfully' ) ;
243
252
} catch ( error ) {
244
253
console . error ( `Failed to append data to JSON file: ${ error . message } ` ) ;
245
254
}
0 commit comments