@lbdudc/linea-core 0.1.0 → 0.1.2

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.
Files changed (253) hide show
  1. package/README.md +230 -358
  2. package/dist/analysis/analyze.d.ts +0 -54
  3. package/dist/analysis/analyze.js +1 -70
  4. package/dist/analysis/analyze.js.map +1 -1
  5. package/dist/analysis/runtime.d.ts +4 -73
  6. package/dist/analysis/runtime.js +7 -100
  7. package/dist/analysis/runtime.js.map +1 -1
  8. package/dist/analysis/uvl-text.d.ts +8 -0
  9. package/dist/analysis/uvl-text.js +70 -0
  10. package/dist/analysis/uvl-text.js.map +1 -0
  11. package/dist/assets.d.ts +0 -12
  12. package/dist/assets.js +0 -25
  13. package/dist/assets.js.map +1 -1
  14. package/dist/ci/annotations.d.ts +6 -0
  15. package/dist/ci/annotations.js +12 -0
  16. package/dist/ci/annotations.js.map +1 -0
  17. package/dist/ci/leftovers.d.ts +25 -0
  18. package/dist/ci/leftovers.js +50 -0
  19. package/dist/ci/leftovers.js.map +1 -0
  20. package/dist/ci/pairwise.d.ts +11 -0
  21. package/dist/ci/pairwise.js +35 -0
  22. package/dist/ci/pairwise.js.map +1 -0
  23. package/dist/ci/pipeline.d.ts +18 -0
  24. package/dist/ci/pipeline.js +26 -0
  25. package/dist/ci/pipeline.js.map +1 -0
  26. package/dist/ci/select.d.ts +28 -0
  27. package/dist/ci/select.js +43 -0
  28. package/dist/ci/select.js.map +1 -0
  29. package/dist/ci/validate-specs.d.ts +52 -0
  30. package/dist/ci/validate-specs.js +212 -0
  31. package/dist/ci/validate-specs.js.map +1 -0
  32. package/dist/constants.d.ts +1 -60
  33. package/dist/constants.js +1 -58
  34. package/dist/constants.js.map +1 -1
  35. package/dist/derivation/derive.d.ts +0 -56
  36. package/dist/derivation/derive.js +21 -72
  37. package/dist/derivation/derive.js.map +1 -1
  38. package/dist/derivation/engine.d.ts +10 -42
  39. package/dist/derivation/engine.js +37 -68
  40. package/dist/derivation/engine.js.map +1 -1
  41. package/dist/derivation/selection-error.d.ts +7 -0
  42. package/dist/derivation/selection-error.js +13 -0
  43. package/dist/derivation/selection-error.js.map +1 -0
  44. package/dist/errors.d.ts +19 -47
  45. package/dist/errors.js +28 -47
  46. package/dist/errors.js.map +1 -1
  47. package/dist/feature-model/uvl.d.ts +52 -0
  48. package/dist/feature-model/uvl.js +191 -0
  49. package/dist/feature-model/uvl.js.map +1 -0
  50. package/dist/fs/archive.d.ts +0 -16
  51. package/dist/fs/archive.js +0 -36
  52. package/dist/fs/archive.js.map +1 -1
  53. package/dist/fs/diff.d.ts +0 -30
  54. package/dist/fs/diff.js +4 -65
  55. package/dist/fs/diff.js.map +1 -1
  56. package/dist/fs/format.d.ts +0 -16
  57. package/dist/fs/format.js +0 -52
  58. package/dist/fs/format.js.map +1 -1
  59. package/dist/fs/workspace.d.ts +0 -52
  60. package/dist/fs/workspace.js +0 -56
  61. package/dist/fs/workspace.js.map +1 -1
  62. package/dist/index.d.ts +23 -29
  63. package/dist/index.js +15 -35
  64. package/dist/index.js.map +1 -1
  65. package/dist/internal/guards.d.ts +0 -13
  66. package/dist/internal/guards.js +0 -13
  67. package/dist/internal/guards.js.map +1 -1
  68. package/dist/line/deletion.d.ts +33 -0
  69. package/dist/line/deletion.js +23 -0
  70. package/dist/line/deletion.js.map +1 -0
  71. package/dist/line/platform-files.d.ts +15 -64
  72. package/dist/line/platform-files.js +18 -94
  73. package/dist/line/platform-files.js.map +1 -1
  74. package/dist/line/restoration.d.ts +27 -0
  75. package/dist/line/restoration.js +27 -0
  76. package/dist/line/restoration.js.map +1 -0
  77. package/dist/line/scaffold.d.ts +26 -57
  78. package/dist/line/scaffold.js +32 -93
  79. package/dist/line/scaffold.js.map +1 -1
  80. package/dist/line/templates/core/extra.js +54 -54
  81. package/dist/line/templates/core/transformation.js +208 -196
  82. package/dist/line/templates/pipeline/.gitlab-ci.yml +51 -51
  83. package/dist/line/templates/pipeline/ci/test-client.sh +16 -16
  84. package/dist/line/templates/pipeline/ci/test-server.sh +16 -16
  85. package/dist/line/templates/pipeline/github-ci.yml +50 -0
  86. package/dist/line/templates/pipeline/spl-gitlab-ci.yml +182 -0
  87. package/dist/modules/configuration/configure.d.ts +52 -0
  88. package/dist/modules/configuration/configure.js +101 -0
  89. package/dist/modules/configuration/configure.js.map +1 -0
  90. package/dist/modules/configuration/constants.d.ts +17 -0
  91. package/dist/modules/configuration/constants.js +14 -0
  92. package/dist/modules/configuration/constants.js.map +1 -0
  93. package/dist/modules/configuration/index.d.ts +6 -0
  94. package/dist/modules/configuration/index.js +5 -0
  95. package/dist/modules/configuration/index.js.map +1 -0
  96. package/dist/modules/configuration/names.d.ts +9 -0
  97. package/dist/modules/configuration/names.js +7 -0
  98. package/dist/modules/configuration/names.js.map +1 -0
  99. package/dist/modules/configuration/selection.d.ts +32 -0
  100. package/dist/modules/configuration/selection.js +49 -0
  101. package/dist/modules/configuration/selection.js.map +1 -0
  102. package/dist/modules/diagnostics.d.ts +2 -0
  103. package/dist/modules/diagnostics.js +2 -0
  104. package/dist/modules/diagnostics.js.map +1 -0
  105. package/dist/modules/index.d.ts +18 -0
  106. package/dist/modules/index.js +18 -0
  107. package/dist/modules/index.js.map +1 -0
  108. package/dist/modules/metamodels/engine.d.ts +93 -0
  109. package/dist/modules/metamodels/engine.js +10 -0
  110. package/dist/modules/metamodels/engine.js.map +1 -0
  111. package/dist/modules/metamodels/files.d.ts +40 -0
  112. package/dist/modules/metamodels/files.js +58 -0
  113. package/dist/modules/metamodels/files.js.map +1 -0
  114. package/dist/modules/metamodels/index.d.ts +8 -0
  115. package/dist/modules/metamodels/index.js +5 -0
  116. package/dist/modules/metamodels/index.js.map +1 -0
  117. package/dist/modules/metamodels/layout.d.ts +23 -0
  118. package/dist/modules/metamodels/layout.js +29 -0
  119. package/dist/modules/metamodels/layout.js.map +1 -0
  120. package/dist/modules/metamodels/offered.d.ts +15 -0
  121. package/dist/modules/metamodels/offered.js +14 -0
  122. package/dist/modules/metamodels/offered.js.map +1 -0
  123. package/dist/modules/metamodels/prepare.d.ts +20 -0
  124. package/dist/modules/metamodels/prepare.js +155 -0
  125. package/dist/modules/metamodels/prepare.js.map +1 -0
  126. package/dist/modules/packages/index.d.ts +4 -0
  127. package/dist/modules/packages/index.js +4 -0
  128. package/dist/modules/packages/index.js.map +1 -0
  129. package/dist/modules/packages/location.d.ts +21 -0
  130. package/dist/modules/packages/location.js +34 -0
  131. package/dist/modules/packages/location.js.map +1 -0
  132. package/dist/modules/packages/manifests.d.ts +33 -0
  133. package/dist/modules/packages/manifests.js +231 -0
  134. package/dist/modules/packages/manifests.js.map +1 -0
  135. package/dist/modules/packages/source.d.ts +34 -0
  136. package/dist/modules/packages/source.js +128 -0
  137. package/dist/modules/packages/source.js.map +1 -0
  138. package/dist/modules/products/check.d.ts +28 -0
  139. package/dist/modules/products/check.js +61 -0
  140. package/dist/modules/products/check.js.map +1 -0
  141. package/dist/modules/products/derive.d.ts +30 -0
  142. package/dist/modules/products/derive.js +56 -0
  143. package/dist/modules/products/derive.js.map +1 -0
  144. package/dist/modules/products/index.d.ts +5 -0
  145. package/dist/modules/products/index.js +4 -0
  146. package/dist/modules/products/index.js.map +1 -0
  147. package/dist/modules/products/seed.d.ts +18 -0
  148. package/dist/modules/products/seed.js +23 -0
  149. package/dist/modules/products/seed.js.map +1 -0
  150. package/dist/modules/registry/catalog.d.ts +64 -0
  151. package/dist/modules/registry/catalog.js +91 -0
  152. package/dist/modules/registry/catalog.js.map +1 -0
  153. package/dist/modules/registry/index.d.ts +5 -0
  154. package/dist/modules/registry/index.js +4 -0
  155. package/dist/modules/registry/index.js.map +1 -0
  156. package/dist/modules/registry/registry.d.ts +34 -0
  157. package/dist/modules/registry/registry.js +37 -0
  158. package/dist/modules/registry/registry.js.map +1 -0
  159. package/dist/modules/registry/routing.d.ts +8 -0
  160. package/dist/modules/registry/routing.js +23 -0
  161. package/dist/modules/registry/routing.js.map +1 -0
  162. package/dist/modules/resolution/closure.d.ts +28 -0
  163. package/dist/modules/resolution/closure.js +105 -0
  164. package/dist/modules/resolution/closure.js.map +1 -0
  165. package/dist/modules/resolution/index.d.ts +4 -0
  166. package/dist/modules/resolution/index.js +3 -0
  167. package/dist/modules/resolution/index.js.map +1 -0
  168. package/dist/modules/resolution/resolve.d.ts +33 -0
  169. package/dist/modules/resolution/resolve.js +59 -0
  170. package/dist/modules/resolution/resolve.js.map +1 -0
  171. package/dist/modules/resolution/resolvers.d.ts +23 -0
  172. package/dist/modules/resolution/resolvers.js +34 -0
  173. package/dist/modules/resolution/resolvers.js.map +1 -0
  174. package/dist/modules/spl/check.d.ts +25 -0
  175. package/dist/modules/spl/check.js +21 -0
  176. package/dist/modules/spl/check.js.map +1 -0
  177. package/dist/modules/spl/cip.d.ts +67 -0
  178. package/dist/modules/spl/cip.js +98 -0
  179. package/dist/modules/spl/cip.js.map +1 -0
  180. package/dist/modules/spl/feature-model.d.ts +39 -0
  181. package/dist/modules/spl/feature-model.js +106 -0
  182. package/dist/modules/spl/feature-model.js.map +1 -0
  183. package/dist/modules/spl/index.d.ts +6 -0
  184. package/dist/modules/spl/index.js +4 -0
  185. package/dist/modules/spl/index.js.map +1 -0
  186. package/dist/modules/spl/platform.d.ts +49 -0
  187. package/dist/modules/spl/platform.js +316 -0
  188. package/dist/modules/spl/platform.js.map +1 -0
  189. package/dist/modules/types.d.ts +132 -0
  190. package/dist/modules/types.js +2 -0
  191. package/dist/modules/types.js.map +1 -0
  192. package/dist/product/engine-spec.d.ts +0 -16
  193. package/dist/product/engine-spec.js +4 -50
  194. package/dist/product/engine-spec.js.map +1 -1
  195. package/dist/product/spec.d.ts +0 -82
  196. package/dist/product/spec.js +0 -79
  197. package/dist/product/spec.js.map +1 -1
  198. package/dist/product/version.d.ts +0 -23
  199. package/dist/product/version.js +0 -28
  200. package/dist/product/version.js.map +1 -1
  201. package/dist/products-index/products-index.d.ts +0 -165
  202. package/dist/products-index/products-index.js +0 -176
  203. package/dist/products-index/products-index.js.map +1 -1
  204. package/dist/workspace/context.d.ts +25 -0
  205. package/dist/workspace/context.js +43 -0
  206. package/dist/workspace/context.js.map +1 -0
  207. package/dist/workspace/gitExclude.d.ts +2 -0
  208. package/dist/workspace/gitExclude.js +19 -0
  209. package/dist/workspace/gitExclude.js.map +1 -0
  210. package/dist/workspace/host.d.ts +14 -0
  211. package/dist/workspace/host.js +13 -0
  212. package/dist/workspace/host.js.map +1 -0
  213. package/dist/workspace/index.d.ts +12 -0
  214. package/dist/workspace/index.js +12 -0
  215. package/dist/workspace/index.js.map +1 -0
  216. package/dist/workspace/local.d.ts +81 -0
  217. package/dist/workspace/local.js +287 -0
  218. package/dist/workspace/local.js.map +1 -0
  219. package/dist/workspace/modular.d.ts +95 -0
  220. package/dist/workspace/modular.js +301 -0
  221. package/dist/workspace/modular.js.map +1 -0
  222. package/dist/workspace/operations.d.ts +35 -0
  223. package/dist/workspace/operations.js +57 -0
  224. package/dist/workspace/operations.js.map +1 -0
  225. package/dist/workspace/origin.d.ts +20 -0
  226. package/dist/workspace/origin.js +19 -0
  227. package/dist/workspace/origin.js.map +1 -0
  228. package/package.json +82 -67
  229. package/dist/feature-model/convert.d.ts +0 -35
  230. package/dist/feature-model/convert.js +0 -47
  231. package/dist/feature-model/convert.js.map +0 -1
  232. package/dist/feature-model/engine.d.ts +0 -60
  233. package/dist/feature-model/engine.js +0 -139
  234. package/dist/feature-model/engine.js.map +0 -1
  235. package/dist/feature-model/inspect.d.ts +0 -67
  236. package/dist/feature-model/inspect.js +0 -113
  237. package/dist/feature-model/inspect.js.map +0 -1
  238. package/dist/feature-model/io.d.ts +0 -66
  239. package/dist/feature-model/io.js +0 -92
  240. package/dist/feature-model/io.js.map +0 -1
  241. package/dist/feature-model/parse.d.ts +0 -30
  242. package/dist/feature-model/parse.js +0 -36
  243. package/dist/feature-model/parse.js.map +0 -1
  244. package/dist/feature-model/text.d.ts +0 -54
  245. package/dist/feature-model/text.js +0 -126
  246. package/dist/feature-model/text.js.map +0 -1
  247. package/dist/line/templates/metamodels/dataModel/extra.js +0 -328
  248. package/dist/line/templates/metamodels/dataModel/transformation.js +0 -211
  249. package/dist/line/templates/metamodels/sensor/extra.js +0 -36
  250. package/dist/line/templates/metamodels/sensor/transformation.js +0 -47
  251. package/dist/selection/selection.d.ts +0 -126
  252. package/dist/selection/selection.js +0 -152
  253. package/dist/selection/selection.js.map +0 -1
