Skip to content

Commit 236dd50

Browse files
authored
feat: bump version to 2.0 (#22)
* chore: bump to v2 * docs: update README.md * chore: add @babel/core * chore: add @babel/register * chore: rename babel-register to @babel/register * chore: rename 'file' parameter to 'data' (#16)
1 parent 7214ccb commit 236dd50

9 files changed

Lines changed: 80 additions & 62 deletions

File tree

.babelrc

Lines changed: 0 additions & 6 deletions
This file was deleted.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ node_modules
22
npm-debug.log
33
/lib
44
package-lock.json
5+
yarn.lock

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
npm-debug.log
22
/src
3+
/test

.travis.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
1-
sudo: required
2-
dist: trusty
3-
group: edge
4-
51
language: node_js
62

73
os:
84
- linux
95

106
node_js:
11-
- '6'
12-
- '8'
137
- '10'
8+
- '12'
149

1510
before_install:
1611
- npm install -g npm

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2017-2019 Cheton Wu
3+
Copyright (c) 2017-2020 Cheton Wu
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,19 @@ Run `github-release` with `-h` or `--help` options:
1818
Usage: github-release <command> [<args>]
1919
2020
Options:
21-
-V, --version output the version number
22-
--baseurl <baseurl> API endpoint (default: "https://api.github.com")
23-
-T, --token <token> OAuth2 token (default: null)
24-
-o, --owner <owner> The repository owner. (default: "")
25-
-r, --repo <repo> The repository name. (default: "")
26-
-t, --tag <tag> The name of the tag.
27-
--release-id <id> The release id.
28-
-c, --commitish <value> Specifies the commitish value for tag. Unused if the tag already exists.
29-
-n, --name <name> The name of the release. (default: "")
30-
-b, --body <body> Text describing the contents of the tag.
31-
-d, --draft [value] `true` makes the release a draft, and `false` publishes the release.
32-
-p, --prerelease [value] `true` to identify the release as a prerelease, `false` to identify the release as a full release.
33-
-h, --help output usage information
21+
-V, --version output the version number
22+
--baseurl <baseurl> API endpoint (default: "https://api.github.com")
23+
--token <token> OAuth2 token (default: null)
24+
--owner <owner> The repository owner. (default: "")
25+
--repo <repo> The repository name. (default: "")
26+
--tag <tag> The name of the tag.
27+
--commitish <value> Specifies the commitish value for tag. Unused if the tag already exists.
28+
--release-id <id> The release id.
29+
--release-name <name> The name of the release. (default: "")
30+
--body <body> Text describing the contents of the tag.
31+
--draft [value] `true` makes the release a draft, and `false` publishes the release.
32+
--prerelease [value] `true` to identify the release as a prerelease, `false` to identify the release as a full release.
33+
-h, --help display help for command
3434
```
3535

3636
## Commands
@@ -50,7 +50,7 @@ github-release upload \
5050
--owner cheton \
5151
--repo github-release-cli \
5252
--tag "v0.1.0" \
53-
--name "v0.1.0" \
53+
--release-name "v0.1.0" \
5454
--body "This release contains bug fixes and imporvements, including:\n..." \
5555
archive.zip index.html app.min.css app.min.js
5656
```
@@ -63,7 +63,7 @@ github-release upload \
6363
--repo github-release-cli \
6464
--commitish 6a8e375 \
6565
--tag "v0.1.0" \
66-
--name "v0.1.0" \
66+
--release-name "v0.1.0" \
6767
--body "The commitish value for tag"
6868
```
6969

@@ -74,7 +74,7 @@ github-release upload \
7474
--owner cheton \
7575
--repo github-release-cli \
7676
--tag "v0.1.0" \
77-
--name "v0.1.0" \
77+
--release-name "v0.1.0" \
7878
--body "This is a prerelease" \
7979
--prerelease
8080
```
@@ -86,7 +86,7 @@ github-release upload \
8686
--owner cheton \
8787
--repo github-release-cli \
8888
--tag "v0.1.0" \
89-
--name "v0.1.0" \
89+
--release-name "v0.1.0" \
9090
--body "This is a published release" \
9191
--prerelease=false
9292
```
@@ -169,7 +169,7 @@ github-release upload \
169169
--owner=cheton \
170170
--repo=github-release-cli \
171171
--tag="latest" \
172-
--name="${TRAVIS_BRANCH}" \
172+
--release-name="${TRAVIS_BRANCH}" \
173173
--body="${COMMIT_LOG}" \
174174
"releases/myapp-0.1.0-win-x32.exe" \
175175
"releases/myapp-0.1.0-win-x64.exe"

babel.config.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module.exports = {
2+
extends: '@trendmicro/babel-config',
3+
presets: [
4+
[
5+
'@babel/preset-env',
6+
{
7+
useBuiltIns: 'entry',
8+
corejs: 3,
9+
}
10+
],
11+
],
12+
plugins: [
13+
'@babel/plugin-transform-runtime',
14+
],
15+
};

package.json

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "github-release-cli",
3-
"version": "1.3.1",
3+
"version": "2.0.0",
44
"description": "A command-line tool for managing release assets on a GitHub repository",
55
"homepage": "https://github.com/cheton/github-release-cli",
66
"author": "Cheton Wu <cheton@gmail.com>",
@@ -10,7 +10,7 @@
1010
"scripts": {
1111
"prepublish": "npm run build",
1212
"build": "babel --out-dir ./lib ./src",
13-
"test": "tap test/*.js --no-timeout --node-arg=--require --node-arg=babel-register --node-arg=--require --node-arg=babel-polyfill",
13+
"test": "tap test/*.js --node-arg=--require --node-arg=@babel/register",
1414
"test:list": "npm run build && node lib/index.js -a --owner cheton --repo github-release-cli list"
1515
},
1616
"files": [
@@ -29,21 +29,23 @@
2929
"cli"
3030
],
3131
"dependencies": {
32-
"@octokit/rest": "^16.23.2",
32+
"@octokit/rest": "^18.0.6",
3333
"babel-runtime": "^6.26.0",
34-
"chalk": "^2.4.2",
35-
"commander": "^2.20.0",
34+
"chalk": "^4.1.0",
35+
"commander": "^6.1.0",
3636
"http-link-header": "^1.0.2",
37-
"mime-types": "^2.1.22",
37+
"mime-types": "^2.1.27",
3838
"minimatch": "^3.0.4",
39-
"ora": "^3.4.0",
40-
"url-parse": "^1.4.4"
39+
"ora": "^5.1.0",
40+
"url-parse": "^1.4.7"
4141
},
4242
"devDependencies": {
43-
"babel-cli": "^6.26.0",
44-
"babel-plugin-transform-runtime": "^6.23.0",
45-
"babel-preset-env": "^1.7.0",
46-
"babel-preset-stage-0": "^6.24.1",
47-
"tap": "^12.6.1"
43+
"@babel/cli": "~7.11.6",
44+
"@babel/core": "~7.11.6",
45+
"@babel/plugin-transform-runtime": "~7.11.5",
46+
"@babel/preset-env": "~7.11.5",
47+
"@babel/register": "~7.11.5",
48+
"@trendmicro/babel-config": "~1.0.0-alpha",
49+
"tap": "^14.10.8"
4850
}
4951
}

src/index.js

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/* eslint max-len: 0 */
33
import fs from 'fs';
44
import path from 'path';
5-
import Octokit from '@octokit/rest';
5+
import { Octokit } from '@octokit/rest';
66
import chalk from 'chalk';
77
import program from 'commander';
88
import * as LinkHeader from 'http-link-header';
@@ -16,21 +16,21 @@ program
1616
.version(pkg.version)
1717
.usage('<command> [<args>]')
1818
.option('--baseurl <baseurl>', 'API endpoint', 'https://api.github.com')
19-
.option('-T, --token <token>', 'OAuth2 token', null)
20-
.option('-o, --owner <owner>', 'The repository owner.', '')
21-
.option('-r, --repo <repo>', 'The repository name.', '')
22-
.option('-t, --tag <tag>', 'The name of the tag.')
19+
.option('--token <token>', 'OAuth2 token', null)
20+
.option('--owner <owner>', 'The repository owner.', '')
21+
.option('--repo <repo>', 'The repository name.', '')
22+
.option('--tag <tag>', 'The name of the tag.')
23+
.option('--commitish <value>', 'Specifies the commitish value for tag. Unused if the tag already exists.')
2324
.option('--release-id <id>', 'The release id.')
24-
.option('-c, --commitish <value>', 'Specifies the commitish value for tag. Unused if the tag already exists.')
25-
.option('-n, --name <name>', 'The name of the release.', '') // Note: name is a reserved word and it has to specify a default value.
26-
.option('-b, --body <body>', 'Text describing the contents of the tag.')
27-
.option('-d, --draft [value]', '`true` makes the release a draft, and `false` publishes the release.', function(val) {
25+
.option('--release-name <name>', 'The name of the release.', '')
26+
.option('--body <body>', 'Text describing the contents of the tag.')
27+
.option('--draft [value]', '`true` makes the release a draft, and `false` publishes the release.', function(val) {
2828
if (String(val).toLowerCase() === 'false') {
2929
return false;
3030
}
3131
return true;
3232
})
33-
.option('-p, --prerelease [value]', '`true` to identify the release as a prerelease, `false` to identify the release as a full release.', function(val) {
33+
.option('--prerelease [value]', '`true` to identify the release as a prerelease, `false` to identify the release as a full release.', function(val) {
3434
if (String(val).toLowerCase() === 'false') {
3535
return false;
3636
}
@@ -97,7 +97,17 @@ const getReleaseByTag = async ({ owner, repo, tag }) => {
9797

9898
const fn = {
9999
'upload': async () => {
100-
const { owner, repo, tag, commitish, name, body, draft, prerelease, releaseId } = program;
100+
const {
101+
owner,
102+
repo,
103+
tag,
104+
commitish,
105+
releaseId,
106+
releaseName,
107+
body,
108+
draft,
109+
prerelease,
110+
} = program;
101111
const files = args;
102112
let release;
103113

@@ -116,26 +126,26 @@ const fn = {
116126

117127
try {
118128
if (!release) {
119-
console.log(`> createRelease: tag_name=${tag}, target_commitish=${commitish || ''}, name=${name || tag}, draft=${!!draft}, prerelease=${!!prerelease}`);
129+
console.log(`> createRelease: tag_name=${tag}, target_commitish=${commitish || ''}, name=${releaseName || tag}, draft=${!!draft}, prerelease=${!!prerelease}`);
120130
const res = await octokit.repos.createRelease({
121131
owner,
122132
repo,
123133
tag_name: tag,
124134
target_commitish: commitish,
125-
name: name || tag,
135+
name: releaseName || tag,
126136
body: body || '',
127137
draft: !!draft,
128138
prerelease: !!prerelease,
129139
});
130140
release = res.data;
131141
} else {
132-
console.log(`> updateRelease: release_id=${release.id}, tag_name=${tag}, name=${name || tag}`);
142+
console.log(`> updateRelease: release_id=${release.id}, tag_name=${tag}, name=${releaseName || tag}`);
133143
const res = await octokit.repos.updateRelease({
134144
owner,
135145
repo,
136146
release_id: release.id,
137147
tag_name: tag,
138-
name: name || tag,
148+
name: releaseName || tag,
139149
body: (body === undefined) ? release.body || '' : body || '',
140150
draft: (draft === undefined) ? !!release.draft : false,
141151
prerelease: (prerelease === undefined) ? !!release.prerelease : false,
@@ -150,7 +160,7 @@ const fn = {
150160
console.log(` #${i + 1}: name="${path.basename(file)}" filePath="${file}"`);
151161
await octokit.repos.uploadReleaseAsset({
152162
url: release.upload_url,
153-
file: fs.createReadStream(file),
163+
data: fs.createReadStream(file),
154164
headers: {
155165
'Content-Type': mime.lookup(file) || 'application/octet-stream',
156166
'Content-Length': fs.statSync(file).size,
@@ -195,12 +205,12 @@ const fn = {
195205

196206
try {
197207
const release_id = release.id;
198-
console.log(`> listAssetsForRelease: release_id=${release_id}`);
208+
console.log(`> listReleaseAssets: release_id=${release_id}`);
199209

200210
let assets = [];
201211
let page = 1;
202212
do {
203-
const res = await octokit.repos.listAssetsForRelease({ owner, repo, release_id, page });
213+
const res = await octokit.repos.listReleaseAssets({ owner, repo, release_id, page });
204214
assets = assets.concat(res.data);
205215
page = getNextPage(res);
206216
} while (page)

0 commit comments

Comments
 (0)