@cipherly/plane-cli 1.0.0
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/LICENSE +201 -0
- package/README.md +65 -0
- package/dist/cycles/create.cycles.js +44 -0
- package/dist/cycles/delete.cycles.js +30 -0
- package/dist/cycles/index.js +21 -0
- package/dist/cycles/list.cycles.js +42 -0
- package/dist/cycles/update.cycles.js +46 -0
- package/dist/cycles/work-items/index.js +17 -0
- package/dist/cycles/work-items/list.cycles.work-items.js +43 -0
- package/dist/labels/create.labels.js +34 -0
- package/dist/labels/delete.labels.js +30 -0
- package/dist/labels/index.js +20 -0
- package/dist/labels/list.labels.js +36 -0
- package/dist/labels/update.labels.js +36 -0
- package/dist/plane.js +60 -0
- package/dist/projects/create.projects.js +38 -0
- package/dist/projects/delete.projects.js +28 -0
- package/dist/projects/index.js +20 -0
- package/dist/projects/list.projects.js +35 -0
- package/dist/projects/update.projects.js +39 -0
- package/dist/states/create.states.js +37 -0
- package/dist/states/delete.states.js +30 -0
- package/dist/states/index.js +20 -0
- package/dist/states/list.states.js +36 -0
- package/dist/states/update.states.js +36 -0
- package/dist/users/index.js +17 -0
- package/dist/users/me.users.js +36 -0
- package/dist/utils.js +63 -0
- package/dist/work-items/create.work-items.js +51 -0
- package/dist/work-items/delete.work-items.js +30 -0
- package/dist/work-items/index.js +21 -0
- package/dist/work-items/list.work-items.js +44 -0
- package/dist/work-items/types/index.js +17 -0
- package/dist/work-items/types/list.types.work-items.js +40 -0
- package/dist/work-items/update.work-items.js +41 -0
- package/package.json +29 -0
- package/src/cycles/create.cycles.ts +39 -0
- package/src/cycles/delete.cycles.ts +25 -0
- package/src/cycles/index.ts +5 -0
- package/src/cycles/list.cycles.ts +37 -0
- package/src/cycles/update.cycles.ts +41 -0
- package/src/cycles/work-items/index.ts +1 -0
- package/src/cycles/work-items/list.cycles.work-items.ts +40 -0
- package/src/labels/create.labels.ts +29 -0
- package/src/labels/delete.labels.ts +25 -0
- package/src/labels/index.ts +5 -0
- package/src/labels/list.labels.ts +31 -0
- package/src/labels/update.labels.ts +31 -0
- package/src/plane.ts +97 -0
- package/src/projects/create.projects.ts +33 -0
- package/src/projects/delete.projects.ts +23 -0
- package/src/projects/index.ts +5 -0
- package/src/projects/list.projects.ts +30 -0
- package/src/projects/update.projects.ts +32 -0
- package/src/states/create.states.ts +32 -0
- package/src/states/delete.states.ts +25 -0
- package/src/states/index.ts +5 -0
- package/src/states/list.states.ts +31 -0
- package/src/states/update.states.ts +31 -0
- package/src/users/index.ts +1 -0
- package/src/users/me.users.ts +30 -0
- package/src/utils.ts +81 -0
- package/src/work-items/create.work-items.ts +85 -0
- package/src/work-items/delete.work-items.ts +25 -0
- package/src/work-items/index.ts +5 -0
- package/src/work-items/list.work-items.ts +43 -0
- package/src/work-items/types/index.ts +1 -0
- package/src/work-items/types/list.types.work-items.ts +36 -0
- package/src/work-items/update.work-items.ts +79 -0
- package/tsconfig.json +14 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateLabel = void 0;
|
|
4
|
+
const commander_1 = require("commander");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
|
+
const list_labels_1 = require("./list.labels");
|
|
7
|
+
exports.updateLabel = new commander_1.Command("update")
|
|
8
|
+
.description("Update a label")
|
|
9
|
+
.requiredOption("-p, --project-id <projectId>", "Project's ID")
|
|
10
|
+
.requiredOption("-l, --label-id <labelId>", "Label's ID")
|
|
11
|
+
.requiredOption("-n, --name <name>", "Label's name")
|
|
12
|
+
.action(async (__, cmd) => {
|
|
13
|
+
if (cmd.parent == null)
|
|
14
|
+
return;
|
|
15
|
+
const { apiKey, apiBase, workspaceSlug, json } = (0, utils_1.checkRequiredOptionsAndReturn)(cmd);
|
|
16
|
+
const projectId = cmd.getOptionValue("projectId");
|
|
17
|
+
const labelId = cmd.getOptionValue("labelId");
|
|
18
|
+
const name = cmd.getOptionValue("name");
|
|
19
|
+
const { result, status } = await (0, utils_1.requestPlaneAPI)({
|
|
20
|
+
apiBase,
|
|
21
|
+
apiKey,
|
|
22
|
+
endpoint: `workspaces/${workspaceSlug}/projects/${projectId}/labels/${labelId}/`,
|
|
23
|
+
method: "PATCH",
|
|
24
|
+
body: {
|
|
25
|
+
name,
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
if (json)
|
|
29
|
+
console.log(JSON.stringify(result));
|
|
30
|
+
else {
|
|
31
|
+
if (status !== 200)
|
|
32
|
+
console.table(result);
|
|
33
|
+
else
|
|
34
|
+
console.table((0, list_labels_1.renderLabel)(result));
|
|
35
|
+
}
|
|
36
|
+
});
|
package/dist/plane.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const commander_1 = require("commander");
|
|
5
|
+
const projects_1 = require("./projects");
|
|
6
|
+
const work_items_1 = require("./work-items");
|
|
7
|
+
const states_1 = require("./states");
|
|
8
|
+
const labels_1 = require("./labels");
|
|
9
|
+
const cycles_1 = require("./cycles");
|
|
10
|
+
const users_1 = require("./users");
|
|
11
|
+
const program = new commander_1.Command();
|
|
12
|
+
program.name("plane").description("CLI for api.plane.so").version("1.0.0");
|
|
13
|
+
program
|
|
14
|
+
.command("projects")
|
|
15
|
+
.description("Manage projects")
|
|
16
|
+
.addCommand(projects_1.listProjects)
|
|
17
|
+
.addCommand(projects_1.createProject)
|
|
18
|
+
.addCommand(projects_1.updateProject)
|
|
19
|
+
.addCommand(projects_1.deleteProject);
|
|
20
|
+
program
|
|
21
|
+
.command("work-items")
|
|
22
|
+
.description("Manage work items")
|
|
23
|
+
.addCommand(work_items_1.listWorkItems)
|
|
24
|
+
.addCommand(work_items_1.createWorkItem)
|
|
25
|
+
.addCommand(work_items_1.updateWorkItem)
|
|
26
|
+
.addCommand(work_items_1.deleteWorkItem);
|
|
27
|
+
program
|
|
28
|
+
.command("work-item-types")
|
|
29
|
+
.description("Manage work item types")
|
|
30
|
+
.addCommand(work_items_1.listWorkItemTypes);
|
|
31
|
+
program
|
|
32
|
+
.command("states")
|
|
33
|
+
.description("Manage states")
|
|
34
|
+
.addCommand(states_1.listStates)
|
|
35
|
+
.addCommand(states_1.createState)
|
|
36
|
+
.addCommand(states_1.updateState)
|
|
37
|
+
.addCommand(states_1.deleteState);
|
|
38
|
+
program
|
|
39
|
+
.command("labels")
|
|
40
|
+
.description("Manage labels")
|
|
41
|
+
.addCommand(labels_1.listLabels)
|
|
42
|
+
.addCommand(labels_1.createLabel)
|
|
43
|
+
.addCommand(labels_1.updateLabel)
|
|
44
|
+
.addCommand(labels_1.deleteLabel);
|
|
45
|
+
program
|
|
46
|
+
.command("cycles")
|
|
47
|
+
.description("Manage cycles")
|
|
48
|
+
.addCommand(cycles_1.listCycles)
|
|
49
|
+
.addCommand(cycles_1.listCyclesWorkItems)
|
|
50
|
+
.addCommand(cycles_1.createCycle)
|
|
51
|
+
.addCommand(cycles_1.updateCycle)
|
|
52
|
+
.addCommand(cycles_1.deleteCycle);
|
|
53
|
+
program.command("users").description("Manage users").addCommand(users_1.getCurrentUser);
|
|
54
|
+
program.commands.forEach((cmd) => {
|
|
55
|
+
cmd.requiredOption("--api-key <key>", "Plane API key", process.env.PLANE_API_KEY);
|
|
56
|
+
cmd.requiredOption("--api-base <url>", "Plane API base", process.env.PLANE_API_BASE || "api.plane.so");
|
|
57
|
+
cmd.requiredOption("--workspace-slug <slug>", "Workspace slug", process.env.PLANE_WORKSPACE_SLUG);
|
|
58
|
+
cmd.option("-j, --json", "Print in JSON format");
|
|
59
|
+
});
|
|
60
|
+
program.parse();
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createProject = void 0;
|
|
4
|
+
const commander_1 = require("commander");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
|
+
const list_projects_1 = require("./list.projects");
|
|
7
|
+
exports.createProject = new commander_1.Command("create")
|
|
8
|
+
.description("Create a new project")
|
|
9
|
+
.requiredOption("-n, --name <name>", "Project's name")
|
|
10
|
+
.requiredOption("-i, --identifier <identifier>", "Project' identifier")
|
|
11
|
+
.option("-d, --description [description]", "Project's description")
|
|
12
|
+
.action(async (__, cmd) => {
|
|
13
|
+
if (cmd.parent == null)
|
|
14
|
+
return;
|
|
15
|
+
const { apiKey, apiBase, workspaceSlug, json } = (0, utils_1.checkRequiredOptionsAndReturn)(cmd);
|
|
16
|
+
const name = cmd.getOptionValue("name");
|
|
17
|
+
const identifier = cmd.getOptionValue("identifier");
|
|
18
|
+
const description = cmd.getOptionValue("description");
|
|
19
|
+
const { result, status } = await (0, utils_1.requestPlaneAPI)({
|
|
20
|
+
apiBase,
|
|
21
|
+
apiKey,
|
|
22
|
+
endpoint: `workspaces/${workspaceSlug}/projects/`,
|
|
23
|
+
method: "POST",
|
|
24
|
+
body: {
|
|
25
|
+
name,
|
|
26
|
+
identifier,
|
|
27
|
+
description,
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
if (json)
|
|
31
|
+
console.log(JSON.stringify(result));
|
|
32
|
+
else {
|
|
33
|
+
if (status !== 201)
|
|
34
|
+
console.table(result);
|
|
35
|
+
else
|
|
36
|
+
console.table((0, list_projects_1.renderProject)(result));
|
|
37
|
+
}
|
|
38
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deleteProject = void 0;
|
|
4
|
+
const commander_1 = require("commander");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
|
+
exports.deleteProject = new commander_1.Command("delete")
|
|
7
|
+
.description("Delete a project")
|
|
8
|
+
.requiredOption("-p, --project-id <projectId>", "Project's ID")
|
|
9
|
+
.action(async (__, cmd) => {
|
|
10
|
+
if (cmd.parent == null)
|
|
11
|
+
return;
|
|
12
|
+
const { apiKey, apiBase, workspaceSlug, json } = (0, utils_1.checkRequiredOptionsAndReturn)(cmd);
|
|
13
|
+
const projectId = cmd.getOptionValue("projectId");
|
|
14
|
+
const { result, status } = await (0, utils_1.requestPlaneAPI)({
|
|
15
|
+
apiBase,
|
|
16
|
+
apiKey,
|
|
17
|
+
endpoint: `workspaces/${workspaceSlug}/projects/${projectId}/`,
|
|
18
|
+
method: "DELETE",
|
|
19
|
+
});
|
|
20
|
+
if (json)
|
|
21
|
+
console.log(JSON.stringify(result));
|
|
22
|
+
else {
|
|
23
|
+
if (status !== 204)
|
|
24
|
+
console.table(result);
|
|
25
|
+
else
|
|
26
|
+
console.table(result);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./list.projects"), exports);
|
|
18
|
+
__exportStar(require("./create.projects"), exports);
|
|
19
|
+
__exportStar(require("./update.projects"), exports);
|
|
20
|
+
__exportStar(require("./delete.projects"), exports);
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.renderProject = exports.listProjects = void 0;
|
|
4
|
+
const commander_1 = require("commander");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
|
+
exports.listProjects = new commander_1.Command("list")
|
|
7
|
+
.description("List projects")
|
|
8
|
+
.action(async (__, cmd) => {
|
|
9
|
+
if (cmd.parent == null)
|
|
10
|
+
return;
|
|
11
|
+
const { apiKey, apiBase, workspaceSlug, json } = (0, utils_1.checkRequiredOptionsAndReturn)(cmd);
|
|
12
|
+
const { result, status } = await (0, utils_1.requestPlaneAPI)({
|
|
13
|
+
apiBase,
|
|
14
|
+
apiKey,
|
|
15
|
+
endpoint: `workspaces/${workspaceSlug}/projects/`,
|
|
16
|
+
method: "GET",
|
|
17
|
+
});
|
|
18
|
+
if (json)
|
|
19
|
+
console.log(JSON.stringify(result));
|
|
20
|
+
else {
|
|
21
|
+
if (status !== 200)
|
|
22
|
+
console.table(result);
|
|
23
|
+
else
|
|
24
|
+
console.table(result.results.map(exports.renderProject));
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
const renderProject = (project) => {
|
|
28
|
+
return {
|
|
29
|
+
id: project.id,
|
|
30
|
+
name: project.name,
|
|
31
|
+
description: project.description,
|
|
32
|
+
total_members: project.total_members,
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
exports.renderProject = renderProject;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateProject = void 0;
|
|
4
|
+
const commander_1 = require("commander");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
|
+
const list_projects_1 = require("./list.projects");
|
|
7
|
+
exports.updateProject = new commander_1.Command("update")
|
|
8
|
+
.description("Update a project")
|
|
9
|
+
.requiredOption("-p, --project-id <projectId>", "Project's ID")
|
|
10
|
+
.option("-n, --name [name]", "Project's name")
|
|
11
|
+
.option("-d, --description [description]", "Project's description")
|
|
12
|
+
.action(async (__, cmd) => {
|
|
13
|
+
if (cmd.parent == null)
|
|
14
|
+
return;
|
|
15
|
+
const { apiKey, apiBase, workspaceSlug, json } = (0, utils_1.checkRequiredOptionsAndReturn)(cmd);
|
|
16
|
+
const projectId = cmd.getOptionValue("projectId");
|
|
17
|
+
const name = cmd.getOptionValue("name");
|
|
18
|
+
const description = cmd.getOptionValue("description");
|
|
19
|
+
const body = {};
|
|
20
|
+
if (name !== undefined)
|
|
21
|
+
body.name = name;
|
|
22
|
+
if (description !== undefined)
|
|
23
|
+
body.description = description;
|
|
24
|
+
const { result, status } = await (0, utils_1.requestPlaneAPI)({
|
|
25
|
+
apiBase,
|
|
26
|
+
apiKey,
|
|
27
|
+
endpoint: `workspaces/${workspaceSlug}/projects/${projectId}/`,
|
|
28
|
+
method: "PATCH",
|
|
29
|
+
body,
|
|
30
|
+
});
|
|
31
|
+
if (json)
|
|
32
|
+
console.log(JSON.stringify(result));
|
|
33
|
+
else {
|
|
34
|
+
if (status !== 200)
|
|
35
|
+
console.table(result);
|
|
36
|
+
else
|
|
37
|
+
console.table((0, list_projects_1.renderProject)(result));
|
|
38
|
+
}
|
|
39
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createState = void 0;
|
|
4
|
+
const commander_1 = require("commander");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
|
+
const list_states_1 = require("./list.states");
|
|
7
|
+
exports.createState = new commander_1.Command("create")
|
|
8
|
+
.description("Create a new state")
|
|
9
|
+
.requiredOption("-p, --project-id <projectId>", "Project's ID")
|
|
10
|
+
.requiredOption("-n, --name <name>", "State's name")
|
|
11
|
+
.requiredOption("-c, --color <color>", "State's color")
|
|
12
|
+
.action(async (__, cmd) => {
|
|
13
|
+
if (cmd.parent == null)
|
|
14
|
+
return;
|
|
15
|
+
const { apiKey, apiBase, workspaceSlug, json } = (0, utils_1.checkRequiredOptionsAndReturn)(cmd);
|
|
16
|
+
const projectId = cmd.getOptionValue("projectId");
|
|
17
|
+
const name = cmd.getOptionValue("name");
|
|
18
|
+
const color = cmd.getOptionValue("color");
|
|
19
|
+
const { result, status } = await (0, utils_1.requestPlaneAPI)({
|
|
20
|
+
apiBase,
|
|
21
|
+
apiKey,
|
|
22
|
+
endpoint: `workspaces/${workspaceSlug}/projects/${projectId}/states/`,
|
|
23
|
+
method: "POST",
|
|
24
|
+
body: {
|
|
25
|
+
name,
|
|
26
|
+
color,
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
if (json)
|
|
30
|
+
console.log(JSON.stringify(result));
|
|
31
|
+
else {
|
|
32
|
+
if (status !== 201)
|
|
33
|
+
console.table(result);
|
|
34
|
+
else
|
|
35
|
+
console.table((0, list_states_1.renderState)(result));
|
|
36
|
+
}
|
|
37
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deleteState = void 0;
|
|
4
|
+
const commander_1 = require("commander");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
|
+
exports.deleteState = new commander_1.Command("delete")
|
|
7
|
+
.description("Delete a state")
|
|
8
|
+
.requiredOption("-p, --project-id <projectId>", "Project's ID")
|
|
9
|
+
.requiredOption("-s, --state-id <stateId>", "State's ID")
|
|
10
|
+
.action(async (__, cmd) => {
|
|
11
|
+
if (cmd.parent == null)
|
|
12
|
+
return;
|
|
13
|
+
const { apiKey, apiBase, workspaceSlug, json } = (0, utils_1.checkRequiredOptionsAndReturn)(cmd);
|
|
14
|
+
const projectId = cmd.getOptionValue("projectId");
|
|
15
|
+
const stateId = cmd.getOptionValue("stateId");
|
|
16
|
+
const { result, status } = await (0, utils_1.requestPlaneAPI)({
|
|
17
|
+
apiBase,
|
|
18
|
+
apiKey,
|
|
19
|
+
endpoint: `workspaces/${workspaceSlug}/projects/${projectId}/states/${stateId}/`,
|
|
20
|
+
method: "DELETE",
|
|
21
|
+
});
|
|
22
|
+
if (json)
|
|
23
|
+
console.log(JSON.stringify(result));
|
|
24
|
+
else {
|
|
25
|
+
if (status !== 204)
|
|
26
|
+
console.table(result);
|
|
27
|
+
else
|
|
28
|
+
console.table(result);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./list.states"), exports);
|
|
18
|
+
__exportStar(require("./create.states"), exports);
|
|
19
|
+
__exportStar(require("./update.states"), exports);
|
|
20
|
+
__exportStar(require("./delete.states"), exports);
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.renderState = exports.listStates = void 0;
|
|
4
|
+
const commander_1 = require("commander");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
|
+
exports.listStates = new commander_1.Command("list")
|
|
7
|
+
.description("List states")
|
|
8
|
+
.requiredOption("-p, --project-id <projectId>", "Project's ID")
|
|
9
|
+
.action(async (__, cmd) => {
|
|
10
|
+
if (cmd.parent == null)
|
|
11
|
+
return;
|
|
12
|
+
const { apiKey, apiBase, workspaceSlug, json } = (0, utils_1.checkRequiredOptionsAndReturn)(cmd);
|
|
13
|
+
const projectId = cmd.getOptionValue("projectId");
|
|
14
|
+
const { result, status } = await (0, utils_1.requestPlaneAPI)({
|
|
15
|
+
apiBase,
|
|
16
|
+
apiKey,
|
|
17
|
+
endpoint: `workspaces/${workspaceSlug}/projects/${projectId}/states/`,
|
|
18
|
+
method: "GET",
|
|
19
|
+
});
|
|
20
|
+
if (json)
|
|
21
|
+
console.log(JSON.stringify(result));
|
|
22
|
+
else {
|
|
23
|
+
if (status !== 200)
|
|
24
|
+
console.table(result);
|
|
25
|
+
else
|
|
26
|
+
console.table(result.results.map(exports.renderState));
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
const renderState = (state) => {
|
|
30
|
+
return {
|
|
31
|
+
id: state.id,
|
|
32
|
+
name: state.name,
|
|
33
|
+
description: state.description,
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
exports.renderState = renderState;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateState = void 0;
|
|
4
|
+
const commander_1 = require("commander");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
|
+
const list_states_1 = require("./list.states");
|
|
7
|
+
exports.updateState = new commander_1.Command("update")
|
|
8
|
+
.description("Update a state")
|
|
9
|
+
.requiredOption("-p, --project-id <projectId>", "Project's ID")
|
|
10
|
+
.requiredOption("-s, --state-id <stateId>", "State's ID")
|
|
11
|
+
.requiredOption("-n, --name <name>", "State's name")
|
|
12
|
+
.action(async (__, cmd) => {
|
|
13
|
+
if (cmd.parent == null)
|
|
14
|
+
return;
|
|
15
|
+
const { apiKey, apiBase, workspaceSlug, json } = (0, utils_1.checkRequiredOptionsAndReturn)(cmd);
|
|
16
|
+
const projectId = cmd.getOptionValue("projectId");
|
|
17
|
+
const stateId = cmd.getOptionValue("stateId");
|
|
18
|
+
const name = cmd.getOptionValue("name");
|
|
19
|
+
const { result, status } = await (0, utils_1.requestPlaneAPI)({
|
|
20
|
+
apiBase,
|
|
21
|
+
apiKey,
|
|
22
|
+
endpoint: `workspaces/${workspaceSlug}/projects/${projectId}/states/${stateId}/`,
|
|
23
|
+
method: "PATCH",
|
|
24
|
+
body: {
|
|
25
|
+
name,
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
if (json)
|
|
29
|
+
console.log(JSON.stringify(result));
|
|
30
|
+
else {
|
|
31
|
+
if (status !== 200)
|
|
32
|
+
console.table(result);
|
|
33
|
+
else
|
|
34
|
+
console.table((0, list_states_1.renderState)(result));
|
|
35
|
+
}
|
|
36
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./me.users"), exports);
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.renderUser = exports.getCurrentUser = void 0;
|
|
4
|
+
const commander_1 = require("commander");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
|
+
exports.getCurrentUser = new commander_1.Command("me")
|
|
7
|
+
.description("Get current user")
|
|
8
|
+
.action(async (__, cmd) => {
|
|
9
|
+
if (cmd.parent == null)
|
|
10
|
+
return;
|
|
11
|
+
const { apiKey, apiBase, json } = (0, utils_1.checkRequiredOptionsAndReturn)(cmd);
|
|
12
|
+
const { result, status } = await (0, utils_1.requestPlaneAPI)({
|
|
13
|
+
apiBase,
|
|
14
|
+
apiKey,
|
|
15
|
+
endpoint: `users/me/`,
|
|
16
|
+
method: "GET",
|
|
17
|
+
});
|
|
18
|
+
if (json)
|
|
19
|
+
console.log(JSON.stringify(result));
|
|
20
|
+
else {
|
|
21
|
+
if (status !== 200)
|
|
22
|
+
console.table(result);
|
|
23
|
+
else
|
|
24
|
+
console.table((0, exports.renderUser)(result));
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
const renderUser = (user) => {
|
|
28
|
+
return {
|
|
29
|
+
id: user.id,
|
|
30
|
+
first_name: user.first_name,
|
|
31
|
+
last_name: user.last_name,
|
|
32
|
+
email: user.email,
|
|
33
|
+
display_name: user.display_name,
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
exports.renderUser = renderUser;
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.requestPlaneAPI = exports.checkRequiredOptionsAndReturn = exports.checkWorkspaceSlug = exports.checkApiBase = exports.checkApiKey = void 0;
|
|
4
|
+
const checkApiKey = (apiKey) => {
|
|
5
|
+
if (!apiKey) {
|
|
6
|
+
console.error("No API key provided. Use: plane <command> --api-key <API_KEY> or set PLANE_API_KEY environment variable");
|
|
7
|
+
process.exit(1);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
exports.checkApiKey = checkApiKey;
|
|
11
|
+
const checkApiBase = (apiBase) => {
|
|
12
|
+
if (!apiBase) {
|
|
13
|
+
console.error("No API base provided. Use: plane <command> --api-base <API_BASE> or set PLANE_API_BASE environment variable");
|
|
14
|
+
process.exit(1);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
exports.checkApiBase = checkApiBase;
|
|
18
|
+
const checkWorkspaceSlug = (workspaceSlug) => {
|
|
19
|
+
if (!workspaceSlug) {
|
|
20
|
+
console.error("No workspace slug provided. Use: plane <command> --workspace-slug <SLUG> or set PLANE_WORKSPACE_SLUG environment variable");
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
exports.checkWorkspaceSlug = checkWorkspaceSlug;
|
|
25
|
+
const checkRequiredOptionsAndReturn = (cmd) => {
|
|
26
|
+
const apiKey = cmd.parent.getOptionValue("apiKey");
|
|
27
|
+
const apiBase = cmd.parent.getOptionValue("apiBase");
|
|
28
|
+
const workspaceSlug = cmd.parent.getOptionValue("workspaceSlug");
|
|
29
|
+
(0, exports.checkApiKey)(apiKey);
|
|
30
|
+
(0, exports.checkApiBase)(apiBase);
|
|
31
|
+
(0, exports.checkWorkspaceSlug)(workspaceSlug);
|
|
32
|
+
const json = cmd.parent.getOptionValue("json");
|
|
33
|
+
return {
|
|
34
|
+
apiKey,
|
|
35
|
+
apiBase,
|
|
36
|
+
workspaceSlug,
|
|
37
|
+
json,
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
exports.checkRequiredOptionsAndReturn = checkRequiredOptionsAndReturn;
|
|
41
|
+
const requestPlaneAPI = async ({ apiKey, apiBase, endpoint, method, body, params, no_v1, }) => {
|
|
42
|
+
let url = `${apiBase}/api${(!!!no_v1 && "/v1") || ""}/${endpoint}`;
|
|
43
|
+
if (params) {
|
|
44
|
+
const qs = new URLSearchParams(params).toString();
|
|
45
|
+
url += `?${qs}`;
|
|
46
|
+
}
|
|
47
|
+
const headers = {
|
|
48
|
+
"X-API-Key": apiKey,
|
|
49
|
+
"Content-Type": "application/json",
|
|
50
|
+
};
|
|
51
|
+
const opts = { method, headers, body };
|
|
52
|
+
if (body)
|
|
53
|
+
opts.body = JSON.stringify(body);
|
|
54
|
+
try {
|
|
55
|
+
const res = await fetch(url, opts);
|
|
56
|
+
return { result: await res.json(), status: res.status };
|
|
57
|
+
}
|
|
58
|
+
catch (err) {
|
|
59
|
+
console.error("Request failed:", err.message);
|
|
60
|
+
process.exit(1);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
exports.requestPlaneAPI = requestPlaneAPI;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createWorkItem = void 0;
|
|
4
|
+
const commander_1 = require("commander");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
|
+
const list_work_items_1 = require("./list.work-items");
|
|
7
|
+
exports.createWorkItem = new commander_1.Command("create")
|
|
8
|
+
.description("Create a new work-item")
|
|
9
|
+
.requiredOption("-p, --project-id <projectId>", "Project's ID")
|
|
10
|
+
.requiredOption("-n, --name <name>", "Work item's name")
|
|
11
|
+
.option("-d, --description [description_html]", "Work item's description in HTML")
|
|
12
|
+
.option("-s, --state <state>", "Work item's state ID")
|
|
13
|
+
.option("-a, --assignees <assignees>", "Work item's assignees IDs (comma seperated)")
|
|
14
|
+
.addOption(new commander_1.Option("-u, --priority <priority>", "Work item's priority").choices([
|
|
15
|
+
"none",
|
|
16
|
+
"urgent",
|
|
17
|
+
"high",
|
|
18
|
+
"medium",
|
|
19
|
+
"low",
|
|
20
|
+
]))
|
|
21
|
+
.option("-l, --labels <labels>", "Work item's labels IDs (comma seperated)")
|
|
22
|
+
.option("--parent <parent>", "Work item's parent ID")
|
|
23
|
+
.option("-ep, --estimate-point <estimatePoint>", "Work item's estimate point")
|
|
24
|
+
.action(async (__, cmd) => {
|
|
25
|
+
if (cmd.parent == null)
|
|
26
|
+
return;
|
|
27
|
+
const { apiKey, apiBase, workspaceSlug, json } = (0, utils_1.checkRequiredOptionsAndReturn)(cmd);
|
|
28
|
+
const projectId = cmd.getOptionValue("projectId");
|
|
29
|
+
const name = cmd.getOptionValue("name");
|
|
30
|
+
const description_html = cmd.getOptionValue("description");
|
|
31
|
+
const { result, status } = await (0, utils_1.requestPlaneAPI)({
|
|
32
|
+
apiBase,
|
|
33
|
+
apiKey,
|
|
34
|
+
endpoint: `workspaces/${workspaceSlug}/projects/${projectId}/issues/`,
|
|
35
|
+
method: "POST",
|
|
36
|
+
body: {
|
|
37
|
+
name,
|
|
38
|
+
description_html,
|
|
39
|
+
project_id: projectId,
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
if (json) {
|
|
43
|
+
console.log(JSON.stringify(result));
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
if (status !== 201)
|
|
47
|
+
console.table(result);
|
|
48
|
+
else
|
|
49
|
+
console.table((0, list_work_items_1.renderWorkItem)(result));
|
|
50
|
+
}
|
|
51
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deleteWorkItem = void 0;
|
|
4
|
+
const commander_1 = require("commander");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
|
+
exports.deleteWorkItem = new commander_1.Command("delete")
|
|
7
|
+
.description("Delete a work-item")
|
|
8
|
+
.requiredOption("-p, --project-id <projectId>", "Project's ID")
|
|
9
|
+
.requiredOption("-w, --work-item-id <workItemId>", "Work item's ID")
|
|
10
|
+
.action(async (__, cmd) => {
|
|
11
|
+
if (cmd.parent == null)
|
|
12
|
+
return;
|
|
13
|
+
const { apiKey, apiBase, workspaceSlug, json } = (0, utils_1.checkRequiredOptionsAndReturn)(cmd);
|
|
14
|
+
const projectId = cmd.getOptionValue("projectId");
|
|
15
|
+
const workItemId = cmd.getOptionValue("workItemId");
|
|
16
|
+
const { result, status } = await (0, utils_1.requestPlaneAPI)({
|
|
17
|
+
apiBase,
|
|
18
|
+
apiKey,
|
|
19
|
+
endpoint: `workspaces/${workspaceSlug}/projects/${projectId}/work-items/${workItemId}/`,
|
|
20
|
+
method: "DELETE",
|
|
21
|
+
});
|
|
22
|
+
if (json)
|
|
23
|
+
console.log(JSON.stringify(result));
|
|
24
|
+
else {
|
|
25
|
+
if (status !== 204)
|
|
26
|
+
console.table(result);
|
|
27
|
+
else
|
|
28
|
+
console.table(result);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./list.work-items"), exports);
|
|
18
|
+
__exportStar(require("./create.work-items"), exports);
|
|
19
|
+
__exportStar(require("./update.work-items"), exports);
|
|
20
|
+
__exportStar(require("./delete.work-items"), exports);
|
|
21
|
+
__exportStar(require("./types"), exports);
|