This boilerplate is a minimal starting point for Apostrophe 2 projects built by CloudRaker.
npm install -g apostrophe-cli && \
apostrophe create-project <shortname-without-spaces> --boilerplate https://github.com/CloudRaker/apostrophe-boilerplate.git
To get started, we recommend taking a look at the guide to create your first Apostrophe project. You could also take a look at Apostrophe's CLI or simply fork this repository.
- Node Version Manager.
- This project requires **Node >=8 <10 **.
- You can check which version of Node is currently in use by running
nvm current
in a Terminal instance. - In the case you have a different version running, you can install the latest v8.x by running
nvm install 8
.
The following components can be installed with Brew, if they are not already available on your machine:
- MongoDB
brew install mongodb
- Redis
brew install redis
At this point, start the services by running these commands one at a time:
- Start Mongodb
brew services start mongodb
- Start Redis
brew services start redis
With Apostrophe installed, the first thing to do create an admin user account so you're able to log into the CMS. Run the following command (this will prompt you for a password).
node app.js apostrophe-users:add admin admin
Now you're all set!
- Run
npm run start
in a Terminal instance to start up the local server. - Head to
localhost:3000
in your web browser.
Once the project is cloned and once the Node modules are installed, it might be a good idea to update the dependencies
and devDependencies
list package.json
so that the project is explicitly depending on the latest versions.
You may run npm outdated
to easily obtain a list of outdated packages.
There are a few scripts available in the package.json
:
npm run start
: Starts the app and makes it visible atlocalhost:3000
in a browser.npm run debug
: TBDnpm run debug-monitor
: TBDnpm run dev
: Starts the app, and rebuilds/reloads when changes are made to files that are watched.npm run njk
: (Deprecated) Renames all*.html
files to*.njk
.
Apostrophe uses LESS as a CSS preprocessor. However, for our projects, we wish to use SASS. Also, we wish to use ES6, which is not available by default with Apostrophe projects.
In order to do so, Brunch was chosen to compile ES6 JavaScript and SASS files.
You most likely will not need to run this script directly, as it is used by the npm run dev
script. Contact a CloudRaker dev admin if you need more information.
With Apostrophe, you extend their modules and create new ones, all in the lib/modules
directory.
When creating new modules, the convention is to prefix their an abbreviation of the project name. For example:
cr-
for CloudRaker (e.g.cr-careers-pages
,cr-social-links-widgets
)
Not much is to be edited from the config located at ./apos-config.js
, but at least these elements should be:
aposOptions.shortName
: Currently set by default as'apostrophe-boilerplate'
, it should be set as the project name.aposOptions.modules.apostrophe-admin-bar
: The custom content should actually be customized.
Otherwise, the modules defined in the lib/modules
directory will be added by ...customModules
rest parameter at the end of the modules definition.
In order for this to work, you will need to replace ^custom-
in the customModuleNames
variable with the prefiix you chose in the last section (ex. ^cr-
)
const customModuleNames = fs.readdirSync(path.resolve(__dirname, 'lib', 'modules'))
.filter(dp => /^custom-/.test(dp));