please xyz[@version] argsRunning the above should run xyz[@version], passing args to it.
If xyz is not available, then the command should first:
a) Install it, or b) Download a prebuilt version, or c) Build it, or d) Display an error
The program, will track a git repository for instructions on how to build
a package. If git is not available, the program shows a warning message
"Please install git to speed up things", then will download a tarball of the
said repository instead (or ask the user to do it manually).
The program needs to provide an API, for getting OS, CPU arch, available disk space and etc... and also an API to install, download and build programs.
The program needs to be portable, fast, easy to understand and easy to maintain. The program needs to be scriptable.
Provide an easy and portable way of installing and using commands. Mainly for devops and on command line.
- Bash is available on most unix systems, although it has a lot of users, it's not as maintainable or understandable as the other options. Plus, it's not available on windows.
- JavaScript is fast, easy to understand and easy to maintain, however not as portable as the others on the list. Downloading and executing external code is relatively easy.
- Python is relatively easy to understand and easy to maintain, however not as fast as the others on this list. Downloading and executing external modules is not straightforward.
- A small custom language can be portable and fast, but difficult to maintain, however, this will give us the biggest compatibility as a custom compiler can be made for each OS/environment where the reference compiler isn't supported (Porting a small language is much easier than porting the entire JavaScript)
After careful considerations, JavaScript was chosen as the scripting language.
Following operating systems should have tier 1 supports:
- Linux
- BSDs
- Unixes, including MacOS
- Windows
please --kwarg args command --ckwargs cargs
We need to store:
- Installation instructions for each OS / package manager
- Prebuilt fetch and decompress instructions
- Build instructions for each OS
- Scripted install or run
Proposed repository structure:
repo/
├─ commands/
│ ├─ ${command}/
│ │ ├─ build/
│ │ │ ├─ ${os}.${variant}.${release}.${arch}.js
│ │ ├─ install/
│ │ │ ├─ ${os}.${variant}.${release}.${arch}.js
│ │ ├─ prebuilt/
│ │ │ ├─ ${os}.${variant}.${release}.${arch}.js
│ │ ├─ script/
│ │ │ ├─ ${os}.${variant}.${release}.${arch}.js
├─ configs/
│ ├─ ${os}.${variant}.${release}.${arch}.js
Where:
osis the OS name, type, class or family (eg.windows,macos,bsd,linuxorany)variantis the distribution, variant or version (eg.10,ubuntu,debian,freebsdorany)releaseis the version, release or build number (eg.18363,20.04,10orany)archis the cpu architecture (eg.arm64,x64, orany)
The program should first try the exact values for each of the parameters, then switch to any one parameter at a time from right to left.
File check order for config or command files is as follows:
- ${os}.${variant}.${release}.${arch}
- ${os}.${variant}.${release}.any
- ${os}.${variant}.any.${arch}
- ${os}.${variant}.any.any
- ${os}.any.any.any
- any.any.any.any
To obtain each of the parameters, the following methods are used:
os, is one ofwindows,macos,bsd,linuxoranyvariantdepends on the os class: 2.1. Forwindowsit is themajor.minorpart ofmajor.minor.buildvalue reported byos.release()2.2. Forlinuxit is the name reported bygetosnpm library, lower-cased and whitespaces removed. 2.3. Formacosit is the name reported bymacos-releasenpm library, lower-cased and whitespaces removed. 2.4. Forbsd, it is eitherfreebsdoropenbsd, as reported byos.platform()releasedepends on the os class: 3.1. Forwindowsit is thebuildpart ofmajor.minor.buildvalue reported byos.release()3.2. Forlinuxit is the release field reported bygetosnpm library. 3.3. Formacosit is the value reported byos.release(), which matches the darwin kernel version number. 3.4. Forbsdit is the value reported byos.release()archparamter is the value reported byos.arch()
Can contain:
- Preferred way of installation, in order of preference
- Preferred package managers, in order of preference (eg. brew, ports...)