semantic-release-vsce 5.5.10 → 5.6.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/README.md +47 -22
- package/index.js +4 -4
- package/lib/prepare.js +5 -5
- package/lib/publish.js +25 -23
- package/lib/utils.js +9 -2
- package/lib/verify-ovsx-auth.js +3 -11
- package/lib/verify-pkg.js +5 -5
- package/lib/verify-target.js +2 -2
- package/lib/{verify-auth.js → verify-vsce-auth.js} +4 -4
- package/lib/verify.js +25 -3
- package/package.json +4 -4
- package/test/index.test.js +30 -4
- package/test/publish.test.js +58 -0
- package/test/verify-ovsx-auth.test.js +2 -13
- package/test/{verify-auth.test.js → verify-vsce-auth.test.js} +24 -23
- package/test/verify.test.js +97 -9
- package/.prettierignore +0 -1
package/README.md
CHANGED
|
@@ -9,11 +9,11 @@
|
|
|
9
9
|
[](https://david-dm.org/felipecrs/semantic-release-vsce?type=peer)
|
|
10
10
|
[](https://github.com/semantic-release/semantic-release)
|
|
11
11
|
|
|
12
|
-
| Step | Description
|
|
13
|
-
| --------- |
|
|
14
|
-
| `verify` | Verify the
|
|
15
|
-
| `prepare` | Generate the `.vsix` file using vsce
|
|
16
|
-
| `publish` | Publish the extension
|
|
12
|
+
| Step | Description |
|
|
13
|
+
| --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
14
|
+
| `verify` | Verify the `package.json` and the validity of the personal access tokens against Visual Studio Marketplace and/or Open VSX Registry when publish is enabled |
|
|
15
|
+
| `prepare` | Generate the `.vsix` file using `vsce` (can be be controlled by the [`packageVsix` config option](#packagevsix) |
|
|
16
|
+
| `publish` | Publish the extension to Visual Studio Marketplace and/or Open VSX Registry (learn more [here](#publishing)) |
|
|
17
17
|
|
|
18
18
|
## Install
|
|
19
19
|
|
|
@@ -60,7 +60,7 @@ The plugin can be configured in the [**semantic-release** configuration file](ht
|
|
|
60
60
|
|
|
61
61
|
### `packageVsix`
|
|
62
62
|
|
|
63
|
-
Whether to package or not the extension `.vsix
|
|
63
|
+
Whether to package or not the extension into a `.vsix` file, or where to place it. This controls if `vsce package` gets called or not, and what value will be used for `vsce package --out`.
|
|
64
64
|
|
|
65
65
|
| Value | Description |
|
|
66
66
|
| ------------------ | ------------------------------------------------------------------------------------------------------------ |
|
|
@@ -71,12 +71,12 @@ Whether to package or not the extension `.vsix`, or where to place it. This cont
|
|
|
71
71
|
|
|
72
72
|
### `publish`
|
|
73
73
|
|
|
74
|
-
Whether to publish or not the extension to Visual Studio Marketplace or
|
|
74
|
+
Whether to publish or not the extension to Visual Studio Marketplace and/or to Open VSX Registry. This controls if `vsce publish` or `ovsx publish` gets called or not. Learn more [here](#publishing).
|
|
75
75
|
|
|
76
|
-
| Value | Description
|
|
77
|
-
| ---------------- |
|
|
78
|
-
| `true` (default) | publishes the extension to Visual Studio Marketplace |
|
|
79
|
-
| `false` | disables publishing the extension to Visual Studio Marketplace |
|
|
76
|
+
| Value | Description |
|
|
77
|
+
| ---------------- | ------------------------------------------------------------------------------------------ |
|
|
78
|
+
| `true` (default) | publishes the extension to Visual Studio Marketplace and/or to Open VSX Registry |
|
|
79
|
+
| `false` | disables publishing the extension to Visual Studio Marketplace and/or to Open VSX Registry |
|
|
80
80
|
|
|
81
81
|
### `publishPackagePath`
|
|
82
82
|
|
|
@@ -90,11 +90,13 @@ Which `.vsix` file (or files) to publish. This controls what value will be used
|
|
|
90
90
|
|
|
91
91
|
### Environment variables
|
|
92
92
|
|
|
93
|
+
The following environment variables are supported by this plugin:
|
|
94
|
+
|
|
93
95
|
| Variable | Description |
|
|
94
96
|
| ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
95
|
-
| `
|
|
97
|
+
| `OVSX_PAT` | _Optional_. The personal access token to push to Open VSX Registry |
|
|
98
|
+
| `VSCE_PAT` | _Optional_. The personal access token to publish to Visual Studio Marketplace |
|
|
96
99
|
| `VSCE_TARGET` | _Optional_. The target to use when packaging or publishing the extension (used as `vsce package --target ${VSCE_TARGET}`). When set to `universal`, behave as if `VSCE_TARGET` was not set (i.e. build the universal/generic `vsix`). See [the platform-specific example](#platform-specific-on-github-actions) |
|
|
97
|
-
| `OVSX_PAT` | _Optional_. The personal access token to push to OpenVSX |
|
|
98
100
|
|
|
99
101
|
### Configuring `vsce`
|
|
100
102
|
|
|
@@ -104,7 +106,7 @@ You can set `vsce` options in the `package.json`, like:
|
|
|
104
106
|
// package.json
|
|
105
107
|
{
|
|
106
108
|
"vsce": {
|
|
107
|
-
"baseImagesUrl": "https://my.custom/base/images/url"
|
|
109
|
+
"baseImagesUrl": "https://my.custom/base/images/url",
|
|
108
110
|
"dependencies": true,
|
|
109
111
|
"yarn": false
|
|
110
112
|
}
|
|
@@ -113,19 +115,39 @@ You can set `vsce` options in the `package.json`, like:
|
|
|
113
115
|
|
|
114
116
|
For more information, check the [`vsce` docs](https://github.com/microsoft/vscode-vsce#configuration).
|
|
115
117
|
|
|
116
|
-
|
|
118
|
+
## Publishing
|
|
119
|
+
|
|
120
|
+
This plugin can publish extensions to Visual Studio Marketplace and/or Open VSX Registry.
|
|
121
|
+
|
|
122
|
+
You can enable or disable publishing with the [`publish`](#publish) config option.
|
|
123
|
+
|
|
124
|
+
When publish is enabled (default), the plugin will publish to Visual Studio Marketplace if the `VSCE_PAT` environment variable is present, and/or to Open VSX Registry if the `OVSX_PAT` environment variable is present.
|
|
125
|
+
|
|
126
|
+
For example, you may want to disable publishing if you only want to publish the `.vsix` file as a GitHub release asset.
|
|
127
|
+
|
|
128
|
+
### Publishing to Visual Studio Marketplace
|
|
129
|
+
|
|
130
|
+
Publishing extensions to Visual Studio Marketplace using this plugin is easy:
|
|
131
|
+
|
|
132
|
+
1. Create your personal access token for Visual Studio Marketplace. Learn more [here](https://code.visualstudio.com/api/working-with-extensions/publishing-extension#get-a-personal-access-token).
|
|
133
|
+
|
|
134
|
+
2. Configure the `VSCE_PAT` environment variable in your CI with the token that you created.
|
|
135
|
+
|
|
136
|
+
3. Enjoy! The plugin will automatically detect the environment variable and it will publish to Visual Studio Marketplace, no additional configuration is needed.
|
|
137
|
+
|
|
138
|
+
### Publishing to Open VSX Registry
|
|
117
139
|
|
|
118
|
-
Publishing extensions to
|
|
140
|
+
Publishing extensions to Open VSX Registry using this plugin is easy:
|
|
119
141
|
|
|
120
|
-
1.
|
|
142
|
+
1. Create your personal access token for Open VSX Registry. Learn more [here](https://github.com/eclipse/openvsx/wiki).
|
|
121
143
|
|
|
122
144
|
2. Configure the `OVSX_PAT` environment variable in your CI with the token that you created.
|
|
123
145
|
|
|
124
|
-
3. Enjoy! The plugin will automatically detect the environment variable and it will publish to
|
|
146
|
+
3. Enjoy! The plugin will automatically detect the environment variable and it will publish to Open VSX Registry, no additional configuration is needed.
|
|
125
147
|
|
|
126
148
|
## Examples
|
|
127
149
|
|
|
128
|
-
###
|
|
150
|
+
### GitHub Actions
|
|
129
151
|
|
|
130
152
|
```yaml
|
|
131
153
|
name: release
|
|
@@ -146,8 +168,9 @@ jobs:
|
|
|
146
168
|
- run: npx semantic-release
|
|
147
169
|
env:
|
|
148
170
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
171
|
+
# In case you want to publish to Visual Studio Marketplace
|
|
149
172
|
VSCE_PAT: ${{ secrets.VSCE_PAT }}
|
|
150
|
-
# In case you want to publish to
|
|
173
|
+
# In case you want to publish to Open VSX Registry
|
|
151
174
|
OVSX_PAT: ${{ secrets.OVSX_PAT }}
|
|
152
175
|
```
|
|
153
176
|
|
|
@@ -277,8 +300,9 @@ jobs:
|
|
|
277
300
|
VSCE_TARGET: ${{ matrix.target }}
|
|
278
301
|
# All tokens are required since semantic-release needs to validate them
|
|
279
302
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
303
|
+
# In case you want to publish to Visual Studio Marketplace
|
|
280
304
|
VSCE_PAT: ${{ secrets.VSCE_PAT }}
|
|
281
|
-
# In case you want to publish to
|
|
305
|
+
# In case you want to publish to Open VSX Registry
|
|
282
306
|
OVSX_PAT: ${{ secrets.OVSX_PAT }}
|
|
283
307
|
|
|
284
308
|
- uses: actions/upload-artifact@v3
|
|
@@ -303,8 +327,9 @@ jobs:
|
|
|
303
327
|
- run: npx semantic-release --extends ./publish.release.config.js
|
|
304
328
|
env:
|
|
305
329
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
330
|
+
# In case you want to publish to Visual Studio Marketplace
|
|
306
331
|
VSCE_PAT: ${{ secrets.VSCE_PAT }}
|
|
307
|
-
# In case you want to publish to
|
|
332
|
+
# In case you want to publish to Open VSX Registry
|
|
308
333
|
OVSX_PAT: ${{ secrets.OVSX_PAT }}
|
|
309
334
|
```
|
|
310
335
|
|
package/index.js
CHANGED
|
@@ -15,7 +15,7 @@ async function verifyConditions(pluginConfig, { logger, cwd }) {
|
|
|
15
15
|
|
|
16
16
|
async function prepare(
|
|
17
17
|
pluginConfig,
|
|
18
|
-
{ nextRelease: { version }, logger, cwd }
|
|
18
|
+
{ nextRelease: { version }, logger, cwd },
|
|
19
19
|
) {
|
|
20
20
|
if (!verified) {
|
|
21
21
|
await verifyVsce(pluginConfig, { logger, cwd });
|
|
@@ -25,14 +25,14 @@ async function prepare(
|
|
|
25
25
|
version,
|
|
26
26
|
pluginConfig.packageVsix,
|
|
27
27
|
logger,
|
|
28
|
-
cwd
|
|
28
|
+
cwd,
|
|
29
29
|
);
|
|
30
30
|
prepared = true;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
async function publish(
|
|
34
34
|
pluginConfig,
|
|
35
|
-
{ nextRelease: { version }, logger, cwd }
|
|
35
|
+
{ nextRelease: { version }, logger, cwd },
|
|
36
36
|
) {
|
|
37
37
|
if (!verified) {
|
|
38
38
|
await verifyVsce(pluginConfig, { logger, cwd });
|
|
@@ -45,7 +45,7 @@ async function publish(
|
|
|
45
45
|
version,
|
|
46
46
|
pluginConfig.packageVsix,
|
|
47
47
|
logger,
|
|
48
|
-
cwd
|
|
48
|
+
cwd,
|
|
49
49
|
);
|
|
50
50
|
}
|
|
51
51
|
|
package/lib/prepare.js
CHANGED
|
@@ -2,19 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
const execa = require('execa');
|
|
4
4
|
const { readJson } = require('fs-extra');
|
|
5
|
-
const {
|
|
5
|
+
const { isOvsxPublishEnabled, isTargetEnabled } = require('./utils');
|
|
6
6
|
|
|
7
7
|
module.exports = async (version, packageVsix, logger, cwd) => {
|
|
8
8
|
if (packageVsix === false) {
|
|
9
9
|
return;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
const
|
|
12
|
+
const ovsxPublishEnabled = isOvsxPublishEnabled();
|
|
13
13
|
|
|
14
|
-
if (packageVsix ||
|
|
15
|
-
if (!packageVsix &&
|
|
14
|
+
if (packageVsix || ovsxPublishEnabled) {
|
|
15
|
+
if (!packageVsix && ovsxPublishEnabled) {
|
|
16
16
|
logger.log(
|
|
17
|
-
'Packaging to VSIX even though `packageVsix` is not set as publish to OpenVSX is enabled.'
|
|
17
|
+
'Packaging to VSIX even though `packageVsix` is not set as publish to OpenVSX is enabled.',
|
|
18
18
|
);
|
|
19
19
|
}
|
|
20
20
|
|
package/lib/publish.js
CHANGED
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
const execa = require('execa');
|
|
4
4
|
const { readJson } = require('fs-extra');
|
|
5
|
-
const {
|
|
5
|
+
const {
|
|
6
|
+
isOvsxPublishEnabled,
|
|
7
|
+
isTargetEnabled,
|
|
8
|
+
isVscePublishEnabled,
|
|
9
|
+
} = require('./utils');
|
|
6
10
|
|
|
7
11
|
module.exports = async (version, packagePath, logger, cwd) => {
|
|
8
12
|
const { publisher, name } = await readJson('./package.json');
|
|
@@ -27,38 +31,36 @@ module.exports = async (version, packagePath, logger, cwd) => {
|
|
|
27
31
|
message += ` for target ${process.env.VSCE_TARGET}`;
|
|
28
32
|
}
|
|
29
33
|
}
|
|
30
|
-
message += ' to Visual Studio Marketplace';
|
|
31
|
-
logger.log(message);
|
|
32
34
|
|
|
33
|
-
|
|
35
|
+
const releases = [];
|
|
36
|
+
if (isVscePublishEnabled()) {
|
|
37
|
+
logger.log(message + ' to Visual Studio Marketplace');
|
|
34
38
|
|
|
35
|
-
|
|
36
|
-
|
|
39
|
+
await execa('vsce', options, { stdio: 'inherit', preferLocal: true, cwd });
|
|
40
|
+
const vsceUrl = `https://marketplace.visualstudio.com/items?itemName=${publisher}.${name}`;
|
|
37
41
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
logger.log(`The new version is available at ${vsceUrl}.`);
|
|
43
|
+
releases.push({
|
|
44
|
+
name: 'Visual Studio Marketplace',
|
|
45
|
+
url: vsceUrl,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
42
48
|
|
|
43
|
-
if (
|
|
44
|
-
logger.log(
|
|
49
|
+
if (isOvsxPublishEnabled()) {
|
|
50
|
+
logger.log(message + 'to Open VSX Registry');
|
|
45
51
|
|
|
46
52
|
// When publishing to OpenVSX, packagePath will be always set
|
|
47
53
|
await execa('ovsx', options, { stdio: 'inherit', preferLocal: true, cwd });
|
|
48
54
|
const ovsxUrl = `https://open-vsx.org/extension/${publisher}/${name}/${version}`;
|
|
49
55
|
|
|
50
56
|
logger.log(`The new ovsx version is available at ${ovsxUrl}`);
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
// url: ovsxUrl
|
|
56
|
-
// };
|
|
57
|
-
|
|
58
|
-
// const releases = [vsceRelease, ovsxRelease];
|
|
59
|
-
|
|
60
|
-
// return releases;
|
|
57
|
+
releases.push({
|
|
58
|
+
name: 'Open VSX Registry',
|
|
59
|
+
url: ovsxUrl,
|
|
60
|
+
});
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
// TODO: uncomment after https://github.com/semantic-release/semantic-release/issues/2123
|
|
64
|
+
// return releases;
|
|
65
|
+
return releases.shift();
|
|
64
66
|
};
|
package/lib/utils.js
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
const isOvsxPublishEnabled = () => {
|
|
2
4
|
return 'OVSX_PAT' in process.env;
|
|
3
5
|
};
|
|
4
6
|
|
|
7
|
+
const isVscePublishEnabled = () => {
|
|
8
|
+
return 'VSCE_PAT' in process.env;
|
|
9
|
+
};
|
|
10
|
+
|
|
5
11
|
const isTargetEnabled = () => {
|
|
6
12
|
return (
|
|
7
13
|
'VSCE_TARGET' in process.env && process.env.VSCE_TARGET !== 'universal'
|
|
@@ -10,5 +16,6 @@ const isTargetEnabled = () => {
|
|
|
10
16
|
|
|
11
17
|
module.exports = {
|
|
12
18
|
isTargetEnabled,
|
|
13
|
-
|
|
19
|
+
isOvsxPublishEnabled,
|
|
20
|
+
isVscePublishEnabled,
|
|
14
21
|
};
|
package/lib/verify-ovsx-auth.js
CHANGED
|
@@ -2,22 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
const SemanticReleaseError = require('@semantic-release/error');
|
|
4
4
|
const execa = require('execa');
|
|
5
|
-
const { isOvsxEnabled } = require('./utils');
|
|
6
5
|
|
|
7
6
|
module.exports = async (logger, cwd) => {
|
|
8
7
|
logger.log('Verifying authentication for ovsx');
|
|
9
8
|
|
|
10
|
-
if (!isOvsxEnabled()) {
|
|
11
|
-
logger.log(
|
|
12
|
-
'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'
|
|
13
|
-
);
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
9
|
if (!process.env.OVSX_PAT) {
|
|
18
10
|
throw new SemanticReleaseError(
|
|
19
|
-
'Empty ovsx personal access token specified.',
|
|
20
|
-
'
|
|
11
|
+
'Empty ovsx personal access token (`OVSX_PAT` environment variable) specified.',
|
|
12
|
+
'EEMPTYOVSXPAT',
|
|
21
13
|
);
|
|
22
14
|
}
|
|
23
15
|
|
|
@@ -26,7 +18,7 @@ module.exports = async (logger, cwd) => {
|
|
|
26
18
|
} catch (e) {
|
|
27
19
|
throw new SemanticReleaseError(
|
|
28
20
|
`Invalid ovsx personal access token. Additional information:\n\n${e}`,
|
|
29
|
-
'EINVALIDOVSXPAT'
|
|
21
|
+
'EINVALIDOVSXPAT',
|
|
30
22
|
);
|
|
31
23
|
}
|
|
32
24
|
};
|
package/lib/verify-pkg.js
CHANGED
|
@@ -8,7 +8,7 @@ module.exports = async () => {
|
|
|
8
8
|
if (!fs.existsSync('./package.json')) {
|
|
9
9
|
throw new SemanticReleaseError(
|
|
10
10
|
'The `package.json` was not found. A `package.json` is required to release with vsce.',
|
|
11
|
-
'ENOPKG'
|
|
11
|
+
'ENOPKG',
|
|
12
12
|
);
|
|
13
13
|
}
|
|
14
14
|
|
|
@@ -16,10 +16,10 @@ module.exports = async () => {
|
|
|
16
16
|
|
|
17
17
|
try {
|
|
18
18
|
packageJson = await readJson('./package.json');
|
|
19
|
-
} catch
|
|
19
|
+
} catch {
|
|
20
20
|
throw new SemanticReleaseError(
|
|
21
21
|
'The `package.json` seems to be invalid.',
|
|
22
|
-
'EINVALIDPKG'
|
|
22
|
+
'EINVALIDPKG',
|
|
23
23
|
);
|
|
24
24
|
}
|
|
25
25
|
|
|
@@ -28,13 +28,13 @@ module.exports = async () => {
|
|
|
28
28
|
if (!name) {
|
|
29
29
|
throw new SemanticReleaseError(
|
|
30
30
|
'No `name` found in `package.json`.',
|
|
31
|
-
'ENOPKGNAME'
|
|
31
|
+
'ENOPKGNAME',
|
|
32
32
|
);
|
|
33
33
|
}
|
|
34
34
|
if (!publisher) {
|
|
35
35
|
throw new SemanticReleaseError(
|
|
36
36
|
'No `publisher` found in `package.json`.',
|
|
37
|
-
'ENOPUBLISHER'
|
|
37
|
+
'ENOPUBLISHER',
|
|
38
38
|
);
|
|
39
39
|
}
|
|
40
40
|
};
|
package/lib/verify-target.js
CHANGED
|
@@ -11,7 +11,7 @@ module.exports = async () => {
|
|
|
11
11
|
if (!process.env.VSCE_TARGET) {
|
|
12
12
|
throw new SemanticReleaseError(
|
|
13
13
|
'Empty vsce target specified.',
|
|
14
|
-
'EINVALIDVSCETARGET'
|
|
14
|
+
'EINVALIDVSCETARGET',
|
|
15
15
|
);
|
|
16
16
|
}
|
|
17
17
|
|
|
@@ -24,7 +24,7 @@ module.exports = async () => {
|
|
|
24
24
|
`Unsupported vsce target: ${
|
|
25
25
|
process.env.VSCE_TARGET
|
|
26
26
|
}. Available targets: ${Object.values(targets).join(', ')}`,
|
|
27
|
-
'EUNSUPPORTEDVSCETARGET'
|
|
27
|
+
'EUNSUPPORTEDVSCETARGET',
|
|
28
28
|
);
|
|
29
29
|
}
|
|
30
30
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
|
|
3
|
-
const execa = require('execa');
|
|
4
3
|
const SemanticReleaseError = require('@semantic-release/error');
|
|
4
|
+
const execa = require('execa');
|
|
5
5
|
|
|
6
6
|
module.exports = async (logger, cwd) => {
|
|
7
7
|
logger.log('Verifying authentication for vsce');
|
|
8
8
|
|
|
9
9
|
if (!process.env.VSCE_PAT) {
|
|
10
10
|
throw new SemanticReleaseError(
|
|
11
|
-
'
|
|
12
|
-
'
|
|
11
|
+
'Empty vsce personal access token (`VSCE_PAT` environment variable) specified.',
|
|
12
|
+
'EEMPTYVSCEPAT',
|
|
13
13
|
);
|
|
14
14
|
}
|
|
15
15
|
|
|
@@ -18,7 +18,7 @@ module.exports = async (logger, cwd) => {
|
|
|
18
18
|
} catch (e) {
|
|
19
19
|
throw new SemanticReleaseError(
|
|
20
20
|
`Invalid vsce personal access token. Additional information:\n\n${e}`,
|
|
21
|
-
'
|
|
21
|
+
'EINVALIDVSCEPAT',
|
|
22
22
|
);
|
|
23
23
|
}
|
|
24
24
|
};
|
package/lib/verify.js
CHANGED
|
@@ -1,16 +1,38 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
|
|
3
|
+
const SemanticReleaseError = require('@semantic-release/error');
|
|
3
4
|
const verifyPkg = require('./verify-pkg');
|
|
4
|
-
const
|
|
5
|
+
const verifyVsceAuth = require('./verify-vsce-auth');
|
|
5
6
|
const verifyOvsxAuth = require('./verify-ovsx-auth');
|
|
6
7
|
const verifyTarget = require('./verify-target');
|
|
8
|
+
const { isOvsxPublishEnabled, isVscePublishEnabled } = require('./utils');
|
|
7
9
|
|
|
8
10
|
module.exports = async (pluginConfig, { logger, cwd }) => {
|
|
9
11
|
await verifyPkg();
|
|
10
12
|
await verifyTarget();
|
|
11
13
|
|
|
12
14
|
if (pluginConfig?.publish !== false) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
const vscePublishEnabled = isVscePublishEnabled();
|
|
16
|
+
const ovsxPublishEnabled = isOvsxPublishEnabled();
|
|
17
|
+
if (!vscePublishEnabled && !ovsxPublishEnabled) {
|
|
18
|
+
throw new SemanticReleaseError(
|
|
19
|
+
'No personal access token was detected. Set the `VSCE_PAT` or the `OVSX_PAT` environment variable, at least one of them must be present when publish is enabled.\nLearn more at https://github.com/felipecrs/semantic-release-vsce#publishing',
|
|
20
|
+
'ENOPAT',
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
if (vscePublishEnabled) {
|
|
24
|
+
await verifyVsceAuth(logger, cwd);
|
|
25
|
+
} else {
|
|
26
|
+
logger.log(
|
|
27
|
+
'Skipping verification of the vsce personal access token as the `VSCE_PAT` environment variable is not set.\n\nDid you know you can easily start publishing to Visual Studio Marketplace with `semantic-release-vsce`?\nLearn more at https://github.com/felipecrs/semantic-release-vsce#publishing-to-visual-studio-marketplace',
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
if (ovsxPublishEnabled) {
|
|
31
|
+
await verifyOvsxAuth(logger, cwd);
|
|
32
|
+
} else {
|
|
33
|
+
logger.log(
|
|
34
|
+
'Skipping verification of the ovsx personal access token as the `OVSX_PAT` environment variable is not set.\n\nDid you know you can easily start publishing to Open VSX Registry with `semantic-release-vsce`?\nLearn more at https://github.com/felipecrs/semantic-release-vsce#publishing-to-open-vsx-registry',
|
|
35
|
+
);
|
|
36
|
+
}
|
|
15
37
|
}
|
|
16
38
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "semantic-release-vsce",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.6.0",
|
|
4
4
|
"description": "semantic-release plugin to package and publish VS Code extensions",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"engines": {
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
]
|
|
44
44
|
},
|
|
45
45
|
"volta": {
|
|
46
|
-
"node": "18.
|
|
47
|
-
"npm": "9.
|
|
46
|
+
"node": "18.16.1",
|
|
47
|
+
"npm": "9.8.0"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@semantic-release/error": "^3.0.0",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"husky": "^8.0.2",
|
|
70
70
|
"lint-staged": "^13.0.3",
|
|
71
71
|
"nyc": "^15.1.0",
|
|
72
|
-
"prettier": "
|
|
72
|
+
"prettier": "3.0.0",
|
|
73
73
|
"proxyquire": "^2.1.3",
|
|
74
74
|
"semantic-release": "^21.0.1",
|
|
75
75
|
"sinon": "^15.0.0"
|
package/test/index.test.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const test = require('ava');
|
|
1
|
+
const test = require('ava').serial;
|
|
2
2
|
const sinon = require('sinon');
|
|
3
3
|
const proxyquire = require('proxyquire');
|
|
4
4
|
|
|
@@ -44,7 +44,7 @@ test('verifyConditions', async (t) => {
|
|
|
44
44
|
verifyVsceStub.calledOnceWith(pluginConfig, {
|
|
45
45
|
logger: semanticReleasePayload.logger,
|
|
46
46
|
cwd: semanticReleasePayload.cwd,
|
|
47
|
-
})
|
|
47
|
+
}),
|
|
48
48
|
);
|
|
49
49
|
});
|
|
50
50
|
|
|
@@ -63,7 +63,7 @@ test('prepare and unverified', async (t) => {
|
|
|
63
63
|
verifyVsceStub.calledOnceWith(pluginConfig, {
|
|
64
64
|
logger: semanticReleasePayload.logger,
|
|
65
65
|
cwd: semanticReleasePayload.cwd,
|
|
66
|
-
})
|
|
66
|
+
}),
|
|
67
67
|
);
|
|
68
68
|
t.deepEqual(vscePrepareStub.getCall(0).args, [
|
|
69
69
|
semanticReleasePayload.nextRelease.version,
|
|
@@ -166,7 +166,7 @@ test('it does not publish the package if publishing is disabled', async (t) => {
|
|
|
166
166
|
|
|
167
167
|
await verifyConditions(
|
|
168
168
|
{ ...pluginConfig, publish: false },
|
|
169
|
-
semanticReleasePayload
|
|
169
|
+
semanticReleasePayload,
|
|
170
170
|
);
|
|
171
171
|
await prepare({ ...pluginConfig, publish: false }, semanticReleasePayload);
|
|
172
172
|
await publish({ ...pluginConfig, publish: false }, semanticReleasePayload);
|
|
@@ -174,6 +174,32 @@ test('it does not publish the package if publishing is disabled', async (t) => {
|
|
|
174
174
|
t.true(vscePublishStub.notCalled);
|
|
175
175
|
});
|
|
176
176
|
|
|
177
|
+
test('it can publish when `OVSX_PAT` is present but `VSCE_PAT` is missing', async (t) => {
|
|
178
|
+
const token = 'abc123';
|
|
179
|
+
sinon.stub(process, 'env').value({
|
|
180
|
+
OVSX_PAT: token,
|
|
181
|
+
});
|
|
182
|
+
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,
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
await verifyConditions({ ...pluginConfig }, semanticReleasePayload);
|
|
190
|
+
await prepare({ ...pluginConfig }, semanticReleasePayload);
|
|
191
|
+
await publish({ ...pluginConfig }, semanticReleasePayload);
|
|
192
|
+
|
|
193
|
+
t.true(verifyVsceStub.calledOnce);
|
|
194
|
+
t.true(vscePrepareStub.calledOnce);
|
|
195
|
+
t.deepEqual(vscePublishStub.getCall(0).args, [
|
|
196
|
+
semanticReleasePayload.nextRelease.version,
|
|
197
|
+
undefined,
|
|
198
|
+
semanticReleasePayload.logger,
|
|
199
|
+
semanticReleasePayload.cwd,
|
|
200
|
+
]);
|
|
201
|
+
});
|
|
202
|
+
|
|
177
203
|
test('expand globs if publishPackagePath is set', async (t) => {
|
|
178
204
|
const { verifyVsceStub, vscePrepareStub, vscePublishStub } = t.context.stubs;
|
|
179
205
|
const { publish } = proxyquire('../index.js', {
|
package/test/publish.test.js
CHANGED
|
@@ -193,3 +193,61 @@ test('publish to OpenVSX', async (t) => {
|
|
|
193
193
|
{ stdio: 'inherit', preferLocal: true, cwd },
|
|
194
194
|
]);
|
|
195
195
|
});
|
|
196
|
+
|
|
197
|
+
test('publish to OpenVSX only', async (t) => {
|
|
198
|
+
const { execaStub } = t.context.stubs;
|
|
199
|
+
const publisher = 'semantic-release-vsce';
|
|
200
|
+
const name = 'Semantice Release VSCE';
|
|
201
|
+
const publish = proxyquire('../lib/publish', {
|
|
202
|
+
execa: execaStub,
|
|
203
|
+
'fs-extra': {
|
|
204
|
+
readJson: sinon.stub().returns({
|
|
205
|
+
publisher,
|
|
206
|
+
name,
|
|
207
|
+
}),
|
|
208
|
+
},
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
const version = '1.0.0';
|
|
212
|
+
const packagePath = 'test.vsix';
|
|
213
|
+
const token = 'abc123';
|
|
214
|
+
sinon.stub(process, 'env').value({
|
|
215
|
+
OVSX_PAT: token,
|
|
216
|
+
});
|
|
217
|
+
const result = await publish(version, packagePath, logger, cwd);
|
|
218
|
+
|
|
219
|
+
t.deepEqual(result, {
|
|
220
|
+
name: 'Open VSX Registry',
|
|
221
|
+
url: `https://open-vsx.org/extension/${publisher}/${name}/${version}`,
|
|
222
|
+
});
|
|
223
|
+
t.true(execaStub.calledOnce);
|
|
224
|
+
t.deepEqual(execaStub.getCall(0).args, [
|
|
225
|
+
'ovsx',
|
|
226
|
+
['publish', '--packagePath', packagePath],
|
|
227
|
+
{ stdio: 'inherit', preferLocal: true, cwd },
|
|
228
|
+
]);
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
test('should not publish when neither vsce nor ovsx personal access token is configured', async (t) => {
|
|
232
|
+
const { execaStub } = t.context.stubs;
|
|
233
|
+
const publisher = 'semantic-release-vsce';
|
|
234
|
+
const name = 'Semantice Release VSCE';
|
|
235
|
+
const publish = proxyquire('../lib/publish', {
|
|
236
|
+
execa: execaStub,
|
|
237
|
+
'fs-extra': {
|
|
238
|
+
readJson: sinon.stub().returns({
|
|
239
|
+
publisher,
|
|
240
|
+
name,
|
|
241
|
+
}),
|
|
242
|
+
},
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
const version = '1.0.0';
|
|
246
|
+
const packagePath = 'test.vsix';
|
|
247
|
+
sinon.stub(process, 'env').value({});
|
|
248
|
+
|
|
249
|
+
const result = await publish(version, packagePath, logger, cwd);
|
|
250
|
+
|
|
251
|
+
t.falsy(result);
|
|
252
|
+
t.true(execaStub.notCalled);
|
|
253
|
+
});
|
|
@@ -1,21 +1,10 @@
|
|
|
1
|
-
const test = require('ava');
|
|
1
|
+
const test = require('ava').serial;
|
|
2
2
|
const sinon = require('sinon');
|
|
3
3
|
const proxyquire = require('proxyquire');
|
|
4
4
|
const SemanticReleaseError = require('@semantic-release/error');
|
|
5
5
|
|
|
6
6
|
const cwd = process.cwd();
|
|
7
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
8
|
test('OVSX_PAT is set', async (t) => {
|
|
20
9
|
const logger = {
|
|
21
10
|
log: sinon.fake(),
|
|
@@ -49,7 +38,7 @@ test('OVSX_PAT is invalid', async (t) => {
|
|
|
49
38
|
|
|
50
39
|
await t.throwsAsync(() => verifyOvsxAuth(logger), {
|
|
51
40
|
instanceOf: SemanticReleaseError,
|
|
52
|
-
code: '
|
|
41
|
+
code: 'EEMPTYOVSXPAT',
|
|
53
42
|
});
|
|
54
43
|
});
|
|
55
44
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const test = require('ava');
|
|
1
|
+
const test = require('ava').serial;
|
|
2
2
|
const sinon = require('sinon');
|
|
3
3
|
const proxyquire = require('proxyquire');
|
|
4
4
|
const SemanticReleaseError = require('@semantic-release/error');
|
|
@@ -13,61 +13,62 @@ test('VSCE_PAT is set', async (t) => {
|
|
|
13
13
|
VSCE_PAT: 'abc123',
|
|
14
14
|
});
|
|
15
15
|
|
|
16
|
-
const
|
|
16
|
+
const verifyVsceAuth = proxyquire('../lib/verify-vsce-auth', {
|
|
17
17
|
execa: sinon
|
|
18
18
|
.stub()
|
|
19
19
|
.withArgs('vsce', ['verify-pat'], { preferLocal: true, cwd })
|
|
20
20
|
.resolves(),
|
|
21
21
|
});
|
|
22
22
|
|
|
23
|
-
await t.notThrowsAsync(() =>
|
|
23
|
+
await t.notThrowsAsync(() => verifyVsceAuth(logger));
|
|
24
24
|
});
|
|
25
25
|
|
|
26
|
-
test('VSCE_PAT is
|
|
27
|
-
sinon.stub(process, 'env').value({
|
|
26
|
+
test('VSCE_PAT is valid', async (t) => {
|
|
27
|
+
sinon.stub(process, 'env').value({
|
|
28
|
+
VSCE_PAT: 'abc123',
|
|
29
|
+
});
|
|
28
30
|
|
|
29
|
-
const
|
|
31
|
+
const verifyVsceAuth = proxyquire('../lib/verify-vsce-auth', {
|
|
30
32
|
execa: sinon
|
|
31
33
|
.stub()
|
|
32
34
|
.withArgs('vsce', ['verify-pat'], { preferLocal: true, cwd })
|
|
33
35
|
.resolves(),
|
|
34
36
|
});
|
|
35
37
|
|
|
36
|
-
await t.
|
|
37
|
-
instanceOf: SemanticReleaseError,
|
|
38
|
-
code: 'ENOVSCEPAT',
|
|
39
|
-
});
|
|
38
|
+
await t.notThrowsAsync(() => verifyVsceAuth(logger));
|
|
40
39
|
});
|
|
41
40
|
|
|
42
|
-
test('VSCE_PAT is
|
|
41
|
+
test('VSCE_PAT is invalid', async (t) => {
|
|
42
|
+
const logger = {
|
|
43
|
+
log: sinon.fake(),
|
|
44
|
+
};
|
|
45
|
+
|
|
43
46
|
sinon.stub(process, 'env').value({
|
|
44
|
-
VSCE_PAT: '
|
|
47
|
+
VSCE_PAT: '',
|
|
45
48
|
});
|
|
46
49
|
|
|
47
|
-
const
|
|
48
|
-
execa: sinon
|
|
49
|
-
.stub()
|
|
50
|
-
.withArgs('vsce', ['verify-pat'], { preferLocal: true, cwd })
|
|
51
|
-
.resolves(),
|
|
52
|
-
});
|
|
50
|
+
const verifyOvsxAuth = require('../lib/verify-vsce-auth');
|
|
53
51
|
|
|
54
|
-
await t.
|
|
52
|
+
await t.throwsAsync(() => verifyOvsxAuth(logger), {
|
|
53
|
+
instanceOf: SemanticReleaseError,
|
|
54
|
+
code: 'EEMPTYVSCEPAT',
|
|
55
|
+
});
|
|
55
56
|
});
|
|
56
57
|
|
|
57
|
-
test('VSCE_PAT is invalid', async (t) => {
|
|
58
|
+
test('VSCE_PAT is invalid but not empty', async (t) => {
|
|
58
59
|
sinon.stub(process, 'env').value({
|
|
59
60
|
VSCE_PAT: 'abc123',
|
|
60
61
|
});
|
|
61
62
|
|
|
62
|
-
const
|
|
63
|
+
const verifyVsceAuth = proxyquire('../lib/verify-vsce-auth', {
|
|
63
64
|
execa: sinon
|
|
64
65
|
.stub()
|
|
65
66
|
.withArgs('vsce', ['verify-pat'], { preferLocal: true, cwd })
|
|
66
67
|
.rejects(),
|
|
67
68
|
});
|
|
68
69
|
|
|
69
|
-
await t.throwsAsync(() =>
|
|
70
|
+
await t.throwsAsync(() => verifyVsceAuth(logger), {
|
|
70
71
|
instanceOf: SemanticReleaseError,
|
|
71
|
-
code: '
|
|
72
|
+
code: 'EINVALIDVSCEPAT',
|
|
72
73
|
});
|
|
73
74
|
});
|
package/test/verify.test.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const SemanticReleaseError = require('@semantic-release/error');
|
|
1
2
|
const test = require('ava');
|
|
2
3
|
const sinon = require('sinon');
|
|
3
4
|
const proxyquire = require('proxyquire');
|
|
@@ -11,8 +12,12 @@ test('resolves', async (t) => {
|
|
|
11
12
|
const verify = proxyquire('../lib/verify', {
|
|
12
13
|
'./verify-pkg': sinon.stub().resolves(),
|
|
13
14
|
'./verify-target': sinon.stub().resolves(),
|
|
14
|
-
'./verify-auth': sinon.stub().resolves(),
|
|
15
|
+
'./verify-vsce-auth': sinon.stub().resolves(),
|
|
15
16
|
'./verify-ovsx-auth': sinon.stub().resolves(),
|
|
17
|
+
'./utils': {
|
|
18
|
+
isVscePublishEnabled: sinon.stub().returns(true),
|
|
19
|
+
isOvsxPublishEnabled: sinon.stub().returns(true),
|
|
20
|
+
},
|
|
16
21
|
});
|
|
17
22
|
|
|
18
23
|
await t.notThrowsAsync(() => verify({}, { logger, cwd }));
|
|
@@ -22,7 +27,7 @@ test('rejects with verify-pkg', async (t) => {
|
|
|
22
27
|
const verify = proxyquire('../lib/verify', {
|
|
23
28
|
'./verify-pkg': sinon.stub().rejects(),
|
|
24
29
|
'./verify-target': sinon.stub().resolves(),
|
|
25
|
-
'./verify-auth': sinon.stub().resolves(),
|
|
30
|
+
'./verify-vsce-auth': sinon.stub().resolves(),
|
|
26
31
|
'./verify-ovsx-auth': sinon.stub().resolves(),
|
|
27
32
|
});
|
|
28
33
|
|
|
@@ -33,7 +38,7 @@ test('rejects with verify-target', async (t) => {
|
|
|
33
38
|
const verify = proxyquire('../lib/verify', {
|
|
34
39
|
'./verify-pkg': sinon.stub().resolves(),
|
|
35
40
|
'./verify-target': sinon.stub().rejects(),
|
|
36
|
-
'./verify-auth': sinon.stub().resolves(),
|
|
41
|
+
'./verify-vsce-auth': sinon.stub().resolves(),
|
|
37
42
|
'./verify-ovsx-auth': sinon.stub().resolves(),
|
|
38
43
|
});
|
|
39
44
|
|
|
@@ -44,7 +49,7 @@ test('rejects with verify-auth', async (t) => {
|
|
|
44
49
|
const verify = proxyquire('../lib/verify', {
|
|
45
50
|
'./verify-pkg': sinon.stub().resolves(),
|
|
46
51
|
'./verify-target': sinon.stub().resolves(),
|
|
47
|
-
'./verify-auth': sinon.stub().rejects(),
|
|
52
|
+
'./verify-vsce-auth': sinon.stub().rejects(),
|
|
48
53
|
'./verify-ovsx-auth': sinon.stub().resolves(),
|
|
49
54
|
});
|
|
50
55
|
|
|
@@ -55,29 +60,112 @@ test('rejects with verify-ovsx-auth', async (t) => {
|
|
|
55
60
|
const verify = proxyquire('../lib/verify', {
|
|
56
61
|
'./verify-pkg': sinon.stub().resolves(),
|
|
57
62
|
'./verify-target': sinon.stub().resolves(),
|
|
58
|
-
'./verify-auth': sinon.stub().resolves(),
|
|
63
|
+
'./verify-vsce-auth': sinon.stub().resolves(),
|
|
59
64
|
'./verify-ovsx-auth': sinon.stub().rejects(),
|
|
60
65
|
});
|
|
61
66
|
|
|
62
67
|
await t.throwsAsync(() => verify({}, { logger, cwd }));
|
|
63
68
|
});
|
|
64
69
|
|
|
65
|
-
test('
|
|
70
|
+
test('it does not verify the auth tokens if publishing is disabled', async (t) => {
|
|
66
71
|
const stubs = {
|
|
67
72
|
verifyPkgStub: sinon.stub().resolves(),
|
|
68
73
|
verifyTargetStub: sinon.stub().resolves(),
|
|
69
|
-
|
|
74
|
+
verifyVsceAuthStub: sinon.stub().resolves(),
|
|
70
75
|
verifyOvsxAuthStub: sinon.stub().resolves(),
|
|
71
76
|
};
|
|
72
77
|
const verify = proxyquire('../lib/verify', {
|
|
73
78
|
'./verify-pkg': stubs.verifyPkgStub,
|
|
74
79
|
'./verify-target': stubs.verifyTargetStub,
|
|
75
|
-
'./verify-auth': stubs.
|
|
80
|
+
'./verify-vsce-auth': stubs.verifyVsceAuthStub,
|
|
76
81
|
'./verify-ovsx-auth': stubs.verifyOvsxAuthStub,
|
|
77
82
|
});
|
|
78
83
|
|
|
79
84
|
await verify({ publish: false }, { logger, cwd });
|
|
80
85
|
|
|
81
|
-
t.true(stubs.
|
|
86
|
+
t.true(stubs.verifyVsceAuthStub.notCalled);
|
|
82
87
|
t.true(stubs.verifyOvsxAuthStub.notCalled);
|
|
83
88
|
});
|
|
89
|
+
|
|
90
|
+
test('errors when neither vsce nor ovsx personal access token is configured', async (t) => {
|
|
91
|
+
const stubs = {
|
|
92
|
+
verifyPkgStub: sinon.stub().resolves(),
|
|
93
|
+
verifyTargetStub: sinon.stub().resolves(),
|
|
94
|
+
verifyVsceAuthStub: sinon.stub().resolves(),
|
|
95
|
+
verifyOvsxAuthStub: sinon.stub().resolves(),
|
|
96
|
+
utilsStub: {
|
|
97
|
+
isVscePublishEnabled: sinon.stub().returns(false),
|
|
98
|
+
isOvsxPublishEnabled: sinon.stub().returns(false),
|
|
99
|
+
},
|
|
100
|
+
};
|
|
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,
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
await t.throwsAsync(() => verify({}, { logger, cwd }), {
|
|
110
|
+
instanceOf: SemanticReleaseError,
|
|
111
|
+
code: 'ENOPAT',
|
|
112
|
+
});
|
|
113
|
+
t.true(stubs.verifyVsceAuthStub.notCalled);
|
|
114
|
+
t.true(stubs.verifyOvsxAuthStub.notCalled);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
test('verify vsce only', async (t) => {
|
|
118
|
+
const stubs = {
|
|
119
|
+
verifyPkgStub: sinon.stub().resolves(),
|
|
120
|
+
verifyTargetStub: sinon.stub().resolves(),
|
|
121
|
+
verifyVsceAuthStub: sinon.stub().resolves(),
|
|
122
|
+
verifyOvsxAuthStub: sinon.stub().resolves(),
|
|
123
|
+
utilsStub: {
|
|
124
|
+
isVscePublishEnabled: sinon.stub().returns(true),
|
|
125
|
+
isOvsxPublishEnabled: sinon.stub().returns(false),
|
|
126
|
+
},
|
|
127
|
+
logger: {
|
|
128
|
+
log: sinon.fake(),
|
|
129
|
+
},
|
|
130
|
+
};
|
|
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,
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
await verify({}, { logger: stubs.logger, cwd });
|
|
140
|
+
t.true(stubs.verifyVsceAuthStub.calledOnce);
|
|
141
|
+
t.true(stubs.verifyOvsxAuthStub.notCalled);
|
|
142
|
+
t.true(stubs.logger.log.calledOnce);
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
test('verify ovsx only', async (t) => {
|
|
146
|
+
const stubs = {
|
|
147
|
+
verifyPkgStub: sinon.stub().resolves(),
|
|
148
|
+
verifyTargetStub: sinon.stub().resolves(),
|
|
149
|
+
verifyVsceAuthStub: sinon.stub().resolves(),
|
|
150
|
+
verifyOvsxAuthStub: sinon.stub().resolves(),
|
|
151
|
+
utilsStub: {
|
|
152
|
+
isVscePublishEnabled: sinon.stub().returns(false),
|
|
153
|
+
isOvsxPublishEnabled: sinon.stub().returns(true),
|
|
154
|
+
},
|
|
155
|
+
logger: {
|
|
156
|
+
log: sinon.fake(),
|
|
157
|
+
},
|
|
158
|
+
};
|
|
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,
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
await verify({}, { logger: stubs.logger, cwd });
|
|
168
|
+
t.true(stubs.verifyVsceAuthStub.notCalled);
|
|
169
|
+
t.true(stubs.verifyOvsxAuthStub.calledOnce);
|
|
170
|
+
t.true(stubs.logger.log.calledOnce);
|
|
171
|
+
});
|
package/.prettierignore
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
.nyc_output
|