diff --git a/.dockerignore b/.dockerignore index 370f11f..9d5d7f8 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,5 +1,8 @@ * +!package.json +!yarn.lock !tsconfig.json -!lib/package.json +!scripts/* +!lib/*.json !lib/**/*.ts diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 9c3db2e..a655c9c 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -124,6 +124,17 @@ jobs: - run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* + - name: Cache + uses: actions/cache@v2 + with: + path: | + .yarn + **/node_modules + key: e2e-${{ hashFiles('yarn.lock') }} + + - name: Install dependencies + run: yarn install --frozen-lockfile --check-files + - name: Download build artifact uses: actions/download-artifact@v2 with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 055b035..b707487 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,4 +21,4 @@ jobs: upstream-branch: main release-branch: release release-tag: ${{ github.event.inputs.tag }} - exclude: '["lib/*", "test/*", "package.json", "yarn.lock"]' + exclude: '["lib/**/*", "test/**/*", "package.json", "yarn.lock"]' diff --git a/CHANGELOG.md b/CHANGELOG.md index 55443dd..de7541e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 10.0.6 (April 01, 2021) + +- Uses Image Optimizer module of [Next.js 10.0.6](https://github.com/vercel/next.js/releases/tag/v10.0.6) ([#3](https://github.com/dealmore/terraform-aws-next-js-image-optimization/pull/3)) +- Bundling of the image optimizer has changed from ncc to nft ([#23](https://github.com/dealmore/terraform-aws-next-js-image-optimization/issues/23), [#24](https://github.com/dealmore/terraform-aws-next-js-image-optimization/pull/24)) + ## 10.0.5 (March 15, 2021) **Note 1:** From now on we aligning the versioning schema with the releases of Next.js. diff --git a/README.md b/README.md index e67b026..0191c59 100644 --- a/README.md +++ b/README.md @@ -130,7 +130,7 @@ module.exports = { | next\_image\_device\_sizes | Allowed device sizes that should be used for image optimization. | `list(number)` | `null` | no | | next\_image\_domains | Allowed origin domains that can be used for fetching images. | `list(string)` | `[]` | no | | next\_image\_image\_sizes | Allowed image sizes that should be used for image optimization. | `list(number)` | `null` | no | -| next\_image\_version | Next.js version from where you want to use the image optimizer from. Supports semver ranges. | `string` | `"10.0.5"` | no | +| next\_image\_version | Next.js version from where you want to use the image optimizer from. Supports semver ranges. | `string` | `"10.0.6"` | no | | source\_bucket\_id | When your static files are deployed to a Bucket (e.g. with Terraform Next.js) the optimizer can pull the source from the bucket rather than over the internet. | `string` | `null` | no | | tags | Tag metadata to label AWS resources that support tags. | `map(string)` | `{}` | no | diff --git a/buildimage.Dockerfile b/buildimage.Dockerfile index 4e1e358..102640c 100644 --- a/buildimage.Dockerfile +++ b/buildimage.Dockerfile @@ -4,11 +4,12 @@ FROM amazon/aws-sam-cli-emulation-image-nodejs14.x +# Install yarn +RUN npm i -g yarn + WORKDIR /app -ADD tsconfig.json \ - lib \ - /app/ +COPY . . -RUN npm i &&\ - npm run build +RUN yarn --frozen-lockfile &&\ + yarn build diff --git a/lib/.gitignore b/lib/.gitignore index a03dbc6..56120fd 100644 --- a/lib/.gitignore +++ b/lib/.gitignore @@ -1,2 +1,6 @@ dist dist.zip + +# Temporary license files +third-party-licenses.txt +LICENSE diff --git a/scripts/build-local.sh b/scripts/build-local.sh index 80d81a2..76b6771 100755 --- a/scripts/build-local.sh +++ b/scripts/build-local.sh @@ -8,5 +8,5 @@ docker build -t "${IMAGE_NAME}" -f buildimage.Dockerfile . # Copy the artifact back to the host machine # https://stackoverflow.com/a/31316636/831465 id=$(docker create local/tf-next-image-optiomizer-build sh) -docker cp $id:/app/dist.zip ./lib/dist.zip +docker cp $id:/app/lib/dist.zip ./lib/dist.zip docker rm -v $id diff --git a/scripts/bundle.js b/scripts/bundle.js new file mode 100644 index 0000000..dac8e47 --- /dev/null +++ b/scripts/bundle.js @@ -0,0 +1,54 @@ +/** + * Creates a bundled zip file with all dependencies for AWS Lambda + */ + +const path = require('path'); +const fs = require('fs'); +const { nodeFileTrace } = require('@vercel/nft'); +const glob = require('glob'); +const archiver = require('archiver'); + +const workspaceRoot = path.resolve(__dirname, '..'); +const buildDir = path.resolve(workspaceRoot, 'lib/dist'); + +async function main() { + // Get all files from build dir + const buildFiles = glob.sync('**/*.js', { cwd: buildDir, absolute: true }); + + console.log('buildFiles', buildFiles); + + const { fileList } = await nodeFileTrace(buildFiles, { + base: workspaceRoot, + processCwd: process.cwd(), + // aws-sdk is already provided in Lambda images + ignore: ['**/aws-sdk/**/*'], + }); + + // Create zip file + await new Promise((resolve, reject) => { + const outputFile = fs.createWriteStream( + path.resolve(workspaceRoot, 'lib/dist.zip') + ); + + outputFile.on('close', () => resolve()); + outputFile.on('error', (error) => reject(error)); + + const archive = archiver('zip', { + zlib: { level: 5 }, // Optimal compression + }); + archive.pipe(outputFile); + + for (const file of fileList) { + // Remove lib/ and lib/dist/ prefix + const fileName = file.replace(/^lib\/(dist\/)?/, ''); + + archive.append(fs.createReadStream(path.join(workspaceRoot, file)), { + name: fileName, + mode: 0o666, + }); + } + archive.finalize(); + }); +} + +main(); diff --git a/test/__snapshots__/e2e/external_accept_all_w-2048_q-75_bmp_test.bmp.bmp b/test/__snapshots__/e2e/external_accept_all_w-2048_q-75_bmp_test.bmp.bmp deleted file mode 100644 index d84c38f..0000000 Binary files a/test/__snapshots__/e2e/external_accept_all_w-2048_q-75_bmp_test.bmp.bmp and /dev/null differ diff --git a/test/__snapshots__/e2e/external_accept_all_w-2048_q-75_gif_test.gif.gif b/test/__snapshots__/e2e/external_accept_all_w-2048_q-75_gif_test.gif.gif deleted file mode 100644 index b74d2a3..0000000 Binary files a/test/__snapshots__/e2e/external_accept_all_w-2048_q-75_gif_test.gif.gif and /dev/null differ diff --git a/test/__snapshots__/e2e/external_accept_all_w-2048_q-75_jpeg_test.jpg.jpeg b/test/__snapshots__/e2e/external_accept_all_w-2048_q-75_jpeg_test.jpg.jpeg deleted file mode 100644 index 7cf26fb..0000000 Binary files a/test/__snapshots__/e2e/external_accept_all_w-2048_q-75_jpeg_test.jpg.jpeg and /dev/null differ diff --git a/test/__snapshots__/e2e/external_accept_all_w-2048_q-75_png_test.png.png b/test/__snapshots__/e2e/external_accept_all_w-2048_q-75_png_test.png.png deleted file mode 100644 index 22b3092..0000000 Binary files a/test/__snapshots__/e2e/external_accept_all_w-2048_q-75_png_test.png.png and /dev/null differ diff --git a/test/__snapshots__/e2e/external_accept_all_w-2048_q-75_svg_test.svg.svg b/test/__snapshots__/e2e/external_accept_all_w-2048_q-75_svg_test.svg.svg deleted file mode 100644 index af83c4c..0000000 --- a/test/__snapshots__/e2e/external_accept_all_w-2048_q-75_svg_test.svg.svg +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/test/__snapshots__/e2e/external_accept_all_w-2048_q-75_tiff_test.tiff.tiff b/test/__snapshots__/e2e/external_accept_all_w-2048_q-75_tiff_test.tiff.tiff deleted file mode 100644 index bb8c8a8..0000000 Binary files a/test/__snapshots__/e2e/external_accept_all_w-2048_q-75_tiff_test.tiff.tiff and /dev/null differ diff --git a/test/__snapshots__/e2e/external_accept_all_w-2048_q-75_webp_animated.webp.webp b/test/__snapshots__/e2e/external_accept_all_w-2048_q-75_webp_animated.webp.webp deleted file mode 100644 index 7a1d3fe..0000000 Binary files a/test/__snapshots__/e2e/external_accept_all_w-2048_q-75_webp_animated.webp.webp and /dev/null differ diff --git a/test/__snapshots__/e2e/external_accept_all_w-2048_q-75_webp_test.webp.webp b/test/__snapshots__/e2e/external_accept_all_w-2048_q-75_webp_test.webp.webp deleted file mode 100644 index 2a8dbd1..0000000 Binary files a/test/__snapshots__/e2e/external_accept_all_w-2048_q-75_webp_test.webp.webp and /dev/null differ diff --git a/test/__snapshots__/e2e/internal_accept_all_w-2048_q-75_bmp_test.bmp.bmp b/test/__snapshots__/e2e/internal_accept_all_w-2048_q-75_bmp_test.bmp.bmp deleted file mode 100644 index d84c38f..0000000 Binary files a/test/__snapshots__/e2e/internal_accept_all_w-2048_q-75_bmp_test.bmp.bmp and /dev/null differ diff --git a/test/__snapshots__/e2e/internal_accept_all_w-2048_q-75_gif_test.gif.gif b/test/__snapshots__/e2e/internal_accept_all_w-2048_q-75_gif_test.gif.gif deleted file mode 100644 index b74d2a3..0000000 Binary files a/test/__snapshots__/e2e/internal_accept_all_w-2048_q-75_gif_test.gif.gif and /dev/null differ diff --git a/test/__snapshots__/e2e/internal_accept_all_w-2048_q-75_jpeg_test.jpg.jpeg b/test/__snapshots__/e2e/internal_accept_all_w-2048_q-75_jpeg_test.jpg.jpeg deleted file mode 100644 index 7cf26fb..0000000 Binary files a/test/__snapshots__/e2e/internal_accept_all_w-2048_q-75_jpeg_test.jpg.jpeg and /dev/null differ diff --git a/test/__snapshots__/e2e/internal_accept_all_w-2048_q-75_png_test.png.png b/test/__snapshots__/e2e/internal_accept_all_w-2048_q-75_png_test.png.png deleted file mode 100644 index 22b3092..0000000 Binary files a/test/__snapshots__/e2e/internal_accept_all_w-2048_q-75_png_test.png.png and /dev/null differ diff --git a/test/__snapshots__/e2e/internal_accept_all_w-2048_q-75_svg_test.svg.svg b/test/__snapshots__/e2e/internal_accept_all_w-2048_q-75_svg_test.svg.svg deleted file mode 100644 index af83c4c..0000000 --- a/test/__snapshots__/e2e/internal_accept_all_w-2048_q-75_svg_test.svg.svg +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/test/__snapshots__/e2e/internal_accept_all_w-2048_q-75_tiff_test.tiff.tiff b/test/__snapshots__/e2e/internal_accept_all_w-2048_q-75_tiff_test.tiff.tiff deleted file mode 100644 index bb8c8a8..0000000 Binary files a/test/__snapshots__/e2e/internal_accept_all_w-2048_q-75_tiff_test.tiff.tiff and /dev/null differ diff --git a/test/__snapshots__/e2e/internal_accept_all_w-2048_q-75_webp_animated.webp.webp b/test/__snapshots__/e2e/internal_accept_all_w-2048_q-75_webp_animated.webp.webp deleted file mode 100644 index 7a1d3fe..0000000 Binary files a/test/__snapshots__/e2e/internal_accept_all_w-2048_q-75_webp_animated.webp.webp and /dev/null differ diff --git a/test/__snapshots__/e2e/internal_accept_all_w-2048_q-75_webp_test.webp.webp b/test/__snapshots__/e2e/internal_accept_all_w-2048_q-75_webp_test.webp.webp deleted file mode 100644 index 2a8dbd1..0000000 Binary files a/test/__snapshots__/e2e/internal_accept_all_w-2048_q-75_webp_test.webp.webp and /dev/null differ diff --git a/test/__snapshots__/external_accept_all_w-2048_q-75_bmp_test.bmp.bmp b/test/__snapshots__/external_accept_all_w-2048_q-75_bmp_test.bmp.bmp deleted file mode 100644 index d84c38f..0000000 Binary files a/test/__snapshots__/external_accept_all_w-2048_q-75_bmp_test.bmp.bmp and /dev/null differ diff --git a/test/__snapshots__/external_accept_all_w-2048_q-75_gif_test.gif.gif b/test/__snapshots__/external_accept_all_w-2048_q-75_gif_test.gif.gif deleted file mode 100644 index b74d2a3..0000000 Binary files a/test/__snapshots__/external_accept_all_w-2048_q-75_gif_test.gif.gif and /dev/null differ diff --git a/test/__snapshots__/external_accept_all_w-2048_q-75_jpeg_test.jpg.jpeg b/test/__snapshots__/external_accept_all_w-2048_q-75_jpeg_test.jpg.jpeg deleted file mode 100644 index 7cf26fb..0000000 Binary files a/test/__snapshots__/external_accept_all_w-2048_q-75_jpeg_test.jpg.jpeg and /dev/null differ diff --git a/test/__snapshots__/external_accept_all_w-2048_q-75_png_test.png.png b/test/__snapshots__/external_accept_all_w-2048_q-75_png_test.png.png deleted file mode 100644 index 22b3092..0000000 Binary files a/test/__snapshots__/external_accept_all_w-2048_q-75_png_test.png.png and /dev/null differ diff --git a/test/__snapshots__/external_accept_all_w-2048_q-75_svg_test.svg.svg b/test/__snapshots__/external_accept_all_w-2048_q-75_svg_test.svg.svg deleted file mode 100644 index af83c4c..0000000 --- a/test/__snapshots__/external_accept_all_w-2048_q-75_svg_test.svg.svg +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/test/__snapshots__/external_accept_all_w-2048_q-75_tiff_test.tiff.tiff b/test/__snapshots__/external_accept_all_w-2048_q-75_tiff_test.tiff.tiff deleted file mode 100644 index bb8c8a8..0000000 Binary files a/test/__snapshots__/external_accept_all_w-2048_q-75_tiff_test.tiff.tiff and /dev/null differ diff --git a/test/__snapshots__/external_accept_all_w-2048_q-75_webp_animated.webp.webp b/test/__snapshots__/external_accept_all_w-2048_q-75_webp_animated.webp.webp deleted file mode 100644 index 7a1d3fe..0000000 Binary files a/test/__snapshots__/external_accept_all_w-2048_q-75_webp_animated.webp.webp and /dev/null differ diff --git a/test/__snapshots__/external_accept_all_w-2048_q-75_webp_test.webp.webp b/test/__snapshots__/external_accept_all_w-2048_q-75_webp_test.webp.webp deleted file mode 100644 index 2a8dbd1..0000000 Binary files a/test/__snapshots__/external_accept_all_w-2048_q-75_webp_test.webp.webp and /dev/null differ diff --git a/test/__snapshots__/external_accept_webp_w-2048_q-75_bmp_test.bmp.bmp b/test/__snapshots__/external_accept_webp_w-2048_q-75_bmp_test.bmp.bmp deleted file mode 100644 index d84c38f..0000000 Binary files a/test/__snapshots__/external_accept_webp_w-2048_q-75_bmp_test.bmp.bmp and /dev/null differ diff --git a/test/__snapshots__/external_accept_webp_w-2048_q-75_gif_test.gif.webp b/test/__snapshots__/external_accept_webp_w-2048_q-75_gif_test.gif.webp deleted file mode 100644 index fa90f7b..0000000 Binary files a/test/__snapshots__/external_accept_webp_w-2048_q-75_gif_test.gif.webp and /dev/null differ diff --git a/test/__snapshots__/external_accept_webp_w-2048_q-75_jpeg_test.jpg.webp b/test/__snapshots__/external_accept_webp_w-2048_q-75_jpeg_test.jpg.webp deleted file mode 100644 index 4b771b0..0000000 Binary files a/test/__snapshots__/external_accept_webp_w-2048_q-75_jpeg_test.jpg.webp and /dev/null differ diff --git a/test/__snapshots__/external_accept_webp_w-2048_q-75_png_test.png.webp b/test/__snapshots__/external_accept_webp_w-2048_q-75_png_test.png.webp deleted file mode 100644 index efb63b6..0000000 Binary files a/test/__snapshots__/external_accept_webp_w-2048_q-75_png_test.png.webp and /dev/null differ diff --git a/test/__snapshots__/external_accept_webp_w-2048_q-75_svg_test.svg.svg b/test/__snapshots__/external_accept_webp_w-2048_q-75_svg_test.svg.svg deleted file mode 100644 index af83c4c..0000000 --- a/test/__snapshots__/external_accept_webp_w-2048_q-75_svg_test.svg.svg +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/test/__snapshots__/external_accept_webp_w-2048_q-75_tiff_test.tiff.webp b/test/__snapshots__/external_accept_webp_w-2048_q-75_tiff_test.tiff.webp deleted file mode 100644 index 71cdb8c..0000000 Binary files a/test/__snapshots__/external_accept_webp_w-2048_q-75_tiff_test.tiff.webp and /dev/null differ diff --git a/test/__snapshots__/external_accept_webp_w-2048_q-75_webp_animated.webp.webp b/test/__snapshots__/external_accept_webp_w-2048_q-75_webp_animated.webp.webp deleted file mode 100644 index 7a1d3fe..0000000 Binary files a/test/__snapshots__/external_accept_webp_w-2048_q-75_webp_animated.webp.webp and /dev/null differ diff --git a/test/__snapshots__/external_accept_webp_w-2048_q-75_webp_test.webp.webp b/test/__snapshots__/external_accept_webp_w-2048_q-75_webp_test.webp.webp deleted file mode 100644 index 2a8dbd1..0000000 Binary files a/test/__snapshots__/external_accept_webp_w-2048_q-75_webp_test.webp.webp and /dev/null differ diff --git a/test/__snapshots__/internal_accept_all_w-2048_q-75_bmp_test.bmp.bmp b/test/__snapshots__/internal_accept_all_w-2048_q-75_bmp_test.bmp.bmp deleted file mode 100644 index d84c38f..0000000 Binary files a/test/__snapshots__/internal_accept_all_w-2048_q-75_bmp_test.bmp.bmp and /dev/null differ diff --git a/test/__snapshots__/internal_accept_all_w-2048_q-75_gif_test.gif.gif b/test/__snapshots__/internal_accept_all_w-2048_q-75_gif_test.gif.gif deleted file mode 100644 index b74d2a3..0000000 Binary files a/test/__snapshots__/internal_accept_all_w-2048_q-75_gif_test.gif.gif and /dev/null differ diff --git a/test/__snapshots__/internal_accept_all_w-2048_q-75_jpeg_test.jpg.jpeg b/test/__snapshots__/internal_accept_all_w-2048_q-75_jpeg_test.jpg.jpeg deleted file mode 100644 index 7cf26fb..0000000 Binary files a/test/__snapshots__/internal_accept_all_w-2048_q-75_jpeg_test.jpg.jpeg and /dev/null differ diff --git a/test/__snapshots__/internal_accept_all_w-2048_q-75_png_test.png.png b/test/__snapshots__/internal_accept_all_w-2048_q-75_png_test.png.png deleted file mode 100644 index 22b3092..0000000 Binary files a/test/__snapshots__/internal_accept_all_w-2048_q-75_png_test.png.png and /dev/null differ diff --git a/test/__snapshots__/internal_accept_all_w-2048_q-75_svg_test.svg.svg b/test/__snapshots__/internal_accept_all_w-2048_q-75_svg_test.svg.svg deleted file mode 100644 index af83c4c..0000000 --- a/test/__snapshots__/internal_accept_all_w-2048_q-75_svg_test.svg.svg +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/test/__snapshots__/internal_accept_all_w-2048_q-75_tiff_test.tiff.tiff b/test/__snapshots__/internal_accept_all_w-2048_q-75_tiff_test.tiff.tiff deleted file mode 100644 index bb8c8a8..0000000 Binary files a/test/__snapshots__/internal_accept_all_w-2048_q-75_tiff_test.tiff.tiff and /dev/null differ diff --git a/test/__snapshots__/internal_accept_all_w-2048_q-75_webp_animated.webp.webp b/test/__snapshots__/internal_accept_all_w-2048_q-75_webp_animated.webp.webp deleted file mode 100644 index 7a1d3fe..0000000 Binary files a/test/__snapshots__/internal_accept_all_w-2048_q-75_webp_animated.webp.webp and /dev/null differ diff --git a/test/__snapshots__/internal_accept_all_w-2048_q-75_webp_test.webp.webp b/test/__snapshots__/internal_accept_all_w-2048_q-75_webp_test.webp.webp deleted file mode 100644 index 2a8dbd1..0000000 Binary files a/test/__snapshots__/internal_accept_all_w-2048_q-75_webp_test.webp.webp and /dev/null differ diff --git a/test/__snapshots__/internal_accept_webp_w-2048_q-75_bmp_test.bmp.bmp b/test/__snapshots__/internal_accept_webp_w-2048_q-75_bmp_test.bmp.bmp deleted file mode 100644 index d84c38f..0000000 Binary files a/test/__snapshots__/internal_accept_webp_w-2048_q-75_bmp_test.bmp.bmp and /dev/null differ diff --git a/test/__snapshots__/internal_accept_webp_w-2048_q-75_gif_test.gif.webp b/test/__snapshots__/internal_accept_webp_w-2048_q-75_gif_test.gif.webp deleted file mode 100644 index fa90f7b..0000000 Binary files a/test/__snapshots__/internal_accept_webp_w-2048_q-75_gif_test.gif.webp and /dev/null differ diff --git a/test/__snapshots__/internal_accept_webp_w-2048_q-75_jpeg_test.jpg.webp b/test/__snapshots__/internal_accept_webp_w-2048_q-75_jpeg_test.jpg.webp deleted file mode 100644 index 4b771b0..0000000 Binary files a/test/__snapshots__/internal_accept_webp_w-2048_q-75_jpeg_test.jpg.webp and /dev/null differ diff --git a/test/__snapshots__/internal_accept_webp_w-2048_q-75_png_test.png.webp b/test/__snapshots__/internal_accept_webp_w-2048_q-75_png_test.png.webp deleted file mode 100644 index efb63b6..0000000 Binary files a/test/__snapshots__/internal_accept_webp_w-2048_q-75_png_test.png.webp and /dev/null differ diff --git a/test/__snapshots__/internal_accept_webp_w-2048_q-75_svg_test.svg.svg b/test/__snapshots__/internal_accept_webp_w-2048_q-75_svg_test.svg.svg deleted file mode 100644 index af83c4c..0000000 --- a/test/__snapshots__/internal_accept_webp_w-2048_q-75_svg_test.svg.svg +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/test/__snapshots__/internal_accept_webp_w-2048_q-75_tiff_test.tiff.webp b/test/__snapshots__/internal_accept_webp_w-2048_q-75_tiff_test.tiff.webp deleted file mode 100644 index 71cdb8c..0000000 Binary files a/test/__snapshots__/internal_accept_webp_w-2048_q-75_tiff_test.tiff.webp and /dev/null differ diff --git a/test/__snapshots__/internal_accept_webp_w-2048_q-75_webp_animated.webp.webp b/test/__snapshots__/internal_accept_webp_w-2048_q-75_webp_animated.webp.webp deleted file mode 100644 index 7a1d3fe..0000000 Binary files a/test/__snapshots__/internal_accept_webp_w-2048_q-75_webp_animated.webp.webp and /dev/null differ diff --git a/test/__snapshots__/internal_accept_webp_w-2048_q-75_webp_test.webp.webp b/test/__snapshots__/internal_accept_webp_w-2048_q-75_webp_test.webp.webp deleted file mode 100644 index 2a8dbd1..0000000 Binary files a/test/__snapshots__/internal_accept_webp_w-2048_q-75_webp_test.webp.webp and /dev/null differ diff --git a/test/fixtures/bmp/test.bmp b/test/fixtures/bmp/test.bmp deleted file mode 100644 index d84c38f..0000000 Binary files a/test/fixtures/bmp/test.bmp and /dev/null differ diff --git a/test/fixtures/gif/test.gif b/test/fixtures/gif/test.gif deleted file mode 100644 index c3ada43..0000000 Binary files a/test/fixtures/gif/test.gif and /dev/null differ diff --git a/test/fixtures/jpeg/test.jpg b/test/fixtures/jpeg/test.jpg deleted file mode 100644 index fde453b..0000000 Binary files a/test/fixtures/jpeg/test.jpg and /dev/null differ diff --git a/test/fixtures/png/test.png b/test/fixtures/png/test.png deleted file mode 100644 index a275523..0000000 Binary files a/test/fixtures/png/test.png and /dev/null differ diff --git a/test/fixtures/svg/test.svg b/test/fixtures/svg/test.svg deleted file mode 100644 index af83c4c..0000000 --- a/test/fixtures/svg/test.svg +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/test/fixtures/tiff/test.tiff b/test/fixtures/tiff/test.tiff deleted file mode 100644 index 70d939b..0000000 Binary files a/test/fixtures/tiff/test.tiff and /dev/null differ diff --git a/test/fixtures/webp/animated.webp b/test/fixtures/webp/animated.webp deleted file mode 100644 index 7a1d3fe..0000000 Binary files a/test/fixtures/webp/animated.webp and /dev/null differ diff --git a/test/fixtures/webp/test.webp b/test/fixtures/webp/test.webp deleted file mode 100644 index efb63b6..0000000 Binary files a/test/fixtures/webp/test.webp and /dev/null differ diff --git a/test/utils/host-ip-address.ts b/test/utils/host-ip-address.ts deleted file mode 100644 index 33f466f..0000000 --- a/test/utils/host-ip-address.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { networkInterfaces } from 'os'; - -/** - * Utility to find the local ip address - * @see: https://stackoverflow.com/a/8440736/831465 - */ -export function getLocalIpAddressFromHost() { - const nets = networkInterfaces(); - const results: Record> = {}; // or just '{}', an empty object - - for (const name of Object.keys(nets)) { - for (const net of nets[name]) { - // skip over non-ipv4 and internal (i.e. 127.0.0.1) addresses - if (net.family === 'IPv4' && !net.internal) { - if (!results[name]) { - results[name] = []; - } - - results[name].push(net.address); - } - } - } - - // Get the first address we find - for (const [, addresses] of Object.entries(results)) { - for (const address of addresses) { - return address; - } - } -} diff --git a/test/utils/s3-public-dir.ts b/test/utils/s3-public-dir.ts deleted file mode 100644 index 787ed2e..0000000 --- a/test/utils/s3-public-dir.ts +++ /dev/null @@ -1,109 +0,0 @@ -import S3 from 'aws-sdk/clients/s3'; -import { randomBytes } from 'crypto'; -import { promises as fs, createReadStream } from 'fs'; -import * as path from 'path'; -import { getType } from 'mime'; - -// Upload the content of the dirPath to the bucket -// https://stackoverflow.com/a/46213474/831465 -async function uploadDir( - s3: S3, - s3Path: string, - bucketName: string, - cacheControl?: string -) { - async function getFiles(dir: string): Promise { - const dirents = await fs.readdir(dir, { withFileTypes: true }); - const files = await Promise.all( - dirents.map((dirent) => { - const res = path.resolve(dir, dirent.name); - return dirent.isDirectory() ? getFiles(res) : res; - }) - ); - return Array.prototype.concat(...files); - } - - const files = (await getFiles(s3Path)) as string[]; - await Promise.all( - files - .filter((filePath) => !filePath.includes('.DS_Store')) - .map((filePath) => { - // Restore the relative structure - const objectKey = path.relative(s3Path, filePath); - return s3 - .putObject({ - Key: objectKey, - Bucket: bucketName, - Body: createReadStream(filePath), - CacheControl: cacheControl, - ContentType: getType(filePath) ?? undefined, - }) - .promise(); - }) - ); - - return files; -} - -/** - * Creates a public bucket and uploads the content of dir to it - * Returns the bucket name - */ -export async function s3PublicDir( - s3: S3, - dirPath: string, - cacheControl?: string -) { - const bucketName = randomBytes(8).toString('hex'); - - // Configure the bucket so that the objects can be accessed publicly - const bucketPolicy = { - Bucket: bucketName, - Policy: `{ - "Version": "2012-10-17", - "Statement": [ - { - "Action": [ - "s3:GetBucketLocation", - "s3:ListBucket" - ], - "Effect": "Allow", - "Principal": { - "AWS": [ - "*" - ] - }, - "Resource": [ - "arn:aws:s3:::${bucketName}" - ], - "Sid": "" - }, - { - "Sid": "", - "Effect": "Allow", - "Principal": { - "AWS": "*" - }, - "Action": [ - "s3:GetObject" - ], - "Resource": [ - "arn:aws:s3:::${bucketName}/*" - ] - } - ] - }`, - }; - - await s3 - .createBucket({ - Bucket: bucketName, - ACL: 'public-read', - }) - .promise(); - await s3.putBucketPolicy(bucketPolicy).promise(); - - const files = await uploadDir(s3, dirPath, bucketName, cacheControl); - - return { bucketName, files }; -} diff --git a/tsconfig.json b/tsconfig.json index c1fb923..c2f611b 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { "target": "es2019", - "lib": ["es2019"], + "lib": ["es2019", "DOM"], "outDir": "dist", "module": "commonjs", "moduleResolution": "node", @@ -10,5 +10,6 @@ "sourceMap": false, "experimentalDecorators": true, "esModuleInterop": true - } + }, + "exclude": ["node_modules"] } diff --git a/variables.tf b/variables.tf index 5305cd7..5fa0f00 100644 --- a/variables.tf +++ b/variables.tf @@ -4,7 +4,7 @@ variable "next_image_version" { description = "Next.js version from where you want to use the image optimizer from. Supports semver ranges." type = string - default = "10.0.5" + default = "10.0.6" } variable "next_image_domains" {