The Australian Government coat of Arms

Communities of practice

Communities of practice

Pancake from the CLI

I am trying to use pancake to set my npmOrg from the CLI and even though I have installed the module via npm and it appears to have been successful, I am getting a message that ‘pancake’ does not exist or is not recognized.

Being that the docs are not very clear about whether or not you have to set up scripts, I am turning to this forum for some help. Here’s my package.json below. What am I missing that it won’t allow me to run pancake from the CLI?

{
  "name": "auds",
  "version": "1.0.0",
  "description": "AUDS components",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "postinstall": "pancake"
  },
  "author": "",
  "license": "MIT",
  "devDependencies": {},
  "pancake": {
    "auto-save": true,
    "plugins": true,
    "ignore": [],
    "json": {
      "enable": false,
      "location": "pancake/",
      "name": "pancake",
      "content": {
        "name": true,
        "version": true,
        "dependencies": true,
        "path": true,
        "settings": true
      }
    },
    "css": {
      "minified": true,
      "modules": false,
      "browsers": [
        "last 2 versions",
        "ie 8",
        "ie 9",
        "ie 10"
      ],
      "location": "pancake/css/",
      "name": "pancake.min.css"
    },
    "sass": {
      "modules": false,
      "location": "pancake/sass/",
      "name": "pancake.scss"
    }
  },
  "dependencies": {
    "@gov.au/core": "^3.4.2",
    "@gov.au/pancake": "^1.4.1"
  }
}

Potentially found my answer on the Pancake NPM repo under bullet item #3

I was looking to set my npmOrg globally. I achieved this via my package.json:

 "scripts": {
     "setOrg": "pancake --set npmOrg @orgName",
}

This doesn’t seem like the most elegant way, however can someone maybe explain the intent of this option? I think I understand the purpose, but can anyone clarify what setting the npmOrg scope actually does?

Also, to clarify, is ‘Pancake’ not able to be used directly from the CLI? Does it have to be placed in the script object of the package json to work?

Thanks in advance!

hey @jamitchell87,

Yea this is probably our fault, our docs need to be updated. I believe the reason you are getting that error is because only globally installed packages can be executed by typing just their name.

If you want to run pancake from the CLI you’ll want to try either one of

npx pancake --set npmOrg @orgName

or

./node_modules/.bin/pancake --set npmOrg @orgName

I believe this option lets pancake know which org to look for modules under.

For example, if you did

npx pancake --set npmOrg @digital.nsw

and then did

@npm i @gov.au/body

The module would not be found, since you are looking only under the @digital.nsw scope. So this setting should be set in accordance to the npm org that you are publishing your module under.

I hope this makes some sense, my knowledge of pancake isn’t the best :sweat_smile: . Let me know if you have any other questions.

Raj

1 Like