@t8/docsgen 0.1.6 → 0.1.7

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/dist/bin.js CHANGED
@@ -130,6 +130,18 @@ function toConfig(metadata) {
130
130
  }
131
131
 
132
132
  // src/bin/getConfig.ts
133
+ async function addMetadata(config2) {
134
+ try {
135
+ let rawContent = await fetchText(getLocation(config2, "package.json"));
136
+ let metadata = JSON.parse(rawContent);
137
+ return {
138
+ ...toConfig(metadata),
139
+ ...config2
140
+ };
141
+ } catch {
142
+ return config2;
143
+ }
144
+ }
133
145
  var config = null;
134
146
  async function getConfig() {
135
147
  if (config) return config;
@@ -151,15 +163,9 @@ async function getConfig() {
151
163
  ...localConfig,
152
164
  ...A(args)
153
165
  };
154
- try {
155
- let rawContent = await fetchText(getLocation(config, "package.json"));
156
- let metadata = JSON.parse(rawContent);
157
- config = {
158
- ...toConfig(metadata),
159
- ...config
160
- };
161
- } catch {
162
- }
166
+ if (config.entries)
167
+ config.entries = await Promise.all(config.entries.map(addMetadata));
168
+ else await addMetadata(config);
163
169
  if (!config.root?.endsWith("/")) config.root = `${config.root ?? ""}/`;
164
170
  return config;
165
171
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@t8/docsgen",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "",
5
5
  "main": "dist/bin.js",
6
6
  "bin": {
@@ -1,10 +1,25 @@
1
1
  import { parseArgs } from "args-json";
2
2
  import type { BinConfig } from "../types/BinConfig";
3
+ import type { EntryConfig } from "../types/EntryConfig";
3
4
  import type { PackageMetadata } from "../types/PackageMetadata";
4
5
  import { fetchText } from "./fetchText";
5
6
  import { getLocation } from "./getLocation";
6
7
  import { toConfig } from "./toConfig";
7
8
 
9
+ async function addMetadata(config: EntryConfig) {
10
+ try {
11
+ let rawContent = await fetchText(getLocation(config, "package.json"));
12
+ let metadata = JSON.parse(rawContent) as PackageMetadata;
13
+
14
+ return {
15
+ ...toConfig(metadata),
16
+ ...config,
17
+ };
18
+ } catch {
19
+ return config;
20
+ }
21
+ }
22
+
8
23
  let config: BinConfig | null = null;
9
24
 
10
25
  export async function getConfig(): Promise<BinConfig> {
@@ -32,15 +47,9 @@ export async function getConfig(): Promise<BinConfig> {
32
47
  ...parseArgs<BinConfig>(args),
33
48
  };
34
49
 
35
- try {
36
- let rawContent = await fetchText(getLocation(config, "package.json"));
37
- let metadata = JSON.parse(rawContent) as PackageMetadata;
38
-
39
- config = {
40
- ...toConfig(metadata),
41
- ...config,
42
- };
43
- } catch {}
50
+ if (config.entries)
51
+ config.entries = await Promise.all(config.entries.map(addMetadata));
52
+ else await addMetadata(config);
44
53
 
45
54
  if (!config.root?.endsWith("/")) config.root = `${config.root ?? ""}/`;
46
55