Skip to content

Commit

Permalink
build more in vercel
Browse files Browse the repository at this point in the history
  • Loading branch information
bracesproul committed Aug 8, 2024
1 parent 6a89e84 commit 80e48e2
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 1 deletion.
36 changes: 36 additions & 0 deletions .github/workflows/deploy-vercel-preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# name: Deploy Docs Preview
# on:
# workflow_dispatch: # Allows triggering the workflow manually in GitHub UI
# pull_request:
# # If another push to the same PR or branch happens while this workflow is still running,
# # cancel the earlier run in favor of the next run.
# #
# # There's no point in testing an outdated version of the code. GitHub only allows
# # a limited number of job runners to be active at the same time, so it's better to cancel
# # pointless jobs early so that more useful jobs can run sooner.
# concurrency:
# group: exports-${{ github.workflow }}-${{ github.ref }}
# cancel-in-progress: true
# jobs:
# deploy-docs-preview:
# name: Deploy Preview Docs to Vercel
# runs-on: ubuntu-latest
# environment: Staging
# env:
# VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
# VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
# VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
# PR_URL: ${{ github.event.pull_request.html_url }}
# GITHUB_TOKEN: ${{ secrets.PR_COMMENT_GITHUB_TOKEN }}
# steps:
# - uses: actions/checkout@v2
# - name: Install Vercel CLI
# run: npm install --global vercel@latest
# - name: Pull Vercel Environment Information
# run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }}
# - name: Build Project Artifacts
# run: vercel build --token=${{ secrets.VERCEL_TOKEN }}
# - name: Deploy Project Artifacts to Vercel
# run: vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }} > deployment-url.txt
# - name: Post Preview URL Comment
# run: gh pr comment $PR_URL -F deployment-url.txt
2 changes: 1 addition & 1 deletion docs/api_refs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"dev": "next dev -p 3001",
"typedoc:build": "npx typedoc --options typedoc.json",
"build:scripts": "node ./scripts/create-entrypoints.js && yarn typedoc:build && node ./scripts/update-typedoc-css.js",
"build:packages": "yarn turbo:command build --filter=@langchain/core --filter=@langchain/openai --filter=@langchain/textsplitters",
"build:packages": "yarn turbo:command build --filter=@langchain/core --filter=@langchain/openai --filter=@langchain/textsplitters --filter=langchain --filter=@langchain/anthropic",
"build": "yarn clean && yarn build:packages && yarn build:scripts && next build",
"start": "yarn build && next start -p 3001",
"lint": "next lint",
Expand Down
47 changes: 47 additions & 0 deletions docs/api_refs/scripts/build-deps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { spawn } from "node:child_process";

async function asyncSpawn(command: string, args: string[]): Promise<{ stdout: string; stderr: string }> {
return new Promise((resolve, reject) => {
let stdout = '';
let stderr = '';

const child = spawn(command, args, {
stdio: ['inherit', 'pipe', 'pipe'],
env: {
// eslint-disable-next-line no-process-env
...process.env,
NODE_OPTIONS: "--max-old-space-size=4096",
},
shell: true,
});

child.stdout.on('data', (data) => {
stdout += data.toString();
});

child.stderr.on('data', (data) => {
stderr += data.toString();
});

child.on("close", (code) => {
if (code !== 0) {
reject(new Error(`Command failed: ${command} ${args.join(" ")}\n${stderr}`));
return;
}
resolve({ stdout, stderr });
});
});
}

const splitStr = `"}
{"`
const joinStr = `"},{"`

async function buildDeps() {
const workspacesStr = (await asyncSpawn("yarn", ["workspaces", "list", "--json"])).stdout;
const workspacesAsJsonStr = `[${workspacesStr.split(splitStr).join(joinStr)}]`
const workspacesJson = JSON.parse(workspacesAsJsonStr);
const filteredWorkspaces = workspacesJson.filter((ws) => ws.name.startsWith("@langchain/") || ws.name === "langchain");
}

buildDeps();

0 comments on commit 80e48e2

Please sign in to comment.