cj-tauri 2.3.2 → 2.3.6
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/cjpm.toml +1 -1
- package/cli/cjpm.toml +12 -1
- package/cli/src/main.cj +8 -0
- package/cli/src/project.cj +15 -16
- package/cli/src/scaffold.cj +1 -1
- package/cli/src/sign_agc.cj +386 -0
- package/cli/src/sign_auto.cj +592 -0
- package/cli/src/sign_cloud.cj +724 -0
- package/cli/src/sign_cmd.cj +444 -0
- package/cli/src/sign_gcm.cj +703 -0
- package/cli/src/sign_login.cj +602 -0
- package/cli/src/sign_offline.cj +1183 -0
- package/cli/src/sign_test.cj +298 -0
- package/cli/src/sign_tool.cj +235 -0
- package/cli/src/sync.cj +90 -25
- package/cli/src/util.cj +26 -1
- package/cli/src/util_path_test.cj +72 -0
- package/cli/templates/app/README.md +1 -0
- package/cli/templates/app-react/README.md +1 -0
- package/cli/templates/app-vue/README.md +1 -0
- package/cli/templates/ohos-skeleton/README.md +19 -1
- package/cli/templates/ohos-skeleton/build-hap.bat +219 -0
- package/package.json +1 -1
- package/src/host_arkweb.cj +10 -0
- package/src/version.cj +1 -1
- package/cli/templates/ohos-skeleton/build-hap.ps1 +0 -205
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
# {{PROJECT_NAME}} - HarmonyOS PC (2in1) HAP build entry for PowerShell.
|
|
2
|
-
#
|
|
3
|
-
# PowerShell twin of build-hap.sh (same steps, native Windows paths; no Git Bash needed).
|
|
4
|
-
# Usage:
|
|
5
|
-
# powershell -ExecutionPolicy Bypass -File build-hap.ps1 build the hap
|
|
6
|
-
# powershell -ExecutionPolicy Bypass -File build-hap.ps1 -Install build + hdc install + aa start
|
|
7
|
-
# powershell -ExecutionPolicy Bypass -File build-hap.ps1 -Clean remove entry/build first
|
|
8
|
-
#
|
|
9
|
-
# Prerequisites (each checked below with an actionable message):
|
|
10
|
-
# 1. DevEco Studio 6.1+ (ships hvigor + node). Probed at common locations;
|
|
11
|
-
# set DEVECO_WIN=<install root, Windows form> to override.
|
|
12
|
-
# 2. Ohos stdx: set CANGJIE_STDX_OHOS=<stdx>/linux_ohos_aarch64_cjnative/dynamic/stdx
|
|
13
|
-
# - without it cjpm reports a misleading "missing dependency" error.
|
|
14
|
-
# 3. Signing: the template ships no certificate. In DevEco: File -> Project Structure ->
|
|
15
|
-
# Signing Configs -> "Automatically generate signature" (requires a Huawei account).
|
|
16
|
-
# Unsigned builds still produce *-unsigned.hap but cannot be installed (9568289 etc.).
|
|
17
|
-
|
|
18
|
-
$ErrorActionPreference = "Stop"
|
|
19
|
-
$RootDir = $PSScriptRoot
|
|
20
|
-
$DoInstall = $false
|
|
21
|
-
$DoClean = $false
|
|
22
|
-
foreach ($a in $args) {
|
|
23
|
-
switch -- ($a.ToLower()) {
|
|
24
|
-
"-install" { $DoInstall = $true }
|
|
25
|
-
"--install" { $DoInstall = $true }
|
|
26
|
-
"-clean" { $DoClean = $true }
|
|
27
|
-
"--clean" { $DoClean = $true }
|
|
28
|
-
"-h" { Get-Content $PSCommandPath | Select-Object -First 22; exit 0 }
|
|
29
|
-
"--help" { Get-Content $PSCommandPath | Select-Object -First 22; exit 0 }
|
|
30
|
-
default { Write-Error "[ohos] unknown arg: $a (supported: -Install / -Clean / -Help)"; exit 2 }
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function Write-Ohos([string]$msg) { Write-Host "[ohos] $msg" }
|
|
35
|
-
function Write-OhosErr([string]$msg) { Write-Host "[ohos] $msg" -ForegroundColor Red }
|
|
36
|
-
|
|
37
|
-
# DevEco install root: DEVECO_WIN first, then common locations.
|
|
38
|
-
function Find-Deveco {
|
|
39
|
-
if ($env:DEVECO_WIN) { return $env:DEVECO_WIN }
|
|
40
|
-
foreach ($cand in @(
|
|
41
|
-
"D:\oh\DevEcoStudio",
|
|
42
|
-
"C:\Program Files\Huawei\DevEco Studio",
|
|
43
|
-
"D:\Program Files\Huawei\DevEco Studio",
|
|
44
|
-
"C:\Program Files (x86)\Huawei\DevEco Studio")) {
|
|
45
|
-
if (Test-Path (Join-Path $cand "tools\hvigor")) { return $cand }
|
|
46
|
-
}
|
|
47
|
-
return $null
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
# A preset env value pointing at a non-existent dir makes hvigor fail with
|
|
51
|
-
# "Invalid value of 'DEVECO_SDK_HOME'" - fall back and say what was ignored.
|
|
52
|
-
function Pick-DevecoPath([string]$cand, [string]$fallback) {
|
|
53
|
-
if ($cand -and (Test-Path $cand)) { return $cand }
|
|
54
|
-
if ($cand) { Write-OhosErr "ignoring invalid path: $cand, using $fallback" }
|
|
55
|
-
return $fallback
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
$deveco = Find-Deveco
|
|
59
|
-
if (-not $deveco) {
|
|
60
|
-
Write-OhosErr "DevEco Studio not found. Set DEVECO_WIN=<install root, Windows form>"
|
|
61
|
-
Write-Host " e.g. `$env:DEVECO_WIN = 'D:\Program Files\Huawei\DevEco Studio'"
|
|
62
|
-
exit 1
|
|
63
|
-
}
|
|
64
|
-
$env:DEVECO_WIN = $deveco
|
|
65
|
-
$env:DEVECO_SDK_HOME = Pick-DevecoPath $env:DEVECO_SDK_HOME (Join-Path $deveco "sdk")
|
|
66
|
-
$env:NODE_HOME = Pick-DevecoPath $env:NODE_HOME (Join-Path $deveco "tools\node")
|
|
67
|
-
|
|
68
|
-
if (-not $env:CANGJIE_STDX_OHOS) {
|
|
69
|
-
Write-OhosErr "set CANGJIE_STDX_OHOS=<ohos stdx>/linux_ohos_aarch64_cjnative/dynamic/stdx first"
|
|
70
|
-
exit 1
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
$nodeExe = Join-Path $deveco "tools\node\node.exe"
|
|
74
|
-
$hvigorJs = Join-Path $deveco "tools\hvigor\bin\hvigorw.js"
|
|
75
|
-
if (-not (Test-Path $hvigorJs)) {
|
|
76
|
-
Write-OhosErr "$hvigorJs not found - is DEVECO_WIN correct?"
|
|
77
|
-
exit 1
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
# hvigorw locates the Cangjie build plugin itself and creates the node_modules junctions;
|
|
81
|
-
# headless runs must hand it the path or the failure surfaces as
|
|
82
|
-
# "property name must be valid: cangjieOptions" (looks like a project config error,
|
|
83
|
-
# actually the plugin was not loaded).
|
|
84
|
-
if (-not $env:DEVECO_HVIGOR_CANGJIE_PLUGIN) {
|
|
85
|
-
$appdata = if ($env:APPDATA) { $env:APPDATA } else { "$env:USERPROFILE\AppData\Roaming" }
|
|
86
|
-
$cjb = Get-ChildItem -Path (Join-Path $appdata "Huawei") -Filter "DevEcoStudio*" -Directory -ErrorAction SilentlyContinue |
|
|
87
|
-
ForEach-Object { Get-ChildItem (Join-Path $_.FullName "plugins") -Filter "devecostudio-cangjie-plugin-*" -Directory -ErrorAction SilentlyContinue } |
|
|
88
|
-
ForEach-Object { Get-ChildItem (Join-Path $_.FullName "lib\hvigor") -Filter "cangjie-build-support" -Directory -ErrorAction SilentlyContinue } |
|
|
89
|
-
Select-Object -First 1
|
|
90
|
-
if ($cjb) {
|
|
91
|
-
$env:DEVECO_HVIGOR_CANGJIE_PLUGIN = $cjb.FullName
|
|
92
|
-
} else {
|
|
93
|
-
Write-OhosErr "Cangjie build plugin not found under <APPDATA>\Huawei\DevEcoStudio*\plugins\devecostudio-cangjie-plugin-*\lib\hvigor\cangjie-build-support"
|
|
94
|
-
Write-Host " set DEVECO_HVIGOR_CANGJIE_PLUGIN=<that dir>"
|
|
95
|
-
exit 1
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
# The plugin being loadable is not the same as being enabled: when disabled it deletes the
|
|
99
|
-
# cangjie schema silently (terminal only shows 00303038). Set both switches.
|
|
100
|
-
$env:DEVECO_CANGJIE_PLUGIN_ENABLED = "true"
|
|
101
|
-
$env:NODE_PATH = Join-Path (Get-Location) "node_modules"
|
|
102
|
-
|
|
103
|
-
# The SDK's cjpm.exe hard-depends on libcangjie-runtime.dll (under runtime/lib):
|
|
104
|
-
# without it hvigor exits 0xC0000139 within milliseconds.
|
|
105
|
-
if (-not $env:CANGJIE_SDK) {
|
|
106
|
-
$cand = Get-ChildItem "$env:USERPROFILE\.cangjie-sdk" -Directory -ErrorAction SilentlyContinue |
|
|
107
|
-
ForEach-Object { Join-Path $_.FullName "cangjie" } | Where-Object { Test-Path $_ } |
|
|
108
|
-
Sort-Object { [version]($_.Split('\') | Where-Object { $_ -match '^\d' } | Select-Object -First 1) } -ErrorAction SilentlyContinue |
|
|
109
|
-
Select-Object -Last 1
|
|
110
|
-
if ($cand) { $env:CANGJIE_SDK = $cand }
|
|
111
|
-
}
|
|
112
|
-
$cjsdkRt = Join-Path $env:CANGJIE_SDK "build-tools\runtime\lib\windows_x86_64_cjnative"
|
|
113
|
-
$cjsdkBin = Join-Path $env:CANGJIE_SDK "build-tools\bin"
|
|
114
|
-
$cjsdkToolsBin = Join-Path $env:CANGJIE_SDK "build-tools\tools\bin"
|
|
115
|
-
if (Test-Path $cjsdkRt) {
|
|
116
|
-
$env:PATH = "$cjsdkRt;$env:PATH"
|
|
117
|
-
} else {
|
|
118
|
-
Write-OhosErr "Cangjie runtime dir not found: $cjsdkRt - cjpm will exit 0xC0000139"
|
|
119
|
-
Write-Host " set CANGJIE_SDK=<.cangjie-sdk/<version>/cangjie>"
|
|
120
|
-
}
|
|
121
|
-
# cjc and opt must come from the SAME SDK build: cjc looks up opt via CANGJIE_HOME;
|
|
122
|
-
# a mismatch shows up as "EnumReflection format: operand numbers error!".
|
|
123
|
-
if (Test-Path $cjsdkBin) {
|
|
124
|
-
$env:PATH = "$cjsdkBin;$cjsdkToolsBin;$env:PATH"
|
|
125
|
-
$env:CANGJIE_HOME = Join-Path $env:CANGJIE_SDK "build-tools"
|
|
126
|
-
$cjcCmd = Get-Command cjc -ErrorAction SilentlyContinue
|
|
127
|
-
Write-Ohos "cjc = $($cjcCmd.Source)"
|
|
128
|
-
Write-Ohos "CANGJIE_HOME = $env:CANGJIE_HOME"
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
# entry/cjpm.toml references stdx via the relative path "../stdx" = a junction on the project
|
|
132
|
-
# root: hvigor only substitutes its own template vars, any other ${...} expands to an empty
|
|
133
|
-
# string which kills the whole path-option line (reported as "not added as a dependency").
|
|
134
|
-
$stdxLink = Join-Path $RootDir "stdx"
|
|
135
|
-
if (-not (Test-Path $stdxLink)) {
|
|
136
|
-
if (-not (Test-Path $env:CANGJIE_STDX_OHOS)) {
|
|
137
|
-
Write-OhosErr "CANGJIE_STDX_OHOS points to a non-existent dir: $env:CANGJIE_STDX_OHOS"
|
|
138
|
-
exit 1
|
|
139
|
-
}
|
|
140
|
-
New-Item -ItemType Junction -Path $stdxLink -Value $env:CANGJIE_STDX_OHOS | Out-Null
|
|
141
|
-
Write-Ohos "stdx junction created: $stdxLink -> $env:CANGJIE_STDX_OHOS"
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
# Stale artifacts: hvigor's CompileCangjie and framework-side cjpm each keep their own
|
|
145
|
-
# incremental cache; clearing only one feeds back an old .so (judge by artifact size,
|
|
146
|
-
# not by "build success").
|
|
147
|
-
if ($DoClean) {
|
|
148
|
-
Write-Ohos "cleaning entry/build (--clean)"
|
|
149
|
-
if (Test-Path (Join-Path $RootDir "entry\build")) { Remove-Item -Recurse -Force (Join-Path $RootDir "entry\build") }
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
# Assets sync: the project root assets/ dir is the single source of truth (RFC-002 section 7);
|
|
153
|
-
# pages and capability manifests are real rawfile files inside the hap - building without
|
|
154
|
-
# this sync installs STALE pages (self-checks still run, changes silently lost).
|
|
155
|
-
$appRoot = Split-Path (Split-Path $RootDir)
|
|
156
|
-
if ((Test-Path (Join-Path $appRoot "cj-tauri.toml")) -and (Test-Path (Join-Path $appRoot "assets"))) {
|
|
157
|
-
$rawfile = Join-Path $RootDir "entry\src\main\resources\rawfile"
|
|
158
|
-
New-Item -ItemType Directory -Force -Path (Join-Path $rawfile "ui") | Out-Null
|
|
159
|
-
New-Item -ItemType Directory -Force -Path (Join-Path $rawfile "capabilities") | Out-Null
|
|
160
|
-
# remove-then-copy: Copy-Item -Recurse into an existing dir would nest ui/ui/ and pages go stale
|
|
161
|
-
Remove-Item -Recurse -Force (Join-Path $rawfile "ui"), (Join-Path $rawfile "capabilities") -ErrorAction SilentlyContinue
|
|
162
|
-
Copy-Item -Recurse -Force (Join-Path $appRoot "assets\ui") (Join-Path $rawfile "ui")
|
|
163
|
-
Copy-Item -Recurse -Force (Join-Path $appRoot "assets\capabilities") (Join-Path $rawfile "capabilities")
|
|
164
|
-
Write-Ohos "assets synced from project root to rawfile (ui/ + capabilities/)"
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
# --no-daemon is mandatory: the resident daemon's CompileCangjie uses the env captured at
|
|
168
|
-
# daemon start; PATH/CANGJIE_HOME exported here never reach it (symptom: manual cjpm works,
|
|
169
|
-
# hvigor run crashes in opt).
|
|
170
|
-
$buildlogDir = Join-Path $RootDir ".buildlog"
|
|
171
|
-
New-Item -ItemType Directory -Force -Path $buildlogDir | Out-Null
|
|
172
|
-
& $nodeExe $hvigorJs --no-daemon --mode module -p product=default -p module=entry@default assembleHap 2>&1 |
|
|
173
|
-
Tee-Object -FilePath (Join-Path $buildlogDir "last-build.log")
|
|
174
|
-
if ($LASTEXITCODE -ne 0) {
|
|
175
|
-
Write-OhosErr "hvigor assembleHap failed (exit=$LASTEXITCODE)"
|
|
176
|
-
exit $LASTEXITCODE
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
$hap = Get-ChildItem (Join-Path $RootDir "entry\build\default\outputs\default") -Filter "*.hap" -ErrorAction SilentlyContinue |
|
|
180
|
-
Sort-Object LastWriteTime -Descending | Select-Object -First 1
|
|
181
|
-
if (-not $hap) {
|
|
182
|
-
Write-OhosErr "build finished but no hap artifact; check .buildlog/last-build.log"
|
|
183
|
-
exit 1
|
|
184
|
-
}
|
|
185
|
-
Write-Ohos "HAP = $($hap.FullName) ($($hap.Length) bytes)"
|
|
186
|
-
if ($hap.Name -like "*unsigned*") {
|
|
187
|
-
Write-OhosErr "unsigned hap: cannot be installed. Configure auto-signing in DevEco and rebuild."
|
|
188
|
-
$DoInstall = $false
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
if ($DoInstall) {
|
|
192
|
-
$hdc = Join-Path $deveco "sdk\default\openharmony\toolchains\hdc.exe"
|
|
193
|
-
if (-not (Test-Path $hdc)) {
|
|
194
|
-
Write-OhosErr "hdc not found: $hdc (-Install needs it; or put your own hdc on PATH)"
|
|
195
|
-
exit 1
|
|
196
|
-
}
|
|
197
|
-
Write-Ohos "connected devices:"
|
|
198
|
-
& $hdc list targets
|
|
199
|
-
Write-Ohos "installing $($hap.Name)"
|
|
200
|
-
& $hdc install -r $hap.FullName
|
|
201
|
-
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
|
202
|
-
Write-Ohos "starting EntryAbility"
|
|
203
|
-
# -a must be the ability name in module.json5 (EntryAbility), not the Cangjie class name.
|
|
204
|
-
& $hdc shell aa start -a EntryAbility -b {{BUNDLE_NAME}}
|
|
205
|
-
}
|