Skip to content

Commit f18720d

Browse files
committed
improve gro gitops path handling and add a banner to the generated repos.ts
1 parent 962f8b5 commit f18720d

3 files changed

Lines changed: 16 additions & 3 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@ryanatkn/fuz_gitops': patch
3+
---
4+
5+
improve `gro gitops` path handling and add a banner to the generated `repos.ts`

src/lib/gitops.task.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type {Task} from '@ryanatkn/gro';
22
import {z} from 'zod';
33
import {readFile, writeFile} from 'node:fs/promises';
44
import {format_file} from '@ryanatkn/gro/format_file.js';
5-
import {join} from 'node:path';
5+
import {basename, resolve} from 'node:path';
66
import {paths, print_path} from '@ryanatkn/gro/paths.js';
77
import {load_from_env} from '@ryanatkn/gro/env.js';
88
import {load_fuz_config} from '@ryanatkn/fuz/config.js';
@@ -46,7 +46,7 @@ export const task: Task<Args> = {
4646
run: async ({args, log, sveltekit_config}) => {
4747
const {path, dir, outdir = sveltekit_config.routes_path} = args;
4848

49-
const outfile = join(outdir, 'repos.ts');
49+
const outfile = resolve(outdir, 'repos.ts');
5050

5151
const fuz_config = await load_fuz_config(path, dir, log);
5252

@@ -73,8 +73,14 @@ export const task: Task<Args> = {
7373
: '@ryanatkn/fuz_gitops/fetch_deployments.js';
7474

7575
// JSON is faster to parse than JS so we optimize it by embedding the data as a string.
76+
// TODO the `basename` is used here because we don't have an `origin_id` like with gen,
77+
// and this file gets re-exported,
78+
// and we don't want the file to change based on where it's being generated,
79+
// because for example linking to a local package would change the contents
7680
const contents = `
81+
// generated by ${basename(import.meta.filename)}
7782
import type {Deployment} from '${specifier}';
83+
7884
export const deployments: Deployment[] = ${embed_json(fetched_deployments)}
7985
`;
8086
// TODO think about possibly using the `gen` functionality in this task, not sure what the API design could look like

src/routes/repos.ts

Lines changed: 3 additions & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)