UNPKG

xweb-templating

Version:

A cli tool for converting 'tags' to regular html, php or some other format

48 lines (47 loc) 2.49 kB
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 { read_config } from "./config/config.js"; import { info, status } from "./log.js"; import { save_tagsets } from "./tagset/util.js"; import { run as run_create_config } from "./config/create.js"; import { confirm } from "./log.js"; import path from "path"; import fs from "fs"; export default function run(argv) { return __awaiter(this, void 0, void 0, function* () { let config; let created_config = false; if (argv.yes || (yield confirm(argv, "Create 'xwebconfig.json' file?"))) { created_config = true; const CONFIG_RESULT = yield run_create_config(argv); if (CONFIG_RESULT == null) return; config = CONFIG_RESULT; info("init/tags_folder", "Using tags folder from config file"); } else { info("init/tags_folder", "Detecting tags folder based on config file or defaults"); config = read_config("init/tags_folder"); } if (argv.yes || (yield confirm(argv, `Create folder '${config.folder.tags}' for tags?`))) { const TAGS_FOLDER_PATH = path.join(process.cwd(), config.folder.tags); fs.mkdirSync(TAGS_FOLDER_PATH); status("init/tags_folder", `Created folder '${config.folder.tags}'`); } if (argv.yes || (yield confirm(argv, "Create '.xwebignore' file"))) { const IGNORE_FILE_PATH = path.join(process.cwd(), ".xwebignore"); fs.writeFileSync(IGNORE_FILE_PATH, ""); status("init/ignores", "Created file '.xwebignore'"); } if (created_config && config.tags.length > 0 && (argv.yes || (yield confirm(argv, "Fetch all tagsets from the public github repo?")))) { save_tagsets("init/fetch", config.tags, config); } }); }