wesleytodd / YeoPress

A Yeoman generator for WordPress
Other
1.08k stars 161 forks source link

Handle errors #148

Closed wesleytodd closed 9 years ago

wesleytodd commented 9 years ago

See: #147

There are a bunch of places we can add useful error messages.

jacquesletesson commented 9 years ago
            remote.directory('.', this.conf.get('wpDir'));
                  ^
TypeError: Cannot read property 'directory' of undefined
    at Generator.<anonymous> (/usr/local/lib/node_modules/generator-wordpress/app/index.js:216:10)
    at Generator.<anonymous> (/usr/local/lib/node_modules/generator-wordpress/node_modules/yeoman-generator/lib/actions/remote.js:79:21)
    at Stream.<anonymous> (/usr/local/lib/node_modules/generator-wordpress/node_modules/yeoman-generator/lib/actions/fetch.js:70:21)
    at Stream.emit (events.js:129:20)
    at DestroyableTransform.onerror (/usr/local/lib/node_modules/generator-wordpress/node_modules/yeoman-generator/node_modules/download/node_modules/stream-combiner/index.js:36:18)
    at DestroyableTransform.emit (events.js:129:20)
    at onwriteError (/usr/local/lib/node_modules/generator-wordpress/node_modules/yeoman-generator/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:250:10)
    at onwrite (/usr/local/lib/node_modules/generator-wordpress/node_modules/yeoman-generator/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:268:5)
    at WritableState.onwrite (/usr/local/lib/node_modules/generator-wordpress/node_modules/yeoman-generator/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:106:5)
    at afterTransform (/usr/local/lib/node_modules/generator-wordpress/node_modules/yeoman-generator/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:104:5)```
jacquesletesson commented 9 years ago

Any idea why I got this error... yo doctor returns no problem.

As mentionned in #147 I deleted cache file but I'm still getting stuck during installation.

Toddses commented 9 years ago

Possibly the download failed. Have you tried running YeoPress with the --verbose flag? It should give more output.

jacquesletesson commented 9 years ago

@Toddses The output is the same with yo wordpress --verbose and I have a stable internet connection so it's really weird that the download failed.

wesleytodd commented 9 years ago

Try throwing some logging right here, console.error(err).

jacquesletesson commented 9 years ago

@wesleytodd Sorry for the late answer, I was focused on an other project.

I modified index.js as you advised :

console.error("Error(s) : " + err);
console.error("Remote : " + remote);

It returns :

Error(s) : Error: invalid characters in fileName: FJCore\IJG.txt
Remote : undefined

So it's somehow link to the FJCore library... Any ideas?

dnzmsc commented 9 years ago

@jacquesletesson I have the same problem! Where did you put the console.error rows? After remote.directory? As:

this.logger.log('Installing WordPress ' + this.conf.get('wpVer'));
    this.remote('wordpress', 'wordpress', this.conf.get('wpVer'), function(err, remote)
        remote.directory('.', this.conf.get('wpDir'));
        console.error("Error(s) : " + err);
        console.error("Remote : " + remote);
        this.logger.log(this.conf.get('wpDir'));
        this.logger.log('WordPress installed');
        done();
    }.bind(this));
wesleytodd commented 9 years ago

@jacquesletesson WOW....lol. So are you guys on windows?

jacquesletesson commented 9 years ago

@wesleytodd Not at all. OSX 10.10.2 – Yosemite.

dnzmsc commented 9 years ago

@wesleytodd No, I'm on Mac OSX 10.10.3 – Yosemite.

wesleytodd commented 9 years ago

Oh, well then it is weird that the directory separator is a \. Seems like that might be part of the problem

jacquesletesson commented 9 years ago

@dnzmsc Put it just before the line : remote.directory('.', this.conf.get('wpDir'));

dnzmsc commented 9 years ago

@wesleytodd I can't see this error as I wrote to @jacquesletesson

wesleytodd commented 9 years ago

Not sure why I closed that....oops.

wesleytodd commented 9 years ago

The odd thing is that I cannot find FJCore anywhere in the wordpress source. So I am really not sure where this file is coming from. You both have cleared your yeoman cache right?

jacquesletesson commented 9 years ago

A quick video demo : http://quick.as/Z1OntY8qV

@wesleytodd The fact that remote is undefined is linked to a failed download?

jacquesletesson commented 9 years ago

http://code.svn.wordpress.org/wordpress-sources/plupload/1.5.4/csharp/Plupload/FJCore/

wesleytodd commented 9 years ago

@jacquesletesson where did you find that? I am pretty sure that yeoman uses the github clone, so that is what I was searching.

Can you try changing your log to console.trace(err)? See where it is actually occurring.

jacquesletesson commented 9 years ago

@wesleytodd With the trace :

Trace: [Error: invalid characters in fileName: FJCore\IJG.txt]
    at Generator.<anonymous> (/usr/local/lib/node_modules/generator-wordpress/app/index.js:216:9)
    at Generator.<anonymous> (/usr/local/lib/node_modules/generator-wordpress/node_modules/yeoman-generator/lib/actions/remote.js:79:21)
    at Stream.<anonymous> (/usr/local/lib/node_modules/generator-wordpress/node_modules/yeoman-generator/lib/actions/fetch.js:70:21)
    at Stream.emit (events.js:129:20)
    at DestroyableTransform.onerror (/usr/local/lib/node_modules/generator-wordpress/node_modules/yeoman-generator/node_modules/download/node_modules/stream-combiner/index.js:36:18)
    at DestroyableTransform.emit (events.js:129:20)
    at onwriteError (/usr/local/lib/node_modules/generator-wordpress/node_modules/yeoman-generator/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:250:10)
    at onwrite (/usr/local/lib/node_modules/generator-wordpress/node_modules/yeoman-generator/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:268:5)
    at WritableState.onwrite (/usr/local/lib/node_modules/generator-wordpress/node_modules/yeoman-generator/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:106:5)
    at afterTransform (/usr/local/lib/node_modules/generator-wordpress/node_modules/yeoman-generator/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:104:5)
wesleytodd commented 9 years ago

Maybe it should have been console.log(err.stack)? The lines in this are not really helpful....I was looking for a check on the filename that might throw this error.

jacquesletesson commented 9 years ago

@wesleytodd console.log(err.stack) returns an error : TypeError: Cannot read property 'stack' of null

Weirdly when I launch the generator with Wordpress installed as a submodule, the error occurs but all the files are downloaded and I can use the install.

wesleytodd commented 9 years ago

With git there is a different install path. So I am actually surprised the error occurs at all. This is going to be a harder one to track down. If you want to really dig in then I would be happy to merge a PR, but otherwise I will not be able to look at it until this weekend.

dnzmsc commented 9 years ago

@wesleytodd I made everything as @jacquesletesson but the only message I get is

................/usr/local/lib/node_modules/generator-wp-scaffold/app/index.js:155
        remote.directory('.', this.conf.get('wpDir'));
              ^
TypeError: Cannot read property 'directory' of undefined
dnzmsc commented 9 years ago

The name is wp-scaffold but it is the same generator

jacquesletesson commented 9 years ago

@wesleytodd @dnzmsc It drives me crazy so I want to understand why I got these errors... Let's assume the FJCore is somehow linked to my configuration... Why does the generator returns a value of undefined for this.remote?

Any way, I will keep digging into this issue.

dnzmsc commented 9 years ago

@jacquesletesson Please tell me if you solve!

jacquesletesson commented 9 years ago

@dnzmsc Does it work without issue while using GIT and Wordpress as a sub module?

dnzmsc commented 9 years ago

@jacquesletesson I didn't try, but I need not to use it in this way

Toddses commented 9 years ago

@jacquesletesson Can you do me a favor, take a look at the yeoman-generator package manifest and let me know what version you have installed?

jacquesletesson commented 9 years ago

@Toddses It's 0.18.10

Toddses commented 9 years ago

Thanks.

Okay here is what I'm finding. I know I'm probably basically talking to myself, but sometimes it helps to write things down and work it out that way.

I get this error 100% of the time when using yeoman-generator 0.18.10, which is the last 0.18 release. But yeoman-generator is on 0.19.1 right now. So I updated that module, and now I don't get the error. But there's a catch, yeoman-generator no longer extracts the archive. So you end up with a tarball in the cache, and the 4.1.1 wordpress tarball in the directory you ran YeoPress. And that's not really useful. So at the moment I'm hunting down what may have changed in the remote() call that makes yeoman-generator no longer extract the dang thing.

If I can't work anything out here in the next couple hours, we could force YeoPress to install yeoman-generator 0.18.7, thinking that would at least get YeoPress working while we figure out the issue and get yeoman-generator updated to 0.19.1.

jacquesletesson commented 9 years ago

That's sick. I didn't get that far... I should have though about updating yeoman-generator. Let me know if I can be of any help.

Toddses commented 9 years ago

Here is the relevant issue: yeoman/generator#794

Toddses commented 9 years ago

Welp using yeoman-generator 0.18.7 doesn't do the trick. You're back to square one. I'm guessing one of the plugins it uses was updated, which broke the extract function. I'm kinda digging in there to see if I can figure it out.

Toddses commented 9 years ago

@jacquesletesson Can you take a look at your node version?

$ node -v
Toddses commented 9 years ago

I believe I've worked out a potential solution. But since YeoPress is so tied into the framework of the yeoman-generator, we may not be able to produce a new release until they get their fix in and released.

Looks to me like it has to do with the latest version of node and how readable streams are handled. Possibly it changed in the 0.12 release. A quick fix is to make a change in fetch.js. If you're willing and able to jump into your YeoPress installation, edit ./node-modules/yeoman-generator/lib/actions/fetch.js on line 64, change

res.on('data', function () {

to

res.on('readable', function () {

and that should get things working for you. It did for me at least.

Toddses commented 9 years ago

yeoman/generator#795

Keep an eye on that PR. When they either pull that in or create a different fix, we can go ahead and bump to the latest version of yeoman-generator and do a new release.

Toddses commented 9 years ago

Ok my fix was merged into the master a few minutes ago: yeoman/generator#796.

@wesleytodd do you want to wait until yeoman-generator issues a new release before we try and get YeoPress updated?

wesleytodd commented 9 years ago

We can probably get an alpha release with the fix by directly referencing the repo. I can do this tonight when I get home form work. But we wont do an actual release until they get their version stabilized.

Toddses commented 9 years ago

Perfect.

wesleytodd commented 9 years ago

https://github.com/yeoman/generator/issues/800

Posted that. Looks like the tarball being copied over is solved by clearing cache after upgrading. But that means this would be backward incompatible.

Im working on updating develop right now and will push it soon.

Toddses commented 9 years ago

0.19.2 just released for yeoman-generator!

wesleytodd commented 9 years ago

https://github.com/wesleytodd/YeoPress/commit/3b4d740634a1ff862fe25ebeee5247f8a0960b0b https://github.com/wesleytodd/YeoPress/commit/ac6a41b343dd6e4040dd3680198375be5a48b225

Give it a test. If you are happy we can close these out and release.

Also, I don't know if you saw this, but I posted an issue that might cause problems: https://github.com/yeoman/generator/issues/800#issuecomment-94283306

It works once you clear cache, but it looks backwards incompatible, so I dont know what they are going to want to do.

Toddses commented 9 years ago

I've been keeping my eye on that one, too. Seeing how it plays out.

I'll test the update here in a few.

Toddses commented 9 years ago

The update looks good to me. :+1:

wesleytodd commented 9 years ago

Closing but not releasing. #152 is a serious blocker.

theoptips commented 9 years ago

I (on Mac Yosemite) got this error when I have underscores in my file/repo directory name e.g. test_test --> throws error build couldn't finish test --> no problem,instantly okay

Toddses commented 9 years ago

Open up a new issue for that.

theoptips commented 9 years ago

@Toddses good idea, done that. FYI link here https://github.com/wesleytodd/YeoPress/issues/157