|
1 |
| -# Jira.js usage examples |
| 1 | +# Jira.js Usage Examples |
| 2 | + |
| 3 | +This guide provides examples of using the [`jira.js`](https://github.com/MrRefactoring/jira.js) library to interact with Jira's API. These examples will help you get started with common operations like creating a project, adding a task, adding a worklog, and retrieving all worklogs. |
2 | 4 |
|
3 | 5 | ## Table of contents
|
4 | 6 |
|
5 |
| -1. [Initial steps](#initial-steps) |
6 |
| -2. Examples |
7 |
| - 1. [Basic example](#basic-example) |
8 |
| - 2. [Add worklog example](#add-worklog-example) |
9 |
| - 3. [Get all worklogs example](#get-all-worklogs-example) |
| 7 | +1. [Getting Started](#getting-started) |
| 8 | +2. [Examples](#examples) |
| 9 | + * [Basic Example](#basic-example) |
| 10 | + * [Add Worklog Example](#add-worklog-example) |
| 11 | + * [Get All Worklogs Example](#get-all-worklogs-example) |
| 12 | + |
| 13 | +## Getting Started |
10 | 14 |
|
11 |
| -## Initial steps |
| 15 | +Before you start running the examples, make sure to complete the following steps: |
12 | 16 |
|
13 |
| -1. Install dependencies |
| 17 | +1. **Install Dependencies**: The examples require certain Node.js packages to run. Install these dependencies by running the command: |
14 | 18 |
|
15 |
| -```shell |
| 19 | +```console |
16 | 20 | npm i
|
17 | 21 | ```
|
18 | 22 |
|
19 |
| -2. Specify `host`, `email` and `apiToken` variables in `src/credentials.ts` file |
| 23 | +2. **Setup Credentials:** The jira.js library uses your Jira's `host`, `email`, and `apiToken` to authenticate requests. Specify these in the `src/credentials.ts` file: |
20 | 24 |
|
21 |
| -```ts |
| 25 | +```typescript |
22 | 26 | const host = 'https://your-domain.atlassian.net';
|
23 | 27 | const email = 'YOUR_EMAIL';
|
24 | 28 | const apiToken = 'YOUR_API_TOKEN';
|
25 | 29 | ```
|
26 | 30 |
|
27 | 31 | ## Examples
|
28 | 32 |
|
29 |
| -### Basic example |
| 33 | +Here are some examples of what you can do with `jira.js`: |
| 34 | + |
| 35 | +### Basic Example |
| 36 | + |
| 37 | +This example creates a new project and a new task in that project. |
30 | 38 |
|
31 |
| -> ⚠️ Attention, the following behavior is performed: |
32 |
| -> 1. If you don't have any projects yet, then a new project is created with the `PROJECT` key, called `My Project` |
33 |
| -> 2. If you already have a project, it will create a new `task` named `My first issue` in the first project that comes along |
| 39 | +⚠️ **NOTE:** The script first checks if you have any existing projects. |
| 40 | +If you do, it creates a new task in the first project it finds. |
| 41 | +If you don't, it creates a new project with the key **PROJECT** and the name **My Project**, |
| 42 | +and then creates a task in that project. |
34 | 43 |
|
35 |
| -To run the basic example, just run the `basic` script: |
| 44 | +To run this example, use the command: |
36 | 45 |
|
37 |
| -```shell |
| 46 | +```console |
38 | 47 | npm run basic
|
39 | 48 | ```
|
40 | 49 |
|
41 | 50 | ---
|
42 | 51 |
|
43 |
| -### Add worklog example |
| 52 | +### Add Worklog Example |
44 | 53 |
|
45 |
| -> ⚠️ Attention, the following behavior is performed: |
46 |
| -> |
47 |
| -> In the first project that comes along, a new task is created, and one new Workflow is added to it |
| 54 | +This example creates a new task in the first project it finds and adds a worklog to it. |
48 | 55 |
|
49 |
| -> If you haven't created a project yet, follow the [basic example](#basic-example) |
| 56 | +⚠️ **NOTE:** If you don't have any existing projects, you should run the [Basic Example](#basic-example) first to create a project. |
| 57 | +One new Worklog will be added. |
50 | 58 |
|
51 |
| -To add a `worklog` run the `addWorklog` script: |
| 59 | +To run this example, use the command: |
52 | 60 |
|
53 |
| -```shell |
| 61 | +```console |
54 | 62 | npm run addWorklog
|
55 | 63 | ```
|
56 | 64 |
|
57 | 65 | ---
|
58 | 66 |
|
59 |
| -### Get all worklogs example |
| 67 | +### Get All Worklogs Example |
60 | 68 |
|
61 |
| -> ⚠️ Attention, the following behavior is performed: |
62 |
| -> |
63 |
| -> The same as in [Add worklog example](#add-worklog-example), and will also get all the worklogs that have been added |
| 69 | +This example creates a new task, adds a worklog to it, |
| 70 | +and then retrieves all the worklogs that have been added to the task. |
64 | 71 |
|
65 |
| -> If you haven't created a project yet, follow the [basic example](#basic-example) |
| 72 | +⚠️ **NOTE:** Similar to the Add Worklog Example, you should have an existing project before running this example. |
| 73 | +If you don't, run the Basic Example first. |
66 | 74 |
|
67 |
| -To get all worklogs run the `getAllWorklogs` script: |
| 75 | +To run this example, use the command: |
68 | 76 |
|
69 |
| -```shell |
| 77 | +```console |
70 | 78 | npm run getAllWorklogs
|
71 | 79 | ```
|
0 commit comments