semantic-release-vsce 6.0.0 → 6.0.2

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.
@@ -1,208 +0,0 @@
1
- import avaTest from 'ava';
2
- import { fake, stub } from 'sinon';
3
- import esmock from 'esmock';
4
- import process from 'node:process';
5
-
6
- // Run tests serially to avoid env pollution
7
- const test = avaTest.serial;
8
-
9
- const logger = {
10
- log: fake(),
11
- };
12
- const cwd = process.cwd();
13
-
14
- test.beforeEach((t) => {
15
- t.context.stubs = {
16
- execaStub: stub().resolves(),
17
- };
18
- });
19
-
20
- test.afterEach((t) => {
21
- t.context.stubs.execaStub.resetHistory();
22
- });
23
-
24
- test('packageVsix is disabled', async (t) => {
25
- const { execaStub } = t.context.stubs;
26
- const { prepare } = await esmock('../lib/prepare.js', {
27
- execa: {
28
- execa: execaStub,
29
- },
30
- });
31
-
32
- const version = '1.0.0';
33
- await prepare(version, false, logger);
34
-
35
- t.true(execaStub.notCalled);
36
- });
37
-
38
- test('packageVsix is not specified', async (t) => {
39
- const { execaStub } = t.context.stubs;
40
- const { prepare } = await esmock('../lib/prepare.js', {
41
- execa: {
42
- execa: execaStub,
43
- },
44
- });
45
-
46
- const version = '1.0.0';
47
- await prepare(version, undefined, logger);
48
-
49
- t.true(execaStub.notCalled);
50
- });
51
-
52
- test('packageVsix is a string', async (t) => {
53
- const { execaStub } = t.context.stubs;
54
- const { prepare } = await esmock('../lib/prepare.js', {
55
- execa: {
56
- execa: execaStub,
57
- },
58
- });
59
-
60
- const version = '1.0.0';
61
- const packageVsix = 'test.vsix';
62
- const packagePath = packageVsix;
63
- const result = await prepare(version, packageVsix, logger, cwd);
64
-
65
- t.deepEqual(result, packagePath);
66
- t.deepEqual(execaStub.getCall(0).args, [
67
- 'vsce',
68
- ['package', version, '--no-git-tag-version', '--out', packagePath],
69
- { stdio: 'inherit', preferLocal: true, cwd },
70
- ]);
71
- });
72
-
73
- test('packageVsix is true', async (t) => {
74
- const { execaStub } = t.context.stubs;
75
- const name = 'test';
76
-
77
- const { prepare } = await esmock('../lib/prepare.js', {
78
- execa: {
79
- execa: execaStub,
80
- },
81
- 'fs-extra/esm': {
82
- readJson: stub().resolves({
83
- name,
84
- }),
85
- },
86
- });
87
-
88
- const version = '1.0.0';
89
- const packageVsix = true;
90
- const packagePath = `${name}-${version}.vsix`;
91
-
92
- const result = await prepare(version, packageVsix, logger, cwd);
93
-
94
- t.deepEqual(result, packagePath);
95
- t.deepEqual(execaStub.getCall(0).args, [
96
- 'vsce',
97
- ['package', version, '--no-git-tag-version', '--out', packagePath],
98
- { stdio: 'inherit', preferLocal: true, cwd },
99
- ]);
100
- });
101
-
102
- test('packageVsix is not set but OVSX_PAT is', async (t) => {
103
- const { execaStub } = t.context.stubs;
104
- const name = 'test';
105
-
106
- const { prepare } = await esmock('../lib/prepare.js', {
107
- execa: {
108
- execa: execaStub,
109
- },
110
- 'fs-extra/esm': {
111
- readJson: stub().resolves({
112
- name,
113
- }),
114
- },
115
- });
116
-
117
- stub(process, 'env').value({
118
- OVSX_PAT: 'abc123',
119
- });
120
-
121
- const version = '1.0.0';
122
- const packageVsix = undefined;
123
- const packagePath = `${name}-${version}.vsix`;
124
-
125
- const result = await prepare(version, packageVsix, logger, cwd);
126
-
127
- t.deepEqual(result, packagePath);
128
- t.deepEqual(execaStub.getCall(0).args, [
129
- 'vsce',
130
- ['package', version, '--no-git-tag-version', '--out', packagePath],
131
- { stdio: 'inherit', preferLocal: true, cwd },
132
- ]);
133
- });
134
-
135
- test('packageVsix when target is set', async (t) => {
136
- const { execaStub } = t.context.stubs;
137
- const name = 'test';
138
-
139
- const target = 'linux-x64';
140
-
141
- const { prepare } = await esmock('../lib/prepare.js', {
142
- execa: {
143
- execa: execaStub,
144
- },
145
- 'fs-extra/esm': {
146
- readJson: stub().resolves({
147
- name,
148
- }),
149
- },
150
- });
151
-
152
- const version = '1.0.0';
153
-
154
- const packagePath = `${name}-${target}-${version}.vsix`;
155
-
156
- stub(process, 'env').value({
157
- VSCE_TARGET: target,
158
- });
159
-
160
- const result = await prepare(version, true, logger, cwd);
161
-
162
- t.deepEqual(result, packagePath);
163
- t.deepEqual(execaStub.getCall(0).args, [
164
- 'vsce',
165
- [
166
- 'package',
167
- version,
168
- '--no-git-tag-version',
169
- '--out',
170
- packagePath,
171
- '--target',
172
- target,
173
- ],
174
- { stdio: 'inherit', preferLocal: true, cwd },
175
- ]);
176
- });
177
-
178
- test('packageVsix when target is set to universal', async (t) => {
179
- const { execaStub } = t.context.stubs;
180
- const name = 'test';
181
-
182
- const { prepare } = await esmock('../lib/prepare.js', {
183
- execa: {
184
- execa: execaStub,
185
- },
186
- 'fs-extra/esm': {
187
- readJson: stub().resolves({
188
- name,
189
- }),
190
- },
191
- });
192
-
193
- const version = '1.0.0';
194
- const packagePath = `${name}-${version}.vsix`;
195
-
196
- stub(process, 'env').value({
197
- VSCE_TARGET: 'universal',
198
- });
199
-
200
- const result = await prepare(version, true, logger, cwd);
201
-
202
- t.deepEqual(result, packagePath);
203
- t.deepEqual(execaStub.getCall(0).args, [
204
- 'vsce',
205
- ['package', version, '--no-git-tag-version', '--out', packagePath],
206
- { stdio: 'inherit', preferLocal: true, cwd },
207
- ]);
208
- });
@@ -1,367 +0,0 @@
1
- import avaTest from 'ava';
2
- import { fake, stub } from 'sinon';
3
- import esmock from 'esmock';
4
-
5
- // Run tests serially to avoid env pollution
6
- const test = avaTest.serial;
7
-
8
- const logger = {
9
- log: fake(),
10
- };
11
- const cwd = process.cwd();
12
-
13
- test.beforeEach((t) => {
14
- t.context.stubs = {
15
- execaStub: stub(),
16
- };
17
- });
18
-
19
- test.afterEach((t) => {
20
- t.context.stubs.execaStub.resetHistory();
21
- });
22
-
23
- test('publish to vs marketplace with VSCE_PAT', async (t) => {
24
- const { execaStub } = t.context.stubs;
25
- const publisher = 'semantic-release-vsce';
26
- const name = 'Semantice Release VSCE';
27
- const { publish } = await esmock('../lib/publish.js', {
28
- execa: {
29
- execa: execaStub,
30
- },
31
- 'fs-extra/esm': {
32
- readJson: stub().resolves({
33
- publisher,
34
- name,
35
- }),
36
- },
37
- });
38
-
39
- const version = '1.0.0';
40
- const token = 'abc123';
41
- stub(process, 'env').value({
42
- VSCE_PAT: token,
43
- });
44
- const result = await publish(version, undefined, logger, cwd);
45
-
46
- t.deepEqual(result, {
47
- name: 'Visual Studio Marketplace',
48
- url: `https://marketplace.visualstudio.com/items?itemName=${publisher}.${name}`,
49
- });
50
- t.deepEqual(execaStub.getCall(0).args, [
51
- 'vsce',
52
- ['publish', version, '--no-git-tag-version'],
53
- { stdio: 'inherit', preferLocal: true, cwd },
54
- ]);
55
- });
56
-
57
- test('publish to vs marketplace with VSCE_AZURE_CREDENTIAL=true', async (t) => {
58
- const { execaStub } = t.context.stubs;
59
- const publisher = 'semantic-release-vsce';
60
- const name = 'Semantice Release VSCE';
61
- const { publish } = await esmock('../lib/publish.js', {
62
- execa: {
63
- execa: execaStub,
64
- },
65
- 'fs-extra/esm': {
66
- readJson: stub().resolves({
67
- publisher,
68
- name,
69
- }),
70
- },
71
- });
72
-
73
- const version = '1.0.0';
74
- const packagePath = 'test.vsix';
75
- stub(process, 'env').value({
76
- VSCE_AZURE_CREDENTIAL: 'true',
77
- });
78
- const result = await publish(version, packagePath, logger, cwd);
79
-
80
- t.deepEqual(result, {
81
- name: 'Visual Studio Marketplace',
82
- url: `https://marketplace.visualstudio.com/items?itemName=${publisher}.${name}`,
83
- });
84
- const args0 = execaStub.getCall(0).args;
85
- t.deepEqual(args0, [
86
- 'vsce',
87
- ['publish', '--packagePath', packagePath, '--azure-credential'],
88
- { stdio: 'inherit', preferLocal: true, cwd },
89
- ]);
90
- });
91
-
92
- test('publish to vs marketplace with VSCE_AZURE_CREDENTIAL=1', async (t) => {
93
- const { execaStub } = t.context.stubs;
94
- const publisher = 'semantic-release-vsce';
95
- const name = 'Semantice Release VSCE';
96
- const { publish } = await esmock('../lib/publish.js', {
97
- execa: {
98
- execa: execaStub,
99
- },
100
- 'fs-extra/esm': {
101
- readJson: stub().resolves({
102
- publisher,
103
- name,
104
- }),
105
- },
106
- });
107
-
108
- const version = '1.0.0';
109
- const packagePath = 'test.vsix';
110
- stub(process, 'env').value({
111
- VSCE_AZURE_CREDENTIAL: '1',
112
- });
113
- const result = await publish(version, packagePath, logger, cwd);
114
-
115
- t.deepEqual(result, {
116
- name: 'Visual Studio Marketplace',
117
- url: `https://marketplace.visualstudio.com/items?itemName=${publisher}.${name}`,
118
- });
119
- const args0 = execaStub.getCall(0).args;
120
- t.deepEqual(args0, [
121
- 'vsce',
122
- ['publish', '--packagePath', packagePath, '--azure-credential'],
123
- { stdio: 'inherit', preferLocal: true, cwd },
124
- ]);
125
- });
126
-
127
- test('publish with packagePath', async (t) => {
128
- const { execaStub } = t.context.stubs;
129
- const publisher = 'semantic-release-vsce';
130
- const name = 'Semantice Release VSCE';
131
- const { publish } = await esmock('../lib/publish.js', {
132
- execa: {
133
- execa: execaStub,
134
- },
135
- 'fs-extra/esm': {
136
- readJson: stub().resolves({
137
- publisher,
138
- name,
139
- }),
140
- },
141
- });
142
-
143
- const version = '1.0.0';
144
- const packagePath = 'test.vsix';
145
- const token = 'abc123';
146
- stub(process, 'env').value({
147
- VSCE_PAT: token,
148
- });
149
- const result = await publish(version, packagePath, logger, cwd);
150
-
151
- t.deepEqual(result, {
152
- name: 'Visual Studio Marketplace',
153
- url: `https://marketplace.visualstudio.com/items?itemName=${publisher}.${name}`,
154
- });
155
- t.deepEqual(execaStub.getCall(0).args, [
156
- 'vsce',
157
- ['publish', '--packagePath', packagePath],
158
- { stdio: 'inherit', preferLocal: true, cwd },
159
- ]);
160
- });
161
-
162
- test('publish with multiple packagePath', async (t) => {
163
- const { execaStub } = t.context.stubs;
164
- const publisher = 'semantic-release-vsce';
165
- const name = 'Semantice Release VSCE';
166
- const { publish } = await esmock('../lib/publish.js', {
167
- execa: {
168
- execa: execaStub,
169
- },
170
- 'fs-extra/esm': {
171
- readJson: stub().resolves({
172
- publisher,
173
- name,
174
- }),
175
- },
176
- });
177
-
178
- const version = '1.0.0';
179
- const packagePath = ['test.vsix', 'test2.vsix'];
180
- const token = 'abc123';
181
- stub(process, 'env').value({
182
- VSCE_PAT: token,
183
- });
184
- const result = await publish(version, packagePath, logger, cwd);
185
-
186
- t.deepEqual(result, {
187
- name: 'Visual Studio Marketplace',
188
- url: `https://marketplace.visualstudio.com/items?itemName=${publisher}.${name}`,
189
- });
190
- t.deepEqual(execaStub.getCall(0).args, [
191
- 'vsce',
192
- ['publish', '--packagePath', ...packagePath],
193
- { stdio: 'inherit', preferLocal: true, cwd },
194
- ]);
195
- });
196
-
197
- test('publish with target', async (t) => {
198
- const { execaStub } = t.context.stubs;
199
- const publisher = 'semantic-release-vsce';
200
- const name = 'Semantice Release VSCE';
201
- const { publish } = await esmock('../lib/publish.js', {
202
- execa: {
203
- execa: execaStub,
204
- },
205
- 'fs-extra/esm': {
206
- readJson: stub().resolves({
207
- publisher,
208
- name,
209
- }),
210
- },
211
- });
212
-
213
- const version = '1.0.0';
214
- const token = 'abc123';
215
- const target = 'linux-x64';
216
- stub(process, 'env').value({
217
- VSCE_PAT: token,
218
- VSCE_TARGET: target,
219
- });
220
- const result = await publish(version, undefined, logger, cwd);
221
-
222
- t.deepEqual(result, {
223
- name: 'Visual Studio Marketplace',
224
- url: `https://marketplace.visualstudio.com/items?itemName=${publisher}.${name}`,
225
- });
226
- t.deepEqual(execaStub.getCall(0).args, [
227
- 'vsce',
228
- ['publish', version, '--no-git-tag-version', '--target', target],
229
- { stdio: 'inherit', preferLocal: true, cwd },
230
- ]);
231
- });
232
-
233
- test('publish to OpenVSX', async (t) => {
234
- const { execaStub } = t.context.stubs;
235
- const publisher = 'semantic-release-vsce';
236
- const name = 'Semantice Release VSCE';
237
- const { publish } = await esmock('../lib/publish.js', {
238
- execa: {
239
- execa: execaStub,
240
- },
241
- 'fs-extra/esm': {
242
- readJson: stub().resolves({
243
- publisher,
244
- name,
245
- }),
246
- },
247
- });
248
-
249
- const version = '1.0.0';
250
- const packagePath = 'test.vsix';
251
- const token = 'abc123';
252
- stub(process, 'env').value({
253
- OVSX_PAT: token,
254
- VSCE_PAT: token,
255
- });
256
- const result = await publish(version, packagePath, logger, cwd);
257
-
258
- t.deepEqual(result, {
259
- name: 'Visual Studio Marketplace',
260
- url: `https://marketplace.visualstudio.com/items?itemName=${publisher}.${name}`,
261
- });
262
- t.deepEqual(execaStub.getCall(0).args, [
263
- 'vsce',
264
- ['publish', '--packagePath', packagePath],
265
- { stdio: 'inherit', preferLocal: true, cwd },
266
- ]);
267
-
268
- // t.deepEqual(result[1], {
269
- // name: 'Open VSX Registry',
270
- // url: `https://open-vsx.org/extension/${publisher}/${name}/${version}`
271
- // });
272
- t.deepEqual(execaStub.getCall(1).args, [
273
- 'ovsx',
274
- ['publish', '--packagePath', packagePath],
275
- { stdio: 'inherit', preferLocal: true, cwd },
276
- ]);
277
- });
278
-
279
- test('publish to OpenVSX only', async (t) => {
280
- const { execaStub } = t.context.stubs;
281
- const publisher = 'semantic-release-vsce';
282
- const name = 'Semantice Release VSCE';
283
- const { publish } = await esmock('../lib/publish.js', {
284
- execa: {
285
- execa: execaStub,
286
- },
287
- 'fs-extra/esm': {
288
- readJson: stub().resolves({
289
- publisher,
290
- name,
291
- }),
292
- },
293
- });
294
-
295
- const version = '1.0.0';
296
- const packagePath = 'test.vsix';
297
- const token = 'abc123';
298
- stub(process, 'env').value({
299
- OVSX_PAT: token,
300
- });
301
- const result = await publish(version, packagePath, logger, cwd);
302
-
303
- t.deepEqual(result, {
304
- name: 'Open VSX Registry',
305
- url: `https://open-vsx.org/extension/${publisher}/${name}/${version}`,
306
- });
307
- t.true(execaStub.calledOnce);
308
- t.deepEqual(execaStub.getCall(0).args, [
309
- 'ovsx',
310
- ['publish', '--packagePath', packagePath],
311
- { stdio: 'inherit', preferLocal: true, cwd },
312
- ]);
313
- });
314
-
315
- test('should not publish when neither vsce nor ovsx personal access token is configured', async (t) => {
316
- const { execaStub } = t.context.stubs;
317
- const publisher = 'semantic-release-vsce';
318
- const name = 'Semantice Release VSCE';
319
- const { publish } = await esmock('../lib/publish.js', {
320
- execa: {
321
- execa: execaStub,
322
- },
323
- 'fs-extra/esm': {
324
- readJson: stub().resolves({
325
- publisher,
326
- name,
327
- }),
328
- },
329
- });
330
-
331
- const version = '1.0.0';
332
- const packagePath = 'test.vsix';
333
- stub(process, 'env').value({});
334
-
335
- const result = await publish(version, packagePath, logger, cwd);
336
-
337
- t.falsy(result);
338
- t.true(execaStub.notCalled);
339
- });
340
-
341
- test('should not publish if no token and VSCE_AZURE_CREDENTIAL=false', async (t) => {
342
- const { execaStub } = t.context.stubs;
343
- const publisher = 'semantic-release-vsce';
344
- const name = 'Semantice Release VSCE';
345
- const { publish } = await esmock('../lib/publish.js', {
346
- execa: {
347
- execa: execaStub,
348
- },
349
- 'fs-extra/esm': {
350
- readJson: stub().resolves({
351
- publisher,
352
- name,
353
- }),
354
- },
355
- });
356
-
357
- const version = '1.0.0';
358
- const packagePath = 'test.vsix';
359
- stub(process, 'env').value({
360
- VSCE_AZURE_CREDENTIAL: 'false',
361
- });
362
-
363
- const result = await publish(version, packagePath, logger, cwd);
364
-
365
- t.falsy(result);
366
- t.true(execaStub.notCalled);
367
- });
@@ -1,64 +0,0 @@
1
- import avaTest from 'ava';
2
- import { fake, stub } from 'sinon';
3
- import esmock from 'esmock';
4
- import SemanticReleaseError from '@semantic-release/error';
5
-
6
- // Run tests serially to avoid env pollution
7
- const test = avaTest.serial;
8
-
9
- const cwd = process.cwd();
10
-
11
- test('OVSX_PAT is set', async (t) => {
12
- const logger = {
13
- log: fake(),
14
- };
15
-
16
- stub(process, 'env').value({
17
- OVSX_PAT: 'abc123',
18
- });
19
-
20
- const { verifyOvsxAuth } = await esmock('../lib/verify-ovsx-auth.js', {
21
- execa: {
22
- execa: stub()
23
- .withArgs('ovsx', ['verify-pat'], { preferLocal: true, cwd })
24
- .resolves(),
25
- },
26
- });
27
-
28
- await t.notThrowsAsync(() => verifyOvsxAuth(logger));
29
- t.true(logger.log.calledOnce);
30
- });
31
-
32
- test('OVSX_PAT is invalid', async (t) => {
33
- const logger = {
34
- log: fake(),
35
- };
36
-
37
- stub(process, 'env').value({
38
- OVSX_PAT: '',
39
- });
40
-
41
- const { verifyOvsxAuth } = await import('../lib/verify-ovsx-auth.js');
42
-
43
- await t.throwsAsync(() => verifyOvsxAuth(logger), {
44
- instanceOf: SemanticReleaseError,
45
- code: 'EEMPTYOVSXPAT',
46
- });
47
- });
48
-
49
- test('OVSX_PAT is invalid but not empty', async (t) => {
50
- const logger = {
51
- log: fake(),
52
- };
53
-
54
- stub(process, 'env').value({
55
- OVSX_PAT: 'abc123',
56
- });
57
-
58
- const { verifyOvsxAuth } = await import('../lib/verify-ovsx-auth.js');
59
-
60
- await t.throwsAsync(() => verifyOvsxAuth(logger), {
61
- instanceOf: SemanticReleaseError,
62
- code: 'EINVALIDOVSXPAT',
63
- });
64
- });