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,EAAQ,OAAO,GACf,KAAK,IAAI,WAAW,OACpB,YAAW,IAAM,KAAK,KAAK,EAAM,IAAQ,KAEzC,QAAQ,GAAG,QAAQ,IACf,KAAK,IAAI,kCAAkC,KAAO,IAEtD,KAAK,IAAI,uBACT,KAAK,OAAO,OAAO,OAAM,IACjB,GAAO,KAAK,IAAI,EAAK,UACL,iBAAT,IAA8B,IAAT,GAAiB,KAC7C,EAAuB,iBAAT,EAAoB,EAAO,EACzC,QAAQ,KAAK,OAAO,IACxB,IAGZ,CAWA,MAAA,CAAQ,GAIJ,OAHA,QAAQ,GAAS,CAAC,EAAI,KAClB,KAAK,GAAK,KAEP,IACX","file":"/npm/bloggify-cli@3.2.0/lib/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/bloggify-cli@3.2.0/lib/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","\"use strict\"\n\nconst BloggifyServer = require(\"./server\")\n    , ul = require(\"ul\")\n    , readJson = require(\"safe-r-json\")\n    , typpy = require(\"typpy\")\n    , deffy = require(\"deffy\")\n    , BloggifyPaths = require(\"./paths\")\n    , Module = require(\"module\")\n    , forEach = require(\"iterate-object\")\n    , noop = require(\"noop6\")\n    , PluginLoader = require(\"bloggify-plugin-loader\")\n    , EventEmitter = require(\"events\")\n    , Logger = require(\"cute-logger\")\n    , ErrorCreator = require(\"error-creator\")\n    , requireDir = require(\"require-dir-watch\")\n    , isThere = require(\"is-there\")\n    , abs = require(\"abs\")\n    , maybeRequire = require(\"maybe-require\")\n    , dotenv = require(\"dotenv\")\n    , fileTree = require(\"fs-file-tree\")\n    , Path = require(\"path\")\n    , BloggifyPackage = require(\"../package.json\")\n\nmodule.exports = class Bloggify extends EventEmitter {\n\n    /**\n     * Bloggify\n     * Creates a new instance of `Bloggify`.\n     *\n     * @name Bloggify\n     * @function\n     * @param {Object} options An object containing the following fields:\n     *\n     *   - `plugins` (Array): The plugins to load. A specific element should be\n     *     either a string or an array of two values (the value name and the\n     *     configuration object).\n     *\n     *     Example:\n     *\n     *     ```js\n     *     [\n     *        // Load the web sockets module\n     *        \"ws\"\n     *      , [\"some-interesting-module\",{\n     *          \"and\": \"some\",\n     *          \"interesting\": \"configuration\"\n     *        }]\n     *     ]\n     *     ```\n     *\n     *     **Note**: If the module name starts with `bloggify-`, you can omit\n     *     that part of the name.\n     *     Example: To load `bloggify-ws`, you can simply use `ws`.\n     *\n     *   - `core_plugins` (Array): Like `plugins`, but these have greater\n     *      priority when starting the app.\n     *\n     *      There are some additional core plugins which are loaded automatically.\n     *\n     *      The specific order of loading core plugins is:\n     *\n     *       0. Models (sequelize/mongoose)\n     *       1. Custom plugins configured in `bloggify.js(on)`\n     *       2. Actions\n     *       3. Router\n     *       4. Renderer(s)\n     *\n     *   - `title` (String): The application name. For convenience (in case it's\n     *      not set), the default is an empty string (`\"\"`).\n     *\n     *   - `description` (String): The application description. For convenience\n     *      (in case it's not set), the default is an empty string (`\"\"`).\n     *\n     *   - `db_uri` (String): The database URI. It can be set in the options,\n     *      or via an environment variable: `DB_URI`. The recommended way is\n     *      to use the environment variable set in the `.env` file or in the\n     *      deployment platform settings (e.g. Heroku).\n     *\n     *      The uri is parsed and the specific dialect is handled. Currently,\n     *      these dialects are supported:\n     *\n     *      **`mongodb`**\n     *\n     *      URI: `mongodb://localhost/your-database-name`\n     *      Needed peer dependencies: `connect-mongo`, `bloggify-mongoose`\n     *\n     *      You need to install these in your app folder:\n     *\n     *      ```sh\n     *      npm install connect-mongo bloggify-mongoose\n     *      ```\n     *\n     *      If no models are used, you don't need to install\n     *      `bloggify-mongoose`. `connect-mongo` will be used for\n     *      session management.\n     *\n     *      The models will be created in the models folder (default: `app/models`).\n     *\n     *      Example:\n     *\n     *      **`Topic.js`**\n     *      ```\n     *      const TopicSchema = new Bloggify.db.Schema({\n     *          title: {\n     *              type: String,\n     *              text: true\n     *          },\n     *          body: {\n     *              type: String,\n     *              text: true\n     *          },\n     *      })\n     *      module.exports = Bloggify.db.model(\"Topic\", TopicSchema)\n     *      ```\n     *\n     *      **`mysql`**\n     *\n     *      URI: `DB_URI=mysql://root:password@host:port/your-database-name`\n     *      Needed peer dependencies: `express-mysql-session`, `bloggify-sequelize`\n     *\n     *      You need to install these in your app folder:\n     *\n     *      ```sh\n     *      npm install connect-mongo bloggify-mongoose\n     *      ```\n     *\n     *      If no models are used, you don't need to install\n     *      `bloggify-mongoose`. `connect-mongo` will be used for\n     *      session management.\n     *\n     *      The models will be created in the models folder (default: `app/models`).\n     *\n     *      Example:\n     *\n     *      **`User.js`**\n     *\n     *      ```js\n     *      const Sequelize = Bloggify.sequelize\n     *\n     *      const Subject = Sequelize.db.define(\"subject\", {\n     *          name: {\n     *              type: Sequelize.STRING\n     *          }\n     *      }, {\n     *          charset: \"utf8mb4\"\n     *      })\n     *\n     *      module.exports = Subject\n     *      ```\n     *\n     *   -  `db_options` (Object): Additional options to be passed to the\n     *      database plugin (`bloggify-sequelize` or `bloggify-mongoose`).\n     *   - `server` (Object) Server ([`lien`](https://github.com/lienjs/lien)) related settings.\n     *     - `port` (Boolean): The server's port (default: `process.env.PORT || 8080`).\n     *     - `host` (Boolean): The server's host (default: `null`).\n     *     - `csrf` (Boolean): Wether to enable csrf validation or not (default: `true`).\n     *     - `session` (Object|Boolean): The session settings, or `false` to\n     *        disable the session management. In most of the cases you will\n     *        not need to change this.\n     *   - `paths` (Object): The paths options. Do *not* change these unless you have a good reason.\n     *     - `bloggify` (String): The Bloggify directory (by default the root of the app).\n     *     - `public_main` (String): The public directory endpoint (default: `\"/@/bloggify/public/\"`)\n     *     - `public_assets` (String): The public core endpoint (default: `\"/@/bloggify/assets/\"`)\n     *     - `css_assets` (String): The CSS assets endpoint (default: `\"/@/bloggify/css-assets/\"`)\n     *     - `errors` (String): (default: `\"/app/errors\"`)\n     *     - `models` (String): (default: `\"/app/models\"`)\n     *     - `controllers` (String): (default: `\"/app/controllers\"`)\n     *     - `routes` (String): (default: `\"/app/routes\"`)\n     *     - `services` (String): (default: `\"/app/services\"`)\n     *     - `partials` (String): (default: `\"/app/partials\"`)\n     *     - `actions` (String): (default: `\"/app/actions\"`)\n     *     - `plugins` (String): (default: `\"/node_modules\"`)\n     *     - `config` (String): The config file: `bloggify.js(on)` (default: `\"/bloggify\"`).\n     *     - `package` (String): The `package.json` file path (default: `\"package.json\"`).\n     *   - `bundler` (Object): The bundler options (see [`rucksack`](https://github.com/Bloggify/rucksack)).\n     *     - `aliases` (Object): The aliases that should be made in the scripts.By default, the following are included. If needed, you can extend with yours:\n     *       - `bloggify` :arrow_right: `${__dirname}/client/index.js`\n     *       - `bloggify/actions` :arrow_right: `${__dirname}/client/actions.js`\n     *       - `bloggify/actions/common` :arrow_right: `${__dirname}/client/common`\n     *   - `renderer` (String): The module to be used for rendering (default: `\"bloggify-template-renderer\"`).\n     *   - `renderers` (Object): An object containing the renderer options.\n     *     - `ajs`: {}\n     *\n     * @returns {Bloggify} The `Bloggify` instance.\n     */\n    constructor (options) {\n\n        super()\n        const self = global.Bloggify = this\n        self._package = BloggifyPackage\n        self.version = self._package.version\n\n        // Now, since we have an instance, expose it\n        const originalRequire = Module.prototype.require;\n        Module.prototype.require = function (name) {\n            if (name === \"bloggify\") {\n                return self\n            }\n            return originalRequire.apply(this, arguments)\n        }\n\n        const isProduction = this.production = process.env.NODE_ENV === \"production\"\n\n        // Handle errors smoothly\n        if (isProduction || process.argv.includes(\"--catch-exceptions\")) {\n            process.on(\"uncaughtException\", err => {\n                this.log(\"Fatal error:\", \"error\")\n                console.log(\"The error is: \", err)\n                this.log(err && err.stack || err, \"error\")\n            })\n        }\n\n        this.on(\"error\", e => {\n            this.log(e, \"error\")\n        })\n\n        // Log level related functinality\n        let logLevel = process.env.BLOGGIFY_LOG_LEVEL\n        Logger.config.date = isProduction\n        if (this.production && !logLevel) {\n            logLevel = 1\n        }\n        this.logLevel(logLevel)\n\n        // Default the options to the CWD path.\n        options = options || process.cwd()\n\n        // Initialize the options object\n        if (typeof options === \"string\") {\n            options = { root: options }\n        }\n\n        options.root = abs(options.root)\n        dotenv.config({ path: `${options.root}/.env` })\n\n        // Merge the Bloggify defaults\n        const defaultOptions = require(\"./defaults\")\n        this.options = options = ul.deepMerge(\n            options,\n            maybeRequire(`${options.root}${defaultOptions.paths.config}`, true),\n            defaultOptions\n        )\n\n        // Initialize the paths\n        const paths = this.paths = new BloggifyPaths(options.root, options, this)\n\n        options = this.options\n\n        // Check for defaults in assets\n        const PATH_STYLESHEETS_MANIFEST = \"app/assets/stylesheets/application.css\"\n        const PATH_JAVASCRIPTS_MANIFEST = \"app/assets/javascripts/application.js\"\n\n        if (!options.styles && isThere(PATH_STYLESHEETS_MANIFEST)) {\n            options.styles = PATH_STYLESHEETS_MANIFEST\n        }\n\n        if (!options.scripts && isThere(PATH_JAVASCRIPTS_MANIFEST)) {\n            options.scripts = PATH_JAVASCRIPTS_MANIFEST\n        }\n\n        if (typeof options.styles === \"string\") {\n            options.styles = [options.styles]\n        }\n\n        if (typeof options.scripts === \"string\") {\n            options.scripts = [options.scripts]\n        }\n\n        // Initialize the public paths\n        this.paths.initPublicPaths()\n\n        // Initialize the plugin loader\n        this.pluginLoader = new PluginLoader(this)\n\n        this.errors = new ErrorCreator()\n        if (isThere(this.paths.errors)) {\n            this.errors.add(requireDir(this.paths.errors))\n        }\n\n        // partials\n        this.partials = {}\n        if (isThere(this.paths.partials)) {\n            this.partials = fileTree.sync(this.paths.partials)\n            const walk = (obj, key, parent) => {\n                if (obj.path) {\n                    parent[key.split(\".\")[0]] = obj.path\n                    return\n                }\n                forEach(obj, (o, k) => walk(o, k, obj))\n\n            }\n            walk(this.partials)\n        }\n\n        // Models\n        this.models = {}\n        const corePlugins = []\n            , foundModels = isThere(this.paths.models)\n\n        if (options.db_uri) {\n            options.db_options = require(\"parse-db-uri\")(options.db_uri)\n            if (options.db_uri.endsWith(\".sqlite3\")) {\n                options.db_uri = options.db_options.uri\n            }\n            switch (options.db_options.dialect) {\n                case \"mongodb\":\n                    if (options.server.session !== false) {\n                        options.server.session = ul.deepMerge(options.server.session, {\n                            store: \"connect-mongo\"\n                          , storeOptions: {\n                                url: options.db_uri\n                            }\n                        })\n                    }\n                    if (foundModels) {\n                        corePlugins.push([\"bloggify-mongoose\", Object.assign({\n                            uri:  options.db_uri\n                          , models_dir: this.paths.models\n                        }, options.db_options)])\n                    }\n                    break\n                case \"mysql\":\n                    if (options.server.session !== false) {\n                        options.server.session = ul.deepMerge(options.server.session, {\n                            store: \"express-mysql-session\"\n                          , storeOptions: {\n                                user: options.db_options.user\n                              , password: options.db_options.password\n                              , host: options.db_options.host\n                              , port: options.db_options.port\n                              , database: options.db_options.database\n                            }\n                        })\n                    }\n                    if (foundModels) {\n                        corePlugins.push([\"bloggify-sequelize\", {\n                            uri:  options.db_uri\n                          , models_dir: this.paths.models\n                          , options: Object.assign({\n                                pool: {\n                                    max: 5\n                                  , min: 0\n                                  , idle: 10000\n                                }\n                              , logging: this.production ? false : this.log.bind(this)\n                              , define: {\n                                    underscored: true\n                                }\n                            }, options.db_options)\n                        }])\n                    }\n                    break\n                case \"sqlite\":\n\n                    if (options.server.session !== false) {\n                        options.server.session = ul.deepMerge(options.server.session, {\n                            store: \"express-session-sqlite\"\n                          , storeOptions: {\n                              path: options.db_uri\n                            , prefix: 'sess:'\n                            , cleanupInterval: 300000\n                            }\n                        })\n                    }\n\n                    if (foundModels) {\n                        corePlugins.push([\"bloggify-sequelize\", {\n                            models_dir: this.paths.models\n                          , options: Object.assign({\n                                storage: options.db_uri\n                              , logging: this.production ? false : this.log.bind(this)\n                            }, options.db_options)\n                        }])\n                    }\n                    break\n            }\n        }\n\n        // Start the server\n        this.extend(BloggifyServer)\n        this._initServer()\n\n        // Read the package\n        this.package = readJson(this.paths.package)\n        this.handleBundleConfig(options, this.paths.root)\n\n\n        if (!this.options.title) {\n            this.options.title = this.package.name\n        }\n\n        // Actions\n        this._actions = {}\n        if (isThere(this.paths.actions)) {\n            this.actions = require(\"./actions\")(this)\n            corePlugins.push(\"bloggify-actions\")\n        }\n\n        // Routes\n        if (isThere(this.paths.routes)) {\n            corePlugins.push([\"bloggify-flexible-router\", {\n                routes_dir: this.paths.routes\n            }])\n        }\n\n        if (options.renderers) {\n            options.Renderer = require(options.renderer)\n            this.renderer = new options.Renderer(this)\n            forEach(options.renderers, (config, name) => {\n                name = `bloggify-renderer-${name}`\n                corePlugins.push([name, config])\n            })\n        }\n\n        // Enable the adapter\n        if (options.adapter) {\n            const cmsMethods = require(\"./cms-methods\")\n            this.extend(cmsMethods)\n            corePlugins.push(options.adapter)\n        }\n\n        options.core_plugins = [\n            foundModels ? corePlugins.splice(0, 1)[0] : null\n          , ...options.core_plugins\n          , ...corePlugins\n        ]\n\n        // Load the core plugins\n        //\n        // 0) Models (sequelize/mongoose)\n        // 1) Custom plugins (from bloggify.js)\n        // 2) Actions\n        // 3) Router\n        // 4) Renderer(s)\n        this.log(\"Loading the core plugins\")\n        this.loadPlugins(options.core_plugins).then(() => {\n            this.log(\"Loading the plugins\")\n            return this.loadPlugins(options.plugins)\n        }).then(data => {\n            process.nextTick(() => {\n                this.log(\"Initialized plugins.\")\n                this.emit(\"plugins-loaded\")\n            })\n        }).catch(err => {\n            if (err) {\n                this.log(\"Failed to start.\", \"error\")\n                this.log(err, \"error\")\n            }\n            this.emit(\"ready\", err)\n            this.emit(\"plugins-loaded\", err)\n        })\n\n        this.ready(() => {\n            this._ready = true\n        })\n    }\n\n    ready (fn) {\n        return new Promise(resolve => {\n            if (this._ready) {\n                process.nextTick(fn => {\n                    if (fn) fn()\n                    resolve()\n                })\n                return\n            }\n            this.once(\"ready\", () => {\n                if (fn) fn()\n                resolve()\n            })\n        })\n    }\n\n    initPlugin (plugin, config) {\n        if (Array.isArray(plugin)) {\n            config = plugin[1]\n            plugin = plugin[0]\n        }\n        const plug = this.pluginLoader.getPlugin(plugin)\n        plug.config = config\n        return this.pluginLoader.initPlugin(plug)\n    }\n\n    /**\n     * render\n     * Renders a template.\n     *\n     * @name render\n     * @function\n     * @param {Lien} lien The `lien` object.\n     * @param {String} templateName The template name or path.\n     * @param {Object} data The template data.\n     */\n    render (lien, templateName, data) {\n\n        data = data || {}\n\n        data.Bloggify = this\n        data.context = data.ctx = data.lien = lien\n        data.template = templateName\n        data.siteMetadata = this.options.metadata || {}\n        data.page = data.page || {}\n        data._public = (filePath, absolute) => this.paths.staticFilePath(filePath, absolute)\n        data.f = i => i in data\n        data.require = require\n        data.stringify = function () {\n            // TODO XSS proof\n            return JSON.stringify.apply(JSON, arguments).replace(/\\//g, \"\\\\u002f\")\n        }\n\n        if (data.error) {\n            data.error.statusCode = data.error.status || data.error.statusCode || (\n                /not found|enoent/i.test(data.error.message) ? 404 : 500\n            )\n            if (!data.forceTemplateName) {\n                templateName = data.error.statusCode.toString()\n            }\n        }\n\n        data.title = data.title || data.page.title || \"\"\n        this.renderer.render(lien, templateName, data)\n    }\n\n    /**\n     * loadPlugins\n     * Loads the provided plugins.\n     *\n     * @param  {Array} names The list of plugin names.\n     * @param  {Function} cb The callback function.\n     */\n    loadPlugins (plugins, cb) {\n        return this.pluginLoader.loadAll(plugins, cb)\n    }\n\n    /**\n     * require\n     * Considering the value of the module (`true`, `false`), it returns the raw module of the plugin or the instance of it.\n     *\n     * @param  {String} name    The plugin's name.\n     * @param  {Boolean} mod    The plugin's module.\n     * @return {BloggifyPlugin} The plugin's instance.\n     */\n    require (name, mod, cb) {\n        return this.pluginLoader.get(name, mod, cb)\n    }\n\n    /**\n     * logLevel\n     * Sets or gets the log level.\n     *\n     * The log levels are:\n     *\n     *   - `0`: Ignore everything\n     *   - `1`: Errors\n     *   - `2`: Errors + Warnings\n     *   - `3`: Errors + Warnings + Info\n     *   - `4`: Everything\n     *\n     * @param  {String} newLogLevel The instance of the log.\n     * @return {String}             The log level.\n     */\n    logLevel (newLogLevel) {\n        newLogLevel = parseInt(newLogLevel)\n        if (!typpy(newLogLevel, Number)) {\n            return this._log_level\n        }\n        Logger.config.level = newLogLevel\n        this._log_level = newLogLevel\n        return newLogLevel\n    }\n\n    /**\n     * log\n     * Prints a log message in the output.\n     *\n     * @name log\n     * @function\n     * @param {Error|String} msg The log message.\n     * @param {String} type The log type (error|info|warn|log).\n     * @param {Stream} stream The output stream (defaults to `process.stderr` for errors and `process.stdout` for other logs).\n     * @param {Boolean} newLine A flag wheter to add a new line at the end of the message or not.\n     */\n    log (msg, type, stream, newLine) {\n        newLine = deffy(newLine, true)\n        if (msg instanceof Error) {\n            type = type || \"error\"\n            msg = msg.toString() + \"\\n\" + msg.stack\n        } else {\n        //    msg = String(msg)\n        }\n\n        // Sendgrid-style errors\n        if (Array.isArray(msg?.response?.body?.errors)) {\n            msg += \"\\n\" + msg.response.body.errors.map(\n                c => c?.message || c\n            ).join(\"\\n\")\n        }\n\n\n        type = deffy(type, \"log\")\n        if (!stream) {\n            Logger.log(msg, type)\n            return\n        }\n        if (newLine) {\n            msg += \"\\n\"\n        }\n        stream = type === \"error\" ? process.stderr : process.stdout\n        stream.write(msg)\n    }\n\n    /**\n     * exit\n     * Closes the Bloggify app.\n     *\n     * @name exit\n     * @function\n     * @param {Number} code The exit code.\n     * @param {Boolean} force Force the closing of the process.\n     * @param {Number} delay An optional delay.\n     */\n    exit (code, force, delay) {\n        if (delay) {\n            delay = Number(delay)\n            this.log(`Waiting ${delay}ms`)\n            setTimeout(() => this.exit(code, force), delay)\n        } else {\n            process.on(\"exit\", code => {\n                this.log(`Closing the app with exit code ${code}.`)\n            });\n            this.log(`Closing the server.`)\n            this.server.server.close(err => {\n                if (err) { this.log(err, \"error\") }\n                if (typeof code === \"number\" || code === true || force) {\n                    code = typeof code === \"number\" ? code : 0\n                    process.exit(Number(code))\n                }\n            })\n        }\n    }\n\n    /**\n     * extend\n     * Extends the Bloggify instance with new methods.\n     *\n     * @name extend\n     * @function\n     * @param {Object} methods An object containing functions you want to append to the `Bloggify` instance.\n     * @returns {Bloggify} The `Bloggify` instance.\n     */\n    extend (methods) {\n        forEach(methods, (fn, c) => {\n            this[c] = fn\n        })\n        return this\n    }\n}\n"]}