@ziniao-open/cli 0.1.0-beta.82 → 0.1.0-beta.89
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/package.json +1 -1
- package/scripts/setup-ziniao-cli.ps1 +15 -21
package/package.json
CHANGED
|
@@ -18,7 +18,7 @@ switch ($arch.ToLowerInvariant()) {
|
|
|
18
18
|
"amd64" { $archDir = "x64" }
|
|
19
19
|
"x86_64" { $archDir = "x64" }
|
|
20
20
|
"arm64" { $archDir = "arm64" }
|
|
21
|
-
default { throw "
|
|
21
|
+
default { throw "Unsupported CPU architecture: $arch" }
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
$sourceName = "ziniao.exe"
|
|
@@ -52,25 +52,19 @@ if (-not $sourcePath) {
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
if ($env:ZINIAO_APP_CACHE_DIR) {
|
|
55
|
-
$
|
|
55
|
+
$targetDir = Join-Path $env:ZINIAO_APP_CACHE_DIR "cli"
|
|
56
56
|
} else {
|
|
57
|
-
$
|
|
58
|
-
(Join-Path $env:APPDATA "ziniao"),
|
|
59
|
-
(Join-Path $env:LOCALAPPDATA "ziniao")
|
|
60
|
-
)
|
|
61
|
-
if (-not $appCacheDir) { $appCacheDir = Join-Path $env:APPDATA "ziniao" }
|
|
62
|
-
$appCacheDir = Join-Path $appCacheDir "app-cache"
|
|
57
|
+
$targetDir = Join-Path $env:APPDATA "ziniaobrowser\cli"
|
|
63
58
|
}
|
|
64
59
|
|
|
65
|
-
$targetDir = Join-Path $appCacheDir "cli"
|
|
66
60
|
$targetPath = Join-Path $targetDir $sourceName
|
|
67
61
|
New-Item -ItemType Directory -Path $targetDir -Force | Out-Null
|
|
68
62
|
|
|
69
63
|
if (-not $sourcePath) {
|
|
70
64
|
if (Test-Path -LiteralPath $targetPath -PathType Leaf) {
|
|
71
|
-
Write-Log "
|
|
65
|
+
Write-Log "Desktop CLI source not found; keeping existing AppCache CLI: $targetPath"
|
|
72
66
|
} else {
|
|
73
|
-
Write-Log "WARN:
|
|
67
|
+
Write-Log "WARN: ${sourceName} was not found in the desktop installation; skipping copy. Set `$env:ZINIAO_INSTALL_DIR or `$env:ZINIAO_CLI_SOURCE."
|
|
74
68
|
}
|
|
75
69
|
} else {
|
|
76
70
|
$needsCopy = -not (Test-Path -LiteralPath $targetPath -PathType Leaf)
|
|
@@ -79,9 +73,9 @@ if (-not $sourcePath) {
|
|
|
79
73
|
}
|
|
80
74
|
if ($needsCopy) {
|
|
81
75
|
Copy-Item -LiteralPath $sourcePath -Destination $targetPath -Force
|
|
82
|
-
Write-Log "
|
|
76
|
+
Write-Log "Synchronized CLI: $sourcePath -> $targetPath"
|
|
83
77
|
} else {
|
|
84
|
-
Write-Log "AppCache CLI
|
|
78
|
+
Write-Log "AppCache CLI is already up to date: $targetPath"
|
|
85
79
|
}
|
|
86
80
|
}
|
|
87
81
|
|
|
@@ -90,7 +84,7 @@ function Install-PathShim {
|
|
|
90
84
|
foreach ($pathEntry in @($env:Path -split ";" | Where-Object { $_ })) {
|
|
91
85
|
if ($pathEntry.TrimEnd('\') -ieq $targetDir.TrimEnd('\')) {
|
|
92
86
|
$script:shimInstalled = $true
|
|
93
|
-
Write-Log "
|
|
87
|
+
Write-Log "Current PATH already contains the AppCache CLI directory: $targetDir"
|
|
94
88
|
return
|
|
95
89
|
}
|
|
96
90
|
$shimPath = Join-Path $pathEntry $sourceName
|
|
@@ -98,13 +92,13 @@ function Install-PathShim {
|
|
|
98
92
|
try {
|
|
99
93
|
Copy-Item -LiteralPath $targetPath -Destination $shimPath -Force -ErrorAction Stop
|
|
100
94
|
$script:shimInstalled = $true
|
|
101
|
-
Write-Log "
|
|
95
|
+
Write-Log "Created a CLI shim in an existing PATH directory: $shimPath"
|
|
102
96
|
return
|
|
103
97
|
} catch {
|
|
104
98
|
continue
|
|
105
99
|
}
|
|
106
100
|
}
|
|
107
|
-
Write-Log "WARN:
|
|
101
|
+
Write-Log "WARN: No writable existing PATH directory was found; the ziniao command is not immediately available."
|
|
108
102
|
}
|
|
109
103
|
|
|
110
104
|
$shimInstalled = $false
|
|
@@ -114,7 +108,7 @@ $userPath = [Environment]::GetEnvironmentVariable("Path", "User")
|
|
|
114
108
|
$entries = @($userPath -split ";" | Where-Object { $_ })
|
|
115
109
|
if (-not ($entries | Where-Object { $_.TrimEnd('\') -ieq $targetDir.TrimEnd('\') })) {
|
|
116
110
|
[Environment]::SetEnvironmentVariable("Path", (($entries + $targetDir) -join ";"), "User")
|
|
117
|
-
Write-Log "
|
|
111
|
+
Write-Log "Added to the user PATH: $targetDir"
|
|
118
112
|
}
|
|
119
113
|
|
|
120
114
|
$currentEntries = @($env:Path -split ";" | Where-Object { $_ })
|
|
@@ -122,10 +116,10 @@ if (-not ($currentEntries | Where-Object { $_.TrimEnd('\') -ieq $targetDir.TrimE
|
|
|
122
116
|
$env:Path = "$targetDir;$env:Path"
|
|
123
117
|
}
|
|
124
118
|
if ($shimInstalled) {
|
|
125
|
-
Write-Log "CLI
|
|
119
|
+
Write-Log "CLI is already available through the current PATH; no PowerShell refresh is required."
|
|
126
120
|
} elseif ($isDotSourced) {
|
|
127
|
-
Write-Log "
|
|
121
|
+
Write-Log "Refreshed the current PowerShell PATH."
|
|
128
122
|
} else {
|
|
129
|
-
Write-Log "
|
|
123
|
+
Write-Log "Refreshed this process PATH; dot-source the script or open a new terminal to refresh the parent PowerShell."
|
|
130
124
|
}
|
|
131
|
-
Write-Log "
|
|
125
|
+
Write-Log "Verify with: Get-Command ziniao"
|