html-snapshots 0.18.2 → 0.19.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/.eslintrc.json +4 -5
- package/README.md +73 -68
- package/examples/custom/myFilter.js +2 -2
- package/examples/custom/package-lock.json +1012 -77
- package/examples/custom/package.json +1 -1
- package/examples/custom/snapshot.js +8 -10
- package/examples/debug-phantomjs/package-lock.json +76 -76
- package/examples/debug-phantomjs/package.json +1 -1
- package/examples/debug-phantomjs/snapshot.js +12 -14
- package/examples/html5rocks/package-lock.json +1379 -78
- package/examples/html5rocks/package.json +1 -1
- package/examples/html5rocks/snapshot.js +15 -18
- package/examples/process-limit/package-lock.json +1379 -78
- package/examples/process-limit/package.json +1 -1
- package/examples/process-limit/snapshot.js +8 -10
- package/examples/simple-promise/package-lock.json +1379 -78
- package/examples/simple-promise/package.json +1 -1
- package/examples/simple-promise/snapshot.js +6 -8
- package/examples/sitemap-index/package-lock.json +1378 -77
- package/examples/sitemap-index/package.json +1 -1
- package/examples/sitemap-index/snapshot.js +6 -6
- package/examples/utils/index.js +2 -4
- package/examples/verbose/package-lock.json +1380 -78
- package/examples/verbose/package.json +1 -1
- package/examples/verbose/snapshot.js +11 -14
- package/lib/async/index.js +0 -1
- package/lib/common/index.js +1 -1
- package/lib/common/sitemap/index.js +16 -0
- package/lib/common/sitemap/sitemap-collection.js +94 -0
- package/lib/common/sitemap/sitemap-index.js +68 -0
- package/lib/common/{sitemap.js → sitemap/sitemap.js} +68 -57
- package/lib/html-snapshots.js +0 -1
- package/lib/input-generators/array.js +0 -1
- package/lib/input-generators/robots.js +98 -58
- package/lib/input-generators/sitemap-index.js +3 -124
- package/lib/input-generators/sitemap.js +3 -7
- package/lib/input-generators/textfile.js +2 -6
- package/package.json +6 -6
- package/test/helpers/options.js +4 -2
- package/test/mocha/html-snapshots/process-limit.js +46 -48
- package/test/mocha/html-snapshots/robots.js +156 -138
- package/test/mocha/html-snapshots/server/test_robots.txt +13 -0
- package/test/mocha/html-snapshots/server/test_robots_sitemap.txt +15 -0
- package/test/mocha/html-snapshots/server/test_robots_sitemap.xml +22 -0
- package/test/mocha/html-snapshots/sitemap-index.js +58 -57
- package/test/mocha/html-snapshots/snapshot-scripts.js +55 -54
- package/test/mocha/html-snapshots/test.js +16 -16
- package/test/mocha/html-snapshots/test_robots.txt +0 -2
- package/test/mocha/html-snapshots/utils.js +0 -1
- package/test/mocha/input-generators/server/test_robots.txt +0 -2
- package/test/mocha/input-generators/server/test_robots_bad.txt +0 -2
- package/test/mocha/input-generators/server/test_robots_sitemap.txt +17 -0
- package/test/mocha/input-generators/server/test_robots_sitemap_bad.txt +17 -0
- package/test/mocha/input-generators/server/test_robots_sitemap_multi.txt +18 -0
- package/test/mocha/input-generators/server/test_sitemap_index_empty.xml +3 -0
- package/test/mocha/input-generators/server/test_sitemap_index_malformed.xml +2 -0
- package/test/mocha/input-generators/sitemap-index.js +65 -9
- package/test/mocha/input-generators/test.js +276 -280
- package/test/mocha/input-generators/test_robots.txt +0 -2
- package/test/mocha/input-generators/test_robots_bad.txt +0 -2
- package/test/mocha/input-generators/test_robots_sitemap.txt +17 -0
- package/test/mocha/input-generators/test_robots_sitemap_bad.txt +17 -0
- package/test/mocha/input-generators/test_robots_sitemap_multi.txt +18 -0
- package/lib/common/node.js +0 -26
- package/test/mocha/common/node.js +0 -100
|
@@ -8,42 +8,41 @@
|
|
|
8
8
|
* Remove all script tags from output.
|
|
9
9
|
* Use javascript arrays.
|
|
10
10
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var htmlSnapshots = require("html-snapshots");
|
|
11
|
+
const path = require("path");
|
|
12
|
+
const util = require("util");
|
|
13
|
+
const htmlSnapshots = require("html-snapshots");
|
|
15
14
|
|
|
16
15
|
// a data structure with snapshot input
|
|
17
|
-
|
|
16
|
+
const sites = [
|
|
18
17
|
{
|
|
19
|
-
label: "
|
|
20
|
-
url: "
|
|
21
|
-
selector: ".
|
|
18
|
+
label: "web.dev",
|
|
19
|
+
url: "https://web.dev",
|
|
20
|
+
selector: "web-subscribe .wrapper"
|
|
22
21
|
},
|
|
23
22
|
{
|
|
24
23
|
label: "updates.html5rocks",
|
|
25
|
-
url: "https://
|
|
26
|
-
selector: ".
|
|
24
|
+
url: "https://developer.chrome.com/blog/",
|
|
25
|
+
selector: ".blog-grid"
|
|
27
26
|
}
|
|
28
27
|
];
|
|
29
28
|
|
|
30
29
|
htmlSnapshots.run({
|
|
31
30
|
// input source is the array of urls to snapshot
|
|
32
31
|
input: "array",
|
|
33
|
-
source: sites.map(
|
|
32
|
+
source: sites.map(site => site.url),
|
|
34
33
|
|
|
35
34
|
// setup and manage the output
|
|
36
35
|
outputDir: path.join(__dirname, "./tmp"),
|
|
37
36
|
outputDirClean: true,
|
|
38
37
|
|
|
39
38
|
// per url output paths, { url: outputpath [, url: outputpath] }
|
|
40
|
-
outputPath: sites.reduce(
|
|
39
|
+
outputPath: sites.reduce((prev, curr) => {
|
|
41
40
|
prev[curr.url] = curr.label; // use the label to differentiate '/index.html' from both sites
|
|
42
41
|
return prev;
|
|
43
42
|
}, {}),
|
|
44
43
|
|
|
45
44
|
// per url selectors, { url: selector [, url: selector] }
|
|
46
|
-
selector: sites.reduce(
|
|
45
|
+
selector: sites.reduce((prev, curr) => {
|
|
47
46
|
prev[curr.url] = curr.selector;
|
|
48
47
|
return prev;
|
|
49
48
|
}, {}),
|
|
@@ -56,13 +55,11 @@ htmlSnapshots.run({
|
|
|
56
55
|
// handle ssl for updates.html5rocks only
|
|
57
56
|
phantomjsOptions: {
|
|
58
57
|
// key must match url exactly
|
|
59
|
-
"https://
|
|
58
|
+
"https://developer.chrome.com/blog/": ["--ssl-protocol=any", "--ignore-ssl-errors=true"]
|
|
60
59
|
}
|
|
61
60
|
})
|
|
62
|
-
.then(
|
|
61
|
+
.then(completed => {
|
|
63
62
|
console.log("completed snapshots:");
|
|
64
63
|
console.log(util.inspect(completed));
|
|
65
64
|
})
|
|
66
|
-
.catch(
|
|
67
|
-
console.error(err);
|
|
68
|
-
});
|
|
65
|
+
.catch(console.error);
|