Project settings: kscript.json
kscript serve, kscript check, kscript fmt, kscript make and the editor read the nearest kscript.json in the folder they work on or a parent folder, so they behave the same from anywhere in the project. Every setting is optional:
{
"name": "my-site",
"kscript": "0.51.0", // the KScript release the project is written for (see below)
"timezone": "Europe/London", // the zone stored dates are in (see docs/data.md); this is the default
"standard": "kscript:recommended", // lint rules and format settings to start from (see Standards)
"packages": ["KScript.Terminal", "KScript.IO"], // imported by every script in the project
"extensions": ["extensions", "shared/**/*.kscript"], // where the project's extend files are (default: extensions/)
"natives": ["natives"], // where the project's native types are, used without an import (default: natives/)
"serve": {
"root": ".", // the site folder, relative to kscript.json
"port": 8080, // --port and --host on the command line still win
"host": "localhost",
"docs": true // also serve the docs, with a page about this project (see docs/web.md)
},
"http": {
"middleware": ["log"], // routes, middleware and their settings (see docs/http.md)
"groups": { "api": ["cors", "throttle"] }
},
"lint": {
"include": ["**/*.html", "**/*.md", "**/*.kscript"], // what `kscript check` looks at
"exclude": ["_templates", "node_modules", "drafts/**"], // never checked, on the command line or in the editor
"rules": { "KS3003": "off", "KS4*": "error" }, // off, hint, info, warning or error, by code or prefix
"warnings_as_errors": false // same as kscript check --warnings-as-errors
},
"test": {
"include": ["tests/**/*.test.kscript"], // what `kscript test` runs (default: **/*.test.kscript and **/*.test.ks.xml)
"exclude": ["tests/slow"],
"timeout": 10, // seconds per test, 0 for no limit
"packages": ["KScript.Terminal"], // imported by test files only
"env": "test" // the environment tests run in, so kscript.test.json applies
},
"format": {
"indent": 2, // spaces per level, or "tab"; used by kscript fmt and Format Document
"print_width": 80, // the longest a line should be; longer lines are wrapped
"rules": { "statement_per_line": false }, // any rule can be turned off
"exclude": ["vendor"] // see docs/formatting.md for every format setting
},
"app": {
"main": "app.kscript", // what `kscript run` and `kscript compile` start from (default: main.kscript, then index.kscript)
"main_function": "start", // the function a script runs by itself after its top-level code (default: main)
"name": "My App", // shown in the Dock, Start menu or launcher (default: the project's name)
"id": "com.example.myapp", // the macOS bundle id
"version": "1.0.0",
"icon": "icon.png", // a .png, .ico or .icns, used for every platform
"user_config": true // lay the person's own config.json (KScript.Storage) over $config
},
"types": {
"uuid": { "v": 4 }, // arguments for every use of a built-in type (see Types and validation)
"password": { "min": 12 }
},
"config": {
"app": { "name": "Shop" }, // the app's own settings: $config.app.name
"database": { "connections": { "main": { "url": "sqlite:data/shop.sqlite" } } }
}
}- A pattern without a
/(such as_templatesor*.draft.html) matches a file or folder of that name anywhere. Otherwise it is matched against the path fromkscript.json:*stays within a folder,**spans folders, and a folder matches everything in it. kscriptnames the KScript release the project is written for: an exact release such as"0.51.0", or"0.51"for the newest 0.51.x. Everykscriptcommand in the project runs that release, downloading it the first time, and so do editors that fetch KScript for you, such as FlowIDE.kscript version pin 0.51writes it, andkscript version unpintakes it out (see Switching versions). Without it, the project runs the computer's version.standardpicks the standard the project'slintandformatsettings start from:kscript:recommended(the default),kscript:strict, or a standard file of your own that you can share between projects. Anything set inkscript.jsonitself wins over the standard.kscript check --print-configshows the result and where each setting came from.ruleschanges how serious a diagnostic is (see the codes). The longest match wins, so"KS3*": "warning"with"KS3001": "error"keeps unknown elements as errors.- Comments and trailing commas are allowed. Unknown settings are reported as warnings rather than ignored silently, and the VS Code extension validates the file and completes its settings as you type.
formatsets the style forkscript fmtand the editor's Format Document, andformat.rulesturns individual rules off. See Formatting for every setting and the ignore comments.- Inside a project,
kscript make page aboutcreates the page in the site root even when run from a subfolder. configholds the app's own settings, read as$config;kscript.<env>.jsonandconfig.kscriptbesidekscript.jsonare laid over it (see Settings).kscript servenever serveskscript.json,kscript.<env>.json,.envfiles, orconfig.*JSON files.httpconfigures route files, middleware, CORS, auth and rate limits for KScript.Http (see Routes, controllers and middleware).typesgives built-in types such asuuid,emailandpasswordthe same arguments everywhere in the project. Arguments written where a type is used, such asuuid(v: 8), win (see Types and validation).app.name(orname) also names the app's own folders for settings, data and caches (see App folders).queuenames the connections jobs wait on, the queues a worker checks and how long failed jobs are kept (see Queues and jobs).appis read bykscript compile, which builds the script (often a desktop app) into a program for macOS, Windows and Linux (see Programs).