semantic-release-vsce 3.4.1 → 5.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/dependabot.yml +1 -0
- package/.github/workflows/ci.yaml +3 -2
- package/README.md +9 -1
- package/index.js +3 -3
- package/lib/prepare.js +8 -6
- package/lib/publish.js +26 -9
- package/lib/verify-auth.js +0 -5
- package/lib/verify-ovsx-auth.js +27 -0
- package/lib/verify.js +3 -0
- package/package.json +18 -18
- package/test/index.test.js +1 -7
- package/test/prepare.test.js +11 -21
- package/test/publish.test.js +21 -35
- package/test/verify-auth.test.js +0 -46
- package/test/verify-ovsx-auth.test.js +27 -0
package/.github/dependabot.yml
CHANGED
|
@@ -4,9 +4,11 @@ on:
|
|
|
4
4
|
push:
|
|
5
5
|
branches:
|
|
6
6
|
- master
|
|
7
|
+
- next
|
|
7
8
|
pull_request:
|
|
8
9
|
branches:
|
|
9
10
|
- master
|
|
11
|
+
- next
|
|
10
12
|
|
|
11
13
|
jobs:
|
|
12
14
|
test:
|
|
@@ -15,9 +17,8 @@ jobs:
|
|
|
15
17
|
strategy:
|
|
16
18
|
matrix:
|
|
17
19
|
node-version:
|
|
18
|
-
- 10
|
|
19
|
-
- 12
|
|
20
20
|
- 14
|
|
21
|
+
- 16
|
|
21
22
|
|
|
22
23
|
steps:
|
|
23
24
|
- uses: actions/checkout@v2
|
package/README.md
CHANGED
|
@@ -45,7 +45,15 @@ Use `semantic-release-vsce` as part of `verifyConditions` and `publish`.
|
|
|
45
45
|
If `packageVsix` is set, will also generate a .vsix file at the set file path after publishing. If is a string, it will be used as value for `--out` of `vsce package`.
|
|
46
46
|
It is recommended to upload this to your GitHub release page so your users can easily rollback to an earlier version if a version ever introduces a bad bug.
|
|
47
47
|
|
|
48
|
-
|
|
48
|
+
#### Publishing to OpenVSX
|
|
49
|
+
|
|
50
|
+
Publishing extensions to OpenVSX using this plugin is easy:
|
|
51
|
+
|
|
52
|
+
1. Get a valid personal access token with the correct privileges to the publisher namespace in OpenVSX. In order to get the personal access token, check this [page](https://github.com/eclipse/openvsx/wiki).
|
|
53
|
+
|
|
54
|
+
2. Configure the `OVSX_PAT` environment variable in your CI with the token that you created.
|
|
55
|
+
|
|
56
|
+
3. Enjoy! The plugin will automatically detect the environment variable and it will publish to OpenVSX, no additional configuration is needed.
|
|
49
57
|
|
|
50
58
|
#### Working with older versions
|
|
51
59
|
|
package/index.js
CHANGED
|
@@ -16,7 +16,7 @@ async function prepare (pluginConfig, { nextRelease: { version }, logger }) {
|
|
|
16
16
|
await verifyVsce(logger);
|
|
17
17
|
verified = true;
|
|
18
18
|
}
|
|
19
|
-
packagePath = await vscePrepare(version, pluginConfig.packageVsix,
|
|
19
|
+
packagePath = await vscePrepare(version, pluginConfig.packageVsix, logger);
|
|
20
20
|
prepared = true;
|
|
21
21
|
}
|
|
22
22
|
|
|
@@ -28,9 +28,9 @@ async function publish (pluginConfig, { nextRelease: { version }, logger }) {
|
|
|
28
28
|
|
|
29
29
|
if (!prepared) {
|
|
30
30
|
// BC: prior to semantic-release v15 prepare was part of publish
|
|
31
|
-
packagePath = await vscePrepare(version, pluginConfig.packageVsix,
|
|
31
|
+
packagePath = await vscePrepare(version, pluginConfig.packageVsix, logger);
|
|
32
32
|
}
|
|
33
|
-
return vscePublish(version, packagePath,
|
|
33
|
+
return vscePublish(version, packagePath, logger);
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
module.exports = {
|
package/lib/prepare.js
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
const execa = require('execa');
|
|
2
2
|
const { readJson } = require('fs-extra');
|
|
3
|
+
const { isOvsxEnabled } = require('./verify-ovsx-auth');
|
|
4
|
+
|
|
5
|
+
module.exports = async (version, packageVsix, logger) => {
|
|
6
|
+
const ovsxEnabled = isOvsxEnabled();
|
|
7
|
+
if (packageVsix || ovsxEnabled) {
|
|
8
|
+
if (!packageVsix && ovsxEnabled) {
|
|
9
|
+
logger.log('Packaging to VSIX even though `packageVsix` is not set as publish to OpenVSX is enabled.');
|
|
10
|
+
}
|
|
3
11
|
|
|
4
|
-
module.exports = async (version, packageVsix, yarn, logger) => {
|
|
5
|
-
if (packageVsix) {
|
|
6
12
|
let packagePath;
|
|
7
13
|
|
|
8
14
|
if (typeof packageVsix === 'string') {
|
|
@@ -16,10 +22,6 @@ module.exports = async (version, packageVsix, yarn, logger) => {
|
|
|
16
22
|
|
|
17
23
|
const options = ['package', version, '--no-git-tag-version', '--out', packagePath];
|
|
18
24
|
|
|
19
|
-
if (yarn) {
|
|
20
|
-
options.push('--yarn');
|
|
21
|
-
}
|
|
22
|
-
|
|
23
25
|
await execa('vsce', options, { stdio: 'inherit' });
|
|
24
26
|
|
|
25
27
|
return packagePath;
|
package/lib/publish.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
const execa = require('execa');
|
|
2
2
|
const { readJson } = require('fs-extra');
|
|
3
|
+
const { isOvsxEnabled } = require('./verify-ovsx-auth');
|
|
3
4
|
|
|
4
|
-
module.exports = async (version, packagePath,
|
|
5
|
+
module.exports = async (version, packagePath, logger) => {
|
|
5
6
|
const { publisher, name } = await readJson('./package.json');
|
|
6
7
|
|
|
7
8
|
const options = ['publish'];
|
|
@@ -14,16 +15,32 @@ module.exports = async (version, packagePath, yarn, logger) => {
|
|
|
14
15
|
options.push(...[version, '--no-git-tag-version']);
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
if (yarn) {
|
|
18
|
-
options.push('--yarn');
|
|
19
|
-
}
|
|
20
|
-
|
|
21
18
|
await execa('vsce', options, { stdio: 'inherit' });
|
|
22
19
|
|
|
23
|
-
const
|
|
24
|
-
logger.log(`The new version is available at ${
|
|
25
|
-
|
|
20
|
+
const vsceUrl = `https://marketplace.visualstudio.com/items?itemName=${publisher}.${name}`;
|
|
21
|
+
logger.log(`The new version is available at ${vsceUrl}.`);
|
|
22
|
+
|
|
23
|
+
const vsceRelease = {
|
|
26
24
|
name: 'Visual Studio Marketplace',
|
|
27
|
-
url
|
|
25
|
+
url: vsceUrl
|
|
28
26
|
};
|
|
27
|
+
|
|
28
|
+
if (isOvsxEnabled()) {
|
|
29
|
+
logger.log('Now publishing to OpenVSX');
|
|
30
|
+
|
|
31
|
+
await execa('ovsx', ['publish', packagePath], { stdio: 'inherit' });
|
|
32
|
+
|
|
33
|
+
// TODO: uncomment after https://github.com/semantic-release/semantic-release/issues/2123
|
|
34
|
+
// const ovsxUrl = `https://open-vsx.org/extension/${publisher}/${name}/${version}`;
|
|
35
|
+
// const ovsxRelease = {
|
|
36
|
+
// name: 'Open VSX Registry',
|
|
37
|
+
// url: ovsxUrl
|
|
38
|
+
// };
|
|
39
|
+
|
|
40
|
+
// const releases = [vsceRelease, ovsxRelease];
|
|
41
|
+
|
|
42
|
+
// return releases;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return vsceRelease;
|
|
29
46
|
};
|
package/lib/verify-auth.js
CHANGED
|
@@ -4,11 +4,6 @@ const SemanticReleaseError = require('@semantic-release/error');
|
|
|
4
4
|
module.exports = async (logger) => {
|
|
5
5
|
logger.log('Verifying authentication for vsce');
|
|
6
6
|
|
|
7
|
-
if (!('VSCE_PAT' in process.env) && ('VSCE_TOKEN' in process.env)) {
|
|
8
|
-
logger.log('VSCE_TOKEN is deprecated and may be removed in the next major release, please use VSCE_PAT instead.');
|
|
9
|
-
process.env.VSCE_PAT = process.env.VSCE_TOKEN;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
7
|
if (!process.env.VSCE_PAT) {
|
|
13
8
|
throw new SemanticReleaseError('No vsce personal access token specified (set the `VSCE_PAT` environment variable).', 'ENOVSCEPAT');
|
|
14
9
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const SemanticReleaseError = require('@semantic-release/error');
|
|
2
|
+
|
|
3
|
+
const isOvsxEnabled = () => {
|
|
4
|
+
return 'OVSX_PAT' in process.env;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
module.exports = async (logger) => {
|
|
8
|
+
logger.log('Verifying authentication for ovsx');
|
|
9
|
+
|
|
10
|
+
if (!isOvsxEnabled()) {
|
|
11
|
+
logger.log('Skipping verification of ovsx personal token because the `OVSX_PAT` environment variable is not set.\n\nDid you know you can easily start publishing to OpenVSX with `semantic-release-vsce`?\nLearn more at https://github.com/felipecrs/semantic-release-vsce#publishing-to-openvsx');
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (!process.env.OVSX_PAT) {
|
|
16
|
+
throw new SemanticReleaseError('Empty ovsx personal access token specified.', 'EINVALIDOVSXPAT');
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// TODO: waiting for https://github.com/eclipse/openvsx/issues/313
|
|
20
|
+
// try {
|
|
21
|
+
// await execa('ovsx', ['verify-pat']);
|
|
22
|
+
// } catch (e) {
|
|
23
|
+
// throw new SemanticReleaseError(`Invalid ovsx personal access token. Additional information:\n\n${e}`, 'EINVALIDOVSXPAT');
|
|
24
|
+
// }
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
module.exports.isOvsxEnabled = isOvsxEnabled;
|
package/lib/verify.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
const verifyPkg = require('./verify-pkg');
|
|
2
2
|
const verifyAuth = require('./verify-auth');
|
|
3
|
+
const verifyOvsxAuth = require('./verify-ovsx-auth');
|
|
3
4
|
|
|
4
5
|
module.exports = async logger => {
|
|
5
6
|
await verifyPkg();
|
|
6
7
|
|
|
7
8
|
await verifyAuth(logger);
|
|
9
|
+
|
|
10
|
+
await verifyOvsxAuth(logger);
|
|
8
11
|
};
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "semantic-release-vsce",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "semantic-release plugin to package and publish VS Code extensions",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"engines": {
|
|
7
|
-
"node": ">=
|
|
7
|
+
"node": ">=14"
|
|
8
8
|
},
|
|
9
9
|
"repository": "https://github.com/felipecrs/semantic-release-vsce.git",
|
|
10
10
|
"bugs": "https://github.com/felipecrs/semantic-release-vsce/issues",
|
|
@@ -48,33 +48,33 @@
|
|
|
48
48
|
"preset": "conventionalcommits"
|
|
49
49
|
},
|
|
50
50
|
"volta": {
|
|
51
|
-
"node": "
|
|
52
|
-
"npm": "
|
|
51
|
+
"node": "16.13.2",
|
|
52
|
+
"npm": "8.3.1"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@semantic-release/error": "^
|
|
55
|
+
"@semantic-release/error": "^3.0.0",
|
|
56
56
|
"execa": "^5.0.0",
|
|
57
57
|
"fs-extra": "^10.0.0",
|
|
58
|
-
"
|
|
58
|
+
"ovsx": "^0.2.0",
|
|
59
|
+
"vsce": "^2.6.3"
|
|
59
60
|
},
|
|
60
61
|
"peerDependencies": {
|
|
61
|
-
"semantic-release": ">=
|
|
62
|
+
"semantic-release": ">=18"
|
|
62
63
|
},
|
|
63
64
|
"devDependencies": {
|
|
64
|
-
"@commitlint/cli": "^
|
|
65
|
-
"@commitlint/config-conventional": "^
|
|
66
|
-
"ava": "^
|
|
65
|
+
"@commitlint/cli": "^16.0.2",
|
|
66
|
+
"@commitlint/config-conventional": "^16.0.0",
|
|
67
|
+
"ava": "^4.0.1",
|
|
67
68
|
"conventional-changelog-conventionalcommits": "^4.2.1",
|
|
68
|
-
"eslint": "^7.
|
|
69
|
-
"eslint-config-standard": "^
|
|
69
|
+
"eslint": "^8.7.0",
|
|
70
|
+
"eslint-config-standard": "^17.0.0-0",
|
|
70
71
|
"eslint-plugin-import": "^2.20.1",
|
|
71
|
-
"eslint-plugin-
|
|
72
|
-
"eslint-plugin-promise": "^
|
|
73
|
-
"
|
|
74
|
-
"husky": "^6.0.0",
|
|
72
|
+
"eslint-plugin-n": "^14.0.0",
|
|
73
|
+
"eslint-plugin-promise": "^6.0.0",
|
|
74
|
+
"husky": "^7.0.4",
|
|
75
75
|
"nyc": "^15.1.0",
|
|
76
76
|
"proxyquire": "^2.1.3",
|
|
77
|
-
"semantic-release": "^
|
|
78
|
-
"sinon": "^
|
|
77
|
+
"semantic-release": "^19.0.2",
|
|
78
|
+
"sinon": "^12.0.1"
|
|
79
79
|
}
|
|
80
80
|
}
|
package/test/index.test.js
CHANGED
|
@@ -12,8 +12,7 @@ const semanticReleasePayload = {
|
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
const pluginConfig = {
|
|
15
|
-
packageVsix: 'test.vsix'
|
|
16
|
-
yarn: undefined
|
|
15
|
+
packageVsix: 'test.vsix'
|
|
17
16
|
};
|
|
18
17
|
|
|
19
18
|
test.beforeEach(t => {
|
|
@@ -58,7 +57,6 @@ test('prepare and unverified', async t => {
|
|
|
58
57
|
t.deepEqual(vscePrepareStub.getCall(0).args, [
|
|
59
58
|
semanticReleasePayload.nextRelease.version,
|
|
60
59
|
pluginConfig.packageVsix,
|
|
61
|
-
pluginConfig.yarn,
|
|
62
60
|
semanticReleasePayload.logger
|
|
63
61
|
]);
|
|
64
62
|
});
|
|
@@ -78,7 +76,6 @@ test('prepare and verified', async t => {
|
|
|
78
76
|
t.deepEqual(vscePrepareStub.getCall(0).args, [
|
|
79
77
|
semanticReleasePayload.nextRelease.version,
|
|
80
78
|
pluginConfig.packageVsix,
|
|
81
|
-
pluginConfig.yarn,
|
|
82
79
|
semanticReleasePayload.logger
|
|
83
80
|
]);
|
|
84
81
|
});
|
|
@@ -98,7 +95,6 @@ test('publish that is unverified and unprepared', async t => {
|
|
|
98
95
|
t.deepEqual(vscePublishStub.getCall(0).args, [
|
|
99
96
|
semanticReleasePayload.nextRelease.version,
|
|
100
97
|
undefined,
|
|
101
|
-
pluginConfig.yarn,
|
|
102
98
|
semanticReleasePayload.logger
|
|
103
99
|
]);
|
|
104
100
|
});
|
|
@@ -119,7 +115,6 @@ test('publish that is verified but unprepared', async t => {
|
|
|
119
115
|
t.deepEqual(vscePublishStub.getCall(0).args, [
|
|
120
116
|
semanticReleasePayload.nextRelease.version,
|
|
121
117
|
undefined,
|
|
122
|
-
pluginConfig.yarn,
|
|
123
118
|
semanticReleasePayload.logger
|
|
124
119
|
]);
|
|
125
120
|
});
|
|
@@ -141,7 +136,6 @@ test('publish that is already verified & prepared', async t => {
|
|
|
141
136
|
t.deepEqual(vscePublishStub.getCall(0).args, [
|
|
142
137
|
semanticReleasePayload.nextRelease.version,
|
|
143
138
|
packagePath,
|
|
144
|
-
pluginConfig.yarn,
|
|
145
139
|
semanticReleasePayload.logger
|
|
146
140
|
]);
|
|
147
141
|
});
|
package/test/prepare.test.js
CHANGED
|
@@ -23,20 +23,7 @@ test('packageVsix is not specified', async t => {
|
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
const version = '1.0.0';
|
|
26
|
-
await prepare(version, undefined,
|
|
27
|
-
|
|
28
|
-
t.true(execaStub.notCalled);
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
test('packageVsix is not specified but yarn is true', async t => {
|
|
32
|
-
const { execaStub } = t.context.stubs;
|
|
33
|
-
const prepare = proxyquire('../lib/prepare', {
|
|
34
|
-
execa: execaStub
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
const version = '1.0.0';
|
|
38
|
-
const yarn = true;
|
|
39
|
-
await prepare(version, undefined, yarn, logger);
|
|
26
|
+
await prepare(version, undefined, logger);
|
|
40
27
|
|
|
41
28
|
t.true(execaStub.notCalled);
|
|
42
29
|
});
|
|
@@ -50,7 +37,7 @@ test('packageVsix is a string', async t => {
|
|
|
50
37
|
const version = '1.0.0';
|
|
51
38
|
const packageVsix = 'test.vsix';
|
|
52
39
|
const packagePath = packageVsix;
|
|
53
|
-
const result = await prepare(version, packageVsix,
|
|
40
|
+
const result = await prepare(version, packageVsix, logger);
|
|
54
41
|
|
|
55
42
|
t.deepEqual(result, packagePath);
|
|
56
43
|
t.deepEqual(execaStub.getCall(0).args, ['vsce', ['package', version, '--no-git-tag-version', '--out', packagePath], { stdio: 'inherit' }]);
|
|
@@ -73,13 +60,13 @@ test('packageVsix is true', async t => {
|
|
|
73
60
|
const packageVsix = true;
|
|
74
61
|
const packagePath = `${name}-${version}.vsix`;
|
|
75
62
|
|
|
76
|
-
const result = await prepare(version, packageVsix,
|
|
63
|
+
const result = await prepare(version, packageVsix, logger);
|
|
77
64
|
|
|
78
65
|
t.deepEqual(result, packagePath);
|
|
79
66
|
t.deepEqual(execaStub.getCall(0).args, ['vsce', ['package', version, '--no-git-tag-version', '--out', packagePath], { stdio: 'inherit' }]);
|
|
80
67
|
});
|
|
81
68
|
|
|
82
|
-
test('packageVsix is
|
|
69
|
+
test('packageVsix is not set but OVSX_PAT is', async t => {
|
|
83
70
|
const { execaStub } = t.context.stubs;
|
|
84
71
|
const name = 'test';
|
|
85
72
|
|
|
@@ -92,13 +79,16 @@ test('packageVsix is true and yarn is true', async t => {
|
|
|
92
79
|
}
|
|
93
80
|
});
|
|
94
81
|
|
|
82
|
+
sinon.stub(process, 'env').value({
|
|
83
|
+
OVSX_PAT: 'abc123'
|
|
84
|
+
});
|
|
85
|
+
|
|
95
86
|
const version = '1.0.0';
|
|
96
|
-
const packageVsix =
|
|
97
|
-
const yarn = true;
|
|
87
|
+
const packageVsix = undefined;
|
|
98
88
|
const packagePath = `${name}-${version}.vsix`;
|
|
99
89
|
|
|
100
|
-
const result = await prepare(version, packageVsix,
|
|
90
|
+
const result = await prepare(version, packageVsix, logger);
|
|
101
91
|
|
|
102
92
|
t.deepEqual(result, packagePath);
|
|
103
|
-
t.deepEqual(execaStub.getCall(0).args, ['vsce', ['package', version, '--no-git-tag-version', '--out', packagePath
|
|
93
|
+
t.deepEqual(execaStub.getCall(0).args, ['vsce', ['package', version, '--no-git-tag-version', '--out', packagePath], { stdio: 'inherit' }]);
|
|
104
94
|
});
|
package/test/publish.test.js
CHANGED
|
@@ -32,8 +32,10 @@ test('publish', async t => {
|
|
|
32
32
|
|
|
33
33
|
const version = '1.0.0';
|
|
34
34
|
const token = 'abc123';
|
|
35
|
-
process
|
|
36
|
-
|
|
35
|
+
sinon.stub(process, 'env').value({
|
|
36
|
+
VSCE_PAT: token
|
|
37
|
+
});
|
|
38
|
+
const result = await publish(version, undefined, logger);
|
|
37
39
|
|
|
38
40
|
t.deepEqual(result, {
|
|
39
41
|
name: 'Visual Studio Marketplace',
|
|
@@ -59,8 +61,10 @@ test('publish with packagePath', async t => {
|
|
|
59
61
|
const version = '1.0.0';
|
|
60
62
|
const packagePath = 'test.vsix';
|
|
61
63
|
const token = 'abc123';
|
|
62
|
-
process
|
|
63
|
-
|
|
64
|
+
sinon.stub(process, 'env').value({
|
|
65
|
+
VSCE_PAT: token
|
|
66
|
+
});
|
|
67
|
+
const result = await publish(version, packagePath, logger);
|
|
64
68
|
|
|
65
69
|
t.deepEqual(result, {
|
|
66
70
|
name: 'Visual Studio Marketplace',
|
|
@@ -69,7 +73,7 @@ test('publish with packagePath', async t => {
|
|
|
69
73
|
t.deepEqual(execaStub.getCall(0).args, ['vsce', ['publish', '--packagePath', packagePath], { stdio: 'inherit' }]);
|
|
70
74
|
});
|
|
71
75
|
|
|
72
|
-
test('publish
|
|
76
|
+
test('publish to OpenVSX', async t => {
|
|
73
77
|
const { execaStub } = t.context.stubs;
|
|
74
78
|
const publisher = 'semantic-release-vsce';
|
|
75
79
|
const name = 'Semantice Release VSCE';
|
|
@@ -84,41 +88,23 @@ test('publish when yarn is true', async t => {
|
|
|
84
88
|
});
|
|
85
89
|
|
|
86
90
|
const version = '1.0.0';
|
|
91
|
+
const packagePath = 'test.vsix';
|
|
87
92
|
const token = 'abc123';
|
|
88
|
-
process
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
t.deepEqual(result, {
|
|
93
|
-
name: 'Visual Studio Marketplace',
|
|
94
|
-
url: `https://marketplace.visualstudio.com/items?itemName=${publisher}.${name}`
|
|
93
|
+
sinon.stub(process, 'env').value({
|
|
94
|
+
OVSX_PAT: token,
|
|
95
|
+
VSCE_PAT: token
|
|
95
96
|
});
|
|
96
|
-
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
test('publish with VSCE_PAT and VSCE_TOKEN should prefer VSCE_PAT', async t => {
|
|
100
|
-
const { execaStub } = t.context.stubs;
|
|
101
|
-
const publisher = 'semantic-release-vsce';
|
|
102
|
-
const name = 'Semantice Release VSCE';
|
|
103
|
-
const publish = proxyquire('../lib/publish', {
|
|
104
|
-
execa: execaStub,
|
|
105
|
-
'fs-extra': {
|
|
106
|
-
readJson: sinon.stub().returns({
|
|
107
|
-
publisher,
|
|
108
|
-
name
|
|
109
|
-
})
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
const version = '1.0.0';
|
|
114
|
-
const token = 'abc123';
|
|
115
|
-
process.env.VSCE_TOKEN = token;
|
|
116
|
-
process.env.VSCE_PAT = token;
|
|
117
|
-
const result = await publish(version, undefined, undefined, logger);
|
|
97
|
+
const result = await publish(version, packagePath, logger);
|
|
118
98
|
|
|
119
99
|
t.deepEqual(result, {
|
|
120
100
|
name: 'Visual Studio Marketplace',
|
|
121
101
|
url: `https://marketplace.visualstudio.com/items?itemName=${publisher}.${name}`
|
|
122
102
|
});
|
|
123
|
-
t.deepEqual(execaStub.getCall(0).args, ['vsce', ['publish',
|
|
103
|
+
t.deepEqual(execaStub.getCall(0).args, ['vsce', ['publish', '--packagePath', packagePath], { stdio: 'inherit' }]);
|
|
104
|
+
|
|
105
|
+
// t.deepEqual(result[1], {
|
|
106
|
+
// name: 'Open VSX Registry',
|
|
107
|
+
// url: `https://open-vsx.org/extension/${publisher}/${name}/${version}`
|
|
108
|
+
// });
|
|
109
|
+
t.deepEqual(execaStub.getCall(1).args, ['ovsx', ['publish', packagePath], { stdio: 'inherit' }]);
|
|
124
110
|
});
|
package/test/verify-auth.test.js
CHANGED
|
@@ -7,28 +7,6 @@ const logger = {
|
|
|
7
7
|
log: sinon.fake()
|
|
8
8
|
};
|
|
9
9
|
|
|
10
|
-
test('VSCE_TOKEN is set', async t => {
|
|
11
|
-
sinon.stub(process, 'env').value({
|
|
12
|
-
VSCE_TOKEN: 'abc123'
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
const verifyAuth = proxyquire('../lib/verify-auth', {
|
|
16
|
-
execa: sinon.stub().withArgs('vsce', ['verify-pat']).resolves()
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
await t.notThrowsAsync(() => verifyAuth(logger));
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
test('VSCE_TOKEN is not set', async t => {
|
|
23
|
-
sinon.stub(process, 'env').value({});
|
|
24
|
-
|
|
25
|
-
const verifyAuth = proxyquire('../lib/verify-auth', {
|
|
26
|
-
execa: sinon.stub().withArgs('vsce', ['verify-pat']).resolves()
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
await t.throwsAsync(() => verifyAuth(logger), { instanceOf: SemanticReleaseError, code: 'ENOVSCEPAT' });
|
|
30
|
-
});
|
|
31
|
-
|
|
32
10
|
test('VSCE_PAT is set', async t => {
|
|
33
11
|
sinon.stub(process, 'env').value({
|
|
34
12
|
VSCE_PAT: 'abc123'
|
|
@@ -51,30 +29,6 @@ test('VSCE_PAT is not set', async t => {
|
|
|
51
29
|
await t.throwsAsync(() => verifyAuth(logger), { instanceOf: SemanticReleaseError, code: 'ENOVSCEPAT' });
|
|
52
30
|
});
|
|
53
31
|
|
|
54
|
-
test('VSCE_TOKEN is valid', async t => {
|
|
55
|
-
sinon.stub(process, 'env').value({
|
|
56
|
-
VSCE_TOKEN: 'abc123'
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
const verifyAuth = proxyquire('../lib/verify-auth', {
|
|
60
|
-
execa: sinon.stub().withArgs('vsce', ['verify-pat']).resolves()
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
await t.notThrowsAsync(() => verifyAuth(logger));
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
test('VSCE_TOKEN is invalid', async t => {
|
|
67
|
-
sinon.stub(process, 'env').value({
|
|
68
|
-
VSCE_TOKEN: 'abc123'
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
const verifyAuth = proxyquire('../lib/verify-auth', {
|
|
72
|
-
execa: sinon.stub().withArgs('vsce', ['verify-pat']).rejects()
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
await t.throwsAsync(() => verifyAuth(logger), { instanceOf: SemanticReleaseError, code: 'EINVALIDVSCETOKEN' });
|
|
76
|
-
});
|
|
77
|
-
|
|
78
32
|
test('VSCE_PAT is valid', async t => {
|
|
79
33
|
sinon.stub(process, 'env').value({
|
|
80
34
|
VSCE_PAT: 'abc123'
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const test = require('ava');
|
|
2
|
+
const sinon = require('sinon');
|
|
3
|
+
const SemanticReleaseError = require('@semantic-release/error');
|
|
4
|
+
|
|
5
|
+
const logger = {
|
|
6
|
+
log: sinon.fake()
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
test('OVSX_PAT is set', async t => {
|
|
10
|
+
sinon.stub(process, 'env').value({
|
|
11
|
+
OVSX_PAT: 'abc123'
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
const verifyOvsxAuth = require('../lib/verify-ovsx-auth');
|
|
15
|
+
|
|
16
|
+
await t.notThrowsAsync(() => verifyOvsxAuth(logger));
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test('OVSX_PAT is invalid', async t => {
|
|
20
|
+
sinon.stub(process, 'env').value({
|
|
21
|
+
OVSX_PAT: ''
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const verifyOvsxAuth = require('../lib/verify-ovsx-auth');
|
|
25
|
+
|
|
26
|
+
await t.throwsAsync(() => verifyOvsxAuth(logger), { instanceOf: SemanticReleaseError, code: 'EINVALIDOVSXPAT' });
|
|
27
|
+
});
|