@coze-arch/cli 0.0.1-alpha.e8683e → 0.0.1-alpha.e89608

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 (128) hide show
  1. package/README.md +1 -0
  2. package/lib/__templates__/expo/.cozeproj/scripts/dev_run.sh +25 -16
  3. package/lib/__templates__/expo/.cozeproj/scripts/server_dev_run.sh +9 -8
  4. package/lib/__templates__/expo/README.md +2 -2
  5. package/lib/__templates__/expo/client/app/+not-found.tsx +30 -0
  6. package/lib/__templates__/expo/client/app.config.ts +2 -2
  7. package/lib/__templates__/expo/client/components/Screen.tsx +2 -2
  8. package/lib/__templates__/expo/client/eslint.config.mjs +21 -1
  9. package/lib/__templates__/expo/client/hooks/useSafeRouter.ts +152 -0
  10. package/lib/__templates__/expo/client/metro.config.js +3 -0
  11. package/lib/__templates__/expo/client/package.json +36 -34
  12. package/lib/__templates__/expo/client/screens/demo/index.tsx +3 -3
  13. package/lib/__templates__/expo/client/scripts/install-missing-deps.js +10 -10
  14. package/lib/__templates__/expo/eslint-plugins/forbid-emoji/index.js +9 -0
  15. package/lib/__templates__/expo/eslint-plugins/forbid-emoji/rule.js +112 -0
  16. package/lib/__templates__/expo/eslint-plugins/forbid-emoji/tech.md +94 -0
  17. package/lib/__templates__/expo/eslint-plugins/react-native/index.js +9 -0
  18. package/lib/__templates__/expo/eslint-plugins/react-native/rule.js +64 -0
  19. package/lib/__templates__/expo/package.json +3 -0
  20. package/lib/__templates__/expo/patches/expo@54.0.33.patch +45 -0
  21. package/lib/__templates__/expo/pnpm-lock.yaml +1318 -2636
  22. package/lib/__templates__/expo/server/package.json +9 -7
  23. package/lib/__templates__/expo/server/src/index.ts +1 -0
  24. package/lib/__templates__/expo/template.config.js +56 -0
  25. package/lib/__templates__/native-static/.coze +11 -0
  26. package/lib/__templates__/native-static/index.html +33 -0
  27. package/lib/__templates__/native-static/styles/main.css +136 -0
  28. package/lib/__templates__/native-static/template.config.js +22 -0
  29. package/lib/__templates__/nextjs/README.md +5 -0
  30. package/lib/__templates__/nextjs/eslint.config.mjs +5 -0
  31. package/lib/__templates__/nextjs/next.config.ts +1 -2
  32. package/lib/__templates__/nextjs/package.json +5 -6
  33. package/lib/__templates__/nextjs/pnpm-lock.yaml +2096 -956
  34. package/lib/__templates__/nextjs/scripts/build.sh +4 -1
  35. package/lib/__templates__/nextjs/scripts/dev.sh +1 -2
  36. package/lib/__templates__/nextjs/scripts/start.sh +1 -1
  37. package/lib/__templates__/nextjs/src/app/layout.tsx +1 -1
  38. package/lib/__templates__/nextjs/src/app/page.tsx +18 -60
  39. package/lib/__templates__/nextjs/src/server.ts +35 -0
  40. package/lib/__templates__/nextjs/template.config.js +49 -14
  41. package/lib/__templates__/nextjs/tsconfig.json +1 -1
  42. package/lib/__templates__/nuxt-vue/.coze +12 -0
  43. package/lib/__templates__/nuxt-vue/README.md +73 -0
  44. package/lib/__templates__/nuxt-vue/_gitignore +24 -0
  45. package/lib/__templates__/nuxt-vue/_npmrc +23 -0
  46. package/lib/__templates__/nuxt-vue/app/app.vue +6 -0
  47. package/lib/__templates__/nuxt-vue/app/pages/index.vue +23 -0
  48. package/lib/__templates__/nuxt-vue/assets/css/main.css +24 -0
  49. package/lib/__templates__/nuxt-vue/nuxt.config.ts +116 -0
  50. package/lib/__templates__/nuxt-vue/package.json +35 -0
  51. package/lib/__templates__/nuxt-vue/pnpm-lock.yaml +8759 -0
  52. package/lib/__templates__/nuxt-vue/postcss.config.mjs +8 -0
  53. package/lib/__templates__/nuxt-vue/public/favicon.ico +0 -0
  54. package/lib/__templates__/nuxt-vue/public/robots.txt +2 -0
  55. package/lib/__templates__/nuxt-vue/scripts/build.sh +14 -0
  56. package/lib/__templates__/nuxt-vue/scripts/dev.sh +31 -0
  57. package/lib/__templates__/nuxt-vue/scripts/prepare.sh +14 -0
  58. package/lib/__templates__/nuxt-vue/scripts/start.sh +15 -0
  59. package/lib/__templates__/nuxt-vue/server/api/hello.ts +10 -0
  60. package/lib/__templates__/nuxt-vue/server/middleware/logger.ts +10 -0
  61. package/lib/__templates__/nuxt-vue/server/routes/health.ts +10 -0
  62. package/lib/__templates__/nuxt-vue/tailwind.config.js +13 -0
  63. package/lib/__templates__/nuxt-vue/template.config.js +87 -0
  64. package/lib/__templates__/nuxt-vue/tsconfig.json +18 -0
  65. package/lib/__templates__/taro/.coze +14 -0
  66. package/lib/__templates__/taro/.cozeproj/scripts/deploy_build.sh +19 -0
  67. package/lib/__templates__/taro/.cozeproj/scripts/deploy_run.sh +14 -0
  68. package/lib/__templates__/taro/.cozeproj/scripts/dev_build.sh +2 -0
  69. package/lib/__templates__/taro/.cozeproj/scripts/dev_run.sh +151 -0
  70. package/lib/__templates__/taro/.cozeproj/scripts/init_env.sh +5 -0
  71. package/lib/__templates__/taro/.cozeproj/scripts/pack.sh +24 -0
  72. package/lib/__templates__/taro/README.md +751 -0
  73. package/lib/__templates__/taro/_gitignore +40 -0
  74. package/lib/__templates__/taro/_npmrc +18 -0
  75. package/lib/__templates__/taro/babel.config.js +12 -0
  76. package/lib/__templates__/taro/config/dev.ts +9 -0
  77. package/lib/__templates__/taro/config/index.ts +223 -0
  78. package/lib/__templates__/taro/config/prod.ts +34 -0
  79. package/lib/__templates__/taro/eslint.config.mjs +80 -0
  80. package/lib/__templates__/taro/key/private.appid.key +0 -0
  81. package/lib/__templates__/taro/package.json +107 -0
  82. package/lib/__templates__/taro/patches/@tarojs__plugin-mini-ci@4.1.9.patch +30 -0
  83. package/lib/__templates__/taro/pnpm-lock.yaml +23100 -0
  84. package/lib/__templates__/taro/pnpm-workspace.yaml +2 -0
  85. package/lib/__templates__/taro/project.config.json +15 -0
  86. package/lib/__templates__/taro/server/nest-cli.json +10 -0
  87. package/lib/__templates__/taro/server/package.json +40 -0
  88. package/lib/__templates__/taro/server/src/app.controller.ts +23 -0
  89. package/lib/__templates__/taro/server/src/app.module.ts +10 -0
  90. package/lib/__templates__/taro/server/src/app.service.ts +8 -0
  91. package/lib/__templates__/taro/server/src/interceptors/http-status.interceptor.ts +23 -0
  92. package/lib/__templates__/taro/server/src/main.ts +49 -0
  93. package/lib/__templates__/taro/server/tsconfig.json +24 -0
  94. package/lib/__templates__/taro/src/app.config.ts +11 -0
  95. package/lib/__templates__/taro/src/app.css +52 -0
  96. package/lib/__templates__/taro/src/app.tsx +9 -0
  97. package/lib/__templates__/taro/src/index.html +39 -0
  98. package/lib/__templates__/taro/src/network.ts +39 -0
  99. package/lib/__templates__/taro/src/pages/index/index.config.ts +3 -0
  100. package/lib/__templates__/taro/src/pages/index/index.css +1 -0
  101. package/lib/__templates__/taro/src/pages/index/index.tsx +33 -0
  102. package/lib/__templates__/taro/src/presets/dev-debug.ts +23 -0
  103. package/lib/__templates__/taro/src/presets/h5-container.tsx +15 -0
  104. package/lib/__templates__/taro/src/presets/h5-navbar.tsx +201 -0
  105. package/lib/__templates__/taro/src/presets/h5-styles.ts +142 -0
  106. package/lib/__templates__/taro/src/presets/index.tsx +18 -0
  107. package/lib/__templates__/taro/stylelint.config.mjs +4 -0
  108. package/lib/__templates__/taro/template.config.js +68 -0
  109. package/lib/__templates__/taro/tsconfig.json +29 -0
  110. package/lib/__templates__/taro/types/global.d.ts +32 -0
  111. package/lib/__templates__/templates.json +75 -0
  112. package/lib/__templates__/vite/README.md +189 -11
  113. package/lib/__templates__/vite/_gitignore +1 -0
  114. package/lib/__templates__/vite/eslint.config.mjs +6 -1
  115. package/lib/__templates__/vite/package.json +20 -3
  116. package/lib/__templates__/vite/pnpm-lock.yaml +944 -1551
  117. package/lib/__templates__/vite/scripts/build.sh +4 -1
  118. package/lib/__templates__/vite/scripts/dev.sh +2 -2
  119. package/lib/__templates__/vite/scripts/start.sh +3 -3
  120. package/lib/__templates__/vite/server/index.ts +57 -0
  121. package/lib/__templates__/vite/server/routes/index.ts +31 -0
  122. package/lib/__templates__/vite/server/vite.ts +79 -0
  123. package/lib/__templates__/vite/src/main.ts +17 -47
  124. package/lib/__templates__/vite/template.config.js +49 -14
  125. package/lib/__templates__/vite/tsconfig.json +4 -3
  126. package/lib/__templates__/vite/vite.config.ts +1 -0
  127. package/lib/cli.js +651 -173
  128. package/package.json +7 -3
