@coze-arch/cli 0.0.1-alpha.13848f → 0.0.1-alpha.140751
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/lib/__templates__/expo/.cozeproj/scripts/server_dev_run.sh +27 -0
- package/lib/__templates__/expo/client/app/_layout.tsx +14 -14
- package/lib/__templates__/expo/client/app/demo.tsx +1 -0
- package/lib/__templates__/expo/client/app/index.tsx +1 -1
- package/lib/__templates__/expo/client/screens/{home → demo}/index.tsx +1 -1
- package/lib/__templates__/expo/server/package.json +1 -1
- package/lib/__templates__/templates.json +37 -0
- package/lib/cli.js +13 -6
- package/package.json +1 -1
- package/lib/__templates__/expo/client/app/home.tsx +0 -1
- /package/lib/__templates__/expo/client/screens/{home → demo}/styles.ts +0 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
ROOT_DIR="$(cd "$(dirname "$0")/../.." && pwd)"
|
|
4
|
+
SERVER_DIR="$ROOT_DIR/server"
|
|
5
|
+
SERVER_PORT="9091"
|
|
6
|
+
|
|
7
|
+
kill_old_server() {
|
|
8
|
+
if command -v lsof &> /dev/null; then
|
|
9
|
+
local pids
|
|
10
|
+
pids=$(lsof -t -i tcp:"$SERVER_PORT" -sTCP:LISTEN 2>/dev/null || true)
|
|
11
|
+
if [ -n "$pids" ]; then
|
|
12
|
+
echo "正在关闭旧的 server 进程:$pids"
|
|
13
|
+
kill -9 $pids 2>/dev/null || echo "关闭进程失败:$pids"
|
|
14
|
+
sleep 1
|
|
15
|
+
fi
|
|
16
|
+
fi
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
echo "==================== Server Dev Run ===================="
|
|
20
|
+
echo "Server 目录:$SERVER_DIR"
|
|
21
|
+
echo "Server 端口:$SERVER_PORT"
|
|
22
|
+
|
|
23
|
+
kill_old_server
|
|
24
|
+
|
|
25
|
+
echo "启动 server 服务..."
|
|
26
|
+
cd "$SERVER_DIR"
|
|
27
|
+
NODE_ENV=development PORT="$SERVER_PORT" npx tsx ./src/index.ts
|
|
@@ -14,20 +14,20 @@ LogBox.ignoreLogs([
|
|
|
14
14
|
export default function RootLayout() {
|
|
15
15
|
return (
|
|
16
16
|
<AuthProvider>
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
17
|
+
<GestureHandlerRootView style={{ flex: 1 }}>
|
|
18
|
+
<StatusBar style="dark"></StatusBar>
|
|
19
|
+
<Stack screenOptions={{
|
|
20
|
+
// 设置所有页面的切换动画为从右侧滑入,适用于iOS 和 Android
|
|
21
|
+
animation: 'slide_from_right',
|
|
22
|
+
gestureEnabled: true,
|
|
23
|
+
gestureDirection: 'horizontal',
|
|
24
|
+
// 隐藏自带的头部
|
|
25
|
+
headerShown: false
|
|
26
|
+
}}>
|
|
27
|
+
<Stack.Screen name="index" options={{ title: "" }} />
|
|
28
|
+
</Stack>
|
|
29
|
+
<Toast />
|
|
30
|
+
</GestureHandlerRootView>
|
|
31
31
|
</AuthProvider>
|
|
32
32
|
);
|
|
33
33
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@/screens/demo'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default } from '
|
|
1
|
+
export { default } from '@/screens/demo';
|
|
@@ -5,7 +5,7 @@ import { useTheme } from '@/hooks/useTheme';
|
|
|
5
5
|
import { Screen } from '@/components/Screen';
|
|
6
6
|
import { styles } from './styles';
|
|
7
7
|
|
|
8
|
-
export default function
|
|
8
|
+
export default function DemoPage() {
|
|
9
9
|
const { theme, isDark } = useTheme();
|
|
10
10
|
|
|
11
11
|
return (
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"preinstall": "npx only-allow pnpm",
|
|
7
|
-
"dev": "
|
|
7
|
+
"dev": "bash ../.cozeproj/scripts/server_dev_run.sh",
|
|
8
8
|
"build": "pnpm exec esbuild src/index.ts --platform=node --packages=external --bundle --format=esm --outdir=dist",
|
|
9
9
|
"start": "NODE_ENV=production PORT=${PORT:-5000} node dist/index.js"
|
|
10
10
|
},
|
|
@@ -51,6 +51,43 @@
|
|
|
51
51
|
"additionalProperties": false
|
|
52
52
|
}
|
|
53
53
|
},
|
|
54
|
+
{
|
|
55
|
+
"name": "test-only",
|
|
56
|
+
"description": "Test template showcasing all template hooks and features",
|
|
57
|
+
"location": "./test-only",
|
|
58
|
+
"paramsSchema": {
|
|
59
|
+
"type": "object",
|
|
60
|
+
"properties": {
|
|
61
|
+
"appName": {
|
|
62
|
+
"type": "string",
|
|
63
|
+
"minLength": 1,
|
|
64
|
+
"pattern": "^[a-z0-9-]+$",
|
|
65
|
+
"description": "Application name (lowercase, alphanumeric and hyphens only)"
|
|
66
|
+
},
|
|
67
|
+
"port": {
|
|
68
|
+
"type": "number",
|
|
69
|
+
"default": 5000,
|
|
70
|
+
"minimum": 1024,
|
|
71
|
+
"maximum": 65535,
|
|
72
|
+
"description": "Development server port"
|
|
73
|
+
},
|
|
74
|
+
"includeTests": {
|
|
75
|
+
"type": "boolean",
|
|
76
|
+
"default": true,
|
|
77
|
+
"nullable": true,
|
|
78
|
+
"description": "Include test files"
|
|
79
|
+
},
|
|
80
|
+
"addCopyright": {
|
|
81
|
+
"type": "boolean",
|
|
82
|
+
"default": false,
|
|
83
|
+
"nullable": true,
|
|
84
|
+
"description": "Add copyright header to source files"
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
"required": [],
|
|
88
|
+
"additionalProperties": false
|
|
89
|
+
}
|
|
90
|
+
},
|
|
54
91
|
{
|
|
55
92
|
"name": "vite",
|
|
56
93
|
"description": "Vite(简单项目):`coze init ${COZE_WORKSPACE_PATH} --template vite`\n- 适用:轻量级 SPA、纯前端交互、仪表盘等轻量级项目。",
|
package/lib/cli.js
CHANGED
|
@@ -1748,13 +1748,20 @@ const runGitInit = (projectPath) => {
|
|
|
1748
1748
|
/**
|
|
1749
1749
|
* 运行开发服务器(后台模式)
|
|
1750
1750
|
* 启动后台子进程运行开发服务器,父进程可以直接退出
|
|
1751
|
+
* 使用 CLI 自己的 dev 命令(定义在 run.ts)而不是直接运行 npm run dev
|
|
1751
1752
|
*/
|
|
1752
|
-
const
|
|
1753
|
+
const runDev = (projectPath) => {
|
|
1753
1754
|
logger.info('\nStarting development server in background...');
|
|
1754
|
-
|
|
1755
|
+
|
|
1756
|
+
// 获取当前 CLI 的可执行文件路径
|
|
1757
|
+
// process.argv[0] 是 node,process.argv[1] 是 CLI 入口文件
|
|
1758
|
+
const cliPath = process.argv[1];
|
|
1759
|
+
|
|
1760
|
+
logger.info(`Executing: ${cliPath} dev in ${projectPath}`);
|
|
1755
1761
|
|
|
1756
1762
|
// 使用通用的后台执行函数启动开发服务器
|
|
1757
|
-
|
|
1763
|
+
// 调用 CLI 自己的 dev 命令
|
|
1764
|
+
const pid = spawnDetached(process.argv[0], [cliPath, 'dev'], {
|
|
1758
1765
|
cwd: projectPath,
|
|
1759
1766
|
verbose: false, // 不输出额外的进程信息,由 logger 统一处理
|
|
1760
1767
|
});
|
|
@@ -1830,7 +1837,7 @@ const executeInit = async (
|
|
|
1830
1837
|
|
|
1831
1838
|
// 如果没有跳过 dev,则启动开发服务器
|
|
1832
1839
|
if (!skipDev) {
|
|
1833
|
-
|
|
1840
|
+
runDev(absoluteOutputPath);
|
|
1834
1841
|
timer.logPhase('Dev server startup');
|
|
1835
1842
|
} else {
|
|
1836
1843
|
// 只有跳过 dev 时才显示 Next steps
|
|
@@ -1844,7 +1851,7 @@ const executeInit = async (
|
|
|
1844
1851
|
' git init && git add . && git commit -m "initial commit"',
|
|
1845
1852
|
);
|
|
1846
1853
|
}
|
|
1847
|
-
logger.info('
|
|
1854
|
+
logger.info(' coze dev');
|
|
1848
1855
|
}
|
|
1849
1856
|
|
|
1850
1857
|
// 输出总耗时
|
|
@@ -1878,7 +1885,7 @@ const registerCommand = program => {
|
|
|
1878
1885
|
});
|
|
1879
1886
|
};
|
|
1880
1887
|
|
|
1881
|
-
var version = "0.0.1-alpha.
|
|
1888
|
+
var version = "0.0.1-alpha.140751";
|
|
1882
1889
|
var packageJson = {
|
|
1883
1890
|
version: version};
|
|
1884
1891
|
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from '@/screens/home'
|
|
File without changes
|