Skip to content
프로젝트

소개

파일 교체에 특화된 CLI 프록시 도구

시스템 및 인프라

이 수치를 측정하는 방법

What you can do

  • Support Mac, Linux and Windows
  • Support both single file and combo file replacing
  • Support directory mapping with any files
  • Support both HTTP and HTTPS

측정된 스타 증가

in 24h
0
in 7 days
0
in 15 days
0
in 1 month
기록 수집 중

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

NProxy

A cli proxy tool specialized in file replacing

Build Status

Why NProxy

Maybe you have such question as why NProxy when we have Fiddler, Charles, Rythem and Tinyproxy. Yes, there is no doubt that they are all great tools, however they don't meet my requirements:

  • Support Mac, Linux and Windows(especially Mac and Linux)
  • Support replacing combo files with separated source files
  • Support directory mapping

This is the main reason why NProxy is here. Besides, NProxy can improve the efficiency of my daily development for enterprise-level product with a bunch of complex building processes, which cost me lots of time.

I've written a post named NProxy: The Mjolnir for UI Developers and a keynote NProxy: A Sharp Weapon for UI Developers to explain my reason for developing NProxy in detail.

Features

  • Support Mac, Linux and Windows
  • Support both single file and combo file replacing
  • Support directory mapping with any files
  • Support both HTTP and HTTPS

Installation

npm install -g nproxy (node >= v0.8.x is required)

If you are not familiar with Node.js and NPM, you can visit the How to install NProxy wiki page to get detail information about installation of NProxy

Usage

nproxy -l replace_rule.js 

Setting your browser's proxy to 127.0.0.1:port(8989 by default)

If you don't know how to set proxy for browser, please read this wiki: How to set brower's proxy

More Options:

Usage: nproxy [options]

Options:

  -h, --help         output usage information
  -V, --version      output the version number
  -l, --list [list]  Specify the replace rule file
  -p, --port [port]  Specify the port nproxy will listen on(8989 by default)
  -t, --timeout [timeout] Specify the request timeout (5 seconds by default)

Template of Replace Rule file(should be a .js file)

module.exports = [

  // 1. replace single file with local one
  {
    pattern: 'homepage.js',      // Match url you wanna replace
    responder:  "/home/goddyzhao/workspace/homepage.js"
  },

  // 2. replace single file with web file
  {
    pattern: 'homepage.js',      // Match url you wanna replace
    responder:  "http://www.anotherwebsite.com/assets/js/homepage2.js"
  },

  // 3. replace combo file with src with absolute file path
  {
    pattern: 'group/homepageTileFramework.*.js', 
    responder: [
      '/home/goddyzhao/workspace/webapp/ui/homepage/js/a.js',
      '/home/goddyzhao/workspace/webapp/ui/homepage/js/b.js',
      '/home/goddyzhao/workspace/webapp/ui/homepage/js/c.js'
    ] 
  },

  // 4. replace combo file with src with relative file path and specified dir
  {
    pattern: 'group/homepageTileFramework.*.js',
    responder: {
      dir: '/home/goddyzhao/workspace/webapp/ui/homepage/js',
      src: [
        'a.js',
        'b.js',
        'c.js'
      ]
    }
  },

  // 5. Map server image directory to local image directory
  {
    pattern: 'ui/homepage/img',  // must be a string
    responder: '/home/goddyzhao/image/' //must be a absolute directory path
  },

  // 6. Write responder with regular expression variables like $1, $2
  {
    pattern: /https?:\/\/[\w\.]*(?::\d+)?\/ui\/(.*)_dev\.(\w+)/,
    reponder: 'http://localhost/proxy/$1.$2'
  },

  // 7. Map server image directory to local image directory with regular expression
  // This simple rule can replace multiple directories to corresponding locale ones
  // For Example, 
  //   http://host:port/ui/a/img/... => /home/a/image/...
  //   http://host:port/ui/b/img/... => /home/b/image/...
  //   http://host:port/ui/c/img/... => /home/c/image/...
  //   ...
  {
    pattern: /ui\/(.*)\/img\//,
    responder: '/home/$1/image/'
  }
];

You can use the template file and replace it with your own configurations.

Quickly setup rule files for SF project

For UI Developers from SuccessFactors, here is a bonus for you guys. You can use the sf-transfer tool to transfer the combo xml file to NProxy rule file automatically!

License

NProxy is available under the terms of the MIT License

관련 프로젝트 살펴보기

불러오는 중…