Skip to content

Commit a05e7c8

Browse files
authored
Merge pull request #2598 from MGatner/devstarter
Deprecate Devstarter, add `builds`
2 parents 223047e + f74d83a commit a05e7c8

3 files changed

Lines changed: 174 additions & 63 deletions

File tree

admin/starter/builds

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
define('LATEST_RELEASE', '^4@rc');
5+
define('GITHUB_URL', 'https://github.com/codeigniter4/codeigniter4');
6+
7+
/*
8+
* --------------------------------------------------------------------
9+
* Stability Toggle
10+
* --------------------------------------------------------------------
11+
* Use this script to toggle the CodeIgniter dependency between the
12+
* latest stable release and the most recent development update.
13+
*
14+
* Usage: php builds [release|development]
15+
*/
16+
17+
// Determine the requested stability
18+
if (empty($argv[1]) || ! in_array($argv[1], ['release', 'development']))
19+
{
20+
echo 'Usage: php builds [release|development]' . PHP_EOL;
21+
exit;
22+
}
23+
24+
$dev = $argv[1] == 'development';
25+
$modified = [];
26+
27+
/* Locate each file and update it for the requested stability */
28+
29+
// Composer.json
30+
$file = __DIR__ . DIRECTORY_SEPARATOR . 'composer.json';
31+
32+
if (is_file($file))
33+
{
34+
// Make sure we can read it
35+
if ($contents = file_get_contents($file))
36+
{
37+
if ($array = json_decode($contents, true))
38+
{
39+
// Development
40+
if ($dev)
41+
{
42+
// Set 'minimum-stability'
43+
$array['minimum-stability'] = 'dev';
44+
45+
// Make sure the repo is configured
46+
if (! isset($array['repositories']))
47+
{
48+
$array['repositories'] = [];
49+
}
50+
51+
// Check for the CodeIgniter repo
52+
$found = false;
53+
foreach ($array['repositories'] as $repository)
54+
{
55+
if ($repository['url'] == GITHUB_URL)
56+
{
57+
$found = true;
58+
break;
59+
}
60+
}
61+
62+
// Add the repo if it was not found
63+
if (! $found)
64+
{
65+
$array['repositories'][] = [
66+
'type' => 'vcs',
67+
'url' => GITHUB_URL,
68+
];
69+
}
70+
71+
// Define the "require"
72+
$array['require']['codeigniter4/codeigniter4'] = 'dev-develop';
73+
unset($array['require']['codeigniter4/framework']);
74+
}
75+
76+
// Release
77+
else
78+
{
79+
// Clear 'minimum-stability'
80+
unset($array['minimum-stability']);
81+
82+
// If the repo is configured then clear it
83+
if (isset($array['repositories']))
84+
{
85+
// Check for the CodeIgniter repo
86+
foreach ($array['repositories'] as $i => $repository)
87+
{
88+
if ($repository['url'] == GITHUB_URL)
89+
{
90+
unset($array['repositories'][$i]);
91+
break;
92+
}
93+
}
94+
if (empty($array['repositories']))
95+
{
96+
unset($array['repositories']);
97+
}
98+
}
99+
100+
// Define the "require"
101+
$array['require']['codeigniter4/framework'] = LATEST_RELEASE;
102+
unset($array['require']['codeigniter4/codeigniter4']);
103+
}
104+
105+
// Write out a new composer.json
106+
file_put_contents($file, json_encode($array, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES) . PHP_EOL);
107+
$modified[] = $file;
108+
}
109+
else
110+
{
111+
echo 'Warning: Unable to decode composer.json! Skipping...' . PHP_EOL;
112+
}
113+
}
114+
else
115+
{
116+
echo 'Warning: Unable to read composer.json! Skipping...' . PHP_EOL;
117+
}
118+
}
119+
120+
// Paths config and PHPUnit XMLs
121+
$files = [
122+
__DIR__ . DIRECTORY_SEPARATOR . 'app/Config/Paths.php',
123+
__DIR__ . DIRECTORY_SEPARATOR . 'phpunit.xml.dist',
124+
__DIR__ . DIRECTORY_SEPARATOR . 'phpunit.xml',
125+
];
126+
127+
foreach ($files as $file)
128+
{
129+
if (is_file($file))
130+
{
131+
$contents = file_get_contents($file);
132+
133+
// Development
134+
if ($dev)
135+
{
136+
$contents = str_replace('vendor/codeigniter4/framework', 'vendor/codeigniter4/codeigniter4', $contents);
137+
}
138+
139+
// Release
140+
else
141+
{
142+
$contents = str_replace('vendor/codeigniter4/codeigniter4', 'vendor/codeigniter4/framework', $contents);
143+
}
144+
145+
file_put_contents($file, $contents);
146+
$modified[] = $file;
147+
}
148+
}
149+
150+
if (empty($modified))
151+
{
152+
echo 'No files modified' . PHP_EOL;
153+
}
154+
else
155+
{
156+
echo 'The following files were modified:' . PHP_EOL;
157+
foreach ($modified as $file)
158+
{
159+
echo " * {$file}" . PHP_EOL;
160+
}
161+
echo 'Run `composer update` to sync changes with your vendor folder' . PHP_EOL;
162+
}

user_guide_src/source/installation/installing_composer.rst

