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

Feature Request: Watch for SPGo.json Updates #34

Closed ChrisRomp closed 6 years ago

ChrisRomp commented 6 years ago

My team uses different branches for different environments. It's nice that we can have different SP site URLs in SPGo.json, but when we switch environments SPGo is still caching the previous URL. If it could check the sharePointSiteUrl parameter before an operation (ok to assume the security model/context is the same, IMO), that would enable us to switch environments without having to reload VS Code.

sg-chrishasz commented 6 years ago

Hello @ChrisRomp !

SPGo should automatically refresh the in-memory config object any time a change made to the SPGo.json. The only thing that would cause the config file to not refresh would be a file schema error, or possibly some issue where SPGo is not correctly parsing the new config data.

Repro Steps

  1. open SPGo.
  2. update a file.
  3. save the file to the server (either by ctrl+s or using the publishing controls)
  4. verify the file was saved to the correct SharePoint site specified in the config.
  5. update SPGo.json, enter the URL of a different SharePoint site.
  6. save the SPGo.json file - ensure there are no errors in the output log.
  7. save/publish the file again
  8. verify if the file was saved to the original SharePoint site, or the new site specified in SPGO.json

Also, if you are still seeing the issue after following the steps above, can you look in the output window for all items scoped to SPGo and send any errors you see? Can you share your config file (feel free to mask customer data)?

ChrisRomp commented 6 years ago

@sg-chrishasz,

I'm using the default schema except I've added a remoteFolders section.

I have two site collections, let's call them "QA" and "Prod." In QA the SPGo.json file has sharePointSiteUrl set to https://tenant.sharepoint.com/sites/qa and in prod it's .../prod.

I will have (for example) a config.js file on the SharePoint server that has something specific to its environment, let's say a URL. If I open VSCode with the QA branch checked out, and then compare the file to the server, it is correct.

Then if in git I check-out the prod branch, the sharePointSiteUrl changes to .../prod. If I run a "compare with server" the system queries the QA server for config.js and highlights the differences between them. I can open SPGo.json, make an arbitrary change like hitting space then backspace, save it, and then it seems to pick up the change and my comparison will check the config.js file in prod.

So it seems that for whatever reason SPGo isn't "noticing" the change in SPGo.json when it happens via git (even though VSCode does show the update in the code editor).

From the console, no errors are reported that appear related to this (there are some other misc. messages related to not finding config.js.git when I open config.js, for example). When I git checkout the prod branch, nothing appears in the SPGo console, however then when I hit space/backspace and hit save, Configuration file reloaded is printed, seeming to verify my hypothesis that SPGo isn't reloading on git checkout.

Thanks!

sg-chrishasz commented 6 years ago

Thanks for the thorough repro steps. SPGo currently reloads the config file only if it is edited inside VSCode. Any external program (e.g. git) that makes changes directly to the file will not be reflected immediately immediately inside of VSCode.

I will need to rebuild the configuration object to support live reloads, but I can make this change. That said, I like caching the object internally as an optimization, so I may add that as a configurable parameter later if people begin experiencing performance issues.

ChrisRomp commented 6 years ago

Maybe better is to have a command that will reload the config. Is there already one?

sg-chrishasz commented 6 years ago

I like that option better. I do not have a command yet, but it is easy to add (and has a much smaller blast-radius than a rewrite of the config file). Here is what I'm thinking:

command: SPGO> Reload Configuration shortcut: <alt>+r, <alt>+c

ChrisRomp commented 6 years ago

Sounds great!

sg-chrishasz commented 6 years ago

Done - SPGO 1.2.4 has been published to VS Marketplace.

I appreciate the feedback and support!