oc 0.49.7 → 0.49.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/README.md +2 -15
- package/dist/cli/domain/clean.d.ts +2 -2
- package/dist/cli/domain/clean.js +10 -13
- package/dist/cli/domain/get-components-by-dir.d.ts +1 -1
- package/dist/cli/domain/get-components-by-dir.js +8 -15
- package/dist/cli/domain/get-mocked-plugins.js +8 -6
- package/dist/cli/domain/handle-dependencies/ensure-compiler-is-declared-as-devDependency.d.ts +1 -1
- package/dist/cli/domain/handle-dependencies/ensure-compiler-is-declared-as-devDependency.js +4 -5
- package/dist/cli/domain/handle-dependencies/get-compiler.d.ts +1 -1
- package/dist/cli/domain/handle-dependencies/get-compiler.js +3 -3
- package/dist/cli/domain/handle-dependencies/index.d.ts +4 -3
- package/dist/cli/domain/handle-dependencies/index.js +40 -34
- package/dist/cli/domain/handle-dependencies/install-compiler.d.ts +1 -1
- package/dist/cli/domain/handle-dependencies/install-compiler.js +14 -7
- package/dist/cli/domain/handle-dependencies/install-missing-dependencies.d.ts +1 -1
- package/dist/cli/domain/handle-dependencies/install-missing-dependencies.js +13 -9
- package/dist/cli/domain/handle-dependencies/link-missing-dependencies.d.ts +1 -1
- package/dist/cli/domain/handle-dependencies/link-missing-dependencies.js +4 -8
- package/dist/cli/domain/init-template/index.d.ts +2 -2
- package/dist/cli/domain/init-template/index.js +6 -8
- package/dist/cli/domain/init-template/install-template.d.ts +2 -2
- package/dist/cli/domain/init-template/install-template.js +10 -9
- package/dist/cli/domain/init-template/scaffold.d.ts +2 -2
- package/dist/cli/domain/init-template/scaffold.js +7 -7
- package/dist/cli/domain/local.js +11 -10
- package/dist/cli/domain/mock.d.ts +1 -1
- package/dist/cli/domain/mock.js +21 -21
- package/dist/cli/domain/package-components.d.ts +1 -1
- package/dist/cli/domain/package-components.js +14 -17
- package/dist/cli/domain/registry.js +68 -81
- package/dist/cli/domain/watch.js +1 -1
- package/dist/cli/facade/clean.d.ts +10 -4
- package/dist/cli/facade/clean.js +38 -28
- package/dist/cli/facade/dev.d.ts +108 -15
- package/dist/cli/facade/dev.js +85 -99
- package/dist/cli/facade/init.d.ts +12 -5
- package/dist/cli/facade/init.js +22 -20
- package/dist/cli/facade/mock.d.ts +12 -5
- package/dist/cli/facade/mock.js +5 -6
- package/dist/cli/facade/package.d.ts +12 -5
- package/dist/cli/facade/package.js +30 -32
- package/dist/cli/facade/preview.d.ts +8 -3
- package/dist/cli/facade/preview.js +12 -10
- package/dist/cli/facade/publish.d.ts +16 -7
- package/dist/cli/facade/publish.js +94 -114
- package/dist/cli/facade/registry-add.d.ts +8 -3
- package/dist/cli/facade/registry-add.js +10 -9
- package/dist/cli/facade/registry-ls.d.ts +4 -1
- package/dist/cli/facade/registry-ls.js +19 -17
- package/dist/cli/facade/registry-remove.d.ts +8 -3
- package/dist/cli/facade/registry-remove.js +10 -9
- package/dist/cli/facade/registry.d.ts +4 -1
- package/dist/cli/facade/registry.js +6 -3
- package/dist/cli/index.js +3 -5
- package/dist/cli/programmatic-api.d.ts +1 -1
- package/dist/components/oc-client/_package/package.json +1 -1
- package/dist/components/oc-client/package.json +1 -1
- package/dist/registry/app-start.d.ts +2 -2
- package/dist/registry/app-start.js +20 -20
- package/dist/registry/domain/components-cache/components-list.d.ts +7 -6
- package/dist/registry/domain/components-cache/components-list.js +31 -45
- package/dist/registry/domain/components-cache/index.d.ts +6 -5
- package/dist/registry/domain/components-cache/index.js +47 -50
- package/dist/registry/domain/components-details.d.ts +5 -4
- package/dist/registry/domain/components-details.js +27 -38
- package/dist/registry/domain/extract-package.d.ts +2 -2
- package/dist/registry/domain/extract-package.js +9 -12
- package/dist/registry/domain/get-package-json-from-temp-dir.d.ts +1 -1
- package/dist/registry/domain/get-package-json-from-temp-dir.js +2 -2
- package/dist/registry/domain/nested-renderer.d.ts +7 -6
- package/dist/registry/domain/nested-renderer.js +36 -72
- package/dist/registry/domain/options-sanitiser.js +5 -3
- package/dist/registry/domain/plugins-initialiser.d.ts +3 -1
- package/dist/registry/domain/plugins-initialiser.js +29 -33
- package/dist/registry/domain/repository.js +78 -100
- package/dist/registry/domain/require-wrapper.js +1 -2
- package/dist/registry/domain/storage-adapter.d.ts +10 -0
- package/dist/registry/domain/storage-adapter.js +55 -0
- package/dist/registry/index.d.ts +2 -2
- package/dist/registry/index.js +15 -28
- package/dist/registry/middleware/index.d.ts +6 -2
- package/dist/registry/middleware/index.js +5 -1
- package/dist/registry/router.d.ts +2 -2
- package/dist/registry/router.js +0 -2
- package/dist/registry/routes/component-info.js +3 -2
- package/dist/registry/routes/component-preview.js +2 -1
- package/dist/registry/routes/components.js +1 -1
- package/dist/registry/routes/helpers/get-component-fallback.d.ts +2 -7
- package/dist/registry/routes/helpers/get-component.d.ts +5 -5
- package/dist/registry/routes/helpers/get-component.js +6 -5
- package/dist/registry/routes/helpers/is-url-discoverable.d.ts +2 -2
- package/dist/registry/routes/helpers/is-url-discoverable.js +15 -9
- package/dist/registry/routes/index.js +4 -3
- package/dist/registry/routes/publish.d.ts +1 -1
- package/dist/registry/routes/publish.js +32 -31
- package/dist/resources/settings.js +1 -1
- package/dist/types.d.ts +35 -43
- package/dist/utils/npm-utils.d.ts +6 -8
- package/dist/utils/npm-utils.js +20 -9
- package/dist/utils/put.d.ts +2 -1
- package/dist/utils/put.js +10 -29
- package/logintervals.md +1 -1
- package/package.json +6 -1
- package/src/cli/domain/clean.ts +10 -20
- package/src/cli/domain/get-components-by-dir.ts +12 -26
- package/src/cli/domain/get-mocked-plugins.ts +32 -26
- package/src/cli/domain/handle-dependencies/ensure-compiler-is-declared-as-devDependency.ts +8 -12
- package/src/cli/domain/handle-dependencies/get-compiler.ts +8 -11
- package/src/cli/domain/handle-dependencies/index.ts +55 -109
- package/src/cli/domain/handle-dependencies/install-compiler.ts +22 -15
- package/src/cli/domain/handle-dependencies/install-missing-dependencies.ts +19 -13
- package/src/cli/domain/handle-dependencies/link-missing-dependencies.ts +8 -16
- package/src/cli/domain/init-template/index.ts +13 -20
- package/src/cli/domain/init-template/install-template.ts +11 -12
- package/src/cli/domain/init-template/scaffold.ts +9 -12
- package/src/cli/domain/local.ts +19 -22
- package/src/cli/domain/mock.ts +32 -36
- package/src/cli/domain/package-components.ts +14 -25
- package/src/cli/domain/registry.ts +80 -116
- package/src/cli/domain/watch.ts +1 -1
- package/src/cli/facade/clean.ts +37 -37
- package/src/cli/facade/dev.ts +159 -182
- package/src/cli/facade/init.ts +36 -38
- package/src/cli/facade/mock.ts +11 -10
- package/src/cli/facade/package.ts +44 -49
- package/src/cli/facade/preview.ts +20 -18
- package/src/cli/facade/publish.ts +134 -172
- package/src/cli/facade/registry-add.ts +16 -15
- package/src/cli/facade/registry-ls.ts +27 -22
- package/src/cli/facade/registry-remove.ts +16 -15
- package/src/cli/facade/registry.ts +7 -5
- package/src/cli/index.ts +3 -5
- package/src/components/oc-client/_package/package.json +1 -1
- package/src/components/oc-client/package.json +1 -1
- package/src/globals.d.ts +38 -0
- package/src/registry/app-start.ts +27 -31
- package/src/registry/domain/components-cache/components-list.ts +45 -67
- package/src/registry/domain/components-cache/index.ts +55 -60
- package/src/registry/domain/components-details.ts +49 -75
- package/src/registry/domain/extract-package.ts +19 -27
- package/src/registry/domain/get-package-json-from-temp-dir.ts +3 -4
- package/src/registry/domain/nested-renderer.ts +64 -122
- package/src/registry/domain/options-sanitiser.ts +6 -3
- package/src/registry/domain/plugins-initialiser.ts +45 -49
- package/src/registry/domain/repository.ts +129 -235
- package/src/registry/domain/require-wrapper.ts +1 -2
- package/src/registry/domain/storage-adapter.ts +85 -0
- package/src/registry/index.ts +48 -79
- package/src/registry/middleware/index.ts +10 -2
- package/src/registry/router.ts +2 -10
- package/src/registry/routes/component-info.ts +4 -3
- package/src/registry/routes/component-preview.ts +3 -2
- package/src/registry/routes/components.ts +1 -1
- package/src/registry/routes/helpers/get-component-fallback.ts +3 -9
- package/src/registry/routes/helpers/get-component.ts +11 -9
- package/src/registry/routes/helpers/is-url-discoverable.ts +14 -15
- package/src/registry/routes/index.ts +18 -13
- package/src/registry/routes/publish.ts +31 -34
- package/src/resources/settings.ts +1 -1
- package/src/types.ts +63 -136
- package/src/utils/npm-utils.ts +38 -37
- package/src/utils/put.ts +15 -37
|
@@ -6,25 +6,25 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const resources_1 = __importDefault(require("../../../resources"));
|
|
9
|
-
function scaffold(options
|
|
9
|
+
async function scaffold(options) {
|
|
10
10
|
const { compiler, compilerPath, componentName, componentPath, templateType } = options;
|
|
11
11
|
const baseComponentPath = path_1.default.join(compilerPath, 'scaffold');
|
|
12
12
|
const baseComponentFiles = path_1.default.join(baseComponentPath, 'src');
|
|
13
|
-
const compilerPackage = fs_extra_1.default.
|
|
13
|
+
const compilerPackage = await fs_extra_1.default.readJson(path_1.default.join(compilerPath, 'package.json'));
|
|
14
14
|
try {
|
|
15
|
-
fs_extra_1.default.
|
|
16
|
-
const componentPackage = fs_extra_1.default.
|
|
15
|
+
await fs_extra_1.default.copy(baseComponentFiles, componentPath);
|
|
16
|
+
const componentPackage = await fs_extra_1.default.readJson(path_1.default.join(componentPath, 'package.json'));
|
|
17
17
|
componentPackage.name = componentName;
|
|
18
18
|
componentPackage.devDependencies[compiler] = compilerPackage.version;
|
|
19
|
-
fs_extra_1.default.
|
|
19
|
+
await fs_extra_1.default.writeJson(componentPath + '/package.json', componentPackage, {
|
|
20
20
|
spaces: 2
|
|
21
21
|
});
|
|
22
|
-
return
|
|
22
|
+
return { ok: true };
|
|
23
23
|
}
|
|
24
24
|
catch (error) {
|
|
25
25
|
const url = (compilerPackage.bugs && compilerPackage.bugs.url) ||
|
|
26
26
|
`the ${templateType} repo`;
|
|
27
|
-
|
|
27
|
+
throw resources_1.default.errors.cli.scaffoldError(url, String(error));
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
exports.default = scaffold;
|
package/dist/cli/domain/local.js
CHANGED
|
@@ -24,6 +24,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
25
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
26
26
|
const targz_1 = __importDefault(require("targz"));
|
|
27
|
+
const util_1 = require("util");
|
|
27
28
|
const clean = __importStar(require("./clean"));
|
|
28
29
|
const get_components_by_dir_1 = __importDefault(require("./get-components-by-dir"));
|
|
29
30
|
const init_template_1 = __importDefault(require("./init-template"));
|
|
@@ -35,11 +36,11 @@ const validator = __importStar(require("../../registry/domain/validators"));
|
|
|
35
36
|
function local() {
|
|
36
37
|
return {
|
|
37
38
|
clean,
|
|
38
|
-
cleanup(compressedPackagePath
|
|
39
|
-
return fs_extra_1.default.unlink(compressedPackagePath
|
|
39
|
+
cleanup(compressedPackagePath) {
|
|
40
|
+
return fs_extra_1.default.unlink(compressedPackagePath);
|
|
40
41
|
},
|
|
41
|
-
compress(input, output
|
|
42
|
-
return targz_1.default.compress({
|
|
42
|
+
compress(input, output) {
|
|
43
|
+
return (0, util_1.promisify)(targz_1.default.compress)({
|
|
43
44
|
src: input,
|
|
44
45
|
dest: output,
|
|
45
46
|
tar: {
|
|
@@ -49,14 +50,14 @@ function local() {
|
|
|
49
50
|
});
|
|
50
51
|
}
|
|
51
52
|
}
|
|
52
|
-
}
|
|
53
|
+
});
|
|
53
54
|
},
|
|
54
55
|
getComponentsByDir: (0, get_components_by_dir_1.default)(),
|
|
55
|
-
init(options
|
|
56
|
+
async init(options) {
|
|
56
57
|
const { componentName, logger } = options;
|
|
57
58
|
let { templateType } = options;
|
|
58
59
|
if (!validator.validateComponentName(componentName)) {
|
|
59
|
-
|
|
60
|
+
throw 'name not valid';
|
|
60
61
|
}
|
|
61
62
|
// LEGACY TEMPLATES WARNING
|
|
62
63
|
if ((0, is_template_legacy_1.default)(templateType)) {
|
|
@@ -65,13 +66,13 @@ function local() {
|
|
|
65
66
|
logger.warn(resources_1.default.messages.cli.legacyTemplateDeprecationWarning(legacyName, templateType));
|
|
66
67
|
}
|
|
67
68
|
try {
|
|
68
|
-
(0, init_template_1.default)(Object.assign(options, {
|
|
69
|
+
await (0, init_template_1.default)(Object.assign(options, {
|
|
69
70
|
templateType,
|
|
70
71
|
compiler: `${templateType}-compiler`
|
|
71
|
-
})
|
|
72
|
+
}));
|
|
72
73
|
}
|
|
73
74
|
catch (e) {
|
|
74
|
-
|
|
75
|
+
throw 'template type not valid';
|
|
75
76
|
}
|
|
76
77
|
},
|
|
77
78
|
mock: (0, mock_1.default)(),
|
package/dist/cli/domain/mock.js
CHANGED
|
@@ -7,27 +7,27 @@ const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const settings_1 = __importDefault(require("../../resources/settings"));
|
|
9
9
|
function mock() {
|
|
10
|
-
return function (params
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
});
|
|
10
|
+
return async function (params) {
|
|
11
|
+
const localConfig = await fs_extra_1.default
|
|
12
|
+
.readJson(settings_1.default.configFile.src)
|
|
13
|
+
.catch(() => ({}));
|
|
14
|
+
const mockType = params.targetType + 's';
|
|
15
|
+
if (!localConfig.mocks) {
|
|
16
|
+
localConfig.mocks = {};
|
|
17
|
+
}
|
|
18
|
+
if (!localConfig.mocks[mockType]) {
|
|
19
|
+
localConfig.mocks[mockType] = {};
|
|
20
|
+
}
|
|
21
|
+
let pluginType = 'static';
|
|
22
|
+
if (fs_extra_1.default.existsSync(path_1.default.resolve(params.targetValue.toString()))) {
|
|
23
|
+
pluginType = 'dynamic';
|
|
24
|
+
}
|
|
25
|
+
if (!localConfig.mocks[mockType][pluginType]) {
|
|
26
|
+
localConfig.mocks[mockType][pluginType] = {};
|
|
27
|
+
}
|
|
28
|
+
localConfig.mocks[mockType][pluginType][params.targetName] =
|
|
29
|
+
params.targetValue;
|
|
30
|
+
return fs_extra_1.default.writeJson(settings_1.default.configFile.src, localConfig, { spaces: 2 });
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
33
|
exports.default = mock;
|
|
@@ -5,5 +5,5 @@ interface PackageOptions {
|
|
|
5
5
|
verbose?: boolean;
|
|
6
6
|
production?: boolean;
|
|
7
7
|
}
|
|
8
|
-
declare const packageComponents: () => (options: PackageOptions
|
|
8
|
+
declare const packageComponents: () => (options: PackageOptions) => Promise<Component>;
|
|
9
9
|
export default packageComponents;
|
|
@@ -23,10 +23,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
23
23
|
};
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
25
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
26
|
+
const util_1 = require("util");
|
|
26
27
|
const path_1 = __importDefault(require("path"));
|
|
27
28
|
const require_template_1 = __importDefault(require("./handle-dependencies/require-template"));
|
|
28
29
|
const validator = __importStar(require("../../registry/domain/validators"));
|
|
29
|
-
const packageComponents = () => (options
|
|
30
|
+
const packageComponents = () => async (options) => {
|
|
30
31
|
const production = options.production;
|
|
31
32
|
const componentPath = options.componentPath;
|
|
32
33
|
const minify = options.minify === true;
|
|
@@ -35,16 +36,16 @@ const packageComponents = () => (options, callback) => {
|
|
|
35
36
|
const componentPackagePath = path_1.default.join(componentPath, 'package.json');
|
|
36
37
|
const ocPackagePath = path_1.default.join(__dirname, '../../../package.json');
|
|
37
38
|
if (!fs_extra_1.default.existsSync(componentPackagePath)) {
|
|
38
|
-
|
|
39
|
+
throw new Error('component does not contain package.json');
|
|
39
40
|
}
|
|
40
41
|
else if (!fs_extra_1.default.existsSync(ocPackagePath)) {
|
|
41
|
-
|
|
42
|
+
throw new Error('error resolving oc internal dependencies');
|
|
42
43
|
}
|
|
43
|
-
fs_extra_1.default.
|
|
44
|
-
const componentPackage = fs_extra_1.default.
|
|
45
|
-
const ocPackage = fs_extra_1.default.
|
|
44
|
+
await fs_extra_1.default.emptyDir(publishPath);
|
|
45
|
+
const componentPackage = await fs_extra_1.default.readJson(componentPackagePath);
|
|
46
|
+
const ocPackage = await fs_extra_1.default.readJson(ocPackagePath);
|
|
46
47
|
if (!validator.validateComponentName(componentPackage.name)) {
|
|
47
|
-
|
|
48
|
+
throw new Error('name not valid');
|
|
48
49
|
}
|
|
49
50
|
const type = componentPackage.oc.files.template.type;
|
|
50
51
|
const compileOptions = {
|
|
@@ -56,15 +57,11 @@ const packageComponents = () => (options, callback) => {
|
|
|
56
57
|
verbose,
|
|
57
58
|
production
|
|
58
59
|
};
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
catch (err) {
|
|
67
|
-
return callback(err, undefined);
|
|
68
|
-
}
|
|
60
|
+
const ocTemplate = (0, require_template_1.default)(type, {
|
|
61
|
+
compiler: true,
|
|
62
|
+
componentPath
|
|
63
|
+
});
|
|
64
|
+
const compile = (0, util_1.promisify)(ocTemplate.compile);
|
|
65
|
+
return compile(compileOptions);
|
|
69
66
|
};
|
|
70
67
|
exports.default = packageComponents;
|
|
@@ -24,7 +24,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
25
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
26
26
|
const path_1 = __importDefault(require("path"));
|
|
27
|
-
const
|
|
27
|
+
const got_1 = __importDefault(require("got"));
|
|
28
28
|
const lodash_1 = __importDefault(require("lodash"));
|
|
29
29
|
const put_1 = __importDefault(require("../../utils/put"));
|
|
30
30
|
const settings_1 = __importDefault(require("../../resources/settings"));
|
|
@@ -40,109 +40,96 @@ function registry(opts = {}) {
|
|
|
40
40
|
'user-agent': `oc-cli-${getOcVersion()}/${process.version}-${process.platform}-${process.arch}`
|
|
41
41
|
};
|
|
42
42
|
return {
|
|
43
|
-
add(registry
|
|
43
|
+
async add(registry) {
|
|
44
44
|
if (registry.slice(registry.length - 1) !== '/') {
|
|
45
45
|
registry += '/';
|
|
46
46
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
json
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
47
|
+
try {
|
|
48
|
+
const apiResponse = await (0, got_1.default)(registry, {
|
|
49
|
+
headers: requestsHeaders
|
|
50
|
+
}).json();
|
|
51
|
+
if (!apiResponse)
|
|
52
|
+
throw 'oc registry not available';
|
|
53
|
+
if (apiResponse.type !== 'oc-registry')
|
|
54
|
+
throw 'not a valid oc registry';
|
|
55
|
+
const res = await fs_extra_1.default
|
|
56
|
+
.readJson(settings_1.default.configFile.src)
|
|
57
|
+
.catch(() => ({}));
|
|
58
|
+
if (!res.registries) {
|
|
59
|
+
res.registries = [];
|
|
54
60
|
}
|
|
55
|
-
|
|
56
|
-
|
|
61
|
+
if (!lodash_1.default.includes(res.registries, registry)) {
|
|
62
|
+
res.registries.push(registry);
|
|
57
63
|
}
|
|
58
|
-
fs_extra_1.default.
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
res.registries = [];
|
|
64
|
-
}
|
|
65
|
-
if (!lodash_1.default.includes(res.registries, registry)) {
|
|
66
|
-
res.registries.push(registry);
|
|
67
|
-
}
|
|
68
|
-
fs_extra_1.default.writeJson(settings_1.default.configFile.src, res, callback);
|
|
69
|
-
});
|
|
70
|
-
});
|
|
64
|
+
return fs_extra_1.default.writeJson(settings_1.default.configFile.src, res);
|
|
65
|
+
}
|
|
66
|
+
catch (err) {
|
|
67
|
+
throw 'oc registry not available';
|
|
68
|
+
}
|
|
71
69
|
},
|
|
72
|
-
get(
|
|
70
|
+
async get() {
|
|
73
71
|
if (opts.registry) {
|
|
74
|
-
return
|
|
72
|
+
return [opts.registry];
|
|
73
|
+
}
|
|
74
|
+
try {
|
|
75
|
+
const res = await fs_extra_1.default.readJson(settings_1.default.configFile.src);
|
|
76
|
+
if (!res.registries || res.registries.length === 0)
|
|
77
|
+
throw 'No oc registries';
|
|
78
|
+
return res.registries;
|
|
79
|
+
}
|
|
80
|
+
catch (err) {
|
|
81
|
+
throw 'No oc registries';
|
|
75
82
|
}
|
|
76
|
-
fs_extra_1.default.readJson(settings_1.default.configFile.src, (err, res) => {
|
|
77
|
-
if (err || !res.registries || res.registries.length === 0) {
|
|
78
|
-
return callback('No oc registries', undefined);
|
|
79
|
-
}
|
|
80
|
-
return callback(null, res.registries);
|
|
81
|
-
});
|
|
82
83
|
},
|
|
83
|
-
getApiComponentByHref(href
|
|
84
|
-
(0,
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
json: true
|
|
88
|
-
}, callback);
|
|
84
|
+
getApiComponentByHref(href) {
|
|
85
|
+
return (0, got_1.default)(href + settings_1.default.registry.componentInfoPath, {
|
|
86
|
+
headers: requestsHeaders
|
|
87
|
+
}).json();
|
|
89
88
|
},
|
|
90
|
-
getComponentPreviewUrlByUrl(componentHref
|
|
91
|
-
(0,
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
json: true
|
|
95
|
-
}, (err, res) => {
|
|
96
|
-
if (err) {
|
|
97
|
-
return callback(err, undefined);
|
|
98
|
-
}
|
|
99
|
-
const parsed = urlParser.parse(res);
|
|
100
|
-
callback(null, urlBuilder.componentPreview(parsed, parsed.registryUrl));
|
|
101
|
-
});
|
|
89
|
+
async getComponentPreviewUrlByUrl(componentHref) {
|
|
90
|
+
const res = await (0, got_1.default)(componentHref, { headers: requestsHeaders }).json();
|
|
91
|
+
const parsed = urlParser.parse(res);
|
|
92
|
+
return urlBuilder.componentPreview(parsed, parsed.registryUrl);
|
|
102
93
|
},
|
|
103
|
-
putComponent(options
|
|
94
|
+
async putComponent(options) {
|
|
104
95
|
if (!!options.username && !!options.password) {
|
|
105
96
|
requestsHeaders = Object.assign(requestsHeaders, {
|
|
106
97
|
Authorization: 'Basic ' +
|
|
107
98
|
Buffer.from(options.username + ':' + options.password).toString('base64')
|
|
108
99
|
});
|
|
109
100
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
if (!!parsedError.code && parsedError.code === 'ECONNREFUSED') {
|
|
120
|
-
err = 'Connection to registry has not been established';
|
|
121
|
-
}
|
|
122
|
-
else if (parsedError.code !== 'cli_version_not_valid' &&
|
|
123
|
-
parsedError.code !== 'node_version_not_valid' &&
|
|
124
|
-
!!parsedError.error) {
|
|
125
|
-
err = parsedError.error;
|
|
101
|
+
try {
|
|
102
|
+
await (0, put_1.default)(options.route, options.path, requestsHeaders);
|
|
103
|
+
}
|
|
104
|
+
catch (err) {
|
|
105
|
+
let parsedError = err;
|
|
106
|
+
let errMsg = '';
|
|
107
|
+
if (!lodash_1.default.isObject(err)) {
|
|
108
|
+
try {
|
|
109
|
+
parsedError = JSON.parse(String(err));
|
|
126
110
|
}
|
|
127
|
-
|
|
111
|
+
catch (er) { }
|
|
112
|
+
}
|
|
113
|
+
if (!!parsedError.code && parsedError.code === 'ECONNREFUSED') {
|
|
114
|
+
errMsg = 'Connection to registry has not been established';
|
|
115
|
+
}
|
|
116
|
+
else if (parsedError.code !== 'cli_version_not_valid' &&
|
|
117
|
+
parsedError.code !== 'node_version_not_valid' &&
|
|
118
|
+
!!parsedError.error) {
|
|
119
|
+
errMsg = parsedError.error;
|
|
128
120
|
}
|
|
129
|
-
|
|
130
|
-
}
|
|
121
|
+
throw errMsg;
|
|
122
|
+
}
|
|
131
123
|
},
|
|
132
|
-
remove(registry
|
|
124
|
+
async remove(registry) {
|
|
133
125
|
if (registry.slice(registry.length - 1) !== '/') {
|
|
134
126
|
registry += '/';
|
|
135
127
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
res.registries = [];
|
|
142
|
-
}
|
|
143
|
-
res.registries = lodash_1.default.without(res.registries, registry);
|
|
144
|
-
fs_extra_1.default.writeJson(settings_1.default.configFile.src, res, callback);
|
|
145
|
-
});
|
|
128
|
+
const res = await fs_extra_1.default
|
|
129
|
+
.readJson(settings_1.default.configFile.src)
|
|
130
|
+
.catch(() => ({ registries: [] }));
|
|
131
|
+
res.registries = lodash_1.default.without(res.registries, registry);
|
|
132
|
+
await fs_extra_1.default.writeJson(settings_1.default.configFile.src, res);
|
|
146
133
|
}
|
|
147
134
|
};
|
|
148
135
|
}
|
package/dist/cli/domain/watch.js
CHANGED
|
@@ -11,7 +11,7 @@ function watch(dirs, baseDir, changed) {
|
|
|
11
11
|
ignored: settings_1.default.filesToIgnoreOnDevWatch,
|
|
12
12
|
persistent: true,
|
|
13
13
|
ignoreInitial: true,
|
|
14
|
-
usePolling:
|
|
14
|
+
usePolling: true
|
|
15
15
|
});
|
|
16
16
|
const onChange = (fileName) => {
|
|
17
17
|
const componentDir = dirs.find(dir => Boolean(fileName.match(escapeRegularExpression(dir + path_1.default.sep))));
|
|
@@ -3,8 +3,14 @@ import { Logger } from '../logger';
|
|
|
3
3
|
declare const clean: ({ local: { clean: { fetchList, remove } }, logger }: {
|
|
4
4
|
local: Local;
|
|
5
5
|
logger: Logger;
|
|
6
|
-
}) =>
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
}) => {
|
|
7
|
+
(opts: {
|
|
8
|
+
dirPath: string;
|
|
9
|
+
yes: boolean;
|
|
10
|
+
}): Promise<void>;
|
|
11
|
+
(arguments__0: {
|
|
12
|
+
dirPath: string;
|
|
13
|
+
yes: boolean;
|
|
14
|
+
}, arguments__1: (error: unknown, value: void) => void): void;
|
|
15
|
+
};
|
|
10
16
|
export default clean;
|
package/dist/cli/facade/clean.js
CHANGED
|
@@ -4,45 +4,55 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const read_1 = __importDefault(require("read"));
|
|
7
|
+
const universalify_1 = require("universalify");
|
|
8
|
+
const util_1 = require("util");
|
|
7
9
|
const index_1 = __importDefault(require("../../resources/index"));
|
|
10
|
+
const read = (0, util_1.promisify)(read_1.default);
|
|
8
11
|
const clean = ({ local: { clean: { fetchList, remove } }, logger }) => {
|
|
9
12
|
const { cleanAlreadyClean, cleanList, cleanPrompt, cleanPromptDefault, cleanSuccess } = index_1.default.messages.cli;
|
|
10
|
-
const prompt =
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
const prompt = async () => {
|
|
14
|
+
try {
|
|
15
|
+
const result = await read({
|
|
16
|
+
prompt: cleanPrompt,
|
|
17
|
+
default: cleanPromptDefault
|
|
18
|
+
});
|
|
19
|
+
const lowered = result.toLowerCase().trim();
|
|
20
|
+
return lowered === 'y' || lowered === 'yes';
|
|
21
|
+
}
|
|
22
|
+
catch (err) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
const removeFolders = async (list) => {
|
|
27
|
+
try {
|
|
28
|
+
await remove(list);
|
|
29
|
+
logger.ok(cleanSuccess);
|
|
30
|
+
}
|
|
31
|
+
catch (err) {
|
|
19
32
|
logger.err(index_1.default.errors.cli.cleanRemoveError(String(err)));
|
|
20
|
-
|
|
33
|
+
throw err;
|
|
21
34
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
fetchList(opts.dirPath, (err, list) => {
|
|
27
|
-
if (err) {
|
|
28
|
-
logger.err(index_1.default.errors.generic(String(err)));
|
|
29
|
-
return callback(err);
|
|
30
|
-
}
|
|
35
|
+
};
|
|
36
|
+
return (0, universalify_1.fromPromise)(async (opts) => {
|
|
37
|
+
try {
|
|
38
|
+
const list = await fetchList(opts.dirPath);
|
|
31
39
|
if (list.length === 0) {
|
|
32
40
|
logger.ok(cleanAlreadyClean);
|
|
33
|
-
return
|
|
41
|
+
return;
|
|
34
42
|
}
|
|
35
43
|
logger.warn(cleanList(list));
|
|
36
44
|
const shouldConfirm = !opts.yes;
|
|
37
45
|
if (shouldConfirm) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return removeFolders(list, callback);
|
|
42
|
-
});
|
|
46
|
+
const confirmed = await prompt();
|
|
47
|
+
if (!confirmed)
|
|
48
|
+
return;
|
|
43
49
|
}
|
|
44
|
-
removeFolders(list
|
|
45
|
-
}
|
|
46
|
-
|
|
50
|
+
await removeFolders(list);
|
|
51
|
+
}
|
|
52
|
+
catch (err) {
|
|
53
|
+
logger.err(index_1.default.errors.generic(String(err)));
|
|
54
|
+
throw err;
|
|
55
|
+
}
|
|
56
|
+
});
|
|
47
57
|
};
|
|
48
58
|
exports.default = clean;
|
package/dist/cli/facade/dev.d.ts
CHANGED
|
@@ -1,21 +1,114 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="express" />
|
|
3
|
+
/// <reference types="node/http" />
|
|
4
|
+
/// <reference types="got/dist/source/core/utils/timed-out" />
|
|
3
5
|
import { Logger } from '../logger';
|
|
4
6
|
import { Local } from '../../types';
|
|
5
|
-
declare type Registry = ReturnType<typeof oc.Registry>;
|
|
6
7
|
declare const dev: ({ local, logger }: {
|
|
7
8
|
logger: Logger;
|
|
8
9
|
local: Local;
|
|
9
|
-
}) =>
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
10
|
+
}) => {
|
|
11
|
+
(opts: {
|
|
12
|
+
prefix: string;
|
|
13
|
+
dirPath: string;
|
|
14
|
+
port?: number | undefined;
|
|
15
|
+
baseUrl: string;
|
|
16
|
+
fallbackRegistryUrl: string;
|
|
17
|
+
hotReloading?: boolean | undefined;
|
|
18
|
+
components?: string[] | undefined;
|
|
19
|
+
watch?: boolean | undefined;
|
|
20
|
+
verbose?: boolean | undefined;
|
|
21
|
+
production?: boolean | undefined;
|
|
22
|
+
}): Promise<{
|
|
23
|
+
close: (callback: (err?: string | Error | undefined) => void) => void | import("http").Server;
|
|
24
|
+
on: <T extends keyof {
|
|
25
|
+
error: {
|
|
26
|
+
code: string;
|
|
27
|
+
message: string;
|
|
28
|
+
};
|
|
29
|
+
start: unknown;
|
|
30
|
+
'cache-poll': number;
|
|
31
|
+
request: import("../../registry/domain/events-handler").RequestData;
|
|
32
|
+
'component-retrieved': {
|
|
33
|
+
headers: import("http").IncomingHttpHeaders;
|
|
34
|
+
name: string;
|
|
35
|
+
parameters: import("http").IncomingHttpHeaders;
|
|
36
|
+
requestVersion: string;
|
|
37
|
+
duration: number;
|
|
38
|
+
};
|
|
39
|
+
}>(eventName: T, listener: (data: {
|
|
40
|
+
error: {
|
|
41
|
+
code: string;
|
|
42
|
+
message: string;
|
|
43
|
+
};
|
|
44
|
+
start: unknown;
|
|
45
|
+
'cache-poll': number;
|
|
46
|
+
request: import("../../registry/domain/events-handler").RequestData;
|
|
47
|
+
'component-retrieved': {
|
|
48
|
+
headers: import("http").IncomingHttpHeaders;
|
|
49
|
+
name: string;
|
|
50
|
+
parameters: import("http").IncomingHttpHeaders;
|
|
51
|
+
requestVersion: string;
|
|
52
|
+
duration: number;
|
|
53
|
+
};
|
|
54
|
+
}[T]) => void) => void;
|
|
55
|
+
register: (plugin: Omit<import("../../types").Plugin, "callback">, callback?: ((...args: any[]) => void) | undefined) => void;
|
|
56
|
+
start: (callback: (err: unknown, data: {
|
|
57
|
+
app: import("express").Express;
|
|
58
|
+
server: import("http").Server;
|
|
59
|
+
}) => void) => Promise<void>;
|
|
60
|
+
app: import("express").Express;
|
|
61
|
+
}>;
|
|
62
|
+
(arguments__0: {
|
|
63
|
+
prefix: string;
|
|
64
|
+
dirPath: string;
|
|
65
|
+
port?: number | undefined;
|
|
66
|
+
baseUrl: string;
|
|
67
|
+
fallbackRegistryUrl: string;
|
|
68
|
+
hotReloading?: boolean | undefined;
|
|
69
|
+
components?: string[] | undefined;
|
|
70
|
+
watch?: boolean | undefined;
|
|
71
|
+
verbose?: boolean | undefined;
|
|
72
|
+
production?: boolean | undefined;
|
|
73
|
+
}, arguments__1: (error: unknown, value: {
|
|
74
|
+
close: (callback: (err?: string | Error | undefined) => void) => void | import("http").Server;
|
|
75
|
+
on: <T extends keyof {
|
|
76
|
+
error: {
|
|
77
|
+
code: string;
|
|
78
|
+
message: string;
|
|
79
|
+
};
|
|
80
|
+
start: unknown;
|
|
81
|
+
'cache-poll': number;
|
|
82
|
+
request: import("../../registry/domain/events-handler").RequestData;
|
|
83
|
+
'component-retrieved': {
|
|
84
|
+
headers: import("http").IncomingHttpHeaders;
|
|
85
|
+
name: string;
|
|
86
|
+
parameters: import("http").IncomingHttpHeaders;
|
|
87
|
+
requestVersion: string;
|
|
88
|
+
duration: number;
|
|
89
|
+
};
|
|
90
|
+
}>(eventName: T, listener: (data: {
|
|
91
|
+
error: {
|
|
92
|
+
code: string;
|
|
93
|
+
message: string;
|
|
94
|
+
};
|
|
95
|
+
start: unknown;
|
|
96
|
+
'cache-poll': number;
|
|
97
|
+
request: import("../../registry/domain/events-handler").RequestData;
|
|
98
|
+
'component-retrieved': {
|
|
99
|
+
headers: import("http").IncomingHttpHeaders;
|
|
100
|
+
name: string;
|
|
101
|
+
parameters: import("http").IncomingHttpHeaders;
|
|
102
|
+
requestVersion: string;
|
|
103
|
+
duration: number;
|
|
104
|
+
};
|
|
105
|
+
}[T]) => void) => void;
|
|
106
|
+
register: (plugin: Omit<import("../../types").Plugin, "callback">, callback?: ((...args: any[]) => void) | undefined) => void;
|
|
107
|
+
start: (callback: (err: unknown, data: {
|
|
108
|
+
app: import("express").Express;
|
|
109
|
+
server: import("http").Server;
|
|
110
|
+
}) => void) => Promise<void>;
|
|
111
|
+
app: import("express").Express;
|
|
112
|
+
}) => void): void;
|
|
113
|
+
};
|
|
21
114
|
export default dev;
|