@lbdudc/linea-core 0.1.1 → 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 (249) hide show
  1. package/README.md +132 -260
  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/transformation.js +17 -5
  81. package/dist/line/templates/pipeline/github-ci.yml +50 -0
  82. package/dist/line/templates/pipeline/spl-gitlab-ci.yml +182 -0
  83. package/dist/modules/configuration/configure.d.ts +52 -0
  84. package/dist/modules/configuration/configure.js +101 -0
  85. package/dist/modules/configuration/configure.js.map +1 -0
  86. package/dist/modules/configuration/constants.d.ts +17 -0
  87. package/dist/modules/configuration/constants.js +14 -0
  88. package/dist/modules/configuration/constants.js.map +1 -0
  89. package/dist/modules/configuration/index.d.ts +6 -0
  90. package/dist/modules/configuration/index.js +5 -0
  91. package/dist/modules/configuration/index.js.map +1 -0
  92. package/dist/modules/configuration/names.d.ts +9 -0
  93. package/dist/modules/configuration/names.js +7 -0
  94. package/dist/modules/configuration/names.js.map +1 -0
  95. package/dist/modules/configuration/selection.d.ts +32 -0
  96. package/dist/modules/configuration/selection.js +49 -0
  97. package/dist/modules/configuration/selection.js.map +1 -0
  98. package/dist/modules/diagnostics.d.ts +2 -0
  99. package/dist/modules/diagnostics.js +2 -0
  100. package/dist/modules/diagnostics.js.map +1 -0
  101. package/dist/modules/index.d.ts +18 -0
  102. package/dist/modules/index.js +18 -0
  103. package/dist/modules/index.js.map +1 -0
  104. package/dist/modules/metamodels/engine.d.ts +93 -0
  105. package/dist/modules/metamodels/engine.js +10 -0
  106. package/dist/modules/metamodels/engine.js.map +1 -0
  107. package/dist/modules/metamodels/files.d.ts +40 -0
  108. package/dist/modules/metamodels/files.js +58 -0
  109. package/dist/modules/metamodels/files.js.map +1 -0
  110. package/dist/modules/metamodels/index.d.ts +8 -0
  111. package/dist/modules/metamodels/index.js +5 -0
  112. package/dist/modules/metamodels/index.js.map +1 -0
  113. package/dist/modules/metamodels/layout.d.ts +23 -0
  114. package/dist/modules/metamodels/layout.js +29 -0
  115. package/dist/modules/metamodels/layout.js.map +1 -0
  116. package/dist/modules/metamodels/offered.d.ts +15 -0
  117. package/dist/modules/metamodels/offered.js +14 -0
  118. package/dist/modules/metamodels/offered.js.map +1 -0
  119. package/dist/modules/metamodels/prepare.d.ts +20 -0
  120. package/dist/modules/metamodels/prepare.js +155 -0
  121. package/dist/modules/metamodels/prepare.js.map +1 -0
  122. package/dist/modules/packages/index.d.ts +4 -0
  123. package/dist/modules/packages/index.js +4 -0
  124. package/dist/modules/packages/index.js.map +1 -0
  125. package/dist/modules/packages/location.d.ts +21 -0
  126. package/dist/modules/packages/location.js +34 -0
  127. package/dist/modules/packages/location.js.map +1 -0
  128. package/dist/modules/packages/manifests.d.ts +33 -0
  129. package/dist/modules/packages/manifests.js +231 -0
  130. package/dist/modules/packages/manifests.js.map +1 -0
  131. package/dist/modules/packages/source.d.ts +34 -0
  132. package/dist/modules/packages/source.js +128 -0
  133. package/dist/modules/packages/source.js.map +1 -0
  134. package/dist/modules/products/check.d.ts +28 -0
  135. package/dist/modules/products/check.js +61 -0
  136. package/dist/modules/products/check.js.map +1 -0
  137. package/dist/modules/products/derive.d.ts +30 -0
  138. package/dist/modules/products/derive.js +56 -0
  139. package/dist/modules/products/derive.js.map +1 -0
  140. package/dist/modules/products/index.d.ts +5 -0
  141. package/dist/modules/products/index.js +4 -0
  142. package/dist/modules/products/index.js.map +1 -0
  143. package/dist/modules/products/seed.d.ts +18 -0
  144. package/dist/modules/products/seed.js +23 -0
  145. package/dist/modules/products/seed.js.map +1 -0
  146. package/dist/modules/registry/catalog.d.ts +64 -0
  147. package/dist/modules/registry/catalog.js +91 -0
  148. package/dist/modules/registry/catalog.js.map +1 -0
  149. package/dist/modules/registry/index.d.ts +5 -0
  150. package/dist/modules/registry/index.js +4 -0
  151. package/dist/modules/registry/index.js.map +1 -0
  152. package/dist/modules/registry/registry.d.ts +34 -0
  153. package/dist/modules/registry/registry.js +37 -0
  154. package/dist/modules/registry/registry.js.map +1 -0
  155. package/dist/modules/registry/routing.d.ts +8 -0
  156. package/dist/modules/registry/routing.js +23 -0
  157. package/dist/modules/registry/routing.js.map +1 -0
  158. package/dist/modules/resolution/closure.d.ts +28 -0
  159. package/dist/modules/resolution/closure.js +105 -0
  160. package/dist/modules/resolution/closure.js.map +1 -0
  161. package/dist/modules/resolution/index.d.ts +4 -0
  162. package/dist/modules/resolution/index.js +3 -0
  163. package/dist/modules/resolution/index.js.map +1 -0
  164. package/dist/modules/resolution/resolve.d.ts +33 -0
  165. package/dist/modules/resolution/resolve.js +59 -0
  166. package/dist/modules/resolution/resolve.js.map +1 -0
  167. package/dist/modules/resolution/resolvers.d.ts +23 -0
  168. package/dist/modules/resolution/resolvers.js +34 -0
  169. package/dist/modules/resolution/resolvers.js.map +1 -0
  170. package/dist/modules/spl/check.d.ts +25 -0
  171. package/dist/modules/spl/check.js +21 -0
  172. package/dist/modules/spl/check.js.map +1 -0
  173. package/dist/modules/spl/cip.d.ts +67 -0
  174. package/dist/modules/spl/cip.js +98 -0
  175. package/dist/modules/spl/cip.js.map +1 -0
  176. package/dist/modules/spl/feature-model.d.ts +39 -0
  177. package/dist/modules/spl/feature-model.js +106 -0
  178. package/dist/modules/spl/feature-model.js.map +1 -0
  179. package/dist/modules/spl/index.d.ts +6 -0
  180. package/dist/modules/spl/index.js +4 -0
  181. package/dist/modules/spl/index.js.map +1 -0
  182. package/dist/modules/spl/platform.d.ts +49 -0
  183. package/dist/modules/spl/platform.js +316 -0
  184. package/dist/modules/spl/platform.js.map +1 -0
  185. package/dist/modules/types.d.ts +132 -0
  186. package/dist/modules/types.js +2 -0
  187. package/dist/modules/types.js.map +1 -0
  188. package/dist/product/engine-spec.d.ts +0 -16
  189. package/dist/product/engine-spec.js +4 -50
  190. package/dist/product/engine-spec.js.map +1 -1
  191. package/dist/product/spec.d.ts +0 -82
  192. package/dist/product/spec.js +0 -79
  193. package/dist/product/spec.js.map +1 -1
  194. package/dist/product/version.d.ts +0 -23
  195. package/dist/product/version.js +0 -28
  196. package/dist/product/version.js.map +1 -1
  197. package/dist/products-index/products-index.d.ts +0 -165
  198. package/dist/products-index/products-index.js +0 -176
  199. package/dist/products-index/products-index.js.map +1 -1
  200. package/dist/workspace/context.d.ts +25 -0
  201. package/dist/workspace/context.js +43 -0
  202. package/dist/workspace/context.js.map +1 -0
  203. package/dist/workspace/gitExclude.d.ts +2 -0
  204. package/dist/workspace/gitExclude.js +19 -0
  205. package/dist/workspace/gitExclude.js.map +1 -0
  206. package/dist/workspace/host.d.ts +14 -0
  207. package/dist/workspace/host.js +13 -0
  208. package/dist/workspace/host.js.map +1 -0
  209. package/dist/workspace/index.d.ts +12 -0
  210. package/dist/workspace/index.js +12 -0
  211. package/dist/workspace/index.js.map +1 -0
  212. package/dist/workspace/local.d.ts +81 -0
  213. package/dist/workspace/local.js +287 -0
  214. package/dist/workspace/local.js.map +1 -0
  215. package/dist/workspace/modular.d.ts +95 -0
  216. package/dist/workspace/modular.js +301 -0
  217. package/dist/workspace/modular.js.map +1 -0
  218. package/dist/workspace/operations.d.ts +35 -0
  219. package/dist/workspace/operations.js +57 -0
  220. package/dist/workspace/operations.js.map +1 -0
  221. package/dist/workspace/origin.d.ts +20 -0
  222. package/dist/workspace/origin.js +19 -0
  223. package/dist/workspace/origin.js.map +1 -0
  224. package/package.json +22 -7
  225. package/dist/feature-model/convert.d.ts +0 -35
  226. package/dist/feature-model/convert.js +0 -47
  227. package/dist/feature-model/convert.js.map +0 -1
  228. package/dist/feature-model/engine.d.ts +0 -60
  229. package/dist/feature-model/engine.js +0 -139
  230. package/dist/feature-model/engine.js.map +0 -1
  231. package/dist/feature-model/inspect.d.ts +0 -67
  232. package/dist/feature-model/inspect.js +0 -113
  233. package/dist/feature-model/inspect.js.map +0 -1
  234. package/dist/feature-model/io.d.ts +0 -66
  235. package/dist/feature-model/io.js +0 -92
  236. package/dist/feature-model/io.js.map +0 -1
  237. package/dist/feature-model/parse.d.ts +0 -30
  238. package/dist/feature-model/parse.js +0 -36
  239. package/dist/feature-model/parse.js.map +0 -1
  240. package/dist/feature-model/text.d.ts +0 -54
  241. package/dist/feature-model/text.js +0 -126
  242. package/dist/feature-model/text.js.map +0 -1
  243. package/dist/line/templates/metamodels/dataModel/extra.js +0 -328
  244. package/dist/line/templates/metamodels/dataModel/transformation.js +0 -211
  245. package/dist/line/templates/metamodels/sensor/extra.js +0 -36
  246. package/dist/line/templates/metamodels/sensor/transformation.js +0 -47
  247. package/dist/selection/selection.d.ts +0 -126
  248. package/dist/selection/selection.js +0 -152
  249. package/dist/selection/selection.js.map +0 -1
