@starduv/lil-schemy
Version:
Lil' Schemy is a cli tool that enables code first schema generation from TypeScript
31 lines (30 loc) • 1.71 kB
JavaScript
;
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());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const commander_1 = require("commander");
const fs_1 = require("fs");
const path_1 = __importDefault(require("path"));
const createConfiguration = (cwd) => {
const src = path_1.default.resolve(__dirname, 'default-config.txt');
const dest = path_1.default.resolve(cwd, 'schemy-config.js');
(0, fs_1.copyFileSync)(src, dest);
console.info('Configuration written to %s', dest);
};
exports.default = new commander_1.Command('init')
.description('Create default lil-schemy configuration (schemy-config.js)')
.action((_, command) => __awaiter(void 0, void 0, void 0, function* () {
var _a;
let parentOptions = (_a = command.parent) === null || _a === void 0 ? void 0 : _a.opts();
createConfiguration(parentOptions === null || parentOptions === void 0 ? void 0 : parentOptions.cwd);
}));