PHP code example of codesvault / wp-bundler
1. Go to this page and download the library: Download codesvault/wp-bundler library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
codesvault / wp-bundler example snippets
#!/usr/bin/env php
use CodesVault\Bundle\Bundler;
use CodesVault\Bundle\Setup;
// basic uses
$bundler
->createProductionRepo('kathamo')
->command("composer install --no-dev")
->command("npm install")
->command("npm run build")
->cleanUp()
->zip('kathamo')
->executionTime();
// .env file
DEV_MODE='true'
TIERS_PRODUCTIDS="basic:1722795,plus:1722797,elite:1722799"
// bundler file
$env = CodesVault\Bundle\Setup::loadEnv(__DIR__, '.env');
if ('true' === $env->getenv('DEV_MODE')) {
$bundler
->command("composer install")
->command("npm install")
->command("npm run build");
}
$tiers_pids = $setup->kv($setup->getEnv('TIERS_PID'));
// array (
// [
// 'key' => 'basic',
// 'value' => '1722795',
// ],
// [
// 'key' => 'plus',
// 'value' => '1722797',
// ],
// [
// 'key' => 'elite',
// 'value' => '1722799',
// ],
// );
// bundler file
// bundler-schema.json file's `{{placeholder}}` name should be same as the key names in the below array.
$intended_data = [
"tier_name" => "Pro",
"release_version" => $setup->getEnv('RELEASE_VERSION'),
];
$bundler
->createProductionRepo('kathamo')
->command("composer install --no-dev")
->cleanUp()
->updateFileContent($intended_data)
->zip('kathamo');
$bundler
->createProductionRepo('kathamo')
->findAndReplace([
[
'find' => "use Kathamo\\Bundle\\Bundler;",
'updated_data' => "use CodesVault\\Kathamo\\Bundle\\Bundler;",
]
])
->cleanUp()
->zip($zip_name);
// .env file
TIERS_PID="basic:123,plus:231,pro:3240"
// bundler file
$setup = Setup::loadEnv(__DIR__, '.env');
$tiers_pids = $setup->kv($setup->getEnv('TIERS_PID'));
$bundler
->createProductionRepo('kathamo')
->command("composer install --no-dev")
->command("npm install")
->command("npm run build")
->cleanUp()
->buildIterator($tiers_pids, function($meta, $builder) {
$zip_name = "kathamo-" . $meta['key'] . "-" . $meta['value'];
$builder
->zip($zip_name);
})
->executionTime();
#!/usr/bin/env php
file
$setup = Setup::loadEnv(__DIR__, '.env');
$tiers_pids = $setup->kv($setup->getEnv('TIERS_PID'));
$bundler
->createProductionRepo('kathamo')
->command("composer install --no-dev")
->command("npm install")
->command("npm run build")
->cleanUp()
->copy('/schema.json', '/schema.json')
->renameProdFile('kathamo.php', 'kathamo-pro.php')
->buildIterator($tiers_pids, function($meta, $builder) {
$zip_name = "kathamo-" . $meta['key'] . "-" . $meta['value'];
$intended_data = [
"tier_name" => $meta['tier'],
"release_version" => $setup->getEnv('RELEASE_VERSION'),
];
$builder
->updateFileContent($intended_data)
->findAndReplace([
[
'find' => "use Kathamo\\Bundle\\Bundler;",
'updated_data' => "use CodesVault\\Kathamo\\Bundle\\Bundler;",
]
])
->zip($zip_name);
})
->executionTime();
bash
php bundler
json
{
"kathamo": {
"path": "",
"extension": "php",
"schema": [
{
"target": "Plugin Name: Kathamo",
"template": "Plugin Name: Kathamo {{tier_name}}"
},
{
"target": "Version: 1.5.2",
"template": "Version: {{release_version}}"
},
{
"target": "define('CV_VERSION', '1.5.2');",
"template": "define('CV_VERSION', '{{release_version}}');"
}
]
},
"README": {
"path": "",
"extension": "txt",
"schema": [
{
"target": "Version: 1.5.2",
"template": "Version: {{release_version}}"
}
]
}
}