oc 0.49.13 → 0.49.15
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/.github/workflows/node.js.yml +1 -1
- package/.husky/pre-commit +1 -1
- package/.nvmrc +1 -1
- package/CHANGELOG.md +11 -1
- 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 -24
- package/dist/cli/domain/get-components-by-dir.d.ts +1 -1
- package/dist/cli/domain/get-components-by-dir.js +41 -41
- package/dist/cli/domain/get-mocked-plugins.d.ts +10 -10
- package/dist/cli/domain/get-mocked-plugins.js +89 -89
- 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 -16
- 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 -10
- package/dist/cli/domain/handle-dependencies/index.js +70 -70
- package/dist/cli/domain/handle-dependencies/install-compiler.d.ts +8 -8
- package/dist/cli/domain/handle-dependencies/install-compiler.js +58 -54
- package/dist/cli/domain/handle-dependencies/install-missing-dependencies.d.ts +5 -5
- package/dist/cli/domain/handle-dependencies/install-missing-dependencies.js +63 -59
- package/dist/cli/domain/handle-dependencies/link-missing-dependencies.d.ts +6 -6
- package/dist/cli/domain/handle-dependencies/link-missing-dependencies.js +32 -32
- 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 +44 -40
- package/dist/cli/domain/init-template/install-template.d.ts +11 -11
- package/dist/cli/domain/init-template/install-template.js +58 -54
- 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 +21 -2
- package/dist/cli/domain/local.js +86 -82
- 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 +71 -67
- package/dist/cli/domain/registry.d.ts +20 -6
- package/dist/cli/domain/registry.js +143 -139
- 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 -16
- package/dist/cli/facade/clean.js +58 -58
- package/dist/cli/facade/dev.d.ts +114 -114
- package/dist/cli/facade/dev.js +180 -176
- package/dist/cli/facade/init.d.ts +18 -18
- package/dist/cli/facade/init.js +39 -39
- package/dist/cli/facade/mock.d.ts +18 -18
- package/dist/cli/facade/mock.js +12 -12
- package/dist/cli/facade/package.d.ts +19 -18
- package/dist/cli/facade/package.js +49 -49
- package/dist/cli/facade/preview.d.ts +14 -14
- package/dist/cli/facade/preview.js +20 -20
- package/dist/cli/facade/publish.d.ts +24 -23
- package/dist/cli/facade/publish.js +145 -145
- package/dist/cli/facade/registry-add.d.ts +14 -14
- package/dist/cli/facade/registry-add.js +18 -18
- package/dist/cli/facade/registry-ls.d.ts +10 -10
- package/dist/cli/facade/registry-ls.js +27 -27
- package/dist/cli/facade/registry-remove.d.ts +14 -14
- package/dist/cli/facade/registry-remove.js +18 -18
- package/dist/cli/facade/registry.d.ts +5 -5
- package/dist/cli/facade/registry.js +9 -9
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +91 -91
- 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/src/oc-client.min.js +2 -2
- package/dist/components/oc-client/_package/src/oc-client.min.map +1 -1
- package/dist/components/oc-client/package.json +1 -1
- package/dist/components/oc-client/src/oc-client.min.js +2 -2
- package/dist/components/oc-client/src/oc-client.min.map +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 +3 -2
- package/dist/registry/app-start.js +44 -44
- package/dist/registry/domain/authentication.d.ts +7 -7
- package/dist/registry/domain/authentication.js +53 -53
- package/dist/registry/domain/components-cache/components-list.d.ts +8 -8
- package/dist/registry/domain/components-cache/components-list.js +50 -50
- package/dist/registry/domain/components-cache/index.d.ts +7 -7
- package/dist/registry/domain/components-cache/index.js +76 -76
- package/dist/registry/domain/components-details.d.ts +6 -6
- package/dist/registry/domain/components-details.js +64 -64
- 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 +30 -26
- 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 -14
- package/dist/registry/domain/nested-renderer.js +59 -59
- package/dist/registry/domain/options-sanitiser.d.ts +6 -6
- package/dist/registry/domain/options-sanitiser.js +113 -106
- package/dist/registry/domain/plugins-initialiser.d.ts +3 -3
- package/dist/registry/domain/plugins-initialiser.js +95 -95
- package/dist/registry/domain/register-templates.d.ts +5 -5
- package/dist/registry/domain/register-templates.js +37 -30
- package/dist/registry/domain/repository.d.ts +22 -2
- package/dist/registry/domain/repository.js +241 -237
- package/dist/registry/domain/require-wrapper.d.ts +2 -2
- package/dist/registry/domain/require-wrapper.js +33 -33
- 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 -10
- package/dist/registry/domain/storage-adapter.js +55 -55
- 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 +117 -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 +110 -107
- 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 +3 -3
- package/dist/registry/middleware/index.js +48 -48
- 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 +4 -3
- package/dist/registry/router.js +56 -56
- package/dist/registry/routes/component-info.d.ts +4 -3
- package/dist/registry/routes/component-info.js +94 -90
- package/dist/registry/routes/component-preview.d.ts +4 -3
- package/dist/registry/routes/component-preview.js +72 -68
- package/dist/registry/routes/component.d.ts +4 -3
- package/dist/registry/routes/component.js +43 -43
- package/dist/registry/routes/components.d.ts +4 -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 -17
- package/dist/registry/routes/helpers/get-component-fallback.js +95 -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 +34 -33
- package/dist/registry/routes/helpers/get-component.js +410 -406
- 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 -22
- package/dist/registry/routes/index.d.ts +3 -3
- package/dist/registry/routes/index.js +93 -93
- 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 +101 -97
- package/dist/registry/routes/static-redirector.d.ts +3 -3
- package/dist/registry/routes/static-redirector.js +86 -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 +39 -39
- 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 +3 -3
- 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 +229 -287
- 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 -20
- package/dist/utils/npm-utils.js +74 -74
- package/dist/utils/put.d.ts +2 -2
- package/dist/utils/put.js +29 -29
- 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 +34 -40
- package/src/cli/domain/local.ts +12 -5
- package/src/cli/domain/package-components.ts +1 -1
- package/src/cli/domain/registry.ts +10 -8
- package/src/cli/facade/clean.ts +1 -1
- package/src/cli/facade/dev.ts +1 -1
- package/src/cli/facade/init.ts +1 -1
- package/src/cli/facade/mock.ts +1 -1
- package/src/cli/facade/package.ts +2 -1
- package/src/cli/facade/preview.ts +1 -1
- package/src/cli/facade/publish.ts +3 -1
- package/src/cli/facade/registry-add.ts +1 -1
- package/src/cli/facade/registry-ls.ts +1 -1
- package/src/cli/facade/registry-remove.ts +1 -1
- package/src/cli/programmatic-api.ts +2 -3
- package/src/components/oc-client/_package/package.json +1 -1
- package/src/components/oc-client/_package/src/oc-client.min.js +2 -2
- package/src/components/oc-client/_package/src/oc-client.min.map +1 -1
- package/src/components/oc-client/package.json +1 -1
- package/src/components/oc-client/src/oc-client.min.js +2 -2
- package/src/components/oc-client/src/oc-client.min.map +1 -1
- package/src/oc-cli.js +0 -0
- package/src/registry/app-start.ts +2 -1
- package/src/registry/domain/components-cache/components-list.ts +2 -2
- package/src/registry/domain/extract-package.ts +7 -2
- package/src/registry/domain/options-sanitiser.ts +4 -0
- package/src/registry/domain/register-templates.ts +12 -2
- package/src/registry/domain/repository.ts +42 -17
- package/src/registry/domain/storage-adapter.ts +7 -7
- package/src/registry/index.ts +4 -1
- package/src/registry/router.ts +2 -1
- package/src/registry/routes/component-info.ts +2 -1
- package/src/registry/routes/component-preview.ts +2 -1
- package/src/registry/routes/component.ts +2 -1
- package/src/registry/routes/components.ts +2 -1
- package/src/registry/routes/helpers/get-component.ts +2 -1
- package/src/registry/routes/index.ts +2 -1
- package/src/registry/routes/publish.ts +3 -3
- package/src/registry/routes/static-redirector.ts +3 -3
- package/src/types.ts +2 -86
|
@@ -1,30 +1,37 @@
|
|
|
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 oc_template_es6_1 = __importDefault(require("oc-template-es6"));
|
|
7
|
-
const oc_template_handlebars_1 = __importDefault(require("oc-template-handlebars"));
|
|
8
|
-
const oc_template_jade_1 = __importDefault(require("oc-template-jade"));
|
|
9
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
10
|
-
function registerTemplates(extraTemplates) {
|
|
11
|
-
const coreTemplates = [
|
|
12
|
-
oc_template_es6_1.default,
|
|
13
|
-
oc_template_jade_1.default,
|
|
14
|
-
oc_template_handlebars_1.default
|
|
15
|
-
];
|
|
16
|
-
const templates = lodash_1.default.union(coreTemplates, extraTemplates);
|
|
17
|
-
const templatesHash = templates.reduce((hash, template) => {
|
|
18
|
-
const type = template.getInfo().type;
|
|
19
|
-
hash[type] = template;
|
|
20
|
-
return hash;
|
|
21
|
-
}, {});
|
|
22
|
-
const templatesInfo = templates.map(template => {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
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 oc_template_es6_1 = __importDefault(require("oc-template-es6"));
|
|
7
|
+
const oc_template_handlebars_1 = __importDefault(require("oc-template-handlebars"));
|
|
8
|
+
const oc_template_jade_1 = __importDefault(require("oc-template-jade"));
|
|
9
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
10
|
+
function registerTemplates(extraTemplates, dev = false) {
|
|
11
|
+
const coreTemplates = [
|
|
12
|
+
oc_template_es6_1.default,
|
|
13
|
+
oc_template_jade_1.default,
|
|
14
|
+
oc_template_handlebars_1.default
|
|
15
|
+
];
|
|
16
|
+
const templates = lodash_1.default.union(coreTemplates, extraTemplates);
|
|
17
|
+
const templatesHash = templates.reduce((hash, template) => {
|
|
18
|
+
const type = template.getInfo().type;
|
|
19
|
+
hash[type] = template;
|
|
20
|
+
return hash;
|
|
21
|
+
}, {});
|
|
22
|
+
const templatesInfo = templates.map(template => {
|
|
23
|
+
const { externals, ...rest } = template.getInfo();
|
|
24
|
+
return {
|
|
25
|
+
...rest,
|
|
26
|
+
externals: externals.map(({ url, devUrl, ...rest }) => ({
|
|
27
|
+
...rest,
|
|
28
|
+
url: dev && devUrl ? devUrl : url
|
|
29
|
+
}))
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
return {
|
|
33
|
+
templatesHash,
|
|
34
|
+
templatesInfo
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
exports.default = registerTemplates;
|
|
@@ -1,2 +1,22 @@
|
|
|
1
|
-
import { Config,
|
|
2
|
-
export default function repository(conf: Config):
|
|
1
|
+
import { Component, ComponentsDetails, Config, TemplateInfo } from '../../types';
|
|
2
|
+
export default function repository(conf: Config): {
|
|
3
|
+
getCompiledView(componentName: string, componentVersion: string): Promise<string>;
|
|
4
|
+
getComponent(componentName: string, componentVersion?: string): Promise<Component>;
|
|
5
|
+
getComponentInfo(componentName: string, componentVersion: string): Promise<Component>;
|
|
6
|
+
getComponentPath(componentName: string, componentVersion: string): string;
|
|
7
|
+
getComponents(): Promise<string[]>;
|
|
8
|
+
getComponentsDetails(): Promise<ComponentsDetails>;
|
|
9
|
+
getComponentVersions(componentName: string): Promise<string[]>;
|
|
10
|
+
getDataProvider(componentName: string, componentVersion: string): Promise<{
|
|
11
|
+
content: string;
|
|
12
|
+
filePath: string;
|
|
13
|
+
}>;
|
|
14
|
+
getStaticClientPath: () => string;
|
|
15
|
+
getStaticClientMapPath: () => string;
|
|
16
|
+
getStaticFilePath: (componentName: string, componentVersion: string, filePath: string) => string;
|
|
17
|
+
getTemplatesInfo: () => TemplateInfo[];
|
|
18
|
+
getTemplate: (type: string) => import("../../types").Template;
|
|
19
|
+
init(): Promise<ComponentsDetails>;
|
|
20
|
+
publishComponent(pkgDetails: any, componentName: string, componentVersion: string): Promise<ComponentsDetails>;
|
|
21
|
+
};
|
|
22
|
+
export declare type Repository = ReturnType<typeof repository>;
|
|
@@ -1,237 +1,241 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
return
|
|
20
|
-
};
|
|
21
|
-
var
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
const
|
|
115
|
-
if (
|
|
116
|
-
throw resources_1.default.errors.registry.
|
|
117
|
-
}
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
.
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
return Promise.
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
30
|
+
const oc_get_unix_utc_timestamp_1 = __importDefault(require("oc-get-unix-utc-timestamp"));
|
|
31
|
+
const path_1 = __importDefault(require("path"));
|
|
32
|
+
const components_cache_1 = __importDefault(require("./components-cache"));
|
|
33
|
+
const components_details_1 = __importDefault(require("./components-details"));
|
|
34
|
+
const register_templates_1 = __importDefault(require("./register-templates"));
|
|
35
|
+
const settings_1 = __importDefault(require("../../resources/settings"));
|
|
36
|
+
const resources_1 = __importDefault(require("../../resources"));
|
|
37
|
+
const validator = __importStar(require("./validators"));
|
|
38
|
+
const storage_adapter_1 = __importDefault(require("./storage-adapter"));
|
|
39
|
+
const versionHandler = __importStar(require("./version-handler"));
|
|
40
|
+
const error_to_string_1 = __importDefault(require("../../utils/error-to-string"));
|
|
41
|
+
const packageInfo = fs_extra_1.default.readJsonSync(path_1.default.join(__dirname, '..', '..', '..', 'package.json'));
|
|
42
|
+
function repository(conf) {
|
|
43
|
+
const cdn = !conf.local &&
|
|
44
|
+
(0, storage_adapter_1.default)(conf.storage.adapter(conf.storage.options));
|
|
45
|
+
const options = !conf.local ? conf.storage.options : null;
|
|
46
|
+
const repositorySource = conf.local
|
|
47
|
+
? 'local repository'
|
|
48
|
+
: cdn.adapterType + ' cdn';
|
|
49
|
+
const componentsCache = (0, components_cache_1.default)(conf, cdn);
|
|
50
|
+
const componentsDetails = (0, components_details_1.default)(conf, cdn);
|
|
51
|
+
const getFilePath = (component, version, filePath) => `${options.componentsDir}/${component}/${version}/${filePath}`;
|
|
52
|
+
const { templatesHash, templatesInfo } = (0, register_templates_1.default)(conf.templates, conf.local);
|
|
53
|
+
const local = {
|
|
54
|
+
getCompiledView(componentName) {
|
|
55
|
+
if (componentName === 'oc-client') {
|
|
56
|
+
return fs_extra_1.default
|
|
57
|
+
.readFileSync(path_1.default.join(__dirname, '../../components/oc-client/_package/template.js'))
|
|
58
|
+
.toString();
|
|
59
|
+
}
|
|
60
|
+
return fs_extra_1.default
|
|
61
|
+
.readFileSync(path_1.default.join(conf.path, `${componentName}/_package/template.js`))
|
|
62
|
+
.toString();
|
|
63
|
+
},
|
|
64
|
+
getComponents() {
|
|
65
|
+
const validComponents = conf.components ||
|
|
66
|
+
fs_extra_1.default.readdirSync(conf.path).filter(file => {
|
|
67
|
+
const isDir = fs_extra_1.default.lstatSync(path_1.default.join(conf.path, file)).isDirectory();
|
|
68
|
+
const isValidComponent = isDir
|
|
69
|
+
? fs_extra_1.default
|
|
70
|
+
.readdirSync(path_1.default.join(conf.path, file))
|
|
71
|
+
.filter(file => file === '_package').length === 1
|
|
72
|
+
: false;
|
|
73
|
+
return isValidComponent;
|
|
74
|
+
});
|
|
75
|
+
validComponents.push('oc-client');
|
|
76
|
+
return validComponents;
|
|
77
|
+
},
|
|
78
|
+
getComponentVersions(componentName) {
|
|
79
|
+
if (componentName === 'oc-client') {
|
|
80
|
+
return Promise.all([
|
|
81
|
+
fs_extra_1.default
|
|
82
|
+
.readJson(path_1.default.join(__dirname, '../../../package.json'))
|
|
83
|
+
.then(x => x.version)
|
|
84
|
+
]);
|
|
85
|
+
}
|
|
86
|
+
if (!local.getComponents().includes(componentName)) {
|
|
87
|
+
return Promise.reject(resources_1.default.errors.registry.COMPONENT_NOT_FOUND(componentName, repositorySource));
|
|
88
|
+
}
|
|
89
|
+
return Promise.all([
|
|
90
|
+
fs_extra_1.default
|
|
91
|
+
.readJson(path_1.default.join(conf.path, `${componentName}/package.json`))
|
|
92
|
+
.then(x => x.version)
|
|
93
|
+
]);
|
|
94
|
+
},
|
|
95
|
+
getDataProvider(componentName) {
|
|
96
|
+
const ocClientServerPath = '../../components/oc-client/_package/server.js';
|
|
97
|
+
const filePath = componentName === 'oc-client'
|
|
98
|
+
? path_1.default.join(__dirname, ocClientServerPath)
|
|
99
|
+
: path_1.default.join(conf.path, `${componentName}/_package/server.js`);
|
|
100
|
+
return {
|
|
101
|
+
content: fs_extra_1.default.readFileSync(filePath).toString(),
|
|
102
|
+
filePath
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
const repository = {
|
|
107
|
+
getCompiledView(componentName, componentVersion) {
|
|
108
|
+
if (conf.local) {
|
|
109
|
+
return Promise.resolve(local.getCompiledView(componentName));
|
|
110
|
+
}
|
|
111
|
+
return cdn.getFile(getFilePath(componentName, componentVersion, 'template.js'));
|
|
112
|
+
},
|
|
113
|
+
async getComponent(componentName, componentVersion) {
|
|
114
|
+
const allVersions = await repository.getComponentVersions(componentName);
|
|
115
|
+
if (allVersions.length === 0) {
|
|
116
|
+
throw resources_1.default.errors.registry.COMPONENT_NOT_FOUND(componentName, repositorySource);
|
|
117
|
+
}
|
|
118
|
+
const version = versionHandler.getAvailableVersion(componentVersion, allVersions);
|
|
119
|
+
if (!version) {
|
|
120
|
+
throw resources_1.default.errors.registry.COMPONENT_VERSION_NOT_FOUND(componentName, componentVersion || '', repositorySource);
|
|
121
|
+
}
|
|
122
|
+
const component = await repository
|
|
123
|
+
.getComponentInfo(componentName, version)
|
|
124
|
+
.catch(err => {
|
|
125
|
+
throw `component not available: ${(0, error_to_string_1.default)(err)}`;
|
|
126
|
+
});
|
|
127
|
+
return Object.assign(component, { allVersions });
|
|
128
|
+
},
|
|
129
|
+
getComponentInfo(componentName, componentVersion) {
|
|
130
|
+
if (conf.local) {
|
|
131
|
+
let componentInfo;
|
|
132
|
+
if (componentName === 'oc-client') {
|
|
133
|
+
componentInfo = fs_extra_1.default.readJsonSync(path_1.default.join(__dirname, '../../components/oc-client/_package/package.json'));
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
componentInfo = fs_extra_1.default.readJsonSync(path_1.default.join(conf.path, `${componentName}/_package/package.json`));
|
|
137
|
+
}
|
|
138
|
+
if (componentInfo.version === componentVersion) {
|
|
139
|
+
return Promise.resolve(componentInfo);
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
// eslint-disable-next-line prefer-promise-reject-errors
|
|
143
|
+
return Promise.reject('version not available');
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return cdn.getJson(getFilePath(componentName, componentVersion, 'package.json'), false);
|
|
147
|
+
},
|
|
148
|
+
getComponentPath(componentName, componentVersion) {
|
|
149
|
+
const prefix = conf.local
|
|
150
|
+
? conf.baseUrl
|
|
151
|
+
: `${options['path']}${options.componentsDir}/`;
|
|
152
|
+
return `${prefix}${componentName}/${componentVersion}/`;
|
|
153
|
+
},
|
|
154
|
+
async getComponents() {
|
|
155
|
+
if (conf.local) {
|
|
156
|
+
return local.getComponents();
|
|
157
|
+
}
|
|
158
|
+
const { components } = await componentsCache.get();
|
|
159
|
+
return Object.keys(components);
|
|
160
|
+
},
|
|
161
|
+
getComponentsDetails() {
|
|
162
|
+
if (conf.local) {
|
|
163
|
+
// when in local this won't get called
|
|
164
|
+
return Promise.resolve(null);
|
|
165
|
+
}
|
|
166
|
+
return componentsDetails.get();
|
|
167
|
+
},
|
|
168
|
+
async getComponentVersions(componentName) {
|
|
169
|
+
if (conf.local) {
|
|
170
|
+
return local.getComponentVersions(componentName);
|
|
171
|
+
}
|
|
172
|
+
const res = await componentsCache.get();
|
|
173
|
+
return res.components[componentName] ? res.components[componentName] : [];
|
|
174
|
+
},
|
|
175
|
+
async getDataProvider(componentName, componentVersion) {
|
|
176
|
+
if (conf.local) {
|
|
177
|
+
return local.getDataProvider(componentName);
|
|
178
|
+
}
|
|
179
|
+
const filePath = getFilePath(componentName, componentVersion, 'server.js');
|
|
180
|
+
const content = await cdn.getFile(filePath);
|
|
181
|
+
return { content, filePath };
|
|
182
|
+
},
|
|
183
|
+
getStaticClientPath: () => `${options['path']}${getFilePath('oc-client', packageInfo.version, 'src/oc-client.min.js')}`,
|
|
184
|
+
getStaticClientMapPath: () => `${options['path']}${getFilePath('oc-client', packageInfo.version, 'src/oc-client.min.map')}`,
|
|
185
|
+
getStaticFilePath: (componentName, componentVersion, filePath) => `${repository.getComponentPath(componentName, componentVersion)}${conf.local ? settings_1.default.registry.localStaticRedirectorPath : ''}${filePath}`,
|
|
186
|
+
getTemplatesInfo: () => templatesInfo,
|
|
187
|
+
getTemplate: (type) => templatesHash[type],
|
|
188
|
+
async init() {
|
|
189
|
+
if (conf.local) {
|
|
190
|
+
// when in local this won't get called
|
|
191
|
+
return 'ok';
|
|
192
|
+
}
|
|
193
|
+
const componentsList = await componentsCache.load();
|
|
194
|
+
return componentsDetails.refresh(componentsList);
|
|
195
|
+
},
|
|
196
|
+
async publishComponent(pkgDetails, componentName, componentVersion) {
|
|
197
|
+
if (conf.local) {
|
|
198
|
+
throw {
|
|
199
|
+
code: resources_1.default.errors.registry.LOCAL_PUBLISH_NOT_ALLOWED_CODE,
|
|
200
|
+
msg: resources_1.default.errors.registry.LOCAL_PUBLISH_NOT_ALLOWED
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
if (!validator.validateComponentName(componentName)) {
|
|
204
|
+
throw {
|
|
205
|
+
code: resources_1.default.errors.registry.COMPONENT_NAME_NOT_VALID_CODE,
|
|
206
|
+
msg: resources_1.default.errors.registry.COMPONENT_NAME_NOT_VALID
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
if (!validator.validateVersion(componentVersion)) {
|
|
210
|
+
throw {
|
|
211
|
+
code: resources_1.default.errors.registry.COMPONENT_VERSION_NOT_VALID_CODE,
|
|
212
|
+
msg: resources_1.default.errors.registry.COMPONENT_VERSION_NOT_VALID(componentVersion)
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
const validationResult = validator.validatePackageJson(Object.assign(pkgDetails, {
|
|
216
|
+
componentName,
|
|
217
|
+
customValidator: conf.publishValidation
|
|
218
|
+
}));
|
|
219
|
+
if (!validationResult.isValid) {
|
|
220
|
+
throw {
|
|
221
|
+
code: resources_1.default.errors.registry.COMPONENT_PUBLISHVALIDATION_FAIL_CODE,
|
|
222
|
+
msg: resources_1.default.errors.registry.COMPONENT_PUBLISHVALIDATION_FAIL(String(validationResult.error))
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
const componentVersions = await repository.getComponentVersions(componentName);
|
|
226
|
+
if (!versionHandler.validateNewVersion(componentVersion, componentVersions)) {
|
|
227
|
+
throw {
|
|
228
|
+
code: resources_1.default.errors.registry.COMPONENT_VERSION_ALREADY_FOUND_CODE,
|
|
229
|
+
msg: resources_1.default.errors.registry.COMPONENT_VERSION_ALREADY_FOUND(componentName, componentVersion, repositorySource)
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
pkgDetails.packageJson.oc.date = (0, oc_get_unix_utc_timestamp_1.default)();
|
|
233
|
+
await fs_extra_1.default.writeJson(path_1.default.join(pkgDetails.outputFolder, 'package.json'), pkgDetails.packageJson);
|
|
234
|
+
await cdn.putDir(pkgDetails.outputFolder, `${options.componentsDir}/${componentName}/${componentVersion}`);
|
|
235
|
+
const componentsList = await componentsCache.refresh();
|
|
236
|
+
return componentsDetails.refresh(componentsList);
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
return repository;
|
|
240
|
+
}
|
|
241
|
+
exports.default = repository;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: (injectedDependencies: string[]) => <T = unknown>(requirePath: string) => T;
|
|
2
|
-
export default _default;
|
|
1
|
+
declare const _default: (injectedDependencies: string[]) => <T = unknown>(requirePath: string) => T;
|
|
2
|
+
export default _default;
|