From ea572acf9976059f4c8bc4d9b5b882f90f6fdc48 Mon Sep 17 00:00:00 2001
From: abgox
Date: Thu, 19 Dec 2024 15:00:24 +0800
Subject: [PATCH] fix(module): update version to 5.2.4
---
module/CHANGELOG-CN.md | 4 ++++
module/CHANGELOG.json | 13 +++++++++++++
module/CHANGELOG.md | 4 ++++
module/PSCompletions/PSCompletions.psd1 | 2 +-
module/PSCompletions/core/init.ps1 | 23 +++++++++++------------
module/version.txt | 2 +-
6 files changed, 34 insertions(+), 14 deletions(-)
diff --git a/module/CHANGELOG-CN.md b/module/CHANGELOG-CN.md
index f15f730..dfd849f 100644
--- a/module/CHANGELOG-CN.md
+++ b/module/CHANGELOG-CN.md
@@ -3,6 +3,10 @@
简体中文
+## 5.2.4 (2024/12/19)
+
+- 优化模块版本迁移
+
## 5.2.3 (2024/12/18)
- 对于语言为 `zh-CN` 或设置为 `zh-CN` 的用户,之前默认会使用 Gitee 源 `https://gitee.com/abgox/PSCompletions/raw/main`
diff --git a/module/CHANGELOG.json b/module/CHANGELOG.json
index 57f69c6..251298a 100644
--- a/module/CHANGELOG.json
+++ b/module/CHANGELOG.json
@@ -1,4 +1,17 @@
[
+ {
+ "version": "5.2.4",
+ "info": {
+ "zh-CN": [
+ "更新(2024/12/19)\n",
+ "- 优化模块版本迁移。\n"
+ ],
+ "en-US": [
+ "Update(2024/12/19)\n",
+ "- Optimize module version migration.\n"
+ ]
+ }
+ },
{
"version": "5.2.3",
"info": {
diff --git a/module/CHANGELOG.md b/module/CHANGELOG.md
index 64b2db0..589b4da 100644
--- a/module/CHANGELOG.md
+++ b/module/CHANGELOG.md
@@ -3,6 +3,10 @@
English
+## 5.2.4 (2024/12/19)
+
+- Optimize module version migration.
+
## 5.2.3 (2024/12/18)
- Use `https://abgox.github.io/PSCompletions` as the primary source for module and completion updates.
diff --git a/module/PSCompletions/PSCompletions.psd1 b/module/PSCompletions/PSCompletions.psd1
index f548ee6..bc78bd8 100644
--- a/module/PSCompletions/PSCompletions.psd1
+++ b/module/PSCompletions/PSCompletions.psd1
@@ -9,7 +9,7 @@
@{
RootModule = 'PSCompletions.psm1'
- ModuleVersion = '5.2.3'
+ ModuleVersion = '5.2.4'
GUID = '00929632-527d-4dab-a5b3-21197faccd05'
diff --git a/module/PSCompletions/core/init.ps1 b/module/PSCompletions/core/init.ps1
index 42ebd2e..618db46 100644
--- a/module/PSCompletions/core/init.ps1
+++ b/module/PSCompletions/core/init.ps1
@@ -1,7 +1,7 @@
using namespace System.Management.Automation
$_ = Split-Path $PSScriptRoot -Parent
New-Variable -Name PSCompletions -Value @{
- version = '5.2.3'
+ version = '5.2.4'
path = @{
root = $_
completions = Join-Path $_ 'completions'
@@ -1036,6 +1036,9 @@ Add-Member -InputObject $PSCompletions -MemberType ScriptMethod new_data {
foreach ($_ in $json.config) {
$data.config.comp_config.$name.$($_.name) = $_.value
}
+ if ($config.hooks -ne $null) {
+ $data.config.comp_config.$name.enable_hooks = [int]$config.hooks
+ }
}
$data | ConvertTo-Json -Depth 100 -Compress | Out-File $PSCompletions.path.data -Force -Encoding utf8
$PSCompletions.data = $data
@@ -1174,22 +1177,14 @@ Add-Member -InputObject $PSCompletions -MemberType ScriptMethod argc_completions
}
if (!(Test-Path $PSCompletions.path.temp)) {
- $PSCompletions.ensure_dir($PSCompletions.path.temp)
- $PSCompletions.ensure_dir($PSCompletions.path.order)
Add-Member -InputObject $PSCompletions -MemberType ScriptMethod move_old_version {
$version = (Get-ChildItem (Split-Path $PSCompletions.path.root -Parent) -ErrorAction SilentlyContinue).Name | Sort-Object { [Version]$_ } -ErrorAction SilentlyContinue | Where-Object { $_ -match '^\d+\.\d.*' }
if ($version -is [array]) {
$old_version = $version[-2]
if ($old_version -match '^\d+\.\d.*' -and $old_version -ge '4') {
$old_version_dir = Join-Path (Split-Path $PSCompletions.path.root -Parent) $old_version
- $PSCompletions.ensure_dir($PSCompletions.path.completions)
if (Test-Path "$old_version_dir/data.json") {
- foreach ($_ in Get-ChildItem "$old_version_dir/completions" -Directory -ErrorAction SilentlyContinue) {
- if ($_.Name -ne 'psc') {
- Move-Item $_.FullName $PSCompletions.path.completions -Force -ErrorAction SilentlyContinue
- }
- }
Move-Item "$old_version_dir/data.json" $PSCompletions.path.data -Force -ErrorAction SilentlyContinue
}
else {
@@ -1232,9 +1227,10 @@ if (!(Test-Path $PSCompletions.path.temp)) {
}
$data | ConvertTo-Json -Depth 100 -Compress | Out-File $PSCompletions.path.data -Force -Encoding utf8
}
- Move-Item "$old_version_dir/temp/update.txt" $PSCompletions.path.update -Force -ErrorAction SilentlyContinue
- Move-Item "$old_version_dir/temp/change.txt" $PSCompletions.path.change -Force -ErrorAction SilentlyContinue
- Move-Item "$old_version_dir/temp/completions.json" $PSCompletions.path.completions_json -Force -ErrorAction SilentlyContinue
+
+ foreach ($f in @('temp', 'completions')) {
+ Move-Item "$old_version_dir/$f" $PSCompletions.path.root -Force -ErrorAction SilentlyContinue
+ }
}
}
else {
@@ -1257,6 +1253,7 @@ if (!(Test-Path $PSCompletions.path.temp)) {
$urls = @('https://github.com/abgox/PSCompletions/raw/main', 'https://gitee.com/abgox/PSCompletions/raw/main')
}
+ $PSCompletions.ensure_dir($PSCompletions.path.completions)
$PSCompletions.ensure_dir("$($PSCompletions.path.completions)/psc")
$PSCompletions.ensure_dir("$($PSCompletions.path.completions)/psc/language")
@@ -1284,6 +1281,8 @@ if (!(Test-Path $PSCompletions.path.temp)) {
$PSCompletions.info = $PSCompletions.ConvertFrom_JsonToHashtable($PSCompletions.get_raw_content("$($PSCompletions.path.completions)/psc/language/$language.json")).info
}
$PSCompletions.move_old_version()
+ $PSCompletions.ensure_dir($PSCompletions.path.temp)
+ $PSCompletions.ensure_dir($PSCompletions.path.order)
$PSCompletions.is_init = $true
}
diff --git a/module/version.txt b/module/version.txt
index c0baecb..73ce950 100644
--- a/module/version.txt
+++ b/module/version.txt
@@ -1 +1 @@
-5.2.3
+5.2.4