This is a documentation for Board Game Arena: play board games online !
Setting up BGA Development environment using VSCode: Difference between revisions
Victoria La (talk | contribs) |
Victoria La (talk | contribs) No edit summary |
||
Line 108: | Line 108: | ||
"skipCreate": false, | "skipCreate": false, | ||
"delete": true | "delete": true | ||
}, | |||
"watcher": { | |||
"files": "**/*.{js,css}", | |||
"autoUpload": true, | |||
"autoDelete": true | |||
} | } | ||
} | } | ||
</pre> | </pre> | ||
Note: you don't need watcher section if you don't use code generators, but its needed if you use typescript, scss or similar code generator tools. | |||
[[Category:Studio]] | [[Category:Studio]] |
Revision as of 23:52, 28 September 2022
Microsoft Visual Studio Code is light weight IDE/Editor. All desktops.
Downloads
- Download and install vscode from https://code.visualstudio.com
- Download and install php (7.4) command line interface (for local tests and debugging)
Extensions
- PHP Intelephense - https://marketplace.visualstudio.com/items?itemName=bmewburn.vscode-intelephense-client
- PHP Debug - https://marketplace.visualstudio.com/items?itemName=xdebug.php-debug
- SQL Tools - https://marketplace.visualstudio.com/items?itemName=mtxr.sqltools
- Prettier - code formatter - https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode
- SFTP (by Natizyskunk) - https://marketplace.visualstudio.com/items?itemName=Natizyskunk.sftp
JavaScript:
Because of dojo style class/method declarations most IDE won't be able to index main JavaScript file properly (i.e. go to definition of function and such). If you manage to have it working in VS code some-how let us know how.
There is way to re-structure code to avoid using this style but this is not for begginers, do not use this on your first game! https://en.doc.boardgamearena.com/BGA_Studio_Cookbook#Avoiding_code_in_dojo_declare_style
Complete example also in "dojoless" project, it also includes typescript definition file (.d.ts) (not complete) for auto-completion of js BGA interfaces https://github.com/elaskavaia/bga-dojoless
PHP:
You can shut up undefined symbols errors in PHP if you setup fake project refernce to BGA stubs
- git clone git@github.com:elaskavaia/bga-sharedcode.git
- add refrence to bga-sharedcode/misc/module
If you using intellephense plugin add this to settings (modify the path obviously)
"intelephense.environment.includePaths": [ "/home/victoria/git/bga-sharedcode/misc/module/" ],
File Sync
You might rely on your IDE to sync the files with the SFTP server. Each time you "save" a file with your modifications, the IDE will also submit it to the sFTP server. These are instructions for VS Code
- Install this extension https://marketplace.visualstudio.com/items?itemName=Natizyskunk.sftp (File->Preferences->Extensions ... type SFTP and make sure its by Natizyskunk)
- Open VSCode on an empty folder that will be the local root of your project.
- Execute Ctrl+Shift+P on Windows/Linux or Cmd+Shift+P on Mac to open the command palette, and the type/run : "SFTP: config" - the edit will open with json config
- Update the json as below:
{ "name": "BGA", "host": "1.studio.boardgamearena.com", "protocol": "sftp", "port": 22, "username": "<your SFTP username>", "password": "<your SFTP password>", "remotePath": "/<your project name>/", "uploadOnSave": true, "ignore": [ ".vscode", ".git", ".DS_Store" ], "syncOption": { "skipCreate": false, # syncs new files "delete": true # syncs deleted files } }
- Execute Ctrl+Shift+P on Windows/Linux or Cmd+Shift+P on Mac to open the command palette, and the type/run : "SFTP: Download Project".
This will download all the files locally, and each time you modify/save a file in VSCode, it will upload it to the SFTP Server. To force upload to a server, execute Ctrl+Shift+P -> "SFTP: Sync Local -> Remote".
Note: the SFTP sync may fail with a permissions error when create or delete nested folders. To fix this, execute `chmod 755 -R <your directory name>` in your terminal, then force sync to remote.
If you want to commit this file to version control, use private key (see other wiki for steps on how to enable private key on bga) instead and move user/password settings vscode user settings I.e. in user setting add this (have to edit settings.js manually, google for location its os specific)
"remotefs.remote": { "bgadev": { "name": "BGA", "host": "1.studio.boardgamearena.com", "protocol": "sftp", "port": 22, "username": "<yourdevusername>", "privateKeyPath": "~/.ssh/id_rsa", }, }
in project folder sftp.json
{ "remote": "bgadev", "remotePath": "/<yourproject>/", "uploadOnSave": true, "ignore": [ ".git" ], "syncOption": { "skipCreate": false, "delete": true }, "watcher": { "files": "**/*.{js,css}", "autoUpload": true, "autoDelete": true } }
Note: you don't need watcher section if you don't use code generators, but its needed if you use typescript, scss or similar code generator tools.