Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add help cli #775

Merged
merged 64 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
00a74fa
feat: Add help CLI option in progress
dominicduffin1 Sep 2, 2023
7d2d598
Fix lint errors
dominicduffin1 Sep 3, 2023
42f002f
Merge branch 'main' of https://github.com/JoshuaKGoldberg/create-type…
dominicduffin1 Sep 3, 2023
cd19059
Fix merge conflict markers from weird VS Code issue
dominicduffin1 Sep 3, 2023
50d5bab
Merge branch 'main' of https://github.com/JoshuaKGoldberg/create-type…
dominicduffin1 Sep 9, 2023
21bf2b9
Get version from package.json and reduce duplication
dominicduffin1 Sep 9, 2023
44c929d
Help function refactor in progress
dominicduffin1 Sep 9, 2023
27cf5d2
Dedeuplication and automation of help printouts
dominicduffin1 Sep 10, 2023
890252c
Merge branch 'main' of https://github.com/JoshuaKGoldberg/create-type…
dominicduffin1 Sep 10, 2023
f966a41
Remove magenta highlighting
dominicduffin1 Sep 11, 2023
1bd67b8
Use URL for package.json import
dominicduffin1 Sep 16, 2023
8be564a
Remove pipes and formattng fixes for help section
dominicduffin1 Sep 16, 2023
d33e8f2
Fix lint errors
dominicduffin1 Sep 16, 2023
d930895
Merge branch 'main' of https://github.com/JoshuaKGoldberg/create-type…
dominicduffin1 Sep 16, 2023
58b2384
Merge branch 'add-help-cli' of https://github.com/dominicduffin1/crea…
dominicduffin1 Sep 16, 2023
32d6750
Merge branch 'main' of https://github.com/JoshuaKGoldberg/create-type…
dominicduffin1 Sep 17, 2023
bdf1704
Merge branch 'main' into add-help-cli
JoshuaKGoldberg Sep 18, 2023
e535b5a
Test descriptions consistent with repo conventions
dominicduffin1 Sep 20, 2023
0b68c65
Remove logPipelessLine function
dominicduffin1 Sep 20, 2023
bc66991
Merge branch 'add-help-cli' of https://github.com/dominicduffin1/crea…
dominicduffin1 Sep 20, 2023
5286d89
Cleanup unnecessary typeof
dominicduffin1 Sep 20, 2023
c2c9a82
Cleanup unnecessary typeof
dominicduffin1 Sep 20, 2023
a593594
Fix spacing in welcome text
dominicduffin1 Sep 20, 2023
f3aa25b
Cleanup help section looping
dominicduffin1 Sep 28, 2023
a9ed7c4
Cleanup help file
dominicduffin1 Sep 28, 2023
3b996a7
Fix lint errors
dominicduffin1 Sep 28, 2023
731d3f3
Throw error if package version not found
dominicduffin1 Oct 5, 2023
bd3a60f
Remove typeof check from package json test
dominicduffin1 Oct 5, 2023
7649696
Merge branch 'main' of https://github.com/JoshuaKGoldberg/create-type…
dominicduffin1 Oct 5, 2023
8668e25
Add help entries for new options
dominicduffin1 Oct 7, 2023
05ea1d0
Add missing argument from merge conflict resolution
dominicduffin1 Oct 7, 2023
ec14a93
Merge branch 'main' of https://github.com/JoshuaKGoldberg/create-type…
dominicduffin1 Oct 7, 2023
7de38f2
Remove type assertion
dominicduffin1 Oct 9, 2023
8abad7c
Cleanup package.json test
dominicduffin1 Oct 9, 2023
7fa04e5
Inline destructuring of subsection.flags
dominicduffin1 Oct 13, 2023
c8e273d
Rename Flag interface for clarity
dominicduffin1 Oct 13, 2023
7688582
Make possible undefined properties in HelpTextSection be optional
dominicduffin1 Oct 13, 2023
0621415
Remove undefined properties
dominicduffin1 Oct 13, 2023
74621d3
Revise help output to not have pipes at top (without indentation)
dominicduffin1 Oct 15, 2023
65e20d9
Help indentation
dominicduffin1 Oct 19, 2023
6a13230
Options code simplification
dominicduffin1 Oct 19, 2023
25689b2
Warning indentation
dominicduffin1 Oct 19, 2023
1b8e714
Attempt to mock an invalid package json file for testing
dominicduffin1 Oct 21, 2023
c037573
Add help cli test
dominicduffin1 Oct 21, 2023
809a3ec
Merge branch 'main' of https://github.com/JoshuaKGoldberg/create-type…
dominicduffin1 Oct 22, 2023
6c2589e
Merge branch 'main' of https://github.com/JoshuaKGoldberg/create-type…
dominicduffin1 Oct 26, 2023
d1b8730
Fix error from merge
dominicduffin1 Oct 26, 2023
5bfe967
Update help snapshot with new options
dominicduffin1 Oct 26, 2023
800ef74
Fix lint issues
dominicduffin1 Oct 26, 2023
3ac59db
Help CLI output tweaks
dominicduffin1 Oct 27, 2023
471ee66
Merge branch 'main' of https://github.com/JoshuaKGoldberg/create-type…
dominicduffin1 Oct 27, 2023
314233b
Exclude help snapshot from spelling linter
dominicduffin1 Oct 30, 2023
f3b22a6
Merge branch 'main' of https://github.com/JoshuaKGoldberg/create-type…
dominicduffin1 Oct 30, 2023
5fe93c3
Revise package.json test
dominicduffin1 Nov 1, 2023
fb97a83
Merge branch 'main' of https://github.com/JoshuaKGoldberg/create-type…
dominicduffin1 Nov 1, 2023
68ea2df
Comment failing test
dominicduffin1 Nov 2, 2023
d9da2ce
Update src/bin/packageJson.test.ts
dominicduffin1 Nov 3, 2023
07d413c
Apply package json test fixes
dominicduffin1 Nov 3, 2023
1716013
Mock chalk in help output test
dominicduffin1 Nov 3, 2023
9a1d298
Update help snapshot
dominicduffin1 Nov 3, 2023
9ccbbb3
Use inline snapshot
dominicduffin1 Nov 5, 2023
86753e8
Remove lint:spelling ignorePath
dominicduffin1 Nov 5, 2023
5f909d7
Merge branch 'main' of https://github.com/JoshuaKGoldberg/create-type…
dominicduffin1 Nov 5, 2023
8ad0980
Merge branch 'main' of https://github.com/JoshuaKGoldberg/create-type…
dominicduffin1 Nov 7, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
336 changes: 336 additions & 0 deletions src/bin/help.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,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",
],
[],
]
`);
});
});
Loading