Skip to content

Commit a6054a8

Browse files
author
ikepu-tp
committed
Add: draft
1 parent 13bb561 commit a6054a8

File tree

5 files changed

+19
-0
lines changed

5 files changed

+19
-0
lines changed

src/commands/publish.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export const publish = async (argv: string[]) => {
2626
let targetItems: QiitaItem[];
2727
if (args["--all"]) {
2828
targetItems = (await fileSystemRepo.loadItems()).filter((item) => {
29+
if (item.draft === false) return false;
2930
return item.modified || item.id === null;
3031
});
3132
} else {

src/lib/entities/qiita-item.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export class QiitaItem {
1313
public readonly published: boolean;
1414
public readonly itemPath: string;
1515
public readonly slide: boolean;
16+
public readonly draft: boolean;
1617

1718
constructor({
1819
id,
@@ -29,6 +30,7 @@ export class QiitaItem {
2930
published,
3031
itemPath,
3132
slide,
33+
draft,
3234
}: {
3335
id: string | null;
3436
title: string;
@@ -44,6 +46,7 @@ export class QiitaItem {
4446
published: boolean;
4547
itemPath: string;
4648
slide: boolean;
49+
draft: boolean;
4750
}) {
4851
this.id = id;
4952
this.title = title;
@@ -59,5 +62,6 @@ export class QiitaItem {
5962
this.published = published;
6063
this.itemPath = itemPath;
6164
this.slide = slide;
65+
this.draft = draft;
6266
}
6367
}

src/lib/file-system-repo.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ slide: false
296296
updated_at: "",
297297
organization_url_name: null,
298298
slide: false,
299+
draft: false,
299300
};
300301
const remoteFilename = `${id}.md`;
301302
const localFilename = remoteFilename;

src/lib/file-system-repo.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class FileContent {
1414
public readonly organizationUrlName: string | null;
1515
public readonly rawBody: string;
1616
public readonly slide: boolean;
17+
public readonly draft: boolean;
1718

1819
constructor({
1920
title,
@@ -24,6 +25,7 @@ class FileContent {
2425
organizationUrlName,
2526
rawBody,
2627
slide,
28+
draft,
2729
}: {
2830
title: string;
2931
tags: string[];
@@ -33,6 +35,7 @@ class FileContent {
3335
organizationUrlName: string | null;
3436
rawBody: string;
3537
slide: boolean;
38+
draft: boolean;
3639
}) {
3740
this.title = title;
3841
this.tags = tags;
@@ -42,6 +45,7 @@ class FileContent {
4245
this.organizationUrlName = organizationUrlName;
4346
this.rawBody = rawBody;
4447
this.slide = slide;
48+
this.draft = draft;
4549
}
4650

4751
static read(fileContent: string): FileContent {
@@ -55,6 +59,7 @@ class FileContent {
5559
id: data.id,
5660
organizationUrlName: data.organization_url_name,
5761
slide: data.slide,
62+
draft: data.draft,
5863
});
5964
}
6065

@@ -74,6 +79,7 @@ class FileContent {
7479
id,
7580
organizationUrlName: null,
7681
slide: false,
82+
draft: false,
7783
});
7884
}
7985

@@ -87,6 +93,7 @@ class FileContent {
8793
id: item.id,
8894
organizationUrlName: item.organization_url_name,
8995
slide: item.slide,
96+
draft: item.draft,
9097
});
9198
}
9299

@@ -100,6 +107,7 @@ class FileContent {
100107
id: item.id,
101108
organizationUrlName: item.organizationUrlName,
102109
slide: item.slide,
110+
draft: item.draft,
103111
});
104112
}
105113

@@ -112,6 +120,7 @@ class FileContent {
112120
id: this.id,
113121
organization_url_name: this.organizationUrlName,
114122
slide: this.slide,
123+
draft: this.draft,
115124
});
116125
}
117126

@@ -153,6 +162,7 @@ class FileContent {
153162
organizationUrlName: this.organizationUrlName,
154163
rawBody: this.rawBody,
155164
slide: this.slide,
165+
draft: this.draft,
156166
});
157167
}
158168
}
@@ -364,6 +374,7 @@ export class FileSystemRepo {
364374
isOlderThanRemote: localFileContent.isOlderThan(remoteFileContent),
365375
itemsShowPath: this.generateItemsShowPath(localFileContent.id, basename),
366376
published: remoteFileContent !== null,
377+
draft: localFileContent.draft,
367378
itemPath,
368379
});
369380
}
@@ -400,6 +411,7 @@ export class FileSystemRepo {
400411
isOlderThanRemote: localFileContent.isOlderThan(remoteFileContent),
401412
itemsShowPath: this.generateItemsShowPath(localFileContent.id, basename),
402413
published: remoteFileContent !== null,
414+
draft: localFileContent.draft,
403415
itemPath,
404416
});
405417
}

src/qiita-api/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export interface Item {
2626
created_at: string;
2727
updated_at: string;
2828
slide: boolean;
29+
draft: boolean;
2930
}
3031

3132
export class QiitaApi {

0 commit comments

Comments
 (0)