Giter Club home page Giter Club logo

playcanvas-sync's Introduction

Overview

The pcsync and pcwatch utilities allow editing copies of JavaScript and other textual files of a PlayCanvas project locally on your own computer, in a text editor of your choice.

pcsync also allows pushing and pulling of binary files, such as images and models.

In addition, if your project has a file called pcignore.txt, PlayCanvas merge will not affect the files listed in it, and the operation of pcsync and pcwatch will be restricted only to those files.

pcsync is used to push or pull one or all files to or from PlayCanvas (overwriting existing files with the same name/path) and to compare one or all local files to their remote (PlayCanvas) versions.

pcwatch detects changes to local files and folders (edits, removals and creation) as they happen and applies them to PlayCanvas in real time.

If you do not need your local changes pushed to PlayCanvas "as you type", you do not have to use pcwatch. Running pcsync pushAll periodically can be sufficient.

Only the pcsync pull and pcsync pullAll commands can change local files. Other pcsync commands and pcwatch change only remote files. Thus your local directory holds the authoritative version of your textual files.

The only scenario we do not support is when developer A uses pcwatch, while developer B is editing files of the same PlayCanvas branch in the browser code editor. B's work will be overwritten by A, if they edit the same file. Either B should start using local files, or A should stop pcwatch and switch to the browser code editor.

The pcsync Utility

pcsync has the following commands:

  diffAll                     compare all local and remote files and folders
  diff <filePath>             show line-by-line diff of the remote and local files at
                              filePath
  pullAll                     download all remote files, overwriting their local
                              counterparts
  pushAll                     upload all local files, overwriting their remote counterparts
  pull <filePath>             download remote file, creating local folders if needed
  push <filePath>             upload local file, creating remote folders if needed
  rename <oldPath> <newPath>  rename remote file or folder, change its parent folder if
                              needed
  rm <filePath>               remove remote file or folder
  parseIgnore                 list assets matched by pcignore.txt

A local directory designated as PLAYCANVAS_TARGET_DIR corresponds to the root of the PlayCanvas file and folder asset hierarchy.

All file and folder paths passed to pcsync as arguments should be relative to this root and use forward slashes even on Windows, e.g.

pcsync rename dir1/file1.js file1.js

will move file1.js to the root asset directory.

pushAll and pullAll accept an optional -y or --yes flag to automatically answer "yes" to confirmation prompts.

The pcwatch Utility

pcwatch does not need any options.

Moving or renaming a file or a folder will appear to pcwatch as a remove + create. In such cases it may be better to stop pcwatch, perform the operation locally, apply it to PlayCanvas with pcsync rename, and start pcwatch again.

Adding New Files as Script Components

Assume file F was created locally and pushed to PlayCanvas with pcsync or pcwatch, and now you are adding F as a script component to an entity in PlayCanvas Editor.

Note that it will take a second or two for F to appear in the dropdown list, because F is parsed by the editor for the first time when that list is populated (we may add some progress indication for that).

The pcignore.txt File

If your project has a file called pcignore.txt in the root folder, any file listed there will be the same before and after a PlayCanvas merge.

The operation of pcsync and pcwatch is restricted to the files listed in pcignore.txt, if pcignore.txt exists. This ensures that the set of files managed locally exactly matches the set ignored by PlayCanvas merge, which is appropriate for most workflows.

To make pcsync and pcwatch work with more files than listed in pcignore.txt, use the PLAYCANVAS_INCLUDE_REG config variable, which is a regular expression to test each file's path from the root of the asset hierarchy.

Before a PlayCanvas merge, make sure that the latest checkpoint of the destination branch is taken after pcignore.txt was added.

If you are using git for your textual files, you can perform a git merge before a PlayCanvas merge of the corresponding branches, push the result to the PlayCanvas destination branch, and then perform a PlayCanvas merge.

pcignore.txt Syntax

pcignore.txt consists of one or more lines, each of which is either a path (with the same syntax as .gitignore), or one of the following:

ignore_all_textual_files
ignore_all_js_files
ignore_all_files_with_extension <extension1,extension2,...>
ignore_regexp <regexp string>
source_branch_wins

ignore_all_textual_files is the most common choice.

source_branch_wins (included once anywhere) changes the PlayCanvas merge behavior: instead of keeping items matching pcignore.txt as is (in the destination branch), the merge result will now include the versions of the corresponding items (if present) from the source branch.

Multiple ignore_regexp lines can be provided. Any textual asset whose path from the root of the asset hierarchy matches an ignore_regexp expression will be ignored.

