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

netlify-plugin-submit-sitemap

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

netlify-plugin-submit-sitemap - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

44

index.js
const url = require('url');
const fetch = require('node-fetch');
const {

@@ -24,20 +24,18 @@ CONTEXT,

const submitToProvider = async ({ utils, provider, sitemapUrl }) => {
// Submit sitemap to a provider. Returns either a successful or failed submission, but no error is thrown
const submitToProvider = async ({ provider, sitemapUrl }) => {
if (!providerUrls[provider]) {
console.error(`Provider ${provider} not found!`);
return;
return { message: `Provider ${provider} not found!`, error: 'Invalid provider' };
}
const providerUrl = providerUrls[provider](sitemapUrl);
const command = `curl -s -o /dev/null --show-error --url ${providerUrl}`;
console.log(`Going to submit sitemap to ${provider} \n * URL: ${providerUrl}`);
console.log(`Going to submit sitemap to ${provider}, URL: ${providerUrl}`);
const { stderr } = await utils.run.command(command);
if (stderr) {
console.log(`\n \u274c ERROR, was not able to submit sitemap to ${provider}`);
return;
try {
await fetch(providerUrl);
} catch (error) {
return { message: `\u274c ERROR, was not able to submit sitemap to ${provider}`, error };
}
console.log(`\n \u2713 DONE! Sitemap submitted succesfully to ${provider}\n`);
return { message: `\u2713 DONE! Sitemap submitted succesfully to ${provider}` };
}

@@ -60,3 +58,3 @@

}
const sitemapUrl = url.resolve(baseUrl, sitemapPath);
const sitemapUrl = (new url.URL(sitemapPath, baseUrl)).href;

@@ -69,6 +67,22 @@ // Only run on production branch

for (const provider of providers) {
await submitToProvider({ utils, provider, sitemapUrl });
// submit sitemap to all providers
const submissions = await Promise.all(
providers.map(provider => submitToProvider({ provider, sitemapUrl }))
);
const messages = submissions
.map(submission => submission.message)
.join('\n');
const errors = submissions
.map(submission => submission.error)
.filter(error => error);
// If there was an error in 1 of the submissions, fail the plugin
if (errors.length > 0) {
utils.build.failPlugin(messages, { errors });
}
utils.status.show({ summary: 'Sitemap submitted successfully', text: messages });
}
};
{
"name": "netlify-plugin-submit-sitemap",
"version": "0.1.0",
"version": "0.1.1",
"description": "Automatically submit your sitemap to Google and Bing!",

@@ -19,3 +19,6 @@ "main": "index.js",

"netlify-plugin"
]
],
"dependencies": {
"node-fetch": "^2.6.0"
}
}
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