/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/wp-plugin@1.0.3/index.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
#!/usr/bin/env node
const inquirer=require("inquirer"),fs=require("fs"),path=require("path"),stringCase=require("stringcase"),chalk=require("chalk"),isSemver=require("is-semver"),figlet=require("figlet"),exec=require("child_process").exec,README_TEMPLATE="# %PLUGIN_NAME%\n\n## Description\n\n%PLUGIN_DESCRIPTION%\n\n## Usage\n\n\n\n## Changelog\n\n### %PLUGIN_VERSION%\n\n* Initial commit.\n\n## Contributors\n\n* %PLUGIN_AUTHOR% <%AUTHOR_EMAIL%> (%AUTHOR_URI%)\n\n## License\n\nLicensed under [GPL v2](http://www.opensource.org/licenses/gpl-license.php).\n",STARTER_FILE_TEMPLATE="<?php\n/**\n * Plugin Name: %PLUGIN_NAME%\n * Plugin URI: %PLUGIN_URI%\n * Description: %PLUGIN_DESCRIPTION%\n * Version: %PLUGIN_VERSION%\n * Author: %PLUGIN_AUTHOR%\n * Author URI: %AUTHOR_URI%\n * Text Domain: %TEXT_DOMAIN%\n * License: GPL-2.0+\n * License URI: http://www.opensource.org/licenses/gpl-license.php\n */\n\n/*\n  Copyright %YEAR%  %PLUGIN_AUTHOR% (%AUTHOR_EMAIL%)\n\n  This program is free software; you can redistribute it and/or modify\n  it under the terms of the GNU General Public License, version 2, as\n  published by the Free Software Foundation.\n\n  Permission is hereby granted, free of charge, to any person obtaining a copy of this\n  software and associated documentation files (the \"Software\"), to deal in the Software\n  without restriction, including without limitation the rights to use, copy, modify, merge,\n  publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons\n  to whom the Software is furnished to do so, subject to the following conditions:\n\n  The above copyright notice and this permission notice shall be included in all copies or\n  substantial portions of the Software.\n\n  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n  THE SOFTWARE.\n*/\n\nnamespace %AUTHOR_NAMESPACE%%PLUGIN_NAMESPACE%;\n\n// Exit if accessed directly\nif ( ! defined( 'ABSPATH' ) ) {\n    exit;\n}\n\nif ( ! class_exists( '%PLUGIN_NAMESPACE%' ) ) :\n\n    class %PLUGIN_NAMESPACE%\n    {\n        private static $instance;\n\n        public static function instance()\n        {\n            if ( ! isset( self::$instance ) && ! ( self::$instance instanceof %PLUGIN_NAMESPACE% ) ) {\n                self::$instance = new %PLUGIN_NAMESPACE%;\n                self::$instance->constants();\n                self::$instance->includes();\n                self::$instance->hooks();\n            }\n\n            return self::$instance;\n        }\n\n        /**\n         * Constants\n         */\n        public function constants()\n        {\n          // Plugin version\n          if ( ! defined( '%PLUGIN_CONSTANT_PREFIX%_PLUGIN_VERSION' ) ) {\n              define( '%PLUGIN_CONSTANT_PREFIX%_PLUGIN_VERSION', '%PLUGIN_VERSION%' );\n          }\n\n          // Plugin file\n          if ( ! defined( '%PLUGIN_CONSTANT_PREFIX%_PLUGIN_FILE' ) ) {\n              define( '%PLUGIN_CONSTANT_PREFIX%_PLUGIN_FILE', __FILE__ );\n          }\n\n          // Plugin basename\n          if ( ! defined( '%PLUGIN_CONSTANT_PREFIX%_PLUGIN_BASENAME' ) ) {\n              define( '%PLUGIN_CONSTANT_PREFIX%_PLUGIN_BASENAME', plugin_basename( %PLUGIN_CONSTANT_PREFIX%_PLUGIN_FILE ) );\n          }\n\n          // Plugin directory path\n          if ( ! defined( '%PLUGIN_CONSTANT_PREFIX%_PLUGIN_DIR_PATH' ) ) {\n              define( '%PLUGIN_CONSTANT_PREFIX%_PLUGIN_DIR_PATH', trailingslashit( plugin_dir_path( %PLUGIN_CONSTANT_PREFIX%_PLUGIN_FILE )  ) );\n          }\n\n          // Plugin directory URL\n          if ( ! defined( '%PLUGIN_CONSTANT_PREFIX%_PLUGIN_DIR_URL' ) ) {\n              define( '%PLUGIN_CONSTANT_PREFIX%_PLUGIN_DIR_URL', trailingslashit( plugin_dir_url( %PLUGIN_CONSTANT_PREFIX%_PLUGIN_FILE )  ) );\n          }\n      }\n\n        /**\n         * Action/filter hooks\n         */\n        public function hooks()\n        {\n            register_activation_hook( %PLUGIN_CONSTANT_PREFIX%_PLUGIN_FILE, array( $this, 'activate' ) );\n            register_deactivation_hook( %PLUGIN_CONSTANT_PREFIX%_PLUGIN_FILE, array( $this, 'deactivate' ) );\n            add_action('wp_enqueue_scripts', array($this, 'scripts'));\n            add_action('wp_enqueue_styles', array($this, 'styles'));\n        }\n\n        /**\n         * Enqueue Scripts\n         */\n        public function scripts() {}\n\n        /**\n         * Enqueue Styles\n        */\n        public function styles()\n        { }\n\n        /**\n         * Include/Require PHP files\n         */\n        public function includes()\n        { }\n\n        /**\n         * Run on plugin activation\n         */\n        public function activate()\n        { }\n\n        /**\n         * Run on plugin de-activation\n        */\n        public function deactivate()\n        { }\n    }\n\nendif;\n\n%PLUGIN_NAMESPACE%::instance();\n",required=e=>n=>!!n.replace(/[\s-]/,"").length||e,canBeEmpty=e=>"empty"===e?"":e.trim(),renderTemplate=(e,n)=>{const i={"%PLUGIN_NAME%":"name","%PLUGIN_DESCRIPTION%":"description","%PLUGIN_AUTHOR%":"authorName","%PLUGIN_URI%":"url","%PLUGIN_VERSION%":"version","%PLUGIN_NAMESPACE%":"namespace","%PLUGIN_CONSTANT_PREFIX%":"constants","%AUTHOR_EMAIL%":"authorEmail","%AUTHOR_URI%":"authorURL","%TEXT_DOMAIN%":"textDomain"};return Object.keys(i).map((t=>{e=e.replace(RegExp(t,"g"),n[i[t]]||"")})),e=(e=e.replace(/%AUTHOR_NAMESPACE%/,n.authorNamespace&&n.authorNamespace.length?`${n.authorNamespace}\\`:"")).replace(/%YEAR%/g,(new Date).getFullYear())};console.clear(),console.log(chalk.green(figlet.textSync("wp-plugin",{horizontalLayout:"default",verticalLayout:"default"}))),console.log("\nBy Hammed Oyedele"),console.log("GitHub: https://github.com/devhammed/wp-plugin\n"),console.log("---\n"),inquirer.prompt([{type:"input",name:"key",message:"Plugin Slug (lowercase with dashes; e.g. 'my-plugin'):",filter:e=>stringCase.spinalcase(e),validate:required("You must specify a plugin key.")},{type:"input",name:"name",message:"Plugin Name:",default:e=>stringCase.titlecase(e.key)},{type:"input",name:"namespace",message:"Plugin Namespace:",default:e=>stringCase.pascalcase(e.key)},{type:"input",name:"constants",message:"Plugin Constants Prefix:",default:e=>stringCase.constcase(e.key)},{type:"input",name:"description",default:"empty",filter:canBeEmpty,message:"Plugin Description:"},{type:"input",name:"url",default:"#",message:"Plugin URI:"},{type:"input",name:"version",default:"0.0.1",message:"Plugin Version:",filter:canBeEmpty,validate:e=>isSemver(e)||"Error: must be valid semver number (e.g. 0.0.1)"},{type:"input",name:"textDomain",message:"Plugin's Text Domain:",default:"wordpress",filter:canBeEmpty},{type:"input",name:"authorName",default:"empty",filter:canBeEmpty,message:"Author Name:"},{type:"input",name:"authorEmail",default:"empty",filter:canBeEmpty,message:"Author's Email Address:"},{type:"input",name:"authorURL",default:"empty",filter:canBeEmpty,message:"Author's URL:"},{type:"input",name:"authorNamespace",default:"empty",filter:canBeEmpty,message:"Author's Vendor Namespace:"}]).then((e=>{const n=renderTemplate(STARTER_FILE_TEMPLATE,e),i=renderTemplate(README_TEMPLATE,e),t=e.key;console.log(chalk.green("\nCreating plugin..."));try{fs.existsSync(t)||fs.mkdirSync(t)}catch(e){console.log(chalk.red("\nFailed to create plugin folder.")),process.exit(1)}try{fs.writeFileSync(path.join(t,"README.md"),i),fs.writeFileSync(path.join(t,`${e.key}.php`),n)}catch(e){console.log(chalk.red("\nError occurred while creating plugin files.")),process.exit(1)}exec(`git init ${t}`,((e,n,i)=>{e?console.log(chalk.red("\nGit not found, skipping repository initialization.")):console.log(chalk.green(`\nInitialized an empty Git repository in ${t}!`)),console.log(chalk.green("\nYour plugin is ready,")),console.log(chalk.green("Change into the directory to start editing files!")),console.log(chalk.green("\nHappy coding!"))}))}));
//# sourceMappingURL=/sm/72de98d03aba0024e45519e935233dc3ef0ca05ddc066ebd2639a36079c4a6d4.map