Remove core variant
This commit is contained in:
parent
c7d0652fbc
commit
ec8c4e338a
|
@ -40,9 +40,7 @@ jobs:
|
||||||
|
|
||||||
- name: Set up Node.js module
|
- name: Set up Node.js module
|
||||||
working-directory: ./nodejs
|
working-directory: ./nodejs
|
||||||
run: |
|
run: npm install
|
||||||
node package.json.gen.js js
|
|
||||||
npm install
|
|
||||||
|
|
||||||
- name: Build bench
|
- name: Build bench
|
||||||
working-directory: ./bench
|
working-directory: ./bench
|
||||||
|
|
|
@ -11,7 +11,6 @@ jobs:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
feature: [core, js]
|
|
||||||
os: [macos-11.0, ubuntu-18.04, windows-2019, self-hosted-linux-arm64, self-hosted-macos-arm64]
|
os: [macos-11.0, ubuntu-18.04, windows-2019, self-hosted-linux-arm64, self-hosted-macos-arm64]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v1
|
||||||
|
@ -54,7 +53,6 @@ jobs:
|
||||||
id: module
|
id: module
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
node package.json.gen.js ${{ matrix.feature }}
|
|
||||||
npm install
|
npm install
|
||||||
npm run build
|
npm run build
|
||||||
node compress.js
|
node compress.js
|
||||||
|
@ -70,9 +68,6 @@ jobs:
|
||||||
file: ./nodejs/index.node.gz
|
file: ./nodejs/index.node.gz
|
||||||
|
|
||||||
package:
|
package:
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
feature: [core, js]
|
|
||||||
runs-on: ubuntu-18.04
|
runs-on: ubuntu-18.04
|
||||||
needs: build
|
needs: build
|
||||||
steps:
|
steps:
|
||||||
|
@ -93,7 +88,6 @@ jobs:
|
||||||
//registry.npmjs.org/:_authToken=${{ secrets.NPM_AUTH_TOKEN }}
|
//registry.npmjs.org/:_authToken=${{ secrets.NPM_AUTH_TOKEN }}
|
||||||
EOF
|
EOF
|
||||||
cp ../README.md .
|
cp ../README.md .
|
||||||
node package.json.gen.js ${{ matrix.feature }}
|
|
||||||
if [[ "${{ steps.version.outputs.VERSION }}" != "0.0.0" ]]; then
|
if [[ "${{ steps.version.outputs.VERSION }}" != "0.0.0" ]]; then
|
||||||
npm publish --access public
|
npm publish --access public
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -11,7 +11,6 @@ jobs:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
feature: [core, js]
|
|
||||||
os: [macos-11.0, ubuntu-18.04, windows-2019, self-hosted-linux-arm64, self-hosted-macos-arm64]
|
os: [macos-11.0, ubuntu-18.04, windows-2019, self-hosted-linux-arm64, self-hosted-macos-arm64]
|
||||||
python: [3.8, 3.9, '3.10']
|
python: [3.8, 3.9, '3.10']
|
||||||
steps:
|
steps:
|
||||||
|
@ -61,9 +60,7 @@ jobs:
|
||||||
|
|
||||||
- name: Build native module
|
- name: Build native module
|
||||||
working-directory: ./python
|
working-directory: ./python
|
||||||
run: |
|
run: cargo build --release
|
||||||
python prepare.py ${{ matrix.feature }}
|
|
||||||
cargo build --release
|
|
||||||
|
|
||||||
- name: Install Python build tools (macOS x64)
|
- name: Install Python build tools (macOS x64)
|
||||||
if: runner.os == 'macOS' && runner.name != 'macos-arm64'
|
if: runner.os == 'macOS' && runner.name != 'macos-arm64'
|
||||||
|
@ -103,7 +100,7 @@ jobs:
|
||||||
else
|
else
|
||||||
pathToPython="$(which python)"
|
pathToPython="$(which python)"
|
||||||
fi
|
fi
|
||||||
# On macOS ARM64 this may emit a warning like "Couldn't find the symbol `PyInit_minify_html_core` in the native library. Python will fail to import this module." Ignore this message.
|
# On macOS ARM64 this may emit a warning like "Couldn't find the symbol `PyInit_minify_html` in the native library. Python will fail to import this module." Ignore this message.
|
||||||
maturin build --release --strip -i "$pathToPython"
|
maturin build --release --strip -i "$pathToPython"
|
||||||
if [[ "$GITHUB_REF" == refs/tags/v* ]]; then
|
if [[ "$GITHUB_REF" == refs/tags/v* ]]; then
|
||||||
# For idempotency, ignore any existing built wheels that have already been successfully uploaded.
|
# For idempotency, ignore any existing built wheels that have already been successfully uploaded.
|
||||||
|
|
10
README.md
10
README.md
|
@ -67,7 +67,7 @@ Check out the [docs](https://docs.rs/minify-html) for API and usage examples.
|
||||||
<details>
|
<details>
|
||||||
<summary><img width="24" src="https://wilsonl.in/minify-html/icon/nodejs.png"> <strong>Node.js</strong></summary>
|
<summary><img width="24" src="https://wilsonl.in/minify-html/icon/nodejs.png"> <strong>Node.js</strong></summary>
|
||||||
|
|
||||||
- Package: [@minify-html/js](https://www.npmjs.com/package/@minify-html/js)
|
- Package: [@minify-html/node](https://www.npmjs.com/package/@minify-html/node)
|
||||||
- Binding: [N-API](https://nodejs.org/api/n-api.html)
|
- Binding: [N-API](https://nodejs.org/api/n-api.html)
|
||||||
- Platforms: Linux (ARM64 and x64), macOS (ARM64 and x64), Windows (x64); Node.js 8.6.0 and higher
|
- Platforms: Linux (ARM64 and x64), macOS (ARM64 and x64), Windows (x64); Node.js 8.6.0 and higher
|
||||||
|
|
||||||
|
@ -76,13 +76,13 @@ Check out the [docs](https://docs.rs/minify-html) for API and usage examples.
|
||||||
Using npm:
|
Using npm:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm i @minify-html/js
|
npm i @minify-html/node
|
||||||
```
|
```
|
||||||
|
|
||||||
Using Yarn:
|
Using Yarn:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
yarn add @minify-html/js
|
yarn add @minify-html/node
|
||||||
```
|
```
|
||||||
|
|
||||||
### Use
|
### Use
|
||||||
|
@ -90,8 +90,8 @@ yarn add @minify-html/js
|
||||||
TypeScript definitions are available.
|
TypeScript definitions are available.
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
import * as minifyHtml from "@minify-html/js";
|
import * as minifyHtml from "@minify-html/node";
|
||||||
// Or `const minifyHtml = require("@minify-html/js")` if not using TS/ESM.
|
// Or `const minifyHtml = require("@minify-html/node")` if not using TS/ESM.
|
||||||
|
|
||||||
const cfg = minifyHtml.createConfiguration({ keep_spaces_between_attributes: true, keep_comments: true });
|
const cfg = minifyHtml.createConfiguration({ keep_spaces_between_attributes: true, keep_comments: true });
|
||||||
const minified = minifyHtml.minify("<p> Hello, world! </p>", cfg);
|
const minified = minifyHtml.minify("<p> Hello, world! </p>", cfg);
|
||||||
|
|
|
@ -24,7 +24,11 @@ for r in *; do
|
||||||
echo "Running $r..."
|
echo "Running $r..."
|
||||||
pushd "$r" >/dev/null
|
pushd "$r" >/dev/null
|
||||||
out="$results_dir/$r.json"
|
out="$results_dir/$r.json"
|
||||||
sudo --preserve-env=MHB_HTML_ONLY,PATH MHB_ITERATIONS="$iterations" MHB_INPUT_DIR="$input_dir" RUST_BACKTRACE=1 nice -n -20 taskset -c 1 ./run >"$out"
|
if [[ "$(uname -s)" = "Darwin" ]]; then
|
||||||
|
MHB_ITERATIONS="$iterations" MHB_INPUT_DIR="$input_dir" RUST_BACKTRACE=1 ./run >"$out"
|
||||||
|
else
|
||||||
|
sudo --preserve-env=MHB_HTML_ONLY,PATH MHB_ITERATIONS="$iterations" MHB_INPUT_DIR="$input_dir" RUST_BACKTRACE=1 nice -n -20 taskset -c 1 ./run >"$out"
|
||||||
|
fi
|
||||||
popd >/dev/null
|
popd >/dev/null
|
||||||
done
|
done
|
||||||
popd >/dev/null
|
popd >/dev/null
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
{
|
|
||||||
"private": true,
|
|
||||||
"dependencies": {
|
|
||||||
"@minify-html/js": "file:../../../nodejs"
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,4 +1,4 @@
|
||||||
const minifyHtml = require("@minify-html/js");
|
const minifyHtml = require("@minify-html/node");
|
||||||
const { htmlOnly, run } = require("../common");
|
const { htmlOnly, run } = require("../common");
|
||||||
|
|
||||||
const minifyHtmlCfg = minifyHtml.createConfiguration({
|
const minifyHtmlCfg = minifyHtml.createConfiguration({
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"private": true,
|
||||||
|
"dependencies": {
|
||||||
|
"@minify-html/node": "file:../../../nodejs"
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,5 +3,4 @@
|
||||||
/native/Cargo.lock
|
/native/Cargo.lock
|
||||||
/native/target
|
/native/target
|
||||||
/package-lock.json
|
/package-lock.json
|
||||||
/package.json
|
|
||||||
node_modules/
|
node_modules/
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
const cp = require("child_process");
|
const cp = require("child_process");
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
const pkg = require("./package.json");
|
|
||||||
|
|
||||||
cp.spawnSync(
|
cp.spawnSync(
|
||||||
"cargo",
|
"cargo",
|
||||||
|
@ -9,8 +8,6 @@ cp.spawnSync(
|
||||||
"--manifest-path",
|
"--manifest-path",
|
||||||
path.join(__dirname, "native", "Cargo.toml"),
|
path.join(__dirname, "native", "Cargo.toml"),
|
||||||
"--release",
|
"--release",
|
||||||
"--features",
|
|
||||||
pkg.name.split("/")[1],
|
|
||||||
],
|
],
|
||||||
{
|
{
|
||||||
stdio: "inherit",
|
stdio: "inherit",
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
{
|
||||||
|
"name": "@minify-html/node",
|
||||||
|
"description": "Extremely fast and smart HTML + JS + CSS minifier",
|
||||||
|
"bin": {
|
||||||
|
"minify-html": "./cli.js"
|
||||||
|
},
|
||||||
|
"version": "0.8.1",
|
||||||
|
"main": "index.js",
|
||||||
|
"types": "index.d.ts",
|
||||||
|
"files": [
|
||||||
|
"cli.js",
|
||||||
|
"postinstall.js",
|
||||||
|
"index.d.ts",
|
||||||
|
"index.js"
|
||||||
|
],
|
||||||
|
"scripts": {
|
||||||
|
"build": "node-gyp build && shx mv build/Release/index.node index.node",
|
||||||
|
"clean": "cd native && cargo clean && cd .. && node-gyp clean && node-gyp configure && shx rm -f index.node",
|
||||||
|
"postinstall": "node postinstall.js"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/wilsonzlin/minify-html.git"
|
||||||
|
},
|
||||||
|
"author": {
|
||||||
|
"email": "npm@wilsonl.in",
|
||||||
|
"name": "Wilson Lin",
|
||||||
|
"url": "https://wilsonl.in/"
|
||||||
|
},
|
||||||
|
"license": "MIT",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/wilsonzlin/minify-html/issues"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 8.6.0"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/wilsonzlin/minify-html#readme",
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/node": "^14.6.0",
|
||||||
|
"node-gyp": "^7.0.0",
|
||||||
|
"shx": "^0.3.2"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"compress",
|
||||||
|
"compressor",
|
||||||
|
"fast",
|
||||||
|
"html",
|
||||||
|
"minifier",
|
||||||
|
"minify"
|
||||||
|
]
|
||||||
|
}
|
|
@ -1,66 +0,0 @@
|
||||||
const fs = require("fs");
|
|
||||||
|
|
||||||
const common = {
|
|
||||||
version: "0.8.1",
|
|
||||||
main: "index.js",
|
|
||||||
types: "index.d.ts",
|
|
||||||
files: ["cli.js", "postinstall.js", "index.d.ts", "index.js"],
|
|
||||||
scripts: {
|
|
||||||
build: "node-gyp build && shx mv build/Release/index.node index.node",
|
|
||||||
clean:
|
|
||||||
"cd native && cargo clean && cd .. && node-gyp clean && node-gyp configure && shx rm -f index.node",
|
|
||||||
postinstall: "node postinstall.js",
|
|
||||||
},
|
|
||||||
repository: {
|
|
||||||
type: "git",
|
|
||||||
url: "git+https://github.com/wilsonzlin/minify-html.git",
|
|
||||||
},
|
|
||||||
author: {
|
|
||||||
email: "npm@wilsonl.in",
|
|
||||||
name: "Wilson Lin",
|
|
||||||
url: "https://wilsonl.in/",
|
|
||||||
},
|
|
||||||
license: "MIT",
|
|
||||||
bugs: {
|
|
||||||
url: "https://github.com/wilsonzlin/minify-html/issues",
|
|
||||||
},
|
|
||||||
engines: {
|
|
||||||
node: ">= 8.6.0",
|
|
||||||
},
|
|
||||||
homepage: "https://github.com/wilsonzlin/minify-html#readme",
|
|
||||||
devDependencies: {
|
|
||||||
"@types/node": "^14.6.0",
|
|
||||||
"node-gyp": "^7.0.0",
|
|
||||||
shx: "^0.3.2",
|
|
||||||
},
|
|
||||||
keywords: ["compress", "compressor", "fast", "html", "minifier", "minify"],
|
|
||||||
};
|
|
||||||
|
|
||||||
const specifics = {
|
|
||||||
core: {
|
|
||||||
name: "@minify-html/core",
|
|
||||||
description: "Extremely fast and smart HTML minifier",
|
|
||||||
bin: {
|
|
||||||
"minify-html-core": "./cli.js",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
js: {
|
|
||||||
name: "@minify-html/js",
|
|
||||||
description: "Extremely fast and smart HTML + JS + CSS minifier",
|
|
||||||
bin: {
|
|
||||||
"minify-html": "./cli.js",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}[process.argv[2]];
|
|
||||||
|
|
||||||
fs.writeFileSync(
|
|
||||||
"package.json",
|
|
||||||
JSON.stringify(
|
|
||||||
{
|
|
||||||
...common,
|
|
||||||
...specifics,
|
|
||||||
},
|
|
||||||
null,
|
|
||||||
2
|
|
||||||
)
|
|
||||||
);
|
|
|
@ -1,15 +1,9 @@
|
||||||
/Cargo.lock
|
/Cargo.lock
|
||||||
/Cargo.toml
|
|
||||||
/src/lib.rs
|
|
||||||
/target/
|
/target/
|
||||||
|
|
||||||
__pycache__/
|
__pycache__/
|
||||||
/venv/
|
/venv/
|
||||||
|
|
||||||
# Ignore locally built native modules.
|
|
||||||
/hyperbuild/**/*.so
|
|
||||||
/hyperbuild/**/*.pyd
|
|
||||||
|
|
||||||
# Used by Python setuptools.
|
# Used by Python setuptools.
|
||||||
/build/
|
/build/
|
||||||
/dist/
|
/dist/
|
||||||
|
|
|
@ -1,21 +0,0 @@
|
||||||
[package]
|
|
||||||
publish = false
|
|
||||||
name = "minify_html_core"
|
|
||||||
description = "Extremely fast and smart HTML minifier"
|
|
||||||
license = "MIT"
|
|
||||||
homepage = "https://github.com/wilsonzlin/minify-html"
|
|
||||||
readme = "README.md"
|
|
||||||
repository = "https://github.com/wilsonzlin/minify-html.git"
|
|
||||||
version = "0.8.1"
|
|
||||||
authors = ["Wilson Lin <code@wilsonl.in>"]
|
|
||||||
edition = "2018"
|
|
||||||
|
|
||||||
[lib]
|
|
||||||
name = "minify_html_core"
|
|
||||||
crate-type = ["cdylib"]
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
minify-html = { path = "../rust/main", features = [] }
|
|
||||||
[dependencies.pyo3]
|
|
||||||
version = "0.13.0"
|
|
||||||
features = ["extension-module"]
|
|
|
@ -1,14 +0,0 @@
|
||||||
import shutil
|
|
||||||
import sys
|
|
||||||
|
|
||||||
feature = sys.argv[1]
|
|
||||||
|
|
||||||
module_name = "minify_html_core" if feature == "core" else "minify_html"
|
|
||||||
cargo_file = "Cargo.core.toml" if feature == "core" else "Cargo.js.toml"
|
|
||||||
|
|
||||||
with open("src/lib.template.rs", "r") as template:
|
|
||||||
actual = template.read().replace("REPLACE_WITH_MODULE_NAME", module_name)
|
|
||||||
with open("src/lib.rs", "w") as librs:
|
|
||||||
librs.write(actual)
|
|
||||||
|
|
||||||
shutil.copyfile(cargo_file, "Cargo.toml")
|
|
|
@ -1,4 +1,4 @@
|
||||||
use minify_html::{Cfg, minify as minify_html_native};
|
use minify_html::{minify as minify_html_native, Cfg};
|
||||||
use pyo3::prelude::*;
|
use pyo3::prelude::*;
|
||||||
use pyo3::wrap_pyfunction;
|
use pyo3::wrap_pyfunction;
|
||||||
use std::string::String;
|
use std::string::String;
|
||||||
|
@ -14,7 +14,7 @@ use std::string::String;
|
||||||
minify_css = "false",
|
minify_css = "false",
|
||||||
minify_js = "false",
|
minify_js = "false",
|
||||||
remove_bangs = "false",
|
remove_bangs = "false",
|
||||||
remove_processing_instructions = "false",
|
remove_processing_instructions = "false"
|
||||||
)]
|
)]
|
||||||
fn minify(
|
fn minify(
|
||||||
code: String,
|
code: String,
|
||||||
|
@ -30,23 +30,26 @@ fn minify(
|
||||||
remove_processing_instructions: bool,
|
remove_processing_instructions: bool,
|
||||||
) -> PyResult<String> {
|
) -> PyResult<String> {
|
||||||
let code = code.into_bytes();
|
let code = code.into_bytes();
|
||||||
let out_code = minify_html_native(&code, &Cfg {
|
let out_code = minify_html_native(
|
||||||
do_not_minify_doctype,
|
&code,
|
||||||
ensure_spec_compliant_unquoted_attribute_values,
|
&Cfg {
|
||||||
keep_closing_tags,
|
do_not_minify_doctype,
|
||||||
keep_comments,
|
ensure_spec_compliant_unquoted_attribute_values,
|
||||||
keep_html_and_head_opening_tags,
|
keep_closing_tags,
|
||||||
keep_spaces_between_attributes,
|
keep_comments,
|
||||||
minify_css,
|
keep_html_and_head_opening_tags,
|
||||||
minify_js,
|
keep_spaces_between_attributes,
|
||||||
remove_bangs,
|
minify_css,
|
||||||
remove_processing_instructions,
|
minify_js,
|
||||||
});
|
remove_bangs,
|
||||||
|
remove_processing_instructions,
|
||||||
|
},
|
||||||
|
);
|
||||||
Ok(String::from_utf8(out_code).unwrap())
|
Ok(String::from_utf8(out_code).unwrap())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[pymodule]
|
#[pymodule]
|
||||||
fn REPLACE_WITH_MODULE_NAME(_py: Python, m: &PyModule) -> PyResult<()> {
|
fn minify_html(_py: Python, m: &PyModule) -> PyResult<()> {
|
||||||
m.add_wrapped(wrap_pyfunction!(minify))?;
|
m.add_wrapped(wrap_pyfunction!(minify))?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
6
version
6
version
|
@ -103,7 +103,7 @@ for (const f of [
|
||||||
"cli/Cargo.toml",
|
"cli/Cargo.toml",
|
||||||
"nodejs/native/Cargo.toml",
|
"nodejs/native/Cargo.toml",
|
||||||
"java/Cargo.toml",
|
"java/Cargo.toml",
|
||||||
"python/Cargo.core.toml",
|
"python/Cargo.toml",
|
||||||
"python/Cargo.js.toml",
|
"python/Cargo.js.toml",
|
||||||
"ruby/Cargo.toml",
|
"ruby/Cargo.toml",
|
||||||
]) {
|
]) {
|
||||||
|
@ -146,10 +146,10 @@ for (const f of ["java/pom.xml", "README.md"]) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const f of ["nodejs/package.json.gen.js"]) {
|
for (const f of ["nodejs/package.json"]) {
|
||||||
replaceInFile(
|
replaceInFile(
|
||||||
f,
|
f,
|
||||||
/^(\s*version: )"\d+\.\d+\.\d+",\s*$/m,
|
/^(\s*"version": )"\d+\.\d+\.\d+",\s*$/m,
|
||||||
`$1"${NEW_VERSION}",`
|
`$1"${NEW_VERSION}",`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue