@hexagen-monaco/sync 0.11.0 → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +8 -5
- package/README.md +2 -2
- package/dist/application/ports/out/file-system.port.d.ts.map +1 -1
- package/dist/application/ports/out/symbol-reference-index.port.d.ts +9 -9
- package/dist/application/ports/out/symbol-reference-index.port.d.ts.map +1 -1
- package/dist/application/use-cases/migrate-manifest.use-case.d.ts +4 -1
- package/dist/application/use-cases/migrate-manifest.use-case.d.ts.map +1 -1
- package/dist/application/use-cases/refactoring-impact.use-case.d.ts +6 -5
- package/dist/application/use-cases/refactoring-impact.use-case.d.ts.map +1 -1
- package/dist/cli.js +893 -360
- package/dist/cli.js.map +1 -1
- package/dist/commands/adopt/index.d.ts.map +1 -1
- package/dist/commands/bootstrap/index.d.ts +21 -0
- package/dist/commands/bootstrap/index.d.ts.map +1 -1
- package/dist/commands/manifest/migrate.d.ts.map +1 -1
- package/dist/commands/scan/index.d.ts +185 -0
- package/dist/commands/scan/index.d.ts.map +1 -0
- package/dist/commands/shared/index.d.ts +1 -0
- package/dist/commands/shared/index.d.ts.map +1 -1
- package/dist/commands/shared/lstat-exists.d.ts +7 -0
- package/dist/commands/shared/lstat-exists.d.ts.map +1 -0
- package/dist/domain/services/impact-request-validator.d.ts.map +1 -1
- package/dist/domain/services/layer-dir-resolver.d.ts +20 -1
- package/dist/domain/services/layer-dir-resolver.d.ts.map +1 -1
- package/dist/fs-utils.d.ts.map +1 -1
- package/dist/generators/barrels/recursive.d.ts.map +1 -1
- package/dist/generators/layer-folders.d.ts +9 -1
- package/dist/generators/layer-folders.d.ts.map +1 -1
- package/dist/generators/package-src-index.d.ts +5 -0
- package/dist/generators/package-src-index.d.ts.map +1 -0
- package/dist/index.js +110 -50
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/adapters/atomic-file-system.adapter.d.ts.map +1 -1
- package/dist/infrastructure/adapters/file-system-workspace.adapter.d.ts.map +1 -1
- package/dist/infrastructure/adapters/ts-morph-symbol-index.adapter.d.ts +1 -1
- package/dist/infrastructure/adapters/ts-morph-symbol-index.adapter.d.ts.map +1 -1
- package/dist/sync-engine.d.ts.map +1 -1
- package/dist/types/index.d.ts +20 -1
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/commands/bootstrap.d.ts +0 -30
- package/dist/commands/bootstrap.d.ts.map +0 -1
package/dist/index.js
CHANGED
|
@@ -399,7 +399,7 @@ function isGeneratedFile(content) {
|
|
|
399
399
|
return content.includes(GENERATED_MARKER);
|
|
400
400
|
}
|
|
401
401
|
function isProtectedRoot(filePath, config) {
|
|
402
|
-
const relative = path7.relative(config.workspaceRoot, filePath);
|
|
402
|
+
const relative = path7.relative(config.workspaceRoot, filePath).replace(/\\/g, "/");
|
|
403
403
|
const isRootLevel = !relative.startsWith("packages/") && !relative.startsWith("tools/") && !relative.startsWith("apps/");
|
|
404
404
|
return isRootLevel && Array.from(protectedFiles).some(
|
|
405
405
|
(f) => relative.endsWith(f) || relative.includes(f)
|
|
@@ -514,6 +514,28 @@ function resolveEmissionDir(layers, site) {
|
|
|
514
514
|
const layer = site.slice(0, slash);
|
|
515
515
|
return resolveLayerDir(layers, layer, site.slice(slash + 1));
|
|
516
516
|
}
|
|
517
|
+
function hasDeclaredNames(value) {
|
|
518
|
+
return Array.isArray(value) && value.length > 0;
|
|
519
|
+
}
|
|
520
|
+
function layerDeclaresContent(layerName, contextLayers) {
|
|
521
|
+
if (!contextLayers) return false;
|
|
522
|
+
if (layerName === "domain") {
|
|
523
|
+
const layer = contextLayers.domain;
|
|
524
|
+
if (!layer) return false;
|
|
525
|
+
return hasDeclaredNames(layer.entities) || hasDeclaredNames(layer.value_objects) || hasDeclaredNames(layer.domain_services) || hasDeclaredNames(layer.ports?.in) || hasDeclaredNames(layer.ports?.out);
|
|
526
|
+
}
|
|
527
|
+
if (layerName === "application") {
|
|
528
|
+
const layer = contextLayers.application;
|
|
529
|
+
if (!layer) return false;
|
|
530
|
+
return hasDeclaredNames(layer.use_cases) || hasDeclaredNames(layer.factories) || hasDeclaredNames(layer.ports?.in) || hasDeclaredNames(layer.ports?.out);
|
|
531
|
+
}
|
|
532
|
+
if (layerName === "infrastructure") {
|
|
533
|
+
const layer = contextLayers.infrastructure;
|
|
534
|
+
if (!layer) return false;
|
|
535
|
+
return hasDeclaredNames(layer.adapters);
|
|
536
|
+
}
|
|
537
|
+
return false;
|
|
538
|
+
}
|
|
517
539
|
|
|
518
540
|
// src/generators/layer-folders.ts
|
|
519
541
|
async function directoryExists(dirPath) {
|
|
@@ -578,7 +600,7 @@ async function loadYamlSafe(filePath) {
|
|
|
578
600
|
throw e;
|
|
579
601
|
}
|
|
580
602
|
}
|
|
581
|
-
async function ensureLayerFolders(moduleDir, layers, config) {
|
|
603
|
+
async function ensureLayerFolders(moduleDir, layers, config, contextLayers) {
|
|
582
604
|
const result = createEmptyResult();
|
|
583
605
|
const { logger } = config;
|
|
584
606
|
const layerRulesPath = path7.join(
|
|
@@ -592,6 +614,9 @@ async function ensureLayerFolders(moduleDir, layers, config) {
|
|
|
592
614
|
logger.warn("layer-rules.yaml not found — skipping layer rule enforcement");
|
|
593
615
|
}
|
|
594
616
|
for (const [layerName, layerConfig] of Object.entries(layers)) {
|
|
617
|
+
if (!layerDeclaresContent(layerName, contextLayers)) {
|
|
618
|
+
continue;
|
|
619
|
+
}
|
|
595
620
|
const layerPath = path7.join(moduleDir, resolveLayerDir(layers, layerName));
|
|
596
621
|
if (!isInScope(layerPath, config) && !isInScope(path7.join(layerPath, "index.ts"), config)) {
|
|
597
622
|
continue;
|
|
@@ -646,18 +671,18 @@ function contentHash2(content) {
|
|
|
646
671
|
function detectCircularExports(exportGraph) {
|
|
647
672
|
const visited = /* @__PURE__ */ new Set();
|
|
648
673
|
const recursionStack = /* @__PURE__ */ new Set();
|
|
649
|
-
const
|
|
674
|
+
const path25 = [];
|
|
650
675
|
function dfs(node) {
|
|
651
676
|
if (recursionStack.has(node)) {
|
|
652
|
-
const cycleStart =
|
|
653
|
-
return [...
|
|
677
|
+
const cycleStart = path25.indexOf(node);
|
|
678
|
+
return [...path25.slice(cycleStart), node];
|
|
654
679
|
}
|
|
655
680
|
if (visited.has(node)) {
|
|
656
681
|
return null;
|
|
657
682
|
}
|
|
658
683
|
visited.add(node);
|
|
659
684
|
recursionStack.add(node);
|
|
660
|
-
|
|
685
|
+
path25.push(node);
|
|
661
686
|
const exports$1 = exportGraph.get(node) ?? [];
|
|
662
687
|
for (const exportPath of exports$1) {
|
|
663
688
|
const cycle = dfs(exportPath);
|
|
@@ -665,7 +690,7 @@ function detectCircularExports(exportGraph) {
|
|
|
665
690
|
return cycle;
|
|
666
691
|
}
|
|
667
692
|
}
|
|
668
|
-
|
|
693
|
+
path25.pop();
|
|
669
694
|
recursionStack.delete(node);
|
|
670
695
|
return null;
|
|
671
696
|
}
|
|
@@ -682,8 +707,8 @@ function generateBarrelContent(entries) {
|
|
|
682
707
|
return null;
|
|
683
708
|
}
|
|
684
709
|
const exportLines = entries.sort((a, b) => a.name.localeCompare(b.name)).map((entry) => {
|
|
685
|
-
const
|
|
686
|
-
return `export * from "${
|
|
710
|
+
const path25 = entry.isDirectory ? `./${entry.name}/index.js` : `./${entry.name}.js`;
|
|
711
|
+
return `export * from "${path25}";`;
|
|
687
712
|
});
|
|
688
713
|
return `${GENERATED_MARKER2}
|
|
689
714
|
|
|
@@ -830,53 +855,18 @@ async function walkDirectory(dirPath, pendingWrites, preserved, exportGraph, con
|
|
|
830
855
|
if (exportEntries.length === 0) {
|
|
831
856
|
const barrelPath2 = path7.join(dirPath, "index.ts");
|
|
832
857
|
const existingBarrel = await readFileIfExists(barrelPath2);
|
|
833
|
-
const dirName = path7.basename(dirPath);
|
|
834
|
-
const isLayerDir = ["domain", "application", "infrastructure"].includes(
|
|
835
|
-
dirName
|
|
836
|
-
);
|
|
837
858
|
if (existingBarrel) {
|
|
838
859
|
const isGenerated = isGeneratedFile2(existingBarrel);
|
|
839
|
-
const
|
|
840
|
-
|
|
860
|
+
const statements = existingBarrel.split("\n").map((line) => line.trim()).filter((line) => line.length > 0 && !line.startsWith("//"));
|
|
861
|
+
const isEmptyStub = statements.length === 1 && /^export\s*\{\s*\}\s*;?$/.test(statements[0]);
|
|
862
|
+
if (isGenerated || isEmptyStub) {
|
|
841
863
|
pendingWrites.push({
|
|
842
864
|
filePath: barrelPath2,
|
|
843
865
|
content: "",
|
|
844
866
|
// Empty content signals deletion
|
|
845
867
|
isNew: false
|
|
846
868
|
});
|
|
847
|
-
} else if (isEmptyStub && isLayerDir) {
|
|
848
|
-
const newContent = `${GENERATED_MARKER2}
|
|
849
|
-
|
|
850
|
-
export {};
|
|
851
|
-
`;
|
|
852
|
-
if (contentHash2(existingBarrel) !== contentHash2(newContent)) {
|
|
853
|
-
pendingWrites.push({
|
|
854
|
-
filePath: barrelPath2,
|
|
855
|
-
content: newContent,
|
|
856
|
-
isNew: false
|
|
857
|
-
});
|
|
858
|
-
}
|
|
859
|
-
} else if (!existingBarrel.includes("export {}") && isLayerDir) {
|
|
860
|
-
const newContent = `${GENERATED_MARKER2}
|
|
861
|
-
|
|
862
|
-
export {};
|
|
863
|
-
`;
|
|
864
|
-
pendingWrites.push({
|
|
865
|
-
filePath: barrelPath2,
|
|
866
|
-
content: newContent,
|
|
867
|
-
isNew: false
|
|
868
|
-
});
|
|
869
869
|
}
|
|
870
|
-
} else if (isLayerDir) {
|
|
871
|
-
const newContent = `${GENERATED_MARKER2}
|
|
872
|
-
|
|
873
|
-
export {};
|
|
874
|
-
`;
|
|
875
|
-
pendingWrites.push({
|
|
876
|
-
filePath: barrelPath2,
|
|
877
|
-
content: newContent,
|
|
878
|
-
isNew: true
|
|
879
|
-
});
|
|
880
870
|
}
|
|
881
871
|
return [];
|
|
882
872
|
}
|
|
@@ -1193,6 +1183,37 @@ async function generateTsconfig(moduleDir, moduleName, config, report) {
|
|
|
1193
1183
|
return result;
|
|
1194
1184
|
}
|
|
1195
1185
|
}
|
|
1186
|
+
var SRC_INDEX_STUB = `${GENERATED_MARKER2}
|
|
1187
|
+
|
|
1188
|
+
export {};
|
|
1189
|
+
`;
|
|
1190
|
+
async function ensurePackageSrcIndex(moduleDir, config, report) {
|
|
1191
|
+
const result = createEmptyResult();
|
|
1192
|
+
const filePath = path7.join(moduleDir, "src", "index.ts");
|
|
1193
|
+
if (!isInScope(filePath, config)) {
|
|
1194
|
+
result.skipped.push(filePath);
|
|
1195
|
+
return result;
|
|
1196
|
+
}
|
|
1197
|
+
try {
|
|
1198
|
+
await fs5.stat(filePath);
|
|
1199
|
+
result.skipped.push(filePath);
|
|
1200
|
+
return result;
|
|
1201
|
+
} catch (err3) {
|
|
1202
|
+
if (err3.code !== "ENOENT") throw err3;
|
|
1203
|
+
}
|
|
1204
|
+
if (!config.dryRun) {
|
|
1205
|
+
await fs5.mkdir(path7.dirname(filePath), { recursive: true });
|
|
1206
|
+
}
|
|
1207
|
+
const status = await safeWriteFileAtomic(
|
|
1208
|
+
filePath,
|
|
1209
|
+
SRC_INDEX_STUB,
|
|
1210
|
+
config,
|
|
1211
|
+
report,
|
|
1212
|
+
false
|
|
1213
|
+
);
|
|
1214
|
+
recordWriteStatus(result, filePath, status);
|
|
1215
|
+
return result;
|
|
1216
|
+
}
|
|
1196
1217
|
async function reapLegacyFolders(moduleDir, config, report) {
|
|
1197
1218
|
const { dryRun, logger } = config;
|
|
1198
1219
|
const legacyLayers = ["domain", "application", "infrastructure"];
|
|
@@ -1267,6 +1288,33 @@ function interpolate(template, vars) {
|
|
|
1267
1288
|
});
|
|
1268
1289
|
return { output, warnings };
|
|
1269
1290
|
}
|
|
1291
|
+
var CURRENT_SCHEMA_VERSION = "1.0.0";
|
|
1292
|
+
function majorOf(version) {
|
|
1293
|
+
const match = /^(\d+)(?:\.|$)/.exec(version);
|
|
1294
|
+
return match ? match[1] : null;
|
|
1295
|
+
}
|
|
1296
|
+
var SUPPORTED_MAJOR = majorOf(CURRENT_SCHEMA_VERSION);
|
|
1297
|
+
z.object({
|
|
1298
|
+
schemaVersion: z.string({ required_error: "schemaVersion is required" }).refine((v) => majorOf(v) !== null, {
|
|
1299
|
+
message: "schemaVersion must start with a numeric major, e.g. '1.0.0'"
|
|
1300
|
+
}).refine((v) => majorOf(v) === SUPPORTED_MAJOR, {
|
|
1301
|
+
message: `Unsupported schemaVersion major; this consumer understands ${SUPPORTED_MAJOR}.x`
|
|
1302
|
+
}),
|
|
1303
|
+
// `layout` is the raw TEXT of the producer's .architecture/layout.yaml, not
|
|
1304
|
+
// a structured object: packages/sync reads that file, and the web adapter
|
|
1305
|
+
// guards on `typeof rec.layout === "string"` before clipping it to an
|
|
1306
|
+
// excerpt. A looser z.unknown() here let a structured fixture through that
|
|
1307
|
+
// the real consumer would silently ignore.
|
|
1308
|
+
layout: z.string().nullable().optional(),
|
|
1309
|
+
// Nullable like its siblings: the producer emits an explicit null when the
|
|
1310
|
+
// count is unknown (the linter prints "Files scanned" on inherited stdio,
|
|
1311
|
+
// so scan cannot see it until BF-0.3 captures that stream). Making this
|
|
1312
|
+
// optional-but-not-nullable would force the producer to choose between
|
|
1313
|
+
// omitting the key and failing its own schema.
|
|
1314
|
+
filesScanned: z.number().int().min(0).nullable().optional(),
|
|
1315
|
+
reportMarkdown: z.string().nullable().optional(),
|
|
1316
|
+
error: z.string().nullable().optional()
|
|
1317
|
+
}).passthrough();
|
|
1270
1318
|
|
|
1271
1319
|
// src/generators/root-file-templates.ts
|
|
1272
1320
|
var BUILTIN_PACKAGE_JSON_TEMPLATE = `{
|
|
@@ -1431,7 +1479,7 @@ function assertValidToolchainVersion(version, source) {
|
|
|
1431
1479
|
function resolveToolchainVersion() {
|
|
1432
1480
|
{
|
|
1433
1481
|
return assertValidToolchainVersion(
|
|
1434
|
-
"0.
|
|
1482
|
+
"0.12.1",
|
|
1435
1483
|
"build-injected __HEXAGEN_TOOLCHAIN_VERSION__"
|
|
1436
1484
|
);
|
|
1437
1485
|
}
|
|
@@ -5171,7 +5219,12 @@ var SyncEngine = class {
|
|
|
5171
5219
|
logger.info(
|
|
5172
5220
|
`Ensuring directories for module: ${mod.name} at ${moduleDir}`
|
|
5173
5221
|
);
|
|
5174
|
-
const layerResult = await ensureLayerFolders(
|
|
5222
|
+
const layerResult = await ensureLayerFolders(
|
|
5223
|
+
moduleDir,
|
|
5224
|
+
layers,
|
|
5225
|
+
config,
|
|
5226
|
+
mod.layers
|
|
5227
|
+
);
|
|
5175
5228
|
mergeResult2(result, layerResult);
|
|
5176
5229
|
}
|
|
5177
5230
|
return result;
|
|
@@ -5212,6 +5265,11 @@ var SyncEngine = class {
|
|
|
5212
5265
|
config,
|
|
5213
5266
|
this.report
|
|
5214
5267
|
);
|
|
5268
|
+
const srcIndexResult = await ensurePackageSrcIndex(
|
|
5269
|
+
moduleDir,
|
|
5270
|
+
config,
|
|
5271
|
+
this.report
|
|
5272
|
+
);
|
|
5215
5273
|
const eslintResult = await generateEslintConfig(
|
|
5216
5274
|
moduleDir,
|
|
5217
5275
|
moduleName,
|
|
@@ -5227,6 +5285,7 @@ var SyncEngine = class {
|
|
|
5227
5285
|
this.noteFailure("Barrels", barrelResult);
|
|
5228
5286
|
this.noteFailure("package.json", pkgResult);
|
|
5229
5287
|
this.noteFailure("tsconfig.json", tsResult);
|
|
5288
|
+
this.noteFailure("src/index.ts", srcIndexResult);
|
|
5230
5289
|
this.noteFailure("ESLint", eslintResult);
|
|
5231
5290
|
this.noteFailure("Stubs", stubResult);
|
|
5232
5291
|
if (this.partialConfig.mode === "self-regen") {
|
|
@@ -5235,6 +5294,7 @@ var SyncEngine = class {
|
|
|
5235
5294
|
mergeResult2(barrels, barrelResult);
|
|
5236
5295
|
mergeResult2(pkgs, pkgResult);
|
|
5237
5296
|
mergeResult2(tsconfigs, tsResult);
|
|
5297
|
+
mergeResult2(tsconfigs, srcIndexResult);
|
|
5238
5298
|
mergeResult2(eslint, eslintResult);
|
|
5239
5299
|
mergeResult2(stubs, stubResult);
|
|
5240
5300
|
}
|
|
@@ -5663,6 +5723,6 @@ async function saveManifest(workspaceRoot, manifest) {
|
|
|
5663
5723
|
}
|
|
5664
5724
|
}
|
|
5665
5725
|
|
|
5666
|
-
export { DEFAULT_NAMING, DEFAULT_TEMPLATES, SyncEngine, createEmptyResult, err2 as err, isIndexManifest, loadManifest2 as loadManifest, mergeSplitManifest, ok2 as ok, parseArgs, portName, recordWriteStatus, saveManifest, validateManifest2 as validateManifest };
|
|
5726
|
+
export { DEFAULT_NAMING, DEFAULT_TEMPLATES, SyncEngine, createEmptyResult, err2 as err, isIndexManifest, loadManifest2 as loadManifest, mergeSplitManifest, ok2 as ok, parseArgs, portName, recordWriteStatus, sanitizeScope, saveManifest, validateManifest2 as validateManifest };
|
|
5667
5727
|
//# sourceMappingURL=index.js.map
|
|
5668
5728
|
//# sourceMappingURL=index.js.map
|