New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

sitemap-generator

Package Overview
Dependencies
Maintainers
1
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sitemap-generator - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

8

package.json
{
"name": "sitemap-generator",
"version": "1.1.0",
"version": "1.2.0",
"description": "Creates a XML-Sitemap by crawling a given site.",

@@ -22,6 +22,6 @@ "homepage": "https://github.com/lgraubner/node-sitemap-generator",

"simplecrawler": "^0.5.2",
"lodash": "^3.8.0",
"xmlbuilder": "^2.6.2",
"lodash": "^3.10.0",
"xmlbuilder": "^2.6.4",
"commander": "^2.8.1",
"chalk": "^1.0.0"
"chalk": "^1.1.0"
},

@@ -28,0 +28,0 @@ "preferGlobal": true,

# Node Sitemap Generator
Creates a XML-Sitemap by crawling a given site.
## Usage
## Installation
```BASH
npm install -g sitemap-generator
$ npm install -g sitemap-generator
```
# sitemap-gen [options] <url>
sitemap-gen --query example.com
## Usage
```BASH
$ sitemap-gen [options] <url>
```
*Important*: Relative Links without leading slash are producing errors.
### Options
```BASH
$ sitemap-gen --help
|command|description
|:---|:---
|-q, --query|consider query string
Usage: sitemap-gen [options] <url>
Options:
-h, --help output usage information
-V, --version output the version number
-q, --query consider query string
-i, --include [ext,ext2] include fetched links by file extension, comma seperated
-e, --exclude [ext,ext2] exclude fetched links by file extension, comma seperated
-o, --output [path] specify output path
```
**Important**: Executing the sitemap-generator with sites using HTML `base`-tag along with links *without* leading slashes will probably not work.
#!/usr/bin/env node
var Crawler = require("simplecrawler");
var forIn = require("lodash/object/forIn");
var _ = require("lodash");
var fs = require("fs");

@@ -14,2 +14,4 @@ var builder = require("xmlbuilder");

.option("-q, --query", "consider query string")
.option("-i, --include [ext,ext2]", "include fetched links by file extension, comma seperated")
.option("-e, --exclude [ext,ext2]", "exclude fetched links by file extension, comma seperated")
.option("-o, --output [path]", "specify output path")

@@ -34,7 +36,24 @@ .parse(process.argv);

var path = "./";
var path = ".";
if (program.output) {
path = program.output;
path = program.output.replace(/\/+$/, "");
}
var exclude = ["gif", "jpg", "jpeg", "png", "ico", "bmp", "ogg", "webp", "mp4", "webm", "mp3", "ttf", "woff", "json", "rss", "atom", "gz", "zip", "rar", "7z", "css", "js", "gzip", "exe"];
if (program.include) {
exclude = _.difference(exclude, program.include.split(","));
}
if (program.exclude) {
exclude = _.union(exclude, program.exclude.split(","));
}
var exts = exclude.join("|");
var regex = new RegExp("\.(" + exts + ")", "i");
c.addFetchCondition(function(parsedURL) {
return !parsedURL.path.match(regex);
});
c.on("fetchcomplete", function(item) {

@@ -58,3 +77,3 @@ chunk.push({

var xml = builder.create("urlset", { version: "1.0", encoding: "UTF-8" }).att("xmlns", "http://www.sitemaps.org/schemas/sitemap/0.9");
forIn(chunk, function(value, key) {
_.forIn(chunk, function(value, key) {
xml.ele("url")

@@ -66,3 +85,3 @@ .ele(value);

fs.writeFile(path + "sitemap.xml", map, function(err) {
fs.writeFile(path + "/sitemap.xml", map, function(err) {
if (err) {

@@ -77,22 +96,2 @@ return console.log(chalk.red(err));

var image = c.addFetchCondition(function(parsedURL) {
return !parsedURL.path.match(/\.(gif|jpg|jpeg|png|ico|bmp)/i);
});
var media = c.addFetchCondition(function(parsedURL) {
return !parsedURL.path.match(/\.(ogg|webp|mp4|webm|mp3)/i);
});
var font = c.addFetchCondition(function(parsedURL) {
return !parsedURL.path.match(/\.(ttf|woff)$/i);
});
var data = c.addFetchCondition(function(parsedURL) {
return !parsedURL.path.match(/\.(json|rss|atom|gz|zip|rar|7z)/i);
});
var misc = c.addFetchCondition(function(parsedURL) {
return !parsedURL.path.match(/\.(css|js|gzip|exe)/i);
});
c.start();
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