@lbdudc/linea-core 0.1.0 → 0.1.1

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 (37) hide show
  1. package/README.md +358 -358
  2. package/dist/analysis/analyze.js.map +1 -1
  3. package/dist/analysis/runtime.js.map +1 -1
  4. package/dist/assets.js.map +1 -1
  5. package/dist/constants.js.map +1 -1
  6. package/dist/derivation/derive.js.map +1 -1
  7. package/dist/derivation/engine.js.map +1 -1
  8. package/dist/errors.js.map +1 -1
  9. package/dist/feature-model/convert.js.map +1 -1
  10. package/dist/feature-model/engine.js.map +1 -1
  11. package/dist/feature-model/inspect.js.map +1 -1
  12. package/dist/feature-model/io.js.map +1 -1
  13. package/dist/feature-model/parse.js.map +1 -1
  14. package/dist/feature-model/text.js.map +1 -1
  15. package/dist/fs/archive.js.map +1 -1
  16. package/dist/fs/diff.js.map +1 -1
  17. package/dist/fs/format.js.map +1 -1
  18. package/dist/fs/workspace.js.map +1 -1
  19. package/dist/index.js.map +1 -1
  20. package/dist/internal/guards.js.map +1 -1
  21. package/dist/line/platform-files.js.map +1 -1
  22. package/dist/line/scaffold.js.map +1 -1
  23. package/dist/line/templates/core/extra.js +54 -54
  24. package/dist/line/templates/core/transformation.js +196 -196
  25. package/dist/line/templates/metamodels/dataModel/extra.js +328 -328
  26. package/dist/line/templates/metamodels/dataModel/transformation.js +211 -211
  27. package/dist/line/templates/metamodels/sensor/extra.js +36 -36
  28. package/dist/line/templates/metamodels/sensor/transformation.js +47 -47
  29. package/dist/line/templates/pipeline/.gitlab-ci.yml +51 -51
  30. package/dist/line/templates/pipeline/ci/test-client.sh +16 -16
  31. package/dist/line/templates/pipeline/ci/test-server.sh +16 -16
  32. package/dist/product/engine-spec.js.map +1 -1
  33. package/dist/product/spec.js.map +1 -1
  34. package/dist/product/version.js.map +1 -1
  35. package/dist/products-index/products-index.js.map +1 -1
  36. package/dist/selection/selection.js.map +1 -1
  37. package/package.json +67 -67
