first commit

This commit is contained in:
s.golasch
2023-08-01 13:49:46 +02:00
commit 1fc239fd54
20238 changed files with 3112246 additions and 0 deletions

10
build/node_modules/http2-push-manifest/.editorconfig generated vendored Normal file
View File

@@ -0,0 +1,10 @@
root = true
[*]
charset = utf-8
indent_size = 2
indent_style = space
trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false

9
build/node_modules/http2-push-manifest/.jshintrc generated vendored Normal file
View File

@@ -0,0 +1,9 @@
{
"indent": 2,
"node": true,
"browser": true,
"esnext": true,
"bitwise": true,
"immed": true,
"noarg": true
}

2
build/node_modules/http2-push-manifest/.npmignore generated vendored Normal file
View File

@@ -0,0 +1,2 @@
node_modules
push_manifest.json

4
build/node_modules/http2-push-manifest/.travis.yml generated vendored Normal file
View File

@@ -0,0 +1,4 @@
language: node_js
node_js:
- "4"
- "node"

202
build/node_modules/http2-push-manifest/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,202 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright 2015 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

150
build/node_modules/http2-push-manifest/README.md generated vendored Normal file
View File

@@ -0,0 +1,150 @@
[![NPM version][npm-image]][npm-url]
[![Build status][travis-image]][travis-url]
[![Dependency Status][daviddm-image]][daviddm-url]
[![License][license-image]][license-url]
> A utility script for doing http2 push and/or preload.
Generates a list of **local static resources** used in your web app by outputting a json
file. This file can be read by your web server to more easily construct the
appropriate `Link: <URL>; rel=preload; as=<TYPE>` headers(s) for http2 push/preload.
## Install
npm install --save-dev http2-push-manifest
## Run tests
npm run test
## What's a push manifest?
> A **manifest is not required by the HTTP2 protocol**. We need it up! We found that it
is useful for telling your server what critical resources to push for the requesting page.
`http2-push-manifest` is a Node script for generating a JSON file listing
all of the static resources used on a page. It tries to discover the resources
in an .html file you specify. This file can be read by your web server to more
easily construct the appropriate `Link: <URL>; rel=preload` headers(s) used in
HTTP2 push. Since all the resources are discovered, you'll almost certainly want
to **prune the list of files that get pushed**. Pushing too much can actually [hurt
page load performance](https://twitter.com/ebidel/status/761016996339134464).
By default, the script generates `push_manifest.json` in the top level directory
of your app with a mapping of `<URL>: <PUSH_PROPERTIES>`. Feel free to add/remove
URLs from this list as necessary for your app or change the priority level.
Example of generated `push_manifest.json` with discovered local resources:
{
"/css/app.css": {
"type": "style",
"weight": 1
},
"/js/app.js": {
"type": "script",
"weight": 1
},
"/bower_components/webcomponentsjs/webcomponents-lite.js": {
"type": "script",
"weight": 1
},
"/bower_components/iron-selector/iron-selection.html": {
"type": "document",
"weight": 1
},
...
"/elements.html": {
"type": "document",
"weight": 1
},
"/elements.vulcanize.html": {
"type": "document",
"weight": 1
}
}
**Note**: as of now, no browser implements control over the priority/weight level.
## Examples
**Example** - list all the static resources of `app/index.html` (including sub-HTML Imports):
http2-push-manifest -f app/index.html
A single file produces the "single-file manifest format":
{
"/css/app.css": {
"type": "style",
"weight": 1
},
"/js/app.js": {
"type": "script",
"weight": 1
},
...
}
**Example** - list all the resources in `static/elements/elements.html`:
http2-push-manifest -f static/elements/elements.html
**Example** - list all the resources app/index.html and page.html, and combine
into a singe manifest:
http2-push-manifest -f app/index.html -f page.html
Using multiple files produces the "multi-file manifest format". Each key is the file
and it's sub-objects are the found resources. It would be up to your server to
decide how the mappings of key -> actual URL work.
{
"index.html": {
"/css/app.css": {
"type": "style",
"weight": 1
},
...
},
"page.html": {
"/css/page.css": {
"type": "style",
"weight": 1
},
...
}
}
**Example** - using a custom manifest filename:
http2-push-manifest -f path/to/site/index.html -m push.json
http2-push-manifest -f path/to/site/index.html --manifest push.json
## Usage on App Engine
If you're using App Engine for your server, check out [http2push-gae](https://github.com/GoogleChrome/http2push-gae). It leverages this manifest file format and automagically reads
`push_mainfest.json`, setting the `Link: rel="preload"` header for you.
Simply decorate your request handler like so:
```python
class Handler(http2.PushHandler):
@http2push.push('push_manifest.json')
def get(self):
# Resources in push_manifest.json will be server-pushed with this handler.
```
## License
[Apache 2.0](https://github.com/googlechrome/http2-push-manifest/blob/master/LICENSE) © 2015 Google Inc.
[npm-url]: https://www.npmjs.com/package/http2-push-manifest
[npm-image]: https://badge.fury.io/js/http2-push-manifest.svg
[travis-url]: https://travis-ci.org/GoogleChrome/http2-push-manifest
[travis-image]: https://travis-ci.org/GoogleChrome/http2-push-manifest.svg?branch=master
[daviddm-url]: https://david-dm.org/GoogleChrome/http2-push-manifest
[daviddm-image]: https://david-dm.org/GoogleChrome/http2-push-manifest.svg
[license-image]: https://img.shields.io/npm/l/http2-push-manifest.svg
[license-url]: LICENSE

View File

@@ -0,0 +1,184 @@
#!/usr/bin/env node
/**
* Copyright 2015 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// jshint node: true
'use strict';
let nopt = require('nopt');
let path = require('path');
let Manifest = require('../lib/manifest');
let pkg = require('../package.json');
const SCRIPT_NAME = path.basename(__filename);
const help = `${SCRIPT_NAME}: Generate a list of static resources for http2 push.
Usage:
${SCRIPT_NAME} -f path/to/file.html
${SCRIPT_NAME} -f path/to/file.html -f path/to/file2.html ...
Options:
-h|--help: print this message
-v|--version: print version number
-f|--file: file to discover resources in. Use multiple times to produce a mult-file manifest format.
-m|--manifest <filename>: Custom filename for the manifest file
Examples:
List all of the resources used in app/index.html, including sub-HTML Imports:
${SCRIPT_NAME} -f app/index.html
{
"/css/app.css": {
"type": "style",
"weight": 1
},
"/js/app.js": {
"type": "script",
"weight": 1
},
...
}
List all the resources used in static/elements/elements.html:
${SCRIPT_NAME} -f static/elements elements.html
List all the resources app/index.html and page.html, and combine into a singe manifest:
${SCRIPT_NAME} -f app/index.html -f page.html
{
"index.html": {
"/css/app.css": {
"type": "style",
"weight": 1
},
...
},
"page.html": {
"/css/page.css": {
"type": "style",
"weight": 1
},
...
}
}
Using a custom filename:
${SCRIPT_NAME} -f path/to/site/index.html -m push.json
${SCRIPT_NAME} -f path/to/site/index.html --manifest push.json
`;
function printHelp() {
console.log(help);
}
function printVersion() {
console.log(`${SCRIPT_NAME}:`, pkg.version);
}
function notifyIfUpdateAvailable() {
try {
let updateNotifier = require('update-notifier');
updateNotifier({pkg: pkg}).notify();
} catch(e) {
// noop
}
}
let jsonOutput = {};
function writeManifest(manifest, opt_content) {
manifest.write(opt_content);
console.log(`Wrote ${manifest.name}`);
}
function generateManifest(manifestName, files, singleFile) {
if (!files.length) {
let manifest = new Manifest({name: manifestName});
writeManifest(manifest, jsonOutput);
return;
}
let f = files[0];
// Make a path if one wasn't given. e.g. basic.html -> ./basic.html
if (f.indexOf(path.sep) === -1) {
f = `.${path.sep}${f}`;
}
let basePath = f.slice(0, f.lastIndexOf(path.sep))
let inputPath = f.slice(f.lastIndexOf(path.sep) + 1);
if (!basePath || !inputPath) {
printHelp();
process.exit(1);
}
let manifest = new Manifest({basePath, inputPath, name: manifestName});
manifest.generate().then(output => {
if (singleFile) {
writeManifest(manifest);
return;
}
jsonOutput[inputPath] = output.file;
// Remove processed file from list and proceed with next.
files.shift();
generateManifest(manifestName, files, singleFile);
}).catch(err => {
console.warn(err);
});
}
let args = nopt({
help: Boolean,
version: Boolean,
manifest: String,
file: [String, Array]
}, {
'h': ['--help'],
'v': ['--version'],
'm': ['--manifest'],
'f': ['--file']
});
let files = args.file || [];
let manifestName = args.manifest;
// let basePath = args.argv.remain[0];
// let inputPath = args.argv.remain[1];
if (args.version) {
printVersion();
process.exit(0);
}
if (args.help || !files.length) {
printHelp();
process.exit(0);
}
notifyIfUpdateAvailable(); // Let user know if there's a newer version.
generateManifest(manifestName, files, files.length < 2);

View File

@@ -0,0 +1,153 @@
/**
* Copyright 2015 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// jshint node: true
'use strict';
let fs = require('fs');
let hyd = require('hydrolysis');
let dom5 = require('dom5');
let url = require('url');
let path = require('path');
/**
* Swallows errors from Hydrolysis so ENOENT files don't throw errors.
* @class
* @extends {hydrolysis.FSResolver}
*/
class ErrorSwallowingFSResolver extends hyd.FSResolver {
constructor(config) {
super(config);
}
accept(uri, deferred) {
var reject = deferred.reject;
deferred.reject = arg => deferred.resolve('');
return super.accept(uri, deferred);
}
}
/**
* Finds and collects the static resources in a page.
* @class
*/
class ResourceList {
static get EXTERNAL_RESOURCE() {
return /^(?:https?:)?\/\//;
}
constructor(opts) {
this.basePath = opts.basePath;
let inputPath = opts.inputPath;
if (!inputPath || !this.basePath) {
console.error('Need input path!');
process.exit(1);
}
this.basePath = path.resolve(this.basePath);
inputPath = path.resolve(path.resolve(this.basePath, inputPath));
if (fs.statSync(inputPath).isDirectory()) {
inputPath = path.join(inputPath, 'index.html');
}
let loader = new hyd.Loader();
loader.addResolver(new ErrorSwallowingFSResolver({
root: this.basePath,
basePath: '/'
}));
// Ignore external resources.
loader.addResolver(new hyd.NoopResolver(ResourceList.EXTERNAL_RESOURCE));
this.analyzer = new hyd.Analyzer(false, loader);
this.inputPath = path.join('/', path.relative(this.basePath, inputPath));
}
treeToList(tree, accum) {
if (!accum) {
accum = [];
}
accum.push(tree.href);
}
styleToUrl(href, style) {
let src = dom5.getAttribute(style, 'href');
if (ResourceList.EXTERNAL_RESOURCE.test(src)) {
return;
}
if (src) {
return url.resolve(href, src);
}
}
scriptToUrl(href, script) {
let src = dom5.getAttribute(script, 'src');
if (ResourceList.EXTERNAL_RESOURCE.test(src)) {
return;
}
if (src) {
return url.resolve(href, src);
}
}
treeToUrls(tree, accum) {
if (!accum) {
accum = [];
}
if (!tree) {
return accum;
}
if (!tree.href) {
return accum;
}
accum.push(tree.href);
tree.imports.forEach(im => {
if (im.href) {
this.treeToUrls(im, accum);
}
});
tree.html.script.forEach(script => {
let u = this.scriptToUrl(tree.href, script);
if (u) {
accum.push(u);
}
});
tree.html.style.forEach(style => {
let u = this.styleToUrl(tree.href, style);
if (u) {
accum.push(u);
}
});
return accum;
}
list() {
return this.analyzer.metadataTree(this.inputPath).then(tree => {
let list = this.treeToUrls(tree).slice(1).reverse();
return list;
}).catch(err => {
console.error(err);
});
}
}
module.exports = ResourceList;

155
build/node_modules/http2-push-manifest/lib/manifest.js generated vendored Normal file
View File

@@ -0,0 +1,155 @@
/**
* Copyright 2015 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// jshint node: true
'use strict';
let fs = require('fs');
let path = require('path');
let ResourceList = require('./listresources');
/**
* Map of file extension to request type.
* See https://fetch.spec.whatwg.org/#concept-request-type
* @const
*/
const EXTENSION_TO_TYPE = {
'.css': 'style',
'.gif': 'image',
'.html': 'document',
'.png': 'image',
'.jpg': 'image',
'.js': 'script',
'.json': 'script',
'.svg': 'image',
'.webp': 'image',
'.woff': 'font',
'.woff2': 'font'
};
/**
* JSON manifest for push resources.
* @class
*/
class PushManifest {
// Single file format:
// {
// "/style.css": {
// "type": "style",
// "weight": 50
// },
// "/path/to/app.js": {
// "type": "script",
// "weight": 10
// }
// }
//
// The multi-file format is a superset of the single case:
// Multi-file format:
// {
// "/index.html": {
// "/style.css": {
// "type": "style",
// "weight": 50
// },
// "/path/to/app.js"; {
// "type": "script",
// "weight": 10
// }
// },
// "/page.html": {
// ...
// }
// }
// TODO: node 4.1.2 doesn't support default function args yet.
constructor(opts) {
opts = opts || {};
this.name = opts.name || this.DEFAULT_MANIFEST_NAME;
this.basePath = opts.basePath;
this.inputPath = opts.inputPath;
if (this.basePath && this.inputPath) {
this.resourceList = new ResourceList(opts);
}
}
get DEFAULT_MANIFEST_NAME() {
return 'push_manifest.json';
}
get PUSH_PRIORITY() {
return 1; // TODO: this gives every resource priority 1.
}
/**
* Generates the JSON format listing the inputs resources.
*
* @return {Promise({urls, fileContent}) The list of urls and generated JSON.
*/
generate() {
if (!this.resourceList) {
console.warn('Cannot generate resources. You did not provide an inputPath/basePath.');
}
return this.resourceList.list().then(urls => {
console.log(`Found ${urls.length} resource URLs in ${this.inputPath}:`);
/* jshint ignore:start */
for (let i = 0, url; url = urls[i]; ++i) {
console.log(' ', url);
}
/* jshint ignore:end */
let priorityMapping = {};
urls.map((url, i) => {
priorityMapping[url] = {
weight: this.PUSH_PRIORITY
};
var type = EXTENSION_TO_TYPE[path.extname(url)];
priorityMapping[url].type = type ? type : '';
});
this.fileContent = priorityMapping;
// TODO: node 4.2.1 doesnt support ... spread operator.
return {urls: urls, file: this.fileContent};
});
}
/**
* Writes the manifest.
*
* @param {Promise} Optional file content to write. By default, the content
* from calling generate() is used.
*/
write(opt_fileContent) {
let fileContent = opt_fileContent || this.fileContent;
fs.writeFile(this.name, JSON.stringify(fileContent, null, 2), err => {
if (err) {
return console.log(err);
}
});
}
}
module.exports = PushManifest;

View File

@@ -0,0 +1 @@
../latest-version/cli.js

View File

@@ -0,0 +1 @@
../repeating/cli.js

View File

@@ -0,0 +1,65 @@
'use strict';
function assembleStyles () {
var styles = {
modifiers: {
reset: [0, 0],
bold: [1, 22], // 21 isn't widely supported and 22 does the same thing
dim: [2, 22],
italic: [3, 23],
underline: [4, 24],
inverse: [7, 27],
hidden: [8, 28],
strikethrough: [9, 29]
},
colors: {
black: [30, 39],
red: [31, 39],
green: [32, 39],
yellow: [33, 39],
blue: [34, 39],
magenta: [35, 39],
cyan: [36, 39],
white: [37, 39],
gray: [90, 39]
},
bgColors: {
bgBlack: [40, 49],
bgRed: [41, 49],
bgGreen: [42, 49],
bgYellow: [43, 49],
bgBlue: [44, 49],
bgMagenta: [45, 49],
bgCyan: [46, 49],
bgWhite: [47, 49]
}
};
// fix humans
styles.colors.grey = styles.colors.gray;
Object.keys(styles).forEach(function (groupName) {
var group = styles[groupName];
Object.keys(group).forEach(function (styleName) {
var style = group[styleName];
styles[styleName] = group[styleName] = {
open: '\u001b[' + style[0] + 'm',
close: '\u001b[' + style[1] + 'm'
};
});
Object.defineProperty(styles, groupName, {
value: group,
enumerable: false
});
});
return styles;
}
Object.defineProperty(module, 'exports', {
enumerable: true,
get: assembleStyles
});

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -0,0 +1,90 @@
{
"_from": "ansi-styles@^2.2.1",
"_id": "ansi-styles@2.2.1",
"_inBundle": false,
"_integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=",
"_location": "/http2-push-manifest/ansi-styles",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "ansi-styles@^2.2.1",
"name": "ansi-styles",
"escapedName": "ansi-styles",
"rawSpec": "^2.2.1",
"saveSpec": null,
"fetchSpec": "^2.2.1"
},
"_requiredBy": [
"/http2-push-manifest/chalk"
],
"_resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz",
"_shasum": "b432dd3358b634cf75e1e4664368240533c1ddbe",
"_spec": "ansi-styles@^2.2.1",
"_where": "/Users/asciidisco/Desktop/asciidisco.com/build/node_modules/http2-push-manifest/node_modules/chalk",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"bugs": {
"url": "https://github.com/chalk/ansi-styles/issues"
},
"bundleDependencies": false,
"deprecated": false,
"description": "ANSI escape codes for styling strings in the terminal",
"devDependencies": {
"mocha": "*"
},
"engines": {
"node": ">=0.10.0"
},
"files": [
"index.js"
],
"homepage": "https://github.com/chalk/ansi-styles#readme",
"keywords": [
"ansi",
"styles",
"color",
"colour",
"colors",
"terminal",
"console",
"cli",
"string",
"tty",
"escape",
"formatting",
"rgb",
"256",
"shell",
"xterm",
"log",
"logging",
"command-line",
"text"
],
"license": "MIT",
"maintainers": [
{
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
{
"name": "Joshua Appelman",
"email": "jappelman@xebia.com",
"url": "jbnicolai.com"
}
],
"name": "ansi-styles",
"repository": {
"type": "git",
"url": "git+https://github.com/chalk/ansi-styles.git"
},
"scripts": {
"test": "mocha"
},
"version": "2.2.1"
}

View File

@@ -0,0 +1,86 @@
# ansi-styles [![Build Status](https://travis-ci.org/chalk/ansi-styles.svg?branch=master)](https://travis-ci.org/chalk/ansi-styles)
> [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code#Colors_and_Styles) for styling strings in the terminal
You probably want the higher-level [chalk](https://github.com/chalk/chalk) module for styling your strings.
![](screenshot.png)
## Install
```
$ npm install --save ansi-styles
```
## Usage
```js
var ansi = require('ansi-styles');
console.log(ansi.green.open + 'Hello world!' + ansi.green.close);
```
## API
Each style has an `open` and `close` property.
## Styles
### Modifiers
- `reset`
- `bold`
- `dim`
- `italic` *(not widely supported)*
- `underline`
- `inverse`
- `hidden`
- `strikethrough` *(not widely supported)*
### Colors
- `black`
- `red`
- `green`
- `yellow`
- `blue`
- `magenta`
- `cyan`
- `white`
- `gray`
### Background colors
- `bgBlack`
- `bgRed`
- `bgGreen`
- `bgYellow`
- `bgBlue`
- `bgMagenta`
- `bgCyan`
- `bgWhite`
## Advanced usage
By default you get a map of styles, but the styles are also available as groups. They are non-enumerable so they don't show up unless you access them explicitly. This makes it easier to expose only a subset in a higher-level module.
- `ansi.modifiers`
- `ansi.colors`
- `ansi.bgColors`
###### Example
```js
console.log(ansi.colors.green.open);
```
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)

View File

@@ -0,0 +1,116 @@
'use strict';
var escapeStringRegexp = require('escape-string-regexp');
var ansiStyles = require('ansi-styles');
var stripAnsi = require('strip-ansi');
var hasAnsi = require('has-ansi');
var supportsColor = require('supports-color');
var defineProps = Object.defineProperties;
var isSimpleWindowsTerm = process.platform === 'win32' && !/^xterm/i.test(process.env.TERM);
function Chalk(options) {
// detect mode if not set manually
this.enabled = !options || options.enabled === undefined ? supportsColor : options.enabled;
}
// use bright blue on Windows as the normal blue color is illegible
if (isSimpleWindowsTerm) {
ansiStyles.blue.open = '\u001b[94m';
}
var styles = (function () {
var ret = {};
Object.keys(ansiStyles).forEach(function (key) {
ansiStyles[key].closeRe = new RegExp(escapeStringRegexp(ansiStyles[key].close), 'g');
ret[key] = {
get: function () {
return build.call(this, this._styles.concat(key));
}
};
});
return ret;
})();
var proto = defineProps(function chalk() {}, styles);
function build(_styles) {
var builder = function () {
return applyStyle.apply(builder, arguments);
};
builder._styles = _styles;
builder.enabled = this.enabled;
// __proto__ is used because we must return a function, but there is
// no way to create a function with a different prototype.
/* eslint-disable no-proto */
builder.__proto__ = proto;
return builder;
}
function applyStyle() {
// support varags, but simply cast to string in case there's only one arg
var args = arguments;
var argsLen = args.length;
var str = argsLen !== 0 && String(arguments[0]);
if (argsLen > 1) {
// don't slice `arguments`, it prevents v8 optimizations
for (var a = 1; a < argsLen; a++) {
str += ' ' + args[a];
}
}
if (!this.enabled || !str) {
return str;
}
var nestedStyles = this._styles;
var i = nestedStyles.length;
// Turns out that on Windows dimmed gray text becomes invisible in cmd.exe,
// see https://github.com/chalk/chalk/issues/58
// If we're on Windows and we're dealing with a gray color, temporarily make 'dim' a noop.
var originalDim = ansiStyles.dim.open;
if (isSimpleWindowsTerm && (nestedStyles.indexOf('gray') !== -1 || nestedStyles.indexOf('grey') !== -1)) {
ansiStyles.dim.open = '';
}
while (i--) {
var code = ansiStyles[nestedStyles[i]];
// Replace any instances already present with a re-opening code
// otherwise only the part of the string until said closing code
// will be colored, and the rest will simply be 'plain'.
str = code.open + str.replace(code.closeRe, code.open) + code.close;
}
// Reset the original 'dim' if we changed it to work around the Windows dimmed gray issue.
ansiStyles.dim.open = originalDim;
return str;
}
function init() {
var ret = {};
Object.keys(styles).forEach(function (name) {
ret[name] = {
get: function () {
return build.call(this, [name]);
}
};
});
return ret;
}
defineProps(Chalk.prototype, init());
module.exports = new Chalk();
module.exports.styles = ansiStyles;
module.exports.hasColor = hasAnsi;
module.exports.stripColor = stripAnsi;
module.exports.supportsColor = supportsColor;

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -0,0 +1,114 @@
{
"_from": "chalk@^1.0.0",
"_id": "chalk@1.1.3",
"_inBundle": false,
"_integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=",
"_location": "/http2-push-manifest/chalk",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "chalk@^1.0.0",
"name": "chalk",
"escapedName": "chalk",
"rawSpec": "^1.0.0",
"saveSpec": null,
"fetchSpec": "^1.0.0"
},
"_requiredBy": [
"/http2-push-manifest/update-notifier"
],
"_resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz",
"_shasum": "a8115c55e4a702fe4d150abd3872822a7e09fc98",
"_spec": "chalk@^1.0.0",
"_where": "/Users/asciidisco/Desktop/asciidisco.com/build/node_modules/http2-push-manifest/node_modules/update-notifier",
"bugs": {
"url": "https://github.com/chalk/chalk/issues"
},
"bundleDependencies": false,
"dependencies": {
"ansi-styles": "^2.2.1",
"escape-string-regexp": "^1.0.2",
"has-ansi": "^2.0.0",
"strip-ansi": "^3.0.0",
"supports-color": "^2.0.0"
},
"deprecated": false,
"description": "Terminal string styling done right. Much color.",
"devDependencies": {
"coveralls": "^2.11.2",
"matcha": "^0.6.0",
"mocha": "*",
"nyc": "^3.0.0",
"require-uncached": "^1.0.2",
"resolve-from": "^1.0.0",
"semver": "^4.3.3",
"xo": "*"
},
"engines": {
"node": ">=0.10.0"
},
"files": [
"index.js"
],
"homepage": "https://github.com/chalk/chalk#readme",
"keywords": [
"color",
"colour",
"colors",
"terminal",
"console",
"cli",
"string",
"str",
"ansi",
"style",
"styles",
"tty",
"formatting",
"rgb",
"256",
"shell",
"xterm",
"log",
"logging",
"command-line",
"text"
],
"license": "MIT",
"maintainers": [
{
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
{
"name": "Joshua Appelman",
"email": "jappelman@xebia.com",
"url": "jbnicolai.com"
},
{
"name": "JD Ballard",
"email": "i.am.qix@gmail.com",
"url": "github.com/qix-"
}
],
"name": "chalk",
"repository": {
"type": "git",
"url": "git+https://github.com/chalk/chalk.git"
},
"scripts": {
"bench": "matcha benchmark.js",
"coverage": "nyc npm test && nyc report",
"coveralls": "nyc npm test && nyc report --reporter=text-lcov | coveralls",
"test": "xo && mocha"
},
"version": "1.1.3",
"xo": {
"envs": [
"node",
"mocha"
]
}
}

View File

@@ -0,0 +1,213 @@
<h1 align="center">
<br>
<br>
<img width="360" src="https://cdn.rawgit.com/chalk/chalk/19935d6484811c5e468817f846b7b3d417d7bf4a/logo.svg" alt="chalk">
<br>
<br>
<br>
</h1>
> Terminal string styling done right
[![Build Status](https://travis-ci.org/chalk/chalk.svg?branch=master)](https://travis-ci.org/chalk/chalk)
[![Coverage Status](https://coveralls.io/repos/chalk/chalk/badge.svg?branch=master)](https://coveralls.io/r/chalk/chalk?branch=master)
[![](http://img.shields.io/badge/unicorn-approved-ff69b4.svg)](https://www.youtube.com/watch?v=9auOCbH5Ns4)
[colors.js](https://github.com/Marak/colors.js) used to be the most popular string styling module, but it has serious deficiencies like extending `String.prototype` which causes all kinds of [problems](https://github.com/yeoman/yo/issues/68). Although there are other ones, they either do too much or not enough.
**Chalk is a clean and focused alternative.**
![](https://github.com/chalk/ansi-styles/raw/master/screenshot.png)
## Why
- Highly performant
- Doesn't extend `String.prototype`
- Expressive API
- Ability to nest styles
- Clean and focused
- Auto-detects color support
- Actively maintained
- [Used by ~4500 modules](https://www.npmjs.com/browse/depended/chalk) as of July 15, 2015
## Install
```
$ npm install --save chalk
```
## Usage
Chalk comes with an easy to use composable API where you just chain and nest the styles you want.
```js
var chalk = require('chalk');
// style a string
chalk.blue('Hello world!');
// combine styled and normal strings
chalk.blue('Hello') + 'World' + chalk.red('!');
// compose multiple styles using the chainable API
chalk.blue.bgRed.bold('Hello world!');
// pass in multiple arguments
chalk.blue('Hello', 'World!', 'Foo', 'bar', 'biz', 'baz');
// nest styles
chalk.red('Hello', chalk.underline.bgBlue('world') + '!');
// nest styles of the same type even (color, underline, background)
chalk.green(
'I am a green line ' +
chalk.blue.underline.bold('with a blue substring') +
' that becomes green again!'
);
```
Easily define your own themes.
```js
var chalk = require('chalk');
var error = chalk.bold.red;
console.log(error('Error!'));
```
Take advantage of console.log [string substitution](http://nodejs.org/docs/latest/api/console.html#console_console_log_data).
```js
var name = 'Sindre';
console.log(chalk.green('Hello %s'), name);
//=> Hello Sindre
```
## API
### chalk.`<style>[.<style>...](string, [string...])`
Example: `chalk.red.bold.underline('Hello', 'world');`
Chain [styles](#styles) and call the last one as a method with a string argument. Order doesn't matter, and later styles take precedent in case of a conflict. This simply means that `Chalk.red.yellow.green` is equivalent to `Chalk.green`.
Multiple arguments will be separated by space.
### chalk.enabled
Color support is automatically detected, but you can override it by setting the `enabled` property. You should however only do this in your own code as it applies globally to all chalk consumers.
If you need to change this in a reusable module create a new instance:
```js
var ctx = new chalk.constructor({enabled: false});
```
### chalk.supportsColor
Detect whether the terminal [supports color](https://github.com/chalk/supports-color). Used internally and handled for you, but exposed for convenience.
Can be overridden by the user with the flags `--color` and `--no-color`. For situations where using `--color` is not possible, add an environment variable `FORCE_COLOR` with any value to force color. Trumps `--no-color`.
### chalk.styles
Exposes the styles as [ANSI escape codes](https://github.com/chalk/ansi-styles).
Generally not useful, but you might need just the `.open` or `.close` escape code if you're mixing externally styled strings with your own.
```js
var chalk = require('chalk');
console.log(chalk.styles.red);
//=> {open: '\u001b[31m', close: '\u001b[39m'}
console.log(chalk.styles.red.open + 'Hello' + chalk.styles.red.close);
```
### chalk.hasColor(string)
Check whether a string [has color](https://github.com/chalk/has-ansi).
### chalk.stripColor(string)
[Strip color](https://github.com/chalk/strip-ansi) from a string.
Can be useful in combination with `.supportsColor` to strip color on externally styled text when it's not supported.
Example:
```js
var chalk = require('chalk');
var styledString = getText();
if (!chalk.supportsColor) {
styledString = chalk.stripColor(styledString);
}
```
## Styles
### Modifiers
- `reset`
- `bold`
- `dim`
- `italic` *(not widely supported)*
- `underline`
- `inverse`
- `hidden`
- `strikethrough` *(not widely supported)*
### Colors
- `black`
- `red`
- `green`
- `yellow`
- `blue` *(on Windows the bright version is used as normal blue is illegible)*
- `magenta`
- `cyan`
- `white`
- `gray`
### Background colors
- `bgBlack`
- `bgRed`
- `bgGreen`
- `bgYellow`
- `bgBlue`
- `bgMagenta`
- `bgCyan`
- `bgWhite`
## 256-colors
Chalk does not support anything other than the base eight colors, which guarantees it will work on all terminals and systems. Some terminals, specifically `xterm` compliant ones, will support the full range of 8-bit colors. For this the lower level [ansi-256-colors](https://github.com/jbnicolai/ansi-256-colors) package can be used.
## Windows
If you're on Windows, do yourself a favor and use [`cmder`](http://bliker.github.io/cmder/) instead of `cmd.exe`.
## Related
- [chalk-cli](https://github.com/chalk/chalk-cli) - CLI for this module
- [ansi-styles](https://github.com/chalk/ansi-styles/) - ANSI escape codes for styling strings in the terminal
- [supports-color](https://github.com/chalk/supports-color/) - Detect whether a terminal supports color
- [strip-ansi](https://github.com/chalk/strip-ansi) - Strip ANSI escape codes
- [has-ansi](https://github.com/chalk/has-ansi) - Check if a string has ANSI escape codes
- [ansi-regex](https://github.com/chalk/ansi-regex) - Regular expression for matching ANSI escape codes
- [wrap-ansi](https://github.com/chalk/wrap-ansi) - Wordwrap a string with ANSI escape codes
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)

View File

@@ -0,0 +1,106 @@
'use strict';
var path = require('path');
var fs = require('graceful-fs');
var osenv = require('osenv');
var assign = require('object-assign');
var mkdirp = require('mkdirp');
var uuid = require('uuid');
var xdgBasedir = require('xdg-basedir');
var osTmpdir = require('os-tmpdir');
var writeFileAtomic = require('write-file-atomic');
var user = (osenv.user() || uuid.v4()).replace(/\\/g, '');
var configDir = xdgBasedir.config || path.join(osTmpdir(), user, '.config');
var permissionError = 'You don\'t have access to this file.';
var defaultPathMode = parseInt('0700', 8);
var writeFileOptions = {mode: parseInt('0600', 8)};
function Configstore(id, defaults, opts) {
opts = opts || {};
var pathPrefix = opts.globalConfigPath ?
path.join(id, 'config.json') :
path.join('configstore', id + '.json');
this.path = path.join(configDir, pathPrefix);
this.all = assign({}, defaults || {}, this.all || {});
}
Configstore.prototype = Object.create(Object.prototype, {
all: {
get: function () {
try {
return JSON.parse(fs.readFileSync(this.path, 'utf8'));
} catch (err) {
// create dir if it doesn't exist
if (err.code === 'ENOENT') {
mkdirp.sync(path.dirname(this.path), defaultPathMode);
return {};
}
// improve the message of permission errors
if (err.code === 'EACCES') {
err.message = err.message + '\n' + permissionError + '\n';
}
// empty the file if it encounters invalid JSON
if (err.name === 'SyntaxError') {
writeFileAtomic.sync(this.path, '', writeFileOptions);
return {};
}
throw err;
}
},
set: function (val) {
try {
// make sure the folder exists as it
// could have been deleted in the meantime
mkdirp.sync(path.dirname(this.path), defaultPathMode);
writeFileAtomic.sync(this.path, JSON.stringify(val, null, '\t'), writeFileOptions);
} catch (err) {
// improve the message of permission errors
if (err.code === 'EACCES') {
err.message = err.message + '\n' + permissionError + '\n';
}
throw err;
}
}
},
size: {
get: function () {
return Object.keys(this.all || {}).length;
}
}
});
Configstore.prototype.get = function (key) {
return this.all[key];
};
Configstore.prototype.set = function (key, val) {
var config = this.all;
if (arguments.length === 1) {
Object.keys(key).forEach(function (k) {
config[k] = key[k];
});
} else {
config[key] = val;
}
this.all = config;
};
Configstore.prototype.del = function (key) {
var config = this.all;
delete config[key];
this.all = config;
};
Configstore.prototype.clear = function () {
this.all = {};
};
module.exports = Configstore;

View File

@@ -0,0 +1,81 @@
{
"_from": "configstore@^1.0.0",
"_id": "configstore@1.4.0",
"_inBundle": false,
"_integrity": "sha1-w1eB0FAdJowlxUuLF/YkDopPsCE=",
"_location": "/http2-push-manifest/configstore",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "configstore@^1.0.0",
"name": "configstore",
"escapedName": "configstore",
"rawSpec": "^1.0.0",
"saveSpec": null,
"fetchSpec": "^1.0.0"
},
"_requiredBy": [
"/http2-push-manifest/update-notifier"
],
"_resolved": "https://registry.npmjs.org/configstore/-/configstore-1.4.0.tgz",
"_shasum": "c35781d0501d268c25c54b8b17f6240e8a4fb021",
"_spec": "configstore@^1.0.0",
"_where": "/Users/asciidisco/Desktop/asciidisco.com/build/node_modules/http2-push-manifest/node_modules/update-notifier",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"bugs": {
"url": "https://github.com/yeoman/configstore/issues"
},
"bundleDependencies": false,
"dependencies": {
"graceful-fs": "^4.1.2",
"mkdirp": "^0.5.0",
"object-assign": "^4.0.1",
"os-tmpdir": "^1.0.0",
"osenv": "^0.1.0",
"uuid": "^2.0.1",
"write-file-atomic": "^1.1.2",
"xdg-basedir": "^2.0.0"
},
"deprecated": false,
"description": "Easily load and save config without having to think about where and how",
"devDependencies": {
"mocha": "*",
"path-exists": "^2.0.0",
"xo": "*"
},
"engines": {
"node": ">=0.10.0"
},
"files": [
"index.js"
],
"homepage": "https://github.com/yeoman/configstore#readme",
"keywords": [
"conf",
"config",
"configuration",
"settings",
"store",
"editable",
"json",
"data",
"persist",
"persistent",
"save"
],
"license": "BSD-2-Clause",
"name": "configstore",
"repository": {
"type": "git",
"url": "git+https://github.com/yeoman/configstore.git"
},
"scripts": {
"test": "xo && mocha"
},
"version": "1.4.0"
}

View File

@@ -0,0 +1,105 @@
# configstore [![Build Status](https://secure.travis-ci.org/yeoman/configstore.svg?branch=master)](http://travis-ci.org/yeoman/configstore)
> Easily load and persist config without having to think about where and how
Config is stored in a JSON file located in `$XDG_CONFIG_HOME` or `~/.config`.
Example: `~/.config/configstore/some-id.json`
## Usage
```js
const Configstore = require('configstore');
const pkg = require('./package.json');
// Init a Configstore instance with an unique ID e.g.
// package name and optionally some default values
const conf = new Configstore(pkg.name, {foo: 'bar'});
conf.set('awesome', true);
console.log(conf.get('awesome'));
//=> true
console.log(conf.get('foo'));
//=> bar
conf.del('awesome');
console.log(conf.get('awesome'));
//=> undefined
```
## API
### Configstore(packageName, [defaults], [options])
Create a new Configstore instance `config`.
#### packageName
Type: `string`
Name of your package.
#### defaults
Type: `object`
Default content to init the config store with.
#### options
Type: `object`
##### globalConfigPath
Type: `boolean`
Default: `false`
Store the config at `$CONFIG/package-name/config.json` instead of the default `$CONFIG/configstore/package-name.json`. This is not recommended as you might end up conflicting with other tools, rendering the "without having to think" idea moot.
### config.set(key, value)
Set an item.
### config.set(object)
Set multiple items at once.
### config.get(key)
Get an item.
### config.del(key)
Delete an item.
### config.clear()
Delete all items.
### config.all
Get all items as an object or replace the current config with an object:
```js
conf.all = {
hello: 'world'
};
```
### config.size
Get the item count.
### config.path
Get the path to the config file. Can be used to show the user where the config file is located or even better open it for them.
## License
[BSD license](http://opensource.org/licenses/bsd-license.php)
Copyright Google

View File

@@ -0,0 +1,276 @@
'use strict';
var http = require('http');
var https = require('https');
var urlLib = require('url');
var util = require('util');
var zlib = require('zlib');
var querystring = require('querystring');
var objectAssign = require('object-assign');
var infinityAgent = require('infinity-agent');
var duplexify = require('duplexify');
var isStream = require('is-stream');
var readAllStream = require('read-all-stream');
var timedOut = require('timed-out');
var prependHttp = require('prepend-http');
var lowercaseKeys = require('lowercase-keys');
var isRedirect = require('is-redirect');
var NestedErrorStacks = require('nested-error-stacks');
function GotError(message, nested) {
NestedErrorStacks.call(this, message, nested);
objectAssign(this, nested, {nested: this.nested});
}
util.inherits(GotError, NestedErrorStacks);
GotError.prototype.name = 'GotError';
function got(url, opts, cb) {
if (typeof url !== 'string' && typeof url !== 'object') {
throw new GotError('Parameter `url` must be a string or object, not ' + typeof url);
}
if (typeof opts === 'function') {
cb = opts;
opts = {};
}
opts = objectAssign(
{
protocol: 'http:'
},
typeof url === 'string' ? urlLib.parse(prependHttp(url)) : url,
opts
);
opts.headers = objectAssign({
'user-agent': 'https://github.com/sindresorhus/got',
'accept-encoding': 'gzip,deflate'
}, lowercaseKeys(opts.headers));
if (opts.pathname) {
opts.path = opts.pathname;
}
if (opts.query) {
if (typeof opts.query !== 'string') {
opts.query = querystring.stringify(opts.query);
}
opts.path = opts.pathname + '?' + opts.query;
delete opts.query;
}
var encoding = opts.encoding;
var body = opts.body;
var json = opts.json;
var timeout = opts.timeout;
var proxy;
var redirectCount = 0;
delete opts.encoding;
delete opts.body;
delete opts.json;
delete opts.timeout;
if (json) {
opts.headers.accept = opts.headers.accept || 'application/json';
}
if (body) {
if (typeof body !== 'string' && !Buffer.isBuffer(body) && !isStream.readable(body)) {
throw new GotError('options.body must be a ReadableStream, string or Buffer');
}
opts.method = opts.method || 'POST';
if (!opts.headers['content-length'] && !opts.headers['transfer-encoding'] && !isStream.readable(body)) {
var length = typeof body === 'string' ? Buffer.byteLength(body) : body.length;
opts.headers['content-length'] = length;
}
}
opts.method = opts.method || 'GET';
// returns a proxy stream to the response
// if no callback has been provided
if (!cb) {
proxy = duplexify();
// forward errors on the stream
cb = function (err, data, response) {
proxy.emit('error', err, data, response);
};
}
if (proxy && json) {
throw new GotError('got can not be used as stream when options.json is used');
}
function get(opts, cb) {
var fn = opts.protocol === 'https:' ? https : http;
var url = urlLib.format(opts);
if (opts.agent === undefined) {
opts.agent = infinityAgent[fn === https ? 'https' : 'http'].globalAgent;
if (process.version.indexOf('v0.10') === 0 && fn === https && (
typeof opts.ca !== 'undefined' ||
typeof opts.cert !== 'undefined' ||
typeof opts.ciphers !== 'undefined' ||
typeof opts.key !== 'undefined' ||
typeof opts.passphrase !== 'undefined' ||
typeof opts.pfx !== 'undefined' ||
typeof opts.rejectUnauthorized !== 'undefined')) {
opts.agent = new infinityAgent.https.Agent({
ca: opts.ca,
cert: opts.cert,
ciphers: opts.ciphers,
key: opts.key,
passphrase: opts.passphrase,
pfx: opts.pfx,
rejectUnauthorized: opts.rejectUnauthorized
});
}
}
var req = fn.request(opts, function (response) {
var statusCode = response.statusCode;
var res = response;
// auto-redirect only for GET and HEAD methods
if (isRedirect(statusCode) && 'location' in res.headers && (opts.method === 'GET' || opts.method === 'HEAD')) {
// discard response
res.resume();
if (++redirectCount > 10) {
cb(new GotError('Redirected 10 times. Aborting.'), undefined, res);
return;
}
var redirectUrl = urlLib.resolve(url, res.headers.location);
var redirectOpts = objectAssign({}, opts, urlLib.parse(redirectUrl));
if (opts.agent === infinityAgent.http.globalAgent && redirectOpts.protocol === 'https:' && opts.protocol === 'http:') {
redirectOpts.agent = undefined;
}
if (proxy) {
proxy.emit('redirect', res, redirectOpts);
}
get(redirectOpts, cb);
return;
}
if (proxy) {
proxy.emit('response', res);
}
if (['gzip', 'deflate'].indexOf(res.headers['content-encoding']) !== -1) {
res = res.pipe(zlib.createUnzip());
}
if (statusCode < 200 || statusCode > 299) {
readAllStream(res, encoding, function (err, data) {
err = new GotError(opts.method + ' ' + url + ' response code is ' + statusCode + ' (' + http.STATUS_CODES[statusCode] + ')', err);
err.code = statusCode;
if (data && json) {
try {
data = JSON.parse(data);
} catch (e) {
err = new GotError('Parsing ' + url + ' response failed', new GotError(e.message, err));
}
}
cb(err, data, response);
});
return;
}
// pipe the response to the proxy if in proxy mode
if (proxy) {
proxy.setReadable(res);
return;
}
readAllStream(res, encoding, function (err, data) {
if (err) {
err = new GotError('Reading ' + url + ' response failed', err);
} else if (json && statusCode !== 204) {
// only parse json if the option is enabled, and the response
// is not a 204 (empty reponse)
try {
data = JSON.parse(data);
} catch (e) {
err = new GotError('Parsing ' + url + ' response failed', e);
}
}
cb(err, data, response);
});
}).once('error', function (err) {
cb(new GotError('Request to ' + url + ' failed', err));
});
if (timeout) {
timedOut(req, timeout);
}
if (!proxy) {
if (isStream.readable(body)) {
body.pipe(req);
} else {
req.end(body);
}
return;
}
if (body) {
proxy.write = function () {
throw new Error('got\'s stream is not writable when options.body is used');
};
if (isStream.readable(body)) {
body.pipe(req);
} else {
req.end(body);
}
return;
}
if (opts.method === 'POST' || opts.method === 'PUT' || opts.method === 'PATCH') {
proxy.setWritable(req);
return;
}
req.end();
}
get(opts, cb);
return proxy;
}
[
'get',
'post',
'put',
'patch',
'head',
'delete'
].forEach(function (el) {
got[el] = function (url, opts, cb) {
if (typeof opts === 'function') {
cb = opts;
opts = {};
}
return got(url, objectAssign({}, opts, {method: el.toUpperCase()}), cb);
};
});
module.exports = got;

View File

@@ -0,0 +1,39 @@
'use strict';
var propIsEnumerable = Object.prototype.propertyIsEnumerable;
function ToObject(val) {
if (val == null) {
throw new TypeError('Object.assign cannot be called with null or undefined');
}
return Object(val);
}
function ownEnumerableKeys(obj) {
var keys = Object.getOwnPropertyNames(obj);
if (Object.getOwnPropertySymbols) {
keys = keys.concat(Object.getOwnPropertySymbols(obj));
}
return keys.filter(function (key) {
return propIsEnumerable.call(obj, key);
});
}
module.exports = Object.assign || function (target, source) {
var from;
var keys;
var to = ToObject(target);
for (var s = 1; s < arguments.length; s++) {
from = arguments[s];
keys = ownEnumerableKeys(Object(from));
for (var i = 0; i < keys.length; i++) {
to[keys[i]] = from[keys[i]];
}
}
return to;
};

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -0,0 +1,70 @@
{
"_from": "object-assign@^3.0.0",
"_id": "object-assign@3.0.0",
"_inBundle": false,
"_integrity": "sha1-m+3VygiXlJvKR+f/QIBi1Un1h/I=",
"_location": "/http2-push-manifest/got/object-assign",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "object-assign@^3.0.0",
"name": "object-assign",
"escapedName": "object-assign",
"rawSpec": "^3.0.0",
"saveSpec": null,
"fetchSpec": "^3.0.0"
},
"_requiredBy": [
"/http2-push-manifest/got"
],
"_resolved": "https://registry.npmjs.org/object-assign/-/object-assign-3.0.0.tgz",
"_shasum": "9bedd5ca0897949bca47e7ff408062d549f587f2",
"_spec": "object-assign@^3.0.0",
"_where": "/Users/asciidisco/Desktop/asciidisco.com/build/node_modules/http2-push-manifest/node_modules/got",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "http://sindresorhus.com"
},
"bugs": {
"url": "https://github.com/sindresorhus/object-assign/issues"
},
"bundleDependencies": false,
"deprecated": false,
"description": "ES6 Object.assign() ponyfill",
"devDependencies": {
"mocha": "*"
},
"engines": {
"node": ">=0.10.0"
},
"files": [
"index.js"
],
"homepage": "https://github.com/sindresorhus/object-assign#readme",
"keywords": [
"object",
"assign",
"extend",
"properties",
"es6",
"ecmascript",
"harmony",
"ponyfill",
"prollyfill",
"polyfill",
"shim",
"browser"
],
"license": "MIT",
"name": "object-assign",
"repository": {
"type": "git",
"url": "git+https://github.com/sindresorhus/object-assign.git"
},
"scripts": {
"test": "mocha"
},
"version": "3.0.0"
}

View File

@@ -0,0 +1,51 @@
# object-assign [![Build Status](https://travis-ci.org/sindresorhus/object-assign.svg?branch=master)](https://travis-ci.org/sindresorhus/object-assign)
> ES6 [`Object.assign()`](http://www.2ality.com/2014/01/object-assign.html) ponyfill
> Ponyfill: A polyfill that doesn't overwrite the native method
## Install
```sh
$ npm install --save object-assign
```
## Usage
```js
var objectAssign = require('object-assign');
objectAssign({foo: 0}, {bar: 1});
//=> {foo: 0, bar: 1}
// multiple sources
objectAssign({foo: 0}, {bar: 1}, {baz: 2});
//=> {foo: 0, bar: 1, baz: 2}
// overwrites equal keys
objectAssign({foo: 0}, {foo: 1}, {foo: 2});
//=> {foo: 2}
// ignores null and undefined sources
objectAssign({foo: 0}, null, {bar: 1}, undefined);
//=> {foo: 0, bar: 1}
```
## API
### objectAssign(target, source, [source, ...])
Assigns enumerable own properties of `source` objects to the `target` object and returns the `target` object. Additional `source` objects will overwrite previous ones.
## Resources
- [ES6 spec - Object.assign](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.assign)
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)

View File

@@ -0,0 +1,94 @@
{
"_from": "got@^3.2.0",
"_id": "got@3.3.1",
"_inBundle": false,
"_integrity": "sha1-5dDtSvVfw+701WAHdp2YGSvLLso=",
"_location": "/http2-push-manifest/got",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "got@^3.2.0",
"name": "got",
"escapedName": "got",
"rawSpec": "^3.2.0",
"saveSpec": null,
"fetchSpec": "^3.2.0"
},
"_requiredBy": [
"/http2-push-manifest/package-json"
],
"_resolved": "https://registry.npmjs.org/got/-/got-3.3.1.tgz",
"_shasum": "e5d0ed4af55fc3eef4d56007769d98192bcb2eca",
"_spec": "got@^3.2.0",
"_where": "/Users/asciidisco/Desktop/asciidisco.com/build/node_modules/http2-push-manifest/node_modules/package-json",
"bugs": {
"url": "https://github.com/sindresorhus/got/issues"
},
"bundleDependencies": false,
"dependencies": {
"duplexify": "^3.2.0",
"infinity-agent": "^2.0.0",
"is-redirect": "^1.0.0",
"is-stream": "^1.0.0",
"lowercase-keys": "^1.0.0",
"nested-error-stacks": "^1.0.0",
"object-assign": "^3.0.0",
"prepend-http": "^1.0.0",
"read-all-stream": "^3.0.0",
"timed-out": "^2.0.0"
},
"deprecated": false,
"description": "Simplified HTTP/HTTPS requests",
"devDependencies": {
"from2-array": "0.0.3",
"istanbul": "^0.3.13",
"pem": "^1.4.4",
"tap": "^1.0.0"
},
"engines": {
"node": ">=0.10.0"
},
"files": [
"index.js"
],
"homepage": "https://github.com/sindresorhus/got#readme",
"keywords": [
"http",
"https",
"get",
"got",
"url",
"uri",
"request",
"util",
"utility",
"simple",
"curl",
"wget",
"fetch"
],
"license": "MIT",
"maintainers": [
{
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
{
"name": "Vsevolod Strukchinsky",
"email": "floatdrop@gmail.com",
"url": "github.com/floatdrop"
}
],
"name": "got",
"repository": {
"type": "git",
"url": "git+https://github.com/sindresorhus/got.git"
},
"scripts": {
"coverage": "istanbul cover tape --report html -- test/test-*.js",
"test": "tap test/test-*.js"
},
"version": "3.3.1"
}

View File

@@ -0,0 +1,203 @@
<h1 align="center">
<br>
<img width="360" src="https://rawgit.com/sindresorhus/got/master/media/logo.svg" alt="got">
<br>
<br>
<br>
</h1>
> Simplified HTTP/HTTPS requests
[![Build Status](https://travis-ci.org/sindresorhus/got.svg?branch=master)](https://travis-ci.org/sindresorhus/got)
A nicer interface to the built-in [`http`](http://nodejs.org/api/http.html) module.
It supports following redirects, streams, automagically handling gzip/deflate and some convenience options.
Created because [`request`](https://github.com/mikeal/request) is bloated *(several megabytes!)* and slow.
## Install
```
$ npm install --save got
```
## Usage
```js
var got = require('got');
// Callback mode
got('todomvc.com', function (err, data, res) {
console.log(data);
//=> <!doctype html> ...
});
// Stream mode
got('todomvc.com').pipe(fs.createWriteStream('index.html'));
// For POST, PUT and PATCH methods got returns a WritableStream
fs.createReadStream('index.html').pipe(got.post('todomvc.com'));
```
### API
It's a `GET` request by default, but can be changed in `options`.
#### got(url, [options], [callback])
##### url
*Required*
Type: `string`, `object`
The URL to request or bare [http.request options](https://nodejs.org/api/http.html#http_http_request_options_callback) object.
Properties from `options` will override properties in the parsed `url`.
##### options
Type: `object`
Any of the [`http.request`](http://nodejs.org/api/http.html#http_http_request_options_callback) options.
###### body
Type: `string`, `Buffer`, `ReadableStream`
*This option and stream mode are mutually exclusive.*
Body that will be sent with a `POST` request. If present in `options` and `options.method` is not set - `options.method` will be set to `POST`.
If `content-length` or `transfer-encoding` is not set in `options.headers` and `body` is a string or buffer, `content-length` will be set to the body length.
###### encoding
Type: `string`, `null`
Default: `'utf8'`
Encoding to be used on `setEncoding` of the response data. If `null`, the body is returned as a Buffer.
###### json
Type: `boolean`
Default: `false`
*This option and stream mode are mutually exclusive.*
Parse response body with `JSON.parse` and set `accept` header to `application/json`.
###### query
Type: `string`, `object`
Query string object that will be added to the request URL. This will override the query string in `url`.
###### timeout
Type: `number`
Milliseconds after which the request will be aborted and an error event with `ETIMEDOUT` code will be emitted.
###### agent
[http.Agent](http://nodejs.org/api/http.html#http_class_http_agent) instance.
If `undefined` - [`infinity-agent`](https://github.com/floatdrop/infinity-agent) will be used to backport Agent class from Node.js core.
To use default [globalAgent](http://nodejs.org/api/http.html#http_http_globalagent) just pass `null`.
##### callback(error, data, response)
###### error
`Error` object with HTTP status code as `code` property.
###### data
The data you requested.
###### response
The [response object](http://nodejs.org/api/http.html#http_http_incomingmessage).
When in stream mode, you can listen for events:
##### .on('response', response)
`response` event to get the response object of the final request.
##### .on('redirect', response, nextOptions)
`redirect` event to get the response object of a redirect. Second argument is options for the next request to the redirect location.
##### .on('error', error, body, response)
`error` event emitted in case of protocol error (like `ENOTFOUND` etc.) or status error (4xx or 5xx). Second argument is body of server response in case of status error. Third argument is response object.
###### response
The [response object](http://nodejs.org/api/http.html#http_http_incomingmessage).
#### got.get(url, [options], [callback])
#### got.post(url, [options], [callback])
#### got.put(url, [options], [callback])
#### got.patch(url, [options], [callback])
#### got.head(url, [options], [callback])
#### got.delete(url, [options], [callback])
Sets `options.method` to the method name and makes a request.
## Proxy
You can use the [`tunnel`](https://github.com/koichik/node-tunnel) module with the `agent` option to work with proxies:
```js
var got = require('got');
var tunnel = require('tunnel');
got('todomvc.com', {
agent: tunnel.httpOverHttp({
proxy: {
host: 'localhost'
}
})
}, function () {});
```
## Tip
It's a good idea to set the `'user-agent'` header so the provider can more easily see how their resource is used. By default it's the URL to this repo.
```js
var got = require('got');
got('todomvc.com', {
headers: {
'user-agent': 'https://github.com/your-username/repo-name'
}
}, function () {});
```
## Related
- [gh-got](https://github.com/sindresorhus/gh-got) - Convenience wrapper for interacting with the GitHub API
- [got-promise](https://github.com/floatdrop/got-promise) - Promise wrapper
## Created by
[![Sindre Sorhus](https://avatars.githubusercontent.com/u/170270?v=3&s=100)](http://sindresorhus.com) | [![Vsevolod Strukchinsky](https://avatars.githubusercontent.com/u/365089?v=3&s=100)](https://github.com/floatdrop)
---|---
[Sindre Sorhus](http://sindresorhus.com) | [Vsevolod Strukchinsky](https://github.com/floatdrop)
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)

View File

@@ -0,0 +1,40 @@
#!/usr/bin/env node
'use strict';
var pkg = require('./package.json');
var latestVersion = require('./');
var argv = process.argv.slice(2);
var input = argv[0];
function help() {
console.log([
'',
' ' + pkg.description,
'',
' Usage',
' latest-version <package-name>',
'',
' Example',
' latest-version pageres',
' 0.4.1'
].join('\n'));
}
if (!input || argv.indexOf('--help') !== -1) {
help();
return;
}
if (argv.indexOf('--version') !== -1) {
console.log(pkg.version);
return;
}
latestVersion(input, function (err, version) {
if (err) {
console.error(err);
process.exit(1);
return;
}
console.log(version);
});

View File

@@ -0,0 +1,13 @@
'use strict';
var packageJson = require('package-json');
module.exports = function (name, cb) {
packageJson(name.toLowerCase(), 'latest', function (err, json) {
if (err) {
cb(err);
return;
}
cb(null, json.version);
});
};

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -0,0 +1,72 @@
{
"_from": "latest-version@^1.0.0",
"_id": "latest-version@1.0.1",
"_inBundle": false,
"_integrity": "sha1-cs/Ebj6NG+ZR4eu1Tqn26pbzdLs=",
"_location": "/http2-push-manifest/latest-version",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "latest-version@^1.0.0",
"name": "latest-version",
"escapedName": "latest-version",
"rawSpec": "^1.0.0",
"saveSpec": null,
"fetchSpec": "^1.0.0"
},
"_requiredBy": [
"/http2-push-manifest/update-notifier"
],
"_resolved": "https://registry.npmjs.org/latest-version/-/latest-version-1.0.1.tgz",
"_shasum": "72cfc46e3e8d1be651e1ebb54ea9f6ea96f374bb",
"_spec": "latest-version@^1.0.0",
"_where": "/Users/asciidisco/Desktop/asciidisco.com/build/node_modules/http2-push-manifest/node_modules/update-notifier",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"bin": {
"latest-version": "cli.js"
},
"bugs": {
"url": "https://github.com/sindresorhus/latest-version/issues"
},
"bundleDependencies": false,
"dependencies": {
"package-json": "^1.0.0"
},
"deprecated": false,
"description": "Get the latest version of a npm package",
"devDependencies": {
"mocha": "*"
},
"engines": {
"node": ">=0.10.0"
},
"files": [
"index.js",
"cli.js"
],
"homepage": "https://github.com/sindresorhus/latest-version#readme",
"keywords": [
"latest",
"version",
"npm",
"package",
"package.json",
"current",
"module"
],
"license": "MIT",
"name": "latest-version",
"repository": {
"type": "git",
"url": "git+https://github.com/sindresorhus/latest-version.git"
},
"scripts": {
"test": "mocha"
},
"version": "1.0.1"
}

View File

@@ -0,0 +1,48 @@
# latest-version [![Build Status](https://travis-ci.org/sindresorhus/latest-version.svg?branch=master)](https://travis-ci.org/sindresorhus/latest-version)
> Get the latest version of a npm package
Fetches the version directly from the registry instead of depending on the massive [npm](https://github.com/npm/npm/blob/8b5e7b6ae5b4cd2d7d62eaf93b1428638b387072/package.json#L37-L85) module like the [latest](https://github.com/bahamas10/node-latest) module does.
## Install
```sh
$ npm install --save latest-version
```
## Usage
```js
var latestVersion = require('latest-version');
latestVersion('pageres', function (err, version) {
console.log(version);
//=> 0.2.3
});
```
## CLI
```sh
$ npm install --global latest-version
```
```sh
$ latest-version --help
Usage
latest-version <package-name>
Example
latest-version pageres
0.4.1ersion pageres
0.2.3
```
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)

View File

@@ -0,0 +1,49 @@
'use strict';
var got = require('got');
var registryUrl = require('registry-url');
function get(url, cb) {
got(url, {json: true}, function (err, data) {
if (err && err.code === 404) {
cb(new Error('Package or version doesn\'t exist'));
return;
}
if (err) {
cb(err);
return;
}
cb(null, data);
});
}
module.exports = function (name, version, cb) {
var url = registryUrl(name.split('/')[0]) + name + '/';
if (typeof version !== 'string') {
cb = version;
version = '';
}
get(url + version, cb);
};
module.exports.field = function (name, field, cb) {
var url = registryUrl(name.split('/')[0]) +
'-/by-field/?key=%22' + name + '%22&field=' + field;
get(url, function (err, res) {
if (err) {
cb(err);
return;
}
if (Object.keys(res).length === 0) {
cb(new Error('Field `' + field + '` doesn\'t exist'));
return;
}
cb(null, res[name][field]);
});
};

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -0,0 +1,71 @@
{
"_from": "package-json@^1.0.0",
"_id": "package-json@1.2.0",
"_inBundle": false,
"_integrity": "sha1-yOysCUInzfdqMWh07QXifMk5oOA=",
"_location": "/http2-push-manifest/package-json",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "package-json@^1.0.0",
"name": "package-json",
"escapedName": "package-json",
"rawSpec": "^1.0.0",
"saveSpec": null,
"fetchSpec": "^1.0.0"
},
"_requiredBy": [
"/http2-push-manifest/latest-version"
],
"_resolved": "https://registry.npmjs.org/package-json/-/package-json-1.2.0.tgz",
"_shasum": "c8ecac094227cdf76a316874ed05e27cc939a0e0",
"_spec": "package-json@^1.0.0",
"_where": "/Users/asciidisco/Desktop/asciidisco.com/build/node_modules/http2-push-manifest/node_modules/latest-version",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"bugs": {
"url": "https://github.com/sindresorhus/package-json/issues"
},
"bundleDependencies": false,
"dependencies": {
"got": "^3.2.0",
"registry-url": "^3.0.0"
},
"deprecated": false,
"description": "Get the package.json of a package from the npm registry",
"devDependencies": {
"mocha": "*"
},
"engines": {
"node": ">=0.10.0"
},
"files": [
"index.js"
],
"homepage": "https://github.com/sindresorhus/package-json#readme",
"keywords": [
"npm",
"registry",
"package",
"pkg",
"package.json",
"json",
"module",
"scope",
"scoped"
],
"license": "MIT",
"name": "package-json",
"repository": {
"type": "git",
"url": "git+https://github.com/sindresorhus/package-json.git"
},
"scripts": {
"test": "mocha"
},
"version": "1.2.0"
}

View File

@@ -0,0 +1,57 @@
# package-json [![Build Status](https://travis-ci.org/sindresorhus/package-json.svg?branch=master)](https://travis-ci.org/sindresorhus/package-json)
> Get the package.json of a package from the npm registry
## Install
```
$ npm install --save package-json
```
## Usage
```js
var packageJson = require('package-json');
packageJson('pageres', 'latest', function (err, json) {
console.log(json);
//=> { name: 'pageres', ... }
});
// also works with scoped packages
packageJson('@company/package', 'latest', function (err, json) {
console.log(json);
//=> { name: 'package', ... }
});
packageJson.field('pageres', 'description', function (err, field) {
console.log(field);
//=> 'Capture website screenshots'
});
```
## API
### packageJson(name, [version], callback)
You can optionally specify a version (e.g. `0.1.0`) or `latest`.
If you don't specify a version you'll get the [main entry](http://registry.npmjs.org/pageres/) containing all versions.
### packageJson.field(name, field, callback)
Get a specific field in the `package.json`.
## Related
- [npm-keyword](https://github.com/sindresorhus/npm-keyword) - Get a list of npm packages with a certain keyword
- [npm-user](https://github.com/sindresorhus/npm-user) - Get user info of a npm user
- [npm-email](https://github.com/sindresorhus/npm-email) - Get the email of a npm user
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)

View File

@@ -0,0 +1,36 @@
#!/usr/bin/env node
'use strict';
var pkg = require('./package.json');
var repeating = require('./');
var argv = process.argv.slice(2);
function help() {
console.log([
'',
' ' + pkg.description,
'',
' Usage',
' $ repeating <string> <count>',
'',
' Example',
' $ repeating \'unicorn \' 2',
' unicorn unicorn'
].join('\n'));
}
if (process.argv.indexOf('--help') !== -1) {
help();
return;
}
if (process.argv.indexOf('--version') !== -1) {
console.log(pkg.version);
return;
}
if (!argv[1]) {
console.error('You have to define how many times to repeat the string.');
process.exit(1);
}
console.log(repeating(argv[0], Number(argv[1])));

View File

@@ -0,0 +1,24 @@
'use strict';
var isFinite = require('is-finite');
module.exports = function (str, n) {
if (typeof str !== 'string') {
throw new TypeError('Expected a string as the first argument');
}
if (n < 0 || !isFinite(n)) {
throw new TypeError('Expected a finite positive number');
}
var ret = '';
do {
if (n & 1) {
ret += str;
}
str += str;
} while (n = n >> 1);
return ret;
};

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -0,0 +1,74 @@
{
"_from": "repeating@^1.1.2",
"_id": "repeating@1.1.3",
"_inBundle": false,
"_integrity": "sha1-PUEUIYh3U3SU+X93+Xhfq4EPpKw=",
"_location": "/http2-push-manifest/repeating",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "repeating@^1.1.2",
"name": "repeating",
"escapedName": "repeating",
"rawSpec": "^1.1.2",
"saveSpec": null,
"fetchSpec": "^1.1.2"
},
"_requiredBy": [
"/http2-push-manifest/update-notifier"
],
"_resolved": "https://registry.npmjs.org/repeating/-/repeating-1.1.3.tgz",
"_shasum": "3d4114218877537494f97f77f9785fab810fa4ac",
"_spec": "repeating@^1.1.2",
"_where": "/Users/asciidisco/Desktop/asciidisco.com/build/node_modules/http2-push-manifest/node_modules/update-notifier",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"bin": {
"repeating": "cli.js"
},
"bugs": {
"url": "https://github.com/sindresorhus/repeating/issues"
},
"bundleDependencies": false,
"dependencies": {
"is-finite": "^1.0.0"
},
"deprecated": false,
"description": "Repeat a string - fast",
"devDependencies": {
"ava": "0.0.4"
},
"engines": {
"node": ">=0.10.0"
},
"files": [
"index.js",
"cli.js"
],
"homepage": "https://github.com/sindresorhus/repeating#readme",
"keywords": [
"cli-app",
"cli",
"bin",
"repeat",
"repeating",
"string",
"str",
"text",
"fill"
],
"license": "MIT",
"name": "repeating",
"repository": {
"type": "git",
"url": "git+https://github.com/sindresorhus/repeating.git"
},
"scripts": {
"test": "node test.js"
},
"version": "1.1.3"
}

View File

@@ -0,0 +1,40 @@
# repeating [![Build Status](https://travis-ci.org/sindresorhus/repeating.svg?branch=master)](https://travis-ci.org/sindresorhus/repeating)
> Repeat a string - fast
## Usage
```sh
$ npm install --save repeating
```
```js
var repeating = require('repeating');
repeating('unicorn ', 100);
//=> unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn unicorn
```
## CLI
```sh
$ npm install --global repeating
```
```
$ repeating --help
Usage
repeating <string> <count>
Example
repeating 'unicorn ' 2
unicorn unicorn
```
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)

View File

@@ -0,0 +1,50 @@
'use strict';
var argv = process.argv;
var terminator = argv.indexOf('--');
var hasFlag = function (flag) {
flag = '--' + flag;
var pos = argv.indexOf(flag);
return pos !== -1 && (terminator !== -1 ? pos < terminator : true);
};
module.exports = (function () {
if ('FORCE_COLOR' in process.env) {
return true;
}
if (hasFlag('no-color') ||
hasFlag('no-colors') ||
hasFlag('color=false')) {
return false;
}
if (hasFlag('color') ||
hasFlag('colors') ||
hasFlag('color=true') ||
hasFlag('color=always')) {
return true;
}
if (process.stdout && !process.stdout.isTTY) {
return false;
}
if (process.platform === 'win32') {
return true;
}
if ('COLORTERM' in process.env) {
return true;
}
if (process.env.TERM === 'dumb') {
return false;
}
if (/^screen|^xterm|^vt100|color|ansi|cygwin|linux/i.test(process.env.TERM)) {
return true;
}
return false;
})();

View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -0,0 +1,89 @@
{
"_from": "supports-color@^2.0.0",
"_id": "supports-color@2.0.0",
"_inBundle": false,
"_integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=",
"_location": "/http2-push-manifest/supports-color",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "supports-color@^2.0.0",
"name": "supports-color",
"escapedName": "supports-color",
"rawSpec": "^2.0.0",
"saveSpec": null,
"fetchSpec": "^2.0.0"
},
"_requiredBy": [
"/http2-push-manifest/chalk"
],
"_resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz",
"_shasum": "535d045ce6b6363fa40117084629995e9df324c7",
"_spec": "supports-color@^2.0.0",
"_where": "/Users/asciidisco/Desktop/asciidisco.com/build/node_modules/http2-push-manifest/node_modules/chalk",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"bugs": {
"url": "https://github.com/chalk/supports-color/issues"
},
"bundleDependencies": false,
"deprecated": false,
"description": "Detect whether a terminal supports color",
"devDependencies": {
"mocha": "*",
"require-uncached": "^1.0.2"
},
"engines": {
"node": ">=0.8.0"
},
"files": [
"index.js"
],
"homepage": "https://github.com/chalk/supports-color#readme",
"keywords": [
"color",
"colour",
"colors",
"terminal",
"console",
"cli",
"ansi",
"styles",
"tty",
"rgb",
"256",
"shell",
"xterm",
"command-line",
"support",
"supports",
"capability",
"detect"
],
"license": "MIT",
"maintainers": [
{
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
{
"name": "Joshua Appelman",
"email": "jappelman@xebia.com",
"url": "jbnicolai.com"
}
],
"name": "supports-color",
"repository": {
"type": "git",
"url": "git+https://github.com/chalk/supports-color.git"
},
"scripts": {
"test": "mocha"
},
"version": "2.0.0"
}

View File

@@ -0,0 +1,36 @@
# supports-color [![Build Status](https://travis-ci.org/chalk/supports-color.svg?branch=master)](https://travis-ci.org/chalk/supports-color)
> Detect whether a terminal supports color
## Install
```
$ npm install --save supports-color
```
## Usage
```js
var supportsColor = require('supports-color');
if (supportsColor) {
console.log('Terminal supports color');
}
```
It obeys the `--color` and `--no-color` CLI flags.
For situations where using `--color` is not possible, add an environment variable `FORCE_COLOR` with any value to force color. Trumps `--no-color`.
## Related
- [supports-color-cli](https://github.com/chalk/supports-color-cli) - CLI for this module
- [chalk](https://github.com/chalk/chalk) - Terminal string styling done right
## License
MIT © [Sindre Sorhus](http://sindresorhus.com)

View File

@@ -0,0 +1,34 @@
'use strict';
module.exports = function (req, time) {
if (req.timeoutTimer) { return req; }
var host = req._headers ? (' to ' + req._headers.host) : '';
req.timeoutTimer = setTimeout(function timeoutHandler() {
req.abort();
var e = new Error('Connection timed out on request' + host);
e.code = 'ETIMEDOUT';
req.emit('error', e);
}, time);
// Set additional timeout on socket - in case if remote
// server freeze after sending headers
req.setTimeout(time, function socketTimeoutHandler() {
req.abort();
var e = new Error('Socket timed out on request' + host);
e.code = 'ESOCKETTIMEDOUT';
req.emit('error', e);
});
function clear() {
if (req.timeoutTimer) {
clearTimeout(req.timeoutTimer);
req.timeoutTimer = null;
}
}
return req
.on('response', clear)
.on('error', clear);
};

View File

@@ -0,0 +1,67 @@
{
"_from": "timed-out@^2.0.0",
"_id": "timed-out@2.0.0",
"_inBundle": false,
"_integrity": "sha1-84sK6B03R9YoAB9B2vxlKs5nHAo=",
"_location": "/http2-push-manifest/timed-out",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "timed-out@^2.0.0",
"name": "timed-out",
"escapedName": "timed-out",
"rawSpec": "^2.0.0",
"saveSpec": null,
"fetchSpec": "^2.0.0"
},
"_requiredBy": [
"/http2-push-manifest/got"
],
"_resolved": "https://registry.npmjs.org/timed-out/-/timed-out-2.0.0.tgz",
"_shasum": "f38b0ae81d3747d628001f41dafc652ace671c0a",
"_spec": "timed-out@^2.0.0",
"_where": "/Users/asciidisco/Desktop/asciidisco.com/build/node_modules/http2-push-manifest/node_modules/got",
"author": {
"name": "Vsevolod Strukchinsky",
"email": "floatdrop@gmail.com"
},
"bugs": {
"url": "https://github.com/floatdrop/timed-out/issues"
},
"bundleDependencies": false,
"deprecated": false,
"description": "Emit `ETIMEDOUT` or `ESOCKETTIMEDOUT` when ClientRequest is hanged",
"devDependencies": {
"mocha": "*"
},
"engines": {
"node": ">=0.10.0"
},
"files": [
"index.js"
],
"homepage": "https://github.com/floatdrop/timed-out#readme",
"keywords": [
"http",
"https",
"get",
"got",
"url",
"uri",
"request",
"util",
"utility",
"simple"
],
"license": "MIT",
"name": "timed-out",
"repository": {
"type": "git",
"url": "git+https://github.com/floatdrop/timed-out.git"
},
"scripts": {
"test": "mocha"
},
"version": "2.0.0"
}

View File

@@ -0,0 +1,37 @@
# timed-out [![Build Status](https://travis-ci.org/floatdrop/timed-out.svg?branch=master)](https://travis-ci.org/floatdrop/timed-out)
> Timeout HTTP/HTTPS requests
Emit Error object with `code` property equal `ETIMEDOUT` or `ESOCKETTIMEDOUT` when ClientRequest is hanged.
## Usage
```js
var get = require('http').get;
var timeout = require('timed-out');
var req = get('http://www.google.ru');
timeout(req, 2000); // Set 2 seconds limit
```
### API
#### timedout(request, time)
##### request
*Required*
Type: [`ClientRequest`](http://nodejs.org/api/http.html#http_class_http_clientrequest)
The request to watch on.
##### time
*Required*
Type: `number`
Time in milliseconds before errors will be emitted and `request.abort()` call happens.
## License
MIT © [Vsevolod Strukchinsky](floatdrop@gmail.com)

View File

@@ -0,0 +1,21 @@
'use strict';
var updateNotifier = require('./');
var options = JSON.parse(process.argv[2]);
var updateNotifier = new updateNotifier.UpdateNotifier(options);
updateNotifier.checkNpm(function (err, update) {
if (err) {
process.exit(1);
}
// only update the last update check time on success
updateNotifier.config.set('lastUpdateCheck', Date.now());
if (update.type && update.type !== 'latest') {
updateNotifier.config.set('update', update);
}
// Call process exit explicitly to terminate the child process
// Otherwise the child process will run forever (according to nodejs docs)
process.exit();
});

View File

@@ -0,0 +1,128 @@
'use strict';
var spawn = require('child_process').spawn;
var path = require('path');
var Configstore = require('configstore');
var chalk = require('chalk');
var semverDiff = require('semver-diff');
var latestVersion = require('latest-version');
var stringLength = require('string-length');
var isNpm = require('is-npm');
var repeating = require('repeating');
function UpdateNotifier(options) {
this.options = options = options || {};
options.pkg = options.pkg || {};
// deprecated options
// TODO: remove this at some point far into the future
if (options.packageName && options.packageVersion) {
options.pkg.name = options.packageName;
options.pkg.version = options.packageVersion;
}
if (!options.pkg.name || !options.pkg.version) {
throw new Error('pkg.name and pkg.version required');
}
this.packageName = options.pkg.name;
this.packageVersion = options.pkg.version;
this.updateCheckInterval = typeof options.updateCheckInterval === 'number' ? options.updateCheckInterval : 1000 * 60 * 60 * 24; // 1 day
this.hasCallback = typeof options.callback === 'function';
this.callback = options.callback || function () {};
if (!this.hasCallback) {
this.config = new Configstore('update-notifier-' + this.packageName, {
optOut: false,
// init with the current time so the first check is only
// after the set interval, so not to bother users right away
lastUpdateCheck: Date.now()
});
}
}
UpdateNotifier.prototype.check = function () {
if (this.hasCallback) {
return this.checkNpm(this.callback);
}
if (this.config.get('optOut') || 'NO_UPDATE_NOTIFIER' in process.env || process.argv.indexOf('--no-update-notifier') !== -1) {
return;
}
this.update = this.config.get('update');
if (this.update) {
this.config.del('update');
}
// Only check for updates on a set interval
if (Date.now() - this.config.get('lastUpdateCheck') < this.updateCheckInterval) {
return;
}
// Spawn a detached process, passing the options as an environment property
spawn(process.execPath, [path.join(__dirname, 'check.js'), JSON.stringify(this.options)], {
detached: true,
stdio: 'ignore'
}).unref();
};
UpdateNotifier.prototype.checkNpm = function (cb) {
latestVersion(this.packageName, function (err, latestVersion) {
if (err) {
return cb(err);
}
cb(null, {
latest: latestVersion,
current: this.packageVersion,
type: semverDiff(this.packageVersion, latestVersion) || 'latest',
name: this.packageName
});
}.bind(this));
};
UpdateNotifier.prototype.notify = function (opts) {
if (!process.stdout.isTTY || isNpm || !this.update) {
return this;
}
opts = opts || {};
opts.defer = opts.defer === undefined ? true : false;
var line1 = ' Update available: ' + chalk.green.bold(this.update.latest) +
chalk.dim(' (current: ' + this.update.current + ')') + ' ';
var line2 = ' Run ' + chalk.blue('npm install -g ' + this.packageName) +
' to update. ';
var contentWidth = Math.max(stringLength(line1), stringLength(line2));
var line1rest = contentWidth - stringLength(line1);
var line2rest = contentWidth - stringLength(line2);
var top = chalk.yellow('┌' + repeating('─', contentWidth) + '┐');
var bottom = chalk.yellow('└' + repeating('─', contentWidth) + '┘');
var side = chalk.yellow('│');
var message =
'\n\n' +
top + '\n' +
side + line1 + repeating(' ', line1rest) + side + '\n' +
side + line2 + repeating(' ', line2rest) + side + '\n' +
bottom + '\n';
if (opts.defer) {
process.on('exit', function () {
console.error(message);
});
} else {
console.error(message);
}
return this;
};
module.exports = function (options) {
var updateNotifier = new UpdateNotifier(options);
updateNotifier.check();
return updateNotifier;
};
module.exports.UpdateNotifier = UpdateNotifier;

View File

@@ -0,0 +1,79 @@
{
"_from": "update-notifier@^0.5.0",
"_id": "update-notifier@0.5.0",
"_inBundle": false,
"_integrity": "sha1-B7XcIGazYnqztPUwEw9+3doHpMw=",
"_location": "/http2-push-manifest/update-notifier",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "update-notifier@^0.5.0",
"name": "update-notifier",
"escapedName": "update-notifier",
"rawSpec": "^0.5.0",
"saveSpec": null,
"fetchSpec": "^0.5.0"
},
"_requiredBy": [
"/http2-push-manifest"
],
"_resolved": "https://registry.npmjs.org/update-notifier/-/update-notifier-0.5.0.tgz",
"_shasum": "07b5dc2066b3627ab3b4f530130f7eddda07a4cc",
"_spec": "update-notifier@^0.5.0",
"_where": "/Users/asciidisco/Desktop/asciidisco.com/build/node_modules/http2-push-manifest",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "http://sindresorhus.com"
},
"bugs": {
"url": "https://github.com/yeoman/update-notifier/issues"
},
"bundleDependencies": false,
"dependencies": {
"chalk": "^1.0.0",
"configstore": "^1.0.0",
"is-npm": "^1.0.0",
"latest-version": "^1.0.0",
"repeating": "^1.1.2",
"semver-diff": "^2.0.0",
"string-length": "^1.0.0"
},
"deprecated": false,
"description": "Update notifications for your CLI app",
"devDependencies": {
"mocha": "*"
},
"engines": {
"node": ">=0.10.0"
},
"files": [
"index.js",
"check.js"
],
"homepage": "https://github.com/yeoman/update-notifier#readme",
"keywords": [
"npm",
"update",
"updater",
"notify",
"notifier",
"check",
"checker",
"cli",
"module",
"package",
"version"
],
"license": "BSD-2-Clause",
"name": "update-notifier",
"repository": {
"type": "git",
"url": "git+https://github.com/yeoman/update-notifier.git"
},
"scripts": {
"test": "mocha --timeout 20000"
},
"version": "0.5.0"
}

View File

@@ -0,0 +1,152 @@
# update-notifier [![Build Status](https://travis-ci.org/yeoman/update-notifier.svg?branch=master)](https://travis-ci.org/yeoman/update-notifier)
> Update notifications for your CLI app
![](screenshot.png)
Inform users of your package of updates in a non-intrusive way.
#### Table of Contents
- [Examples](#examples)
- [How](#how)
- [API](#api)
- [About](#about)
## Examples
### Simple example
```js
var updateNotifier = require('update-notifier');
var pkg = require('./package.json');
updateNotifier({pkg: pkg}).notify();
```
### Comprehensive example
```js
var updateNotifier = require('update-notifier');
var pkg = require('./package.json');
// Checks for available update and returns an instance
var notifier = updateNotifier({pkg: pkg});
// Notify using the built-in convenience method
notifier.notify();
// `notifier.update` contains some useful info about the update
console.log(notifier.update);
/*
{
latest: '1.0.1',
current: '1.0.0',
type: 'patch', // possible values: latest, major, minor, patch, prerelease, build
name: 'pageres'
}
*/
```
### Example with settings and custom message
```js
var notifier = updateNotifier({
pkg: pkg,
updateCheckInterval: 1000 * 60 * 60 * 24 * 7 // 1 week
});
console.log('Update available: ' + notifier.update.latest);
```
## How
Whenever you initiate the update notifier and it's not within the interval threshold, it will asynchronously check with npm in the background for available updates, then persist the result. The next time the notifier is initiated the result will be loaded into the `.update` property. This prevents any impact on your package startup performance.
The check process is done in a unref'ed [child process](http://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options). This means that if you call `process.exit`, the check will still be performed in its own process.
## API
### updateNotifier(options)
Checks if there is an available update. Accepts settings defined below. Returns an object with update info if there is an available update, otherwise `undefined`.
### options
#### pkg
Type: `object`
##### name
*Required*
Type: `string`
##### version
*Required*
Type: `string`
#### updateCheckInterval
Type: `number`
Default: `1000 * 60 * 60 * 24` (1 day)
How often to check for updates.
#### callback(error, update)
Type: `function`
Passing a callback here will make it check for an update directly and report right away. Not recommended as you won't get the benefits explained in [`How`](#how).
`update` is equal to `notifier.update`
### updateNotifier.notify([options])
Convenience method to display a notification message *(see screenshot)*.
Only notifies if there is an update and the process is [TTY](http://nodejs.org/api/tty.html).
#### options.defer
Type: `boolean`
Default: `true`
Defer showing the notication to after the process has exited.
### User settings
Users of your module have the ability to opt-out of the update notifier by changing the `optOut` property to `true` in `~/.config/configstore/update-notifier-[your-module-name].yml`. The path is available in `notifier.config.path`.
Users can also opt-out by [setting the environment variable](https://github.com/sindresorhus/guides/blob/master/set-environment-variables.md) `NO_UPDATE_NOTIFIER` with any value or by using the `--no-update-notifier` flag on a per run basis.
## About
The idea for this module came from the desire to apply the browser update strategy to CLI tools, where everyone is always on the latest version. We first tried automatic updating, which we discovered wasn't popular. This is the second iteration of that idea, but limited to just update notifications.
There are a bunch projects using it:
- [Yeoman](http://yeoman.io) - modern workflows for modern webapps
- [Bower](http://bower.io) - a package manager for the web
- [Pageres](https://github.com/sindresorhus/pageres) - responsive website screenshots
- [Node GH](http://nodegh.io) - GitHub command line tool
- [Hoodie CLI](http://hood.ie) - Hoodie command line tool
- [Roots](http://roots.cx) - a toolkit for advanced front-end development
[And 100+ more...](https://www.npmjs.org/browse/depended/update-notifier)
## License
[BSD license](http://opensource.org/licenses/bsd-license.php) and copyright Google

View File

@@ -0,0 +1,2 @@
node_modules
.DS_Store

View File

@@ -0,0 +1,5 @@
language: node_js
node_js:
- "0.6"
- "0.8"
- "0.10"

View File

@@ -0,0 +1,2 @@
Copyright (c) 2010-2012 Robert Kieffer
MIT License - http://opensource.org/licenses/mit-license.php

View File

@@ -0,0 +1,205 @@
# uuid [![Build Status](https://secure.travis-ci.org/defunctzombie/node-uuid.svg?branch=master)](http://travis-ci.org/defunctzombie/node-uuid) #
[![browser support](https://ci.testling.com/defunctzombie/node-uuid.png)](https://ci.testling.com/defunctzombie/node-uuid)
Simple, fast generation of [RFC4122](http://www.ietf.org/rfc/rfc4122.txt) UUIDS.
Features:
* Generate RFC4122 version 1 or version 4 UUIDs
* Runs in node.js and all browsers.
* Cryptographically strong random # generation on supporting platforms
* 1185 bytes minified and gzip'ed (Want something smaller? Check this [crazy shit](https://gist.github.com/982883) out! )
* [Annotated source code](http://broofa.github.com/node-uuid/docs/uuid.html)
## Getting Started
Install it in your browser:
```html
<script src="uuid.js"></script>
```
Or in node.js:
```
npm install uuid
```
```javascript
var uuid = require('uuid');
// Generate a v1 (time-based) id
uuid.v1(); // -> '6c84fb90-12c4-11e1-840d-7b25c5ee775a'
// Generate a v4 (random) id
uuid.v4(); // -> '110ec58a-a0f2-4ac4-8393-c866d813b8d1'
```
## API
### uuid.v1([`options` [, `buffer` [, `offset`]]])
Generate and return a RFC4122 v1 (timestamp-based) UUID.
* `options` - (Object) Optional uuid state to apply. Properties may include:
* `node` - (Array) Node id as Array of 6 bytes (per 4.1.6). Default: Randomly generated ID. See note 1.
* `clockseq` - (Number between 0 - 0x3fff) RFC clock sequence. Default: An internally maintained clockseq is used.
* `msecs` - (Number | Date) Time in milliseconds since unix Epoch. Default: The current time is used.
* `nsecs` - (Number between 0-9999) additional time, in 100-nanosecond units. Ignored if `msecs` is unspecified. Default: internal uuid counter is used, as per 4.2.1.2.
* `buffer` - (Array | Buffer) Array or buffer where UUID bytes are to be written.
* `offset` - (Number) Starting index in `buffer` at which to begin writing.
Returns `buffer`, if specified, otherwise the string form of the UUID
Notes:
1. The randomly generated node id is only guaranteed to stay constant for the lifetime of the current JS runtime. (Future versions of this module may use persistent storage mechanisms to extend this guarantee.)
Example: Generate string UUID with fully-specified options
```javascript
uuid.v1({
node: [0x01, 0x23, 0x45, 0x67, 0x89, 0xab],
clockseq: 0x1234,
msecs: new Date('2011-11-01').getTime(),
nsecs: 5678
}); // -> "710b962e-041c-11e1-9234-0123456789ab"
```
Example: In-place generation of two binary IDs
```javascript
// Generate two ids in an array
var arr = new Array(32); // -> []
uuid.v1(null, arr, 0); // -> [02 a2 ce 90 14 32 11 e1 85 58 0b 48 8e 4f c1 15]
uuid.v1(null, arr, 16); // -> [02 a2 ce 90 14 32 11 e1 85 58 0b 48 8e 4f c1 15 02 a3 1c b0 14 32 11 e1 85 58 0b 48 8e 4f c1 15]
// Optionally use uuid.unparse() to get stringify the ids
uuid.unparse(buffer); // -> '02a2ce90-1432-11e1-8558-0b488e4fc115'
uuid.unparse(buffer, 16) // -> '02a31cb0-1432-11e1-8558-0b488e4fc115'
```
### uuid.v4([`options` [, `buffer` [, `offset`]]])
Generate and return a RFC4122 v4 UUID.
* `options` - (Object) Optional uuid state to apply. Properties may include:
* `random` - (Number[16]) Array of 16 numbers (0-255) to use in place of randomly generated values
* `rng` - (Function) Random # generator to use. Set to one of the built-in generators - `uuid.mathRNG` (all platforms), `uuid.nodeRNG` (node.js only), `uuid.whatwgRNG` (WebKit only) - or a custom function that returns an array[16] of byte values.
* `buffer` - (Array | Buffer) Array or buffer where UUID bytes are to be written.
* `offset` - (Number) Starting index in `buffer` at which to begin writing.
Returns `buffer`, if specified, otherwise the string form of the UUID
Example: Generate string UUID with fully-specified options
```javascript
uuid.v4({
random: [
0x10, 0x91, 0x56, 0xbe, 0xc4, 0xfb, 0xc1, 0xea,
0x71, 0xb4, 0xef, 0xe1, 0x67, 0x1c, 0x58, 0x36
]
});
// -> "109156be-c4fb-41ea-b1b4-efe1671c5836"
```
Example: Generate two IDs in a single buffer
```javascript
var buffer = new Array(32); // (or 'new Buffer' in node.js)
uuid.v4(null, buffer, 0);
uuid.v4(null, buffer, 16);
```
### uuid.parse(id[, buffer[, offset]])
### uuid.unparse(buffer[, offset])
Parse and unparse UUIDs
* `id` - (String) UUID(-like) string
* `buffer` - (Array | Buffer) Array or buffer where UUID bytes are to be written. Default: A new Array or Buffer is used
* `offset` - (Number) Starting index in `buffer` at which to begin writing. Default: 0
Example parsing and unparsing a UUID string
```javascript
var bytes = uuid.parse('797ff043-11eb-11e1-80d6-510998755d10'); // -> <Buffer 79 7f f0 43 11 eb 11 e1 80 d6 51 09 98 75 5d 10>
var string = uuid.unparse(bytes); // -> '797ff043-11eb-11e1-80d6-510998755d10'
```
### uuid.noConflict()
(Browsers only) Set `uuid` property back to it's previous value.
Returns the uuid object.
Example:
```javascript
var myUuid = uuid.noConflict();
myUuid.v1(); // -> '6c84fb90-12c4-11e1-840d-7b25c5ee775a'
```
## Deprecated APIs
Support for the following v1.2 APIs is available in v1.3, but is deprecated and will be removed in the next major version.
### uuid([format [, buffer [, offset]]])
uuid() has become uuid.v4(), and the `format` argument is now implicit in the `buffer` argument. (i.e. if you specify a buffer, the format is assumed to be binary).
## Testing
In node.js
```
> cd test
> node test.js
```
In Browser
```
open test/test.html
```
### Benchmarking
Requires node.js
```
cd benchmark/
npm install
node benchmark.js
```
For a more complete discussion of uuid performance, please see the `benchmark/README.md` file, and the [benchmark wiki](https://github.com/broofa/uuid/wiki/Benchmark)
For browser performance [checkout the JSPerf tests](http://jsperf.com/node-uuid-performance).
## Release notes
### 2.0.0
* Removed uuid.BufferClass
### 1.4.0
* Improved module context detection
* Removed public RNG functions
### 1.3.2
* Improve tests and handling of v1() options (Issue #24)
* Expose RNG option to allow for perf testing with different generators
### 1.3.0
* Support for version 1 ids, thanks to [@ctavan](https://github.com/ctavan)!
* Support for node.js crypto API
* De-emphasizing performance in favor of a) cryptographic quality PRNGs where available and b) more manageable code

View File

@@ -0,0 +1,53 @@
# node-uuid Benchmarks
### Results
To see the results of our benchmarks visit https://github.com/broofa/node-uuid/wiki/Benchmark
### Run them yourself
node-uuid comes with some benchmarks to measure performance of generating UUIDs. These can be run using node.js. node-uuid is being benchmarked against some other uuid modules, that are available through npm namely `uuid` and `uuid-js`.
To prepare and run the benchmark issue;
```
npm install uuid uuid-js
node benchmark/benchmark.js
```
You'll see an output like this one:
```
# v4
nodeuuid.v4(): 854700 uuids/second
nodeuuid.v4('binary'): 788643 uuids/second
nodeuuid.v4('binary', buffer): 1336898 uuids/second
uuid(): 479386 uuids/second
uuid('binary'): 582072 uuids/second
uuidjs.create(4): 312304 uuids/second
# v1
nodeuuid.v1(): 938086 uuids/second
nodeuuid.v1('binary'): 683060 uuids/second
nodeuuid.v1('binary', buffer): 1644736 uuids/second
uuidjs.create(1): 190621 uuids/second
```
* The `uuid()` entries are for Nikhil Marathe's [uuid module](https://bitbucket.org/nikhilm/uuidjs) which is a wrapper around the native libuuid library.
* The `uuidjs()` entries are for Patrick Negri's [uuid-js module](https://github.com/pnegri/uuid-js) which is a pure javascript implementation based on [UUID.js](https://github.com/LiosK/UUID.js) by LiosK.
If you want to get more reliable results you can run the benchmark multiple times and write the output into a log file:
```
for i in {0..9}; do node benchmark/benchmark.js >> benchmark/bench_0.4.12.log; done;
```
If you're interested in how performance varies between different node versions, you can issue the above command multiple times.
You can then use the shell script `bench.sh` provided in this directory to calculate the averages over all benchmark runs and draw a nice plot:
```
(cd benchmark/ && ./bench.sh)
```
This assumes you have [gnuplot](http://www.gnuplot.info/) and [ImageMagick](http://www.imagemagick.org/) installed. You'll find a nice `bench.png` graph in the `benchmark/` directory then.

View File

@@ -0,0 +1,174 @@
#!/opt/local/bin/gnuplot -persist
#
#
# G N U P L O T
# Version 4.4 patchlevel 3
# last modified March 2011
# System: Darwin 10.8.0
#
# Copyright (C) 1986-1993, 1998, 2004, 2007-2010
# Thomas Williams, Colin Kelley and many others
#
# gnuplot home: http://www.gnuplot.info
# faq, bugs, etc: type "help seeking-assistance"
# immediate help: type "help"
# plot window: hit 'h'
set terminal postscript eps noenhanced defaultplex \
leveldefault color colortext \
solid linewidth 1.2 butt noclip \
palfuncparam 2000,0.003 \
"Helvetica" 14
set output 'bench.eps'
unset clip points
set clip one
unset clip two
set bar 1.000000 front
set border 31 front linetype -1 linewidth 1.000
set xdata
set ydata
set zdata
set x2data
set y2data
set timefmt x "%d/%m/%y,%H:%M"
set timefmt y "%d/%m/%y,%H:%M"
set timefmt z "%d/%m/%y,%H:%M"
set timefmt x2 "%d/%m/%y,%H:%M"
set timefmt y2 "%d/%m/%y,%H:%M"
set timefmt cb "%d/%m/%y,%H:%M"
set boxwidth
set style fill empty border
set style rectangle back fc lt -3 fillstyle solid 1.00 border lt -1
set style circle radius graph 0.02, first 0, 0
set dummy x,y
set format x "% g"
set format y "% g"
set format x2 "% g"
set format y2 "% g"
set format z "% g"
set format cb "% g"
set angles radians
unset grid
set key title ""
set key outside left top horizontal Right noreverse enhanced autotitles columnhead nobox
set key noinvert samplen 4 spacing 1 width 0 height 0
set key maxcolumns 2 maxrows 0
unset label
unset arrow
set style increment default
unset style line
set style line 1 linetype 1 linewidth 2.000 pointtype 1 pointsize default pointinterval 0
unset style arrow
set style histogram clustered gap 2 title offset character 0, 0, 0
unset logscale
set offsets graph 0.05, 0.15, 0, 0
set pointsize 1.5
set pointintervalbox 1
set encoding default
unset polar
unset parametric
unset decimalsign
set view 60, 30, 1, 1
set samples 100, 100
set isosamples 10, 10
set surface
unset contour
set clabel '%8.3g'
set mapping cartesian
set datafile separator whitespace
unset hidden3d
set cntrparam order 4
set cntrparam linear
set cntrparam levels auto 5
set cntrparam points 5
set size ratio 0 1,1
set origin 0,0
set style data points
set style function lines
set xzeroaxis linetype -2 linewidth 1.000
set yzeroaxis linetype -2 linewidth 1.000
set zzeroaxis linetype -2 linewidth 1.000
set x2zeroaxis linetype -2 linewidth 1.000
set y2zeroaxis linetype -2 linewidth 1.000
set ticslevel 0.5
set mxtics default
set mytics default
set mztics default
set mx2tics default
set my2tics default
set mcbtics default
set xtics border in scale 1,0.5 mirror norotate offset character 0, 0, 0
set xtics norangelimit
set xtics ()
set ytics border in scale 1,0.5 mirror norotate offset character 0, 0, 0
set ytics autofreq norangelimit
set ztics border in scale 1,0.5 nomirror norotate offset character 0, 0, 0
set ztics autofreq norangelimit
set nox2tics
set noy2tics
set cbtics border in scale 1,0.5 mirror norotate offset character 0, 0, 0
set cbtics autofreq norangelimit
set title ""
set title offset character 0, 0, 0 font "" norotate
set timestamp bottom
set timestamp ""
set timestamp offset character 0, 0, 0 font "" norotate
set rrange [ * : * ] noreverse nowriteback # (currently [8.98847e+307:-8.98847e+307] )
set autoscale rfixmin
set autoscale rfixmax
set trange [ * : * ] noreverse nowriteback # (currently [-5.00000:5.00000] )
set autoscale tfixmin
set autoscale tfixmax
set urange [ * : * ] noreverse nowriteback # (currently [-10.0000:10.0000] )
set autoscale ufixmin
set autoscale ufixmax
set vrange [ * : * ] noreverse nowriteback # (currently [-10.0000:10.0000] )
set autoscale vfixmin
set autoscale vfixmax
set xlabel ""
set xlabel offset character 0, 0, 0 font "" textcolor lt -1 norotate
set x2label ""
set x2label offset character 0, 0, 0 font "" textcolor lt -1 norotate
set xrange [ * : * ] noreverse nowriteback # (currently [-0.150000:3.15000] )
set autoscale xfixmin
set autoscale xfixmax
set x2range [ * : * ] noreverse nowriteback # (currently [0.00000:3.00000] )
set autoscale x2fixmin
set autoscale x2fixmax
set ylabel ""
set ylabel offset character 0, 0, 0 font "" textcolor lt -1 rotate by -270
set y2label ""
set y2label offset character 0, 0, 0 font "" textcolor lt -1 rotate by -270
set yrange [ 0.00000 : 1.90000e+06 ] noreverse nowriteback # (currently [:] )
set autoscale yfixmin
set autoscale yfixmax
set y2range [ * : * ] noreverse nowriteback # (currently [0.00000:1.90000e+06] )
set autoscale y2fixmin
set autoscale y2fixmax
set zlabel ""
set zlabel offset character 0, 0, 0 font "" textcolor lt -1 norotate
set zrange [ * : * ] noreverse nowriteback # (currently [-10.0000:10.0000] )
set autoscale zfixmin
set autoscale zfixmax
set cblabel ""
set cblabel offset character 0, 0, 0 font "" textcolor lt -1 rotate by -270
set cbrange [ * : * ] noreverse nowriteback # (currently [8.98847e+307:-8.98847e+307] )
set autoscale cbfixmin
set autoscale cbfixmax
set zero 1e-08
set lmargin -1
set bmargin -1
set rmargin -1
set tmargin -1
set pm3d explicit at s
set pm3d scansautomatic
set pm3d interpolate 1,1 flush begin noftriangles nohidden3d corners2color mean
set palette positive nops_allcF maxcolors 0 gamma 1.5 color model RGB
set palette rgbformulae 7, 5, 15
set colorbox default
set colorbox vertical origin screen 0.9, 0.2, 0 size screen 0.05, 0.6, 0 front bdefault
set loadpath
set fontpath
set fit noerrorvariables
GNUTERM = "aqua"
plot 'bench_results.txt' using 2:xticlabel(1) w lp lw 2, '' using 3:xticlabel(1) w lp lw 2, '' using 4:xticlabel(1) w lp lw 2, '' using 5:xticlabel(1) w lp lw 2, '' using 6:xticlabel(1) w lp lw 2, '' using 7:xticlabel(1) w lp lw 2, '' using 8:xticlabel(1) w lp lw 2, '' using 9:xticlabel(1) w lp lw 2
# EOF

View File

@@ -0,0 +1,34 @@
#!/bin/bash
# for a given node version run:
# for i in {0..9}; do node benchmark.js >> bench_0.6.2.log; done;
PATTERNS=('nodeuuid.v1()' "nodeuuid.v1('binary'," 'nodeuuid.v4()' "nodeuuid.v4('binary'," "uuid()" "uuid('binary')" 'uuidjs.create(1)' 'uuidjs.create(4)' '140byte')
FILES=(node_uuid_v1_string node_uuid_v1_buf node_uuid_v4_string node_uuid_v4_buf libuuid_v4_string libuuid_v4_binary uuidjs_v1_string uuidjs_v4_string 140byte_es)
INDICES=(2 3 2 3 2 2 2 2 2)
VERSIONS=$( ls bench_*.log | sed -e 's/^bench_\([0-9\.]*\)\.log/\1/' | tr "\\n" " " )
TMPJOIN="tmp_join"
OUTPUT="bench_results.txt"
for I in ${!FILES[*]}; do
F=${FILES[$I]}
P=${PATTERNS[$I]}
INDEX=${INDICES[$I]}
echo "version $F" > $F
for V in $VERSIONS; do
(VAL=$( grep "$P" bench_$V.log | LC_ALL=en_US awk '{ sum += $'$INDEX' } END { print sum/NR }' ); echo $V $VAL) >> $F
done
if [ $I == 0 ]; then
cat $F > $TMPJOIN
else
join $TMPJOIN $F > $OUTPUT
cp $OUTPUT $TMPJOIN
fi
rm $F
done
rm $TMPJOIN
gnuplot bench.gnu
convert -density 200 -resize 800x560 -flatten bench.eps bench.png
rm bench.eps

View File

@@ -0,0 +1,34 @@
/*
Test performance of native C UUID generation
To Compile: cc -luuid benchmark-native.c -o benchmark-native
*/
#include <stdio.h>
#include <unistd.h>
#include <sys/time.h>
#include <uuid/uuid.h>
int main() {
uuid_t myid;
char buf[36+1];
int i;
struct timeval t;
double start, finish;
gettimeofday(&t, NULL);
start = t.tv_sec + t.tv_usec/1e6;
int n = 2e5;
for (i = 0; i < n; i++) {
uuid_generate(myid);
uuid_unparse(myid, buf);
}
gettimeofday(&t, NULL);
finish = t.tv_sec + t.tv_usec/1e6;
double dur = finish - start;
printf("%d uuids/sec", (int)(n/dur));
return 0;
}

View File

@@ -0,0 +1,84 @@
try {
var nodeuuid = require('../uuid');
} catch (e) {
console.error('node-uuid require failed - skipping tests');
}
try {
var uuid = require('uuid');
} catch (e) {
console.error('uuid require failed - skipping tests');
}
try {
var uuidjs = require('uuid-js');
} catch (e) {
console.error('uuid-js require failed - skipping tests');
}
var N = 5e5;
function rate(msg, t) {
console.log(msg + ': ' +
(N / (Date.now() - t) * 1e3 | 0) +
' uuids/second');
}
console.log('# v4');
// node-uuid - string form
if (nodeuuid) {
for (var i = 0, t = Date.now(); i < N; i++) nodeuuid.v4();
rate('nodeuuid.v4() - using node.js crypto RNG', t);
for (var i = 0, t = Date.now(); i < N; i++) nodeuuid.v4({rng: nodeuuid.mathRNG});
rate('nodeuuid.v4() - using Math.random() RNG', t);
for (var i = 0, t = Date.now(); i < N; i++) nodeuuid.v4('binary');
rate('nodeuuid.v4(\'binary\')', t);
var buffer = new nodeuuid.BufferClass(16);
for (var i = 0, t = Date.now(); i < N; i++) nodeuuid.v4('binary', buffer);
rate('nodeuuid.v4(\'binary\', buffer)', t);
}
// libuuid - string form
if (uuid) {
for (var i = 0, t = Date.now(); i < N; i++) uuid();
rate('uuid()', t);
for (var i = 0, t = Date.now(); i < N; i++) uuid('binary');
rate('uuid(\'binary\')', t);
}
// uuid-js - string form
if (uuidjs) {
for (var i = 0, t = Date.now(); i < N; i++) uuidjs.create(4);
rate('uuidjs.create(4)', t);
}
// 140byte.es
for (var i = 0, t = Date.now(); i < N; i++) 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g,function(s,r){r=Math.random()*16|0;return (s=='x'?r:r&0x3|0x8).toString(16)});
rate('140byte.es_v4', t);
console.log('');
console.log('# v1');
// node-uuid - v1 string form
if (nodeuuid) {
for (var i = 0, t = Date.now(); i < N; i++) nodeuuid.v1();
rate('nodeuuid.v1()', t);
for (var i = 0, t = Date.now(); i < N; i++) nodeuuid.v1('binary');
rate('nodeuuid.v1(\'binary\')', t);
var buffer = new nodeuuid.BufferClass(16);
for (var i = 0, t = Date.now(); i < N; i++) nodeuuid.v1('binary', buffer);
rate('nodeuuid.v1(\'binary\', buffer)', t);
}
// uuid-js - v1 string form
if (uuidjs) {
for (var i = 0, t = Date.now(); i < N; i++) uuidjs.create(1);
rate('uuidjs.create(1)', t);
}

View File

@@ -0,0 +1,9 @@
{
"name": "benchmark-uuid",
"private": true,
"description": "Benchmarks for node-uuid",
"dependencies": {
"uuid": "1.4.1",
"uuid-js": "0.7.4"
}
}

View File

@@ -0,0 +1,62 @@
var assert = require('assert'),
nodeuuid = require('../'),
uuidjs = require('uuid-js'),
util = require('util'),
exec = require('child_process').exec,
os = require('os');
// On Mac Os X / macports there's only the ossp-uuid package that provides uuid
// On Linux there's uuid-runtime which provides uuidgen
var uuidCmd = os.type() === 'Darwin' ? 'uuid -1' : 'uuidgen -t';
function compare(ids) {
console.log(ids);
for (var i = 0; i < ids.length; i++) {
var id = ids[i].split('-');
id = [id[2], id[1], id[0]].join('');
ids[i] = id;
}
var sorted = ([].concat(ids)).sort();
if (sorted.toString() !== ids.toString()) {
console.log('Warning: sorted !== ids');
} else {
console.log('everything in order!');
}
}
// Test time order of v1 uuids
var ids = [];
while (ids.length < 10e3) ids.push(nodeuuid.v1());
var max = 10;
console.log('node-uuid:');
ids = [];
for (var i = 0; i < max; i++) ids.push(nodeuuid.v1());
compare(ids);
console.log('');
console.log('uuidjs:');
ids = [];
for (var i = 0; i < max; i++) ids.push(uuidjs.create(1).toString());
compare(ids);
console.log('');
console.log('libuuid:');
ids = [];
var count = 0;
var last = function() {
compare(ids);
}
var cb = function(err, stdout, stderr) {
ids.push(stdout.substring(0, stdout.length-1));
count++;
if (count < max) {
return next();
}
last();
};
var next = function() {
exec(uuidCmd, cb);
};
next();

View File

@@ -0,0 +1,102 @@
var assert = require('assert');
var uuid = require('../');
var log = console.log;
var generators = {
v1: uuid.v1,
v4: uuid.v4
};
var UUID_FORMAT = {
v1: /[0-9a-f]{8}-[0-9a-f]{4}-1[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/i,
v4: /[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/i
};
var N = 1e4;
// Get %'age an actual value differs from the ideal value
function divergence(actual, ideal) {
return Math.round(100*100*(actual - ideal)/ideal)/100;
}
function rate(msg, t) {
log(msg + ': ' + (N / (Date.now() - t) * 1e3 | 0) + ' uuids\/second');
}
for (var version in generators) {
var counts = {}, max = 0;
var generator = generators[version];
var format = UUID_FORMAT[version];
log('\nSanity check ' + N + ' ' + version + ' uuids');
for (var i = 0, ok = 0; i < N; i++) {
id = generator();
if (!format.test(id)) {
throw Error(id + ' is not a valid UUID string');
}
if (id != uuid.unparse(uuid.parse(id))) {
assert(fail, id + ' is not a valid id');
}
// Count digits for our randomness check
if (version == 'v4') {
var digits = id.replace(/-/g, '').split('');
for (var j = digits.length-1; j >= 0; j--) {
var c = digits[j];
max = Math.max(max, counts[c] = (counts[c] || 0) + 1);
}
}
}
// Check randomness for v4 UUIDs
if (version == 'v4') {
// Limit that we get worried about randomness. (Purely empirical choice, this!)
var limit = 2*100*Math.sqrt(1/N);
log('\nChecking v4 randomness. Distribution of Hex Digits (% deviation from ideal)');
for (var i = 0; i < 16; i++) {
var c = i.toString(16);
var bar = '', n = counts[c], p = Math.round(n/max*100|0);
// 1-3,5-8, and D-F: 1:16 odds over 30 digits
var ideal = N*30/16;
if (i == 4) {
// 4: 1:1 odds on 1 digit, plus 1:16 odds on 30 digits
ideal = N*(1 + 30/16);
} else if (i >= 8 && i <= 11) {
// 8-B: 1:4 odds on 1 digit, plus 1:16 odds on 30 digits
ideal = N*(1/4 + 30/16);
} else {
// Otherwise: 1:16 odds on 30 digits
ideal = N*30/16;
}
var d = divergence(n, ideal);
// Draw bar using UTF squares (just for grins)
var s = n/max*50 | 0;
while (s--) bar += '=';
assert(Math.abs(d) < limit, c + ' |' + bar + '| ' + counts[c] + ' (' + d + '% < ' + limit + '%)');
}
}
}
// Perf tests
for (var version in generators) {
log('\nPerformance testing ' + version + ' UUIDs');
var generator = generators[version];
var buf = new uuid.BufferClass(16);
for (var i = 0, t = Date.now(); i < N; i++) generator();
rate('uuid.' + version + '()', t);
for (var i = 0, t = Date.now(); i < N; i++) generator('binary');
rate('uuid.' + version + '(\'binary\')', t);
for (var i = 0, t = Date.now(); i < N; i++) generator('binary', buf);
rate('uuid.' + version + '(\'binary\', buffer)', t);
}

View File

@@ -0,0 +1,78 @@
{
"_from": "uuid@^2.0.1",
"_id": "uuid@2.0.3",
"_inBundle": false,
"_integrity": "sha1-Z+LoY3lyFVMN/zGOW/nc6/1Hsho=",
"_location": "/http2-push-manifest/uuid",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "uuid@^2.0.1",
"name": "uuid",
"escapedName": "uuid",
"rawSpec": "^2.0.1",
"saveSpec": null,
"fetchSpec": "^2.0.1"
},
"_requiredBy": [
"/http2-push-manifest/configstore"
],
"_resolved": "https://registry.npmjs.org/uuid/-/uuid-2.0.3.tgz",
"_shasum": "67e2e863797215530dff318e5bf9dcebfd47b21a",
"_spec": "uuid@^2.0.1",
"_where": "/Users/asciidisco/Desktop/asciidisco.com/build/node_modules/http2-push-manifest/node_modules/configstore",
"author": {
"name": "Robert Kieffer",
"email": "robert@broofa.com"
},
"browser": {
"./rng.js": "./rng-browser.js"
},
"bugs": {
"url": "https://github.com/defunctzombie/node-uuid/issues"
},
"bundleDependencies": false,
"contributors": [
{
"name": "Christoph Tavan",
"email": "dev@tavan.de"
},
{
"name": "Vincent Voyer",
"email": "vincent@zeroload.net"
}
],
"deprecated": false,
"description": "Rigorous implementation of RFC4122 (v1 and v4) UUIDs.",
"devDependencies": {
"mocha": "1.8.0"
},
"homepage": "https://github.com/defunctzombie/node-uuid#readme",
"keywords": [
"uuid",
"guid",
"rfc4122"
],
"license": "MIT",
"main": "./uuid.js",
"name": "uuid",
"repository": {
"type": "git",
"url": "git+https://github.com/defunctzombie/node-uuid.git"
},
"scripts": {
"test": "mocha test/test.js"
},
"testling": {
"browsers": [
"ie6..latest",
"firefox/3.6..latest",
"chrome/22..latest",
"safari/5.1..latest"
],
"harness": "mocha-tdd",
"files": "test/*.js"
},
"version": "2.0.3"
}

View File

@@ -0,0 +1,32 @@
var rng;
var crypto = global.crypto || global.msCrypto; // for IE 11
if (crypto && crypto.getRandomValues) {
// WHATWG crypto-based RNG - http://wiki.whatwg.org/wiki/Crypto
// Moderately fast, high quality
var _rnds8 = new Uint8Array(16);
rng = function whatwgRNG() {
crypto.getRandomValues(_rnds8);
return _rnds8;
};
}
if (!rng) {
// Math.random()-based (RNG)
//
// If all else fails, use Math.random(). It's fast, but is of unspecified
// quality.
var _rnds = new Array(16);
rng = function() {
for (var i = 0, r; i < 16; i++) {
if ((i & 0x03) === 0) r = Math.random() * 0x100000000;
_rnds[i] = r >>> ((i & 0x03) << 3) & 0xff;
}
return _rnds;
};
}
module.exports = rng;

View File

@@ -0,0 +1,4 @@
var rb = require('crypto').randomBytes;
module.exports = function() {
return rb(16);
};

View File

@@ -0,0 +1 @@
--ui qunit

View File

@@ -0,0 +1,105 @@
var assert = require('assert');
var uuid = require('../');
// Verify ordering of v1 ids created with explicit times
var TIME = 1321644961388; // 2011-11-18 11:36:01.388-08:00
function compare(name, ids) {
test(name, function() {
// avoid .map for older browsers
for (var i=0 ; i<ids.length ; ++i) {
ids[i] = ids[i].split('-').reverse().join('-');
}
ids = ids.sort();
var sorted = ([].concat(ids)).sort();
assert(sorted.toString() == ids.toString(), name + ' have expected order');
});
}
// Verify ordering of v1 ids created using default behavior
compare('uuids with current time', [
uuid.v1(),
uuid.v1(),
uuid.v1(),
uuid.v1(),
uuid.v1()
]);
// Verify ordering of v1 ids created with explicit times
compare('uuids with time option', [
uuid.v1({msecs: TIME - 10*3600*1000}),
uuid.v1({msecs: TIME - 1}),
uuid.v1({msecs: TIME}),
uuid.v1({msecs: TIME + 1}),
uuid.v1({msecs: TIME + 28*24*3600*1000})
]);
test('msec', function() {
assert(
uuid.v1({msecs: TIME}) != uuid.v1({msecs: TIME}),
'IDs created at same msec are different'
);
});
test('exception thrown when > 10k ids created in 1ms', function() {
// Verify throw if too many ids created
var thrown = false;
try {
uuid.v1({msecs: TIME, nsecs: 10000});
} catch (e) {
thrown = true;
}
assert(thrown, 'Exception thrown when > 10K ids created in 1 ms');
});
test('clock regression by msec', function() {
// Verify clock regression bumps clockseq
var uidt = uuid.v1({msecs: TIME});
var uidtb = uuid.v1({msecs: TIME - 1});
assert(
parseInt(uidtb.split('-')[3], 16) - parseInt(uidt.split('-')[3], 16) === 1,
'Clock regression by msec increments the clockseq'
);
});
test('clock regression by nsec', function() {
// Verify clock regression bumps clockseq
var uidtn = uuid.v1({msecs: TIME, nsecs: 10});
var uidtnb = uuid.v1({msecs: TIME, nsecs: 9});
assert(
parseInt(uidtnb.split('-')[3], 16) - parseInt(uidtn.split('-')[3], 16) === 1,
'Clock regression by nsec increments the clockseq'
);
});
test('explicit options product expected id', function() {
// Verify explicit options produce expected id
var id = uuid.v1({
msecs: 1321651533573,
nsecs: 5432,
clockseq: 0x385c,
node: [ 0x61, 0xcd, 0x3c, 0xbb, 0x32, 0x10 ]
});
assert(id == 'd9428888-122b-11e1-b85c-61cd3cbb3210', 'Explicit options produce expected id');
});
test('ids spanning 1ms boundary are 100ns apart', function() {
// Verify adjacent ids across a msec boundary are 1 time unit apart
var u0 = uuid.v1({msecs: TIME, nsecs: 9999});
var u1 = uuid.v1({msecs: TIME + 1, nsecs: 0});
var before = u0.split('-')[0], after = u1.split('-')[0];
var dt = parseInt(after, 16) - parseInt(before, 16);
assert(dt === 1, 'Ids spanning 1ms boundary are 100ns apart');
});
test('parse/unparse', function() {
var id = '00112233445566778899aabbccddeeff';
assert(uuid.unparse(uuid.parse(id.substr(0,10))) ==
'00112233-4400-0000-0000-000000000000', 'Short parse');
assert(uuid.unparse(uuid.parse('(this is the uuid -> ' + id + id)) ==
'00112233-4455-6677-8899-aabbccddeeff', 'Dirty parse');
});

View File

@@ -0,0 +1,183 @@
// uuid.js
//
// Copyright (c) 2010-2012 Robert Kieffer
// MIT License - http://opensource.org/licenses/mit-license.php
// Unique ID creation requires a high quality random # generator. We feature
// detect to determine the best RNG source, normalizing to a function that
// returns 128-bits of randomness, since that's what's usually required
var _rng = require('./rng');
// Maps for number <-> hex string conversion
var _byteToHex = [];
var _hexToByte = {};
for (var i = 0; i < 256; i++) {
_byteToHex[i] = (i + 0x100).toString(16).substr(1);
_hexToByte[_byteToHex[i]] = i;
}
// **`parse()` - Parse a UUID into it's component bytes**
function parse(s, buf, offset) {
var i = (buf && offset) || 0, ii = 0;
buf = buf || [];
s.toLowerCase().replace(/[0-9a-f]{2}/g, function(oct) {
if (ii < 16) { // Don't overflow!
buf[i + ii++] = _hexToByte[oct];
}
});
// Zero out remaining bytes if string was short
while (ii < 16) {
buf[i + ii++] = 0;
}
return buf;
}
// **`unparse()` - Convert UUID byte array (ala parse()) into a string**
function unparse(buf, offset) {
var i = offset || 0, bth = _byteToHex;
return bth[buf[i++]] + bth[buf[i++]] +
bth[buf[i++]] + bth[buf[i++]] + '-' +
bth[buf[i++]] + bth[buf[i++]] + '-' +
bth[buf[i++]] + bth[buf[i++]] + '-' +
bth[buf[i++]] + bth[buf[i++]] + '-' +
bth[buf[i++]] + bth[buf[i++]] +
bth[buf[i++]] + bth[buf[i++]] +
bth[buf[i++]] + bth[buf[i++]];
}
// **`v1()` - Generate time-based UUID**
//
// Inspired by https://github.com/LiosK/UUID.js
// and http://docs.python.org/library/uuid.html
// random #'s we need to init node and clockseq
var _seedBytes = _rng();
// Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1)
var _nodeId = [
_seedBytes[0] | 0x01,
_seedBytes[1], _seedBytes[2], _seedBytes[3], _seedBytes[4], _seedBytes[5]
];
// Per 4.2.2, randomize (14 bit) clockseq
var _clockseq = (_seedBytes[6] << 8 | _seedBytes[7]) & 0x3fff;
// Previous uuid creation time
var _lastMSecs = 0, _lastNSecs = 0;
// See https://github.com/broofa/node-uuid for API details
function v1(options, buf, offset) {
var i = buf && offset || 0;
var b = buf || [];
options = options || {};
var clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq;
// UUID timestamps are 100 nano-second units since the Gregorian epoch,
// (1582-10-15 00:00). JSNumbers aren't precise enough for this, so
// time is handled internally as 'msecs' (integer milliseconds) and 'nsecs'
// (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00.
var msecs = options.msecs !== undefined ? options.msecs : new Date().getTime();
// Per 4.2.1.2, use count of uuid's generated during the current clock
// cycle to simulate higher resolution clock
var nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1;
// Time since last uuid creation (in msecs)
var dt = (msecs - _lastMSecs) + (nsecs - _lastNSecs)/10000;
// Per 4.2.1.2, Bump clockseq on clock regression
if (dt < 0 && options.clockseq === undefined) {
clockseq = clockseq + 1 & 0x3fff;
}
// Reset nsecs if clock regresses (new clockseq) or we've moved onto a new
// time interval
if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === undefined) {
nsecs = 0;
}
// Per 4.2.1.2 Throw error if too many uuids are requested
if (nsecs >= 10000) {
throw new Error('uuid.v1(): Can\'t create more than 10M uuids/sec');
}
_lastMSecs = msecs;
_lastNSecs = nsecs;
_clockseq = clockseq;
// Per 4.1.4 - Convert from unix epoch to Gregorian epoch
msecs += 12219292800000;
// `time_low`
var tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000;
b[i++] = tl >>> 24 & 0xff;
b[i++] = tl >>> 16 & 0xff;
b[i++] = tl >>> 8 & 0xff;
b[i++] = tl & 0xff;
// `time_mid`
var tmh = (msecs / 0x100000000 * 10000) & 0xfffffff;
b[i++] = tmh >>> 8 & 0xff;
b[i++] = tmh & 0xff;
// `time_high_and_version`
b[i++] = tmh >>> 24 & 0xf | 0x10; // include version
b[i++] = tmh >>> 16 & 0xff;
// `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant)
b[i++] = clockseq >>> 8 | 0x80;
// `clock_seq_low`
b[i++] = clockseq & 0xff;
// `node`
var node = options.node || _nodeId;
for (var n = 0; n < 6; n++) {
b[i + n] = node[n];
}
return buf ? buf : unparse(b);
}
// **`v4()` - Generate random UUID**
// See https://github.com/broofa/node-uuid for API details
function v4(options, buf, offset) {
// Deprecated - 'format' argument, as supported in v1.2
var i = buf && offset || 0;
if (typeof(options) == 'string') {
buf = options == 'binary' ? new Array(16) : null;
options = null;
}
options = options || {};
var rnds = options.random || (options.rng || _rng)();
// Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
rnds[6] = (rnds[6] & 0x0f) | 0x40;
rnds[8] = (rnds[8] & 0x3f) | 0x80;
// Copy bytes to buffer, if provided
if (buf) {
for (var ii = 0; ii < 16; ii++) {
buf[i + ii] = rnds[ii];
}
}
return buf || unparse(rnds);
}
// Export public API
var uuid = v4;
uuid.v1 = v1;
uuid.v4 = v4;
uuid.parse = parse;
uuid.unparse = unparse;
module.exports = uuid;

98
build/node_modules/http2-push-manifest/package.json generated vendored Normal file
View File

@@ -0,0 +1,98 @@
{
"_from": "http2-push-manifest",
"_id": "http2-push-manifest@1.0.1",
"_inBundle": false,
"_integrity": "sha1-hl8ICOIcM4wMII/arVCEtGP7NJM=",
"_location": "/http2-push-manifest",
"_phantomChildren": {
"duplexify": "3.5.1",
"escape-string-regexp": "1.0.5",
"graceful-fs": "4.1.11",
"has-ansi": "2.0.0",
"infinity-agent": "2.0.3",
"is-finite": "1.0.2",
"is-npm": "1.0.0",
"is-redirect": "1.0.0",
"is-stream": "1.1.0",
"lowercase-keys": "1.0.0",
"mkdirp": "0.5.1",
"nested-error-stacks": "1.0.2",
"object-assign": "4.1.1",
"os-tmpdir": "1.0.2",
"osenv": "0.1.4",
"prepend-http": "1.0.4",
"read-all-stream": "3.1.0",
"registry-url": "3.1.0",
"semver-diff": "2.1.0",
"string-length": "1.0.1",
"strip-ansi": "3.0.1",
"write-file-atomic": "1.3.4",
"xdg-basedir": "2.0.0"
},
"_requested": {
"type": "tag",
"registry": true,
"raw": "http2-push-manifest",
"name": "http2-push-manifest",
"escapedName": "http2-push-manifest",
"rawSpec": "",
"saveSpec": null,
"fetchSpec": "latest"
},
"_requiredBy": [
"#USER",
"/"
],
"_resolved": "https://registry.npmjs.org/http2-push-manifest/-/http2-push-manifest-1.0.1.tgz",
"_shasum": "865f0808e21c338c0c208fdaad5084b463fb3493",
"_spec": "http2-push-manifest",
"_where": "/Users/asciidisco/Desktop/asciidisco.com/build",
"author": {
"name": "Eric Bidelman",
"email": "ebidel@"
},
"bin": {
"http2-push-manifest": "bin/http2-push-manifest"
},
"bugs": {
"url": "https://github.com/GoogleChrome/http2-push-manifest/issues"
},
"bundleDependencies": false,
"dependencies": {
"dom5": "^1.1.1",
"hydrolysis": "1.22.0",
"nopt": "^3.0.4",
"update-notifier": "^0.5.0",
"vulcanize": "^1.13.1"
},
"deprecated": false,
"description": "Generate a list of static resources for http2 push and preload.",
"devDependencies": {
"jshint": "^2.8.0",
"mocha": "^2.3.3"
},
"engines": {
"node": ">=4.0"
},
"homepage": "https://github.com/GoogleChrome/http2-push-manifest",
"keywords": [
"http2",
"http2 push",
"performance"
],
"license": "Apache-2.0",
"main": "lib/manifest.js",
"name": "http2-push-manifest",
"optionalDependencies": {
"update-notifier": "^0.5.0"
},
"repository": {
"type": "git",
"url": "git+https://github.com/GoogleChrome/http2-push-manifest.git"
},
"scripts": {
"lint": "jshint --verbose lib",
"test": "npm run lint; mocha"
},
"version": "1.0.1"
}

View File

View File

View File

@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="/css/app.css">
<link rel="import" href="import.html">
</head>
<body>
<script src="https://example.com/json"></script>
<script src="/api/endpoint"></script>
<script src="/doesntexist.json"></script>
<script src="/js/app.js"></script>
</body>
</html>

View File

@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="/css/app2.css">
<link rel="import" href="import2.html">
</head>
<body>
<script src="/js/app.js"></script>
</body>
</html>

View File

@@ -0,0 +1 @@
<link rel="import" href="subimport.html">

View File

@@ -0,0 +1 @@
<link rel="import" href="subimport.html">

View File

View File

View File

@@ -0,0 +1,2 @@
--ui tdd
--slow 500

195
build/node_modules/http2-push-manifest/test/tests.js generated vendored Normal file
View File

@@ -0,0 +1,195 @@
'use strict';
// jshint node: true
let assert = require('assert');
let path = require('path');
let fs = require('fs');
const oldOld = console.log;
const EXPECTED_FILE = {
"/css/app.css": {
"weight": 1,
"type": "style"
},
"/js/app.js": {
"weight": 1,
"type": "script"
},
"/doesntexist.json": {
"weight": 1,
"type": "script"
},
"/api/endpoint": {
"weight": 1
},
"/subimport.html": {
"weight": 1,
"type": "document"
},
"/import.html": {
"weight": 1,
"type": "document"
}
};
function muteLogger() {
console.log = function() {}
}
function unmuteLogger() {
console.log = oldOld;
}
function listresources(manifest) {
muteLogger();
return manifest.generate().then(output => {
manifest.write();
unmuteLogger();
return output;
});
}
suite('manifest.js', () => {
let PushManifest = require('../lib/manifest.js');
let BASE = __dirname + '/html';
let INPUT = 'basic.html';
let manifest = null;
suiteSetup(() => {
manifest = new PushManifest({basePath: BASE, inputPath: INPUT});
});
test('defaults', done => {
assert.equal(manifest.DEFAULT_MANIFEST_NAME,
'push_manifest.json', 'default manifest file name');
assert.equal(manifest.name, manifest.DEFAULT_MANIFEST_NAME,
'default manifest file set');
assert.equal(manifest.basePath, BASE, 'basePath set');
assert.equal(manifest.inputPath, INPUT, 'default inputPath set');
done();
});
test('list resources', done => {
listresources(manifest).then(output => {
let name = manifest.DEFAULT_MANIFEST_NAME;
let urls = Object.keys(EXPECTED_FILE);
assert.equal(output.urls.length, urls.length, 'found all resources');
fs.readFile(name, (err, data) => {
if (err) {
throw err;
}
var json = JSON.parse(data);
assert.equal(JSON.stringify(json), JSON.stringify(output.file),
'Written file does not match .file property');
assert(!json['https://example.com/json'], 'External files are left out');
assert(EXPECTED_FILE['/doesntexist.json'], 'non-existent local resources are included');
assert(EXPECTED_FILE['/api/endpoint'], 'url without file extension is included');
// Node 4.2.1 doesn't support ...[] yet. Built ourself.
let arr = urls.concat(Object.keys(json));
let union = new Set(arr);
assert.equal(union.size, urls.length, 'all resources written to file');
// Node 4.2.1 doesn't support for...of
for (let key in json) {
assert('type' in json[key], '.type property exists for all urls');
if (key === '/api/endpoint') {
assert.equal(json[key].type, '', '.type is empty for urls without file extensions');
}
}
fs.unlinkSync(name); // cleanup
done();
});
}).catch(err => {
console.log(err);
});
});
test('custom manifest', function(done) {
this.timeout(2000);
let name = 'custom_manifest.json';
let manifest = new PushManifest({
basePath: BASE, inputPath: INPUT, name: name
});
assert.equal(manifest.name, name, 'custom manifest file name set');
listresources(manifest).then(output => {
assert(fs.statSync(name).isFile(), 'custom manifest written');
fs.unlinkSync(name); // cleanup
done();
});
});
});
suite('cli', () => {
var exec = require('child_process').exec;
let CMD = `${__dirname}/../bin/http2-push-manifest`;
let INPUT = `${__dirname}/html/basic.html`;
let INPUT2 = `${__dirname}/html/basic2.html`;
let NAME = 'push_manifest.json';
function process(cmd, cb) {
exec(cmd, (err, stdout, stderr) => {
assert(!err, 'error running cli');
cb(stdout);
});
}
suiteSetup(() => {
//manifest = new PushManifest({basePath: BASE, inputPath: INPUT});
});
test('single manifest', done => {
process(`${CMD} -f ${INPUT}`, stdout => {
assert(fs.statSync(NAME).isFile(), 'single file manifest written');
fs.unlinkSync(NAME); // cleanup
done();
});
});
test('custom manifest', done => {
let name = 'custom_manifest.json';
process(`${CMD} -f ${INPUT} -m ${name}`, stdout => {
assert(fs.statSync(name).isFile(), 'custom manifest written');
fs.unlinkSync(name); // cleanup
done();
});
});
test('multi manifest', done => {
process(`${CMD} -f ${INPUT} -f ${INPUT2}`, stdout => {
assert(fs.statSync(NAME).isFile(), 'multi file manifest written');
fs.readFile(NAME, (err, data) => {
assert(!err, 'error reading multi file manifest');
var json = JSON.parse(data);
// Check top-level keys are the input file names.
assert(path.basename(INPUT) in json);
assert(path.basename(INPUT2) in json);
fs.unlinkSync(NAME); // cleanup
done();
});
});
});
});