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: create-eliza-app #462

Merged
merged 4 commits into from
Nov 20, 2024
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
75 changes: 75 additions & 0 deletions packages/create-eliza-app/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# create-eliza-app

A minimal CLI tool to scaffold ELIZA applications with zero configuration. Get started building your own ELIZA-style chatbot in seconds.

<!-- automd:badges color="yellow" license name="create-eliza-app" codecov bundlephobia packagephobia -->

[![npm version](https://img.shields.io/npm/v/create-eliza-app?color=yellow)](https://npmjs.com/package/create-eliza-app)
[![npm downloads](https://img.shields.io/npm/dm/create-eliza-app?color=yellow)](https://npm.chart.dev/create-eliza-app)
[![bundle size](https://img.shields.io/bundlephobia/minzip/create-eliza-app?color=yellow)](https://bundlephobia.com/package/create-eliza-app)

<!-- /automd -->

## Usage

You can create a new ELIZA app with your preferred package manager:

<!-- automd:pm-x version="latest" name="create-eliza-app" args="path" <flags>" -->

```sh
# npm
npx create-eliza-app@latest path

# pnpm
pnpm dlx create-eliza-app@latest path

# bun
bunx create-eliza-app@latest path

# deno
deno run -A npm:create-eliza-app@latest path
```

<!-- /automd -->


## Command Line Arguments

- `--name`: Name of the template to use (default: "eliza")
- `--dir`: Directory where the project will be created (default: current directory)
- `--registry`: Custom registry URL for templates

## Getting Started

Once your project is created:

1. Navigate to the project directory:

```bash
cd your-project-name
```

2. Copy the example environment file:

```bash
cp .env.example .env
```

3. Install dependencies:

```bash
pnpm install
```

4. Start the development server:
```bash
pnpm start
```

<!-- automd:with-automd -->

---

_🤖 auto updated with [automd](https://automd.unjs.io)_

<!-- /automd -->
31 changes: 31 additions & 0 deletions packages/create-eliza-app/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "create-eliza-app",
ponderingdemocritus marked this conversation as resolved.
Show resolved Hide resolved
"version": "1.0.0",
"description": "",
"sideEffects": false,
"files": [
"dist"
],
"main": "dist/index.cjs",
"bin": {
"create-eliza-app": "dist/index.mjs"
},
"scripts": {
"build": "unbuild",
"dev": "jiti ./src/index.ts",
"start": "node ./dist/index.cjs",
"automd": "automd"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"citty": "^0.1.6",
"giget": "^1.2.3"
},
"devDependencies": {
"automd": "^0.3.12",
"jiti": "^2.4.0",
"unbuild": "^2.0.0"
}
}
6 changes: 6 additions & 0 deletions packages/create-eliza-app/registry/eliza.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "eliza",
"defaultDir": "eliza",
"url": "https://github.com/ai16z/eliza-starter",
"tar": "https://codeload.github.com/ai16z/eliza-starter/tar.gz/refs/heads/main"
}
63 changes: 63 additions & 0 deletions packages/create-eliza-app/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/usr/bin/env node

import { downloadTemplate } from "giget";
import { runMain } from "citty";

const DEFAULT_TEMPLATE = "eliza";
const DEFAULT_REGISTRY =
"https://raw.githubusercontent.com/ai16z/eliza/main/packages/create-eliza-app/registry";

runMain({
args: {
name: {
type: "string",
description: "Name of the template to use",
required: false,
},
registry: {
type: "string",
description: "Registry URL to download the template from",
default: DEFAULT_REGISTRY,
},
dir: {
type: "string",
description: "Directory where the project will be created",
required: false,
},
_dir: {
type: "positional",
default: ".",
description: "Project directory (prefer using --dir)",
},
},
async run(context) {
try {
const templateName = context.args.name || DEFAULT_TEMPLATE;
const targetDir = context.args.dir || context.args._dir;

console.log(`Downloading template ${templateName}...`);

const res = await downloadTemplate(templateName, {
registry: context.args.registry,
dir: targetDir,
});

console.log(`Downloaded template to ${res.dir} from ${res.source}`);

// Print getting started instructions if using default template
if (templateName === DEFAULT_TEMPLATE) {
console.log("\nGetting Started:");
console.log(` cd ${res.dir}`);
console.log(" cp .env.example .env");
console.log(" pnpm install");
console.log(" pnpm start");
}
} catch (error: any) {
console.error(
"Error:",
"message" in error ? error.message : "unknown error"
);
process.exit(1);
}
},
});
11 changes: 11 additions & 0 deletions packages/create-eliza-app/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "Node",
"esModuleInterop": true,
"strict": true,
"skipLibCheck": true
},
"include": ["src"]
}
Loading