Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jancurn committed Nov 6, 2017
1 parent b842946 commit 6e15505
Show file tree
Hide file tree
Showing 17 changed files with 1,937 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
presets: ["es2015", "stage-0"]
}
27 changes: 27 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"extends": "airbnb-base",
"plugins": [
"import",
"promise"
],
"rules": {
"indent": ["error", 4],
"no-underscore-dangle": [2, {
"allow": ["_id"]
}],
"no-use-before-define": 0,
"no-param-reassign": 0,
"consistent-return": 0,
"array-callback-return": 0,
"arrow-body-style": 0,
"no-plusplus": 0,
"strict": ["error", "global"],
"max-len": ["error", 150],
"no-undef": 0,
"func-names": 0,
"import/prefer-default-export": 0,
"import/no-absolute-path": 0,
"import/no-extraneous-dependencies": ["error", { "devDependencies": ["**/test/*.js"] }],
"no-underscore-dangle": 0
}
}
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
build
node_modules
*.log
*.pid
*.seed
.DS_Store
lib
coverage
logs
pids
.idea
yarn.lock
docs
3 changes: 3 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Keep empty .npmignore file here so that /build is not ignored by "npm publish"
# as it is in .gitignore file. Yes, this happened in older versions of NPM.
# See https://docs.npmjs.com/misc/developers for info.
12 changes: 12 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
dist: trusty
sudo: required
addons:
before_install:
language: node_js
node_js:
- "8"
- "7"
- "6"
script:
- npm run lint
- npm test
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
0.0.x / 2017-11-06
==================
- Project created
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,15 @@
APPENDIX: How to apply the Apache License to your work.

To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]
Copyright 2017 Apifier s.r.o.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# proxy-chain
Enables creation of HTTP proxy-to-proxy
# proxy-chain: Enables creation of HTTP proxy-to-proxy chains

[![npm version](https://badge.fury.io/js/proxy-chain.svg)](http://badge.fury.io/js/proxy-chain)
[![Build Status](https://travis-ci.org/Apifier/proxy-chain.svg)](https://travis-ci.org/Apifier/proxy-chain)

69 changes: 69 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"name": "proxy-chain",
"version": "0.0.1",
"description": "Enables creation of HTTP proxy-to-proxy chains",
"main": "build/index.js",
"keywords": [
"apify",
"apifier",
"proxy",
"chain"
],
"author": {
"name": "Apify",
"email": "[email protected]",
"url": "https://www.apify.com"
},
"contributors": [
"Jan Curn <[email protected]>"
],
"license": "Apache-2.0",
"repository": {
"type": "git",
"url": "git+https://github.com/apifier/proxy-chain"
},
"bugs": {
"url": "https://github.com/apifier/proxy-chain/issues"
},
"homepage": "https://github.com/apifier/proxy-chain",
"files": [
"build"
],
"scripts": {
"build": "rm -rf ./build && babel src --out-dir build",
"mytest": "npm run build && node ./build/index.js",
"test": "npm run build && mocha --compilers js:babel-core/register --recursive",
"test-cov": "npm run build && babel-node node_modules/isparta/bin/isparta cover --report html --report text node_modules/.bin/_mocha",
"prepare": "npm run build",
"prepublishOnly": "(test $RUNNING_FROM_SCRIPT || (echo \"You must use publish.sh instead of 'npm publish' directly!\"; exit 1)) && npm test && npm run lint",
"clean": "rm -rf build",
"lint": "npm run build && eslint src test"
},
"dependencies": {
"bluebird": "^3.5.1",
"underscore": "^1.8.3"
},
"devDependencies": {
"babel-cli": "^6.6.5",
"babel-core": "^6.1.21",
"babel-eslint": "^7.2.2",
"babel-preset-es2015": "^6.1.18",
"babel-preset-stage-0": "^6.1.18",
"basic-auth-parser": "^0.0.2",
"chai": "^4.0.2",
"eslint": "^3.19.0",
"eslint-config-airbnb": "^15.0.1",
"eslint-config-airbnb-base": "^11.1.0",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-jsx-a11y": "^5.0.3",
"eslint-plugin-promise": "^3.4.2",
"eslint-plugin-react": "^7.0.1",
"isparta": "^4.0.0",
"mocha": "^3.2.0",
"proxy": "^0.2.4",
"request": "^2.81.0",
"sinon": "^2.2.0",
"sinon-stub-promise": "^4.0.0"
},
"optionalDependencies": {}
}
65 changes: 65 additions & 0 deletions publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/bin/bash

set -e

RED='\033[0;31m'
NC='\033[0m' # No Color

PACKAGE_NAME=`node -pe "require('./package.json').name"`
PACKAGE_VERSION=`node -pe "require('./package.json').version"`
BRANCH=`git status | grep 'On branch' | cut -d ' ' -f 3`
BRANCH_UP_TO_DATE=`git status | grep 'nothing to commit' | tr -s \n ' '`;
GIT_TAG="v${PACKAGE_VERSION}"

# Upload doc to S3 configuration
DOC_DIR=${PWD}"/docs"
AWS_BUCKET="apify-runtime-js-doc"

if [ -z "${BRANCH_UP_TO_DATE}" ]; then
printf "${RED}You have uncommitted changes!${NC}\n"
exit 1
fi

echo "Generating documentation ..."
npm run build-doc

echo "Uploading docs to S3 ..."
aws s3 cp "${DOC_DIR}/" "s3://${AWS_BUCKET}/${GIT_TAG}/" --recursive --region us-east-1 --acl public-read --cache-control "public, max-age=86400"

echo "Pushing to git ..."
git push

# Master gets published as LATEST if that version doesn't exists yet and retagged as LATEST otherwise.
if [ "${BRANCH}" = "master" ]; then
EXISTING_NPM_VERSION=$(npm view ${PACKAGE_NAME} versions | grep ${PACKAGE_VERSION} | tee) # Using tee to swallow non-zero exit code
if [ -z "${EXISTING_NPM_VERSION}" ]; then
printf "${RED}Version ${PACKAGE_VERSION} was not yet published on NPM. Note that you can only publish to NPM from \"develop\" branch!${NC}\n"
exit 1
else
echo "Tagging version ${PACKAGE_VERSION} with tag \"latest\" ..."
RUNNING_FROM_SCRIPT=1 npm dist-tag add ${PACKAGE_NAME}@${PACKAGE_VERSION} latest
echo "Copy doc to latest folder..."
aws s3 cp "s3://${AWS_BUCKET}/${GIT_TAG}/" "s3://${AWS_BUCKET}/latest/" --recursive --region us-east-1 --acl public-read --cache-control "public, max-age=3600"
fi

# Develop branch gets published as BETA and we don't allow to override tag of existing version.
elif [ "${BRANCH}" = "develop" ]; then
echo "Publishing version ${PACKAGE_VERSION} with tag \"beta\" ..."
RUNNING_FROM_SCRIPT=1 npm publish --tag beta

echo "Tagging git commit with ${GIT_TAG} ..."
git tag ${GIT_TAG}
git push origin ${GIT_TAG}
echo "Git tag: ${GIT_TAG} created."

echo "Copy docs to S3 to beta folder..."
aws s3 cp "s3://${AWS_BUCKET}/${GIT_TAG}/" "s3://${AWS_BUCKET}/beta/" --recursive --region us-east-1 --acl public-read --cache-control "public, max-age=3600"

# For other branch throw an error.
else
printf "${RED}You can publish from develop and master branches only!${NC}\n"
exit 1
fi


echo "Done."
Empty file added src/chained_connection.js
Empty file.
Loading

0 comments on commit 6e15505

Please sign in to comment.