Giter Site home page Giter Site logo

Comments (23)

bestander avatar bestander commented on June 10, 2024

You need to change cwd parameter on the third line.
Make it cwd: 'assets/dist'

from gulp-deploy-azure-cdn.

shaneprice avatar shaneprice commented on June 10, 2024

Still didnt work with the change, Sorry very new to gulp, do I need anything extra to use cwd or is it part of core gulp package?

from gulp-deploy-azure-cdn.

bestander avatar bestander commented on June 10, 2024

No worries, I'll help you out.

The way it resolves the path is done at node_modules/gulp-deploy-azure-cdn/node_modules/deploy-azure-cdn/src/deploy-task.js line 180-181.

Add a this code:

console.log(relativePath, destFileName)

To line 182 and run the task.
It should tell us enough what went wrong.

from gulp-deploy-azure-cdn.

shaneprice avatar shaneprice commented on June 10, 2024

Thanks Konstantin,
The output is

asserts\dist\all.js asserts\dist\all.js

from gulp-deploy-azure-cdn.

bestander avatar bestander commented on June 10, 2024

I just noticed that folder name is asserts, not assets.
Did you try cwd: 'asserts/dist'?

from gulp-deploy-azure-cdn.

bestander avatar bestander commented on June 10, 2024

I expect relativePath to be all.js if cwd is correct

from gulp-deploy-azure-cdn.

shaneprice avatar shaneprice commented on June 10, 2024

opps typo in my code. But yes cwd: was pointing to asserts
I have since corrected my typo. It seems the cwd isn't being picked up

from gulp-deploy-azure-cdn.

bestander avatar bestander commented on June 10, 2024

Could you add another console.log at line 183, please.

console.log(file.cwd, file.path)

from gulp-deploy-azure-cdn.

shaneprice avatar shaneprice commented on June 10, 2024

E:@source\longpath E:@source\longpath\assets\dist\all.js
A little hard to see but there is a space between the 2

from gulp-deploy-azure-cdn.

bestander avatar bestander commented on June 10, 2024

Ok, so it is Windows, I haven't tested on it.
Looks like CWD parameter replaced with your current directory.
I wonder if you play with CWD parameter a bit, how about: assets\dist or .\assets\dist or assets\dist\ or ./assets/dist.

from gulp-deploy-azure-cdn.

bestander avatar bestander commented on June 10, 2024

wait a minute.

function () {
        cwd: 'node_modules/deploy-azure-cdn'
    })

It should not be a function, just a JSON

