Skip to content

Commit 092f6ec

Browse files
feat(lerna): scoped packages with tests WIP
* added httpsnippet core, jquery, xhr, and curl packages which now run test independently and scope relevant package files.
1 parent 28bee13 commit 092f6ec

366 files changed

Lines changed: 495 additions & 639 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.travis.yml

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,10 @@
11
language: node_js
22

33
node_js:
4-
- iojs
5-
- 0.10
6-
- 0.12
4+
- node
5+
- lts/*
6+
- 8
77

88
before_install:
99
- sudo apt-get update -qq
1010
- sudo apt-get install -qq --yes python3 php5-curl php5-cli
11-
12-
after_script:
13-
- npm run codeclimate
14-
15-
notifications:
16-
webhooks:
17-
urls:
18-
- https://webhooks.gitter.im/e/95c4e911f2486588f98c
19-
on_success: always
20-
on_failure: always
21-
on_start: false

lerna.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"packages": [
3-
"packages/*"
3+
"packages/*/*"
44
],
5-
"version": "0.0.0"
5+
"version": "independent"
66
}

package.json

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,47 @@
11
{
22
"version": "1.16.7",
3-
"name": "httpsnippet",
43
"description": "HTTP Request snippet generator for *most* languages",
54
"author": "Kong Inc.",
65
"homepage": "https://github.com/kong/httpsnippet",
76
"license": "MIT",
87
"engines": {
9-
"node": ">=0.10"
8+
"node": ">=8"
109
},
11-
"files": [
12-
"bin",
13-
"src"
14-
],
15-
"repository": "Mashape/httpsnippet",
10+
"repository": "kong/httpsnippet",
1611
"bugs": {
17-
"url": "https://github.com/Mashape/httpsnippet/issues"
12+
"url": "https://github.com/kong/httpsnippet/issues"
1813
},
1914
"scripts": {
2015
"quick": "mocha --no-timeouts --fgrep 'Request Validation' --invert",
21-
"pretest": "standard && echint",
22-
"test": "mocha --no-timeouts",
23-
"posttest": "npm run coverage",
16+
"pretest": "standard \"packages/**/*.js\"",
17+
"test": "lerna run test",
18+
"posttest": "exit 0 && npm run coverage",
2419
"coverage": "istanbul cover --dir coverage _mocha -- --fgrep 'Request Validation' --invert -R dot",
2520
"codeclimate": "codeclimate < coverage/lcov.info"
2621
},
2722
"standard": {
2823
"ignore": [
29-
"**/test/fixtures/**"
24+
"**/fixtures/**",
25+
"**/output/**"
3026
]
3127
},
3228
"echint": {
3329
"ignore": [
3430
"coverage/**",
35-
"CONTRIBUTING.md",
36-
"test/fixtures/**"
31+
"CONTRIBUTING.md",
32+
"**/node_modules/**",
33+
"src/**",
34+
"test/**",
35+
"**/fixtures/**"
3736
]
3837
},
3938
"devDependencies": {
4039
"codeclimate-test-reporter": "0.1.1",
4140
"echint": "^3.0.0",
4241
"glob": "^6.0.1",
4342
"istanbul": "^0.4.0",
44-
"lerna": "^3.8.0",
45-
"mocha": "^2.3.4",
43+
"lerna": "^3.13.1",
44+
"mocha": "^6.0.2",
4645
"require-directory": "^2.1.1",
4746
"should": "^7.1.1",
4847
"standard": "^10.0.2"
@@ -74,5 +73,6 @@
7473
"unirest",
7574
"xhr",
7675
"xmlhttprequest"
77-
]
76+
],
77+
"name": "httpsnippet"
7878
}

packages/@httpsnippet/cli/README.md

Lines changed: 0 additions & 3 deletions

packages/@httpsnippet/curl/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ var helpers = require('../httpsnippet/helpers/shell')
1515
var CodeBuilder = require('../httpsnippet/helpers/code-builder')
1616

1717
module.exports = function (source, options) {
18-
var opts = util._extend({
18+
var opts = Object.assign({
1919
indent: ' ',
2020
short: false,
2121
binary: false
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/* global it */
2+
3+
'use strict'
4+
5+
var fixtures = require('../fixtures')
6+
var HTTPSnippet = require('../httpsnippet')
7+
require('should')
8+
9+
describe('httpsnippet - target - shell - curl', function () {
10+
it('should use short options', function () {
11+
var result = new HTTPSnippet(fixtures.requests.full).convert('shell', 'curl', {
12+
short: true,
13+
indent: false
14+
})
15+
16+
result.should.be.a.String
17+
result.should.eql("curl -X POST 'http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value' -H 'accept: application/json' -H 'content-type: application/x-www-form-urlencoded' -b 'foo=bar; bar=baz' -d foo=bar")
18+
})
19+
20+
it('should use binary option', function () {
21+
var result = new HTTPSnippet(fixtures.requests.full).convert('shell', 'curl', {
22+
short: true,
23+
indent: false,
24+
binary: true
25+
})
26+
27+
result.should.be.a.String
28+
result.should.eql("curl -X POST 'http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value' -H 'accept: application/json' -H 'content-type: application/x-www-form-urlencoded' -b 'foo=bar; bar=baz' --data-binary foo=bar")
29+
})
30+
31+
it('should use --http1.0 for HTTP/1.0', function () {
32+
var result = new HTTPSnippet(fixtures.curl.http1).convert('shell', 'curl', {
33+
indent: false
34+
})
35+
36+
result.should.be.a.String
37+
result.should.eql('curl --request GET --url http://mockbin.com/request --http1.0')
38+
})
39+
40+
it('should use custom indentation', function () {
41+
var result = new HTTPSnippet(fixtures.requests.full).convert('shell', 'curl', {
42+
indent: '@'
43+
})
44+
45+
result.should.be.a.String
46+
result.replace(/\\\n/g, '').should.eql("curl --request POST @--url 'http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value' @--header 'accept: application/json' @--header 'content-type: application/x-www-form-urlencoded' @--cookie 'foo=bar; bar=baz' @--data foo=bar")
47+
})
48+
})

packages/@httpsnippet/curl/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,8 @@
22
"name": "@httpsnippet/curl",
33
"description": "httpsnippet target for cURL",
44
"version": "0.1.0",
5-
"main": "index.js"
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "../../../node_modules/.bin/mocha --recursive *.spec.js"
8+
}
69
}
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)