To check your pcignore.txt syntax, you can run pcsync parseIgnore. It will list all existing files that match your current pcignore.txt.

Use a space and not * or ? to match a space in a file or folder name in gitignore lines.

Using pcsync for Binary Files

Binary files include assets such as textures (JPG and PNG) and models (GLB).

push, pull (single file) and rm work with binary file arguments without any special options.

pushAll, pullAll and diffAll have two options that make them work with matching files only, including binary (without one of these options pcsync only works with textual files):

  -e, --ext <extensions>  handle files with provided extensions
  -r, --regexp <regexp>   handle files matching the provided regular expression

For instance:

pcsync diffAll -e jpeg,png
pcsync pushAll -r "\\.(png|jpeg)"

The regular expression tests each file's path from the root.

Installation

Use a recent stable version of node. We recommend using nvm.

Download or clone https://github.com/playcanvas/playcanvas-sync

On a Mac, install Command Line Tools. On Catalina, you may also need:

sudo xcode-select -s /Applications/Xcode.app/Contents/Developer

From the playcanvas-sync folder run:

npm install

Now set your config variables and you can use the tool from this folder, e.g.

node pcwatch.js diffAll

or install it globally with:

npm install -g

To uninstall globally, run

npm uninstall -g

(all from the playcanvas-sync folder).

Config Variables

Config variables can be set in a file called .pcconfig in your home directory, in pcconfig.json in your target directory (and your remote PlayCanvas branch), or provided as environment variables (which would have the highest precedence).

Sample config file:

{
  "PLAYCANVAS_BRANCH_ID": "abc",
  "PLAYCANVAS_PROJECT_ID": 10,
  "PLAYCANVAS_TARGET_DIR": "/Users/zpaul/proj1",
  "PLAYCANVAS_API_KEY": "xyz",
  "PLAYCANVAS_BAD_FILE_REG": "^\\.|~$",
  "PLAYCANVAS_BAD_FOLDER_REG": "\\.",
  "PLAYCANVAS_CONVERT_TO_POW2": 0
}

You can get your api key (token) from your PlayCanvas account page (playcanvas.com/<username>/account).

You can use

copy({
  PLAYCANVAS_BRANCH_ID: config.self.branch.id,
  PLAYCANVAS_PROJECT_ID: config.project.id
})

from the Chrome Developer Tools console (on the PlayCanvas Editor page) to copy your branch and project id to the clipboard.

Alternatively, you can get your branch id from the Version Control Panel of the PlayCanvas Editor, and your project id from its home page url, e.g. for playcanvas.com/project/10/overview/test_proj the id is 10.

All listed key-value pairs are necessary. You can split them between .pcconfig (in your home directory), pcconfig.json (in your project target directory), and environment variables.

PLAYCANVAS_TARGET_DIR can only be set in .pcconfig or an environment variable. You can also set PLAYCANVAS_USE_CWD_AS_TARGET to 1 in .pcconfig to use your current working directory as your target.

For some workflows, it may be necessary to keep the pcconfig.json file at the top level in the target directory, but treat one of its subdirectories as the root of the local file hierarchy. In such cases PLAYCANVAS_TARGET_SUBDIR needs to be provided, e.g.

"PLAYCANVAS_TARGET_SUBDIR": "src"

Backslash characters should be written as \\ (escaped).

Files and Folders to Exclude

Many text editors and operating systems create local auxiliary files and directories, that do not need to be automatically pushed to PlayCanvas.

PLAYCANVAS_BAD_FILE_REG and PLAYCANVAS_BAD_FOLDER_REG contain RegExp strings (note the escapes) that tell pcwatch which files and directories to ignore. In our sample .pcconfig, a bad file has a name that starts with a dot or ends with ~. A bad folder is one that has a dot anywhere in its path relative to PLAYCANVAS_TARGET_DIR. The expressions provided are sufficient in most cases, and you can simply copy them into your .pcconfig.

To determine which auxiliary files and folders your OS and text editor create, run pcwatch with config/environment variables PLAYCANVAS_DRY_RUN and PLAYCANVAS_VERBOSE set to 1, and create/edit some files.

pcwatch output will show all file system events as they happen, and which of them will be filtered out by your current PLAYCANVAS_BAD_FILE_REG and PLAYCANVAS_BAD_FOLDER_REG.

If in your case no bad files and folders exist, use a string like "matchNothing" as the value of PLAYCANVAS_BAD_FILE_REG and/or PLAYCANVAS_BAD_FOLDER_REG.

Troubleshooting

Problems are often caused by setting config variables incorrectly. Execute your command with the config/environment variable PLAYCANVAS_VERBOSE set to 1 to print the current values of all config variables and other useful data.

Sample Workflows

Case 1: Single user per PlayCanvas branch, without git

  • Run pcsync pullAll to download existing textual files from PlayCanvas
  • Launch pcwatch
  • Start editing/creating files locally in your own text editor

To merge changes from another PlayCanvas branch into your branch without git:

  • Stop pcwatch
  • Run pcsync diffAll, and, if necessary, pcsync push/pushAll to make sure the PlayCanvas version is up-to-date.
  • Perform merge in PlayCanvas
  • Use pcsync pullAll to download the merge result

Case 2: Single user per PlayCanvas branch, with git

  • Create your own PlayCanvas branch of your team's project
  • Create a git branch for your work, and make it your local target directory
  • Create a pcignore.txt file, listing all files you intend to keep in git, create a PlayCanvas checkpoint that includes your pcignore.txt
  • Launch pcwatch
  • Start editing/creating files locally in your own text editor
  • When necessary, merge in git the branch of another group member into your branch
  • Use pcsync pushAll to update your remote branch after git merge
  • Merge the same branches in PlayCanvas
  • Use pcsync diffAll to verify that local and remote files are still in sync

Case 3: Multiple users working on the same PlayCanvas branch, with git

Most items from Case 1 apply, also:

  • Periodically run pcsync diffAll. It is usually OK to see extra remote files (coming from other team members). If you notice that a remote file is different from your local file, consider a git merge to include your team member's changes into your git branch, resolve conflicts in git, if any, as usual.
  • Avoid pcsync pull/pullAll. To get others' files/changes into your branch, use git merge instead to maintain an accurate git history of edits to each file (who added what).

Using TypeScript

TypeScript Bindings

You can build TypeScript Bindings from the PlayCanvas engine repo (branch stable) as mentioned in the instructions here:

npm run build:types

This will generate the file build/output/playcanvas.d.ts in your engine folder.

TypeScript Workflow

TypeScript source files are usually compiled into a single JavaScript file, which is then used in a PlayCanvas project.

This JavaScript file can be added to your pcignore.txt to prevent PlayCanvas merge from reporting conflicts in it.

If you are storing your TypeScript source files in git, there is no need to include them in your PlayCanvas project.

Setting up Visual Studio Code for local editing on Mac

Copy the file playcanvas.d.ts with TypeScript bindings for the PlayCanvas engine to a folder called typings in your target directory.

Create a jsconfig.json file in your target directory with the following content:

{
    "compilerOptions": {
        "target": "ES5",
        "module": "commonjs",
        "files": [
            "typings/playcanvas.d.ts"
        ]
    }
}

Your folder structure should look like this:

Add jsconfig.json and typings to PLAYCANVAS_BAD_FILE_REG and PLAYCANVAS_BAD_FOLDER_REG, e.g.

"PLAYCANVAS_BAD_FILE_REG": "^\\.|~$|jsconfig.json",
"PLAYCANVAS_BAD_FOLDER_REG": "^\\.|typings"

Now you are ready to start using pcsync and pcwatch to sync your PlayCanvas project and edit with VS Code goodness ๐Ÿš€

playcanvas-sync's People

Contributors

dependabot[bot] avatar figo2264 avatar isumygin-sc avatar mathiassoeholm avatar nyan-left avatar querielo avatar willeastcott avatar yaustar avatar zachpeterpaul 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  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  avatar

playcanvas-sync's Issues

pcwatch is very slow when a node_modules folder is present

Hi there ๐Ÿ‘‹

pcwatch seems like a fantastic tool, but it is currently too slow to be of very much use for me.
With verbose mode turned on, I noticed that it was traversing every single file in node_modules, and rightfully concluding that it should not apply that file to the remote.

It seems a bit weird that it has to check each file instead of just ignoring the folder completely. I have pcconfig.json with PLAYCANVAS_BAD_FOLDER_REG set to "node_modules".

If I delete my node_modules folder, it becomes significantly faster. It still seems to be traversing a bunch of files in the hidden .git directory, but it's at least usable.

Have I just misconfigured something, or is there any chance that an optimization can be made, such that it doesn't need to iterate over every file in the node_modules folder? :-)

Cannot read properties of null (reading 'hash')

