@powerlines/plugin-image-compression 0.2.77 → 0.2.78
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 +5 -5
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +3 -3
- package/dist/node_modules/.pnpm/@stryke_string-format@0.12.30/node_modules/@stryke/string-format/dist/pretty-bytes.cjs +71 -0
- package/dist/node_modules/.pnpm/@stryke_string-format@0.12.30/node_modules/@stryke/string-format/dist/pretty-bytes.mjs +70 -0
- package/dist/types/plugin.d.mts +3 -3
- package/package.json +7 -8
- package/dist/powerlines/src/plugin-utils/paths.cjs +0 -36
- package/dist/powerlines/src/plugin-utils/paths.mjs +0 -35
- /package/dist/{powerlines → packages/powerlines}/src/internal/helpers/hooks.d.mts +0 -0
- /package/dist/{powerlines → packages/powerlines}/src/types/api.d.mts +0 -0
- /package/dist/{powerlines → packages/powerlines}/src/types/build.d.mts +0 -0
- /package/dist/{powerlines → packages/powerlines}/src/types/commands.d.mts +0 -0
- /package/dist/{powerlines → packages/powerlines}/src/types/config.d.mts +0 -0
- /package/dist/{powerlines → packages/powerlines}/src/types/context.d.mts +0 -0
- /package/dist/{powerlines → packages/powerlines}/src/types/fs.d.mts +0 -0
- /package/dist/{powerlines → packages/powerlines}/src/types/hooks.d.mts +0 -0
- /package/dist/{powerlines → packages/powerlines}/src/types/plugin.d.mts +0 -0
- /package/dist/{powerlines → packages/powerlines}/src/types/resolved.d.mts +0 -0
- /package/dist/{powerlines → packages/powerlines}/src/types/tsconfig.d.mts +0 -0
- /package/dist/{powerlines → packages/powerlines}/src/types/unplugin.d.mts +0 -0
package/dist/index.cjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
2
|
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
3
|
-
const
|
|
3
|
+
const require_pretty_bytes = require('./node_modules/.pnpm/@stryke_string-format@0.12.30/node_modules/@stryke/string-format/dist/pretty-bytes.cjs');
|
|
4
4
|
let __stryke_convert_to_array = require("@stryke/convert/to-array");
|
|
5
5
|
let __stryke_fs_list_files = require("@stryke/fs/list-files");
|
|
6
6
|
let __stryke_fs_read_file = require("@stryke/fs/read-file");
|
|
7
7
|
let __stryke_fs_write_file = require("@stryke/fs/write-file");
|
|
8
8
|
let __stryke_path_find = require("@stryke/path/find");
|
|
9
|
-
let __stryke_string_format_pretty_bytes = require("@stryke/string-format/pretty-bytes");
|
|
10
9
|
let chalk = require("chalk");
|
|
11
10
|
chalk = require_rolldown_runtime.__toESM(chalk);
|
|
12
11
|
let node_buffer = require("node:buffer");
|
|
13
12
|
let node_fs_promises = require("node:fs/promises");
|
|
13
|
+
let powerlines_plugin_utils_paths = require("powerlines/plugin-utils/paths");
|
|
14
14
|
let svgo = require("svgo");
|
|
15
15
|
|
|
16
16
|
//#region src/index.ts
|
|
@@ -42,12 +42,12 @@ const plugin = (options = {}) => {
|
|
|
42
42
|
},
|
|
43
43
|
async configResolved() {
|
|
44
44
|
if (!this.config.imageCompression.filter) throw new Error("ImageCompression plugin requires a filter or glob pattern to be specified in the configuration.");
|
|
45
|
-
this.config.imageCompression.filter = (0, __stryke_convert_to_array.toArray)(this.config.imageCompression.filter).map((path) =>
|
|
45
|
+
this.config.imageCompression.filter = (0, __stryke_convert_to_array.toArray)(this.config.imageCompression.filter).map((path) => (0, powerlines_plugin_utils_paths.replacePathTokens)(this, path)).filter(Boolean);
|
|
46
46
|
},
|
|
47
47
|
async prepare() {
|
|
48
48
|
await Promise.all((0, __stryke_convert_to_array.toArray)(this.config.imageCompression.filter).map(async (path) => {
|
|
49
49
|
await Promise.all((await (0, __stryke_fs_list_files.listFiles)(path)).map(async (file) => {
|
|
50
|
-
const outputPath = this.config.imageCompression.outputPath ?
|
|
50
|
+
const outputPath = this.config.imageCompression.outputPath ? (0, powerlines_plugin_utils_paths.replacePathTokens)(this, this.config.imageCompression.outputPath).replace(/\{fileName\}/g, file.split("/").pop() || "output") : file;
|
|
51
51
|
const start = performance.now();
|
|
52
52
|
const originalSize = (await (0, node_fs_promises.stat)(file)).size;
|
|
53
53
|
let compressedSize = 0;
|
|
@@ -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(require_pretty_bytes.a(originalSize))} -> ${chalk.default.greenBright(require_pretty_bytes.a(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.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Plugin } from "./powerlines/src/types/plugin.mjs";
|
|
1
|
+
import { Plugin } from "./packages/powerlines/src/types/plugin.mjs";
|
|
2
2
|
import { ImageCompressionPluginContext, ImageCompressionPluginOptions, ImageCompressionPluginResolvedConfig, ImageCompressionPluginUserConfig, __ΩImageCompressionPluginContext, __ΩImageCompressionPluginOptions, __ΩImageCompressionPluginResolvedConfig, __ΩImageCompressionPluginUserConfig } from "./types/plugin.mjs";
|
|
3
3
|
import "./types/index.mjs";
|
|
4
4
|
|
package/dist/index.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a } from "./node_modules/.pnpm/@stryke_string-format@0.12.30/node_modules/@stryke/string-format/dist/pretty-bytes.mjs";
|
|
2
2
|
import { toArray } from "@stryke/convert/to-array";
|
|
3
3
|
import { listFiles } from "@stryke/fs/list-files";
|
|
4
4
|
import { readFile } from "@stryke/fs/read-file";
|
|
5
5
|
import { writeFile } from "@stryke/fs/write-file";
|
|
6
6
|
import { findFileExtensionSafe } from "@stryke/path/find";
|
|
7
|
-
import { prettyBytes } from "@stryke/string-format/pretty-bytes";
|
|
8
7
|
import chalk from "chalk";
|
|
9
8
|
import { Buffer } from "node:buffer";
|
|
10
9
|
import { stat } from "node:fs/promises";
|
|
10
|
+
import { replacePathTokens } from "powerlines/plugin-utils/paths";
|
|
11
11
|
import { optimize } from "svgo";
|
|
12
12
|
|
|
13
13
|
//#region src/index.ts
|
|
@@ -105,7 +105,7 @@ const plugin = (options = {}) => {
|
|
|
105
105
|
this.error(` ✘ Failed to optimize ${file} - Compression output was not smaller than the original`);
|
|
106
106
|
return;
|
|
107
107
|
}
|
|
108
|
-
this.info(` ✔ Successfully optimized ${file}: ${chalk.redBright(
|
|
108
|
+
this.info(` ✔ Successfully optimized ${file}: ${chalk.redBright(a(originalSize))} -> ${chalk.greenBright(a(compressedSize))} (${chalk.green((100 - compressedSize / originalSize * 100).toFixed(2))}%) in ${(performance.now() - start).toFixed(2)} ms`);
|
|
109
109
|
}));
|
|
110
110
|
}));
|
|
111
111
|
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
|
|
2
|
+
//#region ../../node_modules/.pnpm/@stryke+string-format@0.12.30/node_modules/@stryke/string-format/dist/pretty-bytes.mjs
|
|
3
|
+
const e = [
|
|
4
|
+
`B`,
|
|
5
|
+
`kB`,
|
|
6
|
+
`MB`,
|
|
7
|
+
`GB`,
|
|
8
|
+
`TB`,
|
|
9
|
+
`PB`,
|
|
10
|
+
`EB`,
|
|
11
|
+
`ZB`,
|
|
12
|
+
`YB`
|
|
13
|
+
], t = [
|
|
14
|
+
`B`,
|
|
15
|
+
`KiB`,
|
|
16
|
+
`MiB`,
|
|
17
|
+
`GiB`,
|
|
18
|
+
`TiB`,
|
|
19
|
+
`PiB`,
|
|
20
|
+
`EiB`,
|
|
21
|
+
`ZiB`,
|
|
22
|
+
`YiB`
|
|
23
|
+
], n = [
|
|
24
|
+
`b`,
|
|
25
|
+
`kbit`,
|
|
26
|
+
`Mbit`,
|
|
27
|
+
`Gbit`,
|
|
28
|
+
`Tbit`,
|
|
29
|
+
`Pbit`,
|
|
30
|
+
`Ebit`,
|
|
31
|
+
`Zbit`,
|
|
32
|
+
`Ybit`
|
|
33
|
+
], r = [
|
|
34
|
+
`b`,
|
|
35
|
+
`kibit`,
|
|
36
|
+
`Mibit`,
|
|
37
|
+
`Gibit`,
|
|
38
|
+
`Tibit`,
|
|
39
|
+
`Pibit`,
|
|
40
|
+
`Eibit`,
|
|
41
|
+
`Zibit`,
|
|
42
|
+
`Yibit`
|
|
43
|
+
], i = (e$1, t$1, n$1 = {}) => {
|
|
44
|
+
let r$1 = e$1, i$1 = t$1;
|
|
45
|
+
return typeof i$1 == `string` ? (i$1 ||= process.env.STORM_LOCALE || `en-US`, Array.isArray(i$1) && (r$1 = e$1?.toLocaleString(i$1, n$1))) : (i$1 === !0 || n$1 !== void 0) && (r$1 = e$1?.toLocaleString(void 0, n$1)), String(r$1);
|
|
46
|
+
};
|
|
47
|
+
function a(a$1, o) {
|
|
48
|
+
let s = a$1;
|
|
49
|
+
if (!Number.isFinite(s)) throw TypeError(`Expected a finite number, got ${typeof s}: ${s}`);
|
|
50
|
+
let c = {
|
|
51
|
+
bits: !1,
|
|
52
|
+
binary: !1,
|
|
53
|
+
space: !0,
|
|
54
|
+
...o
|
|
55
|
+
}, l = c.bits ? c.binary ? r : n : c.binary ? t : e, u = c.space ? ` ` : ``;
|
|
56
|
+
if (c.signed && s === 0) return ` 0${u}${l[0]}`;
|
|
57
|
+
let d = s < 0, f = d ? `-` : c.signed ? `+` : ``;
|
|
58
|
+
d && (s = -s);
|
|
59
|
+
let p;
|
|
60
|
+
if (c.minimumFractionDigits !== void 0 && (p = { minimumFractionDigits: c.minimumFractionDigits }), c.maximumFractionDigits !== void 0 && (p = {
|
|
61
|
+
maximumFractionDigits: c.maximumFractionDigits,
|
|
62
|
+
...p
|
|
63
|
+
}), s < 1) return f + i(s, c.locale, p) + u + l[0];
|
|
64
|
+
let m = Math.min(Math.floor(c.binary ? Math.log(s) / Math.log(1024) : Math.log10(s) / 3), l.length - 1);
|
|
65
|
+
s /= (c.binary ? 1024 : 1e3) ** m, p || (s = s.toPrecision(3));
|
|
66
|
+
let h = i(Number(s), c.locale, p), g = l[m];
|
|
67
|
+
return f + h + u + g;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
//#endregion
|
|
71
|
+
exports.a = a;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
//#region ../../node_modules/.pnpm/@stryke+string-format@0.12.30/node_modules/@stryke/string-format/dist/pretty-bytes.mjs
|
|
2
|
+
const e = [
|
|
3
|
+
`B`,
|
|
4
|
+
`kB`,
|
|
5
|
+
`MB`,
|
|
6
|
+
`GB`,
|
|
7
|
+
`TB`,
|
|
8
|
+
`PB`,
|
|
9
|
+
`EB`,
|
|
10
|
+
`ZB`,
|
|
11
|
+
`YB`
|
|
12
|
+
], t = [
|
|
13
|
+
`B`,
|
|
14
|
+
`KiB`,
|
|
15
|
+
`MiB`,
|
|
16
|
+
`GiB`,
|
|
17
|
+
`TiB`,
|
|
18
|
+
`PiB`,
|
|
19
|
+
`EiB`,
|
|
20
|
+
`ZiB`,
|
|
21
|
+
`YiB`
|
|
22
|
+
], n = [
|
|
23
|
+
`b`,
|
|
24
|
+
`kbit`,
|
|
25
|
+
`Mbit`,
|
|
26
|
+
`Gbit`,
|
|
27
|
+
`Tbit`,
|
|
28
|
+
`Pbit`,
|
|
29
|
+
`Ebit`,
|
|
30
|
+
`Zbit`,
|
|
31
|
+
`Ybit`
|
|
32
|
+
], r = [
|
|
33
|
+
`b`,
|
|
34
|
+
`kibit`,
|
|
35
|
+
`Mibit`,
|
|
36
|
+
`Gibit`,
|
|
37
|
+
`Tibit`,
|
|
38
|
+
`Pibit`,
|
|
39
|
+
`Eibit`,
|
|
40
|
+
`Zibit`,
|
|
41
|
+
`Yibit`
|
|
42
|
+
], i = (e$1, t$1, n$1 = {}) => {
|
|
43
|
+
let r$1 = e$1, i$1 = t$1;
|
|
44
|
+
return typeof i$1 == `string` ? (i$1 ||= process.env.STORM_LOCALE || `en-US`, Array.isArray(i$1) && (r$1 = e$1?.toLocaleString(i$1, n$1))) : (i$1 === !0 || n$1 !== void 0) && (r$1 = e$1?.toLocaleString(void 0, n$1)), String(r$1);
|
|
45
|
+
};
|
|
46
|
+
function a(a$1, o) {
|
|
47
|
+
let s = a$1;
|
|
48
|
+
if (!Number.isFinite(s)) throw TypeError(`Expected a finite number, got ${typeof s}: ${s}`);
|
|
49
|
+
let c = {
|
|
50
|
+
bits: !1,
|
|
51
|
+
binary: !1,
|
|
52
|
+
space: !0,
|
|
53
|
+
...o
|
|
54
|
+
}, l = c.bits ? c.binary ? r : n : c.binary ? t : e, u = c.space ? ` ` : ``;
|
|
55
|
+
if (c.signed && s === 0) return ` 0${u}${l[0]}`;
|
|
56
|
+
let d = s < 0, f = d ? `-` : c.signed ? `+` : ``;
|
|
57
|
+
d && (s = -s);
|
|
58
|
+
let p;
|
|
59
|
+
if (c.minimumFractionDigits !== void 0 && (p = { minimumFractionDigits: c.minimumFractionDigits }), c.maximumFractionDigits !== void 0 && (p = {
|
|
60
|
+
maximumFractionDigits: c.maximumFractionDigits,
|
|
61
|
+
...p
|
|
62
|
+
}), s < 1) return f + i(s, c.locale, p) + u + l[0];
|
|
63
|
+
let m = Math.min(Math.floor(c.binary ? Math.log(s) / Math.log(1024) : Math.log10(s) / 3), l.length - 1);
|
|
64
|
+
s /= (c.binary ? 1024 : 1e3) ** m, p || (s = s.toPrecision(3));
|
|
65
|
+
let h = i(Number(s), c.locale, p), g = l[m];
|
|
66
|
+
return f + h + u + g;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
//#endregion
|
|
70
|
+
export { a };
|
package/dist/types/plugin.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { UserConfig } from "../powerlines/src/types/config.mjs";
|
|
2
|
-
import { ResolvedConfig } from "../powerlines/src/types/resolved.mjs";
|
|
3
|
-
import { PluginContext } from "../powerlines/src/types/context.mjs";
|
|
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
4
|
import { Config } from "svgo";
|
|
5
5
|
import { AvifOptions, GifOptions, HeifOptions, Jp2Options, JpegOptions, JxlOptions, PngOptions, TiffOptions, WebpOptions } from "sharp";
|
|
6
6
|
|
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.78",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A Powerlines plugin to optimize images used by the project.",
|
|
6
6
|
"repository": {
|
|
@@ -123,22 +123,21 @@
|
|
|
123
123
|
"powerlines-plugin"
|
|
124
124
|
],
|
|
125
125
|
"dependencies": {
|
|
126
|
-
"@stryke/path": "^0.24.1",
|
|
127
|
-
"@stryke/fs": "^0.33.27",
|
|
128
126
|
"@stryke/convert": "^0.6.30",
|
|
127
|
+
"@stryke/fs": "^0.33.27",
|
|
128
|
+
"@stryke/path": "^0.24.1",
|
|
129
129
|
"chalk": "5.6.2",
|
|
130
130
|
"defu": "^6.1.4",
|
|
131
131
|
"jiti": "^2.6.1",
|
|
132
|
+
"powerlines": "^0.37.3",
|
|
132
133
|
"sharp": "^0.34.5",
|
|
133
|
-
"svgo": "^4.0.0"
|
|
134
|
-
"powerlines": "^0.37.2"
|
|
134
|
+
"svgo": "^4.0.0"
|
|
135
135
|
},
|
|
136
136
|
"devDependencies": {
|
|
137
|
+
"@powerlines/plugin-plugin": "^0.12.81",
|
|
137
138
|
"@storm-software/config": "^1.134.75",
|
|
138
|
-
"@powerlines/nx": "^0.11.58",
|
|
139
|
-
"@powerlines/plugin-plugin": "^0.12.80",
|
|
140
139
|
"@types/node": "^24.10.4"
|
|
141
140
|
},
|
|
142
141
|
"publishConfig": { "access": "public" },
|
|
143
|
-
"gitHead": "
|
|
142
|
+
"gitHead": "ae9a5afaa497538477b63988242f433b60974623"
|
|
144
143
|
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
let __stryke_path_replace = require("@stryke/path/replace");
|
|
3
|
-
|
|
4
|
-
//#region ../powerlines/src/plugin-utils/paths.ts
|
|
5
|
-
/**
|
|
6
|
-
* Replaces tokens in the given path string with their corresponding values from the context.
|
|
7
|
-
*
|
|
8
|
-
* @remarks
|
|
9
|
-
* The following tokens are supported:
|
|
10
|
-
* - `{workspaceRoot}` - The root directory of the workspace.
|
|
11
|
-
* - `{root}` - The root directory of the project (same as `{projectRoot}`).
|
|
12
|
-
* - `{projectRoot}` - The root directory of the project (same as `{root}`).
|
|
13
|
-
* - `{sourceRoot}` - The source root directory of the project (usually `./src`).
|
|
14
|
-
* - `{powerlinesPath}` - The directory where Powerlines is installed.
|
|
15
|
-
* - `{cachePath}` - The environment's directory for cached files.
|
|
16
|
-
* - `{dataPath}` - The environment's directory for data files.
|
|
17
|
-
* - `{logPath}` - The environment's directory for log files.
|
|
18
|
-
* - `{tempPath}` - The environment's directory for temporary files.
|
|
19
|
-
* - `{configPath}` - The environment's directory for configuration files.
|
|
20
|
-
* - `{outputPath}` - The configured output directory for the project.
|
|
21
|
-
* - `{buildPath}` - The configured distribution directory for the project.
|
|
22
|
-
* - `{artifactsPath}` - The configured directory for build artifacts.
|
|
23
|
-
* - `{builtinPath}` - The configured directory for generated built-in plugins.
|
|
24
|
-
* - `{entryPath}` - The configured directory for generated entry files.
|
|
25
|
-
*
|
|
26
|
-
* @param context - The context containing the values for the path tokens.
|
|
27
|
-
* @param path - The path string with tokens to replace.
|
|
28
|
-
* @returns The path string with tokens replaced by their corresponding values from the context.
|
|
29
|
-
*/
|
|
30
|
-
function replacePathTokens(context, path) {
|
|
31
|
-
if (!path) return path;
|
|
32
|
-
return path.replaceAll("{workspaceRoot}", context.workspaceConfig.workspaceRoot).replaceAll("{root}", context.config.projectRoot).replaceAll("{projectRoot}", context.config.projectRoot).replaceAll("{sourceRoot}", context.config.sourceRoot).replaceAll("{powerlinesPath}", context.powerlinesPath).replaceAll("{cachePath}", context.cachePath).replaceAll("{dataPath}", context.dataPath).replaceAll("{logPath}", context.envPaths.log).replaceAll("{tempPath}", context.envPaths.temp).replaceAll("{configPath}", context.envPaths.config).replaceAll("{outputPath}", context.config.output.outputPath).replaceAll("{buildPath}", context.config.output.buildPath).replaceAll("{artifactsPath}", (0, __stryke_path_replace.replacePath)(context.artifactsPath, context.workspaceConfig.workspaceRoot)).replaceAll("{builtinPath}", (0, __stryke_path_replace.replacePath)(context.builtinsPath, context.workspaceConfig.workspaceRoot)).replaceAll("{entryPath}", (0, __stryke_path_replace.replacePath)(context.entryPath, context.workspaceConfig.workspaceRoot));
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
//#endregion
|
|
36
|
-
exports.replacePathTokens = replacePathTokens;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { replacePath } from "@stryke/path/replace";
|
|
2
|
-
|
|
3
|
-
//#region ../powerlines/src/plugin-utils/paths.ts
|
|
4
|
-
/**
|
|
5
|
-
* Replaces tokens in the given path string with their corresponding values from the context.
|
|
6
|
-
*
|
|
7
|
-
* @remarks
|
|
8
|
-
* The following tokens are supported:
|
|
9
|
-
* - `{workspaceRoot}` - The root directory of the workspace.
|
|
10
|
-
* - `{root}` - The root directory of the project (same as `{projectRoot}`).
|
|
11
|
-
* - `{projectRoot}` - The root directory of the project (same as `{root}`).
|
|
12
|
-
* - `{sourceRoot}` - The source root directory of the project (usually `./src`).
|
|
13
|
-
* - `{powerlinesPath}` - The directory where Powerlines is installed.
|
|
14
|
-
* - `{cachePath}` - The environment's directory for cached files.
|
|
15
|
-
* - `{dataPath}` - The environment's directory for data files.
|
|
16
|
-
* - `{logPath}` - The environment's directory for log files.
|
|
17
|
-
* - `{tempPath}` - The environment's directory for temporary files.
|
|
18
|
-
* - `{configPath}` - The environment's directory for configuration files.
|
|
19
|
-
* - `{outputPath}` - The configured output directory for the project.
|
|
20
|
-
* - `{buildPath}` - The configured distribution directory for the project.
|
|
21
|
-
* - `{artifactsPath}` - The configured directory for build artifacts.
|
|
22
|
-
* - `{builtinPath}` - The configured directory for generated built-in plugins.
|
|
23
|
-
* - `{entryPath}` - The configured directory for generated entry files.
|
|
24
|
-
*
|
|
25
|
-
* @param context - The context containing the values for the path tokens.
|
|
26
|
-
* @param path - The path string with tokens to replace.
|
|
27
|
-
* @returns The path string with tokens replaced by their corresponding values from the context.
|
|
28
|
-
*/
|
|
29
|
-
function replacePathTokens(context, path) {
|
|
30
|
-
if (!path) return path;
|
|
31
|
-
return path.replaceAll("{workspaceRoot}", context.workspaceConfig.workspaceRoot).replaceAll("{root}", context.config.projectRoot).replaceAll("{projectRoot}", context.config.projectRoot).replaceAll("{sourceRoot}", context.config.sourceRoot).replaceAll("{powerlinesPath}", context.powerlinesPath).replaceAll("{cachePath}", context.cachePath).replaceAll("{dataPath}", context.dataPath).replaceAll("{logPath}", context.envPaths.log).replaceAll("{tempPath}", context.envPaths.temp).replaceAll("{configPath}", context.envPaths.config).replaceAll("{outputPath}", context.config.output.outputPath).replaceAll("{buildPath}", context.config.output.buildPath).replaceAll("{artifactsPath}", replacePath(context.artifactsPath, context.workspaceConfig.workspaceRoot)).replaceAll("{builtinPath}", replacePath(context.builtinsPath, context.workspaceConfig.workspaceRoot)).replaceAll("{entryPath}", replacePath(context.entryPath, context.workspaceConfig.workspaceRoot));
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
//#endregion
|
|
35
|
-
export { replacePathTokens };
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|