diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..bab007b --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,68 @@ +name: CI + +on: [push, pull_request] + +permissions: + contents: read + +jobs: + build: + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + node-version: [22.x] + astro-version: ["3", "4", "5", "6"] + include: + - astro-version: "3" + node-adapter: "@astrojs/node@^6" + - astro-version: "4" + node-adapter: "@astrojs/node@^8" + - astro-version: "5" + node-adapter: "@astrojs/node@^9" + - astro-version: "6" + node-adapter: "@astrojs/node@^10" + + steps: + - uses: actions/checkout@v4 + + - name: Install pnpm + uses: pnpm/action-setup@v4 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: 'pnpm' + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Build + run: pnpm build + + - name: Pack the package + run: | + cd imagekit-astro + pnpm pack + + - name: Setup test-app with packed package and target Astro version + run: | + cd test-app + pnpm remove @imagekit/astro || true + pnpm add ../imagekit-astro/imagekit-astro-*.tgz + pnpm add astro@${{ matrix.astro-version }} + pnpm add ${{ matrix.node-adapter }} + + - name: Install Playwright + run: | + cd test-app + pnpm exec playwright install --with-deps + + - name: Run E2E tests + run: | + cd test-app + pnpm test:e2e + env: + CI: true + ASTRO_VERSION: ${{ matrix.astro-version }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..7314db0 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,52 @@ +name: Publish + +on: + release: + types: [published] + +permissions: + contents: read + id-token: write + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Install pnpm + uses: pnpm/action-setup@v4 + + - uses: actions/setup-node@v4 + with: + node-version: 20 + registry-url: https://registry.npmjs.org/ + cache: 'pnpm' + + - name: Install + run: pnpm install --frozen-lockfile + + - name: Build SDK + run: pnpm --filter @imagekit/astro build + + - name: Stage README and LICENSE into package + run: | + cp README.md imagekit-astro/README.md + cp LICENSE imagekit-astro/LICENSE + + - name: NPM Publish + working-directory: imagekit-astro + run: | + npm whoami + VERSION=$(node -p "require('./package.json').version") + # Stable versions go to "latest", pre-release versions go to "beta" + if [[ "$VERSION" =~ ^[^-]+$ ]]; then + NPM_TAG="latest" + else + NPM_TAG="beta" + fi + echo "Publishing $VERSION with $NPM_TAG tag." + npm publish --tag $NPM_TAG --access public --provenance + env: + NODE_AUTH_TOKEN: ${{ secrets.npm_token }} + CI: true diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0952345 --- /dev/null +++ b/.gitignore @@ -0,0 +1,29 @@ +# Dependencies +node_modules/ + +# Build output +dist/ + +# IDE +.vscode/ +.idea/ +*.swp +*.swo + +# OS +.DS_Store +Thumbs.db + +# Environment +.env +.env.local +.env.*.local + +# Astro +.astro/ + +# Test artifacts +test-results/ +playwright-report/ +coverage/ +imagekit-astro/imagekit-astro-*.tgz diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..cf04042 --- /dev/null +++ b/.npmrc @@ -0,0 +1,2 @@ +shamefully-hoist=true +strict-peer-dependencies=false diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..3007f73 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) ImageKit Private Limited 2025 + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index e8c6ce5..8a862f7 100644 --- a/README.md +++ b/README.md @@ -1 +1,127 @@ -Imagekit Astro +[ImageKit.io](https://imagekit.io) + +# ImageKit.io Astro SDK + +[![npm version](https://img.shields.io/npm/v/@imagekit/astro)](https://www.npmjs.com/package/@imagekit/astro) +[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) +[![Twitter Follow](https://img.shields.io/twitter/follow/imagekitio?label=Follow&style=social)](https://twitter.com/ImagekitIo) + +## Introduction + +ImageKit Astro SDK plugs ImageKit.io into Astro's built-in image pipeline. It allows you to: + +- Render images with Astro's `` and `` components, served from ImageKit with automatic optimization, responsive `srcset`, and lazy loading. +- Apply real-time transformations (resize, crop, focus, quality, format) using URL parameters. +- Apply AI-powered transformations such as background removal, generative fill, and smart cropping via the `transformation` prop. +- Render optimized `