Skip to content
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 25 additions & 36 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,13 @@ jobs:
npm install -g @angular/[email protected]
cd sdk
npm install
cd tests/test-apps/sample-server
echo PRIVATE_KEY=${{ secrets.ik_private_key }} >> .env;
npm install
npm run server &
cd ../../../
npm run test:ci
npm run build
env:
CI: true
PUBLIC_KEY: ${{ secrets.ik_public_key }}
PRIVATE_KEY: ${{ secrets.ik_private_key }}
URL_ENDPOINT: ${{ secrets.ik_url_endopint }}
e2e:
runs-on: ubuntu-latest
needs: build

strategy:
matrix:
Expand All @@ -48,41 +41,37 @@ jobs:
with:
node-version: ${{ matrix.node-version }}

- name: Create e2e environment variables
run: |
cd sdk/src/environments
echo export const environment = { > environment.ts;
echo production: false, >> environment.ts;
echo URL_ENDPOINT:\"https://ik.imagekit.io/sdktestingik\", >> environment.ts;
echo PUBLIC_KEY:\"${{ secrets.ik_public_key }}\", >> environment.ts;
echo '};' >> environment.ts;
less environment.ts

- name: Start client server
- name: Build and pack SDK
run: |
cd sdk
npm install
npm start &
- name: Start auth server
npm run build
npm run pack

- name: Install SDK in test-app
run: |
cd sdk/tests/test-apps/sample-server
echo PRIVATE_KEY=${{ secrets.ik_private_key }} >> .env;
cd test-app
# Get SDK version from sdk/package.json
SDK_VERSION=$(node -p "require('../sdk/package.json').version")
echo "Installing SDK version: $SDK_VERSION"

# Update package.json to use the packed tarball
npm install ../sdk/dist/imagekit-angular/imagekit-angular-${SDK_VERSION}.tgz
npm install
npm run server &
env:
CI: true
PUBLIC_KEY: ${{ secrets.ik_public_key }}
PRIVATE_KEY: ${{ secrets.ik_private_key }}
URL_ENDPOINT: https://ik.imagekit.io/sdktestingik
- name: Run E2E tests
uses: cypress-io/github-action@v5

- name: Start test-app server
run: |
cd test-app
npm start &
npx wait-on http://localhost:4200 --timeout 60000

- name: Run Cypress E2E tests
uses: cypress-io/github-action@v6
with:
install: false
working-directory: test-app
wait-on: 'http://localhost:4200'
working-directory: sdk
wait-on-timeout: 60
env:
DEBUG: 'cypress:server:browsers:electron'
CI: true
PUBLIC_KEY: ${{ secrets.ik_public_key }}
PRIVATE_KEY: ${{ secrets.ik_private_key }}
URL_ENDPOINT: https://ik.imagekit.io/sdktestingik
CI: true
10 changes: 1 addition & 9 deletions .github/workflows/npmpublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,10 @@ jobs:
npm install -g @angular/[email protected]
cd sdk
npm install
cd tests/test-apps/sample-server
echo PRIVATE_KEY=${{ secrets.ik_private_key }} >> .env;
npm install
npm run server &
cd ../../../
npm run test:ci
npm run build
env:
CI: true
PUBLIC_KEY: ${{ secrets.ik_public_key }}
PRIVATE_KEY: ${{ secrets.ik_private_key }}
URL_ENDPOINT: ${{ secrets.ik_url_endopint }}

publish:
needs: build
Expand All @@ -53,7 +45,7 @@ jobs:
cd sdk
npm install
npm run build
cd dist/imagekitio-angular
cd dist/imagekit-angular
npm config set //registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN
npm publish
env:
Expand Down
72 changes: 59 additions & 13 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,80 @@
## SDK development

SDK is build in angular 4 for forward compatibilty and `ng-packagr` is used to create final package. Make sure `@angular/cli` is at `v1.4.*` and node ver `14.x` before building the package.
SDK is built using Angular 12.x and `ng-packagr` for packaging. The project is located in the `sdk/` directory.

**Prerequisites:**
- Node.js v14.x
- Angular CLI compatible with Angular 12.x

## Building package

Execute following command from the `sdk` folder to build the library. This creates a package in `dist/imagekitio-angular` folder.
Execute the following command from the `sdk` folder to build the library. This creates a package in `dist/imagekit-angular` folder.
```sh
# run `npm install` for first time
# Install dependencies (first time)
npm install

# Build the SDK
npm run build
```

## Running test cases

The designated directory for the tests is `sdk/tests/sdk-tests` folder. All tests will be executed once on the Chrome Headless browser.
### Unit Tests

The designated directory for the tests is `sdk/tests/sdk-tests` folder. All tests are executed on Chrome Headless browser.

Execute following command from the `sdk` folder to start testing.
Execute the following command from the `sdk` folder to run unit tests:
```sh
# Run tests in watch mode
npm run test

# Run tests once for CI
npm run test:ci
```

### E2E Tests

E2E tests are located in the `test-app/` directory and use Cypress for browser automation.

To run E2E tests:
```sh
# Navigate to test-app directory
cd test-app

# Install the SDK
./install_sdk.sh

# Install dependencies
npm install

# Start the dev server in one terminal
npm start

# Run Cypress tests in another terminal
npm run e2e

# Or open Cypress UI
npm run e2e:open
```

## Building custom SDK for sample angular app

Repository to get sample app: https://github.com/imagekit-samples/quickstart

Before sample apps can be used, `imagekitio-angular` library needs to be packed and installed using the file system within the sample apps. Use the following steps to run any sample app.
Before sample app can be used, `@imagekit/angular` library needs to be packed and installed using the file system within the sample app. Use the following steps to run any sample app:

1. Navigate to the `test-app` directory
2. Run ./install_sdk.sh. This will build and pack the sdk and install it in the `test-app` project

7. Use `npm start` from the `test-app` folder to run the app

## Testing with the test-app

The repository includes a `test-app/` directory that demonstrates SDK usage:

1. In the `sdk` folder, install dependencies with `npm install`
2. Build library with `npm run build`
3. In the `sdk/dist/imagekitio-angular` folder, use `npm pack` to create a tarball with version mentioned in the current package.json for sdk.
4. Go to the Angular sample app's root folder and use `npm install` to install dependencies.
5. Use `npm install <path to this SDK>/sdk/dist/imagekitio-angular/imagekitio-angular-x.x.x.tgz` where x.x.x needs to be replaced with the current version. For example, SDK version is `0.0.1`, then above command becomes `npm install <path to this SDK>/sdk/dist/imagekitio-angular/imagekitio-angular-2.0.0.tgz`
6. Configure sample app with required keys. Use each app's `Readme.md` for exact details.
7. Use npm start from the Angular sample app's root folder to run the app
1. Build the SDK as described above
2. Navigate to `test-app/` directory
3. Install the built SDK: `./install_sdk.sh`
4. Configure environment variables in `test-app/src/environments/`
5. Run the app: `npm start`
6. Access the demo at `http://localhost:4200`
7 changes: 7 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright 2025 ImageKit Private Limited

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.
Loading