diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 77f8e81..13392e5 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -74,7 +74,7 @@ jobs: run: | binary_name="$(node -e 'console.log([process.platform, process.arch, process.versions.modules].join("__"))')" b2 authorize-account ${{ secrets.CICD_CLI_B2_KEY_ID }} ${{ secrets.CICD_CLI_B2_APPLICATION_KEY }} - b2 upload-file ${{ secrets.CICD_CLI_B2_BUCKET_NAME }} ./nodejs/dist/native.node.gz "minify-html/bin/nodejs/${{ steps.version.outputs.VERSION }}/$binary_name.node.gz" + b2 upload-file ${{ secrets.CICD_CLI_B2_BUCKET_NAME }} ./nodejs/dist/index.node.gz "minify-html/bin/nodejs/${{ steps.version.outputs.VERSION }}/$binary_name.node.gz" package: runs-on: ubuntu-latest needs: build diff --git a/nodejs/compress.js b/nodejs/compress.js index 88e75f0..719686e 100644 --- a/nodejs/compress.js +++ b/nodejs/compress.js @@ -2,6 +2,6 @@ const {readFileSync, writeFileSync} = require('fs'); const {join} = require('path'); const {gzipSync} = require('zlib'); -const src = readFileSync(join(__dirname, 'dist', 'native.node')); +const src = readFileSync(join(__dirname, 'dist', 'index.node')); const out = gzipSync(src); -writeFileSync(join(__dirname, 'dist', 'native.node.gz'), out); +writeFileSync(join(__dirname, 'dist', 'index.node.gz'), out); diff --git a/nodejs/package.json b/nodejs/package.json index 6c9e79d..d4a6bce 100644 --- a/nodejs/package.json +++ b/nodejs/package.json @@ -2,15 +2,12 @@ "name": "@minify-html/js", "version": "0.2.6", "description": "Fast and smart HTML + JS minifier", - "main": "dist/index.js", + "main": "dist/index.node", "files": [ - "dist/**", "postinstall.js" ], "scripts": { - "build": "npm run clean && tsc", - "build-binary": "neon build --release && mkdir -p dist && mv native/index.node dist/native.node", - "clean": "rm -rf dist", + "build": "neon build --release && mkdir -p dist && mv native/index.node dist/index.node", "postinstall": "node postinstall.js" }, "repository": { @@ -28,9 +25,7 @@ }, "homepage": "https://github.com/wilsonzlin/minify-html#readme", "devDependencies": { - "@types/node": "^14.0.22", - "neon-cli": "^0.4.0", - "typescript": "^3.9.6" + "neon-cli": "^0.4.0" }, "keywords": [ "build", diff --git a/nodejs/postinstall.js b/nodejs/postinstall.js index 6a67ed1..aaa4546 100644 --- a/nodejs/postinstall.js +++ b/nodejs/postinstall.js @@ -7,7 +7,7 @@ const pkg = require('./package.json'); const MAX_DOWNLOAD_ATTEMPTS = 4; const binaryName = [process.platform, process.arch, process.versions.modules].join('__'); -const binaryPath = path.join(__dirname, 'dist', 'native.node'); +const binaryPath = path.join(__dirname, 'dist', 'index.node'); const wait = ms => new Promise(resolve => setTimeout(resolve, ms)); diff --git a/nodejs/src/index.ts b/nodejs/src/index.ts deleted file mode 100644 index 50d68f7..0000000 --- a/nodejs/src/index.ts +++ /dev/null @@ -1,17 +0,0 @@ -const native = require(`./native.node`); - -export type Configuration = { - minifyJs: boolean; -}; - -export const minify = (code: string, cfg: Configuration): string => { - const buf = Buffer.from(code); - const len = native.minify(buf, cfg); - return buf.slice(0, len).toString(); -}; - -export const minifyInPlace = (buf: Buffer, cfg: Configuration): Buffer => { - const len = native.minify(buf, cfg); - // This does not do a copy. - return buf.slice(0, len); -}; diff --git a/nodejs/tsconfig.json b/nodejs/tsconfig.json deleted file mode 100644 index 45a9c92..0000000 --- a/nodejs/tsconfig.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "include": [ - "src/**/*.ts" - ], - "compilerOptions": { - "allowJs": false, - "alwaysStrict": true, - "declaration": true, - "esModuleInterop": true, - "lib": [ - "es5", - "es6", - "es7", - "es2017" - ], - "module": "commonjs", - "noFallthroughCasesInSwitch": true, - "noImplicitAny": true, - "noImplicitReturns": true, - "noImplicitThis": true, - "noUnusedParameters": true, - "outDir": "dist", - "skipLibCheck": true, - "strict": true, - "strictFunctionTypes": true, - "strictNullChecks": true, - "strictPropertyInitialization": true, - "suppressImplicitAnyIndexErrors": true, - "target": "es6" - } -} -