From a68577f9b60d615e5ce32624de9b9e0e76be4f38 Mon Sep 17 00:00:00 2001 From: Akos Kitta Date: Fri, 10 Mar 2023 13:07:25 +0100 Subject: [PATCH] fix: use text `--format` for the CLI `Can't write debug log: available only in text format` error is thrown by the CLI if the `--debug` flag is present. Ref: arduino/arduino-cli#2003 Closes #1942 Signed-off-by: Akos Kitta --- arduino-ide-extension/package.json | 6 +- .../src/node/arduino-daemon-impl.ts | 41 ++-- .../cli/commands/v1/commands_grpc_pb.js | 2 - .../arduino/cli/commands/v1/commands_pb.d.ts | 32 +++ .../cc/arduino/cli/commands/v1/commands_pb.js | 193 ++++++++++++++++++ .../cc/arduino/cli/commands/v1/core_pb.d.ts | 17 ++ .../cc/arduino/cli/commands/v1/core_pb.js | 123 +++++++++++ 7 files changed, 389 insertions(+), 25 deletions(-) diff --git a/arduino-ide-extension/package.json b/arduino-ide-extension/package.json index ad52691c0..97e79b06c 100644 --- a/arduino-ide-extension/package.json +++ b/arduino-ide-extension/package.json @@ -163,7 +163,11 @@ ], "arduino": { "cli": { - "version": "0.31.0" + "version": { + "owner": "arduino", + "repo": "arduino-cli", + "commitish": "6992de7" + } }, "fwuploader": { "version": "2.2.2" diff --git a/arduino-ide-extension/src/node/arduino-daemon-impl.ts b/arduino-ide-extension/src/node/arduino-daemon-impl.ts index 3f2480d07..f32271884 100644 --- a/arduino-ide-extension/src/node/arduino-daemon-impl.ts +++ b/arduino-ide-extension/src/node/arduino-daemon-impl.ts @@ -134,8 +134,6 @@ export class ArduinoDaemonImpl const cliConfigPath = join(FileUri.fsPath(configDirUri), CLI_CONFIG); const args = [ 'daemon', - '--format', - 'jsonmini', '--port', '0', '--config-file', @@ -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); @@ -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 }); diff --git a/arduino-ide-extension/src/node/cli-protocol/cc/arduino/cli/commands/v1/commands_grpc_pb.js b/arduino-ide-extension/src/node/cli-protocol/cc/arduino/cli/commands/v1/commands_grpc_pb.js index 887ef6b04..49ec3d019 100644 --- a/arduino-ide-extension/src/node/cli-protocol/cc/arduino/cli/commands/v1/commands_grpc_pb.js +++ b/arduino-ide-extension/src/node/cli-protocol/cc/arduino/cli/commands/v1/commands_grpc_pb.js @@ -1333,5 +1333,3 @@ enumerateMonitorPortSettings: { }, }; -// BOOTSTRAP COMMANDS -// ------------------- diff --git a/arduino-ide-extension/src/node/cli-protocol/cc/arduino/cli/commands/v1/commands_pb.d.ts b/arduino-ide-extension/src/node/cli-protocol/cc/arduino/cli/commands/v1/commands_pb.d.ts index ecfeeb4ff..fc1c8b525 100644 --- a/arduino-ide-extension/src/node/cli-protocol/cc/arduino/cli/commands/v1/commands_pb.d.ts +++ b/arduino-ide-extension/src/node/cli-protocol/cc/arduino/cli/commands/v1/commands_pb.d.ts @@ -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}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + 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; @@ -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, +} diff --git a/arduino-ide-extension/src/node/cli-protocol/cc/arduino/cli/commands/v1/commands_pb.js b/arduino-ide-extension/src/node/cli-protocol/cc/arduino/cli/commands/v1/commands_pb.js index 9d688b4f4..62c15ec81 100644 --- a/arduino-ide-extension/src/node/cli-protocol/cc/arduino/cli/commands/v1/commands_pb.js +++ b/arduino-ide-extension/src/node/cli-protocol/cc/arduino/cli/commands/v1/commands_pb.js @@ -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); @@ -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 @@ -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_, 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. @@ -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); diff --git a/arduino-ide-extension/src/node/cli-protocol/cc/arduino/cli/commands/v1/core_pb.d.ts b/arduino-ide-extension/src/node/cli-protocol/cc/arduino/cli/commands/v1/core_pb.d.ts index 30792fd12..dc8d8b97c 100644 --- a/arduino-ide-extension/src/node/cli-protocol/cc/arduino/cli/commands/v1/core_pb.d.ts +++ b/arduino-ide-extension/src/node/cli-protocol/cc/arduino/cli/commands/v1/core_pb.d.ts @@ -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}; + static extensionsBinary: {[key: number]: jspb.ExtensionFieldBinaryInfo}; + 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; diff --git a/arduino-ide-extension/src/node/cli-protocol/cc/arduino/cli/commands/v1/core_pb.js b/arduino-ide-extension/src/node/cli-protocol/cc/arduino/cli/commands/v1/core_pb.js index 093656172..f1f3b7793 100644 --- a/arduino-ide-extension/src/node/cli-protocol/cc/arduino/cli/commands/v1/core_pb.js +++ b/arduino-ide-extension/src/node/cli-protocol/cc/arduino/cli/commands/v1/core_pb.js @@ -24,6 +24,7 @@ goog.exportSymbol('proto.cc.arduino.cli.commands.v1.PlatformInstallRequest', nul goog.exportSymbol('proto.cc.arduino.cli.commands.v1.PlatformInstallResponse', null, global); goog.exportSymbol('proto.cc.arduino.cli.commands.v1.PlatformListRequest', null, global); goog.exportSymbol('proto.cc.arduino.cli.commands.v1.PlatformListResponse', null, global); +goog.exportSymbol('proto.cc.arduino.cli.commands.v1.PlatformLoadingError', null, global); goog.exportSymbol('proto.cc.arduino.cli.commands.v1.PlatformSearchRequest', null, global); goog.exportSymbol('proto.cc.arduino.cli.commands.v1.PlatformSearchResponse', null, global); goog.exportSymbol('proto.cc.arduino.cli.commands.v1.PlatformUninstallRequest', null, global); @@ -72,6 +73,27 @@ if (goog.DEBUG && !COMPILED) { */ proto.cc.arduino.cli.commands.v1.PlatformInstallResponse.displayName = 'proto.cc.arduino.cli.commands.v1.PlatformInstallResponse'; } +/** + * 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.PlatformLoadingError = function(opt_data) { + jspb.Message.initialize(this, opt_data, 0, -1, null, null); +}; +goog.inherits(proto.cc.arduino.cli.commands.v1.PlatformLoadingError, jspb.Message); +if (goog.DEBUG && !COMPILED) { + /** + * @public + * @override + */ + proto.cc.arduino.cli.commands.v1.PlatformLoadingError.displayName = 'proto.cc.arduino.cli.commands.v1.PlatformLoadingError'; +} /** * Generated by JsPbCodeGenerator. * @param {Array=} opt_data Optional initial data array, typically from a @@ -809,6 +831,107 @@ proto.cc.arduino.cli.commands.v1.PlatformInstallResponse.prototype.hasTaskProgre +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_, 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.PlatformLoadingError.prototype.toObject = function(opt_includeInstance) { + return proto.cc.arduino.cli.commands.v1.PlatformLoadingError.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.PlatformLoadingError} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.cc.arduino.cli.commands.v1.PlatformLoadingError.toObject = function(includeInstance, msg) { + var f, obj = { + + }; + + 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.PlatformLoadingError} + */ +proto.cc.arduino.cli.commands.v1.PlatformLoadingError.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.cc.arduino.cli.commands.v1.PlatformLoadingError; + return proto.cc.arduino.cli.commands.v1.PlatformLoadingError.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.PlatformLoadingError} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.cc.arduino.cli.commands.v1.PlatformLoadingError} + */ +proto.cc.arduino.cli.commands.v1.PlatformLoadingError.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.cc.arduino.cli.commands.v1.PlatformLoadingError.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.cc.arduino.cli.commands.v1.PlatformLoadingError.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.PlatformLoadingError} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.cc.arduino.cli.commands.v1.PlatformLoadingError.serializeBinaryToWriter = function(message, writer) { + var f = undefined; +}; + + + + + if (jspb.Message.GENERATE_TO_OBJECT) { /** * Creates an object representation of this proto.