UNPKG

@tobiastengler/create-relay-app

Version:

Easy configuration of Relay for existing projects

27 lines (26 loc) 988 B
import { TaskBase } from "./TaskBase.js"; import { GRAPHQL_WS_PACKAGE, REACT_RELAY_PACKAGE, RELAY_RUNTIME_PACKAGE } from "../consts.js"; import { bold } from "../utils/cli.js"; export class InstallNpmDependenciesTask extends TaskBase { constructor(context) { super(); this.context = context; this.message = "Add Relay dependencies"; } isEnabled() { return true; } async run() { if (this.context.args.skipInstall) { this.skip(); return; } const packages = [REACT_RELAY_PACKAGE, RELAY_RUNTIME_PACKAGE]; if (this.context.args.subscriptions) { packages.push(GRAPHQL_WS_PACKAGE, "graphql@15.x"); } this.updateMessage(this.message + " " + packages.map((p) => bold(p)).join(" ")); const latestPackages = packages.map((p) => (p.substring(1).includes("@") ? p : p + "@latest")); await this.context.manager.addDependency(latestPackages); } }