@lvce-editor/shared-process 0.0.2 → 0.0.6
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/config/builtinCommands.json +367 -0
- package/config/colorTheme.json +98 -0
- package/config/defaultKeyBindings.json +649 -0
- package/config/defaultSettings.json +17 -0
- package/extensions/builtin.theme-slime/README.md +5 -0
- package/extensions/builtin.theme-slime/color-theme.json +205 -0
- package/extensions/builtin.theme-slime/extension.json +13 -0
- package/extensions/builtin.theme-slime/icon.png +0 -0
- package/package.json +3 -3
- package/src/parts/Env/Env.js +1 -1
- package/src/parts/Platform/Platform.js +7 -0
- package/src/parts/Preferences/Preferences.js +3 -6
- package/src/parts/Root/Root.js +1 -1
- package/test/Callback.test.js +0 -42
- package/test/ClipBoard.test.js +0 -105
- package/test/Credentials.test.js +0 -147
- package/test/Developer.test.js +0 -34
- package/test/Electron.test.js +0 -93
- package/test/Error.test.js +0 -16
- package/test/Exec.test.js +0 -25
- package/test/ExtensionHost.test.js +0 -127
- package/test/ExtensionHostColorTheme.test.js +0 -141
- package/test/ExtensionHostCommand.test.js +0 -27
- package/test/ExtensionHostCompletion.test.js +0 -45
- package/test/ExtensionHostDefinition.test.js +0 -35
- package/test/ExtensionHostDiagnostic.test.js +0 -23
- package/test/ExtensionHostFileSystem.test.js +0 -91
- package/test/ExtensionHostFormatting.test.js +0 -27
- package/test/ExtensionHostIconTheme.test.js +0 -73
- package/test/ExtensionHostLanguages.test.js +0 -212
- package/test/ExtensionHostOutput.test.js +0 -23
- package/test/ExtensionHostRename.test.js +0 -59
- package/test/ExtensionHostSemanticTokens.test.js +0 -26
- package/test/ExtensionHostTabCompletion.test.js +0 -35
- package/test/ExtensionHostTextDocument.test.js +0 -61
- package/test/ExtensionHostTypeDefinition.test.js +0 -35
- package/test/ExtensionHostWorkspace.test.js +0 -21
- package/test/ExtensionManagement.test.js +0 -408
- package/test/FileSystem.test.js +0 -294
- package/test/Json.test.js +0 -25
- package/test/Native.test.js +0 -31
- package/test/OutputChannel.test.js +0 -68
- package/test/Path.test.js +0 -17
- package/test/Platform.test.js +0 -61
- package/test/Preferences.test.js +0 -140
- package/test/Process.test.js +0 -9
- package/test/RgPath.test.js +0 -5
- package/test/Search.test.js +0 -45
- package/test/SearchFile.test.js +0 -80
- package/test/Terminal.test.js +0 -53
- package/test/Trash.test.js +0 -34
- package/test/WebSocketServer.test.js +0 -98
- package/test/fixture-search-1/index.html +0 -10
- package/test/fixture-search-file-1/fileA +0 -0
- package/test/fixture-search-file-1/fileB +0 -0
- package/test/fixture-search-file-1/nested/fileC +0 -0
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
{
|
|
2
|
+
"type": "dark",
|
|
3
|
+
"colors": {
|
|
4
|
+
"ActivityBarBackground": "rgb(41, 48, 48)",
|
|
5
|
+
"ActivityBarForeground": "rgba(135, 143, 140, 0.4)",
|
|
6
|
+
"ActivityBarActiveBackground": "#1f2727",
|
|
7
|
+
"ActivityBarActiveForeground": "rgb(135, 143, 140)",
|
|
8
|
+
|
|
9
|
+
"BadgeBackground": "purple",
|
|
10
|
+
"BadgeForeground": "#fff",
|
|
11
|
+
|
|
12
|
+
"EditorBackGround": "#1e2324",
|
|
13
|
+
"EditorScrollBarBackground": "rgba(57, 71, 71, 0.6)",
|
|
14
|
+
"EditorCursorBackground": "#a8df5a",
|
|
15
|
+
"EditorSelectionBackground": "rgba(255, 255, 255, 0.15)",
|
|
16
|
+
|
|
17
|
+
"FocusOutline": "#3d5252",
|
|
18
|
+
|
|
19
|
+
"InputBackground": "rgb(36, 41, 42)",
|
|
20
|
+
"InputForeground": "rgb(225, 225, 225)",
|
|
21
|
+
|
|
22
|
+
"ListActiveSelectionBackground": "#515f59",
|
|
23
|
+
"ListActiveSelectionForeground": "#ffffff",
|
|
24
|
+
"ListHoverBackground": "#405c5033",
|
|
25
|
+
"ListHoverForeground": "#e0e0e0",
|
|
26
|
+
"ListInactiveSelectionBackground": "#3b474280",
|
|
27
|
+
"ListForeground": "rgb(156, 162, 160)",
|
|
28
|
+
|
|
29
|
+
"MainBackground": "#1e2324",
|
|
30
|
+
|
|
31
|
+
"PanelBackground": "#1b2020",
|
|
32
|
+
"PanelBorderTopColor": "rgba(128, 128, 128, 0.35)",
|
|
33
|
+
"PanelTabForeground": "rgba(231, 231, 231, 0.6)",
|
|
34
|
+
"PanelTabActiveForeground": "rgb(231, 231, 231)",
|
|
35
|
+
"PanelTabHoverForeground": "#e7e7e7",
|
|
36
|
+
|
|
37
|
+
"QuickPickBackground": "rgb(40, 46, 47)",
|
|
38
|
+
|
|
39
|
+
"SideBarBackground": "#1b2020",
|
|
40
|
+
|
|
41
|
+
"StatusBarBackground": "rgb(40, 46, 47)",
|
|
42
|
+
"StatusBarBorderTopColor": "#222222",
|
|
43
|
+
|
|
44
|
+
"TabForeground": "rgba(214, 214, 213, 0.64)",
|
|
45
|
+
"TabActiveForeground": "#fff",
|
|
46
|
+
"TabsBackground": "rgb(40, 46, 47)",
|
|
47
|
+
"TabActiveBackground": "#24292a",
|
|
48
|
+
"TabInactiveBackground": "#282e2f",
|
|
49
|
+
|
|
50
|
+
"TitleBarBackground": "rgb(40, 46, 47)",
|
|
51
|
+
"TitleBarBorderBottomColor": "#222",
|
|
52
|
+
"TitleBarColor": "#cccccc",
|
|
53
|
+
"TitleBarColorInactive": "rgba(204, 204, 204, 0.6)"
|
|
54
|
+
},
|
|
55
|
+
"tokenColors": [
|
|
56
|
+
{
|
|
57
|
+
"name": "TagName",
|
|
58
|
+
"foreground": "#C9B567"
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"name": "AttributeName",
|
|
62
|
+
"foreground": "#9AB383"
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"name": "String",
|
|
66
|
+
"foreground": "#82A2B4"
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"name": "Import",
|
|
70
|
+
"foreground": "#82A2B4"
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"name": "Comment",
|
|
74
|
+
"foreground": "#6E7573"
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"name": "CssPropertyName",
|
|
78
|
+
"foreground": "#83A5A1"
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"name": "CssSelector",
|
|
82
|
+
"foreground": "#BEB558"
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"name": "CssPropertyValue",
|
|
86
|
+
"foreground": "#C0C0C3"
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"name": "Punctuation",
|
|
90
|
+
"foreground": "#CCD2BE"
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"name": "PunctuationTag",
|
|
94
|
+
"foreground": "#929292"
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
"name": "PunctuationString",
|
|
98
|
+
"foreground": "#C0C0C0"
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"name": "PropertyName",
|
|
102
|
+
"foreground": "#A8B298"
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"name": "LanguageConstant",
|
|
106
|
+
"foreground": "#AB6767"
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"name": "VariableName",
|
|
110
|
+
"foreground": "#BE9296"
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"name": "Keyword",
|
|
114
|
+
"foreground": "#D88F56"
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
"name": "Numeric",
|
|
118
|
+
"foreground": "#B081B9"
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
"name": "Include",
|
|
122
|
+
"foreground": "#C5A46F"
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"name": "Text",
|
|
126
|
+
"foreground": "#E1E2DE"
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
"name": "JsonPropertyName",
|
|
130
|
+
"foreground": "#A8B298"
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
"name": "Error",
|
|
134
|
+
"foreground": "red"
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
"name": "LanguageConstant",
|
|
138
|
+
"foreground": "#AB6767"
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
"name": "Regex",
|
|
142
|
+
"foreground": "#96B5B4"
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
"name": "KeywordImport",
|
|
146
|
+
"foreground": "#C5A46F"
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
"name": "Type",
|
|
150
|
+
"foreground": "#8fc4ce"
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
"name": "Macro",
|
|
154
|
+
"foreground": "#C5A46F"
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
"name": "Function",
|
|
158
|
+
"foreground": "#e0ba7d"
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
"name": "Parameter",
|
|
162
|
+
"foreground": "#be9296"
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
"name": "KeywordImport",
|
|
166
|
+
"foreground": "#C5A46F"
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
"name": "KeywordControl",
|
|
170
|
+
"foreground": "#D8D29A"
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
"name": "KeywordModifier",
|
|
174
|
+
"foreground": "#AB9B67"
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
"name": "Class",
|
|
178
|
+
"foreground": "#E6CE64"
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
"name": "KeywordReturn",
|
|
182
|
+
"foreground": "#C5A46F"
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
"name": "KeywordNew",
|
|
186
|
+
"foreground": "#B4B4B4"
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
"name": "KeywordVoid",
|
|
190
|
+
"foreground": "#B4B4B4"
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
"name": "TypePrimitive",
|
|
194
|
+
"foreground": "#C8BA7C"
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
"name": "KeywordDeclare",
|
|
198
|
+
"foreground": "#AB9B67"
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
"name": "StorageModifier",
|
|
202
|
+
"foreground": "#AB9B67"
|
|
203
|
+
}
|
|
204
|
+
]
|
|
205
|
+
}
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lvce-editor/shared-process",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"verror": "^1.10.1",
|
|
33
33
|
"ws": "^8.8.0",
|
|
34
34
|
"xdg-basedir": "^5.1.0",
|
|
35
|
-
"@lvce-editor/pty-host": "0.0.
|
|
36
|
-
"@lvce-editor/extension-host": "0.0.
|
|
35
|
+
"@lvce-editor/pty-host": "0.0.6",
|
|
36
|
+
"@lvce-editor/extension-host": "0.0.6"
|
|
37
37
|
},
|
|
38
38
|
"optionalDependencies": {
|
|
39
39
|
"electron-clipboard-ex": "^1.3.3",
|
package/src/parts/Env/Env.js
CHANGED
|
@@ -84,6 +84,9 @@ export const state = {
|
|
|
84
84
|
getRecentlyOpenedPath() {
|
|
85
85
|
return Path.join(this.getCacheDir(), 'recently-opened.json')
|
|
86
86
|
},
|
|
87
|
+
getDefaultSettingsPath() {
|
|
88
|
+
return Path.join(Root.root, 'config', 'defaultSettings.json')
|
|
89
|
+
},
|
|
87
90
|
}
|
|
88
91
|
|
|
89
92
|
export const isWindows = () => {
|
|
@@ -163,3 +166,7 @@ export const getExtensionHostPath = () => {
|
|
|
163
166
|
export const getRecentlyOpenedPath = () => {
|
|
164
167
|
return state.getRecentlyOpenedPath()
|
|
165
168
|
}
|
|
169
|
+
|
|
170
|
+
export const getDefaultSettingsPath = () => {
|
|
171
|
+
return state.getDefaultSettingsPath()
|
|
172
|
+
}
|
|
@@ -20,6 +20,7 @@ export const getUserPreferences = async () => {
|
|
|
20
20
|
}
|
|
21
21
|
return json
|
|
22
22
|
} catch (error) {
|
|
23
|
+
// @ts-ignore
|
|
23
24
|
throw new VError(error, 'failed to get user preferences')
|
|
24
25
|
}
|
|
25
26
|
}
|
|
@@ -27,14 +28,10 @@ export const getUserPreferences = async () => {
|
|
|
27
28
|
// TODO handle error
|
|
28
29
|
export const getDefaultPreferences = async () => {
|
|
29
30
|
try {
|
|
30
|
-
const defaultSettingsPath =
|
|
31
|
-
Platform.getAppDir(),
|
|
32
|
-
'static',
|
|
33
|
-
'config',
|
|
34
|
-
'defaultSettings.json'
|
|
35
|
-
)
|
|
31
|
+
const defaultSettingsPath = Platform.getDefaultSettingsPath()
|
|
36
32
|
return await JsonFile.readJson(defaultSettingsPath)
|
|
37
33
|
} catch (error) {
|
|
34
|
+
// @ts-ignore
|
|
38
35
|
throw new VError(error, 'Failed to load default preferences')
|
|
39
36
|
}
|
|
40
37
|
}
|
package/src/parts/Root/Root.js
CHANGED
package/test/Callback.test.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { jest } from '@jest/globals'
|
|
2
|
-
import * as Callback from '../src/parts/Callback/Callback.js'
|
|
3
|
-
|
|
4
|
-
beforeEach(() => {
|
|
5
|
-
Callback.state.id = 0
|
|
6
|
-
})
|
|
7
|
-
|
|
8
|
-
test('register / resolve', () => {
|
|
9
|
-
const resolve = jest.fn()
|
|
10
|
-
const reject = jest.fn()
|
|
11
|
-
const id = Callback.register(resolve, reject)
|
|
12
|
-
Callback.resolve(id)
|
|
13
|
-
expect(resolve).toHaveBeenCalledTimes(1)
|
|
14
|
-
Callback.resolve(id)
|
|
15
|
-
expect(resolve).toHaveBeenCalledTimes(2)
|
|
16
|
-
Callback.unregister(id)
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
test('register / resolve - nonexisting id', () => {
|
|
20
|
-
console.warn = jest.fn()
|
|
21
|
-
Callback.resolve(-1)
|
|
22
|
-
expect(console.warn).toHaveBeenCalledWith(
|
|
23
|
-
'callback -1 may already be disposed'
|
|
24
|
-
)
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
test('register / reject', () => {
|
|
28
|
-
const resolve = jest.fn()
|
|
29
|
-
const reject = jest.fn()
|
|
30
|
-
const id = Callback.register(resolve, reject)
|
|
31
|
-
Callback.reject(id)
|
|
32
|
-
expect(reject).toHaveBeenCalledTimes(1)
|
|
33
|
-
Callback.unregister(id)
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
test('register / reject - nonexisting id', () => {
|
|
37
|
-
console.warn = jest.fn()
|
|
38
|
-
Callback.reject(-1)
|
|
39
|
-
expect(console.warn).toHaveBeenCalledWith(
|
|
40
|
-
'callback (rejected) -1 may already be disposed'
|
|
41
|
-
)
|
|
42
|
-
})
|
package/test/ClipBoard.test.js
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { jest } from '@jest/globals'
|
|
2
|
-
|
|
3
|
-
jest.unstable_mockModule('../src/parts/Exec/Exec.js', () => ({
|
|
4
|
-
exec: jest.fn(() => {
|
|
5
|
-
throw new Error('not implemented')
|
|
6
|
-
}),
|
|
7
|
-
}))
|
|
8
|
-
|
|
9
|
-
jest.unstable_mockModule('../src/parts/Platform/Platform.js', () => ({
|
|
10
|
-
getDesktop: jest.fn(() => {
|
|
11
|
-
throw new Error('not implemented')
|
|
12
|
-
}),
|
|
13
|
-
}))
|
|
14
|
-
|
|
15
|
-
const Exec = await import('../src/parts/Exec/Exec.js')
|
|
16
|
-
const Platform = await import('../src/parts/Platform/Platform.js')
|
|
17
|
-
const ClipBoard = await import('../src/parts/ClipBoard/ClipBoard.js')
|
|
18
|
-
|
|
19
|
-
afterEach(() => {
|
|
20
|
-
jest.resetAllMocks()
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
test('readFiles - gnome - copied files', async () => {
|
|
24
|
-
// @ts-ignore
|
|
25
|
-
Platform.getDesktop.mockImplementation(() => 'gnome')
|
|
26
|
-
// @ts-ignore
|
|
27
|
-
Exec.exec.mockImplementation(() => {
|
|
28
|
-
return {
|
|
29
|
-
stdout: `copy
|
|
30
|
-
file:///test/my-folder`,
|
|
31
|
-
stderr: '',
|
|
32
|
-
}
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
expect(await ClipBoard.readFiles()).toEqual({
|
|
36
|
-
source: 'gnomeCopiedFiles',
|
|
37
|
-
type: 'copy',
|
|
38
|
-
files: ['/test/my-folder'],
|
|
39
|
-
})
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
test('readFiles - gnome - target not available', async () => {
|
|
43
|
-
// @ts-ignore
|
|
44
|
-
Platform.getDesktop.mockImplementation(() => 'gnome')
|
|
45
|
-
// @ts-ignore
|
|
46
|
-
Exec.exec.mockImplementation(() => {
|
|
47
|
-
const error = new Error('command failed with exit code 1')
|
|
48
|
-
// @ts-ignore
|
|
49
|
-
error.stderr = 'Error: target x-special/gnome-copied-files not available'
|
|
50
|
-
throw error
|
|
51
|
-
})
|
|
52
|
-
expect(await ClipBoard.readFiles()).toBe(undefined)
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
test('writeFiles - gnome - copied files', async () => {
|
|
56
|
-
// @ts-ignore
|
|
57
|
-
Platform.getDesktop.mockImplementation(() => 'gnome')
|
|
58
|
-
// @ts-ignore
|
|
59
|
-
Exec.exec.mockImplementation(async () => {
|
|
60
|
-
return { stdout: '', stderr: '' }
|
|
61
|
-
})
|
|
62
|
-
await ClipBoard.writeFiles('copy', ['/test/my-folder'])
|
|
63
|
-
expect(Exec.exec).toHaveBeenCalledTimes(3)
|
|
64
|
-
expect(Exec.exec).toHaveBeenNthCalledWith(
|
|
65
|
-
1,
|
|
66
|
-
'xclip',
|
|
67
|
-
['-i', '-selection', 'clipboard', '-t', 'x-special/gnome-copied-files'],
|
|
68
|
-
{
|
|
69
|
-
input: `copy
|
|
70
|
-
file:///test/my-folder`,
|
|
71
|
-
}
|
|
72
|
-
)
|
|
73
|
-
expect(Exec.exec).toHaveBeenNthCalledWith(
|
|
74
|
-
2,
|
|
75
|
-
'xclip',
|
|
76
|
-
['-i', '-selection', 'clipboard', '-t', 'text/uri-list'],
|
|
77
|
-
{
|
|
78
|
-
input: 'file:///test/my-folder',
|
|
79
|
-
}
|
|
80
|
-
)
|
|
81
|
-
expect(Exec.exec).toHaveBeenNthCalledWith(
|
|
82
|
-
3,
|
|
83
|
-
'xclip',
|
|
84
|
-
['-i', '-selection', 'clipboard', '-t', 'text/plain'],
|
|
85
|
-
{
|
|
86
|
-
input: '/test/my-folder',
|
|
87
|
-
}
|
|
88
|
-
)
|
|
89
|
-
})
|
|
90
|
-
|
|
91
|
-
test('writeFiles - unsupported desktop', async () => {
|
|
92
|
-
// @ts-ignore
|
|
93
|
-
Platform.getDesktop.mockImplementation(() => 'test-desktop')
|
|
94
|
-
// @ts-ignore
|
|
95
|
-
Exec.exec.mockImplementation(async () => {
|
|
96
|
-
return { stdout: '', stderr: '' }
|
|
97
|
-
})
|
|
98
|
-
const consoleSpy = jest.spyOn(console, 'info')
|
|
99
|
-
await ClipBoard.writeFiles('copy', ['/test/my-folder'])
|
|
100
|
-
expect(Exec.exec).not.toHaveBeenCalled()
|
|
101
|
-
expect(consoleSpy).toHaveBeenCalledTimes(1)
|
|
102
|
-
expect(consoleSpy).toHaveBeenCalledWith(
|
|
103
|
-
'writing files to clipboard is not yet supported on test-desktop'
|
|
104
|
-
)
|
|
105
|
-
})
|
package/test/Credentials.test.js
DELETED
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
import { jest } from '@jest/globals'
|
|
2
|
-
|
|
3
|
-
// TODO actual keytar tests are failing in ci due to dbus error
|
|
4
|
-
// would be better to have tests using actual keytar
|
|
5
|
-
|
|
6
|
-
const serviceName = `Test 123`
|
|
7
|
-
|
|
8
|
-
jest.unstable_mockModule('keytar', () => {
|
|
9
|
-
return {
|
|
10
|
-
default: {
|
|
11
|
-
deletePassword: jest.fn(() => {
|
|
12
|
-
throw new Error('not implemented')
|
|
13
|
-
}),
|
|
14
|
-
findCredentials: jest.fn(() => {
|
|
15
|
-
throw new Error('not implemented')
|
|
16
|
-
}),
|
|
17
|
-
findPassword: jest.fn(() => {
|
|
18
|
-
throw new Error('not implemented')
|
|
19
|
-
}),
|
|
20
|
-
getPassword: jest.fn(() => {
|
|
21
|
-
throw new Error('not implemented')
|
|
22
|
-
}),
|
|
23
|
-
setPassword: jest.fn(() => {
|
|
24
|
-
throw new Error('not implemented')
|
|
25
|
-
}),
|
|
26
|
-
},
|
|
27
|
-
}
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
const KeyTar = await import('keytar')
|
|
31
|
-
const Credentials = await import('../src/parts/Credentials/Credentials.js')
|
|
32
|
-
|
|
33
|
-
test('deletePassword', async () => {
|
|
34
|
-
// @ts-ignore
|
|
35
|
-
KeyTar.default.deletePassword.mockImplementation(() => {})
|
|
36
|
-
await Credentials.deletePassword(serviceName, 'foo')
|
|
37
|
-
expect(KeyTar.default.deletePassword).toHaveBeenCalledTimes(1)
|
|
38
|
-
expect(KeyTar.default.deletePassword).toHaveBeenCalledWith(serviceName, 'foo')
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
test('deletePassword - error', async () => {
|
|
42
|
-
// @ts-ignore
|
|
43
|
-
KeyTar.default.deletePassword.mockImplementation(() => {
|
|
44
|
-
throw new Error('"dbus-launch" (No such file or directory)')
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
await expect(
|
|
48
|
-
Credentials.deletePassword(serviceName, 'foo')
|
|
49
|
-
).rejects.toThrowError(
|
|
50
|
-
new Error(
|
|
51
|
-
`Failed to delete password from service ${serviceName}: "dbus-launch" (No such file or directory)`
|
|
52
|
-
)
|
|
53
|
-
)
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
test('findCredentials', async () => {
|
|
57
|
-
// @ts-ignore
|
|
58
|
-
KeyTar.default.findCredentials.mockImplementation(() => {
|
|
59
|
-
return [{ account: 'abc', password: 'abc' }]
|
|
60
|
-
})
|
|
61
|
-
expect(await Credentials.findCredentials(serviceName)).toEqual([
|
|
62
|
-
{
|
|
63
|
-
account: 'abc',
|
|
64
|
-
password: 'abc',
|
|
65
|
-
},
|
|
66
|
-
])
|
|
67
|
-
})
|
|
68
|
-
|
|
69
|
-
test('findCredentials - error', async () => {
|
|
70
|
-
// @ts-ignore
|
|
71
|
-
KeyTar.default.findCredentials.mockImplementation(() => {
|
|
72
|
-
throw new Error('"dbus-launch" (No such file or directory)')
|
|
73
|
-
})
|
|
74
|
-
await expect(Credentials.findCredentials(serviceName)).rejects.toThrowError(
|
|
75
|
-
new Error(
|
|
76
|
-
`Failed to find credentials from service ${serviceName}: "dbus-launch" (No such file or directory)`
|
|
77
|
-
)
|
|
78
|
-
)
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
test('findPassword', async () => {
|
|
82
|
-
// @ts-ignore
|
|
83
|
-
KeyTar.default.findPassword.mockImplementation(() => {
|
|
84
|
-
return 'bar'
|
|
85
|
-
})
|
|
86
|
-
expect(await Credentials.findPassword(serviceName)).toBe('bar')
|
|
87
|
-
})
|
|
88
|
-
|
|
89
|
-
test('findPassword - error', async () => {
|
|
90
|
-
// @ts-ignore
|
|
91
|
-
KeyTar.default.findPassword.mockImplementation(() => {
|
|
92
|
-
throw new Error('"dbus-launch" (No such file or directory)')
|
|
93
|
-
})
|
|
94
|
-
await expect(Credentials.findPassword(serviceName)).rejects.toThrowError(
|
|
95
|
-
new Error(
|
|
96
|
-
`Failed to find password from service ${serviceName}: "dbus-launch" (No such file or directory)`
|
|
97
|
-
)
|
|
98
|
-
)
|
|
99
|
-
})
|
|
100
|
-
|
|
101
|
-
test('getPassword', async () => {
|
|
102
|
-
// @ts-ignore
|
|
103
|
-
KeyTar.default.getPassword.mockImplementation(() => {
|
|
104
|
-
return 'bar'
|
|
105
|
-
})
|
|
106
|
-
expect(await Credentials.getPassword(serviceName, 'foo')).toBe('bar')
|
|
107
|
-
})
|
|
108
|
-
|
|
109
|
-
test('getPassword - error', async () => {
|
|
110
|
-
// @ts-ignore
|
|
111
|
-
KeyTar.default.getPassword.mockImplementation(() => {
|
|
112
|
-
throw new Error('"dbus-launch" (No such file or directory)')
|
|
113
|
-
})
|
|
114
|
-
await expect(
|
|
115
|
-
Credentials.getPassword(serviceName, 'foo')
|
|
116
|
-
).rejects.toThrowError(
|
|
117
|
-
new Error(
|
|
118
|
-
`Failed to get password from service ${serviceName}: "dbus-launch" (No such file or directory)`
|
|
119
|
-
)
|
|
120
|
-
)
|
|
121
|
-
})
|
|
122
|
-
|
|
123
|
-
test('setPassword', async () => {
|
|
124
|
-
// @ts-ignore
|
|
125
|
-
KeyTar.default.setPassword.mockImplementation(() => {})
|
|
126
|
-
await Credentials.setPassword(serviceName, 'foo', 'bar')
|
|
127
|
-
expect(KeyTar.default.setPassword).toHaveBeenCalledTimes(1)
|
|
128
|
-
expect(KeyTar.default.setPassword).toHaveBeenCalledWith(
|
|
129
|
-
serviceName,
|
|
130
|
-
'foo',
|
|
131
|
-
'bar'
|
|
132
|
-
)
|
|
133
|
-
})
|
|
134
|
-
|
|
135
|
-
test('setPassword - error', async () => {
|
|
136
|
-
// @ts-ignore
|
|
137
|
-
KeyTar.default.setPassword.mockImplementation(() => {
|
|
138
|
-
throw new Error('"dbus-launch" (No such file or directory)')
|
|
139
|
-
})
|
|
140
|
-
await expect(
|
|
141
|
-
Credentials.setPassword(serviceName, 'foo', 'bar')
|
|
142
|
-
).rejects.toThrowError(
|
|
143
|
-
new Error(
|
|
144
|
-
`Failed to set password for service ${serviceName}: "dbus-launch" (No such file or directory)`
|
|
145
|
-
)
|
|
146
|
-
)
|
|
147
|
-
})
|
package/test/Developer.test.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { access } from 'node:fs/promises'
|
|
2
|
-
import { jest } from '@jest/globals'
|
|
3
|
-
import * as Developer from '../src/parts/Developer/Developer.js'
|
|
4
|
-
|
|
5
|
-
const exists = async (path) => {
|
|
6
|
-
try {
|
|
7
|
-
await access(path)
|
|
8
|
-
return true
|
|
9
|
-
} catch {
|
|
10
|
-
return false
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
test.skip('createHeapSnapshot', async () => {
|
|
15
|
-
Date.now = () => 123456
|
|
16
|
-
// TODO jest esm mock not working https://github.com/facebook/jest/issues/10025
|
|
17
|
-
jest.mock('v8', () => ({
|
|
18
|
-
getHeapSnapshot() {
|
|
19
|
-
return ''
|
|
20
|
-
},
|
|
21
|
-
}))
|
|
22
|
-
await Developer.createHeapSnapshot()
|
|
23
|
-
expect(await exists('/tmp/vscode-123456.heapsnapshot')).toBe(true)
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
test('sharedProcessMemoryUsage', () => {
|
|
27
|
-
expect(Developer.sharedProcessMemoryUsage()).toEqual({
|
|
28
|
-
arrayBuffers: expect.any(Number),
|
|
29
|
-
external: expect.any(Number),
|
|
30
|
-
heapTotal: expect.any(Number),
|
|
31
|
-
heapUsed: expect.any(Number),
|
|
32
|
-
rss: expect.any(Number),
|
|
33
|
-
})
|
|
34
|
-
})
|