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
|
@@ -1,50 +1,50 @@
|
|
|
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 semver_1 = __importDefault(require("semver"));
|
|
7
|
-
const p_limit_1 = __importDefault(require("p-limit"));
|
|
8
|
-
const oc_get_unix_utc_timestamp_1 = __importDefault(require("oc-get-unix-utc-timestamp"));
|
|
9
|
-
function componentsList(conf, cdn) {
|
|
10
|
-
const filePath = () => `${conf.storage.options.componentsDir}/components.json`;
|
|
11
|
-
const componentsList = {
|
|
12
|
-
getFromJson: () => cdn.getJson(filePath(), true),
|
|
13
|
-
getFromDirectories: async () => {
|
|
14
|
-
const componentsInfo = {};
|
|
15
|
-
const getVersionsForComponent = async (componentName) => {
|
|
16
|
-
const versions = await cdn.listSubDirectories(`${conf.storage.options.componentsDir}/${componentName}`);
|
|
17
|
-
return versions.sort(semver_1.default.compare);
|
|
18
|
-
};
|
|
19
|
-
try {
|
|
20
|
-
const components = await cdn.listSubDirectories(conf.storage.options.componentsDir);
|
|
21
|
-
const limit = (0, p_limit_1.default)(cdn.maxConcurrentRequests);
|
|
22
|
-
const versions = await Promise.all(components.map(component => limit(() => getVersionsForComponent(component))));
|
|
23
|
-
components.forEach((component, i) => {
|
|
24
|
-
componentsInfo[component] = versions[i];
|
|
25
|
-
});
|
|
26
|
-
return {
|
|
27
|
-
lastEdit: (0, oc_get_unix_utc_timestamp_1.default)(),
|
|
28
|
-
components: componentsInfo
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
catch (err) {
|
|
32
|
-
if (err.code === 'dir_not_found') {
|
|
33
|
-
|
|
34
|
-
lastEdit: (0, oc_get_unix_utc_timestamp_1.default)(),
|
|
35
|
-
components:
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
throw err;
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
async refresh() {
|
|
42
|
-
const components = await componentsList.getFromDirectories();
|
|
43
|
-
await componentsList.save(components);
|
|
44
|
-
return components;
|
|
45
|
-
},
|
|
46
|
-
save: (data) => cdn.putFileContent(JSON.stringify(data), filePath(), true)
|
|
47
|
-
};
|
|
48
|
-
return componentsList;
|
|
49
|
-
}
|
|
50
|
-
exports.default = componentsList;
|
|
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 semver_1 = __importDefault(require("semver"));
|
|
7
|
+
const p_limit_1 = __importDefault(require("p-limit"));
|
|
8
|
+
const oc_get_unix_utc_timestamp_1 = __importDefault(require("oc-get-unix-utc-timestamp"));
|
|
9
|
+
function componentsList(conf, cdn) {
|
|
10
|
+
const filePath = () => `${conf.storage.options.componentsDir}/components.json`;
|
|
11
|
+
const componentsList = {
|
|
12
|
+
getFromJson: () => cdn.getJson(filePath(), true),
|
|
13
|
+
getFromDirectories: async () => {
|
|
14
|
+
const componentsInfo = {};
|
|
15
|
+
const getVersionsForComponent = async (componentName) => {
|
|
16
|
+
const versions = await cdn.listSubDirectories(`${conf.storage.options.componentsDir}/${componentName}`);
|
|
17
|
+
return versions.sort(semver_1.default.compare);
|
|
18
|
+
};
|
|
19
|
+
try {
|
|
20
|
+
const components = await cdn.listSubDirectories(conf.storage.options.componentsDir);
|
|
21
|
+
const limit = (0, p_limit_1.default)(cdn.maxConcurrentRequests);
|
|
22
|
+
const versions = await Promise.all(components.map(component => limit(() => getVersionsForComponent(component))));
|
|
23
|
+
components.forEach((component, i) => {
|
|
24
|
+
componentsInfo[component] = versions[i];
|
|
25
|
+
});
|
|
26
|
+
return {
|
|
27
|
+
lastEdit: (0, oc_get_unix_utc_timestamp_1.default)(),
|
|
28
|
+
components: componentsInfo
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
catch (err) {
|
|
32
|
+
if (err.code === 'dir_not_found') {
|
|
33
|
+
return {
|
|
34
|
+
lastEdit: (0, oc_get_unix_utc_timestamp_1.default)(),
|
|
35
|
+
components: {}
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
throw err;
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
async refresh() {
|
|
42
|
+
const components = await componentsList.getFromDirectories();
|
|
43
|
+
await componentsList.save(components);
|
|
44
|
+
return components;
|
|
45
|
+
},
|
|
46
|
+
save: (data) => cdn.putFileContent(JSON.stringify(data), filePath(), true)
|
|
47
|
+
};
|
|
48
|
+
return componentsList;
|
|
49
|
+
}
|
|
50
|
+
exports.default = componentsList;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ComponentsList, Config } from '../../../types';
|
|
2
|
-
import { StorageAdapter } from 'oc-storage-adapters-utils';
|
|
3
|
-
export default function componentsCache(conf: Config, cdn: StorageAdapter): {
|
|
4
|
-
get(): ComponentsList;
|
|
5
|
-
load(): Promise<ComponentsList>;
|
|
6
|
-
refresh(): Promise<ComponentsList>;
|
|
7
|
-
};
|
|
1
|
+
import { ComponentsList, Config } from '../../../types';
|
|
2
|
+
import { StorageAdapter } from 'oc-storage-adapters-utils';
|
|
3
|
+
export default function componentsCache(conf: Config, cdn: StorageAdapter): {
|
|
4
|
+
get(): ComponentsList;
|
|
5
|
+
load(): Promise<ComponentsList>;
|
|
6
|
+
refresh(): Promise<ComponentsList>;
|
|
7
|
+
};
|
|
@@ -1,76 +1,76 @@
|
|
|
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 lodash_1 = __importDefault(require("lodash"));
|
|
7
|
-
const components_list_1 = __importDefault(require("./components-list"));
|
|
8
|
-
const events_handler_1 = __importDefault(require("../events-handler"));
|
|
9
|
-
const oc_get_unix_utc_timestamp_1 = __importDefault(require("oc-get-unix-utc-timestamp"));
|
|
10
|
-
function componentsCache(conf, cdn) {
|
|
11
|
-
let cachedComponentsList;
|
|
12
|
-
let refreshLoop;
|
|
13
|
-
const componentsList = (0, components_list_1.default)(conf, cdn);
|
|
14
|
-
const poll = () => setTimeout(async () => {
|
|
15
|
-
try {
|
|
16
|
-
const data = await componentsList.getFromJson();
|
|
17
|
-
events_handler_1.default.fire('cache-poll', (0, oc_get_unix_utc_timestamp_1.default)());
|
|
18
|
-
if (data.lastEdit > cachedComponentsList.lastEdit) {
|
|
19
|
-
cachedComponentsList = data;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
catch (err) {
|
|
23
|
-
events_handler_1.default.fire('error', {
|
|
24
|
-
code: 'components_list_get',
|
|
25
|
-
message: (err === null || err === void 0 ? void 0 : err.message) || String(err)
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
refreshLoop = poll();
|
|
29
|
-
}, conf.pollingInterval * 1000);
|
|
30
|
-
const cacheDataAndStartPolling = (data) => {
|
|
31
|
-
cachedComponentsList = data;
|
|
32
|
-
refreshLoop = poll();
|
|
33
|
-
return data;
|
|
34
|
-
};
|
|
35
|
-
const throwError = (code, message) => {
|
|
36
|
-
var _a;
|
|
37
|
-
events_handler_1.default.fire('error', { code, message: (_a = message === null || message === void 0 ? void 0 : message.message) !== null && _a !== void 0 ? _a : message });
|
|
38
|
-
throw code;
|
|
39
|
-
};
|
|
40
|
-
return {
|
|
41
|
-
get() {
|
|
42
|
-
if (!cachedComponentsList) {
|
|
43
|
-
return throwError('components_cache_empty', `The component's cache was empty`);
|
|
44
|
-
}
|
|
45
|
-
return cachedComponentsList;
|
|
46
|
-
},
|
|
47
|
-
async load() {
|
|
48
|
-
const dirComponents = await componentsList
|
|
49
|
-
.getFromDirectories()
|
|
50
|
-
.catch(err => throwError('components_list_get', err));
|
|
51
|
-
const jsonComponents = await componentsList
|
|
52
|
-
.getFromJson()
|
|
53
|
-
.catch(() => null);
|
|
54
|
-
if (!jsonComponents ||
|
|
55
|
-
!lodash_1.default.isEqual(dirComponents.components, jsonComponents.components)) {
|
|
56
|
-
await componentsList
|
|
57
|
-
.save(dirComponents)
|
|
58
|
-
.catch(err => throwError('components_list_save', err));
|
|
59
|
-
}
|
|
60
|
-
cacheDataAndStartPolling(dirComponents);
|
|
61
|
-
return dirComponents;
|
|
62
|
-
},
|
|
63
|
-
async refresh() {
|
|
64
|
-
clearTimeout(refreshLoop);
|
|
65
|
-
try {
|
|
66
|
-
const components = await componentsList.refresh();
|
|
67
|
-
cacheDataAndStartPolling(components);
|
|
68
|
-
return components;
|
|
69
|
-
}
|
|
70
|
-
catch (err) {
|
|
71
|
-
return throwError('components_cache_refresh', err);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
exports.default = componentsCache;
|
|
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 lodash_1 = __importDefault(require("lodash"));
|
|
7
|
+
const components_list_1 = __importDefault(require("./components-list"));
|
|
8
|
+
const events_handler_1 = __importDefault(require("../events-handler"));
|
|
9
|
+
const oc_get_unix_utc_timestamp_1 = __importDefault(require("oc-get-unix-utc-timestamp"));
|
|
10
|
+
function componentsCache(conf, cdn) {
|
|
11
|
+
let cachedComponentsList;
|
|
12
|
+
let refreshLoop;
|
|
13
|
+
const componentsList = (0, components_list_1.default)(conf, cdn);
|
|
14
|
+
const poll = () => setTimeout(async () => {
|
|
15
|
+
try {
|
|
16
|
+
const data = await componentsList.getFromJson();
|
|
17
|
+
events_handler_1.default.fire('cache-poll', (0, oc_get_unix_utc_timestamp_1.default)());
|
|
18
|
+
if (data.lastEdit > cachedComponentsList.lastEdit) {
|
|
19
|
+
cachedComponentsList = data;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
catch (err) {
|
|
23
|
+
events_handler_1.default.fire('error', {
|
|
24
|
+
code: 'components_list_get',
|
|
25
|
+
message: (err === null || err === void 0 ? void 0 : err.message) || String(err)
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
refreshLoop = poll();
|
|
29
|
+
}, conf.pollingInterval * 1000);
|
|
30
|
+
const cacheDataAndStartPolling = (data) => {
|
|
31
|
+
cachedComponentsList = data;
|
|
32
|
+
refreshLoop = poll();
|
|
33
|
+
return data;
|
|
34
|
+
};
|
|
35
|
+
const throwError = (code, message) => {
|
|
36
|
+
var _a;
|
|
37
|
+
events_handler_1.default.fire('error', { code, message: (_a = message === null || message === void 0 ? void 0 : message.message) !== null && _a !== void 0 ? _a : message });
|
|
38
|
+
throw code;
|
|
39
|
+
};
|
|
40
|
+
return {
|
|
41
|
+
get() {
|
|
42
|
+
if (!cachedComponentsList) {
|
|
43
|
+
return throwError('components_cache_empty', `The component's cache was empty`);
|
|
44
|
+
}
|
|
45
|
+
return cachedComponentsList;
|
|
46
|
+
},
|
|
47
|
+
async load() {
|
|
48
|
+
const dirComponents = await componentsList
|
|
49
|
+
.getFromDirectories()
|
|
50
|
+
.catch(err => throwError('components_list_get', err));
|
|
51
|
+
const jsonComponents = await componentsList
|
|
52
|
+
.getFromJson()
|
|
53
|
+
.catch(() => null);
|
|
54
|
+
if (!jsonComponents ||
|
|
55
|
+
!lodash_1.default.isEqual(dirComponents.components, jsonComponents.components)) {
|
|
56
|
+
await componentsList
|
|
57
|
+
.save(dirComponents)
|
|
58
|
+
.catch(err => throwError('components_list_save', err));
|
|
59
|
+
}
|
|
60
|
+
cacheDataAndStartPolling(dirComponents);
|
|
61
|
+
return dirComponents;
|
|
62
|
+
},
|
|
63
|
+
async refresh() {
|
|
64
|
+
clearTimeout(refreshLoop);
|
|
65
|
+
try {
|
|
66
|
+
const components = await componentsList.refresh();
|
|
67
|
+
cacheDataAndStartPolling(components);
|
|
68
|
+
return components;
|
|
69
|
+
}
|
|
70
|
+
catch (err) {
|
|
71
|
+
return throwError('components_cache_refresh', err);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
exports.default = componentsCache;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ComponentsDetails, ComponentsList, Config } from '../../types';
|
|
2
|
-
import { StorageAdapter } from 'oc-storage-adapters-utils';
|
|
3
|
-
export default function componentsDetails(conf: Config, cdn: StorageAdapter): {
|
|
4
|
-
get: () => Promise<ComponentsDetails>;
|
|
5
|
-
refresh: (componentsList: ComponentsList) => Promise<ComponentsDetails>;
|
|
6
|
-
};
|
|
1
|
+
import { ComponentsDetails, ComponentsList, Config } from '../../types';
|
|
2
|
+
import { StorageAdapter } from 'oc-storage-adapters-utils';
|
|
3
|
+
export default function componentsDetails(conf: Config, cdn: StorageAdapter): {
|
|
4
|
+
get: () => Promise<ComponentsDetails>;
|
|
5
|
+
refresh: (componentsList: ComponentsList) => Promise<ComponentsDetails>;
|
|
6
|
+
};
|
|
@@ -1,64 +1,64 @@
|
|
|
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 p_limit_1 = __importDefault(require("p-limit"));
|
|
7
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
8
|
-
const events_handler_1 = __importDefault(require("./events-handler"));
|
|
9
|
-
const oc_get_unix_utc_timestamp_1 = __importDefault(require("oc-get-unix-utc-timestamp"));
|
|
10
|
-
function componentsDetails(conf, cdn) {
|
|
11
|
-
const returnError = (code, message) => {
|
|
12
|
-
var _a, _b;
|
|
13
|
-
events_handler_1.default.fire('error', {
|
|
14
|
-
code,
|
|
15
|
-
message: (_b = (_a = message) === null || _a === void 0 ? void 0 : _a.message) !== null && _b !== void 0 ? _b : message
|
|
16
|
-
});
|
|
17
|
-
throw code;
|
|
18
|
-
};
|
|
19
|
-
const filePath = () => `${conf.storage.options.componentsDir}/components-details.json`;
|
|
20
|
-
const getFromJson = () => cdn.getJson(filePath(), true);
|
|
21
|
-
const getFromDirectories = async (options) => {
|
|
22
|
-
const details = Object.assign({}, lodash_1.default.cloneDeep(options.details));
|
|
23
|
-
details.components = details.components || {};
|
|
24
|
-
const missing = [];
|
|
25
|
-
lodash_1.default.each(options.componentsList.components, (versions, name) => {
|
|
26
|
-
details.components[name] = details.components[name] || {};
|
|
27
|
-
lodash_1.default.each(versions, version => {
|
|
28
|
-
if (!details.components[name][version]) {
|
|
29
|
-
missing.push({ name, version });
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
const limit = (0, p_limit_1.default)(cdn.maxConcurrentRequests);
|
|
34
|
-
await Promise.all(missing.map(({ name, version }) => limit(async () => {
|
|
35
|
-
const content = await cdn.getJson(`${conf.storage.options.componentsDir}/${name}/${version}/package.json`, true);
|
|
36
|
-
details.components[name][version] = {
|
|
37
|
-
publishDate: content.oc.date || 0
|
|
38
|
-
};
|
|
39
|
-
})));
|
|
40
|
-
return {
|
|
41
|
-
lastEdit: (0, oc_get_unix_utc_timestamp_1.default)(),
|
|
42
|
-
components: details.components
|
|
43
|
-
};
|
|
44
|
-
};
|
|
45
|
-
const save = (data) => cdn.putFileContent(JSON.stringify(data), filePath(), true);
|
|
46
|
-
const refresh = async (componentsList) => {
|
|
47
|
-
const jsonDetails = await getFromJson().catch(() => undefined);
|
|
48
|
-
const dirDetails = await getFromDirectories({
|
|
49
|
-
componentsList,
|
|
50
|
-
details: jsonDetails
|
|
51
|
-
}).catch(err => returnError('components_details_get', err));
|
|
52
|
-
if (!jsonDetails ||
|
|
53
|
-
!lodash_1.default.isEqual(dirDetails.components, jsonDetails.components)) {
|
|
54
|
-
await save(dirDetails).catch(err => returnError('components_details_save', err));
|
|
55
|
-
return dirDetails;
|
|
56
|
-
}
|
|
57
|
-
return jsonDetails;
|
|
58
|
-
};
|
|
59
|
-
return {
|
|
60
|
-
get: getFromJson,
|
|
61
|
-
refresh
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
exports.default = componentsDetails;
|
|
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 p_limit_1 = __importDefault(require("p-limit"));
|
|
7
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
8
|
+
const events_handler_1 = __importDefault(require("./events-handler"));
|
|
9
|
+
const oc_get_unix_utc_timestamp_1 = __importDefault(require("oc-get-unix-utc-timestamp"));
|
|
10
|
+
function componentsDetails(conf, cdn) {
|
|
11
|
+
const returnError = (code, message) => {
|
|
12
|
+
var _a, _b;
|
|
13
|
+
events_handler_1.default.fire('error', {
|
|
14
|
+
code,
|
|
15
|
+
message: (_b = (_a = message) === null || _a === void 0 ? void 0 : _a.message) !== null && _b !== void 0 ? _b : message
|
|
16
|
+
});
|
|
17
|
+
throw code;
|
|
18
|
+
};
|
|
19
|
+
const filePath = () => `${conf.storage.options.componentsDir}/components-details.json`;
|
|
20
|
+
const getFromJson = () => cdn.getJson(filePath(), true);
|
|
21
|
+
const getFromDirectories = async (options) => {
|
|
22
|
+
const details = Object.assign({}, lodash_1.default.cloneDeep(options.details));
|
|
23
|
+
details.components = details.components || {};
|
|
24
|
+
const missing = [];
|
|
25
|
+
lodash_1.default.each(options.componentsList.components, (versions, name) => {
|
|
26
|
+
details.components[name] = details.components[name] || {};
|
|
27
|
+
lodash_1.default.each(versions, version => {
|
|
28
|
+
if (!details.components[name][version]) {
|
|
29
|
+
missing.push({ name, version });
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
const limit = (0, p_limit_1.default)(cdn.maxConcurrentRequests);
|
|
34
|
+
await Promise.all(missing.map(({ name, version }) => limit(async () => {
|
|
35
|
+
const content = await cdn.getJson(`${conf.storage.options.componentsDir}/${name}/${version}/package.json`, true);
|
|
36
|
+
details.components[name][version] = {
|
|
37
|
+
publishDate: content.oc.date || 0
|
|
38
|
+
};
|
|
39
|
+
})));
|
|
40
|
+
return {
|
|
41
|
+
lastEdit: (0, oc_get_unix_utc_timestamp_1.default)(),
|
|
42
|
+
components: details.components
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
const save = (data) => cdn.putFileContent(JSON.stringify(data), filePath(), true);
|
|
46
|
+
const refresh = async (componentsList) => {
|
|
47
|
+
const jsonDetails = await getFromJson().catch(() => undefined);
|
|
48
|
+
const dirDetails = await getFromDirectories({
|
|
49
|
+
componentsList,
|
|
50
|
+
details: jsonDetails
|
|
51
|
+
}).catch(err => returnError('components_details_get', err));
|
|
52
|
+
if (!jsonDetails ||
|
|
53
|
+
!lodash_1.default.isEqual(dirDetails.components, jsonDetails.components)) {
|
|
54
|
+
await save(dirDetails).catch(err => returnError('components_details_save', err));
|
|
55
|
+
return dirDetails;
|
|
56
|
+
}
|
|
57
|
+
return jsonDetails;
|
|
58
|
+
};
|
|
59
|
+
return {
|
|
60
|
+
get: getFromJson,
|
|
61
|
+
refresh
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
exports.default = componentsDetails;
|
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { IncomingHttpHeaders } from 'http';
|
|
3
|
-
declare type Subscription<T = any> = (data: T) => void;
|
|
4
|
-
export interface RequestData {
|
|
5
|
-
body: any;
|
|
6
|
-
duration: number;
|
|
7
|
-
headers: IncomingHttpHeaders;
|
|
8
|
-
method: string;
|
|
9
|
-
path: string;
|
|
10
|
-
relativeUrl: string;
|
|
11
|
-
query: Record<string, any>;
|
|
12
|
-
url: string;
|
|
13
|
-
statusCode: number;
|
|
14
|
-
errorDetails?: string;
|
|
15
|
-
errorCode?: string;
|
|
16
|
-
}
|
|
17
|
-
declare type Events = {
|
|
18
|
-
error: {
|
|
19
|
-
code: string;
|
|
20
|
-
message: string;
|
|
21
|
-
};
|
|
22
|
-
start: unknown;
|
|
23
|
-
'cache-poll': number;
|
|
24
|
-
request: RequestData;
|
|
25
|
-
'component-retrieved': {
|
|
26
|
-
headers: IncomingHttpHeaders;
|
|
27
|
-
name: string;
|
|
28
|
-
parameters: IncomingHttpHeaders;
|
|
29
|
-
requestVersion: string;
|
|
30
|
-
duration: number;
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
declare type EventsHandler = {
|
|
34
|
-
fire<T extends keyof Events>(eventName: T, data: Events[T]): void;
|
|
35
|
-
on<T extends keyof Events>(eventName: T, listener: Subscription<Events[T]>): void;
|
|
36
|
-
off<T extends keyof Events>(eventName: T, listener: Subscription<Events[T]>): void;
|
|
37
|
-
reset(): void;
|
|
38
|
-
};
|
|
39
|
-
declare const eventsHandler: EventsHandler;
|
|
40
|
-
export default eventsHandler;
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { IncomingHttpHeaders } from 'http';
|
|
3
|
+
declare type Subscription<T = any> = (data: T) => void;
|
|
4
|
+
export interface RequestData {
|
|
5
|
+
body: any;
|
|
6
|
+
duration: number;
|
|
7
|
+
headers: IncomingHttpHeaders;
|
|
8
|
+
method: string;
|
|
9
|
+
path: string;
|
|
10
|
+
relativeUrl: string;
|
|
11
|
+
query: Record<string, any>;
|
|
12
|
+
url: string;
|
|
13
|
+
statusCode: number;
|
|
14
|
+
errorDetails?: string;
|
|
15
|
+
errorCode?: string;
|
|
16
|
+
}
|
|
17
|
+
declare type Events = {
|
|
18
|
+
error: {
|
|
19
|
+
code: string;
|
|
20
|
+
message: string;
|
|
21
|
+
};
|
|
22
|
+
start: unknown;
|
|
23
|
+
'cache-poll': number;
|
|
24
|
+
request: RequestData;
|
|
25
|
+
'component-retrieved': {
|
|
26
|
+
headers: IncomingHttpHeaders;
|
|
27
|
+
name: string;
|
|
28
|
+
parameters: IncomingHttpHeaders;
|
|
29
|
+
requestVersion: string;
|
|
30
|
+
duration: number;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
declare type EventsHandler = {
|
|
34
|
+
fire<T extends keyof Events>(eventName: T, data: Events[T]): void;
|
|
35
|
+
on<T extends keyof Events>(eventName: T, listener: Subscription<Events[T]>): void;
|
|
36
|
+
off<T extends keyof Events>(eventName: T, listener: Subscription<Events[T]>): void;
|
|
37
|
+
reset(): void;
|
|
38
|
+
};
|
|
39
|
+
declare const eventsHandler: EventsHandler;
|
|
40
|
+
export default eventsHandler;
|
|
@@ -1,37 +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 resources_1 = __importDefault(require("../../resources"));
|
|
7
|
-
let subscriptions = {};
|
|
8
|
-
const eventsHandler = {
|
|
9
|
-
fire(eventName, eventData) {
|
|
10
|
-
if (subscriptions[eventName]) {
|
|
11
|
-
subscriptions[eventName].forEach(callback => {
|
|
12
|
-
callback(eventData);
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
on(eventName, callback) {
|
|
17
|
-
if (typeof callback !== 'function') {
|
|
18
|
-
throw resources_1.default.errors.registry.CONFIGURATION_ONREQUEST_MUST_BE_FUNCTION;
|
|
19
|
-
}
|
|
20
|
-
if (!subscriptions[eventName]) {
|
|
21
|
-
subscriptions[eventName] = [];
|
|
22
|
-
}
|
|
23
|
-
subscriptions[eventName].push(callback);
|
|
24
|
-
},
|
|
25
|
-
off(eventName, callback) {
|
|
26
|
-
if (typeof callback !== 'function') {
|
|
27
|
-
throw resources_1.default.errors.registry.CONFIGURATION_OFFREQUEST_MUST_BE_FUNCTION;
|
|
28
|
-
}
|
|
29
|
-
if (subscriptions[eventName]) {
|
|
30
|
-
subscriptions[eventName] = subscriptions[eventName].filter(sub => sub !== callback);
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
reset() {
|
|
34
|
-
subscriptions = {};
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
exports.default = eventsHandler;
|
|
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 resources_1 = __importDefault(require("../../resources"));
|
|
7
|
+
let subscriptions = {};
|
|
8
|
+
const eventsHandler = {
|
|
9
|
+
fire(eventName, eventData) {
|
|
10
|
+
if (subscriptions[eventName]) {
|
|
11
|
+
subscriptions[eventName].forEach(callback => {
|
|
12
|
+
callback(eventData);
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
on(eventName, callback) {
|
|
17
|
+
if (typeof callback !== 'function') {
|
|
18
|
+
throw resources_1.default.errors.registry.CONFIGURATION_ONREQUEST_MUST_BE_FUNCTION;
|
|
19
|
+
}
|
|
20
|
+
if (!subscriptions[eventName]) {
|
|
21
|
+
subscriptions[eventName] = [];
|
|
22
|
+
}
|
|
23
|
+
subscriptions[eventName].push(callback);
|
|
24
|
+
},
|
|
25
|
+
off(eventName, callback) {
|
|
26
|
+
if (typeof callback !== 'function') {
|
|
27
|
+
throw resources_1.default.errors.registry.CONFIGURATION_OFFREQUEST_MUST_BE_FUNCTION;
|
|
28
|
+
}
|
|
29
|
+
if (subscriptions[eventName]) {
|
|
30
|
+
subscriptions[eventName] = subscriptions[eventName].filter(sub => sub !== callback);
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
reset() {
|
|
34
|
+
subscriptions = {};
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
exports.default = eventsHandler;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/// <reference types="multer" />
|
|
2
|
-
import { PackageJson } from 'type-fest';
|
|
3
|
-
export default function extractPackage(files: Express.Multer.File[] | {
|
|
4
|
-
[fieldname: string]: Express.Multer.File[];
|
|
5
|
-
}): Promise<{
|
|
6
|
-
outputFolder: string;
|
|
7
|
-
packageJson: PackageJson;
|
|
8
|
-
}>;
|
|
1
|
+
/// <reference types="multer" />
|
|
2
|
+
import { PackageJson } from 'type-fest';
|
|
3
|
+
export default function extractPackage(files: Express.Multer.File[] | {
|
|
4
|
+
[fieldname: string]: Express.Multer.File[];
|
|
5
|
+
}, tarExtractMode: number): Promise<{
|
|
6
|
+
outputFolder: string;
|
|
7
|
+
packageJson: PackageJson;
|
|
8
|
+
}>;
|
|
@@ -1,26 +1,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 path_1 = __importDefault(require("path"));
|
|
7
|
-
const targz_1 = __importDefault(require("targz"));
|
|
8
|
-
const util_1 = require("util");
|
|
9
|
-
const get_package_json_from_temp_dir_1 = __importDefault(require("./get-package-json-from-temp-dir"));
|
|
10
|
-
async function extractPackage(files) {
|
|
11
|
-
const packageFile = files[0];
|
|
12
|
-
const packagePath = path_1.default.resolve(packageFile.path);
|
|
13
|
-
const packageUntarOutput = path_1.default.resolve(packageFile.path, '..', packageFile.filename.replace('.tar.gz', ''));
|
|
14
|
-
const packageOutput = path_1.default.resolve(packageUntarOutput, '_package');
|
|
15
|
-
const decompress = (0, util_1.promisify)(targz_1.default.decompress);
|
|
16
|
-
await decompress({
|
|
17
|
-
src: packagePath,
|
|
18
|
-
dest: packageUntarOutput
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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 path_1 = __importDefault(require("path"));
|
|
7
|
+
const targz_1 = __importDefault(require("targz"));
|
|
8
|
+
const util_1 = require("util");
|
|
9
|
+
const get_package_json_from_temp_dir_1 = __importDefault(require("./get-package-json-from-temp-dir"));
|
|
10
|
+
async function extractPackage(files, tarExtractMode) {
|
|
11
|
+
const packageFile = files[0];
|
|
12
|
+
const packagePath = path_1.default.resolve(packageFile.path);
|
|
13
|
+
const packageUntarOutput = path_1.default.resolve(packageFile.path, '..', packageFile.filename.replace('.tar.gz', ''));
|
|
14
|
+
const packageOutput = path_1.default.resolve(packageUntarOutput, '_package');
|
|
15
|
+
const decompress = (0, util_1.promisify)(targz_1.default.decompress);
|
|
16
|
+
await decompress({
|
|
17
|
+
src: packagePath,
|
|
18
|
+
dest: packageUntarOutput,
|
|
19
|
+
tar: {
|
|
20
|
+
dmode: tarExtractMode,
|
|
21
|
+
fmode: tarExtractMode
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
const packageJson = await (0, get_package_json_from_temp_dir_1.default)(packageOutput);
|
|
25
|
+
return {
|
|
26
|
+
outputFolder: packageOutput,
|
|
27
|
+
packageJson: packageJson
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
exports.default = extractPackage;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { PackageJson } from 'type-fest';
|
|
2
|
-
export default function getPackageJsonFromTempDir(tempDirPath: string): Promise<PackageJson>;
|
|
1
|
+
import { PackageJson } from 'type-fest';
|
|
2
|
+
export default function getPackageJsonFromTempDir(tempDirPath: string): Promise<PackageJson>;
|