@fuzdev/fuz_gitops 0.77.0 → 0.78.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/README.md +25 -5
- package/dist/ModulesDetail.svelte +14 -12
- package/dist/ModulesDetail.svelte.d.ts.map +1 -1
- package/dist/ModulesNav.svelte +6 -6
- package/dist/ModulesNav.svelte.d.ts.map +1 -1
- package/dist/ModulesPage.svelte +2 -2
- package/dist/ModulesPage.svelte.d.ts.map +1 -1
- package/dist/PageFooter.svelte +2 -2
- package/dist/PageHeader.svelte +5 -5
- package/dist/PageHeader.svelte.d.ts +1 -1
- package/dist/PageHeader.svelte.d.ts.map +1 -1
- package/dist/PullRequestsDetail.svelte +25 -17
- package/dist/PullRequestsDetail.svelte.d.ts.map +1 -1
- package/dist/PullRequestsPage.svelte +3 -3
- package/dist/PullRequestsPage.svelte.d.ts.map +1 -1
- package/dist/ReposTable.svelte +24 -15
- package/dist/ReposTable.svelte.d.ts.map +1 -1
- package/dist/ReposTree.svelte +8 -6
- package/dist/ReposTree.svelte.d.ts.map +1 -1
- package/dist/ReposTreeNav.svelte +10 -11
- package/dist/ReposTreeNav.svelte.d.ts.map +1 -1
- package/dist/TablePage.svelte +2 -2
- package/dist/TablePage.svelte.d.ts.map +1 -1
- package/dist/TreeItemPage.svelte +2 -2
- package/dist/TreeItemPage.svelte.d.ts.map +1 -1
- package/dist/TreePage.svelte +2 -2
- package/dist/TreePage.svelte.d.ts.map +1 -1
- package/dist/cargo_toml.d.ts +33 -0
- package/dist/cargo_toml.d.ts.map +1 -0
- package/dist/cargo_toml.js +74 -0
- package/dist/changeset_generator.d.ts +1 -1
- package/dist/changeset_generator.d.ts.map +1 -1
- package/dist/changeset_generator.js +2 -2
- package/dist/changeset_reader.d.ts +1 -1
- package/dist/changeset_reader.d.ts.map +1 -1
- package/dist/changeset_reader.js +3 -3
- package/dist/config_reconcile.d.ts.map +1 -1
- package/dist/config_reconcile.js +6 -2
- package/dist/dependency_graph.d.ts +2 -2
- package/dist/dependency_graph.d.ts.map +1 -1
- package/dist/dependency_graph.js +9 -9
- package/dist/dependency_updater.d.ts +1 -1
- package/dist/dependency_updater.d.ts.map +1 -1
- package/dist/dependency_updater.js +8 -8
- package/dist/fetch_repo_data.d.ts +2 -2
- package/dist/fetch_repo_data.d.ts.map +1 -1
- package/dist/fetch_repo_data.js +4 -4
- package/dist/fs_fetch_value_cache.d.ts +1 -1
- package/dist/fs_fetch_value_cache.d.ts.map +1 -1
- package/dist/fs_fetch_value_cache.js +5 -5
- package/dist/git_operations.d.ts +1 -1
- package/dist/git_operations.d.ts.map +1 -1
- package/dist/git_operations.js +2 -2
- package/dist/github.d.ts +2 -2
- package/dist/github.d.ts.map +1 -1
- package/dist/github.js +7 -7
- package/dist/github_helpers.d.ts.map +1 -1
- package/dist/github_helpers.js +1 -1
- package/dist/gitops_analyze.task.d.ts.map +1 -1
- package/dist/gitops_analyze.task.js +21 -14
- package/dist/gitops_config.d.ts +2 -2
- package/dist/gitops_config.d.ts.map +1 -1
- package/dist/gitops_config.js +5 -5
- package/dist/gitops_plan.task.d.ts.map +1 -1
- package/dist/gitops_plan.task.js +8 -8
- package/dist/gitops_publish.task.d.ts.map +1 -1
- package/dist/gitops_publish.task.js +15 -12
- package/dist/gitops_run.task.d.ts.map +1 -1
- package/dist/gitops_run.task.js +10 -10
- package/dist/gitops_sync.task.d.ts.map +1 -1
- package/dist/gitops_sync.task.js +15 -13
- package/dist/gitops_task_helpers.d.ts +1 -1
- package/dist/gitops_task_helpers.d.ts.map +1 -1
- package/dist/gitops_task_helpers.js +4 -4
- package/dist/gitops_validate.task.d.ts.map +1 -1
- package/dist/gitops_validate.task.js +14 -14
- package/dist/graph_validation.d.ts +2 -2
- package/dist/graph_validation.d.ts.map +1 -1
- package/dist/graph_validation.js +5 -3
- package/dist/local_repo.d.ts +21 -7
- package/dist/local_repo.d.ts.map +1 -1
- package/dist/local_repo.js +64 -16
- package/dist/log_helpers.d.ts +1 -1
- package/dist/log_helpers.d.ts.map +1 -1
- package/dist/multi_repo_publisher.d.ts +3 -3
- package/dist/multi_repo_publisher.d.ts.map +1 -1
- package/dist/multi_repo_publisher.js +24 -20
- package/dist/npm_registry.d.ts +1 -1
- package/dist/npm_registry.d.ts.map +1 -1
- package/dist/npm_registry.js +4 -4
- package/dist/operations.d.ts +4 -4
- package/dist/operations.d.ts.map +1 -1
- package/dist/operations_defaults.d.ts.map +1 -1
- package/dist/operations_defaults.js +16 -16
- package/dist/output_helpers.d.ts +1 -1
- package/dist/output_helpers.d.ts.map +1 -1
- package/dist/preflight_checks.d.ts +2 -2
- package/dist/preflight_checks.d.ts.map +1 -1
- package/dist/preflight_checks.js +5 -5
- package/dist/publish_gate.d.ts.map +1 -1
- package/dist/publish_steps.d.ts.map +1 -1
- package/dist/publish_steps.js +4 -4
- package/dist/publishing_event.d.ts.map +1 -1
- package/dist/publishing_event.js +16 -14
- package/dist/publishing_event_handler.d.ts.map +1 -1
- package/dist/publishing_event_handler.js +6 -6
- package/dist/publishing_plan.d.ts +3 -3
- package/dist/publishing_plan.d.ts.map +1 -1
- package/dist/publishing_plan.js +25 -15
- package/dist/publishing_plan_helpers.d.ts.map +1 -1
- package/dist/publishing_plan_helpers.js +3 -3
- package/dist/publishing_plan_logging.d.ts +1 -1
- package/dist/publishing_plan_logging.d.ts.map +1 -1
- package/dist/publishing_plan_logging.js +2 -2
- package/dist/repo.svelte.d.ts +5 -5
- package/dist/repo.svelte.d.ts.map +1 -1
- package/dist/repo.svelte.js +2 -2
- package/dist/repo_ops.js +2 -2
- package/dist/resolved_gitops_config.d.ts.map +1 -1
- package/dist/resolved_gitops_config.js +1 -1
- package/dist/version_utils.js +1 -1
- package/package.json +16 -15
- package/src/lib/cargo_toml.ts +82 -0
- package/src/lib/changeset_generator.ts +20 -20
- package/src/lib/changeset_reader.ts +18 -18
- package/src/lib/ci_reconcile.ts +5 -5
- package/src/lib/config_reconcile.ts +8 -4
- package/src/lib/dependency_graph.ts +28 -28
- package/src/lib/dependency_updater.ts +30 -30
- package/src/lib/fetch_repo_data.ts +11 -11
- package/src/lib/fs_fetch_value_cache.ts +14 -10
- package/src/lib/git_operations.ts +31 -31
- package/src/lib/github.ts +19 -19
- package/src/lib/github_helpers.ts +6 -6
- package/src/lib/gitops_analyze.task.ts +56 -48
- package/src/lib/gitops_config.ts +14 -14
- package/src/lib/gitops_plan.task.ts +32 -32
- package/src/lib/gitops_publish.task.ts +52 -49
- package/src/lib/gitops_run.task.ts +29 -29
- package/src/lib/gitops_sync.task.ts +39 -30
- package/src/lib/gitops_task_helpers.ts +21 -21
- package/src/lib/gitops_validate.task.ts +38 -38
- package/src/lib/graph_validation.ts +14 -13
- package/src/lib/local_repo.ts +130 -64
- package/src/lib/log_helpers.ts +15 -15
- package/src/lib/multi_repo_publisher.ts +75 -74
- package/src/lib/npm_registry.ts +13 -13
- package/src/lib/operations.ts +50 -39
- package/src/lib/operations_defaults.ts +108 -106
- package/src/lib/output_helpers.ts +4 -4
- package/src/lib/preflight_checks.ts +28 -28
- package/src/lib/publish_gate.ts +7 -9
- package/src/lib/publish_steps.ts +15 -15
- package/src/lib/publishing_event.ts +22 -20
- package/src/lib/publishing_event_handler.ts +8 -8
- package/src/lib/publishing_plan.ts +69 -57
- package/src/lib/publishing_plan_helpers.ts +16 -12
- package/src/lib/publishing_plan_logging.ts +23 -23
- package/src/lib/repo.svelte.ts +8 -8
- package/src/lib/repo_ops.ts +12 -12
- package/src/lib/resolved_gitops_config.ts +5 -5
- package/src/lib/version_utils.ts +3 -3
package/src/lib/ci_reconcile.ts
CHANGED
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
* @module
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import {existsSync, readdirSync} from 'node:fs';
|
|
18
|
-
import {join} from 'node:path';
|
|
17
|
+
import { existsSync, readdirSync } from 'node:fs';
|
|
18
|
+
import { join } from 'node:path';
|
|
19
19
|
|
|
20
20
|
/** How a repo's declared `ci` diverges from its workflow files on disk. */
|
|
21
21
|
export type CiDriftKind =
|
|
@@ -52,11 +52,11 @@ export const reconcile_ci = (repos: Array<CiReconcileInput>): Array<CiDrift> =>
|
|
|
52
52
|
const drift: Array<CiDrift> = [];
|
|
53
53
|
for (const repo of repos) {
|
|
54
54
|
if (!repo.checkable || repo.archived) continue;
|
|
55
|
-
const {repo_url, ci, has_workflows} = repo;
|
|
55
|
+
const { repo_url, ci, has_workflows } = repo;
|
|
56
56
|
if (ci && !has_workflows) {
|
|
57
|
-
drift.push({repo_url, ci, has_workflows, kind: 'missing_ci'});
|
|
57
|
+
drift.push({ repo_url, ci, has_workflows, kind: 'missing_ci' });
|
|
58
58
|
} else if (!ci && has_workflows) {
|
|
59
|
-
drift.push({repo_url, ci, has_workflows, kind: 'stray_ci'});
|
|
59
|
+
drift.push({ repo_url, ci, has_workflows, kind: 'stray_ci' });
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
return drift;
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* @module
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
import type {GitopsRepoConfig} from './gitops_config.
|
|
14
|
+
import type { GitopsRepoConfig } from './gitops_config.ts';
|
|
15
15
|
|
|
16
16
|
/** Repo fields that must agree across every config that lists the repo. */
|
|
17
17
|
const INTRINSIC_FIELDS = ['visibility', 'ci', 'archived', 'branch'] as const;
|
|
@@ -63,7 +63,7 @@ const field_value = (repo: GitopsRepoConfig, field: IntrinsicField): string => {
|
|
|
63
63
|
*/
|
|
64
64
|
export const reconcile_configs = (
|
|
65
65
|
canonical: NamedRepos,
|
|
66
|
-
subsets: Array<NamedRepos
|
|
66
|
+
subsets: Array<NamedRepos>
|
|
67
67
|
): Array<ConfigDrift> => {
|
|
68
68
|
const drift: Array<ConfigDrift> = [];
|
|
69
69
|
const canonical_by_url = new Map(canonical.repos.map((r) => [r.repo_url, r] as const));
|
|
@@ -71,7 +71,11 @@ export const reconcile_configs = (
|
|
|
71
71
|
for (const repo of subset.repos) {
|
|
72
72
|
const canon = canonical_by_url.get(repo.repo_url);
|
|
73
73
|
if (!canon) {
|
|
74
|
-
drift.push({
|
|
74
|
+
drift.push({
|
|
75
|
+
repo_url: repo.repo_url,
|
|
76
|
+
config: subset.name,
|
|
77
|
+
kind: 'missing_from_canonical'
|
|
78
|
+
});
|
|
75
79
|
continue;
|
|
76
80
|
}
|
|
77
81
|
for (const field of INTRINSIC_FIELDS) {
|
|
@@ -84,7 +88,7 @@ export const reconcile_configs = (
|
|
|
84
88
|
kind: 'field_mismatch',
|
|
85
89
|
field,
|
|
86
90
|
canonical_value,
|
|
87
|
-
config_value
|
|
91
|
+
config_value
|
|
88
92
|
});
|
|
89
93
|
}
|
|
90
94
|
}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Dependency graph data structure and algorithms for multi-repo publishing.
|
|
3
3
|
*
|
|
4
|
-
* Provides `DependencyGraph` class with topological sort (via `@fuzdev/fuz_util/sort.
|
|
4
|
+
* Provides `DependencyGraph` class with topological sort (via `@fuzdev/fuz_util/sort.ts`)
|
|
5
5
|
* and cycle detection by dependency type.
|
|
6
6
|
* For validation workflow and publishing order computation, see `graph_validation.ts`.
|
|
7
7
|
*
|
|
8
8
|
* @module
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import {EMPTY_OBJECT} from '@fuzdev/fuz_util/object.
|
|
12
|
-
import {topological_sort as topological_sort_generic} from '@fuzdev/fuz_util/sort.
|
|
11
|
+
import { EMPTY_OBJECT } from '@fuzdev/fuz_util/object.ts';
|
|
12
|
+
import { topological_sort as topological_sort_generic } from '@fuzdev/fuz_util/sort.ts';
|
|
13
13
|
|
|
14
|
-
import type {LocalRepo} from './local_repo.
|
|
14
|
+
import type { LocalRepo } from './local_repo.ts';
|
|
15
15
|
|
|
16
16
|
export const DEPENDENCY_TYPE = {
|
|
17
17
|
PROD: 'prod',
|
|
18
18
|
PEER: 'peer',
|
|
19
|
-
DEV: 'dev'
|
|
19
|
+
DEV: 'dev'
|
|
20
20
|
} as const;
|
|
21
21
|
|
|
22
22
|
export type DependencyType = (typeof DEPENDENCY_TYPE)[keyof typeof DEPENDENCY_TYPE];
|
|
@@ -31,11 +31,11 @@ export interface DependencyGraphJson {
|
|
|
31
31
|
nodes: Array<{
|
|
32
32
|
name: string;
|
|
33
33
|
version: string;
|
|
34
|
-
dependencies: Array<{name: string; spec: DependencySpec}>;
|
|
34
|
+
dependencies: Array<{ name: string; spec: DependencySpec }>;
|
|
35
35
|
dependents: Array<string>;
|
|
36
36
|
publishable: boolean;
|
|
37
37
|
}>;
|
|
38
|
-
edges: Array<{from: string; to: string}>;
|
|
38
|
+
edges: Array<{ from: string; to: string }>;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
export interface DependencyNode {
|
|
@@ -59,14 +59,14 @@ export class DependencyGraph {
|
|
|
59
59
|
public init_from_repos(repos: Array<LocalRepo>): void {
|
|
60
60
|
// First pass: create nodes
|
|
61
61
|
for (const repo of repos) {
|
|
62
|
-
const {library, package_json} = repo;
|
|
62
|
+
const { library, package_json } = repo;
|
|
63
63
|
const node: DependencyNode = {
|
|
64
64
|
name: library.name,
|
|
65
65
|
version: package_json.version || '0.0.0',
|
|
66
66
|
repo,
|
|
67
67
|
dependencies: new Map(),
|
|
68
68
|
dependents: new Set(),
|
|
69
|
-
publishable: !package_json.private
|
|
69
|
+
publishable: !package_json.private
|
|
70
70
|
};
|
|
71
71
|
|
|
72
72
|
// Extract dependencies
|
|
@@ -77,15 +77,15 @@ export class DependencyGraph {
|
|
|
77
77
|
// Add dependencies, prioritizing prod/peer over dev
|
|
78
78
|
// (if a package appears in multiple dep types, use the stronger constraint)
|
|
79
79
|
for (const [name, version] of Object.entries(deps)) {
|
|
80
|
-
node.dependencies.set(name, {type: DEPENDENCY_TYPE.PROD, version});
|
|
80
|
+
node.dependencies.set(name, { type: DEPENDENCY_TYPE.PROD, version });
|
|
81
81
|
}
|
|
82
82
|
for (const [name, version] of Object.entries(peer_deps)) {
|
|
83
|
-
node.dependencies.set(name, {type: DEPENDENCY_TYPE.PEER, version});
|
|
83
|
+
node.dependencies.set(name, { type: DEPENDENCY_TYPE.PEER, version });
|
|
84
84
|
}
|
|
85
85
|
for (const [name, version] of Object.entries(dev_deps)) {
|
|
86
86
|
// Only add dev deps if not already present as prod/peer
|
|
87
87
|
if (!node.dependencies.has(name)) {
|
|
88
|
-
node.dependencies.set(name, {type: DEPENDENCY_TYPE.DEV, version});
|
|
88
|
+
node.dependencies.set(name, { type: DEPENDENCY_TYPE.DEV, version });
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
|
|
@@ -122,7 +122,7 @@ export class DependencyGraph {
|
|
|
122
122
|
/**
|
|
123
123
|
* Computes topological sort order for dependency graph.
|
|
124
124
|
*
|
|
125
|
-
* Delegates to `@fuzdev/fuz_util/sort.
|
|
125
|
+
* Delegates to `@fuzdev/fuz_util/sort.ts` for the sorting algorithm.
|
|
126
126
|
* Throws if cycles detected.
|
|
127
127
|
*
|
|
128
128
|
* @param exclude_dev - if true, excludes dev dependencies to break cycles
|
|
@@ -138,7 +138,7 @@ export class DependencyGraph {
|
|
|
138
138
|
if (exclude_dev && spec.type === DEPENDENCY_TYPE.DEV) return false;
|
|
139
139
|
return this.nodes.has(dep_name);
|
|
140
140
|
})
|
|
141
|
-
.map(([dep_name]) => dep_name)
|
|
141
|
+
.map(([dep_name]) => dep_name)
|
|
142
142
|
}));
|
|
143
143
|
const result = topological_sort_generic(items, 'package');
|
|
144
144
|
if (!result.ok) {
|
|
@@ -164,7 +164,7 @@ export class DependencyGraph {
|
|
|
164
164
|
} {
|
|
165
165
|
const production_cycles = this.#find_cycles((spec) => spec.type !== DEPENDENCY_TYPE.DEV);
|
|
166
166
|
const dev_cycles = this.#find_cycles((spec) => spec.type === DEPENDENCY_TYPE.DEV);
|
|
167
|
-
return {production_cycles, dev_cycles};
|
|
167
|
+
return { production_cycles, dev_cycles };
|
|
168
168
|
}
|
|
169
169
|
|
|
170
170
|
/** DFS cycle detection following only edges that match the filter. */
|
|
@@ -217,20 +217,20 @@ export class DependencyGraph {
|
|
|
217
217
|
version: node.version,
|
|
218
218
|
dependencies: Array.from(node.dependencies.entries()).map(([name, spec]) => ({
|
|
219
219
|
name,
|
|
220
|
-
spec
|
|
220
|
+
spec
|
|
221
221
|
})),
|
|
222
222
|
dependents: Array.from(node.dependents),
|
|
223
|
-
publishable: node.publishable
|
|
223
|
+
publishable: node.publishable
|
|
224
224
|
}));
|
|
225
225
|
|
|
226
|
-
const edges: Array<{from: string; to: string}> = [];
|
|
226
|
+
const edges: Array<{ from: string; to: string }> = [];
|
|
227
227
|
for (const [from, tos] of this.edges) {
|
|
228
228
|
for (const to of tos) {
|
|
229
|
-
edges.push({from, to});
|
|
229
|
+
edges.push({ from, to });
|
|
230
230
|
}
|
|
231
231
|
}
|
|
232
232
|
|
|
233
|
-
return {nodes, edges};
|
|
233
|
+
return { nodes, edges };
|
|
234
234
|
}
|
|
235
235
|
}
|
|
236
236
|
|
|
@@ -270,25 +270,25 @@ export class DependencyGraphBuilder {
|
|
|
270
270
|
analyze(graph: DependencyGraph): {
|
|
271
271
|
production_cycles: Array<Array<string>>;
|
|
272
272
|
dev_cycles: Array<Array<string>>;
|
|
273
|
-
wildcard_deps: Array<{pkg: string; dep: string; version: string}>;
|
|
274
|
-
missing_peers: Array<{pkg: string; dep: string}>;
|
|
273
|
+
wildcard_deps: Array<{ pkg: string; dep: string; version: string }>;
|
|
274
|
+
missing_peers: Array<{ pkg: string; dep: string }>;
|
|
275
275
|
} {
|
|
276
|
-
const {production_cycles, dev_cycles} = graph.detect_cycles_by_type();
|
|
277
|
-
const wildcard_deps: Array<{pkg: string; dep: string; version: string}> = [];
|
|
278
|
-
const missing_peers: Array<{pkg: string; dep: string}> = [];
|
|
276
|
+
const { production_cycles, dev_cycles } = graph.detect_cycles_by_type();
|
|
277
|
+
const wildcard_deps: Array<{ pkg: string; dep: string; version: string }> = [];
|
|
278
|
+
const missing_peers: Array<{ pkg: string; dep: string }> = [];
|
|
279
279
|
|
|
280
280
|
for (const node of graph.nodes.values()) {
|
|
281
281
|
for (const [dep_name, spec] of node.dependencies) {
|
|
282
282
|
if (spec.version === '*') {
|
|
283
|
-
wildcard_deps.push({pkg: node.name, dep: dep_name, version: spec.version});
|
|
283
|
+
wildcard_deps.push({ pkg: node.name, dep: dep_name, version: spec.version });
|
|
284
284
|
}
|
|
285
285
|
if (spec.type === DEPENDENCY_TYPE.PEER && !graph.nodes.has(dep_name)) {
|
|
286
286
|
// External peer dependency
|
|
287
|
-
missing_peers.push({pkg: node.name, dep: dep_name});
|
|
287
|
+
missing_peers.push({ pkg: node.name, dep: dep_name });
|
|
288
288
|
}
|
|
289
289
|
}
|
|
290
290
|
}
|
|
291
291
|
|
|
292
|
-
return {production_cycles, dev_cycles, wildcard_deps, missing_peers};
|
|
292
|
+
return { production_cycles, dev_cycles, wildcard_deps, missing_peers };
|
|
293
293
|
}
|
|
294
294
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import type {Logger} from '@fuzdev/fuz_util/log.
|
|
2
|
-
import {join} from 'node:path';
|
|
1
|
+
import type { Logger } from '@fuzdev/fuz_util/log.ts';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
3
|
|
|
4
|
-
import type {LocalRepo} from './local_repo.
|
|
5
|
-
import type {PublishedVersion} from './multi_repo_publisher.
|
|
4
|
+
import type { LocalRepo } from './local_repo.ts';
|
|
5
|
+
import type { PublishedVersion } from './multi_repo_publisher.ts';
|
|
6
6
|
import {
|
|
7
7
|
create_changeset_for_dependency_updates,
|
|
8
|
-
create_dependency_updates
|
|
9
|
-
} from './changeset_generator.
|
|
10
|
-
import {needs_update, get_update_prefix} from './version_utils.
|
|
11
|
-
import type {GitOperations, FsOperations} from './operations.
|
|
12
|
-
import {default_git_operations, default_fs_operations} from './operations_defaults.
|
|
8
|
+
create_dependency_updates
|
|
9
|
+
} from './changeset_generator.ts';
|
|
10
|
+
import { needs_update, get_update_prefix } from './version_utils.ts';
|
|
11
|
+
import type { GitOperations, FsOperations } from './operations.ts';
|
|
12
|
+
import { default_git_operations, default_fs_operations } from './operations_defaults.ts';
|
|
13
13
|
|
|
14
14
|
export type VersionStrategy = 'exact' | 'caret' | 'tilde' | 'gte';
|
|
15
15
|
|
|
@@ -38,21 +38,21 @@ export interface UpdatePackageJsonOptions {
|
|
|
38
38
|
export const update_package_json = async (
|
|
39
39
|
repo: LocalRepo,
|
|
40
40
|
updates: Map<string, string>,
|
|
41
|
-
options: UpdatePackageJsonOptions = {}
|
|
41
|
+
options: UpdatePackageJsonOptions = {}
|
|
42
42
|
): Promise<void> => {
|
|
43
43
|
const {
|
|
44
44
|
strategy = 'caret',
|
|
45
45
|
published_versions,
|
|
46
46
|
log,
|
|
47
47
|
git_ops = default_git_operations,
|
|
48
|
-
fs_ops = default_fs_operations
|
|
48
|
+
fs_ops = default_fs_operations
|
|
49
49
|
} = options;
|
|
50
50
|
if (updates.size === 0) return;
|
|
51
51
|
|
|
52
52
|
const package_json_path = join(repo.repo_dir, 'package.json');
|
|
53
53
|
|
|
54
54
|
// Read current package.json
|
|
55
|
-
const content_result = await fs_ops.readFile({path: package_json_path, encoding: 'utf8'});
|
|
55
|
+
const content_result = await fs_ops.readFile({ path: package_json_path, encoding: 'utf8' });
|
|
56
56
|
if (!content_result.ok) {
|
|
57
57
|
throw new Error(`Failed to read package.json: ${content_result.message}`);
|
|
58
58
|
}
|
|
@@ -105,7 +105,7 @@ export const update_package_json = async (
|
|
|
105
105
|
// Write updated package.json
|
|
106
106
|
const write_result = await fs_ops.writeFile({
|
|
107
107
|
path: package_json_path,
|
|
108
|
-
content: JSON.stringify(package_json, null, '\t') + '\n'
|
|
108
|
+
content: JSON.stringify(package_json, null, '\t') + '\n'
|
|
109
109
|
});
|
|
110
110
|
if (!write_result.ok) {
|
|
111
111
|
throw new Error(`Failed to write package.json: ${write_result.message}`);
|
|
@@ -145,11 +145,11 @@ export const update_package_json = async (
|
|
|
145
145
|
const changeset_path = await create_changeset_for_dependency_updates(
|
|
146
146
|
repo,
|
|
147
147
|
dependency_updates,
|
|
148
|
-
{log, fs_ops}
|
|
148
|
+
{ log, fs_ops }
|
|
149
149
|
);
|
|
150
150
|
|
|
151
151
|
// Add changeset to git
|
|
152
|
-
const add_result = await git_ops.add({files: changeset_path, cwd: repo.repo_dir});
|
|
152
|
+
const add_result = await git_ops.add({ files: changeset_path, cwd: repo.repo_dir });
|
|
153
153
|
if (!add_result.ok) {
|
|
154
154
|
throw new Error(`Failed to stage changeset: ${add_result.message}`);
|
|
155
155
|
}
|
|
@@ -157,14 +157,14 @@ export const update_package_json = async (
|
|
|
157
157
|
}
|
|
158
158
|
|
|
159
159
|
// Commit the changes (including both package.json and changeset)
|
|
160
|
-
const add_pkg_result = await git_ops.add({files: 'package.json', cwd: repo.repo_dir});
|
|
160
|
+
const add_pkg_result = await git_ops.add({ files: 'package.json', cwd: repo.repo_dir });
|
|
161
161
|
if (!add_pkg_result.ok) {
|
|
162
162
|
throw new Error(`Failed to stage package.json: ${add_pkg_result.message}`);
|
|
163
163
|
}
|
|
164
164
|
|
|
165
165
|
const commit_result = await git_ops.commit({
|
|
166
166
|
message: `update dependencies after publishing`,
|
|
167
|
-
cwd: repo.repo_dir
|
|
167
|
+
cwd: repo.repo_dir
|
|
168
168
|
});
|
|
169
169
|
if (!commit_result.ok) {
|
|
170
170
|
throw new Error(`Failed to commit: ${commit_result.message}`);
|
|
@@ -181,16 +181,16 @@ export interface UpdateAllReposOptions {
|
|
|
181
181
|
export const update_all_repos = async (
|
|
182
182
|
repos: Array<LocalRepo>,
|
|
183
183
|
published: Map<string, string>,
|
|
184
|
-
options: UpdateAllReposOptions = {}
|
|
185
|
-
): Promise<{updated: number; failed: Array<{repo: string; error: Error}>}> => {
|
|
184
|
+
options: UpdateAllReposOptions = {}
|
|
185
|
+
): Promise<{ updated: number; failed: Array<{ repo: string; error: Error }> }> => {
|
|
186
186
|
const {
|
|
187
187
|
strategy = 'caret',
|
|
188
188
|
log,
|
|
189
189
|
git_ops = default_git_operations,
|
|
190
|
-
fs_ops = default_fs_operations
|
|
190
|
+
fs_ops = default_fs_operations
|
|
191
191
|
} = options;
|
|
192
192
|
let updated_count = 0;
|
|
193
|
-
const failed: Array<{repo: string; error: Error}> = [];
|
|
193
|
+
const failed: Array<{ repo: string; error: Error }> = [];
|
|
194
194
|
|
|
195
195
|
for (const repo of repos) {
|
|
196
196
|
const updates: Map<string, string> = new Map();
|
|
@@ -226,29 +226,29 @@ export const update_all_repos = async (
|
|
|
226
226
|
if (updates.size === 0) continue;
|
|
227
227
|
|
|
228
228
|
try {
|
|
229
|
-
await update_package_json(repo, updates, {strategy, log, git_ops, fs_ops});
|
|
229
|
+
await update_package_json(repo, updates, { strategy, log, git_ops, fs_ops });
|
|
230
230
|
updated_count++;
|
|
231
231
|
log?.info(` Updated ${updates.size} dependencies in ${repo.library.name}`);
|
|
232
232
|
} catch (error) {
|
|
233
233
|
const err = error instanceof Error ? error : new Error(String(error));
|
|
234
|
-
failed.push({repo: repo.library.name, error: err});
|
|
234
|
+
failed.push({ repo: repo.library.name, error: err });
|
|
235
235
|
log?.error(` Failed to update ${repo.library.name}: ${err.message}`);
|
|
236
236
|
}
|
|
237
237
|
}
|
|
238
238
|
|
|
239
|
-
return {updated: updated_count, failed};
|
|
239
|
+
return { updated: updated_count, failed };
|
|
240
240
|
};
|
|
241
241
|
|
|
242
242
|
export const find_updates_needed = (
|
|
243
243
|
repo: LocalRepo,
|
|
244
|
-
published: Map<string, string
|
|
244
|
+
published: Map<string, string>
|
|
245
245
|
): Map<
|
|
246
246
|
string,
|
|
247
|
-
{current: string; new: string; type: 'dependencies' | 'devDependencies' | 'peerDependencies'}
|
|
247
|
+
{ current: string; new: string; type: 'dependencies' | 'devDependencies' | 'peerDependencies' }
|
|
248
248
|
> => {
|
|
249
249
|
const updates: Map<
|
|
250
250
|
string,
|
|
251
|
-
{current: string; new: string; type: 'dependencies' | 'devDependencies' | 'peerDependencies'}
|
|
251
|
+
{ current: string; new: string; type: 'dependencies' | 'devDependencies' | 'peerDependencies' }
|
|
252
252
|
> = new Map();
|
|
253
253
|
|
|
254
254
|
// Check dependencies
|
|
@@ -259,7 +259,7 @@ export const find_updates_needed = (
|
|
|
259
259
|
updates.set(dep_name, {
|
|
260
260
|
current: current_version,
|
|
261
261
|
new: new_version,
|
|
262
|
-
type: 'dependencies'
|
|
262
|
+
type: 'dependencies'
|
|
263
263
|
});
|
|
264
264
|
}
|
|
265
265
|
}
|
|
@@ -273,7 +273,7 @@ export const find_updates_needed = (
|
|
|
273
273
|
updates.set(dep_name, {
|
|
274
274
|
current: current_version,
|
|
275
275
|
new: new_version,
|
|
276
|
-
type: 'devDependencies'
|
|
276
|
+
type: 'devDependencies'
|
|
277
277
|
});
|
|
278
278
|
}
|
|
279
279
|
}
|
|
@@ -287,7 +287,7 @@ export const find_updates_needed = (
|
|
|
287
287
|
updates.set(dep_name, {
|
|
288
288
|
current: current_version,
|
|
289
289
|
new: new_version,
|
|
290
|
-
type: 'peerDependencies'
|
|
290
|
+
type: 'peerDependencies'
|
|
291
291
|
});
|
|
292
292
|
}
|
|
293
293
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type {Logger} from '@fuzdev/fuz_util/log.
|
|
2
|
-
import {wait} from '@fuzdev/fuz_util/async.
|
|
3
|
-
import type {FetchValueCache} from '@fuzdev/fuz_util/fetch.
|
|
1
|
+
import type { Logger } from '@fuzdev/fuz_util/log.ts';
|
|
2
|
+
import { wait } from '@fuzdev/fuz_util/async.ts';
|
|
3
|
+
import type { FetchValueCache } from '@fuzdev/fuz_util/fetch.ts';
|
|
4
4
|
|
|
5
|
-
import {fetch_github_check_runs, fetch_github_pull_requests} from './github.
|
|
6
|
-
import type {RepoJson} from './repo.svelte.
|
|
7
|
-
import type {LocalRepo} from './local_repo.
|
|
5
|
+
import { fetch_github_check_runs, fetch_github_pull_requests } from './github.ts';
|
|
6
|
+
import type { RepoJson } from './repo.svelte.ts';
|
|
7
|
+
import type { LocalRepo } from './local_repo.ts';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Fetches GitHub metadata (CI status, PRs) for all repos.
|
|
@@ -25,10 +25,10 @@ export const fetch_repo_data = async (
|
|
|
25
25
|
cache?: FetchValueCache,
|
|
26
26
|
log?: Logger,
|
|
27
27
|
delay = 33,
|
|
28
|
-
github_api_version?: string
|
|
28
|
+
github_api_version?: string
|
|
29
29
|
): Promise<Array<RepoJson>> => {
|
|
30
30
|
const repos: Array<RepoJson> = [];
|
|
31
|
-
for (const {library, package_json, repo_config} of resolved_repos) {
|
|
31
|
+
for (const { library, package_json, repo_config } of resolved_repos) {
|
|
32
32
|
const repo_url = library.repo_url;
|
|
33
33
|
|
|
34
34
|
// CI status
|
|
@@ -38,7 +38,7 @@ export const fetch_repo_data = async (
|
|
|
38
38
|
log,
|
|
39
39
|
token,
|
|
40
40
|
api_version: github_api_version,
|
|
41
|
-
ref: repo_config.branch
|
|
41
|
+
ref: repo_config.branch
|
|
42
42
|
});
|
|
43
43
|
if (!check_runs) log?.error('failed to fetch CI status: ' + repo_url);
|
|
44
44
|
|
|
@@ -48,7 +48,7 @@ export const fetch_repo_data = async (
|
|
|
48
48
|
cache,
|
|
49
49
|
log,
|
|
50
50
|
token,
|
|
51
|
-
api_version: github_api_version
|
|
51
|
+
api_version: github_api_version
|
|
52
52
|
});
|
|
53
53
|
if (!pull_requests) log?.error('failed to fetch issues: ' + repo_url);
|
|
54
54
|
|
|
@@ -56,7 +56,7 @@ export const fetch_repo_data = async (
|
|
|
56
56
|
library_json: library.library_json,
|
|
57
57
|
package_json,
|
|
58
58
|
check_runs,
|
|
59
|
-
pull_requests
|
|
59
|
+
pull_requests
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
62
|
return repos;
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import {mkdir, readFile, rm, writeFile} from 'node:fs/promises';
|
|
2
|
-
import {dirname, join} from 'node:path';
|
|
3
|
-
import {paths} from '@fuzdev/gro/paths.
|
|
4
|
-
import {format_file} from '@fuzdev/gro/format_file.
|
|
5
|
-
import {
|
|
6
|
-
|
|
1
|
+
import { mkdir, readFile, rm, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { dirname, join } from 'node:path';
|
|
3
|
+
import { paths } from '@fuzdev/gro/paths.ts';
|
|
4
|
+
import { format_file } from '@fuzdev/gro/format_file.ts';
|
|
5
|
+
import {
|
|
6
|
+
deserialize_cache,
|
|
7
|
+
serialize_cache,
|
|
8
|
+
type FetchValueCache
|
|
9
|
+
} from '@fuzdev/fuz_util/fetch.ts';
|
|
10
|
+
import { existsSync } from 'node:fs';
|
|
7
11
|
|
|
8
12
|
// TODO upstream to Gro probably, and rename/redesign?
|
|
9
13
|
|
|
@@ -31,7 +35,7 @@ export interface FetchCache {
|
|
|
31
35
|
*/
|
|
32
36
|
export const create_fs_fetch_value_cache = async (
|
|
33
37
|
name: string,
|
|
34
|
-
dir = join(paths.build, 'fetch')
|
|
38
|
+
dir = join(paths.build, 'fetch')
|
|
35
39
|
): Promise<FetchCache> => {
|
|
36
40
|
const data_path = join(dir, name + '.json');
|
|
37
41
|
let data: FetchValueCache;
|
|
@@ -54,10 +58,10 @@ export const create_fs_fetch_value_cache = async (
|
|
|
54
58
|
if (deep_equal_maps(initial, data)) {
|
|
55
59
|
return false; // no changes to save
|
|
56
60
|
}
|
|
57
|
-
await mkdir(dirname(data_path), {recursive: true});
|
|
58
|
-
await writeFile(data_path,
|
|
61
|
+
await mkdir(dirname(data_path), { recursive: true });
|
|
62
|
+
await writeFile(data_path, format_file(serialize_cache(data), { lang: 'json' }));
|
|
59
63
|
return true;
|
|
60
|
-
}
|
|
64
|
+
}
|
|
61
65
|
};
|
|
62
66
|
};
|
|
63
67
|
|