Code Monkey home page Code Monkey logo

gulp-spsave's Introduction

Hi there ๐Ÿ‘‹

Twitter Follow Linkedin: Sergei Sergeev

My name is Sergei.

I'm Microsoft MVP (M365 Development) working mostly as a developer and consultant with Microsoft 365 technology stack. Over 10 years of experience in the industry.
When I have free time, I contribute to my own or community GitHub projects.

You can find the list of my most interesting projects pinned below.

Skills

  • JavaScript/TypeScript
  • C#, Azure, NodeJS
  • SharePoint
  • Power Automate
  • Anything necessary to get things done

Recent blog posts

Github profile stats

Sergei's GitHub stats

gulp-spsave's People

Contributors

lhoff avatar s-kainet avatar viktorhofer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gulp-spsave's Issues

File getting uploaded succesfully but getting error in output Task Runner Window

File is getting uploaded successfully but getting error in Output Task runner window.
Error:

[16:06:17] Using gulpfile ~\documents\visual studio 2013\Projects\GulpTask\gulpfile.js
[16:06:17] Starting 'concat-js'...
[16:06:17] Finished 'concat-js' after 8.81 ms
[16:06:17] Starting 'minify-js'...
[16:06:17] Finished 'minify-js' after 5.21 ms
[16:06:17] Starting 'upload-to-sp'...
[16:06:17] Finished 'upload-to-sp' after 3.29 ms
[16:06:20] spsave: GulpDemo.js checked out.
[16:06:20] spsave: GulpDemo.js successfully uploaded to '<>/TestDocLib' and checked in. Checkin type: minor
[16:06:20] spsave: Error occured:
[16:06:20] spsave: Error: Argument error, options.body.

[16:06:20] spsave: Stack trace:

[16:06:20] spsave: RequestError: Error: Argument error, options.body.
    at new RequestError (<PATH>\node_modules\gulp-spsave\node_modules\spsave\node_modules\sp-request\node_modules\request-promise\lib\errors.js:14:15)
    at Request.RP$callback [as _callback] (<PATH>\node_modules\gulp-spsave\node_modules\spsave\node_modules\sp-request\node_modules\request-promise\lib\rp.js:60:25)
    at self.callback (<PATH>\node_modules\gulp-spsave\node_modules\spsave\node_modules\sp-request\node_modules\request\request.js:200:22)
    at emitOne (events.js:77:13)
    at Request.emit (events.js:169:7)
    at setContentLength (<PATH>\node_modules\gulp-spsave\node_modules\spsave\node_modules\sp-request\node_modules\request\request.js:452:14)
    at Request.init (<PATH>\node_modules\gulp-spsave\node_modules\spsave\node_modules\sp-request\node_modules\request\request.js:457:5)
    at Request.RP$initInterceptor [as init] (<PATH>\node_modules\gulp-spsave\node_modules\spsave\node_modules\sp-request\node_modules\request-promise\lib\rp.js:137:25)

Code:

gulp.task('upload-to-sp', ['minify-js'], function () {
    gulp.src("./Output/*.js")
      .pipe(spsave({
          username: "<UNAME>",
          password: "<PASSWORD>",
          siteUrl: "<URL>",
          folder: "<FOLDER>",
          checkin: true
      }));
});

Note:
This issue happens randomly. And occurs during successive builds. For first build, it uploads successfully. During successive builds, it randomly generates this error and file remains checked-out upon process termination.

If I delete the file again and re-build, it successfully uploads.

Issue with psave

Hello team,

I tried to use your module to upload files on sharepoint but I have strange errors:

My code:
image

My error:
image

Versions:
Node: v15.12.0
NPM: 7.6.3
spsave: 4.0.2

Any ideas?

Thanks for your help!

title: `spsave: ${fileName}: error occured`

Getting Below error while loading gulp-spsave plugin. Please not that I am not calling any function yet. Just adding dependency using

var spsave = require('gulp-spsave');

Below is the full error description:

`Failed to load "\gulpfile.js"...

\node_modules\gulp-spsave\index.js:53
title: spsave: ${fileName}: error occured,
^
SyntaxError: Unexpected token ILLEGAL
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object. (\documents\visual studio 2013\Projects\GulpTask\gulpfile.js:9:14)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
`

Let me know if more details are required.

EDIT: Uploading entire code for reference
`///
//Load gulp
var gulp = require('gulp');

//Load gulp plugins
var concat = require('gulp-concat'); //bundle
var uglify = require('gulp-uglify'); //minify
var rename = require('gulp-rename'); //renaming to min
var spsave = require('gulp-spsave'); //upload to SharePoint

//Bundle JS files together into a single file
gulp.task('concat-js', function () {
gulp.src("./Scripts/*/.js")
.pipe(concat("GulpDemo.js"))
.pipe(gulp.dest("./Output"))
});

//Minify the GulpDemo.js file. This task has a dependency on concat-js which means concat-js will always run before minify-js
gulp.task('minify-js', ['concat-js'], function () {
gulp.src("./Output/GulpDemo.js")
.pipe(uglify())
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest("./Output"))
});

//Upload GulpDemo.js and GulpDemo.min.js files to SharePoint. This task has a dependency on minify-js which means minify-js will always run before upload-to-sp
/*
gulp.task('upload-to-sp', ['minify-js'], function () {
gulp.src("./Output/.js")
.pipe(spsave({
username: "",
password: "",
siteUrl: "URL",
folder: "Style Library/Test",
checkin: true
}));
});
*/
//Watcher task. This will watch for any changes in the scenario1.js and scenario2.js files and then run the upload-to-sp task.
gulp.task('watch-js-upload-to-sp', function () {
gulp.watch("./Scripts/__/
.js", ['upload-to-sp']);
});`

Note: Please note that spsavefunction is commented right now. But just adding dependency produces error.

Upload master page to multiple site collections

My intention is to have one MasterPage, that can be published to mutilple site collections. I have the site collection details in the site settings file.

module.exports = {    
    sitecollections : [
    {        
        'url': 'sc1'
    },
    {        
        'url': 'sc2'     
    },
    {        
        'url': 'sc3'     
    }
    ]
}

To iterate through these site collections I am using event-stream, so my task runs the following code:

var streams = siteSettings.sitecollections.map(uploadToSiteCollection); return es.merge(streams);

The code above runs the function:

var creds = require("./config/creds.js");
var siteSettings = require("./config/sitesettings.js");

gulp.task('publishToSharePoint', function () {
    // build the streams
    var streams = siteSettings.sitecollections.map(uploadToEachSiteCollection);

    return es.merge(streams);
});

function uploadToEachSiteCollection(siteCollectionUrl) {
    var url = "http://xxx/poc/" + siteCollectionUrl.url

    return gulp.src("build/template/masterpage/ExampleMasterPage.html")
        .pipe(spsave({
            siteUrl: url,
            folder: "_catalogs/masterpage",
            checkin: true,
            checkinType: 1, //Major
            checkinMessage: "Checked in by automated Gulp process",            
            filesMetaData: [{
                fileName: "ExampleMasterPage.html",
                metadata: {
                    "__metadata": { type: "SP.Data.OData__x005f_catalogs_x002f_masterpageItem" },
                    HtmlDesignAssociated: "true",
                    ContentTypeId: "0x0101000F1C8B9E0EB4BE489F09807B2C53288F0054AD6EF48B9F7B45A142F8173F171BD10003D357F861E29844953D5CAA1D4D8A3A"
                }
            }]
        }, creds));
};

My issue is when this runs, it doesn't create the .master file for every site collection - usually 1, sometimes 2. I get the impression spsave can only execute one site collection at a time. This is proven when I hard code each site collection URL into its own gulp task, then use runSequence to run through them individually. This isnt a problem if I am just uploading webparts etc.

Missing Parameter error message

Thanks for sharing this cool project.

I am getting missing parameter and not sure why? Looked through a lot of examples and still not sure which one I am missing? I am using SharePoint on Premise 2013

Config:

//Load gulp
var gulp = require('gulp');

//Load gulp plugins
var concat = require('gulp-concat'); //bundle
var uglify = require('gulp-uglify'); //minify
var rename = require('gulp-rename'); //renaming to min
var spsave = require('gulp-spsave'); //upload to SharePoin
var fs = require('fs');

var config = JSON.parse(fs.readFileSync('SharePoint.Assets.GulpDemo/settings.json'));