@@ -0,0 +1,112 @@
1
+ const DEFAULTS = {
2
+ ignorePatterns: [],
3
+ }
4
+
5
+ const RE_EMOJI =
6
+ // 匹配完整 emoji 序列:基础图形 + 可选变体选择符/肤色 + 可选 ZWJ 连接序列;以及国旗与 keycap
7
+ /(?:\p{Extended_Pictographic}(?:\uFE0F|[\u{1F3FB}-\u{1F3FF}])?(?:\u200D\p{Extended_Pictographic}(?:\uFE0F|[\u{1F3FB}-\u{1F3FF}])?)*)|(?:[\u{1F1E6}-\u{1F1FF}]{2})|(?:[#*0-9]\uFE0F?\u20E3)/gu
8
+
9
+ function buildIgnoreRegexes(patterns) {
10
+ if (!Array.isArray(patterns)) return []
11
+ const result = []
12
+ for (const pattern of patterns) {
13
+ if (typeof pattern !== 'string') continue
14
+ try {
15
+ result.push(new RegExp(pattern))
16
+ } catch (_) {
17
+ continue
18
+ }
19
+ }
20
+ return result
21
+ }
22
+
23
+ function shouldIgnore(text, ignoreRegexes) {
24
+ if (!ignoreRegexes.length) return false
25
+ for (const re of ignoreRegexes) {
26
+ if (re.test(text)) return true
27
+ }
28
+ return false
29
+ }
30
+
31
+ function hasEmoji(text) {
32
+ if (!text) return false
33
+ RE_EMOJI.lastIndex = 0
34
+ return RE_EMOJI.test(text)
35
+ }
36
+
37
+ function collectEmojis(text) {
38
+ if (!text) return []
39
+ RE_EMOJI.lastIndex = 0
40
+ const result = []
41
+ const seen = new Set()
42
+ for (const match of text.matchAll(RE_EMOJI)) {
43
+ if (match[0] && !seen.has(match[0])) {
44
+ seen.add(match[0])
45
+ result.push(match[0])
46
+ }
47
+ }
48
+ return result
49
+ }
50
+
51
+ module.exports = {
52
+ meta: {
53
+ type: 'problem',
54
+ docs: {
55
+ description: 'Disallow emoji in code',
56
+ recommended: 'error',
57
+ },
58
+ schema: [
59
+ {
60
+ type: 'object',
61
+ additionalProperties: false,
62
+ properties: {
63
+ ignorePatterns: {
64
+ type: 'array',
65
+ items: { type: 'string' },
66
+ default: DEFAULTS.ignorePatterns,
67
+ },
68
+ },
69
+ },
70
+ ],
71
+ messages: {
72
+ noEmoji: '禁止在代码中使用 emoji:{{emojis}},请移除或者使用 @expo/vector-icons 图标',
73
+ },
74
+ },
75
+
76
+ create(context) {
77
+ const options = context.options && context.options[0] ? context.options[0] : {}
78
+ const ignoreRegexes = buildIgnoreRegexes(
79
+ Array.isArray(options.ignorePatterns) ? options.ignorePatterns : DEFAULTS.ignorePatterns
80
+ )
81
+
82
+ function checkText(node, text) {
83
+ if (!text) return
84
+ if (shouldIgnore(text, ignoreRegexes)) return
85
+ if (hasEmoji(text)) {
86
+ const emojis = collectEmojis(text)
87
+ const emojiText = emojis.length ? emojis.join(' ') : ''
88
+ context.report({ node, messageId: 'noEmoji', data: { emojis: emojiText } })
89
+ }
90
+ }
91
+
92
+ return {
93
+ Literal(node) {
94
+ if (typeof node.value !== 'string') return
95
+ checkText(node, node.value)
96
+ },
97
+ TemplateLiteral(node) {
98
+ for (const quasi of node.quasis) {
99
+ const cooked = quasi.value && typeof quasi.value.cooked === 'string'
100
+ ? quasi.value.cooked
101
+ : quasi.value && typeof quasi.value.raw === 'string'
102
+ ? quasi.value.raw
103
+ : ''
104
+ checkText(quasi, cooked)
105
+ }
106
+ },
107
+ JSXText(node) {
108
+ checkText(node, node.value)
109
+ },
110
+ }
111
+ },
112
+ }
@@ -0,0 +1,94 @@
1
+ # forbid-emoji 技术设计
2
+
3
+ ## 目标
4
+ - 在代码中检测并禁止使用 emoji
5
+ - 覆盖常见的字符串与 JSX 场景,避免明显漏报
6
+ - 保持实现简单、可维护,避免引入新依赖
7
+
8
+ ## 规则命名与对外形态
9
+ - 插件目录:demo/eslint-plugins/forbid-emoji
10
+ - 规则名:forbid-emoji/no-emoji
11
+ - 规则类型:problem
12
+ - 默认等级:error
13
+
14
+ ## 规则行为定义
15
+ ### 报错
16
+ 当以下任一位置包含 emoji 时,报错:
17
+ - 字符串字面量
18
+ - 模板字符串的静态片段
19
+ - JSXText 文本
20
+ - JSXAttribute 中可静态解析为字符串的值
21
+
22
+ ### 不报错
23
+ 以下场景不触发:
24
+ - 标识符、对象键名、属性名中的字符
25
+ - 数值、正则字面量、BigInt
26
+ - 模板字符串的表达式部分(仅检测静态片段)
27
+ - 被用户显式忽略的路径或内容
28
+
29
+ ## 配置项
30
+ ```json
31
+ {
32
+ "ignorePatterns": []
33
+ }
34
+ ```
35
+ - ignorePatterns:字符串数组,命中任一正则则跳过该文本片段
36
+
37
+ ## 检测策略
38
+ ### AST 访问节点
39
+ - Literal:仅处理 typeof value === 'string'
40
+ - TemplateLiteral:遍历 quasis,使用 cooked 值
41
+ - JSXText:使用 node.value
42
+ - JSXAttribute:可静态解析为字符串时处理
43
+
44
+ ### 忽略策略
45
+ 当文本命中 ignorePatterns 的任一正则时,不再做 emoji 检测,减少误报与白名单配置成本。
46
+
47
+ ## Emoji 识别方案
48
+ ### 组合序列处理
49
+ 考虑到真实文本中的 emoji 组合形式,需要识别以下组合序列并保证命中:
50
+ - 变体选择符:U+FE0F
51
+ - 皮肤色修饰符:U+1F3FB–U+1F3FF
52
+ - ZWJ 组合:U+200D
53
+ - 区域指示符组成的国旗:U+1F1E6–U+1F1FF 的成对序列
54
+ - Keycap 组合:[#*0-9] + U+FE0F? + U+20E3
55
+
56
+ 实现上直接使用完整序列正则匹配,覆盖 ZWJ 连接序列、国旗与 keycap。
57
+
58
+ ### 正则示意
59
+ ```
60
+ const RE_EMOJI =
61
+ /(?:\p{Extended_Pictographic}(?:\uFE0F|[\u{1F3FB}-\u{1F3FF}])?(?:\u200D\p{Extended_Pictographic}(?:\uFE0F|[\u{1F3FB}-\u{1F3FF}])?)*)|(?:[\u{1F1E6}-\u{1F1FF}]{2})|(?:[#*0-9]\uFE0F?\u20E3)/gu
62
+ ```
63
+ 命中即判定为 emoji。
64
+
65
+ ## 报错信息
66
+ - messageId: noEmoji
67
+ - 文案:禁止在代码中使用 emoji
68
+
69
+ ## 典型示例
70
+ ### 触发
71
+ - "hello🙂"
72
+ - `title: "Nice 👍"`
73
+ - <Text>欢迎🎉</Text>
74
+
75
+ ### 不触发
76
+ - const icon = "face-smile"
77
+ - <Text>{user.name}</Text>
78
+ - "hello" + emojiName
79
+
80
+ ## 边界与决策
81
+ - 模板字符串表达式部分:不深入解析,避免执行风险与复杂度
82
+ - 正则字面量:不扫描,避免干扰正则语义
83
+ - 注释:默认不扫描
84
+ - 误报控制:提供 ignorePatterns,由使用者按文件或内容片段进行排除
85
+
86
+ ## 性能考虑
87
+ - 仅在字符串节点上进行扫描
88
+ - 正则预编译并复用
89
+ - 对空字符串与短文本快速返回
90
+
91
+ ## 测试计划
92
+ - 覆盖 Literal、TemplateLiteral、JSXText、JSXAttribute 四类节点
93
+ - 覆盖 ZWJ 组合、变体选择符、国旗、keycap、皮肤色修饰符
94
+ - 覆盖 ignorePatterns 行为
@@ -0,0 +1,9 @@
1
+ const wrapScrollViewInView = require('./rule')
2
+
3
+ const plugin = {
4
+ rules: {
5
+ 'wrap-horizontal-scrollview-inside-view': wrapScrollViewInView,
6
+ },
7
+ };
8
+
9
+ module.exports = plugin
@@ -0,0 +1,64 @@
1
+ module.exports = {
2
+ meta: {
3
+ type: 'problem',
4
+ docs: {
5
+ description: '禁止带有 horizontal: true 属性的 ScrollView 单独使用',
6
+ recommended: false,
7
+ },
8
+ schema: [],
9
+ messages: {
10
+ noSiblings: '禁止带有 props.horizontal: true 的 ScrollView 单独使用,需要在 ScrollView 外层使用一个单独的 View 组件进行包裹',
11
+ },
12
+ },
13
+ create(context) {
14
+ return {
15
+ JSXElement(node) {
16
+ const isScrollView = node.openingElement.name.name === 'ScrollView';
17
+
18
+ if (!isScrollView) {
19
+ return;
20
+ }
21
+
22
+ const hasHorizontalProp = node.openingElement.attributes.some(attr => {
23
+ if (attr.type === 'JSXAttribute' && attr.name.name === 'horizontal') {
24
+ if (!attr.value) {
25
+ return true;
26
+ }
27
+ if (
28
+ attr.value.type === 'JSXExpressionContainer' &&
29
+ attr.value.expression.value === true
30
+ ) {
31
+ return true; // horizontal={true}
32
+ }
33
+ if (attr.value.type === 'Literal' && attr.value.value === true) {
34
+ return true; // horizontal={true} 的另一种形式
35
+ }
36
+ }
37
+ return false;
38
+ });
39
+
40
+ if (!hasHorizontalProp) {
41
+ return;
42
+ }
43
+
44
+ const parent = node.parent;
45
+
46
+ if (
47
+ parent.type === 'JSXFragment' ||
48
+ parent.type === 'JSXElement'
49
+ ) {
50
+ const siblings = parent.children.filter(
51
+ child => child.type === 'JSXElement' && child !== node
52
+ );
53
+
54
+ if (siblings.length > 0) {
55
+ context.report({
56
+ node,
57
+ messageId: 'noSiblings',
58
+ });
59
+ }
60
+ }
61
+ },
62
+ };
63
+ },
64
+ }
@@ -17,6 +17,9 @@
17
17
  "pnpm": {
18
18
  "overrides": {
19
19
  "esbuild": "0.27.2"
20
+ },
21
+ "patchedDependencies": {
22
+ "expo@54.0.33": "patches/expo@54.0.33.patch"
20
23
  }
21
24
  }
22
25
  }
@@ -0,0 +1,45 @@
1
+ diff --git a/src/async-require/hmr.ts b/src/async-require/hmr.ts
2
+ index 33ce50ee2950c40d2b0553b148710f1e24e44f3d..3d78cb02dd7e96ac9727a2935d8178f2c7e95982 100644
3
+ --- a/src/async-require/hmr.ts
4
+ +++ b/src/async-require/hmr.ts
5
+ @@ -216,6 +216,40 @@ const HMRClient: HMRClientNativeInterface = {
6
+
7
+ client.on('update-done', () => {
8
+ hideLoading();
9
+ + if (process.env.EXPO_PUBLIC_COZE_PROJECT_ID && typeof window !== 'undefined' && window.location) {
10
+ + if((window as any).__updateTimeoutId) {
11
+ + clearTimeout((window as any).__updateTimeoutId);
12
+ + }
13
+ + const updateDoneTime = Date.now();
14
+ + (window as any).__updateDoneTime = updateDoneTime;
15
+ + (window as any).__updateTimeoutId = setTimeout(() => {
16
+ + const lastUpdateTime = (window as any).__updateDoneTime;
17
+ + if (lastUpdateTime !== updateDoneTime) return;
18
+ + const checkServerAndReload = (retriesLeft: number) => {
19
+ + if ((window as any).__updateDoneTime !== updateDoneTime) return;
20
+ + fetch(`/favicon.ico?_t=${Date.now()}`)
21
+ + .then((response) => {
22
+ + if (response.status === 200) {
23
+ + console.warn('[HMR] Server is ready (200), reloading now.');
24
+ + window.location.reload();
25
+ + } else {
26
+ + throw new Error(`Server status: ${response.status}`);
27
+ + }
28
+ + }).catch((error) => {
29
+ + console.warn(`[HMR] Check failed (${error.message}). Retries left: ${retriesLeft}`);
30
+ + if (retriesLeft > 0) {
31
+ + setTimeout(() => {
32
+ + checkServerAndReload(retriesLeft - 1);
33
+ + }, 5000);
34
+ + } else {
35
+ + console.error('[HMR] Server unreachable after 6 attempts. Abort reload.');
36
+ + }
37
+ + });
38
+ + };
39
+ + checkServerAndReload(6);
40
+ + }, 35_000);
41
+ + }
42
+ + console.log('[HMR] Update done.');
43
+ });
44
+
45
+ client.on('error', (data: { type: string; message: string }) => {