@node-minify/cli 10.0.0-next.0 → 10.0.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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2024 Rodolphe Stoclin
3
+ Copyright (c) 2025 Rodolphe Stoclin
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -6,8 +6,8 @@
6
6
  <br>
7
7
  <a href="https://npmjs.org/package/@node-minify/cli"><img src="https://img.shields.io/npm/v/@node-minify/cli.svg"></a>
8
8
  <a href="https://npmjs.org/package/@node-minify/cli"><img src="https://img.shields.io/npm/dm/@node-minify/cli.svg"></a>
9
- <a href="https://github.com/srod/node-minify/actions"><img alt="Build Status" src="https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Fsrod%2Fnode-minify%2Fbadge%3Fref%3Ddevelop&style=flat" /></a>
10
- <a href="https://codecov.io/gh/srod/node-minify"><img src="https://codecov.io/gh/srod/node-minify/branch/develop/graph/badge.svg"></a>
9
+ <a href="https://github.com/srod/node-minify/actions"><img alt="Build Status" src="https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Fsrod%2Fnode-minify%2Fbadge%3Fref%3Dmain&style=flat" /></a>
10
+ <a href="https://codecov.io/gh/srod/node-minify"><img src="https://codecov.io/gh/srod/node-minify/branch/main/graph/badge.svg"></a>
11
11
  </p>
12
12
 
13
13
  # CLI
@@ -34,4 +34,4 @@ Visit https://node-minify.2clics.net/cli.html for full documentation
34
34
 
35
35
  ## License
36
36
 
