Skip to content
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
10 changes: 2 additions & 8 deletions arduino-ide-extension/src/browser/contributions/about.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,16 @@ export class About extends Contribution {
}

async showAbout(): Promise<void> {
const {
version,
commit,
status: cliStatus,
} = await this.configService.getVersion();
const version = await this.configService.getVersion();
const buildDate = this.buildDate;
const detail = (showAll: boolean) =>
nls.localize(
'arduino/about/detail',
'Version: {0}\nDate: {1}{2}\nCLI Version: {3}{4} [{5}]\n\n{6}',
'Version: {0}\nDate: {1}{2}\nCLI Version: {3}\n\n{4}',
remote.app.getVersion(),
buildDate ? buildDate : nls.localize('', 'dev build'),
buildDate && showAll ? ` (${this.ago(buildDate)})` : '',
version,
cliStatus ? ` ${cliStatus}` : '',
commit,
nls.localize(
'arduino/about/copyright',
'Copyright © {0} Arduino SA',
Expand Down
4 changes: 1 addition & 3 deletions arduino-ide-extension/src/common/protocol/config-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import { RecursivePartial } from '@theia/core/lib/common/types';
export const ConfigServicePath = '/services/config-service';
export const ConfigService = Symbol('ConfigService');
export interface ConfigService {
getVersion(): Promise<
Readonly<{ version: string; commit: string; status?: string }>
>;
getVersion(): Promise<Readonly<string>>;
getConfiguration(): Promise<ConfigState>;
setConfiguration(config: Config): Promise<void>;
}
Expand Down
24 changes: 1 addition & 23 deletions arduino-ide-extension/src/node/arduino-daemon-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { EnvVariablesServer } from '@theia/core/lib/common/env-variables';
import { BackendApplicationContribution } from '@theia/core/lib/node/backend-application';
import { ArduinoDaemon, NotificationServiceServer } from '../common/protocol';
import { CLI_CONFIG } from './cli-config';
import { getExecPath, spawnCommand } from './exec-util';
import { getExecPath } from './exec-util';
import { ErrnoException } from './utils/errors';

@injectable()
Expand Down Expand Up @@ -126,28 +126,6 @@ export class ArduinoDaemonImpl
return this._execPath;
}

async getVersion(): Promise<
Readonly<{ version: string; commit: string; status?: string }>
> {
const execPath = await this.getExecPath();
const raw = await spawnCommand(
`"${execPath}"`,
['version', '--format', 'json'],
this.onError.bind(this)
);
try {
// The CLI `Info` object: https://github.com/arduino/arduino-cli/blob/17d24eb901b1fdaa5a4ec7da3417e9e460f84007/version/version.go#L31-L34
const { VersionString, Commit, Status } = JSON.parse(raw);
return {
version: VersionString,
commit: Commit,
status: Status,
};
} catch {
return { version: raw, commit: raw };
}
}

protected async getSpawnArgs(): Promise<string[]> {
const [configDirUri, debug] = await Promise.all([
this.envVariablesServer.getConfigDirUri(),
Expand Down
6 changes: 2 additions & 4 deletions arduino-ide-extension/src/node/config-service-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,8 @@ export class ConfigServiceImpl
return this.configChangeEmitter.event;
}

async getVersion(): Promise<
Readonly<{ version: string; commit: string; status?: string }>
> {
return this.daemon.getVersion();
async getVersion(): Promise<string> {
return require('../../package.json').arduino?.cli?.version || '';
}

private async initConfig(): Promise<void> {
Expand Down
2 changes: 1 addition & 1 deletion i18n/en.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"arduino": {
"about": {
"detail": "Version: {0}\nDate: {1}{2}\nCLI Version: {3}{4} [{5}]\n\n{6}",
"detail": "Version: {0}\nDate: {1}{2}\nCLI Version: {3}\n\n{4}",
"label": "About {0}"
},
"board": {
Expand Down