-
Notifications
You must be signed in to change notification settings - Fork 485
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'beta' of https://github.com/e2b-dev/E2B into beta
- Loading branch information
Showing
73 changed files
with
15,311 additions
and
10,133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
# This script checks for diffs in the packages directory. | ||
# If there are diffs, it means we need to generate a new API references. | ||
if git diff --name-only HEAD^ | grep -q '^packages/'; then | ||
echo "true" | ||
else | ||
echo "false" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
name: Generate SDK API references | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- main | ||
- beta | ||
|
||
concurrency: ${{ github.workflow }}-${{ github.ref }} | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
is_new_api_ref: | ||
name: Is new API reference? | ||
runs-on: ubuntu-latest | ||
outputs: | ||
new_api_ref: ${{ steps.sdk-changes.outputs.new_api_ref }} | ||
steps: | ||
- name: Checkout Repo | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 2 | ||
|
||
- name: Check if SDK changes | ||
id: sdk-changes | ||
run: | | ||
IS_NEW_API_REF=$(./.github/scripts/is_new_api_ref.sh) | ||
echo "new_api_ref=$IS_NEW_API_REF" >> "$GITHUB_OUTPUT" | ||
sdk-changes: | ||
name: SDK changes | ||
needs: [is_new_api_ref] | ||
if: always() | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Install pnpm | ||
uses: pnpm/action-setup@v3 | ||
id: pnpm-install | ||
with: | ||
version: 9.5 | ||
|
||
- name: Setup Node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: "20.x" | ||
registry-url: "https://registry.npmjs.org" | ||
cache: pnpm | ||
cache-dependency-path: pnpm-lock.yaml | ||
|
||
- name: Configure pnpm | ||
run: | | ||
pnpm config set auto-install-peers true | ||
pnpm config set exclude-links-from-lockfile true | ||
- name: Install dependencies | ||
run: pnpm install --frozen-lockfile | ||
|
||
- name: Set up Python | ||
id: setup-python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.8" | ||
|
||
- name: Install and configure Poetry | ||
uses: snok/install-poetry@v1 | ||
with: | ||
version: 1.5.1 | ||
virtualenvs-create: true | ||
virtualenvs-in-project: true | ||
installer-parallel: true | ||
|
||
- name: Install dependencies | ||
working-directory: ./packages/python-sdk | ||
run: poetry install --no-interaction --no-root | ||
|
||
- name: Generate Python SDK API reference | ||
id: python-sdk-api-ref | ||
working-directory: ./packages/python-sdk | ||
run: | | ||
source .venv/bin/activate | ||
./scripts/generate_api_ref.sh | ||
- name: Generate JS SDK API reference | ||
id: js-sdk-api-ref | ||
working-directory: packages/js-sdk | ||
run: ./scripts/generate_api_ref.sh | ||
|
||
- name: Generate CLI API reference | ||
id: cli-api-ref | ||
working-directory: packages/cli | ||
run: ./scripts/generate_api_ref.sh | ||
|
||
- name: Show docs file structure | ||
run: tree apps/web/src/app/\(docs\)/docs/api-reference | ||
|
||
- name: Commit new SDK API reference versions | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
git config user.name "github-actions[bot]" | ||
git config user.email "github-actions[bot]@users.noreply.github.com" | ||
git add apps/web/src/app/\(docs\)/docs/api-reference | ||
git commit -m "[skip ci] Release new SDK API reference doc versions" || exit 0 | ||
git push |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
const fs = require('fs') | ||
const path = require('path') | ||
|
||
const ApiRefRoutesFilePath = './src/components/Navigation/apiRefRoutes.json' | ||
|
||
// Current directory hierarchy: | ||
// | ||
// { | ||
// 'sdk-name': { | ||
// 'version': { | ||
// 'module': null | ||
// } | ||
// } | ||
// } | ||
let hierarchy = {} | ||
|
||
function buildDirectoryHierarchy(dirPath) { | ||
const result = {} | ||
const entries = fs.readdirSync(dirPath, { withFileTypes: true }) | ||
|
||
entries.forEach((entry) => { | ||
if (entry.isDirectory()) { | ||
result[entry.name] = buildDirectoryHierarchy( | ||
path.join(dirPath, entry.name) | ||
) | ||
} | ||
}) | ||
|
||
return Object.keys(result).length === 0 ? null : result | ||
} | ||
|
||
const filesCreated = new Set() | ||
|
||
function buildRoutes(dirName, dir, basePath = '', depth = 1) { | ||
const entries = fs.readdirSync(dir, { withFileTypes: true }) | ||
const parentDirName = path.basename(path.dirname(dir)) | ||
|
||
return entries | ||
.map((entry) => { | ||
const relativePath = path.join(basePath, entry.name) | ||
|
||
if (entry.isDirectory()) { | ||
let route = { | ||
title: depth === 1 ? entry.name.toLocaleUpperCase() : entry.name, | ||
} | ||
const entryName = entry.name | ||
const childPath = path.join(dir, entry.name) | ||
const links = buildRoutes(entryName, childPath, relativePath, depth + 1) | ||
|
||
if (links.length > 0) { | ||
route.href = '/docs/api-reference/' + relativePath | ||
// SDK level | ||
if (depth === 2) { | ||
const mdxFilePath = path.join(dir, 'page.mdx') | ||
if (filesCreated.has(mdxFilePath)) return route | ||
|
||
// Generate SDK version TOC markdown file | ||
let mdxContent = `# ${dirName}\n\n## ${entryName}\n\n${links | ||
.map( | ||
(link) => | ||
`- [${ | ||
link.title.charAt(0).toUpperCase() + | ||
link.title.slice(1).toLowerCase() | ||
}](./${dirName}/${entryName}/${link.title})` | ||
) | ||
.join('\n')}` | ||
|
||
if ( | ||
hierarchy[dirName] && | ||
Object.keys(hierarchy[dirName]).length > 1 | ||
) { | ||
const versions = Object.keys(hierarchy[dirName]) | ||
const versionLinks = `${versions | ||
.map( | ||
(version) => | ||
`<a href="/docs/api-reference/${dirName}/${version}" class="version-link">[${version}]</a>` | ||
) | ||
.join('\n ')}` | ||
|
||
mdxContent = `${versionLinks}\n\n\n${mdxContent}` | ||
} | ||
|
||
console.log('Generated TOC file:', mdxFilePath) | ||
fs.writeFileSync(mdxFilePath, mdxContent) | ||
filesCreated.add(mdxFilePath) | ||
} | ||
} | ||
|
||
// Version level | ||
if (depth === 3) { | ||
const mdxFilePath = path.join(dir, 'page.mdx') | ||
if (filesCreated.has(mdxFilePath)) return route | ||
|
||
// Generate modules TOC markdown file | ||
const modules = Object.keys(hierarchy[parentDirName][dirName]) | ||
let mdxContent = `# ${parentDirName.toLocaleUpperCase()} ${dirName}\n\n${modules | ||
.map( | ||
(module) => | ||
`- [${ | ||
module.charAt(0).toUpperCase() + module.slice(1).toLowerCase() | ||
}](./${dirName}/${module})` | ||
) | ||
.join('\n')}` | ||
|
||
console.log('Generated TOC file:', mdxFilePath) | ||
fs.writeFileSync(mdxFilePath, mdxContent) | ||
filesCreated.add(mdxFilePath) | ||
} | ||
|
||
return route | ||
} | ||
}) | ||
.filter(Boolean) | ||
} | ||
|
||
function generateApiRefRoutes() { | ||
const apiRefPath = path.join(__dirname, './src/app/(docs)/docs/api-reference') | ||
|
||
if (!fs.existsSync(apiRefPath)) { | ||
return [] | ||
} | ||
|
||
hierarchy = buildDirectoryHierarchy(apiRefPath) | ||
|
||
const routes = buildRoutes('api-reference', apiRefPath) | ||
return routes | ||
} | ||
|
||
const apiRefRoutes = [ | ||
{ | ||
title: 'References', | ||
links: generateApiRefRoutes(), | ||
}, | ||
] | ||
|
||
fs.writeFileSync( | ||
path.join(__dirname, ApiRefRoutesFilePath), | ||
JSON.stringify(apiRefRoutes, null, 2) | ||
) | ||
|
||
console.log( | ||
'\n\nAPI reference TOCs and routes file generated successfully:\n\n' | ||
) | ||
console.log('routes', JSON.stringify(apiRefRoutes, null, 2), '\n\n') |
58 changes: 58 additions & 0 deletions
58
apps/web/src/app/(docs)/docs/api-reference/cli/v0.5.10/auth/page.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# e2b auth | ||
|
||
|
||
authentication commands | ||
|
||
## Usage | ||
|
||
```bash | ||
e2b auth [options] [command] | ||
``` | ||
# e2b auth login | ||
|
||
|
||
log in to CLI | ||
|
||
## Usage | ||
|
||
```bash | ||
e2b auth login [options] | ||
``` | ||
|
||
|
||
# e2b auth logout | ||
|
||
|
||
log out of CLI | ||
|
||
## Usage | ||
|
||
```bash | ||
e2b auth logout [options] | ||
``` | ||
|
||
|
||
# e2b auth info | ||
|
||
|
||
get information about the current user | ||
|
||
## Usage | ||
|
||
```bash | ||
e2b auth info [options] | ||
``` | ||
|
||
|
||
# e2b auth configure | ||
|
||
|
||
configure user | ||
|
||
## Usage | ||
|
||
```bash | ||
e2b auth configure [options] | ||
``` | ||
|
||
|
Oops, something went wrong.