@coze-arch/cli 0.1.4-alpha.007b56 → 0.1.4-alpha.b94eab
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/.coze +0 -3
- package/lib/__templates__/taro/.coze +0 -4
- package/lib/cli.js +4 -3
- package/lib/deploy/package-project.js +4 -1
- package/package.json +1 -1
- package/lib/__templates__/expo/.cozeproj/scripts/dev_build.ps1 +0 -10
- package/lib/__templates__/expo/.cozeproj/scripts/dev_run.ps1 +0 -74
- package/lib/__templates__/expo/.cozeproj/scripts/validate.ps1 +0 -7
- package/lib/__templates__/taro/.cozeproj/scripts/dev_build.ps1 +0 -3
- package/lib/__templates__/taro/.cozeproj/scripts/dev_run.ps1 +0 -62
- package/lib/__templates__/taro/.cozeproj/scripts/pack.ps1 +0 -7
- package/lib/__templates__/taro/.cozeproj/scripts/validate.ps1 +0 -7
|
@@ -5,11 +5,8 @@ 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"]
|
|
9
8
|
run = ["bash", ".cozeproj/scripts/dev_run.sh"]
|
|
10
|
-
run_win = ["powershell.exe", "-NoProfile", "-ExecutionPolicy", "Bypass", "-File", ".cozeproj/scripts/dev_run.ps1"]
|
|
11
9
|
validate = ["bash", ".cozeproj/scripts/validate.sh"]
|
|
12
|
-
validate_win = ["powershell.exe", "-NoProfile", "-ExecutionPolicy", "Bypass", "-File", ".cozeproj/scripts/validate.ps1"]
|
|
13
10
|
|
|
14
11
|
[deploy]
|
|
15
12
|
build = ["bash", ".cozeproj/scripts/prod_build.sh"]
|
|
@@ -5,14 +5,10 @@ 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"]
|
|
9
8
|
run = ["bash", ".cozeproj/scripts/dev_run.sh"]
|
|
10
|
-
run_win = ["powershell.exe", "-NoProfile", "-ExecutionPolicy", "Bypass", "-File", ".cozeproj/scripts/dev_run.ps1"]
|
|
11
9
|
deps = ["git"] # -> apt install git
|
|
12
10
|
pack = ["bash", ".cozeproj/scripts/pack.sh"]
|
|
13
|
-
pack_win = ["powershell.exe", "-NoProfile", "-ExecutionPolicy", "Bypass", "-File", ".cozeproj/scripts/pack.ps1"]
|
|
14
11
|
validate = ["bash", ".cozeproj/scripts/validate.sh"]
|
|
15
|
-
validate_win = ["powershell.exe", "-NoProfile", "-ExecutionPolicy", "Bypass", "-File", ".cozeproj/scripts/validate.ps1"]
|
|
16
12
|
|
|
17
13
|
[deploy]
|
|
18
14
|
build = ["bash", ".cozeproj/scripts/deploy_build.sh"]
|
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.4-alpha.
|
|
2117
|
+
var version = "0.1.4-alpha.b94eab";
|
|
2118
2118
|
var description = "coze coding devtools cli";
|
|
2119
2119
|
var license = "MIT";
|
|
2120
2120
|
var author = "fanwenjie.fe@bytedance.com";
|
|
@@ -9179,7 +9179,6 @@ const shouldRenderFile = (filePath) => {
|
|
|
9179
9179
|
'.prettierrc',
|
|
9180
9180
|
'.babelrc',
|
|
9181
9181
|
'.sh',
|
|
9182
|
-
'.ps1',
|
|
9183
9182
|
]);
|
|
9184
9183
|
|
|
9185
9184
|
const ext = path.extname(filePath).toLowerCase();
|
|
@@ -12266,7 +12265,9 @@ const EXCLUDED_PARTS = new Set([
|
|
|
12266
12265
|
'.env',
|
|
12267
12266
|
'node_modules',
|
|
12268
12267
|
]);
|
|
12269
|
-
|
|
12268
|
+
// Keep archives reproducible while remaining compatible with downstream ZIP
|
|
12269
|
+
// packaging, whose timestamp range starts in 1980.
|
|
12270
|
+
const REPRODUCIBLE_ARCHIVE_MTIME = new Date('2000-01-01T00:00:00.000Z');
|
|
12270
12271
|
|
|
12271
12272
|
const validateBuildOutput = async (
|
|
12272
12273
|
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
|
-
|
|
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,10 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,74 +0,0 @@
|
|
|
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"
|
|
@@ -1,62 +0,0 @@
|
|
|
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"
|