Skip to content

Commit 3f1e204

Browse files
Resolved merge conflict in CHANGELOG.md
2 parents 274a545 + ac1490e commit 3f1e204

10 files changed

Lines changed: 99 additions & 74 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1616
- Sprinkle list in the bakery `debug` command to uses the new `sprinkle:list` table
1717
- `routerCacheFile` config now only contains filename. Locator is used to find the full path
1818
- Updated Docker integration
19+
- Moved some constants from `app/defines.php` to `app/sprinkles/core/defines.php`
20+
- Move route initialization from system to core sprinkle as router service is located in the core sprinkle
1921

2022
### Fix
2123
- Fix for `Test` Bakery command
@@ -34,6 +36,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
3436
- Ignore existing `package-lock.json` which caused incorrect dependencies to be installed when upgrading from older versions of UserFrosting.
3537
- Vendor assets not found in production mode
3638
- Various Docker specific edge cases and misconfigurations
39+
- Fix path issue on Windows
3740

3841
## 4.2.0-beta.1
3942

app/defines.php

Lines changed: 9 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -27,49 +27,21 @@
2727
// The directory containing APP_DIR. Usually, this will contain the entire website.
2828
define('UserFrosting\ROOT_DIR', realpath(__DIR__ . '/..'));
2929

30-
// Directory names
30+
// Names of app directories
3131
define('UserFrosting\APP_DIR_NAME', basename(__DIR__));
32-
define('UserFrosting\BUILD_DIR_NAME', 'build');
33-
define('UserFrosting\CACHE_DIR_NAME', 'cache');
34-
define('UserFrosting\DB_DIR_NAME', 'database');
35-
define('UserFrosting\SESSION_DIR_NAME', 'sessions');
3632
define('UserFrosting\SPRINKLES_DIR_NAME', 'sprinkles');
3733

34+
// Names of src directories within Sprinkles
35+
define('UserFrosting\SRC_DIR_NAME', 'src');
36+
3837
// Full path to Sprinkles directory
39-
define('UserFrosting\SPRINKLES_DIR', APP_DIR . DS . SPRINKLES_DIR_NAME);
38+
define('UserFrosting\SPRINKLES_DIR', APP_DIR_NAME . DS . SPRINKLES_DIR_NAME);
4039

41-
// Sprinkles schema file
40+
// Full path to sprinkles schema file
4241
define('UserFrosting\SPRINKLES_SCHEMA_FILE', APP_DIR . DS . 'sprinkles.json');
4342

44-
define('UserFrosting\LOG_DIR_NAME', 'logs');
45-
define('UserFrosting\VENDOR_DIR_NAME', 'vendor');
46-
47-
// Full path to Composer's vendor directory
48-
define('UserFrosting\VENDOR_DIR', APP_DIR . DS . VENDOR_DIR_NAME);
49-
50-
// Full path to database directory (SQLite only)
51-
define('UserFrosting\DB_DIR', APP_DIR . DS . DB_DIR_NAME);
43+
// Full path to system Bakery commands
44+
define('UserFrosting\BAKERY_SYSTEM_DIR', APP_DIR . DS . 'system' . DS . 'Bakery' . DS . 'Command');
5245

