@coze-arch/cli 0.0.1-alpha.ef0249 → 0.0.1-alpha.ef8b63

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.
Files changed (91) hide show
  1. package/lib/__templates__/expo/.cozeproj/scripts/dev_run.sh +25 -16
  2. package/lib/__templates__/expo/.cozeproj/scripts/server_dev_run.sh +9 -8
  3. package/lib/__templates__/expo/README.md +2 -2
  4. package/lib/__templates__/expo/client/app/+not-found.tsx +30 -0
  5. package/lib/__templates__/expo/client/app/_layout.tsx +11 -8
  6. package/lib/__templates__/expo/client/app.config.ts +2 -2
  7. package/lib/__templates__/expo/client/components/Screen.tsx +1 -17
  8. package/lib/__templates__/expo/client/components/ThemedView.tsx +1 -2
  9. package/lib/__templates__/expo/client/constants/theme.ts +21 -698
  10. package/lib/__templates__/expo/client/eslint.config.mjs +20 -0
  11. package/lib/__templates__/expo/client/hooks/{useColorScheme.ts → useColorScheme.tsx} +20 -6
  12. package/lib/__templates__/expo/client/hooks/useSafeRouter.ts +152 -0
  13. package/lib/__templates__/expo/client/metro.config.js +3 -0
  14. package/lib/__templates__/expo/client/package.json +36 -34
  15. package/lib/__templates__/expo/client/screens/demo/index.tsx +3 -3
  16. package/lib/__templates__/expo/eslint-plugins/fontawesome6/names.js +1886 -2483
  17. package/lib/__templates__/expo/eslint-plugins/fontawesome6/rule.js +20 -1
  18. package/lib/__templates__/expo/eslint-plugins/fontawesome6/v5-only-names.js +388 -0
  19. package/lib/__templates__/expo/eslint-plugins/react-native/index.js +9 -0
  20. package/lib/__templates__/expo/eslint-plugins/react-native/rule.js +64 -0
  21. package/lib/__templates__/expo/eslint-plugins/reanimated/index.js +9 -0
  22. package/lib/__templates__/expo/eslint-plugins/reanimated/rule.js +88 -0
  23. package/lib/__templates__/expo/package.json +3 -0
  24. package/lib/__templates__/expo/patches/expo@54.0.33.patch +45 -0
  25. package/lib/__templates__/expo/pnpm-lock.yaml +1318 -2636
  26. package/lib/__templates__/expo/server/package.json +9 -7
  27. package/lib/__templates__/expo/server/src/index.ts +1 -0
  28. package/lib/__templates__/expo/template.config.js +56 -0
  29. package/lib/__templates__/native-static/.coze +11 -0
  30. package/lib/__templates__/native-static/index.html +33 -0
  31. package/lib/__templates__/native-static/styles/main.css +136 -0
  32. package/lib/__templates__/native-static/template.config.js +22 -0
  33. package/lib/__templates__/nextjs/.babelrc +15 -0
  34. package/lib/__templates__/nextjs/package.json +6 -1
  35. package/lib/__templates__/nextjs/pnpm-lock.yaml +2063 -926
  36. package/lib/__templates__/nextjs/src/app/layout.tsx +5 -3
  37. package/lib/__templates__/nextjs/src/app/page.tsx +18 -60
  38. package/lib/__templates__/nextjs/template.config.js +49 -14
  39. package/lib/__templates__/taro/.coze +14 -0
  40. package/lib/__templates__/taro/.cozeproj/scripts/deploy_build.sh +19 -0
  41. package/lib/__templates__/taro/.cozeproj/scripts/deploy_run.sh +14 -0
  42. package/lib/__templates__/taro/.cozeproj/scripts/dev_build.sh +2 -0
  43. package/lib/__templates__/taro/.cozeproj/scripts/dev_run.sh +151 -0
  44. package/lib/__templates__/taro/.cozeproj/scripts/init_env.sh +5 -0
  45. package/lib/__templates__/taro/.cozeproj/scripts/pack.sh +24 -0
  46. package/lib/__templates__/taro/README.md +751 -0
  47. package/lib/__templates__/taro/_gitignore +40 -0
  48. package/lib/__templates__/taro/_npmrc +18 -0
  49. package/lib/__templates__/taro/babel.config.js +12 -0
  50. package/lib/__templates__/taro/config/dev.ts +9 -0
  51. package/lib/__templates__/taro/config/index.ts +174 -0
  52. package/lib/__templates__/taro/config/prod.ts +35 -0
  53. package/lib/__templates__/taro/eslint.config.mjs +80 -0
  54. package/lib/__templates__/taro/key/private.appid.key +0 -0
  55. package/lib/__templates__/taro/package.json +97 -0
  56. package/lib/__templates__/taro/pnpm-lock.yaml +22706 -0
  57. package/lib/__templates__/taro/pnpm-workspace.yaml +2 -0
  58. package/lib/__templates__/taro/project.config.json +15 -0
  59. package/lib/__templates__/taro/server/nest-cli.json +10 -0
  60. package/lib/__templates__/taro/server/package.json +40 -0
  61. package/lib/__templates__/taro/server/src/app.controller.ts +23 -0
  62. package/lib/__templates__/taro/server/src/app.module.ts +10 -0
  63. package/lib/__templates__/taro/server/src/app.service.ts +8 -0
  64. package/lib/__templates__/taro/server/src/interceptors/http-status.interceptor.ts +23 -0
  65. package/lib/__templates__/taro/server/src/main.ts +49 -0
  66. package/lib/__templates__/taro/server/tsconfig.json +24 -0
  67. package/lib/__templates__/taro/src/app.config.ts +11 -0
  68. package/lib/__templates__/taro/src/app.css +52 -0
  69. package/lib/__templates__/taro/src/app.tsx +9 -0
  70. package/lib/__templates__/taro/src/index.html +39 -0
  71. package/lib/__templates__/taro/src/network.ts +39 -0
  72. package/lib/__templates__/taro/src/pages/index/index.config.ts +3 -0
  73. package/lib/__templates__/taro/src/pages/index/index.css +1 -0
  74. package/lib/__templates__/taro/src/pages/index/index.tsx +33 -0
  75. package/lib/__templates__/taro/src/presets/h5-container.tsx +17 -0
  76. package/lib/__templates__/taro/src/presets/h5-navbar.tsx +167 -0
  77. package/lib/__templates__/taro/src/presets/h5-styles.ts +88 -0
  78. package/lib/__templates__/taro/src/presets/index.tsx +18 -0
  79. package/lib/__templates__/taro/src/presets/wx-debug.ts +23 -0
  80. package/lib/__templates__/taro/stylelint.config.mjs +4 -0
  81. package/lib/__templates__/taro/template.config.js +68 -0
  82. package/lib/__templates__/taro/tsconfig.json +29 -0
  83. package/lib/__templates__/taro/types/global.d.ts +32 -0
  84. package/lib/__templates__/templates.json +43 -0
  85. package/lib/__templates__/vite/package.json +5 -1
  86. package/lib/__templates__/vite/pnpm-lock.yaml +146 -1659
  87. package/lib/__templates__/vite/src/main.ts +17 -47
  88. package/lib/__templates__/vite/template.config.js +49 -14
  89. package/lib/__templates__/vite/vite.config.ts +1 -0
  90. package/lib/cli.js +838 -130
  91. package/package.json +2 -1
