@fuzdev/fuz_gitops 0.78.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 +20 -0
- 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.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/changeset_generator.d.ts.map +1 -1
- package/dist/changeset_generator.js +2 -2
- 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.map +1 -1
- package/dist/dependency_graph.js +5 -5
- package/dist/dependency_updater.d.ts.map +1 -1
- package/dist/dependency_updater.js +8 -8
- package/dist/fetch_repo_data.d.ts.map +1 -1
- package/dist/fetch_repo_data.js +3 -3
- package/dist/fs_fetch_value_cache.d.ts.map +1 -1
- package/dist/fs_fetch_value_cache.js +2 -2
- package/dist/git_operations.d.ts.map +1 -1
- package/dist/git_operations.js +1 -1
- package/dist/github.d.ts.map +1 -1
- package/dist/github.js +6 -6
- package/dist/github_helpers.d.ts.map +1 -1
- package/dist/gitops_analyze.task.d.ts.map +1 -1
- package/dist/gitops_analyze.task.js +7 -7
- package/dist/gitops_config.d.ts.map +1 -1
- package/dist/gitops_config.js +4 -4
- 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 +8 -8
- package/dist/gitops_sync.task.d.ts.map +1 -1
- package/dist/gitops_sync.task.js +11 -9
- package/dist/gitops_task_helpers.d.ts.map +1 -1
- package/dist/gitops_task_helpers.js +3 -3
- package/dist/gitops_validate.task.d.ts.map +1 -1
- package/dist/gitops_validate.task.js +14 -14
- package/dist/graph_validation.d.ts.map +1 -1
- package/dist/graph_validation.js +2 -2
- package/dist/local_repo.d.ts +4 -4
- package/dist/local_repo.d.ts.map +1 -1
- package/dist/local_repo.js +13 -13
- package/dist/log_helpers.d.ts.map +1 -1
- package/dist/multi_repo_publisher.d.ts.map +1 -1
- package/dist/multi_repo_publisher.js +19 -19
- package/dist/npm_registry.d.ts.map +1 -1
- package/dist/npm_registry.js +2 -2
- package/dist/operations.d.ts.map +1 -1
- package/dist/operations_defaults.d.ts.map +1 -1
- package/dist/operations_defaults.js +12 -12
- package/dist/output_helpers.d.ts.map +1 -1
- package/dist/preflight_checks.d.ts +1 -1
- package/dist/preflight_checks.d.ts.map +1 -1
- package/dist/preflight_checks.js +4 -4
- package/dist/publish_gate.d.ts.map +1 -1
- package/dist/publish_steps.d.ts.map +1 -1
- package/dist/publish_steps.js +3 -3
- 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.map +1 -1
- package/dist/publishing_plan.js +14 -14
- 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.map +1 -1
- package/dist/publishing_plan_logging.js +2 -2
- package/dist/repo.svelte.d.ts.map +1 -1
- 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 +3 -3
- package/src/lib/changeset_generator.ts +19 -19
- 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 +26 -26
- package/src/lib/dependency_updater.ts +29 -29
- 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 +30 -30
- package/src/lib/github.ts +19 -19
- package/src/lib/github_helpers.ts +6 -6
- package/src/lib/gitops_analyze.task.ts +40 -40
- package/src/lib/gitops_config.ts +14 -14
- package/src/lib/gitops_plan.task.ts +31 -31
- package/src/lib/gitops_publish.task.ts +51 -48
- 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 +37 -37
- package/src/lib/graph_validation.ts +13 -13
- package/src/lib/local_repo.ts +70 -70
- package/src/lib/log_helpers.ts +15 -15
- package/src/lib/multi_repo_publisher.ts +67 -70
- package/src/lib/npm_registry.ts +13 -13
- package/src/lib/operations.ts +49 -38
- package/src/lib/operations_defaults.ts +106 -104
- package/src/lib/output_helpers.ts +4 -4
- package/src/lib/preflight_checks.ts +26 -26
- 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 +55 -55
- package/src/lib/publishing_plan_helpers.ts +16 -12
- package/src/lib/publishing_plan_logging.ts +22 -22
- 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
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import type {Logger} from '@fuzdev/fuz_util/log.ts';
|
|
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.ts';
|
|
5
|
-
import type {PublishedVersion} from './multi_repo_publisher.ts';
|
|
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
|
|
8
|
+
create_dependency_updates
|
|
9
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';
|
|
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.ts';
|
|
2
|
-
import {wait} from '@fuzdev/fuz_util/async.ts';
|
|
3
|
-
import type {FetchValueCache} from '@fuzdev/fuz_util/fetch.ts';
|
|
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.ts';
|
|
6
|
-
import type {RepoJson} from './repo.svelte.ts';
|
|
7
|
-
import type {LocalRepo} from './local_repo.ts';
|
|
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.ts';
|
|
4
|
-
import {format_file} from '@fuzdev/gro/format_file.ts';
|
|
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
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {spawn_out, spawn_result_to_message} from '@fuzdev/fuz_util/process.ts';
|
|
2
|
-
import type {SpawnOptions} from 'node:child_process';
|
|
1
|
+
import { spawn_out, spawn_result_to_message } from '@fuzdev/fuz_util/process.ts';
|
|
2
|
+
import type { SpawnOptions } from 'node:child_process';
|
|
3
3
|
import {
|
|
4
4
|
git_check_clean_workspace as gro_git_check_clean_workspace,
|
|
5
5
|
git_checkout as gro_git_checkout,
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
git_current_branch_name as gro_git_current_branch_name,
|
|
8
8
|
git_current_commit_hash as gro_git_current_commit_hash,
|
|
9
9
|
type GitBranch,
|
|
10
|
-
type GitOrigin
|
|
10
|
+
type GitOrigin
|
|
11
11
|
} from '@fuzdev/fuz_util/git.ts';
|
|
12
12
|
|
|
13
13
|
/**
|
|
@@ -15,13 +15,13 @@ import {
|
|
|
15
15
|
*/
|
|
16
16
|
export const git_add = async (
|
|
17
17
|
files: string | Array<string>,
|
|
18
|
-
options?: SpawnOptions
|
|
18
|
+
options?: SpawnOptions
|
|
19
19
|
): Promise<void> => {
|
|
20
20
|
const file_list = Array.isArray(files) ? files : [files];
|
|
21
|
-
const {result, stderr} = await spawn_out('git', ['add', ...file_list], options);
|
|
21
|
+
const { result, stderr } = await spawn_out('git', ['add', ...file_list], options);
|
|
22
22
|
if (!result.ok) {
|
|
23
23
|
throw Error(
|
|
24
|
-
`git_add failed with ${spawn_result_to_message(result)}${stderr ? ': ' + stderr.trim() : ''}
|
|
24
|
+
`git_add failed with ${spawn_result_to_message(result)}${stderr ? ': ' + stderr.trim() : ''}`
|
|
25
25
|
);
|
|
26
26
|
}
|
|
27
27
|
};
|
|
@@ -30,10 +30,10 @@ export const git_add = async (
|
|
|
30
30
|
* Commits staged changes with a message and throws if anything goes wrong.
|
|
31
31
|
*/
|
|
32
32
|
export const git_commit = async (message: string, options?: SpawnOptions): Promise<void> => {
|
|
33
|
-
const {result, stderr} = await spawn_out('git', ['commit', '-m', message], options);
|
|
33
|
+
const { result, stderr } = await spawn_out('git', ['commit', '-m', message], options);
|
|
34
34
|
if (!result.ok) {
|
|
35
35
|
throw Error(
|
|
36
|
-
`git_commit failed with ${spawn_result_to_message(result)}${stderr ? ': ' + stderr.trim() : ''}
|
|
36
|
+
`git_commit failed with ${spawn_result_to_message(result)}${stderr ? ': ' + stderr.trim() : ''}`
|
|
37
37
|
);
|
|
38
38
|
}
|
|
39
39
|
};
|
|
@@ -44,7 +44,7 @@ export const git_commit = async (message: string, options?: SpawnOptions): Promi
|
|
|
44
44
|
export const git_add_and_commit = async (
|
|
45
45
|
files: string | Array<string>,
|
|
46
46
|
message: string,
|
|
47
|
-
options?: SpawnOptions
|
|
47
|
+
options?: SpawnOptions
|
|
48
48
|
): Promise<void> => {
|
|
49
49
|
await git_add(files, options);
|
|
50
50
|
await git_commit(message, options);
|
|
@@ -56,14 +56,14 @@ export const git_add_and_commit = async (
|
|
|
56
56
|
export const git_tag = async (
|
|
57
57
|
tag_name: string,
|
|
58
58
|
message?: string,
|
|
59
|
-
options?: SpawnOptions
|
|
59
|
+
options?: SpawnOptions
|
|
60
60
|
): Promise<void> => {
|
|
61
61
|
const args = message ? ['tag', '-a', tag_name, '-m', message] : ['tag', tag_name];
|
|
62
62
|
|
|
63
|
-
const {result, stderr} = await spawn_out('git', args, options);
|
|
63
|
+
const { result, stderr } = await spawn_out('git', args, options);
|
|
64
64
|
if (!result.ok) {
|
|
65
65
|
throw Error(
|
|
66
|
-
`git_tag failed for tag '${tag_name}' with ${spawn_result_to_message(result)}${stderr ? ': ' + stderr.trim() : ''}
|
|
66
|
+
`git_tag failed for tag '${tag_name}' with ${spawn_result_to_message(result)}${stderr ? ': ' + stderr.trim() : ''}`
|
|
67
67
|
);
|
|
68
68
|
}
|
|
69
69
|
};
|
|
@@ -74,12 +74,12 @@ export const git_tag = async (
|
|
|
74
74
|
export const git_push_tag = async (
|
|
75
75
|
tag_name: string,
|
|
76
76
|
origin: GitOrigin = 'origin' as GitOrigin,
|
|
77
|
-
options?: SpawnOptions
|
|
77
|
+
options?: SpawnOptions
|
|
78
78
|
): Promise<void> => {
|
|
79
|
-
const {result, stderr} = await spawn_out('git', ['push', origin, tag_name], options);
|
|
79
|
+
const { result, stderr } = await spawn_out('git', ['push', origin, tag_name], options);
|
|
80
80
|
if (!result.ok) {
|
|
81
81
|
throw Error(
|
|
82
|
-
`git_push_tag failed for tag '${tag_name}' with ${spawn_result_to_message(result)}${stderr ? ': ' + stderr.trim() : ''}
|
|
82
|
+
`git_push_tag failed for tag '${tag_name}' with ${spawn_result_to_message(result)}${stderr ? ': ' + stderr.trim() : ''}`
|
|
83
83
|
);
|
|
84
84
|
}
|
|
85
85
|
};
|
|
@@ -90,7 +90,7 @@ export const git_push_tag = async (
|
|
|
90
90
|
* which reports only tracked working-tree changes relative to HEAD.
|
|
91
91
|
*/
|
|
92
92
|
export const git_has_changes = async (options?: SpawnOptions): Promise<boolean> => {
|
|
93
|
-
const {stdout} = await spawn_out('git', ['status', '--porcelain'], options);
|
|
93
|
+
const { stdout } = await spawn_out('git', ['status', '--porcelain'], options);
|
|
94
94
|
return stdout ? stdout.trim().length > 0 : false;
|
|
95
95
|
};
|
|
96
96
|
|
|
@@ -98,9 +98,9 @@ export const git_has_changes = async (options?: SpawnOptions): Promise<boolean>
|
|
|
98
98
|
* Lists uncommitted files in the working tree (`git diff --name-only HEAD`).
|
|
99
99
|
*/
|
|
100
100
|
export const git_list_uncommitted_files = async (
|
|
101
|
-
options?: SpawnOptions
|
|
101
|
+
options?: SpawnOptions
|
|
102
102
|
): Promise<Array<string>> => {
|
|
103
|
-
const {stdout} = await spawn_out('git', ['diff', '--name-only', 'HEAD'], options);
|
|
103
|
+
const { stdout } = await spawn_out('git', ['diff', '--name-only', 'HEAD'], options);
|
|
104
104
|
if (!stdout) return [];
|
|
105
105
|
|
|
106
106
|
return stdout
|
|
@@ -113,12 +113,12 @@ export const git_has_file_changed = async (
|
|
|
113
113
|
from_commit: string,
|
|
114
114
|
to_commit: string,
|
|
115
115
|
file_path: string,
|
|
116
|
-
options?: SpawnOptions
|
|
116
|
+
options?: SpawnOptions
|
|
117
117
|
): Promise<boolean> => {
|
|
118
|
-
const {stdout} = await spawn_out(
|
|
118
|
+
const { stdout } = await spawn_out(
|
|
119
119
|
'git',
|
|
120
120
|
['diff', '--name-only', from_commit, to_commit, '--', file_path],
|
|
121
|
-
options
|
|
121
|
+
options
|
|
122
122
|
);
|
|
123
123
|
return stdout ? stdout.trim().length > 0 : false;
|
|
124
124
|
};
|
|
@@ -129,10 +129,10 @@ export const git_has_file_changed = async (
|
|
|
129
129
|
export const git_stash = async (message?: string, options?: SpawnOptions): Promise<void> => {
|
|
130
130
|
const args = message ? ['stash', 'push', '-m', message] : ['stash', 'push'];
|
|
131
131
|
|
|
132
|
-
const {result, stderr} = await spawn_out('git', args, options);
|
|
132
|
+
const { result, stderr } = await spawn_out('git', args, options);
|
|
133
133
|
if (!result.ok) {
|
|
134
134
|
throw Error(
|
|
135
|
-
`git_stash failed with ${spawn_result_to_message(result)}${stderr ? ': ' + stderr.trim() : ''}
|
|
135
|
+
`git_stash failed with ${spawn_result_to_message(result)}${stderr ? ': ' + stderr.trim() : ''}`
|
|
136
136
|
);
|
|
137
137
|
}
|
|
138
138
|
};
|
|
@@ -141,10 +141,10 @@ export const git_stash = async (message?: string, options?: SpawnOptions): Promi
|
|
|
141
141
|
* Applies stashed changes and throws if anything goes wrong.
|
|
142
142
|
*/
|
|
143
143
|
export const git_stash_pop = async (options?: SpawnOptions): Promise<void> => {
|
|
144
|
-
const {result, stderr} = await spawn_out('git', ['stash', 'pop'], options);
|
|
144
|
+
const { result, stderr } = await spawn_out('git', ['stash', 'pop'], options);
|
|
145
145
|
if (!result.ok) {
|
|
146
146
|
throw Error(
|
|
147
|
-
`git_stash_pop failed with ${spawn_result_to_message(result)}${stderr ? ': ' + stderr.trim() : ''}
|
|
147
|
+
`git_stash_pop failed with ${spawn_result_to_message(result)}${stderr ? ': ' + stderr.trim() : ''}`
|
|
148
148
|
);
|
|
149
149
|
}
|
|
150
150
|
};
|
|
@@ -155,7 +155,7 @@ export const git_stash_pop = async (options?: SpawnOptions): Promise<void> => {
|
|
|
155
155
|
export const git_switch_branch = async (
|
|
156
156
|
branch: GitBranch,
|
|
157
157
|
pull: boolean = true,
|
|
158
|
-
options?: SpawnOptions
|
|
158
|
+
options?: SpawnOptions
|
|
159
159
|
): Promise<void> => {
|
|
160
160
|
// Check if workspace is clean first
|
|
161
161
|
const error = await gro_git_check_clean_workspace(options);
|
|
@@ -194,7 +194,7 @@ export const git_current_branch_name_required = async (options?: SpawnOptions):
|
|
|
194
194
|
*/
|
|
195
195
|
export const git_current_commit_hash_required = async (
|
|
196
196
|
branch?: string,
|
|
197
|
-
options?: SpawnOptions
|
|
197
|
+
options?: SpawnOptions
|
|
198
198
|
): Promise<string> => {
|
|
199
199
|
const hash = await gro_git_current_commit_hash(branch, options);
|
|
200
200
|
if (!hash) {
|
|
@@ -207,7 +207,7 @@ export const git_current_commit_hash_required = async (
|
|
|
207
207
|
* Wrapper for gro's `git_check_clean_workspace` that returns a boolean.
|
|
208
208
|
*/
|
|
209
209
|
export const git_check_clean_workspace_as_boolean = async (
|
|
210
|
-
options?: SpawnOptions
|
|
210
|
+
options?: SpawnOptions
|
|
211
211
|
): Promise<boolean> => {
|
|
212
212
|
const error = await gro_git_check_clean_workspace(options);
|
|
213
213
|
return error === null;
|
|
@@ -215,9 +215,9 @@ export const git_check_clean_workspace_as_boolean = async (
|
|
|
215
215
|
|
|
216
216
|
export const git_has_remote = async (
|
|
217
217
|
remote: string = 'origin',
|
|
218
|
-
options?: SpawnOptions
|
|
218
|
+
options?: SpawnOptions
|
|
219
219
|
): Promise<boolean> => {
|
|
220
|
-
const {stdout} = await spawn_out('git', ['remote'], options);
|
|
220
|
+
const { stdout } = await spawn_out('git', ['remote'], options);
|
|
221
221
|
if (!stdout) return false;
|
|
222
222
|
const remotes = stdout
|
|
223
223
|
.split('\n')
|
package/src/lib/github.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {Logger} from '@fuzdev/fuz_util/log.ts';
|
|
2
|
-
import {z} from 'zod';
|
|
3
|
-
import {fetch_value, type FetchValueCache} from '@fuzdev/fuz_util/fetch.ts';
|
|
1
|
+
import type { Logger } from '@fuzdev/fuz_util/log.ts';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { fetch_value, type FetchValueCache } from '@fuzdev/fuz_util/fetch.ts';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Minimal interface for GitHub API calls - works with both `Pkg` and `Repo`.
|
|
@@ -17,9 +17,9 @@ export const GithubPullRequest = z.object({
|
|
|
17
17
|
number: z.number(),
|
|
18
18
|
title: z.string(),
|
|
19
19
|
user: z.object({
|
|
20
|
-
login: z.string()
|
|
20
|
+
login: z.string()
|
|
21
21
|
}),
|
|
22
|
-
draft: z.boolean()
|
|
22
|
+
draft: z.boolean()
|
|
23
23
|
});
|
|
24
24
|
export type GithubPullRequest = z.infer<typeof GithubPullRequest>;
|
|
25
25
|
export const GithubPullRequests = z.array(GithubPullRequest);
|
|
@@ -35,24 +35,24 @@ export const fetch_github_pull_requests = async (
|
|
|
35
35
|
log?: Logger;
|
|
36
36
|
token?: string;
|
|
37
37
|
api_version?: string;
|
|
38
|
-
} = {}
|
|
38
|
+
} = {}
|
|
39
39
|
): Promise<GithubPullRequests | null> => {
|
|
40
|
-
const {cache, log, token, api_version} = options;
|
|
40
|
+
const { cache, log, token, api_version } = options;
|
|
41
41
|
if (!repo_info.owner_name) throw Error('owner_name is required');
|
|
42
|
-
const headers = api_version ? new Headers({'x-github-api-version': api_version}) : undefined;
|
|
42
|
+
const headers = api_version ? new Headers({ 'x-github-api-version': api_version }) : undefined;
|
|
43
43
|
const url = `https://api.github.com/repos/${repo_info.owner_name}/${repo_info.repo_name}/pulls`;
|
|
44
44
|
const fetched = await fetch_value(url, {
|
|
45
|
-
request: {headers},
|
|
45
|
+
request: { headers },
|
|
46
46
|
parse: GithubPullRequests.parse,
|
|
47
47
|
token,
|
|
48
48
|
cache,
|
|
49
|
-
log
|
|
49
|
+
log
|
|
50
50
|
});
|
|
51
51
|
if (!fetched.ok) {
|
|
52
52
|
// TODO @many this is messy but I think it's the main case we need to worry about?
|
|
53
53
|
if (fetched.status === 401) {
|
|
54
54
|
throw Error(
|
|
55
|
-
'401 response fetching github pull requests - check your SECRET_GITHUB_API_TOKEN'
|
|
55
|
+
'401 response fetching github pull requests - check your SECRET_GITHUB_API_TOKEN'
|
|
56
56
|
);
|
|
57
57
|
}
|
|
58
58
|
return null;
|
|
@@ -67,12 +67,12 @@ export const GithubCheckRunsItem = z.object({
|
|
|
67
67
|
status: z.enum(['queued', 'in_progress', 'completed']),
|
|
68
68
|
conclusion: z
|
|
69
69
|
.enum(['success', 'failure', 'neutral', 'cancelled', 'skipped', 'timed_out', 'action_required'])
|
|
70
|
-
.nullable()
|
|
70
|
+
.nullable()
|
|
71
71
|
});
|
|
72
72
|
export type GithubCheckRunsItem = z.infer<typeof GithubCheckRunsItem>;
|
|
73
73
|
export const GithubCheckRuns = z.object({
|
|
74
74
|
total_count: z.number(),
|
|
75
|
-
check_runs: z.array(GithubCheckRunsItem)
|
|
75
|
+
check_runs: z.array(GithubCheckRunsItem)
|
|
76
76
|
});
|
|
77
77
|
export type GithubCheckRuns = z.infer<typeof GithubCheckRuns>;
|
|
78
78
|
|
|
@@ -87,18 +87,18 @@ export const fetch_github_check_runs = async (
|
|
|
87
87
|
token?: string;
|
|
88
88
|
api_version?: string;
|
|
89
89
|
ref?: string;
|
|
90
|
-
} = {}
|
|
90
|
+
} = {}
|
|
91
91
|
): Promise<GithubCheckRunsItem | null> => {
|
|
92
|
-
const {cache, log, token, api_version, ref = 'main'} = options;
|
|
92
|
+
const { cache, log, token, api_version, ref = 'main' } = options;
|
|
93
93
|
if (!repo_info.owner_name) throw Error('owner_name is required');
|
|
94
|
-
const headers = api_version ? new Headers({'x-github-api-version': api_version}) : undefined;
|
|
94
|
+
const headers = api_version ? new Headers({ 'x-github-api-version': api_version }) : undefined;
|
|
95
95
|
const url = `https://api.github.com/repos/${repo_info.owner_name}/${repo_info.repo_name}/commits/${ref}/check-runs`;
|
|
96
96
|
const fetched = await fetch_value(url, {
|
|
97
|
-
request: {headers},
|
|
97
|
+
request: { headers },
|
|
98
98
|
parse: (v) => reduce_check_runs(GithubCheckRuns.parse(v).check_runs),
|
|
99
99
|
token,
|
|
100
100
|
cache,
|
|
101
|
-
log
|
|
101
|
+
log
|
|
102
102
|
});
|
|
103
103
|
if (!fetched.ok) {
|
|
104
104
|
// TODO @many this is messy but I think it's the main case we need to worry about?
|
|
@@ -123,5 +123,5 @@ const reduce_check_runs = (check_runs: Array<GithubCheckRunsItem>): GithubCheckR
|
|
|
123
123
|
conclusion = check_run.conclusion;
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
|
-
return {status, conclusion};
|
|
126
|
+
return { status, conclusion };
|
|
127
127
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {ensure_end} from '@fuzdev/fuz_util/string.ts';
|
|
1
|
+
import { ensure_end } from '@fuzdev/fuz_util/string.ts';
|
|
2
2
|
|
|
3
|
-
import type {GithubPullRequest} from './github.ts';
|
|
4
|
-
import type {Repo} from './repo.svelte.ts';
|
|
3
|
+
import type { GithubPullRequest } from './github.ts';
|
|
4
|
+
import type { Repo } from './repo.svelte.ts';
|
|
5
5
|
|
|
6
6
|
export type FilterPullRequest = (pull_request: GithubPullRequest, repo: Repo) => boolean;
|
|
7
7
|
|
|
@@ -12,7 +12,7 @@ export interface PullRequestMeta {
|
|
|
12
12
|
|
|
13
13
|
export const to_pull_requests = (
|
|
14
14
|
repos: Array<Repo>,
|
|
15
|
-
filter_pull_request?: FilterPullRequest
|
|
15
|
+
filter_pull_request?: FilterPullRequest
|
|
16
16
|
): Array<PullRequestMeta> =>
|
|
17
17
|
repos
|
|
18
18
|
.flatMap((repo) => {
|
|
@@ -21,8 +21,8 @@ export const to_pull_requests = (
|
|
|
21
21
|
return repo.pull_requests.map((pull_request) =>
|
|
22
22
|
repo.package_json.homepage &&
|
|
23
23
|
(!filter_pull_request || filter_pull_request(pull_request, repo))
|
|
24
|
-
? {repo, pull_request}
|
|
25
|
-
: null
|
|
24
|
+
? { repo, pull_request }
|
|
25
|
+
: null
|
|
26
26
|
);
|
|
27
27
|
})
|
|
28
28
|
.filter((v) => v !== null);
|