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

gulp-spsync-creds

v2.3.8

Published

Gulp plugin that syncs with a library in SharePoint Online and on-premises

Downloads

911

Readme

gulp-spsync-creds

Gulp plugin for synchronizing local files with a SharePoint library

NPM

This Gulp plugin is based on gulp-spsync which has been created by Wictor Wilen. The difference with gulp-spsync is that this plugin makes use for client credentials (username and password) in order to upload and/or download files. This makes the plugin usable for both SharePoint Online and on-premises environments.

Installation

Run the following command to install the gulp-spsync-creds plugin:

$ npm install gulp-spsync-creds

Usage

Uploading files

For uploading files, you can add the following code to your gulpfile.js:

var gulp = require('gulp');
var spsync = require('gulp-spsync-creds').sync;

gulp.src('./src/**/*')
.pipe(spsync({
    "username": "<username>",
    "password": "<password>",
    "site": "<site-url>",
}));

Downloading files

For downloading files, you can add the following code to your gulpfile.js:

var gulp = require('gulp');
var spdwn = require('gulp-spsync-creds').download;

spdwn({
    "site": "<site-url>",
    "username": "<username>",
    "password": "<password>",
    "startFolder": "<relative-folder-location>"
}).pipe(gulp.dest("src"));

Information: it currently retrieves all files of the given path and the ones of three folders deep.

Options

The plugin has the following options that can be configured:

username

Type: String Default: null

Sets the username to be used for the sync action.

password

Type: String Default: null

Sets the password to be used for the sync action.

site

Type: String Default: ""

Sets the site URL to where the files should be uploaded.

startFolder

Type: String Default: ""

Choose the name of the folder location it has to starts from. This is useful when you have a nested folder structure. Example: if your folder structure is like this src/template1/_sp/_catalogs, and you set the startFolder option to _sp, it will strip out all the folder names before including _sp. You end up with _catalogs.

Important: this property can also be used to specify the location from where you want to download files.

libraryPath New property - v2.3.0

Type: string Default: ""

The libraryPath property can be used if you want to define a default library path to where you want to upload your files.

By default the plugin uploads the files based on their file location (under your source folder).

src
|_ _catalogs
   |_ masterpage
      |_ your-folder
         |_ file1.html

So in the above case, file1.html will be uploaded to the master page gallery (_catalogs/masterpage) in a your-folder folder.

When you define the libaryPath to for example: documents. The plugin will upload the files to that specific document library with the folder structure. So in this case it will be documents/_catalogs/masterpage/your-folder/file1.html.

update_metadata

Type: Boolean Default: false

Specify if you want to update the metadata of files you are uploading. If this is set to true, you will have to pass the file metadata via the files_metadata option.

files_metadata

Type: Object Default: []

With the files_metadata option you can specify the metadata of all the files you wish to upload. Example:

"fileMetadata": [
    {
        "name": "Item_Minimal.js",
        "metadata": {
            "__metadata": {
                "type": "SP.Data.OData__x005f_catalogs_x002f_masterpageItem"
            },
            "Title": "Item Minimal Template (via GULP)",
            "MasterPageDescription": "This is a display template added via gulp.",
            "ManagedPropertyMapping": "'Path','Title':'Title'",
            "ContentTypeId": "0x0101002039C03B61C64EC4A04F5361F38510660500A0383064C59087438E649B7323C95AF6",
            "DisplayTemplateLevel": "Item",
            "TemplateHidden": false,
            "TargetControlType": {
                "__metadata": {
                "type": "Collection(Edm.String)"
                },
                "results": [
                "SearchResults",
                "Content Web Parts"
                ]
            }
        }
    },
    {
        "name": "Control_Minimal.js",
            "metadata": {
            "__metadata": {
                "type": "SP.Data.OData__x005f_catalogs_x002f_masterpageItem"
            },
            "Title": "Control Minimal Template (via GULP)",
            "MasterPageDescription": "This is a display template added via gulp.",
            "ContentTypeId": "0x0101002039C03B61C64EC4A04F5361F38510660500A0383064C59087438E649B7323C95AF6",
            "DisplayTemplateLevel": "Control",
            "TemplateHidden": false,
            "TargetControlType": {
                "__metadata": {
                "type": "Collection(Edm.String)"
                },
                "results": [
                "SearchResults",
                "Content Web Parts"
                ]
            }
        }
    }
]

publish

Type: Boolean Default: false

With this option you can specify if you want to publish files after they are uploaded.

cache

Type: Boolean Default: false

If set to true the plugin caches library locations that already have been processed. Makes the watch tasks quicker.

associatedHtml (only for download actions)

Type: Boolean Default: true

With this property you can specify if you want to download all files (by default set to true) from a folder. This will also download the files that are associated to an HTML template like a page layout, master page and display template. If you set this property to false, the plugin only downloads the HTML files and leaves the ".aspx", ".master" and ".js" files in the folder.

verbose

Type: Boolean Default: false

If you wish to see all the plugin logging you can set this to true.