KScript 문서
KO

언어

영어에서 자동 번역되었습니다. 원문은 영어입니다.

프로젝트와 kscript.json

프로젝트 설정: kscript.json

kscript serve, kscript check, kscript fmt, kscript make 및 편집기는 작업하는 폴더 또는 상위 폴더에서 가장 가까운 kscript.json를 읽으므로, 프로젝트의 어느 위치에서 실행하든 동일하게 동작합니다. 모든 설정은 선택 사항입니다.

JSON
{
  "name": "my-site",
  "kscript": "0.51.0",                             // the KScript release the project is written for (see below)
  "jit": true,                                     // run scripts on the JIT runtime too; false keeps kscript serve off it
  "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)
  "strict": false,                                 // true: every script is strict (see Strict types)
  "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" } } }
  }
}
  • /가 없는 패턴(예: _templates 또는 *.draft.html)은 그 이름의 파일이나 폴더를 어디에서든 찾습니다. 그 외에는 kscript.json부터의 경로와 비교합니다. *는 한 폴더 안에만 해당하고, **는 여러 폴더에 걸쳐 일치하며, 폴더 이름은 그 안의 모든 항목과 일치합니다.
  • kscript는 프로젝트가 대상으로 하는 KScript 릴리스를 지정합니다. "0.51.0"처럼 정확한 릴리스를 적거나, 최신 0.51.x를 뜻하는 "0.51"를 적을 수 있습니다. 프로젝트의 모든 kscript 명령은 그 릴리스로 실행되며, 처음에는 자동으로 내려받습니다. FlowIDE처럼 KScript를 대신 가져오는 편집기도 같은 방식으로 동작합니다. kscript version pin 0.51는 이 값을 기록하고, kscript version unpin는 이 값을 제거합니다(버전 전환 참고). 이 설정이 없으면 프로젝트는 컴퓨터에 설치된 버전으로 실행됩니다.
  • 설치된 kscript가 릴리스 빌드일 때 프로젝트가 어디에서 실행될지는 jit 설정이 정합니다. true로 설정하면 반복문에서 몇 초가 걸리는 스크립트를 위해 스크립트도 JIT 런타임에서 실행되고, false로 설정하면 kscript serve는 설치된 kscript에 남습니다. 이 설정이 없으면 kscript serve는 JIT 런타임에서 실행되고 스크립트는 그렇지 않습니다. --jit, --no-jit, KSCRIPT_JIT이 이 설정보다 우선합니다.
  • standard는 프로젝트의 lint와 format 설정이 시작점으로 삼는 표준을 고릅니다. 값은 kscript:recommended(기본값), kscript:strict, 또는 여러 프로젝트에서 공유할 수 있는 나만의 표준 파일 중에서 고를 수 있습니다. kscript.json에 직접 설정한 값은 표준보다 우선합니다. kscript check --print-config는 최종 결과와 각 설정이 어디에서 왔는지 보여 줍니다.
  • strict: true는 프로젝트의 모든 스크립트를 각각 strict로 시작하는 것처럼 strict로 만듭니다. 모든 값에는 검사기가 증명할 수 있는 타입이 필요하고, 타입 오류는 실행 전에 스크립트를 멈춥니다. lint 심각도만 바꾸는 kscript:strict 표준과는 다릅니다.
  • rules는 진단 메시지의 심각도를 바꿉니다(코드 목록 참고). 가장 긴 일치 규칙이 우선하므로, "KS3*": "warning"와 "KS3001": "error"를 함께 쓰면 알 수 없는 요소는 계속 오류로 표시됩니다.
  • 주석과 끝에 오는 쉼표는 허용됩니다. 알 수 없는 설정은 조용히 무시하지 않고 경고로 표시됩니다. VS Code 확장 프로그램은 파일을 검증하고, 입력하는 동안 설정을 자동으로 완성해 줍니다.
  • format는 kscript fmt와 편집기의 문서 서식 지정(Format Document)에 쓰이는 스타일을 설정하고, format.rules는 개별 규칙을 끌 때 사용해요. 모든 설정과 무시 주석은 서식 지정에서 확인해 보세요.
  • 프로젝트 안에서 하위 폴더에서 실행하더라도 kscript make page about은 사이트 루트에 페이지를 만듭니다.
  • config는 앱 자체 설정을 담고 있으며, $config로 읽힙니다. kscript.json 옆의 kscript.<env>.json와 config.kscript는 그 위에 덮어씌워집니다 (설정 참조).
  • kscript serve은 kscript.json, kscript.<env>.json, .env 파일이나 config.* JSON 파일을 절대 제공하지 않아요.
  • http는 KScript.Http의 라우트 파일, 미들웨어, CORS, 인증, 요청 제한을 설정해요 (라우트, 컨트롤러, 미들웨어 참고).
  • types는 프로젝트 전체에서 uuid, email, password 같은 기본 제공 타입에 동일한 인수를 적용해요. 타입을 사용하는 곳에 직접 쓴 인수(예: uuid(v: 8))가 우선 적용돼요(타입과 유효성 검사 참조).
  • app.name (또는 name)은 앱 자체의 설정, 데이터, 캐시 폴더 이름이기도 해요 (앱 폴더 참고).
  • queue은 작업이 기다리는 연결, 워커가 확인하는 큐, 그리고 실패한 작업을 보관하는 기간을 지정합니다 (큐와 작업 참조).
  • app는 kscript compile가 읽고, 스크립트(주로 데스크톱 앱)를 macOS, Windows, Linux용 프로그램으로 빌드합니다(프로그램 참조).