diff --git a/package.json b/package.json index b5372eb6c..f62955460 100644 --- a/package.json +++ b/package.json @@ -57,7 +57,6 @@ "cac": "^6.7.14", "cli-progress": "3.11.2", "colorette": "2.0.19", - "ejs": "^3.1.9", "express": "^4.18.2", "got": "12.3.1", "inquirer": "^9.2.9", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d3ef5625e..632b4d24b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -14,9 +14,6 @@ dependencies: colorette: specifier: 2.0.19 version: 2.0.19 - ejs: - specifier: ^3.1.9 - version: 3.1.9 express: specifier: ^4.18.2 version: 4.18.2 @@ -3463,10 +3460,6 @@ packages: lodash: 4.17.21 dev: false - /async@3.2.5: - resolution: {integrity: sha512-baNZyqaaLhyLVKm/DlvdW051MSgO6b8eVfIezl9E5PqWxFgzLm/wQntEW4zOytVburDEr0JlALEpdOFwvErLsg==} - dev: false - /available-typed-arrays@1.0.5: resolution: {integrity: sha512-DMD0KiN46eipeziST1LPP/STfDU0sufISXmjSgvVsoU2tqxctQeASejWcfNtxYKqETM1UxQ8sp2OrSBWpHY6sw==} engines: {node: '>= 0.4'} @@ -3514,6 +3507,7 @@ packages: /balanced-match@1.0.2: resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==} + dev: true /base64-js@1.5.1: resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==} @@ -3597,12 +3591,7 @@ packages: dependencies: balanced-match: 1.0.2 concat-map: 0.0.1 - - /brace-expansion@2.0.1: - resolution: {integrity: sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==} - dependencies: - balanced-match: 1.0.2 - dev: false + dev: true /braces@3.0.2: resolution: {integrity: sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==} @@ -3954,6 +3943,7 @@ packages: /concat-map@0.0.1: resolution: {integrity: sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=} + dev: true /config-chain@1.1.13: resolution: {integrity: sha512-qj+f8APARXHrM0hraqXYb2/bOVSV4PvJQlNZ/DVj0QrmNM2q2euizkeuVckQ57J+W0mRH6Hvi+k50M4Jul2VRQ==} @@ -4300,14 +4290,6 @@ packages: /ee-first@1.1.1: resolution: {integrity: sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==} - /ejs@3.1.9: - resolution: {integrity: sha512-rC+QVNMJWv+MtPgkt0y+0rVEIdbtxVADApW9JXrUVlzHetgcyczP/E7DJmWJ4fJCZF2cPcBk0laWO9ZHMG3DmQ==} - engines: {node: '>=0.10.0'} - hasBin: true - dependencies: - jake: 10.8.7 - dev: false - /electron-to-chromium@1.4.477: resolution: {integrity: sha512-shUVy6Eawp33dFBFIoYbIwLHrX0IZ857AlH9ug2o4rvbWmpaCUdBpQ5Zw39HRrfzAFm4APJE9V+E2A/WB0YqJw==} dev: true @@ -5453,12 +5435,6 @@ packages: engines: {node: '>= 6'} dev: true - /filelist@1.0.4: - resolution: {integrity: sha512-w1cEuf3S+DrLCQL7ET6kz+gmlJdbq9J7yXCSjK/OZCPA+qEN1WyF4ZAf0YYJa4/shHJra2t/d/r8SV4Ji+x+8Q==} - dependencies: - minimatch: 5.1.6 - dev: false - /fill-range@7.0.1: resolution: {integrity: sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==} engines: {node: '>=8'} @@ -6423,17 +6399,6 @@ packages: /isexe@2.0.0: resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} - /jake@10.8.7: - resolution: {integrity: sha512-ZDi3aP+fG/LchyBzUM804VjddnwfSfsdeYkwt8NcbKRvo4rFkjhs456iLFn3k2ZUWvNe4i48WACDbza8fhq2+w==} - engines: {node: '>=10'} - hasBin: true - dependencies: - async: 3.2.5 - chalk: 4.1.2 - filelist: 1.0.4 - minimatch: 3.1.2 - dev: false - /javascript-stringify@2.1.0: resolution: {integrity: sha512-JVAfqNPTvNq3sB/VHQJAFxN/sPgKnsKrCwyRt15zwNCdrMMJDdcEOdubuy+DuJYYdm0ox1J4uzEuYKkN+9yhVg==} dev: true @@ -7228,13 +7193,7 @@ packages: resolution: {integrity: sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==} dependencies: brace-expansion: 1.1.11 - - /minimatch@5.1.6: - resolution: {integrity: sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==} - engines: {node: '>=10'} - dependencies: - brace-expansion: 2.0.1 - dev: false + dev: true /minimist@1.2.8: resolution: {integrity: sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==} diff --git a/src/qrcode/index.ts b/src/qrcode/index.ts index cce18f4ba..f62cc23ca 100644 --- a/src/qrcode/index.ts +++ b/src/qrcode/index.ts @@ -1,7 +1,7 @@ import { fileURLToPath } from 'node:url' import { resolve, dirname, join } from 'node:path' import { pipeline } from 'node:stream/promises' -import { existsSync, mkdirSync, createWriteStream } from 'node:fs' +import { existsSync, mkdirSync, createWriteStream, readFileSync } from 'node:fs' import got from 'got' import portfinder from 'portfinder' import qrcode from 'qrcode-terminal' @@ -39,10 +39,17 @@ const config = { } export default async (options: CommandOptions) => { - const { port, open: isOpen, path, lyric: withLyric, base = '' } = options const app = express() + let { port, open: isOpen, path, lyric: withLyric, base = '' } = options - app.set('view engine', 'ejs') + const indexPath = resolve( + __dirname, + process.env.IS_DEV === 'true' ? '../../views/index.html' : '../views/index.html' + ) + + let htmlContent = readFileSync(indexPath, 'utf8') + + htmlContent = htmlContent.replace(/{{base}}/g, base?.length ? `/${base}` : '') app.use( `/${base}`, @@ -50,12 +57,7 @@ export default async (options: CommandOptions) => { ) app.get(`/${base}`, (_, res) => { - res.render( - resolve(__dirname, process.env.IS_DEV === 'true' ? '../../views/index' : '../views/index'), - { - base, - } - ) + res.send(htmlContent) }) app.get( diff --git a/views/index.ejs b/views/index.html similarity index 95% rename from views/index.ejs rename to views/index.html index 39f329d41..129d6be8e 100644 --- a/views/index.ejs +++ b/views/index.html @@ -5,11 +5,11 @@ Music Player - - + + - +