@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,CAAC,GAAG,CAAC,IAAI,CAAC;gBAAE,KAAK,IAAI,CAAC,CAAA;QACvD,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC,CAAA;AAED;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,EAAE,IAAI,EAAoB,EAAU,EAAE;IACzE,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QACnD,MAAM,IAAI,oBAAoB,CAAC,oCAAoC,CAAC,CAAA;IACtE,CAAC;IACD,OAAO,eAAe,IAAI,6BAA6B,CAAA;AACzD,CAAC,CAAA","sourcesContent":["/**\r\n * Pure text helpers over UVL documents. No parsing, no I/O.\r\n */\r\nimport { InvalidArgumentError } from '../errors.js'\r\n\r\n/** UVL keywords that introduce a group instead of naming a feature. */\r\nconst UVL_GROUP_KEYWORDS: ReadonlySet<string> = new Set([\r\n 'mandatory',\r\n 'optional',\r\n 'alternative',\r\n 'or',\r\n 'features',\r\n 'constraints'\r\n])\r\n\r\nconst assertUvlString = (uvl: unknown, parameter: string): string => {\r\n if (typeof uvl !== 'string') {\r\n throw new InvalidArgumentError(`\"${parameter}\" must be a string.`)\r\n }\r\n return uvl\r\n}\r\n\r\n/**\r\n * Faithful port of Python's `str.expandtabs(tabsize)`.\r\n *\r\n * NOT the same as replacing each tab with N spaces: a tab advances to the next\r\n * multiple of `tabSize`. Getting this wrong would silently change the indentation\r\n * of every UVL model, which is significant in UVL.\r\n */\r\nconst expandTabs = (line: string, tabSize = 4): string => {\r\n let out = ''\r\n let column = 0\r\n for (const char of line) {\r\n if (char === '\\t') {\r\n const width = tabSize - (column % tabSize)\r\n out += ' '.repeat(width)\r\n column += width\r\n } else {\r\n out += char\r\n column += 1\r\n }\r\n }\r\n return out\r\n}\r\n\r\n/**\r\n * Normalises line endings and expands tabs so the UVL parser always gets clean\r\n * input.\r\n *\r\n * Migrated from `linea/flamapy-server/main.py:normalize_uvl` (~122-131). Its\r\n * docstring explains why: Monaco on Windows emits CRLF, and Shift+Tab/Tab leave\r\n * mixed tabs and spaces that the UVL language server tolerates but the parser\r\n * does not.\r\n *\r\n * @param params.uvl Raw UVL document.\r\n * @returns The normalised document (trimmed, LF endings, tabs expanded to 4).\r\n * @throws {InvalidArgumentError} if `uvl` is not a string. Returning `''` for a\r\n * non-string would let a caller bug flow into `estimateFeatureCount` and\r\n * silently flip an `ANALYSIS_THRESHOLDS` decision.\r\n */\r\nexport const normalizeUvl = ({ uvl }: { uvl: string }): string => {\r\n const unified = assertUvlString(uvl, 'uvl').trim().replace(/\\r\\n/g, '\\n').replace(/\\r/g, '\\n')\r\n return unified\r\n .split('\\n')\r\n .map((line) => expandTabs(line, 4))\r\n .join('\\n')\r\n}\r\n\r\n/**\r\n * Counts features in a UVL document without parsing it.\r\n *\r\n * Migrated from `linea/server/src/utils/flamapyUtils.mjs:estimateFeatureCount`\r\n * (~11-28), which is itself the twin of\r\n * `linea/flamapy-server/main.py:estimate_feature_count` (~59-78). The counting\r\n * loop is byte-compatible with both: everything after the `constraints` keyword\r\n * is ignored, and a line counts as a feature when it is indented at least 2\r\n * columns and its first token is not a group keyword.\r\n *\r\n * Normalise first: with tab indentation the root feature sits at indent 1 and is\r\n * not counted, which is why `/analyze` in `main.py` calls `normalize_uvl` before\r\n * counting.\r\n *\r\n * @param params.uvl Raw UVL document.\r\n * @returns Estimated number of features.\r\n * @throws {InvalidArgumentError} if `uvl` is not a string.\r\n */\r\nexport const estimateFeatureCount = ({ uvl }: { uvl: string }): number => {\r\n const document = assertUvlString(uvl, 'uvl')\r\n let inConstraints = false\r\n let count = 0\r\n for (const line of document.split('\\n')) {\r\n const trimmed = line.trim()\r\n if (!trimmed || trimmed.startsWith('//') || trimmed.startsWith('#')) continue\r\n if (trimmed === 'constraints') {\r\n inConstraints = true\r\n continue\r\n }\r\n if (inConstraints) continue\r\n if (trimmed === 'features') continue\r\n const indent = line.length - line.trimStart().length\r\n if (indent >= 2) {\r\n const name = trimmed.split(/[\\s{[]/)[0]\r\n if (name && !UVL_GROUP_KEYWORDS.has(name)) count += 1\r\n }\r\n }\r\n return count\r\n}\r\n\r\n/**\r\n * Builds the seed UVL model of a brand new line.\r\n *\r\n * Migrated byte for byte from `linea/server/src/model/services/LineService.js:43`:\r\n * `` `features\\n\\t${line.name}\\n\\t\\tmandatory\\n\\t\\t\\tvoid` ``.\r\n * Tabs and the absence of a trailing newline are part of the contract — a test\r\n * asserts the exact string.\r\n *\r\n * @param params.name Line name; used as the root feature.\r\n * @returns The seed UVL document.\r\n * @throws {InvalidArgumentError} if `name` is not a non-empty string.\r\n */\r\nexport const emptyFeatureModelUvl = ({ name }: { name: string }): string => {\r\n if (typeof name !== 'string' || name.trim() === '') {\r\n throw new InvalidArgumentError('\"name\" must be a non-empty string.')\r\n }\r\n return `features\\n\\t${name}\\n\\t\\tmandatory\\n\\t\\t\\tvoid`\r\n}\r\n"]}
1
+ {"version":3,"file":"text.js","sourceRoot":"","sources":["../../src/feature-model/text.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AAEnD,uEAAuE;AACvE,MAAM,kBAAkB,GAAwB,IAAI,GAAG,CAAC;IACtD,WAAW;IACX,UAAU;IACV,aAAa;IACb,IAAI;IACJ,UAAU;IACV,aAAa;CACd,CAAC,CAAA;AAEF,MAAM,eAAe,GAAG,CAAC,GAAY,EAAE,SAAiB,EAAU,EAAE;IAClE,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QAC5B,MAAM,IAAI,oBAAoB,CAAC,IAAI,SAAS,qBAAqB,CAAC,CAAA;IACpE,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA;AAED;;;;;;GAMG;AACH,MAAM,UAAU,GAAG,CAAC,IAAY,EAAE,OAAO,GAAG,CAAC,EAAU,EAAE;IACvD,IAAI,GAAG,GAAG,EA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MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAA;QAC3B,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC;YAAE,SAAQ;QAC7E,IAAI,OAAO,KAAK,aAAa,EAAE,CAAC;YAC9B,aAAa,GAAG,IAAI,CAAA;YACpB,SAAQ;QACV,CAAC;QACD,IAAI,aAAa;YAAE,SAAQ;QAC3B,IAAI,OAAO,KAAK,UAAU;YAAE,SAAQ;QACpC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC,MAAM,CAAA;QACpD,IAAI,MAAM,IAAI,CAAC,EAAE,CAAC;YAChB,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAA;YACvC,IAAI,IAAI,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,IAAI,CAAC;gBAAE,KAAK,IAAI,CAAC,CAAA;QACvD,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC,CAAA;AAED;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,EAAE,IAAI,EAAoB,EAAU,EAAE;IACzE,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QACnD,MAAM,IAAI,oBAAoB,CAAC,oCAAoC,CAAC,CAAA;IACtE,CAAC;IACD,OAAO,eAAe,IAAI,6BAA6B,CAAA;AACzD,CAAC,CAAA","sourcesContent":["/**\n * Pure text helpers over UVL documents. No parsing, no I/O.\n */\nimport { InvalidArgumentError } from '../errors.js'\n\n/** UVL keywords that introduce a group instead of naming a feature. */\nconst UVL_GROUP_KEYWORDS: ReadonlySet<string> = new Set([\n 'mandatory',\n 'optional',\n 'alternative',\n 'or',\n 'features',\n 'constraints'\n])\n\nconst assertUvlString = (uvl: unknown, parameter: string): string => {\n if (typeof uvl !== 'string') {\n throw new InvalidArgumentError(`\"${parameter}\" must be a string.`)\n }\n return uvl\n}\n\n/**\n * Faithful port of Python's `str.expandtabs(tabsize)`.\n *\n * NOT the same as replacing each tab with N spaces: a tab advances to the next\n * multiple of `tabSize`. Getting this wrong would silently change the indentation\n * of every UVL model, which is significant in UVL.\n */\nconst expandTabs = (line: string, tabSize = 4): string => {\n let out = ''\n let column = 0\n for (const char of line) {\n if (char === '\\t') {\n const width = tabSize - (column % tabSize)\n out += ' '.repeat(width)\n column += width\n } else {\n out += char\n column += 1\n }\n }\n return out\n}\n\n/**\n * Normalises line endings and expands tabs so the UVL parser always gets clean\n * input.\n *\n * Migrated from `linea/flamapy-server/main.py:normalize_uvl` (~122-131). Its\n * docstring explains why: Monaco on Windows emits CRLF, and Shift+Tab/Tab leave\n * mixed tabs and spaces that the UVL language server tolerates but the parser\n * does not.\n *\n * @param params.uvl Raw UVL document.\n * @returns The normalised document (trimmed, LF endings, tabs expanded to 4).\n * @throws {InvalidArgumentError} if `uvl` is not a string. Returning `''` for a\n * non-string would let a caller bug flow into `estimateFeatureCount` and\n * silently flip an `ANALYSIS_THRESHOLDS` decision.\n */\nexport const normalizeUvl = ({ uvl }: { uvl: string }): string => {\n const unified = assertUvlString(uvl, 'uvl').trim().replace(/\\r\\n/g, '\\n').replace(/\\r/g, '\\n')\n return unified\n .split('\\n')\n .map((line) => expandTabs(line, 4))\n .join('\\n')\n}\n\n/**\n * Counts features in a UVL document without parsing it.\n *\n * Migrated from `linea/server/src/utils/flamapyUtils.mjs:estimateFeatureCount`\n * (~11-28), which is itself the twin of\n * `linea/flamapy-server/main.py:estimate_feature_count` (~59-78). The counting\n * loop is byte-compatible with both: everything after the `constraints` keyword\n * is ignored, and a line counts as a feature when it is indented at least 2\n * columns and its first token is not a group keyword.\n *\n * Normalise first: with tab indentation the root feature sits at indent 1 and is\n * not counted, which is why `/analyze` in `main.py` calls `normalize_uvl` before\n * counting.\n *\n * @param params.uvl Raw UVL document.\n * @returns Estimated number of features.\n * @throws {InvalidArgumentError} if `uvl` is not a string.\n */\nexport const estimateFeatureCount = ({ uvl }: { uvl: string }): number => {\n const document = assertUvlString(uvl, 'uvl')\n let inConstraints = false\n let count = 0\n for (const line of document.split('\\n')) {\n const trimmed = line.trim()\n if (!trimmed || trimmed.startsWith('//') || trimmed.startsWith('#')) continue\n if (trimmed === 'constraints') {\n inConstraints = true\n continue\n }\n if (inConstraints) continue\n if (trimmed === 'features') continue\n const indent = line.length - line.trimStart().length\n if (indent >= 2) {\n const name = trimmed.split(/[\\s{[]/)[0]\n if (name && !UVL_GROUP_KEYWORDS.has(name)) count += 1\n }\n }\n return count\n}\n\n/**\n * Builds the seed UVL model of a brand new line.\n *\n * Migrated byte for byte from `linea/server/src/model/services/LineService.js:43`:\n * `` `features\\n\\t${line.name}\\n\\t\\tmandatory\\n\\t\\t\\tvoid` ``.\n * Tabs and the absence of a trailing newline are part of the contract — a test\n * asserts the exact string.\n *\n * @param params.name Line name; used as the root feature.\n * @returns The seed UVL document.\n * @throws {InvalidArgumentError} if `name` is not a non-empty string.\n */\nexport const emptyFeatureModelUvl = ({ name }: { name: string }): string => {\n if (typeof name !== 'string' || name.trim() === '') {\n throw new InvalidArgumentError('\"name\" must be a non-empty string.')\n }\n return `features\\n\\t${name}\\n\\t\\tmandatory\\n\\t\\t\\tvoid`\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"archive.js","sourceRoot":"","sources":["../../src/fs/archive.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,OAAO,MAAM,aAAa,CAAA;AACjC,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AAEnD;;;;;;;;;;;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js:unZip` (~46-80), which\r\n * downloads a repository archive from GitLab and unpacks it.\r\n *\r\n * HARDENED PORT on two counts (ADR-014):\r\n * - `unZip` created its scratch space itself under the GLOBAL\r\n * `properties.paths.output`, so where the files landed depended on\r\n * configuration the caller could not see. Here `destDir` is a required\r\n * parameter and nothing else is ever touched.\r\n * - It also took the archive as a readable STREAM and wrote it to\r\n * `archive.zip` inside the target directory, leaving that file behind for the\r\n * caller to delete (`PlaygroundService.js:164` does exactly that). Here the\r\n * source is a path or a buffer, and any temporary copy is cleaned up.\r\n */\r\nimport fs from 'node:fs'\r\nimport os from 'node:os'\r\nimport path from 'node:path'\r\nimport extract from 'extract-zip'\r\nimport { InvalidArgumentError } from '../errors.js'\r\n\r\n/**\r\n * Extracts a zip archive.\r\n *\r\n * GitLab archives wrap everything in a single top-level directory named after\r\n * the project and commit, so the interesting content is one level down. `prefix`\r\n * selects it, reproducing the `srcPath` argument of `unZip`: the first top-level\r\n * directory whose name starts with `prefix`, falling back to the first one.\r\n *\r\n * @param params.source Path to a `.zip` file, or its bytes.\r\n * @param params.destDir Directory to extract into. Created if missing.\r\n * @param params.prefix Optional: pick the top-level directory starting with it\r\n * and return that instead of `destDir`.\r\n * @returns The directory holding the extracted content.\r\n * @throws {InvalidArgumentError} when the arguments are malformed or `source`\r\n * does not exist.\r\n */\r\nexport const extractArchive = async ({\r\n source,\r\n destDir,\r\n prefix\r\n}: {\r\n source: string | Uint8Array\r\n destDir: string\r\n prefix?: string\r\n}): Promise<{ dir: string }> => {\r\n if (typeof destDir !== 'string' || destDir.trim() === '') {\r\n throw new InvalidArgumentError('\"destDir\" must be a non-empty path.')\r\n }\r\n if (prefix !== undefined && typeof prefix !== 'string') {\r\n throw new InvalidArgumentError('\"prefix\" must be a string when provided.')\r\n }\r\n\r\n const target = path.resolve(destDir)\r\n fs.mkdirSync(target, { recursive: true })\r\n\r\n // A buffer has to reach the disk for yauzl to read it; that copy is ours to\r\n // clean up, and it goes to the OS temp dir so it never pollutes `destDir`.\r\n let archivePath: string\r\n let scratchDir: string | null = null\r\n if (typeof source === 'string') {\r\n if (source.trim() === '') {\r\n throw new InvalidArgumentError('\"source\" must be a non-empty path.')\r\n }\r\n archivePath = path.resolve(source)\r\n if (!fs.existsSync(archivePath)) {\r\n throw new InvalidArgumentError(`Archive not found: ${archivePath}`)\r\n }\r\n } else if (source instanceof Uint8Array) {\r\n scratchDir = fs.mkdtempSync(path.join(os.tmpdir(), 'linea-core-archive-'))\r\n archivePath = path.join(scratchDir, 'archive.zip')\r\n fs.writeFileSync(archivePath, source)\r\n } else {\r\n throw new InvalidArgumentError('\"source\" must be a path or a Uint8Array.')\r\n }\r\n\r\n try {\r\n await extract(archivePath, { dir: target })\r\n } finally {\r\n if (scratchDir !== null) fs.rmSync(scratchDir, { recursive: true, force: true })\r\n }\r\n\r\n if (prefix === undefined) return { dir: target }\r\n\r\n const directories = fs\r\n .readdirSync(target, { withFileTypes: true })\r\n .filter((entry) => entry.isDirectory())\r\n .map((entry) => entry.name)\r\n .sort()\r\n\r\n // Same resolution as unZip: first match on the prefix, else the first\r\n // directory, else the extraction root itself.\r\n const chosen = directories.find((name) => name.startsWith(prefix)) ?? directories[0]\r\n return { dir: chosen === undefined ? target : path.join(target, chosen) }\r\n}\r\n"]}
1
+ {"version":3,"file":"archive.js","sourceRoot":"","sources":["../../src/fs/archive.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,OAAO,MAAM,aAAa,CAAA;AACjC,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AAEnD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,EAAE,EACnC,MAAM,EACN,OAAO,EACP,MAAM,EAKP,EAA4B,EAAE;IAC7B,IAAI,OAAO,O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ACN,MAAM,IAAI,oBAAoB,CAAC,0CAA0C,CAAC,CAAA;IAC5E,CAAC;IAED,IAAI,CAAC;QACH,MAAM,OAAO,CAAC,WAAW,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,CAAA;IAC7C,CAAC;YAAS,CAAC;QACT,IAAI,UAAU,KAAK,IAAI;YAAE,EAAE,CAAC,MAAM,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;IAClF,CAAC;IAED,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,CAAA;IAEhD,MAAM,WAAW,GAAG,EAAE;SACnB,WAAW,CAAC,MAAM,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC;SAC5C,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;SACtC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC;SAC1B,IAAI,EAAE,CAAA;IAET,sEAAsE;IACtE,8CAA8C;IAC9C,MAAM,MAAM,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC,CAAA;IACpF,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAA;AAC3E,CAAC,CAAA","sourcesContent":["/**\n * Archive extraction.\n *\n * Migrated from `linea/server/src/model/services/utils.js:unZip` (~46-80), which\n * downloads a repository archive from GitLab and unpacks it.\n *\n * HARDENED PORT on two counts (ADR-014):\n * - `unZip` created its scratch space itself under the GLOBAL\n * `properties.paths.output`, so where the files landed depended on\n * configuration the caller could not see. Here `destDir` is a required\n * parameter and nothing else is ever touched.\n * - It also took the archive as a readable STREAM and wrote it to\n * `archive.zip` inside the target directory, leaving that file behind for the\n * caller to delete (`PlaygroundService.js:164` does exactly that). Here the\n * source is a path or a buffer, and any temporary copy is cleaned up.\n */\nimport fs from 'node:fs'\nimport os from 'node:os'\nimport path from 'node:path'\nimport extract from 'extract-zip'\nimport { InvalidArgumentError } from '../errors.js'\n\n/**\n * Extracts a zip archive.\n *\n * GitLab archives wrap everything in a single top-level directory named after\n * the project and commit, so the interesting content is one level down. `prefix`\n * selects it, reproducing the `srcPath` argument of `unZip`: the first top-level\n * directory whose name starts with `prefix`, falling back to the first one.\n *\n * @param params.source Path to a `.zip` file, or its bytes.\n * @param params.destDir Directory to extract into. Created if missing.\n * @param params.prefix Optional: pick the top-level directory starting with it\n * and return that instead of `destDir`.\n * @returns The directory holding the extracted content.\n * @throws {InvalidArgumentError} when the arguments are malformed or `source`\n * does not exist.\n */\nexport const extractArchive = async ({\n source,\n destDir,\n prefix\n}: {\n source: string | Uint8Array\n destDir: string\n prefix?: string\n}): Promise<{ dir: string }> => {\n if (typeof destDir !== 'string' || destDir.trim() === '') {\n throw new InvalidArgumentError('\"destDir\" must be a non-empty path.')\n }\n if (prefix !== undefined && typeof prefix !== 'string') {\n throw new InvalidArgumentError('\"prefix\" must be a string when provided.')\n }\n\n const target = path.resolve(destDir)\n fs.mkdirSync(target, { recursive: true })\n\n // A buffer has to reach the disk for yauzl to read it; that copy is ours to\n // clean up, and it goes to the OS temp dir so it never pollutes `destDir`.\n let archivePath: string\n let scratchDir: string | null = null\n if (typeof source === 'string') {\n if (source.trim() === '') {\n throw new InvalidArgumentError('\"source\" must be a non-empty path.')\n }\n archivePath = path.resolve(source)\n if (!fs.existsSync(archivePath)) {\n throw new InvalidArgumentError(`Archive not found: ${archivePath}`)\n }\n } else if (source instanceof Uint8Array) {\n scratchDir = fs.mkdtempSync(path.join(os.tmpdir(), 'linea-core-archive-'))\n archivePath = path.join(scratchDir, 'archive.zip')\n fs.writeFileSync(archivePath, source)\n } else {\n throw new InvalidArgumentError('\"source\" must be a path or a Uint8Array.')\n }\n\n try {\n await extract(archivePath, { dir: target })\n } finally {\n if (scratchDir !== null) fs.rmSync(scratchDir, { recursive: true, force: true })\n }\n\n if (prefix === undefined) return { dir: target }\n\n const directories = fs\n .readdirSync(target, { withFileTypes: true })\n .filter((entry) => entry.isDirectory())\n .map((entry) => entry.name)\n .sort()\n\n // Same resolution as unZip: first match on the prefix, else the first\n // directory, else the extraction root itself.\n const chosen = directories.find((name) => name.startsWith(prefix)) ?? directories[0]\n return { dir: chosen === undefined ? target : path.join(target, chosen) }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"diff.js","sourceRoot":"","sources":["../../src/fs/diff.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,MAAM,MAAM,aAAa,CAAA;AAChC,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AAqBnD;;;;;;GAMG;AACH,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,WAAW,CAAC,CAAC,CAAA;AAE5C;;;;;;;;;;;;;;GAcG;AACH,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAC;IAChC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO;IAClF,OAAO;IACP,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAC5E,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IACzC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,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G,CAAC,CAAC,CAAA;QAC1D,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,CAAC;YACtC,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAA;QACxD,CAAC;IACH,CAAC;IAED,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAA;IACpC,KAAK,MAAM,QAAQ,IAAI,QAAQ,EAAE,CAAC;QAChC,IAAI,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC;YAAE,SAAQ;QACtC,IAAI,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;YAAE,SAAQ;QAC9D,OAAO,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,CAAA;IACzD,CAAC;IAED,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AACrG,CAAC,CAAA","sourcesContent":["/**\r\n * Directory comparison expressed as file changes.\r\n *\r\n * Migrated from `linea/server/src/model/services/utils.js` (~86-128):\r\n * `isFileToDelete`, `isFileToCreate`, `isFileToUpdate`, `generateAction` and\r\n * `generateActions`.\r\n *\r\n * Behaviour is preserved exactly; the IMPLEMENTATION is rebuilt (see below).\r\n */\r\nimport crypto from 'node:crypto'\r\nimport fs from 'node:fs'\r\nimport path from 'node:path'\r\nimport { InvalidArgumentError } from '../errors.js'\r\n\r\n/**\r\n * A single file change between two directory trees.\r\n *\r\n * NEUTRAL FILE-CHANGE FORMAT. The field names (`action`, `file_path`,\r\n * `content`, `encoding`) are GitLab's commit-action vocabulary, kept on purpose\r\n * so linea-server can hand the array straight to `gitlabSession.commit` with no\r\n * adapter in between. linea-core itself neither knows nor cares about GitLab\r\n * (ADR-003) — this is a data shape, not a dependency.\r\n */\r\nexport interface FileChange {\r\n readonly action: 'create' | 'update' | 'delete'\r\n /** Path relative to the compared directory, ALWAYS POSIX (`/`). */\r\n readonly file_path: string\r\n /** Absent for `delete`. */\r\n readonly content?: string\r\n /** Absent for `delete`. */\r\n readonly encoding?: 'text' | 'base64'\r\n}\r\n\r\n/**\r\n * Files never reported as deleted.\r\n *\r\n * Verbatim from `isFileToDelete`, which excludes `README.md`: a generated\r\n * product's README is written by hand and must survive a regeneration that no\r\n * longer produces one.\r\n */\r\nconst NEVER_DELETED = new Set(['README.md'])\r\n\r\n/**\r\n * Extensions treated as binary.\r\n *\r\n * The monolith delegates to the `is-binary-path` package. Reproduced here as an\r\n * explicit list to avoid a dependency whose only job is a lookup table, and\r\n * because being explicit about what ends up base64-encoded is worth more than\r\n * exhaustiveness. Content sniffing is deliberately avoided: it would make the\r\n * encoding of a file depend on its bytes rather than its name, so the same file\r\n * could change encoding between two runs.\r\n *\r\n * When in doubt, ADD the extension. The two mistakes are not symmetric: a false\r\n * positive only base64-encodes a text file that did not need it, while a false\r\n * negative reads binary content with `utf-8`, turns every invalid sequence into\r\n * U+FFFD and commits a silently corrupted file to GitLab — no error, no warning.\r\n */\r\nconst BINARY_EXTENSIONS = new Set([\r\n '.png', '.jpg', '.jpeg', '.gif', '.bmp', '.ico', '.webp', '.tif', '.tiff', '.avif',\r\n '.svgz',\r\n '.pdf', '.zip', '.gz', '.tar', '.tgz', '.bz2', '.7z', '.rar', '.jar', '.war',\r\n '.woff', '.woff2', '.ttf', '.otf', '.eot',\r\n '.mp3', '.mp4', '.avi', '.mov', '.webm', '.ogg', '.wav', '.flac',\r\n '.so', '.dll', '.dylib', '.exe', '.class', '.pyc', '.wasm', '.node',\r\n '.doc', '.docx', '.xls', '.xlsx', '.ppt', '.pptx', '.odt', '.ods',\r\n '.db', '.sqlite', '.keystore', '.jks', '.p12', '.pfx',\r\n '.bin', '.dat'\r\n])\r\n\r\nconst isBinaryPath = (filePath: string): boolean =>\r\n BINARY_EXTENSIONS.has(path.extname(filePath).toLowerCase())\r\n\r\n/**\r\n * Repository-relative POSIX path of `filePath` inside `baseDir`.\r\n *\r\n * HARDENED PORT. `generateAction` derived this by splitting the absolute path on\r\n * the literal `` `tmp${sep}${uuid}${sep}new` `` and keeping the tail — coupled to\r\n * `properties.paths.output`, to the uuid-named temp layout, and silently wrong\r\n * if any of that changed.\r\n *\r\n * It also had a LATENT BUG on Windows: `path.join` produces `\\` separators, so\r\n * `file_path` would come out as `src\\main\\App.java`, which the GitLab API\r\n * rejects. The monolith never hit it because it only ever ran on Linux. Closed\r\n * here by normalising to POSIX unconditionally.\r\n */\r\nconst toRepositoryPath = (baseDir: string, filePath: string): string =>\r\n path.relative(baseDir, filePath).split(path.sep).join('/')\r\n\r\n/** Streaming MD5 of a file. Replaces `md5File.sync` from the monolith. */\r\nconst md5 = (filePath: string): string => {\r\n const hash = crypto.createHash('md5')\r\n hash.update(fs.readFileSync(filePath))\r\n return hash.digest('hex')\r\n}\r\n\r\n/** Same bytes on both sides? Compared by digest, as the monolith does. */\r\nconst hasSameContent = (a: string, b: string): boolean => md5(a) === md5(b)\r\n\r\nconst readAsChange = (\r\n action: 'create' | 'update',\r\n baseDir: string,\r\n absolutePath: string\r\n): FileChange => {\r\n const binary = isBinaryPath(absolutePath)\r\n return {\r\n action,\r\n file_path: toRepositoryPath(baseDir, absolutePath),\r\n content: fs.readFileSync(absolutePath, binary ? 'base64' : 'utf-8'),\r\n encoding: binary ? 'base64' : 'text'\r\n }\r\n}\r\n\r\n/** Relative POSIX paths of every file under `dir`, recursively. */\r\nconst listFiles = (dir: string): string[] => {\r\n const found: string[] = []\r\n const walk = (current: string, prefix: string): void => {\r\n let entries: fs.Dirent[]\r\n try {\r\n entries = fs.readdirSync(current, { withFileTypes: true })\r\n } catch {\r\n return\r\n }\r\n for (const entry of entries) {\r\n const relative = prefix === '' ? entry.name : `${prefix}/${entry.name}`\r\n if (entry.isDirectory()) {\r\n walk(path.join(current, entry.name), relative)\r\n } else if (entry.isFile()) {\r\n found.push(relative)\r\n }\r\n }\r\n }\r\n walk(dir, '')\r\n return found.sort()\r\n}\r\n\r\nconst assertDir = (value: unknown, parameter: string): string => {\r\n if (typeof value !== 'string' || value.trim() === '') {\r\n throw new InvalidArgumentError(`\"${parameter}\" must be a non-empty path.`)\r\n }\r\n return path.resolve(value)\r\n}\r\n\r\n/**\r\n * Compares two directory trees and reports the changes needed to turn the old\r\n * one into the new one.\r\n *\r\n * Preserves the monolith's three rules exactly:\r\n * - present only in `oldDir` -> `delete`, EXCEPT `README.md`, never deleted.\r\n * - present only in `newDir` -> `create`.\r\n * - present in both with different bytes -> `update`.\r\n * - present in both with the same bytes -> nothing.\r\n *\r\n * Binary files are read as base64 with `encoding: 'base64'`; text as UTF-8 with\r\n * `encoding: 'text'`.\r\n *\r\n * @param params.oldDir Directory with the previous state.\r\n * @param params.newDir Directory with the desired state.\r\n * @returns The changes, sorted by `file_path` so the result is deterministic.\r\n * @throws {InvalidArgumentError} when either path is not a non-empty string.\r\n */\r\nexport const diffDirectories = ({\r\n oldDir,\r\n newDir\r\n}: {\r\n oldDir: string\r\n newDir: string\r\n}): FileChange[] => {\r\n const oldRoot = assertDir(oldDir, 'oldDir')\r\n const newRoot = assertDir(newDir, 'newDir')\r\n\r\n const oldFiles = new Set(listFiles(oldRoot))\r\n const newFiles = listFiles(newRoot)\r\n const changes: FileChange[] = []\r\n\r\n for (const relative of newFiles) {\r\n const newPath = path.join(newRoot, ...relative.split('/'))\r\n if (!oldFiles.has(relative)) {\r\n changes.push(readAsChange('create', newRoot, newPath))\r\n continue\r\n }\r\n const oldPath = path.join(oldRoot, ...relative.split('/'))\r\n if (!hasSameContent(oldPath, newPath)) {\r\n changes.push(readAsChange('update', newRoot, newPath))\r\n }\r\n }\r\n\r\n const newFileSet = new Set(newFiles)\r\n for (const relative of oldFiles) {\r\n if (newFileSet.has(relative)) continue\r\n if (NEVER_DELETED.has(path.posix.basename(relative))) continue\r\n changes.push({ action: 'delete', file_path: relative })\r\n }\r\n\r\n return changes.sort((a, b) => (a.file_path < b.file_path ? -1 : a.file_path > b.file_path ? 1 : 0))\r\n}\r\n"]}
1
+ {"version":3,"file":"diff.js","sourceRoot":"","sources":["../../src/fs/diff.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,MAAM,MAAM,aAAa,CAAA;AAChC,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AAqBnD;;;;;;GAMG;AACH,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,WAAW,CAAC,CAAC,CAAA;AAE5C;;;;;;;;;;;;;;GAcG;AACH,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAC;IAChC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO;IAClF,OAAO;IACP,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAC5E,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IACzC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO;IAChE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO;IACnE,MAAM,E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,OAAO,EAAE,OAAO,CAAC,CAAC,CAAA;QACxD,CAAC;IACH,CAAC;IAED,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAA;IACpC,KAAK,MAAM,QAAQ,IAAI,QAAQ,EAAE,CAAC;QAChC,IAAI,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC;YAAE,SAAQ;QACtC,IAAI,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;YAAE,SAAQ;QAC9D,OAAO,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,CAAA;IACzD,CAAC;IAED,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AACrG,CAAC,CAAA","sourcesContent":["/**\n * Directory comparison expressed as file changes.\n *\n * Migrated from `linea/server/src/model/services/utils.js` (~86-128):\n * `isFileToDelete`, `isFileToCreate`, `isFileToUpdate`, `generateAction` and\n * `generateActions`.\n *\n * Behaviour is preserved exactly; the IMPLEMENTATION is rebuilt (see below).\n */\nimport crypto from 'node:crypto'\nimport fs from 'node:fs'\nimport path from 'node:path'\nimport { InvalidArgumentError } from '../errors.js'\n\n/**\n * A single file change between two directory trees.\n *\n * NEUTRAL FILE-CHANGE FORMAT. The field names (`action`, `file_path`,\n * `content`, `encoding`) are GitLab's commit-action vocabulary, kept on purpose\n * so linea-server can hand the array straight to `gitlabSession.commit` with no\n * adapter in between. linea-core itself neither knows nor cares about GitLab\n * (ADR-003) — this is a data shape, not a dependency.\n */\nexport interface FileChange {\n readonly action: 'create' | 'update' | 'delete'\n /** Path relative to the compared directory, ALWAYS POSIX (`/`). */\n readonly file_path: string\n /** Absent for `delete`. */\n readonly content?: string\n /** Absent for `delete`. */\n readonly encoding?: 'text' | 'base64'\n}\n\n/**\n * Files never reported as deleted.\n *\n * Verbatim from `isFileToDelete`, which excludes `README.md`: a generated\n * product's README is written by hand and must survive a regeneration that no\n * longer produces one.\n */\nconst NEVER_DELETED = new Set(['README.md'])\n\n/**\n * Extensions treated as binary.\n *\n * The monolith delegates to the `is-binary-path` package. Reproduced here as an\n * explicit list to avoid a dependency whose only job is a lookup table, and\n * because being explicit about what ends up base64-encoded is worth more than\n * exhaustiveness. Content sniffing is deliberately avoided: it would make the\n * encoding of a file depend on its bytes rather than its name, so the same file\n * could change encoding between two runs.\n *\n * When in doubt, ADD the extension. The two mistakes are not symmetric: a false\n * positive only base64-encodes a text file that did not need it, while a false\n * negative reads binary content with `utf-8`, turns every invalid sequence into\n * U+FFFD and commits a silently corrupted file to GitLab — no error, no warning.\n */\nconst BINARY_EXTENSIONS = new Set([\n '.png', '.jpg', '.jpeg', '.gif', '.bmp', '.ico', '.webp', '.tif', '.tiff', '.avif',\n '.svgz',\n '.pdf', '.zip', '.gz', '.tar', '.tgz', '.bz2', '.7z', '.rar', '.jar', '.war',\n '.woff', '.woff2', '.ttf', '.otf', '.eot',\n '.mp3', '.mp4', '.avi', '.mov', '.webm', '.ogg', '.wav', '.flac',\n '.so', '.dll', '.dylib', '.exe', '.class', '.pyc', '.wasm', '.node',\n '.doc', '.docx', '.xls', '.xlsx', '.ppt', '.pptx', '.odt', '.ods',\n '.db', '.sqlite', '.keystore', '.jks', '.p12', '.pfx',\n '.bin', '.dat'\n])\n\nconst isBinaryPath = (filePath: string): boolean =>\n BINARY_EXTENSIONS.has(path.extname(filePath).toLowerCase())\n\n/**\n * Repository-relative POSIX path of `filePath` inside `baseDir`.\n *\n * HARDENED PORT. `generateAction` derived this by splitting the absolute path on\n * the literal `` `tmp${sep}${uuid}${sep}new` `` and keeping the tail — coupled to\n * `properties.paths.output`, to the uuid-named temp layout, and silently wrong\n * if any of that changed.\n *\n * It also had a LATENT BUG on Windows: `path.join` produces `\\` separators, so\n * `file_path` would come out as `src\\main\\App.java`, which the GitLab API\n * rejects. The monolith never hit it because it only ever ran on Linux. Closed\n * here by normalising to POSIX unconditionally.\n */\nconst toRepositoryPath = (baseDir: string, filePath: string): string =>\n path.relative(baseDir, filePath).split(path.sep).join('/')\n\n/** Streaming MD5 of a file. Replaces `md5File.sync` from the monolith. */\nconst md5 = (filePath: string): string => {\n const hash = crypto.createHash('md5')\n hash.update(fs.readFileSync(filePath))\n return hash.digest('hex')\n}\n\n/** Same bytes on both sides? Compared by digest, as the monolith does. */\nconst hasSameContent = (a: string, b: string): boolean => md5(a) === md5(b)\n\nconst readAsChange = (\n action: 'create' | 'update',\n baseDir: string,\n absolutePath: string\n): FileChange => {\n const binary = isBinaryPath(absolutePath)\n return {\n action,\n file_path: toRepositoryPath(baseDir, absolutePath),\n content: fs.readFileSync(absolutePath, binary ? 'base64' : 'utf-8'),\n encoding: binary ? 'base64' : 'text'\n }\n}\n\n/** Relative POSIX paths of every file under `dir`, recursively. */\nconst listFiles = (dir: string): string[] => {\n const found: string[] = []\n const walk = (current: string, prefix: 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 relative = prefix === '' ? entry.name : `${prefix}/${entry.name}`\n if (entry.isDirectory()) {\n walk(path.join(current, entry.name), relative)\n } else if (entry.isFile()) {\n found.push(relative)\n }\n }\n }\n walk(dir, '')\n return found.sort()\n}\n\nconst assertDir = (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 * Compares two directory trees and reports the changes needed to turn the old\n * one into the new one.\n *\n * Preserves the monolith's three rules exactly:\n * - present only in `oldDir` -> `delete`, EXCEPT `README.md`, never deleted.\n * - present only in `newDir` -> `create`.\n * - present in both with different bytes -> `update`.\n * - present in both with the same bytes -> nothing.\n *\n * Binary files are read as base64 with `encoding: 'base64'`; text as UTF-8 with\n * `encoding: 'text'`.\n *\n * @param params.oldDir Directory with the previous state.\n * @param params.newDir Directory with the desired state.\n * @returns The changes, sorted by `file_path` so the result is deterministic.\n * @throws {InvalidArgumentError} when either path is not a non-empty string.\n */\nexport const diffDirectories = ({\n oldDir,\n newDir\n}: {\n oldDir: string\n newDir: string\n}): FileChange[] => {\n const oldRoot = assertDir(oldDir, 'oldDir')\n const newRoot = assertDir(newDir, 'newDir')\n\n const oldFiles = new Set(listFiles(oldRoot))\n const newFiles = listFiles(newRoot)\n const changes: FileChange[] = []\n\n for (const relative of newFiles) {\n const newPath = path.join(newRoot, ...relative.split('/'))\n if (!oldFiles.has(relative)) {\n changes.push(readAsChange('create', newRoot, newPath))\n continue\n }\n const oldPath = path.join(oldRoot, ...relative.split('/'))\n if (!hasSameContent(oldPath, newPath)) {\n changes.push(readAsChange('update', newRoot, newPath))\n }\n }\n\n const newFileSet = new Set(newFiles)\n for (const relative of oldFiles) {\n if (newFileSet.has(relative)) continue\n if (NEVER_DELETED.has(path.posix.basename(relative))) continue\n changes.push({ action: 'delete', file_path: relative })\n }\n\n return changes.sort((a, b) => (a.file_path < b.file_path ? -1 : a.file_path > b.file_path ? 1 : 0))\n}\n"]}
@@ -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,EAAE,MAAM,cAAc,CAAA;AAEnD;;;;;;;;;GASG;AACH,MAAM,gBA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C;IACH,CAAC;IAED,OAAO,EAAE,SAAS,EAAE,CAAA;AACtB,CAAC,CAAA","sourcesContent":["/**\r\n * Source formatting with prettier.\r\n *\r\n * Migrated from `linea/server/src/model/services/utils.js:pretty` (~84):\r\n * `exec('prettier --ignore-unknown --write \"<path>/\"')`.\r\n *\r\n * HARDENED PORT. The original shells out, which linea-core cannot do:\r\n * - it needs a `prettier` binary on `PATH` in whatever process embeds the\r\n * library, so the result depends on the host machine;\r\n * - spawning a child process is exactly what ADR-014 rules out, and it would\r\n * not work reliably under Bun;\r\n * - the path is interpolated into a shell command string.\r\n *\r\n * Uses prettier's Node API instead: same formatting, no child process, works\r\n * offline and under Bun. `--ignore-unknown` becomes an explicit \"skip files\r\n * prettier has no parser for\".\r\n */\r\nimport fs from 'node:fs'\r\nimport path from 'node:path'\r\nimport * as prettier from 'prettier'\r\nimport { InvalidArgumentError } from '../errors.js'\r\n\r\n/**\r\n * Directories never worth walking into.\r\n *\r\n * DIVERGENCE from the monolith. `prettier --ignore-unknown --write \"<path>/\"`\r\n * skips only `node_modules` by default, so the CLI would descend into `.git`,\r\n * `dist`, `build`, `target` and `coverage`. Unreachable in practice — the\r\n * directory being formatted is a freshly derived product, and the platform\r\n * `config.json` already excludes `build`/`target`/`bin` from derivation — but\r\n * recorded here because every other divergence in this file is.\r\n */\r\nconst SKIP_DIRECTORIES = new Set(['node_modules', '.git', 'dist', 'build', 'target', 'coverage'])\r\n\r\n/** Every file under `dir`, recursively, as absolute paths. */\r\nconst listFiles = (dir: string): string[] => {\r\n const found: string[] = []\r\n const walk = (current: string): void => {\r\n let entries: fs.Dirent[]\r\n try {\r\n entries = fs.readdirSync(current, { withFileTypes: true })\r\n } catch {\r\n return\r\n }\r\n for (const entry of entries) {\r\n const absolute = path.join(current, entry.name)\r\n if (entry.isDirectory()) {\r\n if (SKIP_DIRECTORIES.has(entry.name)) continue\r\n walk(absolute)\r\n } else if (entry.isFile()) {\r\n found.push(absolute)\r\n }\r\n }\r\n }\r\n walk(dir)\r\n return found.sort()\r\n}\r\n\r\n/**\r\n * Formats every file prettier understands under a directory, in place.\r\n *\r\n * Files with no inferable parser are skipped, which is what `--ignore-unknown`\r\n * does. Files that prettier cannot parse (a syntax error in generated code, say)\r\n * are skipped too rather than aborting the whole run: formatting is cosmetic and\r\n * must never fail a generation.\r\n *\r\n * Idempotent by construction, since prettier output is a fixed point. A file is\r\n * only rewritten when its content actually changes, so mtimes stay put and the\r\n * directory diff does not gain spurious entries.\r\n *\r\n * @param params.dir Directory to format, in place.\r\n * @returns How many files were rewritten.\r\n * @throws {InvalidArgumentError} when `dir` is not a non-empty existing directory.\r\n */\r\nexport const formatDirectory = async ({ dir }: { dir: string }): Promise<{ formatted: number }> => {\r\n if (typeof dir !== 'string' || dir.trim() === '') {\r\n throw new InvalidArgumentError('\"dir\" must be a non-empty path.')\r\n }\r\n const root = path.resolve(dir)\r\n if (!fs.existsSync(root) || !fs.statSync(root).isDirectory()) {\r\n throw new InvalidArgumentError(`Not a directory: ${root}`)\r\n }\r\n\r\n let formatted = 0\r\n for (const filePath of listFiles(root)) {\r\n try {\r\n const { inferredParser } = await prettier.getFileInfo(filePath, { resolveConfig: false })\r\n // Equivalent of `--ignore-unknown`: no parser, no formatting.\r\n if (inferredParser === null) continue\r\n\r\n // Resolved PER FILE, like the prettier CLI, so a nested `.prettierrc`\r\n // applies to its own subtree. Resolving once from the root would also miss\r\n // a config living IN the root: `resolveConfig` searches upward from\r\n // `path.dirname(target)`, which for a directory is its parent.\r\n // prettier caches these lookups internally, so this stays cheap.\r\n const options = await prettier.resolveConfig(filePath)\r\n const original = fs.readFileSync(filePath, 'utf8')\r\n const output = await prettier.format(original, { ...options, filepath: filePath })\r\n if (output !== original) {\r\n fs.writeFileSync(filePath, output, 'utf8')\r\n formatted += 1\r\n }\r\n } catch {\r\n // One file failing — unparseable, unreadable, vanished mid-walk — must\r\n // never abort the run. Formatting is cosmetic; leave it as it was.\r\n continue\r\n }\r\n }\r\n\r\n return { form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C,QAAQ,EAAE,EAAE,GAAG,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAA;YAClF,IAAI,MAAM,KAAK,QAAQ,EAAE,CAAC;gBACxB,EAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;gBAC1C,SAAS,IAAI,CAAC,CAAA;YAChB,CAAC;QACH,CAAC;QAAC,MAAM,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 +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,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QACrD,MAAM,IAAI,oBAAoB,CAAC,IAAI,SAAS,6BAA6B,CAAC,CAAA;IAC5E,CAAC;IACD,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;AAC5B,CAAC,CAAA;AAED;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,EAAE,OAAO,EAAuB,EAAa,EAAE;IAC9E,MAAM,IAAI,GAAG,UAAU,CAAC,OAAO,EAAE,SAAS,CAAC,CAAA;IAC3C,OAAO;QACL,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,cAAc,CAAC,IAAI,CAAC;QAC9C,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,cAAc,CAAC,IAAI,CAAC;QAC1C,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,cAAc,CAAC,KAAK,CAAC;QAC5C,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,cAAc,CAAC,MAAM,CAAC;QAC9C,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,cAAc,CA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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":["/**\r\n * Filesystem helpers over a line working directory.\r\n *\r\n * ADR-009: linea-core owns no database. It operates on directories the caller\r\n * hands it (a clone or an unzipped export of a line repository) and returns\r\n * explicit results. Every function takes its working directory as a parameter;\r\n * nothing is resolved from `process.cwd()` or the environment (ADR-014).\r\n *\r\n * Like the rest of the public API, every function takes a single named-parameter\r\n * object — even the single-argument ones. Consistency of the contract consumed\r\n * by linea-server and linea-cli beats brevity.\r\n */\r\nimport fs from 'node:fs'\r\nimport path from 'node:path'\r\nimport { PLATFORM_PATHS, PRODUCTS_INDEX_PATH } from '../constants.js'\r\nimport { InvalidArgumentError } from '../errors.js'\r\n\r\n/** Absolute paths of the well-known files of a line working directory. */\r\nexport interface LinePaths {\r\n /** The `src/platform` directory. */\r\n readonly platform: string\r\n /** Annotated source consumed by the derivation engine. */\r\n readonly code: string\r\n /** UVL feature model. The XML variant lives at `PLATFORM_PATHS.modelXml`. */\r\n readonly model: string\r\n /** Engine configuration (`config.json`). */\r\n readonly config: string\r\n /** Template helper functions (`extra.js`). */\r\n readonly extraJs: string\r\n /** Spec transformation function (`transformation.js`). */\r\n readonly transformation: string\r\n /** Product index at the repository root (ADR-011). */\r\n readonly productsIndex: string\r\n}\r\n\r\nconst assertPath = (value: unknown, parameter: string): string => {\r\n if (typeof value !== 'string' || value.trim() === '') {\r\n throw new InvalidArgumentError(`\"${parameter}\" must be a non-empty path.`)\r\n }\r\n return path.resolve(value)\r\n}\r\n\r\n/**\r\n * Resolves the well-known paths of a line working directory.\r\n *\r\n * The layout mirrors `linea/server/src/resources/properties.yml`\r\n * (`paths.platform.*`), which the monolith read through `properties.paths` in\r\n * `services/utils.js:engine()`. Purely a path computation: nothing is read and\r\n * nothing is required to exist.\r\n *\r\n * @param params.lineDir Root of the line working directory (its repository root).\r\n * @returns Absolute paths for every well-known file.\r\n * @throws {InvalidArgumentError} if `lineDir` is not a non-empty string.\r\n */\r\nexport const resolveLinePaths = ({ lineDir }: { lineDir: string }): LinePaths => {\r\n const root = assertPath(lineDir, 'lineDir')\r\n return {\r\n platform: path.join(root, PLATFORM_PATHS.root),\r\n code: path.join(root, PLATFORM_PATHS.code),\r\n model: path.join(root, PLATFORM_PATHS.model),\r\n config: path.join(root, PLATFORM_PATHS.config),\r\n extraJs: path.join(root, PLATFORM_PATHS.extraJs),\r\n transformation: path.join(root, PLATFORM_PATHS.transformation),\r\n productsIndex: path.join(root, PRODUCTS_INDEX_PATH)\r\n }\r\n}\r\n\r\n/**\r\n * Creates a directory and its parents if they do not exist. Idempotent.\r\n *\r\n * @param params.dirPath Directory to create.\r\n * @returns The absolute path of the directory.\r\n * @throws {InvalidArgumentError} if `dirPath` is not a non-empty string.\r\n */\r\nexport const ensureDir = ({ dirPath }: { dirPath: string }): string => {\r\n const absolute = assertPath(dirPath, 'dirPath')\r\n fs.mkdirSync(absolute, { recursive: true })\r\n return absolute\r\n}\r\n\r\n/**\r\n * Reads a UTF-8 text file.\r\n *\r\n * Unlike the monolith there is no base64 step: models and platform files are\r\n * plain text on disk. Decoding what the GitLab API returns is linea-server's job.\r\n *\r\n * @param params.filePath File to read.\r\n * @returns The file contents.\r\n * @throws {InvalidArgumentError} if `filePath` is not a non-empty string.\r\n */\r\nexport const readTextFile = ({ filePath }: { filePath: string }): string =>\r\n fs.readFileSync(assertPath(filePath, 'filePath'), 'utf8')\r\n\r\n/**\r\n * Writes a UTF-8 text file, creating parent directories as needed.\r\n *\r\n * @param params.filePath File to write.\r\n * @param params.content Contents to write verbatim (no trailing newline is added).\r\n * @returns The absolute path written.\r\n * @throws {InvalidArgumentError} if the arguments are not strings.\r\n */\r\nexport const writeTextFile = ({\r\n filePath,\r\n content\r\n}: {\r\n filePath: string\r\n content: string\r\n}): string => {\r\n const absolute = assertPath(filePath, 'filePath')\r\n if (typeof content !== 'string') {\r\n throw new InvalidArgumentError('\"content\" must be a string.')\r\n }\r\n ensureDir({ dirPath: path.dirname(absolute) })\r\n fs.writeFileSync(absolute, content, 'utf8')\r\n return absolute\r\n}\r\n\r\n/**\r\n * Whether `filePath` exists and is a regular file.\r\n *\r\n * @param params.filePath Path to probe.\r\n * @returns `true` only for an existing regular file.\r\n * @throws {InvalidArgumentError} if `filePath` is not a non-empty string.\r\n */\r\nexport const fileExists = ({ filePath }: { filePath: string }): boolean => {\r\n const absolute = assertPath(filePath, 'filePath')\r\n try {\r\n return fs.statSync(absolute).isFile()\r\n } catch {\r\n return false\r\n }\r\n}\r\n"]}
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,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QACrD,MAAM,IAAI,oBAAoB,CAAC,IAAI,SAAS,6BAA6B,CAAC,CAAA;IAC5E,CAAC;IACD,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;AAC5B,CAAC,CAAA;AAED;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,EAAE,OAAO,EAAuB,EAAa,EAAE;IAC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AAM,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"]}
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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FAAgF;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":["/**\r\n * linea-core — offline engine for Software Product Lines.\r\n *\r\n * A library of stateless JavaScript functions (ADR-014): every function receives\r\n * what it needs as parameters and returns explicit results. No internal state,\r\n * no singletons, no dependency injection, no global configuration, no database\r\n * and no network (ADR-002). Side effects are limited to the directories the\r\n * caller points at (ADR-009).\r\n *\r\n * This is the ONLY public entry point. Everything under `src/` other than this\r\n * file is private and may change without notice — the `exports` map exposes a\r\n * single entry on purpose.\r\n */\r\n\r\n// ── Constants ────────────────────────────────────────────────────────────────\r\nexport {\r\n PLATFORM_PATHS,\r\n PRODUCTS_INDEX_PATH,\r\n NAME_PATTERN,\r\n VERSION_PATTERN,\r\n DEFAULT_LANGUAGES,\r\n DEFAULT_SRID,\r\n FEATURE_MODEL_TYPES,\r\n ANALYSIS_THRESHOLDS,\r\n isFeatureModelType\r\n} from './constants.js'\r\nexport type { FeatureModelType } from './constants.js'\r\n\r\n// ── Errors ───────────────────────────────────────────────────────────────────\r\nexport {\r\n LineaCoreError,\r\n InvalidArgumentError,\r\n UvlParseError,\r\n UnsupportedConversionError,\r\n FeatureSelectionInvalidError,\r\n LinePlatformNotFoundError,\r\n InvalidProductSpecError,\r\n ProductsIndexError,\r\n AnalysisRuntimeError\r\n} from './errors.js'\r\nexport type { LineaCoreErrorCode } from './errors.js'\r\n\r\n// ── Feature models ───────────────────────────────────────────────────────────\r\nexport { parseFeatureModel } from './feature-model/parse.js'\r\nexport type { FeatureModelValue } from './feature-model/parse.js'\r\nexport { convertFeatureModel } from './feature-model/convert.js'\r\nexport { detectFeatureModelType, readFeatureModel, writeFeatureModel } from './feature-model/io.js'\r\nexport type { FeatureModelLocation } from './feature-model/io.js'\r\nexport { normalizeUvl, estimateFeatureCount, emptyFeatureModelUvl } from './feature-model/text.js'\r\nexport { extractFeatureNames, computeMandatoryFeatures } from './feature-model/inspect.js'\r\nexport type { MandatoryFeaturesResult } from './feature-model/inspect.js'\r\n\r\n// ── Feature selection ────────────────────────────────────────────────────────\r\nexport {\r\n normalizeFeatureSelection,\r\n validateFeatureSelection,\r\n assertFeatureSelection,\r\n validateModelAgainstSelections\r\n} from './selection/selection.js'\r\nexport type {\r\n FeatureSelectionInput,\r\n SelectionBearingSpec,\r\n FeatureSelectionVerdict,\r\n NamedSelection,\r\n BrokenSelection,\r\n ModelAgainstSelectionsVerdict\r\n} from './selection/selection.js'\r\n\r\n// ── Product specs ────────────────────────────────────────────────────────────\r\nexport { validateProductSpec, assertProductSpec, normalizeProductSpec } from './product/spec.js'\r\nexport type {\r\n ProductSpec,\r\n ProductBasicData,\r\n ProductSpecError,\r\n ProductSpecErrorCode,\r\n ProductSpecValidation\r\n} from './product/spec.js'\r\nexport { incrementVersion } from './product/version.js'\r\nexport { buildEngineSpec } from './product/engine-spec.js'\r\nexport type { EngineSpec } from './product/engine-spec.js'\r\n\r\n// ── Products index (ADR-011) ─────────────────────────────────────────────────\r\nexport {\r\n emptyProductsIndex,\r\n parseProductsIndex,\r\n serializeProductsIndex,\r\n validateProductsIndex,\r\n addProductToIndex,\r\n renameProductInIndex,\r\n removeProductFromIndex,\r\n readProductsIndex,\r\n writeProductsIndex,\r\n reconcileProductsIndex\r\n} from './products-index/products-index.js'\r\nexport type {\r\n ProductsIndex,\r\n ProductsIndexEntry,\r\n ProductsIndexProblem,\r\n ProductsIndexProblemCode,\r\n ProductsIndexValidation,\r\n ProductsIndexReconciliation\r\n} from './products-index/products-index.js'\r\n\r\n// ── Line scaffold and platform files ─────────────────────────────────────────\r\nexport {\r\n buildLineScaffold,\r\n writeLineScaffold,\r\n DEFAULT_PLATFORM_CONFIG,\r\n DEFAULT_CODE_GITIGNORE\r\n} from './line/scaffold.js'\r\nexport type { LineScaffoldInput } from './line/scaffold.js'\r\nexport { buildExtraJs, buildTransformationJs, getPipelineFiles } from './line/platform-files.js'\r\nexport type { FileSpec, MetamodelName } from './line/platform-files.js'\r\n\r\n// ── Feature model analysis (ADR-008, ADR-021) ────────────────────────────────\r\nexport { createAnalysisRuntime, disposeAnalysisRuntime } from './analysis/runtime.js'\r\nexport type { AnalysisRuntime, AnalysisRuntimeOptions } from './analysis/runtime.js'\r\nexport {\r\n analyzeFeatureModel,\r\n analyzeFeatureModelBdd,\r\n analyzeMetric,\r\n ANALYSIS_METRICS\r\n} from './analysis/analyze.js'\r\nexport type {\r\n AnalysisMode,\r\n AnalysisMetric,\r\n FeatureModelAnalysis,\r\n FeatureModelBddAnalysis,\r\n MetricAnalysis\r\n} from './analysis/analyze.js'\r\n\r\n// ── Product derivation ───────────────────────────────────────────────────────\r\nexport { deriveProduct, deriveProductToZip } from './derivation/derive.js'\r\n\r\n// ── Archive, diff and formatting ─────────────────────────────────────────────\r\nexport { extractArchive } from './fs/archive.js'\r\nexport { diffDirectories } from './fs/diff.js'\r\nexport type { FileChange } from './fs/diff.js'\r\nexport { formatDirectory } from './fs/format.js'\r\n\r\n// ── Working directories ──────────────────────────────────────────────────────\r\nexport {\r\n resolveLinePaths,\r\n ensureDir,\r\n readTextFile,\r\n writeTextFile,\r\n fileExists\r\n} from './fs/workspace.js'\r\nexport type { LinePaths } from './fs/workspace.js'\r\n\r\n// ── Packaged assets ──────────────────────────────────────────────────────────\r\nexport { resolveAsset, assetsRoot } from './assets.js'\r\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,gFAAgF;AAChF,OAAO,EACL,cAA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jB,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 +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":["/**\r\n * INTERNAL type guards. Not exported from `src/index.ts`.\r\n */\r\n\r\n/** Narrows to a non-null, non-array object. */\r\nexport const isPlainObject = (value: unknown): value is Record<string, unknown> =>\r\n typeof value === 'object' && value !== null && !Array.isArray(value)\r\n\r\n/**\r\n * Array check that preserves the declared element type.\r\n *\r\n * `Array.isArray(x)` widens a `readonly T[]` to `any[]` in the narrowed branch\r\n * (TypeScript cannot express \"readonly array\" through its built-in guard), which\r\n * then makes every subsequent `.name`/`.features` access an unsafe `any` member\r\n * access. This guard narrows to `readonly unknown[]` instead, so intersecting it\r\n * with the declared parameter type keeps `readonly T[]` intact.\r\n */\r\nexport const isArray = (value: unknown): value is readonly unknown[] => Array.isArray(value)\r\n"]}
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 +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,cAAc,EAAE,wCAAwC,EAAE;IACzG,MAAM,EAAE,EAAE,KAAK,EAAE,4BAA4B,EAAE,cAAc,EAAE,qCAAqC,EAAE;CAC9F,CAAA;AAKV,MAAM,YAAY,GAAG,CAAC,GAAG,QAAkB,EAAU,EAAE,CACrD,EAAE,CAAC,YAAY,CAAC,YAAY,CAAC,EAAE,QAAQ,EAAE,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,CAAA;AAEzF,MAAM,YAAY,GAAG,CAAC,MAAe,EAAqB,EAAE;IAC1D,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,EAAE,CAAA;IACnC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,I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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":["/**\r\n * Platform files seeded into a brand new line.\r\n *\r\n * Migrated from:\r\n * - `linea/server/src/model/services/templates/PlatformFileFactory.js`\r\n * (`buildExtraJs`, `buildTransformationJs`)\r\n * - `linea/server/src/model/services/templates/PipelineFileFactory.js`\r\n * (`PIPELINE_FILES`)\r\n *\r\n * The templates under `src/line/templates/**` are byte-for-byte copies of\r\n * `linea/server/src/model/services/templates/**`. They are ASSETS, not\r\n * TypeScript: `scripts/copy-assets.mjs` mirrors them into `dist/` at build time\r\n * and `resolveAsset` locates them through `import.meta.url`.\r\n *\r\n * The monolith reads every template ONCE at module load into a module-level\r\n * `const`. That is module state, which ADR-014 rules out, so here each call\r\n * reads from disk. These are a handful of small files read only when a line is\r\n * created; if it ever mattered, the caller can cache.\r\n */\r\nimport fs from 'node:fs'\r\nimport { resolveAsset } from '../assets.js'\r\nimport { InvalidArgumentError } from '../errors.js'\r\nimport { isArray } from '../internal/guards.js'\r\n\r\n/**\r\n * A file to be written somewhere, described without deciding where.\r\n *\r\n * The pure half of the scaffold API returns these so linea-server can push them\r\n * to GitLab and linea-cli can write them to disk, from the same description.\r\n */\r\nexport interface FileSpec {\r\n /** Repository-relative path, always POSIX (`/`), never absolute. */\r\n readonly path: string\r\n /** File contents. */\r\n readonly content: string\r\n /** How `content` is encoded. Every seeded file is text today. */\r\n readonly encoding: 'text' | 'base64'\r\n}\r\n\r\n/** Metamodels that contribute extra template fragments. */\r\nconst METAMODEL_TEMPLATES = {\r\n UML: { extra: 'metamodels/dataModel/extra.js', transformation: 'metamodels/dataModel/transformation.js' },\r\n SENSOR: { extra: 'metamodels/sensor/extra.js', transformation: 'metamodels/sensor/transformation.js' }\r\n} as const\r\n\r\n/** A metamodel name recognised by the template factory. */\r\nexport type MetamodelName = keyof typeof METAMODEL_TEMPLATES\r\n\r\nconst readTemplate = (...segments: string[]): string =>\r\n fs.readFileSync(resolveAsset({ segments: ['line', 'templates', ...segments] }), 'utf8')\r\n\r\nconst assertModels = (models: unknown): readonly string[] => {\r\n if (models === undefined) return []\r\n if (!isArray(models) || models.some((model) => typeof model !== 'string')) {\r\n throw new InvalidArgumentError('\"models\" must be an array of strings.')\r\n }\r\n return models as readonly string[]\r\n}\r\n\r\n/**\r\n * Concatenates the core template with the fragment of each selected metamodel.\r\n *\r\n * Verbatim behaviour of `PlatformFileFactory.js:31-39`: the core template first,\r\n * then `'\\n' + fragment` for every model that has one, in the order given.\r\n * A model with no template — including an unknown name — is skipped silently.\r\n */\r\nconst buildFromTemplates = (\r\n models: readonly string[],\r\n core: string,\r\n kind: 'extra' | 'transformation'\r\n): string => {\r\n let content = readTemplate(core)\r\n for (const model of models) {\r\n const templates = METAMODEL_TEMPLATES[model as MetamodelName] as\r\n | (typeof METAMODEL_TEMPLATES)[MetamodelName]\r\n | undefined\r\n if (templates !== undefined) {\r\n content += '\\n' + readTemplate(templates[kind])\r\n }\r\n }\r\n return content\r\n}\r\n\r\n/**\r\n * Builds `src/platform/extra.js` for a line.\r\n *\r\n * WRITING YOUR OWN `extra.js`: do NOT use `//` line comments. The template\r\n * processor concatenates this file into the function it builds and then strips\r\n * every newline from it (`spl-js-engine/src/template-engine/processor.js:28`),\r\n * so a line comment swallows the rest of that function — including its final\r\n * `return`. Every annotated file then processes to nothing and, because the\r\n * engine skips empty output, the derivation produces ZERO files WITHOUT raising\r\n * an error. Use `/* ... *\\/` blocks. Neither the monolith's `core/extra.js` nor\r\n * its mock LPS uses line comments, for exactly this reason.\r\n *\r\n * @param params.models Metamodels chosen for the line, e.g. `['UML']`. Unknown\r\n * names are ignored, matching the monolith.\r\n * @returns The file contents: core template plus one fragment per known model.\r\n * @throws {InvalidArgumentError} when `models` is not an array of strings.\r\n */\r\nexport const buildExtraJs = ({ models }: { models?: readonly string[] }): string =>\r\n buildFromTemplates(assertModels(models), 'core/extra.js', 'extra')\r\n\r\n/**\r\n * Builds `src/platform/transformation.js` for a line.\r\n *\r\n * WRITING YOUR OWN `transformation.js`: the same `//` trap described on\r\n * {@link buildExtraJs} applies here — the processor strips every newline, so a\r\n * line comment silently swallows the rest of the generated function and the\r\n * derivation produces ZERO files without raising. Use block comments.\r\n *\r\n * @param params.models Metamodels chosen for the line. Unknown names are ignored.\r\n * @returns The file contents: core template plus one fragment per known model.\r\n * @throws {InvalidArgumentError} when `models` is not an array of strings.\r\n */\r\nexport const buildTransformationJs = ({ models }: { models?: readonly string[] }): string =>\r\n buildFromTemplates(assertModels(models), 'core/transformation.js', 'transformation')\r\n\r\n/**\r\n * The default CI pipeline files seeded into every new line repository.\r\n *\r\n * Migrated from `PipelineFileFactory.js:PIPELINE_FILES`, same paths and same\r\n * order. A function rather than an exported constant so no module-level state\r\n * holds the file contents (ADR-014) and so each caller gets its own array.\r\n *\r\n * @returns The pipeline files, in the order the monolith creates them.\r\n */\r\nexport const getPipelineFiles = (): FileSpec[] => [\r\n {\r\n path: 'src/platform/code/.gitlab-ci.yml',\r\n content: readTemplate('pipeline/.gitlab-ci.yml'),\r\n encoding: 'text'\r\n },\r\n {\r\n path: 'src/platform/code/ci/test-server.sh',\r\n content: readTemplate('pipeline/ci/test-server.sh'),\r\n encoding: 'text'\r\n },\r\n {\r\n path: 'src/platform/code/ci/test-client.sh',\r\n content: readTemplate('pipeline/ci/test-client.sh'),\r\n encoding: 'text'\r\n }\r\n]\r\n"]}
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,EAA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IACH,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,EAAE,MAAM,EAAkC,EAAU,EAAE,CACjF,kBAAkB,CAAC,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 +1 @@
1
- {"version":3,"file":"scaffold.js","sourceRoot":"","sources":["../../src/line/scaffold.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,YAAY,EAAyB,MAAM,iBAAiB,CAAA;AAC9G,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAA;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AAC/D,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAC7D,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,gBAAgB,EAAiB,MAAM,qBAAqB,CAAA;AAE1G;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,MAAM,EAAE,CAAC,QAAQ,EAAE,kBAAkB,EAAE,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,YAAY,CAAC;IACxG,UAAU,EAAE;QACV,EAAE,SAAS,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE;QAClE;YACE,SAAS,EAAE;gBACT,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM;gBAClE,WAAW,EAAE,YAAY,EAAE,KAAK,EAAE,KAAK,EAAE,YAAY;aACtD;YACD,KAAK,EAAE,KAAK;YACZ,GAAG,EAAE,KAA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I,IAAI,KAAK,EAAE,CAAC;QACzB,2EAA2E;QAC3E,kCAAkC;QAClC,aAAa,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAA;IAC9F,CAAC;IAED,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,CAAA;AAC7B,CAAC,CAAA","sourcesContent":["/**\r\n * The initial file tree of a brand new line.\r\n *\r\n * Migrated from `linea/server/src/model/services/LineService.js:createLine`\r\n * (~43-68), keeping ONLY the file construction. Everything around it belongs to\r\n * linea-server (ADR-003): creating the GitLab group and project, the\r\n * `createFile` calls, the Mongo transaction and the rollback.\r\n *\r\n * The API is split into a PURE half and an IMPURE half on purpose:\r\n *\r\n * - `buildLineScaffold` computes the files and touches nothing. linea-server\r\n * feeds the result straight to `gitlabSession.createFile`, in order, for\r\n * exact parity with `createLine` — without linea-core ever reaching the\r\n * network or the disk (ADR-002).\r\n * - `writeLineScaffold` materialises the same description on disk, which is\r\n * what linea-cli needs in local mode (ADR-004).\r\n *\r\n * They must stay separate: collapsing them would force the GitLab path to write\r\n * a temporary tree it does not want.\r\n */\r\nimport path from 'node:path'\r\nimport { FEATURE_MODEL_TYPES, isFeatureModelType, NAME_PATTERN, type FeatureModelType } from '../constants.js'\r\nimport { InvalidArgumentError } from '../errors.js'\r\nimport { modelToXml } from '../feature-model/engine.js'\r\nimport { parseFeatureModel } from '../feature-model/parse.js'\r\nimport { emptyFeatureModelUvl } from '../feature-model/text.js'\r\nimport { ensureDir, writeTextFile } from '../fs/workspace.js'\r\nimport { buildExtraJs, buildTransformationJs, getPipelineFiles, type FileSpec } from './platform-files.js'\r\n\r\n/**\r\n * Engine configuration seeded into every new line (`src/platform/config.json`).\r\n *\r\n * Verbatim from `LineService.js:48-56`, which is what actually runs when a line\r\n * is created.\r\n *\r\n * KNOWN DISCREPANCY IN THE MONOLITH: the test fixture\r\n * `linea/server/src/test/mocks/lps/src/platform/config.json` carries a RICHER\r\n * list — it also declares `dockerfile` and `sh` extensions. The two have drifted\r\n * apart. `LineService.js` is the source of truth here because it is the code\r\n * path that creates real lines; the fixture only feeds derivation tests. A line\r\n * seeded by linea-core therefore will not process `Dockerfile` or `.sh`\r\n * annotations until someone edits its `config.json`, exactly as today.\r\n */\r\nexport const DEFAULT_PLATFORM_CONFIG = {\r\n ignore: ['target', 'bower_components', '.gradle', '.project', 'bin', 'build', '.settings', '.classpath'],\r\n delimiters: [\r\n { extension: ['html', 'jsp', 'xml'], start: '<!--%', end: '%-->' },\r\n {\r\n extension: [\r\n 'css', 'js', 'java', 'vue', 'g4', 'tokens', 'gradle', 'md', 'conf',\r\n 'gitignore', 'properties', 'sql', 'env', 'production'\r\n ],\r\n start: '/*%',\r\n end: '%*/'\r\n },\r\n { extension: ['py'], start: '#%', end: '%#' },\r\n { extension: ['json'], start: '###<', end: '>###' }\r\n ]\r\n} as const\r\n\r\n/** Contents of `src/platform/code/.gitignore`, verbatim from `LineService.js:60`. */\r\nexport const DEFAULT_CODE_GITIGNORE = 'node_modules/\\ntarget/\\ndist/\\n.env\\n*.log\\n'\r\n\r\n/** What a line scaffold needs to know. */\r\nexport interface LineScaffoldInput {\r\n /** Line name; becomes the root feature of the seed model. */\r\n name: string\r\n /** Metamodels chosen for the line, e.g. `['UML']`. Unknown names are ignored. */\r\n models?: readonly string[]\r\n /** Notation of the seed feature model. Defaults to `'UVL'`. */\r\n featureModelType?: FeatureModelType\r\n}\r\n\r\n/**\r\n * Computes the files of a brand new line. PURE: reads no working directory and\r\n * writes nothing.\r\n *\r\n * The returned order is the order `createLine` creates them in, and callers\r\n * should preserve it: model, config, code/.gitignore, extra.js,\r\n * transformation.js, then the pipeline files.\r\n *\r\n * Note the template files themselves ARE read from the package's own asset\r\n * directory — that is reading linea-core's own installed data, not the caller's\r\n * working directory, and is what makes the function usable with no filesystem\r\n * target at all.\r\n *\r\n * @param params.name Line name.\r\n * @param params.models Metamodels chosen for the line.\r\n * @param params.featureModelType `'UVL'` (default) or `'XML'`.\r\n * @returns The files to create, in order.\r\n * @throws {InvalidArgumentError} when `name` is empty or has characters outside\r\n * `NAME_PATTERN`, or when `featureModelType` is unknown.\r\n */\r\nexport const buildLineScaffold = ({\r\n name,\r\n models = [],\r\n featureModelType = 'UVL'\r\n}: LineScaffoldInput): FileSpec[] => {\r\n if (typeof name !== 'string' || name === '') {\r\n throw new InvalidArgumentError('\"name\" must be a non-empty string.')\r\n }\r\n if (!NAME_PATTERN.test(name)) {\r\n throw new InvalidArgumentError(\r\n `Invalid line name ${JSON.stringify(name)}: allowed characters are [a-zA-Z0-9_.-].`\r\n )\r\n }\r\n if (!isFeatureModelType(featureModelType)) {\r\n throw new InvalidArgumentError(\r\n `Unknown feature model type ${JSON.stringify(featureModelType)}. Use one of ${FEATURE_MODEL_TYPES.join(', ')}.`\r\n )\r\n }\r\n\r\n const uvlContent = emptyFeatureModelUvl({ name })\r\n const modelFile: FileSpec = featureModelType === 'XML'\r\n ? {\r\n path: 'src/platform/model.xml',\r\n content: modelToXml(parseFeatureModel({ content: uvlContent, type: 'UVL' })),\r\n encoding: 'text'\r\n }\r\n : { path: 'src/platform/model.uvl', content: uvlContent, encoding: 'text' }\r\n\r\n return [\r\n modelFile,\r\n {\r\n path: 'src/platform/config.json',\r\n // JSON.stringify(config, null, 2) — same two-space indentation as the\r\n // monolith, and no trailing newline, so the committed file matches.\r\n content: JSON.stringify(DEFAULT_PLATFORM_CONFIG, null, 2),\r\n encoding: 'text'\r\n },\r\n { path: 'src/platform/code/.gitignore', content: DEFAULT_CODE_GITIGNORE, encoding: 'text' },\r\n { path: 'src/platform/extra.js', content: buildExtraJs({ models }), encoding: 'text' },\r\n {\r\n path: 'src/platform/transformation.js',\r\n content: buildTransformationJs({ models }),\r\n encoding: 'text'\r\n },\r\n ...getPipelineFiles()\r\n ]\r\n}\r\n\r\n/**\r\n * Materialises a line scaffold in a directory.\r\n *\r\n * The impure counterpart of `buildLineScaffold`, for linea-cli's local mode.\r\n * Creates `dir` and every parent directory the files need.\r\n *\r\n * @param params.dir Target directory (the line's working directory root).\r\n * @param params.name Line name.\r\n * @param params.models Metamodels chosen for the line.\r\n * @param params.featureModelType `'UVL'` (default) or `'XML'`.\r\n * @returns The resolved directory and the files written.\r\n * @throws {InvalidArgumentError} for the same reasons as `buildLineScaffold`, or\r\n * when `dir` is not a non-empty path.\r\n */\r\nexport const writeLineScaffold = ({\r\n dir,\r\n name,\r\n models = [],\r\n featureModelType = 'UVL'\r\n}: LineScaffoldInput & { dir: string }): { dir: string, files: FileSpec[] } => {\r\n if (typeof dir !== 'string' || dir.trim() === '') {\r\n throw new InvalidArgumentError('\"dir\" must be a non-empty path.')\r\n }\r\n const files = buildLineScaffold({ name, models, featureModelType })\r\n const root = ensureDir({ dirPath: dir })\r\n\r\n for (const file of files) {\r\n // FileSpec paths are POSIX and repository-relative; join with the platform\r\n // separator to land them on disk.\r\n writeTextFile({ filePath: path.join(root, ...file.path.split('/')), content: file.content })\r\n }\r\n\r\n return { dir: root, files }\r\n}\r\n"]}
1
+ {"version":3,"file":"scaffold.js","sourceRoot":"","sources":["../../src/line/scaffold.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,YAAY,EAAyB,MAAM,iBAAiB,CAAA;AAC9G,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAA;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AAC/D,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MA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AI,EAAE,gCAAgC;YACtC,OAAO,EAAE,qBAAqB,CAAC,EAAE,MAAM,EAAE,CAAC;YAC1C,QAAQ,EAAE,MAAM;SACjB;QACD,GAAG,gBAAgB,EAAE;KACtB,CAAA;AACH,CAAC,CAAA;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,EAChC,GAAG,EACH,IAAI,EACJ,MAAM,GAAG,EAAE,EACX,gBAAgB,GAAG,KAAK,EACY,EAAsC,EAAE;IAC5E,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QACjD,MAAM,IAAI,oBAAoB,CAAC,iCAAiC,CAAC,CAAA;IACnE,CAAC;IACD,MAAM,KAAK,GAAG,iBAAiB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,gBAAgB,EAAE,CAAC,CAAA;IACnE,MAAM,IAAI,GAAG,SAAS,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAA;IAExC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,2EAA2E;QAC3E,kCAAkC;QAClC,aAAa,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAA;IAC9F,CAAC;IAED,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,CAAA;AAC7B,CAAC,CAAA","sourcesContent":["/**\n * The initial file tree of a brand new line.\n *\n * Migrated from `linea/server/src/model/services/LineService.js:createLine`\n * (~43-68), keeping ONLY the file construction. Everything around it belongs to\n * linea-server (ADR-003): creating the GitLab group and project, the\n * `createFile` calls, the Mongo transaction and the rollback.\n *\n * The API is split into a PURE half and an IMPURE half on purpose:\n *\n * - `buildLineScaffold` computes the files and touches nothing. linea-server\n * feeds the result straight to `gitlabSession.createFile`, in order, for\n * exact parity with `createLine` — without linea-core ever reaching the\n * network or the disk (ADR-002).\n * - `writeLineScaffold` materialises the same description on disk, which is\n * what linea-cli needs in local mode (ADR-004).\n *\n * They must stay separate: collapsing them would force the GitLab path to write\n * a temporary tree it does not want.\n */\nimport path from 'node:path'\nimport { FEATURE_MODEL_TYPES, isFeatureModelType, NAME_PATTERN, type FeatureModelType } from '../constants.js'\nimport { InvalidArgumentError } from '../errors.js'\nimport { modelToXml } from '../feature-model/engine.js'\nimport { parseFeatureModel } from '../feature-model/parse.js'\nimport { emptyFeatureModelUvl } from '../feature-model/text.js'\nimport { ensureDir, writeTextFile } from '../fs/workspace.js'\nimport { buildExtraJs, buildTransformationJs, getPipelineFiles, type FileSpec } from './platform-files.js'\n\n/**\n * Engine configuration seeded into every new line (`src/platform/config.json`).\n *\n * Verbatim from `LineService.js:48-56`, which is what actually runs when a line\n * is created.\n *\n * KNOWN DISCREPANCY IN THE MONOLITH: the test fixture\n * `linea/server/src/test/mocks/lps/src/platform/config.json` carries a RICHER\n * list — it also declares `dockerfile` and `sh` extensions. The two have drifted\n * apart. `LineService.js` is the source of truth here because it is the code\n * path that creates real lines; the fixture only feeds derivation tests. A line\n * seeded by linea-core therefore will not process `Dockerfile` or `.sh`\n * annotations until someone edits its `config.json`, exactly as today.\n */\nexport const DEFAULT_PLATFORM_CONFIG = {\n ignore: ['target', 'bower_components', '.gradle', '.project', 'bin', 'build', '.settings', '.classpath'],\n delimiters: [\n { extension: ['html', 'jsp', 'xml'], start: '<!--%', end: '%-->' },\n {\n extension: [\n 'css', 'js', 'java', 'vue', 'g4', 'tokens', 'gradle', 'md', 'conf',\n 'gitignore', 'properties', 'sql', 'env', 'production'\n ],\n start: '/*%',\n end: '%*/'\n },\n { extension: ['py'], start: '#%', end: '%#' },\n { extension: ['json'], start: '###<', end: '>###' }\n ]\n} as const\n\n/** Contents of `src/platform/code/.gitignore`, verbatim from `LineService.js:60`. */\nexport const DEFAULT_CODE_GITIGNORE = 'node_modules/\\ntarget/\\ndist/\\n.env\\n*.log\\n'\n\n/** What a line scaffold needs to know. */\nexport interface LineScaffoldInput {\n /** Line name; becomes the root feature of the seed model. */\n name: string\n /** Metamodels chosen for the line, e.g. `['UML']`. Unknown names are ignored. */\n models?: readonly string[]\n /** Notation of the seed feature model. Defaults to `'UVL'`. */\n featureModelType?: FeatureModelType\n}\n\n/**\n * Computes the files of a brand new line. PURE: reads no working directory and\n * writes nothing.\n *\n * The returned order is the order `createLine` creates them in, and callers\n * should preserve it: model, config, code/.gitignore, extra.js,\n * transformation.js, then the pipeline files.\n *\n * Note the template files themselves ARE read from the package's own asset\n * directory — that is reading linea-core's own installed data, not the caller's\n * working directory, and is what makes the function usable with no filesystem\n * target at all.\n *\n * @param params.name Line name.\n * @param params.models Metamodels chosen for the line.\n * @param params.featureModelType `'UVL'` (default) or `'XML'`.\n * @returns The files to create, in order.\n * @throws {InvalidArgumentError} when `name` is empty or has characters outside\n * `NAME_PATTERN`, or when `featureModelType` is unknown.\n */\nexport const buildLineScaffold = ({\n name,\n models = [],\n featureModelType = 'UVL'\n}: LineScaffoldInput): FileSpec[] => {\n if (typeof name !== 'string' || name === '') {\n throw new InvalidArgumentError('\"name\" must be a non-empty string.')\n }\n if (!NAME_PATTERN.test(name)) {\n throw new InvalidArgumentError(\n `Invalid line name ${JSON.stringify(name)}: allowed characters are [a-zA-Z0-9_.-].`\n )\n }\n if (!isFeatureModelType(featureModelType)) {\n throw new InvalidArgumentError(\n `Unknown feature model type ${JSON.stringify(featureModelType)}. Use one of ${FEATURE_MODEL_TYPES.join(', ')}.`\n )\n }\n\n const uvlContent = emptyFeatureModelUvl({ name })\n const modelFile: FileSpec = featureModelType === 'XML'\n ? {\n path: 'src/platform/model.xml',\n content: modelToXml(parseFeatureModel({ content: uvlContent, type: 'UVL' })),\n encoding: 'text'\n }\n : { path: 'src/platform/model.uvl', content: uvlContent, encoding: 'text' }\n\n return [\n modelFile,\n {\n path: 'src/platform/config.json',\n // JSON.stringify(config, null, 2) — same two-space indentation as the\n // monolith, and no trailing newline, so the committed file matches.\n content: JSON.stringify(DEFAULT_PLATFORM_CONFIG, null, 2),\n encoding: 'text'\n },\n { path: 'src/platform/code/.gitignore', content: DEFAULT_CODE_GITIGNORE, encoding: 'text' },\n { path: 'src/platform/extra.js', content: buildExtraJs({ models }), encoding: 'text' },\n {\n path: 'src/platform/transformation.js',\n content: buildTransformationJs({ models }),\n encoding: 'text'\n },\n ...getPipelineFiles()\n ]\n}\n\n/**\n * Materialises a line scaffold in a directory.\n *\n * The impure counterpart of `buildLineScaffold`, for linea-cli's local mode.\n * Creates `dir` and every parent directory the files need.\n *\n * @param params.dir Target directory (the line's working directory root).\n * @param params.name Line name.\n * @param params.models Metamodels chosen for the line.\n * @param params.featureModelType `'UVL'` (default) or `'XML'`.\n * @returns The resolved directory and the files written.\n * @throws {InvalidArgumentError} for the same reasons as `buildLineScaffold`, or\n * when `dir` is not a non-empty path.\n */\nexport const writeLineScaffold = ({\n dir,\n name,\n models = [],\n featureModelType = 'UVL'\n}: LineScaffoldInput & { dir: string }): { dir: string, files: FileSpec[] } => {\n if (typeof dir !== 'string' || dir.trim() === '') {\n throw new InvalidArgumentError('\"dir\" must be a non-empty path.')\n }\n const files = buildLineScaffold({ name, models, featureModelType })\n const root = ensureDir({ dirPath: dir })\n\n for (const file of files) {\n // FileSpec paths are POSIX and repository-relative; join with the platform\n // separator to land them on disk.\n writeTextFile({ filePath: path.join(root, ...file.path.split('/')), content: file.content })\n }\n\n return { dir: root, files }\n}\n"]}
@@ -1,54 +1,54 @@
1
- function pluralize(name) {
2
- return name + "s";
3
- }
4
-
5
- function capitalizeOneWord(word) {
6
- return word.charAt(0).toUpperCase() + word.slice(1);
7
- }
8
-
9
- function camelToSnakeCase(str) {
10
- return str[0].toLowerCase() + str.slice(1, str.length).replace(/[A-Z]/g, letter => '_' + letter.toLowerCase());
11
- }
12
-
13
- function normalizeKebabCase(str) {
14
- return str
15
- .replace(/[\s-]+/g, '-')
16
- .replace(/([a-z])([A-Z])/g, '$1_$2')
17
- .toLowerCase();
18
- }
19
-
20
- function normalizeSnakeCase(str) {
21
- return str
22
- .replace(/[\s-]+/g, '_')
23
- .replace(/([a-z])([A-Z])/g, '$1_$2')
24
- .toLowerCase();
25
- }
26
-
27
- function normalizeUrl(str) {
28
- return str
29
- .normalize("NFKD")
30
- .replace(/[\u0300-\u036F]/g, "")
31
- .trim()
32
- .replace(/[\s]/g, "-")
33
- .toLowerCase();
34
- }
35
-
36
- function getDatabaseConfigFromSpec(data, name, defaultValue) {
37
- var dataBase = data.basicData.database;
38
- if (dataBase) {
39
- if (dataBase[name] && dataBase[name] != "") {
40
- return dataBase[name];
41
- }
42
- }
43
- return defaultValue;
44
- }
45
-
46
- function getExtraConfigFromSpec(data, name, defaultValue) {
47
- var extra = data.basicData.extra;
48
- if (extra) {
49
- if (extra[name] && extra[name] != "") {
50
- return extra[name];
51
- }
52
- }
53
- return defaultValue;
54
- }
1
+ function pluralize(name) {
2
+ return name + "s";
3
+ }
4
+
5
+ function capitalizeOneWord(word) {
6
+ return word.charAt(0).toUpperCase() + word.slice(1);
7
+ }
8
+
9
+ function camelToSnakeCase(str) {
10
+ return str[0].toLowerCase() + str.slice(1, str.length).replace(/[A-Z]/g, letter => '_' + letter.toLowerCase());
11
+ }
12
+
13
+ function normalizeKebabCase(str) {
14
+ return str
15
+ .replace(/[\s-]+/g, '-')
16
+ .replace(/([a-z])([A-Z])/g, '$1_$2')
17
+ .toLowerCase();
18
+ }
19
+
20
+ function normalizeSnakeCase(str) {
21
+ return str
22
+ .replace(/[\s-]+/g, '_')
23
+ .replace(/([a-z])([A-Z])/g, '$1_$2')
24
+ .toLowerCase();
25
+ }
26
+
27
+ function normalizeUrl(str) {
28
+ return str
29
+ .normalize("NFKD")
30
+ .replace(/[\u0300-\u036F]/g, "")
31
+ .trim()
32
+ .replace(/[\s]/g, "-")
33
+ .toLowerCase();
34
+ }
35
+
36
+ function getDatabaseConfigFromSpec(data, name, defaultValue) {
37
+ var dataBase = data.basicData.database;
38
+ if (dataBase) {
39
+ if (dataBase[name] && dataBase[name] != "") {
40
+ return dataBase[name];
41
+ }
42
+ }
43
+ return defaultValue;
44
+ }
45
+
46
+ function getExtraConfigFromSpec(data, name, defaultValue) {
47
+ var extra = data.basicData.extra;
48
+ if (extra) {
49
+ if (extra[name] && extra[name] != "") {
50
+ return extra[name];
51
+ }
52
+ }
53
+ return defaultValue;
54
+ }