Skip to content

Commit c7ff187

Browse files
authored
feat: mime npm package (#34)
* feat: mime npm package * fix: pipeline
1 parent 67be273 commit c7ff187

File tree

7 files changed

+74
-51
lines changed

7 files changed

+74
-51
lines changed

.github/workflows/ci-dev.yaml

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,28 @@ on:
77

88
jobs:
99
check:
10-
name: Source revision
10+
name: Source Revision
1111
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
node-version: [22.x, 20.x, 18.x]
1215

1316
steps:
1417
- uses: actions/checkout@v4
18+
1519
- uses: actions/setup-node@v4
1620
with:
17-
node-version: '20.17.0'
21+
node-version: ${{ matrix.node-version }}
22+
cache: 'npm'
23+
24+
- name: Install Dependencies
25+
run: npm ci
26+
27+
- name: Run Format Check
28+
run: npm run format:check
29+
30+
- name: Run Lint Check
31+
run: npm run lint:check
1832

19-
- run: npm ci
20-
- run: npm run format:check
21-
- run: npm run lint:check
22-
- run: npm run build
33+
- name: Build
34+
run: npm run build

.github/workflows/ci-full.yaml

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,31 @@ on:
77

88
jobs:
99
check:
10-
name: Source revision
10+
name: Source Revision
1111
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
node-version: [22.x, 20.x, 18.x]
1215

1316
steps:
1417
- uses: actions/checkout@v4
18+
1519
- uses: actions/setup-node@v4
1620
with:
17-
node-version: '20.17.0'
21+
node-version: ${{ matrix.node-version }}
22+
cache: 'npm'
23+
24+
- name: Install Dependencies
25+
run: npm ci
26+
27+
- name: Run Format Check
28+
run: npm run format:check
29+
30+
- name: Run Lint Check
31+
run: npm run lint:check
1832

19-
- run: npm ci
20-
- run: npm run format:check
21-
- run: npm run lint:check
22-
- run: npm run build
33+
- name: Build
34+
run: npm run build
2335

2436
tag:
2537
name: Version tag
@@ -47,10 +59,16 @@ jobs:
4759
- uses: actions/checkout@v4
4860
- uses: actions/setup-node@v4
4961
with:
50-
node-version: '20.16.0'
51-
registry-url: 'https://registry.npmjs.org'
52-
- run: npm ci
53-
- run: npm run build
54-
- run: npm publish
62+
node-version: '22'
63+
cache: 'npm'
64+
65+
- name: Install Dependencies
66+
run: npm ci
67+
68+
- name: Build
69+
run: npm run build
70+
71+
- name: Publish
72+
run: npm publish
5573
env:
5674
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Change log
22

3+
## 1.6
4+
5+
### 1.6.0
6+
7+
- Using mime npm package instead of mime-types: I prefer to use standard text/javascript. It better meets today's requirements.
8+
39
## 1.5
410

511
### 1.5.2

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ In order to be able to easily update OTA, it is important - from the users' poin
1212

1313
This npm package provides a solution for **inserting any JS client application into the ESP web server** (PsychicHttp and also ESPAsyncWebServer available, PsychicHttp is the default). For this, JS, html, css, font, assets, etc. files must be converted to binary byte array. Npm mode is easy to use and easy to **integrate into your CI/CD pipeline**.
1414

15+
> Starting with version v1.6.0, mime npm package is used instead of mime-types (application/javascript -> text/javascript)
16+
1517
> Starting with version v1.5.0, PsychicHttp v2 is also supported.
1618
1719
> Version v1.4.0 has a breaking change! --no-gzip changed to --gzip. Starting with this version c++ compiler directives are available to setup operation in project level.

package-lock.json

Lines changed: 13 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "svelteesp32",
3-
"version": "1.5.2",
3+
"version": "1.6.0",
44
"description": "Convert Svelte (or any frontend) JS application to serve it from ESP32 webserver (PsychicHttp)",
55
"author": "BCsabaEngine",
66
"license": "ISC",
@@ -54,7 +54,6 @@
5454
"espasyncwebserver"
5555
],
5656
"devDependencies": {
57-
"@types/mime-types": "^2.1.4",
5857
"@types/node": "^22.10.1",
5958
"@typescript-eslint/eslint-plugin": "^8.17.0",
6059
"@typescript-eslint/parser": "^8.17.0",
@@ -71,7 +70,7 @@
7170
"dependencies": {
7271
"glob": "^11.0.0",
7372
"handlebars": "^4.7.8",
74-
"mime-types": "^2.1.35",
73+
"mime": "^4.0.4",
7574
"ts-command-line-args": "^2.5.1"
7675
}
7776
}

src/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { mkdirSync, writeFileSync } from 'node:fs';
44
import path from 'node:path';
55
import { gzipSync } from 'node:zlib';
66

7-
import { lookup } from 'mime-types';
7+
import mime from 'mime';
88

99
import { cmdLine } from './commandLine';
1010
import { greenLog, yellowLog } from './consoleColor';
@@ -31,7 +31,7 @@ console.log();
3131
console.log('Translation to header file');
3232
const longestFilename = [...files.keys()].reduce((p, c) => Math.max(c.length, p), 0);
3333
for (const [originalFilename, content] of files) {
34-
const mime = lookup(originalFilename) || 'text/plain';
34+
const mimeType = mime.getType(originalFilename) || 'text/plain';
3535
summary.filecount++;
3636

3737
const filename = originalFilename.replace(/\\/g, '/');
@@ -56,7 +56,7 @@ for (const [originalFilename, content] of files) {
5656
content,
5757
contentGzip: zipContent,
5858
isGzip: true,
59-
mime,
59+
mime: mimeType,
6060
md5
6161
});
6262
console.log(
@@ -72,7 +72,7 @@ for (const [originalFilename, content] of files) {
7272
content,
7373
contentGzip: content,
7474
isGzip: false,
75-
mime,
75+
mime: mimeType,
7676
md5
7777
});
7878
console.log(

0 commit comments

Comments
 (0)