getdave / grunt-deployments

MYSQL database deployments using GruntJS
MIT License
72 stars 34 forks source link

Make it work for windows platform #41

Open wizioo opened 10 years ago

wizioo commented 10 years ago

I have a Windows 8.1 with Wamp locally and I work with a remote linux platform. Your grunt plugin is fantastic but it didn't worked for me until I made some changes which can interest you.

To make it work on Win platform, there is 2 problem:

  1. Sed doesn't work on Windows platform. As shelljs is a dependencie, you can use:

       //Execute SED
       shell.sed("-i", search, replace, output_file);

    to replace:

    
        var cmd = grunt.template.process(tpls.search_replace, {
            data: {
                search: search,
                replace: replace,
                path: output_file
            }
        });
    .....
       // Execute cmd
        shell.exec(cmd);

    in db_replace function and you don't need search_replace template either.

  2. Problem w/ command backslashes in db_dump function

    cmd = tpl_ssh + " \\ " + tpl_mysqldump;

    I just had to remove it (\\ ) to make it work for me. If not, mysql_dump is not launched. I don't know if it's crucial for other platforms.

getdave commented 10 years ago

Hi @wizioo. Thanks for bringing this to my attention.

As I'm not based on a windows platform I'd really appreciate it if you were able to raise a pull request (into the develop branch) detailing these changes.

I can then easily inspect the diff and see if it's possible to provide a mechanism to allow the tool to be more configurable to function across multiple environments without the need to amend the core script.

Would that be possible?

wizioo commented 10 years ago

Hello @getdave. Thanks for your interest in my idea. I'll try to do it this week for sure.

nickbouton commented 10 years ago

@wizioo Thanks for this, saved me a lot of time on Win7!

Also, +1 for Windows support. :)

davemac commented 10 years ago

If using sed for search/replace, does it handle data in serialised arrays?

I'm thinking WordPress databases for example, which use serialised arrays.

getdave commented 10 years ago

@davemac No I don't think sed will handle that. As far as I"m aware the only tool that does is the SearchReplaceDB PHP script I'm using on the advanced search replace branch of this repo.

If there's a node module that can handle this then that would be greatly preferable.

wizioo commented 10 years ago

@davemac Yeah, it doesn't work on serialised arrays... Any solution?

wizioo commented 10 years ago

Have a look at @webrain solution : https://github.com/webrain/grunt-wordpress-deploy Their search / replace function handle serialised arrays. Maybe we should use it to solve the problem.

getdave commented 10 years ago

@wizioo The @webrain solution is a fork of my original. It would have been nice if they had contributed to my script rather than duplicate and rewrite but I understand if they prefer to work on their own solution. It's all open source after all! :)

I like the serialisation of arrays in their script. I suggest that we consider "borrowing" the serialization code and add a credit in a "history" section as they have on their script when referencing.

Any thoughts?