snyk 1.774.0 → 1.775.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/dist/cli/85.index.js
CHANGED
|
@@ -55,7 +55,7 @@ const listItemSeparator = 'LISTITEMSEPARATOR'; // Helper string for rendering Li
|
|
|
55
55
|
* @returns string
|
|
56
56
|
*/
|
|
57
57
|
function getLeftTextPadding() {
|
|
58
|
-
return ' '.repeat(currentHeader);
|
|
58
|
+
return ' '.repeat(currentHeader === 1 || currentHeader === 2 ? 1 : currentHeader - 1);
|
|
59
59
|
}
|
|
60
60
|
/**
|
|
61
61
|
* @description Reads current terminal width if available to limit column width for text-reflowing
|
|
@@ -89,7 +89,7 @@ const renderer = {
|
|
|
89
89
|
return quote;
|
|
90
90
|
},
|
|
91
91
|
list(body, ordered, start) {
|
|
92
|
-
return
|
|
92
|
+
return body
|
|
93
93
|
.split(listItemSeparator)
|
|
94
94
|
.map((listItem, listItemIndex) => {
|
|
95
95
|
const bulletPoint = ordered ? `${listItemIndex + start}. ` : '- ';
|
|
@@ -103,7 +103,7 @@ const renderer = {
|
|
|
103
103
|
})
|
|
104
104
|
.join('\n');
|
|
105
105
|
})
|
|
106
|
-
.join('\n')
|
|
106
|
+
.join('\n');
|
|
107
107
|
},
|
|
108
108
|
listitem(text) {
|
|
109
109
|
return text + listItemSeparator;
|
|
@@ -112,7 +112,7 @@ const renderer = {
|
|
|
112
112
|
return (reflow_text_1.reflowText(text, getIdealTextWidth())
|
|
113
113
|
.split('\n')
|
|
114
114
|
.map((s) => getLeftTextPadding() + chalk_1.default.reset() + s)
|
|
115
|
-
.join('\n') + '\n
|
|
115
|
+
.join('\n') + '\n');
|
|
116
116
|
},
|
|
117
117
|
codespan(text) {
|
|
118
118
|
return chalk_1.default.italic.blueBright(`${text}`);
|
|
@@ -135,7 +135,7 @@ const renderer = {
|
|
|
135
135
|
coloring = chalk_1.default.bold;
|
|
136
136
|
break;
|
|
137
137
|
}
|
|
138
|
-
return
|
|
138
|
+
return `\n${' '.repeat(level === 1 ? 0 : currentHeader - 2)}${coloring(text)}\n`;
|
|
139
139
|
},
|
|
140
140
|
};
|
|
141
141
|
marked_1.marked.use({ renderer });
|
package/dist/cli/85.index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"85.index.js","mappings":";;;;;;;;;;AAAA,sCAAyB;AACzB,wCAA6B;AAC7B,uDAAqD;AAErD,MAAM,YAAY,GAAG,MAAM,CAAC;AAE5B,SAAS,YAAY,CAAC,QAAgB;IACpC,MAAM,IAAI,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAC/C,OAAO,kCAAc,CAAC,IAAI,CAAC,CAAC;AAC9B,CAAC;AAEc,KAAK,UAAU,IAAI,CAAC,IAAuB;IACxD,IAAI,CAAC,IAAI,IAAI,IAAI,KAAK,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,MAAM,EAAE;QACzE,IAAI,GAAG,YAAY,CAAC;KACrB;IAED,+CAA+C;IAC/C,iDAAiD;IACjD,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;IAErC,IAAI;QACF,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAC3B,SAAS,EACT,wBAAwB,EAAE,0DAA0D;QACpF,IAAI,KAAK,YAAY,CAAC,CAAC,CAAC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,QAAQ,IAAI,KAAK,CACjE,CAAC;QACF,OAAO,YAAY,CAAC,QAAQ,CAAC,CAAC;KAC/B;IAAC,OAAO,KAAK,EAAE;QACd,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAC3B,SAAS,EACT,wBAAwB,EACxB,GAAG,YAAY,KAAK,CACrB,CAAC;QACF,OAAO,YAAY,CAAC,QAAQ,CAAC,CAAC;KAC/B;AACH,CAAC;AAxBD,uBAwBC;;;;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AC,CAAC;wBAC7B,OAAO,IAAI,CAAC,MAAM,EAAE;4BAClB,MAAM,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;4BAEhC,IAAI,CAAC,CAAC,CAAC,MAAM;gCAAE,MAAM;4BAErB,IAAI,CAAC,CAAC,MAAM,GAAG,KAAK,EAAE;gCACpB,WAAW,GAAG,CAAC,CAAC;gCAChB,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC;gCAClB,MAAM;6BACP;iCAAM;gCACL,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;gCACjB,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;6BAC3B;yBACF;qBACF;iBACF;qBAAM;oBACL,IAAI,QAAQ,EAAE;wBACZ,WAAW,IAAI,GAAG,CAAC;wBACnB,MAAM,EAAE,CAAC;qBACV;oBAED,WAAW,IAAI,IAAI,CAAC;oBACpB,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC;iBACvB;gBAED,iBAAiB,GAAG,KAAK,CAAC;aAC3B;YAED,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;SACxB;QAED,IAAI,UAAU,CAAC,WAAW,CAAC;YAAE,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAC1D,CAAC,CAAC,CAAC;IAEH,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC7B,CAAC;AAhGD,gCAgGC","sources":["webpack://snyk/./src/cli/commands/help/index.ts","webpack://snyk/./src/cli/commands/help/markdown-renderer.ts","webpack://snyk/./src/cli/commands/help/reflow-text.ts"],"sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\nimport { renderMarkdown } from './markdown-renderer';\n\nconst DEFAULT_HELP = 'snyk';\n\nfunction readHelpFile(filename: string): string {\n const file = fs.readFileSync(filename, 'utf8');\n return renderMarkdown(file);\n}\n\nexport default async function help(item?: string | boolean): Promise<string> {\n if (!item || item === true || typeof item !== 'string' || item === 'help') {\n item = DEFAULT_HELP;\n }\n\n // cleanse the filename to only contain letters\n // aka: /\\W/g but figured this was easier to read\n item = item.replace(/[^a-z-]/gi, '');\n\n try {\n const filename = path.resolve(\n __dirname,\n '../../help/commands-md', // this is a relative path from the webpack dist directory\n item === DEFAULT_HELP ? `${DEFAULT_HELP}.md` : `snyk-${item}.md`,\n );\n return readHelpFile(filename);\n } catch (error) {\n const filename = path.resolve(\n __dirname,\n '../../help/commands-md',\n `${DEFAULT_HELP}.md`,\n );\n return readHelpFile(filename);\n }\n}\n","import { marked } from 'marked';\nimport chalk from 'chalk';\nimport { reflowText } from './reflow-text';\n\n// stateful variable to control left-padding by header level\nlet currentHeader = 1;\nconst listItemSeparator = 'LISTITEMSEPARATOR'; // Helper string for rendering ListItems\n\n/**\n * @description get padding spaces depending on the last header level used\n * @returns string\n */\nfunction getLeftTextPadding(): string {\n return ' '.repeat(currentHeader);\n}\n\n/**\n * @description Reads current terminal width if available to limit column width for text-reflowing\n * @returns {number}\n */\nconst defaultMaximumLineWidth = 100;\nfunction getIdealTextWidth(maximumLineWidth = defaultMaximumLineWidth): number {\n if (typeof process.stdout.columns === 'number') {\n if (process.stdout.columns < maximumLineWidth) {\n return process.stdout.columns - getLeftTextPadding().length - 5;\n }\n }\n return maximumLineWidth - getLeftTextPadding().length;\n}\n\n// Marked custom renderer class\nconst renderer = {\n em(text) {\n return chalk.italic(text);\n },\n strong(text) {\n return chalk.bold(text);\n },\n link(href, title, text) {\n const renderedLink = chalk.bold.blueBright(href);\n if (text && text !== href) {\n return `${text} ${renderedLink}`;\n }\n return renderedLink;\n },\n blockquote(quote) {\n return quote;\n },\n list(body, ordered, start) {\n return (\n body\n .split(listItemSeparator)\n .map((listItem, listItemIndex) => {\n const bulletPoint = ordered ? `${listItemIndex + start}. ` : '- ';\n return reflowText(listItem, getIdealTextWidth())\n .split('\\n')\n .map((listItemLine, listItemLineIndex) => {\n if (!listItemLine) {\n return '';\n }\n return `${getLeftTextPadding()}${\n listItemLineIndex === 0 ? bulletPoint : ' '\n }${listItemLine}`;\n })\n .join('\\n');\n })\n .join('\\n') + '\\n'\n );\n },\n listitem(text) {\n return text + listItemSeparator;\n },\n paragraph(text) {\n return (\n reflowText(text, getIdealTextWidth())\n .split('\\n')\n .map((s) => getLeftTextPadding() + chalk.reset() + s)\n .join('\\n') + '\\n\\n'\n );\n },\n codespan(text) {\n return chalk.italic.blueBright(`${text}`);\n },\n code(code) {\n return code + '\\n';\n },\n heading(text, level) {\n currentHeader = level;\n let coloring;\n switch (level) {\n case 1:\n coloring = chalk.bold.underline;\n break;\n case 3:\n case 4:\n coloring = chalk;\n break;\n default:\n coloring = chalk.bold;\n break;\n }\n return `${' '.repeat(level === 1 ? 0 : currentHeader - 2)}${coloring(\n text,\n )}\\n`;\n },\n};\n\nmarked.use({ renderer });\nmarked.setOptions({\n mangle: false,\n});\n\nconst htmlUnescapes = {\n '&': '&',\n '<': '<',\n '>': '>',\n '"': '\"',\n ''': \"'\",\n '`': '`',\n};\n\n/**\n * @description Replace HTML entities with their non-encoded variant\n * @param {string} text\n * @returns {string}\n */\nfunction unescape(text: string): string {\n Object.entries(htmlUnescapes).forEach(([escapedChar, unescapedChar]) => {\n const escapedCharRegExp = new RegExp(escapedChar, 'g');\n text = text.replace(escapedCharRegExp, unescapedChar);\n });\n return text;\n}\n\nexport function renderMarkdown(markdown: string): string {\n return unescape(marked.parse(markdown));\n}\n","/**\nCode in this file is adapted from mikaelbr/marked-terminal\nhttps://github.com/mikaelbr/marked-terminal/blob/7501b8bb24a5ed52ec7d9114d4aeefa14f1bf5e6/index.js#L234-L330\n\n\nMIT License\n\nCopyright (c) 2017 Mikael Brevik\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n */\n\n// Compute length of str not including ANSI escape codes.\n// See http://en.wikipedia.org/wiki/ANSI_escape_code#graphics\nfunction textLength(str: string): number {\n // eslint-disable-next-line no-control-regex\n return str.replace(/\\u001b\\[(?:\\d{1,3})(?:;\\d{1,3})*m/g, '').length;\n}\n\n// Munge \\n's and spaces in \"text\" so that the number of\n// characters between \\n's is less than or equal to \"width\".\nexport function reflowText(text: string, width: number): string {\n const HARD_RETURN = '\\r|\\n';\n const HARD_RETURN_GFM_RE = new RegExp(HARD_RETURN + '|<br />');\n\n const splitRe = HARD_RETURN_GFM_RE;\n const sections = text.split(splitRe);\n const reflowed = [] as string[];\n\n sections.forEach((section) => {\n // Split the section by escape codes so that we can\n // deal with them separately.\n // eslint-disable-next-line no-control-regex\n const fragments = section.split(/(\\u001b\\[(?:\\d{1,3})(?:;\\d{1,3})*m)/g);\n let column = 0;\n let currentLine = '';\n let lastWasEscapeChar = false;\n\n while (fragments.length) {\n const fragment = fragments[0];\n\n if (fragment === '') {\n fragments.splice(0, 1);\n lastWasEscapeChar = false;\n continue;\n }\n\n // This is an escape code - leave it whole and\n // move to the next fragment.\n if (!textLength(fragment)) {\n currentLine += fragment;\n fragments.splice(0, 1);\n lastWasEscapeChar = true;\n continue;\n }\n\n const words = fragment.split(/[ \\t\\n]+/);\n\n for (let i = 0; i < words.length; i++) {\n let word = words[i];\n let addSpace = column != 0;\n if (lastWasEscapeChar) addSpace = false;\n\n // If adding the new word overflows the required width\n if (column + word.length > width) {\n if (word.length <= width) {\n // If the new word is smaller than the required width\n // just add it at the beginning of a new line\n reflowed.push(currentLine);\n currentLine = word;\n column = word.length;\n } else {\n // If the new word is longer than the required width\n // split this word into smaller parts.\n const w = word.substr(0, width - column);\n if (addSpace) currentLine += ' ';\n currentLine += w;\n reflowed.push(currentLine);\n currentLine = '';\n column = 0;\n\n word = word.substr(w.length);\n while (word.length) {\n const w = word.substr(0, width);\n\n if (!w.length) break;\n\n if (w.length < width) {\n currentLine = w;\n column = w.length;\n break;\n } else {\n reflowed.push(w);\n word = word.substr(width);\n }\n }\n }\n } else {\n if (addSpace) {\n currentLine += ' ';\n column++;\n }\n\n currentLine += word;\n column += word.length;\n }\n\n lastWasEscapeChar = false;\n }\n\n fragments.splice(0, 1);\n }\n\n if (textLength(currentLine)) reflowed.push(currentLine);\n });\n\n return reflowed.join('\\n');\n}\n"],"names":[],"sourceRoot":""}
|
|
1
|
+
{"version":3,"file":"85.index.js","mappings":";;;;;;;;;;AAAA,sCAAyB;AACzB,wCAA6B;AAC7B,uDAAqD;AAErD,MAAM,YAAY,GAAG,MAAM,CAAC;AAE5B,SAAS,YAAY,CAAC,QAAgB;IACpC,MAAM,IAAI,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAC/C,OAAO,kCAAc,CAAC,IAAI,CAAC,CAAC;AAC9B,CAAC;AAEc,KAAK,UAAU,IAAI,CAAC,IAAuB;IACxD,IAAI,CAAC,IAAI,IAAI,IAAI,KAAK,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,MAAM,EAAE;QACzE,IAAI,GAAG,YAAY,CAAC;KACrB;IAED,+CAA+C;IAC/C,iDAAiD;IACjD,IAAI,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BACvB;gBAED,iBAAiB,GAAG,KAAK,CAAC;aAC3B;YAED,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;SACxB;QAED,IAAI,UAAU,CAAC,WAAW,CAAC;YAAE,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAC1D,CAAC,CAAC,CAAC;IAEH,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC7B,CAAC;AAhGD,gCAgGC","sources":["webpack://snyk/./src/cli/commands/help/index.ts","webpack://snyk/./src/cli/commands/help/markdown-renderer.ts","webpack://snyk/./src/cli/commands/help/reflow-text.ts"],"sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\nimport { renderMarkdown } from './markdown-renderer';\n\nconst DEFAULT_HELP = 'snyk';\n\nfunction readHelpFile(filename: string): string {\n const file = fs.readFileSync(filename, 'utf8');\n return renderMarkdown(file);\n}\n\nexport default async function help(item?: string | boolean): Promise<string> {\n if (!item || item === true || typeof item !== 'string' || item === 'help') {\n item = DEFAULT_HELP;\n }\n\n // cleanse the filename to only contain letters\n // aka: /\\W/g but figured this was easier to read\n item = item.replace(/[^a-z-]/gi, '');\n\n try {\n const filename = path.resolve(\n __dirname,\n '../../help/commands-md', // this is a relative path from the webpack dist directory\n item === DEFAULT_HELP ? `${DEFAULT_HELP}.md` : `snyk-${item}.md`,\n );\n return readHelpFile(filename);\n } catch (error) {\n const filename = path.resolve(\n __dirname,\n '../../help/commands-md',\n `${DEFAULT_HELP}.md`,\n );\n return readHelpFile(filename);\n }\n}\n","import { marked } from 'marked';\nimport chalk from 'chalk';\nimport { reflowText } from './reflow-text';\n\n// stateful variable to control left-padding by header level\nlet currentHeader = 1;\nconst listItemSeparator = 'LISTITEMSEPARATOR'; // Helper string for rendering ListItems\n\n/**\n * @description get padding spaces depending on the last header level used\n * @returns string\n */\nfunction getLeftTextPadding(): string {\n return ' '.repeat(\n currentHeader === 1 || currentHeader === 2 ? 1 : currentHeader - 1,\n );\n}\n\n/**\n * @description Reads current terminal width if available to limit column width for text-reflowing\n * @returns {number}\n */\nconst defaultMaximumLineWidth = 100;\nfunction getIdealTextWidth(maximumLineWidth = defaultMaximumLineWidth): number {\n if (typeof process.stdout.columns === 'number') {\n if (process.stdout.columns < maximumLineWidth) {\n return process.stdout.columns - getLeftTextPadding().length - 5;\n }\n }\n return maximumLineWidth - getLeftTextPadding().length;\n}\n\n// Marked custom renderer class\nconst renderer = {\n em(text) {\n return chalk.italic(text);\n },\n strong(text) {\n return chalk.bold(text);\n },\n link(href, title, text) {\n const renderedLink = chalk.bold.blueBright(href);\n if (text && text !== href) {\n return `${text} ${renderedLink}`;\n }\n return renderedLink;\n },\n blockquote(quote) {\n return quote;\n },\n list(body, ordered, start) {\n return body\n .split(listItemSeparator)\n .map((listItem, listItemIndex) => {\n const bulletPoint = ordered ? `${listItemIndex + start}. ` : '- ';\n return reflowText(listItem, getIdealTextWidth())\n .split('\\n')\n .map((listItemLine, listItemLineIndex) => {\n if (!listItemLine) {\n return '';\n }\n return `${getLeftTextPadding()}${\n listItemLineIndex === 0 ? bulletPoint : ' '\n }${listItemLine}`;\n })\n .join('\\n');\n })\n .join('\\n');\n },\n listitem(text) {\n return text + listItemSeparator;\n },\n paragraph(text) {\n return (\n reflowText(text, getIdealTextWidth())\n .split('\\n')\n .map((s) => getLeftTextPadding() + chalk.reset() + s)\n .join('\\n') + '\\n'\n );\n },\n codespan(text) {\n return chalk.italic.blueBright(`${text}`);\n },\n code(code) {\n return code + '\\n';\n },\n heading(text, level) {\n currentHeader = level;\n let coloring;\n switch (level) {\n case 1:\n coloring = chalk.bold.underline;\n break;\n case 3:\n case 4:\n coloring = chalk;\n break;\n default:\n coloring = chalk.bold;\n break;\n }\n return `\\n${' '.repeat(level === 1 ? 0 : currentHeader - 2)}${coloring(\n text,\n )}\\n`;\n },\n};\n\nmarked.use({ renderer });\nmarked.setOptions({\n mangle: false,\n});\n\nconst htmlUnescapes = {\n '&': '&',\n '<': '<',\n '>': '>',\n '"': '\"',\n ''': \"'\",\n '`': '`',\n};\n\n/**\n * @description Replace HTML entities with their non-encoded variant\n * @param {string} text\n * @returns {string}\n */\nfunction unescape(text: string): string {\n Object.entries(htmlUnescapes).forEach(([escapedChar, unescapedChar]) => {\n const escapedCharRegExp = new RegExp(escapedChar, 'g');\n text = text.replace(escapedCharRegExp, unescapedChar);\n });\n return text;\n}\n\nexport function renderMarkdown(markdown: string): string {\n return unescape(marked.parse(markdown));\n}\n","/**\nCode in this file is adapted from mikaelbr/marked-terminal\nhttps://github.com/mikaelbr/marked-terminal/blob/7501b8bb24a5ed52ec7d9114d4aeefa14f1bf5e6/index.js#L234-L330\n\n\nMIT License\n\nCopyright (c) 2017 Mikael Brevik\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n */\n\n// Compute length of str not including ANSI escape codes.\n// See http://en.wikipedia.org/wiki/ANSI_escape_code#graphics\nfunction textLength(str: string): number {\n // eslint-disable-next-line no-control-regex\n return str.replace(/\\u001b\\[(?:\\d{1,3})(?:;\\d{1,3})*m/g, '').length;\n}\n\n// Munge \\n's and spaces in \"text\" so that the number of\n// characters between \\n's is less than or equal to \"width\".\nexport function reflowText(text: string, width: number): string {\n const HARD_RETURN = '\\r|\\n';\n const HARD_RETURN_GFM_RE = new RegExp(HARD_RETURN + '|<br />');\n\n const splitRe = HARD_RETURN_GFM_RE;\n const sections = text.split(splitRe);\n const reflowed = [] as string[];\n\n sections.forEach((section) => {\n // Split the section by escape codes so that we can\n // deal with them separately.\n // eslint-disable-next-line no-control-regex\n const fragments = section.split(/(\\u001b\\[(?:\\d{1,3})(?:;\\d{1,3})*m)/g);\n let column = 0;\n let currentLine = '';\n let lastWasEscapeChar = false;\n\n while (fragments.length) {\n const fragment = fragments[0];\n\n if (fragment === '') {\n fragments.splice(0, 1);\n lastWasEscapeChar = false;\n continue;\n }\n\n // This is an escape code - leave it whole and\n // move to the next fragment.\n if (!textLength(fragment)) {\n currentLine += fragment;\n fragments.splice(0, 1);\n lastWasEscapeChar = true;\n continue;\n }\n\n const words = fragment.split(/[ \\t\\n]+/);\n\n for (let i = 0; i < words.length; i++) {\n let word = words[i];\n let addSpace = column != 0;\n if (lastWasEscapeChar) addSpace = false;\n\n // If adding the new word overflows the required width\n if (column + word.length > width) {\n if (word.length <= width) {\n // If the new word is smaller than the required width\n // just add it at the beginning of a new line\n reflowed.push(currentLine);\n currentLine = word;\n column = word.length;\n } else {\n // If the new word is longer than the required width\n // split this word into smaller parts.\n const w = word.substr(0, width - column);\n if (addSpace) currentLine += ' ';\n currentLine += w;\n reflowed.push(currentLine);\n currentLine = '';\n column = 0;\n\n word = word.substr(w.length);\n while (word.length) {\n const w = word.substr(0, width);\n\n if (!w.length) break;\n\n if (w.length < width) {\n currentLine = w;\n column = w.length;\n break;\n } else {\n reflowed.push(w);\n word = word.substr(width);\n }\n }\n }\n } else {\n if (addSpace) {\n currentLine += ' ';\n column++;\n }\n\n currentLine += word;\n column += word.length;\n }\n\n lastWasEscapeChar = false;\n }\n\n fragments.splice(0, 1);\n }\n\n if (textLength(currentLine)) reflowed.push(currentLine);\n });\n\n return reflowed.join('\\n');\n}\n"],"names":[],"sourceRoot":""}
|
package/help/commands-md/snyk.md
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
# Snyk CLI
|
|
2
2
|
|
|
3
|
-
Snyk CLI scans and monitors your projects for security vulnerabilities
|
|
3
|
+
Snyk CLI scans and monitors your projects for security vulnerabilities.
|
|
4
4
|
|
|
5
|
-
Visit https://snyk.io for more details
|
|
5
|
+
Visit https://snyk.io for more details.
|
|
6
6
|
|
|
7
7
|
## Not sure where to start?
|
|
8
8
|
|
|
9
|
-
1. Authenticate with `snyk auth
|
|
10
|
-
2. Test your local project with `snyk test
|
|
11
|
-
3. Get alerted for new vulnerabilities with `snyk monitor
|
|
9
|
+
1. Authenticate with `snyk auth`.
|
|
10
|
+
2. Test your local project with `snyk test`.
|
|
11
|
+
3. Get alerted for new vulnerabilities with `snyk monitor`.
|
|
12
12
|
|
|
13
13
|
## Available commands
|
|
14
14
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "snyk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.775.0",
|
|
4
4
|
"description": "snyk library and cli utility",
|
|
5
5
|
"files": [
|
|
6
6
|
"help/commands-md",
|
|
@@ -87,5 +87,5 @@
|
|
|
87
87
|
"registry": "https://registry.npmjs.org/",
|
|
88
88
|
"access": "public"
|
|
89
89
|
},
|
|
90
|
-
"gitHead": "
|
|
90
|
+
"gitHead": "c6609aef8a0c90c20f4774ddcffd6a140a024c97"
|
|
91
91
|
}
|