@@ -1,73 +1,24 @@
1
- /**
2
- * A file to be written somewhere, described without deciding where.
3
- *
4
- * The pure half of the scaffold API returns these so linea-server can push them
5
- * to GitLab and linea-cli can write them to disk, from the same description.
6
- */
7
1
  export interface FileSpec {
8
- /** Repository-relative path, always POSIX (`/`), never absolute. */
9
2
  readonly path: string;
10
- /** File contents. */
11
3
  readonly content: string;
12
- /** How `content` is encoded. Every seeded file is text today. */
13
4
  readonly encoding: 'text' | 'base64';
14
5
  }
15
- /** Metamodels that contribute extra template fragments. */
16
- declare const METAMODEL_TEMPLATES: {
17
- readonly UML: {
18
- readonly extra: "metamodels/dataModel/extra.js";
19
- readonly transformation: "metamodels/dataModel/transformation.js";
20
- };
21
- readonly SENSOR: {
22
- readonly extra: "metamodels/sensor/extra.js";
23
- readonly transformation: "metamodels/sensor/transformation.js";
24
- };
25
- };
26
- /** A metamodel name recognised by the template factory. */
27
- export type MetamodelName = keyof typeof METAMODEL_TEMPLATES;
28
- /**
29
- * Builds `src/platform/extra.js` for a line.
30
- *
31
- * WRITING YOUR OWN `extra.js`: do NOT use `//` line comments. The template
32
- * processor concatenates this file into the function it builds and then strips
33
- * every newline from it (`spl-js-engine/src/template-engine/processor.js:28`),
34
- * so a line comment swallows the rest of that function — including its final
35
- * `return`. Every annotated file then processes to nothing and, because the
36
- * engine skips empty output, the derivation produces ZERO files WITHOUT raising
37
- * an error. Use `/* ... *\/` blocks. Neither the monolith's `core/extra.js` nor
38
- * its mock LPS uses line comments, for exactly this reason.
39
- *
40
- * @param params.models Metamodels chosen for the line, e.g. `['UML']`. Unknown
41
- * names are ignored, matching the monolith.
42
- * @returns The file contents: core template plus one fragment per known model.
43
- * @throws {InvalidArgumentError} when `models` is not an array of strings.
44
- */
45
- export declare const buildExtraJs: ({ models }: {
46
- models?: readonly string[];
47
- }) => string;
48
6
  /**
49
- * Builds `src/platform/transformation.js` for a line.
50
- *
51
- * WRITING YOUR OWN `transformation.js`: the same `//` trap described on
52
- * {@link buildExtraJs} applies here — the processor strips every newline, so a
53
- * line comment silently swallows the rest of the generated function and the
54
- * derivation produces ZERO files without raising. Use block comments.
55
- *
56
- * @param params.models Metamodels chosen for the line. Unknown names are ignored.
57
- * @returns The file contents: core template plus one fragment per known model.
58
- * @throws {InvalidArgumentError} when `models` is not an array of strings.
7
+ * The platform files that every line has. What a product needs of its data model, its sensors and the rest is not here: those are
8
+ * metamodels that the modules of an SPL bring, and their models are derived through each metamodel's own JSON mapping.
59
9
  */
