• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What's builds file for?

#1
Question 
File :: builds

PHP Code:
#!/usr/bin/env php
<?php

define
('LATEST_RELEASE''^4.0');
define('GITHUB_URL''https://github.com/codeigniter4/codeigniter4');

/*
 * --------------------------------------------------------------------
 * Stability Toggle
 * --------------------------------------------------------------------
 * Use this script to toggle the CodeIgniter dependency between the
 * latest stable release and the most recent development update.
 *
 * Usage: php builds [release|development]
 */

// Determine the requested stability
if (empty($argv[1]) || ! in_array($argv[1], ['release''development']))
{
    echo 
'Usage: php builds [release|development]' PHP_EOL;
    exit;
}

$dev $argv[1] == 'development';
$modified = [];

/* Locate each file and update it for the requested stability */

// Composer.json
$file __DIR__ DIRECTORY_SEPARATOR 'composer.json';

if (
is_file($file))
{
    
// Make sure we can read it
    
if ($contents file_get_contents($file))
    {
        if (
$array json_decode($contentstrue))
        {
            
// Development
            
if ($dev)
            {
                
// Set 'minimum-stability'
                
$array['minimum-stability'] = 'dev';
                
$array['prefer-stable']     = true;

                
// Make sure the repo is configured
                
if (! isset($array['repositories']))
                {
                    
$array['repositories'] = [];
                }

                
// Check for the CodeIgniter repo
                
$found false;
                foreach (
$array['repositories'] as $repository)
                {
                    if (
$repository['url'] == GITHUB_URL)
                    {
                        
$found true;
                        break;
                    }
                }

                
// Add the repo if it was not found
                
if (! $found)
                {
                    
$array['repositories'][] = [
                        
'type' => 'vcs',
                        
'url'  => GITHUB_URL,
                    ];
                }

                
// Define the "require"
                
$array['require']['codeigniter4/codeigniter4'] = 'dev-develop';
                unset(
$array['require']['codeigniter4/framework']);
            }

            
// Release
            
else
            {
                
// Clear 'minimum-stability'
                
unset($array['minimum-stability']);

                
// If the repo is configured then clear it
                
if (isset($array['repositories']))
                {
                    
// Check for the CodeIgniter repo
                    
foreach ($array['repositories'] as $i => $repository)
                    {
                        if (
$repository['url'] == GITHUB_URL)
                        {
                            unset(
$array['repositories'][$i]);
                            break;
                        }
                    }
                    if (empty(
$array['repositories']))
                    {
                        unset(
$array['repositories']);
                    }
                }

                
// Define the "require"
                
$array['require']['codeigniter4/framework'] = LATEST_RELEASE;
                unset(
$array['require']['codeigniter4/codeigniter4']);
            }

            
// Write out a new composer.json
            
file_put_contents($filejson_encode($arrayJSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES) . PHP_EOL);
            
$modified[] = $file;
        }
        else
        {
            echo 
'Warning: Unable to decode composer.json! Skipping...' PHP_EOL;
        }
    }
    else
    {
        echo 
'Warning: Unable to read composer.json! Skipping...' PHP_EOL;
    }
}

// Paths config and PHPUnit XMLs
$files = [
    
__DIR__ DIRECTORY_SEPARATOR 'app/Config/Paths.php',
    
__DIR__ DIRECTORY_SEPARATOR 'phpunit.xml.dist',
    
__DIR__ DIRECTORY_SEPARATOR 'phpunit.xml',
];

foreach (
$files as $file)
{
    if (
is_file($file))
    {
        
$contents file_get_contents($file);

        
// Development
        
if ($dev)
        {
            
$contents str_replace('vendor/codeigniter4/framework''vendor/codeigniter4/codeigniter4'$contents);
        }

        
// Release
        
else
        {
            
$contents str_replace('vendor/codeigniter4/codeigniter4''vendor/codeigniter4/framework'$contents);
        }

        
file_put_contents($file$contents);
        
$modified[] = $file;
    }
}

if (empty(
$modified))
{
    echo 
'No files modified' PHP_EOL;
}
else
{
    echo 
'The following files were modified:' PHP_EOL;
    foreach (
$modified as $file)
    {
        echo 
" * {$file}PHP_EOL;
    }
    echo 
'Run `composer update` to sync changes with your vendor folder' PHP_EOL;


Learning CI4 from my works, from errors and how to fix bugs in the community

Love CI & Thanks CI Teams

Reply

#2
It's nothing for you to worry about it's for building releases you do not need it.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#3
(10-03-2020, 07:25 AM)InsiteFX Wrote: It's nothing for you to worry about it's for building releases you do not need it.

Thanks, i will delete it

Learning CI4 from my works, from errors and how to fix bugs in the community

Love CI & Thanks CI Teams

Reply

#4
It’s actually for changing your project to use the latest development version of the framework. For example if there is a feature of CI4 since the last release (4.0.4) that you want to use in your project then you can run `builds development` and it will switch your dependencies to point to the latest develop branch of the repo. This is very handy when working on or testing code for future releases.
Reply

#5
(10-03-2020, 08:49 AM)MGatner Wrote: It’s actually for changing your project to use the latest development version of the framework. For example if there is a feature of CI4 since the last release (4.0.4) that you want to use in your project then you can run `builds development` and it will switch your dependencies to point to the latest develop branch of the repo. This is very handy when working on or testing code for future releases.

Thank you so much MGatner

Learning CI4 from my works, from errors and how to fix bugs in the community

Love CI & Thanks CI Teams

Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.