var $ = require('gulp-load-plugins')({lazy: true});

//Bundle JS files together into a single file
gulp.task('concat-js', function () {
gulp.src("./Scripts/*/.js")
.pipe(concat("GulpDemo.js"))
.pipe(gulp.dest("./Output"))
});

//Minify the GulpDemo.js file. This task has a dependency on concat-js which means concat-js will always run before minify-js
gulp.task('minify-js', ['concat-js'], function () {
gulp.src("./Output/GulpDemo.js")
.pipe(uglify())
.pipe(rename({ suffix: '.min'}))
.pipe(gulp.dest("./Output"))
});

//Upload GulpDemo.js and GulpDemo.min. jsfile. This task has a dependency on minify-js which means minify-js will always run before upload-to-sp
gulp.task('upload-to-sp', function () {
gulp.src("./Output/*.js")
.pipe($.debug())
.pipe($.spsave({
username: config.username,
password: config.password,
domain: config.domain,
siteUrl: 'https://anysites.com',
folder: "SiteAssets",
flatten: false,
notification: true
}));
});

//Watcher task. This will watch for any changes in the scenario1.js and scenario2.js files and then run the upload-to-sp task.
gulp.task('watch-js-upload-to-sp', function () {
gulp.watch("./Scripts/*/.js", ['upload-to-sp']);
});

gulp.task('default', ['concat-js','minify-js','upload-to-sp']);

Here is the message that I am getting:

6c4008b152f4:SharePoint.Assets.GulpDemo z001h4c$ history -cw
6c4008b152f4:SharePoint.Assets.GulpDemo z001h4c$ gulp upload-to-sp
[10:59:17] Using gulpfile ~SharePoint.Assets.GulpDemo/gulpfile.js
[10:59:17] Starting 'upload-to-sp'...
[10:59:17] 'upload-to-sp' errored after 23 ms
[10:59:17] Error in plugin 'gulp-spsave'
Message:
Missing parameters
[10:59:17] gulp-debug: Output/GulpDemo.js
[10:59:17] gulp-debug: Output/GulpDemo.min.js
[10:59:17] gulp-debug: 2 items
6c4008b152f4:SharePoint.Assets.GulpDemo$

@Known Issues: Watchers and gulp-spsave bug out

I know that this is a known issue, but I was wondering on how to handle this use case. I have a watcher that basically watches a folder that represents the local Style Library of a site collection. I have a npm task that builds my sources which creates a few files (about 10). gulp-spsave checksout all the files, even uploads them, I think, but then crashes saying that the file is checkout by my user, leaving behind checked-out files that probably aren't even in the updated state. I then have to reupload the files by hand and check the files in again...

Also, maybe related: If the watcher is running fine, and I build any file, spsave often says "File content is empty...", although it isnt. I then have to build the file again for spsave to pick up the changes. Is there a fix to this?

I can't post the full gulpfile example (using gulp 4.0), but I'll post some of it, maybe it helps:

var source = '/Style Library';
var site = '/sites/mysite';

gulp.task('dev', done => {
  var watcher = gulp.watch('.' + source + '/**/*');
  watcher.on('change', function (file) {
    // destination is the folder where to put the files on sharepoint
    uploadToSP(file, source, site, destination);
  });
});

function uploadToSP (file, source, site, destination = 'Style Library') {
  return gulp.src(file, { source })
    .pipe(spsave({
      siteUrl: server + site,
      folder: destination,
      checkin: true,
      checkinType: 1,
      flatten: false
    }, credentials));
}

How to access SharePoint Online from gulp-spsave

Hi,
I am using gulp-spsave to deploy my js bundle into SharePoint. It works find in on-premise. But when I tried to upload my bundle into SharePoint online it gives me following error.

Error: getaddrinfo ENOTFOUND login.microsoftonline.com login.microsoftonline.com:443

Does gulp-spsave supports SharePoint online?

Saving to app web

I'm not sure what the options need to be if I'm saying to the app web. I've provided siteUrl, username, password but I don't know the folder structure of the app web site and where files are pushed to in VS.

This is what I'm doing right now:

gulp.task('pack', function() {
  return gulp.src(['/app/loader.js'])
  .pipe(webpack( require('./webpack.config.js') ))
  // .pipe(gulp.dest('./'))
  .pipe(gulp.dest(target))
  .pipe($.spsave({
    siteUrl: settings.siteUrl,
    username: settings.username,
    password: settings.password
  }))
})

I'm using webpack to bundle everything then I'd like to push it the app web. I'm getting an error saying

[21:57:42] Error in plugin 'gulp-spsave'
Message:
Folder option is empty. Either provide folder explicitly, or specify "base" option

I tried base but it just creates a folder called base so I doubt my app is using the files there.

Recursive folder file upload failed when using gulp spsave

Here i include the code for help.

