From 404ae9ed8fc1180b704829888daf39a1f8b92225 Mon Sep 17 00:00:00 2001 From: Josh Gross Date: Fri, 26 Jun 2020 03:43:50 +0000 Subject: [PATCH] =?UTF-8?q?Update=20comment=20structure=20=20=F0=9F=8F=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 5 ++++- dist/book.js | 48 ------------------------------------------------ dist/index.js | 6 +++--- dist/utils.js | 29 ----------------------------- src/book.ts | 6 +++--- tsconfig.json | 2 +- 6 files changed, 11 insertions(+), 85 deletions(-) delete mode 100644 dist/book.js delete mode 100644 dist/utils.js diff --git a/.gitignore b/.gitignore index c9b6b51..f9467fe 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,7 @@ node_modules # eslint cache -.eslintcache \ No newline at end of file +.eslintcache + +# tsc +lib \ No newline at end of file diff --git a/dist/book.js b/dist/book.js deleted file mode 100644 index 724d254..0000000 --- a/dist/book.js +++ /dev/null @@ -1,48 +0,0 @@ -"use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.generateGuestbook = void 0; -const fs = __importStar(require("fs")); -const startComment = ""; -const endComment = ""; -const commentSectionRegex = new RegExp(`${startComment}[\\s\\S]+${endComment}`); -function getReadme(path) { - return fs.readFileSync(path).toString(); -} -function writeReadme(path, content) { - fs.writeFileSync(path, content); -} -function commentToMarkdown(comment) { - return `[@${comment.user}](https://github.com/${comment.user}) said: -> ${comment.text} -[src](${comment.url})`; -} -function createGuestbookList(comments) { - return comments.map(commentToMarkdown).join("\n\n---\n\n"); -} -function generateGuestbook(path, comments) { - const guestbook = getReadme(path); - const guestbookList = createGuestbookList(comments); - const guestbookContent = `${startComment}\n${guestbookList}\n${endComment}`; - const updatedGuestbook = guestbook.replace(commentSectionRegex, guestbookContent); - writeReadme(path, updatedGuestbook); -} -exports.generateGuestbook = generateGuestbook; diff --git a/dist/index.js b/dist/index.js index 17418d1..c426998 100644 --- a/dist/index.js +++ b/dist/index.js @@ -9480,12 +9480,12 @@ function writeReadme(path, content) { fs.writeFileSync(path, content); } function commentToMarkdown(comment) { - return `[@${comment.user}](https://github.com/${comment.user}) said: -> ${comment.text} + return `> ${comment.text}\n +> -[@${comment.user}](https://github.com/${comment.user}) [src](${comment.url})`; } function createGuestbookList(comments) { - return comments.map(commentToMarkdown).join("\n\n---\n\n"); + return comments.map(commentToMarkdown).join("\n\n"); } function generateGuestbook(path, comments) { const guestbook = getReadme(path); diff --git a/dist/utils.js b/dist/utils.js deleted file mode 100644 index e5453db..0000000 --- a/dist/utils.js +++ /dev/null @@ -1,29 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.logInfo = void 0; -const ColorReset = "\x1b[0m"; -var TextEffect; -(function (TextEffect) { - TextEffect["Bright"] = "\u001B[1m"; - TextEffect["Dim"] = "\u001B[2m"; - TextEffect["Underscore"] = "\u001B[4m"; - TextEffect["Blink"] = "\u001B[5m"; - TextEffect["Reverse"] = "\u001B[7m"; - TextEffect["Hidden"] = "\u001B[8m"; -})(TextEffect || (TextEffect = {})); -var ForegroundColor; -(function (ForegroundColor) { - ForegroundColor["Black"] = "\u001B[30m"; - ForegroundColor["Red"] = "\u001B[31m"; - ForegroundColor["Green"] = "\u001B[32m"; - ForegroundColor["Yellow"] = "\u001B[33m"; - ForegroundColor["Blue"] = "\u001B[34m"; - ForegroundColor["Magenta"] = "\u001B[35m"; - ForegroundColor["Cyan"] = "\u001B[36m"; - ForegroundColor["White"] = "\u001B[37m"; -})(ForegroundColor || (ForegroundColor = {})); -function logInfo(message) { - const textFormat = `${TextEffect.Underscore}${ForegroundColor.Cyan}`; - console.log(`${textFormat}${message}${ColorReset}`); -} -exports.logInfo = logInfo; diff --git a/src/book.ts b/src/book.ts index 7feff4b..79ae5c8 100644 --- a/src/book.ts +++ b/src/book.ts @@ -15,13 +15,13 @@ function writeReadme(path: string, content: string): void { } function commentToMarkdown(comment: Comment): string { - return `[@${comment.user}](https://github.com/${comment.user}) said: -> ${comment.text} + return `> ${comment.text}\n +> -[@${comment.user}](https://github.com/${comment.user}) [src](${comment.url})`; } function createGuestbookList(comments: Comment[]): string { - return comments.map(commentToMarkdown).join("\n\n---\n\n"); + return comments.map(commentToMarkdown).join("\n\n"); } export function generateGuestbook(path: string, comments: Comment[]): void { diff --git a/tsconfig.json b/tsconfig.json index d6fd2c9..02a91de 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,7 +3,7 @@ /* Basic Options */ "target": "ES2020", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */ "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ - "outDir": "./dist", /* Redirect output structure to the directory. */ + "outDir": "./lib", /* Redirect output structure to the directory. */ "rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ /* Strict Type-Checking Options */