Skip to content

fix: use text --format for the CLI #1947

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion arduino-ide-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,11 @@
],
"arduino": {
"cli": {
"version": "0.31.0"
"version": {
"owner": "arduino",
"repo": "arduino-cli",
"commitish": "6992de7"
}
},
"fwuploader": {
"version": "2.2.2"
Expand Down
41 changes: 19 additions & 22 deletions arduino-ide-extension/src/node/arduino-daemon-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,6 @@ export class ArduinoDaemonImpl
const cliConfigPath = join(FileUri.fsPath(configDirUri), CLI_CONFIG);
const args = [
'daemon',
'--format',
'jsonmini',
'--port',
'0',
'--config-file',
Expand Down Expand Up @@ -197,26 +195,6 @@ export class ArduinoDaemonImpl

daemon.stdout.on('data', (data) => {
const message = data.toString();

let port = '';
let address = '';
message
.split('\n')
.filter((line: string) => line.length)
.forEach((line: string) => {
try {
const parsedLine = JSON.parse(line);
if ('Port' in parsedLine) {
port = parsedLine.Port;
}
if ('IP' in parsedLine) {
address = parsedLine.IP;
}
} catch (err) {
// ignore
}
});

this.onData(message);
if (!grpcServerIsReady) {
const error = DaemonError.parse(message);
Expand All @@ -225,6 +203,25 @@ export class ArduinoDaemonImpl
return;
}

let port = '';
let address = '';
message
.split('\n')
.filter((line: string) => line.length)
.forEach((line: string) => {
try {
const parsedLine = JSON.parse(line);
if ('Port' in parsedLine) {
port = parsedLine.Port;
}
if ('IP' in parsedLine) {
address = parsedLine.IP;
}
} catch (err) {
// ignore
}
});

if (port.length && address.length) {
grpcServerIsReady = true;
ready.resolve({ daemon, port });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1333,5 +1333,3 @@ enumerateMonitorPortSettings: {
},
};

// BOOTSTRAP COMMANDS
// -------------------
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,31 @@ export namespace InitResponse {

}

export class FailedInstanceInitError extends jspb.Message {
getReason(): FailedInstanceInitReason;
setReason(value: FailedInstanceInitReason): FailedInstanceInitError;

getMessage(): string;
setMessage(value: string): FailedInstanceInitError;


serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): FailedInstanceInitError.AsObject;
static toObject(includeInstance: boolean, msg: FailedInstanceInitError): FailedInstanceInitError.AsObject;
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
static serializeBinaryToWriter(message: FailedInstanceInitError, writer: jspb.BinaryWriter): void;
static deserializeBinary(bytes: Uint8Array): FailedInstanceInitError;
static deserializeBinaryFromReader(message: FailedInstanceInitError, reader: jspb.BinaryReader): FailedInstanceInitError;
}

export namespace FailedInstanceInitError {
export type AsObject = {
reason: FailedInstanceInitReason,
message: string,
}
}

export class DestroyRequest extends jspb.Message {

hasInstance(): boolean;
Expand Down Expand Up @@ -528,3 +553,10 @@ export namespace ArchiveSketchResponse {
export type AsObject = {
}
}

export enum FailedInstanceInitReason {
FAILED_INSTANCE_INIT_REASON_UNSPECIFIED = 0,
FAILED_INSTANCE_INIT_REASON_INVALID_INDEX_URL = 1,
FAILED_INSTANCE_INIT_REASON_INDEX_LOAD_ERROR = 2,
FAILED_INSTANCE_INIT_REASON_TOOL_LOAD_ERROR = 3,
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ goog.exportSymbol('proto.cc.arduino.cli.commands.v1.CreateRequest', null, global
goog.exportSymbol('proto.cc.arduino.cli.commands.v1.CreateResponse', null, global);
goog.exportSymbol('proto.cc.arduino.cli.commands.v1.DestroyRequest', null, global);
goog.exportSymbol('proto.cc.arduino.cli.commands.v1.DestroyResponse', null, global);
goog.exportSymbol('proto.cc.arduino.cli.commands.v1.FailedInstanceInitError', null, global);
goog.exportSymbol('proto.cc.arduino.cli.commands.v1.FailedInstanceInitReason', null, global);
goog.exportSymbol('proto.cc.arduino.cli.commands.v1.InitRequest', null, global);
goog.exportSymbol('proto.cc.arduino.cli.commands.v1.InitResponse', null, global);
goog.exportSymbol('proto.cc.arduino.cli.commands.v1.InitResponse.MessageCase', null, global);
Expand Down Expand Up @@ -156,6 +158,27 @@ if (goog.DEBUG && !COMPILED) {
*/
proto.cc.arduino.cli.commands.v1.InitResponse.Progress.displayName = 'proto.cc.arduino.cli.commands.v1.InitResponse.Progress';
}
/**
* Generated by JsPbCodeGenerator.
* @param {Array=} opt_data Optional initial data array, typically from a
* server response, or constructed directly in Javascript. The array is used
* in place and becomes part of the constructed object. It is not cloned.
* If no data is provided, the constructed object will be empty, but still
* valid.
* @extends {jspb.Message}
* @constructor
*/
proto.cc.arduino.cli.commands.v1.FailedInstanceInitError = function(opt_data) {
jspb.Message.initialize(this, opt_data, 0, -1, null, null);
};
goog.inherits(proto.cc.arduino.cli.commands.v1.FailedInstanceInitError, jspb.Message);
if (goog.DEBUG && !COMPILED) {
/**
* @public
* @override
*/
proto.cc.arduino.cli.commands.v1.FailedInstanceInitError.displayName = 'proto.cc.arduino.cli.commands.v1.FailedInstanceInitError';
}
/**
* Generated by JsPbCodeGenerator.
* @param {Array=} opt_data Optional initial data array, typically from a
Expand Down Expand Up @@ -1398,6 +1421,166 @@ proto.cc.arduino.cli.commands.v1.InitResponse.prototype.hasProfile = function()



if (jspb.Message.GENERATE_TO_OBJECT) {
/**
* Creates an object representation of this proto.
* Field names that are reserved in JavaScript and will be renamed to pb_name.
* Optional fields that are not set will be set to undefined.
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
* For the list of reserved names please see:
* net/proto2/compiler/js/internal/generator.cc#kKeyword.
* @param {boolean=} opt_includeInstance Deprecated. whether to include the
* JSPB instance for transitional soy proto support:
* http://goto/soy-param-migration
* @return {!Object}
*/
proto.cc.arduino.cli.commands.v1.FailedInstanceInitError.prototype.toObject = function(opt_includeInstance) {
return proto.cc.arduino.cli.commands.v1.FailedInstanceInitError.toObject(opt_includeInstance, this);
};


/**
* Static version of the {@see toObject} method.
* @param {boolean|undefined} includeInstance Deprecated. Whether to include
* the JSPB instance for transitional soy proto support:
* http://goto/soy-param-migration
* @param {!proto.cc.arduino.cli.commands.v1.FailedInstanceInitError} msg The msg instance to transform.
* @return {!Object}
* @suppress {unusedLocalVariables} f is only used for nested messages
*/
proto.cc.arduino.cli.commands.v1.FailedInstanceInitError.toObject = function(includeInstance, msg) {
var f, obj = {
reason: jspb.Message.getFieldWithDefault(msg, 1, 0),
message: jspb.Message.getFieldWithDefault(msg, 2, "")
};

if (includeInstance) {
obj.$jspbMessageInstance = msg;
}
return obj;
};
}


/**
* Deserializes binary data (in protobuf wire format).
* @param {jspb.ByteSource} bytes The bytes to deserialize.
* @return {!proto.cc.arduino.cli.commands.v1.FailedInstanceInitError}
*/
proto.cc.arduino.cli.commands.v1.FailedInstanceInitError.deserializeBinary = function(bytes) {
var reader = new jspb.BinaryReader(bytes);
var msg = new proto.cc.arduino.cli.commands.v1.FailedInstanceInitError;
return proto.cc.arduino.cli.commands.v1.FailedInstanceInitError.deserializeBinaryFromReader(msg, reader);
};


/**
* Deserializes binary data (in protobuf wire format) from the
* given reader into the given message object.
* @param {!proto.cc.arduino.cli.commands.v1.FailedInstanceInitError} msg The message object to deserialize into.
* @param {!jspb.BinaryReader} reader The BinaryReader to use.
* @return {!proto.cc.arduino.cli.commands.v1.FailedInstanceInitError}
*/
proto.cc.arduino.cli.commands.v1.FailedInstanceInitError.deserializeBinaryFromReader = function(msg, reader) {
while (reader.nextField()) {
if (reader.isEndGroup()) {
break;
}
var field = reader.getFieldNumber();
switch (field) {
case 1:
var value = /** @type {!proto.cc.arduino.cli.commands.v1.FailedInstanceInitReason} */ (reader.readEnum());
msg.setReason(value);
break;
case 2:
var value = /** @type {string} */ (reader.readString());
msg.setMessage(value);
break;
default:
reader.skipField();
break;
}
}
return msg;
};


/**
* Serializes the message to binary data (in protobuf wire format).
* @return {!Uint8Array}
*/
proto.cc.arduino.cli.commands.v1.FailedInstanceInitError.prototype.serializeBinary = function() {
var writer = new jspb.BinaryWriter();
proto.cc.arduino.cli.commands.v1.FailedInstanceInitError.serializeBinaryToWriter(this, writer);
return writer.getResultBuffer();
};


/**
* Serializes the given message to binary data (in protobuf wire
* format), writing to the given BinaryWriter.
* @param {!proto.cc.arduino.cli.commands.v1.FailedInstanceInitError} message
* @param {!jspb.BinaryWriter} writer
* @suppress {unusedLocalVariables} f is only used for nested messages
*/
proto.cc.arduino.cli.commands.v1.FailedInstanceInitError.serializeBinaryToWriter = function(message, writer) {
var f = undefined;
f = message.getReason();
if (f !== 0.0) {
writer.writeEnum(
1,
f
);
}
f = message.getMessage();
if (f.length > 0) {
writer.writeString(
2,
f
);
}
};


/**
* optional FailedInstanceInitReason reason = 1;
* @return {!proto.cc.arduino.cli.commands.v1.FailedInstanceInitReason}
*/
proto.cc.arduino.cli.commands.v1.FailedInstanceInitError.prototype.getReason = function() {
return /** @type {!proto.cc.arduino.cli.commands.v1.FailedInstanceInitReason} */ (jspb.Message.getFieldWithDefault(this, 1, 0));
};


/**
* @param {!proto.cc.arduino.cli.commands.v1.FailedInstanceInitReason} value
* @return {!proto.cc.arduino.cli.commands.v1.FailedInstanceInitError} returns this
*/
proto.cc.arduino.cli.commands.v1.FailedInstanceInitError.prototype.setReason = function(value) {
return jspb.Message.setProto3EnumField(this, 1, value);
};


/**
* optional string message = 2;
* @return {string}
*/
proto.cc.arduino.cli.commands.v1.FailedInstanceInitError.prototype.getMessage = function() {
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, ""));
};


/**
* @param {string} value
* @return {!proto.cc.arduino.cli.commands.v1.FailedInstanceInitError} returns this
*/
proto.cc.arduino.cli.commands.v1.FailedInstanceInitError.prototype.setMessage = function(value) {
return jspb.Message.setProto3StringField(this, 2, value);
};





if (jspb.Message.GENERATE_TO_OBJECT) {
/**
* Creates an object representation of this proto.
Expand Down Expand Up @@ -3699,4 +3882,14 @@ proto.cc.arduino.cli.commands.v1.ArchiveSketchResponse.serializeBinaryToWriter =
};


/**
* @enum {number}
*/
proto.cc.arduino.cli.commands.v1.FailedInstanceInitReason = {
FAILED_INSTANCE_INIT_REASON_UNSPECIFIED: 0,
FAILED_INSTANCE_INIT_REASON_INVALID_INDEX_URL: 1,
FAILED_INSTANCE_INIT_REASON_INDEX_LOAD_ERROR: 2,
FAILED_INSTANCE_INIT_REASON_TOOL_LOAD_ERROR: 3
};

goog.object.extend(exports, proto.cc.arduino.cli.commands.v1);
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,23 @@ export namespace PlatformInstallResponse {
}
}

export class PlatformLoadingError extends jspb.Message {

serializeBinary(): Uint8Array;
toObject(includeInstance?: boolean): PlatformLoadingError.AsObject;
static toObject(includeInstance: boolean, msg: PlatformLoadingError): PlatformLoadingError.AsObject;
static extensions: {[key: number]: jspb.ExtensionFieldInfo<jspb.Message>};
static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo<jspb.Message>};
static serializeBinaryToWriter(message: PlatformLoadingError, writer: jspb.BinaryWriter): void;
static deserializeBinary(bytes: Uint8Array): PlatformLoadingError;
static deserializeBinaryFromReader(message: PlatformLoadingError, reader: jspb.BinaryReader): PlatformLoadingError;
}

export namespace PlatformLoadingError {
export type AsObject = {
}
}

export class PlatformDownloadRequest extends jspb.Message {

hasInstance(): boolean;
Expand Down
Loading