Skip to content

Commit 884f762

Browse files
Merge branch 'appwrite:main' into main
2 parents 8d9685e + bffb784 commit 884f762

18 files changed

+255
-426
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,6 @@ jobs:
3838
labels: ${{ steps.meta.outputs.labels }}
3939
build-args: |
4040
_BUILD_WEBSITE_URL=https://appwrite.io
41-
_BUILD_WEBSITE_VERSION=1.6.x
41+
_BUILD_WEBSITE_VERSION=cloud
4242
_BUILD_GIT_URL=https://github.com/appwrite/website.git
4343
_BUILD_GIT_BRANCH=main

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,6 @@ jobs:
4242
labels: ${{ steps.meta.outputs.labels }}
4343
build-args: |
4444
_BUILD_WEBSITE_URL=https://appwrite.io
45-
_BUILD_WEBSITE_VERSION=1.6.x
45+
_BUILD_WEBSITE_VERSION=cloud
4646
_BUILD_GIT_URL=https://github.com/appwrite/website.git
4747
_BUILD_GIT_BRANCH=main

CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ If you are worried about or don’t know where to start, check out the next sect
1111
### 1. Clone the repository with git
1212

1313
```bash
14-
git clone https://github.com/appwrite/console.git appwrite-assistant
14+
git clone https://github.com/appwrite/assistant.git appwrite-assistant
1515
```
1616

1717
### 2. Install dependencies with pnpm
@@ -50,11 +50,11 @@ You can build the docker image and run it with docker compose:
5050
```bash
5151
docker compose build \
5252
--build-arg _BUILD_WEBSITE_URL=https://appwrite.io \
53-
--build-arg _BUILD_WEBSITE_VERSION=1.6.x \
53+
--build-arg _BUILD_WEBSITE_VERSION=cloud \
5454
--build-arg _BUILD_GIT_URL=https://github.com/appwrite/website.git \
5555
--build-arg _BUILD_GIT_BRANCH=main
5656

57-
docker compose up
57+
docker compose up -d
5858
```
5959

6060
### 6. Linting and Formatting

Dockerfile

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,16 @@ RUN apk add --no-cache \
1010
ENV PNPM_HOME="/pnpm"
1111
ENV PATH="$PNPM_HOME:$PATH"
1212
RUN corepack enable
13-
RUN corepack prepare pnpm@10.0.0 --activate
13+
RUN corepack prepare pnpm@10.13.1 --activate
1414

1515
FROM base AS builder
1616

17-
COPY package.json pnpm-lock.yaml /usr/src/app/
1817
WORKDIR /usr/src/app
1918

20-
RUN pnpm fetch --prod
19+
COPY package.json pnpm-lock.yaml ./
20+
RUN pnpm install --frozen-lockfile --prod
2121

22-
COPY . /usr/src/app
23-
24-
RUN pnpm install
22+
COPY . .
2523

2624
ARG _BUILD_GIT_URL
2725
ARG _BUILD_GIT_BRANCH
@@ -35,14 +33,21 @@ ENV _BUILD_WEBSITE_VERSION=${_BUILD_WEBSITE_VERSION}
3533

3634
RUN pnpm run fetch-sources
3735

38-
FROM base
36+
FROM node:18-alpine AS prod
37+
38+
ENV NODE_ENV=production
39+
ENV PNPM_HOME="/pnpm"
40+
ENV PATH="$PNPM_HOME:$PATH"
41+
42+
RUN corepack enable
43+
RUN corepack prepare [email protected] --activate
3944

4045
WORKDIR /usr/src/app
4146

42-
COPY --from=builder /usr/src/app/node_modules /usr/src/app/node_modules
43-
COPY --from=builder /usr/src/app/sources /usr/src/app/sources
44-
COPY --from=builder /usr/src/app/package.json /usr/src/app/
45-
COPY --from=builder /usr/src/app/src /usr/src/app/src
47+
COPY --from=builder /usr/src/app/node_modules ./node_modules
48+
COPY --from=builder /usr/src/app/sources ./sources
49+
COPY --from=builder /usr/src/app/package.json ./
50+
COPY --from=builder /usr/src/app/src ./src
4651

4752
ENV _APP_ASSISTANT_OPENAI_API_KEY=''
4853

package.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"dev": "nodemon src/main.js",
1010
"lint": "eslint src",
1111
"format": "prettier --write \"src/**/*.js\" \"scripts/**/*.js\"",
12-
"fetch-sources": "node scripts/git-sources.js && node scripts/web-sources.js"
12+
"fetch-sources": "node scripts/git-sources.js && node scripts/web-sources.js",
13+
"make-sources": "node scripts/web-sources.js"
1314
},
1415
"keywords": [],
1516
"author": "",
@@ -34,5 +35,10 @@
3435
"globals": "^15.14.0",
3536
"prettier": "^3.4.2"
3637
},
37-
"packageManager": "[email protected]"
38+
"pnpm": {
39+
"onlyBuiltDependencies": [
40+
"hnswlib-node"
41+
]
42+
},
43+
"packageManager": "[email protected]"
3844
}

scripts/git-sources.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,4 @@ await execa("git", ["config", "core.sparseCheckout", "true"], {
4040
});
4141

4242
await execa("git", ["checkout", GIT_BRANCH], { cwd: LOCAL_PATH });
43+
await execa("rm", ["-rf", `${LOCAL_PATH}/.git`]);

