Skip to content

Commit

Permalink
Rename edgedb to gel
Browse files Browse the repository at this point in the history
  • Loading branch information
diksipav committed Jan 14, 2025
1 parent 08fd2b0 commit 9b72ac8
Show file tree
Hide file tree
Showing 50 changed files with 170 additions and 175 deletions.
18 changes: 9 additions & 9 deletions packages/create/README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
# `@edgedb/create`: Project scaffolding for EdgeDB-backed applications
# `@gel/create`: Project scaffolding for Gel-backed applications

The `@edgedb/create` package provides a starting point for various frameworks with everything you need to start building an EdgeDB-backed application. We aim to follow the same conventions as the original "create-app" templates, but with EdgeDB as the database. There are a few different templates to choose from, including: Next.js, Remix, Express, Node HTTP Server.
The `@gel/create` package provides a starting point for various frameworks with everything you need to start building an Gel-backed application. We aim to follow the same conventions as the original "create-app" templates, but with Gel as the database. There are a few different templates to choose from, including: Next.js, Remix, Express, Node HTTP Server.

Important points to note:

- **Upstream changes:** We try to actively monitor and incorporate significant changes from the original "create-app" templates to to ensure developers have access to the latest features and best practices.
- **Support for major options:** While we strive to support the major options offered by the upstream "create-apps", we might not cover every possible configuration or permutation due to the vast scope of possibilities.
- **EdgeDB CLI installation:** For users who do not have the EdgeDB CLI installed, we automatically install it using our typical installation procedure.
- **Gel CLI installation:** For users who do not have the Gel CLI installed, we automatically install it using our typical installation procedure.

## Usage

```bash
$ npm create @edgedb
$ npm create @gel
# or
yarn create @edgedb
yarn create @gel
# or
pnpm create @edgedb
pnpm create @gel
# or
bun create @edgedb
bun create @gel
```

After running the command, you will be prompted to provide a project name and choose a template. You can also specify whether to use EdgeDB Auth, initialize a git repository, and install dependencies.
After running the command, you will be prompted to provide a project name and choose a template. You can also specify whether to use Gel Auth, initialize a git repository, and install dependencies.

The tool will then create a new directory with the specified name and set up the project.

