dudu-converter-cli 1.0.5 → 1.0.7
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/release/cli.js +7 -7
- package/web/dist/assets/{index-DpoSYrss.css → index-D0N1_kqG.css} +1 -1
- package/web/dist/assets/index-crdoK3FU.js +32 -0
- package/web/dist/index.html +2 -2
- package/web/dist/install.ps1 +43 -28
- package/web/dist/install.sh +6 -4
- package/web/dist/assets/index-oCuv6aWs.js +0 -32
package/web/dist/install.ps1
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
#
|
|
2
|
-
#
|
|
1
|
+
# DuDu Converter (dudu-converter-cli) Windows installer (PowerShell 5.1+)
|
|
2
|
+
# Usage: $w=New-Object Net.WebClient;$w.Encoding=[Text.Encoding]::UTF8;iex $w.DownloadString('https://duduer.com/install.ps1')
|
|
3
|
+
# NOTE: All messages are in English to avoid encoding issues in PS 5.1 (Chinese Windows defaults to GBK console).
|
|
4
|
+
# The Chinese user experience lives in the web UI at http://127.0.0.1:3456
|
|
3
5
|
$ErrorActionPreference = 'Stop'
|
|
4
6
|
|
|
5
|
-
#
|
|
7
|
+
# Ensure UTF-8 console (for any Chinese output from Node.js subprocesses like `converter autostart enable`)
|
|
8
|
+
try { chcp.com 65001 | Out-Null } catch { }
|
|
6
9
|
try {
|
|
7
10
|
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
|
|
8
11
|
$OutputEncoding = [System.Text.Encoding]::UTF8
|
|
@@ -14,11 +17,11 @@ function Say($msg) { Write-Host $msg -ForegroundColor Green }
|
|
|
14
17
|
function Warn($msg) { Write-Host $msg -ForegroundColor Yellow }
|
|
15
18
|
function Show-Manual {
|
|
16
19
|
Write-Host ''
|
|
17
|
-
Warn '
|
|
18
|
-
Write-Host ' 1.
|
|
19
|
-
Write-Host ' 2.
|
|
20
|
-
Write-Host ' 3.
|
|
21
|
-
Write-Host ' 4.
|
|
20
|
+
Warn 'Automatic installation did not complete. Manual steps:'
|
|
21
|
+
Write-Host ' 1. Download Node.js 18+ from https://nodejs.org (or a CN mirror like https://mirrors.ustc.edu.cn/node/) and install'
|
|
22
|
+
Write-Host ' 2. Open a NEW PowerShell window, run: npm install -g dudu-converter-cli'
|
|
23
|
+
Write-Host ' 3. Start the service: converter start'
|
|
24
|
+
Write-Host ' 4. Open http://127.0.0.1:3456 in your browser'
|
|
22
25
|
}
|
|
23
26
|
function Die($msg) { Write-Host $msg -ForegroundColor Red; Show-Manual; exit 1 }
|
|
24
27
|
|
|
@@ -38,54 +41,66 @@ function Refresh-Path {
|
|
|
38
41
|
}
|
|
39
42
|
|
|
40
43
|
if (Test-Node) {
|
|
41
|
-
Say "
|
|
44
|
+
Say "Found Node $(node -v) (18+ required) - skipping Node installation"
|
|
42
45
|
} else {
|
|
43
|
-
Say '
|
|
46
|
+
Say 'Node.js 18+ not found, installing...'
|
|
44
47
|
if (Get-Command winget -ErrorAction SilentlyContinue) {
|
|
45
48
|
winget install --id OpenJS.NodeJS.LTS --accept-source-agreements --accept-package-agreements
|
|
46
|
-
if ($LASTEXITCODE -ne 0) { Die 'Node.js
|
|
49
|
+
if ($LASTEXITCODE -ne 0) { Die 'Node.js installation via winget failed' }
|
|
47
50
|
}
|
|
48
51
|
elseif (Get-Command choco -ErrorAction SilentlyContinue) {
|
|
49
52
|
choco install nodejs-lts -y
|
|
50
|
-
if ($LASTEXITCODE -ne 0) { Die 'Node.js
|
|
53
|
+
if ($LASTEXITCODE -ne 0) { Die 'Node.js installation via Chocolatey failed' }
|
|
51
54
|
}
|
|
52
55
|
elseif (Get-Command scoop -ErrorAction SilentlyContinue) {
|
|
53
56
|
scoop install nodejs-lts
|
|
54
|
-
if ($LASTEXITCODE -ne 0) { Die 'Node.js
|
|
57
|
+
if ($LASTEXITCODE -ne 0) { Die 'Node.js installation via Scoop failed' }
|
|
55
58
|
}
|
|
56
59
|
else {
|
|
57
|
-
Say '
|
|
60
|
+
Say 'No package manager found, downloading Node.js installer directly...'
|
|
58
61
|
$nodeArch = if ($env:PROCESSOR_ARCHITECTURE -eq 'ARM64') { 'arm64' } else { 'x64' }
|
|
59
|
-
|
|
62
|
+
# CN mirror first (USTC, tested ~0.1s), fallback to official
|
|
60
63
|
$msiFile = Join-Path $env:TEMP 'dudu-node-installer.msi'
|
|
61
|
-
|
|
62
|
-
|
|
64
|
+
$mirrors = @(
|
|
65
|
+
"https://mirrors.ustc.edu.cn/node/v22.20.0/node-v22.20.0-$nodeArch.msi",
|
|
66
|
+
"https://nodejs.org/dist/v22.20.0/node-v22.20.0-$nodeArch.msi"
|
|
67
|
+
)
|
|
68
|
+
$downloaded = $false
|
|
69
|
+
foreach ($u in $mirrors) {
|
|
70
|
+
try {
|
|
71
|
+
Say " Trying: $u"
|
|
72
|
+
Invoke-WebRequest -Uri $u -OutFile $msiFile -UseBasicParsing
|
|
73
|
+
$downloaded = $true
|
|
74
|
+
break
|
|
75
|
+
} catch { Warn ' Mirror unreachable, trying next...' }
|
|
76
|
+
}
|
|
77
|
+
if (-not $downloaded) { Die 'Node.js download failed from all mirrors' }
|
|
78
|
+
Say 'Installing Node.js (a UAC prompt may appear, click "Yes")...'
|
|
63
79
|
Start-Process msiexec.exe -ArgumentList '/i', $msiFile, '/qn' -Verb RunAs -Wait
|
|
64
80
|
}
|
|
65
|
-
# 刚安装的 Node 不会出现在当前会话的 PATH 中,需从注册表重新加载
|
|
66
81
|
Refresh-Path
|
|
67
|
-
if (-not (Test-Node)) { Die 'Node.js
|
|
82
|
+
if (-not (Test-Node)) { Die 'Node.js installed but not detected. Please reopen PowerShell and re-run this script' }
|
|
68
83
|
}
|
|
69
84
|
|
|
70
|
-
Say "
|
|
85
|
+
Say "Installing DuDu Converter ($PackageSpec)..."
|
|
71
86
|
npm install -g $PackageSpec
|
|
72
|
-
if ($LASTEXITCODE -ne 0) { Die '
|
|
87
|
+
if ($LASTEXITCODE -ne 0) { Die 'npm install failed. Please check your network and retry' }
|
|
73
88
|
|
|
74
89
|
Refresh-Path
|
|
75
90
|
$converter = Get-Command converter -ErrorAction SilentlyContinue
|
|
76
|
-
if (-not $converter) { Die '
|
|
77
|
-
Say "
|
|
91
|
+
if (-not $converter) { Die 'Installed but converter command not found. Please reopen PowerShell and run: converter start' }
|
|
92
|
+
Say "Installed: converter $(converter --version)"
|
|
78
93
|
|
|
79
94
|
if ($env:NO_START -eq '1') {
|
|
80
|
-
Say '
|
|
95
|
+
Say 'Skipped startup. Run anytime: converter start'
|
|
81
96
|
exit 0
|
|
82
97
|
}
|
|
83
98
|
|
|
84
|
-
Say '
|
|
99
|
+
Say 'Enabling auto-start on login...'
|
|
85
100
|
converter autostart enable
|
|
86
|
-
if ($LASTEXITCODE -ne 0) { Warn '
|
|
101
|
+
if ($LASTEXITCODE -ne 0) { Warn 'Auto-start setup failed (non-fatal). Run later: converter autostart enable' }
|
|
87
102
|
|
|
88
|
-
Say '
|
|
103
|
+
Say 'Starting service, browser will open...'
|
|
89
104
|
Start-Process -FilePath 'cmd.exe' -ArgumentList '/c', 'converter', 'start'
|
|
90
105
|
Start-Sleep -Seconds 2
|
|
91
|
-
Say '
|
|
106
|
+
Say 'Done! If browser did not open, visit http://127.0.0.1:3456'
|
package/web/dist/install.sh
CHANGED
|
@@ -33,12 +33,14 @@ if command -v node >/dev/null 2>&1; then
|
|
|
33
33
|
fi
|
|
34
34
|
fi
|
|
35
35
|
if [ "$node_major" -lt 18 ]; then
|
|
36
|
-
# 裸机也全自动:直接下载 Node.js
|
|
36
|
+
# 裸机也全自动:直接下载 Node.js pkg 安装(不依赖 Homebrew)。
|
|
37
|
+
# 国内网络优先走中科大镜像(实测 0.1s 响应),失败自动回退官方源
|
|
37
38
|
NODE_VERSION="22.20.0"
|
|
38
|
-
NODE_PKG_URL="https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}.pkg"
|
|
39
39
|
PKG_FILE="${TMPDIR:-/tmp}/dudu-node-installer.pkg"
|
|
40
|
-
say "未检测到 Node.js 18
|
|
41
|
-
curl -fsSL "$
|
|
40
|
+
say "未检测到 Node.js 18+,正在下载安装包(约 70MB,国内镜像加速)…"
|
|
41
|
+
curl -fsSL --connect-timeout 8 "https://mirrors.ustc.edu.cn/node/v${NODE_VERSION}/node-v${NODE_VERSION}.pkg" -o "$PKG_FILE" \
|
|
42
|
+
|| curl -fsSL --connect-timeout 8 "https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}.pkg" -o "$PKG_FILE" \
|
|
43
|
+
|| die "Node.js 安装包下载失败。国内镜像与官方源均不可达,请检查网络后重试,或到 https://nodejs.org 下载安装"
|
|
42
44
|
say "正在安装 Node.js(可能需要输入一次开机密码)…"
|
|
43
45
|
sudo installer -pkg "$PKG_FILE" -target / || die "Node.js 安装失败,请到 https://nodejs.org 手动安装后重跑本脚本"
|
|
44
46
|
rm -f "$PKG_FILE"
|