From acf26a011761142edc1f3ca773445d617e417172 Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Sat, 9 Sep 2023 16:19:53 +0200 Subject: [PATCH 01/57] Also test for different platforms --- .github/workflows/test.yml | 45 +++++++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 10 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9a842a12..f3228226 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,7 +9,10 @@ on: jobs: default: - runs-on: ubuntu-latest + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 - name: Move pixi.toml @@ -21,7 +24,10 @@ jobs: ./.pixi/env/bin/python --version | grep -q 3.11 no-run-install: - runs-on: ubuntu-latest + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 - name: Move pixi.toml @@ -33,7 +39,10 @@ jobs: ! test -d .pixi custom-pixi-version: - runs-on: ubuntu-latest + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 - name: Move pixi.toml @@ -55,7 +64,10 @@ jobs: - run: pixi --version | grep -q "pixi 0.0.8" custom-manifest-path: - runs-on: ubuntu-latest + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 - uses: ./ @@ -65,7 +77,7 @@ jobs: different-log-level: strategy: matrix: - os: [ubuntu-latest, macos-latest] + os: [ubuntu-latest, macos-latest, windows-latest] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 @@ -91,7 +103,10 @@ jobs: # shell: pixi-shell {0} custom-bin-path: - runs-on: ubuntu-latest + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 - name: Move pixi.toml @@ -105,7 +120,10 @@ jobs: which pixi | grep -q "..." auth-token: - runs-on: windows-latest + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 - name: Move pixi.toml @@ -133,7 +151,10 @@ jobs: auth-password: TODO auth-conda-token: - runs-on: ubuntu-latest + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 - name: Move pixi.toml @@ -147,9 +168,10 @@ jobs: # not implemented yet if: false name: post-cleanup ${{ matrix.post-cleanup }} - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} strategy: matrix: + os: [ubuntu-latest, macos-latest, windows-latest] include: - post-cleanup: 'none' env-exists: '' @@ -179,7 +201,10 @@ jobs: post-cleanup: ${{ matrix.post-cleanup }} no-lockfile: - runs-on: ubuntu-latest + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 - name: Move pixi.toml From 319c4c329baefcc079bed11d4d97331413741fd4 Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Sat, 9 Sep 2023 16:23:45 +0200 Subject: [PATCH 02/57] . --- .github/workflows/test.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f3228226..8028d669 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,7 +21,7 @@ jobs: - run: | pixi info test -f .pixi/env/bin/python - ./.pixi/env/bin/python --version | grep -q 3.11 + ./.pixi/env/bin/python${{ matrix.os == 'windows-latest' && '.exe' || '' }} --version | grep -q 3.11 no-run-install: strategy: @@ -37,6 +37,7 @@ jobs: run-install: false - run: | ! test -d .pixi + shell: bash custom-pixi-version: strategy: @@ -213,4 +214,4 @@ jobs: - run: | pixi info test -f .pixi/env/bin/python - ./.pixi/env/bin/python --version | grep -q 3.11 + ./.pixi/env/bin/python${{ matrix.os == 'windows-latest' && '.exe' || '' }} --version | grep -q 3.11 From 788160f3b8d733aaf7069ccd0cb7f2db4d246425 Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Sat, 9 Sep 2023 16:25:28 +0200 Subject: [PATCH 03/57] . --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8028d669..83ccf621 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,6 +22,7 @@ jobs: pixi info test -f .pixi/env/bin/python ./.pixi/env/bin/python${{ matrix.os == 'windows-latest' && '.exe' || '' }} --version | grep -q 3.11 + shell: bash no-run-install: strategy: From e0e989b7236e04048cc659869946a6ad8b46cb78 Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Sat, 9 Sep 2023 16:27:07 +0200 Subject: [PATCH 04/57] tree --- .github/workflows/test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 83ccf621..018e05f3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -19,7 +19,9 @@ jobs: run: mv test/default/* . - uses: ./ - run: | + set -o pipefail pixi info + tree .pixi test -f .pixi/env/bin/python ./.pixi/env/bin/python${{ matrix.os == 'windows-latest' && '.exe' || '' }} --version | grep -q 3.11 shell: bash From 4600c50b97e512274c38cfc2425825c0c5ce0cf5 Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Sat, 9 Sep 2023 16:28:18 +0200 Subject: [PATCH 05/57] . --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 018e05f3..0e5613db 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,7 +21,7 @@ jobs: - run: | set -o pipefail pixi info - tree .pixi + ls -lah .pixi test -f .pixi/env/bin/python ./.pixi/env/bin/python${{ matrix.os == 'windows-latest' && '.exe' || '' }} --version | grep -q 3.11 shell: bash From 611308a13548d32f125d6411ccdcae8912347acf Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Sat, 9 Sep 2023 16:29:28 +0200 Subject: [PATCH 06/57] . --- .github/workflows/test.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0e5613db..c675c599 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,7 +21,8 @@ jobs: - run: | set -o pipefail pixi info - ls -lah .pixi + ls -lah .pixi/env + ls -lah .pixi/env/bin test -f .pixi/env/bin/python ./.pixi/env/bin/python${{ matrix.os == 'windows-latest' && '.exe' || '' }} --version | grep -q 3.11 shell: bash From 7fc82e82665810aae53e99bf37c67d0cb8183cb7 Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Sat, 9 Sep 2023 16:33:12 +0200 Subject: [PATCH 07/57] . --- .github/workflows/test.yml | 12 +++++++++++- test/default/pixi.toml | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c675c599..e007679f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,10 +22,20 @@ jobs: set -o pipefail pixi info ls -lah .pixi/env - ls -lah .pixi/env/bin + ls -lah .pixi/env/ test -f .pixi/env/bin/python ./.pixi/env/bin/python${{ matrix.os == 'windows-latest' && '.exe' || '' }} --version | grep -q 3.11 shell: bash + if: matrix.os != 'windows-latest' + - run: | + set -o pipefail + pixi info + ls -lah .pixi/env + ls -lah .pixi/env/Scripts + test -f .pixi/env/python.exe + ./.pixi/env/python.exe --version | grep -q 3.11 + shell: bash + - run: pixi run test | grep -q "Hello world" no-run-install: strategy: diff --git a/test/default/pixi.toml b/test/default/pixi.toml index da6ec72e..a7cda49b 100644 --- a/test/default/pixi.toml +++ b/test/default/pixi.toml @@ -7,6 +7,7 @@ channels = ["conda-forge"] platforms = ["linux-64", "osx-64", "win-64"] [tasks] +test = "python -c 'print(\"Hello world!\")'" [dependencies] python = "3.11.*" From db557b2734abf0ce4f92126f592062a3a9ff1d65 Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Sat, 9 Sep 2023 16:33:48 +0200 Subject: [PATCH 08/57] . --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e007679f..863c43ea 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -35,6 +35,7 @@ jobs: test -f .pixi/env/python.exe ./.pixi/env/python.exe --version | grep -q 3.11 shell: bash + if: matrix.os == 'windows-latest' - run: pixi run test | grep -q "Hello world" no-run-install: From b09006da4a2d5459e463e75ae010fdcc6fea113c Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Sat, 9 Sep 2023 16:36:01 +0200 Subject: [PATCH 09/57] . --- .github/workflows/test.yml | 17 ++++++++++++++--- test/no-lockfile/pixi.toml | 1 + 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 863c43ea..6ce57e82 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -30,8 +30,6 @@ jobs: - run: | set -o pipefail pixi info - ls -lah .pixi/env - ls -lah .pixi/env/Scripts test -f .pixi/env/python.exe ./.pixi/env/python.exe --version | grep -q 3.11 shell: bash @@ -227,6 +225,19 @@ jobs: run: mv test/no-lockfile/* . - uses: ./ - run: | + set -o pipefail pixi info + ls -lah .pixi/env + ls -lah .pixi/env/ test -f .pixi/env/bin/python - ./.pixi/env/bin/python${{ matrix.os == 'windows-latest' && '.exe' || '' }} --version | grep -q 3.11 + ./.pixi/env/bin/python${{ matrix.os == 'windows-latest' && '.exe' || '' }} --version | grep -q 3.11 + shell: bash + if: matrix.os != 'windows-latest' + - run: | + set -o pipefail + pixi info + test -f .pixi/env/python.exe + ./.pixi/env/python.exe --version | grep -q 3.11 + shell: bash + if: matrix.os == 'windows-latest' + - run: pixi run test | grep -q "Hello world" diff --git a/test/no-lockfile/pixi.toml b/test/no-lockfile/pixi.toml index d25cb627..82e35d5a 100644 --- a/test/no-lockfile/pixi.toml +++ b/test/no-lockfile/pixi.toml @@ -7,6 +7,7 @@ channels = ["conda-forge"] platforms = ["linux-64", "osx-64", "win-64"] [tasks] +test = "python -c 'print(\"Hello world!\")'" [dependencies] python = "3.11.*" From 180c6cc8b4e5419091c6e511c8721de1c90574f1 Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Sat, 9 Sep 2023 16:39:38 +0200 Subject: [PATCH 10/57] . --- .github/workflows/test.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6ce57e82..6b85e612 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,10 +21,8 @@ jobs: - run: | set -o pipefail pixi info - ls -lah .pixi/env - ls -lah .pixi/env/ test -f .pixi/env/bin/python - ./.pixi/env/bin/python${{ matrix.os == 'windows-latest' && '.exe' || '' }} --version | grep -q 3.11 + ./.pixi/env/bin/python --version | grep -q 3.11 shell: bash if: matrix.os != 'windows-latest' - run: | @@ -34,7 +32,9 @@ jobs: ./.pixi/env/python.exe --version | grep -q 3.11 shell: bash if: matrix.os == 'windows-latest' - - run: pixi run test | grep -q "Hello world" + - run: | + pixi run python --version | grep -q 3.11 + pixi run test | grep -q "Hello world" no-run-install: strategy: @@ -227,10 +227,8 @@ jobs: - run: | set -o pipefail pixi info - ls -lah .pixi/env - ls -lah .pixi/env/ test -f .pixi/env/bin/python - ./.pixi/env/bin/python${{ matrix.os == 'windows-latest' && '.exe' || '' }} --version | grep -q 3.11 + ./.pixi/env/bin/python --version | grep -q 3.11 shell: bash if: matrix.os != 'windows-latest' - run: | @@ -240,4 +238,6 @@ jobs: ./.pixi/env/python.exe --version | grep -q 3.11 shell: bash if: matrix.os == 'windows-latest' - - run: pixi run test | grep -q "Hello world" + - run: | + pixi run python --version | grep -q 3.11 + pixi run test | grep -q "Hello world" From f7b75a1171f1f495482734876de196183ac3108b Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Sat, 9 Sep 2023 16:43:51 +0200 Subject: [PATCH 11/57] test auth --- .github/workflows/test.yml | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6b85e612..3e041945 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -144,10 +144,11 @@ jobs: run: mv test/default/* . - uses: ./ with: - auth-host: TODO - auth-token: TODO - # TODO - # - run: + auth-host: https://custom-conda-registry.com + auth-token: custom-token + - run: | + grep -q "custom-conda-registry.com" ~/.rattler/auth.json + grep -q "custom-token" ~/.rattler/auth.json auth-username-password: strategy: @@ -160,9 +161,13 @@ jobs: run: mv test/default/* . - uses: ./ with: - auth-host: TODO - auth-username: TODO - auth-password: TODO + auth-host: https://custom-conda-registry.com + auth-username: custom-username + auth-password: custom-password + - run: | + grep -q "custom-conda-registry.com" ~/.rattler/auth.json + grep -q "custom-username" ~/.rattler/auth.json + grep -q "custom-password" ~/.rattler/auth.json auth-conda-token: strategy: @@ -175,8 +180,11 @@ jobs: run: mv test/default/* . - uses: ./ with: - auth-host: TODO - auth-conda-token: TODO + auth-host: https://custom-conda-registry.com + auth-conda-token: custom-conda-token + - run: | + grep -q "custom-conda-registry.com" ~/.rattler/auth.json + grep -q "custom-conda-token" ~/.rattler/auth.json post-cleanup: # not implemented yet From 045615e343b947f31d7ed34b6c1bcdd3adc191db Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Sat, 9 Sep 2023 16:45:06 +0200 Subject: [PATCH 12/57] . --- .github/workflows/test.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3e041945..d610d3a0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -147,8 +147,8 @@ jobs: auth-host: https://custom-conda-registry.com auth-token: custom-token - run: | - grep -q "custom-conda-registry.com" ~/.rattler/auth.json - grep -q "custom-token" ~/.rattler/auth.json + grep -q "custom-conda-registry.com" ~/.rattler/rattler_auth_store.json + grep -q "custom-token" ~/.rattler/rattler_auth_store.json auth-username-password: strategy: @@ -165,9 +165,9 @@ jobs: auth-username: custom-username auth-password: custom-password - run: | - grep -q "custom-conda-registry.com" ~/.rattler/auth.json - grep -q "custom-username" ~/.rattler/auth.json - grep -q "custom-password" ~/.rattler/auth.json + grep -q "custom-conda-registry.com" ~/.rattler/rattler_auth_store.json + grep -q "custom-username" ~/.rattler/rattler_auth_store.json + grep -q "custom-password" ~/.rattler/rattler_auth_store.json auth-conda-token: strategy: @@ -183,8 +183,8 @@ jobs: auth-host: https://custom-conda-registry.com auth-conda-token: custom-conda-token - run: | - grep -q "custom-conda-registry.com" ~/.rattler/auth.json - grep -q "custom-conda-token" ~/.rattler/auth.json + grep -q "custom-conda-registry.com" ~/.rattler/rattler_auth_store.json + grep -q "custom-conda-token" ~/.rattler/rattler_auth_store.json post-cleanup: # not implemented yet From 18d10b44b4e66286ae7313904d6af906f20dc95c Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Sat, 9 Sep 2023 16:46:04 +0200 Subject: [PATCH 13/57] . --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d610d3a0..c276d4c6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -165,6 +165,7 @@ jobs: auth-username: custom-username auth-password: custom-password - run: | + cat ~/.rattler/rattler_auth_store.json grep -q "custom-conda-registry.com" ~/.rattler/rattler_auth_store.json grep -q "custom-username" ~/.rattler/rattler_auth_store.json grep -q "custom-password" ~/.rattler/rattler_auth_store.json From 204ce01034e5314cd3de2cdea800f8130004f81d Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Sat, 9 Sep 2023 16:50:31 +0200 Subject: [PATCH 14/57] . --- .github/workflows/test.yml | 3 +++ dist/index.js | 1 + src/main.ts | 1 + 3 files changed, 5 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c276d4c6..e4603cbc 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -147,6 +147,8 @@ jobs: auth-host: https://custom-conda-registry.com auth-token: custom-token - run: | + cat ~/.rattler/rattler_auth_store.json + grep -q "BearerToken" ~/.rattler/rattler_auth_store.json grep -q "custom-conda-registry.com" ~/.rattler/rattler_auth_store.json grep -q "custom-token" ~/.rattler/rattler_auth_store.json @@ -184,6 +186,7 @@ jobs: auth-host: https://custom-conda-registry.com auth-conda-token: custom-conda-token - run: | + cat ~/.rattler/rattler_auth_store.json grep -q "custom-conda-registry.com" ~/.rattler/rattler_auth_store.json grep -q "custom-conda-token" ~/.rattler/rattler_auth_store.json diff --git a/dist/index.js b/dist/index.js index 6df5b63c..b41bf679 100644 --- a/dist/index.js +++ b/dist/index.js @@ -61210,6 +61210,7 @@ var pixiLogin = () => { core4.debug("Skipping pixi login."); return Promise.resolve(0); } + core4.debug(`auth keys: ${Object.keys(auth)}`); return core4.group("Logging in to private channel", () => { if ("token" in auth) { core4.debug(`Logging in to ${auth.host} with token`); diff --git a/src/main.ts b/src/main.ts index 7e5c1d15..a4acf319 100644 --- a/src/main.ts +++ b/src/main.ts @@ -27,6 +27,7 @@ const pixiLogin = () => { core.debug('Skipping pixi login.') return Promise.resolve(0) } + core.debug(`auth keys: ${Object.keys(auth)}`) return core.group('Logging in to private channel', () => { // tokens get censored in the logs as long as they are a github secret if ('token' in auth) { From be21ec69b5072011d68215d6a72c7432547906cb Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Sat, 9 Sep 2023 16:58:17 +0200 Subject: [PATCH 15/57] test --- dist/index.js | 14 +++++++++----- src/options.ts | 26 +++++++++++++++++--------- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/dist/index.js b/dist/index.js index b41bf679..a774456c 100644 --- a/dist/index.js +++ b/dist/index.js @@ -61096,13 +61096,17 @@ var inferOptions = (inputs) => { const generateRunShell = inputs.generateRunShell ?? runInstall; const cacheKey = inputs.cacheKey ?? (inputs.cache ? `pixi-${getCondaArch()}` : void 0); const pixiBinPath = inputs.pixiBinPath ?? PATHS.pixiBin; - const auth = inputs.authHost ? { + const auth = !inputs.authHost ? void 0 : inputs.authToken ? { + host: inputs.authHost, + token: inputs.authToken + } : inputs.authCondaToken ? { host: inputs.authHost, - token: inputs.authToken, - username: inputs.authUsername, - password: inputs.authPassword, condaToken: inputs.authCondaToken - } : void 0; + } : { + host: inputs.authHost, + username: inputs.authUsername, + password: inputs.authPassword + }; const postCleanup = inputs.postCleanup ?? "all"; return { pixiSource, diff --git a/src/options.ts b/src/options.ts index 42a2feb3..f59eb8d6 100644 --- a/src/options.ts +++ b/src/options.ts @@ -134,15 +134,23 @@ const inferOptions = (inputs: Inputs): Options => { const generateRunShell = inputs.generateRunShell ?? runInstall const cacheKey = inputs.cacheKey ?? (inputs.cache ? `pixi-${getCondaArch()}` : undefined) const pixiBinPath = inputs.pixiBinPath ?? PATHS.pixiBin - const auth = inputs.authHost - ? ({ - host: inputs.authHost, - token: inputs.authToken, - username: inputs.authUsername, - password: inputs.authPassword, - condaToken: inputs.authCondaToken - } as Auth) - : undefined + const auth = !inputs.authHost + ? undefined + : ((inputs.authToken + ? { + host: inputs.authHost, + token: inputs.authToken + } + : inputs.authCondaToken + ? { + host: inputs.authHost, + condaToken: inputs.authCondaToken + } + : { + host: inputs.authHost, + username: inputs.authUsername!, + password: inputs.authPassword! + }) as Auth) const postCleanup = inputs.postCleanup ?? 'all' return { pixiSource, From a20b458602d16c0674df790fe709ba42fe3f652a Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Sat, 9 Sep 2023 17:04:31 +0200 Subject: [PATCH 16/57] . --- .github/workflows/test.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e4603cbc..1301dccf 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -131,7 +131,8 @@ jobs: with: pixi-bin-path: bin/pixi - run: | - which pixi | grep -q "..." + which pixi + which pixi | grep -q "adwdwdw" auth-token: strategy: @@ -147,10 +148,10 @@ jobs: auth-host: https://custom-conda-registry.com auth-token: custom-token - run: | - cat ~/.rattler/rattler_auth_store.json grep -q "BearerToken" ~/.rattler/rattler_auth_store.json grep -q "custom-conda-registry.com" ~/.rattler/rattler_auth_store.json grep -q "custom-token" ~/.rattler/rattler_auth_store.json + if: matrix.os == 'ubuntu-latest' auth-username-password: strategy: @@ -167,10 +168,11 @@ jobs: auth-username: custom-username auth-password: custom-password - run: | - cat ~/.rattler/rattler_auth_store.json + grep -q "BasicHTTP" ~/.rattler/rattler_auth_store.json grep -q "custom-conda-registry.com" ~/.rattler/rattler_auth_store.json grep -q "custom-username" ~/.rattler/rattler_auth_store.json grep -q "custom-password" ~/.rattler/rattler_auth_store.json + if: matrix.os == 'ubuntu-latest' auth-conda-token: strategy: @@ -186,9 +188,11 @@ jobs: auth-host: https://custom-conda-registry.com auth-conda-token: custom-conda-token - run: | + grep "CondaToken" ~/.rattler/rattler_auth_store.json cat ~/.rattler/rattler_auth_store.json grep -q "custom-conda-registry.com" ~/.rattler/rattler_auth_store.json grep -q "custom-conda-token" ~/.rattler/rattler_auth_store.json + if: matrix.os == 'ubuntu-latest' post-cleanup: # not implemented yet From 661014c63db2b86efc361b7925686946f271543d Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Sat, 9 Sep 2023 17:07:48 +0200 Subject: [PATCH 17/57] . --- dist/index.js | 2 +- src/options.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/index.js b/dist/index.js index a774456c..c5f4e44b 100644 --- a/dist/index.js +++ b/dist/index.js @@ -61133,7 +61133,7 @@ var getOptions = () => { generateRunShell: parseOrUndefinedJSON("generate-run-shell", booleanType()), cache: parseOrUndefinedJSON("cache", booleanType()), cacheKey: parseOrUndefined("cache-key", stringType()), - pixiBinPath: parseOrUndefined("micromamba-binary-path", stringType()), + pixiBinPath: parseOrUndefined("pixi-bin-path", stringType()), authHost: parseOrUndefined("auth-host", stringType()), authToken: parseOrUndefined("auth-token", stringType()), authUsername: parseOrUndefined("auth-username", stringType()), diff --git a/src/options.ts b/src/options.ts index f59eb8d6..80e027fc 100644 --- a/src/options.ts +++ b/src/options.ts @@ -185,7 +185,7 @@ const getOptions = () => { generateRunShell: parseOrUndefinedJSON('generate-run-shell', z.boolean()), cache: parseOrUndefinedJSON('cache', z.boolean()), cacheKey: parseOrUndefined('cache-key', z.string()), - pixiBinPath: parseOrUndefined('micromamba-binary-path', z.string()), + pixiBinPath: parseOrUndefined('pixi-bin-path', z.string()), authHost: parseOrUndefined('auth-host', z.string()), authToken: parseOrUndefined('auth-token', z.string()), authUsername: parseOrUndefined('auth-username', z.string()), From cc598eee127758b0db5680b71859863918c86f31 Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Sat, 9 Sep 2023 17:14:21 +0200 Subject: [PATCH 18/57] . --- dist/index.js | 12 +++++------- src/main.ts | 7 +++---- src/options.ts | 8 ++++---- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/dist/index.js b/dist/index.js index c5f4e44b..640ceb27 100644 --- a/dist/index.js +++ b/dist/index.js @@ -61041,10 +61041,7 @@ var pixiCmd = (command, withManifestPath = true) => { var logLevelSchema = enumType(["quiet", "warn", "info", "debug", "trace"]); var postCleanupSchema = enumType(["none", "environment", "all"]); var PATHS = { - pixiBin: import_path.default.join(import_os.default.homedir(), ".pixi", "bin", `pixi${import_os.default.platform() === "win32" ? ".exe" : ""}`), - pixiRunShellScript: import_path.default.join(import_os.default.homedir(), ".pixi", "bin", "pixi-shell"), - bashProfile: import_path.default.join(import_os.default.homedir(), ".bash_profile"), - bashrc: import_path.default.join(import_os.default.homedir(), ".bashrc") + pixiBin: import_path.default.join(import_os.default.homedir(), ".pixi", "bin", `pixi${import_os.default.platform() === "win32" ? ".exe" : ""}`) }; var parseOrUndefined = (key, schema) => { const input = core2.getInput(key); @@ -61096,6 +61093,7 @@ var inferOptions = (inputs) => { const generateRunShell = inputs.generateRunShell ?? runInstall; const cacheKey = inputs.cacheKey ?? (inputs.cache ? `pixi-${getCondaArch()}` : void 0); const pixiBinPath = inputs.pixiBinPath ?? PATHS.pixiBin; + const pixiRunShell = import_path.default.join(import_path.default.dirname(pixiBinPath), "pixi-shell"); const auth = !inputs.authHost ? void 0 : inputs.authToken ? { host: inputs.authHost, token: inputs.authToken @@ -61117,6 +61115,7 @@ var inferOptions = (inputs) => { generateRunShell, cacheKey, pixiBinPath, + pixiRunShell, auth, postCleanup }; @@ -61253,17 +61252,16 @@ chmod +x $1 pixi run $1 `; return core4.group("Generating pixi run shell", () => { - core4.debug(`Writing pixi run shell to ${PATHS.pixiRunShellScript}`); + core4.debug(`Writing pixi run shell to ${options.pixiRunShell}`); core4.debug(`File contents: "${pixiRunShellContents}"`); - return import_promises2.default.writeFile(PATHS.pixiRunShellScript, pixiRunShellContents, { encoding: "utf8", mode: 493 }); + return import_promises2.default.writeFile(options.pixiRunShell, pixiRunShellContents, { encoding: "utf8", mode: 493 }); }); }; var generateInfo = () => core4.group("pixi info", () => execute(pixiCmd("info"))); var run = async () => { core4.debug(`process.env.HOME: ${process.env.HOME}`); core4.debug(`os.homedir(): ${import_os3.default.homedir()}`); - core4.debug(`bashProfile ${PATHS.bashProfile}`); await downloadPixi(options.pixiSource); addPixiToPath(); await pixiLogin(); diff --git a/src/main.ts b/src/main.ts index a4acf319..af8f6f3d 100644 --- a/src/main.ts +++ b/src/main.ts @@ -4,7 +4,7 @@ import path from 'path' import * as core from '@actions/core' import { downloadTool } from '@actions/tool-cache' import type { PixiSource } from './options' -import { PATHS, options } from './options' +import { options } from './options' import { execute, getPixiUrlFromVersion, pixiCmd } from './util' import { saveCache, tryRestoreCache } from './cache' @@ -72,9 +72,9 @@ chmod +x $1 pixi run $1 ` return core.group('Generating pixi run shell', () => { - core.debug(`Writing pixi run shell to ${PATHS.pixiRunShellScript}`) + core.debug(`Writing pixi run shell to ${options.pixiRunShell}`) core.debug(`File contents:\n"${pixiRunShellContents}"`) - return fs.writeFile(PATHS.pixiRunShellScript, pixiRunShellContents, { encoding: 'utf8', mode: 0o755 }) + return fs.writeFile(options.pixiRunShell, pixiRunShellContents, { encoding: 'utf8', mode: 0o755 }) }) } @@ -83,7 +83,6 @@ const generateInfo = () => core.group('pixi info', () => execute(pixiCmd('info') const run = async () => { core.debug(`process.env.HOME: ${process.env.HOME}`) core.debug(`os.homedir(): ${os.homedir()}`) - core.debug(`bashProfile ${PATHS.bashProfile}`) await downloadPixi(options.pixiSource) addPixiToPath() await pixiLogin() diff --git a/src/options.ts b/src/options.ts index 80e027fc..bfc22710 100644 --- a/src/options.ts +++ b/src/options.ts @@ -54,6 +54,7 @@ export type Options = Readonly<{ generateRunShell: boolean cacheKey?: string // undefined if cache is false pixiBinPath: string + pixiRunShell: string auth?: Auth postCleanup: PostCleanup }> @@ -65,10 +66,7 @@ const postCleanupSchema = z.enum(['none', 'environment', 'all']) export type PostCleanup = z.infer export const PATHS = { - pixiBin: path.join(os.homedir(), '.pixi', 'bin', `pixi${os.platform() === 'win32' ? '.exe' : ''}`), - pixiRunShellScript: path.join(os.homedir(), '.pixi', 'bin', 'pixi-shell'), - bashProfile: path.join(os.homedir(), '.bash_profile'), - bashrc: path.join(os.homedir(), '.bashrc') + pixiBin: path.join(os.homedir(), '.pixi', 'bin', `pixi${os.platform() === 'win32' ? '.exe' : ''}`) } const parseOrUndefined = (key: string, schema: z.ZodSchema): T | undefined => { @@ -134,6 +132,7 @@ const inferOptions = (inputs: Inputs): Options => { const generateRunShell = inputs.generateRunShell ?? runInstall const cacheKey = inputs.cacheKey ?? (inputs.cache ? `pixi-${getCondaArch()}` : undefined) const pixiBinPath = inputs.pixiBinPath ?? PATHS.pixiBin + const pixiRunShell = path.join(path.dirname(pixiBinPath), 'pixi-shell') const auth = !inputs.authHost ? undefined : ((inputs.authToken @@ -161,6 +160,7 @@ const inferOptions = (inputs: Inputs): Options => { generateRunShell, cacheKey, pixiBinPath, + pixiRunShell, auth, postCleanup } From 3eb48824f8ae1d8b1fc9b778f5b55e541c9bbe96 Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Sat, 9 Sep 2023 17:16:17 +0200 Subject: [PATCH 19/57] . --- .github/workflows/test.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1301dccf..f4cdf15b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -131,8 +131,10 @@ jobs: with: pixi-bin-path: bin/pixi - run: | + pixi --help + echo $PATH which pixi - which pixi | grep -q "adwdwdw" + which pixi | grep -q "awdwd" auth-token: strategy: @@ -151,6 +153,8 @@ jobs: grep -q "BearerToken" ~/.rattler/rattler_auth_store.json grep -q "custom-conda-registry.com" ~/.rattler/rattler_auth_store.json grep -q "custom-token" ~/.rattler/rattler_auth_store.json + # all other platforms have the credentials stored in the keychain + # https://github.com/prefix-dev/pixi/issues/330 if: matrix.os == 'ubuntu-latest' auth-username-password: @@ -172,6 +176,8 @@ jobs: grep -q "custom-conda-registry.com" ~/.rattler/rattler_auth_store.json grep -q "custom-username" ~/.rattler/rattler_auth_store.json grep -q "custom-password" ~/.rattler/rattler_auth_store.json + # all other platforms have the credentials stored in the keychain + # https://github.com/prefix-dev/pixi/issues/330 if: matrix.os == 'ubuntu-latest' auth-conda-token: @@ -192,6 +198,8 @@ jobs: cat ~/.rattler/rattler_auth_store.json grep -q "custom-conda-registry.com" ~/.rattler/rattler_auth_store.json grep -q "custom-conda-token" ~/.rattler/rattler_auth_store.json + # all other platforms have the credentials stored in the keychain + # https://github.com/prefix-dev/pixi/issues/330 if: matrix.os == 'ubuntu-latest' post-cleanup: From 91518f0b867b5775e008fb6b080de8eb60deade5 Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Sat, 9 Sep 2023 17:18:50 +0200 Subject: [PATCH 20/57] resolve --- dist/index.js | 74 ++++++++++++++++++++++++++++---------------------- src/options.ts | 3 +- 2 files changed, 44 insertions(+), 33 deletions(-) diff --git a/dist/index.js b/dist/index.js index 640ceb27..1d312a7f 100644 --- a/dist/index.js +++ b/dist/index.js @@ -99,11 +99,11 @@ var require_command = __commonJS({ }; Object.defineProperty(exports, "__esModule", { value: true }); exports.issue = exports.issueCommand = void 0; - var os6 = __importStar(require("os")); + var os7 = __importStar(require("os")); var utils_1 = require_utils(); function issueCommand(command, properties, message) { const cmd = new Command(command, properties, message); - process.stdout.write(cmd.toString() + os6.EOL); + process.stdout.write(cmd.toString() + os7.EOL); } exports.issueCommand = issueCommand; function issue(name, message = "") { @@ -535,7 +535,7 @@ var require_file_command = __commonJS({ Object.defineProperty(exports, "__esModule", { value: true }); exports.prepareKeyValueMessage = exports.issueFileCommand = void 0; var fs4 = __importStar(require("fs")); - var os6 = __importStar(require("os")); + var os7 = __importStar(require("os")); var uuid_1 = (init_esm_node(), __toCommonJS(esm_node_exports)); var utils_1 = require_utils(); function issueFileCommand(command, message) { @@ -546,7 +546,7 @@ var require_file_command = __commonJS({ if (!fs4.existsSync(filePath)) { throw new Error(`Missing file at path: ${filePath}`); } - fs4.appendFileSync(filePath, `${utils_1.toCommandValue(message)}${os6.EOL}`, { + fs4.appendFileSync(filePath, `${utils_1.toCommandValue(message)}${os7.EOL}`, { encoding: "utf8" }); } @@ -560,7 +560,7 @@ var require_file_command = __commonJS({ if (convertedValue.includes(delimiter2)) { throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter2}"`); } - return `${key}<<${delimiter2}${os6.EOL}${convertedValue}${os6.EOL}${delimiter2}`; + return `${key}<<${delimiter2}${os7.EOL}${convertedValue}${os7.EOL}${delimiter2}`; } exports.prepareKeyValueMessage = prepareKeyValueMessage; } @@ -2076,7 +2076,7 @@ var require_core = __commonJS({ var command_1 = require_command(); var file_command_1 = require_file_command(); var utils_1 = require_utils(); - var os6 = __importStar(require("os")); + var os7 = __importStar(require("os")); var path4 = __importStar(require("path")); var oidc_utils_1 = require_oidc_utils(); var ExitCode; @@ -2144,7 +2144,7 @@ Support boolean input list: \`true | True | TRUE | false | False | FALSE\``); if (filePath) { return file_command_1.issueFileCommand("OUTPUT", file_command_1.prepareKeyValueMessage(name, value)); } - process.stdout.write(os6.EOL); + process.stdout.write(os7.EOL); command_1.issueCommand("set-output", { name }, utils_1.toCommandValue(value)); } exports.setOutput = setOutput; @@ -2178,7 +2178,7 @@ Support boolean input list: \`true | True | TRUE | false | False | FALSE\``); } exports.notice = notice; function info3(message) { - process.stdout.write(message + os6.EOL); + process.stdout.write(message + os7.EOL); } exports.info = info3; function startGroup(name) { @@ -3886,12 +3886,12 @@ var require_manifest = __commonJS({ exports._readLinuxVersionFile = exports._getOsVersion = exports._findMatch = void 0; var semver = __importStar(require_semver()); var core_1 = require_core(); - var os6 = require("os"); + var os7 = require("os"); var cp = require("child_process"); var fs4 = require("fs"); function _findMatch(versionSpec, stable, candidates, archFilter) { return __awaiter(this, void 0, void 0, function* () { - const platFilter = os6.platform(); + const platFilter = os7.platform(); let result; let match; let file; @@ -3928,7 +3928,7 @@ var require_manifest = __commonJS({ } exports._findMatch = _findMatch; function _getOsVersion() { - const plat = os6.platform(); + const plat = os7.platform(); let version3 = ""; if (plat === "darwin") { version3 = cp.execSync("sw_vers -productVersion").toString(); @@ -4101,7 +4101,7 @@ var require_toolrunner = __commonJS({ }; Object.defineProperty(exports, "__esModule", { value: true }); exports.argStringToArray = exports.ToolRunner = void 0; - var os6 = __importStar(require("os")); + var os7 = __importStar(require("os")); var events = __importStar(require("events")); var child = __importStar(require("child_process")); var path4 = __importStar(require("path")); @@ -4156,12 +4156,12 @@ var require_toolrunner = __commonJS({ _processLineBuffer(data, strBuffer, onLine) { try { let s = strBuffer + data.toString(); - let n = s.indexOf(os6.EOL); + let n = s.indexOf(os7.EOL); while (n > -1) { const line = s.substring(0, n); onLine(line); - s = s.substring(n + os6.EOL.length); - n = s.indexOf(os6.EOL); + s = s.substring(n + os7.EOL.length); + n = s.indexOf(os7.EOL); } return s; } catch (err) { @@ -4330,7 +4330,7 @@ var require_toolrunner = __commonJS({ } const optionsNonNull = this._cloneExecOptions(this.options); if (!optionsNonNull.silent && optionsNonNull.outStream) { - optionsNonNull.outStream.write(this._getCommandString(optionsNonNull) + os6.EOL); + optionsNonNull.outStream.write(this._getCommandString(optionsNonNull) + os7.EOL); } const state = new ExecState(optionsNonNull, this.toolPath); state.on("debug", (message) => { @@ -4816,7 +4816,7 @@ var require_tool_cache = __commonJS({ var io = __importStar(require_io()); var fs4 = __importStar(require("fs")); var mm = __importStar(require_manifest()); - var os6 = __importStar(require("os")); + var os7 = __importStar(require("os")); var path4 = __importStar(require("path")); var httpm = __importStar(require_lib()); var semver = __importStar(require_semver()); @@ -5095,7 +5095,7 @@ var require_tool_cache = __commonJS({ function cacheDir(sourceDir, tool, version3, arch3) { return __awaiter(this, void 0, void 0, function* () { version3 = semver.clean(version3) || version3; - arch3 = arch3 || os6.arch(); + arch3 = arch3 || os7.arch(); core5.debug(`Caching tool ${tool} ${version3} ${arch3}`); core5.debug(`source dir: ${sourceDir}`); if (!fs4.statSync(sourceDir).isDirectory()) { @@ -5114,7 +5114,7 @@ var require_tool_cache = __commonJS({ function cacheFile(sourceFile, targetFile, tool, version3, arch3) { return __awaiter(this, void 0, void 0, function* () { version3 = semver.clean(version3) || version3; - arch3 = arch3 || os6.arch(); + arch3 = arch3 || os7.arch(); core5.debug(`Caching tool ${tool} ${version3} ${arch3}`); core5.debug(`source file: ${sourceFile}`); if (!fs4.statSync(sourceFile).isFile()) { @@ -5136,7 +5136,7 @@ var require_tool_cache = __commonJS({ if (!versionSpec) { throw new Error("versionSpec parameter is required"); } - arch3 = arch3 || os6.arch(); + arch3 = arch3 || os7.arch(); if (!isExplicitVersion(versionSpec)) { const localVersions = findAllVersions(toolName, arch3); const match = evaluateVersions(localVersions, versionSpec); @@ -5159,7 +5159,7 @@ var require_tool_cache = __commonJS({ exports.find = find2; function findAllVersions(toolName, arch3) { const versions = []; - arch3 = arch3 || os6.arch(); + arch3 = arch3 || os7.arch(); const toolPath = path4.join(_getCacheDirectory(), toolName); if (fs4.existsSync(toolPath)) { const children2 = fs4.readdirSync(toolPath); @@ -5210,7 +5210,7 @@ var require_tool_cache = __commonJS({ }); } exports.getManifestFromRepo = getManifestFromRepo; - function findFromManifest(versionSpec, stable, manifest, archFilter = os6.arch()) { + function findFromManifest(versionSpec, stable, manifest, archFilter = os7.arch()) { return __awaiter(this, void 0, void 0, function* () { const match = yield mm._findMatch(versionSpec, stable, manifest, archFilter); return match; @@ -6554,7 +6554,7 @@ var require_internal_pattern = __commonJS({ }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Pattern = void 0; - var os6 = __importStar(require("os")); + var os7 = __importStar(require("os")); var path4 = __importStar(require("path")); var pathHelper = __importStar(require_internal_path_helper()); var assert_1 = __importDefault(require("assert")); @@ -6647,7 +6647,7 @@ var require_internal_pattern = __commonJS({ if (pattern === "." || pattern.startsWith(`.${path4.sep}`)) { pattern = _Pattern.globEscape(process.cwd()) + pattern.substr(1); } else if (pattern === "~" || pattern.startsWith(`~${path4.sep}`)) { - homedir = homedir || os6.homedir(); + homedir = homedir || os7.homedir(); assert_1.default(homedir, "Unable to determine HOME directory"); assert_1.default(pathHelper.hasAbsoluteRoot(homedir), `Expected HOME directory to be a rooted path. Actual '${homedir}'`); pattern = _Pattern.globEscape(homedir) + pattern.substr(1); @@ -29300,15 +29300,15 @@ function getPlatformSpecificData() { }; const osInfo = { key: "OS", - value: `(${os3.arch()}-${os3.type()}-${os3.release()})` + value: `(${os4.arch()}-${os4.type()}-${os4.release()})` }; return [runtimeInfo, osInfo]; } -var os3; +var os4; var init_msRestUserAgentPolicy = __esm({ "node_modules/.pnpm/@azure+core-http@3.0.3/node_modules/@azure/core-http/dist-esm/src/policies/msRestUserAgentPolicy.js"() { "use strict"; - os3 = __toESM(require("os")); + os4 = __toESM(require("os")); init_constants(); } }); @@ -46078,12 +46078,12 @@ var init_TelemetryPolicy = __esm({ }); // node_modules/.pnpm/@azure+storage-blob@12.15.0/node_modules/@azure/storage-blob/dist-esm/storage-blob/src/TelemetryPolicyFactory.js -var os4, TelemetryPolicyFactory; +var os5, TelemetryPolicyFactory; var init_TelemetryPolicyFactory = __esm({ "node_modules/.pnpm/@azure+storage-blob@12.15.0/node_modules/@azure/storage-blob/dist-esm/storage-blob/src/TelemetryPolicyFactory.js"() { "use strict"; init_src6(); - os4 = __toESM(require("os")); + os5 = __toESM(require("os")); init_TelemetryPolicy(); init_constants2(); TelemetryPolicyFactory = class { @@ -46105,8 +46105,8 @@ var init_TelemetryPolicyFactory = __esm({ userAgentInfo.push(libInfo); } let runtimeInfo = `(NODE-VERSION ${process.version})`; - if (os4) { - runtimeInfo = `(NODE-VERSION ${process.version}; ${os4.type()} ${os4.release()})`; + if (os5) { + runtimeInfo = `(NODE-VERSION ${process.version}; ${os5.type()} ${os5.release()})`; } if (userAgentInfo.indexOf(runtimeInfo) === -1) { userAgentInfo.push(runtimeInfo); @@ -61037,6 +61037,16 @@ var pixiCmd = (command, withManifestPath = true) => { return commandArray; }; +// node_modules/.pnpm/untildify@5.0.0/node_modules/untildify/index.js +var import_node_os = __toESM(require("os"), 1); +var homeDirectory = import_node_os.default.homedir(); +function untildify(pathWithTilde) { + if (typeof pathWithTilde !== "string") { + throw new TypeError(`Expected a string, got ${typeof pathWithTilde}`); + } + return homeDirectory ? pathWithTilde.replace(/^~(?=$|\/|\\)/, homeDirectory) : pathWithTilde; +} + // src/options.ts var logLevelSchema = enumType(["quiet", "warn", "info", "debug", "trace"]); var postCleanupSchema = enumType(["none", "environment", "all"]); @@ -61092,7 +61102,7 @@ var inferOptions = (inputs) => { const pixiLockFile = import_path.default.basename(manifestPath).replace(/\.toml$/, ".lock"); const generateRunShell = inputs.generateRunShell ?? runInstall; const cacheKey = inputs.cacheKey ?? (inputs.cache ? `pixi-${getCondaArch()}` : void 0); - const pixiBinPath = inputs.pixiBinPath ?? PATHS.pixiBin; + const pixiBinPath = inputs.pixiBinPath ? import_path.default.resolve(untildify(inputs.pixiBinPath)) : PATHS.pixiBin; const pixiRunShell = import_path.default.join(import_path.default.dirname(pixiBinPath), "pixi-shell"); const auth = !inputs.authHost ? void 0 : inputs.authToken ? { host: inputs.authHost, diff --git a/src/options.ts b/src/options.ts index bfc22710..ecf7ff54 100644 --- a/src/options.ts +++ b/src/options.ts @@ -3,6 +3,7 @@ import os from 'os' import * as core from '@actions/core' import * as z from 'zod' import { getCondaArch } from './util' +import untildify from 'untildify' type Inputs = { pixiVersion?: string @@ -131,7 +132,7 @@ const inferOptions = (inputs: Inputs): Options => { const pixiLockFile = path.basename(manifestPath).replace(/\.toml$/, '.lock') const generateRunShell = inputs.generateRunShell ?? runInstall const cacheKey = inputs.cacheKey ?? (inputs.cache ? `pixi-${getCondaArch()}` : undefined) - const pixiBinPath = inputs.pixiBinPath ?? PATHS.pixiBin + const pixiBinPath = inputs.pixiBinPath ? path.resolve(untildify(inputs.pixiBinPath)) : PATHS.pixiBin const pixiRunShell = path.join(path.dirname(pixiBinPath), 'pixi-shell') const auth = !inputs.authHost ? undefined From 972589d4481faf4383a13510cc30db2024890b3d Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Sat, 9 Sep 2023 17:20:22 +0200 Subject: [PATCH 21/57] ,. --- dist/index.js | 4 ++-- src/options.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dist/index.js b/dist/index.js index 1d312a7f..79817102 100644 --- a/dist/index.js +++ b/dist/index.js @@ -61098,8 +61098,8 @@ var inferOptions = (inputs) => { const runInstall = inputs.runInstall ?? true; const pixiSource = inputs.pixiVersion ? { version: inputs.pixiVersion } : inputs.pixiUrl ? { url: inputs.pixiUrl } : { version: "latest" }; const logLevel = inputs.logLevel ?? (core2.isDebug() ? "debug" : "warn"); - const manifestPath = inputs.manifestPath ?? "pixi.toml"; - const pixiLockFile = import_path.default.basename(manifestPath).replace(/\.toml$/, ".lock"); + const manifestPath = inputs.manifestPath ? import_path.default.resolve(untildify(inputs.manifestPath)) : "pixi.toml"; + const pixiLockFile = import_path.default.join(import_path.default.dirname(manifestPath), import_path.default.basename(manifestPath).replace(/\.toml$/, ".lock")); const generateRunShell = inputs.generateRunShell ?? runInstall; const cacheKey = inputs.cacheKey ?? (inputs.cache ? `pixi-${getCondaArch()}` : void 0); const pixiBinPath = inputs.pixiBinPath ? import_path.default.resolve(untildify(inputs.pixiBinPath)) : PATHS.pixiBin; diff --git a/src/options.ts b/src/options.ts index ecf7ff54..b086b924 100644 --- a/src/options.ts +++ b/src/options.ts @@ -128,8 +128,8 @@ const inferOptions = (inputs: Inputs): Options => { ? { url: inputs.pixiUrl } : { version: 'latest' } const logLevel = inputs.logLevel ?? (core.isDebug() ? 'debug' : 'warn') - const manifestPath = inputs.manifestPath ?? 'pixi.toml' - const pixiLockFile = path.basename(manifestPath).replace(/\.toml$/, '.lock') + const manifestPath = inputs.manifestPath ? path.resolve(untildify(inputs.manifestPath)) : 'pixi.toml' + const pixiLockFile = path.join(path.dirname(manifestPath), path.basename(manifestPath).replace(/\.toml$/, '.lock')) const generateRunShell = inputs.generateRunShell ?? runInstall const cacheKey = inputs.cacheKey ?? (inputs.cache ? `pixi-${getCondaArch()}` : undefined) const pixiBinPath = inputs.pixiBinPath ? path.resolve(untildify(inputs.pixiBinPath)) : PATHS.pixiBin From 8f325abdac6cf179d0b8c966a63c50bae7da5627 Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Sat, 9 Sep 2023 17:22:25 +0200 Subject: [PATCH 22/57] . --- .github/workflows/test.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f4cdf15b..2de7cf5a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -129,12 +129,11 @@ jobs: run: mkdir bin - uses: ./ with: - pixi-bin-path: bin/pixi + pixi-bin-path: custom-bin/pixi - run: | + test -f custom-bin/pixi pixi --help - echo $PATH - which pixi - which pixi | grep -q "awdwd" + which pixi | grep -q custom-bin/pixi auth-token: strategy: From d8208f254ffb7b1e7439213a3785a652c5c67c97 Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Sat, 9 Sep 2023 17:24:14 +0200 Subject: [PATCH 23/57] . --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2de7cf5a..39078bc2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -129,9 +129,9 @@ jobs: run: mkdir bin - uses: ./ with: - pixi-bin-path: custom-bin/pixi + pixi-bin-path: custom-bin/pixi${{ matrix.os == 'windows-latest' && '.exe' || '' }} - run: | - test -f custom-bin/pixi + test -f custom-bin/pixi${{ matrix.os == 'windows-latest' && '.exe' || '' }} pixi --help which pixi | grep -q custom-bin/pixi From ac10ce433b773f98ec32047a29f4f9080e967f4d Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Sat, 9 Sep 2023 17:25:49 +0200 Subject: [PATCH 24/57] . --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 39078bc2..c4a27169 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -125,8 +125,6 @@ jobs: - uses: actions/checkout@v4 - name: Move pixi.toml run: mv test/default/* . - - name: Create bin directory - run: mkdir bin - uses: ./ with: pixi-bin-path: custom-bin/pixi${{ matrix.os == 'windows-latest' && '.exe' || '' }} @@ -134,6 +132,8 @@ jobs: test -f custom-bin/pixi${{ matrix.os == 'windows-latest' && '.exe' || '' }} pixi --help which pixi | grep -q custom-bin/pixi + # which pixi should be absolute + which pixi | grep -q "^/home" auth-token: strategy: From 4ebaa903b3df44e7741d29d923f1c55650d0a553 Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Sat, 9 Sep 2023 17:27:30 +0200 Subject: [PATCH 25/57] . --- .github/workflows/test.yml | 2 +- dist/index.js | 30 +++++++++++++++--------------- src/options.ts | 2 +- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c4a27169..a8299325 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -133,7 +133,7 @@ jobs: pixi --help which pixi | grep -q custom-bin/pixi # which pixi should be absolute - which pixi | grep -q "^/home" + which pixi | grep -q "^/" auth-token: strategy: diff --git a/dist/index.js b/dist/index.js index 79817102..314bdf42 100644 --- a/dist/index.js +++ b/dist/index.js @@ -60950,9 +60950,19 @@ var nullableType = ZodNullable.create; var preprocessType = ZodEffects.createWithPreprocess; var pipelineType = ZodPipeline.create; +// node_modules/.pnpm/untildify@5.0.0/node_modules/untildify/index.js +var import_node_os = __toESM(require("os"), 1); +var homeDirectory = import_node_os.default.homedir(); +function untildify(pathWithTilde) { + if (typeof pathWithTilde !== "string") { + throw new TypeError(`Expected a string, got ${typeof pathWithTilde}`); + } + return homeDirectory ? pathWithTilde.replace(/^~(?=$|\/|\\)/, homeDirectory) : pathWithTilde; +} + // src/util.ts var import_crypto4 = require("crypto"); -var os = __toESM(require("os")); +var os2 = __toESM(require("os")); var core = __toESM(require_core()); var import_exec = __toESM(require_exec()); var getCondaArch = () => { @@ -60964,14 +60974,14 @@ var getCondaArch = () => { "linux-ppc64": "linux-ppc64le", "win32-x64": "win-64" }; - const arch3 = archDict[`${os.platform()}-${os.arch()}`]; + const arch3 = archDict[`${os2.platform()}-${os2.arch()}`]; if (!arch3) { - throw new Error(`Unsupported platform: ${os.platform()}-${os.arch()}`); + throw new Error(`Unsupported platform: ${os2.platform()}-${os2.arch()}`); } return arch3; }; var getPlatform = () => { - const platform2 = os.platform(); + const platform2 = os2.platform(); switch (platform2) { case "darwin": return "apple-darwin"; @@ -60984,7 +60994,7 @@ var getPlatform = () => { } }; var getArch = () => { - const arch3 = os.arch(); + const arch3 = os2.arch(); switch (arch3) { case "x64": return "x86_64"; @@ -61037,16 +61047,6 @@ var pixiCmd = (command, withManifestPath = true) => { return commandArray; }; -// node_modules/.pnpm/untildify@5.0.0/node_modules/untildify/index.js -var import_node_os = __toESM(require("os"), 1); -var homeDirectory = import_node_os.default.homedir(); -function untildify(pathWithTilde) { - if (typeof pathWithTilde !== "string") { - throw new TypeError(`Expected a string, got ${typeof pathWithTilde}`); - } - return homeDirectory ? pathWithTilde.replace(/^~(?=$|\/|\\)/, homeDirectory) : pathWithTilde; -} - // src/options.ts var logLevelSchema = enumType(["quiet", "warn", "info", "debug", "trace"]); var postCleanupSchema = enumType(["none", "environment", "all"]); diff --git a/src/options.ts b/src/options.ts index b086b924..2efb89f8 100644 --- a/src/options.ts +++ b/src/options.ts @@ -2,8 +2,8 @@ import path from 'path' import os from 'os' import * as core from '@actions/core' import * as z from 'zod' -import { getCondaArch } from './util' import untildify from 'untildify' +import { getCondaArch } from './util' type Inputs = { pixiVersion?: string From 7810ca5291d332068169b67e1b68c2da0e5e3638 Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Sat, 9 Sep 2023 17:28:37 +0200 Subject: [PATCH 26/57] . --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a8299325..289cd947 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -134,6 +134,7 @@ jobs: which pixi | grep -q custom-bin/pixi # which pixi should be absolute which pixi | grep -q "^/" + which pixi auth-token: strategy: From 594a5183fbc049502a956754955fdb23fc150709 Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Sat, 9 Sep 2023 17:29:55 +0200 Subject: [PATCH 27/57] . --- .github/workflows/test.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 289cd947..a8299325 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -134,7 +134,6 @@ jobs: which pixi | grep -q custom-bin/pixi # which pixi should be absolute which pixi | grep -q "^/" - which pixi auth-token: strategy: From 070891ba7c55ea7bcc0a3f5c61edafa0517b9627 Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Sat, 9 Sep 2023 17:34:42 +0200 Subject: [PATCH 28/57] test cache --- .github/workflows/test.yml | 40 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a8299325..8b9773a9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -264,3 +264,43 @@ jobs: - run: | pixi run python --version | grep -q 3.11 pixi run test | grep -q "Hello world" + + test-cache1: + name: Test cache 1/2 + timeout-minutes: 10 + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [windows-latest, ubuntu-latest, macos-latest] + steps: + - uses: actions/checkout@v4 + - uses: ./ + with: + cache: true + cache-key: test-cache-${{ github.sha }}-${{ github.run_attempt }} + - run: | + set -o pipefail + test -f .pixi/env/bin/python + + test-cache2: + name: Test cache 2/2 + timeout-minutes: 10 + needs: test-cache1 + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [windows-latest, ubuntu-latest, macos-latest] + steps: + - uses: actions/checkout@v4 + - uses: ./ + with: + cache: true + cache-key: test-cache-${{ github.sha }}-${{ github.run_attempt }} + - name: test environment name + run: | + set -o pipefail + test -f .pixi/env/bin/python + + \ No newline at end of file From b2aa32b0a2a3ec030fcde8a3a1ab868c152454f4 Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Sat, 9 Sep 2023 17:35:46 +0200 Subject: [PATCH 29/57] . --- .github/workflows/test.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8b9773a9..53c228bd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -275,6 +275,8 @@ jobs: os: [windows-latest, ubuntu-latest, macos-latest] steps: - uses: actions/checkout@v4 + - name: Move pixi files + run: mv test/no-lockfile/* . - uses: ./ with: cache: true @@ -294,6 +296,8 @@ jobs: os: [windows-latest, ubuntu-latest, macos-latest] steps: - uses: actions/checkout@v4 + - name: Move pixi files + run: mv test/no-lockfile/* . - uses: ./ with: cache: true From e725f509d8da9b8b900eaa4856307dcad0802e75 Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Sat, 9 Sep 2023 17:36:26 +0200 Subject: [PATCH 30/57] . --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 53c228bd..123e19d8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -276,7 +276,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Move pixi files - run: mv test/no-lockfile/* . + run: mv test/default/* . - uses: ./ with: cache: true @@ -297,7 +297,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Move pixi files - run: mv test/no-lockfile/* . + run: mv test/default/* . - uses: ./ with: cache: true From 2a979e62ceaf9d33d2cc0c5c7ac2fffc5ab503dd Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Sat, 9 Sep 2023 17:39:50 +0200 Subject: [PATCH 31/57] . --- .github/workflows/test.yml | 2 -- dist/index.js | 2 +- src/cache.ts | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 123e19d8..0af78c4e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -282,7 +282,6 @@ jobs: cache: true cache-key: test-cache-${{ github.sha }}-${{ github.run_attempt }} - run: | - set -o pipefail test -f .pixi/env/bin/python test-cache2: @@ -304,7 +303,6 @@ jobs: cache-key: test-cache-${{ github.sha }}-${{ github.run_attempt }} - name: test environment name run: | - set -o pipefail test -f .pixi/env/bin/python \ No newline at end of file diff --git a/dist/index.js b/dist/index.js index 314bdf42..d57d30da 100644 --- a/dist/index.js +++ b/dist/index.js @@ -61167,7 +61167,7 @@ var cache = __toESM(require_cache()); var generateCacheKey = async (cacheKeyPrefix) => import_promises.default.readFile(options.pixiLockFile, "utf-8").then((content) => `${cacheKeyPrefix}${sha256(content)}`).catch((err) => { throw new Error(`Failed to generate cache key: ${err}`); }); -var cachePath = import_path2.default.join(import_path2.default.basename(options.manifestPath), ".pixi"); +var cachePath = import_path2.default.join(import_path2.default.dirname(options.pixiLockFile), ".pixi"); var tryRestoreCache = () => { const cacheKeyPrefix = options.cacheKey; if (!cacheKeyPrefix) { diff --git a/src/cache.ts b/src/cache.ts index 90a82d65..5f06537e 100644 --- a/src/cache.ts +++ b/src/cache.ts @@ -13,7 +13,7 @@ export const generateCacheKey = async (cacheKeyPrefix: string) => throw new Error(`Failed to generate cache key: ${err}`) }) -const cachePath = path.join(path.basename(options.manifestPath), '.pixi') +const cachePath = path.join(path.dirname(options.pixiLockFile), '.pixi') export const tryRestoreCache = (): Promise => { const cacheKeyPrefix = options.cacheKey From f0a56f099127b47491fc35185b8599e5353be3bc Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Sat, 9 Sep 2023 17:43:34 +0200 Subject: [PATCH 32/57] . --- .github/workflows/test.yml | 17 ++++++++++++++++- dist/index.js | 2 +- src/cache.ts | 4 ++-- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0af78c4e..a704495c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -305,4 +305,19 @@ jobs: run: | test -f .pixi/env/bin/python - \ No newline at end of file + test-cache-fail-no-lockfile: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [windows-latest, ubuntu-latest, macos-latest] + steps: + - uses: actions/checkout@v4 + - name: Move pixi files + run: mv test/no-lockfile/* . + - uses: ./ + with: + cache: true + cache-key: test-cache-no-lockfile-${{ github.sha }}-${{ github.run_attempt }} + - run: exit 1 + if: success() diff --git a/dist/index.js b/dist/index.js index d57d30da..66a43479 100644 --- a/dist/index.js +++ b/dist/index.js @@ -61164,7 +61164,7 @@ var import_promises = __toESM(require("fs/promises")); var import_path2 = __toESM(require("path")); var core3 = __toESM(require_core()); var cache = __toESM(require_cache()); -var generateCacheKey = async (cacheKeyPrefix) => import_promises.default.readFile(options.pixiLockFile, "utf-8").then((content) => `${cacheKeyPrefix}${sha256(content)}`).catch((err) => { +var generateCacheKey = async (cacheKeyPrefix) => import_promises.default.readFile(options.pixiLockFile, "utf-8").then((content) => `${cacheKeyPrefix}${getCondaArch()}-${sha256(content)}`).catch((err) => { throw new Error(`Failed to generate cache key: ${err}`); }); var cachePath = import_path2.default.join(import_path2.default.dirname(options.pixiLockFile), ".pixi"); diff --git a/src/cache.ts b/src/cache.ts index 5f06537e..e01c9403 100644 --- a/src/cache.ts +++ b/src/cache.ts @@ -3,12 +3,12 @@ import path from 'path' import * as core from '@actions/core' import * as cache from '@actions/cache' import { options } from './options' -import { sha256 } from './util' +import { getCondaArch, sha256 } from './util' export const generateCacheKey = async (cacheKeyPrefix: string) => fs .readFile(options.pixiLockFile, 'utf-8') - .then((content) => `${cacheKeyPrefix}${sha256(content)}`) + .then((content) => `${cacheKeyPrefix}${getCondaArch()}-${sha256(content)}`) .catch((err) => { throw new Error(`Failed to generate cache key: ${err}`) }) From 8cb18b6154f4042b33fbd190b03da523374a31b2 Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Sat, 9 Sep 2023 17:59:40 +0200 Subject: [PATCH 33/57] . --- .github/workflows/test.yml | 45 ++++++-- action.yml | 5 +- dist/index.js | 217 +++++++++++++++++++------------------ src/cache.ts | 12 +- src/options.ts | 19 +++- 5 files changed, 172 insertions(+), 126 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a704495c..f50b7a72 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -280,7 +280,8 @@ jobs: - uses: ./ with: cache: true - cache-key: test-cache-${{ github.sha }}-${{ github.run_attempt }} + cache-key: test-cache-${{ github.sha }}-${{ github.run_attempt }}- + # check the action logs to see if the cache was written - run: | test -f .pixi/env/bin/python @@ -300,12 +301,18 @@ jobs: - uses: ./ with: cache: true - cache-key: test-cache-${{ github.sha }}-${{ github.run_attempt }} - - name: test environment name - run: | + cache-key: test-cache-${{ github.sha }}-${{ github.run_attempt }}- + # check the action logs to see if the cache was restored + - run: | test -f .pixi/env/bin/python + if: matrix.os != 'windows-latest' + - run: | + test -f .pixi/env/python.exe + if: matrix.os == 'windows-latest' - test-cache-fail-no-lockfile: + test-cache-no-write: + name: Test cache no write + timeout-minutes: 10 runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -314,10 +321,30 @@ jobs: steps: - uses: actions/checkout@v4 - name: Move pixi files - run: mv test/no-lockfile/* . + run: mv test/default/* . - uses: ./ with: cache: true - cache-key: test-cache-no-lockfile-${{ github.sha }}-${{ github.run_attempt }} - - run: exit 1 - if: success() + cache-write: false + cache-key: test-cache-${{ github.sha }}-${{ github.run_attempt }}- + # check the action logs to see if the cache write was skipped + + # not properly testable + # https://github.com/actions/runner/issues/2347 + # https://github.com/orgs/community/discussions/15452 + # test-cache-fail-no-lockfile: + # runs-on: ${{ matrix.os }} + # strategy: + # fail-fast: false + # matrix: + # os: [windows-latest, ubuntu-latest, macos-latest] + # steps: + # - uses: actions/checkout@v4 + # - name: Move pixi files + # run: mv test/no-lockfile/* . + # - uses: ./ + # with: + # cache: true + # cache-key: test-cache-no-lockfile-${{ github.sha }}-${{ github.run_attempt }}- + # - run: exit 1 + # if: success() diff --git a/action.yml b/action.yml index d930fea1..24f487d8 100644 --- a/action.yml +++ b/action.yml @@ -26,7 +26,10 @@ inputs: cache-key: description: | Cache key prefix to use for caching the pixi environment. - Defaults to `pixi-{conda-arch}`. + Defaults to `pixi-`. The full cache key is `-`. + cache-write: + description: | + Whether to write to the cache or only read from it. Defaults to `true`. pixi-bin-path: description: | Path to the pixi binary to use. Defaults to `~/.pixi/bin/pixi`. diff --git a/dist/index.js b/dist/index.js index 66a43479..67c851c8 100644 --- a/dist/index.js +++ b/dist/index.js @@ -18941,12 +18941,12 @@ var init_sanitizer = __esm({ }); // node_modules/.pnpm/@azure+core-http@3.0.3/node_modules/@azure/core-http/dist-esm/src/util/inspect.js -var import_util2, custom; +var import_util, custom; var init_inspect = __esm({ "node_modules/.pnpm/@azure+core-http@3.0.3/node_modules/@azure/core-http/dist-esm/src/util/inspect.js"() { "use strict"; - import_util2 = require("util"); - custom = import_util2.inspect.custom; + import_util = require("util"); + custom = import_util.inspect.custom; } }); @@ -18983,14 +18983,14 @@ var init_restError = __esm({ // node_modules/.pnpm/@azure+logger@1.0.4/node_modules/@azure/logger/dist-esm/src/log.js function log(message, ...args) { - process.stderr.write(`${import_util3.default.format(message, ...args)}${import_os2.EOL}`); + process.stderr.write(`${import_util2.default.format(message, ...args)}${import_os2.EOL}`); } -var import_os2, import_util3; +var import_os2, import_util2; var init_log = __esm({ "node_modules/.pnpm/@azure+logger@1.0.4/node_modules/@azure/logger/dist-esm/src/log.js"() { "use strict"; import_os2 = require("os"); - import_util3 = __toESM(require("util")); + import_util2 = __toESM(require("util")); } }); @@ -57383,7 +57383,7 @@ var import_tool_cache = __toESM(require_tool_cache()); // src/options.ts var import_path = __toESM(require("path")); var import_os = __toESM(require("os")); -var core2 = __toESM(require_core()); +var core = __toESM(require_core()); // node_modules/.pnpm/zod@3.22.2/node_modules/zod/lib/index.mjs var util; @@ -60960,93 +60960,6 @@ function untildify(pathWithTilde) { return homeDirectory ? pathWithTilde.replace(/^~(?=$|\/|\\)/, homeDirectory) : pathWithTilde; } -// src/util.ts -var import_crypto4 = require("crypto"); -var os2 = __toESM(require("os")); -var core = __toESM(require_core()); -var import_exec = __toESM(require_exec()); -var getCondaArch = () => { - const archDict = { - "darwin-x64": "osx-64", - "darwin-arm64": "osx-arm64", - "linux-x64": "linux-64", - "linux-arm64": "linux-aarch64", - "linux-ppc64": "linux-ppc64le", - "win32-x64": "win-64" - }; - const arch3 = archDict[`${os2.platform()}-${os2.arch()}`]; - if (!arch3) { - throw new Error(`Unsupported platform: ${os2.platform()}-${os2.arch()}`); - } - return arch3; -}; -var getPlatform = () => { - const platform2 = os2.platform(); - switch (platform2) { - case "darwin": - return "apple-darwin"; - case "linux": - return "unknown-linux-musl"; - case "win32": - return "pc-windows-msvc"; - default: - throw new Error(`Unsupported architecture: ${platform2}`); - } -}; -var getArch = () => { - const arch3 = os2.arch(); - switch (arch3) { - case "x64": - return "x86_64"; - case "arm64": - return "aarch64"; - default: - throw new Error(`Unsupported architecture: ${arch3}`); - } -}; -var getPixiUrlFromVersion = (version3) => { - const arch3 = getArch(); - const platform2 = getPlatform(); - const pixiFile = `pixi-${arch3}-${platform2}${platform2 === "pc-windows-msvc" ? ".exe" : ""}`; - if (arch3 === "aarch64" && platform2 === "pc-windows-msvc") { - throw new Error("Windows on ARM is currently not supported"); - } - if (version3 === "latest") { - return `https://github.com/prefix-dev/pixi/releases/latest/download/${pixiFile}`; - } - return `https://github.com/prefix-dev/pixi/releases/download/${version3}/${pixiFile}`; -}; -var sha256 = (s) => { - return (0, import_crypto4.createHash)("sha256").update(s).digest("hex"); -}; -var execute = (cmd) => { - core.debug(`Executing: ${cmd.join(" ")}`); - return (0, import_exec.exec)(cmd[0], cmd.slice(1)); -}; -var pixiCmd = (command, withManifestPath = true) => { - let commandArray = [options.pixiBinPath].concat(command.split(" ")); - if (withManifestPath) { - commandArray = commandArray.concat(["--manifest-path", options.manifestPath]); - } - switch (options.logLevel) { - case "trace": - commandArray = commandArray.concat(["-vvv"]); - break; - case "debug": - commandArray = commandArray.concat(["-vv"]); - break; - case "info": - commandArray = commandArray.concat(["-v"]); - break; - case "warn": - break; - case "quiet": - commandArray = commandArray.concat(["-q"]); - break; - } - return commandArray; -}; - // src/options.ts var logLevelSchema = enumType(["quiet", "warn", "info", "debug", "trace"]); var postCleanupSchema = enumType(["none", "environment", "all"]); @@ -61054,14 +60967,14 @@ var PATHS = { pixiBin: import_path.default.join(import_os.default.homedir(), ".pixi", "bin", `pixi${import_os.default.platform() === "win32" ? ".exe" : ""}`) }; var parseOrUndefined = (key, schema) => { - const input = core2.getInput(key); + const input = core.getInput(key); if (input === "") { return void 0; } return schema.parse(input); }; var parseOrUndefinedJSON = (key, schema) => { - const input = core2.getInput(key); + const input = core.getInput(key); if (input === "") { return void 0; } @@ -61093,15 +61006,18 @@ var validateInputs = (inputs) => { throw new Error("You need to specify auth-host"); } } + if (inputs.cacheWrite && !inputs.cacheKey && !inputs.cache) { + throw new Error("cache-write is only valid with cache-key or cache specified."); + } }; var inferOptions = (inputs) => { const runInstall = inputs.runInstall ?? true; const pixiSource = inputs.pixiVersion ? { version: inputs.pixiVersion } : inputs.pixiUrl ? { url: inputs.pixiUrl } : { version: "latest" }; - const logLevel = inputs.logLevel ?? (core2.isDebug() ? "debug" : "warn"); + const logLevel = inputs.logLevel ?? (core.isDebug() ? "debug" : "warn"); const manifestPath = inputs.manifestPath ? import_path.default.resolve(untildify(inputs.manifestPath)) : "pixi.toml"; const pixiLockFile = import_path.default.join(import_path.default.dirname(manifestPath), import_path.default.basename(manifestPath).replace(/\.toml$/, ".lock")); const generateRunShell = inputs.generateRunShell ?? runInstall; - const cacheKey = inputs.cacheKey ?? (inputs.cache ? `pixi-${getCondaArch()}` : void 0); + const cache2 = inputs.cacheKey ? { cacheKeyPrefix: inputs.cacheKey, cacheWrite: inputs.cacheWrite ?? true } : inputs.cache ? { cacheKeyPrefix: "pixi-", cacheWrite: true } : void 0; const pixiBinPath = inputs.pixiBinPath ? import_path.default.resolve(untildify(inputs.pixiBinPath)) : PATHS.pixiBin; const pixiRunShell = import_path.default.join(import_path.default.dirname(pixiBinPath), "pixi-shell"); const auth = !inputs.authHost ? void 0 : inputs.authToken ? { @@ -61123,7 +61039,7 @@ var inferOptions = (inputs) => { pixiLockFile, runInstall, generateRunShell, - cacheKey, + cache: cache2, pixiBinPath, pixiRunShell, auth, @@ -61150,15 +61066,102 @@ var getOptions = () => { authCondaToken: parseOrUndefined("auth-conda-token", stringType()), postCleanup: parseOrUndefined("post-cleanup", postCleanupSchema) }; - core2.debug(`Inputs: ${JSON.stringify(inputs)}`); + core.debug(`Inputs: ${JSON.stringify(inputs)}`); validateInputs(inputs); const options2 = inferOptions(inputs); - core2.debug(`Inferred options: ${JSON.stringify(options2)}`); + core.debug(`Inferred options: ${JSON.stringify(options2)}`); assertOptions(options2); return options2; }; var options = getOptions(); +// src/util.ts +var import_crypto4 = require("crypto"); +var os3 = __toESM(require("os")); +var core2 = __toESM(require_core()); +var import_exec = __toESM(require_exec()); +var getCondaArch = () => { + const archDict = { + "darwin-x64": "osx-64", + "darwin-arm64": "osx-arm64", + "linux-x64": "linux-64", + "linux-arm64": "linux-aarch64", + "linux-ppc64": "linux-ppc64le", + "win32-x64": "win-64" + }; + const arch3 = archDict[`${os3.platform()}-${os3.arch()}`]; + if (!arch3) { + throw new Error(`Unsupported platform: ${os3.platform()}-${os3.arch()}`); + } + return arch3; +}; +var getPlatform = () => { + const platform2 = os3.platform(); + switch (platform2) { + case "darwin": + return "apple-darwin"; + case "linux": + return "unknown-linux-musl"; + case "win32": + return "pc-windows-msvc"; + default: + throw new Error(`Unsupported architecture: ${platform2}`); + } +}; +var getArch = () => { + const arch3 = os3.arch(); + switch (arch3) { + case "x64": + return "x86_64"; + case "arm64": + return "aarch64"; + default: + throw new Error(`Unsupported architecture: ${arch3}`); + } +}; +var getPixiUrlFromVersion = (version3) => { + const arch3 = getArch(); + const platform2 = getPlatform(); + const pixiFile = `pixi-${arch3}-${platform2}${platform2 === "pc-windows-msvc" ? ".exe" : ""}`; + if (arch3 === "aarch64" && platform2 === "pc-windows-msvc") { + throw new Error("Windows on ARM is currently not supported"); + } + if (version3 === "latest") { + return `https://github.com/prefix-dev/pixi/releases/latest/download/${pixiFile}`; + } + return `https://github.com/prefix-dev/pixi/releases/download/${version3}/${pixiFile}`; +}; +var sha256 = (s) => { + return (0, import_crypto4.createHash)("sha256").update(s).digest("hex"); +}; +var execute = (cmd) => { + core2.debug(`Executing: ${cmd.join(" ")}`); + return (0, import_exec.exec)(cmd[0], cmd.slice(1)); +}; +var pixiCmd = (command, withManifestPath = true) => { + let commandArray = [options.pixiBinPath].concat(command.split(" ")); + if (withManifestPath) { + commandArray = commandArray.concat(["--manifest-path", options.manifestPath]); + } + switch (options.logLevel) { + case "trace": + commandArray = commandArray.concat(["-vvv"]); + break; + case "debug": + commandArray = commandArray.concat(["-vv"]); + break; + case "info": + commandArray = commandArray.concat(["-v"]); + break; + case "warn": + break; + case "quiet": + commandArray = commandArray.concat(["-q"]); + break; + } + return commandArray; +}; + // src/cache.ts var import_promises = __toESM(require("fs/promises")); var import_path2 = __toESM(require("path")); @@ -61169,14 +61172,14 @@ var generateCacheKey = async (cacheKeyPrefix) => import_promises.default.readFil }); var cachePath = import_path2.default.join(import_path2.default.dirname(options.pixiLockFile), ".pixi"); var tryRestoreCache = () => { - const cacheKeyPrefix = options.cacheKey; - if (!cacheKeyPrefix) { + const cache_ = options.cache; + if (!cache_) { core3.debug("Skipping pixi cache restore."); return Promise.resolve(void 0); } return core3.group( "Restoring pixi cache", - () => generateCacheKey(cacheKeyPrefix).then((cacheKey) => { + () => generateCacheKey(cache_.cacheKeyPrefix).then((cacheKey) => { core3.debug(`Cache key: ${cacheKey}`); core3.debug(`Cache path: ${cachePath}`); return cache.restoreCache([cachePath], cacheKey, void 0, void 0, false).then((key) => { @@ -61191,14 +61194,14 @@ var tryRestoreCache = () => { ); }; var saveCache2 = () => { - const cacheKeyPrefix = options.cacheKey; - if (!cacheKeyPrefix) { + const cache_ = options.cache; + if (!cache_) { core3.debug("Skipping pixi cache save."); return Promise.resolve(void 0); } return core3.group( "Saving pixi cache", - () => generateCacheKey(cacheKeyPrefix).then( + () => generateCacheKey(cache_.cacheKeyPrefix).then( (cacheKey) => cache.saveCache([cachePath], cacheKey, void 0, false).then((cacheId) => { core3.info(`Saved cache with ID \`${cacheId}\``); }).catch((err) => { diff --git a/src/cache.ts b/src/cache.ts index e01c9403..fcbeed2a 100644 --- a/src/cache.ts +++ b/src/cache.ts @@ -16,13 +16,13 @@ export const generateCacheKey = async (cacheKeyPrefix: string) => const cachePath = path.join(path.dirname(options.pixiLockFile), '.pixi') export const tryRestoreCache = (): Promise => { - const cacheKeyPrefix = options.cacheKey - if (!cacheKeyPrefix) { + const cache_ = options.cache + if (!cache_) { core.debug('Skipping pixi cache restore.') return Promise.resolve(undefined) } return core.group('Restoring pixi cache', () => - generateCacheKey(cacheKeyPrefix).then((cacheKey) => { + generateCacheKey(cache_.cacheKeyPrefix).then((cacheKey) => { core.debug(`Cache key: ${cacheKey}`) core.debug(`Cache path: ${cachePath}`) return cache.restoreCache([cachePath], cacheKey, undefined, undefined, false).then((key) => { @@ -38,13 +38,13 @@ export const tryRestoreCache = (): Promise => { } export const saveCache = () => { - const cacheKeyPrefix = options.cacheKey - if (!cacheKeyPrefix) { + const cache_ = options.cache + if (!cache_) { core.debug('Skipping pixi cache save.') return Promise.resolve(undefined) } return core.group('Saving pixi cache', () => - generateCacheKey(cacheKeyPrefix).then((cacheKey) => + generateCacheKey(cache_.cacheKeyPrefix).then((cacheKey) => cache .saveCache([cachePath], cacheKey, undefined, false) .then((cacheId) => { diff --git a/src/options.ts b/src/options.ts index 2efb89f8..349dd240 100644 --- a/src/options.ts +++ b/src/options.ts @@ -14,6 +14,7 @@ type Inputs = { generateRunShell?: boolean cache?: boolean cacheKey?: string + cacheWrite?: boolean pixiBinPath?: string authHost?: string authToken?: string @@ -46,6 +47,11 @@ type Auth = { } ) +type Cache = { + cacheKeyPrefix: string + cacheWrite: boolean +} + export type Options = Readonly<{ pixiSource: PixiSource logLevel: LogLevel @@ -53,7 +59,7 @@ export type Options = Readonly<{ pixiLockFile: string runInstall: boolean generateRunShell: boolean - cacheKey?: string // undefined if cache is false + cache?: Cache pixiBinPath: string pixiRunShell: string auth?: Auth @@ -118,6 +124,9 @@ const validateInputs = (inputs: Inputs): void => { throw new Error('You need to specify auth-host') } } + if (inputs.cacheWrite && !inputs.cacheKey && !inputs.cache) { + throw new Error('cache-write is only valid with cache-key or cache specified.') + } } const inferOptions = (inputs: Inputs): Options => { @@ -131,7 +140,11 @@ const inferOptions = (inputs: Inputs): Options => { const manifestPath = inputs.manifestPath ? path.resolve(untildify(inputs.manifestPath)) : 'pixi.toml' const pixiLockFile = path.join(path.dirname(manifestPath), path.basename(manifestPath).replace(/\.toml$/, '.lock')) const generateRunShell = inputs.generateRunShell ?? runInstall - const cacheKey = inputs.cacheKey ?? (inputs.cache ? `pixi-${getCondaArch()}` : undefined) + const cache = inputs.cacheKey + ? { cacheKeyPrefix: inputs.cacheKey, cacheWrite: inputs.cacheWrite ?? true } + : inputs.cache + ? { cacheKeyPrefix: 'pixi-', cacheWrite: true } + : undefined const pixiBinPath = inputs.pixiBinPath ? path.resolve(untildify(inputs.pixiBinPath)) : PATHS.pixiBin const pixiRunShell = path.join(path.dirname(pixiBinPath), 'pixi-shell') const auth = !inputs.authHost @@ -159,7 +172,7 @@ const inferOptions = (inputs: Inputs): Options => { pixiLockFile, runInstall, generateRunShell, - cacheKey, + cache, pixiBinPath, pixiRunShell, auth, From 7a1d74017282de9e1cc6990610fc744eca7b849f Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Sat, 9 Sep 2023 18:00:40 +0200 Subject: [PATCH 34/57] . --- dist/index.js | 2 +- src/cache.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/index.js b/dist/index.js index 67c851c8..53efa0b1 100644 --- a/dist/index.js +++ b/dist/index.js @@ -61195,7 +61195,7 @@ var tryRestoreCache = () => { }; var saveCache2 = () => { const cache_ = options.cache; - if (!cache_) { + if (!cache_ || !cache_.cacheWrite) { core3.debug("Skipping pixi cache save."); return Promise.resolve(void 0); } diff --git a/src/cache.ts b/src/cache.ts index fcbeed2a..86ba7915 100644 --- a/src/cache.ts +++ b/src/cache.ts @@ -39,7 +39,7 @@ export const tryRestoreCache = (): Promise => { export const saveCache = () => { const cache_ = options.cache - if (!cache_) { + if (!cache_ || !cache_.cacheWrite) { core.debug('Skipping pixi cache save.') return Promise.resolve(undefined) } From eaafc4f41ed926ee44ff6bcdcaa2209846fea9fe Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Sat, 9 Sep 2023 18:05:05 +0200 Subject: [PATCH 35/57] . --- dist/index.js | 1 + src/options.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/dist/index.js b/dist/index.js index 53efa0b1..5f88d9c6 100644 --- a/dist/index.js +++ b/dist/index.js @@ -61058,6 +61058,7 @@ var getOptions = () => { generateRunShell: parseOrUndefinedJSON("generate-run-shell", booleanType()), cache: parseOrUndefinedJSON("cache", booleanType()), cacheKey: parseOrUndefined("cache-key", stringType()), + cacheWrite: parseOrUndefinedJSON("cache-write", booleanType()), pixiBinPath: parseOrUndefined("pixi-bin-path", stringType()), authHost: parseOrUndefined("auth-host", stringType()), authToken: parseOrUndefined("auth-token", stringType()), diff --git a/src/options.ts b/src/options.ts index 349dd240..74a9b536 100644 --- a/src/options.ts +++ b/src/options.ts @@ -3,7 +3,6 @@ import os from 'os' import * as core from '@actions/core' import * as z from 'zod' import untildify from 'untildify' -import { getCondaArch } from './util' type Inputs = { pixiVersion?: string @@ -199,6 +198,7 @@ const getOptions = () => { generateRunShell: parseOrUndefinedJSON('generate-run-shell', z.boolean()), cache: parseOrUndefinedJSON('cache', z.boolean()), cacheKey: parseOrUndefined('cache-key', z.string()), + cacheWrite: parseOrUndefinedJSON('cache-write', z.boolean()), pixiBinPath: parseOrUndefined('pixi-bin-path', z.string()), authHost: parseOrUndefined('auth-host', z.string()), authToken: parseOrUndefined('auth-token', z.string()), From 3635deb6a53e27fb2c1d7ab9174b1a500c2b3cdd Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Sat, 9 Sep 2023 18:10:09 +0200 Subject: [PATCH 36/57] . --- .github/workflows/test.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f50b7a72..a73c23ea 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -284,6 +284,10 @@ jobs: # check the action logs to see if the cache was written - run: | test -f .pixi/env/bin/python + if: matrix.os != 'windows-latest' + - run: | + test -f .pixi/env/python.exe + if: matrix.os == 'windows-latest' test-cache2: name: Test cache 2/2 From 8c54e9c0ed8ab0054b927f11368d489c25d6bf12 Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Sat, 9 Sep 2023 18:15:53 +0200 Subject: [PATCH 37/57] . --- .github/workflows/test.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a73c23ea..06141b48 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -201,6 +201,20 @@ jobs: # https://github.com/prefix-dev/pixi/issues/330 if: matrix.os == 'ubuntu-latest' + pixi-shell: + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + - name: Move pixi.toml + run: mv test/default/* . + - uses: ./ + - run: | + python --version | grep -q "3.11" + shell: pixi run bash {0} + post-cleanup: # not implemented yet if: false From eab596712a69a20953748dc8cdec1b536b8c5945 Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Sat, 9 Sep 2023 18:21:59 +0200 Subject: [PATCH 38/57] . --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 06141b48..e37aa2e8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -213,7 +213,7 @@ jobs: - uses: ./ - run: | python --version | grep -q "3.11" - shell: pixi run bash {0} + shell: pixi shell {0} post-cleanup: # not implemented yet From a14b6b6dc1e6dfbe8d7225e832a01c3b8d13539f Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Sat, 9 Sep 2023 18:25:53 +0200 Subject: [PATCH 39/57] . --- .github/workflows/test.yml | 2 +- action.yml | 8 +- dist/index.js | 5 +- dist/post.js | 5967 +++++++++++++++++++++++++++++++++++- src/options.ts | 11 +- src/post.ts | 39 +- 6 files changed, 6013 insertions(+), 19 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e37aa2e8..06141b48 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -213,7 +213,7 @@ jobs: - uses: ./ - run: | python --version | grep -q "3.11" - shell: pixi shell {0} + shell: pixi run bash {0} post-cleanup: # not implemented yet diff --git a/action.yml b/action.yml index 24f487d8..e406c1b0 100644 --- a/action.yml +++ b/action.yml @@ -48,12 +48,8 @@ inputs: description: Conda token to use for authentication. post-cleanup: description: | - What kind of cleanup the action should do in the post step. - One of `none`, `environment` or `all`. - If `none`, no cleanup is done. - If `environment`, the pixi environment is removed. - If `all`, the pixi environment, the pixi CLI are removed and the rattler cache is cleared. - Defaults to `all`. + If the action should clean up after itself. + If `true`, the pixi environment, the pixi binary and the rattler files in ~/.rattler and ~/.cache/rattler are removed. runs: using: node20 diff --git a/dist/index.js b/dist/index.js index 5f88d9c6..a385ec49 100644 --- a/dist/index.js +++ b/dist/index.js @@ -60962,7 +60962,6 @@ function untildify(pathWithTilde) { // src/options.ts var logLevelSchema = enumType(["quiet", "warn", "info", "debug", "trace"]); -var postCleanupSchema = enumType(["none", "environment", "all"]); var PATHS = { pixiBin: import_path.default.join(import_os.default.homedir(), ".pixi", "bin", `pixi${import_os.default.platform() === "win32" ? ".exe" : ""}`) }; @@ -61031,7 +61030,7 @@ var inferOptions = (inputs) => { username: inputs.authUsername, password: inputs.authPassword }; - const postCleanup = inputs.postCleanup ?? "all"; + const postCleanup = inputs.postCleanup ?? true; return { pixiSource, logLevel, @@ -61065,7 +61064,7 @@ var getOptions = () => { authUsername: parseOrUndefined("auth-username", stringType()), authPassword: parseOrUndefined("auth-password", stringType()), authCondaToken: parseOrUndefined("auth-conda-token", stringType()), - postCleanup: parseOrUndefined("post-cleanup", postCleanupSchema) + postCleanup: parseOrUndefinedJSON("post-cleanup", booleanType()) }; core.debug(`Inputs: ${JSON.stringify(inputs)}`); validateInputs(inputs); diff --git a/dist/post.js b/dist/post.js index ae9ebe0a..3cf1d7a5 100644 --- a/dist/post.js +++ b/dist/post.js @@ -1,5 +1,5970 @@ "use strict"; +var __create = Object.create; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __getProtoOf = Object.getPrototypeOf; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __esm = (fn, res) => function __init() { + return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res; +}; +var __commonJS = (cb, mod) => function __require() { + return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; +}; +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( + // If the importer is in node compatibility mode or this is not an ESM + // file that has been converted to a CommonJS file using a Babel- + // compatible transform (i.e. "__esModule" has not been set), then set + // "default" to the CommonJS "module.exports" for node compatibility. + isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, + mod +)); +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + +// node_modules/.pnpm/@actions+core@1.10.0/node_modules/@actions/core/lib/utils.js +var require_utils = __commonJS({ + "node_modules/.pnpm/@actions+core@1.10.0/node_modules/@actions/core/lib/utils.js"(exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.toCommandProperties = exports.toCommandValue = void 0; + function toCommandValue(input) { + if (input === null || input === void 0) { + return ""; + } else if (typeof input === "string" || input instanceof String) { + return input; + } + return JSON.stringify(input); + } + exports.toCommandValue = toCommandValue; + function toCommandProperties(annotationProperties) { + if (!Object.keys(annotationProperties).length) { + return {}; + } + return { + title: annotationProperties.title, + file: annotationProperties.file, + line: annotationProperties.startLine, + endLine: annotationProperties.endLine, + col: annotationProperties.startColumn, + endColumn: annotationProperties.endColumn + }; + } + exports.toCommandProperties = toCommandProperties; + } +}); + +// node_modules/.pnpm/@actions+core@1.10.0/node_modules/@actions/core/lib/command.js +var require_command = __commonJS({ + "node_modules/.pnpm/@actions+core@1.10.0/node_modules/@actions/core/lib/command.js"(exports) { + "use strict"; + var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) { + if (k2 === void 0) + k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { + return m[k]; + } }); + } : function(o, m, k, k2) { + if (k2 === void 0) + k2 = k; + o[k2] = m[k]; + }); + var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); + } : function(o, v) { + o["default"] = v; + }); + var __importStar = exports && exports.__importStar || function(mod) { + if (mod && mod.__esModule) + return mod; + var result = {}; + if (mod != null) { + for (var k in mod) + if (k !== "default" && Object.hasOwnProperty.call(mod, k)) + __createBinding(result, mod, k); + } + __setModuleDefault(result, mod); + return result; + }; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.issue = exports.issueCommand = void 0; + var os4 = __importStar(require("os")); + var utils_1 = require_utils(); + function issueCommand(command, properties, message) { + const cmd = new Command(command, properties, message); + process.stdout.write(cmd.toString() + os4.EOL); + } + exports.issueCommand = issueCommand; + function issue(name, message = "") { + issueCommand(name, {}, message); + } + exports.issue = issue; + var CMD_STRING = "::"; + var Command = class { + constructor(command, properties, message) { + if (!command) { + command = "missing.command"; + } + this.command = command; + this.properties = properties; + this.message = message; + } + toString() { + let cmdStr = CMD_STRING + this.command; + if (this.properties && Object.keys(this.properties).length > 0) { + cmdStr += " "; + let first = true; + for (const key in this.properties) { + if (this.properties.hasOwnProperty(key)) { + const val = this.properties[key]; + if (val) { + if (first) { + first = false; + } else { + cmdStr += ","; + } + cmdStr += `${key}=${escapeProperty(val)}`; + } + } + } + } + cmdStr += `${CMD_STRING}${escapeData(this.message)}`; + return cmdStr; + } + }; + function escapeData(s) { + return utils_1.toCommandValue(s).replace(/%/g, "%25").replace(/\r/g, "%0D").replace(/\n/g, "%0A"); + } + function escapeProperty(s) { + return utils_1.toCommandValue(s).replace(/%/g, "%25").replace(/\r/g, "%0D").replace(/\n/g, "%0A").replace(/:/g, "%3A").replace(/,/g, "%2C"); + } + } +}); + +// node_modules/.pnpm/uuid@8.3.2/node_modules/uuid/dist/esm-node/rng.js +function rng() { + if (poolPtr > rnds8Pool.length - 16) { + import_crypto.default.randomFillSync(rnds8Pool); + poolPtr = 0; + } + return rnds8Pool.slice(poolPtr, poolPtr += 16); +} +var import_crypto, rnds8Pool, poolPtr; +var init_rng = __esm({ + "node_modules/.pnpm/uuid@8.3.2/node_modules/uuid/dist/esm-node/rng.js"() { + "use strict"; + import_crypto = __toESM(require("crypto")); + rnds8Pool = new Uint8Array(256); + poolPtr = rnds8Pool.length; + } +}); + +// node_modules/.pnpm/uuid@8.3.2/node_modules/uuid/dist/esm-node/regex.js +var regex_default; +var init_regex = __esm({ + "node_modules/.pnpm/uuid@8.3.2/node_modules/uuid/dist/esm-node/regex.js"() { + "use strict"; + regex_default = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i; + } +}); + +// node_modules/.pnpm/uuid@8.3.2/node_modules/uuid/dist/esm-node/validate.js +function validate(uuid) { + return typeof uuid === "string" && regex_default.test(uuid); +} +var validate_default; +var init_validate = __esm({ + "node_modules/.pnpm/uuid@8.3.2/node_modules/uuid/dist/esm-node/validate.js"() { + "use strict"; + init_regex(); + validate_default = validate; + } +}); + +// node_modules/.pnpm/uuid@8.3.2/node_modules/uuid/dist/esm-node/stringify.js +function stringify(arr, offset = 0) { + const uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); + if (!validate_default(uuid)) { + throw TypeError("Stringified UUID is invalid"); + } + return uuid; +} +var byteToHex, stringify_default; +var init_stringify = __esm({ + "node_modules/.pnpm/uuid@8.3.2/node_modules/uuid/dist/esm-node/stringify.js"() { + "use strict"; + init_validate(); + byteToHex = []; + for (let i = 0; i < 256; ++i) { + byteToHex.push((i + 256).toString(16).substr(1)); + } + stringify_default = stringify; + } +}); + +// node_modules/.pnpm/uuid@8.3.2/node_modules/uuid/dist/esm-node/v1.js +function v1(options2, buf, offset) { + let i = buf && offset || 0; + const b = buf || new Array(16); + options2 = options2 || {}; + let node = options2.node || _nodeId; + let clockseq = options2.clockseq !== void 0 ? options2.clockseq : _clockseq; + if (node == null || clockseq == null) { + const seedBytes = options2.random || (options2.rng || rng)(); + if (node == null) { + node = _nodeId = [seedBytes[0] | 1, seedBytes[1], seedBytes[2], seedBytes[3], seedBytes[4], seedBytes[5]]; + } + if (clockseq == null) { + clockseq = _clockseq = (seedBytes[6] << 8 | seedBytes[7]) & 16383; + } + } + let msecs = options2.msecs !== void 0 ? options2.msecs : Date.now(); + let nsecs = options2.nsecs !== void 0 ? options2.nsecs : _lastNSecs + 1; + const dt = msecs - _lastMSecs + (nsecs - _lastNSecs) / 1e4; + if (dt < 0 && options2.clockseq === void 0) { + clockseq = clockseq + 1 & 16383; + } + if ((dt < 0 || msecs > _lastMSecs) && options2.nsecs === void 0) { + nsecs = 0; + } + if (nsecs >= 1e4) { + throw new Error("uuid.v1(): Can't create more than 10M uuids/sec"); + } + _lastMSecs = msecs; + _lastNSecs = nsecs; + _clockseq = clockseq; + msecs += 122192928e5; + const tl = ((msecs & 268435455) * 1e4 + nsecs) % 4294967296; + b[i++] = tl >>> 24 & 255; + b[i++] = tl >>> 16 & 255; + b[i++] = tl >>> 8 & 255; + b[i++] = tl & 255; + const tmh = msecs / 4294967296 * 1e4 & 268435455; + b[i++] = tmh >>> 8 & 255; + b[i++] = tmh & 255; + b[i++] = tmh >>> 24 & 15 | 16; + b[i++] = tmh >>> 16 & 255; + b[i++] = clockseq >>> 8 | 128; + b[i++] = clockseq & 255; + for (let n = 0; n < 6; ++n) { + b[i + n] = node[n]; + } + return buf || stringify_default(b); +} +var _nodeId, _clockseq, _lastMSecs, _lastNSecs, v1_default; +var init_v1 = __esm({ + "node_modules/.pnpm/uuid@8.3.2/node_modules/uuid/dist/esm-node/v1.js"() { + "use strict"; + init_rng(); + init_stringify(); + _lastMSecs = 0; + _lastNSecs = 0; + v1_default = v1; + } +}); + +// node_modules/.pnpm/uuid@8.3.2/node_modules/uuid/dist/esm-node/parse.js +function parse(uuid) { + if (!validate_default(uuid)) { + throw TypeError("Invalid UUID"); + } + let v; + const arr = new Uint8Array(16); + arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24; + arr[1] = v >>> 16 & 255; + arr[2] = v >>> 8 & 255; + arr[3] = v & 255; + arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8; + arr[5] = v & 255; + arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8; + arr[7] = v & 255; + arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8; + arr[9] = v & 255; + arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 1099511627776 & 255; + arr[11] = v / 4294967296 & 255; + arr[12] = v >>> 24 & 255; + arr[13] = v >>> 16 & 255; + arr[14] = v >>> 8 & 255; + arr[15] = v & 255; + return arr; +} +var parse_default; +var init_parse = __esm({ + "node_modules/.pnpm/uuid@8.3.2/node_modules/uuid/dist/esm-node/parse.js"() { + "use strict"; + init_validate(); + parse_default = parse; + } +}); + +// node_modules/.pnpm/uuid@8.3.2/node_modules/uuid/dist/esm-node/v35.js +function stringToBytes(str) { + str = unescape(encodeURIComponent(str)); + const bytes = []; + for (let i = 0; i < str.length; ++i) { + bytes.push(str.charCodeAt(i)); + } + return bytes; +} +function v35_default(name, version2, hashfunc) { + function generateUUID(value, namespace, buf, offset) { + if (typeof value === "string") { + value = stringToBytes(value); + } + if (typeof namespace === "string") { + namespace = parse_default(namespace); + } + if (namespace.length !== 16) { + throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)"); + } + let bytes = new Uint8Array(16 + value.length); + bytes.set(namespace); + bytes.set(value, namespace.length); + bytes = hashfunc(bytes); + bytes[6] = bytes[6] & 15 | version2; + bytes[8] = bytes[8] & 63 | 128; + if (buf) { + offset = offset || 0; + for (let i = 0; i < 16; ++i) { + buf[offset + i] = bytes[i]; + } + return buf; + } + return stringify_default(bytes); + } + try { + generateUUID.name = name; + } catch (err) { + } + generateUUID.DNS = DNS; + generateUUID.URL = URL2; + return generateUUID; +} +var DNS, URL2; +var init_v35 = __esm({ + "node_modules/.pnpm/uuid@8.3.2/node_modules/uuid/dist/esm-node/v35.js"() { + "use strict"; + init_stringify(); + init_parse(); + DNS = "6ba7b810-9dad-11d1-80b4-00c04fd430c8"; + URL2 = "6ba7b811-9dad-11d1-80b4-00c04fd430c8"; + } +}); + +// node_modules/.pnpm/uuid@8.3.2/node_modules/uuid/dist/esm-node/md5.js +function md5(bytes) { + if (Array.isArray(bytes)) { + bytes = Buffer.from(bytes); + } else if (typeof bytes === "string") { + bytes = Buffer.from(bytes, "utf8"); + } + return import_crypto2.default.createHash("md5").update(bytes).digest(); +} +var import_crypto2, md5_default; +var init_md5 = __esm({ + "node_modules/.pnpm/uuid@8.3.2/node_modules/uuid/dist/esm-node/md5.js"() { + "use strict"; + import_crypto2 = __toESM(require("crypto")); + md5_default = md5; + } +}); + +// node_modules/.pnpm/uuid@8.3.2/node_modules/uuid/dist/esm-node/v3.js +var v3, v3_default; +var init_v3 = __esm({ + "node_modules/.pnpm/uuid@8.3.2/node_modules/uuid/dist/esm-node/v3.js"() { + "use strict"; + init_v35(); + init_md5(); + v3 = v35_default("v3", 48, md5_default); + v3_default = v3; + } +}); + +// node_modules/.pnpm/uuid@8.3.2/node_modules/uuid/dist/esm-node/v4.js +function v4(options2, buf, offset) { + options2 = options2 || {}; + const rnds = options2.random || (options2.rng || rng)(); + rnds[6] = rnds[6] & 15 | 64; + rnds[8] = rnds[8] & 63 | 128; + if (buf) { + offset = offset || 0; + for (let i = 0; i < 16; ++i) { + buf[offset + i] = rnds[i]; + } + return buf; + } + return stringify_default(rnds); +} +var v4_default; +var init_v4 = __esm({ + "node_modules/.pnpm/uuid@8.3.2/node_modules/uuid/dist/esm-node/v4.js"() { + "use strict"; + init_rng(); + init_stringify(); + v4_default = v4; + } +}); + +// node_modules/.pnpm/uuid@8.3.2/node_modules/uuid/dist/esm-node/sha1.js +function sha1(bytes) { + if (Array.isArray(bytes)) { + bytes = Buffer.from(bytes); + } else if (typeof bytes === "string") { + bytes = Buffer.from(bytes, "utf8"); + } + return import_crypto3.default.createHash("sha1").update(bytes).digest(); +} +var import_crypto3, sha1_default; +var init_sha1 = __esm({ + "node_modules/.pnpm/uuid@8.3.2/node_modules/uuid/dist/esm-node/sha1.js"() { + "use strict"; + import_crypto3 = __toESM(require("crypto")); + sha1_default = sha1; + } +}); + +// node_modules/.pnpm/uuid@8.3.2/node_modules/uuid/dist/esm-node/v5.js +var v5, v5_default; +var init_v5 = __esm({ + "node_modules/.pnpm/uuid@8.3.2/node_modules/uuid/dist/esm-node/v5.js"() { + "use strict"; + init_v35(); + init_sha1(); + v5 = v35_default("v5", 80, sha1_default); + v5_default = v5; + } +}); + +// node_modules/.pnpm/uuid@8.3.2/node_modules/uuid/dist/esm-node/nil.js +var nil_default; +var init_nil = __esm({ + "node_modules/.pnpm/uuid@8.3.2/node_modules/uuid/dist/esm-node/nil.js"() { + "use strict"; + nil_default = "00000000-0000-0000-0000-000000000000"; + } +}); + +// node_modules/.pnpm/uuid@8.3.2/node_modules/uuid/dist/esm-node/version.js +function version(uuid) { + if (!validate_default(uuid)) { + throw TypeError("Invalid UUID"); + } + return parseInt(uuid.substr(14, 1), 16); +} +var version_default; +var init_version = __esm({ + "node_modules/.pnpm/uuid@8.3.2/node_modules/uuid/dist/esm-node/version.js"() { + "use strict"; + init_validate(); + version_default = version; + } +}); + +// node_modules/.pnpm/uuid@8.3.2/node_modules/uuid/dist/esm-node/index.js +var esm_node_exports = {}; +__export(esm_node_exports, { + NIL: () => nil_default, + parse: () => parse_default, + stringify: () => stringify_default, + v1: () => v1_default, + v3: () => v3_default, + v4: () => v4_default, + v5: () => v5_default, + validate: () => validate_default, + version: () => version_default +}); +var init_esm_node = __esm({ + "node_modules/.pnpm/uuid@8.3.2/node_modules/uuid/dist/esm-node/index.js"() { + "use strict"; + init_v1(); + init_v3(); + init_v4(); + init_v5(); + init_nil(); + init_version(); + init_validate(); + init_stringify(); + init_parse(); + } +}); + +// node_modules/.pnpm/@actions+core@1.10.0/node_modules/@actions/core/lib/file-command.js +var require_file_command = __commonJS({ + "node_modules/.pnpm/@actions+core@1.10.0/node_modules/@actions/core/lib/file-command.js"(exports) { + "use strict"; + var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) { + if (k2 === void 0) + k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { + return m[k]; + } }); + } : function(o, m, k, k2) { + if (k2 === void 0) + k2 = k; + o[k2] = m[k]; + }); + var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); + } : function(o, v) { + o["default"] = v; + }); + var __importStar = exports && exports.__importStar || function(mod) { + if (mod && mod.__esModule) + return mod; + var result = {}; + if (mod != null) { + for (var k in mod) + if (k !== "default" && Object.hasOwnProperty.call(mod, k)) + __createBinding(result, mod, k); + } + __setModuleDefault(result, mod); + return result; + }; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.prepareKeyValueMessage = exports.issueFileCommand = void 0; + var fs2 = __importStar(require("fs")); + var os4 = __importStar(require("os")); + var uuid_1 = (init_esm_node(), __toCommonJS(esm_node_exports)); + var utils_1 = require_utils(); + function issueFileCommand(command, message) { + const filePath = process.env[`GITHUB_${command}`]; + if (!filePath) { + throw new Error(`Unable to find environment variable for file command ${command}`); + } + if (!fs2.existsSync(filePath)) { + throw new Error(`Missing file at path: ${filePath}`); + } + fs2.appendFileSync(filePath, `${utils_1.toCommandValue(message)}${os4.EOL}`, { + encoding: "utf8" + }); + } + exports.issueFileCommand = issueFileCommand; + function prepareKeyValueMessage(key, value) { + const delimiter = `ghadelimiter_${uuid_1.v4()}`; + const convertedValue = utils_1.toCommandValue(value); + if (key.includes(delimiter)) { + throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`); + } + if (convertedValue.includes(delimiter)) { + throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`); + } + return `${key}<<${delimiter}${os4.EOL}${convertedValue}${os4.EOL}${delimiter}`; + } + exports.prepareKeyValueMessage = prepareKeyValueMessage; + } +}); + +// node_modules/.pnpm/@actions+http-client@2.1.1/node_modules/@actions/http-client/lib/proxy.js +var require_proxy = __commonJS({ + "node_modules/.pnpm/@actions+http-client@2.1.1/node_modules/@actions/http-client/lib/proxy.js"(exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.checkBypass = exports.getProxyUrl = void 0; + function getProxyUrl(reqUrl) { + const usingSsl = reqUrl.protocol === "https:"; + if (checkBypass(reqUrl)) { + return void 0; + } + const proxyVar = (() => { + if (usingSsl) { + return process.env["https_proxy"] || process.env["HTTPS_PROXY"]; + } else { + return process.env["http_proxy"] || process.env["HTTP_PROXY"]; + } + })(); + if (proxyVar) { + try { + return new URL(proxyVar); + } catch (_a) { + if (!proxyVar.startsWith("http://") && !proxyVar.startsWith("https://")) + return new URL(`http://${proxyVar}`); + } + } else { + return void 0; + } + } + exports.getProxyUrl = getProxyUrl; + function checkBypass(reqUrl) { + if (!reqUrl.hostname) { + return false; + } + const reqHost = reqUrl.hostname; + if (isLoopbackAddress(reqHost)) { + return true; + } + const noProxy = process.env["no_proxy"] || process.env["NO_PROXY"] || ""; + if (!noProxy) { + return false; + } + let reqPort; + if (reqUrl.port) { + reqPort = Number(reqUrl.port); + } else if (reqUrl.protocol === "http:") { + reqPort = 80; + } else if (reqUrl.protocol === "https:") { + reqPort = 443; + } + const upperReqHosts = [reqUrl.hostname.toUpperCase()]; + if (typeof reqPort === "number") { + upperReqHosts.push(`${upperReqHosts[0]}:${reqPort}`); + } + for (const upperNoProxyItem of noProxy.split(",").map((x) => x.trim().toUpperCase()).filter((x) => x)) { + if (upperNoProxyItem === "*" || upperReqHosts.some((x) => x === upperNoProxyItem || x.endsWith(`.${upperNoProxyItem}`) || upperNoProxyItem.startsWith(".") && x.endsWith(`${upperNoProxyItem}`))) { + return true; + } + } + return false; + } + exports.checkBypass = checkBypass; + function isLoopbackAddress(host) { + const hostLower = host.toLowerCase(); + return hostLower === "localhost" || hostLower.startsWith("127.") || hostLower.startsWith("[::1]") || hostLower.startsWith("[0:0:0:0:0:0:0:1]"); + } + } +}); + +// node_modules/.pnpm/tunnel@0.0.6/node_modules/tunnel/lib/tunnel.js +var require_tunnel = __commonJS({ + "node_modules/.pnpm/tunnel@0.0.6/node_modules/tunnel/lib/tunnel.js"(exports) { + "use strict"; + var net = require("net"); + var tls = require("tls"); + var http = require("http"); + var https = require("https"); + var events = require("events"); + var assert = require("assert"); + var util2 = require("util"); + exports.httpOverHttp = httpOverHttp; + exports.httpsOverHttp = httpsOverHttp; + exports.httpOverHttps = httpOverHttps; + exports.httpsOverHttps = httpsOverHttps; + function httpOverHttp(options2) { + var agent = new TunnelingAgent(options2); + agent.request = http.request; + return agent; + } + function httpsOverHttp(options2) { + var agent = new TunnelingAgent(options2); + agent.request = http.request; + agent.createSocket = createSecureSocket; + agent.defaultPort = 443; + return agent; + } + function httpOverHttps(options2) { + var agent = new TunnelingAgent(options2); + agent.request = https.request; + return agent; + } + function httpsOverHttps(options2) { + var agent = new TunnelingAgent(options2); + agent.request = https.request; + agent.createSocket = createSecureSocket; + agent.defaultPort = 443; + return agent; + } + function TunnelingAgent(options2) { + var self = this; + self.options = options2 || {}; + self.proxyOptions = self.options.proxy || {}; + self.maxSockets = self.options.maxSockets || http.Agent.defaultMaxSockets; + self.requests = []; + self.sockets = []; + self.on("free", function onFree(socket, host, port, localAddress) { + var options3 = toOptions(host, port, localAddress); + for (var i = 0, len = self.requests.length; i < len; ++i) { + var pending = self.requests[i]; + if (pending.host === options3.host && pending.port === options3.port) { + self.requests.splice(i, 1); + pending.request.onSocket(socket); + return; + } + } + socket.destroy(); + self.removeSocket(socket); + }); + } + util2.inherits(TunnelingAgent, events.EventEmitter); + TunnelingAgent.prototype.addRequest = function addRequest(req, host, port, localAddress) { + var self = this; + var options2 = mergeOptions({ request: req }, self.options, toOptions(host, port, localAddress)); + if (self.sockets.length >= this.maxSockets) { + self.requests.push(options2); + return; + } + self.createSocket(options2, function(socket) { + socket.on("free", onFree); + socket.on("close", onCloseOrRemove); + socket.on("agentRemove", onCloseOrRemove); + req.onSocket(socket); + function onFree() { + self.emit("free", socket, options2); + } + function onCloseOrRemove(err) { + self.removeSocket(socket); + socket.removeListener("free", onFree); + socket.removeListener("close", onCloseOrRemove); + socket.removeListener("agentRemove", onCloseOrRemove); + } + }); + }; + TunnelingAgent.prototype.createSocket = function createSocket(options2, cb) { + var self = this; + var placeholder = {}; + self.sockets.push(placeholder); + var connectOptions = mergeOptions({}, self.proxyOptions, { + method: "CONNECT", + path: options2.host + ":" + options2.port, + agent: false, + headers: { + host: options2.host + ":" + options2.port + } + }); + if (options2.localAddress) { + connectOptions.localAddress = options2.localAddress; + } + if (connectOptions.proxyAuth) { + connectOptions.headers = connectOptions.headers || {}; + connectOptions.headers["Proxy-Authorization"] = "Basic " + new Buffer(connectOptions.proxyAuth).toString("base64"); + } + debug3("making CONNECT request"); + var connectReq = self.request(connectOptions); + connectReq.useChunkedEncodingByDefault = false; + connectReq.once("response", onResponse); + connectReq.once("upgrade", onUpgrade); + connectReq.once("connect", onConnect); + connectReq.once("error", onError); + connectReq.end(); + function onResponse(res) { + res.upgrade = true; + } + function onUpgrade(res, socket, head) { + process.nextTick(function() { + onConnect(res, socket, head); + }); + } + function onConnect(res, socket, head) { + connectReq.removeAllListeners(); + socket.removeAllListeners(); + if (res.statusCode !== 200) { + debug3( + "tunneling socket could not be established, statusCode=%d", + res.statusCode + ); + socket.destroy(); + var error = new Error("tunneling socket could not be established, statusCode=" + res.statusCode); + error.code = "ECONNRESET"; + options2.request.emit("error", error); + self.removeSocket(placeholder); + return; + } + if (head.length > 0) { + debug3("got illegal response body from proxy"); + socket.destroy(); + var error = new Error("got illegal response body from proxy"); + error.code = "ECONNRESET"; + options2.request.emit("error", error); + self.removeSocket(placeholder); + return; + } + debug3("tunneling connection has established"); + self.sockets[self.sockets.indexOf(placeholder)] = socket; + return cb(socket); + } + function onError(cause) { + connectReq.removeAllListeners(); + debug3( + "tunneling socket could not be established, cause=%s\n", + cause.message, + cause.stack + ); + var error = new Error("tunneling socket could not be established, cause=" + cause.message); + error.code = "ECONNRESET"; + options2.request.emit("error", error); + self.removeSocket(placeholder); + } + }; + TunnelingAgent.prototype.removeSocket = function removeSocket(socket) { + var pos = this.sockets.indexOf(socket); + if (pos === -1) { + return; + } + this.sockets.splice(pos, 1); + var pending = this.requests.shift(); + if (pending) { + this.createSocket(pending, function(socket2) { + pending.request.onSocket(socket2); + }); + } + }; + function createSecureSocket(options2, cb) { + var self = this; + TunnelingAgent.prototype.createSocket.call(self, options2, function(socket) { + var hostHeader = options2.request.getHeader("host"); + var tlsOptions = mergeOptions({}, self.options, { + socket, + servername: hostHeader ? hostHeader.replace(/:.*$/, "") : options2.host + }); + var secureSocket = tls.connect(0, tlsOptions); + self.sockets[self.sockets.indexOf(socket)] = secureSocket; + cb(secureSocket); + }); + } + function toOptions(host, port, localAddress) { + if (typeof host === "string") { + return { + host, + port, + localAddress + }; + } + return host; + } + function mergeOptions(target) { + for (var i = 1, len = arguments.length; i < len; ++i) { + var overrides = arguments[i]; + if (typeof overrides === "object") { + var keys = Object.keys(overrides); + for (var j = 0, keyLen = keys.length; j < keyLen; ++j) { + var k = keys[j]; + if (overrides[k] !== void 0) { + target[k] = overrides[k]; + } + } + } + } + return target; + } + var debug3; + if (process.env.NODE_DEBUG && /\btunnel\b/.test(process.env.NODE_DEBUG)) { + debug3 = function() { + var args = Array.prototype.slice.call(arguments); + if (typeof args[0] === "string") { + args[0] = "TUNNEL: " + args[0]; + } else { + args.unshift("TUNNEL:"); + } + console.error.apply(console, args); + }; + } else { + debug3 = function() { + }; + } + exports.debug = debug3; + } +}); + +// node_modules/.pnpm/tunnel@0.0.6/node_modules/tunnel/index.js +var require_tunnel2 = __commonJS({ + "node_modules/.pnpm/tunnel@0.0.6/node_modules/tunnel/index.js"(exports, module2) { + "use strict"; + module2.exports = require_tunnel(); + } +}); + +// node_modules/.pnpm/@actions+http-client@2.1.1/node_modules/@actions/http-client/lib/index.js +var require_lib = __commonJS({ + "node_modules/.pnpm/@actions+http-client@2.1.1/node_modules/@actions/http-client/lib/index.js"(exports) { + "use strict"; + var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) { + if (k2 === void 0) + k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { + return m[k]; + } }); + } : function(o, m, k, k2) { + if (k2 === void 0) + k2 = k; + o[k2] = m[k]; + }); + var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); + } : function(o, v) { + o["default"] = v; + }); + var __importStar = exports && exports.__importStar || function(mod) { + if (mod && mod.__esModule) + return mod; + var result = {}; + if (mod != null) { + for (var k in mod) + if (k !== "default" && Object.hasOwnProperty.call(mod, k)) + __createBinding(result, mod, k); + } + __setModuleDefault(result, mod); + return result; + }; + var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) { + function adopt(value) { + return value instanceof P ? value : new P(function(resolve) { + resolve(value); + }); + } + return new (P || (P = Promise))(function(resolve, reject) { + function fulfilled(value) { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + } + function rejected(value) { + try { + step(generator["throw"](value)); + } catch (e) { + reject(e); + } + } + function step(result) { + result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); + } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); + }; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.HttpClient = exports.isHttps = exports.HttpClientResponse = exports.HttpClientError = exports.getProxyUrl = exports.MediaTypes = exports.Headers = exports.HttpCodes = void 0; + var http = __importStar(require("http")); + var https = __importStar(require("https")); + var pm = __importStar(require_proxy()); + var tunnel = __importStar(require_tunnel2()); + var HttpCodes; + (function(HttpCodes2) { + HttpCodes2[HttpCodes2["OK"] = 200] = "OK"; + HttpCodes2[HttpCodes2["MultipleChoices"] = 300] = "MultipleChoices"; + HttpCodes2[HttpCodes2["MovedPermanently"] = 301] = "MovedPermanently"; + HttpCodes2[HttpCodes2["ResourceMoved"] = 302] = "ResourceMoved"; + HttpCodes2[HttpCodes2["SeeOther"] = 303] = "SeeOther"; + HttpCodes2[HttpCodes2["NotModified"] = 304] = "NotModified"; + HttpCodes2[HttpCodes2["UseProxy"] = 305] = "UseProxy"; + HttpCodes2[HttpCodes2["SwitchProxy"] = 306] = "SwitchProxy"; + HttpCodes2[HttpCodes2["TemporaryRedirect"] = 307] = "TemporaryRedirect"; + HttpCodes2[HttpCodes2["PermanentRedirect"] = 308] = "PermanentRedirect"; + HttpCodes2[HttpCodes2["BadRequest"] = 400] = "BadRequest"; + HttpCodes2[HttpCodes2["Unauthorized"] = 401] = "Unauthorized"; + HttpCodes2[HttpCodes2["PaymentRequired"] = 402] = "PaymentRequired"; + HttpCodes2[HttpCodes2["Forbidden"] = 403] = "Forbidden"; + HttpCodes2[HttpCodes2["NotFound"] = 404] = "NotFound"; + HttpCodes2[HttpCodes2["MethodNotAllowed"] = 405] = "MethodNotAllowed"; + HttpCodes2[HttpCodes2["NotAcceptable"] = 406] = "NotAcceptable"; + HttpCodes2[HttpCodes2["ProxyAuthenticationRequired"] = 407] = "ProxyAuthenticationRequired"; + HttpCodes2[HttpCodes2["RequestTimeout"] = 408] = "RequestTimeout"; + HttpCodes2[HttpCodes2["Conflict"] = 409] = "Conflict"; + HttpCodes2[HttpCodes2["Gone"] = 410] = "Gone"; + HttpCodes2[HttpCodes2["TooManyRequests"] = 429] = "TooManyRequests"; + HttpCodes2[HttpCodes2["InternalServerError"] = 500] = "InternalServerError"; + HttpCodes2[HttpCodes2["NotImplemented"] = 501] = "NotImplemented"; + HttpCodes2[HttpCodes2["BadGateway"] = 502] = "BadGateway"; + HttpCodes2[HttpCodes2["ServiceUnavailable"] = 503] = "ServiceUnavailable"; + HttpCodes2[HttpCodes2["GatewayTimeout"] = 504] = "GatewayTimeout"; + })(HttpCodes = exports.HttpCodes || (exports.HttpCodes = {})); + var Headers; + (function(Headers2) { + Headers2["Accept"] = "accept"; + Headers2["ContentType"] = "content-type"; + })(Headers = exports.Headers || (exports.Headers = {})); + var MediaTypes; + (function(MediaTypes2) { + MediaTypes2["ApplicationJson"] = "application/json"; + })(MediaTypes = exports.MediaTypes || (exports.MediaTypes = {})); + function getProxyUrl(serverUrl) { + const proxyUrl = pm.getProxyUrl(new URL(serverUrl)); + return proxyUrl ? proxyUrl.href : ""; + } + exports.getProxyUrl = getProxyUrl; + var HttpRedirectCodes = [ + HttpCodes.MovedPermanently, + HttpCodes.ResourceMoved, + HttpCodes.SeeOther, + HttpCodes.TemporaryRedirect, + HttpCodes.PermanentRedirect + ]; + var HttpResponseRetryCodes = [ + HttpCodes.BadGateway, + HttpCodes.ServiceUnavailable, + HttpCodes.GatewayTimeout + ]; + var RetryableHttpVerbs = ["OPTIONS", "GET", "DELETE", "HEAD"]; + var ExponentialBackoffCeiling = 10; + var ExponentialBackoffTimeSlice = 5; + var HttpClientError = class _HttpClientError extends Error { + constructor(message, statusCode) { + super(message); + this.name = "HttpClientError"; + this.statusCode = statusCode; + Object.setPrototypeOf(this, _HttpClientError.prototype); + } + }; + exports.HttpClientError = HttpClientError; + var HttpClientResponse = class { + constructor(message) { + this.message = message; + } + readBody() { + return __awaiter(this, void 0, void 0, function* () { + return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () { + let output = Buffer.alloc(0); + this.message.on("data", (chunk) => { + output = Buffer.concat([output, chunk]); + }); + this.message.on("end", () => { + resolve(output.toString()); + }); + })); + }); + } + readBodyBuffer() { + return __awaiter(this, void 0, void 0, function* () { + return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () { + const chunks = []; + this.message.on("data", (chunk) => { + chunks.push(chunk); + }); + this.message.on("end", () => { + resolve(Buffer.concat(chunks)); + }); + })); + }); + } + }; + exports.HttpClientResponse = HttpClientResponse; + function isHttps(requestUrl) { + const parsedUrl = new URL(requestUrl); + return parsedUrl.protocol === "https:"; + } + exports.isHttps = isHttps; + var HttpClient = class { + constructor(userAgent, handlers, requestOptions) { + this._ignoreSslError = false; + this._allowRedirects = true; + this._allowRedirectDowngrade = false; + this._maxRedirects = 50; + this._allowRetries = false; + this._maxRetries = 1; + this._keepAlive = false; + this._disposed = false; + this.userAgent = userAgent; + this.handlers = handlers || []; + this.requestOptions = requestOptions; + if (requestOptions) { + if (requestOptions.ignoreSslError != null) { + this._ignoreSslError = requestOptions.ignoreSslError; + } + this._socketTimeout = requestOptions.socketTimeout; + if (requestOptions.allowRedirects != null) { + this._allowRedirects = requestOptions.allowRedirects; + } + if (requestOptions.allowRedirectDowngrade != null) { + this._allowRedirectDowngrade = requestOptions.allowRedirectDowngrade; + } + if (requestOptions.maxRedirects != null) { + this._maxRedirects = Math.max(requestOptions.maxRedirects, 0); + } + if (requestOptions.keepAlive != null) { + this._keepAlive = requestOptions.keepAlive; + } + if (requestOptions.allowRetries != null) { + this._allowRetries = requestOptions.allowRetries; + } + if (requestOptions.maxRetries != null) { + this._maxRetries = requestOptions.maxRetries; + } + } + } + options(requestUrl, additionalHeaders) { + return __awaiter(this, void 0, void 0, function* () { + return this.request("OPTIONS", requestUrl, null, additionalHeaders || {}); + }); + } + get(requestUrl, additionalHeaders) { + return __awaiter(this, void 0, void 0, function* () { + return this.request("GET", requestUrl, null, additionalHeaders || {}); + }); + } + del(requestUrl, additionalHeaders) { + return __awaiter(this, void 0, void 0, function* () { + return this.request("DELETE", requestUrl, null, additionalHeaders || {}); + }); + } + post(requestUrl, data, additionalHeaders) { + return __awaiter(this, void 0, void 0, function* () { + return this.request("POST", requestUrl, data, additionalHeaders || {}); + }); + } + patch(requestUrl, data, additionalHeaders) { + return __awaiter(this, void 0, void 0, function* () { + return this.request("PATCH", requestUrl, data, additionalHeaders || {}); + }); + } + put(requestUrl, data, additionalHeaders) { + return __awaiter(this, void 0, void 0, function* () { + return this.request("PUT", requestUrl, data, additionalHeaders || {}); + }); + } + head(requestUrl, additionalHeaders) { + return __awaiter(this, void 0, void 0, function* () { + return this.request("HEAD", requestUrl, null, additionalHeaders || {}); + }); + } + sendStream(verb, requestUrl, stream, additionalHeaders) { + return __awaiter(this, void 0, void 0, function* () { + return this.request(verb, requestUrl, stream, additionalHeaders); + }); + } + /** + * Gets a typed object from an endpoint + * Be aware that not found returns a null. Other errors (4xx, 5xx) reject the promise + */ + getJson(requestUrl, additionalHeaders = {}) { + return __awaiter(this, void 0, void 0, function* () { + additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); + const res = yield this.get(requestUrl, additionalHeaders); + return this._processResponse(res, this.requestOptions); + }); + } + postJson(requestUrl, obj, additionalHeaders = {}) { + return __awaiter(this, void 0, void 0, function* () { + const data = JSON.stringify(obj, null, 2); + additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); + additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); + const res = yield this.post(requestUrl, data, additionalHeaders); + return this._processResponse(res, this.requestOptions); + }); + } + putJson(requestUrl, obj, additionalHeaders = {}) { + return __awaiter(this, void 0, void 0, function* () { + const data = JSON.stringify(obj, null, 2); + additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); + additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); + const res = yield this.put(requestUrl, data, additionalHeaders); + return this._processResponse(res, this.requestOptions); + }); + } + patchJson(requestUrl, obj, additionalHeaders = {}) { + return __awaiter(this, void 0, void 0, function* () { + const data = JSON.stringify(obj, null, 2); + additionalHeaders[Headers.Accept] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.Accept, MediaTypes.ApplicationJson); + additionalHeaders[Headers.ContentType] = this._getExistingOrDefaultHeader(additionalHeaders, Headers.ContentType, MediaTypes.ApplicationJson); + const res = yield this.patch(requestUrl, data, additionalHeaders); + return this._processResponse(res, this.requestOptions); + }); + } + /** + * Makes a raw http request. + * All other methods such as get, post, patch, and request ultimately call this. + * Prefer get, del, post and patch + */ + request(verb, requestUrl, data, headers) { + return __awaiter(this, void 0, void 0, function* () { + if (this._disposed) { + throw new Error("Client has already been disposed."); + } + const parsedUrl = new URL(requestUrl); + let info = this._prepareRequest(verb, parsedUrl, headers); + const maxTries = this._allowRetries && RetryableHttpVerbs.includes(verb) ? this._maxRetries + 1 : 1; + let numTries = 0; + let response; + do { + response = yield this.requestRaw(info, data); + if (response && response.message && response.message.statusCode === HttpCodes.Unauthorized) { + let authenticationHandler; + for (const handler of this.handlers) { + if (handler.canHandleAuthentication(response)) { + authenticationHandler = handler; + break; + } + } + if (authenticationHandler) { + return authenticationHandler.handleAuthentication(this, info, data); + } else { + return response; + } + } + let redirectsRemaining = this._maxRedirects; + while (response.message.statusCode && HttpRedirectCodes.includes(response.message.statusCode) && this._allowRedirects && redirectsRemaining > 0) { + const redirectUrl = response.message.headers["location"]; + if (!redirectUrl) { + break; + } + const parsedRedirectUrl = new URL(redirectUrl); + if (parsedUrl.protocol === "https:" && parsedUrl.protocol !== parsedRedirectUrl.protocol && !this._allowRedirectDowngrade) { + throw new Error("Redirect from HTTPS to HTTP protocol. This downgrade is not allowed for security reasons. If you want to allow this behavior, set the allowRedirectDowngrade option to true."); + } + yield response.readBody(); + if (parsedRedirectUrl.hostname !== parsedUrl.hostname) { + for (const header in headers) { + if (header.toLowerCase() === "authorization") { + delete headers[header]; + } + } + } + info = this._prepareRequest(verb, parsedRedirectUrl, headers); + response = yield this.requestRaw(info, data); + redirectsRemaining--; + } + if (!response.message.statusCode || !HttpResponseRetryCodes.includes(response.message.statusCode)) { + return response; + } + numTries += 1; + if (numTries < maxTries) { + yield response.readBody(); + yield this._performExponentialBackoff(numTries); + } + } while (numTries < maxTries); + return response; + }); + } + /** + * Needs to be called if keepAlive is set to true in request options. + */ + dispose() { + if (this._agent) { + this._agent.destroy(); + } + this._disposed = true; + } + /** + * Raw request. + * @param info + * @param data + */ + requestRaw(info, data) { + return __awaiter(this, void 0, void 0, function* () { + return new Promise((resolve, reject) => { + function callbackForResult(err, res) { + if (err) { + reject(err); + } else if (!res) { + reject(new Error("Unknown error")); + } else { + resolve(res); + } + } + this.requestRawWithCallback(info, data, callbackForResult); + }); + }); + } + /** + * Raw request with callback. + * @param info + * @param data + * @param onResult + */ + requestRawWithCallback(info, data, onResult) { + if (typeof data === "string") { + if (!info.options.headers) { + info.options.headers = {}; + } + info.options.headers["Content-Length"] = Buffer.byteLength(data, "utf8"); + } + let callbackCalled = false; + function handleResult2(err, res) { + if (!callbackCalled) { + callbackCalled = true; + onResult(err, res); + } + } + const req = info.httpModule.request(info.options, (msg) => { + const res = new HttpClientResponse(msg); + handleResult2(void 0, res); + }); + let socket; + req.on("socket", (sock) => { + socket = sock; + }); + req.setTimeout(this._socketTimeout || 3 * 6e4, () => { + if (socket) { + socket.end(); + } + handleResult2(new Error(`Request timeout: ${info.options.path}`)); + }); + req.on("error", function(err) { + handleResult2(err); + }); + if (data && typeof data === "string") { + req.write(data, "utf8"); + } + if (data && typeof data !== "string") { + data.on("close", function() { + req.end(); + }); + data.pipe(req); + } else { + req.end(); + } + } + /** + * Gets an http agent. This function is useful when you need an http agent that handles + * routing through a proxy server - depending upon the url and proxy environment variables. + * @param serverUrl The server URL where the request will be sent. For example, https://api.github.com + */ + getAgent(serverUrl) { + const parsedUrl = new URL(serverUrl); + return this._getAgent(parsedUrl); + } + _prepareRequest(method, requestUrl, headers) { + const info = {}; + info.parsedUrl = requestUrl; + const usingSsl = info.parsedUrl.protocol === "https:"; + info.httpModule = usingSsl ? https : http; + const defaultPort = usingSsl ? 443 : 80; + info.options = {}; + info.options.host = info.parsedUrl.hostname; + info.options.port = info.parsedUrl.port ? parseInt(info.parsedUrl.port) : defaultPort; + info.options.path = (info.parsedUrl.pathname || "") + (info.parsedUrl.search || ""); + info.options.method = method; + info.options.headers = this._mergeHeaders(headers); + if (this.userAgent != null) { + info.options.headers["user-agent"] = this.userAgent; + } + info.options.agent = this._getAgent(info.parsedUrl); + if (this.handlers) { + for (const handler of this.handlers) { + handler.prepareRequest(info.options); + } + } + return info; + } + _mergeHeaders(headers) { + if (this.requestOptions && this.requestOptions.headers) { + return Object.assign({}, lowercaseKeys(this.requestOptions.headers), lowercaseKeys(headers || {})); + } + return lowercaseKeys(headers || {}); + } + _getExistingOrDefaultHeader(additionalHeaders, header, _default) { + let clientHeader; + if (this.requestOptions && this.requestOptions.headers) { + clientHeader = lowercaseKeys(this.requestOptions.headers)[header]; + } + return additionalHeaders[header] || clientHeader || _default; + } + _getAgent(parsedUrl) { + let agent; + const proxyUrl = pm.getProxyUrl(parsedUrl); + const useProxy = proxyUrl && proxyUrl.hostname; + if (this._keepAlive && useProxy) { + agent = this._proxyAgent; + } + if (this._keepAlive && !useProxy) { + agent = this._agent; + } + if (agent) { + return agent; + } + const usingSsl = parsedUrl.protocol === "https:"; + let maxSockets = 100; + if (this.requestOptions) { + maxSockets = this.requestOptions.maxSockets || http.globalAgent.maxSockets; + } + if (proxyUrl && proxyUrl.hostname) { + const agentOptions = { + maxSockets, + keepAlive: this._keepAlive, + proxy: Object.assign(Object.assign({}, (proxyUrl.username || proxyUrl.password) && { + proxyAuth: `${proxyUrl.username}:${proxyUrl.password}` + }), { host: proxyUrl.hostname, port: proxyUrl.port }) + }; + let tunnelAgent; + const overHttps = proxyUrl.protocol === "https:"; + if (usingSsl) { + tunnelAgent = overHttps ? tunnel.httpsOverHttps : tunnel.httpsOverHttp; + } else { + tunnelAgent = overHttps ? tunnel.httpOverHttps : tunnel.httpOverHttp; + } + agent = tunnelAgent(agentOptions); + this._proxyAgent = agent; + } + if (this._keepAlive && !agent) { + const options2 = { keepAlive: this._keepAlive, maxSockets }; + agent = usingSsl ? new https.Agent(options2) : new http.Agent(options2); + this._agent = agent; + } + if (!agent) { + agent = usingSsl ? https.globalAgent : http.globalAgent; + } + if (usingSsl && this._ignoreSslError) { + agent.options = Object.assign(agent.options || {}, { + rejectUnauthorized: false + }); + } + return agent; + } + _performExponentialBackoff(retryNumber) { + return __awaiter(this, void 0, void 0, function* () { + retryNumber = Math.min(ExponentialBackoffCeiling, retryNumber); + const ms = ExponentialBackoffTimeSlice * Math.pow(2, retryNumber); + return new Promise((resolve) => setTimeout(() => resolve(), ms)); + }); + } + _processResponse(res, options2) { + return __awaiter(this, void 0, void 0, function* () { + return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { + const statusCode = res.message.statusCode || 0; + const response = { + statusCode, + result: null, + headers: {} + }; + if (statusCode === HttpCodes.NotFound) { + resolve(response); + } + function dateTimeDeserializer(key, value) { + if (typeof value === "string") { + const a = new Date(value); + if (!isNaN(a.valueOf())) { + return a; + } + } + return value; + } + let obj; + let contents; + try { + contents = yield res.readBody(); + if (contents && contents.length > 0) { + if (options2 && options2.deserializeDates) { + obj = JSON.parse(contents, dateTimeDeserializer); + } else { + obj = JSON.parse(contents); + } + response.result = obj; + } + response.headers = res.message.headers; + } catch (err) { + } + if (statusCode > 299) { + let msg; + if (obj && obj.message) { + msg = obj.message; + } else if (contents && contents.length > 0) { + msg = contents; + } else { + msg = `Failed request: (${statusCode})`; + } + const err = new HttpClientError(msg, statusCode); + err.result = response.result; + reject(err); + } else { + resolve(response); + } + })); + }); + } + }; + exports.HttpClient = HttpClient; + var lowercaseKeys = (obj) => Object.keys(obj).reduce((c, k) => (c[k.toLowerCase()] = obj[k], c), {}); + } +}); + +// node_modules/.pnpm/@actions+http-client@2.1.1/node_modules/@actions/http-client/lib/auth.js +var require_auth = __commonJS({ + "node_modules/.pnpm/@actions+http-client@2.1.1/node_modules/@actions/http-client/lib/auth.js"(exports) { + "use strict"; + var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) { + function adopt(value) { + return value instanceof P ? value : new P(function(resolve) { + resolve(value); + }); + } + return new (P || (P = Promise))(function(resolve, reject) { + function fulfilled(value) { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + } + function rejected(value) { + try { + step(generator["throw"](value)); + } catch (e) { + reject(e); + } + } + function step(result) { + result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); + } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); + }; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.PersonalAccessTokenCredentialHandler = exports.BearerCredentialHandler = exports.BasicCredentialHandler = void 0; + var BasicCredentialHandler = class { + constructor(username, password) { + this.username = username; + this.password = password; + } + prepareRequest(options2) { + if (!options2.headers) { + throw Error("The request has no headers"); + } + options2.headers["Authorization"] = `Basic ${Buffer.from(`${this.username}:${this.password}`).toString("base64")}`; + } + // This handler cannot handle 401 + canHandleAuthentication() { + return false; + } + handleAuthentication() { + return __awaiter(this, void 0, void 0, function* () { + throw new Error("not implemented"); + }); + } + }; + exports.BasicCredentialHandler = BasicCredentialHandler; + var BearerCredentialHandler = class { + constructor(token) { + this.token = token; + } + // currently implements pre-authorization + // TODO: support preAuth = false where it hooks on 401 + prepareRequest(options2) { + if (!options2.headers) { + throw Error("The request has no headers"); + } + options2.headers["Authorization"] = `Bearer ${this.token}`; + } + // This handler cannot handle 401 + canHandleAuthentication() { + return false; + } + handleAuthentication() { + return __awaiter(this, void 0, void 0, function* () { + throw new Error("not implemented"); + }); + } + }; + exports.BearerCredentialHandler = BearerCredentialHandler; + var PersonalAccessTokenCredentialHandler = class { + constructor(token) { + this.token = token; + } + // currently implements pre-authorization + // TODO: support preAuth = false where it hooks on 401 + prepareRequest(options2) { + if (!options2.headers) { + throw Error("The request has no headers"); + } + options2.headers["Authorization"] = `Basic ${Buffer.from(`PAT:${this.token}`).toString("base64")}`; + } + // This handler cannot handle 401 + canHandleAuthentication() { + return false; + } + handleAuthentication() { + return __awaiter(this, void 0, void 0, function* () { + throw new Error("not implemented"); + }); + } + }; + exports.PersonalAccessTokenCredentialHandler = PersonalAccessTokenCredentialHandler; + } +}); + +// node_modules/.pnpm/@actions+core@1.10.0/node_modules/@actions/core/lib/oidc-utils.js +var require_oidc_utils = __commonJS({ + "node_modules/.pnpm/@actions+core@1.10.0/node_modules/@actions/core/lib/oidc-utils.js"(exports) { + "use strict"; + var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) { + function adopt(value) { + return value instanceof P ? value : new P(function(resolve) { + resolve(value); + }); + } + return new (P || (P = Promise))(function(resolve, reject) { + function fulfilled(value) { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + } + function rejected(value) { + try { + step(generator["throw"](value)); + } catch (e) { + reject(e); + } + } + function step(result) { + result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); + } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); + }; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.OidcClient = void 0; + var http_client_1 = require_lib(); + var auth_1 = require_auth(); + var core_1 = require_core(); + var OidcClient = class _OidcClient { + static createHttpClient(allowRetry = true, maxRetry = 10) { + const requestOptions = { + allowRetries: allowRetry, + maxRetries: maxRetry + }; + return new http_client_1.HttpClient("actions/oidc-client", [new auth_1.BearerCredentialHandler(_OidcClient.getRequestToken())], requestOptions); + } + static getRequestToken() { + const token = process.env["ACTIONS_ID_TOKEN_REQUEST_TOKEN"]; + if (!token) { + throw new Error("Unable to get ACTIONS_ID_TOKEN_REQUEST_TOKEN env variable"); + } + return token; + } + static getIDTokenUrl() { + const runtimeUrl = process.env["ACTIONS_ID_TOKEN_REQUEST_URL"]; + if (!runtimeUrl) { + throw new Error("Unable to get ACTIONS_ID_TOKEN_REQUEST_URL env variable"); + } + return runtimeUrl; + } + static getCall(id_token_url) { + var _a; + return __awaiter(this, void 0, void 0, function* () { + const httpclient = _OidcClient.createHttpClient(); + const res = yield httpclient.getJson(id_token_url).catch((error) => { + throw new Error(`Failed to get ID Token. + + Error Code : ${error.statusCode} + + Error Message: ${error.result.message}`); + }); + const id_token = (_a = res.result) === null || _a === void 0 ? void 0 : _a.value; + if (!id_token) { + throw new Error("Response json body do not have ID Token field"); + } + return id_token; + }); + } + static getIDToken(audience) { + return __awaiter(this, void 0, void 0, function* () { + try { + let id_token_url = _OidcClient.getIDTokenUrl(); + if (audience) { + const encodedAudience = encodeURIComponent(audience); + id_token_url = `${id_token_url}&audience=${encodedAudience}`; + } + core_1.debug(`ID token url is ${id_token_url}`); + const id_token = yield _OidcClient.getCall(id_token_url); + core_1.setSecret(id_token); + return id_token; + } catch (error) { + throw new Error(`Error message: ${error.message}`); + } + }); + } + }; + exports.OidcClient = OidcClient; + } +}); + +// node_modules/.pnpm/@actions+core@1.10.0/node_modules/@actions/core/lib/summary.js +var require_summary = __commonJS({ + "node_modules/.pnpm/@actions+core@1.10.0/node_modules/@actions/core/lib/summary.js"(exports) { + "use strict"; + var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) { + function adopt(value) { + return value instanceof P ? value : new P(function(resolve) { + resolve(value); + }); + } + return new (P || (P = Promise))(function(resolve, reject) { + function fulfilled(value) { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + } + function rejected(value) { + try { + step(generator["throw"](value)); + } catch (e) { + reject(e); + } + } + function step(result) { + result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); + } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); + }; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.summary = exports.markdownSummary = exports.SUMMARY_DOCS_URL = exports.SUMMARY_ENV_VAR = void 0; + var os_1 = require("os"); + var fs_1 = require("fs"); + var { access, appendFile, writeFile } = fs_1.promises; + exports.SUMMARY_ENV_VAR = "GITHUB_STEP_SUMMARY"; + exports.SUMMARY_DOCS_URL = "https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary"; + var Summary = class { + constructor() { + this._buffer = ""; + } + /** + * Finds the summary file path from the environment, rejects if env var is not found or file does not exist + * Also checks r/w permissions. + * + * @returns step summary file path + */ + filePath() { + return __awaiter(this, void 0, void 0, function* () { + if (this._filePath) { + return this._filePath; + } + const pathFromEnv = process.env[exports.SUMMARY_ENV_VAR]; + if (!pathFromEnv) { + throw new Error(`Unable to find environment variable for $${exports.SUMMARY_ENV_VAR}. Check if your runtime environment supports job summaries.`); + } + try { + yield access(pathFromEnv, fs_1.constants.R_OK | fs_1.constants.W_OK); + } catch (_a) { + throw new Error(`Unable to access summary file: '${pathFromEnv}'. Check if the file has correct read/write permissions.`); + } + this._filePath = pathFromEnv; + return this._filePath; + }); + } + /** + * Wraps content in an HTML tag, adding any HTML attributes + * + * @param {string} tag HTML tag to wrap + * @param {string | null} content content within the tag + * @param {[attribute: string]: string} attrs key-value list of HTML attributes to add + * + * @returns {string} content wrapped in HTML element + */ + wrap(tag, content, attrs = {}) { + const htmlAttrs = Object.entries(attrs).map(([key, value]) => ` ${key}="${value}"`).join(""); + if (!content) { + return `<${tag}${htmlAttrs}>`; + } + return `<${tag}${htmlAttrs}>${content}`; + } + /** + * Writes text in the buffer to the summary buffer file and empties buffer. Will append by default. + * + * @param {SummaryWriteOptions} [options] (optional) options for write operation + * + * @returns {Promise} summary instance + */ + write(options2) { + return __awaiter(this, void 0, void 0, function* () { + const overwrite = !!(options2 === null || options2 === void 0 ? void 0 : options2.overwrite); + const filePath = yield this.filePath(); + const writeFunc = overwrite ? writeFile : appendFile; + yield writeFunc(filePath, this._buffer, { encoding: "utf8" }); + return this.emptyBuffer(); + }); + } + /** + * Clears the summary buffer and wipes the summary file + * + * @returns {Summary} summary instance + */ + clear() { + return __awaiter(this, void 0, void 0, function* () { + return this.emptyBuffer().write({ overwrite: true }); + }); + } + /** + * Returns the current summary buffer as a string + * + * @returns {string} string of summary buffer + */ + stringify() { + return this._buffer; + } + /** + * If the summary buffer is empty + * + * @returns {boolen} true if the buffer is empty + */ + isEmptyBuffer() { + return this._buffer.length === 0; + } + /** + * Resets the summary buffer without writing to summary file + * + * @returns {Summary} summary instance + */ + emptyBuffer() { + this._buffer = ""; + return this; + } + /** + * Adds raw text to the summary buffer + * + * @param {string} text content to add + * @param {boolean} [addEOL=false] (optional) append an EOL to the raw text (default: false) + * + * @returns {Summary} summary instance + */ + addRaw(text, addEOL = false) { + this._buffer += text; + return addEOL ? this.addEOL() : this; + } + /** + * Adds the operating system-specific end-of-line marker to the buffer + * + * @returns {Summary} summary instance + */ + addEOL() { + return this.addRaw(os_1.EOL); + } + /** + * Adds an HTML codeblock to the summary buffer + * + * @param {string} code content to render within fenced code block + * @param {string} lang (optional) language to syntax highlight code + * + * @returns {Summary} summary instance + */ + addCodeBlock(code, lang) { + const attrs = Object.assign({}, lang && { lang }); + const element = this.wrap("pre", this.wrap("code", code), attrs); + return this.addRaw(element).addEOL(); + } + /** + * Adds an HTML list to the summary buffer + * + * @param {string[]} items list of items to render + * @param {boolean} [ordered=false] (optional) if the rendered list should be ordered or not (default: false) + * + * @returns {Summary} summary instance + */ + addList(items, ordered = false) { + const tag = ordered ? "ol" : "ul"; + const listItems = items.map((item) => this.wrap("li", item)).join(""); + const element = this.wrap(tag, listItems); + return this.addRaw(element).addEOL(); + } + /** + * Adds an HTML table to the summary buffer + * + * @param {SummaryTableCell[]} rows table rows + * + * @returns {Summary} summary instance + */ + addTable(rows) { + const tableBody = rows.map((row) => { + const cells = row.map((cell) => { + if (typeof cell === "string") { + return this.wrap("td", cell); + } + const { header, data, colspan, rowspan } = cell; + const tag = header ? "th" : "td"; + const attrs = Object.assign(Object.assign({}, colspan && { colspan }), rowspan && { rowspan }); + return this.wrap(tag, data, attrs); + }).join(""); + return this.wrap("tr", cells); + }).join(""); + const element = this.wrap("table", tableBody); + return this.addRaw(element).addEOL(); + } + /** + * Adds a collapsable HTML details element to the summary buffer + * + * @param {string} label text for the closed state + * @param {string} content collapsable content + * + * @returns {Summary} summary instance + */ + addDetails(label, content) { + const element = this.wrap("details", this.wrap("summary", label) + content); + return this.addRaw(element).addEOL(); + } + /** + * Adds an HTML image tag to the summary buffer + * + * @param {string} src path to the image you to embed + * @param {string} alt text description of the image + * @param {SummaryImageOptions} options (optional) addition image attributes + * + * @returns {Summary} summary instance + */ + addImage(src, alt, options2) { + const { width, height } = options2 || {}; + const attrs = Object.assign(Object.assign({}, width && { width }), height && { height }); + const element = this.wrap("img", null, Object.assign({ src, alt }, attrs)); + return this.addRaw(element).addEOL(); + } + /** + * Adds an HTML section heading element + * + * @param {string} text heading text + * @param {number | string} [level=1] (optional) the heading level, default: 1 + * + * @returns {Summary} summary instance + */ + addHeading(text, level) { + const tag = `h${level}`; + const allowedTag = ["h1", "h2", "h3", "h4", "h5", "h6"].includes(tag) ? tag : "h1"; + const element = this.wrap(allowedTag, text); + return this.addRaw(element).addEOL(); + } + /** + * Adds an HTML thematic break (
) to the summary buffer + * + * @returns {Summary} summary instance + */ + addSeparator() { + const element = this.wrap("hr", null); + return this.addRaw(element).addEOL(); + } + /** + * Adds an HTML line break (
) to the summary buffer + * + * @returns {Summary} summary instance + */ + addBreak() { + const element = this.wrap("br", null); + return this.addRaw(element).addEOL(); + } + /** + * Adds an HTML blockquote to the summary buffer + * + * @param {string} text quote text + * @param {string} cite (optional) citation url + * + * @returns {Summary} summary instance + */ + addQuote(text, cite) { + const attrs = Object.assign({}, cite && { cite }); + const element = this.wrap("blockquote", text, attrs); + return this.addRaw(element).addEOL(); + } + /** + * Adds an HTML anchor tag to the summary buffer + * + * @param {string} text link text/content + * @param {string} href hyperlink + * + * @returns {Summary} summary instance + */ + addLink(text, href) { + const element = this.wrap("a", text, { href }); + return this.addRaw(element).addEOL(); + } + }; + var _summary = new Summary(); + exports.markdownSummary = _summary; + exports.summary = _summary; + } +}); + +// node_modules/.pnpm/@actions+core@1.10.0/node_modules/@actions/core/lib/path-utils.js +var require_path_utils = __commonJS({ + "node_modules/.pnpm/@actions+core@1.10.0/node_modules/@actions/core/lib/path-utils.js"(exports) { + "use strict"; + var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) { + if (k2 === void 0) + k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { + return m[k]; + } }); + } : function(o, m, k, k2) { + if (k2 === void 0) + k2 = k; + o[k2] = m[k]; + }); + var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); + } : function(o, v) { + o["default"] = v; + }); + var __importStar = exports && exports.__importStar || function(mod) { + if (mod && mod.__esModule) + return mod; + var result = {}; + if (mod != null) { + for (var k in mod) + if (k !== "default" && Object.hasOwnProperty.call(mod, k)) + __createBinding(result, mod, k); + } + __setModuleDefault(result, mod); + return result; + }; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.toPlatformPath = exports.toWin32Path = exports.toPosixPath = void 0; + var path3 = __importStar(require("path")); + function toPosixPath(pth) { + return pth.replace(/[\\]/g, "/"); + } + exports.toPosixPath = toPosixPath; + function toWin32Path(pth) { + return pth.replace(/[/]/g, "\\"); + } + exports.toWin32Path = toWin32Path; + function toPlatformPath(pth) { + return pth.replace(/[/\\]/g, path3.sep); + } + exports.toPlatformPath = toPlatformPath; + } +}); + +// node_modules/.pnpm/@actions+core@1.10.0/node_modules/@actions/core/lib/core.js +var require_core = __commonJS({ + "node_modules/.pnpm/@actions+core@1.10.0/node_modules/@actions/core/lib/core.js"(exports) { + "use strict"; + var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) { + if (k2 === void 0) + k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { + return m[k]; + } }); + } : function(o, m, k, k2) { + if (k2 === void 0) + k2 = k; + o[k2] = m[k]; + }); + var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); + } : function(o, v) { + o["default"] = v; + }); + var __importStar = exports && exports.__importStar || function(mod) { + if (mod && mod.__esModule) + return mod; + var result = {}; + if (mod != null) { + for (var k in mod) + if (k !== "default" && Object.hasOwnProperty.call(mod, k)) + __createBinding(result, mod, k); + } + __setModuleDefault(result, mod); + return result; + }; + var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) { + function adopt(value) { + return value instanceof P ? value : new P(function(resolve) { + resolve(value); + }); + } + return new (P || (P = Promise))(function(resolve, reject) { + function fulfilled(value) { + try { + step(generator.next(value)); + } catch (e) { + reject(e); + } + } + function rejected(value) { + try { + step(generator["throw"](value)); + } catch (e) { + reject(e); + } + } + function step(result) { + result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); + } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); + }; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.getIDToken = exports.getState = exports.saveState = exports.group = exports.endGroup = exports.startGroup = exports.info = exports.notice = exports.warning = exports.error = exports.debug = exports.isDebug = exports.setFailed = exports.setCommandEcho = exports.setOutput = exports.getBooleanInput = exports.getMultilineInput = exports.getInput = exports.addPath = exports.setSecret = exports.exportVariable = exports.ExitCode = void 0; + var command_1 = require_command(); + var file_command_1 = require_file_command(); + var utils_1 = require_utils(); + var os4 = __importStar(require("os")); + var path3 = __importStar(require("path")); + var oidc_utils_1 = require_oidc_utils(); + var ExitCode; + (function(ExitCode2) { + ExitCode2[ExitCode2["Success"] = 0] = "Success"; + ExitCode2[ExitCode2["Failure"] = 1] = "Failure"; + })(ExitCode = exports.ExitCode || (exports.ExitCode = {})); + function exportVariable(name, val) { + const convertedVal = utils_1.toCommandValue(val); + process.env[name] = convertedVal; + const filePath = process.env["GITHUB_ENV"] || ""; + if (filePath) { + return file_command_1.issueFileCommand("ENV", file_command_1.prepareKeyValueMessage(name, val)); + } + command_1.issueCommand("set-env", { name }, convertedVal); + } + exports.exportVariable = exportVariable; + function setSecret(secret) { + command_1.issueCommand("add-mask", {}, secret); + } + exports.setSecret = setSecret; + function addPath(inputPath) { + const filePath = process.env["GITHUB_PATH"] || ""; + if (filePath) { + file_command_1.issueFileCommand("PATH", inputPath); + } else { + command_1.issueCommand("add-path", {}, inputPath); + } + process.env["PATH"] = `${inputPath}${path3.delimiter}${process.env["PATH"]}`; + } + exports.addPath = addPath; + function getInput2(name, options2) { + const val = process.env[`INPUT_${name.replace(/ /g, "_").toUpperCase()}`] || ""; + if (options2 && options2.required && !val) { + throw new Error(`Input required and not supplied: ${name}`); + } + if (options2 && options2.trimWhitespace === false) { + return val; + } + return val.trim(); + } + exports.getInput = getInput2; + function getMultilineInput(name, options2) { + const inputs = getInput2(name, options2).split("\n").filter((x) => x !== ""); + if (options2 && options2.trimWhitespace === false) { + return inputs; + } + return inputs.map((input) => input.trim()); + } + exports.getMultilineInput = getMultilineInput; + function getBooleanInput(name, options2) { + const trueValue = ["true", "True", "TRUE"]; + const falseValue = ["false", "False", "FALSE"]; + const val = getInput2(name, options2); + if (trueValue.includes(val)) + return true; + if (falseValue.includes(val)) + return false; + throw new TypeError(`Input does not meet YAML 1.2 "Core Schema" specification: ${name} +Support boolean input list: \`true | True | TRUE | false | False | FALSE\``); + } + exports.getBooleanInput = getBooleanInput; + function setOutput(name, value) { + const filePath = process.env["GITHUB_OUTPUT"] || ""; + if (filePath) { + return file_command_1.issueFileCommand("OUTPUT", file_command_1.prepareKeyValueMessage(name, value)); + } + process.stdout.write(os4.EOL); + command_1.issueCommand("set-output", { name }, utils_1.toCommandValue(value)); + } + exports.setOutput = setOutput; + function setCommandEcho(enabled) { + command_1.issue("echo", enabled ? "on" : "off"); + } + exports.setCommandEcho = setCommandEcho; + function setFailed(message) { + process.exitCode = ExitCode.Failure; + error(message); + } + exports.setFailed = setFailed; + function isDebug2() { + return process.env["RUNNER_DEBUG"] === "1"; + } + exports.isDebug = isDebug2; + function debug3(message) { + command_1.issueCommand("debug", {}, message); + } + exports.debug = debug3; + function error(message, properties = {}) { + command_1.issueCommand("error", utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message); + } + exports.error = error; + function warning(message, properties = {}) { + command_1.issueCommand("warning", utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message); + } + exports.warning = warning; + function notice(message, properties = {}) { + command_1.issueCommand("notice", utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message); + } + exports.notice = notice; + function info(message) { + process.stdout.write(message + os4.EOL); + } + exports.info = info; + function startGroup(name) { + command_1.issue("group", name); + } + exports.startGroup = startGroup; + function endGroup() { + command_1.issue("endgroup"); + } + exports.endGroup = endGroup; + function group(name, fn) { + return __awaiter(this, void 0, void 0, function* () { + startGroup(name); + let result; + try { + result = yield fn(); + } finally { + endGroup(); + } + return result; + }); + } + exports.group = group; + function saveState(name, value) { + const filePath = process.env["GITHUB_STATE"] || ""; + if (filePath) { + return file_command_1.issueFileCommand("STATE", file_command_1.prepareKeyValueMessage(name, value)); + } + command_1.issueCommand("save-state", { name }, utils_1.toCommandValue(value)); + } + exports.saveState = saveState; + function getState(name) { + return process.env[`STATE_${name}`] || ""; + } + exports.getState = getState; + function getIDToken(aud) { + return __awaiter(this, void 0, void 0, function* () { + return yield oidc_utils_1.OidcClient.getIDToken(aud); + }); + } + exports.getIDToken = getIDToken; + var summary_1 = require_summary(); + Object.defineProperty(exports, "summary", { enumerable: true, get: function() { + return summary_1.summary; + } }); + var summary_2 = require_summary(); + Object.defineProperty(exports, "markdownSummary", { enumerable: true, get: function() { + return summary_2.markdownSummary; + } }); + var path_utils_1 = require_path_utils(); + Object.defineProperty(exports, "toPosixPath", { enumerable: true, get: function() { + return path_utils_1.toPosixPath; + } }); + Object.defineProperty(exports, "toWin32Path", { enumerable: true, get: function() { + return path_utils_1.toWin32Path; + } }); + Object.defineProperty(exports, "toPlatformPath", { enumerable: true, get: function() { + return path_utils_1.toPlatformPath; + } }); + } +}); + +// src/post.ts +var import_promises = __toESM(require("fs/promises")); +var import_path2 = __toESM(require("path")); +var os3 = __toESM(require("os")); +var core2 = __toESM(require_core()); + +// src/options.ts +var import_path = __toESM(require("path")); +var import_os = __toESM(require("os")); +var core = __toESM(require_core()); + +// node_modules/.pnpm/zod@3.22.2/node_modules/zod/lib/index.mjs +var util; +(function(util2) { + util2.assertEqual = (val) => val; + function assertIs(_arg) { + } + util2.assertIs = assertIs; + function assertNever(_x) { + throw new Error(); + } + util2.assertNever = assertNever; + util2.arrayToEnum = (items) => { + const obj = {}; + for (const item of items) { + obj[item] = item; + } + return obj; + }; + util2.getValidEnumValues = (obj) => { + const validKeys = util2.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number"); + const filtered = {}; + for (const k of validKeys) { + filtered[k] = obj[k]; + } + return util2.objectValues(filtered); + }; + util2.objectValues = (obj) => { + return util2.objectKeys(obj).map(function(e) { + return obj[e]; + }); + }; + util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => { + const keys = []; + for (const key in object) { + if (Object.prototype.hasOwnProperty.call(object, key)) { + keys.push(key); + } + } + return keys; + }; + util2.find = (arr, checker) => { + for (const item of arr) { + if (checker(item)) + return item; + } + return void 0; + }; + util2.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && isFinite(val) && Math.floor(val) === val; + function joinValues(array, separator = " | ") { + return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator); + } + util2.joinValues = joinValues; + util2.jsonStringifyReplacer = (_, value) => { + if (typeof value === "bigint") { + return value.toString(); + } + return value; + }; +})(util || (util = {})); +var objectUtil; +(function(objectUtil2) { + objectUtil2.mergeShapes = (first, second) => { + return { + ...first, + ...second + // second overwrites first + }; + }; +})(objectUtil || (objectUtil = {})); +var ZodParsedType = util.arrayToEnum([ + "string", + "nan", + "number", + "integer", + "float", + "boolean", + "date", + "bigint", + "symbol", + "function", + "undefined", + "null", + "array", + "object", + "unknown", + "promise", + "void", + "never", + "map", + "set" +]); +var getParsedType = (data) => { + const t = typeof data; + switch (t) { + case "undefined": + return ZodParsedType.undefined; + case "string": + return ZodParsedType.string; + case "number": + return isNaN(data) ? ZodParsedType.nan : ZodParsedType.number; + case "boolean": + return ZodParsedType.boolean; + case "function": + return ZodParsedType.function; + case "bigint": + return ZodParsedType.bigint; + case "symbol": + return ZodParsedType.symbol; + case "object": + if (Array.isArray(data)) { + return ZodParsedType.array; + } + if (data === null) { + return ZodParsedType.null; + } + if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") { + return ZodParsedType.promise; + } + if (typeof Map !== "undefined" && data instanceof Map) { + return ZodParsedType.map; + } + if (typeof Set !== "undefined" && data instanceof Set) { + return ZodParsedType.set; + } + if (typeof Date !== "undefined" && data instanceof Date) { + return ZodParsedType.date; + } + return ZodParsedType.object; + default: + return ZodParsedType.unknown; + } +}; +var ZodIssueCode = util.arrayToEnum([ + "invalid_type", + "invalid_literal", + "custom", + "invalid_union", + "invalid_union_discriminator", + "invalid_enum_value", + "unrecognized_keys", + "invalid_arguments", + "invalid_return_type", + "invalid_date", + "invalid_string", + "too_small", + "too_big", + "invalid_intersection_types", + "not_multiple_of", + "not_finite" +]); +var ZodError = class extends Error { + constructor(issues) { + super(); + this.issues = []; + this.addIssue = (sub) => { + this.issues = [...this.issues, sub]; + }; + this.addIssues = (subs = []) => { + this.issues = [...this.issues, ...subs]; + }; + const actualProto = new.target.prototype; + if (Object.setPrototypeOf) { + Object.setPrototypeOf(this, actualProto); + } else { + this.__proto__ = actualProto; + } + this.name = "ZodError"; + this.issues = issues; + } + get errors() { + return this.issues; + } + format(_mapper) { + const mapper = _mapper || function(issue) { + return issue.message; + }; + const fieldErrors = { _errors: [] }; + const processError = (error) => { + for (const issue of error.issues) { + if (issue.code === "invalid_union") { + issue.unionErrors.map(processError); + } else if (issue.code === "invalid_return_type") { + processError(issue.returnTypeError); + } else if (issue.code === "invalid_arguments") { + processError(issue.argumentsError); + } else if (issue.path.length === 0) { + fieldErrors._errors.push(mapper(issue)); + } else { + let curr = fieldErrors; + let i = 0; + while (i < issue.path.length) { + const el = issue.path[i]; + const terminal = i === issue.path.length - 1; + if (!terminal) { + curr[el] = curr[el] || { _errors: [] }; + } else { + curr[el] = curr[el] || { _errors: [] }; + curr[el]._errors.push(mapper(issue)); + } + curr = curr[el]; + i++; + } + } + } + }; + processError(this); + return fieldErrors; + } + toString() { + return this.message; + } + get message() { + return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2); + } + get isEmpty() { + return this.issues.length === 0; + } + flatten(mapper = (issue) => issue.message) { + const fieldErrors = {}; + const formErrors = []; + for (const sub of this.issues) { + if (sub.path.length > 0) { + fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || []; + fieldErrors[sub.path[0]].push(mapper(sub)); + } else { + formErrors.push(mapper(sub)); + } + } + return { formErrors, fieldErrors }; + } + get formErrors() { + return this.flatten(); + } +}; +ZodError.create = (issues) => { + const error = new ZodError(issues); + return error; +}; +var errorMap = (issue, _ctx) => { + let message; + switch (issue.code) { + case ZodIssueCode.invalid_type: + if (issue.received === ZodParsedType.undefined) { + message = "Required"; + } else { + message = `Expected ${issue.expected}, received ${issue.received}`; + } + break; + case ZodIssueCode.invalid_literal: + message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util.jsonStringifyReplacer)}`; + break; + case ZodIssueCode.unrecognized_keys: + message = `Unrecognized key(s) in object: ${util.joinValues(issue.keys, ", ")}`; + break; + case ZodIssueCode.invalid_union: + message = `Invalid input`; + break; + case ZodIssueCode.invalid_union_discriminator: + message = `Invalid discriminator value. Expected ${util.joinValues(issue.options)}`; + break; + case ZodIssueCode.invalid_enum_value: + message = `Invalid enum value. Expected ${util.joinValues(issue.options)}, received '${issue.received}'`; + break; + case ZodIssueCode.invalid_arguments: + message = `Invalid function arguments`; + break; + case ZodIssueCode.invalid_return_type: + message = `Invalid function return type`; + break; + case ZodIssueCode.invalid_date: + message = `Invalid date`; + break; + case ZodIssueCode.invalid_string: + if (typeof issue.validation === "object") { + if ("includes" in issue.validation) { + message = `Invalid input: must include "${issue.validation.includes}"`; + if (typeof issue.validation.position === "number") { + message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`; + } + } else if ("startsWith" in issue.validation) { + message = `Invalid input: must start with "${issue.validation.startsWith}"`; + } else if ("endsWith" in issue.validation) { + message = `Invalid input: must end with "${issue.validation.endsWith}"`; + } else { + util.assertNever(issue.validation); + } + } else if (issue.validation !== "regex") { + message = `Invalid ${issue.validation}`; + } else { + message = "Invalid"; + } + break; + case ZodIssueCode.too_small: + if (issue.type === "array") + message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`; + else if (issue.type === "string") + message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`; + else if (issue.type === "number") + message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`; + else if (issue.type === "date") + message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`; + else + message = "Invalid input"; + break; + case ZodIssueCode.too_big: + if (issue.type === "array") + message = `Array must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`; + else if (issue.type === "string") + message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`; + else if (issue.type === "number") + message = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`; + else if (issue.type === "bigint") + message = `BigInt must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`; + else if (issue.type === "date") + message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue.maximum))}`; + else + message = "Invalid input"; + break; + case ZodIssueCode.custom: + message = `Invalid input`; + break; + case ZodIssueCode.invalid_intersection_types: + message = `Intersection results could not be merged`; + break; + case ZodIssueCode.not_multiple_of: + message = `Number must be a multiple of ${issue.multipleOf}`; + break; + case ZodIssueCode.not_finite: + message = "Number must be finite"; + break; + default: + message = _ctx.defaultError; + util.assertNever(issue); + } + return { message }; +}; +var overrideErrorMap = errorMap; +function getErrorMap() { + return overrideErrorMap; +} +var makeIssue = (params) => { + const { data, path: path3, errorMaps, issueData } = params; + const fullPath = [...path3, ...issueData.path || []]; + const fullIssue = { + ...issueData, + path: fullPath + }; + let errorMessage = ""; + const maps = errorMaps.filter((m) => !!m).slice().reverse(); + for (const map of maps) { + errorMessage = map(fullIssue, { data, defaultError: errorMessage }).message; + } + return { + ...issueData, + path: fullPath, + message: issueData.message || errorMessage + }; +}; +function addIssueToContext(ctx, issueData) { + const issue = makeIssue({ + issueData, + data: ctx.data, + path: ctx.path, + errorMaps: [ + ctx.common.contextualErrorMap, + ctx.schemaErrorMap, + getErrorMap(), + errorMap + // then global default map + ].filter((x) => !!x) + }); + ctx.common.issues.push(issue); +} +var ParseStatus = class _ParseStatus { + constructor() { + this.value = "valid"; + } + dirty() { + if (this.value === "valid") + this.value = "dirty"; + } + abort() { + if (this.value !== "aborted") + this.value = "aborted"; + } + static mergeArray(status, results) { + const arrayValue = []; + for (const s of results) { + if (s.status === "aborted") + return INVALID; + if (s.status === "dirty") + status.dirty(); + arrayValue.push(s.value); + } + return { status: status.value, value: arrayValue }; + } + static async mergeObjectAsync(status, pairs) { + const syncPairs = []; + for (const pair of pairs) { + syncPairs.push({ + key: await pair.key, + value: await pair.value + }); + } + return _ParseStatus.mergeObjectSync(status, syncPairs); + } + static mergeObjectSync(status, pairs) { + const finalObject = {}; + for (const pair of pairs) { + const { key, value } = pair; + if (key.status === "aborted") + return INVALID; + if (value.status === "aborted") + return INVALID; + if (key.status === "dirty") + status.dirty(); + if (value.status === "dirty") + status.dirty(); + if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) { + finalObject[key.value] = value.value; + } + } + return { status: status.value, value: finalObject }; + } +}; +var INVALID = Object.freeze({ + status: "aborted" +}); +var DIRTY = (value) => ({ status: "dirty", value }); +var OK = (value) => ({ status: "valid", value }); +var isAborted = (x) => x.status === "aborted"; +var isDirty = (x) => x.status === "dirty"; +var isValid = (x) => x.status === "valid"; +var isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise; +var errorUtil; +(function(errorUtil2) { + errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {}; + errorUtil2.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message; +})(errorUtil || (errorUtil = {})); +var ParseInputLazyPath = class { + constructor(parent, value, path3, key) { + this._cachedPath = []; + this.parent = parent; + this.data = value; + this._path = path3; + this._key = key; + } + get path() { + if (!this._cachedPath.length) { + if (this._key instanceof Array) { + this._cachedPath.push(...this._path, ...this._key); + } else { + this._cachedPath.push(...this._path, this._key); + } + } + return this._cachedPath; + } +}; +var handleResult = (ctx, result) => { + if (isValid(result)) { + return { success: true, data: result.value }; + } else { + if (!ctx.common.issues.length) { + throw new Error("Validation failed but no issues detected."); + } + return { + success: false, + get error() { + if (this._error) + return this._error; + const error = new ZodError(ctx.common.issues); + this._error = error; + return this._error; + } + }; + } +}; +function processCreateParams(params) { + if (!params) + return {}; + const { errorMap: errorMap2, invalid_type_error, required_error, description } = params; + if (errorMap2 && (invalid_type_error || required_error)) { + throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`); + } + if (errorMap2) + return { errorMap: errorMap2, description }; + const customMap = (iss, ctx) => { + if (iss.code !== "invalid_type") + return { message: ctx.defaultError }; + if (typeof ctx.data === "undefined") { + return { message: required_error !== null && required_error !== void 0 ? required_error : ctx.defaultError }; + } + return { message: invalid_type_error !== null && invalid_type_error !== void 0 ? invalid_type_error : ctx.defaultError }; + }; + return { errorMap: customMap, description }; +} +var ZodType = class { + constructor(def) { + this.spa = this.safeParseAsync; + this._def = def; + this.parse = this.parse.bind(this); + this.safeParse = this.safeParse.bind(this); + this.parseAsync = this.parseAsync.bind(this); + this.safeParseAsync = this.safeParseAsync.bind(this); + this.spa = this.spa.bind(this); + this.refine = this.refine.bind(this); + this.refinement = this.refinement.bind(this); + this.superRefine = this.superRefine.bind(this); + this.optional = this.optional.bind(this); + this.nullable = this.nullable.bind(this); + this.nullish = this.nullish.bind(this); + this.array = this.array.bind(this); + this.promise = this.promise.bind(this); + this.or = this.or.bind(this); + this.and = this.and.bind(this); + this.transform = this.transform.bind(this); + this.brand = this.brand.bind(this); + this.default = this.default.bind(this); + this.catch = this.catch.bind(this); + this.describe = this.describe.bind(this); + this.pipe = this.pipe.bind(this); + this.readonly = this.readonly.bind(this); + this.isNullable = this.isNullable.bind(this); + this.isOptional = this.isOptional.bind(this); + } + get description() { + return this._def.description; + } + _getType(input) { + return getParsedType(input.data); + } + _getOrReturnCtx(input, ctx) { + return ctx || { + common: input.parent.common, + data: input.data, + parsedType: getParsedType(input.data), + schemaErrorMap: this._def.errorMap, + path: input.path, + parent: input.parent + }; + } + _processInputParams(input) { + return { + status: new ParseStatus(), + ctx: { + common: input.parent.common, + data: input.data, + parsedType: getParsedType(input.data), + schemaErrorMap: this._def.errorMap, + path: input.path, + parent: input.parent + } + }; + } + _parseSync(input) { + const result = this._parse(input); + if (isAsync(result)) { + throw new Error("Synchronous parse encountered promise."); + } + return result; + } + _parseAsync(input) { + const result = this._parse(input); + return Promise.resolve(result); + } + parse(data, params) { + const result = this.safeParse(data, params); + if (result.success) + return result.data; + throw result.error; + } + safeParse(data, params) { + var _a; + const ctx = { + common: { + issues: [], + async: (_a = params === null || params === void 0 ? void 0 : params.async) !== null && _a !== void 0 ? _a : false, + contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap + }, + path: (params === null || params === void 0 ? void 0 : params.path) || [], + schemaErrorMap: this._def.errorMap, + parent: null, + data, + parsedType: getParsedType(data) + }; + const result = this._parseSync({ data, path: ctx.path, parent: ctx }); + return handleResult(ctx, result); + } + async parseAsync(data, params) { + const result = await this.safeParseAsync(data, params); + if (result.success) + return result.data; + throw result.error; + } + async safeParseAsync(data, params) { + const ctx = { + common: { + issues: [], + contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap, + async: true + }, + path: (params === null || params === void 0 ? void 0 : params.path) || [], + schemaErrorMap: this._def.errorMap, + parent: null, + data, + parsedType: getParsedType(data) + }; + const maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx }); + const result = await (isAsync(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult)); + return handleResult(ctx, result); + } + refine(check, message) { + const getIssueProperties = (val) => { + if (typeof message === "string" || typeof message === "undefined") { + return { message }; + } else if (typeof message === "function") { + return message(val); + } else { + return message; + } + }; + return this._refinement((val, ctx) => { + const result = check(val); + const setError = () => ctx.addIssue({ + code: ZodIssueCode.custom, + ...getIssueProperties(val) + }); + if (typeof Promise !== "undefined" && result instanceof Promise) { + return result.then((data) => { + if (!data) { + setError(); + return false; + } else { + return true; + } + }); + } + if (!result) { + setError(); + return false; + } else { + return true; + } + }); + } + refinement(check, refinementData) { + return this._refinement((val, ctx) => { + if (!check(val)) { + ctx.addIssue(typeof refinementData === "function" ? refinementData(val, ctx) : refinementData); + return false; + } else { + return true; + } + }); + } + _refinement(refinement) { + return new ZodEffects({ + schema: this, + typeName: ZodFirstPartyTypeKind.ZodEffects, + effect: { type: "refinement", refinement } + }); + } + superRefine(refinement) { + return this._refinement(refinement); + } + optional() { + return ZodOptional.create(this, this._def); + } + nullable() { + return ZodNullable.create(this, this._def); + } + nullish() { + return this.nullable().optional(); + } + array() { + return ZodArray.create(this, this._def); + } + promise() { + return ZodPromise.create(this, this._def); + } + or(option) { + return ZodUnion.create([this, option], this._def); + } + and(incoming) { + return ZodIntersection.create(this, incoming, this._def); + } + transform(transform) { + return new ZodEffects({ + ...processCreateParams(this._def), + schema: this, + typeName: ZodFirstPartyTypeKind.ZodEffects, + effect: { type: "transform", transform } + }); + } + default(def) { + const defaultValueFunc = typeof def === "function" ? def : () => def; + return new ZodDefault({ + ...processCreateParams(this._def), + innerType: this, + defaultValue: defaultValueFunc, + typeName: ZodFirstPartyTypeKind.ZodDefault + }); + } + brand() { + return new ZodBranded({ + typeName: ZodFirstPartyTypeKind.ZodBranded, + type: this, + ...processCreateParams(this._def) + }); + } + catch(def) { + const catchValueFunc = typeof def === "function" ? def : () => def; + return new ZodCatch({ + ...processCreateParams(this._def), + innerType: this, + catchValue: catchValueFunc, + typeName: ZodFirstPartyTypeKind.ZodCatch + }); + } + describe(description) { + const This = this.constructor; + return new This({ + ...this._def, + description + }); + } + pipe(target) { + return ZodPipeline.create(this, target); + } + readonly() { + return ZodReadonly.create(this); + } + isOptional() { + return this.safeParse(void 0).success; + } + isNullable() { + return this.safeParse(null).success; + } +}; +var cuidRegex = /^c[^\s-]{8,}$/i; +var cuid2Regex = /^[a-z][a-z0-9]*$/; +var ulidRegex = /[0-9A-HJKMNP-TV-Z]{26}/; +var uuidRegex = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i; +var emailRegex = /^([A-Z0-9_+-]+\.?)*[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i; +var emojiRegex = /^(\p{Extended_Pictographic}|\p{Emoji_Component})+$/u; +var ipv4Regex = /^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/; +var ipv6Regex = /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/; +var datetimeRegex = (args) => { + if (args.precision) { + if (args.offset) { + return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`); + } else { + return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}Z$`); + } + } else if (args.precision === 0) { + if (args.offset) { + return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$`); + } else { + return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$`); + } + } else { + if (args.offset) { + return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$`); + } else { + return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$`); + } + } +}; +function isValidIP(ip, version2) { + if ((version2 === "v4" || !version2) && ipv4Regex.test(ip)) { + return true; + } + if ((version2 === "v6" || !version2) && ipv6Regex.test(ip)) { + return true; + } + return false; +} +var ZodString = class _ZodString extends ZodType { + constructor() { + super(...arguments); + this._regex = (regex, validation, message) => this.refinement((data) => regex.test(data), { + validation, + code: ZodIssueCode.invalid_string, + ...errorUtil.errToObj(message) + }); + this.nonempty = (message) => this.min(1, errorUtil.errToObj(message)); + this.trim = () => new _ZodString({ + ...this._def, + checks: [...this._def.checks, { kind: "trim" }] + }); + this.toLowerCase = () => new _ZodString({ + ...this._def, + checks: [...this._def.checks, { kind: "toLowerCase" }] + }); + this.toUpperCase = () => new _ZodString({ + ...this._def, + checks: [...this._def.checks, { kind: "toUpperCase" }] + }); + } + _parse(input) { + if (this._def.coerce) { + input.data = String(input.data); + } + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType.string) { + const ctx2 = this._getOrReturnCtx(input); + addIssueToContext( + ctx2, + { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.string, + received: ctx2.parsedType + } + // + ); + return INVALID; + } + const status = new ParseStatus(); + let ctx = void 0; + for (const check of this._def.checks) { + if (check.kind === "min") { + if (input.data.length < check.value) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.too_small, + minimum: check.value, + type: "string", + inclusive: true, + exact: false, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "max") { + if (input.data.length > check.value) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.too_big, + maximum: check.value, + type: "string", + inclusive: true, + exact: false, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "length") { + const tooBig = input.data.length > check.value; + const tooSmall = input.data.length < check.value; + if (tooBig || tooSmall) { + ctx = this._getOrReturnCtx(input, ctx); + if (tooBig) { + addIssueToContext(ctx, { + code: ZodIssueCode.too_big, + maximum: check.value, + type: "string", + inclusive: true, + exact: true, + message: check.message + }); + } else if (tooSmall) { + addIssueToContext(ctx, { + code: ZodIssueCode.too_small, + minimum: check.value, + type: "string", + inclusive: true, + exact: true, + message: check.message + }); + } + status.dirty(); + } + } else if (check.kind === "email") { + if (!emailRegex.test(input.data)) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + validation: "email", + code: ZodIssueCode.invalid_string, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "emoji") { + if (!emojiRegex.test(input.data)) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + validation: "emoji", + code: ZodIssueCode.invalid_string, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "uuid") { + if (!uuidRegex.test(input.data)) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + validation: "uuid", + code: ZodIssueCode.invalid_string, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "cuid") { + if (!cuidRegex.test(input.data)) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + validation: "cuid", + code: ZodIssueCode.invalid_string, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "cuid2") { + if (!cuid2Regex.test(input.data)) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + validation: "cuid2", + code: ZodIssueCode.invalid_string, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "ulid") { + if (!ulidRegex.test(input.data)) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + validation: "ulid", + code: ZodIssueCode.invalid_string, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "url") { + try { + new URL(input.data); + } catch (_a) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + validation: "url", + code: ZodIssueCode.invalid_string, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "regex") { + check.regex.lastIndex = 0; + const testResult = check.regex.test(input.data); + if (!testResult) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + validation: "regex", + code: ZodIssueCode.invalid_string, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "trim") { + input.data = input.data.trim(); + } else if (check.kind === "includes") { + if (!input.data.includes(check.value, check.position)) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_string, + validation: { includes: check.value, position: check.position }, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "toLowerCase") { + input.data = input.data.toLowerCase(); + } else if (check.kind === "toUpperCase") { + input.data = input.data.toUpperCase(); + } else if (check.kind === "startsWith") { + if (!input.data.startsWith(check.value)) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_string, + validation: { startsWith: check.value }, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "endsWith") { + if (!input.data.endsWith(check.value)) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_string, + validation: { endsWith: check.value }, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "datetime") { + const regex = datetimeRegex(check); + if (!regex.test(input.data)) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_string, + validation: "datetime", + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "ip") { + if (!isValidIP(input.data, check.version)) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + validation: "ip", + code: ZodIssueCode.invalid_string, + message: check.message + }); + status.dirty(); + } + } else { + util.assertNever(check); + } + } + return { status: status.value, value: input.data }; + } + _addCheck(check) { + return new _ZodString({ + ...this._def, + checks: [...this._def.checks, check] + }); + } + email(message) { + return this._addCheck({ kind: "email", ...errorUtil.errToObj(message) }); + } + url(message) { + return this._addCheck({ kind: "url", ...errorUtil.errToObj(message) }); + } + emoji(message) { + return this._addCheck({ kind: "emoji", ...errorUtil.errToObj(message) }); + } + uuid(message) { + return this._addCheck({ kind: "uuid", ...errorUtil.errToObj(message) }); + } + cuid(message) { + return this._addCheck({ kind: "cuid", ...errorUtil.errToObj(message) }); + } + cuid2(message) { + return this._addCheck({ kind: "cuid2", ...errorUtil.errToObj(message) }); + } + ulid(message) { + return this._addCheck({ kind: "ulid", ...errorUtil.errToObj(message) }); + } + ip(options2) { + return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options2) }); + } + datetime(options2) { + var _a; + if (typeof options2 === "string") { + return this._addCheck({ + kind: "datetime", + precision: null, + offset: false, + message: options2 + }); + } + return this._addCheck({ + kind: "datetime", + precision: typeof (options2 === null || options2 === void 0 ? void 0 : options2.precision) === "undefined" ? null : options2 === null || options2 === void 0 ? void 0 : options2.precision, + offset: (_a = options2 === null || options2 === void 0 ? void 0 : options2.offset) !== null && _a !== void 0 ? _a : false, + ...errorUtil.errToObj(options2 === null || options2 === void 0 ? void 0 : options2.message) + }); + } + regex(regex, message) { + return this._addCheck({ + kind: "regex", + regex, + ...errorUtil.errToObj(message) + }); + } + includes(value, options2) { + return this._addCheck({ + kind: "includes", + value, + position: options2 === null || options2 === void 0 ? void 0 : options2.position, + ...errorUtil.errToObj(options2 === null || options2 === void 0 ? void 0 : options2.message) + }); + } + startsWith(value, message) { + return this._addCheck({ + kind: "startsWith", + value, + ...errorUtil.errToObj(message) + }); + } + endsWith(value, message) { + return this._addCheck({ + kind: "endsWith", + value, + ...errorUtil.errToObj(message) + }); + } + min(minLength, message) { + return this._addCheck({ + kind: "min", + value: minLength, + ...errorUtil.errToObj(message) + }); + } + max(maxLength, message) { + return this._addCheck({ + kind: "max", + value: maxLength, + ...errorUtil.errToObj(message) + }); + } + length(len, message) { + return this._addCheck({ + kind: "length", + value: len, + ...errorUtil.errToObj(message) + }); + } + get isDatetime() { + return !!this._def.checks.find((ch) => ch.kind === "datetime"); + } + get isEmail() { + return !!this._def.checks.find((ch) => ch.kind === "email"); + } + get isURL() { + return !!this._def.checks.find((ch) => ch.kind === "url"); + } + get isEmoji() { + return !!this._def.checks.find((ch) => ch.kind === "emoji"); + } + get isUUID() { + return !!this._def.checks.find((ch) => ch.kind === "uuid"); + } + get isCUID() { + return !!this._def.checks.find((ch) => ch.kind === "cuid"); + } + get isCUID2() { + return !!this._def.checks.find((ch) => ch.kind === "cuid2"); + } + get isULID() { + return !!this._def.checks.find((ch) => ch.kind === "ulid"); + } + get isIP() { + return !!this._def.checks.find((ch) => ch.kind === "ip"); + } + get minLength() { + let min = null; + for (const ch of this._def.checks) { + if (ch.kind === "min") { + if (min === null || ch.value > min) + min = ch.value; + } + } + return min; + } + get maxLength() { + let max = null; + for (const ch of this._def.checks) { + if (ch.kind === "max") { + if (max === null || ch.value < max) + max = ch.value; + } + } + return max; + } +}; +ZodString.create = (params) => { + var _a; + return new ZodString({ + checks: [], + typeName: ZodFirstPartyTypeKind.ZodString, + coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false, + ...processCreateParams(params) + }); +}; +function floatSafeRemainder(val, step) { + const valDecCount = (val.toString().split(".")[1] || "").length; + const stepDecCount = (step.toString().split(".")[1] || "").length; + const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount; + const valInt = parseInt(val.toFixed(decCount).replace(".", "")); + const stepInt = parseInt(step.toFixed(decCount).replace(".", "")); + return valInt % stepInt / Math.pow(10, decCount); +} +var ZodNumber = class _ZodNumber extends ZodType { + constructor() { + super(...arguments); + this.min = this.gte; + this.max = this.lte; + this.step = this.multipleOf; + } + _parse(input) { + if (this._def.coerce) { + input.data = Number(input.data); + } + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType.number) { + const ctx2 = this._getOrReturnCtx(input); + addIssueToContext(ctx2, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.number, + received: ctx2.parsedType + }); + return INVALID; + } + let ctx = void 0; + const status = new ParseStatus(); + for (const check of this._def.checks) { + if (check.kind === "int") { + if (!util.isInteger(input.data)) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: "integer", + received: "float", + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "min") { + const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value; + if (tooSmall) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.too_small, + minimum: check.value, + type: "number", + inclusive: check.inclusive, + exact: false, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "max") { + const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value; + if (tooBig) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.too_big, + maximum: check.value, + type: "number", + inclusive: check.inclusive, + exact: false, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "multipleOf") { + if (floatSafeRemainder(input.data, check.value) !== 0) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.not_multiple_of, + multipleOf: check.value, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "finite") { + if (!Number.isFinite(input.data)) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.not_finite, + message: check.message + }); + status.dirty(); + } + } else { + util.assertNever(check); + } + } + return { status: status.value, value: input.data }; + } + gte(value, message) { + return this.setLimit("min", value, true, errorUtil.toString(message)); + } + gt(value, message) { + return this.setLimit("min", value, false, errorUtil.toString(message)); + } + lte(value, message) { + return this.setLimit("max", value, true, errorUtil.toString(message)); + } + lt(value, message) { + return this.setLimit("max", value, false, errorUtil.toString(message)); + } + setLimit(kind, value, inclusive, message) { + return new _ZodNumber({ + ...this._def, + checks: [ + ...this._def.checks, + { + kind, + value, + inclusive, + message: errorUtil.toString(message) + } + ] + }); + } + _addCheck(check) { + return new _ZodNumber({ + ...this._def, + checks: [...this._def.checks, check] + }); + } + int(message) { + return this._addCheck({ + kind: "int", + message: errorUtil.toString(message) + }); + } + positive(message) { + return this._addCheck({ + kind: "min", + value: 0, + inclusive: false, + message: errorUtil.toString(message) + }); + } + negative(message) { + return this._addCheck({ + kind: "max", + value: 0, + inclusive: false, + message: errorUtil.toString(message) + }); + } + nonpositive(message) { + return this._addCheck({ + kind: "max", + value: 0, + inclusive: true, + message: errorUtil.toString(message) + }); + } + nonnegative(message) { + return this._addCheck({ + kind: "min", + value: 0, + inclusive: true, + message: errorUtil.toString(message) + }); + } + multipleOf(value, message) { + return this._addCheck({ + kind: "multipleOf", + value, + message: errorUtil.toString(message) + }); + } + finite(message) { + return this._addCheck({ + kind: "finite", + message: errorUtil.toString(message) + }); + } + safe(message) { + return this._addCheck({ + kind: "min", + inclusive: true, + value: Number.MIN_SAFE_INTEGER, + message: errorUtil.toString(message) + })._addCheck({ + kind: "max", + inclusive: true, + value: Number.MAX_SAFE_INTEGER, + message: errorUtil.toString(message) + }); + } + get minValue() { + let min = null; + for (const ch of this._def.checks) { + if (ch.kind === "min") { + if (min === null || ch.value > min) + min = ch.value; + } + } + return min; + } + get maxValue() { + let max = null; + for (const ch of this._def.checks) { + if (ch.kind === "max") { + if (max === null || ch.value < max) + max = ch.value; + } + } + return max; + } + get isInt() { + return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util.isInteger(ch.value)); + } + get isFinite() { + let max = null, min = null; + for (const ch of this._def.checks) { + if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") { + return true; + } else if (ch.kind === "min") { + if (min === null || ch.value > min) + min = ch.value; + } else if (ch.kind === "max") { + if (max === null || ch.value < max) + max = ch.value; + } + } + return Number.isFinite(min) && Number.isFinite(max); + } +}; +ZodNumber.create = (params) => { + return new ZodNumber({ + checks: [], + typeName: ZodFirstPartyTypeKind.ZodNumber, + coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false, + ...processCreateParams(params) + }); +}; +var ZodBigInt = class _ZodBigInt extends ZodType { + constructor() { + super(...arguments); + this.min = this.gte; + this.max = this.lte; + } + _parse(input) { + if (this._def.coerce) { + input.data = BigInt(input.data); + } + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType.bigint) { + const ctx2 = this._getOrReturnCtx(input); + addIssueToContext(ctx2, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.bigint, + received: ctx2.parsedType + }); + return INVALID; + } + let ctx = void 0; + const status = new ParseStatus(); + for (const check of this._def.checks) { + if (check.kind === "min") { + const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value; + if (tooSmall) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.too_small, + type: "bigint", + minimum: check.value, + inclusive: check.inclusive, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "max") { + const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value; + if (tooBig) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.too_big, + type: "bigint", + maximum: check.value, + inclusive: check.inclusive, + message: check.message + }); + status.dirty(); + } + } else if (check.kind === "multipleOf") { + if (input.data % check.value !== BigInt(0)) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.not_multiple_of, + multipleOf: check.value, + message: check.message + }); + status.dirty(); + } + } else { + util.assertNever(check); + } + } + return { status: status.value, value: input.data }; + } + gte(value, message) { + return this.setLimit("min", value, true, errorUtil.toString(message)); + } + gt(value, message) { + return this.setLimit("min", value, false, errorUtil.toString(message)); + } + lte(value, message) { + return this.setLimit("max", value, true, errorUtil.toString(message)); + } + lt(value, message) { + return this.setLimit("max", value, false, errorUtil.toString(message)); + } + setLimit(kind, value, inclusive, message) { + return new _ZodBigInt({ + ...this._def, + checks: [ + ...this._def.checks, + { + kind, + value, + inclusive, + message: errorUtil.toString(message) + } + ] + }); + } + _addCheck(check) { + return new _ZodBigInt({ + ...this._def, + checks: [...this._def.checks, check] + }); + } + positive(message) { + return this._addCheck({ + kind: "min", + value: BigInt(0), + inclusive: false, + message: errorUtil.toString(message) + }); + } + negative(message) { + return this._addCheck({ + kind: "max", + value: BigInt(0), + inclusive: false, + message: errorUtil.toString(message) + }); + } + nonpositive(message) { + return this._addCheck({ + kind: "max", + value: BigInt(0), + inclusive: true, + message: errorUtil.toString(message) + }); + } + nonnegative(message) { + return this._addCheck({ + kind: "min", + value: BigInt(0), + inclusive: true, + message: errorUtil.toString(message) + }); + } + multipleOf(value, message) { + return this._addCheck({ + kind: "multipleOf", + value, + message: errorUtil.toString(message) + }); + } + get minValue() { + let min = null; + for (const ch of this._def.checks) { + if (ch.kind === "min") { + if (min === null || ch.value > min) + min = ch.value; + } + } + return min; + } + get maxValue() { + let max = null; + for (const ch of this._def.checks) { + if (ch.kind === "max") { + if (max === null || ch.value < max) + max = ch.value; + } + } + return max; + } +}; +ZodBigInt.create = (params) => { + var _a; + return new ZodBigInt({ + checks: [], + typeName: ZodFirstPartyTypeKind.ZodBigInt, + coerce: (_a = params === null || params === void 0 ? void 0 : params.coerce) !== null && _a !== void 0 ? _a : false, + ...processCreateParams(params) + }); +}; +var ZodBoolean = class extends ZodType { + _parse(input) { + if (this._def.coerce) { + input.data = Boolean(input.data); + } + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType.boolean) { + const ctx = this._getOrReturnCtx(input); + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.boolean, + received: ctx.parsedType + }); + return INVALID; + } + return OK(input.data); + } +}; +ZodBoolean.create = (params) => { + return new ZodBoolean({ + typeName: ZodFirstPartyTypeKind.ZodBoolean, + coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false, + ...processCreateParams(params) + }); +}; +var ZodDate = class _ZodDate extends ZodType { + _parse(input) { + if (this._def.coerce) { + input.data = new Date(input.data); + } + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType.date) { + const ctx2 = this._getOrReturnCtx(input); + addIssueToContext(ctx2, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.date, + received: ctx2.parsedType + }); + return INVALID; + } + if (isNaN(input.data.getTime())) { + const ctx2 = this._getOrReturnCtx(input); + addIssueToContext(ctx2, { + code: ZodIssueCode.invalid_date + }); + return INVALID; + } + const status = new ParseStatus(); + let ctx = void 0; + for (const check of this._def.checks) { + if (check.kind === "min") { + if (input.data.getTime() < check.value) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.too_small, + message: check.message, + inclusive: true, + exact: false, + minimum: check.value, + type: "date" + }); + status.dirty(); + } + } else if (check.kind === "max") { + if (input.data.getTime() > check.value) { + ctx = this._getOrReturnCtx(input, ctx); + addIssueToContext(ctx, { + code: ZodIssueCode.too_big, + message: check.message, + inclusive: true, + exact: false, + maximum: check.value, + type: "date" + }); + status.dirty(); + } + } else { + util.assertNever(check); + } + } + return { + status: status.value, + value: new Date(input.data.getTime()) + }; + } + _addCheck(check) { + return new _ZodDate({ + ...this._def, + checks: [...this._def.checks, check] + }); + } + min(minDate, message) { + return this._addCheck({ + kind: "min", + value: minDate.getTime(), + message: errorUtil.toString(message) + }); + } + max(maxDate, message) { + return this._addCheck({ + kind: "max", + value: maxDate.getTime(), + message: errorUtil.toString(message) + }); + } + get minDate() { + let min = null; + for (const ch of this._def.checks) { + if (ch.kind === "min") { + if (min === null || ch.value > min) + min = ch.value; + } + } + return min != null ? new Date(min) : null; + } + get maxDate() { + let max = null; + for (const ch of this._def.checks) { + if (ch.kind === "max") { + if (max === null || ch.value < max) + max = ch.value; + } + } + return max != null ? new Date(max) : null; + } +}; +ZodDate.create = (params) => { + return new ZodDate({ + checks: [], + coerce: (params === null || params === void 0 ? void 0 : params.coerce) || false, + typeName: ZodFirstPartyTypeKind.ZodDate, + ...processCreateParams(params) + }); +}; +var ZodSymbol = class extends ZodType { + _parse(input) { + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType.symbol) { + const ctx = this._getOrReturnCtx(input); + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.symbol, + received: ctx.parsedType + }); + return INVALID; + } + return OK(input.data); + } +}; +ZodSymbol.create = (params) => { + return new ZodSymbol({ + typeName: ZodFirstPartyTypeKind.ZodSymbol, + ...processCreateParams(params) + }); +}; +var ZodUndefined = class extends ZodType { + _parse(input) { + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType.undefined) { + const ctx = this._getOrReturnCtx(input); + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.undefined, + received: ctx.parsedType + }); + return INVALID; + } + return OK(input.data); + } +}; +ZodUndefined.create = (params) => { + return new ZodUndefined({ + typeName: ZodFirstPartyTypeKind.ZodUndefined, + ...processCreateParams(params) + }); +}; +var ZodNull = class extends ZodType { + _parse(input) { + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType.null) { + const ctx = this._getOrReturnCtx(input); + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.null, + received: ctx.parsedType + }); + return INVALID; + } + return OK(input.data); + } +}; +ZodNull.create = (params) => { + return new ZodNull({ + typeName: ZodFirstPartyTypeKind.ZodNull, + ...processCreateParams(params) + }); +}; +var ZodAny = class extends ZodType { + constructor() { + super(...arguments); + this._any = true; + } + _parse(input) { + return OK(input.data); + } +}; +ZodAny.create = (params) => { + return new ZodAny({ + typeName: ZodFirstPartyTypeKind.ZodAny, + ...processCreateParams(params) + }); +}; +var ZodUnknown = class extends ZodType { + constructor() { + super(...arguments); + this._unknown = true; + } + _parse(input) { + return OK(input.data); + } +}; +ZodUnknown.create = (params) => { + return new ZodUnknown({ + typeName: ZodFirstPartyTypeKind.ZodUnknown, + ...processCreateParams(params) + }); +}; +var ZodNever = class extends ZodType { + _parse(input) { + const ctx = this._getOrReturnCtx(input); + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.never, + received: ctx.parsedType + }); + return INVALID; + } +}; +ZodNever.create = (params) => { + return new ZodNever({ + typeName: ZodFirstPartyTypeKind.ZodNever, + ...processCreateParams(params) + }); +}; +var ZodVoid = class extends ZodType { + _parse(input) { + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType.undefined) { + const ctx = this._getOrReturnCtx(input); + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.void, + received: ctx.parsedType + }); + return INVALID; + } + return OK(input.data); + } +}; +ZodVoid.create = (params) => { + return new ZodVoid({ + typeName: ZodFirstPartyTypeKind.ZodVoid, + ...processCreateParams(params) + }); +}; +var ZodArray = class _ZodArray extends ZodType { + _parse(input) { + const { ctx, status } = this._processInputParams(input); + const def = this._def; + if (ctx.parsedType !== ZodParsedType.array) { + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.array, + received: ctx.parsedType + }); + return INVALID; + } + if (def.exactLength !== null) { + const tooBig = ctx.data.length > def.exactLength.value; + const tooSmall = ctx.data.length < def.exactLength.value; + if (tooBig || tooSmall) { + addIssueToContext(ctx, { + code: tooBig ? ZodIssueCode.too_big : ZodIssueCode.too_small, + minimum: tooSmall ? def.exactLength.value : void 0, + maximum: tooBig ? def.exactLength.value : void 0, + type: "array", + inclusive: true, + exact: true, + message: def.exactLength.message + }); + status.dirty(); + } + } + if (def.minLength !== null) { + if (ctx.data.length < def.minLength.value) { + addIssueToContext(ctx, { + code: ZodIssueCode.too_small, + minimum: def.minLength.value, + type: "array", + inclusive: true, + exact: false, + message: def.minLength.message + }); + status.dirty(); + } + } + if (def.maxLength !== null) { + if (ctx.data.length > def.maxLength.value) { + addIssueToContext(ctx, { + code: ZodIssueCode.too_big, + maximum: def.maxLength.value, + type: "array", + inclusive: true, + exact: false, + message: def.maxLength.message + }); + status.dirty(); + } + } + if (ctx.common.async) { + return Promise.all([...ctx.data].map((item, i) => { + return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i)); + })).then((result2) => { + return ParseStatus.mergeArray(status, result2); + }); + } + const result = [...ctx.data].map((item, i) => { + return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i)); + }); + return ParseStatus.mergeArray(status, result); + } + get element() { + return this._def.type; + } + min(minLength, message) { + return new _ZodArray({ + ...this._def, + minLength: { value: minLength, message: errorUtil.toString(message) } + }); + } + max(maxLength, message) { + return new _ZodArray({ + ...this._def, + maxLength: { value: maxLength, message: errorUtil.toString(message) } + }); + } + length(len, message) { + return new _ZodArray({ + ...this._def, + exactLength: { value: len, message: errorUtil.toString(message) } + }); + } + nonempty(message) { + return this.min(1, message); + } +}; +ZodArray.create = (schema, params) => { + return new ZodArray({ + type: schema, + minLength: null, + maxLength: null, + exactLength: null, + typeName: ZodFirstPartyTypeKind.ZodArray, + ...processCreateParams(params) + }); +}; +function deepPartialify(schema) { + if (schema instanceof ZodObject) { + const newShape = {}; + for (const key in schema.shape) { + const fieldSchema = schema.shape[key]; + newShape[key] = ZodOptional.create(deepPartialify(fieldSchema)); + } + return new ZodObject({ + ...schema._def, + shape: () => newShape + }); + } else if (schema instanceof ZodArray) { + return new ZodArray({ + ...schema._def, + type: deepPartialify(schema.element) + }); + } else if (schema instanceof ZodOptional) { + return ZodOptional.create(deepPartialify(schema.unwrap())); + } else if (schema instanceof ZodNullable) { + return ZodNullable.create(deepPartialify(schema.unwrap())); + } else if (schema instanceof ZodTuple) { + return ZodTuple.create(schema.items.map((item) => deepPartialify(item))); + } else { + return schema; + } +} +var ZodObject = class _ZodObject extends ZodType { + constructor() { + super(...arguments); + this._cached = null; + this.nonstrict = this.passthrough; + this.augment = this.extend; + } + _getCached() { + if (this._cached !== null) + return this._cached; + const shape = this._def.shape(); + const keys = util.objectKeys(shape); + return this._cached = { shape, keys }; + } + _parse(input) { + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType.object) { + const ctx2 = this._getOrReturnCtx(input); + addIssueToContext(ctx2, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.object, + received: ctx2.parsedType + }); + return INVALID; + } + const { status, ctx } = this._processInputParams(input); + const { shape, keys: shapeKeys } = this._getCached(); + const extraKeys = []; + if (!(this._def.catchall instanceof ZodNever && this._def.unknownKeys === "strip")) { + for (const key in ctx.data) { + if (!shapeKeys.includes(key)) { + extraKeys.push(key); + } + } + } + const pairs = []; + for (const key of shapeKeys) { + const keyValidator = shape[key]; + const value = ctx.data[key]; + pairs.push({ + key: { status: "valid", value: key }, + value: keyValidator._parse(new ParseInputLazyPath(ctx, value, ctx.path, key)), + alwaysSet: key in ctx.data + }); + } + if (this._def.catchall instanceof ZodNever) { + const unknownKeys = this._def.unknownKeys; + if (unknownKeys === "passthrough") { + for (const key of extraKeys) { + pairs.push({ + key: { status: "valid", value: key }, + value: { status: "valid", value: ctx.data[key] } + }); + } + } else if (unknownKeys === "strict") { + if (extraKeys.length > 0) { + addIssueToContext(ctx, { + code: ZodIssueCode.unrecognized_keys, + keys: extraKeys + }); + status.dirty(); + } + } else if (unknownKeys === "strip") + ; + else { + throw new Error(`Internal ZodObject error: invalid unknownKeys value.`); + } + } else { + const catchall = this._def.catchall; + for (const key of extraKeys) { + const value = ctx.data[key]; + pairs.push({ + key: { status: "valid", value: key }, + value: catchall._parse( + new ParseInputLazyPath(ctx, value, ctx.path, key) + //, ctx.child(key), value, getParsedType(value) + ), + alwaysSet: key in ctx.data + }); + } + } + if (ctx.common.async) { + return Promise.resolve().then(async () => { + const syncPairs = []; + for (const pair of pairs) { + const key = await pair.key; + syncPairs.push({ + key, + value: await pair.value, + alwaysSet: pair.alwaysSet + }); + } + return syncPairs; + }).then((syncPairs) => { + return ParseStatus.mergeObjectSync(status, syncPairs); + }); + } else { + return ParseStatus.mergeObjectSync(status, pairs); + } + } + get shape() { + return this._def.shape(); + } + strict(message) { + errorUtil.errToObj; + return new _ZodObject({ + ...this._def, + unknownKeys: "strict", + ...message !== void 0 ? { + errorMap: (issue, ctx) => { + var _a, _b, _c, _d; + const defaultError = (_c = (_b = (_a = this._def).errorMap) === null || _b === void 0 ? void 0 : _b.call(_a, issue, ctx).message) !== null && _c !== void 0 ? _c : ctx.defaultError; + if (issue.code === "unrecognized_keys") + return { + message: (_d = errorUtil.errToObj(message).message) !== null && _d !== void 0 ? _d : defaultError + }; + return { + message: defaultError + }; + } + } : {} + }); + } + strip() { + return new _ZodObject({ + ...this._def, + unknownKeys: "strip" + }); + } + passthrough() { + return new _ZodObject({ + ...this._def, + unknownKeys: "passthrough" + }); + } + // const AugmentFactory = + // (def: Def) => + // ( + // augmentation: Augmentation + // ): ZodObject< + // extendShape, Augmentation>, + // Def["unknownKeys"], + // Def["catchall"] + // > => { + // return new ZodObject({ + // ...def, + // shape: () => ({ + // ...def.shape(), + // ...augmentation, + // }), + // }) as any; + // }; + extend(augmentation) { + return new _ZodObject({ + ...this._def, + shape: () => ({ + ...this._def.shape(), + ...augmentation + }) + }); + } + /** + * Prior to zod@1.0.12 there was a bug in the + * inferred type of merged objects. Please + * upgrade if you are experiencing issues. + */ + merge(merging) { + const merged = new _ZodObject({ + unknownKeys: merging._def.unknownKeys, + catchall: merging._def.catchall, + shape: () => ({ + ...this._def.shape(), + ...merging._def.shape() + }), + typeName: ZodFirstPartyTypeKind.ZodObject + }); + return merged; + } + // merge< + // Incoming extends AnyZodObject, + // Augmentation extends Incoming["shape"], + // NewOutput extends { + // [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation + // ? Augmentation[k]["_output"] + // : k extends keyof Output + // ? Output[k] + // : never; + // }, + // NewInput extends { + // [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation + // ? Augmentation[k]["_input"] + // : k extends keyof Input + // ? Input[k] + // : never; + // } + // >( + // merging: Incoming + // ): ZodObject< + // extendShape>, + // Incoming["_def"]["unknownKeys"], + // Incoming["_def"]["catchall"], + // NewOutput, + // NewInput + // > { + // const merged: any = new ZodObject({ + // unknownKeys: merging._def.unknownKeys, + // catchall: merging._def.catchall, + // shape: () => + // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()), + // typeName: ZodFirstPartyTypeKind.ZodObject, + // }) as any; + // return merged; + // } + setKey(key, schema) { + return this.augment({ [key]: schema }); + } + // merge( + // merging: Incoming + // ): //ZodObject = (merging) => { + // ZodObject< + // extendShape>, + // Incoming["_def"]["unknownKeys"], + // Incoming["_def"]["catchall"] + // > { + // // const mergedShape = objectUtil.mergeShapes( + // // this._def.shape(), + // // merging._def.shape() + // // ); + // const merged: any = new ZodObject({ + // unknownKeys: merging._def.unknownKeys, + // catchall: merging._def.catchall, + // shape: () => + // objectUtil.mergeShapes(this._def.shape(), merging._def.shape()), + // typeName: ZodFirstPartyTypeKind.ZodObject, + // }) as any; + // return merged; + // } + catchall(index) { + return new _ZodObject({ + ...this._def, + catchall: index + }); + } + pick(mask) { + const shape = {}; + util.objectKeys(mask).forEach((key) => { + if (mask[key] && this.shape[key]) { + shape[key] = this.shape[key]; + } + }); + return new _ZodObject({ + ...this._def, + shape: () => shape + }); + } + omit(mask) { + const shape = {}; + util.objectKeys(this.shape).forEach((key) => { + if (!mask[key]) { + shape[key] = this.shape[key]; + } + }); + return new _ZodObject({ + ...this._def, + shape: () => shape + }); + } + /** + * @deprecated + */ + deepPartial() { + return deepPartialify(this); + } + partial(mask) { + const newShape = {}; + util.objectKeys(this.shape).forEach((key) => { + const fieldSchema = this.shape[key]; + if (mask && !mask[key]) { + newShape[key] = fieldSchema; + } else { + newShape[key] = fieldSchema.optional(); + } + }); + return new _ZodObject({ + ...this._def, + shape: () => newShape + }); + } + required(mask) { + const newShape = {}; + util.objectKeys(this.shape).forEach((key) => { + if (mask && !mask[key]) { + newShape[key] = this.shape[key]; + } else { + const fieldSchema = this.shape[key]; + let newField = fieldSchema; + while (newField instanceof ZodOptional) { + newField = newField._def.innerType; + } + newShape[key] = newField; + } + }); + return new _ZodObject({ + ...this._def, + shape: () => newShape + }); + } + keyof() { + return createZodEnum(util.objectKeys(this.shape)); + } +}; +ZodObject.create = (shape, params) => { + return new ZodObject({ + shape: () => shape, + unknownKeys: "strip", + catchall: ZodNever.create(), + typeName: ZodFirstPartyTypeKind.ZodObject, + ...processCreateParams(params) + }); +}; +ZodObject.strictCreate = (shape, params) => { + return new ZodObject({ + shape: () => shape, + unknownKeys: "strict", + catchall: ZodNever.create(), + typeName: ZodFirstPartyTypeKind.ZodObject, + ...processCreateParams(params) + }); +}; +ZodObject.lazycreate = (shape, params) => { + return new ZodObject({ + shape, + unknownKeys: "strip", + catchall: ZodNever.create(), + typeName: ZodFirstPartyTypeKind.ZodObject, + ...processCreateParams(params) + }); +}; +var ZodUnion = class extends ZodType { + _parse(input) { + const { ctx } = this._processInputParams(input); + const options2 = this._def.options; + function handleResults(results) { + for (const result of results) { + if (result.result.status === "valid") { + return result.result; + } + } + for (const result of results) { + if (result.result.status === "dirty") { + ctx.common.issues.push(...result.ctx.common.issues); + return result.result; + } + } + const unionErrors = results.map((result) => new ZodError(result.ctx.common.issues)); + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_union, + unionErrors + }); + return INVALID; + } + if (ctx.common.async) { + return Promise.all(options2.map(async (option) => { + const childCtx = { + ...ctx, + common: { + ...ctx.common, + issues: [] + }, + parent: null + }; + return { + result: await option._parseAsync({ + data: ctx.data, + path: ctx.path, + parent: childCtx + }), + ctx: childCtx + }; + })).then(handleResults); + } else { + let dirty = void 0; + const issues = []; + for (const option of options2) { + const childCtx = { + ...ctx, + common: { + ...ctx.common, + issues: [] + }, + parent: null + }; + const result = option._parseSync({ + data: ctx.data, + path: ctx.path, + parent: childCtx + }); + if (result.status === "valid") { + return result; + } else if (result.status === "dirty" && !dirty) { + dirty = { result, ctx: childCtx }; + } + if (childCtx.common.issues.length) { + issues.push(childCtx.common.issues); + } + } + if (dirty) { + ctx.common.issues.push(...dirty.ctx.common.issues); + return dirty.result; + } + const unionErrors = issues.map((issues2) => new ZodError(issues2)); + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_union, + unionErrors + }); + return INVALID; + } + } + get options() { + return this._def.options; + } +}; +ZodUnion.create = (types, params) => { + return new ZodUnion({ + options: types, + typeName: ZodFirstPartyTypeKind.ZodUnion, + ...processCreateParams(params) + }); +}; +var getDiscriminator = (type) => { + if (type instanceof ZodLazy) { + return getDiscriminator(type.schema); + } else if (type instanceof ZodEffects) { + return getDiscriminator(type.innerType()); + } else if (type instanceof ZodLiteral) { + return [type.value]; + } else if (type instanceof ZodEnum) { + return type.options; + } else if (type instanceof ZodNativeEnum) { + return Object.keys(type.enum); + } else if (type instanceof ZodDefault) { + return getDiscriminator(type._def.innerType); + } else if (type instanceof ZodUndefined) { + return [void 0]; + } else if (type instanceof ZodNull) { + return [null]; + } else { + return null; + } +}; +var ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType { + _parse(input) { + const { ctx } = this._processInputParams(input); + if (ctx.parsedType !== ZodParsedType.object) { + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.object, + received: ctx.parsedType + }); + return INVALID; + } + const discriminator = this.discriminator; + const discriminatorValue = ctx.data[discriminator]; + const option = this.optionsMap.get(discriminatorValue); + if (!option) { + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_union_discriminator, + options: Array.from(this.optionsMap.keys()), + path: [discriminator] + }); + return INVALID; + } + if (ctx.common.async) { + return option._parseAsync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }); + } else { + return option._parseSync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }); + } + } + get discriminator() { + return this._def.discriminator; + } + get options() { + return this._def.options; + } + get optionsMap() { + return this._def.optionsMap; + } + /** + * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor. + * However, it only allows a union of objects, all of which need to share a discriminator property. This property must + * have a different value for each object in the union. + * @param discriminator the name of the discriminator property + * @param types an array of object schemas + * @param params + */ + static create(discriminator, options2, params) { + const optionsMap = /* @__PURE__ */ new Map(); + for (const type of options2) { + const discriminatorValues = getDiscriminator(type.shape[discriminator]); + if (!discriminatorValues) { + throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`); + } + for (const value of discriminatorValues) { + if (optionsMap.has(value)) { + throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`); + } + optionsMap.set(value, type); + } + } + return new _ZodDiscriminatedUnion({ + typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion, + discriminator, + options: options2, + optionsMap, + ...processCreateParams(params) + }); + } +}; +function mergeValues(a, b) { + const aType = getParsedType(a); + const bType = getParsedType(b); + if (a === b) { + return { valid: true, data: a }; + } else if (aType === ZodParsedType.object && bType === ZodParsedType.object) { + const bKeys = util.objectKeys(b); + const sharedKeys = util.objectKeys(a).filter((key) => bKeys.indexOf(key) !== -1); + const newObj = { ...a, ...b }; + for (const key of sharedKeys) { + const sharedValue = mergeValues(a[key], b[key]); + if (!sharedValue.valid) { + return { valid: false }; + } + newObj[key] = sharedValue.data; + } + return { valid: true, data: newObj }; + } else if (aType === ZodParsedType.array && bType === ZodParsedType.array) { + if (a.length !== b.length) { + return { valid: false }; + } + const newArray = []; + for (let index = 0; index < a.length; index++) { + const itemA = a[index]; + const itemB = b[index]; + const sharedValue = mergeValues(itemA, itemB); + if (!sharedValue.valid) { + return { valid: false }; + } + newArray.push(sharedValue.data); + } + return { valid: true, data: newArray }; + } else if (aType === ZodParsedType.date && bType === ZodParsedType.date && +a === +b) { + return { valid: true, data: a }; + } else { + return { valid: false }; + } +} +var ZodIntersection = class extends ZodType { + _parse(input) { + const { status, ctx } = this._processInputParams(input); + const handleParsed = (parsedLeft, parsedRight) => { + if (isAborted(parsedLeft) || isAborted(parsedRight)) { + return INVALID; + } + const merged = mergeValues(parsedLeft.value, parsedRight.value); + if (!merged.valid) { + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_intersection_types + }); + return INVALID; + } + if (isDirty(parsedLeft) || isDirty(parsedRight)) { + status.dirty(); + } + return { status: status.value, value: merged.data }; + }; + if (ctx.common.async) { + return Promise.all([ + this._def.left._parseAsync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }), + this._def.right._parseAsync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }) + ]).then(([left, right]) => handleParsed(left, right)); + } else { + return handleParsed(this._def.left._parseSync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }), this._def.right._parseSync({ + data: ctx.data, + path: ctx.path, + parent: ctx + })); + } + } +}; +ZodIntersection.create = (left, right, params) => { + return new ZodIntersection({ + left, + right, + typeName: ZodFirstPartyTypeKind.ZodIntersection, + ...processCreateParams(params) + }); +}; +var ZodTuple = class _ZodTuple extends ZodType { + _parse(input) { + const { status, ctx } = this._processInputParams(input); + if (ctx.parsedType !== ZodParsedType.array) { + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.array, + received: ctx.parsedType + }); + return INVALID; + } + if (ctx.data.length < this._def.items.length) { + addIssueToContext(ctx, { + code: ZodIssueCode.too_small, + minimum: this._def.items.length, + inclusive: true, + exact: false, + type: "array" + }); + return INVALID; + } + const rest = this._def.rest; + if (!rest && ctx.data.length > this._def.items.length) { + addIssueToContext(ctx, { + code: ZodIssueCode.too_big, + maximum: this._def.items.length, + inclusive: true, + exact: false, + type: "array" + }); + status.dirty(); + } + const items = [...ctx.data].map((item, itemIndex) => { + const schema = this._def.items[itemIndex] || this._def.rest; + if (!schema) + return null; + return schema._parse(new ParseInputLazyPath(ctx, item, ctx.path, itemIndex)); + }).filter((x) => !!x); + if (ctx.common.async) { + return Promise.all(items).then((results) => { + return ParseStatus.mergeArray(status, results); + }); + } else { + return ParseStatus.mergeArray(status, items); + } + } + get items() { + return this._def.items; + } + rest(rest) { + return new _ZodTuple({ + ...this._def, + rest + }); + } +}; +ZodTuple.create = (schemas, params) => { + if (!Array.isArray(schemas)) { + throw new Error("You must pass an array of schemas to z.tuple([ ... ])"); + } + return new ZodTuple({ + items: schemas, + typeName: ZodFirstPartyTypeKind.ZodTuple, + rest: null, + ...processCreateParams(params) + }); +}; +var ZodRecord = class _ZodRecord extends ZodType { + get keySchema() { + return this._def.keyType; + } + get valueSchema() { + return this._def.valueType; + } + _parse(input) { + const { status, ctx } = this._processInputParams(input); + if (ctx.parsedType !== ZodParsedType.object) { + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.object, + received: ctx.parsedType + }); + return INVALID; + } + const pairs = []; + const keyType = this._def.keyType; + const valueType = this._def.valueType; + for (const key in ctx.data) { + pairs.push({ + key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)), + value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)) + }); + } + if (ctx.common.async) { + return ParseStatus.mergeObjectAsync(status, pairs); + } else { + return ParseStatus.mergeObjectSync(status, pairs); + } + } + get element() { + return this._def.valueType; + } + static create(first, second, third) { + if (second instanceof ZodType) { + return new _ZodRecord({ + keyType: first, + valueType: second, + typeName: ZodFirstPartyTypeKind.ZodRecord, + ...processCreateParams(third) + }); + } + return new _ZodRecord({ + keyType: ZodString.create(), + valueType: first, + typeName: ZodFirstPartyTypeKind.ZodRecord, + ...processCreateParams(second) + }); + } +}; +var ZodMap = class extends ZodType { + get keySchema() { + return this._def.keyType; + } + get valueSchema() { + return this._def.valueType; + } + _parse(input) { + const { status, ctx } = this._processInputParams(input); + if (ctx.parsedType !== ZodParsedType.map) { + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.map, + received: ctx.parsedType + }); + return INVALID; + } + const keyType = this._def.keyType; + const valueType = this._def.valueType; + const pairs = [...ctx.data.entries()].map(([key, value], index) => { + return { + key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [index, "key"])), + value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index, "value"])) + }; + }); + if (ctx.common.async) { + const finalMap = /* @__PURE__ */ new Map(); + return Promise.resolve().then(async () => { + for (const pair of pairs) { + const key = await pair.key; + const value = await pair.value; + if (key.status === "aborted" || value.status === "aborted") { + return INVALID; + } + if (key.status === "dirty" || value.status === "dirty") { + status.dirty(); + } + finalMap.set(key.value, value.value); + } + return { status: status.value, value: finalMap }; + }); + } else { + const finalMap = /* @__PURE__ */ new Map(); + for (const pair of pairs) { + const key = pair.key; + const value = pair.value; + if (key.status === "aborted" || value.status === "aborted") { + return INVALID; + } + if (key.status === "dirty" || value.status === "dirty") { + status.dirty(); + } + finalMap.set(key.value, value.value); + } + return { status: status.value, value: finalMap }; + } + } +}; +ZodMap.create = (keyType, valueType, params) => { + return new ZodMap({ + valueType, + keyType, + typeName: ZodFirstPartyTypeKind.ZodMap, + ...processCreateParams(params) + }); +}; +var ZodSet = class _ZodSet extends ZodType { + _parse(input) { + const { status, ctx } = this._processInputParams(input); + if (ctx.parsedType !== ZodParsedType.set) { + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.set, + received: ctx.parsedType + }); + return INVALID; + } + const def = this._def; + if (def.minSize !== null) { + if (ctx.data.size < def.minSize.value) { + addIssueToContext(ctx, { + code: ZodIssueCode.too_small, + minimum: def.minSize.value, + type: "set", + inclusive: true, + exact: false, + message: def.minSize.message + }); + status.dirty(); + } + } + if (def.maxSize !== null) { + if (ctx.data.size > def.maxSize.value) { + addIssueToContext(ctx, { + code: ZodIssueCode.too_big, + maximum: def.maxSize.value, + type: "set", + inclusive: true, + exact: false, + message: def.maxSize.message + }); + status.dirty(); + } + } + const valueType = this._def.valueType; + function finalizeSet(elements2) { + const parsedSet = /* @__PURE__ */ new Set(); + for (const element of elements2) { + if (element.status === "aborted") + return INVALID; + if (element.status === "dirty") + status.dirty(); + parsedSet.add(element.value); + } + return { status: status.value, value: parsedSet }; + } + const elements = [...ctx.data.values()].map((item, i) => valueType._parse(new ParseInputLazyPath(ctx, item, ctx.path, i))); + if (ctx.common.async) { + return Promise.all(elements).then((elements2) => finalizeSet(elements2)); + } else { + return finalizeSet(elements); + } + } + min(minSize, message) { + return new _ZodSet({ + ...this._def, + minSize: { value: minSize, message: errorUtil.toString(message) } + }); + } + max(maxSize, message) { + return new _ZodSet({ + ...this._def, + maxSize: { value: maxSize, message: errorUtil.toString(message) } + }); + } + size(size, message) { + return this.min(size, message).max(size, message); + } + nonempty(message) { + return this.min(1, message); + } +}; +ZodSet.create = (valueType, params) => { + return new ZodSet({ + valueType, + minSize: null, + maxSize: null, + typeName: ZodFirstPartyTypeKind.ZodSet, + ...processCreateParams(params) + }); +}; +var ZodFunction = class _ZodFunction extends ZodType { + constructor() { + super(...arguments); + this.validate = this.implement; + } + _parse(input) { + const { ctx } = this._processInputParams(input); + if (ctx.parsedType !== ZodParsedType.function) { + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.function, + received: ctx.parsedType + }); + return INVALID; + } + function makeArgsIssue(args, error) { + return makeIssue({ + data: args, + path: ctx.path, + errorMaps: [ + ctx.common.contextualErrorMap, + ctx.schemaErrorMap, + getErrorMap(), + errorMap + ].filter((x) => !!x), + issueData: { + code: ZodIssueCode.invalid_arguments, + argumentsError: error + } + }); + } + function makeReturnsIssue(returns, error) { + return makeIssue({ + data: returns, + path: ctx.path, + errorMaps: [ + ctx.common.contextualErrorMap, + ctx.schemaErrorMap, + getErrorMap(), + errorMap + ].filter((x) => !!x), + issueData: { + code: ZodIssueCode.invalid_return_type, + returnTypeError: error + } + }); + } + const params = { errorMap: ctx.common.contextualErrorMap }; + const fn = ctx.data; + if (this._def.returns instanceof ZodPromise) { + const me = this; + return OK(async function(...args) { + const error = new ZodError([]); + const parsedArgs = await me._def.args.parseAsync(args, params).catch((e) => { + error.addIssue(makeArgsIssue(args, e)); + throw error; + }); + const result = await Reflect.apply(fn, this, parsedArgs); + const parsedReturns = await me._def.returns._def.type.parseAsync(result, params).catch((e) => { + error.addIssue(makeReturnsIssue(result, e)); + throw error; + }); + return parsedReturns; + }); + } else { + const me = this; + return OK(function(...args) { + const parsedArgs = me._def.args.safeParse(args, params); + if (!parsedArgs.success) { + throw new ZodError([makeArgsIssue(args, parsedArgs.error)]); + } + const result = Reflect.apply(fn, this, parsedArgs.data); + const parsedReturns = me._def.returns.safeParse(result, params); + if (!parsedReturns.success) { + throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]); + } + return parsedReturns.data; + }); + } + } + parameters() { + return this._def.args; + } + returnType() { + return this._def.returns; + } + args(...items) { + return new _ZodFunction({ + ...this._def, + args: ZodTuple.create(items).rest(ZodUnknown.create()) + }); + } + returns(returnType) { + return new _ZodFunction({ + ...this._def, + returns: returnType + }); + } + implement(func) { + const validatedFunc = this.parse(func); + return validatedFunc; + } + strictImplement(func) { + const validatedFunc = this.parse(func); + return validatedFunc; + } + static create(args, returns, params) { + return new _ZodFunction({ + args: args ? args : ZodTuple.create([]).rest(ZodUnknown.create()), + returns: returns || ZodUnknown.create(), + typeName: ZodFirstPartyTypeKind.ZodFunction, + ...processCreateParams(params) + }); + } +}; +var ZodLazy = class extends ZodType { + get schema() { + return this._def.getter(); + } + _parse(input) { + const { ctx } = this._processInputParams(input); + const lazySchema = this._def.getter(); + return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx }); + } +}; +ZodLazy.create = (getter, params) => { + return new ZodLazy({ + getter, + typeName: ZodFirstPartyTypeKind.ZodLazy, + ...processCreateParams(params) + }); +}; +var ZodLiteral = class extends ZodType { + _parse(input) { + if (input.data !== this._def.value) { + const ctx = this._getOrReturnCtx(input); + addIssueToContext(ctx, { + received: ctx.data, + code: ZodIssueCode.invalid_literal, + expected: this._def.value + }); + return INVALID; + } + return { status: "valid", value: input.data }; + } + get value() { + return this._def.value; + } +}; +ZodLiteral.create = (value, params) => { + return new ZodLiteral({ + value, + typeName: ZodFirstPartyTypeKind.ZodLiteral, + ...processCreateParams(params) + }); +}; +function createZodEnum(values, params) { + return new ZodEnum({ + values, + typeName: ZodFirstPartyTypeKind.ZodEnum, + ...processCreateParams(params) + }); +} +var ZodEnum = class _ZodEnum extends ZodType { + _parse(input) { + if (typeof input.data !== "string") { + const ctx = this._getOrReturnCtx(input); + const expectedValues = this._def.values; + addIssueToContext(ctx, { + expected: util.joinValues(expectedValues), + received: ctx.parsedType, + code: ZodIssueCode.invalid_type + }); + return INVALID; + } + if (this._def.values.indexOf(input.data) === -1) { + const ctx = this._getOrReturnCtx(input); + const expectedValues = this._def.values; + addIssueToContext(ctx, { + received: ctx.data, + code: ZodIssueCode.invalid_enum_value, + options: expectedValues + }); + return INVALID; + } + return OK(input.data); + } + get options() { + return this._def.values; + } + get enum() { + const enumValues = {}; + for (const val of this._def.values) { + enumValues[val] = val; + } + return enumValues; + } + get Values() { + const enumValues = {}; + for (const val of this._def.values) { + enumValues[val] = val; + } + return enumValues; + } + get Enum() { + const enumValues = {}; + for (const val of this._def.values) { + enumValues[val] = val; + } + return enumValues; + } + extract(values) { + return _ZodEnum.create(values); + } + exclude(values) { + return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt))); + } +}; +ZodEnum.create = createZodEnum; +var ZodNativeEnum = class extends ZodType { + _parse(input) { + const nativeEnumValues = util.getValidEnumValues(this._def.values); + const ctx = this._getOrReturnCtx(input); + if (ctx.parsedType !== ZodParsedType.string && ctx.parsedType !== ZodParsedType.number) { + const expectedValues = util.objectValues(nativeEnumValues); + addIssueToContext(ctx, { + expected: util.joinValues(expectedValues), + received: ctx.parsedType, + code: ZodIssueCode.invalid_type + }); + return INVALID; + } + if (nativeEnumValues.indexOf(input.data) === -1) { + const expectedValues = util.objectValues(nativeEnumValues); + addIssueToContext(ctx, { + received: ctx.data, + code: ZodIssueCode.invalid_enum_value, + options: expectedValues + }); + return INVALID; + } + return OK(input.data); + } + get enum() { + return this._def.values; + } +}; +ZodNativeEnum.create = (values, params) => { + return new ZodNativeEnum({ + values, + typeName: ZodFirstPartyTypeKind.ZodNativeEnum, + ...processCreateParams(params) + }); +}; +var ZodPromise = class extends ZodType { + unwrap() { + return this._def.type; + } + _parse(input) { + const { ctx } = this._processInputParams(input); + if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) { + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.promise, + received: ctx.parsedType + }); + return INVALID; + } + const promisified = ctx.parsedType === ZodParsedType.promise ? ctx.data : Promise.resolve(ctx.data); + return OK(promisified.then((data) => { + return this._def.type.parseAsync(data, { + path: ctx.path, + errorMap: ctx.common.contextualErrorMap + }); + })); + } +}; +ZodPromise.create = (schema, params) => { + return new ZodPromise({ + type: schema, + typeName: ZodFirstPartyTypeKind.ZodPromise, + ...processCreateParams(params) + }); +}; +var ZodEffects = class extends ZodType { + innerType() { + return this._def.schema; + } + sourceType() { + return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects ? this._def.schema.sourceType() : this._def.schema; + } + _parse(input) { + const { status, ctx } = this._processInputParams(input); + const effect = this._def.effect || null; + const checkCtx = { + addIssue: (arg) => { + addIssueToContext(ctx, arg); + if (arg.fatal) { + status.abort(); + } else { + status.dirty(); + } + }, + get path() { + return ctx.path; + } + }; + checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx); + if (effect.type === "preprocess") { + const processed = effect.transform(ctx.data, checkCtx); + if (ctx.common.issues.length) { + return { + status: "dirty", + value: ctx.data + }; + } + if (ctx.common.async) { + return Promise.resolve(processed).then((processed2) => { + return this._def.schema._parseAsync({ + data: processed2, + path: ctx.path, + parent: ctx + }); + }); + } else { + return this._def.schema._parseSync({ + data: processed, + path: ctx.path, + parent: ctx + }); + } + } + if (effect.type === "refinement") { + const executeRefinement = (acc) => { + const result = effect.refinement(acc, checkCtx); + if (ctx.common.async) { + return Promise.resolve(result); + } + if (result instanceof Promise) { + throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead."); + } + return acc; + }; + if (ctx.common.async === false) { + const inner = this._def.schema._parseSync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }); + if (inner.status === "aborted") + return INVALID; + if (inner.status === "dirty") + status.dirty(); + executeRefinement(inner.value); + return { status: status.value, value: inner.value }; + } else { + return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((inner) => { + if (inner.status === "aborted") + return INVALID; + if (inner.status === "dirty") + status.dirty(); + return executeRefinement(inner.value).then(() => { + return { status: status.value, value: inner.value }; + }); + }); + } + } + if (effect.type === "transform") { + if (ctx.common.async === false) { + const base = this._def.schema._parseSync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }); + if (!isValid(base)) + return base; + const result = effect.transform(base.value, checkCtx); + if (result instanceof Promise) { + throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`); + } + return { status: status.value, value: result }; + } else { + return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base) => { + if (!isValid(base)) + return base; + return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({ status: status.value, value: result })); + }); + } + } + util.assertNever(effect); + } +}; +ZodEffects.create = (schema, effect, params) => { + return new ZodEffects({ + schema, + typeName: ZodFirstPartyTypeKind.ZodEffects, + effect, + ...processCreateParams(params) + }); +}; +ZodEffects.createWithPreprocess = (preprocess, schema, params) => { + return new ZodEffects({ + schema, + effect: { type: "preprocess", transform: preprocess }, + typeName: ZodFirstPartyTypeKind.ZodEffects, + ...processCreateParams(params) + }); +}; +var ZodOptional = class extends ZodType { + _parse(input) { + const parsedType = this._getType(input); + if (parsedType === ZodParsedType.undefined) { + return OK(void 0); + } + return this._def.innerType._parse(input); + } + unwrap() { + return this._def.innerType; + } +}; +ZodOptional.create = (type, params) => { + return new ZodOptional({ + innerType: type, + typeName: ZodFirstPartyTypeKind.ZodOptional, + ...processCreateParams(params) + }); +}; +var ZodNullable = class extends ZodType { + _parse(input) { + const parsedType = this._getType(input); + if (parsedType === ZodParsedType.null) { + return OK(null); + } + return this._def.innerType._parse(input); + } + unwrap() { + return this._def.innerType; + } +}; +ZodNullable.create = (type, params) => { + return new ZodNullable({ + innerType: type, + typeName: ZodFirstPartyTypeKind.ZodNullable, + ...processCreateParams(params) + }); +}; +var ZodDefault = class extends ZodType { + _parse(input) { + const { ctx } = this._processInputParams(input); + let data = ctx.data; + if (ctx.parsedType === ZodParsedType.undefined) { + data = this._def.defaultValue(); + } + return this._def.innerType._parse({ + data, + path: ctx.path, + parent: ctx + }); + } + removeDefault() { + return this._def.innerType; + } +}; +ZodDefault.create = (type, params) => { + return new ZodDefault({ + innerType: type, + typeName: ZodFirstPartyTypeKind.ZodDefault, + defaultValue: typeof params.default === "function" ? params.default : () => params.default, + ...processCreateParams(params) + }); +}; +var ZodCatch = class extends ZodType { + _parse(input) { + const { ctx } = this._processInputParams(input); + const newCtx = { + ...ctx, + common: { + ...ctx.common, + issues: [] + } + }; + const result = this._def.innerType._parse({ + data: newCtx.data, + path: newCtx.path, + parent: { + ...newCtx + } + }); + if (isAsync(result)) { + return result.then((result2) => { + return { + status: "valid", + value: result2.status === "valid" ? result2.value : this._def.catchValue({ + get error() { + return new ZodError(newCtx.common.issues); + }, + input: newCtx.data + }) + }; + }); + } else { + return { + status: "valid", + value: result.status === "valid" ? result.value : this._def.catchValue({ + get error() { + return new ZodError(newCtx.common.issues); + }, + input: newCtx.data + }) + }; + } + } + removeCatch() { + return this._def.innerType; + } +}; +ZodCatch.create = (type, params) => { + return new ZodCatch({ + innerType: type, + typeName: ZodFirstPartyTypeKind.ZodCatch, + catchValue: typeof params.catch === "function" ? params.catch : () => params.catch, + ...processCreateParams(params) + }); +}; +var ZodNaN = class extends ZodType { + _parse(input) { + const parsedType = this._getType(input); + if (parsedType !== ZodParsedType.nan) { + const ctx = this._getOrReturnCtx(input); + addIssueToContext(ctx, { + code: ZodIssueCode.invalid_type, + expected: ZodParsedType.nan, + received: ctx.parsedType + }); + return INVALID; + } + return { status: "valid", value: input.data }; + } +}; +ZodNaN.create = (params) => { + return new ZodNaN({ + typeName: ZodFirstPartyTypeKind.ZodNaN, + ...processCreateParams(params) + }); +}; +var BRAND = Symbol("zod_brand"); +var ZodBranded = class extends ZodType { + _parse(input) { + const { ctx } = this._processInputParams(input); + const data = ctx.data; + return this._def.type._parse({ + data, + path: ctx.path, + parent: ctx + }); + } + unwrap() { + return this._def.type; + } +}; +var ZodPipeline = class _ZodPipeline extends ZodType { + _parse(input) { + const { status, ctx } = this._processInputParams(input); + if (ctx.common.async) { + const handleAsync = async () => { + const inResult = await this._def.in._parseAsync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }); + if (inResult.status === "aborted") + return INVALID; + if (inResult.status === "dirty") { + status.dirty(); + return DIRTY(inResult.value); + } else { + return this._def.out._parseAsync({ + data: inResult.value, + path: ctx.path, + parent: ctx + }); + } + }; + return handleAsync(); + } else { + const inResult = this._def.in._parseSync({ + data: ctx.data, + path: ctx.path, + parent: ctx + }); + if (inResult.status === "aborted") + return INVALID; + if (inResult.status === "dirty") { + status.dirty(); + return { + status: "dirty", + value: inResult.value + }; + } else { + return this._def.out._parseSync({ + data: inResult.value, + path: ctx.path, + parent: ctx + }); + } + } + } + static create(a, b) { + return new _ZodPipeline({ + in: a, + out: b, + typeName: ZodFirstPartyTypeKind.ZodPipeline + }); + } +}; +var ZodReadonly = class extends ZodType { + _parse(input) { + const result = this._def.innerType._parse(input); + if (isValid(result)) { + result.value = Object.freeze(result.value); + } + return result; + } +}; +ZodReadonly.create = (type, params) => { + return new ZodReadonly({ + innerType: type, + typeName: ZodFirstPartyTypeKind.ZodReadonly, + ...processCreateParams(params) + }); +}; +var late = { + object: ZodObject.lazycreate +}; +var ZodFirstPartyTypeKind; +(function(ZodFirstPartyTypeKind2) { + ZodFirstPartyTypeKind2["ZodString"] = "ZodString"; + ZodFirstPartyTypeKind2["ZodNumber"] = "ZodNumber"; + ZodFirstPartyTypeKind2["ZodNaN"] = "ZodNaN"; + ZodFirstPartyTypeKind2["ZodBigInt"] = "ZodBigInt"; + ZodFirstPartyTypeKind2["ZodBoolean"] = "ZodBoolean"; + ZodFirstPartyTypeKind2["ZodDate"] = "ZodDate"; + ZodFirstPartyTypeKind2["ZodSymbol"] = "ZodSymbol"; + ZodFirstPartyTypeKind2["ZodUndefined"] = "ZodUndefined"; + ZodFirstPartyTypeKind2["ZodNull"] = "ZodNull"; + ZodFirstPartyTypeKind2["ZodAny"] = "ZodAny"; + ZodFirstPartyTypeKind2["ZodUnknown"] = "ZodUnknown"; + ZodFirstPartyTypeKind2["ZodNever"] = "ZodNever"; + ZodFirstPartyTypeKind2["ZodVoid"] = "ZodVoid"; + ZodFirstPartyTypeKind2["ZodArray"] = "ZodArray"; + ZodFirstPartyTypeKind2["ZodObject"] = "ZodObject"; + ZodFirstPartyTypeKind2["ZodUnion"] = "ZodUnion"; + ZodFirstPartyTypeKind2["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion"; + ZodFirstPartyTypeKind2["ZodIntersection"] = "ZodIntersection"; + ZodFirstPartyTypeKind2["ZodTuple"] = "ZodTuple"; + ZodFirstPartyTypeKind2["ZodRecord"] = "ZodRecord"; + ZodFirstPartyTypeKind2["ZodMap"] = "ZodMap"; + ZodFirstPartyTypeKind2["ZodSet"] = "ZodSet"; + ZodFirstPartyTypeKind2["ZodFunction"] = "ZodFunction"; + ZodFirstPartyTypeKind2["ZodLazy"] = "ZodLazy"; + ZodFirstPartyTypeKind2["ZodLiteral"] = "ZodLiteral"; + ZodFirstPartyTypeKind2["ZodEnum"] = "ZodEnum"; + ZodFirstPartyTypeKind2["ZodEffects"] = "ZodEffects"; + ZodFirstPartyTypeKind2["ZodNativeEnum"] = "ZodNativeEnum"; + ZodFirstPartyTypeKind2["ZodOptional"] = "ZodOptional"; + ZodFirstPartyTypeKind2["ZodNullable"] = "ZodNullable"; + ZodFirstPartyTypeKind2["ZodDefault"] = "ZodDefault"; + ZodFirstPartyTypeKind2["ZodCatch"] = "ZodCatch"; + ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise"; + ZodFirstPartyTypeKind2["ZodBranded"] = "ZodBranded"; + ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline"; + ZodFirstPartyTypeKind2["ZodReadonly"] = "ZodReadonly"; +})(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {})); +var stringType = ZodString.create; +var numberType = ZodNumber.create; +var nanType = ZodNaN.create; +var bigIntType = ZodBigInt.create; +var booleanType = ZodBoolean.create; +var dateType = ZodDate.create; +var symbolType = ZodSymbol.create; +var undefinedType = ZodUndefined.create; +var nullType = ZodNull.create; +var anyType = ZodAny.create; +var unknownType = ZodUnknown.create; +var neverType = ZodNever.create; +var voidType = ZodVoid.create; +var arrayType = ZodArray.create; +var objectType = ZodObject.create; +var strictObjectType = ZodObject.strictCreate; +var unionType = ZodUnion.create; +var discriminatedUnionType = ZodDiscriminatedUnion.create; +var intersectionType = ZodIntersection.create; +var tupleType = ZodTuple.create; +var recordType = ZodRecord.create; +var mapType = ZodMap.create; +var setType = ZodSet.create; +var functionType = ZodFunction.create; +var lazyType = ZodLazy.create; +var literalType = ZodLiteral.create; +var enumType = ZodEnum.create; +var nativeEnumType = ZodNativeEnum.create; +var promiseType = ZodPromise.create; +var effectsType = ZodEffects.create; +var optionalType = ZodOptional.create; +var nullableType = ZodNullable.create; +var preprocessType = ZodEffects.createWithPreprocess; +var pipelineType = ZodPipeline.create; + +// node_modules/.pnpm/untildify@5.0.0/node_modules/untildify/index.js +var import_node_os = __toESM(require("os"), 1); +var homeDirectory = import_node_os.default.homedir(); +function untildify(pathWithTilde) { + if (typeof pathWithTilde !== "string") { + throw new TypeError(`Expected a string, got ${typeof pathWithTilde}`); + } + return homeDirectory ? pathWithTilde.replace(/^~(?=$|\/|\\)/, homeDirectory) : pathWithTilde; +} + +// src/options.ts +var logLevelSchema = enumType(["quiet", "warn", "info", "debug", "trace"]); +var PATHS = { + pixiBin: import_path.default.join(import_os.default.homedir(), ".pixi", "bin", `pixi${import_os.default.platform() === "win32" ? ".exe" : ""}`) +}; +var parseOrUndefined = (key, schema) => { + const input = core.getInput(key); + if (input === "") { + return void 0; + } + return schema.parse(input); +}; +var parseOrUndefinedJSON = (key, schema) => { + const input = core.getInput(key); + if (input === "") { + return void 0; + } + return schema.parse(JSON.parse(input)); +}; +var validateInputs = (inputs) => { + if (inputs.pixiVersion && inputs.pixiUrl) { + throw new Error("You need to specify either pixi-version or pixi-url"); + } + if (inputs.cacheKey !== void 0 && inputs.cache === false) { + throw new Error("Cannot specify cache key without caching"); + } + if (inputs.runInstall === false && inputs.cache === true) { + throw new Error("Cannot cache without running install"); + } + if (inputs.authUsername && !inputs.authPassword || !inputs.authUsername && inputs.authPassword) { + throw new Error("You need to specify both auth-username and auth-password"); + } + if (inputs.authHost) { + if (!inputs.authToken && !inputs.authUsername && !inputs.authCondaToken) { + throw new Error("You need to specify either auth-token or auth-username and auth-password or auth-conda-token"); + } + if (inputs.authToken && (inputs.authUsername || inputs.authCondaToken) || inputs.authUsername && inputs.authCondaToken) { + throw new Error("You cannot specify two auth methods"); + } + } + if (!inputs.authHost) { + if (inputs.authToken || inputs.authUsername || inputs.authCondaToken) { + throw new Error("You need to specify auth-host"); + } + } + if (inputs.cacheWrite && !inputs.cacheKey && !inputs.cache) { + throw new Error("cache-write is only valid with cache-key or cache specified."); + } +}; +var inferOptions = (inputs) => { + const runInstall = inputs.runInstall ?? true; + const pixiSource = inputs.pixiVersion ? { version: inputs.pixiVersion } : inputs.pixiUrl ? { url: inputs.pixiUrl } : { version: "latest" }; + const logLevel = inputs.logLevel ?? (core.isDebug() ? "debug" : "warn"); + const manifestPath = inputs.manifestPath ? import_path.default.resolve(untildify(inputs.manifestPath)) : "pixi.toml"; + const pixiLockFile = import_path.default.join(import_path.default.dirname(manifestPath), import_path.default.basename(manifestPath).replace(/\.toml$/, ".lock")); + const generateRunShell = inputs.generateRunShell ?? runInstall; + const cache = inputs.cacheKey ? { cacheKeyPrefix: inputs.cacheKey, cacheWrite: inputs.cacheWrite ?? true } : inputs.cache ? { cacheKeyPrefix: "pixi-", cacheWrite: true } : void 0; + const pixiBinPath = inputs.pixiBinPath ? import_path.default.resolve(untildify(inputs.pixiBinPath)) : PATHS.pixiBin; + const pixiRunShell = import_path.default.join(import_path.default.dirname(pixiBinPath), "pixi-shell"); + const auth = !inputs.authHost ? void 0 : inputs.authToken ? { + host: inputs.authHost, + token: inputs.authToken + } : inputs.authCondaToken ? { + host: inputs.authHost, + condaToken: inputs.authCondaToken + } : { + host: inputs.authHost, + username: inputs.authUsername, + password: inputs.authPassword + }; + const postCleanup = inputs.postCleanup ?? true; + return { + pixiSource, + logLevel, + manifestPath, + pixiLockFile, + runInstall, + generateRunShell, + cache, + pixiBinPath, + pixiRunShell, + auth, + postCleanup + }; +}; +var assertOptions = (_options) => { +}; +var getOptions = () => { + const inputs = { + pixiVersion: parseOrUndefined("pixi-version", unionType([literalType("latest"), stringType().regex(/^v\d+\.\d+\.\d+$/)])), + pixiUrl: parseOrUndefined("pixi-url", stringType().url()), + logLevel: parseOrUndefined("log-level", logLevelSchema), + manifestPath: parseOrUndefined("manifest-path", stringType()), + runInstall: parseOrUndefinedJSON("run-install", booleanType()), + generateRunShell: parseOrUndefinedJSON("generate-run-shell", booleanType()), + cache: parseOrUndefinedJSON("cache", booleanType()), + cacheKey: parseOrUndefined("cache-key", stringType()), + cacheWrite: parseOrUndefinedJSON("cache-write", booleanType()), + pixiBinPath: parseOrUndefined("pixi-bin-path", stringType()), + authHost: parseOrUndefined("auth-host", stringType()), + authToken: parseOrUndefined("auth-token", stringType()), + authUsername: parseOrUndefined("auth-username", stringType()), + authPassword: parseOrUndefined("auth-password", stringType()), + authCondaToken: parseOrUndefined("auth-conda-token", stringType()), + postCleanup: parseOrUndefinedJSON("post-cleanup", booleanType()) + }; + core.debug(`Inputs: ${JSON.stringify(inputs)}`); + validateInputs(inputs); + const options2 = inferOptions(inputs); + core.debug(`Inferred options: ${JSON.stringify(options2)}`); + assertOptions(options2); + return options2; +}; +var options = getOptions(); // src/post.ts -console.log("post"); +var cleanupPixiBin = () => { + const pixiBinPath = options.pixiBinPath; + const pixiBinDir = import_path2.default.dirname(pixiBinPath); + return import_promises.default.rm(options.pixiBinPath).then(() => import_promises.default.readdir(pixiBinDir)).then((files) => { + if (files.length === 0) { + return import_promises.default.rmdir(pixiBinDir); + } + return Promise.resolve(); + }); +}; +var cleanupEnv = () => import_promises.default.rmdir(import_path2.default.join(import_path2.default.dirname(options.manifestPath), ".pixi"), { recursive: true }); +var cleanupRattler = () => Promise.all([ + import_promises.default.rmdir(import_path2.default.join(os3.homedir(), ".rattler"), { recursive: true }), + import_promises.default.rmdir(import_path2.default.join(os3.homedir(), ".cache", "rattler"), { recursive: true }) +]); +var run = () => { + const postCleanup = options.postCleanup; + if (postCleanup) { + return Promise.all([cleanupPixiBin(), cleanupEnv(), cleanupRattler()]); + } + core2.debug("Skipping post-cleanup."); + return Promise.resolve(); +}; +run(); //# sourceMappingURL=post.js.map \ No newline at end of file diff --git a/src/options.ts b/src/options.ts index 74a9b536..3ada10ef 100644 --- a/src/options.ts +++ b/src/options.ts @@ -20,7 +20,7 @@ type Inputs = { authUsername?: string authPassword?: string authCondaToken?: string - postCleanup?: PostCleanup + postCleanup?: boolean } export type PixiSource = @@ -62,15 +62,12 @@ export type Options = Readonly<{ pixiBinPath: string pixiRunShell: string auth?: Auth - postCleanup: PostCleanup + postCleanup: boolean }> const logLevelSchema = z.enum(['quiet', 'warn', 'info', 'debug', 'trace']) export type LogLevel = z.infer -const postCleanupSchema = z.enum(['none', 'environment', 'all']) -export type PostCleanup = z.infer - export const PATHS = { pixiBin: path.join(os.homedir(), '.pixi', 'bin', `pixi${os.platform() === 'win32' ? '.exe' : ''}`) } @@ -163,7 +160,7 @@ const inferOptions = (inputs: Inputs): Options => { username: inputs.authUsername!, password: inputs.authPassword! }) as Auth) - const postCleanup = inputs.postCleanup ?? 'all' + const postCleanup = inputs.postCleanup ?? true return { pixiSource, logLevel, @@ -205,7 +202,7 @@ const getOptions = () => { authUsername: parseOrUndefined('auth-username', z.string()), authPassword: parseOrUndefined('auth-password', z.string()), authCondaToken: parseOrUndefined('auth-conda-token', z.string()), - postCleanup: parseOrUndefined('post-cleanup', postCleanupSchema) + postCleanup: parseOrUndefinedJSON('post-cleanup', z.boolean()) } core.debug(`Inputs: ${JSON.stringify(inputs)}`) validateInputs(inputs) diff --git a/src/post.ts b/src/post.ts index a41a3ae3..da5afb4c 100644 --- a/src/post.ts +++ b/src/post.ts @@ -1 +1,38 @@ -console.log('post') +import fs from 'fs/promises' +import path from 'path' +import * as os from 'os' +import * as core from '@actions/core' +import { options } from './options' + +const cleanupPixiBin = () => { + const pixiBinPath = options.pixiBinPath + const pixiBinDir = path.dirname(pixiBinPath) + return fs + .rm(options.pixiBinPath) + .then(() => fs.readdir(pixiBinDir)) + .then((files) => { + if (files.length === 0) { + return fs.rmdir(pixiBinDir) + } + return Promise.resolve() + }) +} + +const cleanupEnv = () => fs.rmdir(path.join(path.dirname(options.manifestPath), '.pixi'), { recursive: true }) + +const cleanupRattler = () => + Promise.all([ + fs.rmdir(path.join(os.homedir(), '.rattler'), { recursive: true }), + fs.rmdir(path.join(os.homedir(), '.cache', 'rattler'), { recursive: true }) + ]) + +const run = () => { + const postCleanup = options.postCleanup + if (postCleanup) { + return Promise.all([cleanupPixiBin(), cleanupEnv(), cleanupRattler()]) + } + core.debug('Skipping post-cleanup.') + return Promise.resolve() +} + +run() From 1e7547f8cdf61760c3d286f216f15b51682a5550 Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Sat, 9 Sep 2023 18:30:19 +0200 Subject: [PATCH 40/57] . --- .github/workflows/test.yml | 39 +++++++------------------------------- src/post.ts | 8 ++++---- 2 files changed, 11 insertions(+), 36 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 06141b48..7cc7d8b6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -101,21 +101,6 @@ jobs: with: log-level: debug - # run-shell: - # strategy: - # matrix: - # os: [ubuntu-latest, macos-latest] - # runs-on: ${{ matrix.os }} - # steps: - # - uses: actions/checkout@v4 - # - name: Move pixi.toml - # run: mv test/default/* . - # - uses: ./ - # with: - # generate-run-shell: true - # - run: python --version | grep -q "3.11" - # shell: pixi-shell {0} - custom-bin-path: strategy: matrix: @@ -216,26 +201,16 @@ jobs: shell: pixi run bash {0} post-cleanup: - # not implemented yet - if: false name: post-cleanup ${{ matrix.post-cleanup }} runs-on: ${{ matrix.os }} strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] include: - - post-cleanup: 'none' - env-exists: '' - cache-exists: '' - pixi-dir-exists: '' - - post-cleanup: 'environment' - env-exists: '! ' - cache-exists: '' - pixi-dir-exists: '' - - post-cleanup: 'all' - env-exists: '! ' - cache-exists: '! ' - pixi-dir-exists: '! ' + - post-cleanup: 'true' + invert-condition: '' + - post-cleanup: 'false' + invert-condition: '! ' steps: - uses: actions/checkout@v4 - name: Move pixi.toml @@ -244,9 +219,9 @@ jobs: with: run: | set -euxo pipefail - ${{ matrix.env-exists }}test -d .pixi - ${{ matrix.cache-exists }}test -d ~/.cache/rattler - ${{ matrix.pixi-dir-exists }}test -f ~/.pixi + ${{ matrix.invert-condition }}test -d .pixi + ${{ matrix.invert-condition }}test -d ~/.cache/rattler + ${{ matrix.invert-condition }}test -f ~/.pixi - uses: ./ with: post-cleanup: ${{ matrix.post-cleanup }} diff --git a/src/post.ts b/src/post.ts index da5afb4c..f4405f26 100644 --- a/src/post.ts +++ b/src/post.ts @@ -12,18 +12,18 @@ const cleanupPixiBin = () => { .then(() => fs.readdir(pixiBinDir)) .then((files) => { if (files.length === 0) { - return fs.rmdir(pixiBinDir) + return fs.rm(pixiBinDir) } return Promise.resolve() }) } -const cleanupEnv = () => fs.rmdir(path.join(path.dirname(options.manifestPath), '.pixi'), { recursive: true }) +const cleanupEnv = () => fs.rm(path.join(path.dirname(options.manifestPath), '.pixi'), { recursive: true }) const cleanupRattler = () => Promise.all([ - fs.rmdir(path.join(os.homedir(), '.rattler'), { recursive: true }), - fs.rmdir(path.join(os.homedir(), '.cache', 'rattler'), { recursive: true }) + fs.rm(path.join(os.homedir(), '.rattler'), { recursive: true }), + fs.rm(path.join(os.homedir(), '.cache', 'rattler'), { recursive: true }) ]) const run = () => { From 56b41205b81d29f220934158d09e216b3e2fc1cf Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Sat, 9 Sep 2023 18:32:01 +0200 Subject: [PATCH 41/57] . --- dist/post.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dist/post.js b/dist/post.js index 3cf1d7a5..bbec10c3 100644 --- a/dist/post.js +++ b/dist/post.js @@ -5948,15 +5948,15 @@ var cleanupPixiBin = () => { const pixiBinDir = import_path2.default.dirname(pixiBinPath); return import_promises.default.rm(options.pixiBinPath).then(() => import_promises.default.readdir(pixiBinDir)).then((files) => { if (files.length === 0) { - return import_promises.default.rmdir(pixiBinDir); + return import_promises.default.rm(pixiBinDir); } return Promise.resolve(); }); }; -var cleanupEnv = () => import_promises.default.rmdir(import_path2.default.join(import_path2.default.dirname(options.manifestPath), ".pixi"), { recursive: true }); +var cleanupEnv = () => import_promises.default.rm(import_path2.default.join(import_path2.default.dirname(options.manifestPath), ".pixi"), { recursive: true }); var cleanupRattler = () => Promise.all([ - import_promises.default.rmdir(import_path2.default.join(os3.homedir(), ".rattler"), { recursive: true }), - import_promises.default.rmdir(import_path2.default.join(os3.homedir(), ".cache", "rattler"), { recursive: true }) + import_promises.default.rm(import_path2.default.join(os3.homedir(), ".rattler"), { recursive: true }), + import_promises.default.rm(import_path2.default.join(os3.homedir(), ".cache", "rattler"), { recursive: true }) ]); var run = () => { const postCleanup = options.postCleanup; From 5edb1c584984d25d3f0360dbc5df6d437baa07e1 Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Sat, 9 Sep 2023 18:35:23 +0200 Subject: [PATCH 42/57] . --- dist/post.js | 19 ++++++++++++++----- src/post.ts | 18 +++++++++++++----- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/dist/post.js b/dist/post.js index bbec10c3..4a31a25a 100644 --- a/dist/post.js +++ b/dist/post.js @@ -5953,11 +5953,20 @@ var cleanupPixiBin = () => { return Promise.resolve(); }); }; -var cleanupEnv = () => import_promises.default.rm(import_path2.default.join(import_path2.default.dirname(options.manifestPath), ".pixi"), { recursive: true }); -var cleanupRattler = () => Promise.all([ - import_promises.default.rm(import_path2.default.join(os3.homedir(), ".rattler"), { recursive: true }), - import_promises.default.rm(import_path2.default.join(os3.homedir(), ".cache", "rattler"), { recursive: true }) -]); +var cleanupEnv = () => { + if (!options.runInstall) { + core2.debug("Skipping cleanup of .pixi directory."); + } + import_promises.default.rm(import_path2.default.join(import_path2.default.dirname(options.manifestPath), ".pixi"), { recursive: true }); +}; +var cleanupRattler = () => { + const rattlerPath = import_path2.default.join(os3.homedir(), ".rattler"); + const rattlerCachePath = import_path2.default.join(os3.homedir(), ".cache", "rattler"); + return Promise.all([ + import_promises.default.rm(rattlerPath, { recursive: true, force: true }), + import_promises.default.rm(rattlerCachePath, { recursive: true, force: true }) + ]); +}; var run = () => { const postCleanup = options.postCleanup; if (postCleanup) { diff --git a/src/post.ts b/src/post.ts index f4405f26..840ce919 100644 --- a/src/post.ts +++ b/src/post.ts @@ -18,13 +18,21 @@ const cleanupPixiBin = () => { }) } -const cleanupEnv = () => fs.rm(path.join(path.dirname(options.manifestPath), '.pixi'), { recursive: true }) +const cleanupEnv = () => { + if (!options.runInstall) { + core.debug('Skipping cleanup of .pixi directory.') + } + fs.rm(path.join(path.dirname(options.manifestPath), '.pixi'), { recursive: true }) +} -const cleanupRattler = () => - Promise.all([ - fs.rm(path.join(os.homedir(), '.rattler'), { recursive: true }), - fs.rm(path.join(os.homedir(), '.cache', 'rattler'), { recursive: true }) +const cleanupRattler = () => { + const rattlerPath = path.join(os.homedir(), '.rattler') + const rattlerCachePath = path.join(os.homedir(), '.cache', 'rattler') + return Promise.all([ + fs.rm(rattlerPath, { recursive: true, force: true }), + fs.rm(rattlerCachePath, { recursive: true, force: true }) ]) +} const run = () => { const postCleanup = options.postCleanup From 165561228418208f5a903d1482f83248b9da6699 Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Sat, 9 Sep 2023 18:38:34 +0200 Subject: [PATCH 43/57] . --- dist/post.js | 7 ++++++- src/post.ts | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/dist/post.js b/dist/post.js index 4a31a25a..9984f3f1 100644 --- a/dist/post.js +++ b/dist/post.js @@ -5946,8 +5946,10 @@ var options = getOptions(); var cleanupPixiBin = () => { const pixiBinPath = options.pixiBinPath; const pixiBinDir = import_path2.default.dirname(pixiBinPath); + core2.debug(`Cleaning up pixi binary ${pixiBinPath}.`); return import_promises.default.rm(options.pixiBinPath).then(() => import_promises.default.readdir(pixiBinDir)).then((files) => { if (files.length === 0) { + core2.debug(`Removing empty directory ${pixiBinDir}.`); return import_promises.default.rm(pixiBinDir); } return Promise.resolve(); @@ -5957,11 +5959,14 @@ var cleanupEnv = () => { if (!options.runInstall) { core2.debug("Skipping cleanup of .pixi directory."); } - import_promises.default.rm(import_path2.default.join(import_path2.default.dirname(options.manifestPath), ".pixi"), { recursive: true }); + const envDir = import_path2.default.join(import_path2.default.dirname(options.manifestPath), ".pixi"); + core2.debug(`Cleaning up .pixi directory ${envDir}.`); + import_promises.default.rm(envDir, { recursive: true }); }; var cleanupRattler = () => { const rattlerPath = import_path2.default.join(os3.homedir(), ".rattler"); const rattlerCachePath = import_path2.default.join(os3.homedir(), ".cache", "rattler"); + core2.debug(`Cleaning up rattler directories ${rattlerPath} and ${rattlerCachePath}.`); return Promise.all([ import_promises.default.rm(rattlerPath, { recursive: true, force: true }), import_promises.default.rm(rattlerCachePath, { recursive: true, force: true }) diff --git a/src/post.ts b/src/post.ts index 840ce919..43755252 100644 --- a/src/post.ts +++ b/src/post.ts @@ -7,11 +7,13 @@ import { options } from './options' const cleanupPixiBin = () => { const pixiBinPath = options.pixiBinPath const pixiBinDir = path.dirname(pixiBinPath) + core.debug(`Cleaning up pixi binary ${pixiBinPath}.`) return fs .rm(options.pixiBinPath) .then(() => fs.readdir(pixiBinDir)) .then((files) => { if (files.length === 0) { + core.debug(`Removing empty directory ${pixiBinDir}.`) return fs.rm(pixiBinDir) } return Promise.resolve() @@ -22,12 +24,15 @@ const cleanupEnv = () => { if (!options.runInstall) { core.debug('Skipping cleanup of .pixi directory.') } - fs.rm(path.join(path.dirname(options.manifestPath), '.pixi'), { recursive: true }) + const envDir = path.join(path.dirname(options.manifestPath), '.pixi') + core.debug(`Cleaning up .pixi directory ${envDir}.`) + fs.rm(envDir, { recursive: true }) } const cleanupRattler = () => { const rattlerPath = path.join(os.homedir(), '.rattler') const rattlerCachePath = path.join(os.homedir(), '.cache', 'rattler') + core.debug(`Cleaning up rattler directories ${rattlerPath} and ${rattlerCachePath}.`) return Promise.all([ fs.rm(rattlerPath, { recursive: true, force: true }), fs.rm(rattlerCachePath, { recursive: true, force: true }) From 1794739f0981c95f10d96c1a48ef1cc4e9d91895 Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Sat, 9 Sep 2023 18:39:57 +0200 Subject: [PATCH 44/57] . --- dist/post.js | 2 +- src/post.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/post.js b/dist/post.js index 9984f3f1..fefb1252 100644 --- a/dist/post.js +++ b/dist/post.js @@ -5950,7 +5950,7 @@ var cleanupPixiBin = () => { return import_promises.default.rm(options.pixiBinPath).then(() => import_promises.default.readdir(pixiBinDir)).then((files) => { if (files.length === 0) { core2.debug(`Removing empty directory ${pixiBinDir}.`); - return import_promises.default.rm(pixiBinDir); + return import_promises.default.rm(pixiBinDir, { recursive: true }); } return Promise.resolve(); }); diff --git a/src/post.ts b/src/post.ts index 43755252..ba0f72c5 100644 --- a/src/post.ts +++ b/src/post.ts @@ -14,7 +14,7 @@ const cleanupPixiBin = () => { .then((files) => { if (files.length === 0) { core.debug(`Removing empty directory ${pixiBinDir}.`) - return fs.rm(pixiBinDir) + return fs.rm(pixiBinDir, { recursive: true }) } return Promise.resolve() }) From e96cfbeff869ba5ce8f8df6a3cf504f69e761b89 Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Sat, 9 Sep 2023 18:47:58 +0200 Subject: [PATCH 45/57] . --- dist/post.js | 3 ++- src/post.ts | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/dist/post.js b/dist/post.js index fefb1252..d3ab0438 100644 --- a/dist/post.js +++ b/dist/post.js @@ -5958,10 +5958,11 @@ var cleanupPixiBin = () => { var cleanupEnv = () => { if (!options.runInstall) { core2.debug("Skipping cleanup of .pixi directory."); + return Promise.resolve(); } const envDir = import_path2.default.join(import_path2.default.dirname(options.manifestPath), ".pixi"); core2.debug(`Cleaning up .pixi directory ${envDir}.`); - import_promises.default.rm(envDir, { recursive: true }); + return import_promises.default.rm(envDir, { recursive: true }); }; var cleanupRattler = () => { const rattlerPath = import_path2.default.join(os3.homedir(), ".rattler"); diff --git a/src/post.ts b/src/post.ts index ba0f72c5..10792c7e 100644 --- a/src/post.ts +++ b/src/post.ts @@ -23,10 +23,11 @@ const cleanupPixiBin = () => { const cleanupEnv = () => { if (!options.runInstall) { core.debug('Skipping cleanup of .pixi directory.') + return Promise.resolve() } const envDir = path.join(path.dirname(options.manifestPath), '.pixi') core.debug(`Cleaning up .pixi directory ${envDir}.`) - fs.rm(envDir, { recursive: true }) + return fs.rm(envDir, { recursive: true }) } const cleanupRattler = () => { From d29078b29fe8923a22cab42db2bc301165bf1b3b Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Sat, 9 Sep 2023 19:01:59 +0200 Subject: [PATCH 46/57] . --- action.yml | 2 +- dist/index.js | 15 +++++++++++---- src/cache.ts | 7 +++++++ 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/action.yml b/action.yml index e406c1b0..d55b2a7d 100644 --- a/action.yml +++ b/action.yml @@ -48,7 +48,7 @@ inputs: description: Conda token to use for authentication. post-cleanup: description: | - If the action should clean up after itself. + If the action should clean up after itself. Defaults to `true`. If `true`, the pixi environment, the pixi binary and the rattler files in ~/.rattler and ~/.cache/rattler are removed. runs: diff --git a/dist/index.js b/dist/index.js index a385ec49..4e1b2083 100644 --- a/dist/index.js +++ b/dist/index.js @@ -2202,18 +2202,18 @@ Support boolean input list: \`true | True | TRUE | false | False | FALSE\``); }); } exports.group = group3; - function saveState(name, value) { + function saveState2(name, value) { const filePath = process.env["GITHUB_STATE"] || ""; if (filePath) { return file_command_1.issueFileCommand("STATE", file_command_1.prepareKeyValueMessage(name, value)); } command_1.issueCommand("save-state", { name }, utils_1.toCommandValue(value)); } - exports.saveState = saveState; - function getState(name) { + exports.saveState = saveState2; + function getState2(name) { return process.env[`STATE_${name}`] || ""; } - exports.getState = getState; + exports.getState = getState2; function getIDToken(aud) { return __awaiter(this, void 0, void 0, function* () { return yield oidc_utils_1.OidcClient.getIDToken(aud); @@ -61185,8 +61185,10 @@ var tryRestoreCache = () => { return cache.restoreCache([cachePath], cacheKey, void 0, void 0, false).then((key) => { if (key) { core3.info(`Restored cache with key \`${key}\``); + core3.saveState("cache-hit", "true"); } else { core3.info(`Cache miss`); + core3.saveState("cache-hit", "false"); } return key; }); @@ -61199,6 +61201,11 @@ var saveCache2 = () => { core3.debug("Skipping pixi cache save."); return Promise.resolve(void 0); } + const cacheHit = core3.getState("cache-hit"); + if (cacheHit === "true") { + core3.debug("Skipping pixi cache save because cache was restored."); + return Promise.resolve(void 0); + } return core3.group( "Saving pixi cache", () => generateCacheKey(cache_.cacheKeyPrefix).then( diff --git a/src/cache.ts b/src/cache.ts index 86ba7915..c2c58986 100644 --- a/src/cache.ts +++ b/src/cache.ts @@ -28,8 +28,10 @@ export const tryRestoreCache = (): Promise => { return cache.restoreCache([cachePath], cacheKey, undefined, undefined, false).then((key) => { if (key) { core.info(`Restored cache with key \`${key}\``) + core.saveState('cache-hit', 'true') } else { core.info(`Cache miss`) + core.saveState('cache-hit', 'false') } return key }) @@ -43,6 +45,11 @@ export const saveCache = () => { core.debug('Skipping pixi cache save.') return Promise.resolve(undefined) } + const cacheHit = core.getState('cache-hit') + if (cacheHit === 'true') { + core.debug('Skipping pixi cache save because cache was restored.') + return Promise.resolve(undefined) + } return core.group('Saving pixi cache', () => generateCacheKey(cache_.cacheKeyPrefix).then((cacheKey) => cache From a59c35396cce6f4710390e93bb8609f8bd4d7a3b Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Sat, 9 Sep 2023 19:11:50 +0200 Subject: [PATCH 47/57] . --- dist/index.js | 12 ++++++------ src/cache.ts | 7 ++++--- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/dist/index.js b/dist/index.js index 4e1b2083..cc863e2b 100644 --- a/dist/index.js +++ b/dist/index.js @@ -2202,14 +2202,14 @@ Support boolean input list: \`true | True | TRUE | false | False | FALSE\``); }); } exports.group = group3; - function saveState2(name, value) { + function saveState(name, value) { const filePath = process.env["GITHUB_STATE"] || ""; if (filePath) { return file_command_1.issueFileCommand("STATE", file_command_1.prepareKeyValueMessage(name, value)); } command_1.issueCommand("save-state", { name }, utils_1.toCommandValue(value)); } - exports.saveState = saveState2; + exports.saveState = saveState; function getState2(name) { return process.env[`STATE_${name}`] || ""; } @@ -61171,6 +61171,7 @@ var generateCacheKey = async (cacheKeyPrefix) => import_promises.default.readFil throw new Error(`Failed to generate cache key: ${err}`); }); var cachePath = import_path2.default.join(import_path2.default.dirname(options.pixiLockFile), ".pixi"); +var cacheHit = false; var tryRestoreCache = () => { const cache_ = options.cache; if (!cache_) { @@ -61185,10 +61186,9 @@ var tryRestoreCache = () => { return cache.restoreCache([cachePath], cacheKey, void 0, void 0, false).then((key) => { if (key) { core3.info(`Restored cache with key \`${key}\``); - core3.saveState("cache-hit", "true"); + cacheHit = true; } else { core3.info(`Cache miss`); - core3.saveState("cache-hit", "false"); } return key; }); @@ -61201,8 +61201,8 @@ var saveCache2 = () => { core3.debug("Skipping pixi cache save."); return Promise.resolve(void 0); } - const cacheHit = core3.getState("cache-hit"); - if (cacheHit === "true") { + const cacheHit2 = core3.getState("cache-hit"); + if (cacheHit2) { core3.debug("Skipping pixi cache save because cache was restored."); return Promise.resolve(void 0); } diff --git a/src/cache.ts b/src/cache.ts index c2c58986..8db868ce 100644 --- a/src/cache.ts +++ b/src/cache.ts @@ -15,6 +15,8 @@ export const generateCacheKey = async (cacheKeyPrefix: string) => const cachePath = path.join(path.dirname(options.pixiLockFile), '.pixi') +let cacheHit = false + export const tryRestoreCache = (): Promise => { const cache_ = options.cache if (!cache_) { @@ -28,10 +30,9 @@ export const tryRestoreCache = (): Promise => { return cache.restoreCache([cachePath], cacheKey, undefined, undefined, false).then((key) => { if (key) { core.info(`Restored cache with key \`${key}\``) - core.saveState('cache-hit', 'true') + cacheHit = true } else { core.info(`Cache miss`) - core.saveState('cache-hit', 'false') } return key }) @@ -46,7 +47,7 @@ export const saveCache = () => { return Promise.resolve(undefined) } const cacheHit = core.getState('cache-hit') - if (cacheHit === 'true') { + if (cacheHit) { core.debug('Skipping pixi cache save because cache was restored.') return Promise.resolve(undefined) } From 992b71a31a62b1b7762b94434e31c9ce1d0b9745 Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Sat, 9 Sep 2023 19:13:08 +0200 Subject: [PATCH 48/57] . --- .github/workflows/test.yml | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7cc7d8b6..b6c75db3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -206,11 +206,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] - include: - - post-cleanup: 'true' - invert-condition: '' - - post-cleanup: 'false' - invert-condition: '! ' + post-cleanup: [true, false] steps: - uses: actions/checkout@v4 - name: Move pixi.toml @@ -219,9 +215,9 @@ jobs: with: run: | set -euxo pipefail - ${{ matrix.invert-condition }}test -d .pixi - ${{ matrix.invert-condition }}test -d ~/.cache/rattler - ${{ matrix.invert-condition }}test -f ~/.pixi + ${{ matrix.post-cleanup == 'true' && '! ' || '' }}test -d .pixi + ${{ matrix.post-cleanup == 'true' && '! ' || '' }}test -d ~/.cache/rattler + ${{ matrix.post-cleanup == 'true' && '! ' || '' }}test -f ~/.pixi - uses: ./ with: post-cleanup: ${{ matrix.post-cleanup }} From 789df0d0efe7562126b92f0ae65e2c375ac5f60d Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Sat, 9 Sep 2023 19:14:12 +0200 Subject: [PATCH 49/57] . --- .github/workflows/test.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b6c75db3..a30e954e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -201,7 +201,6 @@ jobs: shell: pixi run bash {0} post-cleanup: - name: post-cleanup ${{ matrix.post-cleanup }} runs-on: ${{ matrix.os }} strategy: matrix: From bdfc8120424e4519faf047004ec679c9f8294aea Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Sat, 9 Sep 2023 19:20:00 +0200 Subject: [PATCH 50/57] . --- dist/index.js | 7 +++---- src/cache.ts | 1 - 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/dist/index.js b/dist/index.js index cc863e2b..253bb696 100644 --- a/dist/index.js +++ b/dist/index.js @@ -2210,10 +2210,10 @@ Support boolean input list: \`true | True | TRUE | false | False | FALSE\``); command_1.issueCommand("save-state", { name }, utils_1.toCommandValue(value)); } exports.saveState = saveState; - function getState2(name) { + function getState(name) { return process.env[`STATE_${name}`] || ""; } - exports.getState = getState2; + exports.getState = getState; function getIDToken(aud) { return __awaiter(this, void 0, void 0, function* () { return yield oidc_utils_1.OidcClient.getIDToken(aud); @@ -61201,8 +61201,7 @@ var saveCache2 = () => { core3.debug("Skipping pixi cache save."); return Promise.resolve(void 0); } - const cacheHit2 = core3.getState("cache-hit"); - if (cacheHit2) { + if (cacheHit) { core3.debug("Skipping pixi cache save because cache was restored."); return Promise.resolve(void 0); } diff --git a/src/cache.ts b/src/cache.ts index 8db868ce..88e4b701 100644 --- a/src/cache.ts +++ b/src/cache.ts @@ -46,7 +46,6 @@ export const saveCache = () => { core.debug('Skipping pixi cache save.') return Promise.resolve(undefined) } - const cacheHit = core.getState('cache-hit') if (cacheHit) { core.debug('Skipping pixi cache save because cache was restored.') return Promise.resolve(undefined) From a83418c19c11e72a0aeb5ae1e53e1cad050faea5 Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Sat, 9 Sep 2023 19:28:08 +0200 Subject: [PATCH 51/57] recurse --- dist/post.js | 22 +++++++++++++++------- src/post.ts | 26 ++++++++++++++++---------- 2 files changed, 31 insertions(+), 17 deletions(-) diff --git a/dist/post.js b/dist/post.js index d3ab0438..5feae11d 100644 --- a/dist/post.js +++ b/dist/post.js @@ -5943,18 +5943,26 @@ var getOptions = () => { var options = getOptions(); // src/post.ts -var cleanupPixiBin = () => { - const pixiBinPath = options.pixiBinPath; - const pixiBinDir = import_path2.default.dirname(pixiBinPath); - core2.debug(`Cleaning up pixi binary ${pixiBinPath}.`); - return import_promises.default.rm(options.pixiBinPath).then(() => import_promises.default.readdir(pixiBinDir)).then((files) => { +var removeEmptyParentDirs = (dirPath) => { + return import_promises.default.readdir(dirPath).then((files) => { if (files.length === 0) { - core2.debug(`Removing empty directory ${pixiBinDir}.`); - return import_promises.default.rm(pixiBinDir, { recursive: true }); + core2.debug(`Removing empty directory ${dirPath}.`); + return import_promises.default.rm(dirPath, { recursive: true }).then(() => { + const parentDir = import_path2.default.dirname(dirPath); + if (parentDir !== dirPath) { + return removeEmptyParentDirs(parentDir); + } + }); } return Promise.resolve(); }); }; +var cleanupPixiBin = () => { + const pixiBinPath = options.pixiBinPath; + const pixiBinDir = import_path2.default.dirname(pixiBinPath); + core2.debug(`Cleaning up pixi binary ${pixiBinPath}.`); + return import_promises.default.rm(pixiBinPath).then(() => removeEmptyParentDirs(pixiBinDir)); +}; var cleanupEnv = () => { if (!options.runInstall) { core2.debug("Skipping cleanup of .pixi directory."); diff --git a/src/post.ts b/src/post.ts index 10792c7e..3cafd9c4 100644 --- a/src/post.ts +++ b/src/post.ts @@ -4,20 +4,26 @@ import * as os from 'os' import * as core from '@actions/core' import { options } from './options' +const removeEmptyParentDirs = (dirPath: string): Promise => { + return fs.readdir(dirPath).then((files) => { + if (files.length === 0) { + core.debug(`Removing empty directory ${dirPath}.`) + return fs.rm(dirPath, { recursive: true }).then(() => { + const parentDir = path.dirname(dirPath) + if (parentDir !== dirPath) { + return removeEmptyParentDirs(parentDir) + } + }) + } + return Promise.resolve() + }) +} + const cleanupPixiBin = () => { const pixiBinPath = options.pixiBinPath const pixiBinDir = path.dirname(pixiBinPath) core.debug(`Cleaning up pixi binary ${pixiBinPath}.`) - return fs - .rm(options.pixiBinPath) - .then(() => fs.readdir(pixiBinDir)) - .then((files) => { - if (files.length === 0) { - core.debug(`Removing empty directory ${pixiBinDir}.`) - return fs.rm(pixiBinDir, { recursive: true }) - } - return Promise.resolve() - }) + return fs.rm(pixiBinPath).then(() => removeEmptyParentDirs(pixiBinDir)) } const cleanupEnv = () => { From ff5c41c25e7cc34599b3d40eb60200e12ab5f06d Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Sat, 9 Sep 2023 19:30:04 +0200 Subject: [PATCH 52/57] . --- .github/workflows/test.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a30e954e..a08e994e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -205,7 +205,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] - post-cleanup: [true, false] + post-cleanup: ['true', 'false'] steps: - uses: actions/checkout@v4 - name: Move pixi.toml @@ -215,11 +215,17 @@ jobs: run: | set -euxo pipefail ${{ matrix.post-cleanup == 'true' && '! ' || '' }}test -d .pixi + ${{ matrix.post-cleanup == 'true' && '! ' || '' }}test -d ~/.rattler ${{ matrix.post-cleanup == 'true' && '! ' || '' }}test -d ~/.cache/rattler - ${{ matrix.post-cleanup == 'true' && '! ' || '' }}test -f ~/.pixi + ${{ matrix.post-cleanup == 'true' && '! ' || '' }}test -f ~/.pixi/ - uses: ./ with: post-cleanup: ${{ matrix.post-cleanup }} + - run: | + mkdir -p ~/.rattler + mkdir -p ~/.cache/rattler + # + shell: bash no-lockfile: strategy: From 0599410fa2260999ccc62d80528a4beb4a651f93 Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Sat, 9 Sep 2023 19:36:18 +0200 Subject: [PATCH 53/57] . --- .github/workflows/test.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a08e994e..b7c1d4c0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -217,14 +217,13 @@ jobs: ${{ matrix.post-cleanup == 'true' && '! ' || '' }}test -d .pixi ${{ matrix.post-cleanup == 'true' && '! ' || '' }}test -d ~/.rattler ${{ matrix.post-cleanup == 'true' && '! ' || '' }}test -d ~/.cache/rattler - ${{ matrix.post-cleanup == 'true' && '! ' || '' }}test -f ~/.pixi/ + ${{ matrix.post-cleanup == 'true' && '! ' || '' }}test -f ~/.pixi/bin/pixi - uses: ./ with: post-cleanup: ${{ matrix.post-cleanup }} - run: | mkdir -p ~/.rattler - mkdir -p ~/.cache/rattler - # + # ~/.rattler is only created if the user has logged in and os is linux shell: bash no-lockfile: From db787929f432ae78b33adbf75c2ed5db94c79e82 Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Sat, 9 Sep 2023 19:44:48 +0200 Subject: [PATCH 54/57] . --- .github/workflows/test.yml | 148 ++++++++++++++++++++----------------- dist/post.js | 3 +- src/post.ts | 3 +- 3 files changed, 83 insertions(+), 71 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b7c1d4c0..2c8d00bf 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -211,6 +211,7 @@ jobs: - name: Move pixi.toml run: mv test/default/* . - uses: lisanna-dettwyler/action-post-run@d053b9b43d788b87a409f6cdb3b6fc87c6c8a4fe + if: matrix.os != 'windows-latest' with: run: | set -euxo pipefail @@ -218,13 +219,22 @@ jobs: ${{ matrix.post-cleanup == 'true' && '! ' || '' }}test -d ~/.rattler ${{ matrix.post-cleanup == 'true' && '! ' || '' }}test -d ~/.cache/rattler ${{ matrix.post-cleanup == 'true' && '! ' || '' }}test -f ~/.pixi/bin/pixi - - uses: ./ - with: - post-cleanup: ${{ matrix.post-cleanup }} - run: | mkdir -p ~/.rattler + if: matrix.os != 'windows-latest' # ~/.rattler is only created if the user has logged in and os is linux - shell: bash + - uses: lisanna-dettwyler/action-post-run@d053b9b43d788b87a409f6cdb3b6fc87c6c8a4fe + if: matrix.os == 'windows-latest' + with: + run: | + set -euxo pipefail + ${{ matrix.post-cleanup == 'true' && '! ' || '' }}test -d .pixi + ${{ matrix.post-cleanup == 'true' && '! ' || '' }}test -d "$TEMP/rattler" + ${{ matrix.post-cleanup == 'true' && '! ' || '' }}test -f ~/.pixi/bin/pixi + - uses: ./ + with: + post-cleanup: ${{ matrix.post-cleanup }} + no-lockfile: strategy: @@ -254,73 +264,73 @@ jobs: pixi run python --version | grep -q 3.11 pixi run test | grep -q "Hello world" - test-cache1: - name: Test cache 1/2 - timeout-minutes: 10 - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [windows-latest, ubuntu-latest, macos-latest] - steps: - - uses: actions/checkout@v4 - - name: Move pixi files - run: mv test/default/* . - - uses: ./ - with: - cache: true - cache-key: test-cache-${{ github.sha }}-${{ github.run_attempt }}- - # check the action logs to see if the cache was written - - run: | - test -f .pixi/env/bin/python - if: matrix.os != 'windows-latest' - - run: | - test -f .pixi/env/python.exe - if: matrix.os == 'windows-latest' + # test-cache1: + # name: Test cache 1/2 + # timeout-minutes: 10 + # runs-on: ${{ matrix.os }} + # strategy: + # fail-fast: false + # matrix: + # os: [windows-latest, ubuntu-latest, macos-latest] + # steps: + # - uses: actions/checkout@v4 + # - name: Move pixi files + # run: mv test/default/* . + # - uses: ./ + # with: + # cache: true + # cache-key: test-cache-${{ github.sha }}-${{ github.run_attempt }}- + # # check the action logs to see if the cache was written + # - run: | + # test -f .pixi/env/bin/python + # if: matrix.os != 'windows-latest' + # - run: | + # test -f .pixi/env/python.exe + # if: matrix.os == 'windows-latest' - test-cache2: - name: Test cache 2/2 - timeout-minutes: 10 - needs: test-cache1 - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [windows-latest, ubuntu-latest, macos-latest] - steps: - - uses: actions/checkout@v4 - - name: Move pixi files - run: mv test/default/* . - - uses: ./ - with: - cache: true - cache-key: test-cache-${{ github.sha }}-${{ github.run_attempt }}- - # check the action logs to see if the cache was restored - - run: | - test -f .pixi/env/bin/python - if: matrix.os != 'windows-latest' - - run: | - test -f .pixi/env/python.exe - if: matrix.os == 'windows-latest' + # test-cache2: + # name: Test cache 2/2 + # timeout-minutes: 10 + # needs: test-cache1 + # runs-on: ${{ matrix.os }} + # strategy: + # fail-fast: false + # matrix: + # os: [windows-latest, ubuntu-latest, macos-latest] + # steps: + # - uses: actions/checkout@v4 + # - name: Move pixi files + # run: mv test/default/* . + # - uses: ./ + # with: + # cache: true + # cache-key: test-cache-${{ github.sha }}-${{ github.run_attempt }}- + # # check the action logs to see if the cache was restored + # - run: | + # test -f .pixi/env/bin/python + # if: matrix.os != 'windows-latest' + # - run: | + # test -f .pixi/env/python.exe + # if: matrix.os == 'windows-latest' - test-cache-no-write: - name: Test cache no write - timeout-minutes: 10 - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [windows-latest, ubuntu-latest, macos-latest] - steps: - - uses: actions/checkout@v4 - - name: Move pixi files - run: mv test/default/* . - - uses: ./ - with: - cache: true - cache-write: false - cache-key: test-cache-${{ github.sha }}-${{ github.run_attempt }}- - # check the action logs to see if the cache write was skipped + # test-cache-no-write: + # name: Test cache no write + # timeout-minutes: 10 + # runs-on: ${{ matrix.os }} + # strategy: + # fail-fast: false + # matrix: + # os: [windows-latest, ubuntu-latest, macos-latest] + # steps: + # - uses: actions/checkout@v4 + # - name: Move pixi files + # run: mv test/default/* . + # - uses: ./ + # with: + # cache: true + # cache-write: false + # cache-key: test-cache-${{ github.sha }}-${{ github.run_attempt }}- + # # check the action logs to see if the cache write was skipped # not properly testable # https://github.com/actions/runner/issues/2347 diff --git a/dist/post.js b/dist/post.js index 5feae11d..fd90d39b 100644 --- a/dist/post.js +++ b/dist/post.js @@ -5974,7 +5974,8 @@ var cleanupEnv = () => { }; var cleanupRattler = () => { const rattlerPath = import_path2.default.join(os3.homedir(), ".rattler"); - const rattlerCachePath = import_path2.default.join(os3.homedir(), ".cache", "rattler"); + const xdgCacheHome = os3.platform() !== "win32" ? import_path2.default.join(os3.homedir(), ".cache") : process.env.TEMP; + const rattlerCachePath = import_path2.default.join(xdgCacheHome, "rattler"); core2.debug(`Cleaning up rattler directories ${rattlerPath} and ${rattlerCachePath}.`); return Promise.all([ import_promises.default.rm(rattlerPath, { recursive: true, force: true }), diff --git a/src/post.ts b/src/post.ts index 3cafd9c4..3797ab21 100644 --- a/src/post.ts +++ b/src/post.ts @@ -38,7 +38,8 @@ const cleanupEnv = () => { const cleanupRattler = () => { const rattlerPath = path.join(os.homedir(), '.rattler') - const rattlerCachePath = path.join(os.homedir(), '.cache', 'rattler') + const xdgCacheHome = os.platform() !== 'win32' ? path.join(os.homedir(), '.cache') : process.env.TEMP! + const rattlerCachePath = path.join(xdgCacheHome, 'rattler') core.debug(`Cleaning up rattler directories ${rattlerPath} and ${rattlerCachePath}.`) return Promise.all([ fs.rm(rattlerPath, { recursive: true, force: true }), From bb215564e4cde66505f0b06518063482aeff2112 Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Sat, 9 Sep 2023 19:53:11 +0200 Subject: [PATCH 55/57] . --- .github/workflows/test.yml | 45 +++++++++++++++++++++++++++++--------- dist/post.js | 13 +++++++++-- src/post.ts | 15 +++++++++++-- 3 files changed, 59 insertions(+), 14 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2c8d00bf..fa683bd9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -200,18 +200,16 @@ jobs: python --version | grep -q "3.11" shell: pixi run bash {0} - post-cleanup: - runs-on: ${{ matrix.os }} + post-cleanup-linux: + runs-on: ubuntu-latest strategy: matrix: - os: [ubuntu-latest, macos-latest, windows-latest] post-cleanup: ['true', 'false'] steps: - uses: actions/checkout@v4 - name: Move pixi.toml run: mv test/default/* . - uses: lisanna-dettwyler/action-post-run@d053b9b43d788b87a409f6cdb3b6fc87c6c8a4fe - if: matrix.os != 'windows-latest' with: run: | set -euxo pipefail @@ -219,22 +217,49 @@ jobs: ${{ matrix.post-cleanup == 'true' && '! ' || '' }}test -d ~/.rattler ${{ matrix.post-cleanup == 'true' && '! ' || '' }}test -d ~/.cache/rattler ${{ matrix.post-cleanup == 'true' && '! ' || '' }}test -f ~/.pixi/bin/pixi - - run: | - mkdir -p ~/.rattler - if: matrix.os != 'windows-latest' - # ~/.rattler is only created if the user has logged in and os is linux + - uses: ./ + with: + post-cleanup: ${{ matrix.post-cleanup }} + + post-cleanup-macos: + runs-on: macos-latest + strategy: + matrix: + post-cleanup: ['true', 'false'] + steps: + - uses: actions/checkout@v4 + - name: Move pixi.toml + run: mv test/default/* . - uses: lisanna-dettwyler/action-post-run@d053b9b43d788b87a409f6cdb3b6fc87c6c8a4fe - if: matrix.os == 'windows-latest' with: run: | set -euxo pipefail ${{ matrix.post-cleanup == 'true' && '! ' || '' }}test -d .pixi - ${{ matrix.post-cleanup == 'true' && '! ' || '' }}test -d "$TEMP/rattler" + ${{ matrix.post-cleanup == 'true' && '! ' || '' }}test -d ~/Library/Caches/rattler ${{ matrix.post-cleanup == 'true' && '! ' || '' }}test -f ~/.pixi/bin/pixi - uses: ./ with: post-cleanup: ${{ matrix.post-cleanup }} + post-cleanup-windows: + runs-on: windows-latest + strategy: + matrix: + post-cleanup: ['true', 'false'] + steps: + - uses: actions/checkout@v4 + - name: Move pixi.toml + run: mv test/default/* . + - uses: lisanna-dettwyler/action-post-run@d053b9b43d788b87a409f6cdb3b6fc87c6c8a4fe + with: + run: | + set -euxo pipefail + ${{ matrix.post-cleanup == 'true' && '! ' || '' }}test -d .pixi + ${{ matrix.post-cleanup == 'true' && '! ' || '' }}test -d "$LOCALAPPDATA/rattler" + ${{ matrix.post-cleanup == 'true' && '! ' || '' }}test -f ~/.pixi/bin/pixi + - uses: ./ + with: + post-cleanup: ${{ matrix.post-cleanup }} no-lockfile: strategy: diff --git a/dist/post.js b/dist/post.js index fd90d39b..dc4c39f5 100644 --- a/dist/post.js +++ b/dist/post.js @@ -5972,10 +5972,19 @@ var cleanupEnv = () => { core2.debug(`Cleaning up .pixi directory ${envDir}.`); return import_promises.default.rm(envDir, { recursive: true }); }; +var determineCacheDir = () => { + if (os3.platform() === "win32") { + return process.env.LOCALAPPDATA; + } + if (os3.platform() === "linux") { + return process.env.XDG_CACHE_HOME ?? import_path2.default.join(os3.homedir(), ".cache"); + } + return import_path2.default.join(os3.homedir(), "Library", "Caches"); +}; var cleanupRattler = () => { const rattlerPath = import_path2.default.join(os3.homedir(), ".rattler"); - const xdgCacheHome = os3.platform() !== "win32" ? import_path2.default.join(os3.homedir(), ".cache") : process.env.TEMP; - const rattlerCachePath = import_path2.default.join(xdgCacheHome, "rattler"); + const cacheDir = determineCacheDir(); + const rattlerCachePath = import_path2.default.join(cacheDir, "rattler"); core2.debug(`Cleaning up rattler directories ${rattlerPath} and ${rattlerCachePath}.`); return Promise.all([ import_promises.default.rm(rattlerPath, { recursive: true, force: true }), diff --git a/src/post.ts b/src/post.ts index 3797ab21..d62cfecb 100644 --- a/src/post.ts +++ b/src/post.ts @@ -36,10 +36,21 @@ const cleanupEnv = () => { return fs.rm(envDir, { recursive: true }) } +const determineCacheDir = () => { + // rattler uses dirs::cache_dir https://docs.rs/dirs/latest/dirs/fn.cache_dir.html + if (os.platform() === 'win32') { + return process.env.LOCALAPPDATA! + } + if (os.platform() === 'linux') { + return process.env.XDG_CACHE_HOME ?? path.join(os.homedir(), '.cache') + } + return path.join(os.homedir(), 'Library', 'Caches') +} + const cleanupRattler = () => { const rattlerPath = path.join(os.homedir(), '.rattler') - const xdgCacheHome = os.platform() !== 'win32' ? path.join(os.homedir(), '.cache') : process.env.TEMP! - const rattlerCachePath = path.join(xdgCacheHome, 'rattler') + const cacheDir = determineCacheDir() + const rattlerCachePath = path.join(cacheDir, 'rattler') core.debug(`Cleaning up rattler directories ${rattlerPath} and ${rattlerCachePath}.`) return Promise.all([ fs.rm(rattlerPath, { recursive: true, force: true }), From 26fe3d175ea681cda616328d7917253a26e7520b Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Sat, 9 Sep 2023 19:55:29 +0200 Subject: [PATCH 56/57] . --- .github/workflows/test.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fa683bd9..71e7d38a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -220,6 +220,30 @@ jobs: - uses: ./ with: post-cleanup: ${{ matrix.post-cleanup }} + # ~/.rattler is only created if the user has logged in + auth-host: https://custom-conda-registry.com + auth-token: custom-token + + post-cleanup-linux-no-login: + runs-on: ubuntu-latest + strategy: + matrix: + post-cleanup: ['true', 'false'] + steps: + - uses: actions/checkout@v4 + - name: Move pixi.toml + run: mv test/default/* . + - uses: lisanna-dettwyler/action-post-run@d053b9b43d788b87a409f6cdb3b6fc87c6c8a4fe + with: + run: | + set -euxo pipefail + ${{ matrix.post-cleanup == 'true' && '! ' || '' }}test -d .pixi + ! test -d ~/.rattler + ${{ matrix.post-cleanup == 'true' && '! ' || '' }}test -d ~/.cache/rattler + ${{ matrix.post-cleanup == 'true' && '! ' || '' }}test -f ~/.pixi/bin/pixi + - uses: ./ + with: + post-cleanup: ${{ matrix.post-cleanup }} post-cleanup-macos: runs-on: macos-latest From 42b5c5a3dd71f2a8dc90bda501d514b2533c2f37 Mon Sep 17 00:00:00 2001 From: Pavel Zwerschke Date: Sat, 9 Sep 2023 19:56:48 +0200 Subject: [PATCH 57/57] . --- .github/workflows/test.yml | 130 ++++++++++++++++++------------------- 1 file changed, 65 insertions(+), 65 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 71e7d38a..aceaacb8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -313,73 +313,73 @@ jobs: pixi run python --version | grep -q 3.11 pixi run test | grep -q "Hello world" - # test-cache1: - # name: Test cache 1/2 - # timeout-minutes: 10 - # runs-on: ${{ matrix.os }} - # strategy: - # fail-fast: false - # matrix: - # os: [windows-latest, ubuntu-latest, macos-latest] - # steps: - # - uses: actions/checkout@v4 - # - name: Move pixi files - # run: mv test/default/* . - # - uses: ./ - # with: - # cache: true - # cache-key: test-cache-${{ github.sha }}-${{ github.run_attempt }}- - # # check the action logs to see if the cache was written - # - run: | - # test -f .pixi/env/bin/python - # if: matrix.os != 'windows-latest' - # - run: | - # test -f .pixi/env/python.exe - # if: matrix.os == 'windows-latest' + test-cache1: + name: Test cache 1/2 + timeout-minutes: 10 + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [windows-latest, ubuntu-latest, macos-latest] + steps: + - uses: actions/checkout@v4 + - name: Move pixi files + run: mv test/default/* . + - uses: ./ + with: + cache: true + cache-key: test-cache-${{ github.sha }}-${{ github.run_attempt }}- + # check the action logs to see if the cache was written + - run: | + test -f .pixi/env/bin/python + if: matrix.os != 'windows-latest' + - run: | + test -f .pixi/env/python.exe + if: matrix.os == 'windows-latest' - # test-cache2: - # name: Test cache 2/2 - # timeout-minutes: 10 - # needs: test-cache1 - # runs-on: ${{ matrix.os }} - # strategy: - # fail-fast: false - # matrix: - # os: [windows-latest, ubuntu-latest, macos-latest] - # steps: - # - uses: actions/checkout@v4 - # - name: Move pixi files - # run: mv test/default/* . - # - uses: ./ - # with: - # cache: true - # cache-key: test-cache-${{ github.sha }}-${{ github.run_attempt }}- - # # check the action logs to see if the cache was restored - # - run: | - # test -f .pixi/env/bin/python - # if: matrix.os != 'windows-latest' - # - run: | - # test -f .pixi/env/python.exe - # if: matrix.os == 'windows-latest' + test-cache2: + name: Test cache 2/2 + timeout-minutes: 10 + needs: test-cache1 + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [windows-latest, ubuntu-latest, macos-latest] + steps: + - uses: actions/checkout@v4 + - name: Move pixi files + run: mv test/default/* . + - uses: ./ + with: + cache: true + cache-key: test-cache-${{ github.sha }}-${{ github.run_attempt }}- + # check the action logs to see if the cache was restored + - run: | + test -f .pixi/env/bin/python + if: matrix.os != 'windows-latest' + - run: | + test -f .pixi/env/python.exe + if: matrix.os == 'windows-latest' - # test-cache-no-write: - # name: Test cache no write - # timeout-minutes: 10 - # runs-on: ${{ matrix.os }} - # strategy: - # fail-fast: false - # matrix: - # os: [windows-latest, ubuntu-latest, macos-latest] - # steps: - # - uses: actions/checkout@v4 - # - name: Move pixi files - # run: mv test/default/* . - # - uses: ./ - # with: - # cache: true - # cache-write: false - # cache-key: test-cache-${{ github.sha }}-${{ github.run_attempt }}- - # # check the action logs to see if the cache write was skipped + test-cache-no-write: + name: Test cache no write + timeout-minutes: 10 + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [windows-latest, ubuntu-latest, macos-latest] + steps: + - uses: actions/checkout@v4 + - name: Move pixi files + run: mv test/default/* . + - uses: ./ + with: + cache: true + cache-write: false + cache-key: test-cache-${{ github.sha }}-${{ github.run_attempt }}- + # check the action logs to see if the cache write was skipped # not properly testable # https://github.com/actions/runner/issues/2347