@coze-arch/cli 0.1.3 → 0.1.4-alpha.4711a7

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.
@@ -5,8 +5,11 @@ project_type = "app"
5
5
 
6
6
  [dev]
7
7
  build = ["bash", ".cozeproj/scripts/dev_build.sh"]
8
+ build_win = ["powershell.exe", "-NoProfile", "-ExecutionPolicy", "Bypass", "-File", ".cozeproj/scripts/dev_build.ps1"]
8
9
  run = ["bash", ".cozeproj/scripts/dev_run.sh"]
10
+ run_win = ["powershell.exe", "-NoProfile", "-ExecutionPolicy", "Bypass", "-File", ".cozeproj/scripts/dev_run.ps1"]
9
11
  validate = ["bash", ".cozeproj/scripts/validate.sh"]
12
+ validate_win = ["powershell.exe", "-NoProfile", "-ExecutionPolicy", "Bypass", "-File", ".cozeproj/scripts/validate.ps1"]
10
13
 
11
14
  [deploy]
12
15
  build = ["bash", ".cozeproj/scripts/prod_build.sh"]
@@ -0,0 +1,10 @@
1
+ $ErrorActionPreference = "Stop"
2
+
3
+ $workspace = if ($env:COZE_WORKSPACE_PATH) { $env:COZE_WORKSPACE_PATH } else { (Get-Location).Path }
4
+ Set-Location $workspace
5
+
6
+ Write-Host "Installing Expo project dependencies..."
7
+ & pnpm install --registry=https://registry.npmmirror.com
8
+ if ($LASTEXITCODE -ne 0) {
9
+ Write-Warning "Expo 项目依赖安装失败"
10
+ }
@@ -0,0 +1,74 @@
1
+ $ErrorActionPreference = "Stop"
2
+
3
+ function Stop-ProcessTree([int] $processId) {
4
+ if ($processId -gt 0 -and (Get-Process -Id $processId -ErrorAction SilentlyContinue)) {
5
+ & taskkill.exe /PID $processId /T /F *> $null
6
+ }
7
+ }
8
+
9
+ function Stop-ListeningProcess([int] $port) {
10
+ Get-NetTCPConnection -LocalPort $port -State Listen -ErrorAction SilentlyContinue |
11
+ Select-Object -ExpandProperty OwningProcess -Unique |
12
+ ForEach-Object { Stop-ProcessTree $_ }
13
+ }
14
+
15
+ function Start-LoggedProcess([string] $workingDirectory, [string] $logFile, [string[]] $arguments, [hashtable] $environment) {
16
+ $previousEnvironment = @{}
17
+ foreach ($key in $environment.Keys) {
18
+ $previousEnvironment[$key] = [Environment]::GetEnvironmentVariable($key, 'Process')
19
+ [Environment]::SetEnvironmentVariable($key, $environment[$key], 'Process')
20
+ }
21
+
22
+ try {
23
+ return Start-Process -FilePath "pnpm.cmd" -ArgumentList $arguments -WorkingDirectory $workingDirectory -RedirectStandardOutput $logFile -RedirectStandardError "$logFile.error" -PassThru
24
+ } finally {
25
+ foreach ($key in $environment.Keys) {
26
+ [Environment]::SetEnvironmentVariable($key, $previousEnvironment[$key], 'Process')
27
+ }
28
+ }
29
+ }
30
+
31
+ $workspace = if ($env:COZE_WORKSPACE_PATH) { $env:COZE_WORKSPACE_PATH } else { (Get-Location).Path }
32
+ $serverPort = if ($env:SERVER_PORT) { [int] $env:SERVER_PORT } else { <%= serverPort %> }
33
+ $expoPort = if ($env:DEPLOY_RUN_PORT) { [int] $env:DEPLOY_RUN_PORT } elseif ($env:EXPO_PORT) { [int] $env:EXPO_PORT } else { <%= port %> }
34
+ $logDirectory = if ($env:COZE_LOG_DIR) { $env:COZE_LOG_DIR } else { Join-Path $workspace "logs" }
35
+ $serverLog = Join-Path $logDirectory "server.log"
36
+ $clientLog = Join-Path $logDirectory "client.log"
37
+ New-Item -ItemType Directory -Force -Path $logDirectory | Out-Null
38
+
39
+ Stop-ListeningProcess $serverPort
40
+ Stop-ListeningProcess $expoPort
41
+
42
+ $webUrl = if ($env:COZE_PROJECT_DOMAIN_DEFAULT) {
43
+ $env:COZE_PROJECT_DOMAIN_DEFAULT
44
+ } elseif ($env:COZE_HARDWARE_DID) {
45
+ "https://cozedaemon-$($env:COZE_HARDWARE_DID)-$expoPort.dev.coze.site"
46
+ } else {
47
+ "http://127.0.0.1:$serverPort"
48
+ }
49
+
50
+ $sharedEnvironment = @{
51
+ EXPO_PUBLIC_BACKEND_BASE_URL = $webUrl
52
+ EXPO_PACKAGER_PROXY_URL = $webUrl
53
+ EXPO_PUBLIC_COZE_PROJECT_ID = $env:COZE_PROJECT_ID
54
+ }
55
+
56
+ Write-Host "Starting server on port $serverPort..."
57
+ $server = Start-LoggedProcess (Join-Path $workspace "server") $serverLog @("exec", "tsx", "watch", "./src/index.ts") (@{ NODE_ENV = "development"; PORT = "$serverPort" })
58
+
59
+ Write-Host "Starting Expo on port $expoPort..."
60
+ $expoEnvironment = @{}
61
+ $sharedEnvironment.GetEnumerator() | ForEach-Object { $expoEnvironment[$_.Key] = $_.Value }
62
+ $expoEnvironment.EXPO_NO_DEPENDENCY_VALIDATION = "1"
63
+ $expo = Start-LoggedProcess (Join-Path $workspace "client") $clientLog @("exec", "expo", "start", "--web", "--clear", "--port", "$expoPort") $expoEnvironment
64
+
65
+ Start-Sleep -Seconds 8
66
+ if ((Test-Path $clientLog) -and (Select-String -Path $clientLog -Pattern "TypeError: fetch failed" -Quiet)) {
67
+ Write-Host "Expo 启动检测到网络错误,启用离线模式重试"
68
+ Stop-ProcessTree $expo.Id
69
+ $expoEnvironment.EXPO_OFFLINE = "1"
70
+ $expo = Start-LoggedProcess (Join-Path $workspace "client") $clientLog @("exec", "expo", "start", "--web", "--clear", "--port", "$expoPort") $expoEnvironment
71
+ }
72
+
73
+ Write-Host "服务已启动。Server PID: $($server.Id), Expo PID: $($expo.Id)"
74
+ Write-Host "EXPO_PUBLIC_BACKEND_BASE_URL=$webUrl"
@@ -0,0 +1,7 @@
1
+ $ErrorActionPreference = "Stop"
2
+
3
+ $workspace = if ($env:COZE_WORKSPACE_PATH) { $env:COZE_WORKSPACE_PATH } else { (Get-Location).Path }
4
+ Set-Location $workspace
5
+
6
+ & pnpm validate
7
+ exit $LASTEXITCODE
@@ -5,10 +5,14 @@ project_type = "miniprogram"
5
5
 
6
6
  [dev]
7
7
  build = ["bash", ".cozeproj/scripts/dev_build.sh"]
8
+ build_win = ["powershell.exe", "-NoProfile", "-ExecutionPolicy", "Bypass", "-File", ".cozeproj/scripts/dev_build.ps1"]
8
9
  run = ["bash", ".cozeproj/scripts/dev_run.sh"]
10
+ run_win = ["powershell.exe", "-NoProfile", "-ExecutionPolicy", "Bypass", "-File", ".cozeproj/scripts/dev_run.ps1"]
9
11
  deps = ["git"] # -> apt install git
10
12
  pack = ["bash", ".cozeproj/scripts/pack.sh"]
13
+ pack_win = ["powershell.exe", "-NoProfile", "-ExecutionPolicy", "Bypass", "-File", ".cozeproj/scripts/pack.ps1"]
11
14
  validate = ["bash", ".cozeproj/scripts/validate.sh"]
15
+ validate_win = ["powershell.exe", "-NoProfile", "-ExecutionPolicy", "Bypass", "-File", ".cozeproj/scripts/validate.ps1"]
12
16
 
13
17
  [deploy]
14
18
  build = ["bash", ".cozeproj/scripts/deploy_build.sh"]
@@ -0,0 +1,3 @@
1
+ $ErrorActionPreference = "Stop"
2
+
3
+ Write-Host "Taro development build does not require a separate step."
@@ -0,0 +1,62 @@
1
+ $ErrorActionPreference = "Stop"
2
+
3
+ function Stop-ProcessTree([int] $processId) {
4
+ if ($processId -gt 0 -and (Get-Process -Id $processId -ErrorAction SilentlyContinue)) {
5
+ & taskkill.exe /PID $processId /T /F *> $null
6
+ }
7
+ }
8
+
9
+ function Stop-ListeningProcess([int] $port) {
10
+ Get-NetTCPConnection -LocalPort $port -State Listen -ErrorAction SilentlyContinue |
11
+ Select-Object -ExpandProperty OwningProcess -Unique |
12
+ ForEach-Object { Stop-ProcessTree $_ }
13
+ }
14
+
15
+ function Start-DevProcess([string] $workingDirectory, [string] $logFile, [hashtable] $environment) {
16
+ $previousEnvironment = @{}
17
+ foreach ($key in $environment.Keys) {
18
+ $previousEnvironment[$key] = [Environment]::GetEnvironmentVariable($key, 'Process')
19
+ [Environment]::SetEnvironmentVariable($key, $environment[$key], 'Process')
20
+ }
21
+
22
+ try {
23
+ return Start-Process -FilePath "pnpm.cmd" -ArgumentList @("dev") -WorkingDirectory $workingDirectory -RedirectStandardOutput $logFile -RedirectStandardError "$logFile.error" -PassThru
24
+ } finally {
25
+ foreach ($key in $environment.Keys) {
26
+ [Environment]::SetEnvironmentVariable($key, $previousEnvironment[$key], 'Process')
27
+ }
28
+ }
29
+ }
30
+
31
+ $workspace = if ($env:COZE_WORKSPACE_PATH) { $env:COZE_WORKSPACE_PATH } else { (Get-Location).Path }
32
+ $port = if ($env:DEPLOY_RUN_PORT) { [int] $env:DEPLOY_RUN_PORT } elseif ($env:PORT) { [int] $env:PORT } else { <%= port %> }
33
+ $serverPort = if ($env:SERVER_PORT) { [int] $env:SERVER_PORT } else { <%= serverPort %> }
34
+ $logDirectory = if ($env:COZE_LOG_DIR) { $env:COZE_LOG_DIR } else { Join-Path $workspace "logs" }
35
+ $logFile = Join-Path $logDirectory "dev.log"
36
+ $pidFile = Join-Path $logDirectory "dev.pid"
37
+ New-Item -ItemType Directory -Force -Path $logDirectory | Out-Null
38
+
39
+ if (Test-Path $pidFile) {
40
+ Stop-ProcessTree ([int] (Get-Content $pidFile -Raw))
41
+ Remove-Item $pidFile -Force
42
+ }
43
+ Stop-ListeningProcess $port
44
+ Stop-ListeningProcess $serverPort
45
+
46
+ $environment = @{ PORT = "$port"; SERVER_PORT = "$serverPort" }
47
+ if ($env:COZE_PROJECT_DOMAIN_DEFAULT) {
48
+ $environment.PROJECT_DOMAIN = $env:COZE_PROJECT_DOMAIN_DEFAULT
49
+ }
50
+
51
+ $process = Start-DevProcess $workspace $logFile $environment
52
+ $process.Id | Set-Content $pidFile
53
+ Start-Sleep -Seconds 1
54
+ if ($process.HasExited) {
55
+ Get-Content "$logFile.error" -Tail 20 -ErrorAction SilentlyContinue
56
+ Remove-Item $pidFile -Force -ErrorAction SilentlyContinue
57
+ exit 1
58
+ }
59
+
60
+ Write-Host "Taro H5 and NestJS services started. PID: $($process.Id)"
61
+ Write-Host "Web port: $port; server port: $serverPort"
62
+ Write-Host "Log file: $logFile"
@@ -0,0 +1,7 @@
1
+ $ErrorActionPreference = "Stop"
2
+
3
+ $workspace = if ($env:COZE_WORKSPACE_PATH) { $env:COZE_WORKSPACE_PATH } else { (Get-Location).Path }
4
+ Set-Location $workspace
5
+
6
+ & pnpm build:pack
7
+ exit $LASTEXITCODE
@@ -0,0 +1,7 @@
1
+ $ErrorActionPreference = "Stop"
2
+
3
+ $workspace = if ($env:COZE_WORKSPACE_PATH) { $env:COZE_WORKSPACE_PATH } else { (Get-Location).Path }
4
+ Set-Location $workspace
5
+
6
+ & pnpm validate
7
+ exit $LASTEXITCODE
package/lib/cli.js CHANGED
@@ -2114,7 +2114,7 @@ const EventBuilder = {
2114
2114
  };
