Skip to content

Commit

Permalink
new: Add more schema descriptions, remove some titles. (#1337)
Browse files Browse the repository at this point in the history
* Add more comments.

* Regen.
  • Loading branch information
milesj authored Feb 15, 2024
1 parent 557e612 commit f48dbf0
Show file tree
Hide file tree
Showing 20 changed files with 66 additions and 92 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ reqwest = { version = "0.11.24", default-features = false, features = [
"native-tls-vendored",
] }
rustc-hash = "1.1.0"
schematic = { version = "0.14.1", default-features = false, features = [
schematic = { version = "0.14.2", default-features = false, features = [
"schema",
] }
semver = "1.0.21"
Expand Down
3 changes: 3 additions & 0 deletions nextgen/config/src/project/owners_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@ use rustc_hash::FxHashMap;
use schematic::{Config, PathSegment, ValidateError};

cacheable!(
/// A mapping of file paths and file globs to owners.
#[derive(Clone, Config, Debug, PartialEq)]
#[serde(
untagged,
expecting = "expected a list of paths, or a map of paths to owners"
)]
pub enum OwnersPaths {
/// A list of file paths. The owner is the `defaultOwner`.
#[setting(default)]
List(Vec<String>),
/// A mapping of file paths to owners.
Map(FxHashMap<String, Vec<String>>),
}
);
Expand Down
9 changes: 8 additions & 1 deletion nextgen/config/src/project/task_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,16 @@ derive_enum!(
);

cacheable!(
/// Configures a command to execute, and its arguments.
#[derive(Clone, Config, Debug, Eq, PartialEq)]
#[serde(untagged, expecting = "expected a string or a list of strings")]
pub enum TaskArgs {
/// No value defined.
#[setting(default, null)]
None,
/// A command and arguments as a string. Will be parsed into a list.
String(String),
/// A command and arguments as a list of individual values.
List(Vec<String>),
}
);
Expand Down Expand Up @@ -118,14 +122,17 @@ impl TaskDependencyConfig {
}

cacheable!(
/// Configures another task that a task depends on.
#[derive(Clone, Config, Debug, Eq, PartialEq)]
#[serde(
untagged,
expecting = "expected a valid target or dependency config object"
)]
pub enum TaskDependency {
/// A task referenced by target.
Target(Target),

/// A task referenced by target, with additional parameters to pass through.
#[setting(nested)]
Config(TaskDependencyConfig),
}
Expand Down Expand Up @@ -158,7 +165,7 @@ cacheable!(
#[setting(nested)]
pub args: TaskArgs,

/// Other tasks that this task depends on, and must run to completion,
/// Other tasks that this task depends on, and must run to completion
/// before this task is ran. Can depend on sibling tasks, or tasks in
/// other projects, using targets.
#[setting(nested, validate = validate_deps)]
Expand Down
7 changes: 6 additions & 1 deletion nextgen/config/src/project/task_options_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@ fn validate_interactive<C>(
#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
#[serde(untagged, rename_all = "kebab-case")]
pub enum TaskOptionAffectedFiles {
/// Passed as command line arguments.
Args,
/// Passed as environment variables.
Env,
/// Passed as command line arguments and environment variables.
Enabled(bool),
}

Expand Down Expand Up @@ -63,10 +66,12 @@ impl<'de> Deserialize<'de> for TaskOptionAffectedFiles {
}

derive_enum!(
/// The pattern in which a task is dependent on a .env file.
/// The pattern in which a task is dependent on a `.env` file.
#[serde(untagged, expecting = "expected a boolean or a file system path")]
pub enum TaskOptionEnvFile {
/// Uses an `.env` file in the project root.
Enabled(bool),
/// Explicit path to an `.env` file.
File(FilePath),
}
);
Expand Down
4 changes: 4 additions & 0 deletions nextgen/config/src/project_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,17 @@ cacheable!(
);

cacheable!(
/// Expanded information about a project dependency.
#[derive(Clone, Config, Debug, PartialEq)]
#[serde(
untagged,
expecting = "expected a project name or dependency config object"
)]
pub enum ProjectDependsOn {
/// A project referenced by ID.
String(Id),

/// A project referenced by ID, with additional parameters to pass through.
#[setting(nested)]
Object(DependencyConfig),
}
Expand Down
1 change: 1 addition & 0 deletions nextgen/config/src/template_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use std::path::Path;

macro_rules! var_setting {
($name:ident, $ty:ty) => {
/// Configuration for a template variable.
#[derive(Clone, Config, Debug, Eq, PartialEq)]
pub struct $name {
/// The default value of the variable if none was provided.
Expand Down
5 changes: 5 additions & 0 deletions nextgen/config/src/toolchain/bin_config.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use schematic::Config;
use serde::Serialize;

/// Configures to a tool-specific binary to install.
#[derive(Clone, Config, Debug, Eq, PartialEq, Serialize)]
pub struct BinConfig {
/// Name of the binary, with optional version separated by `@`.
Expand All @@ -16,10 +17,14 @@ pub struct BinConfig {
pub name: Option<String>,
}

/// Configures to a tool-specific binary to install.
#[derive(Clone, Config, Debug, Eq, PartialEq, Serialize)]
#[serde(untagged, expecting = "expecting a bin name, or bin config object")]
pub enum BinEntry {
/// Name of a binary to install.
Name(String),

/// Expanded configuration for a binary to install.
#[setting(nested)]
Config(BinConfig),
}
Expand Down
1 change: 1 addition & 0 deletions nextgen/config/src/workspace/notifier_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use schematic::{validate, Config};
/// Configures how and where notifications are sent.
#[derive(Clone, Config, Debug)]
pub struct NotifierConfig {
/// A secure URL in which to send webhooks to.
#[setting(validate = validate::url_secure)]
pub webhook_url: Option<String>,
}
5 changes: 5 additions & 0 deletions nextgen/config/src/workspace_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ fn validate_projects<D, C>(
Ok(())
}

/// Configures projects in the workspace, using both globs and explicit source paths.
#[derive(Clone, Config, Debug)]
pub struct WorkspaceProjectsConfig {
/// A list of globs in which to locate project directories.
Expand All @@ -75,17 +76,21 @@ pub struct WorkspaceProjectsConfig {
pub sources: FxHashMap<Id, String>,
}

/// Configures projects in the workspace.
#[derive(Clone, Config, Debug)]
#[config(serde(
untagged,
expecting = "expected a list of globs, a map of projects, or both"
))]
pub enum WorkspaceProjects {
/// Using both globs and explicit source paths.
#[setting(nested)]
Both(WorkspaceProjectsConfig),

/// Using globs. Suffix with `moon.yml` to be distinct.
Globs(Vec<String>),

/// Using a mapping of IDs to source paths.
#[setting(default)]
Sources(FxHashMap<Id, String>),
}
Expand Down
4 changes: 2 additions & 2 deletions packages/types/src/tasks-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export interface TaskConfig {
*/
command: TaskArgs;
/**
* Other tasks that this task depends on, and must run to completion,
* Other tasks that this task depends on, and must run to completion
* before this task is ran. Can depend on sibling tasks, or tasks in
* other projects, using targets.
*/
Expand Down Expand Up @@ -332,7 +332,7 @@ export interface PartialTaskConfig {
*/
command?: PartialTaskArgs | null;
/**
* Other tasks that this task depends on, and must run to completion,
* Other tasks that this task depends on, and must run to completion
* before this task is ran. Can depend on sibling tasks, or tasks in
* other projects, using targets.
*/
Expand Down
6 changes: 6 additions & 0 deletions packages/types/src/template-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

/* eslint-disable */

/** Configuration for a template variable. */
export interface PartialTemplateVariableBoolSetting {
/** The default value of the variable if none was provided. */
default?: boolean | null;
Expand Down Expand Up @@ -33,6 +34,7 @@ export interface PartialTemplateVariableEnumSetting {
values?: PartialTemplateVariableEnumValue[] | null;
}

/** Configuration for a template variable. */
export interface PartialTemplateVariableNumberSetting {
/** The default value of the variable if none was provided. */
default?: number | null;
Expand All @@ -43,6 +45,7 @@ export interface PartialTemplateVariableNumberSetting {
type?: 'number' | null;
}

/** Configuration for a template variable. */
export interface PartialTemplateVariableStringSetting {
/** The default value of the variable if none was provided. */
default?: string | null;
Expand Down Expand Up @@ -93,6 +96,7 @@ export interface PartialTemplateFrontmatterConfig {
to?: string | null;
}

/** Configuration for a template variable. */
export interface TemplateVariableBoolSetting {
/** The default value of the variable if none was provided. */
default: boolean;
Expand Down Expand Up @@ -124,6 +128,7 @@ export interface TemplateVariableEnumSetting {
values: TemplateVariableEnumValue[];
}

/** Configuration for a template variable. */
export interface TemplateVariableNumberSetting {
/** The default value of the variable if none was provided. */
default: number;
Expand All @@ -134,6 +139,7 @@ export interface TemplateVariableNumberSetting {
type: 'number';
}

/** Configuration for a template variable. */
export interface TemplateVariableStringSetting {
/** The default value of the variable if none was provided. */
default: string;
Expand Down
2 changes: 2 additions & 0 deletions packages/types/src/toolchain-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export interface BunConfig {
version: string | null;
}

/** Configures to a tool-specific binary to install. */
export interface BinConfig {
/** Name of the binary, with optional version separated by `@`. */
bin: string;
Expand Down Expand Up @@ -362,6 +363,7 @@ export interface PartialBunConfig {
version?: string | null;
}

/** Configures to a tool-specific binary to install. */
export interface PartialBinConfig {
/** Name of the binary, with optional version separated by `@`. */
bin?: string | null;
Expand Down
4 changes: 4 additions & 0 deletions packages/types/src/workspace-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,11 @@ export interface HasherConfig {

/** Configures how and where notifications are sent. */
export interface NotifierConfig {
/** A secure URL in which to send webhooks to. */
webhookUrl: string | null;
}

/** Configures projects in the workspace, using both globs and explicit source paths. */
export interface WorkspaceProjectsConfig {
/**
* A list of globs in which to locate project directories.
Expand Down Expand Up @@ -357,9 +359,11 @@ export interface PartialHasherConfig {

/** Configures how and where notifications are sent. */
export interface PartialNotifierConfig {
/** A secure URL in which to send webhooks to. */
webhookUrl?: string | null;
}

/** Configures projects in the workspace, using both globs and explicit source paths. */
export interface PartialWorkspaceProjectsConfig {
/**
* A list of globs in which to locate project directories.
Expand Down
Loading

0 comments on commit f48dbf0

Please sign in to comment.