@michijs/dev-server 0.4.2 → 0.5.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.
Files changed (40) hide show
  1. package/LICENSE.md +8 -8
  2. package/README.md +229 -208
  3. package/bin/actions/build.js +2 -2
  4. package/bin/actions/dist.js +5 -5
  5. package/bin/actions/generateAssets.d.ts +4 -0
  6. package/bin/actions/generateAssets.js +125 -0
  7. package/bin/actions/start.d.ts +1 -1
  8. package/bin/actions/start.js +46 -30
  9. package/bin/cli.js +33 -33
  10. package/bin/config/config.d.ts +111 -6
  11. package/bin/config/config.js +40 -31
  12. package/bin/config/getIPAddress.js +5 -3
  13. package/bin/config/michi.config.cjs +159 -0
  14. package/bin/config/public/client.js +1 -1
  15. package/bin/config/tsconfig.d.ts +1 -1
  16. package/bin/config/tsconfig.js +3 -3
  17. package/bin/config/userConfig.d.ts +1 -1
  18. package/bin/config/userConfig.js +18 -14
  19. package/bin/constants.d.ts +8 -0
  20. package/bin/constants.js +12 -0
  21. package/bin/index.d.ts +1 -1
  22. package/bin/index.js +1 -1
  23. package/bin/tsconfig.tsbuildinfo +1 -1
  24. package/bin/types.d.ts +71 -7
  25. package/bin/utils/copy.js +4 -4
  26. package/bin/utils/feature-image-template.svg +62 -0
  27. package/bin/utils/getAllFiles.js +2 -2
  28. package/bin/utils/getHostURL.d.ts +1 -0
  29. package/bin/utils/getHostURL.js +4 -0
  30. package/bin/utils/getLocalURL.d.ts +1 -0
  31. package/bin/utils/getLocalURL.js +3 -0
  32. package/bin/utils/getPath.js +1 -1
  33. package/bin/utils/minify.js +3 -3
  34. package/bin/utils/serviceWorkerTransformer.d.ts +1 -1
  35. package/bin/utils/serviceWorkerTransformer.js +8 -8
  36. package/bin/utils/transformers.d.ts +1 -1
  37. package/bin/utils/transformers.js +4 -4
  38. package/package.json +63 -74
  39. package/bin/actions/generateIcons.d.ts +0 -1
  40. package/bin/actions/generateIcons.js +0 -31
