MCPcopy Create free account
hub / github.com/Effect-TS/effect / load

Function load

packages/tools/docgen/src/Configuration.ts:264–358  ·  view source on GitHub ↗
(args: {
  readonly projectHomepage: Option.Option<string>
  readonly srcLink: Option.Option<string>
  readonly srcDir: string
  readonly outDir: string
  readonly theme: string
  readonly enableSearch: boolean
  readonly enforceDescriptions: boolean
  readonly enforceExamples: boolean
  readonly enforceVersion: boolean
  readonly runExamples: boolean
  readonly exclude: ReadonlyArray<string>
  readonly parseCompilerOptions: Option.Option<string | Record<string, unknown>>
  readonly examplesCompilerOptions: Option.Option<string | Record<string, unknown>>
})

Source from the content-addressed store, hash-verified

262
263/** @internal */
264export const load = (args: {
265 readonly projectHomepage: Option.Option<string>
266 readonly srcLink: Option.Option<string>
267 readonly srcDir: string
268 readonly outDir: string
269 readonly theme: string
270 readonly enableSearch: boolean
271 readonly enforceDescriptions: boolean
272 readonly enforceExamples: boolean
273 readonly enforceVersion: boolean
274 readonly runExamples: boolean
275 readonly exclude: ReadonlyArray<string>
276 readonly parseCompilerOptions: Option.Option<string | Record<string, unknown>>
277 readonly examplesCompilerOptions: Option.Option<string | Record<string, unknown>>
278}) =>
279 Effect.gen(function*() {
280 // Extract the requisite services
281 const process = yield* Domain.Process
282 const cwd = yield* process.cwd
283 const path = yield* Path.Path
284
285 // Read and parse the required fields from the `package.json`
286 const packageJsonPath = path.join(cwd, PACKAGE_JSON_FILE_NAME)
287 const packageJson = yield* validateJsonFile(PackageJsonSchema, packageJsonPath)
288 const projectName = packageJson.name
289 const projectHomepage = Option.getOrElse(args.projectHomepage, () => packageJson.homepage)
290 const srcLink = Option.getOrElse(args.srcLink, () => `${projectHomepage}/blob/main/src/`)
291
292 // Read the `docgen.json` configuration file to gain access to the TypeScript
293 // configuration options
294 const configPath = path.join(cwd, CONFIG_FILE_NAME)
295 const config = yield* readDocgenConfig(configPath)
296
297 // Resolve the excluded files
298 const exclude = yield* Array.match(args.exclude, {
299 onEmpty: () =>
300 Effect.result(Config.schema(Config.Array(Schema.String), "exclude")).pipe(
301 Effect.map((configured) =>
302 Result.isSuccess(configured)
303 ? configured.success
304 : Option.match(config, {
305 onNone: () => Array.empty<string>(),
306 onSome: ({ exclude }) => exclude || Array.empty<string>()
307 })
308 )
309 ),
310 onNonEmpty: (exclude) => Effect.succeed(exclude)
311 })
312
313 // Resolve the TypeScript configuration options
314 const examplesCompilerOptions = yield* resolveCompilerOptions(
315 "examplesCompilerOptions",
316 args.examplesCompilerOptions,
317 Option.flatMap(config, (config) => Option.fromNullishOr(config.examplesCompilerOptions))
318 )
319 const parseCompilerOptions = yield* resolveCompilerOptions(
320 "parseCompilerOptions",
321 args.parseCompilerOptions,

Callers

nothing calls this directly

Calls 10

validateJsonFileFunction · 0.85
readDocgenConfigFunction · 0.85
resolveCompilerOptionsFunction · 0.85
joinMethod · 0.80
pipeMethod · 0.65
resultMethod · 0.65
ofMethod · 0.65
schemaMethod · 0.45
mapMethod · 0.45
succeedMethod · 0.45

Tested by

no test coverage detected