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