@cjser/jpegoptim-bin 7.1.0-cjser.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cli.js ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+ import {spawn} from 'node:child_process';
3
+ import process from 'node:process';
4
+ import jpegoptim from './index.js';
5
+
6
+ const input = process.argv.slice(2);
7
+
8
+ spawn(jpegoptim, input, {stdio: 'inherit'})
9
+ .on('exit', process.exit);
@@ -0,0 +1,48 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // packages/@cjser/jpegoptim-bin.tmp-26-1778152071430/index.js
30
+ var index_exports = {};
31
+ __export(index_exports, {
32
+ default: () => index_default
33
+ });
34
+ module.exports = __toCommonJS(index_exports);
35
+
36
+ // packages/@cjser/jpegoptim-bin.tmp-26-1778152071430/lib/index.js
37
+ var import_node_fs = __toESM(require("node:fs"), 1);
38
+ var import_node_process = __toESM(require("node:process"), 1);
39
+ var import_node_url = require("node:url");
40
+ var import_bin_wrapper = __toESM(require("bin-wrapper"), 1);
41
+ var import_meta = {};
42
+ var pkg = JSON.parse(import_node_fs.default.readFileSync(new URL("../package.json", import_meta.url)));
43
+ var url = `https://raw.githubusercontent.com/imagemin/jpegoptim-bin/v${pkg.version}/vendor/`;
44
+ var binWrapper = new import_bin_wrapper.default().src(`${url}osx/jpegoptim`, "darwin").src(`${url}linux/jpegoptim`, "linux").src(`${url}win32/jpegoptim.exe`, "win32").dest((0, import_node_url.fileURLToPath)(new URL("../vendor", import_meta.url))).use(import_node_process.default.platform === "win32" ? "jpegoptim.exe" : "jpegoptim");
45
+ var lib_default = binWrapper;
46
+
47
+ // packages/@cjser/jpegoptim-bin.tmp-26-1778152071430/index.js
48
+ var index_default = lib_default.path();
package/index.js ADDED
@@ -0,0 +1,3 @@
1
+ import lib from './lib/index.js';
2
+
3
+ export default lib.path();
package/lib/index.js ADDED
@@ -0,0 +1,16 @@
1
+ import fs from 'node:fs';
2
+ import process from 'node:process';
3
+ import {fileURLToPath} from 'node:url';
4
+ import BinWrapper from 'bin-wrapper';
5
+
6
+ const pkg = JSON.parse(fs.readFileSync(new URL('../package.json', import.meta.url)));
7
+ const url = `https://raw.githubusercontent.com/imagemin/jpegoptim-bin/v${pkg.version}/vendor/`;
8
+
9
+ const binWrapper = new BinWrapper()
10
+ .src(`${url}osx/jpegoptim`, 'darwin')
11
+ .src(`${url}linux/jpegoptim`, 'linux')
12
+ .src(`${url}win32/jpegoptim.exe`, 'win32')
13
+ .dest(fileURLToPath(new URL('../vendor', import.meta.url)))
14
+ .use(process.platform === 'win32' ? 'jpegoptim.exe' : 'jpegoptim');
15
+
16
+ export default binWrapper;
package/lib/install.js ADDED
@@ -0,0 +1,25 @@
1
+ import process from 'node:process';
2
+ import binBuild from 'bin-build';
3
+ import bin from './index.js';
4
+
5
+ bin.run(['--version']).then(() => {
6
+ console.log('jpegoptim pre-build test passed successfully');
7
+ }).catch(async error => {
8
+ console.warn(error.message);
9
+ console.warn('jpegoptim pre-build test failed');
10
+ console.info('compiling from source');
11
+
12
+ try {
13
+ await binBuild.url('https://github.com/tjko/jpegoptim/archive/RELEASE.1.4.6.tar.gz', [
14
+ `./configure --prefix="${bin.dest()}" --bindir="${bin.dest()}"`,
15
+ 'make install',
16
+ ]);
17
+
18
+ console.log('jpegoptim built successfully');
19
+ } catch (error) {
20
+ console.error(error.stack);
21
+
22
+ // eslint-disable-next-line unicorn/no-process-exit
23
+ process.exit(1);
24
+ }
25
+ });
package/license ADDED
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) Imagemin
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/package.json ADDED
@@ -0,0 +1,99 @@
1
+ {
2
+ "name": "@cjser/jpegoptim-bin",
3
+ "version": "7.1.0-cjser.2",
4
+ "description": "jpegoptim wrapper that makes it seamlessly available as a local dependency",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://code.moenext.com/3rdeye/cjser.git"
9
+ },
10
+ "type": "module",
11
+ "exports": {
12
+ "require": "./dist-cjser/index.cjs",
13
+ "default": "./index.js"
14
+ },
15
+ "author": {
16
+ "name": "Shogo Sensui",
17
+ "email": "shogosensui@gmail.com",
18
+ "url": "github.com/1000ch"
19
+ },
20
+ "maintainers": [
21
+ {
22
+ "name": "Sindre Sorhus",
23
+ "email": "sindresorhus@gmail.com",
24
+ "url": "sindresorhus.com"
25
+ },
26
+ {
27
+ "name": "Kevin Mårtensson",
28
+ "email": "kevinmartensson@gmail.com",
29
+ "url": "github.com/kevva"
30
+ },
31
+ {
32
+ "name": "Shinnosuke Watanabe",
33
+ "url": "github.com/shinnn"
34
+ }
35
+ ],
36
+ "bin": {
37
+ "jpegoptim": "cli.js"
38
+ },
39
+ "engines": {
40
+ "node": "^12.20.0 || ^14.13.1 || >=16.0.0"
41
+ },
42
+ "scripts": {
43
+ "postinstall": "node lib/install.js",
44
+ "test": "xo && ava --timeout=120s"
45
+ },
46
+ "files": [
47
+ "cli.js",
48
+ "index.js",
49
+ "lib",
50
+ "dist-cjser"
51
+ ],
52
+ "keywords": [
53
+ "compress",
54
+ "imagemin",
55
+ "image",
56
+ "img",
57
+ "jpeg",
58
+ "jpg",
59
+ "minify",
60
+ "optimize",
61
+ "jpegoptim"
62
+ ],
63
+ "dependencies": {
64
+ "bin-build": "^3.0.0",
65
+ "bin-wrapper": "^4.0.0"
66
+ },
67
+ "devDependencies": {
68
+ "ava": "^3.15.0",
69
+ "bin-check": "^4.0.1",
70
+ "compare-size": "^3.0.0",
71
+ "execa": "^5.1.1",
72
+ "tempy": "^2.0.0",
73
+ "xo": "^0.45.0"
74
+ },
75
+ "main": "./dist-cjser/index.cjs",
76
+ "cjser": {
77
+ "sourceVersion": "7.1.0",
78
+ "cjserVersion": 2,
79
+ "original": {
80
+ "name": "jpegoptim-bin",
81
+ "version": "7.1.0",
82
+ "exports": "./index.js",
83
+ "repository": "imagemin/jpegoptim-bin",
84
+ "dependencies": {
85
+ "bin-build": "^3.0.0",
86
+ "bin-wrapper": "^4.0.0"
87
+ },
88
+ "files": [
89
+ "cli.js",
90
+ "index.js",
91
+ "lib"
92
+ ],
93
+ "scripts": {
94
+ "postinstall": "node lib/install.js",
95
+ "test": "xo && ava --timeout=120s"
96
+ }
97
+ }
98
+ }
99
+ }
package/readme.md ADDED
@@ -0,0 +1,58 @@
1
+ # jpegoptim-bin ![GitHub Actions Status](https://github.com/imagemin/jpegoptim-bin/workflows/test/badge.svg?branch=main)
2
+
3
+
4
+ > [jpegoptim](https://github.com/tjko/jpegoptim) is a utility for optimizing JPEG files that provides lossless optimization (based on optimizing the Huffman tables) and "lossy" optimization based on setting a maximum quality factor
5
+
6
+ You probably want [`imagemin-jpegoptim`](https://github.com/imagemin/imagemin-jpegoptim) instead.
7
+
8
+
9
+ ## Install
10
+
11
+ ```
12
+ $ npm install jpegoptim-bin
13
+ ```
14
+
15
+ Make sure you have the correct version of libjpeg. See [jpegoptim's README](https://github.com/tjko/jpegoptim#readme) for more information.
16
+
17
+
18
+ ## Usage
19
+
20
+ ```js
21
+ import {execFile} from 'child_process';
22
+ import jpegoptim from 'jpegoptim-bin';
23
+
24
+ const args = [
25
+ '--overwrite',
26
+ '--strip-all',
27
+ '--strip-iptc',
28
+ '--strip-icc',
29
+ '--all-progressive',
30
+ '--dest=build',
31
+ 'input.jpg'
32
+ ];
33
+
34
+ execFile(jpegoptim, args, error => {
35
+ console.log('Image minified');
36
+ });
37
+ ```
38
+
39
+
40
+ ## CLI
41
+
42
+ ```
43
+ $ npm install --global jpegoptim-bin
44
+ ```
45
+
46
+ ```
47
+ $ jpegoptim --help
48
+ ```
49
+
50
+
51
+ ## License
52
+
53
+ MIT © [Imagemin](https://github.com/imagemin)
54
+
55
+ ## cjser
56
+
57
+ This package is a CommonJS-compatible build generated by cjser for projects that still need `require()` support. The source version matches the original npm package version, with a cjser prerelease suffix for this generated build.
58
+ Original repository: https://github.com/imagemin/jpegoptim-bin