octo-dev 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +270 -0
- package/package.json +62 -0
- package/scripts/install.sh +117 -0
- package/src/build/adapters/docker-build-engine.adapter.ts +39 -0
- package/src/build/affected-detector.ts +126 -0
- package/src/build/build-orchestrator.ts +169 -0
- package/src/build/build-scheduler.ts +174 -0
- package/src/build/ports/build-engine.port.ts +38 -0
- package/src/cli/build.command.ts +101 -0
- package/src/cli/bump.command.ts +98 -0
- package/src/cli/down.command.ts +36 -0
- package/src/cli/graph.command.ts +40 -0
- package/src/cli/index.ts +80 -0
- package/src/cli/init.command.ts +106 -0
- package/src/cli/status.command.ts +46 -0
- package/src/cli/up.command.ts +52 -0
- package/src/graph/aggregated-graph.ts +77 -0
- package/src/graph/build-graph.ts +125 -0
- package/src/graph/dependency-graph.ts +82 -0
- package/src/graph/index.ts +4 -0
- package/src/graph/topological-sort.ts +104 -0
- package/src/hooks/hook-runner.ts +57 -0
- package/src/infra/compose-aggregator.ts +152 -0
- package/src/infra/compose-smart-merger.ts +93 -0
- package/src/infra/infra-manager.ts +157 -0
- package/src/manifest/manifest-discovery.ts +144 -0
- package/src/manifest/manifest-parser.ts +109 -0
- package/src/manifest/manifest-printer.ts +75 -0
- package/src/manifest/manifest-schema.ts +34 -0
- package/src/shared/errors.ts +43 -0
- package/src/shared/logger.ts +14 -0
- package/src/shared/process-runner.ts +47 -0
- package/src/shared/shutdown.ts +36 -0
- package/src/version/changelog-generator.ts +112 -0
- package/src/version/version-bumper.ts +116 -0
- package/src/version/version-propagator.ts +120 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { readFile, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import semver from 'semver';
|
|
4
|
+
import { DependencyGraph } from '../graph/dependency-graph.js';
|
|
5
|
+
import { logger } from '../shared/logger.js';
|
|
6
|
+
import { PropagationEntry } from './version-bumper.js';
|
|
7
|
+
|
|
8
|
+
export interface PropagationResult {
|
|
9
|
+
entries: PropagationEntry[];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export class VersionPropagator {
|
|
13
|
+
constructor(private graph: DependencyGraph) {}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Propagate a new version of `packageName` to all compatible dependents,
|
|
17
|
+
* recursively updating dependents of dependents.
|
|
18
|
+
*/
|
|
19
|
+
async propagate(packageName: string, newVersion: string): Promise<PropagationResult> {
|
|
20
|
+
const entries: PropagationEntry[] = [];
|
|
21
|
+
const visited = new Set<string>();
|
|
22
|
+
|
|
23
|
+
await this.propagateRecursive(packageName, newVersion, entries, visited);
|
|
24
|
+
|
|
25
|
+
if (entries.length === 0) {
|
|
26
|
+
logger.info(`Nenhum projeto consome ${packageName}. Propagação encerrada.`);
|
|
27
|
+
return { entries };
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Display summary
|
|
31
|
+
logger.info('--- Resumo da Propagação ---');
|
|
32
|
+
for (const entry of entries) {
|
|
33
|
+
if (entry.skipped) {
|
|
34
|
+
logger.warn(` ${entry.project}: PULADO — ${entry.reason}`);
|
|
35
|
+
} else {
|
|
36
|
+
logger.info(` ${entry.project}: ${entry.previousVersion} → ${entry.newVersion}`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return { entries };
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
private async propagateRecursive(
|
|
44
|
+
packageName: string,
|
|
45
|
+
newVersion: string,
|
|
46
|
+
entries: PropagationEntry[],
|
|
47
|
+
visited: Set<string>,
|
|
48
|
+
): Promise<void> {
|
|
49
|
+
const dependents = this.graph.getDependents(packageName);
|
|
50
|
+
|
|
51
|
+
for (const dependent of dependents) {
|
|
52
|
+
if (visited.has(dependent)) continue;
|
|
53
|
+
visited.add(dependent);
|
|
54
|
+
|
|
55
|
+
const node = this.graph.getNode(dependent);
|
|
56
|
+
if (!node) continue;
|
|
57
|
+
|
|
58
|
+
const pkgJsonPath = join(node.path, 'package.json');
|
|
59
|
+
const content = await readFile(pkgJsonPath, 'utf-8');
|
|
60
|
+
const pkg = JSON.parse(content);
|
|
61
|
+
|
|
62
|
+
const updated = await this.updateDependency(pkg, pkgJsonPath, packageName, newVersion, dependent, entries);
|
|
63
|
+
|
|
64
|
+
// If updated, propagate to dependents of this dependent
|
|
65
|
+
if (updated) {
|
|
66
|
+
await this.propagateRecursive(dependent, newVersion, entries, visited);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Update the version of `packageName` in a dependent's package.json.
|
|
73
|
+
* Returns true if updated, false if skipped.
|
|
74
|
+
*/
|
|
75
|
+
private async updateDependency(
|
|
76
|
+
pkg: Record<string, any>,
|
|
77
|
+
pkgJsonPath: string,
|
|
78
|
+
packageName: string,
|
|
79
|
+
newVersion: string,
|
|
80
|
+
dependentName: string,
|
|
81
|
+
entries: PropagationEntry[],
|
|
82
|
+
): Promise<boolean> {
|
|
83
|
+
const sections = ['dependencies', 'devDependencies'] as const;
|
|
84
|
+
|
|
85
|
+
for (const section of sections) {
|
|
86
|
+
const deps = pkg[section];
|
|
87
|
+
if (!deps || !deps[packageName]) continue;
|
|
88
|
+
|
|
89
|
+
const currentRange: string = deps[packageName];
|
|
90
|
+
|
|
91
|
+
// Check compatibility: if the new version satisfies the existing range, update
|
|
92
|
+
if (!semver.satisfies(newVersion, currentRange)) {
|
|
93
|
+
entries.push({
|
|
94
|
+
project: dependentName,
|
|
95
|
+
previousVersion: currentRange,
|
|
96
|
+
newVersion,
|
|
97
|
+
skipped: true,
|
|
98
|
+
reason: `Range ${currentRange} incompatível com ${newVersion}`,
|
|
99
|
+
});
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Compatible — update to the new version
|
|
104
|
+
const previousVersion = currentRange;
|
|
105
|
+
deps[packageName] = `^${newVersion}`;
|
|
106
|
+
|
|
107
|
+
await writeFile(pkgJsonPath, JSON.stringify(pkg, null, 2) + '\n', 'utf-8');
|
|
108
|
+
|
|
109
|
+
entries.push({
|
|
110
|
+
project: dependentName,
|
|
111
|
+
previousVersion,
|
|
112
|
+
newVersion: `^${newVersion}`,
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
120
|
+
}
|