burp-brightscript
Advanced tools
Comparing version 0.3.2 to 0.4.0
@@ -8,4 +8,4 @@ export interface BurpReplacement { | ||
sourcePath?: string; | ||
globPattern?: string; | ||
filePattern?: string[]; | ||
replacements?: BurpReplacement[]; | ||
} |
@@ -5,2 +5,3 @@ "use strict"; | ||
var path = require("path"); | ||
var util_1 = require("util"); | ||
var FileDescriptor_1 = require("./FileDescriptor"); | ||
@@ -19,3 +20,3 @@ var FileProcessor_1 = require("./FileProcessor"); | ||
this._config = config; | ||
console.log("Starting directory: " + process.cwd() + " sourcePath " + this._config.sourcePath); | ||
debug("Starting directory: " + process.cwd() + " sourcePath " + this._config.sourcePath); | ||
try { | ||
@@ -25,10 +26,10 @@ process.chdir(this._config.sourcePath); | ||
catch (err) { | ||
console.log('Could not change directory to source path: ' + err); | ||
debug('Could not change directory to source path: ' + err); | ||
throw new Error('Aborting'); | ||
} | ||
this._rootPath = process.cwd(); | ||
console.log('Set working directory to : ' + process.cwd()); | ||
debug('Set working directory to : ' + process.cwd()); | ||
this._warnings = []; | ||
this._errors = []; | ||
this._config.globPattern = this._config.globPattern || '**/*.brs'; | ||
this._config.filePattern = this._config.filePattern || ['**/*.brs']; | ||
} | ||
@@ -56,3 +57,4 @@ Object.defineProperty(BurpProcessor.prototype, "errors", { | ||
fileProcessor.rootPath = process.cwd(); | ||
var files = glob.sync(this._config.globPattern); | ||
var files = glob.sync(this._config.filePattern); | ||
debug(util_1.inspect(files)); | ||
files.forEach(function (file) { | ||
@@ -59,0 +61,0 @@ debug("file " + file + ", " + path.resolve(file)); |
@@ -9,7 +9,5 @@ "use strict"; | ||
var chaiSubset = require('chai-subset'); | ||
var dircompare = require('dir-compare'); | ||
chai.use(chaiSubset); | ||
var processor; | ||
var sourcePath = path.resolve(__dirname, '../test/stubProject'); | ||
var testsPath = 'build/source/tests'; | ||
var targetPath = 'build'; | ||
@@ -34,3 +32,3 @@ function clearFiles() { | ||
sourcePath: targetPath, | ||
globPattern: '**/*.brs', | ||
filePattern: ['**/*.brs'], | ||
replacements: [] | ||
@@ -37,0 +35,0 @@ }; |
@@ -18,2 +18,4 @@ "use strict"; | ||
return FileType_1.FileType.Brs; | ||
case '.bs': | ||
return FileType_1.FileType.Bs; | ||
default: | ||
@@ -36,2 +38,3 @@ return FileType_1.FileType.Other; | ||
pkgPath = pkgPath.replace(cwd, ''); | ||
pkgPath = pkgPath.replace('.bs', '.brs'); | ||
return pkgPath.replace('pkg://', 'pkg:/'); | ||
@@ -38,0 +41,0 @@ }; |
export declare enum FileType { | ||
Brs = 0, | ||
Other = 1 | ||
Bs = 0, | ||
Brs = 1, | ||
Other = 2 | ||
} |
@@ -5,5 +5,6 @@ "use strict"; | ||
(function (FileType) { | ||
FileType[FileType["Brs"] = 0] = "Brs"; | ||
FileType[FileType["Other"] = 1] = "Other"; | ||
FileType[FileType["Bs"] = 0] = "Bs"; | ||
FileType[FileType["Brs"] = 1] = "Brs"; | ||
FileType[FileType["Other"] = 2] = "Other"; | ||
})(FileType = exports.FileType || (exports.FileType = {})); | ||
//# sourceMappingURL=FileType.js.map |
{ | ||
"name": "burp-brightscript", | ||
"version": "0.3.2", | ||
"version": "0.4.0", | ||
"description": "lightweight processor for roku brightscript projects", | ||
@@ -18,3 +18,2 @@ "main": "dist/index.js", | ||
"glob-all": "^3.1.0", | ||
"glob-fs": "^0.1.7", | ||
"lodash": "latest", | ||
@@ -21,0 +20,0 @@ "os": "^0.1.1", |
@@ -11,7 +11,5 @@ <h3 align="center"> | ||
## Links | ||
- **[Documentation](documentation)** | ||
- **[Release notes / History / Changes](CHANGELOG.md)** | ||
- [Roku developer slack group](https://join.slack.com/t/rokudevelopers/shared_invite/enQtMzgyODg0ODY0NDM5LTc2ZDdhZWI2MDBmYjcwYTk5MmE1MTYwMTA2NGVjZmJiNWM4ZWY2MjY1MDY0MmViNmQ1ZWRmMWUzYTVhNzJiY2M) | ||
- [Issue tracker](https://github.com/georgejecook/burp/issues) | ||
- [Roadmap](ROADMAP.md) | ||
- [CHANGELOG](CHANGELOG.md) | ||
@@ -28,2 +26,9 @@ ## Development | ||
## What kinds of things can you do with it? | ||
- Add line numbers to log calls in your files, or disable logs | ||
- Prevent further asserts executing in unit tests, if a test has failed | ||
- Replace tokens in your files | ||
- and more | ||
## Usage | ||
@@ -45,4 +50,3 @@ | ||
"sourcePath": "build/.roku-deploy-staging", | ||
// "sourcePath": "build/wtf", | ||
"globPattern": "**/*.brs", | ||
"globPattern": ["**/*.brs","**/*.bs"], | ||
"replacements": [ | ||
@@ -72,7 +76,5 @@ { | ||
``` | ||
export function addDevLogs(cb) { | ||
let config: BurpConfig = { | ||
{ | ||
"sourcePath": "build/.roku-deploy-staging", | ||
// "sourcePath": "build/wtf", | ||
"globPattern": "**/*.brs", | ||
"globPattern": ["**/*.brs"], | ||
"replacements": [ | ||
@@ -89,6 +91,3 @@ { | ||
} | ||
const processor = new BurpProcessor(config); | ||
processor.processFiles(); | ||
cb(); | ||
} | ||
``` | ||
@@ -98,2 +97,3 @@ - Execute Burp `burp burpConfig.json` | ||
### Replacement values | ||
You can use the following constants in your regex replacements: | ||
@@ -108,7 +108,54 @@ | ||
## Why call it Burp? | ||
I like the name. It doesn't mean anything. | ||
## Using with .bs files | ||
Note, you should invoke burp BEFORE you transpile, until further notice - this is because the line numbers will be completely wrong in your transpiled code. | ||
Burp will rename all file paths in the output from .bs to .brs | ||
Here's a gulp example of how you can achieve this (please feel free to put up a pr with docs improvements, for a better suggestion) - the following is for mac/linux: | ||
``` | ||
export async function compile(cb) { | ||
// copy all sources to tmp folder | ||
// so we can add the line numbers to them prior to transpiling | ||
await copyFiles(); | ||
await sleep(100); | ||
await applyBurpPreprocessing(); | ||
let builder = new ProgramBuilder(); | ||
await builder.run({ | ||
stagingFolderPath: outDir, | ||
createPackage: false, | ||
"rootDir": tmpBuildDir, | ||
"autoImportComponentScript": true, | ||
}); | ||
} | ||
public async copyFiles() { | ||
let oldPath = path.resolve(process.cwd()); | ||
try { | ||
let outPath = path.resolve(this.config.outputPath); | ||
fs.mkdirSync(this.config.outputPath); | ||
let sourcePaths = this.config.sourcePaths.map((p) => { | ||
p = path.resolve(p); | ||
p = p.endsWith('/') ? p : p + '/'; | ||
if (!fs.existsSync(p)) { | ||
feedbackError(new File(p, '', '', ''), `cannot find source path ${p}`, true); | ||
} | ||
return p; | ||
}).join(' '); | ||
await exec(`rsync -az ${sourcePaths} ${outPath}`); | ||
console.log(`files copied to ${outPath} dir is now ${process.cwd()}`); | ||
} catch (err) { | ||
console.error(err); | ||
} | ||
process.chdir(oldPath); | ||
} | ||
``` | ||
## Why did you make this? | ||
I also made [rLog](https://github.com/georgejecook/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. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 1 instance in 1 package
8
681
155
0
58278
- Removedglob-fs@^0.1.7
- Removedansi-wrap@0.1.0(transitive)
- Removedansi-yellow@0.1.1(transitive)
- Removedarr-diff@2.0.0(transitive)
- Removedarr-flatten@1.1.0(transitive)
- Removedarray-unique@0.2.1(transitive)
- Removedasync@1.5.2(transitive)
- Removedbluebird@2.11.0(transitive)
- Removedbraces@1.8.5(transitive)
- Removedcomponent-emitter@1.3.1(transitive)
- Removedcore-util-is@1.0.3(transitive)
- Removeddetect-file@0.1.0(transitive)
- Removeddotdir-regex@0.1.0(transitive)
- Removedends-with@0.2.0(transitive)
- Removedexpand-brackets@0.1.5(transitive)
- Removedexpand-range@1.8.2(transitive)
- Removedexpand-tilde@1.2.2(transitive)
- Removedexport-files@2.1.1(transitive)
- Removedextend-shallow@2.0.1(transitive)
- Removedextglob@0.3.2(transitive)
- Removedfilename-regex@2.0.1(transitive)
- Removedfill-range@2.2.4(transitive)
- Removedfindup-sync@1.0.0(transitive)
- Removedfor-in@0.1.81.0.2(transitive)
- Removedfor-own@0.1.5(transitive)
- Removedfs-exists-sync@0.1.0(transitive)
- Removedget-value@1.3.1(transitive)
- Removedglob-base@0.3.0(transitive)
- Removedglob-fs@0.1.7(transitive)
- Removedglob-fs-dotfiles@0.1.6(transitive)
- Removedglob-fs-gitignore@0.1.6(transitive)
- Removedglob-parent@1.3.02.0.0(transitive)
- Removedglobal-modules@0.2.3(transitive)
- Removedglobal-prefix@0.1.5(transitive)
- Removedhomedir-polyfill@1.0.3(transitive)
- Removedini@1.3.8(transitive)
- Removedis-absolute@0.2.6(transitive)
- Removedis-buffer@1.1.6(transitive)
- Removedis-dotdir@0.1.0(transitive)
- Removedis-dotfile@1.0.3(transitive)
- Removedis-equal-shallow@0.1.3(transitive)
- Removedis-extendable@0.1.1(transitive)
- Removedis-extglob@1.0.0(transitive)
- Removedis-glob@2.0.1(transitive)
- Removedis-number@2.1.04.0.0(transitive)
- Removedis-posix-bracket@0.1.1(transitive)
- Removedis-primitive@2.0.0(transitive)
- Removedis-relative@0.2.1(transitive)
- Removedis-unc-path@0.1.2(transitive)
- Removedis-windows@0.1.10.2.0(transitive)
- Removedisarray@1.0.0(transitive)
- Removedisexe@2.0.0(transitive)
- Removedisobject@1.0.22.1.0(transitive)
- Removedkind-of@2.0.13.2.26.0.3(transitive)
- Removedlazy-cache@0.1.00.2.71.0.4(transitive)
- Removedmap-cache@0.2.2(transitive)
- Removedmath-random@1.0.4(transitive)
- Removedmicromatch@2.3.11(transitive)
- Removedmixin-object@2.0.1(transitive)
- Removednoncharacters@1.1.0(transitive)
- Removednormalize-path@2.1.1(transitive)
- Removedobject-visit@0.1.0(transitive)
- Removedobject.omit@1.1.02.0.1(transitive)
- Removedos-homedir@1.0.2(transitive)
- Removedparse-filepath@0.6.3(transitive)
- Removedparse-gitignore@0.2.0(transitive)
- Removedparse-glob@3.0.4(transitive)
- Removedparse-passwd@1.0.0(transitive)
- Removedpreserve@0.2.0(transitive)
- Removedprocess-nextick-args@2.0.1(transitive)
- Removedrandomatic@3.1.1(transitive)
- Removedreadable-stream@2.3.8(transitive)
- Removedregex-cache@0.4.4(transitive)
- Removedrelative@3.0.2(transitive)
- Removedremove-trailing-separator@1.1.0(transitive)
- Removedrepeat-element@1.1.4(transitive)
- Removedrepeat-string@1.6.1(transitive)
- Removedresolve-dir@0.1.1(transitive)
- Removedsafe-buffer@5.1.2(transitive)
- Removedset-value@0.2.0(transitive)
- Removedstarts-with@1.0.2(transitive)
- Removedstring_decoder@1.1.1(transitive)
- Removedthrough2@2.0.5(transitive)
- Removedunc-path-regex@0.1.2(transitive)
- Removedutil-deprecate@1.0.2(transitive)
- Removedwhich@1.3.1(transitive)
- Removedxtend@4.0.2(transitive)