core: download prismjs languages before tests

This commit is contained in:
Abdullah Atta
2023-08-12 20:33:01 +05:00
committed by Abdullah Atta
parent 44e4722de2
commit e4c8e7a0c5
11 changed files with 397 additions and 114 deletions

View File

@@ -95,4 +95,6 @@ public/
# DynamoDB Local files # DynamoDB Local files
.dynamodb/ .dynamodb/
# End of https://www.gitignore.io/api/node # End of https://www.gitignore.io/api/node
languages

View File

@@ -1,5 +1,3 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
exports[`get offer code > offer-code 1`] = `"123"`; exports[`get offer code > offer-code 1`] = `"123"`;
exports[`get offer code: offer-code 1`] = `"123"`;

View File

@@ -18,24 +18,6 @@ exports[`get android pricing tier > get yearly android tier > yearly-android-pri
} }
`; `;
exports[`get android pricing tier get monthly android tier: monthly-android-pricing 1`] = `
Object {
"country": Any<String>,
"countryCode": Any<String>,
"discount": Any<Number>,
"sku": Any<String>,
}
`;
exports[`get android pricing tier get yearly android tier: yearly-android-pricing 1`] = `
Object {
"country": Any<String>,
"countryCode": Any<String>,
"discount": Any<Number>,
"sku": Any<String>,
}
`;
exports[`get ios pricing tier > get monthly ios tier > monthly-ios-pricing 1`] = ` exports[`get ios pricing tier > get monthly ios tier > monthly-ios-pricing 1`] = `
{ {
"country": Any<String>, "country": Any<String>,
@@ -54,24 +36,6 @@ exports[`get ios pricing tier > get yearly ios tier > yearly-ios-pricing 1`] = `
} }
`; `;
exports[`get ios pricing tier get monthly ios tier: monthly-ios-pricing 1`] = `
Object {
"country": Any<String>,
"countryCode": Any<String>,
"discount": Any<Number>,
"sku": Any<String>,
}
`;
exports[`get ios pricing tier get yearly ios tier: yearly-ios-pricing 1`] = `
Object {
"country": Any<String>,
"countryCode": Any<String>,
"discount": Any<Number>,
"sku": Any<String>,
}
`;
exports[`get monthly price > monthly-pricing 1`] = ` exports[`get monthly price > monthly-pricing 1`] = `
{ {
"country": Any<String>, "country": Any<String>,
@@ -81,15 +45,6 @@ exports[`get monthly price > monthly-pricing 1`] = `
} }
`; `;
exports[`get monthly price: monthly-pricing 1`] = `
Object {
"country": Any<String>,
"countryCode": Any<String>,
"discount": Any<Number>,
"price": Any<Number>,
}
`;
exports[`get undefined price > monthly-pricing 1`] = ` exports[`get undefined price > monthly-pricing 1`] = `
{ {
"country": Any<String>, "country": Any<String>,
@@ -99,15 +54,6 @@ exports[`get undefined price > monthly-pricing 1`] = `
} }
`; `;
exports[`get undefined price: monthly-pricing 1`] = `
Object {
"country": Any<String>,
"countryCode": Any<String>,
"discount": Any<Number>,
"price": Any<Number>,
}
`;
exports[`get web pricing tier > get monthly web tier > monthly-web-pricing 1`] = ` exports[`get web pricing tier > get monthly web tier > monthly-web-pricing 1`] = `
{ {
"country": Any<String>, "country": Any<String>,
@@ -126,24 +72,6 @@ exports[`get web pricing tier > get yearly web tier > yearly-web-pricing 1`] = `
} }
`; `;
exports[`get web pricing tier get monthly web tier: monthly-web-pricing 1`] = `
Object {
"country": Any<String>,
"countryCode": Any<String>,
"discount": Any<Number>,
"sku": Any<String>,
}
`;
exports[`get web pricing tier get yearly web tier: yearly-web-pricing 1`] = `
Object {
"country": Any<String>,
"countryCode": Any<String>,
"discount": Any<Number>,
"sku": Any<String>,
}
`;
exports[`get yearly price > yearly-pricing 1`] = ` exports[`get yearly price > yearly-pricing 1`] = `
{ {
"country": Any<String>, "country": Any<String>,
@@ -152,12 +80,3 @@ exports[`get yearly price > yearly-pricing 1`] = `
"price": Any<Number>, "price": Any<Number>,
} }
`; `;
exports[`get yearly price: yearly-pricing 1`] = `
Object {
"country": Any<String>,
"countryCode": Any<String>,
"discount": Any<Number>,
"price": Any<Number>,
}
`;

