-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add create project CLI command, and lot of commands alias
- Loading branch information
Showing
10 changed files
with
74 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { defineCommand, runCommand } from 'citty' | ||
import consola from 'consola' | ||
import { createProject } from '../utils/projects.ts' | ||
import link from './link.ts' | ||
|
||
export default defineCommand({ | ||
meta: { | ||
name: 'create', | ||
description: 'Create a new project', | ||
}, | ||
args: { | ||
name: { | ||
type: 'string', | ||
description: 'Project name', | ||
valueHint: 'my-project', | ||
required: true, | ||
alias: 'n', | ||
}, | ||
}, | ||
async setup(ctx) { | ||
const name = ctx.args.name | ||
consola.start(`Creating project ${ name }...`) | ||
try { | ||
await createProject(name) | ||
consola.success(`Project ${ name } created successfully!`) | ||
const linkProject = await consola.prompt('Do you want to link the project? (y/n)', { | ||
default: 'y', | ||
type: 'confirm', | ||
}) | ||
if (linkProject) { | ||
await runCommand(link, { rawArgs: [name] }).then(() => { | ||
consola.success('Project linked successfully!') | ||
}).catch(() => { | ||
consola.error('Failed to link the project') | ||
}) | ||
} | ||
} catch (e) { | ||
consola.error('Failed to create project') | ||
} | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters