Skip to content

Commit

Permalink
Merge pull request #81 from danfuzz/unbox-options
Browse files Browse the repository at this point in the history
Add new options, prepare for 4.2.0 release
  • Loading branch information
danfuzz authored Dec 23, 2016
2 parents 3fdf64b + 9289e57 commit 671354a
Show file tree
Hide file tree
Showing 6 changed files with 152 additions and 6 deletions.
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ npmbox is intended to be a proof of concept with regards to this issue filled ag

## npmbox news

UPDATE for v.next.
UPDATE December 22, 2016: v4.2.0 of npmbox is out.
* Support for accepting a `package.json` file when boxing. This will cause its
dependencies to get boxed.
* Start using a temporary directory instead of the CWD for temporary files and
Expand All @@ -22,6 +22,12 @@ UPDATE for v.next.
box contents for dependencies. This can be used to install a local package
(from the filesystem) while using a box for dependencies, e.g.
`cd path/to/my/package; npmunbox --install=. path/to/box.npmbox`
* New unbox option `--scripts` to enable running of scripts. (By default,
npmbox acts like `--ignore-scripts` was specified.)
* New options `--proxy` and `--https-proxy` which pass through to the
underlying `npm` invocation. Works on both `npmbox` and `npmunbox`. In the
latter case, this can help prevent unboxing from inadvertently hitting the
network (by specifying nonexistent proxies).

UPDATE December 21, 2016: v4.1.0 of npmbox is out.
* Support for running npmbox on a top-level local package, e.g.
Expand Down Expand Up @@ -57,6 +63,8 @@ Given some package, like `express` this command will create a archive file of th
-v, --verbose Shows npm output which is normally hidden.
-s, --silent Shows no output whatsoever.
-t, --target Specify the .npmbox file to write.
--proxy=<url> npm --proxy switch.
--https-proxy=<url> npm --https-proxy switch.

You must specify at least one package. Packages can be anything accepted as
an argument to `npm install`, and can also be a local path to a `.json` file,
Expand Down Expand Up @@ -88,13 +96,16 @@ Given some .npmbox file (must end with the .npmbox extension), installs the cont
-s, --silent Shows additional output which is normally hidden.
-p, --path Specify the path to a folder from which the .npmbox file(s) will be read.
-i, --install=<pkg> Installs the indicated package instead of using the .npmbox manifest.
--scripts Enable running of scripts during installation.
-g, --global Installs package globally as if --global was passed to npm.
-C, --prefix npm --prefix switch.
-S, --save npm --save switch.
-D, --save-dev npm --save-dev switch.
-O, --save-optional npm --save-optional switch.
-B, --save-bundle npm --save-bundle switch.
-E, --save-exact npm --save-exact switch.
--proxy=<url> npm --proxy switch.
--https-proxy=<url> npm --https-proxy switch.

You must specify at least one file.

Expand Down
119 changes: 118 additions & 1 deletion npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion npmbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
var boxxer = require("./npmboxxer.js");

var argv = require("optimist")
.string([
"proxy",
"https-proxy"
])
.boolean(["v","verbose","s","silent"])
.options("t", {
alias: "target",
Expand All @@ -29,14 +33,18 @@ if (args.length<1 || argv.help) {
console.log(" -v, --verbose Shows additional output which is normally hidden.");
console.log(" -s, --silent Hide all output.");
console.log(" -t, --target Specify the target .npmbox file to write.");
console.log(" --proxy=<url> npm --proxy switch.");
console.log(" --https-proxy=<url> npm --https-proxy switch.");
console.log("");
process.exit(0);
}

var options = {
verbose: argv.v || argv.verbose || false,
silent: argv.s || argv.silent || false,
target: argv.t || argv.target || null
target: argv.t || argv.target || null,
proxy: argv.proxy || null,
"https-proxy": argv["https-proxy"] || null
};

var sources = args;
Expand Down
3 changes: 2 additions & 1 deletion npmboxxer.js
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,8 @@
"ignore-scripts": true,
loglevel: options && options.verbose ? "http" : "silent"
};
if (options.proxy) npmoptions.proxy = options.proxy;
if (options["https-proxy"]) npmoptions["https-proxy"] = options["https-proxy"];

npmInit(npmoptions,function(err){
if (err) return done(err);
Expand Down Expand Up @@ -404,7 +406,6 @@
options.loglevel = options.verbose ? "verbose" : "silent";
options.progress = false;
options.color = false;
options["ignore-scripts"] = true;
options["cache-min"] = 1000 * 365.25 * 24 * 60 * 60; // a thousand years
options["fetch-retries"] = 0;
options["fetch-retry-factor"] = 0;
Expand Down
11 changes: 10 additions & 1 deletion npmunbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@ var utils = require("./utils");

var argv = require("optimist")
.string([
"C","prefix"
"C","prefix",
"proxy",
"https-proxy"
])
.boolean([
"v","verbose",
"s","silent",
"g","global",
"scripts",
"S","save",
"D","save-dev",
"O","save-optional",
Expand Down Expand Up @@ -46,13 +49,16 @@ if (args.length<1 || argv.help) {
console.log(" -s, --silent Hide all output.");
console.log(" -p, --path Specify the path to a folder from which the .npmbox file(s) will be read.");
console.log(" -i, --install=<pkg> Installs the indicated package instead of using the .npmbox manifest.");
console.log(" --scripts Enable running of scripts during installation.");
console.log(" -g, --global Installs package(s) globally as if --global was passed to npm.");
console.log(" -C, --prefix npm --prefix switch.");
console.log(" -S, --save npm --save switch.");
console.log(" -D, --save-dev npm --save-dev switch.");
console.log(" -O, --save-optional npm --save-optional switch.");
console.log(" -B, --save-bundle npm --save-bundle switch.");
console.log(" -E, --save-exact npm --save-exact switch.");
console.log(" --proxy=<url> npm --proxy switch.");
console.log(" --https-proxy=<url> npm --https-proxy switch.");
console.log("");
process.exit(0);
}
Expand All @@ -66,9 +72,12 @@ var options = {
"save-optional": argv.O || argv["save-optional"] || false,
"save-bundle": argv.B || argv["save-bundle"] || false,
"save-exact": argv.E || argv["save-exact"] || false,
"ignore-scripts": !argv.scripts,
path: argv.p || argv.path || false
};
if (argv.C || argv.prefix) options.prefix = argv.C || argv.prefix;
if (argv.proxy) options.proxy = argv.proxy;
if (argv["https-proxy"]) options["https-proxy"] = argv["https-proxy"];

var errorCount = 0;
var sources = args.filter(function(source){
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"unbox"
],
"description": "npm addon utility for creating and installing from an archive file of an npm install, including dependencies.",
"version": "4.1.0",
"version": "4.2.0",
"homepage": "http://github.com/arei/npmbox",
"bugs": {
"url": "http://github.com/arei/npmbox/issues"
Expand Down

0 comments on commit 671354a

Please sign in to comment.