File tree Expand file tree Collapse file tree 3 files changed +27
-13
lines changed
arduino-ide-extension/src Expand file tree Collapse file tree 3 files changed +27
-13
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,10 @@ import {
1616 arduinoCert ,
1717 certificateList ,
1818} from '../dialogs/certificate-uploader/utils' ;
19- import { ArduinoFirmwareUploader } from '../../common/protocol/arduino-firmware-uploader' ;
19+ import {
20+ ArduinoFirmwareUploader ,
21+ UploadCertificateParams ,
22+ } from '../../common/protocol/arduino-firmware-uploader' ;
2023import { nls } from '@theia/core/lib/common' ;
2124
2225@injectable ( )
@@ -74,12 +77,8 @@ export class UploadCertificate extends Contribution {
7477 } ) ;
7578
7679 registry . registerCommand ( UploadCertificate . Commands . UPLOAD_CERT , {
77- execute : async ( { fqbn, address, urls } ) => {
78- return this . arduinoFirmwareUploader . uploadCertificates (
79- `-b ${ fqbn } -a ${ address } ${ urls
80- . map ( ( url : string ) => `-u ${ url } ` )
81- . join ( ' ' ) } `
82- ) ;
80+ execute : async ( params : UploadCertificateParams ) => {
81+ return this . arduinoFirmwareUploader . uploadCertificates ( params ) ;
8382 } ,
8483 } ) ;
8584
Original file line number Diff line number Diff line change 1- import { Port } from " ./boards-service" ;
1+ import type { Port } from ' ./boards-service' ;
22
33export const ArduinoFirmwareUploaderPath =
44 '/services/arduino-firmware-uploader' ;
55export const ArduinoFirmwareUploader = Symbol ( 'ArduinoFirmwareUploader' ) ;
6- export type FirmwareInfo = {
6+ export interface FirmwareInfo {
77 board_name : string ;
88 board_fqbn : string ;
99 module : string ;
1010 firmware_version : string ;
1111 Latest : boolean ;
12- } ;
12+ }
13+ export interface UploadCertificateParams {
14+ readonly fqbn : string ;
15+ readonly address : string ;
16+ readonly urls : readonly string [ ] ;
17+ }
1318export interface ArduinoFirmwareUploader {
1419 list ( fqbn ?: string ) : Promise < FirmwareInfo [ ] > ;
1520 flash ( firmware : FirmwareInfo , port : Port ) : Promise < string > ;
16- uploadCertificates ( command : string ) : Promise < any > ;
21+ uploadCertificates ( params : UploadCertificateParams ) : Promise < unknown > ;
1722 updatableBoards ( ) : Promise < string [ ] > ;
1823 availableFirmwares ( fqbn : string ) : Promise < FirmwareInfo [ ] > ;
1924}
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import type { Port } from '../common/protocol';
44import {
55 ArduinoFirmwareUploader ,
66 FirmwareInfo ,
7+ UploadCertificateParams ,
78} from '../common/protocol/arduino-firmware-uploader' ;
89import { spawnCommand } from './exec-util' ;
910import { MonitorManager } from './monitor-manager' ;
@@ -17,8 +18,17 @@ export class ArduinoFirmwareUploaderImpl implements ArduinoFirmwareUploader {
1718 @inject ( MonitorManager )
1819 private readonly monitorManager : MonitorManager ;
1920
20- async uploadCertificates ( command : string ) : Promise < string > {
21- return await this . runCommand ( [ 'certificates' , 'flash' , command ] ) ;
21+ async uploadCertificates ( params : UploadCertificateParams ) : Promise < string > {
22+ const { fqbn, address, urls } = params ;
23+ return await this . runCommand ( [
24+ 'certificates' ,
25+ 'flash' ,
26+ '-b' ,
27+ fqbn ,
28+ '-a' ,
29+ address ,
30+ ...urls . flatMap ( ( url ) => [ '-u' , url ] ) ,
31+ ] ) ;
2232 }
2333
2434 async list ( fqbn ?: string ) : Promise < FirmwareInfo [ ] > {
You can’t perform that action at this time.
0 commit comments