60
- export declare const buildTransformationJs: ({ models }: {
61
- models?: readonly string[];
62
- }) => string;
10
+ export declare const buildExtraJs: () => string;
11
+ export declare const buildTransformationJs: () => string;
12
+ /** The CI of the products an SPL generates: the pipeline file of the git host the SPL lives on, and the scripts it runs. */
13
+ /** `none`: the host runs no pipelines (the repositories kept on LINEA's own server), so there is no pipeline file; the scripts stay. */
14
+ export type CiHost = 'gitlab' | 'github' | 'none';
15
+ export declare const getPipelineFiles: ({ ci }?: {
16
+ ci?: CiHost;
17
+ }) => FileSpec[];
63
18
  /**
64
- * The default CI pipeline files seeded into every new line repository.
65
- *
66
- * Migrated from `PipelineFileFactory.js:PIPELINE_FILES`, same paths and same
67
- * order. A function rather than an exported constant so no module-level state
68
- * holds the file contents (ADR-014) and so each caller gets its own array.
69
- *
70
- * @returns The pipeline files, in the order the monolith creates them.
19
+ * The CI of the SPL repository itself (not of its products): what a merge request does to the products that exist. Only for GitLab so far;
20
+ * a line that lives on GitHub gets none.
71
21
  */
72
- export declare const getPipelineFiles: () => FileSpec[];
73
- export {};
22
+ export declare const getSplPipelineFiles: ({ ci }?: {
23
+ ci?: CiHost;
24
+ }) => FileSpec[];
@@ -1,103 +1,20 @@
1
- /**
2
- * Platform files seeded into a brand new line.
3
- *
4
- * Migrated from:
5
- * - `linea/server/src/model/services/templates/PlatformFileFactory.js`
6
- * (`buildExtraJs`, `buildTransformationJs`)
7
- * - `linea/server/src/model/services/templates/PipelineFileFactory.js`
8
- * (`PIPELINE_FILES`)
9
- *
10
- * The templates under `src/line/templates/**` are byte-for-byte copies of
11
- * `linea/server/src/model/services/templates/**`. They are ASSETS, not
12
- * TypeScript: `scripts/copy-assets.mjs` mirrors them into `dist/` at build time
13
- * and `resolveAsset` locates them through `import.meta.url`.
14
- *
15
- * The monolith reads every template ONCE at module load into a module-level
16
- * `const`. That is module state, which ADR-014 rules out, so here each call
17
- * reads from disk. These are a handful of small files read only when a line is
18
- * created; if it ever mattered, the caller can cache.
19
- */
20
1
  import fs from 'node:fs';
21
2
  import { resolveAsset } from '../assets.js';
22
- import { InvalidArgumentError } from '../errors.js';
23
- import { isArray } from '../internal/guards.js';
24
- /** Metamodels that contribute extra template fragments. */
25
- const METAMODEL_TEMPLATES = {
26
- UML: { extra: 'metamodels/dataModel/extra.js', transformation: 'metamodels/dataModel/transformation.js' },
27
- SENSOR: { extra: 'metamodels/sensor/extra.js', transformation: 'metamodels/sensor/transformation.js' }
28
- };
29
3
  const readTemplate = (...segments) => fs.readFileSync(resolveAsset({ segments: ['line', 'templates', ...segments] }), 'utf8');
30
- const assertModels = (models) => {
31
- if (models === undefined)
32
- return [];
33
- if (!isArray(models) || models.some((model) => typeof model !== 'string')) {
34
- throw new InvalidArgumentError('"models" must be an array of strings.');
35
- }
36
- return models;
37
- };
38
4
  /**
39
- * Concatenates the core template with the fragment of each selected metamodel.
40
- *
41
- * Verbatim behaviour of `PlatformFileFactory.js:31-39`: the core template first,
42
- * then `'\n' + fragment` for every model that has one, in the order given.
43
- * A model with no template — including an unknown name — is skipped silently.
5
+ * The platform files that every line has. What a product needs of its data model, its sensors and the rest is not here: those are
6
+ * metamodels that the modules of an SPL bring, and their models are derived through each metamodel's own JSON mapping.
44
7
  */
