Socket
Socket
Sign inDemoInstall

sitemap

Package Overview
Dependencies
Maintainers
1
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sitemap - npm Package Compare versions

Comparing version 5.0.0 to 5.0.1

8

CHANGELOG.md

@@ -0,1 +1,9 @@

# 5.0.1
Fix for issue #254. ```
warning: failed to load external entity "./schema/all.xsd"
Schemas parser error : Failed to locate the main schema resource at './schema/all.xsd'.
WXS schema ./schema/all.xsd failed to compile
```
# 5.0.0

@@ -2,0 +10,0 @@ ## Streams

1

dist/cli.js

@@ -43,2 +43,3 @@ #!/usr/bin/env node

--version Print the version
--validate ensure the passed in file is conforms to the sitemap spec
--parse Parse fed xml and spit out config

@@ -45,0 +46,0 @@ --prepend sitemap.xml < urlsToAdd.json

3

dist/lib/xmllint.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const path_1 = require("path");
const child_process_1 = require("child_process");

@@ -11,3 +12,3 @@ const errors_1 = require("./errors");

function xmlLint(xml) {
const args = ['--schema', './schema/all.xsd', '--noout', '-'];
const args = ['--schema', path_1.resolve(__dirname, '..', '..', 'schema', 'all.xsd'), '--noout', '-'];
if (typeof xml === 'string') {

@@ -14,0 +15,0 @@ args[args.length - 1] = xml;

{
"name": "sitemap",
"version": "5.0.0",
"version": "5.0.1",
"description": "Sitemap-generating lib/cli",

@@ -123,17 +123,17 @@ "keywords": [

"dependencies": {
"@types/node": "^12.7.11",
"@types/node": "^12.11.5",
"@types/sax": "^1.2.0",
"arg": "^4.1.1",
"sax": "^1.2.4",
"xmlbuilder": "^13.0.0"
"xmlbuilder": "^13.0.2"
},
"devDependencies": {
"@babel/core": "^7.6.2",
"@babel/core": "^7.6.4",
"@babel/plugin-proposal-class-properties": "^7.5.5",
"@babel/plugin-transform-typescript": "^7.6.0",
"@babel/preset-env": "^7.6.2",
"@babel/plugin-transform-typescript": "^7.6.3",
"@babel/preset-env": "^7.6.3",
"@babel/preset-typescript": "^7.6.0",
"@types/jest": "^24.0.18",
"@typescript-eslint/eslint-plugin": "^2.3.2",
"@typescript-eslint/parser": "^2.3.2",
"@types/jest": "^24.0.19",
"@typescript-eslint/eslint-plugin": "^2.5.0",
"@typescript-eslint/parser": "^2.5.0",
"babel-eslint": "^10.0.3",

@@ -143,5 +143,5 @@ "babel-polyfill": "^6.26.0",

"eslint": "^6.5.1",
"eslint-plugin-jest": "^22.17.0",
"eslint-plugin-jest": "^22.20.0",
"express": "^4.17.1",
"husky": "^3.0.8",
"husky": "^3.0.9",
"jest": "^24.9.0",

@@ -153,3 +153,3 @@ "sort-package-json": "^1.22.1",

"through2-map": "^3.0.0",
"typescript": "^3.6.3"
"typescript": "^3.6.4"
},

@@ -156,0 +156,0 @@ "engines": {

@@ -1,3 +0,2 @@

sitemap.js [![Build Status](https://travis-ci.org/ekalinin/sitemap.js.svg?branch=master)](https://travis-ci.org/ekalinin/sitemap.js)
==========
# sitemap.js [![Build Status](https://travis-ci.org/ekalinin/sitemap.js.svg?branch=master)](https://travis-ci.org/ekalinin/sitemap.js)

@@ -7,4 +6,3 @@ **sitemap.js** is a high-level sitemap-generating library/CLI that

Maintainers
-----------
## Maintainers

@@ -14,40 +12,38 @@ - [@ekalinin](https://github.com/ekalinin)

## Table of Contents
Table of Contents
=================
- [Installation](#installation)
- [Usage](#usage)
- [CLI](#cli)
- [Example of using sitemap.js with <a href="https://expressjs.com/">express</a>](#example-of-using-sitemapjs-with-express)
- [Stream writing a sitemap](#stream-writing-a-sitemap)
- [Example of most of the options you can use for sitemap](#example-of-most-of-the-options-you-can-use-for-sitemap)
- [Building just the sitemap index file](#building-just-the-sitemap-index-file)
- [Auto creating sitemap and index files from one large list](#auto-creating-sitemap-and-index-files-from-one-large-list)
- [API](#api)
- [Sitemap (deprecated)](#sitemap---deprecated)
- [buildSitemapIndex](#buildsitemapindex)
- [createSitemapsAndIndex](#createsitemapsandindex)
- [xmlLint](#xmllint)
- [parseSitemap](#parsesitemap)
- [SitemapStream](#sitemapstream)
- [XMLToISitemapOptions](#XMLToISitemapOptions)
- [lineSeparatedURLsToSitemapOptions](#lineseparatedurlstositemapoptions)
- [streamToPromise](#streamtopromise)
- [ObjectStreamToJSON](#objectstreamtojson)
- [Sitemap Item Options](#sitemap-item-options)
- [ISitemapImage](#isitemapimage)
- [IVideoItem](#ivideoitem)
- [ILinkItem](#ilinkitem)
- [INewsItem](#inewsitem)
- [License](#license)
* [Installation](#installation)
* [Usage](#usage)
* [CLI](#cli)
* [Example of using sitemap.js with <a href="https://expressjs.com/">express</a>](#example-of-using-sitemapjs-with-express)
* [Stream writing a sitemap](#stream-writing-a-sitemap)
* [Example of most of the options you can use for sitemap](#example-of-most-of-the-options-you-can-use-for-sitemap)
* [Building just the sitemap index file](#building-just-the-sitemap-index-file)
* [Auto creating sitemap and index files from one large list](#auto-creating-sitemap-and-index-files-from-one-large-list)
* [API](#api)
* [Sitemap (deprecated)](#sitemap---deprecated)
* [buildSitemapIndex](#buildsitemapindex)
* [createSitemapsAndIndex](#createsitemapsandindex)
* [xmlLint](#xmllint)
* [parseSitemap](#parsesitemap)
* [SitemapStream](#sitemapstream)
* [XMLToISitemapOptions](#XMLToISitemapOptions)
* [lineSeparatedURLsToSitemapOptions](#lineseparatedurlstositemapoptions)
* [streamToPromise](#streamtopromise)
* [ObjectStreamToJSON](#objectstreamtojson)
* [Sitemap Item Options](#sitemap-item-options)
* [ISitemapImage](#isitemapimage)
* [IVideoItem](#ivideoitem)
* [ILinkItem](#ilinkitem)
* [INewsItem](#inewsitem)
* [License](#license)
## Installation
Installation
------------
```sh
npm install --save sitemap
```
npm install --save sitemap
## Usage
Usage
-----
## CLI

@@ -57,8 +53,24 @@

npx sitemap < listofurls.txt
```sh
npx sitemap < listofurls.txt
```
Or verify an existing sitemap (requires libxml)
Or validate an existing sitemap (requires libxml)
npx sitemap --verify sitemap.xml
```sh
npx sitemap --validate sitemap.xml
```
Or take an existing sitemap and turn it into options that can be fed into the libary
```sh
npx sitemap --parse sitemap.xml
```
Or prepend some new urls to an existing sitemap
```sh
npx sitemap --prepend sitemap.xml < listofurls.json # or txt
```
## As a library

@@ -80,2 +92,3 @@

Resolves to a string containing the XML data
```xml

@@ -105,3 +118,3 @@ <?xml version="1.0" encoding="UTF-8"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1"><url><loc>http://example.com/page-1/</loc><changefreq>daily</changefreq><priority>0.3</priority></url><url><loc>http://example.com/page-2</loc></url></urlset>

const smStream = new SitemapStream({ hostname: 'https://example.com/' })
.pipe(createGzip())
const pipeline = smStream.pipe(createGzip())

@@ -112,7 +125,8 @@ smStream.write({ url: '/page-1/', changefreq: 'daily', priority: 0.3 })

smStream.write({ url: '/page-4/', img: "http://urlTest.com" })
smStream.end()
// cache the response
streamToPromise(gzippedStream).then(sm => sitemap = sm)
streamToPromise(pipeline).then(sm => sitemap = sm)
// stream the response
gzippedStream.pipe(res).on('error', (e) => {throw e})
pipeline.pipe(res).on('error', (e) => {throw e})
} catch (e) {

@@ -130,2 +144,3 @@ console.error(e)

### Stream writing a sitemap
The sitemap stream is around 20% faster and only uses ~10% the memory of the traditional interface

@@ -172,3 +187,3 @@

.pipe(streamArray())
.pipe(map.obj(chunk => chunk.value)),
.pipe(map.obj(chunk => chunk.value))
.pipe(new SitemapStream({ hostname: 'https://example.com/' }))

@@ -186,3 +201,3 @@ .pipe(createGzip())

// alternatively you can pipe to another stream
streamToSitemap(smStream).then(console.log)
streamToPromise(smStream).then(console.log)

@@ -284,3 +299,3 @@ smStream.write({

## API
## API

@@ -300,70 +315,90 @@ ### Sitemap - __deprecated__

__toString__
```js
sm.toString(true)
```
#### toString
```js
sm.toString(true)
```
Converts the urls stored in an instance of Sitemap to a valid sitemap xml document as a string. Accepts a boolean as its first argument to designate on whether to pretty print. Defaults to false.
__toXML__
#### toXML
alias for toString
__toGzip__
```js
sm.toGzip ((xmlGzippedBuffer) => console.log(xmlGzippedBuffer))
sm.toGzip()
```
Like toString, it builds the xmlDocument, then it runs gzip on the resulting string and returns it as a Buffer via callback or direct invocation
#### toGzip
```js
sm.toGzip ((xmlGzippedBuffer) => console.log(xmlGzippedBuffer))
sm.toGzip()
```
Like toString, it builds the xmlDocument, then it runs gzip on the resulting string and returns it as a Buffer via callback or direct invocation
#### clearCache
```js
sm.clearCache()
```
Cache will be emptied and will be bypassed until set again
__clearCache__
```js
sm.clearCache()
```
Cache will be emptied and will be bypassed until set again
#### isCacheValid
```js
sm.isCacheValid()
```
Returns true if it has been less than cacheTimeout ms since cache was set
__isCacheValid__
```js
sm.isCacheValid()
```
Returns true if it has been less than cacheTimeout ms since cache was set
#### setCache
```js
sm.setCache('...xmlDoc')
```
Stores the passed in string on the instance to be used when toString is called within the configured cacheTimeout returns the passed in string unaltered
__setCache__
```js
sm.setCache('...xmlDoc')
```
Stores the passed in string on the instance to be used when toString is called within the configured cacheTimeout
returns the passed in string unaltered
#### add
```js
sm.add('/path', 'warn')
```
Adds the provided url to the sitemap instance
takes an optional parameter level for whether to print a console warning in the event of bad data 'warn' (default),
throw an exception 'throw', or quietly ignore bad data 'silent'
returns the number of locations currently in the sitemap instance
__add__
```js
sm.add('/path', 'warn')
```
Adds the provided url to the sitemap instance
takes an optional parameter level for whether to print a console warning in the event of bad data 'warn' (default),
throw an exception 'throw', or quietly ignore bad data 'silent'
returns the number of locations currently in the sitemap instance
#### contains
```js
sm.contains('/path')
```
Returns true if path is already a part of the sitemap instance, false otherwise.
__contains__
```js
sm.contains('/path')
```
Returns true if path is already a part of the sitemap instance, false otherwise.
__del__
```js
sm.del('/path')
```
Removes the provided url or url option from the sitemap instance
#### del
__normalizeURL__
```js
Sitemap.normalizeURL('/', 'http://example.com')
```
Static function that returns the stricter form of a options passed to SitemapItem
```js
sm.del('/path')
```
Removes the provided url or url option from the sitemap instance
#### normalizeURL
```js
Sitemap.normalizeURL('/', 'http://example.com')
```
Static function that returns the stricter form of a options passed to SitemapItem
__normalizeURLs__
```js
Sitemap.normalizeURLs(['http://example.com', {url: 'http://example.com'}])
```
Static function that takes an array of urls and returns a Map of their resolved url to the strict form of SitemapItemOptions
#### normalizeURLs
```js
Sitemap.normalizeURLs(['http://example.com', {url: 'http://example.com'}])
```
Static function that takes an array of urls and returns a Map of their resolved url to the strict form of SitemapItemOptions
### buildSitemapIndex

@@ -382,6 +417,9 @@

### createSitemapsAndIndex
Create several sitemaps and an index automatically from a list of urls
```js
const { createSitemapsAndIndex } createsitemapsandindex('sitemap')
createSitemapsAndIndex(createsitemapsandindex: [/* list of urls */],
const { createSitemapsAndIndex } = require('sitemap')
createSitemapsAndIndex({
urls: [/* list of urls */],
targetFolder: 'absolute path to target folder',

@@ -428,15 +466,19 @@ hostname: 'http://example.com',

### SitemapStream
A [Transform](https://nodejs.org/api/stream.html#stream_implementing_a_transform_stream) for turning a [Readable stream](https://nodejs.org/api/stream.html#stream_readable_streams) of either [SitemapItemOptions](#sitemap-item-options) or url strings into a Sitemap. The readable stream it transforms **must** be in object mode.
```javascript
const { SitemapStream } = require('sitemap')
const sms = new SitemapStream({
hostname: 'https://example.com' // optional only necessary if your paths are relative
})
const readable = // a readable stream of objects
readable.pipe(sms).pipe(process.stdout)
const { SitemapStream } = require('sitemap')
const sms = new SitemapStream({
hostname: 'https://example.com' // optional only necessary if your paths are relative
})
const readable = // a readable stream of objects
readable.pipe(sms).pipe(process.stdout)
```
### XMLToISitemapOptions
Takes a stream of xml and transforms it into a stream of ISitemapOptions.
Use this to parse existing sitemaps into config options compatible with this library
```javascript

@@ -456,6 +498,9 @@ const { createReadStream, createWriteStream } = require('fs');

### lineSeparatedURLsToSitemapOptions
Takes a stream of urls or sitemapoptions likely from fs.createReadStream('./path') and returns an object stream of sitemap items.
### streamToPromise
Takes a stream returns a promise that resolves when stream emits finish.
```javascript

@@ -470,4 +515,7 @@ const { streamToPromise, SitemapStream } = require('sitemap')

### ObjectStreamToJSON
A Transform that converts a stream of objects into a JSON Array or a line separated stringified JSON.
* @param [lineSeparated=false] whether to separate entries by a new line or comma
- @param [lineSeparated=false] whether to separate entries by a new line or comma
```javascript

@@ -485,11 +533,11 @@ const stream = Readable.from([{a: 'b'}])

|------|----|--|-----------|
|url|string|http://example.com/some/path|The only required property for every sitemap entry|
|lastmod|string|'2019-07-29' or '2019-07-22T05:58:37.037Z'|When the page we as last modified use the W3C Datetime ISO8601 subset https://www.sitemaps.org/protocol.html#xmlTagDefinitions|
|changefreq|string|'weekly'|How frequently the page is likely to change. This value provides general information to search engines and may not correlate exactly to how often they crawl the page. Please note that the value of this tag is considered a hint and not a command. See https://www.sitemaps.org/protocol.html#xmlTagDefinitions for the acceptable values|
|priority|number|0.6|The priority of this URL relative to other URLs on your site. Valid values range from 0.0 to 1.0. This value does not affect how your pages are compared to pages on other sites—it only lets the search engines know which pages you deem most important for the crawlers. The default priority of a page is 0.5. https://www.sitemaps.org/protocol.html#xmlTagDefinitions|
|img|object[]|see [#ISitemapImage](#ISitemapImage)|https://support.google.com/webmasters/answer/178636?hl=en&ref_topic=4581190|
|video|object[]|see [#IVideoItem](#IVideoItem)|https://support.google.com/webmasters/answer/80471?hl=en&ref_topic=4581190|
|links|object[]|see [#ILinkItem](#ILinkItem)|Tell search engines about localized versions https://support.google.com/webmasters/answer/189077|
|news|object|see [#INewsItem](#INewsItem)|https://support.google.com/webmasters/answer/74288?hl=en&ref_topic=4581190|
|ampLink|string|'http://ampproject.org/article.amp.html'||
|url|string|`http://example.com/some/path`|The only required property for every sitemap entry|
|lastmod|string|'2019-07-29' or '2019-07-22T05:58:37.037Z'|When the page we as last modified use the W3C Datetime ISO8601 subset <https://www.sitemaps.org/protocol.html#xmlTagDefinitions>|
|changefreq|string|'weekly'|How frequently the page is likely to change. This value provides general information to search engines and may not correlate exactly to how often they crawl the page. Please note that the value of this tag is considered a hint and not a command. See <https://www.sitemaps.org/protocol.html#xmlTagDefinitions> for the acceptable values|
|priority|number|0.6|The priority of this URL relative to other URLs on your site. Valid values range from 0.0 to 1.0. This value does not affect how your pages are compared to pages on other sites—it only lets the search engines know which pages you deem most important for the crawlers. The default priority of a page is 0.5. <https://www.sitemaps.org/protocol.html#xmlTagDefinitions>|
|img|object[]|see [#ISitemapImage](#ISitemapImage)|<https://support.google.com/webmasters/answer/178636?hl=en&ref_topic=4581190>|
|video|object[]|see [#IVideoItem](#IVideoItem)|<https://support.google.com/webmasters/answer/80471?hl=en&ref_topic=4581190>|
|links|object[]|see [#ILinkItem](#ILinkItem)|Tell search engines about localized versions <https://support.google.com/webmasters/answer/189077>|
|news|object|see [#INewsItem](#INewsItem)|<https://support.google.com/webmasters/answer/74288?hl=en&ref_topic=4581190>|
|ampLink|string|`http://ampproject.org/article.amp.html`||
|cdata|boolean|true|wrap url in cdata xml escape|

@@ -500,23 +548,23 @@

Sitemap image
https://support.google.com/webmasters/answer/178636?hl=en&ref_topic=4581190
<https://support.google.com/webmasters/answer/178636?hl=en&ref_topic=4581190>
|Option|Type|eg|Description|
|------|----|--|-----------|
|url|string|'http://example.com/image.jpg'|The URL of the image.|
|url|string|`http://example.com/image.jpg`|The URL of the image.|
|caption|string - optional|'Here we did the stuff'|The caption of the image.|
|title|string - optional|'Star Wars EP IV'|The title of the image.|
|geoLocation|string - optional|'Limerick, Ireland'|The geographic location of the image.|
|license|string - optional|'http://example.com/license.txt'|A URL to the license of the image.|
|license|string - optional|`http://example.com/license.txt`|A URL to the license of the image.|
### IVideoItem
Sitemap video. https://support.google.com/webmasters/answer/80471?hl=en&ref_topic=4581190
Sitemap video. <https://support.google.com/webmasters/answer/80471?hl=en&ref_topic=4581190>
|Option|Type|eg|Description|
|------|----|--|-----------|
|thumbnail_loc|string|"https://rtv3-img-roosterteeth.akamaized.net/store/0e841100-289b-4184-ae30-b6a16736960a.jpg/sm/thumb3.jpg"|A URL pointing to the video thumbnail image file|
|thumbnail_loc|string|`"https://rtv3-img-roosterteeth.akamaized.net/store/0e841100-289b-4184-ae30-b6a16736960a.jpg/sm/thumb3.jpg"`|A URL pointing to the video thumbnail image file|
|title|string|'2018:E6 - GoldenEye: Source'|The title of the video. |
|description|string|'We play gun game in GoldenEye: Source with a good friend of ours. His name is Gruchy. Dan Gruchy.'|A description of the video. Maximum 2048 characters. |
|content_loc|string - optional|"http://streamserver.example.com/video123.mp4"|A URL pointing to the actual video media file. Should be one of the supported formats.HTML is not a supported format. Flash is allowed, but no longer supported on most mobile platforms, and so may be indexed less well. Must not be the same as the <loc> URL.|
|player_loc|string - optional|"https://roosterteeth.com/embed/rouletsplay-2018-goldeneye-source"|A URL pointing to a player for a specific video. Usually this is the information in the src element of an <embed> tag. Must not be the same as the <loc> URL|
|content_loc|string - optional|`"http://streamserver.example.com/video123.mp4"`|A URL pointing to the actual video media file. Should be one of the supported formats.HTML is not a supported format. Flash is allowed, but no longer supported on most mobile platforms, and so may be indexed less well. Must not be the same as the `<loc>` URL.|
|player_loc|string - optional|`"https://roosterteeth.com/embed/rouletsplay-2018-goldeneye-source"`|A URL pointing to a player for a specific video. Usually this is the information in the src element of an `<embed>` tag. Must not be the same as the `<loc>` URL|
|'player_loc:autoplay'|string - optional|'ap=1'|a string the search engine can append as a query param to enable automatic playback|

@@ -530,3 +578,3 @@ |duration|number - optional| 600| duration of video in seconds|

|restriction:relationship| string - optional|"deny"||
|gallery_loc| string - optional|"https://roosterteeth.com/series/awhu"|Currently not used.|
|gallery_loc| string - optional|`"https://roosterteeth.com/series/awhu"`|Currently not used.|
|gallery_loc:title|string - optional|"awhu series page"|Currently not used.|

@@ -538,3 +586,3 @@ |price|string - optional|"1.99"|The price to download or view the video. Omit this tag for free videos.|

|uploader|string - optional|"GrillyMcGrillerson"|The video uploader's name. Only one <video:uploader> is allowed per video. String value, max 255 characters.|
|platform|string - optional|"tv"|Whether to show or hide your video in search results on specified platform types. This is a list of space-delimited platform types. See https://support.google.com/webmasters/answer/80471?hl=en&ref_topic=4581190 for more detail|
|platform|string - optional|"tv"|Whether to show or hide your video in search results on specified platform types. This is a list of space-delimited platform types. See <https://support.google.com/webmasters/answer/80471?hl=en&ref_topic=4581190> for more detail|
|platform:relationship|string 'Allow'\|'Deny' - optional|'Allow'||

@@ -550,3 +598,3 @@ |id|string - optional|||

https://support.google.com/webmasters/answer/189077
<https://support.google.com/webmasters/answer/189077>

@@ -556,7 +604,7 @@ |Option|Type|eg|Description|

|lang|string|'en'||
|url|string|'http://example.com/en/'||
|url|string|`'http://example.com/en/'`||
### INewsItem
https://support.google.com/webmasters/answer/74288?hl=en&ref_topic=4581190
<https://support.google.com/webmasters/answer/74288?hl=en&ref_topic=4581190>

@@ -567,4 +615,4 @@ |Option|Type|eg|Description|

|publication| object|see following options||
|publication['name']| string|'The Example Times'|The <name> is the name of the news publication. It must exactly match the name as it appears on your articles on news.google.com, except for anything in parentheses.|
|publication['language']|string|'en'|he <language> is the language of your publication. Use an ISO 639 language code (2 or 3 letters).|
|publication['name']| string|'The Example Times'|The `<name>` is the name of the news publication. It must exactly match the name as it appears on your articles on news.google.com, except for anything in parentheses.|
|publication['language']|string|'en'|he `<language>` is the language of your publication. Use an ISO 639 language code (2 or 3 letters).|
|genres|string - optional|'PressRelease, Blog'||

@@ -576,5 +624,4 @@ |publication_date|string|'2008-12-23'|Article publication date in W3C format, using either the "complete date" (YYYY-MM-DD) format or the "complete date plus hours, minutes, and seconds"|

License
-------
## License
See [LICENSE](https://github.com/ekalinin/sitemap.js/blob/master/LICENSE) file.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc