@ckeditor/ckeditor5-dev-manual-server 56.3.0 → 56.4.0
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/index.d.ts +1 -1
- package/dist/index.js +23 -4
- package/dist/manual-test-plugin/plugin.d.ts +5 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* For licensing, see LICENSE.md.
|
|
4
4
|
*/
|
|
5
5
|
export { manualTestsPlugin } from "./manual-test-plugin/plugin.js";
|
|
6
|
-
export type { ManualData } from "./manual-test-plugin/plugin.js";
|
|
6
|
+
export type { ManualData, ManualTestsPluginOptions } from "./manual-test-plugin/plugin.js";
|
|
7
7
|
export { refreshPlugin } from "./refresh-plugin/plugin.js";
|
|
8
8
|
export { rawHtmlPlugin } from "./raw-plugin/plugin.js";
|
|
9
9
|
export { stringifyValues } from "./utils.js";
|
package/dist/index.js
CHANGED
|
@@ -312,13 +312,15 @@ const MANUAL_CATALOG_FILE_PATH = resolve(MANUAL_THEME_ROOT, "catalog.html");
|
|
|
312
312
|
const MANUAL_CATALOG_SCRIPT_FILE_PATH = resolve(MANUAL_THEME_ROOT, "catalog.ts");
|
|
313
313
|
const MANUAL_SHELL_TEMPLATE_FILE_PATH = resolve(MANUAL_THEME_ROOT, "shell.html");
|
|
314
314
|
const MANUAL_SHELL_SCRIPT_FILE_PATH = resolve(MANUAL_THEME_ROOT, "shell.ts");
|
|
315
|
-
function manualTestsPlugin(
|
|
315
|
+
function manualTestsPlugin(options) {
|
|
316
316
|
let workspaceRoot = process.cwd();
|
|
317
317
|
let base = "/";
|
|
318
|
+
const manualTestPatterns = options.paths;
|
|
318
319
|
const manualPagePatterns = manualTestPatterns.map(toManualPagePattern);
|
|
319
|
-
const
|
|
320
|
-
const
|
|
320
|
+
const includePackageNames = (options.include || []).filter(Boolean);
|
|
321
|
+
const manualPagesCache = cacheValue(() => filterManualPages(collectManualPages(manualPagePatterns, workspaceRoot), includePackageNames));
|
|
321
322
|
const getManualPages = manualPagesCache.get;
|
|
323
|
+
const manualStaticAssetsCache = cacheValue(() => collectManualStaticAssets(getManualStaticAssetPatterns(getManualPages(), manualTestPatterns, includePackageNames), workspaceRoot));
|
|
322
324
|
const getManualStaticAssets = manualStaticAssetsCache.get;
|
|
323
325
|
const invalidateManualFileCaches = () => {
|
|
324
326
|
manualPagesCache.invalidate();
|
|
@@ -327,8 +329,8 @@ function manualTestsPlugin(manualTestPatterns) {
|
|
|
327
329
|
const getManualPageEntryForFile = (filePath) => {
|
|
328
330
|
return getManualPages().get(toPublicSpecifier(relative(workspaceRoot, filePath)));
|
|
329
331
|
};
|
|
330
|
-
const getManualCatalogPublicPath = () => toPublicFilePath(MANUAL_CATALOG_FILE_PATH, workspaceRoot);
|
|
331
332
|
const getManualCatalogBuildInputFilePath = () => resolve(workspaceRoot, "index.html");
|
|
333
|
+
const getManualCatalogPublicPath = () => toPublicFilePath(getManualCatalogBuildInputFilePath(), workspaceRoot);
|
|
332
334
|
const getManualCatalogScriptPublicPath = () => toPublicFilePath(MANUAL_CATALOG_SCRIPT_FILE_PATH, workspaceRoot);
|
|
333
335
|
const getManualShellScriptPublicPath = () => toPublicFilePath(MANUAL_SHELL_SCRIPT_FILE_PATH, workspaceRoot);
|
|
334
336
|
const getManualCatalogClientPath = (entry) => toBaseCatalogPath(base, entry.htmlFilePath);
|
|
@@ -429,6 +431,23 @@ function toManualPagePattern(pattern) {
|
|
|
429
431
|
if (/\.(?:html|js|md|ts|\{[^}]*\})$/.test(pattern)) return pattern;
|
|
430
432
|
return `${pattern}.{html,js,md,ts}`;
|
|
431
433
|
}
|
|
434
|
+
function filterManualPages(manualPages, includePackageNames) {
|
|
435
|
+
if (includePackageNames.length == 0) return manualPages;
|
|
436
|
+
const normalizedIncludePackageNames = new Set(includePackageNames.map(normalizePackageName));
|
|
437
|
+
return new Map([...manualPages].filter(([, entry]) => normalizedIncludePackageNames.has(normalizePackageName(entry.packageName))));
|
|
438
|
+
}
|
|
439
|
+
function normalizePackageName(packageName) {
|
|
440
|
+
return packageName.replace(/^ckeditor5-/, "");
|
|
441
|
+
}
|
|
442
|
+
function getManualStaticAssetPatterns(manualPages, manualTestPatterns, includePackageNames) {
|
|
443
|
+
if (includePackageNames.length == 0) return manualTestPatterns;
|
|
444
|
+
return [...new Set([...manualPages.values()].map(getManualTestRootDirectory))].map((manualTestRootDirectory) => `${manualTestRootDirectory}/**/*`);
|
|
445
|
+
}
|
|
446
|
+
function getManualTestRootDirectory(entry) {
|
|
447
|
+
const htmlFilePath = stripLeadingSlash(entry.htmlFilePath);
|
|
448
|
+
const manualDirectoryIndex = htmlFilePath.indexOf("/tests/manual/");
|
|
449
|
+
return htmlFilePath.slice(0, manualDirectoryIndex + 14 - 1);
|
|
450
|
+
}
|
|
432
451
|
function isManualCatalogHtmlFile(filePath, catalogBuildInputFilePath) {
|
|
433
452
|
const normalizedFilePath = toPosixPath(filePath);
|
|
434
453
|
return normalizedFilePath == toPosixPath(MANUAL_CATALOG_FILE_PATH) || normalizedFilePath == toPosixPath(catalogBuildInputFilePath);
|
|
@@ -4,4 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import type { Plugin } from "vite";
|
|
6
6
|
export type { ManualData } from "./types.js";
|
|
7
|
-
export
|
|
7
|
+
export interface ManualTestsPluginOptions {
|
|
8
|
+
paths: Array<string>;
|
|
9
|
+
include?: Array<string>;
|
|
10
|
+
}
|
|
11
|
+
export declare function manualTestsPlugin(options: ManualTestsPluginOptions): Plugin;
|
package/package.json
CHANGED