diff --git a/.github/workflows/moon.yml b/.github/workflows/moon.yml index e07d7f488dc..89b876c3b66 100644 --- a/.github/workflows/moon.yml +++ b/.github/workflows/moon.yml @@ -7,6 +7,7 @@ on: paths: - .github/workflows/moon.yml - .moon/workspace.yml + - .moon/toolchain.yml - .moon/project.yml - crates/** - packages/** @@ -39,7 +40,7 @@ jobs: path: ~/.moon/tools key: ${{ runner.os }}-moon-node@${{ matrix.node-version }}-${{ - hashFiles('.moon/workspace.yml') }} + hashFiles('.moon/toolchain.yml') }} restore-keys: ${{ runner.os }}-moon-node@${{ matrix.node-version }}- - uses: actions-rs/toolchain@v1 with: diff --git a/.moon/project.yml b/.moon/project.yml index 7665646e756..19ebb407693 100644 --- a/.moon/project.yml +++ b/.moon/project.yml @@ -1,4 +1,4 @@ -$schema: '../schemas/global-project.json' +$schema: '../website/static/schemas/global-project.json' fileGroups: configs: diff --git a/.moon/toolchain.yml b/.moon/toolchain.yml new file mode 100644 index 00000000000..646bd9071c6 --- /dev/null +++ b/.moon/toolchain.yml @@ -0,0 +1,17 @@ +$schema: '../website/static/schemas/toolchain.json' + +node: + version: '16.18.0' + packageManager: 'yarn' + yarn: + version: '3.2.3' + plugins: + - 'interactive-tools' + - 'version' + - 'workspace-tools' + addEnginesConstraint: false + inferTasksFromScripts: false + +typescript: + routeOutDirToCache: true + syncProjectReferences: true diff --git a/.moon/workspace.yml b/.moon/workspace.yml index a7564a5d401..075a82115fa 100644 --- a/.moon/workspace.yml +++ b/.moon/workspace.yml @@ -1,6 +1,6 @@ # Trigger CI: 7 -$schema: '../schemas/workspace.json' +$schema: '../website/static/schemas/workspace.json' projects: - 'packages/*' @@ -8,22 +8,6 @@ projects: - '!packages/core-*' - 'website' -node: - version: '16.18.0' - packageManager: 'yarn' - yarn: - version: '3.2.3' - plugins: - - 'interactive-tools' - - 'version' - - 'workspace-tools' - addEnginesConstraint: false - inferTasksFromScripts: false - -typescript: - routeOutDirToCache: true - syncProjectReferences: true - generator: templates: - './templates' @@ -36,3 +20,7 @@ runner: vcs: defaultBranch: 'master' + +# TEMP, remove after 0.20 lands +node: + version: '16.18.0' diff --git a/crates/cli/src/commands/docker/scaffold.rs b/crates/cli/src/commands/docker/scaffold.rs index f4ad4e6105c..cbd73dd266b 100644 --- a/crates/cli/src/commands/docker/scaffold.rs +++ b/crates/cli/src/commands/docker/scaffold.rs @@ -62,7 +62,7 @@ async fn scaffold_workspace(workspace: &Workspace, docker_root: &Path) -> Result for lang in ProjectLanguage::iter() { match lang { ProjectLanguage::JavaScript => { - if workspace.config.node.is_some() { + if workspace.toolchain.config.node.is_some() { files.push(NPM.manifest_filename.to_owned()); for ext in NODE.file_exts { @@ -71,7 +71,7 @@ async fn scaffold_workspace(workspace: &Workspace, docker_root: &Path) -> Result } } ProjectLanguage::TypeScript => { - if let Some(typescript_config) = &workspace.config.typescript { + if let Some(typescript_config) = &workspace.toolchain.config.typescript { files.push(typescript_config.project_config_file_name.to_owned()); } } @@ -93,7 +93,7 @@ async fn scaffold_workspace(workspace: &Workspace, docker_root: &Path) -> Result for lang in ProjectLanguage::iter() { match lang { ProjectLanguage::JavaScript => { - if let Some(node_config) = &workspace.config.node { + if let Some(node_config) = &workspace.toolchain.config.node { let package_manager = match &node_config.package_manager { NodePackageManager::Npm => NPM, NodePackageManager::Pnpm => PNPM, @@ -106,7 +106,7 @@ async fn scaffold_workspace(workspace: &Workspace, docker_root: &Path) -> Result } } ProjectLanguage::TypeScript => { - if let Some(typescript_config) = &workspace.config.typescript { + if let Some(typescript_config) = &workspace.toolchain.config.typescript { files.push(&typescript_config.root_config_file_name); files.push(&typescript_config.root_options_config_file_name); } diff --git a/crates/cli/src/commands/init/mod.rs b/crates/cli/src/commands/init/mod.rs index f1b268a2081..7de792bb832 100644 --- a/crates/cli/src/commands/init/mod.rs +++ b/crates/cli/src/commands/init/mod.rs @@ -5,8 +5,14 @@ use crate::helpers::AnyError; use clap::ValueEnum; use dialoguer::theme::ColorfulTheme; use dialoguer::Confirm; -use moon_config::{load_global_project_config_template, load_workspace_config_template}; -use moon_constants::{CONFIG_DIRNAME, CONFIG_GLOBAL_PROJECT_FILENAME, CONFIG_WORKSPACE_FILENAME}; +use moon_config::{ + load_global_project_config_template, load_toolchain_config_template, + load_workspace_config_template, +}; +use moon_constants::{ + CONFIG_DIRNAME, CONFIG_GLOBAL_PROJECT_FILENAME, CONFIG_TOOLCHAIN_FILENAME, + CONFIG_WORKSPACE_FILENAME, +}; use moon_logger::color; use moon_node_lang::NPM; use moon_terminal::{create_theme, safe_exit}; @@ -28,7 +34,11 @@ pub enum InitTool { TypeScript, } -fn render_template(context: &Context) -> Result { +fn render_toolchain_template(context: &Context) -> Result { + Tera::one_off(load_toolchain_config_template(), context, false) +} + +fn render_workspace_template(context: &Context) -> Result { Tera::one_off(load_workspace_config_template(), context, false) } @@ -148,7 +158,7 @@ pub async fn init( context.insert("vcs_default_branch", &vcs.1); // Initialize all tools - let mut workspace_config = VecDeque::new(); + let mut toolchain_configs = VecDeque::new(); if options.yes || dest_dir.join(NPM.manifest_filename).exists() @@ -156,7 +166,7 @@ pub async fn init( .with_prompt("Initialize Node.js?") .interact()? { - workspace_config + toolchain_configs .push_back(init_node(&dest_dir, &options, &theme, Some(&mut context)).await?); if options.yes @@ -165,16 +175,16 @@ pub async fn init( .with_prompt("Initialize TypeScript?") .interact()? { - workspace_config.push_back(init_typescript(&dest_dir, &options, &theme).await?); + toolchain_configs.push_back(init_typescript(&dest_dir, &options, &theme).await?); } } - workspace_config.push_front(render_template(&context)?); + toolchain_configs.push_front(render_toolchain_template(&context)?); // Create config files fs::write( - &moon_dir.join(CONFIG_WORKSPACE_FILENAME), - workspace_config + &moon_dir.join(CONFIG_TOOLCHAIN_FILENAME), + toolchain_configs .into_iter() .map(|c| c.trim().to_owned()) .collect::>() @@ -182,6 +192,12 @@ pub async fn init( ) .await?; + fs::write( + &moon_dir.join(CONFIG_WORKSPACE_FILENAME), + render_workspace_template(&context)?, + ) + .await?; + fs::write( &moon_dir.join(CONFIG_GLOBAL_PROJECT_FILENAME), Tera::one_off(load_global_project_config_template(), &context, false)?, @@ -219,7 +235,7 @@ mod tests { fn renders_default() { let context = create_default_context(); - assert_snapshot!(render_template(&context).unwrap()); + assert_snapshot!(render_workspace_template(&context).unwrap()); } #[test] @@ -227,7 +243,7 @@ mod tests { let mut context = create_default_context(); context.insert("project_globs", &vec!["apps/*", "packages/*"]); - assert_snapshot!(render_template(&context).unwrap()); + assert_snapshot!(render_workspace_template(&context).unwrap()); } #[test] @@ -235,7 +251,7 @@ mod tests { let mut context = create_default_context(); context.insert("projects", &BTreeMap::from([("example", "apps/example")])); - assert_snapshot!(render_template(&context).unwrap()); + assert_snapshot!(render_workspace_template(&context).unwrap()); } #[test] @@ -244,7 +260,7 @@ mod tests { context.insert("vcs_manager", &"git"); context.insert("vcs_default_branch", &"main"); - assert_snapshot!(render_template(&context).unwrap()); + assert_snapshot!(render_workspace_template(&context).unwrap()); } #[test] @@ -253,6 +269,6 @@ mod tests { context.insert("vcs_manager", &"svn"); context.insert("vcs_default_branch", &"trunk"); - assert_snapshot!(render_template(&context).unwrap()); + assert_snapshot!(render_workspace_template(&context).unwrap()); } } diff --git a/crates/cli/src/commands/init/node.rs b/crates/cli/src/commands/init/node.rs index 54a2d734aa5..fef9d576eb2 100644 --- a/crates/cli/src/commands/init/node.rs +++ b/crates/cli/src/commands/init/node.rs @@ -4,7 +4,7 @@ use dialoguer::theme::ColorfulTheme; use dialoguer::{Confirm, Select}; use moon_config::{ default_node_version, default_npm_version, default_pnpm_version, default_yarn_version, - load_workspace_node_config_template, + load_toolchain_node_config_template, }; use moon_lang::{is_using_package_manager, is_using_version_manager}; use moon_logger::color; @@ -18,8 +18,8 @@ use std::collections::BTreeMap; use std::path::Path; use tera::{Context, Error, Tera}; -fn render_template(context: Context) -> Result { - Tera::one_off(load_workspace_node_config_template(), &context, false) +pub fn render_template(context: Context) -> Result { + Tera::one_off(load_toolchain_node_config_template(), &context, false) } /// Detect the Node.js version from local configuration files, diff --git a/crates/cli/src/commands/init/typescript.rs b/crates/cli/src/commands/init/typescript.rs index 45dd67fb01d..9b05fade5c8 100644 --- a/crates/cli/src/commands/init/typescript.rs +++ b/crates/cli/src/commands/init/typescript.rs @@ -2,14 +2,14 @@ use super::InitOptions; use crate::helpers::AnyError; use dialoguer::theme::ColorfulTheme; use dialoguer::Confirm; -use moon_config::load_workspace_typescript_config_template; +use moon_config::load_toolchain_typescript_config_template; use moon_terminal::label_header; use moon_typescript_lang::TsConfigJson; use std::path::Path; use tera::{Context, Error, Tera}; -fn render_template(context: Context) -> Result { - Tera::one_off(load_workspace_typescript_config_template(), &context, false) +pub fn render_template(context: Context) -> Result { + Tera::one_off(load_toolchain_typescript_config_template(), &context, false) } pub async fn init_typescript( diff --git a/crates/cli/src/commands/setup.rs b/crates/cli/src/commands/setup.rs index 393bfd01869..0493595740c 100644 --- a/crates/cli/src/commands/setup.rs +++ b/crates/cli/src/commands/setup.rs @@ -9,7 +9,7 @@ pub async fn setup() -> Result<(), Box> { let workspace = load_workspace().await?; let mut dep_graph = DepGraph::default(); - if let Some(node) = &workspace.config.node { + if let Some(node) = &workspace.toolchain.config.node { let runtime = Runtime::Node(Version(node.version.to_owned(), false)); if is_test_env() { diff --git a/crates/cli/src/helpers.rs b/crates/cli/src/helpers.rs index d89d8ba0f42..1a714f3260c 100644 --- a/crates/cli/src/helpers.rs +++ b/crates/cli/src/helpers.rs @@ -22,7 +22,7 @@ pub async fn load_workspace() -> Result { .projects .register_platform(Box::new(SystemPlatform::default()))?; - if workspace.config.node.is_some() { + if workspace.toolchain.config.node.is_some() { workspace .projects .register_platform(Box::new(NodePlatform::default()))?; @@ -43,7 +43,7 @@ pub async fn load_workspace_with_toolchain() -> Result { - if let Some(node_config) = &workspace.config.node { + if let Some(node_config) = &workspace.toolchain.config.node { workspace .toolchain .node diff --git a/crates/cli/tests/docker_test.rs b/crates/cli/tests/docker_test.rs index 48031e9d9e0..db8c808830f 100644 --- a/crates/cli/tests/docker_test.rs +++ b/crates/cli/tests/docker_test.rs @@ -52,6 +52,7 @@ mod scaffold_workspace { let docker = fixture.join(".moon/docker/workspace"); assert!(docker.join(".moon/project.yml").exists()); + assert!(docker.join(".moon/toolchain.yml").exists()); assert!(docker.join(".moon/workspace.yml").exists()); } @@ -186,7 +187,7 @@ mod scaffold_sources { fn can_include_more_files() { let fixture = create_sandbox_with_git("cases"); - let assert = create_moon_command(fixture.path()) + create_moon_command(fixture.path()) .arg("docker") .arg("scaffold") .arg("base") @@ -199,8 +200,6 @@ mod scaffold_sources { let docker = fixture.join(".moon/docker/sources"); - moon_utils::test::debug_sandbox(&fixture, &assert); - assert!(docker.join("base").exists()); assert!(docker.join("outputs/generate.js").exists()); assert!(docker.join("passthrough-args/passthroughArgs.sh").exists()); diff --git a/crates/cli/tests/init_node_test.rs b/crates/cli/tests/init_node_test.rs index 113dc084c74..adfab12e24d 100644 --- a/crates/cli/tests/init_node_test.rs +++ b/crates/cli/tests/init_node_test.rs @@ -9,7 +9,7 @@ mod init_node { fn infers_version_from_nvm() { let fixture = create_sandbox("init-sandbox"); let root = fixture.path(); - let workspace_config = root.join(".moon").join("workspace.yml"); + let config = root.join(".moon").join("toolchain.yml"); fs::write(&root.join(".nvmrc"), "1.2.3").unwrap(); @@ -19,7 +19,7 @@ mod init_node { .arg(root) .assert(); - let content = fs::read_to_string(workspace_config).unwrap(); + let content = fs::read_to_string(config).unwrap(); assert!(predicate::str::contains("version: '1.2.3'").eval(&content)); } @@ -28,7 +28,7 @@ mod init_node { fn infers_version_from_nodenv() { let fixture = create_sandbox("init-sandbox"); let root = fixture.path(); - let workspace_config = root.join(".moon").join("workspace.yml"); + let config = root.join(".moon").join("toolchain.yml"); fs::write(&root.join(".node-version"), "1.2.3").unwrap(); @@ -38,7 +38,7 @@ mod init_node { .arg(root) .assert(); - let content = fs::read_to_string(workspace_config).unwrap(); + let content = fs::read_to_string(config).unwrap(); assert!(predicate::str::contains("version: '1.2.3'").eval(&content)); } @@ -47,7 +47,7 @@ mod init_node { fn infers_globs_from_workspaces() { let fixture = create_sandbox("init-sandbox"); let root = fixture.path(); - let workspace_config = root.join(".moon").join("workspace.yml"); + let config = root.join(".moon").join("workspace.yml"); fs::create_dir_all(root.join("packages").join("foo")).unwrap(); fs::write(&root.join("packages").join("foo").join("README"), "Hello").unwrap(); @@ -67,7 +67,7 @@ mod init_node { .arg(root) .assert(); - let content = fs::read_to_string(workspace_config).unwrap(); + let content = fs::read_to_string(config).unwrap(); assert!(predicate::str::contains("projects:\n - 'app'").eval(&content)); } @@ -76,7 +76,7 @@ mod init_node { fn infers_globs_from_workspaces_expanded() { let fixture = create_sandbox("init-sandbox"); let root = fixture.path(); - let workspace_config = root.join(".moon").join("workspace.yml"); + let config = root.join(".moon").join("workspace.yml"); fs::create_dir_all(root.join("packages").join("bar")).unwrap(); fs::write(&root.join("packages").join("bar").join("README"), "Hello").unwrap(); @@ -96,7 +96,7 @@ mod init_node { .arg(root) .assert(); - let content = fs::read_to_string(workspace_config).unwrap(); + let content = fs::read_to_string(config).unwrap(); assert!(predicate::str::contains("projects:\n - 'app'").eval(&content)); } @@ -108,7 +108,7 @@ mod init_node { fn infers_npm() { let fixture = create_sandbox("init-sandbox"); let root = fixture.path(); - let workspace_config = root.join(".moon").join("workspace.yml"); + let config = root.join(".moon").join("toolchain.yml"); fs::write(&root.join("package-lock.json"), "").unwrap(); @@ -118,7 +118,7 @@ mod init_node { .arg(root) .assert(); - let content = fs::read_to_string(workspace_config).unwrap(); + let content = fs::read_to_string(config).unwrap(); assert!(predicate::str::contains("packageManager: 'npm'").eval(&content)); } @@ -127,7 +127,7 @@ mod init_node { fn infers_npm_from_package() { let fixture = create_sandbox("init-sandbox"); let root = fixture.path(); - let workspace_config = root.join(".moon").join("workspace.yml"); + let config = root.join(".moon").join("toolchain.yml"); fs::write( &root.join("package.json"), @@ -141,7 +141,7 @@ mod init_node { .arg(root) .assert(); - let content = fs::read_to_string(workspace_config).unwrap(); + let content = fs::read_to_string(config).unwrap(); assert!(predicate::str::contains("packageManager: 'npm'").eval(&content)); assert!(predicate::str::contains("npm:\n version: '4.5.6'").eval(&content)); @@ -151,7 +151,7 @@ mod init_node { fn infers_pnpm() { let fixture = create_sandbox("init-sandbox"); let root = fixture.path(); - let workspace_config = root.join(".moon").join("workspace.yml"); + let config = root.join(".moon").join("toolchain.yml"); fs::write(&root.join("pnpm-lock.yaml"), "").unwrap(); @@ -161,7 +161,7 @@ mod init_node { .arg(root) .assert(); - let content = fs::read_to_string(workspace_config).unwrap(); + let content = fs::read_to_string(config).unwrap(); assert!(predicate::str::contains("packageManager: 'pnpm'").eval(&content)); } @@ -170,7 +170,7 @@ mod init_node { fn infers_pnpm_from_package() { let fixture = create_sandbox("init-sandbox"); let root = fixture.path(); - let workspace_config = root.join(".moon").join("workspace.yml"); + let config = root.join(".moon").join("toolchain.yml"); fs::write( &root.join("package.json"), @@ -184,7 +184,7 @@ mod init_node { .arg(root) .assert(); - let content = fs::read_to_string(workspace_config).unwrap(); + let content = fs::read_to_string(config).unwrap(); assert!(predicate::str::contains("packageManager: 'pnpm'").eval(&content)); assert!(predicate::str::contains("pnpm:\n version: '4.5.6'").eval(&content)); @@ -194,7 +194,7 @@ mod init_node { fn infers_yarn() { let fixture = create_sandbox("init-sandbox"); let root = fixture.path(); - let workspace_config = root.join(".moon").join("workspace.yml"); + let config = root.join(".moon").join("toolchain.yml"); fs::write(&root.join("yarn.lock"), "").unwrap(); @@ -204,7 +204,7 @@ mod init_node { .arg(root) .assert(); - let content = fs::read_to_string(workspace_config).unwrap(); + let content = fs::read_to_string(config).unwrap(); assert!(predicate::str::contains("packageManager: 'yarn'").eval(&content)); } @@ -213,7 +213,7 @@ mod init_node { fn infers_yarn_from_package() { let fixture = create_sandbox("init-sandbox"); let root = fixture.path(); - let workspace_config = root.join(".moon").join("workspace.yml"); + let config = root.join(".moon").join("toolchain.yml"); fs::write( &root.join("package.json"), @@ -227,7 +227,7 @@ mod init_node { .arg(root) .assert(); - let content = fs::read_to_string(workspace_config).unwrap(); + let content = fs::read_to_string(config).unwrap(); assert!(predicate::str::contains("packageManager: 'yarn'").eval(&content)); assert!(predicate::str::contains("yarn:\n version: '4.5.6'").eval(&content)); diff --git a/crates/cli/tests/run_node_test.rs b/crates/cli/tests/run_node_test.rs index f28b18d8b30..40701aed3da 100644 --- a/crates/cli/tests/run_node_test.rs +++ b/crates/cli/tests/run_node_test.rs @@ -4,7 +4,7 @@ use insta::assert_snapshot; use moon_utils::test::{create_moon_command, create_sandbox_with_git, get_assert_output}; use predicates::prelude::*; use std::fs::read_to_string; -use utils::{append_workspace_config, get_path_safe_output, update_workspace_config}; +use utils::{append_toolchain_config, get_path_safe_output, update_toolchain_config}; #[test] fn runs_package_managers() { @@ -177,7 +177,7 @@ fn passes_args_through() { fn passes_args_to_the_node_bin() { let fixture = create_sandbox_with_git("node"); - append_workspace_config( + append_toolchain_config( fixture.path(), " binExecArgs:\n - '--preserve-symlinks'\n", ); @@ -361,7 +361,7 @@ mod engines { fn adds_engines_constraint() { let fixture = create_sandbox_with_git("node"); - update_workspace_config( + update_toolchain_config( fixture.path(), "addEnginesConstraint: false", "addEnginesConstraint: true", @@ -379,7 +379,7 @@ mod engines { fn doesnt_add_engines_constraint() { let fixture = create_sandbox_with_git("node"); - append_workspace_config(fixture.path(), r#" addEnginesConstraint: false"#); + append_toolchain_config(fixture.path(), r#" addEnginesConstraint: false"#); create_moon_command(fixture.path()) .arg("run") @@ -410,7 +410,7 @@ mod version_manager { fn adds_nvmrc_file() { let fixture = create_sandbox_with_git("node"); - append_workspace_config(fixture.path(), r#" syncVersionManagerConfig: nvm"#); + append_toolchain_config(fixture.path(), r#" syncVersionManagerConfig: nvm"#); create_moon_command(fixture.path()) .arg("run") @@ -429,7 +429,7 @@ mod version_manager { fn adds_nodenv_file() { let fixture = create_sandbox_with_git("node"); - append_workspace_config(fixture.path(), r#" syncVersionManagerConfig: nodenv"#); + append_toolchain_config(fixture.path(), r#" syncVersionManagerConfig: nodenv"#); create_moon_command(fixture.path()) .arg("run") @@ -448,7 +448,7 @@ mod version_manager { fn errors_for_invalid_value() { let fixture = create_sandbox_with_git("node"); - append_workspace_config(fixture.path(), r#" syncVersionManagerConfig: invalid"#); + append_toolchain_config(fixture.path(), r#" syncVersionManagerConfig: invalid"#); let assert = create_moon_command(fixture.path()) .arg("run") @@ -470,13 +470,13 @@ mod sync_depends_on { fn test_depends_on_format(format: &str) { let fixture = create_sandbox_with_git("node"); - update_workspace_config( + update_toolchain_config( fixture.path(), "syncProjectWorkspaceDependencies: false", "syncProjectWorkspaceDependencies: true", ); - append_workspace_config( + append_toolchain_config( fixture.path(), &format!(" dependencyVersionFormat: {}", format), ); @@ -542,7 +542,7 @@ mod sync_depends_on { fn syncs_depends_on_with_scopes() { let fixture = create_sandbox_with_git("node"); - update_workspace_config( + update_toolchain_config( fixture.path(), "syncProjectWorkspaceDependencies: false", "syncProjectWorkspaceDependencies: true", @@ -1047,7 +1047,7 @@ mod typescript { fn doesnt_create_missing_tsconfig_if_setting_off() { let fixture = create_sandbox_with_git("typescript"); - update_workspace_config( + update_toolchain_config( fixture.path(), "createMissingConfig: true", "createMissingConfig: false", @@ -1067,7 +1067,7 @@ mod typescript { fn doesnt_create_missing_tsconfig_if_syncing_off() { let fixture = create_sandbox_with_git("typescript"); - update_workspace_config( + update_toolchain_config( fixture.path(), "syncProjectReferences: true", "syncProjectReferences: false", @@ -1141,7 +1141,7 @@ mod typescript { fn routes_to_cache() { let fixture = create_sandbox_with_git("typescript"); - update_workspace_config( + update_toolchain_config( fixture.path(), "routeOutDirToCache: false", "routeOutDirToCache: true", @@ -1161,7 +1161,7 @@ mod typescript { fn routes_to_cache_when_no_compiler_options() { let fixture = create_sandbox_with_git("typescript"); - update_workspace_config( + update_toolchain_config( fixture.path(), "routeOutDirToCache: false", "routeOutDirToCache: true", @@ -1202,7 +1202,7 @@ mod typescript { fn maps_paths() { let fixture = create_sandbox_with_git("typescript"); - update_workspace_config( + update_toolchain_config( fixture.path(), "syncProjectReferencesToPaths: false", "syncProjectReferencesToPaths: true", @@ -1222,13 +1222,13 @@ mod typescript { fn doesnt_map_paths_if_no_refs() { let fixture = create_sandbox_with_git("typescript"); - update_workspace_config( + update_toolchain_config( fixture.path(), "syncProjectReferences: true", "syncProjectReferences: false", ); - update_workspace_config( + update_toolchain_config( fixture.path(), "syncProjectReferencesToPaths: false", "syncProjectReferencesToPaths: true", @@ -1269,7 +1269,7 @@ mod workspace_overrides { fn can_override_version() { let fixture = create_sandbox_with_git("node"); - update_workspace_config( + update_toolchain_config( fixture.path(), "dedupeOnLockfileChange: true", "dedupeOnLockfileChange: false", diff --git a/crates/cli/tests/run_test.rs b/crates/cli/tests/run_test.rs index 151bc867d7e..72d86bd0d85 100644 --- a/crates/cli/tests/run_test.rs +++ b/crates/cli/tests/run_test.rs @@ -235,11 +235,11 @@ mod dependencies { assert_eq!( extract_hash_from_run(fixture.path(), "outputs:asDep").await, - "eb42c930249c065743d1ad796c966c92c87f1a091e0a517fea957b983332ad4e" + "92c5b8c6dceccedc0547032c9eeb5be64d225545ac679c6b1bb7d41baf892d77" ); assert_eq!( extract_hash_from_run(fixture.path(), "outputs:withDeps").await, - "8ee5353d64ec1a5cf7b6dc9d453668ee5b504da90a0bdd975015a10b8a6577d4" + "3d4fef133338cff776bd701538bf4861c92dce2e1f1282feb35d42a1b13c4b3b" ); } @@ -254,11 +254,11 @@ mod dependencies { assert_eq!( extract_hash_from_run(fixture.path(), "outputs:asDep").await, - "eb42c930249c065743d1ad796c966c92c87f1a091e0a517fea957b983332ad4e" + "92c5b8c6dceccedc0547032c9eeb5be64d225545ac679c6b1bb7d41baf892d77" ); assert_eq!( extract_hash_from_run(fixture.path(), "outputs:withDeps").await, - "8ee5353d64ec1a5cf7b6dc9d453668ee5b504da90a0bdd975015a10b8a6577d4" + "3d4fef133338cff776bd701538bf4861c92dce2e1f1282feb35d42a1b13c4b3b" ); // Create an `inputs` file for `outputs:asDep` @@ -271,11 +271,11 @@ mod dependencies { assert_eq!( extract_hash_from_run(fixture.path(), "outputs:asDep").await, - "56d28527480e18d56eaafb3316a374103db405b4ce91aee37b505556b44202d0" + "296411f059717096bc78f8bd1a5f33019de11bd57480c900d9d3a25ea5441ca1" ); assert_eq!( extract_hash_from_run(fixture.path(), "outputs:withDeps").await, - "c8be10745d2b5462452d49278e27b447c61a33c4049f025750d6ed9fb07a09fa" + "b7af1e952f2146ce128b74809598233fdc17cc0dadd3e863edaf1cb8c69f019b" ); } } diff --git a/crates/cli/tests/snapshots/run_node_test__aliases__runs_via_package_name.snap b/crates/cli/tests/snapshots/run_node_test__aliases__runs_via_package_name.snap index 13761c105d1..21fbd8da1e7 100644 --- a/crates/cli/tests/snapshots/run_node_test__aliases__runs_via_package_name.snap +++ b/crates/cli/tests/snapshots/run_node_test__aliases__runs_via_package_name.snap @@ -1,12 +1,12 @@ --- source: crates/cli/tests/run_node_test.rs -assertion_line: 978 +assertion_line: 980 expression: get_assert_output(&assert) --- ▪▪▪▪ npm install ▪▪▪▪ nodeNameScope:standard name-only -▪▪▪▪ nodeNameScope:standard (100ms, b35c4e51) +▪▪▪▪ nodeNameScope:standard (100ms) Tasks: 1 completed Time: 100ms diff --git a/crates/cli/tests/snapshots/run_node_test__engines__adds_engines_constraint.snap b/crates/cli/tests/snapshots/run_node_test__engines__adds_engines_constraint.snap index b127e9f4ac5..d255cf201ce 100644 --- a/crates/cli/tests/snapshots/run_node_test__engines__adds_engines_constraint.snap +++ b/crates/cli/tests/snapshots/run_node_test__engines__adds_engines_constraint.snap @@ -1,6 +1,6 @@ --- source: crates/cli/tests/run_node_test.rs -assertion_line: 373 +assertion_line: 377 expression: "read_to_string(fixture.path().join(\"package.json\")).unwrap()" --- { diff --git a/crates/cli/tests/snapshots/run_node_test__handles_process_exit_code_nonzero.snap b/crates/cli/tests/snapshots/run_node_test__handles_process_exit_code_nonzero.snap index fc53189e28f..7f447d2033d 100644 --- a/crates/cli/tests/snapshots/run_node_test__handles_process_exit_code_nonzero.snap +++ b/crates/cli/tests/snapshots/run_node_test__handles_process_exit_code_nonzero.snap @@ -7,7 +7,7 @@ expression: get_assert_output(&assert) ▪▪▪▪ node:exitCodeNonZero stdout This should appear! -▪▪▪▪ node:exitCodeNonZero (100ms, 438cb1e6) +▪▪▪▪ node:exitCodeNonZero (100ms) stderr ERROR Process ~/.moon/tools/node/16.1.0/bin/node failed with a 1 exit code. diff --git a/crates/cli/tests/snapshots/run_node_test__handles_process_exit_code_zero.snap b/crates/cli/tests/snapshots/run_node_test__handles_process_exit_code_zero.snap index 7c5a77174ff..0793f43ca3a 100644 --- a/crates/cli/tests/snapshots/run_node_test__handles_process_exit_code_zero.snap +++ b/crates/cli/tests/snapshots/run_node_test__handles_process_exit_code_zero.snap @@ -7,7 +7,7 @@ expression: get_assert_output(&assert) ▪▪▪▪ node:exitCodeZero stdout This should appear! -▪▪▪▪ node:exitCodeZero (100ms, e009ce4e) +▪▪▪▪ node:exitCodeZero (100ms) Tasks: 1 completed Time: 100ms diff --git a/crates/cli/tests/snapshots/run_node_test__handles_process_exit_nonzero.snap b/crates/cli/tests/snapshots/run_node_test__handles_process_exit_nonzero.snap index 41599be163e..abb752e618d 100644 --- a/crates/cli/tests/snapshots/run_node_test__handles_process_exit_nonzero.snap +++ b/crates/cli/tests/snapshots/run_node_test__handles_process_exit_nonzero.snap @@ -6,7 +6,7 @@ expression: get_assert_output(&assert) ▪▪▪▪ npm install ▪▪▪▪ node:processExitNonZero stdout -▪▪▪▪ node:processExitNonZero (100ms, 2ab13a98) +▪▪▪▪ node:processExitNonZero (100ms) stderr ERROR Process ~/.moon/tools/node/16.1.0/bin/node failed with a 1 exit code. diff --git a/crates/cli/tests/snapshots/run_node_test__handles_process_exit_zero.snap b/crates/cli/tests/snapshots/run_node_test__handles_process_exit_zero.snap index 6ae56e6fc66..13ad72eb8f7 100644 --- a/crates/cli/tests/snapshots/run_node_test__handles_process_exit_zero.snap +++ b/crates/cli/tests/snapshots/run_node_test__handles_process_exit_zero.snap @@ -6,7 +6,7 @@ expression: get_assert_output(&assert) ▪▪▪▪ npm install ▪▪▪▪ node:processExitZero stdout -▪▪▪▪ node:processExitZero (100ms, 8d69257d) +▪▪▪▪ node:processExitZero (100ms) Tasks: 1 completed Time: 100ms diff --git a/crates/cli/tests/snapshots/run_node_test__handles_unhandled_promise.snap b/crates/cli/tests/snapshots/run_node_test__handles_unhandled_promise.snap index 3ad05b15d1a..b646aa7b63f 100644 --- a/crates/cli/tests/snapshots/run_node_test__handles_unhandled_promise.snap +++ b/crates/cli/tests/snapshots/run_node_test__handles_unhandled_promise.snap @@ -6,7 +6,7 @@ expression: "get_path_safe_output(&assert, fixture.path())" ▪▪▪▪ npm install ▪▪▪▪ node:unhandledPromise stdout -▪▪▪▪ node:unhandledPromise (100ms, 986c5de4) +▪▪▪▪ node:unhandledPromise (100ms) stderr node:internal/process/promises:246 triggerUncaughtException(err, true /* fromPromise */); diff --git a/crates/cli/tests/snapshots/run_node_test__inherits_moon_env_vars.snap b/crates/cli/tests/snapshots/run_node_test__inherits_moon_env_vars.snap index 87637d96a04..8dd895d1609 100644 --- a/crates/cli/tests/snapshots/run_node_test__inherits_moon_env_vars.snap +++ b/crates/cli/tests/snapshots/run_node_test__inherits_moon_env_vars.snap @@ -16,7 +16,7 @@ MOON_TARGET=node:envVarsMoon MOON_TOOLCHAIN_DIR=~/.moon MOON_WORKING_DIR= MOON_WORKSPACE_ROOT= -▪▪▪▪ node:envVarsMoon (100ms, 0f1107c7) +▪▪▪▪ node:envVarsMoon (100ms) Tasks: 1 completed Time: 100ms diff --git a/crates/cli/tests/snapshots/run_node_test__passes_args_through.snap b/crates/cli/tests/snapshots/run_node_test__passes_args_through.snap index c486d7b786e..81e2127632f 100644 --- a/crates/cli/tests/snapshots/run_node_test__passes_args_through.snap +++ b/crates/cli/tests/snapshots/run_node_test__passes_args_through.snap @@ -6,7 +6,7 @@ expression: get_assert_output(&assert) ▪▪▪▪ npm install ▪▪▪▪ node:passthroughArgs Args: -aBc --opt value --optCamel=value foo 'bar baz' --opt-kebab 123 -▪▪▪▪ node:passthroughArgs (100ms, 34fdffbb) +▪▪▪▪ node:passthroughArgs (100ms) Tasks: 1 completed Time: 100ms diff --git a/crates/cli/tests/snapshots/run_node_test__passes_args_to_the_node_bin.snap b/crates/cli/tests/snapshots/run_node_test__passes_args_to_the_node_bin.snap index 6818e9fb674..9a5853455dc 100644 --- a/crates/cli/tests/snapshots/run_node_test__passes_args_to_the_node_bin.snap +++ b/crates/cli/tests/snapshots/run_node_test__passes_args_to_the_node_bin.snap @@ -1,12 +1,12 @@ --- source: crates/cli/tests/run_node_test.rs -assertion_line: 192 +assertion_line: 194 expression: "get_path_safe_output(&assert, fixture.path())" --- ▪▪▪▪ npm install ▪▪▪▪ node:binExecArgs [ '--title', 'node:binExecArgs', '--preserve-symlinks' ] -▪▪▪▪ node:binExecArgs (100ms, 6a8b6e98) +▪▪▪▪ node:binExecArgs (100ms) Tasks: 1 completed Time: 100ms diff --git a/crates/cli/tests/snapshots/run_node_test__runs_cjs_files.snap b/crates/cli/tests/snapshots/run_node_test__runs_cjs_files.snap index 14359f47d4a..59a0b2b18b1 100644 --- a/crates/cli/tests/snapshots/run_node_test__runs_cjs_files.snap +++ b/crates/cli/tests/snapshots/run_node_test__runs_cjs_files.snap @@ -6,7 +6,7 @@ expression: get_assert_output(&assert) ▪▪▪▪ npm install ▪▪▪▪ node:cjs stdout -▪▪▪▪ node:cjs (100ms, d4865cf0) +▪▪▪▪ node:cjs (100ms) Tasks: 1 completed Time: 100ms diff --git a/crates/cli/tests/snapshots/run_node_test__runs_from_project_root.snap b/crates/cli/tests/snapshots/run_node_test__runs_from_project_root.snap index 8c802a2ade8..0bb53d4ba92 100644 --- a/crates/cli/tests/snapshots/run_node_test__runs_from_project_root.snap +++ b/crates/cli/tests/snapshots/run_node_test__runs_from_project_root.snap @@ -6,7 +6,7 @@ expression: "get_path_safe_output(&assert, fixture.path())" ▪▪▪▪ npm install ▪▪▪▪ node:runFromProject /base -▪▪▪▪ node:runFromProject (100ms, 2494e06c) +▪▪▪▪ node:runFromProject (100ms) Tasks: 1 completed Time: 100ms diff --git a/crates/cli/tests/snapshots/run_node_test__runs_from_workspace_root.snap b/crates/cli/tests/snapshots/run_node_test__runs_from_workspace_root.snap index 1b24dd98865..5882c41c6fd 100644 --- a/crates/cli/tests/snapshots/run_node_test__runs_from_workspace_root.snap +++ b/crates/cli/tests/snapshots/run_node_test__runs_from_workspace_root.snap @@ -6,7 +6,7 @@ expression: "get_path_safe_output(&assert, fixture.path())" ▪▪▪▪ npm install ▪▪▪▪ node:runFromWorkspace -▪▪▪▪ node:runFromWorkspace (100ms, d474c784) +▪▪▪▪ node:runFromWorkspace (100ms) Tasks: 1 completed Time: 100ms diff --git a/crates/cli/tests/snapshots/run_node_test__runs_mjs_files.snap b/crates/cli/tests/snapshots/run_node_test__runs_mjs_files.snap index 84cba2119b8..84ddbb88baf 100644 --- a/crates/cli/tests/snapshots/run_node_test__runs_mjs_files.snap +++ b/crates/cli/tests/snapshots/run_node_test__runs_mjs_files.snap @@ -6,7 +6,7 @@ expression: get_assert_output(&assert) ▪▪▪▪ npm install ▪▪▪▪ node:mjs stdout -▪▪▪▪ node:mjs (100ms, 6c4b3619) +▪▪▪▪ node:mjs (100ms) Tasks: 1 completed Time: 100ms diff --git a/crates/cli/tests/snapshots/run_node_test__runs_package_managers.snap b/crates/cli/tests/snapshots/run_node_test__runs_package_managers.snap index 4d3fd27a79a..85cb67a0691 100644 --- a/crates/cli/tests/snapshots/run_node_test__runs_package_managers.snap +++ b/crates/cli/tests/snapshots/run_node_test__runs_package_managers.snap @@ -6,7 +6,7 @@ expression: get_assert_output(&assert) ▪▪▪▪ npm install ▪▪▪▪ node:npm 8.19.2 -▪▪▪▪ node:npm (100ms, b4fe9744) +▪▪▪▪ node:npm (100ms) Tasks: 1 completed Time: 100ms diff --git a/crates/cli/tests/snapshots/run_node_test__runs_standard_script.snap b/crates/cli/tests/snapshots/run_node_test__runs_standard_script.snap index c63f9cd693e..20fb2c19282 100644 --- a/crates/cli/tests/snapshots/run_node_test__runs_standard_script.snap +++ b/crates/cli/tests/snapshots/run_node_test__runs_standard_script.snap @@ -6,7 +6,7 @@ expression: get_assert_output(&assert) ▪▪▪▪ npm install ▪▪▪▪ node:standard stdout -▪▪▪▪ node:standard (100ms, 97fe34a8) +▪▪▪▪ node:standard (100ms) Tasks: 1 completed Time: 100ms diff --git a/crates/cli/tests/snapshots/run_node_test__sets_env_vars.snap b/crates/cli/tests/snapshots/run_node_test__sets_env_vars.snap index 9e200d2d9fc..100b40d7ebf 100644 --- a/crates/cli/tests/snapshots/run_node_test__sets_env_vars.snap +++ b/crates/cli/tests/snapshots/run_node_test__sets_env_vars.snap @@ -8,7 +8,7 @@ expression: get_assert_output(&assert) MOON_FOO=abc MOON_BAR=123 MOON_BAZ=true -▪▪▪▪ node:envVars (100ms, 0e07df64) +▪▪▪▪ node:envVars (100ms) Tasks: 1 completed Time: 100ms diff --git a/crates/cli/tests/snapshots/run_node_test__supports_top_level_await.snap b/crates/cli/tests/snapshots/run_node_test__supports_top_level_await.snap index d4df52c8de6..0d888b4552c 100644 --- a/crates/cli/tests/snapshots/run_node_test__supports_top_level_await.snap +++ b/crates/cli/tests/snapshots/run_node_test__supports_top_level_await.snap @@ -8,7 +8,7 @@ expression: get_assert_output(&assert) before awaiting after -▪▪▪▪ node:topLevelAwait (100ms, 3162f273) +▪▪▪▪ node:topLevelAwait (100ms) Tasks: 1 completed Time: 100ms diff --git a/crates/cli/tests/snapshots/run_node_test__sync_depends_on__format_file.snap b/crates/cli/tests/snapshots/run_node_test__sync_depends_on__format_file.snap index ebeccf32fe0..8270e0d8ca1 100644 --- a/crates/cli/tests/snapshots/run_node_test__sync_depends_on__format_file.snap +++ b/crates/cli/tests/snapshots/run_node_test__sync_depends_on__format_file.snap @@ -1,6 +1,6 @@ --- source: crates/cli/tests/run_node_test.rs -assertion_line: 488 +assertion_line: 492 expression: "read_to_string(fixture.path().join(\"depends-on/package.json\")).unwrap()" --- { diff --git a/crates/cli/tests/snapshots/run_node_test__sync_depends_on__format_link.snap b/crates/cli/tests/snapshots/run_node_test__sync_depends_on__format_link.snap index 34b8cd0062e..89729866ff4 100644 --- a/crates/cli/tests/snapshots/run_node_test__sync_depends_on__format_link.snap +++ b/crates/cli/tests/snapshots/run_node_test__sync_depends_on__format_link.snap @@ -1,6 +1,6 @@ --- source: crates/cli/tests/run_node_test.rs -assertion_line: 488 +assertion_line: 492 expression: "read_to_string(fixture.path().join(\"depends-on/package.json\")).unwrap()" --- { diff --git a/crates/cli/tests/snapshots/run_node_test__sync_depends_on__format_star.snap b/crates/cli/tests/snapshots/run_node_test__sync_depends_on__format_star.snap index e932b3b6a23..8bd183b0b64 100644 --- a/crates/cli/tests/snapshots/run_node_test__sync_depends_on__format_star.snap +++ b/crates/cli/tests/snapshots/run_node_test__sync_depends_on__format_star.snap @@ -1,6 +1,6 @@ --- source: crates/cli/tests/run_node_test.rs -assertion_line: 488 +assertion_line: 492 expression: "read_to_string(fixture.path().join(\"depends-on/package.json\")).unwrap()" --- { diff --git a/crates/cli/tests/snapshots/run_node_test__sync_depends_on__format_version-caret.snap b/crates/cli/tests/snapshots/run_node_test__sync_depends_on__format_version-caret.snap index 24b238cbc20..a1287cb415c 100644 --- a/crates/cli/tests/snapshots/run_node_test__sync_depends_on__format_version-caret.snap +++ b/crates/cli/tests/snapshots/run_node_test__sync_depends_on__format_version-caret.snap @@ -1,6 +1,6 @@ --- source: crates/cli/tests/run_node_test.rs -assertion_line: 488 +assertion_line: 492 expression: "read_to_string(fixture.path().join(\"depends-on/package.json\")).unwrap()" --- { diff --git a/crates/cli/tests/snapshots/run_node_test__sync_depends_on__format_version-tilde.snap b/crates/cli/tests/snapshots/run_node_test__sync_depends_on__format_version-tilde.snap index 0d3f87b936c..52ae34c52c4 100644 --- a/crates/cli/tests/snapshots/run_node_test__sync_depends_on__format_version-tilde.snap +++ b/crates/cli/tests/snapshots/run_node_test__sync_depends_on__format_version-tilde.snap @@ -1,6 +1,6 @@ --- source: crates/cli/tests/run_node_test.rs -assertion_line: 488 +assertion_line: 492 expression: "read_to_string(fixture.path().join(\"depends-on/package.json\")).unwrap()" --- { diff --git a/crates/cli/tests/snapshots/run_node_test__sync_depends_on__format_version.snap b/crates/cli/tests/snapshots/run_node_test__sync_depends_on__format_version.snap index d3e56a26094..b8581fec32f 100644 --- a/crates/cli/tests/snapshots/run_node_test__sync_depends_on__format_version.snap +++ b/crates/cli/tests/snapshots/run_node_test__sync_depends_on__format_version.snap @@ -1,6 +1,6 @@ --- source: crates/cli/tests/run_node_test.rs -assertion_line: 488 +assertion_line: 492 expression: "read_to_string(fixture.path().join(\"depends-on/package.json\")).unwrap()" --- { diff --git a/crates/cli/tests/snapshots/run_node_test__sync_depends_on__format_workspace-caret.snap b/crates/cli/tests/snapshots/run_node_test__sync_depends_on__format_workspace-caret.snap index 89036d17e77..7a3cf0f788d 100644 --- a/crates/cli/tests/snapshots/run_node_test__sync_depends_on__format_workspace-caret.snap +++ b/crates/cli/tests/snapshots/run_node_test__sync_depends_on__format_workspace-caret.snap @@ -1,6 +1,6 @@ --- source: crates/cli/tests/run_node_test.rs -assertion_line: 488 +assertion_line: 492 expression: "read_to_string(fixture.path().join(\"depends-on/package.json\")).unwrap()" --- { diff --git a/crates/cli/tests/snapshots/run_node_test__sync_depends_on__format_workspace-tilde.snap b/crates/cli/tests/snapshots/run_node_test__sync_depends_on__format_workspace-tilde.snap index 1400705a7cd..8cbe98fd7d4 100644 --- a/crates/cli/tests/snapshots/run_node_test__sync_depends_on__format_workspace-tilde.snap +++ b/crates/cli/tests/snapshots/run_node_test__sync_depends_on__format_workspace-tilde.snap @@ -1,6 +1,6 @@ --- source: crates/cli/tests/run_node_test.rs -assertion_line: 488 +assertion_line: 492 expression: "read_to_string(fixture.path().join(\"depends-on/package.json\")).unwrap()" --- { diff --git a/crates/cli/tests/snapshots/run_node_test__sync_depends_on__format_workspace.snap b/crates/cli/tests/snapshots/run_node_test__sync_depends_on__format_workspace.snap index 2afcdc05e0a..444ee94295b 100644 --- a/crates/cli/tests/snapshots/run_node_test__sync_depends_on__format_workspace.snap +++ b/crates/cli/tests/snapshots/run_node_test__sync_depends_on__format_workspace.snap @@ -1,6 +1,6 @@ --- source: crates/cli/tests/run_node_test.rs -assertion_line: 488 +assertion_line: 492 expression: "read_to_string(fixture.path().join(\"depends-on/package.json\")).unwrap()" --- { diff --git a/crates/cli/tests/snapshots/run_system_test__system_windows__caching__uses_cache_on_subsequent_runs-2.snap b/crates/cli/tests/snapshots/run_system_test__system_windows__caching__uses_cache_on_subsequent_runs-2.snap index 619c335be62..a4a0ff0924f 100644 --- a/crates/cli/tests/snapshots/run_system_test__system_windows__caching__uses_cache_on_subsequent_runs-2.snap +++ b/crates/cli/tests/snapshots/run_system_test__system_windows__caching__uses_cache_on_subsequent_runs-2.snap @@ -3,7 +3,7 @@ source: crates/cli/tests/run_system_test.rs expression: get_assert_output(&assert) --- ▪▪▪▪ windows:outputs -▪▪▪▪ windows:outputs (100ms, eaa75056) +▪▪▪▪ windows:outputs (100ms) Tasks: 1 completed Time: 100ms diff --git a/crates/cli/tests/snapshots/run_system_test__system_windows__caching__uses_cache_on_subsequent_runs.snap b/crates/cli/tests/snapshots/run_system_test__system_windows__caching__uses_cache_on_subsequent_runs.snap index baa5ea8fe77..a4a0ff0924f 100644 --- a/crates/cli/tests/snapshots/run_system_test__system_windows__caching__uses_cache_on_subsequent_runs.snap +++ b/crates/cli/tests/snapshots/run_system_test__system_windows__caching__uses_cache_on_subsequent_runs.snap @@ -3,7 +3,7 @@ source: crates/cli/tests/run_system_test.rs expression: get_assert_output(&assert) --- ▪▪▪▪ windows:outputs -▪▪▪▪ windows:outputs (100ms, 1cfe7c3f) +▪▪▪▪ windows:outputs (100ms) Tasks: 1 completed Time: 100ms diff --git a/crates/cli/tests/snapshots/run_system_test__system_windows__handles_process_exit_nonzero.snap b/crates/cli/tests/snapshots/run_system_test__system_windows__handles_process_exit_nonzero.snap index c0d70f2c1ae..b4cbd8d0fd9 100644 --- a/crates/cli/tests/snapshots/run_system_test__system_windows__handles_process_exit_nonzero.snap +++ b/crates/cli/tests/snapshots/run_system_test__system_windows__handles_process_exit_nonzero.snap @@ -4,7 +4,7 @@ expression: get_assert_output(&assert) --- ▪▪▪▪ windows:exitNonZero stdout -▪▪▪▪ windows:exitNonZero (100ms, e899844e) +▪▪▪▪ windows:exitNonZero (100ms) stderr ERROR Process cmd.exe failed with a 1 exit code. diff --git a/crates/cli/tests/snapshots/run_system_test__system_windows__handles_process_exit_zero.snap b/crates/cli/tests/snapshots/run_system_test__system_windows__handles_process_exit_zero.snap index 11835f8effd..94b88b9ca96 100644 --- a/crates/cli/tests/snapshots/run_system_test__system_windows__handles_process_exit_zero.snap +++ b/crates/cli/tests/snapshots/run_system_test__system_windows__handles_process_exit_zero.snap @@ -4,11 +4,11 @@ expression: get_assert_output(&assert) --- ▪▪▪▪ windows:exitZero stdout -▪▪▪▪ windows:exitZero (100ms, f7be3f01) +▪▪▪▪ windows:exitZero (100ms) Tasks: 1 completed Time: 100ms -stderr +stderr diff --git a/crates/cli/tests/snapshots/run_system_test__system_windows__inherits_moon_env_vars.snap b/crates/cli/tests/snapshots/run_system_test__system_windows__inherits_moon_env_vars.snap index 69ecd23d9e2..81aa5457bfa 100644 --- a/crates/cli/tests/snapshots/run_system_test__system_windows__inherits_moon_env_vars.snap +++ b/crates/cli/tests/snapshots/run_system_test__system_windows__inherits_moon_env_vars.snap @@ -5,7 +5,7 @@ expression: "get_path_safe_output(&assert, fixture.path())" ▪▪▪▪ windows:envVarsMoon MOON_TARGET=windows:envVarsMoon MOON_PROJECT_ID=windows -▪▪▪▪ windows:envVarsMoon (100ms, 6a0e36a6) +▪▪▪▪ windows:envVarsMoon (100ms) Tasks: 1 completed Time: 100ms diff --git a/crates/cli/tests/snapshots/run_system_test__system_windows__passes_args_through.snap b/crates/cli/tests/snapshots/run_system_test__system_windows__passes_args_through.snap index 70a658faa44..ba9e2761bf6 100644 --- a/crates/cli/tests/snapshots/run_system_test__system_windows__passes_args_through.snap +++ b/crates/cli/tests/snapshots/run_system_test__system_windows__passes_args_through.snap @@ -4,7 +4,7 @@ expression: get_assert_output(&assert) --- ▪▪▪▪ windows:passthroughArgs -aBc --opt value --optCamel=value foo "'bar baz'" --opt-kebab 123 -▪▪▪▪ windows:passthroughArgs (100ms, 18656fd3) +▪▪▪▪ windows:passthroughArgs (100ms) Tasks: 1 completed Time: 100ms diff --git a/crates/cli/tests/snapshots/run_system_test__system_windows__retries_on_failure_till_count.snap b/crates/cli/tests/snapshots/run_system_test__system_windows__retries_on_failure_till_count.snap index 14d7f80baf5..ade944724eb 100644 --- a/crates/cli/tests/snapshots/run_system_test__system_windows__retries_on_failure_till_count.snap +++ b/crates/cli/tests/snapshots/run_system_test__system_windows__retries_on_failure_till_count.snap @@ -4,16 +4,16 @@ expression: get_assert_output(&assert) --- ▪▪▪▪ windows:retryCount stdout -▪▪▪▪ windows:retryCount (100ms, e899844e) +▪▪▪▪ windows:retryCount (100ms) ▪▪▪▪ windows:retryCount (2/4) stdout -▪▪▪▪ windows:retryCount (2/4, 100ms, e899844e) +▪▪▪▪ windows:retryCount (2/4, 100ms) ▪▪▪▪ windows:retryCount (3/4) stdout -▪▪▪▪ windows:retryCount (3/4, 100ms, e899844e) +▪▪▪▪ windows:retryCount (3/4, 100ms) ▪▪▪▪ windows:retryCount (4/4) stdout -▪▪▪▪ windows:retryCount (4/4, 100ms, e899844e) +▪▪▪▪ windows:retryCount (4/4, 100ms) stderr stderr stderr diff --git a/crates/cli/tests/snapshots/run_system_test__system_windows__runs_bat_script.snap b/crates/cli/tests/snapshots/run_system_test__system_windows__runs_bat_script.snap index f15c606f46c..3289823250b 100644 --- a/crates/cli/tests/snapshots/run_system_test__system_windows__runs_bat_script.snap +++ b/crates/cli/tests/snapshots/run_system_test__system_windows__runs_bat_script.snap @@ -4,11 +4,11 @@ expression: "get_path_safe_output(&assert, fixture.path())" --- ▪▪▪▪ windows:bat stdout -▪▪▪▪ windows:bat (100ms, 7fdc9d49) +▪▪▪▪ windows:bat (100ms) Tasks: 1 completed Time: 100ms -stderr +stderr diff --git a/crates/cli/tests/snapshots/run_system_test__system_windows__runs_from_project_root.snap b/crates/cli/tests/snapshots/run_system_test__system_windows__runs_from_project_root.snap index 4d07c7bc9f5..fe7879a259b 100644 --- a/crates/cli/tests/snapshots/run_system_test__system_windows__runs_from_project_root.snap +++ b/crates/cli/tests/snapshots/run_system_test__system_windows__runs_from_project_root.snap @@ -4,7 +4,7 @@ expression: "get_path_safe_output(&assert, fixture.path())" --- ▪▪▪▪ windows:runFromProject \windows -▪▪▪▪ windows:runFromProject (100ms, 555c7a85) +▪▪▪▪ windows:runFromProject (100ms) Tasks: 1 completed Time: 100ms diff --git a/crates/cli/tests/snapshots/run_system_test__system_windows__runs_from_workspace_root.snap b/crates/cli/tests/snapshots/run_system_test__system_windows__runs_from_workspace_root.snap index 33af84e3bbe..da22a84035a 100644 --- a/crates/cli/tests/snapshots/run_system_test__system_windows__runs_from_workspace_root.snap +++ b/crates/cli/tests/snapshots/run_system_test__system_windows__runs_from_workspace_root.snap @@ -4,7 +4,7 @@ expression: "get_path_safe_output(&assert, fixture.path())" --- ▪▪▪▪ windows:runFromWorkspace -▪▪▪▪ windows:runFromWorkspace (100ms, 9a13c784) +▪▪▪▪ windows:runFromWorkspace (100ms) Tasks: 1 completed Time: 100ms diff --git a/crates/cli/tests/snapshots/run_system_test__system_windows__sets_env_vars.snap b/crates/cli/tests/snapshots/run_system_test__system_windows__sets_env_vars.snap index 0315b3e61a0..bcbf9d92490 100644 --- a/crates/cli/tests/snapshots/run_system_test__system_windows__sets_env_vars.snap +++ b/crates/cli/tests/snapshots/run_system_test__system_windows__sets_env_vars.snap @@ -6,7 +6,7 @@ expression: get_assert_output(&assert) MOON_FOO=abc MOON_BAR=123 MOON_BAZ=true -▪▪▪▪ windows:envVars (100ms, ec1222fb) +▪▪▪▪ windows:envVars (100ms) Tasks: 1 completed Time: 100ms diff --git a/crates/cli/tests/snapshots/run_system_test__unix__caching__uses_cache_on_subsequent_runs-2.snap b/crates/cli/tests/snapshots/run_system_test__unix__caching__uses_cache_on_subsequent_runs-2.snap index 2fc5cdf8c1a..231abd5e8f4 100644 --- a/crates/cli/tests/snapshots/run_system_test__unix__caching__uses_cache_on_subsequent_runs-2.snap +++ b/crates/cli/tests/snapshots/run_system_test__unix__caching__uses_cache_on_subsequent_runs-2.snap @@ -4,7 +4,7 @@ assertion_line: 192 expression: get_assert_output(&assert) --- ▪▪▪▪ unix:outputs -▪▪▪▪ unix:outputs (100ms, ff5f84c4) +▪▪▪▪ unix:outputs (100ms) Tasks: 1 completed Time: 100ms diff --git a/crates/cli/tests/snapshots/run_system_test__unix__caching__uses_cache_on_subsequent_runs.snap b/crates/cli/tests/snapshots/run_system_test__unix__caching__uses_cache_on_subsequent_runs.snap index a6b0cad8b54..04820cd12f0 100644 --- a/crates/cli/tests/snapshots/run_system_test__unix__caching__uses_cache_on_subsequent_runs.snap +++ b/crates/cli/tests/snapshots/run_system_test__unix__caching__uses_cache_on_subsequent_runs.snap @@ -4,7 +4,7 @@ assertion_line: 185 expression: get_assert_output(&assert) --- ▪▪▪▪ unix:outputs -▪▪▪▪ unix:outputs (100ms, 5800dc32) +▪▪▪▪ unix:outputs (100ms) Tasks: 1 completed Time: 100ms diff --git a/crates/cli/tests/snapshots/run_system_test__unix__handles_echo.snap b/crates/cli/tests/snapshots/run_system_test__unix__handles_echo.snap index a04fc247dcc..152e70671fd 100644 --- a/crates/cli/tests/snapshots/run_system_test__unix__handles_echo.snap +++ b/crates/cli/tests/snapshots/run_system_test__unix__handles_echo.snap @@ -5,7 +5,7 @@ expression: get_assert_output(&assert) --- ▪▪▪▪ unix:echo hello -▪▪▪▪ unix:echo (100ms, 36613733) +▪▪▪▪ unix:echo (100ms) Tasks: 1 completed Time: 100ms diff --git a/crates/cli/tests/snapshots/run_system_test__unix__handles_ls.snap b/crates/cli/tests/snapshots/run_system_test__unix__handles_ls.snap index 8e269e0b1f7..9f28060014a 100644 --- a/crates/cli/tests/snapshots/run_system_test__unix__handles_ls.snap +++ b/crates/cli/tests/snapshots/run_system_test__unix__handles_ls.snap @@ -13,7 +13,7 @@ exitZero.sh moon.yml outputs.sh standard.sh -▪▪▪▪ unix:ls (100ms, fcc56faf) +▪▪▪▪ unix:ls (100ms) Tasks: 1 completed Time: 100ms diff --git a/crates/cli/tests/snapshots/run_system_test__unix__handles_process_exit_nonzero.snap b/crates/cli/tests/snapshots/run_system_test__unix__handles_process_exit_nonzero.snap index 04e290fe925..8c560fa7cc3 100644 --- a/crates/cli/tests/snapshots/run_system_test__unix__handles_process_exit_nonzero.snap +++ b/crates/cli/tests/snapshots/run_system_test__unix__handles_process_exit_nonzero.snap @@ -5,7 +5,7 @@ expression: get_assert_output(&assert) --- ▪▪▪▪ unix:exitNonZero stdout -▪▪▪▪ unix:exitNonZero (100ms, 358363d9) +▪▪▪▪ unix:exitNonZero (100ms) stderr ERROR Process bash failed with a 1 exit code. diff --git a/crates/cli/tests/snapshots/run_system_test__unix__handles_process_exit_zero.snap b/crates/cli/tests/snapshots/run_system_test__unix__handles_process_exit_zero.snap index 43a8cb25a2e..a7f6b158351 100644 --- a/crates/cli/tests/snapshots/run_system_test__unix__handles_process_exit_zero.snap +++ b/crates/cli/tests/snapshots/run_system_test__unix__handles_process_exit_zero.snap @@ -5,7 +5,7 @@ expression: get_assert_output(&assert) --- ▪▪▪▪ unix:exitZero stdout -▪▪▪▪ unix:exitZero (100ms, e8623f25) +▪▪▪▪ unix:exitZero (100ms) Tasks: 1 completed Time: 100ms diff --git a/crates/cli/tests/snapshots/run_system_test__unix__inherits_moon_env_vars.snap b/crates/cli/tests/snapshots/run_system_test__unix__inherits_moon_env_vars.snap index 488a8ac9cf2..4c7bcf68335 100644 --- a/crates/cli/tests/snapshots/run_system_test__unix__inherits_moon_env_vars.snap +++ b/crates/cli/tests/snapshots/run_system_test__unix__inherits_moon_env_vars.snap @@ -15,7 +15,7 @@ MOON_TARGET=unix:envVarsMoon MOON_TOOLCHAIN_DIR=~/.moon MOON_WORKING_DIR= MOON_WORKSPACE_ROOT= -▪▪▪▪ unix:envVarsMoon (100ms, f8755824) +▪▪▪▪ unix:envVarsMoon (100ms) Tasks: 1 completed Time: 100ms diff --git a/crates/cli/tests/snapshots/run_system_test__unix__passes_args_through.snap b/crates/cli/tests/snapshots/run_system_test__unix__passes_args_through.snap index 2ed59e7e30a..57126f60b61 100644 --- a/crates/cli/tests/snapshots/run_system_test__unix__passes_args_through.snap +++ b/crates/cli/tests/snapshots/run_system_test__unix__passes_args_through.snap @@ -5,7 +5,7 @@ expression: get_assert_output(&assert) --- ▪▪▪▪ unix:passthroughArgs Args: -aBc --opt value --optCamel=value foo 'bar baz' --opt-kebab 123 -▪▪▪▪ unix:passthroughArgs (100ms, eddf58f9) +▪▪▪▪ unix:passthroughArgs (100ms) Tasks: 1 completed Time: 100ms diff --git a/crates/cli/tests/snapshots/run_system_test__unix__retries_on_failure_till_count.snap b/crates/cli/tests/snapshots/run_system_test__unix__retries_on_failure_till_count.snap index aaa560ce19d..73b28c3faf5 100644 --- a/crates/cli/tests/snapshots/run_system_test__unix__retries_on_failure_till_count.snap +++ b/crates/cli/tests/snapshots/run_system_test__unix__retries_on_failure_till_count.snap @@ -5,16 +5,16 @@ expression: get_assert_output(&assert) --- ▪▪▪▪ unix:retryCount stdout -▪▪▪▪ unix:retryCount (100ms, 358363d9) +▪▪▪▪ unix:retryCount (100ms) ▪▪▪▪ unix:retryCount (2/4) stdout -▪▪▪▪ unix:retryCount (2/4, 100ms, 358363d9) +▪▪▪▪ unix:retryCount (2/4, 100ms) ▪▪▪▪ unix:retryCount (3/4) stdout -▪▪▪▪ unix:retryCount (3/4, 100ms, 358363d9) +▪▪▪▪ unix:retryCount (3/4, 100ms) ▪▪▪▪ unix:retryCount (4/4) stdout -▪▪▪▪ unix:retryCount (4/4, 100ms, 358363d9) +▪▪▪▪ unix:retryCount (4/4, 100ms) stderr stderr stderr diff --git a/crates/cli/tests/snapshots/run_system_test__unix__runs_bash_script.snap b/crates/cli/tests/snapshots/run_system_test__unix__runs_bash_script.snap index f2f6a41b26f..1f51cfbc367 100644 --- a/crates/cli/tests/snapshots/run_system_test__unix__runs_bash_script.snap +++ b/crates/cli/tests/snapshots/run_system_test__unix__runs_bash_script.snap @@ -5,7 +5,7 @@ expression: get_assert_output(&assert) --- ▪▪▪▪ unix:bash stdout -▪▪▪▪ unix:bash (100ms, dbbe50f6) +▪▪▪▪ unix:bash (100ms) Tasks: 1 completed Time: 100ms diff --git a/crates/cli/tests/snapshots/run_system_test__unix__runs_from_project_root.snap b/crates/cli/tests/snapshots/run_system_test__unix__runs_from_project_root.snap index a995b62210e..76ad2603675 100644 --- a/crates/cli/tests/snapshots/run_system_test__unix__runs_from_project_root.snap +++ b/crates/cli/tests/snapshots/run_system_test__unix__runs_from_project_root.snap @@ -5,7 +5,7 @@ expression: "get_path_safe_output(&assert, fixture.path())" --- ▪▪▪▪ unix:runFromProject /unix -▪▪▪▪ unix:runFromProject (100ms, a541e2ee) +▪▪▪▪ unix:runFromProject (100ms) Tasks: 1 completed Time: 100ms diff --git a/crates/cli/tests/snapshots/run_system_test__unix__runs_from_workspace_root.snap b/crates/cli/tests/snapshots/run_system_test__unix__runs_from_workspace_root.snap index 391eaca7dc7..bc9cce6d314 100644 --- a/crates/cli/tests/snapshots/run_system_test__unix__runs_from_workspace_root.snap +++ b/crates/cli/tests/snapshots/run_system_test__unix__runs_from_workspace_root.snap @@ -5,7 +5,7 @@ expression: "get_path_safe_output(&assert, fixture.path())" --- ▪▪▪▪ unix:runFromWorkspace -▪▪▪▪ unix:runFromWorkspace (100ms, 4a89312a) +▪▪▪▪ unix:runFromWorkspace (100ms) Tasks: 1 completed Time: 100ms diff --git a/crates/cli/tests/snapshots/run_system_test__unix__sets_env_vars.snap b/crates/cli/tests/snapshots/run_system_test__unix__sets_env_vars.snap index 91760c08917..cdf3f1b65fd 100644 --- a/crates/cli/tests/snapshots/run_system_test__unix__sets_env_vars.snap +++ b/crates/cli/tests/snapshots/run_system_test__unix__sets_env_vars.snap @@ -7,7 +7,7 @@ expression: get_assert_output(&assert) MOON_FOO=abc MOON_BAR=123 MOON_BAZ=true -▪▪▪▪ unix:envVars (100ms, 85a0de57) +▪▪▪▪ unix:envVars (100ms) Tasks: 1 completed Time: 100ms diff --git a/crates/cli/tests/snapshots/run_test__general__logs_command_for_project_root.snap b/crates/cli/tests/snapshots/run_test__general__logs_command_for_project_root.snap index d21aa08aa61..522c574fdcf 100644 --- a/crates/cli/tests/snapshots/run_test__general__logs_command_for_project_root.snap +++ b/crates/cli/tests/snapshots/run_test__general__logs_command_for_project_root.snap @@ -6,7 +6,7 @@ expression: get_assert_output(&assert) ▪▪▪▪ base:runFromProject echo 'from project' (in ./base) from project -▪▪▪▪ base:runFromProject (100ms, e04dffaf) +▪▪▪▪ base:runFromProject (100ms) Tasks: 1 completed Time: 100ms diff --git a/crates/cli/tests/snapshots/run_test__general__logs_command_for_workspace_root.snap b/crates/cli/tests/snapshots/run_test__general__logs_command_for_workspace_root.snap index 9c0d4d9fc5a..4782b06c6af 100644 --- a/crates/cli/tests/snapshots/run_test__general__logs_command_for_workspace_root.snap +++ b/crates/cli/tests/snapshots/run_test__general__logs_command_for_workspace_root.snap @@ -6,7 +6,7 @@ expression: get_assert_output(&assert) ▪▪▪▪ base:runFromWorkspace echo 'from workspace' (in workspace) from workspace -▪▪▪▪ base:runFromWorkspace (100ms, 33ec20af) +▪▪▪▪ base:runFromWorkspace (100ms) Tasks: 1 completed Time: 100ms diff --git a/crates/cli/tests/snapshots/run_test__noop__runs_noop_deps.snap b/crates/cli/tests/snapshots/run_test__noop__runs_noop_deps.snap index 5cb08fcff8e..b6cb1d9b5f7 100644 --- a/crates/cli/tests/snapshots/run_test__noop__runs_noop_deps.snap +++ b/crates/cli/tests/snapshots/run_test__noop__runs_noop_deps.snap @@ -5,7 +5,7 @@ expression: get_assert_output(&assert) --- ▪▪▪▪ npm install ▪▪▪▪ outputs:generateFile -▪▪▪▪ outputs:generateFile (100ms, 49164410) +▪▪▪▪ outputs:generateFile (100ms) ▪▪▪▪ noop:noopWithDeps (no op) Tasks: 2 completed diff --git a/crates/cli/tests/snapshots/run_test__output_styles__buffer.snap b/crates/cli/tests/snapshots/run_test__output_styles__buffer.snap index 50394d7d1bb..1c3a648b735 100644 --- a/crates/cli/tests/snapshots/run_test__output_styles__buffer.snap +++ b/crates/cli/tests/snapshots/run_test__output_styles__buffer.snap @@ -5,7 +5,7 @@ expression: get_assert_output(&assert) --- ▪▪▪▪ npm install ▪▪▪▪ outputStyles:buffer -▪▪▪▪ outputStyles:buffer (100ms, ea259d36) +▪▪▪▪ outputStyles:buffer (100ms) stdout ▪▪▪▪ outputStyles:bufferPrimary (no op) diff --git a/crates/cli/tests/snapshots/run_test__output_styles__buffer_on_failure_when_failure.snap b/crates/cli/tests/snapshots/run_test__output_styles__buffer_on_failure_when_failure.snap index 0f3f0c8da92..7cc6f8c2f1e 100644 --- a/crates/cli/tests/snapshots/run_test__output_styles__buffer_on_failure_when_failure.snap +++ b/crates/cli/tests/snapshots/run_test__output_styles__buffer_on_failure_when_failure.snap @@ -5,7 +5,7 @@ expression: get_assert_output(&assert) --- ▪▪▪▪ npm install ▪▪▪▪ outputStyles:bufferFailureFail -▪▪▪▪ outputStyles:bufferFailureFail (100ms, fbc4c2e9) +▪▪▪▪ outputStyles:bufferFailureFail (100ms) stdout stderr diff --git a/crates/cli/tests/snapshots/run_test__output_styles__buffer_on_failure_when_success.snap b/crates/cli/tests/snapshots/run_test__output_styles__buffer_on_failure_when_success.snap index 5fd7bfefe0a..d9caf3ce558 100644 --- a/crates/cli/tests/snapshots/run_test__output_styles__buffer_on_failure_when_success.snap +++ b/crates/cli/tests/snapshots/run_test__output_styles__buffer_on_failure_when_success.snap @@ -5,7 +5,7 @@ expression: get_assert_output(&assert) --- ▪▪▪▪ npm install ▪▪▪▪ outputStyles:bufferFailurePass -▪▪▪▪ outputStyles:bufferFailurePass (100ms, ea259d36) +▪▪▪▪ outputStyles:bufferFailurePass (100ms) ▪▪▪▪ outputStyles:bufferFailurePassPrimary (no op) Tasks: 2 completed diff --git a/crates/cli/tests/snapshots/run_test__output_styles__hash.snap b/crates/cli/tests/snapshots/run_test__output_styles__hash.snap index 1ed1c30e395..eff786eb515 100644 --- a/crates/cli/tests/snapshots/run_test__output_styles__hash.snap +++ b/crates/cli/tests/snapshots/run_test__output_styles__hash.snap @@ -5,12 +5,12 @@ expression: get_assert_output(&assert) --- ▪▪▪▪ npm install ▪▪▪▪ outputStyles:hash -▪▪▪▪ outputStyles:hash (100ms, ea259d36) +▪▪▪▪ outputStyles:hash (100ms) ▪▪▪▪ outputStyles:hashPrimary (no op) Tasks: 2 completed Time: 100ms -ea259d36e4ab55052451e4edda89ac493320c33f639cdc4b9e612e8f61e38ed0 +2d21e4bd3ec7c137de9e76e16d797237bfe5c75e08d49f2d2ae6c310f77aa412 diff --git a/crates/cli/tests/snapshots/run_test__output_styles__none.snap b/crates/cli/tests/snapshots/run_test__output_styles__none.snap index c8187b07345..dcd473995e3 100644 --- a/crates/cli/tests/snapshots/run_test__output_styles__none.snap +++ b/crates/cli/tests/snapshots/run_test__output_styles__none.snap @@ -5,7 +5,7 @@ expression: get_assert_output(&assert) --- ▪▪▪▪ npm install ▪▪▪▪ outputStyles:none -▪▪▪▪ outputStyles:none (100ms, ea259d36) +▪▪▪▪ outputStyles:none (100ms) ▪▪▪▪ outputStyles:nonePrimary (no op) Tasks: 2 completed diff --git a/crates/cli/tests/snapshots/run_test__output_styles__stream.snap b/crates/cli/tests/snapshots/run_test__output_styles__stream.snap index 73f191e7631..414b77cfee5 100644 --- a/crates/cli/tests/snapshots/run_test__output_styles__stream.snap +++ b/crates/cli/tests/snapshots/run_test__output_styles__stream.snap @@ -6,7 +6,7 @@ expression: get_assert_output(&assert) ▪▪▪▪ npm install ▪▪▪▪ outputStyles:stream outputStyles:stream | stdout -▪▪▪▪ outputStyles:stream (100ms, ea259d36) +▪▪▪▪ outputStyles:stream (100ms) ▪▪▪▪ outputStyles:streamPrimary (no op) Tasks: 2 completed diff --git a/crates/cli/tests/snapshots/run_test__outputs__hydration__reuses_cache_from_previous_run-2.snap b/crates/cli/tests/snapshots/run_test__outputs__hydration__reuses_cache_from_previous_run-2.snap index aa73127a384..76594b75aaf 100644 --- a/crates/cli/tests/snapshots/run_test__outputs__hydration__reuses_cache_from_previous_run-2.snap +++ b/crates/cli/tests/snapshots/run_test__outputs__hydration__reuses_cache_from_previous_run-2.snap @@ -3,7 +3,7 @@ source: crates/cli/tests/run_test.rs assertion_line: 572 expression: get_assert_output(&assert2) --- -▪▪▪▪ outputs:generateFileAndFolder (cached from previous run, 9dad3fc2) +▪▪▪▪ outputs:generateFileAndFolder (cached from previous run, d1594c00) Tasks: 1 completed (1 cached) Time: 100ms ❯❯❯❯ to the moon diff --git a/crates/cli/tests/snapshots/run_test__outputs__hydration__reuses_cache_from_previous_run.snap b/crates/cli/tests/snapshots/run_test__outputs__hydration__reuses_cache_from_previous_run.snap index 536a54a68f3..d9a506534c6 100644 --- a/crates/cli/tests/snapshots/run_test__outputs__hydration__reuses_cache_from_previous_run.snap +++ b/crates/cli/tests/snapshots/run_test__outputs__hydration__reuses_cache_from_previous_run.snap @@ -5,7 +5,7 @@ expression: get_assert_output(&assert1) --- ▪▪▪▪ npm install ▪▪▪▪ outputs:generateFileAndFolder -▪▪▪▪ outputs:generateFileAndFolder (100ms, 9dad3fc2) +▪▪▪▪ outputs:generateFileAndFolder (100ms) Tasks: 1 completed Time: 100ms diff --git a/crates/cli/tests/utils.rs b/crates/cli/tests/utils.rs index 01d9aa279cf..4bdbef23401 100644 --- a/crates/cli/tests/utils.rs +++ b/crates/cli/tests/utils.rs @@ -17,12 +17,22 @@ pub fn append_workspace_config(root: &Path, yaml: &str) { writeln!(file, "{}", yaml).unwrap(); } -pub fn update_workspace_config(dir: &Path, old: &str, new: &str) { - let mut config = fs::read_to_string(dir.join(".moon/workspace.yml")).unwrap(); +pub fn append_toolchain_config(root: &Path, yaml: &str) { + let mut file = OpenOptions::new() + .write(true) + .append(true) + .open(root.join(".moon/toolchain.yml")) + .unwrap(); + + writeln!(file, "{}", yaml).unwrap(); +} + +pub fn update_toolchain_config(dir: &Path, old: &str, new: &str) { + let mut config = fs::read_to_string(dir.join(".moon/toolchain.yml")).unwrap(); config = config.replace(old, new); - fs::write(dir.join(".moon/workspace.yml"), config).unwrap(); + fs::write(dir.join(".moon/toolchain.yml"), config).unwrap(); } pub fn get_path_safe_output(assert: &assert_cmd::assert::Assert, fixtures_dir: &Path) -> String { diff --git a/crates/core/config/src/lib.rs b/crates/core/config/src/lib.rs index 3c57fa71719..b64eb4b1dd9 100644 --- a/crates/core/config/src/lib.rs +++ b/crates/core/config/src/lib.rs @@ -2,6 +2,7 @@ mod errors; mod helpers; mod project; mod template; +mod toolchain; mod types; mod validators; mod workspace; @@ -11,6 +12,7 @@ pub use errors::{ }; pub use project::*; pub use template::*; +pub use toolchain::*; pub use types::*; pub use validator::ValidationErrors; pub use workspace::*; @@ -19,12 +21,16 @@ pub fn load_workspace_config_template() -> &'static str { include_str!("../templates/workspace.yml") } -pub fn load_workspace_node_config_template() -> &'static str { - include_str!("../templates/workspace_node.yml") +pub fn load_toolchain_config_template() -> &'static str { + include_str!("../templates/toolchain.yml") } -pub fn load_workspace_typescript_config_template() -> &'static str { - include_str!("../templates/workspace_typescript.yml") +pub fn load_toolchain_node_config_template() -> &'static str { + include_str!("../templates/toolchain_node.yml") +} + +pub fn load_toolchain_typescript_config_template() -> &'static str { + include_str!("../templates/toolchain_typescript.yml") } pub fn load_global_project_config_template() -> &'static str { diff --git a/crates/core/config/src/main.rs b/crates/core/config/src/main.rs index b549f8721c3..fdc3fa3a651 100644 --- a/crates/core/config/src/main.rs +++ b/crates/core/config/src/main.rs @@ -1,5 +1,6 @@ use moon_config::{ - GlobalProjectConfig, ProjectConfig, TemplateConfig, TemplateFrontmatterConfig, WorkspaceConfig, + GlobalProjectConfig, ProjectConfig, TemplateConfig, TemplateFrontmatterConfig, ToolchainConfig, + WorkspaceConfig, }; use schemars::schema_for; use std::fs; @@ -10,6 +11,7 @@ fn main() { let global_project_schema = schema_for!(GlobalProjectConfig); let template_schema = schema_for!(TemplateConfig); let template_frontmatter_schema = schema_for!(TemplateFrontmatterConfig); + let toolchain_schema = schema_for!(ToolchainConfig); let workspace_schema = schema_for!(WorkspaceConfig); fs::write( @@ -36,6 +38,12 @@ fn main() { ) .unwrap(); + fs::write( + "website/static/schemas/toolchain.json", + serde_json::to_string_pretty(&toolchain_schema).unwrap(), + ) + .unwrap(); + fs::write( "website/static/schemas/workspace.json", serde_json::to_string_pretty(&workspace_schema).unwrap(), diff --git a/crates/core/config/src/project/local_config.rs b/crates/core/config/src/project/local_config.rs index 0c5671316f6..fe4efd5bbe4 100644 --- a/crates/core/config/src/project/local_config.rs +++ b/crates/core/config/src/project/local_config.rs @@ -8,7 +8,7 @@ use crate::project::task::TaskConfig; use crate::project::workspace::ProjectWorkspaceConfig; use crate::types::{FileGroups, ProjectID}; use crate::validators::validate_id; -use crate::PlatformType; +use crate::{PlatformType, ProjectToolchainConfig}; use figment::{ providers::{Format, Serialized, YamlExtended}, Figment, @@ -149,6 +149,9 @@ pub struct ProjectConfig { #[validate] pub tasks: BTreeMap, + #[validate] + pub toolchain: ProjectToolchainConfig, + #[serde(rename = "type")] pub type_of: ProjectType, diff --git a/crates/core/config/src/project/mod.rs b/crates/core/config/src/project/mod.rs index 9f0b7b13cd6..1cddf55b625 100644 --- a/crates/core/config/src/project/mod.rs +++ b/crates/core/config/src/project/mod.rs @@ -3,6 +3,7 @@ mod global_config; mod local_config; mod task; mod task_options; +mod toolchain; mod workspace; pub use dep::*; @@ -10,4 +11,5 @@ pub use global_config::*; pub use local_config::*; pub use task::*; pub use task_options::*; +pub use toolchain::*; pub use workspace::*; diff --git a/crates/core/config/src/project/toolchain.rs b/crates/core/config/src/project/toolchain.rs new file mode 100644 index 00000000000..f532972cbc2 --- /dev/null +++ b/crates/core/config/src/project/toolchain.rs @@ -0,0 +1,37 @@ +// These configs are project-level settings that override those from the root! + +use crate::validators::validate_semver_version; +use schemars::JsonSchema; +use serde::{Deserialize, Serialize}; +use validator::{Validate, ValidationError}; + +fn validate_node_version(value: &str) -> Result<(), ValidationError> { + validate_semver_version("toolchain.node.version", value) +} + +#[derive(Clone, Debug, Default, Deserialize, Eq, JsonSchema, PartialEq, Serialize, Validate)] +#[schemars(default)] +#[serde(default)] +pub struct ProjectToolchainNodeConfig { + #[validate(custom = "validate_node_version")] + pub version: Option, +} + +#[derive(Clone, Debug, Deserialize, Eq, JsonSchema, PartialEq, Serialize, Validate)] +#[schemars(default)] +#[serde(default, rename_all = "camelCase")] +pub struct ProjectToolchainConfig { + #[validate] + pub node: Option, + + pub typescript: bool, +} + +impl Default for ProjectToolchainConfig { + fn default() -> Self { + ProjectToolchainConfig { + node: None, + typescript: true, + } + } +} diff --git a/crates/core/config/src/project/workspace.rs b/crates/core/config/src/project/workspace.rs index 196d2e702ff..1e82323cfb0 100644 --- a/crates/core/config/src/project/workspace.rs +++ b/crates/core/config/src/project/workspace.rs @@ -1,23 +1,10 @@ // These configs are project-level settings that override those from the workspace! use crate::types::TaskID; -use crate::validators::validate_semver_version; use rustc_hash::FxHashMap; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use validator::{Validate, ValidationError}; - -fn validate_node_version(value: &str) -> Result<(), ValidationError> { - validate_semver_version("workspace.node.version", value) -} - -#[derive(Clone, Debug, Default, Deserialize, Eq, JsonSchema, PartialEq, Serialize, Validate)] -#[schemars(default)] -#[serde(default)] -pub struct ProjectWorkspaceNodeConfig { - #[validate(custom = "validate_node_version")] - pub version: Option, -} +use validator::Validate; #[derive(Clone, Debug, Default, Deserialize, Eq, JsonSchema, PartialEq, Serialize, Validate)] #[schemars(default)] @@ -36,19 +23,12 @@ pub struct ProjectWorkspaceInheritedTasksConfig { pub struct ProjectWorkspaceConfig { #[validate] pub inherited_tasks: ProjectWorkspaceInheritedTasksConfig, - - #[validate] - pub node: Option, - - pub typescript: bool, } impl Default for ProjectWorkspaceConfig { fn default() -> Self { ProjectWorkspaceConfig { inherited_tasks: ProjectWorkspaceInheritedTasksConfig::default(), - node: None, - typescript: true, } } } diff --git a/crates/core/config/src/toolchain/config.rs b/crates/core/config/src/toolchain/config.rs new file mode 100644 index 00000000000..d15cb76ddd3 --- /dev/null +++ b/crates/core/config/src/toolchain/config.rs @@ -0,0 +1,88 @@ +// .moon/toolchain.yml + +use crate::errors::map_validation_errors_to_figment_errors; +use crate::helpers::gather_extended_sources; +use crate::toolchain::node::NodeConfig; +use crate::toolchain::typescript::TypeScriptConfig; +use crate::validators::validate_extends; +use crate::ConfigError; +use figment::{ + providers::{Format, Serialized, YamlExtended}, + Figment, +}; +use schemars::JsonSchema; +use serde::{Deserialize, Serialize}; +use std::env; +use std::path::PathBuf; +use validator::Validate; + +/// Docs: https://moonrepo.dev/docs/config/toolchain +#[derive(Clone, Debug, Default, Deserialize, Eq, JsonSchema, PartialEq, Serialize, Validate)] +#[schemars(default)] +#[serde(rename_all = "camelCase")] +pub struct ToolchainConfig { + #[validate(custom = "validate_extends")] + pub extends: Option, + + #[validate] + pub node: Option, + + #[validate] + pub typescript: Option, + + /// JSON schema URI. + #[serde(skip, rename = "$schema")] + pub schema: String, +} + +impl ToolchainConfig { + pub fn load(path: PathBuf) -> Result { + let profile_name = "toolchain"; + let mut figment = + Figment::from(Serialized::defaults(ToolchainConfig::default()).profile(profile_name)); + + for source in gather_extended_sources(&path)? { + figment = figment.merge(YamlExtended::file(source).profile(profile_name)); + } + + let mut config = ToolchainConfig::load_config(figment.select(profile_name))?; + config.extends = None; + + if let Some(node_config) = &mut config.node { + // Versions from env vars should take precedence + if let Ok(node_version) = env::var("MOON_NODE_VERSION") { + node_config.version = node_version; + } + + if let Ok(npm_version) = env::var("MOON_NPM_VERSION") { + node_config.npm.version = npm_version; + } + + if let Ok(pnpm_version) = env::var("MOON_PNPM_VERSION") { + if let Some(pnpm_config) = &mut node_config.pnpm { + pnpm_config.version = pnpm_version; + } + } + + if let Ok(yarn_version) = env::var("MOON_YARN_VERSION") { + if let Some(yarn_config) = &mut node_config.yarn { + yarn_config.version = yarn_version; + } + } + } + + Ok(config) + } + + fn load_config(figment: Figment) -> Result { + let config: ToolchainConfig = figment.extract()?; + + if let Err(errors) = config.validate() { + return Err(ConfigError::FailedValidation( + map_validation_errors_to_figment_errors(&figment, &errors), + )); + } + + Ok(config) + } +} diff --git a/crates/core/config/src/toolchain/mod.rs b/crates/core/config/src/toolchain/mod.rs new file mode 100644 index 00000000000..1ffa4ef7752 --- /dev/null +++ b/crates/core/config/src/toolchain/mod.rs @@ -0,0 +1,7 @@ +mod config; +mod node; +mod typescript; + +pub use config::*; +pub use node::*; +pub use typescript::*; diff --git a/crates/core/config/src/workspace/node.rs b/crates/core/config/src/toolchain/node.rs similarity index 99% rename from crates/core/config/src/workspace/node.rs rename to crates/core/config/src/toolchain/node.rs index 7e85fabe513..63a55acd51a 100644 --- a/crates/core/config/src/workspace/node.rs +++ b/crates/core/config/src/toolchain/node.rs @@ -10,7 +10,6 @@ pub fn default_node_version() -> String { } pub fn default_npm_version() -> String { - // Use the version bundled with node by default env::var("MOON_NPM_VERSION").unwrap_or_else(|_| NPM.default_version.to_string()) } diff --git a/crates/core/config/src/workspace/typescript.rs b/crates/core/config/src/toolchain/typescript.rs similarity index 100% rename from crates/core/config/src/workspace/typescript.rs rename to crates/core/config/src/toolchain/typescript.rs diff --git a/crates/core/config/src/workspace/config.rs b/crates/core/config/src/workspace/config.rs index 2071e3a2bfe..7d2bbe69a35 100644 --- a/crates/core/config/src/workspace/config.rs +++ b/crates/core/config/src/workspace/config.rs @@ -6,10 +6,8 @@ use crate::types::{FileGlob, FilePath}; use crate::validators::{validate_child_relative_path, validate_extends, validate_id}; use crate::workspace::generator::GeneratorConfig; use crate::workspace::hasher::HasherConfig; -use crate::workspace::node::NodeConfig; use crate::workspace::notifier::NotifierConfig; use crate::workspace::runner::RunnerConfig; -use crate::workspace::typescript::TypeScriptConfig; use crate::workspace::vcs::VcsConfig; use crate::ConfigError; use figment::{ @@ -19,7 +17,6 @@ use figment::{ use rustc_hash::FxHashMap; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; -use std::env; use std::path::PathBuf; use validator::{Validate, ValidationError}; @@ -83,9 +80,6 @@ pub struct WorkspaceConfig { #[validate] pub hasher: HasherConfig, - #[validate] - pub node: Option, - #[validate] pub notifier: NotifierConfig, @@ -95,9 +89,6 @@ pub struct WorkspaceConfig { #[validate] pub runner: RunnerConfig, - #[validate] - pub typescript: Option, - #[validate] pub vcs: VcsConfig, @@ -119,29 +110,6 @@ impl WorkspaceConfig { let mut config = WorkspaceConfig::load_config(figment.select(profile_name))?; config.extends = None; - if let Some(node_config) = &mut config.node { - // Versions from env vars should take precedence - if let Ok(node_version) = env::var("MOON_NODE_VERSION") { - node_config.version = node_version; - } - - if let Ok(npm_version) = env::var("MOON_NPM_VERSION") { - node_config.npm.version = npm_version; - } - - if let Ok(pnpm_version) = env::var("MOON_PNPM_VERSION") { - if let Some(pnpm_config) = &mut node_config.pnpm { - pnpm_config.version = pnpm_version; - } - } - - if let Ok(yarn_version) = env::var("MOON_YARN_VERSION") { - if let Some(yarn_config) = &mut node_config.yarn { - yarn_config.version = yarn_version; - } - } - } - Ok(config) } diff --git a/crates/core/config/src/workspace/mod.rs b/crates/core/config/src/workspace/mod.rs index ad2ac6b15ae..d55390aec79 100644 --- a/crates/core/config/src/workspace/mod.rs +++ b/crates/core/config/src/workspace/mod.rs @@ -1,17 +1,13 @@ mod config; mod generator; mod hasher; -mod node; mod notifier; mod runner; -mod typescript; mod vcs; pub use config::*; pub use generator::*; pub use hasher::*; -pub use node::*; pub use notifier::*; pub use runner::*; -pub use typescript::*; pub use vcs::*; diff --git a/crates/core/config/src/workspace/runner.rs b/crates/core/config/src/workspace/runner.rs index 4319d9b9e3a..24dfe31f8c4 100644 --- a/crates/core/config/src/workspace/runner.rs +++ b/crates/core/config/src/workspace/runner.rs @@ -61,6 +61,7 @@ impl Default for RunnerConfig { "package.json", // When root config changes "/.moon/project.yml", + "/.moon/toolchain.yml", "/.moon/workspace.yml", ], inherit_colors_for_piped_tasks: true, diff --git a/crates/core/config/templates/project.yml b/crates/core/config/templates/project.yml index a945378f7cd..43b772abaf5 100644 --- a/crates/core/config/templates/project.yml +++ b/crates/core/config/templates/project.yml @@ -32,7 +32,7 @@ project: # must be a unique project ID, and NOT a file path or project name. # # When `node.syncProjectWorkspaceDependencies` and `typescript.syncProjectReferences` -# are enabled in `.moon/workspace.yml`, these dependencies will be mapped as dependencies +# are enabled in `.moon/toolchain.yml`, these dependencies will be mapped as dependencies # in `package.json` and project references in `tsconfig.json`, respectively. dependsOn: [] diff --git a/crates/core/config/templates/toolchain.yml b/crates/core/config/templates/toolchain.yml new file mode 100644 index 00000000000..9a4619ea2b2 --- /dev/null +++ b/crates/core/config/templates/toolchain.yml @@ -0,0 +1,7 @@ +# https://moonrepo.dev/docs/config/toolchain +$schema: 'https://moonrepo.dev/schemas/toolchain.json' + +# Extend and inherit an external configuration file. Must be a valid HTTPS URL or file system path. +# extends: './shared/toolchain.yml' + +{# Comment only exists to keep syntax intact #} diff --git a/crates/core/config/templates/workspace_node.yml b/crates/core/config/templates/toolchain_node.yml similarity index 100% rename from crates/core/config/templates/workspace_node.yml rename to crates/core/config/templates/toolchain_node.yml diff --git a/crates/core/config/templates/workspace_typescript.yml b/crates/core/config/templates/toolchain_typescript.yml similarity index 100% rename from crates/core/config/templates/workspace_typescript.yml rename to crates/core/config/templates/toolchain_typescript.yml diff --git a/crates/core/config/tests/toolchain_test.rs b/crates/core/config/tests/toolchain_test.rs new file mode 100644 index 00000000000..4ab81c18c33 --- /dev/null +++ b/crates/core/config/tests/toolchain_test.rs @@ -0,0 +1,623 @@ +use moon_config::{ConfigError, NodeConfig, ToolchainConfig}; +use moon_constants::CONFIG_WORKSPACE_FILENAME; +use moon_utils::test::get_fixtures_dir; +use std::path::Path; + +fn load_jailed_config(root: &Path) -> Result { + match ToolchainConfig::load(root.join(CONFIG_WORKSPACE_FILENAME)) { + Ok(cfg) => Ok(cfg), + Err(err) => Err(match err { + ConfigError::FailedValidation(errors) => errors.first().unwrap().to_owned(), + ConfigError::Figment(f) => f, + e => figment::Error::from(e.to_string()), + }), + } +} + +#[test] +fn loads_defaults() { + figment::Jail::expect_with(|jail| { + jail.create_file(CONFIG_WORKSPACE_FILENAME, "extends: ''")?; + + let config = load_jailed_config(jail.directory())?; + + assert_eq!( + config, + ToolchainConfig { + extends: Some("".into()), + node: None, + typescript: None, + schema: String::new(), + } + ); + + Ok(()) + }); +} + +mod extends { + use super::*; + use moon_config::{NodePackageManager, TypeScriptConfig, YarnConfig}; + use pretty_assertions::assert_eq; + use std::fs; + + #[test] + fn recursive_merges() { + let fixture = get_fixtures_dir("config-extends/workspace"); + let config = ToolchainConfig::load(fixture.join("base-2.yml")).unwrap(); + + assert_eq!( + config, + ToolchainConfig { + node: Some(NodeConfig { + version: "4.5.6".into(), + add_engines_constraint: true, + dedupe_on_lockfile_change: false, + package_manager: NodePackageManager::Yarn, + yarn: Some(YarnConfig { + plugins: None, + version: "3.0.0".into() + }), + ..NodeConfig::default() + }), + ..ToolchainConfig::default() + } + ); + } + + #[test] + fn recursive_merges_typescript() { + let fixture = get_fixtures_dir("config-extends/workspace"); + let config = ToolchainConfig::load(fixture.join("typescript-2.yml")).unwrap(); + + assert_eq!( + config.typescript, + Some(TypeScriptConfig { + create_missing_config: false, + root_config_file_name: "tsconfig.root.json".into(), + sync_project_references: true, + ..TypeScriptConfig::default() + }) + ); + } + + #[test] + #[should_panic(expected = "Invalid extends field, must be a string.")] + // #[should_panic( + // expected = "invalid type: found unsigned int `123`, expected a string for key \"workspace.extends\"" + // )] + fn invalid_type() { + figment::Jail::expect_with(|jail| { + jail.create_file(super::CONFIG_WORKSPACE_FILENAME, "extends: 123")?; + + super::load_jailed_config(jail.directory())?; + + Ok(()) + }); + } + + #[test] + #[should_panic(expected = "only YAML documents are supported")] + // #[should_panic( + // expected = "Must be a valid URL or relative file path (starts with ./) for key \"workspace.extends\"" + // )] + fn not_a_url_or_file() { + figment::Jail::expect_with(|jail| { + jail.create_file(super::CONFIG_WORKSPACE_FILENAME, "extends: random value")?; + + super::load_jailed_config(jail.directory())?; + + Ok(()) + }); + } + + #[test] + #[should_panic(expected = "only HTTPS URLs are supported")] + fn not_a_https_url() { + figment::Jail::expect_with(|jail| { + jail.create_file( + super::CONFIG_WORKSPACE_FILENAME, + "extends: http://domain.com/config.yml", + )?; + + super::load_jailed_config(jail.directory())?; + + Ok(()) + }); + } + + #[test] + #[should_panic(expected = "only YAML documents are supported")] + // #[should_panic(expected = "Must be a YAML document for key \"workspace.extends\"")] + fn not_a_yaml_url() { + figment::Jail::expect_with(|jail| { + jail.create_file( + super::CONFIG_WORKSPACE_FILENAME, + "extends: https://domain.com/file.txt", + )?; + + super::load_jailed_config(jail.directory())?; + + Ok(()) + }); + } + + #[test] + #[should_panic(expected = "only YAML documents are supported")] + // #[should_panic(expected = "Must be a YAML document for key \"workspace.extends\"")] + fn not_a_yaml_file() { + figment::Jail::expect_with(|jail| { + fs::create_dir_all(jail.directory().join("shared")).unwrap(); + + jail.create_file("shared/file.txt", "")?; + + jail.create_file( + super::CONFIG_WORKSPACE_FILENAME, + "extends: ./shared/file.txt", + )?; + + super::load_jailed_config(jail.directory())?; + + Ok(()) + }); + } + + #[test] + fn loads_from_file() { + figment::Jail::expect_with(|jail| { + fs::create_dir_all(jail.directory().join("shared")).unwrap(); + + jail.create_file( + format!("shared/{}", super::CONFIG_WORKSPACE_FILENAME), + include_str!("../../../../tests/fixtures/config-extends/.moon/toolchain.yml"), + )?; + + jail.create_file( + super::CONFIG_WORKSPACE_FILENAME, + r#" +extends: ./shared/toolchain.yml + +node: + version: '18.0.0' + npm: + version: '8.0.0' +"#, + )?; + + let config: ToolchainConfig = super::load_jailed_config(jail.directory())?; + + // Inherits from extended file + assert!(!config.node.as_ref().unwrap().add_engines_constraint); + assert!(!config.typescript.unwrap().sync_project_references); + + // Ensure we can override the extended config + assert_eq!(config.node.as_ref().unwrap().version, "18.0.0".to_owned()); + assert_eq!( + config.node.as_ref().unwrap().npm.version, + "8.0.0".to_owned() + ); + + Ok(()) + }); + } + + #[test] + fn loads_from_url() { + figment::Jail::expect_with(|jail| { + jail.set_env( + "MOON_WORKSPACE_ROOT", + jail.directory().to_owned().to_string_lossy(), + ); + + jail.create_file( + super::CONFIG_WORKSPACE_FILENAME, +r#" +extends: https://raw.githubusercontent.com/moonrepo/moon/020-toolchain-cfg/tests/fixtures/config-extends/.moon/toolchain.yml + +node: + version: '18.0.0' + npm: + version: '8.0.0' +"#, + )?; + + let config: ToolchainConfig = super::load_jailed_config(jail.directory())?; + + // Inherits from extended file + assert!(!config.node.as_ref().unwrap().add_engines_constraint); + assert!(!config.typescript.unwrap().sync_project_references); + + // Ensure we can override the extended config + assert_eq!(config.node.as_ref().unwrap().version, "18.0.0".to_owned()); + assert_eq!( + config.node.as_ref().unwrap().npm.version, + "8.0.0".to_owned() + ); + + Ok(()) + }); + } + + // #[test] + // #[should_panic(expected = "TODO")] + // fn handles_invalid_url() { + // figment::Jail::expect_with(|jail| { + // jail.create_file( + // super::CONFIG_WORKSPACE_FILENAME, + // "extends: https://raw.githubusercontent.com/this/is/an/invalid/file.yml", + // )?; + + // super::load_jailed_config(jail.directory())?; + + // Ok(()) + // }); + // } +} + +mod node { + use super::*; + use moon_config::NodePackageManager; + + #[test] + fn loads_defaults() { + figment::Jail::expect_with(|jail| { + jail.create_file( + CONFIG_WORKSPACE_FILENAME, + r#" +node: + packageManager: yarn"#, + )?; + + let config = super::load_jailed_config(jail.directory())?; + + assert_eq!( + config, + ToolchainConfig { + node: Some(NodeConfig { + package_manager: NodePackageManager::Yarn, + ..NodeConfig::default() + }), + ..ToolchainConfig::default() + } + ); + + Ok(()) + }); + } + + #[test] + #[should_panic( + expected = "invalid type: found unsigned int `123`, expected struct NodeConfig for key \"workspace.node\"" + )] + fn invalid_type() { + figment::Jail::expect_with(|jail| { + jail.create_file(super::CONFIG_WORKSPACE_FILENAME, "node: 123")?; + + super::load_jailed_config(jail.directory())?; + + Ok(()) + }); + } + + #[test] + #[should_panic( + expected = "Must be a valid semantic version for key \"workspace.node.version\"" + )] + fn invalid_version() { + figment::Jail::expect_with(|jail| { + jail.create_file( + super::CONFIG_WORKSPACE_FILENAME, + r#" +node: + version: 'foo bar'"#, + )?; + + super::load_jailed_config(jail.directory())?; + + Ok(()) + }); + } + + #[test] + #[should_panic( + expected = "Must be a valid semantic version for key \"workspace.node.version\"" + )] + fn no_patch_version() { + figment::Jail::expect_with(|jail| { + jail.create_file( + super::CONFIG_WORKSPACE_FILENAME, + r#" +node: + version: '16.13'"#, + )?; + + super::load_jailed_config(jail.directory())?; + + Ok(()) + }); + } + + #[test] + #[should_panic( + expected = "Must be a valid semantic version for key \"workspace.node.version\"" + )] + fn no_minor_version() { + figment::Jail::expect_with(|jail| { + jail.create_file( + super::CONFIG_WORKSPACE_FILENAME, + r#" +node: + version: '16'"#, + )?; + + super::load_jailed_config(jail.directory())?; + + Ok(()) + }); + } + + #[test] + #[should_panic( + expected = "unknown variant: found `what`, expected `one of `npm`, `pnpm`, `yarn`` for key \"workspace.node.packageManager\"" + )] + fn invalid_package_manager() { + figment::Jail::expect_with(|jail| { + jail.create_file( + super::CONFIG_WORKSPACE_FILENAME, + r#" +node: + version: '16.13.0' + packageManager: what"#, + )?; + + super::load_jailed_config(jail.directory())?; + + Ok(()) + }); + } + + #[test] + fn valid_package_manager() { + figment::Jail::expect_with(|jail| { + jail.create_file( + super::CONFIG_WORKSPACE_FILENAME, + r#" +node: + version: '16.13.0' + packageManager: yarn"#, + )?; + + super::load_jailed_config(jail.directory())?; + + Ok(()) + }); + } + + #[test] + fn inherits_from_env_var() { + figment::Jail::expect_with(|jail| { + jail.set_env("MOON_NODE_VERSION", "4.5.6"); + + jail.create_file( + super::CONFIG_WORKSPACE_FILENAME, + r#" +node: + version: '16.13.0' +"#, + )?; + + let config = super::load_jailed_config(jail.directory())?; + + assert_eq!(config.node.unwrap().version, String::from("4.5.6")); + + Ok(()) + }); + } +} + +mod npm { + #[test] + #[should_panic( + expected = "invalid type: found string \"foo\", expected struct NpmConfig for key \"workspace.node.npm\"" + )] + fn invalid_type() { + figment::Jail::expect_with(|jail| { + jail.create_file( + super::CONFIG_WORKSPACE_FILENAME, + r#" +node: + version: '16.13.0' + npm: foo"#, + )?; + + super::load_jailed_config(jail.directory())?; + + Ok(()) + }); + } + + #[test] + #[should_panic( + expected = "Must be a valid semantic version for key \"workspace.node.npm.version\"" + )] + fn invalid_version() { + figment::Jail::expect_with(|jail| { + jail.create_file( + super::CONFIG_WORKSPACE_FILENAME, + r#" +node: + version: '16.13.0' + npm: + version: 'foo bar' +"#, + )?; + + super::load_jailed_config(jail.directory())?; + + Ok(()) + }); + } + + #[test] + fn inherits_from_env_var() { + figment::Jail::expect_with(|jail| { + jail.set_env("MOON_NPM_VERSION", "4.5.6"); + + jail.create_file( + super::CONFIG_WORKSPACE_FILENAME, + r#" +node: + version: '16.13.0' + npm: + version: '1.2.3' +"#, + )?; + + let config = super::load_jailed_config(jail.directory())?; + + assert_eq!(config.node.unwrap().npm.version, String::from("4.5.6")); + + Ok(()) + }); + } +} + +mod pnpm { + #[test] + #[should_panic( + expected = "invalid type: found string \"foo\", expected struct PnpmConfig for key \"workspace.node.pnpm\"" + )] + fn invalid_type() { + figment::Jail::expect_with(|jail| { + jail.create_file( + super::CONFIG_WORKSPACE_FILENAME, + r#" +node: + version: '16.13.0' + pnpm: foo"#, + )?; + + super::load_jailed_config(jail.directory())?; + + Ok(()) + }); + } + + #[test] + #[should_panic( + expected = "Must be a valid semantic version for key \"workspace.node.pnpm.version\"" + )] + fn invalid_version() { + figment::Jail::expect_with(|jail| { + jail.create_file( + super::CONFIG_WORKSPACE_FILENAME, + r#" +node: + version: '16.13.0' + pnpm: + version: 'foo bar'"#, + )?; + + super::load_jailed_config(jail.directory())?; + + Ok(()) + }); + } + + #[test] + fn inherits_from_env_var() { + figment::Jail::expect_with(|jail| { + jail.set_env("MOON_PNPM_VERSION", "4.5.6"); + + jail.create_file( + super::CONFIG_WORKSPACE_FILENAME, + r#" +node: + version: '16.13.0' + packageManager: 'pnpm' + pnpm: + version: '1.2.3' +"#, + )?; + + let config = super::load_jailed_config(jail.directory())?; + + assert_eq!( + config.node.unwrap().pnpm.unwrap().version, + String::from("4.5.6") + ); + + Ok(()) + }); + } +} + +mod yarn { + #[test] + #[should_panic( + expected = "invalid type: found string \"foo\", expected struct YarnConfig for key \"workspace.node.yarn\"" + )] + fn invalid_type() { + figment::Jail::expect_with(|jail| { + jail.create_file( + super::CONFIG_WORKSPACE_FILENAME, + r#" +node: + version: '16.13.0' + yarn: foo"#, + )?; + + super::load_jailed_config(jail.directory())?; + + Ok(()) + }); + } + + #[test] + #[should_panic( + expected = "Must be a valid semantic version for key \"workspace.node.yarn.version\"" + )] + fn invalid_version() { + figment::Jail::expect_with(|jail| { + jail.create_file( + super::CONFIG_WORKSPACE_FILENAME, + r#" +node: + version: '16.13.0' + yarn: + version: 'foo bar'"#, + )?; + + super::load_jailed_config(jail.directory())?; + + Ok(()) + }); + } + + #[test] + fn inherits_from_env_var() { + figment::Jail::expect_with(|jail| { + jail.set_env("MOON_YARN_VERSION", "4.5.6"); + + jail.create_file( + super::CONFIG_WORKSPACE_FILENAME, + r#" +node: + version: '16.13.0' + packageManager: 'yarn' + yarn: + version: '1.2.3' +"#, + )?; + + let config = super::load_jailed_config(jail.directory())?; + + assert_eq!( + config.node.unwrap().yarn.unwrap().version, + String::from("4.5.6") + ); + + Ok(()) + }); + } +} diff --git a/crates/core/config/tests/workspace_test.rs b/crates/core/config/tests/workspace_test.rs index 4cc448ffbf9..5aaee7fa8ee 100644 --- a/crates/core/config/tests/workspace_test.rs +++ b/crates/core/config/tests/workspace_test.rs @@ -1,6 +1,6 @@ use moon_config::{ - ConfigError, GeneratorConfig, HasherConfig, NodeConfig, NotifierConfig, RunnerConfig, - VcsConfig, VcsManager, WorkspaceConfig, WorkspaceProjects, + ConfigError, GeneratorConfig, HasherConfig, NotifierConfig, RunnerConfig, VcsConfig, + VcsManager, WorkspaceConfig, WorkspaceProjects, }; use moon_constants::CONFIG_WORKSPACE_FILENAME; use moon_utils::test::get_fixtures_dir; @@ -31,10 +31,8 @@ fn loads_defaults() { generator: GeneratorConfig::default(), extends: None, hasher: HasherConfig::default(), - node: None, notifier: NotifierConfig::default(), projects: WorkspaceProjects::default(), - typescript: None, vcs: VcsConfig::default(), schema: String::new(), } @@ -46,7 +44,6 @@ fn loads_defaults() { mod extends { use super::*; - use moon_config::{NodePackageManager, TypeScriptConfig, YarnConfig}; use pretty_assertions::assert_eq; use std::fs; @@ -63,17 +60,6 @@ mod extends { log_running_command: false, ..RunnerConfig::default() }, - node: Some(NodeConfig { - version: "4.5.6".into(), - add_engines_constraint: true, - dedupe_on_lockfile_change: false, - package_manager: NodePackageManager::Yarn, - yarn: Some(YarnConfig { - plugins: None, - version: "3.0.0".into() - }), - ..NodeConfig::default() - }), vcs: VcsConfig { manager: VcsManager::Svn, ..VcsConfig::default() @@ -83,22 +69,6 @@ mod extends { ); } - #[test] - fn recursive_merges_typescript() { - let fixture = get_fixtures_dir("config-extends/workspace"); - let config = WorkspaceConfig::load(fixture.join("typescript-2.yml")).unwrap(); - - assert_eq!( - config.typescript, - Some(TypeScriptConfig { - create_missing_config: false, - root_config_file_name: "tsconfig.root.json".into(), - sync_project_references: true, - ..TypeScriptConfig::default() - }) - ); - } - #[test] #[should_panic(expected = "Invalid extends field, must be a string.")] // #[should_panic( @@ -179,491 +149,6 @@ mod extends { Ok(()) }); } - - #[test] - fn loads_from_file() { - figment::Jail::expect_with(|jail| { - fs::create_dir_all(jail.directory().join("shared")).unwrap(); - - jail.create_file( - format!("shared/{}", super::CONFIG_WORKSPACE_FILENAME), - include_str!("../../../../tests/fixtures/config-extends/.moon/workspace.yml"), - )?; - - jail.create_file( - super::CONFIG_WORKSPACE_FILENAME, - r#" -extends: ./shared/workspace.yml - -node: - version: '18.0.0' - npm: - version: '8.0.0' -"#, - )?; - - let config: WorkspaceConfig = super::load_jailed_config(jail.directory())?; - - // Inherits from extended file - assert!(!config.node.as_ref().unwrap().add_engines_constraint); - assert!(!config.typescript.unwrap().sync_project_references); - assert_eq!(config.vcs.manager, VcsManager::Svn); - - // Ensure we can override the extended config - assert_eq!(config.node.as_ref().unwrap().version, "18.0.0".to_owned()); - assert_eq!( - config.node.as_ref().unwrap().npm.version, - "8.0.0".to_owned() - ); - - Ok(()) - }); - } - - #[test] - fn loads_from_url() { - figment::Jail::expect_with(|jail| { - jail.set_env( - "MOON_WORKSPACE_ROOT", - jail.directory().to_owned().to_string_lossy(), - ); - - jail.create_file( - super::CONFIG_WORKSPACE_FILENAME, -r#" -extends: https://raw.githubusercontent.com/moonrepo/moon/master/tests/fixtures/config-extends/.moon/workspace.yml - -node: - version: '18.0.0' - npm: - version: '8.0.0' -"#, - )?; - - let config: WorkspaceConfig = super::load_jailed_config(jail.directory())?; - - // Inherits from extended file - assert!(!config.node.as_ref().unwrap().add_engines_constraint); - assert!(!config.typescript.unwrap().sync_project_references); - assert_eq!(config.vcs.manager, VcsManager::Svn); - - // Ensure we can override the extended config - assert_eq!(config.node.as_ref().unwrap().version, "18.0.0".to_owned()); - assert_eq!( - config.node.as_ref().unwrap().npm.version, - "8.0.0".to_owned() - ); - - Ok(()) - }); - } - - // #[test] - // #[should_panic(expected = "TODO")] - // fn handles_invalid_url() { - // figment::Jail::expect_with(|jail| { - // jail.create_file( - // super::CONFIG_WORKSPACE_FILENAME, - // "extends: https://raw.githubusercontent.com/this/is/an/invalid/file.yml", - // )?; - - // super::load_jailed_config(jail.directory())?; - - // Ok(()) - // }); - // } -} - -mod node { - use super::*; - use moon_config::NodePackageManager; - - #[test] - fn loads_defaults() { - figment::Jail::expect_with(|jail| { - jail.create_file( - CONFIG_WORKSPACE_FILENAME, - r#" -projects: {} -node: - packageManager: yarn"#, - )?; - - let config = super::load_jailed_config(jail.directory())?; - - assert_eq!( - config, - WorkspaceConfig { - node: Some(NodeConfig { - package_manager: NodePackageManager::Yarn, - ..NodeConfig::default() - }), - projects: WorkspaceProjects::default(), - ..WorkspaceConfig::default() - } - ); - - Ok(()) - }); - } - - #[test] - #[should_panic( - expected = "invalid type: found unsigned int `123`, expected struct NodeConfig for key \"workspace.node\"" - )] - fn invalid_type() { - figment::Jail::expect_with(|jail| { - jail.create_file(super::CONFIG_WORKSPACE_FILENAME, "node: 123")?; - - super::load_jailed_config(jail.directory())?; - - Ok(()) - }); - } - - #[test] - #[should_panic( - expected = "Must be a valid semantic version for key \"workspace.node.version\"" - )] - fn invalid_version() { - figment::Jail::expect_with(|jail| { - jail.create_file( - super::CONFIG_WORKSPACE_FILENAME, - r#" -node: - version: 'foo bar' -projects: - foo: packages/foo"#, - )?; - - super::load_jailed_config(jail.directory())?; - - Ok(()) - }); - } - - #[test] - #[should_panic( - expected = "Must be a valid semantic version for key \"workspace.node.version\"" - )] - fn no_patch_version() { - figment::Jail::expect_with(|jail| { - jail.create_file( - super::CONFIG_WORKSPACE_FILENAME, - r#" -node: - version: '16.13' -projects: - foo: packages/foo"#, - )?; - - super::load_jailed_config(jail.directory())?; - - Ok(()) - }); - } - - #[test] - #[should_panic( - expected = "Must be a valid semantic version for key \"workspace.node.version\"" - )] - fn no_minor_version() { - figment::Jail::expect_with(|jail| { - jail.create_file( - super::CONFIG_WORKSPACE_FILENAME, - r#" -node: - version: '16' -projects: - foo: packages/foo"#, - )?; - - super::load_jailed_config(jail.directory())?; - - Ok(()) - }); - } - - #[test] - #[should_panic( - expected = "unknown variant: found `what`, expected `one of `npm`, `pnpm`, `yarn`` for key \"workspace.node.packageManager\"" - )] - fn invalid_package_manager() { - figment::Jail::expect_with(|jail| { - jail.create_file( - super::CONFIG_WORKSPACE_FILENAME, - r#" -node: - version: '16.13.0' - packageManager: what -projects: - foo: packages/foo"#, - )?; - - super::load_jailed_config(jail.directory())?; - - Ok(()) - }); - } - - #[test] - fn valid_package_manager() { - figment::Jail::expect_with(|jail| { - jail.create_file( - super::CONFIG_WORKSPACE_FILENAME, - r#" -node: - version: '16.13.0' - packageManager: yarn -projects: - foo: packages/foo"#, - )?; - - super::load_jailed_config(jail.directory())?; - - Ok(()) - }); - } - - #[test] - fn inherits_from_env_var() { - figment::Jail::expect_with(|jail| { - jail.set_env("MOON_NODE_VERSION", "4.5.6"); - - jail.create_file( - super::CONFIG_WORKSPACE_FILENAME, - r#" -node: - version: '16.13.0' -projects: {} -"#, - )?; - - let config = super::load_jailed_config(jail.directory())?; - - assert_eq!(config.node.unwrap().version, String::from("4.5.6")); - - Ok(()) - }); - } -} - -mod npm { - #[test] - #[should_panic( - expected = "invalid type: found string \"foo\", expected struct NpmConfig for key \"workspace.node.npm\"" - )] - fn invalid_type() { - figment::Jail::expect_with(|jail| { - jail.create_file( - super::CONFIG_WORKSPACE_FILENAME, - r#" -node: - version: '16.13.0' - npm: foo"#, - )?; - - super::load_jailed_config(jail.directory())?; - - Ok(()) - }); - } - - #[test] - #[should_panic( - expected = "Must be a valid semantic version for key \"workspace.node.npm.version\"" - )] - fn invalid_version() { - figment::Jail::expect_with(|jail| { - jail.create_file( - super::CONFIG_WORKSPACE_FILENAME, - r#" -node: - version: '16.13.0' - npm: - version: 'foo bar' -projects: - foo: packages/foo -"#, - )?; - - super::load_jailed_config(jail.directory())?; - - Ok(()) - }); - } - - #[test] - fn inherits_from_env_var() { - figment::Jail::expect_with(|jail| { - jail.set_env("MOON_NPM_VERSION", "4.5.6"); - - jail.create_file( - super::CONFIG_WORKSPACE_FILENAME, - r#" -node: - version: '16.13.0' - npm: - version: '1.2.3' -projects: {} -"#, - )?; - - let config = super::load_jailed_config(jail.directory())?; - - assert_eq!(config.node.unwrap().npm.version, String::from("4.5.6")); - - Ok(()) - }); - } -} - -mod pnpm { - - #[test] - #[should_panic( - expected = "invalid type: found string \"foo\", expected struct PnpmConfig for key \"workspace.node.pnpm\"" - )] - fn invalid_type() { - figment::Jail::expect_with(|jail| { - jail.create_file( - super::CONFIG_WORKSPACE_FILENAME, - r#" -node: - version: '16.13.0' - pnpm: foo"#, - )?; - - super::load_jailed_config(jail.directory())?; - - Ok(()) - }); - } - - #[test] - #[should_panic( - expected = "Must be a valid semantic version for key \"workspace.node.pnpm.version\"" - )] - fn invalid_version() { - figment::Jail::expect_with(|jail| { - jail.create_file( - super::CONFIG_WORKSPACE_FILENAME, - r#" -node: - version: '16.13.0' - pnpm: - version: 'foo bar' -projects: - foo: packages/foo"#, - )?; - - super::load_jailed_config(jail.directory())?; - - Ok(()) - }); - } - - #[test] - fn inherits_from_env_var() { - figment::Jail::expect_with(|jail| { - jail.set_env("MOON_PNPM_VERSION", "4.5.6"); - - jail.create_file( - super::CONFIG_WORKSPACE_FILENAME, - r#" -node: - version: '16.13.0' - packageManager: 'pnpm' - pnpm: - version: '1.2.3' -projects: {} -"#, - )?; - - let config = super::load_jailed_config(jail.directory())?; - - assert_eq!( - config.node.unwrap().pnpm.unwrap().version, - String::from("4.5.6") - ); - - Ok(()) - }); - } -} - -mod yarn { - - #[test] - #[should_panic( - expected = "invalid type: found string \"foo\", expected struct YarnConfig for key \"workspace.node.yarn\"" - )] - fn invalid_type() { - figment::Jail::expect_with(|jail| { - jail.create_file( - super::CONFIG_WORKSPACE_FILENAME, - r#" -node: - version: '16.13.0' - yarn: foo"#, - )?; - - super::load_jailed_config(jail.directory())?; - - Ok(()) - }); - } - - #[test] - #[should_panic( - expected = "Must be a valid semantic version for key \"workspace.node.yarn.version\"" - )] - fn invalid_version() { - figment::Jail::expect_with(|jail| { - jail.create_file( - super::CONFIG_WORKSPACE_FILENAME, - r#" -node: - version: '16.13.0' - yarn: - version: 'foo bar' -projects: - foo: packages/foo"#, - )?; - - super::load_jailed_config(jail.directory())?; - - Ok(()) - }); - } - - #[test] - fn inherits_from_env_var() { - figment::Jail::expect_with(|jail| { - jail.set_env("MOON_YARN_VERSION", "4.5.6"); - - jail.create_file( - super::CONFIG_WORKSPACE_FILENAME, - r#" -node: - version: '16.13.0' - packageManager: 'yarn' - yarn: - version: '1.2.3' -projects: {} -"#, - )?; - - let config = super::load_jailed_config(jail.directory())?; - - assert_eq!( - config.node.unwrap().yarn.unwrap().version, - String::from("4.5.6") - ); - - Ok(()) - }); - } } mod projects { diff --git a/crates/core/constants/src/lib.rs b/crates/core/constants/src/lib.rs index e2a11685a0d..8afa879d8fe 100644 --- a/crates/core/constants/src/lib.rs +++ b/crates/core/constants/src/lib.rs @@ -1,5 +1,7 @@ pub const CONFIG_DIRNAME: &str = ".moon"; +pub const CONFIG_TOOLCHAIN_FILENAME: &str = "toolchain.yml"; + pub const CONFIG_WORKSPACE_FILENAME: &str = "workspace.yml"; pub const CONFIG_GLOBAL_PROJECT_FILENAME: &str = "project.yml"; diff --git a/crates/core/platform/src/lib.rs b/crates/core/platform/src/lib.rs index f6f95e0674d..64348875088 100644 --- a/crates/core/platform/src/lib.rs +++ b/crates/core/platform/src/lib.rs @@ -4,7 +4,7 @@ mod runtime; use moon_config::{ DependencyConfig, PlatformType, ProjectConfig, ProjectsAliasesMap, ProjectsSourcesMap, - TasksConfigsMap, WorkspaceConfig, + TasksConfigsMap, ToolchainConfig, }; use moon_error::MoonError; pub use runtime::{Runtime, Version}; @@ -21,7 +21,7 @@ pub trait Platform: Debug + Send + Sync { fn get_runtime_from_config( &self, project_config: Option<&ProjectConfig>, - workspace_config: &WorkspaceConfig, + toolchain_config: &ToolchainConfig, ) -> Option; /// Determine if the provided project is within the platform's package manager @@ -31,7 +31,7 @@ pub trait Platform: Debug + Send + Sync { project_id: &str, project_root: &Path, workspace_root: &Path, - workspace_config: &WorkspaceConfig, + toolchain_config: &ToolchainConfig, ) -> Result { Ok(true) } @@ -41,7 +41,7 @@ pub trait Platform: Debug + Send + Sync { fn load_project_graph_aliases( &mut self, workspace_root: &Path, - workspace_config: &WorkspaceConfig, + toolchain_config: &ToolchainConfig, projects_map: &ProjectsSourcesMap, aliases_map: &mut ProjectsAliasesMap, ) -> Result<(), MoonError> { @@ -68,7 +68,7 @@ pub trait Platform: Debug + Send + Sync { project_root: &Path, project_config: &ProjectConfig, workspace_root: &Path, - workspace_config: &WorkspaceConfig, + toolchain_config: &ToolchainConfig, ) -> Result { Ok(BTreeMap::new()) } diff --git a/crates/core/project-graph/benches/project_graph_benchmark.rs b/crates/core/project-graph/benches/project_graph_benchmark.rs index 7e3f26e8a0d..cd30d3fee16 100644 --- a/crates/core/project-graph/benches/project_graph_benchmark.rs +++ b/crates/core/project-graph/benches/project_graph_benchmark.rs @@ -1,6 +1,6 @@ use criterion::{black_box, criterion_group, criterion_main, Criterion}; use moon_cache::CacheEngine; -use moon_config::{GlobalProjectConfig, WorkspaceConfig, WorkspaceProjects}; +use moon_config::{GlobalProjectConfig, ToolchainConfig, WorkspaceConfig, WorkspaceProjects}; use moon_project_graph::ProjectGraph; use moon_utils::test::get_fixtures_dir; use rustc_hash::FxHashMap; @@ -23,6 +23,7 @@ pub fn load_benchmark(c: &mut Criterion) { let graph = ProjectGraph::generate( &workspace_root, &workspace_config, + &ToolchainConfig::default(), GlobalProjectConfig::default(), &cache, ) @@ -49,6 +50,7 @@ pub fn load_all_benchmark(c: &mut Criterion) { let graph = ProjectGraph::generate( &workspace_root, &workspace_config, + &ToolchainConfig::default(), GlobalProjectConfig::default(), &cache, ) diff --git a/crates/core/project-graph/src/graph.rs b/crates/core/project-graph/src/graph.rs index 06192bda276..ccafeeb986c 100644 --- a/crates/core/project-graph/src/graph.rs +++ b/crates/core/project-graph/src/graph.rs @@ -1,7 +1,7 @@ use moon_cache::CacheEngine; use moon_config::{ - GlobalProjectConfig, ProjectID, ProjectsAliasesMap, ProjectsSourcesMap, WorkspaceConfig, - WorkspaceProjects, + GlobalProjectConfig, ProjectID, ProjectsAliasesMap, ProjectsSourcesMap, ToolchainConfig, + WorkspaceConfig, WorkspaceProjects, }; use moon_error::MoonError; use moon_logger::{color, debug, map_list, trace}; @@ -108,6 +108,10 @@ pub struct ProjectGraph { /// Is the `projects` setting in `.moon/workspace.yml`. pub projects_map: ProjectsSourcesMap, + /// The toolchain configuration. Necessary for project variants. + /// Is loaded from `.moon/toolchain.yml`. + pub toolchain_config: ToolchainConfig, + /// The workspace configuration. Necessary for project variants. /// Is loaded from `.moon/workspace.yml`. pub workspace_config: WorkspaceConfig, @@ -122,7 +126,7 @@ impl Platformable for ProjectGraph { platform.load_project_graph_aliases( &self.workspace_root, - &self.workspace_config, + &self.toolchain_config, &self.projects_map, &mut self.aliases_map, )?; @@ -137,6 +141,7 @@ impl ProjectGraph { pub async fn generate( workspace_root: &Path, workspace_config: &WorkspaceConfig, + toolchain_config: &ToolchainConfig, global_config: GlobalProjectConfig, cache: &CacheEngine, ) -> Result { @@ -157,7 +162,8 @@ impl ProjectGraph { indices: Arc::new(RwLock::new(FxHashMap::default())), platforms: PlatformManager::default(), projects_map: load_projects_from_cache(workspace_root, workspace_config, cache).await?, - workspace_config: workspace_config.clone(), + toolchain_config: toolchain_config.to_owned(), + workspace_config: workspace_config.to_owned(), workspace_root: workspace_root.to_path_buf(), }) } @@ -377,7 +383,7 @@ impl ProjectGraph { &project.root, &project.config, &self.workspace_root, - &self.workspace_config, + &self.toolchain_config, )? { // Inferred tasks should not override explicit tasks #[allow(clippy::map_entry)] diff --git a/crates/core/project-graph/tests/project_graph_test.rs b/crates/core/project-graph/tests/project_graph_test.rs index 5b7e59a49d0..b3fe626fe02 100644 --- a/crates/core/project-graph/tests/project_graph_test.rs +++ b/crates/core/project-graph/tests/project_graph_test.rs @@ -1,7 +1,8 @@ use insta::assert_snapshot; use moon_cache::CacheEngine; use moon_config::{ - GlobalProjectConfig, NodeConfig, NodeProjectAliasFormat, WorkspaceConfig, WorkspaceProjects, + GlobalProjectConfig, NodeConfig, NodeProjectAliasFormat, ToolchainConfig, WorkspaceConfig, + WorkspaceProjects, }; use moon_project_graph::ProjectGraph; use moon_utils::string_vec; @@ -12,10 +13,6 @@ use std::fs; async fn get_aliases_graph() -> ProjectGraph { let workspace_root = get_fixtures_dir("project-graph/aliases"); let workspace_config = WorkspaceConfig { - node: Some(NodeConfig { - alias_package_names: Some(NodeProjectAliasFormat::NameAndScope), - ..NodeConfig::default() - }), projects: WorkspaceProjects::Sources(FxHashMap::from_iter([ ("explicit".to_owned(), "explicit".to_owned()), ( @@ -30,10 +27,18 @@ async fn get_aliases_graph() -> ProjectGraph { ])), ..WorkspaceConfig::default() }; + let toolchain_config = ToolchainConfig { + node: Some(NodeConfig { + alias_package_names: Some(NodeProjectAliasFormat::NameAndScope), + ..NodeConfig::default() + }), + ..ToolchainConfig::default() + }; ProjectGraph::generate( &workspace_root, &workspace_config, + &toolchain_config, GlobalProjectConfig::default(), &CacheEngine::load(&workspace_root).await.unwrap(), ) @@ -56,6 +61,7 @@ async fn get_dependencies_graph() -> ProjectGraph { ProjectGraph::generate( &workspace_root, &workspace_config, + &ToolchainConfig::default(), GlobalProjectConfig::default(), &CacheEngine::load(&workspace_root).await.unwrap(), ) @@ -78,6 +84,7 @@ async fn get_dependents_graph() -> ProjectGraph { ProjectGraph::generate( &workspace_root, &workspace_config, + &ToolchainConfig::default(), GlobalProjectConfig::default(), &CacheEngine::load(&workspace_root).await.unwrap(), ) @@ -117,6 +124,7 @@ projects: let graph = ProjectGraph::generate( fixture.path(), &workspace_config, + &ToolchainConfig::default(), GlobalProjectConfig::default(), &CacheEngine::load(fixture.path()).await.unwrap(), ) @@ -155,6 +163,7 @@ mod globs { let graph = ProjectGraph::generate( fixture.path(), &workspace_config, + &ToolchainConfig::default(), GlobalProjectConfig::default(), &CacheEngine::load(fixture.path()).await.unwrap(), ) @@ -195,6 +204,7 @@ mod globs { let graph = ProjectGraph::generate( fixture.path(), &workspace_config, + &ToolchainConfig::default(), GlobalProjectConfig::default(), &CacheEngine::load(fixture.path()).await.unwrap(), ) diff --git a/crates/core/runner/src/actions/run_target.rs b/crates/core/runner/src/actions/run_target.rs index 6d3cf120c35..107c9b14f55 100644 --- a/crates/core/runner/src/actions/run_target.rs +++ b/crates/core/runner/src/actions/run_target.rs @@ -571,13 +571,14 @@ impl<'a> TargetRunner<'a> { checkpoint: Checkpoint, comments: &[T], ) -> Result<(), MoonError> { + let label = label_checkpoint(&self.task.target, checkpoint); + if comments.is_empty() { - self.stdout - .write_line(&label_checkpoint(&self.task.target, checkpoint))?; + self.stdout.write_line(&label)?; } else { self.stdout.write_line(&format!( "{} {}", - label_checkpoint(&self.task.target, checkpoint), + label, color::muted(format!( "({})", comments @@ -693,7 +694,9 @@ impl<'a> TargetRunner<'a> { comments.push(time::elapsed(duration)); } - if attempt.finished_at.is_some() { + // Do not include the hash while testing, as the hash + // constantly changes and breaks our local snapshots + if !is_test_env() && attempt.finished_at.is_some() { comments.push(self.get_short_hash().to_owned()); } diff --git a/crates/core/runner/src/dep_graph.rs b/crates/core/runner/src/dep_graph.rs index 8d7005b5473..807ac7a19af 100644 --- a/crates/core/runner/src/dep_graph.rs +++ b/crates/core/runner/src/dep_graph.rs @@ -80,11 +80,11 @@ impl DepGraph { if is_match { project_runtime = platform.get_runtime_from_config( Some(&project.config), - &project_graph.workspace_config, + &project_graph.toolchain_config, ); workspace_runtime = - platform.get_runtime_from_config(None, &project_graph.workspace_config); + platform.get_runtime_from_config(None, &project_graph.toolchain_config); break; } @@ -117,7 +117,7 @@ impl DepGraph { &project.id, &project.root, &project_graph.workspace_root, - &project_graph.workspace_config, + &project_graph.toolchain_config, )? { installs_in_project = true; } diff --git a/crates/core/runner/tests/dep_graph_test.rs b/crates/core/runner/tests/dep_graph_test.rs index 829796dd648..6f034bd8331 100644 --- a/crates/core/runner/tests/dep_graph_test.rs +++ b/crates/core/runner/tests/dep_graph_test.rs @@ -1,6 +1,8 @@ use insta::assert_snapshot; use moon_cache::CacheEngine; -use moon_config::{GlobalProjectConfig, NodeConfig, WorkspaceConfig, WorkspaceProjects}; +use moon_config::{ + GlobalProjectConfig, NodeConfig, ToolchainConfig, WorkspaceConfig, WorkspaceProjects, +}; use moon_node_platform::NodePlatform; use moon_platform::Platformable; use moon_project_graph::ProjectGraph; @@ -34,17 +36,21 @@ async fn create_project_graph() -> (ProjectGraph, TempDir) { ("tasks".to_owned(), "tasks".to_owned()), ("platforms".to_owned(), "platforms".to_owned()), ])), + ..WorkspaceConfig::default() + }; + let toolchain_config = ToolchainConfig { node: Some(NodeConfig { // Consistent snapshots version: "16.0.0".into(), ..NodeConfig::default() }), - ..WorkspaceConfig::default() + ..ToolchainConfig::default() }; let mut graph = ProjectGraph::generate( workspace_root, &workspace_config, + &toolchain_config, GlobalProjectConfig::default(), &CacheEngine::load(workspace_root).await.unwrap(), ) @@ -75,12 +81,15 @@ async fn create_tasks_project_graph() -> (ProjectGraph, TempDir) { ("mergeReplace".to_owned(), "merge-replace".to_owned()), ("noTasks".to_owned(), "no-tasks".to_owned()), ])), + ..WorkspaceConfig::default() + }; + let toolchain_config = ToolchainConfig { node: Some(NodeConfig { // Consistent snapshots version: "16.0.0".into(), ..NodeConfig::default() }), - ..WorkspaceConfig::default() + ..ToolchainConfig::default() }; let global_config = GlobalProjectConfig { file_groups: FxHashMap::from_iter([("sources".to_owned(), vec!["src/**/*".to_owned()])]), @@ -90,6 +99,7 @@ async fn create_tasks_project_graph() -> (ProjectGraph, TempDir) { let mut graph = ProjectGraph::generate( workspace_root, &workspace_config, + &toolchain_config, global_config, &CacheEngine::load(workspace_root).await.unwrap(), ) diff --git a/crates/core/toolchain/src/toolchain.rs b/crates/core/toolchain/src/toolchain.rs index a7a6083f1a7..7c973d63d4e 100644 --- a/crates/core/toolchain/src/toolchain.rs +++ b/crates/core/toolchain/src/toolchain.rs @@ -1,7 +1,7 @@ use crate::errors::ToolchainError; use crate::manager::ToolManager; use crate::tools::node::NodeTool; -use moon_config::WorkspaceConfig; +use moon_config::ToolchainConfig; use moon_constants::CONFIG_DIRNAME; use moon_logger::{color, debug}; use moon_platform::{Runtime, Version}; @@ -11,26 +11,28 @@ use std::path::{Path, PathBuf}; #[derive(Debug)] pub struct Toolchain { + pub config: ToolchainConfig, + /// The directory where toolchain artifacts are stored. /// This is typically ~/.moon. pub dir: PathBuf, - /// Node.js! + /// Tools: pub node: ToolManager, } impl Toolchain { - pub async fn load(workspace_config: &WorkspaceConfig) -> Result { + pub async fn load(config: &ToolchainConfig) -> Result { Toolchain::load_from( path::get_home_dir().ok_or(ToolchainError::MissingHomeDir)?, - workspace_config, + config, ) .await } pub async fn load_from>( base_dir: P, - workspace_config: &WorkspaceConfig, + config: &ToolchainConfig, ) -> Result { let dir = base_dir.as_ref().join(CONFIG_DIRNAME); @@ -43,13 +45,14 @@ impl Toolchain { fs::create_dir_all(&dir).await?; let mut toolchain = Toolchain { + config: config.to_owned(), dir, // Tools node: ToolManager::new(Runtime::Node(Version::default())), }; let proto = toolchain.get_paths(); - if let Some(node_config) = &workspace_config.node { + if let Some(node_config) = &config.node { toolchain .node .register(NodeTool::new(&proto, node_config)?, true); diff --git a/crates/core/utils/src/test.rs b/crates/core/utils/src/test.rs index d19402e1fc6..899b6a59461 100644 --- a/crates/core/utils/src/test.rs +++ b/crates/core/utils/src/test.rs @@ -36,7 +36,10 @@ pub fn create_sandbox>(fixture: T) -> assert_fs::TempDir { .unwrap(); temp_dir - .copy_from(get_fixtures_root(), &["shared-workspace.yml"]) + .copy_from( + get_fixtures_root(), + &["shared-toolchain.yml", "shared-workspace.yml"], + ) .unwrap(); temp_dir diff --git a/crates/core/workspace/src/errors.rs b/crates/core/workspace/src/errors.rs index 0adb3e6aee1..01a546791f0 100644 --- a/crates/core/workspace/src/errors.rs +++ b/crates/core/workspace/src/errors.rs @@ -21,6 +21,13 @@ pub enum WorkspaceError { )] MissingWorkspaceConfigFile, + #[error( + "Failed to validate {}/{} configuration file.\n\n{0}", + constants::CONFIG_DIRNAME, + constants::CONFIG_TOOLCHAIN_FILENAME + )] + InvalidToolchainConfigFile(String), + #[error( "Failed to validate {}/{} configuration file.\n\n{0}", constants::CONFIG_DIRNAME, diff --git a/crates/core/workspace/src/workspace.rs b/crates/core/workspace/src/workspace.rs index 6cc83548fc4..2048e63df48 100644 --- a/crates/core/workspace/src/workspace.rs +++ b/crates/core/workspace/src/workspace.rs @@ -1,7 +1,8 @@ use crate::errors::WorkspaceError; use moon_cache::CacheEngine; use moon_config::{ - format_error_line, format_figment_errors, ConfigError, GlobalProjectConfig, WorkspaceConfig, + format_error_line, format_figment_errors, ConfigError, GlobalProjectConfig, ToolchainConfig, + WorkspaceConfig, }; use moon_constants as constants; use moon_logger::{color, debug, trace}; @@ -69,6 +70,39 @@ fn load_global_project_config(root_dir: &Path) -> Result Result { + let config_path = root_dir + .join(constants::CONFIG_DIRNAME) + .join(constants::CONFIG_TOOLCHAIN_FILENAME); + + trace!( + target: LOG_TARGET, + "Loading {} from {}", + color::file(&format!( + "{}/{}", + constants::CONFIG_DIRNAME, + constants::CONFIG_TOOLCHAIN_FILENAME, + )), + color::path(root_dir) + ); + + if !config_path.exists() { + return Ok(ToolchainConfig::default()); + } + + match ToolchainConfig::load(config_path) { + Ok(cfg) => Ok(cfg), + Err(errors) => Err(WorkspaceError::InvalidToolchainConfigFile( + if let ConfigError::FailedValidation(valids) = errors { + format_figment_errors(valids) + } else { + format_error_line(errors.to_string()) + }, + )), + } +} + // .moon/workspace.yml fn load_workspace_config(root_dir: &Path) -> Result { let config_path = root_dir @@ -150,12 +184,20 @@ impl Workspace { // Load configs let config = load_workspace_config(&root_dir)?; + let toolchain_config = load_toolchain_config(&root_dir)?; let project_config = load_global_project_config(&root_dir)?; // Setup components let cache = CacheEngine::load(&root_dir).await?; - let toolchain = Toolchain::load(&config).await?; - let projects = ProjectGraph::generate(&root_dir, &config, project_config, &cache).await?; + let toolchain = Toolchain::load(&toolchain_config).await?; + let projects = ProjectGraph::generate( + &root_dir, + &config, + &toolchain_config, + project_config, + &cache, + ) + .await?; let vcs = VcsLoader::load(&root_dir, &config)?; Ok(Workspace { diff --git a/crates/node/platform/src/actions/run_target.rs b/crates/node/platform/src/actions/run_target.rs index aa74777c99a..0fde2a9689d 100644 --- a/crates/node/platform/src/actions/run_target.rs +++ b/crates/node/platform/src/actions/run_target.rs @@ -29,7 +29,7 @@ fn create_node_options( &task.target.id, ]; - if let Some(node_config) = &workspace.config.node { + if let Some(node_config) = &workspace.toolchain.config.node { if !node_config.bin_exec_args.is_empty() { options.extend(node_config.bin_exec_args.to_owned()); } @@ -95,7 +95,7 @@ pub async fn create_target_command( let mut node = workspace.toolchain.node.get()?; // If a version override exists, use it for the cmmand - if let Some(node_config) = &project.config.workspace.node { + if let Some(node_config) = &project.config.toolchain.node { if let Some(version_override) = &node_config.version { node = workspace.toolchain.node.get_for_version(version_override)?; } @@ -185,7 +185,7 @@ pub async fn create_target_hasher( hasher.hash_package_json(&package, &resolved_dependencies); } - if let Some(typescript_config) = &workspace.config.typescript { + if let Some(typescript_config) = &workspace.toolchain.config.typescript { if let Some(root_tsconfig) = TsConfigJson::read_with_name(&workspace.root, &typescript_config.root_config_file_name)? { diff --git a/crates/node/platform/src/actions/sync_project.rs b/crates/node/platform/src/actions/sync_project.rs index f7c80a1fb6e..56701202811 100644 --- a/crates/node/platform/src/actions/sync_project.rs +++ b/crates/node/platform/src/actions/sync_project.rs @@ -83,7 +83,7 @@ pub async fn sync_project( let mut mutated_files = false; let workspace = workspace.read().await; let node = workspace.toolchain.node.get()?; - let is_project_typescript_enabled = project.config.workspace.typescript; + let is_project_typescript_enabled = project.config.toolchain.typescript; // Sync each dependency to `tsconfig.json` and `package.json` let mut package_prod_deps: BTreeMap = BTreeMap::new(); @@ -96,7 +96,7 @@ pub async fn sync_project( let dep_project = workspace.projects.load(dep_id)?; let dep_relative_path = path::relative_from(&dep_project.root, &project.root).unwrap_or_default(); - let is_dep_typescript_enabled = dep_project.config.workspace.typescript; + let is_dep_typescript_enabled = dep_project.config.toolchain.typescript; // Update dependencies within this project's `package.json`. // Only add if the dependent project has a `package.json`, @@ -155,7 +155,7 @@ pub async fn sync_project( } } - if let Some(typescript_config) = &workspace.config.typescript { + if let Some(typescript_config) = &workspace.toolchain.config.typescript { // Update `references` within this project's `tsconfig.json`. // Only add if the dependent project has a `tsconfig.json`, // and this `tsconfig.json` has not already declared the dep. @@ -249,7 +249,7 @@ pub async fn sync_project( })?; } - if let Some(typescript_config) = &workspace.config.typescript { + if let Some(typescript_config) = &workspace.toolchain.config.typescript { // Auto-create a `tsconfig.json` if configured and applicable if is_project_typescript_enabled && typescript_config.sync_project_references diff --git a/crates/node/platform/src/lib.rs b/crates/node/platform/src/lib.rs index ab0b138e771..2546643feea 100644 --- a/crates/node/platform/src/lib.rs +++ b/crates/node/platform/src/lib.rs @@ -5,7 +5,7 @@ pub mod task; pub use hasher::NodeTargetHasher; use moon_config::{ DependencyConfig, DependencyScope, NodeProjectAliasFormat, PlatformType, ProjectConfig, - ProjectID, ProjectsAliasesMap, ProjectsSourcesMap, TasksConfigsMap, WorkspaceConfig, + ProjectID, ProjectsAliasesMap, ProjectsSourcesMap, TasksConfigsMap, ToolchainConfig, }; use moon_error::MoonError; use moon_logger::{color, debug, warn}; @@ -57,17 +57,17 @@ impl Platform for NodePlatform { fn get_runtime_from_config( &self, project_config: Option<&ProjectConfig>, - workspace_config: &WorkspaceConfig, + toolchain_config: &ToolchainConfig, ) -> Option { if let Some(config) = &project_config { - if let Some(node_config) = &config.workspace.node { + if let Some(node_config) = &config.toolchain.node { if let Some(version) = &node_config.version { return Some(Runtime::Node(Version(version.to_owned(), true))); } } } - if let Some(node_config) = &workspace_config.node { + if let Some(node_config) = &toolchain_config.node { return Some(Runtime::Node(Version( node_config.version.to_owned(), false, @@ -82,7 +82,7 @@ impl Platform for NodePlatform { project_id: &str, project_root: &Path, workspace_root: &Path, - _workspace_config: &WorkspaceConfig, + _toolchain_config: &ToolchainConfig, ) -> Result { let mut in_workspace = false; @@ -112,14 +112,14 @@ impl Platform for NodePlatform { fn load_project_graph_aliases( &mut self, workspace_root: &Path, - workspace_config: &WorkspaceConfig, + toolchain_config: &ToolchainConfig, projects_map: &ProjectsSourcesMap, aliases_map: &mut ProjectsAliasesMap, ) -> Result<(), MoonError> { let mut map_aliases = false; let mut alias_format = NodeProjectAliasFormat::NameAndScope; - if let Some(node_config) = &workspace_config.node { + if let Some(node_config) = &toolchain_config.node { if let Some(custom_format) = &node_config.alias_package_names { map_aliases = true; alias_format = custom_format.clone(); @@ -234,11 +234,11 @@ impl Platform for NodePlatform { project_root: &Path, _project_config: &ProjectConfig, _workspace_root: &Path, - workspace_config: &WorkspaceConfig, + toolchain_config: &ToolchainConfig, ) -> Result { let mut tasks = BTreeMap::new(); - if let Some(node_config) = &workspace_config.node { + if let Some(node_config) = &toolchain_config.node { if !node_config.infer_tasks_from_scripts { return Ok(tasks); } diff --git a/crates/node/platform/tests/project_aliases_test.rs b/crates/node/platform/tests/project_aliases_test.rs index 48b8e9991aa..5f5067d44a3 100644 --- a/crates/node/platform/tests/project_aliases_test.rs +++ b/crates/node/platform/tests/project_aliases_test.rs @@ -1,7 +1,8 @@ use insta::assert_snapshot; use moon_cache::CacheEngine; use moon_config::{ - GlobalProjectConfig, NodeConfig, NodeProjectAliasFormat, WorkspaceConfig, WorkspaceProjects, + GlobalProjectConfig, NodeConfig, NodeProjectAliasFormat, ToolchainConfig, WorkspaceConfig, + WorkspaceProjects, }; use moon_node_platform::NodePlatform; use moon_platform::Platformable; @@ -17,13 +18,17 @@ async fn get_aliases_graph(node_config: NodeConfig) -> ProjectGraph { ("nodeNameOnly".to_owned(), "node-name-only".to_owned()), ("nodeNameScope".to_owned(), "node-name-scope".to_owned()), ])), - node: Some(node_config), ..WorkspaceConfig::default() }; + let toolchain_config = ToolchainConfig { + node: Some(node_config), + ..ToolchainConfig::default() + }; let mut graph = ProjectGraph::generate( &workspace_root, &workspace_config, + &toolchain_config, GlobalProjectConfig::default(), &CacheEngine::load(&workspace_root).await.unwrap(), ) diff --git a/crates/system/platform/src/lib.rs b/crates/system/platform/src/lib.rs index b320890096e..5a9478f6be5 100644 --- a/crates/system/platform/src/lib.rs +++ b/crates/system/platform/src/lib.rs @@ -2,7 +2,7 @@ pub mod actions; mod hasher; pub use hasher::SystemTargetHasher; -use moon_config::{PlatformType, ProjectConfig, WorkspaceConfig}; +use moon_config::{PlatformType, ProjectConfig, ToolchainConfig}; use moon_platform::{Platform, Runtime}; #[derive(Debug, Default)] @@ -16,7 +16,7 @@ impl Platform for SystemPlatform { fn get_runtime_from_config( &self, _project_config: Option<&ProjectConfig>, - _workspace_config: &WorkspaceConfig, + _toolchain_config: &ToolchainConfig, ) -> Option { Some(Runtime::System) } diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md index 4d1e4a95217..a6256b3f16c 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -2,6 +2,13 @@ ## Unreleased +#### 💥 Breaking + +- Moved the `node` and `typescript` settings from `.moon/workspace.yml` to a new config, + `.moon/toolchain.yml`. +- Moved the `workspace.node` and `workspace.typescript` settings in `moon.yml` to `toolchain.node` + and `toolchain.typescript`. + #### 🚀 Updates - Added `vcs.remoteCandidates` to `.moon/workspace.yml` to customize the remotes for git to query @@ -13,7 +20,7 @@ ##### Toolchain - Implemented a new toolchain, that is more efficient and performant. -- Will now long to the terminal when node, npm, etc, are being installed for the first time. +- Will now log to the terminal when node, npm, etc, are being installed for the first time. ##### Runner @@ -22,6 +29,7 @@ processes. - Implemented a new file tree diffing algorithm that speeds up task output hydration by 10x. - Updated pnpm to no longer run `pnpm prune` while deduping dependencies, as it produces unexpected + results. ##### Generator diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts index b6f779eccb0..f5d0dc913dc 100644 --- a/packages/types/src/index.ts +++ b/packages/types/src/index.ts @@ -4,4 +4,5 @@ export * from './project'; export * from './project-config'; export * from './runner'; export * from './template-config'; +export * from './toolchain-config'; export * from './workspace-config'; diff --git a/packages/types/src/project-config.ts b/packages/types/src/project-config.ts index 68aa4dd1faa..4e492d1edbd 100644 --- a/packages/types/src/project-config.ts +++ b/packages/types/src/project-config.ts @@ -1,5 +1,5 @@ import type { Nullable, Platform } from './common'; -import type { NodeConfig } from './workspace-config'; +import type { NodeConfig } from './toolchain-config'; export type DependencyScope = 'development' | 'peer' | 'production'; @@ -53,7 +53,12 @@ export interface ProjectMetadataConfig { channel: string; } -export type ProjectWorkspaceNodeConfig = Nullable>; +export type ProjectToolchainNodeConfig = Nullable>; + +export interface ProjectToolchainConfig { + node: ProjectToolchainNodeConfig | null; + typescript: boolean; +} export interface ProjectWorkspaceConfig { inheritedTasks: { @@ -61,8 +66,6 @@ export interface ProjectWorkspaceConfig { include: string[] | null; rename: Record | null; }; - node: ProjectWorkspaceNodeConfig | null; - typescript: boolean; } export interface ProjectConfig { @@ -71,6 +74,7 @@ export interface ProjectConfig { language: ProjectLanguage; project: ProjectMetadataConfig | null; tasks: Record; + toolchain: ProjectToolchainConfig; type: ProjectType; workspace: ProjectWorkspaceConfig; } diff --git a/packages/types/src/toolchain-config.ts b/packages/types/src/toolchain-config.ts new file mode 100644 index 00000000000..a6814597358 --- /dev/null +++ b/packages/types/src/toolchain-config.ts @@ -0,0 +1,48 @@ +export type NodeVersionFormat = + | 'file' + | 'link' + | 'star' + | 'version-caret' + | 'version-tilde' + | 'version' + | 'workspace-caret' + | 'workspace-tilde' + | 'workspace'; + +export interface NodePackageManagerConfig { + version: string; +} + +export interface YarnConfig extends NodePackageManagerConfig { + plugins: string[]; +} + +export interface NodeConfig { + addEnginesConstraint: boolean; + aliasPackageNames: 'name-and-scope' | 'name-only' | null; + binExecArgs: string[]; + dedupeOnLockfileChange: boolean; + dependencyVersionFormat: NodeVersionFormat; + inferTasksFromScripts: boolean; + npm: NodePackageManagerConfig; + packageManager: 'npm' | 'pnpm' | 'yarn'; + pnpm: NodePackageManagerConfig | null; + syncProjectWorkspaceDependencies: boolean; + syncVersionManagerConfig: 'nodenv' | 'nvm' | null; + version: string; + yarn: YarnConfig | null; +} + +export interface TypeScriptConfig { + createMissingConfig: boolean; + projectConfigFileName: string; + rootConfigFileName: string; + rootOptionsConfigFileName: string; + syncProjectReferences: boolean; +} + +export interface ToolchainConfig { + extends: string | null; + node: NodeConfig | null; + typescript: TypeScriptConfig | null; +} diff --git a/packages/types/src/workspace-config.ts b/packages/types/src/workspace-config.ts index ed8a834ab32..c705c1a42aa 100644 --- a/packages/types/src/workspace-config.ts +++ b/packages/types/src/workspace-config.ts @@ -10,41 +10,6 @@ export interface NotifierConfig { webhookUrl: string | null; } -export type NodeVersionFormat = - | 'file' - | 'link' - | 'star' - | 'version-caret' - | 'version-tilde' - | 'version' - | 'workspace-caret' - | 'workspace-tilde' - | 'workspace'; - -export interface NodePackageManagerConfig { - version: string; -} - -export interface YarnConfig extends NodePackageManagerConfig { - plugins: string[]; -} - -export interface NodeConfig { - addEnginesConstraint: boolean; - aliasPackageNames: 'name-and-scope' | 'name-only' | null; - binExecArgs: string[]; - dedupeOnLockfileChange: boolean; - dependencyVersionFormat: NodeVersionFormat; - inferTasksFromScripts: boolean; - npm: NodePackageManagerConfig; - packageManager: 'npm' | 'pnpm' | 'yarn'; - pnpm: NodePackageManagerConfig | null; - syncProjectWorkspaceDependencies: boolean; - syncVersionManagerConfig: 'nodenv' | 'nvm' | null; - version: string; - yarn: YarnConfig | null; -} - export interface RunnerConfig { cacheLifetime: string; implicitDeps: string[]; @@ -53,14 +18,6 @@ export interface RunnerConfig { logRunningCommand: boolean; } -export interface TypeScriptConfig { - createMissingConfig: boolean; - projectConfigFileName: string; - rootConfigFileName: string; - rootOptionsConfigFileName: string; - syncProjectReferences: boolean; -} - export interface VcsConfig { defaultBranch: string; manager: 'git' | 'svn'; @@ -78,7 +35,4 @@ export interface WorkspaceConfig { | { globs: string[]; sources: Record }; runner: RunnerConfig; vcs: VcsConfig; - // Languages - node: NodeConfig | null; - typescript: TypeScriptConfig | null; } diff --git a/tests/fixtures/cases/.moon/toolchain.yml b/tests/fixtures/cases/.moon/toolchain.yml new file mode 100644 index 00000000000..c70ba1a1a8b --- /dev/null +++ b/tests/fixtures/cases/.moon/toolchain.yml @@ -0,0 +1,7 @@ +extends: '../shared-toolchain.yml' + +node: + version: '16.0.0' + addEnginesConstraint: false + dedupeOnLockfileChange: false + syncProjectWorkspaceDependencies: false diff --git a/tests/fixtures/cases/.moon/workspace.yml b/tests/fixtures/cases/.moon/workspace.yml index ca08d314596..3f8146e3574 100644 --- a/tests/fixtures/cases/.moon/workspace.yml +++ b/tests/fixtures/cases/.moon/workspace.yml @@ -21,10 +21,3 @@ projects: # Runner passthroughArgs: 'passthrough-args' - -# Put at the bottom so we can append settings to test -node: - version: '16.0.0' - addEnginesConstraint: false - dedupeOnLockfileChange: false - syncProjectWorkspaceDependencies: false diff --git a/tests/fixtures/config-extends/.moon/toolchain.yml b/tests/fixtures/config-extends/.moon/toolchain.yml new file mode 100644 index 00000000000..be365b1b6e4 --- /dev/null +++ b/tests/fixtures/config-extends/.moon/toolchain.yml @@ -0,0 +1,10 @@ +# NOTE: This is used to test config extending. Changing this will definitely break something! + +node: + version: '16.1.0' + addEnginesConstraint: false + npm: + version: '7.0.0' + +typescript: + syncProjectReferences: false diff --git a/tests/fixtures/config-extends/.moon/workspace.yml b/tests/fixtures/config-extends/.moon/workspace.yml index 05e67355e9c..cff2b54448d 100644 --- a/tests/fixtures/config-extends/.moon/workspace.yml +++ b/tests/fixtures/config-extends/.moon/workspace.yml @@ -1,13 +1,4 @@ # NOTE: This is used to test config extending. Changing this will definitely break something! -node: - version: '16.1.0' - addEnginesConstraint: false - npm: - version: '7.0.0' - -typescript: - syncProjectReferences: false - vcs: manager: 'svn' diff --git a/tests/fixtures/config-extends/toolchain/base-0.yml b/tests/fixtures/config-extends/toolchain/base-0.yml new file mode 100644 index 00000000000..b69d1e82d7d --- /dev/null +++ b/tests/fixtures/config-extends/toolchain/base-0.yml @@ -0,0 +1,3 @@ +node: + version: '1.2.3' + addEnginesConstraint: true diff --git a/tests/fixtures/config-extends/toolchain/base-1.yml b/tests/fixtures/config-extends/toolchain/base-1.yml new file mode 100644 index 00000000000..6f4176d6dda --- /dev/null +++ b/tests/fixtures/config-extends/toolchain/base-1.yml @@ -0,0 +1,6 @@ +extends: './base-0.yml' + +node: + packageManager: 'yarn' + yarn: + version: '3.0.0' diff --git a/tests/fixtures/config-extends/toolchain/base-2.yml b/tests/fixtures/config-extends/toolchain/base-2.yml new file mode 100644 index 00000000000..c0dc4031b76 --- /dev/null +++ b/tests/fixtures/config-extends/toolchain/base-2.yml @@ -0,0 +1,5 @@ +extends: './base-1.yml' + +node: + version: '4.5.6' + dedupeOnLockfileChange: false diff --git a/tests/fixtures/config-extends/workspace/typescript-0.yml b/tests/fixtures/config-extends/toolchain/typescript-0.yml similarity index 100% rename from tests/fixtures/config-extends/workspace/typescript-0.yml rename to tests/fixtures/config-extends/toolchain/typescript-0.yml diff --git a/tests/fixtures/config-extends/workspace/typescript-1.yml b/tests/fixtures/config-extends/toolchain/typescript-1.yml similarity index 100% rename from tests/fixtures/config-extends/workspace/typescript-1.yml rename to tests/fixtures/config-extends/toolchain/typescript-1.yml diff --git a/tests/fixtures/config-extends/workspace/typescript-2.yml b/tests/fixtures/config-extends/toolchain/typescript-2.yml similarity index 100% rename from tests/fixtures/config-extends/workspace/typescript-2.yml rename to tests/fixtures/config-extends/toolchain/typescript-2.yml diff --git a/tests/fixtures/config-extends/workspace/base-0.yml b/tests/fixtures/config-extends/workspace/base-0.yml index f374671b6cc..e2c3abab72c 100644 --- a/tests/fixtures/config-extends/workspace/base-0.yml +++ b/tests/fixtures/config-extends/workspace/base-0.yml @@ -1,6 +1,2 @@ runner: cacheLifetime: '3 hours' - -node: - version: '1.2.3' - addEnginesConstraint: true diff --git a/tests/fixtures/config-extends/workspace/base-1.yml b/tests/fixtures/config-extends/workspace/base-1.yml index bb49a35b4b9..1da6e9cedbd 100644 --- a/tests/fixtures/config-extends/workspace/base-1.yml +++ b/tests/fixtures/config-extends/workspace/base-1.yml @@ -3,10 +3,5 @@ extends: './base-0.yml' runner: logRunningCommand: true -node: - packageManager: 'yarn' - yarn: - version: '3.0.0' - vcs: manager: 'svn' diff --git a/tests/fixtures/config-extends/workspace/base-2.yml b/tests/fixtures/config-extends/workspace/base-2.yml index 11734862b16..334574b6593 100644 --- a/tests/fixtures/config-extends/workspace/base-2.yml +++ b/tests/fixtures/config-extends/workspace/base-2.yml @@ -2,7 +2,3 @@ extends: './base-1.yml' runner: logRunningCommand: false - -node: - version: '4.5.6' - dedupeOnLockfileChange: false diff --git a/tests/fixtures/migrate/.moon/toolchain.yml b/tests/fixtures/migrate/.moon/toolchain.yml new file mode 100644 index 00000000000..dc3814fe6d9 --- /dev/null +++ b/tests/fixtures/migrate/.moon/toolchain.yml @@ -0,0 +1 @@ +extends: '../shared-toolchain.yml' diff --git a/tests/fixtures/node-non-workspaces/.moon/toolchain.yml b/tests/fixtures/node-non-workspaces/.moon/toolchain.yml new file mode 100644 index 00000000000..dc3814fe6d9 --- /dev/null +++ b/tests/fixtures/node-non-workspaces/.moon/toolchain.yml @@ -0,0 +1 @@ +extends: '../shared-toolchain.yml' diff --git a/tests/fixtures/node-npm/.moon/toolchain.yml b/tests/fixtures/node-npm/.moon/toolchain.yml new file mode 100644 index 00000000000..f36b4a5795d --- /dev/null +++ b/tests/fixtures/node-npm/.moon/toolchain.yml @@ -0,0 +1,9 @@ +extends: '../shared-toolchain.yml' + +node: + # Use a unique version as to not collide with other tests + version: '16.1.0' + packageManager: 'npm' + npm: + version: '8.0.0' + addEnginesConstraint: false diff --git a/tests/fixtures/node-npm/.moon/workspace.yml b/tests/fixtures/node-npm/.moon/workspace.yml index cf65a884d6c..ae18d35f4c0 100644 --- a/tests/fixtures/node-npm/.moon/workspace.yml +++ b/tests/fixtures/node-npm/.moon/workspace.yml @@ -1,13 +1,5 @@ extends: '../shared-workspace.yml' -node: - # Use a unique version as to not collide with other tests - version: '16.1.0' - packageManager: 'npm' - npm: - version: '8.0.0' - addEnginesConstraint: false - projects: npm: base other: other diff --git a/tests/fixtures/node-pnpm/.moon/toolchain.yml b/tests/fixtures/node-pnpm/.moon/toolchain.yml new file mode 100644 index 00000000000..83e249bdd1c --- /dev/null +++ b/tests/fixtures/node-pnpm/.moon/toolchain.yml @@ -0,0 +1,9 @@ +extends: '../shared-toolchain.yml' + +node: + # Use a unique version as to not collide with other tests + version: '16.2.0' + packageManager: 'pnpm' + pnpm: + version: '7.5.0' + addEnginesConstraint: false diff --git a/tests/fixtures/node-pnpm/.moon/workspace.yml b/tests/fixtures/node-pnpm/.moon/workspace.yml index dacdd7e0557..10757b49286 100644 --- a/tests/fixtures/node-pnpm/.moon/workspace.yml +++ b/tests/fixtures/node-pnpm/.moon/workspace.yml @@ -1,13 +1,5 @@ extends: '../shared-workspace.yml' -node: - # Use a unique version as to not collide with other tests - version: '16.2.0' - packageManager: 'pnpm' - pnpm: - version: '7.5.0' - addEnginesConstraint: false - projects: pnpm: base other: other diff --git a/tests/fixtures/node-yarn/.moon/toolchain.yml b/tests/fixtures/node-yarn/.moon/toolchain.yml new file mode 100644 index 00000000000..d05867fd033 --- /dev/null +++ b/tests/fixtures/node-yarn/.moon/toolchain.yml @@ -0,0 +1,11 @@ +extends: '../shared-toolchain.yml' + +node: + # Use a unique version as to not collide with other tests because of corepack + version: '16.4.0' + packageManager: 'yarn' + yarn: + version: '3.0.0' + plugins: + - 'workspace-tools' + addEnginesConstraint: false diff --git a/tests/fixtures/node-yarn/.moon/workspace.yml b/tests/fixtures/node-yarn/.moon/workspace.yml index a46c639cb51..586b9f49572 100644 --- a/tests/fixtures/node-yarn/.moon/workspace.yml +++ b/tests/fixtures/node-yarn/.moon/workspace.yml @@ -1,15 +1,5 @@ extends: '../shared-workspace.yml' -node: - # Use a unique version as to not collide with other tests because of corepack - version: '16.4.0' - packageManager: 'yarn' - yarn: - version: '3.0.0' - plugins: - - 'workspace-tools' - addEnginesConstraint: false - projects: yarn: base other: other diff --git a/tests/fixtures/node-yarn1/.moon/toolchain.yml b/tests/fixtures/node-yarn1/.moon/toolchain.yml new file mode 100644 index 00000000000..94761d22092 --- /dev/null +++ b/tests/fixtures/node-yarn1/.moon/toolchain.yml @@ -0,0 +1,9 @@ +extends: '../shared-toolchain.yml' + +node: + # Use a unique version as to not collide with other tests because of corepack + version: '16.3.0' + packageManager: 'yarn' + yarn: + version: '1.22.0' + addEnginesConstraint: false diff --git a/tests/fixtures/node-yarn1/.moon/workspace.yml b/tests/fixtures/node-yarn1/.moon/workspace.yml index 59be6f0d2b9..586b9f49572 100644 --- a/tests/fixtures/node-yarn1/.moon/workspace.yml +++ b/tests/fixtures/node-yarn1/.moon/workspace.yml @@ -1,13 +1,5 @@ extends: '../shared-workspace.yml' -node: - # Use a unique version as to not collide with other tests because of corepack - version: '16.3.0' - packageManager: 'yarn' - yarn: - version: '1.22.0' - addEnginesConstraint: false - projects: yarn: base other: other diff --git a/tests/fixtures/node/.moon/toolchain.yml b/tests/fixtures/node/.moon/toolchain.yml new file mode 100644 index 00000000000..cf9a55b27be --- /dev/null +++ b/tests/fixtures/node/.moon/toolchain.yml @@ -0,0 +1,12 @@ +extends: '../shared-toolchain.yml' + +typescript: + syncProjectReferences: false + +# Put at the bottom so we can append settings to test +node: + # Use a unique version as to not collide with other tests + version: '16.1.0' + addEnginesConstraint: false + dedupeOnLockfileChange: false + syncProjectWorkspaceDependencies: false diff --git a/tests/fixtures/node/.moon/workspace.yml b/tests/fixtures/node/.moon/workspace.yml index 31f07fc8b65..59b227c5a98 100644 --- a/tests/fixtures/node/.moon/workspace.yml +++ b/tests/fixtures/node/.moon/workspace.yml @@ -14,14 +14,3 @@ projects: depsD: 'deps-d' dependsOn: 'depends-on' dependsOnScopes: 'depends-on-scopes' - -typescript: - syncProjectReferences: false - -# Put at the bottom so we can append settings to test -node: - # Use a unique version as to not collide with other tests - version: '16.1.0' - addEnginesConstraint: false - dedupeOnLockfileChange: false - syncProjectWorkspaceDependencies: false diff --git a/tests/fixtures/node/version-override/moon.yml b/tests/fixtures/node/version-override/moon.yml index e9902161ee6..908357930e4 100644 --- a/tests/fixtures/node/version-override/moon.yml +++ b/tests/fixtures/node/version-override/moon.yml @@ -1,5 +1,5 @@ language: javascript -workspace: +toolchain: node: version: '18.0.0' diff --git a/tests/fixtures/project-graph/aliases/.moon/toolchain.yml b/tests/fixtures/project-graph/aliases/.moon/toolchain.yml new file mode 100644 index 00000000000..f2a1c180997 --- /dev/null +++ b/tests/fixtures/project-graph/aliases/.moon/toolchain.yml @@ -0,0 +1,4 @@ +extends: '../shared-toolchain.yml' + +node: + aliasPackageNames: 'name-and-scope' diff --git a/tests/fixtures/project-graph/aliases/.moon/workspace.yml b/tests/fixtures/project-graph/aliases/.moon/workspace.yml index 87bbad18ddd..8e05f1f6fc1 100644 --- a/tests/fixtures/project-graph/aliases/.moon/workspace.yml +++ b/tests/fixtures/project-graph/aliases/.moon/workspace.yml @@ -1,8 +1,5 @@ extends: '../shared-workspace.yml' -node: - aliasPackageNames: 'name-and-scope' - projects: noLang: no-lang node: node diff --git a/tests/fixtures/projects/.moon/toolchain.yml b/tests/fixtures/projects/.moon/toolchain.yml new file mode 100644 index 00000000000..dc3814fe6d9 --- /dev/null +++ b/tests/fixtures/projects/.moon/toolchain.yml @@ -0,0 +1 @@ +extends: '../shared-toolchain.yml' diff --git a/tests/fixtures/shared-toolchain.yml b/tests/fixtures/shared-toolchain.yml new file mode 100644 index 00000000000..85c6309963b --- /dev/null +++ b/tests/fixtures/shared-toolchain.yml @@ -0,0 +1,9 @@ +node: + version: '16.0.0' + dedupeOnLockfileChange: false + +typescript: + createMissingConfig: false + routeOutDirToCache: false + syncProjectReferences: false + syncProjectReferencesToPaths: false diff --git a/tests/fixtures/shared-workspace.yml b/tests/fixtures/shared-workspace.yml index b4be93368a8..b117f8a6ff8 100644 --- a/tests/fixtures/shared-workspace.yml +++ b/tests/fixtures/shared-workspace.yml @@ -1,11 +1 @@ -node: - version: '16.0.0' - dedupeOnLockfileChange: false - -typescript: - createMissingConfig: false - routeOutDirToCache: false - syncProjectReferences: false - syncProjectReferencesToPaths: false - projects: {} diff --git a/tests/fixtures/tasks/.moon/toolchain.yml b/tests/fixtures/tasks/.moon/toolchain.yml new file mode 100644 index 00000000000..dc3814fe6d9 --- /dev/null +++ b/tests/fixtures/tasks/.moon/toolchain.yml @@ -0,0 +1 @@ +extends: '../shared-toolchain.yml' diff --git a/tests/fixtures/typescript/.moon/toolchain.yml b/tests/fixtures/typescript/.moon/toolchain.yml new file mode 100644 index 00000000000..1f0be78ce7d --- /dev/null +++ b/tests/fixtures/typescript/.moon/toolchain.yml @@ -0,0 +1,7 @@ +extends: '../shared-toolchain.yml' + +typescript: + createMissingConfig: true + routeOutDirToCache: false + syncProjectReferences: true + syncProjectReferencesToPaths: false diff --git a/tests/fixtures/typescript/.moon/workspace.yml b/tests/fixtures/typescript/.moon/workspace.yml index f45988fa1d0..45222fca493 100644 --- a/tests/fixtures/typescript/.moon/workspace.yml +++ b/tests/fixtures/typescript/.moon/workspace.yml @@ -2,9 +2,3 @@ extends: '../shared-workspace.yml' projects: - '*' - -typescript: - createMissingConfig: true - routeOutDirToCache: false - syncProjectReferences: true - syncProjectReferencesToPaths: false diff --git a/tests/fixtures/typescript/create-config-disabled/moon.yml b/tests/fixtures/typescript/create-config-disabled/moon.yml index 6cb1decb69c..131c64fdfe3 100644 --- a/tests/fixtures/typescript/create-config-disabled/moon.yml +++ b/tests/fixtures/typescript/create-config-disabled/moon.yml @@ -1,2 +1,2 @@ -workspace: +toolchain: typescript: false diff --git a/tests/fixtures/typescript/deps-no-config-disabled/moon.yml b/tests/fixtures/typescript/deps-no-config-disabled/moon.yml index 6cb1decb69c..131c64fdfe3 100644 --- a/tests/fixtures/typescript/deps-no-config-disabled/moon.yml +++ b/tests/fixtures/typescript/deps-no-config-disabled/moon.yml @@ -1,2 +1,2 @@ -workspace: +toolchain: typescript: false diff --git a/tests/fixtures/typescript/deps-with-config-disabled/moon.yml b/tests/fixtures/typescript/deps-with-config-disabled/moon.yml index 6cb1decb69c..131c64fdfe3 100644 --- a/tests/fixtures/typescript/deps-with-config-disabled/moon.yml +++ b/tests/fixtures/typescript/deps-with-config-disabled/moon.yml @@ -1,2 +1,2 @@ -workspace: +toolchain: typescript: false diff --git a/website/blog/2022-09-01_v0.13.mdx b/website/blog/2022-09-01_v0.13.mdx index c5ebde5d2e3..5b329c0e87d 100644 --- a/website/blog/2022-09-01_v0.13.mdx +++ b/website/blog/2022-09-01_v0.13.mdx @@ -1,6 +1,6 @@ --- slug: v0.13 -title: v0.13 - Hashing and toolchain improvements +title: moon v0.13 - Hashing and toolchain improvements authors: [milesj] tags: [hasher, toolchain] --- diff --git a/website/blog/2022-09-13_v0.14.mdx b/website/blog/2022-09-13_v0.14.mdx index 754e90e96e3..ee3fd853076 100644 --- a/website/blog/2022-09-13_v0.14.mdx +++ b/website/blog/2022-09-13_v0.14.mdx @@ -1,6 +1,6 @@ --- slug: v0.14 -title: v0.14 - Code generation and implicit dependencies +title: moon v0.14 - Code generation and implicit dependencies authors: [milesj] tags: [generator, project-graph, ci] --- diff --git a/website/blog/2022-09-26_v0.15.mdx b/website/blog/2022-09-26_v0.15.mdx index 2cacea995c2..2ba81930d9f 100644 --- a/website/blog/2022-09-26_v0.15.mdx +++ b/website/blog/2022-09-26_v0.15.mdx @@ -1,6 +1,6 @@ --- slug: v0.15 -title: v0.15 - Enhanced Docker support and 1,000 stars! +title: moon v0.15 - Enhanced Docker support and 1,000 stars! authors: [milesj] tags: [generator, docker] image: ./img/v0.15.png diff --git a/website/blog/2022-10-06_v0.16.mdx b/website/blog/2022-10-06_v0.16.mdx index fa5a70c74de..fe99ff36ac7 100644 --- a/website/blog/2022-10-06_v0.16.mdx +++ b/website/blog/2022-10-06_v0.16.mdx @@ -1,6 +1,6 @@ --- slug: v0.16 -title: v0.16 - Per-project tool versions and TypeScript improvements +title: moon v0.16 - Per-project tool versions and TypeScript improvements authors: [milesj] tags: [toolchain, runner, generator, typescript, node] image: ./img/v0.16.png @@ -66,7 +66,7 @@ unfortunate as each project folder is now littered with the declaration outputs, gitignored. To improve this experience, we're introducing a new setting -[`typescript.routeOutDirToCache`](../docs/config/workspace#routeoutdirtocache), that will update the +[`typescript.routeOutDirToCache`](../docs/config/toolchain#routeoutdirtocache), that will update the `outDir` compiler option of _all_ projects to route to moon's cache directory (which should already be gitignored). This will standardize the use of project references for the entire repository. @@ -89,9 +89,9 @@ For example, a project at "packages/components" will route to the following outp ### Mapping project references as `paths` moon automatically keeps TypeScript project references in sync with the -[`typescript.syncProjectReferences`](../docs/config/workspace#syncprojectreferences) setting, which +[`typescript.syncProjectReferences`](../docs/config/toolchain#syncprojectreferences) setting, which is great, but we can take it further. With the new -[`typescript.syncProjectReferencesToPaths`](../docs/config/workspace#syncprojectreferencestopaths) +[`typescript.syncProjectReferencesToPaths`](../docs/config/toolchain#syncprojectreferencestopaths) setting, project references (either synced or explicitly defined) will _also_ be mapped to the `paths` compiler option, automating the list of import aliases. diff --git a/website/blog/2022-10-21_v0.17.mdx b/website/blog/2022-10-21_v0.17.mdx index e8559dd35d7..95316ca863d 100644 --- a/website/blog/2022-10-21_v0.17.mdx +++ b/website/blog/2022-10-21_v0.17.mdx @@ -1,6 +1,6 @@ --- slug: v0.17 -title: v0.17 - Webhooks, extended YAML, and improved runtime performance +title: moon v0.17 - Webhooks, extended YAML, and improved runtime performance authors: [milesj] tags: [notifier, runner, config, editors, vscode] image: ./img/v0.17.png diff --git a/website/blog/2022-10-31_v0.18.mdx b/website/blog/2022-10-31_v0.18.mdx index 86fd8dc7f39..fdf1d87c61a 100644 --- a/website/blog/2022-10-31_v0.18.mdx +++ b/website/blog/2022-10-31_v0.18.mdx @@ -1,6 +1,6 @@ --- slug: v0.18 -title: v0.18 - Improved configuration and initialization flow +title: moon v0.18 - Improved configuration and initialization flow authors: [milesj] tags: [projects, config, init, node] image: ./img/v0.18.png @@ -55,7 +55,7 @@ binary, instead of relying on the binary found in the developer's environment. B What if you wanted to use an [experimental loader](https://nodejs.org/api/esm.html#loaders) and execute TypeScript code at _runtime_? Or to preserve symlinks? Well, you couldn't... but no longer, -as we've added a new setting, [`node.binExecArgs`](../docs/config/workspace#binexecargs), that +as we've added a new setting, [`node.binExecArgs`](../docs/config/toolchain#binexecargs), that allows additional `node` [CLI arguments](https://nodejs.org/api/cli.html#options) to be defined, that will be passed to _all_ executions. diff --git a/website/blog/2022-11-14_v0.19.mdx b/website/blog/2022-11-14_v0.19.mdx index 1e0ef327ebd..92699bb6124 100644 --- a/website/blog/2022-11-14_v0.19.mdx +++ b/website/blog/2022-11-14_v0.19.mdx @@ -1,6 +1,6 @@ --- slug: v0.19 -title: v0.19 - Remote caching beta, affected files, and graph optimization +title: moon v0.19 - Remote caching beta, affected files, and graph optimization authors: [milesj] tags: [affected, remote-cache, dep-graph] image: ./img/v0.19.png diff --git a/website/blog/2022-11-28_v0.20.mdx b/website/blog/2022-11-28_v0.20.mdx index 0349ea0563b..2ad395c9902 100644 --- a/website/blog/2022-11-28_v0.20.mdx +++ b/website/blog/2022-11-28_v0.20.mdx @@ -1,22 +1,67 @@ --- slug: v0.20 -title: v0.20 - ??? +title: moon v0.20 - Future proofing and toolchain/hydration improvements authors: [milesj] -tags: [hydration] -# image: ./img/v0.19.png +tags: [hydration, toolchain, generator] +# image: ./img/v0.20.png --- -TODO +With this release, we've focused heavily on future proofing our toolchain, and how it integrates +with moon. We've also landed a handful of quality of life improvements. -## Toolchain next steps +## Breaking changes + +To start, we have a few breaking changes this release to be aware of! + +### Moved toolchain settings + +The [`.moon/workspace.yml`](../docs/config/workspace) config file was getting rather bloated and +complicated, as it contained the projects list, settings for each toolchain language, and each +supported service (runner, generator, etc). Furthermore, this file will keep getting larger with +each new language and service we support. + +To future proof moon, and to land as many breaking changes before an official v1, we've decided to +move toolchain specific settings into a new file, [`.moon/toolchain.yml`](../docs/config/toolchain). +This new file will house all language and dependency manager specific settings. + +To migrate, move the `node` and `typescript` settings from `.moon/workspace.yml` to +`.moon/toolchain.yml`. + +```yaml title=".moon/toolchain.yml" +node: + # ... + +typescript: + # ... +``` + +### Moved project-level overrides + +Continuing with the changes above, we've also moved the `workspace.node` and `workspace.typescript` +from [`moon.yml`](../docs/config/project) into a new parent field, `toolchain`. We think this makes +more sense. + +```yaml title="moon.yml" +# Before +workspace: + node: + version: '...' + +# After +toolchain: + node: + version: '...' +``` + +## Future of the toolchain We're really proud of our toolchain, as it avoids an array problems that developers deal with on a day to day basis, primarily around running tasks using the wrong version of Node.js or their chosen -package manager. While we're in the process of supporting additional languages, starting with Deno, -we had an idea... Since this is basically a better "version manager for tools", why not extract this -out into something else? +package manager. While we're in the process of supporting additional languages, starting with +[Deno](https://deno.land/), we had an idea... Since this is basically a better "version manager for +tools", why not extract this out into something else? And that's what we plan to do! Before we do so, we've had to make some architectural changes, many of which have landed in this release. During this process, we were able to implement an even better @@ -58,12 +103,17 @@ View the [official release](https://github.com/moonrepo/moon/releases/tag/%40moonrepo%2Fcli%400.20.0) for a full list of changes. +- Added `vcs.remoteCandidates` to `.moon/workspace.yml` to customize the remotes for git to query + against. - Added support for `moduleSuffixes` and `moduleDetection` in TypeScript `tsconfig.json` compiler options. - YAML files will now respect the closest `.editorconfig` file. +- Refactored terminal output for bette readability. ## What's next? Expect the following in the v0.21 release! -- ??? +- An interactive dependency and project graph visualizer. +- A more performant project graph. +- More quality of life improvements for affected files. diff --git a/website/docs/concepts/project.mdx b/website/docs/concepts/project.mdx index 363ad57a73a..3fa6deb127c 100644 --- a/website/docs/concepts/project.mdx +++ b/website/docs/concepts/project.mdx @@ -70,4 +70,4 @@ following functionality is enabled. references (when applicable). > File name can be customized with the -> [`typescript.projectConfigFileName`](../config/workspace#projectconfigfilename) setting. +> [`typescript.projectConfigFileName`](../config/toolchain#projectconfigfilename) setting. diff --git a/website/docs/concepts/toolchain.mdx b/website/docs/concepts/toolchain.mdx index 7ba3d744568..2fba06a4224 100644 --- a/website/docs/concepts/toolchain.mdx +++ b/website/docs/concepts/toolchain.mdx @@ -31,7 +31,7 @@ tool to `~/.moon/tools//`. ## Configuration The tools that are managed by the toolchain are configured through the -[`.moon/workspace.yml`](../config/workspace) file, but can be overridden in each project with +[`.moon/toolchain.yml`](../config/toolchain) file, but can be overridden in each project with [`moon.yml`](../config/project). ## Supported tools @@ -46,33 +46,33 @@ The following tools will be managed by the toolchain. Since moon was designed for JavaScript based repo's, we intentionally support Node.js as a first-class citizen within the toolchain. Because of this, Node.js is _always enabled_. -- Configured with: [`node`](../config/workspace#node) +- Configured with: [`node`](../config/toolchain#node) - Installed to: `~/.moon/tools/node/x.x.x` #### npm The `npm` binary comes pre-installed with Node.js, and will _always exist_, regardless of the -[`node.packageManager`](../config/workspace#packagemanager) setting. +[`node.packageManager`](../config/toolchain#packagemanager) setting. -- Configured with: [`node.npm`](../config/workspace#npm-pnpm-yarn) +- Configured with: [`node.npm`](../config/toolchain#npm-pnpm-yarn) - Installed to: `~/.moon/tools/npm/x.x.x` #### pnpm The [`pnpm`](https://pnpm.io) library can be used as an alternative package manager to npm, and will -be enabled when [`node.packageManager`](../config/workspace#packagemanager) is set to "pnpm". The +be enabled when [`node.packageManager`](../config/toolchain#packagemanager) is set to "pnpm". The binary will be installed as a toolchain global npm dependency. -- Configured with: [`node.pnpm`](../config/workspace#npm-pnpm-yarn) +- Configured with: [`node.pnpm`](../config/toolchain#npm-pnpm-yarn) - Installed to: `~/.moon/tools/pnpm/x.x.x` #### yarn The [`yarn`](https://yarnpkg.com) library can be used as an alternative package manager to npm, and -will be enabled when [`node.packageManager`](../config/workspace#packagemanager) is set to "yarn". +will be enabled when [`node.packageManager`](../config/toolchain#packagemanager) is set to "yarn". The binary will be installed as a toolchain global npm dependency. -- Configured with: [`node.yarn`](../config/workspace#npm-pnpm-yarn) +- Configured with: [`node.yarn`](../config/toolchain#npm-pnpm-yarn) - Installed to: `~/.moon/tools/yarn/x.x.x` > Supports v1 and v2/v3 (only `node-modules` linker mode currently). diff --git a/website/docs/config/global-project.mdx b/website/docs/config/global-project.mdx index dc3ac5f2a27..af97a50abbd 100644 --- a/website/docs/config/global-project.mdx +++ b/website/docs/config/global-project.mdx @@ -17,7 +17,7 @@ Defines an external `.moon/project.yml` to extend and inherit settings from. Per and sharing configuration across repositories and projects. When defined, this setting must be an HTTPS URL _or_ relative file system path that points to a valid YAML document! -```yaml title=".moon/workspace.yml" {1} +```yaml title=".moon/project.yml" {1} extends: 'https://raw.githubusercontent.com/organization/repository/master/.moon/project.yml' ``` diff --git a/website/docs/config/project.mdx b/website/docs/config/project.mdx index cfcb76f8cf0..9ac7d134df0 100644 --- a/website/docs/config/project.mdx +++ b/website/docs/config/project.mdx @@ -625,9 +625,42 @@ tasks: > This field exists because of our [toolchain](../concepts/toolchain), and moon ensuring the correct > command is ran. -## Workspace overrides +## Overrides -Dictates how a project interacts with settings defined at the workspace-level. +Dictates how a project interacts with settings defined at the top-level. + +## `toolchain` + + + +### `node` + + + +Configures Node.js for this project and overrides the top-level [`node`](./toolchain#node) setting. +Currently, only the Node.js version can be overridden per-project, not the package manager. + +#### `version` + +Defines the explicit Node.js version to use when _running tasks_ for this project. + +```yaml title="moon.yml" {2,3} +toolchain: + node: + version: '12.12.0' +``` + +### `typescript` + + + +Enables or disables [TypeScript support](./toolchain#typescript) for this project. Currently +controls project reference syncing and `tsconfig.json` creation. Defaults to `true`. + +```yaml title="moon.yml" {2} +toolchain: + typescript: false +``` ## `workspace` @@ -693,32 +726,3 @@ workspace: ``` > Renaming occurs after inclusion and exclusion. - -### `node` - - - -Configures Node.js for this project and overrides the workspace-level [`node`](./workspace#node) -setting. Currently, only the Node.js version can be overridden per-project, not the package manager. - -#### `version` - -Defines the explicit Node.js version to use when _running tasks_ for this project. - -```yaml title="moon.yml" {2} -workspace: - node: - version: '12.12.0' -``` - -### `typescript` - - - -Enables or disables [TypeScript support](./workspace#typescript) for this project. Currently -controls project reference syncing and `tsconfig.json` creation. Defaults to `true`. - -```yaml title="moon.yml" {2} -workspace: - typescript: false -``` diff --git a/website/docs/config/toolchain.mdx b/website/docs/config/toolchain.mdx new file mode 100644 index 00000000000..26d140ad654 --- /dev/null +++ b/website/docs/config/toolchain.mdx @@ -0,0 +1,457 @@ +--- +title: .moon/toolchain.yml +toc_max_heading_level: 6 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import HeadingApiLink from '@site/src/components/Docs/HeadingApiLink'; +import RequiredLabel from '@site/src/components/Docs/RequiredLabel'; +import VersionLabel from '@site/src/components/Docs/VersionLabel'; + + + +The `.moon/toolchain.yml` file configures the toolchain and the workspace development environment. + +## `extends` + + + +Defines an external `.moon/toolchain.yml` to extend and inherit settings from. Perfect for +reusability and sharing configuration across repositories and projects. When defined, this setting +must be an HTTPS URL _or_ relative file system path that points to a valid YAML document! + +```yaml title=".moon/toolchain.yml" {1} +extends: 'https://raw.githubusercontent.com/organization/repository/master/.moon/toolchain.yml' +``` + +:::caution + +Settings will be merged recursively for blocks, with values defined in the local configuration +taking precedence over those defined in the extended configuration. + +::: + +## `node` + + + +Defines the Node.js version and package manager to install within the toolchain, as moon _does not_ +use a Node.js binary found on the local machine. Managing the Node.js version within the toolchain +ensures a deterministic environment across any machine (whether a developer, CI, or production +machine). + +### `version` + + + +Defines the explicit Node.js version to use. We require an explicit and semantic major, minor, and +patch version, to ensure the same environment is used across every machine. Ranges are _not_ +supported. + +```yaml title=".moon/toolchain.yml" {2} +node: + version: '16.13.0' +``` + +> Version can be overridden with the `MOON_NODE_VERSION` environment variable. + +### `packageManager` + + + +Defines which package manager to utilize. Supports `npm` (default), `pnpm`, or `yarn`. + +```yaml title=".moon/toolchain.yml" {2} +node: + packageManager: 'yarn' +``` + +### `npm`, `pnpm`, `yarn` + + + +Optional fields for defining package manager specific configuration. The chosen setting is dependent +on the value of [`node.packageManager`](#packagemanager). If these settings _are not defined_, the +latest version of the active package manager will be used (when applicable). + +#### `version` + + + +The `version` setting defines the explicit package manager version to use. We require an explicit +major, minor, and patch version, to ensure the same environment is used across every machine. + +```yaml title=".moon/toolchain.yml" {4} +node: + packageManager: 'yarn' + yarn: + version: '3.1.0' +``` + +> Version can be overridden with the `MOON_NPM_VERSION`, `MOON_PNPM_VERSION`, or `MOON_YARN_VERSION` +> environment variables. + +### `yarn` + + + +#### `plugins` + + + +A list of plugins that will automatically be imported using `yarn plugin import` (Yarn 2+ only). For +performance reasons, plugins will only be imported when the Yarn version changes. + +```yaml title=".moon/toolchain.yml" {4} +node: + packageManager: 'yarn' + yarn: + version: '3.1.0' + plugins: + - 'interactive-tools' + - 'workspace-tools' +``` + +### `addEnginesConstraint` + + + +Injects the currently configured [Node.js version](#version) as an `engines` constraint to the root +`package.json` field. Defaults to `true`. + +```yaml +node: + addEnginesConstraint: true +``` + +For example, say our Node.js version is "16.15.0", and when we execute a run process through the +`moon` binary, it will update the root `package.json` with the below. We pin a fixed version to +ensure other Node.js processes outside of our toolchain are utilizing the same version. + +```json title="package.json" +{ + // ... + "engines": { + "node": "16.15.0" + } +} +``` + +### `aliasPackageNames` + + + +When enabled, will assign [aliases](../concepts/project#aliases) to configured [projects](#projects) +based on the `name` field in the project's `package.json`. Aliases can be used as a substitute for +project names, allowing for the familiar package name to be used within +[targets](../concepts/target) or configuration. + +This setting accepts one of the following values, which determines how to parse and assign the +alias. + +- `name-and-scope` - Will use the package name as-is, including any scope. For example, + `@scope/example` or `example`. +- `name-only` - Will only use the name and disregard any scope. For example, `@scope/example` will + become `example`. + +```yaml title=".moon/toolchain.yml" {2} +node: + aliasPackageNames: 'name-only' +``` + +### `binExecArgs` + + + +Additional [command line arguments](https://nodejs.org/api/cli.html) to pass to the `node` binary +when it's being executed by running a target. This will apply arguments to _all Node.js based_ +targets, and cannot be changed on a per target basis. + +```yaml title=".moon/toolchain.yml" {2-5} +node: + binExecArgs: + - '--preserve-symlinks' + - '--loader' + - '@boost/module/loader' +``` + +### `dedupeOnLockfileChange` + + + +Will dedupe dependencies after they have been installed, added, removing, or changed in any way, in +an effort to keep the workspace tree as clean and lean as possible. Defaults to `true`. + +```yaml title=".moon/toolchain.yml" {2} +node: + dedupeOnLockfileChange: true +``` + +### `dependencyVersionFormat` + + + +When [syncing project dependencies](#syncprojectworkspacedependencies), customize the format that +will be used for the dependency version range. The following formats are supported (but use the one +most applicable to your chosen package manager): + +- `file` - Uses `file:../relative/path` and copies package contents. +- `link` - Uses `link:../relative/path` and symlinks package contents. +- `star` - Uses an explicit `*`. +- `version` - Uses the explicit version from the dependent project's `package.json`, e.g., "1.2.3". +- `version-caret` - Uses the version from the dependent project's `package.json` as a caret range, + e.g., "^1.2.3". +- `version-tilde` - Uses the version from the dependent project's `package.json` as a tilde range, + e.g., "~1.2.3". +- `workspace` (default) - Uses `workspace:*`, which resolves to "1.2.3". Requires package + workspaces. +- `workspace-caret` - Uses `workspace:^`, which resolves to "^1.2.3". Requires package workspaces. +- `workspace-tilde` - Uses `workspace:~`, which resolves to "~1.2.3". Requires package workspaces. + +```yaml title=".moon/toolchain.yml" {2} +node: + dependencyVersionFormat: 'link' +``` + +> This setting does not apply to peer dependencies, as they will always use a format of +> `^.0.0`. + +### `inferTasksFromScripts` + + + +Will infer and automatically create [tasks](../concepts/task) from `package.json` scripts. Defaults +to `false`. + +This requires the [project's language](./project#language) to be "javascript" or "typescript", a +`package.json` to exist in the project, and will take the following into account: + +- Script names will be converted to kebab-case, and will become the task ID. +- Pre, post, and life cycle hooks are ignored. +- Tasks defined in `.moon/project.yml` or `moon.yml` take precedence over scripts of the same name. + +To verify inferred tasks, run [`moon project `](../commands/project) (pass `--json` to view raw +config and options). Tasks that are inferred will have their command and args set to +`moon node run-script`. + +```yaml title=".moon/toolchain.yml" {2} +node: + inferTasksFromScripts: true +``` + +:::caution + +This implementation shares functionality with +[`moon migrate from-package-json`](../commands/migrate/from-package-json), and will attempt to +determine environment variables, outputs, CI options, and more! Be aware of these when utilizing +this feature, especially in regards to `runInCI`, as it may be inaccurate! + +::: + +### `syncProjectWorkspaceDependencies` + + + +Will sync a project's [`dependsOn`](./project#dependson) setting as normal dependencies within the +project's `package.json`. If a dependent project does not have a `package.json`, or if a dependency +of the same name has an explicit version already defined, the sync will be skipped. Defaults to +`true`. + +```yaml title=".moon/toolchain.yml" {2} +node: + syncProjectWorkspaceDependencies: true +``` + +A quick example on how this works. Given the following `dependsOn`: + +```yaml title="moon.yml" +dependsOn: + - 'designSystem' + - 'reactHooks' +``` + +Would result in the following `dependencies` within a project's `package.json`. The version format +can be customized with [`node.dependencyVersionFormat`](#dependencyversionformat). + +```json title="package.json" +{ + // ... + "dependencies": { + "@company/design-system": "workspace:*", + "@company/react-hooks": "workspace:*" + // ... + } +} +``` + +### `syncVersionManagerConfig` + + + +Will sync the currently configured [Node.js version](#version) to a 3rd-party version manager's +config/rc file. Supports "nodenv" (syncs to `.node-version`), "nvm" (syncs to `.nvmrc`), or none +(default). + +```yaml title=".moon/toolchain.yml" {2} +node: + syncVersionManagerConfig: 'nvm' +``` + +This is a special setting that ensure other Node.js processes outside of our toolchain are utilizing +the same version, which is a very common practice when managing dependencies. + +## `typescript` + + + +Dictates how moon interacts with and utilizes TypeScript within the workspace. This field is +optional and is undefined by default. Define it to enable TypeScript support. + +### `createMissingConfig` + + + +When [syncing project references](#syncprojectreferences) and a depended on project _does not_ have +a `tsconfig.json`, automatically create one. Defaults to `true`. + +```yaml title=".moon/toolchain.yml" {2} +typescript: + createMissingConfig: true +``` + +### `projectConfigFileName` + + + +Defines the file name of the `tsconfig.json` found in the project root. We utilize this setting when +syncing project references between projects. Defaults to `tsconfig.json`. + +```yaml title=".moon/toolchain.yml" {2} +typescript: + projectConfigFileName: 'tsconfig.build.json' +``` + +### `rootConfigFileName` + + + +Defines the file name of the `tsconfig.json` found in the workspace root. We utilize this setting +when syncing projects as references. Defaults to `tsconfig.json`. + +```yaml title=".moon/toolchain.yml" {2} +typescript: + rootConfigFileName: 'tsconfig.projects.json' +``` + +### `rootOptionsConfigFileName` + + + +Defines the file name of the config file found in the workspace root that houses shared compiler +options. Defaults to `tsconfig.options.json`. This setting is used in the following scenarios: + +- When [creating a `tsconfig.json` for a project](#), sets the `extends` field to this value. + +```yaml title=".moon/toolchain.yml" {2} +typescript: + rootOptionsConfigFileName: 'tsconfig.base.json' +``` + +### `routeOutDirToCache` + + + +Updates the `outDir` compiler option in each project's [`tsconfig.json`](#projectConfigFileName) to +route to moon's cache folder. This is useful when using project references and wanting to keep all +the compiled `.d.ts` files _out_ of the project folder. Defaults to `false`. + +```yaml title=".moon/toolchain.yml" {2} +typescript: + routeOutDirToCache: true +``` + +As a demonstration, if we had an npm package located at "packages/components", the `outDir` compiler +option will be re-routed to the following when syncing. + +```json title="/tsconfig.json" +{ + // ... + "compilerOptions": { + // ... + "outDir": "../../.moon/cache/types/packages/components" + } +} +``` + +### `syncProjectReferences` + + + +Will sync a project's [dependencies](../concepts/project#dependencies) (when applicable) as project +references within that project's `tsconfig.json`, and the workspace root `tsconfig.json`. Defaults +to `true` when the parent `typescript` setting is defined, otherwise `false`. + +```yaml title=".moon/toolchain.yml" {2} +typescript: + syncProjectReferences: true +``` + +A quick example on how this works. Given the following `dependsOn`: + +```yaml title="moon.yml" +dependsOn: + - 'designSystem' + - 'reactHooks' +``` + +Would result in the following `references` within both `tsconfig.json`s. + +```json title="tsconfig.json" +{ + // ... + "references": [ + // ... + { "path": "../../design-system" }, + { "path": "../../react-hooks" } + ] +} +``` + +### `syncProjectReferencesToPaths` + + + +Will sync a project's [`tsconfig.json`](#projectConfigFileName) project references to the `paths` +compiler option, using the referenced project's `package.json` name. This is useful for mapping +import aliases to their source code. Defaults to `false`. + +```yaml title=".moon/toolchain.yml" {2} +typescript: + syncProjectReferencesToPaths: true +``` + +As a demonstration, if we had a reference to a shared npm package with the name `@brand/components`, +the `paths` compiler option would be updated to the following when syncing. The index file may exist +in a `src` folder, or the root of the package. + +```json title="/tsconfig.json" +{ + // ... + "compilerOptions": { + // ... + "paths": { + "@brand/components": ["../shared/components/src/index.ts"], + "@brand/components/*": ["../shared/components/src/*"] + } + }, + "references": [ + { + "path": "../shared/components" + } + ] +} +``` + +> This setting runs _after_ [`syncProjectReferences`](#syncprojectreferences) and will inherit any +> synced references from that setting. diff --git a/website/docs/config/workspace.mdx b/website/docs/config/workspace.mdx index a3476f79c38..a1f34e509ce 100644 --- a/website/docs/config/workspace.mdx +++ b/website/docs/config/workspace.mdx @@ -9,8 +9,7 @@ import HeadingApiLink from '@site/src/components/Docs/HeadingApiLink'; import RequiredLabel from '@site/src/components/Docs/RequiredLabel'; import VersionLabel from '@site/src/components/Docs/VersionLabel'; -The `.moon/workspace.yml` file configures available projects and their locations, the toolchain, and -the workspace development environment. +The `.moon/workspace.yml` file configures projects and services in the workspace. ## `extends` @@ -90,435 +89,6 @@ projects: www: 'www' ``` -## Languages - -## `node` - - - -Defines the Node.js version and package manager to install within the toolchain, as moon _does not_ -use a Node.js binary found on the local machine. Managing the Node.js version within the toolchain -ensures a deterministic environment across any machine (whether a developer, CI, or production -machine). - -### `version` - - - -Defines the explicit Node.js version to use. We require an explicit and semantic major, minor, and -patch version, to ensure the same environment is used across every machine. Ranges are _not_ -supported. - -```yaml title=".moon/workspace.yml" {2} -node: - version: '16.13.0' -``` - -> Version can be overridden with the `MOON_NODE_VERSION` environment variable. - -### `packageManager` - - - -Defines which package manager to utilize within the workspace. Supports `npm` (default), `pnpm`, or -`yarn`. - -```yaml title=".moon/workspace.yml" {2} -node: - packageManager: 'yarn' -``` - -### `npm`, `pnpm`, `yarn` - - - -Optional fields for defining package manager specific configuration. The chosen setting is dependent -on the value of [`node.packageManager`](#packagemanager). If these settings _are not defined_, the -latest version of the active package manager will be used (when applicable). - -#### `version` - - - -The `version` setting defines the explicit package manager version to use. We require an explicit -major, minor, and patch version, to ensure the same environment is used across every machine. - -```yaml title=".moon/workspace.yml" {4} -node: - packageManager: 'yarn' - yarn: - version: '3.1.0' -``` - -> Version can be overridden with the `MOON_NPM_VERSION`, `MOON_PNPM_VERSION`, or `MOON_YARN_VERSION` -> environment variables. - -### `yarn` - - - -#### `plugins` - - - -A list of plugins that will automatically be imported using `yarn plugin import` (Yarn 2+ only). For -performance reasons, plugins will only be imported when the Yarn version changes. - -```yaml title=".moon/workspace.yml" {4} -node: - packageManager: 'yarn' - yarn: - version: '3.1.0' - plugins: - - 'interactive-tools' - - 'workspace-tools' -``` - -### `addEnginesConstraint` - - - -Injects the currently configured [Node.js version](#version) as an `engines` constraint to the root -`package.json` field. Defaults to `true`. - -```yaml -node: - addEnginesConstraint: true -``` - -For example, say our Node.js version is "16.15.0", and when we execute a run process through the -`moon` binary, it will update the root `package.json` with the below. We pin a fixed version to -ensure other Node.js processes outside of our toolchain are utilizing the same version. - -```json title="package.json" -{ - // ... - "engines": { - "node": "16.15.0" - } -} -``` - -### `aliasPackageNames` - - - -When enabled, will assign [aliases](../concepts/project#aliases) to configured [projects](#projects) -based on the `name` field in the project's `package.json`. Aliases can be used as a substitute for -project names, allowing for the familiar package name to be used within -[targets](../concepts/target) or configuration. - -This setting accepts one of the following values, which determines how to parse and assign the -alias. - -- `name-and-scope` - Will use the package name as-is, including any scope. For example, - `@scope/example` or `example`. -- `name-only` - Will only use the name and disregard any scope. For example, `@scope/example` will - become `example`. - -```yaml title=".moon/workspace.yml" {2} -node: - aliasPackageNames: 'name-only' -``` - -### `binExecArgs` - - - -Additional [command line arguments](https://nodejs.org/api/cli.html) to pass to the `node` binary -when it's being executed by running a target. This will apply arguments to _all Node.js based_ -targets, and cannot be changed on a per target basis. - -```yaml title=".moon/workspace.yml" {2-5} -node: - binExecArgs: - - '--preserve-symlinks' - - '--loader' - - '@boost/module/loader' -``` - -### `dedupeOnLockfileChange` - - - -Will dedupe dependencies after they have been installed, added, removing, or changed in any way, in -an effort to keep the workspace tree as clean and lean as possible. Defaults to `true`. - -```yaml title=".moon/workspace.yml" {2} -node: - dedupeOnLockfileChange: true -``` - -### `dependencyVersionFormat` - - - -When [syncing project dependencies](#syncprojectworkspacedependencies), customize the format that -will be used for the dependency version range. The following formats are supported (but use the one -most applicable to your chosen package manager): - -- `file` - Uses `file:../relative/path` and copies package contents. -- `link` - Uses `link:../relative/path` and symlinks package contents. -- `star` - Uses an explicit `*`. -- `version` - Uses the explicit version from the dependent project's `package.json`, e.g., "1.2.3". -- `version-caret` - Uses the version from the dependent project's `package.json` as a caret range, - e.g., "^1.2.3". -- `version-tilde` - Uses the version from the dependent project's `package.json` as a tilde range, - e.g., "~1.2.3". -- `workspace` (default) - Uses `workspace:*`, which resolves to "1.2.3". Requires package - workspaces. -- `workspace-caret` - Uses `workspace:^`, which resolves to "^1.2.3". Requires package workspaces. -- `workspace-tilde` - Uses `workspace:~`, which resolves to "~1.2.3". Requires package workspaces. - -```yaml title=".moon/workspace.yml" {2} -node: - dependencyVersionFormat: 'link' -``` - -> This setting does not apply to peer dependencies, as they will always use a format of -> `^.0.0`. - -### `inferTasksFromScripts` - - - -Will infer and automatically create [tasks](../concepts/task) from `package.json` scripts. Defaults -to `false`. - -This requires the [project's language](./project#language) to be "javascript" or "typescript", a -`package.json` to exist in the project, and will take the following into account: - -- Script names will be converted to kebab-case, and will become the task ID. -- Pre, post, and life cycle hooks are ignored. -- Tasks defined in `.moon/project.yml` or `moon.yml` take precedence over scripts of the same name. - -To verify inferred tasks, run [`moon project `](../commands/project) (pass `--json` to view raw -config and options). Tasks that are inferred will have their command and args set to -`moon node run-script`. - -```yaml title=".moon/workspace.yml" {2} -node: - inferTasksFromScripts: true -``` - -:::caution - -This implementation shares functionality with -[`moon migrate from-package-json`](../commands/migrate/from-package-json), and will attempt to -determine environment variables, outputs, CI options, and more! Be aware of these when utilizing -this feature, especially in regards to `runInCI`, as it may be inaccurate! - -::: - -### `syncProjectWorkspaceDependencies` - - - -Will sync a project's [`dependsOn`](./project#dependson) setting as normal dependencies within the -project's `package.json`. If a dependent project does not have a `package.json`, or if a dependency -of the same name has an explicit version already defined, the sync will be skipped. Defaults to -`true`. - -```yaml title=".moon/workspace.yml" {2} -node: - syncProjectWorkspaceDependencies: true -``` - -A quick example on how this works. Given the following `dependsOn`: - -```yaml title="moon.yml" -dependsOn: - - 'designSystem' - - 'reactHooks' -``` - -Would result in the following `dependencies` within a project's `package.json`. The version format -can be customized with [`node.dependencyVersionFormat`](#dependencyversionformat). - -```json title="package.json" -{ - // ... - "dependencies": { - "@company/design-system": "workspace:*", - "@company/react-hooks": "workspace:*" - // ... - } -} -``` - -### `syncVersionManagerConfig` - - - -Will sync the currently configured [Node.js version](#version) to a 3rd-party version manager's -config/rc file. Supports "nodenv" (syncs to `.node-version`), "nvm" (syncs to `.nvmrc`), or none -(default). - -```yaml title=".moon/workspace.yml" {2} -node: - syncVersionManagerConfig: 'nvm' -``` - -This is a special setting that ensure other Node.js processes outside of our toolchain are utilizing -the same version, which is a very common practice when managing dependencies. - -## `typescript` - - - -Dictates how moon interacts with and utilizes TypeScript within the workspace. This field is -optional and is undefined by default. Define it to enable TypeScript support. - -### `createMissingConfig` - - - -When [syncing project references](#syncprojectreferences) and a depended on project _does not_ have -a `tsconfig.json`, automatically create one. Defaults to `true`. - -```yaml title=".moon/workspace.yml" {2} -typescript: - createMissingConfig: true -``` - -### `projectConfigFileName` - - - -Defines the file name of the `tsconfig.json` found in the project root. We utilize this setting when -syncing project references between projects. Defaults to `tsconfig.json`. - -```yaml title=".moon/workspace.yml" {2} -typescript: - projectConfigFileName: 'tsconfig.build.json' -``` - -### `rootConfigFileName` - - - -Defines the file name of the `tsconfig.json` found in the workspace root. We utilize this setting -when syncing projects as references. Defaults to `tsconfig.json`. - -```yaml title=".moon/workspace.yml" {2} -typescript: - rootConfigFileName: 'tsconfig.projects.json' -``` - -### `rootOptionsConfigFileName` - - - -Defines the file name of the config file found in the workspace root that houses shared compiler -options. Defaults to `tsconfig.options.json`. This setting is used in the following scenarios: - -- When [creating a `tsconfig.json` for a project](#), sets the `extends` field to this value. - -```yaml title=".moon/workspace.yml" {2} -typescript: - rootOptionsConfigFileName: 'tsconfig.base.json' -``` - -### `routeOutDirToCache` - - - -Updates the `outDir` compiler option in each project's [`tsconfig.json`](#projectConfigFileName) to -route to moon's cache folder. This is useful when using project references and wanting to keep all -the compiled `.d.ts` files _out_ of the project folder. Defaults to `false`. - -```yaml title=".moon/workspace.yml" {2} -typescript: - routeOutDirToCache: true -``` - -As a demonstration, if we had an npm package located at "packages/components", the `outDir` compiler -option will be re-routed to the following when syncing. - -```json title="/tsconfig.json" -{ - // ... - "compilerOptions": { - // ... - "outDir": "../../.moon/cache/types/packages/components" - } -} -``` - -### `syncProjectReferences` - - - -Will sync a project's [dependencies](../concepts/project#dependencies) (when applicable) as project -references within that project's `tsconfig.json`, and the workspace root `tsconfig.json`. Defaults -to `true` when the parent `typescript` setting is defined, otherwise `false`. - -```yaml title=".moon/workspace.yml" {2} -typescript: - syncProjectReferences: true -``` - -A quick example on how this works. Given the following `dependsOn`: - -```yaml title="moon.yml" -dependsOn: - - 'designSystem' - - 'reactHooks' -``` - -Would result in the following `references` within both `tsconfig.json`s. - -```json title="tsconfig.json" -{ - // ... - "references": [ - // ... - { "path": "../../design-system" }, - { "path": "../../react-hooks" } - ] -} -``` - -### `syncProjectReferencesToPaths` - - - -Will sync a project's [`tsconfig.json`](#projectConfigFileName) project references to the `paths` -compiler option, using the referenced project's `package.json` name. This is useful for mapping -import aliases to their source code. Defaults to `false`. - -```yaml title=".moon/workspace.yml" {2} -typescript: - syncProjectReferencesToPaths: true -``` - -As a demonstration, if we had a reference to a shared npm package with the name `@brand/components`, -the `paths` compiler option would be updated to the following when syncing. The index file may exist -in a `src` folder, or the root of the package. - -```json title="/tsconfig.json" -{ - // ... - "compilerOptions": { - // ... - "paths": { - "@brand/components": ["../shared/components/src/index.ts"], - "@brand/components/*": ["../shared/components/src/*"] - } - }, - "references": [ - { - "path": "../shared/components" - } - ] -} -``` - -> This setting runs _after_ [`syncProjectReferences`](#syncprojectreferences) and will inherit any -> synced references from that setting. - -## Features - ## `generator` @@ -629,6 +199,7 @@ runner: implicitInputs: - 'package.json' - '/.moon/project.yml' + - '/.moon/toolchain.yml' - '/.moon/workspace.yml' ``` diff --git a/website/docs/create-project.mdx b/website/docs/create-project.mdx index a343bb0832f..a8bb8cea35b 100644 --- a/website/docs/create-project.mdx +++ b/website/docs/create-project.mdx @@ -43,7 +43,7 @@ to not manually curate the projects list! :::info Want to use `package.json` names? Enable the -[`node.aliasPackageNames`](./config/workspace#aliaspackagenames) setting! +[`node.aliasPackageNames`](./config/toolchain#aliaspackagenames) setting! ::: diff --git a/website/docs/create-task.mdx b/website/docs/create-task.mdx index 4e78580bc64..624c3266ff1 100644 --- a/website/docs/create-task.mdx +++ b/website/docs/create-task.mdx @@ -139,7 +139,7 @@ expecting some repository state or artifact to exist, can be achieved with the [`deps`](./config/project#deps) setting, which requires a list of [targets](./concepts/target): - `:` - Full canonical target. -- `~:` - A task within the current project. +- `~:` or `` - A task within the current project. - `^:` - A task from all [depended on projects](./concepts/project#dependencies). ```yaml diff --git a/website/docs/faq.mdx b/website/docs/faq.mdx index da0f32e5a70..5d1ee9bd5f8 100644 --- a/website/docs/faq.mdx +++ b/website/docs/faq.mdx @@ -60,10 +60,10 @@ and provides us with the following: not language specific semantics. This field also easily populates the dependency/project graphs. - For JavaScript projects: - `package.json` dependencies (via `dependsOn`) are kept in sync when - [`node.syncProjectWorkspaceDependencies`](./config/workspace#syncprojectworkspacedependencies) + [`node.syncProjectWorkspaceDependencies`](./config/toolchain#syncprojectworkspacedependencies) is enabled. - `tsconfig.json` project references (via `dependsOn`) are kept in sync when - [`typescript.syncProjectReferences`](./config/workspace#syncprojectreferences) is enabled. + [`typescript.syncProjectReferences`](./config/toolchain#syncprojectreferences) is enabled. By using moon as the source of truth, we can ensure a healthy repository, by accurately keeping everything in sync, and modifying project/language configuration to operate effectively. @@ -197,7 +197,7 @@ receive the benefits of the toolchain. Some of which are: We encourage everyone to define tasks in a [`moon.yml`](./config/project#tasks) file, as it allows for additional metadata like `inputs`, `outputs`, `options`, and more. However, if you'd like to keep using `package.json` scripts, enable the -[`node.inferTasksFromScripts`](./config/workspace#infertasksfromscripts) setting. +[`node.inferTasksFromScripts`](./config/toolchain#infertasksfromscripts) setting. View the [official documentation](./migrate-to-moon) for more information on this approach, including risks, disadvantages, and caveats. diff --git a/website/docs/guides/examples/astro.mdx b/website/docs/guides/examples/astro.mdx index c472a8bc2fd..fb901f07e63 100644 --- a/website/docs/guides/examples/astro.mdx +++ b/website/docs/guides/examples/astro.mdx @@ -62,7 +62,7 @@ tasks: - '~:build' local: true -workspace: +toolchain: # Disable project references typescript: false ``` diff --git a/website/docs/guides/examples/typescript.mdx b/website/docs/guides/examples/typescript.mdx index 7fd619ac232..067c7ad8bbb 100644 --- a/website/docs/guides/examples/typescript.mdx +++ b/website/docs/guides/examples/typescript.mdx @@ -94,9 +94,9 @@ editors and tooling for deep integrations. } ``` -> The [`typescript.rootConfigFileName`](../../config/workspace#rootconfigfilename) setting can be +> The [`typescript.rootConfigFileName`](../../config/toolchain#rootconfigfilename) setting can be > used to change the root-level config name and the -> [`typescript.syncProjectReferences`](../../config/workspace#syncprojectreferences) setting will +> [`typescript.syncProjectReferences`](../../config/toolchain#syncprojectreferences) setting will > automatically keep project references in sync! ### Project-level @@ -119,7 +119,7 @@ Every project will require a `tsconfig.json`, as TypeScript itself requires it. } ``` -> The [`typescript.projectConfigFileName`](../../config/workspace#projectconfigfilename) setting can +> The [`typescript.projectConfigFileName`](../../config/toolchain#projectconfigfilename) setting can > be used to change the project-level config name. ### Sharing diff --git a/website/docs/guides/javascript/typescript-project-refs.mdx b/website/docs/guides/javascript/typescript-project-refs.mdx index a1708665589..4efa193e09b 100644 --- a/website/docs/guides/javascript/typescript-project-refs.mdx +++ b/website/docs/guides/javascript/typescript-project-refs.mdx @@ -31,7 +31,7 @@ This all sounds amazing but there's got to be some downsides right? Unfortunatel - Project references require generating declarations to resolve type information correctly. This results in a lot of compilation artifacts littered throughout the repository. There - [are ways](#gitignore) [around this](../../config/workspace#routeoutdirtocache). + [are ways](#gitignore) [around this](../../config/toolchain#routeoutdirtocache). - This approach is a bit involved and may require some cognitive overhead based on your current level of TypeScript tooling knowledge. @@ -103,9 +103,9 @@ In the end, this file should only contain 3 fields: `extends`, `files` (an empty ``` > When using moon, the -> [`typescript.syncProjectReferences`](../../config/workspace#syncprojectreferences) setting will +> [`typescript.syncProjectReferences`](../../config/toolchain#syncprojectreferences) setting will > keep this `references` list automatically in sync, and the name of the file can be customized with -> [`typescript.rootConfigFileName`](../../config/workspace#rootconfigfilename). +> [`typescript.rootConfigFileName`](../../config/toolchain#rootconfigfilename). #### `tsconfig.options.json` @@ -146,7 +146,7 @@ defines common compiler options and may be used here. ``` > When using moon, the name of the file can be customized with -> [`typescript.rootOptionsConfigFileName`](../../config/workspace#rootoptionsconfigfilename). +> [`typescript.rootOptionsConfigFileName`](../../config/toolchain#rootoptionsconfigfilename). ##### ECMAScript interoperability @@ -195,7 +195,7 @@ common compiler options, define its own compiler options (below), define include necessary references. > When using moon, the name of the file can be customized with -> [`typescript.projectConfigFileName`](../../config/workspace#projectconfigfilename). +> [`typescript.projectConfigFileName`](../../config/toolchain#projectconfigfilename). > When using moon, the `outDir` can automatically be re-routed to a shared cache using -> [`typescript.routeOutDirToCache`](../../config/workspace#routeoutdirtocache), to avoid littering +> [`typescript.routeOutDirToCache`](../../config/toolchain#routeoutdirtocache), to avoid littering > the repository with compilation artifacts. ##### Includes and excludes @@ -291,7 +291,7 @@ boundary. ``` > When using moon, the -> [`typescript.syncProjectReferences`](../../config/workspace#syncprojectreferences) setting will +> [`typescript.syncProjectReferences`](../../config/toolchain#syncprojectreferences) setting will > keep this `references` list automatically in sync. #### `tsconfig.*.json` @@ -491,7 +491,7 @@ defining a `paths` alias that maps the `package.json` name to its source files, ``` > When using moon, the -> [`typescript.syncProjectReferencesToPaths`](../../config/workspace#syncprojectreferencestopaths) +> [`typescript.syncProjectReferencesToPaths`](../../config/toolchain#syncprojectreferencestopaths) > setting will automatically create `paths` based on the local references. ## Sharing and augmenting types diff --git a/website/docs/guides/sharing-config.mdx b/website/docs/guides/sharing-config.mdx index f4782b12a54..054e039687e 100644 --- a/website/docs/guides/sharing-config.mdx +++ b/website/docs/guides/sharing-config.mdx @@ -7,7 +7,8 @@ you'll want to use the same configuration across all repositories for consistenc the maintenance burden while ensuring a similar developer experience. To help streamline this process, moon provides an `extends` setting in both -[`.moon/workspace.yml`](../config/workspace#extends) and +[`.moon/workspace.yml`](../config/workspace#extends), +[`.moon/toolchain.yml`](../config/toolchain#extends), and [`.moon/project.yml`](../config/global-project#extends). This setting requires a HTTPS URL _or_ relative file system path that points to a valid YAML document for the configuration in question. diff --git a/website/docs/install.mdx b/website/docs/install.mdx index 4b49dd9c198..a2de89fc6bd 100644 --- a/website/docs/install.mdx +++ b/website/docs/install.mdx @@ -209,8 +209,9 @@ $ moon init When executed, the following operations will be applied. -- Creates a `.moon` folder with associated [`.moon/workspace.yml`](./config/workspace) and - [`.moon/project.yml`](./config/global-project) configuration files. +- Creates a `.moon` folder with associated [`.moon/workspace.yml`](./config/workspace), + [`.moon/toolchain.yml`](./config/toolchain), and [`.moon/project.yml`](./config/global-project) + configuration files. - Appends necessary ignore patterns to the relative `.gitignore`. - Infers the Node.js version from any `.nvmrc` or `.node-version` file. - Infers the package manager based on any existing config and lock files. diff --git a/website/docs/intro.mdx b/website/docs/intro.mdx index 08fd6cd2861..bcd06dcc906 100644 --- a/website/docs/intro.mdx +++ b/website/docs/intro.mdx @@ -32,8 +32,8 @@ and provide a first-class developer experience. - **Ensure correct versions** - Whether it's Node.js or npm, ensure the same version of each tool is the same across _every_ developer's environment. No more wasted hours of debugging. - **Automation built-in** - When applicable, moon will automatically install `node_modules`, or - [sync package dependencies](/docs/config/workspace#syncprojectworkspacedependencies), or even - [sync TypeScript project references](/docs/config/workspace#syncprojectreferences). + [sync package dependencies](/docs/config/toolchain#syncprojectworkspacedependencies), or even + [sync TypeScript project references](/docs/config/toolchain#syncprojectreferences). - And of course, the amazing list of features below! ## Features diff --git a/website/docs/migrate-to-moon.mdx b/website/docs/migrate-to-moon.mdx index e45c6e0e5bb..e8319bcdd05 100644 --- a/website/docs/migrate-to-moon.mdx +++ b/website/docs/migrate-to-moon.mdx @@ -32,7 +32,7 @@ _manually curating_ tasks, but the migrate command well get you most of the way! As a frontend developer you're already familiar with the Node.js ecosystem, specifically around defining and using `package.json` scripts, and you may not want to deviate from this. Don't worry, -simply enable the [`node.inferTasksFromScripts`](./config/workspace#infertasksfromscripts) setting +simply enable the [`node.inferTasksFromScripts`](./config/toolchain#infertasksfromscripts) setting to automatically create moon tasks from a project's scripts! These can then be ran with [`moon run`](./commands/run). diff --git a/website/docs/setup-workspace.mdx b/website/docs/setup-workspace.mdx index fa6b5c1976d..b76d3a6b459 100644 --- a/website/docs/setup-workspace.mdx +++ b/website/docs/setup-workspace.mdx @@ -23,15 +23,15 @@ denoted by the `.moon` folder -- this is known as the workspace root. The worksp The most important tool within moon and its toolchain is Node.js, as it's the backbone of a JavaScript based repository. Let's now define the Node.js version we want to install in the toolchain, enforce for developers, and to utilize when running `moon` commands, by updating -[`node.version`](./config/workspace#version) in [`.moon/workspace.yml`](./config/workspace). +[`node.version`](./config/toolchain#version) in [`.moon/toolchain.yml`](./config/toolchain). This setting requires an explicit semantic version and _does not_ support version ranges, so let's set it to the latest version. We suggest _always_ using an [Active LTS](https://nodejs.org/en/about/releases/) version. -```yaml title=".moon/workspace.yml" +```yaml title=".moon/toolchain.yml" node: - version: '16.15.0' + version: '18.0.0' ``` Let's now run [`moon --log debug setup`](./commands/setup) to verify that Node.js is downloaded and @@ -40,7 +40,7 @@ installed correctly. Pretty cool right? :::info The Node.js version can also be customized _per project_ using the -[`workspace.node.version`](./config/project#node) setting in [`moon.yml`](./config/project). This +[`toolchain.node.version`](./config/project#node) setting in [`moon.yml`](./config/project). This setting exists to support legacy projects that are coupled to an old version and are unable to upgrade. We suggest keeping all projects on the same version whenever possible. @@ -50,21 +50,21 @@ upgrade. We suggest keeping all projects on the same version whenever possible. Even though Node.js is now installed, we need a package manager to install dependencies. During installation, we talked about [choosing a package manager](./install#choosing-a-package-manager), so -let's use that choice here by defining [`node.packageManager`](./config/workspace#packagemanager). +let's use that choice here by defining [`node.packageManager`](./config/toolchain#packagemanager). -```yaml title=".moon/workspace.yml" +```yaml title=".moon/toolchain.yml" node: - version: '16.15.0' + version: '18.0.0' packageManager: 'yarn' ``` By default moon will install the latest version of a package manager, but this isn't consistently updated, so we suggest defining an explicit semantic version for the package manager as well, -through the [`node..version`](./config/workspace#version-1) setting. +through the [`node..version`](./config/toolchain#version-1) setting. -```yaml title=".moon/workspace.yml" +```yaml title=".moon/toolchain.yml" node: - version: '16.15.0' + version: '18.0.0' packageManager: 'yarn' yarn: version: '3.2.0' @@ -126,6 +126,15 @@ vcs: ), url: './config/workspace', }, + { + icon: 'toolchain-config', + label: ( + + Configure .moon/toolchain.yml further + + ), + url: './config/toolchain', + }, { icon: 'workspace', label: 'Learn about the workspace', url: './concepts/workspace' }, { icon: 'toolchain', label: 'Learn about the toolchain', url: './concepts/toolchain' }, ]} diff --git a/website/sidebars.js b/website/sidebars.js index e0fbaad612b..02359ea8671 100644 --- a/website/sidebars.js +++ b/website/sidebars.js @@ -43,7 +43,13 @@ const sidebars = { { type: 'category', label: 'Config files', - items: ['config/workspace', 'config/global-project', 'config/project', 'config/template'], + items: [ + 'config/workspace', + 'config/toolchain', + 'config/global-project', + 'config/project', + 'config/template', + ], link: { type: 'generated-index', title: 'Config files', diff --git a/website/src/ui/iconography/ProductIcon.tsx b/website/src/ui/iconography/ProductIcon.tsx index 92e393ef2ad..730750e917f 100644 --- a/website/src/ui/iconography/ProductIcon.tsx +++ b/website/src/ui/iconography/ProductIcon.tsx @@ -7,6 +7,7 @@ import { faCirclePlus, faDiagramProject, faGrid2, + faScrewdriverWrench, faSliders, faSpaceStationMoonConstruction, faSquare, @@ -34,6 +35,7 @@ const icons = { 'task-config': faCircleBolt, token: faTriangle, toolchain: faToolbox, + 'toolchain-config': faScrewdriverWrench, twitter: faTwitter, workspace: faGrid2, 'workspace-config': faSliders, diff --git a/website/static/schemas/global-project.json b/website/static/schemas/global-project.json index 3a252a8f8b4..14629639608 100644 --- a/website/static/schemas/global-project.json +++ b/website/static/schemas/global-project.json @@ -55,6 +55,7 @@ "type": "object", "properties": { "args": { + "default": null, "anyOf": [ { "$ref": "#/definitions/TaskCommandArgs" @@ -65,6 +66,7 @@ ] }, "command": { + "default": null, "anyOf": [ { "$ref": "#/definitions/TaskCommandArgs" @@ -75,6 +77,7 @@ ] }, "deps": { + "default": null, "type": [ "array", "null" @@ -84,6 +87,7 @@ } }, "env": { + "default": null, "type": [ "object", "null" @@ -93,6 +97,7 @@ } }, "inputs": { + "default": null, "type": [ "array", "null" @@ -102,12 +107,33 @@ } }, "local": { + "default": false, "type": "boolean" }, "options": { - "$ref": "#/definitions/TaskOptionsConfig" + "default": { + "affectedFiles": null, + "cache": null, + "envFile": null, + "mergeArgs": null, + "mergeDeps": null, + "mergeEnv": null, + "mergeInputs": null, + "mergeOutputs": null, + "outputStyle": null, + "retryCount": null, + "runDepsInParallel": null, + "runInCI": null, + "runFromWorkspaceRoot": null + }, + "allOf": [ + { + "$ref": "#/definitions/TaskOptionsConfig" + } + ] }, "outputs": { + "default": null, "type": [ "array", "null" @@ -116,8 +142,13 @@ "type": "string" } }, - "type": { - "$ref": "#/definitions/PlatformType" + "platform": { + "default": "unknown", + "allOf": [ + { + "$ref": "#/definitions/PlatformType" + } + ] } } }, @@ -142,13 +173,22 @@ "TaskOptionsConfig": { "type": "object", "properties": { + "affectedFiles": { + "default": null, + "type": [ + "boolean", + "null" + ] + }, "cache": { + "default": null, "type": [ "boolean", "null" ] }, "envFile": { + "default": null, "anyOf": [ { "$ref": "#/definitions/TaskOptionEnvFile" @@ -159,6 +199,7 @@ ] }, "mergeArgs": { + "default": null, "anyOf": [ { "$ref": "#/definitions/TaskMergeStrategy" @@ -169,6 +210,7 @@ ] }, "mergeDeps": { + "default": null, "anyOf": [ { "$ref": "#/definitions/TaskMergeStrategy" @@ -179,6 +221,7 @@ ] }, "mergeEnv": { + "default": null, "anyOf": [ { "$ref": "#/definitions/TaskMergeStrategy" @@ -189,6 +232,7 @@ ] }, "mergeInputs": { + "default": null, "anyOf": [ { "$ref": "#/definitions/TaskMergeStrategy" @@ -199,6 +243,7 @@ ] }, "mergeOutputs": { + "default": null, "anyOf": [ { "$ref": "#/definitions/TaskMergeStrategy" @@ -209,6 +254,7 @@ ] }, "outputStyle": { + "default": null, "anyOf": [ { "$ref": "#/definitions/TaskOutputStyle" @@ -219,6 +265,7 @@ ] }, "retryCount": { + "default": null, "type": [ "integer", "null" @@ -227,18 +274,21 @@ "minimum": 0.0 }, "runDepsInParallel": { + "default": null, "type": [ "boolean", "null" ] }, "runFromWorkspaceRoot": { + "default": null, "type": [ "boolean", "null" ] }, "runInCI": { + "default": null, "type": [ "boolean", "null" diff --git a/website/static/schemas/project.json b/website/static/schemas/project.json index c88f5564f59..7c651163833 100644 --- a/website/static/schemas/project.json +++ b/website/static/schemas/project.json @@ -5,12 +5,14 @@ "type": "object", "properties": { "dependsOn": { + "default": [], "type": "array", "items": { "$ref": "#/definitions/ProjectDependsOn" } }, "fileGroups": { + "default": {}, "type": "object", "additionalProperties": { "type": "array", @@ -20,9 +22,15 @@ } }, "language": { - "$ref": "#/definitions/ProjectLanguage" + "default": "unknown", + "allOf": [ + { + "$ref": "#/definitions/ProjectLanguage" + } + ] }, "project": { + "default": null, "anyOf": [ { "$ref": "#/definitions/ProjectMetadataConfig" @@ -33,16 +41,35 @@ ] }, "tasks": { + "default": {}, "type": "object", "additionalProperties": { "$ref": "#/definitions/TaskConfig" } }, "type": { - "$ref": "#/definitions/ProjectType" + "default": "unknown", + "allOf": [ + { + "$ref": "#/definitions/ProjectType" + } + ] }, "workspace": { - "$ref": "#/definitions/ProjectWorkspaceConfig" + "default": { + "inheritedTasks": { + "exclude": null, + "include": null, + "rename": null + }, + "node": null, + "typescript": true + }, + "allOf": [ + { + "$ref": "#/definitions/ProjectWorkspaceConfig" + } + ] } }, "definitions": { @@ -142,9 +169,19 @@ "type": "object", "properties": { "inheritedTasks": { - "$ref": "#/definitions/ProjectWorkspaceInheritedTasksConfig" + "default": { + "exclude": null, + "include": null, + "rename": null + }, + "allOf": [ + { + "$ref": "#/definitions/ProjectWorkspaceInheritedTasksConfig" + } + ] }, "node": { + "default": null, "anyOf": [ { "$ref": "#/definitions/ProjectWorkspaceNodeConfig" @@ -164,6 +201,7 @@ "type": "object", "properties": { "exclude": { + "default": null, "type": [ "array", "null" @@ -173,6 +211,7 @@ } }, "include": { + "default": null, "type": [ "array", "null" @@ -182,6 +221,7 @@ } }, "rename": { + "default": null, "type": [ "object", "null" @@ -196,6 +236,7 @@ "type": "object", "properties": { "version": { + "default": null, "type": [ "string", "null" @@ -220,6 +261,7 @@ "type": "object", "properties": { "args": { + "default": null, "anyOf": [ { "$ref": "#/definitions/TaskCommandArgs" @@ -230,6 +272,7 @@ ] }, "command": { + "default": null, "anyOf": [ { "$ref": "#/definitions/TaskCommandArgs" @@ -240,6 +283,7 @@ ] }, "deps": { + "default": null, "type": [ "array", "null" @@ -249,6 +293,7 @@ } }, "env": { + "default": null, "type": [ "object", "null" @@ -258,6 +303,7 @@ } }, "inputs": { + "default": null, "type": [ "array", "null" @@ -267,12 +313,33 @@ } }, "local": { + "default": false, "type": "boolean" }, "options": { - "$ref": "#/definitions/TaskOptionsConfig" + "default": { + "affectedFiles": null, + "cache": null, + "envFile": null, + "mergeArgs": null, + "mergeDeps": null, + "mergeEnv": null, + "mergeInputs": null, + "mergeOutputs": null, + "outputStyle": null, + "retryCount": null, + "runDepsInParallel": null, + "runInCI": null, + "runFromWorkspaceRoot": null + }, + "allOf": [ + { + "$ref": "#/definitions/TaskOptionsConfig" + } + ] }, "outputs": { + "default": null, "type": [ "array", "null" @@ -281,8 +348,13 @@ "type": "string" } }, - "type": { - "$ref": "#/definitions/PlatformType" + "platform": { + "default": "unknown", + "allOf": [ + { + "$ref": "#/definitions/PlatformType" + } + ] } } }, @@ -307,13 +379,22 @@ "TaskOptionsConfig": { "type": "object", "properties": { + "affectedFiles": { + "default": null, + "type": [ + "boolean", + "null" + ] + }, "cache": { + "default": null, "type": [ "boolean", "null" ] }, "envFile": { + "default": null, "anyOf": [ { "$ref": "#/definitions/TaskOptionEnvFile" @@ -324,6 +405,7 @@ ] }, "mergeArgs": { + "default": null, "anyOf": [ { "$ref": "#/definitions/TaskMergeStrategy" @@ -334,6 +416,7 @@ ] }, "mergeDeps": { + "default": null, "anyOf": [ { "$ref": "#/definitions/TaskMergeStrategy" @@ -344,6 +427,7 @@ ] }, "mergeEnv": { + "default": null, "anyOf": [ { "$ref": "#/definitions/TaskMergeStrategy" @@ -354,6 +438,7 @@ ] }, "mergeInputs": { + "default": null, "anyOf": [ { "$ref": "#/definitions/TaskMergeStrategy" @@ -364,6 +449,7 @@ ] }, "mergeOutputs": { + "default": null, "anyOf": [ { "$ref": "#/definitions/TaskMergeStrategy" @@ -374,6 +460,7 @@ ] }, "outputStyle": { + "default": null, "anyOf": [ { "$ref": "#/definitions/TaskOutputStyle" @@ -384,6 +471,7 @@ ] }, "retryCount": { + "default": null, "type": [ "integer", "null" @@ -392,18 +480,21 @@ "minimum": 0.0 }, "runDepsInParallel": { + "default": null, "type": [ "boolean", "null" ] }, "runFromWorkspaceRoot": { + "default": null, "type": [ "boolean", "null" ] }, "runInCI": { + "default": null, "type": [ "boolean", "null" diff --git a/website/static/schemas/toolchain.json b/website/static/schemas/toolchain.json new file mode 100644 index 00000000000..611ea60a1a7 --- /dev/null +++ b/website/static/schemas/toolchain.json @@ -0,0 +1,250 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "ToolchainConfig", + "description": "Docs: https://moonrepo.dev/docs/config/toolchain", + "type": "object", + "properties": { + "extends": { + "default": null, + "type": [ + "string", + "null" + ] + }, + "node": { + "default": null, + "anyOf": [ + { + "$ref": "#/definitions/NodeConfig" + }, + { + "type": "null" + } + ] + }, + "typescript": { + "default": null, + "anyOf": [ + { + "$ref": "#/definitions/TypeScriptConfig" + }, + { + "type": "null" + } + ] + } + }, + "definitions": { + "NodeConfig": { + "type": "object", + "properties": { + "addEnginesConstraint": { + "default": true, + "type": "boolean" + }, + "aliasPackageNames": { + "default": null, + "anyOf": [ + { + "$ref": "#/definitions/NodeProjectAliasFormat" + }, + { + "type": "null" + } + ] + }, + "binExecArgs": { + "default": [], + "type": "array", + "items": { + "type": "string" + } + }, + "dedupeOnLockfileChange": { + "default": true, + "type": "boolean" + }, + "dependencyVersionFormat": { + "default": "workspace-caret", + "allOf": [ + { + "$ref": "#/definitions/NodeVersionFormat" + } + ] + }, + "inferTasksFromScripts": { + "default": false, + "type": "boolean" + }, + "npm": { + "default": { + "version": "8.19.2" + }, + "allOf": [ + { + "$ref": "#/definitions/NpmConfig" + } + ] + }, + "packageManager": { + "default": "npm", + "allOf": [ + { + "$ref": "#/definitions/NodePackageManager" + } + ] + }, + "pnpm": { + "default": null, + "anyOf": [ + { + "$ref": "#/definitions/PnpmConfig" + }, + { + "type": "null" + } + ] + }, + "syncProjectWorkspaceDependencies": { + "default": true, + "type": "boolean" + }, + "syncVersionManagerConfig": { + "default": null, + "anyOf": [ + { + "$ref": "#/definitions/NodeVersionManager" + }, + { + "type": "null" + } + ] + }, + "version": { + "default": "18.12.0", + "type": "string" + }, + "yarn": { + "default": null, + "anyOf": [ + { + "$ref": "#/definitions/YarnConfig" + }, + { + "type": "null" + } + ] + } + } + }, + "NodePackageManager": { + "type": "string", + "enum": [ + "npm", + "pnpm", + "yarn" + ] + }, + "NodeProjectAliasFormat": { + "type": "string", + "enum": [ + "name-and-scope", + "name-only" + ] + }, + "NodeVersionFormat": { + "type": "string", + "enum": [ + "file", + "link", + "star", + "version", + "version-caret", + "version-tilde", + "workspace", + "workspace-caret", + "workspace-tilde" + ] + }, + "NodeVersionManager": { + "type": "string", + "enum": [ + "nodenv", + "nvm" + ] + }, + "NpmConfig": { + "type": "object", + "properties": { + "version": { + "default": "8.19.2", + "type": "string" + } + } + }, + "PnpmConfig": { + "type": "object", + "required": [ + "version" + ], + "properties": { + "version": { + "type": "string" + } + } + }, + "TypeScriptConfig": { + "type": "object", + "properties": { + "createMissingConfig": { + "default": true, + "type": "boolean" + }, + "projectConfigFileName": { + "default": "tsconfig.json", + "type": "string" + }, + "rootConfigFileName": { + "default": "tsconfig.json", + "type": "string" + }, + "rootOptionsConfigFileName": { + "default": "tsconfig.options.json", + "type": "string" + }, + "routeOutDirToCache": { + "default": false, + "type": "boolean" + }, + "syncProjectReferences": { + "default": true, + "type": "boolean" + }, + "syncProjectReferencesToPaths": { + "default": false, + "type": "boolean" + } + } + }, + "YarnConfig": { + "type": "object", + "required": [ + "version" + ], + "properties": { + "plugins": { + "type": [ + "array", + "null" + ], + "items": { + "type": "string" + } + }, + "version": { + "type": "string" + } + } + } + } +} \ No newline at end of file diff --git a/website/static/schemas/workspace.json b/website/static/schemas/workspace.json index fdc06296e3a..e8f7996f5e6 100644 --- a/website/static/schemas/workspace.json +++ b/website/static/schemas/workspace.json @@ -33,17 +33,6 @@ } ] }, - "node": { - "default": null, - "anyOf": [ - { - "$ref": "#/definitions/NodeConfig" - }, - { - "type": "null" - } - ] - }, "notifier": { "default": { "webhookUrl": null @@ -80,21 +69,14 @@ } ] }, - "typescript": { - "default": null, - "anyOf": [ - { - "$ref": "#/definitions/TypeScriptConfig" - }, - { - "type": "null" - } - ] - }, "vcs": { "default": { + "defaultBranch": "master", "manager": "git", - "defaultBranch": "master" + "remoteCandidates": [ + "origin", + "upstream" + ] }, "allOf": [ { @@ -138,137 +120,6 @@ "performance" ] }, - "NodeConfig": { - "type": "object", - "properties": { - "addEnginesConstraint": { - "default": true, - "type": "boolean" - }, - "aliasPackageNames": { - "default": null, - "anyOf": [ - { - "$ref": "#/definitions/NodeProjectAliasFormat" - }, - { - "type": "null" - } - ] - }, - "dedupeOnLockfileChange": { - "default": true, - "type": "boolean" - }, - "dependencyVersionFormat": { - "default": "workspace-caret", - "allOf": [ - { - "$ref": "#/definitions/NodeVersionFormat" - } - ] - }, - "inferTasksFromScripts": { - "default": false, - "type": "boolean" - }, - "npm": { - "default": { - "version": "inherit" - }, - "allOf": [ - { - "$ref": "#/definitions/NpmConfig" - } - ] - }, - "packageManager": { - "default": "npm", - "allOf": [ - { - "$ref": "#/definitions/NodePackageManager" - } - ] - }, - "pnpm": { - "default": null, - "anyOf": [ - { - "$ref": "#/definitions/PnpmConfig" - }, - { - "type": "null" - } - ] - }, - "syncProjectWorkspaceDependencies": { - "default": true, - "type": "boolean" - }, - "syncVersionManagerConfig": { - "default": null, - "anyOf": [ - { - "$ref": "#/definitions/NodeVersionManager" - }, - { - "type": "null" - } - ] - }, - "version": { - "default": "16.17.0", - "type": "string" - }, - "yarn": { - "default": null, - "anyOf": [ - { - "$ref": "#/definitions/YarnConfig" - }, - { - "type": "null" - } - ] - } - } - }, - "NodePackageManager": { - "type": "string", - "enum": [ - "npm", - "pnpm", - "yarn" - ] - }, - "NodeProjectAliasFormat": { - "type": "string", - "enum": [ - "name-and-scope", - "name-only" - ] - }, - "NodeVersionFormat": { - "type": "string", - "enum": [ - "file", - "link", - "star", - "version", - "version-caret", - "version-tilde", - "workspace", - "workspace-caret", - "workspace-tilde" - ] - }, - "NodeVersionManager": { - "type": "string", - "enum": [ - "nodenv", - "nvm" - ] - }, "NotifierConfig": { "type": "object", "properties": { @@ -281,26 +132,6 @@ } } }, - "NpmConfig": { - "type": "object", - "properties": { - "version": { - "default": "inherit", - "type": "string" - } - } - }, - "PnpmConfig": { - "type": "object", - "required": [ - "version" - ], - "properties": { - "version": { - "type": "string" - } - } - }, "RunnerConfig": { "type": "object", "properties": { @@ -336,39 +167,6 @@ } } }, - "TypeScriptConfig": { - "type": "object", - "properties": { - "createMissingConfig": { - "default": true, - "type": "boolean" - }, - "projectConfigFileName": { - "default": "tsconfig.json", - "type": "string" - }, - "rootConfigFileName": { - "default": "tsconfig.json", - "type": "string" - }, - "rootOptionsConfigFileName": { - "default": "tsconfig.options.json", - "type": "string" - }, - "routeOutDirToCache": { - "default": false, - "type": "boolean" - }, - "syncProjectReferences": { - "default": true, - "type": "boolean" - }, - "syncProjectReferencesToPaths": { - "default": false, - "type": "boolean" - } - } - }, "VcsConfig": { "type": "object", "properties": { @@ -383,6 +181,16 @@ "$ref": "#/definitions/VcsManager" } ] + }, + "remoteCandidates": { + "default": [ + "origin", + "upstream" + ], + "type": "array", + "items": { + "type": "string" + } } } }, @@ -395,6 +203,27 @@ }, "WorkspaceProjects": { "anyOf": [ + { + "type": "object", + "required": [ + "globs", + "sources" + ], + "properties": { + "globs": { + "type": "array", + "items": { + "type": "string" + } + }, + "sources": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + }, { "type": "array", "items": { @@ -408,26 +237,6 @@ } } ] - }, - "YarnConfig": { - "type": "object", - "required": [ - "version" - ], - "properties": { - "plugins": { - "type": [ - "array", - "null" - ], - "items": { - "type": "string" - } - }, - "version": { - "type": "string" - } - } } } } \ No newline at end of file