From cf0593813cd7e25aa60d30c32aa197fcb432efac Mon Sep 17 00:00:00 2001 From: Ayush Sharma Date: Sat, 25 Aug 2018 13:42:18 +0200 Subject: [PATCH] fix: removes asciidoctor.js support (#884) (#947) --- package.json | 1 - src/lib/utils.js | 12 ------- .../unit/api/__snapshots__/utils.spec.js.snap | 33 +------------------ test/unit/api/utils.spec.js | 15 +-------- yarn.lock | 19 +---------- 5 files changed, 3 insertions(+), 77 deletions(-) diff --git a/package.json b/package.json index ab68bb6ac..b8e1bc98d 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,6 @@ "@verdaccio/local-storage": "1.1.3", "@verdaccio/streams": "1.0.0", "JSONStream": "1.3.3", - "asciidoctor.js": "1.5.6", "async": "2.6.1", "body-parser": "1.18.3", "bunyan": "1.8.12", diff --git a/src/lib/utils.js b/src/lib/utils.js index 6c4da641d..3c7b818f3 100644 --- a/src/lib/utils.js +++ b/src/lib/utils.js @@ -5,7 +5,6 @@ import assert from 'assert'; import semver from 'semver'; import YAML from 'js-yaml'; import URL from 'url'; -import asciidoctor from 'asciidoctor.js'; import createError from 'http-errors'; import marked from 'marked'; @@ -521,17 +520,6 @@ function addGravatarSupport(pkgInfo: Object): Object { * @return {String} converted html template */ function parseReadme(packageName: string, readme: string): string { - const asciiRegex = /^\n?(?:={1,5}[ \t]+\S|[^#].*(\n(?!#+[ \t]+\S).*){0,8}\n={1,5}[ \t]+\S)/; - const docTypeIdentifier = new RegExp(asciiRegex, 'g'); - // asciidoc - if (docTypeIdentifier.test(readme)) { - const ascii = asciidoctor(); - return ascii.convert(readme, { - safe: 'safe', - attributes: {showtitle: true, icons: 'font'}, - }); - } - if (readme) { return marked(readme); } diff --git a/test/unit/api/__snapshots__/utils.spec.js.snap b/test/unit/api/__snapshots__/utils.spec.js.snap index 2a7630c03..9a591808d 100644 --- a/test/unit/api/__snapshots__/utils.spec.js.snap +++ b/test/unit/api/__snapshots__/utils.spec.js.snap @@ -1,37 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Utilities parseReadme should pass for ascii text to html template 1`] = ` -"

Hello, AsciiDoc!

-
-
-
-

An introduction to AsciiDoc.

-
-
-
-
-

First Section

-
-
-
    -
  • -

    item 1

    -
  • -
  • -

    item 2

    -
  • -
-
-
-
-
puts \\"Hello, World!\\"
-
-
-
-
" -`; - -exports[`Utilities parseReadme should pass for makrdown text to html template 1`] = ` +exports[`Utilities parseReadme should parse makrdown text to html template 1`] = ` "

Project Title

One Paragraph of project description goes here

Getting Started

diff --git a/test/unit/api/utils.spec.js b/test/unit/api/utils.spec.js index 7d0ac24bb..80ba8e31b 100644 --- a/test/unit/api/utils.spec.js +++ b/test/unit/api/utils.spec.js @@ -132,16 +132,7 @@ describe('Utilities', () => { }); describe('parseReadme', () => { - test('should pass for ascii text to html template', () => { - const ascii = '= AsciiDoc'; - - expect(parseReadme('testPackage', ascii)).toEqual('

AsciiDoc

\n'); - expect( - parseReadme('testPackage', String(readmeFile('ascii.adoc'))) - ).toMatchSnapshot(); - }); - - test('should pass for makrdown text to html template', () => { + test('should parse makrdown text to html template', () => { const markdown = '# markdown'; expect(parseReadme('testPackage', markdown)).toEqual( '

markdown

\n' @@ -154,7 +145,6 @@ describe('Utilities', () => { test('should pass for conversion of non-ascii to markdown text', () => { const simpleText = 'simple text'; const randomText = '%%%%%**##=='; - const randomTextNonAscii = 'simple text \n = ascii'; const randomTextMarkdown = 'simple text \n # markdown'; expect(parseReadme('testPackage', randomText)).toEqual( @@ -163,9 +153,6 @@ describe('Utilities', () => { expect(parseReadme('testPackage', simpleText)).toEqual( '

simple text

\n' ); - expect(parseReadme('testPackage', randomTextNonAscii)).toEqual( - '

simple text \n = ascii

\n' - ); expect(parseReadme('testPackage', randomTextMarkdown)).toEqual( '

simple text

\n

markdown

\n' ); diff --git a/yarn.lock b/yarn.lock index 4390eae05..98c2c95d7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -655,12 +655,6 @@ asap@~2.0.3: version "2.0.6" resolved "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz#e50347611d7e690943208bbdafebcbc2fb866d46" -asciidoctor.js@1.5.6: - version "1.5.6" - resolved "https://registry.npmjs.org/asciidoctor.js/-/asciidoctor.js-1.5.6.tgz#12f4810c62ea47867da145e819fc93b0674b5431" - dependencies: - opal-runtime "1.0.3" - asn1.js@^4.0.0: version "4.10.1" resolved "https://registry.npmjs.org/asn1.js/-/asn1.js-4.10.1.tgz#b9c2bf5805f1e64aadeed6df3a2bfafb5a73f5a0" @@ -4417,7 +4411,7 @@ glob-to-regexp@^0.3.0: version "0.3.0" resolved "https://registry.npmjs.org/glob-to-regexp/-/glob-to-regexp-0.3.0.tgz#8c5a1494d2066c570cc3bfe4496175acc4d502ab" -glob@6.0.4, glob@^6.0.1, glob@^6.0.4: +glob@^6.0.1, glob@^6.0.4: version "6.0.4" resolved "https://registry.npmjs.org/glob/-/glob-6.0.4.tgz#0f08860f6a155127b2fadd4f9ce24b1aab6e4d22" dependencies: @@ -7085,13 +7079,6 @@ onetime@^2.0.0: dependencies: mimic-fn "^1.0.0" -opal-runtime@1.0.3: - version "1.0.3" - resolved "https://registry.npmjs.org/opal-runtime/-/opal-runtime-1.0.3.tgz#e81e5c2a2568bbb0b05743b427d035dd901485b7" - dependencies: - glob "6.0.4" - xmlhttprequest "1.8.0" - opener@^1.4.3: version "1.4.3" resolved "https://registry.npmjs.org/opener/-/opener-1.4.3.tgz#5c6da2c5d7e5831e8ffa3964950f8d6674ac90b8" @@ -10602,10 +10589,6 @@ xml-name-validator@^3.0.0: version "3.0.0" resolved "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-3.0.0.tgz#6ae73e06de4d8c6e47f9fb181f78d648ad457c6a" -xmlhttprequest@1.8.0: - version "1.8.0" - resolved "https://registry.npmjs.org/xmlhttprequest/-/xmlhttprequest-1.8.0.tgz#67fe075c5c24fef39f9d65f5f7b7fe75171968fc" - xregexp@4.0.0: version "4.0.0" resolved "https://registry.npmjs.org/xregexp/-/xregexp-4.0.0.tgz#e698189de49dd2a18cc5687b05e17c8e43943020"