grunt-html-snapshots 4.0.2 → 4.1.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.
@@ -18,7 +18,7 @@ jobs:
18
18
  steps:
19
19
  - uses: actions/checkout@v3
20
20
  - name: Use Node.js ${{ matrix.node-version }}
21
- uses: actions/setup-node@v3.0.0
21
+ uses: actions/setup-node@v3
22
22
  with:
23
23
  node-version: ${{ matrix.node-version }}
24
24
  - run: npm ci
package/Gruntfile.js CHANGED
@@ -27,6 +27,12 @@ module.exports = function (grunt) {
27
27
  }
28
28
  },
29
29
 
30
+ test_server3: {
31
+ options: {
32
+ port: 8051
33
+ }
34
+ },
35
+
30
36
  // Configuration to be run (and then tested).
31
37
  html_snapshots: {
32
38
  options: grunt.file.readJSON("test/input/default_options"),
@@ -45,6 +51,14 @@ module.exports = function (grunt) {
45
51
  port: "<%= test_server2.options.port %>",
46
52
  force: true
47
53
  }
54
+ },
55
+
56
+ target3: {
57
+ options: {
58
+ source: "test/fixtures/test_robots_sitemap.txt",
59
+ outputDir: "tmp/target3/snapshots",
60
+ port: "<%= test_server3.options.port %>"
61
+ }
48
62
  }
49
63
  },
50
64
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "grunt-html-snapshots",
3
3
  "description": "The grunt task for html-snapshots",
4
- "version": "4.0.2",
4
+ "version": "4.1.0",
5
5
  "homepage": "https://github.com/localnerve/grunt-html-snapshots",
6
6
  "author": {
7
7
  "name": "Alex Grant",
@@ -25,10 +25,10 @@
25
25
  "lint": "eslint ."
26
26
  },
27
27
  "dependencies": {
28
- "html-snapshots": "^0.18.2"
28
+ "html-snapshots": "^0.19.0"
29
29
  },
30
30
  "devDependencies": {
31
- "eslint": "^8.12.0",
31
+ "eslint": "^8.24.0",
32
32
  "grunt-contrib-clean": "^2.0.1",
33
33
  "grunt-contrib-nodeunit": "^4.0.0",
34
34
  "grunt": ">=1.5.3"
@@ -0,0 +1,3 @@
1
+ tmp/target3/snapshots/index.html
2
+ tmp/target3/snapshots/contact/index.html
3
+ tmp/target3/snapshots/services/carpets/index.html
@@ -9,7 +9,5 @@ Disallow: /vendor/
9
9
  Disallow: /fonts/
10
10
  Disallow: /images/
11
11
 
12
- Sitemap: http://somehost/sitemap.xml
13
-
14
12
  User-agent: ia_archiver
15
13
  Disallow: /
@@ -0,0 +1,15 @@
1
+ User-agent: *
2
+
3
+ Allow: /
4
+ Allow: /contact
5
+ Allow: /services/carpets
6
+
7
+ Disallow: /api/
8
+ Disallow: /vendor/
9
+ Disallow: /fonts/
10
+ Disallow: /images/
11
+
12
+ Sitemap: http://localhost:8051/sitemap.xml
13
+
14
+ User-agent: ia_archiver
15
+ Disallow: /
@@ -0,0 +1,29 @@
1
+ /**
2
+ * tests, target1
3
+ */
4
+ /* global Promise */
5
+ const grunt = require('grunt');
6
+ const { pathExists } = require('./utils');
7
+
8
+ exports.html_snapshots = {
9
+ setUp: done => {
10
+ // setup here if necessary
11
+ done();
12
+ },
13
+
14
+ target1: test => {
15
+ test.expect(3);
16
+
17
+ const results = [];
18
+
19
+ grunt.file.read('test/expected/target3').split('\n').forEach(line => {
20
+ results.push(pathExists(line).then(exists => {
21
+ test.equal(true, exists, `${line} should exist`);
22
+ }));
23
+ });
24
+
25
+ Promise.all(results).finally(()=> {
26
+ test.done();
27
+ })
28
+ }
29
+ };
@@ -39,6 +39,22 @@ exports.html_snapshots = {
39
39
  }));
40
40
  });
41
41
 
42
+ Promise.all(results).finally(() => {
43
+ test.done();
44
+ });
45
+ },
46
+
47
+ target3: function(test) {
48
+ test.expect(3);
49
+
50
+ const results = [];
51
+
52
+ grunt.file.read('test/expected/target3').split('\n').forEach(line => {
53
+ results.push(pathExists(line).then(exists => {
54
+ test.equal(true, exists, `${line} should exist`);
55
+ }));
56
+ });
57
+
42
58
  Promise.all(results).finally(() => {
43
59
  test.done();
44
60
  });
@@ -1,18 +1,18 @@
1
1
  /**
2
2
  * Create a local web server for tests
3
3
  */
4
- var http = require("http"),
5
- url = require("url"),
6
- path = require("path"),
7
- fs = require("fs");
4
+ const http = require("http"),
5
+ url = require("url"),
6
+ path = require("path"),
7
+ fs = require("fs");
8
8
 
9
9
  module.exports = {
10
10
 
11
11
  start: function(rootDir, port, end) {
12
12
  http.createServer(function(request, response) {
13
13
 
14
- var uri = url.parse(request.url).pathname,
15
- filename = path.join(rootDir, uri);
14
+ const uri = url.parse(request.url).pathname;
15
+ let filename = path.join(rootDir, uri);
16
16
 
17
17
  fs.exists(filename, function(exists) {
18
18
  if(!exists) {
@@ -34,8 +34,13 @@ module.exports = {
34
34
  return;
35
35
  }
36
36
 
37
- response.writeHead(200);
38
- response.write(file, "binary");
37
+ if (path.extname(filename) === '.xml') {
38
+ response.writeHead(200, {"Content-Type": "text/xml"});
39
+ response.write(file);
40
+ } else {
41
+ response.writeHead(200);
42
+ response.write(file, "binary");
43
+ }
39
44
  response.end();
40
45
  if (typeof end === "function")
41
46
  setTimeout(end, 1000);
@@ -0,0 +1,21 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
3
+ <url>
4
+ <loc>http://localhost:8051/</loc>
5
+ <lastmod>2012-08-11T12:16:09+00:00</lastmod>
6
+ <changefreq>daily</changefreq>
7
+ <priority>1.0</priority>
8
+ </url>
9
+ <url>
10
+ <loc>http://localhost:8051/contact</loc>
11
+ <lastmod>2012-11-02T02:53:40+00:00</lastmod>
12
+ <changefreq>weekly</changefreq>
13
+ <priority>0.6</priority>
14
+ </url>
15
+ <url>
16
+ <loc>http://localhost:8051/services/carpets</loc>
17
+ <lastmod>2012-10-19T10:45:23+00:00</lastmod>
18
+ <changefreq>weekly</changefreq>
19
+ <priority>0.6</priority>
20
+ </url>
21
+ </urlset>