stephenharris / grunt-wp-deploy

Grunt plug-in to deploy a build directory to WordPress' SVN
MIT License
64 stars 18 forks source link

Issues copying files to /tmp/ #2

Open thejsj opened 10 years ago

thejsj commented 10 years ago

When running the grunt task, the files weren't being copied to the /tmp directory.

In my case, the following change fixed it: From:

exec( 'cp -ar '+ build_dir + '. ' + svnpath+'/trunk/' );

To

exec( 'cp -R '+ build_dir + '. ' + svnpath+'/trunk/' );
helgatheviking commented 10 years ago

I'm also not seeing the build files copied to the trunk directory. Unfortunately, the proposed change (assuming I am implementing it correctly) didn't resolve it for me. I think this copy fail, must be why I'm getting a notice that the plugin was successfully deployed, yet my svn.plugins.org code never updates.

stephenharris commented 10 years ago

Thanks @thejsj - apologies for taking so long to get back to you. This seems similar to #1 - where I believe the argument a (alias for dR) conflicts with the lowercase r. Was this on a mac? Linux doesn't seem to care. Is there any reason why you dropped the a unlike #1?

Hi @helgatheviking have you tried running grunt wp-deploy --verbose - do you see any error messages?

thejsj commented 10 years ago

Yes, I'm on a mac.

No particular reason for not adding the a. It just seemed that R was enough.

Let me know if I can help in any way!

helgatheviking commented 10 years ago

@stephenharris Sorry for the delay. In my mind I already replied! Here'e the output from the verbose command:

Running tasks: wp_deploy

Running "wp_deploy" task

Running "wp_deploy:deploy" (wp_deploy) task
Verifying property wp_deploy.deploy exists in config...OK
File: [no files]
Options: svn_url="http://plugins.svn.wordpress.org/{plugin-slug}", svn_user="hel
gatheviking", plugin_slug="nav-menu-roles", build_dir="build/"
Reading package.json...OK
Parsing package.json...OK
Reading build/readme.txt...OK
Reading build/nav-menu-roles.php...OK
Checking out http://plugins.svn.wordpress.org/nav-menu-roles
Check out complete.
Clearing trunk.
Copying build/ to /tmp/nav-menu-roles/trunk/
[?] Are you sure you want to commit "1.5.0"? Yes
Committing to trunk
Copying to tag
Committing tag

Done, without errors.

The SVN repo is checked out into the /tmp folder, but the trunk is never updated with the new files.

stephenharris commented 10 years ago

@helgatheviking - I'm going to release an update shortly. If nothing else, it should throw out any errors it has when trying to copy the build directory to trunk.

helgatheviking commented 10 years ago

@stephenharris cool. I look forward to it.

helgatheviking commented 10 years ago

@stephenharris Did you ever get around to that update?

stephenharris commented 10 years ago

Sorry @helgatheviking I've been moving house, so I've not had time yet :/. Will try to release it before the weekend!

helgatheviking commented 10 years ago

No rush. I was just double-checking that I hadn't missed something.

On Wed, Mar 26, 2014 at 8:13 PM, Stephen Harris notifications@github.comwrote:

Sorry @helgatheviking https://github.com/helgatheviking I've been moving house, so I've not had time yet :/. Will try to release it before the weekend!

Reply to this email directly or view it on GitHubhttps://github.com/stephenharris/grunt-wp-deploy/issues/2#issuecomment-38726895 .

stephenharris commented 10 years ago

Updated version (finally!) released.

helgatheviking commented 10 years ago

Well the bad news is it still isn't working for me. The good news, is that now I have an error that reveals what is happening:

Running "wp_deploy:deploy" (wp_deploy) task
[D] Task source: D:\www\wordpress\src\wp-content\plugins\nav-menu-roles\node_mod
ules\grunt-wp-deploy\tasks\wp_deploy.js
Checking out http://plugins.svn.wordpress.org/nav-menu-roles
Checked out revision 890282.

Check out complete.
Clearing trunk.
Copying deploy/nav-menu-roles/ to /tmp/nav-menu-roles/trunk/
Warning: Failed to copy into trunk: Error: Command failed: 'cp' is not recognize
d as an internal or external command,
operable program or batch file.
 Use --force to continue.

Aborted due to warnings.

cp does not exist in Windows. Is there a way to make the copy system agnostic? What about using grunt-contrib-copy which you already use in your Events Gruntfile?

stephenharris commented 10 years ago

I could look into using grunt.file.copy (docs) (which grunt-contrib-copy uses)...

helgatheviking commented 10 years ago

that'd be awesome!

helgatheviking commented 10 years ago

To follow up, I tested the gruntfile branch and the copying seems resolved! I am now seeing this instead:

Warning: Failed to commit to assets: Error: Command failed: The syste nd the path specified. 'awk' is not recognized as an internal or external command, operable program or batch file. Use --force to continue.

stephenharris commented 10 years ago

