archgraph-argo-beta 0.27.0-beta.6 → 0.27.0-beta.8
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.
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
3
|
"title": "ArchiMate 3.2 default schema bundle descriptor",
|
|
4
4
|
"description": "Descriptor for the default ARGO schema bundle (ArchiMate 3.2 + ARGO extensions). A repository may override this bundle by placing its own SystemArchitecture.schema.json (plus an optional schema-bundle.config.json / schema-bundle.rules.json) under <workspace>/.argo/schema.",
|
|
5
|
+
"id": "default",
|
|
6
|
+
"aliases": ["archimate3.2", "archimate", "base"],
|
|
5
7
|
"language": "ArchiMate 3.2",
|
|
6
8
|
"elementTypeEnumKey": "archimateElementType",
|
|
7
9
|
"relationshipTypeEnumKey": "archimateRelationshipType",
|
|
@@ -178,14 +178,86 @@ function hasExtendsConfig(dir) {
|
|
|
178
178
|
return typeof config.extends === 'string' && config.extends.trim() !== '';
|
|
179
179
|
}
|
|
180
180
|
|
|
181
|
-
|
|
181
|
+
// Symbolic names a bundle declares about itself (`id` + `aliases`) in its config.
|
|
182
|
+
// The framework resolves an `extends` value against these DECLARED names — never a
|
|
183
|
+
// name hardcoded in framework logic — so a bundle's identity/aliases are data.
|
|
184
|
+
function bundleSymbolicNames(dir) {
|
|
185
|
+
const config = bundleConfig(dir);
|
|
186
|
+
const names = new Set();
|
|
187
|
+
if (typeof config.id === 'string' && config.id.trim() !== '') {
|
|
188
|
+
names.add(config.id.trim());
|
|
189
|
+
}
|
|
190
|
+
if (Array.isArray(config.aliases)) {
|
|
191
|
+
for (const alias of config.aliases) {
|
|
192
|
+
if (typeof alias === 'string' && alias.trim() !== '') {
|
|
193
|
+
names.add(alias.trim());
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
return names;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function isPathLikeExt(value) {
|
|
201
|
+
return value.includes('/') || value.includes('\\') || value.startsWith('.') || value.startsWith('~')
|
|
202
|
+
|| /^[a-zA-Z]:/.test(value);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// Bounded, general candidate list for symbolic bundle resolution: the built-in
|
|
206
|
+
// default bundle, any directory a bundle lists in its own `basePaths`, the bundle's
|
|
207
|
+
// own directory, and its immediate sub-directories. The framework matches a name
|
|
208
|
+
// against each candidate's SELF-DECLARED id/aliases (data) — it hardcodes no
|
|
209
|
+
// modeling-language name. A non-matching symbolic name falls back to a path, so
|
|
210
|
+
// bare relative directory references keep working.
|
|
211
|
+
function candidateBaseDirs(childDir, config) {
|
|
212
|
+
const dirs = [];
|
|
213
|
+
const seen = new Set();
|
|
214
|
+
const push = (dir) => {
|
|
215
|
+
if (!dir) {
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
const resolved = path.resolve(dir);
|
|
219
|
+
const key = resolved.toLowerCase();
|
|
220
|
+
if (!seen.has(key)) {
|
|
221
|
+
seen.add(key);
|
|
222
|
+
dirs.push(resolved);
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
push(path.join(getArgoRoot(), 'schema'));
|
|
226
|
+
const basePaths = config && Array.isArray(config.basePaths) ? config.basePaths : [];
|
|
227
|
+
for (const basePath of basePaths) {
|
|
228
|
+
if (typeof basePath === 'string' && basePath.trim() !== '') {
|
|
229
|
+
push(path.resolve(childDir, basePath.trim()));
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
push(childDir);
|
|
233
|
+
let entries = [];
|
|
234
|
+
try {
|
|
235
|
+
entries = fs.readdirSync(childDir, { withFileTypes: true });
|
|
236
|
+
} catch {
|
|
237
|
+
entries = [];
|
|
238
|
+
}
|
|
239
|
+
for (const entry of entries) {
|
|
240
|
+
if (entry.isDirectory()) {
|
|
241
|
+
push(path.join(childDir, entry.name));
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
return dirs;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
function resolveBaseBundleDir(ext, childDir, config) {
|
|
182
248
|
const value = String(ext).trim();
|
|
183
|
-
//
|
|
184
|
-
// value is a path to another bundle directory — the framework never hardcodes a
|
|
185
|
-
// modeling-language name (ArchiMate or otherwise) into bundle resolution.
|
|
249
|
+
// `default` is the reserved, language-neutral name of the built-in bundle.
|
|
186
250
|
if (value === 'default') {
|
|
187
251
|
return path.join(getArgoRoot(), 'schema');
|
|
188
252
|
}
|
|
253
|
+
if (!isPathLikeExt(value)) {
|
|
254
|
+
for (const dir of candidateBaseDirs(childDir, config)) {
|
|
255
|
+
if (bundleSymbolicNames(dir).has(value)) {
|
|
256
|
+
return dir;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
// Not a symbolic hit: treat as a path relative to the bundle directory.
|
|
189
261
|
return path.resolve(childDir, value);
|
|
190
262
|
}
|
|
191
263
|
|
|
@@ -326,7 +398,7 @@ function applyExtends(bundle, workspaceRoot, seen = new Set()) {
|
|
|
326
398
|
return bundle;
|
|
327
399
|
}
|
|
328
400
|
seen.add(path.resolve(bundle.dir).toLowerCase());
|
|
329
|
-
const baseDir = resolveBaseBundleDir(ext, bundle.dir);
|
|
401
|
+
const baseDir = resolveBaseBundleDir(ext, bundle.dir, bundle.config);
|
|
330
402
|
const baseKey = path.resolve(baseDir).toLowerCase();
|
|
331
403
|
if (seen.has(baseKey)) {
|
|
332
404
|
throw new Error(`schema bundle extends cycle detected at '${baseDir}'`);
|
package/package.json
CHANGED