@coze-arch/cli 0.0.1-alpha.6d3e84 → 0.0.1-alpha.6d580a

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 (25) hide show
  1. package/lib/__templates__/expo/README.md +2 -0
  2. package/lib/__templates__/expo/client/app/_layout.tsx +11 -8
  3. package/lib/__templates__/expo/client/components/Screen.tsx +1 -17
  4. package/lib/__templates__/expo/client/components/ThemedView.tsx +1 -2
  5. package/lib/__templates__/expo/client/constants/theme.ts +21 -698
  6. package/lib/__templates__/expo/client/eslint.config.mjs +17 -10
  7. package/lib/__templates__/expo/client/hooks/{useColorScheme.ts → useColorScheme.tsx} +20 -6
  8. package/lib/__templates__/expo/client/hooks/useTheme.ts +26 -6
  9. package/lib/__templates__/expo/eslint-plugins/fontawesome6/index.js +9 -0
  10. package/lib/__templates__/expo/eslint-plugins/fontawesome6/names.js +1889 -0
  11. package/lib/__templates__/expo/eslint-plugins/fontawesome6/rule.js +174 -0
  12. package/lib/__templates__/expo/eslint-plugins/fontawesome6/v5-only-names.js +388 -0
  13. package/lib/__templates__/expo/eslint-plugins/reanimated/index.js +9 -0
  14. package/lib/__templates__/expo/eslint-plugins/reanimated/rule.js +88 -0
  15. package/lib/__templates__/expo/server/src/index.ts +2 -1
  16. package/lib/__templates__/nextjs/.babelrc +15 -0
  17. package/lib/__templates__/nextjs/package.json +9 -1
  18. package/lib/__templates__/nextjs/pnpm-lock.yaml +2485 -1714
  19. package/lib/__templates__/nextjs/src/app/layout.tsx +5 -3
  20. package/lib/__templates__/nextjs/template.config.js +5 -5
  21. package/lib/__templates__/vite/package.json +6 -1
  22. package/lib/__templates__/vite/pnpm-lock.yaml +504 -982
  23. package/lib/__templates__/vite/template.config.js +6 -4
  24. package/lib/cli.js +246 -9
  25. package/package.json +1 -1
@@ -1,10 +1,12 @@
1
- import js from "@eslint/js";
2
- import globals from "globals";
3
- import tseslint from "typescript-eslint";
4
- import pluginReact from "eslint-plugin-react";
5
- import reactHooks from "eslint-plugin-react-hooks";
6
- import regexp from "eslint-plugin-regexp";
7
- import pluginImport from "eslint-plugin-import";
1
+ import js from '@eslint/js';
2
+ import globals from 'globals';
3
+ import tseslint from 'typescript-eslint';
4
+ import pluginReact from 'eslint-plugin-react';
5
+ import reactHooks from 'eslint-plugin-react-hooks';
6
+ import regexp from 'eslint-plugin-regexp';
7
+ import pluginImport from 'eslint-plugin-import';
8
+ import fontawesome6 from '../eslint-plugins/fontawesome6/index.js';
9
+ import reanimated from '../eslint-plugins/reanimated/index.js'
8
10
 
