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/lib/verify.js CHANGED
@@ -3,12 +3,14 @@
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);
12
- await verifyOvsxAuth(logger);
14
+ await verifyOvsxAuth(logger, cwd);
13
15
  }
14
16
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "semantic-release-vsce",
3
- "version": "5.2.4",
3
+ "version": "5.4.0",
4
4
  "description": "semantic-release plugin to package and publish VS Code extensions",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -10,6 +10,9 @@
10
10
  "bugs": "https://github.com/felipecrs/semantic-release-vsce/issues",
11
11
  "homepage": "https://github.com/felipecrs/semantic-release-vsce#readme",
12
12
  "author": "Morten Henriksen <mh@gi2.dk>",
13
+ "contributors": [
14
+ "Felipe Santos <felipecassiors@gmail.com>"
15
+ ],
13
16
  "keywords": [
14
17
  "semantic-release",
15
18
  "semantic-release-plugin",
@@ -18,7 +21,7 @@
18
21
  ],
19
22
  "main": "index.js",
20
23
  "scripts": {
21
- "lint": "eslint .",
24
+ "lint": "prettier --check . && eslint .",
22
25
  "release": "semantic-release",
23
26
  "test": "nyc ava",
24
27
  "posttest": "npm run lint",
@@ -29,11 +32,6 @@
29
32
  "test/**/*.test.js"
30
33
  ]
31
34
  },
32
- "commitlint": {
33
- "extends": [
34
- "@commitlint/config-conventional"
35
- ]
36
- },
37
35
  "nyc": {
38
36
  "all": true,
39
37
  "exclude": [
@@ -45,33 +43,38 @@
45
43
  ]
46
44
  },
47
45
  "volta": {
48
- "node": "16.15.1",
49
- "npm": "8.12.1"
46
+ "node": "18.12.1",
47
+ "npm": "9.1.1"
50
48
  },
51
49
  "dependencies": {
52
50
  "@semantic-release/error": "^3.0.0",
51
+ "@vscode/vsce": "^2.15.0",
53
52
  "execa": "^5.0.0",
54
- "fs-extra": "^10.0.0",
55
- "ovsx": "^0.5.0",
56
- "vsce": "^2.6.3"
53
+ "fs-extra": "^11.1.0",
54
+ "glob": "^8.0.3",
55
+ "ovsx": "^0.6.0"
57
56
  },
58
57
  "peerDependencies": {
59
58
  "semantic-release": ">=18"
60
59
  },
61
60
  "devDependencies": {
62
- "@commitlint/cli": "^17.0.0",
63
- "@commitlint/config-conventional": "^17.0.0",
64
61
  "ava": "^5.0.1",
65
62
  "conventional-changelog-conventionalcommits": "^5.0.0",
66
63
  "eslint": "^8.7.0",
64
+ "eslint-config-prettier": "^8.5.0",
67
65
  "eslint-config-standard": "^17.0.0",
68
66
  "eslint-plugin-import": "^2.20.1",
69
67
  "eslint-plugin-n": "^15.2.1",
70
68
  "eslint-plugin-promise": "^6.0.0",
71
- "husky": "^8.0.1",
69
+ "husky": "^8.0.2",
70
+ "lint-staged": "^13.0.3",
72
71
  "nyc": "^15.1.0",
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
+ },
77
+ "lint-staged": {
78
+ "**/*": "prettier --write --ignore-unknown"
76
79
  }
77
80
  }
package/release.config.js CHANGED
@@ -6,19 +6,19 @@ module.exports = {
6
6
  releaseRules: [
7
7
  {
8
8
  type: 'perf',
9
- release: 'patch'
9
+ release: 'patch',
10
10
  },
11
11
  {
12
12
  type: 'refactor',
13
- release: 'patch'
13
+ release: 'patch',
14
14
  },
15
15
  {
16
16
  type: 'build',
17
17
  scope: 'deps',
18
- release: 'patch'
19
- }
20
- ]
21
- }
18
+ release: 'patch',
19
+ },
20
+ ],
21
+ },
22
22
  ],
