Skip to content

Commit 719ec86

Browse files
author
Boris Yakubchik
committed
merge master
2 parents 4e861de + c6bea6b commit 719ec86

File tree

10 files changed

+201
-3228
lines changed

10 files changed

+201
-3228
lines changed

.circleci/config.yml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,6 @@ jobs:
3636
- run: yarn run coverage-lcov
3737
- run: yarn run codacy
3838

39-
build-node_6:
40-
<<: *common-build
41-
docker:
42-
- image: node:6
43-
44-
build-node_7:
45-
<<: *common-build
46-
docker:
47-
- image: node:7
48-
4939
build-node_8:
5040
<<: *common-build
5141
docker:
@@ -70,8 +60,6 @@ workflows:
7060
version: 2
7161
build:
7262
jobs:
73-
- build-node_6
74-
- build-node_7
7563
- build-node_8
7664
- build-node_9
7765
- build-node_10
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Describe the bug**
11+
A clear and concise description of what the bug is.
12+
13+
**To Reproduce**
14+
Steps to reproduce the behavior:
15+
1. Go to '...'
16+
2. Click on '....'
17+
3. Scroll down to '....'
18+
4. See error
19+
20+
**Expected behavior**
21+
A clear and concise description of what you expected to happen.
22+
23+
**Screenshots**
24+
If applicable, add screenshots to help explain your problem.
25+
26+
**Desktop (please complete the following information):**
27+
- OS: [e.g. Windows, Linux, Mac]
28+
- Version [e.g. 22]
29+
30+
**Additional context**
31+
Add any other context about the problem here.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Is your feature request related to a problem? Please describe.**
11+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12+
13+
**Describe the solution you'd like**
14+
A clear and concise description of what you want to happen.
15+
16+
**Describe alternatives you've considered**
17+
A clear and concise description of any alternative solutions or features you've considered.
18+
19+
**Additional context**
20+
Add any other context or screenshots about the feature request here.

CODE_OF_CONDUCT.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as
6+
contributors and maintainers pledge to making participation in our project and
7+
our community a harassment-free experience for everyone, regardless of age, body
8+
size, disability, ethnicity, sex characteristics, gender identity and expression,
9+
level of experience, education, socio-economic status, nationality, personal
10+
appearance, race, religion, or sexual identity and orientation.
11+
12+
## Our Standards
13+
14+
Examples of behavior that contributes to creating a positive environment
15+
include:
16+
17+
* Using welcoming and inclusive language
18+
* Being respectful of differing viewpoints and experiences
19+
* Gracefully accepting constructive criticism
20+
* Focusing on what is best for the community
21+
* Showing empathy towards other community members
22+
23+
Examples of unacceptable behavior by participants include:
24+
25+
* The use of sexualized language or imagery and unwelcome sexual attention or
26+
advances
27+
* Trolling, insulting/derogatory comments, and personal or political attacks
28+
* Public or private harassment
29+
* Publishing others' private information, such as a physical or electronic
30+
address, without explicit permission
31+
* Other conduct which could reasonably be considered inappropriate in a
32+
professional setting
33+
34+
## Our Responsibilities
35+
36+
Project maintainers are responsible for clarifying the standards of acceptable
37+
behavior and are expected to take appropriate and fair corrective action in
38+
response to any instances of unacceptable behavior.
39+
40+
Project maintainers have the right and responsibility to remove, edit, or
41+
reject comments, commits, code, wiki edits, issues, and other contributions
42+
that are not aligned to this Code of Conduct, or to ban temporarily or
43+
permanently any contributor for other behaviors that they deem inappropriate,
44+
threatening, offensive, or harmful.
45+
46+
## Scope
47+
48+
This Code of Conduct applies both within project spaces and in public spaces
49+
when an individual is representing the project or its community. Examples of
50+
representing a project or community include using an official project e-mail
51+
address, posting via an official social media account, or acting as an appointed
52+
representative at an online or offline event. Representation of a project may be
53+
further defined and clarified by project maintainers.
54+
55+
## Enforcement
56+
57+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
58+
reported by contacting the project team at rtfrodrigo [at] gmail [dot] com. All
59+
complaints will be reviewed and investigated and will result in a response that
60+
is deemed necessary and appropriate to the circumstances. The project team is
61+
obligated to maintain confidentiality with regard to the reporter of an incident.
62+
Further details of specific enforcement policies may be posted separately.
63+
64+
Project maintainers who do not follow or enforce the Code of Conduct in good
65+
faith may face temporary or permanent repercussions as determined by other
66+
members of the project's leadership.
67+
68+
## Attribution
69+
70+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71+
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72+
73+
[homepage]: https://www.contributor-covenant.org
74+
75+
For answers to common questions about this code of conduct, see
76+
https://www.contributor-covenant.org/faq

