Socket
Socket
Sign inDemoInstall

sitemap

Package Overview
Dependencies
Maintainers
2
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 6.2.0 to 6.3.0

CODE_OF_CONDUCT.md

32

api.md

@@ -20,3 +20,3 @@ # API

### SitemapStream
## SitemapStream

@@ -42,3 +42,3 @@ 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.

### XMLToSitemapItemStream
## XMLToSitemapItemStream

@@ -61,3 +61,3 @@ Takes a stream of xml and transforms it into a stream of SitemapOptions.

### sitemapAndIndexStream
## sitemapAndIndexStream

@@ -103,3 +103,3 @@ Use this to take a stream which may go over the max of 50000 items and split it into an index and sitemaps.

### createSitemapsAndIndex
## createSitemapsAndIndex

@@ -121,3 +121,3 @@ Create several sitemaps and an index automatically from a list of urls. __deprecated__

### SitemapIndexStream
## SitemapIndexStream

@@ -145,3 +145,3 @@ Writes a sitemap index when given a stream urls.

### xmlLint
## xmlLint

@@ -161,3 +161,3 @@ Resolve or reject depending on whether the passed in xml is a valid sitemap.

### parseSitemap
## parseSitemap

@@ -178,7 +178,7 @@ Read xml and resolve with the configuration that would produce it or reject with

### lineSeparatedURLsToSitemapOptions
## lineSeparatedURLsToSitemapOptions
Takes a stream of urls or sitemapoptions likely from fs.createReadStream('./path') and returns an object stream of sitemap items.
### streamToPromise
## streamToPromise

@@ -195,3 +195,3 @@ Takes a stream returns a promise that resolves when stream emits finish.

### ObjectStreamToJSON
## ObjectStreamToJSON

@@ -210,3 +210,3 @@ A Transform that converts a stream of objects into a JSON Array or a line separated stringified JSON.

### SitemapItemStream
## SitemapItemStream

@@ -224,3 +224,3 @@ Takes a stream of SitemapItemOptions and spits out xml for each

### Sitemap Item Options
## Sitemap Item Options

@@ -240,3 +240,3 @@ |Option|Type|eg|Description|

### SitemapImage
## SitemapImage

@@ -254,3 +254,3 @@ Sitemap image

### VideoItem
## VideoItem

@@ -291,3 +291,3 @@ Sitemap video. <https://support.google.com/webmasters/answer/80471?hl=en&ref_topic=4581190>

### ILinkItem
## ILinkItem

@@ -301,3 +301,3 @@ <https://support.google.com/webmasters/answer/189077>

### NewsItem
## NewsItem

@@ -304,0 +304,0 @@ <https://support.google.com/webmasters/answer/74288?hl=en&ref_topic=4581190>

# Changelog
## 6.3.0
- simpleSitemap will create the dest directory if it doesn't exist
- allow user to not gzip fixes #322
## 6.2.0

@@ -4,0 +9,0 @@

