@mimir-labs/core 0.3.0 → 0.4.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 +3 -2
- package/dist/implementation/authoring/mimir-descriptor-loader.d.ts +2 -0
- package/dist/implementation/authoring/mimir-descriptor-loader.js +7 -0
- package/dist/implementation/authoring/mimir-descriptor-loader.js.map +1 -0
- package/dist/implementation/contracts/descriptor.d.ts +27 -0
- package/dist/implementation/contracts/descriptor.js +3 -0
- package/dist/implementation/contracts/descriptor.js.map +1 -0
- package/dist/implementation/contracts/resource.d.ts +16 -0
- package/dist/implementation/contracts/resource.js +3 -0
- package/dist/implementation/contracts/resource.js.map +1 -0
- package/dist/implementation/descriptors/descriptor-discovery.d.ts +2 -0
- package/dist/implementation/descriptors/descriptor-discovery.js +47 -0
- package/dist/implementation/descriptors/descriptor-discovery.js.map +1 -0
- package/dist/implementation/descriptors/descriptor-repository.d.ts +2 -0
- package/dist/implementation/descriptors/descriptor-repository.js +156 -0
- package/dist/implementation/descriptors/descriptor-repository.js.map +1 -0
- package/dist/implementation/generation/generate-service.d.ts +1 -0
- package/dist/implementation/generation/generate-service.js +67 -57
- package/dist/implementation/generation/generate-service.js.map +1 -1
- package/dist/implementation/generation/provenance/provenance-builder.d.ts +0 -1
- package/dist/implementation/generation/provenance/provenance-builder.js +0 -8
- package/dist/implementation/generation/provenance/provenance-builder.js.map +1 -1
- package/dist/implementation/generation/types.d.ts +1 -19
- package/dist/implementation/generators/aps-generator.js +1 -1
- package/dist/implementation/generators/aps-generator.js.map +1 -1
- package/dist/implementation/resource-discovery/storybook-extractor.d.ts +2 -0
- package/dist/implementation/resource-discovery/storybook-extractor.js +63 -0
- package/dist/implementation/resource-discovery/storybook-extractor.js.map +1 -0
- package/dist/implementation/resource-discovery/typescript-extractor.d.ts +2 -0
- package/dist/implementation/resource-discovery/typescript-extractor.js +137 -0
- package/dist/implementation/resource-discovery/typescript-extractor.js.map +1 -0
- package/dist/implementation/services/authoring-service.d.ts +9 -0
- package/dist/implementation/services/authoring-service.js +215 -23
- package/dist/implementation/services/authoring-service.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,7 +4,8 @@ Core business logic and reusable services for the Mimir CLI.
|
|
|
4
4
|
|
|
5
5
|
Public workflows include discovery, authoring, generation, validation,
|
|
6
6
|
governance, context generation, synchronization, initialization, and doctor
|
|
7
|
-
assessment. Author Knowledge sources live
|
|
8
|
-
artifacts remain under
|
|
7
|
+
assessment. Author Knowledge sources live in versioned `*.mimir.yaml`
|
|
8
|
+
descriptors maintained by `mimir author`; generated APS artifacts remain under
|
|
9
|
+
`dist/aps`.
|
|
9
10
|
|
|
10
11
|
See extension guidance in [EXTENSIONS.md](./EXTENSIONS.md).
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadMimirDescriptors = void 0;
|
|
4
|
+
// Backward-compatible re-export. Descriptor loading now lives in descriptors/descriptor-repository.
|
|
5
|
+
var descriptor_repository_1 = require("../descriptors/descriptor-repository");
|
|
6
|
+
Object.defineProperty(exports, "loadMimirDescriptors", { enumerable: true, get: function () { return descriptor_repository_1.loadMimirDescriptors; } });
|
|
7
|
+
//# sourceMappingURL=mimir-descriptor-loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mimir-descriptor-loader.js","sourceRoot":"","sources":["../../../src/implementation/authoring/mimir-descriptor-loader.ts"],"names":[],"mappings":";;;AAAA,oGAAoG;AACpG,8EAA4E;AAAnE,6HAAA,oBAAoB,OAAA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ExtractedProp } from "./resource";
|
|
2
|
+
export type MimirResourceDescriptor = {
|
|
3
|
+
kind: string;
|
|
4
|
+
name: string;
|
|
5
|
+
id?: string;
|
|
6
|
+
auto: {
|
|
7
|
+
source: {
|
|
8
|
+
file?: string;
|
|
9
|
+
symbol?: string;
|
|
10
|
+
public?: boolean;
|
|
11
|
+
};
|
|
12
|
+
props: Record<string, ExtractedProp>;
|
|
13
|
+
variants: string[];
|
|
14
|
+
storyFiles: string[];
|
|
15
|
+
};
|
|
16
|
+
human: {
|
|
17
|
+
description: string;
|
|
18
|
+
whenToUse: string[];
|
|
19
|
+
whenNotToUse: string[];
|
|
20
|
+
};
|
|
21
|
+
sourceRef: string;
|
|
22
|
+
};
|
|
23
|
+
export type MimirDescriptorLoadResult = {
|
|
24
|
+
descriptorFiles: string[];
|
|
25
|
+
resources: MimirResourceDescriptor[];
|
|
26
|
+
warnings: string[];
|
|
27
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"descriptor.js","sourceRoot":"","sources":["../../../src/implementation/contracts/descriptor.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type ExtractedProp = {
|
|
2
|
+
name: string;
|
|
3
|
+
type?: string;
|
|
4
|
+
required?: boolean;
|
|
5
|
+
};
|
|
6
|
+
export type ExtractedComponentFact = {
|
|
7
|
+
name: string;
|
|
8
|
+
filePath: string;
|
|
9
|
+
importName: string;
|
|
10
|
+
packageName: string;
|
|
11
|
+
props: Record<string, ExtractedProp>;
|
|
12
|
+
};
|
|
13
|
+
export type StorybookFacts = {
|
|
14
|
+
variantsByComponent: Record<string, string[]>;
|
|
15
|
+
storyFilesByComponent: Record<string, string[]>;
|
|
16
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource.js","sourceRoot":"","sources":["../../../src/implementation/contracts/resource.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.DESCRIPTOR_SUFFIXES = void 0;
|
|
7
|
+
exports.discoverDescriptorFiles = discoverDescriptorFiles;
|
|
8
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
+
const promises_1 = require("node:fs/promises");
|
|
10
|
+
exports.DESCRIPTOR_SUFFIXES = [".mimir.yaml", ".mimir.yml"];
|
|
11
|
+
function normalizeSlashes(value) {
|
|
12
|
+
return value.split(node_path_1.default.sep).join("/");
|
|
13
|
+
}
|
|
14
|
+
function shouldSkipDirectory(name) {
|
|
15
|
+
if (name === "node_modules" || name === "dist" || name === ".git") {
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
if (name.startsWith(".") && name !== ".aps") {
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
async function collectDescriptorFiles(dir) {
|
|
24
|
+
const entries = await (0, promises_1.readdir)(dir, { withFileTypes: true });
|
|
25
|
+
const files = [];
|
|
26
|
+
for (const entry of entries) {
|
|
27
|
+
const absolutePath = node_path_1.default.join(dir, entry.name);
|
|
28
|
+
if (entry.isDirectory()) {
|
|
29
|
+
if (shouldSkipDirectory(entry.name)) {
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
files.push(...(await collectDescriptorFiles(absolutePath)));
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
if (entry.isFile() && exports.DESCRIPTOR_SUFFIXES.some((suffix) => entry.name.endsWith(suffix))) {
|
|
36
|
+
files.push(absolutePath);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return files;
|
|
40
|
+
}
|
|
41
|
+
async function discoverDescriptorFiles(cwd) {
|
|
42
|
+
const descriptorPaths = await collectDescriptorFiles(cwd);
|
|
43
|
+
return descriptorPaths
|
|
44
|
+
.map((filePath) => normalizeSlashes(node_path_1.default.relative(cwd, filePath)))
|
|
45
|
+
.sort((a, b) => a.localeCompare(b));
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=descriptor-discovery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"descriptor-discovery.js","sourceRoot":"","sources":["../../../src/implementation/descriptors/descriptor-discovery.ts"],"names":[],"mappings":";;;;;;AA4CA,0DAKC;AAjDD,0DAA6B;AAC7B,+CAA2C;AAE9B,QAAA,mBAAmB,GAAG,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC;AAEjE,SAAS,gBAAgB,CAAC,KAAa;IACrC,OAAO,KAAK,CAAC,KAAK,CAAC,mBAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACzC,CAAC;AAED,SAAS,mBAAmB,CAAC,IAAY;IACvC,IAAI,IAAI,KAAK,cAAc,IAAI,IAAI,KAAK,MAAM,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;QAClE,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;QAC5C,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED,KAAK,UAAU,sBAAsB,CAAC,GAAW;IAC/C,MAAM,OAAO,GAAG,MAAM,IAAA,kBAAO,EAAC,GAAG,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;IAC5D,MAAM,KAAK,GAAa,EAAE,CAAC;IAE3B,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC5B,MAAM,YAAY,GAAG,mBAAI,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QAEhD,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;YACxB,IAAI,mBAAmB,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;gBACpC,SAAS;YACX,CAAC;YACD,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,sBAAsB,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;YAC5D,SAAS;QACX,CAAC;QAED,IAAI,KAAK,CAAC,MAAM,EAAE,IAAI,2BAAmB,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;YACxF,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAEM,KAAK,UAAU,uBAAuB,CAAC,GAAW;IACvD,MAAM,eAAe,GAAG,MAAM,sBAAsB,CAAC,GAAG,CAAC,CAAC;IAC1D,OAAO,eAAe;SACnB,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,gBAAgB,CAAC,mBAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC;SACjE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.loadMimirDescriptors = loadMimirDescriptors;
|
|
7
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
+
const yaml_1 = require("yaml");
|
|
9
|
+
const fs_1 = require("../io/fs");
|
|
10
|
+
const json_1 = require("../io/json");
|
|
11
|
+
const descriptor_discovery_1 = require("./descriptor-discovery");
|
|
12
|
+
const SUPPORTED_KINDS = new Set([
|
|
13
|
+
"component",
|
|
14
|
+
"function",
|
|
15
|
+
"api",
|
|
16
|
+
"service",
|
|
17
|
+
"model",
|
|
18
|
+
"event",
|
|
19
|
+
"rule",
|
|
20
|
+
"example",
|
|
21
|
+
"pattern",
|
|
22
|
+
"migration"
|
|
23
|
+
]);
|
|
24
|
+
function readStringArray(value, field, sourceRef) {
|
|
25
|
+
if (value === undefined) {
|
|
26
|
+
return [];
|
|
27
|
+
}
|
|
28
|
+
if (!Array.isArray(value) || value.some((item) => typeof item !== "string")) {
|
|
29
|
+
throw new Error(`${sourceRef}: '${field}' must be an array of strings`);
|
|
30
|
+
}
|
|
31
|
+
return value;
|
|
32
|
+
}
|
|
33
|
+
function readPropsMap(value, field, sourceRef) {
|
|
34
|
+
if (value === undefined) {
|
|
35
|
+
return {};
|
|
36
|
+
}
|
|
37
|
+
if (!Array.isArray(value)) {
|
|
38
|
+
throw new Error(`${sourceRef}: '${field}' must be an array of prop objects`);
|
|
39
|
+
}
|
|
40
|
+
const props = {};
|
|
41
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
42
|
+
const item = value[index];
|
|
43
|
+
if (!(0, json_1.isObject)(item) || typeof item.name !== "string" || item.name.trim() === "") {
|
|
44
|
+
throw new Error(`${sourceRef}: '${field}[${index}]' must include a non-empty 'name'`);
|
|
45
|
+
}
|
|
46
|
+
const name = item.name.trim();
|
|
47
|
+
props[name] = {
|
|
48
|
+
name,
|
|
49
|
+
type: typeof item.type === "string" ? item.type : undefined,
|
|
50
|
+
required: typeof item.required === "boolean" ? item.required : undefined
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
return props;
|
|
54
|
+
}
|
|
55
|
+
function readResource(value, sourceRef, index) {
|
|
56
|
+
if (!(0, json_1.isObject)(value)) {
|
|
57
|
+
throw new Error(`${sourceRef}: resources[${index}] must be an object`);
|
|
58
|
+
}
|
|
59
|
+
const resource = value;
|
|
60
|
+
if (typeof resource.kind !== "string" || resource.kind.trim() === "") {
|
|
61
|
+
throw new Error(`${sourceRef}: resources[${index}].kind must be a non-empty string`);
|
|
62
|
+
}
|
|
63
|
+
if (typeof resource.name !== "string" || resource.name.trim() === "") {
|
|
64
|
+
throw new Error(`${sourceRef}: resources[${index}].name must be a non-empty string`);
|
|
65
|
+
}
|
|
66
|
+
const kind = resource.kind.trim().toLowerCase();
|
|
67
|
+
if (!SUPPORTED_KINDS.has(kind)) {
|
|
68
|
+
throw new Error(`${sourceRef}: resources[${index}].kind '${resource.kind}' is not supported by the descriptor contract`);
|
|
69
|
+
}
|
|
70
|
+
const autoNode = (0, json_1.isObject)(resource.auto) ? resource.auto : {};
|
|
71
|
+
const humanNode = (0, json_1.isObject)(resource.human) ? resource.human : {};
|
|
72
|
+
const sourceCandidate = (0, json_1.isObject)(autoNode.source)
|
|
73
|
+
? autoNode.source
|
|
74
|
+
: (0, json_1.isObject)(resource.source)
|
|
75
|
+
? resource.source
|
|
76
|
+
: {};
|
|
77
|
+
const source = (0, json_1.isObject)(sourceCandidate)
|
|
78
|
+
? {
|
|
79
|
+
file: typeof sourceCandidate.file === "string" ? sourceCandidate.file : undefined,
|
|
80
|
+
symbol: typeof sourceCandidate.symbol === "string" ? sourceCandidate.symbol : undefined,
|
|
81
|
+
public: typeof sourceCandidate.public === "boolean" ? sourceCandidate.public : undefined
|
|
82
|
+
}
|
|
83
|
+
: {};
|
|
84
|
+
const props = readPropsMap(autoNode.props ?? resource.props, "auto.props", sourceRef);
|
|
85
|
+
const variants = readStringArray(autoNode.variants ?? resource.variants, "auto.variants", sourceRef);
|
|
86
|
+
const storyFiles = readStringArray(autoNode.storyFiles ?? resource.storyFiles, "auto.storyFiles", sourceRef);
|
|
87
|
+
return {
|
|
88
|
+
kind,
|
|
89
|
+
name: resource.name,
|
|
90
|
+
id: typeof resource.id === "string" ? resource.id : undefined,
|
|
91
|
+
auto: {
|
|
92
|
+
source,
|
|
93
|
+
props,
|
|
94
|
+
variants,
|
|
95
|
+
storyFiles
|
|
96
|
+
},
|
|
97
|
+
human: {
|
|
98
|
+
description: typeof humanNode.description === "string"
|
|
99
|
+
? humanNode.description
|
|
100
|
+
: typeof resource.description === "string"
|
|
101
|
+
? resource.description
|
|
102
|
+
: "",
|
|
103
|
+
whenToUse: readStringArray(humanNode.whenToUse ?? resource.whenToUse, "human.whenToUse", sourceRef),
|
|
104
|
+
whenNotToUse: readStringArray(humanNode.whenNotToUse ?? resource.whenNotToUse, "human.whenNotToUse", sourceRef)
|
|
105
|
+
},
|
|
106
|
+
sourceRef
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
async function loadMimirDescriptors(cwd) {
|
|
110
|
+
const descriptorFiles = await (0, descriptor_discovery_1.discoverDescriptorFiles)(cwd);
|
|
111
|
+
const resources = [];
|
|
112
|
+
const warnings = [];
|
|
113
|
+
for (const sourceRef of descriptorFiles) {
|
|
114
|
+
const descriptorPath = node_path_1.default.join(cwd, sourceRef);
|
|
115
|
+
let raw;
|
|
116
|
+
try {
|
|
117
|
+
raw = (0, yaml_1.parse)(await (0, fs_1.readText)(descriptorPath));
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
121
|
+
warnings.push(`Invalid descriptor YAML at ${sourceRef}: ${message}`);
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
if (!(0, json_1.isObject)(raw)) {
|
|
125
|
+
warnings.push(`${sourceRef}: descriptor must be a YAML object`);
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
const schemaVersion = raw.schemaVersion;
|
|
129
|
+
if (schemaVersion !== 1) {
|
|
130
|
+
warnings.push(`${sourceRef}: schemaVersion must be 1`);
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
if (!Array.isArray(raw.resources)) {
|
|
134
|
+
warnings.push(`${sourceRef}: resources must be an array`);
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
for (let index = 0; index < raw.resources.length; index += 1) {
|
|
138
|
+
try {
|
|
139
|
+
const resource = readResource(raw.resources[index], sourceRef, index);
|
|
140
|
+
if (resource) {
|
|
141
|
+
resources.push(resource);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
catch (error) {
|
|
145
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
146
|
+
warnings.push(message);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return {
|
|
151
|
+
descriptorFiles,
|
|
152
|
+
resources,
|
|
153
|
+
warnings
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
//# sourceMappingURL=descriptor-repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"descriptor-repository.js","sourceRoot":"","sources":["../../../src/implementation/descriptors/descriptor-repository.ts"],"names":[],"mappings":";;;;;AAoKA,oDAmDC;AAvND,0DAA6B;AAC7B,+BAA6B;AAC7B,iCAAoC;AACpC,qCAAsC;AAGtC,iEAAiE;AAEjE,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC;IAC9B,WAAW;IACX,UAAU;IACV,KAAK;IACL,SAAS;IACT,OAAO;IACP,OAAO;IACP,MAAM;IACN,SAAS;IACT,SAAS;IACT,WAAW;CACZ,CAAC,CAAC;AAiBH,SAAS,eAAe,CAAC,KAAc,EAAE,KAAa,EAAE,SAAiB;IACvE,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC,EAAE,CAAC;QAC5E,MAAM,IAAI,KAAK,CAAC,GAAG,SAAS,MAAM,KAAK,+BAA+B,CAAC,CAAC;IAC1E,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,YAAY,CAAC,KAAc,EAAE,KAAa,EAAE,SAAiB;IACpE,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,EAAE,CAAC;IACZ,CAAC;I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CAAC,IAAI,CAAC,GAAG,SAAS,2BAA2B,CAAC,CAAC;YACvD,SAAS;QACX,CAAC;QAED,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;YAClC,QAAQ,CAAC,IAAI,CAAC,GAAG,SAAS,8BAA8B,CAAC,CAAC;YAC1D,SAAS;QACX,CAAC;QAED,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,GAAG,CAAC,SAAS,CAAC,MAAM,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;YAC7D,IAAI,CAAC;gBACH,MAAM,QAAQ,GAAG,YAAY,CAAC,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;gBACtE,IAAI,QAAQ,EAAE,CAAC;oBACb,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;gBAC3B,CAAC;YACH,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBACvE,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACzB,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO;QACL,eAAe;QACf,SAAS;QACT,QAAQ;KACT,CAAC;AACJ,CAAC"}
|
|
@@ -2,5 +2,6 @@ import type { GenerateReport } from "./types";
|
|
|
2
2
|
type GenerateOptions = {
|
|
3
3
|
force?: boolean;
|
|
4
4
|
};
|
|
5
|
+
export declare function compileApsFromDescriptors(cwd: string, options?: GenerateOptions): Promise<GenerateReport>;
|
|
5
6
|
export declare function generateApsFromEvidence(cwd: string, options?: GenerateOptions): Promise<GenerateReport>;
|
|
6
7
|
export {};
|
|
@@ -3,26 +3,70 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.compileApsFromDescriptors = compileApsFromDescriptors;
|
|
6
7
|
exports.generateApsFromEvidence = generateApsFromEvidence;
|
|
7
8
|
const node_path_1 = __importDefault(require("node:path"));
|
|
8
9
|
const fs_1 = require("../io/fs");
|
|
9
|
-
const json_1 = require("../io/json");
|
|
10
10
|
const compatibility_1 = require("../../protocol/compatibility");
|
|
11
11
|
const governance_1 = require("../../protocol/governance");
|
|
12
|
-
const readme_extractor_1 = require("./extractors/readme-extractor");
|
|
13
|
-
const storybook_extractor_1 = require("./extractors/storybook-extractor");
|
|
14
|
-
const typescript_extractor_1 = require("./extractors/typescript-extractor");
|
|
15
|
-
const component_builder_1 = require("./resource-builders/component-builder");
|
|
16
12
|
const example_builder_1 = require("./resource-builders/example-builder");
|
|
17
|
-
const
|
|
13
|
+
const descriptor_repository_1 = require("../descriptors/descriptor-repository");
|
|
18
14
|
const resource_identity_1 = require("../resource-identity");
|
|
19
|
-
const
|
|
15
|
+
const provenance_builder_1 = require("./provenance/provenance-builder");
|
|
20
16
|
function hasHumanMetadata(component) {
|
|
21
17
|
return component.description.trim() !== "" && component.whenToUse.length > 0 && component.whenNotToUse.length > 0;
|
|
22
18
|
}
|
|
23
19
|
function toUniqueSorted(values) {
|
|
24
20
|
return [...new Set(values)].sort((a, b) => a.localeCompare(b));
|
|
25
21
|
}
|
|
22
|
+
function buildComponentFromDescriptor(packageName, descriptor) {
|
|
23
|
+
const sourceFile = descriptor.auto.source.file ?? descriptor.sourceRef;
|
|
24
|
+
const storyFiles = descriptor.auto.storyFiles;
|
|
25
|
+
const variants = descriptor.auto.variants;
|
|
26
|
+
const authoredDescription = descriptor.human.description.trim();
|
|
27
|
+
const evidenceByField = {
|
|
28
|
+
id: { evidence: [(0, provenance_builder_1.fromPackageJson)()] },
|
|
29
|
+
name: { evidence: [(0, provenance_builder_1.fromTypeScript)(sourceFile)] },
|
|
30
|
+
package: { evidence: [(0, provenance_builder_1.fromPackageJson)()] },
|
|
31
|
+
import: { evidence: [(0, provenance_builder_1.fromTypeScript)(sourceFile)] },
|
|
32
|
+
description: {
|
|
33
|
+
evidence: authoredDescription !== "" ? [(0, provenance_builder_1.fromHumanKnowledge)(descriptor.sourceRef)] : [(0, provenance_builder_1.missingHumanSource)("description")]
|
|
34
|
+
},
|
|
35
|
+
props: { evidence: [(0, provenance_builder_1.fromTypeScript)(sourceFile)] },
|
|
36
|
+
variants: {
|
|
37
|
+
evidence: variants.length > 0
|
|
38
|
+
? storyFiles.length > 0
|
|
39
|
+
? storyFiles.map((file) => (0, provenance_builder_1.fromStorybook)(file))
|
|
40
|
+
: [(0, provenance_builder_1.fromTypeScript)(sourceFile)]
|
|
41
|
+
: [(0, provenance_builder_1.fromTypeScript)(sourceFile)]
|
|
42
|
+
},
|
|
43
|
+
whenToUse: {
|
|
44
|
+
evidence: descriptor.human.whenToUse.length > 0
|
|
45
|
+
? [(0, provenance_builder_1.fromHumanKnowledge)(descriptor.sourceRef)]
|
|
46
|
+
: [(0, provenance_builder_1.missingHumanSource)("whenToUse")]
|
|
47
|
+
},
|
|
48
|
+
whenNotToUse: {
|
|
49
|
+
evidence: descriptor.human.whenNotToUse.length > 0
|
|
50
|
+
? [(0, provenance_builder_1.fromHumanKnowledge)(descriptor.sourceRef)]
|
|
51
|
+
: [(0, provenance_builder_1.missingHumanSource)("whenNotToUse")]
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
return {
|
|
55
|
+
type: "component",
|
|
56
|
+
id: descriptor.id ?? (0, resource_identity_1.createComponentResourceId)(packageName, descriptor.name),
|
|
57
|
+
name: descriptor.name,
|
|
58
|
+
package: packageName,
|
|
59
|
+
import: descriptor.auto.source.symbol ?? descriptor.name,
|
|
60
|
+
description: authoredDescription,
|
|
61
|
+
props: descriptor.auto.props,
|
|
62
|
+
variants,
|
|
63
|
+
whenToUse: descriptor.human.whenToUse,
|
|
64
|
+
whenNotToUse: descriptor.human.whenNotToUse,
|
|
65
|
+
governance: {
|
|
66
|
+
fields: evidenceByField
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
}
|
|
26
70
|
async function readPackageName(cwd) {
|
|
27
71
|
const packageJsonPath = node_path_1.default.join(cwd, "package.json");
|
|
28
72
|
const packageJson = await (0, fs_1.readJson)(packageJsonPath);
|
|
@@ -31,44 +75,7 @@ async function readPackageName(cwd) {
|
|
|
31
75
|
}
|
|
32
76
|
return packageJson.name;
|
|
33
77
|
}
|
|
34
|
-
async function
|
|
35
|
-
const warnings = [];
|
|
36
|
-
const packageJsonPath = node_path_1.default.join(cwd, "package.json");
|
|
37
|
-
const packageJson = await (0, fs_1.readJson)(packageJsonPath);
|
|
38
|
-
let changed = false;
|
|
39
|
-
if (!(0, json_1.isObject)(packageJson.aps)) {
|
|
40
|
-
packageJson.aps = {};
|
|
41
|
-
changed = true;
|
|
42
|
-
}
|
|
43
|
-
const aps = packageJson.aps;
|
|
44
|
-
if (aps.version === undefined) {
|
|
45
|
-
aps.version = 1;
|
|
46
|
-
changed = true;
|
|
47
|
-
warnings.push("APS config version was missing and has been set to 1.");
|
|
48
|
-
}
|
|
49
|
-
if (aps.manifest !== APS_MANIFEST_RELATIVE_PATH) {
|
|
50
|
-
const previous = typeof aps.manifest === "string" ? aps.manifest : "(not set)";
|
|
51
|
-
aps.manifest = APS_MANIFEST_RELATIVE_PATH;
|
|
52
|
-
changed = true;
|
|
53
|
-
warnings.push(`APS manifest path updated from '${previous}' to '${APS_MANIFEST_RELATIVE_PATH}' for consistency with generated resources.`);
|
|
54
|
-
}
|
|
55
|
-
if ((0, json_1.isObject)(packageJson.exports)) {
|
|
56
|
-
const exportsMap = packageJson.exports;
|
|
57
|
-
if (exportsMap["./package.json"] !== "./package.json") {
|
|
58
|
-
exportsMap["./package.json"] = "./package.json";
|
|
59
|
-
changed = true;
|
|
60
|
-
warnings.push("Added exports['./package.json'] for provider discovery compatibility.");
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
else if (packageJson.exports !== undefined) {
|
|
64
|
-
warnings.push("Package exports is not an object. Could not add exports['./package.json']; configure it manually for discovery compatibility.");
|
|
65
|
-
}
|
|
66
|
-
if (changed) {
|
|
67
|
-
await (0, fs_1.writeJson)(packageJsonPath, packageJson);
|
|
68
|
-
}
|
|
69
|
-
return warnings;
|
|
70
|
-
}
|
|
71
|
-
async function generateApsFromEvidence(cwd, options = {}) {
|
|
78
|
+
async function compileApsFromDescriptors(cwd, options = {}) {
|
|
72
79
|
const packageName = await readPackageName(cwd);
|
|
73
80
|
const outputDir = node_path_1.default.join(cwd, "dist", "aps");
|
|
74
81
|
const manifestPath = node_path_1.default.join(outputDir, "manifest.json");
|
|
@@ -77,22 +84,22 @@ async function generateApsFromEvidence(cwd, options = {}) {
|
|
|
77
84
|
if (alreadyExists && !options.force) {
|
|
78
85
|
throw new Error("APS resources already exist in dist/aps. Re-run with --force to replace existing generated resources.");
|
|
79
86
|
}
|
|
80
|
-
const discoverabilityWarnings = await ensureProviderDiscoverability(cwd);
|
|
81
87
|
await (0, fs_1.ensureDir)(outputDir);
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
]);
|
|
87
|
-
const components = await Promise.all(typescriptComponents.map(async (component) => {
|
|
88
|
-
const resourceId = (0, resource_identity_1.createComponentResourceId)(component.packageName, component.name);
|
|
89
|
-
const authored = await (0, knowledge_loader_1.loadComponentKnowledge)(cwd, resourceId);
|
|
90
|
-
return (0, component_builder_1.buildComponentResource)(component, storybookFacts, readmeFacts, authored);
|
|
91
|
-
}));
|
|
88
|
+
const descriptorResult = await (0, descriptor_repository_1.loadMimirDescriptors)(cwd);
|
|
89
|
+
const unsupportedKinds = toUniqueSorted(descriptorResult.resources.filter((resource) => resource.kind !== "component").map((resource) => resource.kind));
|
|
90
|
+
const componentDescriptors = descriptorResult.resources.filter((resource) => resource.kind === "component");
|
|
91
|
+
const components = await Promise.all(componentDescriptors.map(async (descriptor) => buildComponentFromDescriptor(packageName, descriptor)));
|
|
92
92
|
const exampleResult = (0, example_builder_1.buildExamplesNotImplemented)();
|
|
93
|
+
const descriptorWarnings = [...descriptorResult.warnings];
|
|
94
|
+
if (descriptorResult.descriptorFiles.length === 0) {
|
|
95
|
+
descriptorWarnings.push("No *.mimir.yaml descriptors found. Run 'mimir author' to scaffold descriptor files.");
|
|
96
|
+
}
|
|
97
|
+
if (unsupportedKinds.length > 0) {
|
|
98
|
+
descriptorWarnings.push(`Descriptor resources ignored by generator v1 (unsupported kinds): ${unsupportedKinds.join(", ")}.`);
|
|
99
|
+
}
|
|
93
100
|
const output = {
|
|
94
101
|
components,
|
|
95
|
-
warnings: [...exampleResult.warnings, ...
|
|
102
|
+
warnings: [...exampleResult.warnings, ...descriptorWarnings],
|
|
96
103
|
missingHumanMetadata: toUniqueSorted(components
|
|
97
104
|
.filter((component) => !hasHumanMetadata(component))
|
|
98
105
|
.map((component) => component.name))
|
|
@@ -124,4 +131,7 @@ async function generateApsFromEvidence(cwd, options = {}) {
|
|
|
124
131
|
}
|
|
125
132
|
};
|
|
126
133
|
}
|
|
134
|
+
async function generateApsFromEvidence(cwd, options = {}) {
|
|
135
|
+
return compileApsFromDescriptors(cwd, options);
|
|
136
|
+
}
|
|
127
137
|
//# sourceMappingURL=generate-service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-service.js","sourceRoot":"","sources":["../../../src/implementation/generation/generate-service.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"generate-service.js","sourceRoot":"","sources":["../../../src/implementation/generation/generate-service.ts"],"names":[],"mappings":";;;;;AAoGA,8DAmFC;AAED,0DAKC;AA9LD,0DAA6B;AAC7B,iCAAsE;AACtE,gEAAmE;AACnE,0DAA+D;AAC/D,yEAAkF;AAElF,gFAA4E;AAE5E,4DAAiE;AACjE,wEAMyC;AAUzC,SAAS,gB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@ import type { FieldEvidence } from "../types";
|
|
|
2
2
|
export declare function fromTypeScript(sourceRef: string): FieldEvidence;
|
|
3
3
|
export declare function fromPackageJson(): FieldEvidence;
|
|
4
4
|
export declare function fromStorybook(sourceRef: string): FieldEvidence;
|
|
5
|
-
export declare function fromReadme(sourceRef: string): FieldEvidence;
|
|
6
5
|
export declare function fromHumanKnowledge(sourceRef: string): FieldEvidence;
|
|
7
6
|
export declare function missingHumanSource(fieldName: string): FieldEvidence;
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.fromTypeScript = fromTypeScript;
|
|
4
4
|
exports.fromPackageJson = fromPackageJson;
|
|
5
5
|
exports.fromStorybook = fromStorybook;
|
|
6
|
-
exports.fromReadme = fromReadme;
|
|
7
6
|
exports.fromHumanKnowledge = fromHumanKnowledge;
|
|
8
7
|
exports.missingHumanSource = missingHumanSource;
|
|
9
8
|
function fromTypeScript(sourceRef) {
|
|
@@ -27,13 +26,6 @@ function fromStorybook(sourceRef) {
|
|
|
27
26
|
confidence: "medium"
|
|
28
27
|
};
|
|
29
28
|
}
|
|
30
|
-
function fromReadme(sourceRef) {
|
|
31
|
-
return {
|
|
32
|
-
sourceType: "readme",
|
|
33
|
-
sourceRef,
|
|
34
|
-
confidence: "medium"
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
29
|
function fromHumanKnowledge(sourceRef) {
|
|
38
30
|
return {
|
|
39
31
|
sourceType: "human",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provenance-builder.js","sourceRoot":"","sources":["../../../../src/implementation/generation/provenance/provenance-builder.ts"],"names":[],"mappings":";;AAEA,wCAMC;AAED,0CAMC;AAED,sCAMC;AAED,
|
|
1
|
+
{"version":3,"file":"provenance-builder.js","sourceRoot":"","sources":["../../../../src/implementation/generation/provenance/provenance-builder.ts"],"names":[],"mappings":";;AAEA,wCAMC;AAED,0CAMC;AAED,sCAMC;AAED,gDAMC;AAED,gDAOC;AAvCD,SAAgB,cAAc,CAAC,SAAiB;IAC9C,OAAO;QACL,UAAU,EAAE,YAAY;QACxB,SAAS;QACT,UAAU,EAAE,MAAM;KACnB,CAAC;AACJ,CAAC;AAED,SAAgB,eAAe;IAC7B,OAAO;QACL,UAAU,EAAE,SAAS;QACrB,SAAS,EAAE,cAAc;QACzB,UAAU,EAAE,MAAM;KACnB,CAAC;AACJ,CAAC;AAED,SAAgB,aAAa,CAAC,SAAiB;IAC7C,OAAO;QACL,UAAU,EAAE,WAAW;QACvB,SAAS;QACT,UAAU,EAAE,QAAQ;KACrB,CAAC;AACJ,CAAC;AAED,SAAgB,kBAAkB,CAAC,SAAiB;IAClD,OAAO;QACL,UAAU,EAAE,OAAO;QACnB,SAAS;QACT,UAAU,EAAE,MAAM;KACnB,CAAC;AACJ,CAAC;AAED,SAAgB,kBAAkB,CAAC,SAAiB;IAClD,OAAO;QACL,UAAU,EAAE,OAAO;QACnB,SAAS,EAAE,SAAS;QACpB,UAAU,EAAE,KAAK;QACjB,IAAI,EAAE,sCAAsC,SAAS,GAAG;KACzD,CAAC;AACJ,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ExtractedProp } from "../contracts/resource";
|
|
1
2
|
export type EvidenceConfidence = "high" | "medium" | "low";
|
|
2
3
|
export type FieldEvidence = {
|
|
3
4
|
sourceType: string;
|
|
@@ -9,25 +10,6 @@ export type GeneratedField<T> = {
|
|
|
9
10
|
value: T;
|
|
10
11
|
evidence: FieldEvidence[];
|
|
11
12
|
};
|
|
12
|
-
export type ExtractedProp = {
|
|
13
|
-
name: string;
|
|
14
|
-
type?: string;
|
|
15
|
-
required?: boolean;
|
|
16
|
-
};
|
|
17
|
-
export type ExtractedComponentFact = {
|
|
18
|
-
name: string;
|
|
19
|
-
filePath: string;
|
|
20
|
-
importName: string;
|
|
21
|
-
packageName: string;
|
|
22
|
-
props: Record<string, ExtractedProp>;
|
|
23
|
-
};
|
|
24
|
-
export type StorybookFacts = {
|
|
25
|
-
variantsByComponent: Record<string, string[]>;
|
|
26
|
-
storyFilesByComponent: Record<string, string[]>;
|
|
27
|
-
};
|
|
28
|
-
export type ReadmeFacts = {
|
|
29
|
-
descriptionsByComponent: Record<string, string>;
|
|
30
|
-
};
|
|
31
13
|
export type GeneratedComponentResource = {
|
|
32
14
|
type: "component";
|
|
33
15
|
id: string;
|
|
@@ -5,7 +5,7 @@ const generate_service_1 = require("../generation/generate-service");
|
|
|
5
5
|
exports.apsGenerator = {
|
|
6
6
|
name: "aps",
|
|
7
7
|
async generate(cwd, options) {
|
|
8
|
-
return (0, generate_service_1.
|
|
8
|
+
return (0, generate_service_1.compileApsFromDescriptors)(cwd, options ?? {});
|
|
9
9
|
}
|
|
10
10
|
};
|
|
11
11
|
//# sourceMappingURL=aps-generator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aps-generator.js","sourceRoot":"","sources":["../../../src/implementation/generators/aps-generator.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"aps-generator.js","sourceRoot":"","sources":["../../../src/implementation/generators/aps-generator.ts"],"names":[],"mappings":";;;AAAA,qEAA2E;AAQ9D,QAAA,YAAY,GAAuD;IAC9E,IAAI,EAAE,KAAK;IACX,KAAK,CAAC,QAAQ,CAAC,GAAW,EAAE,OAA4B;QACtD,OAAO,IAAA,4CAAyB,EAAC,GAAG,EAAE,OAAO,IAAI,EAAE,CAAC,CAAC;IACvD,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.extractStorybookFacts = extractStorybookFacts;
|
|
7
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
+
const promises_1 = require("node:fs/promises");
|
|
9
|
+
const fs_1 = require("../io/fs");
|
|
10
|
+
function normalizeSlashes(value) {
|
|
11
|
+
return value.split(node_path_1.default.sep).join("/");
|
|
12
|
+
}
|
|
13
|
+
async function collectStoryFiles(dir) {
|
|
14
|
+
const entries = await (0, promises_1.readdir)(dir, { withFileTypes: true });
|
|
15
|
+
const files = [];
|
|
16
|
+
for (const entry of entries) {
|
|
17
|
+
const absolutePath = node_path_1.default.join(dir, entry.name);
|
|
18
|
+
if (entry.isDirectory()) {
|
|
19
|
+
if (entry.name === "node_modules" || entry.name === "dist" || entry.name.startsWith(".")) {
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
files.push(...(await collectStoryFiles(absolutePath)));
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
if (entry.isFile() && entry.name.includes(".stories.")) {
|
|
26
|
+
files.push(absolutePath);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return files;
|
|
30
|
+
}
|
|
31
|
+
async function extractStorybookFacts(cwd) {
|
|
32
|
+
const files = await collectStoryFiles(cwd);
|
|
33
|
+
const variantsByComponent = {};
|
|
34
|
+
const storyFilesByComponent = {};
|
|
35
|
+
for (const file of files) {
|
|
36
|
+
const content = await (0, fs_1.readText)(file);
|
|
37
|
+
const componentMatch = /component\s*:\s*([A-Z][A-Za-z0-9_]*)/.exec(content);
|
|
38
|
+
if (!componentMatch) {
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
const componentName = componentMatch[1];
|
|
42
|
+
if (!variantsByComponent[componentName]) {
|
|
43
|
+
variantsByComponent[componentName] = [];
|
|
44
|
+
storyFilesByComponent[componentName] = [];
|
|
45
|
+
}
|
|
46
|
+
const relativeFile = normalizeSlashes(node_path_1.default.relative(cwd, file));
|
|
47
|
+
storyFilesByComponent[componentName].push(relativeFile);
|
|
48
|
+
const variantPattern = /export\s+const\s+([A-Za-z][A-Za-z0-9_]*)\s*[:=]/g;
|
|
49
|
+
let match;
|
|
50
|
+
while ((match = variantPattern.exec(content)) !== null) {
|
|
51
|
+
const variantName = match[1];
|
|
52
|
+
if (!variantsByComponent[componentName].includes(variantName)) {
|
|
53
|
+
variantsByComponent[componentName].push(variantName);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
variantsByComponent[componentName].sort((a, b) => a.localeCompare(b));
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
variantsByComponent,
|
|
60
|
+
storyFilesByComponent
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=storybook-extractor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storybook-extractor.js","sourceRoot":"","sources":["../../../src/implementation/resource-discovery/storybook-extractor.ts"],"names":[],"mappings":";;;;;AA+BA,sDAqCC;AApED,0DAA6B;AAC7B,+CAA2C;AAC3C,iCAAoC;AAGpC,SAAS,gBAAgB,CAAC,KAAa;IACrC,OAAO,KAAK,CAAC,KAAK,CAAC,mBAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACzC,CAAC;AAED,KAAK,UAAU,iBAAiB,CAAC,GAAW;IAC1C,MAAM,OAAO,GAAG,MAAM,IAAA,kBAAO,EAAC,GAAG,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;IAC5D,MAAM,KAAK,GAAa,EAAE,CAAC;IAE3B,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC5B,MAAM,YAAY,GAAG,mBAAI,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QAChD,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;YACxB,IAAI,KAAK,CAAC,IAAI,KAAK,cAAc,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;gBACzF,SAAS;YACX,CAAC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GAAG,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;YACvD,MAAM,WAAW,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;YAC7B,IAAI,CAAC,mBAAmB,CAAC,aAAa,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;gBAC9D,mBAAmB,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YACvD,CAAC;QACH,CAAC;QAED,mBAAmB,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;IACxE,CAAC;IAED,OAAO;QACL,mBAAmB;QACnB,qBAAqB;KACtB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.extractTypeScriptComponents = extractTypeScriptComponents;
|
|
7
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
+
const promises_1 = require("node:fs/promises");
|
|
9
|
+
const fs_1 = require("../io/fs");
|
|
10
|
+
const TS_EXTENSIONS = new Set([".ts", ".tsx"]);
|
|
11
|
+
function isPascalCase(name) {
|
|
12
|
+
return /^[A-Z][A-Za-z0-9]*$/.test(name);
|
|
13
|
+
}
|
|
14
|
+
function normalizeSlashes(value) {
|
|
15
|
+
return value.split(node_path_1.default.sep).join("/");
|
|
16
|
+
}
|
|
17
|
+
async function collectFiles(dir) {
|
|
18
|
+
const entries = await (0, promises_1.readdir)(dir, { withFileTypes: true });
|
|
19
|
+
const files = [];
|
|
20
|
+
for (const entry of entries) {
|
|
21
|
+
const absolutePath = node_path_1.default.join(dir, entry.name);
|
|
22
|
+
if (entry.isDirectory()) {
|
|
23
|
+
if (entry.name === "node_modules" || entry.name === "dist" || entry.name.startsWith(".")) {
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
files.push(...(await collectFiles(absolutePath)));
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
if (entry.isFile() &&
|
|
30
|
+
TS_EXTENSIONS.has(node_path_1.default.extname(entry.name)) &&
|
|
31
|
+
!entry.name.includes(".stories.")) {
|
|
32
|
+
files.push(absolutePath);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return files;
|
|
36
|
+
}
|
|
37
|
+
function extractExportedNames(content) {
|
|
38
|
+
const names = new Set();
|
|
39
|
+
const patterns = [
|
|
40
|
+
/export\s+function\s+([A-Z][A-Za-z0-9_]*)\s*\(/g,
|
|
41
|
+
/export\s+const\s+([A-Z][A-Za-z0-9_]*)\s*[:=]/g,
|
|
42
|
+
/export\s+class\s+([A-Z][A-Za-z0-9_]*)\s+/g,
|
|
43
|
+
/export\s+\{\s*([^}]+)\s*\}/g
|
|
44
|
+
];
|
|
45
|
+
for (const pattern of patterns) {
|
|
46
|
+
let match;
|
|
47
|
+
while ((match = pattern.exec(content)) !== null) {
|
|
48
|
+
if (pattern.source.includes("[^}]+")) {
|
|
49
|
+
const tokens = match[1].split(",").map((item) => item.trim());
|
|
50
|
+
for (const token of tokens) {
|
|
51
|
+
const aliasParts = token.split(/\s+as\s+/i).map((part) => part.trim());
|
|
52
|
+
const candidate = aliasParts[aliasParts.length - 1];
|
|
53
|
+
if (isPascalCase(candidate)) {
|
|
54
|
+
names.add(candidate);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
const candidate = match[1];
|
|
60
|
+
if (isPascalCase(candidate)) {
|
|
61
|
+
names.add(candidate);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return [...names].sort((a, b) => a.localeCompare(b));
|
|
67
|
+
}
|
|
68
|
+
function parsePropsBlock(block) {
|
|
69
|
+
const result = {};
|
|
70
|
+
const lines = block.split("\n");
|
|
71
|
+
for (const line of lines) {
|
|
72
|
+
const trimmed = line.trim();
|
|
73
|
+
const match = /^([A-Za-z_][A-Za-z0-9_]*)\??:\s*([^;]+);?$/.exec(trimmed);
|
|
74
|
+
if (!match) {
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
const propName = match[1];
|
|
78
|
+
const propType = match[2].trim();
|
|
79
|
+
const optional = trimmed.includes("?:");
|
|
80
|
+
result[propName] = {
|
|
81
|
+
name: propName,
|
|
82
|
+
type: propType,
|
|
83
|
+
required: !optional
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
return result;
|
|
87
|
+
}
|
|
88
|
+
function extractProps(content, componentName) {
|
|
89
|
+
const interfacePattern = new RegExp(`interface\\s+${componentName}Props\\s*\\{([\\s\\S]*?)\\}`, "m");
|
|
90
|
+
const typePattern = new RegExp(`type\\s+${componentName}Props\\s*=\\s*\\{([\\s\\S]*?)\\}`, "m");
|
|
91
|
+
const interfaceMatch = interfacePattern.exec(content);
|
|
92
|
+
if (interfaceMatch) {
|
|
93
|
+
return parsePropsBlock(interfaceMatch[1]);
|
|
94
|
+
}
|
|
95
|
+
const typeMatch = typePattern.exec(content);
|
|
96
|
+
if (typeMatch) {
|
|
97
|
+
return parsePropsBlock(typeMatch[1]);
|
|
98
|
+
}
|
|
99
|
+
return {};
|
|
100
|
+
}
|
|
101
|
+
async function extractTypeScriptComponents(cwd, packageName) {
|
|
102
|
+
const files = await collectFiles(cwd);
|
|
103
|
+
const components = [];
|
|
104
|
+
for (const filePath of files) {
|
|
105
|
+
const content = await (0, fs_1.readText)(filePath);
|
|
106
|
+
const exportedNames = extractExportedNames(content);
|
|
107
|
+
if (exportedNames.length === 0) {
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
const relativeFilePath = normalizeSlashes(node_path_1.default.relative(cwd, filePath));
|
|
111
|
+
for (const exportedName of exportedNames) {
|
|
112
|
+
components.push({
|
|
113
|
+
name: exportedName,
|
|
114
|
+
filePath: relativeFilePath,
|
|
115
|
+
importName: exportedName,
|
|
116
|
+
packageName,
|
|
117
|
+
props: extractProps(content, exportedName)
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
const unique = new Map();
|
|
122
|
+
for (const component of components) {
|
|
123
|
+
const key = component.name;
|
|
124
|
+
const previous = unique.get(key);
|
|
125
|
+
if (!previous) {
|
|
126
|
+
unique.set(key, component);
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
const previousScore = Object.keys(previous.props).length + (previous.filePath.endsWith("/index.ts") ? 0 : 1);
|
|
130
|
+
const candidateScore = Object.keys(component.props).length + (component.filePath.endsWith("/index.ts") ? 0 : 1);
|
|
131
|
+
if (candidateScore > previousScore) {
|
|
132
|
+
unique.set(key, component);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return [...unique.values()].sort((a, b) => a.name.localeCompare(b.name));
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=typescript-extractor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typescript-extractor.js","sourceRoot":"","sources":["../../../src/implementation/resource-discovery/typescript-extractor.ts"],"names":[],"mappings":";;;;;AAyHA,kEA+CC;AAxKD,0DAA6B;AAC7B,+CAA2C;AAC3C,iCAAoC;AAGpC,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;AAE/C,SAAS,YAAY,CAAC,IAAY;IAChC,OAAO,qBAAqB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1C,CAAC;AAED,SAAS,gBAAgB,CAAC,KAAa;IACrC,OAAO,KAAK,CAAC,KAAK,CAAC,mBAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG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,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACzF,MAAM,cAAc,GAClB,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,MAAM,GAAG,CAAC,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAE3F,IAAI,cAAc,GAAG,aAAa,EAAE,CAAC;YACnC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;QAC7B,CAAC;IACH,CAAC;IAED,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AAC3E,CAAC"}
|
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
type AuthoringOptions = {
|
|
2
2
|
dryRun?: boolean;
|
|
3
|
+
refreshAuto?: boolean;
|
|
4
|
+
deleteOrphans?: boolean;
|
|
5
|
+
interactive?: boolean;
|
|
6
|
+
ai?: boolean;
|
|
3
7
|
};
|
|
4
8
|
export type AuthoringReport = {
|
|
5
9
|
outputDir: string;
|
|
6
10
|
discoveredResources: number;
|
|
7
11
|
createdFiles: string[];
|
|
12
|
+
updatedFiles: string[];
|
|
8
13
|
existingFiles: string[];
|
|
9
14
|
plannedFiles: string[];
|
|
15
|
+
orphanedResources: string[];
|
|
16
|
+
deletedOrphans: string[];
|
|
17
|
+
pendingHumanResources: string[];
|
|
18
|
+
warnings: string[];
|
|
10
19
|
dryRun: boolean;
|
|
11
20
|
};
|
|
12
21
|
export declare function runAuthoringWorkflow(cwd: string, options?: AuthoringOptions): Promise<AuthoringReport>;
|
|
@@ -5,18 +5,98 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.runAuthoringWorkflow = runAuthoringWorkflow;
|
|
7
7
|
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
-
const
|
|
8
|
+
const yaml_1 = require("yaml");
|
|
9
|
+
const storybook_extractor_1 = require("../resource-discovery/storybook-extractor");
|
|
10
|
+
const typescript_extractor_1 = require("../resource-discovery/typescript-extractor");
|
|
11
|
+
const descriptor_discovery_1 = require("../descriptors/descriptor-discovery");
|
|
9
12
|
const fs_1 = require("../io/fs");
|
|
13
|
+
const json_1 = require("../io/json");
|
|
10
14
|
const resource_identity_1 = require("../resource-identity");
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
function normalizeSlashes(value) {
|
|
16
|
+
return value.split(node_path_1.default.sep).join("/");
|
|
17
|
+
}
|
|
18
|
+
function toDescriptorPath(filePath) {
|
|
19
|
+
const ext = node_path_1.default.extname(filePath);
|
|
20
|
+
const base = node_path_1.default.basename(filePath, ext);
|
|
21
|
+
return node_path_1.default.join(node_path_1.default.dirname(filePath), `${base}.mimir.yaml`);
|
|
22
|
+
}
|
|
23
|
+
function toPropsArray(props) {
|
|
24
|
+
return Object.values(props)
|
|
25
|
+
.sort((a, b) => a.name.localeCompare(b.name))
|
|
26
|
+
.map((prop) => ({
|
|
27
|
+
name: prop.name,
|
|
28
|
+
type: prop.type ?? "unknown",
|
|
29
|
+
required: prop.required !== false
|
|
30
|
+
}));
|
|
31
|
+
}
|
|
32
|
+
function buildManagedAutoBlock(seed) {
|
|
33
|
+
return {
|
|
34
|
+
source: {
|
|
35
|
+
file: seed.sourceFile,
|
|
36
|
+
symbol: seed.name,
|
|
37
|
+
public: true
|
|
38
|
+
},
|
|
39
|
+
props: toPropsArray(seed.props),
|
|
40
|
+
variants: [...new Set(seed.variants)].sort((a, b) => a.localeCompare(b)),
|
|
41
|
+
storyFiles: [...new Set(seed.storyFiles)].sort((a, b) => a.localeCompare(b))
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function patchManagedResourceAuto(existing, seed) {
|
|
45
|
+
// Hard boundary: preserve every field as-is and update only descriptor.auto.
|
|
46
|
+
return {
|
|
47
|
+
...existing,
|
|
48
|
+
auto: buildManagedAutoBlock(seed)
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function createManagedResource(seed) {
|
|
52
|
+
return {
|
|
53
|
+
kind: "component",
|
|
54
|
+
name: seed.name,
|
|
55
|
+
id: seed.id,
|
|
56
|
+
auto: buildManagedAutoBlock(seed),
|
|
57
|
+
human: {
|
|
58
|
+
description: "",
|
|
59
|
+
whenToUse: [],
|
|
60
|
+
whenNotToUse: []
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function resourceIdentity(resource) {
|
|
65
|
+
const id = typeof resource.id === "string" ? resource.id : null;
|
|
66
|
+
if (id && id.trim() !== "") {
|
|
67
|
+
return id;
|
|
68
|
+
}
|
|
69
|
+
const kind = typeof resource.kind === "string" ? resource.kind.trim().toLowerCase() : "";
|
|
70
|
+
const name = typeof resource.name === "string" ? resource.name.trim() : "";
|
|
71
|
+
if (kind && name) {
|
|
72
|
+
return `${kind}:${name}`;
|
|
73
|
+
}
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
function isComponentResource(resource) {
|
|
77
|
+
return typeof resource.kind === "string" && resource.kind.trim().toLowerCase() === "component";
|
|
78
|
+
}
|
|
79
|
+
function toManagedSeeds(components, storybookFacts) {
|
|
80
|
+
const grouped = new Map();
|
|
81
|
+
for (const component of components) {
|
|
82
|
+
const resourceId = (0, resource_identity_1.createComponentResourceId)(component.packageName, component.name);
|
|
83
|
+
const descriptorRelativePath = normalizeSlashes(toDescriptorPath(component.filePath));
|
|
84
|
+
const seeds = grouped.get(descriptorRelativePath) ?? [];
|
|
85
|
+
seeds.push({
|
|
86
|
+
name: component.name,
|
|
87
|
+
id: resourceId,
|
|
88
|
+
sourceFile: normalizeSlashes(component.filePath),
|
|
89
|
+
props: component.props,
|
|
90
|
+
variants: storybookFacts.variantsByComponent[component.name] ?? [],
|
|
91
|
+
storyFiles: storybookFacts.storyFilesByComponent[component.name] ?? []
|
|
92
|
+
});
|
|
93
|
+
grouped.set(descriptorRelativePath, seeds);
|
|
94
|
+
}
|
|
95
|
+
return grouped;
|
|
96
|
+
}
|
|
97
|
+
function serializeDescriptorDocument(doc) {
|
|
98
|
+
return (0, yaml_1.stringify)(doc, { lineWidth: 120 });
|
|
99
|
+
}
|
|
20
100
|
async function readPackageName(cwd) {
|
|
21
101
|
const packageJson = await (0, fs_1.readJson)(node_path_1.default.join(cwd, "package.json"));
|
|
22
102
|
if (typeof packageJson.name !== "string" || packageJson.name.trim() === "") {
|
|
@@ -25,37 +105,149 @@ async function readPackageName(cwd) {
|
|
|
25
105
|
return packageJson.name;
|
|
26
106
|
}
|
|
27
107
|
async function runAuthoringWorkflow(cwd, options = {}) {
|
|
108
|
+
const shouldRefreshAuto = options.refreshAuto !== false;
|
|
109
|
+
const shouldDeleteOrphans = options.deleteOrphans === true;
|
|
28
110
|
const packageName = await readPackageName(cwd);
|
|
29
|
-
const components = await
|
|
30
|
-
|
|
111
|
+
const [components, storybookFacts] = await Promise.all([
|
|
112
|
+
(0, typescript_extractor_1.extractTypeScriptComponents)(cwd, packageName),
|
|
113
|
+
(0, storybook_extractor_1.extractStorybookFacts)(cwd)
|
|
114
|
+
]);
|
|
115
|
+
const outputDir = cwd;
|
|
31
116
|
const createdFiles = [];
|
|
117
|
+
const updatedFiles = [];
|
|
32
118
|
const existingFiles = [];
|
|
33
119
|
const plannedFiles = [];
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
120
|
+
const orphanedResources = [];
|
|
121
|
+
const deletedOrphans = [];
|
|
122
|
+
const warnings = [];
|
|
123
|
+
if (options.interactive) {
|
|
124
|
+
warnings.push("--interactive is not implemented yet. Running sync-only mode.");
|
|
125
|
+
}
|
|
126
|
+
if (options.ai) {
|
|
127
|
+
warnings.push("--ai is not implemented yet. Running sync-only mode.");
|
|
128
|
+
}
|
|
129
|
+
const groupedDescriptors = toManagedSeeds(components, storybookFacts);
|
|
130
|
+
const existingDescriptorFiles = await (0, descriptor_discovery_1.discoverDescriptorFiles)(cwd);
|
|
131
|
+
const expectedDescriptorPaths = new Set(groupedDescriptors.keys());
|
|
132
|
+
const allDescriptorPaths = new Set([
|
|
133
|
+
...existingDescriptorFiles,
|
|
134
|
+
...expectedDescriptorPaths
|
|
135
|
+
]);
|
|
136
|
+
for (const relativePath of [...allDescriptorPaths].sort((a, b) => a.localeCompare(b))) {
|
|
137
|
+
const filePath = node_path_1.default.join(cwd, relativePath);
|
|
138
|
+
const uniqueSeeds = new Map((groupedDescriptors.get(relativePath) ?? []).map((item) => [item.id, item]));
|
|
139
|
+
const seeds = [...uniqueSeeds.values()].sort((a, b) => a.name.localeCompare(b.name));
|
|
140
|
+
const seedByIdentityEntries = [
|
|
141
|
+
...seeds.map((seed) => [seed.id, seed]),
|
|
142
|
+
...seeds.map((seed) => [`component:${seed.name}`, seed])
|
|
143
|
+
];
|
|
144
|
+
const seedByIdentity = new Map(seedByIdentityEntries);
|
|
145
|
+
let existingDoc = {
|
|
146
|
+
schemaVersion: 1,
|
|
147
|
+
resources: []
|
|
148
|
+
};
|
|
149
|
+
const fileAlreadyExists = await (0, fs_1.fileExists)(filePath);
|
|
150
|
+
if (fileAlreadyExists) {
|
|
151
|
+
try {
|
|
152
|
+
const parsed = (0, yaml_1.parse)(await (0, fs_1.readText)(filePath));
|
|
153
|
+
if ((0, json_1.isObject)(parsed)) {
|
|
154
|
+
existingDoc = {
|
|
155
|
+
...parsed
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
throw new Error(`${relativePath}: descriptor must be a YAML object`);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
catch (error) {
|
|
163
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
164
|
+
throw new Error(`Invalid descriptor\n\n${relativePath}\n\nYAML parse error.\n${message}\n\nFix the descriptor before running author again.`);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
const existingResourcesRaw = Array.isArray(existingDoc.resources) ? existingDoc.resources : [];
|
|
168
|
+
const existingResources = existingResourcesRaw.filter((item) => (0, json_1.isObject)(item));
|
|
169
|
+
const nextResources = [];
|
|
170
|
+
const consumedIdentities = new Set();
|
|
171
|
+
for (const existingResource of existingResources) {
|
|
172
|
+
const identity = resourceIdentity(existingResource);
|
|
173
|
+
if (!identity) {
|
|
174
|
+
nextResources.push(existingResource);
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
const seed = seedByIdentity.get(identity);
|
|
178
|
+
if (seed) {
|
|
179
|
+
const updated = shouldRefreshAuto ? patchManagedResourceAuto(existingResource, seed) : existingResource;
|
|
180
|
+
nextResources.push(updated);
|
|
181
|
+
consumedIdentities.add(identity);
|
|
182
|
+
if (identity === `component:${seed.name}`) {
|
|
183
|
+
consumedIdentities.add(seed.id);
|
|
184
|
+
}
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
if (isComponentResource(existingResource) && typeof existingResource.id === "string") {
|
|
188
|
+
orphanedResources.push(`${relativePath}#${existingResource.id}`);
|
|
189
|
+
if (shouldDeleteOrphans) {
|
|
190
|
+
deletedOrphans.push(`${relativePath}#${existingResource.id}`);
|
|
191
|
+
continue;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
nextResources.push(existingResource);
|
|
195
|
+
}
|
|
196
|
+
for (const seed of seeds) {
|
|
197
|
+
if (consumedIdentities.has(seed.id) || consumedIdentities.has(`component:${seed.name}`)) {
|
|
198
|
+
continue;
|
|
199
|
+
}
|
|
200
|
+
nextResources.push(createManagedResource(seed));
|
|
201
|
+
}
|
|
202
|
+
if (!fileAlreadyExists) {
|
|
203
|
+
if (options.dryRun) {
|
|
204
|
+
plannedFiles.push(relativePath);
|
|
205
|
+
}
|
|
206
|
+
else {
|
|
207
|
+
const doc = {
|
|
208
|
+
schemaVersion: 1,
|
|
209
|
+
resources: nextResources
|
|
210
|
+
};
|
|
211
|
+
await (0, fs_1.writeText)(filePath, serializeDescriptorDocument(doc));
|
|
212
|
+
createdFiles.push(relativePath);
|
|
213
|
+
}
|
|
214
|
+
continue;
|
|
215
|
+
}
|
|
216
|
+
const nextDoc = {
|
|
217
|
+
...existingDoc,
|
|
218
|
+
resources: nextResources
|
|
219
|
+
};
|
|
220
|
+
const before = serializeDescriptorDocument(existingDoc).trim();
|
|
221
|
+
const after = serializeDescriptorDocument(nextDoc).trim();
|
|
222
|
+
if (before === after) {
|
|
39
223
|
existingFiles.push(relativePath);
|
|
40
224
|
continue;
|
|
41
225
|
}
|
|
42
226
|
if (options.dryRun) {
|
|
43
227
|
plannedFiles.push(relativePath);
|
|
44
|
-
continue;
|
|
45
|
-
}
|
|
46
|
-
if (await (0, fs_1.writeTextIfMissing)(filePath, AUTHORING_TEMPLATE)) {
|
|
47
|
-
createdFiles.push(relativePath);
|
|
48
228
|
}
|
|
49
229
|
else {
|
|
50
|
-
|
|
230
|
+
await (0, fs_1.writeText)(filePath, `${after}\n`);
|
|
231
|
+
updatedFiles.push(relativePath);
|
|
51
232
|
}
|
|
52
233
|
}
|
|
234
|
+
const pendingHumanResources = [...allDescriptorPaths]
|
|
235
|
+
.sort((a, b) => a.localeCompare(b))
|
|
236
|
+
.flatMap((relativePath) => {
|
|
237
|
+
const seeds = groupedDescriptors.get(relativePath) ?? [];
|
|
238
|
+
return seeds.map((seed) => `${relativePath}#${seed.id}`);
|
|
239
|
+
});
|
|
53
240
|
return {
|
|
54
|
-
outputDir:
|
|
241
|
+
outputDir: ".",
|
|
55
242
|
discoveredResources: components.length,
|
|
56
243
|
createdFiles,
|
|
244
|
+
updatedFiles,
|
|
57
245
|
existingFiles,
|
|
58
246
|
plannedFiles,
|
|
247
|
+
orphanedResources,
|
|
248
|
+
deletedOrphans,
|
|
249
|
+
pendingHumanResources,
|
|
250
|
+
warnings,
|
|
59
251
|
dryRun: Boolean(options.dryRun)
|
|
60
252
|
};
|
|
61
253
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authoring-service.js","sourceRoot":"","sources":["../../../src/implementation/services/authoring-service.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"authoring-service.js","sourceRoot":"","sources":["../../../src/implementation/services/authoring-service.ts"],"names":[],"mappings":";;;;;AA8KA,oDA4KC;AA1VD,0DAA6B;AAC7B,+BAAwC;AACxC,mFAAkF;AAClF,qFAAyF;AAEzF,8EAA8E;AAC9E,iCAAqE;AACrE,qCAAsC;AACtC,4DAAiE;AAqDjE,SAAS,gBAAgB,CAAC,KAAa;IACrC,OAAO,KAAK,CAAC,KAAK,CAAC,mBAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACzC,CAAC;AAED,SAAS,gBAAgB,CAAC,QAAgB;IACxC,MAAM,GAAG,GAAG,mBAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACnC,MAAM,IAAI,GAAG,mBAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;IAC1C,OAAO,mBAAI,CAAC,IAAI,CAAC,mBAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,GAAG,IAAI,aAAa,CAAC,CAAC;AACjE,CAAC;AAED,SAAS,YAAY,CAAC,KAAoC;IACxD,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;SACxB,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;SAC5C,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACd,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