Git Product home page Git Product logo

kraken-devtools's Introduction

kraken-devtools

Build Status
NPM version

Compile-on-the-fly and other development tools for use when building express applications.

Dependency considerations

Without a great system for supporting optional peer dependencies, here are some minimum versions for using plugins shipped with kraken-devtools:

  1. node-sass@^1.0.0

Middleware compiler

The middleware compiler builds your dependencies as they are requested, allowing you to run your express application as-is and not have to set up a watch task.

Usage

var app = require('express')(),
    devtools = require('kraken-devtools');

app.use(devtools(/* src, dest [, config] */));

Parameters

src - The directory of your source files
dest - The destination directory for the compiled files
config - Optional. An object of compilers to enable

Configuration

less, sass, stylus, dustjs, and a static copier plugin are available to use. To enable, set the module and files properties in your config, e.g.:

{
    "less": {
        "module": "kraken-devtools/plugins/less",
        "files": "/css/**/*.css",
        "ext": "less"
    }
}

To add additional compilers, create a module with the following format and add it to your configuration:

module.exports = function (options) {
    return function (data, args, callback) {
        // Compile the data
    };
};

kraken-devtools-browserify

Thanks to iantocristian we now have browserify support for kraken-devtools

kraken-devtools's People

Contributors

adurrive avatar aredridel avatar bluelnkd avatar gabrielcsapo avatar grawk avatar jamischarles avatar jasisk avatar jeffharrell avatar jgable avatar kylekatarnls avatar lensam69 avatar pvenkatakrishnan avatar skoranga avatar tlivings avatar totherik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kraken-devtools's Issues

Asking for precompiled DUST template that doesn't exist crashes the process

I have a bug in my single page app that yielded a request for a template that doesn't exist. Rather than returning 404, the devtools middleware crashes when trying to compile the non-existent template.

REQUEST:
https://localhost.paypal.com:7443/developer/templates/US/fr/partials/page/foo.js

CONSOLE:
GET /developer/templates/US/fr/partials/page/foo.properties 404 244.000 ms - 1077954
Wed, 24 Sep 2014 15:19:37 GMT uncaughtException ENOENT, open '/Users/cvaughan/workspace/git/cvaughan/developernodeweb/public/templates/partials/page/foo.dust'
Error: ENOENT, open '/Users/cvaughan/workspace/git/cvaughan/developernodeweb/public/templates/partials/page/foo.dust'

-Chris Vaughan

Possible security issue

If I try to load the URL /anything.anything), I get this error:

SyntaxError: Caught exception: Invalid regular expression: //(.*)\.anything:)$/: Unmatched ')'
SyntaxError: Caught exception: Invalid regular expression: //(.*)\.anything:)$/: Unmatched ')'
  at new RegExp (:null:null)
  at start (node_modules/kraken-devtools/lib/middleware.js:45:21)
  at fn (node_modules/kraken-devtools/node_modules/async/lib/async.js:582:34)
  at Object._onImmediate (node_modules/kraken-devtools/node_modules/async/lib/async.js:498:34)
  at processImmediate [as _immediateCallback] (timers.js:336:15)

I see the code:

ext = path.extname(req.path).replace('.', '\\.');
regex = new RegExp(dir + '/(.*)' + ext +'$', 'i');

Inject the URL (user input) in a RegExp is a very bad idea IMHO.

Problems to set up sass+compass sprite generator

Hi Guys.
I'm a little bit confused about how to configure sass and compass sprite generator with the kraken-devtools.

Somebody has already built a setup like this?
I searched on Google but found nothing :/

Thanks.

Middleware regex is bad and you should feel bad

This guy.

The problem is that path.extname will return an extension pretty optimistically.

$ node -e "require('path').extname('/route.ohmy/') === '' || process.exit(1)" || echo 'uh oh'
uh oh

So, a route like /route.ohmy/ returns .ohmy for ext. The subsequent regex checks that extension assuming it's at the end of the path. Since, in this case, it's not at the end of the path, the regex.exec fails (returning null), throwing when you try to get [1] on it.

Middleware errors are not output to console

I noticed that LESS compile errors aren't being output to the console in development mode. I tried it on a fresh kraken app to verify it wasn't my app. I can see the error on the 500 page if I visit the css path directly.

For dust/i18n/browserify I get an "uncaughtException Cannot find module './'" error when any syntax errors occur which isn't very helpful.

Obviously, if I find the time in the near future to dig into why and submit a PR, I will. ๐Ÿ˜„

Add browserify support

Generator allows you to choose browserify as javascript library. It works perfect in production mode after grunt build but doesn't work on development. I'm aware of #19 but it seemed there's no progress since June 4th. Thanks.

externalize all plugins

kraken-devtools has a great plugin architecture. A lot of the issues and PRs are related to changing the built-in plug-ins specifically, as opposed to any changes or issues with the core functionality. As such, it would make sense to externalize the plugins and only focus on core functionality issues in this repository.

