@lbdudc/linea-core 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
package/dist/fs/format.js CHANGED
@@ -1,36 +1,8 @@
1
- /**
2
- * Source formatting with prettier.
3
- *
4
- * Migrated from `linea/server/src/model/services/utils.js:pretty` (~84):
5
- * `exec('prettier --ignore-unknown --write "<path>/"')`.
6
- *
7
- * HARDENED PORT. The original shells out, which linea-core cannot do:
8
- * - it needs a `prettier` binary on `PATH` in whatever process embeds the
9
- * library, so the result depends on the host machine;
10
- * - spawning a child process is exactly what ADR-014 rules out, and it would
11
- * not work reliably under Bun;
12
- * - the path is interpolated into a shell command string.
13
- *
14
- * Uses prettier's Node API instead: same formatting, no child process, works
15
- * offline and under Bun. `--ignore-unknown` becomes an explicit "skip files
16
- * prettier has no parser for".
17
- */
18
1
  import fs from 'node:fs';
19
2
  import path from 'node:path';
20
3
  import * as prettier from 'prettier';
21
4
  import { InvalidArgumentError } from '../errors.js';
22
- /**
23
- * Directories never worth walking into.
24
- *
25
- * DIVERGENCE from the monolith. `prettier --ignore-unknown --write "<path>/"`
26
- * skips only `node_modules` by default, so the CLI would descend into `.git`,
27
- * `dist`, `build`, `target` and `coverage`. Unreachable in practice — the
28
- * directory being formatted is a freshly derived product, and the platform
29
- * `config.json` already excludes `build`/`target`/`bin` from derivation — but
30
- * recorded here because every other divergence in this file is.
31
- */
32
5
  const SKIP_DIRECTORIES = new Set(['node_modules', '.git', 'dist', 'build', 'target', 'coverage']);
