|
1 | | -import { isExcluded } from "@opennextjs/aws/build/copyTracedFiles.js"; |
| 1 | +import { isExcluded, isNonLinuxPlatformPackage } from "@opennextjs/aws/build/copyTracedFiles.js"; |
2 | 2 |
|
3 | 3 | describe("isExcluded", () => { |
4 | 4 | test("should exclude sharp", () => { |
@@ -32,3 +32,84 @@ describe("isExcluded", () => { |
32 | 32 | ).toBe(false); |
33 | 33 | }); |
34 | 34 | }); |
| 35 | + |
| 36 | +describe("isNonLinuxPlatformPackage", () => { |
| 37 | + test("should identify Darwin (macOS) platform packages", () => { |
| 38 | + expect( |
| 39 | + isNonLinuxPlatformPackage( |
| 40 | + "/home/user/project/node_modules/@swc/core-darwin-arm64/swc.darwin-arm64.node" |
| 41 | + ) |
| 42 | + ).toBe(true); |
| 43 | + expect(isNonLinuxPlatformPackage("/home/user/project/node_modules/@esbuild/darwin-x64/bin/esbuild")).toBe( |
| 44 | + true |
| 45 | + ); |
| 46 | + expect(isNonLinuxPlatformPackage("/home/user/project/node_modules/turbo-darwin-arm64/bin/turbo")).toBe( |
| 47 | + true |
| 48 | + ); |
| 49 | + }); |
| 50 | + |
| 51 | + test("should identify Windows platform packages", () => { |
| 52 | + expect( |
| 53 | + isNonLinuxPlatformPackage( |
| 54 | + "/home/user/project/node_modules/@swc/core-win32-x64-msvc/swc.win32-x64-msvc.node" |
| 55 | + ) |
| 56 | + ).toBe(true); |
| 57 | + expect( |
| 58 | + isNonLinuxPlatformPackage( |
| 59 | + "/home/user/project/node_modules/@rollup/rollup-win32-x64-msvc/rollup.win32-x64-msvc.node" |
| 60 | + ) |
| 61 | + ).toBe(true); |
| 62 | + }); |
| 63 | + |
| 64 | + test("should identify FreeBSD platform packages", () => { |
| 65 | + expect( |
| 66 | + isNonLinuxPlatformPackage( |
| 67 | + "/home/user/project/node_modules/@rollup/rollup-freebsd-x64/rollup.freebsd-x64.node" |
| 68 | + ) |
| 69 | + ).toBe(true); |
| 70 | + }); |
| 71 | + |
| 72 | + test("should NOT identify Linux platform packages", () => { |
| 73 | + expect( |
| 74 | + isNonLinuxPlatformPackage( |
| 75 | + "/home/user/project/node_modules/@swc/core-linux-x64-gnu/swc.linux-x64-gnu.node" |
| 76 | + ) |
| 77 | + ).toBe(false); |
| 78 | + expect(isNonLinuxPlatformPackage("/home/user/project/node_modules/@esbuild/linux-x64/bin/esbuild")).toBe( |
| 79 | + false |
| 80 | + ); |
| 81 | + expect( |
| 82 | + isNonLinuxPlatformPackage( |
| 83 | + "/home/user/project_modules/@swc/core-linux-arm64-gnu/swc.linux-arm64-gnu.node" |
| 84 | + ) |
| 85 | + ).toBe(false); |
| 86 | + }); |
| 87 | + |
| 88 | + test("should NOT identify non-platform packages", () => { |
| 89 | + expect(isNonLinuxPlatformPackage("/home/user/project/node_modules/@swc/core/package.json")).toBe(false); |
| 90 | + expect(isNonLinuxPlatformPackage("/home/user/project/node_modules/next/dist/server/next-server.js")).toBe( |
| 91 | + false |
| 92 | + ); |
| 93 | + expect( |
| 94 | + isNonLinuxPlatformPackage("/home/user/project/node_modules/react/cjs/react.production.min.js") |
| 95 | + ).toBe(false); |
| 96 | + }); |
| 97 | + |
| 98 | + test("should handle pnpm store paths", () => { |
| 99 | + expect( |
| 100 | + isNonLinuxPlatformPackage( |
| 101 | + "/home/user/project/node_modules/.pnpm/@swc+core-darwin-arm64@1.0.0/node_modules/@swc/core-darwin-arm64/swc.darwin-arm64.node" |
| 102 | + ) |
| 103 | + ).toBe(true); |
| 104 | + expect( |
| 105 | + isNonLinuxPlatformPackage( |
| 106 | + "/home/user/project/node_modules/.pnpm/@esbuild+darwin-x64@0.19.0/node_modules/@esbuild/darwin-x64/bin/esbuild" |
| 107 | + ) |
| 108 | + ).toBe(true); |
| 109 | + expect( |
| 110 | + isNonLinuxPlatformPackage( |
| 111 | + "/home/user/project/node_modules/.pnpm/@swc+core-linux-x64-gnu@1.0.0/node_modules/@swc/core-linux-x64-gnu/swc.linux-x64-gnu.node" |
| 112 | + ) |
| 113 | + ).toBe(false); |
| 114 | + }); |
| 115 | +}); |
0 commit comments