From e08fb3abcf631e0486eea6392e22ae1a8b97bd6b Mon Sep 17 00:00:00 2001 From: jdalton Date: Mon, 6 Apr 2026 17:18:14 -0400 Subject: [PATCH 1/2] fix(deps): bump vite to 7.3.2 (security) --- pnpm-lock.yaml | 288 ++++++++++++++++++++++++++++++++++++++++++-- pnpm-workspace.yaml | 2 +- 2 files changed, 279 insertions(+), 11 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f4037488b..4ebabd334 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -297,7 +297,7 @@ overrides: tiny-colors: 2.1.3 typedarray: npm:@socketregistry/typedarray@^1.0.8 undici: 6.21.3 - vite: 7.1.12 + vite: 7.3.2 wrap-ansi: 9.0.2 xml2js: 0.6.2 yaml: 2.8.1 @@ -1011,156 +1011,312 @@ packages: cpu: [ppc64] os: [aix] + '@esbuild/aix-ppc64@0.27.4': + resolution: {integrity: sha512-cQPwL2mp2nSmHHJlCyoXgHGhbEPMrEEU5xhkcy3Hs/O7nGZqEpZ2sUtLaL9MORLtDfRvVl2/3PAuEkYZH0Ty8Q==} + engines: {node: '>=18'} + cpu: [ppc64] + os: [aix] + '@esbuild/android-arm64@0.25.11': resolution: {integrity: sha512-9slpyFBc4FPPz48+f6jyiXOx/Y4v34TUeDDXJpZqAWQn/08lKGeD8aDp9TMn9jDz2CiEuHwfhRmGBvpnd/PWIQ==} engines: {node: '>=18'} cpu: [arm64] os: [android] + '@esbuild/android-arm64@0.27.4': + resolution: {integrity: sha512-gdLscB7v75wRfu7QSm/zg6Rx29VLdy9eTr2t44sfTW7CxwAtQghZ4ZnqHk3/ogz7xao0QAgrkradbBzcqFPasw==} + engines: {node: '>=18'} + cpu: [arm64] + os: [android] + '@esbuild/android-arm@0.25.11': resolution: {integrity: sha512-uoa7dU+Dt3HYsethkJ1k6Z9YdcHjTrSb5NUy66ZfZaSV8hEYGD5ZHbEMXnqLFlbBflLsl89Zke7CAdDJ4JI+Gg==} engines: {node: '>=18'} cpu: [arm] os: [android] + '@esbuild/android-arm@0.27.4': + resolution: {integrity: sha512-X9bUgvxiC8CHAGKYufLIHGXPJWnr0OCdR0anD2e21vdvgCI8lIfqFbnoeOz7lBjdrAGUhqLZLcQo6MLhTO2DKQ==} + engines: {node: '>=18'} + cpu: [arm] + os: [android] + '@esbuild/android-x64@0.25.11': resolution: {integrity: sha512-Sgiab4xBjPU1QoPEIqS3Xx+R2lezu0LKIEcYe6pftr56PqPygbB7+szVnzoShbx64MUupqoE0KyRlN7gezbl8g==} engines: {node: '>=18'} cpu: [x64] os: [android] + '@esbuild/android-x64@0.27.4': + resolution: {integrity: sha512-PzPFnBNVF292sfpfhiyiXCGSn9HZg5BcAz+ivBuSsl6Rk4ga1oEXAamhOXRFyMcjwr2DVtm40G65N3GLeH1Lvw==} + engines: {node: '>=18'} + cpu: [x64] + os: [android] + '@esbuild/darwin-arm64@0.25.11': resolution: {integrity: sha512-VekY0PBCukppoQrycFxUqkCojnTQhdec0vevUL/EDOCnXd9LKWqD/bHwMPzigIJXPhC59Vd1WFIL57SKs2mg4w==} engines: {node: '>=18'} cpu: [arm64] os: [darwin] + '@esbuild/darwin-arm64@0.27.4': + resolution: {integrity: sha512-b7xaGIwdJlht8ZFCvMkpDN6uiSmnxxK56N2GDTMYPr2/gzvfdQN8rTfBsvVKmIVY/X7EM+/hJKEIbbHs9oA4tQ==} + engines: {node: '>=18'} + cpu: [arm64] + os: [darwin] + '@esbuild/darwin-x64@0.25.11': resolution: {integrity: sha512-+hfp3yfBalNEpTGp9loYgbknjR695HkqtY3d3/JjSRUyPg/xd6q+mQqIb5qdywnDxRZykIHs3axEqU6l1+oWEQ==} engines: {node: '>=18'} cpu: [x64] os: [darwin] + '@esbuild/darwin-x64@0.27.4': + resolution: {integrity: sha512-sR+OiKLwd15nmCdqpXMnuJ9W2kpy0KigzqScqHI3Hqwr7IXxBp3Yva+yJwoqh7rE8V77tdoheRYataNKL4QrPw==} + engines: {node: '>=18'} + cpu: [x64] + os: [darwin] + '@esbuild/freebsd-arm64@0.25.11': resolution: {integrity: sha512-CmKjrnayyTJF2eVuO//uSjl/K3KsMIeYeyN7FyDBjsR3lnSJHaXlVoAK8DZa7lXWChbuOk7NjAc7ygAwrnPBhA==} engines: {node: '>=18'} cpu: [arm64] os: [freebsd] + '@esbuild/freebsd-arm64@0.27.4': + resolution: {integrity: sha512-jnfpKe+p79tCnm4GVav68A7tUFeKQwQyLgESwEAUzyxk/TJr4QdGog9sqWNcUbr/bZt/O/HXouspuQDd9JxFSw==} + engines: {node: '>=18'} + cpu: [arm64] + os: [freebsd] + '@esbuild/freebsd-x64@0.25.11': resolution: {integrity: sha512-Dyq+5oscTJvMaYPvW3x3FLpi2+gSZTCE/1ffdwuM6G1ARang/mb3jvjxs0mw6n3Lsw84ocfo9CrNMqc5lTfGOw==} engines: {node: '>=18'} cpu: [x64] os: [freebsd] + '@esbuild/freebsd-x64@0.27.4': + resolution: {integrity: sha512-2kb4ceA/CpfUrIcTUl1wrP/9ad9Atrp5J94Lq69w7UwOMolPIGrfLSvAKJp0RTvkPPyn6CIWrNy13kyLikZRZQ==} + engines: {node: '>=18'} + cpu: [x64] + os: [freebsd] + '@esbuild/linux-arm64@0.25.11': resolution: {integrity: sha512-Qr8AzcplUhGvdyUF08A1kHU3Vr2O88xxP0Tm8GcdVOUm25XYcMPp2YqSVHbLuXzYQMf9Bh/iKx7YPqECs6ffLA==} engines: {node: '>=18'} cpu: [arm64] os: [linux] + '@esbuild/linux-arm64@0.27.4': + resolution: {integrity: sha512-7nQOttdzVGth1iz57kxg9uCz57dxQLHWxopL6mYuYthohPKEK0vU0C3O21CcBK6KDlkYVcnDXY099HcCDXd9dA==} + engines: {node: '>=18'} + cpu: [arm64] + os: [linux] + '@esbuild/linux-arm@0.25.11': resolution: {integrity: sha512-TBMv6B4kCfrGJ8cUPo7vd6NECZH/8hPpBHHlYI3qzoYFvWu2AdTvZNuU/7hsbKWqu/COU7NIK12dHAAqBLLXgw==} engines: {node: '>=18'} cpu: [arm] os: [linux] + '@esbuild/linux-arm@0.27.4': + resolution: {integrity: sha512-aBYgcIxX/wd5n2ys0yESGeYMGF+pv6g0DhZr3G1ZG4jMfruU9Tl1i2Z+Wnj9/KjGz1lTLCcorqE2viePZqj4Eg==} + engines: {node: '>=18'} + cpu: [arm] + os: [linux] + '@esbuild/linux-ia32@0.25.11': resolution: {integrity: sha512-TmnJg8BMGPehs5JKrCLqyWTVAvielc615jbkOirATQvWWB1NMXY77oLMzsUjRLa0+ngecEmDGqt5jiDC6bfvOw==} engines: {node: '>=18'} cpu: [ia32] os: [linux] + '@esbuild/linux-ia32@0.27.4': + resolution: {integrity: sha512-oPtixtAIzgvzYcKBQM/qZ3R+9TEUd1aNJQu0HhGyqtx6oS7qTpvjheIWBbes4+qu1bNlo2V4cbkISr8q6gRBFA==} + engines: {node: '>=18'} + cpu: [ia32] + os: [linux] + '@esbuild/linux-loong64@0.25.11': resolution: {integrity: sha512-DIGXL2+gvDaXlaq8xruNXUJdT5tF+SBbJQKbWy/0J7OhU8gOHOzKmGIlfTTl6nHaCOoipxQbuJi7O++ldrxgMw==} engines: {node: '>=18'} cpu: [loong64] os: [linux] + '@esbuild/linux-loong64@0.27.4': + resolution: {integrity: sha512-8mL/vh8qeCoRcFH2nM8wm5uJP+ZcVYGGayMavi8GmRJjuI3g1v6Z7Ni0JJKAJW+m0EtUuARb6Lmp4hMjzCBWzA==} + engines: {node: '>=18'} + cpu: [loong64] + os: [linux] + '@esbuild/linux-mips64el@0.25.11': resolution: {integrity: sha512-Osx1nALUJu4pU43o9OyjSCXokFkFbyzjXb6VhGIJZQ5JZi8ylCQ9/LFagolPsHtgw6himDSyb5ETSfmp4rpiKQ==} engines: {node: '>=18'} cpu: [mips64el] os: [linux] + '@esbuild/linux-mips64el@0.27.4': + resolution: {integrity: sha512-1RdrWFFiiLIW7LQq9Q2NES+HiD4NyT8Itj9AUeCl0IVCA459WnPhREKgwrpaIfTOe+/2rdntisegiPWn/r/aAw==} + engines: {node: '>=18'} + cpu: [mips64el] + os: [linux] + '@esbuild/linux-ppc64@0.25.11': resolution: {integrity: sha512-nbLFgsQQEsBa8XSgSTSlrnBSrpoWh7ioFDUmwo158gIm5NNP+17IYmNWzaIzWmgCxq56vfr34xGkOcZ7jX6CPw==} engines: {node: '>=18'} cpu: [ppc64] os: [linux] + '@esbuild/linux-ppc64@0.27.4': + resolution: {integrity: sha512-tLCwNG47l3sd9lpfyx9LAGEGItCUeRCWeAx6x2Jmbav65nAwoPXfewtAdtbtit/pJFLUWOhpv0FpS6GQAmPrHA==} + engines: {node: '>=18'} + cpu: [ppc64] + os: [linux] + '@esbuild/linux-riscv64@0.25.11': resolution: {integrity: sha512-HfyAmqZi9uBAbgKYP1yGuI7tSREXwIb438q0nqvlpxAOs3XnZ8RsisRfmVsgV486NdjD7Mw2UrFSw51lzUk1ww==} engines: {node: '>=18'} cpu: [riscv64] os: [linux] + '@esbuild/linux-riscv64@0.27.4': + resolution: {integrity: sha512-BnASypppbUWyqjd1KIpU4AUBiIhVr6YlHx/cnPgqEkNoVOhHg+YiSVxM1RLfiy4t9cAulbRGTNCKOcqHrEQLIw==} + engines: {node: '>=18'} + cpu: [riscv64] + os: [linux] + '@esbuild/linux-s390x@0.25.11': resolution: {integrity: sha512-HjLqVgSSYnVXRisyfmzsH6mXqyvj0SA7pG5g+9W7ESgwA70AXYNpfKBqh1KbTxmQVaYxpzA/SvlB9oclGPbApw==} engines: {node: '>=18'} cpu: [s390x] os: [linux] + '@esbuild/linux-s390x@0.27.4': + resolution: {integrity: sha512-+eUqgb/Z7vxVLezG8bVB9SfBie89gMueS+I0xYh2tJdw3vqA/0ImZJ2ROeWwVJN59ihBeZ7Tu92dF/5dy5FttA==} + engines: {node: '>=18'} + cpu: [s390x] + os: [linux] + '@esbuild/linux-x64@0.25.11': resolution: {integrity: sha512-HSFAT4+WYjIhrHxKBwGmOOSpphjYkcswF449j6EjsjbinTZbp8PJtjsVK1XFJStdzXdy/jaddAep2FGY+wyFAQ==} engines: {node: '>=18'} cpu: [x64] os: [linux] + '@esbuild/linux-x64@0.27.4': + resolution: {integrity: sha512-S5qOXrKV8BQEzJPVxAwnryi2+Iq5pB40gTEIT69BQONqR7JH1EPIcQ/Uiv9mCnn05jff9umq/5nqzxlqTOg9NA==} + engines: {node: '>=18'} + cpu: [x64] + os: [linux] + '@esbuild/netbsd-arm64@0.25.11': resolution: {integrity: sha512-hr9Oxj1Fa4r04dNpWr3P8QKVVsjQhqrMSUzZzf+LZcYjZNqhA3IAfPQdEh1FLVUJSiu6sgAwp3OmwBfbFgG2Xg==} engines: {node: '>=18'} cpu: [arm64] os: [netbsd] + '@esbuild/netbsd-arm64@0.27.4': + resolution: {integrity: sha512-xHT8X4sb0GS8qTqiwzHqpY00C95DPAq7nAwX35Ie/s+LO9830hrMd3oX0ZMKLvy7vsonee73x0lmcdOVXFzd6Q==} + engines: {node: '>=18'} + cpu: [arm64] + os: [netbsd] + '@esbuild/netbsd-x64@0.25.11': resolution: {integrity: sha512-u7tKA+qbzBydyj0vgpu+5h5AeudxOAGncb8N6C9Kh1N4n7wU1Xw1JDApsRjpShRpXRQlJLb9wY28ELpwdPcZ7A==} engines: {node: '>=18'} cpu: [x64] os: [netbsd] + '@esbuild/netbsd-x64@0.27.4': + resolution: {integrity: sha512-RugOvOdXfdyi5Tyv40kgQnI0byv66BFgAqjdgtAKqHoZTbTF2QqfQrFwa7cHEORJf6X2ht+l9ABLMP0dnKYsgg==} + engines: {node: '>=18'} + cpu: [x64] + os: [netbsd] + '@esbuild/openbsd-arm64@0.25.11': resolution: {integrity: sha512-Qq6YHhayieor3DxFOoYM1q0q1uMFYb7cSpLD2qzDSvK1NAvqFi8Xgivv0cFC6J+hWVw2teCYltyy9/m/14ryHg==} engines: {node: '>=18'} cpu: [arm64] os: [openbsd] + '@esbuild/openbsd-arm64@0.27.4': + resolution: {integrity: sha512-2MyL3IAaTX+1/qP0O1SwskwcwCoOI4kV2IBX1xYnDDqthmq5ArrW94qSIKCAuRraMgPOmG0RDTA74mzYNQA9ow==} + engines: {node: '>=18'} + cpu: [arm64] + os: [openbsd] + '@esbuild/openbsd-x64@0.25.11': resolution: {integrity: sha512-CN+7c++kkbrckTOz5hrehxWN7uIhFFlmS/hqziSFVWpAzpWrQoAG4chH+nN3Be+Kzv/uuo7zhX716x3Sn2Jduw==} engines: {node: '>=18'} cpu: [x64] os: [openbsd] + '@esbuild/openbsd-x64@0.27.4': + resolution: {integrity: sha512-u8fg/jQ5aQDfsnIV6+KwLOf1CmJnfu1ShpwqdwC0uA7ZPwFws55Ngc12vBdeUdnuWoQYx/SOQLGDcdlfXhYmXQ==} + engines: {node: '>=18'} + cpu: [x64] + os: [openbsd] + '@esbuild/openharmony-arm64@0.25.11': resolution: {integrity: sha512-rOREuNIQgaiR+9QuNkbkxubbp8MSO9rONmwP5nKncnWJ9v5jQ4JxFnLu4zDSRPf3x4u+2VN4pM4RdyIzDty/wQ==} engines: {node: '>=18'} cpu: [arm64] os: [openharmony] + '@esbuild/openharmony-arm64@0.27.4': + resolution: {integrity: sha512-JkTZrl6VbyO8lDQO3yv26nNr2RM2yZzNrNHEsj9bm6dOwwu9OYN28CjzZkH57bh4w0I2F7IodpQvUAEd1mbWXg==} + engines: {node: '>=18'} + cpu: [arm64] + os: [openharmony] + '@esbuild/sunos-x64@0.25.11': resolution: {integrity: sha512-nq2xdYaWxyg9DcIyXkZhcYulC6pQ2FuCgem3LI92IwMgIZ69KHeY8T4Y88pcwoLIjbed8n36CyKoYRDygNSGhA==} engines: {node: '>=18'} cpu: [x64] os: [sunos] + '@esbuild/sunos-x64@0.27.4': + resolution: {integrity: sha512-/gOzgaewZJfeJTlsWhvUEmUG4tWEY2Spp5M20INYRg2ZKl9QPO3QEEgPeRtLjEWSW8FilRNacPOg8R1uaYkA6g==} + engines: {node: '>=18'} + cpu: [x64] + os: [sunos] + '@esbuild/win32-arm64@0.25.11': resolution: {integrity: sha512-3XxECOWJq1qMZ3MN8srCJ/QfoLpL+VaxD/WfNRm1O3B4+AZ/BnLVgFbUV3eiRYDMXetciH16dwPbbHqwe1uU0Q==} engines: {node: '>=18'} cpu: [arm64] os: [win32] + '@esbuild/win32-arm64@0.27.4': + resolution: {integrity: sha512-Z9SExBg2y32smoDQdf1HRwHRt6vAHLXcxD2uGgO/v2jK7Y718Ix4ndsbNMU/+1Qiem9OiOdaqitioZwxivhXYg==} + engines: {node: '>=18'} + cpu: [arm64] + os: [win32] + '@esbuild/win32-ia32@0.25.11': resolution: {integrity: sha512-3ukss6gb9XZ8TlRyJlgLn17ecsK4NSQTmdIXRASVsiS2sQ6zPPZklNJT5GR5tE/MUarymmy8kCEf5xPCNCqVOA==} engines: {node: '>=18'} cpu: [ia32] os: [win32] + '@esbuild/win32-ia32@0.27.4': + resolution: {integrity: sha512-DAyGLS0Jz5G5iixEbMHi5KdiApqHBWMGzTtMiJ72ZOLhbu/bzxgAe8Ue8CTS3n3HbIUHQz/L51yMdGMeoxXNJw==} + engines: {node: '>=18'} + cpu: [ia32] + os: [win32] + '@esbuild/win32-x64@0.25.11': resolution: {integrity: sha512-D7Hpz6A2L4hzsRpPaCYkQnGOotdUpDzSGRIv9I+1ITdHROSFUWW95ZPZWQmGka1Fg7W3zFJowyn9WGwMJ0+KPA==} engines: {node: '>=18'} cpu: [x64] os: [win32] + '@esbuild/win32-x64@0.27.4': + resolution: {integrity: sha512-+knoa0BDoeXgkNvvV1vvbZX4+hizelrkwmGJBdT17t8FNPwG2lKemmuMZlmaNQ3ws3DKKCxpb4zRZEIp3UxFCg==} + engines: {node: '>=18'} + cpu: [x64] + os: [win32] + '@gar/promise-retry@1.0.3': resolution: {integrity: sha512-GmzA9ckNokPypTg10pgpeHNQe7ph+iIKKmhKu3Ob9ANkswreCx7R3cKmY781K8QK3AqVL3xVh9A42JvIAbkkSA==} engines: {node: ^20.17.0 || >=22.9.0} @@ -2258,7 +2414,7 @@ packages: resolution: {integrity: sha512-evZcRspIPbbiJEe748zI2BRu94ThCBE+RkjCpVF8yoVYuTV7hMe+4wLF/7K86r8GwJHSmAPnPbZhpXWWrg1qbA==} peerDependencies: msw: ^2.4.9 - vite: 7.1.12 + vite: 7.3.2 peerDependenciesMeta: msw: optional: true @@ -2765,6 +2921,11 @@ packages: engines: {node: '>=18'} hasBin: true + esbuild@0.27.4: + resolution: {integrity: sha512-Rq4vbHnYkK5fws5NF7MYTU68FPRE1ajX7heQ/8QXXWqNgqqJ/GkmmyxIzUnf2Sr/bakf8l54716CcMGHYhMrrQ==} + engines: {node: '>=18'} + hasBin: true + escalade@3.2.0: resolution: {integrity: sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==} engines: {node: '>=6'} @@ -4233,8 +4394,8 @@ packages: resolution: {integrity: sha512-IUoow1YUtvoBBC06dXs8bR8B9vuA3aJfmQNKMoaPG/OFsPmoQvw8xh+6Ye25Gx9DQhoEom3Pcu9MKHerm/NpUQ==} engines: {node: ^18.17.0 || >=20.5.0} - vite@7.1.12: - resolution: {integrity: sha512-ZWyE8YXEXqJrrSLvYgrRP7p62OziLW7xI5HYGWFzOvupfAlrLvURSzv/FyGyy0eidogEM3ujU+kUG1zuHgb6Ug==} + vite@7.3.2: + resolution: {integrity: sha512-Bby3NOsna2jsjfLVOHKes8sGwgl4TT0E6vvpYgnAYDIF/tie7MRaFthmKuHx1NSXjiTueXH3do80FMQgvEktRg==} engines: {node: ^20.19.0 || >=22.12.0} hasBin: true peerDependencies: @@ -4748,81 +4909,159 @@ snapshots: '@esbuild/aix-ppc64@0.25.11': optional: true + '@esbuild/aix-ppc64@0.27.4': + optional: true + '@esbuild/android-arm64@0.25.11': optional: true + '@esbuild/android-arm64@0.27.4': + optional: true + '@esbuild/android-arm@0.25.11': optional: true + '@esbuild/android-arm@0.27.4': + optional: true + '@esbuild/android-x64@0.25.11': optional: true + '@esbuild/android-x64@0.27.4': + optional: true + '@esbuild/darwin-arm64@0.25.11': optional: true + '@esbuild/darwin-arm64@0.27.4': + optional: true + '@esbuild/darwin-x64@0.25.11': optional: true + '@esbuild/darwin-x64@0.27.4': + optional: true + '@esbuild/freebsd-arm64@0.25.11': optional: true + '@esbuild/freebsd-arm64@0.27.4': + optional: true + '@esbuild/freebsd-x64@0.25.11': optional: true + '@esbuild/freebsd-x64@0.27.4': + optional: true + '@esbuild/linux-arm64@0.25.11': optional: true + '@esbuild/linux-arm64@0.27.4': + optional: true + '@esbuild/linux-arm@0.25.11': optional: true + '@esbuild/linux-arm@0.27.4': + optional: true + '@esbuild/linux-ia32@0.25.11': optional: true + '@esbuild/linux-ia32@0.27.4': + optional: true + '@esbuild/linux-loong64@0.25.11': optional: true + '@esbuild/linux-loong64@0.27.4': + optional: true + '@esbuild/linux-mips64el@0.25.11': optional: true + '@esbuild/linux-mips64el@0.27.4': + optional: true + '@esbuild/linux-ppc64@0.25.11': optional: true + '@esbuild/linux-ppc64@0.27.4': + optional: true + '@esbuild/linux-riscv64@0.25.11': optional: true + '@esbuild/linux-riscv64@0.27.4': + optional: true + '@esbuild/linux-s390x@0.25.11': optional: true + '@esbuild/linux-s390x@0.27.4': + optional: true + '@esbuild/linux-x64@0.25.11': optional: true + '@esbuild/linux-x64@0.27.4': + optional: true + '@esbuild/netbsd-arm64@0.25.11': optional: true + '@esbuild/netbsd-arm64@0.27.4': + optional: true + '@esbuild/netbsd-x64@0.25.11': optional: true + '@esbuild/netbsd-x64@0.27.4': + optional: true + '@esbuild/openbsd-arm64@0.25.11': optional: true + '@esbuild/openbsd-arm64@0.27.4': + optional: true + '@esbuild/openbsd-x64@0.25.11': optional: true + '@esbuild/openbsd-x64@0.27.4': + optional: true + '@esbuild/openharmony-arm64@0.25.11': optional: true + '@esbuild/openharmony-arm64@0.27.4': + optional: true + '@esbuild/sunos-x64@0.25.11': optional: true + '@esbuild/sunos-x64@0.27.4': + optional: true + '@esbuild/win32-arm64@0.25.11': optional: true + '@esbuild/win32-arm64@0.27.4': + optional: true + '@esbuild/win32-ia32@0.25.11': optional: true + '@esbuild/win32-ia32@0.27.4': + optional: true + '@esbuild/win32-x64@0.25.11': optional: true + '@esbuild/win32-x64@0.27.4': + optional: true + '@gar/promise-retry@1.0.3': {} '@gitbeaker/core@43.8.0': @@ -5878,13 +6117,13 @@ snapshots: chai: 6.2.1 tinyrainbow: 3.0.3 - '@vitest/mocker@4.0.3(vite@7.1.12(@types/node@24.9.2)(jiti@2.6.1)(yaml@2.8.1))': + '@vitest/mocker@4.0.3(vite@7.3.2(@types/node@24.9.2)(jiti@2.6.1)(yaml@2.8.1))': dependencies: '@vitest/spy': 4.0.3 estree-walker: 3.0.3 magic-string: 0.30.19 optionalDependencies: - vite: 7.1.12(@types/node@24.9.2)(jiti@2.6.1)(yaml@2.8.1) + vite: 7.3.2(@types/node@24.9.2)(jiti@2.6.1)(yaml@2.8.1) '@vitest/pretty-format@4.0.3': dependencies: @@ -6438,6 +6677,35 @@ snapshots: '@esbuild/win32-ia32': 0.25.11 '@esbuild/win32-x64': 0.25.11 + esbuild@0.27.4: + optionalDependencies: + '@esbuild/aix-ppc64': 0.27.4 + '@esbuild/android-arm': 0.27.4 + '@esbuild/android-arm64': 0.27.4 + '@esbuild/android-x64': 0.27.4 + '@esbuild/darwin-arm64': 0.27.4 + '@esbuild/darwin-x64': 0.27.4 + '@esbuild/freebsd-arm64': 0.27.4 + '@esbuild/freebsd-x64': 0.27.4 + '@esbuild/linux-arm': 0.27.4 + '@esbuild/linux-arm64': 0.27.4 + '@esbuild/linux-ia32': 0.27.4 + '@esbuild/linux-loong64': 0.27.4 + '@esbuild/linux-mips64el': 0.27.4 + '@esbuild/linux-ppc64': 0.27.4 + '@esbuild/linux-riscv64': 0.27.4 + '@esbuild/linux-s390x': 0.27.4 + '@esbuild/linux-x64': 0.27.4 + '@esbuild/netbsd-arm64': 0.27.4 + '@esbuild/netbsd-x64': 0.27.4 + '@esbuild/openbsd-arm64': 0.27.4 + '@esbuild/openbsd-x64': 0.27.4 + '@esbuild/openharmony-arm64': 0.27.4 + '@esbuild/sunos-x64': 0.27.4 + '@esbuild/win32-arm64': 0.27.4 + '@esbuild/win32-ia32': 0.27.4 + '@esbuild/win32-x64': 0.27.4 + escalade@3.2.0: {} escape-string-regexp@1.0.5: {} @@ -8087,9 +8355,9 @@ snapshots: validate-npm-package-name@6.0.2: {} - vite@7.1.12(@types/node@24.9.2)(jiti@2.6.1)(yaml@2.8.1): + vite@7.3.2(@types/node@24.9.2)(jiti@2.6.1)(yaml@2.8.1): dependencies: - esbuild: 0.25.11 + esbuild: 0.27.4 fdir: 6.5.0(picomatch@4.0.3) picomatch: 4.0.3 postcss: 8.5.6 @@ -8104,7 +8372,7 @@ snapshots: vitest@4.0.3(@types/debug@4.1.12)(@types/node@24.9.2)(jiti@2.6.1)(yaml@2.8.1): dependencies: '@vitest/expect': 4.0.3 - '@vitest/mocker': 4.0.3(vite@7.1.12(@types/node@24.9.2)(jiti@2.6.1)(yaml@2.8.1)) + '@vitest/mocker': 4.0.3(vite@7.3.2(@types/node@24.9.2)(jiti@2.6.1)(yaml@2.8.1)) '@vitest/pretty-format': 4.0.3 '@vitest/runner': 4.0.3 '@vitest/snapshot': 4.0.3 @@ -8121,7 +8389,7 @@ snapshots: tinyexec: 0.3.2 tinyglobby: 0.2.15 tinyrainbow: 3.0.3 - vite: 7.1.12(@types/node@24.9.2)(jiti@2.6.1)(yaml@2.8.1) + vite: 7.3.2(@types/node@24.9.2)(jiti@2.6.1)(yaml@2.8.1) why-is-node-running: 2.3.0 optionalDependencies: '@types/debug': 4.1.12 diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 8cd56b90c..0edb29cbc 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -144,7 +144,7 @@ catalog: typescript: 5.9.3 undici: 6.21.3 unplugin-purge-polyfills: 0.1.0 - vite: 7.1.12 + vite: 7.3.2 vitest: 4.0.3 wrap-ansi: 9.0.2 xml2js: 0.6.2 From aedecb324152489e49d74b77bb14d911b17f36fb Mon Sep 17 00:00:00 2001 From: jdalton Date: Mon, 6 Apr 2026 18:50:25 -0400 Subject: [PATCH 2/2] fix(test): replace vi.mock('node:fs') with vi.spyOn in wrapper tests vi.mock auto-mocking of node: built-ins fails intermittently with vitest threads pool + sharding in CI. Switch to vi.spyOn which works reliably. Source files updated to access fs methods via the default import (fs.existsSync) so spies can intercept them. --- .../commands/wrapper/postinstall-wrapper.mts | 10 +-- .../wrapper/remove-socket-wrapper.mts | 6 +- .../check-socket-wrapper-setup.test.mts | 73 ++++++----------- .../wrapper/postinstall-wrapper.test.mts | 51 +++++------- .../wrapper/remove-socket-wrapper.test.mts | 82 ++++++++----------- 5 files changed, 87 insertions(+), 135 deletions(-) diff --git a/packages/cli/src/commands/wrapper/postinstall-wrapper.mts b/packages/cli/src/commands/wrapper/postinstall-wrapper.mts index 57a9a294e..48b3c77ad 100644 --- a/packages/cli/src/commands/wrapper/postinstall-wrapper.mts +++ b/packages/cli/src/commands/wrapper/postinstall-wrapper.mts @@ -1,4 +1,4 @@ -import fs, { existsSync } from 'node:fs' +import fs from 'node:fs' import { debug, debugDir } from '@socketsecurity/lib/debug' import { getDefaultLogger } from '@socketsecurity/lib/logger' @@ -16,8 +16,8 @@ export async function postinstallWrapper() { const bashRcPath = getBashRcPath() const zshRcPath = getZshRcPath() const socketWrapperEnabled = - (existsSync(bashRcPath) && checkSocketWrapperSetup(bashRcPath)) || - (existsSync(zshRcPath) && checkSocketWrapperSetup(zshRcPath)) + (fs.existsSync(bashRcPath) && checkSocketWrapperSetup(bashRcPath)) || + (fs.existsSync(zshRcPath) && checkSocketWrapperSetup(zshRcPath)) if (!socketWrapperEnabled) { await setupSocketWrapper( @@ -78,10 +78,10 @@ async function setupSocketWrapper(query: string): Promise { const bashRcPath = getBashRcPath() const zshRcPath = getZshRcPath() try { - if (existsSync(bashRcPath)) { + if (fs.existsSync(bashRcPath)) { await addSocketWrapper(bashRcPath) } - if (existsSync(zshRcPath)) { + if (fs.existsSync(zshRcPath)) { await addSocketWrapper(zshRcPath) } } catch (e) { diff --git a/packages/cli/src/commands/wrapper/remove-socket-wrapper.mts b/packages/cli/src/commands/wrapper/remove-socket-wrapper.mts index 7020cce74..82613310d 100644 --- a/packages/cli/src/commands/wrapper/remove-socket-wrapper.mts +++ b/packages/cli/src/commands/wrapper/remove-socket-wrapper.mts @@ -1,4 +1,4 @@ -import { readFileSync, writeFileSync } from 'node:fs' +import fs from 'node:fs' import { getDefaultLogger } from '@socketsecurity/lib/logger' const logger = getDefaultLogger() @@ -6,7 +6,7 @@ const logger = getDefaultLogger() export function removeSocketWrapper(filepath: string): void { let content: string | undefined try { - content = readFileSync(filepath, 'utf8') + content = fs.readFileSync(filepath, 'utf8') } catch (e) { logger.fail(`There was an error removing the alias${e ? ':' : '.'}`) if (e) { @@ -22,7 +22,7 @@ export function removeSocketWrapper(filepath: string): void { ) const updatedContent = linesWithoutSocketAlias.join('\n') try { - writeFileSync(filepath, updatedContent, 'utf8') + fs.writeFileSync(filepath, updatedContent, 'utf8') } catch (e) { if (e) { logger.error(e) diff --git a/packages/cli/test/unit/commands/wrapper/check-socket-wrapper-setup.test.mts b/packages/cli/test/unit/commands/wrapper/check-socket-wrapper-setup.test.mts index 16c20a166..37e6f2523 100644 --- a/packages/cli/test/unit/commands/wrapper/check-socket-wrapper-setup.test.mts +++ b/packages/cli/test/unit/commands/wrapper/check-socket-wrapper-setup.test.mts @@ -1,31 +1,12 @@ /** - * Unit tests for checkSocketWrapperSetup. - * - * Purpose: - * Tests checking Socket wrapper installation status. Validates detection of installed wrappers across package managers. - * - * Test Coverage: - * - Core functionality validation - * - Edge case handling - * - Error scenarios - * - Input validation - * - * Testing Approach: - * Comprehensive unit testing of module functionality with mocked dependencies - * where appropriate. - * - * Related Files: - * - src/checkSocketWrapperSetup.mts (implementation) + * @fileoverview Unit tests for checkSocketWrapperSetup. */ import fs from 'node:fs' -import { beforeEach, describe, expect, it, vi } from 'vitest' +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' -import { checkSocketWrapperSetup } from '../../../../src/commands/../../../../src/commands/wrapper/check-socket-wrapper-setup.mts' - -// Mock the dependencies. -vi.mock('node:fs') +import { checkSocketWrapperSetup } from '../../../../src/commands/wrapper/check-socket-wrapper-setup.mts' const mockLogger = vi.hoisted(() => ({ fail: vi.fn(), @@ -42,13 +23,19 @@ vi.mock('@socketsecurity/lib/logger', () => ({ })) describe('checkSocketWrapperSetup', () => { + let readFileSyncSpy: ReturnType + beforeEach(() => { vi.clearAllMocks() + readFileSyncSpy = vi.spyOn(fs, 'readFileSync') + }) + + afterEach(() => { + readFileSyncSpy.mockRestore() }) it('detects npm alias in file', () => { - const mockReadFileSync = vi.mocked(fs.readFileSync) as any - mockReadFileSync.mockReturnValue('alias npm="socket npm"\nother content') + readFileSyncSpy.mockReturnValue('alias npm="socket npm"\nother content') const result = checkSocketWrapperSetup('/home/user/.bashrc') @@ -57,8 +44,7 @@ describe('checkSocketWrapperSetup', () => { }) it('detects npx alias in file', () => { - const mockReadFileSync = vi.mocked(fs.readFileSync) as any - mockReadFileSync.mockReturnValue('alias npx="socket npx"\nother content') + readFileSyncSpy.mockReturnValue('alias npx="socket npx"\nother content') const result = checkSocketWrapperSetup('/home/user/.bashrc') @@ -66,8 +52,7 @@ describe('checkSocketWrapperSetup', () => { }) it('detects both aliases in file', () => { - const mockReadFileSync = vi.mocked(fs.readFileSync) as any - mockReadFileSync.mockReturnValue( + readFileSyncSpy.mockReturnValue( 'alias npm="socket npm"\nalias npx="socket npx"\nother content', ) @@ -77,8 +62,7 @@ describe('checkSocketWrapperSetup', () => { }) it('returns false when no aliases found', () => { - const mockReadFileSync = vi.mocked(fs.readFileSync) as any - mockReadFileSync.mockReturnValue('some other content\nno aliases here') + readFileSyncSpy.mockReturnValue('some other content\nno aliases here') const result = checkSocketWrapperSetup('/home/user/.bashrc') @@ -86,30 +70,28 @@ describe('checkSocketWrapperSetup', () => { }) it('returns false for empty file', () => { - const mockReadFileSync = vi.mocked(fs.readFileSync) as any - mockReadFileSync.mockReturnValue('') + readFileSyncSpy.mockReturnValue('') const result = checkSocketWrapperSetup('/home/user/.bashrc') expect(result).toBe(false) }) - it('logs instructions when wrapper is set up', async () => { - await import('@socketsecurity/lib/logger') - const mockReadFileSync = vi.mocked(fs.readFileSync) as any - mockReadFileSync.mockReturnValue('alias npm="socket npm"') + it('logs instructions when wrapper is set up', () => { + readFileSyncSpy.mockReturnValue('alias npm="socket npm"') checkSocketWrapperSetup('/home/user/.bashrc') expect(mockLogger.log).toHaveBeenCalledWith( 'The Socket npm/npx wrapper is set up in your bash profile (/home/user/.bashrc).', ) - expect(mockLogger.log).toHaveBeenCalledWith(' source /home/user/.bashrc') + expect(mockLogger.log).toHaveBeenCalledWith( + ' source /home/user/.bashrc', + ) }) it('ignores partial alias matches', () => { - const mockReadFileSync = vi.mocked(fs.readFileSync) as any - mockReadFileSync.mockReturnValue( + readFileSyncSpy.mockReturnValue( 'alias npm="other-tool npm"\nalias npx="other-tool npx"', ) @@ -119,8 +101,7 @@ describe('checkSocketWrapperSetup', () => { }) it('handles multiline file with aliases mixed in', () => { - const mockReadFileSync = vi.mocked(fs.readFileSync) as any - mockReadFileSync.mockReturnValue( + readFileSyncSpy.mockReturnValue( `#!/bin/bash # User bashrc export PATH=$PATH:/usr/local/bin @@ -135,8 +116,7 @@ export NODE_ENV=development`, }) it('is case-sensitive for alias detection', () => { - const mockReadFileSync = vi.mocked(fs.readFileSync) as any - mockReadFileSync.mockReturnValue('ALIAS NPM="SOCKET NPM"') + readFileSyncSpy.mockReturnValue('ALIAS NPM="SOCKET NPM"') const result = checkSocketWrapperSetup('/home/user/.bashrc') @@ -144,17 +124,12 @@ export NODE_ENV=development`, }) it('handles files with Windows line endings', () => { - const mockReadFileSync = vi.mocked(fs.readFileSync) as any - // When splitting on \n, Windows line endings leave \r at the end of lines, - // so 'alias npm="socket npm"\r' !== 'alias npm="socket npm"'. - // The function doesn't handle Windows line endings properly. - mockReadFileSync.mockReturnValue( + readFileSyncSpy.mockReturnValue( 'line1\r\nalias npm="socket npm"\r\nalias npx="socket npx"\r\n', ) const result = checkSocketWrapperSetup('/home/user/.bashrc') - // The function splits by \n, leaving \r at the end, so exact match fails. expect(result).toBe(false) }) }) diff --git a/packages/cli/test/unit/commands/wrapper/postinstall-wrapper.test.mts b/packages/cli/test/unit/commands/wrapper/postinstall-wrapper.test.mts index ccc823174..2b5b89f4b 100644 --- a/packages/cli/test/unit/commands/wrapper/postinstall-wrapper.test.mts +++ b/packages/cli/test/unit/commands/wrapper/postinstall-wrapper.test.mts @@ -18,15 +18,12 @@ * - src/postinstallWrapper.mts (implementation) */ -import fs, { existsSync } from 'node:fs' +import fs from 'node:fs' -import { beforeEach, describe, expect, it, vi } from 'vitest' +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' import { postinstallWrapper } from '../../../../src/commands/wrapper/postinstall-wrapper.mts' -// Mock the dependencies. -vi.mock('node:fs') - const mockLogger = vi.hoisted(() => ({ fail: vi.fn(), log: vi.fn(), @@ -67,18 +64,24 @@ vi.mock('../../../../src/utils/error/errors.mts', () => ({ })) describe('postinstallWrapper', () => { + let existsSyncSpy: ReturnType + beforeEach(() => { vi.clearAllMocks() + existsSyncSpy = vi.spyOn(fs, 'existsSync') + }) + + afterEach(() => { + existsSyncSpy.mockRestore() }) it('skips setup when wrapper already enabled in bashrc', async () => { const { checkSocketWrapperSetup } = await import('../../../../src/commands/wrapper/check-socket-wrapper-setup.mts') const { confirm } = await import('@socketsecurity/lib/stdio/prompts') - const mockExistsSync = vi.mocked(existsSync) as any const mockCheckSetup = vi.mocked(checkSocketWrapperSetup) - mockExistsSync.mockImplementation( + existsSyncSpy.mockImplementation( (path: string) => path === '/home/user/.bashrc', ) mockCheckSetup.mockReturnValue(true) @@ -93,10 +96,9 @@ describe('postinstallWrapper', () => { const { checkSocketWrapperSetup } = await import('../../../../src/commands/wrapper/check-socket-wrapper-setup.mts') const { confirm } = await import('@socketsecurity/lib/stdio/prompts') - const mockExistsSync = vi.mocked(existsSync) as any const mockCheckSetup = vi.mocked(checkSocketWrapperSetup) - mockExistsSync.mockImplementation( + existsSyncSpy.mockImplementation( (path: string) => path === '/home/user/.zshrc', ) mockCheckSetup.mockImplementation( @@ -114,11 +116,10 @@ describe('postinstallWrapper', () => { await import('../../../../src/commands/wrapper/check-socket-wrapper-setup.mts') const { confirm } = await import('@socketsecurity/lib/stdio/prompts') await import('@socketsecurity/lib/logger') - const mockExistsSync = vi.mocked(existsSync) as any const mockCheckSetup = vi.mocked(checkSocketWrapperSetup) const mockConfirm = vi.mocked(confirm) - mockExistsSync.mockReturnValue(false) + existsSyncSpy.mockReturnValue(false) mockCheckSetup.mockReturnValue(false) mockConfirm.mockResolvedValue(false) @@ -143,12 +144,11 @@ describe('postinstallWrapper', () => { const { checkSocketWrapperSetup } = await import('../../../../src/commands/wrapper/check-socket-wrapper-setup.mts') const { confirm } = await import('@socketsecurity/lib/stdio/prompts') - const mockExistsSync = vi.mocked(existsSync) as any const mockCheckSetup = vi.mocked(checkSocketWrapperSetup) const mockConfirm = vi.mocked(confirm) const _mockAddWrapper = vi.mocked(addSocketWrapper) - mockExistsSync.mockImplementation( + existsSyncSpy.mockImplementation( (path: string) => path === '/home/user/.bashrc', ) mockCheckSetup.mockReturnValue(false) @@ -165,11 +165,10 @@ describe('postinstallWrapper', () => { const { checkSocketWrapperSetup } = await import('../../../../src/commands/wrapper/check-socket-wrapper-setup.mts') const { confirm } = await import('@socketsecurity/lib/stdio/prompts') - const mockExistsSync = vi.mocked(existsSync) as any const mockCheckSetup = vi.mocked(checkSocketWrapperSetup) const mockConfirm = vi.mocked(confirm) - mockExistsSync.mockReturnValue(true) + existsSyncSpy.mockReturnValue(true) mockCheckSetup.mockReturnValue(false) mockConfirm.mockResolvedValue(true) @@ -185,12 +184,11 @@ describe('postinstallWrapper', () => { const { checkSocketWrapperSetup } = await import('../../../../src/commands/wrapper/check-socket-wrapper-setup.mts') const { confirm } = await import('@socketsecurity/lib/stdio/prompts') - const mockExistsSync = vi.mocked(existsSync) as any const mockCheckSetup = vi.mocked(checkSocketWrapperSetup) const mockConfirm = vi.mocked(confirm) const mockAddWrapper = vi.mocked(addSocketWrapper) - mockExistsSync.mockReturnValue(true) + existsSyncSpy.mockReturnValue(true) mockCheckSetup.mockReturnValue(false) mockConfirm.mockResolvedValue(true) mockAddWrapper.mockImplementation(() => { @@ -208,21 +206,18 @@ describe('postinstallWrapper', () => { await import('@socketsecurity/lib/logger') const { updateInstalledTabCompletionScript } = await import('../../../../src/commands/install/setup-tab-completion.mts') - const mockExistsSync = vi.mocked(existsSync) as any - const mockFsExistsSync = vi.mocked(fs.existsSync) as any const mockGetDetails = vi.mocked(getBashrcDetails) const mockUpdateScript = vi.mocked(updateInstalledTabCompletionScript) const { checkSocketWrapperSetup } = await import('../../../../src/commands/wrapper/check-socket-wrapper-setup.mts') const mockCheckSetup = vi.mocked(checkSocketWrapperSetup) - mockExistsSync.mockReturnValue(true) + existsSyncSpy.mockReturnValue(true) mockCheckSetup.mockReturnValue(true) // Wrapper already setup. mockGetDetails.mockReturnValue({ ok: true, data: { targetPath: '/home/user/.config/socket/tab-completion.bash' }, } as any) - mockFsExistsSync.mockReturnValue(true) mockUpdateScript.mockReturnValue({ ok: true } as any) await postinstallWrapper() @@ -241,20 +236,20 @@ describe('postinstallWrapper', () => { await import('@socketsecurity/lib/logger') const { updateInstalledTabCompletionScript } = await import('../../../../src/commands/install/setup-tab-completion.mts') - const mockExistsSync = vi.mocked(existsSync) as any - const mockFsExistsSync = vi.mocked(fs.existsSync) as any const mockGetDetails = vi.mocked(getBashrcDetails) const { checkSocketWrapperSetup } = await import('../../../../src/commands/wrapper/check-socket-wrapper-setup.mts') const mockCheckSetup = vi.mocked(checkSocketWrapperSetup) - mockExistsSync.mockReturnValue(true) + existsSyncSpy.mockImplementation( + (p: string) => + p !== '/home/user/.config/socket/tab-completion.bash', + ) mockCheckSetup.mockReturnValue(true) mockGetDetails.mockReturnValue({ ok: true, data: { targetPath: '/home/user/.config/socket/tab-completion.bash' }, } as any) - mockFsExistsSync.mockReturnValue(false) await postinstallWrapper() @@ -268,13 +263,12 @@ describe('postinstallWrapper', () => { const { getBashrcDetails } = await import('../../../../src/utils/cli/completion.mts') await import('@socketsecurity/lib/logger') - const mockExistsSync = vi.mocked(existsSync) as any const mockGetDetails = vi.mocked(getBashrcDetails) const { checkSocketWrapperSetup } = await import('../../../../src/commands/wrapper/check-socket-wrapper-setup.mts') const mockCheckSetup = vi.mocked(checkSocketWrapperSetup) - mockExistsSync.mockReturnValue(true) + existsSyncSpy.mockReturnValue(true) mockCheckSetup.mockReturnValue(true) mockGetDetails.mockImplementation(() => { throw new Error('Tab completion error') @@ -291,13 +285,12 @@ describe('postinstallWrapper', () => { const { getBashrcDetails } = await import('../../../../src/utils/cli/completion.mts') await import('@socketsecurity/lib/logger') - const mockExistsSync = vi.mocked(existsSync) as any const mockGetDetails = vi.mocked(getBashrcDetails) const { checkSocketWrapperSetup } = await import('../../../../src/commands/wrapper/check-socket-wrapper-setup.mts') const mockCheckSetup = vi.mocked(checkSocketWrapperSetup) - mockExistsSync.mockReturnValue(true) + existsSyncSpy.mockReturnValue(true) mockCheckSetup.mockReturnValue(true) mockGetDetails.mockReturnValue({ ok: false, message: 'Not found' } as any) diff --git a/packages/cli/test/unit/commands/wrapper/remove-socket-wrapper.test.mts b/packages/cli/test/unit/commands/wrapper/remove-socket-wrapper.test.mts index 49fc66ea0..01ae912b6 100644 --- a/packages/cli/test/unit/commands/wrapper/remove-socket-wrapper.test.mts +++ b/packages/cli/test/unit/commands/wrapper/remove-socket-wrapper.test.mts @@ -18,15 +18,12 @@ * - src/removeSocketWrapper.mts (implementation) */ -import { readFileSync, writeFileSync } from 'node:fs' +import fs from 'node:fs' -import { beforeEach, describe, expect, it, vi } from 'vitest' +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' import { removeSocketWrapper } from '../../../../src/commands/../../../../src/commands/wrapper/remove-socket-wrapper.mts' -// Mock the dependencies. -vi.mock('node:fs') - const mockLogger = vi.hoisted(() => ({ fail: vi.fn(), log: vi.fn(), @@ -42,26 +39,32 @@ vi.mock('@socketsecurity/lib/logger', () => ({ })) describe('removeSocketWrapper', () => { + let readFileSyncSpy: ReturnType + let writeFileSyncSpy: ReturnType + beforeEach(() => { vi.clearAllMocks() - // Reset mocked functions to have default no-op implementation. - const mockWriteFileSync = vi.mocked(writeFileSync) as any - mockWriteFileSync.mockImplementation(() => {}) + readFileSyncSpy = vi.spyOn(fs, 'readFileSync') + writeFileSyncSpy = vi.spyOn(fs, 'writeFileSync') + writeFileSyncSpy.mockImplementation(() => undefined) + }) + + afterEach(() => { + readFileSyncSpy.mockRestore() + writeFileSyncSpy.mockRestore() }) it('successfully removes both aliases from file', async () => { await import('@socketsecurity/lib/logger') - const mockReadFileSync = vi.mocked(readFileSync) as any - const _mockWriteFileSync = vi.mocked(writeFileSync) as any - mockReadFileSync.mockReturnValue( + readFileSyncSpy.mockReturnValue( 'alias npm="socket npm"\nalias npx="socket npx"\nother content', ) removeSocketWrapper('/home/user/.bashrc') - expect(readFileSync).toHaveBeenCalledWith('/home/user/.bashrc', 'utf8') - expect(writeFileSync).toHaveBeenCalledWith( + expect(fs.readFileSync).toHaveBeenCalledWith('/home/user/.bashrc', 'utf8') + expect(fs.writeFileSync).toHaveBeenCalledWith( '/home/user/.bashrc', 'other content', 'utf8', @@ -75,16 +78,13 @@ describe('removeSocketWrapper', () => { }) it('removes only socket aliases, leaving others intact', () => { - const mockReadFileSync = vi.mocked(readFileSync) as any - const _mockWriteFileSync = vi.mocked(writeFileSync) as any - - mockReadFileSync.mockReturnValue( + readFileSyncSpy.mockReturnValue( 'alias ll="ls -la"\nalias npm="socket npm"\nalias gs="git status"\nalias npx="socket npx"', ) removeSocketWrapper('/home/user/.zshrc') - expect(writeFileSync).toHaveBeenCalledWith( + expect(fs.writeFileSync).toHaveBeenCalledWith( '/home/user/.zshrc', 'alias ll="ls -la"\nalias gs="git status"', 'utf8', @@ -93,10 +93,9 @@ describe('removeSocketWrapper', () => { it('handles read error gracefully', async () => { await import('@socketsecurity/lib/logger') - const mockReadFileSync = vi.mocked(readFileSync) as any const readError = new Error('Permission denied') - mockReadFileSync.mockImplementation(() => { + readFileSyncSpy.mockImplementation(() => { throw readError }) @@ -106,17 +105,15 @@ describe('removeSocketWrapper', () => { expect.stringContaining('There was an error removing the alias'), ) expect(mockLogger.error).toHaveBeenCalledWith(readError) - expect(writeFileSync).not.toHaveBeenCalled() + expect(fs.writeFileSync).not.toHaveBeenCalled() }) it('handles write error gracefully', async () => { await import('@socketsecurity/lib/logger') - const mockReadFileSync = vi.mocked(readFileSync) as any - const mockWriteFileSync = vi.mocked(writeFileSync) as any const writeError = new Error('Disk full') - mockReadFileSync.mockReturnValue('alias npm="socket npm"') - mockWriteFileSync.mockImplementation(() => { + readFileSyncSpy.mockReturnValue('alias npm="socket npm"') + writeFileSyncSpy.mockImplementation(() => { throw writeError }) @@ -128,17 +125,15 @@ describe('removeSocketWrapper', () => { it('handles file with no socket aliases', async () => { await import('@socketsecurity/lib/logger') - const mockReadFileSync = vi.mocked(readFileSync) as any - const _mockWriteFileSync = vi.mocked(writeFileSync) as any - mockReadFileSync.mockReturnValue( + readFileSyncSpy.mockReturnValue( 'alias ll="ls -la"\nexport PATH=$PATH:/usr/local/bin', ) removeSocketWrapper('/home/user/.bashrc') // When no socket aliases are removed, success message is still shown. - expect(writeFileSync).toHaveBeenCalledWith( + expect(fs.writeFileSync).toHaveBeenCalledWith( '/home/user/.bashrc', 'alias ll="ls -la"\nexport PATH=$PATH:/usr/local/bin', 'utf8', @@ -150,16 +145,13 @@ describe('removeSocketWrapper', () => { }) it('preserves empty lines when removing aliases', () => { - const mockReadFileSync = vi.mocked(readFileSync) as any - const _mockWriteFileSync = vi.mocked(writeFileSync) as any - - mockReadFileSync.mockReturnValue( + readFileSyncSpy.mockReturnValue( '\nalias npm="socket npm"\n\nalias npx="socket npx"\n\nother content\n', ) removeSocketWrapper('/home/user/.bashrc') - expect(writeFileSync).toHaveBeenCalledWith( + expect(fs.writeFileSync).toHaveBeenCalledWith( '/home/user/.bashrc', '\n\n\nother content\n', 'utf8', @@ -168,14 +160,12 @@ describe('removeSocketWrapper', () => { it('handles empty file', async () => { await import('@socketsecurity/lib/logger') - const mockReadFileSync = vi.mocked(readFileSync) as any - const _mockWriteFileSync = vi.mocked(writeFileSync) as any - mockReadFileSync.mockReturnValue('') + readFileSyncSpy.mockReturnValue('') removeSocketWrapper('/home/user/.bashrc') - expect(writeFileSync).toHaveBeenCalledWith('/home/user/.bashrc', '', 'utf8') + expect(fs.writeFileSync).toHaveBeenCalledWith('/home/user/.bashrc', '', 'utf8') // File is written successfully, so success is logged. expect(mockLogger.success).toHaveBeenCalledWith( expect.stringContaining('The alias was removed from /home/user/.bashrc'), @@ -183,16 +173,13 @@ describe('removeSocketWrapper', () => { }) it('removes only exact matches', () => { - const mockReadFileSync = vi.mocked(readFileSync) as any - const _mockWriteFileSync = vi.mocked(writeFileSync) as any - - mockReadFileSync.mockReturnValue( + readFileSyncSpy.mockReturnValue( 'alias npm="socket npm"\nalias npm2="socket npm"\nalias npx="socket npx"\nalias npx-extra="socket npx --extra"', ) removeSocketWrapper('/home/user/.bashrc') - expect(writeFileSync).toHaveBeenCalledWith( + expect(fs.writeFileSync).toHaveBeenCalledWith( '/home/user/.bashrc', 'alias npm2="socket npm"\nalias npx-extra="socket npx --extra"', 'utf8', @@ -201,9 +188,8 @@ describe('removeSocketWrapper', () => { it('handles undefined error in read catch', async () => { await import('@socketsecurity/lib/logger') - const mockReadFileSync = vi.mocked(readFileSync) as any - mockReadFileSync.mockImplementation(() => { + readFileSyncSpy.mockImplementation(() => { throw undefined }) @@ -217,11 +203,9 @@ describe('removeSocketWrapper', () => { it('handles undefined error in write catch', async () => { await import('@socketsecurity/lib/logger') - const mockReadFileSync = vi.mocked(readFileSync) as any - const mockWriteFileSync = vi.mocked(writeFileSync) as any - mockReadFileSync.mockReturnValue('alias npm="socket npm"') - mockWriteFileSync.mockImplementation(() => { + readFileSyncSpy.mockReturnValue('alias npm="socket npm"') + writeFileSyncSpy.mockImplementation(() => { throw undefined })