This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Normalize Windows-style ZIP entries in a Mini Program build directory."""
|
||||
|
||||
from pathlib import Path
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
def normalize(root: Path) -> int:
|
||||
moved = 0
|
||||
entries = sorted(root.rglob("*"), key=lambda path: len(path.parts), reverse=True)
|
||||
for entry in entries:
|
||||
if "\\" not in entry.name:
|
||||
continue
|
||||
target = entry.parent.joinpath(*entry.name.split("\\"))
|
||||
target.parent.mkdir(parents=True, exist_ok=True)
|
||||
if target.exists():
|
||||
raise FileExistsError(f"normalization target already exists: {target}")
|
||||
os.replace(entry, target)
|
||||
moved += 1
|
||||
return moved
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) != 2:
|
||||
raise SystemExit(f"usage: {Path(sys.argv[0]).name} BUILD_DIR")
|
||||
build_dir = Path(sys.argv[1])
|
||||
if not build_dir.is_dir():
|
||||
raise SystemExit(f"build directory not found: {build_dir}")
|
||||
print(f"normalized {normalize(build_dir)} Windows-style paths")
|
||||
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
function parseVersion(value) {
|
||||
const match = /^v?(\d+)(?:\.(\d+))?(?:\.(\d+))?$/i.exec(String(value ?? '').trim())
|
||||
return match ? [Number(match[1]), Number(match[2] ?? 0), Number(match[3] ?? 0)] : null
|
||||
}
|
||||
|
||||
function nextVersion(value) {
|
||||
const version = parseVersion(value)
|
||||
if (!version) throw new Error(`版本号格式无效: ${value}`)
|
||||
version[2] += 1
|
||||
return version.join('.')
|
||||
}
|
||||
|
||||
if (process.argv.includes('--self-test')) {
|
||||
if (nextVersion('1.0.9') !== '1.0.10' || nextVersion('v2.3') !== '2.3.1') {
|
||||
throw new Error('wechat-next-version self-test failed')
|
||||
}
|
||||
console.log('wechat-next-version self-test passed')
|
||||
} else {
|
||||
const current = process.argv[2]
|
||||
console.log(current ? nextVersion(current) : (process.env.WECHAT_VERSION_FALLBACK || '1.0.2'))
|
||||
}
|
||||
Reference in New Issue
Block a user