@maizzle/framework 6.1.3 → 6.1.5
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/build.d.ts +3 -4
- package/dist/build.d.ts.map +1 -1
- package/dist/build.js +1 -5
- package/dist/build.js.map +1 -1
- package/dist/components/Outlook.vue +8 -2
- package/dist/components/utils.d.ts +10 -11
- package/dist/components/utils.d.ts.map +1 -1
- package/dist/composables/defineConfig.d.ts +1 -2
- package/dist/composables/defineConfig.d.ts.map +1 -1
- package/dist/composables/renderContext.d.ts +4 -5
- package/dist/composables/renderContext.d.ts.map +1 -1
- package/dist/composables/useBaseUrl.d.ts +1 -2
- package/dist/composables/useBaseUrl.d.ts.map +1 -1
- package/dist/composables/useConfig.d.ts +2 -3
- package/dist/composables/useConfig.d.ts.map +1 -1
- package/dist/composables/useCurrentTemplate.d.ts +2 -3
- package/dist/composables/useCurrentTemplate.d.ts.map +1 -1
- package/dist/composables/useDoctype.d.ts +1 -2
- package/dist/composables/useDoctype.d.ts.map +1 -1
- package/dist/composables/useEvent.d.ts +1 -2
- package/dist/composables/useEvent.d.ts.map +1 -1
- package/dist/composables/useFont.d.ts +3 -4
- package/dist/composables/useFont.d.ts.map +1 -1
- package/dist/composables/useOutlookFallback.d.ts +1 -2
- package/dist/composables/useOutlookFallback.d.ts.map +1 -1
- package/dist/composables/useOutputPath.d.ts +1 -2
- package/dist/composables/useOutputPath.d.ts.map +1 -1
- package/dist/composables/usePlaintext.d.ts +2 -3
- package/dist/composables/usePlaintext.d.ts.map +1 -1
- package/dist/composables/usePreheader.d.ts +2 -3
- package/dist/composables/usePreheader.d.ts.map +1 -1
- package/dist/composables/useTransformers.d.ts +1 -2
- package/dist/composables/useTransformers.d.ts.map +1 -1
- package/dist/composables/useUrlQuery.d.ts +1 -2
- package/dist/composables/useUrlQuery.d.ts.map +1 -1
- package/dist/config/defaults.d.ts +1 -2
- package/dist/config/defaults.d.ts.map +1 -1
- package/dist/config/index.d.ts +4 -4
- package/dist/config/index.d.ts.map +1 -1
- package/dist/events/index.d.ts +4 -5
- package/dist/events/index.d.ts.map +1 -1
- package/dist/plaintext.d.ts +1 -2
- package/dist/plaintext.d.ts.map +1 -1
- package/dist/plugin.d.ts +1 -2
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugins/postcss/flattenGradients.d.ts +3 -3
- package/dist/plugins/postcss/flattenGradients.d.ts.map +1 -1
- package/dist/plugins/postcss/mergeMediaQueries.d.ts +1 -2
- package/dist/plugins/postcss/mergeMediaQueries.d.ts.map +1 -1
- package/dist/plugins/postcss/pruneVars.d.ts +2 -2
- package/dist/plugins/postcss/pruneVars.d.ts.map +1 -1
- package/dist/plugins/postcss/quoteFontFamilies.d.ts +2 -3
- package/dist/plugins/postcss/quoteFontFamilies.d.ts.map +1 -1
- package/dist/plugins/postcss/removeDeclarations.d.ts +4 -4
- package/dist/plugins/postcss/removeDeclarations.d.ts.map +1 -1
- package/dist/plugins/postcss/resolveMaizzleImports.d.ts +1 -2
- package/dist/plugins/postcss/resolveMaizzleImports.d.ts.map +1 -1
- package/dist/plugins/postcss/resolveProps.d.ts +2 -2
- package/dist/plugins/postcss/resolveProps.d.ts.map +1 -1
- package/dist/plugins/postcss/tailwindCleanup.d.ts +1 -2
- package/dist/plugins/postcss/tailwindCleanup.d.ts.map +1 -1
- package/dist/prepare.d.ts +2 -3
- package/dist/prepare.d.ts.map +1 -1
- package/dist/render/active.d.ts +2 -3
- package/dist/render/active.d.ts.map +1 -1
- package/dist/render/buildTemplate.d.ts +5 -6
- package/dist/render/buildTemplate.d.ts.map +1 -1
- package/dist/render/buildTemplate.js +1 -1
- package/dist/render/buildTemplate.js.map +1 -1
- package/dist/render/createRenderer.d.ts +4 -5
- package/dist/render/createRenderer.d.ts.map +1 -1
- package/dist/render/index.d.ts +3 -3
- package/dist/render/index.d.ts.map +1 -1
- package/dist/render/index.js +1 -1
- package/dist/render/index.js.map +1 -1
- package/dist/render/injectFonts.d.ts +1 -2
- package/dist/render/injectFonts.d.ts.map +1 -1
- package/dist/render/parallel/buildWorker.d.ts +3 -4
- package/dist/render/parallel/buildWorker.d.ts.map +1 -1
- package/dist/render/plugins/codeBlockExtract.d.ts +1 -2
- package/dist/render/plugins/codeBlockExtract.d.ts.map +1 -1
- package/dist/render/plugins/markdownExtract.d.ts +1 -2
- package/dist/render/plugins/markdownExtract.d.ts.map +1 -1
- package/dist/render/plugins/rawExtract.d.ts +1 -2
- package/dist/render/plugins/rawExtract.d.ts.map +1 -1
- package/dist/render/plugins/rowSourceLocation.d.ts +1 -2
- package/dist/render/plugins/rowSourceLocation.d.ts.map +1 -1
- package/dist/serve.d.ts +3 -4
- package/dist/serve.d.ts.map +1 -1
- package/dist/serve.js +47 -4
- package/dist/serve.js.map +1 -1
- package/dist/server/compatibility.d.ts +2 -3
- package/dist/server/compatibility.d.ts.map +1 -1
- package/dist/server/email.d.ts +2 -3
- package/dist/server/email.d.ts.map +1 -1
- package/dist/server/linter.d.ts +3 -4
- package/dist/server/linter.d.ts.map +1 -1
- package/dist/server/sfc-utils.d.ts +6 -7
- package/dist/server/sfc-utils.d.ts.map +1 -1
- package/dist/server/static.d.ts +10 -0
- package/dist/server/static.d.ts.map +1 -0
- package/dist/server/static.js +71 -0
- package/dist/server/static.js.map +1 -0
- package/dist/server/ui/.vite/deps/@lucide_vue.js +1 -1
- package/dist/server/ui/.vite/deps/@vueuse_core.js +1 -1
- package/dist/server/ui/.vite/deps/@vueuse_shared.js +1 -1
- package/dist/server/ui/.vite/deps/_metadata.json +15 -15
- package/dist/server/ui/.vite/deps/reka-ui.js +1 -2
- package/dist/server/ui/.vite/deps/reka-ui.js.map +1 -1
- package/dist/server/ui/.vite/deps/vue-router.js +1 -1
- package/dist/server/ui/.vite/deps/vue.js +1 -1
- package/dist/server/ui/.vite/deps/{vue.runtime.esm-bundler-S54atuNJ.js → vue.runtime.esm-bundler-Dq07uCLt.js} +174 -53
- package/dist/server/ui/.vite/deps/vue.runtime.esm-bundler-Dq07uCLt.js.map +1 -0
- package/dist/tests/render/_helpers.d.ts +2 -3
- package/dist/tests/render/_helpers.d.ts.map +1 -1
- package/dist/transformers/addAttributes.d.ts +2 -3
- package/dist/transformers/addAttributes.d.ts.map +1 -1
- package/dist/transformers/attributeToStyle.d.ts +2 -3
- package/dist/transformers/attributeToStyle.d.ts.map +1 -1
- package/dist/transformers/base.d.ts +3 -4
- package/dist/transformers/base.d.ts.map +1 -1
- package/dist/transformers/columnWidth.d.ts +1 -2
- package/dist/transformers/columnWidth.d.ts.map +1 -1
- package/dist/transformers/entities.d.ts +3 -4
- package/dist/transformers/entities.d.ts.map +1 -1
- package/dist/transformers/filters/defaults.d.ts +2 -3
- package/dist/transformers/filters/defaults.d.ts.map +1 -1
- package/dist/transformers/filters/index.d.ts +4 -4
- package/dist/transformers/filters/index.d.ts.map +1 -1
- package/dist/transformers/format.d.ts +2 -2
- package/dist/transformers/format.d.ts.map +1 -1
- package/dist/transformers/imgWidth.d.ts +1 -2
- package/dist/transformers/imgWidth.d.ts.map +1 -1
- package/dist/transformers/index.d.ts +2 -2
- package/dist/transformers/index.d.ts.map +1 -1
- package/dist/transformers/index.js +8 -2
- package/dist/transformers/index.js.map +1 -1
- package/dist/transformers/inlineCss.d.ts +3 -4
- package/dist/transformers/inlineCss.d.ts.map +1 -1
- package/dist/transformers/inlineLink.d.ts +2 -3
- package/dist/transformers/inlineLink.d.ts.map +1 -1
- package/dist/transformers/minify.d.ts +2 -2
- package/dist/transformers/minify.d.ts.map +1 -1
- package/dist/transformers/minifyCodeInline.d.ts +1 -2
- package/dist/transformers/minifyCodeInline.d.ts.map +1 -1
- package/dist/transformers/msoConditionals.d.ts +4 -0
- package/dist/transformers/msoConditionals.d.ts.map +1 -0
- package/dist/transformers/msoConditionals.js +25 -0
- package/dist/transformers/msoConditionals.js.map +1 -0
- package/dist/transformers/msoPlaceholders.d.ts +1 -2
- package/dist/transformers/msoPlaceholders.d.ts.map +1 -1
- package/dist/transformers/purgeCss.d.ts +3 -4
- package/dist/transformers/purgeCss.d.ts.map +1 -1
- package/dist/transformers/removeAttributes.d.ts +4 -5
- package/dist/transformers/removeAttributes.d.ts.map +1 -1
- package/dist/transformers/replaceStrings.d.ts +1 -2
- package/dist/transformers/replaceStrings.d.ts.map +1 -1
- package/dist/transformers/safeSelectors.d.ts +2 -3
- package/dist/transformers/safeSelectors.d.ts.map +1 -1
- package/dist/transformers/shorthandCss.d.ts +3 -4
- package/dist/transformers/shorthandCss.d.ts.map +1 -1
- package/dist/transformers/sixHex.d.ts +2 -3
- package/dist/transformers/sixHex.d.ts.map +1 -1
- package/dist/transformers/tailwindComponent.d.ts +1 -2
- package/dist/transformers/tailwindComponent.d.ts.map +1 -1
- package/dist/transformers/tailwindcss.d.ts +2 -3
- package/dist/transformers/tailwindcss.d.ts.map +1 -1
- package/dist/transformers/urlQuery.d.ts +2 -3
- package/dist/transformers/urlQuery.d.ts.map +1 -1
- package/dist/types/config.d.ts +18 -19
- package/dist/types/config.d.ts.map +1 -1
- package/dist/utils/ast/parser.d.ts +1 -2
- package/dist/utils/ast/parser.d.ts.map +1 -1
- package/dist/utils/ast/serializer.d.ts +1 -2
- package/dist/utils/ast/serializer.d.ts.map +1 -1
- package/dist/utils/ast/walker.d.ts +1 -2
- package/dist/utils/ast/walker.d.ts.map +1 -1
- package/dist/utils/cloneConfig.d.ts +1 -2
- package/dist/utils/cloneConfig.d.ts.map +1 -1
- package/dist/utils/compileTailwindCss.d.ts +4 -5
- package/dist/utils/compileTailwindCss.d.ts.map +1 -1
- package/dist/utils/componentSources.d.ts +4 -5
- package/dist/utils/componentSources.d.ts.map +1 -1
- package/dist/utils/cssBox.d.ts +6 -7
- package/dist/utils/cssBox.d.ts.map +1 -1
- package/dist/utils/decodeStyleEntities.d.ts +1 -2
- package/dist/utils/decodeStyleEntities.d.ts.map +1 -1
- package/dist/utils/detect.d.ts +1 -2
- package/dist/utils/detect.d.ts.map +1 -1
- package/dist/utils/output-markers.d.ts +4 -5
- package/dist/utils/output-markers.d.ts.map +1 -1
- package/dist/utils/staticPaths.d.ts +5 -0
- package/dist/utils/staticPaths.d.ts.map +1 -0
- package/dist/utils/staticPaths.js +11 -0
- package/dist/utils/staticPaths.js.map +1 -0
- package/dist/utils/url.d.ts +4 -5
- package/dist/utils/url.d.ts.map +1 -1
- package/dist/utils/watchPaths.d.ts +2 -3
- package/dist/utils/watchPaths.d.ts.map +1 -1
- package/node_modules/tinyexec/dist/main.d.mts +5 -3
- package/node_modules/tinyexec/dist/main.mjs +256 -232
- package/node_modules/tinyexec/package.json +9 -9
- package/package.json +5 -5
- package/dist/server/ui/.vite/deps/vue.runtime.esm-bundler-S54atuNJ.js.map +0 -1
|
@@ -1,165 +1,168 @@
|
|
|
1
|
-
import { spawn
|
|
2
|
-
import { cwd
|
|
3
|
-
import { basename
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import
|
|
1
|
+
import { spawn, spawnSync } from "node:child_process";
|
|
2
|
+
import { cwd } from "node:process";
|
|
3
|
+
import { basename, delimiter, dirname, normalize, resolve } from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { pipeline } from "node:stream/promises";
|
|
6
|
+
import { PassThrough } from "node:stream";
|
|
7
|
+
import readline from "node:readline";
|
|
8
|
+
import { closeSync, openSync, readSync, statSync } from "node:fs";
|
|
8
9
|
//#region src/env.ts
|
|
9
|
-
const
|
|
10
|
-
const
|
|
10
|
+
const isPathLikePattern = /^path$/i;
|
|
11
|
+
const defaultEnvPathInfo = {
|
|
11
12
|
key: "PATH",
|
|
12
13
|
value: ""
|
|
13
14
|
};
|
|
14
|
-
function
|
|
15
|
-
for (const
|
|
16
|
-
if (!Object.prototype.hasOwnProperty.call(
|
|
17
|
-
const
|
|
18
|
-
if (!
|
|
15
|
+
function getPathFromEnv(env) {
|
|
16
|
+
for (const key in env) {
|
|
17
|
+
if (!Object.prototype.hasOwnProperty.call(env, key) || !isPathLikePattern.test(key)) continue;
|
|
18
|
+
const value = env[key];
|
|
19
|
+
if (!value) return defaultEnvPathInfo;
|
|
19
20
|
return {
|
|
20
|
-
key
|
|
21
|
-
value
|
|
21
|
+
key,
|
|
22
|
+
value
|
|
22
23
|
};
|
|
23
24
|
}
|
|
24
|
-
return
|
|
25
|
+
return defaultEnvPathInfo;
|
|
25
26
|
}
|
|
26
|
-
function
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
let
|
|
30
|
-
let
|
|
27
|
+
function addNodeBinToPath(cwd, path) {
|
|
28
|
+
const parts = path.value.split(delimiter);
|
|
29
|
+
const nodeBinPaths = [];
|
|
30
|
+
let currentPath = typeof cwd === "string" ? cwd : fileURLToPath(cwd, { windows: false });
|
|
31
|
+
let lastPath;
|
|
31
32
|
do {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
} while (
|
|
36
|
-
|
|
37
|
-
const
|
|
33
|
+
nodeBinPaths.push(resolve(currentPath, "node_modules", ".bin"));
|
|
34
|
+
lastPath = currentPath;
|
|
35
|
+
currentPath = dirname(currentPath);
|
|
36
|
+
} while (currentPath !== lastPath);
|
|
37
|
+
nodeBinPaths.push(dirname(process.execPath));
|
|
38
|
+
const newPath = nodeBinPaths.concat(parts).join(delimiter);
|
|
38
39
|
return {
|
|
39
|
-
key:
|
|
40
|
-
value:
|
|
40
|
+
key: path.key,
|
|
41
|
+
value: newPath
|
|
41
42
|
};
|
|
42
43
|
}
|
|
43
|
-
function
|
|
44
|
-
const
|
|
44
|
+
function computeEnv(cwd, env, nodePath = true) {
|
|
45
|
+
const envWithDefault = {
|
|
45
46
|
...process.env,
|
|
46
|
-
...
|
|
47
|
+
...env
|
|
47
48
|
};
|
|
48
|
-
if (!
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
return
|
|
49
|
+
if (!nodePath) return envWithDefault;
|
|
50
|
+
const envPathInfo = addNodeBinToPath(cwd, getPathFromEnv(envWithDefault));
|
|
51
|
+
envWithDefault[envPathInfo.key] = envPathInfo.value;
|
|
52
|
+
return envWithDefault;
|
|
52
53
|
}
|
|
53
54
|
//#endregion
|
|
54
55
|
//#region src/stream.ts
|
|
55
|
-
const
|
|
56
|
-
let
|
|
57
|
-
const
|
|
58
|
-
const
|
|
59
|
-
if (--
|
|
56
|
+
const combineStreams = (streams) => {
|
|
57
|
+
let streamCount = streams.length;
|
|
58
|
+
const combined = new PassThrough();
|
|
59
|
+
const maybeEmitEnd = () => {
|
|
60
|
+
if (--streamCount === 0) combined.end();
|
|
60
61
|
};
|
|
61
|
-
for (const
|
|
62
|
-
return
|
|
62
|
+
for (const stream of streams) pipeline(stream, combined, { end: false }).then(maybeEmitEnd).catch(maybeEmitEnd);
|
|
63
|
+
return combined;
|
|
63
64
|
};
|
|
64
65
|
//#endregion
|
|
65
66
|
//#region src/normalize.ts
|
|
66
|
-
const
|
|
67
|
-
const
|
|
68
|
-
const
|
|
69
|
-
const
|
|
70
|
-
const
|
|
71
|
-
const
|
|
67
|
+
const metaCharsRegExp = /([()\][%!^"`<>&|;, *?])/g;
|
|
68
|
+
const shebangRegExp = /^#!\s*(.+)/;
|
|
69
|
+
const isWindowsExecutableRegExp = /\.(?:com|exe)$/i;
|
|
70
|
+
const isNodeModulesCmdRegExp = /node_modules[\\/]\.bin[\\/][^\\/]+\.cmd$/i;
|
|
71
|
+
const isWindows = process.platform === "win32";
|
|
72
|
+
const defaultPathExt = [
|
|
72
73
|
".EXE",
|
|
73
74
|
".CMD",
|
|
74
75
|
".BAT",
|
|
75
76
|
".COM"
|
|
76
77
|
];
|
|
78
|
+
const noPathExt = [""];
|
|
77
79
|
/**
|
|
78
80
|
* Normalizes the command and arguments to work cross-platform.
|
|
79
81
|
* On Windows, this basically handles things like shebangs, calling
|
|
80
82
|
* `node_modules/.bin` commands, and escaping meta characters.
|
|
81
83
|
* On other platforms, it just returns the command and arguments as-is.
|
|
82
84
|
*/
|
|
83
|
-
function
|
|
84
|
-
if (
|
|
85
|
-
command
|
|
86
|
-
args
|
|
87
|
-
options
|
|
85
|
+
function normalizeSpawnCommand(command, args = [], options = {}) {
|
|
86
|
+
if (options.shell === true || !isWindows) return {
|
|
87
|
+
command,
|
|
88
|
+
args,
|
|
89
|
+
options
|
|
88
90
|
};
|
|
89
|
-
let
|
|
90
|
-
let
|
|
91
|
-
if (
|
|
92
|
-
const
|
|
93
|
-
const
|
|
94
|
-
let
|
|
91
|
+
let file = resolveCommand(command, options);
|
|
92
|
+
let shebang = null;
|
|
93
|
+
if (file !== null) {
|
|
94
|
+
const size = 150;
|
|
95
|
+
const buffer = Buffer.alloc(size);
|
|
96
|
+
let fd = null;
|
|
95
97
|
try {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
+
fd = openSync(file, "r");
|
|
99
|
+
readSync(fd, buffer, 0, size, 0);
|
|
98
100
|
} catch {} finally {
|
|
99
|
-
if (
|
|
101
|
+
if (fd !== null) closeSync(fd);
|
|
100
102
|
}
|
|
101
|
-
const
|
|
102
|
-
if (
|
|
103
|
-
const
|
|
104
|
-
const
|
|
105
|
-
const
|
|
106
|
-
const
|
|
107
|
-
const
|
|
108
|
-
|
|
103
|
+
const match = buffer.toString().match(shebangRegExp);
|
|
104
|
+
if (match !== null) {
|
|
105
|
+
const line = match[1].trim();
|
|
106
|
+
const separatorIndex = line.indexOf(" ");
|
|
107
|
+
const path = separatorIndex !== -1 ? line.slice(0, separatorIndex) : line;
|
|
108
|
+
const argument = separatorIndex !== -1 ? line.slice(separatorIndex + 1) : "";
|
|
109
|
+
const binary = basename(path);
|
|
110
|
+
shebang = binary === "env" ? argument || null : binary;
|
|
109
111
|
}
|
|
110
112
|
}
|
|
111
|
-
if (
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
113
|
+
if (shebang !== null && file !== null) {
|
|
114
|
+
args = [file, ...args];
|
|
115
|
+
command = shebang;
|
|
116
|
+
file = resolveCommand(command, options);
|
|
115
117
|
}
|
|
116
|
-
if (
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
if (
|
|
126
|
-
return
|
|
118
|
+
if (file === null || !isWindowsExecutableRegExp.test(file)) {
|
|
119
|
+
const needsDoubleEscapeMetaChars = file !== null && isNodeModulesCmdRegExp.test(file);
|
|
120
|
+
command = normalize(command);
|
|
121
|
+
command = command.replace(metaCharsRegExp, "^$1");
|
|
122
|
+
args = args.map((arg) => {
|
|
123
|
+
arg = arg.replace(/(?=(\\+?)?)\1"/g, "$1$1\\\"");
|
|
124
|
+
arg = arg.replace(/(?=(\\+?)?)\1$/, "$1$1");
|
|
125
|
+
arg = `"${arg}"`;
|
|
126
|
+
arg = arg.replace(metaCharsRegExp, "^$1");
|
|
127
|
+
if (needsDoubleEscapeMetaChars) arg = arg.replace(metaCharsRegExp, "^$1");
|
|
128
|
+
return arg;
|
|
127
129
|
});
|
|
128
|
-
|
|
130
|
+
args = [
|
|
129
131
|
"/d",
|
|
130
132
|
"/s",
|
|
131
133
|
"/c",
|
|
132
|
-
`"${[
|
|
134
|
+
`"${[command, ...args].join(" ")}"`
|
|
133
135
|
];
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
...
|
|
136
|
+
command = options.env?.comspec ?? "cmd.exe";
|
|
137
|
+
options = {
|
|
138
|
+
...options,
|
|
137
139
|
windowsVerbatimArguments: true
|
|
138
140
|
};
|
|
139
141
|
}
|
|
140
142
|
return {
|
|
141
|
-
command
|
|
142
|
-
args
|
|
143
|
-
options
|
|
143
|
+
command,
|
|
144
|
+
args,
|
|
145
|
+
options
|
|
144
146
|
};
|
|
145
147
|
}
|
|
146
148
|
/**
|
|
147
149
|
* Resolves the command to an absolute path if possible.
|
|
148
150
|
* Handles things like traversing PATH and adding extensions from PATHEXT
|
|
149
151
|
*/
|
|
150
|
-
function
|
|
151
|
-
const
|
|
152
|
-
const
|
|
153
|
-
const
|
|
154
|
-
const
|
|
155
|
-
|
|
156
|
-
if (
|
|
157
|
-
for (const
|
|
158
|
-
const
|
|
159
|
-
|
|
160
|
-
|
|
152
|
+
function resolveCommand(command, options) {
|
|
153
|
+
const cwd$3 = (options.cwd ?? cwd()).toString();
|
|
154
|
+
const env = options.env ?? process.env;
|
|
155
|
+
const PATH = getPathFromEnv(env).value;
|
|
156
|
+
const pathEnv = command.includes("/") || command.includes("\\") ? [""] : [cwd$3, ...PATH.split(delimiter)];
|
|
157
|
+
let pathExt = env.PATHEXT ? env.PATHEXT.split(delimiter) : defaultPathExt;
|
|
158
|
+
if (command.includes(".") && pathExt[0] !== "") pathExt = ["", ...pathExt];
|
|
159
|
+
for (const extensions of [pathExt, noPathExt]) for (const path of pathEnv) {
|
|
160
|
+
const unquoted = path.startsWith("\"") && path.endsWith("\"") && path.length > 1 ? path.slice(1, -1) : path;
|
|
161
|
+
const dest = resolve(cwd$3, unquoted, command);
|
|
162
|
+
for (const ext of extensions) {
|
|
163
|
+
const destWithExt = dest + ext;
|
|
161
164
|
try {
|
|
162
|
-
if (
|
|
165
|
+
if (statSync(destWithExt).isFile()) return destWithExt;
|
|
163
166
|
} catch {}
|
|
164
167
|
}
|
|
165
168
|
}
|
|
@@ -167,49 +170,59 @@ function O(e, t) {
|
|
|
167
170
|
}
|
|
168
171
|
//#endregion
|
|
169
172
|
//#region src/non-zero-exit-error.ts
|
|
170
|
-
var
|
|
173
|
+
var NonZeroExitError = class extends Error {
|
|
171
174
|
result;
|
|
172
175
|
output;
|
|
173
|
-
|
|
174
|
-
|
|
176
|
+
exitCode;
|
|
177
|
+
get signalCode() {
|
|
178
|
+
return this.result.signalCode;
|
|
175
179
|
}
|
|
176
|
-
constructor(
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
+
constructor(result, output, command, args) {
|
|
181
|
+
let target = "The process";
|
|
182
|
+
if (command) target = `The command \`${args?.length ? `${command} ${args.map((a) => /[ "'`()]/.test(a) ? JSON.stringify(a) : a).join(" ")}` : command}\``;
|
|
183
|
+
const exitCode = result.exitCode ?? 1;
|
|
184
|
+
super(result.signalCode !== null ? `${target} was killed by the signal ${result.signalCode}` : `${target} exited with a non-zero status (${exitCode})`);
|
|
185
|
+
this.result = result;
|
|
186
|
+
this.output = output;
|
|
187
|
+
this.exitCode = exitCode;
|
|
188
|
+
Object.defineProperty(this, "result", {
|
|
189
|
+
enumerable: false,
|
|
190
|
+
writable: false,
|
|
191
|
+
configurable: false
|
|
192
|
+
});
|
|
180
193
|
}
|
|
181
194
|
};
|
|
182
195
|
//#endregion
|
|
183
196
|
//#region src/main.ts
|
|
184
|
-
const
|
|
185
|
-
const
|
|
197
|
+
const LINE_SEPARATOR_REGEX = /\r?\n/;
|
|
198
|
+
const defaultOptions = {
|
|
186
199
|
timeout: void 0,
|
|
187
200
|
persist: false
|
|
188
201
|
};
|
|
189
|
-
const
|
|
190
|
-
const
|
|
191
|
-
function
|
|
192
|
-
const
|
|
193
|
-
for (const
|
|
194
|
-
if (
|
|
195
|
-
|
|
196
|
-
return
|
|
202
|
+
const defaultSyncOptions = { timeout: void 0 };
|
|
203
|
+
const defaultNodeOptions = { windowsHide: true };
|
|
204
|
+
function combineSignals(signals) {
|
|
205
|
+
const controller = new AbortController();
|
|
206
|
+
for (const signal of signals) {
|
|
207
|
+
if (signal.aborted) {
|
|
208
|
+
controller.abort();
|
|
209
|
+
return signal;
|
|
197
210
|
}
|
|
198
|
-
const
|
|
199
|
-
|
|
211
|
+
const onAbort = () => {
|
|
212
|
+
controller.abort(signal.reason);
|
|
200
213
|
};
|
|
201
|
-
|
|
214
|
+
signal.addEventListener("abort", onAbort, { signal: controller.signal });
|
|
202
215
|
}
|
|
203
|
-
return
|
|
216
|
+
return controller.signal;
|
|
204
217
|
}
|
|
205
|
-
async function
|
|
206
|
-
let
|
|
218
|
+
async function readStream(stream) {
|
|
219
|
+
let output = "";
|
|
207
220
|
try {
|
|
208
|
-
for await (const
|
|
221
|
+
for await (const chunk of stream) output += chunk.toString();
|
|
209
222
|
} catch {}
|
|
210
|
-
return
|
|
223
|
+
return output;
|
|
211
224
|
}
|
|
212
|
-
var
|
|
225
|
+
var ExecProcess = class {
|
|
213
226
|
_process;
|
|
214
227
|
_aborted = false;
|
|
215
228
|
_options;
|
|
@@ -227,19 +240,22 @@ var I = class {
|
|
|
227
240
|
get exitCode() {
|
|
228
241
|
if (this._process && this._process.exitCode !== null) return this._process.exitCode;
|
|
229
242
|
}
|
|
230
|
-
|
|
243
|
+
get signalCode() {
|
|
244
|
+
return this._process?.signalCode ?? null;
|
|
245
|
+
}
|
|
246
|
+
constructor(command, args, options) {
|
|
231
247
|
this._options = {
|
|
232
|
-
...
|
|
233
|
-
...
|
|
248
|
+
...defaultOptions,
|
|
249
|
+
...options
|
|
234
250
|
};
|
|
235
|
-
this._command =
|
|
236
|
-
this._args =
|
|
237
|
-
this._processClosed = new Promise((
|
|
238
|
-
this._resolveClose =
|
|
251
|
+
this._command = command;
|
|
252
|
+
this._args = args ?? [];
|
|
253
|
+
this._processClosed = new Promise((resolve) => {
|
|
254
|
+
this._resolveClose = resolve;
|
|
239
255
|
});
|
|
240
256
|
}
|
|
241
|
-
kill(
|
|
242
|
-
return this._process?.kill(
|
|
257
|
+
kill(signal) {
|
|
258
|
+
return this._process?.kill(signal) === true;
|
|
243
259
|
}
|
|
244
260
|
get aborted() {
|
|
245
261
|
return this._aborted;
|
|
@@ -247,142 +263,150 @@ var I = class {
|
|
|
247
263
|
get killed() {
|
|
248
264
|
return this._process?.killed === true;
|
|
249
265
|
}
|
|
250
|
-
pipe(
|
|
251
|
-
return
|
|
252
|
-
...
|
|
266
|
+
pipe(command, args, options) {
|
|
267
|
+
return exec(command, args, {
|
|
268
|
+
...options,
|
|
253
269
|
stdin: this
|
|
254
270
|
});
|
|
255
271
|
}
|
|
256
272
|
async *[Symbol.asyncIterator]() {
|
|
257
|
-
const
|
|
258
|
-
if (!
|
|
259
|
-
const
|
|
260
|
-
if (this._streamErr)
|
|
261
|
-
if (this._streamOut)
|
|
262
|
-
const
|
|
263
|
-
const
|
|
264
|
-
for await (const
|
|
273
|
+
const proc = this._process;
|
|
274
|
+
if (!proc) return;
|
|
275
|
+
const streams = [];
|
|
276
|
+
if (this._streamErr) streams.push(this._streamErr);
|
|
277
|
+
if (this._streamOut) streams.push(this._streamOut);
|
|
278
|
+
const streamCombined = combineStreams(streams);
|
|
279
|
+
const rl = readline.createInterface({ input: streamCombined });
|
|
280
|
+
for await (const chunk of rl) yield chunk.toString();
|
|
265
281
|
await this._processClosed;
|
|
266
|
-
|
|
282
|
+
proc.removeAllListeners();
|
|
267
283
|
if (this._thrownError) throw this._thrownError;
|
|
268
|
-
if (this._options?.throwOnError && this.exitCode !== 0 && this.exitCode !== void 0) throw new
|
|
284
|
+
if (this._options?.throwOnError && (this.exitCode !== 0 && this.exitCode !== void 0 || this.signalCode !== null)) throw new NonZeroExitError(this, void 0, this._command, this._args);
|
|
269
285
|
}
|
|
270
286
|
async _waitForOutput() {
|
|
271
|
-
const
|
|
272
|
-
if (!
|
|
273
|
-
const [
|
|
287
|
+
const proc = this._process;
|
|
288
|
+
if (!proc) throw new Error("No process was started");
|
|
289
|
+
const [stdout, stderr] = await Promise.all([this._streamOut ? readStream(this._streamOut) : "", this._streamErr ? readStream(this._streamErr) : ""]);
|
|
274
290
|
await this._processClosed;
|
|
275
|
-
const { stdin
|
|
276
|
-
if (
|
|
277
|
-
|
|
291
|
+
const { stdin } = this._options;
|
|
292
|
+
if (stdin && typeof stdin !== "string") await stdin;
|
|
293
|
+
proc.removeAllListeners();
|
|
278
294
|
if (this._thrownError) throw this._thrownError;
|
|
279
|
-
const
|
|
280
|
-
stderr
|
|
281
|
-
stdout
|
|
295
|
+
const result = {
|
|
296
|
+
stderr,
|
|
297
|
+
stdout,
|
|
282
298
|
exitCode: this.exitCode
|
|
283
299
|
};
|
|
284
|
-
if (this._options.throwOnError && this.exitCode !== 0 && this.exitCode !== void 0) throw new
|
|
285
|
-
return
|
|
300
|
+
if (this._options.throwOnError && (this.exitCode !== 0 && this.exitCode !== void 0 || this.signalCode !== null)) throw new NonZeroExitError(this, result, this._command, this._args);
|
|
301
|
+
return result;
|
|
286
302
|
}
|
|
287
|
-
then(
|
|
288
|
-
return this._waitForOutput().then(
|
|
303
|
+
then(onfulfilled, onrejected) {
|
|
304
|
+
return this._waitForOutput().then(onfulfilled, onrejected);
|
|
289
305
|
}
|
|
290
306
|
_streamOut;
|
|
291
307
|
_streamErr;
|
|
292
308
|
spawn() {
|
|
293
|
-
const
|
|
294
|
-
const
|
|
295
|
-
|
|
296
|
-
...
|
|
297
|
-
...r.nodeOptions
|
|
309
|
+
const options = this._options;
|
|
310
|
+
const nodeOptions = {
|
|
311
|
+
...defaultNodeOptions,
|
|
312
|
+
...options.nodeOptions
|
|
298
313
|
};
|
|
299
|
-
const
|
|
314
|
+
const cwd$1 = nodeOptions?.cwd ?? cwd();
|
|
315
|
+
const signals = [];
|
|
300
316
|
this._resetState();
|
|
301
|
-
if (
|
|
302
|
-
if (
|
|
303
|
-
if (
|
|
304
|
-
if (
|
|
305
|
-
|
|
306
|
-
const
|
|
307
|
-
const
|
|
308
|
-
if (
|
|
309
|
-
if (
|
|
310
|
-
this._process =
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
if (
|
|
314
|
-
const { stdin
|
|
315
|
-
if (typeof
|
|
316
|
-
else
|
|
317
|
+
if (options.timeout !== void 0) signals.push(AbortSignal.timeout(options.timeout));
|
|
318
|
+
if (options.signal !== void 0) signals.push(options.signal);
|
|
319
|
+
if (options.persist === true) nodeOptions.detached = true;
|
|
320
|
+
if (signals.length > 0) nodeOptions.signal = combineSignals(signals);
|
|
321
|
+
nodeOptions.env = computeEnv(cwd$1, nodeOptions.env, options.nodePath);
|
|
322
|
+
const crossResult = normalizeSpawnCommand(this._command, this._args, nodeOptions);
|
|
323
|
+
const handle = spawn(crossResult.command, crossResult.args, crossResult.options);
|
|
324
|
+
if (handle.stderr) this._streamErr = handle.stderr;
|
|
325
|
+
if (handle.stdout) this._streamOut = handle.stdout;
|
|
326
|
+
this._process = handle;
|
|
327
|
+
handle.once("error", this._onError);
|
|
328
|
+
handle.once("close", this._onClose);
|
|
329
|
+
if (handle.stdin) {
|
|
330
|
+
const { stdin } = options;
|
|
331
|
+
if (typeof stdin === "string") handle.stdin.end(stdin);
|
|
332
|
+
else stdin?.process?.stdout?.pipe(handle.stdin);
|
|
317
333
|
}
|
|
318
334
|
}
|
|
319
335
|
_resetState() {
|
|
320
336
|
this._aborted = false;
|
|
321
|
-
this._processClosed = new Promise((
|
|
322
|
-
this._resolveClose =
|
|
337
|
+
this._processClosed = new Promise((resolve) => {
|
|
338
|
+
this._resolveClose = resolve;
|
|
323
339
|
});
|
|
324
340
|
this._thrownError = void 0;
|
|
325
341
|
}
|
|
326
|
-
_onError = (
|
|
327
|
-
if (
|
|
342
|
+
_onError = (err) => {
|
|
343
|
+
if (err.name === "AbortError" && (!(err.cause instanceof Error) || err.cause.name !== "TimeoutError")) {
|
|
328
344
|
this._aborted = true;
|
|
329
345
|
return;
|
|
330
346
|
}
|
|
331
|
-
this._thrownError =
|
|
347
|
+
this._thrownError = err;
|
|
332
348
|
};
|
|
333
349
|
_onClose = () => {
|
|
334
350
|
if (this._resolveClose) this._resolveClose();
|
|
335
351
|
};
|
|
336
352
|
};
|
|
337
|
-
function
|
|
338
|
-
const
|
|
339
|
-
...
|
|
340
|
-
...
|
|
353
|
+
function xSync(command, args, options) {
|
|
354
|
+
const opts = {
|
|
355
|
+
...defaultSyncOptions,
|
|
356
|
+
...options
|
|
341
357
|
};
|
|
342
|
-
const
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
...a.nodeOptions
|
|
358
|
+
const nodeOptions = {
|
|
359
|
+
...defaultNodeOptions,
|
|
360
|
+
...opts.nodeOptions
|
|
346
361
|
};
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
const
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
const
|
|
354
|
-
const
|
|
355
|
-
const
|
|
356
|
-
const
|
|
357
|
-
|
|
358
|
-
|
|
362
|
+
const cwd$2 = nodeOptions?.cwd ?? cwd();
|
|
363
|
+
if (opts.timeout !== void 0) nodeOptions.timeout = opts.timeout;
|
|
364
|
+
nodeOptions.env = computeEnv(cwd$2, nodeOptions.env, opts.nodePath);
|
|
365
|
+
const crossResult = normalizeSpawnCommand(command, args ?? [], nodeOptions);
|
|
366
|
+
const spawnResult = spawnSync(crossResult.command, crossResult.args, crossResult.options);
|
|
367
|
+
if (spawnResult.error) throw spawnResult.error;
|
|
368
|
+
const stdout = spawnResult.stdout?.toString() ?? "";
|
|
369
|
+
const stderr = spawnResult.stderr?.toString() ?? "";
|
|
370
|
+
const exitCode = spawnResult.status ?? void 0;
|
|
371
|
+
const signalCode = spawnResult.signal ?? null;
|
|
372
|
+
const killed = signalCode !== null;
|
|
373
|
+
const result = {
|
|
374
|
+
stdout,
|
|
375
|
+
stderr,
|
|
359
376
|
get exitCode() {
|
|
360
|
-
return
|
|
377
|
+
return exitCode;
|
|
378
|
+
},
|
|
379
|
+
get signalCode() {
|
|
380
|
+
return signalCode;
|
|
361
381
|
},
|
|
362
382
|
get pid() {
|
|
363
|
-
return
|
|
383
|
+
return spawnResult.pid;
|
|
364
384
|
},
|
|
365
385
|
get killed() {
|
|
366
|
-
return
|
|
386
|
+
return killed;
|
|
367
387
|
},
|
|
368
388
|
*[Symbol.iterator]() {
|
|
369
|
-
for (const
|
|
370
|
-
if (!
|
|
371
|
-
const
|
|
372
|
-
if (
|
|
373
|
-
yield*
|
|
389
|
+
for (const text of [stdout, stderr]) {
|
|
390
|
+
if (!text) continue;
|
|
391
|
+
const lines = text.split(LINE_SEPARATOR_REGEX);
|
|
392
|
+
if (lines[lines.length - 1] === "") lines.pop();
|
|
393
|
+
yield* lines;
|
|
374
394
|
}
|
|
375
395
|
}
|
|
376
396
|
};
|
|
377
|
-
if (
|
|
378
|
-
|
|
397
|
+
if (opts.throwOnError && (exitCode !== 0 && exitCode !== void 0 || signalCode !== null)) throw new NonZeroExitError(result, {
|
|
398
|
+
stdout: result.stdout,
|
|
399
|
+
stderr: result.stderr,
|
|
400
|
+
exitCode: result.exitCode
|
|
401
|
+
}, command, args);
|
|
402
|
+
return result;
|
|
379
403
|
}
|
|
380
|
-
const
|
|
381
|
-
const
|
|
382
|
-
|
|
383
|
-
return
|
|
404
|
+
const x = (command, args, userOptions) => {
|
|
405
|
+
const proc = new ExecProcess(command, args, userOptions);
|
|
406
|
+
proc.spawn();
|
|
407
|
+
return proc;
|
|
384
408
|
};
|
|
385
|
-
const
|
|
386
|
-
const
|
|
409
|
+
const exec = x;
|
|
410
|
+
const execSync = xSync;
|
|
387
411
|
//#endregion
|
|
388
|
-
export {
|
|
412
|
+
export { ExecProcess, NonZeroExitError, exec, execSync, normalizeSpawnCommand, x, xSync };
|