Expand All @@ -42,7 +42,7 @@ Navigate into `packages/create`:
$ cd packages/create
```

Build `@edgedb/generate`
Build `@gel/generate`

```bash
$ yarn build
Expand Down
11 changes: 6 additions & 5 deletions packages/create/package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
{
"name": "@edgedb/create",
"name": "@gel/create",
"version": "0.2.2",
"type": "module",
"description": "Create a new EdgeDB-based project",
"homepage": "https://edgedb.com/docs",
"author": "EdgeDB <info@edgedb.com>",
"description": "Create a new Gel-based project",
"homepage": "https://gel.com/docs",
"author": "Gel <info@gel.com>",
"engines": {
"node": ">= 18.0.0"
},
"repository": {
"type": "git",
"url": "https://github.com/edgedb/edgedb-js.git"
"url": "https://github.com/gel/gel-js.git",
"directory": "packages/create"
},
"license": "Apache-2.0",
"sideEffects": false,
Expand Down
6 changes: 3 additions & 3 deletions packages/create/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import pc from "picocolors";
import { baseRecipe, recipes as _recipes } from "./recipes/index.js";

async function main() {
p.intro("Welcome to the EdgeDB Create CLI 🚀");
p.intro("Welcome to the Gel Create CLI 🚀");

const baseOptions = await baseRecipe.getOptions();
const recipeOptions: any[] = [];
Expand All @@ -25,14 +25,14 @@ async function main() {
}

p.outro(`\
Your EdgeDB project has been initialized! 🚀
Your Gel project has been initialized! 🚀
Enter your project directory using: ${pc.green(
`cd ${baseOptions.projectName}`,
)}
Follow the instructions in the ${pc.green("README.md")} file to get started.
Need help? Join our community at ${pc.green("https://edgedb.com/community")}`);
Need help? Join our community at ${pc.green("https://gel.com/community")}`);
}

await main();
6 changes: 3 additions & 3 deletions packages/create/src/recipes/_base/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { updatePackage } from "write-package";
import { getPackageManager, copyTemplateFiles } from "../../utils.js";
import type { Framework, BaseRecipe, BaseOptions } from "../types.js";

const logger = debug("@edgedb/create:recipe:base");
const logger = debug("@gel/create:recipe:base");

const recipe: BaseRecipe = {
async getOptions() {
Expand All @@ -34,9 +34,9 @@ const recipe: BaseRecipe = {
{ value: "none", label: "None" },
],
}),
useEdgeDBAuth: () =>
useGelAuth: () =>
p.confirm({
message: "Use the EdgeDB Auth extension?",
message: "Use the Gel Auth extension?",
initialValue: true,
}),
},
Expand Down
4 changes: 2 additions & 2 deletions packages/create/src/recipes/_base/template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"edgedb": "1.x"
"gel": "1.x"
},
"devDependencies": {
"@edgedb/generate": "0.x",
"@gel/generate": "0.x",
"@typescript-eslint/eslint-plugin": "6.x",
"@typescript-eslint/parser": "6.x",
"@eslint/eslintrc": "2.x",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,126 +6,126 @@ import debug from "debug";
import type { BaseOptions, Recipe } from "../types.js";
import { copyTemplateFiles, execInLoginShell } from "../../utils.js";

const logger = debug("@edgedb/create:recipe:edgedb");
const logger = debug("@gel/create:recipe:gel");

interface EdgeDBOptions {
interface GelOptions {
initializeProject: boolean;
}

const recipe: Recipe<EdgeDBOptions> = {
const recipe: Recipe<GelOptions> = {
getOptions() {
return p.group({
initializeProject: () =>
p.confirm({
message: "Initialize a new EdgeDB project with edgedb project init?",
message: "Initialize a new Gel project with gel project init?",
initialValue: true,
}),
});
},

async apply(
{ projectDir, useEdgeDBAuth }: BaseOptions,
{ initializeProject }: EdgeDBOptions,
{ projectDir, useGelAuth }: BaseOptions,
{ initializeProject }: GelOptions,
) {
logger("Running edgedb recipe");
logger("Checking for existing EdgeDB CLI");
logger("Running gel recipe");
logger("Checking for existing Gel CLI");

const spinner = p.spinner();

if (initializeProject) {
let edgedbCliVersion: string | null = null;
let gelCliVersion: string | null = null;
let shouldInstallCli: boolean | symbol = true;
try {
const { stdout } = await execInLoginShell("edgedb --version");
edgedbCliVersion = stdout.trim();
logger(edgedbCliVersion);
const { stdout } = await execInLoginShell("gel --version");
gelCliVersion = stdout.trim();
logger(gelCliVersion);
} catch (_error) {
logger("No EdgeDB CLI detected");
logger("No Gel CLI detected");
shouldInstallCli = await p.confirm({
message:
"The EdgeDB CLI is required to initialize a project. Install now?",
"The Gel CLI is required to initialize a project. Install now?",
initialValue: true,
});
}

if (edgedbCliVersion === null) {
if (gelCliVersion === null) {
if (shouldInstallCli === false) {
logger("User declined to install EdgeDB CLI");
throw new Error("EdgeDB CLI is required");
logger("User declined to install Gel CLI");
throw new Error("Gel CLI is required");
}

logger("Installing EdgeDB CLI");
logger("Installing Gel CLI");

spinner.start("Installing EdgeDB CLI");
spinner.start("Installing Gel CLI");
const { stdout, stderr } = await execInLoginShell(
"curl --proto '=https' --tlsv1.2 -sSf https://sh.edgedb.com | sh -s -- -y",
"curl --proto '=https' --tlsv1.2 -sSf https://sh.gel.com | sh -s -- -y",
);
logger({ stdout, stderr });
spinner.stop("EdgeDB CLI installed");
spinner.stop("Gel CLI installed");
}

try {
const { stdout } = await execInLoginShell("edgedb --version");
edgedbCliVersion = stdout.trim();
logger(edgedbCliVersion);
const { stdout } = await execInLoginShell("gel --version");
gelCliVersion = stdout.trim();
logger(gelCliVersion);
} catch (error) {
logger("EdgeDB CLI could not be installed.");
logger("Gel CLI could not be installed.");
logger(error);
throw new Error("EdgeDB CLI could not be installed.");
throw new Error("Gel CLI could not be installed.");
}

spinner.start("Initializing EdgeDB project");
spinner.start("Initializing Gel project");
try {
await execInLoginShell("edgedb project init --non-interactive", {
await execInLoginShell("gel project init --non-interactive", {
cwd: projectDir,
});
const { stdout, stderr } = await execInLoginShell(
"edgedb query 'select sys::get_version_as_str()'",
"gel query 'select sys::get_version_as_str()'",
{ cwd: projectDir },
);
const serverVersion = JSON.parse(stdout.trim());
logger(`EdgeDB server version: ${serverVersion}`);
logger(`Gel server version: ${serverVersion}`);
if (serverVersion === "") {
const err = new Error(
"There was a problem initializing the EdgeDB project",
"There was a problem initializing the Gel project",
);
spinner.stop(err.message);
logger({ stdout, stderr });

throw err;
}
spinner.stop(`EdgeDB v${serverVersion} project initialized`);
spinner.stop(`Gel v${serverVersion} project initialized`);
} catch (error) {
logger(error);
throw error;
} finally {
spinner.stop();
}
} else {
logger("Skipping edgedb project init");
logger("Copying basic EdgeDB project files");
logger("Skipping gel project init");
logger("Copying basic Gel project files");

const dirname = path.dirname(new URL(import.meta.url).pathname);
await copyTemplateFiles(path.resolve(dirname, "./template"), projectDir);
}

if (useEdgeDBAuth) {
if (useGelAuth) {
logger("Adding auth extension to project");

spinner.start("Enabling auth extension in EdgeDB schema");
spinner.start("Enabling auth extension in Gel schema");
const filePath = path.resolve(projectDir, "./dbschema/default.esdl");
const data = await fs.readFile(filePath, "utf8");
await fs.writeFile(filePath, `using extension auth;\n\n${data}`);
spinner.stop("Auth extension enabled in EdgeDB schema");
spinner.stop("Auth extension enabled in Gel schema");

if (initializeProject) {
logger("Creating and applying initial migration");
spinner.start("Creating and applying initial migration");
try {
await execInLoginShell("edgedb migration create", {
await execInLoginShell("gel migration create", {
cwd: projectDir,
});
await execInLoginShell("edgedb migrate", { cwd: projectDir });
await execInLoginShell("gel migrate", { cwd: projectDir });
spinner.stop("Initial migration created and applied");
} catch (error) {
logger(error);
Expand Down
2 changes: 1 addition & 1 deletion packages/create/src/recipes/_install/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as p from "@clack/prompts";
import type { BaseOptions, Recipe } from "../types.js";
import { execInLoginShell } from "../../utils.js";

const logger = debug("@edgedb/create:recipe:install");
const logger = debug("@gel/create:recipe:install");

interface InstallOptions {
shouldGitInit: boolean;
Expand Down
18 changes: 9 additions & 9 deletions packages/create/src/recipes/express/README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
# Express Integration Recipe for EdgeDB
# Express Integration Recipe for Gel

This recipe provides a starting point for building an [Express](https://expressjs.com/) application with EdgeDB as the database.
This recipe provides a starting point for building an [Express](https://expressjs.com/) application with Gel as the database.

✨ Check out the [`@edgedb/create` package](https://github.com/edgedb/edgedb-js/blob/master/packages/create/README.md) for more information.
✨ Check out the [`@gel/create` package](https://github.com/gel/gel-js/blob/master/packages/create/README.md) for more information.

## Usage

```bash
$ npm create @edgedb
$ npm create @gel
# or
yarn create @edgedb
yarn create @gel
# or
pnpm create @edgedb
pnpm create @gel
# or
bun create @edgedb
bun create @gel
```

After running the command, you will be prompted to provide a project name and choose the **"Express"** template. You can also specify whether to use EdgeDB Auth, initialize a git repository, and install dependencies.
After running the command, you will be prompted to provide a project name and choose the **"Express"** template. You can also specify whether to use Gel Auth, initialize a git repository, and install dependencies.

The tool will then create a new directory with the specified name and set up the project.

Expand All @@ -34,7 +34,7 @@ Navigate into `packages/create`:
$ cd packages/create
```

Build @edgedb/create
Build @gel/create

```bash
$ yarn build
Expand Down
8 changes: 3 additions & 5 deletions packages/create/src/recipes/express/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { updatePackage } from "write-package";
import type { BaseOptions, Recipe } from "../types.js";
import { copyTemplateFiles } from "../../utils.js";

const logger = debug("@edgedb/create:recipe:express");
const logger = debug("@gel/create:recipe:express");

const recipe: Recipe = {
skip(opts: BaseOptions) {
Expand All @@ -24,15 +24,13 @@ const recipe: Recipe = {
sideEffects: false,
type: "module",
scripts: {
dev: "DEBUG=* EDGEDB_CLIENT_SECURITY=insecure_dev_mode tsx watch --clear-screen=false src/index.ts",
dev: "DEBUG=* GEL_CLIENT_SECURITY=insecure_dev_mode tsx watch --clear-screen=false src/index.ts",
build: "tsc",
lint: "eslint --ignore-path .gitignore --cache --cache-location ./node_modules/.cache/eslint .",
typecheck: "tsc --noEmit",
},
dependencies: {
...(baseOptions.useEdgeDBAuth
? { "@edgedb/auth-express": "^0.1.0" }
: {}),
...(baseOptions.useGelAuth ? { "@gel/auth-express": "^0.1.0" } : {}),
"cookie-parser": "^1.4.6",
express: "^4.18.2",
},
Expand Down
2 changes: 1 addition & 1 deletion packages/create/src/recipes/express/template/src/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { type NextFunction, type Response, Router } from "express";
import createExpressAuth, {
type AuthRequest,
type CallbackRequest,
} from "@edgedb/auth-express";
} from "@gel/auth-express";
import { client } from "./db.js";
import { PORT } from "./env.js";

Expand Down
2 changes: 1 addition & 1 deletion packages/create/src/recipes/express/template/src/db.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { createClient } from "edgedb";
import { createClient } from "gel";

export const client = createClient();
4 changes: 2 additions & 2 deletions packages/create/src/recipes/express/template/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import express from "express";
import cookieParser from "cookie-parser";
import { type AuthRequest } from "@edgedb/auth-express";
import { type AuthRequest } from "@gel/auth-express";

import { styles } from "./styles.js";
import { auth, requireAuth, signoutRoute, builtinUIRouter } from "./auth.js";
Expand All @@ -14,7 +14,7 @@ app.use(cookieParser());
app.use(auth.createSessionMiddleware());

app.get("/api/deep-thought", requireAuth, async (req: AuthRequest, res) => {
// See more examples of making queries here: https://github.com/edgedb/edgedb-examples/blob/main/express-auth/todos.ts
// See more examples of making queries here: https://github.com/gel/gel-examples/blob/main/express-auth/todos.ts
const answer = await req.session!.client.query<number>("select 42;");
res.json(answer);
});
Expand Down
Loading

0 comments on commit 9b72ac8

Please sign in to comment.