53-
// Names of directories within Sprinkles
54-
define('UserFrosting\ASSET_DIR_NAME', 'assets');
55-
define('UserFrosting\EXTRA_DIR_NAME', 'extra');
56-
define('UserFrosting\CONFIG_DIR_NAME', 'config');
57-
define('UserFrosting\LOCALE_DIR_NAME', 'locale');
58-
define('UserFrosting\ROUTE_DIR_NAME', 'routes');
59-
define('UserFrosting\SCHEMA_DIR_NAME', 'schema');
60-
define('UserFrosting\SRC_DIR_NAME', 'src');
61-
define('UserFrosting\TEMPLATE_DIR_NAME', 'templates');
62-
define('UserFrosting\FACTORY_DIR_NAME', 'factories');
63-
define('UserFrosting\PUBLIC_DIR_NAME', 'public');
64-
65-
// Paths for the different class sources
46+
// Relative path from within sprinkle directory
6647
define('UserFrosting\BAKERY_DIR', SRC_DIR_NAME . DS . 'Bakery');
67-
68-
// Path to system Bakery commands
69-
define('UserFrosting\BAKERY_SYSTEM_DIR', APP_DIR_NAME . DS . 'system' . DS . 'Bakery' . DS . 'Command');
70-
71-
// Full path to frontend vendor asset directories
72-
define('UserFrosting\ASSET_DIR', APP_DIR_NAME . DS . ASSET_DIR_NAME);
73-
define('UserFrosting\NPM_ASSET_DIR', ASSET_DIR . DS . 'node_modules');
74-
define('UserFrosting\BROWSERIFIED_ASSET_DIR', ASSET_DIR . DS . 'browser_modules');
75-
define('UserFrosting\BOWER_ASSET_DIR', ASSET_DIR . DS . 'bower_components');

app/sprinkles/core/defines.php

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,43 @@
99

1010
namespace UserFrosting;
1111

12+
// Names of root directories
13+
define('UserFrosting\BUILD_DIR_NAME', 'build');
14+
define('UserFrosting\PUBLIC_DIR_NAME', 'public');
15+
16+
// Names of app directories
17+
define('UserFrosting\CACHE_DIR_NAME', 'cache');
18+
define('UserFrosting\DB_DIR_NAME', 'database');
19+
define('UserFrosting\LOG_DIR_NAME', 'logs');
20+
define('UserFrosting\SESSION_DIR_NAME', 'sessions');
21+
define('UserFrosting\VENDOR_DIR_NAME', 'vendor');
22+
1223
// Names of directories within Sprinkles
13-
define('UserFrosting\MIGRATIONS_DIR', SRC_DIR_NAME . DS . 'Database' . DS . 'Migrations');
14-
define('UserFrosting\SEEDS_DIR', SRC_DIR_NAME . DS . 'Database' . DS . 'Seeds');
24+
define('UserFrosting\ASSET_DIR_NAME', 'assets');
25+
define('UserFrosting\EXTRA_DIR_NAME', 'extra');
26+
define('UserFrosting\CONFIG_DIR_NAME', 'config');
27+
define('UserFrosting\LOCALE_DIR_NAME', 'locale');
28+
define('UserFrosting\ROUTE_DIR_NAME', 'routes');
29+
define('UserFrosting\SCHEMA_DIR_NAME', 'schema');
30+
define('UserFrosting\TEMPLATE_DIR_NAME', 'templates');
31+
define('UserFrosting\FACTORY_DIR_NAME', 'factories');
32+
33+
// Full path to database directory (SQLite only)
34+
define('UserFrosting\DB_DIR', APP_DIR . DS . DB_DIR_NAME);
35+
36+
// Full path to storage directories
1537
define('UserFrosting\STORAGE_DIR', APP_DIR . DS . 'storage');
1638
define('UserFrosting\STORAGE_PUBLIC_DIR', PUBLIC_DIR_NAME . DS . 'files');
39+
40+
// Full path to Composer's vendor directory
41+
define('UserFrosting\VENDOR_DIR', APP_DIR . DS . VENDOR_DIR_NAME);
42+
43+
// Full path to frontend vendor asset directories
44+
define('UserFrosting\ASSET_DIR', APP_DIR . DS . ASSET_DIR_NAME);
45+
define('UserFrosting\NPM_ASSET_DIR', ASSET_DIR . DS . 'node_modules');
46+
define('UserFrosting\BROWSERIFIED_ASSET_DIR', ASSET_DIR . DS . 'browser_modules');
47+
define('UserFrosting\BOWER_ASSET_DIR', ASSET_DIR . DS . 'bower_components');
48+
49+
// Relative path from within sprinkle directory
50+
define('UserFrosting\MIGRATIONS_DIR', SRC_DIR_NAME . DS . 'Database' . DS . 'Migrations');
51+
define('UserFrosting\SEEDS_DIR', SRC_DIR_NAME . DS . 'Database' . DS . 'Seeds');

app/sprinkles/core/src/Bakery/BuildAssets.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
5454
$this->checkNodeVersion(false);
5555
$this->checkNpmVersion(false);
5656

57-
// Set $path
57+
// Set $buildPath. We'll use the aboslute path for this task
5858
$this->buildPath = \UserFrosting\ROOT_DIR . \UserFrosting\DS . \UserFrosting\BUILD_DIR_NAME;
5959

6060
// Delete cached data is requested

app/sprinkles/core/src/Core.php

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ public static function getSubscribedEvents()
4444
return [
4545
'onSprinklesInitialized' => ['onSprinklesInitialized', 0],
4646
'onSprinklesRegisterServices' => ['onSprinklesRegisterServices', 0],
47-
'onAddGlobalMiddleware' => ['onAddGlobalMiddleware', 0]
47+
'onAddGlobalMiddleware' => ['onAddGlobalMiddleware', 0],
48+
'onAppInitialize' => ['onAppInitialize', 0]
4849
];
4950
}
5051

@@ -103,6 +104,16 @@ public function onSprinklesRegisterServices()
103104
$sh->register();
104105
}
105106

107+
/**
108+
* Register routes
109+
*
110+
* @param Event $event
111+
*/
112+
public function onAppInitialize(Event $event)
113+
{
114+
$this->ci->router->loadRoutes($event->getApp());
115+
}
116+
106117
/**
107118
* Add CSRF middleware.
108119
*
@@ -122,19 +133,22 @@ protected function registerStreams()
122133
$locator = $this->ci->locator;
123134

124135
// Register core locator shared streams
125-
$locator->registerStream('cache', '', \UserFrosting\APP_DIR_NAME . \UserFrosting\DS . \UserFrosting\CACHE_DIR_NAME, true);
126-
$locator->registerStream('config', '', \UserFrosting\DS . \UserFrosting\CONFIG_DIR_NAME);
127-
$locator->registerStream('log', '', \UserFrosting\APP_DIR_NAME . \UserFrosting\DS . \UserFrosting\LOG_DIR_NAME, true);
128-
$locator->registerStream('migrations', '', \UserFrosting\MIGRATIONS_DIR);
129-
$locator->registerStream('seeds', '', \UserFrosting\SEEDS_DIR);
130-
$locator->registerStream('session', '', \UserFrosting\APP_DIR_NAME . \UserFrosting\DS . \UserFrosting\SESSION_DIR_NAME, true);
136+
$locator->registerStream('cache', '', \UserFrosting\APP_DIR . \UserFrosting\DS . \UserFrosting\CACHE_DIR_NAME, true);
137+
$locator->registerStream('log', '', \UserFrosting\APP_DIR . \UserFrosting\DS . \UserFrosting\LOG_DIR_NAME, true);
138+
$locator->registerStream('session', '', \UserFrosting\APP_DIR . \UserFrosting\DS . \UserFrosting\SESSION_DIR_NAME, true);
131139

132140
// Register core locator sprinkle streams
133-
$locator->registerStream('extra', '', \UserFrosting\DS . \UserFrosting\EXTRA_DIR_NAME);
134-
$locator->registerStream('factories', '', \UserFrosting\DS . \UserFrosting\FACTORY_DIR_NAME);
135-
$locator->registerStream('locale', '', \UserFrosting\DS . \UserFrosting\LOCALE_DIR_NAME);
136-
$locator->registerStream('routes', '', \UserFrosting\DS . \UserFrosting\ROUTE_DIR_NAME);
137-
$locator->registerStream('schema', '', \UserFrosting\DS . \UserFrosting\SCHEMA_DIR_NAME);
138-
$locator->registerStream('templates', '', \UserFrosting\DS . \UserFrosting\TEMPLATE_DIR_NAME);
141+
$locator->registerStream('config', '', \UserFrosting\CONFIG_DIR_NAME);
142+
$locator->registerStream('extra', '', \UserFrosting\EXTRA_DIR_NAME);
143+
$locator->registerStream('factories', '', \UserFrosting\FACTORY_DIR_NAME);
144+
$locator->registerStream('locale', '', \UserFrosting\LOCALE_DIR_NAME);
145+
$locator->registerStream('routes', '', \UserFrosting\ROUTE_DIR_NAME);
146+
$locator->registerStream('schema', '', \UserFrosting\SCHEMA_DIR_NAME);
147+
$locator->registerStream('templates', '', \UserFrosting\TEMPLATE_DIR_NAME);
148+
149+
// Register core sprinkle class streams
150+
$locator->registerStream('seeds', '', \UserFrosting\SEEDS_DIR);
151+
$locator->registerStream('migrations', '', \UserFrosting\MIGRATIONS_DIR);
152+
139153
}
140154
}

app/sprinkles/core/src/ServicesProvider/ServicesProvider.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public function register(ContainerInterface $container)
128128
$locator->registerStream('assets', 'vendor', \UserFrosting\BOWER_ASSET_DIR, true);
129129
$locator->registerStream('assets', 'vendor', \UserFrosting\NPM_ASSET_DIR, true);
130130
$locator->registerStream('assets', 'vendor', \UserFrosting\BROWSERIFIED_ASSET_DIR, true);
131-
$locator->registerStream('assets', '', \UserFrosting\DS . \UserFrosting\ASSET_DIR_NAME);
131+
$locator->registerStream('assets', '', \UserFrosting\ASSET_DIR_NAME);
132132

133133
$baseUrl = $config['site.uri.public'] . '/' . $config['assets.raw.path'];
134134

@@ -698,8 +698,9 @@ public function register(ContainerInterface $container)
698698
$sprinkles = $c->sprinkleManager->getSprinkleNames();
699699

700700
// Add Sprinkles' templates namespaces
701+
// TODO : Use locator
701702
foreach ($sprinkles as $sprinkle) {
702-
$path = \UserFrosting\SPRINKLES_DIR . \UserFrosting\DS .
703+
$path = \UserFrosting\APP_DIR . \UserFrosting\DS . \UserFrosting\SPRINKLES_DIR_NAME . \UserFrosting\DS .
703704
$sprinkle . \UserFrosting\DS .
704705
\UserFrosting\TEMPLATE_DIR_NAME . \UserFrosting\DS;
705706

app/system/Sprinkle/SprinkleManager.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class SprinkleManager
3434
protected $sprinkles = [];
3535

3636
/**
37-
* @var string The full absolute base path to the sprinkles directory.
37+
* @var string Relaive path to the sprinkles directory. Will be used to register the location with the ResourceLocator
3838
*/
3939
protected $sprinklesPath = \UserFrosting\SPRINKLES_DIR . \UserFrosting\DS;
4040

@@ -60,7 +60,7 @@ public function addResources()
6060
}
6161

6262
/**
63-
* Register a sprinkle as a locator location
63+
* Register a sprinkle as a locator location, using relative path to the sprinkle
6464
* @param string $sprinkleName
6565
*/
6666
public function addSprinkleResources($sprinkleName)
@@ -85,12 +85,13 @@ public function getSprinklePath($sprinkleName)
8585
}
8686

8787
// Get path and make sure it exist
88-
$path = $this->getSprinklesPath() . $sprinkle;
89-
if (!file_exists($path)) {
90-
throw new FileNotFoundException("Sprinkle `$sprinkleName` should be found at `$path`, but that directory doesn't exist.");
88+
$relPath = $this->getSprinklesPath() . $sprinkle;
89+
$fullpath = \UserFrosting\ROOT_DIR . \UserFrosting\DS . $relPath;
90+
if (!file_exists($fullpath)) {
91+
throw new FileNotFoundException("Sprinkle `$sprinkleName` should be found at `$fullpath`, but that directory doesn't exist.");
9192
}
9293

93-
return $path;
94+
return $relPath;
9495
}
9596

9697
/**

app/system/UserFrosting.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,6 @@ protected function setupApp()
149149

150150
$this->fireEvent('onAppInitialize', $slimAppEvent);
151151

152-
// Set up all routes
153-
$this->ci->router->loadRoutes($this->app);
154-
155152
// Add global middleware
156153
$this->fireEvent('onAddGlobalMiddleware', $slimAppEvent);
157154
}

app/tests/Unit/SprinkleManagerTest.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -134,16 +134,16 @@ public function testIsAvailable($sprinkleName, $isAvailable, SprinkleManager $sp
134134
/**
135135
* @depends testInitFromSchema
136136
* @param string $sprinkleName
137-
* @param bool $path
138137
* @param SprinkleManager $sprinkleManager
139-
* @testWith ["foo", "/data/foo"]
140-
* ["bar", "/data/bar"]
141-
* ["test", "/data/test"]
138+
* @testWith ["foo"]
139+
* ["bar"]
140+
* ["test"]
142141
*/
143-
public function testGetSprinklePath($sprinkleName, $path, SprinkleManager $sprinkleManager)
142+
public function testGetSprinklePath($sprinkleName, SprinkleManager $sprinkleManager)
144143
{
145-
$sprinkleManager->setSprinklesPath(__DIR__ . '/data/');
146-
$this->assertSame(__DIR__ . $path, $sprinkleManager->getSprinklePath($sprinkleName));
144+
$basePath = 'app/tests/Unit/data/';
145+
$sprinkleManager->setSprinklesPath($basePath);
146+
$this->assertSame($basePath . $sprinkleName, $sprinkleManager->getSprinklePath($sprinkleName));
147147
}
148148

