semantic-release-vsce 5.2.4 → 5.4.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/.eslintrc +12 -24
- package/.github/workflows/ci.yaml +1 -0
- package/.github/workflows/validate-pr-title.yaml +16 -0
- package/.husky/pre-commit +1 -0
- package/.prettierignore +1 -0
- package/.prettierrc +3 -0
- package/README.md +203 -22
- package/index.js +29 -7
- package/lib/prepare.js +24 -4
- package/lib/publish.js +21 -7
- package/lib/utils.js +12 -0
- package/lib/verify-auth.js +8 -2
- package/lib/verify-ovsx-auth.js +18 -15
- package/lib/verify-pkg.js +12 -3
- package/lib/verify-target.js +29 -0
- package/lib/verify.js +3 -1
- package/package.json +19 -16
- package/release.config.js +20 -20
- package/test/index.test.js +74 -30
- package/test/prepare.test.js +85 -21
- package/test/publish.test.js +111 -27
- package/test/verify-auth.test.js +32 -14
- package/test/verify-ovsx-auth.test.js +53 -9
- package/test/verify-pkg.test.js +45 -33
- package/test/verify-target.test.js +55 -0
- package/test/verify.test.js +40 -10
- package/.husky/commit-msg +0 -4
package/test/publish.test.js
CHANGED
|
@@ -1,23 +1,24 @@
|
|
|
1
|
+
// Run tests serially to avoid env pollution
|
|
2
|
+
const test = require('ava').serial;
|
|
1
3
|
const sinon = require('sinon');
|
|
2
|
-
const test = require('ava');
|
|
3
4
|
const proxyquire = require('proxyquire');
|
|
4
5
|
|
|
5
6
|
const logger = {
|
|
6
|
-
log: sinon.fake()
|
|
7
|
+
log: sinon.fake(),
|
|
7
8
|
};
|
|
8
9
|
const cwd = process.cwd();
|
|
9
10
|
|
|
10
|
-
test.beforeEach(t => {
|
|
11
|
+
test.beforeEach((t) => {
|
|
11
12
|
t.context.stubs = {
|
|
12
|
-
execaStub: sinon.stub()
|
|
13
|
+
execaStub: sinon.stub(),
|
|
13
14
|
};
|
|
14
15
|
});
|
|
15
16
|
|
|
16
|
-
test.afterEach(t => {
|
|
17
|
+
test.afterEach((t) => {
|
|
17
18
|
t.context.stubs.execaStub.resetHistory();
|
|
18
19
|
});
|
|
19
20
|
|
|
20
|
-
test('publish', async t => {
|
|
21
|
+
test('publish', async (t) => {
|
|
21
22
|
const { execaStub } = t.context.stubs;
|
|
22
23
|
const publisher = 'semantic-release-vsce';
|
|
23
24
|
const name = 'Semantice Release VSCE';
|
|
@@ -26,26 +27,30 @@ test('publish', async t => {
|
|
|
26
27
|
'fs-extra': {
|
|
27
28
|
readJson: sinon.stub().returns({
|
|
28
29
|
publisher,
|
|
29
|
-
name
|
|
30
|
-
})
|
|
31
|
-
}
|
|
30
|
+
name,
|
|
31
|
+
}),
|
|
32
|
+
},
|
|
32
33
|
});
|
|
33
34
|
|
|
34
35
|
const version = '1.0.0';
|
|
35
36
|
const token = 'abc123';
|
|
36
37
|
sinon.stub(process, 'env').value({
|
|
37
|
-
VSCE_PAT: token
|
|
38
|
+
VSCE_PAT: token,
|
|
38
39
|
});
|
|
39
40
|
const result = await publish(version, undefined, logger, cwd);
|
|
40
41
|
|
|
41
42
|
t.deepEqual(result, {
|
|
42
43
|
name: 'Visual Studio Marketplace',
|
|
43
|
-
url: `https://marketplace.visualstudio.com/items?itemName=${publisher}.${name}
|
|
44
|
+
url: `https://marketplace.visualstudio.com/items?itemName=${publisher}.${name}`,
|
|
44
45
|
});
|
|
45
|
-
t.deepEqual(execaStub.getCall(0).args, [
|
|
46
|
+
t.deepEqual(execaStub.getCall(0).args, [
|
|
47
|
+
'vsce',
|
|
48
|
+
['publish', version, '--no-git-tag-version'],
|
|
49
|
+
{ stdio: 'inherit', preferLocal: true, cwd },
|
|
50
|
+
]);
|
|
46
51
|
});
|
|
47
52
|
|
|
48
|
-
test('publish with packagePath', async t => {
|
|
53
|
+
test('publish with packagePath', async (t) => {
|
|
49
54
|
const { execaStub } = t.context.stubs;
|
|
50
55
|
const publisher = 'semantic-release-vsce';
|
|
51
56
|
const name = 'Semantice Release VSCE';
|
|
@@ -54,27 +59,31 @@ test('publish with packagePath', async t => {
|
|
|
54
59
|
'fs-extra': {
|
|
55
60
|
readJson: sinon.stub().returns({
|
|
56
61
|
publisher,
|
|
57
|
-
name
|
|
58
|
-
})
|
|
59
|
-
}
|
|
62
|
+
name,
|
|
63
|
+
}),
|
|
64
|
+
},
|
|
60
65
|
});
|
|
61
66
|
|
|
62
67
|
const version = '1.0.0';
|
|
63
68
|
const packagePath = 'test.vsix';
|
|
64
69
|
const token = 'abc123';
|
|
65
70
|
sinon.stub(process, 'env').value({
|
|
66
|
-
VSCE_PAT: token
|
|
71
|
+
VSCE_PAT: token,
|
|
67
72
|
});
|
|
68
73
|
const result = await publish(version, packagePath, logger, cwd);
|
|
69
74
|
|
|
70
75
|
t.deepEqual(result, {
|
|
71
76
|
name: 'Visual Studio Marketplace',
|
|
72
|
-
url: `https://marketplace.visualstudio.com/items?itemName=${publisher}.${name}
|
|
77
|
+
url: `https://marketplace.visualstudio.com/items?itemName=${publisher}.${name}`,
|
|
73
78
|
});
|
|
74
|
-
t.deepEqual(execaStub.getCall(0).args, [
|
|
79
|
+
t.deepEqual(execaStub.getCall(0).args, [
|
|
80
|
+
'vsce',
|
|
81
|
+
['publish', '--packagePath', packagePath],
|
|
82
|
+
{ stdio: 'inherit', preferLocal: true, cwd },
|
|
83
|
+
]);
|
|
75
84
|
});
|
|
76
85
|
|
|
77
|
-
test('publish
|
|
86
|
+
test('publish with multiple packagePath', async (t) => {
|
|
78
87
|
const { execaStub } = t.context.stubs;
|
|
79
88
|
const publisher = 'semantic-release-vsce';
|
|
80
89
|
const name = 'Semantice Release VSCE';
|
|
@@ -83,9 +92,76 @@ test('publish to OpenVSX', async t => {
|
|
|
83
92
|
'fs-extra': {
|
|
84
93
|
readJson: sinon.stub().returns({
|
|
85
94
|
publisher,
|
|
86
|
-
name
|
|
87
|
-
})
|
|
88
|
-
}
|
|
95
|
+
name,
|
|
96
|
+
}),
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
const version = '1.0.0';
|
|
101
|
+
const packagePath = ['test.vsix', 'test2.vsix'];
|
|
102
|
+
const token = 'abc123';
|
|
103
|
+
sinon.stub(process, 'env').value({
|
|
104
|
+
VSCE_PAT: token,
|
|
105
|
+
});
|
|
106
|
+
const result = await publish(version, packagePath, logger, cwd);
|
|
107
|
+
|
|
108
|
+
t.deepEqual(result, {
|
|
109
|
+
name: 'Visual Studio Marketplace',
|
|
110
|
+
url: `https://marketplace.visualstudio.com/items?itemName=${publisher}.${name}`,
|
|
111
|
+
});
|
|
112
|
+
t.deepEqual(execaStub.getCall(0).args, [
|
|
113
|
+
'vsce',
|
|
114
|
+
['publish', '--packagePath', ...packagePath],
|
|
115
|
+
{ stdio: 'inherit', preferLocal: true, cwd },
|
|
116
|
+
]);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
test('publish with target', async (t) => {
|
|
120
|
+
const { execaStub } = t.context.stubs;
|
|
121
|
+
const publisher = 'semantic-release-vsce';
|
|
122
|
+
const name = 'Semantice Release VSCE';
|
|
123
|
+
const publish = proxyquire('../lib/publish', {
|
|
124
|
+
execa: execaStub,
|
|
125
|
+
'fs-extra': {
|
|
126
|
+
readJson: sinon.stub().returns({
|
|
127
|
+
publisher,
|
|
128
|
+
name,
|
|
129
|
+
}),
|
|
130
|
+
},
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
const version = '1.0.0';
|
|
134
|
+
const token = 'abc123';
|
|
135
|
+
const target = 'linux-x64';
|
|
136
|
+
sinon.stub(process, 'env').value({
|
|
137
|
+
VSCE_PAT: token,
|
|
138
|
+
VSCE_TARGET: target,
|
|
139
|
+
});
|
|
140
|
+
const result = await publish(version, undefined, logger, cwd);
|
|
141
|
+
|
|
142
|
+
t.deepEqual(result, {
|
|
143
|
+
name: 'Visual Studio Marketplace',
|
|
144
|
+
url: `https://marketplace.visualstudio.com/items?itemName=${publisher}.${name}`,
|
|
145
|
+
});
|
|
146
|
+
t.deepEqual(execaStub.getCall(0).args, [
|
|
147
|
+
'vsce',
|
|
148
|
+
['publish', version, '--no-git-tag-version', '--target', target],
|
|
149
|
+
{ stdio: 'inherit', preferLocal: true, cwd },
|
|
150
|
+
]);
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
test('publish to OpenVSX', async (t) => {
|
|
154
|
+
const { execaStub } = t.context.stubs;
|
|
155
|
+
const publisher = 'semantic-release-vsce';
|
|
156
|
+
const name = 'Semantice Release VSCE';
|
|
157
|
+
const publish = proxyquire('../lib/publish', {
|
|
158
|
+
execa: execaStub,
|
|
159
|
+
'fs-extra': {
|
|
160
|
+
readJson: sinon.stub().returns({
|
|
161
|
+
publisher,
|
|
162
|
+
name,
|
|
163
|
+
}),
|
|
164
|
+
},
|
|
89
165
|
});
|
|
90
166
|
|
|
91
167
|
const version = '1.0.0';
|
|
@@ -93,19 +169,27 @@ test('publish to OpenVSX', async t => {
|
|
|
93
169
|
const token = 'abc123';
|
|
94
170
|
sinon.stub(process, 'env').value({
|
|
95
171
|
OVSX_PAT: token,
|
|
96
|
-
VSCE_PAT: token
|
|
172
|
+
VSCE_PAT: token,
|
|
97
173
|
});
|
|
98
174
|
const result = await publish(version, packagePath, logger, cwd);
|
|
99
175
|
|
|
100
176
|
t.deepEqual(result, {
|
|
101
177
|
name: 'Visual Studio Marketplace',
|
|
102
|
-
url: `https://marketplace.visualstudio.com/items?itemName=${publisher}.${name}
|
|
178
|
+
url: `https://marketplace.visualstudio.com/items?itemName=${publisher}.${name}`,
|
|
103
179
|
});
|
|
104
|
-
t.deepEqual(execaStub.getCall(0).args, [
|
|
180
|
+
t.deepEqual(execaStub.getCall(0).args, [
|
|
181
|
+
'vsce',
|
|
182
|
+
['publish', '--packagePath', packagePath],
|
|
183
|
+
{ stdio: 'inherit', preferLocal: true, cwd },
|
|
184
|
+
]);
|
|
105
185
|
|
|
106
186
|
// t.deepEqual(result[1], {
|
|
107
187
|
// name: 'Open VSX Registry',
|
|
108
188
|
// url: `https://open-vsx.org/extension/${publisher}/${name}/${version}`
|
|
109
189
|
// });
|
|
110
|
-
t.deepEqual(execaStub.getCall(1).args, [
|
|
190
|
+
t.deepEqual(execaStub.getCall(1).args, [
|
|
191
|
+
'ovsx',
|
|
192
|
+
['publish', '--packagePath', packagePath],
|
|
193
|
+
{ stdio: 'inherit', preferLocal: true, cwd },
|
|
194
|
+
]);
|
|
111
195
|
});
|
package/test/verify-auth.test.js
CHANGED
|
@@ -4,52 +4,70 @@ const proxyquire = require('proxyquire');
|
|
|
4
4
|
const SemanticReleaseError = require('@semantic-release/error');
|
|
5
5
|
|
|
6
6
|
const logger = {
|
|
7
|
-
log: sinon.fake()
|
|
7
|
+
log: sinon.fake(),
|
|
8
8
|
};
|
|
9
9
|
const cwd = process.cwd();
|
|
10
10
|
|
|
11
|
-
test('VSCE_PAT is set', async t => {
|
|
11
|
+
test('VSCE_PAT is set', async (t) => {
|
|
12
12
|
sinon.stub(process, 'env').value({
|
|
13
|
-
VSCE_PAT: 'abc123'
|
|
13
|
+
VSCE_PAT: 'abc123',
|
|
14
14
|
});
|
|
15
15
|
|
|
16
16
|
const verifyAuth = proxyquire('../lib/verify-auth', {
|
|
17
|
-
execa: sinon
|
|
17
|
+
execa: sinon
|
|
18
|
+
.stub()
|
|
19
|
+
.withArgs('vsce', ['verify-pat'], { preferLocal: true, cwd })
|
|
20
|
+
.resolves(),
|
|
18
21
|
});
|
|
19
22
|
|
|
20
23
|
await t.notThrowsAsync(() => verifyAuth(logger));
|
|
21
24
|
});
|
|
22
25
|
|
|
23
|
-
test('VSCE_PAT is not set', async t => {
|
|
26
|
+
test('VSCE_PAT is not set', async (t) => {
|
|
24
27
|
sinon.stub(process, 'env').value({});
|
|
25
28
|
|
|
26
29
|
const verifyAuth = proxyquire('../lib/verify-auth', {
|
|
27
|
-
execa: sinon
|
|
30
|
+
execa: sinon
|
|
31
|
+
.stub()
|
|
32
|
+
.withArgs('vsce', ['verify-pat'], { preferLocal: true, cwd })
|
|
33
|
+
.resolves(),
|
|
28
34
|
});
|
|
29
35
|
|
|
30
|
-
await t.throwsAsync(() => verifyAuth(logger), {
|
|
36
|
+
await t.throwsAsync(() => verifyAuth(logger), {
|
|
37
|
+
instanceOf: SemanticReleaseError,
|
|
38
|
+
code: 'ENOVSCEPAT',
|
|
39
|
+
});
|
|
31
40
|
});
|
|
32
41
|
|
|
33
|
-
test('VSCE_PAT is valid', async t => {
|
|
42
|
+
test('VSCE_PAT is valid', async (t) => {
|
|
34
43
|
sinon.stub(process, 'env').value({
|
|
35
|
-
VSCE_PAT: 'abc123'
|
|
44
|
+
VSCE_PAT: 'abc123',
|
|
36
45
|
});
|
|
37
46
|
|
|
38
47
|
const verifyAuth = proxyquire('../lib/verify-auth', {
|
|
39
|
-
execa: sinon
|
|
48
|
+
execa: sinon
|
|
49
|
+
.stub()
|
|
50
|
+
.withArgs('vsce', ['verify-pat'], { preferLocal: true, cwd })
|
|
51
|
+
.resolves(),
|
|
40
52
|
});
|
|
41
53
|
|
|
42
54
|
await t.notThrowsAsync(() => verifyAuth(logger));
|
|
43
55
|
});
|
|
44
56
|
|
|
45
|
-
test('VSCE_PAT is invalid', async t => {
|
|
57
|
+
test('VSCE_PAT is invalid', async (t) => {
|
|
46
58
|
sinon.stub(process, 'env').value({
|
|
47
|
-
VSCE_PAT: 'abc123'
|
|
59
|
+
VSCE_PAT: 'abc123',
|
|
48
60
|
});
|
|
49
61
|
|
|
50
62
|
const verifyAuth = proxyquire('../lib/verify-auth', {
|
|
51
|
-
execa: sinon
|
|
63
|
+
execa: sinon
|
|
64
|
+
.stub()
|
|
65
|
+
.withArgs('vsce', ['verify-pat'], { preferLocal: true, cwd })
|
|
66
|
+
.rejects(),
|
|
52
67
|
});
|
|
53
68
|
|
|
54
|
-
await t.throwsAsync(() => verifyAuth(logger), {
|
|
69
|
+
await t.throwsAsync(() => verifyAuth(logger), {
|
|
70
|
+
instanceOf: SemanticReleaseError,
|
|
71
|
+
code: 'EINVALIDVSCETOKEN',
|
|
72
|
+
});
|
|
55
73
|
});
|
|
@@ -1,27 +1,71 @@
|
|
|
1
1
|
const test = require('ava');
|
|
2
2
|
const sinon = require('sinon');
|
|
3
|
+
const proxyquire = require('proxyquire');
|
|
3
4
|
const SemanticReleaseError = require('@semantic-release/error');
|
|
4
5
|
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
const cwd = process.cwd();
|
|
7
|
+
|
|
8
|
+
test('OVSX_PAT is not set', async (t) => {
|
|
9
|
+
const logger = {
|
|
10
|
+
log: sinon.fake(),
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const verifyOvsxAuth = require('../lib/verify-ovsx-auth');
|
|
14
|
+
|
|
15
|
+
await t.notThrowsAsync(() => verifyOvsxAuth(logger));
|
|
16
|
+
t.true(logger.log.calledTwice);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test('OVSX_PAT is set', async (t) => {
|
|
20
|
+
const logger = {
|
|
21
|
+
log: sinon.fake(),
|
|
22
|
+
};
|
|
8
23
|
|
|
9
|
-
test('OVSX_PAT is set', async t => {
|
|
10
24
|
sinon.stub(process, 'env').value({
|
|
11
|
-
OVSX_PAT: 'abc123'
|
|
25
|
+
OVSX_PAT: 'abc123',
|
|
12
26
|
});
|
|
13
27
|
|
|
14
|
-
const verifyOvsxAuth =
|
|
28
|
+
const verifyOvsxAuth = proxyquire('../lib/verify-ovsx-auth', {
|
|
29
|
+
execa: sinon
|
|
30
|
+
.stub()
|
|
31
|
+
.withArgs('ovsx', ['verify-pat'], { preferLocal: true, cwd })
|
|
32
|
+
.resolves(),
|
|
33
|
+
});
|
|
15
34
|
|
|
16
35
|
await t.notThrowsAsync(() => verifyOvsxAuth(logger));
|
|
36
|
+
t.true(logger.log.calledOnce);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
test('OVSX_PAT is invalid', async (t) => {
|
|
40
|
+
const logger = {
|
|
41
|
+
log: sinon.fake(),
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
sinon.stub(process, 'env').value({
|
|
45
|
+
OVSX_PAT: '',
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
const verifyOvsxAuth = require('../lib/verify-ovsx-auth');
|
|
49
|
+
|
|
50
|
+
await t.throwsAsync(() => verifyOvsxAuth(logger), {
|
|
51
|
+
instanceOf: SemanticReleaseError,
|
|
52
|
+
code: 'EINVALIDOVSXPAT',
|
|
53
|
+
});
|
|
17
54
|
});
|
|
18
55
|
|
|
19
|
-
test('OVSX_PAT is invalid', async t => {
|
|
56
|
+
test('OVSX_PAT is invalid but not empty', async (t) => {
|
|
57
|
+
const logger = {
|
|
58
|
+
log: sinon.fake(),
|
|
59
|
+
};
|
|
60
|
+
|
|
20
61
|
sinon.stub(process, 'env').value({
|
|
21
|
-
OVSX_PAT: ''
|
|
62
|
+
OVSX_PAT: 'abc123',
|
|
22
63
|
});
|
|
23
64
|
|
|
24
65
|
const verifyOvsxAuth = require('../lib/verify-ovsx-auth');
|
|
25
66
|
|
|
26
|
-
await t.throwsAsync(() => verifyOvsxAuth(logger), {
|
|
67
|
+
await t.throwsAsync(() => verifyOvsxAuth(logger), {
|
|
68
|
+
instanceOf: SemanticReleaseError,
|
|
69
|
+
code: 'EINVALIDOVSXPAT',
|
|
70
|
+
});
|
|
27
71
|
});
|
package/test/verify-pkg.test.js
CHANGED
|
@@ -3,103 +3,115 @@ const test = require('ava');
|
|
|
3
3
|
const proxyquire = require('proxyquire');
|
|
4
4
|
const SemanticReleaseError = require('@semantic-release/error');
|
|
5
5
|
|
|
6
|
-
test('package.json is found', async t => {
|
|
6
|
+
test('package.json is found', async (t) => {
|
|
7
7
|
const name = 'test';
|
|
8
8
|
const publisher = 'tester';
|
|
9
9
|
|
|
10
10
|
const verifyPkg = proxyquire('../lib/verify-pkg', {
|
|
11
11
|
fs: {
|
|
12
|
-
existsSync: sinon.stub().returns(true)
|
|
12
|
+
existsSync: sinon.stub().returns(true),
|
|
13
13
|
},
|
|
14
14
|
'fs-extra': {
|
|
15
15
|
readJson: sinon.stub().returns({
|
|
16
16
|
name,
|
|
17
|
-
publisher
|
|
18
|
-
})
|
|
19
|
-
}
|
|
17
|
+
publisher,
|
|
18
|
+
}),
|
|
19
|
+
},
|
|
20
20
|
});
|
|
21
21
|
|
|
22
22
|
await t.notThrowsAsync(() => verifyPkg());
|
|
23
23
|
});
|
|
24
24
|
|
|
25
|
-
test('package.json is not found', async t => {
|
|
25
|
+
test('package.json is not found', async (t) => {
|
|
26
26
|
const name = 'test';
|
|
27
27
|
const publisher = 'tester';
|
|
28
28
|
|
|
29
29
|
const verifyPkg = proxyquire('../lib/verify-pkg', {
|
|
30
30
|
fs: {
|
|
31
|
-
existsSync: sinon.stub().returns(false)
|
|
31
|
+
existsSync: sinon.stub().returns(false),
|
|
32
32
|
},
|
|
33
33
|
'fs-extra': {
|
|
34
34
|
readJson: sinon.stub().returns({
|
|
35
35
|
name,
|
|
36
|
-
publisher
|
|
37
|
-
})
|
|
38
|
-
}
|
|
36
|
+
publisher,
|
|
37
|
+
}),
|
|
38
|
+
},
|
|
39
39
|
});
|
|
40
40
|
|
|
41
|
-
await t.throwsAsync(() => verifyPkg(), {
|
|
41
|
+
await t.throwsAsync(() => verifyPkg(), {
|
|
42
|
+
instanceOf: SemanticReleaseError,
|
|
43
|
+
code: 'ENOPKG',
|
|
44
|
+
});
|
|
42
45
|
});
|
|
43
46
|
|
|
44
|
-
test('package is valid', async t => {
|
|
47
|
+
test('package is valid', async (t) => {
|
|
45
48
|
const name = 'test';
|
|
46
49
|
const publisher = 'tester';
|
|
47
50
|
const verifyPkg = proxyquire('../lib/verify-pkg', {
|
|
48
51
|
fs: {
|
|
49
|
-
existsSync: sinon.stub().returns(true)
|
|
52
|
+
existsSync: sinon.stub().returns(true),
|
|
50
53
|
},
|
|
51
54
|
'fs-extra': {
|
|
52
55
|
readJson: sinon.stub().returns({
|
|
53
56
|
publisher,
|
|
54
|
-
name
|
|
55
|
-
})
|
|
56
|
-
}
|
|
57
|
+
name,
|
|
58
|
+
}),
|
|
59
|
+
},
|
|
57
60
|
});
|
|
58
61
|
|
|
59
62
|
await t.notThrowsAsync(() => verifyPkg());
|
|
60
63
|
});
|
|
61
64
|
|
|
62
|
-
test('package is invalid', async t => {
|
|
65
|
+
test('package is invalid', async (t) => {
|
|
63
66
|
const verifyPkg = proxyquire('../lib/verify-pkg', {
|
|
64
67
|
fs: {
|
|
65
|
-
existsSync: sinon.stub().returns(true)
|
|
68
|
+
existsSync: sinon.stub().returns(true),
|
|
66
69
|
},
|
|
67
70
|
'fs-extra': {
|
|
68
|
-
readJson: sinon.stub().rejects()
|
|
69
|
-
}
|
|
71
|
+
readJson: sinon.stub().rejects(),
|
|
72
|
+
},
|
|
70
73
|
});
|
|
71
74
|
|
|
72
|
-
await t.throwsAsync(() => verifyPkg(), {
|
|
75
|
+
await t.throwsAsync(() => verifyPkg(), {
|
|
76
|
+
instanceOf: SemanticReleaseError,
|
|
77
|
+
code: 'EINVALIDPKG',
|
|
78
|
+
});
|
|
73
79
|
});
|
|
74
80
|
|
|
75
|
-
test('package is missing name', async t => {
|
|
81
|
+
test('package is missing name', async (t) => {
|
|
76
82
|
const publisher = 'tester';
|
|
77
83
|
const verifyPkg = proxyquire('../lib/verify-pkg', {
|
|
78
84
|
fs: {
|
|
79
|
-
existsSync: sinon.stub().returns(true)
|
|
85
|
+
existsSync: sinon.stub().returns(true),
|
|
80
86
|
},
|
|
81
87
|
'fs-extra': {
|
|
82
88
|
readJson: sinon.stub().returns({
|
|
83
|
-
publisher
|
|
84
|
-
})
|
|
85
|
-
}
|
|
89
|
+
publisher,
|
|
90
|
+
}),
|
|
91
|
+
},
|
|
86
92
|
});
|
|
87
93
|
|
|
88
|
-
await t.throwsAsync(() => verifyPkg(), {
|
|
94
|
+
await t.throwsAsync(() => verifyPkg(), {
|
|
95
|
+
instanceOf: SemanticReleaseError,
|
|
96
|
+
code: 'ENOPKGNAME',
|
|
97
|
+
});
|
|
89
98
|
});
|
|
90
99
|
|
|
91
|
-
test('package is missing publisher', async t => {
|
|
100
|
+
test('package is missing publisher', async (t) => {
|
|
92
101
|
const name = 'test';
|
|
93
102
|
const verifyPkg = proxyquire('../lib/verify-pkg', {
|
|
94
103
|
fs: {
|
|
95
|
-
existsSync: sinon.stub().returns(true)
|
|
104
|
+
existsSync: sinon.stub().returns(true),
|
|
96
105
|
},
|
|
97
106
|
'fs-extra': {
|
|
98
107
|
readJson: sinon.stub().returns({
|
|
99
|
-
name
|
|
100
|
-
})
|
|
101
|
-
}
|
|
108
|
+
name,
|
|
109
|
+
}),
|
|
110
|
+
},
|
|
102
111
|
});
|
|
103
112
|
|
|
104
|
-
await t.throwsAsync(() => verifyPkg(), {
|
|
113
|
+
await t.throwsAsync(() => verifyPkg(), {
|
|
114
|
+
instanceOf: SemanticReleaseError,
|
|
115
|
+
code: 'ENOPUBLISHER',
|
|
116
|
+
});
|
|
105
117
|
});
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
const sinon = require('sinon');
|
|
2
|
+
const test = require('ava');
|
|
3
|
+
const proxyquire = require('proxyquire');
|
|
4
|
+
const SemanticReleaseError = require('@semantic-release/error');
|
|
5
|
+
|
|
6
|
+
test('VSCE_TARGET is not set', async (t) => {
|
|
7
|
+
const vscePackage = sinon.stub().returns({
|
|
8
|
+
Targets: new Map(),
|
|
9
|
+
});
|
|
10
|
+
const verifyTarget = proxyquire('../lib/verify-target', {
|
|
11
|
+
'vsce/out/package': vscePackage,
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
await t.notThrowsAsync(() => verifyTarget());
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
test('VSCE_TARGET is valid', async (t) => {
|
|
18
|
+
sinon.stub(process, 'env').value({
|
|
19
|
+
VSCE_TARGET: 'linux-x64',
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const verifyTarget = require('../lib/verify-target');
|
|
23
|
+
|
|
24
|
+
await t.notThrowsAsync(() => verifyTarget());
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test('VSCE_TARGET is empty', async (t) => {
|
|
28
|
+
const vscePackage = sinon.stub().returns({
|
|
29
|
+
Targets: new Map(),
|
|
30
|
+
});
|
|
31
|
+
const verifyTarget = proxyquire('../lib/verify-target', {
|
|
32
|
+
'vsce/out/package': vscePackage,
|
|
33
|
+
});
|
|
34
|
+
sinon.stub(process, 'env').value({
|
|
35
|
+
VSCE_TARGET: '',
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
await t.throwsAsync(() => verifyTarget(), {
|
|
39
|
+
instanceOf: SemanticReleaseError,
|
|
40
|
+
code: 'EINVALIDVSCETARGET',
|
|
41
|
+
});
|
|
42
|
+
t.false(vscePackage.called);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
test('VSCE_TARGET is unsupported', async (t) => {
|
|
46
|
+
sinon.stub(process, 'env').value({
|
|
47
|
+
VSCE_TARGET: 'whatever-x64',
|
|
48
|
+
});
|
|
49
|
+
const verifyTarget = require('../lib/verify-target');
|
|
50
|
+
|
|
51
|
+
await t.throwsAsync(() => verifyTarget(), {
|
|
52
|
+
instanceOf: SemanticReleaseError,
|
|
53
|
+
code: 'EUNSUPPORTEDVSCETARGET',
|
|
54
|
+
});
|
|
55
|
+
});
|
package/test/verify.test.js
CHANGED
|
@@ -3,47 +3,77 @@ const sinon = require('sinon');
|
|
|
3
3
|
const proxyquire = require('proxyquire');
|
|
4
4
|
|
|
5
5
|
const logger = {
|
|
6
|
-
log: sinon.fake()
|
|
6
|
+
log: sinon.fake(),
|
|
7
7
|
};
|
|
8
8
|
const cwd = process.cwd();
|
|
9
9
|
|
|
10
|
-
test('resolves', async t => {
|
|
10
|
+
test('resolves', async (t) => {
|
|
11
11
|
const verify = proxyquire('../lib/verify', {
|
|
12
|
+
'./verify-pkg': sinon.stub().resolves(),
|
|
13
|
+
'./verify-target': sinon.stub().resolves(),
|
|
12
14
|
'./verify-auth': sinon.stub().resolves(),
|
|
13
|
-
'./verify-
|
|
15
|
+
'./verify-ovsx-auth': sinon.stub().resolves(),
|
|
14
16
|
});
|
|
15
17
|
|
|
16
18
|
await t.notThrowsAsync(() => verify({}, { logger, cwd }));
|
|
17
19
|
});
|
|
18
20
|
|
|
19
|
-
test('rejects with verify-
|
|
21
|
+
test('rejects with verify-pkg', async (t) => {
|
|
20
22
|
const verify = proxyquire('../lib/verify', {
|
|
23
|
+
'./verify-pkg': sinon.stub().rejects(),
|
|
24
|
+
'./verify-target': sinon.stub().resolves(),
|
|
25
|
+
'./verify-auth': sinon.stub().resolves(),
|
|
26
|
+
'./verify-ovsx-auth': sinon.stub().resolves(),
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
await t.throwsAsync(() => verify({}, { logger, cwd }));
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
test('rejects with verify-target', async (t) => {
|
|
33
|
+
const verify = proxyquire('../lib/verify', {
|
|
34
|
+
'./verify-pkg': sinon.stub().resolves(),
|
|
35
|
+
'./verify-target': sinon.stub().rejects(),
|
|
36
|
+
'./verify-auth': sinon.stub().resolves(),
|
|
37
|
+
'./verify-ovsx-auth': sinon.stub().resolves(),
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
await t.throwsAsync(() => verify({}, { logger, cwd }));
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test('rejects with verify-auth', async (t) => {
|
|
44
|
+
const verify = proxyquire('../lib/verify', {
|
|
45
|
+
'./verify-pkg': sinon.stub().resolves(),
|
|
46
|
+
'./verify-target': sinon.stub().resolves(),
|
|
21
47
|
'./verify-auth': sinon.stub().rejects(),
|
|
22
|
-
'./verify-
|
|
48
|
+
'./verify-ovsx-auth': sinon.stub().resolves(),
|
|
23
49
|
});
|
|
24
50
|
|
|
25
51
|
await t.throwsAsync(() => verify({}, { logger, cwd }));
|
|
26
52
|
});
|
|
27
53
|
|
|
28
|
-
test('rejects with verify-
|
|
54
|
+
test('rejects with verify-ovsx-auth', async (t) => {
|
|
29
55
|
const verify = proxyquire('../lib/verify', {
|
|
56
|
+
'./verify-pkg': sinon.stub().resolves(),
|
|
57
|
+
'./verify-target': sinon.stub().resolves(),
|
|
30
58
|
'./verify-auth': sinon.stub().resolves(),
|
|
31
|
-
'./verify-
|
|
59
|
+
'./verify-ovsx-auth': sinon.stub().rejects(),
|
|
32
60
|
});
|
|
33
61
|
|
|
34
62
|
await t.throwsAsync(() => verify({}, { logger, cwd }));
|
|
35
63
|
});
|
|
36
64
|
|
|
37
|
-
test('is does not verify the auth tokens if publishing is disabled', async t => {
|
|
65
|
+
test('is does not verify the auth tokens if publishing is disabled', async (t) => {
|
|
38
66
|
const stubs = {
|
|
39
67
|
verifyPkgStub: sinon.stub().resolves(),
|
|
68
|
+
verifyTargetStub: sinon.stub().resolves(),
|
|
40
69
|
verifyAuthStub: sinon.stub().resolves(),
|
|
41
|
-
verifyOvsxAuthStub: sinon.stub().resolves()
|
|
70
|
+
verifyOvsxAuthStub: sinon.stub().resolves(),
|
|
42
71
|
};
|
|
43
72
|
const verify = proxyquire('../lib/verify', {
|
|
44
73
|
'./verify-pkg': stubs.verifyPkgStub,
|
|
74
|
+
'./verify-target': stubs.verifyTargetStub,
|
|
45
75
|
'./verify-auth': stubs.verifyAuthStub,
|
|
46
|
-
'./verify-ovsx-auth': stubs.verifyOvsxAuthStub
|
|
76
|
+
'./verify-ovsx-auth': stubs.verifyOvsxAuthStub,
|
|
47
77
|
});
|
|
48
78
|
|
|
49
79
|
await verify({ publish: false }, { logger, cwd });
|
package/.husky/commit-msg
DELETED