@@ -0,0 +1,88 @@
1
+ /**
2
+ * H5 端特殊样式注入
3
+ * 如无必要,请勿修改本文件
4
+ */
5
+ export function injectH5Styles() {
6
+ if (TARO_ENV !== 'h5') return;
7
+
8
+ const style = document.createElement('style');
9
+ style.innerHTML = `
10
+ /* H5 端隐藏 TabBar 空图标(只隐藏没有 src 的图标) */
11
+ .weui-tabbar__icon:not([src]),
12
+ .weui-tabbar__icon[src=''] {
13
+ display: none !important;
14
+ }
15
+
16
+ .weui-tabbar__item:has(.weui-tabbar__icon:not([src])) .weui-tabbar__label,
17
+ .weui-tabbar__item:has(.weui-tabbar__icon[src='']) .weui-tabbar__label {
18
+ margin-top: 0 !important;
19
+ }
20
+
21
+ /* Vite 错误覆盖层无法选择文本的问题 */
22
+ vite-error-overlay {
23
+ /* stylelint-disable-next-line property-no-vendor-prefix */
24
+ -webkit-user-select: text !important;
25
+ }
26
+
27
+ vite-error-overlay::part(window) {
28
+ max-width: 90vw;
29
+ padding: 10px;
30
+ }
31
+
32
+ .taro_page {
33
+ overflow: auto;
34
+ }
35
+
36
+ ::-webkit-scrollbar {
37
+ width: 4px;
38
+ height: 4px;
39
+ }
40
+
41
+ ::-webkit-scrollbar-track {
42
+ background: transparent;
43
+ }
44
+
45
+ ::-webkit-scrollbar-thumb {
46
+ background: rgba(0, 0, 0, 0.2);
47
+ border-radius: 2px;
48
+ }
49
+
50
+ ::-webkit-scrollbar-thumb:hover {
51
+ background: rgba(0, 0, 0, 0.3);
52
+ }
53
+
54
+ /* PC 宽屏适配 */
55
+ @media (min-width: 769px) {
56
+ html {
57
+ font-size: 15px !important;
58
+ }
59
+
60
+ body {
61
+ background-color: #f3f4f6 !important;
62
+ display: flex !important;
63
+ justify-content: center !important;
64
+ align-items: center !important;
65
+ min-height: 100vh !important;
66
+ }
67
+
68
+ .taro-tabbar__container {
69
+ width: 375px !important;
70
+ max-width: 375px !important;
71
+ height: calc(100vh - 40px) !important;
72
+ max-height: 900px !important;
73
+ background-color: #fff !important;
74
+ transform: translateX(0) !important;
75
+ box-shadow: 0 0 20px rgba(0, 0, 0, 0.1) !important;
76
+ border-radius: 20px !important;
77
+ overflow: hidden !important;
78
+ position: relative !important;
79
+ }
80
+
81
+ .taro-tabbar__panel {
82
+ height: 100% !important;
83
+ overflow: auto !important;
84
+ }
85
+ }
86
+ `;
87
+ document.head.appendChild(style);
88
+ }
@@ -0,0 +1,18 @@
1
+ import { useLaunch } from '@tarojs/taro';
2
+ import { PropsWithChildren } from 'react';
3
+ import { injectH5Styles } from './h5-styles';
4
+ import { H5Container } from './h5-container';
5
+ import { enableWxDebugIfNeeded } from './wx-debug';
6
+
7
+ export const Preset = ({ children }: PropsWithChildren) => {
8
+ useLaunch(() => {
9
+ enableWxDebugIfNeeded();
10
+ injectH5Styles();
11
+ });
12
+
13
+ if (TARO_ENV === 'h5') {
14
+ return <H5Container>{children}</H5Container>;
15
+ }
16
+
17
+ return <>{children}</>;
18
+ };
@@ -0,0 +1,23 @@
1
+ import Taro from '@tarojs/taro'
2
+
3
+ /**
4
+ * 微信小程序调试工具
5
+ * 在开发版/体验版自动开启调试模式
6
+ */
7
+ export function enableWxDebugIfNeeded() {
8
+ // 仅在微信小程序环境执行
9
+ if (Taro.getEnv() === Taro.ENV_TYPE.WEAPP) {
10
+ try {
11
+ const accountInfo = Taro.getAccountInfoSync()
12
+ const envVersion = accountInfo.miniProgram.envVersion
13
+ console.log('[Debug] envVersion:', envVersion)
14
+
15
+ // 开发版/体验版自动开启调试
16
+ if (envVersion !== 'release') {
17
+ Taro.setEnableDebug({ enableDebug: true })
18
+ }
19
+ } catch (error) {
20
+ console.error('[Debug] 开启调试模式失败:', error)
21
+ }
22
+ }
23
+ }
@@ -0,0 +1,4 @@
1
+ /** @type {import('stylelint').Config} */
2
+ export default {
3
+ extends: "stylelint-config-standard",
4
+ };
@@ -0,0 +1,68 @@
1
+
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
10
+ const description = `Taro(小程序 + H5):\`coze init \${COZE_WORKSPACE_PATH} --template taro\`
11
+ - 适用:微信小程序、H5 跨端应用
12
+ - 前后端分离架构:Taro 4 + NestJS
13
+ - 支持微信小程序和 H5 双端构建
14
+ - 使用 TailwindCSS + weapp-tailwindcss 实现跨端样式`;
15
+
16
+ export const paramsSchema = {
17
+ type: 'object',
18
+ properties: {
19
+ appName: {
20
+ type: 'string',
21
+ minLength: 1,
22
+ pattern: '^[a-z0-9-]+$',
23
+ description:
24
+ 'Application name (lowercase, alphanumeric and hyphens only)',
25
+ },
26
+ port: {
27
+ type: 'number',
28
+ default: 5000,
29
+ minimum: 1024,
30
+ maximum: 65535,
31
+ description: 'H5 development server port',
32
+ },
33
+ serverPort: {
34
+ type: 'number',
35
+ default: 3000,
36
+ minimum: 1024,
37
+ maximum: 65535,
38
+ description: 'NestJS backend server port',
39
+ },
40
+ },
41
+ required: [],
42
+ additionalProperties: false,
43
+ };
44
+
45
+ const config = {
46
+ description: description,
47
+ paramsSchema,
48
+ defaultParams: {
49
+ port: 5000,
50
+ serverPort: 3000,
51
+ appName: 'coze-mini-program',
52
+ },
53
+ onBeforeRender: async context => {
54
+ console.log(`Creating Taro project: ${context.appName}`);
55
+ return context;
56
+ },
57
+ onAfterRender: async (context, outputPath) => {
58
+ console.log(`\nProject created at: ${outputPath}`);
59
+ console.log('\nConfiguration:');
60
+ console.log(' - Framework: Taro 4 + NestJS');
61
+ console.log(' - TypeScript: enabled');
62
+ console.log(' - Platforms: H5, WeChat Mini Program');
63
+ console.log(` - H5 Port: ${context.port}`);
64
+ console.log(` - Server Port: ${context.serverPort}`);
65
+ },
66
+ };
67
+
68
+ export default config;
@@ -0,0 +1,29 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "es2017",
4
+ "module": "ESNext",
5
+ "removeComments": false,
6
+ "preserveConstEnums": true,
7
+ "moduleResolution": "bundler",
8
+ "experimentalDecorators": true,
9
+ "noImplicitAny": false,
10
+ "allowSyntheticDefaultImports": true,
11
+ "outDir": "lib",
12
+ "noUnusedLocals": true,
13
+ "noUnusedParameters": true,
14
+ "strictNullChecks": true,
15
+ "sourceMap": true,
16
+ "rootDir": ".",
17
+ "jsx": "react-jsx",
18
+ "allowJs": true,
19
+ "resolveJsonModule": true,
20
+ "typeRoots": [
21
+ "node_modules/@types"
22
+ ],
23
+ "paths": {
24
+ "@/*": ["./src/*"]
25
+ }
26
+ },
27
+ "include": ["./src", "./types", "./config"],
28
+ "compileOnSave": false
29
+ }
@@ -0,0 +1,32 @@
1
+ /// <reference types="@tarojs/taro" />
2
+
3
+ declare const PROJECT_DOMAIN: string | undefined;
4
+ declare const TARO_ENV: "weapp" | "h5" | undefined;
5
+
6
+ declare module '*.png';
7
+ declare module '*.gif';
8
+ declare module '*.jpg';
9
+ declare module '*.jpeg';
10
+ declare module '*.svg';
11
+ declare module '*.css';
12
+ declare module '*.less';
13
+ declare module '*.scss';
14
+ declare module '*.sass';
15
+ declare module '*.styl';
16
+
17
+ declare namespace NodeJS {
18
+ interface ProcessEnv {
19
+ /** NODE 内置环境变量, 会影响到最终构建生成产物 */
20
+ NODE_ENV: 'development' | 'production',
21
+ /** 当前构建的平台 */
22
+ TARO_ENV: 'weapp' | 'swan' | 'alipay' | 'h5' | 'rn' | 'tt' | 'qq' | 'jd' | 'harmony' | 'jdrn'
23
+ /**
24
+ * 当前构建的小程序 appid
25
+ * @description 若不同环境有不同的小程序,可通过在 env 文件中配置环境变量`TARO_APP_ID`来方便快速切换 appid, 而不必手动去修改 dist/project.config.json 文件
26
+ * @see https://taro-docs.jd.com/docs/next/env-mode-config#特殊环境变量-taro_app_id
27
+ */
28
+ TARO_APP_ID: string
29
+ }
30
+ }
31
+
32
+
@@ -26,6 +26,17 @@
26
26
  "additionalProperties": false
