From a6054a8d9f65e5a5ebf52e15d00a384bc58b2340 Mon Sep 17 00:00:00 2001 From: ikepu-tp Date: Tue, 12 Sep 2023 06:03:28 +0900 Subject: [PATCH 1/8] Add: draft --- src/commands/publish.ts | 1 + src/lib/entities/qiita-item.ts | 4 ++++ src/lib/file-system-repo.test.ts | 1 + src/lib/file-system-repo.ts | 12 ++++++++++++ src/qiita-api/index.ts | 1 + 5 files changed, 19 insertions(+) diff --git a/src/commands/publish.ts b/src/commands/publish.ts index 2b0e9fa..ddd9fce 100644 --- a/src/commands/publish.ts +++ b/src/commands/publish.ts @@ -26,6 +26,7 @@ export const publish = async (argv: string[]) => { let targetItems: QiitaItem[]; if (args["--all"]) { targetItems = (await fileSystemRepo.loadItems()).filter((item) => { + if (item.draft === false) return false; return item.modified || item.id === null; }); } else { diff --git a/src/lib/entities/qiita-item.ts b/src/lib/entities/qiita-item.ts index dd8cb67..52e624c 100644 --- a/src/lib/entities/qiita-item.ts +++ b/src/lib/entities/qiita-item.ts @@ -13,6 +13,7 @@ export class QiitaItem { public readonly published: boolean; public readonly itemPath: string; public readonly slide: boolean; + public readonly draft: boolean; constructor({ id, @@ -29,6 +30,7 @@ export class QiitaItem { published, itemPath, slide, + draft, }: { id: string | null; title: string; @@ -44,6 +46,7 @@ export class QiitaItem { published: boolean; itemPath: string; slide: boolean; + draft: boolean; }) { this.id = id; this.title = title; @@ -59,5 +62,6 @@ export class QiitaItem { this.published = published; this.itemPath = itemPath; this.slide = slide; + this.draft = draft; } } diff --git a/src/lib/file-system-repo.test.ts b/src/lib/file-system-repo.test.ts index eecd281..0350f6e 100644 --- a/src/lib/file-system-repo.test.ts +++ b/src/lib/file-system-repo.test.ts @@ -296,6 +296,7 @@ slide: false updated_at: "", organization_url_name: null, slide: false, + draft: false, }; const remoteFilename = `${id}.md`; const localFilename = remoteFilename; diff --git a/src/lib/file-system-repo.ts b/src/lib/file-system-repo.ts index 1309e78..8919274 100644 --- a/src/lib/file-system-repo.ts +++ b/src/lib/file-system-repo.ts @@ -14,6 +14,7 @@ class FileContent { public readonly organizationUrlName: string | null; public readonly rawBody: string; public readonly slide: boolean; + public readonly draft: boolean; constructor({ title, @@ -24,6 +25,7 @@ class FileContent { organizationUrlName, rawBody, slide, + draft, }: { title: string; tags: string[]; @@ -33,6 +35,7 @@ class FileContent { organizationUrlName: string | null; rawBody: string; slide: boolean; + draft: boolean; }) { this.title = title; this.tags = tags; @@ -42,6 +45,7 @@ class FileContent { this.organizationUrlName = organizationUrlName; this.rawBody = rawBody; this.slide = slide; + this.draft = draft; } static read(fileContent: string): FileContent { @@ -55,6 +59,7 @@ class FileContent { id: data.id, organizationUrlName: data.organization_url_name, slide: data.slide, + draft: data.draft, }); } @@ -74,6 +79,7 @@ class FileContent { id, organizationUrlName: null, slide: false, + draft: false, }); } @@ -87,6 +93,7 @@ class FileContent { id: item.id, organizationUrlName: item.organization_url_name, slide: item.slide, + draft: item.draft, }); } @@ -100,6 +107,7 @@ class FileContent { id: item.id, organizationUrlName: item.organizationUrlName, slide: item.slide, + draft: item.draft, }); } @@ -112,6 +120,7 @@ class FileContent { id: this.id, organization_url_name: this.organizationUrlName, slide: this.slide, + draft: this.draft, }); } @@ -153,6 +162,7 @@ class FileContent { organizationUrlName: this.organizationUrlName, rawBody: this.rawBody, slide: this.slide, + draft: this.draft, }); } } @@ -364,6 +374,7 @@ export class FileSystemRepo { isOlderThanRemote: localFileContent.isOlderThan(remoteFileContent), itemsShowPath: this.generateItemsShowPath(localFileContent.id, basename), published: remoteFileContent !== null, + draft: localFileContent.draft, itemPath, }); } @@ -400,6 +411,7 @@ export class FileSystemRepo { isOlderThanRemote: localFileContent.isOlderThan(remoteFileContent), itemsShowPath: this.generateItemsShowPath(localFileContent.id, basename), published: remoteFileContent !== null, + draft: localFileContent.draft, itemPath, }); } diff --git a/src/qiita-api/index.ts b/src/qiita-api/index.ts index 655e9ee..3c977a6 100644 --- a/src/qiita-api/index.ts +++ b/src/qiita-api/index.ts @@ -26,6 +26,7 @@ export interface Item { created_at: string; updated_at: string; slide: boolean; + draft: boolean; } export class QiitaApi { From 50b67d7f00630c54f55a9430932fe3eb41bd4ce9 Mon Sep 17 00:00:00 2001 From: ikepu-tp Date: Tue, 12 Sep 2023 06:04:42 +0900 Subject: [PATCH 2/8] Update: readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 56b56ee..53f7cf9 100644 --- a/README.md +++ b/README.md @@ -138,6 +138,7 @@ updated_at: "" # 記事を投稿した際に自動的に記事の更新日時に id: null # 記事を投稿した際に自動的に記事のUUIDに変わります organization_url_name: null # 関連付けるOrganizationのURL名 slide: false # true: スライドモードON / false: スライドモードOFF +draft: false # true: 下書きON(Qiitaに保存されません) / false: 下書きOFF(Qiitaに保存されます) --- # new article body ``` From bf4a782dc6799304927740b7d8410f0981c4dba8 Mon Sep 17 00:00:00 2001 From: ikepu-tp Date: Fri, 15 Sep 2023 00:29:41 +0900 Subject: [PATCH 3/8] fix: from review --- src/lib/file-system-repo.test.ts | 1 - src/lib/file-system-repo.ts | 6 +++--- src/qiita-api/index.ts | 1 - 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/lib/file-system-repo.test.ts b/src/lib/file-system-repo.test.ts index 0350f6e..eecd281 100644 --- a/src/lib/file-system-repo.test.ts +++ b/src/lib/file-system-repo.test.ts @@ -296,7 +296,6 @@ slide: false updated_at: "", organization_url_name: null, slide: false, - draft: false, }; const remoteFilename = `${id}.md`; const localFilename = remoteFilename; diff --git a/src/lib/file-system-repo.ts b/src/lib/file-system-repo.ts index 8919274..75d2fa2 100644 --- a/src/lib/file-system-repo.ts +++ b/src/lib/file-system-repo.ts @@ -25,7 +25,7 @@ class FileContent { organizationUrlName, rawBody, slide, - draft, + draft = false, }: { title: string; tags: string[]; @@ -59,7 +59,7 @@ class FileContent { id: data.id, organizationUrlName: data.organization_url_name, slide: data.slide, - draft: data.draft, + draft: data.draft ?? false, }); } @@ -93,7 +93,7 @@ class FileContent { id: item.id, organizationUrlName: item.organization_url_name, slide: item.slide, - draft: item.draft, + draft: false, }); } diff --git a/src/qiita-api/index.ts b/src/qiita-api/index.ts index 3c977a6..655e9ee 100644 --- a/src/qiita-api/index.ts +++ b/src/qiita-api/index.ts @@ -26,7 +26,6 @@ export interface Item { created_at: string; updated_at: string; slide: boolean; - draft: boolean; } export class QiitaApi { From 4391454f43c5d42d2d7d5d5afffb8418f206c769 Mon Sep 17 00:00:00 2001 From: ikepu-tp Date: Fri, 15 Sep 2023 00:34:11 +0900 Subject: [PATCH 4/8] change: `draft` to `ignorePublish` --- src/commands/publish.ts | 2 +- src/lib/entities/qiita-item.ts | 8 ++++---- src/lib/file-system-repo.ts | 27 ++++++++++++++------------- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/commands/publish.ts b/src/commands/publish.ts index ddd9fce..7de458a 100644 --- a/src/commands/publish.ts +++ b/src/commands/publish.ts @@ -26,7 +26,7 @@ export const publish = async (argv: string[]) => { let targetItems: QiitaItem[]; if (args["--all"]) { targetItems = (await fileSystemRepo.loadItems()).filter((item) => { - if (item.draft === false) return false; + if (item.ignorePublish === false) return false; return item.modified || item.id === null; }); } else { diff --git a/src/lib/entities/qiita-item.ts b/src/lib/entities/qiita-item.ts index 52e624c..27e2e06 100644 --- a/src/lib/entities/qiita-item.ts +++ b/src/lib/entities/qiita-item.ts @@ -13,7 +13,7 @@ export class QiitaItem { public readonly published: boolean; public readonly itemPath: string; public readonly slide: boolean; - public readonly draft: boolean; + public readonly ignorePublish: boolean; constructor({ id, @@ -30,7 +30,7 @@ export class QiitaItem { published, itemPath, slide, - draft, + ignorePublish, }: { id: string | null; title: string; @@ -46,7 +46,7 @@ export class QiitaItem { published: boolean; itemPath: string; slide: boolean; - draft: boolean; + ignorePublish: boolean; }) { this.id = id; this.title = title; @@ -62,6 +62,6 @@ export class QiitaItem { this.published = published; this.itemPath = itemPath; this.slide = slide; - this.draft = draft; + this.ignorePublish = ignorePublish; } } diff --git a/src/lib/file-system-repo.ts b/src/lib/file-system-repo.ts index 75d2fa2..8bb8d4d 100644 --- a/src/lib/file-system-repo.ts +++ b/src/lib/file-system-repo.ts @@ -14,7 +14,7 @@ class FileContent { public readonly organizationUrlName: string | null; public readonly rawBody: string; public readonly slide: boolean; - public readonly draft: boolean; + public readonly ignorePublish: boolean; constructor({ title, @@ -25,7 +25,7 @@ class FileContent { organizationUrlName, rawBody, slide, - draft = false, + ignorePublish = false, }: { title: string; tags: string[]; @@ -35,7 +35,7 @@ class FileContent { organizationUrlName: string | null; rawBody: string; slide: boolean; - draft: boolean; + ignorePublish: boolean; }) { this.title = title; this.tags = tags; @@ -45,7 +45,7 @@ class FileContent { this.organizationUrlName = organizationUrlName; this.rawBody = rawBody; this.slide = slide; - this.draft = draft; + this.ignorePublish = ignorePublish; } static read(fileContent: string): FileContent { @@ -59,7 +59,7 @@ class FileContent { id: data.id, organizationUrlName: data.organization_url_name, slide: data.slide, - draft: data.draft ?? false, + ignorePublish: data.ignorePublish ?? false, }); } @@ -79,7 +79,7 @@ class FileContent { id, organizationUrlName: null, slide: false, - draft: false, + ignorePublish: false, }); } @@ -93,7 +93,7 @@ class FileContent { id: item.id, organizationUrlName: item.organization_url_name, slide: item.slide, - draft: false, + ignorePublish: false, }); } @@ -107,7 +107,7 @@ class FileContent { id: item.id, organizationUrlName: item.organizationUrlName, slide: item.slide, - draft: item.draft, + ignorePublish: item.ignorePublish, }); } @@ -120,7 +120,7 @@ class FileContent { id: this.id, organization_url_name: this.organizationUrlName, slide: this.slide, - draft: this.draft, + ignorePublisht: this.ignorePublish, }); } @@ -140,7 +140,8 @@ class FileContent { this.tags.sort().join() === aFileContent.tags.sort().join() && this.secret === aFileContent.secret && this.rawBody === aFileContent.rawBody && - this.slide === aFileContent.slide + this.slide === aFileContent.slide && + this.ignorePublish === aFileContent.ignorePublish ); } @@ -162,7 +163,7 @@ class FileContent { organizationUrlName: this.organizationUrlName, rawBody: this.rawBody, slide: this.slide, - draft: this.draft, + ignorePublish: this.ignorePublish, }); } } @@ -374,7 +375,7 @@ export class FileSystemRepo { isOlderThanRemote: localFileContent.isOlderThan(remoteFileContent), itemsShowPath: this.generateItemsShowPath(localFileContent.id, basename), published: remoteFileContent !== null, - draft: localFileContent.draft, + ignorePublish: localFileContent.ignorePublish, itemPath, }); } @@ -411,7 +412,7 @@ export class FileSystemRepo { isOlderThanRemote: localFileContent.isOlderThan(remoteFileContent), itemsShowPath: this.generateItemsShowPath(localFileContent.id, basename), published: remoteFileContent !== null, - draft: localFileContent.draft, + ignorePublish: localFileContent.ignorePublish, itemPath, }); } From 130ce4773c596994b912ab6c45efbc39d78f7641 Mon Sep 17 00:00:00 2001 From: ikepu-tp Date: Fri, 15 Sep 2023 00:39:28 +0900 Subject: [PATCH 5/8] fix: readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 53f7cf9..fb56414 100644 --- a/README.md +++ b/README.md @@ -138,7 +138,7 @@ updated_at: "" # 記事を投稿した際に自動的に記事の更新日時に id: null # 記事を投稿した際に自動的に記事のUUIDに変わります organization_url_name: null # 関連付けるOrganizationのURL名 slide: false # true: スライドモードON / false: スライドモードOFF -draft: false # true: 下書きON(Qiitaに保存されません) / false: 下書きOFF(Qiitaに保存されます) +ignorePublish: false # true: `publish`コマンドにおいて無視されます(Qiitaに保存されません) / false: `publish`コマンドで処理されます(Qiitaに保存されます) --- # new article body ``` From 8ed6928ade94a986badb13f1fff7ee72e0cba140 Mon Sep 17 00:00:00 2001 From: Ikepu Date: Fri, 15 Sep 2023 12:00:03 +0900 Subject: [PATCH 6/8] =?UTF-8?q?README.md=20=E3=82=92=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: ohakutsu --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fb56414..63f3b45 100644 --- a/README.md +++ b/README.md @@ -138,7 +138,7 @@ updated_at: "" # 記事を投稿した際に自動的に記事の更新日時に id: null # 記事を投稿した際に自動的に記事のUUIDに変わります organization_url_name: null # 関連付けるOrganizationのURL名 slide: false # true: スライドモードON / false: スライドモードOFF -ignorePublish: false # true: `publish`コマンドにおいて無視されます(Qiitaに保存されません) / false: `publish`コマンドで処理されます(Qiitaに保存されます) +ignorePublish: false # true: `publish`コマンドにおいて無視されます(Qiitaに投稿されません) / false: `publish`コマンドで処理されます(Qiitaに投稿されます) --- # new article body ``` From 63852bccbb48084ec237d1836d4e2aa48bd6b76a Mon Sep 17 00:00:00 2001 From: Ikepu Date: Fri, 15 Sep 2023 12:53:54 +0900 Subject: [PATCH 7/8] Update src/lib/file-system-repo.ts Co-authored-by: ohakutsu --- src/lib/file-system-repo.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/file-system-repo.ts b/src/lib/file-system-repo.ts index 8bb8d4d..0a7ada4 100644 --- a/src/lib/file-system-repo.ts +++ b/src/lib/file-system-repo.ts @@ -120,7 +120,7 @@ class FileContent { id: this.id, organization_url_name: this.organizationUrlName, slide: this.slide, - ignorePublisht: this.ignorePublish, + ignorePublish: this.ignorePublish, }); } From ff2a520cc486fec2c3d30f070e7cd9d9c7fb58d6 Mon Sep 17 00:00:00 2001 From: Ikepu Date: Fri, 15 Sep 2023 12:54:41 +0900 Subject: [PATCH 8/8] Update src/commands/publish.ts Co-authored-by: ohakutsu --- src/commands/publish.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/publish.ts b/src/commands/publish.ts index 7de458a..a99df82 100644 --- a/src/commands/publish.ts +++ b/src/commands/publish.ts @@ -26,7 +26,7 @@ export const publish = async (argv: string[]) => { let targetItems: QiitaItem[]; if (args["--all"]) { targetItems = (await fileSystemRepo.loadItems()).filter((item) => { - if (item.ignorePublish === false) return false; + if (item.ignorePublish === true) return false; return item.modified || item.id === null; }); } else {