oc 0.49.13 → 0.49.14
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/.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 +54 -54
- package/dist/cli/domain/handle-dependencies/install-missing-dependencies.d.ts +5 -5
- package/dist/cli/domain/handle-dependencies/install-missing-dependencies.js +59 -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 +40 -40
- package/dist/cli/domain/init-template/install-template.d.ts +11 -11
- package/dist/cli/domain/init-template/install-template.js +54 -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 +82 -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 +67 -67
- package/dist/cli/domain/registry.d.ts +20 -6
- package/dist/cli/domain/registry.js +139 -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 +176 -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 +109 -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 +237 -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 +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 -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 +90 -90
- package/dist/registry/routes/component-preview.d.ts +4 -3
- package/dist/registry/routes/component-preview.js +68 -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 +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 +34 -33
- package/dist/registry/routes/helpers/get-component.js +406 -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 +97 -97
- 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 +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 +7 -7
- 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/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 +2 -2
- package/src/types.ts +2 -86
|
@@ -4,7 +4,10 @@ import jadeTemplate from 'oc-template-jade';
|
|
|
4
4
|
import { Template, TemplateInfo } from '../../types';
|
|
5
5
|
import _ from 'lodash';
|
|
6
6
|
|
|
7
|
-
export default function registerTemplates(
|
|
7
|
+
export default function registerTemplates(
|
|
8
|
+
extraTemplates: Template[],
|
|
9
|
+
dev = false
|
|
10
|
+
): {
|
|
8
11
|
templatesHash: Record<string, Template>;
|
|
9
12
|
templatesInfo: TemplateInfo[];
|
|
10
13
|
} {
|
|
@@ -21,7 +24,14 @@ export default function registerTemplates(extraTemplates: Template[]): {
|
|
|
21
24
|
}, {} as Record<string, Template>);
|
|
22
25
|
|
|
23
26
|
const templatesInfo = templates.map(template => {
|
|
24
|
-
|
|
27
|
+
const { externals, ...rest } = template.getInfo();
|
|
28
|
+
return {
|
|
29
|
+
...rest,
|
|
30
|
+
externals: externals.map(({ url, devUrl, ...rest }) => ({
|
|
31
|
+
...rest,
|
|
32
|
+
url: dev && devUrl ? devUrl : url
|
|
33
|
+
}))
|
|
34
|
+
};
|
|
25
35
|
});
|
|
26
36
|
|
|
27
37
|
return {
|
|
@@ -11,14 +11,19 @@ import * as validator from './validators';
|
|
|
11
11
|
import getPromiseBasedAdapter from './storage-adapter';
|
|
12
12
|
import * as versionHandler from './version-handler';
|
|
13
13
|
import errorToString from '../../utils/error-to-string';
|
|
14
|
-
import {
|
|
14
|
+
import {
|
|
15
|
+
Component,
|
|
16
|
+
ComponentsDetails,
|
|
17
|
+
Config,
|
|
18
|
+
TemplateInfo
|
|
19
|
+
} from '../../types';
|
|
15
20
|
import { StorageAdapter } from 'oc-storage-adapters-utils';
|
|
16
21
|
|
|
17
22
|
const packageInfo = fs.readJsonSync(
|
|
18
23
|
path.join(__dirname, '..', '..', '..', 'package.json')
|
|
19
24
|
);
|
|
20
25
|
|
|
21
|
-
export default function repository(conf: Config)
|
|
26
|
+
export default function repository(conf: Config) {
|
|
22
27
|
const cdn: StorageAdapter =
|
|
23
28
|
!conf.local &&
|
|
24
29
|
(getPromiseBasedAdapter(conf.storage.adapter(conf.storage.options)) as any);
|
|
@@ -32,7 +37,10 @@ export default function repository(conf: Config): Repository {
|
|
|
32
37
|
const getFilePath = (component: string, version: string, filePath: string) =>
|
|
33
38
|
`${options!.componentsDir}/${component}/${version}/${filePath}`;
|
|
34
39
|
|
|
35
|
-
const { templatesHash, templatesInfo } = registerTemplates(
|
|
40
|
+
const { templatesHash, templatesInfo } = registerTemplates(
|
|
41
|
+
conf.templates,
|
|
42
|
+
conf.local
|
|
43
|
+
);
|
|
36
44
|
|
|
37
45
|
const local = {
|
|
38
46
|
getCompiledView(componentName: string): string {
|
|
@@ -110,7 +118,10 @@ export default function repository(conf: Config): Repository {
|
|
|
110
118
|
};
|
|
111
119
|
|
|
112
120
|
const repository = {
|
|
113
|
-
getCompiledView(
|
|
121
|
+
getCompiledView(
|
|
122
|
+
componentName: string,
|
|
123
|
+
componentVersion: string
|
|
124
|
+
): Promise<string> {
|
|
114
125
|
if (conf.local) {
|
|
115
126
|
return Promise.resolve(local.getCompiledView(componentName));
|
|
116
127
|
}
|
|
@@ -119,7 +130,10 @@ export default function repository(conf: Config): Repository {
|
|
|
119
130
|
getFilePath(componentName, componentVersion, 'template.js')
|
|
120
131
|
);
|
|
121
132
|
},
|
|
122
|
-
async getComponent(
|
|
133
|
+
async getComponent(
|
|
134
|
+
componentName: string,
|
|
135
|
+
componentVersion?: string
|
|
136
|
+
): Promise<Component> {
|
|
123
137
|
const allVersions = await repository.getComponentVersions(componentName);
|
|
124
138
|
|
|
125
139
|
if (allVersions.length === 0) {
|
|
@@ -150,7 +164,10 @@ export default function repository(conf: Config): Repository {
|
|
|
150
164
|
|
|
151
165
|
return Object.assign(component, { allVersions });
|
|
152
166
|
},
|
|
153
|
-
getComponentInfo(
|
|
167
|
+
getComponentInfo(
|
|
168
|
+
componentName: string,
|
|
169
|
+
componentVersion: string
|
|
170
|
+
): Promise<Component> {
|
|
154
171
|
if (conf.local) {
|
|
155
172
|
let componentInfo: Component;
|
|
156
173
|
|
|
@@ -180,13 +197,13 @@ export default function repository(conf: Config): Repository {
|
|
|
180
197
|
false
|
|
181
198
|
);
|
|
182
199
|
},
|
|
183
|
-
getComponentPath(componentName: string, componentVersion: string) {
|
|
200
|
+
getComponentPath(componentName: string, componentVersion: string): string {
|
|
184
201
|
const prefix = conf.local
|
|
185
202
|
? conf.baseUrl
|
|
186
203
|
: `${options!['path']}${options!.componentsDir}/`;
|
|
187
204
|
return `${prefix}${componentName}/${componentVersion}/`;
|
|
188
205
|
},
|
|
189
|
-
async getComponents() {
|
|
206
|
+
async getComponents(): Promise<string[]> {
|
|
190
207
|
if (conf.local) {
|
|
191
208
|
return local.getComponents();
|
|
192
209
|
}
|
|
@@ -194,7 +211,7 @@ export default function repository(conf: Config): Repository {
|
|
|
194
211
|
const { components } = await componentsCache.get();
|
|
195
212
|
return Object.keys(components);
|
|
196
213
|
},
|
|
197
|
-
getComponentsDetails() {
|
|
214
|
+
getComponentsDetails(): Promise<ComponentsDetails> {
|
|
198
215
|
if (conf.local) {
|
|
199
216
|
// when in local this won't get called
|
|
200
217
|
return Promise.resolve(null) as any;
|
|
@@ -202,7 +219,7 @@ export default function repository(conf: Config): Repository {
|
|
|
202
219
|
|
|
203
220
|
return componentsDetails.get();
|
|
204
221
|
},
|
|
205
|
-
async getComponentVersions(componentName: string) {
|
|
222
|
+
async getComponentVersions(componentName: string): Promise<string[]> {
|
|
206
223
|
if (conf.local) {
|
|
207
224
|
return local.getComponentVersions(componentName);
|
|
208
225
|
}
|
|
@@ -211,7 +228,13 @@ export default function repository(conf: Config): Repository {
|
|
|
211
228
|
|
|
212
229
|
return res.components[componentName] ? res.components[componentName] : [];
|
|
213
230
|
},
|
|
214
|
-
async getDataProvider(
|
|
231
|
+
async getDataProvider(
|
|
232
|
+
componentName: string,
|
|
233
|
+
componentVersion: string
|
|
234
|
+
): Promise<{
|
|
235
|
+
content: string;
|
|
236
|
+
filePath: string;
|
|
237
|
+
}> {
|
|
215
238
|
if (conf.local) {
|
|
216
239
|
return local.getDataProvider(componentName);
|
|
217
240
|
}
|
|
@@ -226,14 +249,14 @@ export default function repository(conf: Config): Repository {
|
|
|
226
249
|
|
|
227
250
|
return { content, filePath };
|
|
228
251
|
},
|
|
229
|
-
getStaticClientPath: () =>
|
|
252
|
+
getStaticClientPath: (): string =>
|
|
230
253
|
`${options!['path']}${getFilePath(
|
|
231
254
|
'oc-client',
|
|
232
255
|
packageInfo.version,
|
|
233
256
|
'src/oc-client.min.js'
|
|
234
257
|
)}`,
|
|
235
258
|
|
|
236
|
-
getStaticClientMapPath: () =>
|
|
259
|
+
getStaticClientMapPath: (): string =>
|
|
237
260
|
`${options!['path']}${getFilePath(
|
|
238
261
|
'oc-client',
|
|
239
262
|
packageInfo.version,
|
|
@@ -244,14 +267,14 @@ export default function repository(conf: Config): Repository {
|
|
|
244
267
|
componentName: string,
|
|
245
268
|
componentVersion: string,
|
|
246
269
|
filePath: string
|
|
247
|
-
) =>
|
|
270
|
+
): string =>
|
|
248
271
|
`${repository.getComponentPath(componentName, componentVersion)}${
|
|
249
272
|
conf.local ? settings.registry.localStaticRedirectorPath : ''
|
|
250
273
|
}${filePath}`,
|
|
251
274
|
|
|
252
|
-
getTemplatesInfo: () => templatesInfo,
|
|
275
|
+
getTemplatesInfo: (): TemplateInfo[] => templatesInfo,
|
|
253
276
|
getTemplate: (type: string) => templatesHash[type],
|
|
254
|
-
async init() {
|
|
277
|
+
async init(): Promise<ComponentsDetails> {
|
|
255
278
|
if (conf.local) {
|
|
256
279
|
// when in local this won't get called
|
|
257
280
|
return 'ok' as any;
|
|
@@ -265,7 +288,7 @@ export default function repository(conf: Config): Repository {
|
|
|
265
288
|
pkgDetails: any,
|
|
266
289
|
componentName: string,
|
|
267
290
|
componentVersion: string
|
|
268
|
-
) {
|
|
291
|
+
): Promise<ComponentsDetails> {
|
|
269
292
|
if (conf.local) {
|
|
270
293
|
throw {
|
|
271
294
|
code: strings.errors.registry.LOCAL_PUBLISH_NOT_ALLOWED_CODE,
|
|
@@ -341,3 +364,5 @@ export default function repository(conf: Config): Repository {
|
|
|
341
364
|
|
|
342
365
|
return repository;
|
|
343
366
|
}
|
|
367
|
+
|
|
368
|
+
export type Repository = ReturnType<typeof repository>;
|
package/src/registry/index.ts
CHANGED
|
@@ -81,7 +81,10 @@ export default function registry(inputOptions: Input) {
|
|
|
81
81
|
).length;
|
|
82
82
|
const componentsReleases = Object.values(
|
|
83
83
|
componentsInfo.components
|
|
84
|
-
).reduce(
|
|
84
|
+
).reduce(
|
|
85
|
+
(acc, component) => acc + Object.keys(component).length,
|
|
86
|
+
0
|
|
87
|
+
);
|
|
85
88
|
|
|
86
89
|
ok(
|
|
87
90
|
`Registry serving ${componentsNumber} components for a total of ${componentsReleases} releases.`
|
package/src/registry/router.ts
CHANGED
|
@@ -9,7 +9,8 @@ import PluginsRoute from './routes/plugins';
|
|
|
9
9
|
import DependenciesRoute from './routes/dependencies';
|
|
10
10
|
import settings from '../resources/settings';
|
|
11
11
|
import type { Express } from 'express';
|
|
12
|
-
import {
|
|
12
|
+
import type { Repository } from '../registry/domain/repository';
|
|
13
|
+
import { Config } from '../types';
|
|
13
14
|
|
|
14
15
|
export function create(app: Express, conf: Config, repository: Repository) {
|
|
15
16
|
const routes = {
|
|
@@ -6,7 +6,8 @@ import * as getComponentFallback from './helpers/get-component-fallback';
|
|
|
6
6
|
import infoView from '../views/info';
|
|
7
7
|
import isUrlDiscoverable from './helpers/is-url-discoverable';
|
|
8
8
|
import * as urlBuilder from '../domain/url-builder';
|
|
9
|
-
import {
|
|
9
|
+
import type { Repository } from '../domain/repository';
|
|
10
|
+
import { Component, Config } from '../../types';
|
|
10
11
|
import { Request, Response } from 'express';
|
|
11
12
|
|
|
12
13
|
function getParams(component: Component) {
|
|
@@ -2,7 +2,8 @@ import * as getComponentFallback from './helpers/get-component-fallback';
|
|
|
2
2
|
import previewView from '../views/preview';
|
|
3
3
|
import * as urlBuilder from '../domain/url-builder';
|
|
4
4
|
import { Request, Response } from 'express';
|
|
5
|
-
import {
|
|
5
|
+
import type { Repository } from '../domain/repository';
|
|
6
|
+
import { Component, Config, TemplateInfo } from '../../types';
|
|
6
7
|
import { fromPromise } from 'universalify';
|
|
7
8
|
|
|
8
9
|
function componentPreview(
|
|
@@ -3,7 +3,8 @@ import _ from 'lodash';
|
|
|
3
3
|
|
|
4
4
|
import GetComponentHelper from './helpers/get-component';
|
|
5
5
|
import strings from '../../resources';
|
|
6
|
-
import {
|
|
6
|
+
import type { Repository } from '../domain/repository';
|
|
7
|
+
import { Config } from '../../types';
|
|
7
8
|
import { Request, RequestHandler, Response } from 'express';
|
|
8
9
|
|
|
9
10
|
export default function component(
|
|
@@ -5,7 +5,8 @@ import GetComponentHelper, {
|
|
|
5
5
|
GetComponentResult
|
|
6
6
|
} from './helpers/get-component';
|
|
7
7
|
import strings from '../../resources';
|
|
8
|
-
import {
|
|
8
|
+
import type { Repository } from '../domain/repository';
|
|
9
|
+
import { Config } from '../../types';
|
|
9
10
|
import { Request, RequestHandler, Response } from 'express';
|
|
10
11
|
|
|
11
12
|
type Component = {
|
|
@@ -18,7 +18,8 @@ import settings from '../../../resources/settings';
|
|
|
18
18
|
import strings from '../../../resources';
|
|
19
19
|
import * as urlBuilder from '../../domain/url-builder';
|
|
20
20
|
import * as validator from '../../domain/validators';
|
|
21
|
-
import {
|
|
21
|
+
import type { Repository } from '../../domain/repository';
|
|
22
|
+
import { Config } from '../../../types';
|
|
22
23
|
import { IncomingHttpHeaders } from 'http';
|
|
23
24
|
import { fromPromise } from 'universalify';
|
|
24
25
|
|
|
@@ -9,7 +9,8 @@ import getComponentsHistory from './helpers/get-components-history';
|
|
|
9
9
|
import getAvailableDependencies from './helpers/get-available-dependencies';
|
|
10
10
|
import indexView from '../views';
|
|
11
11
|
import urlBuilder = require('../domain/url-builder');
|
|
12
|
-
import {
|
|
12
|
+
import type { Repository } from '../domain/repository';
|
|
13
|
+
import { Author, Component, ParsedComponent } from '../../types';
|
|
13
14
|
import { NextFunction, Request, Response } from 'express';
|
|
14
15
|
import { IncomingHttpHeaders } from 'http';
|
|
15
16
|
import { PackageJson } from 'type-fest';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { Request, Response } from 'express';
|
|
1
2
|
import extractPackage from '../domain/extract-package';
|
|
2
3
|
import strings from '../../resources/index';
|
|
3
4
|
import * as validator from '../domain/validators';
|
|
4
|
-
import {
|
|
5
|
-
import { Repository } from '../../types';
|
|
5
|
+
import type { Repository } from '../domain/repository';
|
|
6
6
|
|
|
7
7
|
export default function publish(repository: Repository) {
|
|
8
8
|
return async function (req: Request, res: Response): Promise<void> {
|
|
@@ -54,7 +54,7 @@ export default function publish(repository: Repository) {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
try {
|
|
57
|
-
const pkgDetails = await extractPackage(files);
|
|
57
|
+
const pkgDetails = await extractPackage(files, res.conf.tarExtractMode);
|
|
58
58
|
|
|
59
59
|
try {
|
|
60
60
|
await repository.publishComponent(
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import fs from 'fs-extra';
|
|
2
2
|
import path from 'path';
|
|
3
|
+
import { Request, Response } from 'express';
|
|
3
4
|
|
|
4
5
|
import storageUtils from 'oc-storage-adapters-utils';
|
|
5
|
-
import {
|
|
6
|
-
import { Repository } from '../../types';
|
|
6
|
+
import type { Repository } from '../domain/repository';
|
|
7
7
|
|
|
8
8
|
export default function staticRedirector(repository: Repository) {
|
|
9
9
|
return function (req: Request, res: Response): void {
|
package/src/types.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { NextFunction, Request, Response } from 'express';
|
|
2
|
-
import { Logger } from './cli/logger';
|
|
3
2
|
import { PackageJson } from 'type-fest';
|
|
4
3
|
|
|
5
4
|
export interface Author {
|
|
@@ -25,6 +24,7 @@ export interface TemplateInfo {
|
|
|
25
24
|
name: string;
|
|
26
25
|
global: string | string[];
|
|
27
26
|
url: string;
|
|
27
|
+
devUrl?: string;
|
|
28
28
|
}>;
|
|
29
29
|
type: string;
|
|
30
30
|
version: string;
|
|
@@ -155,6 +155,7 @@ export interface Config {
|
|
|
155
155
|
liveReloadPort: number;
|
|
156
156
|
components?: string[];
|
|
157
157
|
local: boolean;
|
|
158
|
+
tarExtractMode: number;
|
|
158
159
|
path: string;
|
|
159
160
|
plugins: Record<string, (...args: unknown[]) => void>;
|
|
160
161
|
pollingInterval: number;
|
|
@@ -236,91 +237,6 @@ export interface Plugin {
|
|
|
236
237
|
};
|
|
237
238
|
}
|
|
238
239
|
|
|
239
|
-
export interface RegistryCli {
|
|
240
|
-
add(registry: string): Promise<void>;
|
|
241
|
-
get(): Promise<string[]>;
|
|
242
|
-
getApiComponentByHref(href: string): Promise<Component>;
|
|
243
|
-
getComponentPreviewUrlByUrl(componentHref: string): Promise<string>;
|
|
244
|
-
putComponent(options: {
|
|
245
|
-
username?: string;
|
|
246
|
-
password?: string;
|
|
247
|
-
route: string;
|
|
248
|
-
path: string;
|
|
249
|
-
}): Promise<void>;
|
|
250
|
-
remove(registry: string): Promise<void>;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
export interface Local {
|
|
254
|
-
clean: {
|
|
255
|
-
fetchList: (dirPath: string) => Promise<string[]>;
|
|
256
|
-
remove: (list: string[]) => Promise<void>;
|
|
257
|
-
};
|
|
258
|
-
cleanup: (compressedPackagePath: string) => Promise<void>;
|
|
259
|
-
compress: (input: string, output: string) => Promise<void>;
|
|
260
|
-
getComponentsByDir: (
|
|
261
|
-
componentsDir: string,
|
|
262
|
-
componentsToRun?: string[]
|
|
263
|
-
) => Promise<string[]>;
|
|
264
|
-
init: (options: {
|
|
265
|
-
componentName: string;
|
|
266
|
-
logger: Logger;
|
|
267
|
-
componentPath: string;
|
|
268
|
-
templateType: string;
|
|
269
|
-
}) => Promise<void>;
|
|
270
|
-
mock: (params: {
|
|
271
|
-
targetType: string;
|
|
272
|
-
targetValue: string;
|
|
273
|
-
targetName: string;
|
|
274
|
-
}) => Promise<void>;
|
|
275
|
-
package: (options: {
|
|
276
|
-
componentPath: string;
|
|
277
|
-
minify?: boolean;
|
|
278
|
-
verbose?: boolean;
|
|
279
|
-
production?: boolean;
|
|
280
|
-
}) => Promise<Component>;
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
export interface Repository {
|
|
284
|
-
getCompiledView(
|
|
285
|
-
componentName: string,
|
|
286
|
-
componentVersion: string
|
|
287
|
-
): Promise<string>;
|
|
288
|
-
getComponent(
|
|
289
|
-
componentName: string,
|
|
290
|
-
componentVersion?: string
|
|
291
|
-
): Promise<Component>;
|
|
292
|
-
getComponentInfo(
|
|
293
|
-
componentName: string,
|
|
294
|
-
componentVersion: string
|
|
295
|
-
): Promise<Component>;
|
|
296
|
-
getComponentPath(componentName: string, componentVersion: string): void;
|
|
297
|
-
getComponents(): Promise<string[]>;
|
|
298
|
-
getComponentsDetails(): Promise<ComponentsDetails>;
|
|
299
|
-
getComponentVersions(componentName: string): Promise<string[]>;
|
|
300
|
-
getDataProvider(
|
|
301
|
-
componentName: string,
|
|
302
|
-
componentVersion: string
|
|
303
|
-
): Promise<{
|
|
304
|
-
content: string;
|
|
305
|
-
filePath: string;
|
|
306
|
-
}>;
|
|
307
|
-
getStaticClientMapPath: () => string;
|
|
308
|
-
getStaticClientPath: () => string;
|
|
309
|
-
getStaticFilePath: (
|
|
310
|
-
componentName: string,
|
|
311
|
-
componentVersion: string,
|
|
312
|
-
filePath: string
|
|
313
|
-
) => string;
|
|
314
|
-
getTemplate: (type: string) => Template;
|
|
315
|
-
getTemplatesInfo: () => TemplateInfo[];
|
|
316
|
-
init(): Promise<ComponentsList>;
|
|
317
|
-
publishComponent(
|
|
318
|
-
pkgDetails: any,
|
|
319
|
-
componentName: string,
|
|
320
|
-
componentVersion: string
|
|
321
|
-
): Promise<ComponentsDetails>;
|
|
322
|
-
}
|
|
323
|
-
|
|
324
240
|
declare global {
|
|
325
241
|
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
326
242
|
namespace Express {
|