{"id":13750420,"url":"https://github.com/wictorwilen/gulp-spsync","last_synced_at":"2026-03-11T18:33:26.365Z","repository":{"id":57259037,"uuid":"45234029","full_name":"wictorwilen/gulp-spsync","owner":"wictorwilen","description":"Gulp plugin for synchronizing local files with a SharePoint library","archived":false,"fork":false,"pushed_at":"2018-08-18T10:35:59.000Z","size":42,"stargazers_count":57,"open_issues_count":6,"forks_count":17,"subscribers_count":16,"default_branch":"master","last_synced_at":"2024-10-12T08:29:19.775Z","etag":null,"topics":["gulp","gulp-plugins","office365","sharepoint","sharepoint-online","spfx"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wictorwilen.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-10-30T06:46:46.000Z","updated_at":"2023-08-30T19:22:10.000Z","dependencies_parsed_at":"2022-08-28T21:41:48.482Z","dependency_job_id":null,"html_url":"https://github.com/wictorwilen/gulp-spsync","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wictorwilen%2Fgulp-spsync","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wictorwilen%2Fgulp-spsync/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wictorwilen%2Fgulp-spsync/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wictorwilen%2Fgulp-spsync/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wictorwilen","download_url":"https://codeload.github.com/wictorwilen/gulp-spsync/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221666413,"owners_count":16860415,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gulp","gulp-plugins","office365","sharepoint","sharepoint-online","spfx"],"created_at":"2024-08-03T08:00:35.320Z","updated_at":"2026-03-11T18:33:21.342Z","avatar_url":"https://github.com/wictorwilen.png","language":"JavaScript","funding_links":[],"categories":["Tools"],"sub_categories":["Samples"],"readme":"# gulp-spsync\nGulp plugin for synchronizing local files with a SharePoint library\n\n# Features\n \n* Gulp plugin\n* Copies local files to a SharePoint Document libraries and galleries\n\n# How to use\n\n1. Prepare SharePoint by registering a SharePoint app using appregnew.aspx. Eg go to https://contoso.sharepoint.com/sites/site/_layouts/15/appregnew.aspx\n2. Click on Generate for both Client Id and Client Secret. For Title, App Domain and Redirect URI, write something you don't care about. Then click on Create\n3. Note down the Client Id and Client Secret, you will need it later\n4. Navigate to appinv.aspx, https://contoso.sharepoint.com/sites/site/_layouts/15/appinv.aspx, enter the client ID in the App Id box and press Lookup\n5. In the Permission Request XML text box enter the following XML and click Create (Note: `FullControl` is required to update assets in the Master Page gallery)  \n```xml\n\u003cAppPermissionRequests AllowAppOnlyPolicy=\"true\"\u003e\n    \u003cAppPermissionRequest\n        Scope=\"http://sharepoint/content/sitecollection/web\"\n        Right=\"FullControl\"/\u003e\n\u003c/AppPermissionRequests\u003e\n```\n6. In the following consent screen choose to trust the App by clicking on Trust It!\n7. Open a folder using Visual studio code\n8. Run `npm install gulp` to install the Gulp task runner\n9. Run `npm install gulp-spsync` to install to install the gulp-spsync \n10. Press Ctrl-Shift-P, type Task and choose to Configure Task Runner\n11. In the tasks.json file that is being created replace the contents with the following:\n```json\n{\n    \"version\": \"0.1.0\",\n    \"command\": \"gulp\",\n    \"isShellCommand\": true,\n    \"tasks\": [\n        {\n            \"taskName\": \"default\",\n            \"isBuildCommand\": true,\n            \"showOutput\": \"silent\"\n        }\n    ]\n}\t\n```\n12. Create a new file in the root of your folder called `gulpfile.js`, and modify it as follows. This task will monitor all files in the `Src` folder\n```javascript\nvar gulp = require('gulp')\nvar sp = require('gulp-spsync')\ngulp.task('default', function() {\nreturn gulp.src('src/**/*.*').\n    pipe(sp({\n        \"client_id\":\"3d271647-2e12-4ae5-9271-04b3aa67dcd3\",\n        \"client_secret\":\"Zk9ORywN0gaGljrtlxfp+s5vh7ZyWV4dRpOXCLjtl8U=\",\n        \"realm\" : \"\",\n        \"site\" : \"https://contoso.sharepoint.com/sites/site\",\n        \"verbose\": \"true\"\n    })).\t\t\n    pipe(gulp.dest('build'))\n})\n```\n13. Replace the client_id and client_secret parameters with the value for the App you just created\n14. Replace the site URL with your site URL\n15. Create a folder called `Src` (you can call it whatever you want, but the tasks above/below uses `Src`)\n16. Create sub folders to the `Src` folder where each Subfolder represents a Library in a site. You can alos create a subfolder called `_catalogs` and \nadd a subfolder to that one called `masterpage` if you want to sync files to the Master Page Gallery.\n17. Add files as you want to these folders\n18. Press Ctrl-Shift-B to Build and let Gulp and gulp-spsync upload the files to SharePoint\n\n# Using Gulp watchers\n\nYou can use Gulp watchers (gulp-watch) to upload files as they are changed. \nThe following `gulpfile.js` shows how to upload all files on build and then upload files incrementally when changed and saved.\n\nYou need to run `npm install gulp-watch` to install the Gulp watcher\n\n```javascript\nvar gulp = require('gulp')\nvar sp = require('gulp-spsync')\nvar watch = require('gulp-watch')\n\nvar settings = {\n\t\t\t\"client_id\":\"...\",\n\t\t\t\"client_secret\":\"...\",\n\t\t\t\"realm\" : \"\",\n\t\t\t\"site\" : \"https://contoso.sharepoint.com/sites/site\",\n\t\t\t\"verbose\": \"true\",\n\t\t\t\"watch\": true\n\t\t};\ngulp.task('default', function() {\n\treturn gulp.src('src/**/*.*')\n\t\t.pipe(watch('src/**/*.*'))\n\t\t.pipe(sp(settings))\t\t\n\t\t.pipe(gulp.dest('build'))\n})\n\n```\n# Setting metadata for files\nIf you're files require metadata to be set when they are uploaded, you can pass in a metadata options (update_metadata, files_metadata).\n\n**Example:**\n```javascript\nvar fileMetadata = [\n    {\n        name: 'Item_Minimal.js',\n        metadata: {\n            \"__metadata\": { type: \"SP.Data.OData__x005f_catalogs_x002f_masterpageItem\" },\n            Title: 'Item Minimal Template (via GULP)',\n            MasterPageDescription: 'This is a display template added via gulp.',\n            ManagedPropertyMapping: \"'Path','Title':'Title'\",\n            ContentTypeId: '0x0101002039C03B61C64EC4A04F5361F38510660500A0383064C59087438E649B7323C95AF6',\n            DisplayTemplateLevel: 'Item',\n            TargetControlType: {\n                \"__metadata\": {\n                    \"type\": \"Collection(Edm.String)\"\n                },\n                \"results\": [\n                    \"SearchResults\",\n                    \"Content Web Parts\"\n                ]\n            }\n        }\n    },\n    {\n        name: 'Control_Minimal.js',\n        metadata: {\n            \"__metadata\": { type: \"SP.Data.OData__x005f_catalogs_x002f_masterpageItem\" },\n            Title: 'Control Minimal Template (via GULP)',\n            MasterPageDescription: 'This is a display template added via gulp.',\n            ContentTypeId: '0x0101002039C03B61C64EC4A04F5361F38510660500A0383064C59087438E649B7323C95AF6',\n            DisplayTemplateLevel: 'Control',\n            TargetControlType: {\n                \"__metadata\": {\n                    \"type\": \"Collection(Edm.String)\"\n                },\n                \"results\": [\n                    \"SearchResults\",\n                    \"Content Web Parts\"\n                ]\n            }\n        }\n    }\n];\n\nvar settings = {\n    \"client_id\":\"...\",\n    \"client_secret\":\"...\",\n    \"realm\" : \"\",\n    \"site\" : \"https://contoso.sharepoint.com/sites/site\",\n    \"verbose\": true,\n    \"update_metadata\": true,\n    \"files_metadata\": fileMetadata\n};\n```\n\n# Publishing files\nBy setting the **publish** setting, you can specify to publish your files when they are uploaded to the site.\n\n```json\nvar settings = {\n    \"client_id\":\"...\",\n    \"client_secret\":\"...\",\n    \"realm\" : \"\",\n    \"site\" : \"https://contoso.sharepoint.com/sites/site\",\n    \"verbose\": true,\n    \"publish\": true\n};\n```\n\n# Using nested folders (new in 1.4.0)\n\nIf you're using nested folders or deep structures, you can choose the name of the \"start folder\", using the `startFolder` option. \nAssume you have your SharePoint files under `src/template1/_sp/_catalogs` and `src/template2/_sp/_catalogs/` then you can use `\"startFolder\"=\"_sp\"` to make sure that the first folder names are stripped.\n\n```javascript\nvar gulp = require('gulp')\nvar sp = require('gulp-spsync')\n\nvar settings = {\n\t\t\t\"client_id\":\"...\",\n\t\t\t\"client_secret\":\"...\",\n\t\t\t\"realm\" : \"\",\n\t\t\t\"site\" : \"https://contoso.sharepoint.com/sites/site\",\n\t\t\t\"verbose\": \"true\",\n            \"startFolder\":\"_sp\"\n\t\t};\ngulp.task('default', function() {\n\treturn gulp.src('src/**/_sp/**/*.*')\n\t\t.pipe(sp(settings))\t\t\n})\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwictorwilen%2Fgulp-spsync","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwictorwilen%2Fgulp-spsync","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwictorwilen%2Fgulp-spsync/lists"}