import { Readable } from 'stream';
import { SitemapItemLoose } from './types';
export declare const simpleSitemapAndIndex: ({ hostname, sitemapHostname, sourceData, destinationDir, limit, }: {
export declare const simpleSitemapAndIndex: ({ hostname, sitemapHostname, sourceData, destinationDir, limit, gzip, }: {
hostname: string;

@@ -9,3 +9,4 @@ sitemapHostname?: string | undefined;

limit?: number | undefined;
gzip?: boolean | undefined;
}) => Promise<void>;
export default simpleSitemapAndIndex;

@@ -12,7 +12,8 @@ "use strict";

const pipeline = util_1.promisify(stream_1.pipeline);
exports.simpleSitemapAndIndex = ({ hostname, sitemapHostname = hostname, // if different
exports.simpleSitemapAndIndex = async ({ hostname, sitemapHostname = hostname, // if different
/**
* Pass a line separated list of sitemap items or a stream or an array
*/
sourceData, destinationDir, limit = 50000, }) => {
sourceData, destinationDir, limit = 50000, gzip = true, }) => {
await fs_1.promises.mkdir(destinationDir, { recursive: true });
const sitemapAndIndexStream = new index_1.SitemapAndIndexStream({

@@ -25,5 +26,11 @@ limit,

const path = `./sitemap-${i}.xml`;
sitemapStream
.pipe(zlib_1.createGzip()) // compress the output of the sitemap
.pipe(fs_1.createWriteStream(path_1.resolve(destinationDir, path + '.gz'))); // write it to sitemap-NUMBER.xml
const writePath = path_1.resolve(destinationDir, path + (gzip ? '.gz' : ''));
if (gzip) {
sitemapStream
.pipe(zlib_1.createGzip()) // compress the output of the sitemap
.pipe(fs_1.createWriteStream(writePath)); // write it to sitemap-NUMBER.xml
}
else {
sitemapStream.pipe(fs_1.createWriteStream(writePath)); // write it to sitemap-NUMBER.xml
}
return [new url_1.URL(path, sitemapHostname).toString(), sitemapStream];

@@ -45,4 +52,10 @@ },

}
return pipeline(src, sitemapAndIndexStream, zlib_1.createGzip(), fs_1.createWriteStream(path_1.resolve(destinationDir, './sitemap-index.xml.gz')));
const writePath = path_1.resolve(destinationDir, `./sitemap-index.xml${gzip ? '.gz' : ''}`);
if (gzip) {
return pipeline(src, sitemapAndIndexStream, zlib_1.createGzip(), fs_1.createWriteStream(writePath));
}
else {
return pipeline(src, sitemapAndIndexStream, fs_1.createWriteStream(writePath));
}
};
exports.default = exports.simpleSitemapAndIndex;
{
"name": "sitemap",
"version": "6.2.0",
"version": "6.3.0",
"description": "Sitemap-generating lib/cli",

@@ -97,2 +97,8 @@ "keywords": [

],
"@typescript-eslint/ban-ts-comment": [
"error",
{
"ts-expect-error": "allow-with-description"
}
],
"@typescript-eslint/explicit-member-accessibility": "off",

@@ -153,3 +159,3 @@ "@typescript-eslint/naming-convention": [

"dependencies": {
"@types/node": "^14.0.18",
"@types/node": "^14.6.4",
"@types/sax": "^1.2.1",

@@ -160,30 +166,30 @@ "arg": "^4.1.3",

"devDependencies": {
"@babel/core": "^7.10.4",
"@babel/core": "^7.11.6",
"@babel/plugin-proposal-class-properties": "^7.10.4",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.10.4",
"@babel/plugin-proposal-optional-chaining": "^7.10.4",
"@babel/plugin-transform-typescript": "^7.10.4",
"@babel/preset-env": "^7.10.4",
"@babel/plugin-proposal-optional-chaining": "^7.11.0",
"@babel/plugin-transform-typescript": "^7.11.0",
"@babel/preset-env": "^7.11.5",
"@babel/preset-typescript": "^7.10.4",
"@types/jest": "^26.0.4",
"@typescript-eslint/eslint-plugin": "^3.6.0",
"@typescript-eslint/parser": "^3.6.0",
"@types/jest": "^26.0.13",
"@typescript-eslint/eslint-plugin": "^4.0.1",
"@typescript-eslint/parser": "^4.0.1",
"babel-eslint": "^10.1.0",
"babel-polyfill": "^6.26.0",
"concurrently": "^5.2.0",
"eslint": "^7.4.0",
"concurrently": "^5.3.0",
"eslint": "^7.8.1",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-jest": "^23.18.0",
"eslint-plugin-jest": "^24.0.0",
"eslint-plugin-prettier": "^3.1.4",
"express": "^4.17.1",
"husky": "^4.2.5",
"jest": "^26.1.0",
"lint-staged": "^10.2.11",
"prettier": "^2.0.5",
"jest": "^26.4.2",
"lint-staged": "^10.3.0",
"prettier": "^2.1.1",
"sort-package-json": "^1.44.0",
"source-map": "~0.7.3",
"stats-lite": "^2.2.0",
"stream-json": "^1.5.0",
"stream-json": "^1.7.1",
"through2-map": "^3.0.0",
"typescript": "^3.9.6"
"typescript": "^3.9.7"
},

@@ -190,0 +196,0 @@ "engines": {

@@ -6,7 +6,2 @@ # 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)

## Maintainers
- [@ekalinin](https://github.com/ekalinin)
- [@derduher](https://github.com/derduher)
## Table of Contents

@@ -19,4 +14,5 @@

- [Options you can pass](#options-you-can-pass)
- [More](#more)
- [Examples](#examples)
- [API](#api)
- [Maintainers](#maintainers)
- [License](#license)

@@ -42,2 +38,3 @@

const { SitemapStream, streamToPromise } = require( 'sitemap' )
const { Readable } = require( 'stream' )

@@ -50,10 +47,6 @@ // An array with your links

// Loop over your links and add them to your stream
links.forEach( link => stream.write( link ) )
// End the stream
stream.end()
// Return a promise that resolves with your XML string
return streamToPromise( stream ).then( data => data.toString() )
return streamToPromise(Readable.from(links).pipe(stream)).then((data) =>
data.toString()
)
```

@@ -69,2 +62,3 @@

const { createGzip } = require('zlib')
const { Readable } = require('stream')

@@ -92,2 +86,6 @@ const app = express()

smStream.write({ url: '/page-4/', img: "http://urlTest.com" })
/* or use
Readable.from([{url: '/page-1'}...]).pipe(smStream)
if you are looking to avoid writing your own loop.
*/

@@ -124,3 +122,3 @@ // cache the response

// writes sitemaps and index out to the destination you provide
// writes sitemaps and index out to the destination you provide.
simpleSitemapAndIndex({

@@ -132,3 +130,3 @@ hostname: 'https://example.com',

),
// or
// or (only works with node 10.17 and up)
sourceData: [{ url: '/page-1/', changefreq: 'daily'}, ...],

@@ -148,2 +146,3 @@ // or

const { createGzip } = require('zlib')
const { Readable } = require('stream')
const {

@@ -186,4 +185,6 @@ SitemapAndIndexStream,

const arrayOfSitemapItems = [{ url: '/page-1/', changefreq: 'daily'}, ...]
Readable.from(arrayOfSitemapItems).pipe(sms) // available as of node 10.17.0
// or
arrayOfSitemapItems.forEach(item => sms.write(item))
sms.end()
sms.end() // necessary to let it know you've got nothing else to write
```

@@ -276,3 +277,3 @@

## More
## Examples

@@ -285,4 +286,9 @@ For more examples see the [examples directory](./examples/)

## Maintainers
- [@ekalinin](https://github.com/ekalinin)
- [@derduher](https://github.com/derduher)
## 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