-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2e7b861
commit 2712a7f
Showing
18 changed files
with
587 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@dandori/cli": patch | ||
"@dandori/ui": patch | ||
--- | ||
|
||
Add trello |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
import { | ||
describe, | ||
beforeEach, | ||
afterEach, | ||
vi, | ||
expect, | ||
it, | ||
beforeAll, | ||
afterAll, | ||
Mock, | ||
} from "vitest"; | ||
import { DandoriTask } from "@dandori/core"; | ||
import { generateDandoriTrelloCards } from "@dandori/ui"; | ||
import DandoriTrelloCli from "../index"; | ||
import { rm, writeFile } from "fs/promises"; | ||
|
||
const tasks: DandoriTask[] = [ | ||
{ | ||
id: "1", | ||
name: "task1", | ||
deadline: "2021-01-01", | ||
description: "task1-description", | ||
fromTaskIdList: [], | ||
status: "todo", | ||
}, | ||
]; | ||
|
||
vi.mock("@dandori/core", () => ({ | ||
default: vi.fn(() => tasks), | ||
})); | ||
|
||
vi.mock("@dandori/ui", () => ({ | ||
generateDandoriTrelloCards: vi.fn(), | ||
})); | ||
|
||
const mockGenerateDandoriTrelloCards = generateDandoriTrelloCards as Mock; | ||
|
||
describe("DandoriTrelloCli", () => { | ||
const inputFileName = "DandoriTrelloCli.txt"; | ||
const inputFileText = "DandoriTrelloCli"; | ||
const loadProcessArgv = (options: string[]) => { | ||
process.argv = ["node", "cli.js", inputFileName, ...options]; | ||
}; | ||
|
||
beforeAll(async () => { | ||
await writeFile(inputFileName, inputFileText); | ||
}); | ||
|
||
afterAll(async () => { | ||
await rm(inputFileName); | ||
}); | ||
|
||
afterEach(() => { | ||
process.argv = []; | ||
vi.clearAllMocks(); | ||
}); | ||
|
||
describe("with -b option", () => { | ||
const boardId = "boardId"; | ||
|
||
beforeEach(async () => { | ||
loadProcessArgv(["-b", boardId]); | ||
await new DandoriTrelloCli().run(); | ||
}); | ||
|
||
it("call generateDandoriTrelloCards with board id", () => { | ||
expect(mockGenerateDandoriTrelloCards.mock.lastCall[1]).toMatchObject({ | ||
boardId, | ||
}); | ||
}); | ||
}); | ||
|
||
describe("with --status-todo option", () => { | ||
const statusTodo = "ToDo"; | ||
|
||
beforeEach(async () => { | ||
loadProcessArgv(["--status-todo", statusTodo]); | ||
await new DandoriTrelloCli().run(); | ||
}); | ||
|
||
it("call generateDandoriTrelloCards with trelloListPropertiesMap.status.todo", () => { | ||
expect( | ||
mockGenerateDandoriTrelloCards.mock.lastCall[1].trelloListPropertiesMap, | ||
).toMatchObject({ | ||
"status.todo": statusTodo, | ||
}); | ||
}); | ||
}); | ||
|
||
describe("with --status-doing option", () => { | ||
const statusDoing = "Doing"; | ||
|
||
beforeEach(async () => { | ||
loadProcessArgv(["--status-doing", statusDoing]); | ||
await new DandoriTrelloCli().run(); | ||
}); | ||
|
||
it("call generateDandoriTrelloCards with trelloListPropertiesMap.status.doing", () => { | ||
expect( | ||
mockGenerateDandoriTrelloCards.mock.lastCall[1].trelloListPropertiesMap, | ||
).toMatchObject({ | ||
"status.doing": statusDoing, | ||
}); | ||
}); | ||
}); | ||
|
||
describe("with --status-done option", () => { | ||
const statusDone = "Done"; | ||
|
||
beforeEach(async () => { | ||
loadProcessArgv(["--status-done", statusDone]); | ||
await new DandoriTrelloCli().run(); | ||
}); | ||
|
||
it("call generateDandoriTrelloCards with trelloListPropertiesMap.status.done", () => { | ||
expect( | ||
mockGenerateDandoriTrelloCards.mock.lastCall[1].trelloListPropertiesMap, | ||
).toMatchObject({ | ||
"status.done": statusDone, | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env node | ||
|
||
import DandoriTrelloCli from "./index"; | ||
|
||
const cli = new DandoriTrelloCli(); | ||
void cli.run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { generateDandoriTrelloCards } from "@dandori/ui"; | ||
import DandoriCoreCli from "../core"; | ||
|
||
export default class DandoriTrelloCli extends DandoriCoreCli { | ||
override async run(): Promise<void> { | ||
const tasks = await this.generateDandoriTasks(); | ||
const opts = this.program.opts(); | ||
await generateDandoriTrelloCards(tasks, { | ||
boardId: opts.boardId, | ||
trelloListPropertiesMap: { | ||
"status.todo": opts.statusTodo, | ||
"status.doing": opts.statusDoing, | ||
"status.done": opts.statusDone, | ||
}, | ||
}); | ||
} | ||
|
||
protected override buildCommand() { | ||
return super | ||
.buildCommand() | ||
.option("-b, --board-id <board-id>", "trello board id") | ||
.option("--status-todo <status-todo>", "trello list status todo name") | ||
.option("--status-doing <status-doing>", "trello list status doing name") | ||
.option("--status-done <status-done>", "trello list status done name"); | ||
} | ||
} |
Oops, something went wrong.