9
11
  export default [
10
12
  {
@@ -15,19 +17,20 @@ export default [
15
17
  'src/api/**', // 排除 src 下的自动生成 API
16
18
  '.expo/**', // 排除 Expo 自动生成的文件
17
19
  'tailwind.config.js', // 排除 Tailwind 配置文件
20
+ '**/*.d.ts',
18
21
  ],
19
22
  },
20
23
  regexp.configs["flat/recommended"],
21
24
  js.configs.recommended,
22
25
  ...tseslint.configs.recommended,
23
-
26
+
24
27
  // React 的推荐配置
25
28
  pluginReact.configs.flat.recommended,
26
29
  pluginReact.configs.flat['jsx-runtime'],
27
30
  reactHooks.configs.flat.recommended,
28
31
  {
29
32
  files: ["**/*.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"],
30
-
33
+
31
34
  // 语言选项:设置全局变量
32
35
  languageOptions: {
33
36
  globals: {
@@ -52,6 +55,8 @@ export default [
52
55
 
53
56
  plugins: {
54
57
  import: pluginImport,
58
+ fontawesome6,
59
+ reanimated,
55
60
  },
56
61
  rules: {
57
62
  // 关闭代码风格规则
@@ -70,6 +75,8 @@ export default [
70
75
  'no-prototype-builtins': 'off',
71
76
  'react/react-in-jsx-scope': 'off',
72
77
  'react/jsx-uses-react': 'off',
78
+ 'fontawesome6/valid-name': 'error',
79
+ 'reanimated/ban-mix-use': 'error',
73
80
  },
74
81
  },
75
82
 
@@ -91,7 +98,7 @@ export default [
91
98
  // 在 .js 文件中关闭 TS 规则
92
99
  '@typescript-eslint/no-require-imports': 'off',
93
100
  // 在 Node.js 文件中允许 require
94
- '@typescript-eslint/no-var-requires': 'off',
101
+ '@typescript-eslint/no-var-requires': 'off',
95
102
  'no-undef': 'off',
96
103
  },
97
104
  },
@@ -1,19 +1,21 @@
1
- import { useEffect, useState } from 'react';
1
+ import { createContext, Dispatch, ReactNode, SetStateAction, useContext, useEffect, useState } from 'react';
2
2
  import { ColorSchemeName, useColorScheme as useReactNativeColorScheme, Platform } from 'react-native';
3
3
 
4
- export function useColorScheme() {
4
+ const ColorSchemeContext = createContext<'light' | 'dark' | null | undefined>(null);
5
+
6
+ const ColorSchemeProvider = function ({ children }: { children?: ReactNode }) {
5
7
  const systemColorScheme = useReactNativeColorScheme();
6
- const [colorScheme, setColorScheme] = useState<ColorSchemeName>(systemColorScheme);
8
+ const [colorScheme, setColorScheme] = useState(systemColorScheme);
7
9
 
8
10
  useEffect(() => {
9
11
  setColorScheme(systemColorScheme);
10
- }, [systemColorScheme])
12
+ }, [systemColorScheme]);
11
13
 
12
14
  useEffect(() => {
13
15
  function handleMessage(e: MessageEvent<{ event: string; colorScheme: ColorSchemeName; } | undefined>) {
14
16
  if (e.data?.event === 'coze.workbench.colorScheme') {
15
17
  const cs = e.data.colorScheme;
16
- if (typeof cs === 'string') {
18
+ if (typeof cs === 'string' && typeof setColorScheme === 'function') {
17
19
  setColorScheme(cs);
18
20
  }
19
21
  }
@@ -28,7 +30,19 @@ export function useColorScheme() {
28
30
  window.removeEventListener('message', handleMessage, false);
29
31
  }
30
32
  }
31
- }, []);
33
+ }, [setColorScheme]);
34
+
35
+ return <ColorSchemeContext.Provider value={colorScheme}>
36
+ {children}
37
+ </ColorSchemeContext.Provider>
38
+ };
32
39
 
40
+ function useColorScheme() {
41
+ const colorScheme = useContext(ColorSchemeContext);
33
42
  return colorScheme;
34
43
  }
44
+
45
+ export {
46
+ ColorSchemeProvider,
47
+ useColorScheme,
48
+ }
@@ -1,13 +1,33 @@
1
- import { Colors } from "@/constants/theme";
2
- import { useColorScheme } from "@/hooks/useColorScheme";
1
+ import { Colors } from '@/constants/theme';
2
+ import { useColorScheme } from '@/hooks/useColorScheme';
3
3
 
4
- export function useTheme() {
5
- const colorScheme = useColorScheme();
6
- const isDark = colorScheme === "dark";
7
- const theme = Colors[(colorScheme as "light" | "dark") ?? "light"];
4
+ enum COLOR_SCHEME_CHOICE {
5
+ FOLLOW_SYSTEM = 'follow-system', // 跟随系统自动变化
6
+ DARK = 'dark', // 固定为 dark 主题,不随系统变化
7
+ LIGHT = 'light', // 固定为 light 主题,不随系统变化
8
+ };
9
+
10
+ const userPreferColorScheme: COLOR_SCHEME_CHOICE = COLOR_SCHEME_CHOICE.FOLLOW_SYSTEM;
11
+
12
+ function getTheme(colorScheme?: 'dark' | 'light' | null) {
13
+ const isDark = colorScheme === 'dark';
14
+ const theme = Colors[colorScheme ?? 'light'];
8
15
 
9
16
  return {
10
17
  theme,
11
18
  isDark,
12
19
  };
13
20
  }
21
+
22
+ function useTheme() {
23
+ const systemColorScheme = useColorScheme()
24
+ const colorScheme = userPreferColorScheme === COLOR_SCHEME_CHOICE.FOLLOW_SYSTEM ?
25
+ systemColorScheme :
26
+ userPreferColorScheme;
27
+
28
+ return getTheme(colorScheme);
29
+ }
30
+
31
+ export {
32
+ useTheme,
33
+ }
@@ -0,0 +1,9 @@
1
+ const validName = require('./rule')
2
+
3
+ const plugin = {
4
+ rules: {
5
+ 'valid-name': validName,
6
+ },
7
+ };
8
+
9
+ module.exports = plugin