Skip to content

Commit 23e4e62

Browse files
committed
feat(cli): support explicit git opt-in and opt-out flags
1 parent 518f947 commit 23e4e62

4 files changed

Lines changed: 20 additions & 2 deletions

File tree

packages/cli/src/cli.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,7 @@ export function cli({
504504
'--addon-details <addon-id>',
505505
'show detailed information about a specific add-on',
506506
)
507+
.option('--git', 'create a git repository')
507508
.option('--no-git', 'do not create a git repository')
508509
.option(
509510
'--target-dir <path>',

packages/cli/src/command-line.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ export async function normalizeOptions(
195195
cliOptions.packageManager ||
196196
getPackageManager() ||
197197
DEFAULT_PACKAGE_MANAGER,
198-
git: !!cliOptions.git,
198+
git: cliOptions.git ?? true,
199199
install: cliOptions.install,
200200
chosenAddOns,
201201
addOnOptions: {

packages/cli/src/options.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ export async function promptForCreateOptions(
150150
options.addOnOptions = { ...defaultOptions, ...userOptions }
151151
}
152152

153-
options.git = cliOptions.git || (await selectGit())
153+
options.git = cliOptions.git ?? (await selectGit())
154154
if (cliOptions.install === false) {
155155
options.install = false
156156
}

packages/cli/tests/command-line.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,23 @@ describe('normalizeOptions', () => {
9191
expect(solidOptions?.tailwind).toBe(true)
9292
})
9393

94+
it('defaults git initialization to enabled', async () => {
95+
const options = await normalizeOptions({
96+
projectName: 'test',
97+
})
98+
99+
expect(options?.git).toBe(true)
100+
})
101+
102+
it('respects explicit --no-git option', async () => {
103+
const options = await normalizeOptions({
104+
projectName: 'test',
105+
git: false,
106+
})
107+
108+
expect(options?.git).toBe(false)
109+
})
110+
94111
it('should handle a starter url', async () => {
95112
__testRegisterFramework({
96113
id: 'solid',

0 commit comments

Comments
 (0)