Things on the way to making this a reality:

  1. create repos/modules for each existing built-in plugin
  2. establish both a naming convention and a test approach to use in external modules
  3. create a list of available plugins and maintain it in this repo's wiki or TBD

Add support for passing additional paths/parameters to LESS compiler

Very directly, I would like to see the argument passed in this line (https://github.com/paypal/kraken-devtools/blob/master/index.js#L53) be exposed via the middleware.json config.

It would enable the usage of LESS frameworks installed via bower โ€” as it stands I do not believe it is possible to tell kraken-devtools to compile app-level LESS assets along with less libraries/files installed via bower or not in the app-level css directory.

For a more in-depth understanding of what I'm trying to accomplish and why I currently believe I cannot with the current kraken-devtools, see this issue which I filed under the kraken-js project: krakenjs/kraken-js#86

I would be happy to work on this and submit a PR, but I'm not sure if the PayPal team has a plan for addressing this use case or has specific suggestions for implementation/exposing the API.

Thanks!

"pointer being freed was not allocated" with Sass

Hello,

I really don't understand what's happened (updated some npm packages) but I keep having this error "pointer being freed was not allocated" until I go back to node-neat 0.8.6

What's weird is the patch that @aredridel has done here #22 was working fine with node-neat 0.9.3

I have tried to make different combination without success. @pvenkatakrishnan seems to have the same problem 93ae394

I am not enough skilled to debug node C++ and I need 0.9.3 so I must deactivate kraken-devtools :(

Is there some tips to debug this sort of error and help ?

Unable to get this to work if I rebase the static middleware route

I'm serving static files from a separate route in order to easily separate them onto a CDN. Unfortunately, it seems that this change causes devtools to no longer find any of the files it would normally be compiling on the fly.

./config/config.json

   ...
        "static": {
            // comment out the change in route, plus update paths in .dust files, and it will work
            "route": "/public",
            "module": {
                "arguments": [ "path:./.build" ]
            }
        },

./config/development.json

      "devtools": {
          "enabled": true,
          "priority": 35,
          "module": {
              "name": "kraken-devtools",
              "arguments": [
                  "path:./public",
                  "path:./.build",
                  {   
                      "template": {
                          "module": "kraken-devtools/plugins/dustjs",
                          "files": "/templates/**/*.js",
                          "base": "templates",
                          "i18n": "config:i18n"
                      },
                      "less": {
                          "module": "kraken-devtools/plugins/less",
                          "files": "/css/**/*.css",
                          "ext": "less"
                      },
                      "copier": {
                          "module": "kraken-devtools/plugins/copier",
                          "files": "**/*"
                      }
                  }
              ]
          }
      }

I've tried prepending /public/ to the less.files definition, but that seems to have made no difference. Nor does the copier definition seem to work either. My assumption is path matching being done inside devtools is failing, but I'm too new to the environment to know if this is on my end or not.

Less Parser constructor not receiving second argument from Kraken-Devtools

As soon as I reference a less css file in my development environment I get the following error.
I have traced it down as best I can and it appears to be in the way the Less Parser is instantiated.

I've tried replacing my less @import with regular css as well as saving the .less file as an empty file.
The error persists as long as it is trying to process the .less file.

Using [email protected], [email protected], [email protected], [email protected]


The issue itself

In [email protected] lib/less/parser/parser.js#117 it expects the imports variable to be an object with a contents property. In this case, [email protected] plugins/less.js#37 doesn't supply an imports argument to the Parser constructor, thus imports is undefined and Parser.parse attempts to access imports.contents without checking that it exists.


Problem locations in projects

Problem area in kraken-devtools: https://github.com/krakenjs/kraken-devtools/blob/master/plugins/less.js#L37
Problem area in less: https://github.com/less/less.js/blob/master/lib/less/parser/parser.js#L117


Error

TypeError: Cannot read property 'contents' of undefined
    at Object.Parser.parse (/ProjectRoot/node_modules/less/lib/less/parser/parser.js:117:20)
    at module.exports (/ProjectRoot/node_modules/kraken-devtools/plugins/less.js:37:20)
    at /ProjectRoot/node_modules/kraken-devtools/lib/middleware.js:154:9
    at asyncWrap (/ProjectRoot/node_modules/async-listener/glue.js:188:31)
    at fs.js:272:14
    at fs.gracefulify (/ProjectRoot/node_modules/graceful-fs/graceful-fs.js:42:10)
    at originalCloseSync (/ProjectRoot/node_modules/module-config-paypal/node_modules/graceful-fs/graceful-fs.js:104:5)
    at asyncWrap (/ProjectRoot/node_modules/async-listener/glue.js:188:31)
    at Object.oncomplete (fs.js:108:15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.