@lorion-org/descriptor-discovery 1.0.0-beta.2 → 1.0.0-beta.3
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/README.md +3 -3
- package/dist/index.cjs +10 -2
- package/dist/index.d.cts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +8 -1
- package/package.json +1 -1
- package/src/index.ts +14 -0
package/README.md
CHANGED
|
@@ -44,7 +44,7 @@ layer-extensions/
|
|
|
44
44
|
import { discoverDescriptors } from '@lorion-org/descriptor-discovery';
|
|
45
45
|
|
|
46
46
|
const discovered = discoverDescriptors({
|
|
47
|
-
cwd: '
|
|
47
|
+
cwd: '.',
|
|
48
48
|
descriptorPaths: ['layer-extensions/*/extension.json'],
|
|
49
49
|
});
|
|
50
50
|
|
|
@@ -61,7 +61,7 @@ id when the descriptor does not define one.
|
|
|
61
61
|
import { discoverDescriptors } from '@lorion-org/descriptor-discovery';
|
|
62
62
|
|
|
63
63
|
const discovered = discoverDescriptors({
|
|
64
|
-
cwd: '
|
|
64
|
+
cwd: '.',
|
|
65
65
|
descriptorPaths: ['layer-extensions/*/extension.json'],
|
|
66
66
|
nestedField: 'bundles',
|
|
67
67
|
});
|
|
@@ -79,7 +79,7 @@ import { createDescriptorCatalog } from '@lorion-org/composition-graph';
|
|
|
79
79
|
import { discoverDescriptors } from '@lorion-org/descriptor-discovery';
|
|
80
80
|
|
|
81
81
|
const discovered = discoverDescriptors({
|
|
82
|
-
cwd: '
|
|
82
|
+
cwd: '.',
|
|
83
83
|
descriptorPaths: ['layer-extensions/*/extension.json'],
|
|
84
84
|
nestedField: 'bundles',
|
|
85
85
|
});
|
package/dist/index.cjs
CHANGED
|
@@ -32,7 +32,8 @@ var index_exports = {};
|
|
|
32
32
|
__export(index_exports, {
|
|
33
33
|
descriptorSchema: () => descriptorSchema,
|
|
34
34
|
discoverDescriptors: () => discoverDescriptors,
|
|
35
|
-
expandNestedDescriptors: () => expandNestedDescriptors
|
|
35
|
+
expandNestedDescriptors: () => expandNestedDescriptors,
|
|
36
|
+
requirePackageName: () => requirePackageName
|
|
36
37
|
});
|
|
37
38
|
module.exports = __toCommonJS(index_exports);
|
|
38
39
|
var import_node_fs = require("fs");
|
|
@@ -112,6 +113,12 @@ var descriptor_schema_default = {
|
|
|
112
113
|
var descriptorSchema = descriptor_schema_default;
|
|
113
114
|
|
|
114
115
|
// src/index.ts
|
|
116
|
+
function requirePackageName(packageJson, packageJsonPath) {
|
|
117
|
+
if (typeof packageJson.name !== "string") {
|
|
118
|
+
throw new Error(`Capability package is missing "name": ${packageJsonPath}`);
|
|
119
|
+
}
|
|
120
|
+
return packageJson.name;
|
|
121
|
+
}
|
|
115
122
|
function formatDescriptorSchemaValidationError(target, validationError) {
|
|
116
123
|
const jsonPath = validationError.instancePath || "/";
|
|
117
124
|
const ajvError = `${validationError.keyword}${validationError.message ? `: ${validationError.message}` : ""}`;
|
|
@@ -320,5 +327,6 @@ function discoverDescriptors(input) {
|
|
|
320
327
|
0 && (module.exports = {
|
|
321
328
|
descriptorSchema,
|
|
322
329
|
discoverDescriptors,
|
|
323
|
-
expandNestedDescriptors
|
|
330
|
+
expandNestedDescriptors,
|
|
331
|
+
requirePackageName
|
|
324
332
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -2,6 +2,9 @@ import { ErrorObject, Options } from 'ajv';
|
|
|
2
2
|
import { Descriptor } from '@lorion-org/composition-graph';
|
|
3
3
|
export { JsonSchemaObject, descriptorSchema } from './schema.cjs';
|
|
4
4
|
|
|
5
|
+
declare function requirePackageName(packageJson: {
|
|
6
|
+
name?: unknown;
|
|
7
|
+
}, packageJsonPath: string): string;
|
|
5
8
|
type RawDescriptor = Omit<Descriptor, 'id'> & {
|
|
6
9
|
id?: string;
|
|
7
10
|
};
|
|
@@ -39,4 +42,4 @@ type DiscoverDescriptorsInput = {
|
|
|
39
42
|
declare function expandNestedDescriptors(input: ExpandNestedDescriptorsInput): Descriptor[];
|
|
40
43
|
declare function discoverDescriptors(input: DiscoverDescriptorsInput): DiscoveredDescriptor[];
|
|
41
44
|
|
|
42
|
-
export { type DescriptorSchemaValidationErrorFormatter, type DescriptorSchemaValidationTarget, type DescriptorValidationOptions, type DiscoverDescriptorsInput, type DiscoveredDescriptor, type ExpandNestedDescriptorsInput, type RawDescriptor, discoverDescriptors, expandNestedDescriptors };
|
|
45
|
+
export { type DescriptorSchemaValidationErrorFormatter, type DescriptorSchemaValidationTarget, type DescriptorValidationOptions, type DiscoverDescriptorsInput, type DiscoveredDescriptor, type ExpandNestedDescriptorsInput, type RawDescriptor, discoverDescriptors, expandNestedDescriptors, requirePackageName };
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,9 @@ import { ErrorObject, Options } from 'ajv';
|
|
|
2
2
|
import { Descriptor } from '@lorion-org/composition-graph';
|
|
3
3
|
export { JsonSchemaObject, descriptorSchema } from './schema.js';
|
|
4
4
|
|
|
5
|
+
declare function requirePackageName(packageJson: {
|
|
6
|
+
name?: unknown;
|
|
7
|
+
}, packageJsonPath: string): string;
|
|
5
8
|
type RawDescriptor = Omit<Descriptor, 'id'> & {
|
|
6
9
|
id?: string;
|
|
7
10
|
};
|
|
@@ -39,4 +42,4 @@ type DiscoverDescriptorsInput = {
|
|
|
39
42
|
declare function expandNestedDescriptors(input: ExpandNestedDescriptorsInput): Descriptor[];
|
|
40
43
|
declare function discoverDescriptors(input: DiscoverDescriptorsInput): DiscoveredDescriptor[];
|
|
41
44
|
|
|
42
|
-
export { type DescriptorSchemaValidationErrorFormatter, type DescriptorSchemaValidationTarget, type DescriptorValidationOptions, type DiscoverDescriptorsInput, type DiscoveredDescriptor, type ExpandNestedDescriptorsInput, type RawDescriptor, discoverDescriptors, expandNestedDescriptors };
|
|
45
|
+
export { type DescriptorSchemaValidationErrorFormatter, type DescriptorSchemaValidationTarget, type DescriptorValidationOptions, type DiscoverDescriptorsInput, type DiscoveredDescriptor, type ExpandNestedDescriptorsInput, type RawDescriptor, discoverDescriptors, expandNestedDescriptors, requirePackageName };
|
package/dist/index.js
CHANGED
|
@@ -6,6 +6,12 @@ import {
|
|
|
6
6
|
import { existsSync, readFileSync, readdirSync } from "fs";
|
|
7
7
|
import { basename, dirname, join, resolve as resolvePath } from "path";
|
|
8
8
|
import Ajv from "ajv";
|
|
9
|
+
function requirePackageName(packageJson, packageJsonPath) {
|
|
10
|
+
if (typeof packageJson.name !== "string") {
|
|
11
|
+
throw new Error(`Capability package is missing "name": ${packageJsonPath}`);
|
|
12
|
+
}
|
|
13
|
+
return packageJson.name;
|
|
14
|
+
}
|
|
9
15
|
function formatDescriptorSchemaValidationError(target, validationError) {
|
|
10
16
|
const jsonPath = validationError.instancePath || "/";
|
|
11
17
|
const ajvError = `${validationError.keyword}${validationError.message ? `: ${validationError.message}` : ""}`;
|
|
@@ -213,5 +219,6 @@ function discoverDescriptors(input) {
|
|
|
213
219
|
export {
|
|
214
220
|
descriptorSchema,
|
|
215
221
|
discoverDescriptors,
|
|
216
|
-
expandNestedDescriptors
|
|
222
|
+
expandNestedDescriptors,
|
|
223
|
+
requirePackageName
|
|
217
224
|
};
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -6,6 +6,20 @@ import type { Descriptor } from '@lorion-org/composition-graph';
|
|
|
6
6
|
|
|
7
7
|
export { descriptorSchema, type JsonSchemaObject } from './schema';
|
|
8
8
|
|
|
9
|
+
// A capability lives on disk as a package: its descriptor (capability.json) beside
|
|
10
|
+
// a package.json. Validating that the package declares a `name` — with one shared
|
|
11
|
+
// error message — belongs here next to descriptor discovery, so each host does not
|
|
12
|
+
// reimplement it. Takes an already-parsed package.json to avoid re-reading it.
|
|
13
|
+
export function requirePackageName(
|
|
14
|
+
packageJson: { name?: unknown },
|
|
15
|
+
packageJsonPath: string,
|
|
16
|
+
): string {
|
|
17
|
+
if (typeof packageJson.name !== 'string') {
|
|
18
|
+
throw new Error(`Capability package is missing "name": ${packageJsonPath}`);
|
|
19
|
+
}
|
|
20
|
+
return packageJson.name;
|
|
21
|
+
}
|
|
22
|
+
|
|
9
23
|
export type RawDescriptor = Omit<Descriptor, 'id'> & {
|
|
10
24
|
id?: string;
|
|
11
25
|
};
|