Following error occurs when I

  • running pcwatch
  • delete all the codes of a file.
  • paste codes from clipboard
  • save it.
    Then the pcwatch process failed with whoe bunch of error message.

When I restart pcwatch, it fails with the following message.

TypeError: Cannot read properties of null (reading 'hash') at Object.sameHashAsRemote (C:\Projects\playcanvas-sync\src\utils\common-utils.js:179:40) at processTicksAndRejections (node:internal/process/task_queues:96:5) at async ComputeDiffAll.handleFileOnBoth (C:\Projects\playcanvas-sync\src\sync-commands\compute-diff-all.js:97:24) at async Promise.all (index 14) at async ComputeDiffAll.handleAllFiles (C:\Projects\playcanvas-sync\src\sync-commands\compute-diff-all.js:83:5) at async ComputeDiffAll.run (C:\Projects\playcanvas-sync\src\sync-commands\compute-diff-all.js:40:5) at async Object.reportDiffAll (C:\Projects\playcanvas-sync\src\sync-commands\sync-utils.js:10:19) at async Object.errorIfDifferent (C:\Projects\playcanvas-sync\src\sync-commands\sync-utils.js:79:19) at async Object.wrapUserErrors (C:\Projects\playcanvas-sync\src\utils\common-utils.js:112:20) at async run (C:\Projects\playcanvas-sync\pcwatch.js:20:9)

and the target file is hanging in the editor.
image

Watch: compare file hashes

Right now, playcanvas-sync watches on modification time of files. It causes a problem when files are overwritten but their content is not changed.

Right not we check file hashes if modification time is changed to be sure that we don't reupload non-changed files.

Mount instead of syncing

Is it possible to use the same API to mount the folder instead of syncing? Seems like a legit scenario for some use cases. Something WebDAV like?

Sync is kinda broken. (Company Project)

Hi.
I know this kinda general. Iยดll become more specific if needed.
I have been using PC Sync on a company project with my personal API token for around one week now.
These are some of the issues I have run into.

  • "pcsync diffAll" returns different results. More often than not it shows files missing on local that are already downloaded. I circle through the different results until i see one that I know is correct. -> Then only I use pcwatch

  • pcsync pullAll shows the same problems as diffAll. Pulling results sometimes in the correct hierarchy and sometimes in a complete mess of duplicate files in the root and more. I have for now memorized what files should be present at the bottom of the shown list and then only say yes to the pull.

  • pcwatch sometimes corrupts files. I had this happen 3 times by now. the pcwatch console shows some kind of "UnhandledPromiseRejectionWarning" or similar. Following saves to the local file will no longer sync. In the online editor the file is no longer able to open and must be deleted and then created again copy pasting the old code in there. Doesn't happen often still a problem :/

  • pcwatch once duplicated the ammo folder and its scripts as well as 3 other script files in various places. The console output showed pcwatch updating seemingly random files every second without me changing the file. This only happend once to me. Still a bit scary ^^

I hope those issues can somehow be resolved. PCSync is pure bliss and I will continue to use it besides those problems. (I know how to fix them most of the time). For now my workflow is deleting all synced files locally, circling through pullAll until I see the right files. When thats done I diffAll until it shows the right result and only then start pcwatch. If that is done it mostly works fine.

If any additional information is needed I will be happy to provide :)

Add .js.map to textual types

I would like to sync the *.js.map files as well.
Since they are not recognized as textual files, I cannot add them with ignore_all_files_with_extension either.

Cannot recognize diff

Hi, I was able to call pcsync pushAll to get all the files, however after any update, both pcwatch and pcsync diffAll cannot recognize the changes.

Am I missing something?

Feature Request - pcignore.txt works with `pushAll` and `pullAll` too

Right now, pcignore.txt seems to work only with PlayCanvas git merging. With pcignore.txt being somewhat based off .gitignore, I expected it would also ignore files when I ran pushAll or pullAll, but it does not. It would be nice if this was added.

Use-Cases

  • Prevent pushing a file like pcconfig.json
  • Hide some files or folders locally that maybe aren't ready for production, but I may want to add back into the project at a later date by updating the pcignore.txt

Currently, the only way to do this is to modify the PLAYCANVAS_BAD_FILE_REG to specify that file - ^\\.|~$|^pcconfig\\.json$

synced up and down, but not doing it any longer

So this was working for me (and oh my god is it better than just the web browser - so thanks!)

However,

now it's saying everything is up to date when I have a new file on the editor but not locally.
As a test I also added a new file locally and it still says the diff is nothing.

