semantic-release-vsce 5.2.1 → 5.2.3

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/index.js CHANGED
@@ -1,3 +1,5 @@
1
+ // @ts-check
2
+
1
3
  const verifyVsce = require('./lib/verify');
2
4
  const vscePublish = require('./lib/publish');
3
5
  const vscePrepare = require('./lib/prepare');
@@ -6,29 +8,29 @@ let verified = false;
6
8
  let prepared = false;
7
9
  let packagePath;
8
10
 
9
- async function verifyConditions (pluginConfig, { logger }) {
10
- await verifyVsce(logger, pluginConfig);
11
+ async function verifyConditions (pluginConfig, { logger, cwd }) {
12
+ await verifyVsce(pluginConfig, { logger, cwd });
11
13
  verified = true;
12
14
  }
13
15
 
14
- async function prepare (pluginConfig, { nextRelease: { version }, logger }) {
16
+ async function prepare (pluginConfig, { nextRelease: { version }, logger, cwd }) {
15
17
  if (!verified) {
16
- await verifyVsce(logger);
18
+ await verifyVsce(pluginConfig, { logger, cwd });
17
19
  verified = true;
18
20
  }
19
- packagePath = await vscePrepare(version, pluginConfig.packageVsix, logger);
21
+ packagePath = await vscePrepare(version, pluginConfig.packageVsix, logger, cwd);
20
22
  prepared = true;
21
23
  }
22
24
 
23
- async function publish (pluginConfig, { nextRelease: { version }, logger }) {
25
+ async function publish (pluginConfig, { nextRelease: { version }, logger, cwd }) {
24
26
  if (!verified) {
25
- await verifyVsce(logger);
27
+ await verifyVsce(pluginConfig, { logger, cwd });
26
28
  verified = true;
27
29
  }
28
30
 
29
31
  if (!prepared) {
30
32
  // BC: prior to semantic-release v15 prepare was part of publish
31
- packagePath = await vscePrepare(version, pluginConfig.packageVsix, logger);
33
+ packagePath = await vscePrepare(version, pluginConfig.packageVsix, logger, cwd);
32
34
  }
33
35
 
34
36
  // If publishing is disabled, return early.
package/lib/prepare.js CHANGED
@@ -1,8 +1,10 @@
1
+ // @ts-check
2
+
1
3
  const execa = require('execa');
2
4
  const { readJson } = require('fs-extra');
3
5
  const { isOvsxEnabled } = require('./verify-ovsx-auth');
4
6
 
5
- module.exports = async (version, packageVsix, logger) => {
7
+ module.exports = async (version, packageVsix, logger, cwd) => {
6
8
  const ovsxEnabled = isOvsxEnabled();
7
9
  if (packageVsix || ovsxEnabled) {
8
10
  if (!packageVsix && ovsxEnabled) {
@@ -22,7 +24,7 @@ module.exports = async (version, packageVsix, logger) => {
22
24
 
23
25
  const options = ['package', version, '--no-git-tag-version', '--out', packagePath];
24
26
 
25
- await execa('vsce', options, { stdio: 'inherit' });
27
+ await execa('vsce', options, { stdio: 'inherit', preferLocal: true, cwd });
26
28
 
27
29
  return packagePath;
28
30
  }
package/lib/publish.js CHANGED
@@ -1,8 +1,10 @@
1
+ // @ts-check
2
+
1
3
  const execa = require('execa');
2
4
  const { readJson } = require('fs-extra');
3
5
  const { isOvsxEnabled } = require('./verify-ovsx-auth');
4
6
 
5
- module.exports = async (version, packagePath, logger) => {
7
+ module.exports = async (version, packagePath, logger, cwd) => {
6
8
  const { publisher, name } = await readJson('./package.json');
7
9
 
8
10
  const options = ['publish'];
@@ -15,7 +17,7 @@ module.exports = async (version, packagePath, logger) => {
15
17
  options.push(...[version, '--no-git-tag-version']);
16
18
  }
17
19
 
18
- await execa('vsce', options, { stdio: 'inherit' });
20
+ await execa('vsce', options, { stdio: 'inherit', preferLocal: true, cwd });
19
21
 
20
22
  const vsceUrl = `https://marketplace.visualstudio.com/items?itemName=${publisher}.${name}`;
21
23
  logger.log(`The new version is available at ${vsceUrl}.`);
@@ -28,7 +30,7 @@ module.exports = async (version, packagePath, logger) => {
28
30
  if (isOvsxEnabled()) {
29
31
  logger.log('Now publishing to OpenVSX');
30
32
 
31
- await execa('ovsx', ['publish', packagePath], { stdio: 'inherit' });
33
+ await execa('ovsx', ['publish', packagePath], { stdio: 'inherit', preferLocal: true, cwd });
32
34
  const ovsxUrl = `https://open-vsx.org/extension/${publisher}/${name}/${version}`;
33
35
 
34
36
  logger.log(`The new ovsx version is available at ${ovsxUrl}`);
@@ -1,7 +1,9 @@
1
+ // @ts-check
2
+
1
3
  const execa = require('execa');
2
4
  const SemanticReleaseError = require('@semantic-release/error');
3
5
 
4
- module.exports = async (logger) => {
6
+ module.exports = async (logger, cwd) => {
5
7
  logger.log('Verifying authentication for vsce');
6
8
 
7
9
  if (!process.env.VSCE_PAT) {
@@ -9,7 +11,7 @@ module.exports = async (logger) => {
9
11
  }
10
12
 
11
13
  try {
12
- await execa('vsce', ['verify-pat']);
14
+ await execa('vsce', ['verify-pat'], { preferLocal: true, cwd });
13
15
  } catch (e) {
14
16
  throw new SemanticReleaseError(`Invalid vsce token. Additional information:\n\n${e}`, 'EINVALIDVSCETOKEN');
15
17
  }
@@ -1,3 +1,5 @@
1
+ // @ts-check
2
+
1
3
  const SemanticReleaseError = require('@semantic-release/error');
2
4
 
3
5
  const isOvsxEnabled = () => {
@@ -18,7 +20,7 @@ module.exports = async (logger) => {
18
20
 
19
21
  // TODO: waiting for https://github.com/eclipse/openvsx/issues/313
20
22
  // try {
21
- // await execa('ovsx', ['verify-pat']);
23
+ // await execa('ovsx', ['verify-pat'], { preferLocal: true, cwd });
22
24
  // } catch (e) {
23
25
  // throw new SemanticReleaseError(`Invalid ovsx personal access token. Additional information:\n\n${e}`, 'EINVALIDOVSXPAT');
24
26
  // }
package/lib/verify-pkg.js CHANGED
@@ -1,3 +1,5 @@
1
+ // @ts-check
2
+
1
3
  const SemanticReleaseError = require('@semantic-release/error');
2
4
  const { readJson } = require('fs-extra');
3
5
  const fs = require('fs');
package/lib/verify.js CHANGED
@@ -1,12 +1,14 @@
1
+ // @ts-check
2
+
1
3
  const verifyPkg = require('./verify-pkg');
2
4
  const verifyAuth = require('./verify-auth');
3
5
  const verifyOvsxAuth = require('./verify-ovsx-auth');
4
6
 
5
- module.exports = async (logger, pluginConfig) => {
7
+ module.exports = async (pluginConfig, { logger, cwd }) => {
6
8
  await verifyPkg();
7
9
 
8
10
  if (pluginConfig?.publish !== false) {
9
- await verifyAuth(logger);
11
+ await verifyAuth(logger, cwd);
10
12
  await verifyOvsxAuth(logger);
11
13
  }
12
14
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "semantic-release-vsce",
3
- "version": "5.2.1",
3
+ "version": "5.2.3",
4
4
  "description": "semantic-release plugin to package and publish VS Code extensions",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -8,7 +8,8 @@ const semanticReleasePayload = {
8
8
  },
9
9
  logger: {
10
10
  log: sinon.fake()
11
- }
11
+ },
12
+ cwd: process.cwd()
12
13
  };
13
14
 
14
15
  const pluginConfig = {
@@ -39,7 +40,7 @@ test('verifyConditions', async t => {
39
40
 
40
41
  await verifyConditions(pluginConfig, semanticReleasePayload);
41
42
 
42
- t.true(verifyVsceStub.calledOnceWith(semanticReleasePayload.logger));
43
+ t.true(verifyVsceStub.calledOnceWith(pluginConfig, { logger: semanticReleasePayload.logger, cwd: semanticReleasePayload.cwd }));
43
44
  });
44
45
 
45
46
  test('prepare and unverified', async t => {
@@ -53,11 +54,12 @@ test('prepare and unverified', async t => {
53
54
 
54
55
  await prepare(pluginConfig, semanticReleasePayload);
55
56
 
56
- t.true(verifyVsceStub.calledOnceWith(semanticReleasePayload.logger));
57
+ t.true(verifyVsceStub.calledOnceWith(pluginConfig, { logger: semanticReleasePayload.logger, cwd: semanticReleasePayload.cwd }));
57
58
  t.deepEqual(vscePrepareStub.getCall(0).args, [
58
59
  semanticReleasePayload.nextRelease.version,
59
60
  pluginConfig.packageVsix,
60
- semanticReleasePayload.logger
61
+ semanticReleasePayload.logger,
62
+ semanticReleasePayload.cwd
61
63
  ]);
62
64
  });
63
65
 
@@ -76,7 +78,8 @@ test('prepare and verified', async t => {
76
78
  t.deepEqual(vscePrepareStub.getCall(0).args, [
77
79
  semanticReleasePayload.nextRelease.version,
78
80
  pluginConfig.packageVsix,
79
- semanticReleasePayload.logger
81
+ semanticReleasePayload.logger,
82
+ semanticReleasePayload.cwd
80
83
  ]);
81
84
  });
82
85
 
@@ -5,6 +5,7 @@ const proxyquire = require('proxyquire');
5
5
  const logger = {
6
6
  log: sinon.fake()
7
7
  };
8
+ const cwd = process.cwd();
8
9
 
9
10
  test.beforeEach(t => {
10
11
  t.context.stubs = {
@@ -37,10 +38,10 @@ test('packageVsix is a string', async t => {
37
38
  const version = '1.0.0';
38
39
  const packageVsix = 'test.vsix';
39
40
  const packagePath = packageVsix;
40
- const result = await prepare(version, packageVsix, logger);
41
+ const result = await prepare(version, packageVsix, logger, cwd);
41
42
 
42
43
  t.deepEqual(result, packagePath);
43
- t.deepEqual(execaStub.getCall(0).args, ['vsce', ['package', version, '--no-git-tag-version', '--out', packagePath], { stdio: 'inherit' }]);
44
+ t.deepEqual(execaStub.getCall(0).args, ['vsce', ['package', version, '--no-git-tag-version', '--out', packagePath], { stdio: 'inherit', preferLocal: true, cwd }]);
44
45
  });
45
46
 
46
47
  test('packageVsix is true', async t => {
@@ -60,10 +61,10 @@ test('packageVsix is true', async t => {
60
61
  const packageVsix = true;
61
62
  const packagePath = `${name}-${version}.vsix`;
62
63
 
63
- const result = await prepare(version, packageVsix, logger);
64
+ const result = await prepare(version, packageVsix, logger, cwd);
64
65
 
65
66
  t.deepEqual(result, packagePath);
66
- t.deepEqual(execaStub.getCall(0).args, ['vsce', ['package', version, '--no-git-tag-version', '--out', packagePath], { stdio: 'inherit' }]);
67
+ t.deepEqual(execaStub.getCall(0).args, ['vsce', ['package', version, '--no-git-tag-version', '--out', packagePath], { stdio: 'inherit', preferLocal: true, cwd }]);
67
68
  });
68
69
 
69
70
  test('packageVsix is not set but OVSX_PAT is', async t => {
@@ -87,8 +88,8 @@ test('packageVsix is not set but OVSX_PAT is', async t => {
87
88
  const packageVsix = undefined;
88
89
  const packagePath = `${name}-${version}.vsix`;
89
90
 
90
- const result = await prepare(version, packageVsix, logger);
91
+ const result = await prepare(version, packageVsix, logger, cwd);
91
92
 
92
93
  t.deepEqual(result, packagePath);
93
- t.deepEqual(execaStub.getCall(0).args, ['vsce', ['package', version, '--no-git-tag-version', '--out', packagePath], { stdio: 'inherit' }]);
94
+ t.deepEqual(execaStub.getCall(0).args, ['vsce', ['package', version, '--no-git-tag-version', '--out', packagePath], { stdio: 'inherit', preferLocal: true, cwd }]);
94
95
  });
@@ -5,6 +5,7 @@ const proxyquire = require('proxyquire');
5
5
  const logger = {
6
6
  log: sinon.fake()
7
7
  };
8
+ const cwd = process.cwd();
8
9
 
9
10
  test.beforeEach(t => {
10
11
  t.context.stubs = {
@@ -35,13 +36,13 @@ test('publish', async t => {
35
36
  sinon.stub(process, 'env').value({
36
37
  VSCE_PAT: token
37
38
  });
38
- const result = await publish(version, undefined, logger);
39
+ const result = await publish(version, undefined, logger, cwd);
39
40
 
40
41
  t.deepEqual(result, {
41
42
  name: 'Visual Studio Marketplace',
42
43
  url: `https://marketplace.visualstudio.com/items?itemName=${publisher}.${name}`
43
44
  });
44
- t.deepEqual(execaStub.getCall(0).args, ['vsce', ['publish', version, '--no-git-tag-version'], { stdio: 'inherit' }]);
45
+ t.deepEqual(execaStub.getCall(0).args, ['vsce', ['publish', version, '--no-git-tag-version'], { stdio: 'inherit', preferLocal: true, cwd }]);
45
46
  });
46
47
 
47
48
  test('publish with packagePath', async t => {
@@ -64,13 +65,13 @@ test('publish with packagePath', async t => {
64
65
  sinon.stub(process, 'env').value({
65
66
  VSCE_PAT: token
66
67
  });
67
- const result = await publish(version, packagePath, logger);
68
+ const result = await publish(version, packagePath, logger, cwd);
68
69
 
69
70
  t.deepEqual(result, {
70
71
  name: 'Visual Studio Marketplace',
71
72
  url: `https://marketplace.visualstudio.com/items?itemName=${publisher}.${name}`
72
73
  });
73
- t.deepEqual(execaStub.getCall(0).args, ['vsce', ['publish', '--packagePath', packagePath], { stdio: 'inherit' }]);
74
+ t.deepEqual(execaStub.getCall(0).args, ['vsce', ['publish', '--packagePath', packagePath], { stdio: 'inherit', preferLocal: true, cwd }]);
74
75
  });
75
76
 
76
77
  test('publish to OpenVSX', async t => {
@@ -94,17 +95,17 @@ test('publish to OpenVSX', async t => {
94
95
  OVSX_PAT: token,
95
96
  VSCE_PAT: token
96
97
  });
97
- const result = await publish(version, packagePath, logger);
98
+ const result = await publish(version, packagePath, logger, cwd);
98
99
 
99
100
  t.deepEqual(result, {
100
101
  name: 'Visual Studio Marketplace',
101
102
  url: `https://marketplace.visualstudio.com/items?itemName=${publisher}.${name}`
102
103
  });
103
- t.deepEqual(execaStub.getCall(0).args, ['vsce', ['publish', '--packagePath', packagePath], { stdio: 'inherit' }]);
104
+ t.deepEqual(execaStub.getCall(0).args, ['vsce', ['publish', '--packagePath', packagePath], { stdio: 'inherit', preferLocal: true, cwd }]);
104
105
 
105
106
  // t.deepEqual(result[1], {
106
107
  // name: 'Open VSX Registry',
107
108
  // url: `https://open-vsx.org/extension/${publisher}/${name}/${version}`
108
109
  // });
109
- t.deepEqual(execaStub.getCall(1).args, ['ovsx', ['publish', packagePath], { stdio: 'inherit' }]);
110
+ t.deepEqual(execaStub.getCall(1).args, ['ovsx', ['publish', packagePath], { stdio: 'inherit', preferLocal: true, cwd }]);
110
111
  });
@@ -6,6 +6,7 @@ const SemanticReleaseError = require('@semantic-release/error');
6
6
  const logger = {
7
7
  log: sinon.fake()
8
8
  };
9
+ const cwd = process.cwd();
9
10
 
10
11
  test('VSCE_PAT is set', async t => {
11
12
  sinon.stub(process, 'env').value({
@@ -13,7 +14,7 @@ test('VSCE_PAT is set', async t => {
13
14
  });
14
15
 
15
16
  const verifyAuth = proxyquire('../lib/verify-auth', {
16
- execa: sinon.stub().withArgs('vsce', ['verify-pat']).resolves()
17
+ execa: sinon.stub().withArgs('vsce', ['verify-pat'], { preferLocal: true, cwd }).resolves()
17
18
  });
18
19
 
19
20
  await t.notThrowsAsync(() => verifyAuth(logger));
@@ -23,7 +24,7 @@ test('VSCE_PAT is not set', async t => {
23
24
  sinon.stub(process, 'env').value({});
24
25
 
25
26
  const verifyAuth = proxyquire('../lib/verify-auth', {
26
- execa: sinon.stub().withArgs('vsce', ['verify-pat']).resolves()
27
+ execa: sinon.stub().withArgs('vsce', ['verify-pat'], { preferLocal: true, cwd }).resolves()
27
28
  });
28
29
 
29
30
  await t.throwsAsync(() => verifyAuth(logger), { instanceOf: SemanticReleaseError, code: 'ENOVSCEPAT' });
@@ -35,7 +36,7 @@ test('VSCE_PAT is valid', async t => {
35
36
  });
36
37
 
37
38
  const verifyAuth = proxyquire('../lib/verify-auth', {
38
- execa: sinon.stub().withArgs('vsce', ['verify-pat']).resolves()
39
+ execa: sinon.stub().withArgs('vsce', ['verify-pat'], { preferLocal: true, cwd }).resolves()
39
40
  });
40
41
 
41
42
  await t.notThrowsAsync(() => verifyAuth(logger));
@@ -47,7 +48,7 @@ test('VSCE_PAT is invalid', async t => {
47
48
  });
48
49
 
49
50
  const verifyAuth = proxyquire('../lib/verify-auth', {
50
- execa: sinon.stub().withArgs('vsce', ['verify-pat']).rejects()
51
+ execa: sinon.stub().withArgs('vsce', ['verify-pat'], { preferLocal: true, cwd }).rejects()
51
52
  });
52
53
 
53
54
  await t.throwsAsync(() => verifyAuth(logger), { instanceOf: SemanticReleaseError, code: 'EINVALIDVSCETOKEN' });
@@ -5,6 +5,7 @@ const proxyquire = require('proxyquire');
5
5
  const logger = {
6
6
  log: sinon.fake()
7
7
  };
8
+ const cwd = process.cwd();
8
9
 
9
10
  test('resolves', async t => {
10
11
  const verify = proxyquire('../lib/verify', {
@@ -12,7 +13,7 @@ test('resolves', async t => {
12
13
  './verify-pkg': sinon.stub().resolves()
13
14
  });
14
15
 
15
- await t.notThrowsAsync(() => verify(logger));
16
+ await t.notThrowsAsync(() => verify({}, { logger, cwd }));
16
17
  });
17
18
 
18
19
  test('rejects with verify-auth', async t => {
@@ -21,7 +22,7 @@ test('rejects with verify-auth', async t => {
21
22
  './verify-pkg': sinon.stub().resolves()
22
23
  });
23
24
 
24
- await t.throwsAsync(() => verify(logger));
25
+ await t.throwsAsync(() => verify({}, { logger, cwd }));
25
26
  });
26
27
 
27
28
  test('rejects with verify-pkg', async t => {
@@ -30,7 +31,7 @@ test('rejects with verify-pkg', async t => {
30
31
  './verify-pkg': sinon.stub().rejects()
31
32
  });
32
33
 
33
- await t.throwsAsync(() => verify(logger));
34
+ await t.throwsAsync(() => verify({}, { logger, cwd }));
34
35
  });
35
36
 
36
37
  test('is does not verify the auth tokens if publishing is disabled', async t => {
@@ -45,7 +46,7 @@ test('is does not verify the auth tokens if publishing is disabled', async t =>
45
46
  './verify-ovsx-auth': stubs.verifyOvsxAuthStub
46
47
  });
47
48
 
48
- await verify(logger, { publish: false });
49
+ await verify({ publish: false }, { logger, cwd });
49
50
 
50
51
  t.true(stubs.verifyAuthStub.notCalled);
51
52
  t.true(stubs.verifyOvsxAuthStub.notCalled);