writr 1.9.11 → 1.9.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cache.d.ts +18 -0
- package/dist/cache.js +70 -0
- package/dist/cache.js.map +1 -0
- package/dist/config.d.ts +29 -0
- package/dist/config.js +104 -0
- package/dist/config.js.map +1 -0
- package/dist/data/dataProviderInterface.d.ts +12 -0
- package/dist/data/dataProviderInterface.js +2 -0
- package/dist/data/dataProviderInterface.js.map +1 -0
- package/dist/data/dataService.d.ts +19 -0
- package/dist/data/dataService.js +130 -0
- package/dist/data/dataService.js.map +1 -0
- package/dist/data/fileDataProvider.d.ts +20 -0
- package/dist/data/fileDataProvider.js +132 -0
- package/dist/data/fileDataProvider.js.map +1 -0
- package/dist/generator.d.ts +8 -0
- package/dist/generator.js +54 -0
- package/dist/generator.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +80 -0
- package/dist/index.js.map +1 -0
- package/dist/log.d.ts +6 -0
- package/dist/log.js +13 -0
- package/dist/log.js.map +1 -0
- package/dist/migrate/ghostMigrationProvider.d.ts +9 -0
- package/dist/migrate/ghostMigrationProvider.js +65 -0
- package/dist/migrate/ghostMigrationProvider.js.map +1 -0
- package/dist/migrate/jekyllMigrationProvider.d.ts +4 -0
- package/dist/migrate/jekyllMigrationProvider.js +11 -0
- package/dist/migrate/jekyllMigrationProvider.js.map +1 -0
- package/dist/migrate/mediumMigrationProvider.d.ts +7 -0
- package/dist/migrate/mediumMigrationProvider.js +26 -0
- package/dist/migrate/mediumMigrationProvider.js.map +1 -0
- package/dist/migrate/migrationProviderInterface.d.ts +3 -0
- package/dist/migrate/migrationProviderInterface.js +2 -0
- package/dist/migrate/migrationProviderInterface.js.map +1 -0
- package/dist/migrate/wordpressMigrationProvider.d.ts +12 -0
- package/dist/migrate/wordpressMigrationProvider.js +103 -0
- package/dist/migrate/wordpressMigrationProvider.js.map +1 -0
- package/dist/migrate.d.ts +6 -0
- package/dist/migrate.js +34 -0
- package/dist/migrate.js.map +1 -0
- package/dist/post.d.ts +31 -0
- package/dist/post.js +189 -0
- package/dist/post.js.map +1 -0
- package/dist/render/atomRenderProvider.d.ts +8 -0
- package/dist/render/atomRenderProvider.js +51 -0
- package/dist/render/atomRenderProvider.js.map +1 -0
- package/dist/render/htmRenderlProvider.d.ts +14 -0
- package/dist/render/htmRenderlProvider.js +117 -0
- package/dist/render/htmRenderlProvider.js.map +1 -0
- package/dist/render/imageRenderProvider.d.ts +8 -0
- package/dist/render/imageRenderProvider.js +15 -0
- package/dist/render/imageRenderProvider.js.map +1 -0
- package/dist/render/jsonRenderProvider.d.ts +8 -0
- package/dist/render/jsonRenderProvider.js +24 -0
- package/dist/render/jsonRenderProvider.js.map +1 -0
- package/dist/render/renderProviderInterface.d.ts +5 -0
- package/dist/render/renderProviderInterface.js +2 -0
- package/dist/render/renderProviderInterface.js.map +1 -0
- package/dist/serve.d.ts +16 -0
- package/dist/serve.js +29 -0
- package/dist/serve.js.map +1 -0
- package/dist/storage/fileStorageProvider.d.ts +10 -0
- package/dist/storage/fileStorageProvider.js +62 -0
- package/dist/storage/fileStorageProvider.js.map +1 -0
- package/dist/storage/storageProviderInterface.d.ts +8 -0
- package/dist/storage/storageProviderInterface.js +2 -0
- package/dist/storage/storageProviderInterface.js.map +1 -0
- package/dist/storage/storageService.d.ts +12 -0
- package/dist/storage/storageService.js +28 -0
- package/dist/storage/storageService.js.map +1 -0
- package/dist/tag.d.ts +9 -0
- package/dist/tag.js +34 -0
- package/dist/tag.js.map +1 -0
- package/dist/utils/parser.d.ts +5 -0
- package/dist/utils/parser.js +37 -0
- package/dist/utils/parser.js.map +1 -0
- package/dist/utils/setup.d.ts +8 -0
- package/dist/utils/setup.js +75 -0
- package/dist/utils/setup.js.map +1 -0
- package/package.json +1 -1
package/dist/index.js
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { createCommand } from "commander";
|
|
2
|
+
import { Setup } from "./utils/setup.js";
|
|
3
|
+
import { ConsoleMessage } from "./log.js";
|
|
4
|
+
import { Serve } from "./serve.js";
|
|
5
|
+
import { SiteGenerator } from "./generator.js";
|
|
6
|
+
import { Migrate } from "./migrate.js";
|
|
7
|
+
export class Writr {
|
|
8
|
+
async parseCLI(process) {
|
|
9
|
+
const program = createCommand();
|
|
10
|
+
program.storeOptionsAsProperties(true);
|
|
11
|
+
program
|
|
12
|
+
.command('build', { isDefault: true })
|
|
13
|
+
.description('Build the site')
|
|
14
|
+
.option("-p, --path <path>", "Path of where the blog, config, and template are located")
|
|
15
|
+
.option("-o, --output <path>", "Path of where to output the generated blog")
|
|
16
|
+
.option("-r, --render <list>", "What do you want rendered such as html or json (example --render html,json)")
|
|
17
|
+
.option("-c, --config <path>", "custom configuration path")
|
|
18
|
+
.action(async (options) => {
|
|
19
|
+
try {
|
|
20
|
+
await new SiteGenerator(options).run();
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
new ConsoleMessage().error('Error: ' + error.message);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
program
|
|
27
|
+
.command('init')
|
|
28
|
+
.description('Initialize a new Writr project')
|
|
29
|
+
.argument('[name]', 'Name of the project', 'Blog')
|
|
30
|
+
.action(async (name) => {
|
|
31
|
+
try {
|
|
32
|
+
await new Setup(name).init();
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
new ConsoleMessage().error('Error: ' + error.message);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
program
|
|
39
|
+
.command('new')
|
|
40
|
+
.description('Create new markdown file')
|
|
41
|
+
.action(async () => {
|
|
42
|
+
try {
|
|
43
|
+
await new Setup('new').new();
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
new ConsoleMessage().error('Error: ' + error.message);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
program
|
|
50
|
+
.command('migrate')
|
|
51
|
+
.description('Migrate from different sources to Writr')
|
|
52
|
+
.argument("<type> <options...>", "Provider type (jekyll, wordpress, etc), source and destination")
|
|
53
|
+
.action(async (options) => {
|
|
54
|
+
try {
|
|
55
|
+
const [type, src, dest] = options;
|
|
56
|
+
await new Migrate(type).migrate(src, dest);
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
new ConsoleMessage().error('Error: ' + error.message);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
program
|
|
63
|
+
.command('serve')
|
|
64
|
+
.description('Serve the site locally')
|
|
65
|
+
.option("-o, --output <path>", "Path of where to output the generated blog be served", 'blog_output')
|
|
66
|
+
.option("-p, --port <port>", "Port to serve the site on", '3000')
|
|
67
|
+
.option("--path <path>", "Path of where the blog, config, and template are located", './blog')
|
|
68
|
+
.option("-w, --watch", "Watch for changes and rebuild", false)
|
|
69
|
+
.action(async (options) => {
|
|
70
|
+
try {
|
|
71
|
+
await new Serve(options).run();
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
new ConsoleMessage().error('Error: ' + error.message);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
program.parse(process.argv);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAI1C,OAAO,EAAC,KAAK,EAAC,MAAM,kBAAkB,CAAC;AACvC,OAAO,EAAC,cAAc,EAAC,MAAM,UAAU,CAAC;AACxC,OAAO,EAAC,KAAK,EAAC,MAAM,YAAY,CAAC;AACjC,OAAO,EAAC,aAAa,EAAC,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAC,OAAO,EAAC,MAAM,cAAc,CAAC;AAErC,MAAM,OAAO,KAAK;IAKhB,KAAK,CAAC,QAAQ,CAAC,OAAuB;QAGpC,MAAM,OAA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AC,CAAA;QAGJ,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;CACF"}
|
package/dist/log.d.ts
ADDED
package/dist/log.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createLogger, transports } from "winston";
|
|
2
|
+
export class ConsoleMessage {
|
|
3
|
+
constructor() {
|
|
4
|
+
this.log = createLogger({ transports: [new transports.Console()] });
|
|
5
|
+
}
|
|
6
|
+
info(message) {
|
|
7
|
+
this.log.info(message);
|
|
8
|
+
}
|
|
9
|
+
error(message) {
|
|
10
|
+
this.log.error(message);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=log.js.map
|
package/dist/log.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.js","sourceRoot":"","sources":["../src/log.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,UAAU,EAAC,MAAM,SAAS,CAAC;AAEjD,MAAM,OAAO,cAAc;IAG1B;QACC,IAAI,CAAC,GAAG,GAAG,YAAY,CAAC,EAAE,UAAU,EAAE,CAAC,IAAI,UAAU,CAAC,OAAO,EAAE,CAAC,EAAC,CAAC,CAAC;IACpE,CAAC;IAED,IAAI,CAAC,OAAe;QACnB,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACxB,CAAC;IAED,KAAK,CAAC,OAAe;QACpB,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACzB,CAAC;CAED"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { MigrationProviderInterface } from "./migrationProviderInterface.js";
|
|
2
|
+
export declare class GhostMigrationProvider implements MigrationProviderInterface {
|
|
3
|
+
parser: any;
|
|
4
|
+
storage: any;
|
|
5
|
+
constructor();
|
|
6
|
+
fetchPosts(src: string): Promise<Record<string, any>[]>;
|
|
7
|
+
saveMedia(mediaFetched: any, dest: string): Promise<string>;
|
|
8
|
+
migrate(src: string, dest: string): Promise<boolean>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
import { ConsoleMessage } from "../log.js";
|
|
3
|
+
import { Parser } from "../utils/parser.js";
|
|
4
|
+
import { StorageService } from "../storage/storageService.js";
|
|
5
|
+
export class GhostMigrationProvider {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.parser = new Parser();
|
|
8
|
+
this.storage = new StorageService();
|
|
9
|
+
}
|
|
10
|
+
async fetchPosts(src) {
|
|
11
|
+
try {
|
|
12
|
+
const url = new URL(src);
|
|
13
|
+
const { searchParams, origin } = url;
|
|
14
|
+
const key = searchParams.get('key');
|
|
15
|
+
let totalPosts;
|
|
16
|
+
const { posts, meta } = (await axios.get(`${origin}/ghost/api/v2/content/posts/?key=${key}`)).data;
|
|
17
|
+
totalPosts = [...posts];
|
|
18
|
+
const { pagination: { pages } } = meta;
|
|
19
|
+
for (let i = 2; i <= pages; i++) {
|
|
20
|
+
const { posts } = (await axios.get(`${origin}/ghost/api/v2/content/posts/?key=${key}&page=${i}`)).data;
|
|
21
|
+
totalPosts = totalPosts.concat(posts);
|
|
22
|
+
}
|
|
23
|
+
return totalPosts;
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
throw new Error(error.message);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
async saveMedia(mediaFetched, dest) {
|
|
30
|
+
const { mediaUrl, slug } = mediaFetched;
|
|
31
|
+
const response = await axios.get(mediaUrl, { responseType: 'arraybuffer' });
|
|
32
|
+
// const { rawBody: media, headers } = response;
|
|
33
|
+
const { data: media, headers } = response;
|
|
34
|
+
const mime_type = headers['content-type'];
|
|
35
|
+
const extension = mime_type.split('/')[1];
|
|
36
|
+
const filename = `${slug}.${extension}`;
|
|
37
|
+
const mediaBuffer = Buffer.from(media, 'binary').toString('base64');
|
|
38
|
+
await this.storage.set(`${dest}/images/${filename}`, mediaBuffer);
|
|
39
|
+
return `/images/${filename}`;
|
|
40
|
+
}
|
|
41
|
+
async migrate(src, dest) {
|
|
42
|
+
try {
|
|
43
|
+
new ConsoleMessage().info('Migrating from Ghost to Writr');
|
|
44
|
+
const posts = await this.fetchPosts(src);
|
|
45
|
+
for (const post of posts) {
|
|
46
|
+
const { title, slug, html, feature_image, published_at } = post;
|
|
47
|
+
// Markdown header generation
|
|
48
|
+
let mdContent = this.parser.generateMdHeaders({ title, slug, date: published_at });
|
|
49
|
+
if (feature_image) {
|
|
50
|
+
const mediaPath = await this.saveMedia({ mediaUrl: feature_image, slug }, dest);
|
|
51
|
+
mdContent += `\n\n`;
|
|
52
|
+
}
|
|
53
|
+
// Markdown html content
|
|
54
|
+
mdContent += this.parser.htmlToMd(html);
|
|
55
|
+
await this.storage.set(`${dest}/${slug}.md`, mdContent);
|
|
56
|
+
}
|
|
57
|
+
new ConsoleMessage().info("Migration was completed successfully");
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
throw new Error('Error while migrating Ghost site: ' + src);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=ghostMigrationProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ghostMigrationProvider.js","sourceRoot":"","sources":["../../src/migrate/ghostMigrationProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,cAAc,EAAC,MAAM,WAAW,CAAC;AAEzC,OAAO,EAAC,MAAM,EAAC,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAC,cAAc,EAAC,MAAM,8BAA8B,CAAC;AAE5D,MAAM,OAAO,sBAAsB;IAKjC;QACE,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;QAC3B,IAAI,CAAC,OAAO,GAAG,IAAI,cAAc,EAAE,CAAC;IACt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xB,SAAS,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;gBAExC,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,IAAI,IAAI,KAAK,EAAE,SAAS,CAAC,CAAC;aACzD;YACD,IAAI,cAAc,EAAE,CAAC,IAAI,CAAC,sCAAsC,CAAC,CAAC;YAClE,OAAO,IAAI,CAAC;SACb;QAAC,OAAO,KAAU,EAAE;YACnB,MAAM,IAAI,KAAK,CAAC,oCAAoC,GAAG,GAAG,CAAC,CAAA;SAC5D;IACH,CAAC;CAEF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { StorageService } from "../storage/storageService.js";
|
|
2
|
+
import { ConsoleMessage } from "../log.js";
|
|
3
|
+
export class JekyllMigrationProvider {
|
|
4
|
+
async migrate(src, dest) {
|
|
5
|
+
new ConsoleMessage().info("Migrating Jekyll site from " + src + " to " + dest);
|
|
6
|
+
await new StorageService().copy(src + "/_posts", dest);
|
|
7
|
+
await new StorageService().copy(src + "/images", dest + '/images');
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=jekyllMigrationProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jekyllMigrationProvider.js","sourceRoot":"","sources":["../../src/migrate/jekyllMigrationProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,8BAA8B,CAAC;AAE5D,OAAO,EAAC,cAAc,EAAC,MAAM,WAAW,CAAC;AAEzC,MAAM,OAAO,uBAAuB;IAEhC,KAAK,CAAC,OAAO,CAAC,GAAW,EAAE,IAAY;QACnC,IAAI,cAAc,EAAE,CAAC,IAAI,CAAC,6BAA6B,GAAG,GAAG,GAAG,MAAM,GAAG,IAAI,CAAC,CAAC;QAC/E,MAAM,IAAI,cAAc,EAAE,CAAC,IAAI,CAAC,GAAG,GAAG,SAAS,EAAG,IAAI,CAAC,CAAC;QACxD,MAAM,IAAI,cAAc,EAAE,CAAC,IAAI,CAAC,GAAG,GAAG,SAAS,EAAG,IAAI,GAAG,SAAS,CAAC,CAAC;QACpE,OAAO,IAAI,CAAC;IAChB,CAAC;CAEJ"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { MigrationProviderInterface } from "./migrationProviderInterface.js";
|
|
2
|
+
export declare class MediumMigrationProvider implements MigrationProviderInterface {
|
|
3
|
+
parser: any;
|
|
4
|
+
storage: any;
|
|
5
|
+
constructor();
|
|
6
|
+
migrate(src: string, dest: string): Promise<boolean>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import fs from "fs-extra";
|
|
2
|
+
import { ConsoleMessage } from "../log.js";
|
|
3
|
+
import { StorageService } from "../storage/storageService.js";
|
|
4
|
+
import { Parser } from "../utils/parser.js";
|
|
5
|
+
export class MediumMigrationProvider {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.parser = new Parser();
|
|
8
|
+
this.storage = new StorageService();
|
|
9
|
+
}
|
|
10
|
+
async migrate(src, dest) {
|
|
11
|
+
new ConsoleMessage().info("Migrating Medium post from " + src + " to " + dest);
|
|
12
|
+
const files = new StorageService().readDir(`${src}/posts`);
|
|
13
|
+
const bodyRegex = /\<body[^>]*\>([^]*)\<\/body/m;
|
|
14
|
+
files.forEach((file) => {
|
|
15
|
+
const slug = file.replace(".html", "");
|
|
16
|
+
const html = fs.readFileSync(`${src}/posts/${file}`, "utf8");
|
|
17
|
+
const [, content] = html.match(bodyRegex) || [];
|
|
18
|
+
const headerMd = this.parser.generateMdHeaders({ slug });
|
|
19
|
+
const bodyMd = this.parser.htmlToMd(content);
|
|
20
|
+
const contentMd = headerMd + bodyMd;
|
|
21
|
+
fs.outputFileSync(`${dest}/${slug}.md`, contentMd);
|
|
22
|
+
});
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=medium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AAQ,CAAC,OAAO,CAAC,CAAC;YAC7C,MAAM,SAAS,GAAG,QAAQ,GAAG,MAAM,CAAC;YACpC,EAAE,CAAC,cAAc,CAAC,GAAG,IAAI,IAAI,IAAI,KAAK,EAAE,SAAS,CAAC,CAAC;QACpD,CAAC,CAAC,CAAA;QAEF,OAAO,IAAI,CAAC;IACb,CAAC;CAED"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrationProviderInterface.js","sourceRoot":"","sources":["../../src/migrate/migrationProviderInterface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { MigrationProviderInterface } from "./migrationProviderInterface.js";
|
|
2
|
+
export declare class WordpressMigrationProvider implements MigrationProviderInterface {
|
|
3
|
+
parser: any;
|
|
4
|
+
storage: any;
|
|
5
|
+
constructor();
|
|
6
|
+
fetchPosts(src: string): Promise<Record<string, any>[]>;
|
|
7
|
+
fetchMedia(src: string, id: string): Promise<any>;
|
|
8
|
+
saveMedia(mediaFetched: any, dest: string): Promise<string | null>;
|
|
9
|
+
fetchCategoriesPerPost(src: string, postId: string): Promise<Record<string, any>[]>;
|
|
10
|
+
fetchTagsPerPost(src: string, postId: string): Promise<Record<string, any>[]>;
|
|
11
|
+
migrate(src: string, dest: string): Promise<boolean>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
import { Parser } from "../utils/parser.js";
|
|
3
|
+
import { StorageService } from "../storage/storageService.js";
|
|
4
|
+
import { ConsoleMessage } from "../log.js";
|
|
5
|
+
export class WordpressMigrationProvider {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.parser = new Parser();
|
|
8
|
+
this.storage = new StorageService();
|
|
9
|
+
}
|
|
10
|
+
async fetchPosts(src) {
|
|
11
|
+
try {
|
|
12
|
+
let posts;
|
|
13
|
+
const response = await axios.get(`${src}/wp-json/wp/v2/posts?page=1`);
|
|
14
|
+
const headers = response.headers;
|
|
15
|
+
const body = typeof response.data == 'string' ? JSON.parse(response.data) : response.data;
|
|
16
|
+
const pages = headers['x-wp-totalpages'];
|
|
17
|
+
posts = [...body];
|
|
18
|
+
for (let i = 2; i <= parseInt(pages); i++) {
|
|
19
|
+
const body = (await axios.get(`${src}/wp-json/wp/v2/posts?page=${i}`)).data;
|
|
20
|
+
posts = posts.concat(body);
|
|
21
|
+
}
|
|
22
|
+
return posts;
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
throw new Error(error.message);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
async fetchMedia(src, id) {
|
|
29
|
+
try {
|
|
30
|
+
return (await axios.get(`${src}/wp-json/wp/v2/media/${id}`)).data;
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
async saveMedia(mediaFetched, dest) {
|
|
37
|
+
try {
|
|
38
|
+
if (!mediaFetched)
|
|
39
|
+
return null;
|
|
40
|
+
const { source_url, slug, mime_type } = mediaFetched;
|
|
41
|
+
const encodedURI = encodeURI(source_url);
|
|
42
|
+
const response = await axios.get(encodedURI, { responseType: 'arraybuffer' });
|
|
43
|
+
const { data: media, headers } = response;
|
|
44
|
+
const mediaBuffer = Buffer.from(media, 'binary').toString('base64');
|
|
45
|
+
const extension = mime_type.split('/')[1];
|
|
46
|
+
const filename = `${slug}.${extension}`;
|
|
47
|
+
await this.storage.set(`${dest}/images/${filename}`, mediaBuffer);
|
|
48
|
+
return `/images/${filename}`;
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
async fetchCategoriesPerPost(src, postId) {
|
|
55
|
+
try {
|
|
56
|
+
return (await axios.get(`${src}/wp-json/wp/v2/categories?post=${postId}`)).data;
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
return [];
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
async fetchTagsPerPost(src, postId) {
|
|
63
|
+
try {
|
|
64
|
+
return (await axios.get(`${src}/wp-json/wp/v2/tags?post=${postId}`)).data;
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
return [];
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
async migrate(src, dest) {
|
|
71
|
+
new ConsoleMessage().info("Migrating WordPress site from " + src + " to " + dest);
|
|
72
|
+
try {
|
|
73
|
+
const posts = await this.fetchPosts(src);
|
|
74
|
+
for (const post of posts) {
|
|
75
|
+
const { id, title, slug, date, content, featured_media } = post;
|
|
76
|
+
// Get post categories
|
|
77
|
+
const categoriesData = await this.fetchCategoriesPerPost(src, id);
|
|
78
|
+
const tagsData = await this.fetchTagsPerPost(src, id);
|
|
79
|
+
const categories = categoriesData.map((category) => category.name);
|
|
80
|
+
const tags = tagsData.map((tag) => tag.name);
|
|
81
|
+
// Markdown header generation
|
|
82
|
+
let mdContent = this.parser.generateMdHeaders({
|
|
83
|
+
title: title.rendered, slug, categories, tags, date
|
|
84
|
+
});
|
|
85
|
+
// Markdown media content
|
|
86
|
+
if (featured_media) {
|
|
87
|
+
const mediaFetched = await this.fetchMedia(src, featured_media);
|
|
88
|
+
const mediaPath = await this.saveMedia(mediaFetched, dest);
|
|
89
|
+
mdContent += `\n\n`;
|
|
90
|
+
}
|
|
91
|
+
// Markdown html content
|
|
92
|
+
mdContent += this.parser.htmlToMd(content.rendered);
|
|
93
|
+
await this.storage.set(`${dest}/${slug}.md`, mdContent);
|
|
94
|
+
}
|
|
95
|
+
new ConsoleMessage().info("Migration was completed successfully");
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
throw new Error('Error while migrating WordPress site: ' + src);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=wordpressMigrationProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
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AAC,CAAC,GAAQ,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;gBAClD,6BAA6B;gBAC7B,IAAI,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC;oBAC1C,KAAK,EAAE,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI;iBACtD,CAAC,CAAC;gBAEH,yBAAyB;gBACzB,IAAG,cAAc,EAAE;oBACf,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;oBAChE,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;oBAC3D,SAAS,IAAI,KAAK,KAAK,CAAC,QAAQ,KAAK,SAAS,OAAO,CAAC;iBACzD;gBAED,wBAAwB;gBACxB,SAAS,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;gBAEpD,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,IAAI,IAAI,KAAK,EAAE,SAAS,CAAC,CAAC;aAC3D;YACD,IAAI,cAAc,EAAE,CAAC,IAAI,CAAC,sCAAsC,CAAC,CAAC;YAClE,OAAO,IAAI,CAAC;SACf;QAAA,OAAO,KAAU,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,wCAAwC,GAAG,GAAG,CAAC,CAAC;SACnE;IACL,CAAC;CAEJ"}
|
package/dist/migrate.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { JekyllMigrationProvider } from "./migrate/jekyllMigrationProvider.js";
|
|
2
|
+
import { WordpressMigrationProvider } from "./migrate/wordpressMigrationProvider.js";
|
|
3
|
+
import { GhostMigrationProvider } from "./migrate/ghostMigrationProvider.js";
|
|
4
|
+
import { MediumMigrationProvider } from "./migrate/mediumMigrationProvider.js";
|
|
5
|
+
export class Migrate {
|
|
6
|
+
constructor(provider) {
|
|
7
|
+
switch (provider) {
|
|
8
|
+
case "jekyll":
|
|
9
|
+
this.provider = new JekyllMigrationProvider();
|
|
10
|
+
break;
|
|
11
|
+
case "wordpress":
|
|
12
|
+
this.provider = new WordpressMigrationProvider();
|
|
13
|
+
break;
|
|
14
|
+
case "ghost":
|
|
15
|
+
this.provider = new GhostMigrationProvider();
|
|
16
|
+
break;
|
|
17
|
+
case "medium":
|
|
18
|
+
this.provider = new MediumMigrationProvider();
|
|
19
|
+
break;
|
|
20
|
+
default:
|
|
21
|
+
throw new Error("Unknown migration provider: " + provider);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
async migrate(src, dest) {
|
|
25
|
+
if (!src || !dest) {
|
|
26
|
+
throw new Error("Source and destination must be specified");
|
|
27
|
+
}
|
|
28
|
+
await this.getProvider().migrate(src, dest);
|
|
29
|
+
}
|
|
30
|
+
getProvider() {
|
|
31
|
+
return this.provider;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=migrate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate.js","sourceRoot":"","sources":["../src/migrate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,uBAAuB,EAAC,MAAM,sCAAsC,CAAC;AAC7E,OAAO,EAAC,0BAA0B,EAAC,MAAM,yCAAyC,CAAC;AACnF,OAAO,EAAC,sBAAsB,EAAC,MAAM,qCAAqC,CAAC;AAC3E,OAAO,EAAC,uBAAuB,EAAC,MAAM,sCAAsC,CAAC;AAE7E,MAAM,OAAO,OAAO;IAGhB,YAAY,QAAgB;QACxB,QAAQ,QAAQ,EAAE;YACd,KAAK,QAAQ;gBACT,IAAI,CAAC,QAAQ,GAAG,IAAI,uBAAuB,EAAE,CAAC;gBAC9C,MAAM;YACV,KAAK,WAAW;gBACZ,IAAI,CAAC,QAAQ,GAAG,IAAI,0BAA0B,EAAE,CAAC;gBACjD,MAAM;YACV,KAAK,OAAO;gBACR,IAAI,CAAC,QAAQ,GAAG,IAAI,sBAAsB,EAAE,CAAC;gBAC7C,MAAM;YACV,KAAK,QAAQ;gBACT,IAAI,CAAC,QAAQ,GAAG,IAAI,uBAAuB,EAAE,CAAC;gBAC9C,MAAM;YACV;gBACI,MAAM,IAAI,KAAK,CAAC,8BAA8B,GAAG,QAAQ,CAAC,CAAC;SAClE;IACL,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,GAAW,EAAE,IAAY;QACnC,IAAG,CAAC,GAAG,IAAI,CAAC,IAAI,EAAE;YACd,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;SAC/D;QACD,MAAM,IAAI,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IAChD,CAAC;IAED,WAAW;QACP,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;CAEJ"}
|
package/dist/post.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export declare class Post {
|
|
2
|
+
keywords: Array<string>;
|
|
3
|
+
tags: Array<string>;
|
|
4
|
+
content: string;
|
|
5
|
+
private _matter;
|
|
6
|
+
permalink_default: string;
|
|
7
|
+
permalink_date: string;
|
|
8
|
+
permalink_ordinal: string;
|
|
9
|
+
constructor();
|
|
10
|
+
get id(): string;
|
|
11
|
+
get date(): Date;
|
|
12
|
+
get title(): string;
|
|
13
|
+
set title(val: string);
|
|
14
|
+
get author(): string;
|
|
15
|
+
set author(val: string);
|
|
16
|
+
get url(): string;
|
|
17
|
+
set url(val: string);
|
|
18
|
+
get matter(): any;
|
|
19
|
+
set matter(val: any);
|
|
20
|
+
getBody(): Promise<any>;
|
|
21
|
+
get published(): boolean;
|
|
22
|
+
set published(val: boolean);
|
|
23
|
+
getDescription(): Promise<any>;
|
|
24
|
+
getSummary(): Promise<any>;
|
|
25
|
+
addTag(name: string): void;
|
|
26
|
+
addTags(names: Array<string>): void;
|
|
27
|
+
generateUrl(): void;
|
|
28
|
+
parseUrl(url: string): string;
|
|
29
|
+
toObject(): Promise<any>;
|
|
30
|
+
static create(obj: any): Post;
|
|
31
|
+
}
|