@@ -2,14 +2,7 @@ import fs from "node:fs";
2
2
import path from "node:path" ;
3
3
import { config } from "../lib/config" ;
4
4
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
13
6
name: Publish articles
14
7
15
8
on:
@@ -39,15 +32,25 @@ jobs:
39
32
qiita-token: \${{ secrets.QIITA_TOKEN }}
40
33
` ;
41
34
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
+
42
50
if ( ! fs . existsSync ( workflowsDirectoryPath ) ) {
43
51
fs . mkdirSync ( workflowsDirectoryPath , { recursive : true } ) ;
44
52
}
45
53
writeFile ( publishWorkflowFilePath , publishWorkflowFileContent ) ;
46
-
47
- const gitignoreFilePath = path . join ( rootDir , ".gitignore" ) ;
48
- const gitignoreFileContent = `.remote
49
- node_modules
50
- ` ;
51
54
writeFile ( gitignoreFilePath , gitignoreFileContent ) ;
52
55
53
56
const userConfigFilePath = config . getUserConfigFilePath ( ) ;
@@ -61,15 +64,32 @@ node_modules
61
64
2
62
65
) ;
63
66
writeFile ( userConfigFilePath , userConfigFileContent ) ;
67
+
68
+ await printNextSteps ( ) ;
64
69
} ;
65
70
66
71
const writeFile = ( path : string , content : string ) => {
72
+ console . log ( ` Creating ${ path } ` ) ;
67
73
if ( ! fs . existsSync ( path ) ) {
68
74
fs . writeFile ( path , content , { encoding : "utf8" } , ( err ) => {
69
75
if ( err ) throw err ;
70
- console . log ( `Create ${ path } ` ) ;
71
76
} ) ;
77
+ console . log ( ` Created!\n` ) ;
72
78
} else {
73
- console . log ( `${ path } is already exist ` ) ;
79
+ console . log ( ` Already exists.\n ` ) ;
74
80
}
75
81
} ;
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