Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ In order to get started with developing Lapse, run these commands:
# Install all packages
pnpm install

# Set up the development environment
# Set up the development environment (opens the environment variables wizard)
pnpm dev:setup-env

# Start the web client and backend
pnpm dev
```

Lapse relies on ffmpeg for its serverside video processing.
You can install ffmpeg [from their website](https://ffmpeg.org/download.html) by downloading the appropriate ffmpeg binary for your operating system.
To start and stop the development environment, use `pnpm dev:start-env` and `pnpm dev:stop-env` respectively.

When developing, it's a good idea to re-compile all packages on the fly!
Expand Down
24 changes: 19 additions & 5 deletions apps/devscripts/src/setup-dev-env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,21 @@ const __dirname = dirname(__filename);
const DEFAULT_DATABASE_PORT = 5432;
const DEFAULT_SERVER_PORT = 3123;
const DEFAULT_REDIS_PORT = 6379;
const DEFAULT_DATABASE_USER = "postgres";
const DEFAULT_DATABASE_PASSWORD = "postgres";

let databasePort = DEFAULT_DATABASE_PORT;
let serverPort = DEFAULT_SERVER_PORT;
let redisPort = DEFAULT_REDIS_PORT;
let databaseUser = DEFAULT_DATABASE_USER;
let databasePassword = DEFAULT_DATABASE_PASSWORD;

function getDatabaseUrl() {
return `postgresql://postgres:postgres@localhost:${databasePort}/lapse?schema=public`;
return `postgresql://${databaseUser}:${databasePassword}@localhost:${databasePort}/lapse?schema=public`;
}

function getRedisUrl() {
return `redis://localhost:${redisPort}`;
return `redis://localhost:${redisPort}`;
}

let S3_ENDPOINT = "http://s3.localhost.localstack.cloud:4566";
Expand Down Expand Up @@ -270,7 +274,7 @@ async function updateEnvFiles(envVars: {
writeEnvFile(clientDir, envVars.client),
writeEnvFile(workerDir, envVars.worker),
]);

spinner.succeed(chalk.green("Environment variables updated successfully"));
logInfo(`Updated .env files for ${chalk.italic("server")}, ${chalk.italic("client")}, and ${chalk.italic("worker")}`);
}
Expand Down Expand Up @@ -363,7 +367,7 @@ async function updateDockerComposeFile(localstackImage: string | null) {
async function runSetup() {
console.clear();

const TOTAL_STEPS = 8;
const TOTAL_STEPS = 9;
let currentStep = 0;

try {
Expand All @@ -379,6 +383,16 @@ async function runSetup() {
serverPort = await askForPort("API server", DEFAULT_SERVER_PORT);
redisPort = await askForPort("Redis", DEFAULT_REDIS_PORT);

logStep(++currentStep, TOTAL_STEPS, "Configuring database credentials...");
databaseUser = await input({
message: `Enter database username (default: ${DEFAULT_DATABASE_USER}): `,
default: DEFAULT_DATABASE_USER,
});
databasePassword = await input({
message: `Enter database password (default: ${DEFAULT_DATABASE_PASSWORD}): `,
default: DEFAULT_DATABASE_PASSWORD,
});

logStep(++currentStep, TOTAL_STEPS, "Configuring storage backend...");
localstackORr2 = await askLocalstackOrR2();

Expand Down Expand Up @@ -500,7 +514,7 @@ async function main() {
await startDockerCompose();
return;
}

await runSetup();
});

Expand Down
Loading