@theia/plugin-utils 1.77.0-next.0 → 1.77.0-next.101
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/lib/common/constants.js +12 -15
- package/lib/common/constants.js.map +1 -1
- package/lib/common/constants.spec.js +7 -9
- package/lib/common/constants.spec.js.map +1 -1
- package/lib/common/contribution-types.d.ts +3 -3
- package/lib/common/contribution-types.d.ts.map +1 -1
- package/lib/common/contribution-types.js +4 -7
- package/lib/common/contribution-types.js.map +1 -1
- package/lib/common/manifest-types.d.ts +1 -1
- package/lib/common/manifest-types.d.ts.map +1 -1
- package/lib/common/manifest-types.js +7 -11
- package/lib/common/manifest-types.js.map +1 -1
- package/lib/common/manifest-types.spec.js +7 -9
- package/lib/common/manifest-types.spec.js.map +1 -1
- package/lib/common/package-nls.js +6 -11
- package/lib/common/package-nls.js.map +1 -1
- package/lib/common/package-nls.spec.js +23 -24
- package/lib/common/package-nls.spec.js.map +1 -1
- package/lib/common/plugin-activation-events.d.ts +1 -1
- package/lib/common/plugin-activation-events.d.ts.map +1 -1
- package/lib/common/plugin-activation-events.js +14 -17
- package/lib/common/plugin-activation-events.js.map +1 -1
- package/lib/common/plugin-activation-events.spec.js +14 -16
- package/lib/common/plugin-activation-events.spec.js.map +1 -1
- package/lib/common/plugin-manifest.d.ts +1 -1
- package/lib/common/plugin-manifest.d.ts.map +1 -1
- package/lib/common/plugin-manifest.js +8 -12
- package/lib/common/plugin-manifest.js.map +1 -1
- package/lib/common/plugin-manifest.spec.js +21 -22
- package/lib/common/plugin-manifest.spec.js.map +1 -1
- package/lib/common/plugin-model.d.ts +1 -1
- package/lib/common/plugin-model.d.ts.map +1 -1
- package/lib/common/plugin-model.js +23 -37
- package/lib/common/plugin-model.js.map +1 -1
- package/lib/common/plugin-model.spec.js +66 -68
- package/lib/common/plugin-model.spec.js.map +1 -1
- package/lib/common/protocol-shims.js +3 -6
- package/lib/common/protocol-shims.js.map +1 -1
- package/lib/common/test-helpers.d.ts +2 -2
- package/lib/common/test-helpers.d.ts.map +1 -1
- package/lib/common/test-helpers.js +5 -9
- package/lib/common/test-helpers.js.map +1 -1
- package/lib/common/utils.js +6 -14
- package/lib/common/utils.js.map +1 -1
- package/lib/common/utils.spec.js +25 -27
- package/lib/common/utils.spec.js.map +1 -1
- package/lib/node/normalize-contributions.d.ts +3 -3
- package/lib/node/normalize-contributions.d.ts.map +1 -1
- package/lib/node/normalize-contributions.js +86 -126
- package/lib/node/normalize-contributions.js.map +1 -1
- package/lib/node/normalize-contributions.spec.js +158 -160
- package/lib/node/normalize-contributions.spec.js.map +1 -1
- package/lib/node/package-nls.d.ts +1 -1
- package/lib/node/package-nls.d.ts.map +1 -1
- package/lib/node/package-nls.js +9 -11
- package/lib/node/package-nls.js.map +1 -1
- package/lib/node/plugin-manifest.d.ts +2 -2
- package/lib/node/plugin-manifest.d.ts.map +1 -1
- package/lib/node/plugin-manifest.js +6 -8
- package/lib/node/plugin-manifest.js.map +1 -1
- package/lib/node/plugin-model.d.ts +1 -1
- package/lib/node/plugin-model.d.ts.map +1 -1
- package/lib/node/plugin-model.js +5 -8
- package/lib/node/plugin-model.js.map +1 -1
- package/lib/node/read-grammars.d.ts +2 -2
- package/lib/node/read-grammars.d.ts.map +1 -1
- package/lib/node/read-grammars.js +8 -11
- package/lib/node/read-grammars.js.map +1 -1
- package/lib/node/read-grammars.spec.js +25 -26
- package/lib/node/read-grammars.spec.js.map +1 -1
- package/package.json +10 -2
- package/src/common/constants.spec.ts +1 -1
- package/src/common/contribution-types.ts +3 -3
- package/src/common/manifest-types.spec.ts +1 -1
- package/src/common/manifest-types.ts +2 -2
- package/src/common/package-nls.spec.ts +4 -3
- package/src/common/package-nls.ts +1 -1
- package/src/common/plugin-activation-events.spec.ts +2 -2
- package/src/common/plugin-activation-events.ts +2 -2
- package/src/common/plugin-manifest.spec.ts +6 -5
- package/src/common/plugin-manifest.ts +3 -3
- package/src/common/plugin-model.spec.ts +4 -4
- package/src/common/plugin-model.ts +2 -2
- package/src/common/test-helpers.ts +3 -3
- package/src/common/utils.spec.ts +2 -2
- package/src/node/normalize-contributions.spec.ts +5 -5
- package/src/node/normalize-contributions.ts +5 -5
- package/src/node/package-nls.ts +4 -3
- package/src/node/plugin-manifest.ts +4 -3
- package/src/node/plugin-model.ts +1 -1
- package/src/node/read-grammars.spec.ts +3 -2
- package/src/node/read-grammars.ts +5 -4
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// *****************************************************************************
|
|
3
2
|
// Copyright (C) 2026 Maksim Kachurin and others.
|
|
4
3
|
//
|
|
@@ -14,39 +13,38 @@
|
|
|
14
13
|
//
|
|
15
14
|
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
15
|
// *****************************************************************************
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const test_helpers_1 = require("../common/test-helpers");
|
|
16
|
+
import { expect } from 'chai';
|
|
17
|
+
import { CustomEditorPriority } from '../common/contribution-types.js';
|
|
18
|
+
import { PreferenceScope } from '../common/protocol-shims.js';
|
|
19
|
+
import { deriveDefaultForType, extractPluginViewsIds, getScope, normalizeContributions, readColors, readCommand, readConfiguration, readCustomEditors, readDebuggers, readIconThemes, readIcons, readKeybinding, readLanguages, readLocalization, readLocalizations, readMenus, readSnippets, readSubmenus, readTaskDefinition, readTerminals, readThemes, readViews, readViewsContainers, readViewContainer, readViewWelcome, readViewsWelcome, readWalkthroughs, toSchema, transformIconUrl } from './normalize-contributions.js';
|
|
20
|
+
import { createNormalizeCtx, manifest } from '../common/test-helpers.js';
|
|
23
21
|
describe('normalize-contributions', () => {
|
|
24
22
|
describe('deriveDefaultForType', () => {
|
|
25
23
|
it('mirrors VS Code defaults for each json type', () => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
24
|
+
expect(deriveDefaultForType('boolean')).to.equal(false);
|
|
25
|
+
expect(deriveDefaultForType('integer')).to.equal(0);
|
|
26
|
+
expect(deriveDefaultForType('number')).to.equal(0);
|
|
27
|
+
expect(deriveDefaultForType('string')).to.equal('');
|
|
28
|
+
expect(deriveDefaultForType('array')).to.deep.equal([]);
|
|
29
|
+
expect(deriveDefaultForType('object')).to.deep.equal({});
|
|
32
30
|
// eslint-disable-next-line no-null/no-null
|
|
33
|
-
|
|
31
|
+
expect(deriveDefaultForType(undefined)).to.equal(null);
|
|
34
32
|
});
|
|
35
33
|
it('uses the first type when an array is provided', () => {
|
|
36
|
-
|
|
34
|
+
expect(deriveDefaultForType(['string', 'number'])).to.equal('');
|
|
37
35
|
});
|
|
38
36
|
});
|
|
39
37
|
describe('getScope', () => {
|
|
40
38
|
it('maps monaco scopes to preference scope and overridable flag', () => {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
39
|
+
expect(getScope('machine-overridable')).to.deep.equal({ scope: PreferenceScope.Folder, overridable: false });
|
|
40
|
+
expect(getScope('language-overridable')).to.deep.equal({ scope: PreferenceScope.Folder, overridable: true });
|
|
41
|
+
expect(getScope('application')).to.deep.equal({ scope: PreferenceScope.User, overridable: false });
|
|
42
|
+
expect(getScope(undefined)).to.deep.equal({ scope: undefined, overridable: false });
|
|
45
43
|
});
|
|
46
44
|
});
|
|
47
45
|
describe('readConfiguration', () => {
|
|
48
46
|
it('derives defaults and property scopes', () => {
|
|
49
|
-
const schema =
|
|
47
|
+
const schema = readConfiguration({
|
|
50
48
|
title: 'Sample',
|
|
51
49
|
scope: 'application',
|
|
52
50
|
properties: {
|
|
@@ -54,20 +52,20 @@ describe('normalize-contributions', () => {
|
|
|
54
52
|
'sample.path': { type: 'string', default: '/tmp' }
|
|
55
53
|
}
|
|
56
54
|
}, '/tmp/plugin');
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
55
|
+
expect(schema?.scope).to.equal(PreferenceScope.User);
|
|
56
|
+
expect(schema?.properties['sample.enabled'].default).to.equal(false);
|
|
57
|
+
expect(schema?.properties['sample.enabled'].overridable).to.equal(true);
|
|
58
|
+
expect(schema?.properties['sample.path'].default).to.equal('/tmp');
|
|
61
59
|
});
|
|
62
60
|
});
|
|
63
61
|
describe('transformIconUrl and readCommand', () => {
|
|
64
62
|
it('resolves file icons and codicons', () => {
|
|
65
|
-
const ctx =
|
|
66
|
-
|
|
63
|
+
const ctx = createNormalizeCtx();
|
|
64
|
+
expect(transformIconUrl(ctx, ctx.plugin, './media/icon.png')).to.deep.equal({
|
|
67
65
|
iconUrl: 'hostedPlugin/acme_test_ext/media/icon.png'
|
|
68
66
|
});
|
|
69
|
-
|
|
70
|
-
|
|
67
|
+
expect(transformIconUrl(ctx, ctx.plugin, '$(zap)')).to.deep.equal({ themeIcon: '$(zap)' });
|
|
68
|
+
expect(transformIconUrl(ctx, ctx.plugin, {
|
|
71
69
|
light: './light.png',
|
|
72
70
|
dark: './dark.png'
|
|
73
71
|
})).to.deep.equal({
|
|
@@ -76,13 +74,13 @@ describe('normalize-contributions', () => {
|
|
|
76
74
|
dark: 'hostedPlugin/acme_test_ext/dark.png'
|
|
77
75
|
}
|
|
78
76
|
});
|
|
79
|
-
const command =
|
|
77
|
+
const command = readCommand(ctx, {
|
|
80
78
|
command: 'sample.run',
|
|
81
79
|
title: 'Run',
|
|
82
80
|
original: 'Original',
|
|
83
81
|
icon: '$(play)'
|
|
84
82
|
}, ctx.plugin);
|
|
85
|
-
|
|
83
|
+
expect(command).to.include({
|
|
86
84
|
command: 'sample.run',
|
|
87
85
|
title: 'Run',
|
|
88
86
|
originalTitle: 'Original',
|
|
@@ -90,14 +88,14 @@ describe('normalize-contributions', () => {
|
|
|
90
88
|
});
|
|
91
89
|
});
|
|
92
90
|
it('honors ctx.transformIconUrl from readCommand / readSubmenu', () => {
|
|
93
|
-
const ctx =
|
|
91
|
+
const ctx = createNormalizeCtx();
|
|
94
92
|
ctx.transformIconUrl = () => ({ themeIcon: '$(custom)' });
|
|
95
|
-
|
|
93
|
+
expect(readCommand(ctx, {
|
|
96
94
|
command: 'sample.run',
|
|
97
95
|
title: 'Run',
|
|
98
96
|
icon: '$(play)'
|
|
99
97
|
}, ctx.plugin).themeIcon).to.equal('$(custom)');
|
|
100
|
-
|
|
98
|
+
expect(readSubmenus(ctx, [{
|
|
101
99
|
id: 'sample.submenu',
|
|
102
100
|
label: 'Sample',
|
|
103
101
|
icon: './icon.png'
|
|
@@ -106,7 +104,7 @@ describe('normalize-contributions', () => {
|
|
|
106
104
|
});
|
|
107
105
|
describe('readKeybinding and menus', () => {
|
|
108
106
|
it('copies keybinding fields', () => {
|
|
109
|
-
|
|
107
|
+
expect(readKeybinding({
|
|
110
108
|
key: 'ctrl+shift+p',
|
|
111
109
|
command: 'sample.run',
|
|
112
110
|
when: 'editorFocus',
|
|
@@ -122,7 +120,7 @@ describe('normalize-contributions', () => {
|
|
|
122
120
|
});
|
|
123
121
|
});
|
|
124
122
|
it('copies menu fields', () => {
|
|
125
|
-
|
|
123
|
+
expect(readMenus([{
|
|
126
124
|
command: 'sample.run',
|
|
127
125
|
group: 'navigation',
|
|
128
126
|
when: 'true'
|
|
@@ -137,53 +135,53 @@ describe('normalize-contributions', () => {
|
|
|
137
135
|
});
|
|
138
136
|
describe('views', () => {
|
|
139
137
|
it('extracts view ids across locations', () => {
|
|
140
|
-
|
|
138
|
+
expect(extractPluginViewsIds({
|
|
141
139
|
explorer: [{ id: 'a', name: 'A' }],
|
|
142
140
|
panel: [{ id: 'b', name: 'B' }]
|
|
143
141
|
})).to.deep.equal(['a', 'b']);
|
|
144
142
|
});
|
|
145
143
|
it('normalizes view containers, views, and welcome content order', () => {
|
|
146
|
-
const ctx =
|
|
147
|
-
const containers =
|
|
144
|
+
const ctx = createNormalizeCtx();
|
|
145
|
+
const containers = readViewsContainers(ctx, [{
|
|
148
146
|
id: 'sample.container',
|
|
149
147
|
title: 'Sample',
|
|
150
148
|
icon: '$(folder)'
|
|
151
149
|
}], ctx.plugin);
|
|
152
|
-
|
|
150
|
+
expect(containers[0]).to.include({
|
|
153
151
|
id: 'sample.container',
|
|
154
152
|
themeIcon: '$(folder)'
|
|
155
153
|
});
|
|
156
|
-
|
|
157
|
-
const views =
|
|
158
|
-
|
|
154
|
+
expect(containers[0].iconUrl).to.equal('hostedPlugin/acme_test_ext/%24(folder)');
|
|
155
|
+
const views = readViews([{ id: 'sample.view', name: 'Sample View' }]);
|
|
156
|
+
expect(views).to.deep.equal([{
|
|
159
157
|
id: 'sample.view',
|
|
160
158
|
name: 'Sample View',
|
|
161
159
|
when: undefined,
|
|
162
160
|
type: undefined
|
|
163
161
|
}]);
|
|
164
|
-
const welcome =
|
|
162
|
+
const welcome = readViewsWelcome([{
|
|
165
163
|
view: 'sample.view',
|
|
166
164
|
contents: 'Welcome'
|
|
167
165
|
}], { explorer: [{ id: 'sample.view', name: 'Sample View' }] });
|
|
168
|
-
|
|
169
|
-
|
|
166
|
+
expect(welcome[0].order).to.equal(0);
|
|
167
|
+
expect(readViewWelcome({
|
|
170
168
|
view: 'missing.view',
|
|
171
169
|
contents: 'Missing'
|
|
172
170
|
}, ['sample.view']).order).to.equal(1);
|
|
173
171
|
});
|
|
174
172
|
it('skips view containers without a string icon and reports an error', () => {
|
|
175
173
|
const errors = [];
|
|
176
|
-
const ctx =
|
|
174
|
+
const ctx = createNormalizeCtx({}, {
|
|
177
175
|
onError: (_kind, message) => {
|
|
178
176
|
errors.push(message);
|
|
179
177
|
}
|
|
180
178
|
});
|
|
181
|
-
|
|
179
|
+
expect(readViewContainer(ctx, {
|
|
182
180
|
id: 'sample.container',
|
|
183
181
|
title: 'Sample'
|
|
184
182
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
185
183
|
}, ctx.plugin)).to.equal(undefined);
|
|
186
|
-
|
|
184
|
+
expect(readViewsContainers(ctx, [{
|
|
187
185
|
id: 'valid.container',
|
|
188
186
|
title: 'Valid',
|
|
189
187
|
icon: '$(folder)'
|
|
@@ -192,23 +190,23 @@ describe('normalize-contributions', () => {
|
|
|
192
190
|
title: 'Invalid'
|
|
193
191
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
194
192
|
}], ctx.plugin)).to.have.lengthOf(1);
|
|
195
|
-
|
|
193
|
+
expect(errors.length).to.be.greaterThan(0);
|
|
196
194
|
});
|
|
197
195
|
});
|
|
198
196
|
describe('custom editors and debuggers', () => {
|
|
199
197
|
it('normalizes custom editors with default priority', () => {
|
|
200
|
-
|
|
198
|
+
expect(readCustomEditors([{
|
|
201
199
|
viewType: 'sample.editor',
|
|
202
200
|
displayName: 'Editor'
|
|
203
201
|
}])).to.deep.equal([{
|
|
204
202
|
viewType: 'sample.editor',
|
|
205
203
|
displayName: 'Editor',
|
|
206
204
|
selector: [],
|
|
207
|
-
priority:
|
|
205
|
+
priority: CustomEditorPriority.default
|
|
208
206
|
}]);
|
|
209
207
|
});
|
|
210
208
|
it('copies debugger contributions', () => {
|
|
211
|
-
|
|
209
|
+
expect(readDebuggers([{
|
|
212
210
|
type: 'node',
|
|
213
211
|
label: 'Node Debug',
|
|
214
212
|
program: './out/debug.js',
|
|
@@ -237,8 +235,8 @@ describe('normalize-contributions', () => {
|
|
|
237
235
|
});
|
|
238
236
|
describe('themes, snippets, icon themes, and colors', () => {
|
|
239
237
|
it('resolves theme and snippet uris', () => {
|
|
240
|
-
const ctx =
|
|
241
|
-
const plugin =
|
|
238
|
+
const ctx = createNormalizeCtx(undefined, undefined);
|
|
239
|
+
const plugin = manifest({
|
|
242
240
|
name: 'themes',
|
|
243
241
|
contributes: {
|
|
244
242
|
themes: [{ id: 'dark', label: 'Dark', path: './themes/dark.json' }],
|
|
@@ -247,19 +245,19 @@ describe('normalize-contributions', () => {
|
|
|
247
245
|
}
|
|
248
246
|
});
|
|
249
247
|
ctx.plugin = plugin;
|
|
250
|
-
|
|
248
|
+
expect(readThemes(ctx, plugin)).to.deep.equal([{
|
|
251
249
|
id: 'dark',
|
|
252
250
|
label: 'Dark',
|
|
253
251
|
uri: 'hostedPlugin/acme_themes/themes/dark.json',
|
|
254
252
|
description: undefined,
|
|
255
253
|
uiTheme: undefined
|
|
256
254
|
}]);
|
|
257
|
-
|
|
255
|
+
expect(readSnippets(ctx, plugin)).to.deep.equal([{
|
|
258
256
|
language: 'typescript',
|
|
259
257
|
source: 'Test Extension',
|
|
260
258
|
uri: 'hostedPlugin/acme_themes/snippets/ts.json'
|
|
261
259
|
}]);
|
|
262
|
-
|
|
260
|
+
expect(readIconThemes(ctx, plugin)).to.deep.equal([{
|
|
263
261
|
id: 'set',
|
|
264
262
|
label: 'Set',
|
|
265
263
|
uri: 'hostedPlugin/acme_themes/icons/theme.json',
|
|
@@ -270,8 +268,8 @@ describe('normalize-contributions', () => {
|
|
|
270
268
|
// A `uiTheme` that does not survive normalization falls back to `vs-dark` in the frontend, which
|
|
271
269
|
// files the theme under the dark ones and resolves its colors through the dark path.
|
|
272
270
|
it('keeps every ui theme, including hc-light', () => {
|
|
273
|
-
const ctx =
|
|
274
|
-
const plugin =
|
|
271
|
+
const ctx = createNormalizeCtx(undefined, undefined);
|
|
272
|
+
const plugin = manifest({
|
|
275
273
|
name: 'themes',
|
|
276
274
|
contributes: {
|
|
277
275
|
themes: [
|
|
@@ -285,17 +283,17 @@ describe('normalize-contributions', () => {
|
|
|
285
283
|
}
|
|
286
284
|
});
|
|
287
285
|
ctx.plugin = plugin;
|
|
288
|
-
|
|
286
|
+
expect(readThemes(ctx, plugin)?.map(theme => theme.uiTheme))
|
|
289
287
|
.to.deep.equal(['vs', 'vs-dark', 'hc-black', 'hc-light', undefined]);
|
|
290
288
|
});
|
|
291
289
|
it('validates color contributions and reports invalid ids', () => {
|
|
292
290
|
const warnings = [];
|
|
293
|
-
const ctx =
|
|
291
|
+
const ctx = createNormalizeCtx({ name: 'colors' }, {
|
|
294
292
|
onWarn: message => {
|
|
295
293
|
warnings.push(message);
|
|
296
294
|
}
|
|
297
295
|
});
|
|
298
|
-
const plugin =
|
|
296
|
+
const plugin = manifest({
|
|
299
297
|
name: 'colors',
|
|
300
298
|
contributes: {
|
|
301
299
|
colors: [
|
|
@@ -309,19 +307,19 @@ describe('normalize-contributions', () => {
|
|
|
309
307
|
}
|
|
310
308
|
});
|
|
311
309
|
ctx.plugin = plugin;
|
|
312
|
-
const colors =
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
310
|
+
const colors = readColors(ctx, plugin);
|
|
311
|
+
expect(colors).to.have.lengthOf(1);
|
|
312
|
+
expect(colors[0].defaults).to.deep.equal({ light: '#fff', dark: '#000', hc: '#111' });
|
|
313
|
+
expect(warnings.some(message => message.includes('word[.word]*'))).to.equal(true);
|
|
316
314
|
});
|
|
317
315
|
it('rejects color contributions with empty descriptions', () => {
|
|
318
316
|
const warnings = [];
|
|
319
|
-
const ctx =
|
|
317
|
+
const ctx = createNormalizeCtx({ name: 'colors' }, {
|
|
320
318
|
onWarn: message => {
|
|
321
319
|
warnings.push(message);
|
|
322
320
|
}
|
|
323
321
|
});
|
|
324
|
-
const plugin =
|
|
322
|
+
const plugin = manifest({
|
|
325
323
|
name: 'colors',
|
|
326
324
|
contributes: {
|
|
327
325
|
colors: [{
|
|
@@ -332,14 +330,14 @@ describe('normalize-contributions', () => {
|
|
|
332
330
|
}
|
|
333
331
|
});
|
|
334
332
|
ctx.plugin = plugin;
|
|
335
|
-
|
|
336
|
-
|
|
333
|
+
expect(readColors(ctx, plugin)).to.deep.equal([]);
|
|
334
|
+
expect(warnings.some(message => message.includes('description'))).to.equal(true);
|
|
337
335
|
});
|
|
338
336
|
});
|
|
339
337
|
describe('icons', () => {
|
|
340
338
|
it('accepts icon references and font-based defaults', () => {
|
|
341
|
-
const ctx =
|
|
342
|
-
const plugin =
|
|
339
|
+
const ctx = createNormalizeCtx({ name: 'icons', publisher: 'acme' });
|
|
340
|
+
const plugin = manifest({
|
|
343
341
|
name: 'icons',
|
|
344
342
|
publisher: 'acme',
|
|
345
343
|
contributes: {
|
|
@@ -359,8 +357,8 @@ describe('normalize-contributions', () => {
|
|
|
359
357
|
}
|
|
360
358
|
});
|
|
361
359
|
ctx.plugin = plugin;
|
|
362
|
-
const icons =
|
|
363
|
-
|
|
360
|
+
const icons = readIcons(ctx, plugin);
|
|
361
|
+
expect(icons).to.deep.equal([
|
|
364
362
|
{
|
|
365
363
|
id: 'sample-icon',
|
|
366
364
|
extensionId: 'acme.icons',
|
|
@@ -381,7 +379,7 @@ describe('normalize-contributions', () => {
|
|
|
381
379
|
});
|
|
382
380
|
describe('terminals, localizations, submenus, and tasks', () => {
|
|
383
381
|
it('reads terminal profiles with required fields only', () => {
|
|
384
|
-
const plugin =
|
|
382
|
+
const plugin = manifest({
|
|
385
383
|
name: 'terminal',
|
|
386
384
|
contributes: {
|
|
387
385
|
terminal: {
|
|
@@ -394,11 +392,11 @@ describe('normalize-contributions', () => {
|
|
|
394
392
|
}
|
|
395
393
|
}
|
|
396
394
|
});
|
|
397
|
-
|
|
395
|
+
expect(readTerminals(plugin)).to.deep.equal([{ id: 'bash', title: 'Bash' }]);
|
|
398
396
|
});
|
|
399
397
|
it('drops empty theme/snippet paths (avoids resolving to the plugin root)', () => {
|
|
400
|
-
const ctx =
|
|
401
|
-
const plugin =
|
|
398
|
+
const ctx = createNormalizeCtx(undefined, undefined);
|
|
399
|
+
const plugin = manifest({
|
|
402
400
|
name: 'empty-paths',
|
|
403
401
|
contributes: {
|
|
404
402
|
themes: [{ id: 'bad', path: '' }],
|
|
@@ -407,12 +405,12 @@ describe('normalize-contributions', () => {
|
|
|
407
405
|
}
|
|
408
406
|
});
|
|
409
407
|
ctx.plugin = plugin;
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
408
|
+
expect(readThemes(ctx, plugin)).to.deep.equal([]);
|
|
409
|
+
expect(readSnippets(ctx, plugin)).to.deep.equal([]);
|
|
410
|
+
expect(readIconThemes(ctx, plugin)).to.deep.equal([]);
|
|
413
411
|
});
|
|
414
412
|
it('reads localization bundles', () => {
|
|
415
|
-
const plugin =
|
|
413
|
+
const plugin = manifest({
|
|
416
414
|
name: 'l10n',
|
|
417
415
|
packagePath: '/tmp/plugin',
|
|
418
416
|
contributes: {
|
|
@@ -423,7 +421,7 @@ describe('normalize-contributions', () => {
|
|
|
423
421
|
}]
|
|
424
422
|
}
|
|
425
423
|
});
|
|
426
|
-
|
|
424
|
+
expect(readLocalizations(plugin)).to.deep.equal([{
|
|
427
425
|
languageId: 'de',
|
|
428
426
|
languageName: 'German',
|
|
429
427
|
localizedLanguageName: undefined,
|
|
@@ -432,7 +430,7 @@ describe('normalize-contributions', () => {
|
|
|
432
430
|
}]);
|
|
433
431
|
});
|
|
434
432
|
it('honors readLocalization / readTranslation ctx hooks', () => {
|
|
435
|
-
const plugin =
|
|
433
|
+
const plugin = manifest({
|
|
436
434
|
name: 'l10n',
|
|
437
435
|
packagePath: '/tmp/plugin',
|
|
438
436
|
contributes: {
|
|
@@ -442,13 +440,13 @@ describe('normalize-contributions', () => {
|
|
|
442
440
|
}]
|
|
443
441
|
}
|
|
444
442
|
});
|
|
445
|
-
const ctx =
|
|
443
|
+
const ctx = createNormalizeCtx({ name: 'l10n', packagePath: '/tmp/plugin' });
|
|
446
444
|
ctx.readTranslation = (entry, pluginPath) => ({
|
|
447
445
|
id: entry.id,
|
|
448
446
|
path: `${pluginPath}/${entry.path}`
|
|
449
447
|
});
|
|
450
|
-
ctx.readLocalization = (entry, pluginPath) =>
|
|
451
|
-
|
|
448
|
+
ctx.readLocalization = (entry, pluginPath) => readLocalization(entry, pluginPath, ctx);
|
|
449
|
+
expect(readLocalizations(plugin, ctx)).to.deep.equal([{
|
|
452
450
|
languageId: 'de',
|
|
453
451
|
languageName: undefined,
|
|
454
452
|
localizedLanguageName: undefined,
|
|
@@ -457,8 +455,8 @@ describe('normalize-contributions', () => {
|
|
|
457
455
|
}]);
|
|
458
456
|
});
|
|
459
457
|
it('reads submenu icons via transformIconUrl', () => {
|
|
460
|
-
const ctx =
|
|
461
|
-
|
|
458
|
+
const ctx = createNormalizeCtx();
|
|
459
|
+
expect(readSubmenus(ctx, [{
|
|
462
460
|
id: 'sample.submenu',
|
|
463
461
|
label: 'Sample',
|
|
464
462
|
icon: '$(gear)'
|
|
@@ -469,17 +467,17 @@ describe('normalize-contributions', () => {
|
|
|
469
467
|
}]);
|
|
470
468
|
});
|
|
471
469
|
it('builds task definition schema with required type property', () => {
|
|
472
|
-
const definition =
|
|
470
|
+
const definition = readTaskDefinition('sample.tasks', {
|
|
473
471
|
type: 'npm',
|
|
474
472
|
required: ['script'],
|
|
475
473
|
properties: {
|
|
476
474
|
script: { type: 'string' }
|
|
477
475
|
}
|
|
478
476
|
});
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
477
|
+
expect(definition.taskType).to.equal('npm');
|
|
478
|
+
expect(definition.source).to.equal('sample.tasks');
|
|
479
|
+
expect(definition.properties.all).to.deep.equal(['script']);
|
|
480
|
+
expect(toSchema({
|
|
483
481
|
type: 'npm',
|
|
484
482
|
required: [],
|
|
485
483
|
properties: { script: { type: 'string' } }
|
|
@@ -487,42 +485,42 @@ describe('normalize-contributions', () => {
|
|
|
487
485
|
});
|
|
488
486
|
it('honors ctx.toSchema from readTaskDefinition', () => {
|
|
489
487
|
const customSchema = { type: 'object', properties: { custom: { type: 'boolean' } } };
|
|
490
|
-
const definition =
|
|
488
|
+
const definition = readTaskDefinition('sample.tasks', {
|
|
491
489
|
type: 'npm',
|
|
492
490
|
required: [],
|
|
493
491
|
properties: {}
|
|
494
492
|
}, {
|
|
495
493
|
toSchema: () => customSchema
|
|
496
494
|
});
|
|
497
|
-
|
|
495
|
+
expect(definition.properties.schema).to.equal(customSchema);
|
|
498
496
|
});
|
|
499
497
|
});
|
|
500
498
|
describe('readLanguage', () => {
|
|
501
499
|
it('loads language configuration from a relative json file', async () => {
|
|
502
|
-
const ctx =
|
|
500
|
+
const ctx = createNormalizeCtx({ name: 'lang', packagePath: '/tmp/plugin' }, {
|
|
503
501
|
readJsonFile: async () => ({
|
|
504
502
|
autoClosingPairs: [['{', '}'], { open: '[', close: ']', notIn: ['string'] }],
|
|
505
503
|
surroundingPairs: [['(', ')']]
|
|
506
504
|
})
|
|
507
505
|
});
|
|
508
|
-
const languages = await
|
|
506
|
+
const languages = await readLanguages(ctx, [{
|
|
509
507
|
id: 'sample',
|
|
510
508
|
configuration: './language-configuration.json'
|
|
511
509
|
}], ctx.plugin);
|
|
512
|
-
|
|
510
|
+
expect(languages[0].configuration?.autoClosingPairs).to.deep.equal([
|
|
513
511
|
{ open: '{', close: '}' },
|
|
514
512
|
{ open: '[', close: ']', notIn: ['string'] }
|
|
515
513
|
]);
|
|
516
|
-
|
|
514
|
+
expect(languages[0].configuration?.surroundingPairs).to.deep.equal([{ open: '(', close: ')' }]);
|
|
517
515
|
});
|
|
518
516
|
});
|
|
519
517
|
describe('normalizeContributions', () => {
|
|
520
518
|
it('leaves output empty when the manifest has no contribution kinds', async () => {
|
|
521
|
-
const contributions = await
|
|
522
|
-
|
|
519
|
+
const contributions = await normalizeContributions(createNormalizeCtx({ name: 'empty' }), {});
|
|
520
|
+
expect(Object.keys(contributions)).to.deep.equal([]);
|
|
523
521
|
});
|
|
524
522
|
it('normalizes supported contribution kinds via injectable readers', async () => {
|
|
525
|
-
const ctx =
|
|
523
|
+
const ctx = createNormalizeCtx({
|
|
526
524
|
name: 'full',
|
|
527
525
|
contributes: {
|
|
528
526
|
commands: [{ command: 'sample.run', title: 'Run' }],
|
|
@@ -530,10 +528,10 @@ describe('normalize-contributions', () => {
|
|
|
530
528
|
configuration: { title: 'Sample', properties: { enabled: { type: 'boolean' } } }
|
|
531
529
|
}
|
|
532
530
|
});
|
|
533
|
-
const contributions = await
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
531
|
+
const contributions = await normalizeContributions(ctx, {});
|
|
532
|
+
expect(contributions).to.have.property('commands').with.lengthOf(1);
|
|
533
|
+
expect(contributions).to.have.property('keybindings').with.lengthOf(1);
|
|
534
|
+
expect(contributions).to.have.property('configuration').with.lengthOf(1);
|
|
537
535
|
});
|
|
538
536
|
it('runs the orchestrator for shell layout, passthrough, and async contribution kinds', async () => {
|
|
539
537
|
const readGrammars = async () => [{
|
|
@@ -543,7 +541,7 @@ describe('normalize-contributions', () => {
|
|
|
543
541
|
grammar: { scopeName: 'source.sample' },
|
|
544
542
|
grammarLocation: './grammar.json'
|
|
545
543
|
}];
|
|
546
|
-
const ctx =
|
|
544
|
+
const ctx = createNormalizeCtx({
|
|
547
545
|
name: 'orchestrator',
|
|
548
546
|
displayName: 'Orchestrator Extension',
|
|
549
547
|
contributes: {
|
|
@@ -604,24 +602,24 @@ describe('normalize-contributions', () => {
|
|
|
604
602
|
grammars: [{ language: 'sample-lang', scopeName: 'source.sample', path: './grammar.json' }]
|
|
605
603
|
}
|
|
606
604
|
}, { readGrammars });
|
|
607
|
-
const contributions = await
|
|
608
|
-
|
|
605
|
+
const contributions = await normalizeContributions(ctx, {});
|
|
606
|
+
expect(contributions.configurationDefaults).to.deep.equal({ 'sample.enabled': true });
|
|
609
607
|
const configuration = contributions.configuration;
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
608
|
+
expect(configuration).to.have.lengthOf(2);
|
|
609
|
+
expect(configuration[0].properties['sample.enabled'].owner).to.equal('Orchestrator Extension');
|
|
610
|
+
expect(configuration[0].properties['sample.enabled'].group).to.equal('General');
|
|
611
|
+
expect(contributions.submenus).to.deep.equal([{
|
|
614
612
|
icon: '$(gear)',
|
|
615
613
|
id: 'sample.submenu',
|
|
616
614
|
label: 'Sample'
|
|
617
615
|
}]);
|
|
618
|
-
|
|
616
|
+
expect(contributions.customEditors).to.deep.equal([{
|
|
619
617
|
viewType: 'sample.editor',
|
|
620
618
|
displayName: 'Editor',
|
|
621
619
|
selector: [],
|
|
622
|
-
priority:
|
|
620
|
+
priority: CustomEditorPriority.default
|
|
623
621
|
}]);
|
|
624
|
-
|
|
622
|
+
expect(contributions.viewsContainers).to.deep.equal({
|
|
625
623
|
left: [{
|
|
626
624
|
id: 'sample.container',
|
|
627
625
|
title: 'Sample',
|
|
@@ -637,20 +635,20 @@ describe('normalize-contributions', () => {
|
|
|
637
635
|
when: undefined
|
|
638
636
|
}]
|
|
639
637
|
});
|
|
640
|
-
|
|
638
|
+
expect(contributions.views).to.deep.equal({
|
|
641
639
|
explorer: [{ id: 'sample.view', name: 'Sample View', when: undefined, type: undefined }]
|
|
642
640
|
});
|
|
643
|
-
|
|
641
|
+
expect(contributions.viewsWelcome).to.deep.equal([{
|
|
644
642
|
view: 'sample.view',
|
|
645
643
|
content: 'Welcome',
|
|
646
644
|
when: undefined,
|
|
647
645
|
enablement: undefined,
|
|
648
646
|
order: 0
|
|
649
647
|
}]);
|
|
650
|
-
|
|
648
|
+
expect(contributions.menus).to.deep.equal({
|
|
651
649
|
'editor/title': [{ command: 'sample.run', group: 'navigation', submenu: undefined, alt: undefined, when: undefined }]
|
|
652
650
|
});
|
|
653
|
-
|
|
651
|
+
expect(contributions.debuggers).to.deep.equal([{
|
|
654
652
|
type: 'node',
|
|
655
653
|
label: 'Node Debug',
|
|
656
654
|
program: './debug.js',
|
|
@@ -669,7 +667,7 @@ describe('normalize-contributions', () => {
|
|
|
669
667
|
runtimeArgs: undefined,
|
|
670
668
|
configurationAttributes: undefined
|
|
671
669
|
}]);
|
|
672
|
-
|
|
670
|
+
expect(contributions.taskDefinitions).to.deep.equal([{
|
|
673
671
|
taskType: 'npm',
|
|
674
672
|
source: 'orchestrator',
|
|
675
673
|
properties: {
|
|
@@ -685,52 +683,52 @@ describe('normalize-contributions', () => {
|
|
|
685
683
|
}
|
|
686
684
|
}
|
|
687
685
|
}]);
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
686
|
+
expect(contributions.problemMatchers).to.deep.equal([{ name: 'sample-matcher' }]);
|
|
687
|
+
expect(contributions.problemPatterns).to.deep.equal([{ regexp: 'sample' }]);
|
|
688
|
+
expect(contributions.resourceLabelFormatters).to.deep.equal([{ scheme: 'file' }]);
|
|
689
|
+
expect(contributions.authentication).to.deep.equal([{ id: 'github', label: 'GitHub' }]);
|
|
690
|
+
expect(contributions.notebooks).to.deep.equal([{ type: 'sample-notebook', displayName: 'Notebook' }]);
|
|
691
|
+
expect(contributions.notebookRenderer).to.deep.equal([{ id: 'sample-renderer', displayName: 'Renderer' }]);
|
|
692
|
+
expect(contributions.notebookPreload).to.deep.equal([{ type: 'sample-preload' }]);
|
|
693
|
+
expect(contributions.snippets).to.deep.equal([{
|
|
696
694
|
language: 'typescript',
|
|
697
695
|
source: 'Orchestrator Extension',
|
|
698
696
|
uri: 'hostedPlugin/acme_orchestrator/snippets/ts.json'
|
|
699
697
|
}]);
|
|
700
|
-
|
|
698
|
+
expect(contributions.themes).to.deep.equal([{
|
|
701
699
|
id: 'dark',
|
|
702
700
|
label: 'Dark',
|
|
703
701
|
uri: 'hostedPlugin/acme_orchestrator/themes/dark.json',
|
|
704
702
|
description: undefined,
|
|
705
703
|
uiTheme: undefined
|
|
706
704
|
}]);
|
|
707
|
-
|
|
705
|
+
expect(contributions.colors).to.deep.equal([{
|
|
708
706
|
id: 'sample.color',
|
|
709
707
|
description: 'Sample',
|
|
710
708
|
defaults: { light: '#fff', dark: '#000', hc: '#111' }
|
|
711
709
|
}]);
|
|
712
|
-
|
|
710
|
+
expect(contributions.iconThemes).to.deep.equal([{
|
|
713
711
|
id: 'sample-icons',
|
|
714
712
|
label: 'Icons',
|
|
715
713
|
uri: 'hostedPlugin/acme_orchestrator/icons/theme.json',
|
|
716
714
|
description: undefined,
|
|
717
715
|
uiTheme: undefined
|
|
718
716
|
}]);
|
|
719
|
-
|
|
717
|
+
expect(contributions.icons).to.deep.equal([{
|
|
720
718
|
id: 'sample-icon',
|
|
721
719
|
extensionId: 'acme.orchestrator',
|
|
722
720
|
description: 'Sample icon',
|
|
723
721
|
defaults: { id: 'other-icon' }
|
|
724
722
|
}]);
|
|
725
|
-
|
|
726
|
-
|
|
723
|
+
expect(contributions.terminalProfiles).to.deep.equal([{ id: 'bash', title: 'Bash' }]);
|
|
724
|
+
expect(contributions.localizations).to.deep.equal([{
|
|
727
725
|
languageId: 'de',
|
|
728
726
|
languageName: 'German',
|
|
729
727
|
localizedLanguageName: undefined,
|
|
730
728
|
minimalTranslations: undefined,
|
|
731
729
|
translations: [{ id: 'package', path: './package.nls.de.json' }]
|
|
732
730
|
}]);
|
|
733
|
-
|
|
731
|
+
expect(contributions.languages).to.deep.equal([{
|
|
734
732
|
id: 'sample-lang',
|
|
735
733
|
aliases: undefined,
|
|
736
734
|
extensions: ['.sample'],
|
|
@@ -740,7 +738,7 @@ describe('normalize-contributions', () => {
|
|
|
740
738
|
mimetypes: undefined,
|
|
741
739
|
icon: undefined
|
|
742
740
|
}]);
|
|
743
|
-
|
|
741
|
+
expect(contributions.grammars).to.deep.equal([{
|
|
744
742
|
language: 'sample-lang',
|
|
745
743
|
scope: 'source.sample',
|
|
746
744
|
format: 'json',
|
|
@@ -750,7 +748,7 @@ describe('normalize-contributions', () => {
|
|
|
750
748
|
});
|
|
751
749
|
it('merges aliased view container locations and reports async reader failures', async () => {
|
|
752
750
|
const errors = [];
|
|
753
|
-
const ctx =
|
|
751
|
+
const ctx = createNormalizeCtx({
|
|
754
752
|
name: 'merge',
|
|
755
753
|
contributes: {
|
|
756
754
|
viewsContainers: {
|
|
@@ -771,8 +769,8 @@ describe('normalize-contributions', () => {
|
|
|
771
769
|
errors.push({ kind, message });
|
|
772
770
|
}
|
|
773
771
|
});
|
|
774
|
-
const contributions = await
|
|
775
|
-
|
|
772
|
+
const contributions = await normalizeContributions(ctx, {});
|
|
773
|
+
expect(contributions.viewsContainers).to.deep.equal({
|
|
776
774
|
left: [{
|
|
777
775
|
id: 'left-a',
|
|
778
776
|
title: 'A',
|
|
@@ -788,13 +786,13 @@ describe('normalize-contributions', () => {
|
|
|
788
786
|
when: undefined
|
|
789
787
|
}]
|
|
790
788
|
});
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
789
|
+
expect(contributions).to.not.have.property('languages');
|
|
790
|
+
expect(contributions).to.not.have.property('grammars');
|
|
791
|
+
expect(errors.map(error => error.kind)).to.include.members(['languages', 'grammars']);
|
|
794
792
|
});
|
|
795
793
|
it('continues after reader errors and reports them', async () => {
|
|
796
794
|
const errors = [];
|
|
797
|
-
const ctx =
|
|
795
|
+
const ctx = createNormalizeCtx({
|
|
798
796
|
name: 'broken',
|
|
799
797
|
contributes: {
|
|
800
798
|
commands: [{ command: 'ok', title: 'OK' }],
|
|
@@ -808,17 +806,17 @@ describe('normalize-contributions', () => {
|
|
|
808
806
|
errors.push({ kind, message });
|
|
809
807
|
}
|
|
810
808
|
});
|
|
811
|
-
const contributions = await
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
809
|
+
const contributions = await normalizeContributions(ctx, {});
|
|
810
|
+
expect(contributions).to.have.property('commands').with.lengthOf(1);
|
|
811
|
+
expect(contributions).to.have.property('configuration').that.is.empty;
|
|
812
|
+
expect(errors).to.have.lengthOf(1);
|
|
813
|
+
expect(errors[0].kind).to.equal('configuration');
|
|
814
|
+
expect(errors[0].message).to.be.instanceOf(Error);
|
|
817
815
|
});
|
|
818
816
|
});
|
|
819
817
|
describe('readWalkthroughs', () => {
|
|
820
818
|
it('resolves media and plugin icon URLs for browser-only static hosting', async () => {
|
|
821
|
-
const ctx =
|
|
819
|
+
const ctx = createNormalizeCtx({
|
|
822
820
|
name: 'test-plugin',
|
|
823
821
|
publisher: 'test-publisher',
|
|
824
822
|
icon: 'images/icon.png',
|
|
@@ -836,18 +834,18 @@ describe('normalize-contributions', () => {
|
|
|
836
834
|
}]
|
|
837
835
|
}
|
|
838
836
|
});
|
|
839
|
-
const contributions = await
|
|
840
|
-
|
|
837
|
+
const contributions = await normalizeContributions(ctx, {});
|
|
838
|
+
expect(contributions).to.have.property('walkthroughs').with.lengthOf(1);
|
|
841
839
|
const walkthrough = contributions.walkthroughs[0];
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
840
|
+
expect(walkthrough.pluginId).to.equal('test-publisher.test-plugin');
|
|
841
|
+
expect(walkthrough.pluginIcon).to.equal('hostedPlugin/test_publisher_test_plugin/images/icon.png');
|
|
842
|
+
expect(walkthrough.steps[0].media).to.deep.equal({
|
|
845
843
|
markdown: 'hostedPlugin/test_publisher_test_plugin/walkthroughs/open.md'
|
|
846
844
|
});
|
|
847
845
|
});
|
|
848
846
|
it('skips walkthroughs with a missing id', () => {
|
|
849
847
|
const warnings = [];
|
|
850
|
-
const ctx =
|
|
848
|
+
const ctx = createNormalizeCtx({
|
|
851
849
|
name: 'test-plugin',
|
|
852
850
|
publisher: 'test-publisher',
|
|
853
851
|
contributes: {
|
|
@@ -863,8 +861,8 @@ describe('normalize-contributions', () => {
|
|
|
863
861
|
warnings.push(msg);
|
|
864
862
|
}
|
|
865
863
|
});
|
|
866
|
-
|
|
867
|
-
|
|
864
|
+
expect(readWalkthroughs(ctx.plugin, ctx)).to.be.undefined;
|
|
865
|
+
expect(warnings).to.have.lengthOf(1);
|
|
868
866
|
});
|
|
869
867
|
});
|
|
870
868
|
});
|