@lbdudc/linea-core 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { type AnalysisMode, type AnalysisMetric, type FeatureModelAnalysis, type FeatureModelBddAnalysis, type MetricAnalysis } from '../analysis/analyze.js';
|
|
2
|
+
import { type SplKind } from '../modules/types.js';
|
|
3
|
+
import { type ProductSpec } from '../product/spec.js';
|
|
4
|
+
import { incrementVersion } from '../product/version.js';
|
|
5
|
+
import { type ProductsIndexEntry } from '../products-index/products-index.js';
|
|
6
|
+
export interface LocalLine {
|
|
7
|
+
name: string;
|
|
8
|
+
dir: string;
|
|
9
|
+
}
|
|
10
|
+
export declare const COMPOSED_MODEL_PATH: string;
|
|
11
|
+
/** Every line has an `spl.json` (the kind of SPL it is, and what it is made of). */
|
|
12
|
+
export declare function hasSplManifest(lineDir: string): boolean;
|
|
13
|
+
/** What kind of SPL a line is: plain, project (metamodels of the user's choice) or modular (made of modules). */
|
|
14
|
+
export declare function localLineKind(lineDir: string): SplKind;
|
|
15
|
+
export declare function isLocalLineDir(dir: string): boolean;
|
|
16
|
+
export declare function listLocalLines(workdir: string): LocalLine[];
|
|
17
|
+
export declare function resolveLocalLine(workdir: string, target: string): LocalLine;
|
|
18
|
+
/**
|
|
19
|
+
* A new line of any kind: its `spl.json`, its feature model (a model of the feature metamodel), and, unless it is modular, the platform its
|
|
20
|
+
* products are derived with. The workspace has the feature metamodel as `metamodels/featuremodel`. The lockfile is made when the line is
|
|
21
|
+
* first checked.
|
|
22
|
+
*/
|
|
23
|
+
export declare function createLocalLine(opts: {
|
|
24
|
+
workdir: string;
|
|
25
|
+
name: string;
|
|
26
|
+
kind?: SplKind;
|
|
27
|
+
metamodels?: Record<string, string>;
|
|
28
|
+
modules?: Record<string, string>;
|
|
29
|
+
}): LocalLine;
|
|
30
|
+
export declare function deleteLocalLine(lineDir: string): void;
|
|
31
|
+
export declare function localProductDir(lineDir: string, name: string): string;
|
|
32
|
+
/**
|
|
33
|
+
* The products of an SPL: the ones its index lists, and the ones that are there as folders with a spec (a product cloned from LINEA is
|
|
34
|
+
* a folder of its own inside the SPL's, and the SPL's index does not know of it).
|
|
35
|
+
*/
|
|
36
|
+
export declare function listLocalProducts(lineDir: string): ProductsIndexEntry[];
|
|
37
|
+
export declare function readLocalProductSpec(productDir: string): ProductSpec;
|
|
38
|
+
export declare function writeLocalProductSpec(productDir: string, spec: ProductSpec): void;
|
|
39
|
+
export declare function createLocalProduct(opts: {
|
|
40
|
+
lineDir: string;
|
|
41
|
+
spec: unknown;
|
|
42
|
+
}): {
|
|
43
|
+
name: string;
|
|
44
|
+
dir: string;
|
|
45
|
+
spec: ProductSpec;
|
|
46
|
+
};
|
|
47
|
+
export declare function bumpLocalProductVersion(lineDir: string, name: string, version: string): void;
|
|
48
|
+
export declare function readLocalModelAsUvl(lineDir: string): string;
|
|
49
|
+
export declare function analyzeLocalFeatureModelBdd(lineDir: string): Promise<FeatureModelBddAnalysis>;
|
|
50
|
+
export declare function analyzeLocalMetric(lineDir: string, metric: AnalysisMetric, mode: AnalysisMode): Promise<MetricAnalysis>;
|
|
51
|
+
export declare function analyzeLocalFeatureModel(lineDir: string, mode: AnalysisMode): Promise<FeatureModelAnalysis>;
|
|
52
|
+
export declare function deriveLocalProductPreview(opts: {
|
|
53
|
+
lineDir: string;
|
|
54
|
+
spec: ProductSpec;
|
|
55
|
+
outputDir: string;
|
|
56
|
+
}): Promise<{
|
|
57
|
+
outputDir: string;
|
|
58
|
+
}>;
|
|
59
|
+
export declare function generateLocalProduct(lineDir: string, name: string): Promise<{
|
|
60
|
+
outputDir: string;
|
|
61
|
+
version: string;
|
|
62
|
+
}>;
|
|
63
|
+
export declare function updateLocalProduct(opts: {
|
|
64
|
+
lineDir: string;
|
|
65
|
+
name: string;
|
|
66
|
+
spec: unknown;
|
|
67
|
+
}): {
|
|
68
|
+
spec: ProductSpec;
|
|
69
|
+
};
|
|
70
|
+
export declare function deleteLocalProduct(lineDir: string, name: string): void;
|
|
71
|
+
export declare function renameLocalProduct(lineDir: string, from: string, to: string): {
|
|
72
|
+
dir: string;
|
|
73
|
+
};
|
|
74
|
+
/** Whether a product's models are valid for its line: its feature selection against the line's feature model, and the rest of its models. */
|
|
75
|
+
export declare function healthLocalProduct(lineDir: string, name: string): Promise<{
|
|
76
|
+
valid: boolean;
|
|
77
|
+
error: string | null;
|
|
78
|
+
errorType: string | null;
|
|
79
|
+
}>;
|
|
80
|
+
export declare function deriveLocalProductZip(lineDir: string, spec: ProductSpec): Promise<Buffer>;
|
|
81
|
+
export { incrementVersion };
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { readOrigin } from './origin.js';
|
|
4
|
+
import { rootFeatureName } from '../modules/configuration/names.js';
|
|
5
|
+
import { analyzeFeatureModel, analyzeFeatureModelBdd, analyzeMetric } from '../analysis/analyze.js';
|
|
6
|
+
import { createAnalysisRuntime, disposeAnalysisRuntime } from '../analysis/runtime.js';
|
|
7
|
+
import { readTextFile, writeTextFile, resolveLinePaths } from '../fs/workspace.js';
|
|
8
|
+
import { writeLineScaffold } from '../line/scaffold.js';
|
|
9
|
+
import { serializeLock, LOCK_PATH, SPL_MANIFEST_PATH, parseSplManifest } from '../modules/packages/manifests.js';
|
|
10
|
+
import {} from '../modules/types.js';
|
|
11
|
+
import { validateProductSpec, assertProductSpec, normalizeProductSpec } from '../product/spec.js';
|
|
12
|
+
import { incrementVersion } from '../product/version.js';
|
|
13
|
+
import { readProductsIndex, writeProductsIndex, addProductToIndex, removeProductFromIndex, renameProductInIndex, emptyProductsIndex } from '../products-index/products-index.js';
|
|
14
|
+
import { InvalidArgumentError, InvalidProductSpecError } from '../errors.js';
|
|
15
|
+
export const COMPOSED_MODEL_PATH = path.join('.linea', 'composed-model.uvl');
|
|
16
|
+
/** Every line has an `spl.json` (the kind of SPL it is, and what it is made of). */
|
|
17
|
+
export function hasSplManifest(lineDir) {
|
|
18
|
+
return fs.existsSync(path.join(lineDir, SPL_MANIFEST_PATH));
|
|
19
|
+
}
|
|
20
|
+
/** What kind of SPL a line is: plain, project (metamodels of the user's choice) or modular (made of modules). */
|
|
21
|
+
export function localLineKind(lineDir) {
|
|
22
|
+
return parseSplManifest({ content: fs.readFileSync(path.join(lineDir, SPL_MANIFEST_PATH), 'utf8') }).kind;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The feature model of a line as UVL, the one its products choose from: the line's own with the ones of its modules grafted in. It is made by
|
|
26
|
+
* the feature metamodel (bango) when the line is checked, and kept in `.linea/composed-model.uvl`; checking the line, setting its modules and saving the feature
|
|
27
|
+
* model refresh it.
|
|
28
|
+
*/
|
|
29
|
+
function readLineFeatureModel(lineDir) {
|
|
30
|
+
const composed = path.join(lineDir, COMPOSED_MODEL_PATH);
|
|
31
|
+
if (!fs.existsSync(composed))
|
|
32
|
+
throw new InvalidArgumentError(`"${lineDir}" has no composed feature model yet: check the line first.`);
|
|
33
|
+
return { path: composed, content: fs.readFileSync(composed, 'utf8') };
|
|
34
|
+
}
|
|
35
|
+
export function isLocalLineDir(dir) {
|
|
36
|
+
try {
|
|
37
|
+
return hasSplManifest(dir) || fs.statSync(resolveLinePaths({ lineDir: dir }).platform).isDirectory();
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
export function listLocalLines(workdir) {
|
|
44
|
+
let entries;
|
|
45
|
+
try {
|
|
46
|
+
entries = fs.readdirSync(workdir, { withFileTypes: true });
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
return [];
|
|
50
|
+
}
|
|
51
|
+
return entries
|
|
52
|
+
.filter((e) => e.isDirectory())
|
|
53
|
+
.map((e) => ({ name: e.name, dir: path.join(workdir, e.name) }))
|
|
54
|
+
.filter((l) => isLocalLineDir(l.dir))
|
|
55
|
+
.sort((a, b) => a.name.localeCompare(b.name));
|
|
56
|
+
}
|
|
57
|
+
export function resolveLocalLine(workdir, target) {
|
|
58
|
+
const asPath = path.resolve(target);
|
|
59
|
+
if (isLocalLineDir(asPath))
|
|
60
|
+
return { name: path.basename(asPath), dir: asPath };
|
|
61
|
+
const all = listLocalLines(workdir);
|
|
62
|
+
const match = all.find((l) => l.name.toLowerCase() === target.toLowerCase());
|
|
63
|
+
if (match)
|
|
64
|
+
return match;
|
|
65
|
+
throw new InvalidArgumentError(`No local line named "${target}" in ${workdir}.`);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* A new line of any kind: its `spl.json`, its feature model (a model of the feature metamodel), and, unless it is modular, the platform its
|
|
69
|
+
* products are derived with. The workspace has the feature metamodel as `metamodels/featuremodel`. The lockfile is made when the line is
|
|
70
|
+
* first checked.
|
|
71
|
+
*/
|
|
72
|
+
export function createLocalLine(opts) {
|
|
73
|
+
const dir = path.join(opts.workdir, opts.name);
|
|
74
|
+
if (fs.existsSync(dir) && fs.readdirSync(dir).length > 0) {
|
|
75
|
+
throw new InvalidArgumentError(`"${dir}" already exists and is not empty — pick another name.`);
|
|
76
|
+
}
|
|
77
|
+
const { dir: written } = writeLineScaffold({
|
|
78
|
+
dir,
|
|
79
|
+
name: opts.name,
|
|
80
|
+
kind: opts.kind ?? 'plain',
|
|
81
|
+
...(opts.metamodels ? { metamodels: opts.metamodels } : {}),
|
|
82
|
+
...(opts.modules ? { modules: opts.modules } : {}),
|
|
83
|
+
featureMetamodel: 'file:metamodels/featuremodel',
|
|
84
|
+
});
|
|
85
|
+
writeTextFile({ filePath: path.join(written, LOCK_PATH), content: serializeLock({ lock: { lockVersion: 1, packages: {} } }) });
|
|
86
|
+
writeProductsIndex({ lineDir: written, index: emptyProductsIndex() });
|
|
87
|
+
// until the line is checked, the feature model is its root alone
|
|
88
|
+
writeTextFile({ filePath: path.join(written, COMPOSED_MODEL_PATH), content: `features\n\t${rootFeatureName({ name: opts.name })}\n` });
|
|
89
|
+
return { name: opts.name, dir: written };
|
|
90
|
+
}
|
|
91
|
+
export function deleteLocalLine(lineDir) {
|
|
92
|
+
if (!isLocalLineDir(lineDir)) {
|
|
93
|
+
throw new InvalidArgumentError(`"${lineDir}" doesn't look like a local SPL (no src/platform found there) — refusing to delete it. ` +
|
|
94
|
+
'If this came from an active SPL, it may be a stale id from a different mode.');
|
|
95
|
+
}
|
|
96
|
+
fs.rmSync(lineDir, { recursive: true, force: true });
|
|
97
|
+
}
|
|
98
|
+
export function localProductDir(lineDir, name) {
|
|
99
|
+
return path.join(lineDir, name);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* The products of an SPL: the ones its index lists, and the ones that are there as folders with a spec (a product cloned from LINEA is
|
|
103
|
+
* a folder of its own inside the SPL's, and the SPL's index does not know of it).
|
|
104
|
+
*/
|
|
105
|
+
export function listLocalProducts(lineDir) {
|
|
106
|
+
const listed = readProductsIndex({ lineDir }).productos;
|
|
107
|
+
const found = [];
|
|
108
|
+
let entries = [];
|
|
109
|
+
try {
|
|
110
|
+
entries = fs.readdirSync(lineDir, { withFileTypes: true });
|
|
111
|
+
}
|
|
112
|
+
catch {
|
|
113
|
+
/* no folder, no products */
|
|
114
|
+
}
|
|
115
|
+
for (const e of entries) {
|
|
116
|
+
if (!e.isDirectory() || e.name.startsWith('.') || listed.some((p) => p.name === e.name))
|
|
117
|
+
continue;
|
|
118
|
+
try {
|
|
119
|
+
const spec = readLocalProductSpec(path.join(lineDir, e.name));
|
|
120
|
+
found.push({ name: e.name, repositorio: '', ...(spec.basicData?.version ? { version: spec.basicData.version } : {}) });
|
|
121
|
+
}
|
|
122
|
+
catch {
|
|
123
|
+
// no spec: a product LINEA has not generated yet is still one, if that is where the folder came from
|
|
124
|
+
if (readOrigin(path.join(lineDir, e.name))?.kind === 'product')
|
|
125
|
+
found.push({ name: e.name, repositorio: '' });
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return [...listed, ...found.sort((a, b) => a.name.localeCompare(b.name))];
|
|
129
|
+
}
|
|
130
|
+
const SPEC_REL_PATH = path.join('.linea', 'spec.json');
|
|
131
|
+
export function readLocalProductSpec(productDir) {
|
|
132
|
+
const specPath = path.join(productDir, SPEC_REL_PATH);
|
|
133
|
+
let raw;
|
|
134
|
+
try {
|
|
135
|
+
raw = readTextFile({ filePath: specPath });
|
|
136
|
+
}
|
|
137
|
+
catch {
|
|
138
|
+
throw new InvalidArgumentError(`No spec found at ${specPath}.`);
|
|
139
|
+
}
|
|
140
|
+
let parsed;
|
|
141
|
+
try {
|
|
142
|
+
parsed = JSON.parse(raw);
|
|
143
|
+
}
|
|
144
|
+
catch (e) {
|
|
145
|
+
throw new InvalidArgumentError(`${specPath} is not valid JSON: ${e.message}`);
|
|
146
|
+
}
|
|
147
|
+
if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed) || !('spec' in parsed)) {
|
|
148
|
+
throw new InvalidArgumentError(`${specPath} is missing a "spec" object (corrupt or wrong format).`);
|
|
149
|
+
}
|
|
150
|
+
return parsed.spec;
|
|
151
|
+
}
|
|
152
|
+
export function writeLocalProductSpec(productDir, spec) {
|
|
153
|
+
const specPath = path.join(productDir, SPEC_REL_PATH);
|
|
154
|
+
writeTextFile({ filePath: specPath, content: `${JSON.stringify({ spec }, null, 2)}\n` });
|
|
155
|
+
}
|
|
156
|
+
export function createLocalProduct(opts) {
|
|
157
|
+
const validation = validateProductSpec({ spec: opts.spec });
|
|
158
|
+
if (!validation.valid) {
|
|
159
|
+
const detail = validation.errors.map((e) => ` • ${e.path}: ${e.messageKey}`).join('\n');
|
|
160
|
+
throw new InvalidProductSpecError(`Invalid product spec:\n${detail}`);
|
|
161
|
+
}
|
|
162
|
+
const normalized = normalizeProductSpec({ spec: opts.spec });
|
|
163
|
+
const name = normalized.basicData.name;
|
|
164
|
+
const dir = localProductDir(opts.lineDir, name);
|
|
165
|
+
if (fs.existsSync(dir)) {
|
|
166
|
+
throw new InvalidArgumentError(`A local product named "${name}" already exists at ${dir}.`);
|
|
167
|
+
}
|
|
168
|
+
writeLocalProductSpec(dir, normalized);
|
|
169
|
+
const index = addProductToIndex({
|
|
170
|
+
index: readProductsIndex({ lineDir: opts.lineDir }),
|
|
171
|
+
product: { name, repositorio: name, version: normalized.basicData.version },
|
|
172
|
+
});
|
|
173
|
+
writeProductsIndex({ lineDir: opts.lineDir, index });
|
|
174
|
+
return { name, dir, spec: normalized };
|
|
175
|
+
}
|
|
176
|
+
export function bumpLocalProductVersion(lineDir, name, version) {
|
|
177
|
+
const index = readProductsIndex({ lineDir });
|
|
178
|
+
const exists = index.productos.some((e) => e.name === name);
|
|
179
|
+
const next = exists
|
|
180
|
+
? { productos: index.productos.map((e) => (e.name === name ? { ...e, version } : e)) }
|
|
181
|
+
: addProductToIndex({ index, product: { name, repositorio: name, version } });
|
|
182
|
+
writeProductsIndex({ lineDir, index: next });
|
|
183
|
+
}
|
|
184
|
+
export function readLocalModelAsUvl(lineDir) {
|
|
185
|
+
return readLineFeatureModel(lineDir).content;
|
|
186
|
+
}
|
|
187
|
+
export async function analyzeLocalFeatureModelBdd(lineDir) {
|
|
188
|
+
const uvl = readLocalModelAsUvl(lineDir);
|
|
189
|
+
const runtime = await createAnalysisRuntime();
|
|
190
|
+
try {
|
|
191
|
+
return await analyzeFeatureModelBdd({ uvl, runtime });
|
|
192
|
+
}
|
|
193
|
+
finally {
|
|
194
|
+
disposeAnalysisRuntime({ runtime });
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
export async function analyzeLocalMetric(lineDir, metric, mode) {
|
|
198
|
+
const uvl = readLocalModelAsUvl(lineDir);
|
|
199
|
+
const runtime = await createAnalysisRuntime();
|
|
200
|
+
try {
|
|
201
|
+
return await analyzeMetric({ uvl, metric, mode, runtime });
|
|
202
|
+
}
|
|
203
|
+
finally {
|
|
204
|
+
disposeAnalysisRuntime({ runtime });
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
export async function analyzeLocalFeatureModel(lineDir, mode) {
|
|
208
|
+
const uvl = readLocalModelAsUvl(lineDir);
|
|
209
|
+
const runtime = await createAnalysisRuntime();
|
|
210
|
+
try {
|
|
211
|
+
return await analyzeFeatureModel({ uvl, mode, runtime });
|
|
212
|
+
}
|
|
213
|
+
finally {
|
|
214
|
+
disposeAnalysisRuntime({ runtime });
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
export async function deriveLocalProductPreview(opts) {
|
|
218
|
+
const productDir = localProductDir(opts.lineDir, (opts.spec.basicData?.name ?? ''));
|
|
219
|
+
return (await import('./modular.js')).deriveLocalModularProduct(path.dirname(opts.lineDir), opts.lineDir, productDir, opts.spec, opts.outputDir);
|
|
220
|
+
}
|
|
221
|
+
export async function generateLocalProduct(lineDir, name) {
|
|
222
|
+
const dir = localProductDir(lineDir, name);
|
|
223
|
+
const spec = readLocalProductSpec(dir);
|
|
224
|
+
const version = incrementVersion({ version: spec.basicData.version, index: 2 });
|
|
225
|
+
const nextSpec = { ...spec, basicData: { ...spec.basicData, version } };
|
|
226
|
+
const { outputDir } = await (await import('./modular.js')).deriveLocalModularProduct(path.dirname(lineDir), lineDir, dir, nextSpec);
|
|
227
|
+
writeLocalProductSpec(dir, nextSpec);
|
|
228
|
+
bumpLocalProductVersion(lineDir, name, version);
|
|
229
|
+
return { outputDir, version };
|
|
230
|
+
}
|
|
231
|
+
export function updateLocalProduct(opts) {
|
|
232
|
+
const dir = localProductDir(opts.lineDir, opts.name);
|
|
233
|
+
readLocalProductSpec(dir);
|
|
234
|
+
const checked = assertProductSpec({ spec: opts.spec });
|
|
235
|
+
const normalized = normalizeProductSpec({ spec: checked });
|
|
236
|
+
const submittedName = normalized.basicData.name;
|
|
237
|
+
if (submittedName !== opts.name) {
|
|
238
|
+
throw new InvalidArgumentError(`/update can't rename a local product ("${submittedName}" != "${opts.name}") — use /rename for that. ` +
|
|
239
|
+
`Keep spec.basicData.name as "${opts.name}" here.`);
|
|
240
|
+
}
|
|
241
|
+
const version = incrementVersion({ version: normalized.basicData.version, index: 1 });
|
|
242
|
+
const nextSpec = { ...normalized, basicData: { ...normalized.basicData, version } };
|
|
243
|
+
writeLocalProductSpec(dir, nextSpec);
|
|
244
|
+
bumpLocalProductVersion(opts.lineDir, opts.name, version);
|
|
245
|
+
return { spec: nextSpec };
|
|
246
|
+
}
|
|
247
|
+
export function deleteLocalProduct(lineDir, name) {
|
|
248
|
+
const dir = localProductDir(lineDir, name);
|
|
249
|
+
if (!fs.existsSync(dir)) {
|
|
250
|
+
throw new InvalidArgumentError(`No local product named "${name}" at ${dir}.`);
|
|
251
|
+
}
|
|
252
|
+
fs.rmSync(dir, { recursive: true, force: true });
|
|
253
|
+
const index = removeProductFromIndex({ index: readProductsIndex({ lineDir }), name });
|
|
254
|
+
writeProductsIndex({ lineDir, index });
|
|
255
|
+
}
|
|
256
|
+
export function renameLocalProduct(lineDir, from, to) {
|
|
257
|
+
const fromDir = localProductDir(lineDir, from);
|
|
258
|
+
const toDir = localProductDir(lineDir, to);
|
|
259
|
+
if (!fs.existsSync(fromDir)) {
|
|
260
|
+
throw new InvalidArgumentError(`No local product named "${from}" at ${fromDir}.`);
|
|
261
|
+
}
|
|
262
|
+
if (fs.existsSync(toDir)) {
|
|
263
|
+
throw new InvalidArgumentError(`A local product named "${to}" already exists at ${toDir}.`);
|
|
264
|
+
}
|
|
265
|
+
const renamed = renameProductInIndex({ index: readProductsIndex({ lineDir }), from, to });
|
|
266
|
+
const nextIndex = {
|
|
267
|
+
productos: renamed.productos.map((e) => (e.name === to ? { ...e, repositorio: to } : e)),
|
|
268
|
+
};
|
|
269
|
+
fs.renameSync(fromDir, toDir);
|
|
270
|
+
const spec = readLocalProductSpec(toDir);
|
|
271
|
+
writeLocalProductSpec(toDir, { ...spec, basicData: { ...spec.basicData, name: to } });
|
|
272
|
+
writeProductsIndex({ lineDir, index: nextIndex });
|
|
273
|
+
return { dir: toDir };
|
|
274
|
+
}
|
|
275
|
+
/** Whether a product's models are valid for its line: its feature selection against the line's feature model, and the rest of its models. */
|
|
276
|
+
export async function healthLocalProduct(lineDir, name) {
|
|
277
|
+
const { checkLocalProductModels } = await import('./modular.js');
|
|
278
|
+
const report = await checkLocalProductModels(path.dirname(lineDir), lineDir, localProductDir(lineDir, name));
|
|
279
|
+
const first = report.diagnostics.find((d) => d.severity === 'error');
|
|
280
|
+
return { valid: report.ok, error: first ? `${first.file ?? first.package}: ${first.message}` : null, errorType: first ? 'models' : null };
|
|
281
|
+
}
|
|
282
|
+
export async function deriveLocalProductZip(lineDir, spec) {
|
|
283
|
+
const name = (spec.basicData?.name ?? '');
|
|
284
|
+
return (await import('./modular.js')).deriveLocalModularProductZip(path.dirname(lineDir), lineDir, localProductDir(lineDir, name), spec);
|
|
285
|
+
}
|
|
286
|
+
export { incrementVersion };
|
|
287
|
+
//# sourceMappingURL=local.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local.js","sourceRoot":"","sources":["../../src/worksp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KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,OAAO,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,EAAE,CAAA;AAC3I,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,OAAe,EAAE,IAAiB;IAC5E,MAAM,IAAI,GAAG,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,CAAA;IACzC,OAAO,CAAC,MAAM,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,4BAA4B,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,eAAe,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,CAAA;AAC1I,CAAC;AAED,OAAO,EAAE,gBAAgB,EAAE,CAAA","sourcesContent":["import fs from 'node:fs'\nimport path from 'node:path'\nimport { readOrigin } from './origin.js'\nimport { rootFeatureName } from '../modules/configuration/names.js'\nimport { analyzeFeatureModel, analyzeFeatureModelBdd, analyzeMetric, type AnalysisMode, type AnalysisMetric, type FeatureModelAnalysis, type FeatureModelBddAnalysis, type MetricAnalysis } from '../analysis/analyze.js'\nimport { createAnalysisRuntime, disposeAnalysisRuntime } from '../analysis/runtime.js'\nimport { readTextFile, writeTextFile, resolveLinePaths } from '../fs/workspace.js'\nimport { writeLineScaffold } from '../line/scaffold.js'\nimport { serializeLock, LOCK_PATH, SPL_MANIFEST_PATH, parseSplManifest } from '../modules/packages/manifests.js'\nimport { type SplKind } from '../modules/types.js'\nimport { validateProductSpec, assertProductSpec, normalizeProductSpec, type ProductSpec } from '../product/spec.js'\nimport { incrementVersion } from '../product/version.js'\nimport { readProductsIndex, writeProductsIndex, addProductToIndex, removeProductFromIndex, renameProductInIndex, emptyProductsIndex, type ProductsIndexEntry } from '../products-index/products-index.js'\nimport { InvalidArgumentError, InvalidProductSpecError } from '../errors.js'\n\nexport interface LocalLine {\n name: string\n dir: string\n}\n\nexport const COMPOSED_MODEL_PATH = path.join('.linea', 'composed-model.uvl')\n\n/** Every line has an `spl.json` (the kind of SPL it is, and what it is made of). */\nexport function hasSplManifest(lineDir: string): boolean {\n return fs.existsSync(path.join(lineDir, SPL_MANIFEST_PATH))\n}\n\n/** What kind of SPL a line is: plain, project (metamodels of the user's choice) or modular (made of modules). */\nexport function localLineKind(lineDir: string): SplKind {\n return parseSplManifest({ content: fs.readFileSync(path.join(lineDir, SPL_MANIFEST_PATH), 'utf8') }).kind\n}\n\n/**\n * The feature model of a line as UVL, the one its products choose from: the line's own with the ones of its modules grafted in. It is made by\n * the feature metamodel (bango) when the line is checked, and kept in `.linea/composed-model.uvl`; checking the line, setting its modules and saving the feature\n * model refresh it.\n */\nfunction readLineFeatureModel(lineDir: string): { path: string; content: string } {\n const composed = path.join(lineDir, COMPOSED_MODEL_PATH)\n if (!fs.existsSync(composed)) throw new InvalidArgumentError(`\"${lineDir}\" has no composed feature model yet: check the line first.`)\n return { path: composed, content: fs.readFileSync(composed, 'utf8') }\n}\n\nexport function isLocalLineDir(dir: string): boolean {\n try {\n return hasSplManifest(dir) || fs.statSync(resolveLinePaths({ lineDir: dir }).platform).isDirectory()\n } catch {\n return false\n }\n}\n\nexport function listLocalLines(workdir: string): LocalLine[] {\n let entries: fs.Dirent[]\n try {\n entries = fs.readdirSync(workdir, { withFileTypes: true })\n } catch {\n return []\n }\n return entries\n .filter((e) => e.isDirectory())\n .map((e) => ({ name: e.name, dir: path.join(workdir, e.name) }))\n .filter((l) => isLocalLineDir(l.dir))\n .sort((a, b) => a.name.localeCompare(b.name))\n}\n\nexport function resolveLocalLine(workdir: string, target: string): LocalLine {\n const asPath = path.resolve(target)\n if (isLocalLineDir(asPath)) return { name: path.basename(asPath), dir: asPath }\n\n const all = listLocalLines(workdir)\n const match = all.find((l) => l.name.toLowerCase() === target.toLowerCase())\n if (match) return match\n throw new InvalidArgumentError(\n `No local line named \"${target}\" in ${workdir}.`,\n )\n}\n\n/**\n * A new line of any kind: its `spl.json`, its feature model (a model of the feature metamodel), and, unless it is modular, the platform its\n * products are derived with. The workspace has the feature metamodel as `metamodels/featuremodel`. The lockfile is made when the line is\n * first checked.\n */\nexport function createLocalLine(opts: { workdir: string; name: string; kind?: SplKind; metamodels?: Record<string, string>; modules?: Record<string, string> }): LocalLine {\n const dir = path.join(opts.workdir, opts.name)\n if (fs.existsSync(dir) && fs.readdirSync(dir).length > 0) {\n throw new InvalidArgumentError(`\"${dir}\" already exists and is not empty — pick another name.`)\n }\n const { dir: written } = writeLineScaffold({\n dir,\n name: opts.name,\n kind: opts.kind ?? 'plain',\n ...(opts.metamodels ? { metamodels: opts.metamodels } : {}),\n ...(opts.modules ? { modules: opts.modules } : {}),\n featureMetamodel: 'file:metamodels/featuremodel',\n })\n writeTextFile({ filePath: path.join(written, LOCK_PATH), content: serializeLock({ lock: { lockVersion: 1, packages: {} } }) })\n writeProductsIndex({ lineDir: written, index: emptyProductsIndex() })\n // until the line is checked, the feature model is its root alone\n writeTextFile({ filePath: path.join(written, COMPOSED_MODEL_PATH), content: `features\\n\\t${rootFeatureName({ name: opts.name })}\\n` })\n return { name: opts.name, dir: written }\n}\n\nexport function deleteLocalLine(lineDir: string): void {\n if (!isLocalLineDir(lineDir)) {\n throw new InvalidArgumentError(\n `\"${lineDir}\" doesn't look like a local SPL (no src/platform found there) — refusing to delete it. ` +\n 'If this came from an active SPL, it may be a stale id from a different mode.',\n )\n }\n fs.rmSync(lineDir, { recursive: true, force: true })\n}\n\nexport function localProductDir(lineDir: string, name: string): string {\n return path.join(lineDir, name)\n}\n\n/**\n * The products of an SPL: the ones its index lists, and the ones that are there as folders with a spec (a product cloned from LINEA is\n * a folder of its own inside the SPL's, and the SPL's index does not know of it).\n */\nexport function listLocalProducts(lineDir: string): ProductsIndexEntry[] {\n const listed = readProductsIndex({ lineDir }).productos\n const found: ProductsIndexEntry[] = []\n let entries: fs.Dirent[] = []\n try {\n entries = fs.readdirSync(lineDir, { withFileTypes: true })\n } catch {\n /* no folder, no products */\n }\n for (const e of entries) {\n if (!e.isDirectory() || e.name.startsWith('.') || listed.some((p) => p.name === e.name)) continue\n try {\n const spec = readLocalProductSpec(path.join(lineDir, e.name))\n found.push({ name: e.name, repositorio: '', ...(spec.basicData?.version ? { version: spec.basicData.version } : {}) })\n } catch {\n // no spec: a product LINEA has not generated yet is still one, if that is where the folder came from\n if (readOrigin(path.join(lineDir, e.name))?.kind === 'product') found.push({ name: e.name, repositorio: '' })\n }\n }\n return [...listed, ...found.sort((a, b) => a.name.localeCompare(b.name))]\n}\n\nconst SPEC_REL_PATH = path.join('.linea', 'spec.json')\n\nexport function readLocalProductSpec(productDir: string): ProductSpec {\n const specPath = path.join(productDir, SPEC_REL_PATH)\n let raw: string\n try {\n raw = readTextFile({ filePath: specPath })\n } catch {\n throw new InvalidArgumentError(`No spec found at ${specPath}.`)\n }\n let parsed: unknown\n try {\n parsed = JSON.parse(raw)\n } catch (e) {\n throw new InvalidArgumentError(`${specPath} is not valid JSON: ${(e as Error).message}`)\n }\n if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed) || !('spec' in parsed)) {\n throw new InvalidArgumentError(`${specPath} is missing a \"spec\" object (corrupt or wrong format).`)\n }\n return (parsed as { spec: ProductSpec }).spec\n}\n\nexport function writeLocalProductSpec(productDir: string, spec: ProductSpec): void {\n const specPath = path.join(productDir, SPEC_REL_PATH)\n writeTextFile({ filePath: specPath, content: `${JSON.stringify({ spec }, null, 2)}\\n` })\n}\n\nexport function createLocalProduct(opts: { lineDir: string; spec: unknown }): {\n name: string\n dir: string\n spec: ProductSpec\n} {\n const validation = validateProductSpec({ spec: opts.spec })\n if (!validation.valid) {\n const detail = validation.errors.map((e) => ` • ${e.path}: ${e.messageKey}`).join('\\n')\n throw new InvalidProductSpecError(`Invalid product spec:\\n${detail}`)\n }\n const normalized = normalizeProductSpec({ spec: opts.spec as ProductSpec })\n const name = normalized.basicData!.name!\n\n const dir = localProductDir(opts.lineDir, name)\n if (fs.existsSync(dir)) {\n throw new InvalidArgumentError(`A local product named \"${name}\" already exists at ${dir}.`)\n }\n\n writeLocalProductSpec(dir, normalized)\n const index = addProductToIndex({\n index: readProductsIndex({ lineDir: opts.lineDir }),\n product: { name, repositorio: name, version: normalized.basicData!.version },\n })\n writeProductsIndex({ lineDir: opts.lineDir, index })\n\n return { name, dir, spec: normalized }\n}\n\nexport function bumpLocalProductVersion(lineDir: string, name: string, version: string): void {\n const index = readProductsIndex({ lineDir })\n const exists = index.productos.some((e) => e.name === name)\n const next = exists\n ? { productos: index.productos.map((e) => (e.name === name ? { ...e, version } : e)) }\n : addProductToIndex({ index, product: { name, repositorio: name, version } })\n writeProductsIndex({ lineDir, index: next })\n}\n\nexport function readLocalModelAsUvl(lineDir: string): string {\n return readLineFeatureModel(lineDir).content\n}\n\nexport async function analyzeLocalFeatureModelBdd(lineDir: string): Promise<FeatureModelBddAnalysis> {\n const uvl = readLocalModelAsUvl(lineDir)\n const runtime = await createAnalysisRuntime()\n try {\n return await analyzeFeatureModelBdd({ uvl, runtime })\n } finally {\n disposeAnalysisRuntime({ runtime })\n }\n}\n\nexport async function analyzeLocalMetric(\n lineDir: string,\n metric: AnalysisMetric,\n mode: AnalysisMode,\n): Promise<MetricAnalysis> {\n const uvl = readLocalModelAsUvl(lineDir)\n const runtime = await createAnalysisRuntime()\n try {\n return await analyzeMetric({ uvl, metric, mode, runtime })\n } finally {\n disposeAnalysisRuntime({ runtime })\n }\n}\n\nexport async function analyzeLocalFeatureModel(\n lineDir: string,\n mode: AnalysisMode,\n): Promise<FeatureModelAnalysis> {\n const uvl = readLocalModelAsUvl(lineDir)\n const runtime = await createAnalysisRuntime()\n try {\n return await analyzeFeatureModel({ uvl, mode, runtime })\n } finally {\n disposeAnalysisRuntime({ runtime })\n }\n}\n\nexport async function deriveLocalProductPreview(opts: {\n lineDir: string\n spec: ProductSpec\n outputDir: string\n}): Promise<{ outputDir: string }> {\n const productDir = localProductDir(opts.lineDir, (opts.spec.basicData?.name ?? ''))\n return (await import('./modular.js')).deriveLocalModularProduct(path.dirname(opts.lineDir), opts.lineDir, productDir, opts.spec, opts.outputDir)\n}\n\nexport async function generateLocalProduct(\n lineDir: string,\n name: string,\n): Promise<{ outputDir: string; version: string }> {\n const dir = localProductDir(lineDir, name)\n const spec = readLocalProductSpec(dir)\n const version = incrementVersion({ version: spec.basicData!.version!, index: 2 })\n const nextSpec: ProductSpec = { ...spec, basicData: { ...spec.basicData, version } }\n const { outputDir } = await (await import('./modular.js')).deriveLocalModularProduct(path.dirname(lineDir), lineDir, dir, nextSpec)\n writeLocalProductSpec(dir, nextSpec)\n bumpLocalProductVersion(lineDir, name, version)\n return { outputDir, version }\n}\n\nexport function updateLocalProduct(opts: { lineDir: string; name: string; spec: unknown }): {\n spec: ProductSpec\n} {\n const dir = localProductDir(opts.lineDir, opts.name)\n readLocalProductSpec(dir)\n\n const checked = assertProductSpec({ spec: opts.spec as ProductSpec })\n const normalized = normalizeProductSpec({ spec: checked })\n const submittedName = normalized.basicData!.name!\n if (submittedName !== opts.name) {\n throw new InvalidArgumentError(\n `/update can't rename a local product (\"${submittedName}\" != \"${opts.name}\") — use /rename for that. ` +\n `Keep spec.basicData.name as \"${opts.name}\" here.`,\n )\n }\n\n const version = incrementVersion({ version: normalized.basicData!.version!, index: 1 })\n const nextSpec: ProductSpec = { ...normalized, basicData: { ...normalized.basicData, version } }\n writeLocalProductSpec(dir, nextSpec)\n bumpLocalProductVersion(opts.lineDir, opts.name, version)\n return { spec: nextSpec }\n}\n\nexport function deleteLocalProduct(lineDir: string, name: string): void {\n const dir = localProductDir(lineDir, name)\n if (!fs.existsSync(dir)) {\n throw new InvalidArgumentError(`No local product named \"${name}\" at ${dir}.`)\n }\n fs.rmSync(dir, { recursive: true, force: true })\n const index = removeProductFromIndex({ index: readProductsIndex({ lineDir }), name })\n writeProductsIndex({ lineDir, index })\n}\n\nexport function renameLocalProduct(lineDir: string, from: string, to: string): { dir: string } {\n const fromDir = localProductDir(lineDir, from)\n const toDir = localProductDir(lineDir, to)\n if (!fs.existsSync(fromDir)) {\n throw new InvalidArgumentError(`No local product named \"${from}\" at ${fromDir}.`)\n }\n if (fs.existsSync(toDir)) {\n throw new InvalidArgumentError(`A local product named \"${to}\" already exists at ${toDir}.`)\n }\n const renamed = renameProductInIndex({ index: readProductsIndex({ lineDir }), from, to })\n const nextIndex = {\n productos: renamed.productos.map((e) => (e.name === to ? { ...e, repositorio: to } : e)),\n }\n\n fs.renameSync(fromDir, toDir)\n const spec = readLocalProductSpec(toDir)\n writeLocalProductSpec(toDir, { ...spec, basicData: { ...spec.basicData, name: to } })\n writeProductsIndex({ lineDir, index: nextIndex })\n\n return { dir: toDir }\n}\n\n/** Whether a product's models are valid for its line: its feature selection against the line's feature model, and the rest of its models. */\nexport async function healthLocalProduct(\n lineDir: string,\n name: string,\n): Promise<{ valid: boolean; error: string | null; errorType: string | null }> {\n const { checkLocalProductModels } = await import('./modular.js')\n const report = await checkLocalProductModels(path.dirname(lineDir), lineDir, localProductDir(lineDir, name))\n const first = report.diagnostics.find((d) => d.severity === 'error')\n return { valid: report.ok, error: first ? `${first.file ?? first.package}: ${first.message}` : null, errorType: first ? 'models' : null }\n}\n\nexport async function deriveLocalProductZip(lineDir: string, spec: ProductSpec): Promise<Buffer> {\n const name = (spec.basicData?.name ?? '')\n return (await import('./modular.js')).deriveLocalModularProductZip(path.dirname(lineDir), lineDir, localProductDir(lineDir, name), spec)\n}\n\nexport { incrementVersion }\n"]}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { type MetamodelInfo } from '../modules/metamodels/engine.js';
|
|
2
|
+
import { type OfferedModel } from '../modules/metamodels/offered.js';
|
|
3
|
+
import { deriveModularProduct, deriveModularProductToZip } from '../modules/products/derive.js';
|
|
4
|
+
import { checkSpl } from '../modules/spl/check.js';
|
|
5
|
+
import { type PackageKind, type Diagnostic, type PackageFiles, type ResolvedSpl, type SplManifest } from '../modules/types.js';
|
|
6
|
+
import { type ProductSpec } from '../product/spec.js';
|
|
7
|
+
import { type LocalLine } from './local.js';
|
|
8
|
+
export interface LocalPackage {
|
|
9
|
+
kind: PackageKind;
|
|
10
|
+
name: string;
|
|
11
|
+
version: string;
|
|
12
|
+
location: string;
|
|
13
|
+
dir: string;
|
|
14
|
+
description: string;
|
|
15
|
+
}
|
|
16
|
+
export declare const locationOf: (kind: PackageKind, name: string) => string;
|
|
17
|
+
/** A line made of modules: its `spl.json` says so (every line has one: the kind of SPL it is, and what it is made of). */
|
|
18
|
+
export declare function isModularLine(lineDir: string): boolean;
|
|
19
|
+
export declare function listLocalPackages(workdir: string): LocalPackage[];
|
|
20
|
+
export declare function createLocalPackage(opts: {
|
|
21
|
+
workdir: string;
|
|
22
|
+
kind: PackageKind;
|
|
23
|
+
name: string;
|
|
24
|
+
description?: string;
|
|
25
|
+
}): LocalPackage;
|
|
26
|
+
export declare function createLocalModularLine(opts: {
|
|
27
|
+
workdir: string;
|
|
28
|
+
name: string;
|
|
29
|
+
}): LocalLine;
|
|
30
|
+
export interface LocalContext {
|
|
31
|
+
resolved: ResolvedSpl;
|
|
32
|
+
spl: SplManifest;
|
|
33
|
+
files: PackageFiles;
|
|
34
|
+
}
|
|
35
|
+
export interface LocalModulesView {
|
|
36
|
+
modules: Record<string, string>;
|
|
37
|
+
packages: {
|
|
38
|
+
kind: PackageKind;
|
|
39
|
+
name: string;
|
|
40
|
+
version: string;
|
|
41
|
+
location: string;
|
|
42
|
+
requiredBy: readonly string[];
|
|
43
|
+
}[];
|
|
44
|
+
featureModelName: string;
|
|
45
|
+
}
|
|
46
|
+
export declare function getLocalLineModules(workdir: string, lineDir: string): Promise<LocalModulesView>;
|
|
47
|
+
export declare function checkLocalLine(workdir: string, lineDir: string, modules?: Record<string, string>): Promise<{
|
|
48
|
+
resolved: ResolvedSpl;
|
|
49
|
+
report: Awaited<ReturnType<typeof checkSpl>>;
|
|
50
|
+
}>;
|
|
51
|
+
/** Sets the modules of a line: resolves and checks them, and writes `spl.json` and the lockfile. Throws `ModuleCheckError` when they do not fit. */
|
|
52
|
+
export declare function setLocalLineModules(workdir: string, lineDir: string, modules: Record<string, string>): Promise<{
|
|
53
|
+
resolved: ResolvedSpl;
|
|
54
|
+
report: Awaited<ReturnType<typeof checkSpl>>;
|
|
55
|
+
}>;
|
|
56
|
+
export declare function readLocalProductModels(productDir: string): Record<string, string>;
|
|
57
|
+
export interface LocalProductModels {
|
|
58
|
+
metamodels: readonly MetamodelInfo[];
|
|
59
|
+
models: Record<string, string>;
|
|
60
|
+
offered: OfferedModel[];
|
|
61
|
+
diagnostics: readonly Diagnostic[];
|
|
62
|
+
ok: boolean;
|
|
63
|
+
}
|
|
64
|
+
export declare function checkLocalProductModels(workdir: string, lineDir: string, productDir: string): Promise<LocalProductModels>;
|
|
65
|
+
/** Writes the smallest valid model of each metamodel into a new product of a modular line (does nothing for a plain line). */
|
|
66
|
+
export declare function seedLocalProductModels(workdir: string, lineDir: string, productDir: string): Promise<string[]>;
|
|
67
|
+
export declare function deriveLocalModularProduct(workdir: string, lineDir: string, productDir: string, spec: ProductSpec, outputDir?: string): ReturnType<typeof deriveModularProduct>;
|
|
68
|
+
export declare function deriveLocalModularProductZip(workdir: string, lineDir: string, productDir: string, spec: ProductSpec): ReturnType<typeof deriveModularProductToZip>;
|
|
69
|
+
export interface LocalPackageCheck {
|
|
70
|
+
ok: boolean;
|
|
71
|
+
diagnostics: readonly Diagnostic[];
|
|
72
|
+
/** what it brings in with it, dependencies first */
|
|
73
|
+
resolved: {
|
|
74
|
+
modules: number;
|
|
75
|
+
metamodels: number;
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Checks a package of the workspace on its own, as the registry does before it publishes it: what it needs is resolved, and everything
|
|
80
|
+
* is composed. A metamodel is only ever used through a module, so it is checked through one made up for the purpose.
|
|
81
|
+
*/
|
|
82
|
+
export declare function checkLocalPackage(workdir: string, kind: PackageKind, name: string): Promise<LocalPackageCheck>;
|
|
83
|
+
export interface LockChange {
|
|
84
|
+
location: string;
|
|
85
|
+
from?: string;
|
|
86
|
+
to?: string;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Takes the newest versions the ranges of an SPL allow, and pins them: the lockfile is made again (for one module and what it brought,
|
|
90
|
+
* with `only`). Nothing is written when the result does not check out. Returns what changed.
|
|
91
|
+
*/
|
|
92
|
+
export declare function updateLocalLineLock(workdir: string, lineDir: string, only?: string): Promise<{
|
|
93
|
+
changes: LockChange[];
|
|
94
|
+
resolved: ResolvedSpl;
|
|
95
|
+
}>;
|