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 CHANGED
@@ -1,26 +1,14 @@
1
1
  {
2
- "env": {
3
- "es6": true,
4
- "node": true
5
- },
6
- "extends": "standard",
7
- "rules": {
8
- "no-console": "off",
9
- "indent": [
10
- "error",
11
- 2
12
- ],
13
- "linebreak-style": [
14
- "error",
15
- "unix"
16
- ],
17
- "quotes": [
18
- "error",
19
- "single"
20
- ],
21
- "semi": [
22
- "error",
23
- "always"
24
- ]
25
- }
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
+ }
26
14
  }
@@ -19,6 +19,7 @@ jobs:
19
19
  node-version:
20
20
  - 14
21
21
  - 16
22
+ - 18
22
23
 
23
24
  steps:
24
25
  - uses: actions/checkout@v3
@@ -0,0 +1,16 @@
1
+ name: validate-pr-title
2
+
3
+ on:
4
+ pull_request_target:
5
+ types:
6
+ - opened
7
+ - edited
8
+ - synchronize
9
+
10
+ jobs:
11
+ validate-pr-title:
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - uses: amannn/action-semantic-pull-request@v5.0.2
15
+ env:
16
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
package/.husky/pre-commit CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/bin/sh
2
2
  . "$(dirname "$0")/_/husky.sh"
3
3
 
4
+ npx lint-staged
4
5
  npm test
