├── .editorconfig
├── .git-blame-ignore-revs
├── .gitattributes
├── .github
├── CODEOWNERS
├── ISSUE_TEMPLATE
│ ├── bug_report.yaml
│ ├── config.yml
│ ├── documentation.yaml
│ └── feature_request.yaml
├── PULL_REQUEST_TEMPLATE.md
├── dependabot.yml
└── workflows
│ ├── documentation.yml
│ ├── lint.yml
│ ├── release-build.yml
│ ├── release.yml
│ ├── semantic-pr.yml
│ └── tests.yml
├── .gitignore
├── .release-please-manifest.json
├── .tool-versions
├── CHANGELOG.md
├── CONTRIBUTING.md
├── LICENSE
├── Makefile
├── README.md
├── SECURITY.md
├── asdf.elv
├── asdf.fish
├── asdf.nu
├── asdf.ps1
├── asdf.sh
├── ballad-of-asdf.md
├── bin
├── asdf
└── private
│ └── asdf-exec
├── cmd
└── asdf
│ ├── main.go
│ └── main_test.go
├── defaults
├── docs
├── .gitattributes
├── .gitignore
├── .prettierignore
├── .tool-versions
├── .vitepress
│ ├── config.ts
│ ├── navbars.ts
│ ├── sidebars.ts
│ └── theme
│ │ ├── custom.css
│ │ └── index.ts
├── CNAME
├── contribute
│ ├── core.md
│ ├── documentation.md
│ ├── first-party-plugins.md
│ └── github-actions.md
├── guide
│ ├── getting-started-legacy.md
│ ├── getting-started.md
│ ├── introduction.md
│ └── upgrading-to-v0-16.md
├── index.md
├── ja-jp
│ ├── contribute
│ │ ├── core.md
│ │ ├── documentation.md
│ │ ├── first-party-plugins.md
│ │ └── github-actions.md
│ ├── guide
│ │ ├── getting-started-legacy.md
│ │ ├── getting-started.md
│ │ ├── introduction.md
│ │ ├── parts
│ │ │ └── install-dependencies.md
│ │ └── upgrading-to-v0-16.md
│ ├── index.md
│ ├── manage
│ │ ├── commands.md
│ │ ├── configuration.md
│ │ ├── core.md
│ │ ├── plugins.md
│ │ └── versions.md
│ ├── more
│ │ ├── community-projects.md
│ │ ├── faq.md
│ │ └── thanks.md
│ └── plugins
│ │ └── create.md
├── ko-kr
│ ├── contribute
│ │ ├── core.md
│ │ ├── documentation.md
│ │ ├── first-party-plugins.md
│ │ └── github-actions.md
│ ├── guide
│ │ ├── getting-started.md
│ │ └── introduction.md
│ ├── index.md
│ ├── manage
│ │ ├── commands.md
│ │ ├── configuration.md
│ │ ├── core.md
│ │ ├── plugins.md
│ │ └── versions.md
│ ├── more
│ │ ├── community-projects.md
│ │ ├── faq.md
│ │ └── thanks.md
│ └── plugins
│ │ └── create.md
├── manage
│ ├── commands.md
│ ├── configuration.md
│ ├── core.md
│ ├── plugins.md
│ └── versions.md
├── more
│ ├── community-projects.md
│ ├── faq.md
│ └── thanks.md
├── package-lock.json
├── package.json
├── parts
│ └── install-dependencies.md
├── plugins
│ └── create.md
├── pt-br
│ ├── contribute
│ │ ├── core.md
│ │ ├── documentation.md
│ │ ├── first-party-plugins.md
│ │ └── github-actions.md
│ ├── guide
│ │ ├── getting-started.md
│ │ └── introduction.md
│ ├── index.md
│ ├── manage
│ │ ├── commands.md
│ │ ├── configuration.md
│ │ ├── core.md
│ │ ├── plugins.md
│ │ └── versions.md
│ ├── more
│ │ ├── community-projects.md
│ │ ├── faq.md
│ │ └── thanks.md
│ └── plugins
│ │ └── create.md
└── zh-hans
│ ├── contribute
│ ├── core.md
│ ├── documentation.md
│ ├── first-party-plugins.md
│ └── github-actions.md
│ ├── guide
│ ├── getting-started.md
│ └── introduction.md
│ ├── index.md
│ ├── manage
│ ├── commands.md
│ ├── configuration.md
│ ├── core.md
│ ├── plugins.md
│ └── versions.md
│ ├── more
│ ├── community-projects.md
│ ├── faq.md
│ └── thanks.md
│ └── plugins
│ └── create.md
├── go.mod
├── go.sum
├── help.txt
├── internal
├── cli
│ ├── cli.go
│ └── set
│ │ ├── set.go
│ │ └── set_test.go
├── completions
│ ├── asdf.bash
│ ├── asdf.elvish
│ ├── asdf.fish
│ ├── asdf.nushell
│ ├── asdf.zsh
│ ├── completions.go
│ └── completions_test.go
├── config
│ ├── config.go
│ ├── config_test.go
│ └── testdata
│ │ ├── asdfrc
│ │ └── empty-asdfrc
├── data
│ ├── data.go
│ └── data_test.go
├── exec
│ ├── exec.go
│ ├── exec_test.go
│ └── testdata
│ │ └── script
│ │ ├── exec-env.txtar
│ │ └── exec-simple.txtar
├── execenv
│ ├── execenv.go
│ └── execenv_test.go
├── execute
│ ├── execute.go
│ ├── execute_test.go
│ └── testdata
│ │ └── script
├── git
│ ├── git.go
│ └── git_test.go
├── help
│ ├── help.go
│ ├── help.txt
│ └── help_test.go
├── hook
│ ├── hook.go
│ ├── hook_test.go
│ └── testdata
│ │ └── asdfrc
├── info
│ ├── info.go
│ └── info_test.go
├── installs
│ ├── installs.go
│ └── installs_test.go
├── installtest
│ └── installtest.go
├── paths
│ ├── paths.go
│ └── paths_test.go
├── pluginindex
│ ├── pluginindex.go
│ └── pluginindex_test.go
├── plugins
│ ├── plugins.go
│ └── plugins_test.go
├── repotest
│ └── repotest.go
├── resolve
│ ├── resolve.go
│ ├── resolve_test.go
│ └── testdata
│ │ └── asdfrc
├── shims
│ ├── shims.go
│ ├── shims_test.go
│ └── testdata
│ │ └── asdfrc
├── toolversions
│ ├── toolversions.go
│ └── toolversions_test.go
└── versions
│ ├── testdata
│ ├── asdfrc
│ ├── list-all-elixir
│ ├── list-all-python
│ ├── list-all-ruby
│ └── uninstall-asdfrc
│ ├── versions.go
│ └── versions_test.go
├── lib
├── commands
│ ├── command-current.bash
│ ├── command-env.bash
│ ├── command-exec.bash
│ ├── command-export-shell-version.bash
│ ├── command-global.bash
│ ├── command-help.bash
│ ├── command-info.bash
│ ├── command-install.bash
│ ├── command-latest.bash
│ ├── command-list-all.bash
│ ├── command-list.bash
│ ├── command-local.bash
│ ├── command-plugin-add.bash
│ ├── command-plugin-list-all.bash
│ ├── command-plugin-list.bash
│ ├── command-plugin-push.bash
│ ├── command-plugin-remove.bash
│ ├── command-plugin-test.bash
│ ├── command-plugin-update.bash
│ ├── command-reshim.bash
│ ├── command-shim-versions.bash
│ ├── command-uninstall.bash
│ ├── command-update.bash
│ ├── command-version.bash
│ ├── command-where.bash
│ ├── command-which.bash
│ ├── reshim.bash
│ └── version_commands.bash
├── functions
│ ├── installs.bash
│ ├── plugins.bash
│ └── versions.bash
└── utils.bash
├── release-please-config.json
├── scripts
├── checkstyle.py
├── install_dependencies.bash
├── lint.bash
└── test.bash
├── staticcheck.conf
├── test
├── asdf_elvish.bats
├── asdf_fish.bats
├── asdf_nu.bats
├── asdf_pwsh.bats
├── asdf_sh.bats
├── banned_commands.bats
├── current_command.bats
├── fixtures
│ ├── dummy_broken_plugin
│ │ └── bin
│ │ │ ├── download
│ │ │ ├── install
│ │ │ └── list-all
│ ├── dummy_legacy_plugin
│ │ └── bin
│ │ │ ├── get-version-from-legacy-file
│ │ │ ├── install
│ │ │ ├── list-all
│ │ │ ├── list-legacy-filenames
│ │ │ └── parse-legacy-file
│ ├── dummy_plugin
│ │ ├── LICENSE
│ │ └── bin
│ │ │ ├── debug
│ │ │ ├── download
│ │ │ ├── get-version-from-legacy-file
│ │ │ ├── help.overview
│ │ │ ├── install
│ │ │ ├── latest-stable
│ │ │ ├── list-all
│ │ │ ├── list-legacy-filenames
│ │ │ ├── parse-legacy-file
│ │ │ ├── post-plugin-add
│ │ │ ├── post-plugin-update
│ │ │ └── pre-plugin-remove
│ ├── dummy_plugin_no_download
│ │ ├── LICENSE
│ │ └── bin
│ │ │ └── install
│ └── dummy_plugins_repo
│ │ └── plugins
│ │ ├── bar
│ │ ├── dummy
│ │ └── foo
├── get_asdf_config_value.bats
├── help_command.bats
├── info_command.bats
├── install_command.bats
├── latest_command.bats
├── list_command.bats
├── non_existent_command.bats
├── plugin_add_command.bats
├── plugin_extension_command.bats
├── plugin_list_all_command.bats
├── plugin_remove_command.bats
├── plugin_test_command.bats
├── plugin_update_command.bats
├── remove_command.bats
├── reshim_command.bats
├── setup_suite.bash
├── shim_env_command.bats
├── shim_exec.bats
├── shim_versions_command.bats
├── test_helpers.bash
├── uninstall_command.bats
├── update_command.bats
├── utils.bats
├── version_commands.bats
├── where_command.bats
└── which_command.bats
├── tools.go
└── version.txt
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | indent_style = space
5 | indent_size = 2
6 | end_of_line = lf
7 | charset = utf-8
8 | trim_trailing_whitespace = true
9 | insert_final_newline = true
10 |
11 | [*.go]
12 | indent_style = tab
13 |
14 | [*.py]
15 | indent_size = 4
16 |
17 | [*.fish]
18 | indent_size = 4
19 |
20 | [*.md]
21 | trim_trailing_whitespace = false
22 |
--------------------------------------------------------------------------------
/.git-blame-ignore-revs:
--------------------------------------------------------------------------------
1 | # Run shfmt on bash files
2 | b8dc5f160447baabab9c69683824512ded577254
3 |
4 | # fix: Remove == inside [ (#1421)
5 | d81b81f9de2dc5961624464df04cef7cafae588c
6 |
7 | # chore: Fix ShellCheck errors in tests
8 | 407a6696c0739f5e368543c4fc1b14e41458f177
9 | 998180e3625643644603504bea75e3bcc668465f
10 | 6f64aa8d847d53f272d30bcf2532937c02826080
11 | b5e981cf1d9a37af17e48f6a871ff692720df810
12 | 28b348a041b3dfd1898eb0073aa1e83bdae70e4a
13 | 720fd172004c9f29045eb2ad19f35eba47ae31c7
14 | ffa018763c10de63e6548372e7eaad2ae53643d6
15 | 90ead5ea0ae06418c58a47f4c7732797af5fe336
16 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | ## GITATTRIBUTES
2 | #
3 | # Details per file setting:
4 | # text These files should be normalized (i.e. convert CRLF to LF).
5 | # binary These files are binary and should be left untouched.
6 | #
7 | # Note that binary is a macro for -text -diff.
8 | ######################################################################
9 |
10 | ## AUTO-DETECT
11 | ## Handle line endings automatically for files detected as
12 | ## text and leave all files detected as binary untouched.
13 | ## This will handle all files NOT defined below.
14 | * text=auto
15 |
16 | ## SOURCE CODE
17 | *.bats text
18 | *.css text
19 | *.htm text
20 | *.html text
21 | *.js text
22 | *.sh text
23 | *.bash text
24 | *.fish text
25 | *.elv text
26 | #### asdf/bin/* explicitly define as text
27 | *asdf text
28 | *asdf-exec text
29 | *_asdf text
30 | #### asdf/test/fixtures/* should be covered by * text=auto on L14
31 |
32 | ## DOCKER
33 | *.dockerignore text
34 | Dockerfile text
35 |
36 | ## DOCUMENTATION
37 | *.markdown text
38 | *.md text
39 | *.mdwn text
40 | *.mdown text
41 | *.mkd text
42 | *.mkdn text
43 | *.mdtxt text
44 | *.mdtext text
45 | *.txt text
46 | AUTHORS text
47 | CHANGELOG text
48 | CHANGES text
49 | CONTRIBUTING text
50 | COPYING text
51 | copyright text
52 | *COPYRIGHT* text
53 | INSTALL text
54 | license text
55 | LICENSE text
56 | NEWS text
57 | readme text
58 | *README* text
59 | TODO text
60 |
61 | ## CONFIGS
62 | .editorconfig text
63 | .gitattributes text
64 | .gitconfig text
65 | *.yaml text
66 | *.yml text
67 |
--------------------------------------------------------------------------------
/.github/CODEOWNERS:
--------------------------------------------------------------------------------
1 | # Default owners for all the code in this repo
2 | * @asdf-vm/core
3 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.yaml:
--------------------------------------------------------------------------------
1 | name: Bug Report
2 | description: Create a report to help us improve
3 | title: "bug: "
4 | labels: [bug]
5 | body:
6 | - type: markdown
7 | attributes:
8 | value: |
9 | Thanks for taking the time to fill out this bug report!
10 | - type: textarea
11 | id: description
12 | attributes:
13 | label: Describe the Bug
14 | description: A clear and concise description of what the bug is.
15 | validations:
16 | required: true
17 | - type: textarea
18 | id: reproduction
19 | attributes:
20 | label: Steps to Reproduce
21 | description: Tell us what actions you performed before the issue occurred
22 | placeholder: |
23 | 1. Go to '...'
24 | 2. Click on '....'
25 | 3. Scroll down to '....'
26 | 4. See error
27 | validations:
28 | required: true
29 | - type: textarea
30 | id: expected
31 | attributes:
32 | label: Expected Behaviour
33 | description: Tell us what should have happened?
34 | validations:
35 | required: true
36 | - type: textarea
37 | id: actual
38 | attributes:
39 | label: Actual Behaviour
40 | description: Tell us what happened instead
41 | validations:
42 | required: true
43 | - type: textarea
44 | id: environment
45 | attributes:
46 | label: Environment
47 | description: Copy the output of `asdf info` here
48 | render: shell
49 | validations:
50 | required: true
51 | - type: textarea
52 | id: plugins
53 | attributes:
54 | label: asdf plugins affected (if relevant)
55 | description: The plugins you list here should appear in the list from `asdf info`
56 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/config.yml:
--------------------------------------------------------------------------------
1 | # Force users to use one of our predefined issue templates
2 | blank_issues_enabled: false
3 | contact_links:
4 | - name: Question (StackOverflow)
5 | url: https://stackoverflow.com/questions/tagged/asdf-vm
6 | about: Ask new or browse existing questions on StackOverflow.
7 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/documentation.yaml:
--------------------------------------------------------------------------------
1 | name: Documentation
2 | description: Suggest a documentation improvements for this project
3 | labels: "documentation"
4 | body:
5 | - type: markdown
6 | attributes:
7 | value: |
8 | Thanks for taking the time to help improve our docs!
9 | - type: textarea
10 | id: problem
11 | attributes:
12 | label: How can we improve the documentation?
13 | description: Please provide a clear and concise description of the problem. The more information you can provide here, the better.
14 | placeholder: The documentation can be improved by...
15 | validations:
16 | required: true
17 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.yaml:
--------------------------------------------------------------------------------
1 | name: Feature Request
2 | description: Suggest an idea for this project
3 | labels: "enhancement"
4 | body:
5 | - type: markdown
6 | attributes:
7 | value: |
8 | Thanks for taking the time to request this feature!
9 | - type: textarea
10 | id: problem
11 | attributes:
12 | label: Is your feature request related to a problem? Please describe
13 | description: Please provide a clear and concise description the problem this feature would solve. The more information you can provide here, the better.
14 | placeholder: I'm always frustrated when...
15 | validations:
16 | required: true
17 | - type: textarea
18 | id: solution
19 | attributes:
20 | label: Describe the proposed solution
21 | description: Please provide a clear and concise description of what you would like to happen.
22 | placeholder: I would like to see...
23 | validations:
24 | required: true
25 | - type: textarea
26 | id: alternatives
27 | attributes:
28 | label: "Describe similar `asdf` features and why they are not sufficient"
29 | description: "Describe asdf features you tried to use to accomplish what you wanted. Explain why they are insufficient for the task you were trying to accomplish."
30 | validations:
31 | required: true
32 | - type: textarea
33 | id: workarounds
34 | attributes:
35 | label: "Describe other workarounds you've considered"
36 | description: "A clear and concise description of any alternative solutions or features you've considered."
37 | validations:
38 | required: true
39 |
--------------------------------------------------------------------------------
/.github/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | # Summary
2 |
3 |
4 |
5 | Fixes: List issue numbers here
6 |
7 | ## Other Information
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | version: 2
2 | updates:
3 | # Maintain dependencies for GitHub Actions
4 | - package-ecosystem: "github-actions"
5 | directory: "/"
6 | schedule:
7 | interval: "weekly"
8 | reviewers:
9 | - "jthegedus"
10 | - "stratus3d"
11 | # Maintain dependencies for npm used in Documentation site
12 | - package-ecosystem: "npm"
13 | directory: "/docs"
14 | schedule:
15 | interval: "monthly"
16 | reviewers:
17 | - "jthegedus"
18 | groups:
19 | docs:
20 | patterns:
21 | - "*"
22 |
--------------------------------------------------------------------------------
/.github/workflows/documentation.yml:
--------------------------------------------------------------------------------
1 | name: Documentation
2 |
3 | on:
4 | # trigger deployment on push to master branch when changes to docs/**
5 | push:
6 | paths:
7 | - "docs/**"
8 | branches:
9 | - master
10 | # trigger deployment manually
11 | workflow_dispatch:
12 |
13 | jobs:
14 | deploy:
15 | runs-on: ubuntu-latest
16 | defaults:
17 | run:
18 | working-directory: docs/
19 |
20 | steps:
21 | - uses: actions/checkout@v4
22 | with:
23 | # fetch all commits to get last updated time or other git log info
24 | fetch-depth: 0
25 |
26 | - name: Setup Node.js
27 | uses: actions/setup-node@v4
28 | with:
29 | node-version: "20"
30 |
31 | - name: Cache dependencies
32 | uses: actions/cache@v4
33 | id: npm-cache
34 | with:
35 | path: |
36 | **/node_modules
37 | key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
38 | restore-keys: |
39 | ${{ runner.os }}-npm-
40 |
41 | - name: Install dependencies
42 | if: steps.npm-cache.outputs.cache-hit != 'true'
43 | run: npm install
44 |
45 | - name: Build VitePress site
46 | run: npm run build
47 |
48 | - name: Bundle CNAME with site dist
49 | run: cp CNAME .vitepress/dist
50 |
51 | - name: Deploy to GitHub Pages
52 | uses: crazy-max/ghaction-github-pages@v4
53 | with:
54 | # deploy to gh-pages branch
55 | target_branch: gh-pages
56 | # deploy the default output dir of VitePress
57 | build_dir: docs/.vitepress/dist
58 | env:
59 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
60 |
--------------------------------------------------------------------------------
/.github/workflows/lint.yml:
--------------------------------------------------------------------------------
1 | name: Lint
2 |
3 | on:
4 | push:
5 | branches:
6 | - master
7 | pull_request:
8 |
9 | env:
10 | PYTHON_MIN_VERSION: "3.13.1"
11 |
12 | jobs:
13 | asdf-bash:
14 | runs-on: ubuntu-latest
15 | steps:
16 | - uses: actions/checkout@v4
17 | - uses: asdf-vm/actions/install@v3
18 | - uses: actions/setup-python@v5
19 | with:
20 | python-version: ${{ env.PYTHON_MIN_VERSION }}
21 | - run: scripts/install_dependencies.bash
22 | - run: scripts/lint.bash --check
23 |
24 | asdf-golang:
25 | runs-on: ubuntu-latest
26 | steps:
27 | - uses: actions/checkout@v4
28 | - name: Setup Go
29 | uses: actions/setup-go@v5
30 | with:
31 | go-version: '1.23.4'
32 | - name: Install dependencies
33 | run: go get ./...
34 | - name: Run 'gofumpt'
35 | run: go run mvdan.cc/gofumpt -l -w .
36 | - name: Check format
37 | run: '[ -z "$(gofmt -l ./...)" ]'
38 | - name: Run 'revive'
39 | run: go run github.com/mgechev/revive -set_exit_status ./...
40 | - name: Vet
41 | run: go vet ./...
42 | - name: Lint
43 | run: go run honnef.co/go/tools/cmd/staticcheck -tests -show-ignored ./...
44 | - name: Build
45 | run: go build -v ./...
46 |
47 | actions:
48 | runs-on: ubuntu-latest
49 | steps:
50 | - uses: actions/checkout@v4
51 | - name: Check workflow files
52 | uses: docker://rhysd/actionlint:1.6.24
53 | with:
54 | args: -color
55 |
--------------------------------------------------------------------------------
/.github/workflows/release-build.yml:
--------------------------------------------------------------------------------
1 | name: Build Binaries for Release
2 |
3 | on:
4 | release:
5 | types: [published]
6 |
7 | permissions:
8 | contents: write
9 | packages: write
10 |
11 | jobs:
12 | build:
13 | name: Build release binaries
14 | runs-on: ubuntu-latest
15 | strategy:
16 | matrix:
17 | # windows isn't working on windows right now, add it to this list once
18 | # I fix the code.
19 | goos: [linux, darwin]
20 | goarch: ["386", amd64, arm64]
21 | exclude:
22 | - goarch: "386"
23 | goos: darwin
24 | #- goarch: arm64
25 | # goos: windows
26 | steps:
27 | - name: Checkout
28 | uses: actions/checkout@v4
29 | with:
30 | fetch-depth: 0
31 | - name: Build Go binaries
32 | uses: wangyoucao577/go-release-action@v1
33 | with:
34 | pre_command: "export CGO_ENABLED=0"
35 | github_token: ${{ secrets.GITHUB_TOKEN }}
36 | goos: ${{ matrix.goos }}
37 | goarch: ${{ matrix.goarch }}
38 | goversion: "1.23.4"
39 | binary_name: "asdf"
40 | project_path: ./cmd/asdf
41 | release_tag: ${{ github.event.release.tag_name }}
42 | release_name: ${{ github.event.release.tag_name }}
43 | ldflags: -s -X main.version=${{ github.event.release.tag_name }}
44 |
--------------------------------------------------------------------------------
/.github/workflows/release.yml:
--------------------------------------------------------------------------------
1 | name: Release
2 |
3 | on:
4 | push:
5 | branches:
6 | - master
7 |
8 | permissions:
9 | contents: write
10 | pull-requests: write
11 |
12 | jobs:
13 | release:
14 | runs-on: ubuntu-latest
15 | steps:
16 | - uses: googleapis/release-please-action@v4
17 | name: create release
18 | with:
19 | token: ${{ secrets.ASDF_WORKFLOW_TOKEN }}
20 | config-file: release-please-config.json
21 | manifest-file: .release-please-manifest.json
22 |
--------------------------------------------------------------------------------
/.github/workflows/semantic-pr.yml:
--------------------------------------------------------------------------------
1 | name: Lint
2 |
3 | on:
4 | pull_request_target:
5 | types:
6 | - opened
7 | - edited
8 | - synchronize
9 |
10 | jobs:
11 | semantic-pr:
12 | runs-on: ubuntu-latest
13 | steps:
14 | - uses: amannn/action-semantic-pull-request@v5.5.3
15 | env:
16 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
17 | with:
18 | scopes: |
19 | # The scope for all the Golang rewrite commits
20 | golang-rewrite
21 | # A list of all used scopes can be computed by running this command:
22 | #
23 | # git log --pretty=format:%s | rg '^[^: ]*\(([^):]*)\).*' -r '$1' | sort | uniq
24 | #
25 | # We only want to allow a limited set of scopes going forward, so
26 | # the list of valid scopes has been pared down here.
27 | docs
28 | website
29 | plugin
30 | completions
31 | deps
32 |
--------------------------------------------------------------------------------
/.github/workflows/tests.yml:
--------------------------------------------------------------------------------
1 | name: Test
2 |
3 | on:
4 | push:
5 | branches:
6 | - master
7 | pull_request:
8 |
9 | jobs:
10 | detect-changes:
11 | runs-on: ubuntu-latest
12 | # Set job outputs to values from filter step
13 | outputs:
14 | documentation: ${{ steps.filter.outputs.documentation }}
15 | cli: ${{ steps.filter.outputs.cli }}
16 | go: ${{ steps.filter.outputs.go }}
17 | steps:
18 | - uses: actions/checkout@v4
19 | with:
20 | fetch-depth: 0
21 | - uses: dorny/paths-filter@v3
22 | id: filter
23 | with:
24 | filters: |
25 | documentation:
26 | - '.github/workflows/**'
27 | - 'docs/**'
28 | cli:
29 | - '.github/workflows/**'
30 | - 'bin/**'
31 | - 'lib/**'
32 | - 'scripts/**'
33 | - 'test/**'
34 | - '.tool-versions'
35 | - 'asdf.*'
36 | - 'defaults'
37 | - 'help.txt'
38 | go:
39 | - '**.go'
40 | - 'go.mod'
41 | - 'go.sum'
42 |
43 | test-golang:
44 | needs: detect-changes
45 | if: ${{ needs.detect-changes.outputs.go == 'true' || needs.detect-changes.outputs.cli == 'true' }}
46 | strategy:
47 | matrix:
48 | os: [ubuntu-latest, macos-latest]
49 | runs-on: ${{ matrix.os }}
50 | steps:
51 | - uses: actions/checkout@v4
52 | - name: Setup Go
53 | uses: actions/setup-go@v5
54 | with:
55 | go-version: '1.23.4'
56 | - run: scripts/install_dependencies.bash
57 | - name: Install dependencies
58 | run: go get ./...
59 | - name: Run Go tests
60 | run: go test -coverprofile=/tmp/coverage.out -bench= -race ./...
61 |
62 | # Because I changed the test helper code Bash tests now fail. I removed them
63 | # from here to get passing checks. They can be added back at a later time if
64 | # I fix the test helper.
65 |
66 | documentation-site:
67 | needs: detect-changes
68 | # only run if
69 | # - changes to documentation
70 | # - pull_request (workflows/docs.yml deploys on main branch)
71 | if: ${{ github.event_name == 'pull_request' && needs.detect-changes.outputs.documentation == 'true' }}
72 | runs-on: ubuntu-latest
73 | steps:
74 | - uses: actions/checkout@v4
75 | with:
76 | # fetch all commits to get git log info for Vuepress
77 | fetch-depth: 0
78 |
79 | # only run steps past here if changes to docs/** directory
80 | - uses: actions/setup-node@v4
81 | with:
82 | node-version: "18"
83 |
84 | - uses: actions/cache@v4
85 | id: npm-cache
86 | with:
87 | path: |
88 | docs/node_modules
89 | key: ${{ runner.os }}-npm-${{ hashFiles('docs/package-lock.json') }}
90 | restore-keys: |
91 | ${{ runner.os }}-npm-
92 |
93 | - name: Install dependencies
94 | if: steps.npm-cache.outputs.cache-hit != 'true'
95 | working-directory: docs/
96 | run: npm install
97 |
98 | - name: Check errors by building Documentation site
99 | working-directory: docs/
100 | run: npm run build
101 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /installs
2 | /downloads
3 | /shims
4 | repository
5 | .vagrant
6 | keyrings
7 | /tmp
8 |
9 | dist/
10 |
11 | # ignore build binary
12 | asdf
13 |
--------------------------------------------------------------------------------
/.release-please-manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | ".": "0.17.0"
3 | }
4 |
--------------------------------------------------------------------------------
/.tool-versions:
--------------------------------------------------------------------------------
1 | golang 1.23.4
2 | bats 1.8.2
3 | shellcheck 0.10.0
4 | shfmt 3.6.0
5 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # How to Contribute to asdf
2 |
3 | There are many ways to contribute to `asdf`, thanks for taking the time to read and help.
4 |
5 | ## `asdf` Core
6 |
7 | ### Did you find a bug?
8 |
9 | Ensure the bug is actually an issue with asdf and not a plugin. If the bug only occurs when using one tool installed by `asdf` and not others it is likely an issue with the **plugin**. Find the plugin repo URL with `asdf plugin list --urls`, browse their repo Issues and if no solution is found open a new Issue there.
10 |
11 | Ensure the bug was not already reported in existing [Issues](https://github.com/asdf-vm/asdf/issues). If not, then please [open a new Issue](https://github.com/asdf-vm/asdf/issues/new/choose). Please be as specific as possible when reporting the issue.
12 |
13 | ### New Features/Proposals
14 |
15 | Please [open a new Feature Request](https://github.com/asdf-vm/asdf/issues/new/choose) to discuss the feature before implementing a solution.
16 |
17 | ### Developing with the Core
18 |
19 | See [docs/contribute/core.md](docs/contribute/core.md) or on our [Docs Site](https://asdf-vm.com/contribute/core.html).
20 |
21 | ## Documentation
22 |
23 | Documentation can always be improved! See [docs/contribute/documentation.md](docs/contribute/documentation.md) or on our [Docs Site](https://asdf-vm.com/contribute/documentation.html).
24 |
25 | ## First-Party Plugins
26 |
27 | We always need help to maintain our plugins. See [docs/contribute/first-party-plugins.md](docs/contribute/first-party-plugins.md) or on our [Docs Site](https://asdf-vm.com/contribute/first-party-plugins.html).
28 |
29 | ## Create a Plugin?
30 |
31 | Please read the [docs/plugins/create.md](docs/plugins/create.md) or on our [Docs Site](https://asdf-vm.com/plugins/create.html).
32 |
33 | ## GitHub Action
34 |
35 | See the [asdf actions repo](https://github.com/asdf-vm/actions) for existing Issues, conversations and Contributing Guidelines.
36 |
37 | ---
38 |
39 | Thanks for contributing!
40 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014 Akash Manohar J
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of
6 | this software and associated documentation files (the "Software"), to deal in
7 | the Software without restriction, including without limitation the rights to
8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 | the Software, and to permit persons to whom the Software is furnished to do so,
10 | subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | MAIN_PACKAGE_PATH := ./cmd/asdf
2 | TARGET_DIR := .
3 | TARGET := asdf
4 | LINKER_FLAGS = '-s'
5 |
6 | # Not sure what the default location should be for builds
7 | build: # test lint
8 | go build -ldflags=${LINKER_FLAGS} -o=${TARGET_DIR}/${TARGET} ${MAIN_PACKAGE_PATH}
9 |
10 | fmt:
11 | go fmt ./...
12 | go run mvdan.cc/gofumpt -l -w .
13 |
14 | verify:
15 | go mod verify
16 |
17 | tidy:
18 | go mod tidy -v
19 |
20 | audit: verify vet test
21 |
22 | test:
23 | go test -coverprofile=/tmp/coverage.out -bench= -race ./...
24 |
25 | cover: test
26 | go tool cover -html=/tmp/coverage.out
27 |
28 | lint: fmt
29 | go run honnef.co/go/tools/cmd/staticcheck -tests -show-ignored ./...
30 | go run github.com/mgechev/revive -set_exit_status ./...
31 |
32 | vet: fmt
33 | go vet ./...
34 |
35 | run: build
36 | ${TARGET_DIR}/${TARGET}
37 |
38 | .PHONY: fmt lint vet build test run
39 |
--------------------------------------------------------------------------------
/SECURITY.md:
--------------------------------------------------------------------------------
1 | # Security Policy
2 |
3 | **This security policy only applies to asdf core, which is the code contained in
4 | this repository. All plugins are the responsibility of their creators and are
5 | not covered under this security policy.**
6 |
7 | ## Supported Versions
8 |
9 |
10 |
11 | ```
12 | 0.17.0
13 | ```
14 |
15 |
16 |
17 | Typically only the latest version is maintained. Versions are released
18 | sequentially, with major, minor, and patch versions incremented as necessary.
19 |
20 | If a vulnerability is found in an old version of asdf, updating to the latest
21 | version of asdf will be required.
22 |
23 | ## Reporting a Vulnerability
24 |
25 | To report a vulnerability please contact one of:
26 |
27 | - @Stratus3D via email: see https://stratus3d.com/contact/ for email. PGP is not
28 | setup for this email address.
29 | - @danhper via email: see https://daniel.perez.sh/ for email and PGP key
30 | - @jthegedus via email: see https://github.com/jthegedus for email. PGP is not
31 | setup for this email address.
32 |
--------------------------------------------------------------------------------
/asdf.fish:
--------------------------------------------------------------------------------
1 | if test -z $ASDF_DIR
2 | set ASDF_DIR (builtin realpath --no-symlinks (dirname (status filename)))
3 | end
4 | set --export ASDF_DIR $ASDF_DIR
5 |
6 | set -l _asdf_bin "$ASDF_DIR/bin"
7 | if test -z $ASDF_DATA_DIR
8 | set _asdf_shims "$HOME/.asdf/shims"
9 | else
10 | set _asdf_shims "$ASDF_DATA_DIR/shims"
11 | end
12 |
13 | # Do not use fish_add_path (added in Fish 3.2) because it
14 | # potentially changes the order of items in PATH
15 | if not contains $_asdf_bin $PATH
16 | set -gx --prepend PATH $_asdf_bin
17 | end
18 | if not contains $_asdf_shims $PATH
19 | set -gx --prepend PATH $_asdf_shims
20 | end
21 | set --erase _asdf_bin
22 | set --erase _asdf_shims
23 |
24 | # The asdf function is a wrapper so we can export variables
25 | function asdf
26 | set command $argv[1]
27 | set -e argv[1]
28 |
29 | switch "$command"
30 | case shell
31 | # Source commands that need to export variables.
32 | command asdf export-shell-version fish $argv | source # asdf_allow: source
33 | case '*'
34 | # Forward other commands to asdf script.
35 | command asdf "$command" $argv
36 | end
37 | end
38 |
--------------------------------------------------------------------------------
/asdf.ps1:
--------------------------------------------------------------------------------
1 | $Env:ASDF_DIR = $PSScriptRoot
2 |
3 | $_asdf_bin = "$Env:ASDF_DIR/bin"
4 | if ($null -eq $ASDF_DATA_DIR -or $ASDF_DATA_DIR -eq '') {
5 | $_asdf_shims = "${env:HOME}/.asdf/shims"
6 | }
7 | else {
8 | $_asdf_shims = "$ASDF_DATA_DIR/shims"
9 | }
10 |
11 | $env:PATH = "${_asdf_bin}:${_asdf_shims}:${env:PATH}"
12 |
13 | if ($env:PATH -cnotlike "*${_asdf_bin}*") {
14 | $env:PATH = "_asdf_bin:${env:PATH}"
15 | }
16 | if ($env:PATH -cnotlike "*${_asdf_shims}*") {
17 | $env:PATH = "_asdf_shims:${env:PATH}"
18 | }
19 |
20 | Remove-Variable -Force _asdf_bin, _asdf_shims
21 |
22 | function asdf {
23 | $asdf = $(Get-Command -CommandType Application asdf).Source
24 |
25 | if ($args.Count -gt 0 -and $args[0] -eq 'shell') {
26 | Invoke-Expression $(& $asdf 'export-shell-version' pwsh $args[1..($args.Count + -1)])
27 | }
28 | else {
29 | & $asdf $args
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/ballad-of-asdf.md:
--------------------------------------------------------------------------------
1 | # Ballad of asdf
2 |
3 | > Once upon a time there was a programming language
4 | > There were many versions of it
5 | > So people wrote a version manager for it
6 | > To switch between versions for projects
7 | > Different, old, new.
8 |
9 | > Then there came more programming languages
10 | > So there came more version managers
11 | > And many commands for them
12 |
13 | > I installed a lot of them
14 | > I learnt a lot of commands
15 |
16 | > Then I said, just one more version manager
17 | > Which I will write instead
18 |
19 | > So, there came another version manager
20 | > **asdf version manager** -
21 |
22 | > A version manager so extendable
23 | > for which anyone can create a plugin
24 | > To support their favourite language
25 | > No more installing more version managers
26 | > Or learning more commands
27 |
28 | ---
29 |
30 | *This was the mail I wrote to a few friends to tell them about the project. Thanks to [@roshanvid](https://twitter.com/roshanvid) for suggesting that this go into the readme*
31 |
--------------------------------------------------------------------------------
/bin/private/asdf-exec:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | # remove this asdf-exec file when releasing >=0.6.5
4 | printf "asdf is self upgrading shims to new asdf exec ...\\n"
5 |
6 | asdf_dir="$(dirname "$(dirname "$(dirname "$0")")")"
7 | # shellcheck source=lib/utils.bash
8 | . "$asdf_dir/lib/utils.bash"
9 | rm "$(asdf_data_dir)"/shims/*
10 | "$asdf_dir"/bin/asdf reshim
11 | shim_name=$(basename "$2")
12 |
13 | printf "asdf: now running %s\\n" "$shim_name"
14 |
15 | exec "$shim_name" "${@:3}"
16 |
--------------------------------------------------------------------------------
/cmd/asdf/main.go:
--------------------------------------------------------------------------------
1 | // Main entrypoint for the CLI app
2 | package main
3 |
4 | import (
5 | "fmt"
6 | "runtime/debug"
7 | "slices"
8 |
9 | "github.com/asdf-vm/asdf/internal/cli"
10 | )
11 |
12 | // Do not touch this next line
13 | var version = "0.17.0" // x-release-please-version
14 |
15 | // Placeholder for the real code
16 | func main() {
17 | fullVersion := buildFullVersion(version)
18 | cli.Execute(fullVersion)
19 | }
20 |
21 | func buildFullVersion(version string) string {
22 | var shortRef string
23 |
24 | info, ok := debug.ReadBuildInfo()
25 |
26 | if !ok {
27 | panic("can't get build info")
28 | }
29 | idx := slices.IndexFunc(info.Settings, func(s debug.BuildSetting) bool {
30 | return s.Key == "vcs.revision"
31 | })
32 |
33 | if idx < 0 {
34 | shortRef = "unknown"
35 | } else {
36 | shortRef = info.Settings[idx].Value[0:7]
37 | }
38 |
39 | return fmt.Sprintf("%s (revision %s)", version, shortRef)
40 | }
41 |
--------------------------------------------------------------------------------
/defaults:
--------------------------------------------------------------------------------
1 | # See the docs for explanations: https://asdf-vm.com/manage/configuration.html
2 |
3 | legacy_version_file = no
4 | use_release_candidates = no
5 | always_keep_download = no
6 | plugin_repository_last_check_duration = 60
7 | disable_plugin_short_name_repository = no
8 | concurrency = auto
9 |
--------------------------------------------------------------------------------
/docs/.gitignore:
--------------------------------------------------------------------------------
1 | ### Custom ###
2 | # VitePress build output & cache directory
3 | .vitepress/cache
4 | .vitepress/dist
5 |
6 | # Created by https://www.toptal.com/developers/gitignore/api/node
7 | # Edit at https://www.toptal.com/developers/gitignore?templates=node
8 |
9 | ### Node ###
10 | # Logs
11 | logs
12 | *.log
13 | npm-debug.log*
14 | yarn-debug.log*
15 | yarn-error.log*
16 | lerna-debug.log*
17 | .pnpm-debug.log*
18 |
19 | # Diagnostic reports (https://nodejs.org/api/report.html)
20 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
21 |
22 | # Runtime data
23 | pids
24 | *.pid
25 | *.seed
26 | *.pid.lock
27 |
28 | # Directory for instrumented libs generated by jscoverage/JSCover
29 | lib-cov
30 |
31 | # Coverage directory used by tools like istanbul
32 | coverage
33 | *.lcov
34 |
35 | # nyc test coverage
36 | .nyc_output
37 |
38 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
39 | .grunt
40 |
41 | # Bower dependency directory (https://bower.io/)
42 | bower_components
43 |
44 | # node-waf configuration
45 | .lock-wscript
46 |
47 | # Compiled binary addons (https://nodejs.org/api/addons.html)
48 | build/Release
49 |
50 | # Dependency directories
51 | node_modules/
52 | jspm_packages/
53 |
54 | # Snowpack dependency directory (https://snowpack.dev/)
55 | web_modules/
56 |
57 | # TypeScript cache
58 | *.tsbuildinfo
59 |
60 | # Optional npm cache directory
61 | .npm
62 |
63 | # Optional eslint cache
64 | .eslintcache
65 |
66 | # Microbundle cache
67 | .rpt2_cache/
68 | .rts2_cache_cjs/
69 | .rts2_cache_es/
70 | .rts2_cache_umd/
71 |
72 | # Optional REPL history
73 | .node_repl_history
74 |
75 | # Output of 'npm pack'
76 | *.tgz
77 |
78 | # Yarn Integrity file
79 | .yarn-integrity
80 |
81 | # dotenv environment variables file
82 | .env
83 | .env.test
84 | .env.production
85 |
86 | # parcel-bundler cache (https://parceljs.org/)
87 | .cache
88 | .parcel-cache
89 |
90 | # Next.js build output
91 | .next
92 | out
93 |
94 | # Nuxt.js build / generate output
95 | .nuxt
96 | dist
97 |
98 | # Gatsby files
99 | .cache/
100 | # Comment in the public line in if your project uses Gatsby and not Next.js
101 | # https://nextjs.org/blog/next-9-1#public-directory-support
102 | # public
103 |
104 | # vuepress build output
105 | .vuepress/.cache
106 | .vuepress/.temp
107 |
108 | # Serverless directories
109 | .serverless/
110 |
111 | # FuseBox cache
112 | .fusebox/
113 |
114 | # DynamoDB Local files
115 | .dynamodb/
116 |
117 | # TernJS port file
118 | .tern-port
119 |
120 | # Stores VSCode versions used for testing VSCode extensions
121 | .vscode-test
122 |
123 | # yarn v2
124 | .yarn/cache
125 | .yarn/unplugged
126 | .yarn/build-state.yml
127 | .yarn/install-state.gz
128 | .pnp.*
129 |
130 | # End of https://www.toptal.com/developers/gitignore/api/node
131 |
--------------------------------------------------------------------------------
/docs/.prettierignore:
--------------------------------------------------------------------------------
1 | # VitePress build output & cache directory
2 | .vitepress/cache
3 | .vitepress/dist
4 | node_modules
5 | package.json
6 | package-lock.json
7 |
--------------------------------------------------------------------------------
/docs/.tool-versions:
--------------------------------------------------------------------------------
1 | nodejs 22.10.0
2 |
--------------------------------------------------------------------------------
/docs/.vitepress/config.ts:
--------------------------------------------------------------------------------
1 | import { defineConfig } from "vitepress";
2 | import * as navbars from "./navbars";
3 | import * as sidebars from "./sidebars";
4 |
5 | // https://vitepress.dev/reference/site-config
6 | export default defineConfig({
7 | title: "asdf",
8 | description: "Manage multiple runtime versions with a single CLI tool",
9 | lastUpdated: true,
10 | locales: {
11 | root: {
12 | label: "English",
13 | lang: "en-US",
14 | themeConfig: {
15 | nav: navbars.en,
16 | sidebar: sidebars.en,
17 | },
18 | },
19 | "ko-kr": {
20 | label: "한국어",
21 | lang: "ko-kr",
22 | themeConfig: {
23 | nav: navbars.ko_kr,
24 | sidebar: sidebars.ko_kr,
25 | },
26 | },
27 | "ja-jp": {
28 | label: "日本語",
29 | lang: "ja-jp",
30 | themeConfig: {
31 | nav: navbars.ja_jp,
32 | sidebar: sidebars.ja_jp,
33 | },
34 | },
35 | "pt-br": {
36 | label: "Brazilian Portuguese",
37 | lang: "pr-br",
38 | themeConfig: {
39 | nav: navbars.pt_br,
40 | sidebar: sidebars.pt_br,
41 | },
42 | },
43 | "zh-hans": {
44 | label: "简体中文",
45 | lang: "zh-hans",
46 | themeConfig: {
47 | nav: navbars.zh_hans,
48 | sidebar: sidebars.zh_hans,
49 | },
50 | },
51 | },
52 | themeConfig: {
53 | // https://vitepress.dev/reference/default-theme-config
54 | search: {
55 | provider: "local",
56 | },
57 | socialLinks: [
58 | { icon: "github", link: "https://github.com/asdf-vm/asdf" },
59 | // { icon: "twitter", link: "https://twitter.com/asdf_vm" },
60 | ],
61 | },
62 | });
63 |
--------------------------------------------------------------------------------
/docs/.vitepress/navbars.ts:
--------------------------------------------------------------------------------
1 | import path from "path";
2 | import fs from "fs";
3 | import process from "process";
4 |
5 | export const getVersion = () => {
6 | const versionFilepath = path.join(__dirname, "../../.release-please-manifest.json");
7 | try {
8 | const version = JSON.parse(fs.readFileSync(versionFilepath, "utf8"))['.'];
9 | console.log(`Found version ${version} from ${versionFilepath}`);
10 | return version;
11 | } catch (error) {
12 | console.error(`Failed to find version from file ${versionFilepath}`, error);
13 | process.exit(1);
14 | }
15 | };
16 |
17 | const en = [
18 | { text: "Guide", link: "/guide/getting-started" },
19 | {
20 | text: "Reference",
21 | link: "/manage/configuration",
22 | },
23 | {
24 | text: getVersion(),
25 | items: [
26 | {
27 | text: "Changelog",
28 | link: "https://github.com/asdf-vm/asdf/blob/master/CHANGELOG.md",
29 | },
30 | { text: "Contribute", link: "/contribute/core" },
31 | ],
32 | },
33 | ];
34 |
35 | const ja_jp = [
36 | { text: "ガイド", link: "/ja-jp/guide/getting-started" },
37 | {
38 | text: "リファレンス",
39 | link: "/ja-jp/manage/configuration",
40 | },
41 | {
42 | text: getVersion(),
43 | items: [
44 | {
45 | text: "変更履歴",
46 | link: "https://github.com/asdf-vm/asdf/blob/master/CHANGELOG.md",
47 | },
48 | { text: "コントリビューション", link: "/ja-jp/contribute/core" },
49 | ],
50 | },
51 | ];
52 |
53 | const ko_kr = [
54 | { text: "가이드", link: "/ko-kr/guide/getting-started" },
55 | {
56 | text: "참고자료",
57 | link: "/ko-kr/manage/configuration",
58 | },
59 | {
60 | text: getVersion(),
61 | items: [
62 | {
63 | text: "변동사항",
64 | link: "https://github.com/asdf-vm/asdf/blob/master/CHANGELOG.md",
65 | },
66 | { text: "기여하기", link: "/ko-kr/contribute/core" },
67 | ],
68 | },
69 | ];
70 |
71 | const pt_br = [
72 | { text: "Guia", link: "/pt-br/guide/getting-started" },
73 | {
74 | text: "Referência",
75 | link: "/pt-br/manage/configuration",
76 | },
77 | {
78 | text: getVersion(),
79 | items: [
80 | {
81 | text: "Changelog",
82 | link: "https://github.com/asdf-vm/asdf/blob/master/CHANGELOG.md",
83 | },
84 | { text: "Contribute", link: "/pt-br/contribute/core" },
85 | ],
86 | },
87 | ];
88 |
89 | const zh_hans = [
90 | { text: "指导", link: "/zh-hans/guide/getting-started" },
91 | {
92 | text: "参考",
93 | link: "/zh-hans/manage/configuration",
94 | },
95 | {
96 | text: getVersion(),
97 | items: [
98 | {
99 | text: "Changelog",
100 | link: "https://github.com/asdf-vm/asdf/blob/master/CHANGELOG.md",
101 | },
102 | { text: "如何贡献", link: "/zh-hans/contribute/core" },
103 | ],
104 | },
105 | ];
106 |
107 | export { en, ko_kr, ja_jp, pt_br, zh_hans };
108 |
--------------------------------------------------------------------------------
/docs/.vitepress/theme/custom.css:
--------------------------------------------------------------------------------
1 | :root {
2 | --vp-c-brand-1: #b744b8;
3 | --vp-c-brand-2: #a379c9;
4 | /* TODO: make brand-2 and brand-3 different & set brand-soft */
5 | --vp-c-brand-3: #a379c9;
6 | /* --vp-c-brand-soft: #fae3ff; */
7 | }
8 |
--------------------------------------------------------------------------------
/docs/.vitepress/theme/index.ts:
--------------------------------------------------------------------------------
1 | import DefaultTheme from "vitepress/theme";
2 | import "./custom.css";
3 |
4 | export default DefaultTheme;
5 |
--------------------------------------------------------------------------------
/docs/CNAME:
--------------------------------------------------------------------------------
1 | asdf-vm.com
--------------------------------------------------------------------------------
/docs/contribute/first-party-plugins.md:
--------------------------------------------------------------------------------
1 | # First-Party Plugins
2 |
3 | The asdf core team has authored some plugins relevant to their daily work life. Help is always welcome in maintaining and improving these plugins. See the associated repo for each linked below:
4 |
5 | - [Elixir](https://github.com/asdf-vm/asdf-elixir)
6 | - [Erlang](https://github.com/asdf-vm/asdf-erlang)
7 | - [Node.js](https://github.com/asdf-vm/asdf-nodejs)
8 | - [Ruby](https://github.com/asdf-vm/asdf-ruby)
9 |
10 | For community plugins, see:
11 |
12 | - [`asdf-community` organisation](https://github.com/asdf-community): A collaborative, community-driven project for long-term maintenance of `asdf` plugins.
13 | - [`asdf-plugins` shortname repo](https://github.com/asdf-vm/asdf-plugins): Short-name list used by `asdf` core to lookup popular `asdf` plugins.
14 | - [GitHub `asdf-plugin` topic search](https://github.com/topics/asdf-plugin)
15 |
--------------------------------------------------------------------------------
/docs/contribute/github-actions.md:
--------------------------------------------------------------------------------
1 | # GitHub Actions
2 |
3 | Thanks for your interest, please see the [asdf actions repo](https://github.com/asdf-vm/actions) for their existing Issues, conversations and Contributing Guidelines.
4 |
--------------------------------------------------------------------------------
/docs/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | # https://vitepress.dev/reference/default-theme-home-page
3 | layout: home
4 |
5 | hero:
6 | name: asdf
7 | text: The Multiple Runtime Version Manager
8 | tagline: Manage all your runtime versions with one tool!
9 | actions:
10 | - theme: brand
11 | text: Get Started
12 | link: /guide/getting-started
13 | - theme: alt
14 | text: What is asdf?
15 | link: /guide/introduction
16 | - theme: alt
17 | text: View on GitHub
18 | link: https://github.com/asdf-vm/asdf
19 |
20 | features:
21 | - title: One Tool
22 | details: "Manage each of your project runtimes with a single CLI tool and command interface."
23 | icon: 🎉
24 | - title: Plugins
25 | details: "Large ecosystem of existing runtimes & tools. Simple API to add support for new tools as you need!"
26 | icon: 🔌
27 | - title: Backwards Compatible
28 | details: "Support for existing config files .nvmrc, .node-version, .ruby-version for smooth migration!"
29 | icon: ⏮
30 | - title: "One Config File"
31 | details: ".tool-versions to manage all your tools, runtimes and their versions in a single, sharable place."
32 | icon: 📄
33 | - title: "Shells"
34 | details: "Supports Bash, ZSH, Fish & Elvish with completions available."
35 | icon: 🐚
36 | - title: "GitHub Actions"
37 | details: "Provides a GitHub Action to install and utilize your .tool-versions in your CI/CD workflows."
38 | icon: 🤖
39 |
40 | ---
41 |
--------------------------------------------------------------------------------
/docs/ja-jp/contribute/first-party-plugins.md:
--------------------------------------------------------------------------------
1 | # 公式プラグイン
2 |
3 | asdfコアチームでは、日々のワークライフに関連するプラグインをいくつか作成しています。これらのプラグインのメンテナンスおよび改善にご協力いただける方を、いつでも歓迎しています。詳しくは、下記リンクから、それぞれのリポジトリを参照してください:
4 |
5 | - [Elixir](https://github.com/asdf-vm/asdf-elixir)
6 | - [Erlang](https://github.com/asdf-vm/asdf-erlang)
7 | - [Node.js](https://github.com/asdf-vm/asdf-nodejs)
8 | - [Ruby](https://github.com/asdf-vm/asdf-ruby)
9 |
10 | コミュニティプラグインについては、下記をご覧ください:
11 |
12 | - [`asdf-community`オーガナイゼーション](https://github.com/asdf-community): `asdf`プラグインの長期的なメンテナンスを目的としたコミュニティ主導の共同プロジェクトです。
13 | - [`asdf-plugins`ショートネームリポジトリ](https://github.com/asdf-vm/asdf-plugins): ポピュラーな`asdf`プラグインを検索するために`asdf`コアが使用する、ショートネームのリストです。
14 | - [GitHub `asdf-plugin`トピック検索](https://github.com/topics/asdf-plugin)
15 |
--------------------------------------------------------------------------------
/docs/ja-jp/contribute/github-actions.md:
--------------------------------------------------------------------------------
1 | # GitHub Actions
2 |
3 | ご興味を持っていただきありがとうございます。既存のイシュー、議論、コントリビューションガイドについては、[asdf actions リポジトリ](https://github.com/asdf-vm/actions)をご覧ください。
4 |
--------------------------------------------------------------------------------
/docs/ja-jp/guide/introduction.md:
--------------------------------------------------------------------------------
1 | # イントロダクション
2 |
3 | `asdf`は、ツールのためのバージョンマネージャです。すべてのツールのバージョンは単一のファイル(`.tool-versions`)内で定義されるため、プロジェクトのGitリポジトリにチェックインして共有することで、チーム全員に同じーバージョンのツールを使ってもらえるようになります。
4 |
5 | 従来は、複数のCLIのバージョンマネージャを用意する必要があり、それぞれが異なるAPI、構成ファイル、および実装(`$PATH`の操作、Shim、環境変数など)となっていました。`asdf`は、開発ワークフローを簡素化するための単一インターフェースと構成ファイルを提供しており、シンプルなプラグインインターフェースを使って、すべてのツール・ランタイムに拡張することができます。
6 |
7 | ## どうやって動いているの
8 |
9 | シェル上で`asdf`コアがセットアップすると、特定のツールを管理するためのプラグインをインストールすることができるようになります。プラグインによってツールがインストールされると、インストールされる実行ファイルごとに[Shim]()が作成されます。これらの実行ファイルを実行しようとすると、代わりにShimが実行され、`.tool-versions`で定義されているバージョンを`asdf`が認識して、当該バージョンが実行されます。
10 |
11 | ## 関連プロジェクト
12 |
13 | ### nvm / n / rbenv etc
14 |
15 | [nvm](https://github.com/nvm-sh/nvm)、[n](https://github.com/tj/n)、および[rbenv](https://github.com/rbenv/rbenv)のようなツールはすべて、ツールによってインストールされる実行ファイルのShimを作成するシェルスクリプトです。
16 |
17 | `asdf`はこれらのツールと非常に似ていて、ツール/ランタイムのバージョン管理という分野では競合しています。`asdf`はプラグインシステムを採用し、他のツールと差別化することで、ツール/ランタイムごとのマネージャ、マネージャごとの異なるコマンド、そしてリポジトリ内の様々な`*-version`ファイルといったものを排除しています。
18 |
19 |
24 |
25 | ### direnv
26 |
27 | > シェルに、ディレクトリごとに環境変数をロード/アンロードできる機能を付け加えます。
28 |
29 | `asdf`は環境変数を管理することはしませんが、direnvの動作を`asdf`に統合する[`asdf-direnv`](https://github.com/asdf-community/asdf-direnv)プラグインが存在します。
30 |
31 | 詳しくは[direnvのドキュメント](https://direnv.net/)をご覧ください。
32 |
33 | ### Homebrew
34 |
35 | > macOS(またはLinux)のためのパッケージマネージャー
36 |
37 | Homebrewは、パッケージとその上位の依存関係を管理します。`asdf`は上位の依存関係を管理することはしませんし、パッケージマネージャでもありません。それらの管理はユーザが負担することとなりますが、`asdf`はなるべく依存関係のリストを小さく保つように努めています。
38 |
39 | 詳しくは[Homebrewのドキュメント](https://brew.sh/)をご覧ください。
40 |
41 | ### NixOS
42 |
43 | > Nixは、パッケージ管理とシステム構成に独自のアプローチを取り入れたツールです。
44 |
45 | NixOSは、各ツールの依存関係ツリー全体でパッケージのバージョンを正確に管理することで、真に再現可能な環境を構築することを目指しています。`asdf`でそのようなことはできません。NixOSは、独自のプログラミング言語、たくさんのCLIツール、そして60,000を超えるパッケージコレクションによって、それらの機能を支えています。
46 |
47 | 繰り返しになりますが、`asdf`は上位の依存関係を管理することはしませんし、パッケージマネージャでもありません。
48 |
49 | 詳しくは[NixOSのドキュメント](https://nixos.org/guides/how-nix-works.html)をご覧ください。
50 |
51 | ## なぜasdfを使うの?
52 |
53 | `asdf`は、プラグインシステムによって**多くの**ツールをサポートしており、シェル構成にたった1行の**シェル**スクリプトを記述するだけで使えるというシンプルさ・親しみやすさによって、チームが**確実に**同じバージョンのツールを使用することを保証できます。
54 |
55 | ::: tip Note
56 | `asdf`はシステムのパッケージマネージャになることを目指してはいません。あくまで、ツールのバージョンマネージャです。プラグインを作成することで、どのようなツールでも`asdf`で管理できるようになりますが、それがそのツールにとって最善の方法であるとは限りませんのでご注意ください。
57 | :::
58 |
--------------------------------------------------------------------------------
/docs/ja-jp/guide/parts/install-dependencies.md:
--------------------------------------------------------------------------------
1 | ##### 依存関係のインストール
2 |
3 | asdfの動作には`git`が必要です。以下の表は、 _あなたが使用している_ パッケージマネージャで実行するコマンドの _一部例_ です(いくつかのツールは、後の手順で自動的にインストールされます)。
4 |
5 | | OS | パッケージマネージャー | コマンド |
6 | | ----- | ------------------ | ----------------------------- |
7 | | linux | Aptitude | `apt install git` |
8 | | linux | DNF | `dnf install git` |
9 | | linux | Pacman | `pacman -S git` |
10 | | linux | Zypper | `zypper install git` |
11 | | macOS | Homebrew | `brew install coreutils git` |
12 | | macOS | Spack | `spack install coreutils git` |
13 |
14 | ::: tip 備考
15 |
16 | お使いのシステムの構成によっては、`sudo`が必要となる場合があります。
17 |
18 | :::
19 |
--------------------------------------------------------------------------------
/docs/ja-jp/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | # https://vitepress.dev/reference/default-theme-home-page
3 | layout: home
4 |
5 | hero:
6 | name: asdf
7 | text: マルチランタイム
バージョンマネージャ
8 | tagline: 1つのツールですべてのランタイムのバージョンを管理しましょう!
9 | actions:
10 | - theme: brand
11 | text: はじめよう
12 | link: /ja-jp/guide/getting-started
13 | - theme: alt
14 | text: asdfってなに?
15 | link: /ja-jp/guide/introduction
16 | - theme: alt
17 | text: GitHubをみる
18 | link: https://github.com/asdf-vm/asdf
19 |
20 | features:
21 | - title: 単一ツール
22 | details: "単体のCLIツールとコマンドインターフェースで、各プロジェクトのランタイムを管理できます。"
23 | icon: 🎉
24 | - title: プラグイン
25 | details: "既存ランタイム・ツールを使用した大規模なエコシステムです。必要に応じて新しいツールをサポートできるシンプルなAPIを用意しています!"
26 | icon: 🔌
27 | - title: 後方互換性
28 | details: ".nvmrc、.node-version、.ruby-versionといった既存構成ファイルから、スムーズに移行できます!"
29 | icon: ⏮
30 | - title: "単一の構成ファイル"
31 | details: ".tool-versionsを使用すると、すべてのツール、ランタイム、およびそれらのバージョンを、共有された単一の場所で管理できます。"
32 | icon: 📄
33 | - title: "シェル"
34 | details: "Bash、ZSH、Fish、およびElvishをサポートし、コマンド補完にも対応しています。"
35 | icon: 🐚
36 | - title: "GitHub Actions"
37 | details: "CI/CDワークフローで、.tool-versionsをインストールし利用するためのGitHub Actionを提供しています。"
38 | icon: 🤖
39 | ---
40 |
--------------------------------------------------------------------------------
/docs/ja-jp/manage/commands.md:
--------------------------------------------------------------------------------
1 | # すべてのコマンド
2 |
3 | `asdf`で利用可能なすべてのコマンドの一覧です。この一覧は、`asdf help`コマンドで表示されるテキストです。
4 |
5 | <<< @../../internal/help/help.txt
6 |
--------------------------------------------------------------------------------
/docs/ja-jp/manage/plugins.md:
--------------------------------------------------------------------------------
1 | # プラグイン
2 |
3 | プラグインは、`asdf`がNode.jsやRuby、Elixirなどの様々なツールを取り扱えるようにするためのものです。
4 |
5 | 様々なツールをサポートするために使用されるプラグインAPIについては、[プラグインの作成](/ja-jp/plugins/create.md)をご覧ください。
6 |
7 | ## 追加
8 |
9 | 下記コマンドでは、GitのURLからプラグインを追加します:
10 |
11 | ```shell
12 | asdf plugin add
13 | # asdf plugin add elm https://github.com/vic/asdf-elm
14 | ```
15 |
16 | または下記のコマンドで、プラグインリポジトリのショートネームを指定して追加します:
17 |
18 | ```shell
19 | asdf plugin add
20 | # asdf plugin add erlang
21 | ```
22 |
23 | ::: tip 推奨
24 |
25 | リポジトリのショートネームに依存しないために、`git-url`を使用することを推奨します。
26 |
27 | :::
28 |
29 | ## インストール済みプラグイン一覧
30 |
31 | ```shell
32 | asdf plugin list
33 | # asdf plugin list
34 | # java
35 | # nodejs
36 | ```
37 |
38 | ```shell
39 | asdf plugin list --urls
40 | # asdf plugin list
41 | # java https://github.com/halcyon/asdf-java.git
42 | # nodejs https://github.com/asdf-vm/asdf-nodejs.git
43 | ```
44 |
45 | ## 全プラグインのショートネーム一覧
46 |
47 | ```shell
48 | asdf plugin list all
49 | ```
50 |
51 | 全プラグインのショートネーム一覧については、[プラグインショートネームの一覧](https://github.com/asdf-vm/asdf-plugins)もご覧ください。
52 |
53 | ## 更新
54 |
55 | ```shell
56 | asdf plugin update --all
57 | ```
58 |
59 | 特定のプラグインパッケージを更新したい場合は、下記のように指定してください。
60 |
61 | ```shell
62 | asdf plugin update
63 | # asdf plugin update erlang
64 | ```
65 |
66 | この更新コマンドは、プラグインリポジトリの _origin_ の _デフォルトブランチ_ における _最新コミット_ を取得します。バージョニングされたプラグインの更新機能については、現在開発中です([#916](https://github.com/asdf-vm/asdf/pull/916))。
67 |
68 | ## 削除
69 |
70 | ```bash
71 | asdf plugin remove
72 | # asdf plugin remove erlang
73 | ```
74 |
75 | プラグインを削除すると、当該プラグインでインストールされたすべてのツールが削除されます。これは、各ツールの未使用バージョンを手っ取り早くクリーンアップ/プルーニングするのに有用です。
76 |
77 | ## ショートネームリポジトリの同期
78 |
79 | ショートネームリポジトリはローカルマシンに同期され、定期的に更新されます。同期のタイミングの条件は、次のとおりです:
80 |
81 | - 同期イベントは、下記コマンドによってトリガーされます:
82 | - `asdf plugin add `
83 | - `asdf plugin list all`
84 | - 構成設定の`disable_plugin_short_name_repository`オプションが`yes`の場合、同期は中止されます。詳しくは[asdfの構成設定](/ja-jp/manage/configuration.md)のリファレンスをご覧ください。
85 | - もし、過去`X`分の間に同期が行われていない場合、同期が開始されます。
86 | - `X`のデフォルト値は`60`ですが、`.asdfrc`ファイルの`plugin_repository_last_check_duration`オプションで変更することができます。詳しくは[asdfの構成設定](/ja-jp/manage/configuration.md)のリファレンスをご覧ください。
87 |
--------------------------------------------------------------------------------
/docs/ja-jp/more/community-projects.md:
--------------------------------------------------------------------------------
1 | # コミュニティプロジェクト
2 |
3 | `asdf`に関連するコミュニティプロジェクトをいくつか紹介します:
4 |
5 | - [asdf-community](https://github.com/asdf-community): asdfプラグインの長期的なメンテナンスを目的とした
6 | コミュニティ主導の共同プロジェクトです。
7 | - [asdf dev container](https://github.com/iloveitaly/asdf-devcontainer): GitHub Codespacesでasdfによるツール管理をサポートする、
8 | [GitHub Dev Container](https://docs.github.com/en/codespaces/setting-up-your-project-for-codespaces/introduction-to-dev-containers)
9 | です。
10 |
11 | ::: warning 備考
12 |
13 | asdfコアチームは、これらのプロジェクトやコードを所有していません。
14 | asdfコアでは、ここに掲載されているものに関連する品質やセキュリティについては責任を負いません。
15 |
16 | :::
17 |
--------------------------------------------------------------------------------
/docs/ja-jp/more/faq.md:
--------------------------------------------------------------------------------
1 | # FAQ
2 |
3 | ここでは、`asdf`に関するよくある質問を紹介します。
4 |
5 | ## WSL1をサポートしていますか?
6 |
7 | WSL1 ([Windows Subsystem for Linux](https://ja.wikipedia.org/wiki/Windows_Subsystem_for_Linux) 1)は公式にはサポートしていません。`asdf`は正常に動作しない可能性があります。WSL1を公式にサポートする予定はありません。
8 |
9 | ## WSL2をサポートしていますか?
10 |
11 | WSL2 ([Windows Subsystem for Linux](https://ja.wikipedia.org/wiki/Windows_Subsystem_for_Linux#WSL2) 2)では、あなたが選択したWSLディストリビューションに基づいて、セットアップと依存関係の解決を済ませれば、動作するはずです。
12 |
13 | 重要なのは、WSL2が正常に動作するのは、カレントワークディレクトリがWindowsドライブではなくUnixドライブである場合に _限られる_ ということです。
14 |
15 | GitHub Actionsでホストランナーのサポートが可能になれば、WSL2でテストスイートを実行する予定ですが、現時点ではそうではないようです。
16 |
17 | ## 新しくインストールした実行ファイルが実行できないのですが?
18 |
19 | > `npm install -g yarn`を実行したにも関わらず、`yarn`が実行できません。どうなっているの?
20 |
21 | `asdf`は[Shim]()を使って実行ファイルを管理しています。プラグインによってインストールされるものは、自動的にShimが作成されますが、`asdf`が管理しているツールによって実行ファイルがインストールされた場合は、Shimを作成しなければならないということを`asdf`に通知する必要があります。上記の例では、[Yarn](https://yarnpkg.com/)のShimを作成しなければいけません。詳しくは、[`asdf reshim`コマンドのドキュメント](/ja-jp/manage/core.md#shimの再作成)をご覧ください。
22 |
23 | ## シェルが、新しくインストールされたShimを検知してくれないのですが?
24 |
25 | `asdf reshim`コマンドを実行しても問題が解決しない場合、`asdf.sh`や`asdf.fish`のsourceが、シェルの構成ファイル(`.bash_profile`、`.zshrc`、`config.fish`など)の**一番下**にないことが原因である可能性があります。`$PATH`を設定した**後**、そしてフレームワーク(oh-my-zshなど)を使用しているのれあればそれをsourceした**後**に、sourceする必要があります。
26 |
--------------------------------------------------------------------------------
/docs/ja-jp/more/thanks.md:
--------------------------------------------------------------------------------
1 | # 謝辞
2 |
3 | このページを借りて、asdfのオーサーおよびコントリビューターの皆様に感謝を申し上げます!
4 |
5 | ## クレジット
6 |
7 | 私 ([@HashNuke](https://github.com/HashNuke))、高熱、風邪、咳。
8 |
9 | コピーライト 2014年から今まで ([MIT License](https://github.com/asdf-vm/asdf/blob/master/LICENSE))
10 |
11 | ## メンテナー
12 |
13 | - [@HashNuke](https://github.com/HashNuke)
14 | - [@danhper](https://github.com/danhper)
15 | - [@Stratus3D](https://github.com/Stratus3D)
16 | - [@vic](https://github.com/vic)
17 | - [@jthegedus](https://github.com/jthegedus)
18 |
19 | ## コントリビューター
20 |
21 | GitHubの[コントリビューターリスト](https://github.com/asdf-vm/asdf/graphs/contributors):pray:をご覧ください。
22 |
--------------------------------------------------------------------------------
/docs/ko-kr/contribute/documentation.md:
--------------------------------------------------------------------------------
1 | # 문서 & 사이트
2 |
3 | 문서 & 사이트 기여 가이드.
4 |
5 | ## 초기 세팅
6 |
7 | Github의 `asdf` fork 그리고/혹은 기본 브랜치 Git clone:
8 |
9 | ```shell
10 | # clone your fork
11 | git clone https://github.com//asdf.git
12 | # or clone asdf
13 | git clone https://github.com/asdf-vm/asdf.git
14 | ```
15 |
16 | 문서 사이트 개발을 위한 도구들은 `asdf`의 `docs/.tool-versions`에서 관리되고 있습니다. 플러그인들을 추가하기:
17 |
18 | ```shell
19 | asdf plugin add nodejs https://github.com/asdf-vm/asdf-nodejs
20 | ```
21 |
22 | 툴 버전들을 설치하기:
23 |
24 | ```shell
25 | asdf install
26 | ```
27 |
28 | - [Node.js](https://nodejs.org): Chrome의 V8 JavaScript 엔진을 기반으로 구축된 JavaScript 런타임.
29 |
30 | `docs/package.json`로부터 Node.js dependencies 설치하기:
31 |
32 | ```shell
33 | npm install
34 | ```
35 |
36 | ## 개발
37 |
38 | [VitePress (v2)](https://vitepress.dev/)는 우리가 asdf 문서 사이트를 빌드하기 위해 사용하는 정적 사이트 생성기(SSG)입니다. 이는 사용자가 JavaScript를 사용중이지 않을때도 HTML 폴백을 지원하고, [Docsify.js](https://docsify.js.org/)와 결과적으로 VuePress를 대체하기 위해 선택되었습니다. 이는 VuePress로부터 대체된 Docsify & VitePress가 아니면 불가능했을 것입니다. 이것을 제외하면, 최소한의 설정과 함께 마크다운 작성에 집중하는 feature-set은 대부분 비슷합니다.
39 |
40 | `package.json`은 개발에 필요한 스크립트들을 포함합니다:
41 |
42 | @[code json{3-5}](../../package.json)
43 |
44 | 로컬 개발 서버 시작하기:
45 |
46 | ```shell
47 | npm run dev
48 | ```
49 |
50 | 커밋 전 코드 형식 맞추기:
51 |
52 | ```shell
53 | npm run format
54 | ```
55 |
56 | ## 풀 리퀘스트, 릴리스 & 관습적 커밋
57 |
58 | `asdf`는 PR 제목들의 관습적인 커밋들에 의존하는 자동화된 배포 pipeline을 사용하고 있습니다. 더 자세한 문서는 [코어 기여 가이드](./core.md)에서 찾을 수 있습니다.
59 |
60 | 문서 업데이트를 위한 PR을 만드실때는, PR `docs: ` 형식인 관습적인 커밋 타입 `docs` 제목을 만들어주세요.
61 |
62 | ## Vitepress
63 |
64 | 사이트의 설정은 설정을 대표하는 JS 오브젝트의 TypeScript 파일들로 구성되어 있습니다. 그 파일들은 다음과 같습니다:
65 |
66 | - `docs/.vitepress/config.js`: 사이트를 위한 root 설정 파일. [VitePress 문서](https://vitepress.dev/reference/site-config) 참조.
67 |
68 | root 설정 단순화를 위해, _navbar_ 와 _sidebar_ 를 대표하는 더 큰 JS 객체가 추출되었고 로케일로 구분되었습니다. 다음을 참조하세요:
69 |
70 | - `docs/.vitepress/navbars.js`
71 | - `docs/.vitepress/sidebars.js`
72 |
73 | [기본 테마 참고자료](https://vitepress.dev/reference/default-theme-config)에서 위 설정들의 공식 문서를 보실 수 있습니다.
74 |
75 | ## I18n
76 |
77 | VitePress는 국제화를 공식적으로 지원합니다.
78 | root 설정 `docs/.vitepress/config.js`는 선택 dropdown에서의 지원되는 로케일들의 URL, 제목과 navbar/sidebar의 설정 레퍼런스들을 정의합니다.
79 |
80 | navbar/sidebar 설정들은 앞서 언급한 로케일 별로 나누어지고 내보내기된 설정파일들에 의해 결정됩니다.
81 |
82 | 각 로케일을 위한 Markdown 내용은 반드시 root 설정안에 `locales`의 키들과 같은 이름의 폴더에 위치해야합니다. 다시 말해서:
83 |
84 | ```js
85 | // docs/.vitepress/config.js
86 | export default defineConfig({
87 | ...
88 | locales: {
89 | root: {
90 | label: "English",
91 | lang: "en-US",
92 | themeConfig: {
93 | nav: navbars.en,
94 | sidebar: sidebars.en,
95 | },
96 | },
97 | "pt-br": {
98 | label: "Brazilian Portuguese",
99 | lang: "pr-br",
100 | themeConfig: {
101 | nav: navbars.pt_br,
102 | sidebar: sidebars.pt_br,
103 | },
104 | },
105 | "zh-hans": {
106 | label: "简体中文",
107 | lang: "zh-hans",
108 | themeConfig: {
109 | nav: navbars.zh_hans,
110 | sidebar: sidebars.zh_hans,
111 | },
112 | },
113 | },
114 | })
115 | ```
116 |
117 | `/pt-BR/`는 `docs/pt-BR/`에 위치한 Markdown 파일들의 세트가 똑같이 필요합니다, 예를 들어:
118 |
119 | ```shell
120 | docs
121 | ├─ README.md
122 | ├─ foo.md
123 | ├─ nested
124 | │ └─ README.md
125 | └─ pt-BR
126 | ├─ README.md
127 | ├─ foo.md
128 | └─ nested
129 | └─ README.md
130 | ```
131 |
132 | 더 자세한 정보는 [공식 VitePress i18n 문서](https://vitepress.dev/guide/i18n)에서 확인 가능합니다.
133 |
--------------------------------------------------------------------------------
/docs/ko-kr/contribute/first-party-plugins.md:
--------------------------------------------------------------------------------
1 | # 공식 플러그인
2 |
3 | asdf 코어 팀은 일상 업무 환경에서 사용되는 플러그인들을 작성해왔습니다. 이 플러그인들을 관리하고 발전시키는 도움은 언제든 환영입니다. 아래 각 링크들에서 관련된 리포지토리들을 확인하세요:
4 |
5 | - [Elixir](https://github.com/asdf-vm/asdf-elixir)
6 | - [Erlang](https://github.com/asdf-vm/asdf-erlang)
7 | - [Node.js](https://github.com/asdf-vm/asdf-nodejs)
8 | - [Ruby](https://github.com/asdf-vm/asdf-ruby)
9 |
10 | 커뮤니티 플러그인 보기:
11 |
12 | - [`asdf-community` 공동체](https://github.com/asdf-community): `asdf` 플러그인의 장기 유지보수를 위한 공동체 주도의 프로젝트입니다.
13 | - [`asdf-plugins` shortname 리포지토리](https://github.com/asdf-vm/asdf-plugins): 인기 있는 `asdf` 플러그인 검색을 위해 `asdf` 코어가 사용하는 Short-name 목록.
14 | - [Github `asdf-plugin` 토픽 검색](https://github.com/topics/asdf-plugin)
15 |
--------------------------------------------------------------------------------
/docs/ko-kr/contribute/github-actions.md:
--------------------------------------------------------------------------------
1 | # GitHub Actions
2 |
3 | 당신의 관심에 감사드리며, 존재하는 이슈들, 대화들, 그리고 기여 가이드라인을 [asdf actions 리포지토리](https://github.com/asdf-vm/actions)에서 확인 해주세요.
4 |
--------------------------------------------------------------------------------
/docs/ko-kr/guide/introduction.md:
--------------------------------------------------------------------------------
1 | # 소개
2 |
3 | `asdf`는 툴 버전 매니저입니다. 모든 툴 버전 정의들은 당신의 팀들과 공유되는 프로젝트의 Git 리포지토리에서 확인할 수 있는 하나의 (`.tool-versions`) 파일에 있으며, 모든 사람들이 **정확히** 같은 버전의 툴들을 사용하게 합니다.
4 |
5 | 기존의 작업 방식은 여러 CLI 버전 매니저들, 각각의 고유한 API, 설정 파일들 그리고 구현이 필요했었습니다 (e.g. `$PATH` 조정, shims, 환경 변수 등...). `asdf`는 개발 워크플로우 단순화를 위해 단 하나의 인터페이스와 설정파일을 제공하고 단순한 플러그인 인터페이스를 통해 모든 툴과 런타임들 확장가능합니다.
6 |
7 | ## 작동방식
8 |
9 | `asdf` 코어가 셸 설정과 함께 설치되면, 플러그인들이 특정 툴들을 관리하기 위해 설치됩니다. 플러그인에 의해 한가지 툴이 설치되면, [shims]()들을 가진 실행파일들이 각각의 툴들을 위해 생성됩니다. 실행파일들을 실행하려 할 때, `.tool-versions`에 설정된 툴의 버전을 통해 `asdf`가 어떤 버전을 실행시킬 지 결정하고 해당 shim이 대신 실행됩니다.
10 |
11 | ## 관련된 프로젝트
12 |
13 | ### nvm / n / rbenv 등
14 |
15 | [nvm](https://github.com/nvm-sh/nvm), [n](https://github.com/tj/n) 그리고 [rbenv](https://github.com/rbenv/rbenv)과 같은 툴들은 설치된 실행파일을 위한 shim들을 만드는 셸 스크립트들로 작성되어 있습니다.
16 |
17 | `asdf`는 매우 비슷하고 툴/런타임 버전 관리의 영역에서 경쟁하기 위해 만들어졌습니다. `asdf`의 차별화 요소는 플러그인 시스템이 툴/런타임 별 매니저의 필요성, 각기 다른 명령어들, 그리고 리포지토리에 각각 `*-version` 파일들을 제거하였다는 것입니다.
18 |
19 |
24 |
25 | ### direnv
26 |
27 | > 현재 디렉토리에 따라 환경 변수들을 load와 unload 할 수 있는 새로운 기능을 기존의 셸에 추가합니다.
28 |
29 | `asdf`는 환경 변수들을 관리하지 않습니다만, [`asdf-direnv`](https://github.com/asdf-community/asdf-direnv) 플러그인을 통해 direnv 동작를 `asdf`에 통합할 수 있습니다.
30 |
31 | [direnv 문서](https://direnv.net/)에서 더보기.
32 |
33 | ### Homebrew
34 |
35 | > macOS (혹은 Linux)에서의 패키지 매니저 부재
36 |
37 | Homebrew는 패키지들과 upstream dependencies들을 관리합니다. `asdf`는 upstream dependencies들을 관리하지 않고, 패키지 매니저가 아니고, 우리가 dependency 목록들을 작게 유지하므로, 사용자가 직접 관리해야합니다.
38 |
39 | [Homebrew 문서](https://brew.sh/)에서 더보기.
40 |
41 | ### NixOS
42 |
43 | > Nix는 패키지 관리와 시스템 설정에 창의적으로 접근하는 툴입니다.
44 |
45 | NixOS는, `asdf`가 제공하지 않는, 각 툴의 전체 dependency tree를 통해 패키지들의 정확한 버전들을 관리함으로써 재현가능한 환경 구축을 목표로 합니다. NixOS는 자신만의 프로그래밍 언어, 많은 CLI 툴들, 그리고 6000개가 넘는 패키지 컬렉션을 통해 해당 기능을 제공합니다.
46 |
47 | 다시 한번 말씀드리지만, `asdf`는 upstream dependencies들을 관리하지 않으며 패키지 매니저가 아닙니다.
48 |
49 | [NixOS 문서](https://nixos.org/guides/how-nix-works.html)에서 더보기.
50 |
51 | ## 왜 asdf를 사용할까요?
52 |
53 | `asdf`는 팀들이 플러그인 시스템을 통해 **다양한** 툴들의 지원 그리고 셸 설정에 포함시킬 하나의 **셸** 스크립트의 _단순함_ 과 _친숙성_ 을 통해 **정확히** 같은 버전의 툴들을 사용하는 것을 보장합니다.
54 |
55 | ::: tip 노트
56 | `asdf`는 시스템 패키지 매니저가 아닙니다. 이것은 툴 버전 매니저입니다. 단지 어떠한 툴을 위한 플러그인을 생성하고 그것의 버전을 `asdf`로 관리할 수 있다고 해서, 그 특정한 툴을 버전 관리를 위한 최선의 방법을 의미하는 것은 아닙니다.
57 | :::
58 |
--------------------------------------------------------------------------------
/docs/ko-kr/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | # https://vitepress.dev/reference/default-theme-home-page
3 | layout: home
4 |
5 | hero:
6 | name: asdf
7 | text: 다중 런타임 버전 매니저
8 | tagline: 한가지 툴로 모든 런타임 버전들을 관리하세요!
9 | actions:
10 | - theme: brand
11 | text: 시작하기
12 | link: /ko-kr/guide/getting-started
13 | - theme: alt
14 | text: asdf이란?
15 | link: /ko-kr/guide/introduction
16 | - theme: alt
17 | text: GitHub에서 보기
18 | link: https://github.com/asdf-vm/asdf
19 |
20 | features:
21 | - title: "단 한가지 도구"
22 | details: "각 프로젝트 런타임들을 단 한가지 CLI 툴과 커맨드 인터페이스로 관리."
23 | icon: 🎉
24 | - title: "플러그인"
25 | details: "런타임과 툴들의 거대한 생태계. 당신이 필요한 새로운 툴들을 더해주는 간단한 API!"
26 | icon: 🔌
27 | - title: "구버전 호환"
28 | details: "원활한 마이그레이션을 위해 이미 존재하던 .nvmrc, .node-version, .ruby-version 등의 설정 파일들 지원!"
29 | icon: ⏮
30 | - title: "단 하나의 설정 파일"
31 | details: "단 하나의 공유된 .tool-versions 파일로 모든 툴, 런타임, 그리고 버전들을 관리."
32 | icon: 📄
33 | - title: "셸"
34 | details: "Bash, ZSH, Fish & Elvish 자동완성 기능 지원."
35 | icon: 🐚
36 | - title: "GitHub Actions"
37 | details: "GitHub Action 설치 제공과 .tool-versions 파일을 CI/CD 워크플로우에서 활용."
38 | icon: 🤖
39 |
40 | ---
41 |
--------------------------------------------------------------------------------
/docs/ko-kr/manage/commands.md:
--------------------------------------------------------------------------------
1 | # 모든 명령어
2 |
3 | 다음 목록은 `asdf`에서 이용가능한 모든 명령어들입니다. 해당 목록은 `asdf help` 명령어를 통해 확인가능합니다.
4 |
5 | <<< @../../internal/help/help.txt
6 |
--------------------------------------------------------------------------------
/docs/ko-kr/manage/plugins.md:
--------------------------------------------------------------------------------
1 | # 플러그인
2 |
3 | 플로그인들은 `asdf`가 Node.js, Ruby, Elixir 등 여러가지 툴들을 취급하는 방법입니다.
4 |
5 | 더 많은 툴들 지원을 위한 플러그인 API는 [플러그인 생성하기](/ko-kr/plugins/create.md) 참고하세요.
6 |
7 | ## 추가하기
8 |
9 | Git URL로 플러그인 추가하기:
10 |
11 | ```shell
12 | asdf plugin add
13 | # asdf plugin add elm https://github.com/vic/asdf-elm
14 | ```
15 |
16 | 또는 플러그인 리포지토리에 short-name을 통해 추가하기:
17 |
18 | ```shell
19 | asdf plugin add
20 | # asdf plugin add erlang
21 | ```
22 |
23 | ::: tip 추천
24 |
25 | short-name 리포지토리에 독립적인 긴 `git-url` 방식이 선호됩니다.
26 |
27 | :::
28 |
29 | ## 설치된 목록
30 |
31 | ```shell
32 | asdf plugin list
33 | # asdf plugin list
34 | # java
35 | # nodejs
36 | ```
37 |
38 | ```shell
39 | asdf plugin list --urls
40 | # asdf plugin list
41 | # java https://github.com/halcyon/asdf-java.git
42 | # nodejs https://github.com/asdf-vm/asdf-nodejs.git
43 | ```
44 |
45 | ## 모든 Short-name 리포지토리 목록
46 |
47 | ```shell
48 | asdf plugin list all
49 | ```
50 |
51 | 플러그인들의 전체 short-name 목록을 [플러그인 Shortname 인덱스](https://github.com/asdf-vm/asdf-plugins)에서 확인하세요.
52 |
53 | ## 업데이트
54 |
55 | ```shell
56 | asdf plugin update --all
57 | ```
58 |
59 | 특정 패키지를 업데이트하고 싶다면, 다음 명령어를 사용하세요.
60 |
61 | ```shell
62 | asdf plugin update
63 | # asdf plugin update erlang
64 | ```
65 |
66 | 이 명령어는 해당 플러그인 리포지토리의 _origin_ _기본 브랜치_ 의 _가장 최근 커밋_ 을 fetch합니다. 버전화된 플러그인들과 업데이트들은 현재 개발 진행중 입니다 ([#916](https://github.com/asdf-vm/asdf/pull/916)).
67 |
68 | ## 제거
69 |
70 | ```bash
71 | asdf plugin remove
72 | # asdf plugin remove erlang
73 | ```
74 |
75 | 플러그인 제거는 해당 툴과 관련된 모든 것을 제거합니다. 이것은 한 툴의 미사용중인 많은 버전들의 cleaning/pruning에 유용합니다.
76 |
77 | ## asdf Short-name 리포지토리 동기화
78 |
79 | Short-name 리포지토리는 로컬 머신에 주기적으로 동기화됩니다. 동기화 방식들로 다음 방식들이 있습니다:
80 |
81 | - 명령어들에 의한 동기화 이벤트:
82 | - `asdf plugin add `
83 | - `asdf plugin list all`
84 | - 만약 `disable_plugin_short_name_repository` 설정 옵션이 `yes`로 설정되어 있다면, 동기화는 조기 종료됩니다. [asdf 설정 문서](/ko-kr/manage/configuration.md)에서 더보기.
85 | - 만약 동기화가 지난 `X`분 동안 진행되지 않았다면, 동기화가 진행됩니다.
86 | - `X`의 기본값은 `60`입니다만, `.asdfrc`의 `plugin_repository_last_check_duration` 옵션을 통해 설정될 수 있습니다. [asdf 설정 문서](/ko-kr/manage/configuration.md)에서 더보기.
87 |
--------------------------------------------------------------------------------
/docs/ko-kr/more/community-projects.md:
--------------------------------------------------------------------------------
1 | # 커뮤니티 프로젝트
2 |
3 | `asdf`와 관련된 커뮤니티 프로젝트들입니다:
4 |
5 | - [asdf-community](https://github.com/asdf-community):
6 | asdf 플로그인들의 장기 관리를 위한 커뮤니티 주도의 프로젝트입니다.
7 | - [asdf dev container](https://github.com/iloveitaly/asdf-devcontainer):
8 | GitHub 코드스페이스에서 asdf가 관리하는 툴들을 지원하는
9 | [GitHub 개발 컨테이너](https://docs.github.com/en/codespaces/setting-up-your-project-for-codespaces/introduction-to-dev-containers)
10 |
11 | ::: warning 노트
12 |
13 | asdf 코어 팀은 이 프로젝트들 혹은 코드를 소유하지 않습니다.
14 | asdf 코어는 위의 목록들에 품질과 보안을 책임지지 않습니다.
15 |
16 | :::
17 |
--------------------------------------------------------------------------------
/docs/ko-kr/more/faq.md:
--------------------------------------------------------------------------------
1 | # 자주 묻는 질문
2 |
3 | `asdf`에 관련된 공통된 질문들입니다.
4 |
5 | ## WSL1을 지원하나요?
6 |
7 | WSL1 ([Windows Subsystem for Linux](https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux) 1)는 공식적으로 지원되지 않습니다. 어떤 부분의 `asdf`의 제대로 동작하지 않을 수 있습니다. 우리는 WSL1의 공식 지원을 추가할 계획이 없습니다.
8 |
9 | ## WSL2을 지원하나요?
10 |
11 | WSL2 ([Windows Subsystem for Linux](https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux#WSL_2) 2)는 당신이 선택한 WSL distro를 위한 설치 & dependency 설명서를 따르면 작동합니다.
12 |
13 | 중요한 것은, WSL2는 _오직_ 현재 작업 디렉토리가 Unix 드라이브 그리고 Windows 드라이브에 종속되어 있지 않을때 정상적으로 동작합니다.
14 |
15 | 우리는 호스트 runner support가 GitHub Actions에서 사용가능할 때 WSL2에서 테스트 suite를 진행할 계획입니다만, 현재는 아직 이용가능하지 않은 것 같습니다.
16 |
17 | ## 새롭게 설치된 실행파일이 동작하지 않나요?
18 |
19 | > 방금 `npm install -g yarn`, 그러나 `yarn`을 실행시킬 수 없습니다. 어떻게 해야하나요?
20 |
21 | `asdf`는 [shims]()를 사용하여 실행파일들을 관리합니다. 플러그인에 의해서 설치되는 실행파일들은 자동적으로 shim이 생성되지만, `asdf`가 관리하고 있는 툴에 의해서 실행파일이 설치 된 경우는 shim을 생성해야 한다고 하는 것을 `asdf`에 알려줄 필요가 있습니다. 이러한 경우, [Yarn](https://yarnpkg.com/)의 shim을 생성하기 위해 [`asdf reshim` 명령어 문서](/ko-kr/manage/core.md#Shim-재생성)를 참고하세요.
22 |
23 | ## 셸이 새롭게 설치된 shims들을 감지하지 못하나요?
24 |
25 | 만약 `asdf reshim`가 문제를 해결하지 못한다면, 대부분의 경우 `asdf.sh` 혹은 `asdf.fish` sourcing이 당신의 셸 설정 파일 (`.bash_profile`, `.zshrc`, `config.fish` etc) **아래쪽에** 있지 _않을_ 가능성이 높습니다. 당신의 `$PATH`가 설정 된 **후에** 그리고 사용중인 프레임워크 (oh-my-zsh etc)가 source 된 **후에** source 되어야 합니다.
26 |
--------------------------------------------------------------------------------
/docs/ko-kr/more/thanks.md:
--------------------------------------------------------------------------------
1 | # 감사인사
2 |
3 | asdf 저자들 & 기여자들을 위한 감사 페이지!
4 |
5 | ## Credits
6 |
7 | 나 ([@HashNuke](https://github.com/HashNuke)), 고열, 감기, 기침.
8 |
9 | 2014년부터 종료까지의 저작권 ([MIT License](https://github.com/asdf-vm/asdf/blob/master/LICENSE))
10 |
11 | ## 관리자
12 |
13 | - [@HashNuke](https://github.com/HashNuke)
14 | - [@danhper](https://github.com/danhper)
15 | - [@Stratus3D](https://github.com/Stratus3D)
16 | - [@vic](https://github.com/vic)
17 | - [@jthegedus](https://github.com/jthegedus)
18 |
19 | ## 기여자
20 |
21 | GitHub에서 [기여자들의 목록](https://github.com/asdf-vm/asdf/graphs/contributors)를 확인하세요 :pray:
22 |
--------------------------------------------------------------------------------
/docs/manage/commands.md:
--------------------------------------------------------------------------------
1 | # All Commands
2 |
3 | The list of all commands available in `asdf`. This list is the `asdf help` command text.
4 |
5 | <<< @../../internal/help/help.txt
6 |
--------------------------------------------------------------------------------
/docs/manage/plugins.md:
--------------------------------------------------------------------------------
1 | # Plugins
2 |
3 | Plugins are how `asdf` knows to handle different tools like Node.js, Ruby, Elixir etc.
4 |
5 | See [Creating Plugins](/plugins/create.md) for the plugin API used to support more tools.
6 |
7 | ## Add
8 |
9 | Add plugins via their Git URL:
10 |
11 | ```shell
12 | asdf plugin add
13 | # asdf plugin add elm https://github.com/vic/asdf-elm
14 | ```
15 |
16 | or via the short-name association in the plugins repository:
17 |
18 | ```shell
19 | asdf plugin add
20 | # asdf plugin add erlang
21 | ```
22 |
23 | ::: tip Recommendation
24 |
25 | Prefer the longer `git-url` method as it is independent of the short-name repo.
26 |
27 | :::
28 |
29 | ## List Installed
30 |
31 | ```shell
32 | asdf plugin list
33 | # asdf plugin list
34 | # java
35 | # nodejs
36 | ```
37 |
38 | ```shell
39 | asdf plugin list --urls
40 | # asdf plugin list
41 | # java https://github.com/halcyon/asdf-java.git
42 | # nodejs https://github.com/asdf-vm/asdf-nodejs.git
43 | ```
44 |
45 | ## List All in Short-name Repository
46 |
47 | ```shell
48 | asdf plugin list all
49 | ```
50 |
51 | See [Plugins Shortname Index](https://github.com/asdf-vm/asdf-plugins) for the entire short-name list of plugins.
52 |
53 | ## Update
54 |
55 | ```shell
56 | asdf plugin update --all
57 | ```
58 |
59 | If you want to update a specific package, just say so.
60 |
61 | ```shell
62 | asdf plugin update
63 | # asdf plugin update erlang
64 | ```
65 |
66 | This update will fetch the _latest commit_ on the _default branch_ of the _origin_ of the plugin repository. Versioned plugins and updates are currently being developed ([#916](https://github.com/asdf-vm/asdf/pull/916))
67 |
68 | ## Remove
69 |
70 | ```bash
71 | asdf plugin remove
72 | # asdf plugin remove erlang
73 | ```
74 |
75 | Removing a plugin will remove all installations of the tool made with the plugin. This can be used as a shorthand for cleaning/pruning many unused versions of a tool.
76 |
77 | ## Syncing the asdf Short-name Repository
78 |
79 | The short-name repo is synced to your local machine and periodically refreshed. This method to determine a sync is as follows:
80 |
81 | - sync events are triggered by commands:
82 | - `asdf plugin add `
83 | - `asdf plugin list all`
84 | - if configuration option `disable_plugin_short_name_repository` is set to `yes`, then sync is aborted early. See the [asdf config docs](/manage/configuration.md) for more.
85 | - if there has not been a synchronization in the last `X` minutes then the sync will occur.
86 | - `X` defaults to `60`, but can be configured in your `.asdfrc` via the `plugin_repository_last_check_duration` option. See the [asdf config docs](/manage/configuration.md) for more.
87 |
--------------------------------------------------------------------------------
/docs/more/community-projects.md:
--------------------------------------------------------------------------------
1 | # Community Projects
2 |
3 | Here are some community projects related to `asdf`:
4 |
5 | - [asdf-community](https://github.com/asdf-community): A collaborative,
6 | community-driven project for long-term maintenance of asdf plugins.
7 | - [asdf dev container](https://github.com/iloveitaly/asdf-devcontainer): A
8 | [GitHub Dev Container](https://docs.github.com/en/codespaces/setting-up-your-project-for-codespaces/introduction-to-dev-containers)
9 | supporting asdf managed tools in GitHub Codespaces.
10 |
11 | ::: warning Note
12 |
13 | asdf core team do not own these projects or their code. asdf core are not responsible
14 | for the quality or security as they relate to those listed here.
15 |
16 | :::
17 |
--------------------------------------------------------------------------------
/docs/more/thanks.md:
--------------------------------------------------------------------------------
1 | # Thanks
2 |
3 | Thank you page to the asdf authors & contributors!
4 |
5 | ## Credits
6 |
7 | Me ([@HashNuke](https://github.com/HashNuke)), High-fever, cold, cough.
8 |
9 | Copyright 2014 to the end of time ([MIT License](https://github.com/asdf-vm/asdf/blob/master/LICENSE))
10 |
11 | ## Maintainers
12 |
13 | - [@HashNuke](https://github.com/HashNuke)
14 | - [@danhper](https://github.com/danhper)
15 | - [@Stratus3D](https://github.com/Stratus3D)
16 | - [@vic](https://github.com/vic)
17 | - [@jthegedus](https://github.com/jthegedus)
18 |
19 | ## Contributors
20 |
21 | See the [list of contributors](https://github.com/asdf-vm/asdf/graphs/contributors) :pray: on GitHub
22 |
--------------------------------------------------------------------------------
/docs/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "module",
3 | "scripts": {
4 | "fmt": "prettier --write '.vitepress/{config,navbars,sidebars}.ts' '.vitepress/theme/**/*'",
5 | "dev": "vitepress dev",
6 | "build": "vitepress build",
7 | "preview": "vitepress preview"
8 | },
9 | "devDependencies": {
10 | "@types/node": "^22.15.29",
11 | "prettier": "^3.5.3",
12 | "vitepress": "^1.6.3"
13 | }
14 | }
--------------------------------------------------------------------------------
/docs/parts/install-dependencies.md:
--------------------------------------------------------------------------------
1 | ##### Install Dependencies
2 |
3 | asdf primarily requires `git`. Here is a _non-exhaustive_ list of commands to run for _your_ package manager (some might automatically install these tools in later steps).
4 |
5 | | OS | Package Manager | Command |
6 | | ----- | --------------- | ---------------------------------- |
7 | | linux | Aptitude | `apt install git` |
8 | | linux | DNF | `dnf install git` |
9 | | linux | Pacman | `pacman -S git` |
10 | | linux | Zypper | `zypper install git` |
11 | | macOS | Homebrew | `brew install coreutils git` |
12 | | macOS | Spack | `spack install coreutils git` |
13 |
14 | ::: tip Note
15 |
16 | `sudo` may be required depending on your system configuration.
17 |
18 | :::
19 |
--------------------------------------------------------------------------------
/docs/pt-br/contribute/first-party-plugins.md:
--------------------------------------------------------------------------------
1 | # First-Party Plugins
2 |
3 | > Hi, we've recently migrated our docs and added some new pages. If you would like to help translate this page, see the "Edit this page" link at the bottom of the page.
4 |
5 | A equipe principal do asdf criou alguns plugins relevantes para sua vida profissional diária. A ajuda é sempre bem-vinda na manutenção e melhoria desses plugins. Veja o repositório associado para cada link abaixo:
6 |
7 | - [Elixir](https://github.com/asdf-vm/asdf-elixir)
8 | - [Erlang](https://github.com/asdf-vm/asdf-erlang)
9 | - [Node.js](https://github.com/asdf-vm/asdf-nodejs)
10 | - [Ruby](https://github.com/asdf-vm/asdf-ruby)
11 |
12 | Para plugins da comunidade, consulte:
13 |
14 | - [`asdf-community` organisation](https://github.com/asdf-community): A collaborative, community-driven project for long-term maintenance of `asdf` plugins.
15 | - [`asdf-plugins` shortname repo](https://github.com/asdf-vm/asdf-plugins): Short-name list used by `asdf` core to lookup popular `asdf` plugins.
16 | - [GitHub `asdf-plugin` topic search](https://github.com/topics/asdf-plugin)
17 |
--------------------------------------------------------------------------------
/docs/pt-br/contribute/github-actions.md:
--------------------------------------------------------------------------------
1 | # GitHub Actions
2 |
3 | > Hi, we've recently migrated our docs and added some new pages. If you would like to help translate this page, see the "Edit this page" link at the bottom of the page.
4 |
5 | Obrigado pelo seu interesse, consulte o [repositório de ações asdf](https://github.com/asdf-vm/actions) para ver os problemas, conversas e diretrizes de contribuição existentes.
6 |
--------------------------------------------------------------------------------
/docs/pt-br/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: home
3 |
4 | hero:
5 | name: asdf
6 | text: O Gerenciador de Múltiplas Versões de Tempo de Execução
7 | tagline: Gerencie todas as suas versões de tempo de execução com uma ferramenta!
8 | actions:
9 | - theme: brand
10 | text: Começar
11 | link: /pt-br/guide/getting-started
12 | - theme: alt
13 | text: O que é asdf?
14 | link: /pt-br/guide/introduction
15 | - theme: alt
16 | text: Ver no GitHub
17 | link: https://github.com/asdf-vm/asdf
18 |
19 | features:
20 | - title: Uma super ferramenta
21 | details: "Gerencie cada um dos runtimes e ferramentas dos seus projetos com uma única ferramenta de CLI"
22 | icon: 🎉
23 | - title: Plugins
24 | details: "Grande ecossistema de runtimes e ferramentas existentes. API simples para adicionar suporte para novas ferramentas conforme necessário!"
25 | icon: 🔌
26 | - title: "Compatível com vários arquivos de configuração"
27 | details: "Suporte para arquivos de configuração existentes .nvmrc, .node-version, .ruby-version para uma migração tranquila!"
28 | icon: ⏮
29 | - title: "Só um arquivo de configuração"
30 | details: ".tool-versions para gerenciar todas as suas ferramentas, runtimes e suas versões em um único arquivo"
31 | icon: 📄
32 | - title: "Shells"
33 | details: "Suporta Bash, ZSH, Fish & Elvish com autocomplete."
34 | icon: 🐚
35 | - title: "GitHub Actions"
36 | details: "Fornece um GitHub Action para instalar e utilizar seu .tool-verions em seu fluxo de trabalho CICD."
37 | icon: 🤖
38 | ---
39 |
--------------------------------------------------------------------------------
/docs/pt-br/manage/commands.md:
--------------------------------------------------------------------------------
1 | # All Commands
2 |
3 | > Hi, we've recently migrated our docs and added some new pages. If you would like to help translate this page, see the "Edit this page" link at the bottom of the page.
4 |
5 | A lista de todos os comandos disponíveis em `asdf`. Esta lista é o texto do comando `asdf help`.
6 |
7 | <<< @../../internal/help/help.txt
8 |
--------------------------------------------------------------------------------
/docs/pt-br/manage/plugins.md:
--------------------------------------------------------------------------------
1 | # Plugins
2 |
3 | > Hi, we've recently migrated our docs and added some new pages. If you would like to help translate this page, see the "Edit this page" link at the bottom of the page.
4 |
5 | Plugins são como `asdf` sabe lidar com diferentes ferramentas, tais quais Node.js, Ruby, Elixir etc.
6 |
7 | Veja [Criando Plugins](/pt-br/plugins/create.md) para a API do plugin usada para suportar mais ferramentas.
8 |
9 | ## Adicionar
10 |
11 | Adicione os plugins via sua Url Git:
12 |
13 | ```shell
14 | asdf plugin add
15 | # asdf plugin add elm https://github.com/vic/asdf-elm
16 | ```
17 |
18 | ou pelo nome abreviado dentro do repositório de plugins:
19 |
20 | ```shell
21 | asdf plugin add
22 | # asdf plugin add erlang
23 | ```
24 |
25 | ::: tip Recommendation
26 | Prefira o método mais longo `git-url`, pois ele é independente do repositório de nome abreviado.
27 | :::
28 |
29 | ## Listar Instalados
30 |
31 | ```shell
32 | asdf plugin list
33 | # asdf plugin list
34 | # java
35 | # nodejs
36 | ```
37 |
38 | ```shell
39 | asdf plugin list --urls
40 | # asdf plugin list
41 | # java https://github.com/halcyon/asdf-java.git
42 | # nodejs https://github.com/asdf-vm/asdf-nodejs.git
43 | ```
44 |
45 | ## Listar todos nomes abreviados no repositório
46 |
47 | ```shell
48 | asdf plugin list all
49 | ```
50 |
51 | Veja [Plugins Shortname Index](https://github.com/asdf-vm/asdf-plugin-template) para toda a lista de nomes curtos de plugins.
52 |
53 | ## Atualizar
54 |
55 | ```shell
56 | asdf plugin update --all
57 | ```
58 |
59 | Se você quiser atualizar um pacote específico, apenas use.
60 |
61 | ```shell
62 | asdf plugin update
63 | # asdf plugin update erlang
64 | ```
65 |
66 | Esta atualização irá buscar o último _commit_ na _branch_ padrão no _origin_ de seu respositório. Plugins e atualizações das versões estão sendo desenvolvidas ([#916](https://github.com/asdf-vm/asdf/pull/916))
67 |
68 | ## Remover
69 |
70 | ```bash
71 | asdf plugin remove
72 | # asdf plugin remove erlang
73 | ```
74 |
75 | Removendo o plugin irá remover todas as instalações feitas com o plugin. Isso pode ser usado como um atalho para apagar/remover sujeiras de versões não utilizadas de uma ferramenta.
76 |
77 | ## Sincronizar nome abreviado no repositório
78 |
79 | O nome abreviado do repositório é sincronizado em seu máquina local e periodicamente atualizado. Esse período pode ser determinado com o seguinte método:
80 |
81 | - comandos `asdf plugin add ` ou `asdf plugin list all` disparam a sincronização
82 | - ocorre uma sincronização se não houver nenhuma nos últimos `X` minutos
83 | - `X` por padrão é `60`, mas pode ser mudado em `.asdfrc` via as opções do `plugin_repository_last_check_duration`. Seja mais em [asdf documentação de configuração](/pt-br/manage/configuration.md).
84 |
--------------------------------------------------------------------------------
/docs/pt-br/more/community-projects.md:
--------------------------------------------------------------------------------
1 | # Community Projects
2 |
3 | Here are some community projects related to `asdf`:
4 |
5 | - [asdf-community](https://github.com/asdf-community): A collaborative,
6 | community-driven project for long-term maintenance of asdf plugins.
7 | - [asdf dev container](https://github.com/iloveitaly/asdf-devcontainer): A
8 | [GitHub Dev Container](https://docs.github.com/en/codespaces/setting-up-your-project-for-codespaces/introduction-to-dev-containers)
9 | supporting asdf managed tools in GitHub Codespaces.
10 |
11 | ::: warning Note
12 |
13 | asdf core do not own these projects or their code. asdf core are not responsible
14 | for the quality or security as they relate to those listed here.
15 |
16 | :::
17 |
--------------------------------------------------------------------------------
/docs/pt-br/more/faq.md:
--------------------------------------------------------------------------------
1 | # Perguntas frequentes
2 |
3 | Aqui estão algumas perguntas comuns sobre `asdf`.
4 |
5 | ## Suporte WSL1?
6 |
7 | WSL1 ([Windows Subsystem for Linux](https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux) 1) não é oficialmente suportado. Alguns aspectos do `asdf` podem não funcionar corretamente. Não temos a intenção de adicionar suporte oficial para WSL1.
8 |
9 | ## Suporte WSL2?
10 |
11 | WSL2 ([Subsistema Windows para Linux](https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux#WSL_2) 2) deve funcionar usando as instruções de configuração e dependência para a distribuição WSL escolhida.
12 |
13 | É importante ressaltar que o WSL2 _apenas_ deve funcionar corretamente quando o diretório de trabalho atual é uma unidade Unix e não uma unidade Windows vinculada.
14 |
15 | Pretendemos executar o conjunto de testes no WSL2 quando o suporte ao host runner estiver disponível nas Ações do GitHub; atualmente, esse não parece ser o caso.
16 |
17 | ## Exectable recém-instalado não está funcionando?
18 |
19 | > Acabei de instalar o `npm -g yarn`, mas não consigo executar o `yarn`. O que da?
20 |
21 | `asdf` usa [shims]() para gerenciar executáveis. Aqueles instalados por plug-ins têm shims criados automaticamente, enquanto a instalação de executáveis por meio de uma ferramenta gerenciada `asdf` exigirá que você notifique o`asdf` sobre a necessidade de criar shims. Neste caso, para criar um shim para [Yarn](https://yarnpkg.com/). Veja a documentação do comando [`asdf reshim`](/ manage / core.md # reshim).
22 |
23 | ## Shell não detecta shims recém-instalados?
24 |
25 | Se `asdf reshim` não está resolvendo seu problema, então é mais provável devido ao sourcing de`asdf.sh` ou `asdf.fish` _não_ estar no ** BOTTOM ** de seu arquivo de configuração Shell (`.bash_profile`, `.zshrc`, `config.fish`, etc). Ele precisa ser fornecido **DEPOIS** de você definir seu `$PATH` e **DEPOIS** de ter fornecido seu framework (oh-meu-zsh etc), se houver.
26 |
--------------------------------------------------------------------------------
/docs/pt-br/more/thanks.md:
--------------------------------------------------------------------------------
1 | # Créditos
2 |
3 | Eu ([@HashNuke](https://github.com/HashNuke)), febre alta, resfriado e tosse.
4 |
5 | Copyright 2014 até o final dos tempos ([MIT License](https://github.com/asdf-vm/asdf/blob/master/LICENSE))
6 |
7 | ## Mantenedores
8 |
9 | - [@HashNuke](https://github.com/HashNuke)
10 | - [@danhper](https://github.com/danhper)
11 | - [@Stratus3D](https://github.com/Stratus3D)
12 | - [@vic](https://github.com/vic)
13 | - [@jthegedus](https://github.com/jthegedus)
14 |
15 | ## Contribuidores
16 |
17 | Veja em [lista de contribuidores](https://github.com/asdf-vm/asdf/graphs/contributors) :pray: no GitHub
18 |
--------------------------------------------------------------------------------
/docs/zh-hans/contribute/core.md:
--------------------------------------------------------------------------------
1 | # asdf
2 |
3 | `asdf` 核心贡献指南.
4 |
5 | ## 初始化安装
6 |
7 | 在 Github 上 fork `asdf` 并且/或者使用 Git 克隆默认分支:
8 |
9 | ```shell
10 | # 克隆你 fork 的 asdf
11 | git clone https://github.com//asdf.git
12 | # 或者直接克隆 asdf
13 | git clone https://github.com/asdf-vm/asdf.git
14 | ```
15 |
16 | 核心开发所需的工具都列举在这个存储库的 `.tool-versions` 文件中。如果你想要使用 `asdf` 自身来管理它,请使用以下命令添加这些插件:
17 |
18 | ```shell
19 | asdf plugin add bats https://github.com/timgluz/asdf-bats.git
20 | asdf plugin add shellcheck https://github.com/luizm/asdf-shellcheck.git
21 | asdf plugin add shfmt https://github.com/luizm/asdf-shfmt.git
22 | ```
23 |
24 | 使用以下命令安装这些版本来开发 `asdf`:
25 |
26 | ```shell
27 | asdf install
28 | ```
29 |
30 | 在本地机器的开发过程中不使用 `asdf` 来管理工具 _或许_ 对你有帮助,因为你可能需要打破某些可能会影响到你的开发工具链的功能。以下是所需工具的原始列表:
31 |
32 | - [bats-core](https://github.com/bats-core/bats-core):Bash 自动化测试系统,用于单元测试 Bash 或 POSIX 兼容脚本。
33 | - [shellcheck](https://github.com/koalaman/shellcheck):Shell 脚本的静态分析工具。
34 | - [shfmt](https://github.com/mvdan/sh):支持 Bash 的 Shell 解析器、格式化器和解释器;包含 shfmt。
35 |
36 | ## 开发
37 |
38 | 如果你想要在不更改已安装的 `asdf` 的情况下尝试应用你的更改,可以将 `$ASDF_DIR` 变量设置为克隆存储库的路径,并临时将目录的 `bin` 和 `shims` 目录添加到你的路径中。
39 |
40 | 最好在提交或推送到远程之前,在本地做好格式化、lint 检查和测试你的代码。可以使用以下脚本/命令:
41 |
42 | ```shell
43 | # 脚本检查
44 | ./scripts/shellcheck.bash
45 |
46 | # 格式化
47 | ./scripts/shfmt.bash
48 |
49 | # 测试:所有案例
50 | bats test/
51 | # 测试:特定命令
52 | bats test/list_commands.bash
53 | ```
54 |
55 | ::: tip 提示
56 |
57 | **增加测试!** - 新特性需要进行测试,并加快错误修复的审查速度。请在创建拉取请求之前覆盖新的代码路径。查看 [bats-core 文档](https://bats-core.readthedocs.io/en/stable/index.html) 了解更多。
58 |
59 | :::
60 |
61 | ## Bats 测试
62 |
63 | **强烈建议**在编写测试之前检查现有的测试套件和 [bats-core 文档](https://bats-core.readthedocs.io/en/stable/index.html)。
64 |
65 | Bats 调试有时可能很困难。使用带有 `-t` 标识的 TAP 输出将使你能够在测试执行期间打印带有特殊文件描述符 `>&3` 的输出,从而简化调试。例如:
66 |
67 | ```shell
68 | # test/some_tests.bats
69 |
70 | printf "%s\n" "Will not be printed during bats test/some_tests.bats"
71 | printf "%s\n" "Will be printed during bats -t test/some_tests.bats" >&3
72 | ```
73 |
74 | 进一步相关文档请查看 bats-core 的 [Printing to the Terminal](https://bats-core.readthedocs.io/en/stable/writing-tests.html#printing-to-the-terminal) 部分.
75 |
76 | ## 拉取请求、发布以及约定式提交
77 |
78 | `asdf` 正在使用一个名为 [Release Please](https://github.com/googleapis/release-please) 的自动发布工具来自动碰撞 [SemVer](https://semver.org/) 版本并生成 [变更日志](https://github.com/asdf-vm/asdf/blob/master/CHANGELOG.md)。这个信息是通过读取自上次发布以来的提交历史记录来确定的。
79 |
80 | [约定式提交](https://www.conventionalcommits.org/zh-hans/) 定义了拉取请求标题的格式,该标题成为默认分支上的提交消息格式。这是通过 Github Action [`amannn/action-semantic-pull-request`](https://github.com/amannn/action-semantic-pull-request) 强制执行的。
81 |
82 | 约定式提交遵循以下格式:
83 |
84 | ```
85 | [optional scope][optional !]:
86 |
87 |
88 | fix: some fix
89 | feat: a new feature
90 | docs: some documentation update
91 | docs(website): some change for the website
92 | feat!: feature with breaking change
93 | ```
94 |
95 | `` 的所有类型包含: `feat`、`fix`、`docs`、`style`、`refactor`、`perf`、`test`、`build`、`ci`、`chore`、`revert`。
96 |
97 | - `!`:表示重大更改
98 | - `fix`:将会创建一个新的 SemVer `patch` 补丁
99 | - `feat`:将会创建一个新的 SemVer `minor` 小版本
100 | - `!`:将会创建一个新的 SemVer `major` 大版本
101 |
102 | 拉取请求标题必须遵循这种格式。
103 |
104 | ::: tip 提示
105 |
106 | 请使用约定式提交信息格式作为拉取请求标题。
107 |
108 | :::
109 |
110 | ## Docker 镜像
111 |
112 | [asdf-alpine](https://github.com/vic/asdf-alpine) 和 [asdf-ubuntu](https://github.com/vic/asdf-ubuntu) 项目正在努力提供一些 asdf 工具的容器化镜像。你可以使用这些容器镜像作为开发服务器的基础镜像,或者运行生产应用。
113 |
--------------------------------------------------------------------------------
/docs/zh-hans/contribute/documentation.md:
--------------------------------------------------------------------------------
1 | # 文档 & 网站
2 |
3 | 文档 & 网站贡献指南。
4 |
5 | ## 初始化设置
6 |
7 | 在 Github 上 fork `asdf` 并且/或者使用 Git 克隆默认分支:
8 |
9 | ```shell
10 | # 克隆你 fork 的 asdf
11 | git clone https://github.com//asdf.git
12 | # 或者直接克隆 asdf
13 | git clone https://github.com/asdf-vm/asdf.git
14 | ```
15 |
16 | 文档网站开发所需的工具都在文件 `docs/.tool-versions` 中使用 `asdf` 进行管理。使用以下命令添加插件:
17 |
18 | ```shell
19 | asdf plugin add nodejs https://github.com/asdf-vm/asdf-nodejs
20 | ```
21 |
22 | 使用以下命令安装工具版本:
23 |
24 | ```shell
25 | asdf install
26 | ```
27 |
28 | - [Node.js](https://nodejs.org/zh-cn/):基于 Chrome 的 V8 引擎的 JavaScript 运行环境。
29 |
30 | 根据 `docs/package.json` 文件安装 Node.js 依赖:
31 |
32 | ```shell
33 | npm install
34 | ```
35 |
36 | ## 开发
37 |
38 | [Vuepress (v2)](https://v2.vuepress.vuejs.org/zh/) 是我们用来构建 asdf 文档网站的静态站点生成器(SSG)。它被选中来取代 [Docsify.js](https://docsify.js.org/#/zh-cn/),因为我们希望在用户没有可用或未启用 JavaScript 时支持仅依靠 HTML。Docsify 无法做到这一点。除此之外,两者特性集合大致相同,重点是 Vuepress 可以用最少的配置编写 Markdown 文件。
39 |
40 | `package.json` 包含了开发所需的脚本:
41 |
42 | @[code json{3-5}](../../package.json)
43 |
44 | 启动本地开发服务器:
45 |
46 | ```shell
47 | npm run dev
48 | ```
49 |
50 | 在提交之前格式化代码:
51 |
52 | ```shell
53 | npm run format
54 | ```
55 |
56 | ## 拉取请求、发布以及约定式提交
57 |
58 | `asdf` 正在使用依赖 PR 标题中的约定式提交的自动化发布流水线。具体的文档可以查看 [核心贡献指南](./core.md).
59 |
60 | 当为文档更改创建 PR 请求时,请确保 PR 标题使用了约定式提交类型 `docs` 以及 `docs: ` 的格式。
61 |
62 | ## Vuepress
63 |
64 | 网站的配置包含在几个 JavaScript 文件中,其中 JS 对象用于表示配置。它们是:
65 |
66 | - `docs/.vuepress/config.js`:网站的根配置文件。请查看 [Vuepress 文档](https://v2.vuepress.vuejs.org/zh/guide/configuration.html) 了解更多详情。
67 |
68 | 为了简化根配置文件,更大的 JS 对象表示 _导航栏和侧边栏_ 配置已经被提取并按照语言类型分隔开来。请参考以下文件:
69 |
70 | - `docs/.vuepress/navbar.js`
71 | - `docs/.vuepress/sidebar.js`
72 |
73 | 这些配置的官方文档位于 [默认主题参考](https://v2.vuepress.vuejs.org/zh/reference/default-theme/config.html)。
74 |
75 | ## I18n 国际化
76 |
77 | Vuepress 有一流的国际化支持。根配置文件 `docs/.vuepress/config.js` 定义了支持的语言类型及其 URL、在选择下拉菜单中的标题以及导航栏/侧边栏配置引用。
78 |
79 | 导航栏/侧边栏配置在上述配置文件中捕获,按语言类型分隔开并单独导出。
80 |
81 | 每种语言的 markdown 内容必须位于与根配置文件中 `locale` 键同名的目录位置。也就是:
82 |
83 | ```js
84 | {
85 | ...
86 | themeConfig: {
87 | locales: {
88 | "/": {
89 | selectLanguageName: "English (US)",
90 | sidebar: sidebar.en,
91 | navbar: navbar.en
92 | },
93 | "/pt-BR/": {
94 | selectLanguageName: "Brazilian Portuguese",
95 | sidebar: sidebar.pt_br,
96 | navbar: navbar.pt_br
97 | }
98 | }
99 | }
100 | }
101 | ```
102 |
103 | `/pt-BR/` 将要求 markdown 文件的同一集合位于 `docs/pt-BR/` 目录下,如下所示:
104 |
105 | ```shell
106 | docs
107 | ├─ README.md
108 | ├─ foo.md
109 | ├─ nested
110 | │ └─ README.md
111 | └─ pt-BR
112 | ├─ README.md
113 | ├─ foo.md
114 | └─ nested
115 | └─ README.md
116 | ```
117 |
118 | 请查看 [Vuepress i18n 国际化官方文档](https://v2.vuepress.vuejs.org/zh/guide/i18n.html#%E7%AB%99%E7%82%B9%E5%A4%9A%E8%AF%AD%E8%A8%80%E9%85%8D%E7%BD%AE) 了解更多详情。
119 |
--------------------------------------------------------------------------------
/docs/zh-hans/contribute/first-party-plugins.md:
--------------------------------------------------------------------------------
1 | # 官方插件
2 |
3 | asdf 核心团队已经开发了一些与他们日常工作相关的插件。随时欢迎大家维护和改进这些插件。这些插件所对应的存储库链接如下所示:
4 |
5 | - [Elixir](https://github.com/asdf-vm/asdf-elixir)
6 | - [Erlang](https://github.com/asdf-vm/asdf-erlang)
7 | - [Node.js](https://github.com/asdf-vm/asdf-nodejs)
8 | - [Ruby](https://github.com/asdf-vm/asdf-ruby)
9 |
10 | 对于社区插件,请参考:
11 |
12 | - [`asdf-community` 组织](https://github.com/asdf-community):一个用于长期维护 `asdf` 插件的协作、社区驱动的项目。
13 | - [`asdf-plugins` 缩写存储库](https://github.com/asdf-vm/asdf-plugins):`asdf` 核心用于查找流行的 `asdf` 插件的缩写列表。
14 | - [GitHub `asdf-plugin` 主题搜索](https://github.com/topics/asdf-plugin)
15 |
--------------------------------------------------------------------------------
/docs/zh-hans/contribute/github-actions.md:
--------------------------------------------------------------------------------
1 | # GitHub Actions
2 |
3 | 感谢你的关注,请参考 [asdf actions repo](https://github.com/asdf-vm/actions) 了解现有的问题、对话和贡献指南。
4 |
--------------------------------------------------------------------------------
/docs/zh-hans/guide/introduction.md:
--------------------------------------------------------------------------------
1 | # 项目简介
2 |
3 | `asdf` 是一个工具版本管理器。所有的工具版本定义都包含在一个文件(`.tool-versions`)中,你可以将配置文件放在项目的 Git 存储库中以便于和团队其他成员共享,从而确保每个人都使用**完全**相同的工具版本。
4 |
5 | 传统工作方式需要多个命令行版本管理器,而且每个管理器都有其不同的 API、配置文件和实现方式(比如,`$PATH` 操作、垫片、环境变量等等)。`asdf` 提供单个交互方式和配置文件来简化开发工作流程,并可通过简单的插件接口扩展到所有工具和运行环境。
6 |
7 | ## 它是如何工作的
8 |
9 | 一旦 `asdf` 核心在 Shell 配置中设置好之后,你可以安装插件来管理特定的工具。当通过插件安装工具时,安装的可执行程序会为每个可执行程序创建 [垫片]()。当你尝试运行其中一个可执行程序时,将运行垫片,从而允许 `asdf` 识别 `.tool-versions` 文件中设置的工具版本并执行该版本。
10 |
11 | ## 相关项目
12 |
13 | ### nvm / n / rbenv 等
14 |
15 | [nvm](https://github.com/nvm-sh/nvm), [n](https://github.com/tj/n) 和 [rbenv](https://github.com/rbenv/rbenv) 等工具都是用 Shell 脚本写的,这些脚本能为工具安装的可执行程序创建垫片。
16 |
17 | `asdf` 非常相似,目的是在工具/运行环境版本管理领域竞争。`asdf` 的区别之处在于它的插件系统,它消除了每个工具/运行环境对管理工具的需求、每个管理工具的不同命令以及存储库中不同的`*-版本`文件。
18 |
19 |
24 |
25 | ### direnv
26 |
27 | > 使用可以根据当前目录加载和卸载环境变量的新功能增强现有 shell。
28 |
29 | `asdf` 不管理环境变量,但是有一个插件 [`asdf-direnv`](https://github.com/asdf-community/asdf-direnv) 可以用来集成 direnv 的特性到 `asdf` 中。
30 |
31 | 请查看 [direnv 文档](https://direnv.net/) 了解更多。
32 |
33 | ### Homebrew
34 |
35 | > macOS(或者 Linux)上缺失包的管理器
36 |
37 | Homebrew 管理你的软件包及其上游依赖。`asdf` 不管理上游依赖,它不是包管理器。这个责任取决于用户,尽管我们试图保持依赖关系列表很小。
38 |
39 | 请查看 [Homebrew 文档](https://brew.sh/) 了解更多。
40 |
41 | ### NixOS
42 |
43 | > Nix 是一种采用独特方法进行软件包管理和系统配置的工具
44 |
45 | NixOS 旨在通过管理每个工具的整个依赖关系树中软件包的确切版本来构建真正可重复的环境,有些是 `asdf` 无法做到的。NixOS 使用自己的编程语言、许多命令行工具和超过 60,000 个包的包集合来实现这一点。
46 |
47 | 同样,`asdf` 不管理上游依赖,并且它不是一个包管理器。
48 |
49 | 请查看 [NixOS 文档](https://nixos.org/guides/how-nix-works.html) 了解更多。
50 |
51 | ## 为什么使用 asdf?
52 |
53 | `asdf` 确保团队可以使用**完全**相同的工具版本,通过插件系统支持**很多**工具,以及作为 Shell 配置中包含的单个 **Shell** 脚本的 _简单性和熟悉性_ 。
54 |
55 | ::: tip 注意
56 | `asdf` 并不打算成为一个系统包管理器。它是一个工具版本管理器。仅仅因为你可以为任何工具创建插件并使用 `asdf` 管理其版本,并不意味着这是这个特定工具的最佳实践方案。
57 | :::
58 |
--------------------------------------------------------------------------------
/docs/zh-hans/index.md:
--------------------------------------------------------------------------------
1 | ---
2 | # https://vitepress.dev/reference/default-theme-home-page
3 | layout: home
4 |
5 | hero:
6 | name: asdf
7 | text: 多运行时版本管理器
8 | tagline: 使用一个工具管理所有运行时版本!
9 | actions:
10 | - theme: brand
11 | text: 快速上手
12 | link: /zh-hans/guide/getting-started
13 | - theme: alt
14 | text: 什么是asdf?
15 | link: /zh-hans/guide/introduction
16 | - theme: alt
17 | text: 在 Github 上查看
18 | link: https://github.com/asdf-vm/asdf
19 |
20 | features:
21 | - title: 一个工具
22 | details: "使用单个命令行工具和命令界面管理你的每个项目运行环境。"
23 | icon: 🎉
24 | - title: 插件
25 | details: "现有运行环境和工具的大型生态系统。简单 API 用于根据需要添加对新工具的支持!"
26 | icon: 🔌
27 | - title: 向后兼容
28 | details: "支持从现有配置文件 .nvmrc、.node-version、.ruby-version 平滑迁移!"
29 | icon: ⏮
30 | - title: "一个配置文件"
31 | details: "一个可共享的 .tool-versions 配置文件管理所有工具、运行环境及其版本。"
32 | icon: 📄
33 | - title: "Shells"
34 | details: "支持 Bash、ZSH、Fish 和 Elvish,并提供补全功能。"
35 | icon: 🐚
36 | - title: "GitHub Actions"
37 | details: "提供 Github Action 在 CI/CD 工作流中安装和使用 .tool-versions。"
38 | icon: 🤖
39 | ---
40 |
--------------------------------------------------------------------------------
/docs/zh-hans/manage/commands.md:
--------------------------------------------------------------------------------
1 | # 所有命令
2 |
3 | `asdf` 中所有可用命令的列表。这个列表就是 `asdf help` 命令的打印内容。
4 |
5 | <<< @../../internal/help/help.txt
6 |
--------------------------------------------------------------------------------
/docs/zh-hans/manage/plugins.md:
--------------------------------------------------------------------------------
1 | # 插件
2 |
3 | 插件告诉 `asdf` 如何处理不同的工具,如 Node.js、 Ruby、 Elixir 等。
4 |
5 | 请参考 [创建插件](/zh-hans/plugins/create.md) 了解用于支持更多工具的插件 API。
6 |
7 | ## 添加
8 |
9 | 通过 Git URL 地址添加插件:
10 |
11 | ```shell
12 | asdf plugin add
13 | # asdf plugin add elm https://github.com/vic/asdf-elm
14 | ```
15 |
16 | 或者通过插件存储库中的缩写添加插件:
17 |
18 | ```shell
19 | asdf plugin add
20 | # asdf plugin add erlang
21 | ```
22 |
23 | ::: tip 建议
24 | 推荐独立于缩写存储库的、更长的 `git-url` 方法。
25 | :::
26 |
27 | ## 列举已安装
28 |
29 | ```shell
30 | asdf plugin list
31 | # asdf plugin list
32 | # java
33 | # nodejs
34 | ```
35 |
36 | ```shell
37 | asdf plugin list --urls
38 | # asdf plugin list
39 | # java https://github.com/halcyon/asdf-java.git
40 | # nodejs https://github.com/asdf-vm/asdf-nodejs.git
41 | ```
42 |
43 | ## 列举缩写存储库中的所有插件
44 |
45 | ```shell
46 | asdf plugin list all
47 | ```
48 |
49 | 请参考 [插件缩写索引](https://github.com/asdf-vm/asdf-plugins) 了解插件的完整缩写列表。
50 |
51 | ## 更新
52 |
53 | ```shell
54 | asdf plugin update --all
55 | ```
56 |
57 | 如果你想要更新特定的包,如下所示。
58 |
59 | ```shell
60 | asdf plugin update
61 | # asdf plugin update erlang
62 | ```
63 |
64 | 这种更新方式将会获取插件存储库的 _源代码_ 的 _默认分支_ 的 _最新提交_。版本化的插件和更新正在开发中 ([#916](https://github.com/asdf-vm/asdf/pull/916))。
65 |
66 | ## 移除
67 |
68 | ```bash
69 | asdf plugin remove
70 | # asdf plugin remove erlang
71 | ```
72 |
73 | 移除一个插件将会移除该插件安装的所有工具。这可以当作是清理/修剪工具的许多未使用版本的简单方法。
74 |
75 | ## 同步缩写存储库
76 |
77 | 缩写存储库将同步到你的本地计算机并定期刷新。这个周期由以下方法确定:
78 |
79 | - 命令 `asdf plugin add ` 或者 `asdf plugin list all` 将会触发同步
80 | - 如果在过去的 `X` 分钟内没有同步,则进行同步
81 | - `X` 默认是 `60`,但可以通过在 `.asdfrc` 文件中配置 `plugin_repository_last_check_duration` 选项来进行配置。请查看 [asdf 配置文档](/zh-hans/manage/configuration.md) 了解更多。
82 |
--------------------------------------------------------------------------------
/docs/zh-hans/manage/versions.md:
--------------------------------------------------------------------------------
1 | # 版本
2 |
3 | ## 安装版本
4 |
5 | ```shell
6 | asdf install
7 | # asdf install erlang 17.3
8 | ```
9 |
10 | 如果一个插件支持从源代码下载和编译,你可以指定 `ref:foo`,其中 `foo` 是特定的分支、标签或者提交。卸载该版本时,你也需要使用相同的名称和引用。
11 |
12 | ## 安装最新稳定版本
13 |
14 | ```shell
15 | asdf install latest
16 | # asdf install erlang latest
17 | ```
18 |
19 | 安装给定字符串开头的最新稳定版本。
20 |
21 | ```shell
22 | asdf install latest:
23 | # asdf install erlang latest:17
24 | ```
25 |
26 | ## 列举已安装版本
27 |
28 | ```shell
29 | asdf list
30 | # asdf list erlang
31 | ```
32 |
33 | 筛选出以给定字符串开头的版本。
34 |
35 | ```shell
36 | asdf list
37 | # asdf list erlang 17
38 | ```
39 |
40 | ## 列举所有可用版本
41 |
42 | ```shell
43 | asdf list all
44 | # asdf list all erlang
45 | ```
46 |
47 | 筛选出以给定字符串开头的版本。
48 |
49 | ```shell
50 | asdf list all
51 | # asdf list all erlang 17
52 | ```
53 |
54 | ## 显示最新稳定版本
55 |
56 | ```shell
57 | asdf latest
58 | # asdf latest erlang
59 | ```
60 |
61 | 显示以给定字符串开头的最新稳定版本。
62 |
63 | ```shell
64 | asdf latest
65 | # asdf latest erlang 17
66 | ```
67 |
68 | ## 设置当前版本
69 |
70 | ```shell
71 | asdf global [...]
72 | asdf shell [...]
73 | asdf local [...]
74 | # asdf global elixir 1.2.4
75 |
76 | asdf global latest[:]
77 | asdf local latest[:]
78 | # asdf global elixir latest
79 | ```
80 |
81 | `global` 将版本写到 `$HOME/.tool-versions` 文件中。
82 |
83 | `shell` 仅为当前 shell 会话将版本设置为一个名为 `ASDF_${LANG}_VERSION` 的环境变量。
84 |
85 | `local` 将版本写到 `$PWD/.tool-versions` 文件中,如果有需要也会创建此文件。
86 |
87 | 请查看 [配置部分](/zh-hans/manage/configuration.md) 的 `.tool-versions` 文件了解更多详情。
88 |
89 | :::warning 可选
90 | 如果你只是想为当前 shell 会话或者在特定工具版本下执行一条命令,你可以设置一个类似 `ASDF_${TOOL}_VERSION` 的环境变量。
91 | :::
92 |
93 | 下面的示例在版本为 `1.4.0` 的 Elixir 项目上运行测试。
94 | 版本格式与 `.tool-versions` 文件支持的版本格式相同。
95 |
96 | ```shell
97 | ASDF_ELIXIR_VERSION=1.4.0 mix test
98 | ```
99 |
100 | ## 回退到系统版本
101 |
102 | 要使用工具 `` 的系统版本而非 asdf 管理版本,你可以将工具的版本设置为 `system`。
103 |
104 | 使用 `global`、`local` 或者 `shell` 设置系统,如上面的 [设置当前版本](#设置当前版本) 部分所述。
105 |
106 | ```shell
107 | asdf local system
108 | # asdf local python system
109 | ```
110 |
111 | ## 显示当前版本
112 |
113 | ```shell
114 | asdf current
115 | # asdf current
116 | # erlang 17.3 (set by /Users/kim/.tool-versions)
117 | # nodejs 6.11.5 (set by /Users/kim/cool-node-project/.tool-versions)
118 |
119 | asdf current
120 | # asdf current erlang
121 | # 17.3 (set by /Users/kim/.tool-versions)
122 | ```
123 |
124 | ## 卸载版本
125 |
126 | ```shell
127 | asdf uninstall
128 | # asdf uninstall erlang 17.3
129 | ```
130 |
131 | ## 垫片(Shims)
132 |
133 | 当 asdf 安装一个包时,它会在 `$ASDF_DATA_DIR/shims` 目录(默认为 `~/.asdf/shims`)中为该包中的每个可执行程序创建垫片。这个位于 `$PATH` 中(通过 `asdf.sh`、 `asdf.fish` 等等实现)的目录是已安装程序在环境中可用的方式。
134 |
135 | 垫片本身是非常简单的包装器,它 `exec` (执行)一个辅助程序 `asdf exec`,向其传递插件的名称和垫片正在包装的已安装包中的可执行程序的路径。
136 |
137 | `asdf exec` 辅助程序确定要使用的软件包版本(比如在 `.tool-versions` 文件中指定,通过 `asdf local ...` 或者 `asdf global ...` 命令选择)、软件包安装目录中的可执行程序的最终路径(这可以在插件中通过 `exec-path` 回调来操作)以及要在其中执行的环境(也由插件 - `exec-env` 脚本提供),最后完成执行。
138 |
139 | ::: warning 注意
140 | 因为此系统使用 `exec` 调用,所以软件包中的任何脚本如果要由 shell 生效而不是执行的脚本都需要直接访问,而不是通过垫片包装器进行访问。两个 `asdf` 命令:`which` 和 `where` 可以通过返回已安装软件包的路径来帮助解决这个问题。
141 | :::
142 |
143 | ```shell
144 | # 返回当前版本中主要可执行程序的路径
145 | source $(asdf which ${PLUGIN})/../script.sh
146 |
147 | # 返回软件包安装目录的路径
148 | source $(asdf where ${PLUGIN} $(asdf current ${PLUGIN}))/bin/script.sh
149 | ```
150 |
151 | ### 绕过 asdf 垫片
152 |
153 | 如果由于某种原因,你希望绕过 asdf 垫片,或者希望在进入项目目录时自动设置环境变量,则 [asdf-direnv](https://github.com/asdf-community/asdf-direnv) 插件可能会有所帮助。请务必查看其 README 文件了解更多详情。
154 |
--------------------------------------------------------------------------------
/docs/zh-hans/more/community-projects.md:
--------------------------------------------------------------------------------
1 | # Community Projects
2 |
3 | Here are some community projects related to `asdf`:
4 |
5 | - [asdf-community](https://github.com/asdf-community): A collaborative,
6 | community-driven project for long-term maintenance of asdf plugins.
7 | - [asdf dev container](https://github.com/iloveitaly/asdf-devcontainer): A
8 | [GitHub Dev Container](https://docs.github.com/en/codespaces/setting-up-your-project-for-codespaces/introduction-to-dev-containers)
9 | supporting asdf managed tools in GitHub Codespaces.
10 |
11 | ::: warning Note
12 |
13 | asdf core do not own these projects or their code. asdf core are not responsible
14 | for the quality or security as they relate to those listed here.
15 |
16 | :::
17 |
--------------------------------------------------------------------------------
/docs/zh-hans/more/faq.md:
--------------------------------------------------------------------------------
1 | # FAQ
2 |
3 | 以下是 `asdf` 相关的一些常见问题。
4 |
5 | ## 支持 WSL1 吗?
6 |
7 | WSL1 ([Windows Subsystem for Linux 1](https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux#WSL_1)) 不受官方支持。`asdf` 的某些方面可能无法正常工作。我们不打算添加对 WSL1 的官方支持。
8 |
9 | ## 支持 WSL2 吗?
10 |
11 | WSL2 ([Windows Subsystem for Linux 2](https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux#WSL_2)) 应该作为你选择的 WSL 发行版来使用本设置和依赖说明。
12 |
13 | 重要的是,只有当前工作目录是 Unix 驱动器而不是绑定的 Windows 驱动器时,WSL2 _才能_ 正常工作。
14 |
15 | 当 Github Actions 上提供主机运行器支持时,我们打算在 WSL2 上运行测试套件。(Github Actions 目前还未提供 WSL2 支持)
16 |
17 | ## 新安装的可执行程序无法运行?
18 |
19 | > 我执行了 `npm install -g yarn` 命令,但是之后不能运行 `yarn` 命令。这是为什么?
20 |
21 | `asdf` 使用 [垫片]() 来管理可执行程序。插件所安装的那些命令会自动创建垫片,而通过 `asdf` 管理工具安装过的可执行程序则需要通知 `asdf` 创建垫片的需要。在这个例子中,为 [Yarn](https://yarnpkg.com/) 创建一个垫片即可。请查看 [`asdf reshim` 命令文档](/zh-hans/manage/core.md#reshim) 了解更多。
22 |
23 | ## Shell 没有检测到新安装的垫片?
24 |
25 | 如果 `asdf reshim` 没有解决你的问题,那么很有可能是在 `asdf.sh` 或者 `asdf.fish` 的生效不在你的 Shell 配置文件(`.bash_profile`、`.zshrc`、`config.fish` 等等)的**下方**。这需要你在设置你的 `$PATH` **之后**和生效你的框架(oh-my-zsh 等等)(如果有的话)**之后**再生效。
26 |
--------------------------------------------------------------------------------
/docs/zh-hans/more/thanks.md:
--------------------------------------------------------------------------------
1 | # 致谢
2 |
3 | asdf 作者和贡献者的感谢页!
4 |
5 | ## 作者
6 |
7 | 我 ([@HashNuke](https://github.com/HashNuke)),高烧、感冒、咳嗽。
8 |
9 | 版权 2014 直到时间尽头 ([MIT License](https://github.com/asdf-vm/asdf/blob/master/LICENSE))
10 |
11 | ## 维护者
12 |
13 | - [@HashNuke](https://github.com/HashNuke)
14 | - [@danhper](https://github.com/danhper)
15 | - [@Stratus3D](https://github.com/Stratus3D)
16 | - [@vic](https://github.com/vic)
17 | - [@jthegedus](https://github.com/jthegedus)
18 |
19 | ## 贡献者
20 |
21 | 请查看 Github 上的 [贡献者名单](https://github.com/asdf-vm/asdf/graphs/contributors) 🙏 了解更多。
22 |
--------------------------------------------------------------------------------
/go.mod:
--------------------------------------------------------------------------------
1 | module github.com/asdf-vm/asdf
2 |
3 | go 1.23.4
4 |
5 | require (
6 | github.com/go-git/go-git/v5 v5.13.0
7 | github.com/mgechev/revive v1.7.0
8 | github.com/otiai10/copy v1.14.0
9 | github.com/rogpeppe/go-internal v1.12.0
10 | github.com/sethvargo/go-envconfig v1.1.1
11 | github.com/stretchr/testify v1.10.0
12 | github.com/urfave/cli/v3 v3.3.3
13 | golang.org/x/sys v0.31.0
14 | gopkg.in/ini.v1 v1.67.0
15 | honnef.co/go/tools v0.5.1
16 | mvdan.cc/gofumpt v0.7.0
17 | )
18 |
19 | require (
20 | dario.cat/mergo v1.0.0 // indirect
21 | github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c // indirect
22 | github.com/Microsoft/go-winio v0.6.1 // indirect
23 | github.com/ProtonMail/go-crypto v1.1.3 // indirect
24 | github.com/chavacava/garif v0.1.0 // indirect
25 | github.com/cloudflare/circl v1.3.7 // indirect
26 | github.com/cyphar/filepath-securejoin v0.2.5 // indirect
27 | github.com/davecgh/go-spew v1.1.1 // indirect
28 | github.com/emirpasic/gods v1.18.1 // indirect
29 | github.com/fatih/color v1.18.0 // indirect
30 | github.com/fatih/structtag v1.2.0 // indirect
31 | github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
32 | github.com/go-git/go-billy/v5 v5.6.0 // indirect
33 | github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
34 | github.com/google/go-cmp v0.6.0 // indirect
35 | github.com/hashicorp/go-version v1.7.0 // indirect
36 | github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
37 | github.com/kevinburke/ssh_config v1.2.0 // indirect
38 | github.com/mattn/go-colorable v0.1.14 // indirect
39 | github.com/mattn/go-isatty v0.0.20 // indirect
40 | github.com/mattn/go-runewidth v0.0.16 // indirect
41 | github.com/mgechev/dots v0.0.0-20210922191527-e955255bf517 // indirect
42 | github.com/olekukonko/tablewriter v0.0.5 // indirect
43 | github.com/pjbgf/sha1cd v0.3.0 // indirect
44 | github.com/pmezard/go-difflib v1.0.0 // indirect
45 | github.com/rivo/uniseg v0.4.7 // indirect
46 | github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
47 | github.com/skeema/knownhosts v1.3.0 // indirect
48 | github.com/spf13/afero v1.12.0 // indirect
49 | github.com/xanzy/ssh-agent v0.3.3 // indirect
50 | golang.org/x/crypto v0.36.0 // indirect
51 | golang.org/x/exp/typeparams v0.0.0-20231108232855-2478ac86f678 // indirect
52 | golang.org/x/mod v0.23.0 // indirect
53 | golang.org/x/net v0.38.0 // indirect
54 | golang.org/x/sync v0.12.0 // indirect
55 | golang.org/x/text v0.23.0 // indirect
56 | golang.org/x/tools v0.30.0 // indirect
57 | gopkg.in/warnings.v0 v0.1.2 // indirect
58 | gopkg.in/yaml.v3 v3.0.1 // indirect
59 | )
60 |
--------------------------------------------------------------------------------
/internal/completions/completions.go:
--------------------------------------------------------------------------------
1 | // Package completions handles shell completion files.
2 | //
3 | // To add completion support for a shell, simply add a file named
4 | // "asdf." to this directory, replacing "" with the name
5 | // of the shell.
6 | package completions
7 |
8 | import (
9 | "embed"
10 | "errors"
11 | "io/fs"
12 | "slices"
13 | "strings"
14 | )
15 |
16 | //go:embed asdf.*
17 | var completions embed.FS
18 |
19 | // Get returns a file containing completion code for the given shell if it is
20 | // found.
21 | func Get(name string) (fs.File, bool) {
22 | file, err := completions.Open("asdf." + name)
23 | if err != nil {
24 | if errors.Is(err, fs.ErrNotExist) {
25 | return nil, false
26 | }
27 | panic(err) // This should never happen.
28 | }
29 | return file, true
30 | }
31 |
32 | // Names returns a slice of shell names that completion is available for.
33 | func Names() []string {
34 | files, _ := fs.Glob(completions, "asdf.*")
35 | for i, file := range files {
36 | files[i] = strings.TrimPrefix(file, "asdf.")
37 | }
38 | slices.Sort(files)
39 | return files
40 | }
41 |
--------------------------------------------------------------------------------
/internal/completions/completions_test.go:
--------------------------------------------------------------------------------
1 | package completions
2 |
3 | import (
4 | "testing"
5 |
6 | "github.com/stretchr/testify/assert"
7 | )
8 |
9 | func TestGet(t *testing.T) {
10 | t.Run("returns file when completion file found with matching name", func(t *testing.T) {
11 | file, found := Get("bash")
12 |
13 | info, err := file.Stat()
14 | assert.Nil(t, err)
15 | assert.Equal(t, "asdf.bash", info.Name())
16 |
17 | assert.True(t, found)
18 | })
19 |
20 | t.Run("returns false when completion file not found", func(t *testing.T) {
21 | _, found := Get("non-existent")
22 | assert.False(t, found)
23 | })
24 | }
25 |
26 | func TestNames(t *testing.T) {
27 | t.Run("returns slice of shell names for which completion is available", func(t *testing.T) {
28 | assert.Equal(t, []string{"bash", "elvish", "fish", "nushell", "zsh"}, Names())
29 | })
30 | }
31 |
--------------------------------------------------------------------------------
/internal/config/testdata/asdfrc:
--------------------------------------------------------------------------------
1 | # This is a test asdfrc file containing all possible values. Each field to set
2 | # to a value that is different than the default.
3 | legacy_version_file = yes
4 | use_release_candidates = yes
5 | always_keep_download = yes
6 | plugin_repository_last_check_duration = never
7 | disable_plugin_short_name_repository = yes
8 | concurrency = 5
9 |
10 | # Hooks
11 | pre_asdf_plugin_add = echo Executing with args: $@
12 | pre_asdf_plugin_add_test = echo Executing with args: $@
13 | pre_asdf_plugin_add_test2 = echo 'Executing' "with args: $@"
14 |
--------------------------------------------------------------------------------
/internal/config/testdata/empty-asdfrc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/asdf-vm/asdf/9b4927696457e6005b8b3ec2aa7159b38cd71a8f/internal/config/testdata/empty-asdfrc
--------------------------------------------------------------------------------
/internal/data/data.go:
--------------------------------------------------------------------------------
1 | // Package data provides constants and functions pertaining to directories and
2 | // files in the asdf data directory on disk, specified by the $ASDF_DATA_DIR
3 | package data
4 |
5 | import (
6 | "path/filepath"
7 | )
8 |
9 | const (
10 | dataDirDownloads = "downloads"
11 | dataDirInstalls = "installs"
12 | dataDirPlugins = "plugins"
13 | )
14 |
15 | // DownloadDirectory returns the directory a plugin will be placing
16 | // downloads of version source code
17 | func DownloadDirectory(dataDir, pluginName string) string {
18 | return filepath.Join(dataDir, dataDirDownloads, pluginName)
19 | }
20 |
21 | // InstallDirectory returns the path to a plugin directory
22 | func InstallDirectory(dataDir, pluginName string) string {
23 | return filepath.Join(dataDir, dataDirInstalls, pluginName)
24 | }
25 |
26 | // PluginsDirectory returns the path to the plugins directory in the data dir
27 | func PluginsDirectory(dataDir string) string {
28 | return filepath.Join(dataDir, dataDirPlugins)
29 | }
30 |
31 | // PluginDirectory returns the directory a plugin with a given name would be in
32 | // if it were installed
33 | func PluginDirectory(dataDir, pluginName string) string {
34 | return filepath.Join(dataDir, dataDirPlugins, pluginName)
35 | }
36 |
--------------------------------------------------------------------------------
/internal/data/data_test.go:
--------------------------------------------------------------------------------
1 | package data
2 |
3 | import "testing"
4 |
5 | const testPluginName = "lua"
6 |
7 | func TestPluginDirectory(t *testing.T) {
8 | t.Run("returns new path with plugin name as last segment", func(t *testing.T) {
9 | pluginDir := PluginDirectory("~/.asdf/", testPluginName)
10 | expected := "~/.asdf/plugins/lua"
11 | if pluginDir != expected {
12 | t.Errorf("got %v, expected %v", pluginDir, expected)
13 | }
14 | })
15 | }
16 |
--------------------------------------------------------------------------------
/internal/exec/exec.go:
--------------------------------------------------------------------------------
1 | // Package exec handles replacing the asdf go process with
2 | package exec
3 |
4 | import (
5 | "syscall"
6 | )
7 |
8 | // Exec invokes syscall.Exec to exec an executable. Requires an absolute path to
9 | // executable.
10 | func Exec(executablePath string, args []string, env []string) error {
11 | return syscall.Exec(executablePath, append([]string{executablePath}, args...), env)
12 | }
13 |
--------------------------------------------------------------------------------
/internal/exec/exec_test.go:
--------------------------------------------------------------------------------
1 | package exec
2 |
3 | import (
4 | "fmt"
5 | "os"
6 | "os/exec"
7 | "testing"
8 |
9 | "github.com/rogpeppe/go-internal/testscript"
10 | )
11 |
12 | func execit() int {
13 | // Exec only works with absolute path
14 | cmdPath, _ := exec.LookPath(os.Args[1])
15 | err := Exec(cmdPath, os.Args[2:], os.Environ())
16 | if err != nil {
17 | fmt.Printf("Err: %#+v\n", err.Error())
18 | }
19 |
20 | return 0
21 | }
22 |
23 | func TestMain(m *testing.M) {
24 | os.Exit(testscript.RunMain(m, map[string]func() int{
25 | "execit": execit,
26 | }))
27 | }
28 |
29 | func TestExec(t *testing.T) {
30 | testscript.Run(t, testscript.Params{
31 | Dir: "testdata/script",
32 | })
33 | }
34 |
--------------------------------------------------------------------------------
/internal/exec/testdata/script/exec-env.txtar:
--------------------------------------------------------------------------------
1 | env ENV=foo
2 | execit echo this is a $ENV
3 | stdout 'this is a foo\n'
4 |
--------------------------------------------------------------------------------
/internal/exec/testdata/script/exec-simple.txtar:
--------------------------------------------------------------------------------
1 | execit echo this is a test
2 | stdout 'this is a test\n'
3 |
--------------------------------------------------------------------------------
/internal/execenv/execenv.go:
--------------------------------------------------------------------------------
1 | // Package execenv contains logic for generating execution environing using a plugin's
2 | // exec-env callback script if available.
3 | package execenv
4 |
5 | import (
6 | "fmt"
7 | "strings"
8 |
9 | "github.com/asdf-vm/asdf/internal/execute"
10 | "github.com/asdf-vm/asdf/internal/plugins"
11 | )
12 |
13 | const execEnvCallbackName = "exec-env"
14 |
15 | // Generate runs exec-env callback if available and captures the environment
16 | // variables it sets. It then parses them and returns them as a map.
17 | func Generate(plugin plugins.Plugin, callbackEnv map[string]string) (env map[string]string, err error) {
18 | execEnvPath, err := plugin.CallbackPath(execEnvCallbackName)
19 | if err != nil {
20 | return callbackEnv, err
21 | }
22 |
23 | var stdout strings.Builder
24 |
25 | // This is done to support the legacy behavior. exec-env is the only asdf
26 | // callback that works by exporting environment variables. Because of this,
27 | // executing the callback isn't enough. We actually need to source it (.) so
28 | // the environment variables get set, and then run `env` so they get printed
29 | // to STDOUT.
30 | expression := execute.NewExpression(fmt.Sprintf(". \"%s\"; env -0", execEnvPath), []string{})
31 | expression.Env = callbackEnv
32 | expression.Stdout = &stdout
33 | err = expression.Run()
34 |
35 | str := stdout.String()
36 | return execute.SliceToMap(strings.Split(str, "\x00")), err
37 | }
38 |
--------------------------------------------------------------------------------
/internal/execenv/execenv_test.go:
--------------------------------------------------------------------------------
1 | package execenv
2 |
3 | import (
4 | "testing"
5 |
6 | "github.com/asdf-vm/asdf/internal/config"
7 | "github.com/asdf-vm/asdf/internal/plugins"
8 | "github.com/asdf-vm/asdf/internal/repotest"
9 | "github.com/stretchr/testify/assert"
10 | )
11 |
12 | const (
13 | testPluginName = "lua"
14 | testPluginName2 = "ruby"
15 | )
16 |
17 | func TestGenerate(t *testing.T) {
18 | t.Run("returns map of environment variables", func(t *testing.T) {
19 | testDataDir := t.TempDir()
20 | conf := config.Config{DataDir: testDataDir}
21 | _, err := repotest.InstallPlugin("dummy_plugin", testDataDir, testPluginName)
22 | assert.Nil(t, err)
23 | plugin := plugins.New(conf, testPluginName)
24 | assert.Nil(t, repotest.WritePluginCallback(plugin.Dir, "exec-env", "#!/usr/bin/env bash\nexport BAZ=bar"))
25 | env, err := Generate(plugin, map[string]string{"ASDF_INSTALL_VERSION": "test"})
26 | assert.Nil(t, err)
27 | assert.Equal(t, "bar", env["BAZ"])
28 | assert.Equal(t, "test", env["ASDF_INSTALL_VERSION"])
29 | })
30 |
31 | t.Run("returns error when plugin lacks exec-env callback", func(t *testing.T) {
32 | testDataDir := t.TempDir()
33 | conf := config.Config{DataDir: testDataDir}
34 | _, err := repotest.InstallPlugin("dummy_plugin", testDataDir, testPluginName2)
35 | assert.Nil(t, err)
36 | plugin := plugins.New(conf, testPluginName2)
37 | env, err := Generate(plugin, map[string]string{})
38 | assert.Equal(t, err.(plugins.NoCallbackError).Error(), "Plugin named ruby does not have a callback named exec-env")
39 | _, found := env["FOO"]
40 | assert.False(t, found)
41 | })
42 |
43 | t.Run("preserves environment variables that contain equals sign in value", func(t *testing.T) {
44 | testDataDir := t.TempDir()
45 | conf := config.Config{DataDir: testDataDir}
46 | _, err := repotest.InstallPlugin("dummy_plugin", testDataDir, testPluginName)
47 | assert.Nil(t, err)
48 | plugin := plugins.New(conf, testPluginName)
49 | assert.Nil(t, repotest.WritePluginCallback(plugin.Dir, "exec-env", "#!/usr/bin/env bash\nexport BAZ=bar"))
50 | env, err := Generate(plugin, map[string]string{"EQUALSTEST": "abc=123"})
51 | assert.Nil(t, err)
52 | assert.Equal(t, "bar", env["BAZ"])
53 | assert.Equal(t, "abc=123", env["EQUALSTEST"])
54 | })
55 |
56 | t.Run("preserves environment variables that contain equals sign in value", func(t *testing.T) {
57 | testDataDir := t.TempDir()
58 | conf := config.Config{DataDir: testDataDir}
59 | _, err := repotest.InstallPlugin("dummy_plugin", testDataDir, testPluginName)
60 | assert.Nil(t, err)
61 | plugin := plugins.New(conf, testPluginName)
62 | assert.Nil(t, repotest.WritePluginCallback(plugin.Dir, "exec-env", "#!/usr/bin/env bash\nexport BAZ=bar"))
63 | env, err := Generate(plugin, map[string]string{"EQUALSTEST": "abc\n123"})
64 | assert.Nil(t, err)
65 | assert.Equal(t, "bar", env["BAZ"])
66 | assert.Equal(t, "abc\n123", env["EQUALSTEST"])
67 | })
68 |
69 | t.Run("preserves environment variables that contain equals sign and line breaks in value", func(t *testing.T) {
70 | value := "-----BEGIN CERTIFICATE-----\nMANY\\LINES\\THE\nLAST\\ONE\\ENDS\\IN\nAN=\n-----END CERTIFICATE-----"
71 | testDataDir := t.TempDir()
72 | conf := config.Config{DataDir: testDataDir}
73 | _, err := repotest.InstallPlugin("dummy_plugin", testDataDir, testPluginName)
74 | assert.Nil(t, err)
75 | plugin := plugins.New(conf, testPluginName)
76 | assert.Nil(t, repotest.WritePluginCallback(plugin.Dir, "exec-env", "#!/usr/bin/env bash\nexport BAZ=\""+value+"\""))
77 | env, err := Generate(plugin, map[string]string{})
78 | assert.Nil(t, err)
79 | assert.Equal(t, value, env["BAZ"])
80 | })
81 | }
82 |
--------------------------------------------------------------------------------
/internal/execute/execute.go:
--------------------------------------------------------------------------------
1 | // Package execute is a simple package that wraps the os/exec Command features
2 | // for convenient use in asdf. It was inspired by
3 | // https://github.com/chen-keinan/go-command-eval
4 | package execute
5 |
6 | import (
7 | "fmt"
8 | "io"
9 | "os"
10 | "os/exec"
11 | "strings"
12 | )
13 |
14 | // Command represents a Bash command that can be executed by asdf
15 | type Command struct {
16 | Command string
17 | Expression string
18 | Args []string
19 | Stdin io.Reader
20 | Stdout io.Writer
21 | Stderr io.Writer
22 | Env map[string]string
23 | }
24 |
25 | // New takes a string containing the path to a Bash script, and a slice of
26 | // string arguments and returns a Command struct
27 | func New(command string, args []string) Command {
28 | return Command{Command: command, Args: args}
29 | }
30 |
31 | // NewExpression takes a string containing a Bash expression and a slice of
32 | // string arguments and returns a Command struct
33 | func NewExpression(expression string, args []string) Command {
34 | return Command{Expression: expression, Args: args}
35 | }
36 |
37 | // Run executes a Command with Bash and returns the error if there is one
38 | func (c Command) Run() error {
39 | var command string
40 | if c.Expression != "" {
41 | // Expressions need to be invoked inside a Bash function, so variables like
42 | // $0 and $@ are available
43 | command = fmt.Sprintf("fn() { %s; }; fn %s", c.Expression, formatArgString(c.Args))
44 | } else {
45 | // Scripts can be invoked directly, with args provided
46 | command = fmt.Sprintf("%s %s", c.Command, formatArgString(c.Args))
47 | }
48 |
49 | cmd := exec.Command("bash", "-c", command)
50 |
51 | if len(c.Env) > 0 {
52 | cmd.Env = MergeWithCurrentEnv(c.Env)
53 | } else {
54 | cmd.Env = os.Environ()
55 | }
56 |
57 | cmd.Stdin = c.Stdin
58 |
59 | // Capture stdout and stderr
60 | cmd.Stdout = c.Stdout
61 | cmd.Stderr = c.Stderr
62 |
63 | return cmd.Run()
64 | }
65 |
66 | // MergeWithCurrentEnv merges the provided map into the current environment variables
67 | func MergeWithCurrentEnv(env map[string]string) (slice []string) {
68 | return MapToSlice(MergeEnv(CurrentEnv(), env))
69 | }
70 |
71 | // CurrentEnv returns the current environment as a map
72 | func CurrentEnv() map[string]string {
73 | return SliceToMap(os.Environ())
74 | }
75 |
76 | // MergeEnv takes two maps with string keys and values and merges them.
77 | func MergeEnv(map1, map2 map[string]string) map[string]string {
78 | for key, value := range map2 {
79 | map1[key] = value
80 | }
81 |
82 | return map1
83 | }
84 |
85 | // MapToSlice converts an env map to env slice suitable for syscall.Exec
86 | func MapToSlice(env map[string]string) (slice []string) {
87 | for key, value := range env {
88 | slice = append(slice, fmt.Sprintf("%s=%s", key, value))
89 | }
90 |
91 | return slice
92 | }
93 |
94 | // SliceToMap converts an env map to env slice suitable for syscall.Exec
95 | func SliceToMap(env []string) map[string]string {
96 | envMap := map[string]string{}
97 |
98 | for _, envVar := range env {
99 | varValue := strings.SplitN(envVar, "=", 2)
100 |
101 | if len(varValue) == 2 {
102 | envMap[varValue[0]] = varValue[1]
103 | }
104 | }
105 |
106 | return envMap
107 | }
108 |
109 | func formatArgString(args []string) string {
110 | var newArgs []string
111 | for _, str := range args {
112 | newArgs = append(newArgs, fmt.Sprintf("\"%s\"", str))
113 | }
114 | return strings.Join(newArgs, " ")
115 | }
116 |
--------------------------------------------------------------------------------
/internal/execute/testdata/script:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | echo $@
4 |
--------------------------------------------------------------------------------
/internal/hook/hook.go:
--------------------------------------------------------------------------------
1 | // Package hook provides a simple interface for running hook commands that may
2 | // be defined in the asdfrc file
3 | package hook
4 |
5 | import (
6 | "io"
7 | "os"
8 |
9 | "github.com/asdf-vm/asdf/internal/config"
10 | "github.com/asdf-vm/asdf/internal/execute"
11 | )
12 |
13 | // Run gets a hook command from config and runs it with the provided arguments.
14 | // Output is sent to STDOUT and STDERR
15 | func Run(conf config.Config, hookName string, arguments []string) error {
16 | return RunWithOutput(conf, hookName, arguments, os.Stdout, os.Stderr)
17 | }
18 |
19 | // RunWithOutput gets a hook command from config and runs it with the provided
20 | // arguments. Output is sent to the provided io.Writers.
21 | func RunWithOutput(config config.Config, hookName string, arguments []string, stdOut io.Writer, stdErr io.Writer) error {
22 | hookCmd, err := config.GetHook(hookName)
23 | if err != nil {
24 | return err
25 | }
26 |
27 | if hookCmd == "" {
28 | return nil
29 | }
30 |
31 | cmd := execute.NewExpression(hookCmd, arguments)
32 |
33 | cmd.Stdout = stdOut
34 | cmd.Stderr = stdErr
35 |
36 | return cmd.Run()
37 | }
38 |
--------------------------------------------------------------------------------
/internal/hook/hook_test.go:
--------------------------------------------------------------------------------
1 | package hook
2 |
3 | import (
4 | "os/exec"
5 | "testing"
6 |
7 | "github.com/asdf-vm/asdf/internal/config"
8 | "github.com/stretchr/testify/assert"
9 | )
10 |
11 | func TestRun(t *testing.T) {
12 | // Set the asdf config file location to the test file
13 | t.Setenv("ASDF_CONFIG_FILE", "testdata/asdfrc")
14 |
15 | t.Run("accepts config, hook name, and a slice of string arguments", func(t *testing.T) {
16 | config, err := config.LoadConfig()
17 | assert.Nil(t, err)
18 |
19 | err = Run(config, "pre_asdf_plugin_add_test", []string{})
20 | assert.Nil(t, err)
21 | })
22 |
23 | t.Run("passes argument to command", func(t *testing.T) {
24 | config, err := config.LoadConfig()
25 | assert.Nil(t, err)
26 |
27 | err = Run(config, "pre_asdf_plugin_add_test2", []string{"123"})
28 | assert.Equal(t, 123, err.(*exec.ExitError).ExitCode())
29 | })
30 |
31 | t.Run("passes arguments to command", func(t *testing.T) {
32 | config, err := config.LoadConfig()
33 | assert.Nil(t, err)
34 |
35 | err = Run(config, "pre_asdf_plugin_add_test3", []string{"exit 123"})
36 | assert.Equal(t, 123, err.(*exec.ExitError).ExitCode())
37 | })
38 |
39 | t.Run("does not return error when no such hook is defined in asdfrc", func(t *testing.T) {
40 | config, err := config.LoadConfig()
41 | assert.Nil(t, err)
42 |
43 | err = Run(config, "nonexistent-hook", []string{})
44 | assert.Nil(t, err)
45 | })
46 | }
47 |
--------------------------------------------------------------------------------
/internal/hook/testdata/asdfrc:
--------------------------------------------------------------------------------
1 | # This is a test asdfrc file containing all possible values. Each field to set
2 | # to a value that is different than the default.
3 |
4 | # Hooks
5 | pre_asdf_plugin_add = echo Executing with args: $@
6 | pre_asdf_plugin_add_test = echo Executing with args: $@
7 | pre_asdf_plugin_add_test2 = exit $1
8 | pre_asdf_plugin_add_test3 = eval $@
9 |
--------------------------------------------------------------------------------
/internal/info/info.go:
--------------------------------------------------------------------------------
1 | // Package info exists to print important info about this asdf installation to STDOUT for use in debugging and bug reports.
2 | package info
3 |
4 | import (
5 | "fmt"
6 | "io"
7 | "os"
8 | "text/tabwriter"
9 |
10 | "github.com/asdf-vm/asdf/internal/config"
11 | "github.com/asdf-vm/asdf/internal/execute"
12 | "github.com/asdf-vm/asdf/internal/plugins"
13 | )
14 |
15 | // Print info output to STDOUT
16 | func Print(conf config.Config, version string) error {
17 | return Write(conf, version, os.Stdout)
18 | }
19 |
20 | // Write info output to an io.Writer
21 | func Write(conf config.Config, version string, writer io.Writer) error {
22 | fmt.Fprintln(writer, "OS:")
23 | uname := execute.NewExpression("uname -a", []string{})
24 | uname.Stdout = writer
25 | err := uname.Run()
26 | if err != nil {
27 | return err
28 | }
29 |
30 | fmt.Fprintln(writer, "\nSHELL:")
31 | shellVersion := execute.NewExpression("$SHELL --version", []string{})
32 | shellVersion.Stdout = writer
33 | err = shellVersion.Run()
34 | if err != nil {
35 | return err
36 | }
37 |
38 | fmt.Fprintln(writer, "\nBASH VERSION:")
39 | bashVersion := execute.NewExpression("echo $BASH_VERSION", []string{})
40 | bashVersion.Stdout = writer
41 | err = bashVersion.Run()
42 | if err != nil {
43 | return err
44 | }
45 |
46 | fmt.Fprintln(writer, "\nASDF VERSION:")
47 | fmt.Fprintf(writer, "%s\n", version)
48 |
49 | fmt.Fprintln(writer, "\nASDF INTERNAL VARIABLES:")
50 | fmt.Fprintf(writer, "ASDF_DEFAULT_TOOL_VERSIONS_FILENAME=%s\n", conf.DefaultToolVersionsFilename)
51 | fmt.Fprintf(writer, "ASDF_DATA_DIR=%s\n", conf.DataDir)
52 | fmt.Fprintf(writer, "ASDF_CONFIG_FILE=%s\n", conf.ConfigFile)
53 |
54 | fmt.Fprintln(writer, "\nASDF INSTALLED PLUGINS:")
55 | plugins, err := plugins.List(conf, true, true)
56 | if err != nil {
57 | fmt.Fprintf(writer, "error loading plugin list: %s", err)
58 | return err
59 | }
60 |
61 | pluginsTable(plugins, writer)
62 |
63 | return nil
64 | }
65 |
66 | func pluginsTable(plugins []plugins.Plugin, output io.Writer) error {
67 | writer := tabwriter.NewWriter(output, 10, 4, 1, ' ', 0)
68 |
69 | for _, plugin := range plugins {
70 | fmt.Fprintf(writer, "%s\t%s\t%s\n", plugin.Name, plugin.URL, plugin.Ref)
71 | }
72 |
73 | return writer.Flush()
74 | }
75 |
--------------------------------------------------------------------------------
/internal/info/info_test.go:
--------------------------------------------------------------------------------
1 | package info
2 |
3 | import (
4 | "os"
5 | "path/filepath"
6 | "strings"
7 | "testing"
8 |
9 | "github.com/asdf-vm/asdf/internal/config"
10 | "github.com/stretchr/testify/assert"
11 | )
12 |
13 | func TestWrite(t *testing.T) {
14 | testDataDir := t.TempDir()
15 | err := os.MkdirAll(filepath.Join(testDataDir, "plugins"), 0o777)
16 | assert.Nil(t, err)
17 |
18 | conf := config.Config{DataDir: testDataDir}
19 | var stdout strings.Builder
20 |
21 | err = Write(conf, "0.15.0", &stdout)
22 | assert.Nil(t, err)
23 | output := stdout.String()
24 |
25 | // Simple format assertions
26 | assert.True(t, strings.Contains(output, "OS:\n"))
27 | assert.True(t, strings.Contains(output, "BASH VERSION:\n"))
28 | assert.True(t, strings.Contains(output, "SHELL:\n"))
29 | assert.True(t, strings.Contains(output, "ASDF VERSION:\n"))
30 | assert.True(t, strings.Contains(output, "INTERNAL VARIABLES:\n"))
31 | assert.True(t, strings.Contains(output, "ASDF INSTALLED PLUGINS:\n"))
32 | }
33 |
--------------------------------------------------------------------------------
/internal/installs/installs.go:
--------------------------------------------------------------------------------
1 | // Package installs contains tool installation logic. It is "dumb" when it comes
2 | // to versions and treats versions as opaque strings. It cannot depend on the
3 | // versions package because the versions package relies on this page.
4 | package installs
5 |
6 | import (
7 | "io/fs"
8 | "os"
9 | "path/filepath"
10 |
11 | "github.com/asdf-vm/asdf/internal/config"
12 | "github.com/asdf-vm/asdf/internal/data"
13 | "github.com/asdf-vm/asdf/internal/plugins"
14 | "github.com/asdf-vm/asdf/internal/toolversions"
15 | )
16 |
17 | // Installed returns a slice of all installed versions for a given plugin
18 | func Installed(conf config.Config, plugin plugins.Plugin) (versions []string, err error) {
19 | installDirectory := data.InstallDirectory(conf.DataDir, plugin.Name)
20 | files, err := os.ReadDir(installDirectory)
21 | if err != nil {
22 | if _, ok := err.(*fs.PathError); ok {
23 | return versions, nil
24 | }
25 |
26 | return versions, err
27 | }
28 |
29 | for _, file := range files {
30 | if !file.IsDir() {
31 | continue
32 | }
33 |
34 | versions = append(versions, toolversions.VersionStringFromFSFormat(file.Name()))
35 | }
36 |
37 | return versions, err
38 | }
39 |
40 | // InstallPath returns the path to a tool installation
41 | func InstallPath(conf config.Config, plugin plugins.Plugin, version toolversions.Version) string {
42 | if version.Type == "path" {
43 | return version.Value
44 | }
45 |
46 | return filepath.Join(data.InstallDirectory(conf.DataDir, plugin.Name), toolversions.FormatForFS(version))
47 | }
48 |
49 | // DownloadPath returns the download path for a particular plugin and version
50 | func DownloadPath(conf config.Config, plugin plugins.Plugin, version toolversions.Version) string {
51 | if version.Type == "path" {
52 | return ""
53 | }
54 |
55 | return filepath.Join(data.DownloadDirectory(conf.DataDir, plugin.Name), toolversions.FormatForFS(version))
56 | }
57 |
58 | // IsInstalled checks if a specific version of a tool is installed
59 | func IsInstalled(conf config.Config, plugin plugins.Plugin, version toolversions.Version) bool {
60 | installDir := InstallPath(conf, plugin, version)
61 |
62 | // Check if version already installed
63 | _, err := os.Stat(installDir)
64 | return !os.IsNotExist(err)
65 | }
66 |
--------------------------------------------------------------------------------
/internal/installtest/installtest.go:
--------------------------------------------------------------------------------
1 | // Package installtest provides functions used by various asdf tests for
2 | // installing versions of tools. It provides a simplified version of the
3 | // versions.InstallOneVersion function.
4 | package installtest
5 |
6 | import (
7 | "fmt"
8 | "os"
9 | "path/filepath"
10 | "strings"
11 |
12 | "github.com/asdf-vm/asdf/internal/config"
13 | "github.com/asdf-vm/asdf/internal/plugins"
14 | "github.com/asdf-vm/asdf/internal/toolversions"
15 | )
16 |
17 | const (
18 | dataDirInstalls = "installs"
19 | dataDirDownloads = "downloads"
20 | )
21 |
22 | // InstallOneVersion is a simplified version of versions.InstallOneVersion
23 | // function for use in Go tests.
24 | func InstallOneVersion(conf config.Config, plugin plugins.Plugin, versionType, version string) error {
25 | var stdOut strings.Builder
26 | var stdErr strings.Builder
27 |
28 | err := plugin.Exists()
29 | if err != nil {
30 | return err
31 | }
32 |
33 | downloadDir := DownloadPath(conf, plugin, version)
34 | installDir := InstallPath(conf, plugin, version)
35 |
36 | env := map[string]string{
37 | "ASDF_INSTALL_TYPE": versionType,
38 | "ASDF_INSTALL_VERSION": version,
39 | "ASDF_INSTALL_PATH": installDir,
40 | "ASDF_DOWNLOAD_PATH": downloadDir,
41 | "ASDF_CONCURRENCY": "1",
42 | }
43 |
44 | err = os.MkdirAll(downloadDir, 0o777)
45 | if err != nil {
46 | return fmt.Errorf("unable to create download dir: %w", err)
47 | }
48 |
49 | err = plugin.RunCallback("download", []string{}, env, &stdOut, &stdErr)
50 | if _, ok := err.(plugins.NoCallbackError); err != nil && !ok {
51 | return fmt.Errorf("failed to run download callback: %w", err)
52 | }
53 |
54 | err = os.MkdirAll(installDir, 0o777)
55 | if err != nil {
56 | return fmt.Errorf("unable to create install dir: %w", err)
57 | }
58 |
59 | err = plugin.RunCallback("install", []string{}, env, &stdOut, &stdErr)
60 | if err != nil {
61 | return fmt.Errorf("failed to run install callback: %w", err)
62 | }
63 |
64 | return nil
65 | }
66 |
67 | // InstallPath returns the path to a tool installation
68 | func InstallPath(conf config.Config, plugin plugins.Plugin, version string) string {
69 | return filepath.Join(pluginInstallPath(conf, plugin), formatVersionStringForFS(version))
70 | }
71 |
72 | // DownloadPath returns the download path for a particular plugin and version
73 | func DownloadPath(conf config.Config, plugin plugins.Plugin, version string) string {
74 | return filepath.Join(conf.DataDir, dataDirDownloads, plugin.Name, formatVersionStringForFS(version))
75 | }
76 |
77 | func pluginInstallPath(conf config.Config, plugin plugins.Plugin) string {
78 | return filepath.Join(conf.DataDir, dataDirInstalls, plugin.Name)
79 | }
80 |
81 | func formatVersionStringForFS(version string) string {
82 | return toolversions.FormatForFS(toolversions.Parse(version))
83 | }
84 |
--------------------------------------------------------------------------------
/internal/paths/paths.go:
--------------------------------------------------------------------------------
1 | // Package paths contains a variety of helper functions responsible for
2 | // computing paths to various things. This package should not depend on any
3 | // other asdf packages.
4 | package paths
5 |
6 | import (
7 | "strings"
8 | )
9 |
10 | // RemoveFromPath returns the PATH without asdf shims path
11 | func RemoveFromPath(currentPath, pathToRemove string) string {
12 | var newPaths []string
13 |
14 | for _, fspath := range strings.Split(currentPath, ":") {
15 | if fspath != pathToRemove {
16 | newPaths = append(newPaths, fspath)
17 | }
18 | }
19 |
20 | return strings.Join(newPaths, ":")
21 | }
22 |
--------------------------------------------------------------------------------
/internal/paths/paths_test.go:
--------------------------------------------------------------------------------
1 | package paths
2 |
3 | import (
4 | "testing"
5 |
6 | "github.com/stretchr/testify/assert"
7 | )
8 |
9 | func TestRemoveFromPath(t *testing.T) {
10 | t.Run("returns PATH string with matching path removed", func(t *testing.T) {
11 | got := RemoveFromPath("/foo/bar:/baz/bim:/home/user/bin", "/baz/bim")
12 | assert.Equal(t, got, "/foo/bar:/home/user/bin")
13 | })
14 |
15 | t.Run("returns PATH string with multiple matching paths removed", func(t *testing.T) {
16 | got := RemoveFromPath("/foo/bar:/baz/bim:/baz/bim:/home/user/bin", "/baz/bim")
17 | assert.Equal(t, got, "/foo/bar:/home/user/bin")
18 | })
19 |
20 | t.Run("returns PATH string unchanged when no matching path found", func(t *testing.T) {
21 | got := RemoveFromPath("/foo/bar:/baz/bim:/home/user/bin", "/path-not-present/")
22 | assert.Equal(t, got, "/foo/bar:/baz/bim:/home/user/bin")
23 | })
24 | }
25 |
--------------------------------------------------------------------------------
/internal/resolve/testdata/asdfrc:
--------------------------------------------------------------------------------
1 | legacy_version_file = yes
2 |
--------------------------------------------------------------------------------
/internal/shims/testdata/asdfrc:
--------------------------------------------------------------------------------
1 | pre_asdf_reshim_lua = echo pre_reshim $@
2 | post_asdf_reshim_lua = echo post_reshim $@
3 |
--------------------------------------------------------------------------------
/internal/versions/testdata/asdfrc:
--------------------------------------------------------------------------------
1 | pre_asdf_download_testlua = echo pre_asdf_download_lua $@
2 | pre_asdf_install_testlua = echo pre_asdf_install_lua $@
3 | post_asdf_install_testlua = echo post_asdf_install_lua $@
4 | always_keep_download = yes
5 |
--------------------------------------------------------------------------------
/internal/versions/testdata/uninstall-asdfrc:
--------------------------------------------------------------------------------
1 | pre_asdf_uninstall_uninstall-test = echo pre_asdf_uninstall_test $@
2 | post_asdf_uninstall_uninstall-test = echo post_asdf_uninstall_test $@
3 |
--------------------------------------------------------------------------------
/lib/commands/command-current.bash:
--------------------------------------------------------------------------------
1 | # -*- sh -*-
2 | # shellcheck source=lib/functions/plugins.bash
3 | . "$(dirname "$(dirname "$0")")/lib/functions/plugins.bash"
4 |
5 | # shellcheck disable=SC2059
6 | plugin_current_command() {
7 | local plugin_name=$1
8 | local terminal_format=$2
9 |
10 | check_if_plugin_exists "$plugin_name"
11 |
12 | local search_path
13 | search_path=$PWD
14 | local version_and_path
15 | version_and_path=$(find_versions "$plugin_name" "$search_path")
16 | local full_version
17 | full_version=$(cut -d '|' -f 1 <<<"$version_and_path")
18 | local version_file_path
19 | version_file_path=$(cut -d '|' -f 2 <<<"$version_and_path")
20 | local version_not_installed
21 | local description=""
22 |
23 | IFS=' ' read -r -a versions <<<"$full_version"
24 | for version in "${versions[@]}"; do
25 | if ! (check_if_version_exists "$plugin_name" "$version"); then
26 | version_not_installed="$version"
27 | fi
28 | done
29 | check_for_deprecated_plugin "$plugin_name"
30 |
31 | if [ -n "$version_not_installed" ]; then
32 | description="Not installed. Run \"asdf install $plugin $version\""
33 | printf "$terminal_format" "$plugin" "$version" "$description" 1>&2
34 | return 1
35 | elif [ -z "$full_version" ]; then
36 | description="No version is set. Run \"asdf $plugin \""
37 | printf "$terminal_format" "$plugin" "______" "$description" 1>&2
38 | return 126
39 | else
40 | description="$version_file_path"
41 | printf "$terminal_format" "$plugin" "$full_version" "$description"
42 | fi
43 | }
44 |
45 | # shellcheck disable=SC2059
46 | current_command() {
47 | local terminal_format="%-15s %-15s %-10s\n"
48 | local exit_status=0
49 | local plugin
50 |
51 | # printf "$terminal_format" "PLUGIN" "VERSION" "SET BY CONFIG" # disable this until we release headings across the board
52 | if [ $# -eq 0 ]; then
53 | # shellcheck disable=SC2119
54 | for plugin in $(plugin_list_command); do
55 | plugin_current_command "$plugin" "$terminal_format"
56 | done
57 | else
58 | plugin=$1
59 | plugin_current_command "$plugin" "$terminal_format"
60 | exit_status="$?"
61 | fi
62 |
63 | exit "$exit_status"
64 | }
65 |
66 | # Warn if the plugin isn't using the updated legacy file api.
67 | check_for_deprecated_plugin() {
68 | local plugin_name=$1
69 |
70 | local plugin_path
71 | plugin_path=$(get_plugin_path "$plugin_name")
72 | local legacy_config
73 | legacy_config=$(get_asdf_config_value "legacy_version_file")
74 | local deprecated_script="${plugin_path}/bin/get-version-from-legacy-file"
75 | local new_script="${plugin_path}/bin/list-legacy-filenames"
76 |
77 | if [ "$legacy_config" = "yes" ] && [ -f "$deprecated_script" ] && [ ! -f "$new_script" ]; then
78 | printf "Heads up! It looks like your %s plugin is out of date. You can update it with:\n\n" "$plugin_name"
79 | printf " asdf plugin-update %s\n\n" "$plugin_name"
80 | fi
81 | }
82 |
83 | current_command "$@"
84 |
--------------------------------------------------------------------------------
/lib/commands/command-env.bash:
--------------------------------------------------------------------------------
1 | # -*- sh -*-
2 |
3 | shim_env_command() {
4 | local shim_name="$1"
5 | local env_cmd="${2}"
6 | local env_args=("${@:3}")
7 |
8 | if [ -z "$shim_name" ]; then
9 | printf "usage: asdf env \n"
10 | exit 1
11 | fi
12 |
13 | if [ -z "$env_cmd" ]; then
14 | env_cmd="env"
15 | fi
16 |
17 | shim_env() {
18 | "$env_cmd" "${env_args[@]}"
19 | }
20 |
21 | with_shim_executable "$shim_name" shim_env || exit $?
22 | }
23 |
24 | shim_env_command "$@"
25 |
--------------------------------------------------------------------------------
/lib/commands/command-exec.bash:
--------------------------------------------------------------------------------
1 | # -*- sh -*-
2 |
3 | shim_exec_command() {
4 | local shim_name
5 | shim_name=$(basename "$1")
6 | local shim_args=("${@:2}")
7 |
8 | if [ -z "$shim_name" ]; then
9 | printf "usage: asdf exec \n"
10 | exit 1
11 | fi
12 |
13 | exec_shim() {
14 | local plugin_name="$1"
15 | local version="$2"
16 | local executable_path="$3"
17 |
18 | if [ ! -x "$executable_path" ]; then
19 | printf "No %s executable found for %s %s\n" "$shim_name" "$plugin_name" "$version" >&2
20 | exit 2
21 | fi
22 |
23 | asdf_run_hook "pre_${plugin_name}_${shim_name}" "${shim_args[@]}"
24 | pre_status=$?
25 | if [ "$pre_status" -ne 0 ]; then
26 | return "$pre_status"
27 | fi
28 | exec "$executable_path" "${shim_args[@]}"
29 | }
30 |
31 | with_shim_executable "$shim_name" exec_shim || exit $?
32 | }
33 |
34 | shim_exec_command "$@"
35 |
--------------------------------------------------------------------------------
/lib/commands/command-export-shell-version.bash:
--------------------------------------------------------------------------------
1 | # -*- sh -*-
2 | # shellcheck source=lib/functions/versions.bash
3 | . "$(dirname "$(dirname "$0")")/lib/functions/versions.bash"
4 |
5 | # Output from this command must be executable shell code
6 | shell_command() {
7 | local asdf_shell="$1"
8 | shift
9 |
10 | if [ "$#" -lt "2" ]; then
11 | printf "Usage: asdf shell {|--unset}\n" >&2
12 | printf "false\n"
13 | exit 1
14 | fi
15 |
16 | local plugin=$1
17 | local version=$2
18 |
19 | local upcase_name
20 | upcase_name=$(tr '[:lower:]-' '[:upper:]_' <<<"$plugin")
21 | local version_env_var="ASDF_${upcase_name}_VERSION"
22 |
23 | if [ "$version" = "--unset" ]; then
24 | case "$asdf_shell" in
25 | fish)
26 | printf "set -e %s\n" "$version_env_var"
27 | ;;
28 | elvish)
29 | # Elvish doesn't have a `source` command, and eval is banned, so the
30 | # var name and value are printed on separate lines for asdf.elv to parse
31 | # and pass to unset-env.
32 | printf "unset-env\n%s" "$version_env_var"
33 | ;;
34 | pwsh)
35 | printf '%s\n' "if (\$(Test-Path Env:$version_env_var) -eq 'True') { Remove-Item Env:$version_env_var }"
36 | ;;
37 | *)
38 | printf "unset %s\n" "$version_env_var"
39 | ;;
40 | esac
41 | exit 0
42 | fi
43 | if [ "$version" = "latest" ]; then
44 | version=$(latest_command "$plugin")
45 | fi
46 | if ! (check_if_version_exists "$plugin" "$version"); then
47 | version_not_installed_text "$plugin" "$version" 1>&2
48 | printf "false\n"
49 | exit 1
50 | fi
51 |
52 | case "$asdf_shell" in
53 | fish)
54 | printf "set -gx %s \"%s\"\n" "$version_env_var" "$version"
55 | ;;
56 | elvish)
57 | # Elvish doesn't have a `source` command, and eval is banned, so the
58 | # var name and value are printed on separate lines for asdf.elv to parse
59 | # and pass to set-env.
60 | printf "set-env\n%s\n%s" "$version_env_var" "$version"
61 | ;;
62 | pwsh)
63 | printf '%s\n' "\$Env:$version_env_var = '$version'"
64 | ;;
65 | *)
66 | printf "export %s=\"%s\"\n" "$version_env_var" "$version"
67 | ;;
68 | esac
69 | }
70 |
71 | shell_command "$@"
72 |
--------------------------------------------------------------------------------
/lib/commands/command-global.bash:
--------------------------------------------------------------------------------
1 | # -*- sh -*-
2 |
3 | # shellcheck source=lib/commands/version_commands.bash
4 | . "$(dirname "$ASDF_CMD_FILE")/version_commands.bash"
5 | version_command global "$@"
6 |
--------------------------------------------------------------------------------
/lib/commands/command-help.bash:
--------------------------------------------------------------------------------
1 | # -*- sh -*-
2 | # shellcheck source=lib/functions/versions.bash
3 | . "$(dirname "$(dirname "$0")")/lib/functions/versions.bash"
4 |
5 | asdf_help() {
6 | printf "version: %s\n\n" "$(asdf_version)"
7 | cat "$(asdf_dir)/help.txt"
8 | }
9 |
10 | asdf_moto() {
11 | cat </dev/null)"
25 | if [[ -n $ext_cmds ]]; then
26 | printf "\nPLUGIN %s\n" "$plugin"
27 | for ext_cmd in $ext_cmds; do
28 | ext_cmd_name="$(basename "$ext_cmd")"
29 | sed "s/-/ /g;s/.bash//;s/command-*/ asdf $plugin/;" <<<"$ext_cmd_name"
30 | done | sort
31 | fi
32 | done
33 | }
34 |
35 | help_command() {
36 | local plugin_name="$1"
37 | local tool_version="$2"
38 | local plugin_path
39 |
40 | # If plugin name is present as first argument output plugin help info
41 | if [ -n "$plugin_name" ]; then
42 | plugin_path=$(get_plugin_path "$plugin_name")
43 |
44 | if [ -d "$plugin_path" ]; then
45 | if [ -f "${plugin_path}/bin/help.overview" ]; then
46 | if [ -n "$tool_version" ]; then
47 |
48 | # TODO: Refactor this code out into helper functions in utils.bash
49 | IFS=':' read -r -a version_info <<<"$tool_version"
50 | if [ "${version_info[0]}" = "ref" ]; then
51 | local install_type="${version_info[0]}"
52 | local version="${version_info[1]}"
53 | else
54 | local install_type="version"
55 |
56 | if [ "${version_info[0]}" = "latest" ]; then
57 | local version
58 | version=$(latest_command "$plugin_name" "${version_info[1]}")
59 | else
60 | local version="${version_info[0]}"
61 | fi
62 | fi
63 |
64 | local install_path
65 | install_path=$(get_install_path "$plugin_name" "$install_type" "$version")
66 |
67 | (
68 | # shellcheck disable=SC2031
69 | export ASDF_INSTALL_TYPE=$install_type
70 | # shellcheck disable=SC2031
71 | export ASDF_INSTALL_VERSION=$version
72 | # shellcheck disable=SC2031
73 | export ASDF_INSTALL_PATH=$install_path
74 |
75 | print_plugin_help "$plugin_path"
76 | )
77 | else
78 | (print_plugin_help "$plugin_path")
79 | fi
80 | else
81 | printf "No documentation for plugin %s\n" "$plugin_name" >&2
82 | exit 1
83 | fi
84 | else
85 | printf "No plugin named %s\n" "$plugin_name" >&2
86 | exit 1
87 | fi
88 | else
89 | # Otherwise output general asdf help
90 | asdf_help
91 | asdf_extension_cmds
92 | asdf_moto
93 | fi
94 | }
95 |
96 | print_plugin_help() {
97 | local plugin_path=$1
98 |
99 | # Eventually @jthegedus or someone else will format the output from these
100 | # scripts in a certain way.
101 | "${plugin_path}"/bin/help.overview
102 |
103 | if [ -f "${plugin_path}"/bin/help.deps ]; then
104 | "${plugin_path}"/bin/help.deps
105 | fi
106 |
107 | if [ -f "${plugin_path}"/bin/help.config ]; then
108 | "${plugin_path}"/bin/help.config
109 | fi
110 |
111 | if [ -f "${plugin_path}"/bin/help.links ]; then
112 | "${plugin_path}"/bin/help.links
113 | fi
114 | }
115 |
116 | help_command "$@"
117 |
--------------------------------------------------------------------------------
/lib/commands/command-info.bash:
--------------------------------------------------------------------------------
1 | # -*- sh -*-
2 | # shellcheck source=lib/functions/plugins.bash
3 | . "$(dirname "$(dirname "$0")")/lib/functions/plugins.bash"
4 |
5 | info_command() {
6 | printf "%s:\n%s\n\n" "OS" "$(uname -a)"
7 | printf "%s:\n%s\n\n" "SHELL" "$("$SHELL" --version)"
8 | printf "%s:\n%s\n\n" "BASH VERSION" "$BASH_VERSION"
9 | printf "%s:\n%s\n\n" "ASDF VERSION" "$(asdf_version)"
10 | printf '%s\n' 'ASDF INTERNAL VARIABLES:'
11 | printf 'ASDF_DEFAULT_TOOL_VERSIONS_FILENAME=%s\n' "${ASDF_DEFAULT_TOOL_VERSIONS_FILENAME}"
12 | printf 'ASDF_DATA_DIR=%s\n' "${ASDF_DATA_DIR}"
13 | printf 'ASDF_DIR=%s\n' "${ASDF_DIR}"
14 | printf 'ASDF_CONFIG_FILE=%s\n\n' "${ASDF_CONFIG_FILE}"
15 | printf "%s:\n%s\n\n" "ASDF INSTALLED PLUGINS" "$(plugin_list_command --urls --refs)"
16 | }
17 |
18 | info_command "$@"
19 |
--------------------------------------------------------------------------------
/lib/commands/command-install.bash:
--------------------------------------------------------------------------------
1 | # -*- sh -*-
2 | # shellcheck source=lib/functions/versions.bash
3 | . "$(dirname "$(dirname "$0")")/lib/functions/versions.bash"
4 | # shellcheck source=lib/commands/reshim.bash
5 | . "$(dirname "$ASDF_CMD_FILE")/reshim.bash"
6 | # shellcheck source=lib/functions/installs.bash
7 | . "$(dirname "$(dirname "$0")")/lib/functions/installs.bash"
8 |
9 | install_command "$@"
10 |
--------------------------------------------------------------------------------
/lib/commands/command-latest.bash:
--------------------------------------------------------------------------------
1 | # -*- sh -*-
2 | # shellcheck source=lib/functions/versions.bash
3 | . "$(dirname "$(dirname "$0")")/lib/functions/versions.bash"
4 |
5 | latest_command "$@"
6 |
--------------------------------------------------------------------------------
/lib/commands/command-list-all.bash:
--------------------------------------------------------------------------------
1 | # -*- sh -*-
2 | # shellcheck source=lib/functions/versions.bash
3 | . "$(dirname "$(dirname "$0")")/lib/functions/versions.bash"
4 |
5 | list_all_command "$@"
6 |
--------------------------------------------------------------------------------
/lib/commands/command-list.bash:
--------------------------------------------------------------------------------
1 | # -*- sh -*-
2 |
3 | list_command() {
4 | local plugin_name=$1
5 | local query=$2
6 |
7 | if [ -z "$plugin_name" ]; then
8 | local plugins_path
9 | plugins_path=$(get_plugin_path)
10 |
11 | if find "$plugins_path" -mindepth 1 -type d &>/dev/null; then
12 | for plugin_path in "$plugins_path"/*/; do
13 | plugin_name=$(basename "$plugin_path")
14 | printf "%s\n" "$plugin_name"
15 | display_installed_versions "$plugin_name" "$query"
16 | done
17 | else
18 | printf "%s\n" 'No plugins installed'
19 | fi
20 | else
21 | check_if_plugin_exists "$plugin_name"
22 | display_installed_versions "$plugin_name" "$query"
23 | fi
24 | }
25 |
26 | display_installed_versions() {
27 | local plugin_name=$1
28 | local query=$2
29 | local versions
30 | local current_version
31 | local flag
32 |
33 | versions=$(list_installed_versions "$plugin_name")
34 |
35 | if [[ $query ]]; then
36 | versions=$(printf "%s\n" "$versions" | grep -E "^\s*$query")
37 |
38 | if [ -z "${versions}" ]; then
39 | display_error "No compatible versions installed ($plugin_name $query)"
40 | exit 1
41 | fi
42 | fi
43 |
44 | if [ -n "${versions}" ]; then
45 | current_version=$(cut -d '|' -f 1 <<<"$(find_versions "$plugin_name" "$PWD")")
46 |
47 | for version in $versions; do
48 | flag=" "
49 | if [[ "$version" == "$current_version" ]]; then
50 | flag=" *"
51 | fi
52 | printf "%s%s\n" "$flag" "$version"
53 | done
54 | else
55 | display_error ' No versions installed'
56 | fi
57 | }
58 |
59 | list_command "$@"
60 |
--------------------------------------------------------------------------------
/lib/commands/command-local.bash:
--------------------------------------------------------------------------------
1 | # -*- sh -*-
2 |
3 | # shellcheck source=lib/commands/version_commands.bash
4 | . "$(dirname "$ASDF_CMD_FILE")/version_commands.bash"
5 |
6 | local_command "$@"
7 |
--------------------------------------------------------------------------------
/lib/commands/command-plugin-add.bash:
--------------------------------------------------------------------------------
1 | # -*- sh -*-
2 | # shellcheck source=lib/functions/plugins.bash
3 | . "$(dirname "$(dirname "$0")")/lib/functions/plugins.bash"
4 |
5 | plugin_add_command "$@"
6 |
--------------------------------------------------------------------------------
/lib/commands/command-plugin-list-all.bash:
--------------------------------------------------------------------------------
1 | # -*- sh -*-
2 |
3 | plugin_list_all_command() {
4 | initialize_or_update_plugin_repository
5 |
6 | local plugins_index_path
7 | plugins_index_path="$(asdf_data_dir)/repository/plugins"
8 |
9 | local plugins_local_path
10 | plugins_local_path="$(get_plugin_path)"
11 |
12 | if find "$plugins_index_path" -mindepth 1 -type d &>/dev/null; then
13 | (
14 | for index_plugin in "$plugins_index_path"/*; do
15 | index_plugin_name=$(basename "$index_plugin")
16 | source_url=$(get_plugin_source_url "$index_plugin_name")
17 | installed_flag=" "
18 |
19 | [[ -d "${plugins_local_path}/${index_plugin_name}" ]] && installed_flag='*'
20 |
21 | printf "%s\t%s\n" "$index_plugin_name" "$installed_flag$source_url"
22 | done
23 | ) | awk '{ printf("%-28s", $1); sub(/^[^*]/, " &", $2); $1=""; print $0 }'
24 | else
25 | printf "%s%s\n" "error: index of plugins not found at " "$plugins_index_path"
26 | fi
27 | }
28 |
29 | plugin_list_all_command "$@"
30 |
--------------------------------------------------------------------------------
/lib/commands/command-plugin-list.bash:
--------------------------------------------------------------------------------
1 | # -*- sh -*-
2 | # shellcheck source=lib/functions/plugins.bash
3 | . "$(dirname "$(dirname "$0")")/lib/functions/plugins.bash"
4 |
5 | plugin_list_command "$@"
6 |
--------------------------------------------------------------------------------
/lib/commands/command-plugin-push.bash:
--------------------------------------------------------------------------------
1 | # -*- sh -*-
2 |
3 | plugin_push_command() {
4 | local plugin_name=$1
5 | if [ "$plugin_name" = "--all" ]; then
6 | for dir in "$(asdf_data_dir)"/plugins/*/; do
7 | printf "Pushing %s...\n" "$(basename "$dir")"
8 | (cd "$dir" && git push)
9 | done
10 | else
11 | local plugin_path
12 | plugin_path=$(get_plugin_path "$plugin_name")
13 | check_if_plugin_exists "$plugin_name"
14 | printf "Pushing %s...\n" "$plugin_name"
15 | (cd "$plugin_path" && git push)
16 | fi
17 | }
18 |
19 | plugin_push_command "$@"
20 |
--------------------------------------------------------------------------------
/lib/commands/command-plugin-remove.bash:
--------------------------------------------------------------------------------
1 | # -*- sh -*-
2 |
3 | plugin_remove_command() {
4 | local plugin_name=$1
5 | check_if_plugin_exists "$plugin_name"
6 |
7 | local plugin_path
8 | plugin_path=$(get_plugin_path "$plugin_name")
9 |
10 | asdf_run_hook "pre_asdf_plugin_remove" "$plugin_name"
11 | asdf_run_hook "pre_asdf_plugin_remove_${plugin_name}"
12 |
13 | if [ -f "${plugin_path}/bin/pre-plugin-remove" ]; then
14 | (
15 | export ASDF_PLUGIN_PATH=$plugin_path
16 | "${plugin_path}/bin/pre-plugin-remove"
17 | )
18 | fi
19 |
20 | rm -rf "$plugin_path"
21 | rm -rf "$(asdf_data_dir)/installs/${plugin_name}"
22 | rm -rf "$(asdf_data_dir)/downloads/${plugin_name}"
23 |
24 | for f in "$(asdf_data_dir)"/shims/*; do
25 | if [ -f "$f" ]; then # nullglob may not be set
26 | if grep -q "asdf-plugin: ${plugin_name}" "$f"; then
27 | rm -f "$f"
28 | fi
29 | fi
30 | done
31 |
32 | asdf_run_hook "post_asdf_plugin_remove" "$plugin_name"
33 | asdf_run_hook "post_asdf_plugin_remove_${plugin_name}"
34 | }
35 |
36 | plugin_remove_command "$@"
37 |
--------------------------------------------------------------------------------
/lib/commands/command-plugin-update.bash:
--------------------------------------------------------------------------------
1 | # -*- sh -*-
2 | # shellcheck source=lib/functions/plugins.bash
3 | . "$(dirname "$(dirname "$0")")/lib/functions/plugins.bash"
4 |
5 | plugin_update_command "$@"
6 |
--------------------------------------------------------------------------------
/lib/commands/command-reshim.bash:
--------------------------------------------------------------------------------
1 | # -*- sh -*-
2 |
3 | # shellcheck source=lib/commands/reshim.bash
4 | . "$(dirname "$ASDF_CMD_FILE")/reshim.bash"
5 |
6 | reshim_command "$@"
7 |
--------------------------------------------------------------------------------
/lib/commands/command-shim-versions.bash:
--------------------------------------------------------------------------------
1 | # -*- sh -*-
2 |
3 | shim_versions_command() {
4 | local shim_name=$1
5 | shim_plugin_versions "$shim_name"
6 | }
7 |
8 | shim_versions_command "$@"
9 |
--------------------------------------------------------------------------------
/lib/commands/command-uninstall.bash:
--------------------------------------------------------------------------------
1 | # -*- sh -*-
2 |
3 | # shellcheck source=lib/commands/reshim.bash
4 | . "$(dirname "$ASDF_CMD_FILE")/reshim.bash"
5 |
6 | uninstall_command() {
7 | local plugin_name=$1
8 | local full_version=$2
9 | local plugin_path
10 | plugin_path=$(get_plugin_path "$plugin_name")
11 |
12 | check_if_plugin_exists "$plugin_name"
13 |
14 | IFS=':' read -r -a version_info <<<"$full_version"
15 | if [ "${version_info[0]}" = "ref" ]; then
16 | local install_type="${version_info[0]}"
17 | local version="${version_info[1]}"
18 | else
19 | local install_type="version"
20 | local version="${version_info[0]}"
21 | fi
22 |
23 | local install_path
24 | install_path=$(get_install_path "$plugin_name" "$install_type" "$version")
25 |
26 | if [ ! -d "$install_path" ]; then
27 | display_error "No such version"
28 | exit 1
29 | fi
30 |
31 | asdf_run_hook "pre_asdf_uninstall_${plugin_name}" "$full_version"
32 | remove_shims_for_version "$plugin_name" "$full_version"
33 |
34 | if [ -f "${plugin_path}/bin/uninstall" ]; then
35 | (
36 | export ASDF_INSTALL_TYPE=$install_type
37 | export ASDF_INSTALL_VERSION=$version
38 | export ASDF_INSTALL_PATH=$install_path
39 | "${plugin_path}/bin/uninstall"
40 | )
41 | else
42 | rm -rf "$install_path"
43 | fi
44 |
45 | asdf_run_hook "post_asdf_uninstall_${plugin_name}" "$full_version"
46 | }
47 |
48 | remove_shims_for_version() {
49 | local plugin_name=$1
50 | local full_version=$2
51 | for shim_path in $(plugin_shims "$plugin_name" "$full_version"); do
52 | remove_shim_for_version "$plugin_name" "$full_version" "$shim_path"
53 | done
54 | }
55 |
56 | uninstall_command "$@"
57 |
--------------------------------------------------------------------------------
/lib/commands/command-update.bash:
--------------------------------------------------------------------------------
1 | # -*- sh -*-
2 |
3 | update_command() {
4 | printf "Upgrading asdf via asdf update is no longer supported. Please use your OS\npackage manager (Homebrew, APT, etc...) to upgrade asdf or download the\nlatest asdf binary manually from the asdf website.\n\nPlease visit https://asdf-vm.com/ or https://github.com/asdf-vm/asdf for more\ndetails.\n"
5 |
6 | exit 1
7 | }
8 |
9 | update_command "$@"
10 |
--------------------------------------------------------------------------------
/lib/commands/command-version.bash:
--------------------------------------------------------------------------------
1 | # -*- sh -*-
2 | asdf_version
3 |
--------------------------------------------------------------------------------
/lib/commands/command-where.bash:
--------------------------------------------------------------------------------
1 | # -*- sh -*-
2 |
3 | where_command() {
4 | local plugin_name=$1
5 | local full_version=$2
6 | check_if_plugin_exists "$plugin_name"
7 |
8 | local version
9 | local install_type="version"
10 | if [[ -z ${full_version} ]]; then
11 | local version_and_path
12 | local versions
13 | version_and_path=$(find_versions "$plugin_name" "$PWD")
14 | versions=$(cut -d '|' -f 1 <<<"$version_and_path")
15 | IFS=' ' read -r -a plugin_versions <<<"$versions"
16 | version="${plugin_versions[0]}"
17 | else
18 | local -a version_info
19 | IFS=':' read -r -a version_info <<<"$full_version"
20 | if [ "${version_info[0]}" = "ref" ]; then
21 | install_type="${version_info[0]}"
22 | version="${version_info[1]}"
23 | else
24 | version="${version_info[0]}"
25 | fi
26 | fi
27 |
28 | if [ -z "$version" ]; then
29 | display_no_version_set "$plugin_name"
30 | exit 1
31 | fi
32 |
33 | local install_path
34 | install_path=$(get_install_path "$plugin_name" "$install_type" "$version")
35 |
36 | if [ -d "$install_path" ]; then
37 | printf "%s\n" "$install_path"
38 | exit 0
39 | else
40 | if [ "$version" = "system" ]; then
41 | printf "System version is selected\n"
42 | exit 1
43 | else
44 | printf "Version not installed\n"
45 | exit 1
46 | fi
47 | fi
48 | }
49 |
50 | where_command "$@"
51 |
--------------------------------------------------------------------------------
/lib/commands/command-which.bash:
--------------------------------------------------------------------------------
1 | # -*- sh -*-
2 |
3 | which_command() {
4 | local shim_name
5 | shim_name=$(basename "$1")
6 |
7 | if [ -z "$shim_name" ]; then
8 | printf "usage: asdf which \n"
9 | exit 1
10 | fi
11 |
12 | print_exec() {
13 | local plugin_name="$1"
14 | local version="$2"
15 | local executable_path="$3"
16 |
17 | if [ ! -x "$executable_path" ]; then
18 | printf "No %s executable found for %s %s\n" "$shim_name" "$plugin_name" "$version" >&2
19 | exit 1
20 | fi
21 |
22 | printf "%s\n" "$executable_path"
23 | exit 0
24 | }
25 |
26 | with_shim_executable "$shim_name" print_exec || exit 1
27 | }
28 |
29 | which_command "$@"
30 |
--------------------------------------------------------------------------------
/lib/commands/version_commands.bash:
--------------------------------------------------------------------------------
1 | # -*- sh -*-
2 | # shellcheck source=lib/functions/versions.bash
3 | . "$(dirname "$(dirname "$0")")/lib/functions/versions.bash"
4 |
--------------------------------------------------------------------------------
/release-please-config.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json",
3 | "packages": {
4 | ".": {
5 | "release-type": "go",
6 | "bump-minor-pre-major": true,
7 | "changelog-types": [
8 | {
9 | "type": "feat",
10 | "section": "Features",
11 | "hidden": false
12 | },
13 | {
14 | "type": "fix",
15 | "section": "Patches",
16 | "hidden": false
17 | },
18 | {
19 | "type": "docs",
20 | "section": "Documentation",
21 | "hidden": false
22 | }
23 | ],
24 | "extra-files": [
25 | "SECURITY.md",
26 | "docs/guide/getting-started.md",
27 | "docs/pt-br/guide/getting-started.md",
28 | "docs/zh-hans/guide/getting-started.md",
29 | "docs/ko-kr/guide/getting-started.md",
30 | "docs/ja-jp/guide/getting-started.md",
31 | "cmd/asdf/main.go"
32 | ]
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/scripts/install_dependencies.bash:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | set -euo pipefail
4 | IFS=$'\n\t'
5 |
6 | ### Used env vars set by default in GitHub Actions
7 | # docs: https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables
8 | # GITHUB_ACTIONS
9 | # RUNNER_OS
10 |
11 | if [ -z "$GITHUB_ACTIONS" ]; then
12 | printf "%s\n" "GITHUB_ACTIONS is not set. This script is only intended to be run in GitHub Actions. Exiting."
13 | exit 1
14 | fi
15 |
16 | if [ -z "$RUNNER_OS" ]; then
17 | printf "%s\n" "RUNNER_OS is not set. This script is only intended to be run in GitHub Actions. Exiting."
18 | exit 1
19 | fi
20 |
21 | ### Set variables for tracking versions
22 | # Elvish
23 | elvish_semver="v0.19.2"
24 | # Nushell
25 | nushell_semver="0.86.0"
26 | # Powershell
27 | powershell_semver="7.4.6"
28 | powershell_apt_semver="${powershell_semver}-1.deb"
29 |
30 | ### Install dependencies on Linux
31 | if [ "$RUNNER_OS" = "Linux" ]; then
32 | printf "%s\n" "Installing dependencies on Linux"
33 |
34 | curl -fsSLo- https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc >/dev/null
35 | sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-debian-bullseye-prod bullseye main" > /etc/apt/sources.list.d/microsoft.list'
36 | sudo add-apt-repository -y ppa:fish-shell/release-3
37 | sudo apt-get update
38 | sudo apt-get --allow-downgrades -y install curl parallel \
39 | fish powershell="${powershell_apt_semver}"
40 |
41 | # Create $HOME/bin
42 | mkdir -p "$HOME/bin"
43 |
44 | # Download elvish binary and add to path
45 | curl https://dl.elv.sh/linux-amd64/elvish-${elvish_semver}.tar.gz -o elvish-${elvish_semver}.tar.gz
46 | tar xzf elvish-${elvish_semver}.tar.gz
47 | rm elvish-${elvish_semver}.tar.gz
48 | mv elvish-${elvish_semver} "$HOME/bin/elvish"
49 |
50 | # Download nushell binary and add to path
51 | curl -L https://github.com/nushell/nushell/releases/download/${nushell_semver}/nu-${nushell_semver}-x86_64-unknown-linux-gnu.tar.gz -o nu-${nushell_semver}-x86_64-unknown-linux-gnu.tar.gz
52 | tar xzf nu-${nushell_semver}-x86_64-unknown-linux-gnu.tar.gz
53 | rm nu-${nushell_semver}-x86_64-unknown-linux-gnu.tar.gz
54 | mv nu-${nushell_semver}-x86_64-unknown-linux-gnu/* "$HOME/bin"
55 |
56 | # Add $HOME/bin to path (add Elvish & Nushell to path)
57 | echo "$HOME/bin" >>"$GITHUB_PATH"
58 | fi
59 |
60 | ### Install dependencies on macOS
61 | if [ "$RUNNER_OS" = "macOS" ]; then
62 | printf "%s\n" "Installing dependencies on macOS"
63 | brew install coreutils parallel \
64 | elvish \
65 | fish \
66 | nushell \
67 | powershell
68 | fi
69 |
70 | ### Install bats-core
71 | printf "%s\n" "Installing bats-core"
72 | bats_version=$(grep -Eo "^\\s*bats\\s*.*$" ".tool-versions" | cut -d ' ' -f2-)
73 | git clone --depth 1 --branch "v$bats_version" https://github.com/bats-core/bats-core.git "$HOME/bats-core"
74 | echo "$HOME/bats-core/bin" >>"$GITHUB_PATH"
75 |
--------------------------------------------------------------------------------
/scripts/test.bash:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | set -euo pipefail
4 | IFS=$'\n\t'
5 |
6 | print.info() {
7 | printf '[INFO] %s\n' "$1"
8 | }
9 |
10 | print.error() {
11 | printf '[ERROR] %s\n' "$1" >&2
12 | }
13 |
14 | {
15 | repo_dir=$(git rev-parse --show-toplevel)
16 | current_dir=$(pwd -P)
17 | if [ "$repo_dir" != "$current_dir" ]; then
18 | print.error "This scripts requires execution from the repository root directory."
19 | printf "\t%s\t%s\n" "Repo root dir:" "$repo_dir"
20 | printf "\t%s\t%s\n\n" "Current dir:" "$current_dir"
21 | exit 1
22 | fi
23 | }
24 |
25 | test_directory="./test"
26 | bats_options=(--timing --print-output-on-failure)
27 |
28 | if command -v parallel >/dev/null; then
29 | # Enable parallel jobs
30 | bats_options+=(--jobs 2 --no-parallelize-within-files)
31 | elif [[ -n "${CI-}" ]]; then
32 | print.error "GNU parallel should be installed in the CI environment. Please install and rerun the test suite."
33 | exit 1
34 | else
35 | print.info "For faster test execution, install GNU parallel."
36 | fi
37 |
38 | print.info "Running Bats in directory '${test_directory}' with options:" "${bats_options[@]}"
39 | bats "${bats_options[@]}" "${test_directory}"
40 |
--------------------------------------------------------------------------------
/staticcheck.conf:
--------------------------------------------------------------------------------
1 | checks = ["all", "-ST1005"]
2 |
--------------------------------------------------------------------------------
/test/asdf_elvish.bats:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bats
2 | # shellcheck disable=SC2030,SC2031
3 |
4 | load test_helpers
5 |
6 | setup() {
7 | export XDG_CONFIG_HOME=
8 | export XDG_DATA_HOME=
9 | export XDG_DATA_DIRS=
10 |
11 | if ! command -v elvish &>/dev/null && [ -z "$GITHUB_ACTIONS" ]; then
12 | skip 'Elvish not installed'
13 | fi
14 |
15 | local ver_major=
16 | local ver_minor=
17 | local ver_patch=
18 | IFS='.' read -r ver_major ver_minor ver_patch <<<"$(elvish -version)"
19 |
20 | if ((ver_major == 0 && ver_minor < 18)) && [ -z "$GITHUB_ACTIONS" ]; then
21 | skip "Elvish version is not at least 0.18. Found ${ver_major}.${ver_minor}.${ver_patch}"
22 | fi
23 | }
24 |
25 | cleaned_path() {
26 | echo "$PATH" | tr ':' '\n' | grep -v "asdf" | tr '\n' ' '
27 | }
28 |
29 | @test "exports ASDF_DIR" {
30 | run elvish -norc -c "
31 | unset-env ASDF_DIR
32 | set paths = [$(cleaned_path)]
33 | use ./asdf _asdf; var asdf~ = \$_asdf:asdf~
34 | echo \$E:ASDF_DIR"
35 |
36 | [ "$status" -eq 0 ]
37 | [ "$output" = "$HOME/.asdf" ]
38 | }
39 |
40 | @test "retains ASDF_DIR" {
41 | run elvish -norc -c "
42 | set-env ASDF_DIR \"/path/to/asdf\"
43 | set paths = [$(cleaned_path)]
44 | use ./asdf _asdf; var asdf~ = \$_asdf:asdf~
45 | echo \$E:ASDF_DIR"
46 |
47 | [ "$status" -eq 0 ]
48 | [ "$output" = "/path/to/asdf" ]
49 | }
50 |
51 | @test "retains ASDF_DATA_DIR" {
52 | run elvish -norc -c "
53 | set-env ASDF_DATA_DIR \"/path/to/asdf-data\"
54 | set paths = [$(cleaned_path)]
55 | use ./asdf _asdf; var asdf~ = \$_asdf:asdf~
56 | echo \$E:ASDF_DATA_DIR"
57 |
58 | [ "$status" -eq 0 ]
59 | [ "$output" = "/path/to/asdf-data" ]
60 | }
61 |
62 | @test "adds asdf dirs to PATH" {
63 | run elvish -norc -c "
64 | unset-env ASDF_DIR
65 | set paths = [$(cleaned_path)]
66 | use ./asdf _asdf; var asdf~ = \$_asdf:asdf~
67 | echo \$E:PATH"
68 |
69 | [ "$status" -eq 0 ]
70 |
71 | result=$(echo "$output" | grep "asdf")
72 | [ "$result" != "" ]
73 | }
74 |
75 | @test "defines the _asdf namespace" {
76 | run elvish -norc -c "
77 | unset-env ASDF_DIR
78 | set paths = [$(cleaned_path)]
79 | use ./asdf _asdf; var asdf~ = \$_asdf:asdf~
80 | pprint \$_asdf:"
81 |
82 | [ "$status" -eq 0 ]
83 | [[ "$output" =~ "/dev/null && [ -z "$GITHUB_ACTIONS" ]; then
10 | skip "Fish is not installed"
11 | fi
12 | }
13 |
14 | cleaned_path() {
15 | echo "$PATH" | tr ':' '\n' | grep -v "asdf" | tr '\n' ' '
16 | }
17 |
18 | @test "exports ASDF_DIR" {
19 | run fish --no-config -c "
20 | set -e asdf
21 | set -e ASDF_DIR
22 | set -e ASDF_DATA_DIR
23 | set PATH $(cleaned_path)
24 |
25 | . asdf.fish
26 | echo \$ASDF_DIR"
27 |
28 | [ "$status" -eq 0 ]
29 | [ "$output" != "" ]
30 | }
31 |
32 | @test "adds asdf dirs to PATH" {
33 | run fish --no-config -c "
34 | set -e asdf
35 | set -e ASDF_DIR
36 | set -e ASDF_DATA_DIR
37 | set PATH $(cleaned_path)
38 |
39 | . (pwd)/asdf.fish # if the full path is not passed, status -f will return the relative path
40 | echo \$PATH"
41 |
42 | [ "$status" -eq 0 ]
43 |
44 | result=$(echo "$output" | grep "asdf")
45 | [ "$result" != "" ]
46 | }
47 |
48 | @test "does not add paths to PATH more than once" {
49 | run fish --no-config -c "
50 | set -e asdf
51 | set -e ASDF_DIR
52 | set -e ASDF_DATA_DIR
53 | set PATH $(cleaned_path)
54 |
55 | . asdf.fish
56 | . asdf.fish
57 | echo \$PATH"
58 |
59 | [ "$status" -eq 0 ]
60 |
61 | result=$(echo "$output" | tr ' ' '\n' | grep "asdf" | sort | uniq -d)
62 | [ "$result" = "" ]
63 | }
64 |
65 | @test "defines the asdf function" {
66 | run fish --no-config -c "
67 | set -e asdf
68 | set -e ASDF_DIR
69 | set PATH $(cleaned_path)
70 |
71 | . asdf.fish
72 | type asdf"
73 |
74 | [ "$status" -eq 0 ]
75 | [[ "$output" =~ "is a function" ]]
76 | }
77 |
78 | @test "function calls asdf command" {
79 | run fish --no-config -c "
80 | set -e asdf
81 | set -x ASDF_DIR $(pwd) # checkstyle-ignore
82 | set PATH $(cleaned_path)
83 |
84 | . asdf.fish
85 | asdf info"
86 |
87 | [ "$status" -eq 0 ]
88 |
89 | result=$(echo "$output" | grep "ASDF INSTALLED PLUGINS:")
90 | [ "$result" != "" ]
91 | }
92 |
--------------------------------------------------------------------------------
/test/asdf_pwsh.bats:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bats
2 | # shellcheck disable=SC2164
3 |
4 | load test_helpers
5 |
6 | setup() {
7 | cd "$(dirname "$BATS_TEST_DIRNAME")"
8 |
9 | if ! command -v pwsh &>/dev/null && [ -z "$GITHUB_ACTIONS" ]; then
10 | skip "Powershell Core is not installed"
11 | fi
12 | }
13 |
14 | cleaned_path() {
15 | echo "$PATH" | tr ':' '\n' | grep -v "asdf" | tr '\n' ':'
16 | }
17 |
18 | @test "exports ASDF_DIR" {
19 | run pwsh -Command "
20 | function asdf() {} # checkstyle-ignore
21 | Remove-item Function:asdf
22 | \$Env:ASDF_DIR = ''
23 | \$Env:ASDF_DATA_DIR = ''
24 | \$Env:PATH = \"$(cleaned_path)\"
25 |
26 | . ./asdf.ps1
27 | Write-Output \"\$env:ASDF_DIR\""
28 |
29 | [ "$status" -eq 0 ]
30 | [ "$output" != "" ]
31 | }
32 |
33 | @test "adds asdf dirs to PATH" {
34 | run pwsh -Command "
35 | function asdf() {} # checkstyle-ignore
36 | Remove-item Function:asdf
37 | \$Env:ASDF_DIR = ''
38 | \$Env:ASDF_DATA_DIR = ''
39 | \$Env:PATH = \"$(cleaned_path)\"
40 |
41 | . ./asdf.ps1
42 | Write-Output \$Env:PATH"
43 |
44 | [ "$status" -eq 0 ]
45 | result=$(echo "$output" | grep "asdf")
46 | [ "$result" != "" ]
47 | }
48 |
49 | @test "does not add paths to PATH more than once" {
50 | run pwsh -Command "
51 | function asdf() {} # checkstyle-ignore
52 | Remove-item Function:asdf
53 | \$Env:ASDF_DIR = ''
54 | \$Env:ASDF_DATA_DIR = ''
55 | \$Env:PATH = \"$(cleaned_path)\"
56 |
57 | . ./asdf.ps1
58 | . ./asdf.ps1
59 | Write-Output \$Env:PATH"
60 |
61 | [ "$status" -eq 0 ]
62 |
63 | result=$(echo "$output" | tr ' ' '\n' | grep "asdf" | sort | uniq -d)
64 | [ "$result" = "" ]
65 | }
66 |
67 | @test "defines the asdf function" {
68 | run pwsh -Command "
69 | function asdf() {} # checkstyle-ignore
70 | Remove-item Function:asdf
71 | \$Env:ASDF_DIR = ''
72 | \$Env:ASDF_DATA_DIR = ''
73 | \$Env:PATH = \"$(cleaned_path)\"
74 |
75 | ./ asdf.ps1
76 | \$(Get-Command -CommandType asdf).Name"
77 |
78 | [ "$status" -eq 0 ]
79 | [[ "$output" =~ "asdf" ]]
80 | }
81 |
82 | @test "function calls asdf command" {
83 | run pwsh -Command "
84 | function asdf() {} # checkstyle-ignore
85 | Remove-item Function:asdf
86 | \$Env:ASDF_DIR = ''
87 | \$Env:ASDF_DATA_DIR = ''
88 | \$Env:PATH = \"$(cleaned_path)\"
89 |
90 | . ./asdf.ps1
91 | asdf info"
92 |
93 | [ "$status" -eq 0 ]
94 | result=$(echo "$output" | grep "ASDF INSTALLED PLUGINS:")
95 | [ "$result" != "" ]
96 | }
97 |
--------------------------------------------------------------------------------
/test/asdf_sh.bats:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bats
2 |
3 | load test_helpers
4 |
5 | # Helper function to handle sourcing of asdf.sh
6 | source_asdf_sh() {
7 | . "$(dirname "$BATS_TEST_DIRNAME")/asdf.sh"
8 | }
9 |
10 | cleaned_path() {
11 | echo "$PATH" | tr ':' '\n' | grep -v "asdf" | tr '\n' ':'
12 | }
13 |
14 | @test "exports ASDF_DIR" {
15 | output=$(
16 | unset -f asdf
17 | unset ASDF_DIR
18 | PATH=$(cleaned_path)
19 |
20 | source_asdf_sh
21 | echo "$ASDF_DIR"
22 | )
23 |
24 | result=$(echo "$output" | grep "asdf")
25 | [ "$result" != "" ]
26 | }
27 |
28 | @test "does not error if nounset is enabled" {
29 | output=$(
30 | unset -f asdf
31 | unset ASDF_DIR
32 | PATH=$(cleaned_path)
33 | set -o nounset
34 |
35 | source_asdf_sh
36 | echo "$ASDF_DIR"
37 | )
38 |
39 | result=$(echo "$output" | grep "asdf")
40 | [ "$result" != "" ]
41 | }
42 |
43 | @test "adds asdf dirs to PATH" {
44 | output=$(
45 | unset -f asdf
46 | unset ASDF_DIR
47 | PATH=$(cleaned_path)
48 |
49 | source_asdf_sh
50 | echo "$PATH"
51 | )
52 |
53 | result=$(echo "$output" | grep "asdf")
54 | [ "$result" != "" ]
55 | }
56 |
57 | @test "does not add paths to PATH more than once" {
58 | output=$(
59 | unset -f asdf
60 | unset ASDF_DIR
61 | PATH=$(cleaned_path)
62 |
63 | source_asdf_sh
64 | source_asdf_sh
65 | echo "$PATH"
66 | )
67 |
68 | result=$(echo "$output" | tr ':' '\n' | grep "asdf" | sort | uniq -d)
69 | [ "$result" = "" ]
70 | }
71 |
72 | @test "defines the asdf function" {
73 | output=$(
74 | unset -f asdf
75 | unset ASDF_DIR
76 | PATH=$(cleaned_path)
77 |
78 | source_asdf_sh
79 | type asdf
80 | )
81 |
82 | [[ "$output" =~ "is a function" ]]
83 | }
84 |
85 | @test "function calls asdf command" {
86 | result=$(
87 | unset -f asdf
88 | ASDF_DIR=$PWD
89 | PATH=$(cleaned_path)
90 |
91 | source_asdf_sh
92 | asdf info
93 | )
94 |
95 | output=$(echo "$result" | grep "ASDF INSTALLED PLUGINS:")
96 | [ "$output" != "" ]
97 | }
98 |
--------------------------------------------------------------------------------
/test/banned_commands.bats:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bats
2 |
3 | load test_helpers
4 |
5 | banned_commands=(
6 | # Process substitution isn't POSIX compliant and cause trouble
7 | "<("
8 | # Command isn't included in the Ubuntu packages asdf depends on. Also not
9 | # defined in POSIX
10 | column
11 | # echo isn't consistent across operating systems, and sometimes output can
12 | # be confused with echo flags. printf does everything echo does and more.
13 | echo
14 | # It's best to avoid eval as it makes it easier to accidentally execute
15 | # arbitrary strings
16 | eval
17 | # realpath not available by default on OSX.
18 | realpath
19 | # source isn't POSIX compliant. . behaves the same and is POSIX compliant
20 | # Except in fish, where . is deprecated, and will be removed in the future.
21 | source
22 | # For consistency, [ should be used instead. There is a leading space so 'fail_test', etc. is not matched
23 | ' test'
24 | )
25 |
26 | banned_commands_regex=(
27 | # grep -y does not work on alpine and should be "grep -i" either way
28 | "grep.* -y"
29 | # grep -P is not a valid option in OSX.
30 | "grep.* -P"
31 | # Ban grep long commands as they do not work on alpine
32 | "grep[^|]+--\w{2,}"
33 | # readlink -f on OSX behaves differently from readlink -f on other Unix systems
34 | 'readlink.+-.*f.+["$]'
35 | # sort --sort-version isn't supported everywhere
36 | "sort.*-V"
37 | "sort.*--sort-versions"
38 |
39 | # ls often gets used when we want to glob for files that match a pattern
40 | # or when we want to find all files/directories that match a pattern or are
41 | # found in a certain location. Using shell globs is preferred over ls, and
42 | # find is better at locating files that are in a certain location or that
43 | # match certain filename patterns.
44 | # https://github-wiki-see.page/m/koalaman/shellcheck/wiki/SC2012
45 | '\bls '
46 |
47 | # Ban recursive asdf calls as they are inefficient and may introduce bugs.
48 | # If you find yourself needing to invoke an `asdf` command from within
49 | # asdf code, please source the appropriate file and invoke the
50 | # corresponding function.
51 | '\basdf '
52 | )
53 |
54 | setup() {
55 | setup_asdf_dir
56 | }
57 |
58 | teardown() {
59 | clean_asdf_dir
60 | }
61 |
62 | @test "banned commands are not found in source code" {
63 | # Assert command is not used in the lib and bin dirs
64 | # or expect an explicit comment at end of line, allowing it.
65 | # Also ignore matches that are contained in comments or a string or
66 | # followed by an underscore (indicating it's a variable and not a
67 | # command).
68 | for cmd in "${banned_commands[@]}"; do
69 | run bash -c "grep -nHR --include \*.bash --include \*.sh '$cmd' asdf.* lib bin\
70 | | grep -v '#.*$cmd'\
71 | | grep -v '\".*$cmd.*\"' \
72 | | grep -v '${cmd}_'\
73 | | grep -v '# asdf_allow: $cmd'"
74 |
75 | # Only print output if we've found a banned command
76 | #if [ "$status" -ne 1 ]; then
77 | if [ "" != "$output" ]; then
78 | echo "banned command $cmd: $output"
79 | fi
80 |
81 | [ "$status" -eq 1 ]
82 | [ "" = "$output" ]
83 | done
84 |
85 | for cmd in "${banned_commands_regex[@]}"; do
86 | run bash -c "grep -nHRE --include \*.bash --include \*.sh '$cmd' asdf.* lib bin\
87 | | grep -v '#.*$cmd'\
88 | | grep -v '\".*$cmd.*\"' \
89 | | grep -v '${cmd}_'\
90 | | grep -v '# asdf_allow: $cmd'"
91 |
92 | # Only print output if we've found a banned command
93 | #if [ "$status" -ne 1 ]; then
94 | if [ "" != "$output" ]; then
95 | echo "banned command $cmd: $output"
96 | fi
97 |
98 | [ "$status" -eq 1 ]
99 | [ "" = "$output" ]
100 | done
101 | }
102 |
--------------------------------------------------------------------------------
/test/fixtures/dummy_broken_plugin/bin/download:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | echo "Download failed!"
4 | exit 1
5 |
--------------------------------------------------------------------------------
/test/fixtures/dummy_broken_plugin/bin/install:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | echo "Unused script"
4 |
--------------------------------------------------------------------------------
/test/fixtures/dummy_broken_plugin/bin/list-all:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | echo "Attempting to list versions"
4 | echo "List-all failed!" >&2
5 | exit 1
6 |
--------------------------------------------------------------------------------
/test/fixtures/dummy_legacy_plugin/bin/get-version-from-legacy-file:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | get_legacy_version() {
4 | current_directory=$1
5 | version_file="$current_directory/.dummy-version"
6 |
7 | if [ -f "$version_file" ]; then
8 | cat "$version_file"
9 | fi
10 | }
11 |
12 | get_legacy_version "$1"
13 |
--------------------------------------------------------------------------------
/test/fixtures/dummy_legacy_plugin/bin/install:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | mkdir -p "$ASDF_INSTALL_PATH"
4 | env >"$ASDF_INSTALL_PATH/env"
5 | echo "$ASDF_INSTALL_VERSION" >"$ASDF_INSTALL_PATH/version"
6 |
7 | # create the dummy executable
8 | mkdir -p "$ASDF_INSTALL_PATH/bin"
9 | cat <"$ASDF_INSTALL_PATH/bin/dummy"
10 | echo This is Dummy ${ASDF_INSTALL_VERSION}! \$2 \$1
11 | EOF
12 | chmod +x "$ASDF_INSTALL_PATH/bin/dummy"
13 | mkdir -p "$ASDF_INSTALL_PATH/bin/subdir"
14 | cat <"$ASDF_INSTALL_PATH/bin/subdir/other_bin"
15 | echo This is Other Bin ${ASDF_INSTALL_VERSION}! \$2 \$1
16 | EOF
17 | chmod +x "$ASDF_INSTALL_PATH/bin/subdir/other_bin"
18 |
--------------------------------------------------------------------------------
/test/fixtures/dummy_legacy_plugin/bin/list-all:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | versions_list=(1.0.0 1.1.0 2.0.0 3.0.0-alpha1 3.0.0-beta2 4.0.0 4.1.0-pre 5.0.0-Alpha1 5.1.0 5.2.0-Alpha2)
4 | echo "${versions_list[@]}"
5 |
--------------------------------------------------------------------------------
/test/fixtures/dummy_legacy_plugin/bin/list-legacy-filenames:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | echo ".dummy-version .dummyrc"
4 |
--------------------------------------------------------------------------------
/test/fixtures/dummy_legacy_plugin/bin/parse-legacy-file:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | # shellcheck disable=SC2020
4 | tr <"$1" -d "dummy-"
5 |
--------------------------------------------------------------------------------
/test/fixtures/dummy_plugin/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014 Akash Manohar J
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of
6 | this software and associated documentation files (the "Software"), to deal in
7 | the Software without restriction, including without limitation the rights to
8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 | the Software, and to permit persons to whom the Software is furnished to do so,
10 | subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
--------------------------------------------------------------------------------
/test/fixtures/dummy_plugin/bin/debug:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | echo "$@"
4 |
--------------------------------------------------------------------------------
/test/fixtures/dummy_plugin/bin/download:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | exit 0
4 |
--------------------------------------------------------------------------------
/test/fixtures/dummy_plugin/bin/get-version-from-legacy-file:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | get_legacy_version() {
4 | current_directory=$1
5 | version_file="$current_directory/.dummy-version"
6 |
7 | if [ -f "$version_file" ]; then
8 | cat "$version_file"
9 | fi
10 | }
11 |
12 | get_legacy_version "$1"
13 |
--------------------------------------------------------------------------------
/test/fixtures/dummy_plugin/bin/help.overview:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | echo "Dummy plugin documentation"
4 | echo
5 | echo "Dummy plugin is a plugin only used for unit tests"
6 |
7 | if [ -n "$ASDF_INSTALL_VERSION" ]; then
8 | echo
9 | echo "Details specific for version $ASDF_INSTALL_VERSION"
10 | fi
11 |
--------------------------------------------------------------------------------
/test/fixtures/dummy_plugin/bin/install:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | # We want certain versions to fail installation for various reasons in the tests
4 | check_dummy_versions() {
5 | local bad_versions=" other-dummy "
6 | if [[ "$bad_versions" == *" $ASDF_INSTALL_VERSION "* ]]; then
7 | echo "Dummy couldn't install version: $ASDF_INSTALL_VERSION (on purpose)"
8 | exit 1
9 | fi
10 | }
11 |
12 | check_dummy_versions
13 | mkdir -p "$ASDF_INSTALL_PATH"
14 | env >"$ASDF_INSTALL_PATH/env"
15 | echo "$ASDF_INSTALL_VERSION" >"$ASDF_INSTALL_PATH/version"
16 |
17 | # create the dummy executable
18 | mkdir -p "$ASDF_INSTALL_PATH/bin"
19 | cat <"$ASDF_INSTALL_PATH/bin/dummy"
20 | #!/usr/bin/env bash
21 | echo This is Dummy ${ASDF_INSTALL_VERSION}! \$2 \$1
22 | EOF
23 | chmod +x "$ASDF_INSTALL_PATH/bin/dummy"
24 | mkdir -p "$ASDF_INSTALL_PATH/bin/subdir"
25 | cat <"$ASDF_INSTALL_PATH/bin/subdir/other_bin"
26 | #!/usr/bin/env bash
27 | echo This is Other Bin ${ASDF_INSTALL_VERSION}! \$2 \$1
28 | EOF
29 | chmod +x "$ASDF_INSTALL_PATH/bin/subdir/other_bin"
30 |
--------------------------------------------------------------------------------
/test/fixtures/dummy_plugin/bin/latest-stable:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | get_latest_stable() {
4 | query=$1
5 |
6 | version_list=(1.0.0 1.1.0 2.0.0)
7 | printf "%s\n" "${version_list[@]}" | grep -E "^\s*$query" | tail -1
8 | }
9 |
10 | get_latest_stable "$1"
11 |
--------------------------------------------------------------------------------
/test/fixtures/dummy_plugin/bin/list-all:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | versions_list=(1.0.0 1.1.0 2.0.0)
4 | echo "${versions_list[@]}"
5 | # Sending message to STD error to ensure that it is ignored
6 | echo "ignore this error" >&2
7 |
--------------------------------------------------------------------------------
/test/fixtures/dummy_plugin/bin/list-legacy-filenames:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | echo ".dummy-version .dummyrc"
4 |
--------------------------------------------------------------------------------
/test/fixtures/dummy_plugin/bin/parse-legacy-file:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | # shellcheck disable=SC2020
4 | tr <"$1" -d "dummy-"
5 |
--------------------------------------------------------------------------------
/test/fixtures/dummy_plugin/bin/post-plugin-add:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | echo "plugin add path=${ASDF_PLUGIN_PATH} source_url=${ASDF_PLUGIN_SOURCE_URL}"
4 |
--------------------------------------------------------------------------------
/test/fixtures/dummy_plugin/bin/post-plugin-update:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | echo "plugin updated path=${ASDF_PLUGIN_PATH} old git-ref=${ASDF_PLUGIN_PREV_REF} new git-ref=${ASDF_PLUGIN_POST_REF}"
4 |
--------------------------------------------------------------------------------
/test/fixtures/dummy_plugin/bin/pre-plugin-remove:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | echo "plugin-remove ${ASDF_PLUGIN_PATH}"
4 |
--------------------------------------------------------------------------------
/test/fixtures/dummy_plugin_no_download/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014 Akash Manohar J
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of
6 | this software and associated documentation files (the "Software"), to deal in
7 | the Software without restriction, including without limitation the rights to
8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 | the Software, and to permit persons to whom the Software is furnished to do so,
10 | subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
--------------------------------------------------------------------------------
/test/fixtures/dummy_plugin_no_download/bin/install:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | printf '%s' 'install'
4 |
--------------------------------------------------------------------------------
/test/fixtures/dummy_plugins_repo/plugins/bar:
--------------------------------------------------------------------------------
1 | repository = http://example.com/bar
2 |
--------------------------------------------------------------------------------
/test/fixtures/dummy_plugins_repo/plugins/dummy:
--------------------------------------------------------------------------------
1 | repository = http://example.com/dummy
2 |
--------------------------------------------------------------------------------
/test/fixtures/dummy_plugins_repo/plugins/foo:
--------------------------------------------------------------------------------
1 | repository = http://example.com/foo
2 |
--------------------------------------------------------------------------------
/test/get_asdf_config_value.bats:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bats
2 | # shellcheck disable=SC2164
3 |
4 | load test_helpers
5 |
6 | setup() {
7 | cd "$BATS_TMPDIR"
8 | ASDF_CONFIG_FILE="$BATS_TMPDIR/asdfrc"
9 | cat >"$ASDF_CONFIG_FILE" <<-EOM
10 | key1 = value1
11 | legacy_version_file = yes
12 | EOM
13 |
14 | ASDF_CONFIG_DEFAULT_FILE="$BATS_TMPDIR/asdfrc_defaults"
15 | cat >"$ASDF_CONFIG_DEFAULT_FILE" <<-EOM
16 | # i have a comment, it's ok
17 | key2 = value2
18 | legacy_version_file = no
19 | EOM
20 | }
21 |
22 | teardown() {
23 | rm "$ASDF_CONFIG_FILE"
24 | rm "$ASDF_CONFIG_DEFAULT_FILE"
25 | unset ASDF_CONFIG_DEFAULT_FILE
26 | unset ASDF_CONFIG_FILE
27 | }
28 |
29 | @test "get_config returns default when config file does not exist" {
30 | result=$(ASDF_CONFIG_FILE="/some/fake/path" get_asdf_config_value "legacy_version_file")
31 | [ "$result" = "no" ]
32 | }
33 |
34 | @test "get_config returns default value when the key does not exist" {
35 | [ "$(get_asdf_config_value "key2")" = "value2" ]
36 | }
37 |
38 | @test "get_config returns config file value when key exists" {
39 | [ "$(get_asdf_config_value "key1")" = "value1" ]
40 | [ "$(get_asdf_config_value "legacy_version_file")" = "yes" ]
41 | }
42 |
43 | @test "get_config returns config file complete value including '=' symbols" {
44 | cat >>"$ASDF_CONFIG_FILE" <<-'EOM'
45 | key3 = VAR=val
46 | EOM
47 |
48 | [ "$(get_asdf_config_value "key3")" = "VAR=val" ]
49 | }
50 |
--------------------------------------------------------------------------------
/test/help_command.bats:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bats
2 |
3 | load test_helpers
4 |
5 | setup() {
6 | setup_asdf_dir
7 | install_dummy_plugin
8 | install_dummy_legacy_plugin
9 | run asdf install dummy 1.0
10 | run asdf install dummy 1.1
11 |
12 | PROJECT_DIR="$HOME/project"
13 | mkdir -p "$PROJECT_DIR"
14 | }
15 |
16 | teardown() {
17 | clean_asdf_dir
18 | }
19 |
20 | @test "help should show dummy plugin help" {
21 | cd "$PROJECT_DIR"
22 |
23 | run asdf help "dummy"
24 |
25 | expected_output="$(
26 | cat <>"$PROJECT_DIR/.tool-versions"
30 | run asdf install dummy 1.0.0
31 | run asdf install dummy 1.1.0
32 |
33 | run asdf list
34 | [[ "$output" == *$'dummy\n 1.0.0\n *1.1.0'* ]]
35 | [[ "$output" == *$'dummy-broken\n No versions installed'* ]]
36 | [ "$status" -eq 0 ]
37 | }
38 |
39 | @test "list_command should continue listing even when no version is installed for any of the plugins" {
40 | run install_mock_plugin "dummy"
41 | run install_mock_plugin "mummy"
42 | run install_mock_plugin "tummy"
43 | run asdf install dummy 1.0.0
44 | run asdf install tummy 2.0.0
45 | run asdf list
46 | [[ "$output" == *$'dummy\n 1.0.0'* ]]
47 | [[ "$output" == *$'dummy-broken\n No versions installed'* ]]
48 | [[ "$output" == *$'mummy\n No versions installed'* ]]
49 | [[ "$output" == *$'tummy\n 2.0.0'* ]]
50 | [ "$status" -eq 0 ]
51 | }
52 |
53 | @test "list_command with plugin should list installed versions" {
54 | run asdf install dummy 1.0.0
55 | run asdf install dummy 1.1.0
56 | run asdf list dummy
57 | [ $' 1.0.0\n 1.1.0' = "$output" ]
58 | [ "$status" -eq 0 ]
59 | }
60 |
61 | @test "list_command with version filters installed versions" {
62 | run asdf install dummy 1.0
63 | run asdf install dummy 1.1
64 | run asdf install dummy 2.0
65 | run asdf list dummy 1
66 | [ $' 1.0\n 1.1' = "$output" ]
67 | [ "$status" -eq 0 ]
68 | }
69 |
70 | @test "list_command with an invalid version should return an error" {
71 | run asdf install dummy 1.0
72 | run asdf install dummy 1.1
73 | run asdf list dummy 2
74 | [ "No compatible versions installed (dummy 2)" = "$output" ]
75 | [ "$status" -eq 1 ]
76 | }
77 |
78 | @test "list_all_command lists available versions" {
79 | run asdf list all dummy
80 | [ $'1.0.0\n1.1.0\n2.0.0' = "$output" ]
81 | [ "$status" -eq 0 ]
82 | }
83 |
84 | @test "list_all_command with version filters available versions" {
85 | run asdf list all dummy 1
86 | [ $'1.0.0\n1.1.0' = "$output" ]
87 | [ "$status" -eq 0 ]
88 | }
89 |
90 | @test "list_all_command with an invalid version should return an error" {
91 | run asdf list all dummy 3
92 | [ "No compatible versions available (dummy 3)" = "$output" ]
93 | [ "$status" -eq 1 ]
94 | }
95 |
96 | @test "list_all_command fails when list-all script exits with non-zero code" {
97 | run asdf list all dummy-broken
98 | [ "$status" -eq 1 ]
99 | [[ "$output" == "Plugin dummy-broken's list-all callback script failed with output:"* ]]
100 | }
101 |
102 | @test "list_all_command displays stderr then stdout when failing" {
103 | run asdf list all dummy-broken
104 | [[ "$output" == *"List-all failed!"* ]]
105 | [[ "$output" == *"Attempting to list versions" ]]
106 | }
107 |
108 | @test "list_all_command ignores stderr when completing successfully" {
109 | run asdf list all dummy
110 | [[ "$output" != *"ignore this error"* ]]
111 | }
112 |
--------------------------------------------------------------------------------
/test/non_existent_command.bats:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bats
2 |
3 | load test_helpers
4 |
5 | setup() {
6 | setup_asdf_dir
7 |
8 | PROJECT_DIR="$HOME/project"
9 | mkdir -p "$PROJECT_DIR"
10 | }
11 |
12 | @test "should show help when no valid command is provided" {
13 | cd "$PROJECT_DIR"
14 |
15 | run asdf non-existent-command
16 |
17 | [ "$status" -eq 1 ]
18 | [[ $output == 'invalid command provided:'* ]]
19 | [[ $output =~ $'version: '[0-9]* ]]
20 | [[ $output == *$'MANAGE PLUGINS\n'* ]]
21 | [[ $output == *$'MANAGE TOOLS\n'* ]]
22 | [[ $output == *$'UTILS\n'* ]]
23 | [[ $output == *$'"Late but latest"\n-- Rajinikanth' ]]
24 | }
25 |
--------------------------------------------------------------------------------
/test/plugin_list_all_command.bats:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bats
2 | # shellcheck disable=SC2030,SC2031
3 |
4 | load test_helpers
5 |
6 | setup() {
7 | setup_asdf_dir
8 | setup_repo
9 | install_dummy_plugin
10 | }
11 |
12 | teardown() {
13 | clean_asdf_dir
14 | }
15 |
16 | @test "plugin_list_all should exit before syncing the plugin repo if disabled" {
17 | export ASDF_CONFIG_DEFAULT_FILE="$HOME/.asdfrc"
18 | echo 'disable_plugin_short_name_repository=yes' >"$ASDF_CONFIG_DEFAULT_FILE"
19 | local expected="Short-name plugin repository is disabled"
20 |
21 | run asdf plugin list all
22 | [ "$status" -eq 1 ]
23 | [ "$output" = "$expected" ]
24 | }
25 |
26 | @test "plugin_list_all should sync repo when check_duration set to 0" {
27 | export ASDF_CONFIG_DEFAULT_FILE="$HOME/.asdfrc"
28 | echo 'plugin_repository_last_check_duration = 0' >"$ASDF_CONFIG_DEFAULT_FILE"
29 | local expected_plugins_list="\
30 | bar http://example.com/bar
31 | dummy http://example.com/dummy
32 | foo http://example.com/foo"
33 |
34 | run asdf plugin list all
35 | [ "$status" -eq 0 ]
36 | [[ "$output" == *"$expected_plugins_list"* ]]
37 | }
38 |
39 | @test "plugin_list_all no immediate repo sync expected because check_duration is greater than 0" {
40 | export ASDF_CONFIG_DEFAULT_FILE="$HOME/.asdfrc"
41 | echo 'plugin_repository_last_check_duration = 10' >"$ASDF_CONFIG_DEFAULT_FILE"
42 | local expected="\
43 | bar http://example.com/bar
44 | dummy http://example.com/dummy
45 | foo http://example.com/foo"
46 |
47 | run asdf plugin list all
48 | [ "$status" -eq 0 ]
49 | [ "$output" = "$expected" ]
50 | }
51 |
52 | @test "plugin_list_all skips repo sync because check_duration is set to never" {
53 | export ASDF_CONFIG_DEFAULT_FILE="$HOME/.asdfrc"
54 | echo 'plugin_repository_last_check_duration = never' >"$ASDF_CONFIG_DEFAULT_FILE"
55 | local expected="\
56 | bar http://example.com/bar
57 | dummy http://example.com/dummy
58 | foo http://example.com/foo"
59 |
60 | run asdf plugin list all
61 | [ "$status" -eq 0 ]
62 | [ "$output" = "$expected" ]
63 | }
64 |
65 | @test "plugin_list_all list all plugins in the repository" {
66 | local expected="\
67 | bar http://example.com/bar
68 | dummy http://example.com/dummy
69 | foo http://example.com/foo"
70 |
71 | run asdf plugin list all
72 | [ "$status" -eq 0 ]
73 | [ "$output" = "$expected" ]
74 | }
75 |
--------------------------------------------------------------------------------
/test/plugin_remove_command.bats:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bats
2 |
3 | load test_helpers
4 |
5 | setup() {
6 | setup_asdf_dir
7 | install_dummy_plugin
8 | }
9 |
10 | teardown() {
11 | clean_asdf_dir
12 | }
13 |
14 | @test "plugin_remove command removes the plugin directory" {
15 | run asdf install dummy 1.0
16 | [ "$status" -eq 0 ]
17 | [ -d "$ASDF_DIR/downloads/dummy" ]
18 |
19 | run asdf plugin remove "dummy"
20 | [ "$status" -eq 0 ]
21 | [ ! -d "$ASDF_DIR/downloads/dummy" ]
22 | }
23 |
24 | @test "plugin_remove command fails if the plugin doesn't exist" {
25 | run asdf plugin remove "does-not-exist"
26 | [ "$status" -eq 1 ]
27 | echo "$output" | grep "No such plugin: does-not-exist"
28 | }
29 |
--------------------------------------------------------------------------------
/test/plugin_test_command.bats:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bats
2 |
3 | load test_helpers
4 |
5 | setup() {
6 | setup_asdf_dir
7 | install_mock_plugin_repo "dummy"
8 | }
9 |
10 | teardown() {
11 | clean_asdf_dir
12 | }
13 |
14 | @test "plugin_test_command with no URL specified prints an error" {
15 | run asdf plugin test "elixir"
16 | [ "$status" -eq 1 ]
17 | [ "$output" = "FAILED: please provide a plugin name and url" ]
18 | }
19 |
20 | @test "plugin_test_command with no name or URL specified prints an error" {
21 | run asdf plugin test
22 | [ "$status" -eq 1 ]
23 | [ "$output" = "FAILED: please provide a plugin name and url" ]
24 | }
25 |
26 | @test "plugin_test_command works with no options provided" {
27 | run asdf plugin test dummy "${BASE_DIR}/repo-dummy"
28 | [ "$status" -eq 0 ]
29 | }
30 |
31 | @test "plugin_test_command works with all options provided" {
32 | run asdf plugin test dummy "${BASE_DIR}/repo-dummy" --asdf-tool-version 1.0.0 --asdf-plugin-gitref master
33 | [ "$status" -eq 0 ]
34 | }
35 |
--------------------------------------------------------------------------------
/test/setup_suite.bash:
--------------------------------------------------------------------------------
1 | setup_suite() {
2 | # Unset ASDF_DIR because it may already be set by the users shell, and some
3 | # tests fail when it is set to something other than the temp dir.
4 | unset ASDF_DIR
5 |
6 | # Also unset below variables, because in users shell shimmed commands
7 | # (include bats) export them by determining user's real HOME.
8 | unset ASDF_DATA_DIR
9 | unset ASDF_CONFIG_FILE
10 |
11 | # Set an agnostic Git configuration directory to prevent personal
12 | # configuration from interfering with the tests
13 | export GIT_CONFIG_GLOBAL=/dev/null
14 | }
15 |
--------------------------------------------------------------------------------
/test/shim_versions_command.bats:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bats
2 | # shellcheck disable=SC2164
3 |
4 | load test_helpers
5 |
6 | setup() {
7 | setup_asdf_dir
8 | install_dummy_plugin
9 |
10 | PROJECT_DIR="$HOME/project"
11 | mkdir -p "$PROJECT_DIR"
12 | cd "$PROJECT_DIR"
13 | }
14 |
15 | teardown() {
16 | clean_asdf_dir
17 | }
18 |
19 | @test "shim_versions_command should list plugins and versions where command is available" {
20 | cd "$PROJECT_DIR"
21 | run asdf install dummy 3.0
22 | run asdf install dummy 1.0
23 | run asdf reshim dummy
24 |
25 | run asdf shimversions dummy
26 | [ "$status" -eq 0 ]
27 |
28 | echo "$output" | grep "dummy 3.0"
29 | echo "$output" | grep "dummy 1.0"
30 | }
31 |
--------------------------------------------------------------------------------
/test/uninstall_command.bats:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bats
2 |
3 | load test_helpers
4 |
5 | setup() {
6 | setup_asdf_dir
7 | install_dummy_plugin
8 |
9 | PROJECT_DIR="$HOME/project"
10 | mkdir -p "$PROJECT_DIR"
11 | }
12 |
13 | teardown() {
14 | clean_asdf_dir
15 | }
16 |
17 | @test "uninstall_command should fail when no such version is installed" {
18 | run asdf uninstall dummy 3.14
19 | [ "$output" = "No such version" ]
20 | [ "$status" -eq 1 ]
21 | }
22 |
23 | @test "uninstall_command should remove the plugin with that version from asdf" {
24 | run asdf install dummy 1.1.0
25 | [ "$status" -eq 0 ]
26 | [ "$(cat "$ASDF_DIR/installs/dummy/1.1.0/version")" = "1.1.0" ]
27 | run asdf uninstall dummy 1.1.0
28 | [ ! -f "$ASDF_DIR/installs/dummy/1.1.0/version" ]
29 | }
30 |
31 | @test "uninstall_command should invoke the plugin bin/uninstall if available" {
32 | run asdf install dummy 1.1.0
33 | [ "$status" -eq 0 ]
34 | mkdir -p "$ASDF_DIR/plugins/dummy/bin"
35 | printf '%s\n' "echo custom uninstall" >"$ASDF_DIR/plugins/dummy/bin/uninstall"
36 | chmod 755 "$ASDF_DIR/plugins/dummy/bin/uninstall"
37 | run asdf uninstall dummy 1.1.0
38 | [ "$output" = "custom uninstall" ]
39 | [ "$status" -eq 0 ]
40 | }
41 |
42 | @test "uninstall_command should remove the plugin shims if no other version is installed" {
43 | run asdf install dummy 1.1.0
44 | [ -f "$ASDF_DIR/shims/dummy" ]
45 | run asdf uninstall dummy 1.1.0
46 | [ ! -f "$ASDF_DIR/shims/dummy" ]
47 | }
48 |
49 | @test "uninstall_command should leave the plugin shims if other version is installed" {
50 | run asdf install dummy 1.0.0
51 | [ -f "$ASDF_DIR/installs/dummy/1.0.0/bin/dummy" ]
52 |
53 | run asdf install dummy 1.1.0
54 | [ -f "$ASDF_DIR/installs/dummy/1.1.0/bin/dummy" ]
55 |
56 | [ -f "$ASDF_DIR/shims/dummy" ]
57 | run asdf uninstall dummy 1.0.0
58 | [ -f "$ASDF_DIR/shims/dummy" ]
59 | }
60 |
61 | @test "uninstall_command should remove relevant asdf-plugin metadata" {
62 | run asdf install dummy 1.0.0
63 | [ -f "$ASDF_DIR/installs/dummy/1.0.0/bin/dummy" ]
64 |
65 | run asdf install dummy 1.1.0
66 | [ -f "$ASDF_DIR/installs/dummy/1.1.0/bin/dummy" ]
67 |
68 | run asdf uninstall dummy 1.0.0
69 | run grep "asdf-plugin: dummy 1.1.0" "$ASDF_DIR/shims/dummy"
70 | [ "$status" -eq 0 ]
71 | run grep "asdf-plugin: dummy 1.0.0" "$ASDF_DIR/shims/dummy"
72 | [ "$status" -eq 1 ]
73 | }
74 |
75 | # Disabled as this test represents an invalid state. A shim (`gummy`) should
76 | # never exist unless it referenced an existing tool and version.
77 | #
78 | #@test "uninstall_command should not remove other unrelated shims" {
79 | # run asdf install dummy 1.0.0
80 | # [ -f "$ASDF_DIR/shims/dummy" ]
81 |
82 | # touch "$ASDF_DIR/shims/gummy"
83 | # [ -f "$ASDF_DIR/shims/gummy" ]
84 |
85 | # run asdf uninstall dummy 1.0.0
86 | # [ -f "$ASDF_DIR/shims/gummy" ]
87 | #}
88 |
89 | @test "uninstall command executes configured pre hook" {
90 | cat >"$HOME/.asdfrc" <<-'EOM'
91 | pre_asdf_uninstall_dummy = echo will uninstall dummy $1
92 | EOM
93 |
94 | run asdf install dummy 1.0.0
95 | run asdf uninstall dummy 1.0.0
96 | [ "$output" = "will uninstall dummy 1.0.0" ]
97 | }
98 |
99 | @test "uninstall command executes configured post hook" {
100 | cat >"$HOME/.asdfrc" <<-'EOM'
101 | post_asdf_uninstall_dummy = echo removed dummy $1
102 | EOM
103 |
104 | run asdf install dummy 1.0.0
105 | run asdf uninstall dummy 1.0.0
106 | [ "$output" = "removed dummy 1.0.0" ]
107 | }
108 |
--------------------------------------------------------------------------------
/test/update_command.bats:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bats
2 |
3 | #load test_helpers
4 |
5 | #setup() {
6 | # BASE_DIR=$(mktemp -dt asdf.XXXX)
7 | # HOME="$BASE_DIR/home"
8 | # ASDF_DIR="$HOME/.asdf"
9 | # git clone -o local "$(dirname "$BATS_TEST_DIRNAME")" "$ASDF_DIR"
10 | # git --git-dir "$ASDF_DIR/.git" remote add origin https://github.com/asdf-vm/asdf.git
11 | # mkdir -p "$ASDF_DIR/plugins"
12 | # mkdir -p "$ASDF_DIR/installs"
13 | # mkdir -p "$ASDF_DIR/shims"
14 | # mkdir -p "$ASDF_DIR/tmp"
15 | # ASDF_BIN="$ASDF_DIR/bin"
16 |
17 | # # shellcheck disable=SC2031
18 | # PATH="$ASDF_BIN:$ASDF_DIR/shims:$PATH"
19 | # install_dummy_plugin
20 |
21 | # PROJECT_DIR="$HOME/project"
22 | # mkdir -p "$PROJECT_DIR"
23 | #}
24 |
25 | #teardown() {
26 | # clean_asdf_dir
27 | #}
28 |
29 | #@test "asdf update --head should checkout the master branch" {
30 | # run asdf update --head
31 | # [ "$status" -eq 0 ]
32 | # cd "$ASDF_DIR"
33 | # [ "$(git rev-parse --abbrev-ref HEAD)" = "master" ]
34 | #}
35 |
36 | #@test "asdf update should checkout the latest non-RC tag" {
37 | # local tag=
38 | # tag=$(git tag | grep -vi "rc" | tail -1)
39 | # if [ -n "$tag" ]; then
40 | # run asdf update
41 | # [ "$status" -eq 0 ]
42 | # cd "$ASDF_DIR"
43 | # git tag | grep "$tag"
44 | # fi
45 | #}
46 |
47 | #@test "asdf update should checkout the latest tag when configured with use_release_candidates = yes" {
48 | # local tag=
49 | # tag=$(git tag | tail -1)
50 | # if [ -n "$tag" ]; then
51 | # export ASDF_CONFIG_DEFAULT_FILE="$BATS_TMPDIR/asdfrc_defaults"
52 | # echo "use_release_candidates = yes" >"$ASDF_CONFIG_DEFAULT_FILE"
53 | # run asdf update
54 | # [ "$status" -eq 0 ]
55 | # cd "$ASDF_DIR"
56 | # git tag | grep "$tag"
57 | # fi
58 | #}
59 |
60 | #@test "asdf update is a noop for when updates are disabled" {
61 | # touch "$ASDF_DIR/asdf_updates_disabled"
62 | # run asdf update
63 | # [ "$status" -eq 42 ]
64 | # [ $'Update command disabled. Please use the package manager that you used to install asdf to upgrade asdf.' = "$output" ]
65 | #}
66 |
67 | #@test "asdf update is a noop for non-git repos" {
68 | # rm -rf "$ASDF_DIR/.git/"
69 | # run asdf update
70 | # [ "$status" -eq 42 ]
71 | # [ $'Update command disabled. Please use the package manager that you used to install asdf to upgrade asdf.' = "$output" ]
72 | #}
73 |
74 | #@test "asdf update fails with exit code 1" {
75 | # git --git-dir "$ASDF_DIR/.git" remote set-url origin https://this-host-does-not-exist.xyz
76 | # run asdf update
77 | # [ "$status" -eq 1 ]
78 | #}
79 |
80 | #@test "asdf update should not remove plugin versions" {
81 | # run asdf install dummy 1.1.0
82 | # [ "$status" -eq 0 ]
83 | # [ "$(cat "$ASDF_DIR/installs/dummy/1.1.0/version")" = "1.1.0" ]
84 | # run asdf update
85 | # [ "$status" -eq 0 ]
86 | # [ -f "$ASDF_DIR/installs/dummy/1.1.0/version" ]
87 | # run asdf update --head
88 | # [ "$status" -eq 0 ]
89 | # [ -f "$ASDF_DIR/installs/dummy/1.1.0/version" ]
90 | #}
91 |
92 | #@test "asdf update should not remove plugins" {
93 | # # dummy plugin is already installed
94 | # run asdf update
95 | # [ "$status" -eq 0 ]
96 | # [ -d "$ASDF_DIR/plugins/dummy" ]
97 | # run asdf update --head
98 | # [ "$status" -eq 0 ]
99 | # [ -d "$ASDF_DIR/plugins/dummy" ]
100 | #}
101 |
102 | #@test "asdf update should not remove shims" {
103 | # run asdf install dummy 1.1.0
104 | # [ -f "$ASDF_DIR/shims/dummy" ]
105 | # run asdf update
106 | # [ "$status" -eq 0 ]
107 | # [ -f "$ASDF_DIR/shims/dummy" ]
108 | # run asdf update --head
109 | # [ "$status" -eq 0 ]
110 | # [ -f "$ASDF_DIR/shims/dummy" ]
111 | #}
112 |
--------------------------------------------------------------------------------
/test/where_command.bats:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bats
2 |
3 | load test_helpers
4 |
5 | setup() {
6 | setup_asdf_dir
7 | install_dummy_plugin
8 | install_dummy_version 1.0
9 | install_dummy_version 2.1
10 | install_dummy_version ref-master
11 | cd "$HOME" || exit
12 | }
13 |
14 | teardown() {
15 | clean_asdf_dir
16 | }
17 |
18 | @test "where shows install location of selected version" {
19 | run asdf where 'dummy' '1.0'
20 | [ "$status" -eq 0 ]
21 | [ "$output" = "$ASDF_DIR/installs/dummy/1.0" ]
22 | }
23 |
24 | @test "where understands versions installed by ref" {
25 | run asdf where 'dummy' 'ref:master'
26 | [ "$status" -eq 0 ]
27 | [ "$output" = "$ASDF_DIR/installs/dummy/ref-master" ]
28 | }
29 |
30 | @test "where shows install location of current version if no version specified" {
31 | echo 'dummy 2.1' >>"$HOME/.tool-versions"
32 |
33 | run asdf where 'dummy'
34 |
35 | [ "$status" -eq 0 ]
36 | [ "$output" = "$ASDF_DIR/installs/dummy/2.1" ]
37 | }
38 |
39 | @test "where shows install location of first current version if not version specified and multiple current versions" {
40 | echo 'dummy 2.1 1.0' >>"$HOME/.tool-versions"
41 | run asdf where 'dummy'
42 | [ "$status" -eq 0 ]
43 | [ "$output" = "$ASDF_DIR/installs/dummy/2.1" ]
44 | }
45 |
46 | @test "where should error when the plugin doesn't exist" {
47 | run asdf where "foobar"
48 | [ "$status" -eq 1 ]
49 | [ "$output" = "No such plugin: foobar" ]
50 | }
51 |
52 | @test "where should error when version is not installed" {
53 | run asdf where 'dummy' '1.6'
54 | [ "$status" -eq 1 ]
55 | [ "$output" = "Version not installed" ]
56 | }
57 |
58 | @test "where should error when system version is set" {
59 | run asdf where 'dummy' 'system'
60 | [ "$status" -eq 1 ]
61 | [ "$output" = "System version is selected" ]
62 | }
63 |
64 | @test "where should error when no current version selected and version not specified" {
65 | run asdf where 'dummy'
66 |
67 | local expected
68 | expected="No version is set for dummy; please run \`asdf set [options] dummy \`"
69 |
70 | [ "$status" -eq 1 ]
71 | [ "$output" = "$expected" ]
72 | }
73 |
--------------------------------------------------------------------------------
/test/which_command.bats:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bats
2 |
3 | load test_helpers
4 |
5 | setup() {
6 | setup_asdf_dir
7 | install_dummy_plugin
8 | run asdf install dummy 1.0
9 | run asdf install dummy 1.1
10 |
11 | PROJECT_DIR="$HOME/project"
12 | mkdir -p "$PROJECT_DIR"
13 | echo 'dummy 1.0' >>"$PROJECT_DIR/.tool-versions"
14 | }
15 |
16 | teardown() {
17 | clean_asdf_dir
18 | }
19 |
20 | @test "which should show dummy 1.0 main binary" {
21 | cd "$PROJECT_DIR"
22 |
23 | run asdf which "dummy"
24 | [ "$status" -eq 0 ]
25 | [ "$output" = "$ASDF_DIR/installs/dummy/1.0/bin/dummy" ]
26 | }
27 |
28 | @test "which should fail for unknown binary" {
29 | cd "$PROJECT_DIR"
30 |
31 | run asdf which "sunny"
32 | [ "$status" -eq 1 ]
33 | [ "$output" = "unknown command: sunny. Perhaps you have to reshim?" ]
34 | }
35 |
36 | @test "which should show dummy 1.0 other binary" {
37 | cd "$PROJECT_DIR"
38 |
39 | echo "echo bin bin/subdir" >"$ASDF_DIR/plugins/dummy/bin/list-bin-paths"
40 | chmod +x "$ASDF_DIR/plugins/dummy/bin/list-bin-paths"
41 | run asdf reshim dummy 1.0
42 |
43 | run asdf which "other_bin"
44 | [ "$status" -eq 0 ]
45 | [ "$output" = "$ASDF_DIR/installs/dummy/1.0/bin/subdir/other_bin" ]
46 | }
47 |
48 | @test "which should show path of system version" {
49 | echo 'dummy system' >"$PROJECT_DIR/.tool-versions"
50 | cd "$PROJECT_DIR"
51 |
52 | mkdir "$PROJECT_DIR/sys"
53 | touch "$PROJECT_DIR/sys/dummy"
54 | chmod +x "$PROJECT_DIR/sys/dummy"
55 |
56 | run env "PATH=$PATH:$PROJECT_DIR/sys" asdf which "dummy"
57 | [ "$status" -eq 0 ]
58 | [ "$output" = "$PROJECT_DIR/sys/dummy" ]
59 | }
60 |
61 | @test "which report when missing executable on system version" {
62 | echo 'dummy system' >"$PROJECT_DIR/.tool-versions"
63 | cd "$PROJECT_DIR"
64 |
65 | run asdf which "dummy"
66 | [ "$status" -eq 1 ]
67 | [ "$output" = "No dummy executable found for dummy system" ]
68 | }
69 |
70 | @test "which should inform when no binary is found" {
71 | cd "$PROJECT_DIR"
72 |
73 | run asdf which "bazbat"
74 | [ "$status" -eq 1 ]
75 | [ "$output" = "unknown command: bazbat. Perhaps you have to reshim?" ]
76 | }
77 |
78 | @test "which should use path returned by exec-path when present" {
79 | cd "$PROJECT_DIR"
80 | install_dummy_exec_path_script "dummy"
81 |
82 | run asdf which "dummy"
83 | [ "$status" -eq 0 ]
84 | [ "$output" = "$ASDF_DIR/installs/dummy/1.0/bin/custom/dummy" ]
85 | }
86 |
87 | @test "which should return the path set by the legacy file" {
88 | cd "$PROJECT_DIR"
89 |
90 | echo 'dummy 1.0' >>"$HOME/.tool-versions"
91 | echo '1.1' >>"$PROJECT_DIR/.dummy-version"
92 | rm "$PROJECT_DIR/.tool-versions"
93 | echo 'legacy_version_file = yes' >"$HOME/.asdfrc"
94 |
95 | run asdf which "dummy"
96 | [ "$status" -eq 0 ]
97 | [ "$output" = "$ASDF_DIR/installs/dummy/1.1/bin/dummy" ]
98 | }
99 |
100 | @test "which should not return shim path" {
101 | cd "$PROJECT_DIR"
102 | echo 'dummy 1.0' >"$PROJECT_DIR/.tool-versions"
103 | rm "$ASDF_DIR/installs/dummy/1.0/bin/dummy"
104 |
105 | run env PATH="$PATH:$ASDF_DIR/shims" asdf which dummy
106 | [ "$status" -eq 1 ]
107 | [ "$output" = "No dummy executable found for dummy 1.0" ]
108 | }
109 |
--------------------------------------------------------------------------------
/tools.go:
--------------------------------------------------------------------------------
1 | //go:build tools
2 |
3 | package tools
4 |
5 | import (
6 | _ "github.com/mgechev/revive"
7 | _ "honnef.co/go/tools/cmd/staticcheck"
8 | _ "mvdan.cc/gofumpt"
9 | )
10 |
--------------------------------------------------------------------------------
/version.txt:
--------------------------------------------------------------------------------
1 | 0.15.0
2 |
--------------------------------------------------------------------------------