@michijs/dev-server 0.8.8-beta.4 → 0.8.9
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 +0 -1
- package/bin/actions/dist.js +4 -2
- package/bin/actions/generateAssets.js +3 -3
- package/bin/actions/start.js +1 -1
- package/bin/cli.js +4 -1
- package/bin/config/plugins/publicFolder.js +6 -5
- package/bin/config/userConfig.js +1 -1
- package/bin/index.js +0 -0
- package/bin/utils/copy.js +2 -1
- package/bin/utils/getAllFiles.d.ts +1 -1
- package/bin/utils/getAllFiles.js +5 -7
- package/bin/utils/getCurrentCommitSha.js +1 -3
- package/bin/utils/globToRegex.js +3 -5
- package/package.json +6 -5
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
|
-
[](https://github.com/michijs/dev-server/actions/workflows/tests.yml)
|
|
7
6
|
|
|
8
7
|
## Main features
|
|
9
8
|
- Configure esbuild options with Typescript
|
package/bin/actions/dist.js
CHANGED
|
@@ -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
|
-
|
|
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(
|
|
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
|
|
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
|
|
46
|
-
|
|
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, }) {
|
package/bin/actions/start.js
CHANGED
package/bin/cli.js
CHANGED
|
@@ -3,6 +3,7 @@ import yargs from "yargs";
|
|
|
3
3
|
import { Timer } from "./classes/Timer.js";
|
|
4
4
|
import { hideBin } from "yargs/helpers";
|
|
5
5
|
import { packageJson } from "./utils/packageJson.js";
|
|
6
|
+
import { config } from "./config/config.js";
|
|
6
7
|
const version = packageJson.version;
|
|
7
8
|
export async function cli() {
|
|
8
9
|
console.log(` ${coloredString(`Running dev server version ${version}.`)}`);
|
|
@@ -57,7 +58,9 @@ export async function cli() {
|
|
|
57
58
|
: args.dist || args.testTsc
|
|
58
59
|
? "DISTRIBUTION"
|
|
59
60
|
: "DEVELOPMENT");
|
|
60
|
-
const generateAssets = args.generateAssets === ""
|
|
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
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
}
|
package/bin/config/userConfig.js
CHANGED
|
@@ -20,7 +20,7 @@ if (fs.existsSync("michi.config.ts")) {
|
|
|
20
20
|
logLevel: "error",
|
|
21
21
|
target: ["node16"],
|
|
22
22
|
});
|
|
23
|
-
// @ts-
|
|
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
|
-
|
|
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
|
|
1
|
+
export declare const getAllFiles: (dirPath: string, dirToShow?: string) => string[];
|
package/bin/utils/getAllFiles.js
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
2
|
import { getPath } from "./getPath.js";
|
|
3
|
-
export const getAllFiles = (dirPath, dirToShow = dirPath
|
|
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
|
-
|
|
9
|
-
|
|
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
|
};
|
package/bin/utils/globToRegex.js
CHANGED
|
@@ -22,15 +22,13 @@ export function globToRegex(glob) {
|
|
|
22
22
|
if (char === "*") {
|
|
23
23
|
return ".*";
|
|
24
24
|
}
|
|
25
|
-
|
|
25
|
+
if (char === "?") {
|
|
26
26
|
return ".";
|
|
27
27
|
}
|
|
28
|
-
|
|
28
|
+
if (regexSpecialChars.includes(char)) {
|
|
29
29
|
return "\\" + char;
|
|
30
30
|
}
|
|
31
|
-
|
|
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.
|
|
4
|
+
"version": "0.8.9",
|
|
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.26",
|
|
32
33
|
"@michijs/tsconfig": "0.0.5",
|
|
33
|
-
"@types/node": "24.
|
|
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.
|
|
59
|
+
"esbuild": "0.25.9",
|
|
59
60
|
"node-watch": "0.7.4",
|
|
60
61
|
"open": "10.2.0",
|
|
61
|
-
"playwright-core": "1.
|
|
62
|
+
"playwright-core": "1.55.0",
|
|
62
63
|
"sharp": "0.34.3",
|
|
63
64
|
"yargs": "18.0.0"
|
|
64
65
|
}
|
|
65
|
-
}
|
|
66
|
+
}
|