@@ -2,14 +2,7 @@ import fs from "node:fs";
22import path from "node:path" ;
33import { config } from "../lib/config" ;
44
5- export const init = async ( ) => {
6- const rootDir = process . cwd ( ) ;
7- const workflowsDirectoryPath = path . join ( rootDir , ".github/workflows" ) ;
8- const publishWorkflowFilePath = path . join (
9- workflowsDirectoryPath ,
10- "publish.yml"
11- ) ;
12- const publishWorkflowFileContent = `# Please set 'QIITA_TOKEN' secret to your repository
5+ const publishWorkflowFileContent = `# Please set 'QIITA_TOKEN' secret to your repository
136name: Publish articles
147
158on:
@@ -39,15 +32,25 @@ jobs:
3932 qiita-token: \${{ secrets.QIITA_TOKEN }}
4033` ;
4134
35+ const rootDir = process . cwd ( ) ;
36+ const workflowsDirectoryPath = path . join ( rootDir , ".github/workflows" ) ;
37+ const publishWorkflowFilePath = path . join (
38+ workflowsDirectoryPath ,
39+ "publish.yml"
40+ ) ;
41+
42+ const gitignoreFilePath = path . join ( rootDir , ".gitignore" ) ;
43+ const gitignoreFileContent = `.remote
44+ node_modules
45+ ` ;
46+
47+ export const init = async ( ) => {
48+ console . log ( "設定ファイルを生成します。\n" ) ;
49+
4250 if ( ! fs . existsSync ( workflowsDirectoryPath ) ) {
4351 fs . mkdirSync ( workflowsDirectoryPath , { recursive : true } ) ;
4452 }
4553 writeFile ( publishWorkflowFilePath , publishWorkflowFileContent ) ;
46-
47- const gitignoreFilePath = path . join ( rootDir , ".gitignore" ) ;
48- const gitignoreFileContent = `.remote
49- node_modules
50- ` ;
5154 writeFile ( gitignoreFilePath , gitignoreFileContent ) ;
5255
5356 const userConfigFilePath = config . getUserConfigFilePath ( ) ;
@@ -61,15 +64,32 @@ node_modules
6164 2
6265 ) ;
6366 writeFile ( userConfigFilePath , userConfigFileContent ) ;
67+
68+ await printNextSteps ( ) ;
6469} ;
6570
6671const writeFile = ( path : string , content : string ) => {
72+ console . log ( ` Creating ${ path } ` ) ;
6773 if ( ! fs . existsSync ( path ) ) {
6874 fs . writeFile ( path , content , { encoding : "utf8" } , ( err ) => {
6975 if ( err ) throw err ;
70- console . log ( `Create ${ path } ` ) ;
7176 } ) ;
77+ console . log ( ` Created!\n` ) ;
7278 } else {
73- console . log ( `${ path } is already exist ` ) ;
79+ console . log ( ` Already exists.\n ` ) ;
7480 }
7581} ;
82+
83+ const printNextSteps = async ( ) => {
84+ const chalk = ( await import ( "chalk" ) ) . default ;
85+ console . log ( `Success! ✨
86+
87+ 次のステップ:
88+
89+ 1. トークンを作成してログインをしてください。
90+ ${ chalk . bold ( "npx qiita login" ) }
91+
92+ 2. 記事のプレビューができるようになります。
93+ ${ chalk . bold ( "npx qiita preview" ) }
94+ ` ) ;
95+ } ;
0 commit comments