@node-minify/cli 8.0.1-beta.0 → 8.0.3-beta.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.d.ts +1 -0
- package/dist/cli.mjs +205 -0
- package/dist/cli.mjs.map +1 -0
- package/dist/index.d.ts +0 -3
- package/dist/index.js +11 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +12 -12
- package/bin/cli.js +0 -55
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
package/dist/cli.mjs
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
3
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
4
|
+
}) : x)(function(x) {
|
|
5
|
+
if (typeof require !== "undefined")
|
|
6
|
+
return require.apply(this, arguments);
|
|
7
|
+
throw new Error('Dynamic require of "' + x + '" is not supported');
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
// src/bin/cli.ts
|
|
11
|
+
import updateNotifier from "update-notifier";
|
|
12
|
+
import { Command } from "commander";
|
|
13
|
+
|
|
14
|
+
// src/index.ts
|
|
15
|
+
import chalk2 from "chalk";
|
|
16
|
+
|
|
17
|
+
// src/compress.ts
|
|
18
|
+
import minify from "@node-minify/core";
|
|
19
|
+
import { utils } from "@node-minify/utils";
|
|
20
|
+
var compress = (options2) => {
|
|
21
|
+
return new Promise((resolve, reject) => {
|
|
22
|
+
minify(options2).then(() => {
|
|
23
|
+
if (options2.output.includes("$1")) {
|
|
24
|
+
return resolve({
|
|
25
|
+
compressorLabel: options2.compressorLabel || "",
|
|
26
|
+
compressor: options2.compressor,
|
|
27
|
+
size: "0",
|
|
28
|
+
sizeGzip: "0"
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
utils.getFilesizeGzippedInBytes(options2.output).then((sizeGzip) => {
|
|
32
|
+
resolve({
|
|
33
|
+
compressorLabel: options2.compressorLabel || "",
|
|
34
|
+
compressor: options2.compressor,
|
|
35
|
+
size: utils.getFilesizeInBytes(options2.output),
|
|
36
|
+
sizeGzip
|
|
37
|
+
});
|
|
38
|
+
}).catch(reject);
|
|
39
|
+
}).catch(reject);
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
// src/spinner.ts
|
|
44
|
+
import chalk from "chalk";
|
|
45
|
+
import ora from "ora";
|
|
46
|
+
var spinner = ora();
|
|
47
|
+
var start = (options2) => {
|
|
48
|
+
spinner.text = "Compressing file(s) with " + chalk.green(options2.compressorLabel) + "...";
|
|
49
|
+
spinner.start();
|
|
50
|
+
};
|
|
51
|
+
var stop = (result) => {
|
|
52
|
+
spinner.text = "File(s) compressed successfully with " + chalk.green(result.compressorLabel) + " (" + chalk.green(result.size) + " minified, " + chalk.green(result.sizeGzip) + " gzipped)";
|
|
53
|
+
spinner.succeed();
|
|
54
|
+
};
|
|
55
|
+
var error = (options2) => {
|
|
56
|
+
spinner.text = "Error - file(s) not compressed with " + chalk.red(options2.compressorLabel);
|
|
57
|
+
spinner.fail();
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
// src/index.ts
|
|
61
|
+
var silence = false;
|
|
62
|
+
var runOne = (cli) => {
|
|
63
|
+
return new Promise((resolve, reject) => {
|
|
64
|
+
const compressor = typeof cli.compressor === "string" ? __require(`@node-minify/${cli.compressor}`).default : cli.compressor;
|
|
65
|
+
const compressorName = typeof cli.compressor === "string" ? cli.compressor : cli.compressor ? cli.compressor.name : "unknownCompressor";
|
|
66
|
+
const options2 = {
|
|
67
|
+
compressorLabel: compressorName,
|
|
68
|
+
compressor,
|
|
69
|
+
input: typeof cli.input === "string" ? cli.input.split(",") : "",
|
|
70
|
+
output: cli.output
|
|
71
|
+
};
|
|
72
|
+
if (cli.option) {
|
|
73
|
+
options2.options = JSON.parse(cli.option);
|
|
74
|
+
}
|
|
75
|
+
if (!silence) {
|
|
76
|
+
start(options2);
|
|
77
|
+
}
|
|
78
|
+
return compress(options2).then((result) => {
|
|
79
|
+
if (!silence) {
|
|
80
|
+
stop(result);
|
|
81
|
+
}
|
|
82
|
+
resolve(result);
|
|
83
|
+
}).catch((err) => {
|
|
84
|
+
if (!silence) {
|
|
85
|
+
error(options2);
|
|
86
|
+
}
|
|
87
|
+
reject(err);
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
var run = (cli) => {
|
|
92
|
+
silence = !!cli.silence;
|
|
93
|
+
if (!silence) {
|
|
94
|
+
console.log("");
|
|
95
|
+
console.log(chalk2.bgBlue.black(" INFO "), "Starting compression...");
|
|
96
|
+
console.log("");
|
|
97
|
+
}
|
|
98
|
+
return new Promise((resolve, reject) => {
|
|
99
|
+
runOne(cli).then(() => {
|
|
100
|
+
if (!silence) {
|
|
101
|
+
console.log("");
|
|
102
|
+
console.log(chalk2.bgGreen.black(" DONE "), chalk2.green("Done!"));
|
|
103
|
+
console.log("");
|
|
104
|
+
}
|
|
105
|
+
}).then(resolve).catch(reject);
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
// package.json
|
|
110
|
+
var package_default = {
|
|
111
|
+
name: "@node-minify/cli",
|
|
112
|
+
version: "8.0.3-beta.0",
|
|
113
|
+
description: "CLI - command line interface for @node-minify",
|
|
114
|
+
keywords: [
|
|
115
|
+
"compressor",
|
|
116
|
+
"minify",
|
|
117
|
+
"minifier"
|
|
118
|
+
],
|
|
119
|
+
author: "Rodolphe Stoclin <srodolphe@gmail.com>",
|
|
120
|
+
homepage: "https://github.com/srod/node-minify/tree/master/packages/cli#readme",
|
|
121
|
+
license: "MIT",
|
|
122
|
+
bin: {
|
|
123
|
+
"node-minify": "dist/cli.mjs"
|
|
124
|
+
},
|
|
125
|
+
engines: {
|
|
126
|
+
node: ">=16.0.0"
|
|
127
|
+
},
|
|
128
|
+
directories: {
|
|
129
|
+
lib: "dist",
|
|
130
|
+
test: "__tests__"
|
|
131
|
+
},
|
|
132
|
+
main: "./dist/index.js",
|
|
133
|
+
module: "./dist/index.mjs",
|
|
134
|
+
types: "./dist/index.d.ts",
|
|
135
|
+
exports: {
|
|
136
|
+
require: "./dist/index.js",
|
|
137
|
+
import: "./dist/index.mjs",
|
|
138
|
+
types: "./dist/index.d.ts"
|
|
139
|
+
},
|
|
140
|
+
files: [
|
|
141
|
+
"bin",
|
|
142
|
+
"dist/**/*"
|
|
143
|
+
],
|
|
144
|
+
publishConfig: {
|
|
145
|
+
access: "public"
|
|
146
|
+
},
|
|
147
|
+
repository: {
|
|
148
|
+
type: "git",
|
|
149
|
+
url: "git+https://github.com/srod/node-minify.git"
|
|
150
|
+
},
|
|
151
|
+
bugs: {
|
|
152
|
+
url: "https://github.com/srod/node-minify/issues"
|
|
153
|
+
},
|
|
154
|
+
scripts: {
|
|
155
|
+
clean: "pnpm dlx rimraf dist",
|
|
156
|
+
build: "pnpm clean && tsup src/index.ts --format cjs,esm --dts --sourcemap && tsup src/bin/cli.ts --format esm --dts --sourcemap",
|
|
157
|
+
prepublishOnly: "pnpm build"
|
|
158
|
+
},
|
|
159
|
+
dependencies: {
|
|
160
|
+
"@node-minify/core": "8.0.3-beta.0",
|
|
161
|
+
"@node-minify/utils": "8.0.3-beta.0",
|
|
162
|
+
chalk: "5.2.0",
|
|
163
|
+
commander: "9.5.0",
|
|
164
|
+
ora: "6.1.2",
|
|
165
|
+
"update-notifier": "6.0.2"
|
|
166
|
+
},
|
|
167
|
+
devDependencies: {
|
|
168
|
+
"@node-minify/types": "8.0.3-beta.0",
|
|
169
|
+
"@types/chalk": "^2.2.0",
|
|
170
|
+
"@types/ora": "^3.2.0"
|
|
171
|
+
},
|
|
172
|
+
gitHead: "f79e146eed24ca117756cf029eb5005631f12892"
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
// src/bin/cli.ts
|
|
176
|
+
var program = new Command();
|
|
177
|
+
updateNotifier({ pkg: package_default }).notify();
|
|
178
|
+
program.storeOptionsAsProperties().version(package_default.version, "-v, --version").option("-c, --compressor [compressor]", "use the specified compressor [uglify-js]", "uglify-js").option("-i, --input [file]", "input file path").option("-o, --output [file]", "output file path").option("-s, --silence", "no output will be printed").option("-O, --option [option]", "option for the compressor as JSON object", "");
|
|
179
|
+
program.on("--help", function() {
|
|
180
|
+
console.log(" List of compressors:");
|
|
181
|
+
console.log("");
|
|
182
|
+
console.log(" - babel-minify");
|
|
183
|
+
console.log(" - gcc");
|
|
184
|
+
console.log(" - html-minifier");
|
|
185
|
+
console.log(" - terser");
|
|
186
|
+
console.log(" - uglify-js");
|
|
187
|
+
console.log(" - uglify-es");
|
|
188
|
+
console.log(" - yui");
|
|
189
|
+
console.log("");
|
|
190
|
+
});
|
|
191
|
+
program.parse(process.argv);
|
|
192
|
+
var options = program.opts();
|
|
193
|
+
if (!options.compressor || !options.input || !options.output) {
|
|
194
|
+
program.help();
|
|
195
|
+
}
|
|
196
|
+
run(options).then(() => process.exit()).catch((err) => {
|
|
197
|
+
console.error(err);
|
|
198
|
+
process.exit(1);
|
|
199
|
+
});
|
|
200
|
+
/*!
|
|
201
|
+
* node-minify
|
|
202
|
+
* Copyright(c) 2011-2022 Rodolphe Stoclin
|
|
203
|
+
* MIT Licensed
|
|
204
|
+
*/
|
|
205
|
+
//# sourceMappingURL=cli.mjs.map
|
package/dist/cli.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
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-2022 Rodolphe Stoclin\n * MIT Licensed\n */\n\nimport updateNotifier from 'update-notifier';\nimport { Command } from 'commander';\nconst program = new Command();\nimport { run } from '../';\nimport packageJson from '../../package.json';\nimport { Settings } from '@node-minify/types';\n\nupdateNotifier({ pkg: packageJson }).notify();\n\nprogram\n .storeOptionsAsProperties()\n .version(packageJson.version, '-v, --version')\n .option('-c, --compressor [compressor]', 'use the specified compressor [uglify-js]', 'uglify-js')\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('-O, --option [option]', 'option for the compressor as JSON object', '');\n\nprogram.on('--help', function () {\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-2022 Rodolphe Stoclin\n * MIT Licensed\n */\n\n/**\n * Module dependencies.\n */\nimport chalk from 'chalk';\nimport { compress } from './compress';\nimport { spinnerStart, spinnerStop, spinnerError } from './spinner';\nimport { Settings, Result } from '@node-minify/types';\n\n/**\n * Module variables.\n */\nlet silence = false;\n\n/**\n * Run one compressor.\n */\nconst runOne = (cli: Settings): Promise<Result> => {\n return new Promise<Result>((resolve, reject) => {\n /* eslint-disable @typescript-eslint/no-var-requires */\n const compressor =\n typeof cli.compressor === 'string' ? require(`@node-minify/${cli.compressor}`).default : cli.compressor;\n /* eslint-enable @typescript-eslint/no-var-requires */\n\n const compressorName =\n typeof cli.compressor === 'string' ? cli.compressor : cli.compressor ? cli.compressor.name : 'unknownCompressor';\n\n const options: Settings = {\n compressorLabel: compressorName,\n compressor,\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 resolve(result);\n })\n .catch((err: Error) => {\n if (!silence) {\n spinnerError(options);\n }\n reject(err);\n });\n });\n};\n\n/**\n * Run cli.\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(chalk.bgGreen.black(' DONE '), chalk.green('Done!'));\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-2022 Rodolphe Stoclin\n * MIT Licensed\n */\n\n/**\n * Module dependencies.\n */\nimport minify from '@node-minify/core';\nimport { utils } from '@node-minify/utils';\nimport { Settings, Result } from '@node-minify/types';\n\n/**\n * Run compression.\n *\n * @param {Object} options\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 // TODO handle $1 output\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 utils\n .getFilesizeGzippedInBytes(options.output)\n .then((sizeGzip: string) => {\n resolve({\n compressorLabel: options.compressorLabel || '',\n compressor: options.compressor,\n size: utils.getFilesizeInBytes(options.output),\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-2022 Rodolphe Stoclin\n * MIT Licensed\n */\n\n/**\n * Module dependencies.\n */\nimport chalk from 'chalk';\nimport ora from 'ora';\nimport { Settings, Result } from '@node-minify/types';\n\nconst spinner = ora();\n\n/**\n * Start spinner.\n *\n * @param {Object} options\n */\nconst start = (options: Settings) => {\n spinner.text = 'Compressing file(s) with ' + chalk.green(options.compressorLabel) + '...';\n spinner.start();\n};\n\n/**\n * Stop spinner.\n *\n * @param {Object} result\n */\nconst stop = (result: Result) => {\n spinner.text =\n 'File(s) compressed successfully with ' +\n chalk.green(result.compressorLabel) +\n ' (' +\n chalk.green(result.size) +\n ' minified, ' +\n chalk.green(result.sizeGzip) +\n ' gzipped)';\n spinner.succeed();\n};\n\n/**\n * Mark spinner as failed.\n *\n * @param {Object} options\n */\nconst error = (options: Settings) => {\n spinner.text = 'Error - file(s) not compressed with ' + chalk.red(options.compressorLabel);\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\": \"8.0.3-beta.0\",\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\": \">=16.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 \"require\": \"./dist/index.js\",\n \"import\": \"./dist/index.mjs\",\n \"types\": \"./dist/index.d.ts\"\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 \"prepublishOnly\": \"pnpm build\"\n },\n \"dependencies\": {\n \"@node-minify/core\": \"8.0.3-beta.0\",\n \"@node-minify/utils\": \"8.0.3-beta.0\",\n \"chalk\": \"5.2.0\",\n \"commander\": \"9.5.0\",\n \"ora\": \"6.1.2\",\n \"update-notifier\": \"6.0.2\"\n },\n \"devDependencies\": {\n \"@node-minify/types\": \"8.0.3-beta.0\",\n \"@types/chalk\": \"^2.2.0\",\n \"@types/ora\": \"^3.2.0\"\n },\n \"gitHead\": \"f79e146eed24ca117756cf029eb5005631f12892\"\n}\n"],"mappings":";;;;;;;;;;AAQA,OAAO,oBAAoB;AAC3B,SAAS,eAAe;;;ACAxB,OAAOA,YAAW;;;ACAlB,OAAO,YAAY;AACnB,SAAS,aAAa;AAQtB,IAAM,WAAW,CAACC,aAAuC;AACvD,SAAO,IAAI,QAAgB,CAAC,SAAS,WAAW;AAC9C,WAAOA,QAAO,EACX,KAAK,MAAM;AACV,UAAIA,SAAQ,OAAO,SAAS,IAAI,GAAG;AAGjC,eAAO,QAAQ;AAAA,UACb,iBAAiBA,SAAQ,mBAAmB;AAAA,UAC5C,YAAYA,SAAQ;AAAA,UACpB,MAAM;AAAA,UACN,UAAU;AAAA,QACZ,CAAC;AAAA,MACH;AACA,YACG,0BAA0BA,SAAQ,MAAM,EACxC,KAAK,CAAC,aAAqB;AAC1B,gBAAQ;AAAA,UACN,iBAAiBA,SAAQ,mBAAmB;AAAA,UAC5C,YAAYA,SAAQ;AAAA,UACpB,MAAM,MAAM,mBAAmBA,SAAQ,MAAM;AAAA,UAC7C;AAAA,QACF,CAAC;AAAA,MACH,CAAC,EACA,MAAM,MAAM;AAAA,IACjB,CAAC,EACA,MAAM,MAAM;A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AAK,CAAC,EACzB,MAAM,SAAO;AACZ,UAAQ,MAAM,GAAG;AACjB,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":["chalk","options","options","options","chalk"]}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -17,6 +18,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
18
|
return to;
|
|
18
19
|
};
|
|
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.
|
|
20
25
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
26
|
mod
|
|
22
27
|
));
|
|
@@ -38,15 +43,15 @@ var compress = (options) => {
|
|
|
38
43
|
(0, import_core.default)(options).then(() => {
|
|
39
44
|
if (options.output.includes("$1")) {
|
|
40
45
|
return resolve({
|
|
41
|
-
compressorLabel: options.compressorLabel,
|
|
46
|
+
compressorLabel: options.compressorLabel || "",
|
|
42
47
|
compressor: options.compressor,
|
|
43
|
-
size: 0,
|
|
44
|
-
sizeGzip: 0
|
|
48
|
+
size: "0",
|
|
49
|
+
sizeGzip: "0"
|
|
45
50
|
});
|
|
46
51
|
}
|
|
47
52
|
import_utils.utils.getFilesizeGzippedInBytes(options.output).then((sizeGzip) => {
|
|
48
53
|
resolve({
|
|
49
|
-
compressorLabel: options.compressorLabel,
|
|
54
|
+
compressorLabel: options.compressorLabel || "",
|
|
50
55
|
compressor: options.compressor,
|
|
51
56
|
size: import_utils.utils.getFilesizeInBytes(options.output),
|
|
52
57
|
sizeGzip
|
|
@@ -78,8 +83,9 @@ var silence = false;
|
|
|
78
83
|
var runOne = (cli) => {
|
|
79
84
|
return new Promise((resolve, reject) => {
|
|
80
85
|
const compressor = typeof cli.compressor === "string" ? require(`@node-minify/${cli.compressor}`).default : cli.compressor;
|
|
86
|
+
const compressorName = typeof cli.compressor === "string" ? cli.compressor : cli.compressor ? cli.compressor.name : "unknownCompressor";
|
|
81
87
|
const options = {
|
|
82
|
-
compressorLabel:
|
|
88
|
+
compressorLabel: compressorName,
|
|
83
89
|
compressor,
|
|
84
90
|
input: typeof cli.input === "string" ? cli.input.split(",") : "",
|
|
85
91
|
output: cli.output
|
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-2022 Rodolphe Stoclin\n * MIT Licensed\n */\n\n/**\n * Module dependencies.\n */\nimport chalk from 'chalk';\nimport { compress } from './compress';\nimport { spinnerStart, spinnerStop, spinnerError } from './spinner';\nimport { Settings, Result } from '@node-minify/types';\n\n
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/compress.ts","../src/spinner.ts"],"sourcesContent":["/*!\n * node-minify\n * Copyright(c) 2011-2022 Rodolphe Stoclin\n * MIT Licensed\n */\n\n/**\n * Module dependencies.\n */\nimport chalk from 'chalk';\nimport { compress } from './compress';\nimport { spinnerStart, spinnerStop, spinnerError } from './spinner';\nimport { Settings, Result } from '@node-minify/types';\n\n/**\n * Module variables.\n */\nlet silence = false;\n\n/**\n * Run one compressor.\n */\nconst runOne = (cli: Settings): Promise<Result> => {\n return new Promise<Result>((resolve, reject) => {\n /* eslint-disable @typescript-eslint/no-var-requires */\n const compressor =\n typeof cli.compressor === 'string' ? require(`@node-minify/${cli.compressor}`).default : cli.compressor;\n /* eslint-enable @typescript-eslint/no-var-requires */\n\n const compressorName =\n typeof cli.compressor === 'string' ? cli.compressor : cli.compressor ? cli.compressor.name : 'unknownCompressor';\n\n const options: Settings = {\n compressorLabel: compressorName,\n compressor,\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 resolve(result);\n })\n .catch((err: Error) => {\n if (!silence) {\n spinnerError(options);\n }\n reject(err);\n });\n });\n};\n\n/**\n * Run cli.\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(chalk.bgGreen.black(' DONE '), chalk.green('Done!'));\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-2022 Rodolphe Stoclin\n * MIT Licensed\n */\n\n/**\n * Module dependencies.\n */\nimport minify from '@node-minify/core';\nimport { utils } from '@node-minify/utils';\nimport { Settings, Result } from '@node-minify/types';\n\n/**\n * Run compression.\n *\n * @param {Object} options\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 // TODO handle $1 output\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 utils\n .getFilesizeGzippedInBytes(options.output)\n .then((sizeGzip: string) => {\n resolve({\n compressorLabel: options.compressorLabel || '',\n compressor: options.compressor,\n size: utils.getFilesizeInBytes(options.output),\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-2022 Rodolphe Stoclin\n * MIT Licensed\n */\n\n/**\n * Module dependencies.\n */\nimport chalk from 'chalk';\nimport ora from 'ora';\nimport { Settings, Result } from '@node-minify/types';\n\nconst spinner = ora();\n\n/**\n * Start spinner.\n *\n * @param {Object} options\n */\nconst start = (options: Settings) => {\n spinner.text = 'Compressing file(s) with ' + chalk.green(options.compressorLabel) + '...';\n spinner.start();\n};\n\n/**\n * Stop spinner.\n *\n * @param {Object} result\n */\nconst stop = (result: Result) => {\n spinner.text =\n 'File(s) compressed successfully with ' +\n chalk.green(result.compressorLabel) +\n ' (' +\n chalk.green(result.size) +\n ' minified, ' +\n chalk.green(result.sizeGzip) +\n ' gzipped)';\n spinner.succeed();\n};\n\n/**\n * Mark spinner as failed.\n *\n * @param {Object} options\n */\nconst error = (options: Settings) => {\n spinner.text = 'Error - file(s) not compressed with ' + chalk.red(options.compressorLabel);\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;AASA,IAAAA,gBAAkB;;;ACAlB,kBAAmB;AACnB,mBAAsB;AAQtB,IAAM,WAAW,CAAC,YAAuC;AACvD,SAAO,IAAI,QAAgB,CAAC,SAAS,WAAW;AAC9C,oBAAAC,SAAO,OAAO,EACX,KAAK,MAAM;AACV,UAAI,QAAQ,OAAO,SAAS,IAAI,GAAG;AAGjC,eAAO,QAAQ;AAAA,UACb,iBAAiB,QAAQ,mBAAmB;AAAA,UAC5C,YAAY,QAAQ;AAAA,UACpB,MAAM;AAAA,UACN,UAAU;AAAA,QACZ,CAAC;AAAA,MACH;AACA,yBACG,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A,IACd;AAEA,QAAI,IAAI,QAAQ;AACd,cAAQ,UAAU,KAAK,MAAM,IAAI,MAAM;AAAA,IACzC;AAEA,QAAI,CAAC,SAAS;AACZ,YAAa,OAAO;AAAA,IACtB;AAEA,WAAO,SAAS,OAAO,EACpB,KAAK,CAAC,WAAmB;AACxB,UAAI,CAAC,SAAS;AACZ,aAAY,MAAM;AAAA,MACpB;AACA,cAAQ,MAAM;AAAA,IAChB,CAAC,EACA,MAAM,CAAC,QAAe;AACrB,UAAI,CAAC,SAAS;AACZ,cAAa,OAAO;AAAA,MACtB;AACA,aAAO,GAAG;AAAA,IACZ,CAAC;AAAA,EACL,CAAC;AACH;AAKA,IAAM,MAAM,CAAC,QAAkB;AAC7B,YAAU,CAAC,CAAC,IAAI;AAEhB,MAAI,CAAC,SAAS;AACZ,YAAQ,IAAI,EAAE;AACd,YAAQ,IAAI,cAAAC,QAAM,OAAO,MAAM,QAAQ,GAAG,yBAAyB;AACnE,YAAQ,IAAI,EAAE;AAAA,EAChB;AAEA,SAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACtC,WAAO,GAAG,EACP,KAAK,MAAM;AACV,UAAI,CAAC,SAAS;AACZ,gBAAQ,IAAI,EAAE;AACd,gBAAQ,IAAI,cAAAA,QAAM,QAAQ,MAAM,QAAQ,GAAG,cAAAA,QAAM,MAAM,OAAO,CAAC;AAC/D,gBAAQ,IAAI,EAAE;AAAA,MAChB;AAAA,IACF,CAAC,EACA,KAAK,OAAO,EACZ,MAAM,MAAM;AAAA,EACjB,CAAC;AACH;","names":["import_chalk","minify","ora","chalk","chalk"]}
|
package/dist/index.mjs
CHANGED
|
@@ -17,15 +17,15 @@ var compress = (options) => {
|
|
|
17
17
|
minify(options).then(() => {
|
|
18
18
|
if (options.output.includes("$1")) {
|
|
19
19
|
return resolve({
|
|
20
|
-
compressorLabel: options.compressorLabel,
|
|
20
|
+
compressorLabel: options.compressorLabel || "",
|
|
21
21
|
compressor: options.compressor,
|
|
22
|
-
size: 0,
|
|
23
|
-
sizeGzip: 0
|
|
22
|
+
size: "0",
|
|
23
|
+
sizeGzip: "0"
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
26
|
utils.getFilesizeGzippedInBytes(options.output).then((sizeGzip) => {
|
|
27
27
|
resolve({
|
|
28
|
-
compressorLabel: options.compressorLabel,
|
|
28
|
+
compressorLabel: options.compressorLabel || "",
|
|
29
29
|
compressor: options.compressor,
|
|
30
30
|
size: utils.getFilesizeInBytes(options.output),
|
|
31
31
|
sizeGzip
|
|
@@ -57,8 +57,9 @@ var silence = false;
|
|
|
57
57
|
var runOne = (cli) => {
|
|
58
58
|
return new Promise((resolve, reject) => {
|
|
59
59
|
const compressor = typeof cli.compressor === "string" ? __require(`@node-minify/${cli.compressor}`).default : cli.compressor;
|
|
60
|
+
const compressorName = typeof cli.compressor === "string" ? cli.compressor : cli.compressor ? cli.compressor.name : "unknownCompressor";
|
|
60
61
|
const options = {
|
|
61
|
-
compressorLabel:
|
|
62
|
+
compressorLabel: compressorName,
|
|
62
63
|
compressor,
|
|
63
64
|
input: typeof cli.input === "string" ? cli.input.split(",") : "",
|
|
64
65
|
output: cli.output
|
package/dist/index.mjs.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-2022 Rodolphe Stoclin\n * MIT Licensed\n */\n\n/**\n * Module dependencies.\n */\nimport chalk from 'chalk';\nimport { compress } from './compress';\nimport { spinnerStart, spinnerStop, spinnerError } from './spinner';\nimport { Settings, Result } from '@node-minify/types';\n\n
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/compress.ts","../src/spinner.ts"],"sourcesContent":["/*!\n * node-minify\n * Copyright(c) 2011-2022 Rodolphe Stoclin\n * MIT Licensed\n */\n\n/**\n * Module dependencies.\n */\nimport chalk from 'chalk';\nimport { compress } from './compress';\nimport { spinnerStart, spinnerStop, spinnerError } from './spinner';\nimport { Settings, Result } from '@node-minify/types';\n\n/**\n * Module variables.\n */\nlet silence = false;\n\n/**\n * Run one compressor.\n */\nconst runOne = (cli: Settings): Promise<Result> => {\n return new Promise<Result>((resolve, reject) => {\n /* eslint-disable @typescript-eslint/no-var-requires */\n const compressor =\n typeof cli.compressor === 'string' ? require(`@node-minify/${cli.compressor}`).default : cli.compressor;\n /* eslint-enable @typescript-eslint/no-var-requires */\n\n const compressorName =\n typeof cli.compressor === 'string' ? cli.compressor : cli.compressor ? cli.compressor.name : 'unknownCompressor';\n\n const options: Settings = {\n compressorLabel: compressorName,\n compressor,\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 resolve(result);\n })\n .catch((err: Error) => {\n if (!silence) {\n spinnerError(options);\n }\n reject(err);\n });\n });\n};\n\n/**\n * Run cli.\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(chalk.bgGreen.black(' DONE '), chalk.green('Done!'));\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-2022 Rodolphe Stoclin\n * MIT Licensed\n */\n\n/**\n * Module dependencies.\n */\nimport minify from '@node-minify/core';\nimport { utils } from '@node-minify/utils';\nimport { Settings, Result } from '@node-minify/types';\n\n/**\n * Run compression.\n *\n * @param {Object} options\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 // TODO handle $1 output\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 utils\n .getFilesizeGzippedInBytes(options.output)\n .then((sizeGzip: string) => {\n resolve({\n compressorLabel: options.compressorLabel || '',\n compressor: options.compressor,\n size: utils.getFilesizeInBytes(options.output),\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-2022 Rodolphe Stoclin\n * MIT Licensed\n */\n\n/**\n * Module dependencies.\n */\nimport chalk from 'chalk';\nimport ora from 'ora';\nimport { Settings, Result } from '@node-minify/types';\n\nconst spinner = ora();\n\n/**\n * Start spinner.\n *\n * @param {Object} options\n */\nconst start = (options: Settings) => {\n spinner.text = 'Compressing file(s) with ' + chalk.green(options.compressorLabel) + '...';\n spinner.start();\n};\n\n/**\n * Stop spinner.\n *\n * @param {Object} result\n */\nconst stop = (result: Result) => {\n spinner.text =\n 'File(s) compressed successfully with ' +\n chalk.green(result.compressorLabel) +\n ' (' +\n chalk.green(result.size) +\n ' minified, ' +\n chalk.green(result.sizeGzip) +\n ' gzipped)';\n spinner.succeed();\n};\n\n/**\n * Mark spinner as failed.\n *\n * @param {Object} options\n */\nconst error = (options: Settings) => {\n spinner.text = 'Error - file(s) not compressed with ' + chalk.red(options.compressorLabel);\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":";;;;;;;;;AASA,OAAOA,YAAW;;;ACAlB,OAAO,YAAY;AACnB,SAAS,aAAa;AAQtB,IAAM,WAAW,CAAC,YAAuC;AACvD,SAAO,IAAI,QAAgB,CAAC,SAAS,WAAW;AAC9C,WAAO,OAAO,EACX,K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"8.0.
|
|
3
|
+
"version": "8.0.3-beta.0",
|
|
4
4
|
"description": "CLI - command line interface for @node-minify",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"compressor",
|
|
@@ -11,10 +11,10 @@
|
|
|
11
11
|
"homepage": "https://github.com/srod/node-minify/tree/master/packages/cli#readme",
|
|
12
12
|
"license": "MIT",
|
|
13
13
|
"bin": {
|
|
14
|
-
"node-minify": "
|
|
14
|
+
"node-minify": "dist/cli.mjs"
|
|
15
15
|
},
|
|
16
16
|
"engines": {
|
|
17
|
-
"node": ">=
|
|
17
|
+
"node": ">=16.0.0"
|
|
18
18
|
},
|
|
19
19
|
"directories": {
|
|
20
20
|
"lib": "dist",
|
|
@@ -44,21 +44,21 @@
|
|
|
44
44
|
},
|
|
45
45
|
"scripts": {
|
|
46
46
|
"clean": "pnpm dlx rimraf dist",
|
|
47
|
-
"build": "
|
|
48
|
-
"prepublishOnly": "
|
|
47
|
+
"build": "pnpm clean && tsup src/index.ts --format cjs,esm --dts --sourcemap && tsup src/bin/cli.ts --format esm --dts --sourcemap",
|
|
48
|
+
"prepublishOnly": "pnpm build"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@node-minify/core": "8.0.
|
|
52
|
-
"@node-minify/utils": "8.0.
|
|
53
|
-
"chalk": "
|
|
54
|
-
"commander": "9.
|
|
55
|
-
"ora": "
|
|
51
|
+
"@node-minify/core": "8.0.3-beta.0",
|
|
52
|
+
"@node-minify/utils": "8.0.3-beta.0",
|
|
53
|
+
"chalk": "5.2.0",
|
|
54
|
+
"commander": "9.5.0",
|
|
55
|
+
"ora": "6.1.2",
|
|
56
56
|
"update-notifier": "6.0.2"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@node-minify/types": "8.0.
|
|
59
|
+
"@node-minify/types": "8.0.3-beta.0",
|
|
60
60
|
"@types/chalk": "^2.2.0",
|
|
61
61
|
"@types/ora": "^3.2.0"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "f79e146eed24ca117756cf029eb5005631f12892"
|
|
64
64
|
}
|
package/bin/cli.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/*!
|
|
4
|
-
* node-minify
|
|
5
|
-
* Copyright(c) 2011-2022 Rodolphe Stoclin
|
|
6
|
-
* MIT Licensed
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
const updateNotifier = require('update-notifier');
|
|
10
|
-
const program = require('commander');
|
|
11
|
-
const cli = require('../lib/cli');
|
|
12
|
-
const pkg = require('../package.json');
|
|
13
|
-
|
|
14
|
-
updateNotifier({ pkg: pkg }).notify();
|
|
15
|
-
|
|
16
|
-
program
|
|
17
|
-
.storeOptionsAsProperties()
|
|
18
|
-
.version(pkg.version, '-v, --version')
|
|
19
|
-
.option('-c, --compressor [compressor]', 'use the specified compressor [uglify-js]', 'uglify-js')
|
|
20
|
-
.option('-i, --input [file]', 'input file path')
|
|
21
|
-
.option('-o, --output [file]', 'output file path')
|
|
22
|
-
.option('-s, --silence', 'no output will be printed')
|
|
23
|
-
.option('-O, --option [option]', 'option for the compressor as JSON object', '');
|
|
24
|
-
|
|
25
|
-
program.on('--help', function () {
|
|
26
|
-
console.log(' List of compressors:');
|
|
27
|
-
console.log('');
|
|
28
|
-
console.log(' - babel-minify');
|
|
29
|
-
console.log(' - gcc');
|
|
30
|
-
console.log(' - html-minifier');
|
|
31
|
-
console.log(' - terser');
|
|
32
|
-
console.log(' - uglify-js');
|
|
33
|
-
console.log(' - uglify-es');
|
|
34
|
-
console.log(' - yui');
|
|
35
|
-
console.log('');
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
program.parse(process.argv);
|
|
39
|
-
|
|
40
|
-
const options = program.opts();
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Show help if missing mandatory.
|
|
44
|
-
*/
|
|
45
|
-
if (!options.compressor || !options.input || !options.output) {
|
|
46
|
-
program.help();
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
cli
|
|
50
|
-
.run(options)
|
|
51
|
-
.then(() => process.exit())
|
|
52
|
-
.catch(err => {
|
|
53
|
-
console.error(err);
|
|
54
|
-
process.exit(1);
|
|
55
|
-
});
|