wesleytodd / YeoPress

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

Generator exiting early, not downloading any themes #12

Closed drbroad closed 11 years ago

drbroad commented 11 years ago

First up - love the generator. Just experiencing some minor trouble with installing a theme (any theme)

Event with the defaults selected in the generator it seems to die directly after creating wp-config.php.

   create content/themes/twentytwelve/tag.php
   create wp-config.php

/usr/local/lib/node_modules/generator-wordpress/util/wordpress.js:81
        db.name   = contents.match(/define\(["']DB_NAME["'],[\s]*["'](.*)["']\)/)[1]
                             ^
TypeError: Object <?php
/**
 * The base configurations of the WordPress.
 *
 * This file has the following configurations: MySQL settings, Table Prefix,
 * Secret Keys, WordPress Language, and ABSPATH. You can find more information
 * by visiting {@link http://codex.wordpress.org/Editing_wp-config.php Editing
 * wp-config.php} Codex page. You can get the MySQL settings from your web host.
 *
 * This file is used by the wp-config.php creation script during the
 * installation. You don't have to use the web site, you can just copy this file
 * to "wp-config.php" and fill in the values.
 *
 * @package WordPress
 */

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'yeopress');

/** MySQL database username */
define('DB_USER', 'root');

/** MySQL database password */
define('DB_PASSWORD', 'yeopress');

/** MySQL hostname */
define('DB_HOST', 'localhost');

/** Database Charset to use in creating databa

And thats where it dies... Any thoughts?

wesleytodd commented 11 years ago

I am not able to replicate this. Could you paste in the settings you used (the portion between the red lines when it asks for confirmation)? Also, it might help to add a console.log where it is saying the error is to see what the contents variable is holding. If you do that, please also copy in that output. And thanks for using YeoPress, hopefully I can get this figured out for you.

drbroad commented 11 years ago
          A Yeoman Generator For WordPress

[?] URL WordPress will be installed at (ex. example.com):  dev.yeopress.com
[?] WordPress Version:  (3.5.1)
[?] Table prefix:  (wp_) yo_
[?] Database host:  (localhost)
[?] Database name:  wp_yo
[?] Database user:  root
[?] Database password:  yeopress
[?] Use Git?  (Y)
[?] Would you like to install WordPress as a submodule?  (N) y
[?] WordPress install directory:  (wordpress)
[?] WordPress content directory:  (content)
[?] Install a custom theme?  (Y) y
[?] Destination directory (ex. twentytwelve):  yeopress
[?] Theme source type (git/tar):  (git)
[?] GitHub username:  (wesleytodd)
[?] GitHub repository name:  (YeoPress)
[?] Repository branch:  (template)

----------------------------
WordPress URL: http://dev.yeopress.com
Database table prefix: yo_
Database host: localhost
Database name: wp_yo
Database user: root
Database password: yeopress
WordPress install directory: wordpress
WordPress content directory: content
Initialize a Git repo: Yes
Install WordPress as a Git submodule: Yes
Theme install directory: content/themes/yeopress
----------------------------
[?] Does everything look correct?  (Y)

And the console.log shows this in iterm2:

create content/themes/twentytwelve/page.php
   create content/themes/twentytwelve/rtl.css
   create content/themes/twentytwelve/screenshot.png
   create content/themes/twentytwelve/search.php
   create content/themes/twentytwelve/sidebar-front.php
   create content/themes/twentytwelve/sidebar.php
   create content/themes/twentytwelve/single.php
   create content/themes/twentytwelve/style.css
   create content/themes/twentytwelve/tag.php
   create wp-config.php
<Buffer 3c 3f 70 68 70 0a 2f 2a 2a 0a 20 2a 20 54 68 65 20 62 61 73 65 20 63 6f 6e 66 69 67 75 72 61 74 69 6f 6e 73 20 6f 66 20 74 68 65 20 57 6f 72 64 50 72 65 ...>

/usr/local/lib/node_modules/generator-wordpress/util/wordpress.js:82
        db.name   = contents.match(/define\(["']DB_NAME["'],[\s]*["'](.*)["']\)/)[1]
                             ^
TypeError: Object <?php
/**
 * The base configurations of the WordPress.
 *
 * This file has the following configurations: MySQL settings, Table Prefix,
 * Secret Keys, WordPress Language, and ABSPATH. You can find more information
 * by visiting {@link http://codex.wordpress.org/Editing_wp-config.php Editing
 * wp-config.php} Codex page. You can get the MySQL settings from your web host.

in wordpress.js:

function getDbCredentials() {
    var ee = new EventEmitter();

    loadConfig().on('done', function(contents) {
        console.log(contents)
        var db    = {};
        db.name   = contents.match(/define\(["']DB_NAME["'],[\s]*["'](.*)["']\)/)[1];
        db.user   = contents.match(/define\(["']DB_USER["'],[\s]*["'](.*)["']\)/)[1];
        db.pass   = contents.match(/define\(["']DB_PASSWORD["'],[\s]*["'](.*)["']\)/)[1];
        db.host   = contents.match(/define\(["']DB_HOST["'],[\s]*["'](.*)["']\)/)[1];
        db.prefix = contents.match(/\$table_prefix[\s]*=[\s]*["'](.*)["']/)[1];

        ee.emit('done', db);
    }).on('error', function(err) {
        ee.emit('error', err);
    });

    return ee;
};

Appreciate the help!

wesleytodd commented 11 years ago

Which version of node are you using ($ node -v)? I am not having this issue on 0.10.*, but I know exactly what it happening and can push a fix out tonight, I will update here when it is published. Sorry for your issue.

drbroad commented 11 years ago

I believe i was using 0.9.6 but just performed a round of uninstalls/reinstalls to make sure nothing fishy was happening. I am on 0.10.12 now and all is well with the generator.

wesleytodd commented 11 years ago

I am glad it is working well now. I have not been making backward compatibility a priority, but I don't think it matters much for generator users. Also, in case you don't know, odd number releases are unstable (0.9., 0.11.), so you should be careful of using them for anything other than testing.