create-miniprogram-scaffold 1.0.6 → 1.0.8

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/bin/cli.js CHANGED
@@ -39328,109 +39328,6 @@ cd server && ${startCmd}
39328
39328
  \`\`\`
39329
39329
  `;
39330
39330
  }
39331
- function generateClaudeMd(name, config) {
39332
- const { layout, server, port } = config;
39333
- const serverLabel = SERVERS[server].label;
39334
- const startCmd = server === "python" ? "pip install -r requirements.txt && python main.py" : "go mod tidy && go run main.go";
39335
- return `# ${name}
39336
-
39337
- ## Tech Stack
39338
-
39339
- - Frontend: Taro 3 + React + TypeScript + Sass
39340
- - Backend: ${serverLabel}
39341
- - Layout: ${layout}
39342
-
39343
- ## Commands
39344
-
39345
- \`\`\`bash
39346
- cd miniprogram && pnpm install && pnpm dev:weapp # \u524D\u7AEF\u5F00\u53D1
39347
- cd server && ${startCmd} # \u540E\u7AEF\u5F00\u53D1
39348
- \`\`\`
39349
-
39350
- ## Conventions
39351
-
39352
- - CSS \u5B57\u53F7\u7528\u53D8\u91CF \`var(--fs-xxl)\`\uFF0C\u7981\u6B62\u5199\u6B7B px
39353
- - \u7C7B\u540D BEM\uFF1A\`.block__element--modifier\`
39354
- - API \u8FD4\u56DE \`{ code: 0, message, data, pagination? }\`
39355
- - \u7EAF\u5C55\u793A\u7EC4\u4EF6\u7528 \`memo()\` \u5305\u88F9
39356
- - PNG only\uFF0C\u4E0D\u7528 SVG
39357
- - \`<Image>\` \u5BB9\u5668\u5FC5\u987B\u6709\u663E\u5F0F width/height
39358
-
39359
- ## Project Structure
39360
-
39361
- \`\`\`
39362
- \u251C\u2500\u2500 miniprogram/ # Taro \u524D\u7AEF
39363
- \u2502 \u251C\u2500\u2500 src/layouts/ # \u5E03\u5C40\u7EC4\u4EF6
39364
- \u2502 \u251C\u2500\u2500 src/pages/ # \u9875\u9762
39365
- \u2502 \u2514\u2500\u2500 config/ # \u6784\u5EFA\u914D\u7F6E
39366
- \u251C\u2500\u2500 server/ # ${serverLabel} \u540E\u7AEF
39367
- \u251C\u2500\u2500 reusable/ # \u53EF\u590D\u7528\u7EC4\u4EF6\u548C\u5DE5\u5177
39368
- \u251C\u2500\u2500 docs/ # \u9879\u76EE\u6587\u6863
39369
- \u251C\u2500\u2500 CLAUDE.md # AI \u534F\u4F5C\u89C4\u8303
39370
- \u2514\u2500\u2500 AGENT.md # Agent \u4F7F\u7528\u6307\u5357
39371
- \`\`\`
39372
-
39373
- ## Notes
39374
-
39375
- - \u90E8\u7F72\u524D\u786E\u8BA4\u7528\u6237\u610F\u56FE\uFF0C\u4E0D\u8981\u4E3B\u52A8 deploy
39376
- - \u4E0D\u8981\u624B\u52A8 push \u5230 main
39377
- - \u53EA\u8DD1 build \u9A8C\u8BC1\u7F16\u8BD1\uFF0C\u4E0D\u8981\u8D77\u670D\u52A1
39378
- `;
39379
- }
39380
- function generateAgentMd(name, config) {
39381
- const { server } = config;
39382
- const serverLabel = SERVERS[server].label;
39383
- const startCmd = server === "python" ? "cd server && pip install -r requirements.txt && python main.py" : "cd server && go mod tidy && go run main.go";
39384
- return `# Agent \u4F7F\u7528\u6307\u5357
39385
-
39386
- > \u672C\u6587\u4EF6\u4F9B AI Agent \u9605\u8BFB\uFF0C\u8BF4\u660E\u5982\u4F55\u5728\u8FD9\u4E2A\u9879\u76EE\u4E2D\u5DE5\u4F5C\u3002
39387
-
39388
- ## \u5FEB\u901F\u5F00\u59CB
39389
-
39390
- \`\`\`bash
39391
- cd miniprogram && pnpm install && pnpm dev:weapp
39392
- ${startCmd}
39393
- \`\`\`
39394
-
39395
- ## \u5F00\u53D1\u6D41\u7A0B
39396
-
39397
- 1. **\u7406\u89E3\u9700\u6C42** \u2192 \u8BFB CLAUDE.md \u4E86\u89E3\u89C4\u8303
39398
- 2. **\u5B9A\u4F4D\u4EE3\u7801** \u2192 \u9875\u9762\u5728 \`src/pages/\`\uFF0C\u5E03\u5C40\u5728 \`src/layouts/\`
39399
- 3. **\u4FEE\u6539\u4EE3\u7801** \u2192 \u9075\u5FAA BEM\u3001CSS \u53D8\u91CF\u3001memo \u7B49\u89C4\u8303
39400
- 4. **\u9A8C\u8BC1** \u2192 \u8DD1 \`pnpm build:weapp\` \u786E\u8BA4\u7F16\u8BD1\u901A\u8FC7
39401
- 5. **\u4E0D\u8981\u4E3B\u52A8\u90E8\u7F72** \u2192 \u7B49\u7528\u6237\u786E\u8BA4
39402
-
39403
- ## \u5173\u952E\u8DEF\u5F84
39404
-
39405
- | \u5185\u5BB9 | \u8DEF\u5F84 |
39406
- |------|------|
39407
- | \u9875\u9762 | \`miniprogram/src/pages/\` |
39408
- | \u5E03\u5C40 | \`miniprogram/src/layouts/\` |
39409
- | \u6837\u5F0F\u53D8\u91CF | \`miniprogram/src/styles/variables.scss\` |
39410
- | \u540E\u7AEF\u5165\u53E3 | \`server/main.${server === "python" ? "py" : "go"}\` |
39411
- | \u9879\u76EE\u89C4\u8303 | \`CLAUDE.md\` |
39412
- | \u8BBE\u8BA1\u7CFB\u7EDF | \`docs/design-tokens.md\` |
39413
- | API \u7EA6\u5B9A | \`docs/api-conventions.md\` |
39414
- | \u53EF\u590D\u7528\u7EC4\u4EF6 | \`reusable/components/\` |
39415
- | \u8E29\u5751\u6587\u6863 | \`reusable/patterns/\` |
39416
-
39417
- ## \u7981\u5FCC
39418
-
39419
- - \u4E0D\u8981\u5199\u6B7B px \u5B57\u53F7
39420
- - \u4E0D\u8981\u7528 SVG \u505A\u5C0F\u7A0B\u5E8F\u56FE\u6807
39421
- - \u4E0D\u8981\u624B\u5199 \`wx.requestSubscribeMessage\`
39422
- - \u4E0D\u8981\u76F4\u63A5\u64CD\u4F5C\u6570\u636E\u5E93
39423
- - \u4E0D\u8981\u4E3B\u52A8 deploy
39424
- - \u4E0D\u8981 push \u5230 main\uFF08\u9664\u975E\u7528\u6237\u660E\u786E\u8981\u6C42\uFF09
39425
-
39426
- ## \u6587\u4EF6\u53D8\u66F4\u68C0\u67E5\u6E05\u5355
39427
-
39428
- - \u6539\u4E86\u9875\u9762 \u2192 \u68C0\u67E5 \`app.config.ts\` \u7684 pages \u662F\u5426\u9700\u8981\u66F4\u65B0
39429
- - \u6539\u4E86\u7EC4\u4EF6 \u2192 \u68C0\u67E5\u662F\u5426\u9700\u8981 \`memo()\`
39430
- - \u6539\u4E86\u6837\u5F0F \u2192 \u68C0\u67E5\u662F\u5426\u7528\u4E86 CSS \u53D8\u91CF
39431
- - \u65B0\u589E\u4F9D\u8D56 \u2192 \u786E\u8BA4\u662F\u5C0F\u7A0B\u5E8F\u517C\u5BB9\u7684\u5305
39432
- `;
39433
- }
39434
39331
  async function scaffold(projectName, config) {
39435
39332
  const { layout, server, port } = config;
39436
39333
  const tDir = import_path.default.join(__dirname, "..", "templates");
@@ -39460,11 +39357,6 @@ async function scaffold(projectName, config) {
39460
39357
  pc.projectname = projectName;
39461
39358
  await import_fs_extra.default.writeJson(import_path.default.join(mDir, "project.config.json"), pc, { spaces: 2 });
39462
39359
  await import_fs_extra.default.copy(import_path.default.join(tDir, serverCfg.template), import_path.default.join(dir, "server"));
39463
- const repoRoot = import_path.default.join(tDir, "..", "..");
39464
- await import_fs_extra.default.copy(import_path.default.join(repoRoot, "reusable"), import_path.default.join(dir, "reusable"));
39465
- await import_fs_extra.default.copy(import_path.default.join(repoRoot, "docs"), import_path.default.join(dir, "docs"));
39466
- await import_fs_extra.default.writeFile(import_path.default.join(dir, "CLAUDE.md"), generateClaudeMd(projectName, config));
39467
- await import_fs_extra.default.writeFile(import_path.default.join(dir, "AGENT.md"), generateAgentMd(projectName, config));
39468
39360
  if (server === "go") {
39469
39361
  const goModPath = import_path.default.join(dir, "server/go.mod");
39470
39362
  let goMod = await import_fs_extra.default.readFile(goModPath, "utf8");
@@ -39478,6 +39370,12 @@ async function scaffold(projectName, config) {
39478
39370
  await import_fs_extra.default.writeFile(envPath, env);
39479
39371
  await import_fs_extra.default.writeFile(envExamplePath, env);
39480
39372
  }
39373
+ const repoRoot = import_path.default.join(tDir, "..", "..");
39374
+ await import_fs_extra.default.copy(import_path.default.join(repoRoot, "reusable"), import_path.default.join(dir, "reusable"));
39375
+ await import_fs_extra.default.copy(import_path.default.join(repoRoot, "docs"), import_path.default.join(dir, "docs"));
39376
+ const metaDir = import_path.default.join(tDir, "meta");
39377
+ await import_fs_extra.default.copy(import_path.default.join(metaDir, "CLAUDE.md"), import_path.default.join(dir, "CLAUDE.md"));
39378
+ await import_fs_extra.default.copy(import_path.default.join(metaDir, "CLAUDE.md"), import_path.default.join(dir, "AGENT.md"));
39481
39379
  await import_fs_extra.default.writeFile(import_path.default.join(dir, "README.md"), generateReadme(projectName, layout, server));
39482
39380
  }
39483
39381
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-miniprogram-scaffold",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "Create Taro + Go/Python mini program projects",
5
5
  "repository": {
6
6
  "type": "git",
@@ -0,0 +1,74 @@
1
+ # 项目规范
2
+
3
+ ## 技术栈
4
+
5
+ - 前端:Taro 3 + React + TypeScript + Sass
6
+ - 后端:Go (Fiber) / Python (FastAPI)
7
+
8
+ ## 常用命令
9
+
10
+ ```bash
11
+ cd miniprogram && pnpm install && pnpm dev:weapp # 前端开发
12
+ cd server && go mod tidy && go run main.go # Go 后端
13
+ cd server && pip install -r requirements.txt && python main.py # Python 后端
14
+ ```
15
+
16
+ ## 项目规范
17
+
18
+ - CSS 字号用变量 `var(--fs-xxl)`,禁止写死 px
19
+ - 类名 BEM:`.block__element--modifier`
20
+ - API 返回 `{ code: 0, message, data, pagination? }`
21
+ - 纯展示组件用 `memo()` 包裹
22
+ - PNG only,不用 SVG
23
+ - `<Image>` 容器必须有显式 width/height
24
+
25
+ ## 项目结构
26
+
27
+ ```
28
+ ├── miniprogram/ # Taro 前端
29
+ │ ├── src/layouts/ # 布局组件
30
+ │ ├── src/pages/ # 页面
31
+ │ └── config/ # 构建配置
32
+ ├── server/ # 后端
33
+ ├── reusable/ # 可复用组件和工具
34
+ ├── docs/ # 项目文档
35
+ ├── CLAUDE.md # AI 协作规范
36
+ └── AGENT.md # Agent 使用指南
37
+ ```
38
+
39
+ ## 可复用资产
40
+
41
+ `reusable/` 包含可直接复用的组件、工具和踩坑文档:
42
+
43
+ ### 组件(reusable/components/)
44
+
45
+ | 组件 | 说明 |
46
+ |------|------|
47
+ | CachedImage | 远程图本地缓存 |
48
+ | AppNoticeModal | 公告弹窗 |
49
+ | AnnouncementModal | 系统公告 |
50
+ | PageHeader | 页面标题区 |
51
+ | Page | 页面容器壳 |
52
+ | GlobalFab | 全局浮动按钮 |
53
+ | Confetti | 撒花特效 |
54
+ | SearchBar | 搜索输入条 |
55
+ | DetailCard | 详情卡片壳 |
56
+
57
+ ### 工具(reusable/utils/)
58
+
59
+ - `subscribeMessage.ts` — 微信订阅消息统一封装
60
+ - `obfuscate.ts` — Base64 + JSON 混淆
61
+
62
+ ### 踩坑文档(reusable/patterns/)
63
+
64
+ - bundle-size-optimization / ios-date-parse / wxss-compatibility
65
+ - taro-build-gotchas / local-image-imports / page-scroll-and-tabbar
66
+ - css-variables-and-bem / cached-image-container-size
67
+ - api-response-format / subscribe-message-flow
68
+ - blue-green-deployment / smoke-test
69
+
70
+ ## 注意事项
71
+
72
+ - 部署前确认用户意图,不要主动 deploy
73
+ - 不要手动 push 到 main
74
+ - 只跑 build 验证编译,不要起服务