@d-zero/backlog-projects 0.2.2 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -0
- package/dist/assign.js +2 -2
- package/dist/cli.js +2 -11
- package/dist/create-backlog-client.d.ts +2 -0
- package/dist/create-backlog-client.js +18 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/package.json +11 -6
package/README.md
CHANGED
|
@@ -46,3 +46,24 @@ BACKLOG_HOST=xxxxx.backlog.jp
|
|
|
46
46
|
BACKLOG_APIKEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
|
47
47
|
NOTION_TOKEN=secret_xxxxxxxxxxxxxx
|
|
48
48
|
```
|
|
49
|
+
|
|
50
|
+
## API
|
|
51
|
+
|
|
52
|
+
### `assing`
|
|
53
|
+
|
|
54
|
+
```ts
|
|
55
|
+
function assign(backlog: Backlog, params: Params): Promise<void>;
|
|
56
|
+
|
|
57
|
+
type Params = {
|
|
58
|
+
backlogProject: Project.Project;
|
|
59
|
+
assignedUsers: Record<Role, User.User>;
|
|
60
|
+
backlogCategory?: string;
|
|
61
|
+
log?: (message: string) => void;
|
|
62
|
+
};
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### `createBacklogClient
|
|
66
|
+
|
|
67
|
+
```ts
|
|
68
|
+
function createBacklogClient(): Backlog;
|
|
69
|
+
```
|
package/dist/assign.js
CHANGED
|
@@ -28,8 +28,8 @@ export async function assign(backlog, params) {
|
|
|
28
28
|
throw new Error('issueTypes is not found');
|
|
29
29
|
}
|
|
30
30
|
const category = categoryName
|
|
31
|
-
? categories.find((c) => c.name === categoryName) ??
|
|
32
|
-
(await backlog.postCategories(project.id, { name: categoryName }))
|
|
31
|
+
? (categories.find((c) => c.name === categoryName) ??
|
|
32
|
+
(await backlog.postCategories(project.id, { name: categoryName })))
|
|
33
33
|
: null;
|
|
34
34
|
const now = dayjs();
|
|
35
35
|
let i = 0;
|
package/dist/cli.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { Backlog } from 'backlog-js';
|
|
3
2
|
import dotenv from 'dotenv';
|
|
4
3
|
import Enquirer from 'enquirer';
|
|
5
4
|
import minimist from 'minimist';
|
|
6
5
|
import { assign } from './assign.js';
|
|
6
|
+
import { createBacklogClient } from './create-backlog-client.js';
|
|
7
7
|
import { roles } from './define.js';
|
|
8
8
|
import { getBacklogProjectIdFromUrl } from './get-backlog-project-id-from-url.js';
|
|
9
9
|
dotenv.config();
|
|
@@ -12,16 +12,7 @@ const cli = minimist(process.argv.slice(2), {
|
|
|
12
12
|
a: 'assign',
|
|
13
13
|
},
|
|
14
14
|
});
|
|
15
|
-
|
|
16
|
-
throw new Error('BACKLOG_HOST is not defined. Please set it in .env file');
|
|
17
|
-
}
|
|
18
|
-
if (!process.env.BACKLOG_APIKEY) {
|
|
19
|
-
throw new Error('BACKLOG_APIKEY is not defined. Please set it in .env file');
|
|
20
|
-
}
|
|
21
|
-
const backlog = new Backlog({
|
|
22
|
-
host: process.env.BACKLOG_HOST,
|
|
23
|
-
apiKey: process.env.BACKLOG_APIKEY,
|
|
24
|
-
});
|
|
15
|
+
const backlog = createBacklogClient();
|
|
25
16
|
if (cli.assign) {
|
|
26
17
|
const users = await backlog.getUsers();
|
|
27
18
|
const dzUsers = users.filter((u) => u.mailAddress.endsWith('@d-zero.co.jp'));
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Backlog } from 'backlog-js';
|
|
2
|
+
let singleton = null;
|
|
3
|
+
export function createBacklogClient() {
|
|
4
|
+
if (singleton) {
|
|
5
|
+
return singleton;
|
|
6
|
+
}
|
|
7
|
+
if (!process.env.BACKLOG_HOST) {
|
|
8
|
+
throw new Error('BACKLOG_HOST is not defined. Please set it in .env file');
|
|
9
|
+
}
|
|
10
|
+
if (!process.env.BACKLOG_APIKEY) {
|
|
11
|
+
throw new Error('BACKLOG_APIKEY is not defined. Please set it in .env file');
|
|
12
|
+
}
|
|
13
|
+
singleton = new Backlog({
|
|
14
|
+
host: process.env.BACKLOG_HOST,
|
|
15
|
+
apiKey: process.env.BACKLOG_APIKEY,
|
|
16
|
+
});
|
|
17
|
+
return singleton;
|
|
18
|
+
}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@d-zero/backlog-projects",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "A manipulating Backlog projects library",
|
|
5
5
|
"author": "D-ZERO",
|
|
6
6
|
"license": "MIT",
|
|
@@ -15,6 +15,11 @@
|
|
|
15
15
|
"bin": {
|
|
16
16
|
"backlog-projects": "./dist/cli.js"
|
|
17
17
|
},
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"import": "./dist/index.js"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
18
23
|
"files": [
|
|
19
24
|
"dist"
|
|
20
25
|
],
|
|
@@ -23,13 +28,13 @@
|
|
|
23
28
|
"clean": "tsc --build --clean"
|
|
24
29
|
},
|
|
25
30
|
"dependencies": {
|
|
26
|
-
"@d-zero/notion": "1.0.
|
|
27
|
-
"@d-zero/shared": "0.
|
|
28
|
-
"backlog-js": "0.13.
|
|
29
|
-
"dayjs": "1.11.
|
|
31
|
+
"@d-zero/notion": "1.0.3",
|
|
32
|
+
"@d-zero/shared": "0.5.0",
|
|
33
|
+
"backlog-js": "0.13.3",
|
|
34
|
+
"dayjs": "1.11.13",
|
|
30
35
|
"dotenv": "16.4.5",
|
|
31
36
|
"enquirer": "2.4.1",
|
|
32
37
|
"minimist": "1.2.8"
|
|
33
38
|
},
|
|
34
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "e8f65086bf7c316dda6667f1173da8585a5ef19c"
|
|
35
40
|
}
|