Skip to content

chore: fix test #2669

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

Open
wants to merge 21 commits into
base: app
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
582ce6f
fix(deps): dependabot versions - undici, @babel (also fixes broken ch…
dubwub Apr 24, 2025
65ee9d7
chore: CDK setup (#2639)
chdeskur Apr 26, 2025
8402819
chore: reduce bundle size (#2649)
chdeskur Apr 26, 2025
3e273cf
chore: try removing esbuild from build (#2651)
chdeskur Apr 26, 2025
2512b85
chore: reinstall esbuild (#2652)
chdeskur Apr 26, 2025
cd4276b
chore: include the build script in the bundle (#2653)
chdeskur Apr 26, 2025
a434834
chore: remove custom js from local development mode (#2654)
chdeskur Apr 27, 2025
71d6492
chore: centralize openrpc wrapped requests (#2650)
dsinghvi Apr 28, 2025
30b246f
fix: pass in endpoint.protocol whenever calling serializeFormStateBody
dsinghvi Apr 28, 2025
94c3481
chore: use env for websocket port (#2656)
chdeskur Apr 28, 2025
a1a42b9
chore(docs): update Contributing.md to have correct file path (#2657)
sbawabe Apr 28, 2025
8404da1
chore(deps-dev): bump axios from 1.8.1 to 1.8.2 (#2661)
dependabot[bot] Apr 28, 2025
0608139
fix: prepend https:// if not there to urls in AI chat footnotes (#2662)
dubwub Apr 28, 2025
061c626
chore: always close the nav on tab change (#2660)
chdeskur Apr 28, 2025
a9ce64d
chore(deps): bump axios from 1.8.1 to 1.9.0 (#2663)
dependabot[bot] Apr 28, 2025
0b57be1
fix: openrpc requests always send application/json header (#2664)
dsinghvi Apr 28, 2025
0881554
chore: add fixture/snapshot tests for turbopuffer indexing (#2659)
dubwub Apr 28, 2025
a8b2125
(chore): always respect frontmatter title (#2666)
chdeskur Apr 29, 2025
4b56c24
(chore): preserve api sections (#2667)
chdeskur Apr 29, 2025
ea30ac7
(fix): use origin for authed preview urls (#2668)
chdeskur Apr 29, 2025
c08e907
chore: fix test
dsinghvi Apr 29, 2025
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
70 changes: 70 additions & 0 deletions .github/workflows/deploy-local-preview-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Deploy Local Preview (DEV)

on:
push:
branches:
- app
release:
types: [created]
tags:
- "docs@*"

env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: "buildwithfern"
FERN_TOKEN: ${{ secrets.FERN_TOKEN }}
GITHUB_TOKEN: ${{ secrets.FERN_GITHUB_TOKEN }}

jobs:
dev:
if: github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: us-east-1
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- name: Install
uses: ./.github/actions/install
- name: Compile
run: pnpm compile
- name: Build local preview bundle
run: pnpm --filter=@fern-docs/bundle run docs:build:local
- name: Copy static and public files
working-directory: packages/fern-docs/bundle
run: cp -r .next/static .next/standalone/packages/fern-docs/bundle/.next && cp -r public .next/standalone/packages/fern-docs/bundle
- name: Remove unnecessary files
working-directory: packages/fern-docs/bundle
run: find .next -depth -mindepth 1 -not -path ".next/standalone*" -exec rm -rf {} \;
- name: Remove esbuild dependency
working-directory: packages/fern-docs/bundle
run: rm -rf .next/standalone/node_modules/.pnpm/[email protected] && rm -rf .next/standalone/node_modules/.pnpm/@[email protected]
- name: Synthesize local preview bundle
run: pnpm --filter=@fern-platform/cdk run deploy-app:dev2

prod:
if: github.event_name == 'release' && startsWith(github.event.release.tag_name, 'docs@')
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: us-east-1
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- name: Install
uses: ./.github/actions/install
- name: Compile
run: pnpm compile
- name: Build local preview bundle
run: pnpm --filter=@fern-docs/bundle run docs:build:local
- name: Copy static and public files
working-directory: packages/fern-docs/bundle
run: cp -r .next/static .next/standalone/packages/fern-docs/bundle/.next && cp -r public .next/standalone/packages/fern-docs/bundle
- name: Remove unnecessary files
working-directory: packages/fern-docs/bundle
run: find .next -depth -mindepth 1 -not -path ".next/standalone*" -exec rm -rf {} \;
- name: Synthesize local preview bundle
run: pnpm --filter=@fern-platform/cdk run deploy-app:prod
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ From the fern-platform repository, link vercel to the Fern project:

Then, run `vercel pull`, which will create `/fern-platform/.vercel/.env.development.local`
Then, copy that file (creating if necessary) to `/fern-platform/packages/fern-docs/bundle/.env.local`
Finally, to run the dev server, `cd /packages/fern-docs/bundle` and run `pnpm docs:dev`, which should begin running on `localhost:3000`
Finally, to run the dev server, `cd packages/fern-docs/bundle` and run `pnpm docs:dev`, which should begin running on `localhost:3000`

To set a dev docs domain, add a `NEXT_PUBLIC_DOCS_DOMAIN` to `.env.local`. For instance:

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@
"vercel:up": "pnpm up -r \"@vercel/*\""
},
"resolutions": {
"@babel/core": "7.26.9",
"clipboardy": "4.0.0",
"colorjs.io": "^0.5.2",
"cookie": "0.7.0",
"cross-spawn": "7.0.5",
"elliptic": "6.6.1",
"esbuild": "0.25.0",
"jsonpath-plus": "10.3.0",
"katex": "0.16.21",
"markdown-to-jsx": "7.4.0",
"micromatch": "4.0.8",
"react": "19.0.0",
Expand Down
1 change: 1 addition & 0 deletions packages/cdk/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*.js
!install-esbuild.js
*.d.ts
node_modules

Expand Down
3 changes: 3 additions & 0 deletions packages/cdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@
],
"scripts": {
"cdk": "cdk",
"deploy-app:dev2": "cdk deploy local-preview-bundle3-dev2 --require-approval never --progress events",
"deploy-app:prod": "cdk deploy local-preview-bundle3-prod --require-approval never --progress events",
"deploy:dev2": "cdk deploy local-preview-bundle2-dev2 --require-approval never --progress events",
"deploy:prod": "cdk deploy local-preview-bundle2-prod --require-approval never --progress events",
"synth-app:dev2": "cdk synth local-preview-bundle3-dev2",
"synth:dev2": "cdk synth local-preview-bundle2-dev2"
},
"dependencies": {
Expand Down
7 changes: 4 additions & 3 deletions packages/cdk/src/cdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async function main() {
case EnvironmentType.Prod:
new DocsFeStack(
app,
`local-preview-bundle2-${environmentType.toLowerCase()}`,
`local-preview-bundle3-${environmentType.toLowerCase()}`,
environmentType,
{
env: { account: "985111089818", region: "us-east-1" },
Expand All @@ -43,9 +43,10 @@ async function getEnvironments(): Promise<Environments> {
{
method: "GET",
headers: {
Authorization: "Bearer " + process.env["GITHUB_TOKEN"],
/* eslint-disable turbo/no-undeclared-env-vars */
Authorization: "Bearer " + process.env.GITHUB_TOKEN,
},
}
);
return (await response.json()) as any as Environments;
return (await response.json()) as Environments;
}
44 changes: 29 additions & 15 deletions packages/cdk/src/docs-fe-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { EnvironmentType } from "@fern-fern/fern-cloud-sdk/api";

const LOCAL_PREVIEW_BUNDLE_OUT_DIR = path.resolve(
__dirname,
"../../fern-docs/local-preview-bundle/out"
"../../fern-docs/bundle/.next"
);

export class DocsFeStack extends Stack {
Expand All @@ -22,8 +22,8 @@ export class DocsFeStack extends Stack {
props?: StackProps
) {
super(scope, id, props);
const bucket = new Bucket(this, "local-preview-bundle2", {
bucketName: `${environmentType.toLowerCase()}-local-preview-bundle2`,
const bucket = new Bucket(this, "local-preview-bundle3", {
bucketName: `${environmentType.toLowerCase()}-local-preview-bundle3`,
removalPolicy: RemovalPolicy.RETAIN,
cors: [
{
Expand Down Expand Up @@ -51,7 +51,7 @@ export class DocsFeStack extends Stack {

const local_preview_bundle_dist_zip = path.resolve(
__dirname,
"../../fern-docs/local-preview-bundle/dist/out.zip"
"../../fern-docs/bundle/next.zip"
);
if (
!fs.existsSync(LOCAL_PREVIEW_BUNDLE_OUT_DIR) ||
Expand All @@ -62,17 +62,31 @@ export class DocsFeStack extends Stack {
);
}

void zipFolder(
LOCAL_PREVIEW_BUNDLE_OUT_DIR,
local_preview_bundle_dist_zip
).then(() => {
new BucketDeployment(this, "deploy-local-preview-bundle2", {
sources: [Source.asset(local_preview_bundle_dist_zip)],
destinationBucket: bucket,
extract: false,
memoryLimit: 1024,
// Copy install-esbuild.js into the .next folder
fs.promises
.copyFile(
path.resolve(__dirname, "../utilities/install-esbuild.js"),
path.join(LOCAL_PREVIEW_BUNDLE_OUT_DIR, "install-esbuild.js")
)
.then(() => {
return zipFolder(
LOCAL_PREVIEW_BUNDLE_OUT_DIR,
local_preview_bundle_dist_zip
);
})
.then(() => {
new BucketDeployment(this, "deploy-local-preview-bundle3", {
sources: [Source.asset(local_preview_bundle_dist_zip)],
destinationBucket: bucket,
extract: false,
memoryLimit: 1024,
});
})
.catch((error: unknown) => {
throw new Error(
`Failed to prepare and deploy bundle: ${error instanceof Error ? error.message : String(error)}`
);
});
});
}
}

Expand All @@ -90,7 +104,7 @@ async function zipFolder(sourceFolder: string, zipFilePath: string) {
const archive = archiver("zip");

archive.on("error", (err: unknown) => {
reject(err);
reject(err instanceof Error ? err : new Error(String(err)));
});

output.on("close", function () {
Expand Down
7 changes: 6 additions & 1 deletion packages/cdk/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
{
"extends": "@fern-platform/configs/tsconfig/cli.json",
"compilerOptions": { "outDir": "./dist", "rootDir": "./src" },
"compilerOptions": {
"outDir": "./dist",
"rootDir": "./src",
"module": "NodeNext",
"moduleResolution": "NodeNext"
},
"include": ["./src/**/*"],
"exclude": ["cdk.out"]
}
97 changes: 97 additions & 0 deletions packages/cdk/utilities/install-esbuild.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
const fs = require("fs").promises;
const path = require("path");
const os = require("os");
const { exec } = require("child_process");
const util = require("util");
const execAsync = util.promisify(exec);

const SKIP_DIRS = ["node_modules", ".git", "dist", "build"];

async function processFiles(dir, platform, arch) {
const entries = await fs.readdir(dir, { withFileTypes: true });

for (const entry of entries) {
const fullPath = path.join(dir, entry.name);

if (entry.isDirectory() && !SKIP_DIRS.includes(entry.name)) {
await processFiles(fullPath, platform, arch);
} else if (entry.isFile() && entry.name.endsWith(".json")) {
let content = await fs.readFile(fullPath, "utf8");

if (content.includes("linux-x64")) {
const replacement = `${platform}-${arch}`;
content = content.replace(/linux-x64/g, replacement);
await fs.writeFile(fullPath, content, "utf8");
}
}
}
}

const targetDir = path.join(__dirname, "./standalone");

function checkOS() {
const platform = os.platform();
const arch = os.arch();
return { platform, arch };
}

async function copyModules(destPath) {
const isWindows = os.platform() === "win32";

try {
if (isWindows) {
await execAsync(
`copy node_modules/.pnpm/[email protected] ${destPath}\\ && copy node_modules/.pnpm/@esbuild+* ${destPath}\\`
);
} else {
await execAsync(
`cp -r node_modules/.pnpm/[email protected] node_modules/.pnpm/@esbuild+* ${destPath}/`
);
}
} catch (error) {
console.error("Error copying modules:", error.message);
throw error;
}
}

async function checkImport() {
try {
const pnpmDir = path.resolve("node_modules/.pnpm");
const entries = await fs.readdir(pnpmDir);

const esbuildPackage = entries.find((entry) =>
entry.startsWith("@esbuild+")
);
if (!esbuildPackage) return null;

const match = esbuildPackage.match(/@esbuild\+(.+)@0\.25\.0/);
return match ? match[1] : null;
} catch (error) {
console.error("Error checking imports:", error.message);
return null;
}
}

async function main() {
try {
const { platform, arch } = checkOS();
console.log(
`Replacing 'linux-x64' with '${platform}-${arch}' in .json files in ${targetDir}`
);
await processFiles(targetDir, platform, arch);

const importName = await checkImport();
if (importName) {
console.log(`Found esbuild import: ${importName}`);

const destPath = path.resolve("./standalone/node_modules/.pnpm");
await copyModules(destPath);
console.log(`Modules copied to ${destPath}`);
}
} catch (error) {
console.error("Error in main process:", error.message);
process.exit(1);
}
}

void main();
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { cloneRepository } from "../cloneRepository";
describe("cloneRepository", () => {
it("fern-api/docs-starter-openapi", async () => {
const repository = await cloneRepository({
githubRepository: "github.com/fern-api/docs-starter-openapi",
githubRepository: "github.com/fern-api/docs-starter",
installationToken: undefined,
});
const readme = await repository.getReadme();
Expand Down
Loading
Loading