Skip to content

Commit

Permalink
add production flag to deploynodeapp
Browse files Browse the repository at this point in the history
  • Loading branch information
noahdietz committed Oct 12, 2017
1 parent b56cb38 commit 3704914
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ for organization name, all of which are required.
`--resolve-modules -R`
(optional) If the API proxy includes Node.js modules (e.g., in a `node_modules` directory), this option updates them on Apigee Edge without uploading them from your system. Basically, it's like running "npm install" on Apigee Edge in the root directory of the API proxy bundle.

`--production`
(optional) Indicates if Apigee Edge should use the `--production` flag during `npm install`. Defaults to `true`, example of disabling the flag would be `--production false`.

`--upload-modules -U`
(optional) If specified, uploads Node.js modules from your system to Apigee Edge rather than resolving the modules directly on Apigee Edge (the default behavior).

Expand Down
20 changes: 13 additions & 7 deletions lib/commands/deploynodeapp.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ var descriptor = defaults.defaultDescriptor({
name: 'Wait N seconds after importing proxy before deploying',
shortOption: 'W',
required: false
},
'production': {
name: 'Run resolve modules with npm install --production, default true',
required: false
}
});
module.exports.descriptor = descriptor;
Expand Down Expand Up @@ -594,18 +598,20 @@ function runNpm(opts, request, done) {
console.log('Running "npm install" at Apigee. This may take several minutes.');
}

var body = {
command: 'install'
};
var installURI = util.format('%s/v1/o/%s/apis/%s/revisions/%d/npm?command=install',
opts.baseuri, opts.organization, opts.api, opts.deploymentVersion)

if (opts.production === 'false') {
installURI = util.format("%s&production=false", installURI)
}

if (opts.debug) {
body.verbose = true;
installURI = util.format("%s&verbose=true", installURI)
}

request({
uri: util.format('%s/v1/o/%s/apis/%s/revisions/%d/npm',
opts.baseuri, opts.organization, opts.api, opts.deploymentVersion),
uri: installURI,
method: 'POST',
form: body,
headers: {
'Accept': 'text/plain'
},
Expand Down

0 comments on commit 3704914

Please sign in to comment.