@coze-arch/cli 0.0.1-alpha.3002ee → 0.0.1-alpha.3ce8c6

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 (60) hide show
  1. package/lib/__templates__/expo/.coze +7 -2
  2. package/lib/__templates__/expo/.cozeproj/scripts/{deploy_build.sh → dev_build.sh} +4 -10
  3. package/lib/__templates__/expo/.cozeproj/scripts/{deploy_run.sh → dev_run.sh} +25 -57
  4. package/lib/__templates__/expo/.cozeproj/scripts/prod_build.sh +47 -0
  5. package/lib/__templates__/expo/.cozeproj/scripts/prod_run.sh +34 -0
  6. package/lib/__templates__/expo/README.md +41 -12
  7. package/lib/__templates__/expo/_gitignore +1 -1
  8. package/lib/__templates__/expo/_npmrc +3 -5
  9. package/lib/__templates__/expo/client/app/_layout.tsx +1 -1
  10. package/lib/__templates__/expo/client/app/index.ts +1 -0
  11. package/lib/__templates__/expo/client/app.config.ts +71 -0
  12. package/lib/__templates__/expo/client/components/ThemedText.tsx +33 -0
  13. package/lib/__templates__/expo/client/components/ThemedView.tsx +38 -0
  14. package/lib/__templates__/expo/client/constants/theme.ts +779 -47
  15. package/lib/__templates__/expo/client/contexts/AuthContext.tsx +14 -107
  16. package/lib/__templates__/expo/client/hooks/useTheme.ts +1 -1
  17. package/lib/__templates__/expo/client/metro.config.js +121 -0
  18. package/lib/__templates__/expo/client/package.json +92 -0
  19. package/lib/__templates__/expo/client/screens/home/index.tsx +1 -5
  20. package/lib/__templates__/expo/client/screens/home/styles.ts +1 -273
  21. package/lib/__templates__/expo/client/tsconfig.json +24 -0
  22. package/lib/__templates__/expo/client/utils/index.ts +1 -2
  23. package/lib/__templates__/expo/package.json +16 -12
  24. package/lib/__templates__/expo/pnpm-lock.yaml +383 -516
  25. package/lib/__templates__/expo/pnpm-workspace.yaml +3 -0
  26. package/lib/__templates__/expo/server/package.json +17 -0
  27. package/lib/__templates__/expo/{src → server/src}/index.ts +2 -2
  28. package/lib/__templates__/expo/template.config.js +1 -1
  29. package/lib/__templates__/expo/tsconfig.json +1 -24
  30. package/lib/__templates__/nextjs/.coze +3 -3
  31. package/lib/__templates__/nextjs/_npmrc +1 -1
  32. package/lib/__templates__/nextjs/package.json +8 -3
  33. package/lib/__templates__/nextjs/pnpm-lock.yaml +2495 -1122
  34. package/lib/__templates__/nextjs/scripts/dev.sh +8 -27
  35. package/lib/__templates__/nextjs/src/app/globals.css +99 -87
  36. package/lib/__templates__/nextjs/src/app/layout.tsx +18 -22
  37. package/lib/__templates__/nextjs/template.config.js +1 -1
  38. package/lib/__templates__/templates.json +7 -0
  39. package/lib/__templates__/vite/.coze +3 -3
  40. package/lib/__templates__/vite/README.md +204 -26
  41. package/lib/__templates__/vite/_npmrc +1 -1
  42. package/lib/__templates__/vite/package.json +1 -1
  43. package/lib/__templates__/vite/pnpm-lock.yaml +120 -120
  44. package/lib/__templates__/vite/scripts/dev.sh +7 -26
  45. package/lib/__templates__/vite/template.config.js +10 -1
  46. package/lib/__templates__/vite/vite.config.ts +3 -3
  47. package/lib/cli.js +408 -248
  48. package/package.json +7 -3
  49. package/lib/__templates__/expo/app.json +0 -63
  50. package/lib/__templates__/expo/babel.config.js +0 -9
  51. package/lib/__templates__/expo/client/app/(tabs)/_layout.tsx +0 -43
  52. package/lib/__templates__/expo/client/app/(tabs)/home.tsx +0 -1
  53. package/lib/__templates__/expo/client/app/(tabs)/index.tsx +0 -7
  54. package/lib/__templates__/expo/client/app/+not-found.tsx +0 -79
  55. package/lib/__templates__/expo/client/index.js +0 -12
  56. package/lib/__templates__/expo/metro.config.js +0 -53
  57. package/lib/__templates__/nextjs/.babelrc +0 -15
  58. package/lib/__templates__/nextjs/server.mjs +0 -50
  59. /package/lib/__templates__/expo/{eslint-formatter-simple.mjs → client/eslint-formatter-simple.mjs} +0 -0
  60. /package/lib/__templates__/expo/{eslint.config.mjs → client/eslint.config.mjs} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coze-arch/cli",
