Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No "verb" targets found #4

Open
jwtd opened this issue Jan 3, 2015 · 7 comments
Open

No "verb" targets found #4

jwtd opened this issue Jan 3, 2015 · 7 comments
Labels

Comments

@jwtd
Copy link

jwtd commented Jan 3, 2015

Need a sanity check. The readme for grunt-verb says there is no configuration required. When I install and attempt to run the verb task without adding a config to my Gruntfile.js I get a "No verb targets found." response.

$ npm install grunt-verb --save-dev
$ grunt verb
...
> Running "verb" task
> [D] Task source: /Users/jd/Projects/4tr/node_modules/grunt-verb/tasks/verb.js
>> No "verb" targets found.
> Warning: Task "verb" failed. Use --force to continue.

The readme also says that I can use the Verb generator to kickstart the documentation for any project, so I tried that as well, but got the same result.

$ npm i -g generator-verb
$ npm install grunt-verb --save-dev
$ yo verb
> ? Project name? foo
> ? Description? Foo's description
> ? Author's name? John Smith
> ? Author's URL? https://github.com/jsmith
> ? GitHub username/org? jsmith
>    create LICENSE-MIT
>    create .verb.md
>   create CONTRIBUTING.md

$ grunt verb --verbose --debug
...
Registering "grunt-verb" local Npm module tasks.
Reading /Users/jd/Projects/4tr/node_modules/grunt-verb/package.json...OK
Parsing /Users/jd/Projects/4tr/node_modules/grunt-verb/package.json...OK
Loading "verb.js" tasks...OK
+ verb
Reading package.json...OK
Parsing package.json...OK
Initializing config...OK
Loading "Gruntfile.js" tasks...OK
+ build, changelog, cover, default, doc, integration, jsdocs, polish, readme, saveRevision, server, tagRevision, test, unit, verify, version, yuidocs
...
Running "verb" task
[D] Task source: /Users/jd/Projects/4tr/node_modules/grunt-verb/tasks/verb.js
>> No "verb" targets found.
Warning: Task "verb" failed. Use --force to continue.

I dug into grunt-verb task's code, and at the bottom it looks like the task's default config file is ".verbrc.md", but according to the output of yo verb it created ".verb.md".

// /node_modules/grunt-verb/tasks/verb.js
...
    grunt.config('verb', {
      readme: {
        files: [
          {src: ['.verbrc.md'], dest: 'README.md'},
          {expand: true, cwd: 'docs', src: ['**/*.tmpl.md'], dest: '.', ext: '.md'},
        ]
      }
    });
...

So, I tried changing my .verb.md to .verbrc.md, thinking that the task might now find the correct init file. No joy though. I still get the "No verb targets found." response.

There are some grunt tasks (like grunt-build-number) that require an entry in the Gruntfile.js even when you don't alter the defaults. So, I tried adding a verb block....

// Gruntfile.js
    verb: {
      readme: {}
    },

And running task again produces...

Registering "grunt-verb" local Npm module tasks.
Reading /Users/jd/Projects/4tr/node_modules/grunt-verb/package.json...OK
Parsing /Users/jd/Projects/4tr/node_modules/grunt-verb/package.json...OK
Loading "verb.js" tasks...OK
+ verb
Reading package.json...OK
Parsing package.json...OK
Initializing config...OK
Loading "Gruntfile.js" tasks...OK
+ build, changelog, cover, default, doc, integration, jsdocs, polish, readme, saveRevision, server, tagRevision, test, unit, verify, version, yuidocs

Running "verb" task
[D] Task source: /Users/jd/Projects/4tr/node_modules/grunt-verb/tasks/verb.js

Running "verb:readme" (verb) task
[D] Task source: /Users/jd/Projects/4tr/node_modules/grunt-verb/tasks/verb.js
Verifying property verb.readme exists in config...OK
File: [no files]
Options: sep="\n", ext=".md", data=["docs/*.{json,yml}"], prefixBase, cwd="/Users/jd/Projects/4tr", destBase="/Users/jd/Projects/4tr", docs="docs"

Done, without errors.

This time around, the verb task was found, and it tried to run, but it didn't find any files in its default options, so I tried to set some up...

// Gruntfile.js
    verb: {
      readme: {
        files:[ 
          { 
            src: [ '.verbrc.md' ], 
            dest: 'README.md' 
          }
        ]
      }
    },

And now I get an error 'test/fixtures/comment.tmpl.md' not existing.

Running "verb:readme" (verb) task
[D] Task source: /Users/jd/Projects/4tr/node_modules/grunt-verb/tasks/verb.js
Verifying property verb.readme exists in config...OK
Files: .verbrc.md -> README.md
Options: sep="\n", ext=".md", data=["docs/*.{json,yml}"], prefixBase, cwd="/Users/jd/Projects/4tr", destBase="/Users/jd/Projects/4tr", docs="docs"
Reading .verbrc.md...OK
Warning: ENOENT, no such file or directory 'test/fixtures/comment.tmpl.md' Use --force to continue.

Aborted due to warnings.

I checked the verbrc.md and found no reference to 'test/fixtures/comment.tmpl.md', so I'm assuming that error was thrown from inside the verb module.

This is where I'm at now. Have I gone through the steps incorrectly?

@jwtd
Copy link
Author

