@coze-arch/cli 0.0.1-alpha.b0f2c2 → 0.0.1-alpha.b41a94
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/README.md +1 -0
- package/lib/__templates__/expo/.cozeproj/scripts/dev_run.sh +13 -12
- package/lib/__templates__/expo/.cozeproj/scripts/server_dev_run.sh +9 -8
- package/lib/__templates__/expo/client/components/Screen.tsx +2 -2
- package/lib/__templates__/expo/client/eslint.config.mjs +7 -0
- package/lib/__templates__/expo/client/metro.config.js +3 -0
- package/lib/__templates__/expo/client/package.json +35 -35
- package/lib/__templates__/expo/client/screens/demo/index.tsx +3 -3
- package/lib/__templates__/expo/client/scripts/install-missing-deps.js +10 -10
- package/lib/__templates__/expo/eslint-plugins/forbid-emoji/index.js +9 -0
- package/lib/__templates__/expo/eslint-plugins/forbid-emoji/rule.js +112 -0
- package/lib/__templates__/expo/eslint-plugins/forbid-emoji/tech.md +94 -0
- package/lib/__templates__/expo/eslint-plugins/restrict-linear-gradient/index.js +9 -0
- package/lib/__templates__/expo/eslint-plugins/restrict-linear-gradient/rule.js +120 -0
- package/lib/__templates__/expo/eslint-plugins/restrict-linear-gradient/tech.md +58 -0
- package/lib/__templates__/expo/package.json +1 -1
- package/lib/__templates__/expo/patches/{expo@54.0.32.patch → expo@54.0.33.patch} +3 -2
- package/lib/__templates__/expo/pnpm-lock.yaml +340 -1736
- package/lib/__templates__/expo/server/package.json +9 -7
- package/lib/__templates__/expo/server/src/index.ts +1 -0
- package/lib/__templates__/expo/template.config.js +56 -0
- package/lib/__templates__/native-static/.coze +11 -0
- package/lib/__templates__/native-static/index.html +33 -0
- package/lib/__templates__/native-static/styles/main.css +136 -0
- package/lib/__templates__/native-static/template.config.js +22 -0
- package/lib/__templates__/nextjs/README.md +5 -0
- package/lib/__templates__/nextjs/eslint.config.mjs +5 -0
- package/lib/__templates__/nextjs/next.config.ts +1 -2
- package/lib/__templates__/nextjs/package.json +5 -6
- package/lib/__templates__/nextjs/pnpm-lock.yaml +1145 -109
- package/lib/__templates__/nextjs/scripts/build.sh +4 -1
- package/lib/__templates__/nextjs/scripts/dev.sh +8 -2
- package/lib/__templates__/nextjs/scripts/start.sh +7 -1
- package/lib/__templates__/nextjs/src/app/layout.tsx +1 -1
- package/lib/__templates__/nextjs/src/app/page.tsx +17 -60
- package/lib/__templates__/nextjs/src/server.ts +35 -0
- package/lib/__templates__/nextjs/template.config.js +49 -14
- package/lib/__templates__/nextjs/tsconfig.json +1 -1
- package/lib/__templates__/nuxt-vue/.coze +12 -0
- package/lib/__templates__/nuxt-vue/README.md +73 -0
- package/lib/__templates__/nuxt-vue/_gitignore +24 -0
- package/lib/__templates__/nuxt-vue/_npmrc +23 -0
- package/lib/__templates__/nuxt-vue/app/app.vue +6 -0
- package/lib/__templates__/nuxt-vue/app/pages/index.vue +23 -0
- package/lib/__templates__/nuxt-vue/assets/css/main.css +24 -0
- package/lib/__templates__/nuxt-vue/nuxt.config.ts +116 -0
- package/lib/__templates__/nuxt-vue/package.json +35 -0
- package/lib/__templates__/nuxt-vue/pnpm-lock.yaml +8759 -0
- package/lib/__templates__/nuxt-vue/postcss.config.mjs +8 -0
- package/lib/__templates__/nuxt-vue/public/favicon.ico +0 -0
- package/lib/__templates__/nuxt-vue/public/robots.txt +2 -0
- package/lib/__templates__/nuxt-vue/scripts/build.sh +14 -0
- package/lib/__templates__/nuxt-vue/scripts/dev.sh +39 -0
- package/lib/__templates__/nuxt-vue/scripts/prepare.sh +14 -0
- package/lib/__templates__/nuxt-vue/scripts/start.sh +21 -0
- package/lib/__templates__/nuxt-vue/server/api/hello.ts +10 -0
- package/lib/__templates__/nuxt-vue/server/middleware/logger.ts +10 -0
- package/lib/__templates__/nuxt-vue/server/routes/health.ts +10 -0
- package/lib/__templates__/nuxt-vue/tailwind.config.js +13 -0
- package/lib/__templates__/nuxt-vue/template.config.js +87 -0
- package/lib/__templates__/nuxt-vue/tsconfig.json +18 -0
- package/lib/__templates__/taro/.coze +1 -1
- package/lib/__templates__/taro/.cozeproj/scripts/deploy_build.sh +2 -2
- package/lib/__templates__/taro/.cozeproj/scripts/deploy_run.sh +4 -3
- package/lib/__templates__/taro/.cozeproj/scripts/dev_build.sh +0 -15
- package/lib/__templates__/taro/.cozeproj/scripts/dev_run.sh +117 -24
- package/lib/__templates__/taro/.cozeproj/scripts/pack.sh +24 -1
- package/lib/__templates__/taro/README.md +138 -62
- package/lib/__templates__/taro/config/index.ts +105 -41
- package/lib/__templates__/taro/config/prod.ts +4 -5
- package/lib/__templates__/taro/eslint.config.mjs +82 -4
- package/lib/__templates__/taro/package.json +22 -13
- package/lib/__templates__/taro/patches/@tarojs__plugin-mini-ci@4.1.9.patch +30 -0
- package/lib/__templates__/taro/pnpm-lock.yaml +1307 -423
- package/lib/__templates__/taro/server/package.json +3 -1
- package/lib/__templates__/taro/server/src/main.ts +14 -2
- package/lib/__templates__/taro/src/app.css +141 -37
- package/lib/__templates__/taro/src/app.tsx +9 -0
- package/lib/__templates__/taro/src/components/ui/accordion.tsx +159 -0
- package/lib/__templates__/taro/src/components/ui/alert-dialog.tsx +260 -0
- package/lib/__templates__/taro/src/components/ui/alert.tsx +60 -0
- package/lib/__templates__/taro/src/components/ui/aspect-ratio.tsx +36 -0
- package/lib/__templates__/taro/src/components/ui/avatar.tsx +84 -0
- package/lib/__templates__/taro/src/components/ui/badge.tsx +37 -0
- package/lib/__templates__/taro/src/components/ui/breadcrumb.tsx +117 -0
- package/lib/__templates__/taro/src/components/ui/button-group.tsx +83 -0
- package/lib/__templates__/taro/src/components/ui/button.tsx +67 -0
- package/lib/__templates__/taro/src/components/ui/calendar.tsx +394 -0
- package/lib/__templates__/taro/src/components/ui/card.tsx +108 -0
- package/lib/__templates__/taro/src/components/ui/carousel.tsx +228 -0
- package/lib/__templates__/taro/src/components/ui/checkbox.tsx +58 -0
- package/lib/__templates__/taro/src/components/ui/code-block.tsx +169 -0
- package/lib/__templates__/taro/src/components/ui/collapsible.tsx +71 -0
- package/lib/__templates__/taro/src/components/ui/command.tsx +385 -0
- package/lib/__templates__/taro/src/components/ui/context-menu.tsx +614 -0
- package/lib/__templates__/taro/src/components/ui/dialog.tsx +256 -0
- package/lib/__templates__/taro/src/components/ui/drawer.tsx +192 -0
- package/lib/__templates__/taro/src/components/ui/dropdown-menu.tsx +561 -0
- package/lib/__templates__/taro/src/components/ui/field.tsx +228 -0
- package/lib/__templates__/taro/src/components/ui/hover-card.tsx +282 -0
- package/lib/__templates__/taro/src/components/ui/input-group.tsx +197 -0
- package/lib/__templates__/taro/src/components/ui/input-otp.tsx +136 -0
- package/lib/__templates__/taro/src/components/ui/input.tsx +56 -0
- package/lib/__templates__/taro/src/components/ui/label.tsx +24 -0
- package/lib/__templates__/taro/src/components/ui/menubar.tsx +595 -0
- package/lib/__templates__/taro/src/components/ui/navigation-menu.tsx +264 -0
- package/lib/__templates__/taro/src/components/ui/pagination.tsx +118 -0
- package/lib/__templates__/taro/src/components/ui/popover.tsx +291 -0
- package/lib/__templates__/taro/src/components/ui/portal.tsx +19 -0
- package/lib/__templates__/taro/src/components/ui/progress.tsx +28 -0
- package/lib/__templates__/taro/src/components/ui/radio-group.tsx +64 -0
- package/lib/__templates__/taro/src/components/ui/resizable.tsx +346 -0
- package/lib/__templates__/taro/src/components/ui/scroll-area.tsx +34 -0
- package/lib/__templates__/taro/src/components/ui/select.tsx +438 -0
- package/lib/__templates__/taro/src/components/ui/separator.tsx +30 -0
- package/lib/__templates__/taro/src/components/ui/sheet.tsx +262 -0
- package/lib/__templates__/taro/src/components/ui/skeleton.tsx +17 -0
- package/lib/__templates__/taro/src/components/ui/slider.tsx +203 -0
- package/lib/__templates__/taro/src/components/ui/sonner.tsx +1 -0
- package/lib/__templates__/taro/src/components/ui/switch.tsx +55 -0
- package/lib/__templates__/taro/src/components/ui/table.tsx +142 -0
- package/lib/__templates__/taro/src/components/ui/tabs.tsx +114 -0
- package/lib/__templates__/taro/src/components/ui/textarea.tsx +54 -0
- package/lib/__templates__/taro/src/components/ui/toast.tsx +517 -0
- package/lib/__templates__/taro/src/components/ui/toggle-group.tsx +120 -0
- package/lib/__templates__/taro/src/components/ui/toggle.tsx +77 -0
- package/lib/__templates__/taro/src/components/ui/tooltip.tsx +455 -0
- package/lib/__templates__/taro/src/index.html +20 -1
- package/lib/__templates__/taro/src/lib/hooks/use-keyboard-offset.ts +37 -0
- package/lib/__templates__/taro/src/lib/measure.ts +115 -0
- package/lib/__templates__/taro/src/lib/platform.ts +12 -0
- package/lib/__templates__/taro/src/lib/utils.ts +6 -0
- package/lib/__templates__/taro/src/presets/dev-debug.ts +23 -0
- package/lib/__templates__/taro/src/presets/h5-container.tsx +15 -0
- package/lib/__templates__/taro/src/presets/h5-navbar.tsx +238 -0
- package/lib/__templates__/taro/src/presets/h5-styles.ts +220 -0
- package/lib/__templates__/taro/src/presets/index.tsx +18 -0
- package/lib/__templates__/templates.json +28 -22
- package/lib/__templates__/vite/README.md +190 -11
- package/lib/__templates__/vite/_gitignore +1 -0
- package/lib/__templates__/vite/eslint.config.mjs +6 -1
- package/lib/__templates__/vite/package.json +14 -3
- package/lib/__templates__/vite/pnpm-lock.yaml +820 -1593
- package/lib/__templates__/vite/scripts/build.sh +4 -1
- package/lib/__templates__/vite/scripts/dev.sh +9 -2
- package/lib/__templates__/vite/scripts/start.sh +9 -3
- package/lib/__templates__/vite/server/routes/index.ts +31 -0
- package/lib/__templates__/vite/server/server.ts +65 -0
- package/lib/__templates__/vite/server/vite.ts +67 -0
- package/lib/__templates__/vite/src/main.ts +17 -47
- package/lib/__templates__/vite/template.config.js +49 -14
- package/lib/__templates__/vite/tsconfig.json +4 -3
- package/lib/__templates__/vite/vite.config.ts +5 -0
- package/lib/cli.js +160 -159
- package/package.json +7 -3
- package/lib/__templates__/taro/src/app.ts +0 -14
- package/lib/__templates__/taro/src/utils/h5-styles.ts +0 -22
- package/lib/__templates__/taro/src/utils/wx-debug.ts +0 -23
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
const LINEAR_GRADIENT_RE = /linear-gradient/i
|
|
2
|
+
|
|
3
|
+
function getPropertyKeyName(property) {
|
|
4
|
+
if (!property || property.type !== 'Property') return null
|
|
5
|
+
if (property.key.type === 'Identifier') return property.key.name
|
|
6
|
+
if (property.key.type === 'Literal' && typeof property.key.value === 'string') {
|
|
7
|
+
return property.key.value
|
|
8
|
+
}
|
|
9
|
+
return null
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function getStaticStringValue(node) {
|
|
13
|
+
if (!node) return null
|
|
14
|
+
if (node.type === 'Literal' && typeof node.value === 'string') return node.value
|
|
15
|
+
if (node.type === 'TemplateLiteral') {
|
|
16
|
+
return node.quasis.map(quasi => quasi.value?.cooked || '').join('')
|
|
17
|
+
}
|
|
18
|
+
return null
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function isLinearGradientString(text) {
|
|
22
|
+
if (!text) return false
|
|
23
|
+
return LINEAR_GRADIENT_RE.test(text)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function checkStyleObjectExpression(objectExpression, report) {
|
|
27
|
+
if (!objectExpression || objectExpression.type !== 'ObjectExpression') return
|
|
28
|
+
for (const property of objectExpression.properties) {
|
|
29
|
+
if (!property || property.type !== 'Property') continue
|
|
30
|
+
const keyName = getPropertyKeyName(property)
|
|
31
|
+
if (keyName !== 'backgroundColor') continue
|
|
32
|
+
const valueText = getStaticStringValue(property.value)
|
|
33
|
+
if (isLinearGradientString(valueText)) {
|
|
34
|
+
report(property.key || property)
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function isStyleSheetMethodCall(node, methodName) {
|
|
40
|
+
if (!node || node.type !== 'CallExpression') return false
|
|
41
|
+
const callee = node.callee
|
|
42
|
+
if (!callee || callee.type !== 'MemberExpression') return false
|
|
43
|
+
if (callee.object.type !== 'Identifier' || callee.object.name !== 'StyleSheet') return false
|
|
44
|
+
if (callee.property.type === 'Identifier') return callee.property.name === methodName
|
|
45
|
+
return false
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function checkStyleExpression(expression, report) {
|
|
49
|
+
if (!expression) return
|
|
50
|
+
if (expression.type === 'ObjectExpression') {
|
|
51
|
+
checkStyleObjectExpression(expression, report)
|
|
52
|
+
return
|
|
53
|
+
}
|
|
54
|
+
if (expression.type === 'ArrayExpression') {
|
|
55
|
+
for (const element of expression.elements) {
|
|
56
|
+
if (!element) continue
|
|
57
|
+
if (element.type === 'SpreadElement') {
|
|
58
|
+
checkStyleExpression(element.argument, report)
|
|
59
|
+
} else {
|
|
60
|
+
checkStyleExpression(element, report)
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return
|
|
64
|
+
}
|
|
65
|
+
// 例:StyleSheet.flatten([styles.a, { backgroundColor: 'linear-gradient(...)' }])
|
|
66
|
+
if (isStyleSheetMethodCall(expression, 'flatten')) {
|
|
67
|
+
const arg = expression.arguments[0]
|
|
68
|
+
checkStyleExpression(arg, report)
|
|
69
|
+
return
|
|
70
|
+
}
|
|
71
|
+
// 例:StyleSheet.compose(styles.a, { backgroundColor: `linear-gradient(${angle},#fff,#000)` })
|
|
72
|
+
if (isStyleSheetMethodCall(expression, 'compose')) {
|
|
73
|
+
const [first, second] = expression.arguments
|
|
74
|
+
checkStyleExpression(first, report)
|
|
75
|
+
checkStyleExpression(second, report)
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
module.exports = {
|
|
80
|
+
meta: {
|
|
81
|
+
type: 'problem',
|
|
82
|
+
docs: {
|
|
83
|
+
description: 'Disallow linear-gradient string in backgroundColor',
|
|
84
|
+
recommended: 'error',
|
|
85
|
+
},
|
|
86
|
+
schema: [],
|
|
87
|
+
messages: {
|
|
88
|
+
noLinearGradientBackgroundColor:
|
|
89
|
+
'backgroundColor 和 linear-gradient 无法一起使用,请将 backgroundColor 改为 experimental_backgroundImage',
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
|
|
93
|
+
create(context) {
|
|
94
|
+
function report(node) {
|
|
95
|
+
context.report({ node, messageId: 'noLinearGradientBackgroundColor' })
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return {
|
|
99
|
+
CallExpression(node) {
|
|
100
|
+
if (!isStyleSheetMethodCall(node, 'create')) return
|
|
101
|
+
const firstArg = node.arguments[0]
|
|
102
|
+
if (!firstArg || firstArg.type !== 'ObjectExpression') return
|
|
103
|
+
|
|
104
|
+
checkStyleObjectExpression(firstArg, report)
|
|
105
|
+
|
|
106
|
+
for (const property of firstArg.properties) {
|
|
107
|
+
if (!property || property.type !== 'Property') continue
|
|
108
|
+
if (!property.value || property.value.type !== 'ObjectExpression') continue
|
|
109
|
+
checkStyleObjectExpression(property.value, report)
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
|
|
113
|
+
JSXAttribute(node) {
|
|
114
|
+
if (!node.name || node.name.name !== 'style') return
|
|
115
|
+
if (!node.value || node.value.type !== 'JSXExpressionContainer') return
|
|
116
|
+
checkStyleExpression(node.value.expression, report)
|
|
117
|
+
},
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# restrict-linear-gradient 技术设计
|
|
2
|
+
|
|
3
|
+
## 目标
|
|
4
|
+
- 禁止在 backgroundColor 中使用 linear-gradient 字符串
|
|
5
|
+
- 覆盖 StyleSheet.create 与 JSX style 的常见写法
|
|
6
|
+
- 实现轻量、易维护,不引入新依赖
|
|
7
|
+
|
|
8
|
+
## 规则命名与对外形态
|
|
9
|
+
- 插件目录:expo/eslint-plugins/restrict-linear-gradient
|
|
10
|
+
- 规则名:restrict-linear-gradient/no-linear-gradient-backgroundcolor
|
|
11
|
+
- 规则类型:problem
|
|
12
|
+
- 默认等级:error
|
|
13
|
+
|
|
14
|
+
## 规则行为定义
|
|
15
|
+
### 报错
|
|
16
|
+
当以下任一位置出现 backgroundColor 且值包含 linear-gradient( 时,报错:
|
|
17
|
+
- StyleSheet.create 的样式对象中
|
|
18
|
+
- JSX 元素 style 属性内的对象或数组成员
|
|
19
|
+
|
|
20
|
+
### 不报错
|
|
21
|
+
以下场景不触发:
|
|
22
|
+
- 非 backgroundColor 的属性
|
|
23
|
+
- backgroundColor 的非字符串值
|
|
24
|
+
- 模板字符串包含表达式的动态值
|
|
25
|
+
- 与 style 无关的对象字面量
|
|
26
|
+
|
|
27
|
+
## 检测策略
|
|
28
|
+
### StyleSheet.create
|
|
29
|
+
遍历 StyleSheet.create 的首个参数对象,检查:
|
|
30
|
+
- 顶层 backgroundColor
|
|
31
|
+
- 每个样式项对应的对象内的 backgroundColor
|
|
32
|
+
|
|
33
|
+
### JSX style
|
|
34
|
+
定位 JSXAttribute(name=style) 后,检查表达式:
|
|
35
|
+
- ObjectExpression
|
|
36
|
+
- ArrayExpression 的各元素
|
|
37
|
+
- StyleSheet.flatten / StyleSheet.compose 的参数
|
|
38
|
+
|
|
39
|
+
## 线性渐变识别
|
|
40
|
+
使用正则 /linear-gradient/i 检测字符串字面量与模板字符串静态片段。
|
|
41
|
+
|
|
42
|
+
## 报错信息
|
|
43
|
+
- messageId: noLinearGradientBackgroundColor
|
|
44
|
+
- 文案:backgroundColor 和 linear-gradient 无法一起使用,请将 backgroundColor 改为 experimental_backgroundImage
|
|
45
|
+
|
|
46
|
+
## 典型示例
|
|
47
|
+
### 触发
|
|
48
|
+
- StyleSheet.create({ a: { backgroundColor: 'linear-gradient(135deg,#F97316 0%,#FB923C 100%)' } })
|
|
49
|
+
- <View style={{ backgroundColor: "linear-gradient(135deg,#F97316 0%,#FB923C 100%)" }} />
|
|
50
|
+
- <View style={[{ backgroundColor: `linear-gradient(135deg,#F97316 0%,#FB923C 100%)` }]} />
|
|
51
|
+
|
|
52
|
+
### 不触发
|
|
53
|
+
- { background: 'linear-gradient(...)' }
|
|
54
|
+
- { backgroundColor: someVar }
|
|
55
|
+
|
|
56
|
+
## 性能考虑
|
|
57
|
+
- 仅扫描目标节点与静态字符串
|
|
58
|
+
- 早返回空节点与非字符串值
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
diff --git a/src/async-require/hmr.ts b/src/async-require/hmr.ts
|
|
2
|
-
index 33ce50ee2950c40d2b0553b148710f1e24e44f3d..
|
|
2
|
+
index 33ce50ee2950c40d2b0553b148710f1e24e44f3d..3d78cb02dd7e96ac9727a2935d8178f2c7e95982 100644
|
|
3
3
|
--- a/src/async-require/hmr.ts
|
|
4
4
|
+++ b/src/async-require/hmr.ts
|
|
5
|
-
@@ -216,6 +216,
|
|
5
|
+
@@ -216,6 +216,40 @@ const HMRClient: HMRClientNativeInterface = {
|
|
6
6
|
|
|
7
7
|
client.on('update-done', () => {
|
|
8
8
|
hideLoading();
|
|
@@ -39,6 +39,7 @@ index 33ce50ee2950c40d2b0553b148710f1e24e44f3d..a13d6f2da10dea858019cc991c21753f
|
|
|
39
39
|
+ checkServerAndReload(6);
|
|
40
40
|
+ }, 35_000);
|
|
41
41
|
+ }
|
|
42
|
+
+ console.log('[HMR] Update done.');
|
|
42
43
|
});
|
|
43
44
|
|
|
44
45
|
client.on('error', (data: { type: string; message: string }) => {
|