@powerlines/plugin-image-compression 0.2.171 → 0.2.173
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/index.cjs +2 -2
- package/dist/index.d.cts +2 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/types/plugin.d.cts +3 -3
- package/dist/types/plugin.d.mts +3 -3
- package/package.json +3 -3
- package/dist/node_modules/.pnpm/@stryke_string-format@0.13.4/node_modules/@stryke/string-format/dist/pretty-bytes.cjs +0 -128
- package/dist/node_modules/.pnpm/@stryke_string-format@0.13.4/node_modules/@stryke/string-format/dist/pretty-bytes.mjs +0 -127
- package/dist/packages/powerlines/src/internal/helpers/hooks.d.mts +0 -47
- package/dist/packages/powerlines/src/types/api.d.mts +0 -104
- package/dist/packages/powerlines/src/types/build.d.mts +0 -185
- package/dist/packages/powerlines/src/types/commands.d.mts +0 -8
- package/dist/packages/powerlines/src/types/config.d.mts +0 -424
- package/dist/packages/powerlines/src/types/context.d.mts +0 -514
- package/dist/packages/powerlines/src/types/fs.d.mts +0 -486
- package/dist/packages/powerlines/src/types/hooks.d.mts +0 -32
- package/dist/packages/powerlines/src/types/plugin.d.mts +0 -205
- package/dist/packages/powerlines/src/types/resolved.d.mts +0 -93
- package/dist/packages/powerlines/src/types/tsconfig.d.mts +0 -69
- package/dist/packages/powerlines/src/types/unplugin.d.mts +0 -22
- package/dist/powerlines/src/internal/helpers/hooks.d.cts +0 -47
- package/dist/powerlines/src/types/api.d.cts +0 -104
- package/dist/powerlines/src/types/build.d.cts +0 -185
- package/dist/powerlines/src/types/commands.d.cts +0 -8
- package/dist/powerlines/src/types/config.d.cts +0 -424
- package/dist/powerlines/src/types/context.d.cts +0 -514
- package/dist/powerlines/src/types/fs.d.cts +0 -486
- package/dist/powerlines/src/types/hooks.d.cts +0 -32
- package/dist/powerlines/src/types/plugin.d.cts +0 -205
- package/dist/powerlines/src/types/resolved.d.cts +0 -93
- package/dist/powerlines/src/types/tsconfig.d.cts +0 -69
- package/dist/powerlines/src/types/unplugin.d.cts +0 -22
package/dist/index.cjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
2
|
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
3
|
-
const require_pretty_bytes = require('./node_modules/.pnpm/@stryke_string-format@0.13.4/node_modules/@stryke/string-format/dist/pretty-bytes.cjs');
|
|
4
3
|
let __stryke_convert_to_array = require("@stryke/convert/to-array");
|
|
5
4
|
let __stryke_fs_list_files = require("@stryke/fs/list-files");
|
|
6
5
|
let __stryke_fs_read_file = require("@stryke/fs/read-file");
|
|
7
6
|
let __stryke_fs_write_file = require("@stryke/fs/write-file");
|
|
8
7
|
let __stryke_path_find = require("@stryke/path/find");
|
|
8
|
+
let __stryke_string_format_pretty_bytes = require("@stryke/string-format/pretty-bytes");
|
|
9
9
|
let chalk = require("chalk");
|
|
10
10
|
chalk = require_rolldown_runtime.__toESM(chalk);
|
|
11
11
|
let node_buffer = require("node:buffer");
|
|
@@ -108,7 +108,7 @@ const plugin = (options = {}) => {
|
|
|
108
108
|
this.error(` ✘ Failed to optimize ${file} - Compression output was not smaller than the original`);
|
|
109
109
|
return;
|
|
110
110
|
}
|
|
111
|
-
this.info(` ✔ Successfully optimized ${file}: ${chalk.default.redBright(
|
|
111
|
+
this.info(` ✔ Successfully optimized ${file}: ${chalk.default.redBright((0, __stryke_string_format_pretty_bytes.prettyBytes)(originalSize))} -> ${chalk.default.greenBright((0, __stryke_string_format_pretty_bytes.prettyBytes)(compressedSize))} (${chalk.default.green((100 - compressedSize / originalSize * 100).toFixed(2))}%) in ${(performance.now() - start).toFixed(2)} ms`);
|
|
112
112
|
}));
|
|
113
113
|
}));
|
|
114
114
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Plugin } from "./powerlines/src/types/plugin.cjs";
|
|
2
1
|
import { ImageCompressionPluginContext, ImageCompressionPluginOptions, ImageCompressionPluginResolvedConfig, ImageCompressionPluginUserConfig, __ΩImageCompressionPluginContext, __ΩImageCompressionPluginOptions, __ΩImageCompressionPluginResolvedConfig, __ΩImageCompressionPluginUserConfig } from "./types/plugin.cjs";
|
|
2
|
+
import "./types/index.cjs";
|
|
3
|
+
import { Plugin } from "powerlines/types/plugin";
|
|
3
4
|
|
|
4
5
|
//#region src/index.d.ts
|
|
5
6
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Plugin } from "./packages/powerlines/src/types/plugin.mjs";
|
|
2
1
|
import { ImageCompressionPluginContext, ImageCompressionPluginOptions, ImageCompressionPluginResolvedConfig, ImageCompressionPluginUserConfig, __ΩImageCompressionPluginContext, __ΩImageCompressionPluginOptions, __ΩImageCompressionPluginResolvedConfig, __ΩImageCompressionPluginUserConfig } from "./types/plugin.mjs";
|
|
3
2
|
import "./types/index.mjs";
|
|
3
|
+
import { Plugin } from "powerlines/types/plugin";
|
|
4
4
|
|
|
5
5
|
//#region src/index.d.ts
|
|
6
6
|
|
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { prettyBytes } from "./node_modules/.pnpm/@stryke_string-format@0.13.4/node_modules/@stryke/string-format/dist/pretty-bytes.mjs";
|
|
2
1
|
import { toArray } from "@stryke/convert/to-array";
|
|
3
2
|
import { listFiles } from "@stryke/fs/list-files";
|
|
4
3
|
import { readFile } from "@stryke/fs/read-file";
|
|
5
4
|
import { writeFile } from "@stryke/fs/write-file";
|
|
6
5
|
import { findFileExtensionSafe } from "@stryke/path/find";
|
|
6
|
+
import { prettyBytes } from "@stryke/string-format/pretty-bytes";
|
|
7
7
|
import chalk from "chalk";
|
|
8
8
|
import { Buffer } from "node:buffer";
|
|
9
9
|
import { stat } from "node:fs/promises";
|
package/dist/types/plugin.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { UserConfig } from "
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { UserConfig } from "powerlines/types/config";
|
|
2
|
+
import { PluginContext } from "powerlines/types/context";
|
|
3
|
+
import { ResolvedConfig } from "powerlines/types/resolved";
|
|
4
4
|
import { AvifOptions, GifOptions, HeifOptions, Jp2Options, JpegOptions, JxlOptions, PngOptions, TiffOptions, WebpOptions } from "sharp";
|
|
5
5
|
import { Config } from "svgo";
|
|
6
6
|
|
package/dist/types/plugin.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { UserConfig } from "../packages/powerlines/src/types/config.mjs";
|
|
2
|
-
import { ResolvedConfig } from "../packages/powerlines/src/types/resolved.mjs";
|
|
3
|
-
import { PluginContext } from "../packages/powerlines/src/types/context.mjs";
|
|
4
1
|
import { Config } from "svgo";
|
|
5
2
|
import { AvifOptions, GifOptions, HeifOptions, Jp2Options, JpegOptions, JxlOptions, PngOptions, TiffOptions, WebpOptions } from "sharp";
|
|
3
|
+
import { UserConfig } from "powerlines/types/config";
|
|
4
|
+
import { PluginContext } from "powerlines/types/context";
|
|
5
|
+
import { ResolvedConfig } from "powerlines/types/resolved";
|
|
6
6
|
|
|
7
7
|
//#region src/types/plugin.d.ts
|
|
8
8
|
interface ImageCompressionPluginOptions {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerlines/plugin-image-compression",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.173",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A Powerlines plugin to optimize images used by the project.",
|
|
6
6
|
"repository": {
|
|
@@ -134,10 +134,10 @@
|
|
|
134
134
|
"svgo": "^4.0.0"
|
|
135
135
|
},
|
|
136
136
|
"devDependencies": {
|
|
137
|
-
"@powerlines/plugin-plugin": "^0.12.
|
|
137
|
+
"@powerlines/plugin-plugin": "^0.12.175",
|
|
138
138
|
"@storm-software/config": "^1.135.1",
|
|
139
139
|
"@types/node": "^24.10.9"
|
|
140
140
|
},
|
|
141
141
|
"publishConfig": { "access": "public" },
|
|
142
|
-
"gitHead": "
|
|
142
|
+
"gitHead": "f153baa7a374fe331eeb1b8ea37c30c379c5efce"
|
|
143
143
|
}
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
//#region ../../node_modules/.pnpm/@stryke+string-format@0.13.4/node_modules/@stryke/string-format/dist/pretty-bytes.mjs
|
|
3
|
-
const BYTE_UNITS = [
|
|
4
|
-
"B",
|
|
5
|
-
"kB",
|
|
6
|
-
"MB",
|
|
7
|
-
"GB",
|
|
8
|
-
"TB",
|
|
9
|
-
"PB",
|
|
10
|
-
"EB",
|
|
11
|
-
"ZB",
|
|
12
|
-
"YB"
|
|
13
|
-
];
|
|
14
|
-
const BIBYTE_UNITS = [
|
|
15
|
-
"B",
|
|
16
|
-
"KiB",
|
|
17
|
-
"MiB",
|
|
18
|
-
"GiB",
|
|
19
|
-
"TiB",
|
|
20
|
-
"PiB",
|
|
21
|
-
"EiB",
|
|
22
|
-
"ZiB",
|
|
23
|
-
"YiB"
|
|
24
|
-
];
|
|
25
|
-
const BIT_UNITS = [
|
|
26
|
-
"b",
|
|
27
|
-
"kbit",
|
|
28
|
-
"Mbit",
|
|
29
|
-
"Gbit",
|
|
30
|
-
"Tbit",
|
|
31
|
-
"Pbit",
|
|
32
|
-
"Ebit",
|
|
33
|
-
"Zbit",
|
|
34
|
-
"Ybit"
|
|
35
|
-
];
|
|
36
|
-
const BIBIT_UNITS = [
|
|
37
|
-
"b",
|
|
38
|
-
"kibit",
|
|
39
|
-
"Mibit",
|
|
40
|
-
"Gibit",
|
|
41
|
-
"Tibit",
|
|
42
|
-
"Pibit",
|
|
43
|
-
"Eibit",
|
|
44
|
-
"Zibit",
|
|
45
|
-
"Yibit"
|
|
46
|
-
];
|
|
47
|
-
/**
|
|
48
|
-
* Formats the given number using `Number#toLocaleString`.
|
|
49
|
-
*
|
|
50
|
-
* @remarks
|
|
51
|
-
* - If locale is a string, the value is expected to be a locale-key (for example: `de`).
|
|
52
|
-
* - If locale is true, the system default locale is used for translation.
|
|
53
|
-
* - If no value for locale is specified, the number is returned unmodified.
|
|
54
|
-
*
|
|
55
|
-
* @param number - The number to format.
|
|
56
|
-
* @param locale - The locale to use for formatting the number.
|
|
57
|
-
* @param options - The options to use for formatting the number.
|
|
58
|
-
* @returns The formatted number.
|
|
59
|
-
*/
|
|
60
|
-
const toLocaleString = (number, locale, options = {}) => {
|
|
61
|
-
let result = number;
|
|
62
|
-
let _locale = locale;
|
|
63
|
-
if (typeof _locale === "string") {
|
|
64
|
-
if (!_locale) _locale = process.env.STORM_LOCALE || "en-US";
|
|
65
|
-
if (Array.isArray(_locale)) result = number?.toLocaleString(_locale, options);
|
|
66
|
-
} else if (_locale === true || options !== void 0) result = number?.toLocaleString(void 0, options);
|
|
67
|
-
return String(result);
|
|
68
|
-
};
|
|
69
|
-
/**
|
|
70
|
-
* Convert bytes to a human readable string: `1337` → `1.34 kB`.
|
|
71
|
-
*
|
|
72
|
-
* @param number - The number to format.
|
|
73
|
-
*
|
|
74
|
-
* @example
|
|
75
|
-
* ```ts
|
|
76
|
-
* import { prettyBytes } from '@stryke/string-fns/pretty-bytes';
|
|
77
|
-
*
|
|
78
|
-
* prettyBytes(1337);
|
|
79
|
-
* //=> '1.34 kB'
|
|
80
|
-
*
|
|
81
|
-
* prettyBytes(100);
|
|
82
|
-
* //=> '100 B'
|
|
83
|
-
*
|
|
84
|
-
* // Display file size differences
|
|
85
|
-
* prettyBytes(42, {signed: true});
|
|
86
|
-
* //=> '+42 B'
|
|
87
|
-
*
|
|
88
|
-
* // Localized output using German locale
|
|
89
|
-
* prettyBytes(1337, {locale: 'de'});
|
|
90
|
-
* //=> '1,34 kB'
|
|
91
|
-
* ```
|
|
92
|
-
*
|
|
93
|
-
* @param number - The number to format.
|
|
94
|
-
* @param options - The options to use.
|
|
95
|
-
* @returns The formatted string.
|
|
96
|
-
*/
|
|
97
|
-
function prettyBytes(number, options) {
|
|
98
|
-
let _number = number;
|
|
99
|
-
if (!Number.isFinite(_number)) throw new TypeError(`Expected a finite number, got ${typeof _number}: ${_number}`);
|
|
100
|
-
const opts = {
|
|
101
|
-
bits: false,
|
|
102
|
-
binary: false,
|
|
103
|
-
space: true,
|
|
104
|
-
...options
|
|
105
|
-
};
|
|
106
|
-
const UNITS = opts.bits ? opts.binary ? BIBIT_UNITS : BIT_UNITS : opts.binary ? BIBYTE_UNITS : BYTE_UNITS;
|
|
107
|
-
const separator = opts.space ? " " : "";
|
|
108
|
-
if (opts.signed && _number === 0) return ` 0${separator}${UNITS[0]}`;
|
|
109
|
-
const isNegative = _number < 0;
|
|
110
|
-
const prefix = isNegative ? "-" : opts.signed ? "+" : "";
|
|
111
|
-
if (isNegative) _number = -_number;
|
|
112
|
-
let localeOptions;
|
|
113
|
-
if (opts.minimumFractionDigits !== void 0) localeOptions = { minimumFractionDigits: opts.minimumFractionDigits };
|
|
114
|
-
if (opts.maximumFractionDigits !== void 0) localeOptions = {
|
|
115
|
-
maximumFractionDigits: opts.maximumFractionDigits,
|
|
116
|
-
...localeOptions
|
|
117
|
-
};
|
|
118
|
-
if (_number < 1) return prefix + toLocaleString(_number, opts.locale, localeOptions) + separator + UNITS[0];
|
|
119
|
-
const exponent = Math.min(Math.floor(opts.binary ? Math.log(_number) / Math.log(1024) : Math.log10(_number) / 3), UNITS.length - 1);
|
|
120
|
-
_number /= (opts.binary ? 1024 : 1e3) ** exponent;
|
|
121
|
-
if (!localeOptions) _number = _number.toPrecision(3);
|
|
122
|
-
const numberString = toLocaleString(Number(_number), opts.locale, localeOptions);
|
|
123
|
-
const unit = UNITS[exponent];
|
|
124
|
-
return prefix + numberString + separator + unit;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
//#endregion
|
|
128
|
-
exports.prettyBytes = prettyBytes;
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
//#region ../../node_modules/.pnpm/@stryke+string-format@0.13.4/node_modules/@stryke/string-format/dist/pretty-bytes.mjs
|
|
2
|
-
const BYTE_UNITS = [
|
|
3
|
-
"B",
|
|
4
|
-
"kB",
|
|
5
|
-
"MB",
|
|
6
|
-
"GB",
|
|
7
|
-
"TB",
|
|
8
|
-
"PB",
|
|
9
|
-
"EB",
|
|
10
|
-
"ZB",
|
|
11
|
-
"YB"
|
|
12
|
-
];
|
|
13
|
-
const BIBYTE_UNITS = [
|
|
14
|
-
"B",
|
|
15
|
-
"KiB",
|
|
16
|
-
"MiB",
|
|
17
|
-
"GiB",
|
|
18
|
-
"TiB",
|
|
19
|
-
"PiB",
|
|
20
|
-
"EiB",
|
|
21
|
-
"ZiB",
|
|
22
|
-
"YiB"
|
|
23
|
-
];
|
|
24
|
-
const BIT_UNITS = [
|
|
25
|
-
"b",
|
|
26
|
-
"kbit",
|
|
27
|
-
"Mbit",
|
|
28
|
-
"Gbit",
|
|
29
|
-
"Tbit",
|
|
30
|
-
"Pbit",
|
|
31
|
-
"Ebit",
|
|
32
|
-
"Zbit",
|
|
33
|
-
"Ybit"
|
|
34
|
-
];
|
|
35
|
-
const BIBIT_UNITS = [
|
|
36
|
-
"b",
|
|
37
|
-
"kibit",
|
|
38
|
-
"Mibit",
|
|
39
|
-
"Gibit",
|
|
40
|
-
"Tibit",
|
|
41
|
-
"Pibit",
|
|
42
|
-
"Eibit",
|
|
43
|
-
"Zibit",
|
|
44
|
-
"Yibit"
|
|
45
|
-
];
|
|
46
|
-
/**
|
|
47
|
-
* Formats the given number using `Number#toLocaleString`.
|
|
48
|
-
*
|
|
49
|
-
* @remarks
|
|
50
|
-
* - If locale is a string, the value is expected to be a locale-key (for example: `de`).
|
|
51
|
-
* - If locale is true, the system default locale is used for translation.
|
|
52
|
-
* - If no value for locale is specified, the number is returned unmodified.
|
|
53
|
-
*
|
|
54
|
-
* @param number - The number to format.
|
|
55
|
-
* @param locale - The locale to use for formatting the number.
|
|
56
|
-
* @param options - The options to use for formatting the number.
|
|
57
|
-
* @returns The formatted number.
|
|
58
|
-
*/
|
|
59
|
-
const toLocaleString = (number, locale, options = {}) => {
|
|
60
|
-
let result = number;
|
|
61
|
-
let _locale = locale;
|
|
62
|
-
if (typeof _locale === "string") {
|
|
63
|
-
if (!_locale) _locale = process.env.STORM_LOCALE || "en-US";
|
|
64
|
-
if (Array.isArray(_locale)) result = number?.toLocaleString(_locale, options);
|
|
65
|
-
} else if (_locale === true || options !== void 0) result = number?.toLocaleString(void 0, options);
|
|
66
|
-
return String(result);
|
|
67
|
-
};
|
|
68
|
-
/**
|
|
69
|
-
* Convert bytes to a human readable string: `1337` → `1.34 kB`.
|
|
70
|
-
*
|
|
71
|
-
* @param number - The number to format.
|
|
72
|
-
*
|
|
73
|
-
* @example
|
|
74
|
-
* ```ts
|
|
75
|
-
* import { prettyBytes } from '@stryke/string-fns/pretty-bytes';
|
|
76
|
-
*
|
|
77
|
-
* prettyBytes(1337);
|
|
78
|
-
* //=> '1.34 kB'
|
|
79
|
-
*
|
|
80
|
-
* prettyBytes(100);
|
|
81
|
-
* //=> '100 B'
|
|
82
|
-
*
|
|
83
|
-
* // Display file size differences
|
|
84
|
-
* prettyBytes(42, {signed: true});
|
|
85
|
-
* //=> '+42 B'
|
|
86
|
-
*
|
|
87
|
-
* // Localized output using German locale
|
|
88
|
-
* prettyBytes(1337, {locale: 'de'});
|
|
89
|
-
* //=> '1,34 kB'
|
|
90
|
-
* ```
|
|
91
|
-
*
|
|
92
|
-
* @param number - The number to format.
|
|
93
|
-
* @param options - The options to use.
|
|
94
|
-
* @returns The formatted string.
|
|
95
|
-
*/
|
|
96
|
-
function prettyBytes(number, options) {
|
|
97
|
-
let _number = number;
|
|
98
|
-
if (!Number.isFinite(_number)) throw new TypeError(`Expected a finite number, got ${typeof _number}: ${_number}`);
|
|
99
|
-
const opts = {
|
|
100
|
-
bits: false,
|
|
101
|
-
binary: false,
|
|
102
|
-
space: true,
|
|
103
|
-
...options
|
|
104
|
-
};
|
|
105
|
-
const UNITS = opts.bits ? opts.binary ? BIBIT_UNITS : BIT_UNITS : opts.binary ? BIBYTE_UNITS : BYTE_UNITS;
|
|
106
|
-
const separator = opts.space ? " " : "";
|
|
107
|
-
if (opts.signed && _number === 0) return ` 0${separator}${UNITS[0]}`;
|
|
108
|
-
const isNegative = _number < 0;
|
|
109
|
-
const prefix = isNegative ? "-" : opts.signed ? "+" : "";
|
|
110
|
-
if (isNegative) _number = -_number;
|
|
111
|
-
let localeOptions;
|
|
112
|
-
if (opts.minimumFractionDigits !== void 0) localeOptions = { minimumFractionDigits: opts.minimumFractionDigits };
|
|
113
|
-
if (opts.maximumFractionDigits !== void 0) localeOptions = {
|
|
114
|
-
maximumFractionDigits: opts.maximumFractionDigits,
|
|
115
|
-
...localeOptions
|
|
116
|
-
};
|
|
117
|
-
if (_number < 1) return prefix + toLocaleString(_number, opts.locale, localeOptions) + separator + UNITS[0];
|
|
118
|
-
const exponent = Math.min(Math.floor(opts.binary ? Math.log(_number) / Math.log(1024) : Math.log10(_number) / 3), UNITS.length - 1);
|
|
119
|
-
_number /= (opts.binary ? 1024 : 1e3) ** exponent;
|
|
120
|
-
if (!localeOptions) _number = _number.toPrecision(3);
|
|
121
|
-
const numberString = toLocaleString(Number(_number), opts.locale, localeOptions);
|
|
122
|
-
const unit = UNITS[exponent];
|
|
123
|
-
return prefix + numberString + separator + unit;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
//#endregion
|
|
127
|
-
export { prettyBytes };
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { SelectHooksOptions } from "../../types/context.mjs";
|
|
2
|
-
import { MaybePromise } from "@stryke/types/base";
|
|
3
|
-
|
|
4
|
-
//#region ../powerlines/src/internal/helpers/hooks.d.ts
|
|
5
|
-
type CallHookOptions = SelectHooksOptions & (({
|
|
6
|
-
/**
|
|
7
|
-
* Whether to call the hooks sequentially or in parallel.
|
|
8
|
-
*
|
|
9
|
-
* @defaultValue true
|
|
10
|
-
*/
|
|
11
|
-
sequential?: true;
|
|
12
|
-
} & ({
|
|
13
|
-
/**
|
|
14
|
-
* How to handle multiple return values from hooks.
|
|
15
|
-
* - "merge": Merge all non-undefined return values (if they are objects).
|
|
16
|
-
* - "first": Return the first non-undefined value.
|
|
17
|
-
*
|
|
18
|
-
* @remarks
|
|
19
|
-
* Merging only works if the return values are objects.
|
|
20
|
-
*
|
|
21
|
-
* @defaultValue "merge"
|
|
22
|
-
*/
|
|
23
|
-
result: "first";
|
|
24
|
-
} | {
|
|
25
|
-
/**
|
|
26
|
-
* How to handle multiple return values from hooks.
|
|
27
|
-
* - "merge": Merge all non-undefined return values (if they are objects).
|
|
28
|
-
* - "first": Return the first non-undefined value.
|
|
29
|
-
*
|
|
30
|
-
* @remarks
|
|
31
|
-
* Merging only works if the return values are objects.
|
|
32
|
-
*
|
|
33
|
-
* @defaultValue "merge"
|
|
34
|
-
*/
|
|
35
|
-
result?: "merge" | "last";
|
|
36
|
-
/**
|
|
37
|
-
* An indicator specifying if the results of the previous hook should be provided as the **first** parameter of the next hook function, or a function to process the result of the previous hook function and pass the returned value as the next hook's **first** parameter
|
|
38
|
-
*/
|
|
39
|
-
asNextParam?: false | ((previousResult: any) => MaybePromise<any>);
|
|
40
|
-
})) | {
|
|
41
|
-
/**
|
|
42
|
-
* Whether to call the hooks sequentially or in parallel.
|
|
43
|
-
*/
|
|
44
|
-
sequential: false;
|
|
45
|
-
});
|
|
46
|
-
//#endregion
|
|
47
|
-
export { CallHookOptions };
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { BuildInlineConfig, CleanInlineConfig, DeployInlineConfig, DocsInlineConfig, LintInlineConfig, NewInlineConfig, PrepareInlineConfig } from "./config.mjs";
|
|
2
|
-
import { InferHookParameters, InferHookReturnType } from "./hooks.mjs";
|
|
3
|
-
import { ResolvedConfig } from "./resolved.mjs";
|
|
4
|
-
import { APIContext, EnvironmentContext, PluginContext } from "./context.mjs";
|
|
5
|
-
import { CallHookOptions } from "../internal/helpers/hooks.mjs";
|
|
6
|
-
|
|
7
|
-
//#region ../powerlines/src/types/api.d.ts
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Powerlines API Interface
|
|
11
|
-
*/
|
|
12
|
-
interface API<TResolvedConfig extends ResolvedConfig = ResolvedConfig> {
|
|
13
|
-
/**
|
|
14
|
-
* The Powerlines shared API context
|
|
15
|
-
*/
|
|
16
|
-
context: APIContext<TResolvedConfig>;
|
|
17
|
-
/**
|
|
18
|
-
* Prepare the Powerlines API
|
|
19
|
-
*
|
|
20
|
-
* @remarks
|
|
21
|
-
* This method will prepare the Powerlines API for use, initializing any necessary resources.
|
|
22
|
-
*
|
|
23
|
-
* @param inlineConfig - The inline configuration for the prepare command
|
|
24
|
-
*/
|
|
25
|
-
prepare: (inlineConfig: PrepareInlineConfig | NewInlineConfig | CleanInlineConfig | BuildInlineConfig | LintInlineConfig | DocsInlineConfig | DeployInlineConfig) => Promise<void>;
|
|
26
|
-
/**
|
|
27
|
-
* Create a new Powerlines project
|
|
28
|
-
*
|
|
29
|
-
* @remarks
|
|
30
|
-
* This method will create a new Powerlines project in the current directory.
|
|
31
|
-
*
|
|
32
|
-
* @param inlineConfig - The inline configuration for the new command
|
|
33
|
-
* @returns A promise that resolves when the project has been created
|
|
34
|
-
*/
|
|
35
|
-
new: (inlineConfig: NewInlineConfig) => Promise<void>;
|
|
36
|
-
/**
|
|
37
|
-
* Clean any previously prepared artifacts
|
|
38
|
-
*
|
|
39
|
-
* @remarks
|
|
40
|
-
* This method will remove the previous Powerlines artifacts from the project.
|
|
41
|
-
*
|
|
42
|
-
* @param inlineConfig - The inline configuration for the clean command
|
|
43
|
-
* @returns A promise that resolves when the clean command has completed
|
|
44
|
-
*/
|
|
45
|
-
clean: (inlineConfig: CleanInlineConfig | PrepareInlineConfig) => Promise<void>;
|
|
46
|
-
/**
|
|
47
|
-
* Lint the project source code
|
|
48
|
-
*
|
|
49
|
-
* @param inlineConfig - The inline configuration for the lint command
|
|
50
|
-
* @returns A promise that resolves when the lint command has completed
|
|
51
|
-
*/
|
|
52
|
-
lint: (inlineConfig: LintInlineConfig) => Promise<void>;
|
|
53
|
-
/**
|
|
54
|
-
* Build the project
|
|
55
|
-
*
|
|
56
|
-
* @remarks
|
|
57
|
-
* This method will build the Powerlines project, generating the necessary artifacts.
|
|
58
|
-
*
|
|
59
|
-
* @param inlineConfig - The inline configuration for the build command
|
|
60
|
-
* @returns A promise that resolves when the build command has completed
|
|
61
|
-
*/
|
|
62
|
-
build: (inlineConfig: BuildInlineConfig) => Promise<void>;
|
|
63
|
-
/**
|
|
64
|
-
* Prepare the documentation for the project
|
|
65
|
-
*
|
|
66
|
-
* @param inlineConfig - The inline configuration for the docs command
|
|
67
|
-
* @returns A promise that resolves when the documentation generation has completed
|
|
68
|
-
*/
|
|
69
|
-
docs: (inlineConfig: DocsInlineConfig) => Promise<void>;
|
|
70
|
-
/**
|
|
71
|
-
* Deploy the project source code
|
|
72
|
-
*
|
|
73
|
-
* @remarks
|
|
74
|
-
* This method will prepare and build the Powerlines project, generating the necessary artifacts for the deployment.
|
|
75
|
-
*
|
|
76
|
-
* @param inlineConfig - The inline configuration for the deploy command
|
|
77
|
-
*/
|
|
78
|
-
deploy: (inlineConfig: DeployInlineConfig) => Promise<void>;
|
|
79
|
-
/**
|
|
80
|
-
* Finalization process
|
|
81
|
-
*
|
|
82
|
-
* @remarks
|
|
83
|
-
* This step includes any final processes or clean up required by Powerlines. It will be run after each Powerlines command.
|
|
84
|
-
*
|
|
85
|
-
* @returns A promise that resolves when the finalization process has completed
|
|
86
|
-
*/
|
|
87
|
-
finalize: () => Promise<void>;
|
|
88
|
-
/**
|
|
89
|
-
* Invokes the configured plugin hooks
|
|
90
|
-
*
|
|
91
|
-
* @remarks
|
|
92
|
-
* By default, it will call the `"pre"`, `"normal"`, and `"post"` ordered hooks in sequence
|
|
93
|
-
*
|
|
94
|
-
* @param hook - The hook to call
|
|
95
|
-
* @param options - The options to provide to the hook
|
|
96
|
-
* @param args - The arguments to pass to the hook
|
|
97
|
-
* @returns The result of the hook call
|
|
98
|
-
*/
|
|
99
|
-
callHook: <TKey extends string>(hook: TKey, options: CallHookOptions & {
|
|
100
|
-
environment?: string | EnvironmentContext<TResolvedConfig>;
|
|
101
|
-
}, ...args: InferHookParameters<PluginContext<TResolvedConfig>, TKey>) => Promise<InferHookReturnType<PluginContext<TResolvedConfig>, TKey> | undefined>;
|
|
102
|
-
}
|
|
103
|
-
//#endregion
|
|
104
|
-
export { API };
|