From 15babb858a53d981e91604075274ebaaaa89625c Mon Sep 17 00:00:00 2001 From: Filip Richtarik Date: Sat, 3 Feb 2024 03:04:41 +0100 Subject: [PATCH] fix: downloads --- .github/workflows/codeql-analysis.yml | 6 +++--- .github/workflows/dependency-review.yml | 2 +- .github/workflows/test-action.yml | 4 ++-- .github/workflows/test.yml | 4 ++-- __tests__/get-arch.test.ts | 6 +++--- __tests__/get-os.test.ts | 6 +++--- __tests__/get-url.test.ts | 28 ++++++++++++------------- src/get-arch.ts | 8 ++++--- src/get-os.ts | 6 +++--- 9 files changed, 36 insertions(+), 34 deletions(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index f5bfa0a..dd9f075 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -13,12 +13,12 @@ jobs: - uses: actions/checkout@v4 - name: Initialize CodeQL - uses: github/codeql-action/init@v2 + uses: github/codeql-action/init@v3 with: languages: javascript - name: Autobuild - uses: github/codeql-action/autobuild@v2 + uses: github/codeql-action/autobuild@v3 - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + uses: github/codeql-action/analyze@v3 diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml index bbf8088..9fe7f7e 100644 --- a/.github/workflows/dependency-review.yml +++ b/.github/workflows/dependency-review.yml @@ -13,4 +13,4 @@ jobs: runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 - - uses: actions/dependency-review-action@v3 + - uses: actions/dependency-review-action@v4 diff --git a/.github/workflows/test-action.yml b/.github/workflows/test-action.yml index eeae154..bd9e98a 100644 --- a/.github/workflows/test-action.yml +++ b/.github/workflows/test-action.yml @@ -26,13 +26,13 @@ jobs: - uses: actions/checkout@v4 - name: Setup Hugo - uses: peaceiris/actions-hugo@v2.6.0 + uses: peaceiris/actions-hugo@v2 with: hugo-version: ${{ matrix.hugo-version }} extended: ${{ matrix.extended }} - name: Run hugo version - run: echo "::set-output name=hugo_version::$(hugo version)" + run: echo "hugo_version=$(hugo version)" >> $GITHUB_OUTPUT id: hugo_version - name: '${{ steps.hugo_version.outputs.hugo_version }}' diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a61b1f0..9a14a43 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -25,11 +25,11 @@ jobs: - uses: actions/checkout@v4 - name: Read .nvmrc - run: echo "::set-output name=NVMRC::$(cat .nvmrc)" + run: echo "NVMRC=$(cat .nvmrc)" >> $GITHUB_OUTPUT id: nvm - name: Setup Node - uses: actions/setup-node@v3.6.0 + uses: actions/setup-node@v4 with: node-version: '${{ steps.nvm.outputs.NVMRC }}' diff --git a/__tests__/get-arch.test.ts b/__tests__/get-arch.test.ts index 54dbb86..4cb85e9 100644 --- a/__tests__/get-arch.test.ts +++ b/__tests__/get-arch.test.ts @@ -2,9 +2,9 @@ import getArch from '../src/get-arch'; describe('getArch', () => { test('processor architecture', () => { - expect(getArch('x64')).toBe('64bit'); - expect(getArch('arm')).toBe('ARM'); - expect(getArch('arm64')).toBe('ARM64'); + expect(getArch('x64')).toBe('amd64'); + expect(getArch('arm')).toBe('arm'); + expect(getArch('arm64')).toBe('arm64'); }); test('exception', () => { diff --git a/__tests__/get-os.test.ts b/__tests__/get-os.test.ts index fbb204a..2c5c39b 100644 --- a/__tests__/get-os.test.ts +++ b/__tests__/get-os.test.ts @@ -2,9 +2,9 @@ import getOS from '../src/get-os'; describe('getOS', () => { test('os type', () => { - expect(getOS('linux')).toBe('Linux'); - expect(getOS('darwin')).toBe('macOS'); - expect(getOS('win32')).toBe('Windows'); + expect(getOS('linux')).toBe('linux'); + expect(getOS('darwin')).toBe('darwin'); + expect(getOS('win32')).toBe('windows'); }); test('exception', () => { diff --git a/__tests__/get-url.test.ts b/__tests__/get-url.test.ts index 89c22b4..8e19e94 100644 --- a/__tests__/get-url.test.ts +++ b/__tests__/get-url.test.ts @@ -2,19 +2,19 @@ import getURL from '../src/get-url'; describe('getURL()', () => { test('get a URL to an asset for each platform', () => { - const baseURL = 'https://github.com/gohugoio/hugo/releases/download/v0.58.2'; - const urlLinux = `${baseURL}/hugo_0.58.2_Linux-64bit.tar.gz`; - const urlLinuxExtended = `${baseURL}/hugo_extended_0.58.2_Linux-64bit.tar.gz`; - const urlMacOS = `${baseURL}/hugo_0.58.2_macOS-64bit.tar.gz`; - const urlMacOSExtended = `${baseURL}/hugo_extended_0.58.2_macOS-64bit.tar.gz`; - const urlWindows = `${baseURL}/hugo_0.58.2_Windows-64bit.zip`; - expect(getURL('Linux', '64bit', 'false', '0.58.2')).toBe(urlLinux); - expect(getURL('Linux', '64bit', 'true', '0.58.2')).not.toBe(urlLinux); - expect(getURL('MyOS', '64bit', 'false', '0.58.2')).not.toBe(urlLinux); - expect(getURL('Linux', '64bit', 'false', '0.58.1')).not.toBe(urlLinux); - expect(getURL('Linux', '64bit', 'true', '0.58.2')).toBe(urlLinuxExtended); - expect(getURL('macOS', '64bit', 'false', '0.58.2')).toBe(urlMacOS); - expect(getURL('macOS', '64bit', 'true', '0.58.2')).toBe(urlMacOSExtended); - expect(getURL('Windows', '64bit', 'false', '0.58.2')).toBe(urlWindows); + const baseURL = 'https://github.com/gohugoio/hugo/releases/download/v0.122.0'; + const urlLinux = `${baseURL}/hugo_0.122.0_linux-amd64.tar.gz`; + const urlLinuxExtended = `${baseURL}/hugo_extended_0.122.0_linux-amd64.tar.gz`; + const urlMacOS = `${baseURL}/hugo_0.122.0_darwin-universal.tar.gz`; + const urlMacOSExtended = `${baseURL}/hugo_extended_0.122.0_darwin-universal.tar.gz`; + const urlWindows = `${baseURL}/hugo_0.122.0_windows-amd64.zip`; + expect(getURL('linux', 'amd64', 'false', '0.122.0')).toBe(urlLinux); + expect(getURL('linux', 'amd64', 'true', '0.122.0')).not.toBe(urlLinux); + expect(getURL('MyOS', 'amd64', 'false', '0.122.0')).not.toBe(urlLinux); + expect(getURL('linux', 'amd64', 'false', '0.121.0')).not.toBe(urlLinux); + expect(getURL('linux', 'amd64', 'true', '0.122.0')).toBe(urlLinuxExtended); + expect(getURL('darwin', 'universal', 'false', '0.122.0')).toBe(urlMacOS); + expect(getURL('darwin', 'universal', 'true', '0.122.0')).toBe(urlMacOSExtended); + expect(getURL('windows', 'amd64', 'false', '0.122.0')).toBe(urlWindows); }); }); diff --git a/src/get-arch.ts b/src/get-arch.ts index 04e56af..4292bd2 100644 --- a/src/get-arch.ts +++ b/src/get-arch.ts @@ -1,11 +1,13 @@ export default function getArch(arch: string): string { switch (arch) { case 'x64': - return '64bit'; + return 'amd64'; case 'arm': - return 'ARM'; + return 'arm'; case 'arm64': - return 'ARM64'; + return 'arm64'; + case 'universal': + return 'universal'; default: throw new Error(`${arch} is not supported`); } diff --git a/src/get-os.ts b/src/get-os.ts index 8360089..ed8f55e 100644 --- a/src/get-os.ts +++ b/src/get-os.ts @@ -1,11 +1,11 @@ export default function getOS(platform: string): string { switch (platform) { case 'linux': - return 'Linux'; + return 'linux'; case 'darwin': - return 'macOS'; + return 'darwin'; case 'win32': - return 'Windows'; + return 'windows'; default: throw new Error(`${platform} is not supported`); }