2115
2115
 
2116
2116
  var name = "@coze-arch/cli";
2117
- var version = "0.1.3";
2117
+ var version = "0.1.4-alpha.4711a7";
2118
2118
  var description = "coze coding devtools cli";
2119
2119
  var license = "MIT";
2120
2120
  var author = "fanwenjie.fe@bytedance.com";
@@ -9179,6 +9179,7 @@ const shouldRenderFile = (filePath) => {
9179
9179
  '.prettierrc',
9180
9180
  '.babelrc',
9181
9181
  '.sh',
9182
+ '.ps1',
9182
9183
  ]);
9183
9184
 
9184
9185
  const ext = path.extname(filePath).toLowerCase();
@@ -12265,7 +12266,9 @@ const EXCLUDED_PARTS = new Set([
12265
12266
  '.env',
12266
12267
  'node_modules',
12267
12268
  ]);
12268
- const REPRODUCIBLE_ARCHIVE_MTIME = new Date(0);
12269
+ // Keep archives reproducible while remaining compatible with downstream ZIP
12270
+ // packaging, whose timestamp range starts in 1980.
12271
+ const REPRODUCIBLE_ARCHIVE_MTIME = new Date('2000-01-01T00:00:00.000Z');
12269
12272
 
12270
12273
  const validateBuildOutput = async (
12271
12274
  sourceRoot,
@@ -35,7 +35,10 @@ const LOCAL_METADATA_FILES = new Set([
35
35
  '.host.json',
36
36
  ]);
37
37
  const UPLOAD_SESSION_TEMP_PREFIX = '.coze-deploy-upload-';
38
- const REPRODUCIBLE_ARCHIVE_MTIME = new Date(0);
38
+ // Keep archives reproducible without producing timestamps that ZIP cannot
39
+ // represent when the Deploy service repackages the source. Using 2000 also
40
+ // avoids the 1980 lower-bound edge in tools that apply a local timezone.
41
+ const REPRODUCIBLE_ARCHIVE_MTIME = new Date('2000-01-01T00:00:00.000Z');
39
42
  const PROJECT_METADATA_FILE_MODE = 0o644;
40
43
 
41
44
  const parseArguments = argv => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coze-arch/cli",
3
- "version": "0.1.3",
3
+ "version": "0.1.4-alpha.4711a7",
4
4
  "private": false,
5
5
  "description": "coze coding devtools cli",
6
6
  "license": "MIT",