@@ -17,17 +17,17 @@ export default async function createReadme({
17
17
18
18
if ( addWip ) {
19
19
// WIP banner
20
- content += `# 🚧 WORK IN PROGRESS. See [#1](https://github.com/${ repository } /pull/1)
20
+ content += `# 🚧 WORK IN PROGRESS. See [#1](https://github.com/${ repository } /pull/1) | [Preview](https://github.com/ ${ repository } /tree/initial-version)
21
21
22
22
` ;
23
23
}
24
24
25
25
// header
26
- content += `# ${ repo }
26
+ content += `# ${ repo } \n\n` ;
27
27
28
- > ${ description }
29
-
30
- ` ;
28
+ if ( description ) {
29
+ content += `> ${ description } \n\n` ;
30
+ }
31
31
32
32
if ( addBadges ) {
33
33
content += `[](https://www.npmjs.com/package/${ packageName } )
@@ -37,58 +37,69 @@ export default async function createReadme({
37
37
}
38
38
39
39
if ( addUsage ) {
40
- let usage = `npx ${ packageName } \\
41
- --octoherd-token 0123456789012345678901234567890123456789 \\
42
- "${ owner } /*"` ;
40
+ let minimalUsage = `npx ${ packageName } ` ;
41
+ let fullUsage = `npx ${ packageName } \\
42
+ -T ghp_0123456789abcdefghjklmnopqrstuvwxyzA \\
43
+ -R "${ owner } /*"` ;
43
44
44
45
Object . entries ( scriptOptions ) . forEach ( ( [ name , { required, example } ] ) => {
45
46
if ( ! required ) return ;
46
- usage += ` \\
47
+ minimalUsage += ` \\
48
+ --${ name } ${ example } ` ;
49
+ } ) ;
50
+ Object . entries ( scriptOptions ) . forEach ( ( [ name , { required, example } ] ) => {
51
+ fullUsage += ` \\
47
52
--${ name } ${ example } ` ;
48
53
} ) ;
49
54
50
55
content += `## Usage
51
56
57
+ Minimal usage
58
+
52
59
\`\`\`js
53
- ${ usage }
60
+ ${ minimalUsage }
61
+ \`\`\`
62
+
63
+ Pass all options as CLI flags to avoid user prompts
64
+
65
+ \`\`\`js
66
+ ${ fullUsage }
54
67
\`\`\`
55
68
56
- ` ;
57
69
58
- if ( Object . keys ( scriptOptions ) . length === 0 ) {
59
- content += `The script has no options
60
-
61
70
` ;
62
- } else {
63
- content += `## Options
71
+
72
+ content += `## Options
64
73
65
74
| option | type | description |
66
75
| --- | --- | --- |
67
76
` ;
68
77
69
- Object . entries ( scriptOptions ) . forEach (
70
- ( [ name , { type, required, description, default : defaultValue } ] ) => {
71
- const CliOption = decamelize ( name , {
72
- separator : "-" ,
73
- } ) ;
74
- let optionNames = `\`--${ CliOption } \`` ;
75
- if ( type === "boolean" ) {
76
- optionNames += ` or \`--no-${ CliOption } \`` ;
77
- }
78
-
79
- content += `| ${ optionNames } | ${ type } | ${
80
- required ? `**(required)**` : ""
81
- } ${ description } ${
82
- defaultValue
83
- ? `. Defaults to ${
84
- type === "string" ? `"${ defaultValue } "` : defaultValue
85
- } `
86
- : ""
87
- } |
88
- ` ;
78
+ Object . entries ( scriptOptions ) . forEach (
79
+ ( [ name , { type, required, description, default : defaultValue } ] ) => {
80
+ const CliOption = decamelize ( name , {
81
+ separator : "-" ,
82
+ } ) ;
83
+ let optionNames = `\`--${ CliOption } \`` ;
84
+ if ( type === "boolean" ) {
85
+ optionNames += ` or \`--no-${ CliOption } \`` ;
89
86
}
90
- ) ;
91
- }
87
+
88
+ content += `| ${ optionNames } | ${ type } | ${
89
+ required ? `**Required.**` : ""
90
+ } ${ description } ${
91
+ defaultValue
92
+ ? `. Defaults to ${
93
+ type === "string" ? `"${ defaultValue } "` : defaultValue
94
+ } `
95
+ : ""
96
+ } |
97
+ ` ;
98
+ }
99
+ ) ;
100
+
101
+ content += `| \`--octoherd-token\`, \`-T\` | string | A personal access token ([create](https://github.com/settings/tokens/new?scopes=repo)). Script will create one if option is not set |\n` ;
102
+ content += `| \`--octoherd-repos\`, \`-R\` | array of strings | One or multiple space-separated repositories in the form of \`repo-owner/repo-name\`. \`repo-owner/*\` will find all repositories for one owner. \`*\` will find all repositories the user has access to. Will prompt for repositories if not set |\n\n` ;
92
103
}
93
104
94
105
// footer
0 commit comments