chore: Remove 16+ unused dependencies (#4910)
* chore: Remove no-longer used webpack loaders * chore: Remove migration of markdown from Slate documents (2y old) * chore: Remove more unused deps * chore: Remove explicit core-js dep * Remove more unused dependencies * test
This commit is contained in:
@@ -37,131 +37,6 @@ paragraph 2`,
|
||||
});
|
||||
});
|
||||
|
||||
describe("#migrateVersion", () => {
|
||||
test("should maintain empty paragraph under headings", async () => {
|
||||
const document = await buildDocument({
|
||||
version: 1,
|
||||
text: `# Heading
|
||||
|
||||
paragraph`,
|
||||
});
|
||||
await document.migrateVersion();
|
||||
expect(document.text).toBe(`# Heading
|
||||
|
||||
paragraph`);
|
||||
});
|
||||
|
||||
test("should add breaks under headings with extra paragraphs", async () => {
|
||||
const document = await buildDocument({
|
||||
version: 1,
|
||||
text: `# Heading
|
||||
|
||||
|
||||
paragraph`,
|
||||
});
|
||||
await document.migrateVersion();
|
||||
expect(document.text).toBe(`# Heading
|
||||
|
||||
|
||||
\\
|
||||
paragraph`);
|
||||
});
|
||||
|
||||
test("should add breaks between paragraphs", async () => {
|
||||
const document = await buildDocument({
|
||||
version: 1,
|
||||
text: `paragraph
|
||||
|
||||
paragraph`,
|
||||
});
|
||||
await document.migrateVersion();
|
||||
expect(document.text).toBe(`paragraph
|
||||
|
||||
\\
|
||||
paragraph`);
|
||||
});
|
||||
|
||||
test("should add breaks for multiple empty paragraphs", async () => {
|
||||
const document = await buildDocument({
|
||||
version: 1,
|
||||
text: `paragraph
|
||||
|
||||
|
||||
paragraph`,
|
||||
});
|
||||
await document.migrateVersion();
|
||||
expect(document.text).toBe(`paragraph
|
||||
|
||||
\\
|
||||
\\
|
||||
paragraph`);
|
||||
});
|
||||
|
||||
test("should add breaks with non-latin characters", async () => {
|
||||
const document = await buildDocument({
|
||||
version: 1,
|
||||
text: `除。
|
||||
|
||||
通`,
|
||||
});
|
||||
await document.migrateVersion();
|
||||
expect(document.text).toBe(`除。
|
||||
|
||||
\\
|
||||
通`);
|
||||
});
|
||||
|
||||
test("should update task list formatting", async () => {
|
||||
const document = await buildDocument({
|
||||
version: 1,
|
||||
text: `[ ] list item
|
||||
`,
|
||||
});
|
||||
await document.migrateVersion();
|
||||
expect(document.text).toBe(`- [ ] list item
|
||||
`);
|
||||
});
|
||||
|
||||
test("should update task list with multiple items", async () => {
|
||||
const document = await buildDocument({
|
||||
version: 1,
|
||||
text: `[ ] list item
|
||||
[ ] list item 2
|
||||
`,
|
||||
});
|
||||
await document.migrateVersion();
|
||||
expect(document.text).toBe(`- [ ] list item
|
||||
- [ ] list item 2
|
||||
`);
|
||||
});
|
||||
|
||||
test("should update checked task list formatting", async () => {
|
||||
const document = await buildDocument({
|
||||
version: 1,
|
||||
text: `[x] list item
|
||||
`,
|
||||
});
|
||||
await document.migrateVersion();
|
||||
expect(document.text).toBe(`- [x] list item
|
||||
`);
|
||||
});
|
||||
|
||||
test("should update nested task list formatting", async () => {
|
||||
const document = await buildDocument({
|
||||
version: 1,
|
||||
text: `[x] list item
|
||||
[ ] list item
|
||||
[x] list item
|
||||
`,
|
||||
});
|
||||
await document.migrateVersion();
|
||||
expect(document.text).toBe(`- [x] list item
|
||||
- [ ] list item
|
||||
- [x] list item
|
||||
`);
|
||||
});
|
||||
});
|
||||
|
||||
describe("#delete", () => {
|
||||
test("should soft delete and set last modified", async () => {
|
||||
const document = await buildDocument();
|
||||
|
||||
@@ -29,7 +29,6 @@ import {
|
||||
IsNumeric,
|
||||
IsDate,
|
||||
} from "sequelize-typescript";
|
||||
import MarkdownSerializer from "slate-md-serializer";
|
||||
import isUUID from "validator/lib/isUUID";
|
||||
import type { NavigationNode } from "@shared/types";
|
||||
import getTasks from "@shared/utils/getTasks";
|
||||
@@ -50,8 +49,6 @@ import Fix from "./decorators/Fix";
|
||||
import DocumentHelper from "./helpers/DocumentHelper";
|
||||
import Length from "./validators/Length";
|
||||
|
||||
const serializer = new MarkdownSerializer();
|
||||
|
||||
export const DOCUMENT_VERSION = 2;
|
||||
|
||||
@DefaultScope(() => ({
|
||||
@@ -470,37 +467,6 @@ class Document extends ParanoidModel {
|
||||
|
||||
// instance methods
|
||||
|
||||
migrateVersion = () => {
|
||||
let migrated = false;
|
||||
|
||||
// migrate from document version 0 -> 1
|
||||
if (!this.version) {
|
||||
// removing the title from the document text attribute
|
||||
this.text = this.text.replace(/^#\s(.*)\n/, "");
|
||||
this.version = 1;
|
||||
migrated = true;
|
||||
}
|
||||
|
||||
// migrate from document version 1 -> 2
|
||||
if (this.version === 1) {
|
||||
const nodes = serializer.deserialize(this.text);
|
||||
this.text = serializer.serialize(nodes, {
|
||||
version: 2,
|
||||
});
|
||||
this.version = 2;
|
||||
migrated = true;
|
||||
}
|
||||
|
||||
if (migrated) {
|
||||
return this.save({
|
||||
silent: true,
|
||||
hooks: false,
|
||||
});
|
||||
}
|
||||
|
||||
return undefined;
|
||||
};
|
||||
|
||||
get titleWithDefault(): string {
|
||||
return this.title || "Untitled";
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import {
|
||||
IsNumeric,
|
||||
Length as SimpleLength,
|
||||
} from "sequelize-typescript";
|
||||
import MarkdownSerializer from "slate-md-serializer";
|
||||
import { DocumentValidation } from "@shared/validations";
|
||||
import Document from "./Document";
|
||||
import User from "./User";
|
||||
@@ -17,8 +16,6 @@ import IdModel from "./base/IdModel";
|
||||
import Fix from "./decorators/Fix";
|
||||
import Length from "./validators/Length";
|
||||
|
||||
const serializer = new MarkdownSerializer();
|
||||
|
||||
@DefaultScope(() => ({
|
||||
include: [
|
||||
{
|
||||
@@ -110,35 +107,6 @@ class Revision extends IdModel {
|
||||
order: [["createdAt", "DESC"]],
|
||||
});
|
||||
}
|
||||
|
||||
migrateVersion = function () {
|
||||
let migrated = false;
|
||||
|
||||
// migrate from document version 0 -> 1
|
||||
if (!this.version) {
|
||||
// removing the title from the document text attribute
|
||||
this.text = this.text.replace(/^#\s(.*)\n/, "");
|
||||
this.version = 1;
|
||||
migrated = true;
|
||||
}
|
||||
|
||||
// migrate from document version 1 -> 2
|
||||
if (this.version === 1) {
|
||||
const nodes = serializer.deserialize(this.text);
|
||||
this.text = serializer.serialize(nodes, {
|
||||
version: 2,
|
||||
});
|
||||
this.version = 2;
|
||||
migrated = true;
|
||||
}
|
||||
|
||||
if (migrated) {
|
||||
return this.save({
|
||||
silent: true,
|
||||
hooks: false,
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export default Revision;
|
||||
|
||||
Reference in New Issue
Block a user