npm

npm’s 2019 JavaScript ecosystem survey analysis is now available!Get your copy here »

burp-brightscript

0.3.2 • Public • Published

Burp - Lightweight script processing for Roku brightscript projects

codecov Build Status GitHub NPM

Links

Development

Burp is an independent open-source project, maintained exclusively by volunteers.

You might want to help! Get in touch via the slack group, or raise issues.

What is Burp?

It's a simple tool for executing regex replacements on source code files, a bit like awk. The killer feature is that it understands brightscript syntax, so it knows what line and function it's in. It can be used from command line, or from a js environment (such as when using gulp for building)

Usage

From javascript/typescript/node

Gulp typescript example

The following working gulpfile can be found in my roku MVVM spike; but the process is as follows.

  • npm install burp-brightscript --save-dev
  • Add the following to the top of gulpfile.ts `import { BurpConfig, BurpProcessor } from "burp-brightscript";
  • Create a task to process your files, with the desired regex replacements, such as:
export function addDevLogs(cb) {
 let config: BurpConfig = {
   "sourcePath": "build/.roku-deploy-staging",
   // "sourcePath": "build/wtf",
   "globPattern": "**/*.brs",
   "replacements": [
     {
       "regex": "(^.*(logInfo|logError|logVerbose|logDebug)\\((\\s*\"))",
       "replacement": "$1#FullPath# "
     },
     {
       "regex": "(^.*(logMethod)\\((\\s*\"))",
       "replacement": "$1#FullPath# "
     }
   ]
 }
 const processor = new BurpProcessor(config);
 processor.processFiles();
 cb();
}

From command line

  • Install burp globally with npm install -g burp-brightscript
  • Create a config file for your source, such as burpConfig.json containing:
export function addDevLogs(cb) {
  let config: BurpConfig = {
    "sourcePath": "build/.roku-deploy-staging",
    // "sourcePath": "build/wtf",
    "globPattern": "**/*.brs",
    "replacements": [
      {
        "regex": "(^.*(logInfo|logError|logVerbose|logDebug)\\((\\s*\"))",
        "replacement": "$1#FullPath# "
      },
      {
        "regex": "(^.*(logMethod)\\((\\s*\"))",
        "replacement": "$1#FullPath# "
      }
    ]
  }
  const processor = new BurpProcessor(config);
  processor.processFiles();
  cb();
}
  • Execute Burp burp burpConfig.json

Replacement values

You can use the following constants in your regex replacements:

  • #FullPath# - full path of file
  • #LineNumber# - line number of replacement
  • #FileName# - filename of replacement
  • #FunctionName# - function name of replacement
  • #CommentLine# - will result in the line being commented out

Why call it Burp?

I like the name. It doesn't mean anything.

Why did you make this?

I also made rLog and needed a tool that could process source files to insert the line number and function name. I figured this is a more generally useful way of doing it, which other's might leverage in their own tool-chains and build processes.

install

npm i burp-brightscript

Downloadsweekly downloads

6

version

0.3.2

license

MIT

last publish

collaborators

  • avatar
Report a vulnerability