SECURITY.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Security Policy
2+
3+
## Supported Versions
4+
5+
| Version | Supported |
6+
| ------- | ------------------ |
7+
| 2.7.x | :white_check_mark: |
8+
| < 2.7 | :x: |
9+
10+
## Reporting a Vulnerability
11+
12+
We take all security bugs in `diff2html-cli` seriously.
13+
Thank you for the help improving the security of `diff2html-cli`.
14+
We appreciate your efforts and responsible disclosure and
15+
will make every effort to acknowledge your contributions.
16+
17+
Report security bugs by emailing the lead maintainer at `rtfrodrigo [at] gmail [dot] com`.
18+
19+
The lead maintainer will acknowledge your email within 48 hours, and will send a
20+
more detailed response within 48 hours indicating the next steps in handling
21+
your report. After the initial reply to your report, the security team will
22+
endeavor to keep you informed of the progress towards a fix and full
23+
announcement, and may ask for additional information or guidance.
24+
25+
Report security bugs in third-party modules to the person or team maintaining
26+
the module.
27+
28+
## Disclosure Policy
29+
30+
When the security team receives a security bug report, they will assign it to a
31+
primary handler. This person will coordinate the fix and release process,
32+
involving the following steps:
33+
34+
* Confirm the problem and determine the affected versions.
35+
* Audit code to find any potential similar problems.
36+
* Prepare fixes for all releases still under maintenance. These fixes will be
37+
released as fast as possible.
38+
39+
## Comments on this Policy
40+
41+
If you have suggestions on how this process could be improved please submit a
42+
pull request.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "diff2html-cli",
3-
"version": "2.7.0",
3+
"version": "3.0.4",
44
"homepage": "https://www.github.com/rtfpessoa/diff2html-cli",
55
"description": "Fast Diff to colorized HTML",
66
"keywords": [
@@ -32,7 +32,7 @@
3232
"url": "https://www.github.com/rtfpessoa/diff2html-cli/issues"
3333
},
3434
"engines": {
35-
"node": ">=6"
35+
"node": ">=8"
3636
},
3737
"preferGlobal": true,
3838
"scripts": {
@@ -54,10 +54,10 @@
5454
},
5555
"main": "./src/main.js",
5656
"dependencies": {
57-
"copy-paste": "^1.3.0",
57+
"clipboardy": "^2.1.0",
5858
"diff2html": "^2.7.0",
5959
"extend": "^3.0.2",
60-
"opn": "^5.4.0",
60+
"open": "^6.0.0",
6161
"request": "^2.88.0",
6262
"yargs": "^13.2.1"
6363
},

src/cli.ts

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@ const path = require('path');
1414

1515
const diff2Html = require('diff2html').Diff2Html;
1616

17-
const log = require('./logger.js').Logger;
18-
const http = require('./http-utils.js').HttpUtils;
19-
const utils = require('./utils.js').Utils;
17+
var open = require('open');
18+
var clipboardy = require('clipboardy');
2019

2120
const ncp = require('copy-paste');
2221
const opn = require('opn');
@@ -153,26 +152,21 @@ module.exports = {
153152
postToDiffy(diff: string, postType: PostType, callback) {
154153
var jsonParams = {udiff: diff};
155154

156-
http.post('http://diffy.org/api/new', jsonParams, (err, response) => {
155+
http.put('https://diffy.org/api/diff/', jsonParams, (err, response) => {
157156
if (err) {
158157
log.error(err);
159158
return;
160159
}
161160

162-
if (response.status !== 'error') {
163-
log.print('Link powered by diffy.org:');
164-
log.print(response.url);
165-
166-
if (postType === 'browser') {
167-
open(response.url);
168-
return callback(null, response.url);
169-
} else if (postType === 'pbcopy') {
170-
ncp.copy(response.url, () => {
171-
return callback(null, response.url);
172-
});
173-
}
174-
} else {
175-
log.error('Error: ' + response.statusCode);
161+
log.print('Link powered by https://diffy.org');
162+
log.print(url);
163+
164+
if (postType === 'browser') {
165+
open(url);
166+
return callback(null, url);
167+
} else if (postType === 'pbcopy') {
168+
clipboardy.writeSync(url);
169+
return callback(null, url);
176170
}
177171
});
178172
}

src/http-utils.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,25 @@
1111
function HttpUtils() {
1212
}
1313

14-
HttpUtils.prototype.post = function(url, payload, callback) {
14+
HttpUtils.prototype.put = function(url, payload, callback) {
1515
request({
1616
url: url,
17-
method: 'POST',
18-
form: payload
17+
method: 'PUT',
18+
headers: {},
19+
body: payload,
20+
json: true
1921
})
2022
.on('response', function(response) {
2123
response.on('data', function(body) {
2224
try {
23-
return callback(null, JSON.parse(body.toString('utf8')));
25+
var object = JSON.parse(body.toString('utf8'));
26+
if(object.id) {
27+
return callback(null, "https://diffy.org/diff/" + object.id);
28+
} else if (object.error) {
29+
return callback(new Error(object.error));
30+
}else {
31+
return callback(new Error(body.toString('utf8')));
32+
}
2433
} catch (err) {
2534
return callback(new Error('could not parse response'));
2635
}

test/cli-tests.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ describe('Cli', function() {
4242
});
4343

4444
describe('postToDiffy', function() {
45-
it('should call `http.post`', function() {
46-
var spy = sinon.stub(http, 'post');
45+
it('should call `http.put`', function() {
46+
var spy = sinon.stub(http, 'put');
4747
Cli.postToDiffy('a', 'b', 'callback');
4848
assert(spy.calledOnce);
49-
assert(spy.calledWith('http://diffy.org/api/new', { udiff: 'a' }));
49+
assert(spy.calledWith('https://diffy.org/api/diff/', { diff: 'a' }));
5050
});
5151
});
5252
});

0 commit comments

Comments
 (0)