@node-minify/cli 9.0.1 → 10.0.0-next.0
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/dist/{cli.mjs → cli.js} +71 -72
- package/dist/cli.js.map +1 -0
- package/dist/index.cjs +154 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.js +18 -54
- package/dist/index.js.map +1 -1
- package/package.json +26 -25
- package/dist/cli.mjs.map +0 -1
- package/dist/index.mjs +0 -120
- package/dist/index.mjs.map +0 -1
- /package/dist/{cli.d.mts → cli.d.ts} +0 -0
- /package/dist/{index.d.mts → index.d.cts} +0 -0
package/dist/{cli.mjs → cli.js}
RENAMED
|
@@ -4,6 +4,77 @@
|
|
|
4
4
|
import { Command } from "commander";
|
|
5
5
|
import updateNotifier from "update-notifier";
|
|
6
6
|
|
|
7
|
+
// package.json
|
|
8
|
+
var package_default = {
|
|
9
|
+
name: "@node-minify/cli",
|
|
10
|
+
version: "10.0.0-next.0",
|
|
11
|
+
description: "CLI - command line interface for @node-minify",
|
|
12
|
+
keywords: [
|
|
13
|
+
"compressor",
|
|
14
|
+
"minify",
|
|
15
|
+
"minifier"
|
|
16
|
+
],
|
|
17
|
+
author: "Rodolphe Stoclin <srodolphe@gmail.com>",
|
|
18
|
+
homepage: "https://github.com/srod/node-minify/tree/main/packages/cli#readme",
|
|
19
|
+
license: "MIT",
|
|
20
|
+
type: "module",
|
|
21
|
+
bin: {
|
|
22
|
+
"node-minify": "dist/cli.js"
|
|
23
|
+
},
|
|
24
|
+
engines: {
|
|
25
|
+
node: ">=22.0.0"
|
|
26
|
+
},
|
|
27
|
+
directories: {
|
|
28
|
+
lib: "dist",
|
|
29
|
+
test: "__tests__"
|
|
30
|
+
},
|
|
31
|
+
main: "./dist/index.cjs",
|
|
32
|
+
exports: {
|
|
33
|
+
"./package.json": "./package.json",
|
|
34
|
+
".": {
|
|
35
|
+
import: "./dist/index.js",
|
|
36
|
+
default: "./dist/index.cjs"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
files: [
|
|
40
|
+
"bin",
|
|
41
|
+
"dist/**/*"
|
|
42
|
+
],
|
|
43
|
+
publishConfig: {
|
|
44
|
+
access: "public"
|
|
45
|
+
},
|
|
46
|
+
repository: {
|
|
47
|
+
type: "git",
|
|
48
|
+
url: "git+https://github.com/srod/node-minify.git"
|
|
49
|
+
},
|
|
50
|
+
bugs: {
|
|
51
|
+
url: "https://github.com/srod/node-minify/issues"
|
|
52
|
+
},
|
|
53
|
+
scripts: {
|
|
54
|
+
build: "tsup src/index.ts --format cjs,esm --dts && tsup src/bin/cli.ts --format esm --dts",
|
|
55
|
+
"check-exports": "attw --pack .",
|
|
56
|
+
"format:check": "biome check .",
|
|
57
|
+
lint: "biome lint .",
|
|
58
|
+
prepublishOnly: "bun run build",
|
|
59
|
+
test: "vitest run",
|
|
60
|
+
"test:ci": "vitest run --coverage",
|
|
61
|
+
"test:watch": "vitest"
|
|
62
|
+
},
|
|
63
|
+
dependencies: {
|
|
64
|
+
"@node-minify/core": "workspace:*",
|
|
65
|
+
"@node-minify/utils": "workspace:*",
|
|
66
|
+
chalk: "5.3.0",
|
|
67
|
+
commander: "12.1.0",
|
|
68
|
+
ora: "8.1.1",
|
|
69
|
+
"update-notifier": "7.3.1"
|
|
70
|
+
},
|
|
71
|
+
devDependencies: {
|
|
72
|
+
"@node-minify/types": "workspace:*",
|
|
73
|
+
"@types/chalk": "^2.2.4",
|
|
74
|
+
"@types/ora": "^3.2.0"
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
|
|
7
78
|
// src/index.ts
|
|
8
79
|
import chalk2 from "chalk";
|
|
9
80
|
|
|
@@ -116,77 +187,6 @@ var run = (cli) => {
|
|
|
116
187
|
});
|
|
117
188
|
};
|
|
118
189
|
|
|
119
|
-
// package.json
|
|
120
|
-
var package_default = {
|
|
121
|
-
name: "@node-minify/cli",
|
|
122
|
-
version: "9.0.1",
|
|
123
|
-
description: "CLI - command line interface for @node-minify",
|
|
124
|
-
keywords: [
|
|
125
|
-
"compressor",
|
|
126
|
-
"minify",
|
|
127
|
-
"minifier"
|
|
128
|
-
],
|
|
129
|
-
author: "Rodolphe Stoclin <srodolphe@gmail.com>",
|
|
130
|
-
homepage: "https://github.com/srod/node-minify/tree/master/packages/cli#readme",
|
|
131
|
-
license: "MIT",
|
|
132
|
-
bin: {
|
|
133
|
-
"node-minify": "dist/cli.mjs"
|
|
134
|
-
},
|
|
135
|
-
engines: {
|
|
136
|
-
node: ">=18.0.0"
|
|
137
|
-
},
|
|
138
|
-
directories: {
|
|
139
|
-
lib: "dist",
|
|
140
|
-
test: "__tests__"
|
|
141
|
-
},
|
|
142
|
-
main: "./dist/index.js",
|
|
143
|
-
module: "./dist/index.mjs",
|
|
144
|
-
types: "./dist/index.d.ts",
|
|
145
|
-
exports: {
|
|
146
|
-
".": {
|
|
147
|
-
types: "./dist/index.d.ts",
|
|
148
|
-
import: "./dist/index.mjs",
|
|
149
|
-
require: "./dist/index.cjs"
|
|
150
|
-
}
|
|
151
|
-
},
|
|
152
|
-
files: [
|
|
153
|
-
"bin",
|
|
154
|
-
"dist/**/*"
|
|
155
|
-
],
|
|
156
|
-
publishConfig: {
|
|
157
|
-
access: "public"
|
|
158
|
-
},
|
|
159
|
-
repository: {
|
|
160
|
-
type: "git",
|
|
161
|
-
url: "git+https://github.com/srod/node-minify.git"
|
|
162
|
-
},
|
|
163
|
-
bugs: {
|
|
164
|
-
url: "https://github.com/srod/node-minify/issues"
|
|
165
|
-
},
|
|
166
|
-
scripts: {
|
|
167
|
-
clean: "pnpm dlx rimraf dist",
|
|
168
|
-
build: "pnpm clean && tsup src/index.ts --format cjs,esm --dts --sourcemap && tsup src/bin/cli.ts --format esm --dts --sourcemap",
|
|
169
|
-
lint: "biome lint .",
|
|
170
|
-
prepublishOnly: "pnpm build",
|
|
171
|
-
test: "vitest run",
|
|
172
|
-
"test:ci": "vitest run --coverage",
|
|
173
|
-
"test:watch": "vitest"
|
|
174
|
-
},
|
|
175
|
-
dependencies: {
|
|
176
|
-
"@node-minify/core": "workspace:*",
|
|
177
|
-
"@node-minify/utils": "workspace:*",
|
|
178
|
-
chalk: "5.3.0",
|
|
179
|
-
commander: "12.1.0",
|
|
180
|
-
ora: "8.1.1",
|
|
181
|
-
"update-notifier": "7.3.1"
|
|
182
|
-
},
|
|
183
|
-
devDependencies: {
|
|
184
|
-
"@node-minify/types": "workspace:*",
|
|
185
|
-
"@types/chalk": "^2.2.0",
|
|
186
|
-
"@types/ora": "^3.2.0"
|
|
187
|
-
}
|
|
188
|
-
};
|
|
189
|
-
|
|
190
190
|
// src/bin/cli.ts
|
|
191
191
|
var program = new Command();
|
|
192
192
|
updateNotifier({ pkg: package_default }).notify();
|
|
@@ -225,4 +225,3 @@ run(options).then(() => process.exit()).catch((err) => {
|
|
|
225
225
|
* Copyright(c) 2011-2024 Rodolphe Stoclin
|
|
226
226
|
* MIT Licensed
|
|
227
227
|
*/
|
|
228
|
-
//# sourceMappingURL=cli.mjs.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/bin/cli.ts","../package.json","../src/index.ts","../src/compress.ts","../src/spinner.ts"],"sourcesContent":["#!/usr/bin/env node\n\n/*!\n * node-minify\n * Copyright(c) 2011-2024 Rodolphe Stoclin\n * MIT Licensed\n */\n\nimport { Command } from \"commander\";\nimport updateNotifier from \"update-notifier\";\nconst program = new Command();\nimport type { Settings } from \"@node-minify/types\";\nimport packageJson from \"../../package.json\";\nimport { run } from \"../index.ts\";\n\nupdateNotifier({ pkg: packageJson }).notify();\n\nprogram\n .storeOptionsAsProperties()\n .version(packageJson.version, \"-v, --version\")\n .option(\n \"-c, --compressor [compressor]\",\n \"use the specified compressor [uglify-js]\",\n \"uglify-js\"\n )\n .option(\"-i, --input [file]\", \"input file path\")\n .option(\"-o, --output [file]\", \"output file path\")\n .option(\"-s, --silence\", \"no output will be printed\")\n .option(\n \"-O, --option [option]\",\n \"option for the compressor as JSON object\",\n \"\"\n );\n\nprogram.on(\"--help\", () => {\n console.log(\" List of compressors:\");\n console.log(\"\");\n console.log(\" - babel-minify\");\n console.log(\" - gcc\");\n console.log(\" - html-minifier\");\n console.log(\" - terser\");\n console.log(\" - uglify-js\");\n console.log(\" - uglify-es\");\n console.log(\" - yui\");\n console.log(\"\");\n});\n\nprogram.parse(process.argv);\n\nconst options: Settings = program.opts();\n\n/**\n * Show help if missing mandatory.\n */\nif (!options.compressor || !options.input || !options.output) {\n program.help();\n}\n\nrun(options)\n .then(() => process.exit())\n .catch((err) => {\n console.error(err);\n process.exit(1);\n });\n","{\n \"name\": \"@node-minify/cli\",\n \"version\": \"9.0.2\",\n \"description\": \"CLI - command line interface for @node-minify\",\n \"keywords\": [\n \"compressor\",\n \"minify\",\n \"minifier\"\n ],\n \"author\": \"Rodolphe Stoclin <srodolphe@gmail.com>\",\n \"homepage\": \"https://github.com/srod/node-minify/tree/main/packages/cli#readme\",\n \"license\": \"MIT\",\n \"type\": \"module\",\n \"bin\": {\n \"node-minify\": \"dist/cli.js\"\n },\n \"engines\": {\n \"node\": \">=22.0.0\"\n },\n \"directories\": {\n \"lib\": \"dist\",\n \"test\": \"__tests__\"\n },\n \"main\": \"./dist/index.cjs\",\n \"exports\": {\n \".\": {\n \"import\": \"./dist/index.js\",\n \"default\": \"./dist/index.cjs\"\n }\n },\n \"files\": [\n \"bin\",\n \"dist/**/*\"\n ],\n \"publishConfig\": {\n \"access\": \"public\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/srod/node-minify.git\"\n },\n \"bugs\": {\n \"url\": \"https://github.com/srod/node-minify/issues\"\n },\n \"scripts\": {\n \"clean\": \"bunx rimraf dist\",\n \"build\": \"bun clean && tsup src/index.ts --format cjs,esm --dts --sourcemap && tsup src/bin/cli.ts --format esm --dts --sourcemap\",\n \"lint\": \"biome lint .\",\n \"prepublishOnly\": \"bun run build\",\n \"test\": \"vitest run\",\n \"test:ci\": \"vitest run --coverage\",\n \"test:watch\": \"vitest\",\n \"check-exports\": \"attw --pack .\"\n },\n \"dependencies\": {\n \"@node-minify/core\": \"workspace:*\",\n \"@node-minify/utils\": \"workspace:*\",\n \"chalk\": \"5.3.0\",\n \"commander\": \"12.1.0\",\n \"ora\": \"8.1.1\",\n \"update-notifier\": \"7.3.1\"\n },\n \"devDependencies\": {\n \"@arethetypeswrong/cli\": \"^0.17.0\",\n \"@node-minify/types\": \"workspace:*\",\n \"@types/chalk\": \"^2.2.4\",\n \"@types/ora\": \"^3.2.0\"\n }\n}\n","/*!\n * node-minify\n * Copyright(c) 2011-2024 Rodolphe Stoclin\n * MIT Licensed\n */\n\n/**\n * Module dependencies.\n */\nimport type { Result, Settings } from \"@node-minify/types\";\nimport chalk from \"chalk\";\nimport { compress } from \"./compress.ts\";\nimport { spinnerError, spinnerStart, spinnerStop } from \"./spinner.ts\";\n\n/**\n * Module variables.\n */\nlet silence = false;\n\n/**\n * Run one compressor.\n * @param cli Settings\n */\nconst runOne = async (cli: Settings) => {\n const compressor =\n typeof cli.compressor === \"string\"\n ? await import(`@node-minify/${cli.compressor}`)\n : cli.compressor;\n\n const compressorName =\n typeof cli.compressor === \"string\"\n ? cli.compressor\n : cli.compressor\n ? cli.compressor.name\n : \"unknownCompressor\";\n\n const options: Settings = {\n compressorLabel: compressorName,\n compressor: compressor.default,\n input: typeof cli.input === \"string\" ? cli.input.split(\",\") : \"\",\n output: cli.output,\n };\n\n if (cli.option) {\n options.options = JSON.parse(cli.option);\n }\n\n if (!silence) {\n spinnerStart(options);\n }\n\n return compress(options)\n .then((result: Result) => {\n if (!silence) {\n spinnerStop(result);\n }\n return result;\n })\n .catch((err: Error) => {\n if (!silence) {\n spinnerError(options);\n }\n throw err;\n });\n};\n\n/**\n * Run cli.\n * @param cli Settings\n */\nconst run = (cli: Settings) => {\n silence = !!cli.silence;\n\n if (!silence) {\n console.log(\"\");\n console.log(chalk.bgBlue.black(\" INFO \"), \"Starting compression...\");\n console.log(\"\");\n }\n\n return new Promise((resolve, reject) => {\n runOne(cli)\n .then(() => {\n if (!silence) {\n console.log(\"\");\n console.log(\n chalk.bgGreen.black(\" DONE \"),\n chalk.green(\"Done!\")\n );\n console.log(\"\");\n }\n })\n .then(resolve)\n .catch(reject);\n });\n};\n\n/**\n * Expose `run()`.\n */\nexport { run };\n","/*!\n * node-minify\n * Copyright(c) 2011-2024 Rodolphe Stoclin\n * MIT Licensed\n */\n\n/**\n * Module dependencies.\n */\nimport minify from \"@node-minify/core\";\nimport type { Result, Settings } from \"@node-minify/types\";\nimport { utils } from \"@node-minify/utils\";\n\n/**\n * Run compression.\n * @param options Settings\n */\nconst compress = (options: Settings): Promise<Result> => {\n return new Promise<Result>((resolve, reject) => {\n minify(options)\n .then(() => {\n if (options?.output?.includes(\"$1\")) {\n // npx node-minify --compressor uglify-js --input 'source/**/*.js' --output 'source/$1.min.js' --option '{\"warnings\": true, \"mangle\": false}'\n return resolve({\n compressorLabel: options.compressorLabel ?? \"\",\n compressor: options.compressor,\n size: \"0\",\n sizeGzip: \"0\",\n });\n }\n if (!options.output) {\n return resolve({\n compressorLabel: options.compressorLabel ?? \"\",\n compressor: options.compressor,\n size: \"0\",\n sizeGzip: \"0\",\n });\n }\n utils\n .getFilesizeGzippedInBytes(options.output)\n .then((sizeGzip: string) => {\n resolve({\n compressorLabel: options.compressorLabel ?? \"\",\n compressor: options.compressor,\n size: options.output\n ? utils.getFilesizeInBytes(options.output)\n : \"0\",\n sizeGzip: sizeGzip,\n });\n })\n .catch(reject);\n })\n .catch(reject);\n });\n};\n\n/**\n * Expose `compress()`.\n */\nexport { compress };\n","/*!\n * node-minify\n * Copyright(c) 2011-2024 Rodolphe Stoclin\n * MIT Licensed\n */\n\n/**\n * Module dependencies.\n */\nimport type { Result, Settings } from \"@node-minify/types\";\nimport chalk from \"chalk\";\nimport ora from \"ora\";\n\nconst spinner = ora();\n\n/**\n * Start spinner.\n * @param options Settings\n */\nconst start = (options: Settings) => {\n spinner.text = `Compressing file(s) with ${chalk.green(\n options.compressorLabel\n )}...`;\n spinner.start();\n};\n\n/**\n * Stop spinner.\n * @param result\n */\nconst stop = (result: Result) => {\n spinner.text = `File(s) compressed successfully with ${chalk.green(\n result.compressorLabel\n )} (${chalk.green(result.size)} minified, ${chalk.green(\n result.sizeGzip\n )} gzipped)`;\n spinner.succeed();\n};\n\n/**\n * Mark spinner as failed.\n * @param options Settings\n */\nconst error = (options: Settings) => {\n spinner.text = `Error - file(s) not compressed with ${chalk.red(\n options.compressorLabel\n )}`;\n spinner.fail();\n};\n\n/**\n * Expose `start(), stop() and error()`.\n */\nexport { start as spinnerStart, stop as spinnerStop, error as spinnerError };\n"],"mappings":";;;AAQA,SAAS,eAAe;AACxB,OAAO,oBAAoB;;;ACT3B;AAAA,EACE,MAAQ;AAAA,EACR,SAAW;AAAA,EACX,aAAe;AAAA,EACf,UAAY;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,QAAU;AAAA,EACV,UAAY;AAAA,EACZ,SAAW;AAAA,EACX,MAAQ;AAAA,EACR,KAAO;AAAA,IACL,eAAe;AAAA,EACjB;AAAA,EACA,SAAW;AAAA,IACT,MAAQ;AAAA,EACV;AAAA,EACA,aAAe;AAAA,IACb,KAAO;AAAA,IACP,MAAQ;AAAA,EACV;AAAA,EACA,MAAQ;AAAA,EACR,SAAW;AAAA,IACT,KAAK;AAAA,MACH,QAAU;AAAA,MACV,SAAW;AAAA,IACb;AAAA,EACF;AAAA,EACA,OAAS;AAAA,IACP;AAAA,IACA;AAAA,EACF;AAAA,EACA,eAAiB;AAAA,IACf,QAAU;AAAA,EACZ;AAAA,EACA,YAAc;AAAA,IACZ,MAAQ;AAAA,IACR,KAAO;AAAA,EACT;AAAA,EACA,MAAQ;AAAA,IACN,KAAO;AAAA,EACT;AAAA,EACA,SAAW;AAAA,IACT,OAAS;AAAA,IACT,OAAS;AAAA,IACT,MAAQ;AAAA,IACR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B,CAAC;AAED,QAAQ,MAAM,QAAQ,IAAI;AAE1B,IAAM,UAAoB,QAAQ,KAAK;AAKvC,IAAI,CAAC,QAAQ,cAAc,CAAC,QAAQ,SAAS,CAAC,QAAQ,QAAQ;AAC1D,UAAQ,KAAK;AACjB;AAEA,IAAI,OAAO,EACN,KAAK,MAAM,QAAQ,KAAK,CAAC,EACzB,MAAM,CAAC,QAAQ;AACZ,UAAQ,MAAM,GAAG;AACjB,UAAQ,KAAK,CAAC;AAClB,CAAC;","names":["chalk","options","options","options","chalk"]}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var src_exports = {};
|
|
32
|
+
__export(src_exports, {
|
|
33
|
+
run: () => run
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(src_exports);
|
|
36
|
+
var import_chalk2 = __toESM(require("chalk"), 1);
|
|
37
|
+
|
|
38
|
+
// src/compress.ts
|
|
39
|
+
var import_core = __toESM(require("@node-minify/core"), 1);
|
|
40
|
+
var import_utils = require("@node-minify/utils");
|
|
41
|
+
var compress = (options) => {
|
|
42
|
+
return new Promise((resolve, reject) => {
|
|
43
|
+
(0, import_core.default)(options).then(() => {
|
|
44
|
+
if (options?.output?.includes("$1")) {
|
|
45
|
+
return resolve({
|
|
46
|
+
compressorLabel: options.compressorLabel ?? "",
|
|
47
|
+
compressor: options.compressor,
|
|
48
|
+
size: "0",
|
|
49
|
+
sizeGzip: "0"
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
if (!options.output) {
|
|
53
|
+
return resolve({
|
|
54
|
+
compressorLabel: options.compressorLabel ?? "",
|
|
55
|
+
compressor: options.compressor,
|
|
56
|
+
size: "0",
|
|
57
|
+
sizeGzip: "0"
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
import_utils.utils.getFilesizeGzippedInBytes(options.output).then((sizeGzip) => {
|
|
61
|
+
resolve({
|
|
62
|
+
compressorLabel: options.compressorLabel ?? "",
|
|
63
|
+
compressor: options.compressor,
|
|
64
|
+
size: options.output ? import_utils.utils.getFilesizeInBytes(options.output) : "0",
|
|
65
|
+
sizeGzip
|
|
66
|
+
});
|
|
67
|
+
}).catch(reject);
|
|
68
|
+
}).catch(reject);
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
// src/spinner.ts
|
|
73
|
+
var import_chalk = __toESM(require("chalk"), 1);
|
|
74
|
+
var import_ora = __toESM(require("ora"), 1);
|
|
75
|
+
var spinner = (0, import_ora.default)();
|
|
76
|
+
var start = (options) => {
|
|
77
|
+
spinner.text = `Compressing file(s) with ${import_chalk.default.green(
|
|
78
|
+
options.compressorLabel
|
|
79
|
+
)}...`;
|
|
80
|
+
spinner.start();
|
|
81
|
+
};
|
|
82
|
+
var stop = (result) => {
|
|
83
|
+
spinner.text = `File(s) compressed successfully with ${import_chalk.default.green(
|
|
84
|
+
result.compressorLabel
|
|
85
|
+
)} (${import_chalk.default.green(result.size)} minified, ${import_chalk.default.green(
|
|
86
|
+
result.sizeGzip
|
|
87
|
+
)} gzipped)`;
|
|
88
|
+
spinner.succeed();
|
|
89
|
+
};
|
|
90
|
+
var error = (options) => {
|
|
91
|
+
spinner.text = `Error - file(s) not compressed with ${import_chalk.default.red(
|
|
92
|
+
options.compressorLabel
|
|
93
|
+
)}`;
|
|
94
|
+
spinner.fail();
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
// src/index.ts
|
|
98
|
+
var silence = false;
|
|
99
|
+
var runOne = async (cli) => {
|
|
100
|
+
const compressor = typeof cli.compressor === "string" ? await import(`@node-minify/${cli.compressor}`) : cli.compressor;
|
|
101
|
+
const compressorName = typeof cli.compressor === "string" ? cli.compressor : cli.compressor ? cli.compressor.name : "unknownCompressor";
|
|
102
|
+
const options = {
|
|
103
|
+
compressorLabel: compressorName,
|
|
104
|
+
compressor: compressor.default,
|
|
105
|
+
input: typeof cli.input === "string" ? cli.input.split(",") : "",
|
|
106
|
+
output: cli.output
|
|
107
|
+
};
|
|
108
|
+
if (cli.option) {
|
|
109
|
+
options.options = JSON.parse(cli.option);
|
|
110
|
+
}
|
|
111
|
+
if (!silence) {
|
|
112
|
+
start(options);
|
|
113
|
+
}
|
|
114
|
+
return compress(options).then((result) => {
|
|
115
|
+
if (!silence) {
|
|
116
|
+
stop(result);
|
|
117
|
+
}
|
|
118
|
+
return result;
|
|
119
|
+
}).catch((err) => {
|
|
120
|
+
if (!silence) {
|
|
121
|
+
error(options);
|
|
122
|
+
}
|
|
123
|
+
throw err;
|
|
124
|
+
});
|
|
125
|
+
};
|
|
126
|
+
var run = (cli) => {
|
|
127
|
+
silence = !!cli.silence;
|
|
128
|
+
if (!silence) {
|
|
129
|
+
console.log("");
|
|
130
|
+
console.log(import_chalk2.default.bgBlue.black(" INFO "), "Starting compression...");
|
|
131
|
+
console.log("");
|
|
132
|
+
}
|
|
133
|
+
return new Promise((resolve, reject) => {
|
|
134
|
+
runOne(cli).then(() => {
|
|
135
|
+
if (!silence) {
|
|
136
|
+
console.log("");
|
|
137
|
+
console.log(
|
|
138
|
+
import_chalk2.default.bgGreen.black(" DONE "),
|
|
139
|
+
import_chalk2.default.green("Done!")
|
|
140
|
+
);
|
|
141
|
+
console.log("");
|
|
142
|
+
}
|
|
143
|
+
}).then(resolve).catch(reject);
|
|
144
|
+
});
|
|
145
|
+
};
|
|
146
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
147
|
+
0 && (module.exports = {
|
|
148
|
+
run
|
|
149
|
+
});
|
|
150
|
+
/*!
|
|
151
|
+
* node-minify
|
|
152
|
+
* Copyright(c) 2011-2024 Rodolphe Stoclin
|
|
153
|
+
* MIT Licensed
|
|
154
|
+
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/compress.ts","../src/spinner.ts"],"sourcesContent":["/*!\n * node-minify\n * Copyright(c) 2011-2024 Rodolphe Stoclin\n * MIT Licensed\n */\n\n/**\n * Module dependencies.\n */\nimport type { Result, Settings } from \"@node-minify/types\";\nimport chalk from \"chalk\";\nimport { compress } from \"./compress.ts\";\nimport { spinnerError, spinnerStart, spinnerStop } from \"./spinner.ts\";\n\n/**\n * Module variables.\n */\nlet silence = false;\n\n/**\n * Run one compressor.\n * @param cli Settings\n */\nconst runOne = async (cli: Settings) => {\n const compressor =\n typeof cli.compressor === \"string\"\n ? await import(`@node-minify/${cli.compressor}`)\n : cli.compressor;\n\n const compressorName =\n typeof cli.compressor === \"string\"\n ? cli.compressor\n : cli.compressor\n ? cli.compressor.name\n : \"unknownCompressor\";\n\n const options: Settings = {\n compressorLabel: compressorName,\n compressor: compressor.default,\n input: typeof cli.input === \"string\" ? cli.input.split(\",\") : \"\",\n output: cli.output,\n };\n\n if (cli.option) {\n options.options = JSON.parse(cli.option);\n }\n\n if (!silence) {\n spinnerStart(options);\n }\n\n return compress(options)\n .then((result: Result) => {\n if (!silence) {\n spinnerStop(result);\n }\n return result;\n })\n .catch((err: Error) => {\n if (!silence) {\n spinnerError(options);\n }\n throw err;\n });\n};\n\n/**\n * Run cli.\n * @param cli Settings\n */\nconst run = (cli: Settings) => {\n silence = !!cli.silence;\n\n if (!silence) {\n console.log(\"\");\n console.log(chalk.bgBlue.black(\" INFO \"), \"Starting compression...\");\n console.log(\"\");\n }\n\n return new Promise((resolve, reject) => {\n runOne(cli)\n .then(() => {\n if (!silence) {\n console.log(\"\");\n console.log(\n chalk.bgGreen.black(\" DONE \"),\n chalk.green(\"Done!\")\n );\n console.log(\"\");\n }\n })\n .then(resolve)\n .catch(reject);\n });\n};\n\n/**\n * Expose `run()`.\n */\nexport { run };\n","/*!\n * node-minify\n * Copyright(c) 2011-2024 Rodolphe Stoclin\n * MIT Licensed\n */\n\n/**\n * Module dependencies.\n */\nimport minify from \"@node-minify/core\";\nimport type { Result, Settings } from \"@node-minify/types\";\nimport { utils } from \"@node-minify/utils\";\n\n/**\n * Run compression.\n * @param options Settings\n */\nconst compress = (options: Settings): Promise<Result> => {\n return new Promise<Result>((resolve, reject) => {\n minify(options)\n .then(() => {\n if (options?.output?.includes(\"$1\")) {\n // npx node-minify --compressor uglify-js --input 'source/**/*.js' --output 'source/$1.min.js' --option '{\"warnings\": true, \"mangle\": false}'\n return resolve({\n compressorLabel: options.compressorLabel ?? \"\",\n compressor: options.compressor,\n size: \"0\",\n sizeGzip: \"0\",\n });\n }\n if (!options.output) {\n return resolve({\n compressorLabel: options.compressorLabel ?? \"\",\n compressor: options.compressor,\n size: \"0\",\n sizeGzip: \"0\",\n });\n }\n utils\n .getFilesizeGzippedInBytes(options.output)\n .then((sizeGzip: string) => {\n resolve({\n compressorLabel: options.compressorLabel ?? \"\",\n compressor: options.compressor,\n size: options.output\n ? utils.getFilesizeInBytes(options.output)\n : \"0\",\n sizeGzip: sizeGzip,\n });\n })\n .catch(reject);\n })\n .catch(reject);\n });\n};\n\n/**\n * Expose `compress()`.\n */\nexport { compress };\n","/*!\n * node-minify\n * Copyright(c) 2011-2024 Rodolphe Stoclin\n * MIT Licensed\n */\n\n/**\n * Module dependencies.\n */\nimport type { Result, Settings } from \"@node-minify/types\";\nimport chalk from \"chalk\";\nimport ora from \"ora\";\n\nconst spinner = ora();\n\n/**\n * Start spinner.\n * @param options Settings\n */\nconst start = (options: Settings) => {\n spinner.text = `Compressing file(s) with ${chalk.green(\n options.compressorLabel\n )}...`;\n spinner.start();\n};\n\n/**\n * Stop spinner.\n * @param result\n */\nconst stop = (result: Result) => {\n spinner.text = `File(s) compressed successfully with ${chalk.green(\n result.compressorLabel\n )} (${chalk.green(result.size)} minified, ${chalk.green(\n result.sizeGzip\n )} gzipped)`;\n spinner.succeed();\n};\n\n/**\n * Mark spinner as failed.\n * @param options Settings\n */\nconst error = (options: Settings) => {\n spinner.text = `Error - file(s) not compressed with ${chalk.red(\n options.compressorLabel\n )}`;\n spinner.fail();\n};\n\n/**\n * Expose `start(), stop() and error()`.\n */\nexport { start as spinnerStart, stop as spinnerStop, error as spinnerError };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAUA,IAAAA,gBAAkB;;;ACDlB,kBAAmB;AAEnB,mBAAsB;AAMtB,IAAM,WAAW,CAAC,YAAuC;AACrD,SAAO,IAAI,QAAgB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AAQ,MAAM,QAAQ;AAAA,UAC5B,cAAAA,QAAM,MAAM,OAAO;AAAA,QACvB;AACA,gBAAQ,IAAI,EAAE;AAAA,MAClB;AAAA,IACJ,CAAC,EACA,KAAK,OAAO,EACZ,MAAM,MAAM;AAAA,EACrB,CAAC;AACL;","names":["import_chalk","minify","ora","chalk","chalk"]}
|
package/dist/index.js
CHANGED
|
@@ -1,46 +1,12 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
1
|
// src/index.ts
|
|
31
|
-
|
|
32
|
-
__export(src_exports, {
|
|
33
|
-
run: () => run
|
|
34
|
-
});
|
|
35
|
-
module.exports = __toCommonJS(src_exports);
|
|
36
|
-
var import_chalk2 = __toESM(require("chalk"));
|
|
2
|
+
import chalk2 from "chalk";
|
|
37
3
|
|
|
38
4
|
// src/compress.ts
|
|
39
|
-
|
|
40
|
-
|
|
5
|
+
import minify from "@node-minify/core";
|
|
6
|
+
import { utils } from "@node-minify/utils";
|
|
41
7
|
var compress = (options) => {
|
|
42
8
|
return new Promise((resolve, reject) => {
|
|
43
|
-
(
|
|
9
|
+
minify(options).then(() => {
|
|
44
10
|
if (options?.output?.includes("$1")) {
|
|
45
11
|
return resolve({
|
|
46
12
|
compressorLabel: options.compressorLabel ?? "",
|
|
@@ -57,11 +23,11 @@ var compress = (options) => {
|
|
|
57
23
|
sizeGzip: "0"
|
|
58
24
|
});
|
|
59
25
|
}
|
|
60
|
-
|
|
26
|
+
utils.getFilesizeGzippedInBytes(options.output).then((sizeGzip) => {
|
|
61
27
|
resolve({
|
|
62
28
|
compressorLabel: options.compressorLabel ?? "",
|
|
63
29
|
compressor: options.compressor,
|
|
64
|
-
size: options.output ?
|
|
30
|
+
size: options.output ? utils.getFilesizeInBytes(options.output) : "0",
|
|
65
31
|
sizeGzip
|
|
66
32
|
});
|
|
67
33
|
}).catch(reject);
|
|
@@ -70,25 +36,25 @@ var compress = (options) => {
|
|
|
70
36
|
};
|
|
71
37
|
|
|
72
38
|
// src/spinner.ts
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
var spinner = (
|
|
39
|
+
import chalk from "chalk";
|
|
40
|
+
import ora from "ora";
|
|
41
|
+
var spinner = ora();
|
|
76
42
|
var start = (options) => {
|
|
77
|
-
spinner.text = `Compressing file(s) with ${
|
|
43
|
+
spinner.text = `Compressing file(s) with ${chalk.green(
|
|
78
44
|
options.compressorLabel
|
|
79
45
|
)}...`;
|
|
80
46
|
spinner.start();
|
|
81
47
|
};
|
|
82
48
|
var stop = (result) => {
|
|
83
|
-
spinner.text = `File(s) compressed successfully with ${
|
|
49
|
+
spinner.text = `File(s) compressed successfully with ${chalk.green(
|
|
84
50
|
result.compressorLabel
|
|
85
|
-
)} (${
|
|
51
|
+
)} (${chalk.green(result.size)} minified, ${chalk.green(
|
|
86
52
|
result.sizeGzip
|
|
87
53
|
)} gzipped)`;
|
|
88
54
|
spinner.succeed();
|
|
89
55
|
};
|
|
90
56
|
var error = (options) => {
|
|
91
|
-
spinner.text = `Error - file(s) not compressed with ${
|
|
57
|
+
spinner.text = `Error - file(s) not compressed with ${chalk.red(
|
|
92
58
|
options.compressorLabel
|
|
93
59
|
)}`;
|
|
94
60
|
spinner.fail();
|
|
@@ -127,7 +93,7 @@ var run = (cli) => {
|
|
|
127
93
|
silence = !!cli.silence;
|
|
128
94
|
if (!silence) {
|
|
129
95
|
console.log("");
|
|
130
|
-
console.log(
|
|
96
|
+
console.log(chalk2.bgBlue.black(" INFO "), "Starting compression...");
|
|
131
97
|
console.log("");
|
|
132
98
|
}
|
|
133
99
|
return new Promise((resolve, reject) => {
|
|
@@ -135,21 +101,19 @@ var run = (cli) => {
|
|
|
135
101
|
if (!silence) {
|
|
136
102
|
console.log("");
|
|
137
103
|
console.log(
|
|
138
|
-
|
|
139
|
-
|
|
104
|
+
chalk2.bgGreen.black(" DONE "),
|
|
105
|
+
chalk2.green("Done!")
|
|
140
106
|
);
|
|
141
107
|
console.log("");
|
|
142
108
|
}
|
|
143
109
|
}).then(resolve).catch(reject);
|
|
144
110
|
});
|
|
145
111
|
};
|
|
146
|
-
|
|
147
|
-
0 && (module.exports = {
|
|
112
|
+
export {
|
|
148
113
|
run
|
|
149
|
-
}
|
|
114
|
+
};
|
|
150
115
|
/*!
|
|
151
116
|
* node-minify
|
|
152
117
|
* Copyright(c) 2011-2024 Rodolphe Stoclin
|
|
153
118
|
* MIT Licensed
|
|
154
119
|
*/
|
|
155
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/compress.ts","../src/spinner.ts"],"sourcesContent":["/*!\n * node-minify\n * Copyright(c) 2011-2024 Rodolphe Stoclin\n * MIT Licensed\n */\n\n/**\n * Module dependencies.\n */\nimport type { Result, Settings } from \"@node-minify/types\";\
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/compress.ts","../src/spinner.ts"],"sourcesContent":["/*!\n * node-minify\n * Copyright(c) 2011-2024 Rodolphe Stoclin\n * MIT Licensed\n */\n\n/**\n * Module dependencies.\n */\nimport type { Result, Settings } from \"@node-minify/types\";\nimport chalk from \"chalk\";\nimport { compress } from \"./compress.ts\";\nimport { spinnerError, spinnerStart, spinnerStop } from \"./spinner.ts\";\n\n/**\n * Module variables.\n */\nlet silence = false;\n\n/**\n * Run one compressor.\n * @param cli Settings\n */\nconst runOne = async (cli: Settings) => {\n const compressor =\n typeof cli.compressor === \"string\"\n ? await import(`@node-minify/${cli.compressor}`)\n : cli.compressor;\n\n const compressorName =\n typeof cli.compressor === \"string\"\n ? cli.compressor\n : cli.compressor\n ? cli.compressor.name\n : \"unknownCompressor\";\n\n const options: Settings = {\n compressorLabel: compressorName,\n compressor: compressor.default,\n input: typeof cli.input === \"string\" ? cli.input.split(\",\") : \"\",\n output: cli.output,\n };\n\n if (cli.option) {\n options.options = JSON.parse(cli.option);\n }\n\n if (!silence) {\n spinnerStart(options);\n }\n\n return compress(options)\n .then((result: Result) => {\n if (!silence) {\n spinnerStop(result);\n }\n return result;\n })\n .catch((err: Error) => {\n if (!silence) {\n spinnerError(options);\n }\n throw err;\n });\n};\n\n/**\n * Run cli.\n * @param cli Settings\n */\nconst run = (cli: Settings) => {\n silence = !!cli.silence;\n\n if (!silence) {\n console.log(\"\");\n console.log(chalk.bgBlue.black(\" INFO \"), \"Starting compression...\");\n console.log(\"\");\n }\n\n return new Promise((resolve, reject) => {\n runOne(cli)\n .then(() => {\n if (!silence) {\n console.log(\"\");\n console.log(\n chalk.bgGreen.black(\" DONE \"),\n chalk.green(\"Done!\")\n );\n console.log(\"\");\n }\n })\n .then(resolve)\n .catch(reject);\n });\n};\n\n/**\n * Expose `run()`.\n */\nexport { run };\n","/*!\n * node-minify\n * Copyright(c) 2011-2024 Rodolphe Stoclin\n * MIT Licensed\n */\n\n/**\n * Module dependencies.\n */\nimport minify from \"@node-minify/core\";\nimport type { Result, Settings } from \"@node-minify/types\";\nimport { utils } from \"@node-minify/utils\";\n\n/**\n * Run compression.\n * @param options Settings\n */\nconst compress = (options: Settings): Promise<Result> => {\n return new Promise<Result>((resolve, reject) => {\n minify(options)\n .then(() => {\n if (options?.output?.includes(\"$1\")) {\n // npx node-minify --compressor uglify-js --input 'source/**/*.js' --output 'source/$1.min.js' --option '{\"warnings\": true, \"mangle\": false}'\n return resolve({\n compressorLabel: options.compressorLabel ?? \"\",\n compressor: options.compressor,\n size: \"0\",\n sizeGzip: \"0\",\n });\n }\n if (!options.output) {\n return resolve({\n compressorLabel: options.compressorLabel ?? \"\",\n compressor: options.compressor,\n size: \"0\",\n sizeGzip: \"0\",\n });\n }\n utils\n .getFilesizeGzippedInBytes(options.output)\n .then((sizeGzip: string) => {\n resolve({\n compressorLabel: options.compressorLabel ?? \"\",\n compressor: options.compressor,\n size: options.output\n ? utils.getFilesizeInBytes(options.output)\n : \"0\",\n sizeGzip: sizeGzip,\n });\n })\n .catch(reject);\n })\n .catch(reject);\n });\n};\n\n/**\n * Expose `compress()`.\n */\nexport { compress };\n","/*!\n * node-minify\n * Copyright(c) 2011-2024 Rodolphe Stoclin\n * MIT Licensed\n */\n\n/**\n * Module dependencies.\n */\nimport type { Result, Settings } from \"@node-minify/types\";\nimport chalk from \"chalk\";\nimport ora from \"ora\";\n\nconst spinner = ora();\n\n/**\n * Start spinner.\n * @param options Settings\n */\nconst start = (options: Settings) => {\n spinner.text = `Compressing file(s) with ${chalk.green(\n options.compressorLabel\n )}...`;\n spinner.start();\n};\n\n/**\n * Stop spinner.\n * @param result\n */\nconst stop = (result: Result) => {\n spinner.text = `File(s) compressed successfully with ${chalk.green(\n result.compressorLabel\n )} (${chalk.green(result.size)} minified, ${chalk.green(\n result.sizeGzip\n )} gzipped)`;\n spinner.succeed();\n};\n\n/**\n * Mark spinner as failed.\n * @param options Settings\n */\nconst error = (options: Settings) => {\n spinner.text = `Error - file(s) not compressed with ${chalk.red(\n options.compressorLabel\n )}`;\n spinner.fail();\n};\n\n/**\n * Expose `start(), stop() and error()`.\n */\nexport { start as spinnerStart, stop as spinnerStop, error as spinnerError };\n"],"mappings":";AAUA,OAAOA,YAAW;;;ACDlB,OAAO,YAAY;AAEnB,SAAS,aAAa;AAMtB,IAAM,WAAW,CAAC,YAAuC;AACrD,SAAO,IAAI,QAAgB,CAAC,SAAS,WAAW;AAC5C,WAAO,OAAO,EACT,KAAK,MAAM;AACR,UAAI,SAAS,QAAQ,SAAS,IAAI,GAAG;AAEjC,eAAO,QAAQ;AAAA,UACX,iBAAiB,QAAQ,mBAAmB;AAAA,UAC5C,YAAY,QAAQ;AAAA,UACpB,MAAM;AAAA,UACN,UAAU;AAAA,QACd,CAAC;AAAA,MACL;AACA,UAAI,CAAC,QAAQ,QAAQ;AACjB,eAAO,QAAQ;AAAA,UACX,iBAAiB,QAAQ,mBAAmB;AAAA,UAC5C,YAAY,QAAQ;AAAA,UACpB,MAAM;AAAA,UACN,UAAU;AAAA,QACd,CAAC;AAAA,MACL;AACA,YACK,0BAA0B,QAAQ,MAAM,EACxC,KAAK,CAAC,aAAqB;AACxB,gBAAQ;AAAA,UACJ,iBAAiB,QAAQ,mBAAmB;AAAA,UAC5C,YAAY,QAAQ;AAAA,UACpB,MAAM,QAAQ,SACR,MAAM,mBAAmB,QAAQ,MAAM,IACvC;AAAA,UACN;AAAA,QACJ,CAAC;AAAA,MACL,CAAC,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AA,IACtB;AACA,WAAO;AAAA,EACX,CAAC,EACA,MAAM,CAAC,QAAe;AACnB,QAAI,CAAC,SAAS;AACV,YAAa,OAAO;AAAA,IACxB;AACA,UAAM;AAAA,EACV,CAAC;AACT;AAMA,IAAM,MAAM,CAAC,QAAkB;AAC3B,YAAU,CAAC,CAAC,IAAI;AAEhB,MAAI,CAAC,SAAS;AACV,YAAQ,IAAI,EAAE;AACd,YAAQ,IAAIC,OAAM,OAAO,MAAM,QAAQ,GAAG,yBAAyB;AACnE,YAAQ,IAAI,EAAE;AAAA,EAClB;AAEA,SAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACpC,WAAO,GAAG,EACL,KAAK,MAAM;AACR,UAAI,CAAC,SAAS;AACV,gBAAQ,IAAI,EAAE;AACd,gBAAQ;AAAA,UACJA,OAAM,QAAQ,MAAM,QAAQ;AAAA,UAC5BA,OAAM,MAAM,OAAO;AAAA,QACvB;AACA,gBAAQ,IAAI,EAAE;AAAA,MAClB;AAAA,IACJ,CAAC,EACA,KAAK,OAAO,EACZ,MAAM,MAAM;AAAA,EACrB,CAAC;AACL;","names":["chalk","chalk"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@node-minify/cli",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "10.0.0-next.0",
|
|
4
4
|
"description": "CLI - command line interface for @node-minify",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"compressor",
|
|
@@ -8,26 +8,25 @@
|
|
|
8
8
|
"minifier"
|
|
9
9
|
],
|
|
10
10
|
"author": "Rodolphe Stoclin <srodolphe@gmail.com>",
|
|
11
|
-
"homepage": "https://github.com/srod/node-minify/tree/
|
|
11
|
+
"homepage": "https://github.com/srod/node-minify/tree/main/packages/cli#readme",
|
|
12
12
|
"license": "MIT",
|
|
13
|
+
"type": "module",
|
|
13
14
|
"bin": {
|
|
14
|
-
"node-minify": "dist/cli.
|
|
15
|
+
"node-minify": "dist/cli.js"
|
|
15
16
|
},
|
|
16
17
|
"engines": {
|
|
17
|
-
"node": ">=
|
|
18
|
+
"node": ">=22.0.0"
|
|
18
19
|
},
|
|
19
20
|
"directories": {
|
|
20
21
|
"lib": "dist",
|
|
21
22
|
"test": "__tests__"
|
|
22
23
|
},
|
|
23
|
-
"main": "./dist/index.
|
|
24
|
-
"module": "./dist/index.mjs",
|
|
25
|
-
"types": "./dist/index.d.ts",
|
|
24
|
+
"main": "./dist/index.cjs",
|
|
26
25
|
"exports": {
|
|
26
|
+
"./package.json": "./package.json",
|
|
27
27
|
".": {
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"require": "./dist/index.cjs"
|
|
28
|
+
"import": "./dist/index.js",
|
|
29
|
+
"default": "./dist/index.cjs"
|
|
31
30
|
}
|
|
32
31
|
},
|
|
33
32
|
"files": [
|
|
@@ -44,25 +43,27 @@
|
|
|
44
43
|
"bugs": {
|
|
45
44
|
"url": "https://github.com/srod/node-minify/issues"
|
|
46
45
|
},
|
|
46
|
+
"scripts": {
|
|
47
|
+
"build": "tsup src/index.ts --format cjs,esm --dts && tsup src/bin/cli.ts --format esm --dts",
|
|
48
|
+
"check-exports": "attw --pack .",
|
|
49
|
+
"format:check": "biome check .",
|
|
50
|
+
"lint": "biome lint .",
|
|
51
|
+
"prepublishOnly": "bun run build",
|
|
52
|
+
"test": "vitest run",
|
|
53
|
+
"test:ci": "vitest run --coverage",
|
|
54
|
+
"test:watch": "vitest"
|
|
55
|
+
},
|
|
47
56
|
"dependencies": {
|
|
57
|
+
"@node-minify/core": "workspace:*",
|
|
58
|
+
"@node-minify/utils": "workspace:*",
|
|
48
59
|
"chalk": "5.3.0",
|
|
49
60
|
"commander": "12.1.0",
|
|
50
61
|
"ora": "8.1.1",
|
|
51
|
-
"update-notifier": "7.3.1"
|
|
52
|
-
"@node-minify/core": "9.0.1",
|
|
53
|
-
"@node-minify/utils": "9.0.0"
|
|
62
|
+
"update-notifier": "7.3.1"
|
|
54
63
|
},
|
|
55
64
|
"devDependencies": {
|
|
56
|
-
"@types
|
|
57
|
-
"@types/
|
|
58
|
-
"@
|
|
59
|
-
},
|
|
60
|
-
"scripts": {
|
|
61
|
-
"clean": "pnpm dlx rimraf dist",
|
|
62
|
-
"build": "pnpm clean && tsup src/index.ts --format cjs,esm --dts --sourcemap && tsup src/bin/cli.ts --format esm --dts --sourcemap",
|
|
63
|
-
"lint": "biome lint .",
|
|
64
|
-
"test": "vitest run",
|
|
65
|
-
"test:ci": "vitest run --coverage",
|
|
66
|
-
"test:watch": "vitest"
|
|
65
|
+
"@node-minify/types": "workspace:*",
|
|
66
|
+
"@types/chalk": "^2.2.4",
|
|
67
|
+
"@types/ora": "^3.2.0"
|
|
67
68
|
}
|
|
68
|
-
}
|
|
69
|
+
}
|
package/dist/cli.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/bin/cli.ts","../src/index.ts","../src/compress.ts","../src/spinner.ts","../package.json"],"sourcesContent":["#!/usr/bin/env node\n\n/*!\n * node-minify\n * Copyright(c) 2011-2024 Rodolphe Stoclin\n * MIT Licensed\n */\n\nimport { Command } from \"commander\";\nimport updateNotifier from \"update-notifier\";\nconst program = new Command();\nimport type { Settings } from \"@node-minify/types\";\nimport { run } from \"../\";\nimport packageJson from \"../../package.json\";\n\nupdateNotifier({ pkg: packageJson }).notify();\n\nprogram\n .storeOptionsAsProperties()\n .version(packageJson.version, \"-v, --version\")\n .option(\n \"-c, --compressor [compressor]\",\n \"use the specified compressor [uglify-js]\",\n \"uglify-js\"\n )\n .option(\"-i, --input [file]\", \"input file path\")\n .option(\"-o, --output [file]\", \"output file path\")\n .option(\"-s, --silence\", \"no output will be printed\")\n .option(\n \"-O, --option [option]\",\n \"option for the compressor as JSON object\",\n \"\"\n );\n\nprogram.on(\"--help\", () => {\n console.log(\" List of compressors:\");\n console.log(\"\");\n console.log(\" - babel-minify\");\n console.log(\" - gcc\");\n console.log(\" - html-minifier\");\n console.log(\" - terser\");\n console.log(\" - uglify-js\");\n console.log(\" - uglify-es\");\n console.log(\" - yui\");\n console.log(\"\");\n});\n\nprogram.parse(process.argv);\n\nconst options: Settings = program.opts();\n\n/**\n * Show help if missing mandatory.\n */\nif (!options.compressor || !options.input || !options.output) {\n program.help();\n}\n\nrun(options)\n .then(() => process.exit())\n .catch((err) => {\n console.error(err);\n process.exit(1);\n });\n","/*!\n * node-minify\n * Copyright(c) 2011-2024 Rodolphe Stoclin\n * MIT Licensed\n */\n\n/**\n * Module dependencies.\n */\nimport type { Result, Settings } from \"@node-minify/types\";\n// @ts-expect-error moduleResolution:nodenext issue 54523\nimport chalk from \"chalk\";\nimport { compress } from \"./compress\";\nimport { spinnerError, spinnerStart, spinnerStop } from \"./spinner\";\n\n/**\n * Module variables.\n */\nlet silence = false;\n\n/**\n * Run one compressor.\n * @param cli Settings\n */\nconst runOne = async (cli: Settings) => {\n const compressor =\n typeof cli.compressor === \"string\"\n ? await import(`@node-minify/${cli.compressor}`)\n : cli.compressor;\n\n const compressorName =\n typeof cli.compressor === \"string\"\n ? cli.compressor\n : cli.compressor\n ? cli.compressor.name\n : \"unknownCompressor\";\n\n const options: Settings = {\n compressorLabel: compressorName,\n compressor: compressor.default,\n input: typeof cli.input === \"string\" ? cli.input.split(\",\") : \"\",\n output: cli.output,\n };\n\n if (cli.option) {\n options.options = JSON.parse(cli.option);\n }\n\n if (!silence) {\n spinnerStart(options);\n }\n\n return compress(options)\n .then((result: Result) => {\n if (!silence) {\n spinnerStop(result);\n }\n return result;\n })\n .catch((err: Error) => {\n if (!silence) {\n spinnerError(options);\n }\n throw err;\n });\n};\n\n/**\n * Run cli.\n * @param cli Settings\n */\nconst run = (cli: Settings) => {\n silence = !!cli.silence;\n\n if (!silence) {\n console.log(\"\");\n console.log(chalk.bgBlue.black(\" INFO \"), \"Starting compression...\");\n console.log(\"\");\n }\n\n return new Promise((resolve, reject) => {\n runOne(cli)\n .then(() => {\n if (!silence) {\n console.log(\"\");\n console.log(\n chalk.bgGreen.black(\" DONE \"),\n chalk.green(\"Done!\")\n );\n console.log(\"\");\n }\n })\n .then(resolve)\n .catch(reject);\n });\n};\n\n/**\n * Expose `run()`.\n */\nexport { run };\n","/*!\n * node-minify\n * Copyright(c) 2011-2024 Rodolphe Stoclin\n * MIT Licensed\n */\n\n/**\n * Module dependencies.\n */\nimport minify from \"@node-minify/core\";\nimport type { Result, Settings } from \"@node-minify/types\";\nimport { utils } from \"@node-minify/utils\";\n\n/**\n * Run compression.\n * @param options Settings\n */\nconst compress = (options: Settings): Promise<Result> => {\n return new Promise<Result>((resolve, reject) => {\n minify(options)\n .then(() => {\n if (options?.output?.includes(\"$1\")) {\n // npx node-minify --compressor uglify-js --input 'source/**/*.js' --output 'source/$1.min.js' --option '{\"warnings\": true, \"mangle\": false}'\n return resolve({\n compressorLabel: options.compressorLabel ?? \"\",\n compressor: options.compressor,\n size: \"0\",\n sizeGzip: \"0\",\n });\n }\n if (!options.output) {\n return resolve({\n compressorLabel: options.compressorLabel ?? \"\",\n compressor: options.compressor,\n size: \"0\",\n sizeGzip: \"0\",\n });\n }\n utils\n .getFilesizeGzippedInBytes(options.output)\n .then((sizeGzip: string) => {\n resolve({\n compressorLabel: options.compressorLabel ?? \"\",\n compressor: options.compressor,\n size: options.output\n ? utils.getFilesizeInBytes(options.output)\n : \"0\",\n sizeGzip: sizeGzip,\n });\n })\n .catch(reject);\n })\n .catch(reject);\n });\n};\n\n/**\n * Expose `compress()`.\n */\nexport { compress };\n","/*!\n * node-minify\n * Copyright(c) 2011-2024 Rodolphe Stoclin\n * MIT Licensed\n */\n\n/**\n * Module dependencies.\n */\nimport type { Result, Settings } from \"@node-minify/types\";\nimport chalk from \"chalk\";\nimport ora from \"ora\";\n\nconst spinner = ora();\n\n/**\n * Start spinner.\n * @param options Settings\n */\nconst start = (options: Settings) => {\n spinner.text = `Compressing file(s) with ${chalk.green(\n options.compressorLabel\n )}...`;\n spinner.start();\n};\n\n/**\n * Stop spinner.\n * @param result\n */\nconst stop = (result: Result) => {\n spinner.text = `File(s) compressed successfully with ${chalk.green(\n result.compressorLabel\n )} (${chalk.green(result.size)} minified, ${chalk.green(\n result.sizeGzip\n )} gzipped)`;\n spinner.succeed();\n};\n\n/**\n * Mark spinner as failed.\n * @param options Settings\n */\nconst error = (options: Settings) => {\n spinner.text = `Error - file(s) not compressed with ${chalk.red(\n options.compressorLabel\n )}`;\n spinner.fail();\n};\n\n/**\n * Expose `start(), stop() and error()`.\n */\nexport { start as spinnerStart, stop as spinnerStop, error as spinnerError };\n","{\n \"name\": \"@node-minify/cli\",\n \"version\": \"9.0.1\",\n \"description\": \"CLI - command line interface for @node-minify\",\n \"keywords\": [\n \"compressor\",\n \"minify\",\n \"minifier\"\n ],\n \"author\": \"Rodolphe Stoclin <srodolphe@gmail.com>\",\n \"homepage\": \"https://github.com/srod/node-minify/tree/master/packages/cli#readme\",\n \"license\": \"MIT\",\n \"bin\": {\n \"node-minify\": \"dist/cli.mjs\"\n },\n \"engines\": {\n \"node\": \">=18.0.0\"\n },\n \"directories\": {\n \"lib\": \"dist\",\n \"test\": \"__tests__\"\n },\n \"main\": \"./dist/index.js\",\n \"module\": \"./dist/index.mjs\",\n \"types\": \"./dist/index.d.ts\",\n \"exports\": {\n \".\": {\n \"types\": \"./dist/index.d.ts\",\n \"import\": \"./dist/index.mjs\",\n \"require\": \"./dist/index.cjs\"\n }\n },\n \"files\": [\n \"bin\",\n \"dist/**/*\"\n ],\n \"publishConfig\": {\n \"access\": \"public\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/srod/node-minify.git\"\n },\n \"bugs\": {\n \"url\": \"https://github.com/srod/node-minify/issues\"\n },\n \"scripts\": {\n \"clean\": \"pnpm dlx rimraf dist\",\n \"build\": \"pnpm clean && tsup src/index.ts --format cjs,esm --dts --sourcemap && tsup src/bin/cli.ts --format esm --dts --sourcemap\",\n \"lint\": \"biome lint .\",\n \"prepublishOnly\": \"pnpm build\",\n \"test\": \"vitest run\",\n \"test:ci\": \"vitest run --coverage\",\n \"test:watch\": \"vitest\"\n },\n \"dependencies\": {\n \"@node-minify/core\": \"workspace:*\",\n \"@node-minify/utils\": \"workspace:*\",\n \"chalk\": \"5.3.0\",\n \"commander\": \"12.1.0\",\n \"ora\": \"8.1.1\",\n \"update-notifier\": \"7.3.1\"\n },\n \"devDependencies\": {\n \"@node-minify/types\": \"workspace:*\",\n \"@types/chalk\": \"^2.2.0\",\n \"@types/ora\": \"^3.2.0\"\n }\n}\n"],"mappings":";;;AAQA,SAAS,eAAe;AACxB,OAAO,oBAAoB;;;ACE3B,OAAOA,YAAW;;;ACFlB,OAAO,YAAY;AAEnB,SAAS,aAAa;AAMtB,IAAM,WAAW,CAACC,aAAuC;AACrD,SAAO,IAAI,QAAgB,CAAC,SAAS,WAAW;AAC5C,WAAOA,QAAO,EACT,KAAK,MAAM;AACR,UAAIA,UAAS,QAAQ,SAAS,IAAI,GAAG;AAEjC,eAAO,QAAQ;AAAA,UACX,iBAAiBA,SAAQ,mBAAmB;AAAA,UAC5C,YAAYA,SAAQ;AAAA,UACpB,MAAM;AAAA,UACN,UAAU;AAAA,QACd,CAAC;AAAA,MACL;AACA,UAAI,CAACA,SAAQ,QAAQ;AACjB,eAAO,QAAQ;AAAA,UACX,iBAAiBA,SAAQ,mBAAmB;AAAA,UAC5C,YAAYA,SAAQ;AAAA,UACpB,MAAM;AAAA,UACN,UAAU;AAAA,QACd,CAAC;AAAA,MACL;AACA,YACK,0BAA0BA,SAAQ,MAAM,EACxC,KAAK,CAAC,aAAqB;AACxB,gBAAQ;AAAA,UACJ,iBAAiBA,SAAQ,mBAAmB;AAAA,UAC5C,YAAYA,SAAQ;AAAA,UACpB,MAAMA,SAAQ,SACR,MAAM,mBAAmBA,SAAQ,MAAM,IACvC;AAAA,UACN;AAAA,QACJ,CAAC;AAAA,MACL,CAAC,EACA,MAAM,MAAM;AAAA,IACrB,CAAC,EACA,MAAM,MAAM;AAA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,SAAS,CAAC,QAAQ,QAAQ;AAC1D,UAAQ,KAAK;AACjB;AAEA,IAAI,OAAO,EACN,KAAK,MAAM,QAAQ,KAAK,CAAC,EACzB,MAAM,CAAC,QAAQ;AACZ,UAAQ,MAAM,GAAG;AACjB,UAAQ,KAAK,CAAC;AAClB,CAAC;","names":["chalk","options","options","options","chalk"]}
|
package/dist/index.mjs
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
// src/index.ts
|
|
2
|
-
import chalk2 from "chalk";
|
|
3
|
-
|
|
4
|
-
// src/compress.ts
|
|
5
|
-
import minify from "@node-minify/core";
|
|
6
|
-
import { utils } from "@node-minify/utils";
|
|
7
|
-
var compress = (options) => {
|
|
8
|
-
return new Promise((resolve, reject) => {
|
|
9
|
-
minify(options).then(() => {
|
|
10
|
-
if (options?.output?.includes("$1")) {
|
|
11
|
-
return resolve({
|
|
12
|
-
compressorLabel: options.compressorLabel ?? "",
|
|
13
|
-
compressor: options.compressor,
|
|
14
|
-
size: "0",
|
|
15
|
-
sizeGzip: "0"
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
if (!options.output) {
|
|
19
|
-
return resolve({
|
|
20
|
-
compressorLabel: options.compressorLabel ?? "",
|
|
21
|
-
compressor: options.compressor,
|
|
22
|
-
size: "0",
|
|
23
|
-
sizeGzip: "0"
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
utils.getFilesizeGzippedInBytes(options.output).then((sizeGzip) => {
|
|
27
|
-
resolve({
|
|
28
|
-
compressorLabel: options.compressorLabel ?? "",
|
|
29
|
-
compressor: options.compressor,
|
|
30
|
-
size: options.output ? utils.getFilesizeInBytes(options.output) : "0",
|
|
31
|
-
sizeGzip
|
|
32
|
-
});
|
|
33
|
-
}).catch(reject);
|
|
34
|
-
}).catch(reject);
|
|
35
|
-
});
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
// src/spinner.ts
|
|
39
|
-
import chalk from "chalk";
|
|
40
|
-
import ora from "ora";
|
|
41
|
-
var spinner = ora();
|
|
42
|
-
var start = (options) => {
|
|
43
|
-
spinner.text = `Compressing file(s) with ${chalk.green(
|
|
44
|
-
options.compressorLabel
|
|
45
|
-
)}...`;
|
|
46
|
-
spinner.start();
|
|
47
|
-
};
|
|
48
|
-
var stop = (result) => {
|
|
49
|
-
spinner.text = `File(s) compressed successfully with ${chalk.green(
|
|
50
|
-
result.compressorLabel
|
|
51
|
-
)} (${chalk.green(result.size)} minified, ${chalk.green(
|
|
52
|
-
result.sizeGzip
|
|
53
|
-
)} gzipped)`;
|
|
54
|
-
spinner.succeed();
|
|
55
|
-
};
|
|
56
|
-
var error = (options) => {
|
|
57
|
-
spinner.text = `Error - file(s) not compressed with ${chalk.red(
|
|
58
|
-
options.compressorLabel
|
|
59
|
-
)}`;
|
|
60
|
-
spinner.fail();
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
// src/index.ts
|
|
64
|
-
var silence = false;
|
|
65
|
-
var runOne = async (cli) => {
|
|
66
|
-
const compressor = typeof cli.compressor === "string" ? await import(`@node-minify/${cli.compressor}`) : cli.compressor;
|
|
67
|
-
const compressorName = typeof cli.compressor === "string" ? cli.compressor : cli.compressor ? cli.compressor.name : "unknownCompressor";
|
|
68
|
-
const options = {
|
|
69
|
-
compressorLabel: compressorName,
|
|
70
|
-
compressor: compressor.default,
|
|
71
|
-
input: typeof cli.input === "string" ? cli.input.split(",") : "",
|
|
72
|
-
output: cli.output
|
|
73
|
-
};
|
|
74
|
-
if (cli.option) {
|
|
75
|
-
options.options = JSON.parse(cli.option);
|
|
76
|
-
}
|
|
77
|
-
if (!silence) {
|
|
78
|
-
start(options);
|
|
79
|
-
}
|
|
80
|
-
return compress(options).then((result) => {
|
|
81
|
-
if (!silence) {
|
|
82
|
-
stop(result);
|
|
83
|
-
}
|
|
84
|
-
return result;
|
|
85
|
-
}).catch((err) => {
|
|
86
|
-
if (!silence) {
|
|
87
|
-
error(options);
|
|
88
|
-
}
|
|
89
|
-
throw err;
|
|
90
|
-
});
|
|
91
|
-
};
|
|
92
|
-
var run = (cli) => {
|
|
93
|
-
silence = !!cli.silence;
|
|
94
|
-
if (!silence) {
|
|
95
|
-
console.log("");
|
|
96
|
-
console.log(chalk2.bgBlue.black(" INFO "), "Starting compression...");
|
|
97
|
-
console.log("");
|
|
98
|
-
}
|
|
99
|
-
return new Promise((resolve, reject) => {
|
|
100
|
-
runOne(cli).then(() => {
|
|
101
|
-
if (!silence) {
|
|
102
|
-
console.log("");
|
|
103
|
-
console.log(
|
|
104
|
-
chalk2.bgGreen.black(" DONE "),
|
|
105
|
-
chalk2.green("Done!")
|
|
106
|
-
);
|
|
107
|
-
console.log("");
|
|
108
|
-
}
|
|
109
|
-
}).then(resolve).catch(reject);
|
|
110
|
-
});
|
|
111
|
-
};
|
|
112
|
-
export {
|
|
113
|
-
run
|
|
114
|
-
};
|
|
115
|
-
/*!
|
|
116
|
-
* node-minify
|
|
117
|
-
* Copyright(c) 2011-2024 Rodolphe Stoclin
|
|
118
|
-
* MIT Licensed
|
|
119
|
-
*/
|
|
120
|
-
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/compress.ts","../src/spinner.ts"],"sourcesContent":["/*!\n * node-minify\n * Copyright(c) 2011-2024 Rodolphe Stoclin\n * MIT Licensed\n */\n\n/**\n * Module dependencies.\n */\nimport type { Result, Settings } from \"@node-minify/types\";\n// @ts-expect-error moduleResolution:nodenext issue 54523\nimport chalk from \"chalk\";\nimport { compress } from \"./compress\";\nimport { spinnerError, spinnerStart, spinnerStop } from \"./spinner\";\n\n/**\n * Module variables.\n */\nlet silence = false;\n\n/**\n * Run one compressor.\n * @param cli Settings\n */\nconst runOne = async (cli: Settings) => {\n const compressor =\n typeof cli.compressor === \"string\"\n ? await import(`@node-minify/${cli.compressor}`)\n : cli.compressor;\n\n const compressorName =\n typeof cli.compressor === \"string\"\n ? cli.compressor\n : cli.compressor\n ? cli.compressor.name\n : \"unknownCompressor\";\n\n const options: Settings = {\n compressorLabel: compressorName,\n compressor: compressor.default,\n input: typeof cli.input === \"string\" ? cli.input.split(\",\") : \"\",\n output: cli.output,\n };\n\n if (cli.option) {\n options.options = JSON.parse(cli.option);\n }\n\n if (!silence) {\n spinnerStart(options);\n }\n\n return compress(options)\n .then((result: Result) => {\n if (!silence) {\n spinnerStop(result);\n }\n return result;\n })\n .catch((err: Error) => {\n if (!silence) {\n spinnerError(options);\n }\n throw err;\n });\n};\n\n/**\n * Run cli.\n * @param cli Settings\n */\nconst run = (cli: Settings) => {\n silence = !!cli.silence;\n\n if (!silence) {\n console.log(\"\");\n console.log(chalk.bgBlue.black(\" INFO \"), \"Starting compression...\");\n console.log(\"\");\n }\n\n return new Promise((resolve, reject) => {\n runOne(cli)\n .then(() => {\n if (!silence) {\n console.log(\"\");\n console.log(\n chalk.bgGreen.black(\" DONE \"),\n chalk.green(\"Done!\")\n );\n console.log(\"\");\n }\n })\n .then(resolve)\n .catch(reject);\n });\n};\n\n/**\n * Expose `run()`.\n */\nexport { run };\n","/*!\n * node-minify\n * Copyright(c) 2011-2024 Rodolphe Stoclin\n * MIT Licensed\n */\n\n/**\n * Module dependencies.\n */\nimport minify from \"@node-minify/core\";\nimport type { Result, Settings } from \"@node-minify/types\";\nimport { utils } from \"@node-minify/utils\";\n\n/**\n * Run compression.\n * @param options Settings\n */\nconst compress = (options: Settings): Promise<Result> => {\n return new Promise<Result>((resolve, reject) => {\n minify(options)\n .then(() => {\n if (options?.output?.includes(\"$1\")) {\n // npx node-minify --compressor uglify-js --input 'source/**/*.js' --output 'source/$1.min.js' --option '{\"warnings\": true, \"mangle\": false}'\n return resolve({\n compressorLabel: options.compressorLabel ?? \"\",\n compressor: options.compressor,\n size: \"0\",\n sizeGzip: \"0\",\n });\n }\n if (!options.output) {\n return resolve({\n compressorLabel: options.compressorLabel ?? \"\",\n compressor: options.compressor,\n size: \"0\",\n sizeGzip: \"0\",\n });\n }\n utils\n .getFilesizeGzippedInBytes(options.output)\n .then((sizeGzip: string) => {\n resolve({\n compressorLabel: options.compressorLabel ?? \"\",\n compressor: options.compressor,\n size: options.output\n ? utils.getFilesizeInBytes(options.output)\n : \"0\",\n sizeGzip: sizeGzip,\n });\n })\n .catch(reject);\n })\n .catch(reject);\n });\n};\n\n/**\n * Expose `compress()`.\n */\nexport { compress };\n","/*!\n * node-minify\n * Copyright(c) 2011-2024 Rodolphe Stoclin\n * MIT Licensed\n */\n\n/**\n * Module dependencies.\n */\nimport type { Result, Settings } from \"@node-minify/types\";\nimport chalk from \"chalk\";\nimport ora from \"ora\";\n\nconst spinner = ora();\n\n/**\n * Start spinner.\n * @param options Settings\n */\nconst start = (options: Settings) => {\n spinner.text = `Compressing file(s) with ${chalk.green(\n options.compressorLabel\n )}...`;\n spinner.start();\n};\n\n/**\n * Stop spinner.\n * @param result\n */\nconst stop = (result: Result) => {\n spinner.text = `File(s) compressed successfully with ${chalk.green(\n result.compressorLabel\n )} (${chalk.green(result.size)} minified, ${chalk.green(\n result.sizeGzip\n )} gzipped)`;\n spinner.succeed();\n};\n\n/**\n * Mark spinner as failed.\n * @param options Settings\n */\nconst error = (options: Settings) => {\n spinner.text = `Error - file(s) not compressed with ${chalk.red(\n options.compressorLabel\n )}`;\n spinner.fail();\n};\n\n/**\n * Expose `start(), stop() and error()`.\n */\nexport { start as spinnerStart, stop as spinnerStop, error as spinnerError };\n"],"mappings":";AAWA,OAAOA,YAAW;;;ACFlB,OAAO,YAAY;AAEnB,SAAS,aAAa;AAMtB,IAAM,WAAW,CAAC,YAAuC;AACrD,SAAO,IAAI,QAAgB,CAAC,SAAS,WAAW;AAC5C,WAAO,OAAO,EACT,KAAK,MAAM;AACR,UAAI,SAAS,QAAQ,SAAS,IAAI,GAAG;AAEjC,eAAO,QAAQ;AAAA,UACX,iBAAiB,QAAQ,mBAAmB;AAAA,UAC5C,YAAY,QAAQ;AAAA,UACpB,MAAM;A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