View File

@@ -21,7 +21,7 @@ import { databaseTest, noteTest, StorageInterface } from "../__tests__/utils";
import { login } from "./utils"; import { login } from "./utils";
import { test, expect, beforeEach, afterAll } from "vitest"; import { test, expect, beforeEach, afterAll } from "vitest";
const TEST_TIMEOUT = 15 * 1000; const TEST_TIMEOUT = 30 * 1000;
beforeEach(() => { beforeEach(() => {
StorageInterface.clear(); StorageInterface.clear();
@@ -36,7 +36,7 @@ afterAll(async () => {
} }
StorageInterface.clear(); StorageInterface.clear();
}); }, TEST_TIMEOUT);
// test("get monographs", () => // test("get monographs", () =>
// databaseTest().then(async (db) => { // databaseTest().then(async (db) => {

View File

@@ -25,7 +25,6 @@ export const user = {
hashed: process.env.USER_HASHED_PASSWORD, hashed: process.env.USER_HASHED_PASSWORD,
totpSecret: process.env.USER_TOTP_SECRET totpSecret: process.env.USER_TOTP_SECRET
}; };
console.log(user);
export async function login(db) { export async function login(db) {
await db.user.authenticateEmail(user.email); await db.user.authenticateEmail(user.email);

View File

@@ -16,7 +16,7 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
import { afterAll } from "vitest";
import crypto from "crypto"; import crypto from "crypto";
import dotenv from "dotenv"; import dotenv from "dotenv";
import fetch from "node-fetch"; import fetch from "node-fetch";
@@ -25,8 +25,3 @@ globalThis.fetch = fetch;
require("abortcontroller-polyfill/dist/polyfill-patch-fetch"); require("abortcontroller-polyfill/dist/polyfill-patch-fetch");
globalThis.crypto = crypto; globalThis.crypto = crypto;
dotenv.config(); dotenv.config();
afterAll(() => {
globalThis.crypto = null;
globalThis.fetch = null;
});

View File

@@ -40,6 +40,7 @@
"happy-dom": "^10.9.0", "happy-dom": "^10.9.0",
"mockdate": "^3.0.5", "mockdate": "^3.0.5",
"otplib": "^12.0.1", "otplib": "^12.0.1",
"refractor": "^4.8.1",
"vitest": "^0.34.1", "vitest": "^0.34.1",
"vitest-fetch-mock": "^0.2.2" "vitest-fetch-mock": "^0.2.2"
} }
@@ -554,6 +555,15 @@
"@types/chai": "*" "@types/chai": "*"
} }
}, },
"node_modules/@types/hast": {
"version": "2.3.5",
"resolved": "https://registry.npmjs.org/@types/hast/-/hast-2.3.5.tgz",
"integrity": "sha512-SvQi0L/lNpThgPoleH53cdjB3y9zpLlVjRbqB3rH8hx1jiRSBGAhyjV3H+URFjNVRqt2EdYNrbZE5IsGlNfpRg==",
"dev": true,
"dependencies": {
"@types/unist": "^2"
}
},
"node_modules/@types/html-to-text": { "node_modules/@types/html-to-text": {
"version": "9.0.0", "version": "9.0.0",
"resolved": "https://registry.npmjs.org/@types/html-to-text/-/html-to-text-9.0.0.tgz", "resolved": "https://registry.npmjs.org/@types/html-to-text/-/html-to-text-9.0.0.tgz",
@@ -608,6 +618,12 @@
"integrity": "sha512-70xBJoLv+oXjB5PhtA8vo7erjLDp9/qqI63SRHm4REKrwuPOLs8HhXwlZJBJaB4kC18cCZ1UUZ6Fb/PLFW4TCA==", "integrity": "sha512-70xBJoLv+oXjB5PhtA8vo7erjLDp9/qqI63SRHm4REKrwuPOLs8HhXwlZJBJaB4kC18cCZ1UUZ6Fb/PLFW4TCA==",
"dev": true "dev": true
}, },
"node_modules/@types/unist": {
"version": "2.0.7",
"resolved": "https://registry.npmjs.org/@types/unist/-/unist-2.0.7.tgz",
"integrity": "sha512-cputDpIbFgLUaGQn6Vqg3/YsJwxUwHLO13v3i5ouxT4lat0khip9AEWxtERujXV9wxIB1EyF97BSJFt6vpdI8g==",
"dev": true
},
"node_modules/@vitest/expect": { "node_modules/@vitest/expect": {
"version": "0.34.1", "version": "0.34.1",
"resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-0.34.1.tgz", "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-0.34.1.tgz",
@@ -927,6 +943,36 @@
"node": ">=4" "node": ">=4"
} }
}, },
"node_modules/character-entities": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/character-entities/-/character-entities-2.0.2.tgz",
"integrity": "sha512-shx7oQ0Awen/BRIdkjkvz54PnEEI/EjwXDSIZp86/KKdbafHh1Df/RYGBhn4hbe2+uKC9FnT5UCEdyPz3ai9hQ==",
"dev": true,
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/character-entities-legacy": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/character-entities-legacy/-/character-entities-legacy-3.0.0.tgz",
"integrity": "sha512-RpPp0asT/6ufRm//AJVwpViZbGM/MkjQFxJccQRHmISF/22NBtsHqAWmL+/pmkPWoIUJdWyeVleTl1wydHATVQ==",
"dev": true,
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/character-reference-invalid": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/character-reference-invalid/-/character-reference-invalid-2.0.1.tgz",
"integrity": "sha512-iBZ4F4wRbyORVsu0jPV7gXkOsGYjGHPmAyv+HiHG8gi5PtC9KI2j1+v8/tlibRvjoWX027ypmG/n0HtO5t7unw==",
"dev": true,
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/check-error": { "node_modules/check-error": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz",
@@ -948,6 +994,16 @@
"node": ">= 0.8" "node": ">= 0.8"
} }
}, },
"node_modules/comma-separated-tokens": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/comma-separated-tokens/-/comma-separated-tokens-2.0.3.tgz",
"integrity": "sha512-Fu4hJdvzeylCfQPp9SGWidpzrMs7tTrlu6Vb8XGaRGck8QSNZJJp538Wrb60Lax4fPwR64ViY468OIUTbRlGZg==",
"dev": true,
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/cross-env": { "node_modules/cross-env": {
"version": "7.0.3", "version": "7.0.3",
"resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz", "resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz",
@@ -1094,6 +1150,19 @@
"optional": true, "optional": true,
"peer": true "peer": true
}, },
"node_modules/decode-named-character-reference": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/decode-named-character-reference/-/decode-named-character-reference-1.0.2.tgz",
"integrity": "sha512-O8x12RzrUF8xyVcY0KJowWsmaJxQbmy0/EtnNtHRpsOcT7dFk5W598coHqBVpmWo1oQQfsCqfCmkZN5DJrZVdg==",
"dev": true,
"dependencies": {
"character-entities": "^2.0.0"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/deep-eql": { "node_modules/deep-eql": {
"version": "4.1.3", "version": "4.1.3",
"resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-4.1.3.tgz", "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-4.1.3.tgz",
@@ -1419,6 +1488,36 @@
"whatwg-mimetype": "^3.0.0" "whatwg-mimetype": "^3.0.0"
} }
}, },
"node_modules/hast-util-parse-selector": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/hast-util-parse-selector/-/hast-util-parse-selector-3.1.1.tgz",
"integrity": "sha512-jdlwBjEexy1oGz0aJ2f4GKMaVKkA9jwjr4MjAAI22E5fM/TXVZHuS5OpONtdeIkRKqAaryQ2E9xNQxijoThSZA==",
"dev": true,
"dependencies": {
"@types/hast": "^2.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/hastscript": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/hastscript/-/hastscript-7.2.0.tgz",
"integrity": "sha512-TtYPq24IldU8iKoJQqvZOuhi5CyCQRAbvDOX0x1eW6rsHSxa/1i2CCiptNTotGHJ3VoHRGmqiv6/D3q113ikkw==",
"dev": true,
"dependencies": {
"@types/hast": "^2.0.0",
"comma-separated-tokens": "^2.0.0",
"hast-util-parse-selector": "^3.0.0",
"property-information": "^6.0.0",
"space-separated-tokens": "^2.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
}
},
"node_modules/html-encoding-sniffer": { "node_modules/html-encoding-sniffer": {
"version": "3.0.0", "version": "3.0.0",
"resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-3.0.0.tgz", "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-3.0.0.tgz",
@@ -1509,6 +1608,50 @@
"node": ">=0.10.0" "node": ">=0.10.0"
} }
}, },
"node_modules/is-alphabetical": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/is-alphabetical/-/is-alphabetical-2.0.1.tgz",
"integrity": "sha512-FWyyY60MeTNyeSRpkM2Iry0G9hpr7/9kD40mD/cGQEuilcZYS4okz8SN2Q6rLCJ8gbCt6fN+rC+6tMGS99LaxQ==",
"dev": true,
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/is-alphanumerical": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/is-alphanumerical/-/is-alphanumerical-2.0.1.tgz",
"integrity": "sha512-hmbYhX/9MUMF5uh7tOXyK/n0ZvWpad5caBA17GsC6vyuCqaWliRG5K1qS9inmUhEMaOBIW7/whAnSwveW/LtZw==",
"dev": true,
"dependencies": {
"is-alphabetical": "^2.0.0",
"is-decimal": "^2.0.0"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/is-decimal": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/is-decimal/-/is-decimal-2.0.1.tgz",
"integrity": "sha512-AAB9hiomQs5DXWcRB1rqsxGUstbRroFOPPVAomNk/3XHR5JyEZChOyTWe2oayKnsSsr/kcGqF+z6yuH6HHpN0A==",
"dev": true,
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/is-hexadecimal": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/is-hexadecimal/-/is-hexadecimal-2.0.1.tgz",
"integrity": "sha512-DgZQp241c8oO6cA1SbTEWiXeoxV42vlcJxgH+B3hi1AiqqKruZR3ZGF8In3fj4+/y/7rHvlOZLZtgJ/4ttYGZg==",
"dev": true,
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/is-potential-custom-element-name": { "node_modules/is-potential-custom-element-name": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz", "resolved": "https://registry.npmjs.org/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz",
@@ -1893,6 +2036,26 @@
"@otplib/preset-v11": "^12.0.1" "@otplib/preset-v11": "^12.0.1"
} }
}, },
"node_modules/parse-entities": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/parse-entities/-/parse-entities-4.0.1.tgz",
"integrity": "sha512-SWzvYcSJh4d/SGLIOQfZ/CoNv6BTlI6YEQ7Nj82oDVnRpwe/Z/F1EMx42x3JAOwGBlCjeCH0BRJQbQ/opHL17w==",
"dev": true,
"dependencies": {
"@types/unist": "^2.0.0",
"character-entities": "^2.0.0",
"character-entities-legacy": "^3.0.0",
"character-reference-invalid": "^2.0.0",
"decode-named-character-reference": "^1.0.0",
"is-alphanumerical": "^2.0.0",
"is-decimal": "^2.0.0",
"is-hexadecimal": "^2.0.0"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/parse5": { "node_modules/parse5": {
"version": "7.1.2", "version": "7.1.2",
"resolved": "https://registry.npmjs.org/parse5/-/parse5-7.1.2.tgz", "resolved": "https://registry.npmjs.org/parse5/-/parse5-7.1.2.tgz",
@@ -2015,6 +2178,16 @@
"node": ">=6" "node": ">=6"
} }
}, },
"node_modules/property-information": {
"version": "6.2.0",
"resolved": "https://registry.npmjs.org/property-information/-/property-information-6.2.0.tgz",
"integrity": "sha512-kma4U7AFCTwpqq5twzC1YVIDXSqg6qQK6JN0smOw8fgRy1OkMi0CYSzFmsy6dnqSenamAtj0CyXMUJ1Mf6oROg==",
"dev": true,
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/psl": { "node_modules/psl": {
"version": "1.9.0", "version": "1.9.0",
"resolved": "https://registry.npmjs.org/psl/-/psl-1.9.0.tgz", "resolved": "https://registry.npmjs.org/psl/-/psl-1.9.0.tgz",
@@ -2061,6 +2234,22 @@
"integrity": "sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==", "integrity": "sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==",
"dev": true "dev": true
}, },
"node_modules/refractor": {
"version": "4.8.1",
"resolved": "https://registry.npmjs.org/refractor/-/refractor-4.8.1.tgz",
"integrity": "sha512-/fk5sI0iTgFYlmVGYVew90AoYnNMP6pooClx/XKqyeeCQXrL0Kvgn8V0VEht5ccdljbzzF1i3Q213gcntkRExg==",
"dev": true,
"dependencies": {
"@types/hast": "^2.0.0",
"@types/prismjs": "^1.0.0",
"hastscript": "^7.0.0",
"parse-entities": "^4.0.0"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/requires-port": { "node_modules/requires-port": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz",
@@ -2157,6 +2346,16 @@
"node": ">=0.10.0" "node": ">=0.10.0"
} }
}, },
"node_modules/space-separated-tokens": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/space-separated-tokens/-/space-separated-tokens-2.0.2.tgz",
"integrity": "sha512-PEGlAwrG8yXGXRjW32fGbg66JAlOAwbObuqVoJpv/mRgoWDQfgH1wDPvtzWyUSNAXBGSk8h755YDbbcEy3SH2Q==",
"dev": true,
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
}
},
"node_modules/spark-md5": { "node_modules/spark-md5": {
"version": "3.0.2", "version": "3.0.2",
"resolved": "https://registry.npmjs.org/spark-md5/-/spark-md5-3.0.2.tgz", "resolved": "https://registry.npmjs.org/spark-md5/-/spark-md5-3.0.2.tgz",
@@ -2908,6 +3107,15 @@
"@types/chai": "*" "@types/chai": "*"
} }
}, },
"@types/hast": {
"version": "2.3.5",
"resolved": "https://registry.npmjs.org/@types/hast/-/hast-2.3.5.tgz",
"integrity": "sha512-SvQi0L/lNpThgPoleH53cdjB3y9zpLlVjRbqB3rH8hx1jiRSBGAhyjV3H+URFjNVRqt2EdYNrbZE5IsGlNfpRg==",
"dev": true,
"requires": {
"@types/unist": "^2"
}
},
"@types/html-to-text": { "@types/html-to-text": {
"version": "9.0.0", "version": "9.0.0",
"resolved": "https://registry.npmjs.org/@types/html-to-text/-/html-to-text-9.0.0.tgz", "resolved": "https://registry.npmjs.org/@types/html-to-text/-/html-to-text-9.0.0.tgz",
@@ -2961,6 +3169,12 @@
"integrity": "sha512-70xBJoLv+oXjB5PhtA8vo7erjLDp9/qqI63SRHm4REKrwuPOLs8HhXwlZJBJaB4kC18cCZ1UUZ6Fb/PLFW4TCA==", "integrity": "sha512-70xBJoLv+oXjB5PhtA8vo7erjLDp9/qqI63SRHm4REKrwuPOLs8HhXwlZJBJaB4kC18cCZ1UUZ6Fb/PLFW4TCA==",
"dev": true "dev": true
}, },
"@types/unist": {
"version": "2.0.7",
"resolved": "https://registry.npmjs.org/@types/unist/-/unist-2.0.7.tgz",
"integrity": "sha512-cputDpIbFgLUaGQn6Vqg3/YsJwxUwHLO13v3i5ouxT4lat0khip9AEWxtERujXV9wxIB1EyF97BSJFt6vpdI8g==",
"dev": true
},
"@vitest/expect": { "@vitest/expect": {
"version": "0.34.1", "version": "0.34.1",
"resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-0.34.1.tgz", "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-0.34.1.tgz",
@@ -3208,6 +3422,24 @@
"type-detect": "^4.0.5" "type-detect": "^4.0.5"
} }
}, },
"character-entities": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/character-entities/-/character-entities-2.0.2.tgz",
"integrity": "sha512-shx7oQ0Awen/BRIdkjkvz54PnEEI/EjwXDSIZp86/KKdbafHh1Df/RYGBhn4hbe2+uKC9FnT5UCEdyPz3ai9hQ==",
"dev": true
},
"character-entities-legacy": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/character-entities-legacy/-/character-entities-legacy-3.0.0.tgz",
"integrity": "sha512-RpPp0asT/6ufRm//AJVwpViZbGM/MkjQFxJccQRHmISF/22NBtsHqAWmL+/pmkPWoIUJdWyeVleTl1wydHATVQ==",
"dev": true
},
"character-reference-invalid": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/character-reference-invalid/-/character-reference-invalid-2.0.1.tgz",
"integrity": "sha512-iBZ4F4wRbyORVsu0jPV7gXkOsGYjGHPmAyv+HiHG8gi5PtC9KI2j1+v8/tlibRvjoWX027ypmG/n0HtO5t7unw==",
"dev": true
},
"check-error": { "check-error": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz",
@@ -3223,6 +3455,12 @@
"delayed-stream": "~1.0.0" "delayed-stream": "~1.0.0"
} }
}, },
"comma-separated-tokens": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/comma-separated-tokens/-/comma-separated-tokens-2.0.3.tgz",
"integrity": "sha512-Fu4hJdvzeylCfQPp9SGWidpzrMs7tTrlu6Vb8XGaRGck8QSNZJJp538Wrb60Lax4fPwR64ViY468OIUTbRlGZg==",
"dev": true
},
"cross-env": { "cross-env": {
"version": "7.0.3", "version": "7.0.3",
"resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz", "resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz",
@@ -3336,6 +3574,15 @@
"optional": true, "optional": true,
"peer": true "peer": true
}, },
"decode-named-character-reference": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/decode-named-character-reference/-/decode-named-character-reference-1.0.2.tgz",
"integrity": "sha512-O8x12RzrUF8xyVcY0KJowWsmaJxQbmy0/EtnNtHRpsOcT7dFk5W598coHqBVpmWo1oQQfsCqfCmkZN5DJrZVdg==",
"dev": true,
"requires": {
"character-entities": "^2.0.0"
}
},
"deep-eql": { "deep-eql": {
"version": "4.1.3", "version": "4.1.3",
"resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-4.1.3.tgz", "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-4.1.3.tgz",
@@ -3570,6 +3817,28 @@
"whatwg-mimetype": "^3.0.0" "whatwg-mimetype": "^3.0.0"
} }
}, },
"hast-util-parse-selector": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/hast-util-parse-selector/-/hast-util-parse-selector-3.1.1.tgz",
"integrity": "sha512-jdlwBjEexy1oGz0aJ2f4GKMaVKkA9jwjr4MjAAI22E5fM/TXVZHuS5OpONtdeIkRKqAaryQ2E9xNQxijoThSZA==",
"dev": true,
"requires": {
"@types/hast": "^2.0.0"
}
},
"hastscript": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/hastscript/-/hastscript-7.2.0.tgz",
"integrity": "sha512-TtYPq24IldU8iKoJQqvZOuhi5CyCQRAbvDOX0x1eW6rsHSxa/1i2CCiptNTotGHJ3VoHRGmqiv6/D3q113ikkw==",
"dev": true,
"requires": {
"@types/hast": "^2.0.0",
"comma-separated-tokens": "^2.0.0",
"hast-util-parse-selector": "^3.0.0",
"property-information": "^6.0.0",
"space-separated-tokens": "^2.0.0"
}
},
"html-encoding-sniffer": { "html-encoding-sniffer": {
"version": "3.0.0", "version": "3.0.0",
"resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-3.0.0.tgz", "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-3.0.0.tgz",
@@ -3638,6 +3907,34 @@
"safer-buffer": ">= 2.1.2 < 3.0.0" "safer-buffer": ">= 2.1.2 < 3.0.0"
} }
}, },
"is-alphabetical": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/is-alphabetical/-/is-alphabetical-2.0.1.tgz",
"integrity": "sha512-FWyyY60MeTNyeSRpkM2Iry0G9hpr7/9kD40mD/cGQEuilcZYS4okz8SN2Q6rLCJ8gbCt6fN+rC+6tMGS99LaxQ==",
"dev": true
},
"is-alphanumerical": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/is-alphanumerical/-/is-alphanumerical-2.0.1.tgz",
"integrity": "sha512-hmbYhX/9MUMF5uh7tOXyK/n0ZvWpad5caBA17GsC6vyuCqaWliRG5K1qS9inmUhEMaOBIW7/whAnSwveW/LtZw==",
"dev": true,
"requires": {
"is-alphabetical": "^2.0.0",
"is-decimal": "^2.0.0"
}
},
"is-decimal": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/is-decimal/-/is-decimal-2.0.1.tgz",
"integrity": "sha512-AAB9hiomQs5DXWcRB1rqsxGUstbRroFOPPVAomNk/3XHR5JyEZChOyTWe2oayKnsSsr/kcGqF+z6yuH6HHpN0A==",
"dev": true
},
"is-hexadecimal": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/is-hexadecimal/-/is-hexadecimal-2.0.1.tgz",
"integrity": "sha512-DgZQp241c8oO6cA1SbTEWiXeoxV42vlcJxgH+B3hi1AiqqKruZR3ZGF8In3fj4+/y/7rHvlOZLZtgJ/4ttYGZg==",
"dev": true
},
"is-potential-custom-element-name": { "is-potential-custom-element-name": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz", "resolved": "https://registry.npmjs.org/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz",
@@ -3936,6 +4233,22 @@
"@otplib/preset-v11": "^12.0.1" "@otplib/preset-v11": "^12.0.1"
} }
}, },
"parse-entities": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/parse-entities/-/parse-entities-4.0.1.tgz",
"integrity": "sha512-SWzvYcSJh4d/SGLIOQfZ/CoNv6BTlI6YEQ7Nj82oDVnRpwe/Z/F1EMx42x3JAOwGBlCjeCH0BRJQbQ/opHL17w==",
"dev": true,
"requires": {
"@types/unist": "^2.0.0",
"character-entities": "^2.0.0",
"character-entities-legacy": "^3.0.0",
"character-reference-invalid": "^2.0.0",
"decode-named-character-reference": "^1.0.0",
"is-alphanumerical": "^2.0.0",
"is-decimal": "^2.0.0",
"is-hexadecimal": "^2.0.0"
}
},
"parse5": { "parse5": {
"version": "7.1.2", "version": "7.1.2",
"resolved": "https://registry.npmjs.org/parse5/-/parse5-7.1.2.tgz", "resolved": "https://registry.npmjs.org/parse5/-/parse5-7.1.2.tgz",
@@ -4020,6 +4333,12 @@
"resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.29.0.tgz", "resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.29.0.tgz",
"integrity": "sha512-Kx/1w86q/epKcmte75LNrEoT+lX8pBpavuAbvJWRXar7Hz8jrtF+e3vY751p0R8H9HdArwaCTNDDzHg/ScJK1Q==" "integrity": "sha512-Kx/1w86q/epKcmte75LNrEoT+lX8pBpavuAbvJWRXar7Hz8jrtF+e3vY751p0R8H9HdArwaCTNDDzHg/ScJK1Q=="
}, },
"property-information": {
"version": "6.2.0",
"resolved": "https://registry.npmjs.org/property-information/-/property-information-6.2.0.tgz",
"integrity": "sha512-kma4U7AFCTwpqq5twzC1YVIDXSqg6qQK6JN0smOw8fgRy1OkMi0CYSzFmsy6dnqSenamAtj0CyXMUJ1Mf6oROg==",
"dev": true
},
"psl": { "psl": {
"version": "1.9.0", "version": "1.9.0",
"resolved": "https://registry.npmjs.org/psl/-/psl-1.9.0.tgz", "resolved": "https://registry.npmjs.org/psl/-/psl-1.9.0.tgz",
@@ -4060,6 +4379,18 @@
"integrity": "sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==", "integrity": "sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==",
"dev": true "dev": true
}, },
"refractor": {
"version": "4.8.1",
"resolved": "https://registry.npmjs.org/refractor/-/refractor-4.8.1.tgz",
"integrity": "sha512-/fk5sI0iTgFYlmVGYVew90AoYnNMP6pooClx/XKqyeeCQXrL0Kvgn8V0VEht5ccdljbzzF1i3Q213gcntkRExg==",
"dev": true,
"requires": {
"@types/hast": "^2.0.0",
"@types/prismjs": "^1.0.0",
"hastscript": "^7.0.0",
"parse-entities": "^4.0.0"
}
},
"requires-port": { "requires-port": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz",
@@ -4133,6 +4464,12 @@
"integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==", "integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==",
"dev": true "dev": true
}, },
"space-separated-tokens": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/space-separated-tokens/-/space-separated-tokens-2.0.2.tgz",
"integrity": "sha512-PEGlAwrG8yXGXRjW32fGbg66JAlOAwbObuqVoJpv/mRgoWDQfgH1wDPvtzWyUSNAXBGSk8h755YDbbcEy3SH2Q==",
"dev": true
},
"spark-md5": { "spark-md5": {
"version": "3.0.2", "version": "3.0.2",
"resolved": "https://registry.npmjs.org/spark-md5/-/spark-md5-3.0.2.tgz", "resolved": "https://registry.npmjs.org/spark-md5/-/spark-md5-3.0.2.tgz",

View File

@@ -21,10 +21,14 @@
"happy-dom": "^10.9.0", "happy-dom": "^10.9.0",
"mockdate": "^3.0.5", "mockdate": "^3.0.5",
"otplib": "^12.0.1", "otplib": "^12.0.1",
"refractor": "^4.8.1",
"vitest": "^0.34.1", "vitest": "^0.34.1",
"vitest-fetch-mock": "^0.2.2" "vitest-fetch-mock": "^0.2.2"
}, },
"scripts": { "scripts": {
"prebuild": "node scripts/prebuild.mjs",
"pretest": "node scripts/prebuild.mjs",
"pretest:e2e": "node scripts/prebuild.mjs",
"build": "tsc", "build": "tsc",
"test:e2e": "cross-env IS_E2E=true vitest run", "test:e2e": "cross-env IS_E2E=true vitest run",
"test": "vitest run" "test": "vitest run"

View File

@@ -0,0 +1,48 @@
/*
This file is part of the Notesnook project (https://notesnook.com/)
Copyright (C) 2023 Streetwriters (Private) Limited
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import path from "path";
import fs from "fs/promises";
import { langen } from "../../editor/scripts/langen.mjs";
import { fileURLToPath } from "url";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const ROOT_DIR = path.resolve(path.join(__dirname, ".."));
const languagesList = await langen(ROOT_DIR, path.join(ROOT_DIR, "languages"));
const languageIndex = `function hasRequire() {
return typeof require === "function" && !("IS_DESKTOP_APP" in globalThis);
}
export async function loadLanguage(language) {
switch (language) {
${languagesList
.map(({ filename, alias }) => {
return [
...(alias || []).map((a) => `case "${a}":`),
`case "${filename}":`,
`return hasRequire() ? require("./${filename}.js") : await import("./${filename}.js");`
].join("\n");
})
.join("\n\n")}
}
}`;
await fs.writeFile(path.join(ROOT_DIR, "languages", "index.js"), languageIndex);

View File

@@ -67,8 +67,8 @@ async function preprocessHTML(templateData) {
? require("prismjs") ? require("prismjs")
: (await import("prismjs")).default; : (await import("prismjs")).default;
const { loadLanguage } = hasRequire() const { loadLanguage } = hasRequire()
? require("../../../../../editor/languages/index.js") ? require("../../../../languages/index.js")
: await import("../../../../../editor/languages/index.js"); : await import("../../../../languages/index.js");
prismjs.register = (syntax) => { prismjs.register = (syntax) => {
if (typeof arg === "function") syntax(prismjs); if (typeof arg === "function") syntax(prismjs);
}; };

View File

@@ -42,25 +42,6 @@ for (const name in pathsToCopy) {
} }
const languagesList = await langen(ROOT_DIR, path.join(ROOT_DIR, "languages")); const languagesList = await langen(ROOT_DIR, path.join(ROOT_DIR, "languages"));
const languageIndex = `function hasRequire() {
return typeof require === "function" && !("IS_DESKTOP_APP" in globalThis);
}
export async function loadLanguage(language) {
switch (language) {
${languagesList
.map(({ filename, alias }) => {
return [
...(alias || []).map((a) => `case "${a}":`),
`case "${filename}":`,
`return hasRequire() ? require("./${filename}.js") : await import("./${filename}.js");`
].join("\n");
})
.join("\n\n")}
}
}`;
fs.writeFileSync(path.join(ROOT_DIR, "languages", "index.js"), languageIndex);
fs.writeFileSync( fs.writeFileSync(
path.join(ROOT_DIR, "src", "extensions", "code-block", "languages.json"), path.join(ROOT_DIR, "src", "extensions", "code-block", "languages.json"),