@theia/core 1.64.0-next.0 → 1.64.0-next.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/lib/browser/catalog.json +782 -725
- package/lib/browser/hover-service.d.ts +9 -3
- package/lib/browser/hover-service.d.ts.map +1 -1
- package/lib/browser/hover-service.js +25 -13
- package/lib/browser/hover-service.js.map +1 -1
- package/lib/browser/menu/browser-menu-plugin.js +1 -1
- package/lib/browser/menu/browser-menu-plugin.js.map +1 -1
- package/lib/browser/saveable-service.d.ts.map +1 -1
- package/lib/browser/saveable-service.js +4 -0
- package/lib/browser/saveable-service.js.map +1 -1
- package/lib/browser/shell/tab-bar-toolbar/tab-toolbar-item.d.ts.map +1 -1
- package/lib/browser/shell/tab-bar-toolbar/tab-toolbar-item.js +5 -0
- package/lib/browser/shell/tab-bar-toolbar/tab-toolbar-item.js.map +1 -1
- package/lib/browser/status-bar/status-bar.d.ts +2 -1
- package/lib/browser/status-bar/status-bar.d.ts.map +1 -1
- package/lib/browser/status-bar/status-bar.js +14 -7
- package/lib/browser/status-bar/status-bar.js.map +1 -1
- package/lib/browser/tree/tree-widget.d.ts +8 -0
- package/lib/browser/tree/tree-widget.d.ts.map +1 -1
- package/lib/browser/tree/tree-widget.js +38 -26
- package/lib/browser/tree/tree-widget.js.map +1 -1
- package/lib/browser/widgets/alert-message.js +1 -2
- package/lib/browser/widgets/alert-message.js.map +1 -1
- package/lib/browser/widgets/select-component.d.ts +2 -0
- package/lib/browser/widgets/select-component.d.ts.map +1 -1
- package/lib/browser/widgets/select-component.js +1 -1
- package/lib/browser/widgets/select-component.js.map +1 -1
- package/lib/electron-main/electron-main-application.d.ts.map +1 -1
- package/lib/electron-main/electron-main-application.js +21 -7
- package/lib/electron-main/electron-main-application.js.map +1 -1
- package/lib/node/setting-service.d.ts +5 -1
- package/lib/node/setting-service.d.ts.map +1 -1
- package/lib/node/setting-service.js +25 -10
- package/lib/node/setting-service.js.map +1 -1
- package/lib/node/setting-service.spec.d.ts +2 -0
- package/lib/node/setting-service.spec.d.ts.map +1 -0
- package/lib/node/setting-service.spec.js +84 -0
- package/lib/node/setting-service.spec.js.map +1 -0
- package/package.json +4 -4
- package/src/browser/hover-service.ts +31 -13
- package/src/browser/menu/browser-menu-plugin.ts +1 -1
- package/src/browser/saveable-service.ts +4 -0
- package/src/browser/shell/tab-bar-toolbar/tab-toolbar-item.tsx +8 -0
- package/src/browser/status-bar/status-bar.tsx +14 -7
- package/src/browser/style/alert-messages.css +20 -17
- package/src/browser/style/breadcrumbs.css +1 -2
- package/src/browser/style/dialog.css +3 -2
- package/src/browser/style/index.css +5 -3
- package/src/browser/style/progress-bar.css +3 -0
- package/src/browser/style/select-component.css +1 -4
- package/src/browser/style/sidepanel.css +10 -14
- package/src/browser/style/split-widget.css +4 -0
- package/src/browser/style/status-bar.css +23 -20
- package/src/browser/style/tabs.css +15 -13
- package/src/browser/style/tree.css +5 -3
- package/src/browser/style/view-container.css +3 -7
- package/src/browser/tree/tree-widget.tsx +50 -27
- package/src/browser/widgets/alert-message.tsx +2 -2
- package/src/browser/widgets/select-component.tsx +4 -1
- package/src/electron-main/electron-main-application.ts +22 -7
- package/src/node/setting-service.spec.ts +97 -0
- package/src/node/setting-service.ts +25 -11
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2025 and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { expect } from 'chai';
|
|
18
|
+
import { promises as fs } from 'fs';
|
|
19
|
+
import { Container } from 'inversify';
|
|
20
|
+
import * as sinon from 'sinon';
|
|
21
|
+
import { EnvVariablesServer } from '../common/env-variables';
|
|
22
|
+
import { ILogger } from '../common/logger';
|
|
23
|
+
import { MockLogger } from '../common/test/mock-logger';
|
|
24
|
+
import { URI } from '../common/uri';
|
|
25
|
+
import { SettingServiceImpl } from './setting-service';
|
|
26
|
+
|
|
27
|
+
describe('SettingServiceImpl', () => {
|
|
28
|
+
const mockConfigDirUri = new URI('mock');
|
|
29
|
+
|
|
30
|
+
const setup = (): Container => {
|
|
31
|
+
const container = new Container({ defaultScope: 'Singleton' });
|
|
32
|
+
container.bind(SettingServiceImpl).toSelf();
|
|
33
|
+
container.bind(MockLogger).toSelf();
|
|
34
|
+
container.bind(ILogger).toService(MockLogger);
|
|
35
|
+
container.bind(EnvVariablesServer).toConstantValue({
|
|
36
|
+
getConfigDirUri: () => Promise.resolve(mockConfigDirUri.toString()),
|
|
37
|
+
} as unknown as EnvVariablesServer);
|
|
38
|
+
return container;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
afterEach(() => {
|
|
42
|
+
sinon.restore();
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('should initialize and read settings file', async () => {
|
|
46
|
+
const container = setup();
|
|
47
|
+
const settingService = container.get(SettingServiceImpl);
|
|
48
|
+
const mockLogger = container.get(MockLogger);
|
|
49
|
+
|
|
50
|
+
const readFileStub = sinon.stub(fs, 'readFile').resolves(JSON.stringify({ key: 'value' }));
|
|
51
|
+
const infoSpy = sinon.spy(mockLogger, 'info');
|
|
52
|
+
const warnSpy = sinon.spy(mockLogger, 'warn');
|
|
53
|
+
|
|
54
|
+
const actual = await settingService.get('key');
|
|
55
|
+
expect(actual).to.be.equal('value');
|
|
56
|
+
|
|
57
|
+
expect(readFileStub.calledWith(mockConfigDirUri.resolve('backend-settings.json').path.fsPath())).to.be.true;
|
|
58
|
+
expect(infoSpy.callCount).to.be.equal(0);
|
|
59
|
+
expect(warnSpy.callCount).to.be.equal(0);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('should fallback to default and log info when errors with ENOENT', async () => {
|
|
63
|
+
const container = setup();
|
|
64
|
+
const settingService = container.get(SettingServiceImpl);
|
|
65
|
+
const mockLogger = container.get(MockLogger);
|
|
66
|
+
|
|
67
|
+
const enoent = Object.assign(new Error('ENOENT'), { code: 'ENOENT' });
|
|
68
|
+
sinon.stub(fs, 'readFile').rejects(enoent);
|
|
69
|
+
const infoSpy = sinon.spy(mockLogger, 'info');
|
|
70
|
+
const warnSpy = sinon.spy(mockLogger, 'warn');
|
|
71
|
+
|
|
72
|
+
const actual = await settingService.get('key');
|
|
73
|
+
expect(actual).to.be.undefined;
|
|
74
|
+
|
|
75
|
+
expect(infoSpy.callCount).to.be.equal(1);
|
|
76
|
+
expect(infoSpy.firstCall.args[0]).to.include('Falling back to defaults');
|
|
77
|
+
expect(warnSpy.callCount).to.be.equal(0);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it('should fallback to default and log warn when errors', async () => {
|
|
81
|
+
const container = setup();
|
|
82
|
+
const settingService = container.get(SettingServiceImpl);
|
|
83
|
+
const mockLogger = container.get(MockLogger);
|
|
84
|
+
|
|
85
|
+
const enoent = Object.assign(new Error('EISDIR'), { code: 'EISDIR' });
|
|
86
|
+
sinon.stub(fs, 'readFile').rejects(enoent);
|
|
87
|
+
const infoSpy = sinon.spy(mockLogger, 'info');
|
|
88
|
+
const warnSpy = sinon.spy(mockLogger, 'warn');
|
|
89
|
+
|
|
90
|
+
const actual = await settingService.get('key');
|
|
91
|
+
expect(actual).to.be.undefined;
|
|
92
|
+
|
|
93
|
+
expect(infoSpy.callCount).to.be.equal(0);
|
|
94
|
+
expect(warnSpy.callCount).to.be.equal(1);
|
|
95
|
+
expect(warnSpy.firstCall.args[0]).to.include('Falling back to defaults');
|
|
96
|
+
});
|
|
97
|
+
});
|
|
@@ -14,11 +14,11 @@
|
|
|
14
14
|
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
|
+
import { promises as fs } from 'fs';
|
|
17
18
|
import { inject, injectable, postConstruct } from 'inversify';
|
|
19
|
+
import { ILogger, URI } from '../common';
|
|
18
20
|
import { EnvVariablesServer } from '../common/env-variables';
|
|
19
21
|
import { Deferred } from '../common/promise-util';
|
|
20
|
-
import { promises as fs } from 'fs';
|
|
21
|
-
import { URI } from '../common';
|
|
22
22
|
|
|
23
23
|
export const SettingService = Symbol('SettingService');
|
|
24
24
|
|
|
@@ -32,6 +32,8 @@ export interface SettingService {
|
|
|
32
32
|
|
|
33
33
|
@injectable()
|
|
34
34
|
export class SettingServiceImpl implements SettingService {
|
|
35
|
+
@inject(ILogger)
|
|
36
|
+
protected readonly logger: ILogger;
|
|
35
37
|
|
|
36
38
|
@inject(EnvVariablesServer)
|
|
37
39
|
protected readonly envVarServer: EnvVariablesServer;
|
|
@@ -42,15 +44,17 @@ export class SettingServiceImpl implements SettingService {
|
|
|
42
44
|
@postConstruct()
|
|
43
45
|
protected init(): void {
|
|
44
46
|
const asyncInit = async () => {
|
|
45
|
-
const
|
|
46
|
-
const path
|
|
47
|
+
const settingsFileUri = await this.getSettingsFileUri();
|
|
48
|
+
const path = settingsFileUri.path.fsPath();
|
|
47
49
|
try {
|
|
48
|
-
const contents = await fs.readFile(path,
|
|
49
|
-
encoding: 'utf-8'
|
|
50
|
-
});
|
|
50
|
+
const contents = await fs.readFile(path, 'utf8');
|
|
51
51
|
this.values = JSON.parse(contents);
|
|
52
52
|
} catch (e) {
|
|
53
|
-
|
|
53
|
+
if (e instanceof Error && 'code' in e && e.code === 'ENOENT') {
|
|
54
|
+
this.logger.info(`Settings file not found at '${path}'. Falling back to defaults.`);
|
|
55
|
+
} else {
|
|
56
|
+
this.logger.warn(`Failed to read settings file at '${path}'. Falling back to defaults.`, e);
|
|
57
|
+
}
|
|
54
58
|
} finally {
|
|
55
59
|
this.ready.resolve();
|
|
56
60
|
}
|
|
@@ -64,9 +68,9 @@ export class SettingServiceImpl implements SettingService {
|
|
|
64
68
|
await this.writeFile();
|
|
65
69
|
}
|
|
66
70
|
|
|
67
|
-
async writeFile(): Promise<void> {
|
|
68
|
-
const
|
|
69
|
-
const path
|
|
71
|
+
protected async writeFile(): Promise<void> {
|
|
72
|
+
const settingsFileUri = await this.getSettingsFileUri();
|
|
73
|
+
const path = settingsFileUri.path.fsPath();
|
|
70
74
|
const values = JSON.stringify(this.values);
|
|
71
75
|
await fs.writeFile(path, values);
|
|
72
76
|
}
|
|
@@ -75,4 +79,14 @@ export class SettingServiceImpl implements SettingService {
|
|
|
75
79
|
await this.ready.promise;
|
|
76
80
|
return this.values[key];
|
|
77
81
|
}
|
|
82
|
+
|
|
83
|
+
protected async getConfigDirUri(): Promise<URI> {
|
|
84
|
+
const uri = await this.envVarServer.getConfigDirUri();
|
|
85
|
+
return new URI(uri);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
protected async getSettingsFileUri(): Promise<URI> {
|
|
89
|
+
const configDir = await this.getConfigDirUri();
|
|
90
|
+
return configDir.resolve('backend-settings.json');
|
|
91
|
+
}
|
|
78
92
|
}
|