diff --git a/.github/workflows/ci-dev.yaml b/.github/workflows/ci-dev.yaml index 2c5c7b6..07f2012 100644 --- a/.github/workflows/ci-dev.yaml +++ b/.github/workflows/ci-dev.yaml @@ -7,16 +7,28 @@ on: jobs: check: - name: Source revision + name: Source Revision runs-on: ubuntu-latest + strategy: + matrix: + node-version: [22.x, 20.x, 18.x] steps: - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: - node-version: '20.17.0' + node-version: ${{ matrix.node-version }} + cache: 'npm' + + - name: Install Dependencies + run: npm ci + + - name: Run Format Check + run: npm run format:check + + - name: Run Lint Check + run: npm run lint:check - - run: npm ci - - run: npm run format:check - - run: npm run lint:check - - run: npm run build + - name: Build + run: npm run build diff --git a/.github/workflows/ci-full.yaml b/.github/workflows/ci-full.yaml index c403c79..4a74fe6 100644 --- a/.github/workflows/ci-full.yaml +++ b/.github/workflows/ci-full.yaml @@ -7,19 +7,31 @@ on: jobs: check: - name: Source revision + name: Source Revision runs-on: ubuntu-latest + strategy: + matrix: + node-version: [22.x, 20.x, 18.x] steps: - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 with: - node-version: '20.17.0' + node-version: ${{ matrix.node-version }} + cache: 'npm' + + - name: Install Dependencies + run: npm ci + + - name: Run Format Check + run: npm run format:check + + - name: Run Lint Check + run: npm run lint:check - - run: npm ci - - run: npm run format:check - - run: npm run lint:check - - run: npm run build + - name: Build + run: npm run build tag: name: Version tag @@ -47,10 +59,16 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: - node-version: '20.16.0' - registry-url: 'https://registry.npmjs.org' - - run: npm ci - - run: npm run build - - run: npm publish + node-version: '22' + cache: 'npm' + + - name: Install Dependencies + run: npm ci + + - name: Build + run: npm run build + + - name: Publish + run: npm publish env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/CHANGELOG.md b/CHANGELOG.md index c82b7ce..6d914a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Change log +## 1.6 + +### 1.6.0 + +- Using mime npm package instead of mime-types: I prefer to use standard text/javascript. It better meets today's requirements. + ## 1.5 ### 1.5.2 diff --git a/README.md b/README.md index a91cb5e..718b86e 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,8 @@ In order to be able to easily update OTA, it is important - from the users' poin 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**. +> Starting with version v1.6.0, mime npm package is used instead of mime-types (application/javascript -> text/javascript) + > Starting with version v1.5.0, PsychicHttp v2 is also supported. > 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. diff --git a/package-lock.json b/package-lock.json index 56d032b..e0081a3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,24 +1,23 @@ { "name": "svelteesp32", - "version": "1.5.2", + "version": "1.6.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "svelteesp32", - "version": "1.5.2", + "version": "1.6.0", "license": "ISC", "dependencies": { "glob": "^11.0.0", "handlebars": "^4.7.8", - "mime-types": "^2.1.35", + "mime": "^4.0.4", "ts-command-line-args": "^2.5.1" }, "bin": { "svelteesp32": "bin/index.js" }, "devDependencies": { - "@types/mime-types": "^2.1.4", "@types/node": "^22.10.1", "@typescript-eslint/eslint-plugin": "^8.17.0", "@typescript-eslint/parser": "^8.17.0", @@ -836,13 +835,6 @@ "dev": true, "license": "MIT" }, - "node_modules/@types/mime-types": { - "version": "2.1.4", - "resolved": "https://registry.npmjs.org/@types/mime-types/-/mime-types-2.1.4.tgz", - "integrity": "sha512-lfU4b34HOri+kAY5UheuFMWPDOI+OPceBSHZKp69gEyTL/mmJ4cnU6Y/rlme3UL3GyOn6Y42hyIEw0/q8sWx5w==", - "dev": true, - "license": "MIT" - }, "node_modules/@types/node": { "version": "22.10.1", "resolved": "https://registry.npmjs.org/@types/node/-/node-22.10.1.tgz", @@ -2630,25 +2622,19 @@ "node": ">=8.6" } }, - "node_modules/mime-db": { - "version": "1.52.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", - "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", - "license": "MIT", - "engines": { - "node": ">= 0.6" - } - }, - "node_modules/mime-types": { - "version": "2.1.35", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", - "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "node_modules/mime": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/mime/-/mime-4.0.4.tgz", + "integrity": "sha512-v8yqInVjhXyqP6+Kw4fV3ZzeMRqEW6FotRsKXjRS5VMTNIuXsdRoAvklpoRgSqXm6o9VNH4/C0mgedko9DdLsQ==", + "funding": [ + "https://github.com/sponsors/broofa" + ], "license": "MIT", - "dependencies": { - "mime-db": "1.52.0" + "bin": { + "mime": "bin/cli.js" }, "engines": { - "node": ">= 0.6" + "node": ">=16" } }, "node_modules/min-indent": { diff --git a/package.json b/package.json index fa1417a..d2790d4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "svelteesp32", - "version": "1.5.2", + "version": "1.6.0", "description": "Convert Svelte (or any frontend) JS application to serve it from ESP32 webserver (PsychicHttp)", "author": "BCsabaEngine", "license": "ISC", @@ -54,7 +54,6 @@ "espasyncwebserver" ], "devDependencies": { - "@types/mime-types": "^2.1.4", "@types/node": "^22.10.1", "@typescript-eslint/eslint-plugin": "^8.17.0", "@typescript-eslint/parser": "^8.17.0", @@ -71,7 +70,7 @@ "dependencies": { "glob": "^11.0.0", "handlebars": "^4.7.8", - "mime-types": "^2.1.35", + "mime": "^4.0.4", "ts-command-line-args": "^2.5.1" } } diff --git a/src/index.ts b/src/index.ts index 810d500..574ce20 100644 --- a/src/index.ts +++ b/src/index.ts @@ -4,7 +4,7 @@ import { mkdirSync, writeFileSync } from 'node:fs'; import path from 'node:path'; import { gzipSync } from 'node:zlib'; -import { lookup } from 'mime-types'; +import mime from 'mime'; import { cmdLine } from './commandLine'; import { greenLog, yellowLog } from './consoleColor'; @@ -31,7 +31,7 @@ console.log(); console.log('Translation to header file'); const longestFilename = [...files.keys()].reduce((p, c) => Math.max(c.length, p), 0); for (const [originalFilename, content] of files) { - const mime = lookup(originalFilename) || 'text/plain'; + const mimeType = mime.getType(originalFilename) || 'text/plain'; summary.filecount++; const filename = originalFilename.replace(/\\/g, '/'); @@ -56,7 +56,7 @@ for (const [originalFilename, content] of files) { content, contentGzip: zipContent, isGzip: true, - mime, + mime: mimeType, md5 }); console.log( @@ -72,7 +72,7 @@ for (const [originalFilename, content] of files) { content, contentGzip: content, isGzip: false, - mime, + mime: mimeType, md5 }); console.log(