{"id":14954944,"url":"https://github.com/codesvault/wp-bundler","last_synced_at":"2025-10-24T07:30:34.912Z","repository":{"id":239186088,"uuid":"798670176","full_name":"CodesVault/wp-bundler","owner":"CodesVault","description":"WordPress plugin bundler. Build dependencies \u0026 Bundle production ready plugins.","archived":false,"fork":false,"pushed_at":"2024-10-08T11:39:05.000Z","size":46,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-01-29T08:11:48.812Z","etag":null,"topics":["bundler","ci-cd","wordpress","wordpress-development","wordpress-plugin"],"latest_commit_sha":null,"homepage":"https://packagist.org/packages/codesvault/wp-bundler","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CodesVault.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-10T08:43:50.000Z","updated_at":"2024-11-04T09:35:53.000Z","dependencies_parsed_at":"2024-05-10T15:39:08.230Z","dependency_job_id":"16374850-e65a-4068-b34a-d950885f63b5","html_url":"https://github.com/CodesVault/wp-bundler","commit_stats":{"total_commits":22,"total_committers":1,"mean_commits":22.0,"dds":0.0,"last_synced_commit":"2914dc1423a6db2e91dcd883e1cfcc4b9edc54db"},"previous_names":["codesvault/wp-bundler"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodesVault%2Fwp-bundler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodesVault%2Fwp-bundler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodesVault%2Fwp-bundler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CodesVault%2Fwp-bundler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CodesVault","download_url":"https://codeload.github.com/CodesVault/wp-bundler/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237932059,"owners_count":19389560,"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":["bundler","ci-cd","wordpress","wordpress-development","wordpress-plugin"],"created_at":"2024-09-24T13:10:16.515Z","updated_at":"2025-10-24T07:30:34.906Z","avatar_url":"https://github.com/CodesVault.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WP Bundler\n\nBuild dependencies \u0026 Bundle production ready plugin.\n\u003cbr\u003e\nWP Bundler is a CI/CD tool. It can configure and run build process, and bundle zip(s) for WordPress plugins.\n\n\u003cbr\u003e\n\n## Requirements\n- Environment: Mac, Linux.\n- PHP CLI 7.4 \u003e=\n- Composer\n\n\u003cbr\u003e\n\u003cbr\u003e\n\n## Installation\n\n\nIt is required to use composer to install WP Bundler.\n\u003cbr\u003e\n\n```bash\ncomposer require codesvault/wp-bundler --dev\n```\n\n\u003cbr\u003e\n\n\n## Setup\n\nCreate a `bundler` file in the root folder of your plugin. E.g. `wp-content/plugins/kathamo/bundler`.\nAdd the below code in the file.\n\n```php\n#!/usr/bin/env php\n\u003c?php\n\nuse CodesVault\\Bundle\\Bundler;\nuse CodesVault\\Bundle\\Setup;\n\nrequire __DIR__ . \"/vendor/autoload.php\";\n\n$bundler = new Bundler(__DIR__);\n```\n\n\u003cbr\u003e\n\nMake a `.distignore` file in the root folder of your plugin. Add all those files, folders which you want to exclude from the production zip like below.\n\n```\nbundler\n\nnode_modules\npackage.json\npackage-lock.json\n\ncomposer.json\ncomposer.lock\n\nassets/dev\n```\n\n\u003cbr\u003e\n\u003cbr\u003e\n\n## Uses\n\n```php\n// basic uses\n\n$bundler\n    -\u003ecreateProductionRepo('kathamo')\n    -\u003ecommand(\"composer install --no-dev\")\n    -\u003ecommand(\"npm install\")\n    -\u003ecommand(\"npm run build\")\n    -\u003ecleanUp()\n    -\u003ezip('kathamo')\n    -\u003eexecutionTime();\n```\n\nNow Let's add build pipeline in the above `bundler` file using this codes. Then from terminal `cd` into plugin's folder and run the below command to create a production zip.\n\n```bash\nphp bundler\n```\n\n\u003cbr\u003e\n\nIt's creating a repo in the `/pluginName/prod` folder then running build `command` then 'cleaning' up the repo based on `.distignore` and finally making a zip.\n\n\u003cbr\u003e\n\u003cbr\u003e\n\n## Envirnoment variables\n\nGet env file data using WP Bundler.\n\n```php\n\n// .env file\nDEV_MODE='true'\nTIERS_PRODUCTIDS=\"basic:1722795,plus:1722797,elite:1722799\"\n\n\n// bundler file\n$env = CodesVault\\Bundle\\Setup::loadEnv(__DIR__, '.env');\n\nif ('true' === $env-\u003egetenv('DEV_MODE')) {\n  $bundler\n    -\u003ecommand(\"composer install\")\n    -\u003ecommand(\"npm install\")\n    -\u003ecommand(\"npm run build\");\n}\n\n$tiers_pids = $setup-\u003ekv($setup-\u003egetEnv('TIERS_PID'));\n// array (\n//   [\n//     'key'   =\u003e 'basic',\n//     'value' =\u003e '1722795',\n//   ],\n//   [\n//     'key'   =\u003e 'plus',\n//     'value' =\u003e '1722797',\n//   ],\n//   [\n//     'key'   =\u003e 'elite',\n//     'value' =\u003e '1722799',\n//   ],\n// );\n```\n\n\u003cbr\u003e\n\u003cbr\u003e\n\n## Update File content\n\nYou can also update specific file data dynamically before making the zip using `updateFileContent` api.\n\n### Configuration\nCreate a `bundler-schema.json` file in the root folder of your plugin.\n`bundler-schema.json` file data structure will be like below.\n\n```json\n{\n  \"kathamo\": {\n    \"path\": \"\",\n    \"extension\": \"php\",\n    \"schema\": [\n      {\n        \"target\": \"Plugin Name: Kathamo\",\n        \"template\": \"Plugin Name: Kathamo {{tier_name}}\"\n      },\n      {\n        \"target\": \"Version: 1.5.2\",\n        \"template\": \"Version: {{release_version}}\"\n      },\n      {\n          \"target\": \"define('CV_VERSION', '1.5.2');\",\n          \"template\": \"define('CV_VERSION', '{{release_version}}');\"\n      }\n    ]\n  },\n  \"README\": {\n    \"path\": \"\",\n    \"extension\": \"txt\",\n    \"schema\": [\n      {\n        \"target\": \"Version: 1.5.2\",\n        \"template\": \"Version: {{release_version}}\"\n      }\n    ]\n  }\n}\n```\n\nHere `Kathamo, README` these keys are the file names. `path` is the file's relative path. `extension` is the file extension. `schema` is the array of objects where `target` is the data which you want to update and `template` is the data which you want to replace with.\n\n\u003cbr\u003e\n\n### Usage\n\n```php\n// bundler file\n\n// bundler-schema.json file's `{{placeholder}}` name should be same as the key names in the below array.\n$intended_data = [\n  \"tier_name\"       =\u003e \"Pro\",\n  \"release_version\" =\u003e $setup-\u003egetEnv('RELEASE_VERSION'),\n];\n\n$bundler\n  -\u003ecreateProductionRepo('kathamo')\n  -\u003ecommand(\"composer install --no-dev\")\n  -\u003ecleanUp()\n  -\u003eupdateFileContent($intended_data)\n  -\u003ezip('kathamo');\n```\n\n\u003cbr\u003e\n\u003cbr\u003e\n\n## Find and Replace\n\nUpdate entire plugin file's data using `findAndReplace` api.\n\n```php\n$bundler\n  -\u003ecreateProductionRepo('kathamo')\n  -\u003efindAndReplace([\n    [\n      'find'          =\u003e \"use Kathamo\\\\Bundle\\\\Bundler;\",\n      'updated_data'  =\u003e \"use CodesVault\\\\Kathamo\\\\Bundle\\\\Bundler;\",\n    ]\n  ])\n  -\u003ecleanUp()\n  -\u003ezip($zip_name);\n```\n\n\u003cbr\u003e\n\u003cbr\u003e\n\n## Multiple Zips\n\nWhen you want to create multiple zip, use `buildIterator` api.\n\n```php\n// .env file\nTIERS_PID=\"basic:123,plus:231,pro:3240\"\n\n\n// bundler file\n$setup = Setup::loadEnv(__DIR__, '.env');\n$tiers_pids = $setup-\u003ekv($setup-\u003egetEnv('TIERS_PID'));\n\n$bundler\n  -\u003ecreateProductionRepo('kathamo')\n  -\u003ecommand(\"composer install --no-dev\")\n  -\u003ecommand(\"npm install\")\n  -\u003ecommand(\"npm run build\")\n  -\u003ecleanUp()\n  -\u003ebuildIterator($tiers_pids, function($meta, $builder) {\n    $zip_name = \"kathamo-\" . $meta['key'] . \"-\" . $meta['value'];\n\n    $builder\n      -\u003ezip($zip_name);\n  })\n  -\u003eexecutionTime();\n```\n\n\u003cbr\u003e\n\u003cbr\u003e\n\n## Callable Function as command\n\nYou can also use callable or callback function as command. It will be executed in the prod repo folder.\n\n```php\n$bundler\n  -\u003ecreateProductionRepo('kathamo')\n  -\u003ecommand('foo', $env) // foo is a callable function with $env parameter\n  -\u003ecommand(function() {\n    echo \"Hello world!\\n\";\n  })\n  -\u003ecleanUp()\n  -\u003ebuildIterator($tiers_pids, function($meta, $builder) {\n    $zip_name = \"kathamo-\" . $meta['key'] . \"-\" . $meta['value'];\n\n    $builder\n      -\u003ezip($zip_name);\n  })\n  -\u003eexecutionTime();\n\n\nfunction foo() {\n  // Do something here\n}\n\n```\n\n\u003cbr\u003e\n\u003cbr\u003e\n\n## Example\n\nHere is an example of a `bundler` file.\n\n```php\n#!/usr/bin/env php\n\u003c?php\n\nrequire __DIR__ . \"/vendor/autoload.php\";\n\n// data loaded from .env file\n$setup = Setup::loadEnv(__DIR__, '.env');\n$tiers_pids = $setup-\u003ekv($setup-\u003egetEnv('TIERS_PID'));\n\n$bundler\n  -\u003ecreateProductionRepo('kathamo')\n  -\u003ecommand(\"composer install --no-dev\")\n  -\u003ecommand(\"npm install\")\n  -\u003ecommand(\"npm run build\")\n  -\u003ecleanUp()\n  -\u003ecopy('/schema.json', '/schema.json')\n  -\u003erenameProdFile('kathamo.php', 'kathamo-pro.php')\n  -\u003ebuildIterator($tiers_pids, function($meta, $builder) {\n    $zip_name = \"kathamo-\" . $meta['key'] . \"-\" . $meta['value'];\n    $intended_data = [\n      \"tier_name\"       =\u003e $meta['tier'],\n      \"release_version\" =\u003e $setup-\u003egetEnv('RELEASE_VERSION'),\n    ];\n\n    $builder\n      -\u003eupdateFileContent($intended_data)\n      -\u003efindAndReplace([\n        [\n          'find'          =\u003e \"use Kathamo\\\\Bundle\\\\Bundler;\",\n          'updated_data'  =\u003e \"use CodesVault\\\\Kathamo\\\\Bundle\\\\Bundler;\",\n        ]\n      ])\n      -\u003ezip($zip_name);\n  })\n  -\u003eexecutionTime();\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodesvault%2Fwp-bundler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodesvault%2Fwp-bundler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodesvault%2Fwp-bundler/lists"}