37
- [MIT](https://github.com/srod/node-minify/blob/develop/LICENSE)
37
+ [MIT](https://github.com/srod/node-minify/blob/main/LICENSE)
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,111 @@
1
+ #!/usr/bin/env node
2
+ import { n as AVAILABLE_MINIFIER, t as run } from "../src-BMvwXoUW.js";
3
+ import { Command } from "commander";
4
+ import updateNotifier from "update-notifier";
5
+
6
+ //#region package.json
7
+ var version = "10.0.0";
8
+ var package_default = {
9
+ name: "@node-minify/cli",
10
+ version,
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: { "node-minify": "dist/cli.js" },
22
+ engines: { "node": ">=20.0.0" },
23
+ directories: {
24
+ "lib": "dist",
25
+ "test": "__tests__"
26
+ },
27
+ types: "./dist/index.d.ts",
28
+ main: "./dist/index.js",
29
+ exports: {
30
+ "types": "./dist/index.d.ts",
31
+ "default": "./dist/index.js"
32
+ },
33
+ sideEffects: false,
34
+ files: ["bin", "dist/**/*"],
35
+ publishConfig: { "access": "public" },
36
+ repository: {
37
+ "type": "git",
38
+ "url": "git+https://github.com/srod/node-minify.git"
39
+ },
40
+ bugs: { "url": "https://github.com/srod/node-minify/issues" },
41
+ scripts: {
42
+ "build": "tsdown src/index.ts src/bin/cli.ts",
43
+ "check-exports": "attw --pack . --profile esm-only",
44
+ "format:check": "biome check .",
45
+ "lint": "biome lint .",
46
+ "prepublishOnly": "bun run build",
47
+ "test": "vitest run",
48
+ "test:ci": "vitest run --coverage",
49
+ "test:watch": "vitest",
50
+ "typecheck": "tsc --noEmit",
51
+ "dev": "tsdown src/index.ts --watch"
52
+ },
53
+ dependencies: {
54
+ "@node-minify/core": "workspace:*",
55
+ "@node-minify/utils": "workspace:*",
56
+ "chalk": "5.6.2",
57
+ "commander": "14.0.2",
58
+ "ora": "9.0.0",
59
+ "update-notifier": "7.3.1"
60
+ },
61
+ devDependencies: {
62
+ "@node-minify/google-closure-compiler": "workspace:*",
63
+ "@node-minify/types": "workspace:*",
64
+ "@node-minify/yui": "workspace:*"
65
+ }
66
+ };
67
+
68
+ //#endregion
69
+ //#region src/bin/cli.ts
70
+ /*!
71
+ * node-minify
72
+ * Copyright(c) 2011-2025 Rodolphe Stoclin
73
+ * MIT Licensed
74
+ */
75
+ const DEFAULT_COMPRESSOR = "uglify-js";
76
+ function setupProgram() {
77
+ const program = new Command();
78
+ program.storeOptionsAsProperties().version(version, "-v, --version").option("-c, --compressor [compressor]", "use the specified compressor [uglify-js]", DEFAULT_COMPRESSOR).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", "");
79
+ program.on("--help", displayCompressorsList);
80
+ return program;
81
+ }
82
+ function displayCompressorsList() {
83
+ console.log(" List of compressors:");
84
+ console.log("");
85
+ AVAILABLE_MINIFIER.forEach((compressor) => {
86
+ console.log(` - ${compressor.name}`);
87
+ });
88
+ console.log("");
89
+ }
90
+ function validateOptions(options, program) {
91
+ if (!options.compressor || !options.input || !options.output) program.help();
92
+ }
93
+ async function main() {
94
+ updateNotifier({ pkg: package_default }).notify();
95
+ const program = setupProgram();
96
+ program.parse(process.argv);
97
+ const options = program.opts();
98
+ validateOptions(options, program);
99
+ try {
100
+ await run(options);
101
+ process.exit(0);
102
+ } catch (error) {
103
+ console.error(error);
104
+ process.exit(1);
105
+ }
106
+ }
107
+ main();
108
+
109
+ //#endregion
110
+ export { };
111
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","names":["packageJson.version","packageJson","options: SettingsWithCompressor"],"sources":["../../package.json","../../src/bin/cli.ts"],"sourcesContent":["","#!/usr/bin/env node\n\n/*!\n * node-minify\n * Copyright(c) 2011-2025 Rodolphe Stoclin\n * MIT Licensed\n */\n\nimport { Command } from \"commander\";\nimport updateNotifier from \"update-notifier\";\nimport packageJson from \"../../package.json\" with { type: \"json\" };\nimport { AVAILABLE_MINIFIER } from \"../config.ts\";\nimport type { SettingsWithCompressor } from \"../index.ts\";\nimport { run } from \"../index.ts\";\n\nconst DEFAULT_COMPRESSOR = \"uglify-js\";\n\nfunction setupProgram(): Command {\n const program = new Command();\n\n program\n .storeOptionsAsProperties()\n .version(packageJson.version, \"-v, --version\")\n .option(\n \"-c, --compressor [compressor]\",\n \"use the specified compressor [uglify-js]\",\n DEFAULT_COMPRESSOR\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\n program.on(\"--help\", displayCompressorsList);\n\n return program;\n}\n\nfunction displayCompressorsList() {\n console.log(\" List of compressors:\");\n console.log(\"\");\n AVAILABLE_MINIFIER.forEach((compressor) => {\n console.log(` - ${compressor.name}`);\n });\n console.log(\"\");\n}\n\nfunction validateOptions(options: SettingsWithCompressor, program: Command) {\n if (!options.compressor || !options.input || !options.output) {\n program.help();\n }\n}\n\nasync function main(): Promise<void> {\n updateNotifier({ pkg: packageJson }).notify();\n\n const program = setupProgram();\n program.parse(process.argv);\n\n const options: SettingsWithCompressor = program.opts();\n validateOptions(options, program);\n\n try {\n await run(options);\n process.exit(0);\n } catch (error) {\n console.error(error);\n process.exit(1);\n }\n}\n\nmain();\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACeA,MAAM,qBAAqB;AAE3B,SAAS,eAAwB;CAC7B,MAAM,UAAU,IAAI,SAAS;AAE7B,SACK,0BAA0B,CAC1B,QAAQA,SAAqB,gBAAgB,CAC7C,OACG,iCACA,4CACA,mBACH,CACA,OAAO,sBAAsB,kBAAkB,CAC/C,OAAO,uBAAuB,mBAAmB,CACjD,OAAO,iBAAiB,4BAA4B,CACpD,OACG,yBACA,4CACA,GACH;AAEL,SAAQ,GAAG,UAAU,uBAAuB;AAE5C,QAAO;;AAGX,SAAS,yBAAyB;AAC9B,SAAQ,IAAI,yBAAyB;AACrC,SAAQ,IAAI,GAAG;AACf,oBAAmB,SAAS,eAAe;AACvC,UAAQ,IAAI,SAAS,WAAW,OAAO;GACzC;AACF,SAAQ,IAAI,GAAG;;AAGnB,SAAS,gBAAgB,SAAiC,SAAkB;AACxE,KAAI,CAAC,QAAQ,cAAc,CAAC,QAAQ,SAAS,CAAC,QAAQ,OAClD,SAAQ,MAAM;;AAItB,eAAe,OAAsB;AACjC,gBAAe,EAAE,KAAKC,iBAAa,CAAC,CAAC,QAAQ;CAE7C,MAAM,UAAU,cAAc;AAC9B,SAAQ,MAAM,QAAQ,KAAK;CAE3B,MAAMC,UAAkC,QAAQ,MAAM;AACtD,iBAAgB,SAAS,QAAQ;AAEjC,KAAI;AACA,QAAM,IAAI,QAAQ;AAClB,UAAQ,KAAK,EAAE;UACV,OAAO;AACZ,UAAQ,MAAM,MAAM;AACpB,UAAQ,KAAK,EAAE;;;AAIvB,MAAM"}
package/dist/index.d.ts CHANGED
@@ -1,11 +1,186 @@
1
- import { Settings } from '@node-minify/types';
1
+ //#region ../types/src/types.d.ts
2
2
 
3
- /*!
4
- * node-minify
5
- * Copyright(c) 2011-2024 Rodolphe Stoclin
6
- * MIT Licensed
3
+ /**
4
+ * Result returned by a compressor function.
7
5
  */
6
+ type CompressorResult = {
7
+ code: string;
8
+ map?: string;
9
+ };
10
+ /**
11
+ * Base options that all compressors can accept.
12
+ * Specific compressors may extend this with their own options.
13
+ */
14
+ type CompressorOptions = Record<string, unknown>;
15
+ /**
16
+ * A compressor function that minifies content.
17
+ * @param args - The minifier options including settings and content
18
+ * @returns A promise resolving to the compression result
19
+ */
20
+ type Compressor<TOptions extends CompressorOptions = CompressorOptions> = (args: MinifierOptions<TOptions>) => Promise<CompressorResult>;
21
+ /**
22
+ * File type for compressors that support multiple types (e.g., YUI).
23
+ */
24
+ type FileType = "js" | "css";
25
+ /**
26
+ * User-facing settings for the minify function.
27
+ * This is what users pass when calling minify().
28
+ *
29
+ * @example
30
+ * ```ts
31
+ * import { minify } from '@node-minify/core';
32
+ * import { terser } from '@node-minify/terser';
33
+ *
34
+ * await minify({
35
+ * compressor: terser,
36
+ * input: 'src/*.js',
37
+ * output: 'dist/bundle.min.js',
38
+ * options: { mangle: true }
39
+ * });
40
+ * ```
41
+ */
42
+ type Settings<TOptions extends CompressorOptions = CompressorOptions> = {
43
+ /**
44
+ * The compressor function to use for minification.
45
+ */
46
+ compressor: Compressor<TOptions>;
47
+
48
+ /**
49
+ * Optional label for the compressor (used in logging).
50
+ */
51
+ compressorLabel?: string;
52
+
53
+ /**
54
+ * Content to minify (for in-memory minification).
55
+ * If provided, input/output are not required.
56
+ */
57
+ content?: string;
58
+
59
+ /**
60
+ * Input file path(s) or glob pattern.
61
+ * Can be a single file, array of files, or wildcard pattern.
62
+ *
63
+ * @example
64
+ * - 'src/app.js'
65
+ * - ['src/a.js', 'src/b.js']
66
+ * - 'src/**\/*.js'
67
+ */
68
+ input?: string | string[];
69
+
70
+ /**
71
+ * Output file path.
72
+ * Use $1 as placeholder for input filename in multi-file scenarios.
73
+ * Can be a single file, array of files, or pattern with $1.
74
+ *
75
+ * @example
76
+ * - 'dist/bundle.min.js'
77
+ * - ['file1.min.js', 'file2.min.js']
78
+ * - '$1.min.js' (creates app.min.js from app.js)
79
+ */
80
+ output?: string | string[];
81
+
82
+ /**
83
+ * Compressor-specific options.
84
+ * See individual compressor documentation for available options.
85
+ */
86
+ options?: TOptions;
8
87
 
9
- declare const run: (cli: Settings) => Promise<unknown>;
88
+ /**
89
+ * CLI option string (used by CLI only).
90
+ * @internal
91
+ */
92
+ option?: string;
10
93
 
11
- export { run };
94
+ /**
95
+ * Buffer size for file operations (in bytes).
96
+ * @default 1024000 (1MB)
97
+ */
98
+ buffer?: number;
99
+
100
+ /**
101
+ * File type for compressors that support multiple types.
102
+ * Required for YUI compressor.
103
+ */
104
+ type?: FileType;
105
+
106
+ /**
107
+ * Suppress console output.
108
+ * @default false
109
+ */
110
+ silence?: boolean;
111
+
112
+ /**
113
+ * Public folder to prepend to input paths.
114
+ *
115
+ * @example
116
+ * With publicFolder: 'public/js/' and input: 'app.js',
117
+ * the actual path becomes 'public/js/app.js'
118
+ */
119
+ publicFolder?: string;
120
+
121
+ /**
122
+ * Replace files in place instead of creating new output files.
123
+ * @default false
124
+ */
125
+ replaceInPlace?: boolean;
126
+ };
127
+ /**
128
+ * Options passed to compressor functions internally.
129
+ * This is what compressors receive, not what users pass.
130
+ */
131
+ type MinifierOptions<TOptions extends CompressorOptions = CompressorOptions> = {
132
+ /**
133
+ * The full settings object.
134
+ */
135
+ settings: Settings<TOptions>;
136
+
137
+ /**
138
+ * The content to minify.
139
+ */
140
+ content?: string;
141
+
142
+ /**
143
+ * Index of current file when processing multiple files.
144
+ */
145
+ index?: number;
146
+ };
147
+ //#endregion
148
+ //#region src/config.d.ts
149
+ declare const AVAILABLE_MINIFIER: readonly [{
150
+ readonly name: "babel-minify";
151
+ readonly export: "babelMinify";
152
+ }, {
153
+ readonly name: "csso";
154
+ readonly export: "csso";
155
+ }, {
156
+ readonly name: "google-closure-compiler";
157
+ readonly export: "gcc";
158
+ }, {
159
+ readonly name: "html-minifier";
160
+ readonly export: "htmlMinifier";
161
+ }, {
162
+ readonly name: "terser";
163
+ readonly export: "terser";
164
+ }, {
165
+ readonly name: "uglify-js";
166
+ readonly export: "uglifyJs";
167
+ }, {
168
+ readonly name: "uglify-es";
169
+ readonly export: "uglifyEs";
170
+ }, {
171
+ readonly name: "yui";
172
+ readonly export: "yui";
173
+ }];
174
+ //#endregion
175
+ //#region src/index.d.ts
176
+ type SettingsWithCompressor = Omit<Settings, "compressor"> & {
177
+ compressor: (typeof AVAILABLE_MINIFIER)[number]["name"];
178
+ };
179
+ /**
180
+ * Run cli.
181
+ * @param cli Settings
182
+ */
183
+ declare function run(cli: SettingsWithCompressor): Promise<void>;
184
+ //#endregion
185
+ export { SettingsWithCompressor, run };
186
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":["CompressorReturnType","CompressorResult","CompressorOptions","Record","Compressor","TOptions","MinifierOptions","Promise","FileType","Settings","Result","MinifyOptions"],"sources":["../../types/src/types.d.ts","../src/config.ts","../src/index.ts"],"sourcesContent":["/*!\n * node-minify\n * Copyright(c) 2011-2025 Rodolphe Stoclin\n * MIT Licensed\n */\n\n/**\n * The return type of a compressor function.\n * @deprecated Use `CompressorResult` instead. Will be removed in v11.\n */\nexport type CompressorReturnType = string;\n\n/**\n * Result returned by a compressor function.\n */\nexport type CompressorResult = {\n code: string;\n map?: string;\n};\n\n/**\n * Base options that all compressors can accept.\n * Specific compressors may extend this with their own options.\n */\nexport type CompressorOptions = Record<string, unknown>;\n\n/**\n * A compressor function that minifies content.\n * @param args - The minifier options including settings and content\n * @returns A promise resolving to the compression result\n */\nexport type Compressor<TOptions extends CompressorOptions = CompressorOptions> =\n (args: MinifierOptions<TOptions>) => Promise<CompressorResult>;\n\n/**\n * File type for compressors that support multiple types (e.g., YUI).\n */\nexport type FileType = \"js\" | \"css\";\n\n/**\n * User-facing settings for the minify function.\n * This is what users pass when calling minify().\n *\n * @example\n * ```ts\n * import { minify } from '@node-minify/core';\n * import { terser } from '@node-minify/terser';\n *\n * await minify({\n * compressor: terser,\n * input: 'src/*.js',\n * output: 'dist/bundle.min.js',\n * options: { mangle: true }\n * });\n * ```\n */\nexport type Settings<TOptions extends CompressorOptions = CompressorOptions> = {\n /**\n * The compressor function to use for minification.\n */\n compressor: Compressor<TOptions>;\n\n /**\n * Optional label for the compressor (used in logging).\n */\n compressorLabel?: string;\n\n /**\n * Content to minify (for in-memory minification).\n * If provided, input/output are not required.\n */\n content?: string;\n\n /**\n * Input file path(s) or glob pattern.\n * Can be a single file, array of files, or wildcard pattern.\n *\n * @example\n * - 'src/app.js'\n * - ['src/a.js', 'src/b.js']\n * - 'src/**\\/*.js'\n */\n input?: string | string[];\n\n /**\n * Output file path.\n * Use $1 as placeholder for input filename in multi-file scenarios.\n * Can be a single file, array of files, or pattern with $1.\n *\n * @example\n * - 'dist/bundle.min.js'\n * - ['file1.min.js', 'file2.min.js']\n * - '$1.min.js' (creates app.min.js from app.js)\n */\n output?: string | string[];\n\n /**\n * Compressor-specific options.\n * See individual compressor documentation for available options.\n */\n options?: TOptions;\n\n /**\n * CLI option string (used by CLI only).\n * @internal\n */\n option?: string;\n\n /**\n * Buffer size for file operations (in bytes).\n * @default 1024000 (1MB)\n */\n buffer?: number;\n\n /**\n * File type for compressors that support multiple types.\n * Required for YUI compressor.\n */\n type?: FileType;\n\n /**\n * Suppress console output.\n * @default false\n */\n silence?: boolean;\n\n /**\n * Public folder to prepend to input paths.\n *\n * @example\n * With publicFolder: 'public/js/' and input: 'app.js',\n * the actual path becomes 'public/js/app.js'\n */\n publicFolder?: string;\n\n /**\n * Replace files in place instead of creating new output files.\n * @default false\n */\n replaceInPlace?: boolean;\n};\n\n/**\n * Options passed to compressor functions internally.\n * This is what compressors receive, not what users pass.\n */\nexport type MinifierOptions<\n TOptions extends CompressorOptions = CompressorOptions,\n> = {\n /**\n * The full settings object.\n */\n settings: Settings<TOptions>;\n\n /**\n * The content to minify.\n */\n content?: string;\n\n /**\n * Index of current file when processing multiple files.\n */\n index?: number;\n};\n\n/**\n * Result returned after compression (used by CLI).\n */\nexport type Result = {\n /**\n * Label of the compressor used.\n */\n compressorLabel: string;\n\n /**\n * Size of minified content (formatted string, e.g., \"1.5 KB\").\n */\n size: string;\n\n /**\n * Gzipped size of minified content (formatted string).\n */\n sizeGzip: string;\n};\n\n/**\n * Type alias for user convenience.\n * @deprecated Use `Settings` instead. Will be removed in v11.\n */\nexport type MinifyOptions<\n TOptions extends CompressorOptions = CompressorOptions,\n> = Settings<TOptions>;\n"],"mappings":";;AAwDA;;;AAI2BK,KA7CfJ,gBAAAA,GA6CeI;EAAXD,IAAAA,EAAAA,MAAAA;EAwCFC,GAAAA,CAAAA,EAAAA,MAAAA;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BM,EAAA,YAAA,CAAA,GAAA;EAKpCD,UAAAA,EAAQ,CAAA,OErBI,kBFqBJ,CAAA,CAAA,MAAA,CAAA,CAAA,MAAA,CAAA;AAmBpB,CAAA;;;;;AA4CcH,iBEnBQ,GAAA,CFmBRA,GAAAA,EEnBiB,sBFmBjBA,CAAAA,EEnBuC,OFmBvCA,CAAAA,IAAAA,CAAAA"}
package/dist/index.js CHANGED
@@ -1,119 +1,3 @@
1
- // src/index.ts
2
- import chalk2 from "chalk";
1
+ import { t as run } from "./src-BMvwXoUW.js";
3
2
 
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
- */
3
+ export { run };
@@ -0,0 +1,169 @@
1
+ import chalk from "chalk";
2
+ import { minify } from "@node-minify/core";
3
+ import { getFilesizeGzippedInBytes, getFilesizeInBytes } from "@node-minify/utils";
4
+ import ora from "ora";
5
+
6
+ //#region src/compress.ts
7
+ /*!
8
+ * node-minify
9
+ * Copyright(c) 2011-2025 Rodolphe Stoclin
10
+ * MIT Licensed
11
+ */
12
+ /**
13
+ * Module dependencies.
14
+ */
15
+ /**
16
+ * Run compression.
17
+ * @param options Settings
18
+ */
19
+ async function compress(options) {
20
+ try {
21
+ await minify(options);
22
+ const defaultResult = {
23
+ compressorLabel: options.compressorLabel ?? "",
24
+ size: "0",
25
+ sizeGzip: "0"
26
+ };
27
+ if (!options.output || Array.isArray(options.output) || options.output.includes("$1")) return defaultResult;
28
+ const sizeGzip = await getFilesizeGzippedInBytes(options.output);
29
+ const size = getFilesizeInBytes(options.output);
30
+ return {
31
+ ...defaultResult,
32
+ size,
33
+ sizeGzip
34
+ };
35
+ } catch (error$1) {
36
+ const errorMessage = error$1 instanceof Error ? error$1.message : "Unknown error occurred";
37
+ throw new Error(`Compression failed: ${errorMessage}`);
38
+ }
39
+ }
40
+
41
+ //#endregion
42
+ //#region src/config.ts
43
+ const AVAILABLE_MINIFIER = [
44
+ {
45
+ name: "babel-minify",
46
+ export: "babelMinify"
47
+ },
48
+ {
49
+ name: "csso",
50
+ export: "csso"
51
+ },
52
+ {
53
+ name: "google-closure-compiler",
54
+ export: "gcc"
55
+ },
56
+ {
57
+ name: "html-minifier",
58
+ export: "htmlMinifier"
59
+ },
60
+ {
61
+ name: "terser",
62
+ export: "terser"
63
+ },
64
+ {
65
+ name: "uglify-js",
66
+ export: "uglifyJs"
67
+ },
68
+ {
69
+ name: "uglify-es",
70
+ export: "uglifyEs"
71
+ },
72
+ {
73
+ name: "yui",
74
+ export: "yui"
75
+ }
76
+ ];
77
+
78
+ //#endregion
79
+ //#region src/spinner.ts
80
+ const spinner = ora();
81
+ /**
82
+ * Formats a compression message with the compressor label
83
+ */
84
+ function formatCompressionMessage(status, compressorLabel) {
85
+ return `${status} with ${chalk.green(compressorLabel)}`;
86
+ }
87
+ /**
88
+ * Start spinner for compression process
89
+ */
90
+ function start({ compressorLabel }) {
91
+ spinner.text = `Compressing file(s) ${formatCompressionMessage("...", compressorLabel)}`;
92
+ spinner.start();
93
+ }
94
+ /**
95
+ * Stop spinner with success message
96
+ */
97
+ function stop({ compressorLabel, size, sizeGzip }) {
98
+ spinner.text = [
99
+ "File(s) compressed successfully",
100
+ formatCompressionMessage("", compressorLabel),
101
+ `(${chalk.green(size)} minified,`,
102
+ `${chalk.green(sizeGzip)} gzipped)`
103
+ ].join(" ");
104
+ spinner.succeed();
105
+ }
106
+ /**
107
+ * Stop spinner with error message
108
+ */
109
+ function error({ compressorLabel }) {
110
+ spinner.text = `Error - file(s) not compressed ${formatCompressionMessage("", compressorLabel)}`;
111
+ spinner.fail();
112
+ }
113
+
114
+ //#endregion
115
+ //#region src/index.ts
116
+ /**
117
+ * Module variables.
118
+ */
119
+ let silence = false;
120
+ /**
121
+ * Run one compressor.
122
+ * @param cli Settings
123
+ */
124
+ async function runOne(cli) {
125
+ const minifierDefinition = AVAILABLE_MINIFIER.find((compressor) => compressor.name === cli.compressor);
126
+ if (!minifierDefinition) throw new Error(`Compressor '${cli.compressor}' not found.`);
127
+ const minifierImplementation = (await import(`@node-minify/${cli.compressor}`))[minifierDefinition.export];
128
+ if (!minifierImplementation || typeof minifierImplementation !== "function") throw new Error(`Invalid compressor implementation for '${cli.compressor}'.`);
129
+ const settings = {
130
+ compressorLabel: cli.compressor,
131
+ compressor: minifierImplementation,
132
+ input: typeof cli.input === "string" ? cli.input.split(",") : cli.input,
133
+ output: cli.output,
134
+ ...cli.option && { options: JSON.parse(cli.option) }
135
+ };
136
+ if (!silence) start(settings);
137
+ try {
138
+ const result = await compress(settings);
139
+ if (!silence) stop(result);
140
+ return result;
141
+ } catch (error$1) {
142
+ if (!silence) error(settings);
143
+ throw error$1;
144
+ }
145
+ }
146
+ /**
147
+ * Run cli.
148
+ * @param cli Settings
149
+ */
150
+ async function run(cli) {
151
+ silence = !!cli.silence;
152
+ if (!silence) logMessage("INFO", "Starting compression...", "bgBlue");
153
+ try {
154
+ await runOne(cli);
155
+ if (!silence) logMessage("DONE", "Done!", "bgGreen", "green");
156
+ } catch (error$1) {
157
+ const errorMessage = error$1 instanceof Error ? error$1.message : "Unknown error occurred";
158
+ throw new Error(`Compression failed: ${errorMessage}`);
159
+ }
160
+ }
161
+ function logMessage(badge, message, badgeColor, messageColor) {
162
+ console.log("");
163
+ console.log(chalk[badgeColor].black(` ${badge} `), messageColor ? chalk[messageColor](message) : message);
164
+ console.log("");
165
+ }
166
+
167
+ //#endregion
168
+ export { AVAILABLE_MINIFIER as n, run as t };
169
+ //# sourceMappingURL=src-BMvwXoUW.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"src-BMvwXoUW.js","names":["defaultResult: Result","error","settings: Settings","error"],"sources":["../src/compress.ts","../src/config.ts","../src/spinner.ts","../src/index.ts"],"sourcesContent":["/*!\n * node-minify\n * Copyright(c) 2011-2025 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 {\n getFilesizeGzippedInBytes,\n getFilesizeInBytes,\n} from \"@node-minify/utils\";\n\n/**\n * Run compression.\n * @param options Settings\n */\nasync function compress(options: Settings): Promise<Result> {\n try {\n await minify(options);\n\n const defaultResult: Result = {\n compressorLabel: options.compressorLabel ?? \"\",\n size: \"0\",\n sizeGzip: \"0\",\n };\n\n // Return default result if output contains pattern, is an array, or is undefined\n // Arrays and $1 patterns produce multiple files, so we can't calculate a single size\n if (\n !options.output ||\n Array.isArray(options.output) ||\n options.output.includes(\"$1\")\n ) {\n return defaultResult;\n }\n\n // Get file sizes\n const sizeGzip = await getFilesizeGzippedInBytes(options.output);\n const size = getFilesizeInBytes(options.output);\n\n return {\n ...defaultResult,\n size,\n sizeGzip,\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : \"Unknown error occurred\";\n throw new Error(`Compression failed: ${errorMessage}`);\n }\n}\n\nexport { compress };\n","export const AVAILABLE_MINIFIER = [\n { name: \"babel-minify\", export: \"babelMinify\" },\n { name: \"csso\", export: \"csso\" },\n { name: \"google-closure-compiler\", export: \"gcc\" },\n { name: \"html-minifier\", export: \"htmlMinifier\" },\n { name: \"terser\", export: \"terser\" },\n { name: \"uglify-js\", export: \"uglifyJs\" },\n { name: \"uglify-es\", export: \"uglifyEs\" },\n { name: \"yui\", export: \"yui\" },\n] as const;\n","/*!\n * node-minify\n * Copyright(c) 2011-2025 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 * Formats a compression message with the compressor label\n */\nfunction formatCompressionMessage(\n status: string,\n compressorLabel?: string\n): string {\n return `${status} with ${chalk.green(compressorLabel)}`;\n}\n\n/**\n * Start spinner for compression process\n */\nfunction start({ compressorLabel }: Settings): void {\n spinner.text = `Compressing file(s) ${formatCompressionMessage(\n \"...\",\n compressorLabel\n )}`;\n spinner.start();\n}\n\n/**\n * Stop spinner with success message\n */\nfunction stop({ compressorLabel, size, sizeGzip }: Result): void {\n spinner.text = [\n \"File(s) compressed successfully\",\n formatCompressionMessage(\"\", compressorLabel),\n `(${chalk.green(size)} minified,`,\n `${chalk.green(sizeGzip)} gzipped)`,\n ].join(\" \");\n spinner.succeed();\n}\n\n/**\n * Stop spinner with error message\n */\nfunction error({ compressorLabel }: Settings): void {\n spinner.text = `Error - file(s) not compressed ${formatCompressionMessage(\n \"\",\n compressorLabel\n )}`;\n spinner.fail();\n}\n\nexport { start as spinnerStart, stop as spinnerStop, error as spinnerError };\n","/*!\n * node-minify\n * Copyright(c) 2011-2025 Rodolphe Stoclin\n * MIT Licensed\n */\n\n/**\n * Module dependencies.\n */\nimport type { Compressor, Result, Settings } from \"@node-minify/types\";\nimport chalk from \"chalk\";\nimport { compress } from \"./compress.ts\";\nimport { AVAILABLE_MINIFIER } from \"./config.ts\";\nimport { spinnerError, spinnerStart, spinnerStop } from \"./spinner.ts\";\n\nexport type SettingsWithCompressor = Omit<Settings, \"compressor\"> & {\n compressor: (typeof AVAILABLE_MINIFIER)[number][\"name\"];\n};\n\n/**\n * Module variables.\n */\nlet silence = false;\n\n/**\n * Run one compressor.\n * @param cli Settings\n */\nasync function runOne(cli: SettingsWithCompressor): Promise<Result> {\n // Find compressor\n const minifierDefinition = AVAILABLE_MINIFIER.find(\n (compressor) => compressor.name === cli.compressor\n );\n\n if (!minifierDefinition) {\n throw new Error(`Compressor '${cli.compressor}' not found.`);\n }\n\n // Load minifier implementation dynamically\n const minifierPackage = (await import(\n `@node-minify/${cli.compressor}`\n )) as Record<string, Compressor>;\n\n const minifierImplementation = minifierPackage[\n minifierDefinition.export\n ] as Compressor;\n\n if (\n !minifierImplementation ||\n typeof minifierImplementation !== \"function\"\n ) {\n throw new Error(\n `Invalid compressor implementation for '${cli.compressor}'.`\n );\n }\n\n // Prepare settings\n const settings: Settings = {\n compressorLabel: cli.compressor,\n compressor: minifierImplementation,\n input: typeof cli.input === \"string\" ? cli.input.split(\",\") : cli.input,\n output: cli.output,\n ...(cli.option && { options: JSON.parse(cli.option) }),\n };\n\n if (!silence) spinnerStart(settings);\n\n try {\n const result = await compress(settings);\n if (!silence) spinnerStop(result);\n return result;\n } catch (error) {\n if (!silence) spinnerError(settings);\n throw error;\n }\n}\n\n/**\n * Run cli.\n * @param cli Settings\n */\nexport async function run(cli: SettingsWithCompressor) {\n silence = !!cli.silence;\n\n if (!silence) {\n logMessage(\"INFO\", \"Starting compression...\", \"bgBlue\");\n }\n\n try {\n await runOne(cli);\n\n if (!silence) {\n logMessage(\"DONE\", \"Done!\", \"bgGreen\", \"green\");\n }\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : \"Unknown error occurred\";\n throw new Error(`Compression failed: ${errorMessage}`);\n }\n}\n\n// Helper function to handle consistent logging\nfunction logMessage(\n badge: \"INFO\" | \"DONE\",\n message: string,\n badgeColor: \"bgBlue\" | \"bgGreen\",\n messageColor?: \"green\"\n) {\n console.log(\"\");\n console.log(\n chalk[badgeColor].black(` ${badge} `),\n messageColor ? chalk[messageColor](message) : message\n );\n console.log(\"\");\n}\n"],"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YACA,cACF;AACE,SAAQ,IAAI,GAAG;AACf,SAAQ,IACJ,MAAM,YAAY,MAAM,IAAI,MAAM,GAAG,EACrC,eAAe,MAAM,cAAc,QAAQ,GAAG,QACjD;AACD,SAAQ,IAAI,GAAG"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@node-minify/cli",
3
- "version": "10.0.0-next.0",
3
+ "version": "10.0.0",
4
4
  "description": "CLI - command line interface for @node-minify",
