npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

konstantinast-fork-gulp-webdav-sync

v1.0.2

Published

(Temporary fork with a fix) Put files and folders on a WebDAV server. Deploy with gulp

Downloads

7

Readme

gulp-webdav-sync

Put files and folders to a WebDAV server. Deploy with gulp.

Targeting

Pass a URL argument indicating a directory/collection on a WebDAV server. Include any HTTP Basic authentication inline. HTTPS authentication must go in the options argument.

URL as String

var webdav = require( 'gulp-webdav-sync' )

// put index.js to http://localhost:8000/js/index.js
gulp.task( 'deploy', function () {
  return gulp.src( 'index.js' )
    .pipe( webdav( 'http://localhost:8000/js/' ) )
} )

URL as Object

Extend a URL object.

var webdav = require( 'gulp-webdav-sync' )

// put index.js to http://localhost:8000/js/index.js
// show status codes
// show credentials in urls
gulp.task( 'deploy', function () {
  var options = {
      protocol: 'http:'
    , auth: 'user:pass'
    , hostname: 'localhost'
    , port: 8000
    , pathname: '/js/'
    , log: 'info'
    , logAuth: true
  }
  return gulp.src( 'index.js' )
    .pipe( webdav( options ) )
} )

Subdirectories

Suppose the following directory tree,

  • project/
    • dist/
      • css/
      • images/
      • js/

and this target,

  • localhost:8000/
    • css/
    • images/
    • js/

use the 'base' option to constrain the localpath mapping,

var webdav = require( 'gulp-webdav-sync' )

gulp.task( 'deploy', function () {
  var options = {
      'base': 'dist'
    , 'log': 'info'
    , 'port': 8000
  }
  return gulp.src( 'dist/**' )
    .pipe( webdav( options ) )
} )

otherwise, the result is this.

  • localhost:8000/
    • dist/
      • css/
      • images/
      • js/

Continuous Deploying: Creates, Updates, Deletes

By combining methods, most cases can be satisfied, however deleting directories may be inconsistent. If any file changes or there is a creation in the path, then gulp.watch will re-stream all files. The uselastmodified option ( default ) compares the local time to the server time so as to only upload updates. Deletes emit a different object; not in the stream, but with a change event.

With gulp.watch

browser-sync, npmconf, and .npmrc for a save-sync-reload solution.

npm set dav http://user:pass@localhost:8000/js/
var browserSync = require( 'browser-sync' ).create()
var webdav = require( 'gulp-webdav-sync' )
var npmconf = require( 'npmconf' )
var paths = {
  'js': [ '*.js', '!gulpfile.js' ]
}
var href
var options = {
  'log': 'info'
}

gulp.task( 'default', [ 'deploy' ], function () {
  browserSync.init( { proxy: href } )
  gulp.watch( paths.js, [ 'deploy' ] )
    .on( 'change', webdav( href, options ).watch )
    .on( 'change', browserSync.reload )
} )

gulp.task( 'deploy', [ 'load-npmrc' ], function () {
  return gulp.src( paths.js )
    .pipe( webdav( href, options ) )
} )

gulp.task( 'load-npmrc', function ( cb ) {
  npmconf.load( null, function() {
    if ( npmconf.loaded.sources.user ) {
      href = npmconf.loaded.sources.user.data.dav
    }
    cb()
  } )
} )

With gulp-watch

gulp-watch uses a different strategy of extending the file objects in stream. It re-emits created, modified, and deleted files. Delete/'unlink' type events are attempted on the server as well.

var watch = require( 'gulp-watch' )
var webdav = require( 'gulp-webdav-sync' )
var paths = {
  'js': [ '*.js', '!gulpfile.js' ]
}
var href = 'http://localhost'

gulp.task( 'deploy', function () {
  return gulp.src( paths.js )
    .pipe( watch( paths.js ) )
    .pipe( webdav( href ) )
} )

API

webdav( [ href ] [, options ] )

Target is a URL-type parameter whereto files are uploaded. It must specify a directory ( also known as a "collection" ). At a minimum this must be DAV root, but subdirectories may be included ( e.g. project name ). Part-wise definition across multiple arguments is undefined. Use the http: or https: scheme, not dav:.

webdav( [ href ] [, options ] ).clean( [ cb ] )

Deletes all resources under href.

webdav( [ href ] [, options ] ).watch( event [, cb ] )

Callback adapter for 'change' events from gulp.watch. Only handles type: 'deleted' events. gulp.src does not push deleted files; use this or gulp-watch instead. Calls back regardless of event.type.

cb

Optional, asynchronous, callback function.

Type: Function Default: undefined

event

glob-watcher event.

{
    type: 'deleted'
  , path: '/absolute/path.ext'
}

Type: Object Default: undefined

href

Type: String Default: undefined

options

Superset of http.request options parameter, https.request options parameter, and url.object. If any URL properties are defined, then protocol, hostname, and pathname are assigned to http://localhost/. If options.agent is undefined, then a http[s] agent will be created for the stream.

Type: Object Default:

{
    'clean': false
  , 'headers': { 'User-Agent': PLUGIN_NAME + '/' + VERSION }
  , 'log': 'error'
  , 'logAuth': false
  , 'base': process.cwd()
  , 'uselastmodified': 1000
}
options.base

Relative or absolute path which halves the source path [vinyl.path] for appending the subsequent to the DAV target URI. Use with glob ** to prevent super-directories from being created on the target. e.g. gulp.src( 'dist/**' ).

Type: String Default: process.cwd()

options.clean

Deletes corresponding resources on server instead of uploading. Note, glob star-star will delete directories before contents are pushed.

Type: Boolean Default: false

options.log

Logging threshold. Orthogonal to the console methods.

string | output :-------: | -------------- 'error' | 'warn' | 'info' | HTTP Responses 'log' | Debug

Type: String Default: 'error'

options.logAuth

Display credentials in logged URLs.

Type: Boolean Default: false

options.uselastmodified

Compare remote getlastmodified versus local ( changed ) ctime. Only PUT if ctime is newer than getlastmodified. Numeric value in milliseconds is the tolerance interval for qualifying client-server synchronization. Set to false to disable.

Type: Number Default: 1000 ms

Development

cd gulp-webdav-sync
npm install
pushd test/assets
./rekey.sh
popd
npm test
npm set dav http://user:pass@localhost:8000/
gulp