@coze-arch/cli 0.0.3 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/__templates__/expo/AGENTS.md +77 -0
- package/lib/__templates__/expo/README.md +14 -11
- package/lib/__templates__/expo/client/contexts/AuthContext.tsx +9 -3
- package/lib/__templates__/expo/client/eslint.config.mjs +3 -0
- package/lib/__templates__/nextjs/AGENTS.md +54 -0
- package/lib/__templates__/nuxt-vue/AGENTS.md +42 -0
- package/lib/__templates__/templates.json +0 -37
- package/lib/__templates__/vite/AGENTS.md +41 -0
- package/lib/cli.js +3304 -735
- package/package.json +4 -1
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Expo App + Express.js
|
|
2
|
+
|
|
3
|
+
## 目录结构规范(严格遵循)
|
|
4
|
+
|
|
5
|
+
当前仓库是一个 monorepo(基于 pnpm 的 workspace)
|
|
6
|
+
|
|
7
|
+
- Expo 代码在 client 目录,Express.js 代码在 server 目录
|
|
8
|
+
- 本模板默认无 Tab Bar,可按需改造
|
|
9
|
+
|
|
10
|
+
目录结构说明
|
|
11
|
+
|
|
12
|
+
├── server/ # 服务端代码根目录 (Express.js)
|
|
13
|
+
| ├── src/
|
|
14
|
+
│ │ └── index.ts # Express 入口文件
|
|
15
|
+
| └── package.json # 服务端 package.json
|
|
16
|
+
├── client/ # React Native 前端代码
|
|
17
|
+
│ ├── app/ # Expo Router 路由目录(仅路由配置)
|
|
18
|
+
│ │ ├── _layout.tsx # 根布局文件(必需,务必阅读)
|
|
19
|
+
│ │ ├── home.tsx # 首页
|
|
20
|
+
│ │ └── index.tsx # re-export home.tsx
|
|
21
|
+
│ ├── screens/ # 页面实现目录(与 app/ 路由对应)
|
|
22
|
+
│ │ └── demo/ # demo 示例页面
|
|
23
|
+
│ │ ├── index.tsx # 页面组件实现
|
|
24
|
+
│ │ └── styles.ts # 页面样式
|
|
25
|
+
│ ├── components/ # 可复用组件
|
|
26
|
+
│ │ └── Screen.tsx # 页面容器组件(必用)
|
|
27
|
+
│ ├── hooks/ # 自定义 Hooks
|
|
28
|
+
│ ├── contexts/ # React Context 代码
|
|
29
|
+
│ ├── constants/ # 常量定义(如主题配置)
|
|
30
|
+
│ ├── utils/ # 工具函数
|
|
31
|
+
│ ├── assets/ # 静态资源
|
|
32
|
+
| └── package.json # Expo 应用 package.json
|
|
33
|
+
├── package.json
|
|
34
|
+
├── .cozeproj # 预置脚手架脚本(禁止修改)
|
|
35
|
+
└── .coze # 配置文件(禁止修改)
|
|
36
|
+
|
|
37
|
+
## 依赖管理与模块导入规范
|
|
38
|
+
|
|
39
|
+
### 依赖安装
|
|
40
|
+
**禁止**使用 `npm` 或 `yarn`,按目录区分安装命令:
|
|
41
|
+
|
|
42
|
+
| 目录 | 安装命令 | 说明 |
|
|
43
|
+
|------|----------|------|
|
|
44
|
+
| `client/` | `npx expo install <package>` | Expo 会自动选择与 SDK 兼容的版本 |
|
|
45
|
+
| `server/` | `pnpm add <package>` | 使用 pnpm 管理后端依赖 |
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
# client 目录(Expo 项目)
|
|
49
|
+
cd client && npx expo install expo-camera expo-image-picker
|
|
50
|
+
|
|
51
|
+
# server 目录(Express 项目)
|
|
52
|
+
cd server && pnpm add axios cors
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
**网络问题处理**:`npx expo install` 可能因网络原因失败,失败时重试 2 次,仍失败则改用 `pnpm add` 安装
|
|
56
|
+
|
|
57
|
+
## Expo 开发规范
|
|
58
|
+
|
|
59
|
+
### 路径别名
|
|
60
|
+
|
|
61
|
+
Expo 配置了 `@/` 路径别名指向 `client/` 目录:
|
|
62
|
+
|
|
63
|
+
```tsx
|
|
64
|
+
// 正确
|
|
65
|
+
import { Screen } from '@/components/Screen';
|
|
66
|
+
|
|
67
|
+
// 避免相对路径
|
|
68
|
+
import { Screen } from '../../../components/Screen';
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## 本地开发
|
|
72
|
+
|
|
73
|
+
运行 coze dev 可以同时启动前端和后端服务,如果端口已占用,该命令会先杀掉占用端口的进程再启动,也可以用来重启前端和后端服务
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
coze dev
|
|
77
|
+
```
|
|
@@ -34,22 +34,25 @@
|
|
|
34
34
|
├── .cozeproj # 预置脚手架脚本(禁止修改)
|
|
35
35
|
└── .coze # 配置文件(禁止修改)
|
|
36
36
|
|
|
37
|
-
##
|
|
37
|
+
## 依赖管理与模块导入规范
|
|
38
38
|
|
|
39
|
-
###
|
|
39
|
+
### 依赖安装
|
|
40
|
+
**禁止**使用 `npm` 或 `yarn`,按目录区分安装命令:
|
|
40
41
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
### 新增依赖约束
|
|
42
|
+
| 目录 | 安装命令 | 说明 |
|
|
43
|
+
|------|----------|------|
|
|
44
|
+
| `client/` | `npx expo install <package>` | Expo 会自动选择与 SDK 兼容的版本 |
|
|
45
|
+
| `server/` | `pnpm add <package>` | 使用 pnpm 管理后端依赖 |
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
```bash
|
|
48
|
+
# client 目录(Expo 项目)
|
|
49
|
+
cd client && npx expo install expo-camera expo-image-picker
|
|
48
50
|
|
|
49
|
-
|
|
51
|
+
# server 目录(Express 项目)
|
|
52
|
+
cd server && pnpm add axios cors
|
|
53
|
+
```
|
|
50
54
|
|
|
51
|
-
|
|
52
|
-
- 在根目录执行 `pnpm i`
|
|
55
|
+
**网络问题处理**:`npx expo install` 可能因网络原因失败,失败时重试 2 次,仍失败则改用 `pnpm add` 安装
|
|
53
56
|
|
|
54
57
|
## Expo 开发规范
|
|
55
58
|
|
|
@@ -33,9 +33,15 @@ export const AuthProvider: React.FC<{ children: ReactNode }> = ({ children }) =>
|
|
|
33
33
|
token: null,
|
|
34
34
|
isAuthenticated: false,
|
|
35
35
|
isLoading: false,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
|
|
37
|
+
// 登录逻辑,根据项目实际情况实现
|
|
38
|
+
login: async (token: string) => {}, // eslint-disable-line @typescript-eslint/no-empty-function
|
|
39
|
+
|
|
40
|
+
// 登出逻辑,根据项目实际情况实现
|
|
41
|
+
logout: async () => {}, // eslint-disable-line @typescript-eslint/no-empty-function
|
|
42
|
+
|
|
43
|
+
// 更新用户信息,根据项目实际情况实现
|
|
44
|
+
updateUser: () => {}, // eslint-disable-line @typescript-eslint/no-empty-function
|
|
39
45
|
};
|
|
40
46
|
return <AuthContext.Provider value={value}>{children}</AuthContext.Provider>;
|
|
41
47
|
};
|
|
@@ -100,6 +100,9 @@ export default [
|
|
|
100
100
|
},
|
|
101
101
|
],
|
|
102
102
|
'reactnative/wrap-horizontal-scrollview-inside-view': ['error'],
|
|
103
|
+
'no-empty-function': 'off',
|
|
104
|
+
'@typescript-eslint/no-empty-function': 'error',
|
|
105
|
+
'no-warning-comments': ['error', { terms: ['TODO'], location: 'start' }],
|
|
103
106
|
},
|
|
104
107
|
},
|
|
105
108
|
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# 项目上下文
|
|
2
|
+
|
|
3
|
+
### 版本技术栈
|
|
4
|
+
|
|
5
|
+
- **Framework**: Next.js 16 (App Router)
|
|
6
|
+
- **Core**: React 19
|
|
7
|
+
- **Language**: TypeScript 5
|
|
8
|
+
- **UI 组件**: shadcn/ui (基于 Radix UI)
|
|
9
|
+
- **Styling**: Tailwind CSS 4
|
|
10
|
+
|
|
11
|
+
## 目录结构
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
├── public/ # 静态资源
|
|
15
|
+
├── scripts/ # 构建与启动脚本
|
|
16
|
+
│ ├── build.sh # 构建脚本
|
|
17
|
+
│ ├── dev.sh # 开发环境启动脚本
|
|
18
|
+
│ ├── prepare.sh # 预处理脚本
|
|
19
|
+
│ └── start.sh # 生产环境启动脚本
|
|
20
|
+
├── src/
|
|
21
|
+
│ ├── app/ # 页面路由与布局
|
|
22
|
+
│ ├── components/ui/ # Shadcn UI 组件库
|
|
23
|
+
│ ├── hooks/ # 自定义 Hooks
|
|
24
|
+
│ ├── lib/ # 工具库
|
|
25
|
+
│ │ └── utils.ts # 通用工具函数 (cn)
|
|
26
|
+
│ └── server.ts # 自定义服务端入口
|
|
27
|
+
├── next.config.ts # Next.js 配置
|
|
28
|
+
├── package.json # 项目依赖管理
|
|
29
|
+
└── tsconfig.json # TypeScript 配置
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
- 项目文件(如 app 目录、pages 目录、components 等)默认初始化到 `src/` 目录下。
|
|
33
|
+
|
|
34
|
+
## 包管理规范
|
|
35
|
+
|
|
36
|
+
**仅允许使用 pnpm** 作为包管理器,**严禁使用 npm 或 yarn**。
|
|
37
|
+
**常用命令**:
|
|
38
|
+
- 安装依赖:`pnpm add <package>`
|
|
39
|
+
- 安装开发依赖:`pnpm add -D <package>`
|
|
40
|
+
- 安装所有依赖:`pnpm install`
|
|
41
|
+
- 移除依赖:`pnpm remove <package>`
|
|
42
|
+
|
|
43
|
+
## 开发规范
|
|
44
|
+
|
|
45
|
+
- **项目理解加速**:初始可以依赖项目下`package.json`文件理解项目类型,如果没有或无法理解退化成阅读其他文件。
|
|
46
|
+
- **Hydration 错误预防**:严禁在 JSX 渲染逻辑中直接使用 typeof window、Date.now()、Math.random() 等动态数据。必须使用 'use client' 并配合 useEffect + useState 确保动态内容仅在客户端挂载后渲染;同时严禁非法 HTML 嵌套(如 <p> 嵌套 <div>)。
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
## UI 设计与组件规范 (UI & Styling Standards)
|
|
50
|
+
|
|
51
|
+
- 模板默认预装核心组件库 `shadcn/ui`,位于`src/components/ui/`目录下
|
|
52
|
+
- Next.js 项目**必须默认**采用 shadcn/ui 组件、风格和规范,**除非用户指定用其他的组件和规范。**
|
|
53
|
+
|
|
54
|
+
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# 项目上下文
|
|
2
|
+
|
|
3
|
+
## 技术栈
|
|
4
|
+
|
|
5
|
+
- **核心**: Nuxt 4, Vue 3, TypeScript
|
|
6
|
+
- **UI**: Tailwind CSS
|
|
7
|
+
|
|
8
|
+
## 目录结构
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
├── app/ # 页面路由与布局
|
|
12
|
+
│ ├── pages/ # 页面组件
|
|
13
|
+
│ └── app.vue # 根组件
|
|
14
|
+
├── assets/ # 静态资源
|
|
15
|
+
│ └── css/ # 全局样式
|
|
16
|
+
├── public/ # 公共静态资源
|
|
17
|
+
├── scripts/ # 构建与启动脚本
|
|
18
|
+
│ ├── build.sh # 构建脚本
|
|
19
|
+
│ ├── dev.sh # 开发环境启动脚本
|
|
20
|
+
│ ├── prepare.sh # 预处理脚本
|
|
21
|
+
│ └── start.sh # 生产环境启动脚本
|
|
22
|
+
├── server/ # 服务端逻辑
|
|
23
|
+
│ ├── api/ # API 路由
|
|
24
|
+
│ ├── middleware/ # 中间件
|
|
25
|
+
│ └── routes/ # 服务端路由
|
|
26
|
+
├── nuxt.config.ts # Nuxt 配置
|
|
27
|
+
├── package.json # 项目依赖管理
|
|
28
|
+
└── tsconfig.json # TypeScript 配置
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## 包管理规范
|
|
32
|
+
|
|
33
|
+
**仅允许使用 pnpm** 作为包管理器,**严禁使用 npm 或 yarn**。
|
|
34
|
+
**常用命令**:
|
|
35
|
+
- 安装依赖:`pnpm add <package>`
|
|
36
|
+
- 安装开发依赖:`pnpm add -D <package>`
|
|
37
|
+
- 安装所有依赖:`pnpm install`
|
|
38
|
+
- 移除依赖:`pnpm remove <package>`
|
|
39
|
+
|
|
40
|
+
## 开发规范
|
|
41
|
+
|
|
42
|
+
- 使用 Tailwind CSS 进行样式开发
|
|
@@ -126,43 +126,6 @@
|
|
|
126
126
|
"additionalProperties": false
|
|
127
127
|
}
|
|
128
128
|
},
|
|
129
|
-
{
|
|
130
|
-
"name": "test-only",
|
|
131
|
-
"description": "Test template showcasing all template hooks and features",
|
|
132
|
-
"location": "./test-only",
|
|
133
|
-
"paramsSchema": {
|
|
134
|
-
"type": "object",
|
|
135
|
-
"properties": {
|
|
136
|
-
"appName": {
|
|
137
|
-
"type": "string",
|
|
138
|
-
"minLength": 1,
|
|
139
|
-
"pattern": "^[a-z0-9-]+$",
|
|
140
|
-
"description": "Application name (lowercase, alphanumeric and hyphens only)"
|
|
141
|
-
},
|
|
142
|
-
"port": {
|
|
143
|
-
"type": "number",
|
|
144
|
-
"default": 5000,
|
|
145
|
-
"minimum": 1024,
|
|
146
|
-
"maximum": 65535,
|
|
147
|
-
"description": "Development server port"
|
|
148
|
-
},
|
|
149
|
-
"includeTests": {
|
|
150
|
-
"type": "boolean",
|
|
151
|
-
"default": true,
|
|
152
|
-
"nullable": true,
|
|
153
|
-
"description": "Include test files"
|
|
154
|
-
},
|
|
155
|
-
"addCopyright": {
|
|
156
|
-
"type": "boolean",
|
|
157
|
-
"default": false,
|
|
158
|
-
"nullable": true,
|
|
159
|
-
"description": "Add copyright header to source files"
|
|
160
|
-
}
|
|
161
|
-
},
|
|
162
|
-
"required": [],
|
|
163
|
-
"additionalProperties": false
|
|
164
|
-
}
|
|
165
|
-
},
|
|
166
129
|
{
|
|
167
130
|
"name": "vite",
|
|
168
131
|
"description": "Vite(简单项目):`coze init ${COZE_WORKSPACE_PATH} --template vite`\n- 适用:轻量级 SPA、纯前端交互、仪表盘等轻量级项目。",
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# 项目上下文
|
|
2
|
+
|
|
3
|
+
## 技术栈
|
|
4
|
+
|
|
5
|
+
- **核心**: Vite 7, TypeScript, Express
|
|
6
|
+
- **UI**: Tailwind CSS
|
|
7
|
+
|
|
8
|
+
## 目录结构
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
├── scripts/ # 构建与启动脚本
|
|
12
|
+
│ ├── build.sh # 构建脚本
|
|
13
|
+
│ ├── dev.sh # 开发环境启动脚本
|
|
14
|
+
│ ├── prepare.sh # 预处理脚本
|
|
15
|
+
│ └── start.sh # 生产环境启动脚本
|
|
16
|
+
├── server/ # 服务端逻辑
|
|
17
|
+
│ ├── routes/ # API 路由
|
|
18
|
+
│ ├── server.ts # Express 服务入口
|
|
19
|
+
│ └── vite.ts # Vite 中间件集成
|
|
20
|
+
├── src/ # 前端源码
|
|
21
|
+
│ ├── index.css # 全局样式
|
|
22
|
+
│ ├── index.ts # 客户端入口
|
|
23
|
+
│ └── main.ts # 主逻辑
|
|
24
|
+
├── index.html # 入口 HTML
|
|
25
|
+
├── package.json # 项目依赖管理
|
|
26
|
+
├── tsconfig.json # TypeScript 配置
|
|
27
|
+
└── vite.config.ts # Vite 配置
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## 包管理规范
|
|
31
|
+
|
|
32
|
+
**仅允许使用 pnpm** 作为包管理器,**严禁使用 npm 或 yarn**。
|
|
33
|
+
**常用命令**:
|
|
34
|
+
- 安装依赖:`pnpm add <package>`
|
|
35
|
+
- 安装开发依赖:`pnpm add -D <package>`
|
|
36
|
+
- 安装所有依赖:`pnpm install`
|
|
37
|
+
- 移除依赖:`pnpm remove <package>`
|
|
38
|
+
|
|
39
|
+
## 开发规范
|
|
40
|
+
|
|
41
|
+
- 使用 Tailwind CSS 进行样式开发
|