jwtd commented Jan 3, 2015

I just tried to trace what happens to the defaults. Inside of /node_modules/grunt-verb/tasks/verb.js I dumped verb.options out to the console in a few different places:

  • At the bottom of the file where you test !grunt.config('verb')
  • At the top of the file just before verb.options = _.extend(verb.options || {}, options);
  • At the top of the file just after verb.options = _.extend(verb.options || {}, options);

The output is below. It looks like the grunt.config('verb') at the bottom isn't getting persisted or isn't getting passed to verb.options, because when the task runs verb.options is undefined.

The grunt.config('verb') call isn't being seen by Grunt for some reason, which is why the "No "verb" targets found" error gets thrown when there isn't a verb config in Gruntfile.js.

Registering "grunt-verb" local Npm module tasks.
Reading /Users/jd/Projects/4tr/node_modules/grunt-verb/package.json...OK
Parsing /Users/jd/Projects/4tr/node_modules/grunt-verb/package.json...OK
--------------------------------------------------------------------------------
>>>>>>>>> Right after if (!grunt.config('verb')) 
No grunt config found using defaults.
Inspect grunt.config :: { [Function]
  data:
   { verb:
      { readme:
         { files:
            [ { src: [ '.verbrc.md' ], dest: 'README.md' },
              { expand: true,
                cwd: 'docs',
                src: [ '**/*.tmpl.md' ],
                dest: '.',
                ext: '.md' } ] } } },
  escape: [Function],
  getPropString: [Function],
  getRaw: [Function],
  get: [Function],
  process: [Function],
  set: [Function],
  merge: [Function],
  init: [Function],
  requires: [Function] }
--------------------------------------------------------------------------------
Loading "verb.js" tasks...OK
+ verb
Reading package.json...OK
Parsing package.json...OK
Initializing config...OK
Loading "Gruntfile.js" tasks...OK
+ build, changelog, cover, default, doc, integration, jsdocs, polish, readme, saveRevision, server, tagRevision, test, unit, verify, version, yuidocs

Running tasks: readme

Running "readme" task
[D] Task source: /Users/jd/Projects/4tr/Gruntfile.js

Running "verb" task
[D] Task source: /Users/jd/Projects/4tr/node_modules/grunt-verb/tasks/verb.js

Running "verb:readme" (verb) task
[D] Task source: /Users/jd/Projects/4tr/node_modules/grunt-verb/tasks/verb.js
Verifying property verb.readme exists in config...OK
Files: .verbrc.md -> README.md
Options: sep="\n", ext=".md", data=["docs/*.{json,yml}"], prefixBase, cwd="/Users/jd/Projects/4tr", destBase="/Users/jd/Projects/4tr", docs="docs"
--------------------------------------------------------------------------------
>>>>>>>>> Before  verb.options = _.extend(verb.options || {}, options);
Inspect initial verb.options :: undefined
--------------------------------------------------------------------------------
>>>>>>>>> After  verb.options = _.extend(verb.options || {}, options);
Inspect using verb.options :: { sep: '\n',
  ext: '.md',
  data: [ 'docs/*.{json,yml}' ],
  prefixBase: true,
  cwd: '/Users/jd/Projects/4tr',
  destBase: '/Users/jd/Projects/4tr',
  docs: 'docs' }
--------------------------------------------------------------------------------
Reading .verbrc.md...OK
Warning: ENOENT, no such file or directory 'test/fixtures/comment.tmpl.md' Use --force to continue.

@jwtd
Copy link
Author

jwtd commented Jan 3, 2015

I was able to get it to work by setting up the verb task in the Gruntfile.js and stripping the content of .verbrc.md down so that it only references items that actually exist in the project.

Gruntfile.js

    verb: {
      readme: {
        files:[ 
          { 
            src: [ '.verbrc.md' ], 
            dest: 'README.md' 
          }
        ]
      }
    },

.verbrc.md

# {%= name %}

> {%= description %}

## Install
{%= include("install-npm", {save: true}) %}

@jonschlinkert
Copy link
Member

wow, thanks so much for the detailed description and research into the problem. I'll try to look into it this weekend to see what the issue is.

@jonschlinkert
Copy link
Member

doh, I think (hope) it's as simple as updating grunt-verb to read .verb.md files? Glaring oversight on my part

@jwtd
Copy link
Author

jwtd commented Jan 3, 2015

No worries. Yes, aligning .verb.md and .verbrc.md across the verb projects will resolve one of the issues.

The issue of the default verb task not being loaded was my fault. I was calling grunt.loadNpmTasks('grunt-verb'); before grunt.initConfig() in my Gruntfile. As a result, the default verb config block your task create was wiped out before the task was called and that resulted in the No "verb" targets found error. Moving the task loader below the initiConfig call resolved the problem.

Even with all of that sorted, I was still getting a compilation error. I traced the error down to the line {%= comments("index.js") %} in the .verbrc.md file that generator-verb created by default. When left in, it produces the error:

Warning: ENOENT, no such file or directory 'test/fixtures/comment.tmpl.md' Use --force to continue.

@jonschlinkert
Copy link
Member

perfect, this is great feedback. thanks again for tracking everything down. I think I know what needs to be done to get all of it fixed

@alundiak
Copy link

to get all of it fixed

@jonschlinkert so, is this fixed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants