Skip to content

Instantly share code, notes, and snippets.

@fgrilli
Last active April 5, 2016 10:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fgrilli/7283d91fcb140e611fdc7f8e2e5abfa3 to your computer and use it in GitHub Desktop.
Save fgrilli/7283d91fcb140e611fdc7f8e2e5abfa3 to your computer and use it in GitHub Desktop.

NPM module with dependencies on @magnolia/cli and @magnolia/jumpstart

  • mkdir my-project && cd my-project
  • npm init
  • npm install @magnolia/cli @magnolia/jumpstart --save
  • this will make dependencies scripts (those declared in the bin section) available to the client module (see bin part at https://docs.npmjs.com/files/package.json)
  • edit package.json and add a scripts section, e.g.
"scripts": {
	"setup-magnolia": "setup-magnolia", 
	"add-page": "add-page",
	"add-component": "add-component"
 }
  • run npm run setup-magnolia
  • will download Magnolia, prepare it for light development and start it up
  • create pages and stuff, e.g npm run add-page home
  • if dependencies are installed globally e.g. npm install @magnolia/cli -g then one can run commands like shell scripts e.g. add-page home without the npm run bit
  • there may be drawbacks to this approach having to do with update dependencies and possibly overwriting of existing global commands

Pro:

Contra:

  • one needs to setup package.json manually and adds the needed bits, unless we can automate this with some postinstall script magic

Non NPM Project taking advantage of @magnolia/cli

This is the approach used lately by Tomas and which seems the simplest and most promising Video

  • mkdir my-project && cd my-project
  • npm install @magnolia/cli
  • cd cli && npm install
  • this will prepare the cli module, for instance replace package.json
  • edit package.json if necessary
  • run npm start
  • this will download tomcat bundle and prepare it for light dev
  • run commands to create pages and other stuff

Pro:

  • works and it's pretty much done, polishing apart. It also includes the download Magnolia part which would basically make jumpstart module redunant

Contra:

  • need to run npm install twice, once to install the cli module proper, then from the cli folder itself to complete the installation
  • does not look like the "recommended" way to use npm modules providing commands
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment