File tree Expand file tree Collapse file tree 4 files changed +22
-5
lines changed Expand file tree Collapse file tree 4 files changed +22
-5
lines changed Original file line number Diff line number Diff line change @@ -207,6 +207,14 @@ Qiita 上で更新を行い、手元で変更を行っていない記事ファ
207207npx qiita pull
208208```
209209
210+ ` --force ` オプションを用いることで、記事ファイルをを全て強制的に Qiita と同期します。
211+
212+ ``` console
213+ npx qiita pull --force
214+ # -f は --force のエイリアスとして使用できます。
215+ npx qiita pull -f
216+ ```
217+
210218### version
211219
212220Qiita CLI のバージョンを確認できます。
Original file line number Diff line number Diff line change @@ -7,12 +7,19 @@ import { QiitaApi } from "../qiita-api";
77import { startLocalChangeWatcher , startServer } from "../server/app" ;
88
99export const pull = async ( argv : string [ ] ) => {
10- const args = arg ( { } , { argv } ) ;
10+ const args = arg (
11+ {
12+ "--force" : Boolean ,
13+ "-f" : "--force" ,
14+ } ,
15+ { argv }
16+ ) ;
1117
1218 const qiitaApi = await getQiitaApiInstance ( ) ;
1319 const fileSystemRepo = await getFileSystemRepo ( ) ;
20+ const isLocalUpdate = args [ "--force" ] ;
1421
15- await syncArticlesFromQiita ( { fileSystemRepo, qiitaApi } ) ;
22+ await syncArticlesFromQiita ( { fileSystemRepo, qiitaApi, isLocalUpdate } ) ;
1623 console . log ( "Sync local articles from Qiita" ) ;
1724 console . log ( "Successful!" ) ;
1825} ;
Original file line number Diff line number Diff line change @@ -276,9 +276,9 @@ export class FileSystemRepo {
276276 }
277277 }
278278
279- async saveItems ( items : Item [ ] ) {
279+ async saveItems ( items : Item [ ] , isLocalUpdate : boolean = false ) {
280280 const promises = items . map ( async ( item ) => {
281- await this . syncItem ( item ) ;
281+ await this . syncItem ( item , false , isLocalUpdate ) ;
282282 } ) ;
283283
284284 await Promise . all ( promises ) ;
Original file line number Diff line number Diff line change @@ -5,9 +5,11 @@ import { config } from "./config";
55export const syncArticlesFromQiita = async ( {
66 fileSystemRepo,
77 qiitaApi,
8+ isLocalUpdate = false ,
89} : {
910 fileSystemRepo : FileSystemRepo ;
1011 qiitaApi : QiitaApi ;
12+ isLocalUpdate ?: boolean ;
1113} ) => {
1214 const per = 100 ;
1315 const userConfig = await config . getUserConfig ( ) ;
@@ -20,6 +22,6 @@ export const syncArticlesFromQiita = async ({
2022 const result = userConfig . includePrivate
2123 ? items
2224 : items . filter ( ( item ) => ! item . private ) ;
23- await fileSystemRepo . saveItems ( result ) ;
25+ await fileSystemRepo . saveItems ( result , isLocalUpdate ) ;
2426 }
2527} ;
You can’t perform that action at this time.
0 commit comments