|
1 |
| -To test out changes in snap-in locally, developers can create a snap-in version in test mode. |
2 |
| -A snap-in version created in test mode enables developers to specify a public HTTP URL to receive events from DevRev. This makes for |
| 1 | +To test out changes in snap-in locally, you can create a snap-in version in test mode. |
| 2 | +A snap-in version created in test mode enables you to specify a public HTTP URL to receive events from DevRev. This makes for |
3 | 3 | quick code changes on the local machine without needing to repeatedly deploy the snap-in again for testing the changes.
|
4 | 4 |
|
5 |
| -To set up the framework, the developer needs to |
| 5 | +To set up the framework, follow these steps. |
6 | 6 |
|
7 |
| -- Run the server local server present in the template on the mentioned port. |
8 |
| -- Expose this port to a public URL. |
9 |
| -- Create a snap-in version in test mode mentioning this URL. |
10 |
| - |
11 |
| -### Setting up the server |
12 |
| - |
13 |
| -To test out a snap-in version locally, follow the below steps: |
| 7 | +<Steps> |
| 8 | +### Set up the server |
14 | 9 |
|
15 | 10 | 1. Run a server locally to ingest events from DevRev. The `port` parameter is optional. If not set, the server starts default on `8000`.
|
16 | 11 |
|
17 | 12 | ```
|
18 | 13 | npm run test:server -- --port=<PORT>
|
19 | 14 | ```
|
20 | 15 |
|
21 |
| -2. Expose the local port as a publicly available URL. We recommend using [`ngrok`](https://ngrok.com/download) since it is free and easy to set up. The command for running ngrok tunnelling on port `8000`: |
| 16 | +2. Expose the local port as a publicly available URL. We recommend using [`ngrok`](https://ngrok.com/download) since it is free and easy to set up. The command for running ngrok tunneling on port `8000`: |
22 | 17 |
|
23 | 18 | ```
|
24 | 19 | ngrok http 8000
|
25 | 20 | ```
|
26 | 21 |
|
27 |
| -This returns a public HTTP URL. |
| 22 | + This returns a public HTTP URL. |
28 | 23 |
|
29 |
| -3. Create a snap-in version with the `testing-url` flag set |
| 24 | +3. Create a snap-in version with the `testing-url` flag set. |
30 | 25 |
|
31 | 26 | ```
|
32 | 27 | devrev snap_in_version create-one --manifest <manifest path> --create-package --testing-url <HTTP_URL>
|
33 | 28 | ```
|
34 | 29 |
|
35 |
| -Here, `HTTP_URL` is the publicly available URL from Step 2. The URL should start with `http` or `https`. Do note that |
36 |
| -the developer cannot use the `path` and `testing-url` flags together. |
| 30 | + `HTTP_URL` is the publicly available URL from the previous step. The URL should start with `http` or `https`. Do note that |
| 31 | + the developer cannot use the `path` and `testing-url` flags together. |
37 | 32 |
|
38 | 33 | 4. Once the snap-in version is ready, create a snap-in, update, and activate it.
|
39 | 34 |
|
40 | 35 | ```
|
41 | 36 | devrev snap_in draft
|
42 |
| - ``` |
43 |
| - |
44 |
| - Update the snap-in through UI or using the CLI: |
45 |
| - |
46 |
| - ``` |
47 | 37 | devrev snap_in update
|
48 |
| - ``` |
49 |
| - |
50 |
| - Activate the snap-in through UI or the CLI command: |
51 |
| - |
52 |
| - ``` |
53 | 38 | devrev snap_in activate
|
54 | 39 | ```
|
55 | 40 |
|
56 |
| -### Receiving events locally |
| 41 | +### Receive events locally |
57 | 42 |
|
58 | 43 | After the snap-in has been activated, it can receive events locally from DevRev as a
|
59 |
| -snap-in would. If the snap-in is listening to `work_created` event type, then creating a |
60 |
| -new work-item would send the event to the local server. |
| 44 | +snap-in would. For example, if the snap-in is listening for the `work_created` event type, then creating a |
| 45 | +new work item would send the event to the local server. |
61 | 46 |
|
62 |
| -If utilizing ngrok, accessing the ngrok UI is possible by opening http://127.0.0.1:4040/ in the browser. This interface offers a neat way to review the list of requests and replay them if necessary. |
| 47 | +If utilizing ngrok, you can access the ngrok UI by opening http://127.0.0.1:4040/ in the browser. This interface offers a neat way to review the list of requests and replay them if necessary. |
63 | 48 |
|
64 |
| -The service account token included with the request is valid for only 30 minutes. Therefore, attempting to call the DevRev API with that token for events older than this timeframe will result in a '401 Unauthorized' error. |
| 49 | +The service account token included with the request is valid for only 30 minutes. Therefore, attempting to call the DevRev API with that token for events older than this timeframe results in a _401 Unauthorized_ error. |
65 | 50 |
|
66 |
| -### Updating manifest or the URL |
| 51 | +### Update the URL |
67 | 52 |
|
68 | 53 | The code can be changed without the need to create a snap-in version or redeploy the snap-in. On any change to the
|
69 |
| -`src` folder, the server restarts with the updated changes. However, on [patch compatible](/snapin-development/upgrade-snap-ins#version-compatibility) updates to the manifest or the testing URL, we can `upgrade` the snap-in version. |
| 54 | +`src` folder, the server restarts with the updated changes. However, on [patch compatible](/snapin-development/upgrade-snap-ins#version-compatibility) updates to the manifest or the testing URL, you can `upgrade` the snap-in version. |
70 | 55 |
|
71 | 56 | ```
|
72 | 57 | devrev snap_in_version upgrade --manifest <PATH_TO_MANIFEST> --testing-url <UPDATED_URL>
|
73 | 58 | ```
|
74 | 59 |
|
75 |
| -In case of non-patch compatible updates, the `force` flag can be used to upgrade the version. However, this will delete any |
| 60 | +In case of non-patch compatible updates, the `force` flag can be used to upgrade the version. However, forcing the update deletes any |
76 | 61 | existing snap-ins that have been created from this version.
|
77 | 62 |
|
78 | 63 | ```
|
79 | 64 | devrev snap_in_version upgrade --force --manifest <PATH_TO_MANIFEST> --testing-url <UPDATED_URL>
|
80 | 65 | ```
|
81 | 66 |
|
82 |
| -Do note that manifest must always be provided when upgrading a snap-in version. |
| 67 | +The manifest must always be provided when upgrading a snap-in version. |
| 68 | + |
| 69 | +</Steps> |
0 commit comments