-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added schema for
bunfig.toml
(#4024)
* Added schema for `bunfig.toml` * fix: add newline at end of `src/test/bunfig/bunfig.toml` file * fix: add newline at end of `src/schemas/json/bunfig.json` file * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
347d0a9
commit 67d0593
Showing
3 changed files
with
370 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,291 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"$id": "https://json.schemastore.org/bunfig.json", | ||
"title": "Bun configuration", | ||
"description": "Bun configuration schema for `bunfig.toml`. See https://bun.sh/docs/runtime/bunfig", | ||
"additionalProperties": false, | ||
"type": "object", | ||
"properties": { | ||
"preload": { | ||
"$comment": "https://bun.sh/docs/runtime/bunfig#preload", | ||
"type": "array", | ||
"description": "An array of scripts/plugins to execute before running a file or script\nhttps://bun.sh/docs/runtime/bunfig#preload", | ||
"examples": [["./preload.ts"]] | ||
}, | ||
"jsx": { | ||
"$comment": "https://bun.sh/docs/runtime/bunfig#jsx", | ||
"type": "string", | ||
"description": "Configure how Bun handles JSX. You can also set these fields in the `compilerOptions` of your `tsconfig.json`, but they are supported here as well for non-TypeScript projects\nhttps://bun.sh/docs/runtime/bunfig#jsx\nhttps://www.typescriptlang.org/tsconfig/#jsx", | ||
"examples": ["react"] | ||
}, | ||
"jsxFactory": { | ||
"$comment": "https://www.typescriptlang.org/tsconfig#jsxFactory", | ||
"type": "string", | ||
"description": "Specify the function that is used to create JSX elements\nhttps://www.typescriptlang.org/tsconfig#jsxFactory", | ||
"examples": ["h"] | ||
}, | ||
"jsxFragment": { | ||
"$comment": "https://www.typescriptlang.org/tsconfig#jsxFragment", | ||
"type": "string", | ||
"description": "Specify the function that is used for JSX fragments\nhttps://www.typescriptlang.org/tsconfig#jsxFragment", | ||
"examples": ["Fragment"] | ||
}, | ||
"jsxImportSource": { | ||
"$comment": "https://www.typescriptlang.org/tsconfig#jsxImportSource", | ||
"type": "string", | ||
"description": "Specify the module specifier to be used for importing the JSX factory functions\nhttps://www.typescriptlang.org/tsconfig#jsxImportSource", | ||
"examples": ["react"] | ||
}, | ||
"smol": { | ||
"$comment": "https://bun.sh/docs/runtime/bunfig#smol", | ||
"type": "boolean", | ||
"description": "Enable `smol` mode. This reduces memory usage at the cost of performance\nhttps://bun.sh/docs/runtime/bunfig#smol" | ||
}, | ||
"logLevel": { | ||
"$comment": "https://bun.sh/docs/runtime/bunfig#loglevel", | ||
"type": "string", | ||
"description": "Set the log level. This can be one of `\"debug\"`, `\"warn\"`, or `\"error\"`\nhttps://bun.sh/docs/runtime/bunfig#loglevel", | ||
"enum": ["debug", "warn", "error"], | ||
"examples": ["debug"] | ||
}, | ||
"define": { | ||
"$comment": "https://bun.sh/docs/runtime/bunfig#define", | ||
"type": "object", | ||
"description": "The `define` field allows you to replace certain global identifiers with constant expressions. Bun will replace any usage of the identifier with the expression. The expression should be a JSON string\nhttps://bun.sh/docs/runtime/bunfig#define", | ||
"additionalProperties": true | ||
}, | ||
"loader": { | ||
"$comment": "https://bun.sh/docs/runtime/bunfig#loader", | ||
"type": "object", | ||
"description": "Configure how Bun maps file extensions to loaders. This is useful for loading files that aren't natively supported by Bun\nhttps://bun.sh/docs/runtime/bunfig#loader", | ||
"additionalProperties": true | ||
}, | ||
"telemetry": { | ||
"$comment": "https://bun.sh/docs/runtime/bunfig#telemetry", | ||
"type": "boolean", | ||
"description": "The `telemetry` field permit to enable/disable the analytics records. Bun records bundle timings (so we can answer with data, \"is Bun getting faster?\") and feature usage (e.g., \"are people actually using macros?\"). The request body size is about 60 bytes, so it's not a lot of data. By default the telemetry is enabled. Equivalent of `DO_NOT_TRACK` env variable\nhttps://bun.sh/docs/runtime/bunfig#telemetry", | ||
"default": true, | ||
"examples": [false] | ||
}, | ||
"test": { | ||
"$comment": "https://bun.sh/docs/runtime/bunfig#test-runner", | ||
"description": "Test runner\nhttps://bun.sh/docs/runtime/bunfig#test-runner", | ||
"type": "object", | ||
"additionalProperties": false, | ||
"properties": { | ||
"root": { | ||
"$comment": "https://bun.sh/docs/runtime/bunfig#test-root", | ||
"type": "string", | ||
"description": "The root directory to run tests from. Default `.`\nhttps://bun.sh/docs/runtime/bunfig#test-root", | ||
"examples": ["./__tests__"] | ||
}, | ||
"preload": { | ||
"$comment": "https://bun.sh/docs/runtime/bunfig#test-preload", | ||
"type": "array", | ||
"description": "Same as the top-level `preload` field, but only applies to `bun test`\nhttps://bun.sh/docs/runtime/bunfig#test-preload", | ||
"examples": [["./setup.ts"]] | ||
}, | ||
"smol": { | ||
"$comment": "https://bun.sh/docs/runtime/bunfig#test-smol", | ||
"type": "boolean", | ||
"description": "Same as the top-level `smol` field, but only applies to `bun test`\nhttps://bun.sh/docs/runtime/bunfig#test-smol" | ||
}, | ||
"coverage": { | ||
"$comment": "https://bun.sh/docs/runtime/bunfig#test-coverage", | ||
"type": "boolean", | ||
"description": "Enables coverage reporting. Default `false`. Use `--coverage` to override\nhttps://bun.sh/docs/runtime/bunfig#test-coverage", | ||
"default": false | ||
}, | ||
"coverageThreshold": { | ||
"$comment": "https://bun.sh/docs/runtime/bunfig#test-coveragethreshold", | ||
"oneOf": [ | ||
{ "type": "integer" }, | ||
{ "type": "number" }, | ||
{ | ||
"type": "object", | ||
"additionalProperties": true | ||
} | ||
], | ||
"description": "To specify a coverage threshold. By default, no threshold is set. If your test suite does not meet or exceed this threshold, `bun test` will exit with a non-zero exit code to indicate the failure\nhttps://bun.sh/docs/runtime/bunfig#test-coveragethreshold", | ||
"examples": ["0.9", "{ line = 0.7, function = 0.8, statement = 0.9 }"] | ||
}, | ||
"coverageSkipTestFiles": { | ||
"$comment": "https://bun.sh/docs/runtime/bunfig#test-coverageskiptestfiles", | ||
"type": "boolean", | ||
"description": "Whether to skip test files when computing coverage statistics. Default false\nhttps://bun.sh/docs/runtime/bunfig#test-coverageskiptestfiles" | ||
} | ||
} | ||
}, | ||
"install": { | ||
"$comment": "https://bun.sh/docs/runtime/bunfig#package-manager", | ||
"type": "object", | ||
"description": "Package management is a complex issue; to support a range of use cases, the behavior of `bun install` can be configured under the `[install]` section\nhttps://bun.sh/docs/runtime/bunfig#package-manager", | ||
"additionalProperties": false, | ||
"properties": { | ||
"optional": { | ||
"$comment": "https://bun.sh/docs/runtime/bunfig#install-optional", | ||
"type": "boolean", | ||
"description": "Whether to install optional dependencies. Default `true`\nhttps://bun.sh/docs/runtime/bunfig#install-optional", | ||
"default": "true" | ||
}, | ||
"dev": { | ||
"$comment": "https://bun.sh/docs/runtime/bunfig#install-dev", | ||
"type": "boolean", | ||
"description": "Whether to install development dependencies. Default `true`\nhttps://bun.sh/docs/runtime/bunfig#install-dev", | ||
"default": "true" | ||
}, | ||
"peer": { | ||
"$comment": "https://bun.sh/docs/runtime/bunfig#install-peer", | ||
"type": "boolean", | ||
"description": "Whether to install peer dependencies. Default `true`\nhttps://bun.sh/docs/runtime/bunfig#install-peer", | ||
"default": "true" | ||
}, | ||
"production": { | ||
"$comment": "https://bun.sh/docs/runtime/bunfig#install-production", | ||
"type": "boolean", | ||
"description": "Whether bun install will run in \"production mode\". Default `false`\n\nIn production mode, `\"devDependencies\"` are not installed. You can use `--production` in the CLI to override this setting\nhttps://bun.sh/docs/runtime/bunfig#install-production", | ||
"default": "false" | ||
}, | ||
"exact": { | ||
"$comment": "https://bun.sh/docs/runtime/bunfig#install-exact", | ||
"type": "boolean", | ||
"description": "Whether to set an exact version in package.json. Default `false`\n\nBy default Bun uses caret ranges; if the `latest` version of a package is `2.4.1`, the version range in your `package.json` will be `^2.4.1`. This indicates that any version from `2.4.1` up to (but not including) `3.0.0` is acceptable\nhttps://bun.sh/docs/runtime/bunfig#install-exact", | ||
"default": "false" | ||
}, | ||
"auto": { | ||
"$comment": "https://bun.sh/docs/runtime/bunfig#install-auto", | ||
"type": "string", | ||
"description": "To configure Bun's package auto-install behavior. Default `\"auto\"` — when no `node_modules` folder is found, Bun will automatically install dependencies on the fly during execution\nhttps://bun.sh/docs/runtime/bunfig#install-auto", | ||
"enum": ["auto", "force", "disable", "fallback"], | ||
"default": "auto" | ||
}, | ||
"frozenLockfile": { | ||
"$comment": "https://bun.sh/docs/runtime/bunfig#install-frozenlockfile", | ||
"type": "boolean", | ||
"description": "When true, `bun install` will not update `bun.lockb`. Default `false`. If `package.json` and the existing `bun.lockb` are not in agreement, this will error\nhttps://bun.sh/docs/runtime/bunfig#install-frozenlockfile", | ||
"default": "false" | ||
}, | ||
"dryRun": { | ||
"$comment": "https://bun.sh/docs/runtime/bunfig#install-dryrun", | ||
"type": "boolean", | ||
"description": "Whether `bun install` will actually install dependencies. Default `false`. When true, it's equivalent to setting `--dry-run` on all `bun install` commands\nhttps://bun.sh/docs/runtime/bunfig#install-dryrun", | ||
"default": "false" | ||
}, | ||
"globalDir": { | ||
"$comment": "https://bun.sh/docs/runtime/bunfig#install-globaldir", | ||
"type": "string", | ||
"description": "To configure the directory where Bun puts globally installed packages\nhttps://bun.sh/docs/runtime/bunfig#install-globaldir", | ||
"default": "~/.bun/install/global", | ||
"examples": ["~/.bun/install/global"] | ||
}, | ||
"globalBinDir": { | ||
"$comment": "https://bun.sh/docs/runtime/bunfig#install-globalbindir", | ||
"type": "string", | ||
"description": "To configure the directory where Bun installs globally installed binaries and CLIs\nhttps://bun.sh/docs/runtime/bunfig#install-globalbindir", | ||
"default": "~/.bun/bin", | ||
"examples": ["~/.bun/bin"] | ||
}, | ||
"registry": { | ||
"$comment": "https://bun.sh/docs/runtime/bunfig#install-registry", | ||
"oneOf": [ | ||
{ "type": "string" }, | ||
{ | ||
"type": "object", | ||
"additionalProperties": false, | ||
"properties": { | ||
"url": { | ||
"type": "string", | ||
"description": "The URL of the registry\nhttps://bun.sh/docs/runtime/bunfig#install-registry", | ||
"examples": ["https://registry.npmjs.org"] | ||
}, | ||
"token": { | ||
"type": "string", | ||
"description": "The token to use for authentication\nhttps://bun.sh/docs/runtime/bunfig#install-registry", | ||
"examples": ["123456"] | ||
} | ||
} | ||
} | ||
], | ||
"description": "The default registry is `https://registry.npmjs.org/`. This can be globally configured in `bunfig.toml`\nhttps://bun.sh/docs/runtime/bunfig#install-registry", | ||
"default": "https://registry.npmjs.org/", | ||
"examples": [ | ||
"https://registry.npmjs.org", | ||
"{ url = \"https://registry.npmjs.org\", token = \"123456\" }", | ||
"https://username:[email protected]" | ||
] | ||
}, | ||
"scopes": { | ||
"$comment": "https://bun.sh/docs/runtime/bunfig#install-scopes", | ||
"type": "object", | ||
"description": "To configure a registry for a particular scope (e.g. `@myorg/<package>`) use `install.scopes`. You can reference environment variables with `$variable` notation\nhttps://bun.sh/docs/runtime/bunfig#install-scopes", | ||
"additionalProperties": true | ||
}, | ||
"cache": { | ||
"$comment": "https://bun.sh/docs/runtime/bunfig#install-cache", | ||
"type": "object", | ||
"description": "To configure the cache behavior\nhttps://bun.sh/docs/runtime/bunfig#install-cache", | ||
"additionalProperties": false, | ||
"properties": { | ||
"dir": { | ||
"type": "string", | ||
"description": "The directory to use for the cache\nhttps://bun.sh/docs/runtime/bunfig#install-cache", | ||
"default": "~/.bun/install/cache", | ||
"examples": ["~/.bun/install/cache"] | ||
}, | ||
"disable": { | ||
"type": "boolean", | ||
"description": "When true, don't load from the global cache.\n\nBun may still write to `node_modules/.cache`\nhttps://bun.sh/docs/runtime/bunfig#install-cache" | ||
}, | ||
"disableManifest": { | ||
"type": "boolean", | ||
"description": "When true, always resolve the latest versions from the registry\nhttps://bun.sh/docs/runtime/bunfig#install-cache" | ||
} | ||
} | ||
}, | ||
"lockfile": { | ||
"$comment": "https://bun.sh/docs/runtime/bunfig#install-lockfile", | ||
"type": "object", | ||
"description": "To configure lockfile behavior, use the `install.lockfile` section\nhttps://bun.sh/docs/runtime/bunfig#install-lockfile", | ||
"additionalProperties": false, | ||
"properties": { | ||
"save": { | ||
"type": "boolean", | ||
"description": "Whether to generate a lockfile on `bun install`. Default `true`\nhttps://bun.sh/docs/runtime/bunfig#install-lockfile", | ||
"default": "true" | ||
}, | ||
"print": { | ||
"type": "string", | ||
"description": "Whether to generate a non-Bun lockfile alongside `bun.lockb`. (A `bun.lockb` will always be created.) Currently `\"yarn\"` is the only supported value\nhttps://bun.sh/docs/runtime/bunfig#install-lockfile", | ||
"const": "yarn" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"run": { | ||
"$comment": "https://bun.sh/docs/runtime/bunfig#bun-run", | ||
"type": "object", | ||
"description": "The `bun run` command can be configured under the `[run]` section. These apply to the `bun run` command and the `bun` command when running a file or executable or script.\n\nCurrently, `bunfig.toml` isn't always automatically loaded for `bun run` in a local project (it does check for a global `bunfig.toml`), so you might still need to pass `-c` or `-c=bunfig.toml` to use these settings\nhttps://bun.sh/docs/runtime/bunfig#bun-run", | ||
"additionalProperties": false, | ||
"properties": { | ||
"shell": { | ||
"$comment": "https://bun.sh/docs/runtime/bunfig#run-shell-use-the-system-shell-or-bun-s-shell", | ||
"type": "string", | ||
"description": "The shell to use when running package.json scripts via `bun run` or `bun`. On Windows, this defaults to `\"bun\"` and on other platforms it defaults to `\"system\"`\nhttps://bun.sh/docs/runtime/bunfig#run-shell-use-the-system-shell-or-bun-s-shell", | ||
"enum": ["system", "bun"] | ||
}, | ||
"bun": { | ||
"$comment": "https://bun.sh/docs/runtime/bunfig#run-bun-auto-alias-node-to-bun", | ||
"type": "boolean", | ||
"description": "Auto alias `node` to `bun`\n\nWhen `true`, this prepends `$PATH` with a `node` symlink that points to the `bun` binary for all scripts or executables invoked by `bun run` or `bun`\n\nThis means that if you have a script that runs `node`, it will actually run `bun` instead, without needing to change your script. This works recursively, so if your script runs another script that runs `node`, it will also run `bun` instead. This applies to shebangs as well, so if you have a script with a shebang that points to `node`, it will actually run `bun` instead.\n\nBy default, this is enabled if `node` is not already in your `$PATH`\nhttps://bun.sh/docs/runtime/bunfig#run-bun-auto-alias-node-to-bun" | ||
}, | ||
"silent": { | ||
"$comment": "https://bun.sh/docs/runtime/bunfig#run-silent-suppress-reporting-the-command-being-run", | ||
"type": "boolean", | ||
"description": "When `true`, suppresses the output of the command being run by `bun run` or `bun`\nhttps://bun.sh/docs/runtime/bunfig#run-silent-suppress-reporting-the-command-being-run", | ||
"default": "false" | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# Reduce memory usage at the cost of performance | ||
smol = true | ||
|
||
# scripts to run before `bun run`-ing a file or script | ||
# register plugins by adding them to this list | ||
preload = ["./preload.ts"] | ||
|
||
jsx = "react" | ||
jsxFactory = "h" | ||
jsxFragment = "Fragment" | ||
jsxImportSource = "react" | ||
|
||
logLevel = "debug" # "debug" | "warn" | "error" | ||
|
||
telemetry = false | ||
|
||
[define] | ||
# Replace any usage of "process.env.bagel" with the string `lox`. | ||
# The values are parsed as JSON, except single-quoted strings are supported and `'undefined'` becomes `undefined` in JS. | ||
# This will probably change in a future release to be just regular TOML instead. It is a holdover from the CLI argument parsing. | ||
"process.env.bagel" = "'lox'" | ||
|
||
[install] | ||
auto = "auto" | ||
dev = true | ||
dryRun = false | ||
exact = false | ||
frozenLockfile = false | ||
globalBinDir = "~/.bun/bin" | ||
# where `bun install --global` installs packages | ||
globalDir = "~/.bun/install/global" | ||
optional = true | ||
peer = true | ||
production = false | ||
registry = "https://registry.npmjs.org" | ||
|
||
[install.cache] | ||
# the directory to use for the cache | ||
dir = "~/.bun/install/cache" | ||
|
||
# when true, don't load from the global cache. | ||
# Bun may still write to node_modules/.cache | ||
disable = false | ||
|
||
# when true, always resolve the latest versions from the registry | ||
disableManifest = false | ||
|
||
[install.lockfile] | ||
print = "yarn" | ||
save = true | ||
|
||
[install.scopes] | ||
myorg = "https://username:[email protected]/" | ||
|
||
[loader] | ||
# when a .bagel file is imported, treat it like a tsx file | ||
".bagel" = "tsx" | ||
|
||
[run] | ||
# equivalent to `bun --bun` for all `bun run` commands | ||
bun = true | ||
# default on Windows | ||
shell = "bun" | ||
silent = true | ||
|
||
[test] | ||
coverage = false | ||
coverageSkipTestFiles = false | ||
# to require 90% line-level and function-level coverage | ||
coverageThreshold = 0.9 | ||
preload = ["./setup.ts"] | ||
root = "./__tests__" | ||
smol = true |