chrishasz / spgo

SPGo: A Lightweight, Open Source, SharePoint IDE for Visual Studio Code
https://www.chrishasz.com/spgo
MIT License
60 stars 11 forks source link

Won't publish without Site Asset folder in directory #66

Closed simkessy closed 5 years ago

simkessy commented 5 years ago

Config:

{
    "sourceDirectory": "src",
    "sharePointSiteUrl": "https://mysite.sharepoint.com/sites/Demo",
    "publishingScope": "PublishMajor",
    "authenticationType": "Digest",
    "remoteFolders": ["/SiteAssets/"],
    "checkInMessage": "",
    "storeCredentials": true
}

image

I run "Public local workspace" and the output says:

Starting Workspace Publish...
Saving file:  c:\Users\me\OneDrive - me\projects\blue.sp\src\**\*.*
Workspace Publish complete.

But there's nothing in Site Assets. I was expecting there to be a folder called "bs.widgets" with all of the stuff I have in there.

simkessy commented 5 years ago

I can only get it to work if I have a "SiteAssets" folder in my directory which seems pretty strange.

image

sg-chrishasz commented 5 years ago

Hello @simkessy

The reason for this functionality is that SPGo needs to be able to map multiple directories, possibly across different SharePoint folders and libraries, to your local workspace. By replicating the site-relative paths, we can ensure that we know exactly where to store files on your local disk and remote sites.

I can see how this may be confusing for managing a single file/folder, but it is necessary in order to support site-wide customizations.

simkessy commented 5 years ago

@sg-chrishasz That's not in the documentation. For example the docs for Publish Local Workspace just says

Publish a major version of all files in the src folder to SharePoint

It doesn't specify that it needs to be Site Assets. What if I don't want to use Site Assets at all. I don't think you're explanation is correct.

sg-chrishasz commented 5 years ago

Hello @simkessy

I believe that you have confused two commands. The remoteFolders configuration parameter only controls which remote folders SPGo will download when you run the Populate Local Workspace command

When you run the Publish Local Workspace command, SPGo will attempt to upload all files and folders inside of the local /src/ folder to your SharePoint web, mimicing the directory structure within the /src/ folder.

Per your example, if you want SPGo to upload code files to a folder called bs.widgets, inside of the Site Assets library, then you would want to structure your local directory as follows:

src\
    SiteAssets\
        bs.widgets\
            <files...>

This is why, in your second post, the files uploaded to the correct directory.

If you want to synchronize files to multiple directories, you will need to either create the structure locally, - or use the Populate Local Workspace or Retrieve Folder commands to automatically download this content from SharePoint.

Here is an example of a local directory schema which would upload files to multiple different SharePoint folders when you execute the Publish Workspace command:

src\
    SiteAssets\
        bs.widgets\
            <files...>
    Style Library\
        bs.style\
            <files...>

This would place all files in your local /src/ directory the following SharePoint structure (assuming your SPGO.json configuration matches your first post): https://mysite.sharepoint.com/sites/Demo/SiteAssets/bs.widgets/<files> https://mysite.sharepoint.com/sites/Demo/Style Library/bs.style/<files>

Anyway, hope this clears up some of the confusion. Please feel free to reach out if you have further questions.