23
23
  [
24
24
  '@semantic-release/release-notes-generator',
@@ -27,40 +27,40 @@ module.exports = {
27
27
  types: [
28
28
  {
29
29
  type: 'feat',
30
- section: 'Features'
30
+ section: 'Features',
31
31
  },
32
32
  {
33
33
  type: 'fix',
34
- section: 'Bug Fixes'
34
+ section: 'Bug Fixes',
35
35
  },
36
36
  {
37
37
  type: 'perf',
38
- section: 'Performance Improvements'
38
+ section: 'Performance Improvements',
39
39
  },
40
40
  {
41
41
  type: 'revert',
42
- section: 'Reverts'
42
+ section: 'Reverts',
43
43
  },
44
44
  {
45
45
  type: 'refactor',
46
- section: 'Code Refactoring'
46
+ section: 'Code Refactoring',
47
47
  },
48
48
  {
49
49
  type: 'build',
50
50
  scope: 'deps',
51
- section: 'Dependencies'
52
- }
53
- ]
54
- }
55
- }
51
+ section: 'Dependencies',
52
+ },
53
+ ],
54
+ },
55
+ },
56
56
  ],
57
57
  '@semantic-release/npm',
58
58
  [
59
59
  '@semantic-release/github',
60
60
  {
61
- addReleases: 'bottom'
62
- }
63
- ]
61
+ addReleases: 'bottom',
62
+ },
63
+ ],
64
64
  ],
65
- preset: 'conventionalcommits'
65
+ preset: 'conventionalcommits',
66
66
  };
@@ -4,71 +4,81 @@ const proxyquire = require('proxyquire');
4
4
 
5
5
  const semanticReleasePayload = {
6
6
  nextRelease: {
7
- version: '1.0.0'
7
+ version: '1.0.0',
8
8
  },
9
9
  logger: {
10
- log: sinon.fake()
10
+ log: sinon.fake(),
11
11
  },
12
- cwd: process.cwd()
12
+ cwd: process.cwd(),
13
13
  };
14
14
 
15
15
  const pluginConfig = {
16
- packageVsix: 'test.vsix'
16
+ packageVsix: 'test.vsix',
17
17
  };
18
18
 
