|
1 | 1 | ## SDK development |
2 | 2 |
|
3 | | -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. |
| 3 | +SDK is built using Angular 12.x and `ng-packagr` for packaging. The project is located in the `sdk/` directory. |
| 4 | + |
| 5 | +**Prerequisites:** |
| 6 | +- Node.js v14.x |
| 7 | +- Angular CLI compatible with Angular 12.x |
4 | 8 |
|
5 | 9 | ## Building package |
6 | 10 |
|
7 | | -Execute following command from the `sdk` folder to build the library. This creates a package in `dist/imagekitio-angular` folder. |
| 11 | +Execute the following command from the `sdk` folder to build the library. This creates a package in `dist/imagekit-angular` folder. |
8 | 12 | ```sh |
9 | | -# run `npm install` for first time |
| 13 | +# Install dependencies (first time) |
| 14 | +npm install |
| 15 | + |
| 16 | +# Build the SDK |
10 | 17 | npm run build |
11 | 18 | ``` |
12 | 19 |
|
13 | 20 | ## Running test cases |
14 | 21 |
|
15 | | -The designated directory for the tests is `sdk/tests/sdk-tests` folder. All tests will be executed once on the Chrome Headless browser. |
| 22 | +### Unit Tests |
| 23 | + |
| 24 | +The designated directory for the tests is `sdk/tests/sdk-tests` folder. All tests are executed on Chrome Headless browser. |
16 | 25 |
|
17 | | -Execute following command from the `sdk` folder to start testing. |
| 26 | +Execute the following command from the `sdk` folder to run unit tests: |
18 | 27 | ```sh |
| 28 | +# Run tests in watch mode |
19 | 29 | npm run test |
| 30 | + |
| 31 | +# Run tests once for CI |
| 32 | +npm run test:ci |
| 33 | +``` |
| 34 | + |
| 35 | +### E2E Tests |
| 36 | + |
| 37 | +E2E tests are located in the `test-app/` directory and use Cypress for browser automation. |
| 38 | + |
| 39 | +To run E2E tests: |
| 40 | +```sh |
| 41 | +# Navigate to test-app directory |
| 42 | +cd test-app |
| 43 | + |
| 44 | +# Install the SDK |
| 45 | +./install_sdk.sh |
| 46 | + |
| 47 | +# Install dependencies |
| 48 | +npm install |
| 49 | + |
| 50 | +# Start the dev server in one terminal |
| 51 | +npm start |
| 52 | + |
| 53 | +# Run Cypress tests in another terminal |
| 54 | +npm run e2e |
| 55 | + |
| 56 | +# Or open Cypress UI |
| 57 | +npm run e2e:open |
20 | 58 | ``` |
21 | 59 |
|
22 | 60 | ## Building custom SDK for sample angular app |
23 | 61 |
|
24 | 62 | Repository to get sample app: https://github.com/imagekit-samples/quickstart |
25 | 63 |
|
26 | | -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. |
| 64 | +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: |
| 65 | + |
| 66 | +1. Navigate to the `test-app` directory |
| 67 | +2. Run ./install_sdk.sh. This will build and pack the sdk and install it in the `test-app` project |
| 68 | + |
| 69 | +7. Use `npm start` from the `test-app` folder to run the app |
| 70 | + |
| 71 | +## Testing with the test-app |
| 72 | + |
| 73 | +The repository includes a `test-app/` directory that demonstrates SDK usage: |
27 | 74 |
|
28 | | -1. In the `sdk` folder, install dependencies with `npm install` |
29 | | -2. Build library with `npm run build` |
30 | | -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. |
31 | | -4. Go to the Angular sample app's root folder and use `npm install` to install dependencies. |
32 | | -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` |
33 | | -6. Configure sample app with required keys. Use each app's `Readme.md` for exact details. |
34 | | -7. Use npm start from the Angular sample app's root folder to run the app |
| 75 | +1. Build the SDK as described above |
| 76 | +2. Navigate to `test-app/` directory |
| 77 | +3. Install the built SDK: `./install_sdk.sh` |
| 78 | +4. Configure environment variables in `test-app/src/environments/` |
| 79 | +5. Run the app: `npm start` |
| 80 | +6. Access the demo at `http://localhost:4200` |
0 commit comments