├── .github └── workflows │ └── publish.yaml ├── .gitignore ├── .tool-versions ├── Injection.lua ├── LICENSE ├── README.md ├── hooks ├── available.lua ├── env_keys.lua ├── parse_legacy_file.lua ├── pre_install.lua └── pre_use.lua ├── lib └── util.lua └── metadata.lua /.github/workflows/publish.yaml: -------------------------------------------------------------------------------- 1 | name: generate and publish manifest 2 | 3 | on: 4 | push: 5 | tags: [ 'v*' ] 6 | 7 | permissions: 8 | contents: write 9 | 10 | jobs: 11 | generate-manifest-json: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - name: Set repo name 15 | run: | 16 | echo "REPO_NAME=$(echo ${{ github.repository }} | cut -d'/' -f2)" >> $GITHUB_ENV 17 | echo "VERSION=$(echo ${{ github.ref }} | cut -d'/' -f3 | cut -c2-)" >> $GITHUB_ENV 18 | - uses: actions/checkout@v2 19 | 20 | - name: Set up Lua 21 | uses: leafo/gh-actions-lua@v8 22 | with: 23 | luaVersion: '5.3.5' 24 | 25 | - name: Install dependencies 26 | run: | 27 | sudo apt-get install luarocks 28 | sudo luarocks install dkjson 29 | 30 | - name: Generate manifest 31 | run: | 32 | sudo lua -e ' 33 | require("metadata"); 34 | local dkjson = require("dkjson"); 35 | PLUGIN.downloadUrl = "https://github.com/${{ github.repository }}/releases/download/v${{ env.VERSION }}/${{ env.REPO_NAME }}-${{ env.VERSION }}.zip"; 36 | local str = dkjson.encode(PLUGIN); 37 | print(str)' > manifest.json 38 | cat manifest.json 39 | - name: Upload JSON file 40 | uses: actions/upload-artifact@v2 41 | with: 42 | name: manifest 43 | path: manifest.json 44 | release-plugin-and-manifest: 45 | needs: generate-manifest-json 46 | runs-on: ubuntu-latest 47 | steps: 48 | - name: Set repo name 49 | run: | 50 | echo "REPO_NAME=$(echo ${{ github.repository }} | cut -d'/' -f2)" >> $GITHUB_ENV 51 | echo "VERSION=$(echo ${{ github.ref }} | cut -d'/' -f3 | cut -c2-)" >> $GITHUB_ENV 52 | - name: Checkout code 53 | uses: actions/checkout@v2 54 | - name: Download JSON file 55 | uses: actions/download-artifact@v2 56 | with: 57 | name: manifest 58 | - name: Compress build files 59 | uses: thedoctor0/zip-release@0.7.6 60 | with: 61 | type: "zip" 62 | directory: "./" 63 | filename: "${{ env.REPO_NAME }}-${{ env.VERSION }}.zip" 64 | exclusions: "*.git* manifest.json" 65 | - name: Publish release 66 | uses: svenstaro/upload-release-action@v2 67 | with: 68 | repo_token: ${{ secrets.GITHUB_TOKEN }} 69 | file: ./${{ env.REPO_NAME }}-${{ env.VERSION }}.zip 70 | tag: v${{ env.VERSION }} 71 | file_glob: true 72 | - name: Publish manifest 73 | uses: svenstaro/upload-release-action@v2 74 | with: 75 | repo_token: ${{ secrets.GITHUB_TOKEN }} 76 | file: ./manifest.json 77 | tag: "manifest" 78 | overwrite: true 79 | file_glob: true -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea -------------------------------------------------------------------------------- /.tool-versions: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/version-fox/vfox-nodejs/4aaafa4b049012765d8f232a217406a4887ad027/.tool-versions -------------------------------------------------------------------------------- /Injection.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | Do not change any thing in the current file, 3 | it's just there to show what objects are injected by vfox and what they do. 4 | 5 | It's just handy when developing plugins, IDE can use this object for code hints! 6 | --]] 7 | RUNTIME = { 8 | --- Operating system type at runtime (Windows, Linux, Darwin) 9 | osType = "", 10 | --- Operating system architecture at runtime (amd64, arm64, etc.) 11 | archType = "", 12 | --- vfox runtime version 13 | version = "", 14 | } 15 | 16 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2024 Han Li and contributors 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vfox-nodejs 2 | 3 | Node.js plugin for [vfox](https://vfox.lhan.me/). 4 | 5 | ## Install 6 | 7 | After installing [vfox](https://github.com/version-fox/vfox), install the plugin by running: 8 | 9 | ```bash 10 | vfox add nodejs 11 | ``` 12 | 13 | ## Mirror 14 | 15 | You can configure the mirror by `VFOX_NODEJS_MIRROR` environment variable. The default value 16 | is `https://nodejs.org/dist/`. 17 | -------------------------------------------------------------------------------- /hooks/available.lua: -------------------------------------------------------------------------------- 1 | local json = require("json") 2 | local http = require("http") 3 | local util = require("util") 4 | 5 | --- Return all available versions provided by this plugin 6 | --- @param ctx table Empty table used as context, for future extension 7 | --- @return table Descriptions of available versions and accompanying tool descriptions 8 | available_result = nil 9 | function PLUGIN:Available(ctx) 10 | if available_result then 11 | return available_result 12 | end 13 | local resp, err = http.get({ 14 | url = util.getBaseUrl() .. util.VersionSourceUrl 15 | }) 16 | if err ~= nil or resp.status_code ~= 200 then 17 | return {} 18 | end 19 | local body = json.decode(resp.body) 20 | local result = {} 21 | 22 | for _, v in ipairs(body) do 23 | table.insert(result, { 24 | version = string.gsub(v.version, "^v", ""), 25 | note = v.lts and "LTS" or "", 26 | addition = { 27 | { 28 | name = "npm", 29 | version = v.npm, 30 | } 31 | } 32 | }) 33 | end 34 | table.sort(result, util.compare_versions) 35 | available_result = result 36 | return result 37 | end -------------------------------------------------------------------------------- /hooks/env_keys.lua: -------------------------------------------------------------------------------- 1 | --- Each SDK may have different environment variable configurations. 2 | --- This allows plugins to define custom environment variables (including PATH settings) 3 | --- Note: Be sure to distinguish between environment variable settings for different platforms! 4 | --- @param ctx table Context information 5 | --- @field ctx.path string SDK installation directory 6 | function PLUGIN:EnvKeys(ctx) 7 | --- this variable is same as ctx.sdkInfo['plugin-name'].path 8 | local version_path = ctx.path 9 | if RUNTIME.osType == "windows" then 10 | return { 11 | { 12 | key = "PATH", 13 | value = version_path 14 | }, 15 | } 16 | else 17 | return { 18 | { 19 | key = "PATH", 20 | value = version_path .. "/bin" 21 | }, 22 | } 23 | end 24 | 25 | end -------------------------------------------------------------------------------- /hooks/parse_legacy_file.lua: -------------------------------------------------------------------------------- 1 | --- Parse the legacy file found by vfox to determine the version of the tool. 2 | --- Useful to extract version numbers from files like JavaScript's package.json or Golangs go.mod. 3 | function PLUGIN:ParseLegacyFile(ctx) 4 | local filepath = ctx.filepath 5 | local file = io.open(filepath, "r") 6 | local content = file:read("*a") 7 | file:close() 8 | content = content:gsub("%s+", "") 9 | if content == "" then 10 | return {} 11 | end 12 | function resolve_legacy_version(strategy, query) 13 | local list = {} 14 | 15 | if strategy == "latest_installed" then 16 | list = ctx:getInstalledVersions() 17 | elseif strategy == "latest_available" then 18 | for _, av in pairs(self:Available({})) do 19 | table.insert(list, av.version) 20 | end 21 | else 22 | -- Just return the original query 23 | return query 24 | end 25 | 26 | local resolved = "" 27 | for _, item in pairs(list) do 28 | if item:match("^" .. query) then 29 | resolved = item 30 | break 31 | end 32 | end 33 | 34 | if resolved ~= "" then 35 | return resolved 36 | elseif strategy ~= "latest_available" then 37 | -- If no version is installed, fallback to latest_available 38 | return resolve_legacy_version("latest_available", query) 39 | else 40 | -- Give up and pretty the query itself 41 | return query 42 | end 43 | end 44 | local query = resolve_version(content) 45 | 46 | query = resolve_legacy_version("latest_installed", query) 47 | 48 | return { 49 | version = query 50 | } 51 | end 52 | 53 | function resolve_version(query) 54 | query = string.lower(query:gsub("v", "")) 55 | 56 | if query:match("^lts-") then 57 | query = query:gsub("-", "/") 58 | end 59 | 60 | local nodejs_codenames = { 61 | argon = 4, 62 | boron = 6, 63 | carbon = 8, 64 | dubnium = 10, 65 | erbium = 12, 66 | fermium = 14, 67 | gallium = 16, 68 | hydrogen = 18, 69 | iron = 20 70 | } 71 | 72 | for codename, version_number in pairs(nodejs_codenames) do 73 | if query == "lts/" .. codename then 74 | query = tostring(version_number) 75 | break 76 | end 77 | end 78 | 79 | if query == "lts" or query == "lts/*" then 80 | query = tostring(nodejs_codenames[#nodejs_codenames]) 81 | end 82 | 83 | return query 84 | end 85 | 86 | -------------------------------------------------------------------------------- /hooks/pre_install.lua: -------------------------------------------------------------------------------- 1 | local http = require("http") 2 | local util = require("util") 3 | --- Returns some pre-installed information, such as version number, download address, local files, etc. 4 | --- If checksum is provided, vfox will automatically check it for you. 5 | --- @param ctx table 6 | --- @field ctx.version string User-input version 7 | --- @return table Version information 8 | function PLUGIN:PreInstall(ctx) 9 | local version = ctx.version 10 | 11 | if version == "latest" then 12 | local lists = self:Available({}) 13 | version = lists[1].version 14 | end 15 | 16 | if not util.is_semver_simple(version) then 17 | local lists = self:Available({}) 18 | local shorthands = util.calculate_shorthand(lists) 19 | version = shorthands[version] 20 | end 21 | 22 | if (version == nil) then 23 | error("version not found for provided version " .. (ctx.version or "null")) 24 | end 25 | 26 | local arch_type = RUNTIME.archType 27 | local ext = ".tar.gz" 28 | local osType = RUNTIME.osType 29 | if RUNTIME.archType == "amd64" then 30 | arch_type = "x64" 31 | end 32 | if RUNTIME.osType == "windows" then 33 | ext = ".zip" 34 | osType = "win" 35 | end 36 | -- add logic for macOS M1~ 37 | if RUNTIME.osType == "darwin" then 38 | local major, _ = util.extract_semver(version) 39 | if major and tonumber(major) <= 16 then 40 | arch_type = "x64" 41 | end 42 | end 43 | 44 | local filename = util.FileName:format(version, osType, arch_type, ext) 45 | local baseUrl = util.getBaseUrl() .. util.NodeBaseUrl:format(version) 46 | 47 | local resp, err = http.get({ 48 | url = baseUrl .. "SHASUMS256.txt" 49 | }) 50 | if err ~= nil or resp.status_code ~= 200 then 51 | error("get checksum failed") 52 | end 53 | local checksum = util.get_checksum(resp.body, filename) 54 | return { 55 | version = version, 56 | url = baseUrl .. filename, 57 | sha256 = checksum, 58 | } 59 | end 60 | -------------------------------------------------------------------------------- /hooks/pre_use.lua: -------------------------------------------------------------------------------- 1 | local util = require("util") 2 | --- When user invoke `use` command, this function will be called to get the 3 | --- valid version information. 4 | --- @param ctx table Context information 5 | function PLUGIN:PreUse(ctx) 6 | --- user input version 7 | local version = ctx.version 8 | 9 | local shorthands = util.calculate_shorthand(ctx.installedSdks) 10 | 11 | if not util.is_semver_simple(version) then 12 | version = shorthands[version] 13 | end 14 | 15 | --- return the version information 16 | return { 17 | version = version, 18 | } 19 | end -------------------------------------------------------------------------------- /lib/util.lua: -------------------------------------------------------------------------------- 1 | local UTIL = {} 2 | 3 | UTIL.NodeBaseUrl = "/v%s/" 4 | UTIL.FileName = "node-v%s-%s-%s%s" 5 | UTIL.VersionSourceUrl = "/index.json" 6 | 7 | function UTIL.getBaseUrl() 8 | local mirror = os.getenv("VFOX_NODEJS_MIRROR") 9 | if mirror == "" or mirror == nil then 10 | return "https://nodejs.org/dist" 11 | end 12 | return mirror 13 | end 14 | 15 | function UTIL.compare_versions(v1o, v2o) 16 | local v1 = v1o.version 17 | local v2 = v2o.version 18 | local v1_parts = {} 19 | for part in string.gmatch(v1, "[^.]+") do 20 | table.insert(v1_parts, tonumber(part)) 21 | end 22 | 23 | local v2_parts = {} 24 | for part in string.gmatch(v2, "[^.]+") do 25 | table.insert(v2_parts, tonumber(part)) 26 | end 27 | 28 | for i = 1, math.max(#v1_parts, #v2_parts) do 29 | local v1_part = v1_parts[i] or 0 30 | local v2_part = v2_parts[i] or 0 31 | if v1_part > v2_part then 32 | return true 33 | elseif v1_part < v2_part then 34 | return false 35 | end 36 | end 37 | 38 | return false 39 | end 40 | 41 | function UTIL.get_checksum(file_content, file_name) 42 | for line in string.gmatch(file_content, '([^\n]*)\n?') do 43 | local checksum, name = string.match(line, '(%w+)%s+(%S+)') 44 | if name == file_name then 45 | return checksum 46 | end 47 | end 48 | return nil 49 | end 50 | 51 | function UTIL.is_semver_simple(str) 52 | -- match pattern: three digits, separated by dot 53 | local pattern = "^%d+%.%d+%.%d+$" 54 | return str:match(pattern) ~= nil 55 | end 56 | 57 | function UTIL.extract_semver(semver) 58 | local pattern = "^(%d+)%.(%d+)%.[%d.]+$" 59 | local major, minor = semver:match(pattern) 60 | return major, minor 61 | end 62 | 63 | function UTIL.calculate_shorthand(list) 64 | local versions_shorthand = {} 65 | for _, v in pairs(list) do 66 | local version = v.version 67 | local major, minor = UTIL.extract_semver(version) 68 | 69 | if major then 70 | if not versions_shorthand[major] then 71 | versions_shorthand[major] = version 72 | else 73 | if UTIL.compare_versions({ version = version }, { version = versions_shorthand[major] }) then 74 | versions_shorthand[major] = version 75 | end 76 | end 77 | 78 | if minor then 79 | local major_minor = major .. "." .. minor 80 | if not versions_shorthand[major_minor] then 81 | versions_shorthand[major_minor] = version 82 | else 83 | if UTIL.compare_versions({ version = version }, { version = versions_shorthand[major_minor] }) then 84 | versions_shorthand[major_minor] = version 85 | end 86 | end 87 | end 88 | end 89 | end 90 | 91 | return versions_shorthand 92 | end 93 | 94 | return UTIL 95 | -------------------------------------------------------------------------------- /metadata.lua: -------------------------------------------------------------------------------- 1 | --- !!! DO NOT EDIT OR RENAME !!! 2 | PLUGIN = {} 3 | 4 | --- !!! MUST BE SET !!! 5 | --- Plugin name 6 | PLUGIN.name = "nodejs" 7 | --- Plugin version 8 | PLUGIN.version = "0.3.0" 9 | --- Plugin repository 10 | PLUGIN.homepage = "https://github.com/version-fox/vfox-nodejs" 11 | --- Plugin license 12 | PLUGIN.license = "Apache 2.0" 13 | --- Plugin description 14 | PLUGIN.description = "Node.js runtime environment." 15 | 16 | --- !!! OPTIONAL !!! 17 | --- minimum compatible vfox version 18 | PLUGIN.minRuntimeVersion = "0.3.0" 19 | --- Some things that need user to be attention! 20 | PLUGIN.notes = {} 21 | 22 | --- List legacy configuration filenames for determining the specified version of the tool. 23 | --- such as ".node-version", ".nvmrc", etc. 24 | PLUGIN.legacyFilenames = { 25 | ".node-version", 26 | ".nvmrc" 27 | } 28 | --------------------------------------------------------------------------------