Skip to content
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

Add install recipe #834

Merged
merged 1 commit into from
Jan 12, 2024
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
1 change: 0 additions & 1 deletion packages/create/src/recipes/_base/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import path from "node:path";

import debug from "debug";
import * as p from "@clack/prompts";

import { updatePackage } from "write-package";

import { getPackageManager, copyTemplateFiles } from "../../utils.js";
Expand Down
43 changes: 43 additions & 0 deletions packages/create/src/recipes/_install/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import debug from "debug";
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");

Expand All @@ -27,6 +28,48 @@ const recipe: Recipe<InstallOptions> = {
},
async apply(baseOptions: BaseOptions, recipeOptions: InstallOptions) {
logger("Running install recipe");

const spinner = p.spinner();

if (recipeOptions.shouldGitInit) {
spinner.start("Initializing git repository");
try {
await execInLoginShell("git init", {
cwd: baseOptions.projectDir,
});
spinner.stop("Initialized git repository");
} catch (err) {
spinner.stop("Failed to initialize git repository");
throw err;
}
}

if (recipeOptions.shouldInstall) {
const command = `${baseOptions.packageManager} install`;
spinner.start(`Installing dependencies: ${command}`);
try {
await execInLoginShell(command, {
cwd: baseOptions.projectDir,
});
spinner.stop("Installed dependencies");
} catch (err) {
spinner.stop("Failed to install dependencies");
throw err;
}
}

if (recipeOptions.shouldGitInit) {
spinner.start("Staging changes");
try {
await execInLoginShell("git add .", {
cwd: baseOptions.projectDir,
});
spinner.stop("Staged changes");
} catch (err) {
spinner.stop("Failed to stage changes");
throw err;
}
}
},
};

Expand Down
Loading