45
- const buildFromTemplates = (models, core, kind) => {
46
- let content = readTemplate(core);
47
- for (const model of models) {
48
- const templates = METAMODEL_TEMPLATES[model];
49
- if (templates !== undefined) {
50
- content += '\n' + readTemplate(templates[kind]);
51
- }
52
- }
53
- return content;
8
+ export const buildExtraJs = () => readTemplate('core/extra.js');
9
+ export const buildTransformationJs = () => readTemplate('core/transformation.js');
10
+ const CI_FILES = {
11
+ gitlab: { path: 'src/platform/code/.gitlab-ci.yml', template: 'pipeline/.gitlab-ci.yml' },
12
+ github: { path: 'src/platform/code/.github/workflows/ci.yml', template: 'pipeline/github-ci.yml' }
54
13
  };
55
- /**
56
- * Builds `src/platform/extra.js` for a line.
57
- *
58
- * WRITING YOUR OWN `extra.js`: do NOT use `//` line comments. The template
59
- * processor concatenates this file into the function it builds and then strips
60
- * every newline from it (`spl-js-engine/src/template-engine/processor.js:28`),
61
- * so a line comment swallows the rest of that function — including its final
62
- * `return`. Every annotated file then processes to nothing and, because the
63
- * engine skips empty output, the derivation produces ZERO files WITHOUT raising
64
- * an error. Use `/* ... *\/` blocks. Neither the monolith's `core/extra.js` nor
65
- * its mock LPS uses line comments, for exactly this reason.
66
- *
67
- * @param params.models Metamodels chosen for the line, e.g. `['UML']`. Unknown
68
- * names are ignored, matching the monolith.
69
- * @returns The file contents: core template plus one fragment per known model.
70
- * @throws {InvalidArgumentError} when `models` is not an array of strings.
71
- */
72
- export const buildExtraJs = ({ models }) => buildFromTemplates(assertModels(models), 'core/extra.js', 'extra');
73
- /**
74
- * Builds `src/platform/transformation.js` for a line.
75
- *
76
- * WRITING YOUR OWN `transformation.js`: the same `//` trap described on
77
- * {@link buildExtraJs} applies here — the processor strips every newline, so a
78
- * line comment silently swallows the rest of the generated function and the
79
- * derivation produces ZERO files without raising. Use block comments.
80
- *
81
- * @param params.models Metamodels chosen for the line. Unknown names are ignored.
82
- * @returns The file contents: core template plus one fragment per known model.
83
- * @throws {InvalidArgumentError} when `models` is not an array of strings.
84
- */
85
- export const buildTransformationJs = ({ models }) => buildFromTemplates(assertModels(models), 'core/transformation.js', 'transformation');
86
- /**
87
- * The default CI pipeline files seeded into every new line repository.
88
- *
89
- * Migrated from `PipelineFileFactory.js:PIPELINE_FILES`, same paths and same
90
- * order. A function rather than an exported constant so no module-level state
91
- * holds the file contents (ADR-014) and so each caller gets its own array.
92
- *
93
- * @returns The pipeline files, in the order the monolith creates them.
94
- */
95
- export const getPipelineFiles = () => [
96
- {
97
- path: 'src/platform/code/.gitlab-ci.yml',
98
- content: readTemplate('pipeline/.gitlab-ci.yml'),
99
- encoding: 'text'
100
- },
14
+ export const getPipelineFiles = ({ ci = 'gitlab' } = {}) => [
15
+ ...(ci === 'none'
16
+ ? []
17
+ : [{ path: CI_FILES[ci].path, content: readTemplate(CI_FILES[ci].template), encoding: 'text' }]),
101
18
  {
102
19
  path: 'src/platform/code/ci/test-server.sh',
103
20
  content: readTemplate('pipeline/ci/test-server.sh'),
@@ -109,4 +26,11 @@ export const getPipelineFiles = () => [
109
26
  encoding: 'text'
110
27
  }
111
28
  ];
29
+ /**
30
+ * The CI of the SPL repository itself (not of its products): what a merge request does to the products that exist. Only for GitLab so far;
31
+ * a line that lives on GitHub gets none.
32
+ */
33
+ export const getSplPipelineFiles = ({ ci = 'gitlab' } = {}) => ci === 'gitlab'
34
+ ? [{ path: '.gitlab-ci.yml', content: readTemplate('pipeline/spl-gitlab-ci.yml'), encoding: 'text' }]
35
+ : [];
112
36
  //# sourceMappingURL=platform-files.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"platform-files.js","sourceRoot":"","sources":["../../src/line/platform-files.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AAiB/C,2DAA2D;AAC3D,MAAM,mBAAmB,GAAG;IAC1B,GAAG,EAAE,EAAE,KAAK,EAAE,+BAA+B,EAAE,cAA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AC,YAAY,CAAC,MAAM,CAAC,EAAE,eAAe,EAAE,OAAO,CAAC,CAAA;AAEpE;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,EAAE,MAAM,EAAkC,EAAU,EAAE,CAC1F,kBAAkB,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,wBAAwB,EAAE,gBAAgB,CAAC,CAAA;AAEtF;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAe,EAAE,CAAC;IAChD;QACE,IAAI,EAAE,kCAAkC;QACxC,OAAO,EAAE,YAAY,CAAC,yBAAyB,CAAC;QAChD,QAAQ,EAAE,MAAM;KACjB;IACD;QACE,IAAI,EAAE,qCAAqC;QAC3C,OAAO,EAAE,YAAY,CAAC,4BAA4B,CAAC;QACnD,QAAQ,EAAE,MAAM;KACjB;IACD;QACE,IAAI,EAAE,qCAAqC;QAC3C,OAAO,EAAE,YAAY,CAAC,4BAA4B,CAAC;QACnD,QAAQ,EAAE,MAAM;KACjB;CACF,CAAA","sourcesContent":["/**\n * Platform files seeded into a brand new line.\n *\n * Migrated from:\n * - `linea/server/src/model/services/templates/PlatformFileFactory.js`\n * (`buildExtraJs`, `buildTransformationJs`)\n * - `linea/server/src/model/services/templates/PipelineFileFactory.js`\n * (`PIPELINE_FILES`)\n *\n * The templates under `src/line/templates/**` are byte-for-byte copies of\n * `linea/server/src/model/services/templates/**`. They are ASSETS, not\n * TypeScript: `scripts/copy-assets.mjs` mirrors them into `dist/` at build time\n * and `resolveAsset` locates them through `import.meta.url`.\n *\n * The monolith reads every template ONCE at module load into a module-level\n * `const`. That is module state, which ADR-014 rules out, so here each call\n * reads from disk. These are a handful of small files read only when a line is\n * created; if it ever mattered, the caller can cache.\n */\nimport fs from 'node:fs'\nimport { resolveAsset } from '../assets.js'\nimport { InvalidArgumentError } from '../errors.js'\nimport { isArray } from '../internal/guards.js'\n\n/**\n * A file to be written somewhere, described without deciding where.\n *\n * The pure half of the scaffold API returns these so linea-server can push them\n * to GitLab and linea-cli can write them to disk, from the same description.\n */\nexport interface FileSpec {\n /** Repository-relative path, always POSIX (`/`), never absolute. */\n readonly path: string\n /** File contents. */\n readonly content: string\n /** How `content` is encoded. Every seeded file is text today. */\n readonly encoding: 'text' | 'base64'\n}\n\n/** Metamodels that contribute extra template fragments. */\nconst METAMODEL_TEMPLATES = {\n UML: { extra: 'metamodels/dataModel/extra.js', transformation: 'metamodels/dataModel/transformation.js' },\n SENSOR: { extra: 'metamodels/sensor/extra.js', transformation: 'metamodels/sensor/transformation.js' }\n} as const\n\n/** A metamodel name recognised by the template factory. */\nexport type MetamodelName = keyof typeof METAMODEL_TEMPLATES\n\nconst readTemplate = (...segments: string[]): string =>\n fs.readFileSync(resolveAsset({ segments: ['line', 'templates', ...segments] }), 'utf8')\n\nconst assertModels = (models: unknown): readonly string[] => {\n if (models === undefined) return []\n if (!isArray(models) || models.some((model) => typeof model !== 'string')) {\n throw new InvalidArgumentError('\"models\" must be an array of strings.')\n }\n return models as readonly string[]\n}\n\n/**\n * Concatenates the core template with the fragment of each selected metamodel.\n *\n * Verbatim behaviour of `PlatformFileFactory.js:31-39`: the core template first,\n * then `'\\n' + fragment` for every model that has one, in the order given.\n * A model with no template — including an unknown name — is skipped silently.\n */\nconst buildFromTemplates = (\n models: readonly string[],\n core: string,\n kind: 'extra' | 'transformation'\n): string => {\n let content = readTemplate(core)\n for (const model of models) {\n const templates = METAMODEL_TEMPLATES[model as MetamodelName] as\n | (typeof METAMODEL_TEMPLATES)[MetamodelName]\n | undefined\n if (templates !== undefined) {\n content += '\\n' + readTemplate(templates[kind])\n }\n }\n return content\n}\n\n/**\n * Builds `src/platform/extra.js` for a line.\n *\n * WRITING YOUR OWN `extra.js`: do NOT use `//` line comments. The template\n * processor concatenates this file into the function it builds and then strips\n * every newline from it (`spl-js-engine/src/template-engine/processor.js:28`),\n * so a line comment swallows the rest of that function — including its final\n * `return`. Every annotated file then processes to nothing and, because the\n * engine skips empty output, the derivation produces ZERO files WITHOUT raising\n * an error. Use `/* ... *\\/` blocks. Neither the monolith's `core/extra.js` nor\n * its mock LPS uses line comments, for exactly this reason.\n *\n * @param params.models Metamodels chosen for the line, e.g. `['UML']`. Unknown\n * names are ignored, matching the monolith.\n * @returns The file contents: core template plus one fragment per known model.\n * @throws {InvalidArgumentError} when `models` is not an array of strings.\n */\nexport const buildExtraJs = ({ models }: { models?: readonly string[] }): string =>\n buildFromTemplates(assertModels(models), 'core/extra.js', 'extra')\n\n/**\n * Builds `src/platform/transformation.js` for a line.\n *\n * WRITING YOUR OWN `transformation.js`: the same `//` trap described on\n * {@link buildExtraJs} applies here — the processor strips every newline, so a\n * line comment silently swallows the rest of the generated function and the\n * derivation produces ZERO files without raising. Use block comments.\n *\n * @param params.models Metamodels chosen for the line. Unknown names are ignored.\n * @returns The file contents: core template plus one fragment per known model.\n * @throws {InvalidArgumentError} when `models` is not an array of strings.\n */\nexport const buildTransformationJs = ({ models }: { models?: readonly string[] }): string =>\n buildFromTemplates(assertModels(models), 'core/transformation.js', 'transformation')\n\n/**\n * The default CI pipeline files seeded into every new line repository.\n *\n * Migrated from `PipelineFileFactory.js:PIPELINE_FILES`, same paths and same\n * order. A function rather than an exported constant so no module-level state\n * holds the file contents (ADR-014) and so each caller gets its own array.\n *\n * @returns The pipeline files, in the order the monolith creates them.\n */\nexport const getPipelineFiles = (): FileSpec[] => [\n {\n path: 'src/platform/code/.gitlab-ci.yml',\n content: readTemplate('pipeline/.gitlab-ci.yml'),\n encoding: 'text'\n },\n {\n path: 'src/platform/code/ci/test-server.sh',\n content: readTemplate('pipeline/ci/test-server.sh'),\n encoding: 'text'\n },\n {\n path: 'src/platform/code/ci/test-client.sh',\n content: readTemplate('pipeline/ci/test-client.sh'),\n encoding: 'text'\n }\n]\n"]}
1
+ {"version":3,"file":"platform-files.js","sourceRoot":"","sources":["../../src/line/platform-files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,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;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,EAAE,EAAE,GAAG,QAAQ,KAAsB,EAAE,EAAc,EAAE,CACzF,EAAE,KAAK,QAAQ;IACb,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,YAAY,CAAC,4BAA4B,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;IACrG,CAAC,CAAC,EAAE,CAAA","sourcesContent":["import fs from 'node:fs'\nimport { resolveAsset } from '../assets.js'\n\nexport interface FileSpec {\n readonly path: string\n readonly content: string\n readonly encoding: 'text' | 'base64'\n}\n\nconst readTemplate = (...segments: string[]): string =>\n fs.readFileSync(resolveAsset({ segments: ['line', 'templates', ...segments] }), 'utf8')\n\n/**\n * The platform files that every line has. What a product needs of its data model, its sensors and the rest is not here: those are\n * metamodels that the modules of an SPL bring, and their models are derived through each metamodel's own JSON mapping.\n */\nexport const buildExtraJs = (): string => readTemplate('core/extra.js')\n\nexport const buildTransformationJs = (): string => readTemplate('core/transformation.js')\n\n/** The CI of the products an SPL generates: the pipeline file of the git host the SPL lives on, and the scripts it runs. */\n/** `none`: the host runs no pipelines (the repositories kept on LINEA's own server), so there is no pipeline file; the scripts stay. */\nexport type CiHost = 'gitlab' | 'github' | 'none'\n\nconst CI_FILES: Record<Exclude<CiHost, 'none'>, { readonly path: string, readonly template: string }> = {\n gitlab: { path: 'src/platform/code/.gitlab-ci.yml', template: 'pipeline/.gitlab-ci.yml' },\n github: { path: 'src/platform/code/.github/workflows/ci.yml', template: 'pipeline/github-ci.yml' }\n}\n\nexport const getPipelineFiles = ({ ci = 'gitlab' }: { ci?: CiHost } = {}): FileSpec[] => [\n ...(ci === 'none'\n ? []\n : [{ path: CI_FILES[ci].path, content: readTemplate(CI_FILES[ci].template), encoding: 'text' as const }]),\n {\n path: 'src/platform/code/ci/test-server.sh',\n content: readTemplate('pipeline/ci/test-server.sh'),\n encoding: 'text'\n },\n {\n path: 'src/platform/code/ci/test-client.sh',\n content: readTemplate('pipeline/ci/test-client.sh'),\n encoding: 'text'\n }\n]\n\n/**\n * The CI of the SPL repository itself (not of its products): what a merge request does to the products that exist. Only for GitLab so far;\n * a line that lives on GitHub gets none.\n */\nexport const getSplPipelineFiles = ({ ci = 'gitlab' }: { ci?: CiHost } = {}): FileSpec[] =>\n ci === 'gitlab'\n ? [{ path: '.gitlab-ci.yml', content: readTemplate('pipeline/spl-gitlab-ci.yml'), encoding: 'text' }]\n : []\n"]}
@@ -0,0 +1,27 @@
1
+ import { type DeletionStep, type HostDeletionTraits, type HostId } from './deletion.js';
2
+ export interface PendingItem {
3
+ repositoryId: HostId;
4
+ namespaceId: HostId;
5
+ repositoryScheduled: boolean;
6
+ namespaceScheduled: boolean;
7
+ }
8
+ export interface PendingProduct extends PendingItem {
9
+ id: string;
10
+ }
11
+ export interface RestorationStep extends DeletionStep {
12
+ action: 'restore' | 'delete';
13
+ }
14
+ export interface LineRestorationPlan {
15
+ steps: RestorationStep[];
16
+ restoredProductIds: string[];
17
+ pendingProductIds: string[];
18
+ }
19
+ export declare const planProductRestoration: ({ product }: {
20
+ product: PendingItem;
21
+ }) => RestorationStep[];
22
+ export declare const planLineRestoration: ({ line, products, restoreProductIds, host }: {
23
+ line: PendingItem;
24
+ products: PendingProduct[];
25
+ restoreProductIds?: string[];
26
+ host: HostDeletionTraits;
27
+ }) => LineRestorationPlan;
@@ -0,0 +1,27 @@
1
+ import { InvalidArgumentError } from '../errors.js';
2
+ import { planProductDeletion } from './deletion.js';
3
+ const restoring = ({ repositoryId, namespaceId, repositoryScheduled, namespaceScheduled }) => [
4
+ ...(namespaceScheduled ? [{ action: 'restore', kind: 'namespace', id: namespaceId }] : []),
5
+ ...(repositoryScheduled ? [{ action: 'restore', kind: 'repository', id: repositoryId }] : []),
6
+ ];
7
+ export const planProductRestoration = ({ product }) => restoring(product);
8
+ export const planLineRestoration = ({ line, products, restoreProductIds, host }) => {
9
+ const known = new Set(products.map((product) => product.id));
10
+ const stranger = restoreProductIds?.find((id) => !known.has(id));
11
+ if (stranger !== undefined)
12
+ throw new InvalidArgumentError(`The product to restore "${stranger}" is not waiting to be deleted in this line.`);
13
+ const wanted = new Set(restoreProductIds ?? known);
14
+ const chosen = products.filter((product) => wanted.has(product.id));
15
+ const left = products.filter((product) => !wanted.has(product.id));
16
+ const comesBackWithLine = (product) => line.namespaceScheduled && !product.repositoryScheduled && !product.namespaceScheduled;
17
+ return {
18
+ steps: [
19
+ ...restoring(line),
20
+ ...chosen.flatMap(restoring),
21
+ ...left.filter(comesBackWithLine).flatMap((product) => (planProductDeletion({ product, host }).map((step) => ({ action: 'delete', ...step })))),
22
+ ],
23
+ restoredProductIds: chosen.map((product) => product.id),
24
+ pendingProductIds: left.map((product) => product.id),
25
+ };
26
+ };
27
+ //# sourceMappingURL=restoration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"restoration.js","sourceRoot":"","sources":["../../src/line/restoration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,EAAE,mBAAmB,EAA2D,MAAM,eAAe,CAAA;AAuB5G,MAAM,SAAS,GAAG,CAAC,EAAE,YAAY,EAAE,WAAW,EAAE,mBAAmB,EAAE,kBAAkB,EAAe,EAAqB,EAAE,CAAC;IAC5H,GAAG,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,SAAkB,EAAE,IAAI,EAAE,WAAoB,EAAE,EAAE,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC5G,GAAG,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,SAAkB,EAAE,IAAI,EAAE,YAAqB,EAAE,EAAE,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;CAChH,CAAA;AAED,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,EAAE,OA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AAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CACrD,mBAAmB,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAmB,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC,CACvG,CAAC;SACH;QACD,kBAAkB,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;QACvD,iBAAiB,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;KACrD,CAAA;AACH,CAAC,CAAA","sourcesContent":["import { InvalidArgumentError } from '../errors.js'\nimport { planProductDeletion, type DeletionStep, type HostDeletionTraits, type HostId } from './deletion.js'\n\nexport interface PendingItem {\n repositoryId: HostId\n namespaceId: HostId\n repositoryScheduled: boolean\n namespaceScheduled: boolean\n}\n\nexport interface PendingProduct extends PendingItem {\n id: string\n}\n\nexport interface RestorationStep extends DeletionStep {\n action: 'restore' | 'delete'\n}\n\nexport interface LineRestorationPlan {\n steps: RestorationStep[]\n restoredProductIds: string[]\n pendingProductIds: string[]\n}\n\nconst restoring = ({ repositoryId, namespaceId, repositoryScheduled, namespaceScheduled }: PendingItem): RestorationStep[] => [\n ...(namespaceScheduled ? [{ action: 'restore' as const, kind: 'namespace' as const, id: namespaceId }] : []),\n ...(repositoryScheduled ? [{ action: 'restore' as const, kind: 'repository' as const, id: repositoryId }] : []),\n]\n\nexport const planProductRestoration = ({ product }: { product: PendingItem }): RestorationStep[] => restoring(product)\n\nexport const planLineRestoration = ({ line, products, restoreProductIds, host }: {\n line: PendingItem\n products: PendingProduct[]\n restoreProductIds?: string[]\n host: HostDeletionTraits\n}): LineRestorationPlan => {\n const known = new Set(products.map((product) => product.id))\n const stranger = restoreProductIds?.find((id) => !known.has(id))\n if (stranger !== undefined) throw new InvalidArgumentError(`The product to restore \"${stranger}\" is not waiting to be deleted in this line.`)\n\n const wanted = new Set(restoreProductIds ?? known)\n const chosen = products.filter((product) => wanted.has(product.id))\n const left = products.filter((product) => !wanted.has(product.id))\n const comesBackWithLine = (product: PendingProduct): boolean => line.namespaceScheduled && !product.repositoryScheduled && !product.namespaceScheduled\n\n return {\n steps: [\n ...restoring(line),\n ...chosen.flatMap(restoring),\n ...left.filter(comesBackWithLine).flatMap((product) => (\n planProductDeletion({ product, host }).map((step): RestorationStep => ({ action: 'delete', ...step }))\n )),\n ],\n restoredProductIds: chosen.map((product) => product.id),\n pendingProductIds: left.map((product) => product.id),\n }\n}\n"]}
@@ -1,19 +1,6 @@
1
- import { type FeatureModelType } from '../constants.js';
2
- import { type FileSpec } from './platform-files.js';
3
- /**
4
- * Engine configuration seeded into every new line (`src/platform/config.json`).
5
- *
6
- * Verbatim from `LineService.js:48-56`, which is what actually runs when a line
7
- * is created.
8
- *
9
- * KNOWN DISCREPANCY IN THE MONOLITH: the test fixture
10
- * `linea/server/src/test/mocks/lps/src/platform/config.json` carries a RICHER
11
- * list — it also declares `dockerfile` and `sh` extensions. The two have drifted
12
- * apart. `LineService.js` is the source of truth here because it is the code
13
- * path that creates real lines; the fixture only feeds derivation tests. A line
14
- * seeded by linea-core therefore will not process `Dockerfile` or `.sh`
15
- * annotations until someone edits its `config.json`, exactly as today.
16
- */
1
+ import { FEATURE_METAMODEL } from '../modules/configuration/constants.js';
2
+ import type { SplKind, SplManifest } from '../modules/types.js';
3
+ import { type CiHost, type FileSpec } from './platform-files.js';
17
4
  export declare const DEFAULT_PLATFORM_CONFIG: {
18
5
  readonly ignore: readonly ["target", "bower_components", ".gradle", ".project", "bin", "build", ".settings", ".classpath"];
19
6
  readonly delimiters: readonly [{
@@ -34,55 +21,37 @@ export declare const DEFAULT_PLATFORM_CONFIG: {
34
21
  readonly end: ">###";
35
22
  }];
36
23
  };
37
- /** Contents of `src/platform/code/.gitignore`, verbatim from `LineService.js:60`. */
38
24
  export declare const DEFAULT_CODE_GITIGNORE = "node_modules/\ntarget/\ndist/\n.env\n*.log\n";
39
- /** What a line scaffold needs to know. */
25
+ /** The first feature model of an SPL, as a model of the feature metamodel: just the root, named after the SPL. */
26
+ export declare const emptyFeatureModel: ({ name }: {
27
+ name: string;
28
+ }) => string;
29
+ /** Where an SPL keeps its feature model. */
30
+ export declare const FEATURE_MODEL_PATH = "models/featuremodel.featuremodel";
40
31
  export interface LineScaffoldInput {
41
- /** Line name; becomes the root feature of the seed model. */
42
32
  name: string;
43
- /** Metamodels chosen for the line, e.g. `['UML']`. Unknown names are ignored. */
44
- models?: readonly string[];
45
- /** Notation of the seed feature model. Defaults to `'UVL'`. */
46
- featureModelType?: FeatureModelType;
33
+ /** `plain` (the default): the feature metamodel only. `project`: also the `metamodels` the user chose. `modular`: made of `modules`. */
34
+ kind?: SplKind;
35
+ /** The metamodels of a `project` (location -> range), besides the feature metamodel. */
36
+ metamodels?: Record<string, string>;
37
+ /** The modules of a `modular` SPL (location -> range). */
38
+ modules?: Record<string, string>;
39
+ /** Where the feature metamodel is, when not in the default registry (a workspace on disk has it as `file:metamodels/featuremodel`). */
40
+ featureMetamodel?: string;
41
+ /** The git host the SPL will live on: which CI file the generated products get (default `gitlab`). */
42
+ ci?: CiHost;
47
43
  }
44
+ /** The `spl.json` of a new SPL. */
45
+ export declare const buildSplManifest: ({ name, kind, metamodels, modules, featureMetamodel }: LineScaffoldInput) => SplManifest;
48
46
  /**
49
- * Computes the files of a brand new line. PURE: reads no working directory and
50
- * writes nothing.
51
- *
52
- * The returned order is the order `createLine` creates them in, and callers
53
- * should preserve it: model, config, code/.gitignore, extra.js,
54
- * transformation.js, then the pipeline files.
55
- *
56
- * Note the template files themselves ARE read from the package's own asset
57
- * directory — that is reading linea-core's own installed data, not the caller's
58
- * working directory, and is what makes the function usable with no filesystem
59
- * target at all.
60
- *
61
- * @param params.name Line name.
62
- * @param params.models Metamodels chosen for the line.
63
- * @param params.featureModelType `'UVL'` (default) or `'XML'`.
64
- * @returns The files to create, in order.
65
- * @throws {InvalidArgumentError} when `name` is empty or has characters outside
66
- * `NAME_PATTERN`, or when `featureModelType` is unknown.
67
- */
68
- export declare const buildLineScaffold: ({ name, models, featureModelType }: LineScaffoldInput) => FileSpec[];
69
- /**
70
- * Materialises a line scaffold in a directory.
71
- *
72
- * The impure counterpart of `buildLineScaffold`, for linea-cli's local mode.
73
- * Creates `dir` and every parent directory the files need.
74
- *
75
- * @param params.dir Target directory (the line's working directory root).
76
- * @param params.name Line name.
77
- * @param params.models Metamodels chosen for the line.
78
- * @param params.featureModelType `'UVL'` (default) or `'XML'`.
79
- * @returns The resolved directory and the files written.
80
- * @throws {InvalidArgumentError} for the same reasons as `buildLineScaffold`, or
81
- * when `dir` is not a non-empty path.
47
+ * 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
48
+ * its products are derived with (a modular one gets it from its modules).
82
49
  */
83
- export declare const writeLineScaffold: ({ dir, name, models, featureModelType }: LineScaffoldInput & {
50
+ export declare const buildLineScaffold: ({ name, kind, metamodels, modules, featureMetamodel, ci }: LineScaffoldInput) => FileSpec[];
51
+ export declare const writeLineScaffold: ({ dir, ...rest }: LineScaffoldInput & {
84
52
  dir: string;
85
53
  }) => {
86
54
  dir: string;
87
55
  files: FileSpec[];
88
56
  };
57
+ export { FEATURE_METAMODEL };
@@ -1,45 +1,11 @@
1
- /**
2
- * The initial file tree of a brand new line.
3
- *
4
- * Migrated from `linea/server/src/model/services/LineService.js:createLine`
5
- * (~43-68), keeping ONLY the file construction. Everything around it belongs to
6
- * linea-server (ADR-003): creating the GitLab group and project, the
7
- * `createFile` calls, the Mongo transaction and the rollback.
8
- *
9
- * The API is split into a PURE half and an IMPURE half on purpose:
10
- *
11
- * - `buildLineScaffold` computes the files and touches nothing. linea-server
12
- * feeds the result straight to `gitlabSession.createFile`, in order, for
13
- * exact parity with `createLine` — without linea-core ever reaching the
14
- * network or the disk (ADR-002).
15
- * - `writeLineScaffold` materialises the same description on disk, which is
16
- * what linea-cli needs in local mode (ADR-004).
17
- *
18
- * They must stay separate: collapsing them would force the GitLab path to write
19
- * a temporary tree it does not want.
20
- */
21
1
  import path from 'node:path';
22
- import { FEATURE_MODEL_TYPES, isFeatureModelType, NAME_PATTERN } from '../constants.js';
2
+ import { NAME_PATTERN } from '../constants.js';
23
3
  import { InvalidArgumentError } from '../errors.js';
24
- import { modelToXml } from '../feature-model/engine.js';
25
- import { parseFeatureModel } from '../feature-model/parse.js';
26
- import { emptyFeatureModelUvl } from '../feature-model/text.js';
27
4
  import { ensureDir, writeTextFile } from '../fs/workspace.js';
5
+ import { FEATURE_METAMODEL, FEATURE_MODEL_GRAMMAR, withFeatureMetamodel } from '../modules/configuration/constants.js';
6
+ import { bangoName, rootFeatureName } from '../modules/configuration/names.js';
7
+ import { serializeSplManifest } from '../modules/packages/manifests.js';
28
8
  import { buildExtraJs, buildTransformationJs, getPipelineFiles } from './platform-files.js';
29
- /**
30
- * Engine configuration seeded into every new line (`src/platform/config.json`).
31
- *
32
- * Verbatim from `LineService.js:48-56`, which is what actually runs when a line
33
- * is created.
34
- *
35
- * KNOWN DISCREPANCY IN THE MONOLITH: the test fixture
36
- * `linea/server/src/test/mocks/lps/src/platform/config.json` carries a RICHER
37
- * list — it also declares `dockerfile` and `sh` extensions. The two have drifted
38
- * apart. `LineService.js` is the source of truth here because it is the code
39
- * path that creates real lines; the fixture only feeds derivation tests. A line
40
- * seeded by linea-core therefore will not process `Dockerfile` or `.sh`
41
- * annotations until someone edits its `config.json`, exactly as today.
42
- */
43
9
  export const DEFAULT_PLATFORM_CONFIG = {
44
10
  ignore: ['target', 'bower_components', '.gradle', '.project', 'bin', 'build', '.settings', '.classpath'],
45
11
  delimiters: [
@@ -56,90 +22,63 @@ export const DEFAULT_PLATFORM_CONFIG = {
56
22
  { extension: ['json'], start: '###<', end: '>###' }
57
23
  ]
58
24
  };
59
- /** Contents of `src/platform/code/.gitignore`, verbatim from `LineService.js:60`. */
60
25
  export const DEFAULT_CODE_GITIGNORE = 'node_modules/\ntarget/\ndist/\n.env\n*.log\n';
26
+ /** The first feature model of an SPL, as a model of the feature metamodel: just the root, named after the SPL. */
27
+ export const emptyFeatureModel = ({ name }) => {
28
+ const root = bangoName({ name: rootFeatureName({ name }) });
29
+ return `featuremodel ${root}\nfeature ${root}\n`;
30
+ };
31
+ /** Where an SPL keeps its feature model. */
32
+ export const FEATURE_MODEL_PATH = `models/${FEATURE_MODEL_GRAMMAR}.${FEATURE_MODEL_GRAMMAR}`;
33
+ /** The `spl.json` of a new SPL. */
34
+ export const buildSplManifest = ({ name, kind = 'plain', metamodels = {}, modules = {}, featureMetamodel }) => withFeatureMetamodel({
35
+ spl: { name, version: '1.0.0', kind, metamodels: kind === 'project' ? metamodels : {}, modules: kind === 'modular' ? modules : {} },
36
+ ...(featureMetamodel === undefined ? {} : { location: featureMetamodel })
37
+ });
61
38
  /**
62
- * Computes the files of a brand new line. PURE: reads no working directory and
63
- * writes nothing.
64
- *
65
- * The returned order is the order `createLine` creates them in, and callers
66
- * should preserve it: model, config, code/.gitignore, extra.js,
67
- * transformation.js, then the pipeline files.
68
- *
69
- * Note the template files themselves ARE read from the package's own asset
70
- * directory — that is reading linea-core's own installed data, not the caller's
71
- * working directory, and is what makes the function usable with no filesystem
72
- * target at all.
73
- *
74
- * @param params.name Line name.
75
- * @param params.models Metamodels chosen for the line.
76
- * @param params.featureModelType `'UVL'` (default) or `'XML'`.
77
- * @returns The files to create, in order.
78
- * @throws {InvalidArgumentError} when `name` is empty or has characters outside
79
- * `NAME_PATTERN`, or when `featureModelType` is unknown.
39
+ * 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
40
+ * its products are derived with (a modular one gets it from its modules).
80
41
  */
81
- export const buildLineScaffold = ({ name, models = [], featureModelType = 'UVL' }) => {
42
+ export const buildLineScaffold = ({ name, kind = 'plain', metamodels, modules, featureMetamodel, ci = 'gitlab' }) => {
82
43
  if (typeof name !== 'string' || name === '') {
83
44
  throw new InvalidArgumentError('"name" must be a non-empty string.');
84
45
  }
85
46
  if (!NAME_PATTERN.test(name)) {
86
47
  throw new InvalidArgumentError(`Invalid line name ${JSON.stringify(name)}: allowed characters are [a-zA-Z0-9_.-].`);
87
48
  }
88
- if (!isFeatureModelType(featureModelType)) {
89
- throw new InvalidArgumentError(`Unknown feature model type ${JSON.stringify(featureModelType)}. Use one of ${FEATURE_MODEL_TYPES.join(', ')}.`);
90
- }
91
- const uvlContent = emptyFeatureModelUvl({ name });
92
- const modelFile = featureModelType === 'XML'
93
- ? {
94
- path: 'src/platform/model.xml',
95
- content: modelToXml(parseFeatureModel({ content: uvlContent, type: 'UVL' })),
96
- encoding: 'text'
97
- }
98
- : { path: 'src/platform/model.uvl', content: uvlContent, encoding: 'text' };
49
+ const own = [
50
+ { path: 'spl.json', content: serializeSplManifest({ spl: buildSplManifest({ name, kind, ...(metamodels === undefined ? {} : { metamodels }), ...(modules === undefined ? {} : { modules }), ...(featureMetamodel === undefined ? {} : { featureMetamodel }) }) }), encoding: 'text' },
51
+ { path: FEATURE_MODEL_PATH, content: emptyFeatureModel({ name }), encoding: 'text' }
52
+ ];
53
+ if (kind === 'modular')
54
+ return own;
99
55
  return [
100
- modelFile,
56
+ ...own,
101
57
  {
102
58
  path: 'src/platform/config.json',
103
- // JSON.stringify(config, null, 2) — same two-space indentation as the
104
- // monolith, and no trailing newline, so the committed file matches.
105
59
  content: JSON.stringify(DEFAULT_PLATFORM_CONFIG, null, 2),
106
60
  encoding: 'text'
107
61
  },
108
62
  { path: 'src/platform/code/.gitignore', content: DEFAULT_CODE_GITIGNORE, encoding: 'text' },
109
- { path: 'src/platform/extra.js', content: buildExtraJs({ models }), encoding: 'text' },
63
+ { path: 'src/platform/extra.js', content: buildExtraJs(), encoding: 'text' },
110
64
  {
111
65
  path: 'src/platform/transformation.js',
112
- content: buildTransformationJs({ models }),
66
+ content: buildTransformationJs(),
113
67
  encoding: 'text'
114
68
  },
115
- ...getPipelineFiles()
69
+ ...getPipelineFiles({ ci })
116
70
  ];
117
71
  };
118
- /**
119
- * Materialises a line scaffold in a directory.
120
- *
121
- * The impure counterpart of `buildLineScaffold`, for linea-cli's local mode.
122
- * Creates `dir` and every parent directory the files need.
123
- *
124
- * @param params.dir Target directory (the line's working directory root).
125
- * @param params.name Line name.
126
- * @param params.models Metamodels chosen for the line.
127
- * @param params.featureModelType `'UVL'` (default) or `'XML'`.
128
- * @returns The resolved directory and the files written.
129
- * @throws {InvalidArgumentError} for the same reasons as `buildLineScaffold`, or
130
- * when `dir` is not a non-empty path.
131
- */
132
- export const writeLineScaffold = ({ dir, name, models = [], featureModelType = 'UVL' }) => {
72
+ export const writeLineScaffold = ({ dir, ...rest }) => {
133
73
  if (typeof dir !== 'string' || dir.trim() === '') {
134
74
  throw new InvalidArgumentError('"dir" must be a non-empty path.');
135
75
  }
136
- const files = buildLineScaffold({ name, models, featureModelType });
76
+ const files = buildLineScaffold(rest);
137
77
  const root = ensureDir({ dirPath: dir });
138
78
  for (const file of files) {
139
- // FileSpec paths are POSIX and repository-relative; join with the platform
140
- // separator to land them on disk.
141
79
  writeTextFile({ filePath: path.join(root, ...file.path.split('/')), content: file.content });
142
80
  }
143
81
  return { dir: root, files };
144
82
  };
83
+ export { FEATURE_METAMODEL };
145
84
  //# sourceMappingURL=scaffold.js.map