@@ -0,0 +1 @@
1
+ .nyc_output
package/.prettierrc ADDED
@@ -0,0 +1,3 @@
1
+ {
2
+ "singleQuote": true
3
+ }
package/README.md CHANGED
@@ -9,11 +9,11 @@
9
9
  [![peerDependencies](https://david-dm.org/felipecrs/semantic-release-vsce/peer-status.svg)](https://david-dm.org/felipecrs/semantic-release-vsce?type=peer)
10
10
  [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
11
11
 
12
- | Step | Description |
13
- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
14
- | `verify` | Verify the presence and the validity of the authentication (set via [environment variables](#environment-variables)) and the `package.json` |
15
- | `prepare` | Generate the `.vsix` file using vsce, this can be be controlled by providing `packageVsix` in config. <br/> _Note: If the `OVSX_PAT` environment variable is set, this step will still run_ |
16
- | `publish` | Publish the extension |
12
+ | Step | Description |
13
+ | --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
14
+ | `verify` | Verify the presence and the validity of the authentication (set via [environment variables](#environment-variables)) and the `package.json` |
15
+ | `prepare` | Generate the `.vsix` file using vsce, this can be be controlled by providing `packageVsix` in config. <br/> _Note: If the `OVSX_PAT` environment variable is set, this step will run even if not explicitly enabled_ |
16
+ | `publish` | Publish the extension |
17
17
 
18
18
  ## Install
19
19
 
@@ -47,8 +47,7 @@ The plugin can be configured in the [**semantic-release** configuration file](ht
47
47
  {
48
48
  "assets": [
49
49
  {
50
- "path": "*.vsix",
51
- "label": "Extension File"
50
+ "path": "*.vsix"
52
51
  }
53
52
  ]
54
53
  }
@@ -59,17 +58,43 @@ The plugin can be configured in the [**semantic-release** configuration file](ht
59
58
 
60
59
  ## Configuration
61
60
 
62
- | Option | Type | Description |
63
- | ------------- | --------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
64
- | `packageVsix` | `boolean` or `string` | If set to `true`, the plugin will generate a `.vsix` file. If is a string, it will be used as value for `--out` of `vsce package`. |
65
- | `publish` | `boolean` | The plugin will publish the package unless this option is set to `false`, in which case it will only package the extension `vsix`. |
61
+ ### `packageVsix`
66
62
 
67
- ### Environment Variables
63
+ Whether to package or not the extension `.vsix`, or where to place it. This controls if `vsce package` gets called or not, and what value will be used for `vsce package --out`.
68
64
 
69
- | Variable | Description |
70
- | ---------- | ---------------------------------------------------------------------------------------------------------------------------- |
71
- | `VSCE_PAT` | _**Required**_ unless `publish` is set to `false`. The personal access token to publish the extension of VS Code Marketplace |
72
- | `OVSX_PAT` | _Optional_. The personal access token to push to OpenVSX |
65
+ | Value | Description |
66
+ | ------------------ | ------------------------------------------------------------------------------------------------------------ |
67
+ | `"auto"` (default) | behave as `true` in case [`publish`](#publish) is disabled or the `OVSX_PAT` environment variable is present |
68
+ | `true` | package the extension `.vsix`, and place it at the current working directory |
69
+ | `false` | disables packaging the extension `.vsix` entirely |
70
+ | a `string` | package the extension `.vsix` and place it at the specified path |
71
+
72
+ ### `publish`
73
+
74
+ Whether to publish or not the extension to Visual Studio Marketplace or OpenVSX (if the `OVSX_PAT` environment variable is present). This controls if `vsce publish` or `ovsx publish` (if the `OVSX_PAT` environment variable is present) gets called or not.
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 |
80
+
81
+ ### `publishPackagePath`
82
+
83
+ Which `.vsix` file (or files) to publish. This controls what value will be used for `vsce publish --packagePath`.
84
+
85
+ | Value | Description |
86
+ | ------------------ | ----------------------------------------------------------------------------------------------------------------- |
87
+ | `"auto"` (default) | uses the `.vsix` packaged during the `prepare` step (if packaged), or behave as `false` otherwise |
88
+ | `false` | do not use a `.vsix` file to publish, which causes `vsce` to package the extension as part of the publish process |
89
+ | a `string` | publish the specified `.vsix` file(s). This can be a glob pattern, or a comma-separated list of files |
90
+
91
+ ### Environment variables
92
+
93
+ | Variable | Description |
94
+ | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
95
+ | `VSCE_PAT` | **Required** (unless `publish` is set to `false`). The personal access token to publish the extension to Visual Studio Marketplace |
96
+ | `VSCE_TARGET` | _Optional_. The target to use when packaging or publishing the extension (used as `vsce package --target ${VSCE_TARGET}`). See [the platform-specific example](#platform-specific-on-github-actions) ) |
97
+ | `OVSX_PAT` | _Optional_. The personal access token to push to OpenVSX |
73
98
 
74
99
  ### Publishing to OpenVSX
75
100
 
@@ -79,9 +104,11 @@ Publishing extensions to OpenVSX using this plugin is easy:
79
104
 
80
105
  2. Configure the `OVSX_PAT` environment variable in your CI with the token that you created.
81
106
 
82
- 3. The plugin will automatically detect the environment variable and it will publish to OpenVSX, no additional configuration is needed. Enjoy!
107
+ 3. Enjoy! The plugin will automatically detect the environment variable and it will publish to OpenVSX, no additional configuration is needed.
108
+
109
+ ## Examples
83
110
 
84
- ### Github Actions Example
111
+ ### Github Actions
85
112
 
86
113
  ```yaml
87
114
  name: release
@@ -98,11 +125,165 @@ jobs:
98
125
  - uses: actions/setup-node@v3
99
126
  with:
100
127
  node-version: 16
101
- - name: Install Node Dependencies
102
- run: npm ci
103
- - name: Release
104
- run: npx semantic-release
128
+ - run: npm ci
129
+ - run: npx semantic-release
105
130
  env:
106
131
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
107
132
  VSCE_PAT: ${{ secrets.VSCE_PAT }}
133
+ # In case you want to publish to OpenVSX
134
+ OVSX_PAT: ${{ secrets.OVSX_PAT }}
108
135
  ```
136
+
137
+ ### Platform-specific on GitHub Actions
138
+
139
+ 1. Install [`semantic-release-stop-before-publish`](https://github.com/felipecrs/semantic-release-stop-before-publish)
140
+
141
+ ```console
142
+ npm install --save-dev semantic-release-stop-before-publish
143
+ ```
144
+
145
+ We will use it to make `semantic-release` stop before publishing anything, so that we can use `semantic-release` to build each `.vsix` in a matrix.
146
+
147
+ 2. Separate your `semantic-release` configuration into two, one for packaging and another for publishing.
148
+
149
+ The one for packaging has `semantic-release-stop-before-publish` so that `semantic-release` does not publish anything (which includes the git tag).
150
+
151
+ ```js
152
+ // package.release.config.js
153
+ module.exports = {
154
+ plugins: [
155
+ '@semantic-release/commit-analyzer',
156
+ '@semantic-release/release-notes-generator',
157
+ [
158
+ 'semantic-release-vsce',
159
+ {
160
+ packageVsix: true,
161
+ publish: false, // no-op since we use semantic-release-stop-before-publish
162
+ },
163
+ ],
164
+ 'semantic-release-stop-before-publish',
165
+ ],
166
+ };
167
+ ```
168
+
169
+ The one for publishing does not package the `.vsix`, but publishes all the `*.vsix` files.
170
+
171
+ ```js
172
+ // publish.release.config.js
173
+ module.exports = {
174
+ plugins: [
175
+ '@semantic-release/commit-analyzer',
176
+ '@semantic-release/release-notes-generator',
177
+ [
178
+ 'semantic-release-vsce',
179
+ {
180
+ packageVsix: false,
181
+ publishPackagePath: '*/*.vsix',
182
+ },
183
+ ],
184
+ [
185
+ '@semantic-release/github',
186
+ {
187
+ assets: '*/*.vsix',
188
+ },
189
+ ],
190
+ ],
191
+ };
192
+ ```
193
+
194
+ > **Note:** do not forget to remove your existing `semantic-release` configuration.
195
+
196
+ 3. Create a workflow file like below:
197
+
198
+ ```yaml
199
+ # .github/workflows/ci.yaml
200
+ name: ci
201
+
202
+ on:
203
+ push:
204
+ branches: [master]
205
+
206
+ jobs:
207
+ build:
208
+ strategy:
209
+ matrix:
210
+ include:
211
+ - os: windows-latest
212
+ platform: win32
213
+ arch: x64
214
+ npm_config_arch: x64
215
+ - os: windows-latest
216
+ platform: win32
217
+ arch: ia32
218
+ npm_config_arch: ia32
219
+ - os: windows-latest
220
+ platform: win32
221
+ arch: arm64
222
+ npm_config_arch: arm
223
+ - os: ubuntu-latest
224
+ platform: linux
225
+ arch: x64
226
+ npm_config_arch: x64
227
+ - os: ubuntu-latest
228
+ platform: linux
229
+ arch: arm64
230
+ npm_config_arch: arm64
231
+ - os: ubuntu-latest
232
+ platform: linux
233
+ arch: armhf
234
+ npm_config_arch: arm
235
+ - os: ubuntu-latest
236
+ platform: alpine
237
+ arch: x64
238
+ npm_config_arch: x64
239
+ - os: macos-latest
240
+ platform: darwin
241
+ arch: x64
242
+ npm_config_arch: x64
243
+ - os: macos-latest
244
+ platform: darwin
245
+ arch: arm64
246
+ npm_config_arch: arm64
247
+ runs-on: ${{ matrix.os }}
248
+ steps:
249
+ - uses: actions/checkout@v3
250
+ - uses: actions/setup-node@v3
251
+ with:
252
+ node-version: 16
253
+ - run: npm ci
254
+ env:
255
+ npm_config_arch: ${{ matrix.npm_config_arch }}
256
+ - name: Set VSCE_TARGET
257
+ shell: pwsh
258
+ run: echo "VSCE_TARGET=${{ matrix.platform }}-${{ matrix.arch }}" >> $env:GITHUB_ENV
259
+ - run: npx semantic-release --extends ./package.release.config.js
260
+ env:
261
+ # All tokens are required since semantic-release needs to validate them
262
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
263
+ VSCE_PAT: ${{ secrets.VSCE_PAT }}
264
+ # In case you want to publish to OpenVSX
265
+ OVSX_PAT: ${{ secrets.OVSX_PAT }}
266
+ - uses: actions/upload-artifact@v3
267
+ with:
268
+ name: ${{ env.VSCE_TARGET }}
269
+ path: '*.vsix'
270
+
271
+ release:
272
+ runs-on: ubuntu-latest
273
+ needs: build
274
+ steps:
275
+ - uses: actions/checkout@v3
276
+ - uses: actions/setup-node@v3
277
+ with:
278
+ node-version: 16
279
+ - run: npm ci
280
+ - uses: actions/download-artifact@v3
281
+ - run: npx semantic-release --extends ./publish.release.config.js
282
+ env:
283
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
284
+ VSCE_PAT: ${{ secrets.VSCE_PAT }}
285
+ # In case you want to publish to OpenVSX
286
+ OVSX_PAT: ${{ secrets.OVSX_PAT }}
287
+ ```
288
+
289
+ A reference implementation can also be found in the [VS Code ShellCheck extension](https://github.com/vscode-shellcheck/vscode-shellcheck/pull/805).
package/index.js CHANGED
@@ -8,21 +8,32 @@ let verified = false;
8
8
  let prepared = false;
9
9
  let packagePath;
10
10
 
11
- async function verifyConditions (pluginConfig, { logger, cwd }) {
11
+ async function verifyConditions(pluginConfig, { logger, cwd }) {
12
12
  await verifyVsce(pluginConfig, { logger, cwd });
13
13
  verified = true;
14
14
  }
15
15
 
16
- async function prepare (pluginConfig, { nextRelease: { version }, logger, cwd }) {
16
+ async function prepare(
17
+ pluginConfig,
18
+ { nextRelease: { version }, logger, cwd }
19
+ ) {
17
20
  if (!verified) {
18
21
  await verifyVsce(pluginConfig, { logger, cwd });
19
22
  verified = true;
20
23
  }
21
- packagePath = await vscePrepare(version, pluginConfig.packageVsix, logger, cwd);
24
+ packagePath = await vscePrepare(
25
+ version,
26
+ pluginConfig.packageVsix,
27
+ logger,
28
+ cwd
29
+ );
22
30
  prepared = true;
23
31
  }
24
32
 
25
- async function publish (pluginConfig, { nextRelease: { version }, logger, cwd }) {
33
+ async function publish(
34
+ pluginConfig,
35
+ { nextRelease: { version }, logger, cwd }
36
+ ) {
26
37
  if (!verified) {
27
38
  await verifyVsce(pluginConfig, { logger, cwd });
28
39
  verified = true;
@@ -30,7 +41,12 @@ async function publish (pluginConfig, { nextRelease: { version }, logger, cwd })
30
41
 
31
42
  if (!prepared) {
32
43
  // BC: prior to semantic-release v15 prepare was part of publish
33
- packagePath = await vscePrepare(version, pluginConfig.packageVsix, logger, cwd);
44
+ packagePath = await vscePrepare(
45
+ version,
46
+ pluginConfig.packageVsix,
47
+ logger,
48
+ cwd
49
+ );
34
50
  }
35
51
 
36
52
  // If publishing is disabled, return early.
@@ -38,11 +54,17 @@ async function publish (pluginConfig, { nextRelease: { version }, logger, cwd })
38
54
  return;
39
55
  }
40
56
 
41
- return vscePublish(version, packagePath, logger);
57
+ if (pluginConfig?.publishPackagePath) {
58
+ // Expand glob
59
+ const glob = require('glob');
60
+ packagePath = glob.sync(pluginConfig.publishPackagePath, { cwd });
61
+ }
62
+
63
+ return vscePublish(version, packagePath, logger, cwd);
42
64
  }
43
65
 
44
66
  module.exports = {
45
67
  verifyConditions,
46
68
  prepare,
47
- publish
69
+ publish,
48
70
  };
package/lib/prepare.js CHANGED
@@ -2,13 +2,20 @@
2
2
 
3
3
  const execa = require('execa');
4
4
  const { readJson } = require('fs-extra');
5
- const { isOvsxEnabled } = require('./verify-ovsx-auth');
5
+ const { isOvsxEnabled, isTargetEnabled } = require('./utils');
6
6
 
7
7
  module.exports = async (version, packageVsix, logger, cwd) => {
8
+ if (packageVsix === false) {
9
+ return;
10
+ }
11
+
8
12
  const ovsxEnabled = isOvsxEnabled();
13
+
9
14
  if (packageVsix || ovsxEnabled) {
10
15
  if (!packageVsix && ovsxEnabled) {
11
- logger.log('Packaging to VSIX even though `packageVsix` is not set as publish to OpenVSX is enabled.');
16
+ logger.log(
17
+ 'Packaging to VSIX even though `packageVsix` is not set as publish to OpenVSX is enabled.'
18
+ );
12
19
  }
13
20
 
14
21
  let packagePath;
@@ -17,12 +24,25 @@ module.exports = async (version, packageVsix, logger, cwd) => {
17
24
  packagePath = packageVsix;
18
25
  } else {
19
26
  const { name } = await readJson('./package.json');
20
- packagePath = `${name}-${version}.vsix`;
27
+ if (isTargetEnabled()) {
28
+ packagePath = `${name}-${process.env.VSCE_TARGET}-${version}.vsix`;
29
+ } else {
30
+ packagePath = `${name}-${version}.vsix`;
31
+ }
21
32
  }
22
33
 
23
34
  logger.log(`Packaging version ${version} to ${packagePath}`);
24
35
 
25
- const options = ['package', version, '--no-git-tag-version', '--out', packagePath];
36
+ const options = [
37
+ 'package',
38
+ version,
39
+ '--no-git-tag-version',
40
+ '--out',
41
+ packagePath,
42
+ ];
43
+ if (process.env.VSCE_TARGET) {
44
+ options.push('--target', process.env.VSCE_TARGET);
45
+ }
26
46
 
27
47
  await execa('vsce', options, { stdio: 'inherit', preferLocal: true, cwd });
28
48
 
package/lib/publish.js CHANGED
@@ -2,20 +2,33 @@
2
2
 
3
3
  const execa = require('execa');
4
4
  const { readJson } = require('fs-extra');
5
- const { isOvsxEnabled } = require('./verify-ovsx-auth');
5
+ const { isOvsxEnabled, isTargetEnabled } = require('./utils');
6
6
 
7
7
  module.exports = async (version, packagePath, logger, cwd) => {
8
8
  const { publisher, name } = await readJson('./package.json');
9
9
 
10
10
  const options = ['publish'];
11
11
 
12
+ let message = `Publishing version ${version}`;
12
13
  if (packagePath) {
13
- logger.log(`Publishing version ${version} from ${packagePath} to Visual Studio Marketplace`);
14
- options.push(...['--packagePath', packagePath]);
14
+ // Ensure packagePath is a list
15
+ if (typeof packagePath === 'string') {
16
+ packagePath = [packagePath];
17
+ }
18
+
19
+ options.push('--packagePath', ...packagePath);
20
+ message += ` from ${packagePath.join(', ')}`;
15
21
  } else {
16
- logger.log(`Publishing version ${version} to Visual Studio Marketplace`);
17
- options.push(...[version, '--no-git-tag-version']);
22
+ options.push(version, '--no-git-tag-version');
23
+
24
+ if (isTargetEnabled()) {
25
+ // @ts-ignore
26
+ options.push('--target', process.env.VSCE_TARGET);
27
+ message += ` for target ${process.env.VSCE_TARGET}`;
28
+ }
18
29
  }
30
+ message += ' to Visual Studio Marketplace';
31
+ logger.log(message);
19
32
 
20
33
  await execa('vsce', options, { stdio: 'inherit', preferLocal: true, cwd });
21
34
 
@@ -24,13 +37,14 @@ module.exports = async (version, packagePath, logger, cwd) => {
24
37
 
25
38
  const vsceRelease = {
26
39
  name: 'Visual Studio Marketplace',
27
- url: vsceUrl
40
+ url: vsceUrl,
28
41
  };
29
42
 
30
43
  if (isOvsxEnabled()) {
31
44
  logger.log('Now publishing to OpenVSX');
32
45
 
33
- await execa('ovsx', ['publish', packagePath], { stdio: 'inherit', preferLocal: true, cwd });
46
+ // When publishing to OpenVSX, packagePath will be always set
47
+ await execa('ovsx', options, { stdio: 'inherit', preferLocal: true, cwd });
34
48
  const ovsxUrl = `https://open-vsx.org/extension/${publisher}/${name}/${version}`;
35
49
 
36
50
  logger.log(`The new ovsx version is available at ${ovsxUrl}`);
package/lib/utils.js ADDED
@@ -0,0 +1,12 @@
1
+ const isOvsxEnabled = () => {
2
+ return 'OVSX_PAT' in process.env;
3
+ };
4
+
5
+ const isTargetEnabled = () => {
6
+ return 'VSCE_TARGET' in process.env;
7
+ };
8
+
9
+ module.exports = {
10
+ isTargetEnabled,
11
+ isOvsxEnabled,
12
+ };
@@ -7,12 +7,18 @@ module.exports = async (logger, cwd) => {
7
7
  logger.log('Verifying authentication for vsce');
8
8
 
9
9
  if (!process.env.VSCE_PAT) {
10
- throw new SemanticReleaseError('No vsce personal access token specified (set the `VSCE_PAT` environment variable).', 'ENOVSCEPAT');
10
+ throw new SemanticReleaseError(
11
+ 'No vsce personal access token specified (set the `VSCE_PAT` environment variable).',
12
+ 'ENOVSCEPAT'
13
+ );
11
14
  }
12
15
 
13
16
  try {
14
17
  await execa('vsce', ['verify-pat'], { preferLocal: true, cwd });
15
18
  } catch (e) {
16
- throw new SemanticReleaseError(`Invalid vsce token. Additional information:\n\n${e}`, 'EINVALIDVSCETOKEN');
19
+ throw new SemanticReleaseError(
20
+ `Invalid vsce personal access token. Additional information:\n\n${e}`,
21
+ 'EINVALIDVSCETOKEN'
22
+ );
17
23
  }
18
24
  };
@@ -1,29 +1,32 @@
1
1
  // @ts-check
2
2
 
3
3
  const SemanticReleaseError = require('@semantic-release/error');
4
+ const execa = require('execa');
5
+ const { isOvsxEnabled } = require('./utils');
4
6
 
5
- const isOvsxEnabled = () => {
6
- return 'OVSX_PAT' in process.env;
7
- };
8
-
9
- module.exports = async (logger) => {
7
+ module.exports = async (logger, cwd) => {
10
8
  logger.log('Verifying authentication for ovsx');
11
9
 
12
10
  if (!isOvsxEnabled()) {
13
- 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');
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
14
  return;
15
15
  }
16
16
 
17
17
  if (!process.env.OVSX_PAT) {
18
- throw new SemanticReleaseError('Empty ovsx personal access token specified.', 'EINVALIDOVSXPAT');
18
+ throw new SemanticReleaseError(
19
+ 'Empty ovsx personal access token specified.',
20
+ 'EINVALIDOVSXPAT'
21
+ );
19
22
  }
20
23
 
21
- // TODO: waiting for https://github.com/eclipse/openvsx/issues/313
22
- // try {
23
- // await execa('ovsx', ['verify-pat'], { preferLocal: true, cwd });
24
- // } catch (e) {
25
- // throw new SemanticReleaseError(`Invalid ovsx personal access token. Additional information:\n\n${e}`, 'EINVALIDOVSXPAT');
26
- // }
24
+ try {
25
+ await execa('ovsx', ['verify-pat'], { preferLocal: true, cwd });
26
+ } catch (e) {
27
+ throw new SemanticReleaseError(
28
+ `Invalid ovsx personal access token. Additional information:\n\n${e}`,
29
+ 'EINVALIDOVSXPAT'
30
+ );
31
+ }
27
32
  };
28
-
29
- module.exports.isOvsxEnabled = isOvsxEnabled;
package/lib/verify-pkg.js CHANGED
@@ -17,15 +17,24 @@ module.exports = async () => {
17
17
  try {
18
18
  packageJson = await readJson('./package.json');
19
19
  } catch (error) {
20
- throw new SemanticReleaseError('The `package.json` seems to be invalid.', 'EINVALIDPKG');
20
+ throw new SemanticReleaseError(
21
+ 'The `package.json` seems to be invalid.',
22
+ 'EINVALIDPKG'
23
+ );
21
24
  }
22
25
 
23
26
  const { name, publisher } = packageJson;
24
27
 
25
28
  if (!name) {
26
- throw new SemanticReleaseError('No `name` found in `package.json`.', 'ENOPKGNAME');
29
+ throw new SemanticReleaseError(
30
+ 'No `name` found in `package.json`.',
31
+ 'ENOPKGNAME'
32
+ );
27
33
  }
28
34
  if (!publisher) {
29
- throw new SemanticReleaseError('No `publisher` found in `package.json`.', 'ENOPUBLISHER');
35
+ throw new SemanticReleaseError(
36
+ 'No `publisher` found in `package.json`.',
37
+ 'ENOPUBLISHER'
38
+ );
30
39
  }
31
40
  };
@@ -0,0 +1,29 @@
1
+ // @ts-check
2
+
3
+ const SemanticReleaseError = require('@semantic-release/error');
4
+ const { isTargetEnabled } = require('./utils');
5
+
6
+ module.exports = async () => {
7
+ if (!isTargetEnabled()) {
8
+ return;
9
+ }
10
+
11
+ if (!process.env.VSCE_TARGET) {
12
+ throw new SemanticReleaseError(
13
+ 'Empty vsce target specified.',
14
+ 'EINVALIDVSCETARGET'
15
+ );
16
+ }
17
+
18
+ const targets = require('@vscode/vsce/out/package').Targets;
19
+
20
+ // Throw if the target is not supported
21
+ if (!targets.has(process.env.VSCE_TARGET)) {
22
+ throw new SemanticReleaseError(
23
+ `Unsupported vsce target: ${
24
+ process.env.VSCE_TARGET
25
+ }. Available targets: ${Object.values(targets).join(', ')}`,
26
+ 'EUNSUPPORTEDVSCETARGET'
27
+ );
28
+ }
29
+ };