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.
- package/.github/workflows/ci.yaml +12 -3
- package/README.md +47 -10
- package/eslint.config.js +7 -0
- package/index.js +13 -21
- package/lib/prepare.js +8 -7
- package/lib/publish.js +14 -8
- package/lib/utils.js +17 -13
- package/lib/verify-ovsx-auth.js +5 -4
- package/lib/verify-pkg.js +7 -8
- package/lib/verify-target.js +6 -5
- package/lib/verify-vsce-auth.js +25 -10
- package/lib/verify.js +10 -10
- package/package.json +22 -23
- package/release.config.js +9 -1
- package/test/index.test.js +115 -56
- package/test/prepare.test.js +50 -31
- package/test/publish.test.js +155 -41
- package/test/verify-ovsx-auth.test.js +21 -17
- package/test/verify-pkg.test.js +32 -41
- package/test/verify-target.test.js +20 -17
- package/test/verify-vsce-auth.test.js +123 -29
- package/test/verify.test.js +152 -80
- package/.eslintrc +0 -14
package/test/publish.test.js
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
|
+
import avaTest from 'ava';
|
|
2
|
+
import { fake, stub } from 'sinon';
|
|
3
|
+
import esmock from 'esmock';
|
|
4
|
+
|
|
1
5
|
// Run tests serially to avoid env pollution
|
|
2
|
-
const test =
|
|
3
|
-
const sinon = require('sinon');
|
|
4
|
-
const proxyquire = require('proxyquire');
|
|
6
|
+
const test = avaTest.serial;
|
|
5
7
|
|
|
6
8
|
const logger = {
|
|
7
|
-
log:
|
|
9
|
+
log: fake(),
|
|
8
10
|
};
|
|
9
11
|
const cwd = process.cwd();
|
|
10
12
|
|
|
11
13
|
test.beforeEach((t) => {
|
|
12
14
|
t.context.stubs = {
|
|
13
|
-
execaStub:
|
|
15
|
+
execaStub: stub(),
|
|
14
16
|
};
|
|
15
17
|
});
|
|
16
18
|
|
|
@@ -18,14 +20,16 @@ test.afterEach((t) => {
|
|
|
18
20
|
t.context.stubs.execaStub.resetHistory();
|
|
19
21
|
});
|
|
20
22
|
|
|
21
|
-
test('publish', async (t) => {
|
|
23
|
+
test('publish to vs marketplace with VSCE_PAT', async (t) => {
|
|
22
24
|
const { execaStub } = t.context.stubs;
|
|
23
25
|
const publisher = 'semantic-release-vsce';
|
|
24
26
|
const name = 'Semantice Release VSCE';
|
|
25
|
-
const publish =
|
|
26
|
-
execa:
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
const { publish } = await esmock('../lib/publish.js', {
|
|
28
|
+
execa: {
|
|
29
|
+
execa: execaStub,
|
|
30
|
+
},
|
|
31
|
+
'fs-extra/esm': {
|
|
32
|
+
readJson: stub().resolves({
|
|
29
33
|
publisher,
|
|
30
34
|
name,
|
|
31
35
|
}),
|
|
@@ -34,7 +38,7 @@ test('publish', async (t) => {
|
|
|
34
38
|
|
|
35
39
|
const version = '1.0.0';
|
|
36
40
|
const token = 'abc123';
|
|
37
|
-
|
|
41
|
+
stub(process, 'env').value({
|
|
38
42
|
VSCE_PAT: token,
|
|
39
43
|
});
|
|
40
44
|
const result = await publish(version, undefined, logger, cwd);
|
|
@@ -50,14 +54,86 @@ test('publish', async (t) => {
|
|
|
50
54
|
]);
|
|
51
55
|
});
|
|
52
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
|
+
|
|
53
127
|
test('publish with packagePath', async (t) => {
|
|
54
128
|
const { execaStub } = t.context.stubs;
|
|
55
129
|
const publisher = 'semantic-release-vsce';
|
|
56
130
|
const name = 'Semantice Release VSCE';
|
|
57
|
-
const publish =
|
|
58
|
-
execa:
|
|
59
|
-
|
|
60
|
-
|
|
131
|
+
const { publish } = await esmock('../lib/publish.js', {
|
|
132
|
+
execa: {
|
|
133
|
+
execa: execaStub,
|
|
134
|
+
},
|
|
135
|
+
'fs-extra/esm': {
|
|
136
|
+
readJson: stub().resolves({
|
|
61
137
|
publisher,
|
|
62
138
|
name,
|
|
63
139
|
}),
|
|
@@ -67,7 +143,7 @@ test('publish with packagePath', async (t) => {
|
|
|
67
143
|
const version = '1.0.0';
|
|
68
144
|
const packagePath = 'test.vsix';
|
|
69
145
|
const token = 'abc123';
|
|
70
|
-
|
|
146
|
+
stub(process, 'env').value({
|
|
71
147
|
VSCE_PAT: token,
|
|
72
148
|
});
|
|
73
149
|
const result = await publish(version, packagePath, logger, cwd);
|
|
@@ -87,10 +163,12 @@ test('publish with multiple packagePath', async (t) => {
|
|
|
87
163
|
const { execaStub } = t.context.stubs;
|
|
88
164
|
const publisher = 'semantic-release-vsce';
|
|
89
165
|
const name = 'Semantice Release VSCE';
|
|
90
|
-
const publish =
|
|
91
|
-
execa:
|
|
92
|
-
|
|
93
|
-
|
|
166
|
+
const { publish } = await esmock('../lib/publish.js', {
|
|
167
|
+
execa: {
|
|
168
|
+
execa: execaStub,
|
|
169
|
+
},
|
|
170
|
+
'fs-extra/esm': {
|
|
171
|
+
readJson: stub().resolves({
|
|
94
172
|
publisher,
|
|
95
173
|
name,
|
|
96
174
|
}),
|
|
@@ -100,7 +178,7 @@ test('publish with multiple packagePath', async (t) => {
|
|
|
100
178
|
const version = '1.0.0';
|
|
101
179
|
const packagePath = ['test.vsix', 'test2.vsix'];
|
|
102
180
|
const token = 'abc123';
|
|
103
|
-
|
|
181
|
+
stub(process, 'env').value({
|
|
104
182
|
VSCE_PAT: token,
|
|
105
183
|
});
|
|
106
184
|
const result = await publish(version, packagePath, logger, cwd);
|
|
@@ -120,10 +198,12 @@ test('publish with target', async (t) => {
|
|
|
120
198
|
const { execaStub } = t.context.stubs;
|
|
121
199
|
const publisher = 'semantic-release-vsce';
|
|
122
200
|
const name = 'Semantice Release VSCE';
|
|
123
|
-
const publish =
|
|
124
|
-
execa:
|
|
125
|
-
|
|
126
|
-
|
|
201
|
+
const { publish } = await esmock('../lib/publish.js', {
|
|
202
|
+
execa: {
|
|
203
|
+
execa: execaStub,
|
|
204
|
+
},
|
|
205
|
+
'fs-extra/esm': {
|
|
206
|
+
readJson: stub().resolves({
|
|
127
207
|
publisher,
|
|
128
208
|
name,
|
|
129
209
|
}),
|
|
@@ -133,7 +213,7 @@ test('publish with target', async (t) => {
|
|
|
133
213
|
const version = '1.0.0';
|
|
134
214
|
const token = 'abc123';
|
|
135
215
|
const target = 'linux-x64';
|
|
136
|
-
|
|
216
|
+
stub(process, 'env').value({
|
|
137
217
|
VSCE_PAT: token,
|
|
138
218
|
VSCE_TARGET: target,
|
|
139
219
|
});
|
|
@@ -154,10 +234,12 @@ test('publish to OpenVSX', async (t) => {
|
|
|
154
234
|
const { execaStub } = t.context.stubs;
|
|
155
235
|
const publisher = 'semantic-release-vsce';
|
|
156
236
|
const name = 'Semantice Release VSCE';
|
|
157
|
-
const publish =
|
|
158
|
-
execa:
|
|
159
|
-
|
|
160
|
-
|
|
237
|
+
const { publish } = await esmock('../lib/publish.js', {
|
|
238
|
+
execa: {
|
|
239
|
+
execa: execaStub,
|
|
240
|
+
},
|
|
241
|
+
'fs-extra/esm': {
|
|
242
|
+
readJson: stub().resolves({
|
|
161
243
|
publisher,
|
|
162
244
|
name,
|
|
163
245
|
}),
|
|
@@ -167,7 +249,7 @@ test('publish to OpenVSX', async (t) => {
|
|
|
167
249
|
const version = '1.0.0';
|
|
168
250
|
const packagePath = 'test.vsix';
|
|
169
251
|
const token = 'abc123';
|
|
170
|
-
|
|
252
|
+
stub(process, 'env').value({
|
|
171
253
|
OVSX_PAT: token,
|
|
172
254
|
VSCE_PAT: token,
|
|
173
255
|
});
|
|
@@ -198,10 +280,12 @@ test('publish to OpenVSX only', async (t) => {
|
|
|
198
280
|
const { execaStub } = t.context.stubs;
|
|
199
281
|
const publisher = 'semantic-release-vsce';
|
|
200
282
|
const name = 'Semantice Release VSCE';
|
|
201
|
-
const publish =
|
|
202
|
-
execa:
|
|
203
|
-
|
|
204
|
-
|
|
283
|
+
const { publish } = await esmock('../lib/publish.js', {
|
|
284
|
+
execa: {
|
|
285
|
+
execa: execaStub,
|
|
286
|
+
},
|
|
287
|
+
'fs-extra/esm': {
|
|
288
|
+
readJson: stub().resolves({
|
|
205
289
|
publisher,
|
|
206
290
|
name,
|
|
207
291
|
}),
|
|
@@ -211,7 +295,7 @@ test('publish to OpenVSX only', async (t) => {
|
|
|
211
295
|
const version = '1.0.0';
|
|
212
296
|
const packagePath = 'test.vsix';
|
|
213
297
|
const token = 'abc123';
|
|
214
|
-
|
|
298
|
+
stub(process, 'env').value({
|
|
215
299
|
OVSX_PAT: token,
|
|
216
300
|
});
|
|
217
301
|
const result = await publish(version, packagePath, logger, cwd);
|
|
@@ -232,10 +316,38 @@ test('should not publish when neither vsce nor ovsx personal access token is con
|
|
|
232
316
|
const { execaStub } = t.context.stubs;
|
|
233
317
|
const publisher = 'semantic-release-vsce';
|
|
234
318
|
const name = 'Semantice Release VSCE';
|
|
235
|
-
const publish =
|
|
236
|
-
execa:
|
|
237
|
-
|
|
238
|
-
|
|
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({
|
|
239
351
|
publisher,
|
|
240
352
|
name,
|
|
241
353
|
}),
|
|
@@ -244,7 +356,9 @@ test('should not publish when neither vsce nor ovsx personal access token is con
|
|
|
244
356
|
|
|
245
357
|
const version = '1.0.0';
|
|
246
358
|
const packagePath = 'test.vsix';
|
|
247
|
-
|
|
359
|
+
stub(process, 'env').value({
|
|
360
|
+
VSCE_AZURE_CREDENTIAL: 'false',
|
|
361
|
+
});
|
|
248
362
|
|
|
249
363
|
const result = await publish(version, packagePath, logger, cwd);
|
|
250
364
|
|
|
@@ -1,24 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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;
|
|
5
8
|
|
|
6
9
|
const cwd = process.cwd();
|
|
7
10
|
|
|
8
11
|
test('OVSX_PAT is set', async (t) => {
|
|
9
12
|
const logger = {
|
|
10
|
-
log:
|
|
13
|
+
log: fake(),
|
|
11
14
|
};
|
|
12
15
|
|
|
13
|
-
|
|
16
|
+
stub(process, 'env').value({
|
|
14
17
|
OVSX_PAT: 'abc123',
|
|
15
18
|
});
|
|
16
19
|
|
|
17
|
-
const verifyOvsxAuth =
|
|
18
|
-
execa:
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
+
},
|
|
22
26
|
});
|
|
23
27
|
|
|
24
28
|
await t.notThrowsAsync(() => verifyOvsxAuth(logger));
|
|
@@ -27,14 +31,14 @@ test('OVSX_PAT is set', async (t) => {
|
|
|
27
31
|
|
|
28
32
|
test('OVSX_PAT is invalid', async (t) => {
|
|
29
33
|
const logger = {
|
|
30
|
-
log:
|
|
34
|
+
log: fake(),
|
|
31
35
|
};
|
|
32
36
|
|
|
33
|
-
|
|
37
|
+
stub(process, 'env').value({
|
|
34
38
|
OVSX_PAT: '',
|
|
35
39
|
});
|
|
36
40
|
|
|
37
|
-
const verifyOvsxAuth =
|
|
41
|
+
const { verifyOvsxAuth } = await import('../lib/verify-ovsx-auth.js');
|
|
38
42
|
|
|
39
43
|
await t.throwsAsync(() => verifyOvsxAuth(logger), {
|
|
40
44
|
instanceOf: SemanticReleaseError,
|
|
@@ -44,14 +48,14 @@ test('OVSX_PAT is invalid', async (t) => {
|
|
|
44
48
|
|
|
45
49
|
test('OVSX_PAT is invalid but not empty', async (t) => {
|
|
46
50
|
const logger = {
|
|
47
|
-
log:
|
|
51
|
+
log: fake(),
|
|
48
52
|
};
|
|
49
53
|
|
|
50
|
-
|
|
54
|
+
stub(process, 'env').value({
|
|
51
55
|
OVSX_PAT: 'abc123',
|
|
52
56
|
});
|
|
53
57
|
|
|
54
|
-
const verifyOvsxAuth =
|
|
58
|
+
const { verifyOvsxAuth } = await import('../lib/verify-ovsx-auth.js');
|
|
55
59
|
|
|
56
60
|
await t.throwsAsync(() => verifyOvsxAuth(logger), {
|
|
57
61
|
instanceOf: SemanticReleaseError,
|
package/test/verify-pkg.test.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import avaTest from 'ava';
|
|
2
|
+
import SemanticReleaseError from '@semantic-release/error';
|
|
3
|
+
import { stub } from 'sinon';
|
|
4
|
+
import esmock from 'esmock';
|
|
5
|
+
|
|
6
|
+
// Run tests serially to avoid env pollution
|
|
7
|
+
const test = avaTest.serial;
|
|
5
8
|
|
|
6
9
|
const cwd = process.cwd();
|
|
7
10
|
|
|
@@ -9,12 +12,10 @@ test('package.json is found', async (t) => {
|
|
|
9
12
|
const name = 'test';
|
|
10
13
|
const publisher = 'tester';
|
|
11
14
|
|
|
12
|
-
const verifyPkg =
|
|
13
|
-
fs: {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
'fs-extra': {
|
|
17
|
-
readJson: sinon.stub().returns({
|
|
15
|
+
const { verifyPkg } = await esmock('../lib/verify-pkg.js', {
|
|
16
|
+
'fs-extra/esm': {
|
|
17
|
+
pathExists: stub().resolves(true),
|
|
18
|
+
readJson: stub().resolves({
|
|
18
19
|
name,
|
|
19
20
|
publisher,
|
|
20
21
|
}),
|
|
@@ -28,12 +29,10 @@ test('package.json is not found', async (t) => {
|
|
|
28
29
|
const name = 'test';
|
|
29
30
|
const publisher = 'tester';
|
|
30
31
|
|
|
31
|
-
const verifyPkg =
|
|
32
|
-
fs: {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
'fs-extra': {
|
|
36
|
-
readJson: sinon.stub().returns({
|
|
32
|
+
const { verifyPkg } = await esmock('../lib/verify-pkg.js', {
|
|
33
|
+
'fs-extra/esm': {
|
|
34
|
+
pathExists: stub().resolves(false),
|
|
35
|
+
readJson: stub().resolves({
|
|
37
36
|
name,
|
|
38
37
|
publisher,
|
|
39
38
|
}),
|
|
@@ -49,14 +48,12 @@ test('package.json is not found', async (t) => {
|
|
|
49
48
|
test('package is valid', async (t) => {
|
|
50
49
|
const name = 'test';
|
|
51
50
|
const publisher = 'tester';
|
|
52
|
-
const verifyPkg =
|
|
53
|
-
fs: {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
'fs-extra': {
|
|
57
|
-
readJson: sinon.stub().returns({
|
|
58
|
-
publisher,
|
|
51
|
+
const { verifyPkg } = await esmock('../lib/verify-pkg.js', {
|
|
52
|
+
'fs-extra/esm': {
|
|
53
|
+
pathExists: stub().resolves(true),
|
|
54
|
+
readJson: stub().resolves({
|
|
59
55
|
name,
|
|
56
|
+
publisher,
|
|
60
57
|
}),
|
|
61
58
|
},
|
|
62
59
|
});
|
|
@@ -65,12 +62,10 @@ test('package is valid', async (t) => {
|
|
|
65
62
|
});
|
|
66
63
|
|
|
67
64
|
test('package is invalid', async (t) => {
|
|
68
|
-
const verifyPkg =
|
|
69
|
-
fs: {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
'fs-extra': {
|
|
73
|
-
readJson: sinon.stub().rejects(),
|
|
65
|
+
const { verifyPkg } = await esmock('../lib/verify-pkg.js', {
|
|
66
|
+
'fs-extra/esm': {
|
|
67
|
+
pathExists: stub().resolves(true),
|
|
68
|
+
readJson: stub().rejects(),
|
|
74
69
|
},
|
|
75
70
|
});
|
|
76
71
|
|
|
@@ -82,12 +77,10 @@ test('package is invalid', async (t) => {
|
|
|
82
77
|
|
|
83
78
|
test('package is missing name', async (t) => {
|
|
84
79
|
const publisher = 'tester';
|
|
85
|
-
const verifyPkg =
|
|
86
|
-
fs: {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
'fs-extra': {
|
|
90
|
-
readJson: sinon.stub().returns({
|
|
80
|
+
const { verifyPkg } = await esmock('../lib/verify-pkg.js', {
|
|
81
|
+
'fs-extra/esm': {
|
|
82
|
+
pathExists: stub().resolves(true),
|
|
83
|
+
readJson: stub().resolves({
|
|
91
84
|
publisher,
|
|
92
85
|
}),
|
|
93
86
|
},
|
|
@@ -101,12 +94,10 @@ test('package is missing name', async (t) => {
|
|
|
101
94
|
|
|
102
95
|
test('package is missing publisher', async (t) => {
|
|
103
96
|
const name = 'test';
|
|
104
|
-
const verifyPkg =
|
|
105
|
-
fs: {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
'fs-extra': {
|
|
109
|
-
readJson: sinon.stub().returns({
|
|
97
|
+
const { verifyPkg } = await esmock('../lib/verify-pkg.js', {
|
|
98
|
+
'fs-extra/esm': {
|
|
99
|
+
pathExists: stub().resolves(true),
|
|
100
|
+
readJson: stub().resolves({
|
|
110
101
|
name,
|
|
111
102
|
}),
|
|
112
103
|
},
|
|
@@ -1,37 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import SemanticReleaseError from '@semantic-release/error';
|
|
2
|
+
import avaTest from 'ava';
|
|
3
|
+
import esmock from 'esmock';
|
|
4
|
+
import { stub } from 'sinon';
|
|
5
|
+
|
|
6
|
+
// Run tests serially to avoid env pollution
|
|
7
|
+
const test = avaTest.serial;
|
|
5
8
|
|
|
6
9
|
test('VSCE_TARGET is not set', async (t) => {
|
|
7
|
-
const vscePackage =
|
|
10
|
+
const vscePackage = stub().returns({
|
|
8
11
|
Targets: new Map(),
|
|
9
12
|
});
|
|
10
|
-
const verifyTarget =
|
|
11
|
-
'vsce/out/package': vscePackage,
|
|
13
|
+
const { verifyTarget } = await esmock('../lib/verify-target.js', {
|
|
14
|
+
'@vscode/vsce/out/package.js': vscePackage,
|
|
12
15
|
});
|
|
13
16
|
|
|
14
17
|
await t.notThrowsAsync(() => verifyTarget());
|
|
15
18
|
});
|
|
16
19
|
|
|
17
20
|
test('VSCE_TARGET is valid', async (t) => {
|
|
18
|
-
|
|
21
|
+
stub(process, 'env').value({
|
|
19
22
|
VSCE_TARGET: 'linux-x64',
|
|
20
23
|
});
|
|
21
24
|
|
|
22
|
-
const verifyTarget =
|
|
25
|
+
const { verifyTarget } = await import('../lib/verify-target.js');
|
|
23
26
|
|
|
24
27
|
await t.notThrowsAsync(() => verifyTarget());
|
|
25
28
|
});
|
|
26
29
|
|
|
27
30
|
test('VSCE_TARGET is empty', async (t) => {
|
|
28
|
-
const vscePackage =
|
|
31
|
+
const vscePackage = stub().returns({
|
|
29
32
|
Targets: new Map(),
|
|
30
33
|
});
|
|
31
|
-
const verifyTarget =
|
|
32
|
-
'vsce/out/package': vscePackage,
|
|
34
|
+
const { verifyTarget } = await esmock('../lib/verify-target.js', {
|
|
35
|
+
'@vscode/vsce/out/package.js': vscePackage,
|
|
33
36
|
});
|
|
34
|
-
|
|
37
|
+
stub(process, 'env').value({
|
|
35
38
|
VSCE_TARGET: '',
|
|
36
39
|
});
|
|
37
40
|
|
|
@@ -43,10 +46,10 @@ test('VSCE_TARGET is empty', async (t) => {
|
|
|
43
46
|
});
|
|
44
47
|
|
|
45
48
|
test('VSCE_TARGET is unsupported', async (t) => {
|
|
46
|
-
|
|
49
|
+
stub(process, 'env').value({
|
|
47
50
|
VSCE_TARGET: 'whatever-x64',
|
|
48
51
|
});
|
|
49
|
-
const verifyTarget =
|
|
52
|
+
const { verifyTarget } = await import('../lib/verify-target.js');
|
|
50
53
|
|
|
51
54
|
await t.throwsAsync(() => verifyTarget(), {
|
|
52
55
|
instanceOf: SemanticReleaseError,
|
|
@@ -55,11 +58,11 @@ test('VSCE_TARGET is unsupported', async (t) => {
|
|
|
55
58
|
});
|
|
56
59
|
|
|
57
60
|
test('VSCE_TARGET is universal', async (t) => {
|
|
58
|
-
|
|
61
|
+
stub(process, 'env').value({
|
|
59
62
|
VSCE_TARGET: 'universal',
|
|
60
63
|
});
|
|
61
64
|
|
|
62
|
-
const verifyTarget =
|
|
65
|
+
const { verifyTarget } = await import('../lib/verify-target.js');
|
|
63
66
|
|
|
64
67
|
await t.notThrowsAsync(() => verifyTarget());
|
|
65
68
|
});
|