semantic-release-vsce 5.3.0 → 5.5.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 CHANGED
@@ -90,11 +90,11 @@ Which `.vsix` file (or files) to publish. This controls what value will be used
90
90
 
91
91
  ### Environment variables
92
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 |
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}`). 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
98
 
99
99
  ### Publishing to OpenVSX
100
100
 
@@ -178,13 +178,13 @@ jobs:
178
178
  'semantic-release-vsce',
179
179
  {
180
180
  packageVsix: false,
181
- publishPackagePath: '*.vsix',
181
+ publishPackagePath: '*/*.vsix',
182
182
  },
183
183
  ],
184
184
  [
185
185
  '@semantic-release/github',
186
186
  {
187
- assets: '*.vsix',
187
+ assets: '*/*.vsix',
188
188
  },
189
189
  ],
190
190
  ],
@@ -209,55 +209,55 @@ jobs:
209
209
  matrix:
210
210
  include:
211
211
  - os: windows-latest
212
- platform: win32
213
- arch: x64
212
+ target: win32-x64
214
213
  npm_config_arch: x64
215
214
  - os: windows-latest
216
- platform: win32
217
- arch: ia32
215
+ target: win32-ia32
218
216
  npm_config_arch: ia32
219
217
  - os: windows-latest
220
- platform: win32
221
- arch: arm64
218
+ target: win32-arm64
222
219
  npm_config_arch: arm
223
220
  - os: ubuntu-latest
224
- platform: linux
225
- arch: x64
221
+ taget: linux-x64
226
222
  npm_config_arch: x64
227
223
  - os: ubuntu-latest
228
- platform: linux
229
- arch: arm64
224
+ target: linux-arm64
230
225
  npm_config_arch: arm64
231
226
  - os: ubuntu-latest
232
- platform: linux
233
- arch: armhf
227
+ target: linux-armhf
234
228
  npm_config_arch: arm
235
229
  - os: ubuntu-latest
236
- platform: alpine
237
- arch: x64
230
+ target: alpine-x64
238
231
  npm_config_arch: x64
239
232
  - os: macos-latest
240
- platform: darwin
241
- arch: x64
233
+ target: darwin-x64
242
234
  npm_config_arch: x64
243
235
  - os: macos-latest
244
- platform: darwin
245
- arch: arm64
236
+ target: darwin-arm64
246
237
  npm_config_arch: arm64
238
+ - os: ubuntu-latest
239
+ target: universal
247
240
  runs-on: ${{ matrix.os }}
248
241
  steps:
249
242
  - uses: actions/checkout@v3
243
+
250
244
  - uses: actions/setup-node@v3
251
245
  with:
252
246
  node-version: 16
253
- - run: npm ci
247
+
248
+ - if: matrix.target != 'universal'
249
+ name: Install dependencies (with binaries)
250
+ run: npm ci
254
251
  env:
255
252
  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
253
+
254
+ - if: matrix.target == 'universal'
255
+ name: Install dependencies (without binaries)
256
+ run: npm ci
257
+
258
+ - run: npx semantic-release --extends ./package.release.config.js
259
259
  env:
260
- VSCE_TARGET: ${{ env.target }}
260
+ VSCE_TARGET: ${{ matrix.target }}
261
261
  # All tokens are required since semantic-release needs to validate them
262
262
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
263
263
  VSCE_PAT: ${{ secrets.VSCE_PAT }}
@@ -266,7 +266,7 @@ jobs:
266
266
 
267
267
  - uses: actions/upload-artifact@v3
268
268
  with:
269
- name: ${{ env.target }}
269
+ name: ${{ matrix.target }}
270
270
  path: '*.vsix'
271
271
 
272
272
  release:
@@ -274,15 +274,21 @@ jobs:
274
274
  needs: build
275
275
  steps:
276
276
  - uses: actions/checkout@v3
277
+
277
278
  - uses: actions/setup-node@v3
278
279
  with:
279
280
  node-version: 16
281
+
280
282
  - run: npm ci
283
+
281
284
  - uses: actions/download-artifact@v3
282
- - run: npx semantic-release --extends publish.release.config.js
285
+
286
+ - run: npx semantic-release --extends ./publish.release.config.js
283
287
  env:
284
288
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
285
289
  VSCE_PAT: ${{ secrets.VSCE_PAT }}
286
290
  # In case you want to publish to OpenVSX
287
291
  OVSX_PAT: ${{ secrets.OVSX_PAT }}
288
292
  ```
