Coder Social home page Coder Social logo

yakiyo / dsm Goto Github PK

View Code? Open in Web Editor NEW
10.0 1.0 1.0 1.01 MB

Version Manager for the Dart SDK

Home Page: https://dsm-vm.vercel.app/

License: MIT License

Dockerfile 0.27% Shell 9.79% Rust 85.64% TypeScript 2.08% PowerShell 2.21%
cli dart fnm rust version-manager dart-sdk

dsm's Introduction

DSM - Dart SDK Manager

ci

Simplified version manager for the Dart SDK. Inspired by fnm and nvm.

demo svg

Installation

To quickly install dsm, you can use one of the following scripts

bash (linux/macos/windows)

$ curl -fsSL https://dsm-vm.vercel.app/install.sh | bash

The bash script works on windows too if you have git bash, since it comes with the associated utilities like uname, curl and others. The script accepts options like the -F or --filename flag to override what file to use (see the release section to see the available ones). Run the --help flag to see available ones. For example

$ curl -fsSL https://dsm-vm.vercel.app/install.sh | bash -s -- --install-dir "path/to/file" -F "x86_64-unknown-linux-musl" --skip-shell

powershell (windows)

$ irm https://dsm-vm.vercel.app/install.ps1 | iex

You can specify the version by declaring a $v variable beforehand and change the installation dir by a env variable named DSM_INSTALL

crates.io:

$ cargo install dsm

Locally

Clone the repo first. Then build it. You need the rust toolchain installed in your local environment. Get it from here. You also need git.

$ git clone https://github.com/Yakiyo/dsm

$ cd dsm

$ cargo build --release

Pre-built binaries

Pre-built binaries for some platforms are available in github releases section. You can download the file, rename it and add it to your system PATH.

After installation, setup your shell as mentioned in setup.

Setup

The dsm env <SHELL> command is used for setting up shell. Currently powershell, bash. zsh, cmd and fish are supported.

Bash/Zsh

Add the following to your .bashrc or .zshrc file.

eval $(dsm env bash)
# or for zsh
eval $(dsm env zsh)

Windows users using Git Bash should check out this issue: #20

Fish

Create ~/.config/fish/conf.d/dsm.fish and add the following.

dsm env fish | source

Powershell

Add the following to your powershell profile

dsm env powershell | Out-String | Invoke-Expression

You can view the path to your profile with the $PROFILE variable.

Command Prompt

Create a startup script and add the following.

FOR /f "tokens=*" %i IN ('dsm env cmd') DO CALL %i

Usage

For installing a specific version

$ dsm install 3.0.3

You can use latest to install the latest stable sdk version. Latest versions of dev/beta channels are also supported via latest/channel or latest-channel format.

$ dsm install latest-dev # or dsm install latest/dev

$ dsm install latest # same as latest-stable or latest/stable

Then use the use command to activate it

$ dsm use 3.0.3

For creating aliases, use the alias and unalias commands

$ dsm alias 3.0.3 pinned

$ dsm unalias pinned

View all installed versions

$ dsm ls # or dsm list

For a list of all commands, do dsm --help.

Logs

Dsm logs additional information throughout the program. The level of the emitted logs can be manually customized using the DSM_LOG environment variable. The env takes one of the following values:

  • error
  • warn
  • info
  • debug
  • trace

The default is error. If info is set, then all logs of level info, warn and error will be emitted. Similar for the others too. See the docs at env_logger for additional details

Colors can be disabled either via the --disable-colors flag or by setting DSM_LOG_STYLE env to "never".

Contributing

Contributions are always welcome. You can start with any of the open issues to work on. For adding a new feature, please open an issue before working on it in order to discuss it. Feature commits are prefered so please open individual prs for individual features instead of doing several feature additions/changes in a single pull request. For any changes, add a changeset via pnpm changeset if its applicable.

Make sure your code passes the CI and please merge and resolve conflicts from upstream before finalizing the pr.

If you cannot code yourself but would like to request a feature, please open an issue and I'll see what can be done.

Credits

A huge amount of code and inspiration has been taken from Schniz's fnm. The project structure, some of the hacks and codes are based from it.

Author

dsm © Yakiyo. Authored and maintained by Yakiyo.

Released under MIT License

If you like this project, consider leaving a star ⭐ and sharing it with your friends and colleagues.

dsm's People

Contributors

actions-user avatar dependabot[bot] avatar yakiyo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

dsm's Issues

Invalid arch detection when installing Dart?

Hello,

I am using dsm to install Dart inside a devcontainer running on a Mac M1.

And I believe running dsm install 3.1.2 installs the wrong architecture version of Dart.

Indeed, when trying to run dart after the installation I get the following error:

