@verdaccio/web 6.0.0-6-next.18 → 6.0.0-6-next.22
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/CHANGELOG.md +95 -0
- package/build/api/package.d.ts +1 -1
- package/build/api/package.js +18 -22
- package/build/api/package.js.map +1 -1
- package/build/api/readme.d.ts +1 -1
- package/build/api/readme.js +9 -9
- package/build/api/readme.js.map +1 -1
- package/build/api/search.js +3 -3
- package/build/api/search.js.map +1 -1
- package/build/api/sidebar.d.ts +1 -1
- package/build/api/sidebar.js +17 -13
- package/build/api/sidebar.js.map +1 -1
- package/build/api/user.d.ts +1 -1
- package/build/api/user.js +9 -9
- package/build/api/user.js.map +1 -1
- package/build/middleware/render-web.js +9 -9
- package/build/middleware/render-web.js.map +1 -1
- package/build/middleware/security.js +5 -5
- package/build/middleware/security.js.map +1 -1
- package/build/middleware/web-api.d.ts +1 -1
- package/build/middleware/web-api.js +6 -6
- package/build/middleware/web-api.js.map +1 -1
- package/build/renderHTML.js +16 -16
- package/build/renderHTML.js.map +1 -1
- package/build/template.js +2 -2
- package/build/template.js.map +1 -1
- package/build/utils/web-utils.d.ts +1 -2
- package/build/utils/web-utils.js +5 -71
- package/build/utils/web-utils.js.map +1 -1
- package/build/web-middleware.js.map +1 -1
- package/package.json +20 -22
- package/src/api/package.ts +6 -7
- package/src/api/readme.ts +5 -5
- package/src/api/search.ts +6 -4
- package/src/api/sidebar.ts +7 -7
- package/src/api/user.ts +9 -9
- package/src/middleware/render-web.ts +5 -4
- package/src/middleware/security.ts +1 -1
- package/src/middleware/web-api.ts +7 -6
- package/src/renderHTML.ts +5 -4
- package/src/template.ts +3 -1
- package/src/utils/web-utils.ts +3 -55
- package/src/web-middleware.ts +1 -0
- package/test/api.packages.test.ts +3 -1
- package/test/api.readme.test.ts +2 -1
- package/test/api.search.test.ts +3 -2
- package/test/api.sidebar.test.ts +2 -1
- package/test/api.user.test.ts +3 -1
- package/test/helper.ts +7 -5
- package/test/render.test.ts +3 -1
- package/test/template.test.ts +1 -0
- package/test/utils.spec.ts +1 -209
- package/build/utils/user.d.ts +0 -5
- package/build/utils/user.js +0 -34
- package/build/utils/user.js.map +0 -1
- package/src/utils/user.ts +0 -37
package/src/api/search.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import buildDebug from 'debug';
|
|
2
|
-
import { SearchInstance } from '@verdaccio/store';
|
|
3
|
-
import { DIST_TAGS } from '@verdaccio/commons-api';
|
|
4
2
|
import { Router } from 'express';
|
|
5
|
-
|
|
3
|
+
|
|
6
4
|
import { IAuth } from '@verdaccio/auth';
|
|
5
|
+
import { DIST_TAGS } from '@verdaccio/core';
|
|
6
|
+
import { SearchInstance } from '@verdaccio/store';
|
|
7
7
|
import { Storage } from '@verdaccio/store';
|
|
8
|
-
import {
|
|
8
|
+
import { Package } from '@verdaccio/types';
|
|
9
|
+
|
|
10
|
+
import { $NextFunctionVer, $RequestExtend, $ResponseExtend } from './package';
|
|
9
11
|
|
|
10
12
|
const debug = buildDebug('verdaccio:web:api:search');
|
|
11
13
|
|
package/src/api/sidebar.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import buildDebug from 'debug';
|
|
2
|
+
import { Router } from 'express';
|
|
2
3
|
import _ from 'lodash';
|
|
3
|
-
import { isVersionValid, formatAuthor } from '@verdaccio/utils';
|
|
4
|
-
import { HTTP_STATUS, DIST_TAGS } from '@verdaccio/commons-api';
|
|
5
|
-
import { allow, $RequestExtend, $ResponseExtend, $NextFunctionVer } from '@verdaccio/middleware';
|
|
6
4
|
|
|
7
|
-
import { Router } from 'express';
|
|
8
5
|
import { IAuth } from '@verdaccio/auth';
|
|
6
|
+
import { DIST_TAGS, HTTP_STATUS } from '@verdaccio/core';
|
|
7
|
+
import { $NextFunctionVer, $RequestExtend, $ResponseExtend, allow } from '@verdaccio/middleware';
|
|
9
8
|
import { Storage } from '@verdaccio/store';
|
|
9
|
+
import { convertDistRemoteToLocalTarballUrls } from '@verdaccio/tarball';
|
|
10
10
|
import { Config, Package, Version } from '@verdaccio/types';
|
|
11
|
+
import { addGravatarSupport, formatAuthor, isVersionValid } from '@verdaccio/utils';
|
|
11
12
|
|
|
12
|
-
import {
|
|
13
|
-
import { addGravatarSupport, addScope, AuthorAvatar, deleteProperties } from '../utils/web-utils';
|
|
13
|
+
import { AuthorAvatar, addScope, deleteProperties } from '../utils/web-utils';
|
|
14
14
|
|
|
15
15
|
export { $RequestExtend, $ResponseExtend, $NextFunctionVer }; // Was required by other packages
|
|
16
16
|
|
|
@@ -42,7 +42,7 @@ function addSidebarWebApi(route: Router, config: Config, storage: Storage, auth:
|
|
|
42
42
|
let sideBarInfo = _.clone(info);
|
|
43
43
|
sideBarInfo.versions = convertDistRemoteToLocalTarballUrls(
|
|
44
44
|
info,
|
|
45
|
-
req,
|
|
45
|
+
{ protocol: req.protocol, headers: req.headers as any, host: req.hostname },
|
|
46
46
|
config.url_prefix
|
|
47
47
|
).versions;
|
|
48
48
|
if (typeof v === 'string' && isVersionValid(info, v)) {
|
package/src/api/user.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import _ from 'lodash';
|
|
2
1
|
import buildDebug from 'debug';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
import { Config, RemoteUser, JWTSignOptions } from '@verdaccio/types';
|
|
2
|
+
import { Request, Response, Router } from 'express';
|
|
3
|
+
import _ from 'lodash';
|
|
6
4
|
|
|
7
|
-
import { API_ERROR, APP_ERROR, HTTP_STATUS } from '@verdaccio/commons-api';
|
|
8
5
|
import { IAuth } from '@verdaccio/auth';
|
|
9
|
-
import {
|
|
6
|
+
import { API_ERROR, APP_ERROR, HTTP_STATUS, errorUtils } from '@verdaccio/core';
|
|
7
|
+
import { Config, JWTSignOptions, RemoteUser } from '@verdaccio/types';
|
|
8
|
+
import { validatePassword } from '@verdaccio/utils';
|
|
9
|
+
|
|
10
10
|
import { $NextFunctionVer } from './package';
|
|
11
11
|
|
|
12
12
|
const debug = buildDebug('verdaccio:web:api:user');
|
|
@@ -19,7 +19,7 @@ function addUserAuthApi(route: Router, auth: IAuth, config: Config): void {
|
|
|
19
19
|
if (err) {
|
|
20
20
|
const errorCode = err.message ? HTTP_STATUS.UNAUTHORIZED : HTTP_STATUS.INTERNAL_ERROR;
|
|
21
21
|
debug('error authenticate %o', errorCode);
|
|
22
|
-
next(
|
|
22
|
+
next(errorUtils.getCode(errorCode, err.message));
|
|
23
23
|
} else {
|
|
24
24
|
req.remote_user = user;
|
|
25
25
|
const jWTSignOptions: JWTSignOptions = config.security.web.sign;
|
|
@@ -58,12 +58,12 @@ function addUserAuthApi(route: Router, auth: IAuth, config: Config): void {
|
|
|
58
58
|
ok: true,
|
|
59
59
|
});
|
|
60
60
|
} else {
|
|
61
|
-
return next(
|
|
61
|
+
return next(errorUtils.getInternalError(API_ERROR.INTERNAL_SERVER_ERROR));
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
);
|
|
65
65
|
} else {
|
|
66
|
-
return next(
|
|
66
|
+
return next(errorUtils.getCode(HTTP_STATUS.BAD_REQUEST, APP_ERROR.PASSWORD_VALIDATION));
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
);
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
import _ from 'lodash';
|
|
3
1
|
import buildDebug from 'debug';
|
|
4
2
|
import express from 'express';
|
|
3
|
+
import _ from 'lodash';
|
|
4
|
+
import path from 'path';
|
|
5
5
|
|
|
6
|
-
import {
|
|
7
|
-
import { HTTP_STATUS } from '@verdaccio/commons-api';
|
|
6
|
+
import { HTTP_STATUS } from '@verdaccio/core';
|
|
8
7
|
import { loadPlugin } from '@verdaccio/loaders';
|
|
8
|
+
import { SearchInstance } from '@verdaccio/store';
|
|
9
9
|
import { isURLhasValidProtocol } from '@verdaccio/url';
|
|
10
|
+
|
|
10
11
|
import renderHTML from '../renderHTML';
|
|
11
12
|
import { setSecurityWebHeaders } from './security';
|
|
12
13
|
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import { Router } from 'express';
|
|
2
1
|
import bodyParser from 'body-parser';
|
|
2
|
+
import { Router } from 'express';
|
|
3
3
|
|
|
4
|
-
import { SearchInstance } from '@verdaccio/store';
|
|
5
|
-
import { match, validateName, validatePackage } from '@verdaccio/middleware';
|
|
6
|
-
import { Config } from '@verdaccio/types';
|
|
7
4
|
import { IAuth } from '@verdaccio/auth';
|
|
5
|
+
import { match, validateName, validatePackage } from '@verdaccio/middleware';
|
|
6
|
+
import { SearchInstance } from '@verdaccio/store';
|
|
8
7
|
import { Storage } from '@verdaccio/store';
|
|
9
|
-
import
|
|
8
|
+
import { Config } from '@verdaccio/types';
|
|
9
|
+
|
|
10
10
|
import addPackageWebApi from '../api/package';
|
|
11
|
-
import addUserAuthApi from '../api/user';
|
|
12
11
|
import addReadmeWebApi from '../api/readme';
|
|
12
|
+
import addSearchWebApi from '../api/search';
|
|
13
13
|
import addSidebarWebApi from '../api/sidebar';
|
|
14
|
+
import addUserAuthApi from '../api/user';
|
|
14
15
|
import { hasLogin } from '../utils/web-utils';
|
|
15
16
|
import { setSecurityWebHeaders } from './security';
|
|
16
17
|
|
package/src/renderHTML.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { URL } from 'url';
|
|
2
1
|
import buildDebug from 'debug';
|
|
3
2
|
import LRU from 'lru-cache';
|
|
4
|
-
import {
|
|
5
|
-
import { getPublicUrl } from '@verdaccio/url';
|
|
3
|
+
import { URL } from 'url';
|
|
6
4
|
|
|
7
5
|
import { WEB_TITLE } from '@verdaccio/config';
|
|
8
|
-
import {
|
|
6
|
+
import { HEADERS } from '@verdaccio/core';
|
|
7
|
+
import { getPublicUrl } from '@verdaccio/url';
|
|
8
|
+
|
|
9
9
|
import renderTemplate from './template';
|
|
10
|
+
import { hasLogin, validatePrimaryColor } from './utils/web-utils';
|
|
10
11
|
|
|
11
12
|
const pkgJSON = require('../package.json');
|
|
12
13
|
const DEFAULT_LANGUAGE = 'es-US';
|
package/src/template.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import buildDebug from 'debug';
|
|
2
|
+
|
|
2
3
|
import { TemplateUIOptions } from '@verdaccio/types';
|
|
3
|
-
|
|
4
|
+
|
|
5
|
+
import { Manifest, getManifestValue } from './utils/manifest';
|
|
4
6
|
|
|
5
7
|
const debug = buildDebug('verdaccio:web:render:template');
|
|
6
8
|
|
package/src/utils/web-utils.ts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import _ from 'lodash';
|
|
2
1
|
import buildDebug from 'debug';
|
|
3
|
-
import
|
|
4
|
-
import { Package, Author, ConfigYaml } from '@verdaccio/types';
|
|
5
|
-
import { normalizeContributors } from '@verdaccio/store';
|
|
2
|
+
import _ from 'lodash';
|
|
6
3
|
|
|
7
4
|
import sanitizyReadme from '@verdaccio/readme';
|
|
5
|
+
// import { normalizeContributors } from '@verdaccio/store';
|
|
6
|
+
import { Author, ConfigYaml } from '@verdaccio/types';
|
|
8
7
|
|
|
9
8
|
export type AuthorAvatar = Author & { avatar?: string };
|
|
10
|
-
import { generateGravatarUrl, GENERIC_AVATAR } from './user';
|
|
11
9
|
|
|
12
10
|
const debug = buildDebug('verdaccio:web:utils');
|
|
13
11
|
|
|
@@ -21,56 +19,6 @@ export function validatePrimaryColor(primaryColor) {
|
|
|
21
19
|
return primaryColor;
|
|
22
20
|
}
|
|
23
21
|
|
|
24
|
-
export function addGravatarSupport(pkgInfo: Package, online = true): AuthorAvatar {
|
|
25
|
-
const pkgInfoCopy = { ...pkgInfo } as any;
|
|
26
|
-
const author: any = _.get(pkgInfo, 'latest.author', null) as any;
|
|
27
|
-
const contributors: AuthorAvatar[] = normalizeContributors(
|
|
28
|
-
_.get(pkgInfo, 'latest.contributors', [])
|
|
29
|
-
);
|
|
30
|
-
const maintainers = _.get(pkgInfo, 'latest.maintainers', []);
|
|
31
|
-
|
|
32
|
-
// for author.
|
|
33
|
-
if (author && _.isObject(author)) {
|
|
34
|
-
const { email } = author as Author;
|
|
35
|
-
pkgInfoCopy.latest.author.avatar = generateGravatarUrl(email, online);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (author && _.isString(author)) {
|
|
39
|
-
pkgInfoCopy.latest.author = {
|
|
40
|
-
avatar: GENERIC_AVATAR,
|
|
41
|
-
email: '',
|
|
42
|
-
author,
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// for contributors
|
|
47
|
-
if (_.isEmpty(contributors) === false) {
|
|
48
|
-
pkgInfoCopy.latest.contributors = contributors.map((contributor): AuthorAvatar => {
|
|
49
|
-
if (isObject(contributor)) {
|
|
50
|
-
contributor.avatar = generateGravatarUrl(contributor.email, online);
|
|
51
|
-
} else if (_.isString(contributor)) {
|
|
52
|
-
contributor = {
|
|
53
|
-
avatar: GENERIC_AVATAR,
|
|
54
|
-
email: contributor,
|
|
55
|
-
name: contributor,
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return contributor;
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// for maintainers
|
|
64
|
-
if (_.isEmpty(maintainers) === false) {
|
|
65
|
-
pkgInfoCopy.latest.maintainers = maintainers.map((maintainer): void => {
|
|
66
|
-
maintainer.avatar = generateGravatarUrl(maintainer.email, online);
|
|
67
|
-
return maintainer;
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return pkgInfoCopy;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
22
|
/**
|
|
75
23
|
* parse package readme - markdown/ascii
|
|
76
24
|
* @param {String} packageName name of package
|
package/src/web-middleware.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
2
|
import supertest from 'supertest';
|
|
3
|
+
|
|
4
|
+
import { HEADERS, HEADER_TYPE, HTTP_STATUS } from '@verdaccio/core';
|
|
3
5
|
import { setup } from '@verdaccio/logger';
|
|
4
|
-
|
|
6
|
+
|
|
5
7
|
import { initializeServer } from './helper';
|
|
6
8
|
|
|
7
9
|
setup([]);
|
package/test/api.readme.test.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
2
|
import supertest from 'supertest';
|
|
3
|
+
|
|
4
|
+
import { HEADERS, HEADER_TYPE, HTTP_STATUS } from '@verdaccio/core';
|
|
3
5
|
import { setup } from '@verdaccio/logger';
|
|
4
6
|
import { IGetPackageOptions } from '@verdaccio/store';
|
|
5
|
-
import { HEADERS, HEADER_TYPE, HTTP_STATUS } from '@verdaccio/commons-api';
|
|
6
7
|
|
|
7
8
|
import { NOT_README_FOUND } from '../src/api/readme';
|
|
8
9
|
import { initializeServer } from './helper';
|
package/test/api.search.test.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
2
|
import supertest from 'supertest';
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
import { HEADERS, HEADER_TYPE, HTTP_STATUS } from '@verdaccio/core';
|
|
4
5
|
import { setup } from '@verdaccio/logger';
|
|
6
|
+
import { IGetPackageOptions } from '@verdaccio/store';
|
|
5
7
|
|
|
6
|
-
import { HEADERS, HEADER_TYPE, HTTP_STATUS } from '@verdaccio/commons-api';
|
|
7
8
|
import { initializeServer } from './helper';
|
|
8
9
|
|
|
9
10
|
setup([]);
|
package/test/api.sidebar.test.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
2
|
import supertest from 'supertest';
|
|
3
|
+
|
|
4
|
+
import { HEADERS, HEADER_TYPE, HTTP_STATUS } from '@verdaccio/core';
|
|
3
5
|
import { setup } from '@verdaccio/logger';
|
|
4
6
|
import { IGetPackageOptions } from '@verdaccio/store';
|
|
5
|
-
import { HEADERS, HEADER_TYPE, HTTP_STATUS } from '@verdaccio/commons-api';
|
|
6
7
|
|
|
7
8
|
import { NOT_README_FOUND } from '../src/api/readme';
|
|
8
9
|
import { initializeServer } from './helper';
|
package/test/api.user.test.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
2
|
import supertest from 'supertest';
|
|
3
|
+
|
|
4
|
+
import { API_ERROR, HEADERS, HEADER_TYPE, HTTP_STATUS } from '@verdaccio/core';
|
|
3
5
|
import { setup } from '@verdaccio/logger';
|
|
4
|
-
|
|
6
|
+
|
|
5
7
|
import { initializeServer } from './helper';
|
|
6
8
|
|
|
7
9
|
setup([]);
|
package/test/helper.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import
|
|
1
|
+
import bodyParser from 'body-parser';
|
|
2
2
|
import express from 'express';
|
|
3
3
|
import { Application } from 'express';
|
|
4
|
-
import
|
|
5
|
-
import { Config, parseConfigFile } from '@verdaccio/config';
|
|
6
|
-
import { final, handleError, errorReportingMiddleware } from '@verdaccio/middleware';
|
|
4
|
+
import path from 'path';
|
|
7
5
|
|
|
8
|
-
import { Storage } from '@verdaccio/store';
|
|
9
6
|
import { Auth, IAuth } from '@verdaccio/auth';
|
|
7
|
+
import { Config, parseConfigFile } from '@verdaccio/config';
|
|
10
8
|
import { setup } from '@verdaccio/logger';
|
|
9
|
+
import { errorReportingMiddleware, final, handleError } from '@verdaccio/middleware';
|
|
10
|
+
import { Storage } from '@verdaccio/store';
|
|
11
|
+
|
|
11
12
|
import routes from '../src';
|
|
12
13
|
|
|
13
14
|
setup([]);
|
|
@@ -20,6 +21,7 @@ const getConf = (configName: string) => {
|
|
|
20
21
|
export async function initializeServer(configName: string): Promise<Application> {
|
|
21
22
|
const app = express();
|
|
22
23
|
const config = new Config(getConf(configName));
|
|
24
|
+
config.checkSecretKey('12345');
|
|
23
25
|
const storage = new Storage(config);
|
|
24
26
|
await storage.init(config, []);
|
|
25
27
|
const auth: IAuth = new Auth(config);
|
package/test/render.test.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
2
|
import supertest from 'supertest';
|
|
3
|
+
|
|
4
|
+
import { HEADERS, HEADER_TYPE, HTTP_STATUS } from '@verdaccio/core';
|
|
3
5
|
import { setup } from '@verdaccio/logger';
|
|
4
|
-
|
|
6
|
+
|
|
5
7
|
import { initializeServer } from './helper';
|
|
6
8
|
|
|
7
9
|
setup([]);
|
package/test/template.test.ts
CHANGED
package/test/utils.spec.ts
CHANGED
|
@@ -1,221 +1,13 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
import { generateGravatarUrl, GENERIC_AVATAR } from '../src/utils/user';
|
|
4
|
+
import { parseReadme } from '../src/utils/web-utils';
|
|
6
5
|
|
|
7
6
|
const readmeFile = (fileName = 'markdown.md') => {
|
|
8
7
|
return fs.readFileSync(path.join(__dirname, `./partials/readme/${fileName}`));
|
|
9
8
|
};
|
|
10
9
|
|
|
11
10
|
describe('Utilities', () => {
|
|
12
|
-
describe('User utilities', () => {
|
|
13
|
-
test('should generate gravatar url with email', () => {
|
|
14
|
-
const gravatarUrl: string = generateGravatarUrl('user@verdaccio.org');
|
|
15
|
-
|
|
16
|
-
expect(gravatarUrl).toMatch('https://www.gravatar.com/avatar/');
|
|
17
|
-
expect(gravatarUrl).not.toMatch('000000000');
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
test('should generate generic gravatar url', () => {
|
|
21
|
-
const gravatarUrl: string = generateGravatarUrl();
|
|
22
|
-
|
|
23
|
-
expect(gravatarUrl).toMatch(GENERIC_AVATAR);
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
describe('addGravatarSupport', () => {
|
|
28
|
-
test('check for blank object', () => {
|
|
29
|
-
// @ts-ignore
|
|
30
|
-
expect(addGravatarSupport({})).toEqual({});
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
test('author, contributors and maintainers fields are not present', () => {
|
|
34
|
-
const packageInfo = {
|
|
35
|
-
latest: {},
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
// @ts-ignore
|
|
39
|
-
expect(addGravatarSupport(packageInfo)).toEqual(packageInfo);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
test('author field is a blank object', () => {
|
|
43
|
-
const packageInfo = { latest: { author: {} } };
|
|
44
|
-
|
|
45
|
-
// @ts-ignore
|
|
46
|
-
expect(addGravatarSupport(packageInfo)).toEqual(packageInfo);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
test('author field is a string type', () => {
|
|
50
|
-
const packageInfo = {
|
|
51
|
-
latest: { author: 'user@verdccio.org' },
|
|
52
|
-
};
|
|
53
|
-
const result = {
|
|
54
|
-
latest: {
|
|
55
|
-
author: {
|
|
56
|
-
author: 'user@verdccio.org',
|
|
57
|
-
avatar: GENERIC_AVATAR,
|
|
58
|
-
email: '',
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
// @ts-ignore
|
|
64
|
-
expect(addGravatarSupport(packageInfo)).toEqual(result);
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
test('author field is an object type with author information', () => {
|
|
68
|
-
const packageInfo = {
|
|
69
|
-
latest: { author: { name: 'verdaccio', email: 'user@verdccio.org' } },
|
|
70
|
-
};
|
|
71
|
-
const result = {
|
|
72
|
-
latest: {
|
|
73
|
-
author: {
|
|
74
|
-
avatar: 'https://www.gravatar.com/avatar/794d7f6ef93d0689437de3c3e48fadc7',
|
|
75
|
-
email: 'user@verdccio.org',
|
|
76
|
-
name: 'verdaccio',
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
// @ts-ignore
|
|
82
|
-
expect(addGravatarSupport(packageInfo)).toEqual(result);
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
test('contributor field is a blank array', () => {
|
|
86
|
-
const packageInfo = {
|
|
87
|
-
latest: {
|
|
88
|
-
contributors: [],
|
|
89
|
-
},
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
// @ts-ignore
|
|
93
|
-
expect(addGravatarSupport(packageInfo)).toEqual(packageInfo);
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
describe('contributors', () => {
|
|
97
|
-
test('contributors field has contributors', () => {
|
|
98
|
-
const packageInfo = {
|
|
99
|
-
latest: {
|
|
100
|
-
contributors: [
|
|
101
|
-
{ name: 'user', email: 'user@verdccio.org' },
|
|
102
|
-
{ name: 'user1', email: 'user1@verdccio.org' },
|
|
103
|
-
],
|
|
104
|
-
},
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
const result = {
|
|
108
|
-
latest: {
|
|
109
|
-
contributors: [
|
|
110
|
-
{
|
|
111
|
-
avatar: 'https://www.gravatar.com/avatar/794d7f6ef93d0689437de3c3e48fadc7',
|
|
112
|
-
email: 'user@verdccio.org',
|
|
113
|
-
name: 'user',
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
avatar: 'https://www.gravatar.com/avatar/51105a49ce4a9c2bfabf0f6a2cba3762',
|
|
117
|
-
email: 'user1@verdccio.org',
|
|
118
|
-
name: 'user1',
|
|
119
|
-
},
|
|
120
|
-
],
|
|
121
|
-
},
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
// @ts-ignore
|
|
125
|
-
expect(addGravatarSupport(packageInfo)).toEqual(result);
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
test('contributors field is an object', () => {
|
|
129
|
-
const packageInfo = {
|
|
130
|
-
latest: {
|
|
131
|
-
contributors: { name: 'user', email: 'user@verdccio.org' },
|
|
132
|
-
},
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
const result = {
|
|
136
|
-
latest: {
|
|
137
|
-
contributors: [
|
|
138
|
-
{
|
|
139
|
-
avatar: 'https://www.gravatar.com/avatar/794d7f6ef93d0689437de3c3e48fadc7',
|
|
140
|
-
email: 'user@verdccio.org',
|
|
141
|
-
name: 'user',
|
|
142
|
-
},
|
|
143
|
-
],
|
|
144
|
-
},
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
// @ts-ignore
|
|
148
|
-
expect(addGravatarSupport(packageInfo)).toEqual(result);
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
test('contributors field is a string', () => {
|
|
152
|
-
const contributor = 'Barney Rubble <b@rubble.com> (http://barnyrubble.tumblr.com/)';
|
|
153
|
-
const packageInfo = {
|
|
154
|
-
latest: {
|
|
155
|
-
contributors: contributor,
|
|
156
|
-
},
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
const result = {
|
|
160
|
-
latest: {
|
|
161
|
-
contributors: [
|
|
162
|
-
{
|
|
163
|
-
avatar: GENERIC_AVATAR,
|
|
164
|
-
email: contributor,
|
|
165
|
-
name: contributor,
|
|
166
|
-
},
|
|
167
|
-
],
|
|
168
|
-
},
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
// @ts-ignore
|
|
172
|
-
expect(addGravatarSupport(packageInfo)).toEqual(result);
|
|
173
|
-
});
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
test('maintainers field is a blank array', () => {
|
|
177
|
-
const packageInfo = {
|
|
178
|
-
latest: {
|
|
179
|
-
maintainers: [],
|
|
180
|
-
},
|
|
181
|
-
};
|
|
182
|
-
|
|
183
|
-
// @ts-ignore
|
|
184
|
-
expect(addGravatarSupport(packageInfo)).toEqual(packageInfo);
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
test('maintainers field has maintainers', () => {
|
|
188
|
-
const packageInfo = {
|
|
189
|
-
latest: {
|
|
190
|
-
maintainers: [
|
|
191
|
-
{ name: 'user', email: 'user@verdccio.org' },
|
|
192
|
-
{ name: 'user1', email: 'user1@verdccio.org' },
|
|
193
|
-
],
|
|
194
|
-
},
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
const result = {
|
|
198
|
-
latest: {
|
|
199
|
-
maintainers: [
|
|
200
|
-
{
|
|
201
|
-
avatar: 'https://www.gravatar.com/avatar/794d7f6ef93d0689437de3c3e48fadc7',
|
|
202
|
-
email: 'user@verdccio.org',
|
|
203
|
-
name: 'user',
|
|
204
|
-
},
|
|
205
|
-
{
|
|
206
|
-
avatar: 'https://www.gravatar.com/avatar/51105a49ce4a9c2bfabf0f6a2cba3762',
|
|
207
|
-
email: 'user1@verdccio.org',
|
|
208
|
-
name: 'user1',
|
|
209
|
-
},
|
|
210
|
-
],
|
|
211
|
-
},
|
|
212
|
-
};
|
|
213
|
-
|
|
214
|
-
// @ts-ignore
|
|
215
|
-
expect(addGravatarSupport(packageInfo)).toEqual(result);
|
|
216
|
-
});
|
|
217
|
-
});
|
|
218
|
-
|
|
219
11
|
describe('parseReadme', () => {
|
|
220
12
|
test('should parse makrdown text to html template', () => {
|
|
221
13
|
const markdown = '# markdown';
|
package/build/utils/user.d.ts
DELETED
package/build/utils/user.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.generateGravatarUrl = generateGravatarUrl;
|
|
7
|
-
exports.GENERIC_AVATAR = void 0;
|
|
8
|
-
|
|
9
|
-
var _lodash = _interopRequireDefault(require("lodash"));
|
|
10
|
-
|
|
11
|
-
var _utils = require("@verdaccio/utils");
|
|
12
|
-
|
|
13
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
-
|
|
15
|
-
// this is a generic avatar
|
|
16
|
-
// https://www.iconfinder.com/icons/403017/anonym_avatar_default_head_person_unknown_user_icon
|
|
17
|
-
// license: free commercial usage
|
|
18
|
-
const GENERIC_AVATAR = 'data:image/svg+xml;utf8,' + encodeURIComponent('<svg height="100" viewBox="-27 24 100 100" width="100" xmlns="http://www.w3.org/' + '2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><defs><circle cx="23" cy="7' + '4" id="a" r="50"/></defs><use fill="#F5EEE5" overflow="visible" xlink:href="#a"/' + '><clipPath id="b"><use overflow="visible" xlink:href="#a"/></clipPath><g clip-pa' + 'th="url(#b)"><defs><path d="M36 95.9c0 4 4.7 5.2 7.1 5.8 7.6 2 22.8 5.9 22.8 5.9' + ' 3.2 1.1 5.7 3.5 7.1 6.6v9.8H-27v-9.8c1.3-3.1 3.9-5.5 7.1-6.6 0 0 15.2-3.9 22.8-' + '5.9 2.4-.6 7.1-1.8 7.1-5.8V85h26v10.9z" id="c"/></defs><use fill="#E6C19C" overf' + 'low="visible" xlink:href="#c"/><clipPath id="d"><use overflow="visible" xlink:hr' + 'ef="#c"/></clipPath><path clip-path="url(#d)" d="M23.2 35h.2c3.3 0 8.2.2 11.4 2 ' + '3.3 1.9 7.3 5.6 8.5 12.1 2.4 13.7-2.1 35.4-6.3 42.4-4 6.7-9.8 9.2-13.5 9.4H23h-.' + '1c-3.7-.2-9.5-2.7-13.5-9.4-4.2-7-8.7-28.7-6.3-42.4 1.2-6.5 5.2-10.2 8.5-12.1 3.2' + '-1.8 8.1-2 11.4-2h.2z" fill="#D4B08C"/></g><path d="M22.6 40c19.1 0 20.7 13.8 20' + '.8 15.1 1.1 11.9-3 28.1-6.8 33.7-4 5.9-9.8 8.1-13.5 8.3h-.5c-3.8-.3-9.6-2.5-13.6' + '-8.4-3.8-5.6-7.9-21.8-6.8-33.8C2.3 53.7 3.5 40 22.6 40z" fill="#F2CEA5"/></svg>');
|
|
19
|
-
/**
|
|
20
|
-
* Generate gravatar url from email address
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
exports.GENERIC_AVATAR = GENERIC_AVATAR;
|
|
24
|
-
|
|
25
|
-
function generateGravatarUrl(email = '', online = true) {
|
|
26
|
-
if (online && _lodash.default.isString(email) && _lodash.default.size(email) > 0) {
|
|
27
|
-
email = email.trim().toLocaleLowerCase();
|
|
28
|
-
const emailMD5 = (0, _utils.stringToMD5)(email);
|
|
29
|
-
return `https://www.gravatar.com/avatar/${emailMD5}`;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return GENERIC_AVATAR;
|
|
33
|
-
}
|
|
34
|
-
//# sourceMappingURL=user.js.map
|
package/build/utils/user.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/user.ts"],"names":["GENERIC_AVATAR","encodeURIComponent","generateGravatarUrl","email","online","_","isString","size","trim","toLocaleLowerCase","emailMD5"],"mappings":";;;;;;;;AAAA;;AAEA;;;;AAEA;AACA;AACA;AACO,MAAMA,cAAc,GACzB,6BACAC,kBAAkB,CAChB,qFACE,kFADF,GAEE,kFAFF,GAGE,kFAHF,GAIE,kFAJF,GAKE,kFALF,GAME,kFANF,GAOE,kFAPF,GAQE,kFARF,GASE,kFATF,GAUE,kFAVF,GAWE,kFAXF,GAYE,kFAZF,GAaE,iFAdc,CAFb;AAmBP;AACA;AACA;;;;AACO,SAASC,mBAAT,CAA6BC,KAAoB,GAAG,EAApD,EAAwDC,MAAe,GAAG,IAA1E,EAAwF;AAC7F,MAAIA,MAAM,IAAIC,gBAAEC,QAAF,CAAWH,KAAX,CAAV,IAA+BE,gBAAEE,IAAF,CAAOJ,KAAP,IAAgB,CAAnD,EAAsD;AACpDA,IAAAA,KAAK,GAAGA,KAAK,CAACK,IAAN,GAAaC,iBAAb,EAAR;AACA,UAAMC,QAAQ,GAAG,wBAAYP,KAAZ,CAAjB;AACA,WAAQ,mCAAkCO,QAAS,EAAnD;AACD;;AACD,SAAOV,cAAP;AACD","sourcesContent":["import _ from 'lodash';\n\nimport { stringToMD5 } from '@verdaccio/utils';\n\n// this is a generic avatar\n// https://www.iconfinder.com/icons/403017/anonym_avatar_default_head_person_unknown_user_icon\n// license: free commercial usage\nexport const GENERIC_AVATAR =\n 'data:image/svg+xml;utf8,' +\n encodeURIComponent(\n '<svg height=\"100\" viewBox=\"-27 24 100 100\" width=\"100\" xmlns=\"http://www.w3.org/' +\n '2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"><defs><circle cx=\"23\" cy=\"7' +\n '4\" id=\"a\" r=\"50\"/></defs><use fill=\"#F5EEE5\" overflow=\"visible\" xlink:href=\"#a\"/' +\n '><clipPath id=\"b\"><use overflow=\"visible\" xlink:href=\"#a\"/></clipPath><g clip-pa' +\n 'th=\"url(#b)\"><defs><path d=\"M36 95.9c0 4 4.7 5.2 7.1 5.8 7.6 2 22.8 5.9 22.8 5.9' +\n ' 3.2 1.1 5.7 3.5 7.1 6.6v9.8H-27v-9.8c1.3-3.1 3.9-5.5 7.1-6.6 0 0 15.2-3.9 22.8-' +\n '5.9 2.4-.6 7.1-1.8 7.1-5.8V85h26v10.9z\" id=\"c\"/></defs><use fill=\"#E6C19C\" overf' +\n 'low=\"visible\" xlink:href=\"#c\"/><clipPath id=\"d\"><use overflow=\"visible\" xlink:hr' +\n 'ef=\"#c\"/></clipPath><path clip-path=\"url(#d)\" d=\"M23.2 35h.2c3.3 0 8.2.2 11.4 2 ' +\n '3.3 1.9 7.3 5.6 8.5 12.1 2.4 13.7-2.1 35.4-6.3 42.4-4 6.7-9.8 9.2-13.5 9.4H23h-.' +\n '1c-3.7-.2-9.5-2.7-13.5-9.4-4.2-7-8.7-28.7-6.3-42.4 1.2-6.5 5.2-10.2 8.5-12.1 3.2' +\n '-1.8 8.1-2 11.4-2h.2z\" fill=\"#D4B08C\"/></g><path d=\"M22.6 40c19.1 0 20.7 13.8 20' +\n '.8 15.1 1.1 11.9-3 28.1-6.8 33.7-4 5.9-9.8 8.1-13.5 8.3h-.5c-3.8-.3-9.6-2.5-13.6' +\n '-8.4-3.8-5.6-7.9-21.8-6.8-33.8C2.3 53.7 3.5 40 22.6 40z\" fill=\"#F2CEA5\"/></svg>'\n );\n\n/**\n * Generate gravatar url from email address\n */\nexport function generateGravatarUrl(email: string | void = '', online: boolean = true): string {\n if (online && _.isString(email) && _.size(email) > 0) {\n email = email.trim().toLocaleLowerCase();\n const emailMD5 = stringToMD5(email);\n return `https://www.gravatar.com/avatar/${emailMD5}`;\n }\n return GENERIC_AVATAR;\n}\n"],"file":"user.js"}
|