@coze-arch/cli 0.0.1-alpha.cac8f5 → 0.0.1-alpha.cbb5ba
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 +25 -16
- package/lib/__templates__/expo/.cozeproj/scripts/server_dev_run.sh +9 -8
- package/lib/__templates__/expo/README.md +2 -2
- package/lib/__templates__/expo/client/app/+not-found.tsx +30 -0
- package/lib/__templates__/expo/client/app/_layout.tsx +11 -8
- package/lib/__templates__/expo/client/app.config.ts +2 -2
- package/lib/__templates__/expo/client/components/Screen.tsx +3 -19
- package/lib/__templates__/expo/client/components/ThemedView.tsx +1 -2
- package/lib/__templates__/expo/client/constants/theme.ts +8 -0
- package/lib/__templates__/expo/client/eslint.config.mjs +23 -0
- package/lib/__templates__/expo/client/hooks/{useColorScheme.ts → useColorScheme.tsx} +20 -6
- package/lib/__templates__/expo/client/hooks/useSafeRouter.ts +152 -0
- package/lib/__templates__/expo/client/metro.config.js +3 -0
- package/lib/__templates__/expo/client/package.json +36 -34
- 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/fontawesome6/names.js +1886 -2483
- package/lib/__templates__/expo/eslint-plugins/fontawesome6/rule.js +20 -1
- package/lib/__templates__/expo/eslint-plugins/fontawesome6/v5-only-names.js +388 -0
- 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/react-native/index.js +9 -0
- package/lib/__templates__/expo/eslint-plugins/react-native/rule.js +64 -0
- package/lib/__templates__/expo/eslint-plugins/reanimated/index.js +9 -0
- package/lib/__templates__/expo/eslint-plugins/reanimated/rule.js +88 -0
- package/lib/__templates__/expo/package.json +3 -0
- package/lib/__templates__/expo/patches/expo@54.0.33.patch +45 -0
- package/lib/__templates__/expo/pnpm-lock.yaml +1318 -2636
- 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/.babelrc +15 -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 +8 -6
- package/lib/__templates__/nextjs/pnpm-lock.yaml +3123 -963
- package/lib/__templates__/nextjs/scripts/build.sh +4 -1
- package/lib/__templates__/nextjs/scripts/dev.sh +1 -2
- package/lib/__templates__/nextjs/scripts/start.sh +1 -1
- package/lib/__templates__/nextjs/src/app/layout.tsx +5 -3
- 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 +32 -0
- package/lib/__templates__/nuxt-vue/scripts/prepare.sh +14 -0
- package/lib/__templates__/nuxt-vue/scripts/start.sh +15 -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 +14 -0
- package/lib/__templates__/taro/.cozeproj/scripts/deploy_build.sh +19 -0
- package/lib/__templates__/taro/.cozeproj/scripts/deploy_run.sh +14 -0
- package/lib/__templates__/taro/.cozeproj/scripts/dev_build.sh +2 -0
- package/lib/__templates__/taro/.cozeproj/scripts/dev_run.sh +151 -0
- package/lib/__templates__/taro/.cozeproj/scripts/init_env.sh +5 -0
- package/lib/__templates__/taro/.cozeproj/scripts/pack.sh +24 -0
- package/lib/__templates__/taro/README.md +751 -0
- package/lib/__templates__/taro/_gitignore +40 -0
- package/lib/__templates__/taro/_npmrc +18 -0
- package/lib/__templates__/taro/babel.config.js +12 -0
- package/lib/__templates__/taro/config/dev.ts +9 -0
- package/lib/__templates__/taro/config/index.ts +223 -0
- package/lib/__templates__/taro/config/prod.ts +34 -0
- package/lib/__templates__/taro/eslint.config.mjs +80 -0
- package/lib/__templates__/taro/key/private.appid.key +0 -0
- package/lib/__templates__/taro/package.json +107 -0
- package/lib/__templates__/taro/patches/@tarojs__plugin-mini-ci@4.1.9.patch +30 -0
- package/lib/__templates__/taro/pnpm-lock.yaml +23100 -0
- package/lib/__templates__/taro/pnpm-workspace.yaml +2 -0
- package/lib/__templates__/taro/project.config.json +15 -0
- package/lib/__templates__/taro/server/nest-cli.json +10 -0
- package/lib/__templates__/taro/server/package.json +40 -0
- package/lib/__templates__/taro/server/src/app.controller.ts +23 -0
- package/lib/__templates__/taro/server/src/app.module.ts +10 -0
- package/lib/__templates__/taro/server/src/app.service.ts +8 -0
- package/lib/__templates__/taro/server/src/interceptors/http-status.interceptor.ts +23 -0
- package/lib/__templates__/taro/server/src/main.ts +49 -0
- package/lib/__templates__/taro/server/tsconfig.json +24 -0
- package/lib/__templates__/taro/src/app.config.ts +11 -0
- package/lib/__templates__/taro/src/app.css +52 -0
- package/lib/__templates__/taro/src/app.tsx +9 -0
- package/lib/__templates__/taro/src/index.html +39 -0
- package/lib/__templates__/taro/src/network.ts +39 -0
- package/lib/__templates__/taro/src/pages/index/index.config.ts +3 -0
- package/lib/__templates__/taro/src/pages/index/index.css +1 -0
- package/lib/__templates__/taro/src/pages/index/index.tsx +33 -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 +201 -0
- package/lib/__templates__/taro/src/presets/h5-styles.ts +142 -0
- package/lib/__templates__/taro/src/presets/index.tsx +18 -0
- package/lib/__templates__/taro/stylelint.config.mjs +4 -0
- package/lib/__templates__/taro/template.config.js +68 -0
- package/lib/__templates__/taro/tsconfig.json +29 -0
- package/lib/__templates__/taro/types/global.d.ts +32 -0
- package/lib/__templates__/templates.json +75 -0
- 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 +2 -2
- package/lib/__templates__/vite/scripts/start.sh +3 -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 +897 -182
- package/package.json +7 -3
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
meta: {
|
|
3
|
+
type: 'problem',
|
|
4
|
+
docs: {
|
|
5
|
+
description:
|
|
6
|
+
'Disallow passing useAnimatedScrollHandler return value to ScrollView',
|
|
7
|
+
recommended: 'error',
|
|
8
|
+
},
|
|
9
|
+
schema: [],
|
|
10
|
+
messages: {
|
|
11
|
+
noUseAnimatedScrollHandlerOnScroll:
|
|
12
|
+
'Do not pass useAnimatedScrollHandler return value to ScrollView, pass to Animated.ScrollView instead.',
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
create(context) {
|
|
17
|
+
// 记录 useAnimatedScrollHandler 的本地名字
|
|
18
|
+
let useAnimatedScrollHandlerImportName = null;
|
|
19
|
+
// 记录 ScrollView 的本地名字
|
|
20
|
+
let scrollViewImportName = null;
|
|
21
|
+
// 记录调用 useAnimatedScrollHandler 返回值的变量名
|
|
22
|
+
const animatedScrollHandlerVars = new Set();
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
ImportDeclaration(node) {
|
|
26
|
+
if (node.source.value === 'react-native-reanimated') {
|
|
27
|
+
for (const specifier of node.specifiers) {
|
|
28
|
+
if (
|
|
29
|
+
specifier.type === 'ImportSpecifier' &&
|
|
30
|
+
specifier.imported.name === 'useAnimatedScrollHandler'
|
|
31
|
+
) {
|
|
32
|
+
useAnimatedScrollHandlerImportName = specifier.local.name;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (node.source.value === 'react-native') {
|
|
38
|
+
for (const specifier of node.specifiers) {
|
|
39
|
+
if (
|
|
40
|
+
specifier.type === 'ImportSpecifier' &&
|
|
41
|
+
specifier.imported.name === 'ScrollView'
|
|
42
|
+
) {
|
|
43
|
+
scrollViewImportName = specifier.local.name;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
VariableDeclarator(node) {
|
|
50
|
+
if (
|
|
51
|
+
node.init &&
|
|
52
|
+
node.init.type === 'CallExpression' &&
|
|
53
|
+
node.init.callee.type === 'Identifier' &&
|
|
54
|
+
node.init.callee.name === useAnimatedScrollHandlerImportName
|
|
55
|
+
) {
|
|
56
|
+
if (node.id.type === 'Identifier') {
|
|
57
|
+
animatedScrollHandlerVars.add(node.id.name);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
JSXOpeningElement(node) {
|
|
63
|
+
if (
|
|
64
|
+
node.name.type === 'JSXIdentifier' &&
|
|
65
|
+
node.name.name === scrollViewImportName
|
|
66
|
+
) {
|
|
67
|
+
for (const attr of node.attributes) {
|
|
68
|
+
if (
|
|
69
|
+
attr.type === 'JSXAttribute' &&
|
|
70
|
+
attr.name.name === 'onScroll' &&
|
|
71
|
+
attr.value &&
|
|
72
|
+
attr.value.type === 'JSXExpressionContainer' &&
|
|
73
|
+
attr.value.expression.type === 'Identifier'
|
|
74
|
+
) {
|
|
75
|
+
const varName = attr.value.expression.name;
|
|
76
|
+
if (animatedScrollHandlerVars.has(varName)) {
|
|
77
|
+
context.report({
|
|
78
|
+
node: attr,
|
|
79
|
+
messageId: 'noUseAnimatedScrollHandlerOnScroll',
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
},
|
|
88
|
+
};
|
|
@@ -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 }) => {
|