@lbdudc/linea-core 0.1.1 → 0.2.0
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 +132 -260
- package/dist/analysis/analyze.d.ts +0 -54
- package/dist/analysis/analyze.js +1 -70
- package/dist/analysis/analyze.js.map +1 -1
- package/dist/analysis/runtime.d.ts +4 -73
- package/dist/analysis/runtime.js +7 -100
- package/dist/analysis/runtime.js.map +1 -1
- package/dist/analysis/uvl-text.d.ts +8 -0
- package/dist/analysis/uvl-text.js +70 -0
- package/dist/analysis/uvl-text.js.map +1 -0
- package/dist/assets.d.ts +0 -12
- package/dist/assets.js +0 -25
- package/dist/assets.js.map +1 -1
- package/dist/ci/annotations.d.ts +6 -0
- package/dist/ci/annotations.js +12 -0
- package/dist/ci/annotations.js.map +1 -0
- package/dist/ci/leftovers.d.ts +25 -0
- package/dist/ci/leftovers.js +50 -0
- package/dist/ci/leftovers.js.map +1 -0
- package/dist/ci/pairwise.d.ts +11 -0
- package/dist/ci/pairwise.js +35 -0
- package/dist/ci/pairwise.js.map +1 -0
- package/dist/ci/pipeline.d.ts +18 -0
- package/dist/ci/pipeline.js +26 -0
- package/dist/ci/pipeline.js.map +1 -0
- package/dist/ci/select.d.ts +28 -0
- package/dist/ci/select.js +43 -0
- package/dist/ci/select.js.map +1 -0
- package/dist/ci/validate-specs.d.ts +52 -0
- package/dist/ci/validate-specs.js +212 -0
- package/dist/ci/validate-specs.js.map +1 -0
- package/dist/constants.d.ts +1 -60
- package/dist/constants.js +1 -58
- package/dist/constants.js.map +1 -1
- package/dist/derivation/derive.d.ts +0 -56
- package/dist/derivation/derive.js +21 -72
- package/dist/derivation/derive.js.map +1 -1
- package/dist/derivation/engine.d.ts +10 -42
- package/dist/derivation/engine.js +37 -68
- package/dist/derivation/engine.js.map +1 -1
- package/dist/derivation/selection-error.d.ts +7 -0
- package/dist/derivation/selection-error.js +13 -0
- package/dist/derivation/selection-error.js.map +1 -0
- package/dist/errors.d.ts +19 -47
- package/dist/errors.js +28 -47
- package/dist/errors.js.map +1 -1
- package/dist/feature-model/uvl.d.ts +52 -0
- package/dist/feature-model/uvl.js +191 -0
- package/dist/feature-model/uvl.js.map +1 -0
- package/dist/fs/archive.d.ts +0 -16
- package/dist/fs/archive.js +0 -36
- package/dist/fs/archive.js.map +1 -1
- package/dist/fs/diff.d.ts +0 -30
- package/dist/fs/diff.js +4 -65
- package/dist/fs/diff.js.map +1 -1
- package/dist/fs/format.d.ts +0 -16
- package/dist/fs/format.js +0 -52
- package/dist/fs/format.js.map +1 -1
- package/dist/fs/workspace.d.ts +0 -52
- package/dist/fs/workspace.js +0 -56
- package/dist/fs/workspace.js.map +1 -1
- package/dist/index.d.ts +23 -29
- package/dist/index.js +15 -35
- package/dist/index.js.map +1 -1
- package/dist/internal/guards.d.ts +0 -13
- package/dist/internal/guards.js +0 -13
- package/dist/internal/guards.js.map +1 -1
- package/dist/line/deletion.d.ts +33 -0
- package/dist/line/deletion.js +23 -0
- package/dist/line/deletion.js.map +1 -0
- package/dist/line/platform-files.d.ts +15 -64
- package/dist/line/platform-files.js +18 -94
- package/dist/line/platform-files.js.map +1 -1
- package/dist/line/restoration.d.ts +27 -0
- package/dist/line/restoration.js +27 -0
- package/dist/line/restoration.js.map +1 -0
- package/dist/line/scaffold.d.ts +26 -57
- package/dist/line/scaffold.js +32 -93
- package/dist/line/scaffold.js.map +1 -1
- package/dist/line/templates/core/transformation.js +17 -5
- package/dist/line/templates/pipeline/github-ci.yml +50 -0
- package/dist/line/templates/pipeline/spl-gitlab-ci.yml +182 -0
- package/dist/modules/configuration/configure.d.ts +52 -0
- package/dist/modules/configuration/configure.js +101 -0
- package/dist/modules/configuration/configure.js.map +1 -0
- package/dist/modules/configuration/constants.d.ts +17 -0
- package/dist/modules/configuration/constants.js +14 -0
- package/dist/modules/configuration/constants.js.map +1 -0
- package/dist/modules/configuration/index.d.ts +6 -0
- package/dist/modules/configuration/index.js +5 -0
- package/dist/modules/configuration/index.js.map +1 -0
- package/dist/modules/configuration/names.d.ts +9 -0
- package/dist/modules/configuration/names.js +7 -0
- package/dist/modules/configuration/names.js.map +1 -0
- package/dist/modules/configuration/selection.d.ts +32 -0
- package/dist/modules/configuration/selection.js +49 -0
- package/dist/modules/configuration/selection.js.map +1 -0
- package/dist/modules/diagnostics.d.ts +2 -0
- package/dist/modules/diagnostics.js +2 -0
- package/dist/modules/diagnostics.js.map +1 -0
- package/dist/modules/index.d.ts +18 -0
- package/dist/modules/index.js +18 -0
- package/dist/modules/index.js.map +1 -0
- package/dist/modules/metamodels/engine.d.ts +93 -0
- package/dist/modules/metamodels/engine.js +10 -0
- package/dist/modules/metamodels/engine.js.map +1 -0
- package/dist/modules/metamodels/files.d.ts +40 -0
- package/dist/modules/metamodels/files.js +58 -0
- package/dist/modules/metamodels/files.js.map +1 -0
- package/dist/modules/metamodels/index.d.ts +8 -0
- package/dist/modules/metamodels/index.js +5 -0
- package/dist/modules/metamodels/index.js.map +1 -0
- package/dist/modules/metamodels/layout.d.ts +23 -0
- package/dist/modules/metamodels/layout.js +29 -0
- package/dist/modules/metamodels/layout.js.map +1 -0
- package/dist/modules/metamodels/offered.d.ts +15 -0
- package/dist/modules/metamodels/offered.js +14 -0
- package/dist/modules/metamodels/offered.js.map +1 -0
- package/dist/modules/metamodels/prepare.d.ts +20 -0
- package/dist/modules/metamodels/prepare.js +155 -0
- package/dist/modules/metamodels/prepare.js.map +1 -0
- package/dist/modules/packages/index.d.ts +4 -0
- package/dist/modules/packages/index.js +4 -0
- package/dist/modules/packages/index.js.map +1 -0
- package/dist/modules/packages/location.d.ts +21 -0
- package/dist/modules/packages/location.js +34 -0
- package/dist/modules/packages/location.js.map +1 -0
- package/dist/modules/packages/manifests.d.ts +33 -0
- package/dist/modules/packages/manifests.js +231 -0
- package/dist/modules/packages/manifests.js.map +1 -0
- package/dist/modules/packages/source.d.ts +34 -0
- package/dist/modules/packages/source.js +128 -0
- package/dist/modules/packages/source.js.map +1 -0
- package/dist/modules/products/check.d.ts +28 -0
- package/dist/modules/products/check.js +61 -0
- package/dist/modules/products/check.js.map +1 -0
- package/dist/modules/products/derive.d.ts +30 -0
- package/dist/modules/products/derive.js +56 -0
- package/dist/modules/products/derive.js.map +1 -0
- package/dist/modules/products/index.d.ts +5 -0
- package/dist/modules/products/index.js +4 -0
- package/dist/modules/products/index.js.map +1 -0
- package/dist/modules/products/seed.d.ts +18 -0
- package/dist/modules/products/seed.js +23 -0
- package/dist/modules/products/seed.js.map +1 -0
- package/dist/modules/registry/catalog.d.ts +64 -0
- package/dist/modules/registry/catalog.js +91 -0
- package/dist/modules/registry/catalog.js.map +1 -0
- package/dist/modules/registry/index.d.ts +5 -0
- package/dist/modules/registry/index.js +4 -0
- package/dist/modules/registry/index.js.map +1 -0
- package/dist/modules/registry/registry.d.ts +34 -0
- package/dist/modules/registry/registry.js +37 -0
- package/dist/modules/registry/registry.js.map +1 -0
- package/dist/modules/registry/routing.d.ts +8 -0
- package/dist/modules/registry/routing.js +23 -0
- package/dist/modules/registry/routing.js.map +1 -0
- package/dist/modules/resolution/closure.d.ts +28 -0
- package/dist/modules/resolution/closure.js +105 -0
- package/dist/modules/resolution/closure.js.map +1 -0
- package/dist/modules/resolution/index.d.ts +4 -0
- package/dist/modules/resolution/index.js +3 -0
- package/dist/modules/resolution/index.js.map +1 -0
- package/dist/modules/resolution/resolve.d.ts +33 -0
- package/dist/modules/resolution/resolve.js +59 -0
- package/dist/modules/resolution/resolve.js.map +1 -0
- package/dist/modules/resolution/resolvers.d.ts +23 -0
- package/dist/modules/resolution/resolvers.js +34 -0
- package/dist/modules/resolution/resolvers.js.map +1 -0
- package/dist/modules/spl/check.d.ts +25 -0
- package/dist/modules/spl/check.js +21 -0
- package/dist/modules/spl/check.js.map +1 -0
- package/dist/modules/spl/cip.d.ts +67 -0
- package/dist/modules/spl/cip.js +98 -0
- package/dist/modules/spl/cip.js.map +1 -0
- package/dist/modules/spl/feature-model.d.ts +39 -0
- package/dist/modules/spl/feature-model.js +106 -0
- package/dist/modules/spl/feature-model.js.map +1 -0
- package/dist/modules/spl/index.d.ts +6 -0
- package/dist/modules/spl/index.js +4 -0
- package/dist/modules/spl/index.js.map +1 -0
- package/dist/modules/spl/platform.d.ts +49 -0
- package/dist/modules/spl/platform.js +316 -0
- package/dist/modules/spl/platform.js.map +1 -0
- package/dist/modules/types.d.ts +132 -0
- package/dist/modules/types.js +2 -0
- package/dist/modules/types.js.map +1 -0
- package/dist/product/engine-spec.d.ts +0 -16
- package/dist/product/engine-spec.js +4 -50
- package/dist/product/engine-spec.js.map +1 -1
- package/dist/product/spec.d.ts +0 -82
- package/dist/product/spec.js +0 -79
- package/dist/product/spec.js.map +1 -1
- package/dist/product/version.d.ts +0 -23
- package/dist/product/version.js +0 -28
- package/dist/product/version.js.map +1 -1
- package/dist/products-index/products-index.d.ts +0 -165
- package/dist/products-index/products-index.js +0 -176
- package/dist/products-index/products-index.js.map +1 -1
- package/dist/workspace/context.d.ts +25 -0
- package/dist/workspace/context.js +43 -0
- package/dist/workspace/context.js.map +1 -0
- package/dist/workspace/gitExclude.d.ts +2 -0
- package/dist/workspace/gitExclude.js +19 -0
- package/dist/workspace/gitExclude.js.map +1 -0
- package/dist/workspace/host.d.ts +14 -0
- package/dist/workspace/host.js +13 -0
- package/dist/workspace/host.js.map +1 -0
- package/dist/workspace/index.d.ts +12 -0
- package/dist/workspace/index.js +12 -0
- package/dist/workspace/index.js.map +1 -0
- package/dist/workspace/local.d.ts +81 -0
- package/dist/workspace/local.js +287 -0
- package/dist/workspace/local.js.map +1 -0
- package/dist/workspace/modular.d.ts +95 -0
- package/dist/workspace/modular.js +301 -0
- package/dist/workspace/modular.js.map +1 -0
- package/dist/workspace/operations.d.ts +35 -0
- package/dist/workspace/operations.js +57 -0
- package/dist/workspace/operations.js.map +1 -0
- package/dist/workspace/origin.d.ts +20 -0
- package/dist/workspace/origin.js +19 -0
- package/dist/workspace/origin.js.map +1 -0
- package/package.json +22 -7
- package/dist/feature-model/convert.d.ts +0 -35
- package/dist/feature-model/convert.js +0 -47
- package/dist/feature-model/convert.js.map +0 -1
- package/dist/feature-model/engine.d.ts +0 -60
- package/dist/feature-model/engine.js +0 -139
- package/dist/feature-model/engine.js.map +0 -1
- package/dist/feature-model/inspect.d.ts +0 -67
- package/dist/feature-model/inspect.js +0 -113
- package/dist/feature-model/inspect.js.map +0 -1
- package/dist/feature-model/io.d.ts +0 -66
- package/dist/feature-model/io.js +0 -92
- package/dist/feature-model/io.js.map +0 -1
- package/dist/feature-model/parse.d.ts +0 -30
- package/dist/feature-model/parse.js +0 -36
- package/dist/feature-model/parse.js.map +0 -1
- package/dist/feature-model/text.d.ts +0 -54
- package/dist/feature-model/text.js +0 -126
- package/dist/feature-model/text.js.map +0 -1
- package/dist/line/templates/metamodels/dataModel/extra.js +0 -328
- package/dist/line/templates/metamodels/dataModel/transformation.js +0 -211
- package/dist/line/templates/metamodels/sensor/extra.js +0 -36
- package/dist/line/templates/metamodels/sensor/transformation.js +0 -47
- package/dist/selection/selection.d.ts +0 -126
- package/dist/selection/selection.js +0 -152
- package/dist/selection/selection.js.map +0 -1
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { createModuleRegistry, createMetamodelRegistry } from './registry.js';
|
|
2
|
+
export type { PackageRegistry, LoadedPackage } from './registry.js';
|
|
3
|
+
export { createRoutingSource } from './routing.js';
|
|
4
|
+
export { createMemoryCatalog, createFileCatalog, registerPackage, registerLocation } from './catalog.js';
|
|
5
|
+
export type { PackageCatalog } from './catalog.js';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { createModuleRegistry, createMetamodelRegistry } from './registry.js';
|
|
2
|
+
export { createRoutingSource } from './routing.js';
|
|
3
|
+
export { createMemoryCatalog, createFileCatalog, registerPackage, registerLocation } from './catalog.js';
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/registry/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAA;AAE7E,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAClD,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA","sourcesContent":["export { createModuleRegistry, createMetamodelRegistry } from './registry.js'\nexport type { PackageRegistry, LoadedPackage } from './registry.js'\nexport { createRoutingSource } from './routing.js'\nexport { createMemoryCatalog, createFileCatalog, registerPackage, registerLocation } from './catalog.js'\nexport type { PackageCatalog } from './catalog.js'\n"]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { MetamodelManifest, ModuleManifest, PackageFiles, PackageKind, PackageSource } from '../types.js';
|
|
2
|
+
/** One version of a package, read and checked: its manifest is valid and says the version it was published under. */
|
|
3
|
+
export interface LoadedPackage<Manifest> {
|
|
4
|
+
readonly location: string;
|
|
5
|
+
readonly version: string;
|
|
6
|
+
readonly files: PackageFiles;
|
|
7
|
+
readonly manifest: Manifest;
|
|
8
|
+
/** An immutable id of that version (a commit sha), when the host gives one. */
|
|
9
|
+
readonly revision?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Where the packages of ONE kind come from. The module registry and the metamodel registry are separate pieces: each knows what its
|
|
13
|
+
* kind looks like (the manifest file, how it is read) and nothing about the other. Both are built on a `PackageSource`, which only
|
|
14
|
+
* knows how to reach a host (GitLab, GitHub, a folder...).
|
|
15
|
+
*/
|
|
16
|
+
export interface PackageRegistry<Manifest> {
|
|
17
|
+
readonly kind: PackageKind;
|
|
18
|
+
/** The published versions of a package, as plain `x.y.z`. */
|
|
19
|
+
versions: (args: {
|
|
20
|
+
location: string;
|
|
21
|
+
}) => Promise<string[]>;
|
|
22
|
+
load: (args: {
|
|
23
|
+
location: string;
|
|
24
|
+
version: string;
|
|
25
|
+
}) => Promise<LoadedPackage<Manifest>>;
|
|
26
|
+
}
|
|
27
|
+
/** The modules of a registry: `module.json` at the root of each package. */
|
|
28
|
+
export declare const createModuleRegistry: ({ source }: {
|
|
29
|
+
source: PackageSource;
|
|
30
|
+
}) => PackageRegistry<ModuleManifest>;
|
|
31
|
+
/** The metamodels of a registry: `metamodel.json` and the grammars at the root of each package. */
|
|
32
|
+
export declare const createMetamodelRegistry: ({ source }: {
|
|
33
|
+
source: PackageSource;
|
|
34
|
+
}) => PackageRegistry<MetamodelManifest>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ModuleResolutionError } from '../../errors.js';
|
|
2
|
+
import { METAMODEL_MANIFEST_PATH, MODULE_MANIFEST_PATH, parseMetamodelManifest, parseModuleManifest } from '../packages/manifests.js';
|
|
3
|
+
import { readPackageText } from '../packages/source.js';
|
|
4
|
+
const createRegistry = ({ kind, manifestPath, parse, source }) => ({
|
|
5
|
+
kind,
|
|
6
|
+
versions: ({ location }) => source.listVersions({ location }),
|
|
7
|
+
load: async ({ location, version }) => {
|
|
8
|
+
let files;
|
|
9
|
+
try {
|
|
10
|
+
files = await source.open({ location, version });
|
|
11
|
+
}
|
|
12
|
+
catch (error) {
|
|
13
|
+
throw new ModuleResolutionError(`Could not download ${kind} ${location}@${version}: ${error.message}`, { cause: error });
|
|
14
|
+
}
|
|
15
|
+
const content = await readPackageText({ files, path: manifestPath });
|
|
16
|
+
if (content === undefined) {
|
|
17
|
+
throw new ModuleResolutionError(`${location}@${version} has no ${manifestPath}: it is not a ${kind}.`);
|
|
18
|
+
}
|
|
19
|
+
let manifest;
|
|
20
|
+
try {
|
|
21
|
+
manifest = parse({ content });
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
throw new ModuleResolutionError(`${location}@${version}: ${error.message}`, { cause: error });
|
|
25
|
+
}
|
|
26
|
+
if (manifest.version !== version) {
|
|
27
|
+
throw new ModuleResolutionError(`${location}: the version ${version} (its tag) declares version ${manifest.version} in ${manifestPath}.`);
|
|
28
|
+
}
|
|
29
|
+
const revision = await source.revision?.({ location, version });
|
|
30
|
+
return { location, version, files, manifest, ...(revision === undefined ? {} : { revision }) };
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
/** The modules of a registry: `module.json` at the root of each package. */
|
|
34
|
+
export const createModuleRegistry = ({ source }) => createRegistry({ kind: 'module', manifestPath: MODULE_MANIFEST_PATH, parse: parseModuleManifest, source });
|
|
35
|
+
/** The metamodels of a registry: `metamodel.json` and the grammars at the root of each package. */
|
|
36
|
+
export const createMetamodelRegistry = ({ source }) => createRegistry({ kind: 'metamodel', manifestPath: METAMODEL_MANIFEST_PATH, parse: parseMetamodelManifest, source });
|
|
37
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../src/modules/registry/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAA;AACvD,OAAO,EACL,uBAAuB,EACvB,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,EACpB,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAyBvD,MAAM,cAAc,GAAG,CAAgD,EACrE,IAAI,EACJ,YAAY,EACZ,KAAK,EACL,MAAM,EAMP,EAA6B,EAAE,CAAC,CAAC;IAC9B,IAAI;IACJ,QAAQ,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,QAAQ,EAAE,CAAC;IAC7D,IAAI,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE;QACpC,IAAI,KAAmB,CAAA;QACvB,IAAI,CAAC;YACH,KAAK,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAA;QAClD,CAA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CAAA;AAEJ,4EAA4E;AAC5E,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,EAAE,MAAM,EAA6B,EAAmC,EAAE,CAC7G,cAAc,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,YAAY,EAAE,oBAAoB,EAAE,KAAK,EAAE,mBAAmB,EAAE,MAAM,EAAE,CAAC,CAAA;AAE5G,mGAAmG;AACnG,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,EAAE,MAAM,EAA6B,EAAsC,EAAE,CACnH,cAAc,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,YAAY,EAAE,uBAAuB,EAAE,KAAK,EAAE,sBAAsB,EAAE,MAAM,EAAE,CAAC,CAAA","sourcesContent":["import { ModuleResolutionError } from '../../errors.js'\nimport {\n METAMODEL_MANIFEST_PATH,\n MODULE_MANIFEST_PATH,\n parseMetamodelManifest,\n parseModuleManifest\n} from '../packages/manifests.js'\nimport { readPackageText } from '../packages/source.js'\nimport type { MetamodelManifest, ModuleManifest, PackageFiles, PackageKind, PackageSource } from '../types.js'\n\n/** One version of a package, read and checked: its manifest is valid and says the version it was published under. */\nexport interface LoadedPackage<Manifest> {\n readonly location: string\n readonly version: string\n readonly files: PackageFiles\n readonly manifest: Manifest\n /** An immutable id of that version (a commit sha), when the host gives one. */\n readonly revision?: string\n}\n\n/**\n * Where the packages of ONE kind come from. The module registry and the metamodel registry are separate pieces: each knows what its\n * kind looks like (the manifest file, how it is read) and nothing about the other. Both are built on a `PackageSource`, which only\n * knows how to reach a host (GitLab, GitHub, a folder...).\n */\nexport interface PackageRegistry<Manifest> {\n readonly kind: PackageKind\n /** The published versions of a package, as plain `x.y.z`. */\n versions: (args: { location: string }) => Promise<string[]>\n load: (args: { location: string, version: string }) => Promise<LoadedPackage<Manifest>>\n}\n\nconst createRegistry = <Manifest extends { readonly version: string }>({\n kind,\n manifestPath,\n parse,\n source\n}: {\n kind: PackageKind\n manifestPath: string\n parse: (args: { content: string }) => Manifest\n source: PackageSource\n}): PackageRegistry<Manifest> => ({\n kind,\n versions: ({ location }) => source.listVersions({ location }),\n load: async ({ location, version }) => {\n let files: PackageFiles\n try {\n files = await source.open({ location, version })\n } catch (error) {\n throw new ModuleResolutionError(`Could not download ${kind} ${location}@${version}: ${(error as Error).message}`, { cause: error })\n }\n const content = await readPackageText({ files, path: manifestPath })\n if (content === undefined) {\n throw new ModuleResolutionError(`${location}@${version} has no ${manifestPath}: it is not a ${kind}.`)\n }\n let manifest: Manifest\n try {\n manifest = parse({ content })\n } catch (error) {\n throw new ModuleResolutionError(`${location}@${version}: ${(error as Error).message}`, { cause: error })\n }\n if (manifest.version !== version) {\n throw new ModuleResolutionError(\n `${location}: the version ${version} (its tag) declares version ${manifest.version} in ${manifestPath}.`\n )\n }\n const revision = await source.revision?.({ location, version })\n return { location, version, files, manifest, ...(revision === undefined ? {} : { revision }) }\n }\n })\n\n/** The modules of a registry: `module.json` at the root of each package. */\nexport const createModuleRegistry = ({ source }: { source: PackageSource }): PackageRegistry<ModuleManifest> =>\n createRegistry({ kind: 'module', manifestPath: MODULE_MANIFEST_PATH, parse: parseModuleManifest, source })\n\n/** The metamodels of a registry: `metamodel.json` and the grammars at the root of each package. */\nexport const createMetamodelRegistry = ({ source }: { source: PackageSource }): PackageRegistry<MetamodelManifest> =>\n createRegistry({ kind: 'metamodel', manifestPath: METAMODEL_MANIFEST_PATH, parse: parseMetamodelManifest, source })\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { PackageSource } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* One `PackageSource` made of several, one per host: a location says where it lives with its scheme (`gitlab:group/project`,
|
|
4
|
+
* `github:owner/repo`, `file:modules/core`), so a module on GitHub can require a metamodel on GitLab and the SPL does not care.
|
|
5
|
+
*/
|
|
6
|
+
export declare const createRoutingSource: ({ sources }: {
|
|
7
|
+
sources: Readonly<Record<string, PackageSource>>;
|
|
8
|
+
}) => PackageSource;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ModuleResolutionError } from '../../errors.js';
|
|
2
|
+
const SCHEME = /^([a-z][a-z0-9+.-]*):/i;
|
|
3
|
+
/**
|
|
4
|
+
* One `PackageSource` made of several, one per host: a location says where it lives with its scheme (`gitlab:group/project`,
|
|
5
|
+
* `github:owner/repo`, `file:modules/core`), so a module on GitHub can require a metamodel on GitLab and the SPL does not care.
|
|
6
|
+
*/
|
|
7
|
+
export const createRoutingSource = ({ sources }) => {
|
|
8
|
+
const sourceOf = (location) => {
|
|
9
|
+
const scheme = SCHEME.exec(location)?.[1]?.toLowerCase();
|
|
10
|
+
const source = scheme === undefined ? undefined : sources[scheme];
|
|
11
|
+
if (source === undefined) {
|
|
12
|
+
const known = Object.keys(sources).map((name) => `${name}:`).join(', ');
|
|
13
|
+
throw new ModuleResolutionError(`"${location}" is not a location any registry here reads (${known}).`);
|
|
14
|
+
}
|
|
15
|
+
return source;
|
|
16
|
+
};
|
|
17
|
+
return {
|
|
18
|
+
listVersions: (args) => sourceOf(args.location).listVersions(args),
|
|
19
|
+
open: (args) => sourceOf(args.location).open(args),
|
|
20
|
+
revision: (args) => sourceOf(args.location).revision?.(args) ?? Promise.resolve(undefined)
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=routing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routing.js","sourceRoot":"","sources":["../../../src/modules/registry/routing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAA;AAGvD,MAAM,MAAM,GAAG,wBAAwB,CAAA;AAEvC;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,EAAE,OAAO,EAAwD,EAAiB,EAAE;IACtH,MAAM,QAAQ,GAAG,CAAC,QAAgB,EAAiB,EAAE;QACnD,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAA;QACxD,MAAM,MAAM,GAAG,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;QACjE,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YACzB,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;YACvE,MAAM,IAAI,qBAAqB,CAAC,IAAI,QAAQ,gDAAgD,KAAK,IAAI,CAAC,CAAA;QACxG,CAAC;QACD,OAAO,MAAM,CAAA;IACf,CAAC,CAAA;IACD,OAAO;QACL,YAAY,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC;QAClE,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;QAClD,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC;KAC3F,CAAA;AACH,CAAC,CAAA","sourcesContent":["import { ModuleResolutionError } from '../../errors.js'\nimport type { PackageSource } from '../types.js'\n\nconst SCHEME = /^([a-z][a-z0-9+.-]*):/i\n\n/**\n * One `PackageSource` made of several, one per host: a location says where it lives with its scheme (`gitlab:group/project`,\n * `github:owner/repo`, `file:modules/core`), so a module on GitHub can require a metamodel on GitLab and the SPL does not care.\n */\nexport const createRoutingSource = ({ sources }: { sources: Readonly<Record<string, PackageSource>> }): PackageSource => {\n const sourceOf = (location: string): PackageSource => {\n const scheme = SCHEME.exec(location)?.[1]?.toLowerCase()\n const source = scheme === undefined ? undefined : sources[scheme]\n if (source === undefined) {\n const known = Object.keys(sources).map((name) => `${name}:`).join(', ')\n throw new ModuleResolutionError(`\"${location}\" is not a location any registry here reads (${known}).`)\n }\n return source\n }\n return {\n listVersions: (args) => sourceOf(args.location).listVersions(args),\n open: (args) => sourceOf(args.location).open(args),\n revision: (args) => sourceOf(args.location).revision?.(args) ?? Promise.resolve(undefined)\n }\n}\n"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { LoadedPackage, PackageRegistry } from '../registry/registry.js';
|
|
2
|
+
import type { Lock } from '../types.js';
|
|
3
|
+
/** A range somebody asks of a package, and who asks. */
|
|
4
|
+
export interface Wanted {
|
|
5
|
+
readonly range: string;
|
|
6
|
+
readonly by: string;
|
|
7
|
+
}
|
|
8
|
+
export interface Closure<Manifest> {
|
|
9
|
+
/** Every package needed, each at the one version chosen for it. */
|
|
10
|
+
readonly packages: ReadonlyMap<string, LoadedPackage<Manifest>>;
|
|
11
|
+
/** Who asked for each, with which range. */
|
|
12
|
+
readonly wanted: ReadonlyMap<string, readonly Wanted[]>;
|
|
13
|
+
/** Locations, dependencies before dependants. */
|
|
14
|
+
readonly order: readonly string[];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The packages of ONE registry needed to satisfy `roots`, each at exactly one version: the highest that satisfies the ranges of everyone
|
|
18
|
+
* who asks for it. What a package requires of its own kind is given by `requires` (absolute locations). `lock` is kept wherever it still fits.
|
|
19
|
+
*
|
|
20
|
+
* Each round walks the graph with the versions chosen so far, collects every range asked of every package, and chooses again. It is done
|
|
21
|
+
* when a round chooses what the last one did: the choices are consistent with the dependencies they bring in.
|
|
22
|
+
*/
|
|
23
|
+
export declare const resolveClosure: <Manifest>({ roots, registry, requires, lock }: {
|
|
24
|
+
roots: Readonly<Record<string, readonly Wanted[]>>;
|
|
25
|
+
registry: PackageRegistry<Manifest>;
|
|
26
|
+
requires: (pkg: LoadedPackage<Manifest>) => Record<string, string>;
|
|
27
|
+
lock?: Lock;
|
|
28
|
+
}) => Promise<Closure<Manifest>>;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import semver from 'semver';
|
|
2
|
+
import { ModuleResolutionError } from '../../errors.js';
|
|
3
|
+
const MAX_ROUNDS = 100;
|
|
4
|
+
const describeWanted = (wanted) => wanted.map(({ range, by }) => `${range} (required by ${by})`).join(', ');
|
|
5
|
+
/**
|
|
6
|
+
* The version to use: the locked one while it still satisfies every range (so resolving twice gives the same answer), else the highest
|
|
7
|
+
* published version that does.
|
|
8
|
+
*/
|
|
9
|
+
const pickVersion = ({ location, available, wanted, locked }) => {
|
|
10
|
+
const valid = available.filter((version) => semver.valid(version) !== null);
|
|
11
|
+
const fits = valid.filter((version) => wanted.every(({ range }) => semver.satisfies(version, range)));
|
|
12
|
+
if (locked !== undefined && fits.includes(locked))
|
|
13
|
+
return locked;
|
|
14
|
+
const best = semver.rsort([...fits])[0];
|
|
15
|
+
if (best !== undefined)
|
|
16
|
+
return best;
|
|
17
|
+
const have = valid.length === 0 ? 'it has no published versions' : `available: ${semver.sort([...valid]).join(', ')}`;
|
|
18
|
+
throw new ModuleResolutionError(`No version of ${location} satisfies ${describeWanted(wanted)}; ${have}.`);
|
|
19
|
+
};
|
|
20
|
+
const sameMap = (a, b) => a.size === b.size && [...a].every(([key, value]) => b.get(key) === value);
|
|
21
|
+
/**
|
|
22
|
+
* The packages of ONE registry needed to satisfy `roots`, each at exactly one version: the highest that satisfies the ranges of everyone
|
|
23
|
+
* who asks for it. What a package requires of its own kind is given by `requires` (absolute locations). `lock` is kept wherever it still fits.
|
|
24
|
+
*
|
|
25
|
+
* Each round walks the graph with the versions chosen so far, collects every range asked of every package, and chooses again. It is done
|
|
26
|
+
* when a round chooses what the last one did: the choices are consistent with the dependencies they bring in.
|
|
27
|
+
*/
|
|
28
|
+
export const resolveClosure = async ({ roots, registry, requires, lock }) => {
|
|
29
|
+
const available = new Map();
|
|
30
|
+
const loaded = new Map();
|
|
31
|
+
const versionsOf = async (location) => {
|
|
32
|
+
const known = available.get(location);
|
|
33
|
+
if (known !== undefined)
|
|
34
|
+
return known;
|
|
35
|
+
const versions = await registry.versions({ location });
|
|
36
|
+
available.set(location, versions);
|
|
37
|
+
return versions;
|
|
38
|
+
};
|
|
39
|
+
const load = async (location, version) => {
|
|
40
|
+
const key = `${location}@${version}`;
|
|
41
|
+
const cached = loaded.get(key);
|
|
42
|
+
if (cached !== undefined)
|
|
43
|
+
return cached;
|
|
44
|
+
const pkg = await registry.load({ location, version });
|
|
45
|
+
loaded.set(key, pkg);
|
|
46
|
+
return pkg;
|
|
47
|
+
};
|
|
48
|
+
let chosen = new Map();
|
|
49
|
+
let wantedNow = new Map();
|
|
50
|
+
for (let round = 0;; round++) {
|
|
51
|
+
if (round >= MAX_ROUNDS)
|
|
52
|
+
throw new ModuleResolutionError('The versions of the modules do not settle: their requirements contradict each other.');
|
|
53
|
+
const wanted = new Map();
|
|
54
|
+
const visited = new Set();
|
|
55
|
+
const ask = async (location, range, by) => {
|
|
56
|
+
wanted.set(location, [...(wanted.get(location) ?? []), { range, by }]);
|
|
57
|
+
if (visited.has(location))
|
|
58
|
+
return;
|
|
59
|
+
visited.add(location);
|
|
60
|
+
const version = chosen.get(location);
|
|
61
|
+
if (version === undefined)
|
|
62
|
+
return; // its own requirements are found in the next round
|
|
63
|
+
const pkg = await load(location, version);
|
|
64
|
+
const who = `${location}@${version}`;
|
|
65
|
+
for (const [other, otherRange] of Object.entries(requires(pkg)))
|
|
66
|
+
await ask(other, otherRange, who);
|
|
67
|
+
};
|
|
68
|
+
for (const [location, asked] of Object.entries(roots)) {
|
|
69
|
+
for (const { range, by } of asked)
|
|
70
|
+
await ask(location, range, by);
|
|
71
|
+
}
|
|
72
|
+
const next = new Map();
|
|
73
|
+
for (const [location, asked] of wanted) {
|
|
74
|
+
next.set(location, pickVersion({ location, available: await versionsOf(location), wanted: asked, locked: lock?.packages[location]?.version }));
|
|
75
|
+
}
|
|
76
|
+
wantedNow = wanted;
|
|
77
|
+
if (sameMap(next, chosen))
|
|
78
|
+
break;
|
|
79
|
+
chosen = next;
|
|
80
|
+
}
|
|
81
|
+
// everything that is chosen has been loaded by the last (consistent) round
|
|
82
|
+
const packages = new Map();
|
|
83
|
+
for (const [location, version] of chosen)
|
|
84
|
+
packages.set(location, await load(location, version));
|
|
85
|
+
// dependencies before dependants; a package that is reached again while it is being visited is a cycle
|
|
86
|
+
const order = [];
|
|
87
|
+
const state = new Map();
|
|
88
|
+
const visit = (location, trail) => {
|
|
89
|
+
const status = state.get(location);
|
|
90
|
+
if (status === 'done')
|
|
91
|
+
return;
|
|
92
|
+
if (status === 'visiting') {
|
|
93
|
+
throw new ModuleResolutionError(`Circular requirement: ${[...trail.slice(trail.indexOf(location)), location].join(' -> ')}`);
|
|
94
|
+
}
|
|
95
|
+
state.set(location, 'visiting');
|
|
96
|
+
for (const dependency of Object.keys(requires(packages.get(location))).sort())
|
|
97
|
+
visit(dependency, [...trail, location]);
|
|
98
|
+
state.set(location, 'done');
|
|
99
|
+
order.push(location);
|
|
100
|
+
};
|
|
101
|
+
for (const location of Object.keys(roots).sort())
|
|
102
|
+
visit(location, []);
|
|
103
|
+
return { packages, wanted: wantedNow, order };
|
|
104
|
+
};
|
|
105
|
+
//# sourceMappingURL=closure.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"closure.js","sourceRoot":"","sources":["../../../src/modules/resolution/closure.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAA;AAC3B,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAA;AAmBvD,MAAM,UAAU,GAAG,GAAG,CAAA;AAEtB,MAAM,cAAc,GAAG,CAAC,MAAyB,EAAU,EAAE,CAC3D,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,GAAG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AAC,yBAAyB,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;QAC9H,CAAC;QACD,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAA;QAC/B,KAAK,MAAM,UAAU,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAE,CAAC,CAAC,CAAC,IAAI,EAAE;YAAE,KAAK,CAAC,UAAU,EAAE,CAAC,GAAG,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAA;QACvH,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;QAC3B,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IACtB,CAAC,CAAA;IACD,KAAK,MAAM,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE;QAAE,KAAK,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA;IAErE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,CAAA;AAC/C,CAAC,CAAA","sourcesContent":["import semver from 'semver'\nimport { ModuleResolutionError } from '../../errors.js'\nimport type { LoadedPackage, PackageRegistry } from '../registry/registry.js'\nimport type { Lock } from '../types.js'\n\n/** A range somebody asks of a package, and who asks. */\nexport interface Wanted {\n readonly range: string\n readonly by: string\n}\n\nexport interface Closure<Manifest> {\n /** Every package needed, each at the one version chosen for it. */\n readonly packages: ReadonlyMap<string, LoadedPackage<Manifest>>\n /** Who asked for each, with which range. */\n readonly wanted: ReadonlyMap<string, readonly Wanted[]>\n /** Locations, dependencies before dependants. */\n readonly order: readonly string[]\n}\n\nconst MAX_ROUNDS = 100\n\nconst describeWanted = (wanted: readonly Wanted[]): string =>\n wanted.map(({ range, by }) => `${range} (required by ${by})`).join(', ')\n\n/**\n * The version to use: the locked one while it still satisfies every range (so resolving twice gives the same answer), else the highest\n * published version that does.\n */\nconst pickVersion = ({\n location,\n available,\n wanted,\n locked\n}: {\n location: string\n available: readonly string[]\n wanted: readonly Wanted[]\n locked: string | undefined\n}): string => {\n const valid = available.filter((version) => semver.valid(version) !== null)\n const fits = valid.filter((version) => wanted.every(({ range }) => semver.satisfies(version, range)))\n if (locked !== undefined && fits.includes(locked)) return locked\n const best = semver.rsort([...fits])[0]\n if (best !== undefined) return best\n const have = valid.length === 0 ? 'it has no published versions' : `available: ${semver.sort([...valid]).join(', ')}`\n throw new ModuleResolutionError(`No version of ${location} satisfies ${describeWanted(wanted)}; ${have}.`)\n}\n\nconst sameMap = (a: ReadonlyMap<string, string>, b: ReadonlyMap<string, string>): boolean =>\n a.size === b.size && [...a].every(([key, value]) => b.get(key) === value)\n\n/**\n * The packages of ONE registry needed to satisfy `roots`, each at exactly one version: the highest that satisfies the ranges of everyone\n * who asks for it. What a package requires of its own kind is given by `requires` (absolute locations). `lock` is kept wherever it still fits.\n *\n * Each round walks the graph with the versions chosen so far, collects every range asked of every package, and chooses again. It is done\n * when a round chooses what the last one did: the choices are consistent with the dependencies they bring in.\n */\nexport const resolveClosure = async <Manifest>({\n roots,\n registry,\n requires,\n lock\n}: {\n roots: Readonly<Record<string, readonly Wanted[]>>\n registry: PackageRegistry<Manifest>\n requires: (pkg: LoadedPackage<Manifest>) => Record<string, string>\n lock?: Lock\n}): Promise<Closure<Manifest>> => {\n const available = new Map<string, string[]>()\n const loaded = new Map<string, LoadedPackage<Manifest>>()\n\n const versionsOf = async (location: string): Promise<string[]> => {\n const known = available.get(location)\n if (known !== undefined) return known\n const versions = await registry.versions({ location })\n available.set(location, versions)\n return versions\n }\n\n const load = async (location: string, version: string): Promise<LoadedPackage<Manifest>> => {\n const key = `${location}@${version}`\n const cached = loaded.get(key)\n if (cached !== undefined) return cached\n const pkg = await registry.load({ location, version })\n loaded.set(key, pkg)\n return pkg\n }\n\n let chosen = new Map<string, string>()\n let wantedNow = new Map<string, Wanted[]>()\n for (let round = 0; ; round++) {\n if (round >= MAX_ROUNDS) throw new ModuleResolutionError('The versions of the modules do not settle: their requirements contradict each other.')\n const wanted = new Map<string, Wanted[]>()\n const visited = new Set<string>()\n const ask = async (location: string, range: string, by: string): Promise<void> => {\n wanted.set(location, [...(wanted.get(location) ?? []), { range, by }])\n if (visited.has(location)) return\n visited.add(location)\n const version = chosen.get(location)\n if (version === undefined) return // its own requirements are found in the next round\n const pkg = await load(location, version)\n const who = `${location}@${version}`\n for (const [other, otherRange] of Object.entries(requires(pkg))) await ask(other, otherRange, who)\n }\n for (const [location, asked] of Object.entries(roots)) {\n for (const { range, by } of asked) await ask(location, range, by)\n }\n\n const next = new Map<string, string>()\n for (const [location, asked] of wanted) {\n next.set(location, pickVersion({ location, available: await versionsOf(location), wanted: asked, locked: lock?.packages[location]?.version }))\n }\n wantedNow = wanted\n if (sameMap(next, chosen)) break\n chosen = next\n }\n\n // everything that is chosen has been loaded by the last (consistent) round\n const packages = new Map<string, LoadedPackage<Manifest>>()\n for (const [location, version] of chosen) packages.set(location, await load(location, version))\n\n // dependencies before dependants; a package that is reached again while it is being visited is a cycle\n const order: string[] = []\n const state = new Map<string, 'visiting' | 'done'>()\n const visit = (location: string, trail: readonly string[]): void => {\n const status = state.get(location)\n if (status === 'done') return\n if (status === 'visiting') {\n throw new ModuleResolutionError(`Circular requirement: ${[...trail.slice(trail.indexOf(location)), location].join(' -> ')}`)\n }\n state.set(location, 'visiting')\n for (const dependency of Object.keys(requires(packages.get(location)!)).sort()) visit(dependency, [...trail, location])\n state.set(location, 'done')\n order.push(location)\n }\n for (const location of Object.keys(roots).sort()) visit(location, [])\n\n return { packages, wanted: wantedNow, order }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/resolution/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAExD,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA","sourcesContent":["export { resolveSpl, isLockCurrent } from './resolve.js'\nexport type { ResolutionProgress } from './resolve.js'\nexport { resolveModules, resolveMetamodels } from './resolvers.js'\nexport type { Closure, Wanted } from './closure.js'\n"]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type PackageRegistry } from '../registry/registry.js';
|
|
2
|
+
import type { Lock, MetamodelManifest, ModuleManifest, PackageKind, PackageSource, ResolvedSpl, SplManifest } from '../types.js';
|
|
3
|
+
/** A package whose download just started, reported as `resolveSpl` finds out which one and at which version. */
|
|
4
|
+
export interface ResolutionProgress {
|
|
5
|
+
readonly kind: PackageKind;
|
|
6
|
+
readonly location: string;
|
|
7
|
+
readonly version: string;
|
|
8
|
+
/** The modules that declare this metamodel; none for a module, or for a metamodel only the SPL or another metamodel asks for. */
|
|
9
|
+
readonly requiredBy: readonly string[];
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The closure of the modules of an SPL: the transitive modules and metamodels, each at exactly one version.
|
|
13
|
+
*
|
|
14
|
+
* It is two resolutions, one per registry: the modules first (they decide which metamodels are needed), then the metamodels they need.
|
|
15
|
+
* Every package is used once (a metamodel is composed by name, so two versions of one cannot live together): the version is the highest
|
|
16
|
+
* one that satisfies the ranges of everyone who asks for it. `lock` (from a previous resolution) is kept wherever it still fits.
|
|
17
|
+
*
|
|
18
|
+
* Modules and metamodels come from the same `source` unless a registry is given for either. `onProgress` is told of each package as
|
|
19
|
+
* its download starts (once per package, however many rounds the resolution takes to settle on its version).
|
|
20
|
+
*/
|
|
21
|
+
export declare const resolveSpl: ({ spl, source, lock, onProgress, moduleRegistry, metamodelRegistry }: {
|
|
22
|
+
spl: SplManifest;
|
|
23
|
+
source: PackageSource;
|
|
24
|
+
lock?: Lock;
|
|
25
|
+
onProgress?: (progress: ResolutionProgress) => void | Promise<void>;
|
|
26
|
+
moduleRegistry?: PackageRegistry<ModuleManifest>;
|
|
27
|
+
metamodelRegistry?: PackageRegistry<MetamodelManifest>;
|
|
28
|
+
}) => Promise<ResolvedSpl>;
|
|
29
|
+
/** Whether a lock still describes what resolving the SPL would give (same packages, same versions). */
|
|
30
|
+
export declare const isLockCurrent: ({ lock, resolved }: {
|
|
31
|
+
lock: Lock;
|
|
32
|
+
resolved: ResolvedSpl;
|
|
33
|
+
}) => boolean;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { ModuleResolutionError } from '../../errors.js';
|
|
2
|
+
import { absoluteRequires } from '../packages/location.js';
|
|
3
|
+
import { createMetamodelRegistry, createModuleRegistry } from '../registry/registry.js';
|
|
4
|
+
import { resolveMetamodels, resolveModules } from './resolvers.js';
|
|
5
|
+
const withProgress = (registry, onProgress, requiredBy = () => []) => onProgress === undefined ? registry : {
|
|
6
|
+
...registry,
|
|
7
|
+
load: async (args) => {
|
|
8
|
+
await onProgress({ kind: registry.kind, location: args.location, version: args.version, requiredBy: requiredBy(args.location) });
|
|
9
|
+
return registry.load(args);
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* The closure of the modules of an SPL: the transitive modules and metamodels, each at exactly one version.
|
|
14
|
+
*
|
|
15
|
+
* It is two resolutions, one per registry: the modules first (they decide which metamodels are needed), then the metamodels they need.
|
|
16
|
+
* Every package is used once (a metamodel is composed by name, so two versions of one cannot live together): the version is the highest
|
|
17
|
+
* one that satisfies the ranges of everyone who asks for it. `lock` (from a previous resolution) is kept wherever it still fits.
|
|
18
|
+
*
|
|
19
|
+
* Modules and metamodels come from the same `source` unless a registry is given for either. `onProgress` is told of each package as
|
|
20
|
+
* its download starts (once per package, however many rounds the resolution takes to settle on its version).
|
|
21
|
+
*/
|
|
22
|
+
export const resolveSpl = async ({ spl, source, lock, onProgress, moduleRegistry = createModuleRegistry({ source }), metamodelRegistry = createMetamodelRegistry({ source }) }) => {
|
|
23
|
+
const moduleClosure = await resolveModules({ spl, registry: withProgress(moduleRegistry, onProgress), lock });
|
|
24
|
+
const loadedModules = moduleClosure.order.map((location) => moduleClosure.packages.get(location));
|
|
25
|
+
const modulesUsing = (metamodel) => loadedModules
|
|
26
|
+
.filter(({ location, manifest }) => metamodel in absoluteRequires({ kind: 'module', location, manifest }).metamodels)
|
|
27
|
+
.map(({ location }) => location);
|
|
28
|
+
const metamodelClosure = await resolveMetamodels({
|
|
29
|
+
spl,
|
|
30
|
+
modules: loadedModules,
|
|
31
|
+
registry: withProgress(metamodelRegistry, onProgress, modulesUsing),
|
|
32
|
+
lock
|
|
33
|
+
});
|
|
34
|
+
for (const location of metamodelClosure.order) {
|
|
35
|
+
if (moduleClosure.packages.has(location))
|
|
36
|
+
throw new ModuleResolutionError(`${location} is required as a module and as a metamodel.`);
|
|
37
|
+
}
|
|
38
|
+
const requiredBy = (closure, location) => (closure.wanted.get(location) ?? []).map(({ by }) => by);
|
|
39
|
+
const modules = moduleClosure.order.map((location) => {
|
|
40
|
+
const pkg = moduleClosure.packages.get(location);
|
|
41
|
+
return { kind: 'module', location, version: pkg.version, files: pkg.files, manifest: pkg.manifest, requiredBy: requiredBy(moduleClosure, location), ...(pkg.revision === undefined ? {} : { revision: pkg.revision }) };
|
|
42
|
+
});
|
|
43
|
+
const metamodels = metamodelClosure.order.map((location) => {
|
|
44
|
+
const pkg = metamodelClosure.packages.get(location);
|
|
45
|
+
return { kind: 'metamodel', location, version: pkg.version, files: pkg.files, manifest: pkg.manifest, requiredBy: requiredBy(metamodelClosure, location), ...(pkg.revision === undefined ? {} : { revision: pkg.revision }) };
|
|
46
|
+
});
|
|
47
|
+
const packages = {};
|
|
48
|
+
for (const pkg of [...modules, ...metamodels]) {
|
|
49
|
+
packages[pkg.location] = { kind: pkg.kind, version: pkg.version, ...(pkg.revision === undefined ? {} : { revision: pkg.revision }) };
|
|
50
|
+
}
|
|
51
|
+
return { spl, modules, metamodels, lock: { lockVersion: 1, packages } };
|
|
52
|
+
};
|
|
53
|
+
/** Whether a lock still describes what resolving the SPL would give (same packages, same versions). */
|
|
54
|
+
export const isLockCurrent = ({ lock, resolved }) => {
|
|
55
|
+
const a = Object.entries(lock.packages).map(([location, entry]) => `${location}@${entry.version}`).sort();
|
|
56
|
+
const b = Object.entries(resolved.lock.packages).map(([location, entry]) => `${location}@${entry.version}`).sort();
|
|
57
|
+
return a.length === b.length && a.every((value, index) => value === b[index]);
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=resolve.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve.js","sourceRoot":"","sources":["../../../src/modules/resolution/resolve.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAA;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAwB,MAAM,yBAAyB,CAAA;AAa7G,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAWlE,MAAM,YAAY,GAAG,CACnB,QAAmC,EACnC,UAAmE,EACnE,aAAsD,GAAG,EAAE,CAAC,EAAE,EACnC,EAAE,CAC7B,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;IACpC,GAAG,QAAQ;IACX,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;QACnB,MAAM,UAAU,CAAC,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,UAAU,EAAE,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;QAChI,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC5B,CAAC;CACF,CAA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IAAI,EAAE,CAAA;IAClH,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,CAAA;AAC/E,CAAC,CAAA","sourcesContent":["import { ModuleResolutionError } from '../../errors.js'\nimport { absoluteRequires } from '../packages/location.js'\nimport { createMetamodelRegistry, createModuleRegistry, type PackageRegistry } from '../registry/registry.js'\nimport type {\n Lock,\n LockEntry,\n MetamodelManifest,\n ModuleManifest,\n PackageKind,\n PackageSource,\n ResolvedMetamodel,\n ResolvedModule,\n ResolvedSpl,\n SplManifest\n} from '../types.js'\nimport { resolveMetamodels, resolveModules } from './resolvers.js'\n\n/** A package whose download just started, reported as `resolveSpl` finds out which one and at which version. */\nexport interface ResolutionProgress {\n readonly kind: PackageKind\n readonly location: string\n readonly version: string\n /** The modules that declare this metamodel; none for a module, or for a metamodel only the SPL or another metamodel asks for. */\n readonly requiredBy: readonly string[]\n}\n\nconst withProgress = <Manifest>(\n registry: PackageRegistry<Manifest>,\n onProgress?: (progress: ResolutionProgress) => void | Promise<void>,\n requiredBy: (location: string) => readonly string[] = () => []\n): PackageRegistry<Manifest> =>\n onProgress === undefined ? registry : {\n ...registry,\n load: async (args) => {\n await onProgress({ kind: registry.kind, location: args.location, version: args.version, requiredBy: requiredBy(args.location) })\n return registry.load(args)\n }\n }\n\n/**\n * The closure of the modules of an SPL: the transitive modules and metamodels, each at exactly one version.\n *\n * It is two resolutions, one per registry: the modules first (they decide which metamodels are needed), then the metamodels they need.\n * Every package is used once (a metamodel is composed by name, so two versions of one cannot live together): the version is the highest\n * one that satisfies the ranges of everyone who asks for it. `lock` (from a previous resolution) is kept wherever it still fits.\n *\n * Modules and metamodels come from the same `source` unless a registry is given for either. `onProgress` is told of each package as\n * its download starts (once per package, however many rounds the resolution takes to settle on its version).\n */\nexport const resolveSpl = async ({\n spl,\n source,\n lock,\n onProgress,\n moduleRegistry = createModuleRegistry({ source }),\n metamodelRegistry = createMetamodelRegistry({ source })\n}: {\n spl: SplManifest\n source: PackageSource\n lock?: Lock\n onProgress?: (progress: ResolutionProgress) => void | Promise<void>\n moduleRegistry?: PackageRegistry<ModuleManifest>\n metamodelRegistry?: PackageRegistry<MetamodelManifest>\n}): Promise<ResolvedSpl> => {\n const moduleClosure = await resolveModules({ spl, registry: withProgress(moduleRegistry, onProgress), lock })\n const loadedModules = moduleClosure.order.map((location) => moduleClosure.packages.get(location)!)\n const modulesUsing = (metamodel: string): string[] =>\n loadedModules\n .filter(({ location, manifest }) => metamodel in absoluteRequires({ kind: 'module', location, manifest }).metamodels)\n .map(({ location }) => location)\n const metamodelClosure = await resolveMetamodels({\n spl,\n modules: loadedModules,\n registry: withProgress(metamodelRegistry, onProgress, modulesUsing),\n lock\n })\n\n for (const location of metamodelClosure.order) {\n if (moduleClosure.packages.has(location)) throw new ModuleResolutionError(`${location} is required as a module and as a metamodel.`)\n }\n\n const requiredBy = (closure: { wanted: ReadonlyMap<string, readonly { by: string }[]> }, location: string): string[] =>\n (closure.wanted.get(location) ?? []).map(({ by }) => by)\n\n const modules: ResolvedModule[] = moduleClosure.order.map((location) => {\n const pkg = moduleClosure.packages.get(location)!\n return { kind: 'module', location, version: pkg.version, files: pkg.files, manifest: pkg.manifest, requiredBy: requiredBy(moduleClosure, location), ...(pkg.revision === undefined ? {} : { revision: pkg.revision }) }\n })\n const metamodels: ResolvedMetamodel[] = metamodelClosure.order.map((location) => {\n const pkg = metamodelClosure.packages.get(location)!\n return { kind: 'metamodel', location, version: pkg.version, files: pkg.files, manifest: pkg.manifest, requiredBy: requiredBy(metamodelClosure, location), ...(pkg.revision === undefined ? {} : { revision: pkg.revision }) }\n })\n\n const packages: Record<string, LockEntry> = {}\n for (const pkg of [...modules, ...metamodels]) {\n packages[pkg.location] = { kind: pkg.kind, version: pkg.version, ...(pkg.revision === undefined ? {} : { revision: pkg.revision }) }\n }\n return { spl, modules, metamodels, lock: { lockVersion: 1, packages } }\n}\n\n/** Whether a lock still describes what resolving the SPL would give (same packages, same versions). */\nexport const isLockCurrent = ({ lock, resolved }: { lock: Lock, resolved: ResolvedSpl }): boolean => {\n const a = Object.entries(lock.packages).map(([location, entry]) => `${location}@${entry.version}`).sort()\n const b = Object.entries(resolved.lock.packages).map(([location, entry]) => `${location}@${entry.version}`).sort()\n return a.length === b.length && a.every((value, index) => value === b[index])\n}\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { LoadedPackage, PackageRegistry } from '../registry/registry.js';
|
|
2
|
+
import type { Lock, MetamodelManifest, ModuleManifest, SplManifest } from '../types.js';
|
|
3
|
+
import { type Closure } from './closure.js';
|
|
4
|
+
/**
|
|
5
|
+
* The module resolver: the modules an SPL lists and, transitively, the modules those require. It only talks to the module registry, and
|
|
6
|
+
* knows nothing of metamodels.
|
|
7
|
+
*/
|
|
8
|
+
export declare const resolveModules: ({ spl, registry, lock }: {
|
|
9
|
+
spl: SplManifest;
|
|
10
|
+
registry: PackageRegistry<ModuleManifest>;
|
|
11
|
+
lock?: Lock;
|
|
12
|
+
}) => Promise<Closure<ModuleManifest>>;
|
|
13
|
+
/**
|
|
14
|
+
* The metamodel resolver: the metamodels the modules declare and, transitively, the ones their grammars import. It only talks to the
|
|
15
|
+
* metamodel registry, and is given the modules that were resolved (it does not choose them).
|
|
16
|
+
*/
|
|
17
|
+
export declare const resolveMetamodels: ({ spl, modules, registry, lock }: {
|
|
18
|
+
/** The SPL itself: the metamodels it lists directly are roots too. */
|
|
19
|
+
spl?: SplManifest;
|
|
20
|
+
modules: readonly LoadedPackage<ModuleManifest>[];
|
|
21
|
+
registry: PackageRegistry<MetamodelManifest>;
|
|
22
|
+
lock?: Lock;
|
|
23
|
+
}) => Promise<Closure<MetamodelManifest>>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { absoluteRequires } from '../packages/location.js';
|
|
2
|
+
import { resolveClosure } from './closure.js';
|
|
3
|
+
/**
|
|
4
|
+
* The module resolver: the modules an SPL lists and, transitively, the modules those require. It only talks to the module registry, and
|
|
5
|
+
* knows nothing of metamodels.
|
|
6
|
+
*/
|
|
7
|
+
export const resolveModules = ({ spl, registry, lock }) => resolveClosure({
|
|
8
|
+
roots: Object.fromEntries(Object.entries(spl.modules).map(([location, range]) => [location, [{ range, by: 'spl' }]])),
|
|
9
|
+
registry,
|
|
10
|
+
requires: (pkg) => absoluteRequires({ kind: 'module', location: pkg.location, manifest: pkg.manifest }).modules,
|
|
11
|
+
lock
|
|
12
|
+
});
|
|
13
|
+
/**
|
|
14
|
+
* The metamodel resolver: the metamodels the modules declare and, transitively, the ones their grammars import. It only talks to the
|
|
15
|
+
* metamodel registry, and is given the modules that were resolved (it does not choose them).
|
|
16
|
+
*/
|
|
17
|
+
export const resolveMetamodels = ({ spl, modules, registry, lock }) => {
|
|
18
|
+
const roots = {};
|
|
19
|
+
for (const [location, range] of Object.entries(spl?.metamodels ?? {}))
|
|
20
|
+
roots[location] = [{ range, by: 'spl' }];
|
|
21
|
+
for (const module of modules) {
|
|
22
|
+
const who = `${module.location}@${module.version}`;
|
|
23
|
+
for (const [location, range] of Object.entries(absoluteRequires({ kind: 'module', location: module.location, manifest: module.manifest }).metamodels)) {
|
|
24
|
+
roots[location] = [...(roots[location] ?? []), { range, by: who }];
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return resolveClosure({
|
|
28
|
+
roots,
|
|
29
|
+
registry,
|
|
30
|
+
requires: (pkg) => absoluteRequires({ kind: 'metamodel', location: pkg.location, manifest: pkg.manifest }).metamodels,
|
|
31
|
+
lock
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=resolvers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolvers.js","sourceRoot":"","sources":["../../../src/modules/resolution/resolvers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE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AAC,QAAQ,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,gBAAgB,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,UAAU,CAAC,EAAE,CAAC;YACtJ,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,CAAA;QACpE,CAAC;IACH,CAAC;IACD,OAAO,cAAc,CAAC;QACpB,KAAK;QACL,QAAQ;QACR,QAAQ,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,gBAAgB,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,UAAU;QACrH,IAAI;KACL,CAAC,CAAA;AACJ,CAAC,CAAA","sourcesContent":["import { absoluteRequires } from '../packages/location.js'\nimport type { LoadedPackage, PackageRegistry } from '../registry/registry.js'\nimport type { Lock, MetamodelManifest, ModuleManifest, SplManifest } from '../types.js'\nimport { resolveClosure, type Closure, type Wanted } from './closure.js'\n\n/**\n * The module resolver: the modules an SPL lists and, transitively, the modules those require. It only talks to the module registry, and\n * knows nothing of metamodels.\n */\nexport const resolveModules = ({\n spl,\n registry,\n lock\n}: {\n spl: SplManifest\n registry: PackageRegistry<ModuleManifest>\n lock?: Lock\n}): Promise<Closure<ModuleManifest>> =>\n resolveClosure({\n roots: Object.fromEntries(Object.entries(spl.modules).map(([location, range]) => [location, [{ range, by: 'spl' }]])),\n registry,\n requires: (pkg) => absoluteRequires({ kind: 'module', location: pkg.location, manifest: pkg.manifest }).modules,\n lock\n })\n\n/**\n * The metamodel resolver: the metamodels the modules declare and, transitively, the ones their grammars import. It only talks to the\n * metamodel registry, and is given the modules that were resolved (it does not choose them).\n */\nexport const resolveMetamodels = ({\n spl,\n modules,\n registry,\n lock\n}: {\n /** The SPL itself: the metamodels it lists directly are roots too. */\n spl?: SplManifest\n modules: readonly LoadedPackage<ModuleManifest>[]\n registry: PackageRegistry<MetamodelManifest>\n lock?: Lock\n}): Promise<Closure<MetamodelManifest>> => {\n const roots: Record<string, Wanted[]> = {}\n for (const [location, range] of Object.entries(spl?.metamodels ?? {})) roots[location] = [{ range, by: 'spl' }]\n for (const module of modules) {\n const who = `${module.location}@${module.version}`\n for (const [location, range] of Object.entries(absoluteRequires({ kind: 'module', location: module.location, manifest: module.manifest }).metamodels)) {\n roots[location] = [...(roots[location] ?? []), { range, by: who }]\n }\n }\n return resolveClosure({\n roots,\n registry,\n requires: (pkg) => absoluteRequires({ kind: 'metamodel', location: pkg.location, manifest: pkg.manifest }).metamodels,\n lock\n })\n}\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type Configuration } from '../configuration/configure.js';
|
|
2
|
+
import type { MetamodelEngine, MetamodelInfo } from '../metamodels/engine.js';
|
|
3
|
+
import type { Diagnostic, PackageFiles, ResolvedSpl } from '../types.js';
|
|
4
|
+
export interface SplCheckReport {
|
|
5
|
+
readonly ok: boolean;
|
|
6
|
+
readonly diagnostics: readonly Diagnostic[];
|
|
7
|
+
readonly metamodels: readonly MetamodelInfo[];
|
|
8
|
+
/** The feature model the products choose from (UVL): the SPL's own with the ones of its modules grafted in. */
|
|
9
|
+
readonly featureModel: string;
|
|
10
|
+
/** The models of the levels above 0 (the feature model), and the platform composed with them. Not there when `configuration` was `false`. */
|
|
11
|
+
readonly configuration?: Configuration;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Whether the packages of an SPL fit together: metamodels that compose, offered models that are valid together, the SPL's own models of the
|
|
15
|
+
* levels above 0 (its feature model) and the feature models of its modules, and code that can be merged. Nothing is thrown for a problem of
|
|
16
|
+
* the packages: they are all in the report, each with the package (and file) at fault.
|
|
17
|
+
*/
|
|
18
|
+
export declare const checkSpl: ({ resolved, spl, createEngine, configuration }: {
|
|
19
|
+
resolved: ResolvedSpl;
|
|
20
|
+
/** The files of the SPL itself (`models/...`, `src/platform/...`), when it has any. */
|
|
21
|
+
spl?: PackageFiles;
|
|
22
|
+
createEngine: () => MetamodelEngine;
|
|
23
|
+
/** `false` to check packages on their own, with no SPL around them (no feature model is asked for). */
|
|
24
|
+
configuration?: boolean;
|
|
25
|
+
}) => Promise<SplCheckReport>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { configure } from '../configuration/configure.js';
|
|
2
|
+
import { hasErrors } from '../diagnostics.js';
|
|
3
|
+
import { prepareEngine } from '../metamodels/prepare.js';
|
|
4
|
+
import { planPlatform } from './platform.js';
|
|
5
|
+
/**
|
|
6
|
+
* Whether the packages of an SPL fit together: metamodels that compose, offered models that are valid together, the SPL's own models of the
|
|
7
|
+
* levels above 0 (its feature model) and the feature models of its modules, and code that can be merged. Nothing is thrown for a problem of
|
|
8
|
+
* the packages: they are all in the report, each with the package (and file) at fault.
|
|
9
|
+
*/
|
|
10
|
+
export const checkSpl = async ({ resolved, spl, createEngine, configuration = true }) => {
|
|
11
|
+
const { engine, metamodels, diagnostics, contributed } = await prepareEngine({ resolved, createEngine });
|
|
12
|
+
if (!configuration) {
|
|
13
|
+
// a check does not write the code anywhere: it is listed, and only what decides something is read
|
|
14
|
+
const plan = await planPlatform({ resolved, spl, loadCode: false });
|
|
15
|
+
diagnostics.push(...plan.diagnostics);
|
|
16
|
+
return { ok: !hasErrors(diagnostics), diagnostics, metamodels, featureModel: plan.featureModel };
|
|
17
|
+
}
|
|
18
|
+
const composed = await configure({ engine, resolved, spl, metamodels, offered: contributed, diagnostics, loadCode: false });
|
|
19
|
+
return { ok: !hasErrors(diagnostics), diagnostics, metamodels, featureModel: composed.featureModelUvl, configuration: composed };
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=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Y,EAAE,QAAQ,CAAC,eAAe,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAA;AAClI,CAAC,CAAA","sourcesContent":["import { configure, type Configuration } from '../configuration/configure.js'\nimport { hasErrors } from '../diagnostics.js'\nimport { prepareEngine } from '../metamodels/prepare.js'\nimport type { MetamodelEngine, MetamodelInfo } from '../metamodels/engine.js'\nimport type { Diagnostic, PackageFiles, ResolvedSpl } from '../types.js'\nimport { planPlatform } from './platform.js'\n\nexport interface SplCheckReport {\n readonly ok: boolean\n readonly diagnostics: readonly Diagnostic[]\n readonly metamodels: readonly MetamodelInfo[]\n /** The feature model the products choose from (UVL): the SPL's own with the ones of its modules grafted in. */\n readonly featureModel: string\n /** The models of the levels above 0 (the feature model), and the platform composed with them. Not there when `configuration` was `false`. */\n readonly configuration?: Configuration\n}\n\n/**\n * Whether the packages of an SPL fit together: metamodels that compose, offered models that are valid together, the SPL's own models of the\n * levels above 0 (its feature model) and the feature models of its modules, and code that can be merged. Nothing is thrown for a problem of\n * the packages: they are all in the report, each with the package (and file) at fault.\n */\nexport const checkSpl = async ({\n resolved,\n spl,\n createEngine,\n configuration = true\n}: {\n resolved: ResolvedSpl\n /** The files of the SPL itself (`models/...`, `src/platform/...`), when it has any. */\n spl?: PackageFiles\n createEngine: () => MetamodelEngine\n /** `false` to check packages on their own, with no SPL around them (no feature model is asked for). */\n configuration?: boolean\n}): Promise<SplCheckReport> => {\n const { engine, metamodels, diagnostics, contributed } = await prepareEngine({ resolved, createEngine })\n if (!configuration) {\n // a check does not write the code anywhere: it is listed, and only what decides something is read\n const plan = await planPlatform({ resolved, spl, loadCode: false })\n diagnostics.push(...plan.diagnostics)\n return { ok: !hasErrors(diagnostics), diagnostics, metamodels, featureModel: plan.featureModel }\n }\n const composed = await configure({ engine, resolved, spl, metamodels, offered: contributed, diagnostics, loadCode: false })\n return { ok: !hasErrors(diagnostics), diagnostics, metamodels, featureModel: composed.featureModelUvl, configuration: composed }\n}\n"]}
|