3
- "version": "0.0.1-alpha.3002ee",
3
+ "version": "0.0.1-alpha.3ce8c6",
4
4
  "private": false,
5
5
  "description": "coze coding devtools cli",
6
6
  "license": "MIT",
@@ -19,7 +19,7 @@
19
19
  "scripts": {
20
20
  "prebuild": "tsx scripts/prebuild.ts",
21
21
  "build": "tsx scripts/build.ts",
22
- "generate-templates": "tsx scripts/generate-templates-config.ts",
22
+ "create": "tsx scripts/create-template.ts",
23
23
  "lint": "eslint ./ --cache",
24
24
  "postpublish": "bash scripts/sync-npmmirror.sh",
25
25
  "test": "vitest --run --passWithNoTests",
@@ -32,12 +32,14 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "@iarna/toml": "^2.2.5",
35
+ "@inquirer/prompts": "^3.2.0",
35
36
  "ajv": "^8.17.1",
36
37
  "ajv-formats": "^3.0.1",
37
38
  "change-case": "^5.4.4",
38
39
  "commander": "~12.1.0",
39
40
  "ejs": "^3.1.10",
40
41
  "js-yaml": "^4.1.0",
42
+ "minimist": "^1.2.5",
41
43
  "shelljs": "^0.10.0"
42
44
  },
43
45
  "devDependencies": {
@@ -51,6 +53,7 @@
51
53
  "@types/ejs": "^3.1.5",
52
54
  "@types/iarna__toml": "^2.0.5",
53
55
  "@types/js-yaml": "^4.0.9",
56
+ "@types/minimist": "^1.2.5",
54
57
  "@types/node": "^24",
55
58
  "@types/shelljs": "^0.10.0",
56
59
  "@vitest/coverage-v8": "~4.0.16",
@@ -61,7 +64,8 @@
61
64
  "vitest": "~4.0.16"
62
65
  },
63
66
  "publishConfig": {
64
- "access": "public"
67
+ "access": "public",
68
+ "registry": "https://registry.npmjs.org"
65
69
  },
