Skip to content

Commit c1e269c

Browse files
committed
fix setup/ run example
1 parent 678b215 commit c1e269c

File tree

6 files changed

+47
-11
lines changed

6 files changed

+47
-11
lines changed

eslint.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export default [
1010
ignores: [
1111
"dist/**",
1212
"eslint.config.js",
13+
"setup.cjs",
1314
"**/_generated/",
1415
"node10stubs.mjs",
1516
],

examples/chat-basic/package-lock.json

Lines changed: 8 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/chat-streaming/package-lock.json

Lines changed: 8 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"scripts": {
2020
"example": "npm run setup && cd example && npm run dev",
2121
"dev": "run-p 'example' 'build:watch'",
22-
"setup": "npm i && npm run build && cd example && npm i",
22+
"setup": "node setup.cjs",
2323
"build": "npm run build:esm && npm run build:cjs",
2424
"build:watch": "cd src && npx chokidar '../tsconfig.json' '*.ts' 'react/**/*.ts' 'component/**/*.ts' 'client/**/*.ts' -c 'npm run build' --initial",
2525
"build:esm": "tsc --project ./esm.json && npm run copy:dts:esm && echo '{\\n \"type\": \"module\"\\n}' > dist/esm/package.json",

playground/package-lock.json

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

setup.cjs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env node
2+
3+
// "setup": "npm i && npm run build && cd example && npm i",
4+
const { readdirSync, statSync } = require("fs");
5+
const { join } = require("path");
6+
const { execSync } = require("child_process");
7+
8+
execSync("npm install", { cwd: __dirname, stdio: "inherit" });
9+
execSync("npm run build", { cwd: __dirname, stdio: "inherit" });
10+
execSync("npm install", {
11+
cwd: join(__dirname, "./example"),
12+
stdio: "inherit",
13+
});
14+
execSync("npm install", {
15+
cwd: join(__dirname, "./playground"),
16+
stdio: "inherit",
17+
});
18+
19+
const examplesDir = join(__dirname, "./examples");
20+
readdirSync(examplesDir).forEach((name) => {
21+
const dir = join(examplesDir, name);
22+
if (statSync(dir).isDirectory()) {
23+
console.log(`↪ installing in ${dir}`);
24+
execSync("npm install", { cwd: dir, stdio: "inherit" });
25+
}
26+
});

0 commit comments

Comments
 (0)