jpillora / grunt-aws

A Grunt interface into the Amazon Node.JS SDK
171 stars 44 forks source link

Files not uploading (similar to issue #28) #30

Closed nicelemon closed 8 years ago

nicelemon commented 9 years ago

Similar problem to issue #28; however, suggested fix isn't resolving the problem. I'm referencing the 'prod' directory, which contains my build as the cwd:

module.exports = function(grunt) {

    grunt.loadNpmTasks('grunt-aws');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-copy');

    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        aws: grunt.file.readJSON("aws-credentials.json"),

        s3: {
            options: {
                accessKeyId: "<%= aws.accessKeyId %>",
                secretAccessKey: "<%= aws.secretAccessKey %>",
                bucket: "<%= aws.bucket %>",
                region: "<%= aws.region %>",
                access: "public-read"
            },
            upload: {
                headers: {
                    CacheControl: 604800,
                    Expires: new Date(Date.now() + 604800000).toUTCString()
                },
                cwd: "prod/",
                src: "**"
            }
        },

        cloudfront: {
            options: {
                accessKeyId: "<%= aws.accessKeyId %>",
                secretAccessKey: "<%= aws.secretAccessKey %>",
                distributionId: "EGPU172BPH6RM",
                invalidations: [
                    "/index.html",
                    "/css/osis.css",
                    "/js/osis.js",
                    "/js/osis-fullpage-controls.js"
                ]
            }
        },

        copy: {
            main: {
                expand: true,
                cwd: 'dev/',
                src: '**',
                dest: 'prod/',
            },
        },

        uglify: {
            dist: {
                files: {
                    'build/<%= pkg.name %>.min.js': ['<%= concat.dist.dest %>']
                }
            }
        }

    });

    grunt.registerTask('default', ['copy']);
    grunt.registerTask('s3', ['s3']);
    grunt.registerTask('uglify', ['uglify']);
};

And here's the output of grunt s3 -v:

user$ grunt s3 -v Initializing Command-line options: --verbose

Reading "Gruntfile.js" Gruntfile...OK

Registering Gruntfile tasks.

Registering "grunt-aws" local Npm module tasks. Reading /Users/user/Sites/osis.dev/node_modules/grunt-aws/package.json...OK Parsing /Users/user/Sites/osis.dev/node_modules/grunt-aws/package.json...OK

Registering "/Users/user/Sites/osis.dev/node_modules/grunt-aws/tasks/services" tasks. Loading "cloudfront.js" tasks...OK

  • cloudfront Loading "route53.js" tasks...OK
  • route53 Loading "s3.js" tasks...OK
  • s3 Loading "aws.js" tasks...OK

    No tasks were registered or unregistered. Loading "cache-mgr.js" tasks...OK No tasks were registered or unregistered.

Registering "grunt-contrib-uglify" local Npm module tasks. Reading /Users/user/Sites/osis.dev/node_modules/grunt-contrib-uglify/package.json...OK Parsing /Users/user/Sites/osis.dev/node_modules/grunt-contrib-uglify/package.json...OK Loading "uglify.js" tasks...OK

  • uglify

Registering "grunt-contrib-copy" local Npm module tasks. Reading /Users/user/Sites/osis.dev/node_modules/grunt-contrib-copy/package.json...OK Parsing /Users/user/Sites/osis.dev/node_modules/grunt-contrib-copy/package.json...OK Loading "copy.js" tasks...OK

  • copy Reading package.json...OK Parsing package.json...OK Reading aws-credentials.json...OK Parsing aws-credentials.json...OK Initializing config...OK Loading "Gruntfile.js" tasks...OK
  • default, s3, uglify

Running tasks: s3

Running "s3" task

Running "s3" task

Running "s3" task ...

The line "Running 's3' task" continues ad-infinitum. Any help would be greatly appreciated!

nring commented 9 years ago

Seeing this same behavior. Would grunt-aws print an error if there was a credential or permission problem?

nring commented 9 years ago

So the issue was naming the same task name: grunt.registerTask('s3', ['s3']);

It will work fine if you change this to something like grunt.registerTask('s3task', ['s3']);