pull-request-split-advisor 3.1.2
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/LICENSE +52 -0
- package/README.md +168 -0
- package/dist/ai/config-wizard.js +282 -0
- package/dist/ai/enricher.js +290 -0
- package/dist/ai/prompts.js +231 -0
- package/dist/ai/provider.js +265 -0
- package/dist/cli.js +442 -0
- package/dist/config/config.js +315 -0
- package/dist/config/default-config.js +223 -0
- package/dist/core/blocks.js +145 -0
- package/dist/core/commit-planner.js +273 -0
- package/dist/core/dependency.js +284 -0
- package/dist/core/file-stats.js +341 -0
- package/dist/core/history.js +72 -0
- package/dist/core/planner.js +25 -0
- package/dist/core/scoring.js +166 -0
- package/dist/core/strategy.js +486 -0
- package/dist/git/branch-naming.js +120 -0
- package/dist/git/executor.js +378 -0
- package/dist/git/git.js +239 -0
- package/dist/output/report-styles.generated.js +10 -0
- package/dist/output/report.js +726 -0
- package/dist/output/ui.js +417 -0
- package/dist/shared/constants.js +59 -0
- package/dist/shared/types.js +7 -0
- package/dist/shared/utils.js +73 -0
- package/node_modules/@colors/colors/LICENSE +26 -0
- package/node_modules/@colors/colors/README.md +219 -0
- package/node_modules/@colors/colors/examples/normal-usage.js +83 -0
- package/node_modules/@colors/colors/examples/safe-string.js +80 -0
- package/node_modules/@colors/colors/index.d.ts +136 -0
- package/node_modules/@colors/colors/lib/colors.js +211 -0
- package/node_modules/@colors/colors/lib/custom/trap.js +46 -0
- package/node_modules/@colors/colors/lib/custom/zalgo.js +110 -0
- package/node_modules/@colors/colors/lib/extendStringPrototype.js +110 -0
- package/node_modules/@colors/colors/lib/index.js +13 -0
- package/node_modules/@colors/colors/lib/maps/america.js +10 -0
- package/node_modules/@colors/colors/lib/maps/rainbow.js +12 -0
- package/node_modules/@colors/colors/lib/maps/random.js +11 -0
- package/node_modules/@colors/colors/lib/maps/zebra.js +5 -0
- package/node_modules/@colors/colors/lib/styles.js +95 -0
- package/node_modules/@colors/colors/lib/system/has-flag.js +35 -0
- package/node_modules/@colors/colors/lib/system/supports-colors.js +151 -0
- package/node_modules/@colors/colors/package.json +45 -0
- package/node_modules/@colors/colors/safe.d.ts +48 -0
- package/node_modules/@colors/colors/safe.js +10 -0
- package/node_modules/@colors/colors/themes/generic-logging.js +12 -0
- package/node_modules/ansi-align/LICENSE +13 -0
- package/node_modules/ansi-align/README.md +80 -0
- package/node_modules/ansi-align/index.js +61 -0
- package/node_modules/ansi-align/node_modules/ansi-regex/index.d.ts +37 -0
- package/node_modules/ansi-align/node_modules/ansi-regex/index.js +10 -0
- package/node_modules/ansi-align/node_modules/ansi-regex/license +9 -0
- package/node_modules/ansi-align/node_modules/ansi-regex/package.json +55 -0
- package/node_modules/ansi-align/node_modules/ansi-regex/readme.md +78 -0
- package/node_modules/ansi-align/node_modules/emoji-regex/LICENSE-MIT.txt +20 -0
- package/node_modules/ansi-align/node_modules/emoji-regex/README.md +73 -0
- package/node_modules/ansi-align/node_modules/emoji-regex/es2015/index.js +6 -0
- package/node_modules/ansi-align/node_modules/emoji-regex/es2015/text.js +6 -0
- package/node_modules/ansi-align/node_modules/emoji-regex/index.d.ts +23 -0
- package/node_modules/ansi-align/node_modules/emoji-regex/index.js +6 -0
- package/node_modules/ansi-align/node_modules/emoji-regex/package.json +50 -0
- package/node_modules/ansi-align/node_modules/emoji-regex/text.js +6 -0
- package/node_modules/ansi-align/node_modules/string-width/index.d.ts +29 -0
- package/node_modules/ansi-align/node_modules/string-width/index.js +47 -0
- package/node_modules/ansi-align/node_modules/string-width/license +9 -0
- package/node_modules/ansi-align/node_modules/string-width/package.json +56 -0
- package/node_modules/ansi-align/node_modules/string-width/readme.md +50 -0
- package/node_modules/ansi-align/node_modules/strip-ansi/index.d.ts +17 -0
- package/node_modules/ansi-align/node_modules/strip-ansi/index.js +4 -0
- package/node_modules/ansi-align/node_modules/strip-ansi/license +9 -0
- package/node_modules/ansi-align/node_modules/strip-ansi/package.json +54 -0
- package/node_modules/ansi-align/node_modules/strip-ansi/readme.md +46 -0
- package/node_modules/ansi-align/package.json +43 -0
- package/node_modules/ansi-regex/index.d.ts +33 -0
- package/node_modules/ansi-regex/index.js +14 -0
- package/node_modules/ansi-regex/license +9 -0
- package/node_modules/ansi-regex/package.json +61 -0
- package/node_modules/ansi-regex/readme.md +66 -0
- package/node_modules/ansi-styles/index.d.ts +236 -0
- package/node_modules/ansi-styles/index.js +223 -0
- package/node_modules/ansi-styles/license +9 -0
- package/node_modules/ansi-styles/package.json +54 -0
- package/node_modules/ansi-styles/readme.md +173 -0
- package/node_modules/boxen/index.d.ts +267 -0
- package/node_modules/boxen/index.js +376 -0
- package/node_modules/boxen/license +9 -0
- package/node_modules/boxen/package.json +69 -0
- package/node_modules/boxen/readme.md +300 -0
- package/node_modules/camelcase/index.d.ts +102 -0
- package/node_modules/camelcase/index.js +110 -0
- package/node_modules/camelcase/license +9 -0
- package/node_modules/camelcase/package.json +47 -0
- package/node_modules/camelcase/readme.md +135 -0
- package/node_modules/chalk/license +9 -0
- package/node_modules/chalk/package.json +83 -0
- package/node_modules/chalk/readme.md +297 -0
- package/node_modules/chalk/source/index.d.ts +325 -0
- package/node_modules/chalk/source/index.js +225 -0
- package/node_modules/chalk/source/utilities.js +33 -0
- package/node_modules/chalk/source/vendor/ansi-styles/index.d.ts +236 -0
- package/node_modules/chalk/source/vendor/ansi-styles/index.js +223 -0
- package/node_modules/chalk/source/vendor/supports-color/browser.d.ts +1 -0
- package/node_modules/chalk/source/vendor/supports-color/browser.js +34 -0
- package/node_modules/chalk/source/vendor/supports-color/index.d.ts +55 -0
- package/node_modules/chalk/source/vendor/supports-color/index.js +190 -0
- package/node_modules/cli-boxes/boxes.json +82 -0
- package/node_modules/cli-boxes/index.d.ts +127 -0
- package/node_modules/cli-boxes/index.js +6 -0
- package/node_modules/cli-boxes/license +9 -0
- package/node_modules/cli-boxes/package.json +42 -0
- package/node_modules/cli-boxes/readme.md +115 -0
- package/node_modules/cli-table3/LICENSE +21 -0
- package/node_modules/cli-table3/README.md +236 -0
- package/node_modules/cli-table3/index.d.ts +96 -0
- package/node_modules/cli-table3/index.js +1 -0
- package/node_modules/cli-table3/node_modules/ansi-regex/index.d.ts +37 -0
- package/node_modules/cli-table3/node_modules/ansi-regex/index.js +10 -0
- package/node_modules/cli-table3/node_modules/ansi-regex/license +9 -0
- package/node_modules/cli-table3/node_modules/ansi-regex/package.json +55 -0
- package/node_modules/cli-table3/node_modules/ansi-regex/readme.md +78 -0
- package/node_modules/cli-table3/node_modules/emoji-regex/LICENSE-MIT.txt +20 -0
- package/node_modules/cli-table3/node_modules/emoji-regex/README.md +73 -0
- package/node_modules/cli-table3/node_modules/emoji-regex/es2015/index.js +6 -0
- package/node_modules/cli-table3/node_modules/emoji-regex/es2015/text.js +6 -0
- package/node_modules/cli-table3/node_modules/emoji-regex/index.d.ts +23 -0
- package/node_modules/cli-table3/node_modules/emoji-regex/index.js +6 -0
- package/node_modules/cli-table3/node_modules/emoji-regex/package.json +50 -0
- package/node_modules/cli-table3/node_modules/emoji-regex/text.js +6 -0
- package/node_modules/cli-table3/node_modules/string-width/index.d.ts +29 -0
- package/node_modules/cli-table3/node_modules/string-width/index.js +47 -0
- package/node_modules/cli-table3/node_modules/string-width/license +9 -0
- package/node_modules/cli-table3/node_modules/string-width/package.json +56 -0
- package/node_modules/cli-table3/node_modules/string-width/readme.md +50 -0
- package/node_modules/cli-table3/node_modules/strip-ansi/index.d.ts +17 -0
- package/node_modules/cli-table3/node_modules/strip-ansi/index.js +4 -0
- package/node_modules/cli-table3/node_modules/strip-ansi/license +9 -0
- package/node_modules/cli-table3/node_modules/strip-ansi/package.json +54 -0
- package/node_modules/cli-table3/node_modules/strip-ansi/readme.md +46 -0
- package/node_modules/cli-table3/package.json +100 -0
- package/node_modules/cli-table3/src/cell.js +409 -0
- package/node_modules/cli-table3/src/debug.js +28 -0
- package/node_modules/cli-table3/src/layout-manager.js +254 -0
- package/node_modules/cli-table3/src/table.js +106 -0
- package/node_modules/cli-table3/src/utils.js +344 -0
- package/node_modules/commander/LICENSE +22 -0
- package/node_modules/commander/Readme.md +1157 -0
- package/node_modules/commander/esm.mjs +16 -0
- package/node_modules/commander/index.js +24 -0
- package/node_modules/commander/lib/argument.js +149 -0
- package/node_modules/commander/lib/command.js +2509 -0
- package/node_modules/commander/lib/error.js +39 -0
- package/node_modules/commander/lib/help.js +520 -0
- package/node_modules/commander/lib/option.js +330 -0
- package/node_modules/commander/lib/suggestSimilar.js +101 -0
- package/node_modules/commander/package-support.json +16 -0
- package/node_modules/commander/package.json +84 -0
- package/node_modules/commander/typings/esm.d.mts +3 -0
- package/node_modules/commander/typings/index.d.ts +969 -0
- package/node_modules/emoji-regex/LICENSE-MIT.txt +20 -0
- package/node_modules/emoji-regex/README.md +107 -0
- package/node_modules/emoji-regex/index.d.ts +3 -0
- package/node_modules/emoji-regex/index.js +4 -0
- package/node_modules/emoji-regex/index.mjs +4 -0
- package/node_modules/emoji-regex/package.json +45 -0
- package/node_modules/get-east-asian-width/index.d.ts +60 -0
- package/node_modules/get-east-asian-width/index.js +30 -0
- package/node_modules/get-east-asian-width/license +9 -0
- package/node_modules/get-east-asian-width/lookup-data.js +18 -0
- package/node_modules/get-east-asian-width/lookup.js +135 -0
- package/node_modules/get-east-asian-width/package.json +71 -0
- package/node_modules/get-east-asian-width/readme.md +65 -0
- package/node_modules/get-east-asian-width/utilities.js +24 -0
- package/node_modules/is-fullwidth-code-point/index.d.ts +17 -0
- package/node_modules/is-fullwidth-code-point/index.js +50 -0
- package/node_modules/is-fullwidth-code-point/license +9 -0
- package/node_modules/is-fullwidth-code-point/package.json +42 -0
- package/node_modules/is-fullwidth-code-point/readme.md +39 -0
- package/node_modules/isbinaryfile/LICENSE.txt +22 -0
- package/node_modules/isbinaryfile/README.md +70 -0
- package/node_modules/isbinaryfile/lib/index.d.ts +3 -0
- package/node_modules/isbinaryfile/lib/index.js +256 -0
- package/node_modules/isbinaryfile/package.json +64 -0
- package/node_modules/string-width/index.d.ts +39 -0
- package/node_modules/string-width/index.js +82 -0
- package/node_modules/string-width/license +9 -0
- package/node_modules/string-width/package.json +64 -0
- package/node_modules/string-width/readme.md +66 -0
- package/node_modules/strip-ansi/index.d.ts +15 -0
- package/node_modules/strip-ansi/index.js +19 -0
- package/node_modules/strip-ansi/license +9 -0
- package/node_modules/strip-ansi/package.json +59 -0
- package/node_modules/strip-ansi/readme.md +37 -0
- package/node_modules/type-fest/index.d.ts +178 -0
- package/node_modules/type-fest/license-cc0 +121 -0
- package/node_modules/type-fest/license-mit +9 -0
- package/node_modules/type-fest/package.json +91 -0
- package/node_modules/type-fest/readme.md +1060 -0
- package/node_modules/type-fest/source/all-union-fields.d.ts +88 -0
- package/node_modules/type-fest/source/and.d.ts +25 -0
- package/node_modules/type-fest/source/array-indices.d.ts +23 -0
- package/node_modules/type-fest/source/array-slice.d.ts +109 -0
- package/node_modules/type-fest/source/array-splice.d.ts +99 -0
- package/node_modules/type-fest/source/array-tail.d.ts +76 -0
- package/node_modules/type-fest/source/array-values.d.ts +22 -0
- package/node_modules/type-fest/source/arrayable.d.ts +29 -0
- package/node_modules/type-fest/source/async-return-type.d.ts +23 -0
- package/node_modules/type-fest/source/asyncify.d.ts +32 -0
- package/node_modules/type-fest/source/basic.d.ts +68 -0
- package/node_modules/type-fest/source/camel-case.d.ts +89 -0
- package/node_modules/type-fest/source/camel-cased-properties-deep.d.ts +97 -0
- package/node_modules/type-fest/source/camel-cased-properties.d.ts +43 -0
- package/node_modules/type-fest/source/conditional-except.d.ts +45 -0
- package/node_modules/type-fest/source/conditional-keys.d.ts +47 -0
- package/node_modules/type-fest/source/conditional-pick-deep.d.ts +118 -0
- package/node_modules/type-fest/source/conditional-pick.d.ts +44 -0
- package/node_modules/type-fest/source/conditional-simplify.d.ts +32 -0
- package/node_modules/type-fest/source/delimiter-case.d.ts +78 -0
- package/node_modules/type-fest/source/delimiter-cased-properties-deep.d.ts +106 -0
- package/node_modules/type-fest/source/delimiter-cased-properties.d.ts +46 -0
- package/node_modules/type-fest/source/distributed-omit.d.ts +89 -0
- package/node_modules/type-fest/source/distributed-pick.d.ts +85 -0
- package/node_modules/type-fest/source/empty-object.d.ts +46 -0
- package/node_modules/type-fest/source/enforce-optional.d.ts +47 -0
- package/node_modules/type-fest/source/entries.d.ts +62 -0
- package/node_modules/type-fest/source/entry.d.ts +65 -0
- package/node_modules/type-fest/source/exact.d.ts +68 -0
- package/node_modules/type-fest/source/except.d.ts +108 -0
- package/node_modules/type-fest/source/find-global-type.d.ts +64 -0
- package/node_modules/type-fest/source/fixed-length-array.d.ts +43 -0
- package/node_modules/type-fest/source/get.d.ts +219 -0
- package/node_modules/type-fest/source/global-this.d.ts +21 -0
- package/node_modules/type-fest/source/greater-than-or-equal.d.ts +22 -0
- package/node_modules/type-fest/source/greater-than.d.ts +56 -0
- package/node_modules/type-fest/source/has-optional-keys.d.ts +21 -0
- package/node_modules/type-fest/source/has-readonly-keys.d.ts +21 -0
- package/node_modules/type-fest/source/has-required-keys.d.ts +59 -0
- package/node_modules/type-fest/source/has-writable-keys.d.ts +21 -0
- package/node_modules/type-fest/source/if-any.d.ts +24 -0
- package/node_modules/type-fest/source/if-empty-object.d.ts +26 -0
- package/node_modules/type-fest/source/if-never.d.ts +24 -0
- package/node_modules/type-fest/source/if-null.d.ts +24 -0
- package/node_modules/type-fest/source/if-unknown.d.ts +24 -0
- package/node_modules/type-fest/source/includes.d.ts +22 -0
- package/node_modules/type-fest/source/int-closed-range.d.ts +35 -0
- package/node_modules/type-fest/source/int-range.d.ts +55 -0
- package/node_modules/type-fest/source/internal/array.d.ts +126 -0
- package/node_modules/type-fest/source/internal/characters.d.ts +67 -0
- package/node_modules/type-fest/source/internal/index.d.ts +8 -0
- package/node_modules/type-fest/source/internal/keys.d.ts +97 -0
- package/node_modules/type-fest/source/internal/numeric.d.ts +118 -0
- package/node_modules/type-fest/source/internal/object.d.ts +236 -0
- package/node_modules/type-fest/source/internal/string.d.ts +210 -0
- package/node_modules/type-fest/source/internal/tuple.d.ts +90 -0
- package/node_modules/type-fest/source/internal/type.d.ts +139 -0
- package/node_modules/type-fest/source/invariant-of.d.ts +76 -0
- package/node_modules/type-fest/source/is-any.d.ts +33 -0
- package/node_modules/type-fest/source/is-equal.d.ts +31 -0
- package/node_modules/type-fest/source/is-float.d.ts +41 -0
- package/node_modules/type-fest/source/is-integer.d.ts +58 -0
- package/node_modules/type-fest/source/is-literal.d.ts +296 -0
- package/node_modules/type-fest/source/is-never.d.ts +42 -0
- package/node_modules/type-fest/source/is-null.d.ts +20 -0
- package/node_modules/type-fest/source/is-tuple.d.ts +89 -0
- package/node_modules/type-fest/source/is-unknown.d.ts +52 -0
- package/node_modules/type-fest/source/iterable-element.d.ts +64 -0
- package/node_modules/type-fest/source/join.d.ts +68 -0
- package/node_modules/type-fest/source/jsonifiable.d.ts +37 -0
- package/node_modules/type-fest/source/jsonify.d.ts +122 -0
- package/node_modules/type-fest/source/kebab-case.d.ts +44 -0
- package/node_modules/type-fest/source/kebab-cased-properties-deep.d.ts +63 -0
- package/node_modules/type-fest/source/kebab-cased-properties.d.ts +40 -0
- package/node_modules/type-fest/source/keys-of-union.d.ts +42 -0
- package/node_modules/type-fest/source/last-array-element.d.ts +38 -0
- package/node_modules/type-fest/source/less-than-or-equal.d.ts +22 -0
- package/node_modules/type-fest/source/less-than.d.ts +26 -0
- package/node_modules/type-fest/source/literal-to-primitive-deep.d.ts +36 -0
- package/node_modules/type-fest/source/literal-to-primitive.d.ts +36 -0
- package/node_modules/type-fest/source/literal-union.d.ts +37 -0
- package/node_modules/type-fest/source/merge-deep.d.ts +486 -0
- package/node_modules/type-fest/source/merge-exclusive.d.ts +41 -0
- package/node_modules/type-fest/source/merge.d.ts +48 -0
- package/node_modules/type-fest/source/multidimensional-array.d.ts +44 -0
- package/node_modules/type-fest/source/multidimensional-readonly-array.d.ts +48 -0
- package/node_modules/type-fest/source/non-empty-object.d.ts +35 -0
- package/node_modules/type-fest/source/non-empty-string.d.ts +28 -0
- package/node_modules/type-fest/source/non-empty-tuple.d.ts +21 -0
- package/node_modules/type-fest/source/numeric.d.ts +222 -0
- package/node_modules/type-fest/source/observable-like.d.ts +63 -0
- package/node_modules/type-fest/source/omit-deep.d.ts +167 -0
- package/node_modules/type-fest/source/omit-index-signature.d.ts +95 -0
- package/node_modules/type-fest/source/opaque.d.ts +1 -0
- package/node_modules/type-fest/source/optional-keys-of.d.ts +39 -0
- package/node_modules/type-fest/source/or.d.ts +25 -0
- package/node_modules/type-fest/source/override-properties.d.ts +36 -0
- package/node_modules/type-fest/source/package-json.d.ts +676 -0
- package/node_modules/type-fest/source/partial-deep.d.ts +151 -0
- package/node_modules/type-fest/source/partial-on-undefined-deep.d.ts +78 -0
- package/node_modules/type-fest/source/pascal-case.d.ts +42 -0
- package/node_modules/type-fest/source/pascal-cased-properties-deep.d.ts +62 -0
- package/node_modules/type-fest/source/pascal-cased-properties.d.ts +36 -0
- package/node_modules/type-fest/source/paths.d.ts +262 -0
- package/node_modules/type-fest/source/pick-deep.d.ts +149 -0
- package/node_modules/type-fest/source/pick-index-signature.d.ts +50 -0
- package/node_modules/type-fest/source/primitive.d.ts +13 -0
- package/node_modules/type-fest/source/promisable.d.ts +25 -0
- package/node_modules/type-fest/source/readonly-deep.d.ts +81 -0
- package/node_modules/type-fest/source/readonly-keys-of.d.ts +30 -0
- package/node_modules/type-fest/source/readonly-tuple.d.ts +41 -0
- package/node_modules/type-fest/source/replace.d.ts +85 -0
- package/node_modules/type-fest/source/require-all-or-none.d.ts +51 -0
- package/node_modules/type-fest/source/require-at-least-one.d.ts +47 -0
- package/node_modules/type-fest/source/require-exactly-one.d.ts +45 -0
- package/node_modules/type-fest/source/require-one-or-none.d.ts +46 -0
- package/node_modules/type-fest/source/required-deep.d.ts +78 -0
- package/node_modules/type-fest/source/required-keys-of.d.ts +30 -0
- package/node_modules/type-fest/source/schema.d.ts +114 -0
- package/node_modules/type-fest/source/screaming-snake-case.d.ts +28 -0
- package/node_modules/type-fest/source/set-field-type.d.ts +65 -0
- package/node_modules/type-fest/source/set-non-nullable-deep.d.ts +83 -0
- package/node_modules/type-fest/source/set-non-nullable.d.ts +39 -0
- package/node_modules/type-fest/source/set-optional.d.ts +38 -0
- package/node_modules/type-fest/source/set-parameter-type.d.ts +117 -0
- package/node_modules/type-fest/source/set-readonly.d.ts +39 -0
- package/node_modules/type-fest/source/set-required-deep.d.ts +68 -0
- package/node_modules/type-fest/source/set-required.d.ts +70 -0
- package/node_modules/type-fest/source/set-return-type.d.ts +29 -0
- package/node_modules/type-fest/source/shared-union-fields-deep.d.ts +178 -0
- package/node_modules/type-fest/source/shared-union-fields.d.ts +76 -0
- package/node_modules/type-fest/source/simplify-deep.d.ts +115 -0
- package/node_modules/type-fest/source/simplify.d.ts +58 -0
- package/node_modules/type-fest/source/single-key-object.d.ts +29 -0
- package/node_modules/type-fest/source/snake-case.d.ts +45 -0
- package/node_modules/type-fest/source/snake-cased-properties-deep.d.ts +63 -0
- package/node_modules/type-fest/source/snake-cased-properties.d.ts +40 -0
- package/node_modules/type-fest/source/split.d.ts +88 -0
- package/node_modules/type-fest/source/spread.d.ts +84 -0
- package/node_modules/type-fest/source/string-key-of.d.ts +25 -0
- package/node_modules/type-fest/source/string-repeat.d.ts +47 -0
- package/node_modules/type-fest/source/string-slice.d.ts +37 -0
- package/node_modules/type-fest/source/stringified.d.ts +23 -0
- package/node_modules/type-fest/source/structured-cloneable.d.ts +92 -0
- package/node_modules/type-fest/source/subtract.d.ts +83 -0
- package/node_modules/type-fest/source/sum.d.ts +78 -0
- package/node_modules/type-fest/source/tagged-union.d.ts +51 -0
- package/node_modules/type-fest/source/tagged.d.ts +256 -0
- package/node_modules/type-fest/source/trim.d.ts +27 -0
- package/node_modules/type-fest/source/tsconfig-json.d.ts +1294 -0
- package/node_modules/type-fest/source/tuple-to-object.d.ts +42 -0
- package/node_modules/type-fest/source/tuple-to-union.d.ts +51 -0
- package/node_modules/type-fest/source/typed-array.d.ts +17 -0
- package/node_modules/type-fest/source/undefined-on-partial-deep.d.ts +80 -0
- package/node_modules/type-fest/source/union-to-intersection.d.ts +61 -0
- package/node_modules/type-fest/source/union-to-tuple.d.ts +56 -0
- package/node_modules/type-fest/source/unknown-array.d.ts +25 -0
- package/node_modules/type-fest/source/unknown-map.d.ts +24 -0
- package/node_modules/type-fest/source/unknown-record.d.ts +31 -0
- package/node_modules/type-fest/source/unknown-set.d.ts +24 -0
- package/node_modules/type-fest/source/value-of.d.ts +42 -0
- package/node_modules/type-fest/source/words.d.ts +118 -0
- package/node_modules/type-fest/source/writable-deep.d.ts +83 -0
- package/node_modules/type-fest/source/writable-keys-of.d.ts +33 -0
- package/node_modules/type-fest/source/writable.d.ts +68 -0
- package/node_modules/widest-line/index.d.ts +12 -0
- package/node_modules/widest-line/index.js +11 -0
- package/node_modules/widest-line/license +9 -0
- package/node_modules/widest-line/package.json +60 -0
- package/node_modules/widest-line/readme.md +26 -0
- package/node_modules/wrap-ansi/index.d.ts +41 -0
- package/node_modules/wrap-ansi/index.js +222 -0
- package/node_modules/wrap-ansi/license +9 -0
- package/node_modules/wrap-ansi/package.json +69 -0
- package/node_modules/wrap-ansi/readme.md +75 -0
- package/package.json +78 -0
- package/scripts/postinstall.cjs +122 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type {IsEqual} from './is-equal';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
Extract all writable keys from the given type.
|
|
5
|
+
|
|
6
|
+
This is useful when you want to create a new type that contains writable keys only.
|
|
7
|
+
|
|
8
|
+
@example
|
|
9
|
+
```
|
|
10
|
+
import type {WritableKeysOf} from 'type-fest';
|
|
11
|
+
|
|
12
|
+
interface User {
|
|
13
|
+
name: string;
|
|
14
|
+
surname: string;
|
|
15
|
+
readonly id: number;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
type UpdateRequest<Entity extends object> = Pick<Entity, WritableKeysOf<Entity>>;
|
|
19
|
+
|
|
20
|
+
const update1: UpdateRequest<User> = {
|
|
21
|
+
name: 'Alice',
|
|
22
|
+
surname: 'Acme',
|
|
23
|
+
};
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
@category Utilities
|
|
27
|
+
*/
|
|
28
|
+
export type WritableKeysOf<T> =
|
|
29
|
+
T extends unknown // For distributing `T`
|
|
30
|
+
? (keyof {
|
|
31
|
+
[P in keyof T as IsEqual<{[Q in P]: T[P]}, {readonly [Q in P]: T[P]}> extends false ? P : never]: never
|
|
32
|
+
}) & keyof T // Intersect with `keyof T` to ensure result of `WritableKeysOf<T>` is always assignable to `keyof T`
|
|
33
|
+
: never; // Should never happen
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type {Except} from './except';
|
|
2
|
+
import type {Simplify} from './simplify';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
Create a writable version of the given array type.
|
|
6
|
+
*/
|
|
7
|
+
type WritableArray<ArrayType extends readonly unknown[]> =
|
|
8
|
+
ArrayType extends readonly [] ? []
|
|
9
|
+
: ArrayType extends readonly [...infer U, infer V] ? [...U, V]
|
|
10
|
+
: ArrayType extends readonly [infer U, ...infer V] ? [U, ...V]
|
|
11
|
+
: ArrayType extends ReadonlyArray<infer U> ? U[]
|
|
12
|
+
: ArrayType;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
Create a type that strips `readonly` from the given type. Inverse of `Readonly<T>`.
|
|
16
|
+
|
|
17
|
+
The 2nd argument will be ignored if the input type is not an object.
|
|
18
|
+
|
|
19
|
+
Note: This type can make readonly `Set` and `Map` writable. This behavior is different from `Readonly<T>` (as of TypeScript 5.2.2). See: https://github.com/microsoft/TypeScript/issues/29655
|
|
20
|
+
|
|
21
|
+
This can be used to [store and mutate options within a class](https://github.com/sindresorhus/pageres/blob/4a5d05fca19a5fbd2f53842cbf3eb7b1b63bddd2/source/index.ts#L72), [edit `readonly` objects within tests](https://stackoverflow.com/questions/50703834), [construct a `readonly` object within a function](https://github.com/Microsoft/TypeScript/issues/24509), or to define a single model where the only thing that changes is whether or not some of the keys are writable.
|
|
22
|
+
|
|
23
|
+
@example
|
|
24
|
+
```
|
|
25
|
+
import type {Writable} from 'type-fest';
|
|
26
|
+
|
|
27
|
+
type Foo = {
|
|
28
|
+
readonly a: number;
|
|
29
|
+
readonly b: readonly string[]; // To show that only the mutability status of the properties, not their values, are affected.
|
|
30
|
+
readonly c: boolean;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const writableFoo: Writable<Foo> = {a: 1, b: ['2'], c: true};
|
|
34
|
+
writableFoo.a = 3;
|
|
35
|
+
writableFoo.b[0] = 'new value'; // Will still fail as the value of property "b" is still a readonly type.
|
|
36
|
+
writableFoo.b = ['something']; // Will work as the "b" property itself is no longer readonly.
|
|
37
|
+
|
|
38
|
+
type SomeWritable = Writable<Foo, 'b' | 'c'>;
|
|
39
|
+
// type SomeWritable = {
|
|
40
|
+
// readonly a: number;
|
|
41
|
+
// b: readonly string[]; // It's now writable. The type of the property remains unaffected.
|
|
42
|
+
// c: boolean; // It's now writable.
|
|
43
|
+
// }
|
|
44
|
+
|
|
45
|
+
// Also supports array
|
|
46
|
+
const readonlyArray: readonly number[] = [1, 2, 3];
|
|
47
|
+
readonlyArray.push(4); // Will fail as the array itself is readonly.
|
|
48
|
+
const writableArray: Writable<typeof readonlyArray> = readonlyArray as Writable<typeof readonlyArray>;
|
|
49
|
+
writableArray.push(4); // Will work as the array itself is now writable.
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
@category Object
|
|
53
|
+
*/
|
|
54
|
+
export type Writable<BaseType, Keys extends keyof BaseType = keyof BaseType> =
|
|
55
|
+
BaseType extends ReadonlyMap<infer KeyType, infer ValueType>
|
|
56
|
+
? Map<KeyType, ValueType>
|
|
57
|
+
: BaseType extends ReadonlySet<infer ItemType>
|
|
58
|
+
? Set<ItemType>
|
|
59
|
+
: BaseType extends readonly unknown[]
|
|
60
|
+
// Handle array
|
|
61
|
+
? WritableArray<BaseType>
|
|
62
|
+
// Handle object
|
|
63
|
+
: Simplify<
|
|
64
|
+
// Pick just the keys that are not writable from the base type.
|
|
65
|
+
Except<BaseType, Keys> &
|
|
66
|
+
// Pick the keys that should be writable from the base type and make them writable by removing the `readonly` modifier from the key.
|
|
67
|
+
{-readonly [KeyType in keyof Pick<BaseType, Keys>]: Pick<BaseType, Keys>[KeyType]}
|
|
68
|
+
>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Get the visual width of the widest line in a string - the number of columns required to display it.
|
|
3
|
+
|
|
4
|
+
@example
|
|
5
|
+
```
|
|
6
|
+
import widestLine from 'widest-line';
|
|
7
|
+
|
|
8
|
+
widestLine('古\n\u001B[1m@\u001B[22m');
|
|
9
|
+
//=> 2
|
|
10
|
+
```
|
|
11
|
+
*/
|
|
12
|
+
export default function widestLine(string: string): number;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "widest-line",
|
|
3
|
+
"version": "5.0.0",
|
|
4
|
+
"description": "Get the visual width of the widest line in a string - the number of columns required to display it",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": "sindresorhus/widest-line",
|
|
7
|
+
"funding": "https://github.com/sponsors/sindresorhus",
|
|
8
|
+
"author": {
|
|
9
|
+
"name": "Sindre Sorhus",
|
|
10
|
+
"email": "sindresorhus@gmail.com",
|
|
11
|
+
"url": "https://sindresorhus.com"
|
|
12
|
+
},
|
|
13
|
+
"type": "module",
|
|
14
|
+
"exports": {
|
|
15
|
+
"types": "./index.d.ts",
|
|
16
|
+
"default": "./index.js"
|
|
17
|
+
},
|
|
18
|
+
"engines": {
|
|
19
|
+
"node": ">=18"
|
|
20
|
+
},
|
|
21
|
+
"scripts": {
|
|
22
|
+
"test": "xo && ava && tsd"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"index.js",
|
|
26
|
+
"index.d.ts"
|
|
27
|
+
],
|
|
28
|
+
"keywords": [
|
|
29
|
+
"string",
|
|
30
|
+
"character",
|
|
31
|
+
"unicode",
|
|
32
|
+
"width",
|
|
33
|
+
"visual",
|
|
34
|
+
"column",
|
|
35
|
+
"columns",
|
|
36
|
+
"fullwidth",
|
|
37
|
+
"full-width",
|
|
38
|
+
"full",
|
|
39
|
+
"ansi",
|
|
40
|
+
"escape",
|
|
41
|
+
"codes",
|
|
42
|
+
"cli",
|
|
43
|
+
"command-line",
|
|
44
|
+
"terminal",
|
|
45
|
+
"console",
|
|
46
|
+
"cjk",
|
|
47
|
+
"chinese",
|
|
48
|
+
"japanese",
|
|
49
|
+
"korean",
|
|
50
|
+
"fixed-width"
|
|
51
|
+
],
|
|
52
|
+
"dependencies": {
|
|
53
|
+
"string-width": "^7.0.0"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"ava": "^5.3.1",
|
|
57
|
+
"tsd": "^0.29.0",
|
|
58
|
+
"xo": "^0.56.0"
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# widest-line
|
|
2
|
+
|
|
3
|
+
> Get the visual width of the widest line in a string - the number of columns required to display it
|
|
4
|
+
|
|
5
|
+
Some Unicode characters are [fullwidth](https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms) and use double the normal width. [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code) are stripped and doesn't affect the width.
|
|
6
|
+
|
|
7
|
+
Useful to be able to know the maximum width a string will take up in the terminal.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
npm install widest-line
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```js
|
|
18
|
+
import widestLine from 'widest-line';
|
|
19
|
+
|
|
20
|
+
widestLine('古\n\u001B[1m@\u001B[22m');
|
|
21
|
+
//=> 2
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Related
|
|
25
|
+
|
|
26
|
+
- [string-width](https://github.com/sindresorhus/string-width) - Get the visual width of a string
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export type Options = {
|
|
2
|
+
/**
|
|
3
|
+
By default the wrap is soft, meaning long words may extend past the column width. Setting this to `true` will make it hard wrap at the column width.
|
|
4
|
+
|
|
5
|
+
@default false
|
|
6
|
+
*/
|
|
7
|
+
readonly hard?: boolean;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
By default, an attempt is made to split words at spaces, ensuring that they don't extend past the configured columns. If wordWrap is `false`, each column will instead be completely filled splitting words as necessary.
|
|
11
|
+
|
|
12
|
+
@default true
|
|
13
|
+
*/
|
|
14
|
+
readonly wordWrap?: boolean;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
Whitespace on all lines is removed by default. Set this option to `false` if you don't want to trim.
|
|
18
|
+
|
|
19
|
+
@default true
|
|
20
|
+
*/
|
|
21
|
+
readonly trim?: boolean;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
Wrap words to the specified column width.
|
|
26
|
+
|
|
27
|
+
@param string - A string with ANSI escape codes, like one styled by [`chalk`](https://github.com/chalk/chalk). Newline characters will be normalized to `\n`.
|
|
28
|
+
@param columns - The number of columns to wrap the text to.
|
|
29
|
+
|
|
30
|
+
@example
|
|
31
|
+
```
|
|
32
|
+
import chalk from 'chalk';
|
|
33
|
+
import wrapAnsi from 'wrap-ansi';
|
|
34
|
+
|
|
35
|
+
const input = 'The quick brown ' + chalk.red('fox jumped over ') +
|
|
36
|
+
'the lazy ' + chalk.green('dog and then ran away with the unicorn.');
|
|
37
|
+
|
|
38
|
+
console.log(wrapAnsi(input, 20));
|
|
39
|
+
```
|
|
40
|
+
*/
|
|
41
|
+
export default function wrapAnsi(string: string, columns: number, options?: Options): string;
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import stringWidth from 'string-width';
|
|
2
|
+
import stripAnsi from 'strip-ansi';
|
|
3
|
+
import ansiStyles from 'ansi-styles';
|
|
4
|
+
|
|
5
|
+
const ESCAPES = new Set([
|
|
6
|
+
'\u001B',
|
|
7
|
+
'\u009B',
|
|
8
|
+
]);
|
|
9
|
+
|
|
10
|
+
const END_CODE = 39;
|
|
11
|
+
const ANSI_ESCAPE_BELL = '\u0007';
|
|
12
|
+
const ANSI_CSI = '[';
|
|
13
|
+
const ANSI_OSC = ']';
|
|
14
|
+
const ANSI_SGR_TERMINATOR = 'm';
|
|
15
|
+
const ANSI_ESCAPE_LINK = `${ANSI_OSC}8;;`;
|
|
16
|
+
|
|
17
|
+
const wrapAnsiCode = code => `${ESCAPES.values().next().value}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`;
|
|
18
|
+
const wrapAnsiHyperlink = url => `${ESCAPES.values().next().value}${ANSI_ESCAPE_LINK}${url}${ANSI_ESCAPE_BELL}`;
|
|
19
|
+
|
|
20
|
+
// Calculate the length of words split on ' ', ignoring
|
|
21
|
+
// the extra characters added by ansi escape codes
|
|
22
|
+
const wordLengths = string => string.split(' ').map(character => stringWidth(character));
|
|
23
|
+
|
|
24
|
+
// Wrap a long word across multiple rows
|
|
25
|
+
// Ansi escape codes do not count towards length
|
|
26
|
+
const wrapWord = (rows, word, columns) => {
|
|
27
|
+
const characters = [...word];
|
|
28
|
+
|
|
29
|
+
let isInsideEscape = false;
|
|
30
|
+
let isInsideLinkEscape = false;
|
|
31
|
+
let visible = stringWidth(stripAnsi(rows.at(-1)));
|
|
32
|
+
|
|
33
|
+
for (const [index, character] of characters.entries()) {
|
|
34
|
+
const characterLength = stringWidth(character);
|
|
35
|
+
|
|
36
|
+
if (visible + characterLength <= columns) {
|
|
37
|
+
rows[rows.length - 1] += character;
|
|
38
|
+
} else {
|
|
39
|
+
rows.push(character);
|
|
40
|
+
visible = 0;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (ESCAPES.has(character)) {
|
|
44
|
+
isInsideEscape = true;
|
|
45
|
+
|
|
46
|
+
const ansiEscapeLinkCandidate = characters.slice(index + 1, index + 1 + ANSI_ESCAPE_LINK.length).join('');
|
|
47
|
+
isInsideLinkEscape = ansiEscapeLinkCandidate === ANSI_ESCAPE_LINK;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (isInsideEscape) {
|
|
51
|
+
if (isInsideLinkEscape) {
|
|
52
|
+
if (character === ANSI_ESCAPE_BELL) {
|
|
53
|
+
isInsideEscape = false;
|
|
54
|
+
isInsideLinkEscape = false;
|
|
55
|
+
}
|
|
56
|
+
} else if (character === ANSI_SGR_TERMINATOR) {
|
|
57
|
+
isInsideEscape = false;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
visible += characterLength;
|
|
64
|
+
|
|
65
|
+
if (visible === columns && index < characters.length - 1) {
|
|
66
|
+
rows.push('');
|
|
67
|
+
visible = 0;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// It's possible that the last row we copy over is only
|
|
72
|
+
// ansi escape characters, handle this edge-case
|
|
73
|
+
if (!visible && rows.at(-1).length > 0 && rows.length > 1) {
|
|
74
|
+
rows[rows.length - 2] += rows.pop();
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
// Trims spaces from a string ignoring invisible sequences
|
|
79
|
+
const stringVisibleTrimSpacesRight = string => {
|
|
80
|
+
const words = string.split(' ');
|
|
81
|
+
let last = words.length;
|
|
82
|
+
|
|
83
|
+
while (last > 0) {
|
|
84
|
+
if (stringWidth(words[last - 1]) > 0) {
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
last--;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (last === words.length) {
|
|
92
|
+
return string;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return words.slice(0, last).join(' ') + words.slice(last).join('');
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
// The wrap-ansi module can be invoked in either 'hard' or 'soft' wrap mode.
|
|
99
|
+
//
|
|
100
|
+
// 'hard' will never allow a string to take up more than columns characters.
|
|
101
|
+
//
|
|
102
|
+
// 'soft' allows long words to expand past the column length.
|
|
103
|
+
const exec = (string, columns, options = {}) => {
|
|
104
|
+
if (options.trim !== false && string.trim() === '') {
|
|
105
|
+
return '';
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
let returnValue = '';
|
|
109
|
+
let escapeCode;
|
|
110
|
+
let escapeUrl;
|
|
111
|
+
|
|
112
|
+
const lengths = wordLengths(string);
|
|
113
|
+
let rows = [''];
|
|
114
|
+
|
|
115
|
+
for (const [index, word] of string.split(' ').entries()) {
|
|
116
|
+
if (options.trim !== false) {
|
|
117
|
+
rows[rows.length - 1] = rows.at(-1).trimStart();
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
let rowLength = stringWidth(rows.at(-1));
|
|
121
|
+
|
|
122
|
+
if (index !== 0) {
|
|
123
|
+
if (rowLength >= columns && (options.wordWrap === false || options.trim === false)) {
|
|
124
|
+
// If we start with a new word but the current row length equals the length of the columns, add a new row
|
|
125
|
+
rows.push('');
|
|
126
|
+
rowLength = 0;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (rowLength > 0 || options.trim === false) {
|
|
130
|
+
rows[rows.length - 1] += ' ';
|
|
131
|
+
rowLength++;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// In 'hard' wrap mode, the length of a line is never allowed to extend past 'columns'
|
|
136
|
+
if (options.hard && lengths[index] > columns) {
|
|
137
|
+
const remainingColumns = (columns - rowLength);
|
|
138
|
+
const breaksStartingThisLine = 1 + Math.floor((lengths[index] - remainingColumns - 1) / columns);
|
|
139
|
+
const breaksStartingNextLine = Math.floor((lengths[index] - 1) / columns);
|
|
140
|
+
if (breaksStartingNextLine < breaksStartingThisLine) {
|
|
141
|
+
rows.push('');
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
wrapWord(rows, word, columns);
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (rowLength + lengths[index] > columns && rowLength > 0 && lengths[index] > 0) {
|
|
149
|
+
if (options.wordWrap === false && rowLength < columns) {
|
|
150
|
+
wrapWord(rows, word, columns);
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
rows.push('');
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if (rowLength + lengths[index] > columns && options.wordWrap === false) {
|
|
158
|
+
wrapWord(rows, word, columns);
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
rows[rows.length - 1] += word;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if (options.trim !== false) {
|
|
166
|
+
rows = rows.map(row => stringVisibleTrimSpacesRight(row));
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const preString = rows.join('\n');
|
|
170
|
+
const pre = [...preString];
|
|
171
|
+
|
|
172
|
+
// We need to keep a separate index as `String#slice()` works on Unicode code units, while `pre` is an array of codepoints.
|
|
173
|
+
let preStringIndex = 0;
|
|
174
|
+
|
|
175
|
+
for (const [index, character] of pre.entries()) {
|
|
176
|
+
returnValue += character;
|
|
177
|
+
|
|
178
|
+
if (ESCAPES.has(character)) {
|
|
179
|
+
const {groups} = new RegExp(`(?:\\${ANSI_CSI}(?<code>\\d+)m|\\${ANSI_ESCAPE_LINK}(?<uri>.*)${ANSI_ESCAPE_BELL})`).exec(preString.slice(preStringIndex)) || {groups: {}};
|
|
180
|
+
if (groups.code !== undefined) {
|
|
181
|
+
const code = Number.parseFloat(groups.code);
|
|
182
|
+
escapeCode = code === END_CODE ? undefined : code;
|
|
183
|
+
} else if (groups.uri !== undefined) {
|
|
184
|
+
escapeUrl = groups.uri.length === 0 ? undefined : groups.uri;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const code = ansiStyles.codes.get(Number(escapeCode));
|
|
189
|
+
|
|
190
|
+
if (pre[index + 1] === '\n') {
|
|
191
|
+
if (escapeUrl) {
|
|
192
|
+
returnValue += wrapAnsiHyperlink('');
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if (escapeCode && code) {
|
|
196
|
+
returnValue += wrapAnsiCode(code);
|
|
197
|
+
}
|
|
198
|
+
} else if (character === '\n') {
|
|
199
|
+
if (escapeCode && code) {
|
|
200
|
+
returnValue += wrapAnsiCode(escapeCode);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
if (escapeUrl) {
|
|
204
|
+
returnValue += wrapAnsiHyperlink(escapeUrl);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
preStringIndex += character.length;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
return returnValue;
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
// For each newline, invoke the method separately
|
|
215
|
+
export default function wrapAnsi(string, columns, options) {
|
|
216
|
+
return String(string)
|
|
217
|
+
.normalize()
|
|
218
|
+
.replaceAll('\r\n', '\n')
|
|
219
|
+
.split('\n')
|
|
220
|
+
.map(line => exec(line, columns, options))
|
|
221
|
+
.join('\n');
|
|
222
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "wrap-ansi",
|
|
3
|
+
"version": "9.0.2",
|
|
4
|
+
"description": "Wordwrap a string with ANSI escape codes",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": "chalk/wrap-ansi",
|
|
7
|
+
"funding": "https://github.com/chalk/wrap-ansi?sponsor=1",
|
|
8
|
+
"author": {
|
|
9
|
+
"name": "Sindre Sorhus",
|
|
10
|
+
"email": "sindresorhus@gmail.com",
|
|
11
|
+
"url": "https://sindresorhus.com"
|
|
12
|
+
},
|
|
13
|
+
"type": "module",
|
|
14
|
+
"exports": {
|
|
15
|
+
"types": "./index.d.ts",
|
|
16
|
+
"default": "./index.js"
|
|
17
|
+
},
|
|
18
|
+
"engines": {
|
|
19
|
+
"node": ">=18"
|
|
20
|
+
},
|
|
21
|
+
"scripts": {
|
|
22
|
+
"test": "xo && nyc ava && tsd"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"index.js",
|
|
26
|
+
"index.d.ts"
|
|
27
|
+
],
|
|
28
|
+
"keywords": [
|
|
29
|
+
"wrap",
|
|
30
|
+
"break",
|
|
31
|
+
"wordwrap",
|
|
32
|
+
"wordbreak",
|
|
33
|
+
"linewrap",
|
|
34
|
+
"ansi",
|
|
35
|
+
"styles",
|
|
36
|
+
"color",
|
|
37
|
+
"colour",
|
|
38
|
+
"colors",
|
|
39
|
+
"terminal",
|
|
40
|
+
"console",
|
|
41
|
+
"cli",
|
|
42
|
+
"string",
|
|
43
|
+
"tty",
|
|
44
|
+
"escape",
|
|
45
|
+
"formatting",
|
|
46
|
+
"rgb",
|
|
47
|
+
"256",
|
|
48
|
+
"shell",
|
|
49
|
+
"xterm",
|
|
50
|
+
"log",
|
|
51
|
+
"logging",
|
|
52
|
+
"command-line",
|
|
53
|
+
"text"
|
|
54
|
+
],
|
|
55
|
+
"dependencies": {
|
|
56
|
+
"ansi-styles": "^6.2.1",
|
|
57
|
+
"string-width": "^7.0.0",
|
|
58
|
+
"strip-ansi": "^7.1.0"
|
|
59
|
+
},
|
|
60
|
+
"devDependencies": {
|
|
61
|
+
"ava": "^5.3.1",
|
|
62
|
+
"chalk": "^5.3.0",
|
|
63
|
+
"coveralls": "^3.1.1",
|
|
64
|
+
"has-ansi": "^5.0.1",
|
|
65
|
+
"nyc": "^15.1.0",
|
|
66
|
+
"tsd": "^0.29.0",
|
|
67
|
+
"xo": "^0.56.0"
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# wrap-ansi
|
|
2
|
+
|
|
3
|
+
> Wordwrap a string with [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code#Colors_and_Styles)
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install wrap-ansi
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```js
|
|
14
|
+
import chalk from 'chalk';
|
|
15
|
+
import wrapAnsi from 'wrap-ansi';
|
|
16
|
+
|
|
17
|
+
const input = 'The quick brown ' + chalk.red('fox jumped over ') +
|
|
18
|
+
'the lazy ' + chalk.green('dog and then ran away with the unicorn.');
|
|
19
|
+
|
|
20
|
+
console.log(wrapAnsi(input, 20));
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
<img width="331" src="screenshot.png">
|
|
24
|
+
|
|
25
|
+
## API
|
|
26
|
+
|
|
27
|
+
### wrapAnsi(string, columns, options?)
|
|
28
|
+
|
|
29
|
+
Wrap words to the specified column width.
|
|
30
|
+
|
|
31
|
+
#### string
|
|
32
|
+
|
|
33
|
+
Type: `string`
|
|
34
|
+
|
|
35
|
+
A string with ANSI escape codes, like one styled by [`chalk`](https://github.com/chalk/chalk).
|
|
36
|
+
|
|
37
|
+
Newline characters will be normalized to `\n`.
|
|
38
|
+
|
|
39
|
+
#### columns
|
|
40
|
+
|
|
41
|
+
Type: `number`
|
|
42
|
+
|
|
43
|
+
The number of columns to wrap the text to.
|
|
44
|
+
|
|
45
|
+
#### options
|
|
46
|
+
|
|
47
|
+
Type: `object`
|
|
48
|
+
|
|
49
|
+
##### hard
|
|
50
|
+
|
|
51
|
+
Type: `boolean`\
|
|
52
|
+
Default: `false`
|
|
53
|
+
|
|
54
|
+
By default the wrap is soft, meaning long words may extend past the column width. Setting this to `true` will make it hard wrap at the column width.
|
|
55
|
+
|
|
56
|
+
##### wordWrap
|
|
57
|
+
|
|
58
|
+
Type: `boolean`\
|
|
59
|
+
Default: `true`
|
|
60
|
+
|
|
61
|
+
By default, an attempt is made to split words at spaces, ensuring that they don't extend past the configured columns. If wordWrap is `false`, each column will instead be completely filled splitting words as necessary.
|
|
62
|
+
|
|
63
|
+
##### trim
|
|
64
|
+
|
|
65
|
+
Type: `boolean`\
|
|
66
|
+
Default: `true`
|
|
67
|
+
|
|
68
|
+
Whitespace on all lines is removed by default. Set this option to `false` if you don't want to trim.
|
|
69
|
+
|
|
70
|
+
## Related
|
|
71
|
+
|
|
72
|
+
- [slice-ansi](https://github.com/chalk/slice-ansi) - Slice a string with ANSI escape codes
|
|
73
|
+
- [cli-truncate](https://github.com/sindresorhus/cli-truncate) - Truncate a string to a specific width in the terminal
|
|
74
|
+
- [chalk](https://github.com/chalk/chalk) - Terminal string styling done right
|
|
75
|
+
- [jsesc](https://github.com/mathiasbynens/jsesc) - Generate ASCII-only output from Unicode strings. Useful for creating test fixtures.
|