@tobiastengler/create-relay-app
Version:
Easy configuration of Relay for existing projects
35 lines (34 loc) • 1.08 kB
JavaScript
import { TS_CONFIG_FILE, TYPESCRIPT_PACKAGE } from "../consts.js";
import { ArgumentBase } from "./ArgumentBase.js";
export class TypeScriptArgument extends ArgumentBase {
constructor(fs, env) {
super();
this.fs = fs;
this.env = env;
this.name = "typescript";
this.promptMessage = "Does your project use TypeScript";
}
registerCliOption(command) {
const flags = this.getCliFlags();
command.option(flags, "use TypeScript");
}
promptForValue(existingArgs) {
return this.showInquirerPrompt({
type: "confirm",
}, existingArgs);
}
isValid(value, existingArgs) {
return true;
}
async getDefaultValue(existingArgs) {
const tsconfigFile = this.env.rel(TS_CONFIG_FILE);
if (this.fs.exists(tsconfigFile.abs)) {
return true;
}
const typescriptInstalled = await this.env.packageJson.containsDependency(TYPESCRIPT_PACKAGE);
if (typescriptInstalled) {
return true;
}
return false;
}
}