UNPKG

gamelet-cli

Version:

Download project from code.gamelet.com, edit/test in vscode and sync back to server.

117 lines (88 loc) 3.24 kB
# gamelet-cli Help to download project from code.gamelet.com, edit/test in vscode and sync back to server. ## Create Local Workspace of your CG Project You can download your CG project files to local and create a nice workspace of [VSCode](https://code.visualstudio.com/) to develop locally. ## Download Project Token File Before creating the workspace, you need to download a token file in your project page. 1. Open your project page on code.gamelet.com 2. Open the "Project Info" panel from the right-side toolbar. 3. Click the "Npm" button above the project code. 4. Toggle the "Allow local dev with npm" 5. Click the "Download dev-token" button to download ## Use the Project Token Make sure you have the token file in a proper folder, and the apps below are installed * [nodejs](https://nodejs.org/zh-tw/download/) * [npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) 1. Install gamelet-cli ```typescript npm install -g gamelet-cli ``` 2. Create workspace of your project Run the command in the folder of the token file: ```typescript gamelet download ``` Choose a token file when the command prompts you a list of choices. The command will create the workspace in a default folder that is named by the project code. If custom folder of workspace is desired, use the flag --dir ```typescript // assign a custom folder gamelet download --dir=testfolder // assign a token file and a folder gamelet download myProject.token --dir=testfolder ``` 3. Install npm packages ```typescript // enter the folder that is created from the above command cd your-project-folder-just-created // install packages npm install ``` 4. Transpile and run a local server ```typescript // one line command npm start ``` The command will transpile your typescripts and re-transpile when any file is changed. It also creates a local server so you can test the project at http://localhost:3000 5. Test and Debug Open the "Run and Debug" on the left-side-toolbar of your vscode, find and click the "Play Game" button to run the game. Change the button to "Test Module" to run the testbed. 6. Sync the workspace from the CG project After the workspace is built, you can run the below command to sync resources from your CG project on code.gamelet.com ```typescript // run the commands inside the workspace folder // sync everything and merge sources from CG gamelet merge // sync only sources gamelet merge --item=source // sync only sources without git commit gamelet merge --item=source --force // sync only resources gamelet merge --item=resource // sync items and badges gamelet merge --item=item,badge /** * available sync items are * - source * - resource * - item * - badge * - score */ ``` 7. Upload the sources back to CG Once you are satisfied with the codes, you can upload the source back to the CG server. Before uploading, make sure you have merge the latest sources from server by running the command "gamelet merge". ```typescript // run the commands inside the workspace folder // merge first gamelet merge // upload gamelet upload ```