oc 0.49.6 → 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.
- package/CHANGELOG.md +26 -0
- package/README.md +2 -15
- package/dist/cli/commands.d.ts +163 -163
- package/dist/cli/commands.js +162 -162
- package/dist/cli/domain/clean.d.ts +2 -2
- package/dist/cli/domain/clean.js +24 -27
- package/dist/cli/domain/get-components-by-dir.d.ts +1 -1
- package/dist/cli/domain/get-components-by-dir.js +41 -48
- package/dist/cli/domain/get-mocked-plugins.d.ts +10 -10
- package/dist/cli/domain/get-mocked-plugins.js +89 -87
- package/dist/cli/domain/handle-dependencies/ensure-compiler-is-declared-as-devDependency.d.ts +6 -6
- package/dist/cli/domain/handle-dependencies/ensure-compiler-is-declared-as-devDependency.js +16 -17
- package/dist/cli/domain/handle-dependencies/get-compiler.d.ts +10 -10
- package/dist/cli/domain/handle-dependencies/get-compiler.js +28 -28
- package/dist/cli/domain/handle-dependencies/get-missing-dependencies.d.ts +1 -1
- package/dist/cli/domain/handle-dependencies/get-missing-dependencies.js +18 -18
- package/dist/cli/domain/handle-dependencies/index.d.ts +10 -9
- package/dist/cli/domain/handle-dependencies/index.js +70 -64
- package/dist/cli/domain/handle-dependencies/install-compiler.d.ts +8 -8
- package/dist/cli/domain/handle-dependencies/install-compiler.js +54 -47
- package/dist/cli/domain/handle-dependencies/install-missing-dependencies.d.ts +5 -5
- package/dist/cli/domain/handle-dependencies/install-missing-dependencies.js +59 -55
- package/dist/cli/domain/handle-dependencies/link-missing-dependencies.d.ts +6 -6
- package/dist/cli/domain/handle-dependencies/link-missing-dependencies.js +32 -36
- package/dist/cli/domain/handle-dependencies/require-template.d.ts +17 -17
- package/dist/cli/domain/handle-dependencies/require-template.js +34 -34
- package/dist/cli/domain/init-template/index.d.ts +10 -10
- package/dist/cli/domain/init-template/index.js +40 -42
- package/dist/cli/domain/init-template/install-template.d.ts +11 -11
- package/dist/cli/domain/init-template/install-template.js +54 -53
- package/dist/cli/domain/init-template/scaffold.d.ts +11 -11
- package/dist/cli/domain/init-template/scaffold.js +30 -30
- package/dist/cli/domain/local.d.ts +2 -2
- package/dist/cli/domain/local.js +82 -81
- package/dist/cli/domain/mock.d.ts +5 -5
- package/dist/cli/domain/mock.js +33 -33
- package/dist/cli/domain/package-components.d.ts +9 -9
- package/dist/cli/domain/package-components.js +67 -70
- package/dist/cli/domain/registry.d.ts +6 -6
- package/dist/cli/domain/registry.js +136 -149
- package/dist/cli/domain/url-parser.d.ts +14 -14
- package/dist/cli/domain/url-parser.js +31 -31
- package/dist/cli/domain/watch.d.ts +1 -1
- package/dist/cli/domain/watch.js +29 -29
- package/dist/cli/facade/clean.d.ts +16 -10
- package/dist/cli/facade/clean.js +58 -48
- package/dist/cli/facade/dev.d.ts +114 -21
- package/dist/cli/facade/dev.js +176 -190
- package/dist/cli/facade/init.d.ts +18 -11
- package/dist/cli/facade/init.js +39 -37
- package/dist/cli/facade/mock.d.ts +18 -11
- package/dist/cli/facade/mock.js +12 -13
- package/dist/cli/facade/package.d.ts +18 -11
- package/dist/cli/facade/package.js +49 -51
- package/dist/cli/facade/preview.d.ts +14 -9
- package/dist/cli/facade/preview.js +20 -18
- package/dist/cli/facade/publish.d.ts +23 -14
- package/dist/cli/facade/publish.js +145 -165
- package/dist/cli/facade/registry-add.d.ts +14 -9
- package/dist/cli/facade/registry-add.js +18 -17
- package/dist/cli/facade/registry-ls.d.ts +10 -7
- package/dist/cli/facade/registry-ls.js +27 -25
- package/dist/cli/facade/registry-remove.d.ts +14 -9
- package/dist/cli/facade/registry-remove.js +18 -17
- package/dist/cli/facade/registry.d.ts +5 -2
- package/dist/cli/facade/registry.js +9 -6
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +91 -93
- package/dist/cli/logger.d.ts +8 -8
- package/dist/cli/logger.js +19 -19
- package/dist/cli/programmatic-api.d.ts +84 -84
- package/dist/cli/programmatic-api.js +66 -66
- package/dist/cli/validate-command.d.ts +2 -2
- package/dist/cli/validate-command.js +18 -18
- package/dist/components/oc-client/_package/package.json +1 -1
- package/dist/components/oc-client/package.json +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +12 -12
- package/dist/oc-cli.d.ts +2 -2
- package/dist/oc-cli.js +3 -3
- package/dist/registry/app-start.d.ts +2 -2
- package/dist/registry/app-start.js +44 -44
- package/dist/registry/domain/authentication.d.ts +7 -8
- package/dist/registry/domain/authentication.js +53 -50
- package/dist/registry/domain/components-cache/components-list.d.ts +8 -7
- package/dist/registry/domain/components-cache/components-list.js +50 -64
- package/dist/registry/domain/components-cache/index.d.ts +7 -6
- package/dist/registry/domain/components-cache/index.js +76 -79
- package/dist/registry/domain/components-details.d.ts +6 -5
- package/dist/registry/domain/components-details.js +64 -75
- package/dist/registry/domain/events-handler.d.ts +40 -40
- package/dist/registry/domain/events-handler.js +37 -37
- package/dist/registry/domain/extract-package.d.ts +8 -8
- package/dist/registry/domain/extract-package.js +26 -29
- package/dist/registry/domain/get-package-json-from-temp-dir.d.ts +2 -2
- package/dist/registry/domain/get-package-json-from-temp-dir.js +11 -11
- package/dist/registry/domain/nested-renderer.d.ts +14 -13
- package/dist/registry/domain/nested-renderer.js +59 -95
- package/dist/registry/domain/options-sanitiser.d.ts +6 -6
- package/dist/registry/domain/options-sanitiser.js +106 -104
- package/dist/registry/domain/plugins-initialiser.d.ts +3 -1
- package/dist/registry/domain/plugins-initialiser.js +95 -99
- package/dist/registry/domain/register-templates.d.ts +5 -5
- package/dist/registry/domain/register-templates.js +30 -30
- package/dist/registry/domain/repository.d.ts +2 -2
- package/dist/registry/domain/repository.js +237 -259
- package/dist/registry/domain/require-wrapper.d.ts +2 -2
- package/dist/registry/domain/require-wrapper.js +33 -34
- package/dist/registry/domain/sanitiser.d.ts +2 -2
- package/dist/registry/domain/sanitiser.js +52 -52
- package/dist/registry/domain/storage-adapter.d.ts +10 -0
- package/dist/registry/domain/storage-adapter.js +55 -0
- package/dist/registry/domain/url-builder.d.ts +10 -10
- package/dist/registry/domain/url-builder.js +60 -60
- package/dist/registry/domain/validators/component-parameters.d.ts +11 -11
- package/dist/registry/domain/validators/component-parameters.js +79 -79
- package/dist/registry/domain/validators/index.d.ts +16 -16
- package/dist/registry/domain/validators/index.js +29 -29
- package/dist/registry/domain/validators/node-version.d.ts +15 -15
- package/dist/registry/domain/validators/node-version.js +40 -40
- package/dist/registry/domain/validators/oc-cli-version.d.ts +15 -15
- package/dist/registry/domain/validators/oc-cli-version.js +34 -34
- package/dist/registry/domain/validators/package-json-validator.d.ts +13 -13
- package/dist/registry/domain/validators/package-json-validator.js +23 -23
- package/dist/registry/domain/validators/plugins-requirements.d.ts +9 -9
- package/dist/registry/domain/validators/plugins-requirements.js +22 -22
- package/dist/registry/domain/validators/registry-configuration.d.ts +9 -9
- package/dist/registry/domain/validators/registry-configuration.js +113 -113
- package/dist/registry/domain/validators/uploaded-package.d.ts +14 -14
- package/dist/registry/domain/validators/uploaded-package.js +25 -25
- package/dist/registry/domain/version-handler.d.ts +2 -2
- package/dist/registry/domain/version-handler.js +22 -22
- package/dist/registry/index.d.ts +48 -48
- package/dist/registry/index.js +107 -120
- package/dist/registry/middleware/base-url-handler.d.ts +2 -2
- package/dist/registry/middleware/base-url-handler.js +12 -12
- package/dist/registry/middleware/cors.d.ts +2 -2
- package/dist/registry/middleware/cors.js +11 -11
- package/dist/registry/middleware/discovery-handler.d.ts +2 -2
- package/dist/registry/middleware/discovery-handler.js +15 -15
- package/dist/registry/middleware/file-uploads.d.ts +2 -2
- package/dist/registry/middleware/file-uploads.js +23 -23
- package/dist/registry/middleware/index.d.ts +7 -3
- package/dist/registry/middleware/index.js +51 -47
- package/dist/registry/middleware/request-handler.d.ts +2 -2
- package/dist/registry/middleware/request-handler.js +30 -30
- package/dist/registry/router.d.ts +3 -3
- package/dist/registry/router.js +56 -58
- package/dist/registry/routes/component-info.d.ts +3 -3
- package/dist/registry/routes/component-info.js +90 -89
- package/dist/registry/routes/component-preview.d.ts +3 -3
- package/dist/registry/routes/component-preview.js +68 -67
- package/dist/registry/routes/component.d.ts +3 -3
- package/dist/registry/routes/component.js +43 -43
- package/dist/registry/routes/components.d.ts +3 -3
- package/dist/registry/routes/components.js +78 -78
- package/dist/registry/routes/dependencies.d.ts +3 -3
- package/dist/registry/routes/dependencies.js +28 -28
- package/dist/registry/routes/helpers/apply-default-values.d.ts +2 -2
- package/dist/registry/routes/helpers/apply-default-values.js +13 -13
- package/dist/registry/routes/helpers/get-available-dependencies.d.ts +8 -8
- package/dist/registry/routes/helpers/get-available-dependencies.js +24 -24
- package/dist/registry/routes/helpers/get-component-fallback.d.ts +17 -22
- package/dist/registry/routes/helpers/get-component-fallback.js +91 -91
- package/dist/registry/routes/helpers/get-component-retrieving-info.d.ts +20 -20
- package/dist/registry/routes/helpers/get-component-retrieving-info.js +24 -24
- package/dist/registry/routes/helpers/get-component.d.ts +33 -33
- package/dist/registry/routes/helpers/get-component.js +406 -405
- package/dist/registry/routes/helpers/get-components-history.d.ts +8 -8
- package/dist/registry/routes/helpers/get-components-history.js +28 -28
- package/dist/registry/routes/helpers/is-url-discoverable.d.ts +3 -3
- package/dist/registry/routes/helpers/is-url-discoverable.js +22 -16
- package/dist/registry/routes/index.d.ts +3 -3
- package/dist/registry/routes/index.js +93 -92
- package/dist/registry/routes/plugins.d.ts +3 -3
- package/dist/registry/routes/plugins.js +17 -17
- package/dist/registry/routes/publish.d.ts +3 -3
- package/dist/registry/routes/publish.js +97 -96
- package/dist/registry/routes/static-redirector.d.ts +3 -3
- package/dist/registry/routes/static-redirector.js +63 -63
- package/dist/registry/views/index.d.ts +2 -2
- package/dist/registry/views/index.js +39 -39
- package/dist/registry/views/info.d.ts +16 -16
- package/dist/registry/views/info.js +44 -41
- package/dist/registry/views/partials/component-author.d.ts +8 -8
- package/dist/registry/views/partials/component-author.js +20 -20
- package/dist/registry/views/partials/component-parameters.d.ts +5 -5
- package/dist/registry/views/partials/component-parameters.js +24 -24
- package/dist/registry/views/partials/component-state.d.ts +5 -5
- package/dist/registry/views/partials/component-state.js +6 -6
- package/dist/registry/views/partials/component-versions.d.ts +5 -5
- package/dist/registry/views/partials/component-versions.js +9 -9
- package/dist/registry/views/partials/components-dependencies.d.ts +2 -2
- package/dist/registry/views/partials/components-dependencies.js +12 -12
- package/dist/registry/views/partials/components-history.d.ts +2 -2
- package/dist/registry/views/partials/components-history.js +10 -10
- package/dist/registry/views/partials/components-list.d.ts +2 -2
- package/dist/registry/views/partials/components-list.js +26 -26
- package/dist/registry/views/partials/components-plugins.d.ts +2 -2
- package/dist/registry/views/partials/components-plugins.js +8 -8
- package/dist/registry/views/partials/components-templates.d.ts +2 -2
- package/dist/registry/views/partials/components-templates.js +14 -14
- package/dist/registry/views/partials/layout.d.ts +8 -8
- package/dist/registry/views/partials/layout.js +11 -11
- package/dist/registry/views/partials/property.d.ts +2 -2
- package/dist/registry/views/partials/property.js +11 -11
- package/dist/registry/views/partials/selected-checkbox.d.ts +4 -4
- package/dist/registry/views/partials/selected-checkbox.js +7 -7
- package/dist/registry/views/preview.d.ts +8 -8
- package/dist/registry/views/preview.js +9 -9
- package/dist/registry/views/static/index.d.ts +2 -2
- package/dist/registry/views/static/index.js +3 -3
- package/dist/registry/views/static/info.d.ts +2 -2
- package/dist/registry/views/static/info.js +15 -4
- package/dist/registry/views/static/style.d.ts +2 -2
- package/dist/registry/views/static/style.js +3 -3
- package/dist/resources/index.d.ts +134 -134
- package/dist/resources/index.js +145 -145
- package/dist/resources/settings.d.ts +17 -17
- package/dist/resources/settings.js +18 -18
- package/dist/types.d.ts +287 -285
- package/dist/types.js +2 -2
- package/dist/utils/clean-require.d.ts +16 -16
- package/dist/utils/clean-require.js +18 -18
- package/dist/utils/date-stringify.d.ts +1 -1
- package/dist/utils/date-stringify.js +22 -22
- package/dist/utils/error-to-string.d.ts +1 -1
- package/dist/utils/error-to-string.js +15 -15
- package/dist/utils/is-template-legacy.d.ts +3 -3
- package/dist/utils/is-template-legacy.js +6 -6
- package/dist/utils/is-template-valid.d.ts +4 -4
- package/dist/utils/is-template-valid.js +12 -12
- package/dist/utils/module-exists.d.ts +1 -1
- package/dist/utils/module-exists.js +15 -15
- package/dist/utils/npm-utils.d.ts +20 -22
- package/dist/utils/npm-utils.js +74 -63
- package/dist/utils/put.d.ts +2 -1
- package/dist/utils/put.js +29 -48
- package/dist/utils/strip-version.d.ts +1 -1
- package/dist/utils/strip-version.js +11 -11
- package/logintervals.md +1 -1
- package/package.json +6 -1
- package/src/cli/domain/clean.ts +10 -20
- package/src/cli/domain/get-components-by-dir.ts +12 -26
- package/src/cli/domain/get-mocked-plugins.ts +32 -26
- package/src/cli/domain/handle-dependencies/ensure-compiler-is-declared-as-devDependency.ts +8 -12
- package/src/cli/domain/handle-dependencies/get-compiler.ts +8 -11
- package/src/cli/domain/handle-dependencies/index.ts +55 -109
- package/src/cli/domain/handle-dependencies/install-compiler.ts +22 -15
- package/src/cli/domain/handle-dependencies/install-missing-dependencies.ts +19 -13
- package/src/cli/domain/handle-dependencies/link-missing-dependencies.ts +8 -16
- package/src/cli/domain/init-template/index.ts +13 -20
- package/src/cli/domain/init-template/install-template.ts +11 -12
- package/src/cli/domain/init-template/scaffold.ts +9 -12
- package/src/cli/domain/local.ts +19 -22
- package/src/cli/domain/mock.ts +32 -36
- package/src/cli/domain/package-components.ts +14 -25
- package/src/cli/domain/registry.ts +80 -116
- package/src/cli/domain/watch.ts +1 -1
- package/src/cli/facade/clean.ts +37 -37
- package/src/cli/facade/dev.ts +159 -182
- package/src/cli/facade/init.ts +36 -38
- package/src/cli/facade/mock.ts +11 -10
- package/src/cli/facade/package.ts +44 -49
- package/src/cli/facade/preview.ts +20 -18
- package/src/cli/facade/publish.ts +134 -172
- package/src/cli/facade/registry-add.ts +16 -15
- package/src/cli/facade/registry-ls.ts +27 -22
- package/src/cli/facade/registry-remove.ts +16 -15
- package/src/cli/facade/registry.ts +7 -5
- package/src/cli/index.ts +3 -5
- package/src/components/oc-client/_package/package.json +1 -1
- package/src/components/oc-client/package.json +1 -1
- package/src/globals.d.ts +38 -0
- package/src/oc-cli.js +0 -0
- package/src/registry/app-start.ts +27 -31
- package/src/registry/domain/authentication.ts +5 -13
- package/src/registry/domain/components-cache/components-list.ts +45 -67
- package/src/registry/domain/components-cache/index.ts +55 -60
- package/src/registry/domain/components-details.ts +49 -75
- package/src/registry/domain/extract-package.ts +19 -27
- package/src/registry/domain/get-package-json-from-temp-dir.ts +3 -4
- package/src/registry/domain/nested-renderer.ts +64 -122
- package/src/registry/domain/options-sanitiser.ts +6 -3
- package/src/registry/domain/plugins-initialiser.ts +45 -49
- package/src/registry/domain/repository.ts +129 -235
- package/src/registry/domain/require-wrapper.ts +1 -2
- package/src/registry/domain/storage-adapter.ts +85 -0
- package/src/registry/index.ts +48 -79
- package/src/registry/middleware/index.ts +10 -2
- package/src/registry/router.ts +2 -10
- package/src/registry/routes/component-info.ts +4 -3
- package/src/registry/routes/component-preview.ts +3 -2
- package/src/registry/routes/components.ts +1 -1
- package/src/registry/routes/helpers/get-component-fallback.ts +3 -9
- package/src/registry/routes/helpers/get-component.ts +11 -9
- package/src/registry/routes/helpers/is-url-discoverable.ts +14 -15
- package/src/registry/routes/index.ts +18 -13
- package/src/registry/routes/publish.ts +31 -34
- package/src/registry/views/info.ts +5 -2
- package/src/registry/views/static/info.ts +12 -1
- package/src/resources/settings.ts +1 -1
- package/src/types.ts +80 -141
- package/src/utils/npm-utils.ts +38 -37
- package/src/utils/put.ts +15 -37
|
@@ -1,145 +1,87 @@
|
|
|
1
|
-
import async from 'async';
|
|
2
|
-
import _ from 'lodash';
|
|
3
|
-
|
|
4
1
|
import settings from '../../resources/settings';
|
|
5
2
|
import strings from '../../resources';
|
|
6
3
|
import { Config } from '../../types';
|
|
4
|
+
import {
|
|
5
|
+
GetComponentResult,
|
|
6
|
+
RendererOptions
|
|
7
|
+
} from '../routes/helpers/get-component';
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
interface Options {
|
|
10
|
+
ip?: string;
|
|
10
11
|
version?: string;
|
|
11
12
|
name?: string;
|
|
12
13
|
headers?: Record<string, string>;
|
|
13
14
|
parameters?: Record<string, string>;
|
|
14
|
-
}
|
|
15
|
-
type Params = {
|
|
16
|
-
components: Options[];
|
|
17
|
-
options: Options;
|
|
18
|
-
callback: Cb;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
const sanitise = {
|
|
22
|
-
componentParams(component: string, options: Options | Cb, callback?: Cb) {
|
|
23
|
-
return {
|
|
24
|
-
...sanitise.options(options, callback),
|
|
25
|
-
componentName: component
|
|
26
|
-
};
|
|
27
|
-
},
|
|
28
|
-
componentsParams(
|
|
29
|
-
components: Options[],
|
|
30
|
-
options: Options | Cb,
|
|
31
|
-
callback: Cb
|
|
32
|
-
): Params {
|
|
33
|
-
return {
|
|
34
|
-
...sanitise.options(options, callback),
|
|
35
|
-
components: components
|
|
36
|
-
};
|
|
37
|
-
},
|
|
38
|
-
headers(h = {}) {
|
|
39
|
-
return {
|
|
40
|
-
...h,
|
|
41
|
-
accept: settings.registry.acceptRenderedHeader
|
|
42
|
-
};
|
|
43
|
-
},
|
|
44
|
-
options(
|
|
45
|
-
options: Options | Cb,
|
|
46
|
-
callback?: Cb
|
|
47
|
-
): { options: Options; callback: Cb } {
|
|
48
|
-
const cb = !callback && typeof options === 'function' ? options : callback;
|
|
49
|
-
const opts = typeof options === 'function' ? {} : options;
|
|
50
|
-
|
|
51
|
-
return { callback: cb!, options: opts };
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
const validate = {
|
|
56
|
-
callback(c: Cb) {
|
|
57
|
-
if (!c || typeof c !== 'function') {
|
|
58
|
-
throw new Error(
|
|
59
|
-
strings.errors.registry.NESTED_RENDERER_CALLBACK_IS_NOT_VALID
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
componentParams(params: { componentName: string; callback: Cb }) {
|
|
64
|
-
if (!params.componentName) {
|
|
65
|
-
throw new Error(
|
|
66
|
-
strings.errors.registry.NESTED_RENDERER_COMPONENT_NAME_IS_NOT_VALID
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
validate.callback(params.callback);
|
|
71
|
-
},
|
|
72
|
-
componentsParams(params: Params) {
|
|
73
|
-
if (_.isEmpty(params.components)) {
|
|
74
|
-
throw new Error(
|
|
75
|
-
strings.errors.registry.NESTED_RENDERER_COMPONENTS_IS_NOT_VALID
|
|
76
|
-
);
|
|
77
|
-
}
|
|
15
|
+
}
|
|
78
16
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
17
|
+
export default function nestedRenderer(
|
|
18
|
+
rendererWithCallback: (
|
|
19
|
+
options: RendererOptions,
|
|
20
|
+
cb: (result: GetComponentResult) => void
|
|
21
|
+
) => void,
|
|
22
|
+
conf: Config
|
|
23
|
+
) {
|
|
24
|
+
const renderer = (options: RendererOptions) =>
|
|
25
|
+
new Promise<string>((res, rej) => {
|
|
26
|
+
rendererWithCallback(options, result => {
|
|
27
|
+
if (result.response.error) {
|
|
28
|
+
rej(result.response.error);
|
|
29
|
+
} else {
|
|
30
|
+
res(result.response.html!);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
});
|
|
82
34
|
|
|
83
|
-
export default function nestedRenderer(renderer: any, conf: Config) {
|
|
84
35
|
return {
|
|
85
36
|
renderComponent(
|
|
86
37
|
componentName: string,
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
);
|
|
95
|
-
validate.componentParams(p);
|
|
38
|
+
options: Options = {}
|
|
39
|
+
): Promise<string> {
|
|
40
|
+
if (!componentName) {
|
|
41
|
+
throw new Error(
|
|
42
|
+
strings.errors.registry.NESTED_RENDERER_COMPONENT_NAME_IS_NOT_VALID
|
|
43
|
+
);
|
|
44
|
+
}
|
|
96
45
|
|
|
97
|
-
return renderer(
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
version: p.options.version || ''
|
|
46
|
+
return renderer({
|
|
47
|
+
conf: conf,
|
|
48
|
+
ip: options.ip || '',
|
|
49
|
+
headers: {
|
|
50
|
+
...options.headers,
|
|
51
|
+
accept: settings.registry.acceptRenderedHeader
|
|
104
52
|
},
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
return p.callback(null, result.response.html);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
);
|
|
53
|
+
name: componentName,
|
|
54
|
+
parameters: options.parameters || {},
|
|
55
|
+
version: options.version || ''
|
|
56
|
+
});
|
|
113
57
|
},
|
|
114
58
|
renderComponents(
|
|
115
59
|
components: Options[],
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
60
|
+
options: Options = {}
|
|
61
|
+
): Promise<Array<string | Error>> {
|
|
62
|
+
if (!components || !components.length) {
|
|
63
|
+
throw new Error(
|
|
64
|
+
strings.errors.registry.NESTED_RENDERER_COMPONENTS_IS_NOT_VALID
|
|
65
|
+
);
|
|
66
|
+
}
|
|
121
67
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
{
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
name: component.name,
|
|
130
|
-
parameters: {
|
|
131
|
-
...p.options.parameters,
|
|
132
|
-
...component.parameters
|
|
133
|
-
},
|
|
134
|
-
version: component.version || ''
|
|
68
|
+
return Promise.all(
|
|
69
|
+
components.map(component => {
|
|
70
|
+
return renderer({
|
|
71
|
+
conf: conf,
|
|
72
|
+
headers: {
|
|
73
|
+
...options.headers,
|
|
74
|
+
accept: settings.registry.acceptRenderedHeader
|
|
135
75
|
},
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
76
|
+
ip: component.ip || '',
|
|
77
|
+
name: component.name!,
|
|
78
|
+
parameters: {
|
|
79
|
+
...options.parameters,
|
|
80
|
+
...component.parameters
|
|
81
|
+
},
|
|
82
|
+
version: component.version || ''
|
|
83
|
+
}).catch(err => new Error(err));
|
|
84
|
+
})
|
|
143
85
|
);
|
|
144
86
|
}
|
|
145
87
|
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _ from 'lodash';
|
|
2
1
|
import settings from '../../resources/settings';
|
|
3
2
|
import { Config } from '../../types';
|
|
4
3
|
import * as auth from './authentication';
|
|
@@ -10,7 +9,7 @@ interface Input extends Partial<Omit<Config, 'beforePublish'>> {
|
|
|
10
9
|
}
|
|
11
10
|
|
|
12
11
|
export default function optionsSanitiser(input: Input): Config {
|
|
13
|
-
const options =
|
|
12
|
+
const options = { ...input };
|
|
14
13
|
|
|
15
14
|
if (!options.publishAuth) {
|
|
16
15
|
(options as Config).beforePublish = (_req, _res, next) => next();
|
|
@@ -57,9 +56,13 @@ export default function optionsSanitiser(input: Input): Config {
|
|
|
57
56
|
options.templates = [];
|
|
58
57
|
}
|
|
59
58
|
|
|
59
|
+
if (!options.dependencies) {
|
|
60
|
+
options.dependencies = [];
|
|
61
|
+
}
|
|
62
|
+
|
|
60
63
|
if (
|
|
61
64
|
typeof options.fallbackRegistryUrl !== 'undefined' &&
|
|
62
|
-
|
|
65
|
+
!options.fallbackRegistryUrl.endsWith('/')
|
|
63
66
|
) {
|
|
64
67
|
options.fallbackRegistryUrl += '/';
|
|
65
68
|
}
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import
|
|
1
|
+
import pLimit from 'p-limit';
|
|
2
2
|
import _ from 'lodash';
|
|
3
3
|
import { DepGraph } from 'dependency-graph';
|
|
4
|
+
import { promisify } from 'util';
|
|
4
5
|
|
|
5
6
|
import strings from '../../resources';
|
|
6
7
|
import { Plugin } from '../../types';
|
|
7
8
|
|
|
8
9
|
function validatePlugins(plugins: unknown[]): asserts plugins is Plugin[] {
|
|
9
|
-
let
|
|
10
|
-
|
|
11
|
-
plugins.forEach(plugin => {
|
|
12
|
-
c++;
|
|
10
|
+
for (let idx = 0; idx < plugins.length; idx++) {
|
|
11
|
+
const plugin = plugins[idx];
|
|
13
12
|
if (
|
|
14
13
|
!_.isObject((plugin as Plugin).register) ||
|
|
15
14
|
typeof (plugin as Plugin).register.register !== 'function' ||
|
|
@@ -18,11 +17,11 @@ function validatePlugins(plugins: unknown[]): asserts plugins is Plugin[] {
|
|
|
18
17
|
) {
|
|
19
18
|
throw new Error(
|
|
20
19
|
strings.errors.registry.PLUGIN_NOT_VALID(
|
|
21
|
-
(plugin as Plugin).name || String(
|
|
20
|
+
(plugin as Plugin).name || String(idx + 1)
|
|
22
21
|
)
|
|
23
22
|
);
|
|
24
23
|
}
|
|
25
|
-
}
|
|
24
|
+
}
|
|
26
25
|
}
|
|
27
26
|
|
|
28
27
|
function checkDependencies(plugins: Plugin[]) {
|
|
@@ -48,26 +47,16 @@ function checkDependencies(plugins: Plugin[]) {
|
|
|
48
47
|
}
|
|
49
48
|
|
|
50
49
|
let deferredLoads: Plugin[] = [];
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
) => void
|
|
62
|
-
): void {
|
|
63
|
-
const registered: Record<string, (...args: unknown[]) => void> = {};
|
|
64
|
-
|
|
65
|
-
try {
|
|
66
|
-
validatePlugins(pluginsToRegister);
|
|
67
|
-
checkDependencies(pluginsToRegister);
|
|
68
|
-
} catch (err) {
|
|
69
|
-
return callback(err, undefined as any);
|
|
70
|
-
}
|
|
50
|
+
|
|
51
|
+
type PluginFunctions = Record<string, (...args: unknown[]) => void>;
|
|
52
|
+
|
|
53
|
+
export async function init(
|
|
54
|
+
pluginsToRegister: unknown[]
|
|
55
|
+
): Promise<PluginFunctions> {
|
|
56
|
+
const registered: PluginFunctions = {};
|
|
57
|
+
|
|
58
|
+
validatePlugins(pluginsToRegister);
|
|
59
|
+
checkDependencies(pluginsToRegister);
|
|
71
60
|
|
|
72
61
|
const dependenciesRegistered = (dependencies: string[]) => {
|
|
73
62
|
if (dependencies.length === 0) {
|
|
@@ -84,11 +73,9 @@ export function init(
|
|
|
84
73
|
return present;
|
|
85
74
|
};
|
|
86
75
|
|
|
87
|
-
const loadPlugin = (plugin: Plugin
|
|
88
|
-
const done = _.once(cb);
|
|
89
|
-
|
|
76
|
+
const loadPlugin = async (plugin: Plugin): Promise<void> => {
|
|
90
77
|
if (registered[plugin.name]) {
|
|
91
|
-
return
|
|
78
|
+
return;
|
|
92
79
|
}
|
|
93
80
|
|
|
94
81
|
if (!plugin.register.dependencies) {
|
|
@@ -96,36 +83,45 @@ export function init(
|
|
|
96
83
|
}
|
|
97
84
|
|
|
98
85
|
if (!dependenciesRegistered(plugin.register.dependencies)) {
|
|
99
|
-
|
|
86
|
+
deferredLoads.push(plugin);
|
|
87
|
+
return;
|
|
100
88
|
}
|
|
101
89
|
|
|
102
90
|
const dependencies = _.pick(registered, plugin.register.dependencies);
|
|
103
91
|
|
|
104
|
-
plugin.register.register
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
);
|
|
92
|
+
const register = promisify(plugin.register.register);
|
|
93
|
+
|
|
94
|
+
const pluginCallback = plugin.callback || _.noop;
|
|
95
|
+
await register(plugin.options || {}, dependencies).catch(err => {
|
|
96
|
+
pluginCallback(err);
|
|
97
|
+
throw err;
|
|
98
|
+
});
|
|
99
|
+
// Overriding toString so implementation details of plugins do not
|
|
100
|
+
// leak to OC consumers
|
|
101
|
+
plugin.register.execute.toString = () => plugin.description || '';
|
|
102
|
+
registered[plugin.name] = plugin.register.execute;
|
|
103
|
+
pluginCallback();
|
|
117
104
|
};
|
|
118
105
|
|
|
119
|
-
const terminator =
|
|
106
|
+
const terminator = async (): Promise<PluginFunctions> => {
|
|
120
107
|
if (deferredLoads.length > 0) {
|
|
121
108
|
const deferredPlugins = _.clone(deferredLoads);
|
|
122
109
|
deferredLoads = [];
|
|
123
110
|
|
|
124
|
-
|
|
111
|
+
await Promise.all(
|
|
112
|
+
deferredPlugins.map(plugin => onSeries(() => loadPlugin(plugin)))
|
|
113
|
+
);
|
|
114
|
+
return terminator();
|
|
125
115
|
}
|
|
126
116
|
|
|
127
|
-
|
|
117
|
+
return registered;
|
|
128
118
|
};
|
|
129
119
|
|
|
130
|
-
|
|
120
|
+
const onSeries = pLimit(1);
|
|
121
|
+
|
|
122
|
+
await Promise.all(
|
|
123
|
+
pluginsToRegister.map(plugin => onSeries(() => loadPlugin(plugin)))
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
return terminator();
|
|
131
127
|
}
|