release-it 15.0.0-esm.3 → 15.0.0-esm.4

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
@@ -321,17 +321,18 @@ While mostly used as a CLI tool, release-it can be used as a dependency to integ
321
321
  - [blockchain/blockchain-wallet-v4-frontend](https://github.com/blockchain/blockchain-wallet-v4-frontend)
322
322
  - [callstack/linaria](https://github.com/callstack/linaria)
323
323
  - [ember-cli/ember-cli](https://github.com/ember-cli/ember-cli)
324
+ - [metalsmith/metalsmith](https://github.com/metalsmith/metalsmith)
324
325
  - [react-native-paper](https://github.com/callstack/react-native-paper)
325
326
  - [js-cookie/js-cookie](https://github.com/js-cookie/js-cookie)
326
327
  - [mirumee/saleor](https://github.com/mirumee/saleor)
327
328
  - [mozilla/readability](https://github.com/mozilla/readability)
328
- - [satya164/react-native-tab-view](https://github.com/satya164/react-native-tab-view)
329
+ - [redis/node-redis](https://github.com/redis/node-redis)
329
330
  - [shipshapecode/shepherd](https://github.com/shipshapecode/shepherd)
330
331
  - [swagger-api/swagger-ui](https://github.com/swagger-api/swagger-ui) +
331
332
  [swagger-editor](https://github.com/swagger-api/swagger-editor)
332
333
  - [StevenBlack/hosts](https://github.com/StevenBlack/hosts)
333
- - [tabler](https://github.com/tabler/tabler) + [tabler-icons](https://github.com/tabler/tabler-icons)
334
- - [youzan/vant](https://github.com/youzan/vant/search?q=release-it)
334
+ - [tabler/tabler](https://github.com/tabler/tabler) + [tabler-icons](https://github.com/tabler/tabler-icons)
335
+ - [youzan/vant](https://github.com/youzan/vant)
335
336
  - [Repositories that depend on release-it](https://github.com/release-it/release-it/network/dependents)
336
337
  - GitHub search for [filename:.release-it.json](https://github.com/search?q=filename%3A.release-it.json)
337
338
 
@@ -33,6 +33,7 @@
33
33
  "release": false,
34
34
  "releaseName": "Release ${version}",
35
35
  "releaseNotes": null,
36
+ "autoGenerate": false,
36
37
  "preRelease": false,
37
38
  "draft": false,
38
39
  "tokenRef": "GITHUB_TOKEN",
@@ -38,7 +38,7 @@ class GitHub extends Release {
38
38
  async init() {
39
39
  await super.init();
40
40
 
41
- const { skipChecks, tokenRef, web, update } = this.options;
41
+ const { skipChecks, tokenRef, web, update, assets } = this.options;
42
42
 
43
43
  if (!this.token || web) {
44
44
  if (!web) {
@@ -49,6 +49,10 @@ class GitHub extends Release {
49
49
  return;
50
50
  }
51
51
 
52
+ if (web && assets) {
53
+ this.log.warn('Assets are not included in web-based releases.');
54
+ }
55
+
52
56
  if (!skipChecks) {
53
57
  // If we're running on GitHub Actions, we can skip the authentication and
54
58
  // collaborator checks. Ref: https://bit.ly/2vsyRzu
@@ -188,12 +192,12 @@ class GitHub extends Release {
188
192
 
189
193
  getOctokitReleaseOptions(options = {}) {
190
194
  const { owner, project: repo } = this.getContext('repo');
191
- const { releaseName, draft = false, preRelease = false } = this.options;
195
+ const { releaseName, draft = false, preRelease = false, autoGenerate = false } = this.options;
192
196
  const { tagName } = this.config.getContext();
193
197
  const { version, releaseNotes } = this.getContext();
194
198
  const { isPreRelease } = parseVersion(version);
195
199
  const name = format(releaseName, this.config.getContext());
196
- const body = releaseNotes;
200
+ const body = autoGenerate ? '' : releaseNotes || '';
197
201
 
198
202
  return Object.assign(options, {
199
203
  owner,
@@ -202,7 +206,8 @@ class GitHub extends Release {
202
206
  name,
203
207
  body,
204
208
  draft,
205
- prerelease: isPreRelease || preRelease
209
+ prerelease: isPreRelease || preRelease,
210
+ generate_release_notes: autoGenerate
206
211
  });
207
212
  }
208
213
 
@@ -106,7 +106,11 @@ class Version extends Plugin {
106
106
  }
107
107
 
108
108
  if (this.config.isCI && !increment) {
109
- return semver.inc(latestVersion, 'patch');
109
+ if (isPreRelease) {
110
+ return semver.inc(latestVersion, 'prepatch', preReleaseId);
111
+ } else {
112
+ return semver.inc(latestVersion, 'patch');
113
+ }
110
114
  }
111
115
 
112
116
  const normalizedType = RELEASE_TYPES.includes(increment) && isPreRelease ? `pre${increment}` : increment;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "release-it",
3
- "version": "15.0.0-esm.3",
3
+ "version": "15.0.0-esm.4",
4
4
  "description": "Generic CLI tool to automate versioning and package publishing related tasks.",
5
5
  "keywords": [
6
6
  "build",
@@ -83,7 +83,7 @@
83
83
  "os-name": "5.0.1",
84
84
  "parse-json": "5.2.0",
85
85
  "semver": "7.3.5",
86
- "shelljs": "0.8.4",
86
+ "shelljs": "0.8.5",
87
87
  "update-notifier": "5.1.0",
88
88
  "url-join": "4.0.1",
89
89
  "uuid": "8.3.2",
@@ -94,17 +94,17 @@
94
94
  "@octokit/request-error": "2.1.0",
95
95
  "ava": "3.15.0",
96
96
  "codecov": "3.8.3",
97
- "eslint": "8.3.0",
97
+ "eslint": "8.7.0",
98
98
  "eslint-config-prettier": "8.3.0",
99
- "eslint-plugin-ava": "13.1.0",
100
- "eslint-plugin-import": "2.25.3",
99
+ "eslint-plugin-ava": "13.2.0",
100
+ "eslint-plugin-import": "2.25.4",
101
101
  "eslint-plugin-prettier": "4.0.0",
102
102
  "markdown-toc": "1.2.0",
103
103
  "mock-fs": "5.1.2",
104
104
  "mock-stdio": "1.0.3",
105
- "nock": "13.2.1",
105
+ "nock": "13.2.2",
106
106
  "nyc": "15.1.0",
107
- "prettier": "2.5.0",
107
+ "prettier": "2.5.1",
108
108
  "sinon": "12.0.1",
109
109
  "strip-ansi": "7.0.1"
110
110
  },
package/test/github.js CHANGED
@@ -15,7 +15,7 @@ import {
15
15
  const tokenRef = 'GITHUB_TOKEN';
16
16
  const pushRepo = 'git://github.com:user/repo';
17
17
  const host = 'github.com';
18
- const git = { changelog: null };
18
+ const git = { changelog: '' };
19
19
  const requestErrorOptions = { request: { url: '', headers: {} }, response: { headers: {} } };
20
20
 
21
21
  test.serial('should check token and perform checks', async t => {
@@ -91,7 +91,36 @@ test('should create a pre-release and draft release notes', async t => {
91
91
 
92
92
  interceptAuthentication();
93
93
  interceptCollaborator();
94
- interceptCreate({ body: { tag_name: '2.0.2', name: 'Release 2.0.2', body: null, prerelease: true, draft: true } });
94
+ interceptCreate({ body: { tag_name: '2.0.2', name: 'Release 2.0.2', body: '', prerelease: true, draft: true } });
95
+
96
+ await runTasks(github);
97
+
98
+ const { isReleased, releaseUrl } = github.getContext();
99
+ t.true(isReleased);
100
+ t.is(releaseUrl, 'https://github.com/user/repo/releases/tag/2.0.2');
101
+ exec.restore();
102
+ });
103
+
104
+ test('should create auto generated release notes', async t => {
105
+ const options = {
106
+ git,
107
+ github: {
108
+ pushRepo,
109
+ tokenRef,
110
+ release: true,
111
+ releaseName: 'Release ${tagName}',
112
+ autoGenerate: true
113
+ }
114
+ };
115
+ const github = factory(GitHub, { options });
116
+ const exec = sinon.stub(github.shell, 'exec').callThrough();
117
+ exec.withArgs('git describe --tags --match=* --abbrev=0').resolves('2.0.1');
118
+
119
+ interceptAuthentication();
120
+ interceptCollaborator();
121
+ interceptCreate({
122
+ body: { tag_name: '2.0.2', name: 'Release 2.0.2', draft: false, prerelease: false, generate_release_notes: true }
123
+ });
95
124
 
96
125
  await runTasks(github);
97
126
 
@@ -220,7 +249,7 @@ test('should release to alternative host and proxy', async t => {
220
249
  test('should release to git.pushRepo', async t => {
221
250
  const remote = { api: 'https://my-custom-host.org/api/v3', host: 'my-custom-host.org' };
222
251
  interceptCreate(Object.assign({ body: { tag_name: '1.0.1' } }, remote));
223
- const options = { git: { pushRepo: 'upstream', changelog: null }, github: { tokenRef, skipChecks: true } };
252
+ const options = { git: { pushRepo: 'upstream', changelog: '' }, github: { tokenRef, skipChecks: true } };
224
253
  const github = factory(GitHub, { options });
225
254
  const exec = sinon.stub(github.shell, 'exec').callThrough();
226
255
  exec.withArgs('git log --pretty=format:"* %s (%h)" ${from}...${to}').resolves('');
@@ -371,6 +400,7 @@ test('should generate GitHub web release url', async t => {
371
400
 
372
401
  test('should generate GitHub web release url for enterprise host', async t => {
373
402
  const options = {
403
+ git,
374
404
  github: {
375
405
  pushRepo: 'git://my-custom-host.org:user/repo',
376
406
  release: true,
@@ -1,16 +1,19 @@
1
1
  import nock from 'nock';
2
2
 
3
- const interceptAuthentication = ({ api = 'https://api.github.com', username = 'john' } = {}) =>
3
+ const interceptAuthentication = ({ api = 'https://api.github.com', username = 'john' } = {}) => {
4
4
  nock(api).get('/user').reply(200, {
5
5
  login: username
6
6
  });
7
+ };
7
8
 
8
9
  const interceptCollaborator = ({
9
10
  api = 'https://api.github.com',
10
11
  owner = 'user',
11
12
  project = 'repo',
12
13
  username = 'john'
13
- } = {}) => nock(api).get(`/repos/${owner}/${project}/collaborators/${username}`).reply(204);
14
+ } = {}) => {
15
+ nock(api).get(`/repos/${owner}/${project}/collaborators/${username}`).reply(204);
16
+ };
14
17
 
15
18
  const interceptListReleases = ({
16
19
  host = 'github.com',
@@ -18,7 +21,7 @@ const interceptListReleases = ({
18
21
  owner = 'user',
19
22
  project = 'repo',
20
23
  tag_name
21
- } = {}) =>
24
+ } = {}) => {
22
25
  nock(api)
23
26
  .get(`/repos/${owner}/${project}/releases?per_page=1&page=1`)
24
27
  .reply(200, [
@@ -34,16 +37,24 @@ const interceptListReleases = ({
34
37
  prerelease: false
35
38
  }
36
39
  ]);
40
+ };
37
41
 
38
42
  const interceptCreate = ({
39
43
  api = 'https://api.github.com',
40
44
  host = 'github.com',
41
45
  owner = 'user',
42
46
  project = 'repo',
43
- body: { tag_name, name = '', body = null, prerelease = false, draft = false }
44
- } = {}) =>
47
+ body: { tag_name, name = '', body = '', prerelease = false, draft = false, generate_release_notes = false }
48
+ } = {}) => {
45
49
  nock(api)
46
- .post(`/repos/${owner}/${project}/releases`, { tag_name, name, body, prerelease, draft })
50
+ .post(`/repos/${owner}/${project}/releases`, {
51
+ tag_name,
52
+ name,
53
+ body,
54
+ prerelease,
55
+ draft,
56
+ generate_release_notes
57
+ })
47
58
  .reply(() => {
48
59
  const id = 1;
49
60
  const responseBody = {
@@ -53,21 +64,23 @@ const interceptCreate = ({
53
64
  body,
54
65
  prerelease,
55
66
  draft,
67
+ generate_release_notes,
56
68
  upload_url: `https://uploads.${host}/repos/${owner}/${project}/releases/${id}/assets{?name,label}`,
57
69
  html_url: `https://${host}/${owner}/${project}/releases/tag/${tag_name}`
58
70
  };
59
71
  return [200, responseBody, { location: `${api}/repos/${owner}/${project}/releases/${id}` }];
60
72
  });
73
+ };
61
74
 
62
75
  const interceptUpdate = ({
63
76
  host = 'github.com',
64
77
  api = 'https://api.github.com',
65
78
  owner = 'user',
66
79
  project = 'repo',
67
- body: { tag_name, name = '', body = null, prerelease = false, draft = false }
68
- } = {}) =>
80
+ body: { tag_name, name = '', body = '', prerelease = false, draft = false, generate_release_notes = false }
81
+ } = {}) => {
69
82
  nock(api)
70
- .patch(`/repos/${owner}/${project}/releases/1`, { tag_name, name, body, draft, prerelease })
83
+ .patch(`/repos/${owner}/${project}/releases/1`, { tag_name, name, body, draft, prerelease, generate_release_notes })
71
84
  .reply(200, {
72
85
  id: 1,
73
86
  tag_name,
@@ -75,9 +88,11 @@ const interceptUpdate = ({
75
88
  body,
76
89
  prerelease,
77
90
  draft,
91
+ generate_release_notes,
78
92
  upload_url: `https://uploads.${host}/repos/${owner}/${project}/releases/1/assets{?name,label}`,
79
93
  html_url: `https://${host}/${owner}/${project}/releases/tag/${tag_name}`
80
94
  });
95
+ };
81
96
 
82
97
  const interceptAsset = ({
83
98
  api = 'https://api.github.com',
@@ -86,7 +101,7 @@ const interceptAsset = ({
86
101
  project = 'repo',
87
102
  tagName,
88
103
  body = {}
89
- } = {}) =>
104
+ } = {}) => {
90
105
  nock(`https://uploads.${host}`)
91
106
  .post(`/repos/${owner}/${project}/releases/1/assets`, body)
92
107
  .query(true)
@@ -103,6 +118,7 @@ const interceptAsset = ({
103
118
  browser_download_url: `https://${host}/${owner}/${project}/releases/download/${tagName}/${name}`
104
119
  };
105
120
  });
121
+ };
106
122
 
107
123
  export {
108
124
  interceptAuthentication,
@@ -30,23 +30,14 @@ export let factory = (Definition, { namespace, options = {}, container = {} } =
30
30
  });
31
31
  };
32
32
 
33
- const getIncrement = (plugin, { latestVersion }) => {
34
- return (
35
- plugin.getIncrement({
36
- latestVersion,
37
- increment: plugin.options.increment,
38
- isPreRelease: false,
39
- preReleaseId: null
40
- }) ||
41
- plugin.getContext('increment') ||
42
- plugin.config.getContext('increment')
43
- );
44
- };
33
+ const getIncrement = plugin =>
34
+ plugin.getIncrement(plugin.options) || plugin.getContext('increment') || plugin.config.getContext('increment');
45
35
 
46
- const getVersion = async (plugin, { latestVersion, increment }) => {
36
+ const getVersion = async (plugin, options) => {
37
+ const { latestVersion, increment } = options;
47
38
  return (
48
- (await plugin.getIncrementedVersionCI({ latestVersion, increment })) ||
49
- (await plugin.getIncrementedVersion({ latestVersion, increment })) ||
39
+ (await plugin.getIncrementedVersionCI(options)) ||
40
+ (await plugin.getIncrementedVersion(options)) ||
50
41
  (increment !== false ? semver.inc(latestVersion, increment || 'patch') : latestVersion)
51
42
  );
52
43
  };
@@ -56,12 +47,15 @@ export let runTasks = async plugin => {
56
47
 
57
48
  const name = (await plugin.getName()) || '__test__';
58
49
  const latestVersion = (await plugin.getLatestVersion()) || '1.0.0';
59
- const changelog = (await plugin.getChangelog()) || null;
60
- const increment = getIncrement(plugin, { latestVersion });
50
+ const changelog = (await plugin.getChangelog(latestVersion)) || null;
51
+ const increment = getIncrement(plugin);
61
52
 
62
53
  plugin.config.setContext({ name, latestVersion, latestTag: latestVersion, changelog });
63
54
 
64
- const version = await getVersion(plugin, { latestVersion, increment });
55
+ const { preRelease } = plugin.config.options;
56
+ const isPreRelease = Boolean(preRelease);
57
+ const preReleaseId = typeof preRelease === 'string' ? preRelease : null;
58
+ const version = await getVersion(plugin, { latestVersion, increment, isPreRelease, preReleaseId });
65
59
 
66
60
  plugin.config.setContext(parseVersion(version));
67
61
 
package/test/version.js CHANGED
@@ -148,17 +148,22 @@ test('should run tasks without errors', async t => {
148
148
  await runTasks(v);
149
149
 
150
150
  t.is(getIncrement.callCount, 1);
151
- t.deepEqual(getIncrement.firstCall.args[0], {
151
+ t.deepEqual(getIncrement.firstCall.args[0], { increment: 'minor' });
152
+ t.is(getIncrementedVersionCI.callCount, 1);
153
+ t.deepEqual(getIncrementedVersionCI.firstCall.args[0], {
152
154
  latestVersion: '1.0.0',
153
155
  increment: 'minor',
154
156
  isPreRelease: false,
155
157
  preReleaseId: null
156
158
  });
157
- t.is(getIncrementedVersionCI.callCount, 1);
158
- t.deepEqual(getIncrementedVersionCI.firstCall.args[0], { latestVersion: '1.0.0', increment: 'minor' });
159
159
  t.is(await incrementVersion.firstCall.returnValue, '1.1.0');
160
160
  t.is(incrementVersion.callCount, 1);
161
- t.deepEqual(incrementVersion.firstCall.args[0], { latestVersion: '1.0.0', increment: 'minor' });
161
+ t.deepEqual(incrementVersion.firstCall.args[0], {
162
+ latestVersion: '1.0.0',
163
+ increment: 'minor',
164
+ isPreRelease: false,
165
+ preReleaseId: null
166
+ });
162
167
  t.is(incrementVersion.firstCall.returnValue, '1.1.0');
163
168
  const { latestVersion, version, isPreRelease, preReleaseId } = v.config.getContext();
164
169
  t.is(latestVersion, '1.0.0');