@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scaffold.js","sourceRoot":"","sources":["../../src/line/scaffold.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,YAAY,EAAyB,MAAM,iBAAiB,CAAA;AAC9G,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAA;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AAC/D,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,oBAA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,gCAAgC;YACtC,OAAO,EAAE,qBAAqB,CAAC,EAAE,MAAM,EAAE,CAAC;YAC1C,QAAQ,EAAE,MAAM;SACjB;QACD,GAAG,gBAAgB,EAAE;KACtB,CAAA;AACH,CAAC,CAAA;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,EAChC,GAAG,EACH,IAAI,EACJ,MAAM,GAAG,EAAE,EACX,gBAAgB,GAAG,KAAK,EACY,EAAsC,EAAE;IAC5E,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QACjD,MAAM,IAAI,oBAAoB,CAAC,iCAAiC,CAAC,CAAA;IACnE,CAAC;IACD,MAAM,KAAK,GAAG,iBAAiB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,gBAAgB,EAAE,CAAC,CAAA;IACnE,MAAM,IAAI,GAAG,SAAS,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAA;IAExC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,2EAA2E;QAC3E,kCAAkC;QAClC,aAAa,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAA;IAC9F,CAAC;IAED,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,CAAA;AAC7B,CAAC,CAAA","sourcesContent":["/**\n * The initial file tree of a brand new line.\n *\n * Migrated from `linea/server/src/model/services/LineService.js:createLine`\n * (~43-68), keeping ONLY the file construction. Everything around it belongs to\n * linea-server (ADR-003): creating the GitLab group and project, the\n * `createFile` calls, the Mongo transaction and the rollback.\n *\n * The API is split into a PURE half and an IMPURE half on purpose:\n *\n * - `buildLineScaffold` computes the files and touches nothing. linea-server\n * feeds the result straight to `gitlabSession.createFile`, in order, for\n * exact parity with `createLine` — without linea-core ever reaching the\n * network or the disk (ADR-002).\n * - `writeLineScaffold` materialises the same description on disk, which is\n * what linea-cli needs in local mode (ADR-004).\n *\n * They must stay separate: collapsing them would force the GitLab path to write\n * a temporary tree it does not want.\n */\nimport path from 'node:path'\nimport { FEATURE_MODEL_TYPES, isFeatureModelType, NAME_PATTERN, type FeatureModelType } from '../constants.js'\nimport { InvalidArgumentError } from '../errors.js'\nimport { modelToXml } from '../feature-model/engine.js'\nimport { parseFeatureModel } from '../feature-model/parse.js'\nimport { emptyFeatureModelUvl } from '../feature-model/text.js'\nimport { ensureDir, writeTextFile } from '../fs/workspace.js'\nimport { buildExtraJs, buildTransformationJs, getPipelineFiles, type FileSpec } from './platform-files.js'\n\n/**\n * Engine configuration seeded into every new line (`src/platform/config.json`).\n *\n * Verbatim from `LineService.js:48-56`, which is what actually runs when a line\n * is created.\n *\n * KNOWN DISCREPANCY IN THE MONOLITH: the test fixture\n * `linea/server/src/test/mocks/lps/src/platform/config.json` carries a RICHER\n * list — it also declares `dockerfile` and `sh` extensions. The two have drifted\n * apart. `LineService.js` is the source of truth here because it is the code\n * path that creates real lines; the fixture only feeds derivation tests. A line\n * seeded by linea-core therefore will not process `Dockerfile` or `.sh`\n * annotations until someone edits its `config.json`, exactly as today.\n */\nexport const DEFAULT_PLATFORM_CONFIG = {\n ignore: ['target', 'bower_components', '.gradle', '.project', 'bin', 'build', '.settings', '.classpath'],\n delimiters: [\n { extension: ['html', 'jsp', 'xml'], start: '<!--%', end: '%-->' },\n {\n extension: [\n 'css', 'js', 'java', 'vue', 'g4', 'tokens', 'gradle', 'md', 'conf',\n 'gitignore', 'properties', 'sql', 'env', 'production'\n ],\n start: '/*%',\n end: '%*/'\n },\n { extension: ['py'], start: '#%', end: '%#' },\n { extension: ['json'], start: '###<', end: '>###' }\n ]\n} as const\n\n/** Contents of `src/platform/code/.gitignore`, verbatim from `LineService.js:60`. */\nexport const DEFAULT_CODE_GITIGNORE = 'node_modules/\\ntarget/\\ndist/\\n.env\\n*.log\\n'\n\n/** What a line scaffold needs to know. */\nexport interface LineScaffoldInput {\n /** Line name; becomes the root feature of the seed model. */\n name: string\n /** Metamodels chosen for the line, e.g. `['UML']`. Unknown names are ignored. */\n models?: readonly string[]\n /** Notation of the seed feature model. Defaults to `'UVL'`. */\n featureModelType?: FeatureModelType\n}\n\n/**\n * Computes the files of a brand new line. PURE: reads no working directory and\n * writes nothing.\n *\n * The returned order is the order `createLine` creates them in, and callers\n * should preserve it: model, config, code/.gitignore, extra.js,\n * transformation.js, then the pipeline files.\n *\n * Note the template files themselves ARE read from the package's own asset\n * directory — that is reading linea-core's own installed data, not the caller's\n * working directory, and is what makes the function usable with no filesystem\n * target at all.\n *\n * @param params.name Line name.\n * @param params.models Metamodels chosen for the line.\n * @param params.featureModelType `'UVL'` (default) or `'XML'`.\n * @returns The files to create, in order.\n * @throws {InvalidArgumentError} when `name` is empty or has characters outside\n * `NAME_PATTERN`, or when `featureModelType` is unknown.\n */\nexport const buildLineScaffold = ({\n name,\n models = [],\n featureModelType = 'UVL'\n}: LineScaffoldInput): FileSpec[] => {\n if (typeof name !== 'string' || name === '') {\n throw new InvalidArgumentError('\"name\" must be a non-empty string.')\n }\n if (!NAME_PATTERN.test(name)) {\n throw new InvalidArgumentError(\n `Invalid line name ${JSON.stringify(name)}: allowed characters are [a-zA-Z0-9_.-].`\n )\n }\n if (!isFeatureModelType(featureModelType)) {\n throw new InvalidArgumentError(\n `Unknown feature model type ${JSON.stringify(featureModelType)}. Use one of ${FEATURE_MODEL_TYPES.join(', ')}.`\n )\n }\n\n const uvlContent = emptyFeatureModelUvl({ name })\n const modelFile: FileSpec = featureModelType === 'XML'\n ? {\n path: 'src/platform/model.xml',\n content: modelToXml(parseFeatureModel({ content: uvlContent, type: 'UVL' })),\n encoding: 'text'\n }\n : { path: 'src/platform/model.uvl', content: uvlContent, encoding: 'text' }\n\n return [\n modelFile,\n {\n path: 'src/platform/config.json',\n // JSON.stringify(config, null, 2) — same two-space indentation as the\n // monolith, and no trailing newline, so the committed file matches.\n content: JSON.stringify(DEFAULT_PLATFORM_CONFIG, null, 2),\n encoding: 'text'\n },\n { path: 'src/platform/code/.gitignore', content: DEFAULT_CODE_GITIGNORE, encoding: 'text' },\n { path: 'src/platform/extra.js', content: buildExtraJs({ models }), encoding: 'text' },\n {\n path: 'src/platform/transformation.js',\n content: buildTransformationJs({ models }),\n encoding: 'text'\n },\n ...getPipelineFiles()\n ]\n}\n\n/**\n * Materialises a line scaffold in a directory.\n *\n * The impure counterpart of `buildLineScaffold`, for linea-cli's local mode.\n * Creates `dir` and every parent directory the files need.\n *\n * @param params.dir Target directory (the line's working directory root).\n * @param params.name Line name.\n * @param params.models Metamodels chosen for the line.\n * @param params.featureModelType `'UVL'` (default) or `'XML'`.\n * @returns The resolved directory and the files written.\n * @throws {InvalidArgumentError} for the same reasons as `buildLineScaffold`, or\n * when `dir` is not a non-empty path.\n */\nexport const writeLineScaffold = ({\n dir,\n name,\n models = [],\n featureModelType = 'UVL'\n}: LineScaffoldInput & { dir: string }): { dir: string, files: FileSpec[] } => {\n if (typeof dir !== 'string' || dir.trim() === '') {\n throw new InvalidArgumentError('\"dir\" must be a non-empty path.')\n }\n const files = buildLineScaffold({ name, models, featureModelType })\n const root = ensureDir({ dirPath: dir })\n\n for (const file of files) {\n // FileSpec paths are POSIX and repository-relative; join with the platform\n // separator to land them on disk.\n writeTextFile({ filePath: path.join(root, ...file.path.split('/')), content: file.content })\n }\n\n return { dir: root, files }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"scaffold.js","sourceRoot":"","sources":["../../src/line/scaffold.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,EAAE,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AChC,QAAQ,EAAE,MAAM;SACjB;QACD,GAAG,gBAAgB,CAAC,EAAE,EAAE,EAAE,CAAC;KAC5B,CAAA;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,EAAE,GAAG,EAAE,GAAG,IAAI,EAAuC,EAAsC,EAAE;IAC7H,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QACjD,MAAM,IAAI,oBAAoB,CAAC,iCAAiC,CAAC,CAAA;IACnE,CAAC;IACD,MAAM,KAAK,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAA;IACrC,MAAM,IAAI,GAAG,SAAS,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAA;IAExC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,aAAa,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAA;IAC9F,CAAC;IAED,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,CAAA;AAC7B,CAAC,CAAA;AAED,OAAO,EAAE,iBAAiB,EAAE,CAAA","sourcesContent":["import path from 'node:path'\nimport { NAME_PATTERN } from '../constants.js'\nimport { InvalidArgumentError } from '../errors.js'\nimport { ensureDir, writeTextFile } from '../fs/workspace.js'\nimport { FEATURE_METAMODEL, FEATURE_MODEL_GRAMMAR, withFeatureMetamodel } from '../modules/configuration/constants.js'\nimport { bangoName, rootFeatureName } from '../modules/configuration/names.js'\nimport { serializeSplManifest } from '../modules/packages/manifests.js'\nimport type { SplKind, SplManifest } from '../modules/types.js'\nimport { buildExtraJs, buildTransformationJs, getPipelineFiles, type CiHost, type FileSpec } from './platform-files.js'\n\nexport const DEFAULT_PLATFORM_CONFIG = {\n ignore: ['target', 'bower_components', '.gradle', '.project', 'bin', 'build', '.settings', '.classpath'],\n delimiters: [\n { extension: ['html', 'jsp', 'xml'], start: '<!--%', end: '%-->' },\n {\n extension: [\n 'css', 'js', 'java', 'vue', 'g4', 'tokens', 'gradle', 'md', 'conf',\n 'gitignore', 'properties', 'sql', 'env', 'production'\n ],\n start: '/*%',\n end: '%*/'\n },\n { extension: ['py'], start: '#%', end: '%#' },\n { extension: ['json'], start: '###<', end: '>###' }\n ]\n} as const\n\nexport const DEFAULT_CODE_GITIGNORE = 'node_modules/\\ntarget/\\ndist/\\n.env\\n*.log\\n'\n\n/** The first feature model of an SPL, as a model of the feature metamodel: just the root, named after the SPL. */\nexport const emptyFeatureModel = ({ name }: { name: string }): string => {\n const root = bangoName({ name: rootFeatureName({ name }) })\n return `featuremodel ${root}\\nfeature ${root}\\n`\n}\n\n/** Where an SPL keeps its feature model. */\nexport const FEATURE_MODEL_PATH = `models/${FEATURE_MODEL_GRAMMAR}.${FEATURE_MODEL_GRAMMAR}`\n\nexport interface LineScaffoldInput {\n name: string\n /** `plain` (the default): the feature metamodel only. `project`: also the `metamodels` the user chose. `modular`: made of `modules`. */\n kind?: SplKind\n /** The metamodels of a `project` (location -> range), besides the feature metamodel. */\n metamodels?: Record<string, string>\n /** The modules of a `modular` SPL (location -> range). */\n modules?: Record<string, string>\n /** Where the feature metamodel is, when not in the default registry (a workspace on disk has it as `file:metamodels/featuremodel`). */\n featureMetamodel?: string\n /** The git host the SPL will live on: which CI file the generated products get (default `gitlab`). */\n ci?: CiHost\n}\n\n/** The `spl.json` of a new SPL. */\nexport const buildSplManifest = ({ name, kind = 'plain', metamodels = {}, modules = {}, featureMetamodel }: LineScaffoldInput): SplManifest =>\n withFeatureMetamodel({\n spl: { name, version: '1.0.0', kind, metamodels: kind === 'project' ? metamodels : {}, modules: kind === 'modular' ? modules : {} },\n ...(featureMetamodel === undefined ? {} : { location: featureMetamodel })\n })\n\n/**\n * The files of a new SPL: its manifest, its feature model (a model of the feature metamodel), and, for a plain or project SPL, the platform\n * its products are derived with (a modular one gets it from its modules).\n */\nexport const buildLineScaffold = ({ name, kind = 'plain', metamodels, modules, featureMetamodel, ci = 'gitlab' }: LineScaffoldInput): FileSpec[] => {\n if (typeof name !== 'string' || name === '') {\n throw new InvalidArgumentError('\"name\" must be a non-empty string.')\n }\n if (!NAME_PATTERN.test(name)) {\n throw new InvalidArgumentError(\n `Invalid line name ${JSON.stringify(name)}: allowed characters are [a-zA-Z0-9_.-].`\n )\n }\n\n const own: FileSpec[] = [\n { path: 'spl.json', content: serializeSplManifest({ spl: buildSplManifest({ name, kind, ...(metamodels === undefined ? {} : { metamodels }), ...(modules === undefined ? {} : { modules }), ...(featureMetamodel === undefined ? {} : { featureMetamodel }) }) }), encoding: 'text' },\n { path: FEATURE_MODEL_PATH, content: emptyFeatureModel({ name }), encoding: 'text' }\n ]\n if (kind === 'modular') return own\n\n return [\n ...own,\n {\n path: 'src/platform/config.json',\n content: JSON.stringify(DEFAULT_PLATFORM_CONFIG, null, 2),\n encoding: 'text'\n },\n { path: 'src/platform/code/.gitignore', content: DEFAULT_CODE_GITIGNORE, encoding: 'text' },\n { path: 'src/platform/extra.js', content: buildExtraJs(), encoding: 'text' },\n {\n path: 'src/platform/transformation.js',\n content: buildTransformationJs(),\n encoding: 'text'\n },\n ...getPipelineFiles({ ci })\n ]\n}\n\nexport const writeLineScaffold = ({ dir, ...rest }: LineScaffoldInput & { dir: string }): { dir: string, files: FileSpec[] } => {\n if (typeof dir !== 'string' || dir.trim() === '') {\n throw new InvalidArgumentError('\"dir\" must be a non-empty path.')\n }\n const files = buildLineScaffold(rest)\n const root = ensureDir({ dirPath: dir })\n\n for (const file of files) {\n writeTextFile({ filePath: path.join(root, ...file.path.split('/')), content: file.content })\n }\n\n return { dir: root, files }\n}\n\nexport { FEATURE_METAMODEL }\n"]}
|
|
@@ -11,16 +11,28 @@ function modelTransformation(input) {
|
|
|
11
11
|
|
|
12
12
|
let ret = {};
|
|
13
13
|
ret.features = input.features;
|
|
14
|
-
ret.data = {};
|
|
15
|
-
ret.data.basicData =
|
|
14
|
+
ret.data = Object.assign({}, modelData(input));
|
|
15
|
+
ret.data.basicData = ret.data.basicData
|
|
16
|
+
? withVersion(ret.data.basicData, input.basicData)
|
|
17
|
+
: basicData(input.basicData);
|
|
16
18
|
|
|
17
19
|
_metamodelProcessors.forEach(function(processor) {
|
|
18
20
|
processor(ret, input);
|
|
19
21
|
});
|
|
20
22
|
|
|
21
|
-
ret.data.gui = gui(ret.features,
|
|
22
|
-
ret.data.menus = menus(ret);
|
|
23
|
-
ret.data.statics = statics(input.statics);
|
|
23
|
+
ret.data.gui = Object.assign(gui(ret.features, ret.data.basicData.name), ret.data.gui);
|
|
24
|
+
ret.data.menus = Array.isArray(ret.data.menus) && ret.data.menus.length ? ret.data.menus : menus(ret);
|
|
25
|
+
ret.data.statics = ret.data.statics !== undefined ? ret.data.statics : statics(input.statics);
|
|
26
|
+
return ret;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function modelData(input) {
|
|
30
|
+
return input.models && input.models.data ? input.models.data : {};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function withVersion(fromModels, given) {
|
|
34
|
+
const ret = Object.assign({}, fromModels);
|
|
35
|
+
if (ret.version === undefined && given && given.version !== undefined) ret.version = given.version;
|
|
24
36
|
return ret;
|
|
25
37
|
}
|
|
26
38
|
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# The same two jobs as .gitlab-ci.yml, for GitHub Actions.
|
|
2
|
+
#
|
|
3
|
+
# Test commands live in ci/test-server.sh and ci/test-client.sh.
|
|
4
|
+
# Domain engineers edit those scripts to wire in real tests; this YAML should
|
|
5
|
+
# not need changes.
|
|
6
|
+
|
|
7
|
+
name: CI
|
|
8
|
+
|
|
9
|
+
on:
|
|
10
|
+
push:
|
|
11
|
+
pull_request:
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
test_server:
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
container: gradle:8-jdk21
|
|
17
|
+
env:
|
|
18
|
+
GRADLE_USER_HOME: ${{ github.workspace }}/.gradle
|
|
19
|
+
steps:
|
|
20
|
+
- uses: actions/checkout@v4
|
|
21
|
+
- uses: actions/cache@v4
|
|
22
|
+
with:
|
|
23
|
+
key: gradle-${{ github.ref_name }}
|
|
24
|
+
path: |
|
|
25
|
+
.gradle/caches
|
|
26
|
+
.gradle/wrapper
|
|
27
|
+
- run: sh ./ci/test-server.sh
|
|
28
|
+
- uses: actions/upload-artifact@v4
|
|
29
|
+
if: always()
|
|
30
|
+
with:
|
|
31
|
+
name: server-test-results
|
|
32
|
+
path: server/build/test-results/test/**/TEST-*.xml
|
|
33
|
+
retention-days: 7
|
|
34
|
+
|
|
35
|
+
test_client:
|
|
36
|
+
runs-on: ubuntu-latest
|
|
37
|
+
container: node:20
|
|
38
|
+
steps:
|
|
39
|
+
- uses: actions/checkout@v4
|
|
40
|
+
- uses: actions/cache@v4
|
|
41
|
+
with:
|
|
42
|
+
key: node-${{ github.ref_name }}
|
|
43
|
+
path: client/node_modules
|
|
44
|
+
- run: sh ./ci/test-client.sh
|
|
45
|
+
- uses: actions/upload-artifact@v4
|
|
46
|
+
if: always()
|
|
47
|
+
with:
|
|
48
|
+
name: client-test-results
|
|
49
|
+
path: client/test-results/**/junit*.xml
|
|
50
|
+
retention-days: 7
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
#
|
|
2
|
+
# CI of an SPL: what a merge request does to the products that already exist.
|
|
3
|
+
#
|
|
4
|
+
# validate the feature model against the real products (their .linea/spec.json is fetched from
|
|
5
|
+
# the repositories listed in products.json); the version of the line is raised when
|
|
6
|
+
# features are removed
|
|
7
|
+
# select the products the change can break (the ones that have a feature the changed code tests)
|
|
8
|
+
# products a child pipeline: each selected product is derived from the proposed code, checked for
|
|
9
|
+
# annotations left in it, derived twice to see that it is deterministic, and tested
|
|
10
|
+
# metrics the selected products are derived from the proposed code and from the target branch and
|
|
11
|
+
# measured (cyclomatic complexity); what each touched feature brings is measured by deriving
|
|
12
|
+
# a product with and without it. The result is a note on the merge request and the Code
|
|
13
|
+
# Quality widget.
|
|
14
|
+
# test GitLab's security scans (SAST, secret detection, dependency scanning)
|
|
15
|
+
#
|
|
16
|
+
# A scheduled pipeline (or one started by hand) does more:
|
|
17
|
+
# - every product of the SPL is derived and checked, and what is committed in each product is compared
|
|
18
|
+
# with what the line generates (drift: someone edited the generated code by hand)
|
|
19
|
+
# - a pairwise sample of configurations (every pair of features together once) is derived and tested,
|
|
20
|
+
# to find interactions between features that no real product has
|
|
21
|
+
#
|
|
22
|
+
# Pushing a tag asks LINEA to generate again every product of the SPL (release), once LINEA_URL and LINEA_TOKEN are
|
|
23
|
+
# set: without them there is no release job, and a tag runs nothing.
|
|
24
|
+
#
|
|
25
|
+
# Needs these CI/CD variables:
|
|
26
|
+
# LINEA_CI_TOKEN a token that can read the product repositories and the registry of packages, and
|
|
27
|
+
# comment on merge requests
|
|
28
|
+
# LINEA_CI_PACKAGE where linea-ci is installed from (npm name, git URL or tarball)
|
|
29
|
+
# LINEA_URL, LINEA_TOKEN only for releases: the address of LINEA and a session token of a user who
|
|
30
|
+
# can generate the products
|
|
31
|
+
|
|
32
|
+
include:
|
|
33
|
+
- template: Security/SAST.gitlab-ci.yml
|
|
34
|
+
- template: Security/Secret-Detection.gitlab-ci.yml
|
|
35
|
+
- template: Security/Dependency-Scanning.gitlab-ci.yml
|
|
36
|
+
|
|
37
|
+
workflow:
|
|
38
|
+
rules:
|
|
39
|
+
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
|
|
40
|
+
- if: '$CI_PIPELINE_SOURCE == "schedule"'
|
|
41
|
+
- if: '$CI_PIPELINE_SOURCE == "web"'
|
|
42
|
+
- if: '$CI_COMMIT_TAG'
|
|
43
|
+
|
|
44
|
+
variables:
|
|
45
|
+
LINEA_CI_PACKAGE: "git+https://$CI_SERVER_HOST/linea/linea-ci.git"
|
|
46
|
+
LINEA_CI_MAX_PRODUCTS: "5"
|
|
47
|
+
LINEA_CI_MAX_SAMPLES: "30"
|
|
48
|
+
LINEA_CI_MAX_CCN: "15"
|
|
49
|
+
LINEA_CI_SPECS: ".linea-ci/specs"
|
|
50
|
+
|
|
51
|
+
stages:
|
|
52
|
+
- validate
|
|
53
|
+
- select
|
|
54
|
+
- products
|
|
55
|
+
- metrics
|
|
56
|
+
- test
|
|
57
|
+
- release
|
|
58
|
+
|
|
59
|
+
.linea-ci:
|
|
60
|
+
image: node:22
|
|
61
|
+
before_script:
|
|
62
|
+
# a package kept in this GitLab (a git URL on its host) is cloned with the token of the job
|
|
63
|
+
- git config --global url."https://gitlab-ci-token:${CI_JOB_TOKEN}@${CI_SERVER_HOST}/".insteadOf "https://${CI_SERVER_HOST}/"
|
|
64
|
+
- npm install --global "$LINEA_CI_PACKAGE"
|
|
65
|
+
|
|
66
|
+
.not-on-tags:
|
|
67
|
+
rules:
|
|
68
|
+
- if: '$CI_COMMIT_TAG'
|
|
69
|
+
when: never
|
|
70
|
+
- when: on_success
|
|
71
|
+
|
|
72
|
+
specs:
|
|
73
|
+
extends: [.linea-ci, .not-on-tags]
|
|
74
|
+
stage: validate
|
|
75
|
+
script:
|
|
76
|
+
- linea-ci fetch-specs --line . --out "$LINEA_CI_SPECS"
|
|
77
|
+
- linea-ci validate-specs --line . "$LINEA_CI_SPECS"
|
|
78
|
+
artifacts:
|
|
79
|
+
paths:
|
|
80
|
+
- .linea-ci/specs/
|
|
81
|
+
expire_in: 1 week
|
|
82
|
+
|
|
83
|
+
version:
|
|
84
|
+
extends: .linea-ci
|
|
85
|
+
stage: validate
|
|
86
|
+
variables:
|
|
87
|
+
GIT_DEPTH: "0"
|
|
88
|
+
script:
|
|
89
|
+
- git worktree add ../base "$CI_MERGE_REQUEST_DIFF_BASE_SHA"
|
|
90
|
+
- linea-ci check-version --line . --base-line ../base
|
|
91
|
+
rules:
|
|
92
|
+
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
|
|
93
|
+
|
|
94
|
+
select:
|
|
95
|
+
extends: [.linea-ci, .not-on-tags]
|
|
96
|
+
stage: select
|
|
97
|
+
needs: [specs]
|
|
98
|
+
script:
|
|
99
|
+
- |
|
|
100
|
+
if [ "$CI_PIPELINE_SOURCE" = "merge_request_event" ]; then
|
|
101
|
+
RANGE="--base $CI_MERGE_REQUEST_DIFF_BASE_SHA --head $CI_COMMIT_SHA --max $LINEA_CI_MAX_PRODUCTS"
|
|
102
|
+
else
|
|
103
|
+
# nightly or by hand: the feature model is touched as far as the selection goes, so every product is rebuilt and compared with its repository
|
|
104
|
+
RANGE="--changed src/platform/model.uvl --with-drift"
|
|
105
|
+
fi
|
|
106
|
+
linea-ci select-products --line . --specs "$LINEA_CI_SPECS" $RANGE --pipeline-out .linea-ci/child.yml | tee .linea-ci/selection.json
|
|
107
|
+
artifacts:
|
|
108
|
+
paths:
|
|
109
|
+
- .linea-ci/
|
|
110
|
+
expire_in: 1 week
|
|
111
|
+
|
|
112
|
+
products:
|
|
113
|
+
stage: products
|
|
114
|
+
needs: [select]
|
|
115
|
+
variables:
|
|
116
|
+
PARENT_PIPELINE_ID: $CI_PIPELINE_ID
|
|
117
|
+
trigger:
|
|
118
|
+
include:
|
|
119
|
+
- artifact: .linea-ci/child.yml
|
|
120
|
+
job: select
|
|
121
|
+
strategy: depend
|
|
122
|
+
rules:
|
|
123
|
+
- if: '$CI_COMMIT_TAG'
|
|
124
|
+
when: never
|
|
125
|
+
- when: on_success
|
|
126
|
+
|
|
127
|
+
sample:
|
|
128
|
+
extends: .linea-ci
|
|
129
|
+
stage: select
|
|
130
|
+
needs: [specs]
|
|
131
|
+
script:
|
|
132
|
+
- linea-ci sample-configs --line . --specs "$LINEA_CI_SPECS" --out .linea-ci/samples --max "$LINEA_CI_MAX_SAMPLES" --pipeline-out .linea-ci/samples-child.yml
|
|
133
|
+
artifacts:
|
|
134
|
+
paths:
|
|
135
|
+
- .linea-ci/
|
|
136
|
+
expire_in: 1 week
|
|
137
|
+
rules:
|
|
138
|
+
- if: '$CI_PIPELINE_SOURCE == "schedule" || $CI_PIPELINE_SOURCE == "web"'
|
|
139
|
+
|
|
140
|
+
samples:
|
|
141
|
+
stage: products
|
|
142
|
+
needs: [sample]
|
|
143
|
+
variables:
|
|
144
|
+
PARENT_PIPELINE_ID: $CI_PIPELINE_ID
|
|
145
|
+
trigger:
|
|
146
|
+
include:
|
|
147
|
+
- artifact: .linea-ci/samples-child.yml
|
|
148
|
+
job: sample
|
|
149
|
+
strategy: depend
|
|
150
|
+
rules:
|
|
151
|
+
- if: '$CI_PIPELINE_SOURCE == "schedule" || $CI_PIPELINE_SOURCE == "web"'
|
|
152
|
+
|
|
153
|
+
metrics:
|
|
154
|
+
extends: .linea-ci
|
|
155
|
+
stage: metrics
|
|
156
|
+
needs: [select]
|
|
157
|
+
variables:
|
|
158
|
+
GIT_DEPTH: "0"
|
|
159
|
+
script:
|
|
160
|
+
- apt-get update -qq && apt-get install -y -qq python3-pip > /dev/null && pip install --quiet --break-system-packages lizard
|
|
161
|
+
- git worktree add ../base "$CI_MERGE_REQUEST_DIFF_BASE_SHA"
|
|
162
|
+
- linea-ci mr-metrics --line . --specs "$LINEA_CI_SPECS" --selection .linea-ci/selection.json --base-line ../base --max-ccn "$LINEA_CI_MAX_CCN" --out .linea-ci/metrics
|
|
163
|
+
- linea-ci mr-note .linea-ci/metrics/metrics.md || echo "The note could not be posted (LINEA_CI_TOKEN needs the api scope)."
|
|
164
|
+
artifacts:
|
|
165
|
+
when: always
|
|
166
|
+
paths:
|
|
167
|
+
- .linea-ci/metrics/metrics.md
|
|
168
|
+
- .linea-ci/metrics/metrics.json
|
|
169
|
+
reports:
|
|
170
|
+
codequality: .linea-ci/metrics/gl-code-quality-report.json
|
|
171
|
+
expire_in: 1 week
|
|
172
|
+
allow_failure: true
|
|
173
|
+
rules:
|
|
174
|
+
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
|
|
175
|
+
|
|
176
|
+
release:
|
|
177
|
+
extends: .linea-ci
|
|
178
|
+
stage: release
|
|
179
|
+
script:
|
|
180
|
+
- linea-ci release-products --linea-url "$LINEA_URL" --line "$CI_PROJECT_NAME"
|
|
181
|
+
rules:
|
|
182
|
+
- if: '$CI_COMMIT_TAG && $LINEA_TOKEN'
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { type FeatureModelTree } from '../../feature-model/uvl.js';
|
|
2
|
+
import { type MetamodelEngine, type MetamodelInfo } from '../metamodels/engine.js';
|
|
3
|
+
import { type PlatformPlan } from '../spl/platform.js';
|
|
4
|
+
import type { Diagnostic, PackageFiles, ResolvedSpl } from '../types.js';
|
|
5
|
+
/** A model of a level above 0: what the final models are made from. */
|
|
6
|
+
export interface ConfigurationModel {
|
|
7
|
+
readonly metamodel: string;
|
|
8
|
+
readonly level: number;
|
|
9
|
+
readonly text: string;
|
|
10
|
+
/** Where the SPL keeps it (`models/<metamodel>.<extension>`). The composed feature model of a modular SPL is not a file. */
|
|
11
|
+
readonly file: string;
|
|
12
|
+
/** Whether the SPL has the file: a model of a metamodel the SPL gained is made new (the smallest valid one) until it is saved. */
|
|
13
|
+
readonly stored: boolean;
|
|
14
|
+
}
|
|
15
|
+
/** The models of the levels above 0 of an SPL, ready to be offered to its products, and the platform composed with them. */
|
|
16
|
+
export interface Configuration {
|
|
17
|
+
/** Highest level first. */
|
|
18
|
+
readonly models: readonly ConfigurationModel[];
|
|
19
|
+
/** The feature model the products choose from: the SPL's own, with the ones of its modules grafted in. */
|
|
20
|
+
readonly featureModel?: FeatureModelTree;
|
|
21
|
+
/** The same, as UVL: what flamapy analyzes and the derivation engine reads. */
|
|
22
|
+
readonly featureModelUvl: string;
|
|
23
|
+
readonly plan: PlatformPlan;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Gives the engine the models of the levels above 0 of an SPL, to offer to its products, read-only: for each such metamodel (highest
|
|
27
|
+
* level first, each checked with the ones above it offered), the SPL's own model of it from `models/<metamodel>.<extension>` (the feature
|
|
28
|
+
* model made new when there is none). The feature models of the SPL's modules are then grafted under the root of the SPL's own, and that
|
|
29
|
+
* composed feature model is what is offered. What is wrong with any of it is added to `diagnostics`.
|
|
30
|
+
*
|
|
31
|
+
* Afterwards the engine has no models of its own (`setInstances({})`): the caller sets the product's.
|
|
32
|
+
*/
|
|
33
|
+
export declare const configure: ({ engine, resolved, spl, metamodels, offered, diagnostics, loadCode }: {
|
|
34
|
+
engine: MetamodelEngine;
|
|
35
|
+
resolved: ResolvedSpl;
|
|
36
|
+
/** The files of the SPL. */
|
|
37
|
+
spl?: PackageFiles;
|
|
38
|
+
metamodels: readonly MetamodelInfo[];
|
|
39
|
+
/** What the engine already offers: the models of the modules. */
|
|
40
|
+
offered: readonly {
|
|
41
|
+
origin: string;
|
|
42
|
+
metamodel: string;
|
|
43
|
+
text: string;
|
|
44
|
+
}[];
|
|
45
|
+
diagnostics: Diagnostic[];
|
|
46
|
+
/** `false` for a check, where the code of the modules is only listed (see `planPlatform`). */
|
|
47
|
+
loadCode?: boolean;
|
|
48
|
+
}) => Promise<Configuration>;
|
|
49
|
+
/** The names of the features of a configuration's feature model. */
|
|
50
|
+
export declare const featureNames: ({ configuration }: {
|
|
51
|
+
configuration: Pick<Configuration, "featureModel">;
|
|
52
|
+
}) => string[];
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { UvlParseError } from '../../errors.js';
|
|
2
|
+
import { featuresOf, parseUvl, printUvl } from '../../feature-model/uvl.js';
|
|
3
|
+
import { toDiagnostics } from '../metamodels/engine.js';
|
|
4
|
+
import { readPackageText } from '../packages/source.js';
|
|
5
|
+
import { planPlatform } from '../spl/platform.js';
|
|
6
|
+
import { FEATURE_MODEL_GRAMMAR } from './constants.js';
|
|
7
|
+
import { rootFeatureName } from './names.js';
|
|
8
|
+
/** `models/<metamodel>.<extension>`: where an SPL keeps its model of a metamodel. */
|
|
9
|
+
const configurationPath = ({ info }) => `models/${info.name}.${info.extension}`;
|
|
10
|
+
/**
|
|
11
|
+
* Gives the engine the models of the levels above 0 of an SPL, to offer to its products, read-only: for each such metamodel (highest
|
|
12
|
+
* level first, each checked with the ones above it offered), the SPL's own model of it from `models/<metamodel>.<extension>` (the feature
|
|
13
|
+
* model made new when there is none). The feature models of the SPL's modules are then grafted under the root of the SPL's own, and that
|
|
14
|
+
* composed feature model is what is offered. What is wrong with any of it is added to `diagnostics`.
|
|
15
|
+
*
|
|
16
|
+
* Afterwards the engine has no models of its own (`setInstances({})`): the caller sets the product's.
|
|
17
|
+
*/
|
|
18
|
+
export const configure = async ({ engine, resolved, spl, metamodels, offered, diagnostics, loadCode = true }) => {
|
|
19
|
+
const upper = metamodels.filter((info) => info.level > 0).sort((a, b) => b.level - a.level);
|
|
20
|
+
const contributed = [...offered];
|
|
21
|
+
const models = [];
|
|
22
|
+
let own;
|
|
23
|
+
const fail = (file, message) => { diagnostics.push({ severity: 'error', package: 'spl', file, message }); };
|
|
24
|
+
for (const info of upper) {
|
|
25
|
+
const file = configurationPath({ info });
|
|
26
|
+
let text = spl === undefined ? undefined : await readPackageText({ files: spl, path: file });
|
|
27
|
+
const stored = text !== undefined;
|
|
28
|
+
if (text === undefined) {
|
|
29
|
+
if (info.name === FEATURE_MODEL_GRAMMAR) {
|
|
30
|
+
// an SPL that has no feature model yet has an empty one, named after it
|
|
31
|
+
const name = rootFeatureName({ name: resolved.spl.name });
|
|
32
|
+
text = (await engine.importJson({ featureModel: { name, root: { name, groups: [] }, constraints: [] } })).texts[info.name];
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
// any other metamodel of a level above 0 starts from what it says is its smallest valid model, until the SPL saves one
|
|
36
|
+
await engine.setContributed(contributed);
|
|
37
|
+
text = (await engine.createInstance(info.name)).text;
|
|
38
|
+
}
|
|
39
|
+
if (text === undefined) {
|
|
40
|
+
fail(file, `There is no model of "${info.name}".`);
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
await engine.setContributed(contributed);
|
|
45
|
+
const states = await engine.setInstances({ [info.name]: text });
|
|
46
|
+
for (const state of states)
|
|
47
|
+
diagnostics.push(...toDiagnostics(state.problems, { package: 'spl', file }));
|
|
48
|
+
if (info.name === FEATURE_MODEL_GRAMMAR) {
|
|
49
|
+
// (a model that does not parse has no JSON: what is wrong with it is already in the diagnostics)
|
|
50
|
+
const json = (await engine.toJson(info.name).catch(() => undefined));
|
|
51
|
+
own = json?.featureModel;
|
|
52
|
+
}
|
|
53
|
+
models.push({ metamodel: info.name, level: info.level, text, file, stored });
|
|
54
|
+
contributed.push({ origin: `level-${info.level}`, metamodel: info.name, text });
|
|
55
|
+
}
|
|
56
|
+
// the SPL's own feature model is the root and what it declares itself; what its modules declare is grafted in
|
|
57
|
+
const plan = await planPlatform({ resolved, spl, loadCode, ...(own === undefined ? {} : { ownFeatureModel: printUvl({ tree: own }) }) });
|
|
58
|
+
diagnostics.push(...plan.diagnostics);
|
|
59
|
+
let featureModel = own;
|
|
60
|
+
if (own !== undefined && resolved.modules.length > 0 && plan.featureModel !== '') {
|
|
61
|
+
try {
|
|
62
|
+
featureModel = parseUvl({ content: plan.featureModel });
|
|
63
|
+
const composed = (await engine.importJson({ featureModel })).texts[FEATURE_MODEL_GRAMMAR];
|
|
64
|
+
if (composed === undefined)
|
|
65
|
+
fail('models/featuremodel', 'The composed feature model could not be made.');
|
|
66
|
+
else {
|
|
67
|
+
const at = contributed.findIndex((item) => item.metamodel === FEATURE_MODEL_GRAMMAR && item.origin.startsWith('level-'));
|
|
68
|
+
contributed[at] = { ...contributed[at], text: composed };
|
|
69
|
+
const index = models.findIndex((model) => model.metamodel === FEATURE_MODEL_GRAMMAR);
|
|
70
|
+
models[index] = { ...models[index], text: composed };
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
if (!(error instanceof UvlParseError))
|
|
75
|
+
throw error;
|
|
76
|
+
fail('models/featuremodel', `The merged feature model is not valid: ${error.message}`);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
// what is offered, with its problems (the feature model of the modules is checked here: a feature declared twice, a constraint on a missing one)
|
|
80
|
+
if (contributed.length > 0) {
|
|
81
|
+
for (const state of await engine.setContributed(contributed)) {
|
|
82
|
+
if (!state.origin.startsWith('level-'))
|
|
83
|
+
continue;
|
|
84
|
+
const model = models.find((candidate) => candidate.metamodel === state.metamodel);
|
|
85
|
+
diagnostics.push(...toDiagnostics(state.problems, { package: 'spl', ...(model === undefined ? {} : { file: model.file }) }));
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
await engine.setInstances({});
|
|
89
|
+
if (upper.every((info) => info.name !== FEATURE_MODEL_GRAMMAR)) {
|
|
90
|
+
diagnostics.push({ severity: 'error', package: 'spl', message: 'The SPL has no feature metamodel: add "featuremodel" to its metamodels.' });
|
|
91
|
+
}
|
|
92
|
+
return {
|
|
93
|
+
models,
|
|
94
|
+
...(featureModel === undefined ? {} : { featureModel }),
|
|
95
|
+
featureModelUvl: featureModel === undefined ? '' : printUvl({ tree: featureModel }),
|
|
96
|
+
plan
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
/** The names of the features of a configuration's feature model. */
|
|
100
|
+
export const featureNames = ({ configuration }) => configuration.featureModel === undefined ? [] : featuresOf({ tree: configuration.featureModel }).map((feature) => feature.name);
|
|
101
|
+
//# sourceMappingURL=configure.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configure.js","sourceRoot":"","sources":["../../../src/modules/configuration/configure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAyB,MAAM,4BAA4B,CAAA;AAClG,OAAO,EAAE,aAAa,EAA4C,MAAM,yBAAyB,CAAA;AACjG,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CA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Y,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA","sourcesContent":["import { UvlParseError } from '../../errors.js'\nimport { featuresOf, parseUvl, printUvl, type FeatureModelTree } from '../../feature-model/uvl.js'\nimport { toDiagnostics, type MetamodelEngine, type MetamodelInfo } from '../metamodels/engine.js'\nimport { readPackageText } from '../packages/source.js'\nimport { planPlatform, type PlatformPlan } from '../spl/platform.js'\nimport type { Diagnostic, PackageFiles, ResolvedSpl } from '../types.js'\nimport { FEATURE_MODEL_GRAMMAR } from './constants.js'\nimport { rootFeatureName } from './names.js'\n\n/** A model of a level above 0: what the final models are made from. */\nexport interface ConfigurationModel {\n readonly metamodel: string\n readonly level: number\n readonly text: string\n /** Where the SPL keeps it (`models/<metamodel>.<extension>`). The composed feature model of a modular SPL is not a file. */\n readonly file: string\n /** Whether the SPL has the file: a model of a metamodel the SPL gained is made new (the smallest valid one) until it is saved. */\n readonly stored: boolean\n}\n\n/** The models of the levels above 0 of an SPL, ready to be offered to its products, and the platform composed with them. */\nexport interface Configuration {\n /** Highest level first. */\n readonly models: readonly ConfigurationModel[]\n /** The feature model the products choose from: the SPL's own, with the ones of its modules grafted in. */\n readonly featureModel?: FeatureModelTree\n /** The same, as UVL: what flamapy analyzes and the derivation engine reads. */\n readonly featureModelUvl: string\n readonly plan: PlatformPlan\n}\n\n/** `models/<metamodel>.<extension>`: where an SPL keeps its model of a metamodel. */\nconst configurationPath = ({ info }: { info: Pick<MetamodelInfo, 'name' | 'extension'> }): string => `models/${info.name}.${info.extension}`\n\n/**\n * Gives the engine the models of the levels above 0 of an SPL, to offer to its products, read-only: for each such metamodel (highest\n * level first, each checked with the ones above it offered), the SPL's own model of it from `models/<metamodel>.<extension>` (the feature\n * model made new when there is none). The feature models of the SPL's modules are then grafted under the root of the SPL's own, and that\n * composed feature model is what is offered. What is wrong with any of it is added to `diagnostics`.\n *\n * Afterwards the engine has no models of its own (`setInstances({})`): the caller sets the product's.\n */\nexport const configure = async ({\n engine,\n resolved,\n spl,\n metamodels,\n offered,\n diagnostics,\n loadCode = true\n}: {\n engine: MetamodelEngine\n resolved: ResolvedSpl\n /** The files of the SPL. */\n spl?: PackageFiles\n metamodels: readonly MetamodelInfo[]\n /** What the engine already offers: the models of the modules. */\n offered: readonly { origin: string, metamodel: string, text: string }[]\n diagnostics: Diagnostic[]\n /** `false` for a check, where the code of the modules is only listed (see `planPlatform`). */\n loadCode?: boolean\n}): Promise<Configuration> => {\n const upper = metamodels.filter((info) => info.level > 0).sort((a, b) => b.level - a.level)\n const contributed = [...offered]\n const models: ConfigurationModel[] = []\n let own: FeatureModelTree | undefined\n\n const fail = (file: string, message: string): void => { diagnostics.push({ severity: 'error', package: 'spl', file, message }) }\n\n for (const info of upper) {\n const file = configurationPath({ info })\n let text = spl === undefined ? undefined : await readPackageText({ files: spl, path: file })\n const stored = text !== undefined\n if (text === undefined) {\n if (info.name === FEATURE_MODEL_GRAMMAR) {\n // an SPL that has no feature model yet has an empty one, named after it\n const name = rootFeatureName({ name: resolved.spl.name })\n text = (await engine.importJson({ featureModel: { name, root: { name, groups: [] }, constraints: [] } })).texts[info.name]\n } else {\n // any other metamodel of a level above 0 starts from what it says is its smallest valid model, until the SPL saves one\n await engine.setContributed(contributed)\n text = (await engine.createInstance(info.name)).text\n }\n if (text === undefined) { fail(file, `There is no model of \"${info.name}\".`); continue }\n }\n await engine.setContributed(contributed)\n const states = await engine.setInstances({ [info.name]: text })\n for (const state of states) diagnostics.push(...toDiagnostics(state.problems, { package: 'spl', file }))\n if (info.name === FEATURE_MODEL_GRAMMAR) {\n // (a model that does not parse has no JSON: what is wrong with it is already in the diagnostics)\n const json = (await engine.toJson(info.name).catch(() => undefined)) as { featureModel?: FeatureModelTree } | undefined\n own = json?.featureModel\n }\n models.push({ metamodel: info.name, level: info.level, text, file, stored })\n contributed.push({ origin: `level-${info.level}`, metamodel: info.name, text })\n }\n\n // the SPL's own feature model is the root and what it declares itself; what its modules declare is grafted in\n const plan = await planPlatform({ resolved, spl, loadCode, ...(own === undefined ? {} : { ownFeatureModel: printUvl({ tree: own }) }) })\n diagnostics.push(...plan.diagnostics)\n\n let featureModel = own\n if (own !== undefined && resolved.modules.length > 0 && plan.featureModel !== '') {\n try {\n featureModel = parseUvl({ content: plan.featureModel })\n const composed = (await engine.importJson({ featureModel })).texts[FEATURE_MODEL_GRAMMAR]\n if (composed === undefined) fail('models/featuremodel', 'The composed feature model could not be made.')\n else {\n const at = contributed.findIndex((item) => item.metamodel === FEATURE_MODEL_GRAMMAR && item.origin.startsWith('level-'))\n contributed[at] = { ...contributed[at]!, text: composed }\n const index = models.findIndex((model) => model.metamodel === FEATURE_MODEL_GRAMMAR)\n models[index] = { ...models[index]!, text: composed }\n }\n } catch (error) {\n if (!(error instanceof UvlParseError)) throw error\n fail('models/featuremodel', `The merged feature model is not valid: ${error.message}`)\n }\n }\n\n // what is offered, with its problems (the feature model of the modules is checked here: a feature declared twice, a constraint on a missing one)\n if (contributed.length > 0) {\n for (const state of await engine.setContributed(contributed)) {\n if (!state.origin.startsWith('level-')) continue\n const model = models.find((candidate) => candidate.metamodel === state.metamodel)\n diagnostics.push(...toDiagnostics(state.problems, { package: 'spl', ...(model === undefined ? {} : { file: model.file }) }))\n }\n }\n await engine.setInstances({})\n\n if (upper.every((info) => info.name !== FEATURE_MODEL_GRAMMAR)) {\n diagnostics.push({ severity: 'error', package: 'spl', message: 'The SPL has no feature metamodel: add \"featuremodel\" to its metamodels.' })\n }\n\n return {\n models,\n ...(featureModel === undefined ? {} : { featureModel }),\n featureModelUvl: featureModel === undefined ? '' : printUvl({ tree: featureModel }),\n plan\n }\n}\n\n/** The names of the features of a configuration's feature model. */\nexport const featureNames = ({ configuration }: { configuration: Pick<Configuration, 'featureModel'> }): string[] =>\n configuration.featureModel === undefined ? [] : featuresOf({ tree: configuration.featureModel }).map((feature) => feature.name)\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { SplManifest } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* The feature metamodel (bango's `featuremodel` package) and its grammars. Every SPL uses it: its feature model is a model of it (level 1),
|
|
4
|
+
* and the feature selection of each product is a model of `featureselection` (level 0) that selects from it.
|
|
5
|
+
*/
|
|
6
|
+
export declare const FEATURE_METAMODEL: {
|
|
7
|
+
/** Where a registry that publishes the LINEA metamodels has it (a workspace on disk has it as `file:metamodels/featuremodel`). */
|
|
8
|
+
readonly location: "gitlab:linea/metamodels/featuremodel";
|
|
9
|
+
readonly range: "^1.0.0";
|
|
10
|
+
};
|
|
11
|
+
export declare const FEATURE_MODEL_GRAMMAR = "featuremodel";
|
|
12
|
+
export declare const FEATURE_SELECTION_GRAMMAR = "featureselection";
|
|
13
|
+
/** The manifest with the feature metamodel in its own `metamodels` (what every SPL has), at `location` when the host has it somewhere else. */
|
|
14
|
+
export declare const withFeatureMetamodel: ({ spl, location }: {
|
|
15
|
+
spl: SplManifest;
|
|
16
|
+
location?: string;
|
|
17
|
+
}) => SplManifest;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The feature metamodel (bango's `featuremodel` package) and its grammars. Every SPL uses it: its feature model is a model of it (level 1),
|
|
3
|
+
* and the feature selection of each product is a model of `featureselection` (level 0) that selects from it.
|
|
4
|
+
*/
|
|
5
|
+
export const FEATURE_METAMODEL = {
|
|
6
|
+
/** Where a registry that publishes the LINEA metamodels has it (a workspace on disk has it as `file:metamodels/featuremodel`). */
|
|
7
|
+
location: 'gitlab:linea/metamodels/featuremodel',
|
|
8
|
+
range: '^1.0.0'
|
|
9
|
+
};
|
|
10
|
+
export const FEATURE_MODEL_GRAMMAR = 'featuremodel';
|
|
11
|
+
export const FEATURE_SELECTION_GRAMMAR = 'featureselection';
|
|
12
|
+
/** The manifest with the feature metamodel in its own `metamodels` (what every SPL has), at `location` when the host has it somewhere else. */
|
|
13
|
+
export const withFeatureMetamodel = ({ spl, location = FEATURE_METAMODEL.location }) => spl.metamodels[location] === undefined ? { ...spl, metamodels: { ...spl.metamodels, [location]: FEATURE_METAMODEL.range } } : spl;
|
|
14
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/modules/configuration/constants.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,kIAAkI;IAClI,QAAQ,EAAE,sCAAsC;IAChD,KAAK,EAAE,QAAQ;CACP,CAAA;AAEV,MAAM,CAAC,MAAM,qBAAqB,GAAG,cAAc,CAAA;AACnD,MAAM,CAAC,MAAM,yBAAyB,GAAG,kBAAkB,CAAA;AAE3D,+IAA+I;AAC/I,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,EAAE,GAAG,EAAE,QAAQ,GAAG,iBAAiB,CAAC,QAAQ,EAA2C,EAAe,EAAE,CAC3I,GAAG,CAAC,UAAU,CAAC,QAAQ,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,EAAE,UAAU,EAAE,EAAE,GAAG,GAAG,CAAC,UAAU,EAAE,CAAC,QAAQ,CAAC,EAAE,iBAAiB,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAA","sourcesContent":["import type { SplManifest } from '../types.js'\n\n/**\n * The feature metamodel (bango's `featuremodel` package) and its grammars. Every SPL uses it: its feature model is a model of it (level 1),\n * and the feature selection of each product is a model of `featureselection` (level 0) that selects from it.\n */\nexport const FEATURE_METAMODEL = {\n /** Where a registry that publishes the LINEA metamodels has it (a workspace on disk has it as `file:metamodels/featuremodel`). */\n location: 'gitlab:linea/metamodels/featuremodel',\n range: '^1.0.0'\n} as const\n\nexport const FEATURE_MODEL_GRAMMAR = 'featuremodel'\nexport const FEATURE_SELECTION_GRAMMAR = 'featureselection'\n\n/** The manifest with the feature metamodel in its own `metamodels` (what every SPL has), at `location` when the host has it somewhere else. */\nexport const withFeatureMetamodel = ({ spl, location = FEATURE_METAMODEL.location }: { spl: SplManifest, location?: string }): SplManifest =>\n spl.metamodels[location] === undefined ? { ...spl, metamodels: { ...spl.metamodels, [location]: FEATURE_METAMODEL.range } } : spl\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { FEATURE_METAMODEL, FEATURE_MODEL_GRAMMAR, FEATURE_SELECTION_GRAMMAR, withFeatureMetamodel } from './constants.js';
|
|
2
|
+
export { configure } from './configure.js';
|
|
3
|
+
export type { Configuration, ConfigurationModel } from './configure.js';
|
|
4
|
+
export { selectionText, defaultSelection, checkSelections } from './selection.js';
|
|
5
|
+
export type { SelectionVerdict } from './selection.js';
|
|
6
|
+
export { bangoName, rootFeatureName } from './names.js';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { FEATURE_METAMODEL, FEATURE_MODEL_GRAMMAR, FEATURE_SELECTION_GRAMMAR, withFeatureMetamodel } from './constants.js';
|
|
2
|
+
export { configure } from './configure.js';
|
|
3
|
+
export { selectionText, defaultSelection, checkSelections } from './selection.js';
|
|
4
|
+
export { bangoName, rootFeatureName } from './names.js';
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/configuration/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,yBAAyB,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAA;AAC1H,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAE1C,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAEjF,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA","sourcesContent":["export { FEATURE_METAMODEL, FEATURE_MODEL_GRAMMAR, FEATURE_SELECTION_GRAMMAR, withFeatureMetamodel } from './constants.js'\nexport { configure } from './configure.js'\nexport type { Configuration, ConfigurationModel } from './configure.js'\nexport { selectionText, defaultSelection, checkSelections } from './selection.js'\nexport type { SelectionVerdict } from './selection.js'\nexport { bangoName, rootFeatureName } from './names.js'\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** A name as the feature metamodel writes it: plain when it can be, else between double quotes. */
|
|
2
|
+
export declare const bangoName: ({ name }: {
|
|
3
|
+
name: string;
|
|
4
|
+
}) => string;
|
|
5
|
+
/** The root feature of a new SPL called `name`: its parts joined in camel case (`QA-Mono.2` is `QAMono2`), or `fallback` when nothing of the name is left. */
|
|
6
|
+
export declare const rootFeatureName: ({ name, fallback }: {
|
|
7
|
+
name: string;
|
|
8
|
+
fallback?: string;
|
|
9
|
+
}) => string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** The words of the feature metamodel's grammars: a name that is one has to be written between quotes. */
|
|
2
|
+
const WORDS = new Set(['featuremodel', 'feature', 'abstract', 'mandatory', 'optional', 'alternative', 'or', 'constraints', 'selection', 'of', 'select', 'deselect']);
|
|
3
|
+
/** A name as the feature metamodel writes it: plain when it can be, else between double quotes. */
|
|
4
|
+
export const bangoName = ({ name }) => /^[_a-zA-Z][\w-]*$/.test(name) && !WORDS.has(name) ? name : JSON.stringify(name);
|
|
5
|
+
/** The root feature of a new SPL called `name`: its parts joined in camel case (`QA-Mono.2` is `QAMono2`), or `fallback` when nothing of the name is left. */
|
|
6
|
+
export const rootFeatureName = ({ name, fallback = 'Spl' }) => name.replace(/(^|[-_.\s]+)(.)/g, (_match, _separator, char) => char.toUpperCase()).replace(/[^A-Za-z0-9_]/g, '') || fallback;
|
|
7
|
+
//# sourceMappingURL=names.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"names.js","sourceRoot":"","sources":["../../../src/modules/configuration/names.ts"],"names":[],"mappings":"AAAA,0GAA0G;AAC1G,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,CAAC,cAAc,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,aAAa,EAAE,IAAI,EAAE,aAAa,EAAE,WAAW,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAA;AAEpK,mGAAmG;AACnG,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,EAAE,IAAI,EAAoB,EAAU,EAAE,CAC9D,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;AAElF,8JAA8J;AAC9J,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,EAAE,IAAI,EAAE,QAAQ,GAAG,KAAK,EAAuC,EAAU,EAAE,CACzG,IAAI,CAAC,OAAO,CAAC,kBAAkB,EAAE,CAAC,MAAM,EAAE,UAAU,EAAE,IAAY,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,OAAO,CAAC,gBAAgB,EAAE,EAAE,CAAC,IAAI,QAAQ,CAAA","sourcesContent":["/** The words of the feature metamodel's grammars: a name that is one has to be written between quotes. */\nconst WORDS = new Set(['featuremodel', 'feature', 'abstract', 'mandatory', 'optional', 'alternative', 'or', 'constraints', 'selection', 'of', 'select', 'deselect'])\n\n/** A name as the feature metamodel writes it: plain when it can be, else between double quotes. */\nexport const bangoName = ({ name }: { name: string }): string =>\n /^[_a-zA-Z][\\w-]*$/.test(name) && !WORDS.has(name) ? name : JSON.stringify(name)\n\n/** The root feature of a new SPL called `name`: its parts joined in camel case (`QA-Mono.2` is `QAMono2`), or `fallback` when nothing of the name is left. */\nexport const rootFeatureName = ({ name, fallback = 'Spl' }: { name: string, fallback?: string }): string =>\n name.replace(/(^|[-_.\\s]+)(.)/g, (_match, _separator, char: string) => char.toUpperCase()).replace(/[^A-Za-z0-9_]/g, '') || fallback\n"]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type FeatureModelTree } from '../../feature-model/uvl.js';
|
|
2
|
+
import type { MetamodelEngine } from '../metamodels/engine.js';
|
|
3
|
+
/** A feature selection as a model of the feature metamodel (`featureselection`): `selection of <model> { select ... }`. */
|
|
4
|
+
export declare const selectionText: ({ model, features }: {
|
|
5
|
+
model: string;
|
|
6
|
+
features: readonly string[];
|
|
7
|
+
}) => string;
|
|
8
|
+
/**
|
|
9
|
+
* The smallest selection the tree of a feature model accepts, by its groups alone: what is mandatory, and the first features of every
|
|
10
|
+
* alternative, or and cardinality group that is in. (Constraints are not looked at: whoever uses it checks the result with the feature
|
|
11
|
+
* metamodel, which also adds what the constraints need.) The root is not listed: every selection has it.
|
|
12
|
+
*/
|
|
13
|
+
export declare const defaultSelection: ({ tree }: {
|
|
14
|
+
tree: FeatureModelTree;
|
|
15
|
+
}) => string[];
|
|
16
|
+
export interface SelectionVerdict {
|
|
17
|
+
readonly valid: boolean;
|
|
18
|
+
/** What the feature metamodel finds wrong with the selection, one message each. */
|
|
19
|
+
readonly problems: readonly string[];
|
|
20
|
+
/** The selection once what the model implies is added (the root, ancestors, mandatory features, what the constraints need). */
|
|
21
|
+
readonly completed: readonly string[];
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* What the feature metamodel says of selections of features against a feature model: whether each is valid, and with what it is completed.
|
|
25
|
+
* `engine` is one prepared for an SPL (`prepareEngine`), so the feature metamodel is loaded; the model is offered to the selections
|
|
26
|
+
* as it is to a product. Selections are independent of each other.
|
|
27
|
+
*/
|
|
28
|
+
export declare const checkSelections: ({ engine, tree, selections }: {
|
|
29
|
+
engine: MetamodelEngine;
|
|
30
|
+
tree: FeatureModelTree;
|
|
31
|
+
selections: readonly (readonly string[])[];
|
|
32
|
+
}) => Promise<SelectionVerdict[]>;
|