Skip to content

Commit 41a3761

Browse files
committedFeb 5, 2020
lerna version v0.2.0
1 parent 75d8c84 commit 41a3761

File tree

10 files changed

+143
-156
lines changed

10 files changed

+143
-156
lines changed
 

‎.github/README.md

-20
This file was deleted.

‎README.md

+102-107
Original file line numberDiff line numberDiff line change
@@ -6,170 +6,165 @@
66

77
---
88

9-
<!-- # mini-shed -->
109

11-
12-
13-
<!-- 迷你屋是一个开放,高效的小游戏框架 -->
14-
15-
<!-- ## Table of Contents
16-
17-
- [koa-jwt](#koa-jwt)
18-
- [Table of Contents](#table-of-contents)
19-
- [Introduction](#introduction)
20-
- [Install](#install)
21-
- [Usage](#usage)
22-
- [Retrieving the token](#retrieving-the-token)
23-
- [Passing the secret](#passing-the-secret)
24-
- [Checking if the token is revoked](#checking-if-the-token-is-revoked)
25-
- [Example](#example)
26-
- [Token Verification Exceptions](#token-verification-exceptions)
27-
- [Related Modules](#related-modules)
28-
- [Tests](#tests)
29-
- [Author](#author)
30-
- [Credits](#credits)
31-
- [Contributors](#contributors)
32-
- [License](#license) -->
33-
34-
<!-- ## 简介
35-
36-
`mini-shed` 是一枚高效,开放,易扩展的微信小游戏框架。 -->
37-
38-
> mini-shed 正在独立开发中,有建议,想帮忙,想聊天的,都欢迎来骚扰我。[[联系方式]](https://nshen.net/about)
10+
> mini-shed 目前版本 v0.2,龟速独立开发中,有建议,想参与,想聊天的欢迎来[骚扰](https://nshen.net/about)
3911
4012
## 特性
4113

4214
- 基于前端流行技术 `TypeScript` 编写,`babel` + `rollup` 构建,用组合 `npm` 包的方式开发小游戏。
4315
-`VSCode` 中开发,`Chrome`浏览器中实时刷新调试,秒编译到各个小游戏平台。
4416
- 可发布 Web版`H5小游戏``微信/QQ小游戏``头条/抖音小游戏``OPPO/VIVO小游戏` 等快游戏平台。
45-
- 迷你的`Entity-Component-System` 架构,数据驱动,简单高效,独立`System`自由组合,易于扩展。
46-
- 没用`Adapter库`,原生`WebGL`高速渲染,跨小游戏平台统一API,专注于`小且快`
17+
- `Entity-Component-System` 架构,数据驱动,简单高效,独立`System`自由组合,易于扩展。
18+
- 专注于小且快,没用`Adapter库`,原生`WebGL`渲染,跨小游戏平台统一API。
4719

48-
# 快速开始
20+
## 快速开始
4921

50-
## 获取最新脚手架
22+
### 安装 `@shed/cli` 命令行工具
5123

52-
```
53-
git clone https://github.com/nshen/shed.git myGame
24+
迷你屋使用 `@shed/cli` 来创建,编译小游戏。
5425

55-
```
26+
- 用 npm 安装
5627

57-
## 然后进入目录
28+
```bash
29+
npm install -g @shed/cli
5830

59-
```
60-
cd myGame
31+
# 网络环境不好可安装淘宝镜像 cnpm,之后所有 npm 命令都用 cnpm 代替
32+
npm install -g cnpm --registry=https://registry.npm.taobao.org
33+
cnpm install -g @shed/cli
6134
```
6235

63-
## 安装 npm 依赖
36+
- 或用 yarn 安装
6437

65-
```
66-
npm install
38+
```bash
39+
yarn global add @shed/cli
6740
```
6841

69-
## 简单一条命令即可编译出小游戏
42+
打开命令行输入 `shed` 回车,如果安装成功会有提示信息。
7043

71-
```
72-
npm run build
73-
```
44+
### 创建一个新的小游戏
7445

75-
## 打开微信小游戏开发工具,导入游戏,选择 `dist` 子目录即可
46+
```bash
47+
> shed create myGame # 在当前目录下创建一个新游戏叫做 `myGame`
48+
```
49+
进入 `myGame` 目录,安装依赖
7650

77-
![create mini game](./create_minigame.png)
51+
```bash
52+
> cd myGame
53+
> npm install # 或者 yarn install
54+
```
7855

79-
# 迷你ECS架构
56+
### 实时编译Web预览
8057

81-
Entity Component System 是一个经典架构,`Shed.js` 根据JS语言特性实现了这个迷你版本
58+
`myGame` 目录中运行
8259

83-
## Component
60+
```bash
61+
> shed build h5 --watch
62+
```
8463

85-
`Component` **只有数据,没有方法。** 例如一个 `transform` 组件只是一个含 `type` 属性的 `Object`
64+
其他命令见 [@shed/cli](./packages/cli) 文档页
8665

87-
```typescript
88-
{ type: 'transform', x: 0, y: 0, rotation: 180 }
89-
```
66+
## 项目结构
9067

91-
## Entity
68+
整个项目是在 [Lerna](https://lerna.js.org/) 管理下的 monorepo。
9269

70+
mini-shed 中的包是标准的 npm 包,可按需组合,并不局限在下边的包,可自行扩展。
9371

94-
`Entity` 仅是一个有唯一 `id`**容器**,并且保存了一个 `Components` 表。
72+
#### 常用包
9573

96-
例如一个添加了 `transform 组件``render 组件``Entity` **可以想象成**
74+
| Package | Status | Description |
75+
|---------|--------|-------------|
76+
| [@shed/cli] | [![shed-cli-status]][@shed/cli-package] | 命令行工具,主要用来创建,编译小游戏,还提供一些辅助功能 |
77+
| [@shed/ecs] | [![shed-ecs-status]][@shed/ecs-package] | 开放的 `Entity-Component-System` 系统实现 |
78+
| [@shed/math] | [![shed-math-status]][@shed/math-package] | 数学支持库 Matrix,Vector 等|
79+
| [@shed/gl] | [![shed-gl-status]][@shed/gl-package] | 使`WebGL API` 简化的面向对象包装 |
80+
| [@shed/platform] | [![shed-platform-status]][@shed/platform-package] | 以微信小游戏为基准,统一各小游戏平台提供的`API`,并 `Promise`|
81+
| [@shed/utils] | [![shed-utils-status]][@shed/utils-package] | 一些实用类或函数 |
9782

98-
```typescript
99-
let entity = {
100-
id: 'Entity121',
101-
components: {
102-
'transform': { type: 'transform', x: 0, y: 0, rotation: 180 },
103-
'render': { image:'sprite.png' }
104-
}
105-
}
106-
```
83+
#### 默认demo包
10784

108-
## System
85+
| Package | Status | Description |
86+
|---------|--------|-------------|
87+
| [@shed/starter] | [![shed-starter-status]][@shed/starter-package] | 使用`shed create` 命令创建的默认demo |
10988

110-
System **只有方法,不存数据。** 以下是一个自定义 `System` 的写法
11189

112-
```typescript
90+
#### 新包模板
11391

114-
import { System } from "@shed/ecs";
92+
创建一个新包可以基于此修改
11593

116-
export class EmptySystem extends System {
94+
| Package | Status | Description |
95+
|---------|--------|-------------|
96+
| [@shed/new-package] | [![shed-new-package-status]][@shed/new-package-package] | 一个配置好`typescript`, `babel`, `rollup` 的模板包 |
11797

118-
update() {
98+
#### Systems
11999

120-
// write you code here
121-
}
122-
}
100+
`Entity Component System` 中的 `System` 可以独立成一个 `npm` 包存在,使得非常容易扩展。
123101

124-
```
102+
| Project | Status | Description |
103+
|---------|--------|-------------|
104+
| [@shed/render2d-system] | [![@shed/render2d-system-status]][@shed/render2d-system-package] | 2d渲染系统,它会尽量把所有 Entity 打包在一起一次渲染 |
125105

126-
一个 `System` 通常关注和操作一组指定类型的 `Entities`
127106

128-
例如一个 `RenderSystem` 就应该只关注同时含有 `render``transform` 组件的 `Entities`
107+
[@shed/render2d-system]: ./packages/render2d-system
108+
[@shed/render2d-system-status]: https://img.shields.io/npm/v/@shed/render2d-system.svg
109+
[@shed/render2d-system-package]: https://www.npmjs.com/package/@shed/render2d-system
129110

130-
确实 [@shed/render-system](https://github.com/nshen/shed-render-system) 就是这么做的。
131111

132-
这里可以看到,一个 `System` 可以发布成一个独立的 `npm包`。开发游戏时可以像拼插乐高一样按需安装系统。
112+
[@shed/cli]: ./packages/cli
113+
[@shed/ecs]: ./packages/ecs
114+
[@shed/math]: ./packages/math
115+
[@shed/gl]: ./packages/gl
116+
[@shed/platform]: ./packages/platform
117+
[@shed/utils]: ./packages/utils
118+
[@shed/starter]: ./packages/starter
119+
[@shed/new-package]: ./packages/new-package
133120

134-
`npm install shed-xxx-system`
121+
[shed-cli-status]: https://img.shields.io/npm/v/@shed/cli.svg
122+
[shed-ecs-status]: https://img.shields.io/npm/v/@shed/ecs.svg
123+
[shed-math-status]: https://img.shields.io/npm/v/@shed/math.svg
124+
[shed-gl-status]: https://img.shields.io/npm/v/@shed/gl.svg
125+
[shed-platform-status]: https://img.shields.io/npm/v/@shed/platform.svg
126+
[shed-utils-status]: https://img.shields.io/npm/v/@shed/utils.svg
127+
[shed-starter-status]: https://img.shields.io/npm/v/@shed/starter.svg
128+
[shed-new-package-status]: https://img.shields.io/npm/v/@shed/new-package.svg
135129

136-
这就是这个系统容易扩展的地方,更多信息请查看 [@shed/ecs](https://github.com/nshen/shed-ecs) 主页
130+
[@shed/cli-package]: https://www.npmjs.com/package/@shed/cli
131+
[@shed/ecs-package]: https://www.npmjs.com/package/@shed/ecs
132+
[@shed/math-package]: https://www.npmjs.com/package/@shed/math
133+
[@shed/gl-package]: https://www.npmjs.com/package/@shed/gl
134+
[@shed/platform-package]: https://www.npmjs.com/package/@shed/platform
135+
[@shed/utils-package]: https://www.npmjs.com/package/@shed/utils
136+
[@shed/starter-package]: https://www.npmjs.com/package/@shed/starter
137+
[@shed/new-package-package]: https://www.npmjs.com/package/@shed/new-package
137138

138139

139140

141+
## `.github` 文件夹
140142

141-
# 生态系统
143+
.github 文件夹内是 github actions ,用于发布`@shed/starter` 到国内镜像
142144

143-
## 每个游戏都需要的核心库
145+
### 触发
144146

145-
| Project | Status | Description |
146-
|---------|--------|-------------|
147-
| [@shed/ecs] | [![shed-ecs-status]][@shed/ecs-package] | 迷你 `Entity-Component-System` 系统 |
148-
| [@shed/math] | [![shed-math-status]][@shed/math-package] | Matrix,Vector 等数学支持库 |
149-
| [@shed/gl] | [![shed-gl-status]][@shed/gl-package] |`Webgl API` 更简洁的帮助库 |
147+
每次`push`源代码到 `github` 时,会触发此流程
150148

149+
### 发布 starter
151150

151+
`github actions`会自动把 `/packages/starter` 目录 ,强推到 `coding.net``gitee.com` 以下项目地址
152152

153-
[@shed/ecs]: https://github.com/nshen/shed-ecs
154-
[@shed/math]: https://github.com/nshen/shed-math
155-
[@shed/gl]: https://github.com/nshen/shed-gl
153+
- https://shed.coding.net/p/mini-shed-starter
154+
- https://gitee.com/nshen/mini-shed-starter
156155

157-
[shed-ecs-status]: https://img.shields.io/npm/v/@shed/ecs.svg
158-
[shed-math-status]: https://img.shields.io/npm/v/@shed/math.svg
159-
[shed-gl-status]: https://img.shields.io/npm/v/@shed/gl.svg
156+
使用`@shed/cli`命令行创建游戏时,实际上是从上边的地址clone下来的
160157

161-
[@shed/ecs-package]: https://www.npmjs.com/package/@shed/ecs
162-
[@shed/math-package]: https://www.npmjs.com/package/@shed/math
163-
[@shed/gl-package]: https://www.npmjs.com/package/@shed/gl
158+
```bash
159+
shed create myGame
160+
# 实际相当于
161+
# git clone https://e.coding.net/shed/mini-shed-starter.git myGame
162+
```
164163

165-
## Systems
164+
## Contributors
166165

167-
| Project | Status | Description |
168-
|---------|--------|-------------|
169-
| [@shed/render-system] | [![@shed/render-system-status]][@shed/render-system-package] | 高效的 2D Batching 渲染系统 |
166+
* [nshen](https://github.com/nshen)
170167

171-
[@shed/render-system]: https://github.com/nshen/shed-render-system
172-
[@shed/render-system-status]: https://img.shields.io/npm/v/@shed/render-system.svg
173-
[@shed/render-system-package]: https://www.npmjs.com/package/@shed/render-system
168+
## License
174169

175-
目前 `System` 生态比较贫乏,期待你的加入。
170+
[The MIT License](http://opensource.org/licenses/MIT)

‎packages/cli/README.md

+19-8
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,17 @@ shed -h # -h显示所有命令的 help 信息
2323

2424
## 用法
2525

26+
安装成功之后即可在命令行中调用`shed`命令,`shed -h` 查看帮助。
27+
2628
通常为 `shed` + `命令` + `--参数` 的方式使用命令行
2729

28-
### 创建一个新游戏
30+
## 所有命令
31+
32+
- `shed create <name>` [创建一个新的小游戏](###创建一个新的小游戏)
33+
- `shed build <platform>` [编译到小游戏平台](###编译到小游戏平台)
34+
- `shed spritesheet <folder>` [创建一个`spritesheet`](###创建一个`spritesheet`)
35+
- `shed fnt <file>` [fnt 格式转 json](###fnt-格式转-json)
36+
### 创建一个新的小游戏
2937

3038
```bash
3139
> shed create myGame # 在当前目录下创建一个新游戏叫做 `myGame`
@@ -59,12 +67,16 @@ shed -h # -h显示所有命令的 help 信息
5967

6068
通常调用后会发布到一个独立**文件夹**下,打开对应的**开发者工具**导入该**文件夹**,根据需要修改对应平台的参数。
6169

62-
### 创建一个 `spritesheet`
70+
各平台不同,且在发展之中,但大同小异,具体参数还需参看各[小游戏平台参考文档](###小游戏平台参考文档),做相应的修改。
71+
72+
### 创建一个`spritesheet`
73+
6374

64-
此命令需要提前安装 `ImageMagick 6.X`
6575

6676
命令为 `shed + spritesheet + 文件夹`
6777

78+
>此命令需要提前安装 [`ImageMagick 6.X`](https://imagemagick.org/download/releases/)
79+
6880
```bash
6981
> shed spritesheet ./images #将./images目录下所有图片打包成一个 spritesheet
7082
```
@@ -82,10 +94,10 @@ shed fnt ./myfont.fnt # 将./myfont.fnt 转换成 ./myfont.json
8294
shed -h
8395
```
8496

85-
## 小游戏平台文档
86-
87-
OPPO https://open.oppomobile.com/wiki/doc#id=10516
97+
## 小游戏平台参考文档
8898

99+
- OPPO https://open.oppomobile.com/wiki/doc#id=10516
100+
- 快应用 https://doc.quickapp.cn/framework/manifest.html
89101

90102
## Contributors
91103

@@ -96,6 +108,5 @@ OPPO https://open.oppomobile.com/wiki/doc#id=10516
96108
[The MIT License](http://opensource.org/licenses/MIT)
97109

98110

99-
Build
100-
快应用 https://doc.quickapp.cn/framework/manifest.html
111+
101112

‎packages/cli/src/commands/create.ts

+11-11
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ import * as fs from "fs-extra";
22
import { Logger } from "../helpers/log";
33
import path from 'path';
44
import chalk from "chalk";
5+
import { shouldUseYarn } from "../helpers/should-use-yarn";
56

67
const clone = require('git-clone');
78
const ora = require('ora');
89

9-
1010
let repositories: { [key: string]: string; } = {
1111
'coding': 'https://e.coding.net/shed/mini-shed-starter.git',
1212
'gitee': 'https://gitee.com/nshen/mini-shed-starter.git',
@@ -34,7 +34,7 @@ export async function create(name: string, r: string = 'coding') {
3434
clone(repo, name, async (err: any) => {
3535
if (err) {
3636
spinner.fail(`下载失败,请检查网络并重试。`);
37-
spinner.fail(`从 ${chalk.cyan(r)} 下载失败,请检查网络,或尝试 shed create ${name} ${r === 'github' ? 'coding' : 'github'}`);
37+
spinner.fail(`从 ${chalk.cyan(r)} 下载失败,请检查网络,或尝试 shed create ${name} ${r === 'gitee' ? 'coding' : 'gitee'}`);
3838
return;
3939
}
4040
try {
@@ -45,22 +45,22 @@ export async function create(name: string, r: string = 'coding') {
4545
console.error(error);
4646
}
4747
// TODO: copy to __dirname?
48-
spinner.succeed(`成功在 ${path.join(process.cwd(), name)} 中创建了 ${chalk.cyan(name)} 项目!`);
49-
console.log('在这个目录中,你可以调用以下命令:');
50-
console.log();
51-
console.log(chalk.cyan(' shed '));
48+
spinner.succeed(`成功在 ${chalk.cyan(path.join(process.cwd(), name))} 中创建了 ${chalk.cyan(name)} 项目!`);
49+
const useYarn = shouldUseYarn();
5250
console.log();
5351
console.log(`建议你现在输入:`);
54-
console.log(chalk.cyan(` cd ${name}`));
55-
console.log(chalk.cyan(` npm install`));
5652
console.log();
57-
console.log('发布小游戏请使用');
58-
Logger.command('npm run build');
53+
Logger.command(` cd ${name}`);
54+
useYarn ? Logger.command(` yarn install`) : Logger.command(` npm install`);
55+
console.log();
56+
console.log('依赖安装后,可用以下命令预览小游戏:');
57+
console.log();
58+
useYarn ? Logger.command('yarn dev') : Logger.command('npm run dev');
5959
});
6060

6161
}
6262

63-
let thingsYouCanDo: string[] = ['喝杯水', '冲杯茶', '冲杯咖啡', '吃块糖', '直直腰', '起立走走', '眺望远方', '闭目养神', '到处逛逛'];
63+
const thingsYouCanDo: string[] = ['喝杯水', '冲杯茶', '冲杯咖啡', '吃块糖', '直直腰', '起立走走', '眺望远方', '闭目养神', '到处逛逛', '提臀5次'];
6464
function randomThing(): string {
6565
return thingsYouCanDo[Math.floor(Math.random() * thingsYouCanDo.length)];
6666
}

‎packages/cli/src/helpers/log.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export class Logger {
88
}
99

1010
static command(str: string) {
11-
console.log(chalk.blue.bold(str));
11+
// console.log(chalk.blue.bold(str));
12+
console.log(chalk.cyan(str))
1213
}
1314
}

‎packages/cli/src/index.ts

+5-6
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,11 @@ program.parse(process.argv);
5959
if (process.argv.length <= 2) {
6060

6161
console.log(chalk.cyan(figlet.textSync('mini-shed', { horizontalLayout: 'full' })));
62-
console.log('感谢尝试 mini-shed 小游戏框架 < https://github.com/nshen/mini-shed >');
63-
// console.log('https://github.com/nshen/mini-shed/issues');
64-
console.log('有任何问题请入QQ群:431085380');
65-
console.log('shed -h 可显示更多帮助信息');
66-
console.log('--------------------------\n');
67-
62+
console.log('感谢尝试 ' + chalk.cyan('mini-shed v' + pkg.version) + ' 小游戏框架');
63+
console.log('有问题请到此留言:', chalk.cyan('<https://github.com/nshen/mini-shed/issues>'));
64+
console.log(chalk.cyan('shed -h') + ' 可显示更多帮助信息');
65+
console.log();
66+
// console.log('----------------------------------------------------\n');
6867
// program.help();
6968
} else {
7069
// clear();

‎packages/gl-examples/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"description": "examples of @shed/gl",
55
"module": "dist/gl-examples.es.js",
66
"types": "dist/index.d.ts",
7+
"private": true,
78
"files": [
89
"dist"
910
],

‎packages/math/docs/mathUtils.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# MathUtils
22

3-
提供数学常用函数,与常量
3+
提供数学常用函数与常量
44

55
## 常数
66

‎packages/platform/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# @shed/platform
22

3-
:hammer: 以微信小游戏为基准,统一各小游戏平台提供的`API` ,并 `Promise`
3+
:hammer: 以微信小游戏为基准,统一各小游戏平台提供的`API`,并 `Promise`
44

55
各个小游戏平台均实现了 `IPlatform` 接口
66

‎packages/starter/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@shed/starter",
33
"version": "0.2.0",
4-
"description": "mini-shed starter",
4+
"description": "mini-shed 小游戏示例项目",
55
"module": "dist/mini-game.es.js",
66
"keywords": [
77
"mini-game",

0 commit comments

Comments
 (0)
Please sign in to comment.