@verdaccio/web 6.0.0-6-next.37 → 6.0.0-6-next.39

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.
Files changed (49) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/build/api/index.js +1 -15
  3. package/build/api/index.js.map +1 -1
  4. package/build/api/package.js +11 -37
  5. package/build/api/package.js.map +1 -1
  6. package/build/api/readme.d.ts +1 -1
  7. package/build/api/readme.js +13 -21
  8. package/build/api/readme.js.map +1 -1
  9. package/build/api/search.js +5 -18
  10. package/build/api/search.js.map +1 -1
  11. package/build/api/sidebar.d.ts +2 -2
  12. package/build/api/sidebar.js +11 -25
  13. package/build/api/sidebar.js.map +1 -1
  14. package/build/api/user.js +2 -17
  15. package/build/api/user.js.map +1 -1
  16. package/build/index.js +0 -2
  17. package/build/index.js.map +1 -1
  18. package/build/middleware/render-web.d.ts +1 -1
  19. package/build/middleware/render-web.js +10 -29
  20. package/build/middleware/render-web.js.map +1 -1
  21. package/build/middleware/security.js +6 -8
  22. package/build/middleware/security.js.map +1 -1
  23. package/build/middleware/web-api.js +2 -9
  24. package/build/middleware/web-api.js.map +1 -1
  25. package/build/renderHTML.js +3 -19
  26. package/build/renderHTML.js.map +1 -1
  27. package/build/template.d.ts +1 -1
  28. package/build/template.js +0 -6
  29. package/build/template.js.map +1 -1
  30. package/build/utils/manifest.d.ts +1 -1
  31. package/build/utils/manifest.js +0 -4
  32. package/build/utils/manifest.js.map +1 -1
  33. package/build/utils/web-utils.d.ts +1 -8
  34. package/build/utils/web-utils.js +0 -35
  35. package/build/utils/web-utils.js.map +1 -1
  36. package/build/web-middleware.js +4 -11
  37. package/build/web-middleware.js.map +1 -1
  38. package/package.json +18 -19
  39. package/src/api/package.ts +1 -1
  40. package/src/api/readme.ts +13 -10
  41. package/src/api/user.ts +2 -1
  42. package/src/middleware/render-web.ts +3 -2
  43. package/src/renderHTML.ts +1 -1
  44. package/src/utils/web-utils.ts +0 -18
  45. package/test/api.readme.test.ts +1 -1
  46. package/test/api.user.test.ts +1 -0
  47. package/test/utils.spec.ts +1 -33
  48. package/test/__snapshots__/utils.spec.ts.snap +0 -51
  49. package/test/partials/readme/markdown.md +0 -81
@@ -4,13 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getManifestValue = getManifestValue;
7
-
8
7
  var _debug = _interopRequireDefault(require("debug"));
9
-
10
8
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
12
9
  const debug = (0, _debug.default)('verdaccio:web:render:manifest');
