-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
import { installGlobals } from "../../core/src/globals" | ||
Check failure on line 1 in packages/cli/src/main.ts GitHub Actions / build
|
||
import { cli } from "./cli" | ||
|
||
installGlobals() | ||
cli() |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { glob } from "glob" | ||
import { YAMLParse, YAMLStringify } from "./yaml" | ||
import { CSVParse, CSVToMarkdown } from "./csv" | ||
import { INIParse, INIStringify } from "./ini" | ||
import { XMLParse } from "./xml" | ||
import { | ||
frontmatterTryParse, | ||
splitMarkdown, | ||
updateFrontmatter, | ||
} from "./frontmatter" | ||
import { JSONLStringify, JSONLTryParse } from "./jsonl" | ||
|
||
export function resolveGlobal(): any { | ||
if (typeof window !== "undefined") | ||
return window // Browser environment | ||
else if (typeof self !== "undefined") return self | ||
else if (typeof global !== "undefined") return global // Node.js environment | ||
throw new Error("Could not find global") | ||
} | ||
|
||
export function installGlobals() { | ||
const glb = resolveGlobal() | ||
|
||
glb.YAML = Object.freeze<YAML>({ | ||
stringify: YAMLStringify, | ||
parse: YAMLParse, | ||
}) | ||
glb.CSV = Object.freeze<CSV>({ | ||
parse: CSVParse, | ||
markdownify: CSVToMarkdown, | ||
}) | ||
glb.INI = Object.freeze<INI>({ | ||
parse: INIParse, | ||
stringify: INIStringify, | ||
}) | ||
glb.XML = Object.freeze<XML>({ | ||
parse: XMLParse, | ||
}) | ||
glb.MD = Object.freeze<MD>({ | ||
frontmatter: (text, format) => | ||
frontmatterTryParse(text, { format })?.value ?? {}, | ||
content: (text) => splitMarkdown(text)?.content, | ||
updateFrontmatter: (text, frontmatter, format): string => | ||
updateFrontmatter(text, frontmatter, { format }), | ||
}) | ||
glb.JSONL = Object.freeze<JSONL>({ | ||
parse: JSONLTryParse, | ||
stringify: JSONLStringify, | ||
}) | ||
glb.AICI = Object.freeze<AICI>({ | ||
gen: (options: AICIGenOptions) => { | ||
// validate options | ||
return { | ||
type: "aici", | ||
name: "gen", | ||
options, | ||
} | ||
}, | ||
}) | ||
} | ||
Check failure on line 60 in packages/core/src/globals.ts GitHub Actions / build
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.