0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-30 22:34:10 -05:00

fix: fix missing readme on npm7 (#2010)

* fix: fix missing readme on npm7

* test: update test for readme
This commit is contained in:
Juan Picado 2020-11-28 22:57:52 +01:00 committed by GitHub
parent cc5d786133
commit f4a85af20d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 69 additions and 2 deletions

View file

@ -183,10 +183,11 @@ export function publishPackage(storage: IStorageHandler, config: Config, auth: I
}
const versionToPublish = Object.keys(versions)[0];
const versionMetadataToPublish = versions[versionToPublish];
versions[versionToPublish].readme = _.isNil(metadataCopy.readme) === false ? String(metadataCopy.readme) : '';
versionMetadataToPublish.readme = _.isNil(versionMetadataToPublish.readme) === false ? String(versionMetadataToPublish.readme) : '';
createVersion(versionToPublish, versions[versionToPublish], function(error) {
createVersion(versionToPublish, versionMetadataToPublish, function(error) {
if (error) {
return next(error);
}

View file

@ -0,0 +1,57 @@
{
"_id": "readme-test-npm6",
"name": "readme-test-npm6",
"description": "",
"dist-tags": {
"foo": "0.0.0",
"latest": "0.0.0"
},
"versions": {
"0.0.0": {
"name": "test-readme",
"version": "0.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": ""
},
"author": "",
"license": "ISC",
"_id": "test-readme@0.0.0",
"dist": {
"shasum": "8ee7331cbc641581b1a8cecd9d38d744a8feb863",
"tarball": "http:\/\/localhost:1234\/test-readme\/-\/test-readme-0.0.0.tgz"
},
"_from": ".",
"_npmVersion": "1.3.1",
"_npmUser": {
"name": "alex",
"email": "user@domain.com"
},
"maintainers": [
{
"name": "juan",
"email": "user@domain.com"
}
]
}
},
"readme": "this is a readme",
"maintainers": [
{
"name": "juan",
"email": "user@domain.com"
}
],
"_attachments": {
"test-readme-0.0.0.tgz": {
"content_type": "application\/octet-stream",
"data": "H4sIAAAAAAAAA+2TsW7CMBCGM\/spTh6YKHUSIJLXqkPnrixWcIMLsS3btCDEu\/fs0Ba1SFVVVISUP8Odzqf\/zlY+K+qlaOSt7eLo2RudnVmMsel4DBjzasKOY1JZlJDlRVkU5aSspnnG8pIVOZ6fe5FTWvsgHK7yV5\/uLvARr0Q7qkUrKadB+mCXzY2Wr9q2TjZ0SF+k88poPGUj\/LAyl752yoauioVWqJgpPZcb\/Hmw0jV4ynfJEw9lvTAwo\/fOGcdBG4h18FbW6knJ+YzCYAByowLkdD+kTlrjVTBumzy2Nq7XqIDea7eKY7FJrMPCuG6Hlaql9rHr4fGO7i\/9pFcl+4X\/rWhX557xA\/9FVZ3gv+j5\/w9F+jl8g58c0OeQyCdH3HOglETsObxTTw7McwLJClt+wzz5JD45IPEcEHjMEfg0r8M9pQfaOSDs5NLP16tXr15XqzeJD6m5AAwAAA==",
"length": 352
}
}
}

View file

@ -21,6 +21,7 @@
},
"author": "",
"license": "ISC",
"readme": "this is a readme",
"_id": "test-readme@0.0.0",
"dist": {
"shasum": "8ee7331cbc641581b1a8cecd9d38d744a8feb863",

View file

@ -2,6 +2,7 @@ import {DEFAULT_NO_README, HTTP_STATUS} from '../../../src/lib/constants';
import pkgReadmeJSON from './pkg-readme.json';
import pkgNoReadmeJSON from './pkg-no-readme.json';
import pkgNoReadmeJSONOldFormat from './pkg-readme-npm6.json';
export default function (server, server2) {
@ -9,12 +10,15 @@ export default function (server, server2) {
const README_PKG1 = 'readme-test';
const README_PKG2 = 'readme-test-no-readme';
const README_MESSAGE = 'this is a readme';
const README_PKG3 = 'readme-test-npm6';
beforeAll(async function() {
await server.putPackage('readme-test', pkgReadmeJSON)
.status(HTTP_STATUS.CREATED);
await server.putPackage(README_PKG2, pkgNoReadmeJSON)
.status(HTTP_STATUS.CREATED);
await server.putPackage(README_PKG3, pkgNoReadmeJSONOldFormat)
.status(HTTP_STATUS.CREATED);
});
test('add pkg', () => {});
@ -41,6 +45,10 @@ export default function (server, server2) {
return matchReadme(server, README_PKG2, DEFAULT_NO_README);
});
test('should fetch found readme special case for npm6', () => {
return matchReadme(server, README_PKG3, DEFAULT_NO_README);
});
test('should fetch not found readme package on local server1', () => {
return matchReadme(server2, README_PKG2, DEFAULT_NO_README);
});