From 791aacc27703c2fbe4279f716ec10b0b9e22300d Mon Sep 17 00:00:00 2001 From: Stefan Verhoeven Date: Mon, 21 Oct 2024 12:18:36 +0200 Subject: [PATCH 1/5] Add publish instructions --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index 64aafc3..f2880de 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,19 @@ cd packages/class pnpm json2ts ``` +### Publish package + +To publish a new version of the class package: + +1. Bump version in `**/package.json` files. They should all have same version. +2. Commit & push changes to main branch. +3. Create a new [GitHub release](https://github.com/classmodel/class-web/releases) + - Tag version and title should be the same as the version in the package.json file with `v` prefix. + - Use `Implementation of the Chemistry Land-surface Atmosphere Soil Slab (CLASS) model that runs entirely in the browser.` as the description with generated release notes. +4. A GitHub CI workflow will publish the package to [jsr](https://jsr.io/@classmodel/class) + +After the workflow has completed the new version will be available on [jsr](https://jsr.io/@classmodel/class). + ## Local build To run a local development version: From ceb7abffef5ca77186afc49b58cb1537ec9f9a7a Mon Sep 17 00:00:00 2001 From: Stefan Verhoeven Date: Mon, 21 Oct 2024 12:18:55 +0200 Subject: [PATCH 2/5] Bump version --- apps/class-solid/package.json | 2 +- package.json | 2 +- packages/class/package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/class-solid/package.json b/apps/class-solid/package.json index b29ac7d..272834a 100644 --- a/apps/class-solid/package.json +++ b/apps/class-solid/package.json @@ -1,7 +1,7 @@ { "name": "class-solid", "private": true, - "version": "0.0.3", + "version": "0.0.4", "type": "module", "scripts": { "dev": "vinxi dev", diff --git a/package.json b/package.json index 357276a..54790a3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "private": true, - "version": "0.0.3", + "version": "0.0.4", "scripts": { "build": "turbo build", "dev": "turbo dev", diff --git a/packages/class/package.json b/packages/class/package.json index 3825798..a5cdc25 100644 --- a/packages/class/package.json +++ b/packages/class/package.json @@ -1,6 +1,6 @@ { "name": "@classmodel/class", - "version": "0.0.3", + "version": "0.0.4", "exports": { "./class": "./src/class.ts", "./config": "./src/config.ts", From 937a7c34d4fe83bb4fa9e8c1592904c8fcc0e5c2 Mon Sep 17 00:00:00 2001 From: Stefan Verhoeven Date: Mon, 21 Oct 2024 12:19:08 +0200 Subject: [PATCH 3/5] More docs To better score at https://jsr.io/@classmodel/class/score --- packages/class/src/bmi.ts | 12 +++++++++++- packages/class/src/class.ts | 5 ++++- packages/class/src/runclass.ts | 5 +++++ packages/class/src/runner.ts | 5 +++++ packages/class/src/validate.ts | 16 +++++++++++++++- 5 files changed, 40 insertions(+), 3 deletions(-) diff --git a/packages/class/src/bmi.ts b/packages/class/src/bmi.ts index 4e83533..673c92a 100644 --- a/packages/class/src/bmi.ts +++ b/packages/class/src/bmi.ts @@ -1,9 +1,14 @@ +/** + * This module contains the Basic Modelling Interface class. + * @module + */ + import { CLASS } from "./class"; import type { Config } from "./config"; import { parse } from "./validate"; /** - * A lightweight [BMI](https://bmi.readthedocs.io) like interface for the CLASS model. + * A lightweight [Basic Modelling Interface (BMI)](https://bmi.readthedocs.io) like interface for the CLASS model. * * Inspiration https://github.com/uihilab/BMI-JS/blob/main/bmijs/bmi.js * @@ -11,6 +16,7 @@ import { parse } from "./validate"; * - accessors do not use dest argument * - initialize() accepts object instead of string * - parameters() returns default config + * - run() as extra method */ interface BmiLight { initialize(config: Config): void; @@ -31,6 +37,10 @@ interface BmiLight { const ouput_var_names: string[] = ["h", "theta", "dtheta", "q", "dq"] as const; +/** + * Class representing a BMI (Basic Model Interface) implementation for the CLASS model. + * This class provides methods to initialize, update, and retrieve information from the model. + */ export class BmiClass implements BmiLight { config: Config = parse({}); model: CLASS = new CLASS(this.config); diff --git a/packages/class/src/class.ts b/packages/class/src/class.ts index 758296c..a8d698c 100644 --- a/packages/class/src/class.ts +++ b/packages/class/src/class.ts @@ -1,3 +1,7 @@ +/** + * This module contains the CLASS model implementation. + * @module + */ import type { Config } from "./config"; // Constants @@ -14,7 +18,6 @@ const cp = 1005.0; /** Specific heat of dry air [J kg-1 K-1] */ * @property dq: Specific humidity jump at h [kg kg-1] * @property t: Model time [s] */ - export class CLASS { _cfg: Config; h: number; diff --git a/packages/class/src/runclass.ts b/packages/class/src/runclass.ts index 73bf993..09b80b6 100644 --- a/packages/class/src/runclass.ts +++ b/packages/class/src/runclass.ts @@ -1,3 +1,8 @@ +/** + * Script to run Class model with default configuration. + * + * @module + */ import { CLASS } from "./class"; import type { ClassOutput } from "./runner"; import { parse } from "./validate"; diff --git a/packages/class/src/runner.ts b/packages/class/src/runner.ts index 75bead1..7c61f31 100644 --- a/packages/class/src/runner.ts +++ b/packages/class/src/runner.ts @@ -1,3 +1,8 @@ +/** + * This module contains the `runClass` function + * + * @module + */ import { CLASS } from "./class"; import type { Config } from "./config"; import { parse } from "./validate"; diff --git a/packages/class/src/validate.ts b/packages/class/src/validate.ts index 2abeff6..3962903 100644 --- a/packages/class/src/validate.ts +++ b/packages/class/src/validate.ts @@ -1,3 +1,8 @@ +/** + * This module contains functions to validate and parse configuration objects. + * + * @module + */ import Ajv from "ajv/dist/2019"; import type { DefinedError, JSONSchemaType } from "ajv/dist/2019"; @@ -11,7 +16,7 @@ export type JsonSchemaOfConfig = JSONSchemaType; export const jsonSchemaOfConfig = rawConfigJson as unknown as JsonSchemaOfConfig; -export const ajv = new Ajv({ +const ajv = new Ajv({ coerceTypes: true, allErrors: true, useDefaults: "empty", @@ -149,6 +154,9 @@ export function overwriteDefaultsInJsonSchema( return newSchema; } +/** + * An experiment configuration is a combination of a reference configuration and a set of permutation configurations. + */ export interface ExperimentConfigSchema { name: string; description?: string; @@ -183,6 +191,12 @@ const jsonSchemaOfExperimentConfig = { const validateExperimentConfig = ajv.compile(jsonSchemaOfExperimentConfig); +/** Parse unknown input into a Experiment configuration + * + * @param input - The input to be parsed. + * @returns The validated input as a Experiment configuration object. + * @throws {ValidationError} If the input is not valid according to the validation rules. + */ export function parseExperimentConfig(input: unknown): ExperimentConfigSchema { if (!validateExperimentConfig(input)) { throw new ValidationError( From 6185732440ffcf436f4c2596479dca92b1d45fcb Mon Sep 17 00:00:00 2001 From: Stefan Verhoeven Date: Mon, 21 Oct 2024 12:22:17 +0200 Subject: [PATCH 4/5] Bump version for jsr --- README.md | 2 +- packages/class/jsr.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f2880de..30baf8b 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ pnpm json2ts To publish a new version of the class package: -1. Bump version in `**/package.json` files. They should all have same version. +1. Bump version in `**/package.json` and `packages/class/jsr.json` files. They should all have same version. 2. Commit & push changes to main branch. 3. Create a new [GitHub release](https://github.com/classmodel/class-web/releases) - Tag version and title should be the same as the version in the package.json file with `v` prefix. diff --git a/packages/class/jsr.json b/packages/class/jsr.json index bb0600e..6bbac66 100644 --- a/packages/class/jsr.json +++ b/packages/class/jsr.json @@ -1,6 +1,6 @@ { "name": "@classmodel/class", - "version": "0.0.3", + "version": "0.0.4", "exports": { ".": "./src/class.ts", "./class": "./src/class.ts", From 41cc336d790f1b1bdb20ba56c65ee52a810bedb0 Mon Sep 17 00:00:00 2001 From: Stefan Verhoeven Date: Mon, 21 Oct 2024 12:27:19 +0200 Subject: [PATCH 5/5] Fix typecheck --- packages/class/src/validate.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/class/src/validate.ts b/packages/class/src/validate.ts index 3962903..51bc0af 100644 --- a/packages/class/src/validate.ts +++ b/packages/class/src/validate.ts @@ -16,7 +16,7 @@ export type JsonSchemaOfConfig = JSONSchemaType; export const jsonSchemaOfConfig = rawConfigJson as unknown as JsonSchemaOfConfig; -const ajv = new Ajv({ +export const ajv = new Ajv({ coerceTypes: true, allErrors: true, useDefaults: "empty",