293
+
294
+ A reference implementation can also be found in the [VS Code ShellCheck extension](https://github.com/vscode-shellcheck/vscode-shellcheck/pull/805).
package/lib/prepare.js CHANGED
@@ -40,7 +40,7 @@ module.exports = async (version, packageVsix, logger, cwd) => {
40
40
  '--out',
41
41
  packagePath,
42
42
  ];
43
- if (process.env.VSCE_TARGET) {
43
+ if (isTargetEnabled()) {
44
44
  options.push('--target', process.env.VSCE_TARGET);
45
45
  }
46
46
 
package/lib/utils.js CHANGED
@@ -3,7 +3,9 @@ const isOvsxEnabled = () => {
3
3
  };
4
4
 
5
5
  const isTargetEnabled = () => {
6
- return 'VSCE_TARGET' in process.env;
6
+ return (
7
+ 'VSCE_TARGET' in process.env && process.env.VSCE_TARGET !== 'universal'
8
+ );
7
9
  };
8
10
 
9
11
  module.exports = {
@@ -17,7 +17,7 @@ module.exports = async (logger, cwd) => {
17
17
  await execa('vsce', ['verify-pat'], { preferLocal: true, cwd });
18
18
  } catch (e) {
19
19
  throw new SemanticReleaseError(
20
- `Invalid vsce token. Additional information:\n\n${e}`,
20
+ `Invalid vsce personal access token. Additional information:\n\n${e}`,
21
21
  'EINVALIDVSCETOKEN'
22
22
  );
23
23
  }
@@ -1,9 +1,10 @@
1
1
  // @ts-check
2
2
 
3
3
  const SemanticReleaseError = require('@semantic-release/error');
4
+ const execa = require('execa');
4
5
  const { isOvsxEnabled } = require('./utils');
5
6
 
6
- module.exports = async (logger) => {
7
+ module.exports = async (logger, cwd) => {
7
8
  logger.log('Verifying authentication for ovsx');
8
9
 
9
10
  if (!isOvsxEnabled()) {
@@ -20,10 +21,12 @@ module.exports = async (logger) => {
20
21
  );
21
22
  }
22
23
 
23
- // TODO: waiting for https://github.com/eclipse/openvsx/issues/313
24
- // try {
25
- // await execa('ovsx', ['verify-pat'], { preferLocal: true, cwd });
26
- // } catch (e) {
27
- // throw new SemanticReleaseError(`Invalid ovsx personal access token. Additional information:\n\n${e}`, 'EINVALIDOVSXPAT');
28
- // }
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
+ }
29
32
  };
@@ -15,15 +15,17 @@ module.exports = async () => {
15
15
  );
16
16
  }
17
17
 
18
- const targets = require('vsce/out/package').Targets;
18
+ if (process.env.VSCE_TARGET !== 'universal') {
19
+ const targets = require('@vscode/vsce/out/package').Targets;
19
20
 
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
- );
21
+ // Throw if the target is not supported
22
+ if (!targets.has(process.env.VSCE_TARGET)) {
23
+ throw new SemanticReleaseError(
24
+ `Unsupported vsce target: ${
25
+ process.env.VSCE_TARGET
26
+ }. Available targets: ${Object.values(targets).join(', ')}`,
27
+ 'EUNSUPPORTEDVSCETARGET'
28
+ );
29
+ }
28
30
  }
29
31
  };
package/lib/verify.js CHANGED
@@ -11,6 +11,6 @@ module.exports = async (pluginConfig, { logger, cwd }) => {
11
11
 
12
12
  if (pluginConfig?.publish !== false) {
13
13
  await verifyAuth(logger, cwd);
14
- await verifyOvsxAuth(logger);
14
+ await verifyOvsxAuth(logger, cwd);
15
15
  }
16
16
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "semantic-release-vsce",
3
- "version": "5.3.0",
3
+ "version": "5.5.0",
4
4
  "description": "semantic-release plugin to package and publish VS Code extensions",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -48,11 +48,11 @@
48
48
  },
49
49
  "dependencies": {
50
50
  "@semantic-release/error": "^3.0.0",
51
+ "@vscode/vsce": "^2.15.0",
51
52
  "execa": "^5.0.0",
52
- "fs-extra": "^10.0.0",
53
+ "fs-extra": "^11.1.0",
53
54
  "glob": "^8.0.3",
54
- "ovsx": "^0.5.0",
55
- "vsce": "^2.6.3"
55
+ "ovsx": "^0.6.0"
56
56
  },
