1.5.13 • Published 6 years ago

muddler v1.5.13

Weekly downloads
1
License
ISC
Repository
github
Last release
6 years ago

Muddler

Transpile, Unit Test, and Minify your hackmud scripts (TypeScript or JavaScript) with ease. Works with hackmud version 1.4.10

Changelog - most recent entry

1.5.0 - 2017-10-25

Added

  • TypeScript testing support! You can now write .test.ts files instead of test.js files. #2
  • Added '-t' option to specify a testing directory. #1
  • Added '-R' option to specify a custom mocha reporter

Fixed

  • Temp files are now removed like they should be.
  • Temp files are now created in the same directory as the source script, to make unit testing easier. #3
  • -V option returns the correct version now. #4
  • Mocha was caching testing results and returning false positives. We now run Mocha in a child process, and errors are reported as expected.

Changed

  • We all needed a little more Nyan in our lives.
  • Debounced testing while watching to 2000ms per file so transpiled ts files don't triggler double muddling.
  • Modifying a test while watching re-runs the target file. #5

Full changelog can be found here

Prerequisites

This project requires Java 7+ and Google's Closure Compiler on your PATH to function.

Installation

npm install muddler -g

Usage

    -V, --version                output the version number
    -o, --out-file <filename>    the name of the output file
    -w, --watch                  watch the current directory for changes
    -W, --watch-dir <directory>  watch the provided directory for changes
    -d, --out-dir <directory>    what directory to save files to
    -c, --config <filename>      the location of your config file (defaults to muddle.json in the current directory)
    -v, --verbose                increase program verbosity. Good for debugging, or checking for sneaky hacks.
    -q, --quiet                  disable all program output
    -s, --skip-tests             skip tests if they exist
    -t, --test-dir <directory>   the directory to search for tests.
    -R, --reporter <reporter>    Pass this in if you want to use a different mocha test reporter
    -h, --help                   output usage information

Examples:

muddle -W C:\dev\hackmud -d C:\User\1337H4x0r\AppData\Roaming\hackmud\1337H4x0r\scripts

This will watch C:\dev\hackmud for changes to .ts and .js files, run any .test.js files, and then write _mud.js files to your hackmud folder. I think this is the most useful option.

muddle

This will watch the current working directory for changes to .ts and .js files, run any .test and write _mud.js files to the current directory.

muddle <filename>

This will test \<filename>.test.js, and then write a minified \<filename>_mud.js to the current directory.

Testing

New Feature If you don't want to clutter up your scripts folder with tests, you can now create a test directory to store your tests in. You still need to follow the <filename>.test.(t|j)s naming convention. Don't like the 'test' dir? Add -t and specify your own test folder name

If you wish to unit test your files, create a test file with the same name as your script, but with an extension of .test.js. I'll hopefully add support for writing tests in TypeScript someday, but today is not that day. Done. Write unit tests as you normally would for Mocha, with the following exceptions:

  • anywhere you would use '#', use '$' instead.
  • at the top of your file add const window = {}
  • to call the main function in your script, call muddled(context, args)
  • remember that you're going to have to mock context, args, $fs.scripts.lib(), etc..

See sample.test.ts for simple example of testing

Config file

Create a muddle.json file in your development directory (!!not AppData/hackmud/user/scripts !!) muddle your life. The available settings are the options for the program, but camelCased instead of kebab-cased. e.g.

{
  "watchDir": "C:\dev\hackmud" 
  "outDir": "C:\User\1337H4x0r\AppData\Roaming\hackmud\1337H4x0r\scripts"
}

Caveats

  • The Clojure Compiler (v20170910) is still working to support all of es6. One thing they do NOT support yet is array destructuring. You'll have to manually edit your script to rename your variables to non-clashing variables if you use destructuring.
  • If you wish to preserve your object property names, provide them as strings.
  • I haven't tested this with scripts that use the DB. If you run into problems, please make an issue on the github repo and I'll fix it asap.
  • For now, if you want to do testing, you have to save the test files in the same folder as your .ts/.js scripts.

Credits

This project was inspired by Gerow's Mudify. (@gerow on hackmud). The testing portion of the project was blatantly stolen from Jer0ge's hackmud-unit-poc.

I'm typically playing as @s1mply_me on hackmud go by Jolley in the Discord channel Feel free to hit me up (or even send some sweet sweet GC my way ;) ).

What's next?

So, you've got a muddler, but no scripts to muddle? Get started scripting with this excellent guide by @ciastex_ and @i20k.

1.5.13

6 years ago

1.5.12

6 years ago

1.5.11

6 years ago

1.5.10

7 years ago

1.5.8

7 years ago

1.5.7

7 years ago

1.5.5

7 years ago

1.5.4

7 years ago

1.5.3

7 years ago

1.5.2

7 years ago

1.5.1

7 years ago

1.5.0

7 years ago

1.4.9

7 years ago

1.4.8

7 years ago

1.4.7

7 years ago

1.4.6

7 years ago

1.4.5

7 years ago

1.4.3

7 years ago

1.4.2

7 years ago

1.4.1

7 years ago

1.4.0

7 years ago

1.3.14

7 years ago

1.3.13

7 years ago

1.3.12

7 years ago

1.3.11

7 years ago

1.3.10

7 years ago

1.3.9

7 years ago

1.3.8

7 years ago

1.3.7

7 years ago

1.3.6

7 years ago

1.3.5

7 years ago

1.3.3

7 years ago

1.3.2

7 years ago

1.3.1

7 years ago

1.3.0

7 years ago

1.2.1

7 years ago

1.2.0

7 years ago

1.1.4

7 years ago

1.1.3

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.0.11

7 years ago

1.0.10

7 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago