semantic-release-vsce 5.7.4 → 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,70 +1,144 @@
1
- const test = require('ava').serial;
2
- const sinon = require('sinon');
3
- const proxyquire = require('proxyquire');
4
- const SemanticReleaseError = require('@semantic-release/error');
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 logger = {
7
- log: sinon.fake(),
10
+ log: fake(),
8
11
  };
9
12
  const cwd = process.cwd();
10
13
 
11
14
  test('VSCE_PAT is set', async (t) => {
12
- sinon.stub(process, 'env').value({
15
+ stub(process, 'env').value({
13
16
  VSCE_PAT: 'abc123',
14
17
  });
15
18
 
16
- const verifyVsceAuth = proxyquire('../lib/verify-vsce-auth', {
17
- execa: sinon
18
- .stub()
19
- .withArgs('vsce', ['verify-pat'], { preferLocal: true, cwd })
20
- .resolves(),
19
+ const { verifyVsceAuth } = await esmock('../lib/verify-vsce-auth.js', {
20
+ execa: {
21
+ execa: stub()
22
+ .withArgs('vsce', ['verify-pat'], { preferLocal: true, cwd })
23
+ .resolves(),
24
+ },
21
25
  });
22
26
 
23
27
  await t.notThrowsAsync(() => verifyVsceAuth(logger));
24
28
  });
25
29
 
30
+ test('VSCE_AZURE_CREDENTIAL is set to true', async (t) => {
31
+ stub(process, 'env').value({
32
+ VSCE_AZURE_CREDENTIAL: 'true',
33
+ });
34
+
35
+ const { verifyVsceAuth } = await esmock('../lib/verify-vsce-auth.js', {
36
+ execa: {
37
+ execa: stub()
38
+ .withArgs('vsce', ['verify-pat', '--azure-credential'], {
39
+ preferLocal: true,
40
+ cwd,
41
+ })
42
+ .resolves(),
43
+ },
44
+ });
45
+
46
+ await t.notThrowsAsync(() => verifyVsceAuth(logger));
47
+ });
48
+
49
+ test('VSCE_AZURE_CREDENTIAL is set to 1', async (t) => {
50
+ stub(process, 'env').value({
51
+ VSCE_AZURE_CREDENTIAL: '1',
52
+ });
53
+
54
+ const { verifyVsceAuth } = await esmock('../lib/verify-vsce-auth.js', {
55
+ execa: {
56
+ execa: stub()
57
+ .withArgs('vsce', ['verify-pat', '--azure-credential'], {
58
+ preferLocal: true,
59
+ cwd,
60
+ })
61
+ .resolves(),
62
+ },
63
+ });
64
+
65
+ await t.notThrowsAsync(() => verifyVsceAuth(logger));
66
+ });
67
+
68
+ test('VSCE_AZURE_CREDENTIAL is set to false', async (t) => {
69
+ stub(process, 'env').value({
70
+ VSCE_AZURE_CREDENTIAL: 'false',
71
+ });
72
+
73
+ const { verifyVsceAuth } = await import('../lib/verify-vsce-auth.js');
74
+
75
+ await t.throwsAsync(() => verifyVsceAuth(logger), {
76
+ instanceOf: SemanticReleaseError,
77
+ code: 'EVSCEAUTHNOTPROVIDED',
78
+ });
79
+ });
80
+
26
81
  test('VSCE_PAT is valid', async (t) => {
27
- sinon.stub(process, 'env').value({
82
+ stub(process, 'env').value({
28
83
  VSCE_PAT: 'abc123',
29
84
  });
30
85
 
31
- const verifyVsceAuth = proxyquire('../lib/verify-vsce-auth', {
32
- execa: sinon
33
- .stub()
34
- .withArgs('vsce', ['verify-pat'], { preferLocal: true, cwd })
35
- .resolves(),
86
+ const { verifyVsceAuth } = await esmock('../lib/verify-vsce-auth.js', {
87
+ execa: {
88
+ execa: stub()
89
+ .withArgs('vsce', ['verify-pat'], { preferLocal: true, cwd })
90
+ .resolves(),
91
+ },
36
92
  });
37
93
 
38
94
  await t.notThrowsAsync(() => verifyVsceAuth(logger));
39
95
  });
40
96
 
41
- test('VSCE_PAT is invalid', async (t) => {
97
+ test('VSCE_PAT is valid and VSCE_AZURE_CREDENTIAL=false', async (t) => {
98
+ stub(process, 'env').value({
99
+ VSCE_PAT: 'abc123',
100
+ VSCE_AZURE_CREDENTIAL: 'false',
101
+ });
102
+
103
+ const { verifyVsceAuth } = await esmock('../lib/verify-vsce-auth.js', {
104
+ execa: {
105
+ execa: stub()
106
+ .withArgs('vsce', ['verify-pat'], { preferLocal: true, cwd })
107
+ .resolves(),
108
+ },
109
+ });
110
+
111
+ await t.notThrowsAsync(() => verifyVsceAuth(logger));
112
+ });
113
+
114
+ test('Neither VSCE_PAT or VSCE_AZURE_CREDENTIAL are set', async (t) => {
42
115
  const logger = {
43
- log: sinon.fake(),
116
+ log: fake(),
44
117
  };
45
118
 
46
- sinon.stub(process, 'env').value({
119
+ stub(process, 'env').value({
47
120
  VSCE_PAT: '',
48
121
  });
49
122
 
50
- const verifyOvsxAuth = require('../lib/verify-vsce-auth');
123
+ const { verifyVsceAuth } = await import('../lib/verify-vsce-auth.js');
51
124
 
52
- await t.throwsAsync(() => verifyOvsxAuth(logger), {
125
+ await t.throwsAsync(() => verifyVsceAuth(logger), {
53
126
  instanceOf: SemanticReleaseError,
54
- code: 'EEMPTYVSCEPAT',
127
+ code: 'EVSCEAUTHNOTPROVIDED',
55
128
  });
56
129
  });
57
130
 
58
131
  test('VSCE_PAT is invalid but not empty', async (t) => {
59
- sinon.stub(process, 'env').value({
132
+ stub(process, 'env').value({
60
133
  VSCE_PAT: 'abc123',
61
134
  });
62
135
 
63
- const verifyVsceAuth = proxyquire('../lib/verify-vsce-auth', {
64
- execa: sinon
65
- .stub()
66
- .withArgs('vsce', ['verify-pat'], { preferLocal: true, cwd })
67
- .rejects(),
136
+ const { verifyVsceAuth } = await esmock('../lib/verify-vsce-auth.js', {
137
+ execa: {
138
+ execa: stub()
139
+ .withArgs('vsce', ['verify-pat'], { preferLocal: true, cwd })
140
+ .rejects(),
141
+ },
68
142
  });
69
143
 
70
144
  await t.throwsAsync(() => verifyVsceAuth(logger), {
@@ -72,3 +146,23 @@ test('VSCE_PAT is invalid but not empty', async (t) => {
72
146
  code: 'EINVALIDVSCEPAT',
73
147
  });
74
148
  });
149
+
150
+ test('Both VSCE_PAT and VSCE_AZURE_CREDENTIAL are set', async (t) => {
151
+ stub(process, 'env').value({
152
+ VSCE_PAT: 'abc123',
153
+ VSCE_AZURE_CREDENTIAL: 'true',
154
+ });
155
+
156
+ const { verifyVsceAuth } = await esmock('../lib/verify-vsce-auth.js', {
157
+ execa: {
158
+ execa: stub()
159
+ .withArgs('vsce', ['verify-pat'], { preferLocal: true, cwd })
160
+ .rejects(),
161
+ },
162
+ });
163
+
164
+ await t.throwsAsync(() => verifyVsceAuth(logger), {
165
+ instanceOf: SemanticReleaseError,
166
+ code: 'EVSCEDUPLICATEAUTHPROVIDED',
167
+ });
168
+ });
@@ -1,22 +1,30 @@
1
- const SemanticReleaseError = require('@semantic-release/error');
2
- const test = require('ava');
3
- const sinon = require('sinon');
4
- const proxyquire = require('proxyquire');
1
+ import SemanticReleaseError from '@semantic-release/error';
2
+ import test from 'ava';
3
+ import { fake, stub } from 'sinon';
4
+ import esmock from 'esmock';
5
5
 
6
6
  const logger = {
7
- log: sinon.fake(),
7
+ log: fake(),
8
8
  };
9
9
  const cwd = process.cwd();
10
10
 
11
11
  test('resolves', async (t) => {
12
- const verify = proxyquire('../lib/verify', {
13
- './verify-pkg': sinon.stub().resolves(),
14
- './verify-target': sinon.stub().resolves(),
15
- './verify-vsce-auth': sinon.stub().resolves(),
16
- './verify-ovsx-auth': sinon.stub().resolves(),
17
- './utils': {
18
- isVscePublishEnabled: sinon.stub().returns(true),
19
- isOvsxPublishEnabled: sinon.stub().returns(true),
12
+ const { verify } = await esmock('../lib/verify.js', {
13
+ '../lib/verify-pkg.js': {
14
+ verifyPkg: stub().resolves(),
15
+ },
16
+ '../lib/verify-target.js': {
17
+ verifyTarget: stub().resolves(),
18
+ },
19
+ '../lib/verify-vsce-auth.js': {
20
+ verifyVsceAuth: stub().resolves(),
21
+ },
22
+ '../lib/verify-ovsx-auth.js': {
23
+ verifyOvsxAuth: stub().resolves(),
24
+ },
25
+ '../lib/utils.js': {
26
+ isVscePublishEnabled: stub().returns(true),
27
+ isOvsxPublishEnabled: stub().returns(true),
20
28
  },
21
29
  });
22
30
 
@@ -24,44 +32,76 @@ test('resolves', async (t) => {
24
32
  });
25
33
 
26
34
  test('rejects with verify-pkg', async (t) => {
27
- const verify = proxyquire('../lib/verify', {
28
- './verify-pkg': sinon.stub().rejects(),
29
- './verify-target': sinon.stub().resolves(),
30
- './verify-vsce-auth': sinon.stub().resolves(),
31
- './verify-ovsx-auth': sinon.stub().resolves(),
35
+ const { verify } = await esmock('../lib/verify.js', {
36
+ '../lib/verify-pkg.js': {
37
+ verifyPkg: stub().rejects(),
38
+ },
39
+ '../lib/verify-target.js': {
40
+ verifyTarget: stub().resolves(),
41
+ },
42
+ '../lib/verify-vsce-auth.js': {
43
+ verifyVsceAuth: stub().resolves(),
44
+ },
45
+ '../lib/verify-ovsx-auth.js': {
46
+ verifyOvsxAuth: stub().resolves(),
47
+ },
32
48
  });
33
49
 
34
50
  await t.throwsAsync(() => verify({}, { logger, cwd }));
35
51
  });
36
52
 
37
53
  test('rejects with verify-target', async (t) => {
38
- const verify = proxyquire('../lib/verify', {
39
- './verify-pkg': sinon.stub().resolves(),
40
- './verify-target': sinon.stub().rejects(),
41
- './verify-vsce-auth': sinon.stub().resolves(),
42
- './verify-ovsx-auth': sinon.stub().resolves(),
54
+ const { verify } = await esmock('../lib/verify.js', {
55
+ '../lib/verify-pkg.js': {
56
+ verifyPkg: stub().resolves(),
57
+ },
58
+ '../lib/verify-target.js': {
59
+ verifyTarget: stub().rejects(),
60
+ },
61
+ '../lib/verify-vsce-auth.js': {
62
+ verifyVsceAuth: stub().resolves(),
63
+ },
64
+ '../lib/verify-ovsx-auth.js': {
65
+ verifyOvsxAuth: stub().resolves(),
66
+ },
43
67
  });
44
68
 
45
69
  await t.throwsAsync(() => verify({}, { logger, cwd }));
46
70
  });
47
71
 
48
72
  test('rejects with verify-auth', async (t) => {
49
- const verify = proxyquire('../lib/verify', {
50
- './verify-pkg': sinon.stub().resolves(),
51
- './verify-target': sinon.stub().resolves(),
52
- './verify-vsce-auth': sinon.stub().rejects(),
53
- './verify-ovsx-auth': sinon.stub().resolves(),
73
+ const { verify } = await esmock('../lib/verify.js', {
74
+ '../lib/verify-pkg.js': {
75
+ verifyPkg: stub().resolves(),
76
+ },
77
+ '../lib/verify-target.js': {
78
+ verifyTarget: stub().resolves(),
79
+ },
80
+ '../lib/verify-vsce-auth.js': {
81
+ verifyVsceAuth: stub().rejects(),
82
+ },
83
+ '../lib/verify-ovsx-auth.js': {
84
+ verifyOvsxAuth: stub().resolves(),
85
+ },
54
86
  });
55
87
 
56
88
  await t.throwsAsync(() => verify({}, { logger, cwd }));
57
89
  });
58
90
 
59
91
  test('rejects with verify-ovsx-auth', async (t) => {
60
- const verify = proxyquire('../lib/verify', {
61
- './verify-pkg': sinon.stub().resolves(),
62
- './verify-target': sinon.stub().resolves(),
63
- './verify-vsce-auth': sinon.stub().resolves(),
64
- './verify-ovsx-auth': sinon.stub().rejects(),
92
+ const { verify } = await esmock('../lib/verify.js', {
93
+ '../lib/verify-pkg.js': {
94
+ verifyPkg: stub().resolves(),
95
+ },
96
+ '../lib/verify-target.js': {
97
+ verifyTarget: stub().resolves(),
98
+ },
99
+ '../lib/verify-vsce-auth.js': {
100
+ verifyVsceAuth: stub().resolves(),
101
+ },
102
+ '../lib/verify-ovsx-auth.js': {
103
+ verifyOvsxAuth: stub().rejects(),
104
+ },
65
105
  });
66
106
 
67
107
  await t.throwsAsync(() => verify({}, { logger, cwd }));
@@ -69,16 +109,24 @@ test('rejects with verify-ovsx-auth', async (t) => {
69
109
 
70
110
  test('it does not verify the auth tokens if publishing is disabled', async (t) => {
71
111
  const stubs = {
72
- verifyPkgStub: sinon.stub().resolves(),
73
- verifyTargetStub: sinon.stub().resolves(),
74
- verifyVsceAuthStub: sinon.stub().resolves(),
75
- verifyOvsxAuthStub: sinon.stub().resolves(),
112
+ verifyPkgStub: stub().resolves(),
113
+ verifyTargetStub: stub().resolves(),
114
+ verifyVsceAuthStub: stub().resolves(),
115
+ verifyOvsxAuthStub: stub().resolves(),
76
116
  };
77
- const verify = proxyquire('../lib/verify', {
78
- './verify-pkg': stubs.verifyPkgStub,
79
- './verify-target': stubs.verifyTargetStub,
80
- './verify-vsce-auth': stubs.verifyVsceAuthStub,
81
- './verify-ovsx-auth': stubs.verifyOvsxAuthStub,
117
+ const { verify } = await esmock('../lib/verify.js', {
118
+ '../lib/verify-pkg.js': {
119
+ verifyPkg: stubs.verifyPkgStub,
120
+ },
121
+ '../lib/verify-target.js': {
122
+ verifyTarget: stubs.verifyTargetStub,
123
+ },
124
+ '../lib/verify-vsce-auth.js': {
125
+ verifyVsceAuth: stubs.verifyVsceAuthStub,
126
+ },
127
+ '../lib/verify-ovsx-auth.js': {
128
+ verifyOvsxAuth: stubs.verifyOvsxAuthStub,
129
+ },
82
130
  });
83
131
 
84
132
  await verify({ publish: false }, { logger, cwd });
@@ -89,21 +137,29 @@ test('it does not verify the auth tokens if publishing is disabled', async (t) =
89
137
 
90
138
  test('errors when neither vsce nor ovsx personal access token is configured', async (t) => {
91
139
  const stubs = {
92
- verifyPkgStub: sinon.stub().resolves(),
93
- verifyTargetStub: sinon.stub().resolves(),
94
- verifyVsceAuthStub: sinon.stub().resolves(),
95
- verifyOvsxAuthStub: sinon.stub().resolves(),
140
+ verifyPkgStub: stub().resolves(),
141
+ verifyTargetStub: stub().resolves(),
142
+ verifyVsceAuthStub: stub().resolves(),
143
+ verifyOvsxAuthStub: stub().resolves(),
96
144
  utilsStub: {
97
- isVscePublishEnabled: sinon.stub().returns(false),
98
- isOvsxPublishEnabled: sinon.stub().returns(false),
145
+ isVscePublishEnabled: stub().returns(false),
146
+ isOvsxPublishEnabled: stub().returns(false),
99
147
  },
100
148
  };
101
- const verify = proxyquire('../lib/verify', {
102
- './verify-pkg': stubs.verifyPkgStub,
103
- './verify-target': stubs.verifyTargetStub,
104
- './verify-vsce-auth': stubs.verifyVsceAuthStub,
105
- './verify-ovsx-auth': stubs.verifyOvsxAuthStub,
106
- './utils': stubs.utilsStub,
149
+ const { verify } = await esmock('../lib/verify.js', {
150
+ '../lib/verify-pkg.js': {
151
+ verifyPkg: stubs.verifyPkgStub,
152
+ },
153
+ '../lib/verify-target.js': {
154
+ verifyTarget: stubs.verifyTargetStub,
155
+ },
156
+ '../lib/verify-vsce-auth.js': {
157
+ verifyVsceAuth: stubs.verifyVsceAuthStub,
158
+ },
159
+ '../lib/verify-ovsx-auth.js': {
160
+ verifyOvsxAuth: stubs.verifyOvsxAuthStub,
161
+ },
162
+ '../lib/utils.js': stubs.utilsStub,
107
163
  });
108
164
 
109
165
  await t.throwsAsync(() => verify({}, { logger, cwd }), {
@@ -116,24 +172,32 @@ test('errors when neither vsce nor ovsx personal access token is configured', as
116
172
 
117
173
  test('verify vsce only', async (t) => {
118
174
  const stubs = {
119
- verifyPkgStub: sinon.stub().resolves(),
120
- verifyTargetStub: sinon.stub().resolves(),
121
- verifyVsceAuthStub: sinon.stub().resolves(),
122
- verifyOvsxAuthStub: sinon.stub().resolves(),
175
+ verifyPkgStub: stub().resolves(),
176
+ verifyTargetStub: stub().resolves(),
177
+ verifyVsceAuthStub: stub().resolves(),
178
+ verifyOvsxAuthStub: stub().resolves(),
123
179
  utilsStub: {
124
- isVscePublishEnabled: sinon.stub().returns(true),
125
- isOvsxPublishEnabled: sinon.stub().returns(false),
180
+ isVscePublishEnabled: stub().returns(true),
181
+ isOvsxPublishEnabled: stub().returns(false),
126
182
  },
127
183
  logger: {
128
- log: sinon.fake(),
184
+ log: fake(),
129
185
  },
130
186
  };
131
- const verify = proxyquire('../lib/verify', {
132
- './verify-pkg': stubs.verifyPkgStub,
133
- './verify-target': stubs.verifyTargetStub,
134
- './verify-vsce-auth': stubs.verifyVsceAuthStub,
135
- './verify-ovsx-auth': stubs.verifyOvsxAuthStub,
136
- './utils': stubs.utilsStub,
187
+ const { verify } = await esmock('../lib/verify.js', {
188
+ '../lib/verify-pkg.js': {
189
+ verifyPkg: stubs.verifyPkgStub,
190
+ },
191
+ '../lib/verify-target.js': {
192
+ verifyTarget: stubs.verifyTargetStub,
193
+ },
194
+ '../lib/verify-vsce-auth.js': {
195
+ verifyVsceAuth: stubs.verifyVsceAuthStub,
196
+ },
197
+ '../lib/verify-ovsx-auth.js': {
198
+ verifyOvsxAuth: stubs.verifyOvsxAuthStub,
199
+ },
200
+ '../lib/utils.js': stubs.utilsStub,
137
201
  });
138
202
 
139
203
  await verify({}, { logger: stubs.logger, cwd });
@@ -144,24 +208,32 @@ test('verify vsce only', async (t) => {
144
208
 
145
209
  test('verify ovsx only', async (t) => {
146
210
  const stubs = {
147
- verifyPkgStub: sinon.stub().resolves(),
148
- verifyTargetStub: sinon.stub().resolves(),
149
- verifyVsceAuthStub: sinon.stub().resolves(),
150
- verifyOvsxAuthStub: sinon.stub().resolves(),
211
+ verifyPkgStub: stub().resolves(),
212
+ verifyTargetStub: stub().resolves(),
213
+ verifyVsceAuthStub: stub().resolves(),
214
+ verifyOvsxAuthStub: stub().resolves(),
151
215
  utilsStub: {
152
- isVscePublishEnabled: sinon.stub().returns(false),
153
- isOvsxPublishEnabled: sinon.stub().returns(true),
216
+ isVscePublishEnabled: stub().returns(false),
217
+ isOvsxPublishEnabled: stub().returns(true),
154
218
  },
155
219
  logger: {
156
- log: sinon.fake(),
220
+ log: fake(),
157
221
  },
158
222
  };
159
- const verify = proxyquire('../lib/verify', {
160
- './verify-pkg': stubs.verifyPkgStub,
161
- './verify-target': stubs.verifyTargetStub,
162
- './verify-vsce-auth': stubs.verifyVsceAuthStub,
163
- './verify-ovsx-auth': stubs.verifyOvsxAuthStub,
164
- './utils': stubs.utilsStub,
223
+ const { verify } = await esmock('../lib/verify.js', {
224
+ '../lib/verify-pkg.js': {
225
+ verifyPkg: stubs.verifyPkgStub,
226
+ },
227
+ '../lib/verify-target.js': {
228
+ verifyTarget: stubs.verifyTargetStub,
229
+ },
230
+ '../lib/verify-vsce-auth.js': {
231
+ verifyVsceAuth: stubs.verifyVsceAuthStub,
232
+ },
233
+ '../lib/verify-ovsx-auth.js': {
234
+ verifyOvsxAuth: stubs.verifyOvsxAuthStub,
235
+ },
236
+ '../lib/utils.js': stubs.utilsStub,
165
237
  });
166
238
 
167
239
  await verify({}, { logger: stubs.logger, cwd });
package/.eslintrc DELETED
@@ -1,14 +0,0 @@
1
- {
2
- "env": {
3
- "es6": true,
4
- "node": true
5
- },
6
- "extends": ["standard", "prettier"],
7
- "rules": {
8
- "no-console": "off",
9
- "indent": ["error", 2],
10
- "linebreak-style": ["error", "unix"],
11
- "quotes": ["error", "single"],
12
- "semi": ["error", "always"]
13
- }
14
- }