package/package.json CHANGED
@@ -1,74 +1,63 @@
1
- {
2
- "name": "@michijs/dev-server",
3
- "license": "MIT",
4
- "version": "0.4.2",
5
- "repository": {
6
- "type": "git",
7
- "url": "https://github.com/michijs/dev-server.git"
8
- },
9
- "main": "bin/index",
10
- "exports": {
11
- "types": "./bin/index.d.ts",
12
- "default": "./bin/index.js"
13
- },
14
- "bin": {
15
- "michi-server": "bin/index.js"
16
- },
17
- "description": "Development server based on esbuild",
18
- "files": [
19
- "bin/"
20
- ],
21
- "type": "module",
22
- "baseUrl": "./src",
23
- "scripts": {
24
- "dist": "tsc",
25
- "link": "npm run dist && npm link --force && tsc -w",
26
- "publish-patch-version": "npm version patch && npm run publish-npm",
27
- "publish-npm": "npm run dist && npm publish --access public"
28
- },
29
- "devDependencies": {
30
- "@types/node": "18.16.3",
31
- "@types/yargs": "17.0.24",
32
- "lint-staged": "13.2.2",
33
- "rome": "12.0.0",
34
- "simple-git-hooks": "2.8.1"
35
- },
36
- "keywords": [
37
- "react",
38
- "javascript",
39
- "css",
40
- "bundler",
41
- "typescript",
42
- "compiler",
43
- "jsx",
44
- "commonjs",
45
- "minifier",
46
- "tsx",
47
- "esm",
48
- "server",
49
- "development"
50
- ],
51
- "engines": {
52
- "node": ">=14.16"
53
- },
54
- "dependencies": {
55
- "@types/web-app-manifest": "1.0.2",
56
- "esbuild": "0.17.18",
57
- "node-watch": "0.7.3",
58
- "open": "9.1.0",
59
- "sharp": "0.32.1",
60
- "yargs": "17.7.2"
61
- },
62
- "peerDependencies": {
63
- "typescript": "5.0.4"
64
- },
65
- "simple-git-hooks": {
66
- "pre-commit": "npx lint-staged"
67
- },
68
- "lint-staged": {
69
- "*.{js,jsx,ts,tsx}": [
70
- "rome check --apply",
71
- "rome format --write"
72
- ]
73
- }
74
- }
1
+ {
2
+ "name": "@michijs/dev-server",
3
+ "license": "MIT",
4
+ "version": "0.5.0",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/michijs/dev-server.git"
8
+ },
9
+ "main": "bin/index",
10
+ "exports": {
11
+ "types": "./bin/index.d.ts",
12
+ "default": "./bin/index.js"
13
+ },
14
+ "bin": {
15
+ "michi-server": "bin/index.js"
16
+ },
17
+ "description": "Development server based on esbuild",
18
+ "files": [
19
+ "bin/"
20
+ ],
21
+ "type": "module",
22
+ "baseUrl": "./src",
23
+ "scripts": {
24
+ "dist": "tsc",
25
+ "link": "npm run dist && npm link --force && tsc -w",
26
+ "publish-patch-version": "npm version patch && npm run publish-npm",
27
+ "publish-npm": "npm run dist && npm publish --access public"
28
+ },
29
+ "devDependencies": {
30
+ "@types/node": "20.3.2",
31
+ "@types/yargs": "17.0.24"
32
+ },
33
+ "keywords": [
34
+ "react",
35
+ "javascript",
36
+ "css",
37
+ "bundler",
38
+ "typescript",
39
+ "compiler",
40
+ "jsx",
41
+ "commonjs",
42
+ "minifier",
43
+ "tsx",
44
+ "esm",
45
+ "server",
46
+ "development"
47
+ ],
48
+ "engines": {
49
+ "node": ">=14.16"
50
+ },
51
+ "dependencies": {
52
+ "@types/web-app-manifest": "1.0.4",
53
+ "esbuild": "0.18.9",
54
+ "node-watch": "0.7.3",
55
+ "open": "9.1.0",
56
+ "puppeteer": "^20.5.0",
57
+ "sharp": "0.32.1",
58
+ "yargs": "17.7.2"
59
+ },
60
+ "peerDependencies": {
61
+ "typescript": "5.0.4"
62
+ }
63
+ }
@@ -1 +0,0 @@
1
- export declare function generateIcons(callback: () => void, src: string): Promise<void>;
@@ -1,31 +0,0 @@
1
- import { getPath } from '../utils/getPath.js';
2
- import { config } from '../config/config.js';
3
- import { mkdirSync, existsSync, writeFileSync } from 'fs';
4
- import { pngToIco } from '../utils/pngToIco.js';
5
- const generateFavicon = async (src, dest) => {
6
- const { default: sharp } = await import('sharp');
7
- const image = await sharp(src);
8
- const iconSizes = [16, 24, 32, 48, 64, 128, 256];
9
- const resizedBuffers = await Promise.all(iconSizes.map((size) => {
10
- return image.resize(size, size).png().toBuffer();
11
- }));
12
- writeFileSync(dest, await pngToIco(resizedBuffers, iconSizes));
13
- };
14
- export async function generateIcons(callback, src) {
15
- const destPath = getPath(`${config.public.path}/assets/generated`);
16
- if (!existsSync(destPath))
17
- mkdirSync(destPath, { recursive: true });
18
- const { default: sharp } = await import('sharp');
19
- const sizes = [24, 48, 72, 96, 128, 256, 512];
20
- const image = sharp(src);
21
- await Promise.all([
22
- ...sizes.map((x) => {
23
- return image
24
- .resize(x, x)
25
- .webp()
26
- .toFile(getPath(`${destPath}/${src.split('/').at(-1)?.split('.')[0]}-${x}.webp`));
27
- }),
28
- generateFavicon(src, getPath(`${config.public.path}/favicon.ico`)),
29
- ]);
30
- callback();
31
- }