oc 0.49.8 → 0.49.9

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 (244) hide show
  1. package/dist/cli/commands.d.ts +163 -163
  2. package/dist/cli/commands.js +162 -162
  3. package/dist/cli/domain/clean.d.ts +2 -2
  4. package/dist/cli/domain/clean.js +24 -24
  5. package/dist/cli/domain/get-components-by-dir.d.ts +1 -1
  6. package/dist/cli/domain/get-components-by-dir.js +41 -41
  7. package/dist/cli/domain/get-mocked-plugins.d.ts +10 -10
  8. package/dist/cli/domain/get-mocked-plugins.js +89 -89
  9. package/dist/cli/domain/handle-dependencies/ensure-compiler-is-declared-as-devDependency.d.ts +6 -6
  10. package/dist/cli/domain/handle-dependencies/ensure-compiler-is-declared-as-devDependency.js +16 -16
  11. package/dist/cli/domain/handle-dependencies/get-compiler.d.ts +10 -10
  12. package/dist/cli/domain/handle-dependencies/get-compiler.js +28 -28
  13. package/dist/cli/domain/handle-dependencies/get-missing-dependencies.d.ts +1 -1
  14. package/dist/cli/domain/handle-dependencies/get-missing-dependencies.js +18 -18
  15. package/dist/cli/domain/handle-dependencies/index.d.ts +10 -10
  16. package/dist/cli/domain/handle-dependencies/index.js +70 -70
  17. package/dist/cli/domain/handle-dependencies/install-compiler.d.ts +8 -8
  18. package/dist/cli/domain/handle-dependencies/install-compiler.js +54 -54
  19. package/dist/cli/domain/handle-dependencies/install-missing-dependencies.d.ts +5 -5
  20. package/dist/cli/domain/handle-dependencies/install-missing-dependencies.js +59 -59
  21. package/dist/cli/domain/handle-dependencies/link-missing-dependencies.d.ts +6 -6
  22. package/dist/cli/domain/handle-dependencies/link-missing-dependencies.js +32 -32
  23. package/dist/cli/domain/handle-dependencies/require-template.d.ts +17 -17
  24. package/dist/cli/domain/handle-dependencies/require-template.js +34 -34
  25. package/dist/cli/domain/init-template/index.d.ts +10 -10
  26. package/dist/cli/domain/init-template/index.js +40 -40
  27. package/dist/cli/domain/init-template/install-template.d.ts +11 -11
  28. package/dist/cli/domain/init-template/install-template.js +54 -54
  29. package/dist/cli/domain/init-template/scaffold.d.ts +11 -11
  30. package/dist/cli/domain/init-template/scaffold.js +30 -30
  31. package/dist/cli/domain/local.d.ts +2 -2
  32. package/dist/cli/domain/local.js +82 -82
  33. package/dist/cli/domain/mock.d.ts +5 -5
  34. package/dist/cli/domain/mock.js +33 -33
  35. package/dist/cli/domain/package-components.d.ts +9 -9
  36. package/dist/cli/domain/package-components.js +67 -67
  37. package/dist/cli/domain/registry.d.ts +6 -6
  38. package/dist/cli/domain/registry.js +136 -136
  39. package/dist/cli/domain/url-parser.d.ts +14 -14
  40. package/dist/cli/domain/url-parser.js +31 -31
  41. package/dist/cli/domain/watch.d.ts +1 -1
  42. package/dist/cli/domain/watch.js +29 -29
  43. package/dist/cli/facade/clean.d.ts +16 -16
  44. package/dist/cli/facade/clean.js +58 -58
  45. package/dist/cli/facade/dev.d.ts +114 -114
  46. package/dist/cli/facade/dev.js +176 -176
  47. package/dist/cli/facade/init.d.ts +18 -18
  48. package/dist/cli/facade/init.js +39 -39
  49. package/dist/cli/facade/mock.d.ts +18 -18
  50. package/dist/cli/facade/mock.js +12 -12
  51. package/dist/cli/facade/package.d.ts +18 -18
  52. package/dist/cli/facade/package.js +49 -49
  53. package/dist/cli/facade/preview.d.ts +14 -14
  54. package/dist/cli/facade/preview.js +20 -20
  55. package/dist/cli/facade/publish.d.ts +23 -23
  56. package/dist/cli/facade/publish.js +145 -145
  57. package/dist/cli/facade/registry-add.d.ts +14 -14
  58. package/dist/cli/facade/registry-add.js +18 -18
  59. package/dist/cli/facade/registry-ls.d.ts +10 -10
  60. package/dist/cli/facade/registry-ls.js +27 -27
  61. package/dist/cli/facade/registry-remove.d.ts +14 -14
  62. package/dist/cli/facade/registry-remove.js +18 -18
  63. package/dist/cli/facade/registry.d.ts +5 -5
  64. package/dist/cli/facade/registry.js +9 -9
  65. package/dist/cli/index.d.ts +1 -1
  66. package/dist/cli/index.js +91 -91
  67. package/dist/cli/logger.d.ts +8 -8
  68. package/dist/cli/logger.js +19 -19
  69. package/dist/cli/programmatic-api.d.ts +84 -84
  70. package/dist/cli/programmatic-api.js +66 -66
  71. package/dist/cli/validate-command.d.ts +2 -2
  72. package/dist/cli/validate-command.js +18 -18
  73. package/dist/components/oc-client/_package/package.json +1 -1
  74. package/dist/components/oc-client/package.json +1 -1
  75. package/dist/index.d.ts +3 -3
  76. package/dist/index.js +12 -12
  77. package/dist/oc-cli.d.ts +2 -2
  78. package/dist/oc-cli.js +3 -3
  79. package/dist/registry/app-start.d.ts +2 -2
  80. package/dist/registry/app-start.js +44 -44
  81. package/dist/registry/domain/authentication.d.ts +7 -7
  82. package/dist/registry/domain/authentication.js +53 -53
  83. package/dist/registry/domain/components-cache/components-list.d.ts +8 -8
  84. package/dist/registry/domain/components-cache/components-list.js +50 -50
  85. package/dist/registry/domain/components-cache/index.d.ts +7 -7
  86. package/dist/registry/domain/components-cache/index.js +76 -76
  87. package/dist/registry/domain/components-details.d.ts +6 -6
  88. package/dist/registry/domain/components-details.js +64 -64
  89. package/dist/registry/domain/events-handler.d.ts +40 -40
  90. package/dist/registry/domain/events-handler.js +37 -37
  91. package/dist/registry/domain/extract-package.d.ts +8 -8
  92. package/dist/registry/domain/extract-package.js +26 -26
  93. package/dist/registry/domain/get-package-json-from-temp-dir.d.ts +2 -2
  94. package/dist/registry/domain/get-package-json-from-temp-dir.js +11 -11
  95. package/dist/registry/domain/nested-renderer.d.ts +14 -14
  96. package/dist/registry/domain/nested-renderer.js +59 -59
  97. package/dist/registry/domain/options-sanitiser.d.ts +6 -6
  98. package/dist/registry/domain/options-sanitiser.js +106 -106
  99. package/dist/registry/domain/plugins-initialiser.d.ts +3 -3
  100. package/dist/registry/domain/plugins-initialiser.js +95 -95
  101. package/dist/registry/domain/register-templates.d.ts +5 -5
  102. package/dist/registry/domain/register-templates.js +30 -30
  103. package/dist/registry/domain/repository.d.ts +2 -2
  104. package/dist/registry/domain/repository.js +237 -237
  105. package/dist/registry/domain/require-wrapper.d.ts +2 -2
  106. package/dist/registry/domain/require-wrapper.js +33 -33
  107. package/dist/registry/domain/sanitiser.d.ts +2 -2
  108. package/dist/registry/domain/sanitiser.js +52 -52
  109. package/dist/registry/domain/storage-adapter.d.ts +10 -10
  110. package/dist/registry/domain/storage-adapter.js +55 -55
  111. package/dist/registry/domain/url-builder.d.ts +10 -10
  112. package/dist/registry/domain/url-builder.js +60 -60
  113. package/dist/registry/domain/validators/component-parameters.d.ts +11 -11
  114. package/dist/registry/domain/validators/component-parameters.js +79 -79
  115. package/dist/registry/domain/validators/index.d.ts +16 -16
  116. package/dist/registry/domain/validators/index.js +29 -29
  117. package/dist/registry/domain/validators/node-version.d.ts +15 -15
  118. package/dist/registry/domain/validators/node-version.js +40 -40
  119. package/dist/registry/domain/validators/oc-cli-version.d.ts +15 -15
  120. package/dist/registry/domain/validators/oc-cli-version.js +34 -34
  121. package/dist/registry/domain/validators/package-json-validator.d.ts +13 -13
  122. package/dist/registry/domain/validators/package-json-validator.js +23 -23
  123. package/dist/registry/domain/validators/plugins-requirements.d.ts +9 -9
  124. package/dist/registry/domain/validators/plugins-requirements.js +22 -22
  125. package/dist/registry/domain/validators/registry-configuration.d.ts +9 -9
  126. package/dist/registry/domain/validators/registry-configuration.js +113 -113
  127. package/dist/registry/domain/validators/uploaded-package.d.ts +14 -14
  128. package/dist/registry/domain/validators/uploaded-package.js +25 -25
  129. package/dist/registry/domain/version-handler.d.ts +2 -2
  130. package/dist/registry/domain/version-handler.js +22 -22
  131. package/dist/registry/index.d.ts +48 -48
  132. package/dist/registry/index.js +107 -107
  133. package/dist/registry/middleware/base-url-handler.d.ts +2 -2
  134. package/dist/registry/middleware/base-url-handler.js +12 -12
  135. package/dist/registry/middleware/cors.d.ts +2 -2
  136. package/dist/registry/middleware/cors.js +11 -11
  137. package/dist/registry/middleware/discovery-handler.d.ts +2 -2
  138. package/dist/registry/middleware/discovery-handler.js +15 -15
  139. package/dist/registry/middleware/file-uploads.d.ts +2 -2
  140. package/dist/registry/middleware/file-uploads.js +23 -23
  141. package/dist/registry/middleware/index.d.ts +7 -7
  142. package/dist/registry/middleware/index.js +51 -51
  143. package/dist/registry/middleware/request-handler.d.ts +2 -2
  144. package/dist/registry/middleware/request-handler.js +30 -30
  145. package/dist/registry/router.d.ts +3 -3
  146. package/dist/registry/router.js +56 -56
  147. package/dist/registry/routes/component-info.d.ts +3 -3
  148. package/dist/registry/routes/component-info.js +90 -90
  149. package/dist/registry/routes/component-preview.d.ts +3 -3
  150. package/dist/registry/routes/component-preview.js +68 -68
  151. package/dist/registry/routes/component.d.ts +3 -3
  152. package/dist/registry/routes/component.js +43 -43
  153. package/dist/registry/routes/components.d.ts +3 -3
  154. package/dist/registry/routes/components.js +78 -78
  155. package/dist/registry/routes/dependencies.d.ts +3 -3
  156. package/dist/registry/routes/dependencies.js +28 -28
  157. package/dist/registry/routes/helpers/apply-default-values.d.ts +2 -2
  158. package/dist/registry/routes/helpers/apply-default-values.js +13 -13
  159. package/dist/registry/routes/helpers/get-available-dependencies.d.ts +8 -8
  160. package/dist/registry/routes/helpers/get-available-dependencies.js +24 -24
  161. package/dist/registry/routes/helpers/get-component-fallback.d.ts +17 -17
  162. package/dist/registry/routes/helpers/get-component-fallback.js +91 -91
  163. package/dist/registry/routes/helpers/get-component-retrieving-info.d.ts +20 -20
  164. package/dist/registry/routes/helpers/get-component-retrieving-info.js +24 -24
  165. package/dist/registry/routes/helpers/get-component.d.ts +33 -33
  166. package/dist/registry/routes/helpers/get-component.js +406 -406
  167. package/dist/registry/routes/helpers/get-components-history.d.ts +8 -8
  168. package/dist/registry/routes/helpers/get-components-history.js +28 -28
  169. package/dist/registry/routes/helpers/is-url-discoverable.d.ts +3 -3
  170. package/dist/registry/routes/helpers/is-url-discoverable.js +22 -22
  171. package/dist/registry/routes/index.d.ts +3 -3
  172. package/dist/registry/routes/index.js +93 -93
  173. package/dist/registry/routes/plugins.d.ts +3 -3
  174. package/dist/registry/routes/plugins.js +17 -17
  175. package/dist/registry/routes/publish.d.ts +3 -3
  176. package/dist/registry/routes/publish.js +97 -97
  177. package/dist/registry/routes/static-redirector.d.ts +3 -3
  178. package/dist/registry/routes/static-redirector.js +63 -63
  179. package/dist/registry/views/index.d.ts +2 -2
  180. package/dist/registry/views/index.js +39 -39
  181. package/dist/registry/views/info.d.ts +16 -16
  182. package/dist/registry/views/info.js +39 -39
  183. package/dist/registry/views/partials/component-author.d.ts +8 -8
  184. package/dist/registry/views/partials/component-author.js +20 -20
  185. package/dist/registry/views/partials/component-parameters.d.ts +5 -5
  186. package/dist/registry/views/partials/component-parameters.js +24 -24
  187. package/dist/registry/views/partials/component-state.d.ts +5 -5
  188. package/dist/registry/views/partials/component-state.js +6 -6
  189. package/dist/registry/views/partials/component-versions.d.ts +5 -5
  190. package/dist/registry/views/partials/component-versions.js +9 -9
  191. package/dist/registry/views/partials/components-dependencies.d.ts +2 -2
  192. package/dist/registry/views/partials/components-dependencies.js +12 -12
  193. package/dist/registry/views/partials/components-history.d.ts +2 -2
  194. package/dist/registry/views/partials/components-history.js +10 -10
  195. package/dist/registry/views/partials/components-list.d.ts +2 -2
  196. package/dist/registry/views/partials/components-list.js +26 -26
  197. package/dist/registry/views/partials/components-plugins.d.ts +2 -2
  198. package/dist/registry/views/partials/components-plugins.js +8 -8
  199. package/dist/registry/views/partials/components-templates.d.ts +2 -2
  200. package/dist/registry/views/partials/components-templates.js +14 -14
  201. package/dist/registry/views/partials/layout.d.ts +8 -8
  202. package/dist/registry/views/partials/layout.js +11 -11
  203. package/dist/registry/views/partials/property.d.ts +2 -2
  204. package/dist/registry/views/partials/property.js +11 -11
  205. package/dist/registry/views/partials/selected-checkbox.d.ts +4 -4
  206. package/dist/registry/views/partials/selected-checkbox.js +7 -7
  207. package/dist/registry/views/preview.d.ts +8 -8
  208. package/dist/registry/views/preview.js +9 -9
  209. package/dist/registry/views/static/index.d.ts +2 -2
  210. package/dist/registry/views/static/index.js +3 -3
  211. package/dist/registry/views/static/info.d.ts +2 -2
  212. package/dist/registry/views/static/info.js +3 -3
  213. package/dist/registry/views/static/style.d.ts +2 -2
  214. package/dist/registry/views/static/style.js +3 -3
  215. package/dist/resources/index.d.ts +134 -134
  216. package/dist/resources/index.js +145 -145
  217. package/dist/resources/settings.d.ts +17 -17
  218. package/dist/resources/settings.js +18 -18
  219. package/dist/types.d.ts +287 -287
  220. package/dist/types.js +2 -2
  221. package/dist/utils/clean-require.d.ts +16 -16
  222. package/dist/utils/clean-require.js +18 -18
  223. package/dist/utils/date-stringify.d.ts +1 -1
  224. package/dist/utils/date-stringify.js +22 -22
  225. package/dist/utils/error-to-string.d.ts +1 -1
  226. package/dist/utils/error-to-string.js +15 -15
  227. package/dist/utils/is-template-legacy.d.ts +3 -3
  228. package/dist/utils/is-template-legacy.js +6 -6
  229. package/dist/utils/is-template-valid.d.ts +4 -4
  230. package/dist/utils/is-template-valid.js +12 -12
  231. package/dist/utils/module-exists.d.ts +1 -1
  232. package/dist/utils/module-exists.js +15 -15
  233. package/dist/utils/npm-utils.d.ts +20 -20
  234. package/dist/utils/npm-utils.js +74 -74
  235. package/dist/utils/put.d.ts +2 -2
  236. package/dist/utils/put.js +29 -29
  237. package/dist/utils/strip-version.d.ts +1 -1
  238. package/dist/utils/strip-version.js +11 -11
  239. package/logintervals.md +1 -1
  240. package/package.json +1 -1
  241. package/src/cli/facade/dev.ts +1 -1
  242. package/src/components/oc-client/_package/package.json +1 -1
  243. package/src/components/oc-client/package.json +1 -1
  244. package/src/oc-cli.js +0 -0