57
57
  "peerDependencies": {
58
58
  "semantic-release": ">=18"
@@ -69,10 +69,10 @@
69
69
  "husky": "^8.0.2",
70
70
  "lint-staged": "^13.0.3",
71
71
  "nyc": "^15.1.0",
72
- "prettier": "2.7.1",
72
+ "prettier": "2.8.0",
73
73
  "proxyquire": "^2.1.3",
74
74
  "semantic-release": "^19.0.2",
75
- "sinon": "^14.0.0"
75
+ "sinon": "^15.0.0"
76
76
  },
77
77
  "lint-staged": {
78
78
  "**/*": "prettier --write --ignore-unknown"
@@ -157,3 +157,33 @@ test('packageVsix when target is set', async (t) => {
157
157
  { stdio: 'inherit', preferLocal: true, cwd },
158
158
  ]);
159
159
  });
160
+
161
+ test('packageVsix when target is set to universal', async (t) => {
162
+ const { execaStub } = t.context.stubs;
163
+ const name = 'test';
164
+
165
+ const prepare = proxyquire('../lib/prepare', {
166
+ execa: execaStub,
167
+ 'fs-extra': {
168
+ readJson: sinon.stub().returns({
169
+ name,
170
+ }),
171
+ },
172
+ });
173
+
174
+ const version = '1.0.0';
175
+ const packagePath = `${name}-${version}.vsix`;
176
+
177
+ sinon.stub(process, 'env').value({
178
+ VSCE_TARGET: 'universal',
179
+ });
180
+
181
+ const result = await prepare(version, true, logger, cwd);
182
+
183
+ t.deepEqual(result, packagePath);
184
+ t.deepEqual(execaStub.getCall(0).args, [
185
+ 'vsce',
186
+ ['package', version, '--no-git-tag-version', '--out', packagePath],
187
+ { stdio: 'inherit', preferLocal: true, cwd },
188
+ ]);
189
+ });
@@ -1,7 +1,10 @@
1
1
  const test = require('ava');
2
2
  const sinon = require('sinon');
3
+ const proxyquire = require('proxyquire');
3
4
  const SemanticReleaseError = require('@semantic-release/error');
4
5
 
6
+ const cwd = process.cwd();
7
+
5
8
  test('OVSX_PAT is not set', async (t) => {
6
9
  const logger = {
7
10
  log: sinon.fake(),
@@ -22,7 +25,12 @@ test('OVSX_PAT is set', async (t) => {
22
25
  OVSX_PAT: 'abc123',
23
26
  });
24
27
 
25
- const verifyOvsxAuth = require('../lib/verify-ovsx-auth');
28
+ const verifyOvsxAuth = proxyquire('../lib/verify-ovsx-auth', {
29
+ execa: sinon
30
+ .stub()
31
+ .withArgs('ovsx', ['verify-pat'], { preferLocal: true, cwd })
32
+ .resolves(),
33
+ });
26
34
 
27
35
  await t.notThrowsAsync(() => verifyOvsxAuth(logger));
28
36
  t.true(logger.log.calledOnce);
@@ -44,3 +52,20 @@ test('OVSX_PAT is invalid', async (t) => {
44
52
  code: 'EINVALIDOVSXPAT',
45
53
  });
46
54
  });
55
+
56
+ test('OVSX_PAT is invalid but not empty', async (t) => {
57
+ const logger = {
58
+ log: sinon.fake(),
59
+ };
60
+
61
+ sinon.stub(process, 'env').value({
62
+ OVSX_PAT: 'abc123',
63
+ });
64
+
65
+ const verifyOvsxAuth = require('../lib/verify-ovsx-auth');
66
+
67
+ await t.throwsAsync(() => verifyOvsxAuth(logger), {
68
+ instanceOf: SemanticReleaseError,
69
+ code: 'EINVALIDOVSXPAT',
70
+ });
71
+ });
@@ -53,3 +53,13 @@ test('VSCE_TARGET is unsupported', async (t) => {
53
53
  code: 'EUNSUPPORTEDVSCETARGET',
54
54
  });
55
55
  });
56
+
57
+ test('VSCE_TARGET is universal', async (t) => {
58
+ sinon.stub(process, 'env').value({
59
+ VSCE_TARGET: 'universal',
60
+ });
61
+
62
+ const verifyTarget = require('../lib/verify-target');
63
+
64
+ await t.notThrowsAsync(() => verifyTarget());
65
+ });