@effijs/forge 1.0.0-alpha.2 → 1.0.0-alpha.3
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/package.json +1 -1
- package/src/Forge.js +1 -0
- package/src/cli/ForgeCLI.js +1 -0
- package/src/shims/repairInquirer.js +18 -0
- package/src/shims/strip-ansi.cjs +16 -0
package/package.json
CHANGED
package/src/Forge.js
CHANGED
package/src/cli/ForgeCLI.js
CHANGED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import Module from "node:module";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
|
|
5
|
+
const shim = fileURLToPath(new URL("./strip-ansi.cjs", import.meta.url));
|
|
6
|
+
const inquirerDir = `${path.sep}inquirer${path.sep}`;
|
|
7
|
+
const original = Module._resolveFilename;
|
|
8
|
+
|
|
9
|
+
if (!original.__forgeStripAnsi) {
|
|
10
|
+
function resolveFilename(request, parent, ...rest) {
|
|
11
|
+
if (request === "strip-ansi" && parent?.filename?.includes(inquirerDir)) {
|
|
12
|
+
return shim;
|
|
13
|
+
}
|
|
14
|
+
return original.call(this, request, parent, ...rest);
|
|
15
|
+
}
|
|
16
|
+
resolveFilename.__forgeStripAnsi = true;
|
|
17
|
+
Module._resolveFilename = resolveFilename;
|
|
18
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// inquirer 9's nested ora@5 does require("strip-ansi") and expects the v6 function.
|
|
4
|
+
// A hoisted strip-ansi v7 is ESM, so Node's require() returns a module namespace.
|
|
5
|
+
function ansiRegex() {
|
|
6
|
+
const pattern = [
|
|
7
|
+
"[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
|
|
8
|
+
"(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))",
|
|
9
|
+
].join("|");
|
|
10
|
+
return new RegExp(pattern, "g");
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
module.exports = function stripAnsi(string) {
|
|
14
|
+
if (typeof string !== "string") return string;
|
|
15
|
+
return string.replace(ansiRegex(), "");
|
|
16
|
+
};
|