@@ -1,8 +1,8 @@
1
- import { ComponentsDetails } from '../../../types';
2
- interface ComponentHistory {
3
- name: string;
4
- version: string;
5
- publishDate: string;
6
- }
7
- export default function getComponentsHistory(history: ComponentsDetails): ComponentHistory[];
8
- export {};
1
+ import { ComponentsDetails } from '../../../types';
2
+ interface ComponentHistory {
3
+ name: string;
4
+ version: string;
5
+ publishDate: string;
6
+ }
7
+ export default function getComponentsHistory(history: ComponentsDetails): ComponentHistory[];
8
+ export {};
@@ -1,28 +1,28 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const date_stringify_1 = __importDefault(require("../../../utils/date-stringify"));
7
- function getComponentsHistory(history) {
8
- const result = [];
9
- for (const [name, versions] of Object.entries(history.components)) {
10
- for (const [version, details] of Object.entries(versions)) {
11
- result.push({
12
- name,
13
- publishDate: details.publishDate,
14
- version
15
- });
16
- }
17
- }
18
- return result
19
- .sort((a, b) => b.publishDate - a.publishDate)
20
- .map(x => ({
21
- name: x.name,
22
- version: x.version,
23
- publishDate: !x.publishDate
24
- ? 'Unknown'
25
- : (0, date_stringify_1.default)(new Date(x.publishDate))
26
- }));
27
- }
28
- exports.default = getComponentsHistory;
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const date_stringify_1 = __importDefault(require("../../../utils/date-stringify"));
7
+ function getComponentsHistory(history) {
8
+ const result = [];
9
+ for (const [name, versions] of Object.entries(history.components)) {
10
+ for (const [version, details] of Object.entries(versions)) {
11
+ result.push({
12
+ name,
13
+ publishDate: details.publishDate,
14
+ version
15
+ });
16
+ }
17
+ }
18
+ return result
19
+ .sort((a, b) => b.publishDate - a.publishDate)
20
+ .map(x => ({
21
+ name: x.name,
22
+ version: x.version,
23
+ publishDate: !x.publishDate
24
+ ? 'Unknown'
25
+ : (0, date_stringify_1.default)(new Date(x.publishDate))
26
+ }));
27
+ }
28
+ exports.default = getComponentsHistory;
@@ -1,3 +1,3 @@
1
- export default function isUrlDiscoverable(url: string): Promise<{
2
- isDiscoverable: boolean;
3
- }>;
1
+ export default function isUrlDiscoverable(url: string): Promise<{
2
+ isDiscoverable: boolean;
3
+ }>;
@@ -1,22 +1,22 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const got_1 = __importDefault(require("got"));
7
- async function isUrlDiscoverable(url) {
8
- var _a;
9
- try {
10
- const res = await (0, got_1.default)(url, {
11
- headers: { accept: 'text/html' }
12
- });
13
- const isHtml = !!((_a = res.headers['content-type']) === null || _a === void 0 ? void 0 : _a.includes('text/html'));
14
- return {
15
- isDiscoverable: isHtml
16
- };
17
- }
18
- catch (err) {
19
- return { isDiscoverable: false };
20
- }
21
- }
22
- exports.default = isUrlDiscoverable;
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const got_1 = __importDefault(require("got"));
7
+ async function isUrlDiscoverable(url) {
8
+ var _a;
9
+ try {
10
+ const res = await (0, got_1.default)(url, {
11
+ headers: { accept: 'text/html' }
12
+ });
13
+ const isHtml = !!((_a = res.headers['content-type']) === null || _a === void 0 ? void 0 : _a.includes('text/html'));
14
+ return {
15
+ isDiscoverable: isHtml
16
+ };
17
+ }
18
+ catch (err) {
19
+ return { isDiscoverable: false };
20
+ }
21
+ }
22
+ exports.default = isUrlDiscoverable;
@@ -1,3 +1,3 @@
1
- import { Repository } from '../../types';
2
- import { NextFunction, Request, Response } from 'express';
3
- export default function (repository: Repository): (req: Request, res: Response, next: NextFunction) => void;
1
+ import { Repository } from '../../types';
2
+ import { NextFunction, Request, Response } from 'express';
3
+ export default function (repository: Repository): (req: Request, res: Response, next: NextFunction) => void;
@@ -1,93 +1,93 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const async_1 = __importDefault(require("async"));
7
- const parse_author_1 = __importDefault(require("parse-author"));
8
- const lodash_1 = __importDefault(require("lodash"));
9
- const path_1 = __importDefault(require("path"));
10
- const fs_extra_1 = __importDefault(require("fs-extra"));
11
- const date_stringify_1 = __importDefault(require("../../utils/date-stringify"));
12
- const get_components_history_1 = __importDefault(require("./helpers/get-components-history"));
13
- const get_available_dependencies_1 = __importDefault(require("./helpers/get-available-dependencies"));
14
- const views_1 = __importDefault(require("../views"));
15
- const urlBuilder = require("../domain/url-builder");
16
- const universalify_1 = require("universalify");
17
- const packageInfo = fs_extra_1.default.readJsonSync(path_1.default.join(__dirname, '..', '..', '..', 'package.json'));
18
- const getParsedAuthor = (author) => {
19
- author = author || {};
20
- return typeof author === 'string' ? (0, parse_author_1.default)(author) : author;
21
- };
22
- const mapComponentDetails = (component) => Object.assign(component, { author: getParsedAuthor(component.author) });
23
- const isHtmlRequest = (headers) => !!headers.accept && headers.accept.indexOf('text/html') >= 0;
24
- function default_1(repository) {
25
- return (req, res, next) => {
26
- (0, universalify_1.fromPromise)(repository.getComponents)((err, components) => {
27
- if (err) {
28
- res.errorDetails = 'cdn not available';
29
- res.status(404).json({ error: res.errorDetails });
30
- return;
31
- }
32
- const baseResponse = {
33
- href: res.conf.baseUrl,
34
- ocVersion: packageInfo.version,
35
- type: res.conf.local ? 'oc-registry-local' : 'oc-registry'
36
- };
37
- if (isHtmlRequest(req.headers) && !!res.conf.discovery) {
38
- let componentsInfo = [];
39
- let componentsReleases = 0;
40
- const stateCounts = {};
41
- async_1.default.each(components, (component, callback) => (0, universalify_1.fromPromise)(repository.getComponent)(component, undefined, (err, result) => {
42
- if (err)
43
- return callback(err);
44
- if (result.oc && result.oc.date) {
45
- result.oc.stringifiedDate = (0, date_stringify_1.default)(new Date(result.oc.date));
46
- }
47
- componentsInfo.push(mapComponentDetails(result));
48
- componentsReleases += result.allVersions.length;
49
- callback();
50
- }), err => {
51
- if (err)
52
- return next(err);
53
- componentsInfo = lodash_1.default.sortBy(componentsInfo, 'name');
54
- (0, universalify_1.fromPromise)(repository.getComponentsDetails)((err, details) => {
55
- // eslint-disable-next-line no-console
56
- if (err)
57
- console.log(err);
58
- res.send((0, views_1.default)(
59
- // @ts-ignore
60
- Object.assign(baseResponse, {
61
- availableDependencies: (0, get_available_dependencies_1.default)(res.conf.dependencies),
62
- availablePlugins: res.conf.plugins,
63
- components: componentsInfo,
64
- componentsReleases,
65
- componentsList: componentsInfo.map(component => {
66
- const state = lodash_1.default.get(component, 'oc.state', '');
67
- if (state) {
68
- stateCounts[state] = (stateCounts[state] || 0) + 1;
69
- }
70
- return {
71
- name: component.name,
72
- author: component.author,
73
- state
74
- };
75
- }),
76
- componentsHistory: !res.conf.local && (0, get_components_history_1.default)(details),
77
- q: req.query['q'] || '',
78
- stateCounts,
79
- templates: repository.getTemplatesInfo(),
80
- title: 'OpenComponents Registry'
81
- })));
82
- });
83
- });
84
- }
85
- else {
86
- res.status(200).json(Object.assign(baseResponse, {
87
- components: lodash_1.default.map(components, component => urlBuilder.component(component, res.conf.baseUrl))
88
- }));
89
- }
90
- });
91
- };
92
- }
93
- exports.default = default_1;
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const async_1 = __importDefault(require("async"));
7
+ const parse_author_1 = __importDefault(require("parse-author"));
8
+ const lodash_1 = __importDefault(require("lodash"));
9
+ const path_1 = __importDefault(require("path"));
10
+ const fs_extra_1 = __importDefault(require("fs-extra"));
11
+ const date_stringify_1 = __importDefault(require("../../utils/date-stringify"));
12
+ const get_components_history_1 = __importDefault(require("./helpers/get-components-history"));
13
+ const get_available_dependencies_1 = __importDefault(require("./helpers/get-available-dependencies"));
14
+ const views_1 = __importDefault(require("../views"));
15
+ const urlBuilder = require("../domain/url-builder");
16
+ const universalify_1 = require("universalify");
17
+ const packageInfo = fs_extra_1.default.readJsonSync(path_1.default.join(__dirname, '..', '..', '..', 'package.json'));
18
+ const getParsedAuthor = (author) => {
19
+ author = author || {};
20
+ return typeof author === 'string' ? (0, parse_author_1.default)(author) : author;
21
+ };
22
+ const mapComponentDetails = (component) => Object.assign(component, { author: getParsedAuthor(component.author) });
23
+ const isHtmlRequest = (headers) => !!headers.accept && headers.accept.indexOf('text/html') >= 0;
24
+ function default_1(repository) {
25
+ return (req, res, next) => {
26
+ (0, universalify_1.fromPromise)(repository.getComponents)((err, components) => {
27
+ if (err) {
28
+ res.errorDetails = 'cdn not available';
29
+ res.status(404).json({ error: res.errorDetails });
30
+ return;
31
+ }
32
+ const baseResponse = {
33
+ href: res.conf.baseUrl,
34
+ ocVersion: packageInfo.version,
35
+ type: res.conf.local ? 'oc-registry-local' : 'oc-registry'
36
+ };
37
+ if (isHtmlRequest(req.headers) && !!res.conf.discovery) {
38
+ let componentsInfo = [];
39
+ let componentsReleases = 0;
40
+ const stateCounts = {};
41
+ async_1.default.each(components, (component, callback) => (0, universalify_1.fromPromise)(repository.getComponent)(component, undefined, (err, result) => {
42
+ if (err)
43
+ return callback(err);
44
+ if (result.oc && result.oc.date) {
45
+ result.oc.stringifiedDate = (0, date_stringify_1.default)(new Date(result.oc.date));
46
+ }
47
+ componentsInfo.push(mapComponentDetails(result));
48
+ componentsReleases += result.allVersions.length;
49
+ callback();
50
+ }), err => {
51
+ if (err)
52
+ return next(err);
53
+ componentsInfo = lodash_1.default.sortBy(componentsInfo, 'name');
54
+ (0, universalify_1.fromPromise)(repository.getComponentsDetails)((err, details) => {
55
+ // eslint-disable-next-line no-console
56
+ if (err)
57
+ console.log(err);
58
+ res.send((0, views_1.default)(
59
+ // @ts-ignore
60
+ Object.assign(baseResponse, {
61
+ availableDependencies: (0, get_available_dependencies_1.default)(res.conf.dependencies),
62
+ availablePlugins: res.conf.plugins,
63
+ components: componentsInfo,
64
+ componentsReleases,
65
+ componentsList: componentsInfo.map(component => {
66
+ const state = lodash_1.default.get(component, 'oc.state', '');
67
+ if (state) {
68
+ stateCounts[state] = (stateCounts[state] || 0) + 1;
69
+ }
70
+ return {
71
+ name: component.name,
72
+ author: component.author,
73
+ state
74
+ };
75
+ }),
76
+ componentsHistory: !res.conf.local && (0, get_components_history_1.default)(details),
77
+ q: req.query['q'] || '',
78
+ stateCounts,
79
+ templates: repository.getTemplatesInfo(),
80
+ title: 'OpenComponents Registry'
81
+ })));
82
+ });
83
+ });
84
+ }
85
+ else {
86
+ res.status(200).json(Object.assign(baseResponse, {
87
+ components: lodash_1.default.map(components, component => urlBuilder.component(component, res.conf.baseUrl))
88
+ }));
89
+ }
90
+ });
91
+ };
92
+ }
93
+ exports.default = default_1;
@@ -1,3 +1,3 @@
1
- import { Request, Response } from 'express';
2
- import { Config } from '../../types';
3
- export default function plugins(conf: Config): (_req: Request, res: Response) => void;
1
+ import { Request, Response } from 'express';
2
+ import { Config } from '../../types';
3
+ export default function plugins(conf: Config): (_req: Request, res: Response) => void;
@@ -1,17 +1,17 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- function plugins(conf) {
4
- return (_req, res) => {
5
- if (res.conf.discovery) {
6
- const plugins = Object.entries(conf.plugins).map(([pluginName, pluginFn]) => ({
7
- name: pluginName,
8
- description: pluginFn.toString()
9
- }));
10
- res.status(200).json(plugins);
11
- }
12
- else {
13
- res.status(401);
14
- }
15
- };
16
- }
17
- exports.default = plugins;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ function plugins(conf) {
4
+ return (_req, res) => {
5
+ if (res.conf.discovery) {
6
+ const plugins = Object.entries(conf.plugins).map(([pluginName, pluginFn]) => ({
7
+ name: pluginName,
8
+ description: pluginFn.toString()
9
+ }));
10
+ res.status(200).json(plugins);
11
+ }
12
+ else {
13
+ res.status(401);
14
+ }
15
+ };
16
+ }
17
+ exports.default = plugins;
@@ -1,3 +1,3 @@
1
- import { Request, Response } from 'express';
2
- import { Repository } from '../../types';
3
- export default function publish(repository: Repository): (req: Request, res: Response) => Promise<void>;
1
+ import { Request, Response } from 'express';
2
+ import { Repository } from '../../types';
3
+ export default function publish(repository: Repository): (req: Request, res: Response) => Promise<void>;
@@ -1,97 +1,97 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
21
- var __importDefault = (this && this.__importDefault) || function (mod) {
22
- return (mod && mod.__esModule) ? mod : { "default": mod };
23
- };
24
- Object.defineProperty(exports, "__esModule", { value: true });
25
- const extract_package_1 = __importDefault(require("../domain/extract-package"));
26
- const index_1 = __importDefault(require("../../resources/index"));
27
- const validator = __importStar(require("../domain/validators"));
28
- function publish(repository) {
29
- return async function (req, res) {
30
- if (!req.params['componentName'] || !req.params['componentVersion']) {
31
- res.errorDetails = 'malformed request';
32
- res.status(409).json({ error: res.errorDetails });
33
- return;
34
- }
35
- const packageValidation = validator.validatePackage(req.files);
36
- if (!packageValidation.isValid) {
37
- res.errorDetails = 'package is not valid';
38
- res.status(409).json({ error: res.errorDetails });
39
- return;
40
- }
41
- const files = packageValidation.files;
42
- const ocCliValidationResult = validator.validateOcCliVersion(req.headers['user-agent']);
43
- if (!ocCliValidationResult.isValid) {
44
- res.errorDetails = index_1.default.errors.registry.OC_CLI_VERSION_IS_NOT_VALID(ocCliValidationResult.error.registryVersion, ocCliValidationResult.error.cliVersion);
45
- res.status(409).json({
46
- code: 'cli_version_not_valid',
47
- error: res.errorDetails,
48
- details: ocCliValidationResult.error
49
- });
50
- return;
51
- }
52
- const nodeValidationResult = validator.validateNodeVersion(req.headers['user-agent'], process.version);
53
- if (!nodeValidationResult.isValid) {
54
- res.errorDetails = index_1.default.errors.registry.NODE_CLI_VERSION_IS_NOT_VALID(nodeValidationResult.error.registryNodeVersion, nodeValidationResult.error.cliNodeVersion);
55
- res.status(409).json({
56
- code: 'node_version_not_valid',
57
- error: res.errorDetails,
58
- details: nodeValidationResult.error
59
- });
60
- return;
61
- }
62
- try {
63
- const pkgDetails = await (0, extract_package_1.default)(files);
64
- try {
65
- await repository.publishComponent(pkgDetails, req.params['componentName'], req.params['componentVersion']);
66
- res.status(200).json({ ok: true });
67
- }
68
- catch (err) {
69
- if (err.code === 'not_allowed') {
70
- res.errorDetails = `Publish not allowed: ${err.msg}`;
71
- res.status(403).json({ error: err.msg });
72
- }
73
- else if (err.code === 'already_exists') {
74
- res.errorDetails = `Component already exists: ${err.msg}`;
75
- res.status(403).json({ error: err.msg });
76
- }
77
- else if (err.code === 'name_not_valid') {
78
- res.errorDetails = `Component name not valid: ${err.msg}`;
79
- res.status(409).json({ error: err.msg });
80
- }
81
- else if (err.code === 'version_not_valid') {
82
- res.errorDetails = `Component version not valid: ${err.msg}`;
83
- res.status(409).json({ error: err.msg });
84
- }
85
- else {
86
- res.errorDetails = `Publish failed: ${err.msg}`;
87
- res.status(500).json({ error: err.msg });
88
- }
89
- }
90
- }
91
- catch (err) {
92
- res.errorDetails = `Package is not valid: ${err}`;
93
- res.status(500).json({ error: 'package is not valid', details: err });
94
- }
95
- };
96
- }
97
- exports.default = publish;
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ var __importDefault = (this && this.__importDefault) || function (mod) {
22
+ return (mod && mod.__esModule) ? mod : { "default": mod };
23
+ };
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ const extract_package_1 = __importDefault(require("../domain/extract-package"));
26
+ const index_1 = __importDefault(require("../../resources/index"));
27
+ const validator = __importStar(require("../domain/validators"));
28
+ function publish(repository) {
29
+ return async function (req, res) {
30
+ if (!req.params['componentName'] || !req.params['componentVersion']) {
31
+ res.errorDetails = 'malformed request';
32
+ res.status(409).json({ error: res.errorDetails });
33
+ return;
34
+ }
35
+ const packageValidation = validator.validatePackage(req.files);
36
+ if (!packageValidation.isValid) {
37
+ res.errorDetails = 'package is not valid';
38
+ res.status(409).json({ error: res.errorDetails });
39
+ return;
40
+ }
41
+ const files = packageValidation.files;
42
+ const ocCliValidationResult = validator.validateOcCliVersion(req.headers['user-agent']);
43
+ if (!ocCliValidationResult.isValid) {
44
+ res.errorDetails = index_1.default.errors.registry.OC_CLI_VERSION_IS_NOT_VALID(ocCliValidationResult.error.registryVersion, ocCliValidationResult.error.cliVersion);
45
+ res.status(409).json({
46
+ code: 'cli_version_not_valid',
47
+ error: res.errorDetails,
48
+ details: ocCliValidationResult.error
49
+ });
50
+ return;
51
+ }
52
+ const nodeValidationResult = validator.validateNodeVersion(req.headers['user-agent'], process.version);
53
+ if (!nodeValidationResult.isValid) {
54
+ res.errorDetails = index_1.default.errors.registry.NODE_CLI_VERSION_IS_NOT_VALID(nodeValidationResult.error.registryNodeVersion, nodeValidationResult.error.cliNodeVersion);
55
+ res.status(409).json({
56
+ code: 'node_version_not_valid',
57
+ error: res.errorDetails,
58
+ details: nodeValidationResult.error
59
+ });
60
+ return;
61
+ }
62
+ try {
63
+ const pkgDetails = await (0, extract_package_1.default)(files);
64
+ try {
65
+ await repository.publishComponent(pkgDetails, req.params['componentName'], req.params['componentVersion']);
66
+ res.status(200).json({ ok: true });
67
+ }
68
+ catch (err) {
69
+ if (err.code === 'not_allowed') {
70
+ res.errorDetails = `Publish not allowed: ${err.msg}`;
71
+ res.status(403).json({ error: err.msg });
72
+ }
73
+ else if (err.code === 'already_exists') {
74
+ res.errorDetails = `Component already exists: ${err.msg}`;
75
+ res.status(403).json({ error: err.msg });
76
+ }
77
+ else if (err.code === 'name_not_valid') {
78
+ res.errorDetails = `Component name not valid: ${err.msg}`;
79
+ res.status(409).json({ error: err.msg });
80
+ }
81
+ else if (err.code === 'version_not_valid') {
82
+ res.errorDetails = `Component version not valid: ${err.msg}`;
83
+ res.status(409).json({ error: err.msg });
84
+ }
85
+ else {
86
+ res.errorDetails = `Publish failed: ${err.msg}`;
87
+ res.status(500).json({ error: err.msg });
88
+ }
89
+ }
90
+ }
91
+ catch (err) {
92
+ res.errorDetails = `Package is not valid: ${err}`;
93
+ res.status(500).json({ error: 'package is not valid', details: err });
94
+ }
95
+ };
96
+ }
97
+ exports.default = publish;
@@ -1,3 +1,3 @@
1
- import { Request, Response } from 'express';
2
- import { Repository } from '../../types';
3
- export default function staticRedirector(repository: Repository): (req: Request, res: Response) => void;
1
+ import { Request, Response } from 'express';
2
+ import { Repository } from '../../types';
3
+ export default function staticRedirector(repository: Repository): (req: Request, res: Response) => void;