66
70
  "cozePublishConfig": {
67
71
  "bin": {
@@ -1,63 +0,0 @@
1
- {
2
- "expo": {
3
- "name": "${app_name}",
4
- "slug": "${slug}",
5
- "version": "1.0.0",
6
- "orientation": "portrait",
7
- "icon": "./client/assets/images/icon.png",
8
- "scheme": "myapp",
9
- "userInterfaceStyle": "automatic",
10
- "newArchEnabled": true,
11
- "ios": {
12
- "supportsTablet": true
13
- },
14
- "android": {
15
- "adaptiveIcon": {
16
- "foregroundImage": "./client/assets/images/adaptive-icon.png",
17
- "backgroundColor": "#ffffff"
18
- }
19
- },
20
- "web": {
21
- "bundler": "metro",
22
- "output": "single",
23
- "favicon": "./client/assets/images/favicon.png"
24
- },
25
- "plugins": [
26
- "expo-router",
27
- [
28
- "expo-splash-screen",
29
- {
30
- "image": "./client/assets/images/splash-icon.png",
31
- "imageWidth": 200,
32
- "resizeMode": "contain",
33
- "backgroundColor": "#ffffff"
34
- }
35
- ],
36
- [
37
- "expo-image-picker",
38
- {
39
- "photosPermission": "允许${app_name}访问您的相册,以便您上传或保存图片。",
40
- "cameraPermission": "允许${app_name}使用您的相机,以便您直接拍摄照片上传。",
41
- "microphonePermission": "允许${app_name}访问您的麦克风,以便您拍摄带有声音的视频。"
42
- }
43
- ],
44
- [
45
- "expo-location",
46
- {
47
- "locationWhenInUsePermission": "${app_name}需要访问您的位置以提供周边服务及导航功能。"
48
- }
49
- ],
50
- [
51
- "expo-camera",
52
- {
53
- "cameraPermission": "${app_name}需要访问相机以拍摄照片和视频。",
54
- "microphonePermission": "${app_name}需要访问麦克风以录制视频声音。",
55
- "recordAudioAndroid": true
56
- }
57
- ]
58
- ],
59
- "experiments": {
60
- "typedRoutes": true
61
- }
62
- }
63
- }
@@ -1,9 +0,0 @@
1
- module.exports = function (api) {
2
- api.cache(true);
3
- return {
4
- presets: ["babel-preset-expo"],
5
- plugins: [
6
- "react-native-reanimated/plugin",
7
- ],
8
- };
9
- };
@@ -1,43 +0,0 @@
1
- import { Tabs } from 'expo-router';
2
- import { FontAwesome6 } from '@expo/vector-icons';
3
- import { useSafeAreaInsets } from 'react-native-safe-area-context';
4
- import { useTheme } from '@/hooks/useTheme';
5
-
6
- export default function TabLayout() {
7
- const insets = useSafeAreaInsets();
8
- const { theme } = useTheme();
9
- const tabBarHeight = 56 + Math.max(insets.bottom, 8);
10
-
11
- return (
12
- <Tabs
13
- backBehavior='history'
14
- screenOptions={{
15
- headerShown: false,
16
- tabBarActiveTintColor: theme.tabIconSelected,
17
- tabBarInactiveTintColor: theme.tabIconDefault,
18
- tabBarStyle: {
19
- backgroundColor: theme.backgroundRoot,
20
- borderTopColor: theme.backgroundSecondary,
21
- borderTopWidth: 1,
22
- height: tabBarHeight,
23
- paddingBottom: Math.max(insets.bottom, 8),
24
- paddingTop: 6,
25
- },
26
- }}
27
- >
28
- <Tabs.Screen
29
- name='index'
30
- options={{ href: null }}
31
- />
32
- <Tabs.Screen
33
- name='home'
34
- options={{
35
- title: '首页',
36
- tabBarIcon: ({ color }) => (
37
- <FontAwesome6 name='house' size={20} color={color} />
38
- ),
39
- }}
40
- />
41
- </Tabs>
42
- );
43
- }
@@ -1 +0,0 @@
1
- export { default } from "@/screens/home";
@@ -1,7 +0,0 @@
1
- import { Redirect } from 'expo-router';
2
-
3
- const Index = () => {
4
- return <Redirect href="./home" relativeToDirectory />;
5
- };
6
-
7
- export default Index;
@@ -1,79 +0,0 @@
1
- import { useRouter } from 'expo-router';
2
- import { StyleSheet, View, Text, Pressable, Platform } from 'react-native';
3
-
4
- export default function NotFoundScreen() {
5
- const router = useRouter();
6
-
7
- const goBack = () => {
8
- if (router.canGoBack()) {
9
- router.back();
10
- }
11
- };
12
-
13
- return (
14
- <View style={styles.container}>
15
- <Text style={styles.heading}>404</Text>
16
- <Text style={styles.textStyle}>页面未找到</Text>
17
- <Text style={styles.subTextStyle}>
18
- 抱歉!您访问的页面不存在,当前页面功能待完善。
19
- </Text>
20
- <Pressable onPress={goBack} style={styles.button}>
21
- <Text style={styles.buttonText}>返回上一页</Text>
22
- </Pressable>
23
- </View>
24
- );
25
- }
26
-
27
- const styles = StyleSheet.create({
28
- container: {
29
- flex: 1,
30
- alignItems: 'center',
31
- justifyContent: 'center',
32
- backgroundColor: '#f3f5ff',
33
- padding: 16,
34
- },
35
- heading: {
36
- fontSize: 120,
37
- fontWeight: '900',
38
- color: '#4a5568',
39
- textShadowColor: 'rgba(0, 0, 0, 0.05)',
40
- textShadowOffset: { width: 0, height: 4 },
41
- textShadowRadius: 8,
42
- },
43
- textStyle: {
44
- fontSize: 24,
45
- fontWeight: '500',
46
- marginTop: -16,
47
- marginBottom: 16,
48
- color: '#4a5568',
49
- },
50
- subTextStyle: {
51
- fontSize: 16,
52
- color: '#718096',
53
- marginBottom: 32,
54
- maxWidth: 400,
55
- textAlign: 'center',
56
- },
57
- button: {
58
- paddingVertical: 12,
59
- paddingHorizontal: 24,
60
- backgroundColor: '#6366f1',
61
- borderRadius: 9999,
62
- ...Platform.select({
63
- ios: {
64
- shadowColor: 'rgba(0, 0, 0, 0.1)',
65
- shadowOffset: { width: 0, height: 10 },
66
- shadowOpacity: 1,
67
- shadowRadius: 15,
68
- },
69
- android: {
70
- elevation: 5,
71
- },
72
- }),
73
- },
74
- buttonText: {
75
- fontSize: 16,
76
- fontWeight: '600',
77
- color: '#ffffff',
78
- },
79
- });
@@ -1,12 +0,0 @@
1
- import '@expo/metro-runtime';
2
- import { registerRootComponent } from 'expo';
3
- import { ExpoRoot } from 'expo-router';
4
-
5
- // 显式定义 App 组件
6
- export function App() {
7
- // eslint-disable-next-line no-undef
8
- const ctx = require.context('./app');
9
- return <ExpoRoot context={ctx} />;
10
- }
11
-
12
- registerRootComponent(App);
@@ -1,53 +0,0 @@
1
- const { getDefaultConfig } = require('expo/metro-config');
2
- // const { createProxyMiddleware } = require('http-proxy-middleware');
3
- const connect = require('connect');
4
-
5
- const config = getDefaultConfig(__dirname);
6
-
7
- // 安全地获取 Expo 的默认排除列表
8
- const existingBlockList = [].concat(config.resolver.blockList || []);
9
-
10
- config.resolver.blockList = [
11
- ...existingBlockList,
12
- /.*\/\.expo\/.*/, // Expo 的缓存和构建产物目录
13
-
14
- // 1. 原生代码 (Java/C++/Objective-C)
15
- /.*\/react-native\/ReactAndroid\/.*/,
16
- /.*\/react-native\/ReactCommon\/.*/,
17
-
18
- // 2. 纯开发和调试工具
19
- // 这些工具只在开发电脑上运行,不会被打包到应用中
20
- /.*\/@typescript-eslint\/eslint-plugin\/.*/,
21
-
22
- // 3. 构建时数据
23
- // 这个数据库只在打包过程中使用,应用运行时不需要
24
- /.*\/caniuse-lite\/data\/.*/,
25
-
26
- // 4. 通用规则
27
- /.*\/__tests__\/.*/, // 排除所有测试目录
28
- /.*\.git\/.*/, // 排除 Git 目录
29
- ];
30
-
31
- /*
32
- const apiProxy = createProxyMiddleware({
33
- target: 'http://localhost:5000',
34
- logLevel: 'debug',
35
- });
36
-
37
- config.server = {
38
- ...config.server,
39
- enhanceMiddleware: (metroMiddleware, metroServer) => {
40
- return connect()
41
- .use((req, res, next) => {
42
- if (req.url && req.url.startsWith('/api')) {
43
- console.log(`[Metro Proxy] Forwarding ${req.method} ${req.url}`);
44
- return apiProxy(req, res, next);
45
- }
46
- next();
47
- })
48
- .use(metroMiddleware);
49
- },
50
- }
51
- */
52
-
53
- module.exports = config;
@@ -1,15 +0,0 @@
1
- {
2
- "presets": [
3
- [
4
- "next/babel",
5
- {
6
- "preset-react": {
7
- "development": true
8
- }
9
- }
10
- ]
11
- ],
12
- "plugins": [
13
- "@react-dev-inspector/babel-plugin"
14
- ]
15
- }
@@ -1,50 +0,0 @@
1
- import { createServer } from 'node:http';
2
- import next from 'next';
3
- import { launchEditorMiddleware } from '@react-dev-inspector/middleware';
4
-
5
- const dev = process.env.NODE_ENV !== 'production';
6
- const hostname = process.env.HOSTNAME || 'localhost';
7
- const port = parseInt(process.env.PORT || '3000', 10);
8
-
9
- const app = next({ dev, hostname, port });
10
- const handle = app.getRequestHandler();
11
-
12
- app.prepare().then(() => {
13
- createServer((req, res) => {
14
- /**
15
- * Middlewares, from top to bottom
16
- */
17
- const middlewares = [
18
- /**
19
- * react-dev-inspector middleware for launching editor
20
- * Only active in development mode
21
- */
22
- ...(dev ? [launchEditorMiddleware] : []),
23
-
24
- /**
25
- * Next.js default app handler
26
- */
27
- (req, res) => handle(req, res),
28
- ];
29
-
30
- /**
31
- * Build middleware pipeline using reduceRight
32
- * Executes middlewares from top to bottom
33
- */
34
- const middlewarePipeline = middlewares.reduceRight(
35
- (next, middleware) => () => {
36
- middleware(req, res, next);
37
- },
38
- () => {},
39
- );
40
-
41
- middlewarePipeline();
42
- })
43
- .once('error', (err) => {
44
- console.error(err);
45
- process.exit(1);
46
- })
47
- .listen(port, () => {
48
- console.log(`> Ready on http://${hostname}:${port}`);
49
- });
50
- });