mirror of
https://github.com/docmost/docmost.git
synced 2026-05-19 07:54:05 +08:00
add docmost app version
This commit is contained in:
@@ -7,8 +7,8 @@ export type ExportPageMetadata = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export type ExportMetadata = {
|
export type ExportMetadata = {
|
||||||
version: number;
|
|
||||||
exportedAt: string;
|
exportedAt: string;
|
||||||
source: 'docmost';
|
source: 'docmost';
|
||||||
|
version: string;
|
||||||
pages: Record<string, ExportPageMetadata>;
|
pages: Record<string, ExportPageMetadata>;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -29,6 +29,8 @@ import { Node } from '@tiptap/pm/model';
|
|||||||
import { EditorState } from '@tiptap/pm/state';
|
import { EditorState } from '@tiptap/pm/state';
|
||||||
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
||||||
import slugify = require('@sindresorhus/slugify');
|
import slugify = require('@sindresorhus/slugify');
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
||||||
|
const packageJson = require('../../../package.json');
|
||||||
import { EnvironmentService } from '../environment/environment.service';
|
import { EnvironmentService } from '../environment/environment.service';
|
||||||
import {
|
import {
|
||||||
getAttachmentIds,
|
getAttachmentIds,
|
||||||
@@ -261,9 +263,9 @@ export class ExportService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const metadata: ExportMetadata = {
|
const metadata: ExportMetadata = {
|
||||||
version: 1,
|
|
||||||
exportedAt: new Date().toISOString(),
|
exportedAt: new Date().toISOString(),
|
||||||
source: 'docmost',
|
source: 'docmost',
|
||||||
|
version: packageJson.version,
|
||||||
pages: pagesMetadata,
|
pages: pagesMetadata,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -98,11 +98,7 @@ export async function readDocmostMetadata(
|
|||||||
try {
|
try {
|
||||||
const content = await fs.readFile(metadataPath, 'utf-8');
|
const content = await fs.readFile(metadataPath, 'utf-8');
|
||||||
const metadata = JSON.parse(content) as ExportMetadata;
|
const metadata = JSON.parse(content) as ExportMetadata;
|
||||||
if (
|
if (metadata.source === 'docmost' && metadata.pages) {
|
||||||
metadata.source === 'docmost' &&
|
|
||||||
metadata.version === 1 &&
|
|
||||||
metadata.pages
|
|
||||||
) {
|
|
||||||
return metadata;
|
return metadata;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
Reference in New Issue
Block a user