Comparing version 7.1.0 to 7.1.1
# Changelog | ||
## 7.1.1 | ||
- fix #378 exit code not set on parse failure. A proper error will be set on the stream now. | ||
- fix #384 thanks @tomcek112 parseSitemapIndex not included in 7.1.0 release | ||
- fix #356 thanks @vandres - SitemapIndexStream now has lastmodDateOnly | ||
- Fix #375 thanks @huntharo parseSitemap and parseSitemapIndex uncatchable errors | ||
- Filter out null as well when writing XML thanks @huntharo #376 | ||
## 7.1.0 | ||
@@ -4,0 +12,0 @@ |
@@ -13,2 +13,3 @@ #!/usr/bin/env node | ||
const zlib_1 = require("zlib"); | ||
const types_1 = require("./lib/types"); | ||
/* eslint-disable-next-line @typescript-eslint/no-var-requires */ | ||
@@ -84,3 +85,3 @@ const arg = require('arg'); | ||
let oStream = getStream() | ||
.pipe(new sitemap_parser_1.XMLToSitemapItemStream()) | ||
.pipe(new sitemap_parser_1.XMLToSitemapItemStream({ level: types_1.ErrorLevel.THROW })) | ||
.pipe(new sitemap_parser_1.ObjectStreamToJSON({ lineSeparated: !argv['--single-line-json'] })); | ||
@@ -87,0 +88,0 @@ if (argv['--gzip']) { |
@@ -14,2 +14,3 @@ /*! | ||
export { parseSitemap, XMLToSitemapItemStream, XMLToSitemapItemStreamOptions, ObjectStreamToJSON, ObjectStreamToJSONOptions, } from './lib/sitemap-parser'; | ||
export { parseSitemapIndex, XMLToSitemapIndexStream, XMLToSitemapIndexItemStreamOptions, IndexObjectStreamToJSON, IndexObjectStreamToJSONOptions, } from './lib/sitemap-index-parser'; | ||
export { simpleSitemapAndIndex } from './lib/sitemap-simple'; |
@@ -13,3 +13,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.simpleSitemapAndIndex = exports.ObjectStreamToJSON = exports.XMLToSitemapItemStream = exports.parseSitemap = exports.xmlLint = exports.ReadlineStream = exports.normalizeURL = exports.validateSMIOptions = exports.mergeStreams = exports.lineSeparatedURLsToSitemapOptions = exports.SitemapStream = exports.streamToPromise = exports.SitemapAndIndexStream = exports.SitemapIndexStream = exports.IndexTagNames = exports.SitemapItemStream = void 0; | ||
exports.simpleSitemapAndIndex = exports.IndexObjectStreamToJSON = exports.XMLToSitemapIndexStream = exports.parseSitemapIndex = exports.ObjectStreamToJSON = exports.XMLToSitemapItemStream = exports.parseSitemap = exports.xmlLint = exports.ReadlineStream = exports.normalizeURL = exports.validateSMIOptions = exports.mergeStreams = exports.lineSeparatedURLsToSitemapOptions = exports.SitemapStream = exports.streamToPromise = exports.SitemapAndIndexStream = exports.SitemapIndexStream = exports.IndexTagNames = exports.SitemapItemStream = void 0; | ||
/*! | ||
@@ -43,3 +43,7 @@ * Sitemap | ||
Object.defineProperty(exports, "ObjectStreamToJSON", { enumerable: true, get: function () { return sitemap_parser_1.ObjectStreamToJSON; } }); | ||
var sitemap_index_parser_1 = require("./lib/sitemap-index-parser"); | ||
Object.defineProperty(exports, "parseSitemapIndex", { enumerable: true, get: function () { return sitemap_index_parser_1.parseSitemapIndex; } }); | ||
Object.defineProperty(exports, "XMLToSitemapIndexStream", { enumerable: true, get: function () { return sitemap_index_parser_1.XMLToSitemapIndexStream; } }); | ||
Object.defineProperty(exports, "IndexObjectStreamToJSON", { enumerable: true, get: function () { return sitemap_index_parser_1.IndexObjectStreamToJSON; } }); | ||
var sitemap_simple_1 = require("./lib/sitemap-simple"); | ||
Object.defineProperty(exports, "simpleSitemapAndIndex", { enumerable: true, get: function () { return sitemap_simple_1.simpleSitemapAndIndex; } }); |
@@ -12,2 +12,3 @@ /// <reference types="node" /> | ||
export interface SitemapIndexStreamOptions extends TransformOptions { | ||
lastmodDateOnly?: boolean; | ||
level?: ErrorLevel; | ||
@@ -17,2 +18,3 @@ xslUrl?: string; | ||
export declare class SitemapIndexStream extends Transform { | ||
lastmodDateOnly: boolean; | ||
level: ErrorLevel; | ||
@@ -19,0 +21,0 @@ xslUrl?: string; |
@@ -24,2 +24,3 @@ "use strict"; | ||
this.hasHeadOutput = false; | ||
this.lastmodDateOnly = opts.lastmodDateOnly || false; | ||
this.level = (_a = opts.level) !== null && _a !== void 0 ? _a : types_1.ErrorLevel.WARN; | ||
@@ -44,3 +45,4 @@ this.xslUrl = opts.xslUrl; | ||
if (item.lastmod) { | ||
this.push((0, sitemap_xml_1.element)(IndexTagNames.lastmod, new Date(item.lastmod).toISOString())); | ||
const lastmod = new Date(item.lastmod).toISOString(); | ||
this.push((0, sitemap_xml_1.element)(IndexTagNames.lastmod, this.lastmodDateOnly ? lastmod.slice(0, 10) : lastmod)); | ||
} | ||
@@ -47,0 +49,0 @@ } |
@@ -17,5 +17,7 @@ /// <reference types="node" /> | ||
logger: Logger; | ||
error: Error | null; | ||
saxStream: SAXStream; | ||
constructor(opts?: XMLToSitemapItemStreamOptions); | ||
_transform(data: string, encoding: string, callback: TransformCallback): void; | ||
private err; | ||
} | ||
@@ -22,0 +24,0 @@ /** |
@@ -58,2 +58,3 @@ "use strict"; | ||
super(opts); | ||
this.error = null; | ||
this.saxStream = sax_1.default.createStream(true, { | ||
@@ -109,2 +110,3 @@ xmlns: true, | ||
this.logger('log', 'unhandled attr for xhtml:link', tag.attributes); | ||
this.err(`unhandled attr for xhtml:link ${tag.attributes}`); | ||
} | ||
@@ -115,2 +117,3 @@ } | ||
this.logger('warn', 'unhandled tag', tag.name); | ||
this.err(`unhandled tag: ${tag.name}`); | ||
} | ||
@@ -280,2 +283,3 @@ }); | ||
this.logger('log', 'unhandled text for tag:', currentTag, `'${text}'`); | ||
this.err(`unhandled text for tag: ${currentTag} '${text}'`); | ||
break; | ||
@@ -322,2 +326,3 @@ } | ||
this.logger('log', 'unhandled cdata for tag:', currentTag); | ||
this.err(`unhandled cdata for tag: ${currentTag}`); | ||
break; | ||
@@ -338,2 +343,3 @@ } | ||
this.logger('log', 'unhandled attr', currentTag, attr.name); | ||
this.err(`unhandled attr: ${currentTag} ${attr.name}`); | ||
} | ||
@@ -353,2 +359,3 @@ break; | ||
this.logger('log', 'unhandled attr for video:price', attr.name); | ||
this.err(`unhandled attr: ${currentTag} ${attr.name}`); | ||
} | ||
@@ -365,2 +372,3 @@ break; | ||
this.logger('log', 'unhandled attr for video:player_loc', attr.name); | ||
this.err(`unhandled attr: ${currentTag} ${attr.name}`); | ||
} | ||
@@ -374,2 +382,3 @@ break; | ||
this.logger('log', 'unhandled attr for video:platform', attr.name, attr.value); | ||
this.err(`unhandled attr: ${currentTag} ${attr.name} ${attr.value}`); | ||
} | ||
@@ -383,2 +392,3 @@ break; | ||
this.logger('log', 'unhandled attr for video:galler_loc', attr.name); | ||
this.err(`unhandled attr: ${currentTag} ${attr.name}`); | ||
} | ||
@@ -392,2 +402,3 @@ break; | ||
this.logger('log', 'unhandled attr for video:uploader', attr.name); | ||
this.err(`unhandled attr: ${currentTag} ${attr.name}`); | ||
} | ||
@@ -397,2 +408,3 @@ break; | ||
this.logger('log', 'unhandled attr', currentTag, attr.name); | ||
this.err(`unhandled attr: ${currentTag} ${attr.name}`); | ||
} | ||
@@ -426,9 +438,18 @@ }); | ||
_transform(data, encoding, callback) { | ||
// correcting the type here can be done without making it a breaking change | ||
// TODO fix this | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
this.saxStream.write(data, encoding); | ||
callback(); | ||
try { | ||
// correcting the type here can be done without making it a breaking change | ||
// TODO fix this | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
this.saxStream.write(data, encoding); | ||
callback(this.level === types_1.ErrorLevel.THROW ? this.error : null); | ||
} | ||
catch (error) { | ||
callback(error); | ||
} | ||
} | ||
err(msg) { | ||
if (!this.error) | ||
this.error = new Error(msg); | ||
} | ||
} | ||
@@ -435,0 +456,0 @@ exports.XMLToSitemapItemStream = XMLToSitemapItemStream; |
@@ -6,3 +6,3 @@ "use strict"; | ||
// eslint-disable-next-line no-control-regex | ||
/[\u0001-\u0008\u000B\u000C\u000E-\u001F\u007F-\u0084\u0086-\u009F\uD800-\uDFFF\uFDD0-\uFDDF\u{1FFFE}-\u{1FFFF}\u{2FFFE}-\u{2FFFF}\u{3FFFE}-\u{3FFFF}\u{4FFFE}-\u{4FFFF}\u{5FFFE}-\u{5FFFF}\u{6FFFE}-\u{6FFFF}\u{7FFFE}-\u{7FFFF}\u{8FFFE}-\u{8FFFF}\u{9FFFE}-\u{9FFFF}\u{AFFFE}-\u{AFFFF}\u{BFFFE}-\u{BFFFF}\u{CFFFE}-\u{CFFFF}\u{DFFFE}-\u{DFFFF}\u{EFFFE}-\u{EFFFF}\u{FFFFE}-\u{FFFFF}\u{10FFFE}-\u{10FFFF}]/gu; | ||
/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F-\u0084\u0086-\u009F\uD800-\uDFFF\uFDD0-\uFDDF\u{1FFFE}-\u{1FFFF}\u{2FFFE}-\u{2FFFF}\u{3FFFE}-\u{3FFFF}\u{4FFFE}-\u{4FFFF}\u{5FFFE}-\u{5FFFF}\u{6FFFE}-\u{6FFFF}\u{7FFFE}-\u{7FFFF}\u{8FFFE}-\u{8FFFF}\u{9FFFE}-\u{9FFFF}\u{AFFFE}-\u{AFFFF}\u{BFFFE}-\u{BFFFF}\u{CFFFE}-\u{CFFFF}\u{DFFFE}-\u{DFFFF}\u{EFFFE}-\u{EFFFF}\u{FFFFE}-\u{FFFFF}\u{10FFFE}-\u{10FFFF}]/gu; | ||
const amp = /&/g; | ||
@@ -9,0 +9,0 @@ const lt = /</g; |
{ | ||
"name": "sitemap", | ||
"version": "7.1.0", | ||
"version": "7.1.1", | ||
"description": "Sitemap-generating lib/cli", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -147,2 +147,3 @@ # sitemap ![MIT License](https://img.shields.io/npm/l/sitemap)[![Build Status](https://travis-ci.org/ekalinin/sitemap.js.svg?branch=master)](https://travis-ci.org/ekalinin/sitemap.js)![Monthly Downloads](https://img.shields.io/npm/dm/sitemap) | ||
limit: 50000, // defaults to 45k | ||
lastmodDateOnly: false, // print date not time | ||
// SitemapAndIndexStream will call this user provided function every time | ||
@@ -158,7 +159,7 @@ // it needs to create a new sitemap file. You merely need to return a stream | ||
sitemapStream | ||
const ws = sitemapStream | ||
.pipe(createGzip()) // compress the output of the sitemap | ||
.pipe(createWriteStream(resolve(path + '.gz'))); // write it to sitemap-NUMBER.xml | ||
return [new URL(path, 'https://example.com/subdir/').toString(), sitemapStream]; | ||
return [new URL(path, 'https://example.com/subdir/').toString(), sitemapStream, ws]; | ||
}, | ||
@@ -165,0 +166,0 @@ }); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
169569
34
3034
287