From c5e329057fcd6dc2ff62d42fab97b58f672e5ed4 Mon Sep 17 00:00:00 2001 From: Benedikt Rief Date: Wed, 7 Aug 2024 02:53:37 +0200 Subject: [PATCH 1/6] Add support for Windows userprofile paths with whitespace --- hooks/post_install.lua | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/hooks/post_install.lua b/hooks/post_install.lua index 6cc7f9f..9e11736 100644 --- a/hooks/post_install.lua +++ b/hooks/post_install.lua @@ -36,12 +36,35 @@ function InstallComposerForWin(path) error(err) end - local code = os.execute(path .. '\\php.exe ' .. setup .. ' --install-dir=' .. path) + local phpPath = path .. "\\php.exe" + local setupPath = setup + local installPath = path + local execString = phpPath .. ' ' .. setupPath .. ' --install-dir=' .. installPath + + + if RUNTIME.osType == 'windows' then + phpPath = "\"" .. phpPath .. "\"" + setupPath = "\"" .. setupPath .. "\"" + installPath = "\"" .. installPath .. "\"" + + local winPrefix = '' + + util.write_file(path .. '\\composer_install.bat', winPrefix .. phpPath .. ' ' .. setupPath .. ' --install-dir=' .. installPath) + + execString = path .. '\\composer_install.bat' + end + + local code = os.execute(execString) if code ~= 0 then error('Failed to install composer.') end os.remove(setup) + + if RUNTIME.osType == 'windows' then + os.remove(path .. '\\composer_install.bat') + end + util.write_file(path .. '\\composer.bat', '@php "%~dp0composer.phar" %*') end From a0c4e341117a8312e3858212deb9b129fc7eafd9 Mon Sep 17 00:00:00 2001 From: windmillcode0 Date: Tue, 6 May 2025 07:02:07 -0400 Subject: [PATCH 2/6] feat: support to install LTS php versions along with optional TS and NTS versions (#11) --- README.md | 5 ++++- hooks/available.lua | 49 +++++++++++++++++++++++++++---------------- hooks/pre_install.lua | 10 ++++++--- lib/constants.lua | 1 + lib/util.lua | 1 - 5 files changed, 43 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 27f7c33..1d804f2 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,10 @@ vfox add php # install an available version vfox search php # or specific version -vfox install php@8.3.3 +vfox install php@8.4.5 + +# or nts version +vfox install php@8.4.5-nts ``` ## Prerequirements diff --git a/hooks/available.lua b/hooks/available.lua index 6a7a19c..e2f26c7 100644 --- a/hooks/available.lua +++ b/hooks/available.lua @@ -15,27 +15,40 @@ function PLUGIN:Available(ctx) end function GetReleaseListForWindows() - local resp, err = http.get({ - url = WIN_URL - }) - local doc = html.parse(resp.body) - local result = {} - doc:find('a'):each(function(i, selection) - local versionStr = selection:text() - if util.filter_windows_version(versionStr) then - local versions = util.split_string(versionStr, '-') - if util.compare_versions(versions[2], "5.3.2") >= 0 then - table.insert(result, { - version = versions[2], - name = versionStr, - }) + local urls = { WIN_URL, WIN_URL_LTS } + + for _, url in ipairs(urls) do + local resp, err = http.get({ url = url }) + + if resp then + local doc = html.parse(resp.body) + local versions = {} + doc:find('a'):each(function(i, selection) + local versionStr = selection:text() + table.insert(versions, versionStr) + end) + -- TODO like this because for some reason sorting it at the end resets is_from_lts to false + table.sort(versions, function(a, b) + return util.compare_versions(a, b) > 0 + end) + for _, versionStr in ipairs(versions) do + if util.filter_windows_version(versionStr) then + local versions = util.split_string(versionStr, '-') + if util.compare_versions(versions[2], "5.3.2") >= 0 then + local entry = { + version = (versions[3] ~= "nts") and versions[2] or versions[2] .. "-nts", + name = versionStr + } + + entry.is_from_lts = (url == WIN_URL_LTS) + table.insert(result, entry) + end + end end end - end) - table.sort(result, function(a, b) - return util.compare_versions(a.version, b.version) > 0 - end) + end + return result end diff --git a/hooks/pre_install.lua b/hooks/pre_install.lua index 61c9031..f69158d 100644 --- a/hooks/pre_install.lua +++ b/hooks/pre_install.lua @@ -10,11 +10,10 @@ require('constants') --- @return table Version information function PLUGIN:PreInstall(ctx) local version = ctx.version - local lists = self:Available({}) if version == 'latest' or version == '' then version = lists[1].version - end + end local versions = {} for _, value in pairs(lists) do @@ -40,9 +39,14 @@ function PLUGIN:PreInstall(ctx) end function GetReleaseForWindows(versions) + url = WIN_URL .. versions.name + + if (versions.is_from_lts) then + url = WIN_URL_LTS .. versions.name + end return { version = versions.version, - url = WIN_URL .. versions.name, + url = url, } end diff --git a/lib/constants.lua b/lib/constants.lua index a442863..25387ac 100644 --- a/lib/constants.lua +++ b/lib/constants.lua @@ -1,2 +1,3 @@ URL = 'https://www.php.net/' WIN_URL = 'https://windows.php.net/downloads/releases/archives/' +WIN_URL_LTS = 'https://windows.php.net/downloads/releases/' \ No newline at end of file diff --git a/lib/util.lua b/lib/util.lua index 563c992..6b62ab5 100644 --- a/lib/util.lua +++ b/lib/util.lua @@ -42,7 +42,6 @@ end function util.filter_windows_version(version) return util.starts_with(version, 'php') - and string.find(version, 'nts') and not util.starts_with(version, 'php-debug') and not util.starts_with(version, 'php-devel') and not util.starts_with(version, 'php-test') From 2e2bc4701a7d12ce8b8cd10071cffb22454d31b7 Mon Sep 17 00:00:00 2001 From: Han Li Date: Fri, 16 May 2025 09:24:03 +0000 Subject: [PATCH 3/6] release v0.2.1 --- metadata.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.lua b/metadata.lua index 28ef7d2..21ccf90 100644 --- a/metadata.lua +++ b/metadata.lua @@ -5,7 +5,7 @@ PLUGIN = {} --- Plugin name PLUGIN.name = "php" --- Plugin version -PLUGIN.version = "0.2.0" +PLUGIN.version = "0.2.1" --- Plugin homepage PLUGIN.homepage = "https://github.com/version-fox/vfox-php" --- Plugin license, please choose a correct license according to your needs. From b2f427a98cf2ab9692800cafd58a69c247df41c3 Mon Sep 17 00:00:00 2001 From: Han Li Date: Fri, 16 May 2025 09:25:41 +0000 Subject: [PATCH 4/6] fix ci --- .github/workflows/publish.yaml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index f44d298..786873c 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -15,7 +15,7 @@ jobs: run: | echo "REPO_NAME=$(echo ${{ github.repository }} | cut -d'/' -f2)" >> $GITHUB_ENV echo "VERSION=$(echo ${{ github.ref }} | cut -d'/' -f3 | cut -c2-)" >> $GITHUB_ENV - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up Lua uses: leafo/gh-actions-lua@v8 @@ -30,14 +30,14 @@ jobs: - name: Generate manifest run: | sudo lua -e ' - require("metadata"); - local dkjson = require("dkjson"); - PLUGIN.downloadUrl = "https://github.com/${{ github.repository }}/releases/download/v${{ env.VERSION }}/${{ env.REPO_NAME }}-${{ env.VERSION }}.zip"; - local str = dkjson.encode(PLUGIN); + require("metadata"); + local dkjson = require("dkjson"); + PLUGIN.downloadUrl = "https://github.com/${{ github.repository }}/releases/download/v${{ env.VERSION }}/${{ env.REPO_NAME }}-${{ env.VERSION }}.zip"; + local str = dkjson.encode(PLUGIN); print(str)' > manifest.json cat manifest.json - name: Upload JSON file - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: manifest path: manifest.json @@ -50,9 +50,9 @@ jobs: echo "REPO_NAME=$(echo ${{ github.repository }} | cut -d'/' -f2)" >> $GITHUB_ENV echo "VERSION=$(echo ${{ github.ref }} | cut -d'/' -f3 | cut -c2-)" >> $GITHUB_ENV - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Download JSON file - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v4 with: name: manifest - name: Compress build files From 280808dab57f82f74ada30ee97381700f255b9a5 Mon Sep 17 00:00:00 2001 From: Risu <79110363+risu729@users.noreply.github.com> Date: Thu, 19 Jun 2025 19:02:44 +1000 Subject: [PATCH 5/6] feat: support lts releases in linux --- hooks/available.lua | 35 +++++++++++++++++++++-------------- hooks/pre_install.lua | 4 ++-- lib/constants.lua | 8 +++++--- 3 files changed, 28 insertions(+), 19 deletions(-) diff --git a/hooks/available.lua b/hooks/available.lua index e2f26c7..59e5027 100644 --- a/hooks/available.lua +++ b/hooks/available.lua @@ -16,7 +16,7 @@ end function GetReleaseListForWindows() local result = {} - local urls = { WIN_URL, WIN_URL_LTS } + local urls = { WIN_RELEASES_URL, WIN_RELEASES_URL_LTS } for _, url in ipairs(urls) do local resp, err = http.get({ url = url }) @@ -41,7 +41,7 @@ function GetReleaseListForWindows() name = versionStr } - entry.is_from_lts = (url == WIN_URL_LTS) + entry.is_from_lts = (url == WIN_RELEASES_URL_LTS) table.insert(result, entry) end end @@ -53,20 +53,27 @@ function GetReleaseListForWindows() end function GetReleaseListForLinux() - local resp, err = http.get({ - url = URL .. '/releases' - }) - local doc = html.parse(resp.body) - local result = {} - doc:find("#layout-content h2"):each(function(i, selection) - local versionStr = selection:text() - if util.compare_versions(versionStr, "5.3.2") >= 0 then - table.insert(result, { - version = versionStr, - }) + local urls = { RELEASES_URL, RELEASES_URL_LTS } + + for _, url in ipairs(urls) do + local resp, err = http.get({ url = url }) + local is_from_lts = (url == RELEASES_URL_LTS) + + if resp then + local doc = html.parse(resp.body) + local query = "#layout-content " .. (is_from_lts and "h3" or "h2") + doc:find(query):each(function(i, selection) + local versionStr = is_from_lts and selection:attr("id") or selection:text() + versionStr = versionStr:gsub("^v", "") + if util.compare_versions(versionStr, "5.3.2") >= 0 then + table.insert(result, { + version = versionStr, + }) + end + end) end - end) + end table.sort(result, function(a, b) return util.compare_versions(a.version, b.version) > 0 diff --git a/hooks/pre_install.lua b/hooks/pre_install.lua index f69158d..f9fa16e 100644 --- a/hooks/pre_install.lua +++ b/hooks/pre_install.lua @@ -39,10 +39,10 @@ function PLUGIN:PreInstall(ctx) end function GetReleaseForWindows(versions) - url = WIN_URL .. versions.name + url = WIN_RELEASES_URL .. versions.name if (versions.is_from_lts) then - url = WIN_URL_LTS .. versions.name + url = WIN_RELEASES_URL_LTS .. versions.name end return { version = versions.version, diff --git a/lib/constants.lua b/lib/constants.lua index 25387ac..f7f0250 100644 --- a/lib/constants.lua +++ b/lib/constants.lua @@ -1,3 +1,5 @@ -URL = 'https://www.php.net/' -WIN_URL = 'https://windows.php.net/downloads/releases/archives/' -WIN_URL_LTS = 'https://windows.php.net/downloads/releases/' \ No newline at end of file +URL = 'https://www.php.net' +RELEASES_URL = URL .. '/releases' +RELEASES_URL_LTS = URL .. '/downloads' +WIN_RELEASES_URL = 'https://windows.php.net/downloads/releases/archives/' +WIN_RELEASES_URL_LTS = 'https://windows.php.net/downloads/releases/' From 6c1e8ff7522c77825545c7b5d48ee7e41f37594f Mon Sep 17 00:00:00 2001 From: Risu <79110363+risu729@users.noreply.github.com> Date: Thu, 19 Jun 2025 19:26:53 +1000 Subject: [PATCH 6/6] fix: use redirected urls --- lib/constants.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/constants.lua b/lib/constants.lua index f7f0250..ce2e09a 100644 --- a/lib/constants.lua +++ b/lib/constants.lua @@ -1,5 +1,5 @@ URL = 'https://www.php.net' -RELEASES_URL = URL .. '/releases' -RELEASES_URL_LTS = URL .. '/downloads' +RELEASES_URL = URL .. '/releases/' +RELEASES_URL_LTS = URL .. '/downloads.php' WIN_RELEASES_URL = 'https://windows.php.net/downloads/releases/archives/' WIN_RELEASES_URL_LTS = 'https://windows.php.net/downloads/releases/'