@ancademy/bespoke-cli v2.7.3
About
bespoke-cli provides several commands for developers to increase speed of developing games based on @ancademy/bespoke-xxx framework. It packs some tasks of webpack and file operation , and you can refer to source code in /src to custom your own task.
Install
npm i -g @ancademy/bespoke-cliCommands
Options:
-v --version output the version number
-h, --help display help for command
Commands:
init init base project structure
add add new sub game
dev dev a sub game
build build a sub game
extra extra util tasks
help [command] display help for commandStart
Init project
mkdir hello-bespoke
cd hello-bespoke
bespoke-cli init
# Input project name : hello-bespokeAdd first game
bespoke-cli add
# Input game namespace : openAuctionAs for the namespace, the first letter will be converted to uppercase,and then used as the game folder name. You can
freely modify it later in config.ts, and it will become the routing prefix of the game. When you modify it in '
config.ts', it can be shaped like '/auction/openAuction', as a multi-layer prefix.
Dev
Frontend
bespoke-cli -> choose game (OpenAuction) -> client -> HMRThe frontend code would be built by webpack-dev-server and served at port 8080 ,and HMR will be enabled when Y is selected.
Custom webpack config in config.ts:
export function updateWebpack(config) {
//update
return config;
}Backend
- Start
mongodbandredis. - Configure
mongodb,redisand other connection parameters in file.env. If.envdoes not exist, the server will connect to db with default configuration and automatically create.envon the first startup. - There are 2 ways to start the server :
- @ancademy/bespoke-cli
bespoke-cli -> choose game (OpenAuction) -> server -> HMR- Node(support IDE breakpoint debug)
The backend server would listen on port 8081, then refer to console log, browsenode --inspect -r ts-node/register OpenAuction\server.tshttp://ip:8081/OpenAuction. If you enabled HMR on both end, visit port 8080 instead, request other than js bundle would be forward to port 8081.
Visit
- Refer to console log, browse
http://ip:port/OpenAuction. - Register-free Experience(Teacher) -> (Password 111111) -> Create Room -> Configure room parameters -> Submit -> Automatically redirect to the room console page.
- Add Player (Player A) -> Click to open a new tab to play with the identity of this player.
Build
bespoke-cli build -> choose game (OpenAuction) -> dist/publishFrontend code would be packaged into namespace/dist,while backend into namespace/build. Compared with dist
, publish will upload the frontend bundle to Qiniu based on the keys in .env.
Deploy
- upload
package.json + dist + buildto remote server npm inode ./build/serve.js
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago