manifest 0.1.4 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +7 -35
- package/readme.md +3 -0
- package/.npmignore +0 -2
- package/.travis.yml +0 -9
- package/README.md +0 -63
- package/docs.json +0 -10
- package/examples/simple.js +0 -8
- package/index.js +0 -102
- package/test/local.js +0 -27
- package/test/mock/css/test.css +0 -3
- package/test/mock/js/test.js +0 -1
- package/test/mock/manifest +0 -2
- package/test/mockdist/css/test.css +0 -3
- package/test/mockdist/js/test.js +0 -1
package/package.json
CHANGED
|
@@ -1,39 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "manifest",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"tags": [],
|
|
6
|
-
"version": "0.1.4",
|
|
7
|
-
"dependencies": {
|
|
8
|
-
"async": "~0.9",
|
|
9
|
-
"debug": "^1",
|
|
10
|
-
"getit": "~0.4",
|
|
11
|
-
"mkdirp": "~0.5"
|
|
12
|
-
},
|
|
13
|
-
"devDependencies": {
|
|
14
|
-
"mocha": "^1",
|
|
15
|
-
"rimraf": "^2"
|
|
16
|
-
},
|
|
17
|
-
"repository": {
|
|
18
|
-
"type": "git",
|
|
19
|
-
"url": "git://github.com/DamonOehlman/manifest.git"
|
|
20
|
-
},
|
|
21
|
-
"bugs": {
|
|
22
|
-
"url": "http://github.com/DamonOehlman/manifest/issues"
|
|
23
|
-
},
|
|
24
|
-
"scripts": {
|
|
25
|
-
"test": "$(npm bin)/mocha --reporter spec",
|
|
26
|
-
"gendocs": "gendocs > README.md"
|
|
27
|
-
},
|
|
28
|
-
"optionalDependencies": {},
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "",
|
|
29
5
|
"main": "index.js",
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"test": "test"
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
33
8
|
},
|
|
34
|
-
"
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
],
|
|
38
|
-
"license": "MIT"
|
|
39
|
-
}
|
|
9
|
+
"author": "",
|
|
10
|
+
"license": "ISC"
|
|
11
|
+
}
|
package/readme.md
ADDED
package/.npmignore
DELETED
package/.travis.yml
DELETED
package/README.md
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
# manifest
|
|
2
|
-
|
|
3
|
-
1. This has nothing to do with HTML5 cache-manifest / appcache
|
|
4
|
-
2. This is designed to make downloading multiple files from a remote
|
|
5
|
-
web location (using [getit](https://github.com/DamonOehlman/getit)) via
|
|
6
|
-
a simple manifest file, really bloody simple.
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
[](https://nodei.co/npm/manifest/)
|
|
10
|
-
|
|
11
|
-
[](https://travis-ci.org/DamonOehlman/manifest) [](https://github.com/dominictarr/stability#stable) [](https://david-dm.org/DamonOehlman/manifest)
|
|
12
|
-
|
|
13
|
-
## Example Usage
|
|
14
|
-
|
|
15
|
-
```js
|
|
16
|
-
var manifest = require('manifest');
|
|
17
|
-
|
|
18
|
-
// download files from test.com
|
|
19
|
-
// as specified in the manifest file "http://test.com/manifest"
|
|
20
|
-
// to the current working directory
|
|
21
|
-
manifest.download('http://test.com/', function(err) {
|
|
22
|
-
// it's done
|
|
23
|
-
});
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
More documentation to come, in the meantime have a look at the
|
|
27
|
-
test directory.
|
|
28
|
-
|
|
29
|
-
## Reference
|
|
30
|
-
|
|
31
|
-
### load(target, opts?, callback)
|
|
32
|
-
|
|
33
|
-
Load a manifest from the specified location.
|
|
34
|
-
|
|
35
|
-
### download(target, opts?, callback)
|
|
36
|
-
|
|
37
|
-
Download all the files specified in the manifest file from the specified
|
|
38
|
-
location.
|
|
39
|
-
|
|
40
|
-
## License(s)
|
|
41
|
-
|
|
42
|
-
### MIT
|
|
43
|
-
|
|
44
|
-
Copyright (c) 2014 Damon Oehlman <damon.oehlman@gmail.com>
|
|
45
|
-
|
|
46
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
|
47
|
-
a copy of this software and associated documentation files (the
|
|
48
|
-
'Software'), to deal in the Software without restriction, including
|
|
49
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
|
50
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
|
51
|
-
permit persons to whom the Software is furnished to do so, subject to
|
|
52
|
-
the following conditions:
|
|
53
|
-
|
|
54
|
-
The above copyright notice and this permission notice shall be
|
|
55
|
-
included in all copies or substantial portions of the Software.
|
|
56
|
-
|
|
57
|
-
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
58
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
59
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
60
|
-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
61
|
-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
62
|
-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
63
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/docs.json
DELETED
package/examples/simple.js
DELETED
package/index.js
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
/* jshint node: true */
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
var async = require('async');
|
|
5
|
-
var debug = require('debug')('manifest');
|
|
6
|
-
var getit = require('getit');
|
|
7
|
-
var mkdirp = require('mkdirp');
|
|
8
|
-
var path = require('path');
|
|
9
|
-
var fs = require('fs');
|
|
10
|
-
var reTrailingSlash = /\/$/;
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
# manifest
|
|
14
|
-
|
|
15
|
-
1. This has nothing to do with HTML5 cache-manifest / appcache
|
|
16
|
-
2. This is designed to make downloading multiple files from a remote
|
|
17
|
-
web location (using [getit](https://github.com/DamonOehlman/getit)) via
|
|
18
|
-
a simple manifest file, really bloody simple.
|
|
19
|
-
|
|
20
|
-
## Example Usage
|
|
21
|
-
|
|
22
|
-
<<< examples/simple.js
|
|
23
|
-
|
|
24
|
-
More documentation to come, in the meantime have a look at the
|
|
25
|
-
test directory.
|
|
26
|
-
|
|
27
|
-
## Reference
|
|
28
|
-
**/
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
### load(target, opts?, callback)
|
|
32
|
-
|
|
33
|
-
Load a manifest from the specified location.
|
|
34
|
-
|
|
35
|
-
**/
|
|
36
|
-
var load = exports.load = function(target, opts, callback) {
|
|
37
|
-
var basePath = (target || '').replace(reTrailingSlash, '');
|
|
38
|
-
var manifestFile;
|
|
39
|
-
|
|
40
|
-
// remap args if required
|
|
41
|
-
if (typeof opts == 'function') {
|
|
42
|
-
callback = opts;
|
|
43
|
-
opts = {};
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// ensure we have opts
|
|
47
|
-
opts = opts || {};
|
|
48
|
-
|
|
49
|
-
// initialise the manifest file name
|
|
50
|
-
manifestFile = basePath + '/' + (opts.manifest || 'manifest');
|
|
51
|
-
|
|
52
|
-
// get the manifest from the specified target path
|
|
53
|
-
debug('downloading manifest from: ' + manifestFile);
|
|
54
|
-
getit(manifestFile, opts, function(err, data) {
|
|
55
|
-
callback(err, (data || '').split('\n'), basePath);
|
|
56
|
-
});
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
### download(target, opts?, callback)
|
|
61
|
-
|
|
62
|
-
Download all the files specified in the manifest file from the specified
|
|
63
|
-
location.
|
|
64
|
-
|
|
65
|
-
**/
|
|
66
|
-
exports.download = function(target, opts, callback) {
|
|
67
|
-
// remap args if required
|
|
68
|
-
if (typeof opts == 'function') {
|
|
69
|
-
callback = opts;
|
|
70
|
-
opts = {};
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// initialise defaults
|
|
74
|
-
opts.path = opts.path || process.cwd();
|
|
75
|
-
|
|
76
|
-
// load the manifest from the target location
|
|
77
|
-
load(target, opts, function(err, items, basePath) {
|
|
78
|
-
if (err) {
|
|
79
|
-
return callback(err);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
async.forEach(
|
|
83
|
-
items,
|
|
84
|
-
function(item, itemCallback) {
|
|
85
|
-
var targetFile = path.resolve(opts.path, item);
|
|
86
|
-
|
|
87
|
-
// ensure the directory for the file exists
|
|
88
|
-
mkdirp(path.dirname(targetFile), function(err) {
|
|
89
|
-
if (err) {
|
|
90
|
-
return itemCallback(err);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// download the file to the target
|
|
94
|
-
getit(basePath + '/' + item, opts)
|
|
95
|
-
.pipe(fs.createWriteStream(targetFile))
|
|
96
|
-
.on('close', itemCallback);
|
|
97
|
-
});
|
|
98
|
-
},
|
|
99
|
-
callback
|
|
100
|
-
);
|
|
101
|
-
});
|
|
102
|
-
};
|
package/test/local.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
var manifest = require('../'),
|
|
2
|
-
assert = require('assert'),
|
|
3
|
-
path = require('path'),
|
|
4
|
-
rimraf = require('rimraf'),
|
|
5
|
-
testSrcPath = path.resolve(__dirname, 'mock'),
|
|
6
|
-
testDstPath = path.resolve(__dirname, 'mockdist');
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
describe('local manifest tests', function() {
|
|
10
|
-
before(rimraf.bind(null, testDstPath));
|
|
11
|
-
|
|
12
|
-
it('should be able to load a local manifest', function(done) {
|
|
13
|
-
manifest.load(testSrcPath, function(err, data, basePath) {
|
|
14
|
-
assert.equal(basePath, testSrcPath);
|
|
15
|
-
assert(data.indexOf('css/test.css') >= 0);
|
|
16
|
-
assert(data.indexOf('js/test.js') >= 0);
|
|
17
|
-
|
|
18
|
-
done();
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it('should be able to move files from the source to the target', function(done) {
|
|
23
|
-
manifest.download(testSrcPath, { path: testDstPath }, function(err, data) {
|
|
24
|
-
done(err);
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
});
|
package/test/mock/css/test.css
DELETED
package/test/mock/js/test.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var test = 1;
|
package/test/mock/manifest
DELETED
package/test/mockdist/js/test.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var test = 1;
|