frontend-maven-plugin icon indicating copy to clipboard operation
frontend-maven-plugin copied to clipboard

Modified the NodeInstaller to use a custom method for copying files c…

Open marcajimenez opened this issue 8 years ago • 6 comments

…opyDirectoryContents() rather than using the FileUtils.copyDirectory() which does not preserve file attributes. Also modified the ArchiveExtractor class to use a umask of 0001 when checking to set execute permission on files being unpacked.

Summary

We recently upgraded the version of Node for our webapp application to 6.11.3 and when using the frontend-maven-plugin to help with installation we ran into a permission error at build time. Several scripts included in the Node 6.11.3 archive which should have execute permission were not longer set to executable after the plugin's lifecycle. This fix is meant to cover this issue posted: https://github.com/eirslett/frontend-maven-plugin/issues/667

The root cause of the issue was in the plugin's use of FileUtils.copyDirectory which does not preserve File attributes. To fix this issue I have implemented a new method to copyDirectory contents which is used instead of the FileUtils method.

We have tested the fix on our local developer machines and jenkins machine and have confirmed that our Node installation has all of the correct permissions now.

marcajimenez avatar Nov 10 '17 22:11 marcajimenez

Is it possible to do this with the native Java API? https://stackoverflow.com/questions/6838221/how-to-preserve-file-permissions-when-using-fileutils-copydirectory I haven't looked much into it.

eirslett avatar Nov 11 '17 15:11 eirslett

I came across the same article and this is what I used to implement the copyDirectory function. The limitation of Files.copy() api is that it only copies a target file or directory but not the contents of a directory.

https://docs.oracle.com/javase/tutorial/essential/io/copy.html

My copyDirectory function will use Files.copy as it recurses the directory and sub-directories copying all contents.

marcajimenez avatar Nov 11 '17 18:11 marcajimenez

Ah ok, I see.

  1. Maybe move that function into its own file, as a utility class with a static method in it?
  2. Is it possible to shoehorn a test case into one of the integration test cases, to verify that permissions etc are correct?
  3. Looks like the Travis build is failing :-/

eirslett avatar Nov 11 '17 19:11 eirslett

Shouldn't be a problem to add a test, and I'll move it to it's own file. I should be able to get to that early this week.

marcajimenez avatar Nov 13 '17 14:11 marcajimenez

I've also run into this issue. I am unable to run jest tests with Node 8.9.3 and npm 5.5.1.

[INFO] > [email protected] basicTests /Users/thombaynes/Projects/Development/design/target/test-classes [INFO] > jest --config=./config/basicConfig.json --forceExit; exit 0 [INFO] [ERROR] sh: /Users/thombaynes/Projects/Development/design/target/test-classes/node_modules/.bin/jest: Permission denied

thombaynes avatar Dec 13 '17 23:12 thombaynes

Is there anything preventing this PR to be merged? I've come across this issue as well, and I'm happy to help if needed.

rjimgal avatar May 08 '18 11:05 rjimgal