27
27
  }
28
28
  },
29
+ {
30
+ "name": "native-static",
31
+ "description": "Native Static(纯静态):`coze init ${COZE_WORKSPACE_PATH} --template native-static`\n- 适用:纯静态 HTML/CSS/JS 项目、静态网站\n- 使用 Python http.server 作为开发服务器\n- 不需要 Node.js 环境,适合简单静态内容",
32
+ "location": "./native-static",
33
+ "paramsSchema": {
34
+ "type": "object",
35
+ "properties": {},
36
+ "required": [],
37
+ "additionalProperties": false
38
+ }
39
+ },
29
40
  {
30
41
  "name": "nextjs",
31
42
  "description": "Next.js(复杂项目):`coze init ${COZE_WORKSPACE_PATH} --template nextjs`\n- 适用:全栈应用、复杂多页面等复杂项目\n- 使用默认nextjs项目规范\n - **目录规范**: 默认开启src目录(打开--src-dir选项):项目文件(如 app 目录、pages 目录、components 等)初始化到 src/ 目录下。\n - **项目理解加速**:初始可以依赖项目下 `package.json` 文件理解项目类型,如果没有或无法理解退化成阅读其他文件。\n - **UI设计与组件规范**:Next.js项目**必须默认**采用 shadcn/ui 风格和规范,`shadcn/ui`组件默认完整的预装在`src/components/ui/`目录下",
@@ -51,6 +62,38 @@
51
62
  "additionalProperties": false
52
63
  }