5
5
  "keywords": [
6
6
  "compressor",
@@ -15,20 +15,19 @@
15
15
  "node-minify": "dist/cli.js"
16
16
  },
17
17
  "engines": {
18
- "node": ">=22.0.0"
18
+ "node": ">=20.0.0"
19
19
  },
20
20
  "directories": {
21
21
  "lib": "dist",
22
22
  "test": "__tests__"
23
23
  },
24
- "main": "./dist/index.cjs",
24
+ "types": "./dist/index.d.ts",
25
+ "main": "./dist/index.js",
25
26
  "exports": {
26
- "./package.json": "./package.json",
27
- ".": {
28
- "import": "./dist/index.js",
29
- "default": "./dist/index.cjs"
30
- }
27
+ "types": "./dist/index.d.ts",
28
+ "default": "./dist/index.js"
31
29
  },
30
+ "sideEffects": false,
32
31
  "files": [
33
32
  "bin",
34
33
  "dist/**/*"
@@ -44,26 +43,28 @@
44
43
  "url": "https://github.com/srod/node-minify/issues"
45
44
  },
46
45
  "scripts": {
47
- "build": "tsup src/index.ts --format cjs,esm --dts && tsup src/bin/cli.ts --format esm --dts",
48
- "check-exports": "attw --pack .",
46
+ "build": "tsdown src/index.ts src/bin/cli.ts",
47
+ "check-exports": "attw --pack . --profile esm-only",
49
48
  "format:check": "biome check .",
50
49
  "lint": "biome lint .",
51
50
  "prepublishOnly": "bun run build",
52
51
  "test": "vitest run",
53
52
  "test:ci": "vitest run --coverage",
54
- "test:watch": "vitest"
53
+ "test:watch": "vitest",
54
+ "typecheck": "tsc --noEmit",
55
+ "dev": "tsdown src/index.ts --watch"
55
56
  },
