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

hexo-migrator-tryghost

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hexo-migrator-tryghost - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

.vscode/settings.json

137

index.js

@@ -1,46 +0,53 @@

var fs = require('fs');
var JSONStream = require('JSONStream');
var es = require('event-stream');
/* global hexo */
'use strict'
var tagsList = {};
var mapPostToTag = {};
var fs = require('fs')
var JSONStream = require('JSONStream')
var es = require('event-stream')
function loadMeta(src, callback) {
var log = hexo.log;
var waiting = false;
var tagsList = {}
var mapPostToTag = {}
function loadMeta (src, callback) {
var log = hexo.log
var waiting = false
var tagSrc = fs.createReadStream(src)
.pipe(JSONStream.parse(['db', true, 'data', 'tags', true]))
.pipe(es.mapSync(data => {
tagsList[data.id] = {
name: data.name,
slug: data.slug
};
}));
.pipe(JSONStream.parse(['db', true, 'data', 'tags', true]))
.pipe(es.mapSync(tag => {
tagsList[tag.id] = {
name: tag.name,
slug: tag.slug
}
}))
var mapSrc = fs.createReadStream(src)
.pipe(JSONStream.parse(['db', true, 'data', 'posts_tags', true]))
.pipe(es.mapSync(data => {
if (!mapPostToTag[data.post_id]) {
mapPostToTag[data.post_id] = [];
}
.pipe(JSONStream.parse(['db', true, 'data', 'posts_tags', true]))
.pipe(es.mapSync(post2Tag => {
if (!mapPostToTag[post2Tag.post_id]) {
mapPostToTag[post2Tag.post_id] = []
}
mapPostToTag[data.post_id].push(data.tag_id);
}));
mapPostToTag[post2Tag.post_id].push(post2Tag.tag_id)
}))
tagSrc.on('end', (ev) => {
log.i('tag data are finish');
if (waiting) { return callback() };
waiting = true;
});
log.i('tag data are finish')
if (waiting) {
return callback()
}
waiting = true
})
mapSrc.on('end', () => {
log.i('post to tag are finish');
if (waiting) { return callback() };
waiting = true;
});
log.i('post to tag are finish')
if (waiting) {
return callback()
}
waiting = true
})
}
hexo.extend.migrator.register('ghost', function (args, callback) {
var source = args._.shift();
var source = args._.shift()

@@ -52,25 +59,24 @@ if (!source) {

'For more help, you can check https://hexo.io/docs/migration.html'
];
]
console.log(help.join('\n'));
return callback();
console.log(help.join('\n'))
return callback()
}
var log = hexo.log;
var post = hexo.post;
var posts = [];
var fixYaml = new RegExp('[\"|\'|\&]', 'g');
var log = hexo.log
var post = hexo.post
var fixYaml = new RegExp('["|\'|&]', 'g')
log.i('Ready to import ghost posts');
loadMeta((source), () => {
log.i('Load import metadata...');
log.i('Ready to import ghost posts')
loadMeta((source), () => {
log.i('Load import metadata...')
var srcEv = fs.createReadStream(source)
.pipe(JSONStream.parse(['db', true, 'data', 'posts', true]))
.pipe(es.mapSync(data => {
if (data.title
&& data.created_at
&& data.markdown
&& data.status === 'published') {
.pipe(JSONStream.parse(['db', true, 'data', 'posts', true]))
.pipe(es.mapSync(data => {
if (data.title &&
data.created_at &&
data.markdown &&
data.status === 'published') {
if (data.title.match(fixYaml)) {
log.i(data.title + 'invalid in yaml, need fixed');
log.i(data.title + 'invalid in yaml, need fixed')
}

@@ -83,26 +89,27 @@

slug: data.slug
};
}
var tags = [];
var tags = []
if (mapPostToTag[data.id] && Array.isArray(mapPostToTag[data.id])) {
mapPostToTag[data.id].forEach(item => {
if (tagsList[item]) tags.push(tagsList[item]['name']);
});
log.i(`${newPost.title} has tags - ${tags.join(',')}`);
if (tagsList[item]) tags.push(tagsList[item]['name'])
})
log.i(`${newPost.title} has tags - ${tags.join(',')}`)
}
if (tags.length > 0) { newPost.tags = tags; }
if (tags.length > 0) {
newPost.tags = tags
}
log.i(`Create post - ${data.title}`);
post.create(newPost);
log.i(`Create post - ${data.title}`)
post.create(newPost)
} else {
log.i('ERROR - Incorrect post format', JSON.stringify(data));
log.i('ERROR - Incorrect post format', JSON.stringify(data))
}
}));
}))
srcEv.on('end', function() {
log.i('Finish import ghost posts');
callback();
});
});
});
srcEv.on('end', function () {
log.i('Finish import ghost posts')
callback()
})
})
})
{
"name": "hexo-migrator-tryghost",
"version": "1.1.0",
"version": "1.1.1",
"description": "Ghost migrator plugin for Hexo",

@@ -5,0 +5,0 @@ "main": "index.js",

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