semantic-release-vsce 5.2.3 → 5.3.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 +202 -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 +8 -8
- package/lib/verify-pkg.js +12 -3
- package/lib/verify-target.js +29 -0
- package/lib/verify.js +2 -0
- package/package.json +16 -13
- 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 +27 -8
- 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/.eslintrc
CHANGED
|
@@ -1,26 +1,14 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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
|
}
|
|
@@ -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
package/.prettierignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.nyc_output
|
package/.prettierrc
ADDED
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 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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
|
70
|
-
|
|
|
71
|
-
| `
|
|
72
|
-
| `
|
|
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.
|
|
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
|
|
111
|
+
### Github Actions
|
|
85
112
|
|
|
86
113
|
```yaml
|
|
87
114
|
name: release
|
|
@@ -98,11 +125,164 @@ jobs:
|
|
|
98
125
|
- uses: actions/setup-node@v3
|
|
99
126
|
with:
|
|
100
127
|
node-version: 16
|
|
101
|
-
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
128
|
+
- run: npm ci
|
|
129
|
+
- run: npx semantic-release
|
|
130
|
+
env:
|
|
131
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
132
|
+
VSCE_PAT: ${{ secrets.VSCE_PAT }}
|
|
133
|
+
# In case you want to publish to OpenVSX
|
|
134
|
+
OVSX_PAT: ${{ secrets.OVSX_PAT }}
|
|
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
|
+
- shell: pwsh
|
|
257
|
+
run: echo "target=${{ matrix.platform }}-${{ matrix.arch }}" >> $env:GITHUB_ENV
|
|
258
|
+
- run: npx semantic-release --extends package.release.config.js
|
|
259
|
+
env:
|
|
260
|
+
VSCE_TARGET: ${{ env.target }}
|
|
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
|
+
|
|
267
|
+
- uses: actions/upload-artifact@v3
|
|
268
|
+
with:
|
|
269
|
+
name: ${{ env.target }}
|
|
270
|
+
path: '*.vsix'
|
|
271
|
+
|
|
272
|
+
release:
|
|
273
|
+
runs-on: ubuntu-latest
|
|
274
|
+
needs: build
|
|
275
|
+
steps:
|
|
276
|
+
- uses: actions/checkout@v3
|
|
277
|
+
- uses: actions/setup-node@v3
|
|
278
|
+
with:
|
|
279
|
+
node-version: 16
|
|
280
|
+
- run: npm ci
|
|
281
|
+
- uses: actions/download-artifact@v3
|
|
282
|
+
- run: npx semantic-release --extends publish.release.config.js
|
|
105
283
|
env:
|
|
106
284
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
107
285
|
VSCE_PAT: ${{ secrets.VSCE_PAT }}
|
|
286
|
+
# In case you want to publish to OpenVSX
|
|
287
|
+
OVSX_PAT: ${{ secrets.OVSX_PAT }}
|
|
108
288
|
```
|
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
|
|
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
|
|
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(
|
|
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
|
|
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(
|
|
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
|
-
|
|
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('./
|
|
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(
|
|
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
|
-
|
|
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 = [
|
|
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('./
|
|
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
|
-
|
|
14
|
-
|
|
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
|
-
|
|
17
|
-
|
|
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
|
-
|
|
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
package/lib/verify-auth.js
CHANGED
|
@@ -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(
|
|
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(
|
|
19
|
+
throw new SemanticReleaseError(
|
|
20
|
+
`Invalid vsce token. Additional information:\n\n${e}`,
|
|
21
|
+
'EINVALIDVSCETOKEN'
|
|
22
|
+
);
|
|
17
23
|
}
|
|
18
24
|
};
|
package/lib/verify-ovsx-auth.js
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
|
|
3
3
|
const SemanticReleaseError = require('@semantic-release/error');
|
|
4
|
-
|
|
5
|
-
const isOvsxEnabled = () => {
|
|
6
|
-
return 'OVSX_PAT' in process.env;
|
|
7
|
-
};
|
|
4
|
+
const { isOvsxEnabled } = require('./utils');
|
|
8
5
|
|
|
9
6
|
module.exports = async (logger) => {
|
|
10
7
|
logger.log('Verifying authentication for ovsx');
|
|
11
8
|
|
|
12
9
|
if (!isOvsxEnabled()) {
|
|
13
|
-
logger.log(
|
|
10
|
+
logger.log(
|
|
11
|
+
'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
|
+
);
|
|
14
13
|
return;
|
|
15
14
|
}
|
|
16
15
|
|
|
17
16
|
if (!process.env.OVSX_PAT) {
|
|
18
|
-
throw new SemanticReleaseError(
|
|
17
|
+
throw new SemanticReleaseError(
|
|
18
|
+
'Empty ovsx personal access token specified.',
|
|
19
|
+
'EINVALIDOVSXPAT'
|
|
20
|
+
);
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
// TODO: waiting for https://github.com/eclipse/openvsx/issues/313
|
|
@@ -25,5 +27,3 @@ module.exports = async (logger) => {
|
|
|
25
27
|
// throw new SemanticReleaseError(`Invalid ovsx personal access token. Additional information:\n\n${e}`, 'EINVALIDOVSXPAT');
|
|
26
28
|
// }
|
|
27
29
|
};
|
|
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(
|
|
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(
|
|
29
|
+
throw new SemanticReleaseError(
|
|
30
|
+
'No `name` found in `package.json`.',
|
|
31
|
+
'ENOPKGNAME'
|
|
32
|
+
);
|
|
27
33
|
}
|
|
28
34
|
if (!publisher) {
|
|
29
|
-
throw new SemanticReleaseError(
|
|
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('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
|
+
};
|
package/lib/verify.js
CHANGED
|
@@ -3,9 +3,11 @@
|
|
|
3
3
|
const verifyPkg = require('./verify-pkg');
|
|
4
4
|
const verifyAuth = require('./verify-auth');
|
|
5
5
|
const verifyOvsxAuth = require('./verify-ovsx-auth');
|
|
6
|
+
const verifyTarget = require('./verify-target');
|
|
6
7
|
|
|
7
8
|
module.exports = async (pluginConfig, { logger, cwd }) => {
|
|
8
9
|
await verifyPkg();
|
|
10
|
+
await verifyTarget();
|
|
9
11
|
|
|
10
12
|
if (pluginConfig?.publish !== false) {
|
|
11
13
|
await verifyAuth(logger, cwd);
|