semantic-release-vsce 5.7.3 → 6.0.0

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,13 +1,17 @@
1
- const test = require('ava').serial;
2
- const sinon = require('sinon');
3
- const proxyquire = require('proxyquire');
1
+ import avaTest from 'ava';
2
+ import esmock from 'esmock';
3
+ import { resolve } from 'path';
4
+ import { fake, stub } from 'sinon';
5
+
6
+ // Run tests serially to avoid env pollution
7
+ const test = avaTest.serial;
4
8
 
5
9
  const semanticReleasePayload = {
6
10
  nextRelease: {
7
11
  version: '1.0.0',
8
12
  },
9
13
  logger: {
10
- log: sinon.fake(),
14
+ log: fake(),
11
15
  },
12
16
  cwd: process.cwd(),
13
17
  };
@@ -18,9 +22,9 @@ const pluginConfig = {
18
22
 
19
23
  test.beforeEach((t) => {
20
24
  t.context.stubs = {
21
- verifyVsceStub: sinon.stub().resolves(),
22
- vscePublishStub: sinon.stub().resolves(),
23
- vscePrepareStub: sinon.stub().resolves(),
25
+ verifyVsceStub: stub().resolves(),
26
+ vscePublishStub: stub().resolves(),
27
+ vscePrepareStub: stub().resolves(),
24
28
  };
25
29
  });
26
30
 
@@ -32,10 +36,16 @@ test.afterEach((t) => {
32
36
 
33
37
  test('verifyConditions', async (t) => {
34
38
  const { verifyVsceStub, vscePrepareStub, vscePublishStub } = t.context.stubs;
35
- const { verifyConditions } = proxyquire('../index.js', {
36
- './lib/verify': verifyVsceStub,
37
- './lib/publish': vscePublishStub,
38
- './lib/prepare': vscePrepareStub,
39
+ const { verifyConditions } = await esmock('../index.js', {
40
+ '../lib/verify.js': {
41
+ verify: verifyVsceStub,
42
+ },
43
+ '../lib/prepare.js': {
44
+ prepare: vscePrepareStub,
45
+ },
46
+ '../lib/publish.js': {
47
+ publish: vscePublishStub,
48
+ },
39
49
  });
40
50
 
41
51
  await verifyConditions(pluginConfig, semanticReleasePayload);
@@ -50,11 +60,16 @@ test('verifyConditions', async (t) => {
50
60
 
51
61
  test('prepare and unverified', async (t) => {
52
62
  const { verifyVsceStub, vscePrepareStub, vscePublishStub } = t.context.stubs;
53
- const { prepare } = proxyquire('../index.js', {
54
- './lib/verify': verifyVsceStub,
55
- './lib/publish': vscePublishStub,
56
- './lib/prepare': vscePrepareStub,
57
- verified: false,
63
+ const { prepare } = await esmock('../index.js', {
64
+ '../lib/verify.js': {
65
+ verify: verifyVsceStub,
66
+ },
67
+ '../lib/prepare.js': {
68
+ prepare: vscePrepareStub,
69
+ },
70
+ '../lib/publish.js': {
71
+ publish: vscePublishStub,
72
+ },
58
73
  });
59
74
 
60
75
  await prepare(pluginConfig, semanticReleasePayload);
@@ -75,10 +90,16 @@ test('prepare and unverified', async (t) => {
75
90
 
76
91
  test('prepare and verified', async (t) => {
77
92
  const { verifyVsceStub, vscePrepareStub, vscePublishStub } = t.context.stubs;
78
- const { prepare, verifyConditions } = proxyquire('../index.js', {
79
- './lib/verify': verifyVsceStub,
80
- './lib/publish': vscePublishStub,
81
- './lib/prepare': vscePrepareStub,
93
+ const { prepare, verifyConditions } = await esmock('../index.js', {
94
+ '../lib/verify.js': {
95
+ verify: verifyVsceStub,
96
+ },
97
+ '../lib/prepare.js': {
98
+ prepare: vscePrepareStub,
99
+ },
100
+ '../lib/publish.js': {
101
+ publish: vscePublishStub,
102
+ },
82
103
  });
83
104
 
84
105
  await verifyConditions(pluginConfig, semanticReleasePayload);
@@ -95,10 +116,16 @@ test('prepare and verified', async (t) => {
95
116
 
96
117
  test('publish that is unverified and unprepared', async (t) => {
97
118
  const { verifyVsceStub, vscePrepareStub, vscePublishStub } = t.context.stubs;
98
- const { publish } = proxyquire('../index.js', {
99
- './lib/verify': verifyVsceStub,
100
- './lib/publish': vscePublishStub,
101
- './lib/prepare': vscePrepareStub,
119
+ const { publish } = await esmock('../index.js', {
120
+ '../lib/verify.js': {
121
+ verify: verifyVsceStub,
122
+ },
123
+ '../lib/prepare.js': {
124
+ prepare: vscePrepareStub,
125
+ },
126
+ '../lib/publish.js': {
127
+ publish: vscePublishStub,
128
+ },
102
129
  });
103
130
 
104
131
  await publish(pluginConfig, semanticReleasePayload);
@@ -115,10 +142,16 @@ test('publish that is unverified and unprepared', async (t) => {
115
142
 
116
143
  test('publish that is verified but unprepared', async (t) => {
117
144
  const { verifyVsceStub, vscePrepareStub, vscePublishStub } = t.context.stubs;
118
- const { publish, verifyConditions } = proxyquire('../index.js', {
119
- './lib/verify': verifyVsceStub,
120
- './lib/publish': vscePublishStub,
121
- './lib/prepare': vscePrepareStub,
145
+ const { publish, verifyConditions } = await esmock('../index.js', {
146
+ '../lib/verify.js': {
147
+ verify: verifyVsceStub,
148
+ },
149
+ '../lib/prepare.js': {
150
+ prepare: vscePrepareStub,
151
+ },
152
+ '../lib/publish.js': {
153
+ publish: vscePublishStub,
154
+ },
122
155
  });
123
156
 
124
157
  await verifyConditions(pluginConfig, semanticReleasePayload);
@@ -136,10 +169,16 @@ test('publish that is verified but unprepared', async (t) => {
136
169
 
137
170
  test('publish that is already verified & prepared', async (t) => {
138
171
  const { verifyVsceStub, vscePrepareStub, vscePublishStub } = t.context.stubs;
139
- const { prepare, publish, verifyConditions } = proxyquire('../index.js', {
140
- './lib/verify': verifyVsceStub,
141
- './lib/publish': vscePublishStub,
142
- './lib/prepare': vscePrepareStub,
172
+ const { prepare, publish, verifyConditions } = await esmock('../index.js', {
173
+ '../lib/verify.js': {
174
+ verify: verifyVsceStub,
175
+ },
176
+ '../lib/prepare.js': {
177
+ prepare: vscePrepareStub,
178
+ },
179
+ '../lib/publish.js': {
180
+ publish: vscePublishStub,
181
+ },
143
182
  });
144
183
 
145
184
  await verifyConditions(pluginConfig, semanticReleasePayload);
@@ -158,10 +197,16 @@ test('publish that is already verified & prepared', async (t) => {
158
197
 
159
198
  test('it does not publish the package if publishing is disabled', async (t) => {
160
199
  const { verifyVsceStub, vscePrepareStub, vscePublishStub } = t.context.stubs;
161
- const { prepare, publish, verifyConditions } = proxyquire('../index.js', {
162
- './lib/verify': verifyVsceStub,
163
- './lib/publish': vscePublishStub,
164
- './lib/prepare': vscePrepareStub,
200
+ const { prepare, publish, verifyConditions } = await esmock('../index.js', {
201
+ '../lib/verify.js': {
202
+ verify: verifyVsceStub,
203
+ },
204
+ '../lib/prepare.js': {
205
+ prepare: vscePrepareStub,
206
+ },
207
+ '../lib/publish.js': {
208
+ publish: vscePublishStub,
209
+ },
165
210
  });
166
211
 
167
212
  await verifyConditions(
@@ -176,14 +221,20 @@ test('it does not publish the package if publishing is disabled', async (t) => {
176
221
 
177
222
  test('it can publish when `OVSX_PAT` is present but `VSCE_PAT` is missing', async (t) => {
178
223
  const token = 'abc123';
179
- sinon.stub(process, 'env').value({
224
+ stub(process, 'env').value({
180
225
  OVSX_PAT: token,
181
226
  });
182
227
  const { verifyVsceStub, vscePrepareStub, vscePublishStub } = t.context.stubs;
183
- const { prepare, publish, verifyConditions } = proxyquire('../index.js', {
184
- './lib/verify': verifyVsceStub,
185
- './lib/publish': vscePublishStub,
186
- './lib/prepare': vscePrepareStub,
228
+ const { prepare, publish, verifyConditions } = await esmock('../index.js', {
229
+ '../lib/verify.js': {
230
+ verify: verifyVsceStub,
231
+ },
232
+ '../lib/prepare.js': {
233
+ prepare: vscePrepareStub,
234
+ },
235
+ '../lib/publish.js': {
236
+ publish: vscePublishStub,
237
+ },
187
238
  });
188
239
 
189
240
  await verifyConditions({ ...pluginConfig }, semanticReleasePayload);
@@ -202,14 +253,18 @@ test('it can publish when `OVSX_PAT` is present but `VSCE_PAT` is missing', asyn
202
253
 
203
254
  test('expand globs if publishPackagePath is set', async (t) => {
204
255
  const { verifyVsceStub, vscePrepareStub, vscePublishStub } = t.context.stubs;
205
- const { publish } = proxyquire('../index.js', {
206
- './lib/verify': verifyVsceStub,
207
- './lib/publish': vscePublishStub,
208
- './lib/prepare': vscePrepareStub,
256
+ const { publish } = await esmock.p('../index.js', {
257
+ '../lib/verify.js': {
258
+ verify: verifyVsceStub,
259
+ },
260
+ '../lib/prepare.js': {
261
+ prepare: vscePrepareStub,
262
+ },
263
+ '../lib/publish.js': {
264
+ publish: vscePublishStub,
265
+ },
209
266
  glob: {
210
- glob: {
211
- sync: sinon.stub().returns(['package1.vsix', 'package2.vsix']),
212
- },
267
+ glob: stub().resolves(['package1.vsix', 'package2.vsix']),
213
268
  },
214
269
  });
215
270
 
@@ -232,21 +287,25 @@ test('expand globs if publishPackagePath is set', async (t) => {
232
287
 
233
288
  test('publishes an extension in a non-root folder', async (t) => {
234
289
  const { verifyVsceStub, vscePrepareStub, vscePublishStub } = t.context.stubs;
235
- const { publish } = proxyquire('../index.js', {
236
- './lib/verify': verifyVsceStub,
237
- './lib/publish': vscePublishStub,
238
- './lib/prepare': vscePrepareStub,
290
+ const { publish } = await esmock.p('../index.js', {
291
+ '../lib/verify.js': {
292
+ verify: verifyVsceStub,
293
+ },
294
+ '../lib/prepare.js': {
295
+ prepare: vscePrepareStub,
296
+ },
297
+ '../lib/publish.js': {
298
+ publish: vscePublishStub,
299
+ },
239
300
  glob: {
240
- glob: {
241
- sync: sinon.stub().returns(['package1.vsix', 'package2.vsix']),
242
- },
301
+ glob: stub().resolves(['package1.vsix', 'package2.vsix']),
243
302
  },
244
303
  });
245
304
 
246
305
  const pluginConfig = {
247
306
  packageRoot: './vscode-extension',
248
307
  };
249
- const resolvedCwd = `${semanticReleasePayload.cwd}/vscode-extension`;
308
+ const resolvedCwd = resolve(`${semanticReleasePayload.cwd}/vscode-extension`);
250
309
 
251
310
  await publish(pluginConfig, semanticReleasePayload);
252
311
 
@@ -1,16 +1,19 @@
1
+ import avaTest from 'ava';
2
+ import { fake, stub } from 'sinon';
3
+ import esmock from 'esmock';
4
+ import process from 'node:process';
5
+
1
6
  // Run tests serially to avoid env pollution
2
- const test = require('ava').serial;
3
- const sinon = require('sinon');
4
- const proxyquire = require('proxyquire');
7
+ const test = avaTest.serial;
5
8
 
6
9
  const logger = {
7
- log: sinon.fake(),
10
+ log: fake(),
8
11
  };
9
12
  const cwd = process.cwd();
10
13
 
11
14
  test.beforeEach((t) => {
12
15
  t.context.stubs = {
13
- execaStub: sinon.stub(),
16
+ execaStub: stub().resolves(),
14
17
  };
15
18
  });
16
19
 
@@ -20,8 +23,10 @@ test.afterEach((t) => {
20
23
 
21
24
  test('packageVsix is disabled', async (t) => {
22
25
  const { execaStub } = t.context.stubs;
23
- const prepare = proxyquire('../lib/prepare', {
24
- execa: execaStub,
26
+ const { prepare } = await esmock('../lib/prepare.js', {
27
+ execa: {
28
+ execa: execaStub,
29
+ },
25
30
  });
26
31
 
27
32
  const version = '1.0.0';
@@ -32,8 +37,10 @@ test('packageVsix is disabled', async (t) => {
32
37
 
33
38
  test('packageVsix is not specified', async (t) => {
34
39
  const { execaStub } = t.context.stubs;
35
- const prepare = proxyquire('../lib/prepare', {
36
- execa: execaStub,
40
+ const { prepare } = await esmock('../lib/prepare.js', {
41
+ execa: {
42
+ execa: execaStub,
43
+ },
37
44
  });
38
45
 
39
46
  const version = '1.0.0';
@@ -44,8 +51,10 @@ test('packageVsix is not specified', async (t) => {
44
51
 
45
52
  test('packageVsix is a string', async (t) => {
46
53
  const { execaStub } = t.context.stubs;
47
- const prepare = proxyquire('../lib/prepare', {
48
- execa: execaStub,
54
+ const { prepare } = await esmock('../lib/prepare.js', {
55
+ execa: {
56
+ execa: execaStub,
57
+ },
49
58
  });
50
59
 
51
60
  const version = '1.0.0';
@@ -65,10 +74,12 @@ test('packageVsix is true', async (t) => {
65
74
  const { execaStub } = t.context.stubs;
66
75
  const name = 'test';
67
76
 
68
- const prepare = proxyquire('../lib/prepare', {
69
- execa: execaStub,
70
- 'fs-extra': {
71
- readJson: sinon.stub().returns({
77
+ const { prepare } = await esmock('../lib/prepare.js', {
78
+ execa: {
79
+ execa: execaStub,
80
+ },
81
+ 'fs-extra/esm': {
82
+ readJson: stub().resolves({
72
83
  name,
73
84
  }),
74
85
  },
@@ -92,16 +103,18 @@ test('packageVsix is not set but OVSX_PAT is', async (t) => {
92
103
  const { execaStub } = t.context.stubs;
93
104
  const name = 'test';
94
105
 
95
- const prepare = proxyquire('../lib/prepare', {
96
- execa: execaStub,
97
- 'fs-extra': {
98
- readJson: sinon.stub().returns({
106
+ const { prepare } = await esmock('../lib/prepare.js', {
107
+ execa: {
108
+ execa: execaStub,
109
+ },
110
+ 'fs-extra/esm': {
111
+ readJson: stub().resolves({
99
112
  name,
100
113
  }),
101
114
  },
102
115
  });
103
116
 
104
- sinon.stub(process, 'env').value({
117
+ stub(process, 'env').value({
105
118
  OVSX_PAT: 'abc123',
106
119
  });
107
120
 
@@ -123,20 +136,24 @@ test('packageVsix when target is set', async (t) => {
123
136
  const { execaStub } = t.context.stubs;
124
137
  const name = 'test';
125
138
 
126
- const prepare = proxyquire('../lib/prepare', {
127
- execa: execaStub,
128
- 'fs-extra': {
129
- readJson: sinon.stub().returns({
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({
130
147
  name,
131
148
  }),
132
149
  },
133
150
  });
134
151
 
135
152
  const version = '1.0.0';
136
- const target = 'linux-x64';
153
+
137
154
  const packagePath = `${name}-${target}-${version}.vsix`;
138
155
 
139
- sinon.stub(process, 'env').value({
156
+ stub(process, 'env').value({
140
157
  VSCE_TARGET: target,
141
158
  });
142
159
 
@@ -162,10 +179,12 @@ test('packageVsix when target is set to universal', async (t) => {
162
179
  const { execaStub } = t.context.stubs;
163
180
  const name = 'test';
164
181
 
165
- const prepare = proxyquire('../lib/prepare', {
166
- execa: execaStub,
167
- 'fs-extra': {
168
- readJson: sinon.stub().returns({
182
+ const { prepare } = await esmock('../lib/prepare.js', {
183
+ execa: {
184
+ execa: execaStub,
185
+ },
186
+ 'fs-extra/esm': {
187
+ readJson: stub().resolves({
169
188
  name,
170
189
  }),
171
190
  },
@@ -174,7 +193,7 @@ test('packageVsix when target is set to universal', async (t) => {
174
193
  const version = '1.0.0';
175
194
  const packagePath = `${name}-${version}.vsix`;
176
195
 
177
- sinon.stub(process, 'env').value({
196
+ stub(process, 'env').value({
178
197
  VSCE_TARGET: 'universal',
179
198
  });
180
199