Improve bootstrap flow of a Ghost application#1858
Conversation
|
Note for self: Use https://github.com/snowmantw/Fe to test that a non |
|
Aside from structural improvements this PR introduces the ability for a Ghost blog to define where the content directory resides. This is a step towards enabling Ghost to be used as a npm module. I'm currently taking advantage of this PR for my own blog. Let's say you want to use Ghost as a npm module, and want the Create a repo with the following files (as I have in my blog repo: content/ config.js Of particular interest is the new top-level property So this means that you can make this configuration: Assigning the location of the contentPath to exist where you desire, in this case relative to your index.js package.json My I'm using the GitHub dependency format for the moment as Ghost is not yet published on npm. Another big caveot: because Ghost requires compiling the admin assets I actually do this within the module and upload those contents directly. This is one issue that is noted in #2078. Hope this helps clarify! |
|
Will merge just as soon as the build passes 👍 |
|
Passing now on all except Postgres. Seems this commit does break postgres, and it's not just a fluke of travis. I don't have postgres installed locally to test it unfortunately (although I do need to get that set up). |
|
I'm pretty sure postgress is already mostly broken. I don't have it locally either yet. I'm just looking through all your comments and how the code has changed. One thing I don't understand... but easier to commend directly. |
addresses TryGhost#1789, TryGhost#1364 - Moves ./core/server/loader -> ./core/bootstrap. The bootstrap file is only accessed once during startup, and it’s sole job is to ensure a config.js file exists (creating one if it doesn’t) and then validates the contents of the config file. Since this is directly related to the initializing the application is is appropriate to have it in the ./core folder, named bootstrap as that is what it does. This also improves the dependency graph, as now the bootstrap file require’s the ./core/server/config module and is responsible for passing in the validated config file. Whereas before we had ./core/server/config require’ing ./core/server/loader and running its init code and then passing that value back to itself, the flow is now more straight forward of ./core/bootstrap handling initialization and then instatiation of config module - Merges ./core/server/config/paths into ./core/server/config This flow was always confusing me to that some config options were on the config object, and some were on the paths object. This change now incorporates all of the variables previously defined in config/paths directly into the config module, and in extension, the config.js file. This means that you now have the option of deciding at startup where the content directory for ghost should reside. - broke out loader tests in config_spec to bootstrap_spec - updated all relevant files to now use config().paths - moved urlFor and urlForPost function into ./server/config/url.js
Improve bootstrap flow of a Ghost application
addresses #1789, #1364
Moves ./core/server/loader -> ./core/bootstrap.
The bootstrap file is only accessed once during startup,
and it’s sole job is to ensure a config.js file exists
(creating one if it doesn’t) and then validates
the contents of the config file.
Since this is directly related to the initializing
the application is is appropriate to have
it in the ./core folder, named bootstrap as that
is what it does.
This also improves the dependency graph, as now
the bootstrap file require’s the ./core/server/config
module and is responsible for passing in the validated
config file.
Whereas before we had ./core/server/config
require’ing ./core/server/loader and running its
init code and then passing that value back to itself,
the flow is now more straight forward of
./core/bootstrap handling initialization and then
instatiation of config module
Merges ./core/server/config/paths into ./core/server/config
This flow was always confusing me to that some config
options were on the config object, and some were on
the paths object.
This change now incorporates all of the variables
previously defined in config/paths directly
into the config module, and in extension,
the config.js file.
This means that you now have the option of deciding
at startup where the content directory for ghost
should reside.
broke out loader tests in config_spec to bootstrap_spec
updated all relevant files to now use config().paths
moved urlFor and urlForPost function into
./server/config/url.js
💃