qemu-x86_64: Could not open '/lib64/ld-linux-x86-64.so.2': No such file or directory

If I run dsm install --arch arm64 3.1.2, then all is good I can invoke dart.

I believe it detect the wrong architecture because if I run dsm install --arch x64 latest then I get the same error as when running dsm install latest.

Is it related to #2 ?

Running uname -m inside the VM gives me aarch64

Reproduction

Dockfile I am using:

# Use x86_64 architecture to avoid all the small pains
# coming from alpine over ARM --platform=linux/amd64
FROM mcr.microsoft.com/devcontainers/base:debian
# Install the xz-utils package
RUN apt-get update && apt-get install -y xz-utils

# Options
# Let it here to avoid conflicts with Microsoft options !!!
ARG DOTNET_VERSION=6.0.406
ARG NODE_VERSION=18.8.0
ARG PYTHON_VERSION=3.11.5
ARG DART_VERSION=3.1.2

USER vscode

# Change the default shell to zsh
SHELL ["/bin/zsh", "-c"]

# # Install .NET
WORKDIR /home/vscode

# Instal dart
RUN curl -fsSL https://dsm-vm.vercel.app/install.sh | bash
RUN echo "# Load dart path" >> .zshrc
RUN echo 'export PATH="/home/vscode/.dsm:$PATH"' >> .zshrc
RUN echo 'eval "`dsm env zsh`"' >> .zshrc
# RUN source .zshrc && dsm install $DART_VERSION
# RUN source .zshrc && dsm use $DART_VERSION

# Force docker to load the zsh profile
# This should be the last steps
CMD [ "/bin/zsh" ]
  1. docker build --tag fable-dev .
  2. docker run -it --rm fable-dev
  3. dsm install latest
  4. dart <- See that this fails with the reported error

installation scripts

I'm no good with shell scripts like bash or powershell so any help regarding making one would be appreciated. For linux/macos, we a bash script that can be downloaded via curl/wget and ran to install and a powershell script for windows would be nice.
I'll try by myself but idk how long it'll take. If anyone is interested, please drop a comment below before going ahead and doing it in order to notify me.

  • Bash script for linux/macos (and windows too preferebly) - #14
  • Powershell script for windows

detect archs

Detecting platform arch in ./src/arch.rs needs fixing

Windows Git Bash Issue

Rust changes the path separater (\ for win and / for unix systems) based on the platform. So windows builds always use \ as a path separater. While this is completely reasonable for windows apps, this causes some slight issues with using Git Bash that comes packed with Git. Git bash uses the unix style path separater, as such to git bash, path\\to\\file is just pathtofile. A work around for this is done by using cygpath (here) to convert the windows style path to unix. This should in general solve the issue. But again, sometimes it doesnt work. This makes dsm env bash sometimes buggy.
In such cases, the fix is to manually define the dsm-dir option. This can be done via the follow two ways

# make sure to use `/` as the path separater

# define the env var for it
export DSM_DIR = "path/to/dsm/dir"
eval `dsm env bash`

# or just pass it to the cli
eval `dsm env bash --dsm-dir path/to/file

Both of them do the same thing. the default dsm dir is ~/.dsm so it can be referenced via $HOME/.dsm within the .bashrc or whatever file is being used. Until i can find the reason behind this unexpected bug, this should solve the problem. Im not even sure if this issue is just in my own dekstop only or is actually a bug. Comment to this issue if you've got any queries/suggestions etc.

NOTE: This is only applicable for windows users using Git bash. Powershell and Cmd should have no problems. This might also occur for zsh and fish but i've never gotten the oppurtunity nor do i know any method to install zsh or fish on windows without wsl

partial version arguments

Currently dsm requires the version input to be an exact version string. as in "3.0.5" will work but "3.0" wont resolve to the latest patch of the version. This is partly due to a lack of available index for the dart sdk version and also because of the crate dart_semver, thats current being used to parse the semver, not supporting the syntax. fetching directly from gh api is not possible as it needs a lot of pagination (and time) to fetch all tags of the sdk and it hits the daily free ratelimit too.
For the index, i've been trying to make one at Yakiyo/dart-index and for the semver parsing, Yakiyo/dart-semver.rs needs fixing. So the current issues would

detect x86

x86 is being flagged as an invalid arch type. forgot to map it to an arch. fix that

dsm envs on git bash for windows

in windows paths are expressed using \\ between folders while unix uses /. git bash on windows ends up using / but rust displays path as \\ so dsm env isnt working properly. Powershell on windows work perfectly fine but not on bash

remove alias on uninstall

Remove all aliases that point to a version when its uninstalled. otherwise the directories remain there even tho theres no version for it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.