oc 0.50.26 → 0.50.28
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/CHANGELOG.md +11 -0
- package/dist/cli/commands.d.ts +19 -0
- package/dist/cli/commands.js +19 -0
- package/dist/cli/domain/get-mocked-plugins.d.ts +1 -1
- package/dist/cli/domain/get-mocked-plugins.js +4 -22
- package/dist/cli/domain/ocConfig.d.ts +18 -1
- package/dist/cli/domain/ocConfig.js +26 -5
- package/dist/cli/domain/registry.d.ts +4 -0
- package/dist/cli/domain/registry.js +41 -0
- package/dist/cli/facade/dev.js +30 -22
- package/dist/cli/facade/validate.d.ts +20 -0
- package/dist/cli/facade/validate.js +127 -0
- package/dist/cli/index.js +3 -1
- package/dist/components/oc-client/_package/package.json +4 -4
- package/dist/components/oc-client/_package/server.js +1 -1
- package/dist/components/oc-client/_package/src/oc-client.js +2 -2
- package/dist/components/oc-client/_package/src/oc-client.min.js +1 -1
- package/dist/components/oc-client/package.json +1 -1
- package/dist/components/oc-client/src/oc-client.js +2 -2
- package/dist/components/oc-client/src/oc-client.min.js +1 -1
- package/dist/registry/domain/options-sanitiser.d.ts +1 -0
- package/dist/registry/domain/options-sanitiser.js +55 -1
- package/dist/registry/domain/validators/registry-configuration.js +4 -2
- package/dist/registry/index.js +1 -1
- package/dist/registry/router.js +15 -3
- package/dist/registry/routes/component-info.js +9 -2
- package/dist/registry/routes/component-preview.js +2 -1
- package/dist/registry/routes/component.js +7 -0
- package/dist/registry/routes/components.js +14 -0
- package/dist/registry/routes/helpers/format-error-stack.d.ts +7 -0
- package/dist/registry/routes/helpers/format-error-stack.js +172 -0
- package/dist/registry/routes/helpers/get-component.d.ts +7 -1
- package/dist/registry/routes/helpers/get-component.js +37 -5
- package/dist/registry/routes/validate.d.ts +2 -0
- package/dist/registry/routes/validate.js +153 -0
- package/dist/registry/views/info.js +10 -1
- package/dist/registry/views/partials/component-author.js +1 -1
- package/dist/registry/views/partials/component-parameters.d.ts +2 -1
- package/dist/registry/views/partials/component-parameters.js +20 -3
- package/dist/registry/views/partials/component-versions.js +1 -1
- package/dist/registry/views/partials/components-dependencies.js +1 -1
- package/dist/registry/views/partials/components-list.js +2 -2
- package/dist/registry/views/partials/components-templates.js +2 -2
- package/dist/registry/views/partials/layout.js +1 -1
- package/dist/registry/views/partials/property.js +2 -2
- package/dist/registry/views/preview.d.ts +1 -0
- package/dist/registry/views/preview.js +256 -3
- package/dist/registry/views/static/info.d.ts +1 -1
- package/dist/registry/views/static/info.js +62 -0
- package/dist/registry/views/static/style.d.ts +1 -1
- package/dist/registry/views/static/style.js +1 -1
- package/dist/resources/index.d.ts +3 -1
- package/dist/resources/index.js +3 -1
- package/dist/types.d.ts +14 -1
- package/logintervals.md +1 -1
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
## Change Log
|
|
2
2
|
|
|
3
|
+
### v0.50.28
|
|
4
|
+
- [#1442](https://github.com/opencomponents/oc/pull/1442) add routes option in oc.json
|
|
5
|
+
- [#1441](https://github.com/opencomponents/oc/pull/1441) add preload option
|
|
6
|
+
- [#1440](https://github.com/opencomponents/oc/pull/1440) validate command
|
|
7
|
+
- [#1439](https://github.com/opencomponents/oc/pull/1439) add editable fields
|
|
8
|
+
- [#1436](https://github.com/opencomponents/oc/pull/1436) add preview overlay
|
|
9
|
+
- [#1438](https://github.com/opencomponents/oc/pull/1438) feat: add setCookie functionality to component context
|
|
10
|
+
|
|
11
|
+
### v0.50.27
|
|
12
|
+
- [#1435](https://github.com/opencomponents/oc/pull/1435) Fix loading info correctly
|
|
13
|
+
|
|
3
14
|
### v0.50.26
|
|
4
15
|
- [#1434](https://github.com/opencomponents/oc/pull/1434) add fallback client option and new oc.json section for dev
|
|
5
16
|
|
package/dist/cli/commands.d.ts
CHANGED
|
@@ -132,6 +132,25 @@ declare const _default: {
|
|
|
132
132
|
description: string;
|
|
133
133
|
usage: string;
|
|
134
134
|
};
|
|
135
|
+
validate: {
|
|
136
|
+
cmd: string;
|
|
137
|
+
example: {
|
|
138
|
+
cmd: string;
|
|
139
|
+
};
|
|
140
|
+
options: {
|
|
141
|
+
skipPackage: {
|
|
142
|
+
boolean: boolean;
|
|
143
|
+
description: string;
|
|
144
|
+
default: boolean;
|
|
145
|
+
};
|
|
146
|
+
registries: {
|
|
147
|
+
array: boolean;
|
|
148
|
+
description: string;
|
|
149
|
+
};
|
|
150
|
+
};
|
|
151
|
+
description: string;
|
|
152
|
+
usage: string;
|
|
153
|
+
};
|
|
135
154
|
registry: {
|
|
136
155
|
cmd: string;
|
|
137
156
|
description: string;
|
package/dist/cli/commands.js
CHANGED
|
@@ -132,6 +132,25 @@ exports.default = {
|
|
|
132
132
|
description: 'Publish a component',
|
|
133
133
|
usage: 'Usage: $0 publish <componentPath>'
|
|
134
134
|
},
|
|
135
|
+
validate: {
|
|
136
|
+
cmd: 'validate <componentPath>',
|
|
137
|
+
example: {
|
|
138
|
+
cmd: '$0 validate my-new-component/'
|
|
139
|
+
},
|
|
140
|
+
options: {
|
|
141
|
+
skipPackage: {
|
|
142
|
+
boolean: true,
|
|
143
|
+
description: 'Skip packaging step and validate existing package.json',
|
|
144
|
+
default: false
|
|
145
|
+
},
|
|
146
|
+
registries: {
|
|
147
|
+
array: true,
|
|
148
|
+
description: 'List of registries to validate against. This setting will take precedence over oc.json file'
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
description: 'Validate a component against registry requirements without publishing',
|
|
152
|
+
usage: 'Usage: $0 validate <componentPath>'
|
|
153
|
+
},
|
|
135
154
|
registry: {
|
|
136
155
|
cmd: 'registry <command>',
|
|
137
156
|
description: 'Manage oc registries in the current project',
|
|
@@ -7,5 +7,5 @@ interface PluginMock {
|
|
|
7
7
|
execute: (...args: unknown[]) => unknown;
|
|
8
8
|
};
|
|
9
9
|
}
|
|
10
|
-
export default function getMockedPlugins(logger: Logger, componentsDir
|
|
10
|
+
export default function getMockedPlugins(logger: Logger, componentsDir?: string): PluginMock[];
|
|
11
11
|
export {};
|
|
@@ -5,9 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.default = getMockedPlugins;
|
|
7
7
|
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
-
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
9
8
|
const resources_1 = __importDefault(require("../../resources/"));
|
|
10
|
-
const settings_1 = __importDefault(require("../../resources/settings"));
|
|
11
9
|
const ocConfig_1 = require("./ocConfig");
|
|
12
10
|
const isMockValid = (plugin) => {
|
|
13
11
|
const isFunction = typeof plugin === 'function';
|
|
@@ -57,29 +55,13 @@ const registerDynamicMocks = (ocJsonLocation, mocks, logger) => Object.entries(m
|
|
|
57
55
|
};
|
|
58
56
|
})
|
|
59
57
|
.filter((pluginMock) => !!pluginMock);
|
|
60
|
-
const findPath = (pathToResolve, fileName) => {
|
|
61
|
-
const rootDir = fs_extra_1.default.realpathSync('.');
|
|
62
|
-
const fileToResolve = node_path_1.default.join(pathToResolve, fileName);
|
|
63
|
-
if (!fs_extra_1.default.existsSync(fileToResolve)) {
|
|
64
|
-
if (pathToResolve === rootDir) {
|
|
65
|
-
return undefined;
|
|
66
|
-
}
|
|
67
|
-
const getParent = (pathToResolve) => pathToResolve.split('/').slice(0, -1).join('/');
|
|
68
|
-
const parentDir = pathToResolve ? getParent(pathToResolve) : rootDir;
|
|
69
|
-
return findPath(parentDir, fileName);
|
|
70
|
-
}
|
|
71
|
-
return fileToResolve;
|
|
72
|
-
};
|
|
73
58
|
function getMockedPlugins(logger, componentsDir) {
|
|
74
59
|
componentsDir = node_path_1.default.resolve(componentsDir || '.');
|
|
75
60
|
let plugins = [];
|
|
76
|
-
const
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
const content = (0, ocConfig_1.getOcConfig)(ocJsonPath);
|
|
82
|
-
const ocJsonLocation = ocJsonPath.slice(0, -ocJsonFileName.length);
|
|
61
|
+
const content = (0, ocConfig_1.getOcConfig)(componentsDir);
|
|
62
|
+
const ocJsonLocation = content.sourcePath
|
|
63
|
+
? node_path_1.default.dirname(content.sourcePath)
|
|
64
|
+
: componentsDir;
|
|
83
65
|
if (!content.development?.plugins) {
|
|
84
66
|
return plugins;
|
|
85
67
|
}
|
|
@@ -5,6 +5,16 @@ export interface OpenComponentsConfig {
|
|
|
5
5
|
registries?: string[];
|
|
6
6
|
/** Development-specific configuration settings */
|
|
7
7
|
development?: {
|
|
8
|
+
/** Additional Express routes to mount on the registry application */
|
|
9
|
+
routes?: Array<{
|
|
10
|
+
route: string;
|
|
11
|
+
method: string;
|
|
12
|
+
handler: string;
|
|
13
|
+
}>;
|
|
14
|
+
/** JavaScript code to be included in the preview HTML's <head> section.
|
|
15
|
+
* Can be either a filepath to a JS script or inline JavaScript code.
|
|
16
|
+
*/
|
|
17
|
+
preload?: string;
|
|
8
18
|
/** Fallback configuration for when components cannot be found locally */
|
|
9
19
|
fallback?: {
|
|
10
20
|
/** URL of the fallback registry to use when components cannot be found locally */
|
|
@@ -32,8 +42,15 @@ export interface OpenComponentsConfig {
|
|
|
32
42
|
};
|
|
33
43
|
}
|
|
34
44
|
type ParsedConfig = {
|
|
45
|
+
sourcePath?: string;
|
|
35
46
|
registries: string[];
|
|
36
47
|
development: {
|
|
48
|
+
routes?: Array<{
|
|
49
|
+
route: string;
|
|
50
|
+
method: string;
|
|
51
|
+
handler: string;
|
|
52
|
+
}>;
|
|
53
|
+
preload?: string;
|
|
37
54
|
plugins: {
|
|
38
55
|
dynamic?: Record<string, string>;
|
|
39
56
|
static?: Record<string, string>;
|
|
@@ -44,6 +61,6 @@ type ParsedConfig = {
|
|
|
44
61
|
};
|
|
45
62
|
};
|
|
46
63
|
};
|
|
47
|
-
export declare function getOcConfig(
|
|
64
|
+
export declare function getOcConfig(folder?: string): ParsedConfig;
|
|
48
65
|
export declare function setOcConfig(config: ParsedConfig, path?: string): void;
|
|
49
66
|
export {};
|
|
@@ -6,7 +6,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.getOcConfig = getOcConfig;
|
|
7
7
|
exports.setOcConfig = setOcConfig;
|
|
8
8
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
9
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
9
10
|
const settings_1 = __importDefault(require("../../resources/settings"));
|
|
11
|
+
const findPath = (pathToResolve, fileName) => {
|
|
12
|
+
const rootDir = node_fs_1.default.realpathSync('.');
|
|
13
|
+
const fileToResolve = node_path_1.default.join(pathToResolve, fileName);
|
|
14
|
+
if (!node_fs_1.default.existsSync(fileToResolve)) {
|
|
15
|
+
if (pathToResolve === rootDir) {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
const getParent = (pathToResolve) => pathToResolve.split('/').slice(0, -1).join('/');
|
|
19
|
+
const parentDir = pathToResolve ? getParent(pathToResolve) : rootDir;
|
|
20
|
+
return findPath(parentDir, fileName);
|
|
21
|
+
}
|
|
22
|
+
return fileToResolve;
|
|
23
|
+
};
|
|
10
24
|
function parseConfig(config) {
|
|
11
25
|
const plugins = {
|
|
12
26
|
...(config.mocks?.plugins || {}),
|
|
@@ -16,16 +30,22 @@ function parseConfig(config) {
|
|
|
16
30
|
...config,
|
|
17
31
|
registries: config.registries || [],
|
|
18
32
|
development: {
|
|
33
|
+
preload: config.development?.preload,
|
|
19
34
|
plugins,
|
|
20
|
-
fallback: config.development?.fallback
|
|
35
|
+
fallback: config.development?.fallback,
|
|
36
|
+
routes: config.development?.routes
|
|
21
37
|
}
|
|
22
38
|
};
|
|
23
39
|
return parsedConfig;
|
|
24
40
|
}
|
|
25
|
-
function getOcConfig(
|
|
41
|
+
function getOcConfig(folder) {
|
|
42
|
+
const configPath = folder
|
|
43
|
+
? findPath(folder, settings_1.default.configFile.src.replace('./', '')) ||
|
|
44
|
+
settings_1.default.configFile.src
|
|
45
|
+
: settings_1.default.configFile.src;
|
|
26
46
|
try {
|
|
27
|
-
const config = JSON.parse(node_fs_1.default.readFileSync(
|
|
28
|
-
return parseConfig(config);
|
|
47
|
+
const config = JSON.parse(node_fs_1.default.readFileSync(configPath, 'utf8'));
|
|
48
|
+
return { ...parseConfig(config), sourcePath: configPath };
|
|
29
49
|
}
|
|
30
50
|
catch {
|
|
31
51
|
return {
|
|
@@ -37,5 +57,6 @@ function getOcConfig(path) {
|
|
|
37
57
|
}
|
|
38
58
|
}
|
|
39
59
|
function setOcConfig(config, path) {
|
|
40
|
-
|
|
60
|
+
const { sourcePath, ...rest } = config;
|
|
61
|
+
node_fs_1.default.writeFileSync(path || sourcePath || settings_1.default.configFile.src, JSON.stringify(rest, null, 2));
|
|
41
62
|
}
|
|
@@ -14,6 +14,10 @@ export default function registry(opts?: RegistryOptions): {
|
|
|
14
14
|
path: string;
|
|
15
15
|
}): Promise<void>;
|
|
16
16
|
remove(registry: string): Promise<void>;
|
|
17
|
+
validateComponent(options: {
|
|
18
|
+
url: string;
|
|
19
|
+
packageJson: any;
|
|
20
|
+
}): Promise<void>;
|
|
17
21
|
};
|
|
18
22
|
export type RegistryCli = ReturnType<typeof registry>;
|
|
19
23
|
export {};
|
|
@@ -144,6 +144,47 @@ function registry(opts = {}) {
|
|
|
144
144
|
const res = (0, ocConfig_1.getOcConfig)();
|
|
145
145
|
res.registries = res.registries?.filter((x) => x !== registry) || [];
|
|
146
146
|
(0, ocConfig_1.setOcConfig)(res);
|
|
147
|
+
},
|
|
148
|
+
async validateComponent(options) {
|
|
149
|
+
try {
|
|
150
|
+
const response = await (0, undici_1.request)(options.url, {
|
|
151
|
+
method: 'POST',
|
|
152
|
+
headers: {
|
|
153
|
+
...requestsHeaders,
|
|
154
|
+
'Content-Type': 'application/json'
|
|
155
|
+
},
|
|
156
|
+
body: JSON.stringify({ packageJson: options.packageJson })
|
|
157
|
+
});
|
|
158
|
+
if (response.statusCode === 404) {
|
|
159
|
+
throw 'Registry URL is invalid or does not exist';
|
|
160
|
+
}
|
|
161
|
+
const result = (await response.body.json());
|
|
162
|
+
if (response.statusCode !== 200) {
|
|
163
|
+
throw result;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
catch (err) {
|
|
167
|
+
let parsedError = err;
|
|
168
|
+
let errMsg = '';
|
|
169
|
+
if (!parsedError || typeof parsedError !== 'object') {
|
|
170
|
+
try {
|
|
171
|
+
parsedError = JSON.parse(String(parsedError));
|
|
172
|
+
}
|
|
173
|
+
catch { }
|
|
174
|
+
}
|
|
175
|
+
if (!!parsedError.code && parsedError.code === 'ECONNREFUSED') {
|
|
176
|
+
errMsg = 'Connection to registry has not been established';
|
|
177
|
+
}
|
|
178
|
+
else if (parsedError.code !== 'cli_version_not_valid' &&
|
|
179
|
+
parsedError.code !== 'node_version_not_valid' &&
|
|
180
|
+
!!parsedError.error) {
|
|
181
|
+
errMsg = parsedError.error;
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
errMsg = parsedError;
|
|
185
|
+
}
|
|
186
|
+
throw errMsg;
|
|
187
|
+
}
|
|
147
188
|
}
|
|
148
189
|
};
|
|
149
190
|
}
|
package/dist/cli/facade/dev.js
CHANGED
|
@@ -39,15 +39,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
39
39
|
const node_path_1 = __importDefault(require("node:path"));
|
|
40
40
|
const node_util_1 = require("node:util");
|
|
41
41
|
const safe_1 = __importDefault(require("colors/safe"));
|
|
42
|
-
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
43
42
|
const getport_1 = __importDefault(require("getport"));
|
|
44
43
|
const livereload_1 = __importDefault(require("livereload"));
|
|
45
44
|
const universalify_1 = require("universalify");
|
|
46
45
|
const oc = __importStar(require("../../index"));
|
|
47
46
|
const index_1 = __importDefault(require("../../resources/index"));
|
|
48
|
-
const settings_1 = __importDefault(require("../../resources/settings"));
|
|
49
47
|
const get_mocked_plugins_1 = __importDefault(require("../domain/get-mocked-plugins"));
|
|
50
48
|
const handle_dependencies_1 = __importDefault(require("../domain/handle-dependencies"));
|
|
49
|
+
const ocConfig_1 = require("../domain/ocConfig");
|
|
51
50
|
const watch_1 = __importDefault(require("../domain/watch"));
|
|
52
51
|
const cliMessages = index_1.default.messages.cli;
|
|
53
52
|
const cliErrors = index_1.default.errors.cli;
|
|
@@ -59,9 +58,9 @@ const dev = ({ local, logger }) => (0, universalify_1.fromPromise)(async (opts)
|
|
|
59
58
|
const baseUrl = opts.baseUrl || `http://localhost:${port}/`;
|
|
60
59
|
let fallbackRegistryUrl = opts.fallbackRegistryUrl;
|
|
61
60
|
let fallbackClient = false;
|
|
61
|
+
const localConfig = (0, ocConfig_1.getOcConfig)(componentsDir);
|
|
62
62
|
if (!fallbackRegistryUrl) {
|
|
63
63
|
try {
|
|
64
|
-
const localConfig = await fs_extra_1.default.readJson(settings_1.default.configFile.src);
|
|
65
64
|
if (!fallbackRegistryUrl &&
|
|
66
65
|
typeof localConfig.development?.fallback?.url === 'string') {
|
|
67
66
|
fallbackRegistryUrl = localConfig.development?.fallback?.url;
|
|
@@ -175,25 +174,34 @@ const dev = ({ local, logger }) => (0, universalify_1.fromPromise)(async (opts)
|
|
|
175
174
|
const refresher = () => liveReloadServer.refresh('/');
|
|
176
175
|
liveReload = { refresher, port: otherPort };
|
|
177
176
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
177
|
+
let registry;
|
|
178
|
+
try {
|
|
179
|
+
registry = oc.Registry({
|
|
180
|
+
baseUrl,
|
|
181
|
+
prefix: opts.prefix || '',
|
|
182
|
+
dependencies: dependencies.modules,
|
|
183
|
+
compileClient: true,
|
|
184
|
+
discovery: true,
|
|
185
|
+
env: { name: 'local' },
|
|
186
|
+
fallbackRegistryUrl,
|
|
187
|
+
fallbackClient,
|
|
188
|
+
hotReloading,
|
|
189
|
+
liveReloadPort: liveReload.port,
|
|
190
|
+
local: true,
|
|
191
|
+
postRequestPayloadSize,
|
|
192
|
+
components: opts.components,
|
|
193
|
+
path: node_path_1.default.resolve(componentsDir),
|
|
194
|
+
port,
|
|
195
|
+
templates: dependencies.templates,
|
|
196
|
+
verbosity: 1,
|
|
197
|
+
preload: localConfig.development?.preload,
|
|
198
|
+
routes: localConfig.development?.routes
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
catch (err) {
|
|
202
|
+
logger.err(String(err));
|
|
203
|
+
throw err;
|
|
204
|
+
}
|
|
197
205
|
registerPlugins(registry);
|
|
198
206
|
logger.warn(cliMessages.REGISTRY_STARTING(baseUrl));
|
|
199
207
|
if (liveReload.port) {
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Local } from '../domain/local';
|
|
2
|
+
import type { RegistryCli } from '../domain/registry';
|
|
3
|
+
import type { Logger } from '../logger';
|
|
4
|
+
declare const validate: ({ logger, registry, local }: {
|
|
5
|
+
logger: Logger;
|
|
6
|
+
registry: RegistryCli;
|
|
7
|
+
local: Local;
|
|
8
|
+
}) => {
|
|
9
|
+
(opts: {
|
|
10
|
+
componentPath: string;
|
|
11
|
+
skipPackage?: boolean;
|
|
12
|
+
registries?: string[];
|
|
13
|
+
}): Promise<void>;
|
|
14
|
+
(opts: {
|
|
15
|
+
componentPath: string;
|
|
16
|
+
skipPackage?: boolean;
|
|
17
|
+
registries?: string[];
|
|
18
|
+
}, arguments__1: (error: unknown, value: void) => void): void;
|
|
19
|
+
};
|
|
20
|
+
export default validate;
|
|
@@ -0,0 +1,127 @@
|
|
|
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 node_path_1 = __importDefault(require("node:path"));
|
|
7
|
+
const safe_1 = __importDefault(require("colors/safe"));
|
|
8
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
9
|
+
const universalify_1 = require("universalify");
|
|
10
|
+
const index_1 = __importDefault(require("../../resources/index"));
|
|
11
|
+
const handle_dependencies_1 = __importDefault(require("../domain/handle-dependencies"));
|
|
12
|
+
const validate = ({ logger, registry, local }) => (0, universalify_1.fromPromise)(async (opts) => {
|
|
13
|
+
const componentPath = opts.componentPath;
|
|
14
|
+
const skipPackage = opts.skipPackage;
|
|
15
|
+
const packageDir = node_path_1.default.resolve(componentPath, '_package');
|
|
16
|
+
let errorMessage;
|
|
17
|
+
const readPackageJson = () => fs_extra_1.default.readJson(node_path_1.default.join(packageDir, 'package.json'));
|
|
18
|
+
const packageComponent = async () => {
|
|
19
|
+
logger.warn(index_1.default.messages.cli.PACKAGING(packageDir));
|
|
20
|
+
const packageOptions = {
|
|
21
|
+
production: true,
|
|
22
|
+
componentPath: node_path_1.default.resolve(componentPath)
|
|
23
|
+
};
|
|
24
|
+
const component = await local.package(packageOptions);
|
|
25
|
+
return component;
|
|
26
|
+
};
|
|
27
|
+
const validateComponentWithRegistry = async (options) => {
|
|
28
|
+
const { registryUrl, packageJson, componentName, componentVersion } = options;
|
|
29
|
+
const registryNormalised = registryUrl.replace(/\/$/, '');
|
|
30
|
+
const validateUrl = `${registryNormalised}/~registry/validate/${componentName}/${componentVersion}`;
|
|
31
|
+
logger.warn(`Validating component against registry: ${registryNormalised}`);
|
|
32
|
+
try {
|
|
33
|
+
await registry.validateComponent({
|
|
34
|
+
url: validateUrl,
|
|
35
|
+
packageJson
|
|
36
|
+
});
|
|
37
|
+
logger.ok(`✓ Validation successful for registry: ${registryNormalised}`);
|
|
38
|
+
}
|
|
39
|
+
catch (err) {
|
|
40
|
+
if (err.code === 'cli_version_not_valid') {
|
|
41
|
+
const upgradeCommand = index_1.default.commands.cli.UPGRADE(err.details.suggestedVersion);
|
|
42
|
+
const errorDetails = index_1.default.errors.cli.OC_CLI_VERSION_NEEDS_UPGRADE(safe_1.default.blue(upgradeCommand));
|
|
43
|
+
errorMessage = index_1.default.errors.cli.VALIDATION_FAIL(errorDetails);
|
|
44
|
+
logger.err(errorMessage);
|
|
45
|
+
throw errorMessage;
|
|
46
|
+
}
|
|
47
|
+
else if (err.code === 'node_version_not_valid') {
|
|
48
|
+
const details = index_1.default.errors.cli.NODE_CLI_VERSION_NEEDS_UPGRADE(err.details.suggestedVersion);
|
|
49
|
+
errorMessage = index_1.default.errors.cli.VALIDATION_FAIL(details);
|
|
50
|
+
logger.err(errorMessage);
|
|
51
|
+
throw errorMessage;
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
if (err.message) {
|
|
55
|
+
errorMessage = err.message;
|
|
56
|
+
}
|
|
57
|
+
else if (err && typeof err === 'object') {
|
|
58
|
+
try {
|
|
59
|
+
errorMessage = JSON.stringify(err);
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
errorMessage = String(err);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
errorMessage = String(err);
|
|
67
|
+
}
|
|
68
|
+
errorMessage = `✗ Validation failed for registry ${registryNormalised}: ${errorMessage}`;
|
|
69
|
+
logger.err(errorMessage);
|
|
70
|
+
throw errorMessage;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
const validateWithRegistries = async (registryLocations, component) => {
|
|
75
|
+
const packageJsonPath = node_path_1.default.join(packageDir, 'package.json');
|
|
76
|
+
const packageJson = await fs_extra_1.default.readJson(packageJsonPath);
|
|
77
|
+
for (const registryUrl of registryLocations) {
|
|
78
|
+
await validateComponentWithRegistry({
|
|
79
|
+
registryUrl,
|
|
80
|
+
packageJson,
|
|
81
|
+
componentName: component.name,
|
|
82
|
+
componentVersion: component.version
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
try {
|
|
87
|
+
const registryLocations = opts.registries || (await registry.get());
|
|
88
|
+
if (!skipPackage) {
|
|
89
|
+
await (0, handle_dependencies_1.default)({
|
|
90
|
+
components: [node_path_1.default.resolve(componentPath)],
|
|
91
|
+
logger
|
|
92
|
+
}).catch((err) => {
|
|
93
|
+
logger.err(err);
|
|
94
|
+
return Promise.reject(err);
|
|
95
|
+
});
|
|
96
|
+
const component = await packageComponent().catch((err) => {
|
|
97
|
+
errorMessage = index_1.default.errors.cli.PACKAGE_CREATION_FAIL(String(err));
|
|
98
|
+
logger.err(errorMessage);
|
|
99
|
+
return Promise.reject(errorMessage);
|
|
100
|
+
});
|
|
101
|
+
await validateWithRegistries(registryLocations, component);
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
if (fs_extra_1.default.existsSync(packageDir)) {
|
|
105
|
+
const component = await readPackageJson().catch((err) => {
|
|
106
|
+
logger.err(String(err));
|
|
107
|
+
return Promise.reject(err);
|
|
108
|
+
});
|
|
109
|
+
await validateWithRegistries(registryLocations, component);
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
errorMessage = index_1.default.errors.cli.PACKAGE_FOLDER_MISSING;
|
|
113
|
+
logger.err(errorMessage);
|
|
114
|
+
throw errorMessage;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
logger.ok('✓ Component validation completed successfully for all registries');
|
|
118
|
+
}
|
|
119
|
+
catch (err) {
|
|
120
|
+
// Don't log again if it's already been logged by validateComponentWithRegistry
|
|
121
|
+
if (!String(err).includes('✗ Validation failed for registry')) {
|
|
122
|
+
logger.err(String(err));
|
|
123
|
+
}
|
|
124
|
+
throw err;
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
exports.default = validate;
|
package/dist/cli/index.js
CHANGED
|
@@ -20,6 +20,7 @@ const registry_2 = __importDefault(require("./facade/registry"));
|
|
|
20
20
|
const registry_add_1 = __importDefault(require("./facade/registry-add"));
|
|
21
21
|
const registry_ls_1 = __importDefault(require("./facade/registry-ls"));
|
|
22
22
|
const registry_remove_1 = __importDefault(require("./facade/registry-remove"));
|
|
23
|
+
const validate_1 = __importDefault(require("./facade/validate"));
|
|
23
24
|
const logger_1 = __importDefault(require("./logger"));
|
|
24
25
|
const validate_command_1 = __importDefault(require("./validate-command"));
|
|
25
26
|
const cliFunctions = {
|
|
@@ -33,7 +34,8 @@ const cliFunctions = {
|
|
|
33
34
|
registry: registry_2.default,
|
|
34
35
|
'registry-add': registry_add_1.default,
|
|
35
36
|
'registry-ls': registry_ls_1.default,
|
|
36
|
-
'registry-remove': registry_remove_1.default
|
|
37
|
+
'registry-remove': registry_remove_1.default,
|
|
38
|
+
validate: validate_1.default
|
|
37
39
|
};
|
|
38
40
|
const currentNodeVersion = process.version;
|
|
39
41
|
const minSupportedVersion = '6.0.0';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oc-client",
|
|
3
3
|
"description": "The OpenComponents client-side javascript client",
|
|
4
|
-
"version": "0.50.
|
|
4
|
+
"version": "0.50.28",
|
|
5
5
|
"repository": "https://github.com/opencomponents/oc/tree/master/components/oc-client",
|
|
6
6
|
"author": "Matteo Figus <matteofigus@gmail.com>",
|
|
7
7
|
"oc": {
|
|
@@ -22,14 +22,14 @@
|
|
|
22
22
|
],
|
|
23
23
|
"dataProvider": {
|
|
24
24
|
"type": "node.js",
|
|
25
|
-
"hashKey": "
|
|
25
|
+
"hashKey": "8d9e7c4d166e0630573f2c69470003476451d7c5",
|
|
26
26
|
"src": "server.js",
|
|
27
27
|
"size": 613
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
|
-
"version": "0.50.
|
|
30
|
+
"version": "0.50.28",
|
|
31
31
|
"packaged": true,
|
|
32
|
-
"date":
|
|
32
|
+
"date": 1756715231220
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"oc-template-es6-compiler": "^1.0.1"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=(t,s)=>{const{staticPath:e,templates:a}=t;return s(null,{staticPath:e,templates:a})},o=(t,s)=>{r(t,(e,a)=>{if(e)return s(e);if(a==null)return s(null,{__oc_emptyResponse:!0});const n=t.action?a:Object.assign({},a,{_staticPath:t.staticPath,_baseUrl:t.baseUrl,_componentName:"oc-client",_componentVersion:"0.50.
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=(t,s)=>{const{staticPath:e,templates:a}=t;return s(null,{staticPath:e,templates:a})},o=(t,s)=>{r(t,(e,a)=>{if(e)return s(e);if(a==null)return s(null,{__oc_emptyResponse:!0});const n=t.action?a:Object.assign({},a,{_staticPath:t.staticPath,_baseUrl:t.baseUrl,_componentName:"oc-client",_componentVersion:"0.50.28"}),c=t.staticPath.indexOf("http")===0?t.staticPath:"https:"+t.staticPath;return s(null,Object.assign({},{component:{key:"8b7545cba94f7c029b9d46108bfe8e4e6040ea09",src:c+"template.js",props:n}}))})};exports.data=o;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! OpenComponents client v2.1.
|
|
1
|
+
/*! OpenComponents client v2.1.4 | (c) 2015-2025 OpenComponents community | https://github.com/opencomponents/oc-client-browser/tree/master/LICENSES */
|
|
2
2
|
(() => {
|
|
3
3
|
// <define:__EXTERNALS__>
|
|
4
4
|
var define_EXTERNALS_default = [];
|
|
@@ -453,7 +453,7 @@
|
|
|
453
453
|
oc2.conf = oc2.conf || {};
|
|
454
454
|
oc2.cmd = oc2.cmd || [];
|
|
455
455
|
oc2.renderedComponents = oc2.renderedComponents || {};
|
|
456
|
-
oc2.clientVersion = "2.1.
|
|
456
|
+
oc2.clientVersion = "2.1.4";
|
|
457
457
|
let isRequired = (name, value) => {
|
|
458
458
|
if (!value) {
|
|
459
459
|
throw name + " parameter is required";
|