create-node-blueprint
Version:
A cli tool to generate nodejs project
52 lines (51 loc) • 2.83 kB
JavaScript
#!/usr/bin/env node
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
import yargs from "yargs";
import { hideBin } from "yargs/helpers";
import { prompt } from "./src/prompts/prompts.js";
import { createProject } from "./src/program/create-project.js";
import { AuthEnum } from "./src/enums/enums.js";
function init() {
return __awaiter(this, void 0, void 0, function* () {
const argv = yield yargs(hideBin(process.argv))
.scriptName("create-node-blueprint")
.option("name", { alias: "n", type: "string", description: "Project name", default: "" })
.option("framework", { alias: "f", type: "string", description: "Framework to use", default: "" })
.option("database", { alias: "d", type: "string", description: "Database type", default: "" })
.option("orm", { alias: "o", type: "string", description: "ORM to use", default: "" })
.option("auth", { alias: "a", type: "string", description: "Authentication method", default: AuthEnum.none })
.option("features", { type: "array", description: "Additional features to include", default: [] })
.option("git", { type: "boolean", description: "Init git repository (use --no-git to skip)", default: true })
.option("install", { type: "boolean", description: "Install packages (use --no-install to skip)", default: true })
.demandOption(["name", "framework", "database", "orm"], "Please provide the required arguments.")
.parse();
const { name, framework, database, orm, features, git, install, auth } = argv;
if (name && framework && database && orm) {
yield createProject({
projectName: name,
framework: framework,
database: database,
orm: orm,
features: features,
installDependencies: install !== false,
initializeGit: git !== false,
auth: auth || AuthEnum.none
});
}
else {
const answers = yield prompt();
yield createProject(answers);
}
});
}
init().catch((e) => {
console.log(e);
});