19
- test.beforeEach(t => {
19
+ test.beforeEach((t) => {
20
20
  t.context.stubs = {
21
21
  verifyVsceStub: sinon.stub().resolves(),
22
22
  vscePublishStub: sinon.stub().resolves(),
23
- vscePrepareStub: sinon.stub().resolves()
23
+ vscePrepareStub: sinon.stub().resolves(),
24
24
  };
25
25
  });
26
26
 
27
- test.afterEach(t => {
28
- Object.keys(t.context.stubs).forEach(key => {
27
+ test.afterEach((t) => {
28
+ Object.keys(t.context.stubs).forEach((key) => {
29
29
  t.context.stubs[key].resetHistory();
30
30
  });
31
31
  });
32
32
 
33
- test('verifyConditions', async t => {
33
+ test('verifyConditions', async (t) => {
34
34
  const { verifyVsceStub, vscePrepareStub, vscePublishStub } = t.context.stubs;
35
35
  const { verifyConditions } = proxyquire('../index.js', {
36
36
  './lib/verify': verifyVsceStub,
37
37
  './lib/publish': vscePublishStub,
38
- './lib/prepare': vscePrepareStub
38
+ './lib/prepare': vscePrepareStub,
39
39
  });
40
40
 
41
41
  await verifyConditions(pluginConfig, semanticReleasePayload);
42
42
 
43
- t.true(verifyVsceStub.calledOnceWith(pluginConfig, { logger: semanticReleasePayload.logger, cwd: semanticReleasePayload.cwd }));
43
+ t.true(
44
+ verifyVsceStub.calledOnceWith(pluginConfig, {
45
+ logger: semanticReleasePayload.logger,
46
+ cwd: semanticReleasePayload.cwd,
47
+ })
48
+ );
44
49
  });
45
50
 
46
- test('prepare and unverified', async t => {
51
+ test('prepare and unverified', async (t) => {
47
52
  const { verifyVsceStub, vscePrepareStub, vscePublishStub } = t.context.stubs;
48
53
  const { prepare } = proxyquire('../index.js', {
49
54
  './lib/verify': verifyVsceStub,
50
55
  './lib/publish': vscePublishStub,
51
56
  './lib/prepare': vscePrepareStub,
52
- verified: false
57
+ verified: false,
53
58
  });
54
59
 
55
60
  await prepare(pluginConfig, semanticReleasePayload);
56
61
 
57
- t.true(verifyVsceStub.calledOnceWith(pluginConfig, { logger: semanticReleasePayload.logger, cwd: semanticReleasePayload.cwd }));
62
+ t.true(
63
+ verifyVsceStub.calledOnceWith(pluginConfig, {
64
+ logger: semanticReleasePayload.logger,
65
+ cwd: semanticReleasePayload.cwd,
66
+ })
67
+ );
58
68
  t.deepEqual(vscePrepareStub.getCall(0).args, [
59
69
  semanticReleasePayload.nextRelease.version,
60
70
  pluginConfig.packageVsix,
61
71
  semanticReleasePayload.logger,
62
- semanticReleasePayload.cwd
72
+ semanticReleasePayload.cwd,
63
73
  ]);
64
74
  });
65
75
 
66
- test('prepare and verified', async t => {
76
+ test('prepare and verified', async (t) => {
67
77
  const { verifyVsceStub, vscePrepareStub, vscePublishStub } = t.context.stubs;
68
78
  const { prepare, verifyConditions } = proxyquire('../index.js', {
69
79
  './lib/verify': verifyVsceStub,
70
80
  './lib/publish': vscePublishStub,
71
- './lib/prepare': vscePrepareStub
81
+ './lib/prepare': vscePrepareStub,
72
82
  });
73
83
 
74
84
  await verifyConditions(pluginConfig, semanticReleasePayload);
@@ -79,16 +89,16 @@ test('prepare and verified', async t => {
79
89
  semanticReleasePayload.nextRelease.version,
80
90
  pluginConfig.packageVsix,
81
91
  semanticReleasePayload.logger,
82
- semanticReleasePayload.cwd
92
+ semanticReleasePayload.cwd,
83
93
  ]);
84
94
  });
85
95
 
86
- test('publish that is unverified and unprepared', async t => {
96
+ test('publish that is unverified and unprepared', async (t) => {
87
97
  const { verifyVsceStub, vscePrepareStub, vscePublishStub } = t.context.stubs;
88
98
  const { publish } = proxyquire('../index.js', {
89
99
  './lib/verify': verifyVsceStub,
90
100
  './lib/publish': vscePublishStub,
91
- './lib/prepare': vscePrepareStub
101
+ './lib/prepare': vscePrepareStub,
92
102
  });
93
103
 
94
104
  await publish(pluginConfig, semanticReleasePayload);
@@ -98,16 +108,17 @@ test('publish that is unverified and unprepared', async t => {
98
108
  t.deepEqual(vscePublishStub.getCall(0).args, [
99
109
  semanticReleasePayload.nextRelease.version,
100
110
  undefined,
101
- semanticReleasePayload.logger
111
+ semanticReleasePayload.logger,
112
+ semanticReleasePayload.cwd,
102
113
  ]);
103
114
  });
104
115
 
105
- test('publish that is verified but unprepared', async t => {
116
+ test('publish that is verified but unprepared', async (t) => {
106
117
  const { verifyVsceStub, vscePrepareStub, vscePublishStub } = t.context.stubs;
107
118
  const { publish, verifyConditions } = proxyquire('../index.js', {
108
119
  './lib/verify': verifyVsceStub,
109
120
  './lib/publish': vscePublishStub,
110
- './lib/prepare': vscePrepareStub
121
+ './lib/prepare': vscePrepareStub,
111
122
  });
112
123
 
113
124
  await verifyConditions(pluginConfig, semanticReleasePayload);
@@ -118,16 +129,17 @@ test('publish that is verified but unprepared', async t => {
118
129
  t.deepEqual(vscePublishStub.getCall(0).args, [
119
130
  semanticReleasePayload.nextRelease.version,
120
131
  undefined,
121
- semanticReleasePayload.logger
132
+ semanticReleasePayload.logger,
133
+ semanticReleasePayload.cwd,
122
134
  ]);
123
135
  });
124
136
 
125
- test('publish that is already verified & prepared', async t => {
137
+ test('publish that is already verified & prepared', async (t) => {
126
138
  const { verifyVsceStub, vscePrepareStub, vscePublishStub } = t.context.stubs;
127
139
  const { prepare, publish, verifyConditions } = proxyquire('../index.js', {
128
140
  './lib/verify': verifyVsceStub,
129
141
  './lib/publish': vscePublishStub,
130
- './lib/prepare': vscePrepareStub
142
+ './lib/prepare': vscePrepareStub,
131
143
  });
132
144
 
133
145
  await verifyConditions(pluginConfig, semanticReleasePayload);
@@ -139,21 +151,53 @@ test('publish that is already verified & prepared', async t => {
139
151
  t.deepEqual(vscePublishStub.getCall(0).args, [
140
152
  semanticReleasePayload.nextRelease.version,
141
153
  packagePath,
142
- semanticReleasePayload.logger
154
+ semanticReleasePayload.logger,
155
+ semanticReleasePayload.cwd,
143
156
  ]);
144
157
  });
145
158
 
146
- test('it does not publish the package if publishing is disabled', async t => {
159
+ test('it does not publish the package if publishing is disabled', async (t) => {
147
160
  const { verifyVsceStub, vscePrepareStub, vscePublishStub } = t.context.stubs;
148
161
  const { prepare, publish, verifyConditions } = proxyquire('../index.js', {
149
162
  './lib/verify': verifyVsceStub,
150
163
  './lib/publish': vscePublishStub,
151
- './lib/prepare': vscePrepareStub
164
+ './lib/prepare': vscePrepareStub,
152
165
  });
153
166
 
154
- await verifyConditions({ ...pluginConfig, publish: false }, semanticReleasePayload);
167
+ await verifyConditions(
168
+ { ...pluginConfig, publish: false },
169
+ semanticReleasePayload
170
+ );
155
171
  await prepare({ ...pluginConfig, publish: false }, semanticReleasePayload);
156
172
  await publish({ ...pluginConfig, publish: false }, semanticReleasePayload);
157
173
 
158
174
  t.true(vscePublishStub.notCalled);
159
175
  });
176
+
177
+ test('expand globs if publishPackagePath is set', async (t) => {
178
+ const { verifyVsceStub, vscePrepareStub, vscePublishStub } = t.context.stubs;
179
+ const { publish } = proxyquire('../index.js', {
180
+ './lib/verify': verifyVsceStub,
181
+ './lib/publish': vscePublishStub,
182
+ './lib/prepare': vscePrepareStub,
183
+ glob: {
184
+ sync: sinon.stub().returns(['package1.vsix', 'package2.vsix']),
185
+ },
186
+ });
187
+
188
+ const pluginConfig = {
189
+ publishPackagePath: 'package*.vsix',
190
+ packageVsix: false,
191
+ };
192
+
193
+ await publish(pluginConfig, semanticReleasePayload);
194
+
195
+ t.true(verifyVsceStub.calledOnce);
196
+ t.true(vscePrepareStub.calledOnce);
197
+ t.deepEqual(vscePublishStub.getCall(0).args, [
198
+ semanticReleasePayload.nextRelease.version,
199
+ ['package1.vsix', 'package2.vsix'],
200
+ semanticReleasePayload.logger,
201
+ semanticReleasePayload.cwd,
202
+ ]);
203
+ });
@@ -1,26 +1,39 @@
1
+ // Run tests serially to avoid env pollution
2
+ const test = require('ava').serial;
1
3
  const sinon = require('sinon');
2
- const test = require('ava');
3
4
  const proxyquire = require('proxyquire');
4
5
 
5
6
  const logger = {
6
- log: sinon.fake()
7
+ log: sinon.fake(),
7
8
  };
8
9
  const cwd = process.cwd();
9
10
 
10
- test.beforeEach(t => {
11
+ test.beforeEach((t) => {
11
12
  t.context.stubs = {
12
- execaStub: sinon.stub()
13
+ execaStub: sinon.stub(),
13
14
  };
14
15
  });
15
16
 
16
- test.afterEach(t => {
17
+ test.afterEach((t) => {
17
18
  t.context.stubs.execaStub.resetHistory();
18
19
  });
19
20
 
20
- test('packageVsix is not specified', async t => {
21
+ test('packageVsix is disabled', async (t) => {
21
22
  const { execaStub } = t.context.stubs;
22
23
  const prepare = proxyquire('../lib/prepare', {
23
- execa: execaStub
24
+ execa: execaStub,
25
+ });
26
+
27
+ const version = '1.0.0';
28
+ await prepare(version, false, logger);
29
+
30
+ t.true(execaStub.notCalled);
31
+ });
32
+
33
+ test('packageVsix is not specified', async (t) => {
34
+ const { execaStub } = t.context.stubs;
35
+ const prepare = proxyquire('../lib/prepare', {
36
+ execa: execaStub,
24
37
  });
25
38
 
26
39
  const version = '1.0.0';
@@ -29,10 +42,10 @@ test('packageVsix is not specified', async t => {
29
42
  t.true(execaStub.notCalled);
30
43
  });
31
44
 
32
- test('packageVsix is a string', async t => {
45
+ test('packageVsix is a string', async (t) => {
33
46
  const { execaStub } = t.context.stubs;
34
47
  const prepare = proxyquire('../lib/prepare', {
35
- execa: execaStub
48
+ execa: execaStub,
36
49
  });
37
50
 
38
51
  const version = '1.0.0';
@@ -41,10 +54,14 @@ test('packageVsix is a string', async t => {
41
54
  const result = await prepare(version, packageVsix, logger, cwd);
42
55
 
43
56
  t.deepEqual(result, packagePath);
44
- t.deepEqual(execaStub.getCall(0).args, ['vsce', ['package', version, '--no-git-tag-version', '--out', packagePath], { stdio: 'inherit', preferLocal: true, cwd }]);
57
+ t.deepEqual(execaStub.getCall(0).args, [
58
+ 'vsce',
59
+ ['package', version, '--no-git-tag-version', '--out', packagePath],
60
+ { stdio: 'inherit', preferLocal: true, cwd },
61
+ ]);
45
62
  });
46
63
 
47
- test('packageVsix is true', async t => {
64
+ test('packageVsix is true', async (t) => {
48
65
  const { execaStub } = t.context.stubs;
49
66
  const name = 'test';
50
67
 
@@ -52,9 +69,9 @@ test('packageVsix is true', async t => {
52
69
  execa: execaStub,
53
70
  'fs-extra': {
54
71
  readJson: sinon.stub().returns({
55
- name
56
- })
57
- }
72
+ name,
73
+ }),
74
+ },
58
75
  });
59
76
 
60
77
  const version = '1.0.0';
@@ -64,10 +81,14 @@ test('packageVsix is true', async t => {
64
81
  const result = await prepare(version, packageVsix, logger, cwd);
65
82
 
66
83
  t.deepEqual(result, packagePath);
67
- t.deepEqual(execaStub.getCall(0).args, ['vsce', ['package', version, '--no-git-tag-version', '--out', packagePath], { stdio: 'inherit', preferLocal: true, cwd }]);
84
+ t.deepEqual(execaStub.getCall(0).args, [
85
+ 'vsce',
86
+ ['package', version, '--no-git-tag-version', '--out', packagePath],
87
+ { stdio: 'inherit', preferLocal: true, cwd },
88
+ ]);
68
89
  });
69
90
 
70
- test('packageVsix is not set but OVSX_PAT is', async t => {
91
+ test('packageVsix is not set but OVSX_PAT is', async (t) => {
71
92
  const { execaStub } = t.context.stubs;
72
93
  const name = 'test';
73
94
 
@@ -75,13 +96,13 @@ test('packageVsix is not set but OVSX_PAT is', async t => {
75
96
  execa: execaStub,
76
97
  'fs-extra': {
77
98
  readJson: sinon.stub().returns({
78
- name
79
- })
80
- }
99
+ name,
100
+ }),
101
+ },
81
102
  });
82
103
 
83
104
  sinon.stub(process, 'env').value({
84
- OVSX_PAT: 'abc123'
105
+ OVSX_PAT: 'abc123',
85
106
  });
86
107
 
87
108
  const version = '1.0.0';
@@ -91,5 +112,48 @@ test('packageVsix is not set but OVSX_PAT is', async t => {
91
112
  const result = await prepare(version, packageVsix, logger, cwd);
92
113
 
93
114
  t.deepEqual(result, packagePath);
94
- t.deepEqual(execaStub.getCall(0).args, ['vsce', ['package', version, '--no-git-tag-version', '--out', packagePath], { stdio: 'inherit', preferLocal: true, cwd }]);
115
+ t.deepEqual(execaStub.getCall(0).args, [
116
+ 'vsce',
117
+ ['package', version, '--no-git-tag-version', '--out', packagePath],
118
+ { stdio: 'inherit', preferLocal: true, cwd },
119
+ ]);
120
+ });
121
+
122
+ test('packageVsix when target is set', async (t) => {
123
+ const { execaStub } = t.context.stubs;
124
+ const name = 'test';
125
+
126
+ const prepare = proxyquire('../lib/prepare', {
127
+ execa: execaStub,
128
+ 'fs-extra': {
129
+ readJson: sinon.stub().returns({
130
+ name,
131
+ }),
132
+ },
133
+ });
134
+
135
+ const version = '1.0.0';
136
+ const target = 'linux-x64';
137
+ const packagePath = `${name}-${target}-${version}.vsix`;
138
+
139
+ sinon.stub(process, 'env').value({
140
+ VSCE_TARGET: target,
141
+ });
142
+
143
+ const result = await prepare(version, true, logger, cwd);
144
+
145
+ t.deepEqual(result, packagePath);
146
+ t.deepEqual(execaStub.getCall(0).args, [
147
+ 'vsce',
148
+ [
149
+ 'package',
150
+ version,
151
+ '--no-git-tag-version',
152
+ '--out',
153
+ packagePath,
154
+ '--target',
155
+ target,
156
+ ],
157
+ { stdio: 'inherit', preferLocal: true, cwd },
158
+ ]);
95
159
  });