mirror of
https://github.com/leonvanzyl/agentic-coding-starter-kit.git
synced 2026-03-16 18:33:09 +00:00
Add non-interactive mode
This commit is contained in:
@@ -16,6 +16,27 @@ Create a new project in a subdirectory:
|
|||||||
npx create-agentic-app@latest my-app
|
npx create-agentic-app@latest my-app
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Non-Interactive Mode (for CI/CD and coding agents)
|
||||||
|
|
||||||
|
All prompts can be bypassed with CLI flags, enabling fully automated project scaffolding:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Full non-interactive setup
|
||||||
|
npx create-agentic-app@latest my-app -y -p pnpm
|
||||||
|
|
||||||
|
# Skip install and git init for faster scaffolding
|
||||||
|
npx create-agentic-app@latest my-app -y -p npm --skip-install --skip-git
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Available Flags
|
||||||
|
|
||||||
|
| Flag | Short | Description |
|
||||||
|
|------|-------|-------------|
|
||||||
|
| `--yes` | `-y` | Auto-confirm non-empty directory prompt |
|
||||||
|
| `--package-manager <manager>` | `-p` | Package manager to use: `pnpm`, `npm`, or `yarn` |
|
||||||
|
| `--skip-install` | | Skip dependency installation |
|
||||||
|
| `--skip-git` | | Skip git repository initialization |
|
||||||
|
|
||||||
## What's Included
|
## What's Included
|
||||||
|
|
||||||
This starter kit includes:
|
This starter kit includes:
|
||||||
|
|||||||
@@ -21,11 +21,24 @@ async function main() {
|
|||||||
.name('create-agentic-app')
|
.name('create-agentic-app')
|
||||||
.description('Scaffold a new agentic AI application')
|
.description('Scaffold a new agentic AI application')
|
||||||
.argument('[project-directory]', 'Project directory name (use "." for current directory)')
|
.argument('[project-directory]', 'Project directory name (use "." for current directory)')
|
||||||
|
.option('-y, --yes', 'Auto-confirm non-empty directory prompt')
|
||||||
|
.option('-p, --package-manager <manager>', 'Package manager to use: pnpm | npm | yarn')
|
||||||
|
.option('--skip-install', 'Skip dependency installation')
|
||||||
|
.option('--skip-git', 'Skip git repository initialization')
|
||||||
.parse(process.argv);
|
.parse(process.argv);
|
||||||
|
|
||||||
const args = program.args;
|
const args = program.args;
|
||||||
|
const opts = program.opts();
|
||||||
let projectDir = args[0] || '.';
|
let projectDir = args[0] || '.';
|
||||||
|
|
||||||
|
// Validate --package-manager value if provided
|
||||||
|
const validPackageManagers = ['pnpm', 'npm', 'yarn'];
|
||||||
|
if (opts.packageManager && !validPackageManagers.includes(opts.packageManager)) {
|
||||||
|
console.log(chalk.red(`Invalid package manager: "${opts.packageManager}"`));
|
||||||
|
console.log(chalk.yellow(`Valid options: ${validPackageManagers.join(', ')}`));
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
// Resolve the target directory
|
// Resolve the target directory
|
||||||
const targetDir = path.resolve(process.cwd(), projectDir);
|
const targetDir = path.resolve(process.cwd(), projectDir);
|
||||||
const projectName = projectDir === '.' ? path.basename(targetDir) : projectDir;
|
const projectName = projectDir === '.' ? path.basename(targetDir) : projectDir;
|
||||||
@@ -34,6 +47,9 @@ async function main() {
|
|||||||
if (fs.existsSync(targetDir)) {
|
if (fs.existsSync(targetDir)) {
|
||||||
const files = fs.readdirSync(targetDir);
|
const files = fs.readdirSync(targetDir);
|
||||||
if (files.length > 0 && projectDir !== '.') {
|
if (files.length > 0 && projectDir !== '.') {
|
||||||
|
if (opts.yes) {
|
||||||
|
console.log(chalk.yellow(`Directory "${projectDir}" is not empty. Proceeding (--yes).`));
|
||||||
|
} else {
|
||||||
const { proceed } = await prompts({
|
const { proceed } = await prompts({
|
||||||
type: 'confirm',
|
type: 'confirm',
|
||||||
name: 'proceed',
|
name: 'proceed',
|
||||||
@@ -47,9 +63,14 @@ async function main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Prompt for package manager
|
// Determine package manager
|
||||||
const { packageManager } = await prompts({
|
let packageManager;
|
||||||
|
if (opts.packageManager) {
|
||||||
|
packageManager = opts.packageManager;
|
||||||
|
} else {
|
||||||
|
const response = await prompts({
|
||||||
type: 'select',
|
type: 'select',
|
||||||
name: 'packageManager',
|
name: 'packageManager',
|
||||||
message: 'Which package manager do you want to use?',
|
message: 'Which package manager do you want to use?',
|
||||||
@@ -60,11 +81,13 @@ async function main() {
|
|||||||
],
|
],
|
||||||
initial: 0
|
initial: 0
|
||||||
});
|
});
|
||||||
|
packageManager = response.packageManager;
|
||||||
|
|
||||||
if (!packageManager) {
|
if (!packageManager) {
|
||||||
console.log(chalk.yellow('Cancelled.'));
|
console.log(chalk.yellow('Cancelled.'));
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
console.log();
|
console.log();
|
||||||
const spinner = ora('Creating project...').start();
|
const spinner = ora('Creating project...').start();
|
||||||
@@ -122,6 +145,9 @@ async function main() {
|
|||||||
spinner.succeed(chalk.green('Project created successfully!'));
|
spinner.succeed(chalk.green('Project created successfully!'));
|
||||||
|
|
||||||
// Install dependencies
|
// Install dependencies
|
||||||
|
if (opts.skipInstall) {
|
||||||
|
console.log(chalk.yellow('\nSkipping dependency installation (--skip-install).'));
|
||||||
|
} else {
|
||||||
console.log();
|
console.log();
|
||||||
const installSpinner = ora(`Installing dependencies with ${packageManager}...`).start();
|
const installSpinner = ora(`Installing dependencies with ${packageManager}...`).start();
|
||||||
|
|
||||||
@@ -136,8 +162,12 @@ async function main() {
|
|||||||
installSpinner.fail(chalk.red('Failed to install dependencies'));
|
installSpinner.fail(chalk.red('Failed to install dependencies'));
|
||||||
console.log(chalk.yellow(`\nPlease run "${packageManager} install" manually.\n`));
|
console.log(chalk.yellow(`\nPlease run "${packageManager} install" manually.\n`));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Initialize Git repository
|
// Initialize Git repository
|
||||||
|
if (opts.skipGit) {
|
||||||
|
console.log(chalk.yellow('\nSkipping git initialization (--skip-git).'));
|
||||||
|
} else {
|
||||||
console.log();
|
console.log();
|
||||||
const gitSpinner = ora('Initializing Git repository...').start();
|
const gitSpinner = ora('Initializing Git repository...').start();
|
||||||
|
|
||||||
@@ -160,6 +190,7 @@ async function main() {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
gitSpinner.warn(chalk.yellow('Git not found - skipping repository initialization'));
|
gitSpinner.warn(chalk.yellow('Git not found - skipping repository initialization'));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Display next steps
|
// Display next steps
|
||||||
console.log();
|
console.log();
|
||||||
|
|||||||
4
create-agentic-app/package-lock.json
generated
4
create-agentic-app/package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "create-agentic-app",
|
"name": "create-agentic-app",
|
||||||
"version": "1.1.46",
|
"version": "1.1.47",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "create-agentic-app",
|
"name": "create-agentic-app",
|
||||||
"version": "1.1.46",
|
"version": "1.1.47",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"chalk": "^5.3.0",
|
"chalk": "^5.3.0",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "create-agentic-app",
|
"name": "create-agentic-app",
|
||||||
"version": "1.1.46",
|
"version": "1.1.47",
|
||||||
"description": "Scaffold a new agentic AI application with Next.js, Better Auth, and AI SDK",
|
"description": "Scaffold a new agentic AI application with Next.js, Better Auth, and AI SDK",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"bin": {
|
"bin": {
|
||||||
|
|||||||
Reference in New Issue
Block a user