forked from JoshuaKGoldberg/create-typescript-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelp.test.ts
336 lines (329 loc) · 8.96 KB
/
help.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
import chalk from "chalk";
import { SpyInstance, beforeEach, describe, expect, it, vi } from "vitest";
import { logHelpText } from "./help.js";
function makeProxy<T extends object>(receiver: T): T {
return new Proxy(receiver, {
get: () => makeProxy((input: string) => input),
});
}
vi.mock("chalk", () => ({
default: makeProxy({}),
}));
let mockConsoleLog: SpyInstance;
describe("logHelpText", () => {
beforeEach(() => {
mockConsoleLog = vi
.spyOn(console, "log")
.mockImplementation(() => undefined);
});
it("logs help text when called", () => {
logHelpText([
chalk.yellow(
"⚠️ This template is early stage, opinionated, and not endorsed by the TypeScript team. ⚠️",
),
chalk.yellow(
"⚠️ If any tooling it sets displeases you, you can always remove that portion manually. ⚠️",
),
]);
expect(mockConsoleLog.mock.calls).toMatchInlineSnapshot(`
[
[
"⚠️ This template is early stage, opinionated, and not endorsed by the TypeScript team. ⚠️",
],
[
" ",
],
[
"⚠️ If any tooling it sets displeases you, you can always remove that portion manually. ⚠️",
],
[
" ",
],
[
"
A quickstart-friendly TypeScript template with comprehensive formatting,
linting, releases, testing, and other great tooling built-in.
",
],
[
" ",
],
[
"Core options:",
],
[
"
--base (string): Whether to scaffold the repository with:
• everything: that comes with the template (recommended)
• minimum: amounts of tooling, essentially opting out of everything
• prompt: for which portions to exclude",
],
[
"
--create-repository: Whether to create a corresponding repository on github.com
(if it doesn't yet exist)",
],
[
"
--description (string): Sentence case description of the repository
(e.g. A quickstart-friendly TypeScript package with lots of great
repository tooling. ✨)",
],
[
"
--mode (string): Whether to:
• create: a new repository in a child directory
• initialize: a freshly repository in the current directory
• migrate: an existing repository in the current directory",
],
[
"
--owner (string): GitHub organization or user the repository is underneath
(e.g. JoshuaKGoldberg)",
],
[
"
--repository (string): The kebab-case name of the repository
(e.g. create-typescript-app)",
],
[
"
--title (string): Title Case title for the repository to be used in
documentation (e.g. Create TypeScript App)",
],
[],
[
" ",
],
[
"Optional options:",
],
[
"
--access (string): (\\"public\\" | \\"restricted\\"): Which npm publish --access to
release npm packages with (by default, \\"public\\")",
],
[
"
--author (string): Username on npm to publish packages under (by
default, an existing npm author, or the currently logged in npm user, or
owner.toLowerCase())",
],
[
"
--directory (string): Directory to create the repository in (by default, the same
name as the repository)",
],
[
"
--email (string): Email address to be listed as the point of contact in docs
and packages (e.g. [email protected])",
],
[
"
--email-github (string): Optionally, may be provided to use different emails in .md
files",
],
[
"
--email-npm (string): Optionally, may be provided to use different emails in
package.json",
],
[
"
--funding (string): GitHub organization or username to mention in funding.yml
(by default, owner)",
],
[
"
--guide (string): Link to a contribution guide to place at the top of the
development docs",
],
[
"
--guide-title (string): If --guide is provided or detected from an existing
DEVELOPMENT.md, the text title to place in the guide link",
],
[
"
--keywords (string): Any number of keywords to include in package.json (by default,
none). This can be specified any number of times, like
--keywords apple --keywords \\"banana cherry\\"",
],
[
"
--logo (string): Local image file in the repository to display near the top of
the README.md as a logo",
],
[
"
--logo-alt (string): If --logo is provided or detected from an existing README.md,
alt text that describes the image will be prompted for if not provided",
],
[
"
--preserve-generated-form: Whether to keep the GitHub repository generated from
notice (by default, false)",
],
[],
[
" ",
],
[
"Opt-outs:",
],
[
"
⚠️ Warning: Specifying any --exclude-* flag on the command-line will
cause the setup script to skip prompting for more excludes. ⚠️",
],
[
"
--exclude-all-contributors: Don't add all-contributors to track contributions
and display them in a README.md table.",
],
[
"
--exclude-compliance: Don't add a GitHub Actions workflow to verify that PRs match
an expected format.",
],
[
"
--exclude-lint-deprecation: Don't use eslint-plugin-deprecation to report on usage
of code marked as @deprecated.",
],
[
"
--exclude-lint-jsdoc: Don't use eslint-plugin-jsdoc to enforce good practices around
JSDoc comments.",
],
[
"
--exclude-lint-json: Don't apply linting and sorting to *.json, and
*.jsonc files.",
],
[
"
--exclude-lint-knip: Don't add Knip to detect unused files, dependencies, and code
exports.",
],
[
"
--exclude-lint-md: Don't apply linting to *.md files.",
],
[
"
--exclude-lint-package-json: Don't add npm-package-json-lint to lint for
package.json correctness.",
],
[
"
--exclude-lint-packages: Don't add a pnpm dedupe workflow to ensure packages
aren't duplicated unnecessarily.",
],
[
"
--exclude-lint-perfectionist: Don't apply eslint-plugin-perfectionist to ensure
imports, keys, and so on are in sorted order.",
],
[
"
--exclude-lint-regex: Don't add eslint-plugin-regex to enforce good practices around
regular expressions.",
],
[
"
--exclude-lint-spelling: Don't add cspell to spell check against dictionaries
of known words.",
],
[
"
--exclude-lint-strict: Don't augment the recommended logical lint rules with
typescript-eslint's strict config.",
],
[
"
--exclude-lint-stylistic: Don't add stylistic rules such as typescript-eslint's
stylistic config.",
],
[
"
--exclude-lint-yml: Don't apply linting and sorting to *.yaml and *.yml files.",
],
[
"
--exclude-releases: Don't add release-it to generate changelogs, package bumps,
and publishes based on conventional commits.",
],
[
"
--exclude-renovate: Don't add a Renovate config to dependencies up-to-date with
PRs.",
],
[
"
--exclude-tests: Don't add Vitest tooling for fast unit tests, configured
with coverage tracking.",
],
[
"
You can prevent the migration script from making some network-based
changes using any or all of the following CLI flags:",
],
[
"
--exclude-contributors: Skips network calls that fetch all-contributors
data from GitHub",
],
[
"
--skip-all-contributors-api: Skips network calls that fetch all-contributors data from
GitHub. This flag does nothing if --exclude-all-contributors was specified.",
],
[
"
--skip-github-api: Skips calling to GitHub APIs.",
],
[
"
--skip-install: Skips installing all the new template packages with pnpm.",
],
[
"
You can prevent the migration script from making some changes on disk
using any or all of the following CLI flags:",
],
[
"
--skip-removal: Skips removing setup docs and scripts, including this docs/
directory",
],
[
"
--skip-restore: Skips the prompt offering to restore the repository if an
error occurs during setup",
],
[
"
--skip-uninstall: Skips uninstalling packages only used for setup scripts",
],
[],
[
" ",
],
[
"Offline Mode:",
],
[
"
--offline: You can run create-typescript-app in an \\"offline\\" mode.
Doing so will:
• Enable --exclude-all-contributors-api and --skip-github-api
• Skip network calls when setting up contributors
• Run pnpm commands with pnpm's --offline mode",
],
[],
]
`);
});
});