Skip to content

Commit

Permalink
Merge pull request #65 from ikepu-tp/main
Browse files Browse the repository at this point in the history
Add a parameter whose name is `ignorePublish` to article markdown
  • Loading branch information
ohakutsu authored Sep 15, 2023
2 parents 6fc357f + ff2a520 commit 0d49baa
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +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に投稿されます)
---
# new article body
```
Expand Down
1 change: 1 addition & 0 deletions src/commands/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const publish = async (argv: string[]) => {
let targetItems: QiitaItem[];
if (args["--all"]) {
targetItems = (await fileSystemRepo.loadItems()).filter((item) => {
if (item.ignorePublish === true) return false;
return item.modified || item.id === null;
});
} else {
Expand Down
4 changes: 4 additions & 0 deletions src/lib/entities/qiita-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export class QiitaItem {
public readonly published: boolean;
public readonly itemPath: string;
public readonly slide: boolean;
public readonly ignorePublish: boolean;

constructor({
id,
Expand All @@ -29,6 +30,7 @@ export class QiitaItem {
published,
itemPath,
slide,
ignorePublish,
}: {
id: string | null;
title: string;
Expand All @@ -44,6 +46,7 @@ export class QiitaItem {
published: boolean;
itemPath: string;
slide: boolean;
ignorePublish: boolean;
}) {
this.id = id;
this.title = title;
Expand All @@ -59,5 +62,6 @@ export class QiitaItem {
this.published = published;
this.itemPath = itemPath;
this.slide = slide;
this.ignorePublish = ignorePublish;
}
}
15 changes: 14 additions & 1 deletion src/lib/file-system-repo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class FileContent {
public readonly organizationUrlName: string | null;
public readonly rawBody: string;
public readonly slide: boolean;
public readonly ignorePublish: boolean;

constructor({
title,
Expand All @@ -24,6 +25,7 @@ class FileContent {
organizationUrlName,
rawBody,
slide,
ignorePublish = false,
}: {
title: string;
tags: string[];
Expand All @@ -33,6 +35,7 @@ class FileContent {
organizationUrlName: string | null;
rawBody: string;
slide: boolean;
ignorePublish: boolean;
}) {
this.title = title;
this.tags = tags;
Expand All @@ -42,6 +45,7 @@ class FileContent {
this.organizationUrlName = organizationUrlName;
this.rawBody = rawBody;
this.slide = slide;
this.ignorePublish = ignorePublish;
}

static read(fileContent: string): FileContent {
Expand All @@ -55,6 +59,7 @@ class FileContent {
id: data.id,
organizationUrlName: data.organization_url_name,
slide: data.slide,
ignorePublish: data.ignorePublish ?? false,
});
}

Expand All @@ -74,6 +79,7 @@ class FileContent {
id,
organizationUrlName: null,
slide: false,
ignorePublish: false,
});
}

Expand All @@ -87,6 +93,7 @@ class FileContent {
id: item.id,
organizationUrlName: item.organization_url_name,
slide: item.slide,
ignorePublish: false,
});
}

Expand All @@ -100,6 +107,7 @@ class FileContent {
id: item.id,
organizationUrlName: item.organizationUrlName,
slide: item.slide,
ignorePublish: item.ignorePublish,
});
}

Expand All @@ -112,6 +120,7 @@ class FileContent {
id: this.id,
organization_url_name: this.organizationUrlName,
slide: this.slide,
ignorePublish: this.ignorePublish,
});
}

Expand All @@ -131,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
);
}

Expand All @@ -153,6 +163,7 @@ class FileContent {
organizationUrlName: this.organizationUrlName,
rawBody: this.rawBody,
slide: this.slide,
ignorePublish: this.ignorePublish,
});
}
}
Expand Down Expand Up @@ -364,6 +375,7 @@ export class FileSystemRepo {
isOlderThanRemote: localFileContent.isOlderThan(remoteFileContent),
itemsShowPath: this.generateItemsShowPath(localFileContent.id, basename),
published: remoteFileContent !== null,
ignorePublish: localFileContent.ignorePublish,
itemPath,
});
}
Expand Down Expand Up @@ -400,6 +412,7 @@ export class FileSystemRepo {
isOlderThanRemote: localFileContent.isOlderThan(remoteFileContent),
itemsShowPath: this.generateItemsShowPath(localFileContent.id, basename),
published: remoteFileContent !== null,
ignorePublish: localFileContent.ignorePublish,
itemPath,
});
}
Expand Down

0 comments on commit 0d49baa

Please sign in to comment.