ssqch 0.7.1 → 0.8.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/README.md +6 -4
- package/bin/ssqch.js +14 -48
- package/bundled/README.md +1247 -0
- package/bundled/completions/bash +840 -0
- package/bundled/completions/elvish +286 -0
- package/bundled/completions/fish +182 -0
- package/bundled/completions/powershell +318 -0
- package/bundled/completions/zsh +510 -0
- package/bundled/ssqch.d.ts +532 -0
- package/bundled/starter/engines/index.edge +11 -0
- package/bundled/starter/engines/index.ejs +11 -0
- package/bundled/starter/engines/index.hbs +11 -0
- package/bundled/starter/engines/index.liquid +11 -0
- package/bundled/starter/engines/layout.edge +35 -0
- package/bundled/starter/engines/layout.ejs +35 -0
- package/bundled/starter/engines/layout.hbs +35 -0
- package/bundled/starter/engines/layout.liquid +35 -0
- package/bundled/starter/gitignore +3 -0
- package/bundled/starter/jsconfig.json +11 -0
- package/bundled/starter/src/404.md +8 -0
- package/bundled/starter/src/_blueprints/posts.md +5 -0
- package/bundled/starter/src/_data/site.json +4 -0
- package/bundled/starter/src/_includes/layout.jinja +35 -0
- package/bundled/starter/src/index.jinja +11 -0
- package/bundled/starter/src/posts/i-know-what-i-saw.md +11 -0
- package/bundled/starter/src/posts/posts.json +4 -0
- package/bundled/starter/src/posts/raiders-of-the-lost-path.md +27 -0
- package/bundled/starter/src/posts/the-cache-of-the-wild.md +26 -0
- package/bundled/starter/src/posts/the-stump-has-moved.md +15 -0
- package/bundled/starter/src/posts/upon-further-review-a-stump.md +18 -0
- package/bundled/starter/ssqch.config.js +29 -0
- package/bundled/starter-docs/engines/edge/base.edge +41 -0
- package/bundled/starter-docs/engines/edge/containers/details.edge +5 -0
- package/bundled/starter-docs/engines/edge/containers/tab.edge +4 -0
- package/bundled/starter-docs/engines/edge/containers/tabs.edge +5 -0
- package/bundled/starter-docs/engines/edge/doc.edge +59 -0
- package/bundled/starter-docs/engines/edge/hooks/heading.edge +2 -0
- package/bundled/starter-docs/engines/ejs/base.ejs +41 -0
- package/bundled/starter-docs/engines/ejs/containers/details.ejs +5 -0
- package/bundled/starter-docs/engines/ejs/containers/tab.ejs +4 -0
- package/bundled/starter-docs/engines/ejs/containers/tabs.ejs +5 -0
- package/bundled/starter-docs/engines/ejs/doc.ejs +59 -0
- package/bundled/starter-docs/engines/ejs/hooks/heading.ejs +2 -0
- package/bundled/starter-docs/engines/hbs/base.hbs +41 -0
- package/bundled/starter-docs/engines/hbs/containers/details.hbs +5 -0
- package/bundled/starter-docs/engines/hbs/containers/tab.hbs +4 -0
- package/bundled/starter-docs/engines/hbs/containers/tabs.hbs +5 -0
- package/bundled/starter-docs/engines/hbs/doc.hbs +58 -0
- package/bundled/starter-docs/engines/hbs/hooks/heading.hbs +2 -0
- package/bundled/starter-docs/engines/liquid/base.liquid +41 -0
- package/bundled/starter-docs/engines/liquid/containers/details.liquid +5 -0
- package/bundled/starter-docs/engines/liquid/containers/tab.liquid +4 -0
- package/bundled/starter-docs/engines/liquid/containers/tabs.liquid +5 -0
- package/bundled/starter-docs/engines/liquid/doc.liquid +60 -0
- package/bundled/starter-docs/engines/liquid/hooks/heading.liquid +2 -0
- package/bundled/starter-docs/gitignore +4 -0
- package/bundled/starter-docs/src/404.md +12 -0
- package/bundled/starter-docs/src/_blueprints/docs.md +5 -0
- package/bundled/starter-docs/src/_data/nav.yml +10 -0
- package/bundled/starter-docs/src/_data/site.json +5 -0
- package/bundled/starter-docs/src/_includes/base.jinja +41 -0
- package/bundled/starter-docs/src/_includes/containers/details.jinja +5 -0
- package/bundled/starter-docs/src/_includes/containers/tab.jinja +4 -0
- package/bundled/starter-docs/src/_includes/containers/tabs.jinja +5 -0
- package/bundled/starter-docs/src/_includes/doc.jinja +59 -0
- package/bundled/starter-docs/src/_includes/hooks/heading.jinja +2 -0
- package/bundled/starter-docs/src/assets/docs.css +257 -0
- package/bundled/starter-docs/src/assets/docs.js +67 -0
- package/bundled/starter-docs/src/docs/docs.json +1 -0
- package/bundled/starter-docs/src/docs/guides/deploying.md +77 -0
- package/bundled/starter-docs/src/docs/guides/writing.md +65 -0
- package/bundled/starter-docs/src/docs/index.md +29 -0
- package/bundled/starter-docs/src/docs/install.md +42 -0
- package/bundled/starter-docs/src/index.md +13 -0
- package/bundled/starter-docs/ssqch.config.js +40 -0
- package/bundled/trailheads/from-component-frameworks.md +116 -0
- package/bundled/trailheads/from-docusaurus.md +55 -0
- package/bundled/trailheads/from-eleventy.md +140 -0
- package/bundled/trailheads/from-hexo.md +92 -0
- package/bundled/trailheads/from-mkdocs.md +45 -0
- package/bundled/trailheads/from-zola.md +71 -0
- package/lib/assets.js +235 -3
- package/lib/chunk-37KSIVNY.js +29 -0
- package/lib/chunk-3GYLOC6Y.js +1017 -0
- package/lib/chunk-3NYSSA2C.js +22 -0
- package/lib/chunk-3PHCFZEU.js +209 -0
- package/lib/chunk-4Q6WMTER.js +32 -0
- package/lib/chunk-6XYSFG6V.js +4423 -0
- package/lib/chunk-6XYSFG6V.js.LEGAL.txt +41 -0
- package/lib/chunk-AD3HAW3W.js +10 -0
- package/lib/chunk-AMBFWPZ4.js +118 -0
- package/lib/chunk-BOBPVAX2.js +37088 -0
- package/lib/chunk-BOBPVAX2.js.LEGAL.txt +27 -0
- package/lib/chunk-BRK4MXXO.js +565 -0
- package/lib/chunk-C35KIPAR.js +247 -0
- package/lib/chunk-CDEPYU7W.js +25 -0
- package/lib/chunk-CMUWRPSQ.js +113 -0
- package/lib/chunk-DDV6JEC2.js +46 -0
- package/lib/chunk-DHHQKW4F.js +71 -0
- package/lib/chunk-EIT4ZDT4.js +1485 -0
- package/lib/chunk-EZZUUPI4.js +20 -0
- package/lib/chunk-F65YUXZ7.js +334 -0
- package/lib/chunk-FVZ5JBRI.js +115 -0
- package/lib/chunk-FYGE634X.js +44 -0
- package/lib/chunk-GOE4ZSAB.js +75 -0
- package/lib/chunk-GSKVRAHF.js +44 -0
- package/lib/chunk-HR2RU2LY.js +999 -0
- package/lib/chunk-HXCLCXRT.js +20 -0
- package/lib/chunk-I3PS26CI.js +48 -0
- package/lib/chunk-IAFM5ITE.js +11 -0
- package/lib/chunk-IRHRK7XB.js +54 -0
- package/lib/chunk-JRT7TQQP.js +57 -0
- package/lib/chunk-JSPSMIJ2.js +217 -0
- package/lib/chunk-KBGE5MCY.js +175 -0
- package/lib/chunk-N5QTGQ5N.js +207 -0
- package/lib/chunk-NKXEPHRZ.js +136 -0
- package/lib/chunk-NUKCUDC4.js +146 -0
- package/lib/chunk-RI2L3VGO.js +376 -0
- package/lib/chunk-TDGBQNGW.js +251 -0
- package/lib/chunk-TN6EEDX2.js +3935 -0
- package/lib/chunk-TWCVHOKO.js +1229 -0
- package/lib/chunk-UGEGUUBT.js +29 -0
- package/lib/chunk-UU43WIZG.js +29 -0
- package/lib/chunk-VJWQSYEG.js +119 -0
- package/lib/chunk-VVPZ5PDP.js +160 -0
- package/lib/chunk-WMOVCQO6.js +1287 -0
- package/lib/chunk-WP3RPVUM.js +211 -0
- package/lib/chunk-YSH2NMIE.js +502 -0
- package/lib/cli.js +540 -0
- package/lib/elements.js +180 -3
- package/lib/image.js +27 -3
- package/lib/links.js +464 -3
- package/lib/minify.js +69 -3
- package/lib/redirects.js +152 -3
- package/lib/rss.js +139 -3
- package/lib/sass.js +221 -3
- package/lib/sitemap.js +88 -3
- package/lib/ssqch.js +28 -0
- package/package.json +83 -80
- package/src/serve/live.js +174 -0
- package/src/serve/not-found.html +31 -0
- package/types/globals.d.ts +3 -2
- package/types/image.d.ts +7 -3
- package/types/index.d.ts +18 -5
- package/types/links.d.ts +1 -1
- package/types/minify.d.ts +1 -1
- package/types/rss.d.ts +1 -1
- package/types/sass.d.ts +1 -1
- package/wasm/markdown.wasm +0 -0
- package/wasm/minify.wasm +0 -0
- package/wasm/sass.wasm +0 -0
- package/lib/index.js +0 -3
- package/platforms.json +0 -6
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { createRequire as __ssqchCreateRequire } from "node:module";
|
|
2
|
+
const require = __ssqchCreateRequire(import.meta.url);
|
|
3
|
+
|
|
4
|
+
// src/plugin-files.ts
|
|
5
|
+
var read = /* @__PURE__ */ new WeakMap();
|
|
6
|
+
function startReading(config, plugin) {
|
|
7
|
+
let byPlugin = read.get(config);
|
|
8
|
+
if (!byPlugin) read.set(config, byPlugin = /* @__PURE__ */ new Map());
|
|
9
|
+
const files = /* @__PURE__ */ new Set();
|
|
10
|
+
byPlugin.set(plugin, files);
|
|
11
|
+
return files;
|
|
12
|
+
}
|
|
13
|
+
function filesRead(config) {
|
|
14
|
+
const all = /* @__PURE__ */ new Set();
|
|
15
|
+
for (const files of read.get(config)?.values() ?? []) for (const file of files) all.add(file);
|
|
16
|
+
return [...all].sort();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export {
|
|
20
|
+
startReading,
|
|
21
|
+
filesRead
|
|
22
|
+
};
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { createRequire as __ssqchCreateRequire } from "node:module";
|
|
2
|
+
const require = __ssqchCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
BUDGETS
|
|
5
|
+
} from "./chunk-IRHRK7XB.js";
|
|
6
|
+
import {
|
|
7
|
+
bytes,
|
|
8
|
+
count,
|
|
9
|
+
fixed
|
|
10
|
+
} from "./chunk-NKXEPHRZ.js";
|
|
11
|
+
import {
|
|
12
|
+
padEnd,
|
|
13
|
+
padStart
|
|
14
|
+
} from "./chunk-CMUWRPSQ.js";
|
|
15
|
+
import {
|
|
16
|
+
BuildError,
|
|
17
|
+
bail,
|
|
18
|
+
warning
|
|
19
|
+
} from "./chunk-6XYSFG6V.js";
|
|
20
|
+
import {
|
|
21
|
+
compareText,
|
|
22
|
+
realPath
|
|
23
|
+
} from "./chunk-VJWQSYEG.js";
|
|
24
|
+
|
|
25
|
+
// src/footprint.ts
|
|
26
|
+
import fs from "node:fs";
|
|
27
|
+
import path from "node:path";
|
|
28
|
+
var KINDS = [
|
|
29
|
+
["Pages", ["html", "htm"]],
|
|
30
|
+
["Images", ["avif", "webp", "jpg", "jpeg", "png", "gif", "svg", "ico", "bmp", "tif", "tiff", "jxl"]],
|
|
31
|
+
["CSS", ["css"]],
|
|
32
|
+
["JavaScript", ["js", "mjs", "cjs", "wasm"]],
|
|
33
|
+
["Fonts", ["woff2", "woff", "ttf", "otf", "eot"]],
|
|
34
|
+
["Media", ["mp4", "webm", "mov", "mp3", "ogg", "wav", "m4a", "flac"]],
|
|
35
|
+
["Documents", ["pdf", "zip", "epub"]],
|
|
36
|
+
["Data and feeds", ["xml", "json", "txt", "webmanifest", "csv", "map", "rss", "atom"]]
|
|
37
|
+
];
|
|
38
|
+
var OTHER = "Other";
|
|
39
|
+
var KIND_OF_EXTENSION = new Map(KINDS.flatMap(([name, exts]) => exts.map((ext) => [ext, name])));
|
|
40
|
+
function kindOf(file) {
|
|
41
|
+
const dot = file.lastIndexOf(".");
|
|
42
|
+
return dot === -1 ? OTHER : KIND_OF_EXTENSION.get(asciiLower(file.slice(dot + 1))) ?? OTHER;
|
|
43
|
+
}
|
|
44
|
+
var asciiLower = (text) => text.replace(/[A-Z]/g, (c) => c.toLowerCase());
|
|
45
|
+
function urlOf(file) {
|
|
46
|
+
if (file.endsWith("index.html")) {
|
|
47
|
+
const dir = file.slice(0, -10);
|
|
48
|
+
if (dir === "" || dir.endsWith("/")) return `/${dir}`;
|
|
49
|
+
}
|
|
50
|
+
return `/${file}`;
|
|
51
|
+
}
|
|
52
|
+
var AT_ONCE = 32;
|
|
53
|
+
function buildFiles(dir, sizes) {
|
|
54
|
+
const out = [];
|
|
55
|
+
const folders = [{ path: dir, rel: "", real: realPath(dir), parent: void 0 }];
|
|
56
|
+
const files = [];
|
|
57
|
+
let active = 0;
|
|
58
|
+
const failures = [];
|
|
59
|
+
return new Promise((resolve, reject) => {
|
|
60
|
+
const fail = (at, detail) => {
|
|
61
|
+
failures.push([at, `reading ${dir}: ${detail}`]);
|
|
62
|
+
};
|
|
63
|
+
const inside = (folder, name) => folder.parent === void 0 && /[\\/]$/.test(folder.path) ? folder.path + name : folder.path + path.sep + name;
|
|
64
|
+
const done = () => {
|
|
65
|
+
active--;
|
|
66
|
+
pump();
|
|
67
|
+
};
|
|
68
|
+
const read = (folder) => {
|
|
69
|
+
fs.readdir(folder.path, { withFileTypes: true }, (e, entries) => {
|
|
70
|
+
if (e) fail(folder.path, `IO error for operation on ${folder.path}: ${e.message}`);
|
|
71
|
+
else for (const entry of entries) {
|
|
72
|
+
const file = inside(folder, entry.name);
|
|
73
|
+
const rel = folder.rel === "" ? entry.name : `${folder.rel}/${entry.name}`;
|
|
74
|
+
let isDir = entry.isDirectory(), isFile = entry.isFile();
|
|
75
|
+
if (entry.isSymbolicLink()) {
|
|
76
|
+
const stat = fs.statSync(file, { throwIfNoEntry: false });
|
|
77
|
+
if (!stat) {
|
|
78
|
+
fail(file, `IO error for operation on ${file}: No such file or directory (os error 2): No such file or directory (os error 2)`);
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
[isDir, isFile] = [stat.isDirectory(), stat.isFile()];
|
|
82
|
+
if (isDir) {
|
|
83
|
+
const real = realPath(file);
|
|
84
|
+
let loop = folder;
|
|
85
|
+
while (loop && loop.real !== real) loop = loop.parent;
|
|
86
|
+
if (loop) {
|
|
87
|
+
fail(file, `File system loop found: ${file} points to an ancestor ${loop.path}`);
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
folders.push({ path: file, rel, real, parent: folder });
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (isDir) folders.push({ path: file, rel, real: folder.real + path.sep + entry.name, parent: folder });
|
|
95
|
+
else if (isFile && entry.name !== ".DS_Store") {
|
|
96
|
+
if (sizes) files.push([file, rel]);
|
|
97
|
+
else out.push([rel, 0]);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
done();
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
const size = (file, rel) => {
|
|
104
|
+
fs.stat(file, (e, stat) => {
|
|
105
|
+
if (e) fail(file, `IO error for operation on ${file}: ${e.message}`);
|
|
106
|
+
else out.push([rel, stat.size]);
|
|
107
|
+
done();
|
|
108
|
+
});
|
|
109
|
+
};
|
|
110
|
+
const pump = () => {
|
|
111
|
+
while (active < AT_ONCE && (folders.length || files.length)) {
|
|
112
|
+
active++;
|
|
113
|
+
if (folders.length) read(folders.pop());
|
|
114
|
+
else size(...files.pop());
|
|
115
|
+
}
|
|
116
|
+
if (active === 0) {
|
|
117
|
+
if (failures.length) reject(new BuildError(failures.sort((a, b) => compareText(a[0], b[0]))[0][1]));
|
|
118
|
+
else resolve(out);
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
pump();
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
async function measure(dir) {
|
|
125
|
+
if (!(fs.statSync(dir, { throwIfNoEntry: false })?.isDirectory() ?? false)) bail(`${dir} isn't a folder; build the site first, or give \`ssqch footprint\` a build folder (\`ssqch footprint dist\`)`);
|
|
126
|
+
const pages = [];
|
|
127
|
+
const others = [];
|
|
128
|
+
for (const [file, size] of await buildFiles(dir, true)) (kindOf(file) === "Pages" ? pages : others).push({ path: file, bytes: size });
|
|
129
|
+
const heaviest = (a, b) => b.bytes - a.bytes || compareText(a.path, b.path);
|
|
130
|
+
pages.sort(heaviest);
|
|
131
|
+
others.sort(heaviest);
|
|
132
|
+
const kinds = [...KINDS.map(([name]) => name), OTHER].map((name) => ({ name, files: 0, bytes: 0 }));
|
|
133
|
+
for (const file of [...pages, ...others]) {
|
|
134
|
+
const kind = kinds.find((k) => k.name === kindOf(file.path));
|
|
135
|
+
kind.files += 1;
|
|
136
|
+
kind.bytes += file.bytes;
|
|
137
|
+
}
|
|
138
|
+
const used = kinds.filter((k) => k.files > 0);
|
|
139
|
+
return { files: pages.length + others.length, bytes: used.reduce((sum, k) => sum + k.bytes, 0), kinds: used, pages, others };
|
|
140
|
+
}
|
|
141
|
+
function share(part, total) {
|
|
142
|
+
if (total === 0) return "0%";
|
|
143
|
+
const percent = part * 100 / total;
|
|
144
|
+
return percent > 0 && percent < 1 ? "<1%" : `${fixed(percent, 0)}%`;
|
|
145
|
+
}
|
|
146
|
+
function footprintText(footprint, shown, top) {
|
|
147
|
+
let out = `Footprint of ${shown}: ${count(footprint.files)} file${footprint.files === 1 ? "" : "s"}, ${bytes(footprint.bytes)}
|
|
148
|
+
`;
|
|
149
|
+
if (footprint.files === 0) return `${out}Nothing sighted: the folder is empty.
|
|
150
|
+
`;
|
|
151
|
+
const rows = footprint.kinds.map((k) => [k.name, count(k.files), k.files === 1 ? "file" : "files", bytes(k.bytes), share(k.bytes, footprint.bytes)]);
|
|
152
|
+
const width = (i) => Math.max(0, ...rows.map((r) => [...r[i]].length));
|
|
153
|
+
const [w0, w1, w2, w3] = [width(0), width(1), width(2), width(3)];
|
|
154
|
+
for (const [name, files, word, size, part] of rows) out += ` ${padEnd(name, w0)} ${padStart(files, w1)} ${padEnd(word, w2)} ${padStart(size, w3)} ${part}
|
|
155
|
+
`;
|
|
156
|
+
const list = (title, files, name) => {
|
|
157
|
+
if (!files.length || top === 0) return;
|
|
158
|
+
out += `
|
|
159
|
+
${title}
|
|
160
|
+
`;
|
|
161
|
+
const listed = files.slice(0, top).map((f) => [bytes(f.bytes), name(f)]);
|
|
162
|
+
const w = Math.max(0, ...listed.map(([size]) => [...size].length));
|
|
163
|
+
for (const [size, file] of listed) out += ` ${padStart(size, w)} ${file}
|
|
164
|
+
`;
|
|
165
|
+
};
|
|
166
|
+
list("Largest footprints: pages", footprint.pages, (f) => urlOf(f.path));
|
|
167
|
+
list("Largest footprints: other files", footprint.others, (f) => `/${f.path}`);
|
|
168
|
+
return out;
|
|
169
|
+
}
|
|
170
|
+
function footprintJson(footprint, output, top) {
|
|
171
|
+
const files = (list, page) => list.slice(0, top).map((f) => page ? { path: f.path, bytes: f.bytes, url: urlOf(f.path) } : { path: f.path, bytes: f.bytes, kind: kindOf(f.path) });
|
|
172
|
+
return {
|
|
173
|
+
schemaVersion: 1,
|
|
174
|
+
output,
|
|
175
|
+
files: footprint.files,
|
|
176
|
+
bytes: footprint.bytes,
|
|
177
|
+
kinds: footprint.kinds.map((k) => ({ kind: k.name, files: k.files, bytes: k.bytes })),
|
|
178
|
+
largest: { pages: files(footprint.pages, true), files: files(footprint.others, false) }
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
function overBudget(footprint, budgets) {
|
|
182
|
+
const out = [];
|
|
183
|
+
for (const [name, limit] of budgets) {
|
|
184
|
+
if (name === "total") {
|
|
185
|
+
if (footprint.bytes > limit) out.push(warning("over-budget", `the build is ${bytes(footprint.bytes)}, over its total budget of ${bytes(limit)}`));
|
|
186
|
+
continue;
|
|
187
|
+
}
|
|
188
|
+
const kind = BUDGETS.find(([key]) => key === name)?.[1];
|
|
189
|
+
if (kind === void 0) continue;
|
|
190
|
+
const page = kind === "Pages";
|
|
191
|
+
const over = [...footprint.pages, ...footprint.others].filter((f) => kindOf(f.path) === kind && f.bytes > limit);
|
|
192
|
+
const shown = (f) => `${page ? urlOf(f.path) : `/${f.path}`} (${bytes(f.bytes)})`;
|
|
193
|
+
const what = page ? "page" : "file";
|
|
194
|
+
if (!over.length) continue;
|
|
195
|
+
const message = over.length === 1 ? `${shown(over[0])} is over the ${name} budget of ${bytes(limit)}` : `${over.length} ${what}s are over the ${name} budget of ${bytes(limit)}: ${over.slice(0, 5).map(shown).join(", ")}${over.length > 5 ? ", ..." : ""}`;
|
|
196
|
+
out.push(warning("over-budget", message));
|
|
197
|
+
}
|
|
198
|
+
return out;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export {
|
|
202
|
+
kindOf,
|
|
203
|
+
urlOf,
|
|
204
|
+
buildFiles,
|
|
205
|
+
measure,
|
|
206
|
+
footprintText,
|
|
207
|
+
footprintJson,
|
|
208
|
+
overBudget
|
|
209
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { createRequire as __ssqchCreateRequire } from "node:module";
|
|
2
|
+
const require = __ssqchCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
isDir
|
|
5
|
+
} from "./chunk-VJWQSYEG.js";
|
|
6
|
+
|
|
7
|
+
// src/command-line.ts
|
|
8
|
+
import os from "node:os";
|
|
9
|
+
import path from "node:path";
|
|
10
|
+
function toolPath(root) {
|
|
11
|
+
const bins = [];
|
|
12
|
+
for (let dir = path.resolve(root); ; dir = path.dirname(dir)) {
|
|
13
|
+
const bin = path.join(dir, "node_modules", ".bin");
|
|
14
|
+
if (isDir(bin)) bins.push(bin);
|
|
15
|
+
if (path.dirname(dir) === dir) break;
|
|
16
|
+
}
|
|
17
|
+
const rest = (process.env.PATH ?? process.env.Path ?? "").split(path.delimiter).filter(Boolean);
|
|
18
|
+
return [...bins, ...rest].join(path.delimiter);
|
|
19
|
+
}
|
|
20
|
+
function commandLine(command, root, vars) {
|
|
21
|
+
const env = { ...process.env, ...vars };
|
|
22
|
+
if (env.UV_THREADPOOL_SIZE === String(os.availableParallelism() + 4)) delete env.UV_THREADPOOL_SIZE;
|
|
23
|
+
for (const key of Object.keys(env)) if (key.toUpperCase() === "PATH") delete env[key];
|
|
24
|
+
env.PATH = toolPath(root);
|
|
25
|
+
if (process.platform !== "win32") return { file: "/bin/sh", args: ["-c", command], options: { cwd: root, env } };
|
|
26
|
+
return { file: process.env.ComSpec ?? "cmd.exe", args: ["/s", "/c", `"${command}"`], options: { cwd: root, env, windowsVerbatimArguments: true } };
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export {
|
|
30
|
+
toolPath,
|
|
31
|
+
commandLine
|
|
32
|
+
};
|