|
1 | 1 | # Cloudflare AI |
2 | 2 |
|
3 | | -This repository contains various packages and apps related consuming Cloudflare's AI offerings on the client-side. It is a monorepo powered by [Nx](https://nx.dev/) and [Changesets](https://github.com/changesets/changesets). |
| 3 | +This repository contains various packages and demo apps related consuming Cloudflare's AI offerings on the client-side. It is a monorepo powered by [Nx](https://nx.dev/) and [Changesets](https://github.com/changesets/changesets). |
4 | 4 |
|
5 | | -## What's in the Repo |
6 | | - |
7 | | -``` |
8 | | -- demos [Apps that demonstrate Cloudflare AI capabilities] |
9 | | -- libs [Shared libraries for demos and packages] |
10 | | -- packages [Packages that can be published to npm] |
11 | | -``` |
12 | | - |
13 | | -### Packages |
| 5 | +## Packages |
14 | 6 |
|
15 | 7 | - [`workers-ai-provider`](./packages/workers-ai-provider/README.md): A custom provider that enables [Workers AI](https://ai.cloudflare.com/)'s models for the [Vercel AI SDK](https://sdk.vercel.ai/). |
16 | 8 |
|
@@ -69,6 +61,20 @@ This repository contains various packages and apps related consuming Cloudflare' |
69 | 61 | - `test:smoke`: Runs smoke tests. |
70 | 62 | - `type-check`: Performs TypeScript type checks. |
71 | 63 |
|
| 64 | +## Creating a New Demo App |
| 65 | + |
| 66 | +In order to scaffold a new demo app, you can use the `create-demo` script. This script will create a new demo app in the `demos` directory. |
| 67 | + |
| 68 | +```bash |
| 69 | +npm run create-demo <demo-name> |
| 70 | +``` |
| 71 | + |
| 72 | +After creating the app, `npm install` will be run to install the dependencies, and `npx nx cf-typegen <demo-name>` will be run to generate the types for the demo app. Then it's simply a case of starting the app with: |
| 73 | +
|
| 74 | +```bash |
| 75 | +npx nx dev <demo-name> |
| 76 | +``` |
| 77 | +
|
72 | 78 | ## Contributing |
73 | 79 |
|
74 | 80 | We appreciate contributions and encourage pull requests. Please follow these guidelines: |
@@ -100,53 +106,6 @@ This repository uses [Changesets](https://github.com/changesets/changesets) to m |
100 | 106 |
|
101 | 107 | 3. **Publication**: The release workflow (`.github/workflows/release.yml`) will run on every push to `main`. It ensures each published package is tagged and released on npm. Any package with a version field in its `package.json` will be included in this process. |
102 | 108 |
|
103 | | -## Various Repo Notes |
104 | | - |
105 | | -### Hoisted Dependencies |
106 | | - |
107 | | -In this monorepo, we rely on hoisting to place common dependencies in the root `node_modules`, thereby simplifying version management. This practice means: |
108 | | - |
109 | | -- Shared dependencies appear only once at the root. |
110 | | -- Individual package or library directories usually contain only project-specific dependencies. |
111 | | - |
112 | | -Should you encounter version conflicts or require specific dependency versions, adjustments can be made on a per-package basis, but in general, we keep everything consolidated at the root wherever possible. |
113 | | - |
114 | | -### Relative paths |
115 | | - |
116 | | -In this monorepo, relative paths are used for imports in order to simplify the tool-chain. This means that when you import a module, you should use the relative path from the file where you're importing it. For example: |
117 | | -
|
118 | | -```ts |
119 | | -import { myFunction } from '../my-package/src/myFunction'; |
120 | | -``` |
121 | | -
|
122 | | -### TSConfig |
123 | | -
|
124 | | -There are several `tsconfig` files at the root that cover the various environments that each package or file is supposed to run in. In most cases, this means that you don't need a tsconfig in each package, but sometimes it's unavoidable, especially in published packages. |
125 | | -
|
126 | | -The way that it is setup, each file by default is included in the `tsconfig.node.json` config. So this will apply to everything in the package. If the `src` for the package is not supposed to run in Node, then you can add it to the relevant `tsconfig`. For example: |
127 | | -
|
128 | | -```txt |
129 | | -- my-browser-based-app |
130 | | - - src |
131 | | - - index.ts |
132 | | - some-node-config-or-script.ts |
133 | | - package.json |
134 | | -``` |
135 | | -Here, the `some-node-config-or-script.ts` file falls correctly under the `tsconfig.node.json` config, but we can add the `src` folder to the `tsconfig.browser.json` config. |
136 | | -
|
137 | | -```jsonc |
138 | | -{ |
139 | | - "extends": "./tsconfig.base.json", |
140 | | - "compilerOptions": { |
141 | | - ... |
142 | | - }, |
143 | | - "include": [ |
144 | | - "./demos/my-browser-based-app/src/client/**/*.ts", |
145 | | - "./demos/my-browser-based-app/src/client/**/*.tsx", |
146 | | - ] |
147 | | -} |
148 | | -``` |
149 | | -
|
150 | 109 | --- |
151 | 110 |
|
152 | 111 | For any queries or guidance, kindly open an issue or submit a pull request. We hope this structure and process help you to contribute effectively. |
|
0 commit comments