Yeah, over one hurdle and straight into the next :). Seems Windows doesn't support awk. But apparently you can install gawk (see http://stackoverflow.com/questions/21927944/how-to-run-an-awk-commands-in-windows).

I'm not sure if there is a better alternative (it would of course be nice for the task to run on Windows without requiring third-party software be installed) - but at least that will/should get it working for you.

helgatheviking commented 10 years ago

What is the purpose of awk? i've not seen anything regarding awk in the various bash scripts for deployment http://thereforei.am/2011/04/21/git-to-svn-automated-wordpress-plugin-deployment/

stephenharris commented 10 years ago

This isn't git to svn. Essentially it copies a folder into trunk, and checks in the changes. The awk allows the script to check in the changes.

(See line 73 of the script linked to by that article: https://github.com/thenbrent/multisite-user-management/blob/master/deploy.sh#L73)

stephenharris commented 10 years ago

@helgatheviking - so grunt.file.copy is now used, but I'm guessing the use of awk still presents a problem for Windows users? I don't know of a way around that, so can I close this with an update to the readme warning Windows users that they will need to install gawk?

helgatheviking commented 10 years ago

I've updated to 1.0.3 and there are still problems on the Windows side of things.

Committing to trunk Copying to tag Committing tag Warning: Failed to comit tag: Error: Command failed: The system cannot find the path specified. Use --force to continue.

When I look at the /tmp folder the new version has been copied into trunk, but the trunk is then not copied into a new tag folder. I didn't think grunt.file.copy could be used outside of the folder where grunt is installed?

Thanks for continuing to work on this!

stephenharris commented 10 years ago

grunt.file.copy is used for copying the build/assets directory to trunk/assets in the tmp directory respectively. For copying trunk to tags/[version], svn copy is used. If this fails it should display an error (as per https://github.com/stephenharris/grunt-wp-deploy/blob/master/tasks/wp_deploy.js#L164:L166) and abort the process. Perhaps try console.log-ing stdout and stderr, which might give a fuller picture.

helgatheviking commented 9 years ago

Looks like it isn't copying to trunk after all. In verbose mode I get this:

Check out complete. Clearing trunk. Copying build/ to /tmp/radio-buttons-for-taxonomies/trunk/ Warning: Failed to copy into trunk: Error: Command failed: cp: cannot create dir ectory `/tmp/radio-buttons-for-taxonomies/trunk/': No such file or directory Use --force to continue.

Which makes me think that the script is stuck because Windows has a different directory path structure than Mac/Linux? D:/tmp/radio-buttons-for-taxonomies/trunk does exist, but Windows probably doesn't know what '/tmp' is.

I don't know if I have suggested it before, but would it be possible to put the temporary SVN repo inside the project folder? Then you could use relative paths which I think should be less impacted by the OS. Or maybe even grunt.file.copy would work. At the end the deploy folder could optionally delete itself.

stephenharris commented 9 years ago

but would it be possible to put the temporary SVN repo inside the project folder

I kept it out of there to avoid clutter (also accidentally overriding stuff). It should be possible, and with a careful choice of name for the svn repo directory, perfectly safe. At least we've got a fairly good idea of what the problem is, so I'll a think a see if there's a way round this.

helgatheviking commented 9 years ago

If you made it an option in the Gruntfile setup, people could set up whatever folder they wanted and nothing would be overwritten. Well, in theory of course! and if the file auto-deleted itself there wouldn't be any clutter.

helgatheviking commented 9 years ago

I was playing with this today and was thinking of

adding a temp_path to the options

    var options = this.options({
        svn_url: "http://plugins.svn.wordpress.org/{plugin-slug}",
        svn_user: false,
        plugin_slug: false,
        build_dir: false,
        assets_dir: false,
        max_buffer: 200*1024,
        temp_path: "/tmp/"
    });

And then the svn path would be var svnpath = options.temp_path.replace(/\/?$/, '/') + slug;

Inside this script svn copy will not copy the trunk. Outside of the script, svn commands work fine in the terminal, so I am just as confused as ever.

I never get the error Failed to copy to tag, but I think this is failing as looking at the folders, I never see the new tag. So then it fails when it trys to when it tries to switch to the new tag folder.

Do you have to commit twice? Don't know if it would make a difference, but you could copy to trunk, svn copy to tag and then commit everything at once?

shivapoudel commented 9 years ago

@stephenharris for this issue hackathon can be obtained from https://github.com/remcotolsma/grunt-rt-wp-deploy xD

Committing to trunk Copying to tag Committing tag Warning: Failed to comit tag: Error: Command failed: The system cannot find the path specified. Use --force to continue.

Please fix this issue as soon :)

stephenharris commented 9 years ago

If you'd care to make a PR of the fix, I'd be happy to test and merge :)

shivapoudel commented 9 years ago

Cool! I will take care of this bug ASAP, I am hitting roughly right now to fix this ;)