playcanvas / playcanvas-sync

Real-time synchronization of files between PlayCanvas and your local machine
https://playcanvas.com/
MIT License
75 stars 18 forks source link

pcwatch has stopped working #43

Closed jelling closed 2 years ago

jelling commented 2 years ago

pcwatch has stopped working for me after changing PLAYCANVAS_TARGET_DIR to a new dir. Rebooting and reinstalling playcanvas-sync also has not fixed the issue.

Here's the log:

➜  foo rm -rf *.*
➜  foo pcsync pullAll
---- Remote Files Missing on Local ----
scripts/api/api.js
scripts/api/mockApi.js
scripts/background/background.js
scripts/background/gradient.css
scripts/colorPicker/colorPicker.html
scripts/colorPicker/colorPicker.js
scripts/colorPicker/colorPickerButton.js
scripts/imagePicker/imagePicker.html
scripts/imagePicker/imagePicker.js
scripts/imagePicker/imagePickerButton.js
scripts/lib/keyboard-input.js
scripts/lib/mouse-input.js
scripts/lib/orbit-camera.js
scripts/lib/touch-input.js
scripts/memberCard.js
scripts/ticker/ticker.css
scripts/ticker/ticker.html
scripts/ticker/ticker.js
Proceed? [y/n] y
Created scripts
Created scripts/api
Created scripts/background
Created scripts/colorPicker
Created scripts/imagePicker
Created scripts/lib
Created scripts/ticker
Created scripts/background/background.js
Created scripts/memberCard.js
Created scripts/background/gradient.css
Created scripts/ticker/ticker.js
Created scripts/ticker/ticker.css
Created scripts/lib/keyboard-input.js
Created scripts/lib/touch-input.js
Created scripts/lib/orbit-camera.js
Created scripts/lib/mouse-input.js
Created scripts/api/mockApi.js
Created scripts/api/api.js
Created scripts/ticker/ticker.html
Created scripts/imagePicker/imagePicker.js
Created scripts/colorPicker/colorPicker.js
Created scripts/colorPicker/colorPickerButton.js
Created scripts/imagePicker/imagePickerButton.js
Created scripts/imagePicker/imagePicker.html
Created scripts/colorPicker/colorPicker.html
➜  foo ls 
scripts
➜  foo PLAYCANVAS_VERBOSE=1 pcwatch
PLAYCANVAS_API_KEY:  {removed}
PLAYCANVAS_BASE_URL: https://playcanvas.com
PLAYCANVAS_PROJECT_ID: {removed}
PLAYCANVAS_BRANCH_ID: {removed}
PLAYCANVAS_TARGET_DIR: /Users/JEllin/dev/foo
PLAYCANVAS_BAD_FILE_REG: /^\.|~$|jsconfig.json/
PLAYCANVAS_BAD_FOLDER_REG: /^\.|typings|build|/
PLAYCANVAS_USE_CWD_AS_TARGET: undefined
PLAYCANVAS_TARGET_SUBDIR: undefined
PLAYCANVAS_INCLUDE_REG: undefined
PLAYCANVAS_FORCE_REG: undefined
PLAYCANVAS_DRY_RUN: undefined
PLAYCANVAS_VERBOSE: 1
---- Remote Files Missing on Local ----
scripts/api/api.js
scripts/api/mockApi.js
scripts/background/background.js
scripts/background/gradient.css
scripts/colorPicker/colorPicker.html
scripts/colorPicker/colorPicker.js
scripts/colorPicker/colorPickerButton.js
scripts/imagePicker/imagePicker.html
scripts/imagePicker/imagePicker.js
scripts/imagePicker/imagePickerButton.js
scripts/lib/keyboard-input.js
scripts/lib/mouse-input.js
scripts/lib/orbit-camera.js
scripts/lib/touch-input.js
scripts/memberCard.js
scripts/ticker/ticker.css
scripts/ticker/ticker.html
scripts/ticker/ticker.js
Differences found between local and remote. Use 'pcsync' to fix or use '--force' to skip this check
querielo commented 2 years ago

@jelling There are two options: 1) "Use 'pcsync' to fix ...". So, you can call pcsync pullAll to download all remote files from Playcanvas Editor (WARNING: it overwrites local files). And only after it call pcwatch 2) "... use '--force' to skip this check". For example, pcwatch --force. In this case, local files are uploaded to Playcanvas Editor, but there are some remote files in Editor that are not in your local repo (so, also be careful careful with it).