Installed from the main branch 2 days ago (so up to date and was working).

config:

PLAYCANVAS_API_KEY:<redacted>
PLAYCANVAS_BASE_URL: https://playcanvas.com
PLAYCANVAS_PROJECT_ID: 854449
PLAYCANVAS_BRANCH_ID: a7c38dfb-fdd8-408d-95bf-bf486b3fea2b
PLAYCANVAS_TARGET_DIR: /Users/tobowers/code/play-glad
PLAYCANVAS_BAD_FILE_REG: /^\.|~$/
PLAYCANVAS_BAD_FOLDER_REG: /\./
PLAYCANVAS_USE_CWD_AS_TARGET: undefined
PLAYCANVAS_INCLUDE_REG: undefined
PLAYCANVAS_FORCE_REG: undefined
PLAYCANVAS_DRY_RUN: undefined
PLAYCANVAS_VERBOSE: 1

Not sure if this is related or not but I created a checkpoint on the editor before it stopped working.

PCWatch can duplicate files and show weird behavior

PCWatch once duplicated the ammo folder and its scripts as well as 3 other script files in various places. The console output showed PCWatch updating seemingly random files every second without me changing the file. This only happend once to me.
Still a bit scary ^^

Add sub directory option to for pc-sync to pull and push from

This is so that there's a 'clean' folder for pc-sync to use for the PlayCanvas project that doesn't have node_modules, package.json etc files in a PLAYCANVAS_USE_CWD_AS_TARGET: 1 setup. It will just have the files from the PlayCanvas project

The setup would have ~/.pcconfig as

{
  "PLAYCANVAS_API_KEY": "XXXXXX",
  "PLAYCANVAS_USE_CWD_AS_TARGET": 1
}

In the project (CWD), the pcconfig.json would be

{
  "PLAYCANVAS_INCLUDE_REG": "Scripts/.*|.*\\.(html|js|json)$",
  "PLAYCANVAS_BRANCH_ID": "XXXXXX",
  "PLAYCANVAS_PROJECT_ID": XXXXXX,
  "PLAYCANVAS_CWD_SUBDIR": "src"
  "PLAYCANVAS_VERBOSE": 1
}

And pc-sync would push and pull files from the CWD/src directory

Where to put the target directory??

Error: could not find target directory: . Check capitalization.

I put .pcconfig in the playcanvas-sync-master folder, and set "PLAYCANVAS_TARGET_DIR": "/project"

And run node pcwatch.js diffAll

PCWatch sometimes corrupts files

I had this happen 3 times by now. The PCWatch console shows some kind of "UnhandledPromiseRejectionWarning" or similar. Following saves to the local file will no longer sync. In the online editor the file is no longer able to open and must be deleted and then created again copy pasting the old code in there.

pcwatch has stopped working

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

Project in npm registry

Related to this issue #30

We currently use this project as an npm module installed via the direct GitHub link. This causes deployment issues with CI/CD pipelines on npm v7 and later, where the deployment server requires an SSH key for public repositories. This is a known issue tracked here.

I published this playcanvas-sync repository to the npm registry without realizing it wouldn't associate the project with the Github owners. In hindsight that does make sense. I've invited the 'playcanvas' account to become a maintainer and eventual owner of the npm package, but wanted to open this line of dialogue here in case the maintainers would prefer alternative actions such as renaming the package or removing it altogether.

Option to disable confirmation prompt

I am trying to automate pcsync pushAll as a workaround while pcwatch is not working on Windows.
So far I've managed to call pcsync pushAll automatically, but I still need to confirm the upload with "y" every time.
It would be great to provide an option to skip the confirmation like -y or --headless.

Removing a folder locally removes the remote folder even if it contains assets.

Removing a folder locally removes the remote folder even if it contains assets.

Steps to reproduce:

  • Go into PlayCanvas and create a folder.
  • Put a template in it.
  • If you pullAll, the folder does not exist locally because there is no script in the folder, only a template.
  • Then put a script in the folder.
  • pullAll -> the folder exists with only a script in it.
  • pcwatch
  • Remove the folder locally.
  • Go into PlayCanvas on Google Chrome and the folder is removed even if it contains a template.
    I lost some templates because of this.

Not all asset types are supported

I am looking to use the approach described here https://github.com/playcanvas/playcanvas-sync#case-2-single-user-per-playcanvas-branch-with-git though am running into issues when trying to sync certain asset types, eg. material, animation graph. I feel that if we don't place all assets into the VCS of our choice we will have a nightmare of trying to keep our VCS branches in sync with PlayCanvas VCS. Can all asset type be supported? Do I not have the right approach?