33
- /** Every file under `dir`, recursively, as absolute paths. */
34
6
  const listFiles = (dir) => {
35
7
  const found = [];
36
8
  const walk = (current) => {
@@ -56,22 +28,6 @@ const listFiles = (dir) => {
56
28
  walk(dir);
57
29
  return found.sort();
58
30
  };
59
- /**
60
- * Formats every file prettier understands under a directory, in place.
61
- *
62
- * Files with no inferable parser are skipped, which is what `--ignore-unknown`
63
- * does. Files that prettier cannot parse (a syntax error in generated code, say)
64
- * are skipped too rather than aborting the whole run: formatting is cosmetic and
65
- * must never fail a generation.
66
- *
67
- * Idempotent by construction, since prettier output is a fixed point. A file is
68
- * only rewritten when its content actually changes, so mtimes stay put and the
69
- * directory diff does not gain spurious entries.
70
- *
71
- * @param params.dir Directory to format, in place.
72
- * @returns How many files were rewritten.
73
- * @throws {InvalidArgumentError} when `dir` is not a non-empty existing directory.
74
- */
75
31
  export const formatDirectory = async ({ dir }) => {
76
32
  if (typeof dir !== 'string' || dir.trim() === '') {
77
33
  throw new InvalidArgumentError('"dir" must be a non-empty path.');
@@ -84,14 +40,8 @@ export const formatDirectory = async ({ dir }) => {
84
40
  for (const filePath of listFiles(root)) {
85
41
  try {
86
42
  const { inferredParser } = await prettier.getFileInfo(filePath, { resolveConfig: false });
87
- // Equivalent of `--ignore-unknown`: no parser, no formatting.
88
43
  if (inferredParser === null)
89
44
  continue;
90
- // Resolved PER FILE, like the prettier CLI, so a nested `.prettierrc`
91
- // applies to its own subtree. Resolving once from the root would also miss
92
- // a config living IN the root: `resolveConfig` searches upward from
93
- // `path.dirname(target)`, which for a directory is its parent.
94
- // prettier caches these lookups internally, so this stays cheap.
95
45
  const options = await prettier.resolveConfig(filePath);
96
46
  const original = fs.readFileSync(filePath, 'utf8');
97
47
  const output = await prettier.format(original, { ...options, filepath: filePath });
@@ -101,8 +51,6 @@ export const formatDirectory = async ({ dir }) => {
101
51
  }
102
52
  }
103
53
  catch {
104
- // One file failing — unparseable, unreadable, vanished mid-walk — must
105
- // never abort the run. Formatting is cosmetic; leave it as it was.
106
54
  continue;
107
55
  }
108
56
  }
@@ -1 +1 @@
1
- {"version":3,"file":"format.js","sourceRoot":"","sources":["../../src/fs/format.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,KAAK,QAAQ,MAAM,UAAU,CAAA;AACpC,OAAO,EAAE,oBAAoB,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AAM,CAAC;YACP,uEAAuE;YACvE,mEAAmE;YACnE,SAAQ;QACV,CAAC;IACH,CAAC;IAED,OAAO,EAAE,SAAS,EAAE,CAAA;AACtB,CAAC,CAAA","sourcesContent":["/**\n * Source formatting with prettier.\n *\n * Migrated from `linea/server/src/model/services/utils.js:pretty` (~84):\n * `exec('prettier --ignore-unknown --write \"<path>/\"')`.\n *\n * HARDENED PORT. The original shells out, which linea-core cannot do:\n * - it needs a `prettier` binary on `PATH` in whatever process embeds the\n * library, so the result depends on the host machine;\n * - spawning a child process is exactly what ADR-014 rules out, and it would\n * not work reliably under Bun;\n * - the path is interpolated into a shell command string.\n *\n * Uses prettier's Node API instead: same formatting, no child process, works\n * offline and under Bun. `--ignore-unknown` becomes an explicit \"skip files\n * prettier has no parser for\".\n */\nimport fs from 'node:fs'\nimport path from 'node:path'\nimport * as prettier from 'prettier'\nimport { InvalidArgumentError } from '../errors.js'\n\n/**\n * Directories never worth walking into.\n *\n * DIVERGENCE from the monolith. `prettier --ignore-unknown --write \"<path>/\"`\n * skips only `node_modules` by default, so the CLI would descend into `.git`,\n * `dist`, `build`, `target` and `coverage`. Unreachable in practice — the\n * directory being formatted is a freshly derived product, and the platform\n * `config.json` already excludes `build`/`target`/`bin` from derivation — but\n * recorded here because every other divergence in this file is.\n */\nconst SKIP_DIRECTORIES = new Set(['node_modules', '.git', 'dist', 'build', 'target', 'coverage'])\n\n/** Every file under `dir`, recursively, as absolute paths. */\nconst listFiles = (dir: string): string[] => {\n const found: string[] = []\n const walk = (current: string): void => {\n let entries: fs.Dirent[]\n try {\n entries = fs.readdirSync(current, { withFileTypes: true })\n } catch {\n return\n }\n for (const entry of entries) {\n const absolute = path.join(current, entry.name)\n if (entry.isDirectory()) {\n if (SKIP_DIRECTORIES.has(entry.name)) continue\n walk(absolute)\n } else if (entry.isFile()) {\n found.push(absolute)\n }\n }\n }\n walk(dir)\n return found.sort()\n}\n\n/**\n * Formats every file prettier understands under a directory, in place.\n *\n * Files with no inferable parser are skipped, which is what `--ignore-unknown`\n * does. Files that prettier cannot parse (a syntax error in generated code, say)\n * are skipped too rather than aborting the whole run: formatting is cosmetic and\n * must never fail a generation.\n *\n * Idempotent by construction, since prettier output is a fixed point. A file is\n * only rewritten when its content actually changes, so mtimes stay put and the\n * directory diff does not gain spurious entries.\n *\n * @param params.dir Directory to format, in place.\n * @returns How many files were rewritten.\n * @throws {InvalidArgumentError} when `dir` is not a non-empty existing directory.\n */\nexport const formatDirectory = async ({ dir }: { dir: string }): Promise<{ formatted: number }> => {\n if (typeof dir !== 'string' || dir.trim() === '') {\n throw new InvalidArgumentError('\"dir\" must be a non-empty path.')\n }\n const root = path.resolve(dir)\n if (!fs.existsSync(root) || !fs.statSync(root).isDirectory()) {\n throw new InvalidArgumentError(`Not a directory: ${root}`)\n }\n\n let formatted = 0\n for (const filePath of listFiles(root)) {\n try {\n const { inferredParser } = await prettier.getFileInfo(filePath, { resolveConfig: false })\n // Equivalent of `--ignore-unknown`: no parser, no formatting.\n if (inferredParser === null) continue\n\n // Resolved PER FILE, like the prettier CLI, so a nested `.prettierrc`\n // applies to its own subtree. Resolving once from the root would also miss\n // a config living IN the root: `resolveConfig` searches upward from\n // `path.dirname(target)`, which for a directory is its parent.\n // prettier caches these lookups internally, so this stays cheap.\n const options = await prettier.resolveConfig(filePath)\n const original = fs.readFileSync(filePath, 'utf8')\n const output = await prettier.format(original, { ...options, filepath: filePath })\n if (output !== original) {\n fs.writeFileSync(filePath, output, 'utf8')\n formatted += 1\n }\n } catch {\n // One file failing — unparseable, unreadable, vanished mid-walk — must\n // never abort the run. Formatting is cosmetic; leave it as it was.\n continue\n }\n }\n\n return { formatted }\n}\n"]}
1
+ {"version":3,"file":"format.js","sourceRoot":"","sources":["../../src/fs/format.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,KAAK,QAAQ,MAAM,UAAU,CAAA;AACpC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:path'\nimport * as prettier from 'prettier'\nimport { InvalidArgumentError } from '../errors.js'\n\nconst SKIP_DIRECTORIES = new Set(['node_modules', '.git', 'dist', 'build', 'target', 'coverage'])\n\nconst listFiles = (dir: string): string[] => {\n const found: string[] = []\n const walk = (current: string): void => {\n let entries: fs.Dirent[]\n try {\n entries = fs.readdirSync(current, { withFileTypes: true })\n } catch {\n return\n }\n for (const entry of entries) {\n const absolute = path.join(current, entry.name)\n if (entry.isDirectory()) {\n if (SKIP_DIRECTORIES.has(entry.name)) continue\n walk(absolute)\n } else if (entry.isFile()) {\n found.push(absolute)\n }\n }\n }\n walk(dir)\n return found.sort()\n}\n\nexport const formatDirectory = async ({ dir }: { dir: string }): Promise<{ formatted: number }> => {\n if (typeof dir !== 'string' || dir.trim() === '') {\n throw new InvalidArgumentError('\"dir\" must be a non-empty path.')\n }\n const root = path.resolve(dir)\n if (!fs.existsSync(root) || !fs.statSync(root).isDirectory()) {\n throw new InvalidArgumentError(`Not a directory: ${root}`)\n }\n\n let formatted = 0\n for (const filePath of listFiles(root)) {\n try {\n const { inferredParser } = await prettier.getFileInfo(filePath, { resolveConfig: false })\n if (inferredParser === null) continue\n\n const options = await prettier.resolveConfig(filePath)\n const original = fs.readFileSync(filePath, 'utf8')\n const output = await prettier.format(original, { ...options, filepath: filePath })\n if (output !== original) {\n fs.writeFileSync(filePath, output, 'utf8')\n formatted += 1\n }\n } catch {\n continue\n }\n }\n\n return { formatted }\n}\n"]}
@@ -1,77 +1,25 @@
1
- /** Absolute paths of the well-known files of a line working directory. */
2
1
  export interface LinePaths {
3
- /** The `src/platform` directory. */
4
2
  readonly platform: string;
5
- /** Annotated source consumed by the derivation engine. */
6
3
  readonly code: string;
7
- /** UVL feature model. The XML variant lives at `PLATFORM_PATHS.modelXml`. */
8
4
  readonly model: string;
9
- /** Engine configuration (`config.json`). */
10
5
  readonly config: string;
11
- /** Template helper functions (`extra.js`). */
12
6
  readonly extraJs: string;
13
- /** Spec transformation function (`transformation.js`). */
14
7
  readonly transformation: string;
15
- /** Product index at the repository root (ADR-011). */
16
8
  readonly productsIndex: string;
17
9
  }
18
- /**
19
- * Resolves the well-known paths of a line working directory.
20
- *
21
- * The layout mirrors `linea/server/src/resources/properties.yml`
22
- * (`paths.platform.*`), which the monolith read through `properties.paths` in
23
- * `services/utils.js:engine()`. Purely a path computation: nothing is read and
24
- * nothing is required to exist.
25
- *
26
- * @param params.lineDir Root of the line working directory (its repository root).
27
- * @returns Absolute paths for every well-known file.
28
- * @throws {InvalidArgumentError} if `lineDir` is not a non-empty string.
29
- */
30
10
  export declare const resolveLinePaths: ({ lineDir }: {
31
11
  lineDir: string;
32
12
  }) => LinePaths;
33
- /**
34
- * Creates a directory and its parents if they do not exist. Idempotent.
35
- *
36
- * @param params.dirPath Directory to create.
37
- * @returns The absolute path of the directory.
38
- * @throws {InvalidArgumentError} if `dirPath` is not a non-empty string.
39
- */
40
13
  export declare const ensureDir: ({ dirPath }: {
41
14
  dirPath: string;
42
15
  }) => string;
43
- /**
44
- * Reads a UTF-8 text file.
45
- *
46
- * Unlike the monolith there is no base64 step: models and platform files are
47
- * plain text on disk. Decoding what the GitLab API returns is linea-server's job.
48
- *
49
- * @param params.filePath File to read.
50
- * @returns The file contents.
51
- * @throws {InvalidArgumentError} if `filePath` is not a non-empty string.
52
- */
53
16
  export declare const readTextFile: ({ filePath }: {
54
17
  filePath: string;
55
18
  }) => string;
56
- /**
57
- * Writes a UTF-8 text file, creating parent directories as needed.
58
- *
59
- * @param params.filePath File to write.
60
- * @param params.content Contents to write verbatim (no trailing newline is added).
61
- * @returns The absolute path written.
62
- * @throws {InvalidArgumentError} if the arguments are not strings.
63
- */
64
19
  export declare const writeTextFile: ({ filePath, content }: {
65
20
  filePath: string;
66
21
  content: string;
67
22
  }) => string;
68
- /**
69
- * Whether `filePath` exists and is a regular file.
70
- *
71
- * @param params.filePath Path to probe.
72
- * @returns `true` only for an existing regular file.
73
- * @throws {InvalidArgumentError} if `filePath` is not a non-empty string.
74
- */
75
23
  export declare const fileExists: ({ filePath }: {
76
24
  filePath: string;
77
25
  }) => boolean;
@@ -1,15 +1,3 @@
1
- /**
2
- * Filesystem helpers over a line working directory.
3
- *
4
- * ADR-009: linea-core owns no database. It operates on directories the caller
5
- * hands it (a clone or an unzipped export of a line repository) and returns
6
- * explicit results. Every function takes its working directory as a parameter;
7
- * nothing is resolved from `process.cwd()` or the environment (ADR-014).
8
- *
9
- * Like the rest of the public API, every function takes a single named-parameter
10
- * object — even the single-argument ones. Consistency of the contract consumed
11
- * by linea-server and linea-cli beats brevity.
12
- */
13
1
  import fs from 'node:fs';
14
2
  import path from 'node:path';
15
3
  import { PLATFORM_PATHS, PRODUCTS_INDEX_PATH } from '../constants.js';
@@ -20,18 +8,6 @@ const assertPath = (value, parameter) => {
20
8
  }
21
9
  return path.resolve(value);
22
10
  };
23
- /**
24
- * Resolves the well-known paths of a line working directory.
25
- *
26
- * The layout mirrors `linea/server/src/resources/properties.yml`
27
- * (`paths.platform.*`), which the monolith read through `properties.paths` in
28
- * `services/utils.js:engine()`. Purely a path computation: nothing is read and
29
- * nothing is required to exist.
30
- *
31
- * @param params.lineDir Root of the line working directory (its repository root).
32
- * @returns Absolute paths for every well-known file.
33
- * @throws {InvalidArgumentError} if `lineDir` is not a non-empty string.
34
- */
35
11
  export const resolveLinePaths = ({ lineDir }) => {
36
12
  const root = assertPath(lineDir, 'lineDir');
37
13
  return {
@@ -44,37 +20,12 @@ export const resolveLinePaths = ({ lineDir }) => {
44
20
  productsIndex: path.join(root, PRODUCTS_INDEX_PATH)
45
21
  };
46
22
  };
47
- /**
48
- * Creates a directory and its parents if they do not exist. Idempotent.
49
- *
50
- * @param params.dirPath Directory to create.
51
- * @returns The absolute path of the directory.
52
- * @throws {InvalidArgumentError} if `dirPath` is not a non-empty string.
53
- */
54
23
  export const ensureDir = ({ dirPath }) => {
55
24
  const absolute = assertPath(dirPath, 'dirPath');
56
25
  fs.mkdirSync(absolute, { recursive: true });
57
26
  return absolute;
58
27
  };
59
- /**
60
- * Reads a UTF-8 text file.
61
- *
62
- * Unlike the monolith there is no base64 step: models and platform files are
63
- * plain text on disk. Decoding what the GitLab API returns is linea-server's job.
64
- *
65
- * @param params.filePath File to read.
66
- * @returns The file contents.
67
- * @throws {InvalidArgumentError} if `filePath` is not a non-empty string.
68
- */
69
28
  export const readTextFile = ({ filePath }) => fs.readFileSync(assertPath(filePath, 'filePath'), 'utf8');
70
- /**
71
- * Writes a UTF-8 text file, creating parent directories as needed.
72
- *
73
- * @param params.filePath File to write.
74
- * @param params.content Contents to write verbatim (no trailing newline is added).
75
- * @returns The absolute path written.
76
- * @throws {InvalidArgumentError} if the arguments are not strings.
77
- */
78
29
  export const writeTextFile = ({ filePath, content }) => {
79
30
  const absolute = assertPath(filePath, 'filePath');
80
31
  if (typeof content !== 'string') {
@@ -84,13 +35,6 @@ export const writeTextFile = ({ filePath, content }) => {
84
35
  fs.writeFileSync(absolute, content, 'utf8');
85
36
  return absolute;
86
37
  };
87
- /**
88
- * Whether `filePath` exists and is a regular file.
89
- *
90
- * @param params.filePath Path to probe.
91
- * @returns `true` only for an existing regular file.
92
- * @throws {InvalidArgumentError} if `filePath` is not a non-empty string.
93
- */
94
38
  export const fileExists = ({ filePath }) => {
95
39
  const absolute = assertPath(filePath, 'filePath');
96
40
  try {
@@ -1 +1 @@
1
- {"version":3,"file":"workspace.js","sourceRoot":"","sources":["../../src/fs/workspace.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AACrE,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AAoBnD,MAAM,UAAU,GAAG,CAAC,KAAc,EAAE,SAAiB,EAAU,EAAE;IAC/D,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAA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;AAED;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,EAAE,QAAQ,EAAwB,EAAU,EAAE,CACzE,EAAE,CAAC,YAAY,CAAC,UAAU,CAAC,QAAQ,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,CAAA;AAE3D;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,EAC5B,QAAQ,EACR,OAAO,EAIR,EAAU,EAAE;IACX,MAAM,QAAQ,GAAG,UAAU,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAA;IACjD,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAChC,MAAM,IAAI,oBAAoB,CAAC,6BAA6B,CAAC,CAAA;IAC/D,CAAC;IACD,SAAS,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;IAC9C,EAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC,CAAA;IAC3C,OAAO,QAAQ,CAAA;AACjB,CAAC,CAAA;AAED;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,EAAE,QAAQ,EAAwB,EAAW,EAAE;IACxE,MAAM,QAAQ,GAAG,UAAU,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAA;IACjD,IAAI,CAAC;QACH,OAAO,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,MAAM,EAAE,CAAA;IACvC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAA;IACd,CAAC;AACH,CAAC,CAAA","sourcesContent":["/**\n * Filesystem helpers over a line working directory.\n *\n * ADR-009: linea-core owns no database. It operates on directories the caller\n * hands it (a clone or an unzipped export of a line repository) and returns\n * explicit results. Every function takes its working directory as a parameter;\n * nothing is resolved from `process.cwd()` or the environment (ADR-014).\n *\n * Like the rest of the public API, every function takes a single named-parameter\n * object — even the single-argument ones. Consistency of the contract consumed\n * by linea-server and linea-cli beats brevity.\n */\nimport fs from 'node:fs'\nimport path from 'node:path'\nimport { PLATFORM_PATHS, PRODUCTS_INDEX_PATH } from '../constants.js'\nimport { InvalidArgumentError } from '../errors.js'\n\n/** Absolute paths of the well-known files of a line working directory. */\nexport interface LinePaths {\n /** The `src/platform` directory. */\n readonly platform: string\n /** Annotated source consumed by the derivation engine. */\n readonly code: string\n /** UVL feature model. The XML variant lives at `PLATFORM_PATHS.modelXml`. */\n readonly model: string\n /** Engine configuration (`config.json`). */\n readonly config: string\n /** Template helper functions (`extra.js`). */\n readonly extraJs: string\n /** Spec transformation function (`transformation.js`). */\n readonly transformation: string\n /** Product index at the repository root (ADR-011). */\n readonly productsIndex: string\n}\n\nconst assertPath = (value: unknown, parameter: string): string => {\n if (typeof value !== 'string' || value.trim() === '') {\n throw new InvalidArgumentError(`\"${parameter}\" must be a non-empty path.`)\n }\n return path.resolve(value)\n}\n\n/**\n * Resolves the well-known paths of a line working directory.\n *\n * The layout mirrors `linea/server/src/resources/properties.yml`\n * (`paths.platform.*`), which the monolith read through `properties.paths` in\n * `services/utils.js:engine()`. Purely a path computation: nothing is read and\n * nothing is required to exist.\n *\n * @param params.lineDir Root of the line working directory (its repository root).\n * @returns Absolute paths for every well-known file.\n * @throws {InvalidArgumentError} if `lineDir` is not a non-empty string.\n */\nexport const resolveLinePaths = ({ lineDir }: { lineDir: string }): LinePaths => {\n const root = assertPath(lineDir, 'lineDir')\n return {\n platform: path.join(root, PLATFORM_PATHS.root),\n code: path.join(root, PLATFORM_PATHS.code),\n model: path.join(root, PLATFORM_PATHS.model),\n config: path.join(root, PLATFORM_PATHS.config),\n extraJs: path.join(root, PLATFORM_PATHS.extraJs),\n transformation: path.join(root, PLATFORM_PATHS.transformation),\n productsIndex: path.join(root, PRODUCTS_INDEX_PATH)\n }\n}\n\n/**\n * Creates a directory and its parents if they do not exist. Idempotent.\n *\n * @param params.dirPath Directory to create.\n * @returns The absolute path of the directory.\n * @throws {InvalidArgumentError} if `dirPath` is not a non-empty string.\n */\nexport const ensureDir = ({ dirPath }: { dirPath: string }): string => {\n const absolute = assertPath(dirPath, 'dirPath')\n fs.mkdirSync(absolute, { recursive: true })\n return absolute\n}\n\n/**\n * Reads a UTF-8 text file.\n *\n * Unlike the monolith there is no base64 step: models and platform files are\n * plain text on disk. Decoding what the GitLab API returns is linea-server's job.\n *\n * @param params.filePath File to read.\n * @returns The file contents.\n * @throws {InvalidArgumentError} if `filePath` is not a non-empty string.\n */\nexport const readTextFile = ({ filePath }: { filePath: string }): string =>\n fs.readFileSync(assertPath(filePath, 'filePath'), 'utf8')\n\n/**\n * Writes a UTF-8 text file, creating parent directories as needed.\n *\n * @param params.filePath File to write.\n * @param params.content Contents to write verbatim (no trailing newline is added).\n * @returns The absolute path written.\n * @throws {InvalidArgumentError} if the arguments are not strings.\n */\nexport const writeTextFile = ({\n filePath,\n content\n}: {\n filePath: string\n content: string\n}): string => {\n const absolute = assertPath(filePath, 'filePath')\n if (typeof content !== 'string') {\n throw new InvalidArgumentError('\"content\" must be a string.')\n }\n ensureDir({ dirPath: path.dirname(absolute) })\n fs.writeFileSync(absolute, content, 'utf8')\n return absolute\n}\n\n/**\n * Whether `filePath` exists and is a regular file.\n *\n * @param params.filePath Path to probe.\n * @returns `true` only for an existing regular file.\n * @throws {InvalidArgumentError} if `filePath` is not a non-empty string.\n */\nexport const fileExists = ({ filePath }: { filePath: string }): boolean => {\n const absolute = assertPath(filePath, 'filePath')\n try {\n return fs.statSync(absolute).isFile()\n } catch {\n return false\n }\n}\n"]}
1
+ {"version":3,"file":"workspace.js","sourceRoot":"","sources":["../../src/fs/workspace.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AACrE,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,C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S,EAAE,IAAI,EAAE,CAAC,CAAA;IAC3C,OAAO,QAAQ,CAAA;AACjB,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,EAAE,QAAQ,EAAwB,EAAU,EAAE,CACzE,EAAE,CAAC,YAAY,CAAC,UAAU,CAAC,QAAQ,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,CAAA;AAE3D,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,EAC5B,QAAQ,EACR,OAAO,EAIR,EAAU,EAAE;IACX,MAAM,QAAQ,GAAG,UAAU,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAA;IACjD,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAChC,MAAM,IAAI,oBAAoB,CAAC,6BAA6B,CAAC,CAAA;IAC/D,CAAC;IACD,SAAS,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;IAC9C,EAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC,CAAA;IAC3C,OAAO,QAAQ,CAAA;AACjB,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,EAAE,QAAQ,EAAwB,EAAW,EAAE;IACxE,MAAM,QAAQ,GAAG,UAAU,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAA;IACjD,IAAI,CAAC;QACH,OAAO,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,MAAM,EAAE,CAAA;IACvC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAA;IACd,CAAC;AACH,CAAC,CAAA","sourcesContent":["import fs from 'node:fs'\nimport path from 'node:path'\nimport { PLATFORM_PATHS, PRODUCTS_INDEX_PATH } from '../constants.js'\nimport { InvalidArgumentError } from '../errors.js'\n\nexport interface LinePaths {\n readonly platform: string\n readonly code: string\n readonly model: string\n readonly config: string\n readonly extraJs: string\n readonly transformation: string\n readonly productsIndex: string\n}\n\nconst assertPath = (value: unknown, parameter: string): string => {\n if (typeof value !== 'string' || value.trim() === '') {\n throw new InvalidArgumentError(`\"${parameter}\" must be a non-empty path.`)\n }\n return path.resolve(value)\n}\n\nexport const resolveLinePaths = ({ lineDir }: { lineDir: string }): LinePaths => {\n const root = assertPath(lineDir, 'lineDir')\n return {\n platform: path.join(root, PLATFORM_PATHS.root),\n code: path.join(root, PLATFORM_PATHS.code),\n model: path.join(root, PLATFORM_PATHS.model),\n config: path.join(root, PLATFORM_PATHS.config),\n extraJs: path.join(root, PLATFORM_PATHS.extraJs),\n transformation: path.join(root, PLATFORM_PATHS.transformation),\n productsIndex: path.join(root, PRODUCTS_INDEX_PATH)\n }\n}\n\nexport const ensureDir = ({ dirPath }: { dirPath: string }): string => {\n const absolute = assertPath(dirPath, 'dirPath')\n fs.mkdirSync(absolute, { recursive: true })\n return absolute\n}\n\nexport const readTextFile = ({ filePath }: { filePath: string }): string =>\n fs.readFileSync(assertPath(filePath, 'filePath'), 'utf8')\n\nexport const writeTextFile = ({\n filePath,\n content\n}: {\n filePath: string\n content: string\n}): string => {\n const absolute = assertPath(filePath, 'filePath')\n if (typeof content !== 'string') {\n throw new InvalidArgumentError('\"content\" must be a string.')\n }\n ensureDir({ dirPath: path.dirname(absolute) })\n fs.writeFileSync(absolute, content, 'utf8')\n return absolute\n}\n\nexport const fileExists = ({ filePath }: { filePath: string }): boolean => {\n const absolute = assertPath(filePath, 'filePath')\n try {\n return fs.statSync(absolute).isFile()\n } catch {\n return false\n }\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -1,30 +1,9 @@
1
- /**
2
- * linea-core — offline engine for Software Product Lines.
3
- *
4
- * A library of stateless JavaScript functions (ADR-014): every function receives
5
- * what it needs as parameters and returns explicit results. No internal state,
6
- * no singletons, no dependency injection, no global configuration, no database
7
- * and no network (ADR-002). Side effects are limited to the directories the
8
- * caller points at (ADR-009).
9
- *
10
- * This is the ONLY public entry point. Everything under `src/` other than this
11
- * file is private and may change without notice — the `exports` map exposes a
12
- * single entry on purpose.
13
- */
14
- export { PLATFORM_PATHS, PRODUCTS_INDEX_PATH, NAME_PATTERN, VERSION_PATTERN, DEFAULT_LANGUAGES, DEFAULT_SRID, FEATURE_MODEL_TYPES, ANALYSIS_THRESHOLDS, isFeatureModelType } from './constants.js';
15
- export type { FeatureModelType } from './constants.js';
16
- export { LineaCoreError, InvalidArgumentError, UvlParseError, UnsupportedConversionError, FeatureSelectionInvalidError, LinePlatformNotFoundError, InvalidProductSpecError, ProductsIndexError, AnalysisRuntimeError } from './errors.js';
1
+ export { PLATFORM_PATHS, PRODUCTS_INDEX_PATH, NAME_PATTERN, VERSION_PATTERN, DEFAULT_LANGUAGES, DEFAULT_SRID, ANALYSIS_THRESHOLDS } from './constants.js';
2
+ export { LineaCoreError, InvalidArgumentError, UvlParseError, FeatureSelectionInvalidError, LinePlatformNotFoundError, FeatureModelEmptyError, InvalidProductSpecError, ProductsIndexError, AnalysisRuntimeError, ModuleManifestError, ModuleResolutionError, ModuleCheckError, TemplateError } from './errors.js';
17
3
  export type { LineaCoreErrorCode } from './errors.js';
18
- export { parseFeatureModel } from './feature-model/parse.js';
19
- export type { FeatureModelValue } from './feature-model/parse.js';
20
- export { convertFeatureModel } from './feature-model/convert.js';
21
- export { detectFeatureModelType, readFeatureModel, writeFeatureModel } from './feature-model/io.js';
22
- export type { FeatureModelLocation } from './feature-model/io.js';
23
- export { normalizeUvl, estimateFeatureCount, emptyFeatureModelUvl } from './feature-model/text.js';
24
- export { extractFeatureNames, computeMandatoryFeatures } from './feature-model/inspect.js';
25
- export type { MandatoryFeaturesResult } from './feature-model/inspect.js';
26
- export { normalizeFeatureSelection, validateFeatureSelection, assertFeatureSelection, validateModelAgainstSelections } from './selection/selection.js';
27
- export type { FeatureSelectionInput, SelectionBearingSpec, FeatureSelectionVerdict, NamedSelection, BrokenSelection, ModelAgainstSelectionsVerdict } from './selection/selection.js';
4
+ export { normalizeUvl, estimateFeatureCount } from './analysis/uvl-text.js';
5
+ export { parseUvl, printUvl, uvlName, featuresOf } from './feature-model/uvl.js';
6
+ export type { FeatureModelTree, FeatureNode, FeatureGroup, GroupKind, Formula } from './feature-model/uvl.js';
28
7
  export { validateProductSpec, assertProductSpec, normalizeProductSpec } from './product/spec.js';
29
8
  export type { ProductSpec, ProductBasicData, ProductSpecError, ProductSpecErrorCode, ProductSpecValidation } from './product/spec.js';
30
9
  export { incrementVersion } from './product/version.js';
@@ -32,10 +11,14 @@ export { buildEngineSpec } from './product/engine-spec.js';
32
11
  export type { EngineSpec } from './product/engine-spec.js';
33
12
  export { emptyProductsIndex, parseProductsIndex, serializeProductsIndex, validateProductsIndex, addProductToIndex, renameProductInIndex, removeProductFromIndex, readProductsIndex, writeProductsIndex, reconcileProductsIndex } from './products-index/products-index.js';
34
13
  export type { ProductsIndex, ProductsIndexEntry, ProductsIndexProblem, ProductsIndexProblemCode, ProductsIndexValidation, ProductsIndexReconciliation } from './products-index/products-index.js';
35
- export { buildLineScaffold, writeLineScaffold, DEFAULT_PLATFORM_CONFIG, DEFAULT_CODE_GITIGNORE } from './line/scaffold.js';
14
+ export { buildLineScaffold, buildSplManifest, emptyFeatureModel, FEATURE_MODEL_PATH, writeLineScaffold, DEFAULT_PLATFORM_CONFIG, DEFAULT_CODE_GITIGNORE } from './line/scaffold.js';
36
15
  export type { LineScaffoldInput } from './line/scaffold.js';
37
- export { buildExtraJs, buildTransformationJs, getPipelineFiles } from './line/platform-files.js';
38
- export type { FileSpec, MetamodelName } from './line/platform-files.js';
16
+ export { buildExtraJs, buildTransformationJs, getPipelineFiles, getSplPipelineFiles } from './line/platform-files.js';
17
+ export type { FileSpec, CiHost } from './line/platform-files.js';
18
+ export { planLineDeletion, planProductDeletion } from './line/deletion.js';
19
+ export type { DeletableLine, DeletableProduct, DeletionStep, HostDeletionTraits, HostId, LineDeletionPlan } from './line/deletion.js';
20
+ export { planLineRestoration, planProductRestoration } from './line/restoration.js';
21
+ export type { LineRestorationPlan, PendingItem, PendingProduct, RestorationStep } from './line/restoration.js';
39
22
  export { createAnalysisRuntime, disposeAnalysisRuntime } from './analysis/runtime.js';
40
23
  export type { AnalysisRuntime, AnalysisRuntimeOptions } from './analysis/runtime.js';
41
24
  export { analyzeFeatureModel, analyzeFeatureModelBdd, analyzeMetric, ANALYSIS_METRICS } from './analysis/analyze.js';
@@ -48,3 +31,14 @@ export { formatDirectory } from './fs/format.js';
48
31
  export { resolveLinePaths, ensureDir, readTextFile, writeTextFile, fileExists } from './fs/workspace.js';
49
32
  export type { LinePaths } from './fs/workspace.js';
50
33
  export { resolveAsset, assetsRoot } from './assets.js';
34
+ export * from './modules/index.js';
35
+ export { checkLeftovers } from './ci/leftovers.js';
36
+ export type { Leftover, LeftoverDelimiters } from './ci/leftovers.js';
37
+ export { validateSelection, validateProductSelections, completeSelection, ablateFeature, activateFeature } from './ci/validate-specs.js';
38
+ export type { SelectionProblem, ProductSelection, ProductSelectionReport } from './ci/validate-specs.js';
39
+ export { analyzeAnnotations } from './ci/annotations.js';
40
+ export type { FeaturesByFile } from './ci/annotations.js';
41
+ export { selectProducts } from './ci/select.js';
42
+ export type { SelectableProduct, ProductSelectionResult } from './ci/select.js';
43
+ export { renderChildPipeline } from './ci/pipeline.js';
44
+ export { pairwiseSelections } from './ci/pairwise.js';
package/dist/index.js CHANGED
@@ -1,48 +1,28 @@
1
- /**
2
- * linea-core — offline engine for Software Product Lines.
3
- *
4
- * A library of stateless JavaScript functions (ADR-014): every function receives
5
- * what it needs as parameters and returns explicit results. No internal state,
6
- * no singletons, no dependency injection, no global configuration, no database
7
- * and no network (ADR-002). Side effects are limited to the directories the
8
- * caller points at (ADR-009).
9
- *
10
- * This is the ONLY public entry point. Everything under `src/` other than this
11
- * file is private and may change without notice — the `exports` map exposes a
12
- * single entry on purpose.
13
- */
14
- // ── Constants ────────────────────────────────────────────────────────────────
15
- export { PLATFORM_PATHS, PRODUCTS_INDEX_PATH, NAME_PATTERN, VERSION_PATTERN, DEFAULT_LANGUAGES, DEFAULT_SRID, FEATURE_MODEL_TYPES, ANALYSIS_THRESHOLDS, isFeatureModelType } from './constants.js';
16
- // ── Errors ───────────────────────────────────────────────────────────────────
17
- export { LineaCoreError, InvalidArgumentError, UvlParseError, UnsupportedConversionError, FeatureSelectionInvalidError, LinePlatformNotFoundError, InvalidProductSpecError, ProductsIndexError, AnalysisRuntimeError } from './errors.js';
18
- // ── Feature models ───────────────────────────────────────────────────────────
19
- export { parseFeatureModel } from './feature-model/parse.js';
20
- export { convertFeatureModel } from './feature-model/convert.js';
21
- export { detectFeatureModelType, readFeatureModel, writeFeatureModel } from './feature-model/io.js';
22
- export { normalizeUvl, estimateFeatureCount, emptyFeatureModelUvl } from './feature-model/text.js';
23
- export { extractFeatureNames, computeMandatoryFeatures } from './feature-model/inspect.js';
24
- // ── Feature selection ────────────────────────────────────────────────────────
25
- export { normalizeFeatureSelection, validateFeatureSelection, assertFeatureSelection, validateModelAgainstSelections } from './selection/selection.js';
26
- // ── Product specs ────────────────────────────────────────────────────────────
1
+ export { PLATFORM_PATHS, PRODUCTS_INDEX_PATH, NAME_PATTERN, VERSION_PATTERN, DEFAULT_LANGUAGES, DEFAULT_SRID, ANALYSIS_THRESHOLDS } from './constants.js';
2
+ export { LineaCoreError, InvalidArgumentError, UvlParseError, FeatureSelectionInvalidError, LinePlatformNotFoundError, FeatureModelEmptyError, InvalidProductSpecError, ProductsIndexError, AnalysisRuntimeError, ModuleManifestError, ModuleResolutionError, ModuleCheckError, TemplateError } from './errors.js';
3
+ export { normalizeUvl, estimateFeatureCount } from './analysis/uvl-text.js';
4
+ export { parseUvl, printUvl, uvlName, featuresOf } from './feature-model/uvl.js';
27
5
  export { validateProductSpec, assertProductSpec, normalizeProductSpec } from './product/spec.js';
28
6
  export { incrementVersion } from './product/version.js';
29
7
  export { buildEngineSpec } from './product/engine-spec.js';
30
- // ── Products index (ADR-011) ─────────────────────────────────────────────────
31
8
  export { emptyProductsIndex, parseProductsIndex, serializeProductsIndex, validateProductsIndex, addProductToIndex, renameProductInIndex, removeProductFromIndex, readProductsIndex, writeProductsIndex, reconcileProductsIndex } from './products-index/products-index.js';
32
- // ── Line scaffold and platform files ─────────────────────────────────────────
33
- export { buildLineScaffold, writeLineScaffold, DEFAULT_PLATFORM_CONFIG, DEFAULT_CODE_GITIGNORE } from './line/scaffold.js';
34
- export { buildExtraJs, buildTransformationJs, getPipelineFiles } from './line/platform-files.js';
35
- // ── Feature model analysis (ADR-008, ADR-021) ────────────────────────────────
9
+ export { buildLineScaffold, buildSplManifest, emptyFeatureModel, FEATURE_MODEL_PATH, writeLineScaffold, DEFAULT_PLATFORM_CONFIG, DEFAULT_CODE_GITIGNORE } from './line/scaffold.js';
10
+ export { buildExtraJs, buildTransformationJs, getPipelineFiles, getSplPipelineFiles } from './line/platform-files.js';
11
+ export { planLineDeletion, planProductDeletion } from './line/deletion.js';
12
+ export { planLineRestoration, planProductRestoration } from './line/restoration.js';
36
13
  export { createAnalysisRuntime, disposeAnalysisRuntime } from './analysis/runtime.js';
37
14
  export { analyzeFeatureModel, analyzeFeatureModelBdd, analyzeMetric, ANALYSIS_METRICS } from './analysis/analyze.js';
38
- // ── Product derivation ───────────────────────────────────────────────────────
39
15
  export { deriveProduct, deriveProductToZip } from './derivation/derive.js';
40
- // ── Archive, diff and formatting ─────────────────────────────────────────────
41
16
  export { extractArchive } from './fs/archive.js';
42
17
  export { diffDirectories } from './fs/diff.js';
43
18
  export { formatDirectory } from './fs/format.js';
44
- // ── Working directories ──────────────────────────────────────────────────────
45
19
  export { resolveLinePaths, ensureDir, readTextFile, writeTextFile, fileExists } from './fs/workspace.js';
46
- // ── Packaged assets ──────────────────────────────────────────────────────────
47
20
  export { resolveAsset, assetsRoot } from './assets.js';
21
+ export * from './modules/index.js';
22
+ export { checkLeftovers } from './ci/leftovers.js';
23
+ export { validateSelection, validateProductSelections, completeSelection, ablateFeature, activateFeature } from './ci/validate-specs.js';
24
+ export { analyzeAnnotations } from './ci/annotations.js';
25
+ export { selectProducts } from './ci/select.js';
26
+ export { renderChildPipeline } from './ci/pipeline.js';
27
+ export { pairwiseSelections } from './ci/pairwise.js';
48
28
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,gFAAgF;AAChF,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,YAAY,EACZ,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EACnB,MAAM,gBAAgB,CAAA;AAGvB,gFAAgF;AAChF,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,aAAa,EACb,0BAA0B,EAC1B,4BAA4B,EAC5B,yBAAyB,EACzB,uBAAuB,EACvB,kBAAkB,EAClB,oBAAoB,EACrB,MAAM,aAAa,CAAA;AAGpB,gFAAgF;AAChF,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAE5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AAChE,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AAEnG,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAClG,OAAO,EAAE,mBAAmB,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAA;AAG1F,gFAAgF;AAChF,OAAO,EACL,yBAAyB,EACzB,wBAAwB,EACxB,sBAAsB,EACtB,8BAA8B,EAC/B,MAAM,0BAA0B,CAAA;AAUjC,gFAAgF;AAChF,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAA;AAQhG,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAG1D,gFAAgF;AAChF,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,sBAAsB,EACtB,qBAAqB,EACrB,iBAAiB,EACjB,oBAAoB,EACpB,sBAAsB,EACtB,iBAAiB,EACjB,kBAAkB,EAClB,sBAAsB,EACvB,MAAM,oCAAoC,CAAA;AAU3C,gFAAgF;AAChF,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,uBAAuB,EACvB,sBAAsB,EACvB,MAAM,oBAAoB,CAAA;AAE3B,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAGhG,gFAAgF;AAChF,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAA;AAErF,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,aAAa,EACb,gBAAgB,EACjB,MAAM,uBAAuB,CAAA;AAS9B,gFAAgF;AAChF,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAE1E,gFAAgF;AAChF,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAE9C,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAEhD,gFAAgF;AAChF,OAAO,EACL,gBAAgB,EAChB,SAAS,EACT,YAAY,EACZ,aAAa,EACb,UAAU,EACX,MAAM,mBAAmB,CAAA;AAG1B,gFAAgF;AAChF,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA","sourcesContent":["/**\n * linea-core — offline engine for Software Product Lines.\n *\n * A library of stateless JavaScript functions (ADR-014): every function receives\n * what it needs as parameters and returns explicit results. No internal state,\n * no singletons, no dependency injection, no global configuration, no database\n * and no network (ADR-002). Side effects are limited to the directories the\n * caller points at (ADR-009).\n *\n * This is the ONLY public entry point. Everything under `src/` other than this\n * file is private and may change without notice — the `exports` map exposes a\n * single entry on purpose.\n */\n\n// ── Constants ────────────────────────────────────────────────────────────────\nexport {\n PLATFORM_PATHS,\n PRODUCTS_INDEX_PATH,\n NAME_PATTERN,\n VERSION_PATTERN,\n DEFAULT_LANGUAGES,\n DEFAULT_SRID,\n FEATURE_MODEL_TYPES,\n ANALYSIS_THRESHOLDS,\n isFeatureModelType\n} from './constants.js'\nexport type { FeatureModelType } from './constants.js'\n\n// ── Errors ───────────────────────────────────────────────────────────────────\nexport {\n LineaCoreError,\n InvalidArgumentError,\n UvlParseError,\n UnsupportedConversionError,\n FeatureSelectionInvalidError,\n LinePlatformNotFoundError,\n InvalidProductSpecError,\n ProductsIndexError,\n AnalysisRuntimeError\n} from './errors.js'\nexport type { LineaCoreErrorCode } from './errors.js'\n\n// ── Feature models ───────────────────────────────────────────────────────────\nexport { parseFeatureModel } from './feature-model/parse.js'\nexport type { FeatureModelValue } from './feature-model/parse.js'\nexport { convertFeatureModel } from './feature-model/convert.js'\nexport { detectFeatureModelType, readFeatureModel, writeFeatureModel } from './feature-model/io.js'\nexport type { FeatureModelLocation } from './feature-model/io.js'\nexport { normalizeUvl, estimateFeatureCount, emptyFeatureModelUvl } from './feature-model/text.js'\nexport { extractFeatureNames, computeMandatoryFeatures } from './feature-model/inspect.js'\nexport type { MandatoryFeaturesResult } from './feature-model/inspect.js'\n\n// ── Feature selection ────────────────────────────────────────────────────────\nexport {\n normalizeFeatureSelection,\n validateFeatureSelection,\n assertFeatureSelection,\n validateModelAgainstSelections\n} from './selection/selection.js'\nexport type {\n FeatureSelectionInput,\n SelectionBearingSpec,\n FeatureSelectionVerdict,\n NamedSelection,\n BrokenSelection,\n ModelAgainstSelectionsVerdict\n} from './selection/selection.js'\n\n// ── Product specs ────────────────────────────────────────────────────────────\nexport { validateProductSpec, assertProductSpec, normalizeProductSpec } from './product/spec.js'\nexport type {\n ProductSpec,\n ProductBasicData,\n ProductSpecError,\n ProductSpecErrorCode,\n ProductSpecValidation\n} from './product/spec.js'\nexport { incrementVersion } from './product/version.js'\nexport { buildEngineSpec } from './product/engine-spec.js'\nexport type { EngineSpec } from './product/engine-spec.js'\n\n// ── Products index (ADR-011) ─────────────────────────────────────────────────\nexport {\n emptyProductsIndex,\n parseProductsIndex,\n serializeProductsIndex,\n validateProductsIndex,\n addProductToIndex,\n renameProductInIndex,\n removeProductFromIndex,\n readProductsIndex,\n writeProductsIndex,\n reconcileProductsIndex\n} from './products-index/products-index.js'\nexport type {\n ProductsIndex,\n ProductsIndexEntry,\n ProductsIndexProblem,\n ProductsIndexProblemCode,\n ProductsIndexValidation,\n ProductsIndexReconciliation\n} from './products-index/products-index.js'\n\n// ── Line scaffold and platform files ─────────────────────────────────────────\nexport {\n buildLineScaffold,\n writeLineScaffold,\n DEFAULT_PLATFORM_CONFIG,\n DEFAULT_CODE_GITIGNORE\n} from './line/scaffold.js'\nexport type { LineScaffoldInput } from './line/scaffold.js'\nexport { buildExtraJs, buildTransformationJs, getPipelineFiles } from './line/platform-files.js'\nexport type { FileSpec, MetamodelName } from './line/platform-files.js'\n\n// ── Feature model analysis (ADR-008, ADR-021) ────────────────────────────────\nexport { createAnalysisRuntime, disposeAnalysisRuntime } from './analysis/runtime.js'\nexport type { AnalysisRuntime, AnalysisRuntimeOptions } from './analysis/runtime.js'\nexport {\n analyzeFeatureModel,\n analyzeFeatureModelBdd,\n analyzeMetric,\n ANALYSIS_METRICS\n} from './analysis/analyze.js'\nexport type {\n AnalysisMode,\n AnalysisMetric,\n FeatureModelAnalysis,\n FeatureModelBddAnalysis,\n MetricAnalysis\n} from './analysis/analyze.js'\n\n// ── Product derivation ───────────────────────────────────────────────────────\nexport { deriveProduct, deriveProductToZip } from './derivation/derive.js'\n\n// ── Archive, diff and formatting ─────────────────────────────────────────────\nexport { extractArchive } from './fs/archive.js'\nexport { diffDirectories } from './fs/diff.js'\nexport type { FileChange } from './fs/diff.js'\nexport { formatDirectory } from './fs/format.js'\n\n// ── Working directories ──────────────────────────────────────────────────────\nexport {\n resolveLinePaths,\n ensureDir,\n readTextFile,\n writeTextFile,\n fileExists\n} from './fs/workspace.js'\nexport type { LinePaths } from './fs/workspace.js'\n\n// ── Packaged assets ──────────────────────────────────────────────────────────\nexport { resolveAsset, assetsRoot } from './assets.js'\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,YAAY,EACZ,mBAAmB,EACpB,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,aAAa,EACb,4BAA4B,EAC5B,yBAAyB,EACzB,sBAAsB,EACtB,uBAAuB,EACvB,kBAAkB,EAClB,oBAAoB,EACpB,mBAAmB,EACnB,qBAAqB,EACrB,gBAAgB,EAChB,aAAa,EACd,MAAM,aAAa,CAAA;AAGpB,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAC3E,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAGhF,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAA;AAQhG,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAG1D,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,sBAAsB,EACtB,qBAAqB,EACrB,iBAAiB,EACjB,oBAAoB,EACpB,sBAAsB,EACtB,iBAAiB,EACjB,kBAAkB,EAClB,sBAAsB,EACvB,MAAM,oCAAoC,CAAA;AAU3C,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,uBAAuB,EACv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RODUCTS_INDEX_PATH,\n NAME_PATTERN,\n VERSION_PATTERN,\n DEFAULT_LANGUAGES,\n DEFAULT_SRID,\n ANALYSIS_THRESHOLDS\n} from './constants.js'\n\nexport {\n LineaCoreError,\n InvalidArgumentError,\n UvlParseError,\n FeatureSelectionInvalidError,\n LinePlatformNotFoundError,\n FeatureModelEmptyError,\n InvalidProductSpecError,\n ProductsIndexError,\n AnalysisRuntimeError,\n ModuleManifestError,\n ModuleResolutionError,\n ModuleCheckError,\n TemplateError\n} from './errors.js'\nexport type { LineaCoreErrorCode } from './errors.js'\n\nexport { normalizeUvl, estimateFeatureCount } from './analysis/uvl-text.js'\nexport { parseUvl, printUvl, uvlName, featuresOf } from './feature-model/uvl.js'\nexport type { FeatureModelTree, FeatureNode, FeatureGroup, GroupKind, Formula } from './feature-model/uvl.js'\n\nexport { validateProductSpec, assertProductSpec, normalizeProductSpec } from './product/spec.js'\nexport type {\n ProductSpec,\n ProductBasicData,\n ProductSpecError,\n ProductSpecErrorCode,\n ProductSpecValidation\n} from './product/spec.js'\nexport { incrementVersion } from './product/version.js'\nexport { buildEngineSpec } from './product/engine-spec.js'\nexport type { EngineSpec } from './product/engine-spec.js'\n\nexport {\n emptyProductsIndex,\n parseProductsIndex,\n serializeProductsIndex,\n validateProductsIndex,\n addProductToIndex,\n renameProductInIndex,\n removeProductFromIndex,\n readProductsIndex,\n writeProductsIndex,\n reconcileProductsIndex\n} from './products-index/products-index.js'\nexport type {\n ProductsIndex,\n ProductsIndexEntry,\n ProductsIndexProblem,\n ProductsIndexProblemCode,\n ProductsIndexValidation,\n ProductsIndexReconciliation\n} from './products-index/products-index.js'\n\nexport {\n buildLineScaffold,\n buildSplManifest,\n emptyFeatureModel,\n FEATURE_MODEL_PATH,\n writeLineScaffold,\n DEFAULT_PLATFORM_CONFIG,\n DEFAULT_CODE_GITIGNORE\n} from './line/scaffold.js'\nexport type { LineScaffoldInput } from './line/scaffold.js'\nexport { buildExtraJs, buildTransformationJs, getPipelineFiles, getSplPipelineFiles } from './line/platform-files.js'\nexport type { FileSpec, CiHost } from './line/platform-files.js'\nexport { planLineDeletion, planProductDeletion } from './line/deletion.js'\nexport type { DeletableLine, DeletableProduct, DeletionStep, HostDeletionTraits, HostId, LineDeletionPlan } from './line/deletion.js'\nexport { planLineRestoration, planProductRestoration } from './line/restoration.js'\nexport type { LineRestorationPlan, PendingItem, PendingProduct, RestorationStep } from './line/restoration.js'\n\nexport { createAnalysisRuntime, disposeAnalysisRuntime } from './analysis/runtime.js'\nexport type { AnalysisRuntime, AnalysisRuntimeOptions } from './analysis/runtime.js'\nexport {\n analyzeFeatureModel,\n analyzeFeatureModelBdd,\n analyzeMetric,\n ANALYSIS_METRICS\n} from './analysis/analyze.js'\nexport type {\n AnalysisMode,\n AnalysisMetric,\n FeatureModelAnalysis,\n FeatureModelBddAnalysis,\n MetricAnalysis\n} from './analysis/analyze.js'\n\nexport { deriveProduct, deriveProductToZip } from './derivation/derive.js'\n\nexport { extractArchive } from './fs/archive.js'\nexport { diffDirectories } from './fs/diff.js'\nexport type { FileChange } from './fs/diff.js'\nexport { formatDirectory } from './fs/format.js'\n\nexport {\n resolveLinePaths,\n ensureDir,\n readTextFile,\n writeTextFile,\n fileExists\n} from './fs/workspace.js'\nexport type { LinePaths } from './fs/workspace.js'\n\nexport { resolveAsset, assetsRoot } from './assets.js'\n\nexport * from './modules/index.js'\n\nexport { checkLeftovers } from './ci/leftovers.js'\nexport type { Leftover, LeftoverDelimiters } from './ci/leftovers.js'\nexport { validateSelection, validateProductSelections, completeSelection, ablateFeature, activateFeature } from './ci/validate-specs.js'\nexport type { SelectionProblem, ProductSelection, ProductSelectionReport } from './ci/validate-specs.js'\nexport { analyzeAnnotations } from './ci/annotations.js'\nexport type { FeaturesByFile } from './ci/annotations.js'\nexport { selectProducts } from './ci/select.js'\nexport type { SelectableProduct, ProductSelectionResult } from './ci/select.js'\nexport { renderChildPipeline } from './ci/pipeline.js'\nexport { pairwiseSelections } from './ci/pairwise.js'\n"]}
@@ -1,15 +1,2 @@
1
- /**
2
- * INTERNAL type guards. Not exported from `src/index.ts`.
3
- */
4
- /** Narrows to a non-null, non-array object. */
5
1
  export declare const isPlainObject: (value: unknown) => value is Record<string, unknown>;
6
- /**
7
- * Array check that preserves the declared element type.
8
- *
9
- * `Array.isArray(x)` widens a `readonly T[]` to `any[]` in the narrowed branch
10
- * (TypeScript cannot express "readonly array" through its built-in guard), which
11
- * then makes every subsequent `.name`/`.features` access an unsafe `any` member
12
- * access. This guard narrows to `readonly unknown[]` instead, so intersecting it
13
- * with the declared parameter type keeps `readonly T[]` intact.
14
- */
15
2
  export declare const isArray: (value: unknown) => value is readonly unknown[];
@@ -1,16 +1,3 @@
1
- /**
2
- * INTERNAL type guards. Not exported from `src/index.ts`.
3
- */
4
- /** Narrows to a non-null, non-array object. */
5
1
  export const isPlainObject = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
6
- /**
7
- * Array check that preserves the declared element type.
8
- *
9
- * `Array.isArray(x)` widens a `readonly T[]` to `any[]` in the narrowed branch
10
- * (TypeScript cannot express "readonly array" through its built-in guard), which
11
- * then makes every subsequent `.name`/`.features` access an unsafe `any` member
12
- * access. This guard narrows to `readonly unknown[]` instead, so intersecting it
13
- * with the declared parameter type keeps `readonly T[]` intact.
14
- */
15
2
  export const isArray = (value) => Array.isArray(value);
16
3
  //# sourceMappingURL=guards.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"guards.js","sourceRoot":"","sources":["../../src/internal/guards.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,+CAA+C;AAC/C,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,KAAc,EAAoC,EAAE,CAChF,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;AAEtE;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,KAAc,EAA+B,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA","sourcesContent":["/**\n * INTERNAL type guards. Not exported from `src/index.ts`.\n */\n\n/** Narrows to a non-null, non-array object. */\nexport const isPlainObject = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null && !Array.isArray(value)\n\n/**\n * Array check that preserves the declared element type.\n *\n * `Array.isArray(x)` widens a `readonly T[]` to `any[]` in the narrowed branch\n * (TypeScript cannot express \"readonly array\" through its built-in guard), which\n * then makes every subsequent `.name`/`.features` access an unsafe `any` member\n * access. This guard narrows to `readonly unknown[]` instead, so intersecting it\n * with the declared parameter type keeps `readonly T[]` intact.\n */\nexport const isArray = (value: unknown): value is readonly unknown[] => Array.isArray(value)\n"]}
1
+ {"version":3,"file":"guards.js","sourceRoot":"","sources":["../../src/internal/guards.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,KAAc,EAAoC,EAAE,CAChF,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;AAEtE,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,KAAc,EAA+B,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA","sourcesContent":["\nexport const isPlainObject = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null && !Array.isArray(value)\n\nexport const isArray = (value: unknown): value is readonly unknown[] => Array.isArray(value)\n"]}
@@ -0,0 +1,33 @@
1
+ export type HostId = string | number;
2
+ export interface HostDeletionTraits {
3
+ namespaceIsRepository: boolean;
4
+ }
5
+ export interface DeletionStep {
6
+ kind: 'repository' | 'namespace';
7
+ id: HostId;
8
+ }
9
+ export interface DeletableProduct {
10
+ id: string;
11
+ repositoryId: HostId;
12
+ namespaceId: HostId;
13
+ }
14
+ export interface DeletableLine {
15
+ repositoryId: HostId;
16
+ namespaceId: HostId;
17
+ }
18
+ export interface LineDeletionPlan {
19
+ steps: DeletionStep[];
20
+ deletedProductIds: string[];
21
+ keptProductIds: string[];
22
+ lineSurvives: boolean;
23
+ }
24
+ export declare const planProductDeletion: ({ product, host }: {
25
+ product: Pick<DeletableProduct, "repositoryId" | "namespaceId">;
26
+ host: HostDeletionTraits;
27
+ }) => DeletionStep[];
28
+ export declare const planLineDeletion: ({ line, products, keepProductIds, host }: {
29
+ line: DeletableLine;
30
+ products: DeletableProduct[];
31
+ keepProductIds?: string[];
32
+ host: HostDeletionTraits;
33
+ }) => LineDeletionPlan;
@@ -0,0 +1,23 @@
1
+ import { InvalidArgumentError } from '../errors.js';
2
+ export const planProductDeletion = ({ product, host }) => (host.namespaceIsRepository
3
+ ? [{ kind: 'namespace', id: product.namespaceId }]
4
+ : [{ kind: 'repository', id: product.repositoryId }, { kind: 'namespace', id: product.namespaceId }]);
5
+ export const planLineDeletion = ({ line, products, keepProductIds = [], host }) => {
6
+ const known = new Set(products.map((product) => product.id));
7
+ const stranger = keepProductIds.find((id) => !known.has(id));
8
+ if (stranger !== undefined)
9
+ throw new InvalidArgumentError(`The product to keep "${stranger}" is not one of the line.`);
10
+ const keep = new Set(keepProductIds);
11
+ const doomed = products.filter((product) => !keep.has(product.id));
12
+ const kept = products.filter((product) => keep.has(product.id));
13
+ const steps = kept.length === 0
14
+ ? [{ kind: 'namespace', id: line.namespaceId }]
15
+ : [...doomed.flatMap((product) => planProductDeletion({ product, host })), { kind: 'repository', id: line.repositoryId }];
16
+ return {
17
+ steps,
18
+ deletedProductIds: doomed.map((product) => product.id),
19
+ keptProductIds: kept.map((product) => product.id),
20
+ lineSurvives: kept.length > 0,
21
+ };
22
+ };
23
+ //# sourceMappingURL=deletion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deletion.js","sourceRoot":"","sources":["../../src/line/deletion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AA+BnD,MAAM,CAAC,M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,KAAK,GAAmB,IAAI,CAAC,MAAM,KAAK,CAAC;QAC7C,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC;QAC/C,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,mBAAmB,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,EAAE,EAAE,IAAI,CAAC,YAAY,EAAE,CAAC,CAAA;IAE3H,OAAO;QACL,KAAK;QACL,iBAAiB,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;QACtD,cAAc,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;QACjD,YAAY,EAAE,IAAI,CAAC,MAAM,GAAG,CAAC;KAC9B,CAAA;AACH,CAAC,CAAA","sourcesContent":["import { InvalidArgumentError } from '../errors.js'\n\nexport type HostId = string | number\n\nexport interface HostDeletionTraits {\n namespaceIsRepository: boolean\n}\n\nexport interface DeletionStep {\n kind: 'repository' | 'namespace'\n id: HostId\n}\n\nexport interface DeletableProduct {\n id: string\n repositoryId: HostId\n namespaceId: HostId\n}\n\nexport interface DeletableLine {\n repositoryId: HostId\n namespaceId: HostId\n}\n\nexport interface LineDeletionPlan {\n steps: DeletionStep[]\n deletedProductIds: string[]\n keptProductIds: string[]\n lineSurvives: boolean\n}\n\nexport const planProductDeletion = ({ product, host }: { product: Pick<DeletableProduct, 'repositoryId' | 'namespaceId'>, host: HostDeletionTraits }): DeletionStep[] => (\n host.namespaceIsRepository\n ? [{ kind: 'namespace', id: product.namespaceId }]\n : [{ kind: 'repository', id: product.repositoryId }, { kind: 'namespace', id: product.namespaceId }]\n)\n\nexport const planLineDeletion = ({ line, products, keepProductIds = [], host }: {\n line: DeletableLine\n products: DeletableProduct[]\n keepProductIds?: string[]\n host: HostDeletionTraits\n}): LineDeletionPlan => {\n const known = new Set(products.map((product) => product.id))\n const stranger = keepProductIds.find((id) => !known.has(id))\n if (stranger !== undefined) throw new InvalidArgumentError(`The product to keep \"${stranger}\" is not one of the line.`)\n\n const keep = new Set(keepProductIds)\n const doomed = products.filter((product) => !keep.has(product.id))\n const kept = products.filter((product) => keep.has(product.id))\n const steps: DeletionStep[] = kept.length === 0\n ? [{ kind: 'namespace', id: line.namespaceId }]\n : [...doomed.flatMap((product) => planProductDeletion({ product, host })), { kind: 'repository', id: line.repositoryId }]\n\n return {\n steps,\n deletedProductIds: doomed.map((product) => product.id),\n keptProductIds: kept.map((product) => product.id),\n lineSurvives: kept.length > 0,\n }\n}\n"]}