LeoPlatform / cli

MIT License
2 stars 13 forks source link

leo-cli publish gives invalid file permissions #44

Open anztenney opened 5 years ago

anztenney commented 5 years ago

When I run leo-cli publish on a linux machine, it is returning with an error code and message:


From /tmp/poc-1.0.0 to s3://leo-cli-publishbucket-.../poc/1.0.0/
--
12-Dec-2018 14:21:09 | Switching AWS Profile default
12-Dec-2018 14:21:10 | warning: Skipping file /tmp/poc-1.0.0/poc-1544644301049.js. File/Directory is not readable.
12-Dec-2018 14:21:10 |  
12-Dec-2018 14:21:17 | Error: Error publishing files
12-Dec-2018 14:21:17 | at ChildProcess.upload.on (/usr/local/bamboo/.nvm/versions/node/v8.9.1/lib/node_modules/leo-cli/lib/build.js:539:13)
12-Dec-2018 14:21:17 | at emitTwo (events.js:126:13)
12-Dec-2018 14:21:17 | at ChildProcess.emit (events.js:214:7)
12-Dec-2018 14:21:17 | at maybeClose (internal/child_process.js:925:16)
12-Dec-2018 14:21:17 | at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)

When I run the same command from my Windows machine, it runs without issue.

I'm using leo-cli 2.5.2 and running on Linux:


Linux hostname 3.10.0-862.11.6.el7.x86_64 #1 SMP Tue Aug 14 21:49:04 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

LSB Version:    :core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch
Distributor ID: CentOS
Description:    CentOS Linux release 7.5.1804 (Core)
Release:        7.5.1804
Codename:       Core```
anztenney commented 5 years ago

I made a couple of changes to leo-cli\lib\build.js to get this working:

Inside of publish I added the following:

                let args = ['s3', opts.command || 'sync', rootDir, `${remoteDir}`];
                if (opts.public) {
                        args.push("--grants", "read=uri=http://acs.amazonaws.com/groups/global/AllUsers");
                }
/*********************code added below**********************************/
                if (fs.lstatSync(`${rootDir}`).isDirectory()) {
                  var files = fs.readdirSync(`${rootDir}`);
                  for (var i = 0, len = files.length; i < len; i++) {
                    var match = files[i].match(/.*-index-.*\.js/);
                    if(match !== null){
                      fs.unlinkSync(`${rootDir}/${match[0]}`);
                      console.log(console.log(`Deleted ${match[0]}`));
                    }
                  }
                }

And in buildLambdaDirectory I changed .pipe(gulp.dest(${opts.dir}/)).on("end", () => { to .pipe(gulp.dest(${opts.dir}/, {"mode": "0655"})).on("end", () => {

Not sure if this is something I should create a PR on, but it got me unblocked for now.