UNPKG

@vxrn/takeout-cli

Version:

CLI tools for Takeout starter kit - interactive onboarding and project setup

91 lines (90 loc) 3.58 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: !0 }); }, __copyProps = (to, from, except, desc) => { if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod); var files_exports = {}; __export(files_exports, { checkOnboarded: () => checkOnboarded, markOnboarded: () => markOnboarded, updateAppConfig: () => updateAppConfig, updatePackageJson: () => updatePackageJson }); module.exports = __toCommonJS(files_exports); var import_node_fs = require("node:fs"), import_node_path = require("node:path"); function updatePackageJson(cwd, updates) { var packagePath = (0, import_node_path.join)(cwd, "package.json"); if (!(0, import_node_fs.existsSync)(packagePath)) return { success: !1, error: "package.json not found" }; try { var content = (0, import_node_fs.readFileSync)(packagePath, "utf-8"), pkg = JSON.parse(content); return updates.name && (pkg.name = updates.name), updates.description && (pkg.description = updates.description), (0, import_node_fs.writeFileSync)(packagePath, JSON.stringify(pkg, null, 2) + ` `, "utf-8"), { success: !0 }; } catch (error) { return { success: !1, error: error instanceof Error ? error.message : "Unknown error" }; } } function updateAppConfig(cwd, updates) { var configPath = (0, import_node_path.join)(cwd, "app.config.ts"); if (!(0, import_node_fs.existsSync)(configPath)) return { success: !1, error: "app.config.ts not found" }; try { var content = (0, import_node_fs.readFileSync)(configPath, "utf-8"); return updates.name && (content = content.replace(/(name:\s*['"])([^'"]+)(['"])/, `$1${updates.name}$3`)), updates.slug && (content = content.replace(/(slug:\s*['"])([^'"]+)(['"])/, `$1${updates.slug}$3`)), updates.bundleId && (content = content.replace(/(bundleIdentifier:\s*['"])([^'"]+)(['"])/, `$1${updates.bundleId}$3`), content = content.replace(/(package:\s*['"])([^'"]+)(['"])/, `$1${updates.bundleId}$3`)), (0, import_node_fs.writeFileSync)(configPath, content, "utf-8"), { success: !0 }; } catch (error) { return { success: !1, error: error instanceof Error ? error.message : "Unknown error" }; } } function checkOnboarded(cwd) { return (0, import_node_fs.existsSync)((0, import_node_path.join)(cwd, ".onboarded")); } function markOnboarded(cwd) { var marker = (0, import_node_path.join)(cwd, ".onboarded"); try { var timestamp = (/* @__PURE__ */ new Date()).toISOString(); return (0, import_node_fs.writeFileSync)(marker, `Onboarded at: ${timestamp} Run 'bun onboard' to reconfigure. `, "utf-8"), { success: !0 }; } catch (error) { return { success: !1, error: error instanceof Error ? error.message : "Unknown error" }; } } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { checkOnboarded, markOnboarded, updateAppConfig, updatePackageJson }); //# sourceMappingURL=files.js.map