{"id":23387251,"url":"https://github.com/wp-forge/wp-scaffolding-tool","last_synced_at":"2025-04-11T05:09:23.023Z","repository":{"id":45402303,"uuid":"411854824","full_name":"wp-forge/wp-scaffolding-tool","owner":"wp-forge","description":"A zero-config scaffolding tool for WordPress.","archived":false,"fork":false,"pushed_at":"2025-01-15T21:43:30.000Z","size":74,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-11T05:09:16.210Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wp-forge.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-09-29T23:08:38.000Z","updated_at":"2025-01-15T21:42:38.000Z","dependencies_parsed_at":"2022-09-22T18:50:46.820Z","dependency_job_id":null,"html_url":"https://github.com/wp-forge/wp-scaffolding-tool","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wp-forge%2Fwp-scaffolding-tool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wp-forge%2Fwp-scaffolding-tool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wp-forge%2Fwp-scaffolding-tool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wp-forge%2Fwp-scaffolding-tool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wp-forge","download_url":"https://codeload.github.com/wp-forge/wp-scaffolding-tool/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248345266,"owners_count":21088244,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-22T01:15:23.933Z","updated_at":"2025-04-11T05:09:23.002Z","avatar_url":"https://github.com/wp-forge.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WP Scaffolding Tool\n\nA zero-configuration* scaffolding tool library built to be included in a WP-CLI package.\n\n## Installation\n\n```shell\ncomposer require wp-forge/wp-scaffolding-tool\n```\n\n## Integration\n\nBe sure that the `type` property in your `composer.json` file is set to `wp-cli-package`.\n\nAutoload the file with the code below via Composer:\n\n```php\n\u003c?php\n\nuse WP_Forge\\WP_Scaffolding_Tool\\Package;\n\nif ( ! class_exists( 'WP_CLI' ) ) {\n\treturn;\n}\n\nif ( file_exists( __DIR__ . '/vendor/autoload.php' ) ) {\n\trequire __DIR__ . '/vendor/autoload.php';\n}\n\nnew Package(\n\t[\n\t\t'base_command'             =\u003e 'forge',\n\t\t'template_config_filename' =\u003e 'config.json',\n\t\t'project_config_filename'  =\u003e '.wp-forge-project.json', \n\t\t'global_config_filename'   =\u003e '.wp-forge.json',\n\t\t'default_template_repo'    =\u003e 'https://github.com/wp-forge/scaffolding-templates.git', \n\t]\n);\n```\n\nThe following values are meant to be customized for your specific use case:\n\n- **base_command** - The name of the base WP-CLI command. For example, a value of `forge` would result in available\n  commands such as `wp forge init` and `wp forge make`.\n- **template_config_filename** - The name of the config file used in scaffolding templates. When scaffolding a new\n  entity, this JSON file is read to determine the user prompts and resulting actions.\n- **project_config_filename** - The name of the project config file. This is generated when running the `init`\n  subcommand.\n- **global_config_filename** - The name of the global config file.\n- **default_template_repo** - The Git repository URL where the scaffolding templates are located.\n\n## Usage\n\nAll commands are self-documented by the tool. Simply type an available command followed by the `--help` flag for more\ndetails.\n\n**Get high-level documentation on available commands:**\n\n```shell\nwp \u003cbase_command\u003e --help\n```\n\n**Get documentation for a specific command:**\n\n```shell\nwp \u003cbase_command\u003e \u003csubcommand\u003e --help\n```\n\n#### Available commands:\n\n- [repo](#the-repo-command)\n- [make](#the-make-command)\n- [init](#the-init-command)\n- [template](#the-template-command)\n- [config](#the-config-command)\n\n### The `repo` Command\n\n#### List\n\nList all available template repositories:\n\n```shell\nwp \u003cbase_command\u003e repo list\n```\n\n#### Clone\n\nClone a Git repository containing [scaffolding templates](#scaffolding-templates) so they will be locally available to\nthe tool.\n\n```shell\nwp \u003cbase_command\u003e repo clone \u003crepository_url\u003e\n```\n\nWhen cloning a repository, you can optionally provide a name. This allows you to utilize multiple repositories\ncontaining scaffolding templates from various sources. If you do not set a name, the system will use the name \"default\"\nautomatically.\n\n```shell\nwp \u003cbase_command\u003e repo clone \u003crepository_url\u003e --as=\u003cname\u003e\n```\n\n#### Link\n\nThe `link` command registers a symlink to a local scaffolding template directory.\n\nTo create a new link, run:\n\n```shell\nwp \u003cbase_command\u003e repo link ./path/to/templates --as=\u003cname\u003e\n```\n\n#### Update\n\nTo update a repository that has already been cloned, run the following command where the `name` is the registered name\nfor the scaffolding repository (the default value is `default`):\n\n```shell\nwp \u003cbase_command\u003e repo update \u003cname\u003e\n```\n\nWhere `name` is the name used when running the `repo clone` subcommand.\n\n#### Delete\n\nTo delete a locally cloned repository, run:\n\n```shell\nwp \u003cbase_command\u003e repo delete \u003cname\u003e\n```\n\nWhere `name` is the name used when running the `repo clone` subcommand.\n\n### The `make` Command\n\nTo scaffold using a template from a named repository, just prefix the entity name with your custom namespace.\n\nFor example, if you set the name to be `company`, and you wanted to scaffold a `wp-plugin`, then you would run this\ncommand:\n\n```shell\nwp \u003cbase_command\u003e make company:wp-plugin\n```\n\nThis will ensure that the repository containing the `company` templates will be checked for the `wp-plugin` scaffolding.\nIn the event that you have multiple template sources configured and the requested template cannot be found under the\nrequested namespace, the tool will ask you if you want to check the other template sources for that template.\n\nYou can also use a path to leverage templates found nested in other folders.\n\n```shell\nwp \u003cbase_command\u003e make company:github-actions/lint-php\n```\n\nThe above command would look in the `~/.wp-cli/templates/company` folder for the template in\nthe `github-actions/lint-php` directory.\n\n### The `init` Command\n\nThe `init` command will ask a series of questions and generate a project configuration file.\n\n```shell\nwp \u003cbase_command\u003e init\n```\n\nData found in the project configuration file will be automatically loaded when a command is run within the project. If a\nscaffolding template requests a specific piece of information and it can be found in the project config file, then the\nuser won't see a prompt requesting that information.\n\n### The `template` Command\n\n#### List\n\nTo list all available scaffolding templates, run:\n\n```shell\nwp \u003cbase_command\u003e template list\n```\n\n#### Create\n\nTo create a new scaffolding template in the current directory, run:\n\n```shell\nwp \u003cbase_command\u003e template create\n```\n\n**Note:** *This feature is experimental and is still in active development.*\n\n### The `config` Command\n\nAll subcommands will accept the `--global` flag. When used, all commands will apply to the global config file.\nOtherwise, all commands will apply to the project config file.\n\n#### Create\n\nCreate a new config file:\n\n```shell\nwp \u003cbase_command\u003e config create [--global]\n```\n\nWhen used with the `--global` flag, an empty global config file will be created in the user's home directory.\n\nWhen used without the `--global` flag, this will trigger the `init` command to create a project config.\n\n#### Edit\n\nLaunch the system file editor to edit the config file:\n\n```shell\nwp \u003cbase_command\u003e config edit [--global]\n```\n\n#### Has\n\nCheck if the config file has a specific value:\n\n```shell\nwp \u003cbase_command\u003e config has \u003ckey\u003e [--global]\n```\n\nWhere `key` is the name of the JSON property. Dot notation can be used to reference nested properties.\n\n#### Get\n\nGet a value from a config file:\n\n```shell\nwp \u003cbase_command\u003e config get \u003ckey\u003e [--global]\n```\n\nWhere `key` is the name of the JSON property. Dot notation can be used to reference nested properties.\n\n#### Set\n\nSet a value in a config file:\n\n```shell\nwp \u003cbase_command\u003e config set \u003ckey\u003e \u003cvalue\u003e [--global]\n```\n\nWhere `key` is the name of the JSON property. Dot notation can be used to reference nested properties.\n\nThe `value` is the value to be set.\n\n#### Delete\n\nDelete a value in a config file:\n\n```shell\nwp \u003cbase_command\u003e config delete \u003ckey\u003e [--global]\n```\n\nWhere `key` is the name of the JSON property. Dot notation can be used to reference nested properties.\n\n#### List\n\nList the settings from a config file:\n\n```shell\nwp \u003cbase_command\u003e config list [--global]\n```\n\n#### Path\n\nGet the path to a config file:\n\n```shell\nwp \u003cbase_command\u003e config path [--global]\n```\n\n## Scaffolding Templates\n\nIn order to use this tool, you must first have a Git repository where you will host your scaffolding templates.\n\n**Let's get started!**\n\n\u003e **Step 1:** Create a [new Git repository](https://github.com/new).\n\n\u003e **Step 2:** Create a folder in the repository for each thing you will want to scaffold. The name of the folder is the name you will use with the `make` command.\n\nExamples of things you might want to scaffold:\n\n- WordPress plugins\n- WordPress themes\n- WordPress sites\n- Custom post types\n- GitHub actions\n- Other custom code you use frequently\n\n\u003e **Step 3:** Make sure you have a template config file (e.g. `config.json`) file in the template folder. This will \n\u003e tell the CLI what to do with your template.\n\n### Config Examples\n\nA simple `config.json` file might look like this:\n\n```json\n{\n  \"directives\": [\n    {\n      \"action\": \"copy\",\n      \"from\": \"lint-php.yml\",\n      \"to\": \".github/workflows/lint-php.yml\",\n      \"relativeTo\": \"projectRoot\"\n    }\n  ]\n}\n```\n\nThis would copy the `lint-php.yml` file from the template folder to the `.github/workflows/lint-php.yml` file relative\nto the project root. You can provide multiple copy directives to copy not only files, but also entire directories. If\nyou want the path to be relative to the current directory where the CLI tool is being run, then just leave off\nthe `relativeTo` property or set its value to `workingDir`.\n\nIt is very common that you will want to replace placeholders in your templates. To facilitate this, you must first\ncollect the required information from the user.\n\nYou can add a `prompts` section to trigger these data requests in the CLI:\n\n```json\n{\n  \"prompts\": [\n    {\n      \"message\": \"What is your first name?\",\n      \"name\": \"first_name\",\n      \"type\": \"input\"\n    },\n    {\n      \"message\": \"What country are you in?\",\n      \"name\": \"country\",\n      \"type\": \"input\",\n      \"default\": \"United States\"\n    },\n    {\n      \"message\": \"What is your favorite ice cream?\",\n      \"name\": \"ice_cream\",\n      \"type\": \"radio\",\n      \"options\": [\n        \"Chocolate\",\n        \"Vanilla\",\n        \"Strawberry\"\n      ]\n    },\n    {\n      \"message\": \"Select one or more taxonomies\",\n      \"name\": \"taxonomies\",\n      \"type\": \"checkboxes\",\n      \"options\": [\n        \"Categories\",\n        \"Tags\"\n      ]\n    }\n  ]\n}\n```\n\nWith these prompts defined, you can now use the `name` field as a [Mustache](https://mustache.github.io/) placeholder in\nany template file. You can also reference the name of any property from the project configuration file in your templates\nwithout needing to prompt the user.\n\nYou can have a template leverage other templates by using the `runCommand` directive and calling the `make` command:\n\n```json\n{\n  \"directives\": [\n    {\n      \"action\": \"runCommand\",\n      \"command\": \"wp forge make github-actions/lint-js\"\n    },\n    {\n      \"action\": \"runCommand\",\n      \"command\": \"wp forge make github-actions/lint-php\"\n    },\n    {\n      \"action\": \"runCommand\",\n      \"command\": \"wp forge make github-actions/lint-yml\"\n    }\n  ]\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwp-forge%2Fwp-scaffolding-tool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwp-forge%2Fwp-scaffolding-tool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwp-forge%2Fwp-scaffolding-tool/lists"}