Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[features]: Attempt of Unification of Utility And Operation Instantiation #55

Open
lvyuemeng opened this issue Dec 19, 2024 · 6 comments
Labels
feature | 功能 New feature or request

Comments

@lvyuemeng
Copy link
Collaborator

lvyuemeng commented Dec 19, 2024

Features Describe | 功能描述

Current runtime is quoted by every feature, and spread out over many files includes common.lua, xlings.lua, parts of utils.lua, platform.lua. It could be parts of cli, runtime, system separation.

Usage Scenario | 需求背景/使用场景

Maybe Solutions | 可能的实现方案 - (if you are developer)

  1. Segregate as cli, runtime, system and much more by utility.
  2. cli: Parse input; call a certain functionality or feature.
  3. runtime: provide infos of current execution, such as home, cwd, xlings_home; control the current env or index.
  4. system: provide OS, Arch, PM info with their interaction.
  5. env: handle version and path.
  6. package: package_index and related utility.

Currently, there are two ways of separation, first as functionality, second as cli args. If we want to emphasize on functionality, the callee should be each functionality as args rather than install, uninstall, it's vague whether uninstall package or uninstall xlings itself. So a better choice is to separate by functionality, and abandon the verb args (xlings xim *args*). If we want to extend many, such segregation seems unavoidable.

For example:

-- cli
-- -- xim
-- -- other functionality...
-- runtime
-- package
-- other base...

Additional context | 额外补充

@lvyuemeng lvyuemeng added the feature | 功能 New feature or request label Dec 19, 2024
@lvyuemeng lvyuemeng changed the title [features]: Attempt of Unification of Runtime And Instantiation [features]: Attempt of Unification of Utility And Operation Instantiation Dec 20, 2024
@lvyuemeng
Copy link
Collaborator Author

lvyuemeng commented Dec 23, 2024

system

  1. system package manager: moving pm_wrapper to it. (postpone implementation)
  • system deps control.
  1. console control. (set temporary local console.)
  2. add OS, arch semantics.
  3. path modification

version

  1. version semantics.
  2. version manager connection.
  3. accept info from package.
  4. version control ops:
    • transfer installation strategy.
      • if vm handled version manager.
      • if self_vm handled self-versioned.
      • if native no need.
      • if prebuilt handled env info.

package #54

Prefer plugin, remove index for manual version maintaining

  1. Installation strategy semantics.
    • self_vm
    • vm (handled by preinstalled version manager)
      • list version managers.
    • native (extract env info from installation script)
    • prebuilt
      • fetch
      • extract
      • config
      • env_set
  2. package plugin (remove manual maintaining).
    • example:
      • rust
        • Possible files for private operation
        • index/src (interfaces, list below.)
    • register
      • register()
    • env
      • detect_version_files() -- local version requirement detection
      • fetch_version() -- collect version info online.
      • locate_exec()
    • download
      • fetch_prebuilt()
    • installation/remove
      • install_self_vm()
      • install_vm() -- check and install vm first.
      • install_native()
      • install_prebuilt()

env

  1. accept info from package, version for ops.
  2. env strategy in priority:
    • vm
      • including self version manager (for example: bun, rust)
    • shims
      • accept locate_exec from package:
        • run version
        • detect local proj
          • if version conflict, resolve to change
      • path
      • script
    • symlink (not recommend)
      • path
      • ops
    • activation (local proj if necessary)

@lvyuemeng
Copy link
Collaborator Author

lvyuemeng commented Dec 25, 2024

Native:

Definition: The package is installed directly from source or binaries without any version management.

Use Case: Tools that do not require version management or are system-level dependencies.

Example: gcc, make, or system utilities.

Version Manager:

Definition: The package is managed by a version manager (e.g., nvm for Node.js, rvm for Ruby).

Use Case: Tools that require multiple versions or isolated environments.

Example: node, ruby, python.

Prebuilt:

Definition: The package is downloaded as precompiled binaries and installed directly.

Use Case: Tools that are distributed as binaries and do not require compilation.

Example: docker, vscode.

Self-Versioned:

Definition: The package comes with its own version manager (e.g., Rust with rustup).

Use Case: Tools that bundle their own version management system.

Example: rust, bun.

@lvyuemeng
Copy link
Collaborator Author

lvyuemeng commented Dec 26, 2024

Runtime

Path Storage

  • home (home path)
  • cur (work path)
  • store
    • root (the store path of infos that list below)
    • bin_dir
    • cache_dir
    • temp_dir
    • plugin_dir
    • tools_dir (store remote versions and portable package)

Construct a test sandbox...(May need other Lua package aid)

Config

  • config
    • config_global
    • config_local
    • config_all

@lvyuemeng
Copy link
Collaborator Author

lvyuemeng commented Dec 26, 2024

CLI

Utils

  • install graph
  • version list
  • progress bar
  • users interaction (including prompt, parse info)
  • style control
  • debug info
  • plugin register

Cmds
Format: xlings [module] [ops] [target]

  • xim (move XPackage ops to xim itself, because it's related to IO ops)
    • accept various args to define ops
    • install by
      • source
      • install strategy
    • update by installation type
    • uninstall by installation type
  • xvm
    • ...

@lvyuemeng
Copy link
Collaborator Author

lvyuemeng commented Dec 27, 2024

shims

env
shims script or binary content:

  • read shims registry (wait for construction...)
  • determine version based on config
  • interpolate cmds with real env path and name

create shims:

  • ensure self integrity
  • create shims script or binary
  • place at the entry path

shims registry

  • name
    • name callee (the real name called in env)
    • before args
    • after args
    • env vars

@lvyuemeng
Copy link
Collaborator Author

lvyuemeng commented Dec 27, 2024

Package Plugin Supplement

meta:

  • default infos

register:

  • name
  • requires?
  • vms?
  • private_config?
  • ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature | 功能 New feature or request
Projects
Status: No status
Development

No branches or pull requests

1 participant