@michijs/dev-server 0.8.8-beta.4 → 0.8.10

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/README.md CHANGED
@@ -3,7 +3,6 @@ Development server built on top of esbuild.
3
3
  <!-- TODO: To generate feature-image require to install roboto -->
4
4
 
5
5
  ![npm][version] [![license][github-license]][github-license-url] ![npm][npm-downloads] ![npm][repo-size]
6
- [![Tests](https://github.com/michijs/dev-server/actions/workflows/tests.yml/badge.svg)](https://github.com/michijs/dev-server/actions/workflows/tests.yml)
7
6
 
8
7
  ## Main features
9
8
  - Configure esbuild options with Typescript
@@ -36,7 +36,9 @@ export async function dist(callback, watchOption = false) {
36
36
  if (fs.existsSync(outDir))
37
37
  fs.rmSync(outDir, { recursive: true });
38
38
  const omit = tsconfig.exclude.map((x) => globToRegex(getPath(x)));
39
- tsconfig.include.forEach((x) => copy(x, outDir, transformers, omit));
39
+ for (const x of tsconfig.include) {
40
+ copy(x, outDir, transformers, omit);
41
+ }
40
42
  exec(
41
43
  // outDir takes the dir from the extended tsconfig...
42
44
  `tsc ${watchOption ? "-w --incremental" : ""} --emitDeclarationOnly --project ${config.esbuildOptions.tsconfig} --outDir ${outDir}`, { maxBuffer: 1024 * 500 }, (error, stdout, stderr) => {
@@ -57,6 +59,6 @@ export async function dist(callback, watchOption = false) {
57
59
  });
58
60
  }
59
61
  else {
60
- throw new Error(`Your tsconfig needs an outdir`);
62
+ throw new Error("Your tsconfig needs an outdir");
61
63
  }
62
64
  }
@@ -10,7 +10,7 @@ import { chromium, } from "playwright-core";
10
10
  import { exec } from "child_process";
11
11
  import { getColor } from "colorthief";
12
12
  import { packageJson } from "../utils/packageJson.js";
13
- export async function installPlaywright() {
13
+ export function installPlaywright() {
14
14
  const playwrightVersion = `playwright@${packageJson.dependencies["playwright-core"]}`;
15
15
  console.log(`Installing ${playwrightVersion}...`);
16
16
  return new Promise((resolve, reject) => {
@@ -42,8 +42,8 @@ const generateFavicon = async (src, dest) => {
42
42
  config.watch = false;
43
43
  config.openBrowser = false;
44
44
  let browser;
45
- const port = await new Promise(async (resolve) => {
46
- const { start } = await import("./start.js");
45
+ const { start } = await import("./start.js");
46
+ const port = await new Promise((resolve) => {
47
47
  start((port) => resolve(port));
48
48
  });
49
49
  async function takeScreenshots({ viewports, options, pageCallback, path, }) {
@@ -46,7 +46,7 @@ export const start = async (callback) => {
46
46
  });
47
47
  let selectedPort = config.port;
48
48
  server.on("error", (e) => {
49
- // @ts-ignore
49
+ // @ts-expect-error
50
50
  if (e.code === "EADDRINUSE") {
51
51
  selectedPort++;
52
52
  server.listen(selectedPort);
package/bin/cli.js CHANGED
@@ -57,7 +57,10 @@ export async function cli() {
57
57
  : args.dist || args.testTsc
58
58
  ? "DISTRIBUTION"
59
59
  : "DEVELOPMENT");
60
- const generateAssets = args.generateAssets === "" ? "public/assets/icon.svg" : args.generateAssets;
60
+ const { config } = await import("./config/config.js");
61
+ const generateAssets = args.generateAssets === ""
62
+ ? `${config.public.path}/assets/icon.svg`
63
+ : args.generateAssets;
61
64
  if (generateAssets) {
62
65
  const action = await import("./actions/generateAssets.js");
63
66
  await action.generateAssets(showReadyMessage, generateAssets);
@@ -41,11 +41,12 @@ export const publicFolderPlugin = {
41
41
  copy(config.public.path, outdir, transformers);
42
42
  if (config.watch)
43
43
  syncDirs(config.public.path, config.esbuildOptions.outdir, transformers, undefined, undefined, (event, fileChangedPath) => {
44
- connections.forEach((x) => x.write(`event: change\ndata: ${JSON.stringify({
45
- added: [],
46
- removed: event === "remove" ? [fileChangedPath] : [],
47
- updated: event === "update" ? [fileChangedPath] : [],
48
- })}\n\n`));
44
+ for (const x of connections)
45
+ x.write(`event: change\ndata: ${JSON.stringify({
46
+ added: [],
47
+ removed: event === "remove" ? [fileChangedPath] : [],
48
+ updated: event === "update" ? [fileChangedPath] : [],
49
+ })}\n\n`);
49
50
  });
50
51
  firstLoad = false;
51
52
  }
@@ -20,7 +20,7 @@ if (fs.existsSync("michi.config.ts")) {
20
20
  logLevel: "error",
21
21
  target: ["node16"],
22
22
  });
23
- // @ts-ignore
23
+ // @ts-expect-error
24
24
  const michiConfig = await import("./michi.config.cjs");
25
25
  config = michiConfig.default.default({
26
26
  ...defaultProductionConfig,
package/bin/index.js CHANGED
File without changes
package/bin/utils/copy.js CHANGED
@@ -28,5 +28,6 @@ export function copy(src, dest, transformers, omit) {
28
28
  fs.mkdirSync(dest);
29
29
  }
30
30
  catch { }
31
- srcDir.forEach((fileName) => copyFile(src, fileName, dest, transformers, omit));
31
+ for (const fileName of srcDir)
32
+ copyFile(src, fileName, dest, transformers, omit);
32
33
  }
@@ -1 +1 @@
1
- export declare const getAllFiles: (dirPath: string, dirToShow?: string, arrayOfFiles?: string[]) => string[];
1
+ export declare const getAllFiles: (dirPath: string, dirToShow?: string) => string[];
@@ -1,16 +1,14 @@
1
1
  import fs from "fs";
2
2
  import { getPath } from "./getPath.js";
3
- export const getAllFiles = (dirPath, dirToShow = dirPath, arrayOfFiles = []) => {
3
+ export const getAllFiles = (dirPath, dirToShow = dirPath) => {
4
4
  const files = fs.readdirSync(dirPath);
5
+ const arrayOfFiles = [];
5
6
  files.forEach((file) => {
6
7
  const normalizedPath = getPath(`${dirPath}/${file}`);
7
8
  const filePath = `${dirToShow}/${file}`;
8
- if (fs.statSync(normalizedPath).isDirectory()) {
9
- arrayOfFiles = getAllFiles(normalizedPath, filePath, arrayOfFiles);
10
- }
11
- else {
12
- arrayOfFiles.push(filePath);
13
- }
9
+ arrayOfFiles.push(...(fs.statSync(normalizedPath).isDirectory()
10
+ ? getAllFiles(normalizedPath, filePath)
11
+ : [filePath]));
14
12
  });
15
13
  return arrayOfFiles;
16
14
  };
@@ -8,9 +8,7 @@ export const getCurrentCommitSha = () => {
8
8
  const refPath = join(".git", headContent.split(" ")[1]);
9
9
  return fs.readFileSync(refPath, "utf-8").trim();
10
10
  }
11
- else {
12
- return headContent;
13
- }
11
+ return headContent;
14
12
  }
15
13
  catch {
16
14
  return "";
@@ -22,15 +22,13 @@ export function globToRegex(glob) {
22
22
  if (char === "*") {
23
23
  return ".*";
24
24
  }
25
- else if (char === "?") {
25
+ if (char === "?") {
26
26
  return ".";
27
27
  }
28
- else if (regexSpecialChars.includes(char)) {
28
+ if (regexSpecialChars.includes(char)) {
29
29
  return "\\" + char;
30
30
  }
31
- else {
32
- return char;
33
- }
31
+ return char;
34
32
  })
35
33
  .join("") +
36
34
  "$");
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@michijs/dev-server",
3
3
  "license": "MIT",
4
- "version": "0.8.8-beta.4",
4
+ "version": "0.8.10",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/michijs/dev-server.git"
@@ -29,8 +29,9 @@
29
29
  "link": "bunx concurrently bun:dist-w bun:bun-link"
30
30
  },
31
31
  "devDependencies": {
32
+ "@michijs/shared-configs": "0.0.29",
32
33
  "@michijs/tsconfig": "0.0.5",
33
- "@types/node": "24.2.1",
34
+ "@types/node": "24.3.0",
34
35
  "@types/yargs": "17.0.33",
35
36
  "typescript": "5.9.2"
36
37
  },
@@ -55,11 +56,11 @@
55
56
  "dependencies": {
56
57
  "colorthief": "2.6.0",
57
58
  "@types/web-app-manifest": "1.0.9",
58
- "esbuild": "0.25.8",
59
+ "esbuild": "0.25.9",
59
60
  "node-watch": "0.7.4",
60
61
  "open": "10.2.0",
61
- "playwright-core": "1.54.2",
62
+ "playwright-core": "1.55.0",
62
63
  "sharp": "0.34.3",
63
64
  "yargs": "18.0.0"
64
65
  }
65
- }
66
+ }