13
-
14
10
  function getManifestValue(manifestItems, manifest, basePath = '') {
15
11
  return manifestItems === null || manifestItems === void 0 ? void 0 : manifestItems.map(item => {
16
12
  debug('resolve item %o', item);
@@ -1 +1 @@
1
- {"version":3,"file":"manifest.js","names":["debug","buildDebug","getManifestValue","manifestItems","manifest","basePath","map","item","resolvedItem"],"sources":["../../src/utils/manifest.ts"],"sourcesContent":["import buildDebug from 'debug';\n\nexport type Manifest = {\n // goes on first place at the header\n ico: string;\n css: string[];\n js: string[];\n};\n\nconst debug = buildDebug('verdaccio:web:render:manifest');\n\nexport function getManifestValue(\n manifestItems: string[],\n manifest,\n basePath: string = ''\n): string[] {\n return manifestItems?.map((item) => {\n debug('resolve item %o', item);\n const resolvedItem = `${basePath}${manifest[item]}`;\n debug('resolved item %o', resolvedItem);\n return resolvedItem;\n });\n}\n"],"mappings":";;;;;;;AAAA;;;;AASA,MAAMA,KAAK,GAAG,IAAAC,cAAA,EAAW,+BAAX,CAAd;;AAEO,SAASC,gBAAT,CACLC,aADK,EAELC,QAFK,EAGLC,QAAgB,GAAG,EAHd,EAIK;EACV,OAAOF,aAAP,aAAOA,aAAP,uBAAOA,aAAa,CAAEG,GAAf,CAAoBC,IAAD,IAAU;IAClCP,KAAK,CAAC,iBAAD,EAAoBO,IAApB,CAAL;IACA,MAAMC,YAAY,GAAI,GAAEH,QAAS,GAAED,QAAQ,CAACG,IAAD,CAAO,EAAlD;IACAP,KAAK,CAAC,kBAAD,EAAqBQ,YAArB,CAAL;IACA,OAAOA,YAAP;EACD,CALM,CAAP;AAMD"}
1
+ {"version":3,"file":"manifest.js","names":["debug","buildDebug","getManifestValue","manifestItems","manifest","basePath","map","item","resolvedItem"],"sources":["../../src/utils/manifest.ts"],"sourcesContent":["import buildDebug from 'debug';\n\nexport type Manifest = {\n // goes on first place at the header\n ico: string;\n css: string[];\n js: string[];\n};\n\nconst debug = buildDebug('verdaccio:web:render:manifest');\n\nexport function getManifestValue(\n manifestItems: string[],\n manifest,\n basePath: string = ''\n): string[] {\n return manifestItems?.map((item) => {\n debug('resolve item %o', item);\n const resolvedItem = `${basePath}${manifest[item]}`;\n debug('resolved item %o', resolvedItem);\n return resolvedItem;\n });\n}\n"],"mappings":";;;;;;AAAA;AAA+B;AAS/B,MAAMA,KAAK,GAAG,IAAAC,cAAU,EAAC,+BAA+B,CAAC;AAElD,SAASC,gBAAgB,CAC9BC,aAAuB,EACvBC,QAAQ,EACRC,QAAgB,GAAG,EAAE,EACX;EACV,OAAOF,aAAa,aAAbA,aAAa,uBAAbA,aAAa,CAAEG,GAAG,CAAEC,IAAI,IAAK;IAClCP,KAAK,CAAC,iBAAiB,EAAEO,IAAI,CAAC;IAC9B,MAAMC,YAAY,GAAI,GAAEH,QAAS,GAAED,QAAQ,CAACG,IAAI,CAAE,EAAC;IACnDP,KAAK,CAAC,kBAAkB,EAAEQ,YAAY,CAAC;IACvC,OAAOA,YAAY;EACrB,CAAC,CAAC;AACJ"}
@@ -1,15 +1,8 @@
1
1
  import { Author, ConfigYaml } from '@verdaccio/types';
2
- export declare type AuthorAvatar = Author & {
2
+ export type AuthorAvatar = Author & {
3
3
  avatar?: string;
4
4
  };
5
5
  export declare function validatePrimaryColor(primaryColor: any): any;
6
- /**
7
- * parse package readme - markdown/ascii
8
- * @param {String} packageName name of package
9
- * @param {String} readme package readme
10
- * @return {String} converted html template
11
- */
12
- export declare function parseReadme(packageName: string, readme: string): string | void;
13
6
  export declare function deleteProperties(propertiesToDelete: string[], objectItem: any): any;
14
7
  export declare function addScope(scope: string, packageName: string): string;
15
8
  export declare function sortByName(packages: any[], orderAscending?: boolean | void): string[];
@@ -6,73 +6,38 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.addScope = addScope;
7
7
  exports.deleteProperties = deleteProperties;
8
8
  exports.hasLogin = hasLogin;
9
- exports.parseReadme = parseReadme;
10
9
  exports.sortByName = sortByName;
11
10
  exports.validatePrimaryColor = validatePrimaryColor;
12
-
13
11
  var _debug = _interopRequireDefault(require("debug"));
14
-
15
12
  var _lodash = _interopRequireDefault(require("lodash"));
16
-
17
- var _readme = _interopRequireDefault(require("@verdaccio/readme"));
18
-
19
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
-
21
14
  const debug = (0, _debug.default)('verdaccio:web:utils');
22
-
23
15
  function validatePrimaryColor(primaryColor) {
24
16
  const isHex = /^#([0-9A-F]{3}){1,2}$/i.test(primaryColor);
25
-
26
17
  if (!isHex) {
27
18
  debug('invalid primary color %o', primaryColor);
28
19
  return;
29
20
  }
30
-
31
21
  return primaryColor;
32
22
  }
33
- /**
34
- * parse package readme - markdown/ascii
35
- * @param {String} packageName name of package
36
- * @param {String} readme package readme
37
- * @return {String} converted html template
38
- */
39
-
40
-
41
- function parseReadme(packageName, readme) {
42
- if (_lodash.default.isEmpty(readme) === false) {
43
- debug('sanizity readme');
44
- return (0, _readme.default)(readme);
45
- } // logs readme not found error
46
- // logger.error({ packageName }, '@{packageName}: No readme found');
47
-
48
-
49
- throw new Error('ERROR: No README data found!');
50
- }
51
-
52
23
  function deleteProperties(propertiesToDelete, objectItem) {
53
24
  debug('deleted unused version properties');
54
-
55
25
  _lodash.default.forEach(propertiesToDelete, property => {
56
26
  delete objectItem[property];
57
27
  });
58
-
59
28
  return objectItem;
60
29
  }
61
-
62
30
  function addScope(scope, packageName) {
63
31
  return `@${scope}/${packageName}`;
64
32
  }
65
-
66
33
  function sortByName(packages, orderAscending = true) {
67
34
  return packages.slice().sort(function (a, b) {
68
35
  const comparatorNames = a.name.toLowerCase() < b.name.toLowerCase();
69
36
  return orderAscending ? comparatorNames ? -1 : 1 : comparatorNames ? 1 : -1;
70
37
  });
71
38
  }
72
-
73
39
  function hasLogin(config) {
74
40
  var _config$web, _config$web2;
75
-
76
41
  return _lodash.default.isNil(config === null || config === void 0 ? void 0 : (_config$web = config.web) === null || _config$web === void 0 ? void 0 : _config$web.login) || (config === null || config === void 0 ? void 0 : (_config$web2 = config.web) === null || _config$web2 === void 0 ? void 0 : _config$web2.login) === true;
77
42
  }
78
43
  //# sourceMappingURL=web-utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"web-utils.js","names":["debug","buildDebug","validatePrimaryColor","primaryColor","isHex","test","parseReadme","packageName","readme","_","isEmpty","sanitizyReadme","Error","deleteProperties","propertiesToDelete","objectItem","forEach","property","addScope","scope","sortByName","packages","orderAscending","slice","sort","a","b","comparatorNames","name","toLowerCase","hasLogin","config","isNil","web","login"],"sources":["../../src/utils/web-utils.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport _ from 'lodash';\n\nimport sanitizyReadme from '@verdaccio/readme';\n// import { normalizeContributors } from '@verdaccio/store';\nimport { Author, ConfigYaml } from '@verdaccio/types';\n\nexport type AuthorAvatar = Author & { avatar?: string };\n\nconst debug = buildDebug('verdaccio:web:utils');\n\nexport function validatePrimaryColor(primaryColor) {\n const isHex = /^#([0-9A-F]{3}){1,2}$/i.test(primaryColor);\n if (!isHex) {\n debug('invalid primary color %o', primaryColor);\n return;\n }\n\n return primaryColor;\n}\n\n/**\n * parse package readme - markdown/ascii\n * @param {String} packageName name of package\n * @param {String} readme package readme\n * @return {String} converted html template\n */\nexport function parseReadme(packageName: string, readme: string): string | void {\n if (_.isEmpty(readme) === false) {\n debug('sanizity readme');\n return sanitizyReadme(readme);\n }\n\n // logs readme not found error\n // logger.error({ packageName }, '@{packageName}: No readme found');\n throw new Error('ERROR: No README data found!');\n}\n\nexport function deleteProperties(propertiesToDelete: string[], objectItem: any): any {\n debug('deleted unused version properties');\n _.forEach(propertiesToDelete, (property): any => {\n delete objectItem[property];\n });\n\n return objectItem;\n}\n\nexport function addScope(scope: string, packageName: string): string {\n return `@${scope}/${packageName}`;\n}\n\nexport function sortByName(packages: any[], orderAscending: boolean | void = true): string[] {\n return packages.slice().sort(function (a, b): number {\n const comparatorNames = a.name.toLowerCase() < b.name.toLowerCase();\n return orderAscending ? (comparatorNames ? -1 : 1) : comparatorNames ? 1 : -1;\n });\n}\n\nexport function hasLogin(config: ConfigYaml) {\n return _.isNil(config?.web?.login) || config?.web?.login === true;\n}\n"],"mappings":";;;;;;;;;;;;AAAA;;AACA;;AAEA;;;;AAMA,MAAMA,KAAK,GAAG,IAAAC,cAAA,EAAW,qBAAX,CAAd;;AAEO,SAASC,oBAAT,CAA8BC,YAA9B,EAA4C;EACjD,MAAMC,KAAK,GAAG,yBAAyBC,IAAzB,CAA8BF,YAA9B,CAAd;;EACA,IAAI,CAACC,KAAL,EAAY;IACVJ,KAAK,CAAC,0BAAD,EAA6BG,YAA7B,CAAL;IACA;EACD;;EAED,OAAOA,YAAP;AACD;AAED;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASG,WAAT,CAAqBC,WAArB,EAA0CC,MAA1C,EAAyE;EAC9E,IAAIC,eAAA,CAAEC,OAAF,CAAUF,MAAV,MAAsB,KAA1B,EAAiC;IAC/BR,KAAK,CAAC,iBAAD,CAAL;IACA,OAAO,IAAAW,eAAA,EAAeH,MAAf,CAAP;EACD,CAJ6E,CAM9E;EACA;;;EACA,MAAM,IAAII,KAAJ,CAAU,8BAAV,CAAN;AACD;;AAEM,SAASC,gBAAT,CAA0BC,kBAA1B,EAAwDC,UAAxD,EAA8E;EACnFf,KAAK,CAAC,mCAAD,CAAL;;EACAS,eAAA,CAAEO,OAAF,CAAUF,kBAAV,EAA+BG,QAAD,IAAmB;IAC/C,OAAOF,UAAU,CAACE,QAAD,CAAjB;EACD,CAFD;;EAIA,OAAOF,UAAP;AACD;;AAEM,SAASG,QAAT,CAAkBC,KAAlB,EAAiCZ,WAAjC,EAA8D;EACnE,OAAQ,IAAGY,KAAM,IAAGZ,WAAY,EAAhC;AACD;;AAEM,SAASa,UAAT,CAAoBC,QAApB,EAAqCC,cAA8B,GAAG,IAAtE,EAAsF;EAC3F,OAAOD,QAAQ,CAACE,KAAT,GAAiBC,IAAjB,CAAsB,UAAUC,CAAV,EAAaC,CAAb,EAAwB;IACnD,MAAMC,eAAe,GAAGF,CAAC,CAACG,IAAF,CAAOC,WAAP,KAAuBH,CAAC,CAACE,IAAF,CAAOC,WAAP,EAA/C;IACA,OAAOP,cAAc,GAAIK,eAAe,GAAG,CAAC,CAAJ,GAAQ,CAA3B,GAAgCA,eAAe,GAAG,CAAH,GAAO,CAAC,CAA5E;EACD,CAHM,CAAP;AAID;;AAEM,SAASG,QAAT,CAAkBC,MAAlB,EAAsC;EAAA;;EAC3C,OAAOtB,eAAA,CAAEuB,KAAF,CAAQD,MAAR,aAAQA,MAAR,sCAAQA,MAAM,CAAEE,GAAhB,gDAAQ,YAAaC,KAArB,KAA+B,CAAAH,MAAM,SAAN,IAAAA,MAAM,WAAN,4BAAAA,MAAM,CAAEE,GAAR,8DAAaC,KAAb,MAAuB,IAA7D;AACD"}
1
+ {"version":3,"file":"web-utils.js","names":["debug","buildDebug","validatePrimaryColor","primaryColor","isHex","test","deleteProperties","propertiesToDelete","objectItem","_","forEach","property","addScope","scope","packageName","sortByName","packages","orderAscending","slice","sort","a","b","comparatorNames","name","toLowerCase","hasLogin","config","isNil","web","login"],"sources":["../../src/utils/web-utils.ts"],"sourcesContent":["import buildDebug from 'debug';\nimport _ from 'lodash';\n\n// import { normalizeContributors } from '@verdaccio/store';\nimport { Author, ConfigYaml } from '@verdaccio/types';\n\nexport type AuthorAvatar = Author & { avatar?: string };\n\nconst debug = buildDebug('verdaccio:web:utils');\n\nexport function validatePrimaryColor(primaryColor) {\n const isHex = /^#([0-9A-F]{3}){1,2}$/i.test(primaryColor);\n if (!isHex) {\n debug('invalid primary color %o', primaryColor);\n return;\n }\n\n return primaryColor;\n}\n\nexport function deleteProperties(propertiesToDelete: string[], objectItem: any): any {\n debug('deleted unused version properties');\n _.forEach(propertiesToDelete, (property): any => {\n delete objectItem[property];\n });\n\n return objectItem;\n}\n\nexport function addScope(scope: string, packageName: string): string {\n return `@${scope}/${packageName}`;\n}\n\nexport function sortByName(packages: any[], orderAscending: boolean | void = true): string[] {\n return packages.slice().sort(function (a, b): number {\n const comparatorNames = a.name.toLowerCase() < b.name.toLowerCase();\n return orderAscending ? (comparatorNames ? -1 : 1) : comparatorNames ? 1 : -1;\n });\n}\n\nexport function hasLogin(config: ConfigYaml) {\n return _.isNil(config?.web?.login) || config?.web?.login === true;\n}\n"],"mappings":";;;;;;;;;;AAAA;AACA;AAAuB;AAOvB,MAAMA,KAAK,GAAG,IAAAC,cAAU,EAAC,qBAAqB,CAAC;AAExC,SAASC,oBAAoB,CAACC,YAAY,EAAE;EACjD,MAAMC,KAAK,GAAG,wBAAwB,CAACC,IAAI,CAACF,YAAY,CAAC;EACzD,IAAI,CAACC,KAAK,EAAE;IACVJ,KAAK,CAAC,0BAA0B,EAAEG,YAAY,CAAC;IAC/C;EACF;EAEA,OAAOA,YAAY;AACrB;AAEO,SAASG,gBAAgB,CAACC,kBAA4B,EAAEC,UAAe,EAAO;EACnFR,KAAK,CAAC,mCAAmC,CAAC;EAC1CS,eAAC,CAACC,OAAO,CAACH,kBAAkB,EAAGI,QAAQ,IAAU;IAC/C,OAAOH,UAAU,CAACG,QAAQ,CAAC;EAC7B,CAAC,CAAC;EAEF,OAAOH,UAAU;AACnB;AAEO,SAASI,QAAQ,CAACC,KAAa,EAAEC,WAAmB,EAAU;EACnE,OAAQ,IAAGD,KAAM,IAAGC,WAAY,EAAC;AACnC;AAEO,SAASC,UAAU,CAACC,QAAe,EAAEC,cAA8B,GAAG,IAAI,EAAY;EAC3F,OAAOD,QAAQ,CAACE,KAAK,EAAE,CAACC,IAAI,CAAC,UAAUC,CAAC,EAAEC,CAAC,EAAU;IACnD,MAAMC,eAAe,GAAGF,CAAC,CAACG,IAAI,CAACC,WAAW,EAAE,GAAGH,CAAC,CAACE,IAAI,CAACC,WAAW,EAAE;IACnE,OAAOP,cAAc,GAAIK,eAAe,GAAG,CAAC,CAAC,GAAG,CAAC,GAAIA,eAAe,GAAG,CAAC,GAAG,CAAC,CAAC;EAC/E,CAAC,CAAC;AACJ;AAEO,SAASG,QAAQ,CAACC,MAAkB,EAAE;EAAA;EAC3C,OAAOjB,eAAC,CAACkB,KAAK,CAACD,MAAM,aAANA,MAAM,sCAANA,MAAM,CAAEE,GAAG,gDAAX,YAAaC,KAAK,CAAC,IAAI,CAAAH,MAAM,aAANA,MAAM,uCAANA,MAAM,CAAEE,GAAG,iDAAX,aAAaC,KAAK,MAAK,IAAI;AACnE"}
@@ -4,25 +4,18 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _express = _interopRequireDefault(require("express"));
9
-
10
8
  var _renderWeb = require("./middleware/render-web");
11
-
12
9
  var _webApi = require("./middleware/web-api");
13
-
14
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
16
11
  var _default = async (config, auth, storage) => {
17
12
  // eslint-disable-next-line new-cap
18
- const app = _express.default.Router(); // load application
19
-
20
-
21
- app.use('/', await (0, _renderWeb.renderWebMiddleware)(config, auth)); // web endpoints, search, packages, etc
22
-
13
+ const app = _express.default.Router();
14
+ // load application
15
+ app.use('/', await (0, _renderWeb.renderWebMiddleware)(config, auth));
16
+ // web endpoints, search, packages, etc
23
17
  app.use('/-/verdaccio/', (0, _webApi.webAPI)(config, auth, storage));
24
18
  return app;
25
19
  };
26
-
27
20
  exports.default = _default;
28
21
  //# sourceMappingURL=web-middleware.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"web-middleware.js","names":["config","auth","storage","app","express","Router","use","renderWebMiddleware","webAPI"],"sources":["../src/web-middleware.ts"],"sourcesContent":["import express from 'express';\n\nimport { renderWebMiddleware } from './middleware/render-web';\nimport { webAPI } from './middleware/web-api';\n\nexport default async (config, auth, storage) => {\n // eslint-disable-next-line new-cap\n const app = express.Router();\n // load application\n app.use('/', await renderWebMiddleware(config, auth));\n // web endpoints, search, packages, etc\n app.use('/-/verdaccio/', webAPI(config, auth, storage));\n return app;\n};\n"],"mappings":";;;;;;;AAAA;;AAEA;;AACA;;;;eAEe,OAAOA,MAAP,EAAeC,IAAf,EAAqBC,OAArB,KAAiC;EAC9C;EACA,MAAMC,GAAG,GAAGC,gBAAA,CAAQC,MAAR,EAAZ,CAF8C,CAG9C;;;EACAF,GAAG,CAACG,GAAJ,CAAQ,GAAR,EAAa,MAAM,IAAAC,8BAAA,EAAoBP,MAApB,EAA4BC,IAA5B,CAAnB,EAJ8C,CAK9C;;EACAE,GAAG,CAACG,GAAJ,CAAQ,eAAR,EAAyB,IAAAE,cAAA,EAAOR,MAAP,EAAeC,IAAf,EAAqBC,OAArB,CAAzB;EACA,OAAOC,GAAP;AACD,C"}
1
+ {"version":3,"file":"web-middleware.js","names":["config","auth","storage","app","express","Router","use","renderWebMiddleware","webAPI"],"sources":["../src/web-middleware.ts"],"sourcesContent":["import express from 'express';\n\nimport { renderWebMiddleware } from './middleware/render-web';\nimport { webAPI } from './middleware/web-api';\n\nexport default async (config, auth, storage) => {\n // eslint-disable-next-line new-cap\n const app = express.Router();\n // load application\n app.use('/', await renderWebMiddleware(config, auth));\n // web endpoints, search, packages, etc\n app.use('/-/verdaccio/', webAPI(config, auth, storage));\n return app;\n};\n"],"mappings":";;;;;;AAAA;AAEA;AACA;AAA8C;AAAA,eAE/B,OAAOA,MAAM,EAAEC,IAAI,EAAEC,OAAO,KAAK;EAC9C;EACA,MAAMC,GAAG,GAAGC,gBAAO,CAACC,MAAM,EAAE;EAC5B;EACAF,GAAG,CAACG,GAAG,CAAC,GAAG,EAAE,MAAM,IAAAC,8BAAmB,EAACP,MAAM,EAAEC,IAAI,CAAC,CAAC;EACrD;EACAE,GAAG,CAACG,GAAG,CAAC,eAAe,EAAE,IAAAE,cAAM,EAACR,MAAM,EAAEC,IAAI,EAAEC,OAAO,CAAC,CAAC;EACvD,OAAOC,GAAG;AACZ,CAAC;AAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verdaccio/web",
3
- "version": "6.0.0-6-next.37",
3
+ "version": "6.0.0-6-next.39",
4
4
  "description": "web ui middleware",
5
5
  "main": "./build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -25,35 +25,34 @@
25
25
  },
26
26
  "license": "MIT",
27
27
  "dependencies": {
28
- "@verdaccio/auth": "6.0.0-6-next.29",
29
- "@verdaccio/core": "6.0.0-6-next.50",
30
- "@verdaccio/config": "6.0.0-6-next.50",
31
- "@verdaccio/loaders": "6.0.0-6-next.19",
32
- "@verdaccio/logger": "6.0.0-6-next.18",
33
- "@verdaccio/middleware": "6.0.0-6-next.29",
34
- "@verdaccio/readme": "11.0.0-6-next.6",
35
- "@verdaccio/store": "6.0.0-6-next.30",
36
- "@verdaccio/tarball": "11.0.0-6-next.19",
37
- "@verdaccio/url": "11.0.0-6-next.16",
38
- "@verdaccio/utils": "6.0.0-6-next.18",
28
+ "@verdaccio/auth": "6.0.0-6-next.31",
29
+ "@verdaccio/core": "6.0.0-6-next.52",
30
+ "@verdaccio/config": "6.0.0-6-next.52",
31
+ "@verdaccio/loaders": "6.0.0-6-next.21",
32
+ "@verdaccio/logger": "6.0.0-6-next.20",
33
+ "@verdaccio/middleware": "6.0.0-6-next.31",
34
+ "@verdaccio/store": "6.0.0-6-next.32",
35
+ "@verdaccio/tarball": "11.0.0-6-next.21",
36
+ "@verdaccio/url": "11.0.0-6-next.18",
37
+ "@verdaccio/utils": "6.0.0-6-next.20",
39
38
  "body-parser": "1.20.1",
40
39
  "debug": "4.3.4",
41
40
  "express": "4.18.2",
42
41
  "lodash": "4.17.21",
43
- "lru-cache": "6.0.0"
42
+ "lru-cache": "7.14.1"
44
43
  },
45
44
  "devDependencies": {
46
- "@types/node": "16.11.65",
45
+ "@types/node": "16.18.3",
47
46
  "@verdaccio/types": "11.0.0-6-next.17",
48
47
  "@verdaccio/test-helper": "2.0.0-6-next.6",
49
- "@verdaccio/api": "6.0.0-6-next.33",
48
+ "@verdaccio/api": "6.0.0-6-next.35",
50
49
  "node-html-parser": "4.1.5",
51
- "supertest": "6.3.0",
50
+ "supertest": "6.3.1",
52
51
  "nock": "13.2.9",
53
- "jsdom": "20.0.1",
52
+ "jsdom": "20.0.3",
54
53
  "undici": "4.16.0",
55
- "verdaccio-auth-memory": "11.0.0-6-next.15",
56
- "verdaccio-memory": "11.0.0-6-next.17"
54
+ "verdaccio-auth-memory": "11.0.0-6-next.17",
55
+ "verdaccio-memory": "11.0.0-6-next.19"
57
56
  },
58
57
  "funding": {
59
58
  "type": "opencollective",
@@ -97,7 +97,7 @@ function addPackageWebApi(storage: Storage, auth: Auth, config: Config): Router
97
97
  debug('hit package web api %o');
98
98
 
99
99
  try {
100
- const localPackages: Version[] = await storage.getLocalDatabaseNext();
100
+ const localPackages: Version[] = await storage.getLocalDatabase();
101
101
 
102
102
  const order = getOrder(config?.web?.sort_packages);
103
103
  debug('order %o', order);
package/src/api/readme.ts CHANGED
@@ -4,20 +4,27 @@ import { Router } from 'express';
4
4
  import { Auth } from '@verdaccio/auth';
5
5
  import { HEADERS, HEADER_TYPE } from '@verdaccio/core';
6
6
  import { $NextFunctionVer, $RequestExtend, $ResponseExtend, allow } from '@verdaccio/middleware';
7
- import sanitizyReadme from '@verdaccio/readme';
8
7
  import { Storage } from '@verdaccio/store';
9
8
  import { Manifest } from '@verdaccio/types';
10
9
 
11
- import { AuthorAvatar, addScope, parseReadme } from '../utils/web-utils';
10
+ import { AuthorAvatar, addScope } from '../utils/web-utils';
12
11
 
13
12
  export { $RequestExtend, $ResponseExtend, $NextFunctionVer }; // Was required by other packages
14
13
 
15
14
  // TODO: review this type, should be on @verdacid/types
16
15
  export type PackageExt = Manifest & { author: AuthorAvatar; dist?: { tarball: string } };
17
-
18
- const debug = buildDebug('verdaccio:web:api:readme');
19
-
20
16
  export const NOT_README_FOUND = 'ERROR: No README data found!';
17
+ const debug = buildDebug('verdaccio:web:api:readme');
18
+ const getReadme = (readme) => {
19
+ if (typeof readme === 'string' && readme.length === 0) {
20
+ return NOT_README_FOUND;
21
+ }
22
+ if (typeof readme !== 'string') {
23
+ return NOT_README_FOUND;
24
+ } else {
25
+ return readme;
26
+ }
27
+ };
21
28
 
22
29
  function addReadmeWebApi(storage: Storage, auth: Auth): Router {
23
30
  debug('initialized readme web api');
@@ -53,11 +60,7 @@ function addReadmeWebApi(storage: Storage, auth: Auth): Router {
53
60
  })) as Manifest;
54
61
  debug('readme pkg %o', manifest?.name);
55
62
  res.set(HEADER_TYPE.CONTENT_TYPE, HEADERS.TEXT_PLAIN_UTF8);
56
- try {
57
- next(parseReadme(manifest.name, manifest.readme as string));
58
- } catch {
59
- next(sanitizyReadme(NOT_README_FOUND));
60
- }
63
+ next(getReadme(manifest.readme));
61
64
  } catch (err) {
62
65
  next(err);
63
66
  }
package/src/api/user.ts CHANGED
@@ -6,6 +6,7 @@ import { Auth } from '@verdaccio/auth';
6
6
  import {
7
7
  API_ERROR,
8
8
  APP_ERROR,
9
+ HEADERS,
9
10
  HTTP_STATUS,
10
11
  VerdaccioError,
11
12
  errorUtils,
@@ -33,7 +34,7 @@ function addUserAuthApi(auth: Auth, config: Config): Router {
33
34
  } else {
34
35
  req.remote_user = user as RemoteUser;
35
36
  const jWTSignOptions: JWTSignOptions = config.security.web.sign;
36
-
37
+ res.set(HEADERS.CACHE_CONTROL, 'no-cache, no-store');
37
38
  next({
38
39
  token: await auth.jwtEncrypt(user as RemoteUser, jWTSignOptions),
39
40
  username: req.remote_user.name,
@@ -18,8 +18,9 @@ export async function loadTheme(config: any) {
18
18
  const plugin = await asyncLoadPlugin(
19
19
  config.theme,
20
20
  { config, logger },
21
- function (plugin) {
22
- return typeof plugin === 'string';
21
+ // TODO: add types { staticPath: string; manifest: unknown; manifestFiles: unknown }
22
+ function (plugin: any) {
23
+ return plugin.staticPath && plugin.manifest && plugin.manifestFiles;
23
24
  },
24
25
  config?.serverSettings?.pluginPrefix ?? 'verdaccio-theme'
25
26
  );
package/src/renderHTML.ts CHANGED
@@ -12,7 +12,7 @@ import { hasLogin, validatePrimaryColor } from './utils/web-utils';
12
12
 
13
13
  const pkgJSON = require('../package.json');
14
14
  const DEFAULT_LANGUAGE = 'es-US';
15
- const cache = new LRU({ max: 500, maxAge: 1000 * 60 * 60 });
15
+ const cache = new LRU({ max: 500, ttl: 1000 * 60 * 60 });
16
16
 
17
17
  const debug = buildDebug('verdaccio:web:render');
18
18
 
@@ -1,7 +1,6 @@
1
1
  import buildDebug from 'debug';
2
2
  import _ from 'lodash';
3
3
 
4
- import sanitizyReadme from '@verdaccio/readme';
5
4
  // import { normalizeContributors } from '@verdaccio/store';
6
5
  import { Author, ConfigYaml } from '@verdaccio/types';
7
6
 
@@ -19,23 +18,6 @@ export function validatePrimaryColor(primaryColor) {
19
18
  return primaryColor;
20
19
  }
21
20
 
22
- /**
23
- * parse package readme - markdown/ascii
24
- * @param {String} packageName name of package
25
- * @param {String} readme package readme
26
- * @return {String} converted html template
27
- */
28
- export function parseReadme(packageName: string, readme: string): string | void {
29
- if (_.isEmpty(readme) === false) {
30
- debug('sanizity readme');
31
- return sanitizyReadme(readme);
32
- }
33
-
34
- // logs readme not found error
35
- // logger.error({ packageName }, '@{packageName}: No readme found');
36
- throw new Error('ERROR: No README data found!');
37
- }
38
-
39
21
  export function deleteProperties(propertiesToDelete: string[], objectItem: any): any {
40
22
  debug('deleted unused version properties');
41
23
  _.forEach(propertiesToDelete, (property): any => {
@@ -8,7 +8,7 @@ import { publishVersion } from '@verdaccio/test-helper';
8
8
  import { NOT_README_FOUND } from '../src/api/readme';
9
9
  import { initializeServer } from './helper';
10
10
 
11
- setup([]);
11
+ setup({});
12
12
 
13
13
  const mockManifest = jest.fn();
14
14
  jest.mock('@verdaccio/ui-theme', () => mockManifest());
@@ -55,6 +55,7 @@ describe('test web server', () => {
55
55
  )
56
56
  .set(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON)
57
57
  .expect(HEADER_TYPE.CONTENT_TYPE, HEADERS.JSON_CHARSET)
58
+ .expect(HEADERS.CACHE_CONTROL, 'no-cache, no-store')
58
59
  .expect(HTTP_STATUS.OK)
59
60
  .then((res) => {
60
61
  expect(res.body.error).toBeUndefined();
@@ -1,11 +1,4 @@
1
- import fs from 'fs';
2
- import path from 'path';
3
-
4
- import { parseReadme, validatePrimaryColor } from '../src/utils/web-utils';
5
-
6
- const readmeFile = (fileName = 'markdown.md') => {
7
- return fs.readFileSync(path.join(__dirname, `./partials/readme/${fileName}`));
8
- };
1
+ import { validatePrimaryColor } from '../src/utils/web-utils';
9
2
 
10
3
  describe('Utilities', () => {
11
4
  describe('validatePrimaryColor', () => {
@@ -17,29 +10,4 @@ describe('Utilities', () => {
17
10
  expect(validatePrimaryColor('fff')).toBeUndefined();
18
11
  });
19
12
  });
20
- describe('parseReadme', () => {
21
- test('should parse makrdown text to html template', () => {
22
- const markdown = '# markdown';
23
- expect(parseReadme('testPackage', markdown)).toEqual('<h1 id="markdown">markdown</h1>');
24
- // @ts-ignore
25
- expect(parseReadme('testPackage', String(readmeFile('markdown.md')))).toMatchSnapshot();
26
- });
27
-
28
- test('should pass for conversion of non-ascii to markdown text', () => {
29
- const simpleText = 'simple text';
30
- const randomText = '%%%%%**##==';
31
- const randomTextMarkdown = 'simple text \n # markdown';
32
-
33
- expect(parseReadme('testPackage', randomText)).toEqual('<p>%%%%%**##==</p>');
34
- expect(parseReadme('testPackage', simpleText)).toEqual('<p>simple text</p>');
35
- expect(parseReadme('testPackage', randomTextMarkdown)).toEqual(
36
- '<p>simple text </p>\n<h1 id="markdown">markdown</h1>'
37
- );
38
- });
39
-
40
- test('should show error for no readme data', () => {
41
- const noData = '';
42
- expect(() => parseReadme('testPackage', noData)).toThrowError('ERROR: No README data found!');
43
- });
44
- });
45
13
  });
@@ -1,51 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`Utilities parseReadme should parse makrdown text to html template 1`] = `
4
- "<h1 id="project-title">Project Title</h1>
5
- <p>One Paragraph of project description goes here</p>
6
- <h2 id="getting-started">Getting Started</h2>
7
- <p>These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.</p>
8
- <h3 id="prerequisites">Prerequisites</h3>
9
- <p>What things you need to install the software and how to install them</p>
10
- <pre><code>Give examples
11
- </code></pre>
12
- <h3 id="installing">Installing</h3>
13
- <p>A step by step series of examples that tell you how to get a development env running</p>
14
- <p>Say what the step will be</p>
15
- <pre><code>Give the example
16
- </code></pre>
17
- <p>And repeat</p>
18
- <pre><code>until finished
19
- </code></pre>
20
- <p>End with an example of getting some data out of the system or using it for a little demo</p>
21
- <h2 id="running-the-tests">Running the tests</h2>
22
- <p>Explain how to run the automated tests for this system</p>
23
- <h3 id="break-down-into-end-to-end-tests">Break down into end to end tests</h3>
24
- <p>Explain what these tests test and why</p>
25
- <pre><code>Give an example
26
- </code></pre>
27
- <h3 id="and-coding-style-tests">And coding style tests</h3>
28
- <p>Explain what these tests test and why</p>
29
- <pre><code>Give an example
30
- </code></pre>
31
- <h2 id="deployment">Deployment</h2>
32
- <p>Add additional notes about how to deploy this on a live system</p>
33
- <h2 id="built-with">Built With</h2>
34
- <ul>
35
- <li>The web framework used</li>
36
- <li>Dependency Management</li>
37
- <li>Used to generate RSS Feeds</li>
38
- </ul>
39
- <h2 id="contributing">Contributing</h2>
40
- <p>Please read <a href="CONTRIBUTING.md">CONTRIBUTING.md</a> for details on our code of conduct, and the process for submitting pull requests to us.</p>
41
- <h2 id="versioning">Versioning</h2>
42
- <p>We use <a href="http://semver.org/">SemVer</a> for versioning. For the versions available, see the <a href="https://github.com/your/project/tags">tags on this repository</a>.</p>
43
- <h2 id="license">License</h2>
44
- <p>This project is licensed under the MIT License - see the <a href="LICENSE.md">LICENSE.md</a> file for details</p>
45
- <h2 id="acknowledgments">Acknowledgments</h2>
46
- <ul>
47
- <li>Hat tip to anyone whose code was used</li>
48
- <li>Inspiration</li>
49
- <li>etc</li>
50
- </ul>"
51
- `;
@@ -1,81 +0,0 @@
1
- # Project Title
2
-
3
- One Paragraph of project description goes here
4
-
5
- ## Getting Started
6
-
7
- These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
8
-
9
- ### Prerequisites
10
-
11
- What things you need to install the software and how to install them
12
-
13
- ```
14
- Give examples
15
- ```
16
-
17
- ### Installing
18
-
19
- A step by step series of examples that tell you how to get a development env running
20
-
21
- Say what the step will be
22
-
23
- ```
24
- Give the example
25
- ```
26
-
27
- And repeat
28
-
29
- ```
30
- until finished
31
- ```
32
-
33
- End with an example of getting some data out of the system or using it for a little demo
34
-
35
- ## Running the tests
36
-
37
- Explain how to run the automated tests for this system
38
-
39
- ### Break down into end to end tests
40
-
41
- Explain what these tests test and why
42
-
43
- ```
44
- Give an example
45
- ```
46
-
47
- ### And coding style tests
48
-
49
- Explain what these tests test and why
50
-
51
- ```
52
- Give an example
53
- ```
54
-
55
- ## Deployment
56
-
57
- Add additional notes about how to deploy this on a live system
58
-
59
- ## Built With
60
-
61
- - The web framework used
62
- - Dependency Management
63
- - Used to generate RSS Feeds
64
-
65
- ## Contributing
66
-
67
- Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us.
68
-
69
- ## Versioning
70
-
71
- We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/your/project/tags).
72
-
73
- ## License
74
-
75
- This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details
76
-
77
- ## Acknowledgments
78
-
79
- - Hat tip to anyone whose code was used
80
- - Inspiration
81
- - etc