var gulp = require('gulp');
var spsave = require('gulp-spsave');
var path = require('path');
require('dotenv').load();
const ENV_PATH = path.join(process.env.HOME + "/.env");
require("dotenv").config({ path: ENV_PATH });
var args = require('yargs').argv;
const rp = require("request-promise");
const { SPPurge, Delete } = require('sppurge');
const spauth = require('node-sp-auth');
var folderPath = args.folderPath ? args.folderPath : null;
var siteUrl = args.siteUrl ? args.siteUrl : null;
var sharepointFolder = args.sharepointFolder ? args.sharepointFolder.trim() : null;
var creds = {
clientId: process.env.CLIENT_ID,
clientSecret: process.env.CLIENT_SECRET
};
gulp.task('upload', function () {
console.log("");
console.log("This upload process may take some time to complete.");
console.log("
");
if (folderPath && siteUrl && sharepointFolder) {
const resultList = sharepointFolder.split('/');
console.log(resultList)
if (resultList.length && resultList.length > 1 && resultList[1] !== "") {
//get auth options
return spauth.getAuth(siteUrl, {
clientId: process.env.CLIENT_ID,
clientSecret: process.env.CLIENT_SECRET,
realm: process.env.TENANT_ID
})
.then(options => {
console.log("options: ", options);
//perform request with any http-enabled library (request-promise in a sample below):
let headers = options.headers;
headers['Accept'] = 'application/json;odata=verbose';
return rp.get({
url: siteUrl + /_api/web/GetFolderByServerRelativeUrl('${sharepointFolder}'),
headers: headers
}).then(response => {
console.log("response: ", response);
if (JSON.parse(response).d.Exists) {
const authContext = {
siteUrl: siteUrl,
creds: {
clientId: process.env.CLIENT_ID,
clientSecret: process.env.CLIENT_SECRET,
realm: process.env.TENANT_ID
}
};
let sppurge = new Delete();
const relativeUrl = ${sharepointFolder};
return sppurge.deleteFolder(authContext, relativeUrl)
.then(_ => {
console.log('Folder has been deleted ....');
// runs the spsave gulp command on only files the have
return gulp.src(folderPath + '//')
.pipe(spsave({
siteUrl: siteUrl,
notification: true,
folder: sharepointFolder,
flatten: false
}, creds));
})
.catch(error => {
console.log(Error: ${error.message});
});
} else {
console.log("save: ............");
return gulp.src(folderPath + '//')
.pipe(spsave({
siteUrl: siteUrl,
notification: true,
folder: sharepointFolder,
flatten: false
}, creds));
}
})
.catch(error => {
console.log("save2: ............");
return gulp.src(folderPath + '//')
.pipe(spsave({
siteUrl: siteUrl,
notification: true,
folder: sharepointFolder,
flatten: false
}, creds));
});
});
} else {
console.warn("Parent Folder cannot be deleted !");
}
} else {
console.warn("Local Folder Path and SharePoint Site Url and SharePoint Folder are Required \n eg: gulp upload --folderPath '/disk1/operations-work/exports' --siteUrl 'https://test.sharepoint.com/sites/E1/' --sharepointFolder 'Shared Documents'");
}
});

Upgrade to latest spave?

Hi Sergei,

do you plan to upgrade the module to the latest spave? I still like using this module in my dev environment, but it's quite outdated in respect to "node-sp-auth". This yields to more and more problems with on-demand authentication and electron (e.g. s-KaiNet/node-sp-auth#79).

I would appreciate a short answer on the future of this module.

Best regards
Tobias

SPSave not pushing all files in folder structure

SPSave is not pushing all files in folder. I have this folder structure:

js/
 file.js
 file2.js
 forms/
  form1.js
  form2.js
// PROCESS JS FILES
gulp.task("js", () => {
    let stream = gulp
        .src(["./src/**/*.js", "!./src/**/loader.js"])
        .pipe($.plumber())
        .pipe($.changed("temp/" + args.env))
        .pipe($.preprocess(preprocessConfig));

    // Don't babel dev
    if (!isDev || args.babel) stream = stream.pipe(babel());

    // minify is min arguement provided
    if (args.min) stream = stream.pipe($.uglify());

    // Update SharePoint
    if ((isDev || isQA) && args.push) {
        stream.pipe(
            $.spsave(
                {
                    siteUrl: ENV.domain + ENV.path,
                    folder: ENV.library + ENV.environment,
                    flatten: false
                },
                getCredentials()
            )
        );
    }

    stream.pipe(gulp.dest("temp/" + args.env));
});

Every time I run it, it gets maybe half the files in /forms and always stop at the same file. No errors.

gulp-spsave uploading only 16 files

Hi,

I am using "gulp-spsave" to automate uploading files to asset site. I am having files around 200 + including js, css , image and font files. I observed that, its uploading only 16 files. Is there any limit on the file count.

Error: certificate not trusted when running

c:\MyStuff\github\oap\OAP>gulp spsave
[16:03:03] Using gulpfile c:\MyStuff\github\oap\OAP\gulpfile.j
[16:03:03] Starting 'spsave'...
Error: certificate not trusted
{ [Error: certificate not trusted] code: 'CERT_UNTRUSTED' }
[16:03:03] 'spsave' errored after 69 ms
[16:03:03] Error in plugin 'gulp-spsave'
Message:
certificate not trusted

gulp4 base --> glob

Hey I just found a little bug with maybe gulp4. If flatten is set to false the path cannot be resolved.

gulp4-spsave

Error in SPSave on Node 17.2.0

Just installed Node 17.2.0 and receive the following error. I was running Node10x without any problems. This was working before the upgrade.

'uploadToSharePoint' errored after 103 ms
[15:30:35] Error in plugin "gulp-spsave"
Message:
error:0308010C:digital envelope routines::unsupported
Details:
opensslErrorStack: error:03000086:digital envelope routines::initialization error
library: digital envelope routines
reason: unsupported
code: ERR_OSSL_EVP_UNSUPPORTED
domainEmitter: [object Object]
domainThrown: false

Stack:
Error: error:0308010C:digital envelope routines::unsupported
at new Hash (node:internal/crypto/hash:67:19)
at Object.createHash (node:crypto:130:10)
at Object.createNTLMHash (C:\Code\comminvoice\node_modules\node-ntlm-client\lib\hash.js:77:22)
at Object.createType3Message (C:\Code\comminvoice\node_modules\node-ntlm-client\lib\ntlm.js:213:23)
at C:\Code\comminvoice\node_modules\node-sp-auth\lib\src\auth\resolvers\OnpremiseUserCredentials.js:41:35
at processTicksAndRejections (node:internal/process/task_queues:96:5)
[15:30:35] 'InitialDevDeploy' errored after 2.83 s

gulp dest not working

When using with gulp.dest option and flatten = true, error is thrown:

vfs.src("files/**/*.*")
.pipe(spsave({
                "username": "",
                "password": "",
                "folder" : "SiteAssets",
                "siteUrl" : "",
                "flatten": true
            }))
    .pipe(vfs.dest("output"))

Deploying WebPart - set Web Part Group Value

I am deploying a number of WebParts using the following code:

 gulp.src("build/webparts/*.*")
        .pipe(spsave({
            siteUrl: url,
            checkin: true,
            folder: "_catalogs/wp",
            checkinType: 1,
            flatten:false
        },  settings.creds));

I would like to set the WebPart property of the group, but cannot be done by adding the property to the .webpart file. Looking at some C# feature implementation code I can use something along the lines of:

<Module Name=โ€WebPartsโ€ List=โ€113โ€ณ Url=โ€_catalogs/wpโ€>
      <File Path=โ€FlarePoint.MyWebPart.webpartโ€ Url=โ€FlarePoint.MyWebPart.webpartโ€ Type=โ€GhostableInLibraryโ€>
          <Property Name=โ€Groupโ€ Value=โ€FlarePoint Web Partsโ€ />this is what you add for the Group
          <Property Name=โ€Titleโ€ Value=โ€FlarePoint.MyWebPartโ€ />this is what you add for the Title
          <Property Name=โ€WebPartDescriptionโ€ Value=โ€FlarePoints MyWebPart descriptionโ€ />this is what you add for the Description
      </File>
  </Module>

I have tried to update the filesMetadata in the same way that you can do this for Master Pages and Display Templates, but having no joy. Is setting the value of the Web Part Group something that can be done this way?

Status code 401 while saving

Environment : SP 2013, basic NTLM auth

Error details:
[17:22:16] StatusCodeError in plugin "gulp-spsave"
Message:
401 - undefined
Details:
statusCode: 401
error: undefined
options: [object Object]
response: [object Object]
domainEmitter: [object Object]
domain: [object Object]
domainThrown: false
StatusCodeError: 401 - undefined
at new StatusCodeError (\Source\Repos\TypeScript-SP-StarterPack\node_modules\request-promise-core\lib\errors.js:32:15)
at Request.plumbing.callback (\Source\Repos\TypeScript-SP-StarterPack\node_modules\request-promise-core\lib\plumbing.js:104:33)
at Request.RP$callback [as _callback] (\Source\Repos\TypeScript-SP-StarterPack\node_modules\request-promise-core\lib\plumbing.js:46:31)
at Request.self.callback (\Source\Repos\TypeScript-SP-StarterPack\node_modules\request\request.js:185:22)
at emitTwo (events.js:126:13)
at Request.emit (events.js:214:7)
at Request. (\Source\Repos\TypeScript-SP-StarterPack\node_modules\request\request.js:1161:10)
at emitOne (events.js:116:13)
at Request.emit (events.js:211:7)
at IncomingMessage. (\Source\Repos\TypeScript-SP-StarterPack\node_modules\request\request.js:1083:12)
at Object.onceWrapper (events.js:313:30)
at emitNone (events.js:111:20)
at IncomingMessage.emit (events.js:208:7)
at endReadableNT (_stream_readable.js:1064:12)
at _combinedTickCallback (internal/process/next_tick.js:139:11)
at process._tickDomainCallback (internal/process/next_tick.js:219:9)
From previous event:
at runCallback (timers.js:810:20)
at tryOnImmediate (timers.js:768:5)
at processImmediate [as _immediateCallback] (timers.js:745:5)
From previous event:
at \Source\Repos\TypeScript-SP-StarterPack\node_modules\sp-request\lib\src\core\SPRequest.js:46:18
From previous event:
at coreRequest (\Source\Repos\TypeScript-SP-StarterPack\node_modules\sp-request\lib\src\core\SPRequest.js:22:16)
at spRequestFunc (\Source\Repos\TypeScript-SP-StarterPack\node_modules\sp-request\lib\src\core\SPRequest.js:69:20)
at Function.spRequestFunc.(anonymous function) [as post] (\Source\Repos\TypeScript-SP-StarterPack\node_modules\sp-request\lib\src\core\SPRequest.js:109:24)
at \Source\Repos\TypeScript-SP-StarterPack\node_modules\sp-request\lib\src\core\SPRequest.js:87:27
From previous event:
at Function.spRequestFunc.requestDigest (\Source\Repos\TypeScript-SP-StarterPack\node_modules\sp-request\lib\src\core\SPRequest.js:79:16)
at \Source\Repos\TypeScript-SP-StarterPack\node_modules\spsave\lib\src\core\FileSaver.js:54:36
at bound (domain.js:301:14)
at runBound (domain.js:314:12)
at runCallback (timers.js:810:20)
at tryOnImmediate (timers.js:768:5)
at processImmediate [as _immediateCallback] (timers.js:745:5)
From previous event:
at FileSaver.saveFile (\Source\Repos\TypeScript-SP-StarterPack\node_modules\spsave\lib\src\core\FileSaver.js:53:14)
at FileSaver.save (\Source\Repos\TypeScript-SP-StarterPack\node_modules\spsave\lib\src\core\FileSaver.js:38:18)
at saveSingleFile (\Source\Repos\TypeScript-SP-StarterPack\node_modules\spsave\lib\src\core\SPSave.js:80:76)
at \Source\Repos\TypeScript-SP-StarterPack\node_modules\spsave\lib\src\core\SPSave.js:41:13
From previous event:
at spsave (\Source\Repos\TypeScript-SP-StarterPack\node_modules\spsave\lib\src\core\SPSave.js:13:12)
at DestroyableTransform.uploadFile [as _transform] (\Source\Repos\TypeScript-SP-StarterPack\node_modules\gulp-spsave\index.js:42:7)
at DestroyableTransform.Transform._read (\Source\Repos\TypeScript-SP-StarterPack\node_modules\gulp-spsave\node_modules\readable-stream\lib_stream_transform.js:159:10)
at DestroyableTransform.Transform.write (\Source\Repos\TypeScript-SP-StarterPack\node_modules\gulp-spsave\node_modules\readable-stream\lib_stream_transform.js:147:83)
at doWrite (\Source\Repos\TypeScript-SP-StarterPack\node_modules\gulp-spsave\node_modules\readable-stream\lib_stream_writable.js:313:64)
at writeOrBuffer (\Source\Repos\TypeScript-SP-StarterPack\node_modules\gulp-spsave\node_modules\readable-stream\lib_stream_writable.js:302:5)
at DestroyableTransform.Writable.write (\Source\Repos\TypeScript-SP-StarterPack\node_modules\gulp-spsave\node_modules\readable-stream\lib_stream_writable.js:241:11)
at DestroyableTransform.ondata (\Source\Repos\TypeScript-SP-StarterPack\node_modules\through2\node_modules\readable-stream\lib_stream_readable.js:619:20)
at emitOne (events.js:116:13)
at DestroyableTransform.emit (events.js:211:7)
at addChunk (\Source\Repos\TypeScript-SP-StarterPack\node_modules\through2\node_modules\readable-stream\lib_stream_readable.js:291:12)
at readableAddChunk (\Source\Repos\TypeScript-SP-StarterPack\node_modules\through2\node_modules\readable-stream\lib_stream_readable.js:278:11)
at DestroyableTransform.Readable.push (\Source\Repos\TypeScript-SP-StarterPack\node_modules\through2\node_modules\readable-stream\lib_stream_readable.js:245:10)
at DestroyableTransform.Transform.push (\Source\Repos\TypeScript-SP-StarterPack\node_modules\through2\node_modules\readable-stream\lib_stream_transform.js:148:32)
at Pumpify.onReadable (\Source\Repos\TypeScript-SP-StarterPack\node_modules\to-through\index.js:25:14)
at emitNone (events.js:106:13)
at Pumpify.emit (events.js:208:7)
at emitReadable
(\Source\Repos\TypeScript-SP-StarterPack\node_modules\duplexify\node_modules\readable-stream\lib_stream_readable.js:504:10)
at emitReadable (\Source\Repos\TypeScript-SP-StarterPack\node_modules\duplexify\node_modules\readable-stream\lib_stream_readable.js:498:62)
at addChunk (\Source\Repos\TypeScript-SP-StarterPack\node_modules\duplexify\node_modules\readable-stream\lib_stream_readable.js:298:29)
at readableAddChunk (\Source\Repos\TypeScript-SP-StarterPack\node_modules\duplexify\node_modules\readable-stream\lib_stream_readable.js:278:11)
at Pumpify.Readable.push (\Source\Repos\TypeScript-SP-StarterPack\node_modules\duplexify\node_modules\readable-stream\lib_stream_readable.js:245:10)
at Pumpify.Duplexify._forward (\Source\Repos\TypeScript-SP-StarterPack\node_modules\duplexify\index.js:170:26)
at DestroyableTransform.onreadable (\Source\Repos\TypeScript-SP-StarterPack\node_modules\duplexify\index.js:134:10)
at emitNone (events.js:106:13)

Description:
I am trying to save files into SharePoint. I am working behind a corporate proxy and have set the proxy in the env variables as below:
set https_proxy=http://[company proxy url]
set http_proxy=http://[company proxy url]
set NODE_TLS_REJECT_UNAUTHORIZED=0

I have verified the above setting by logging the console.log(process.env.https_proxy);

The proxy value given is correct as I use it for npm and git and both of them works.

gulp-util is being depreciated.

According to the gulp team, gulp-util is being depreciated. Since gulp-spsave depends on gulp-util, the guidance is to replace the dependency with the individual functionality that it requires.

Link to guidance: https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5

remove gulp-util using the following API replacements:
gutil.File => https://www.npmjs.com/package/vinyl
gutil.replaceExtension => The .extname property on Vinyl objects or https://www.npmjs.com/package/replace-ext
gutil.colors => https://www.npmjs.com/package/ansi-colors
gutil.date => https://www.npmjs.com/package/date-format
gutil.log => https://www.npmjs.com/package/fancy-log
gutil.template => https://www.npmjs.com/package/lodash.template
gutil.env => https://www.npmjs.com/package/minimist
gutil.beep => https://www.npmjs.com/package/beeper
gutil.noop => https://www.npmjs.com/package/through2
gutil.isStream => Use the .isStream() method on Vinyl objects
gutil.isBuffer => Use the .isBuffer() method on Vinyl objects
gutil.isNull => Use the .isNull() method on Vinyl objects
gutil.linefeed => Use the string '\n' in your code
gutil.combine => https://www.npmjs.com/package/multipipe
gutil.buffer => https://www.npmjs.com/package/list-stream
gutil.PluginError => https://www.npmjs.com/package/plugin-error

How to configure proxy for spsave?

working behind the firewall when using spsave and just wondering how I configure the proxy for spsave. I configure the correct proxy for npm already.
Thanks

Cannot read property 'indexOf' of null

Using gulp-spsave I get an error in node-sp-auth, see the following error output. This just happened out of nowhere - it was working perfectly fine before. Could this be in incompatibility with gulp^4.0.0?

[09:34:03] spsave: Error occured:
[09:34:03] spsave: Cannot read property 'indexOf' of null

[09:34:03] spsave: Stack trace:

[09:34:03] spsave: TypeError: Cannot read property 'indexOf' of null
    at isOnPremUrl (...\node_modules\node-sp-auth\lib\src\auth\IAuthOptions.js:6:17)

This is the function that throws the error:

const url = require("url");
function isOnPremUrl(siteUrl) {
    let host = (url.parse(siteUrl)).host;
    return host.indexOf('.sharepoint.com') === -1 && host.indexOf('.sharepoint.cn') === -1 && host.indexOf('.sharepoint.de') === -1
        && host.indexOf('.sharepoint-mil.us') === -1 && host.indexOf('.sharepoint.us') === -1;
}

Error when using ondemand credentials

Hi,

I'm trying to upload files to SharePoint using ondemand credentials:

var coreOptions = {
    siteUrl: '*hidden url*',
    folder: "SiteAssets/Scripts",
    flatten: false
};
var creds = {
    ondemand: "true"
};
gulp.task("upload-to-sp", function () {
    return gulp.src([
        "./app/**/*.js",
        "./app/**/*.css",
        "./app/**/*.html"])
        .pipe(spsave(coreOptions, creds));
});

However, when I run the task I get the following error:

[15:17:51] Starting 'upload-to-sp'...
[15:17:57] spsave: Error occured:
[15:17:57] spsave: Cookie array is empty
[15:17:57] spsave: Stack trace:
[15:17:57] spsave: Error: Cookie array is empty
    at OnDemand.saveAuthData (C:\Users\joaander\source\repos\ABB.PA.GlobalManagementSite\ABB.PA.GlobalManagementSite\node_modules\spsave\node_modules\node-sp-auth\lib\src\auth\resolvers\ondemand\OnDemand.js:104:19)

It worked a couple of days ago on a site collection on the same tenant. Electron is started but it closes quickly as if it is using cached credentials.

Any clues?

Thanks,
Joachim

missing module 'bluebird'

Maybe another stupid issue, I have this issue when upgrade to 2.0
node_modules\gulp-spsave\node_modules\spsave\lib\src\core\SPSave.js require module 'bluebird', but I do not see it downloaded by npm. maybe i have to add it to my package?

Failed to run "C:\GitHub\Portal\Portal\Gulpfile.js"...
cmd.exe /c gulp --tasks-simple
Error: Cannot find module 'bluebird'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object. (C:\GitHub\Portal\Portal\node_modules\gulp-spsave\node_modules\spsave\lib\src\core\SPSave.js:2:15)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object. (C:\GitHub\Portal\Portal\node_modules\gulp-spsave\node_modules\spsave\lib\src\index.js:5:10)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object. (C:\GitHub\Portal\Portal\node_modules\gulp-spsave\index.js:1:76)

Upload Html Master Page

When uploading the html master page in the _catalogs\masterpage directory, the .html file is placed in the directory but the .master isn't created. I can go in and edit the properties of the .html file, not changing anything, then saving the file and the .master file is created.

return gulp.src("build/template/masterpage/*.*") .pipe(spsave({ siteUrl: url, checkin: true, folder: "_catalogs/masterpage", checkinType: 1, //Major checkinMessage: "Checked in by automated Gulp process", flatten:false }, creds));

I can also use manually upload the .html file into the directory and the ,master file is created, so in laymen terms it seems the gulp process does not notify the folder the file has appear so the process to kick off the creation of the .master file cannot be started.

I have also tried to use the DisplayTemplate example and adding a specific ContentTypeId but then I am not sure on the value of "type", so recieving the error:

spsave: 400 - {"error":{"code":"-1, Microsoft.SharePoint.Client.InvalidClientQueryException","message":{"lang":"en-US","value":"An entry without a type name was found, but no expected type was specified. To allow entries without type information, the expected type must also be specified when the model is specified."}}}

Is this one type of artefact that must be applied using the DisplayTemplate example but correctly specifying the correct "type"?

spsave: TypeError: Cannot read property 'match' of undefined

Upload to SPO works but not to on-premise

my gulp task:

gulp.task('spsave', function() {
  return gulp.src('./dist/*.*')
    .pipe(spsave({
      siteUrl: "https://subdomain.domain.com/communities/site/",
      folder: "app"
    }, {
      username: "[email protected]",
      password: "foooo",
      domain: 'foo'
    }));
});

i get following log:

[13:57:09] Starting 'spsave'...
[13:57:10] spsave: Error occured:
[13:57:10] spsave: Cannot read property 'match' of undefined

[13:57:10] spsave: Stack trace:

[13:57:10] spsave: TypeError: Cannot read property 'match' of undefined
at Object.parseType2Message (C:\Users\Jonas\Source\Repos\Swisscom.PartnerPortal\node_modules\httpntlm\ntlm.js:114:20)
at C:\Users\Jonas\Source\Repos\Swisscom.PartnerPortal\node_modules\node-sp-auth\lib\src\auth\resolvers\OnpremiseUserCredentials.js:35:33
From previous event:
at coreRequest (C:\Users\Jonas\Source\Repos\Swisscom.PartnerPortal\node_modules\sp-request\lib\src\core\SPRequest.js:15:16)
at spRequestFunc (C:\Users\Jonas\Source\Repos\Swisscom.PartnerPortal\node_modules\sp-request\lib\src\core\SPRequest.js:56:20)
at Function.spRequestFunc.(anonymous function) [as post] (C:\Users\Jonas\Source\Repos\Swisscom.PartnerPortal\node_modules\sp-request\lib\src\core\SPRequest.js:96:24)
at C:\Users\Jonas\Source\Repos\Swisscom.PartnerPortal\node_modules\sp-request\lib\src\core\SPRequest.js:74:27
From previous event:
at Function.spRequestFunc.requestDigest (C:\Users\Jonas\Source\Repos\Swisscom.PartnerPortal\node_modules\sp-request\lib\src\core\SPRequest.js:66:16)
at C:\Users\Jonas\Source\Repos\Swisscom.PartnerPortal\node_modules\spsave\lib\src\core\FileSaver.js:53:36
at runCallback (timers.js:666:20)
at tryOnImmediate (timers.js:639:5)
at processImmediate [as _immediateCallback] (timers.js:611:5)
From previous event:
at FileSaver.saveFile (C:\Users\Jonas\Source\Repos\Swisscom.PartnerPortal\node_modules\spsave\lib\src\core\FileSaver.js:52:14)
at FileSaver.save (C:\Users\Jonas\Source\Repos\Swisscom.PartnerPortal\node_modules\spsave\lib\src\core\FileSaver.js:37:18)
at saveSingleFile (C:\Users\Jonas\Source\Repos\Swisscom.PartnerPortal\node_modules\spsave\lib\src\core\SPSave.js:74:76)
at C:\Users\Jonas\Source\Repos\Swisscom.PartnerPortal\node_modules\spsave\lib\src\core\SPSave.js:40:13
From previous event:
at spsave (C:\Users\Jonas\Source\Repos\Swisscom.PartnerPortal\node_modules\spsave\lib\src\core\SPSave.js:12:12)
at DestroyableTransform.uploadFile [as _transform] (C:\Users\Jonas\Source\Repos\Swisscom.PartnerPortal\node_modules\gulp-spsave\index.js:43:7)
at DestroyableTransform.Transform._read (C:\Users\Jonas\Source\Repos\Swisscom.PartnerPortal\node_modules\gulp-spsave\node_modules\readable-stream\lib_stream_transform.js:159:10)
at DestroyableTransform.Transform.write (C:\Users\Jonas\Source\Repos\Swisscom.PartnerPortal\node_modules\gulp-spsave\node_modules\readable-stream\lib_stream_transform.js:147:83)
at doWrite (C:\Users\Jonas\Source\Repos\Swisscom.PartnerPortal\node_modules\gulp-spsave\node_modules\readable-stream\lib_stream_writable.js:313:64)
at writeOrBuffer (C:\Users\Jonas\Source\Repos\Swisscom.PartnerPortal\node_modules\gulp-spsave\node_modules\readable-stream\lib_stream_writable.js:302:5)
at DestroyableTransform.Writable.write (C:\Users\Jonas\Source\Repos\Swisscom.PartnerPortal\node_modules\gulp-spsave\node_modules\readable-stream\lib_stream_writable.js:241:11)
at write (C:\Users\Jonas\Source\Repos\Swisscom.PartnerPortal\node_modules\vinyl-fs\node_modules\readable-stream\lib_stream_readable.js:623:24)
at flow (C:\Users\Jonas\Source\Repos\Swisscom.PartnerPortal\node_modules\vinyl-fs\node_modules\readable-stream\lib_stream_readable.js:632:7)
at DestroyableTransform.pipeOnReadable (C:\Users\Jonas\Source\Repos\Swisscom.PartnerPortal\node_modules\vinyl-fs\node_modules\readable-stream\lib_stream_readable.js:664:5)
at emitNone (events.js:86:13)
at DestroyableTransform.emit (events.js:188:7)
at emitReadable
(C:\Users\Jonas\Source\Repos\Swisscom.PartnerPortal\node_modules\vinyl-fs\node_modules\readable-stream\lib_stream_readable.js:448:10)
at emitReadable (C:\Users\Jonas\Source\Repos\Swisscom.PartnerPortal\node_modules\vinyl-fs\node_modules\readable-stream\lib_stream_readable.js:444:5)
at readableAddChunk (C:\Users\Jonas\Source\Repos\Swisscom.PartnerPortal\node_modules\vinyl-fs\node_modules\readable-stream\lib_stream_readable.js:187:9)
at DestroyableTransform.Readable.push (C:\Users\Jonas\Source\Repos\Swisscom.PartnerPortal\node_modules\vinyl-fs\node_modules\readable-stream\lib_stream_readable.js:149:10)
at DestroyableTransform.Transform.push (C:\Users\Jonas\Source\Repos\Swisscom.PartnerPortal\node_modules\vinyl-fs\node_modules\readable-stream\lib_stream_transform.js:145:32)
at afterTransform (C:\Users\Jonas\Source\Repos\Swisscom.PartnerPortal\node_modules\vinyl-fs\node_modules\readable-stream\lib_stream_transform.js:101:12)
at TransformState.afterTransform (C:\Users\Jonas\Source\Repos\Swisscom.PartnerPortal\node_modules\vinyl-fs\node_modules\readable-stream\lib_stream_transform.js:79:12)
at DestroyableTransform.noop [as _transform] (C:\Users\Jonas\Source\Repos\Swisscom.PartnerPortal\node_modules\vinyl-fs\node_modules\through2\through2.js:26:3)
at DestroyableTransform.Transform._read (C:\Users\Jonas\Source\Repos\Swisscom.PartnerPortal\node_modules\vinyl-fs\node_modules\readable-stream\lib_stream_transform.js:184:10)
at DestroyableTransform.Transform._write (C:\Users\Jonas\Source\Repos\Swisscom.PartnerPortal\node_modules\vinyl-fs\node_modules\readable-stream\lib_stream_transform.js:172:12)
at doWrite (C:\Users\Jonas\Source\Repos\Swisscom.PartnerPortal\node_modules\vinyl-fs\node_modules\readable-stream\lib_stream_writable.js:237:10)
at writeOrBuffer (C:\Users\Jonas\Source\Repos\Swisscom.PartnerPortal\node_modules\vinyl-fs\node_modules\readable-stream\lib_stream_writable.js:227:5)
at DestroyableTransform.Writable.write (C:\Users\Jonas\Source\Repos\Swisscom.PartnerPortal\node_modules\vinyl-fs\node_modules\readable-stream\lib_stream_writable.js:194:11)
[13:57:10] 'spsave' errored after 471 ms
[13:57:10] TypeError in plugin 'gulp-spsave'

Issues uploading large amount of files

Hi,

I've found an issue when trying to upload a high number of documents through this module

I include the code for reference

                        var es, log, logFile;

                        es = require('event-stream');

                        log = require('gulp-util').log;

                        logFile = function (es) {
                            return es.map(function (file, cb) {
                                log(file.path);
                                return cb();
                            });
                        };

                        gulp.src("dist/**/*")
                            .pipe(spSave(coreOptions, creds))
                            .pipe(logFile(es))
                            .on('end', function (data) { console.log(data) })
                            .on('error', function (data) { console.log(data) });

With the code included, this works fine. However, if I comment the ".pipe(logFile(es))" line, which should be optional, gulp-spsave uploads 15 documents and then stops.

Error: Unexpected close tag Unhandled rejection Error in plugin "gulp-spsave"

PS D:\Workspace\Angular\Test App\test-app> gulp
[23:31:49] Using gulpfile D:\Workspace\Angular\Test App\test-app\gulpfile.js
[23:31:49] Starting 'watch'...
[23:31:49] Finished 'watch' after 15 ms
[23:31:49] Starting 'default'...
[23:31:49] Starting 'aspx'...
[23:31:49] Starting 'js'...
[23:31:49] Finished 'default' after 12 ms
[node-sp-auth]: reading auth data from C:\Users\Daneshwaran\AppData\Roaming\spauth\creds\https___.json
[23:31:53] spsave: Error occured:
[23:31:53] spsave: Unexpected close tag
Line: 2
Column: 77
Char: >

[23:31:53] spsave: Stack trace:

[23:31:53] spsave: Error: Unexpected close tag
Line: 2
Column: 77
Char: >
at error (D:\Workspace\Angular\Test App\test-app\node_modules\xmldoc\node_modules\sax\lib\sax.js:666:10)
at strictFail (D:\Workspace\Angular\Test App\test-app\node_modules\xmldoc\node_modules\sax\lib\sax.js:692:7)
at closeTag (D:\Workspace\Angular\Test App\test-app\node_modules\xmldoc\node_modules\sax\lib\sax.js:885:9)
at SAXParser.write (D:\Workspace\Angular\Test App\test-app\node_modules\xmldoc\node_modules\sax\lib\sax.js:1447:13) at new XmlDocument (D:\Workspace\Angular\Test App\test-app\node_modules\xmldoc\lib\xmldoc.js:206:15)
at config_1.request.post.then.xmlResponse (D:\Workspace\Angular\Test App\test-app\node_modules\node-sp-auth\lib\src\utils\AdfsHelper.js:28:23)
at processImmediate (timers.js:632:19)
From previous event:
at coreRequest (D:\Workspace\Angular\Test App\test-app\node_modules\sp-request\lib\src\core\SPRequest.js:22:16)
at spRequestFunc (D:\Workspace\Angular\Test App\test-app\node_modules\sp-request\lib\src\core\SPRequest.js:69:20)
at Function.spRequestFunc.(anonymous function) [as get] (D:\Workspace\Angular\Test App\test-app\node_modules\sp-request\lib\src\core\SPRequest.js:109:24)
at FileSaver.getFileByUrl (D:\Workspace\Angular\Test App\test-app\node_modules\spsave\lib\src\core\FileSaver.js:211:31)
at D:\Workspace\Angular\Test App\test-app\node_modules\spsave\lib\src\core\FileSaver.js:176:19
at FileSaver.checkoutFile (D:\Workspace\Angular\Test App\test-app\node_modules\spsave\lib\src\core\FileSaver.js:171:23)
at FileSaver.saveFile (D:\Workspace\Angular\Test App\test-app\node_modules\spsave\lib\src\core\FileSaver.js:51:35)
at FileSaver.save (D:\Workspace\Angular\Test App\test-app\node_modules\spsave\lib\src\core\FileSaver.js:38:18)
at saveSingleFile (D:\Workspace\Angular\Test App\test-app\node_modules\spsave\lib\src\core\SPSave.js:80:76)
at D:\Workspace\Angular\Test App\test-app\node_modules\spsave\lib\src\core\SPSave.js:41:13
at spsave (D:\Workspace\Angular\Test App\test-app\node_modules\spsave\lib\src\core\SPSave.js:13:12)
at DestroyableTransform.uploadFile [as _transform] (D:\Workspace\Angular\Test App\test-app\node_modules\gulp-spsave\index.js:42:7)
at DestroyableTransform.Transform._read (D:\Workspace\Angular\Test App\test-app\node_modules\gulp-spsave\node_modules\readable-stream\lib_stream_transform.js:159:10)
at DestroyableTransform.Transform._write (D:\Workspace\Angular\Test App\test-app\node_modules\gulp-spsave\node_modules\readable-stream\lib_stream_transform.js:147:83)
at doWrite (D:\Workspace\Angular\Test App\test-app\node_modules\gulp-spsave\node_modules\readable-stream\lib_stream_writable.js:313:64)
at writeOrBuffer (D:\Workspace\Angular\Test App\test-app\node_modules\gulp-spsave\node_modules\readable-stream\lib_stream_writable.js:302:5)
at DestroyableTransform.Writable.write (D:\Workspace\Angular\Test App\test-app\node_modules\gulp-spsave\node_modules\readable-stream\lib_stream_writable.js:241:11)
at DestroyableTransform.ondata (internal/streams/legacy.js:15:31)
From previous event:
at FileSaver.checkoutFile (D:\Workspace\Angular\Test App\test-app\node_modules\spsave\lib\src\core\FileSaver.js:171:23)
at FileSaver.saveFile (D:\Workspace\Angular\Test App\test-app\node_modules\spsave\lib\src\core\FileSaver.js:51:35)
at FileSaver.save (D:\Workspace\Angular\Test App\test-app\node_modules\spsave\lib\src\core\FileSaver.js:38:18)
at saveSingleFile (D:\Workspace\Angular\Test App\test-app\node_modules\spsave\lib\src\core\SPSave.js:80:76)
at D:\Workspace\Angular\Test App\test-app\node_modules\spsave\lib\src\core\SPSave.js:41:13
From previous event:
at spsave (D:\Workspace\Angular\Test App\test-app\node_modules\spsave\lib\src\core\SPSave.js:13:12)
at DestroyableTransform.uploadFile [as _transform] (D:\Workspace\Angular\Test App\test-app\node_modules\gulp-spsave\index.js:42:7)
at DestroyableTransform.Transform._read (D:\Workspace\Angular\Test App\test-app\node_modules\gulp-spsave\node_modules\readable-stream\lib_stream_transform.js:159:10)
at DestroyableTransform.Transform.write (D:\Workspace\Angular\Test App\test-app\node_modules\gulp-spsave\node_modules\readable-stream\lib_stream_transform.js:147:83)
at doWrite (D:\Workspace\Angular\Test App\test-app\node_modules\gulp-spsave\node_modules\readable-stream\lib_stream_writable.js:313:64)
at writeOrBuffer (D:\Workspace\Angular\Test App\test-app\node_modules\gulp-spsave\node_modules\readable-stream\lib_stream_writable.js:302:5)
at DestroyableTransform.Writable.write (D:\Workspace\Angular\Test App\test-app\node_modules\gulp-spsave\node_modules\readable-stream\lib_stream_writable.js:241:11)
at DestroyableTransform.ondata (internal/streams/legacy.js:15:31)
at DestroyableTransform.emit (events.js:189:13)
at DestroyableTransform. (D:\Workspace\Angular\Test App\test-app\node_modules\vinyl-fs\node_modules\readable-stream\lib_stream_readable.js:786:14)
at DestroyableTransform.emit (events.js:189:13)
at emitReadable
(D:\Workspace\Angular\Test App\test-app\node_modules\vinyl-fs\node_modules\readable-stream\lib_stream_readable.js:448:10)
at emitReadable (D:\Workspace\Angular\Test App\test-app\node_modules\vinyl-fs\node_modules\readable-stream\lib_stream_readable.js:444:5)
at readableAddChunk (D:\Workspace\Angular\Test App\test-app\node_modules\vinyl-fs\node_modules\readable-stream\lib_stream_readable.js:187:9)
at DestroyableTransform.Readable.push (D:\Workspace\Angular\Test App\test-app\node_modules\vinyl-fs\node_modules\readable-stream\lib_stream_readable.js:149:10)
at DestroyableTransform.Transform.push (D:\Workspace\Angular\Test App\test-app\node_modules\vinyl-fs\node_modules\readable-stream\lib_stream_transform.js:145:32)
at afterTransform (D:\Workspace\Angular\Test App\test-app\node_modules\vinyl-fs\node_modules\readable-stream\lib_stream_transform.js:101:12)
at TransformState.afterTransform (D:\Workspace\Angular\Test App\test-app\node_modules\vinyl-fs\node_modules\readable-stream\lib_stream_transform.js:79:12)
at done (D:\Workspace\Angular\Test App\test-app\node_modules\vinyl-fs\lib\dest\writeContents\index.js:11:7)
at FSReqCallback.args [as oncomplete] (fs.js:147:20)
Unhandled rejection Error in plugin "gulp-spsave"

The system was unable to find the specified registry key or value.

SP2016 On-Prem

Have gulp-spsave, sp-request and node-sp-auth in my package.json and installed to Visual Studio 2015.

Gulp task configured as follows:

gulp.task('copyLocal'), function () {
return gulp.src("./Modules/justAnotherScript.js")
        .pipe(spsave({
            siteUrl: 'https://sp.mjh.local/',
            folder: "Style Library",
            flatten: true,
            checkin: true,
            checkinType: 1
        })
    );
};

Running the task results in:

"ERROR: The system was unable to find the specified registry key or value."

Not all files are copied over

Hi,

I have a few issues with my gulp-spsave configuration. My project is simply a project folder that is stored within the site assets folder. This structure just needs replicating to the SiteAssets folder on my target site.

SiteAssets

  • Project
    • home
      • images
        • image1.png
        • image2.png
        • image3.png
      • page.aspx
      • page.js
    • page1
      • images
        • image1.png
        • image2.png
        • image3.png
      • page.aspx
      • page.js
    • page2
      • images
        • image1.png
        • image2.png
        • image3.png
      • page.aspx
      • page.js

My current configuration doesn't pick up all files when one changes. Weirdly it picks up some files and not others and really, it's intermittent and different files at different times (sometimes they upload, sometimes they don't). Ideally, I would like to just upload the changed file. Images are always ignored. I'd like it so that when I drop a new image in the images folder (or overwrite an existing image) it gets uploaded.

Here is my current config:

var gulp = require('gulp');
var path = require('path');
var settings = require("./settings.js");

var $ = require('gulp-load-plugins')({lazy: true});

gulp.task('default', function() {
  gulp.watch(['SiteAssets/**/*.*'], function () {
    return gulp.src('SiteAssets/**/*.*')
        .pipe($.spsave({
            siteUrl: settings.siteUrl,
            username: settings.username,
            password: settings.password,
            folder: "SiteAssets",
            flatten: false
        }));
    });
});

Get UNABLE_TO_VERIFY_LEAF_SIGNATURE error when upload file to a on premise site with CA trust certificate

Hi,

First, I would like to appreciate this tool. It makes CEWP-based script development easy. it works fine for SPO. When I tried to use this tool to upload files to my on premise SP2013, I got the following exception:
[14:03:40] spsave: Error occured: [14:03:40] spsave: Error: UNABLE_TO_VERIFY_LEAF_SIGNATURE [14:03:40] spsave: Stack trace: [14:03:40] spsave: RequestError: Error: UNABLE_TO_VERIFY_LEAF_SIGNATURE at new RequestError (C:\Temp\TestSharePointAddInGulp1\TestSharePointAddInGulp1\node_modules\gulp-spsave\node_modules\spsave\node_modules\sp-request\node_modules\request-promise\lib\errors.js:14:15) at Request.RP$callback [as _callback] (C:\Temp\TestSharePointAddInGulp1\TestSharePointAddInGulp1\node_modules\gulp-spsave\node_modules\spsave\node_modules\sp-request\node_modules\request-promise\lib\rp.js:60:25) at self.callback (C:\Temp\TestSharePointAddInGulp1\TestSharePointAddInGulp1\node_modules\gulp-spsave\node_modules\spsave\node_modules\sp-request\node_modules\request\request.js:187:22) at Request.emit (events.js:95:17) at Request.onRequestError (C:\Temp\TestSharePointAddInGulp1\TestSharePointAddInGulp1\node_modules\gulp-spsave\node_modules\spsave\node_modules\sp-request\node_modules\request\request.js:813:8) at ClientRequest.emit (events.js:95:17) at CleartextStream.socketErrorListener (http.js:1547:9) at CleartextStream.emit (events.js:95:17) at SecurePair.<anonymous> (tls.js:1386:19) at SecurePair.emit (events.js:92:17) at SecurePair.maybeInitFinished (tls.js:979:10) at CleartextStream.read [as _read] (tls.js:471:13) at CleartextStream.Readable.read (_stream_readable.js:340:10) at EncryptedStream.write [as _write] (tls.js:368:25) at doWrite (_stream_writable.js:225:10) at writeOrBuffer (_stream_writable.js:215:5) From previous event: at Request.RP$initInterceptor [as init] (C:\Temp\TestSharePointAddInGulp1\TestSharePointAddInGulp1\node_modules\gulp-spsave\node_modules\spsave\node_modules\sp-request\node_modules\request-promise\lib\rp.js:117:28) at new Request (C:\Temp\TestSharePointAddInGulp1\TestSharePointAddInGulp1\node_modules\gulp-spsave\node_modules\spsave\node_modules\sp-request\node_modules\request\request.js:129:8) at request (C:\Temp\TestSharePointAddInGulp1\TestSharePointAddInGulp1\node_modules\gulp-spsave\node_modules\spsave\node_modules\sp-request\node_modules\request\index.js:55:10) at C:\Temp\TestSharePointAddInGulp1\TestSharePointAddInGulp1\node_modules\gulp-spsave\node_modules\spsave\node_modules\sp-request\lib\src\core\auth\OnPremResolver.js:19:13 From previous event: at OnPremResolver.applyAuthHeaders (C:\Temp\TestSharePointAddInGulp1\TestSharePointAddInGulp1\node_modules\gulp-spsave\node_modules\spsave\node_modules\sp-request\lib\src\core\auth\OnPremResolver.js:12:16) at C:\Temp\TestSharePointAddInGulp1\TestSharePointAddInGulp1\node_modules\gulp-spsave\node_modules\spsave\node_modules\sp-request\lib\src\core\SPRequest.js:28:18 From previous event: at coreRequest (C:\Temp\TestSharePointAddInGulp1\TestSharePointAddInGulp1\node_modules\gulp-spsave\node_modules\spsave\node_modules\sp-request\lib\src\core\SPRequest.js:12:16) at spRequestFunc (C:\Temp\TestSharePointAddInGulp1\TestSharePointAddInGulp1\node_modules\gulp-spsave\node_modules\spsave\node_modules\sp-request\lib\src\core\SPRequest.js:52:20) at Function.spRequestFunc.(anonymous function) [as post] (C:\Temp\TestSharePointAddInGulp1\TestSharePointAddInGulp1\node_modules\gulp-spsave\node_modules\spsave\node_modules\sp-request\lib\src\core\SPRequest.js:92:24) at C:\Temp\TestSharePointAddInGulp1\TestSharePointAddInGulp1\node_modules\gulp-spsave\node_modules\spsave\node_modules\sp-request\lib\src\core\SPRequest.js:70:27 From previous event: at Function.spRequestFunc.requestDigest (C:\Temp\TestSharePointAddInGulp1\TestSharePointAddInGulp1\node_modules\gulp-spsave\node_modules\spsave\node_modules\sp-request\lib\src\core\SPRequest.js:62:16) at checkoutResult.then.then._this.sprequest.post.headers.X-RequestDigest (C:\Temp\TestSharePointAddInGulp1\TestSharePointAddInGulp1\node_modules\gulp-spsave\node_modules\spsave\lib\src\core\FileSaver.js:53:36) at process._tickCallback (node.js:419:13) From previous event: at FileSaver.saveFile (C:\Temp\TestSharePointAddInGulp1\TestSharePointAddInGulp1\node_modules\gulp-spsave\node_modules\spsave\lib\src\core\FileSaver.js:52:14) at FileSaver.save (C:\Temp\TestSharePointAddInGulp1\TestSharePointAddInGulp1\node_modules\gulp-spsave\node_modules\spsave\lib\src\core\FileSaver.js:37:18) at saveSingleFile (C:\Temp\TestSharePointAddInGulp1\TestSharePointAddInGulp1\node_modules\gulp-spsave\node_modules\spsave\lib\src\core\SPSave.js:69:47) at C:\Temp\TestSharePointAddInGulp1\TestSharePointAddInGulp1\node_modules\gulp-spsave\node_modules\spsave\lib\src\core\SPSave.js:36:13 From previous event: at spsave (C:\Temp\TestSharePointAddInGulp1\TestSharePointAddInGulp1\node_modules\gulp-spsave\node_modules\spsave\lib\src\core\SPSave.js:12:12) at DestroyableTransform.uploadFile (C:\Temp\TestSharePointAddInGulp1\TestSharePointAddInGulp1\node_modules\gulp-spsave\index.js:44:7) at DestroyableTransform.Transform._read (C:\Temp\TestSharePointAddInGulp1\TestSharePointAddInGulp1\node_modules\gulp-spsave\node_modules\through2\node_modules\readable-stream\lib\_stream_transform.js:159:10) at DestroyableTransform.Transform._write (C:\Temp\TestSharePointAddInGulp1\TestSharePointAddInGulp1\node_modules\gulp-spsave\node_modules\through2\node_modules\readable-stream\lib\_stream_transform.js:147:83) at doWrite (C:\Temp\TestSharePointAddInGulp1\TestSharePointAddInGulp1\node_modules\gulp-spsave\node_modules\through2\node_modules\readable-stream\lib\_stream_writable.js:313:64) at writeOrBuffer (C:\Temp\TestSharePointAddInGulp1\TestSharePointAddInGulp1\node_modules\gulp-spsave\node_modules\through2\node_modules\readable-stream\lib\_stream_writable.js:302:5) at DestroyableTransform.Writable.write (C:\Temp\TestSharePointAddInGulp1\TestSharePointAddInGulp1\node_modules\gulp-spsave\node_modules\through2\node_modules\readable-stream\lib\_stream_writable.js:241:11) at write (C:\Temp\TestSharePointAddInGulp1\TestSharePointAddInGulp1\node_modules\gulp\node_modules\vinyl-fs\node_modules\through2\node_modules\readable-stream\lib\_stream_readable.js:623:24) at flow (C:\Temp\TestSharePointAddInGulp1\TestSharePointAddInGulp1\node_modules\gulp\node_modules\vinyl-fs\node_modules\through2\node_modules\readable-stream\lib\_stream_readable.js:632:7) at DestroyableTransform.pipeOnReadable (C:\Temp\TestSharePointAddInGulp1\TestSharePointAddInGulp1\node_modules\gulp\node_modules\vinyl-fs\node_modules\through2\node_modules\readable-stream\lib\_stream_readable.js:664:5) at DestroyableTransform.emit (events.js:92:17) at emitReadable_ (C:\Temp\TestSharePointAddInGulp1\TestSharePointAddInGulp1\node_modules\gulp\node_modules\vinyl-fs\node_modules\through2\node_modules\readable-stream\lib\_stream_readable.js:448:10) at emitReadable (C:\Temp\TestSharePointAddInGulp1\TestSharePointAddInGulp1\node_modules\gulp\node_modules\vinyl-fs\node_modules\through2\node_modules\readable-stream\lib\_stream_readable.js:444:5) at readableAddChunk (C:\Temp\TestSharePointAddInGulp1\TestSharePointAddInGulp1\node_modules\gulp\node_modules\vinyl-fs\node_modules\through2\node_modules\readable-stream\lib\_stream_readable.js:187:9) at DestroyableTransform.Readable.push (C:\Temp\TestSharePointAddInGulp1\TestSharePointAddInGulp1\node_modules\gulp\node_modules\vinyl-fs\node_modules\through2\node_modules\readable-stream\lib\_stream_readable.js:149:10) at DestroyableTransform.Transform.push (C:\Temp\TestSharePointAddInGulp1\TestSharePointAddInGulp1\node_modules\gulp\node_modules\vinyl-fs\node_modules\through2\node_modules\readable-stream\lib\_stream_transform.js:145:32) at afterTransform (C:\Temp\TestSharePointAddInGulp1\TestSharePointAddInGulp1\node_modules\gulp\node_modules\vinyl-fs\node_modules\through2\node_modules\readable-stream\lib\_stream_transform.js:101:12) at TransformState.afterTransform (C:\Temp\TestSharePointAddInGulp1\TestSharePointAddInGulp1\node_modules\gulp\node_modules\vinyl-fs\node_modules\through2\node_modules\readable-stream\lib\_stream_transform.js:79:12) at DestroyableTransform.noop [as _transform] (C:\Temp\TestSharePointAddInGulp1\TestSharePointAddInGulp1\node_modules\gulp\node_modules\vinyl-fs\node_modules\through2\through2.js:26:3) [14:03:40] 'copyToSP' errored after 159 ms [14:03:40] RequestError in plugin 'gulp-spsave' Message: Error: **UNABLE_TO_VERIFY_LEAF_SIGNATURE** Details: cause: Error: UNABLE_TO_VERIFY_LEAF_SIGNATURE error: Error: UNABLE_TO_VERIFY_LEAF_SIGNATURE options: [object Object] response: undefined Process terminated with code 1.
My SP2013 site is using a certificate issued by my local CA from AD. I have no problem to view this site through https format in my browser. The exactly same gulp code was working fine for SPO site. Just wondering if I missed something. the following is my code:
`var gulp = require('gulp');
var spsave = require('gulp-spsave');
var spSettings = require('./spSettings.js');

gulp.task('copyToSP', function () {
// place code for your default task here
console.log(spSettings);
console.log(spSettings.siteUrl);
return gulp.src("./Scripts/app.js")
.pipe(spsave({
//username: on-premise, use current user,
//password: spSettings.password,
siteUrl: spSettings.siteUrl,
folder: "SiteAssets/TestSharePointAddInGulp1/Scripts"
}));

});
`

Thanks

Frank

Only upload files that have changed.

This is awesome, by the way! One less reason to go into SharePoint Designer.

However, when a file changes in my project then my task is uploading ALL files in my directory, not just those ones that have changed. Can I change my task to only upload the modified files?

var gulp = require('gulp');
var $ = require('gulp-load-plugins')({lazy: true});

gulp.task('default', function() {
  gulp.watch('SiteAssets/**/*.*', function () {
    return gulp.src(["SiteAssets/**/*.*"])
        .pipe($.spsave({
            siteUrl: "https://xxxx.sharepoint.com/sites/gulp-spsave-test",
            username: "[email protected]",
            password: "************",
            folder: "SiteAssets/SaveTest",
            flatten: false
        }));
    });
});

Callback will be triggered for each uploaded file

Hi,

currently the cb() function will be called after each file is uploaded. That does not work quite well with the gulp pipeline. Is it possible to call the callback after all files are published?

Thanks,
Viktor

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.