53
64
  },
65
+ {
66
+ "name": "taro",
67
+ "description": "Taro(小程序 + H5):`coze init ${COZE_WORKSPACE_PATH} --template taro`\n- 适用:微信小程序、H5 跨端应用\n- 前后端分离架构:Taro 4 + NestJS\n- 支持微信小程序和 H5 双端构建\n- 使用 TailwindCSS + weapp-tailwindcss 实现跨端样式",
68
+ "location": "./taro",
69
+ "paramsSchema": {
70
+ "type": "object",
71
+ "properties": {
72
+ "appName": {
73
+ "type": "string",
74
+ "minLength": 1,
75
+ "pattern": "^[a-z0-9-]+$",
76
+ "description": "Application name (lowercase, alphanumeric and hyphens only)"
77
+ },
78
+ "port": {
79
+ "type": "number",
80
+ "default": 5000,
81
+ "minimum": 1024,
82
+ "maximum": 65535,
83
+ "description": "H5 development server port"
84
+ },
85
+ "serverPort": {
86
+ "type": "number",
87
+ "default": 3000,
88
+ "minimum": 1024,
89
+ "maximum": 65535,
90
+ "description": "NestJS backend server port"
91
+ }
92
+ },
93
+ "required": [],
94
+ "additionalProperties": false
95
+ }
96
+ },
54
97
  {
55
98
  "name": "vite",
56
99
  "description": "Vite(简单项目):`coze init ${COZE_WORKSPACE_PATH} --template vite`\n- 适用:轻量级 SPA、纯前端交互、仪表盘等轻量级项目。",
@@ -10,9 +10,13 @@
10
10
  "start": "bash ./scripts/start.sh",
11
11
  "ts-check": "tsc -p tsconfig.json"
12
12
  },
13
+ "dependencies": {
14
+ "@supabase/supabase-js": "2.95.3",
15
+ "dotenv": "^17.2.3"
16
+ },
13
17
  "devDependencies": {
14
18
  "autoprefixer": "^10.4.20",
15
- "coze-coding-dev-sdk": "^0.7.3",
19
+ "coze-coding-dev-sdk": "^0.7.16",
16
20
  "eslint": "^9",
17
21
  "only-allow": "^1.2.2",
18
22
  "postcss": "^8.4.49",