149149
/**
@@ -154,7 +154,8 @@ public function testGetSprinklePath($sprinkleName, $path, SprinkleManager $sprin
154154
*/
155155
public function testGetSprinklePathWherePathDoesntExist(SprinkleManager $sprinkleManager)
156156
{
157-
$sprinkleManager->setSprinklesPath(__DIR__ . '/foo/');
157+
$basePath = 'app/tests/Unit/foo/';
158+
$sprinkleManager->setSprinklesPath($basePath);
158159
$sprinkleManager->getSprinklePath('foo');
159160
}
160161

@@ -193,7 +194,8 @@ class_alias('foo', 'UserFrosting\Sprinkle\Test\ServicesProvider\ServicesProvider
193194
*/
194195
public function testAddResources(SprinkleManager $sprinkleManager)
195196
{
196-
$sprinkleManager->setSprinklesPath(__DIR__ . '/data/');
197+
$basePath = 'app/tests/Unit/data/';
198+
$sprinkleManager->setSprinklesPath($basePath);
197199
$sprinkleManager->addResources();
198200
}
199201

build/before_install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ if [ "$DB" == "pgsql" ] ; then
2828
psql -c "GRANT ALL PRIVILEGES ON DATABASE userfrosting TO postgres;" -U postgres
2929
printf "UF_MODE=\"debug\"\nDB_DRIVER=\"pgsql\"\nDB_HOST=\"localhost\"\nDB_PORT=\"5432\"\nDB_NAME=\"userfrosting\"\nDB_USER=\"postgres\"\nDB_PASSWORD=\"\"\nTEST_DB=\"default\"\n" > app/.env
3030
fi
31-
s
31+
3232
#
3333
# set up sqlite
3434
#

0 commit comments

Comments
 (0)