diff --git a/package-lock.json b/package-lock.json index 0eabbef8..a337a886 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3918,7 +3918,6 @@ "version": "2.3.6", "resolved": "https://registry.npmjs.org/@types/hast/-/hast-2.3.6.tgz", "integrity": "sha512-47rJE80oqPmFdVDCD7IheXBrVdwuBgsYwoczFvKmwfo2Mzsnt+V9OONsYauFmICb6lQPpCuXYJWejBNs4pDJRg==", - "dev": true, "dependencies": { "@types/unist": "^2" } @@ -4096,8 +4095,7 @@ "node_modules/@types/unist": { "version": "2.0.8", "resolved": "https://registry.npmjs.org/@types/unist/-/unist-2.0.8.tgz", - "integrity": "sha512-d0XxK3YTObnWVp6rZuev3c49+j4Lo8g4L1ZRm9z5L0xpoZycUPshHgczK5gsUMaZOstjVYYi09p5gYvUtfChYw==", - "dev": true + "integrity": "sha512-d0XxK3YTObnWVp6rZuev3c49+j4Lo8g4L1ZRm9z5L0xpoZycUPshHgczK5gsUMaZOstjVYYi09p5gYvUtfChYw==" }, "node_modules/@types/uslug": { "version": "1.0.2", @@ -7903,6 +7901,31 @@ "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==", "dev": true }, + "node_modules/emphasize": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/emphasize/-/emphasize-6.0.0.tgz", + "integrity": "sha512-lVh/I8dHqIel6kq4yIRuSsjl4sAQOKpSuBR36V5usLGNP2oehnOwX09742xx16baa7eAahF9v52xO83yzT0NdQ==", + "dependencies": { + "chalk": "^5.0.0", + "highlight.js": "~11.6.0", + "lowlight": "~2.7.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/emphasize/node_modules/chalk": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.3.0.tgz", + "integrity": "sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w==", + "engines": { + "node": "^12.17.0 || ^14.13 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, "node_modules/encode-registry": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/encode-registry/-/encode-registry-3.0.1.tgz", @@ -9587,7 +9610,6 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/fault/-/fault-2.0.1.tgz", "integrity": "sha512-WtySTkS4OKev5JtpHXnib4Gxiurzh5NCGvWrFaZ34m6JehfTUhKZvn9njTfw48t6JumVQOmrKqpmGcdwxnhqBQ==", - "dev": true, "dependencies": { "format": "^0.2.0" }, @@ -9877,7 +9899,6 @@ "version": "0.2.2", "resolved": "https://registry.npmjs.org/format/-/format-0.2.2.tgz", "integrity": "sha512-wzsgA6WOq+09wrU1tsJ09udeR/YZRaeArL9e1wPbFg3GG2yDnC2ldKpxs4xunpFF9DgqCqOIra3bc1HWrJ37Ww==", - "dev": true, "engines": { "node": ">=0.4.x" } @@ -11226,6 +11247,14 @@ "url": "https://opencollective.com/unified" } }, + "node_modules/highlight.js": { + "version": "11.6.0", + "resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-11.6.0.tgz", + "integrity": "sha512-ig1eqDzJaB0pqEvlPVIpSSyMaO92bH1N2rJpLMN/nX396wTpDA4Eq0uK+7I/2XG17pFaaKE0kjV/XPeGt7Evjw==", + "engines": { + "node": ">=12.0.0" + } + }, "node_modules/hosted-git-info": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-7.0.1.tgz", @@ -14435,6 +14464,20 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/lowlight": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/lowlight/-/lowlight-2.7.0.tgz", + "integrity": "sha512-RRdrHalFfjpxL91ITTX7KhJYH3QmX5bW9Uie2D2E5GPIR3XBYDYhScBjE291ewFZkStz/k2PN9KC+8deNLiI3Q==", + "dependencies": { + "@types/hast": "^2.0.0", + "fault": "^2.0.0", + "highlight.js": "~11.6.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, "node_modules/lru-cache": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", @@ -23030,6 +23073,7 @@ "@readme/openapi-parser": "^2.4.0", "chalk": "^5.3.0", "commander": "^11.1.0", + "emphasize": "^6.0.0", "execa": "^8.0.1", "figures": "^5.0.0", "httpsnippet-client-api": "file:../httpsnippet-client-api", diff --git a/packages/api/package.json b/packages/api/package.json index c73ef1ba..f97b0093 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -47,6 +47,7 @@ "@readme/openapi-parser": "^2.4.0", "chalk": "^5.3.0", "commander": "^11.1.0", + "emphasize": "^6.0.0", "execa": "^8.0.1", "figures": "^5.0.0", "httpsnippet-client-api": "file:../httpsnippet-client-api", diff --git a/packages/api/src/commands/install.ts b/packages/api/src/commands/install.ts index fc1b2878..4ac44094 100644 --- a/packages/api/src/commands/install.ts +++ b/packages/api/src/commands/install.ts @@ -2,6 +2,7 @@ import type { SupportedLanguage } from '../codegen/factory.js'; import chalk from 'chalk'; import { Command, Option } from 'commander'; +import { emphasize } from 'emphasize'; import figures from 'figures'; import Oas from 'oas'; import ora from 'ora'; @@ -222,10 +223,11 @@ cmd const exampleSnippet = await getExampleCodeSnippet(oas, identifier); if (exampleSnippet) { logger(''); - logger("Here's an example code snippet you can try out:"); + logger(chalk.bold("👇 Here's an example code snippet you can try out 👇")); logger(''); - logger(chalk.green(exampleSnippet)); + logger(emphasize.highlight(language, exampleSnippet).value); } + logger(''); }) .addHelpText( 'after',