@ancademy/bespoke-cli
v2.7.3
Published
**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.
Downloads
61
Readme
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-cli
Commands
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 command
Start
Init project
mkdir hello-bespoke
cd hello-bespoke
bespoke-cli init
# Input project name : hello-bespoke
Add first game
bespoke-cli add
# Input game namespace : openAuction
As 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 -> HMR
The 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
mongodb
andredis
. - Configure
mongodb
,redis
and other connection parameters in file.env
. If.env
does not exist, the server will connect to db with default configuration and automatically create.env
on 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.ts
http://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/publish
Frontend 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 + build
to remote server npm i
node ./build/serve.js