Would you like me to pack that for you?

Would you like me to pack that for you?

Looking at the work that I've been doing, things were looking really messy.
I needed a way to cleanup, and I needed it to make sense and scale onwards.

Keeping everything in a single directory wasn't really working, and just allowing everything to load wasn't working either.
Some systems had docker, some didn't, there are commands I currently want only on Linux systems, other on Windows, there are commands that I need them to behave differently on Windows and on Linux, and having the command code do the juggling didn't feel right either.

This ties in to what I mentioned about different environments in my previous post, and I chose to implement the concept of packages.

The inspiration came to me from the packages in Home-Assistant, but my implementation is a bit more 'dynamic' (I think).

Keep a clean root

Up until now everything was focused in $MyPSScriptRoot, but as I mentioned, it has become hard to manage. Instead I'm creating a base package - which will contain all of the basic scripts, including the package management code.

Packages are sub-directories that have a _.package.json file in them describing the package.

The package description contains a set of conditions, when the condition set are met, the package is on.

An active package will have it's commands available, it's aliases loaded and it's profile.d sub-dir executed.

Breaking the egg...

This new package paradigm allowed me to drop the previous sys.XXXX per-system scheme, as I the package condition already takes care of that, so sys.Linux became base.Linux with a System condition of Linux in the json.

Changes were made to Reload-MyScripts, Get-MyScripts and Edit-MyScripts to address the changes.

The 'most painful' change was probably to the profile code, so Setup-Profile has been updated, and I had to update the profile on all environments I installed it on, but thankfully, after running the script and reloading the shell, everything was in working order.

What's Next?

The journey continues, but I really feel 'at home' in this PowerShell environment, and I really like how it's coming along.

I think my next post will be a more in depth look at what makes a package and how they work, and after that I'll focus on the tasks I still want to accomplish (some of which I mentioned in my previous post)

* Source Code

Latest commit at the time of writing: 1792bb23a1