56
57
  "dependencies": {
57
58
  "@node-minify/core": "workspace:*",
58
59
  "@node-minify/utils": "workspace:*",
59
- "chalk": "5.3.0",
60
- "commander": "12.1.0",
61
- "ora": "8.1.1",
60
+ "chalk": "5.6.2",
61
+ "commander": "14.0.2",
62
+ "ora": "9.0.0",
62
63
  "update-notifier": "7.3.1"
63
64
  },
64
65
  "devDependencies": {
66
+ "@node-minify/google-closure-compiler": "workspace:*",
65
67
  "@node-minify/types": "workspace:*",
66
- "@types/chalk": "^2.2.4",
67
- "@types/ora": "^3.2.0"
68
+ "@node-minify/yui": "workspace:*"
68
69
  }
69
70
  }
package/dist/cli.d.ts DELETED
@@ -1 +0,0 @@
1
- #!/usr/bin/env node
package/dist/cli.js DELETED
@@ -1,227 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // src/bin/cli.ts
4
- import { Command } from "commander";
5
- import updateNotifier from "update-notifier";
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
-
78
- // src/index.ts
79
- import chalk2 from "chalk";
80
-
81
- // src/compress.ts
82
- import minify from "@node-minify/core";
83
- import { utils } from "@node-minify/utils";
84
- var compress = (options2) => {
85
- return new Promise((resolve, reject) => {
86
- minify(options2).then(() => {
87
- if (options2?.output?.includes("$1")) {
88
- return resolve({
89
- compressorLabel: options2.compressorLabel ?? "",
90
- compressor: options2.compressor,
91
- size: "0",
92
- sizeGzip: "0"
93
- });
94
- }
95
- if (!options2.output) {
96
- return resolve({
97
- compressorLabel: options2.compressorLabel ?? "",
98
- compressor: options2.compressor,
99
- size: "0",
100
- sizeGzip: "0"
101
- });
102
- }
103
- utils.getFilesizeGzippedInBytes(options2.output).then((sizeGzip) => {
104
- resolve({
105
- compressorLabel: options2.compressorLabel ?? "",
106
- compressor: options2.compressor,
107
- size: options2.output ? utils.getFilesizeInBytes(options2.output) : "0",
108
- sizeGzip
109
- });
110
- }).catch(reject);
111
- }).catch(reject);
112
- });
113
- };
114
-
115
- // src/spinner.ts
116
- import chalk from "chalk";
117
- import ora from "ora";
118
- var spinner = ora();
119
- var start = (options2) => {
120
- spinner.text = `Compressing file(s) with ${chalk.green(
121
- options2.compressorLabel
122
- )}...`;
123
- spinner.start();
124
- };
125
- var stop = (result) => {
126
- spinner.text = `File(s) compressed successfully with ${chalk.green(
127
- result.compressorLabel
128
- )} (${chalk.green(result.size)} minified, ${chalk.green(
129
- result.sizeGzip
130
- )} gzipped)`;
131
- spinner.succeed();
132
- };
133
- var error = (options2) => {
134
- spinner.text = `Error - file(s) not compressed with ${chalk.red(
135
- options2.compressorLabel
136
- )}`;
137
- spinner.fail();
138
- };
139
-
140
- // src/index.ts
141
- var silence = false;
142
- var runOne = async (cli) => {
143
- const compressor = typeof cli.compressor === "string" ? await import(`@node-minify/${cli.compressor}`) : cli.compressor;
144
- const compressorName = typeof cli.compressor === "string" ? cli.compressor : cli.compressor ? cli.compressor.name : "unknownCompressor";
145
- const options2 = {
146
- compressorLabel: compressorName,
147
- compressor: compressor.default,
148
- input: typeof cli.input === "string" ? cli.input.split(",") : "",
149
- output: cli.output
150
- };
151
- if (cli.option) {
152
- options2.options = JSON.parse(cli.option);
153
- }
154
- if (!silence) {
155
- start(options2);
156
- }
157
- return compress(options2).then((result) => {
158
- if (!silence) {
159
- stop(result);
160
- }
161
- return result;
162
- }).catch((err) => {
163
- if (!silence) {
164
- error(options2);
165
- }
166
- throw err;
167
- });
168
- };
169
- var run = (cli) => {
170
- silence = !!cli.silence;
171
- if (!silence) {
172
- console.log("");
173
- console.log(chalk2.bgBlue.black(" INFO "), "Starting compression...");
174
- console.log("");
175
- }
176
- return new Promise((resolve, reject) => {
177
- runOne(cli).then(() => {
178
- if (!silence) {
179
- console.log("");
180
- console.log(
181
- chalk2.bgGreen.black(" DONE "),
182
- chalk2.green("Done!")
183
- );
184
- console.log("");
185
- }
186
- }).then(resolve).catch(reject);
187
- });
188
- };
189
-
190
- // src/bin/cli.ts
191
- var program = new Command();
192
- updateNotifier({ pkg: package_default }).notify();
193
- program.storeOptionsAsProperties().version(package_default.version, "-v, --version").option(
194
- "-c, --compressor [compressor]",
195
- "use the specified compressor [uglify-js]",
196
- "uglify-js"
197
- ).option("-i, --input [file]", "input file path").option("-o, --output [file]", "output file path").option("-s, --silence", "no output will be printed").option(
198
- "-O, --option [option]",
199
- "option for the compressor as JSON object",
200
- ""
201
- );
202
- program.on("--help", () => {
203
- console.log(" List of compressors:");
204
- console.log("");
205
- console.log(" - babel-minify");
206
- console.log(" - gcc");
207
- console.log(" - html-minifier");
208
- console.log(" - terser");
209
- console.log(" - uglify-js");
210
- console.log(" - uglify-es");
211
- console.log(" - yui");
212
- console.log("");
213
- });
214
- program.parse(process.argv);
215
- var options = program.opts();
216
- if (!options.compressor || !options.input || !options.output) {
217
- program.help();
218
- }
219
- run(options).then(() => process.exit()).catch((err) => {
220
- console.error(err);
221
- process.exit(1);
222
- });
223
- /*!
224
- * node-minify
225
- * Copyright(c) 2011-2024 Rodolphe Stoclin
226
- * MIT Licensed
227
- */
package/dist/cli.js.map DELETED
@@ -1 +0,0 @@
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,gBAAkB;AAAA,IAClB,MAAQ;AAAA,IACR,WAAW;AAAA,IACX,cAAc;AAAA,IACd,iBAAiB;AAAA,EACnB;AAAA,EACA,cAAgB;AAAA,IACd,qBAAqB;AAAA,IACrB,sBAAsB;AAAA,IACtB,OAAS;AAAA,IACT,WAAa;AAAA,IACb,KAAO;AAAA,IACP,mBAAmB;AAAA,EACrB;AAAA,EACA,iBAAmB;AAAA,IACjB,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AAM,GAAG;AACjB,UAAQ,KAAK,CAAC;AAClB,CAAC;","names":["chalk","options","options","options","chalk"]}
package/dist/index.cjs DELETED
@@ -1,154 +0,0 @@
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
- */
@@ -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\";\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,CAAC,SAAS,WAAW;AAC5C,oBAAAC,SAAO,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,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,IACjB,YAAY,WAAW;AAAA,IACvB,OAAO,OAAO,IAAI,UAAU,WAAW,IAAI,MAAM,MAAM,GAAG,IAAI;AAAA,IAC9D,QAAQ,IAAI;AAAA,EAChB;AAEA,MAAI,IAAI,QAAQ;AACZ,YAAQ,UAAU,KAAK,MAAM,IAAI,MAAM;AAAA,EAC3C;AAEA,MAAI,CAAC,SAAS;AACV,UAAa,OAAO;AAAA,EACxB;AAEA,SAAO,SAAS,OAAO,EAClB,KAAK,CAAC,WAAmB;AACtB,QAAI,CAAC,SAAS;AACV,WAAY,MAAM;AAAA,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,IAAI,cAAAC,QAAM,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,UACJ,cAAAA,QAAM,QAAQ,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.d.cts DELETED
@@ -1,11 +0,0 @@
1
- import { Settings } from '@node-minify/types';
2
-
3
- /*!
4
- * node-minify
5
- * Copyright(c) 2011-2024 Rodolphe Stoclin
6
- * MIT Licensed
7
- */
8
-
9
- declare const run: (cli: Settings) => Promise<unknown>;
10
-
11
- export { run };
package/dist/index.js.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\";\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,EACA,MAAM,MAAM;AAAA,IACrB,CAAC,EACA,MAAM,MAAM;AAAA,EACrB,CAAC;AACL;;;AC5CA,OAAO,WAAW;AAClB,OAAO,SAAS;AAEhB,IAAM,UAAU,IAAI;AAMpB,IAAM,QAAQ,CAAC,YAAsB;AACjC,UAAQ,OAAO,4BAA4B,MAAM;AAAA,IAC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