C:\playcanvas\pc_test>pcsync pullAll -y -e js,cube,png,html,css,anim
C:\playcanvas\playcanvas-sync\src\api-client.js:85
    const name = asset.file.filename;
                            ^

TypeError: Cannot read properties of null (reading 'filename')
    at ApiClient.makeDownloadStream (C:\playcanvas\playcanvas-sync\src\api-client.js:85:29)
    at ApiClient.loadAssetToFile (C:\playcanvas\playcanvas-sync\src\api-client.js:73:25)
    at OverwriteAllLocalWithRemote.fetchFile (C:\playcanvas\playcanvas-sync\src\sync-commands\overwrite-all-local-with-remote.js:51:32)
    at OverwriteAllLocalWithRemote.handleAllFiles (C:\playcanvas\playcanvas-sync\src\sync-commands\overwrite-all-local-with-remote.js:44:24)
    at OverwriteAllLocalWithRemote.run (C:\playcanvas\playcanvas-sync\src\sync-commands\overwrite-all-local-with-remote.js:15:20)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

As CLI tool?

Any reason why this isnt simply a CLI tool on npm? Also why the explicit calling of node? This is kind of counter-intuitive to people coming from the web ecosystem.

I would also suggest having the user optionally explicity provide the config as it confused me and it seems to confuse others too (judging by the forum and issues).

A more usual / preferred developer experience would be:

  1. npm install playcanvas-sync -g
  2. playcanvas-sync -c my-config.json watchAll

Security Feature Request - Disallow Uploading of pcconfig.json with API Key

By default, if you have a pcconfig.json in your target directory, playcanvas-sync will want to upload that file when you run pcsync pushAll. You can also keep your API key inside that config file. If that happens, the user will be making their API key available to the world when the project is deployed.

I do like the idea of keeping the pcconfig.json paired with a project for consistency across development environments. So, instead of disabling the uploading of pcconfig.json all together, it would be nice if playcanvas-sync had a special case where it checks pcconfig.json for the API key property before it uploads.

I embarrassingly made this mistake, and I know PlayCanvas has a lot of younger users. So, getting ahead of this might be a good idea.

PCSync "diffAll" returns different results

More often than not diffAll shows files missing on local that are already downloaded.
I mostly circle through the different results until i see one that I know is correct.

When used with no local files it shows mostly two versions of the missing local files.

pcsync pullAll returns different results

pcsync pullAll shows the same problems as diffAll #9 . Pulling results sometimes in the correct hierarchy and sometimes in a complete mess of duplicate files in the root and more.
I have for now memorized what files should be present at the bottom of the shown list and then only say yes to the pull. This works areoudn every 3 times. (Pull -> see if its correct. If not delete local files -> try again)

Error: Missing config variable: PLAYCANVAS_API_KEY

Just started trying to use this tool and I'm getting this error that the api key is missing from the config. But, I definitely have the the api key in the config. I took the config from the README and just altered the values to match the ones for my project.

.pcconfig

 {                                                                                                                                                                                       
    "PLAYCANVAS_BRANCH_ID": "<branch id>",                                                                                                                       
    "PLAYCANVAS_PROJECT_ID": <project integer ID>,                                                                                                                                                      
    "PLAYCANVAS_TARGET_DIR": "<absolute path to files dir>",                                                                                           
    "PLAYCANVAS_API_KEY": "<api key generated by PlayCanvas>",                                                                                                                             
    "PLAYCANVAS_BAD_FILE_REG": "^\\.|~$",                                                                                                                                                 
    "PLAYCANVAS_BAD_FOLDER_REG": "\\."                                                                                                                                                    
  }

I tried setting an environment variable instead like the README said was possible, still no luck. Any ideas?

Platform: Ubuntu 20.04
NPM: 6.13.4
Node: 13.7.0

(Windows) pcconfig.json not read - pull cannot be performed

splitting the data between the .pcconfig file and pcconfig.json does not appear to work.
When I merge the content of the 2 files it does work (concluding that the data I have in there is correct and something else is wrong)

Code_AluidlOqaV

I would like to suggest a potential fix for this to allow node pcsync.js pull PROJECTID BRANCHID TARGET_DIR
This should allow a degree of freedom to the user so they can set up commands in their package.json to pull data without the need of the json file.

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.