gulp.task('upload-azure', function () {
    return gulp.src(['asserts/dist/*.css', 'asserts/dist/*.js'], {
        cwd: 'node_modules/deploy-azure-cdn'
    })

from gulp-deploy-azure-cdn.

shaneprice avatar shaneprice commented on June 10, 2024

Also tried that prior to asking the question.
I have found a dirty hack that works if I apply
destFileName = destFileName.substring(destFileName.lastIndexOf("\\")+1);
to deploy-task it works. I still would be keen to know why the full path is used as the name.

from gulp-deploy-azure-cdn.

bestander avatar bestander commented on June 10, 2024

Did you try my last suggestion?
The options with CWD should not be a function IMO

from gulp-deploy-azure-cdn.

shaneprice avatar shaneprice commented on June 10, 2024

Yes I did try it without the use of a function as I saw that way was used in the grunt version.
I tried with both cwd: 'node_modules/deploy-azure-cdn' and cwd: 'assets\dist'

The console.log locations are not hit when the function is removed. No errors are outputted the console either.
Its hard to debug modules without breakpoints!

from gulp-deploy-azure-cdn.

bestander avatar bestander commented on June 10, 2024

You tell me, @shaneprice, debugging is not native to node.
Webstorm is quite good at it though, it can run node apps, give it a try.
I would really appreciate if you find a fix and do a pull request.

If nothing works for you, you can use https://github.com/bestander/deploy-azure-cdn from your gulp task directly.
It has same API and expects an array of vinyl file objects (with path and cwd properties).

from gulp-deploy-azure-cdn.

shaneprice avatar shaneprice commented on June 10, 2024

I will take another look over the weekend and make a pull request should I find the answer :)

from gulp-deploy-azure-cdn.

plwalters avatar plwalters commented on June 10, 2024

Hey I got here for same reason - the docs have the function in them somewhere. Also the folder: '' option isn't currently documented.

Thanks for this work though, I will PR tomorrow when I have some time.

from gulp-deploy-azure-cdn.

bestander avatar bestander commented on June 10, 2024

@PWKad I would appreciate a PR and any improvements on the docs.

from gulp-deploy-azure-cdn.

JamieBradders avatar JamieBradders commented on June 10, 2024

I'm not sure if this is related but it may be worth a try? I was having a similar issue whereby I was running the task and no errors were returned in the terminal, but no 'upload' messages were returned either. As a result, my assets weren't uploaded to the container on Azure. My code was pretty much identical to the code shared by @shaneprice. After some looking about online, I found a tutorial that uses "deploy-azure-cdn" as oppose to the gulp plugin. In this post (http://www.geekhive.com/buzz/post/2014/9/gulp-js-azure-blob-storage) they have used the path module to get the specific directory that you wish to upload. So we end up with code like this:

First require "path"

var path = require("path");

Then construct the task:

gulp.task("upload-assets-to-azure", function () {
    return gulp.src(["**"], {
        cwd : path.resolve(path.dirname('gulpfile.js'), 'public/assets/')
    }).pipe(deployCdn({
        containerName           : "test-container",
        serviceOptions          : ["test", "XXXX"],
        containerOptions        : { publicAccessLevel : "blob" },
        folder                  : "",
        zip                     : true,
        deleteExistingBlobs     : true,
        concurrentUploadThreads : 10,
        metadata : {
            cacheControl        : "public, max-age=86400",
            cacheControlHeader  : "public, max-age=3000"
        },
        testRun                 : false
    })).on("error", gutil.log);
});

The value of cwd then becomes (in my example) :

/Users/jamie/Development/Spikes/AzureDeployTest/public/assets

Obviously there is a slight difference to @shaneprice example as I am telling Gulp to upload everything from the assets folder (/css, /images etc). Based on these findings, I would be tempted to set your cwd and gulp.src as follows:

cwd : path.resolve(path.dirname('gulpfile.js'), 'asserts/')
gulp.src([dist/*.css', 'dist/*.js']

I've not tested this with your file structure so I may be shooting in the dark here. But using the code I have shared for my file structure, I was able to upload to Azure successfully and the assets are structured exactly as I would like them within the container. Let me know how this goes, would be interested to see if it has worked for you!

from gulp-deploy-azure-cdn.

bestander avatar bestander commented on June 10, 2024

Hey guys, I have just published 2.0.0 version and it uses base parameter of vinyl files and uses an updated deploy-azure-cdn dependency.
I wonder if it fixes the problem for you.

@shaneprice I got my hands on a windows device, I'll give it a try in the next little while.

from gulp-deploy-azure-cdn.

JamieBradders avatar JamieBradders commented on June 10, 2024

Hey @bestander, sorry I don't quite understand the update. I am trying to upload all contents of an "assets" folder within pubic/assets - where public is situated in the root of my project. So I have the following:

    return gulp.src(["**"], {
        base : "public/assets/"
    })

I am clearly misunderstanding something because the the plugin is attempting to upload tones of unwanted stuff from node_modules 😕

Please can you assist?

from gulp-deploy-azure-cdn.

bestander avatar bestander commented on June 10, 2024

Sure.
Full disclosure, I don't completely understand what this base means in gulp.

In your case I would do

return gulp.src(['public/assets/**'], {
  base: 'public'
}).pipe(deployCdn({
    containerName: 'my-comtainer',
    folder: 'path-in-container/'
});

This should deploy all files from public/assets/file1 and public/assets/file2 etc into my-container/path-in-container/assets/file1 my-container/path-in-container/assets/file2.

from gulp-deploy-azure-cdn.

JamieBradders avatar JamieBradders commented on June 10, 2024

Cheers man! I'll take a look, thanks for clearing this up.

from gulp-deploy-azure-cdn.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.