Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a parameter whose name is ignorePublish to article markdown #65

Merged
merged 8 commits into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 === false) 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,
ignorePublisht: 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