scripts/test-prompts.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const PROMPTS = [
88
"How do I use the users API to create a new user with Dart?",
99
"What endpoints are available for the Avatars API? I'm using the PHP SDK",
1010
"How to use Appwrite with React?",
11+
"How do I host a simple static website with Appwrite?",
1112
];
1213
const TESTS_FOLDER = "./tests";
1314

scripts/web-sources.js

Lines changed: 40 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,15 @@ const SDKS = [
4040
"server-graphql",
4141
"server-rest",
4242
];
43+
4344
const SERVICES = [
4445
"account",
4546
"avatars",
4647
"databases",
4748
"functions",
4849
"locale",
4950
"messaging",
51+
"sites",
5052
"storage",
5153
"teams",
5254
"users",
@@ -55,37 +57,48 @@ const SERVICES = [
5557
await execa("rm", ["-rf", LOCAL_PATH]);
5658
await mkdir(LOCAL_PATH, { recursive: true });
5759

58-
console.log("Downloading reference pages...");
60+
await Promise.all(
61+
SDKS.map((sdk) => {
62+
return mkdir(`${LOCAL_PATH}/${sdk}/`, { recursive: true });
63+
}),
64+
);
5965

60-
for (const sdk of SDKS) {
61-
await mkdir(`./sources/references/${sdk}/`, { recursive: true });
66+
console.log("Downloading reference pages...");
6267

63-
for (const service of SERVICES) {
64-
const url = new URL(
65-
`/docs/references/${WEBSITE_VERSION}/${sdk}/${service}`,
66-
WEBSITE_URL,
67-
);
68+
const start = Date.now();
6869

69-
const response = await fetch(url.toString());
70+
await Promise.all(
71+
SDKS.flatMap((sdk) =>
72+
SERVICES.map(async (service) => {
73+
const url = new URL(
74+
`/docs/references/${WEBSITE_VERSION}/${sdk}/${service}`,
75+
WEBSITE_URL,
76+
);
7077

71-
const html = await response.text();
72-
if (!html) {
73-
console.warn(`Skipping page ${url} - no content found`);
74-
continue;
75-
}
78+
try {
79+
const response = await fetch(url.toString());
80+
const html = await response.text();
81+
if (!html) {
82+
console.warn(`Skipping page ${url} - no content found`);
83+
return;
84+
}
7685

77-
// Ignore the header and footer
78-
const matches = html.match(
79-
/<main class="contents" id="main">(.*?)<\/main>/s,
80-
);
81-
if (!matches || !matches[0]) {
82-
console.warn(`Skipping page ${url} - no <main> tag found`);
83-
continue;
84-
}
86+
const matches = html.match(
87+
/<main class="contents" id="main">(.*?)<\/main>/s,
88+
);
89+
if (!matches || !matches[0]) {
90+
console.warn(`Skipping page ${url} - no <main> tag found`);
91+
return;
92+
}
8593

86-
const markdown = NodeHtmlMarkdown.translate(matches[0]);
94+
const markdown = NodeHtmlMarkdown.translate(matches[0]);
95+
await writeFile(`${LOCAL_PATH}/${sdk}/${service}.md`, markdown);
96+
console.log(`Created ./sources/references/${sdk}/${service}.md`);
97+
} catch (e) {
98+
console.warn(`Failed to download ${url}:`, e);
99+
}
100+
}),
101+
),
102+
);
87103

88-
await writeFile(`./sources/references/${sdk}/${service}.md`, markdown);
89-
console.log(`Created ./sources/references/${sdk}/${service}.md`);
90-
}
91-
}
104+
console.log("References created in", (Date.now() - start) / 1000, "seconds");

src/documents.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ const getDocumentation = async () => {
4444
*/
4545
const getReferences = async () => {
4646
const filenames = await glob(["./sources/references/**/*.md"]);
47+
const version = process.env._BUILD_WEBSITE_VERSION ?? "cloud";
4748

4849
return Promise.all(
4950
filenames.map(async (filename) => {
@@ -52,7 +53,7 @@ const getReferences = async () => {
5253
const { sdk, service } = parseReferenceData(filename);
5354
const metadata = {
5455
filename,
55-
url: `https://appwrite.io/docs/references/cloud/${sdk}/${service}`,
56+
url: `https://appwrite.io/docs/references/${version}/${sdk}/${service}`,
5657
};
5758

5859
return new Document({
@@ -64,8 +65,10 @@ const getReferences = async () => {
6465
};
6566

6667
export const getDocuments = async () => {
67-
const documentation = await getDocumentation();
68-
const references = await getReferences();
68+
const [documentation, references] = await Promise.all([
69+
getDocumentation(),
70+
getReferences(),
71+
]);
6972

7073
return await splitDocuments([...documentation, ...references]);
7174
};

src/embeddings.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { getDocuments } from "./documents.js";
77
/**
88
* @returns {Promise<VectorStoreRetriever<HNSWLib>>}
99
*/
10-
export const intializeDocumentRetriever = async () => {
10+
export const initializeDocumentRetriever = async () => {
1111
const embeddings = new OpenAIEmbeddings({
1212
openAIApiKey: process.env._APP_ASSISTANT_OPENAI_API_KEY,
1313
});

0 commit comments

Comments
 (0)