Skip to content

Commit fb9de5d

Browse files
committed
update exports
1 parent e1a1e0a commit fb9de5d

8 files changed

Lines changed: 39 additions & 25 deletions

File tree

.changeset/selfish-seals-peel.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@ryanatkn/orc': minor
3+
---
4+
5+
update exports

gro.config.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,21 @@ const config: CreateGroConfig = async (cfg) => {
1818
}),
1919
);
2020

21+
// TODO this shouldn't be necessary
22+
cfg.map_package_json = (pkg) => {
23+
pkg.exports = Object.fromEntries(
24+
Object.entries(pkg.exports!)
25+
.map(([key, value]) => {
26+
if (key === './packages.json' || key === './packages.json.d.ts') {
27+
return null!;
28+
}
29+
return [key, value];
30+
})
31+
.filter(Boolean),
32+
);
33+
return pkg;
34+
};
35+
2136
return cfg;
2237
};
2338

File renamed without changes.

package.json

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,6 @@
7878
"default": "./dist/fetch_packages.js",
7979
"types": "./dist/fetch_packages.d.ts"
8080
},
81-
"./orc.config.js": {
82-
"default": "./dist/orc.config.js",
83-
"types": "./dist/orc.config.d.ts"
84-
},
85-
"./packages.json": {
86-
"default": "./dist/packages.json",
87-
"types": "./dist/packages.json.d.ts"
88-
},
8981
"./packages.task.js": {
9082
"default": "./dist/packages.task.js",
9183
"types": "./dist/packages.task.d.ts"

src/lib/config.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import type {Url} from '@grogarden/gro/paths.js';
1+
import {paths, type Url} from '@grogarden/gro/paths.js';
2+
import {join} from 'node:path';
23

34
export interface OrcConfig {
45
// TODO name? `packages`? `package_urls`?
56
repos: Url[];
67
}
78

89
// TODO refactor for reusability
9-
export const load_orc_config = async (): Promise<OrcConfig> =>
10-
(await import('./orc.config.js')).default;
10+
export const load_orc_config = async (dir = paths.root): Promise<OrcConfig> =>
11+
(await import(join(dir, 'orc.config.ts'))).default;

src/lib/packages.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"package_json": {
55
"name": "@ryanatkn/orc",
66
"description": "a tool for orchestrating many repos",
7-
"version": "0.1.0",
7+
"version": "0.1.1",
88
"license": "MIT",
99
"homepage": "https://orc.ryanatkn.com/",
1010
"repository": "https://github.com/ryanatkn/orc",
@@ -59,11 +59,6 @@
5959
"default": "./dist/fetch_packages.js",
6060
"types": "./dist/fetch_packages.d.ts"
6161
},
62-
"./orc.config.js": {"default": "./dist/orc.config.js", "types": "./dist/orc.config.d.ts"},
63-
"./packages.json": {
64-
"default": "./dist/packages.json",
65-
"types": "./dist/packages.json.d.ts"
66-
},
6762
"./packages.task.js": {
6863
"default": "./dist/packages.task.js",
6964
"types": "./dist/packages.task.d.ts"

src/lib/packages.task.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,29 @@
11
import type {Task} from '@grogarden/gro';
2-
import {load_package_json, type PackageJson} from '@grogarden/gro/package_json.js';
2+
import {load_package_json} from '@grogarden/gro/package_json.js';
33
import {z} from 'zod';
44
import {writeFile} from 'node:fs/promises';
55
import {format_file} from '@grogarden/gro/format_file.js';
66
import {exists} from '@grogarden/gro/exists.js';
7+
import {join} from 'node:path';
8+
import {paths} from '@grogarden/gro/paths.js';
79

810
import {fetch_packages, type FetchedPackage} from '$lib/fetch_packages.js';
911
import {load_orc_config} from '$lib/config.js';
1012

13+
// TODO etags - cache?
1114
// TODO refactor for reusability
1215

1316
// TODO maybe support `--check` for CI
1417
export const Args = z
1518
.object({
19+
dir: z
20+
.string({
21+
description: 'path to the directory containing the source package.json and orc.config.ts',
22+
})
23+
.optional(),
1624
outfile: z
1725
.string({description: 'path to the generated packages.json file'})
18-
.default('./src/lib/packages.json'),
26+
.default(join(paths.lib, 'packages.json')),
1927
})
2028
.strict();
2129
export type Args = z.infer<typeof Args>;
@@ -27,17 +35,14 @@ export const task: Task<Args> = {
2735
Args,
2836
summary: 'download metadata for the given packages',
2937
run: async ({args, log}) => {
30-
const {outfile} = args;
38+
const {dir, outfile} = args;
3139

32-
const orc_config = await load_orc_config();
40+
const orc_config = await load_orc_config(dir);
3341
const package_urls = orc_config.repos;
3442

3543
const fetched_packages = await fetch_packages(package_urls, log);
3644

37-
let local_package_json: PackageJson | undefined;
38-
try {
39-
local_package_json = await load_package_json();
40-
} catch (err) {}
45+
const local_package_json = await load_package_json(dir);
4146

4247
const packages: FetchedPackage[] = local_package_json?.homepage
4348
? [

tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
},
2323
"include": [
2424
"./gro.config.ts",
25+
"./orc.config.ts",
2526
"./svelte.config.js",
2627
"./.svelte-kit/ambient.d.ts",
2728
"./.svelte-kit/types/**/$types.d.ts",

0 commit comments

Comments
 (0)