main
1// Copyright 2024 Google LLC
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15import { URL } from 'node:url'
16import {
17 convertPathToPattern,
18 globby,
19 globbySync,
20 globbyStream,
21 generateGlobTasksSync,
22 generateGlobTasks,
23 isGitIgnoredSync,
24 isGitIgnored,
25 isDynamicPattern,
26 type Options as GlobbyOptions,
27} from 'globby'
28import * as _yaml from 'yaml'
29import * as _maml from 'maml.js'
30import * as _fs from 'fs-extra'
31import _createRequire from 'create-require'
32import { fetch as _nodeFetch, AbortController } from 'node-fetch-native'
33import { depseekSync as _depseek } from 'depseek'
34import { default as _minimist } from 'minimist'
35import { default as _dotenv } from 'envapi'
36
37import { bus } from './internals.ts'
38
39const { wrap } = bus
40
41// Calculate a global variable for use (Deno/NodeJS) runtime.
42// deno-lint-ignore no-node-globals
43const globalVar = 'Deno' in globalThis ? globalThis : global
44
45globalVar.AbortController = globalVar.AbortController || AbortController
46
47export const createRequire = _createRequire as unknown as (
48 filename: string | URL
49) => NodeJS.Require
50
51const globbyModule = {
52 convertPathToPattern,
53 globby,
54 sync: globbySync,
55 globbySync,
56 globbyStream,
57 generateGlobTasksSync,
58 generateGlobTasks,
59 isGitIgnoredSync,
60 isGitIgnored,
61 isDynamicPattern,
62}
63
64const _glob = Object.assign(function globby(
65 patterns: string | readonly string[],
66 options?: GlobbyOptions
67) {
68 return globbyModule.globby(patterns, options)
69}, globbyModule) as (typeof globbyModule)['globby'] & typeof globbyModule
70
71const _YAML: YAML = _yaml
72
73export interface YAML {
74 parse(text: string): any
75 stringify(object: any): string
76 /** @deprecated */
77 parseAllDocuments(s: string, opts?: any): any[]
78 /** @deprecated */
79 parseDocument(s: string, opts?: any): any
80 /** @deprecated */
81 isAlias(v: any): boolean
82 /** @deprecated */
83 isCollection(v: any): boolean
84 /** @deprecated */
85 isDocument(v: any): boolean
86 /** @deprecated */
87 isMap(v: any): boolean
88 /** @deprecated */
89 isNode(v: any): boolean
90 /** @deprecated */
91 isPair(v: any): boolean
92 /** @deprecated */
93 isScalar(v: any): boolean
94 /** @deprecated */
95 isSeq(v: any): boolean
96 /** @deprecated */
97 Alias: any
98 /** @deprecated */
99 Composer: any
100 /** @deprecated */
101 Document: any
102 /** @deprecated */
103 Schema: any
104 /** @deprecated */
105 YAMLSeq: any
106 /** @deprecated */
107 YAMLMap: any
108 /** @deprecated */
109 YAMLError: any
110 /** @deprecated */
111 YAMLParseError: any
112 /** @deprecated */
113 YAMLWarning: any
114 /** @deprecated */
115 Pair: any
116 /** @deprecated */
117 Scalar: any
118 /** @deprecated */
119 Lexer: any
120 /** @deprecated */
121 LineCounter: any
122 /** @deprecated */
123 Parser: any
124}
125
126export const depseek: typeof _depseek = wrap('depseek', _depseek)
127export const dotenv: typeof _dotenv = wrap('dotenv', _dotenv)
128export const fs: typeof import('fs-extra') = wrap('fs', _fs)
129export const YAML: typeof _YAML = wrap('YAML', _YAML)
130export const MAML: typeof _maml = wrap('MAML', _maml)
131export const glob: typeof _glob = wrap('glob', _glob)
132export const nodeFetch: typeof _nodeFetch = wrap('nodeFetch', _nodeFetch)
133
134export const minimist: typeof _minimist = wrap('minimist', _minimist)
135export namespace minimist {
136 export interface Opts extends _minimist.Opts {}
137 export interface ParsedArgs extends _minimist.ParsedArgs {}
138}