@socketsecurity/cli-with-sentry 1.1.14 → 1.1.17
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/CHANGELOG.md +19 -0
- package/dist/cli.js +114 -32
- package/dist/cli.js.map +1 -1
- package/dist/constants.js +35 -37
- package/dist/constants.js.map +1 -1
- package/dist/shadow-npm-bin.js +6 -6
- package/dist/shadow-npm-bin.js.map +1 -1
- package/dist/shadow-pnpm-bin.js +3 -5
- package/dist/shadow-pnpm-bin.js.map +1 -1
- package/dist/shadow-yarn-bin.js +2 -2
- package/dist/shadow-yarn-bin.js.map +1 -1
- package/dist/tsconfig.dts.tsbuildinfo +1 -1
- package/dist/types/commands/fix/cmd-fix.d.mts.map +1 -1
- package/dist/types/commands/fix/coana-fix.d.mts.map +1 -1
- package/dist/types/commands/fix/env-helpers.d.mts +13 -0
- package/dist/types/commands/fix/env-helpers.d.mts.map +1 -1
- package/dist/types/commands/fix/handle-fix.d.mts.map +1 -1
- package/dist/types/commands/manifest/cmd-manifest-cdxgen.d.mts.map +1 -1
- package/dist/types/commands/manifest/run-cdxgen.d.mts.map +1 -1
- package/dist/types/commands/optimize/apply-optimization.d.mts.map +1 -1
- package/dist/types/commands/optimize/update-lockfile.d.mts.map +1 -1
- package/dist/types/commands/package/fetch-purls-shallow-score.d.mts.map +1 -1
- package/dist/types/commands/patch/cmd-patch.d.mts.map +1 -1
- package/dist/types/commands/patch/handle-patch.d.mts.map +1 -1
- package/dist/types/commands/threat-feed/cmd-threat-feed.d.mts.map +1 -1
- package/dist/types/commands/yarn/cmd-yarn.d.mts +1 -1
- package/dist/types/commands/yarn/cmd-yarn.d.mts.map +1 -1
- package/dist/types/constants.d.mts +15 -19
- package/dist/types/constants.d.mts.map +1 -1
- package/dist/types/shadow/pnpm/bin.d.mts.map +1 -1
- package/dist/types/utils/agent.d.mts.map +1 -1
- package/dist/types/utils/api.d.mts.map +1 -1
- package/dist/types/utils/dlx.d.mts.map +1 -1
- package/dist/types/utils/package-environment.d.mts.map +1 -1
- package/dist/types/utils/path-resolve.d.mts.map +1 -1
- package/dist/utils.js +70 -29
- package/dist/utils.js.map +1 -1
- package/dist/vendor.js +514 -517
- package/external/@socketsecurity/registry/external/@inquirer/confirm.js +45 -205
- package/external/@socketsecurity/registry/external/@inquirer/input.js +45 -205
- package/external/@socketsecurity/registry/external/@inquirer/password.js +181 -205
- package/external/@socketsecurity/registry/external/@inquirer/search.js +47 -207
- package/external/@socketsecurity/registry/external/@inquirer/select.js +183 -207
- package/external/@socketsecurity/registry/external/@npmcli/package-json/index.js +388 -2280
- package/external/@socketsecurity/registry/external/browserslist.js +11534 -567
- package/external/@socketsecurity/registry/external/cacache.js +2575 -4914
- package/external/@socketsecurity/registry/external/libnpmpack.js +64667 -166061
- package/external/@socketsecurity/registry/external/make-fetch-happen.js +384 -4044
- package/external/@socketsecurity/registry/external/normalize-package-data.js +30 -278
- package/external/@socketsecurity/registry/external/npm-package-arg.js +28 -9
- package/external/@socketsecurity/registry/external/pacote.js +46680 -66482
- package/external/@socketsecurity/registry/external/spdx-correct.js +19 -0
- package/external/@socketsecurity/registry/external/spdx-expression-parse.js +19 -0
- package/external/@socketsecurity/registry/lib/agent.js +390 -0
- package/external/@socketsecurity/registry/lib/arrays.js +31 -0
- package/external/@socketsecurity/registry/lib/bin.js +650 -0
- package/external/@socketsecurity/registry/lib/constants/bun-lock.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/bun-lockb.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/bun.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/dot-git-dir.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/dot-socket-dir.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/empty-value.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/env.js +17 -3
- package/external/@socketsecurity/registry/lib/constants/ext-yaml.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/ext-yml.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/index.js +20 -11
- package/external/@socketsecurity/registry/lib/constants/npm-exec-path.js +2 -2
- package/external/@socketsecurity/registry/lib/constants/npm-real-exec-path.js +1 -1
- package/external/@socketsecurity/registry/lib/constants/npm-shrinkwrap-json.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/pnpm-exec-path.js +5 -0
- package/external/@socketsecurity/registry/lib/constants/pnpm-lock-yaml.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/unknown-error.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/unknown-value.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/vlt-lock-json.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/vlt.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/yarn-berry.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/yarn-classic.js +3 -0
- package/external/@socketsecurity/registry/lib/constants/yarn-exec-path.js +5 -0
- package/external/@socketsecurity/registry/lib/constants/yarn.js +3 -0
- package/external/@socketsecurity/registry/lib/debug.js +53 -0
- package/external/@socketsecurity/registry/lib/env.js +18 -0
- package/external/@socketsecurity/registry/lib/fs.js +218 -2
- package/external/@socketsecurity/registry/lib/functions.js +5 -0
- package/external/@socketsecurity/registry/lib/globs.js +22 -1
- package/external/@socketsecurity/registry/lib/json.js +16 -0
- package/external/@socketsecurity/registry/lib/logger.js +157 -0
- package/external/@socketsecurity/registry/lib/objects.js +103 -0
- package/external/@socketsecurity/registry/lib/packages.js +88 -0
- package/external/@socketsecurity/registry/lib/path.js +51 -1
- package/external/@socketsecurity/registry/lib/promises.js +55 -0
- package/external/@socketsecurity/registry/lib/regexps.js +5 -0
- package/external/@socketsecurity/registry/lib/sorts.js +17 -0
- package/external/@socketsecurity/registry/lib/spawn.js +105 -7
- package/external/@socketsecurity/registry/lib/streams.js +26 -0
- package/external/@socketsecurity/registry/lib/strings.js +123 -9
- package/external/@socketsecurity/registry/lib/url.js +21 -0
- package/external/@socketsecurity/registry/lib/words.js +16 -0
- package/external/@socketsecurity/registry/manifest.json +5 -4
- package/package.json +5 -4
- package/external/@socketsecurity/registry/external/ansi-regex.js +0 -13
- package/external/@socketsecurity/registry/lib/constants/node-workspaces.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/parse-args-config.js +0 -14
- package/external/@socketsecurity/registry/lib/constants/skip-tests-by-ecosystem.js +0 -43
- package/external/@socketsecurity/registry/lib/constants/template-cjs-browser.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/template-cjs-esm.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/template-cjs.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/template-es-shim-constructor.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/template-es-shim-prototype-method.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/template-es-shim-static-method.js +0 -3
- package/external/@socketsecurity/registry/lib/constants/win32-ensure-tests-by-ecosystem.js +0 -3
- package/external/@socketsecurity/registry/lib/npm.js +0 -404
- /package/external/@socketsecurity/registry/lib/constants/{hidden-package-lock-json.js → dot-package-lock-json.js} +0 -0
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
const readline$1 = require('readline')
|
|
4
4
|
const async_hooks = require('async_hooks')
|
|
5
|
-
const require$$0$
|
|
5
|
+
const require$$0$2 = require('stream')
|
|
6
6
|
const util = require('util')
|
|
7
|
-
const require$$0$2 = require('tty')
|
|
8
7
|
const require$$0$1 = require('tty')
|
|
8
|
+
const require$$0 = require('tty')
|
|
9
9
|
const process$2 = require('process')
|
|
10
10
|
|
|
11
11
|
function _interopNamespaceDefault(e) {
|
|
@@ -207,45 +207,6 @@ function useEffect(cb, depArray) {
|
|
|
207
207
|
})
|
|
208
208
|
}
|
|
209
209
|
|
|
210
|
-
function getAugmentedNamespace(n) {
|
|
211
|
-
if (Object.prototype.hasOwnProperty.call(n, '__esModule')) {
|
|
212
|
-
return n
|
|
213
|
-
}
|
|
214
|
-
const f = n.default
|
|
215
|
-
if (typeof f == 'function') {
|
|
216
|
-
var a = function a() {
|
|
217
|
-
let isInstance = false
|
|
218
|
-
try {
|
|
219
|
-
isInstance = this instanceof a
|
|
220
|
-
} catch {}
|
|
221
|
-
if (isInstance) {
|
|
222
|
-
return Reflect.construct(f, arguments, this.constructor)
|
|
223
|
-
}
|
|
224
|
-
return f.apply(this, arguments)
|
|
225
|
-
}
|
|
226
|
-
a.prototype = f.prototype
|
|
227
|
-
} else {
|
|
228
|
-
a = {}
|
|
229
|
-
}
|
|
230
|
-
Object.defineProperty(a, '__esModule', { value: true })
|
|
231
|
-
Object.keys(n).forEach(function (k) {
|
|
232
|
-
const d = Object.getOwnPropertyDescriptor(n, k)
|
|
233
|
-
Object.defineProperty(
|
|
234
|
-
a,
|
|
235
|
-
k,
|
|
236
|
-
d.get
|
|
237
|
-
? d
|
|
238
|
-
: {
|
|
239
|
-
enumerable: true,
|
|
240
|
-
get: function () {
|
|
241
|
-
return n[k]
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
)
|
|
245
|
-
})
|
|
246
|
-
return a
|
|
247
|
-
}
|
|
248
|
-
|
|
249
210
|
let yoctocolorsCjs
|
|
250
211
|
let hasRequiredYoctocolorsCjs
|
|
251
212
|
function requireYoctocolorsCjs() {
|
|
@@ -253,7 +214,7 @@ function requireYoctocolorsCjs() {
|
|
|
253
214
|
return yoctocolorsCjs
|
|
254
215
|
}
|
|
255
216
|
hasRequiredYoctocolorsCjs = 1
|
|
256
|
-
const tty = require$$0
|
|
217
|
+
const tty = require$$0 // eslint-disable-line unicorn/prefer-module
|
|
257
218
|
|
|
258
219
|
// eslint-disable-next-line no-warning-comments
|
|
259
220
|
// TODO: Use a better method when it's added to Node.js (https://github.com/nodejs/node/pull/40240)
|
|
@@ -767,7 +728,7 @@ function requireCliWidth() {
|
|
|
767
728
|
const defaultOpts = {
|
|
768
729
|
defaultWidth: 0,
|
|
769
730
|
output: process.stdout,
|
|
770
|
-
tty: require$$0$
|
|
731
|
+
tty: require$$0$1
|
|
771
732
|
}
|
|
772
733
|
if (!options) {
|
|
773
734
|
return defaultOpts
|
|
@@ -805,23 +766,23 @@ const cliWidthExports = requireCliWidth()
|
|
|
805
766
|
|
|
806
767
|
const stringWidth = { exports: {} }
|
|
807
768
|
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
769
|
+
let ansiRegex
|
|
770
|
+
let hasRequiredAnsiRegex
|
|
771
|
+
function requireAnsiRegex() {
|
|
772
|
+
if (hasRequiredAnsiRegex) {
|
|
773
|
+
return ansiRegex
|
|
774
|
+
}
|
|
775
|
+
hasRequiredAnsiRegex = 1
|
|
776
|
+
ansiRegex = ({ onlyFirst = false } = {}) => {
|
|
777
|
+
const pattern = [
|
|
778
|
+
'[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)',
|
|
779
|
+
'(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))'
|
|
780
|
+
].join('|')
|
|
781
|
+
return new RegExp(pattern, onlyFirst ? undefined : 'g')
|
|
782
|
+
}
|
|
783
|
+
return ansiRegex
|
|
816
784
|
}
|
|
817
785
|
|
|
818
|
-
const ansiRegex$1 = /*#__PURE__*/ Object.freeze({
|
|
819
|
-
__proto__: null,
|
|
820
|
-
default: ansiRegex
|
|
821
|
-
})
|
|
822
|
-
|
|
823
|
-
const require$$0 = /*@__PURE__*/ getAugmentedNamespace(ansiRegex$1)
|
|
824
|
-
|
|
825
786
|
let stripAnsi
|
|
826
787
|
let hasRequiredStripAnsi
|
|
827
788
|
function requireStripAnsi() {
|
|
@@ -829,7 +790,7 @@ function requireStripAnsi() {
|
|
|
829
790
|
return stripAnsi
|
|
830
791
|
}
|
|
831
792
|
hasRequiredStripAnsi = 1
|
|
832
|
-
const ansiRegex =
|
|
793
|
+
const ansiRegex = requireAnsiRegex()
|
|
833
794
|
stripAnsi = string =>
|
|
834
795
|
typeof string === 'string' ? string.replace(ansiRegex(), '') : string
|
|
835
796
|
return stripAnsi
|
|
@@ -2447,7 +2408,7 @@ function requireLib() {
|
|
|
2447
2408
|
return lib
|
|
2448
2409
|
}
|
|
2449
2410
|
hasRequiredLib = 1
|
|
2450
|
-
const Stream = require$$0$
|
|
2411
|
+
const Stream = require$$0$2
|
|
2451
2412
|
class MuteStream extends Stream {
|
|
2452
2413
|
#isTTY = null
|
|
2453
2414
|
constructor(opts = {}) {
|
|
@@ -2892,147 +2853,28 @@ const {
|
|
|
2892
2853
|
processOk(process$1) ? new SignalExit(process$1) : new SignalExitFallback()
|
|
2893
2854
|
)
|
|
2894
2855
|
|
|
2895
|
-
const
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
const ESC = '\u001B['
|
|
2908
|
-
const OSC = '\u001B]'
|
|
2909
|
-
const BEL = '\u0007'
|
|
2910
|
-
const SEP = ';'
|
|
2911
|
-
const isTerminalApp = process.env.TERM_PROGRAM === 'Apple_Terminal'
|
|
2912
|
-
ansiEscapes.cursorTo = (x, y) => {
|
|
2913
|
-
if (typeof x !== 'number') {
|
|
2914
|
-
throw new TypeError('The `x` argument is required')
|
|
2915
|
-
}
|
|
2916
|
-
if (typeof y !== 'number') {
|
|
2917
|
-
return ESC + (x + 1) + 'G'
|
|
2918
|
-
}
|
|
2919
|
-
return ESC + (y + 1) + ';' + (x + 1) + 'H'
|
|
2920
|
-
}
|
|
2921
|
-
ansiEscapes.cursorMove = (x, y) => {
|
|
2922
|
-
if (typeof x !== 'number') {
|
|
2923
|
-
throw new TypeError('The `x` argument is required')
|
|
2924
|
-
}
|
|
2925
|
-
let ret = ''
|
|
2926
|
-
if (x < 0) {
|
|
2927
|
-
ret += ESC + -x + 'D'
|
|
2928
|
-
} else if (x > 0) {
|
|
2929
|
-
ret += ESC + x + 'C'
|
|
2930
|
-
}
|
|
2931
|
-
if (y < 0) {
|
|
2932
|
-
ret += ESC + -y + 'A'
|
|
2933
|
-
} else if (y > 0) {
|
|
2934
|
-
ret += ESC + y + 'B'
|
|
2935
|
-
}
|
|
2936
|
-
return ret
|
|
2937
|
-
}
|
|
2938
|
-
ansiEscapes.cursorUp = (count = 1) => ESC + count + 'A'
|
|
2939
|
-
ansiEscapes.cursorDown = (count = 1) => ESC + count + 'B'
|
|
2940
|
-
ansiEscapes.cursorForward = (count = 1) => ESC + count + 'C'
|
|
2941
|
-
ansiEscapes.cursorBackward = (count = 1) => ESC + count + 'D'
|
|
2942
|
-
ansiEscapes.cursorLeft = ESC + 'G'
|
|
2943
|
-
ansiEscapes.cursorSavePosition = isTerminalApp ? '\u001B7' : ESC + 's'
|
|
2944
|
-
ansiEscapes.cursorRestorePosition = isTerminalApp ? '\u001B8' : ESC + 'u'
|
|
2945
|
-
ansiEscapes.cursorGetPosition = ESC + '6n'
|
|
2946
|
-
ansiEscapes.cursorNextLine = ESC + 'E'
|
|
2947
|
-
ansiEscapes.cursorPrevLine = ESC + 'F'
|
|
2948
|
-
ansiEscapes.cursorHide = ESC + '?25l'
|
|
2949
|
-
ansiEscapes.cursorShow = ESC + '?25h'
|
|
2950
|
-
ansiEscapes.eraseLines = count => {
|
|
2951
|
-
let clear = ''
|
|
2952
|
-
for (let i = 0; i < count; i++) {
|
|
2953
|
-
clear +=
|
|
2954
|
-
ansiEscapes.eraseLine + (i < count - 1 ? ansiEscapes.cursorUp() : '')
|
|
2955
|
-
}
|
|
2956
|
-
if (count) {
|
|
2957
|
-
clear += ansiEscapes.cursorLeft
|
|
2958
|
-
}
|
|
2959
|
-
return clear
|
|
2960
|
-
}
|
|
2961
|
-
ansiEscapes.eraseEndLine = ESC + 'K'
|
|
2962
|
-
ansiEscapes.eraseStartLine = ESC + '1K'
|
|
2963
|
-
ansiEscapes.eraseLine = ESC + '2K'
|
|
2964
|
-
ansiEscapes.eraseDown = ESC + 'J'
|
|
2965
|
-
ansiEscapes.eraseUp = ESC + '1J'
|
|
2966
|
-
ansiEscapes.eraseScreen = ESC + '2J'
|
|
2967
|
-
ansiEscapes.scrollUp = ESC + 'S'
|
|
2968
|
-
ansiEscapes.scrollDown = ESC + 'T'
|
|
2969
|
-
ansiEscapes.clearScreen = '\u001Bc'
|
|
2970
|
-
ansiEscapes.clearTerminal =
|
|
2971
|
-
process.platform === 'win32'
|
|
2972
|
-
? `${ansiEscapes.eraseScreen}${ESC}0f`
|
|
2973
|
-
: // 1. Erases the screen (Only done in case `2` is not supported)
|
|
2974
|
-
// 2. Erases the whole screen including scrollback buffer
|
|
2975
|
-
// 3. Moves cursor to the top-left position
|
|
2976
|
-
// More info: https://www.real-world-systems.com/docs/ANSIcode.html
|
|
2977
|
-
`${ansiEscapes.eraseScreen}${ESC}3J${ESC}H`
|
|
2978
|
-
ansiEscapes.beep = BEL
|
|
2979
|
-
ansiEscapes.link = (text, url) => {
|
|
2980
|
-
return [OSC, '8', SEP, SEP, url, BEL, text, OSC, '8', SEP, SEP, BEL].join(
|
|
2981
|
-
''
|
|
2982
|
-
)
|
|
2983
|
-
}
|
|
2984
|
-
ansiEscapes.image = (buffer, options = {}) => {
|
|
2985
|
-
let ret = `${OSC}1337;File=inline=1`
|
|
2986
|
-
if (options.width) {
|
|
2987
|
-
ret += `;width=${options.width}`
|
|
2988
|
-
}
|
|
2989
|
-
if (options.height) {
|
|
2990
|
-
ret += `;height=${options.height}`
|
|
2991
|
-
}
|
|
2992
|
-
if (options.preserveAspectRatio === false) {
|
|
2993
|
-
ret += ';preserveAspectRatio=0'
|
|
2994
|
-
}
|
|
2995
|
-
return ret + ':' + buffer.toString('base64') + BEL
|
|
2996
|
-
}
|
|
2997
|
-
ansiEscapes.iTerm = {
|
|
2998
|
-
setCwd: (cwd = process.cwd()) => `${OSC}50;CurrentDir=${cwd}${BEL}`,
|
|
2999
|
-
annotation: (message, options = {}) => {
|
|
3000
|
-
let ret = `${OSC}1337;`
|
|
3001
|
-
const hasX = typeof options.x !== 'undefined'
|
|
3002
|
-
const hasY = typeof options.y !== 'undefined'
|
|
3003
|
-
if (
|
|
3004
|
-
(hasX || hasY) &&
|
|
3005
|
-
!(hasX && hasY && typeof options.length !== 'undefined')
|
|
3006
|
-
) {
|
|
3007
|
-
throw new Error(
|
|
3008
|
-
'`x`, `y` and `length` must be defined when `x` or `y` is defined'
|
|
3009
|
-
)
|
|
3010
|
-
}
|
|
3011
|
-
message = message.replace(/\|/g, '')
|
|
3012
|
-
ret += options.isHidden ? 'AddHiddenAnnotation=' : 'AddAnnotation='
|
|
3013
|
-
if (options.length > 0) {
|
|
3014
|
-
ret += (
|
|
3015
|
-
hasX
|
|
3016
|
-
? [message, options.length, options.x, options.y]
|
|
3017
|
-
: [options.length, message]
|
|
3018
|
-
).join('|')
|
|
3019
|
-
} else {
|
|
3020
|
-
ret += message
|
|
3021
|
-
}
|
|
3022
|
-
return ret + BEL
|
|
3023
|
-
}
|
|
3024
|
-
}
|
|
3025
|
-
})(ansiEscapes)
|
|
3026
|
-
return ansiEscapes.exports
|
|
2856
|
+
const ESC = '\u001B['
|
|
2857
|
+
/** Move cursor to first column */
|
|
2858
|
+
const cursorLeft = ESC + 'G'
|
|
2859
|
+
/** Show the cursor */
|
|
2860
|
+
const cursorShow = ESC + '?25h'
|
|
2861
|
+
/** Move cursor up by count rows */
|
|
2862
|
+
const cursorUp = (rows = 1) => (rows > 0 ? `${ESC}${rows}A` : '')
|
|
2863
|
+
/** Move cursor down by count rows */
|
|
2864
|
+
const cursorDown = (rows = 1) => (rows > 0 ? `${ESC}${rows}B` : '')
|
|
2865
|
+
/** Move cursor to position (x, y) */
|
|
2866
|
+
const cursorTo = (x, y) => {
|
|
2867
|
+
return `${ESC}${x + 1}G`
|
|
3027
2868
|
}
|
|
3028
|
-
|
|
3029
|
-
|
|
2869
|
+
const eraseLine = ESC + '2K'
|
|
2870
|
+
/** Erase the specified number of lines above the cursor */
|
|
2871
|
+
const eraseLines = lines =>
|
|
2872
|
+
lines > 0
|
|
2873
|
+
? (eraseLine + cursorUp(1)).repeat(lines - 1) + eraseLine + cursorLeft
|
|
2874
|
+
: ''
|
|
3030
2875
|
|
|
3031
2876
|
const height = content => content.split('\n').length
|
|
3032
2877
|
const lastLine = content => content.split('\n').pop() ?? ''
|
|
3033
|
-
function cursorDown(n) {
|
|
3034
|
-
return n > 0 ? ansiEscapesExports.cursorDown(n) : ''
|
|
3035
|
-
}
|
|
3036
2878
|
class ScreenManager {
|
|
3037
2879
|
// These variables are keeping information to allow correct prompt re-rendering
|
|
3038
2880
|
height = 0
|
|
@@ -3083,17 +2925,15 @@ class ScreenManager {
|
|
|
3083
2925
|
promptLineUpDiff + (bottomContent ? height(bottomContent) : 0)
|
|
3084
2926
|
// Return cursor to the input position (on top of the bottomContent)
|
|
3085
2927
|
if (bottomContentHeight > 0) {
|
|
3086
|
-
output +=
|
|
2928
|
+
output += cursorUp(bottomContentHeight)
|
|
3087
2929
|
}
|
|
3088
2930
|
// Return cursor to the initial left offset.
|
|
3089
|
-
output +=
|
|
2931
|
+
output += cursorTo(this.cursorPos.cols)
|
|
3090
2932
|
/**
|
|
3091
2933
|
* Render and store state for future re-rendering
|
|
3092
2934
|
*/
|
|
3093
2935
|
this.write(
|
|
3094
|
-
cursorDown(this.extraLinesUnderPrompt) +
|
|
3095
|
-
ansiEscapesExports.eraseLines(this.height) +
|
|
3096
|
-
output
|
|
2936
|
+
cursorDown(this.extraLinesUnderPrompt) + eraseLines(this.height) + output
|
|
3097
2937
|
)
|
|
3098
2938
|
this.extraLinesUnderPrompt = bottomContentHeight
|
|
3099
2939
|
this.height = height(output)
|
|
@@ -3101,15 +2941,15 @@ class ScreenManager {
|
|
|
3101
2941
|
checkCursorPos() {
|
|
3102
2942
|
const cursorPos = this.rl.getCursorPos()
|
|
3103
2943
|
if (cursorPos.cols !== this.cursorPos.cols) {
|
|
3104
|
-
this.write(
|
|
2944
|
+
this.write(cursorTo(cursorPos.cols))
|
|
3105
2945
|
this.cursorPos = cursorPos
|
|
3106
2946
|
}
|
|
3107
2947
|
}
|
|
3108
2948
|
done({ clearContent }) {
|
|
3109
2949
|
this.rl.setPrompt('')
|
|
3110
2950
|
let output = cursorDown(this.extraLinesUnderPrompt)
|
|
3111
|
-
output += clearContent ?
|
|
3112
|
-
output +=
|
|
2951
|
+
output += clearContent ? eraseLines(this.height) : '\n'
|
|
2952
|
+
output += cursorShow
|
|
3113
2953
|
this.write(output)
|
|
3114
2954
|
this.rl.close()
|
|
3115
2955
|
}
|
|
@@ -3271,6 +3111,142 @@ function createPrompt(view) {
|
|
|
3271
3111
|
return prompt
|
|
3272
3112
|
}
|
|
3273
3113
|
|
|
3114
|
+
const ansiEscapes = { exports: {} }
|
|
3115
|
+
|
|
3116
|
+
let hasRequiredAnsiEscapes
|
|
3117
|
+
function requireAnsiEscapes() {
|
|
3118
|
+
if (hasRequiredAnsiEscapes) {
|
|
3119
|
+
return ansiEscapes.exports
|
|
3120
|
+
}
|
|
3121
|
+
hasRequiredAnsiEscapes = 1
|
|
3122
|
+
;(function (module) {
|
|
3123
|
+
const ansiEscapes = module.exports
|
|
3124
|
+
// TODO: remove this in the next major version
|
|
3125
|
+
module.exports.default = ansiEscapes
|
|
3126
|
+
const ESC = '\u001B['
|
|
3127
|
+
const OSC = '\u001B]'
|
|
3128
|
+
const BEL = '\u0007'
|
|
3129
|
+
const SEP = ';'
|
|
3130
|
+
const isTerminalApp = process.env.TERM_PROGRAM === 'Apple_Terminal'
|
|
3131
|
+
ansiEscapes.cursorTo = (x, y) => {
|
|
3132
|
+
if (typeof x !== 'number') {
|
|
3133
|
+
throw new TypeError('The `x` argument is required')
|
|
3134
|
+
}
|
|
3135
|
+
if (typeof y !== 'number') {
|
|
3136
|
+
return ESC + (x + 1) + 'G'
|
|
3137
|
+
}
|
|
3138
|
+
return ESC + (y + 1) + ';' + (x + 1) + 'H'
|
|
3139
|
+
}
|
|
3140
|
+
ansiEscapes.cursorMove = (x, y) => {
|
|
3141
|
+
if (typeof x !== 'number') {
|
|
3142
|
+
throw new TypeError('The `x` argument is required')
|
|
3143
|
+
}
|
|
3144
|
+
let ret = ''
|
|
3145
|
+
if (x < 0) {
|
|
3146
|
+
ret += ESC + -x + 'D'
|
|
3147
|
+
} else if (x > 0) {
|
|
3148
|
+
ret += ESC + x + 'C'
|
|
3149
|
+
}
|
|
3150
|
+
if (y < 0) {
|
|
3151
|
+
ret += ESC + -y + 'A'
|
|
3152
|
+
} else if (y > 0) {
|
|
3153
|
+
ret += ESC + y + 'B'
|
|
3154
|
+
}
|
|
3155
|
+
return ret
|
|
3156
|
+
}
|
|
3157
|
+
ansiEscapes.cursorUp = (count = 1) => ESC + count + 'A'
|
|
3158
|
+
ansiEscapes.cursorDown = (count = 1) => ESC + count + 'B'
|
|
3159
|
+
ansiEscapes.cursorForward = (count = 1) => ESC + count + 'C'
|
|
3160
|
+
ansiEscapes.cursorBackward = (count = 1) => ESC + count + 'D'
|
|
3161
|
+
ansiEscapes.cursorLeft = ESC + 'G'
|
|
3162
|
+
ansiEscapes.cursorSavePosition = isTerminalApp ? '\u001B7' : ESC + 's'
|
|
3163
|
+
ansiEscapes.cursorRestorePosition = isTerminalApp ? '\u001B8' : ESC + 'u'
|
|
3164
|
+
ansiEscapes.cursorGetPosition = ESC + '6n'
|
|
3165
|
+
ansiEscapes.cursorNextLine = ESC + 'E'
|
|
3166
|
+
ansiEscapes.cursorPrevLine = ESC + 'F'
|
|
3167
|
+
ansiEscapes.cursorHide = ESC + '?25l'
|
|
3168
|
+
ansiEscapes.cursorShow = ESC + '?25h'
|
|
3169
|
+
ansiEscapes.eraseLines = count => {
|
|
3170
|
+
let clear = ''
|
|
3171
|
+
for (let i = 0; i < count; i++) {
|
|
3172
|
+
clear +=
|
|
3173
|
+
ansiEscapes.eraseLine + (i < count - 1 ? ansiEscapes.cursorUp() : '')
|
|
3174
|
+
}
|
|
3175
|
+
if (count) {
|
|
3176
|
+
clear += ansiEscapes.cursorLeft
|
|
3177
|
+
}
|
|
3178
|
+
return clear
|
|
3179
|
+
}
|
|
3180
|
+
ansiEscapes.eraseEndLine = ESC + 'K'
|
|
3181
|
+
ansiEscapes.eraseStartLine = ESC + '1K'
|
|
3182
|
+
ansiEscapes.eraseLine = ESC + '2K'
|
|
3183
|
+
ansiEscapes.eraseDown = ESC + 'J'
|
|
3184
|
+
ansiEscapes.eraseUp = ESC + '1J'
|
|
3185
|
+
ansiEscapes.eraseScreen = ESC + '2J'
|
|
3186
|
+
ansiEscapes.scrollUp = ESC + 'S'
|
|
3187
|
+
ansiEscapes.scrollDown = ESC + 'T'
|
|
3188
|
+
ansiEscapes.clearScreen = '\u001Bc'
|
|
3189
|
+
ansiEscapes.clearTerminal =
|
|
3190
|
+
process.platform === 'win32'
|
|
3191
|
+
? `${ansiEscapes.eraseScreen}${ESC}0f`
|
|
3192
|
+
: // 1. Erases the screen (Only done in case `2` is not supported)
|
|
3193
|
+
// 2. Erases the whole screen including scrollback buffer
|
|
3194
|
+
// 3. Moves cursor to the top-left position
|
|
3195
|
+
// More info: https://www.real-world-systems.com/docs/ANSIcode.html
|
|
3196
|
+
`${ansiEscapes.eraseScreen}${ESC}3J${ESC}H`
|
|
3197
|
+
ansiEscapes.beep = BEL
|
|
3198
|
+
ansiEscapes.link = (text, url) => {
|
|
3199
|
+
return [OSC, '8', SEP, SEP, url, BEL, text, OSC, '8', SEP, SEP, BEL].join(
|
|
3200
|
+
''
|
|
3201
|
+
)
|
|
3202
|
+
}
|
|
3203
|
+
ansiEscapes.image = (buffer, options = {}) => {
|
|
3204
|
+
let ret = `${OSC}1337;File=inline=1`
|
|
3205
|
+
if (options.width) {
|
|
3206
|
+
ret += `;width=${options.width}`
|
|
3207
|
+
}
|
|
3208
|
+
if (options.height) {
|
|
3209
|
+
ret += `;height=${options.height}`
|
|
3210
|
+
}
|
|
3211
|
+
if (options.preserveAspectRatio === false) {
|
|
3212
|
+
ret += ';preserveAspectRatio=0'
|
|
3213
|
+
}
|
|
3214
|
+
return ret + ':' + buffer.toString('base64') + BEL
|
|
3215
|
+
}
|
|
3216
|
+
ansiEscapes.iTerm = {
|
|
3217
|
+
setCwd: (cwd = process.cwd()) => `${OSC}50;CurrentDir=${cwd}${BEL}`,
|
|
3218
|
+
annotation: (message, options = {}) => {
|
|
3219
|
+
let ret = `${OSC}1337;`
|
|
3220
|
+
const hasX = typeof options.x !== 'undefined'
|
|
3221
|
+
const hasY = typeof options.y !== 'undefined'
|
|
3222
|
+
if (
|
|
3223
|
+
(hasX || hasY) &&
|
|
3224
|
+
!(hasX && hasY && typeof options.length !== 'undefined')
|
|
3225
|
+
) {
|
|
3226
|
+
throw new Error(
|
|
3227
|
+
'`x`, `y` and `length` must be defined when `x` or `y` is defined'
|
|
3228
|
+
)
|
|
3229
|
+
}
|
|
3230
|
+
message = message.replace(/\|/g, '')
|
|
3231
|
+
ret += options.isHidden ? 'AddHiddenAnnotation=' : 'AddAnnotation='
|
|
3232
|
+
if (options.length > 0) {
|
|
3233
|
+
ret += (
|
|
3234
|
+
hasX
|
|
3235
|
+
? [message, options.length, options.x, options.y]
|
|
3236
|
+
: [options.length, message]
|
|
3237
|
+
).join('|')
|
|
3238
|
+
} else {
|
|
3239
|
+
ret += message
|
|
3240
|
+
}
|
|
3241
|
+
return ret + BEL
|
|
3242
|
+
}
|
|
3243
|
+
}
|
|
3244
|
+
})(ansiEscapes)
|
|
3245
|
+
return ansiEscapes.exports
|
|
3246
|
+
}
|
|
3247
|
+
|
|
3248
|
+
const ansiEscapesExports = requireAnsiEscapes()
|
|
3249
|
+
|
|
3274
3250
|
const index = createPrompt((config, done) => {
|
|
3275
3251
|
const { validate = () => true } = config
|
|
3276
3252
|
const theme = makeTheme(config.theme)
|