Jump to content

Сортировщик .CKAN файла.


Serjevski

Recommended Posts

Использую CKAN для управления модами. Также акивно использую GIT для отслеживания истории изменения состава модов. После каждого добавления/удаления мода делаю экспорт модпака. Да я в курсе, что CKAN держит историю в папке с игрой, но лично мне удобней отслеживать историю каким-либо GUI Git-клиентом.

Проблема в том, что CKAN помещает моды в  пак в каком-то произвольном порядке, скорее всего хронологическом в порядке удаления добавления, что дает полную кашу при сравнении файлов.

Решение - сортировать моды в алфавитном порядке, тогда сразу будет четко видно, что добавлено, и что удалено.

Простейший сортировщик написан на Powershell и составляет всего 12 строк:

Ему передается имя файла через параметр -FileName, скрипт этот файл сортирует и записывает туда же.

У меня настроен мониторинг папки специальной утилитой, как только файл изменяется - запускается скрипт.

[CmdletBinding()]

Param (
[Parameter (Mandatory=$true)]
[string]$FileName
)

$a = (Get-Content $FileName | ConvertFrom-Json)
$dep = ($a.depends|sort -Property Name)
$a.depends = $dep
$text = $a| ConvertTo-Json
$text| Out-File -Encoding utf8 "$FileName"

 

Link to comment
Share on other sites

  • 3 weeks later...

Hi, apologies for using English here (I'm reading via browser translation), but that's a good point.

On 12/7/2021 at 2:54 PM, Serjevski said:

The problem is that CKAN puts mods in the pack in some random order, most likely chronological in the order of deletion of additions, which is a complete mess when comparing files.

It's the order of the identifier keys in a C# Dictionary, which is indeed "non-deterministic". Looks easy to sort, though, so we'll look into adding that to CKAN. Thanks for the suggestion.

Link to comment
Share on other sites

1 minute ago, HebaruSan said:

It's the order of the identifier keys in a C# Dictionary, which is indeed "non-deterministic". Looks easy to sort, though, so we'll look into adding that to CKAN. Thanks for the suggestion.

Thank you, it will be good! It would be very nice if you could come up with a convenient mechanism for synchronizing mods and their settings between two computers. I use Git for this, creating a repository in the GameData folder. Adding Squad folders and dome other files to exceptions.

Link to comment
Share on other sites

16 minutes ago, Serjevski said:

Thank you, it will be good!

You're welcome. The work is now under way here:

https://github.com/KSP-CKAN/CKAN/pull/3499

16 minutes ago, Serjevski said:

It would be very nice if you could come up with a convenient mechanism for synchronizing mods and their settings between two computers. I use Git for this, creating a repository in the GameData folder. Adding Squad folders and dome other files to exceptions.

That's not something I will be able to throw together quickly on a whim. I would suggest filing an issue with an explanation of why you need this so we'll have a long-term reminder to come back to it and investigate:

https://github.com/KSP-CKAN/CKAN/issues/new?assignees=&labels=Enhancement&template=feature_request.md&title=[Feature]

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...