jelling commented 2 years ago

@querielo as you can see in the log above, I ran pcsync pullAll but after that I still get the "differences found" error. That shouldn't be, should it?

And then when I run pcwatch --force afterwards, changes on local are not synced to remote.

Is there a cache somewhere that's possibly corrupted? Or is there possibly an issue with this project in specific?

yaustar commented 2 years ago

@jelling Would you be able to share the following please to help us reproduce?

zachpeterpaul commented 2 years ago

please also provide a full path to your target directory and the directory where playcanvas-sync is installed. Did it all work correctly in another target directory? Does your project have a pcconfig.json file? Do you use environment variables? After pullAll, please check if individual files are correctly downloaded to your computer, e.g. whether you can open a script file. From our past experience, the most likely cause of your issue is incorrect configuration.

yaustar commented 2 years ago

I've tried to reproduce this with the following setup on a Mac with pc-sync installed globally

.pcconfig in the home directory

{
  "PLAYCANVAS_API_KEY": "XXXX",
  "PLAYCANVAS_TARGET_DIR": "/Users/stevenyau/Snapchat/Dev/bitmoji-library",
  "PLAYCANVAS_BAD_FILE_REG": "^\\.|~$|pcconfig\\.json",
  "PLAYCANVAS_BAD_FOLDER_REG": "\\."
}

A project in /Users/stevenyau/Snapchat/Dev/bitmoji-library with a pcconfig.json file

{
  "PLAYCANVAS_BRANCH_ID": "40ddb1ac-58d3-40b9-8c6e-a091a29175eb",
  "PLAYCANVAS_PROJECT_ID": 721733
}

And a different project in /Users/stevenyau/Snapchat/Dev/bitmoji-plaza

{
  "PLAYCANVAS_BRANCH_ID": "c96f8dff-b9b9-4369-9540-62ee398ff1f8",
  "PLAYCANVAS_PROJECT_ID": 681065
}

And doing the following on command line:

~% pcsync pullAll
~% pcwatch

Change a text file to check it syncs correctly. Change ~/.pcconfig PLAYCANVAS_TARGET_DIR to the other project

And doing the following on command line:

~% pcsync pullAll
~% pcwatch

Change a text file to check it syncs correctly.

I've not yet run into the issue that you've hit @jelling.

Do you have different setup to this?

yaustar commented 2 years ago

I also tried having all the setup in ~/.pcconfig

{
  "PLAYCANVAS_API_KEY": "XXXXXX",
  "PLAYCANVAS_TARGET_DIR": "/Users/stevenyau/Snapchat/Dev/test-folder-one",
  "PLAYCANVAS_BAD_FILE_REG": "^\\.|~$|pcconfig\\.json",
  "PLAYCANVAS_BAD_FOLDER_REG": "\\.",
  "PLAYCANVAS_BRANCH_ID": "40ddb1ac-58d3-40b9-8c6e-a091a29175eb",
  "PLAYCANVAS_PROJECT_ID": 721733
}

And did the same thing with two empty folders, switching the PLAYCANVAS_TARGET_DIR several times and going through the pcsync pullAll, pcwatch process with no issues either

yaustar commented 2 years ago

@zachpeterpaul Is there any caching of files/synced files/etc for pcsync that we could try to clear out here?

yaustar commented 2 years ago

Spoke to Zach and there's no state for pc-sync that it stores.

@jelling You did mention in a DM that your company has some IT policies in place and we were wondering if the new target directory was preventing pcwatch from traversing the directory structure? Could you try a different target directory that is similar to the previous?

If you changed the target directory back to the original path, does it work or gives the same error?

yaustar commented 2 years ago

Reproduced with configs that the client has given me

zachpeterpaul commented 2 years ago

The issue was caused by the final pipe | in PLAYCANVAS_BAD_FOLDER_REG in the provided config file, which made the regex match everything. With it removed, both sync and watch should work correctly with that project. There are PLAYCANVAS_DRY_RUN and PLAYCANVAS_VERBOSE env vars for checking what gets matched by current config regex's

yaustar commented 2 years ago

Confirmed fixed by OP