Lines changed: 12 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -81,70 +81,29 @@ Folders in your project after set up:
8181
- vendor/codeigniter4/framework/system
8282
- vendor/codeigniter4/framework/app & public (compare with yours after updating)
8383

84-
Dev Starter
85-
============================================================
86-
87-
Installation & Set Up
84+
Latest Dev
8885
-------------------------------------------------------
8986

90-
The `CodeIgniter 4 dev starter <https://github.com/codeigniter4/devstarter>`_
91-
repository holds a skeleton application, just like the appstarter above,
92-
but with a composer dependency on
93-
the develop branch (unreleased) of the framework.
94-
It can be composer-installed as described here.
95-
96-
This installation technique would suit a developer who wishes to start
97-
a new CodeIgniter4 based project, and who is willing to live with the
98-
latest unreleased changes, which may be unstable.
87+
The App Starter repo comes with a ``builds`` scripts to switch Composer sources between the
88+
current stable release and the latest development branch of the framework. Use this script
89+
for a developer who is willing to live with the latest unreleased changes, which may be unstable.
9990

10091
The `development user guide <https://codeigniter4.github.io/CodeIgniter4/>`_ is accessible online.
10192
Note that this differs from the released user guide, and will pertain to the
10293
develop branch explicitly.
10394

104-
In the folder above your project root::
105-
106-
composer create-project codeigniter4/devstarter -s dev
107-
108-
The command above will create a "devstarter" folder.
109-
Feel free to rename that for your project.
110-
111-
Just like the appstarter, you can provide your own project
112-
name as the third composer argument, and you can add
113-
the "--no-dev" argument if your don't want phpunit and its dependencies included.
114-
An example::
115-
116-
composer create-project codeigniter4/devstarter my-awesome-project -s dev --no-dev
117-
118-
119-
Upgrading
120-
-------------------------------------------------------
121-
122-
``composer update`` whenever you are ready for the latest changes,
123-
or ``composer update --no-dev`` if you used that argument when creating your project.
124-
125-
Check the changelog to see if any recent changes affect your app,
126-
bearing in mind that the most recent changes may not have made it
127-
into the changelog!
128-
129-
Pros
130-
-------------------------------------------------------
131-
132-
Simple installation; easy to update; bleeding edge version
133-
134-
Cons
135-
-------------------------------------------------------
95+
In your project root::
13696

137-
This is not guaranteed to be stable; the onus is on you to upgrade.
138-
You still need to check for ``app/Config`` changes after updating.
97+
php builds development
13998

140-
Structure
141-
-------------------------------------------------------
99+
The command above will update **composer.json** to point to the ``develop`` branch of the
100+
working repository, and update the corresponding paths in config and XML files. To revert
101+
these changes run::
142102

143-
Folders in your project after set up:
103+
php builds release
144104

145-
- app, public, tests, writable
146-
- vendor/codeigniter4/codeigniter4/system
147-
- vendor/codeigniter4/codeigniter4/app & public (compare with yours after updating)
105+
After using the ``builds`` command be sure to run ``composer update`` to sync your vendor
106+
folder with the latest target build.
148107

149108
Adding CodeIgniter4 to an Existing Project
150109
============================================================

user_guide_src/source/installation/repositories.rst

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ There are several development repositories, of interest to potential contributor
1111
+==================+==============+=================================================================+
1212
+ CodeIgniter4 + contributors + Project codebase, including tests & user guide sources +
1313
+------------------+--------------+-----------------------------------------------------------------+
14-
+ devstarter + developers + Starter project (app/public/writable). +
15-
+ + + Dependent on develop branch of codebase repository +
16-
+------------------+--------------+-----------------------------------------------------------------+
1714
+ translations + developers + System message translations +
1815
+------------------+--------------+-----------------------------------------------------------------+
1916
+ coding-standard + contributors + Coding style conventions & rules +
@@ -52,7 +49,6 @@ These correspond to the repositories mentioned above:
5249

5350
- `codeigniter4/framework <https://packagist.org/packages/codeigniter4/framework>`_
5451
- `codeigniter4/appstarter <https://packagist.org/packages/codeigniter4/appstarter>`_
55-
- `codeigniter4/devstarter <https://packagist.org/packages/codeigniter4/devstarter>`_
5652
- `codeigniter4/userguide <https://packagist.org/packages/codeigniter4/userguide>`_
5753
- `codeigniter4/translations <https://packagist.org/packages/codeigniter4/translations>`_
5854
- `codeigniter4/CodeIgniter4 <https://packagist.org/packages/codeigniter4/CodeIgniter4>`_
@@ -72,12 +68,6 @@ but which showcase it or make it easier to work with!
7268
+==================+==============+=================================================================+
7369
+ website2 + developers + The codeigniter.com website, written in CodeIgniter 4 +
7470
+------------------+--------------+-----------------------------------------------------------------+
75-
+ module-tests + plugin + PHPunit testing scaffold for CI4 module / plugin developers +
76-
+ + developers + +
77-
+------------------+--------------+-----------------------------------------------------------------+
78-
+ project-tests + app + PHPunit testugn scaffold for CI4 projects +
79-
+ + developers + +
80-
+------------------+--------------+-----------------------------------------------------------------+
8171
+ + + +
8272
+------------------+--------------+-----------------------------------------------------------------+
8373

0 commit comments

Comments
 (0)