linemanjs / lineman

Lineman helps you build fat-client JavaScript apps. It produces happiness by building assets, mocking servers, running specs on every file change
MIT License
1.18k stars 80 forks source link

troubleshooting grunt task for lineman plugin development #314

Closed dcunited001 closed 9 years ago

dcunited001 commented 10 years ago

I'm trying to write a lineman-vulcanize plugin, which uses the grunt-vulcanize task. i've pretty much gotten the lineman plugin wired up correctly, but i cannot for the life of me determine what input the grunt-vulcanize task is getting.

i can't do a grunt.log.warn() or grunt.log.writeln() or anything. i'm running the task with lineman grunt -v vulcanize and it runs, but nothing happens. I'm using npm link on both lineman-vulcanize and grunt-vulcanize to try to see what input grunt-vulcanize is getting. what's the best way to debug and troubleshoot here? I know the problem is something simple. I've tried looking at lineman config and everything looks correct. the only thing i can successfully do is crash grunt while it's running the task by adding a syntax error.

dcunited001 commented 10 years ago

here's the section of code in grunt-vulcanize that i'm trying to debug. some of it has been updated to try to debug.

/*
 * grunt-vulcanize
 * https://github.com/Polymer/grunt-vulcanize
 *
 * Copyright (c) 2013 The Polymer Authors
 * Licensed under the BSD license.
 */

'use strict';

module.exports = function(grunt) {

  var vulcanize = require('vulcanize');
  // Please see the Grunt documentation for more information regarding task
  // creation: http://gruntjs.com/creating-tasks

  grunt.registerMultiTask('vulcanize', 'Inline HTML Imports', function() {
    grunt.log.writeln('V=========V');
    grunt.log.writeln('vulcanizing');
    grunt.log.writeln('V=========V');

    var done = this.async();
    // Merge task-specific and/or target-specific options with these defaults.
    var options = this.options({
      config: null,
      csp: false,
      inline: false,
      strip: false,
      excludes: {
        imports: [],
        scripts: [],
        styles: []
      }
    });

    // Iterate over all specified file groups.
    this.files.forEach(function(f) {
      // Concat specified files.
      var src = f.src.filter(function(filepath) {
        // Warn on and remove invalid source files (if nonull was set).
        if (!grunt.file.exists(filepath)) {
          grunt.log.warn('Source file "' + filepath + '" not found.');
          return false;
        } else {
          return true;
        }
      });

      // Handle options.
      options.input = src[0];
      options.output = f.dest;

      vulcanize.setOptions(options, function(err) {
        if (err) {
          return grunt.fatal(err);
        }
        vulcanize.processDocument();
        grunt.log.ok();
        grunt.verbose.writeln('wrote %s', f.dest + (!options.csp ? '' : ' and ' + f.dest.replace('.html', '.js')));
        done();
      });

    });
  });

};

and here's the configuration I'm trying to supply:


module.exports = (lineman) ->
  app = lineman.config.application

  config:
    loadNpmTasks: lineman.config.application.loadNpmTasks.concat("grunt-vulcanize")
    prependTasks: lineman.config.application.prependTasks.common.concat("vulcanize")

    vulcanize:
      options:
        csp: false
        inline: false
        strip: false
        exports:
          imports: []
          scripts: []
          styles: []

    watch:
      vulcanize:
        files: ["app/vulcanize/**.html"]
        tasks: ["vulcanize", "bower"]

  files:
    vulcanize:
      src: "app/vulcanize/index.html"
      dest: "generated/vulcanize/build.html"
dcunited001 commented 10 years ago

by the way, here's my lineman-vulcanize project and here's the project which includes the plugin.

davemo commented 10 years ago

Hey @dcunited001, debugging grunt is always challenging; this is probably easier to debug on a pairing session. Do you have time for that today? If so download zoom.us and shoot me an invite link here: davidmosher at gmail dot com

dcunited001 commented 10 years ago

Thanks Dave. Unfortunately, I don't have time today as I've got lots of work I promised to deliver for a client.

Would you have time this weekend? Or if not, can we set something up for Monday?

On Fri, Aug 29, 2014 at 10:23 AM, David Mosher notifications@github.com wrote:

Hey @dcunited001 https://github.com/dcunited001, debugging grunt is always challenging; this is probably easier to debug on a pairing session. Do you have time for that today? If so download zoom.us and shoot me an invite link here: davidmosher at gmail dot com

— Reply to this email directly or view it on GitHub https://github.com/linemanjs/lineman/issues/314#issuecomment-53882310.

David Conner *@dcunit3d 424-244-1486* [[ Github http://www.github.com/dcunited001 - Coursera https://www.coursera.org/user/i/8671e7b4d35f3d498f22e225dbe70bd9 - Smarterer http://smarterer.com/dcunit3d - Plus http://plus.google.com/101141634039644438128/ ]]

dcunited001 commented 10 years ago

Hey Dave,

Do you have time sometime this week to jump on a pairing session? Should

At this point I'm using node-inspector to debug the process and trying to get grunt-vulcanize to break on a debugger statement. I've got the lineman-vulcanize and grunt-vulcanize packages loaded with npm link, so changes in the source should be reflected in. I don't have a whole lot of experience debugging node apps.

I'm using the following commands to run the inspector:

node --debug-brk $(which lineman) grunt vulcanize
node --debug-brk $(which lineman) run

However, both of them seem to skip the debugger statement. I think the problem is likely something simple, like grunt-vulcanize receiving config in the wrong format or not at all or it may not even be running for some reason. However, I can't seem to determine what grunt is getting as input.

On Fri, Aug 29, 2014 at 12:19 PM, david conner dconner.pro@gmail.com wrote:

Thanks Dave. Unfortunately, I don't have time today as I've got lots of work I promised to deliver for a client.

Would you have time this weekend? Or if not, can we set something up for Monday?

On Fri, Aug 29, 2014 at 10:23 AM, David Mosher notifications@github.com wrote:

Hey @dcunited001 https://github.com/dcunited001, debugging grunt is always challenging; this is probably easier to debug on a pairing session. Do you have time for that today? If so download zoom.us and shoot me an invite link here: davidmosher at gmail dot com

— Reply to this email directly or view it on GitHub https://github.com/linemanjs/lineman/issues/314#issuecomment-53882310.

David Conner *@dcunit3d 424-244-1486 <424-244-1486>* [[ Github http://www.github.com/dcunited001 - Coursera https://www.coursera.org/user/i/8671e7b4d35f3d498f22e225dbe70bd9 - Smarterer http://smarterer.com/dcunit3d - Plus http://plus.google.com/101141634039644438128/ ]]

David Conner *@dcunit3d 424-244-1486* [[ Github http://www.github.com/dcunited001 - Coursera https://www.coursera.org/user/i/8671e7b4d35f3d498f22e225dbe70bd9 - Smarterer http://smarterer.com/dcunit3d - Plus http://plus.google.com/101141634039644438128/ ]]

davemo commented 9 years ago

Hi @dcunited001, sorry I failed to follow up with you on this. Did you end up sorting it out? If not, my offer is still open to pair on zoom.us; availability for me is limited to weekdays from 9am - 5pm EST, but if that works feel free to email me and setup a time :)