@allurereport/static-server 3.0.0-beta.15 → 3.0.0-beta.17

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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allurereport/static-server",
3
- "version": "3.0.0-beta.15",
3
+ "version": "3.0.0-beta.17",
4
4
  "description": "Minimalistic web-server for serving static files",
5
5
  "keywords": [
6
6
  "allure",
@@ -32,8 +32,8 @@
32
32
  "test:e2e": "playwright test"
33
33
  },
34
34
  "dependencies": {
35
- "@allurereport/directory-watcher": "3.0.0-beta.15",
36
- "@allurereport/web-commons": "3.0.0-beta.15",
35
+ "@allurereport/directory-watcher": "3.0.0-beta.17",
36
+ "@allurereport/web-commons": "3.0.0-beta.17",
37
37
  "open": "^10.1.0"
38
38
  },
39
39
  "devDependencies": {
@@ -43,12 +43,12 @@
43
43
  "@types/node": "^20.17.9",
44
44
  "@typescript-eslint/eslint-plugin": "^8.0.0",
45
45
  "@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",
46
+ "@vitest/runner": "^2.1.9",
47
+ "@vitest/snapshot": "^2.1.9",
48
+ "allure-js-commons": "^3.3.0",
49
+ "allure-playwright": "^3.3.0",
50
+ "allure-vitest": "^3.3.0",
51
+ "axios": "^1.9.0",
52
52
  "eslint": "^8.57.0",
53
53
  "eslint-config-prettier": "^9.1.0",
54
54
  "eslint-plugin-import": "^2.29.1",
@@ -60,6 +60,6 @@
60
60
  "npm-run-all2": "^7.0.1",
61
61
  "rimraf": "^6.0.1",
62
62
  "typescript": "^5.6.3",
63
- "vitest": "^2.1.8"
63
+ "vitest": "^2.1.9"
64
64
  }
65
65
  }