@@ -1,51 +1,51 @@
1
- #
2
- # A pipeline is composed of independent jobs that run scripts, grouped into stages.
3
- # Stages run in sequential order, but jobs within stages run in parallel.
4
- #
5
- # For more information, see: https://docs.gitlab.com/ee/ci/yaml/index.html#stages
6
-
7
- stages:
8
- - test
9
-
10
- # Test commands live in ci/test-server.sh and ci/test-client.sh.
11
- # Domain engineers edit those scripts to wire in real tests; this YAML should
12
- # not need changes.
13
-
14
- test_server:
15
- stage: test
16
- image: gradle:8-jdk21
17
- variables:
18
- GRADLE_USER_HOME: "$CI_PROJECT_DIR/.gradle"
19
- script:
20
- - sh ./ci/test-server.sh
21
- cache:
22
- key: gradle-$CI_COMMIT_REF_SLUG
23
- paths:
24
- - .gradle/caches
25
- - .gradle/wrapper
26
- artifacts:
27
- when: always
28
- reports:
29
- junit: server/build/test-results/test/**/TEST-*.xml
30
- expire_in: 1 week
31
- rules:
32
- - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
33
- - if: '$CI_COMMIT_BRANCH'
34
-
35
- test_client:
36
- stage: test
37
- image: node:20
38
- script:
39
- - sh ./ci/test-client.sh
40
- cache:
41
- key: node-$CI_COMMIT_REF_SLUG
42
- paths:
43
- - client/node_modules
44
- artifacts:
45
- when: always
46
- reports:
47
- junit: client/test-results/**/junit*.xml
48
- expire_in: 1 week
49
- rules:
50
- - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
51
- - if: '$CI_COMMIT_BRANCH'
1
+ #
2
+ # A pipeline is composed of independent jobs that run scripts, grouped into stages.
3
+ # Stages run in sequential order, but jobs within stages run in parallel.
4
+ #
5
+ # For more information, see: https://docs.gitlab.com/ee/ci/yaml/index.html#stages
6
+
7
+ stages:
8
+ - test
9
+
10
+ # Test commands live in ci/test-server.sh and ci/test-client.sh.
11
+ # Domain engineers edit those scripts to wire in real tests; this YAML should
12
+ # not need changes.
13
+
14
+ test_server:
15
+ stage: test
16
+ image: gradle:8-jdk21
17
+ variables:
18
+ GRADLE_USER_HOME: "$CI_PROJECT_DIR/.gradle"
19
+ script:
20
+ - sh ./ci/test-server.sh
21
+ cache:
22
+ key: gradle-$CI_COMMIT_REF_SLUG
23
+ paths:
24
+ - .gradle/caches
25
+ - .gradle/wrapper
26
+ artifacts:
27
+ when: always
28
+ reports:
29
+ junit: server/build/test-results/test/**/TEST-*.xml
30
+ expire_in: 1 week
31
+ rules:
32
+ - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
33
+ - if: '$CI_COMMIT_BRANCH'
34
+
35
+ test_client:
36
+ stage: test
37
+ image: node:20
38
+ script:
39
+ - sh ./ci/test-client.sh
40
+ cache:
41
+ key: node-$CI_COMMIT_REF_SLUG
42
+ paths:
43
+ - client/node_modules
44
+ artifacts:
45
+ when: always
46
+ reports:
47
+ junit: client/test-results/**/junit*.xml
48
+ expire_in: 1 week
49
+ rules:
50
+ - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
51
+ - if: '$CI_COMMIT_BRANCH'
@@ -1,16 +1,16 @@
1
- #!/bin/sh
2
- #
3
- # Client test command for this product.
4
- #
5
- # Default is a no-op (exit 0) so generated products with no tests yield a
6
- # green pipeline. Replace the echo+exit below with the real test command,
7
- # e.g.:
8
- #
9
- # cd client && npm ci && npm test
10
- # cd client && yarn install --frozen-lockfile && yarn test
11
- #
12
- # Any non-zero exit will fail the test_client job in .gitlab-ci.yml.
13
-
14
- echo "[test-client] No client tests defined for this product."
15
- echo "[test-client] Edit ci/test-client.sh to wire in real tests."
16
- exit 0
1
+ #!/bin/sh
2
+ #
3
+ # Client test command for this product.
4
+ #
5
+ # Default is a no-op (exit 0) so generated products with no tests yield a
6
+ # green pipeline. Replace the echo+exit below with the real test command,
7
+ # e.g.:
8
+ #
9
+ # cd client && npm ci && npm test
10
+ # cd client && yarn install --frozen-lockfile && yarn test
11
+ #
12
+ # Any non-zero exit will fail the test_client job in .gitlab-ci.yml.
13
+
14
+ echo "[test-client] No client tests defined for this product."
15
+ echo "[test-client] Edit ci/test-client.sh to wire in real tests."
16
+ exit 0
@@ -1,16 +1,16 @@
1
- #!/bin/sh
2
- #
3
- # Server test command for this product.
4
- #
5
- # Default is a no-op (exit 0) so generated products with no tests yield a
6
- # green pipeline. Replace the echo+exit below with the real test command,
7
- # e.g.:
8
- #
9
- # cd server && ./gradlew test
10
- # cd server && mvn test
11
- #
12
- # Any non-zero exit will fail the test_server job in .gitlab-ci.yml.
13
-
14
- echo "[test-server] No server tests defined for this product."
15
- echo "[test-server] Edit ci/test-server.sh to wire in real tests."
16
- exit 0
1
+ #!/bin/sh
2
+ #
3
+ # Server test command for this product.
4
+ #
5
+ # Default is a no-op (exit 0) so generated products with no tests yield a
6
+ # green pipeline. Replace the echo+exit below with the real test command,
7
+ # e.g.:
8
+ #
9
+ # cd server && ./gradlew test
10
+ # cd server && mvn test
11
+ #
12
+ # Any non-zero exit will fail the test_server job in .gitlab-ci.yml.
13
+
14
+ echo "[test-server] No server tests defined for this product."
15
+ echo "[test-server] Edit ci/test-server.sh to wire in real tests."
16
+ exit 0
@@ -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,CAAA;AACvD,OAAO,EAAE,YAAY,EAAqB,MAAM,oBAAoB,CAAA;AAEpE,OAAO,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAA;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAwB5C,qFAAqF;AACrF,MAAM,iBAAiB,GAAG,CAAC,EAAE,IAAI,EAAuD,EAAU,EAAE,CAAC,UAAU,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,SAAS,EAAE,CAAA;AAE5I;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,KAAK,EAAE,EAC9B,MAAM,EACN,Q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,CAAA;QAC9H,CAAC;IACH,CAAC;IACD,MAAM,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC,CAAA;IAE7B,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,qBAAqB,CAAC,EAAE,CAAC;QAC/D,WAAW,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,yEAAyE,EAAE,CAAC,CAAA;IAC7I,CAAC;IAED,OAAO;QACL,MAAM;QACN,GAAG,CAAC,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC;QACvD,eAAe,EAAE,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC;QACnF,IAAI;KACL,CAAA;AACH,CAAC,CAAA;AAED,oEAAoE;AACpE,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,EAAE,aAAa,EAA0D,EAAY,EAAE,CAClH,aAAa,CAAC,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,EAAE,IAAI,EAAE,aAAa,CAAC,YAAY,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"]}