@allurereport/static-server 3.0.0-beta.9 → 3.0.1

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 CHANGED
@@ -5,7 +5,7 @@ export type AllureStaticServer = {
5
5
  reload: () => Promise<void>;
6
6
  open: (url: string) => Promise<void>;
7
7
  };
8
- export declare const renderDirectory: (files: string[], dirPath?: boolean) => Promise<string>;
8
+ export declare const renderDirectory: (entries: string[], dirPath?: boolean) => Promise<string>;
9
9
  export declare const serve: (options?: {
10
10
  port?: number;
11
11
  live?: boolean;
package/dist/index.js CHANGED
@@ -7,17 +7,29 @@ import { basename, extname, join, resolve } from "node:path";
7
7
  import { cwd } from "node:process";
8
8
  import openUrl from "open";
9
9
  import { TYPES_BY_EXTENSION, identity, injectLiveReloadScript } from "./utils.js";
10
- export const renderDirectory = async (files, dirPath) => {
10
+ export const renderDirectory = async (entries, dirPath) => {
11
11
  const links = [];
12
- for (const file of files) {
13
- const stats = await stat(file);
12
+ const files = [];
13
+ const dirs = [];
14
+ for (const entry of entries) {
15
+ const stats = await stat(entry);
14
16
  if (stats.isDirectory()) {
15
- links.push(`<a href="./${basename(file)}/">${basename(file)}/</a>`);
17
+ dirs.push(entry);
16
18
  }
17
19
  else {
18
- links.push(`<a href="./${basename(file)}">${basename(file)}</a>`);
20
+ files.push(entry);
19
21
  }
20
22
  }
23
+ dirs
24
+ .sort((a, b) => a.localeCompare(b))
25
+ .forEach((entry) => {
26
+ links.push(`<a href="./${basename(entry)}/">${basename(entry)}/</a>`);
27
+ });
28
+ files
29
+ .sort((a, b) => a.localeCompare(b))
30
+ .forEach((entry) => {
31
+ links.push(`<a href="./${basename(entry)}">${basename(entry)}</a>`);
32
+ });
21
33
  return `
22
34
  <!DOCTYPE html>
23
35
  <html lang="en">
@@ -36,8 +48,8 @@ export const renderDirectory = async (files, dirPath) => {
36
48
  `;
37
49
  };
38
50
  export const serve = async (options) => {
39
- const { port, live = false, servePath = cwd(), open = false } = options ?? {};
40
- const pathToServe = resolve(cwd(), servePath);
51
+ const { port, live = false, servePath, open = false } = options ?? {};
52
+ const pathToServe = servePath ? resolve(cwd(), servePath) : cwd();
41
53
  const clients = new Set();
42
54
  const server = createServer(async (req, res) => {
43
55
  const hostHeaderIdx = req.rawHeaders.findIndex((header) => header === "Host") + 1;
@@ -56,7 +68,7 @@ export const serve = async (options) => {
56
68
  });
57
69
  return;
58
70
  }
59
- let fsPath = join(pathToServe, pathname.replace(/\?.*$/, ""));
71
+ let fsPath = join(pathToServe, decodeURI(pathname));
60
72
  let stats;
61
73
  try {
62
74
  stats = await stat(fsPath);
@@ -152,6 +164,7 @@ export const serve = async (options) => {
152
164
  await openUrl(url);
153
165
  },
154
166
  stop: async () => {
167
+ server.closeAllConnections();
155
168
  server.unref();
156
169
  await unwatch();
157
170
  },
package/dist/utils.js CHANGED
@@ -1,4 +1,4 @@
1
- import { ALLURE_LIVE_RELOAD_HASH_STORAGE_KEY } from "@allurereport/web-commons";
1
+ const ALLURE_LIVE_RELOAD_HASH_STORAGE_KEY = "__allure_report_live_reload_hash__";
2
2
  export const EXTENSIONS_BY_TYPE = {
3
3
  "application/andrew-inset": ".ez",
4
4
  "application/applixware": ".aw",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allurereport/static-server",
3
- "version": "3.0.0-beta.9",
3
+ "version": "3.0.1",
4
4
  "description": "Minimalistic web-server for serving static files",
5
5
  "keywords": [
6
6
  "allure",
@@ -32,23 +32,22 @@
32
32
  "test:e2e": "playwright test"
33
33
  },
34
34
  "dependencies": {
35
- "@allurereport/directory-watcher": "3.0.0-beta.9",
36
- "@allurereport/web-commons": "3.0.0-beta.9",
35
+ "@allurereport/directory-watcher": "3.0.1",
37
36
  "open": "^10.1.0"
38
37
  },
39
38
  "devDependencies": {
40
- "@playwright/test": "^1.48.2",
39
+ "@playwright/test": "^1.56.1",
41
40
  "@stylistic/eslint-plugin": "^2.6.1",
42
41
  "@types/eslint": "^8.56.11",
43
42
  "@types/node": "^20.17.9",
44
43
  "@typescript-eslint/eslint-plugin": "^8.0.0",
45
44
  "@typescript-eslint/parser": "^8.0.0",
46
- "@vitest/runner": "^2.1.8",
47
- "@vitest/snapshot": "^2.1.8",
48
- "allure-js-commons": "^3.0.9",
49
- "allure-playwright": "^3.0.9",
50
- "allure-vitest": "^3.0.9",
51
- "axios": "^1.7.7",
45
+ "@vitest/runner": "^2.1.9",
46
+ "@vitest/snapshot": "^2.1.9",
47
+ "allure-js-commons": "^3.3.3",
48
+ "allure-playwright": "^3.3.3",
49
+ "allure-vitest": "^3.3.3",
50
+ "axios": "^1.13.1",
52
51
  "eslint": "^8.57.0",
53
52
  "eslint-config-prettier": "^9.1.0",
54
53
  "eslint-plugin-import": "^2.29.1",
@@ -60,6 +59,6 @@
60
59
  "npm-run-all2": "^7.0.1",
61
60
  "rimraf": "^6.0.1",
62
61
  "typescript": "^5.6.3",
63
- "vitest": "^2.1.8"
62
+ "vitest": "^2.1.9"
64
63
  }
65
64
  }