Skip to content

feat: add options.type #2112

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

Merged
merged 4 commits into from
Apr 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions docs/CLI.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ Each defaults to a value based on the running system, including an repository if
| `--pnpm` | `string` | pnpm version for `package.json`'s `packageManager` field | Existing value in `package.json` if it exists |
| `--repository` | `string` | Name for the new repository | The same as `--directory` |
| `--title` | `string` | 'Title Case' title for the repository | Title-cased `repository` |
| `--type` | `string` | package.json modules type | Existing value in `package.json` if it exists, or `"module"` |
| `--version` | `string` | package version to publish as and store in `package.json` | Existing value in `package.json` if it exists, or `"0.0.0"` |
| `--words` | `string[]` | additional words to add to the CSpell dictionary | Existing `words` in a `cspell.json` file if it exists, and any new words in from other options |

Expand Down
2 changes: 1 addition & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default tseslint.config(
tseslint.configs.strictTypeChecked,
tseslint.configs.stylisticTypeChecked,
],
files: ["**/*.js", "**/*.ts"],
files: ["**/*.{js,ts}"],
languageOptions: {
parserOptions: {
projectService: {
Expand Down
1 change: 1 addition & 0 deletions src/base.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ describe("base", () => {
pnpm: expect.any(String),
repository: "create-typescript-app",
title: "Create TypeScript App",
type: expect.any(String),
version: expect.any(String),
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-require-imports
words: require("../cspell.json").words,
Expand Down
7 changes: 7 additions & 0 deletions src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ export const base = createBase({
.optional()
.describe("GitHub branch ruleset ID for main branch protections"),
title: z.string().describe("'Title Case' title for the repository"),
type: z
.union([z.literal("commonjs"), z.literal("module")])
.optional()
.describe("package.json modules type"),
version: z
.string()
.optional()
Expand Down Expand Up @@ -294,6 +298,8 @@ export const base = createBase({
async () => await readTitle(getReadme, getRepository),
);

const getType = lazyValue(async () => (await getPackageData()).type);

const getVersion = lazyValue(async () => (await getPackageData()).version);

const getWords = lazyValue(async () => await readWords(take));
Expand Down Expand Up @@ -324,6 +330,7 @@ export const base = createBase({
repository: getRepository,
rulesetId: getRulesetId,
title: getTitle,
type: getType,
version: getVersion,
words: getWords,
workflowsVersions: getWorkflowData,
Expand Down
Loading